From fd1a4f6702d1447767d9b21131f1c751c787dd34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20La=C3=ADn?= Date: Sun, 1 Oct 2023 21:35:33 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat(nvim):=20big=20Changes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Null-ls changed to none-ls - Added keymap to see none-ls buffer info - Lualine style changed to slanted - Neo-tree handlers - Spectre new keymaps - Telescope fzf options and some keybindings - Which-key adapted to new spectre bind changes BREAKING CHANGE: - Null-ls changed to none-ls --- .config/nvim/lua/config/keymaps.lua | 9 ++----- .config/nvim/lua/plugins/lualine.lua | 2 ++ .config/nvim/lua/plugins/neo-tree.lua | 26 +++++++++++++++++++ .../lua/plugins/{null-ls.lua => none-ls.lua} | 2 +- .config/nvim/lua/plugins/spectre.lua | 14 ++++++++++ .../nvim/lua/plugins/telescope-all-recent.lua | 3 +++ .../nvim/lua/plugins/telescope-dap.lua.bak | 9 +++++++ .config/nvim/lua/plugins/telescope.lua | 19 +++++++++++--- .config/nvim/lua/plugins/which-key.lua | 1 + 9 files changed, 74 insertions(+), 11 deletions(-) rename .config/nvim/lua/plugins/{null-ls.lua => none-ls.lua} (95%) create mode 100644 .config/nvim/lua/plugins/spectre.lua create mode 100644 .config/nvim/lua/plugins/telescope-dap.lua.bak diff --git a/.config/nvim/lua/config/keymaps.lua b/.config/nvim/lua/config/keymaps.lua index 0a48e079..4d80a0e8 100644 --- a/.config/nvim/lua/config/keymaps.lua +++ b/.config/nvim/lua/config/keymaps.lua @@ -1,8 +1,6 @@ -- Keymaps are automatically loaded on the VeryLazy event -- Default keymaps that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/keymaps.lua -- Add any additional keymaps here -local Util = require("lazyvim.util") - local function map(mode, lhs, rhs, opts) local keys = require("lazy.core.handler").handlers.keys ---@cast keys LazyKeysHandler @@ -76,6 +74,8 @@ map("n", "sp", ":Telescope lazy", { desc = "Plugins (Lazy)" }) map("n", "si", ":Telescope import", { desc = "Imports" }) +map("n", "cn", ":NullLsInfo", { desc = "NullLs Info" }) + map( "n", "ft", @@ -312,11 +312,6 @@ vim.keymap.set({ "n", "x" }, "l", "lua Scroll('l', 0, 1)") vim.keymap.set({ "n", "x" }, "", "lua Scroll('h', 0, 1)") vim.keymap.set({ "n", "x" }, "", "lua Scroll('l', 0, 1)") --- SCROLL_WHEEL_KEYMAPS: - -vim.keymap.set({ "n", "x" }, "", "lua Scroll('')") -vim.keymap.set({ "n", "x" }, "", "lua Scroll('')") - vim.keymap.set("n", "", "noh", { noremap = true, silent = true, desc = "Clear Search" }) vim.keymap.set("n", "]b", require("goto-breakpoints").next, { desc = "Next Breakpoint" }) diff --git a/.config/nvim/lua/plugins/lualine.lua b/.config/nvim/lua/plugins/lualine.lua index 776e33eb..6da61a7e 100644 --- a/.config/nvim/lua/plugins/lualine.lua +++ b/.config/nvim/lua/plugins/lualine.lua @@ -11,6 +11,8 @@ return { theme = "catppuccin", globalstatus = true, disabled_filetypes = { statusline = { "dashboard", "alpha" } }, + component_separators = "", + section_separators = { left = "", right = "" }, }, sections = { lualine_a = { "mode" }, diff --git a/.config/nvim/lua/plugins/neo-tree.lua b/.config/nvim/lua/plugins/neo-tree.lua index 947ca79f..5e2536c3 100644 --- a/.config/nvim/lua/plugins/neo-tree.lua +++ b/.config/nvim/lua/plugins/neo-tree.lua @@ -76,6 +76,32 @@ return { }, }, config = function(_, opts) + opts.event_handlers = opts.event_handlers or {} + + local function on_move(data) + local clients = vim.lsp.get_active_clients() + for _, client in ipairs(clients) do + if client:supports_method("workspace/willRenameFiles") then + local resp = client.request_sync("workspace/willRenameFiles", { + files = { + { + oldUri = vim.uri_from_fname(data.source), + newUri = vim.uri_from_fname(data.destination), + }, + }, + }, 1000) + if resp and resp.result ~= nil then + vim.lsp.util.apply_workspace_edit(resp.result, client.offset_encoding) + end + end + end + end + + local events = require("neo-tree.events") + vim.list_extend(opts.event_handlers, { + { event = events.FILE_MOVED, handler = on_move }, + { event = events.FILE_RENAMED, handler = on_move }, + }) require("neo-tree").setup(opts) vim.api.nvim_create_autocmd("TermClose", { pattern = "*lazygit", diff --git a/.config/nvim/lua/plugins/null-ls.lua b/.config/nvim/lua/plugins/none-ls.lua similarity index 95% rename from .config/nvim/lua/plugins/null-ls.lua rename to .config/nvim/lua/plugins/none-ls.lua index 50bd1460..301b2bc9 100644 --- a/.config/nvim/lua/plugins/null-ls.lua +++ b/.config/nvim/lua/plugins/none-ls.lua @@ -1,6 +1,6 @@ return { { - "jose-elias-alvarez/null-ls.nvim", + "nvimtools/none-ls.nvim", opts = function(_, opts) local nls = require("null-ls") diff --git a/.config/nvim/lua/plugins/spectre.lua b/.config/nvim/lua/plugins/spectre.lua new file mode 100644 index 00000000..78d226ac --- /dev/null +++ b/.config/nvim/lua/plugins/spectre.lua @@ -0,0 +1,14 @@ +return { + { + "nvim-pack/nvim-spectre", + cmd = "Spectre", + opts = { open_cmd = "noswapfile vnew" }, + -- stylua: ignore + keys = { + { "srf", function() require("spectre").toggle() end, desc = "Replace globally" }, + { "srw", mode = {"n"},function() require("spectre").open_visual({select_word=true}) end, desc = "Current Word" }, + { "srw", mode = {"v"},function() require("spectre").open_visual() end, desc = "Current Word" }, + { "src", mode = {"n"},function() require("spectre").open_file_search({select_word=true}) end, desc = "Word on Current File" }, + }, + }, +} diff --git a/.config/nvim/lua/plugins/telescope-all-recent.lua b/.config/nvim/lua/plugins/telescope-all-recent.lua index 3556cc0c..5849837b 100644 --- a/.config/nvim/lua/plugins/telescope-all-recent.lua +++ b/.config/nvim/lua/plugins/telescope-all-recent.lua @@ -16,6 +16,9 @@ return { ["yanky.nvim#yank_history"] = { disable = true, }, + ["zoxide.nvim#zoxide"] = { + disable = true, + }, }, }) end, diff --git a/.config/nvim/lua/plugins/telescope-dap.lua.bak b/.config/nvim/lua/plugins/telescope-dap.lua.bak new file mode 100644 index 00000000..f31508d7 --- /dev/null +++ b/.config/nvim/lua/plugins/telescope-dap.lua.bak @@ -0,0 +1,9 @@ +return { + { + "nvim-telescope/telescope-dap.nvim", + requires = { "nvim-telescope/telescope.nvim" }, + config = function() + require("telescope").load_extension("dap") + end, + }, +} diff --git a/.config/nvim/lua/plugins/telescope.lua b/.config/nvim/lua/plugins/telescope.lua index b9e49364..cbb13fd9 100644 --- a/.config/nvim/lua/plugins/telescope.lua +++ b/.config/nvim/lua/plugins/telescope.lua @@ -1,5 +1,4 @@ local Util = require("lazyvim.util") -local macchiato = require("catppuccin.palettes").get_palette("macchiato") return { { @@ -404,10 +403,15 @@ return { Util.telescope("find_files", { hidden = true, default_text = line })() end - local TelescopeColor = {} - return { defaults = { + -- layout_strategy = "horizontal", + -- layout_config = { + -- horizontal = { + -- prompt_position = "top", + -- }, + -- }, + -- sorting_strategy = "ascending", prompt_prefix = " ", selection_caret = " ", mappings = { @@ -423,6 +427,9 @@ return { [""] = actions.move_selection_previous, [""] = actions.move_selection_next, [""] = actions.send_selected_to_qflist + actions.open_qflist, + [""] = actions.close, + [""] = false, + [""] = actions.delete_buffer + actions.move_to_top, }, n = { ["q"] = actions.close, @@ -455,6 +462,12 @@ return { -- Add imports to the top of the file keeping the cursor in place insert_at_top = true, }, + fzf = { + fuzzy = true, + override_generic_sorter = true, + override_file_sorter = true, + case_mode = "smart_case", + }, }, }, require("telescope").load_extension("refactoring"), diff --git a/.config/nvim/lua/plugins/which-key.lua b/.config/nvim/lua/plugins/which-key.lua index 6edd0ba0..9a873207 100644 --- a/.config/nvim/lua/plugins/which-key.lua +++ b/.config/nvim/lua/plugins/which-key.lua @@ -31,6 +31,7 @@ return { ["sS"] = { name = "+Goto Symbols (Workspace)" }, ["ss"] = { name = "+Goto Symbols" }, ["db"] = { name = "+Breakpoints" }, + ["sr"] = { name = "+replace" }, }, }, config = function(_, opts)