From 68cfd827b4cacbb055844d219dd3b20ae5d12a67 Mon Sep 17 00:00:00 2001 From: Gabriel Arazas Date: Tue, 28 Jan 2025 17:13:49 +0800 Subject: [PATCH] nvim: update plugins config --- nvim/lua/plugins/fuzzy-finder.lua | 4 +- nvim/lua/plugins/qol.lua | 6 +- nvim/lua/plugins/tree-sitter.lua | 130 +++++++++++++++++++++++++++--- 3 files changed, 126 insertions(+), 14 deletions(-) diff --git a/nvim/lua/plugins/fuzzy-finder.lua b/nvim/lua/plugins/fuzzy-finder.lua index 90736c8..e0b612a 100644 --- a/nvim/lua/plugins/fuzzy-finder.lua +++ b/nvim/lua/plugins/fuzzy-finder.lua @@ -5,6 +5,7 @@ return { depedencies = { "nvim-lua/plenary.nvim", "nvim-telescope/telescope-project.nvim", + { "nvim-telescope/telescope-fzf-native.nvim", build = "make" }, }, module = true, config = function() @@ -25,6 +26,7 @@ return { { "~/library/writings" }, }, }, + fzf = { }, }, }) @@ -55,10 +57,10 @@ return { vim.keymap.set("n", "fh", get_builtin("help_tags"), { noremap = true, desc = "Search help pages" }) vim.keymap.set("n", "ft", get_builtin("treesitter"), { noremap = true, desc = "Search treesitter objects" }) vim.keymap.set("n", "fM", get_builtin("man_pages"), { noremap = true, desc = "Search manpages" }) + vim.keymap.set("n", "fS", get_builtin("spell_suggest"), { noremap = true, desc = "Pick spell suggestions" }) vim.keymap.set("n", "fA", get_builtin("resume"), { noremap = true, desc = "Return last search" }) - -- Ekeymap.set vim.keymap.set("n", "fp", [[lua require("telescope").extensions.project.project({})]], opts) end, }, diff --git a/nvim/lua/plugins/qol.lua b/nvim/lua/plugins/qol.lua index 6aa7229..bf8fc18 100644 --- a/nvim/lua/plugins/qol.lua +++ b/nvim/lua/plugins/qol.lua @@ -71,7 +71,10 @@ return { { "stevearc/oil.nvim", - dependencies = { "nvim-tree/nvim-web-devicons" }, + dependencies = { + "nvim-tree/nvim-web-devicons", + "nvim-telescope/telescope.nvim", + }, opts = { default_file_explorer = true, @@ -83,6 +86,7 @@ return { keys = { { "-", "Oil", { desc = "Open parent directory in file explorer" } }, + { "", function () require("oil").open(vim.fn.getcwd()) end, { desc = "Open current working directory in file explorer" } }, }, }, } diff --git a/nvim/lua/plugins/tree-sitter.lua b/nvim/lua/plugins/tree-sitter.lua index 9cea7ff..47da250 100644 --- a/nvim/lua/plugins/tree-sitter.lua +++ b/nvim/lua/plugins/tree-sitter.lua @@ -28,22 +28,128 @@ return { indent = { enable = true }, - -- custom text objects with nvim-treesitter-textobjects - -- I've just copied this from the README but they are reasonable additions to me. + highlight_current_scope = { enable = false }, + highlight_definitions = { clear_on_cursor_move = true, enable = true }, + navigation = { + enable = true, + keymaps = { + goto_definition = "gnd", + goto_next_usage = "", + goto_previous_usage = "", + list_definitions = "gnD", + list_definitions_toc = "gO", + }, + }, + smart_rename = { enable = true, keymaps = { smart_rename = "grr" } }, textobjects = { + lsp_interop = { + border = "none", + enable = true, + peek_definition_code = { + ["dF"] = { desc = "Peek definition of class", query = "@class.outer" }, + ["df"] = { desc = "Peek definition of function", query = "@function.outer" }, + }, + }, + move = { + enable = true, + goto_next_end = { + ["]]b"] = { desc = "Jump to inner part of the next block", query = "@block.inner" }, + ["]]c"] = { desc = "Jump to inner part of the next class", query = "@class.inner" }, + ["]]d"] = { desc = "Jump to inner part of the next conditional", query = "@conditional.inner" }, + ["]]f"] = { desc = "Jump to inner part of the next call", query = "@call.inner" }, + ["]]l"] = { desc = "Jump to inner part of the next loop", query = "@loop.inner" }, + ["]]m"] = { desc = "Jump to inner part of the next function", query = "@function.inner" }, + ["]]s"] = { desc = "Jump to inner part of the next statement", query = "@statement.inner" }, + ["]b"] = { desc = "Jump to next block", query = "@block.outer" }, + ["]c"] = { desc = "Jump to next class", query = "@class.outer" }, + ["]d"] = { desc = "Jump to next conditional", query = "@conditional.outer" }, + ["]f"] = { desc = "Jump to next call", query = "@call.outer" }, + ["]l"] = { desc = "Jump to next loop", query = "@loop.outer" }, + ["]m"] = { desc = "Jump to next function", query = "@function.outer" }, + ["]s"] = { desc = "Jump to next statement", query = "@statement.outer" }, + }, + goto_next_start = { + ["]]b"] = { desc = "Jump to inner part of the next block", query = "@block.inner" }, + ["]]c"] = { desc = "Jump to inner part of the next class", query = "@class.inner" }, + ["]]d"] = { desc = "Jump to inner part of the next conditional", query = "@conditional.inner" }, + ["]]f"] = { desc = "Jump to inner part of the next call", query = "@call.inner" }, + ["]]l"] = { desc = "Jump to inner part of the next loop", query = "@loop.inner" }, + ["]]m"] = { desc = "Jump to inner part of the next function", query = "@function.inner" }, + ["]]s"] = { desc = "Jump to inner part of the next statement", query = "@statement.inner" }, + ["]b"] = { desc = "Jump to next block", query = "@block.outer" }, + ["]c"] = { desc = "Jump to next class", query = "@class.outer" }, + ["]d"] = { desc = "Jump to next conditional", query = "@conditional.outer" }, + ["]f"] = { desc = "Jump to next call", query = "@call.outer" }, + ["]l"] = { desc = "Jump to next loop", query = "@loop.outer" }, + ["]m"] = { desc = "Jump to next function", query = "@function.outer" }, + ["]s"] = { desc = "Jump to next statement", query = "@statement.outer" }, + }, + goto_previous_end = { + ["[B"] = { desc = "Jump to previous block", query = "@block.outer" }, + ["[C"] = { desc = "Jump to previous class", query = "@class.outer" }, + ["[D"] = { desc = "Jump to previous conditional", query = "@conditional.outer" }, + ["[F"] = { desc = "Jump to previous call", query = "@call.outer" }, + ["[L"] = { desc = "Jump to previous loop", query = "@loop.outer" }, + ["[M"] = { desc = "Jump to previous function", query = "@function.outer" }, + ["[S"] = { desc = "Jump to previous statement", query = "@statement.outer" }, + ["[[B"] = { desc = "Jump to inner part of the previous block", query = "@block.inner" }, + ["[[C"] = { desc = "Jump to inner part of the previous class", query = "@class.inner" }, + ["[[D"] = { desc = "Jump to inner part of the previous conditional", query = "@conditional.inner" }, + ["[[F"] = { desc = "Jump to inner part of the previous call", query = "@call.inner" }, + ["[[L"] = { desc = "Jump to inner part of the previous loop", query = "@loop.inner" }, + ["[[M"] = { desc = "Jump to inner part of the previous function", query = "@function.inner" }, + ["[[S"] = { desc = "Jump to inner part of the previous statement", query = "@statement.inner" }, + }, + goto_previous_start = { + ["[B"] = { desc = "Jump to previous block", query = "@block.outer" }, + ["[C"] = { desc = "Jump to previous class", query = "@class.outer" }, + ["[D"] = { desc = "Jump to previous conditional", query = "@conditional.outer" }, + ["[F"] = { desc = "Jump to previous call", query = "@call.outer" }, + ["[L"] = { desc = "Jump to previous loop", query = "@loop.outer" }, + ["[M"] = { desc = "Jump to previous function", query = "@function.outer" }, + ["[S"] = { desc = "Jump to previous statement", query = "@statement.outer" }, + ["[[B"] = { desc = "Jump to inner part of the previous block", query = "@block.inner" }, + ["[[C"] = { desc = "Jump to inner part of the previous class", query = "@class.inner" }, + ["[[D"] = { desc = "Jump to inner part of the previous conditional", query = "@conditional.inner" }, + ["[[F"] = { desc = "Jump to inner part of the previous call", query = "@call.inner" }, + ["[[L"] = { desc = "Jump to inner part of the previous loop", query = "@loop.inner" }, + ["[[M"] = { desc = "Jump to inner part of the previous function", query = "@function.inner" }, + ["[[S"] = { desc = "Jump to inner part of the previous statement", query = "@statement.inner" }, + }, + set_jumps = true, + }, select = { enable = true, - lookahead = true, - keymaps = { - ["af"] = "@function.outer", - ["if"] = "@function.inner", - ["ae"] = "@block.outer", - ["ie"] = "@block.inner", - ["ac"] = "@class.outer", - ["ic"] = "@class.inner", - ["aC"] = "@conditional.outer", - ["iC"] = "@conditional.inner", + aa = { desc = "Select around the attribute region", query = "@attribute.outer" }, + ab = { desc = "Select around the block region", query = "@block.outer" }, + ac = { desc = "Select around the class region", query = "@class.outer" }, + af = { desc = "Select around the call region", query = "@call.outer" }, + al = { desc = "Select around the loop region", query = "@loop.outer" }, + am = { desc = "Select around the function region", query = "@function.outer" }, + as = { desc = "Select around the statement region", query = "@statement.outer" }, + ia = { desc = "Select inner part of the attribute region", query = "@attribute.inner" }, + ib = { desc = "Select inner part of the block region", query = "@block.inner" }, + ic = { desc = "Select inner part of the class region", query = "@class.inner" }, + ["if"] = { desc = "Select inner part of the call region", query = "@call.inner" }, + il = { desc = "Select inner part of the loop region", query = "@loop.inner" }, + im = { desc = "Select inner part of the function region", query = "@function.inner" }, + is = { desc = "Select inner part of the statement region", query = "@statement.inner" }, + }, + lookahead = true, + selection_modes = { ["@block.outer"] = "", ["@class.outer"] = "", ["@function.outer"] = "V" }, + }, + swap = { + enable = true, + swap_next = { + ["sa"] = { desc = "Jump to next parameter", query = "@parameter.outer" }, + ["sd"] = { desc = "Jump to next conditional", query = "@conditional.outer" }, + ["sf"] = { desc = "Jump to next function", query = "@function.outer" }, + }, + swap_previous = { + ["SA"] = { desc = "Jump to previous parameter", query = "@parameter.outer" }, + ["SD"] = { desc = "Jump to previous conditional", query = "@conditional.outer" }, + ["SF"] = { desc = "Jump to previous function", query = "@function.outer" }, }, }, },