From a6dddb569e43683cc8644486ae544edf681bf4c1 Mon Sep 17 00:00:00 2001 From: Pratik Tripathy Date: Sat, 28 Dec 2024 00:33:00 +0530 Subject: [PATCH] chore(nvim): Navbuddy UI enhancements, plugins removed, and code cleanup - Navbuddy: size increased - Navbuddy: added keybindings: o -> preview, f -> search - LSP: disable inlayHints by default - Removed 2 plugins: bigfile, obsidian --- .../.config/nvim/lua/plugins/code-generic.lua | 98 ++++++++----------- common/.config/nvim/lua/plugins/code-lsp.lua | 33 ++----- .../nvim/lua/plugins/utility-plugs.lua | 35 ------- 3 files changed, 49 insertions(+), 117 deletions(-) diff --git a/common/.config/nvim/lua/plugins/code-generic.lua b/common/.config/nvim/lua/plugins/code-generic.lua index 497dd8f..3f297d0 100644 --- a/common/.config/nvim/lua/plugins/code-generic.lua +++ b/common/.config/nvim/lua/plugins/code-generic.lua @@ -373,67 +373,47 @@ return { "SmiteshP/nvim-navic", "MunifTanjim/nui.nvim", }, - opts = { - lsp = { auto_attach = true }, - icons = require("config.util").icons.kinds, - }, + config = function() + local actions = require("nvim-navbuddy.actions") + local navbuddy = require("nvim-navbuddy") + + navbuddy.setup({ + lsp = { auto_attach = true }, + icons = require("config.util").icons.kinds, + window = { + border = "rounded", + size = "80%", + }, + mappings = { + -- Fuzzy finder at current level. + ["f"] = actions.telescope({ + layout_config = { + height = 0.8, + width = 0.8, + }, + }), + -- Show preview of current node + ["o"] = actions.toggle_preview(), + + -- Default Mappings on the popup + -- + -- ["J"] = actions.move_down(), -- Move focused node down + -- ["K"] = actions.move_up(), -- Move focused node up + -- + -- ["r"] = actions.rename(), -- Rename currently focused symbol + -- + -- [""] = actions.vsplit(), -- Open selected node in a vertical split + -- [""] = actions.hsplit(), -- Open selected node in a horizontal split + -- + -- ["0"] = actions.root(), -- Move to first panel + -- + -- ["g?"] = actions.help(), -- Open mappings help window + }, + }) + end, keys = { - -- Default Mappings on the popup - -- [""] = actions.close(), -- Close and cursor to original location - -- ["q"] = actions.close(), - -- - -- ["j"] = actions.next_sibling(), -- down - -- ["k"] = actions.previous_sibling(), -- up - -- - -- ["h"] = actions.parent(), -- Move to left panel - -- ["l"] = actions.children(), -- Move to right panel - -- ["0"] = actions.root(), -- Move to first panel - -- - -- ["v"] = actions.visual_name(), -- Visual selection of name - -- ["V"] = actions.visual_scope(), -- Visual selection of scope - -- - -- ["y"] = actions.yank_name(), -- Yank the name to system clipboard "+ - -- ["Y"] = actions.yank_scope(), -- Yank the scope to system clipboard "+ - -- - -- ["i"] = actions.insert_name(), -- Insert at start of name - -- ["I"] = actions.insert_scope(), -- Insert at start of scope - -- - -- ["a"] = actions.append_name(), -- Insert at end of name - -- ["A"] = actions.append_scope(), -- Insert at end of scope - -- - -- ["r"] = actions.rename(), -- Rename currently focused symbol - -- - -- ["d"] = actions.delete(), -- Delete scope - -- - -- ["f"] = actions.fold_create(), -- Create fold of current scope - -- ["F"] = actions.fold_delete(), -- Delete fold of current scope - -- - -- ["c"] = actions.comment(), -- Comment out current scope - -- - -- [""] = actions.select(), -- Goto selected symbol - -- ["o"] = actions.select(), - -- - -- ["J"] = actions.move_down(), -- Move focused node down - -- ["K"] = actions.move_up(), -- Move focused node up - -- - -- ["s"] = actions.toggle_preview(), -- Show preview of current node - -- - -- [""] = actions.vsplit(), -- Open selected node in a vertical split - -- [""] = actions.hsplit(), -- Open selected node in a horizontal split - -- - -- ["t"] = actions.telescope({ -- Fuzzy finder at current level. - -- layout_config = { -- All options that can be - -- height = 0.60, -- passed to telescope.nvim's - -- width = 0.60, -- default can be passed here. - -- prompt_position = "top", - -- preview_width = 0.50, - -- }, - -- layout_strategy = "horizontal", - -- }), - -- - -- ["g?"] = actions.help(), -- Open mappings help window { - "O", + "o", function() return require("nvim-navbuddy").open() end, diff --git a/common/.config/nvim/lua/plugins/code-lsp.lua b/common/.config/nvim/lua/plugins/code-lsp.lua index e6864a1..0255596 100644 --- a/common/.config/nvim/lua/plugins/code-lsp.lua +++ b/common/.config/nvim/lua/plugins/code-lsp.lua @@ -43,12 +43,8 @@ return { map("gd", require("telescope.builtin").lsp_definitions, "[G]oto [D]efinition") map("", require("telescope.builtin").lsp_definitions, "[G]oto [D]efinition") map("gD", vim.lsp.buf.declaration, "[G]oto [D]eclaration") - -- map("gr", require("telescope.builtin").lsp_references, "[G]oto [R]eferences") map("gI", require("telescope.builtin").lsp_implementations, "[G]oto [I]mplementation") - -- Fuzzy find all the symbols in your current document. - -- Symbols are things like variables, functions, types, etc. - map("o", require("telescope.builtin").lsp_document_symbols, "Search Document Symbols") map("cs", require("telescope.builtin").lsp_document_symbols, "Search Document Symbols") map("cS", require("telescope.builtin").lsp_dynamic_workspace_symbols, "Search Workspace Symbols") map("ci", require("telescope.builtin").lsp_implementations, "Goto Implementation") @@ -89,12 +85,10 @@ return { }) end - -- TODO: Make inlay_hint enabled by default - -- Change this keymap - -- - -- The following code creates a keymap to toggle inlay hints if client and client.supports_method(vim.lsp.protocol.Methods.textDocument_inlayHint) then - map("ni", function() + -- vim.lsp.inlay_hint.enable() + + map("cI", function() vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled({ bufnr = event.buf })) end, "Toggle Inlay Hints") end @@ -111,31 +105,25 @@ return { vim.diagnostic.config({ signs = { text = diagnostic_signs } }) end - -- LSP servers and clients are able to communicate to each other what features they support. - -- By default, Neovim doesn't support everything that is in the LSP specification. - -- When you add nvim-cmp, luasnip, etc. Neovim now has *more* capabilities. - -- Here, we broadcast the new capabilities to the servers. - local capabilities = vim.lsp.protocol.make_client_capabilities() - capabilities = vim.tbl_deep_extend("force", capabilities, require("cmp_nvim_lsp").default_capabilities()) - -- Enable the following language servers - -- Add any additional override configuration in the following tables. Available keys are: + -- Available keys are: -- - cmd (table): Override the default command used to start the server -- - filetypes (table): Override the default list of associated filetypes for the server -- - capabilities (table): Override fields in capabilities. Can be used to disable certain LSP features. -- - settings (table): Override the default settings passed when initializing the server. - -- For example, to see the options for `lua_ls`, you could go to: https://luals.github.io/wiki/settings/ local servers = { - html = { filetypes = { "html", "twig", "hbs" } }, + html = { + -- cmd = { ... }, + -- filetypes = { ... }, + -- capabilities = {}, + filetypes = { "html", "twig", "hbs" }, + }, cssls = {}, jsonls = {}, bashls = { filetypes = { "sh", "bash", "zsh" } }, pylsp = {}, lua_ls = { - -- cmd = { ... }, - -- filetypes = { ... }, - -- capabilities = {}, settings = { Lua = { workspace = { checkThirdParty = false }, @@ -204,7 +192,6 @@ return { dockerls = {}, docker_compose_language_service = {}, - -- marksman = {}, -- ltex = { -- filetypes = { "markdown", "text" }, -- flags = { debounce_text_changes = 3000 }, diff --git a/common/.config/nvim/lua/plugins/utility-plugs.lua b/common/.config/nvim/lua/plugins/utility-plugs.lua index 748079b..7f18d86 100644 --- a/common/.config/nvim/lua/plugins/utility-plugs.lua +++ b/common/.config/nvim/lua/plugins/utility-plugs.lua @@ -90,39 +90,4 @@ return { dir = vim.fn.expand(vim.fn.stdpath("config") .. "/sessions/"), }, }, - - -- Speedup loading large files by disabling some plugins - { - "LunarVim/bigfile.nvim", - cond = require("config.util").is_not_vscode(), - lazy = true, - opts = { - filesize = 2, --2MiB - pattern = "*", - features = { - "indent_blankline", - "lsp", - "syntax", - "treesitter", - }, - }, - }, - - { - "epwalsh/obsidian.nvim", - version = "*", - dependencies = { - "nvim-lua/plenary.nvim", - }, - cond = require("config.util").is_not_vscode(), - ft = "markdown", - opts = { - workspaces = { - { name = "personal", path = "~/Code/Notes" }, - }, - completion = { - nvim_cmp = true, - }, - }, - }, }