Skip to content

feat: add configurable file metadata column#54

Open
Goutham-AR wants to merge 5 commits intocorwinm:mainfrom
Goutham-AR:feat/add-metadata-columns
Open

feat: add configurable file metadata column#54
Goutham-AR wants to merge 5 commits intocorwinm:mainfrom
Goutham-AR:feat/add-metadata-columns

Conversation

@Goutham-AR
Copy link

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 the
save/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):

"oil-code.columns": ["icon", "permissions", "size", "mtime"]
Column Example Fixed width
icon 📄 existing
permissions -rw-r--r-- 10
size 12K 4, right-aligned, NBSP-padded
mtime Mar 14 14:23 12

New command oil-code.toggleDetails — toggles metadata display on/off for
the current session without changing the setting.

Binding Key
Native / non-Vim Alt+Shift+D
VSCodeVim normal mode <C-d>
neovim oil filetype <C-d>

🔧 Type of Change

  • 🐛 Bug fix (non-breaking change which fixes an issue)
  • ✨ New feature (non-breaking change which adds functionality)
  • 💥 Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • 📚 Documentation update
  • ♻️ Code refactoring (no functional changes)
  • ⚡ Performance improvement
  • 🧪 Tests (adding missing tests or correcting existing tests)
  • 🎨 Style changes (formatting, missing semi-colons, etc)
  • 🔧 Chore (maintenance tasks, dependency updates)
  • 🌟 Other (please describe):

🔗 Related Issues

Testing

  • I have tested this change locally
  • I have added/updated unit tests
  • All existing tests pass

Screenshots (if applicable)

Screenshot 2026-03-21 at 8 07 14 PM

Checklist

  • My code follows the project's coding standards
  • I have performed a self-review of my code
  • I have commented my code in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have checked my code and corrected any misspellings

Additional Notes

None

- 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.
Copy link
Owner

@corwinm corwinm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>"],
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above, lets default to "gd" to not conflict with the default.


for (const name of listings) {
if (name === "../") {
continue;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like oil.nvim uses dashes for this row:

Image

Not sure if that should be set here or somewhere else in the code.

}
}

oilState.metadataCache.set(folderPathUri, fileMap);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be good to do a pass here to normalize column widths. Right now we can have a view with inconsistent column widths:

Image

With oil.nvim:

Image

metadataDecorationType = vscode.window.createTextEditorDecorationType({
before: {
color: new vscode.ThemeColor("editorInlayHint.foreground"),
fontStyle: "italic",
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +148 to +149
// Clear previous metadata decorations
editor.setDecorations(getMetadataDecorationType(), []);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor change but this will cause the file icons to show before the metadata which I think is a better default for now.

Suggested change
// Clear previous metadata decorations
editor.setDecorations(getMetadataDecorationType(), []);
// Clear previous metadata decorations (avoid creating the decoration type too early)
if (metadataDecorationType) {
editor.setDecorations(metadataDecorationType, []);
}
Image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Configurable file metadata columns in directory listing

2 participants