feat(keybinds): Add incremental selection
These keybinds use nvim-0.12 functionality. Later commits should introduce a backwards compatible option until every system I use has nvim-0.12 available natively
This commit is contained in:
parent
0d623139fa
commit
4ebf0be6f7
|
|
@ -6,10 +6,15 @@ M.setup = function()
|
||||||
require("core.filetypes")
|
require("core.filetypes")
|
||||||
require("plugins.lazy")
|
require("plugins.lazy")
|
||||||
|
|
||||||
-- Load this after loading plugins to ensure default lspconfig is there
|
-- Load this after loading plugins to ensure default lsp-config is there
|
||||||
require("core.lspconfig")
|
require("core.lspconfig")
|
||||||
require("core.treesitter")
|
require("core.treesitter")
|
||||||
|
|
||||||
|
-- Load this after loading everything else
|
||||||
|
-- to ensure we are ready for them.
|
||||||
|
require("core.keybinds")
|
||||||
|
|
||||||
|
-- Finally set the colorscheme
|
||||||
vim.cmd.colorscheme("gruvbox")
|
vim.cmd.colorscheme("gruvbox")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
51
lua/core/keybinds.lua
Normal file
51
lua/core/keybinds.lua
Normal file
|
|
@ -0,0 +1,51 @@
|
||||||
|
-- NOTE: MOST PLUGIN KEY-BINDS ARE LOCATED IN THE PLUGINS SPEC
|
||||||
|
-- As a general rule of thumb:
|
||||||
|
-- * if the key-bind requires a given plugin be loaded
|
||||||
|
-- * or is/can be used to lazy-load a plugin
|
||||||
|
-- It doesn't belong here
|
||||||
|
|
||||||
|
-- NOTE: I am not using any convenience function here.
|
||||||
|
-- Instead I am using the `vim.keymap.set` function bare.
|
||||||
|
-- This is to make it easier to know what this is doing
|
||||||
|
-- if I come back to edit a binding later.
|
||||||
|
|
||||||
|
|
||||||
|
-- ! Use native tree-sitter incremental highlighting when possible.
|
||||||
|
if vim.fn.has('nvim-0.12') == 1 then
|
||||||
|
vim.keymap.set({'n','x'}, '<TAB>',
|
||||||
|
function ()
|
||||||
|
require('vim.treesitter._select')
|
||||||
|
.select_next(vim.v.count1)
|
||||||
|
end,
|
||||||
|
{
|
||||||
|
desc = 'Select next Treesitter Node'
|
||||||
|
}
|
||||||
|
)
|
||||||
|
vim.keymap.set({'n','x'}, '<S-TAB>',
|
||||||
|
function ()
|
||||||
|
require('vim.treesitter._select')
|
||||||
|
.select_prev(vim.v.count1)
|
||||||
|
end,
|
||||||
|
{
|
||||||
|
desc = 'Select previous Treesitter Node'
|
||||||
|
}
|
||||||
|
)
|
||||||
|
vim.keymap.set({'n','x'}, '<CR>',
|
||||||
|
function ()
|
||||||
|
require('vim.treesitter._select')
|
||||||
|
.select_parent(vim.v.count1)
|
||||||
|
end,
|
||||||
|
{
|
||||||
|
desc = 'Select parent TS node'
|
||||||
|
}
|
||||||
|
)
|
||||||
|
vim.keymap.set({'n','x'}, '<S-CR>',
|
||||||
|
function ()
|
||||||
|
require('vim.treesitter._select')
|
||||||
|
.select_child(vim.v.count1)
|
||||||
|
end,
|
||||||
|
{
|
||||||
|
desc = 'Select child TS node'
|
||||||
|
}
|
||||||
|
)
|
||||||
|
end
|
||||||
Loading…
Reference in New Issue
Block a user