-
Notifications
You must be signed in to change notification settings - Fork 0
fix(nvim): Make Oil the reliable directory explorer #11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -183,6 +183,28 @@ vim.api.nvim_create_autocmd("FileType", { | |
| end, | ||
| }) | ||
|
|
||
| vim.g.netrw_sort_by = "name" | ||
| vim.g.netrw_sort_direction = "reverse" | ||
| vim.g.netrw_sort_sequence = | ||
| [[\(\.bak\|\~\|\.o\|\.h\|\.info\|\.swp\|\.obj\)[*@]\=$,*]] | ||
|
|
||
| -- For reference, this is the default sorting sequence | ||
| -- [\/]$,*,\(\.bak\|\~\|\.o\|\.h\|\.info\|\.swp\|\.obj\)[*@]\=$ | ||
|
|
||
| -- Oil replaces netrw's `:Explore` command and keeps `:E` as a shorthand. | ||
| local function open_oil(opts) | ||
| local path = opts.args ~= "" and opts.args or nil | ||
| require("oil").open(path) | ||
| end | ||
|
|
||
| local oil_command_opts = { | ||
| force = true, | ||
| nargs = "?", | ||
| complete = "dir", | ||
| } | ||
| vim.api.nvim_create_user_command("Explore", open_oil, oil_command_opts) | ||
| vim.api.nvim_create_user_command("E", open_oil, oil_command_opts) | ||
|
|
||
| -- To change the default tree list mode in `netrw`, set the `g:netrw_liststyle` variable. | ||
| -- The possible values for `g:netrw_liststyle` are: | ||
| -- | ||
|
|
@@ -273,8 +295,16 @@ highlights_question_answer() | |
| -- `[target-group]`: Syntax highlighting group you want to apply properties to. | ||
| -- `[source-group]`: Syntax highlighting group it will inherit/link from. | ||
|
|
||
| -- This forces `:E` to map to `:Explore` even if another plugin has already | ||
| -- overwritten that command. | ||
| vim.api.nvim_create_user_command("E", "Explore", { force = true }) | ||
| vim.api.nvim_create_user_command("PrintWinbar", function() | ||
| local winbar = vim.wo.winbar | ||
|
|
||
| print(vim.inspect({ | ||
| raw = winbar, | ||
| rendered = vim.api.nvim_eval_statusline(winbar, { | ||
| winid = vim.api.nvim_get_current_win(), | ||
| use_winbar = true, | ||
| }).str, | ||
| })) | ||
| end, {}) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Debug PrintWinbar command committedLow Severity A new Reviewed by Cursor Bugbot for commit a408243. Configure here. |
||
|
|
||
| return {} | ||


There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Scheduled Oil opens wrong window
Medium Severity
The directory
BufEnterhandler captures onlypath, then callsoil.open(path)insidevim.schedule. When the callback runs, Oil uses the then-current window, not the window that entered the directory buffer, so a quick buffer or window switch can open the explorer in the wrong place or trigger Oil errors.Reviewed by Cursor Bugbot for commit a408243. Configure here.