From df7c711e2a49d51249350f52c63274b72aacb739 Mon Sep 17 00:00:00 2001 From: Elvis Claros Castro Date: Sun, 27 Sep 2026 12:46:49 -0300 Subject: =?UTF-8?q?Migraci=C3=B3n=20de=20plugins=20a=20funcionalidad=20nat?= =?UTF-8?q?iva:=20statusline=20y=20treesitter=20propios,=20se=20quitan=20m?= =?UTF-8?q?ason,=20lualine,=20mini,=20notify=20y=20otros?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lazy-lock.json | 93 +++++---------- lua/config/autocmds.lua | 137 +++++++++++++++++++++- lua/config/init.lua | 3 + lua/config/keymaps.lua | 51 +++++++++ lua/config/lazy.lua | 2 +- lua/config/options.lua | 6 +- lua/config/statusline.lua | 214 ++++++++++++++++++++++++++++++++++ lua/pi/animations.lua | 71 +++++------- lua/pi/dap/configs/cpp.lua | 46 +++++--- lua/pi/lsp/attach.lua | 2 +- lua/pi/lsp/default.lua | 4 - lua/pi/lsp/init.lua | 13 --- lua/pi/lsp/mason.lua | 33 ------ lua/pi/snips/ft/go.lua | 24 ++-- lua/pi/treesitter.lua | 248 ++++++++++++++++++++++++++++++++++++++++ lua/plugins/animation.lua | 11 -- lua/plugins/buffer_manager.lua | 24 ---- lua/plugins/close-buffer.lua | 12 -- lua/plugins/code-annotation.lua | 11 -- lua/plugins/codecompanion.lua | 6 +- lua/plugins/color-picker.lua | 7 -- lua/plugins/colorize.lua | 34 +++--- lua/plugins/completition.lua | 20 ++++ lua/plugins/flutter.lua | 1 - lua/plugins/gitsigns.lua | 11 +- lua/plugins/icon-picker.lua | 9 -- lua/plugins/indent-o-matic.lua | 5 - lua/plugins/init.lua | 11 -- lua/plugins/json-nvim.lua | 8 -- lua/plugins/laravel.lua | 8 +- lua/plugins/lsp.lua | 18 +-- lua/plugins/lualine.lua | 233 ------------------------------------- lua/plugins/menu.lua | 28 ----- lua/plugins/mini.lua | 7 -- lua/plugins/minty.lua | 28 ++++- lua/plugins/navigator.lua | 41 ------- lua/plugins/neorg.lua | 3 +- lua/plugins/neotest.lua | 1 - lua/plugins/noice.lua | 243 +++------------------------------------ lua/plugins/notify.lua | 10 -- lua/plugins/project-config.lua | 5 - lua/plugins/rest.lua | 55 --------- lua/plugins/rustaceanvim.lua | 14 +++ lua/plugins/snacks.lua | 10 ++ lua/plugins/treesitter.lua | 182 +++++++---------------------- lua/plugins/undotree.lua | 11 -- 46 files changed, 935 insertions(+), 1079 deletions(-) create mode 100644 lua/config/statusline.lua delete mode 100644 lua/pi/lsp/mason.lua create mode 100644 lua/pi/treesitter.lua delete mode 100644 lua/plugins/animation.lua delete mode 100644 lua/plugins/buffer_manager.lua delete mode 100644 lua/plugins/close-buffer.lua delete mode 100644 lua/plugins/color-picker.lua delete mode 100644 lua/plugins/icon-picker.lua delete mode 100644 lua/plugins/indent-o-matic.lua delete mode 100644 lua/plugins/json-nvim.lua delete mode 100644 lua/plugins/lualine.lua delete mode 100644 lua/plugins/menu.lua delete mode 100644 lua/plugins/mini.lua delete mode 100644 lua/plugins/navigator.lua delete mode 100644 lua/plugins/notify.lua delete mode 100644 lua/plugins/project-config.lua delete mode 100644 lua/plugins/rest.lua diff --git a/lazy-lock.json b/lazy-lock.json index a1895a0..8ae6199 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -1,107 +1,70 @@ { - "CopilotChat.nvim": { "branch": "main", "commit": "ab5cf12ea8b8c8af82feb616bf7fbac096edc0e0" }, - "FixCursorHold.nvim": { "branch": "master", "commit": "1900f89dc17c603eec29960f57c00bd9ae696495" }, - "LazyVim": { "branch": "main", "commit": "459a4c3b1059671e766a46c7cc223827dc67e3d0" }, - "LuaSnip": { "branch": "master", "commit": "500981ff6cefc7343e3959ef0f939bd0bfd49ba9" }, + "CopilotChat.nvim": { "branch": "main", "commit": "004ced055d8db59561cfcddc5f141ccd8d5a033b" }, "SmoothCursor.nvim": { "branch": "main", "commit": "12518b284e1e3f7c6c703b346815968e1620bee2" }, - "animation.nvim": { "branch": "main", "commit": "fb77091ab72ec9971aee0562e7081182527aaa6a" }, "blink-cmp-latex": { "branch": "main", "commit": "4f2910b98dabed17a1667ab806354faa8763098e" }, "blink.cmp": { "branch": "main", "commit": "78336bc89ee5365633bcf754d93df01678b5c08f" }, - "buffer_manager.nvim": { "branch": "main", "commit": "a0ac2db39c8bd4a2b6ca897f38c88770f90d9323" }, "codecompanion-history.nvim": { "branch": "main", "commit": "bc1b4fe06eaaf0aa2399be742e843c22f7f1652a" }, - "codecompanion.nvim": { "branch": "main", "commit": "7cc35b7f7f08d093469fa9ae67d3af716bd729c3" }, - "color-picker.nvim": { "branch": "master", "commit": "06cb5f853535dea529a523e9a0e8884cdf9eba4d" }, + "codecompanion.nvim": { "branch": "main", "commit": "b9d31246b0646a775fa75e8a73d47698eba26129" }, "composer.nvim": { "branch": "main", "commit": "ec9537969adc7fc128cfe9c3a9925850455896c8" }, - "dressing.nvim": { "branch": "master", "commit": "2d7c2db2507fa3c4956142ee607431ddb2828639" }, "elixir-tools.nvim": { "branch": "main", "commit": "b51b48edc668924a6b2f6610f9a0aff34741d20e" }, - "firenvim": { "branch": "master", "commit": "af775c4a1cef5a1e833ae5c6d81afe229ceb639e" }, - "flutter-tools.nvim": { "branch": "main", "commit": "7d1acfd139215e02d2784733af69a61aaebe06e8" }, - "friendly-snippets": { "branch": "main", "commit": "6cd7280adead7f586db6fccbd15d2cac7e2188b9" }, - "gitsigns.nvim": { "branch": "main", "commit": "25050e4ed39e628282831d4cbecb1850454ce915" }, - "guihua.lua": { "branch": "master", "commit": "f8e06bd8a26dee3377d63c2adf1e57cdb58ac474" }, + "firenvim": { "branch": "master", "commit": "7456b09491337bb53d2146012e8d0c9858f04557" }, + "friendly-snippets": { "branch": "main", "commit": "30bfd475adadfd4f286f86168831348dfd8aecdc" }, + "gitsigns.nvim": { "branch": "main", "commit": "f2421c550618d257048afa650413d9e542ddbe67" }, "hydra.nvim": { "branch": "master", "commit": "3ced42c0b6a6c85583ff0f221635a7f4c1ab0dd0" }, - "icon-picker.nvim": { "branch": "master", "commit": "3ee9a0ea9feeef08ae35e40c8be6a2fa2c20f2d3" }, - "img-clip.nvim": { "branch": "main", "commit": "b6ddfb97b5600d99afe3452d707444afda658aca" }, - "indent-o-matic": { "branch": "master", "commit": "764da1f30b5bb4a49035c3abc9a586322296b812" }, - "json-nvim": { "branch": "master", "commit": "beb76a5ffa0a936677695bc82cc868654aad4398" }, - "laravel.nvim": { "branch": "main", "commit": "0c12031c8c049c423c6c31951beba721115ce6cc" }, - "lazy.nvim": { "branch": "main", "commit": "306a05526ada86a7b30af95c5cc81ffba93fef97" }, - "lua-utils.nvim": { "branch": "main", "commit": "e565749421f4bbb5d2e85e37c3cef9d56553d8bd" }, - "lualine.nvim": { "branch": "master", "commit": "221ce6b2d999187044529f49da6554a92f740a96" }, - "markview.nvim": { "branch": "main", "commit": "e27dee8b2a61f89ac3a06deae0264ad1d3f7b62c" }, - "mason-lspconfig.nvim": { "branch": "main", "commit": "21c5b3ebeaa0412e28096bb0701434c51c1fbf76" }, - "mason-tool-installer.nvim": { "branch": "main", "commit": "443f1ef8b5e6bf47045cb2217b6f748a223cf7dc" }, + "img-clip.nvim": { "branch": "main", "commit": "99848daf801789dbebe2192b475eb887d375002c" }, + "laravel.nvim": { "branch": "main", "commit": "587db9f2f272d141ed8aa45b122828262d800d89" }, + "lazy.nvim": { "branch": "main", "commit": "85c7ff3711b730b4030d03144f6db6375044ae82" }, "mason.nvim": { "branch": "main", "commit": "2a6940af80375532e5e9e7c1f2fc6319a1b7a69d" }, "mcphub.nvim": { "branch": "main", "commit": "7cd5db330f41b7bae02b2d6202218a061c3ebc1f" }, - "menu": { "branch": "main", "commit": "7a0a4a2896b715c066cfbe320bdc048091874cc6" }, - "middleclass": { "branch": "master", "commit": "9fab4d5bca67262614960960ca35c4740eb2be2c" }, - "mini.diff": { "branch": "main", "commit": "05be51814a718e74244829754a2a900a430a8d8b" }, - "mini.icons": { "branch": "main", "commit": "ac38c983aed0a2bd32a65ca3e2348e12e58ca292" }, - "mini.nvim": { "branch": "main", "commit": "bf8169f3e518be8de3f88073ace37d91f576cb04" }, + "mini.diff": { "branch": "main", "commit": "626b8a5b93874c4d05ca25aedec56cfff0b378fb" }, + "mini.icons": { "branch": "main", "commit": "98faae31e9be1cc054ae63485e58ceb185efcad0" }, "minty": { "branch": "main", "commit": "aafc9e8e0afe6bf57580858a2849578d8d8db9e0" }, - "minuet-ai.nvim": { "branch": "main", "commit": "d29dec4c36be2b41aa10e70938b7b09a03f0bdba" }, - "navigator.lua": { "branch": "master", "commit": "cdf118b21a2b7c05a6e8e6d57acbe7a41d4ea41b" }, + "minuet-ai.nvim": { "branch": "main", "commit": "3b0a4c5f97b7124d94302c608fbe01c0270d4fbe" }, "neogen": { "branch": "main", "commit": "23e7e9f883d01289ebd90e98025acc860ea26366" }, - "neorg": { "branch": "main", "commit": "1f14d72aad7165eac307a2a2f6be0fb97a04b3c2" }, - "neotest": { "branch": "master", "commit": "ad991822b7076b1d940b33a9d6d0d30416d5df81" }, + "neorg": { "branch": "main", "commit": "6fda795b0108c92840fd32db6d5dd54e7f997fa8" }, + "neotest": { "branch": "master", "commit": "27bf921498043f7ecd821d6db68d05de244bbd02" }, "neotest-go": { "branch": "main", "commit": "59b50505053f9c45a9febb79e11a56206c3e3901" }, "neotest-plenary": { "branch": "master", "commit": "3523adcf9ffaad1911960c5813b0136c1b63a2ec" }, - "neotest-python": { "branch": "master", "commit": "e6df4f1892f6137f58135917db24d1655937d831" }, + "neotest-python": { "branch": "master", "commit": "1b56ca4ba51c6014f986d6548ee629bdc95589d1" }, "neotest-vim-test": { "branch": "master", "commit": "75c4228882ae4883b11bfce9b8383e637eb44192" }, "noice.nvim": { "branch": "main", "commit": "7bfd942445fb63089b59f97ca487d605e715f155" }, - "none-ls-extras.nvim": { "branch": "main", "commit": "27681d797a26f1b4d6119296df42f5204c88a2dc" }, + "none-ls-extras.nvim": { "branch": "main", "commit": "9a8b8a9aeb43382e5aaf49b00b7cfb5d42d32118" }, "none-ls-luacheck.nvim": { "branch": "main", "commit": "a1dfea0d4c40c4023829c8b9a7ab0a26135985ca" }, "none-ls-shellcheck.nvim": { "branch": "main", "commit": "0f84461241e76e376a95fb7391deac82dc3efdbf" }, - "none-ls.nvim": { "branch": "main", "commit": "01f8e62ea11603e59ad9ff7afcfa94fd183f76d6" }, - "nui.nvim": { "branch": "main", "commit": "de740991c12411b663994b2860f1a4fd0937c130" }, - "numb.nvim": { "branch": "master", "commit": "167fbbb8de5529eac4f66ef054c260636cd9af51" }, - "nvim-autopairs": { "branch": "master", "commit": "7b9923abad60b903ece7c52940e1321d39eccc79" }, - "nvim-colorizer.lua": { "branch": "master", "commit": "a065833f35a3a7cc3ef137ac88b5381da2ba302e" }, - "nvim-dap": { "branch": "master", "commit": "531771530d4f82ad2d21e436e3cc052d68d7aebb" }, + "none-ls.nvim": { "branch": "main", "commit": "c4b82bb63b13856ba4d6b971b7aad3bb38fc6fe2" }, + "nui.nvim": { "branch": "main", "commit": "10fc361835c856ba4233ef5ea135b919bf3dce97" }, + "numb.nvim": { "branch": "master", "commit": "36260c446465b1303b0b1922c722904791bdb03f" }, + "nvim-autopairs": { "branch": "master", "commit": "430522f95fe4fb7c511ec64f8c1a90cc6a66c05c" }, + "nvim-colorizer.lua": { "branch": "master", "commit": "72a05f62c52241bc7441c820eb53946f92b2e6a4" }, + "nvim-dap": { "branch": "master", "commit": "c9a0738e45f1bd41d792a126941348dce661cf9b" }, "nvim-dap-go": { "branch": "main", "commit": "b4421153ead5d726603b02743ea40cf26a51ed5f" }, "nvim-dap-python": { "branch": "master", "commit": "1808458eba2b18f178f990e01376941a42c7f93b" }, - "nvim-dap-ui": { "branch": "master", "commit": "1a66cabaa4a4da0be107d5eda6d57242f0fe7e49" }, + "nvim-dap-ui": { "branch": "master", "commit": "cc9dd33aade7f20bae414d0cba163bc60d4d4b43" }, "nvim-dap-virtual-text": { "branch": "master", "commit": "fbdb48c2ed45f4a8293d0d483f7730d24467ccb6" }, "nvim-dap-vscode-js": { "branch": "main", "commit": "03bd29672d7fab5e515fc8469b7d07cc5994bbf6" }, - "nvim-early-retirement": { "branch": "main", "commit": "3b05315a61c8f01bb893249f9e044fc359122c9d" }, - "nvim-lspconfig": { "branch": "master", "commit": "a683e0ddf0cf64c6cd689e18ffb480ade3c162b7" }, - "nvim-nio": { "branch": "master", "commit": "21f5324bfac14e22ba26553caf69ec76ae8a7662" }, - "nvim-notify": { "branch": "master", "commit": "8701bece920b38ea289b457f902e2ad184131a5d" }, "nvim-python-repl": { "branch": "main", "commit": "09e77dcb9b44e28062a754f8019003bb88fe9734" }, "nvim-spectre": { "branch": "master", "commit": "72f56f7585903cd7bf92c665351aa585e150af0f" }, - "nvim-treesitter": { "branch": "master", "commit": "cf12346a3414fa1b06af75c79faebe7f76df080a" }, - "nvim-treesitter-context": { "branch": "master", "commit": "b311b30818951d01f7b4bf650521b868b3fece16" }, + "nvim-treesitter": { "branch": "main", "commit": "427e9222363d07c32d6db6169e4049c28d58d141" }, + "nvim-treesitter-context": { "branch": "master", "commit": "f3061339b8eaf9fda873600bc425b8d2d8502533" }, "nvim-treesitter-endwise": { "branch": "master", "commit": "8fe8a95630f4f2c72a87ba1927af649e0bfaa244" }, - "nvim-treesitter-textobjects": { "branch": "master", "commit": "5ca4aaa6efdcc59be46b95a3e876300cfead05ef" }, + "nvim-treesitter-textobjects": { "branch": "main", "commit": "5c7b0263797dfd1bd6202f2b219f3b53a80b2187" }, "nvim-ts-autotag": { "branch": "main", "commit": "88c1453db4ba7dd24131086fe51fdf74e587d275" }, - "nvim-web-devicons": { "branch": "master", "commit": "dfbfaa967a6f7ec50789bead7ef87e336c1fa63c" }, "oil-git-status.nvim": { "branch": "main", "commit": "a3e2ccb00cb8822115e28a9a1791eda051d940c9" }, "oil-image-preview.nvim": { "branch": "master", "commit": "a71eacc879e1264339a62019ee3c2ff376f2cc39" }, "oil.nvim": { "branch": "master", "commit": "b73018b75affd13fa38e2fc94ef753b465f770d7" }, - "pathlib.nvim": { "branch": "main", "commit": "57e5598af6fe253761c1b48e0b59b7cd6699e2c1" }, - "playground": { "branch": "master", "commit": "ba48c6a62a280eefb7c85725b0915e021a1a0749" }, "plenary.nvim": { "branch": "master", "commit": "74b06c6c75e4eeb3108ec01852001636d85a932b" }, - "refactoring.nvim": { "branch": "master", "commit": "7eaa150061ea18fdbe18fbb924d236e3ddccc57d" }, - "rustaceanvim": { "branch": "master", "commit": "f69c85a955b9a83d495e3dc8d43adb6364a0b765" }, - "rustowl": { "branch": "main", "commit": "f7bdd868df2501acff029b2d85fa544ec66ef9b6" }, + "refactoring.nvim": { "branch": "master", "commit": "64e10d782ae5b9653558482910213b8946651456" }, + "rustaceanvim": { "branch": "main", "commit": "a968f5133b8b24f481de12f08cd79420d1ace559" }, "snacks.nvim": { "branch": "main", "commit": "882c996cf28183f4d63640de0b4c02ec886d01f2" }, "spinner.nvim": { "branch": "main", "commit": "67ae7f64a6a7940be10c226301413521da26ea72" }, - "telescope.nvim": { "branch": "master", "commit": "9377230aa5305d9e9aca4ed8dadf1070fb4aa9fc" }, "todo-comments.nvim": { "branch": "main", "commit": "31e3c38ce9b29781e4422fc0322eb0a21f4e8668" }, - "tree-sitter-norg": { "branch": "main", "commit": "d7edfaf89198aab652c7a1f0f818196efedaccfb" }, - "tree-sitter-norg-meta": { "branch": "main", "commit": "729d4e54fb881ba0ddf0f925ec78401354c7c6db" }, "treesj": { "branch": "main", "commit": "79aedb401bbdc7e4202f7881eab5f6feb2105b0a" }, "undotree": { "branch": "master", "commit": "6fa6b57cda8459e1e4b2ca34df702f55242f4e4d" }, - "vim-dispatch": { "branch": "master", "commit": "a2ff28abdb2d89725192db5b8562977d392a4d3f" }, - "vim-dotenv": { "branch": "master", "commit": "5c51cfcf8d87280d6414e03cd6b253eb70ecb800" }, - "vim-eunuch": { "branch": "master", "commit": "e86bb794a1c10a2edac130feb0ea590a00d03f1e" }, "vim-fugitive": { "branch": "master", "commit": "3b753cf8c6a4dcde6edee8827d464ba9b8c4a6f0" }, - "vim-jsdoc": { "branch": "master", "commit": "6e5bc2a1f98a69e4902081c9f5969b228a7a5fd6" }, "vim-repeat": { "branch": "master", "commit": "65846025c15494983dafe5e3b46c8f88ab2e9635" }, - "vim-rhubarb": { "branch": "master", "commit": "5496d7c94581c4c9ad7430357449bb57fc59f501" }, "vim-surround": { "branch": "master", "commit": "3d188ed2113431cf8dac77be61b842acb64433d9" }, "vim-test": { "branch": "master", "commit": "2676d84c6901e484df00b5d728bd6a345d47ee12" }, - "vimtex": { "branch": "master", "commit": "fedb7ffc1bebf254cc74e7419c3a5930b6719065" }, + "vimtex": { "branch": "master", "commit": "e355987594cbf16283bee7b37e3aa3a65d5e1c5c" }, "volt": { "branch": "main", "commit": "620de1321f275ec9d80028c68d1b88b409c0c8b1" }, "which-key.nvim": { "branch": "main", "commit": "3aab2147e74890957785941f0c1ad87d0a44c15a" } } diff --git a/lua/config/autocmds.lua b/lua/config/autocmds.lua index ffb5d57..ccb9bd0 100644 --- a/lua/config/autocmds.lua +++ b/lua/config/autocmds.lua @@ -15,7 +15,6 @@ vim.api.nvim_create_autocmd("FileType", { "lspinfo", "spectre_panel", "startuptime", - "tsplayground", "PlenaryTestPopup", }, callback = function(event) @@ -162,6 +161,128 @@ vim.api.nvim_create_autocmd("User", { end, }) +-- Progreso LSP como notificación de snacks.notifier (reemplaza noice lsp.progress) +---@type table +local lsp_progress = vim.defaulttable() +vim.api.nvim_create_autocmd("LspProgress", { + group = augroup "lsp_progress_notify", + ---@param ev {data: {client_id: integer, params: lsp.ProgressParams}} + callback = function(ev) + local client = vim.lsp.get_client_by_id(ev.data.client_id) + local value = ev.data.params.value --[[@as {percentage?: number, title?: string, message?: string, kind: "begin" | "report" | "end"}]] + if not client or type(value) ~= "table" then + return + end + local p = lsp_progress[client.id] + + for i = 1, #p + 1 do + if i == #p + 1 or p[i].token == ev.data.params.token then + p[i] = { + token = ev.data.params.token, + msg = ("[%3d%%] %s%s"):format( + value.kind == "end" and 100 or value.percentage or 100, + value.title or "", + value.message and (" **%s**"):format(value.message) or "" + ), + done = value.kind == "end", + } + break + end + end + + local msg = {} ---@type string[] + lsp_progress[client.id] = vim.tbl_filter(function(v) + return table.insert(msg, v.msg) or not v.done + end, p) + + local spinner = { "⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏" } + vim.notify(table.concat(msg, "\n"), vim.log.levels.INFO, { + id = "lsp_progress", + title = client.name, + opts = function(notif) + notif.icon = #lsp_progress[client.id] == 0 and " " + or spinner[math.floor(vim.uv.hrtime() / (1e6 * 80)) % #spinner + 1] + end, + }) + end, +}) + +-- Formatear/minificar JSON con jq (reemplaza json-nvim) +vim.api.nvim_create_autocmd("FileType", { + group = augroup "json_jq", + pattern = "json", + callback = function(event) + vim.keymap.set("n", "jff", ":%!jq .", { buffer = event.buf, desc = "Formatear JSON con jq" }) + vim.keymap.set("n", "jmf", ":%!jq -c .", { buffer = event.buf, desc = "Minificar JSON con jq" }) + end, +}) + +-- Cerrar buffers inactivos tras 120 min (reemplaza nvim-early-retirement) +local retirement_age_mins = 120 +local buf_last_used = {} +vim.api.nvim_create_autocmd("BufEnter", { + group = augroup "early_retirement", + callback = function(event) + buf_last_used[event.buf] = os.time() + end, +}) +local retirement_timer = assert(vim.uv.new_timer()) +retirement_timer:start( + 60000, + 60000, + vim.schedule_wrap(function() + local now = os.time() + for _, buf in ipairs(vim.api.nvim_list_bufs()) do + if + vim.api.nvim_buf_is_valid(buf) + and vim.bo[buf].buflisted + and not vim.bo[buf].modified + and #vim.fn.win_findbuf(buf) == 0 + then + local last = buf_last_used[buf] + if last == nil then + buf_last_used[buf] = now + elseif now - last > retirement_age_mins * 60 then + pcall(vim.api.nvim_buf_delete, buf, {}) + buf_last_used[buf] = nil + end + end + end + end) +) + +-- Detección simple de indentación (reemplaza indent-o-matic); editorconfig nativo tiene prioridad +vim.api.nvim_create_autocmd("BufReadPost", { + group = augroup "detect_indent", + callback = function(event) + local ec = vim.b[event.buf].editorconfig + if ec and (ec.indent_style or ec.indent_size) then + return + end + local tabs, spaces, min_spaces = 0, 0, math.huge + for _, line in ipairs(vim.api.nvim_buf_get_lines(event.buf, 0, 200, false)) do + local ws = line:match "^%s+" + if ws then + if ws:find "\t" then + tabs = tabs + 1 + else + spaces = spaces + 1 + if #ws > 1 and #ws < min_spaces then + min_spaces = #ws + end + end + end + end + if tabs > spaces then + vim.bo[event.buf].expandtab = false + elseif spaces > 0 and min_spaces ~= math.huge then + vim.bo[event.buf].expandtab = true + vim.bo[event.buf].shiftwidth = min_spaces + vim.bo[event.buf].softtabstop = min_spaces + end + end, +}) + -- vim.api.nvim_create_autocmd("User", { @@ -177,3 +298,17 @@ vim.api.nvim_create_autocmd("User", { -- end -- end, -- }) + +-- WezTerm no implementa el borrado de imágenes del protocolo kitty (snacks.image +-- usa el modo fallback sin placeholders), así que al salir de un buffer de imagen +-- quedan restos en pantalla. Forzar un repintado completo los limpia. +if vim.env.TERM_PROGRAM == "WezTerm" then + vim.api.nvim_create_autocmd("BufWinLeave", { + group = vim.api.nvim_create_augroup("wezterm_image_cleanup", { clear = true }), + callback = function(ev) + if vim.bo[ev.buf].filetype == "image" then + vim.schedule(function() vim.cmd "mode" end) + end + end, + }) +end diff --git a/lua/config/init.lua b/lua/config/init.lua index 5da196b..fe60f1f 100644 --- a/lua/config/init.lua +++ b/lua/config/init.lua @@ -7,6 +7,9 @@ require "config.options" local colorscheme = require "config.native-colorscheme" colorscheme.setup() +-- Statusline nativa (reemplaza lualine.nvim) +require("config.statusline").setup() + -- Additional UI Enhancements vim.opt.guicursor = "n-v-c:block,i-ci-ve:ver25,r-cr:hor20,o:hor50" vim.opt.cursorline = true diff --git a/lua/config/keymaps.lua b/lua/config/keymaps.lua index c1e126e..00ef762 100644 --- a/lua/config/keymaps.lua +++ b/lua/config/keymaps.lua @@ -173,3 +173,54 @@ map("n", "ft", "FloatermToggle", { desc = "run terminal" }) map({ "n", "v" }, "", "CodeCompanionActions", { noremap = true, silent = true }) map({ "n", "v" }, "a", "CodeCompanionChat Toggle", { noremap = true, silent = true }) map("v", "ga", "CodeCompanionChat Add", { noremap = true, silent = true }) + +-- Historial de notificaciones (reemplaza :Noice history) +map("n", "nh", function() + Snacks.notifier.show_history() +end, { desc = "Historial de notificaciones" }) + +-- Abrir archivo/selección en el navegador (reemplaza vim-rhubarb :GBrowse) +map({ "n", "v" }, "go", function() + Snacks.gitbrowse() +end, { desc = "Git browse en el navegador" }) + +-- Picker de iconos/emoji (reemplaza icon-picker.nvim) +map("n", "i", function() + Snacks.picker.icons() +end, { desc = "Insertar icono/emoji" }) +map("n", "y", function() + Snacks.picker.icons { confirm = "yank" } +end, { desc = "Copiar icono/emoji" }) +map("i", "", function() + Snacks.picker.icons() +end, { desc = "Insertar icono/emoji" }) + +-- Menú de acciones de Oil vía vim.ui.select (reemplaza menu.nvim) +map("n", "um", function() + local items = vim.tbl_filter(function(item) + return item.cmd ~= nil + end, require "menus.oil") + vim.ui.select(items, { + prompt = "Oil", + format_item = function(item) + return item.name .. (item.rtxt and " (" .. item.rtxt .. ")" or "") + end, + }, function(choice) + if choice then + choice.cmd() + end + end) +end, { desc = "Abrir menú de Oil" }) + +-- Animación de retipeo del buffer (antes plugin animation.nvim) +map("n", "AA", function() + require("pi.animations").redraw_buffer() +end, { desc = "Retype buffer animation" }) + +-- Buffers abiertos y navegación entre ellos (reemplaza buffer_manager.nvim, +-- roto en Neovim: usa el autocmd BufModifiedSet, que Vim soporta pero Neovim no implementa) +map("n", "o", function() + Snacks.picker.buffers() +end, { desc = "Buffers abiertos" }) +map("n", "]b", ":bnext", { desc = "Buffer siguiente" }) +map("n", "[b", ":bprevious", { desc = "Buffer anterior" }) diff --git a/lua/config/lazy.lua b/lua/config/lazy.lua index 34e034f..89a14a8 100644 --- a/lua/config/lazy.lua +++ b/lua/config/lazy.lua @@ -13,7 +13,7 @@ vim.opt.rtp:prepend(lazypath) require("lazy").setup { -- leave nil when passing the spec as the first argument to setup() - spec = { { "LazyVim/LazyVim", import = "plugins" } }, + spec = { { import = "plugins" } }, local_spec = true, -- load project specific .lazy.lua spec files. They will be added at the end of the spec. defaults = { -- Set this to `true` to have all your plugins lazy-loaded by default. diff --git a/lua/config/options.lua b/lua/config/options.lua index 2d80d08..1598c1c 100644 --- a/lua/config/options.lua +++ b/lua/config/options.lua @@ -103,8 +103,10 @@ opt.listchars = "tab:\\ ,trail:-" -- Siempre muestra la línea de estado. opt.laststatus = 3 --- Configura la altura del área de comandos. -opt.cmdheight = 1 +-- Sin fila de comandos: la cmdline la dibuja noice como popup centrado. +-- (Antes lo forzaba noice con messages activado; ahora lo seteamos nosotros.) +-- En firenvim no hay noice, así que ahí se mantiene la fila clásica. +opt.cmdheight = vim.g.started_by_firenvim and 1 or 0 -- Establece el tiempo de actualización en milisegundos. opt.updatetime = 50 diff --git a/lua/config/statusline.lua b/lua/config/statusline.lua new file mode 100644 index 0000000..c74d8d4 --- /dev/null +++ b/lua/config/statusline.lua @@ -0,0 +1,214 @@ +-- Statusline nativa (reemplaza lualine.nvim), con la paleta de config.native-colorscheme. +local M = {} + +local colors = require("config.native-colorscheme").colors + +local mode_names = { + n = "NORMAL", + no = "O-PENDING", + nt = "NORMAL", + v = "VISUAL", + V = "V-LINE", + ["\22"] = "V-BLOCK", + s = "SELECT", + S = "S-LINE", + ["\19"] = "S-BLOCK", + i = "INSERT", + R = "REPLACE", + Rv = "V-REPLACE", + c = "COMMAND", + cv = "EX", + r = "PROMPT", + ["r?"] = "CONFIRM", + ["!"] = "SHELL", + t = "TERMINAL", +} + +local mode_hl = { + n = "StlModeNormal", + i = "StlModeInsert", + v = "StlModeVisual", + V = "StlModeVisual", + ["\22"] = "StlModeVisual", + s = "StlModeVisual", + S = "StlModeVisual", + c = "StlModeCommand", + R = "StlModeReplace", + r = "StlModeReplace", + t = "StlModeTerminal", + ["!"] = "StlModeTerminal", +} + +function M.set_highlights() + local hl = function(name, fg, bg, bold) + vim.api.nvim_set_hl(0, name, { fg = fg, bg = bg, bold = bold ~= false }) + end + hl("StlModeIcon", colors.base4, colors.base03) + hl("StlModeNormal", colors.blue100, colors.base03) + hl("StlModeInsert", colors.green100, colors.base03) + hl("StlModeVisual", colors.magenta100, colors.base03) + hl("StlModeCommand", colors.yellow100, colors.base03) + hl("StlModeReplace", colors.red100, colors.base03) + hl("StlModeTerminal", colors.orange100, colors.base03) + hl("StlBranch", colors.orange100, colors.base03) + hl("StlDiffAdd", colors.green300, colors.base03) + hl("StlDiffChange", colors.yellow300, colors.base03) + hl("StlDiffDelete", colors.red300, colors.base03) + hl("StlFile", colors.yellow100, colors.base03) + hl("StlDiagError", colors.red300, colors.base03) + hl("StlDiagWarn", colors.yellow300, colors.base03) + hl("StlDiagInfo", colors.blue300, colors.base03) + hl("StlDiagHint", colors.cyan300, colors.base03) + hl("StlUpdates", colors.orange300, colors.bg_statusline, false) + hl("StlLsp", colors.base4, colors.base03) + hl("StlFt", colors.magenta100, colors.base03) + hl("StlProgress", colors.cyan100, colors.base03) + hl("StlSep", colors.base00, colors.base03, false) + hl("StlBg", colors.fg, colors.bg_statusline, false) +end + +-- Handlers de click (:h 'statusline' %@); globales porque %@ necesita un nombre simple. +function _G.StlClickFile() + Snacks.picker.files() +end + +function _G.StlClickDiag() + Snacks.picker.diagnostics() +end + +local function filename() + local name = vim.api.nvim_buf_get_name(0) + if name == "" then + return "[Sin nombre]" + end + local file = vim.fn.fnamemodify(name, ":t") + local parent = vim.fn.fnamemodify(name, ":h:t") + return parent .. "/" .. file +end + +local function git() + local out = {} + -- vim.b para el repo del buffer; vim.g como fallback (repo del cwd, ej. en oil) + local head = vim.b.gitsigns_head or vim.g.gitsigns_head + if head and head ~= "" then + out[#out + 1] = "%#StlBranch# " .. head + end + local status = vim.b.gitsigns_status_dict + if status then + if (status.added or 0) > 0 then + out[#out + 1] = "%#StlDiffAdd# " .. status.added + end + if (status.changed or 0) > 0 then + out[#out + 1] = "%#StlDiffChange# " .. status.changed + end + if (status.removed or 0) > 0 then + out[#out + 1] = "%#StlDiffDelete# " .. status.removed + end + end + if #out == 0 then + return "" + end + return table.concat(out) +end + +local diag_specs = { + { vim.diagnostic.severity.ERROR, "StlDiagError", " " }, + { vim.diagnostic.severity.WARN, "StlDiagWarn", " " }, + { vim.diagnostic.severity.INFO, "StlDiagInfo", " " }, + { vim.diagnostic.severity.HINT, "StlDiagHint", "󰠠 " }, +} + +local function diagnostics() + local counts = vim.diagnostic.count(0) + local parts = {} + for _, spec in ipairs(diag_specs) do + local n = counts[spec[1]] + if n and n > 0 then + parts[#parts + 1] = "%#" .. spec[2] .. "#" .. spec[3] .. n + end + end + if #parts == 0 then + return "" + end + return "%@v:lua.StlClickDiag@" .. table.concat(parts, " ") .. "%X " +end + +local function lsp_clients() + local clients = vim.lsp.get_clients { bufnr = 0 } + if #clients == 0 then + return "No LSP" + end + local names = {} + for _, client in ipairs(clients) do + names[#names + 1] = client.name + end + return table.concat(names, ",") +end + +local function lazy_updates() + local ok, status = pcall(require, "lazy.status") + if ok and status.has_updates() then + return "%#StlUpdates#" .. status.updates() .. " " + end + return "" +end + +local function filetype() + local ft = vim.bo.filetype + if ft == "" then + return "" + end + local ok, mini = pcall(require, "mini.icons") + if ok then + local ok_get, icon, icon_hl = pcall(mini.get, "filetype", ft) + if ok_get and icon then + return "%#" .. icon_hl .. "#" .. icon .. " %#StlFt#" .. ft .. " " + end + end + return "%#StlFt#" .. ft .. " " +end + +-- Como el componente 'progress' de lualine: Top / Bot / porcentaje +local function progress() + local cur = vim.fn.line "." + local total = vim.fn.line "$" + if cur == 1 then + return "Top" + elseif cur == total then + return "Bot" + end + return string.format("%2d%%%%", math.floor(cur / total * 100)) +end + +function M.render() + local mode = vim.api.nvim_get_mode().mode + local hl = mode_hl[mode:sub(1, 1)] or "StlModeNormal" + local name = mode_names[mode] or mode_names[mode:sub(1, 1)] or mode + local left = vim.tbl_filter(function(s) + return s ~= "" + end, { + "%#StlModeIcon# %#" .. hl .. "#" .. name, + git(), + "%#StlFile#%@v:lua.StlClickFile@ " .. filename() .. "%X", + }) + + return table.concat(left, "%#StlSep# │ ") .. table.concat { + " %#StlBg#%=", + diagnostics(), + lazy_updates(), + "%#StlLsp#", lsp_clients(), " ", + filetype(), + "%#StlProgress#", progress(), " ", + } +end + +function M.setup() + M.set_highlights() + vim.api.nvim_create_autocmd("ColorScheme", { + group = vim.api.nvim_create_augroup("native_statusline", { clear = true }), + callback = M.set_highlights, + }) + vim.o.statusline = "%!v:lua.require'config.statusline'.render()" +end + +return M diff --git a/lua/pi/animations.lua b/lua/pi/animations.lua index 3ff711f..e4bc859 100644 --- a/lua/pi/animations.lua +++ b/lua/pi/animations.lua @@ -1,48 +1,39 @@ -local redraw_buffer = function() - local Animation = require "animation" - local fps = 15 -- frames per second - local easing = require "animation.easing" - - local buffer = 0 - local len = 0 - local place_holder = {} +-- Animación de "retipeo" del buffer, con vim.uv (antes dependía de animation.nvim). +local fps = 15 -- un caracter por frame, como la versión original +local redraw_buffer = function() + local buffer = vim.api.nvim_get_current_buf() local lines = vim.api.nvim_buf_get_lines(buffer, 0, -1, true) - for _, line in ipairs(lines) do - len = len + string.len(line) + local place_holder = {} + for _ = 1, #lines do table.insert(place_holder, "") end - - vim.api.nvim_buf_set_lines(buffer, 0, #lines, true, place_holder) - - local duration = math.ceil(len / fps * 1000) - - local i = 1 - local line_nr = 1 - local insertLine = "" - - local function callback() - if lines[line_nr] == nil then - return true - end - local char = string.sub(lines[line_nr], i, i) - if char == nil then - return true - end - insertLine = insertLine .. char - i = i + 1 - vim.api.nvim_buf_set_lines(buffer, line_nr - 1, line_nr, true, { insertLine }) - - if insertLine == lines[line_nr] then - i = 1 - line_nr = line_nr + 1 - insertLine = "" - end - end - - local animation = Animation(duration, fps, easing.line, callback) - animation:run() + vim.api.nvim_buf_set_lines(buffer, 0, -1, true, place_holder) + + local line_nr, col = 1, 0 + local timer = assert(vim.uv.new_timer()) + + timer:start( + 0, + math.floor(1000 / fps), + vim.schedule_wrap(function() + if not vim.api.nvim_buf_is_valid(buffer) or line_nr > #lines then + timer:stop() + timer:close() + return + end + + col = col + 1 + local line = lines[line_nr] + vim.api.nvim_buf_set_lines(buffer, line_nr - 1, line_nr, true, { line:sub(1, col) }) + + if col >= #line then + line_nr = line_nr + 1 + col = 0 + end + end) + ) end return { diff --git a/lua/pi/dap/configs/cpp.lua b/lua/pi/dap/configs/cpp.lua index a2718b0..4f47345 100644 --- a/lua/pi/dap/configs/cpp.lua +++ b/lua/pi/dap/configs/cpp.lua @@ -1,24 +1,47 @@ local dap = require("dap") +-- gdb DAP nativo (gdb >= 14). No usa runInTerminal, así que evita el bug +-- de nvim-dap `terminals.acquire` en Neovim 0.13-dev. La salida del programa +-- aparece en la consola/repl de dap-ui. +dap.adapters.gdb = { + type = "executable", + command = "gdb", + args = { "--interpreter=dap", "--eval-command", "set print pretty on" }, +} + +-- Adaptador cpptools/OpenDebugAD7 (Microsoft) como fallback. dap.adapters.cppdbg = { id = 'cppdbg', type = 'executable', command = '/home/elvis/.local/share/nvim/mason/packages/cpptools/extension/debugAdapters/bin/OpenDebugAD7', } +local function pick_program() + return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file') +end + +local function pick_args() + return vim.split(vim.fn.input('Program arguments: ', ''), " ") +end + dap.configurations.cpp = { { - name = "Launch file", + name = "Launch (gdb)", + type = "gdb", + request = "launch", + program = pick_program, + cwd = "${workspaceFolder}", + args = pick_args, + stopAtBeginningOfMainSubprogram = true, -- equivalente a stopAtEntry en gdb DAP + }, + { + name = "Launch (cppdbg / cpptools)", type = "cppdbg", request = "launch", - program = function() - return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file') - end, + program = pick_program, cwd = '${workspaceFolder}', stopAtEntry = true, - args = function() - return vim.split(vim.fn.input('Program arguments: ', ''), " ") - end, + args = pick_args, }, { name = 'Attach to gdbserver :1234', @@ -28,14 +51,9 @@ dap.configurations.cpp = { miDebuggerServerAddress = 'localhost:1234', miDebuggerPath = '/usr/bin/gdb', cwd = '${workspaceFolder}', - program = function() - return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file') - end, - args = function() - return vim.split(vim.fn.input('Program arguments: ', ''), " ") - end, + program = pick_program, + args = pick_args, }, } dap.configurations.c = dap.configurations.cpp - diff --git a/lua/pi/lsp/attach.lua b/lua/pi/lsp/attach.lua index 7030cbd..e05f3f3 100644 --- a/lua/pi/lsp/attach.lua +++ b/lua/pi/lsp/attach.lua @@ -23,7 +23,7 @@ return function(client, bufnr) vim.keymap.set("n", "gr", function() Snacks.picker.lsp_references() end, { buffer = bufnr, desc = "LSP References of symbol on cursor" }) vim.keymap.set("n", "pv", function() Snacks.picker.lsp_workspace_symbols() end, { buffer = bufnr, desc = "LSP find symbol on the project" }) vim.keymap.set("n", "pd", function() Snacks.picker.lsp_symbols() end, { buffer = bufnr, desc = "LSP document symbols" }) - vim.keymap.set("n", "", function() Snacks.picker.lsp_definitions() end, { buffer = bufnr, desc = "LSP go to definition" }) + vim.keymap.set("n", "gd", function() Snacks.picker.lsp_definitions() end, { buffer = bufnr, desc = "LSP go to definition" }) vim.bo.omnifunc = "v:lua.vim.lsp.omnifunc" diff --git a/lua/pi/lsp/default.lua b/lua/pi/lsp/default.lua index efde87a..1f4dfb0 100644 --- a/lua/pi/lsp/default.lua +++ b/lua/pi/lsp/default.lua @@ -35,10 +35,6 @@ local server_commands = { } return { - mason = { - enable = true, - auto_install = false, - }, get_server_cmd = function(server) return server_commands[server] or { server } end, diff --git a/lua/pi/lsp/init.lua b/lua/pi/lsp/init.lua index de6e95b..ebc8fab 100644 --- a/lua/pi/lsp/init.lua +++ b/lua/pi/lsp/init.lua @@ -10,7 +10,6 @@ return { return orig_open_floating_preview(contents, syntax, opts, ...) end - local mason_servers = {} for server, options in pairs(ops.servers) do if options.enable == true then local ok, definition = pcall(require, "pi.lsp.servers." .. server) @@ -53,19 +52,7 @@ return { end, }) end - - table.insert(mason_servers, server) - end - end - - -- Mason - if ops.mason.enable then - local mason_ops = {} - if ops.mason.auto_install == true then - mason_ops.ensure_installed = mason_servers end - local mason_lspconfig = require "mason-lspconfig" - mason_lspconfig.setup(mason_ops) end -- TODO: implement null ls with options diff --git a/lua/pi/lsp/mason.lua b/lua/pi/lsp/mason.lua deleted file mode 100644 index 6c959a6..0000000 --- a/lua/pi/lsp/mason.lua +++ /dev/null @@ -1,33 +0,0 @@ -local mason_lspconfig = require "mason-lspconfig" -local servers = require "pi.lsp.servers" - --- Note: This file is deprecated in favor of native LSP configuration --- Keeping for reference/compatibility - -local mason_servers = {} - --- Since we're using native LSP, we'll check for executables differently -local server_commands = { - lua_ls = "lua-language-server", - gopls = "gopls", - ts_ls = "typescript-language-server", - -- Add other servers as needed -} - -for server, _ in pairs(servers) do - local cmd = server_commands[server] or server - if vim.fn.executable(cmd) == 0 then - table.insert(mason_servers, server) - end -end - -mason_lspconfig.setup { - -- ensure_installed = mason_servers, -} - --- filter the list for the ones not globally installed --- require("mason-tool-installer").setup { --- ensure_installed = vim.tbl_filter(function (tool) --- return vim.fn.executable(tool) == 0 --- end, require "pi.lsp.tools"), --- } diff --git a/lua/pi/snips/ft/go.lua b/lua/pi/snips/ft/go.lua index 9c3977f..4490e63 100644 --- a/lua/pi/snips/ft/go.lua +++ b/lua/pi/snips/ft/go.lua @@ -8,9 +8,6 @@ local i = ls.insert_node local rep = require("luasnip.extras").rep local fmt = require("luasnip.extras.fmt").fmt -local ts_locals = require "nvim-treesitter.locals" -local ts_utils = require "nvim-treesitter.ts_utils" - local get_node_text = vim.treesitter.get_node_text vim.treesitter.query.set( @@ -71,19 +68,28 @@ local handlers = { end, } +-- `nvim-treesitter.locals`/`ts_utils` no existen en la rama `main`; subimos a +-- mano por los padres del nodo bajo el cursor hasta la función que lo contiene. local function go_result_type(info) - local cursor_node = ts_utils.get_node_at_cursor() - local scope = ts_locals.get_scope_tree(cursor_node, 0) - local function_node - for _, v in ipairs(scope) do - if v:type() == "function_declaration" or v:type() == "method_declaration" or v:type() == "func_literal" then - function_node = v + local node = vim.treesitter.get_node() + while node do + local kind = node:type() + if kind == "function_declaration" or kind == "method_declaration" or kind == "func_literal" then + function_node = node break end + node = node:parent() + end + + if not function_node then + return end local query = vim.treesitter.query.get("go", "LuaSnip_Result") + if not query then + return + end for _, node in query:iter_captures(function_node, 0) do if handlers[node:type()] then return handlers[node:type()](node, info) diff --git a/lua/pi/treesitter.lua b/lua/pi/treesitter.lua new file mode 100644 index 0000000..d137ac5 --- /dev/null +++ b/lua/pi/treesitter.lua @@ -0,0 +1,248 @@ +-- Integración de treesitter para Neovim 0.13 + nvim-treesitter rama `main`. +-- +-- La rama `main` es una reescritura sin sistema de módulos: sólo instala parsers +-- y provee queries. Highlight, indent, folds e injections los da Neovim, así que +-- el enganche lo hacemos nosotros en un autocomando FileType. + +local M = {} + +local install_dir = vim.fs.joinpath(vim.fn.stdpath "data", "site") + +--- Parsers que queremos siempre disponibles. +M.ensure_installed = { + "bash", + "blade", + "css", + "dockerfile", + "cpp", + "elixir", + "erlang", + "go", + "gomod", + "html", + "javascript", + "json", + "latex", + "lua", + "luadoc", + "markdown", + "markdown_inline", + "nix", + "php", + "php_only", + "phpdoc", + "python", + "query", + "regex", + "rust", + "sql", + "svelte", + "twig", + "typescript", + "typst", + "vim", + "yaml", +} + +--- Filetypes de buffers de plugins que reusan el parser de otro lenguaje. +M.language_aliases = { + codecompanion = "markdown", + snacks_notif = "markdown", + oil = "markdown", +} + +--- Filetypes donde no queremos highlight ni indent de treesitter. +M.disabled_filetypes = { + oil = true, + snacks_notif = true, +} + +---@param lang string +---@return boolean +local function parser_available(lang) + return #vim.api.nvim_get_runtime_file("parser/" .. lang .. ".so", false) > 0 +end + +--- Reemplazo de `auto_install`: instala el parser que falte, una sola vez por +--- lenguaje y sin bloquear, y engancha el buffer cuando termina. +local installing = {} ---@type table + +---@param lang string +---@param on_ready fun() +local function install_missing(lang, on_ready) + if installing[lang] then + return + end + local ok, parsers = pcall(require, "nvim-treesitter.parsers") + if not ok or not parsers[lang] then + return + end + installing[lang] = true + require("nvim-treesitter").install({ lang }):await(function() + installing[lang] = nil + vim.schedule(on_ready) + end) +end + +---@param buf integer +local function attach(buf) + if not vim.api.nvim_buf_is_valid(buf) then + return + end + + local ft = vim.bo[buf].filetype + if ft == "" or M.disabled_filetypes[ft] then + return + end + + local lang = vim.treesitter.language.get_lang(ft) + if not lang then + return + end + + if not parser_available(lang) then + install_missing(lang, function() + attach(buf) + end) + return + end + + if not pcall(vim.treesitter.start, buf, lang) then + return + end + + -- Indent de nvim-treesitter (experimental, era el módulo `indent` en master). + -- Sólo si el lenguaje trae query `indents`; si no, dejamos el indentexpr del + -- ftplugin, que es mejor que un fallback vacío. + if vim.treesitter.query.get(lang, "indents") then + vim.bo[buf].indentexpr = "v:lua.require'nvim-treesitter'.indentexpr()" + end +end + +function M.setup() + require("nvim-treesitter").setup { install_dir = install_dir } + + for ft, lang in pairs(M.language_aliases) do + vim.treesitter.language.register(lang, ft) + end + + vim.filetype.add { + pattern = { + [".*%.blade%.php"] = "blade", + }, + } + + require("nvim-treesitter").install(M.ensure_installed) + + vim.api.nvim_create_autocmd("FileType", { + group = vim.api.nvim_create_augroup("pi_treesitter", { clear = true }), + callback = function(args) + attach(args.buf) + end, + }) + + -- El autocomando llega tarde para los buffers que ya se abrieron al arrancar. + for _, buf in ipairs(vim.api.nvim_list_bufs()) do + if vim.api.nvim_buf_is_loaded(buf) then + attach(buf) + end + end + + M.setup_incremental_selection() +end + +-------------------------------------------------------------------------------- +-- Selección incremental +-- +-- El módulo `incremental_selection` desapareció con la rama `main` y Neovim no +-- trae equivalente. Esto reimplementa los cuatro mapeos que había: gnn / grn / +-- grc / grm. +-------------------------------------------------------------------------------- + +local stacks = {} ---@type table + +---@param node TSNode +local function select_node(node) + local srow, scol, erow, ecol = node:range() + if ecol == 0 and erow > srow then + erow = erow - 1 + ecol = #(vim.api.nvim_buf_get_lines(0, erow, erow + 1, false)[1] or "") + end + if vim.fn.mode() ~= "n" then + vim.cmd "normal! \27" + end + vim.fn.setpos("'<", { 0, srow + 1, scol + 1, 0 }) + vim.fn.setpos("'>", { 0, erow + 1, math.max(ecol, 1), 0 }) + vim.cmd "normal! gv" +end + +---@return TSNode[] +local function stack() + local buf = vim.api.nvim_get_current_buf() + stacks[buf] = stacks[buf] or {} + return stacks[buf] +end + +local function init_selection() + local node = vim.treesitter.get_node() + if not node then + return + end + local s = stack() + for i = #s, 1, -1 do + s[i] = nil + end + s[1] = node + select_node(node) +end + +--- Sube al ancestro más chico que sea estrictamente más grande que el actual. +---@param predicate? fun(node: TSNode, from: TSNode): boolean +local function grow(predicate) + local s = stack() + local node = s[#s] or vim.treesitter.get_node() + if not node then + return + end + local parent = node:parent() + while parent do + local same = vim.deep_equal({ parent:range() }, { node:range() }) + if not same and (not predicate or predicate(parent, node)) then + s[#s + 1] = parent + select_node(parent) + return + end + parent = parent:parent() + end + select_node(node) +end + +local function shrink() + local s = stack() + if #s > 1 then + s[#s] = nil + end + local node = s[#s] + if node then + select_node(node) + end +end + +function M.setup_incremental_selection() + local map = vim.keymap.set + map("n", "gnn", init_selection, { desc = "Treesitter: iniciar selección" }) + map("x", "grn", function() + grow() + end, { desc = "Treesitter: expandir al nodo padre" }) + map("x", "grc", function() + -- "scope": el primer ancestro que abarque más líneas que el nodo actual. + grow(function(parent, from) + local psrow, _, perow = parent:range() + local srow, _, erow = from:range() + return (perow - psrow) > (erow - srow) + end) + end, { desc = "Treesitter: expandir al scope" }) + map("x", "grm", shrink, { desc = "Treesitter: reducir selección" }) +end + +return M diff --git a/lua/plugins/animation.lua b/lua/plugins/animation.lua deleted file mode 100644 index 865287e..0000000 --- a/lua/plugins/animation.lua +++ /dev/null @@ -1,11 +0,0 @@ -return { - "anuvyklack/animation.nvim", - dependencies = { - "anuvyklack/middleclass", - }, - keys = { - {"AA", function () - require("pi.animations").redraw_buffer() - end} - }, -} diff --git a/lua/plugins/buffer_manager.lua b/lua/plugins/buffer_manager.lua deleted file mode 100644 index 794e178..0000000 --- a/lua/plugins/buffer_manager.lua +++ /dev/null @@ -1,24 +0,0 @@ -return { - 'j-morano/buffer_manager.nvim', - dependencies = { 'nvim-lua/plenary.nvim' }, - keys = { - { - desc = 'Buffer Manager', - 'o', - function() require('buffer_manager.ui').toggle_quick_menu() end, - }, - { - desc = 'Next buffer', - ']b', - function() require('buffer_manager.ui').nav_next() end, - }, - { - desc = 'Previous buffer', - '[b', - function() require('buffer_manager.ui').nav_prev() end, - }, - }, - opts = { - width = 0.9, - }, - } diff --git a/lua/plugins/close-buffer.lua b/lua/plugins/close-buffer.lua deleted file mode 100644 index 64a6a82..0000000 --- a/lua/plugins/close-buffer.lua +++ /dev/null @@ -1,12 +0,0 @@ -return { - -- Send buffers into early retirement by automatically closing them after x minutes of inactivity. - { - "chrisgrieser/nvim-early-retirement", - config = true, - event = "VeryLazy", - opts = { - -- if a buffer has been inactive for this many minutes, close it - retirementAgeMins = 120, - }, - }, -} diff --git a/lua/plugins/code-annotation.lua b/lua/plugins/code-annotation.lua index eae61d0..52d0379 100644 --- a/lua/plugins/code-annotation.lua +++ b/lua/plugins/code-annotation.lua @@ -9,17 +9,6 @@ if not vim.g.vscode then end return { - -- JsDoc generator - { - "heavenshell/vim-jsdoc", - ft = "javascript,typescript,typescriptreact,svelte", - cmd = "JsDoc", - keys = { - { "jd", "JsDoc", desc = "JsDoc" }, - }, - -- make sure that you will have lehre install locally on plugin folder, refer https://github.com/heavenshell/vim-jsdoc#manual-installation - build = "make install", - }, { -- A better annotation generator. Supports multiple languages and annotation conventions. -- to jump to next annotation, to jump to previous annotation diff --git a/lua/plugins/codecompanion.lua b/lua/plugins/codecompanion.lua index 7b805a7..f4230b0 100644 --- a/lua/plugins/codecompanion.lua +++ b/lua/plugins/codecompanion.lua @@ -216,36 +216,36 @@ return { -- }, }, inline = { + -- adapter = "llama.cpp", adapter = { name ="claude_code", model = "claude-haiku-4-5", -- model = "claude-sonnet-4-6", }, - -- adapter = "llama.cpp", -- adapter = { -- name = "copilot", -- model = "gpt-4.1", -- }, }, cmd = { + -- adapter = "llama.cpp", adapter = { name ="claude_code", model = "claude-haiku-4-5", -- model = "claude-sonnet-4-6", }, - -- adapter = "llama.cpp", -- adapter = { -- name = "copilot", -- model = "gpt-4.1", -- }, }, background = { + -- adapter = "llama.cpp" adapter = { name ="claude_code", model = "claude-haiku-4-5", -- model = "claude-sonnet-4-6", }, - -- adapter = "llama.cpp" -- adapter = { -- name = "copilot", -- model = "gpt-4.1", diff --git a/lua/plugins/color-picker.lua b/lua/plugins/color-picker.lua deleted file mode 100644 index 1e6c88b..0000000 --- a/lua/plugins/color-picker.lua +++ /dev/null @@ -1,7 +0,0 @@ -return { - "ziontee113/color-picker.nvim", - keys = { - { "", "PickColorInsert", mode = "i", desc = "ColorPicker" }, - }, - config = true, -} diff --git a/lua/plugins/colorize.lua b/lua/plugins/colorize.lua index 41a4006..9f4dcef 100644 --- a/lua/plugins/colorize.lua +++ b/lua/plugins/colorize.lua @@ -1,19 +1,23 @@ return { - 'norcalli/nvim-colorizer.lua', - config = function() - require('colorizer').setup({ - 'css', - 'lua', - }, { + -- Fork mantenido de norcalli/nvim-colorizer.lua (el original usa APIs deprecadas + -- y dejaba el aviso "vim.tbl_flatten is deprecated" en cada arranque) + 'catgoose/nvim-colorizer.lua', + event = 'BufReadPre', + opts = { + filetypes = { + 'css', 'scss', 'sass', 'less', 'html', + 'lua', 'javascript', 'typescript', + 'toml', 'conf', 'yaml', 'json', + }, + user_default_options = { RGB = true, -- Colorear valores RGB - RRGGBB = true, -- Deshabilitar otros formatos + RRGGBB = true, names = false, -- Deshabilitar nombres de colores como "Red" - RRGGBBAA = true, -- Deshabilitar valores RGBA - rgb_fn = true, -- Deshabilitar funciones rgb() y rgba() - hsl_fn = true, -- Deshabilitar funciones hsl() y hsla() - css = false, -- Deshabilitar otros valores CSS - css_fn = false, -- Deshabilitar funciones CSS - }) - end + RRGGBBAA = true, + rgb_fn = true, -- Funciones rgb() y rgba() + hsl_fn = true, -- Funciones hsl() y hsla() + css = false, + css_fn = false, + }, + }, } - diff --git a/lua/plugins/completition.lua b/lua/plugins/completition.lua index 071c16c..bde2568 100644 --- a/lua/plugins/completition.lua +++ b/lua/plugins/completition.lua @@ -155,6 +155,26 @@ return { -- Experimental signature help support signature = { enabled = true }, + cmdline = { + enabled = true, + keymap = { + [""] = { "select_next", "fallback" }, + [""] = { "select_prev", "fallback" }, + [""] = { "accept", "fallback" }, + [""] = { "cancel", "fallback" }, + }, + completion = { + list = { selection = { preselect = false, auto_insert = false } }, + menu = { auto_show = true }, + }, + sources = function() + local type = vim.fn.getcmdtype() + if type == "/" or type == "?" then return { "buffer" } end + if type == ":" or type == "@" then return { "cmdline" } end + return {} + end, + }, + -- (Default) Rust fuzzy matcher for typo resistance and significantly better performance fuzzy = { implementation = "prefer_rust_with_warning" }, }, diff --git a/lua/plugins/flutter.lua b/lua/plugins/flutter.lua index 9d83940..36f2101 100644 --- a/lua/plugins/flutter.lua +++ b/lua/plugins/flutter.lua @@ -5,7 +5,6 @@ return filetype = 'dart', dependencies = { 'nvim-lua/plenary.nvim', - 'stevearc/dressing.nvim', -- optional for vim.ui.select }, config = true, } diff --git a/lua/plugins/gitsigns.lua b/lua/plugins/gitsigns.lua index 251ab40..6dd6145 100644 --- a/lua/plugins/gitsigns.lua +++ b/lua/plugins/gitsigns.lua @@ -4,7 +4,14 @@ return { opts = { signcolumn = false, numhl = true, - trouble = false, + current_line_blame = false, -- arranca apagado; se activa con el toggle + current_line_blame_opts = { + virt_text = true, + virt_text_pos = "eol", -- 'eol' | 'overlay' | 'right_align' + delay = 300, + ignore_whitespace = false, + }, + current_line_blame_formatter = " , · ", on_attach = function(bufnr) local gitsigns = require "gitsigns" vim.keymap.set("n", "hs", gitsigns.stage_hunk, { buffer = bufnr }) @@ -13,6 +20,8 @@ return { vim.keymap.set("n", "hp", gitsigns.preview_hunk, { buffer = bufnr }) vim.keymap.set("n", "hj", gitsigns.next_hunk, { buffer = bufnr }) vim.keymap.set("n", "hk", gitsigns.prev_hunk, { buffer = bufnr }) + -- Toggle del blame virtual (autor que modificó la línea) + vim.keymap.set("n", "hb", gitsigns.toggle_current_line_blame, { buffer = bufnr, desc = "Toggle blame línea" }) end, max_file_length = 10000, }, diff --git a/lua/plugins/icon-picker.lua b/lua/plugins/icon-picker.lua deleted file mode 100644 index adb1bb4..0000000 --- a/lua/plugins/icon-picker.lua +++ /dev/null @@ -1,9 +0,0 @@ -return { - "ziontee113/icon-picker.nvim", - keys = { - { "i", "IconPickerNormal nerd_font", mode = "n", desc = "IconPicker NerdFont Insert" }, - { "y", "IconPickerYank nerd_font", mode = "n", desc = "IconPicker NerdFont Yank" }, - { "", "IconPickerInsert nerd_font emoji alt_font nerd_font_v3 symbols ", mode = "i", desc = "IconPicker NerdFont Insert mode" }, - }, - opts = { disable_legacy_commands = true }, -} diff --git a/lua/plugins/indent-o-matic.lua b/lua/plugins/indent-o-matic.lua deleted file mode 100644 index 39b53d3..0000000 --- a/lua/plugins/indent-o-matic.lua +++ /dev/null @@ -1,5 +0,0 @@ -return { - 'Darazaki/indent-o-matic', - event = 'BufReadPre', - opts = {}, - } diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua index 3df2c55..dc3715b 100644 --- a/lua/plugins/init.lua +++ b/lua/plugins/init.lua @@ -1,15 +1,4 @@ return { - { - "jwalton512/vim-blade", - enabled = false, - }, - { - "tpope/vim-dispatch", - cmd = { "Make", "Dispatch" }, - }, "tpope/vim-surround", "tpope/vim-repeat", - "tpope/vim-rhubarb", - "tpope/vim-dotenv", - "tpope/vim-eunuch", } diff --git a/lua/plugins/json-nvim.lua b/lua/plugins/json-nvim.lua deleted file mode 100644 index 3866e1b..0000000 --- a/lua/plugins/json-nvim.lua +++ /dev/null @@ -1,8 +0,0 @@ -return { - "VPavliashvili/json-nvim", - ft = "json", -- only load for json filetype - config = function() - vim.keymap.set("n", "jff", "JsonFormatFile") - vim.keymap.set("n", "jmf", "JsonMinifyFile") - end, -} diff --git a/lua/plugins/laravel.lua b/lua/plugins/laravel.lua index b158221..e524698 100644 --- a/lua/plugins/laravel.lua +++ b/lua/plugins/laravel.lua @@ -1,8 +1,6 @@ return { "adalessa/laravel.nvim", dependencies = { - "rcarriga/nvim-notify", - "nvim-telescope/telescope.nvim", "MunifTanjim/nui.nvim", }, cmd = { "Sail", "Artisan", "Composer", "Npm", "Laravel", "LaravelInfo", "DockerCompose" }, @@ -28,6 +26,11 @@ return { local user_arg = string.format("%s:%s", vim.trim(uid), vim.trim(gid)) require("laravel").setup { + features = { + pickers = { + provider = "snacks", + }, + }, route_info = { position = "top", }, @@ -40,6 +43,5 @@ return { }, }, } - require("telescope").load_extension "laravel" end, } diff --git a/lua/plugins/lsp.lua b/lua/plugins/lsp.lua index 57e1b09..4448b91 100644 --- a/lua/plugins/lsp.lua +++ b/lua/plugins/lsp.lua @@ -13,27 +13,11 @@ return { }, event = "VeryLazy", }, - { - "williamboman/mason-lspconfig.nvim", - event = "VeryLazy", - dependencies = { - "neovim/nvim-lspconfig", - }, - }, - { - "WhoIsSethDaniel/mason-tool-installer.nvim", - event = "VeryLazy", - }, { name = "native-lsp", dir = vim.fn.stdpath("config"), event = "VeryLazy", main = "pi.lsp", - opts = { - mason = { - enable = true, - auto_install = false, - }, - }, + opts = {}, }, } diff --git a/lua/plugins/lualine.lua b/lua/plugins/lualine.lua deleted file mode 100644 index 9409537..0000000 --- a/lua/plugins/lualine.lua +++ /dev/null @@ -1,233 +0,0 @@ -return { - "nvim-lualine/lualine.nvim", - dependencies = { "nvim-tree/nvim-web-devicons" }, - config = function() - local native_colorscheme = require "config.native-colorscheme" - local colors = native_colorscheme.colors - local config = { lualine_bold = true } -- Default config since we're not using solarized-osaka plugin - - local personal_colors = { - normal = { - a = { bg = colors.base03, fg = colors.blue100 }, - b = { bg = colors.fg, fg = colors.bg }, - c = { bg = colors.bg_statusline, fg = colors.fg }, - }, - insert = { - a = { bg = colors.base03, fg = colors.green100 }, - }, - - command = { - a = { bg = colors.base03, fg = colors.yellow100 }, - }, - - visual = { - a = { bg = colors.base03, fg = colors.magenta100 }, - }, - - replace = { - a = { bg = colors.base03, fg = colors.red100 }, - }, - - terminal = { - a = { bg = colors.base03, fg = colors.orange100 }, - }, - - inactive = { - a = { bg = colors.bg_statusline, fg = colors.blue }, - b = { bg = colors.bg_statusline, fg = colors.fg, gui = "bold" }, - c = { bg = colors.bg_statusline, fg = colors.fg }, - }, - } - - for _, mode in pairs(personal_colors) do - if config.lualine_bold then - mode.a.gui = "bold" - end - end - - -- local empty = require('lualine.component'):extend() - - -- local function jarak() - -- return ' ' - -- end - - local empty = require("lualine.component"):extend() - function empty:draw(default_highlight) - self.status = "" - self.applied_separator = "" - self:apply_highlights(default_highlight) - self:apply_section_separators() - return self.status - end - - local function process_sections(sections) - for name, section in pairs(sections) do - local left = name:sub(9, 10) < "x" - for pos = 1, name ~= "lualine_z" and #section or #section - 1 do - table.insert(section, pos * 2, { empty, color = { fg = colors.base03, bg = colors.base03 } }) - end - for id, comp in ipairs(section) do - if type(comp) ~= "table" then - comp = { comp } - section[id] = comp - end - -- comp.separator = left and { right = '' } or { left = '' } - comp.separator = left and { right = " " } or { left = " " } - -- comp.separator = {left = '' } and { right = '' } - end - end - return sections - end - - local lazy_status = require "lazy.status" - - require("lualine").setup { - options = { - theme = personal_colors, - -- icons_enabled = true, - -- component_separators = { left = '>', right = '┇' }, - -- section_separators = {left = '', right = '' }, - }, - sections = process_sections { - lualine_a = { - { - "mode", - icons_enabled = true, - icon = { - " ", - color = { fg = colors.base4, bg = colors.base03, gui = "bold" }, - }, - -- color = { fg = colors.base0, bg = colors.green300, gui = 'bold' }, - -- separator = { left = '', right = '' }, - -- left_padding = 2, right_padding = 0, - }, - }, - -- lualine_b = { 'filename', 'branch' }, - lualine_b = { - { - "branch", - -- separator = { left = '', right = '' }, - -- left_padding = 0, right_padding = 2, - icon = { - "", - -- align = 'left', - color = { fg = colors.orange100, bg = colors.base03, gui = "bold" }, - -- -- separator = {left = '', right = ''} - }, - -- left_padding = 0, - color = { fg = colors.orange100, bg = colors.base03, gui = "bold" }, - }, - { - "diff", - -- separator = { right = '',left = ''}, - colored = true, - symbols = { added = " ", modified = " ", removed = " " }, - diff_color = { - added = { fg = colors.green300, bg = colors.base03, gui = "bold" }, - modified = { fg = colors.yellow300, bg = colors.base03, gui = "bold" }, - removed = { fg = colors.red300, bg = colors.base03, gui = "bold" }, - }, - }, - }, - lualine_c = { - { - "filename", - on_click = function() - Snacks.picker.files() - -- print('file name clicked') - end, - icon = " ", - color = { fg = colors.yellow100, bg = colors.base03, gui = "bold" }, - path = 4, - file_status = false, - -- s