diff --git a/common/.config/nvim/lua/core/lsp.lua b/common/.config/nvim/lua/core/lsp.lua index 20be883..e55488e 100644 --- a/common/.config/nvim/lua/core/lsp.lua +++ b/common/.config/nvim/lua/core/lsp.lua @@ -71,6 +71,7 @@ vim.api.nvim_create_autocmd("LspAttach", { end) end + -- Keymaps local map = function(keys, func, desc, mode) mode = mode or "n" vim.keymap.set(mode, keys, func, { buffer = event.buf, desc = "LSP: " .. desc }) @@ -86,9 +87,9 @@ vim.api.nvim_create_autocmd("LspAttach", { -- LspSaga map("", "Lspsaga code_action", "Code Actions") map("cr", "Lspsaga finder", "Goto References") - map("cpf", "Lspsaga peek_definition", "Peek definition: Function") - map("cpt", "Lspsaga peek_type_definition", "Peek definition: Class") - map("cpi", "Lspsaga finder imp", "Peek: Implementations") + map("cF", "Lspsaga peek_definition", "Peek definition: Function") + map("cT", "Lspsaga peek_type_definition", "Peek definition: Class") + map("cI", "Lspsaga finder imp", "Peek: Implementations") -- e to jump to the symbol under cursor; q to quit map("co", "Lspsaga outline", "Outline Panel on Left") @@ -99,60 +100,13 @@ vim.api.nvim_create_autocmd("LspAttach", { map("ct", require("telescope.builtin").lsp_type_definitions, "Goto Type Definition") map("cd", require("telescope.builtin").diagnostics, "List Diagnostics") - -- The following two autocommands are used to highlight references of the - -- word under cursor when cursor rests there for a little while. - if client and client.supports_method(vim.lsp.protocol.Methods.textDocument_documentHighlight) then - local highlight_augroup = vim.api.nvim_create_augroup("kickstart-lsp-highlight", { clear = false }) - vim.api.nvim_create_autocmd({ "CursorHold", "CursorHoldI" }, { - buffer = event.buf, - group = highlight_augroup, - callback = vim.lsp.buf.document_highlight, - }) - - vim.api.nvim_create_autocmd({ "CursorMoved", "CursorMovedI" }, { - buffer = event.buf, - group = highlight_augroup, - callback = vim.lsp.buf.clear_references, - }) - - vim.api.nvim_create_autocmd("LspDetach", { - group = vim.api.nvim_create_augroup("kickstart-lsp-detach", { clear = true }), - callback = function(event2) - vim.lsp.buf.clear_references() - vim.api.nvim_clear_autocmds({ group = "kickstart-lsp-highlight", buffer = event2.buf }) - end, - }) - end - -- Native lsp inline virtual text / inlay hints if client and client.supports_method(vim.lsp.protocol.Methods.textDocument_inlayHint) then - vim.lsp.inlay_hint.enable() -- enabled by default + vim.lsp.inlay_hint.enable() - map("cI", function() + map("ch", function() vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled({ bufnr = event.buf })) end, "Toggle Inlay Hints") end end, }) - --- Change diagnostic symbols in the sign column (gutter) -if vim.g.have_nerd_font then - local signs = require("config.util").icons.diagnostics - local diagnostic_signs = {} - for type, icon in pairs(signs) do - diagnostic_signs[vim.diagnostic.severity[type]] = icon - end - vim.diagnostic.config({ signs = { text = diagnostic_signs } }) -end - -vim.diagnostic.config({ - virtual_text = { - enabled = true, - spacing = 5, - severity = { min = vim.diagnostic.severity.ERROR }, - }, - virtual_lines = { - current_line = true, - severity = { min = vim.diagnostic.severity.INFO }, - }, -}) diff --git a/common/.config/nvim/lua/plugins/code-generic.lua b/common/.config/nvim/lua/plugins/code-generic.lua index 1227375..bef3b70 100644 --- a/common/.config/nvim/lua/plugins/code-generic.lua +++ b/common/.config/nvim/lua/plugins/code-generic.lua @@ -243,17 +243,18 @@ return { -- kind = require("config.util").icons.kind_lspsaga, kind = require("catppuccin.groups.integrations.lsp_saga").custom_kind(), }, + implement = { enabled = true }, symbol_in_winbar = { enable = true, hide_keyword = true, }, - lightbulb = { - virtual_text = false, - }, + lightbulb = { virtual_text = false }, outline = { auto_preview = false }, }) - -- Keymaps in code-lsp.lua + vim.keymap.set({ "n", "t" }, "", "Lspsaga term_toggle", { desc = "Toggle Floating Terminal" }) + + -- Rest of the keymaps in ../core/lsp.lua end, }, @@ -277,20 +278,16 @@ return { size = "80%", }, mappings = { - -- Fuzzy finder at current level. - ["f"] = actions.telescope({ + -- Telescope search symbols at current level + ["/"] = actions.telescope({ layout_config = { height = 0.8, width = 0.8, }, }), - -- Show preview of current node - ["o"] = actions.toggle_preview(), -- Default Mappings on the popup -- - -- ["f"] = Search the children nodes using telescope - -- -- ["J"] = actions.move_down(), -- Move focused node down -- ["K"] = actions.move_up(), -- Move focused node up -- diff --git a/common/.config/nvim/lua/plugins/code-git.lua b/common/.config/nvim/lua/plugins/code-git.lua index df72e68..e714b1b 100644 --- a/common/.config/nvim/lua/plugins/code-git.lua +++ b/common/.config/nvim/lua/plugins/code-git.lua @@ -81,10 +81,6 @@ return { map("n", "gsh", gs.stage_hunk, { desc = "Git: Stage Hunk" }) map("n", "gsu", gs.undo_stage_hunk, { desc = "Git: Undo Stage Hunk" }) map("n", "gsb", gs.stage_buffer, { desc = "Git: Stage Current File" }) - map("n", "gK", function() - gs.blame_line({ full = true }) - end, { desc = "Git: Hover blame-line" }) - -- visual mode map("v", "gsH", function() gs.stage_hunk({ vim.fn.line("."), vim.fn.line("v") }) @@ -93,8 +89,11 @@ return { -- normal mode map("n", "gp", gs.preview_hunk, { desc = "Git: Preview hunk" }) - -- Toggles - map("n", "gB", gs.toggle_current_line_blame, { desc = "Git: Toggle blame-line" }) + map("n", "gK", function() + gs.blame_line({ full = true }) + end, { desc = "Git: Hover blame-line" }) + + map("n", "gB", gs.toggle_current_line_blame, { desc = "Git: Toggle virtual blame-line" }) end, }, }, diff --git a/common/.config/nvim/lua/plugins/utility-plugs.lua b/common/.config/nvim/lua/plugins/utility-plugs.lua index 4e079a6..75a6a21 100644 --- a/common/.config/nvim/lua/plugins/utility-plugs.lua +++ b/common/.config/nvim/lua/plugins/utility-plugs.lua @@ -108,7 +108,14 @@ return { function() Snacks.lazygit.log(opts) end, - desc = "Git: Log", + desc = "LazyGit: List Git Log", + }, + { + "gL", + function() + Snacks.git.blame_line(opts) + end, + desc = "Git: Line Log", }, { "gf", @@ -117,6 +124,13 @@ return { end, desc = "Git: Show File Log", }, + { + "gO", + function() + Snacks.gitbrowse.open(opts) + end, + desc = "Git: Open the file on Browser", + }, { "]]", function() @@ -154,13 +168,6 @@ return { end, desc = "Toggle Zen Mode", }, - { - "gO", - function() - Snacks.gitbrowse.open(opts) - end, - desc = "Git: Open the file on Browser", - }, }, }, @@ -226,10 +233,11 @@ return { -- Document existing key chains spec = { { "/", group = "NVIM Scratch Buffer" }, - { "a", group = "AI" }, - { "b", group = "Buffer Operations", icon = { icon = "", color = "orange" } }, + { "a", group = "AI", icon = { icon = "󰚩", color = "orange" } }, + { "b", group = "Buffer Operations", icon = { icon = "󰲂", color = "orange" } }, { "c", group = "Code", icon = { icon = "", color = "orange" } }, - { "d", group = "Diagnostics", icon = { icon = "", color = "orange" } }, + { "d", group = "Diagnostics", icon = { icon = "🔬", color = "orange" } }, + { "D", group = "Debug", icon = { icon = "", color = "orange" } }, { "g", group = "Git", icon = { icon = "", color = "orange" } }, { "h", group = "Help", icon = { icon = "󰞋", color = "orange" } }, { "n", group = "Neovim Things", icon = { icon = "", color = "orange" } }, @@ -237,6 +245,7 @@ return { { "s", group = "Search/Grep", icon = { icon = "", color = "orange" } }, { "t", group = "Unit Test" }, { "x", group = "Delete/Disable/Remove", icon = { icon = "", color = "orange" } }, + -- More icons: https://github.com/echasnovski/mini.icons/blob/main/lua/mini/icons.lua#L686 }, }, },