diff --git a/nvim/.config/nvim/lazy-lock.json b/nvim/.config/nvim/lazy-lock.json index 3fd89bc..d568aa3 100644 --- a/nvim/.config/nvim/lazy-lock.json +++ b/nvim/.config/nvim/lazy-lock.json @@ -3,7 +3,7 @@ "LuaSnip": { "branch": "master", "commit": "5a1e39223db9a0498024a77b8441169d260c8c25" }, "R.nvim": { "branch": "main", "commit": "659dc18aba2d2b799c04efbce66a15ea87bd6ec6" }, "barbecue": { "branch": "main", "commit": "cd7e7da622d68136e13721865b4d919efd6325ed" }, - "catppuccin": { "branch": "main", "commit": "beaf41a30c26fd7d6c386d383155cbd65dd554cd" }, + "catppuccin": { "branch": "main", "commit": "0a5de4da015a175f416d6ef1eda84661623e0500" }, "cmp-buffer": { "branch": "main", "commit": "b74fab3656eea9de20a9b8116afa3cfc4ec09657" }, "cmp-cmdline": { "branch": "main", "commit": "d126061b624e0af6c3a556428712dd4d4194ec6d" }, "cmp-nvim-lsp": { "branch": "main", "commit": "cbc7b02bb99fae35cb42f514762b89b5126651ef" }, @@ -12,7 +12,7 @@ "cmp-r": { "branch": "main", "commit": "70bfe8f4c062acc10266e24825439c009a0b1b89" }, "cmp-vimtex": { "branch": "master", "commit": "5283bf9108ef33d41e704027b9ef22437ce7a15b" }, "cmp_luasnip": { "branch": "master", "commit": "98d9cb5c2c38532bd9bdb481067b20fea8f32e90" }, - "conform.nvim": { "branch": "master", "commit": "c2526f1cde528a66e086ab1668e996d162c75f4f" }, + "conform.nvim": { "branch": "master", "commit": "e969e302bced7ffb9a0a0323629f31feb0ca35a6" }, "dashboard-nvim": { "branch": "master", "commit": "0775e567b6c0be96d01a61795f7b64c1758262f6" }, "diffview.nvim": { "branch": "main", "commit": "4516612fe98ff56ae0415a259ff6361a89419b0a" }, "dracula.nvim": { "branch": "main", "commit": "ae752c13e95fb7c5f58da4b5123cb804ea7568ee" }, @@ -20,36 +20,36 @@ "everforest": { "branch": "master", "commit": "b03a03148c8b34c24c96960b93da9c8883d11f54" }, "flash.nvim": { "branch": "main", "commit": "fcea7ff883235d9024dc41e638f164a450c14ca2" }, "friendly-snippets": { "branch": "main", "commit": "6cd7280adead7f586db6fccbd15d2cac7e2188b9" }, - "fzf-lua": { "branch": "main", "commit": "fb8c50ba62a0daa433b7ac2b78834f318322b879" }, - "gitsigns.nvim": { "branch": "main", "commit": "31217271a7314c343606acb4072a94a039a19fb5" }, + "fzf-lua": { "branch": "main", "commit": "76ddd6b56875bf4f6fd13848728207e738bb75a3" }, + "gitsigns.nvim": { "branch": "main", "commit": "9f3c6dd7868bcc116e9c1c1929ce063b978fa519" }, "grapple.nvim": { "branch": "main", "commit": "b41ddfc1c39f87f3d1799b99c2f0f1daa524c5f7" }, "gruvbox-mat": { "branch": "master", "commit": "790afe9dd085aa04eccd1da3626c5fa05c620e53" }, - "indent-blankline.nvim": { "branch": "master", "commit": "005b56001b2cb30bfa61b7986bc50657816ba4ba" }, + "indent-blankline.nvim": { "branch": "master", "commit": "d28a3f70721c79e3c5f6693057ae929f3d9c0a03" }, "kanagawa.nvim": { "branch": "master", "commit": "aef7f5cec0a40dbe7f3304214850c472e2264b10" }, "lazy.nvim": { "branch": "main", "commit": "306a05526ada86a7b30af95c5cc81ffba93fef97" }, "lazydev.nvim": { "branch": "main", "commit": "5231c62aa83c2f8dc8e7ba957aa77098cda1257d" }, - "live-preview.nvim": { "branch": "main", "commit": "f056b4b859d54595afce53e67129f7684380d3ba" }, + "live-preview.nvim": { "branch": "main", "commit": "4bbcbe79948b2726f00b5217277abd1e2651e699" }, "lualine.nvim": { "branch": "master", "commit": "47f91c416daef12db467145e16bed5bbfe00add8" }, "luvit-meta": { "branch": "main", "commit": "0ea4ff636c5bb559ffa78108561d0976f4de9682" }, - "mason-lspconfig.nvim": { "branch": "main", "commit": "ae609525ddf01c153c39305730b1791800ffe4fe" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "6c4830e37743b060d13c9269394176aea6a0fbc8" }, "mason-tool-installer.nvim": { "branch": "main", "commit": "443f1ef8b5e6bf47045cb2217b6f748a223cf7dc" }, "mason.nvim": { "branch": "main", "commit": "44d1e90e1f66e077268191e3ee9d2ac97cc18e65" }, "neo-tree.nvim": { "branch": "v3.x", "commit": "f3df514fff2bdd4318127c40470984137f87b62e" }, - "neogit": { "branch": "master", "commit": "73870229977fdd8747025820e15e98cfde787b9c" }, + "neogit": { "branch": "master", "commit": "0ea6b87ae19e8e5a235c682f8db1305774824f9b" }, "nightfox.nvim": { "branch": "main", "commit": "ba47d4b4c5ec308718641ba7402c143836f35aa9" }, "noice.nvim": { "branch": "main", "commit": "7bfd942445fb63089b59f97ca487d605e715f155" }, "nui.nvim": { "branch": "main", "commit": "de740991c12411b663994b2860f1a4fd0937c130" }, "nvim-autopairs": { "branch": "master", "commit": "59bce2eef357189c3305e25bc6dd2d138c1683f5" }, "nvim-cmp": { "branch": "main", "commit": "da88697d7f45d16852c6b2769dc52387d1ddc45f" }, "nvim-colorizer.lua": { "branch": "master", "commit": "a065833f35a3a7cc3ef137ac88b5381da2ba302e" }, - "nvim-lint": { "branch": "master", "commit": "bcd1a44edbea8cd473af7e7582d3f7ffc60d8e81" }, - "nvim-lspconfig": { "branch": "master", "commit": "f4e9d367d4e067d7a5fabc9fd3f1349b291eb718" }, + "nvim-lint": { "branch": "master", "commit": "486474c2ace8d78d28995074dbdbe29011bc63d0" }, + "nvim-lspconfig": { "branch": "master", "commit": "5a855bcfec7973767a1a472335684bbd71d2fa2b" }, "nvim-navic": { "branch": "master", "commit": "f5eba192f39b453675d115351808bd51276d9de5" }, "nvim-notify": { "branch": "master", "commit": "8701bece920b38ea289b457f902e2ad184131a5d" }, "nvim-spectre": { "branch": "master", "commit": "72f56f7585903cd7bf92c665351aa585e150af0f" }, - "nvim-surround": { "branch": "main", "commit": "1098d7b3c34adcfa7feb3289ee434529abd4afd1" }, + "nvim-surround": { "branch": "main", "commit": "b2f5ff27e603e0a756bd1926c476d2f219e6d42a" }, "nvim-tmux-navigation": { "branch": "main", "commit": "4898c98702954439233fdaf764c39636681e2861" }, - "nvim-treesitter": { "branch": "main", "commit": "9f2dad22ef8bb14fd1e0a3aa8859cdc88170668b" }, + "nvim-treesitter": { "branch": "main", "commit": "dc42c209f3820bdfaae0956f15de29689aa6b451" }, "nvim-treesitter-textobjects": { "branch": "main", "commit": "a0e182ae21fda68c59d1f36c9ed45600aef50311" }, "nvim-ts-context-commentstring": { "branch": "main", "commit": "1b212c2eee76d787bbea6aa5e92a2b534e7b4f8f" }, "nvim-ufo": { "branch": "main", "commit": "ab3eb124062422d276fae49e0dd63b3ad1062cfc" }, @@ -59,18 +59,18 @@ "plenary.nvim": { "branch": "master", "commit": "b9fd5226c2f76c951fc8ed5923d85e4de065e509" }, "portal.nvim": { "branch": "main", "commit": "77d9d53fec945bfa407d5fd7120f1b4f117450ed" }, "promise-async": { "branch": "main", "commit": "119e8961014c9bfaf1487bf3c2a393d254f337e2" }, - "rainbow-delimiters.nvim": { "branch": "master", "commit": "d6b802552cbe7d643a3b6b31f419c248d1f1e220" }, - "render-markdown.nvim": { "branch": "main", "commit": "48b4175dbca8439d30c1f52231cbe5a712c8f9d9" }, + "rainbow-delimiters.nvim": { "branch": "master", "commit": "e2858c43caafec291f915ef25fbed27bbe78abbd" }, + "render-markdown.nvim": { "branch": "main", "commit": "1c958131c083c8557ea499fdb08c88b8afb05c4e" }, "rose-pine": { "branch": "main", "commit": "cf2a288696b03d0934da713d66c6d71557b5c997" }, "snacks.nvim": { "branch": "main", "commit": "fe7cfe9800a182274d0f868a74b7263b8c0c020b" }, "sonokai": { "branch": "master", "commit": "b023c5280b16fe2366f5e779d8d2756b3e5ee9c3" }, "telescope-ui-select.nvim": { "branch": "master", "commit": "6e51d7da30bd139a6950adf2a47fda6df9fa06d2" }, - "telescope.nvim": { "branch": "master", "commit": "ad7d9580338354ccc136e5b8f0aa4f880434dcdc" }, + "telescope.nvim": { "branch": "master", "commit": "5255aa27c422de944791318024167ad5d40aad20" }, "todo-comments.nvim": { "branch": "main", "commit": "31e3c38ce9b29781e4422fc0322eb0a21f4e8668" }, "toggleterm.nvim": { "branch": "main", "commit": "50ea089fc548917cc3cc16b46a8211833b9e3c7c" }, "tokyonight": { "branch": "main", "commit": "5da1b76e64daf4c5d410f06bcb6b9cb640da7dfd" }, "trouble.nvim": { "branch": "main", "commit": "bd67efe408d4816e25e8491cc5ad4088e708a69a" }, "vimtex": { "branch": "master", "commit": "95b93a24740f7b89dd8331326b41bdd1337d79f6" }, "which-key.nvim": { "branch": "main", "commit": "3aab2147e74890957785941f0c1ad87d0a44c15a" }, - "yazi.nvim": { "branch": "main", "commit": "a3fe7b5855254974837c23c915865478b0d54534" } + "yazi.nvim": { "branch": "main", "commit": "854ac9c225fcfd8f0c8711819783366814da40eb" } } diff --git a/nvim/.config/nvim/lua/plugins.inactive/nvim-surround.lua b/nvim/.config/nvim/lua/plugins.inactive/nvim-surround.lua new file mode 100644 index 0000000..f4b686f --- /dev/null +++ b/nvim/.config/nvim/lua/plugins.inactive/nvim-surround.lua @@ -0,0 +1,228 @@ +-- nvim-surround.lua: Quickly add, delete, or change surrounding delimiters (e.g., brackets). + +-- nvim-surround configuration with autopairs, treesitter, and comment integration + +return { + -- nvim-surround: manipulate surroundings + { + "kylechui/nvim-surround", + version = "*", + event = "VeryLazy", + dependencies = { + "nvim-treesitter/nvim-treesitter", + "nvim-treesitter/nvim-treesitter-textobjects", + }, + config = function() + require("nvim-surround").setup({ + keymaps = { + insert = "s", + insert_line = "S", + normal = "ys", + normal_cur = "yss", + normal_line = "yS", + normal_cur_line = "ySS", + visual = "S", + visual_line = "gS", + delete = "ds", + change = "cs", + change_line = "cS", + }, + + -- Custom surrounds + surrounds = { + -- Function call surround + ["f"] = { + add = function() + local result = require("nvim-surround.config").get_input("Enter function name: ") + if result then + return { { result .. "(" }, { ")" } } + end + end, + find = function() + return require("nvim-surround.config").get_selection({ motion = "a(" }) + end, + delete = "^([^(]+%()().-(%))()$", + change = { + target = "^([^(]+%()().-(%))()$", + replacement = function() + local result = require("nvim-surround.config").get_input("Enter function name: ") + if result then + return { { result .. "(" }, { ")" } } + end + end, + }, + }, + + -- Markdown code block + ["c"] = { + add = function() + local lang = require("nvim-surround.config").get_input("Enter language: ") + return { { "```" .. (lang or "") }, { "```" } } + end, + }, + + -- HTML/JSX tag with class + ["C"] = { + add = function() + local class = require("nvim-surround.config").get_input("Enter class name: ") + if class then + return { { '
' }, { "
" } } + end + end, + }, + + -- Template literal (JavaScript/TypeScript) + ["`"] = { + add = { "`", "`" }, + find = "`.-`", + delete = "^(`)().-(`)()$", + }, + }, + + -- Use treesitter for better text object detection + move_cursor = "begin", + indent_lines = function(start, stop) + local b = vim.bo + -- Only indent if the buffer is not a special filetype + if b.ft ~= "help" and b.ft ~= "man" and b.ft ~= "qf" then + vim.cmd(string.format("silent normal! %dG=%dG", start, stop)) + end + end, + }) + end, + }, + + -- nvim-autopairs: auto-close brackets with integration + { + "windwp/nvim-autopairs", + event = "InsertEnter", + dependencies = { "hrsh7th/nvim-cmp" }, + config = function() + local npairs = require("nvim-autopairs") + local Rule = require("nvim-autopairs.rule") + local cond = require("nvim-autopairs.conds") + + npairs.setup({ + check_ts = true, -- Use treesitter + ts_config = { + lua = { "string", "source" }, + javascript = { "string", "template_string" }, + java = false, + }, + disable_filetype = { "TelescopePrompt", "spectre_panel" }, + fast_wrap = { + map = "", + chars = { "{", "[", "(", '"', "'" }, + pattern = string.gsub([[ [%'%"%)%>%]%)%}%,] ]], "%s+", ""), + offset = 0, + end_key = "$", + keys = "qwertyuiopzxcvbnmasdfghjkl", + check_comma = true, + highlight = "PmenuSel", + highlight_grey = "LineNr", + }, + enable_moveright = true, + enable_afterquote = true, + enable_check_bracket_line = true, + enable_bracket_in_quote = true, + enable_abbr = false, + break_undo = true, + map_cr = true, + map_bs = true, + map_c_h = false, + map_c_w = false, + }) + + -- Add spacing inside pairs + local brackets = { { "(", ")" }, { "[", "]" }, { "{", "}" } } + npairs.add_rules({ + Rule(" ", " "):with_pair(function(opts) + local pair = opts.line:sub(opts.col - 1, opts.col) + return vim.tbl_contains({ + brackets[1][1] .. brackets[1][2], + brackets[2][1] .. brackets[2][2], + brackets[3][1] .. brackets[3][2], + }, pair) + end), + }) + + for _, bracket in pairs(brackets) do + npairs.add_rules({ + Rule(bracket[1] .. " ", " " .. bracket[2]) + :with_pair(function() + return false + end) + :with_move(function(opts) + return opts.prev_char:match(".%" .. bracket[2]) ~= nil + end) + :use_key(bracket[2]), + }) + end + + -- Add arrow function for JavaScript/TypeScript + npairs.add_rules({ + Rule("%(.*%)%s*=>$", " { }", { "typescript", "typescriptreact", "javascript", "javascriptreact" }) + :use_regex(true) + :set_end_pair_length(2), + }) + + -- Integration with nvim-cmp + local cmp_autopairs = require("nvim-autopairs.completion.cmp") + local cmp = require("cmp") + cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done()) + end, + }, + + -- Comment.nvim: smart commenting with treesitter + { + "numToStr/Comment.nvim", + event = { "BufReadPre", "BufNewFile" }, + dependencies = { + "nvim-treesitter/nvim-treesitter", + "JoosepAlviste/nvim-ts-context-commentstring", -- For better JSX/TSX comments + }, + config = function() + require("Comment").setup({ + -- Use treesitter for comment detection + pre_hook = require("ts_context_commentstring.integrations.comment_nvim").create_pre_hook(), + + padding = true, + sticky = true, + ignore = "^$", -- Ignore empty lines + + -- LHS of toggle mappings in NORMAL mode + toggler = { + line = "gcc", -- Line-comment toggle + block = "gbc", -- Block-comment toggle + }, + + -- LHS of operator-pending mappings in NORMAL and VISUAL mode + opleader = { + line = "gc", -- Line-comment keymap + block = "gb", -- Block-comment keymap + }, + + -- LHS of extra mappings + extra = { + above = "gcO", -- Add comment on the line above + below = "gco", -- Add comment on the line below + eol = "gcA", -- Add comment at the end of line + }, + + mappings = { + basic = true, + extra = true, + }, + }) + end, + }, + + -- nvim-ts-context-commentstring: JSX/TSX comment support + { + "JoosepAlviste/nvim-ts-context-commentstring", + lazy = true, + opts = { + enable_autocmd = false, -- Disable auto commands, Comment.nvim handles it + }, + }, +} diff --git a/nvim/.config/nvim/lua/plugins/nvim-surround.lua b/nvim/.config/nvim/lua/plugins/nvim-surround.lua index f4b686f..6c9ae44 100644 --- a/nvim/.config/nvim/lua/plugins/nvim-surround.lua +++ b/nvim/.config/nvim/lua/plugins/nvim-surround.lua @@ -1,7 +1,3 @@ --- nvim-surround.lua: Quickly add, delete, or change surrounding delimiters (e.g., brackets). - --- nvim-surround configuration with autopairs, treesitter, and comment integration - return { -- nvim-surround: manipulate surroundings { @@ -14,19 +10,7 @@ return { }, config = function() require("nvim-surround").setup({ - keymaps = { - insert = "s", - insert_line = "S", - normal = "ys", - normal_cur = "yss", - normal_line = "yS", - normal_cur_line = "ySS", - visual = "S", - visual_line = "gS", - delete = "ds", - change = "cs", - change_line = "cS", - }, + -- Note: keymaps table removed for v4 compatibility -- Custom surrounds surrounds = { @@ -52,7 +36,6 @@ return { end, }, }, - -- Markdown code block ["c"] = { add = function() @@ -60,7 +43,6 @@ return { return { { "```" .. (lang or "") }, { "```" } } end, }, - -- HTML/JSX tag with class ["C"] = { add = function() @@ -70,15 +52,13 @@ return { end end, }, - - -- Template literal (JavaScript/TypeScript) + -- Template literal (JavaScript/TypeScript) - SYNTAX FIXED ["`"] = { add = { "`", "`" }, find = "`.-`", delete = "^(`)().-(`)()$", }, }, - -- Use treesitter for better text object detection move_cursor = "begin", indent_lines = function(start, stop) @@ -91,7 +71,6 @@ return { }) end, }, - -- nvim-autopairs: auto-close brackets with integration { "windwp/nvim-autopairs", @@ -101,7 +80,6 @@ return { local npairs = require("nvim-autopairs") local Rule = require("nvim-autopairs.rule") local cond = require("nvim-autopairs.conds") - npairs.setup({ check_ts = true, -- Use treesitter ts_config = { @@ -132,7 +110,6 @@ return { map_c_h = false, map_c_w = false, }) - -- Add spacing inside pairs local brackets = { { "(", ")" }, { "[", "]" }, { "{", "}" } } npairs.add_rules({ @@ -145,7 +122,6 @@ return { }, pair) end), }) - for _, bracket in pairs(brackets) do npairs.add_rules({ Rule(bracket[1] .. " ", " " .. bracket[2]) @@ -158,21 +134,18 @@ return { :use_key(bracket[2]), }) end - -- Add arrow function for JavaScript/TypeScript npairs.add_rules({ Rule("%(.*%)%s*=>$", " { }", { "typescript", "typescriptreact", "javascript", "javascriptreact" }) :use_regex(true) :set_end_pair_length(2), }) - -- Integration with nvim-cmp local cmp_autopairs = require("nvim-autopairs.completion.cmp") local cmp = require("cmp") cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done()) end, }, - -- Comment.nvim: smart commenting with treesitter { "numToStr/Comment.nvim", @@ -185,30 +158,25 @@ return { require("Comment").setup({ -- Use treesitter for comment detection pre_hook = require("ts_context_commentstring.integrations.comment_nvim").create_pre_hook(), - padding = true, sticky = true, ignore = "^$", -- Ignore empty lines - -- LHS of toggle mappings in NORMAL mode toggler = { line = "gcc", -- Line-comment toggle block = "gbc", -- Block-comment toggle }, - -- LHS of operator-pending mappings in NORMAL and VISUAL mode opleader = { line = "gc", -- Line-comment keymap block = "gb", -- Block-comment keymap }, - -- LHS of extra mappings extra = { above = "gcO", -- Add comment on the line above below = "gco", -- Add comment on the line below eol = "gcA", -- Add comment at the end of line }, - mappings = { basic = true, extra = true, @@ -216,7 +184,6 @@ return { }) end, }, - -- nvim-ts-context-commentstring: JSX/TSX comment support { "JoosepAlviste/nvim-ts-context-commentstring",