[WIP] feat: virtual text columns + headers #667
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I'm a huge fan of oil, I use it constantly. Recently I turned on some of the metadata columns though and they've been bugging me enough that I desperately want to fix these problems:
A - Metadata columns should be able to be on the right (I totally agree with #496)
B - Columns should be able to have headers
C - metadata columns should be formattable with Lua functions
I previously tried to hack together a fix for B over here: #662 but it was pretty half baked and also only partially solved these problems for me.
So instead I set out on the goal of achieving all of the above in one go, by moving all the immutable metadata columns into virtual text. With virtual text, the constraint on the filename being at the end of a line and the constraint on column formats being parseable via string formats go away. The header row could still in theory be added separately, but the implementation of a header row with/without virtual columns are pretty different so I figured it be best to knock them both out at once in the same PR.
This PR is still a WIP, but I figured I'd open a draft to motivate myself to keep working on it, and potentially get a little help from anyone else interested in fixing these issues.
The current implementation is mostly working pretty well, but there are a couple quirks I've discovered about virtual text in neovim in the process of building it. I've documented some of the major learnings below to save anyone else wanting to dive in some time:
vim.api.nvim_win_get_cursorreturns the correct columnnormal! 0to trigger cursor moved events and whatnot in various places is required to get the cursor to behave as expectedAnyways, the included changes in this PR are the following: (again, still WIP)
virtual_text_columnstrue, immutable columns will be rendered with virtual textnamecolumn to be configured in the existingcolumnsconfig, so that virtual columns may be placed on the right side of the name columnshow_headertrue, an empty line will be added to the top of every oil buffer and a header row will be rendered there with virtual textconstrain_cursor, to prevent the header row from interfering with existing oil featuresheader_formatBIRTHTIMEand spit outCreated atto be rendered insteadformatin thecolumnsconfigvirtual_text_columnsis true, otherwise buffer text metadata columns must remain parseableX days agoHere's an example of what my oil buffers look like on this branch: