From fd83a29f1eacf6a7574f4fe294b757c332b53a6b Mon Sep 17 00:00:00 2001 From: darwincereska Date: Thu, 27 Nov 2025 13:38:49 -0500 Subject: [PATCH] working condition --- lazy-lock.json | 17 +++-- lua/plugins/autopairs.lua | 147 ++++++++++++++++++------------------ lua/plugins/completions.lua | 23 +++++- lua/plugins/surround.lua | 16 ++++ 4 files changed, 117 insertions(+), 86 deletions(-) create mode 100644 lua/plugins/surround.lua diff --git a/lazy-lock.json b/lazy-lock.json index 84a192f..6d1d685 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -17,13 +17,13 @@ "inc-rename.nvim": { "branch": "main", "commit": "2597bccb57d1b570fbdbd4adf88b955f7ade715b" }, "indent-blankline.nvim": { "branch": "master", "commit": "005b56001b2cb30bfa61b7986bc50657816ba4ba" }, "lazy.nvim": { "branch": "main", "commit": "85c7ff3711b730b4030d03144f6db6375044ae82" }, - "lualine.nvim": { "branch": "master", "commit": "3946f0122255bc377d14a59b27b609fb3ab25768" }, - "mason-lspconfig.nvim": { "branch": "main", "commit": "b1d9a914b02ba5660f1e272a03314b31d4576fe2" }, + "lualine.nvim": { "branch": "master", "commit": "47f91c416daef12db467145e16bed5bbfe00add8" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "7d527c76c43f46294de9c19d39c5a86317809b4b" }, "mason.nvim": { "branch": "main", "commit": "57e5a8addb8c71fb063ee4acda466c7cf6ad2800" }, "mdx.nvim": { "branch": "main", "commit": "464a74be368dce212cff02f6305845dc7f209ab3" }, "mini.icons": { "branch": "main", "commit": "ff2e4f1d29f659cc2bad0f9256f2f6195c6b2428" }, - "mini.nvim": { "branch": "main", "commit": "b409fd1d8b9ea7ec7c0923eb2562b52ed5d1ab0a" }, - "neo-tree.nvim": { "branch": "main", "commit": "0bf326c601063a6518aa9a039b71351debb83d2f" }, + "mini.nvim": { "branch": "main", "commit": "72b0194c56c984476c5975b62eb340fd1aa1686a" }, + "neo-tree.nvim": { "branch": "main", "commit": "a981ef287503c668434bffa78071d5b9ff92c12f" }, "noice.nvim": { "branch": "main", "commit": "7bfd942445fb63089b59f97ca487d605e715f155" }, "nord.nvim": { "branch": "main", "commit": "07647ad23e5b7fc1599a841dcd8f173b9aeb0419" }, "notes.nvim": { "branch": "main", "commit": "bd5dcb67227bc2102887c3285cd3c0f27f1b20fe" }, @@ -31,21 +31,22 @@ "nvim-autopairs": { "branch": "master", "commit": "7a2c97cccd60abc559344042fefb1d5a85b3e33b" }, "nvim-cmp": { "branch": "main", "commit": "d97d85e01339f01b842e6ec1502f639b080cb0fc" }, "nvim-colorizer.lua": { "branch": "master", "commit": "a065833f35a3a7cc3ef137ac88b5381da2ba302e" }, - "nvim-lspconfig": { "branch": "master", "commit": "b7c48a7111534b66bee077da8035ac7208a294ff" }, + "nvim-lspconfig": { "branch": "master", "commit": "07f4e93de92e8d4ea7ab99602e3a8c9ac0fb778a" }, "nvim-notify": { "branch": "master", "commit": "8701bece920b38ea289b457f902e2ad184131a5d" }, + "nvim-surround": { "branch": "main", "commit": "fcfa7e02323d57bfacc3a141f8a74498e1522064" }, "nvim-treesitter": { "branch": "master", "commit": "42fc28ba918343ebfd5565147a42a26580579482" }, "nvim-ufo": { "branch": "main", "commit": "72d54c31079d38d8dfc5456131b1d0fb5c0264b0" }, "nvim-web-devicons": { "branch": "master", "commit": "8dcb311b0c92d460fac00eac706abd43d94d68af" }, - "oil.nvim": { "branch": "master", "commit": "7e1cd7703ff2924d7038476dcbc04b950203b902" }, + "oil.nvim": { "branch": "master", "commit": "01cb3a8ad7d5e8707041edc775af83dbf33838f4" }, "plenary.nvim": { "branch": "master", "commit": "b9fd5226c2f76c951fc8ed5923d85e4de065e509" }, "presenting.nvim": { "branch": "main", "commit": "e78245995a09233e243bf48169b2f00dc76341f7" }, "promise-async": { "branch": "main", "commit": "119e8961014c9bfaf1487bf3c2a393d254f337e2" }, "render-markdown.nvim": { "branch": "main", "commit": "6e0e8902dac70fecbdd8ce557d142062a621ec38" }, "telescope-fzf-native.nvim": { "branch": "main", "commit": "6fea601bd2b694c6f2ae08a6c6fab14930c60e2c" }, - "telescope.nvim": { "branch": "master", "commit": "83a3a713d6b2d2a408491a1b959e55a7fa8678e8" }, + "telescope.nvim": { "branch": "master", "commit": "f0caedf064aa8c926325d7fe64c141d29b8e7853" }, "toggleterm.nvim": { "branch": "main", "commit": "50ea089fc548917cc3cc16b46a8211833b9e3c7c" }, "universal-clipboard.nvim": { "branch": "main", "commit": "48a625ab592633a05446ef66031611593a5b55d9" }, "vim-be-good": { "branch": "master", "commit": "0ae3de14eb8efc6effe7704b5e46495e91931cc5" }, - "vim-table-mode": { "branch": "master", "commit": "e156dbbedce0bbf61c0919db7678fa246fabd616" }, + "vim-table-mode": { "branch": "master", "commit": "bb025308a45c67c7c8f0763ba37bc2ee3f534df0" }, "which-key.nvim": { "branch": "main", "commit": "3aab2147e74890957785941f0c1ad87d0a44c15a" } } diff --git a/lua/plugins/autopairs.lua b/lua/plugins/autopairs.lua index 350dd56..dff6067 100644 --- a/lua/plugins/autopairs.lua +++ b/lua/plugins/autopairs.lua @@ -1,80 +1,79 @@ return { - 'windwp/nvim-autopairs', - event = "InsertEnter", - dependencies = { 'nvim-treesitter/nvim-treesitter' }, - config = function() - local npairs = require('nvim-autopairs') - local Rule = require('nvim-autopairs.rule') - local cond = require('nvim-autopairs.conds') - - npairs.setup({ - check_ts = true, -- Enable treesitter integration - ts_config = { - lua = {'string', 'source'}, - kotlin = {'string', 'comment'}, - java = {'string', 'comment'}, - }, - disable_filetype = { "TelescopePrompt", "spectre_panel" }, - disable_in_macro = false, - disable_in_visualblock = false, - disable_in_replace_mode = true, - ignored_next_char = [=[[%w%%%'%[%"%.%`%$]]=], - enable_moveright = true, - enable_afterquote = true, - enable_check_bracket_line = false, - 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, - - -- Fast wrap feature - press Alt+e to wrap selection - fast_wrap = { - map = '', - chars = { '{', '[', '(', '"', "'" }, - pattern = [=[[%'%"%>%]%)%}%,]]=], - offset = 0, - end_key = '$', - keys = 'qwertyuiopzxcvbnmasdfghjkl', - check_comma = true, - highlight = 'PmenuSel', - highlight_grey = 'LineNr' - }, - }) + 'windwp/nvim-autopairs', + event = "InsertEnter", + dependencies = { 'nvim-treesitter/nvim-treesitter' }, + config = function() + local npairs = require('nvim-autopairs') + local Rule = require('nvim-autopairs.rule') + local cond = require('nvim-autopairs.conds') - -- Custom rules for better Kotlin support - npairs.add_rules({ - -- Add spaces inside brackets for function calls - Rule(' ', ' ') - :with_pair(function(opts) - local pair = opts.line:sub(opts.col - 1, opts.col) - return vim.tbl_contains({ '()', '[]', '{}' }, pair) - end), - - -- Don't pair quotes after backslash - Rule('"', '"', 'kotlin') - :with_pair(cond.not_before_regex('\\', 1)), - - -- Smart pairing for lambda expressions - Rule('{', '}', 'kotlin') - :with_pair(function(opts) - -- Don't autopair if we're after forEach, let, etc. - local line = opts.line:sub(1, opts.col - 1) - if line:match('forEach%s*$') or line:match('let%s*$') or line:match('run%s*$') then - return false - end - return true - end), - }) + npairs.setup({ + check_ts = true, -- Enable treesitter integration + ts_config = { + lua = {'string', 'source'}, + kotlin = {'string', 'comment'}, + java = {'string', 'comment'}, + }, + disable_filetype = { "TelescopePrompt", "spectre_panel" }, + disable_in_macro = false, + disable_in_visualblock = false, + disable_in_replace_mode = true, + ignored_next_char = [=[[%w%%%'%[%"%.%`%$]]=], + enable_moveright = true, + enable_afterquote = true, + enable_check_bracket_line = false, + 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, - -- Integration with nvim-cmp if you have it - local cmp_status_ok, cmp = pcall(require, "cmp") - if cmp_status_ok then - local cmp_autopairs = require('nvim-autopairs.completion.cmp') - cmp.event:on('confirm_done', cmp_autopairs.on_confirm_done()) + -- Fast wrap feature - press Alt+e to wrap selection + fast_wrap = { + map = '', -- or whatever key you prefer + chars = { '{', '[', '(', '"', "'", '*' }, -- Added * here + pattern = [=[[%'%"%)%>%]%)%}%,]]=], + end_key = '$', + keys = 'qwertyuiopzxcvbnmasdfghjkl', + check_comma = true, + highlight = 'Search', + highlight_grey = 'Comment' + }, + }) + + -- Custom rules for better Kotlin support + npairs.add_rules({ + -- Add spaces inside brackets for function calls + Rule(' ', ' ') + :with_pair(function(opts) + local pair = opts.line:sub(opts.col - 1, opts.col) + return vim.tbl_contains({ '()', '[]', '{}' }, pair) + end), + + -- Don't pair quotes after backslash + Rule('"', '"', 'kotlin') + :with_pair(cond.not_before_regex('\\', 1)), + + -- Smart pairing for lambda expressions + Rule('{', '}', 'kotlin') + :with_pair(function(opts) + -- Don't autopair if we're after forEach, let, etc. + local line = opts.line:sub(1, opts.col - 1) + if line:match('forEach%s*$') or line:match('let%s*$') or line:match('run%s*$') then + return false + end + return true + end), + }) + + -- Integration with nvim-cmp if you have it + local cmp_status_ok, cmp = pcall(require, "cmp") + if cmp_status_ok then + local cmp_autopairs = require('nvim-autopairs.completion.cmp') + cmp.event:on('confirm_done', cmp_autopairs.on_confirm_done()) + end end - end } diff --git a/lua/plugins/completions.lua b/lua/plugins/completions.lua index a29593f..7dc644d 100644 --- a/lua/plugins/completions.lua +++ b/lua/plugins/completions.lua @@ -16,16 +16,30 @@ return { local cmp = require("cmp") local luasnip = require("luasnip") + -- Load VSCode-style snippets require("luasnip.loaders.from_vscode").lazy_load() + -- Highlighting for completion windows vim.api.nvim_set_hl(0, "CmpBorder", { link = "FloatBorder" }) vim.api.nvim_set_hl(0, "CmpDocBorder", { link = "FloatBorder" }) vim.api.nvim_set_hl(0, "CmpDocNormal", { link = "NormalFloat" }) + local snippets_enabled = true + + -- Toggle function for snippets + function toggle_snippets() + snippets_enabled = not snippets_enabled + end + + -- Key mapping to toggle snippets + vim.api.nvim_set_keymap('n', 'ts', ':lua toggle_snippets()', { noremap = true, silent = true }) + cmp.setup({ snippet = { expand = function(args) - luasnip.lsp_expand(args.body) + if snippets_enabled then + luasnip.lsp_expand(args.body) + end end, }, @@ -39,7 +53,7 @@ return { [""] = cmp.mapping(function(fallback) if cmp.visible() then cmp.select_next_item() - elseif luasnip.expand_or_jumpable() then + elseif snippets_enabled and luasnip.expand_or_jumpable() then luasnip.expand_or_jump() else fallback() @@ -49,7 +63,7 @@ return { [""] = cmp.mapping(function(fallback) if cmp.visible() then cmp.select_prev_item() - elseif luasnip.jumpable(-1) then + elseif snippets_enabled and luasnip.jumpable(-1) then luasnip.jump(-1) else fallback() @@ -60,7 +74,7 @@ return { sources = cmp.config.sources({ { name = "nvim_lsp" }, { name = "luasnip" }, - { name = "buffer" }, + { name = "buffer", keyword_length = 3 }, { name = "path" }, { name = "spell" }, }), @@ -113,3 +127,4 @@ return { end, }, } + diff --git a/lua/plugins/surround.lua b/lua/plugins/surround.lua new file mode 100644 index 0000000..4129042 --- /dev/null +++ b/lua/plugins/surround.lua @@ -0,0 +1,16 @@ +return { + "kylechui/nvim-surround", + version = "*", + event = "VeryLazy", + config = function() + require("nvim-surround").setup({ + surrounds = { + ["*"] = { -- 'b' for bold + add = { "**", "**" }, + find = "%*%*.-%*%*", + delete = "^(%*%*)().-(%*%*)()$", + }, + } + }) + end +}