diff --git a/init.lua b/init.lua index d4dab21a..5f38facd 100644 --- a/init.lua +++ b/init.lua @@ -175,6 +175,12 @@ vim.keymap.set('n', '', '', { desc = 'Move focus to the upper win -- vim.keymap.set("n", "", "J", { desc = "Move window to the lower" }) -- vim.keymap.set("n", "", "K", { desc = "Move window to the upper" }) +-- helper to jump to diagnostic +local function diagnostic_jump(count, opts) + opts = vim.tbl_extend('force', { count = count, wrap = true, float = true }, opts or {}) + vim.diagnostic.jump(opts) +end + -- [[ Basic Autocommands ]] -- See `:help lua-guide-autocommands` @@ -328,6 +334,9 @@ require('lazy').setup({ { 's', group = '[S]earch' }, { 't', group = '[T]oggle' }, { 'h', group = 'Git [H]unk', mode = { 'n', 'v' } }, + { 'r', group = '[R]efactor' }, + { 'g', group = '[G]oto' }, + { 'e', group = '[E]rror Diagnostics' }, }, }, }, @@ -418,6 +427,22 @@ require('lazy').setup({ vim.keymap.set('n', 's.', builtin.oldfiles, { desc = '[S]earch Recent Files ("." for repeat)' }) vim.keymap.set('n', '', builtin.buffers, { desc = '[ ] Find existing buffers' }) + vim.keymap.set('n', 'rn', vim.lsp.buf.rename, { desc = '[R]e[n]ame' }) + vim.keymap.set('n', 'rr', vim.lsp.buf.references, { desc = '[R]eferences' }) + vim.keymap.set('n', 'gd', builtin.lsp_definitions, { desc = '[G]oto [D]efinition' }) + vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, { desc = '[G]oto [D]eclaration' }) + vim.keymap.set('n', 'gi', builtin.lsp_implementations, { desc = '[G]oto [I]mplementation' }) + + vim.keymap.set('n', 'gb', '', { desc = '[G]o [B]ack' }) + vim.keymap.set('n', 'gf', '', { desc = '[G]o [F]orward' }) + + vim.keymap.set('n', 'en', function() + diagnostic_jump(vim.v.count1) + end, { desc = '[E]rror [N]ext' }) + vim.keymap.set('n', 'ep', function() + diagnostic_jump(-vim.v.count1) + end, { desc = '[E]rror [P]revious' }) + -- Slightly advanced example of overriding default behavior and theme vim.keymap.set('n', '/', function() -- You can pass additional configuration to Telescope to change the theme, layout, etc. @@ -1014,7 +1039,7 @@ require('lazy').setup({ require 'kickstart.plugins.lint', require 'kickstart.plugins.autopairs', require 'kickstart.plugins.neo-tree', - -- require 'kickstart.plugins.gitsigns', -- adds gitsigns recommend keymaps + require 'kickstart.plugins.gitsigns', -- adds gitsigns recommend keymaps -- NOTE: The import below can automatically add your own plugins, configuration, etc from `lua/custom/plugins/*.lua` -- This is the easiest way to modularize your config. @@ -1026,6 +1051,7 @@ require('lazy').setup({ -- Or use telescope! -- In normal mode type `sh` then write `lazy.nvim-plugin` -- you can continue same window with `sr` which resumes last telescope search + -- }, { ui = { -- If you are using a Nerd Font: set icons to an empty table which will use the