What is the best way to define blink keybindings in a seperate file? #1698
-
Essentially I am trying to structure my neovim config in a way that sets all keybindings in a single file. Using |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
DumbWhy don't you just return an object from your file that contains all the If you don't want to deal with imports, you can also simply assign a global variable: -- keymaps.lua
vim.g.blink_keymaps = {
default = {
preset = 'none',
['<Down>'] = { 'select_next', 'fallback' },
['<Up>'] = { 'select_prev', 'fallback' },
-- ...
},
cmdline = {
preset = 'none',
-- ...
},
} -- blink.lua
return {
'saghen/blink.cmp',
-- please test on `main` if possible
-- otherwise, remove this line and set `version = '*'`
build = 'cargo build --release',
opts = {
keymap = vim.g.blink_keymaps.default,
cmdline = {
keymap = vim.g.blink_keymaps.cmdline,
},
},
} SmartThe only potential issue is the loading order. In my opinion, your approach is quite tricky to implement.
-- plugins/keymaps.lua
local plugins = {}
-- stylua: ignore start
vim.keymap.set('n', '<F1>', function() vim.print 'Yay, general purpose keymap' end, {})
vim.keymap.set('n', '<F2>', function() vim.print 'Yay, general purpose keymap' end, {})
vim.keymap.set('n', '<F3>', function() vim.print 'Yay, general purpose keymap' end, {})
vim.keymap.set('n', '<F4>', function() vim.print 'Yay, general purpose keymap' end, {})
vim.keymap.set('n', '<F5>', function() vim.print 'Yay, general purpose keymap' end, {})
-- stylua: ignore end
table.insert(plugins, {
'some-author/some-plugin',
optional = true,
keys = {
-- ...
},
})
table.insert(plugins, {
'saghen/blink.cmp',
optional = true,
opts = {
keymap = {
preset = 'none',
['<Down>'] = { 'select_next', 'fallback' },
['<Up>'] = { 'select_prev', 'fallback' },
-- ...
},
cmdline = {
keymap = {
preset = 'inherit',
-- ...
},
},
},
})
return plugins |
Beta Was this translation helpful? Give feedback.
Dumb
Why don't you just return an object from your file that contains all the
blink.cmp
keymaps? You can import this file from any part of your code.If you don't want to deal with imports, you can also simply assign a global variable: