From 42796862073cae4e5dedd9f83d714e9eed193f33 Mon Sep 17 00:00:00 2001 From: Daniel Heras Quesada Date: Mon, 22 Sep 2025 12:17:57 +0200 Subject: [PATCH] feat: basic config on search and minor styling --- lazy-lock.json | 5 +- lua/config/remap.lua | 163 ++++++++++++++++++---------------- lua/plugins/context.lua | 130 +++++++++++++-------------- lua/plugins/opts/gitsigns.lua | 94 ++++++++++---------- lua/plugins/search.lua | 56 ++++++------ 5 files changed, 233 insertions(+), 215 deletions(-) diff --git a/lazy-lock.json b/lazy-lock.json index 3292036..3a7e58a 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -4,6 +4,7 @@ "blueprints": { "branch": "main", "commit": "e5825c30464f98e77e8b5ffb88d59fd98df6c802" }, "bufferline.nvim": { "branch": "main", "commit": "655133c3b4c3e5e05ec549b9f8cc2894ac6f51b3" }, "conform.nvim": { "branch": "master", "commit": "b4aab989db276993ea5dcb78872be494ce546521" }, + "ctrlsf.vim": { "branch": "master", "commit": "50186c529c881b7844bcd66c7b8e9826eb8990a4" }, "diffview.nvim": { "branch": "main", "commit": "4516612fe98ff56ae0415a259ff6361a89419b0a" }, "friendly-snippets": { "branch": "main", "commit": "572f5660cf05f8cd8834e096d7b4c921ba18e175" }, "gitsigns.nvim": { "branch": "main", "commit": "f780609807eca1f783a36a8a31c30a48fbe150c5" }, @@ -17,6 +18,7 @@ "no-neck-pain.nvim": { "branch": "main", "commit": "0463fbb77bcab4cc9716ba1e87255bbe4d002de7" }, "noice.nvim": { "branch": "main", "commit": "0427460c2d7f673ad60eb02b35f5e9926cf67c59" }, "nui.nvim": { "branch": "main", "commit": "de740991c12411b663994b2860f1a4fd0937c130" }, + "nvim-spectre": { "branch": "master", "commit": "72f56f7585903cd7bf92c665351aa585e150af0f" }, "nvim-treesitter": { "branch": "master", "commit": "42fc28ba918343ebfd5565147a42a26580579482" }, "nvim-treesitter-context": { "branch": "master", "commit": "41847d3dafb5004464708a3db06b14f12bde548a" }, "nvim-ts-autotag": { "branch": "main", "commit": "c4ca798ab95b316a768d51eaaaee48f64a4a46bc" }, @@ -32,5 +34,6 @@ "telescope.nvim": { "branch": "master", "commit": "b4da76be54691e854d3e0e02c36b0245f945c2c7" }, "todo-comments.nvim": { "branch": "main", "commit": "304a8d204ee787d2544d8bc23cd38d2f929e7cc5" }, "trouble.nvim": { "branch": "main", "commit": "85bedb7eb7fa331a2ccbecb9202d8abba64d37b3" }, - "vim-fugitive": { "branch": "master", "commit": "61b51c09b7c9ce04e821f6cf76ea4f6f903e3cf4" } + "vim-fugitive": { "branch": "master", "commit": "61b51c09b7c9ce04e821f6cf76ea4f6f903e3cf4" }, + "windline.nvim": { "branch": "master", "commit": "1630ab15aa3349f1ad32ef78d5cff632ae74625d" } } diff --git a/lua/config/remap.lua b/lua/config/remap.lua index 1256128..9cbcb67 100644 --- a/lua/config/remap.lua +++ b/lua/config/remap.lua @@ -17,10 +17,10 @@ map("n", "", "BufferLineMoveNext", { desc = "Move buffer to right" map("n", "[b", "bprevious", { desc = "Prev Buffer" }) map("n", "]b", "bnext", { desc = "Next Buffer" }) map("n", "bd", function() - Snacks.bufdelete() + Snacks.bufdelete() end, { desc = "Delete Buffer" }) map("n", "x", function() - Snacks.bufdelete() + Snacks.bufdelete() end, { desc = "Delete Buffer" }) -- tabpages @@ -34,7 +34,18 @@ map("n", "nt", ":tabnew", { desc = "Create new tabpage" }) map("n", "tc", "TSContextToggle", { desc = "Toggle treesitter context" }) -- Regex search and replace -map("n", "fs", "GrugFar", { desc = "Search all with replace option" }) +map("n", "S", 'lua require("spectre").toggle()', { + desc = "Toggle Spectre", +}) +map("n", "sw", 'lua require("spectre").open_visual({select_word=true})', { + desc = "Search current word", +}) +map("v", "sw", 'lua require("spectre").open_visual()', { + desc = "Search current word", +}) +map("n", "sp", 'lua require("spectre").open_file_search({select_word=true})', { + desc = "Search on current file", +}) -- Blueprints map("n", "ct", "lua require('blueprints').createFromTemplateTelescope()", { desc = "Nvim blueprints" }) @@ -52,28 +63,28 @@ map("n", "gs", "Telescope git_status ", { desc = "Git status" } -- lazygit map("n", "gg", function() - Snacks.lazygit({ cwd = LazyVim.root.git() }) + Snacks.lazygit({ cwd = LazyVim.root.git() }) end, { desc = "Lazygit (Root Dir)" }) map("n", "gG", function() - Snacks.lazygit() + Snacks.lazygit() end, { desc = "Lazygit (cwd)" }) map("n", "gb", function() - Snacks.lazygit.blame_line() + Snacks.lazygit.blame_line() end, { desc = "Git Blame Line" }) map("n", "gB", function() - Snacks.lazygit.browse() + Snacks.lazygit.browse() end, { desc = "Git Browse" }) map("n", "gf", function() - local git_path = vim.api.nvim_buf_get_name(0) - Snacks.lazygit({ args = { "-f", vim.trim(git_path) } }) + local git_path = vim.api.nvim_buf_get_name(0) + Snacks.lazygit({ args = { "-f", vim.trim(git_path) } }) end, { desc = "Lazygit Current File History" }) map("n", "gl", function() - Snacks.lazygit({ args = { "log" }, cwd = LazyVim.root.git() }) + Snacks.lazygit({ args = { "log" }, cwd = LazyVim.root.git() }) end, { desc = "Lazygit Log" }) map("n", "gL", function() - Snacks.lazygit({ args = { "log" } }) + Snacks.lazygit({ args = { "log" } }) end, { desc = "Lazygit Log (cwd)" }) --------------------------------------------------------------------------- @@ -84,74 +95,74 @@ map("n", "e", "Neotree focus", { desc = "Focus neotree" }) -- LSP map("n", "gD", function() - vim.lsp.buf.declaration() + vim.lsp.buf.declaration() end, { desc = "LSP declaration" }) map("n", "gd", function() - vim.lsp.buf.definition() + vim.lsp.buf.definition() end, { desc = "LSP definition" }) map("n", "gr", function() - vim.lsp.buf.references() + vim.lsp.buf.references() end, { desc = "LSP references" }) map("n", "K", function() - vim.lsp.buf.hover() + vim.lsp.buf.hover() end, { desc = "LSP hover" }) map("n", "gi", function() - vim.lsp.buf.implementation() + vim.lsp.buf.implementation() end, { desc = "LSP implementation" }) map("n", "ls", function() - vim.lsp.buf.signature_help() + vim.lsp.buf.signature_help() end, { desc = "LSP signature help" }) map("n", "lf", function() - vim.diagnostic.open_float({ border = "rounded" }) + vim.diagnostic.open_float({ border = "rounded" }) end, { desc = "Floating diagnostics" }) map("n", "D", function() - vim.lsp.buf.type_definition() + vim.lsp.buf.type_definition() end, { desc = "LSP type definition" }) map("n", "ca", function() - vim.lsp.buf.code_action() + vim.lsp.buf.code_action() end, { desc = "LSP code actions" }) map("n", "[d", function() - vim.diagnostic.goto_prev({ float = { border = "rounded" } }) + vim.diagnostic.goto_prev({ float = { border = "rounded" } }) end, { desc = "Goto prev diagnostic" }) map("n", "]d", function() - vim.diagnostic.goto_next({ float = { border = "rounded" } }) + vim.diagnostic.goto_next({ float = { border = "rounded" } }) end, { desc = "Goto next diagnostic" }) map("v", "ca", function() - vim.lsp.buf.code_action() + vim.lsp.buf.code_action() end, { desc = "LSP code action" }) map("n", "r", function() - -- when rename opens the prompt, this autocommand will trigger - -- it will "press" CTRL-F to enter the command-line window `:h cmdwin` - -- in this window I can use normal mode keybindings - local cmdId - cmdId = vim.api.nvim_create_autocmd({ "CmdlineEnter" }, { - callback = function() - local key = vim.api.nvim_replace_termcodes("", true, false, true) - vim.api.nvim_feedkeys(key, "c", false) - vim.api.nvim_feedkeys("0", "n", false) - -- autocmd was triggered and so we can remove the ID and return true to delete the autocmd - cmdId = nil - return true - end, - }) - vim.lsp.buf.rename() - -- if LPS couldn't trigger rename on the symbol, clear the autocmd - vim.defer_fn(function() - -- the cmdId is not nil only if the LSP failed to rename - if cmdId then - vim.api.nvim_del_autocmd(cmdId) - end - end, 500) + -- when rename opens the prompt, this autocommand will trigger + -- it will "press" CTRL-F to enter the command-line window `:h cmdwin` + -- in this window I can use normal mode keybindings + local cmdId + cmdId = vim.api.nvim_create_autocmd({ "CmdlineEnter" }, { + callback = function() + local key = vim.api.nvim_replace_termcodes("", true, false, true) + vim.api.nvim_feedkeys(key, "c", false) + vim.api.nvim_feedkeys("0", "n", false) + -- autocmd was triggered and so we can remove the ID and return true to delete the autocmd + cmdId = nil + return true + end, + }) + vim.lsp.buf.rename() + -- if LPS couldn't trigger rename on the symbol, clear the autocmd + vim.defer_fn(function() + -- the cmdId is not nil only if the LSP failed to rename + if cmdId then + vim.api.nvim_del_autocmd(cmdId) + end + end, 500) end, { desc = "Rename symbol" }) map("n", "wa", function() - vim.lsp.buf.add_workspace_folder() + vim.lsp.buf.add_workspace_folder() end, { desc = "Add workspace folder" }) map("n", "wr", function() - vim.lsp.buf.remove_workspace_folder() + vim.lsp.buf.remove_workspace_folder() end, { desc = "Remove workspace folder" }) map("n", "wl", function() - print(vim.inspect(vim.lsp.buf.list_workspace_folders())) + print(vim.inspect(vim.lsp.buf.list_workspace_folders())) end, { desc = "List workspace folders" }) ---- Debugging with dap ---- @@ -203,10 +214,10 @@ map({ "i", "n" }, "", "noh", { desc = "Escape and Clear hlsea -- Clear search, diff update and redraw -- taken from runtime/lua/_editor.lua map( - "n", - "ur", - "nohlsearchdiffupdatenormal! ", - { desc = "Redraw / Clear hlsearch / Diff Update" } + "n", + "ur", + "nohlsearchdiffupdatenormal! ", + { desc = "Redraw / Clear hlsearch / Diff Update" } ) -- https://github.com/mhinz/vim-galore#saner-behavior-of-n-and-n @@ -237,16 +248,16 @@ map("n", "]q", vim.cmd.cnext, { desc = "Next Quickfix" }) -- formatting map({ "n", "v" }, "cf", function() - require("conform").format() + require("conform").format() end, { desc = "Format" }) -- diagnostic local diagnostic_goto = function(next, severity) - local go = next and vim.diagnostic.goto_next or vim.diagnostic.goto_prev - severity = severity and vim.diagnostic.severity[severity] or nil - return function() - go({ severity = severity }) - end + local go = next and vim.diagnostic.goto_next or vim.diagnostic.goto_prev + severity = severity and vim.diagnostic.severity[severity] or nil + return function() + go({ severity = severity }) + end end map("n", "cd", vim.diagnostic.open_float, { desc = "Line Diagnostics" }) map("n", "]d", diagnostic_goto(true), { desc = "Next Diagnostic" }) @@ -259,44 +270,44 @@ map("n", "[w", diagnostic_goto(false, "WARN"), { desc = "Prev Warning" }) ---- Toggle options ---- map("n", "uf", function() - LazyVim.format.toggle() + LazyVim.format.toggle() end, { desc = "Toggle Auto Format (Global)" }) map("n", "uF", function() - LazyVim.format.toggle(true) + LazyVim.format.toggle(true) end, { desc = "Toggle Auto Format (Buffer)" }) map("n", "us", function() - LazyVim.toggle("spell") + LazyVim.toggle("spell") end, { desc = "Toggle Spelling" }) map("n", "uw", function() - LazyVim.toggle("wrap") + LazyVim.toggle("wrap") end, { desc = "Toggle Word Wrap" }) map("n", "uL", function() - LazyVim.toggle("relativenumber") + LazyVim.toggle("relativenumber") end, { desc = "Toggle Relative Line Numbers" }) map("n", "ul", function() - LazyVim.toggle.number() + LazyVim.toggle.number() end, { desc = "Toggle Line Numbers" }) map("n", "ud", function() - LazyVim.toggle.diagnostics() + LazyVim.toggle.diagnostics() end, { desc = "Toggle Diagnostics" }) local conceallevel = vim.o.conceallevel > 0 and vim.o.conceallevel or 3 map("n", "uc", function() - LazyVim.toggle("conceallevel", false, { 0, conceallevel }) + LazyVim.toggle("conceallevel", false, { 0, conceallevel }) end, { desc = "Toggle Conceal" }) if vim.lsp.buf.inlay_hint or vim.lsp.inlay_hint then - map("n", "uh", function() - LazyVim.toggle.inlay_hints() - end, { desc = "Toggle Inlay Hints" }) + map("n", "uh", function() + LazyVim.toggle.inlay_hints() + end, { desc = "Toggle Inlay Hints" }) end map("n", "uT", function() - if vim.b.ts_highlight then - vim.treesitter.stop() - else - vim.treesitter.start() - end + if vim.b.ts_highlight then + vim.treesitter.stop() + else + vim.treesitter.start() + end end, { desc = "Toggle Treesitter Highlight" }) map("n", "ub", function() - LazyVim.toggle("background", false, { "light", "dark" }) + LazyVim.toggle("background", false, { "light", "dark" }) end, { desc = "Toggle Background" }) -- aerial map("n", "ua", "AerialToggle", { desc = "Toggle aerial view" }) @@ -331,7 +342,7 @@ map("n", "w|", "v", { desc = "Split Window Right", remap = true }) map("n", "-", "s", { desc = "Split Window Below", remap = true }) map("n", "|", "v", { desc = "Split Window Right", remap = true }) map("n", "wm", function() - LazyVim.toggle.maximize() + LazyVim.toggle.maximize() end, { desc = "Maximize Toggle" }) -- Move to window using the hjkl keys diff --git a/lua/plugins/context.lua b/lua/plugins/context.lua index 5d8535b..d436d42 100644 --- a/lua/plugins/context.lua +++ b/lua/plugins/context.lua @@ -2,73 +2,73 @@ -- │ Context │ -- ╰─────────╯ return { - { - "akinsho/bufferline.nvim", - version = "*", - dependencies = "nvim-tree/nvim-web-devicons", - opts = function() - return require("plugins.opts.bufferline") - end, - }, + { + "akinsho/bufferline.nvim", + version = "*", + dependencies = "nvim-tree/nvim-web-devicons", + opts = function() + return require("plugins.opts.bufferline") + end, + }, - { - "nvim-lualine/lualine.nvim", - event = "VeryLazy", - dependencies = { "nvim-tree/nvim-web-devicons" }, - opts = function() - return require("plugins.opts.lualine") - end, - }, + { + "nvim-lualine/lualine.nvim", + event = "VeryLazy", + dependencies = { "nvim-tree/nvim-web-devicons" }, + opts = function() + return require("plugins.opts.lualine") + end, + }, - { - "nvim-neo-tree/neo-tree.nvim", - dependencies = { - "nvim-lua/plenary.nvim", - "nvim-tree/nvim-web-devicons", - "MunifTanjim/nui.nvim", - { - "s1n7ax/nvim-window-picker", - version = "2.*", - config = function() - require("window-picker").setup({ - filter_rules = { - include_current_win = false, - autoselect_one = true, - bo = { - filetype = { "neo-tree", "neo-tree-popup", "notify" }, - buftype = { "terminal", "quickfix" }, - }, - }, - }) - end, - }, - }, - opts = function() - return require("plugins.opts.neotree") - end, - }, + { + "nvim-neo-tree/neo-tree.nvim", + dependencies = { + "nvim-lua/plenary.nvim", + "nvim-tree/nvim-web-devicons", + "MunifTanjim/nui.nvim", + { + "s1n7ax/nvim-window-picker", + version = "2.*", + config = function() + require("window-picker").setup({ + filter_rules = { + include_current_win = false, + autoselect_one = true, + bo = { + filetype = { "neo-tree", "neo-tree-popup", "notify" }, + buftype = { "terminal", "quickfix" }, + }, + }, + }) + end, + }, + }, + opts = function() + return require("plugins.opts.neotree") + end, + }, - { - "stevearc/aerial.nvim", - opts = {}, - dependencies = { - "nvim-treesitter/nvim-treesitter", - "nvim-tree/nvim-web-devicons", - }, - }, + { + "stevearc/aerial.nvim", + opts = {}, + dependencies = { + "nvim-treesitter/nvim-treesitter", + "nvim-tree/nvim-web-devicons", + }, + }, - { - "lukas-reineke/indent-blankline.nvim", - main = "ibl", - opts = {}, - init = function() - require("ibl").setup({ - whitespace = { - highlight = { "Whitespace", "NonText" }, - remove_blankline_trail = true, - }, - scope = { exclude = { language = { "lua", "css" } } }, - }) - end, - }, + { + "lukas-reineke/indent-blankline.nvim", + main = "ibl", + opts = {}, + init = function() + require("ibl").setup({ + whitespace = { + highlight = { "Whitespace", "NonText" }, + remove_blankline_trail = true, + }, + scope = { exclude = { language = { "lua", "css" } } }, + }) + end, + }, } diff --git a/lua/plugins/opts/gitsigns.lua b/lua/plugins/opts/gitsigns.lua index aaccc62..abda5ea 100644 --- a/lua/plugins/opts/gitsigns.lua +++ b/lua/plugins/opts/gitsigns.lua @@ -1,51 +1,51 @@ local config = { - signs = { - add = { text = '┃' }, - change = { text = '┃' }, - delete = { text = '_' }, - topdelete = { text = '‾' }, - changedelete = { text = '~' }, - untracked = { text = '┆' }, - }, - signs_staged = { - add = { text = '┃' }, - change = { text = '┃' }, - delete = { text = '_' }, - topdelete = { text = '‾' }, - changedelete = { text = '~' }, - untracked = { text = '┆' }, - }, - signs_staged_enable = true, - signcolumn = true, -- Toggle with `:Gitsigns toggle_signs` - numhl = true, -- Toggle with `:Gitsigns toggle_numhl` - linehl = false, -- Toggle with `:Gitsigns toggle_linehl` - word_diff = false, -- Toggle with `:Gitsigns toggle_word_diff` - watch_gitdir = { - follow_files = true, - }, - auto_attach = true, - attach_to_untracked = false, - current_line_blame = true, -- Toggle with `:Gitsigns toggle_current_line_blame` - current_line_blame_opts = { - virt_text = true, - virt_text_pos = "eol", -- 'eol' | 'overlay' | 'right_align' - delay = 500, - ignore_whitespace = false, - virt_text_priority = 100, - }, - current_line_blame_formatter = ", - ", - sign_priority = 6, - update_debounce = 100, - status_formatter = nil, -- Use default - max_file_length = 40000, -- Disable if file is longer than this (in lines) - preview_config = { - -- Options passed to nvim_open_win - border = "single", - style = "minimal", - relative = "cursor", - row = 0, - col = 1, - }, + signs = { + add = { text = "┃" }, + change = { text = "┃" }, + delete = { text = "_" }, + topdelete = { text = "‾" }, + changedelete = { text = "~" }, + untracked = { text = "┆" }, + }, + signs_staged = { + add = { text = "┃" }, + change = { text = "┃" }, + delete = { text = "_" }, + topdelete = { text = "‾" }, + changedelete = { text = "~" }, + untracked = { text = "┆" }, + }, + signs_staged_enable = true, + signcolumn = true, -- Toggle with `:Gitsigns toggle_signs` + numhl = true, -- Toggle with `:Gitsigns toggle_numhl` + linehl = false, -- Toggle with `:Gitsigns toggle_linehl` + word_diff = false, -- Toggle with `:Gitsigns toggle_word_diff` + watch_gitdir = { + follow_files = true, + }, + auto_attach = true, + attach_to_untracked = false, + current_line_blame = true, -- Toggle with `:Gitsigns toggle_current_line_blame` + current_line_blame_opts = { + virt_text = true, + virt_text_pos = "eol", -- 'eol' | 'overlay' | 'right_align' + delay = 500, + ignore_whitespace = false, + virt_text_priority = 100, + }, + current_line_blame_formatter = ", - ", + sign_priority = 6, + update_debounce = 100, + status_formatter = nil, -- Use default + max_file_length = 40000, -- Disable if file is longer than this (in lines) + preview_config = { + -- Options passed to nvim_open_win + border = "single", + style = "minimal", + relative = "cursor", + row = 0, + col = 1, + }, } return config diff --git a/lua/plugins/search.lua b/lua/plugins/search.lua index 2b6b98c..89c9bc2 100644 --- a/lua/plugins/search.lua +++ b/lua/plugins/search.lua @@ -2,31 +2,35 @@ -- │ Telescope │ -- ╰───────────╯ return { - { - "nvim-telescope/telescope.nvim", - dependencies = { - "nvim-treesitter/nvim-treesitter", - { "nvim-telescope/telescope-fzf-native.nvim", build = "make" }, - { - "isak102/telescope-git-file-history.nvim", - dependencies = { - "nvim-lua/plenary.nvim", - "tpope/vim-fugitive", - }, - }, - }, - cmd = "Telescope", - opts = function() - return require("plugins.opts.telescope") - end, - config = function(_, opts) - local telescope = require("telescope") - telescope.setup(opts) + { + "nvim-telescope/telescope.nvim", + dependencies = { + "nvim-treesitter/nvim-treesitter", + { "nvim-telescope/telescope-fzf-native.nvim", build = "make" }, + { + "isak102/telescope-git-file-history.nvim", + dependencies = { + "nvim-lua/plenary.nvim", + "tpope/vim-fugitive", + }, + }, + }, + cmd = "Telescope", + opts = function() + return require("plugins.opts.telescope") + end, + config = function(_, opts) + local telescope = require("telescope") + telescope.setup(opts) - -- load extensions - for _, ext in ipairs(opts.extensions_list) do - telescope.load_extension(ext) - end - end, - }, + -- load extensions + for _, ext in ipairs(opts.extensions_list) do + telescope.load_extension(ext) + end + end, + }, + -- Multi buffer search + { + "nvim-pack/nvim-spectre", + }, }