diff --git a/lua/core/init.lua b/lua/core/init.lua index 5159c9c..6747961 100644 --- a/lua/core/init.lua +++ b/lua/core/init.lua @@ -6,10 +6,15 @@ M.setup = function() require("core.filetypes") 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.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") end diff --git a/lua/core/keybinds.lua b/lua/core/keybinds.lua new file mode 100644 index 0000000..0eb8009 --- /dev/null +++ b/lua/core/keybinds.lua @@ -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'}, '', + function () + require('vim.treesitter._select') + .select_next(vim.v.count1) + end, + { + desc = 'Select next Treesitter Node' + } + ) + vim.keymap.set({'n','x'}, '', + function () + require('vim.treesitter._select') + .select_prev(vim.v.count1) + end, + { + desc = 'Select previous Treesitter Node' + } + ) + vim.keymap.set({'n','x'}, '', + function () + require('vim.treesitter._select') + .select_parent(vim.v.count1) + end, + { + desc = 'Select parent TS node' + } + ) + vim.keymap.set({'n','x'}, '', + function () + require('vim.treesitter._select') + .select_child(vim.v.count1) + end, + { + desc = 'Select child TS node' + } + ) +end