-
-
Notifications
You must be signed in to change notification settings - Fork 625
feat(mapping): deprecate user mappings and add on_attach #1424
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
Conversation
To confirm: we are completely removing actions e.g. This is the right way forward. Users invoking
This shouldn't be a problem if they are mapping directly to the API. We will need to provide all the default mappings in the help, so that users can copy-paste to create their own e.g. vim.api.nvim_buf_set_keymap(bufnr, 'n', 'hs', '<cmd>lua require"gitsigns".stage_hunk()<CR>', {})
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'Y', '<cmd>lua require"nvim-tree.actions.fs.copy-paste".copy_path()<CR>', {}) Users could not use regular vimscript keymaps, however that is acceptable.
We will need to create a page to explain the migration process with examples. We will unfortunately need to provide a legacy migration path, pointing them to the migration doc. Users will be very upset if we don't do this. Perhaps we could provide a function to convert their existing mappings to
We can do that at any time before this. It's on my list ;) |
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
70fab85
to
618ffa3
Compare
This comment was marked as resolved.
This comment was marked as resolved.
f68cae2
to
f573e97
Compare
0ab0eb9
to
aab36b6
Compare
@alex-courtis i've migrated the keymap code to a new module. We will do a 2 step deprecation, 1st switching the default to the on_attach (in the next week or two) with a warning message, and in a month or two we'll remove the whole code and options related to this. |
Let's wait until we have completed everything and are ready to cut over to the new keymap. You know how upset users get when we show warnings ;) There may be an unforseen issue that requires us to make an api or on_attach change, which is OK for early adopters but not for everyone.
Yes. We can give them some time; there is no rush to remove the legacy mappings. |
Pushed a draft mechanism to write current mappings -> on_attach Feel free to revert / change etc. Run We could probably just simplify the helper to local function map(key, fn)
vim.keymap.set("n", key, function(...)
fn(...)
end, { buffer = bufnr, noremap = true })
end however I'm not sure what else you have in mind with the mappings... |
Not sure how we are going to do the DEFAULT_KEYMAPS for update-help.sh Might have to do something horrible like: {
key = { "<CR>", "o", "<2-LeftMouse>" },
callback = { "node", "open", "edit", },
desc = "open a file or folder; root will cd to the above directory",
},
...
function M.set_keymaps(bufnr)
local opts = { noremap = true, silent = true, nowait = true, buffer = bufnr }
for _, km in ipairs(M.keymaps) do
local keys = type(km.key) == "table" and km.key or { km.key }
for _, key in ipairs(keys) do
local fn = Api
for _, t in ipairs(km.callback) do
fn = fn[t]
end
vim.keymap.set("n", key, fn, opts)
end
end
end
... |
i'm moving your commit in a separate PR so we can discuss it more. I think we can probably have a better strategy for migrating user configs under the hood too. |
See the help doc. I think this is better than providing our custom binding methods, idea taken from gitsigns.nvim. Once this is complete, we could remove the whole mapping code and simplify the actions -> dispatch configurations. The new keymap.lua module is now used whenever on_attach is defined.
d06cd7f
to
495084b
Compare
This was the right desicion. Early feedback is useful. #1461 |
See the help doc. I think this is better than providing our custom binding methods
The idea was taken from gitsigns.nvim.
We have a new keymap module that uses the API directly. I've taken the same map from the actions/init.lua file and migrated the action keys to callback keys. We will need to update the script for the default mappings too once this lands.