Closed nkhlmn closed 8 months ago
Sorry, I misunderstood what was happening here. I assumed that because I was getting prompted to save, that my write keymap was getting executed when in fact the default keymap to open the split was and it was prompting me because my cursor was on the new file and it was attempting to open it in a new split, which triggers the prompt.
That said, it would be nice if I could keep the default oil keymaps but not have them overwrite any of my already existing ones (without having to disable all default keymaps and then explicitly map the remaining ones). Maybe oil could check for existing keymaps that conflict with the defaults and not overwrite those? I would be happy to submit a PR for that if you're open to that. Either way, thanks for the excellent plugin!
This is because Oil sets up buffer-local keymaps, one of which includes <C-s>
, and those have higher priority than global keymaps. You can override the oil keymap like so:
require("oil").setup({
keymaps = {
['<C-s>'] = "<CMD>write<CR>",
},
})
Did you check the docs and existing issues?
Neovim version (nvim -v)
0.9.5
Operating system/version
macos 14.0
Describe the bug
I haveC-s
as my global keymap to write a buffer. When I write to an oil buffer via my keymap I get the prompt to save changes, which does not happen when executing:w
manuallySorry, I misunderstood what was happening here. I assumed that because I was getting prompted to save, that my write keymap was getting executed when in fact the default keymap to open the split was and it was prompting me because my cursor was on the new file and it was attempting to open it in a new split, which triggers the prompt.
What is the severity of this bug?
minor (annoyance)
Steps To Reproduce
~~1. Setup
C-s
as a keymap to execute:w<cr>
Expected Behavior
I should not get prompted to save changes when executing my keymap.If I have some keymaps already defined that conflict with the defaults, oil will not overwrite them.
Directory structure
No response
Repro
Did you check the bug with a clean config?
nvim -u repro.lua
using the repro.lua file above.