feat: add configurable file metadata column#54
feat: add configurable file metadata column#54Goutham-AR wants to merge 5 commits intocorwinm:mainfrom
Conversation
- Add MetadataColumn type and FileMetadata interface to constants.ts. - Extend OilState with a metadataCache field. Add metadataUtils.ts with fixed-width formatting helpers (formatSize, formatMtime, formatPermissions, formatMetadataColumns) and populateMetadataCache. - Add getColumnsSettings() to settings.ts. - Add peekOilState() to oilState.ts for use in the decoration layer. - Initialize metadataCache in both OilState init functions.
- Call populateMetadataCache at the end of getDirectoryListing when at least one non-icon column is configured. Clear the cache entry for the current directory on refresh, alongside visitedPaths. - Add oil-code.columns setting (array, default ["icon"]) with enum values icon/permissions/size/mtime. Register oil-code.toggleDetails command and alt+shift+d keybinding.
…mand Add columnState.ts with session-level getDetailsVisible/toggleDetailsVisible. - Add toggleDetails command that flips the flag and redraws all visible oil editors. - Update updateDecorations to inject metadata as before: virtual text at the filename start position when non-icon columns are configured and details are visible. Metadata is never written to buffer text, so the /NNN filename format and the save/diff pipeline are entirely unaffected. - Register oil-code.toggleDetails in extension.ts.
- Map <C-d> to oil-code.toggleDetails in both the neovim Lua autocmd block and the VSCodeVim normal-mode keymap registration. - Add three tests: toggleDetails executes without error, rename with metadata columns enabled does not corrupt file operations, and buffer text always stays in /NNN filename format regardless of columns setting.
corwinm
left a comment
There was a problem hiding this comment.
This looks really great so far, thank you! I added some comments for some improvements and I want to align the default keymaps so they don't conflict with the existing "" keymap.
Once those keymap changes are in place, we should update the README.md and help.ts content to include the new keymaps.
Thanks again! Overall this is really great work 😃
| map("n", "<C-t>", function() vscode.action('oil-code.selectTab') end) | ||
| map("n", "<C-l>", function() vscode.action('oil-code.refresh') end) | ||
| map("n", "`", function() vscode.action('oil-code.cd') end) | ||
| map("n", "<C-d>", function() vscode.action('oil-code.toggleDetails') end) |
There was a problem hiding this comment.
Let's change this to "gd" so it doesn't conflict with the default keybind for moving down half a page. This also aligns with the example https://github.com/stevearc/oil.nvim/blob/master/doc/recipes.md#toggle-file-detail-view
| case "mtime": | ||
| parts.push(meta.mtime); // always 12 chars | ||
| break; | ||
| // "icon" is not a metadata column — silently ignored |
There was a problem hiding this comment.
I think I will want to consolidate the two but that might have to be a follow up refactor unless you want to make that update.
| ); | ||
| if (!hasOilToggleDetailsBinding) { | ||
| updatedKeymap.push({ | ||
| before: ["<C-d>"], |
There was a problem hiding this comment.
Same as above, lets default to "gd" to not conflict with the default.
|
|
||
| for (const name of listings) { | ||
| if (name === "../") { | ||
| continue; |
| } | ||
| } | ||
|
|
||
| oilState.metadataCache.set(folderPathUri, fileMap); |
| metadataDecorationType = vscode.window.createTextEditorDecorationType({ | ||
| before: { | ||
| color: new vscode.ThemeColor("editorInlayHint.foreground"), | ||
| fontStyle: "italic", |
There was a problem hiding this comment.
I would remove this. If you think it would be valuable I would make it a config option that can be opted into. The color does a good job of indicating that this is text that can't be edited.
| // Clear previous metadata decorations | ||
| editor.setDecorations(getMetadataDecorationType(), []); |
There was a problem hiding this comment.
Minor change but this will cause the file icons to show before the metadata which I think is a better default for now.
| // Clear previous metadata decorations | |
| editor.setDecorations(getMetadataDecorationType(), []); | |
| // Clear previous metadata decorations (avoid creating the decoration type too early) | |
| if (metadataDecorationType) { | |
| editor.setDecorations(metadataDecorationType, []); | |
| } |



feat: add configurable file metadata column
📝 Description
Adds opt-in file metadata columns to the oil directory listing, displayed as
virtual text decorations to the left of each filename — similar to Emacs Dired
and oil.nvim's column system.
The buffer text format (
/NNN filename) is never modified, so thesave/diff pipeline is completely unaffected. Metadata is rendered purely via
VSCode
before:decorations and never written into the document.New setting
oil-code.columns(default["icon"]— no breaking change):iconpermissions-rw-r--r--size12KmtimeMar 14 14:23New command
oil-code.toggleDetails— toggles metadata display on/off forthe current session without changing the setting.
Alt+Shift+D<C-d>oilfiletype<C-d>🔧 Type of Change
🔗 Related Issues
Testing
Screenshots (if applicable)
Checklist
Additional Notes
None