diff --git a/.luarc.json b/.luarc.json new file mode 100644 index 0000000..1e1765c --- /dev/null +++ b/.luarc.json @@ -0,0 +1,5 @@ +{ + "diagnostics.globals": [ + "vim" + ] +} \ No newline at end of file diff --git a/init.lua b/init.lua index 0f3fe52..ee9eab0 100644 --- a/init.lua +++ b/init.lua @@ -1,3 +1,4 @@ +require("config.lsp") require("config.options") require("config.lazy") require("config.commands") diff --git a/lazy-lock.json b/lazy-lock.json index fcade56..298d7cb 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -1,51 +1,49 @@ { - "astrotheme": { "branch": "main", "commit": "f12dcf64b1f9a05839c3ac2146f550f43bae9dab" }, - "avante.nvim": { "branch": "main", "commit": "868c13657442b799a5c161940602f99623a08197" }, - "blink.cmp": { "branch": "main", "commit": "cb5e346d9e0efa7a3eee7fd4da0b690c48d2a98e" }, - "conform.nvim": { "branch": "master", "commit": "6632e7d788a85bf8405ea0c812d343fc308b7b8c" }, - "copilot.lua": { "branch": "master", "commit": "b3988bb51e87a057fee79192c3cc0932a0360bf6" }, + "astrotheme": { "branch": "main", "commit": "0a3fb361f1e3d6a0cbb42e93f3d01fb5203b6752" }, + "avante.nvim": { "branch": "main", "commit": "7e50de89049ea3540f0d39acec7b68a74a5d1edb" }, + "betterTerm.nvim": { "branch": "main", "commit": "33257f0d25c4e1e7a56059b7b9cadaa53f06a4a8" }, + "blink-cmp-copilot": { "branch": "main", "commit": "439cff78780c033aa23cf061d7315314b347e3c1" }, + "blink.cmp": { "branch": "main", "commit": "bae4bae0eedd1fa55f34b685862e94a222d5c6f8" }, + "conform.nvim": { "branch": "master", "commit": "26ebdcfb4f3c9d33d6f81c9534037bd5172b6d65" }, + "copilot.lua": { "branch": "master", "commit": "3fd7b50810ae4cccf8b38e4c509b1608f141a9e9" }, "dressing.nvim": { "branch": "master", "commit": "2d7c2db2507fa3c4956142ee607431ddb2828639" }, - "fidget.nvim": { "branch": "main", "commit": "d9ba6b7bfe29b3119a610892af67602641da778e" }, - "friendly-snippets": { "branch": "main", "commit": "31f2a2657b6261724313281fe0d8ba6f43f4a4fa" }, - "fzf-lua": { "branch": "main", "commit": "307147097e49ca8592fe857f6b3e12a01fda8e69" }, - "img-clip.nvim": { "branch": "main", "commit": "08a02e14c8c0d42fa7a92c30a98fd04d6993b35d" }, + "friendly-snippets": { "branch": "main", "commit": "572f5660cf05f8cd8834e096d7b4c921ba18e175" }, + "fzf-lua": { "branch": "main", "commit": "d6e899e8dfdaf47bf849c0875ca3ca0e5a0e0d12" }, + "harpoon": { "branch": "harpoon2", "commit": "ed1f853847ffd04b2b61c314865665e1dadf22c7" }, + "img-clip.nvim": { "branch": "main", "commit": "d8b6b030672f9f551a0e3526347699985a779d93" }, + "kulala.nvim": { "branch": "main", "commit": "1695bdfc87e2af737bec034cd4cd2d11098a22fd" }, "lazy.nvim": { "branch": "main", "commit": "6c3bda4aca61a13a9c63f1c1d1b16b9d3be90d7a" }, - "live-preview.nvim": { "branch": "main", "commit": "14e76214d8cf83c708fb8fb2ed966ba7e74dabb7" }, - "lsp_signature.nvim": { "branch": "master", "commit": "15bb33cdb47e85278e168cad11acb1b6fa9c6488" }, + "live-preview.nvim": { "branch": "main", "commit": "5890c4f7cb81a432fd5f3b960167757f1b4d4702" }, "lspkind.nvim": { "branch": "master", "commit": "d79a1c3299ad0ef94e255d045bed9fa26025dab6" }, - "lualine.nvim": { "branch": "master", "commit": "86fe39534b7da729a1ac56c0466e76f2c663dc42" }, - "mason-lspconfig.nvim": { "branch": "main", "commit": "1a31f824b9cd5bc6f342fc29e9a53b60d74af245" }, - "mason-null-ls.nvim": { "branch": "main", "commit": "de19726de7260c68d94691afb057fa73d3cc53e7" }, - "mason.nvim": { "branch": "main", "commit": "fc98833b6da5de5a9c5b1446ac541577059555be" }, - "mini.icons": { "branch": "main", "commit": "910db5df9724d65371182948f921fce23c2c881e" }, - "mini.pick": { "branch": "main", "commit": "fc0d862a044af97f7850535fc8799ab38a223fe6" }, - "mini.splitjoin": { "branch": "main", "commit": "3e92f6764e770ba392325cad3a4497adcada695f" }, - "mini.tabline": { "branch": "main", "commit": "06ef4ecaeca2e362c7d31113435d86d144b3cbbe" }, - "moonfly": { "branch": "master", "commit": "bfa6b2486a72784b7546d0d3e9322aef70e07b03" }, - "nightfly": { "branch": "master", "commit": "20ce962726d0991826f243a589a53f6d49b94651" }, - "none-ls.nvim": { "branch": "main", "commit": "fb50cf17e926a037c9f8d96d8db29ddbd04965d4" }, - "nui.nvim": { "branch": "main", "commit": "8d3bce9764e627b62b07424e0df77f680d47ffdb" }, + "lualine.nvim": { "branch": "master", "commit": "b8c23159c0161f4b89196f74ee3a6d02cdc3a955" }, + "marks.nvim": { "branch": "master", "commit": "f353e8c08c50f39e99a9ed474172df7eddd89b72" }, + "mini.icons": { "branch": "main", "commit": "397ed3807e96b59709ef3292f0a3e253d5c1dc0a" }, + "mini.indentscope": { "branch": "main", "commit": "8af2569a7d7fd37300dfa760e44e71efbbf322fd" }, + "mini.notify": { "branch": "main", "commit": "e18f9fc783c7a26fab9c8a094d97dc768e56f558" }, + "mini.pick": { "branch": "main", "commit": "fa1e449e1080bf7aa9b2890ee186d23b1b4e1287" }, + "mini.splitjoin": { "branch": "main", "commit": "70240d5d3881ff1b2b1d7902450f98a6fa303800" }, + "mini.tabline": { "branch": "main", "commit": "ff7a050721352580184db1ff203286c1032d5b54" }, + "none-ls.nvim": { "branch": "main", "commit": "5fcb73913a9290f78097e34420fe0e6130c5c33c" }, + "nui.nvim": { "branch": "main", "commit": "de740991c12411b663994b2860f1a4fd0937c130" }, "nvim-cmp": { "branch": "main", "commit": "b5311ab3ed9c846b585c0c15b7559be131ec4be9" }, - "nvim-dap": { "branch": "master", "commit": "7aade9e99bef5f0735cf966e715b3ce45515d786" }, - "nvim-dap-ui": { "branch": "master", "commit": "881a69e25bd6658864fab47450025490b74be878" }, - "nvim-lspconfig": { "branch": "master", "commit": "b70b900fba6e3255a5a8113c76f213102564cb0d" }, + "nvim-dap": { "branch": "master", "commit": "a479e25ed5b5d331fb46ee4b9e160ff02ac64310" }, + "nvim-dap-ui": { "branch": "master", "commit": "cf91d5e2d07c72903d052f5207511bf7ecdb7122" }, "nvim-nio": { "branch": "master", "commit": "21f5324bfac14e22ba26553caf69ec76ae8a7662" }, - "nvim-treesitter": { "branch": "master", "commit": "684eeac91ed8e297685a97ef70031d19ac1de25a" }, - "nvim-web-devicons": { "branch": "master", "commit": "c90dee4e930ab9f49fa6d77f289bff335b49e972" }, - "odoo-ls.nvim": { "branch": "main", "commit": "a2245072ab910f3641f46f090c1f4cf9e2840664" }, - "oldschool.nvim": { "branch": "master", "commit": "f981e3864733a25259fbc5c505e244501b7cb288" }, - "plenary.nvim": { "branch": "master", "commit": "857c5ac632080dba10aae49dba902ce3abf91b35" }, - "render-markdown.nvim": { "branch": "main", "commit": "dfc1299d9f32b53b34b7ac6c3a7553b5fd29977f" }, + "nvim-tree.lua": { "branch": "master", "commit": "321bc61580fd066b76861c32de3319c3a6d089e7" }, + "nvim-treesitter": { "branch": "master", "commit": "42fc28ba918343ebfd5565147a42a26580579482" }, + "nvim-web-devicons": { "branch": "master", "commit": "c2599a81ecabaae07c49ff9b45dcd032a8d90f1a" }, + "plenary.nvim": { "branch": "master", "commit": "b9fd5226c2f76c951fc8ed5923d85e4de065e509" }, + "render-markdown.nvim": { "branch": "main", "commit": "ec74afa498b6ce3ee686131adf2b3941b713f307" }, + "sllm.nvim": { "branch": "main", "commit": "a7353fa0612c18b16e9654031736dca43811cba6" }, "snacks.nvim": { "branch": "main", "commit": "bc0630e43be5699bb94dadc302c0d21615421d93" }, - "symbol-usage.nvim": { "branch": "main", "commit": "d6fff0e061d555624760ed82113ddf8587358c4e" }, - "telescope.nvim": { "branch": "master", "commit": "a4ed82509cecc56df1c7138920a1aeaf246c0ac5" }, - "tiny-inline-diagnostic.nvim": { "branch": "main", "commit": "cd401038de4cbae37651cfe02510294ccf5cdc98" }, + "telescope.nvim": { "branch": "master", "commit": "b4da76be54691e854d3e0e02c36b0245f945c2c7" }, + "tiny-code-action.nvim": { "branch": "main", "commit": "597c4a39d5601e050d740f3ef437ee695d1ff3b0" }, + "tiny-inline-diagnostic.nvim": { "branch": "main", "commit": "f64efd33a51ea89bdb847fb3aaf716e96b83ba1a" }, "todo-comments.nvim": { "branch": "main", "commit": "304a8d204ee787d2544d8bc23cd38d2f929e7cc5" }, - "tokyonight.nvim": { "branch": "main", "commit": "057ef5d260c1931f1dffd0f052c685dcd14100a3" }, "trouble.nvim": { "branch": "main", "commit": "85bedb7eb7fa331a2ccbecb9202d8abba64d37b3" }, - "vim-dadbod": { "branch": "master", "commit": "9f0ca8bcef704659820a95c3bbd2c262583a66a1" }, + "vim-dadbod": { "branch": "master", "commit": "e95afed23712f969f83b4857a24cf9d59114c2e6" }, "vim-dadbod-completion": { "branch": "master", "commit": "a8dac0b3cf6132c80dc9b18bef36d4cf7a9e1fe6" }, - "vim-dadbod-ui": { "branch": "master", "commit": "460432301a5cb280ea265ddfa15c9f3dcd1d26b7" }, - "vim-tmux-navigator": { "branch": "master", "commit": "791dacfcfc8ccb7f6eb1c853050883b03e5a22fe" }, + "vim-dadbod-ui": { "branch": "master", "commit": "2900a1617b3df1a48683d872eadbe1101146a49a" }, + "vim-tmux-navigator": { "branch": "master", "commit": "c45243dc1f32ac6bcf6068e5300f3b2b237e576a" }, "which-key.nvim": { "branch": "main", "commit": "370ec46f710e058c9c1646273e6b225acf47cbed" } } diff --git a/lsp/intelephense.lua b/lsp/intelephense.lua new file mode 100644 index 0000000..b2e992b --- /dev/null +++ b/lsp/intelephense.lua @@ -0,0 +1,5 @@ +return { + cmd = { "intelephense", "--stdio" }, + filetypes = { "php" }, + root_markers = { "composer.json", ".git" }, +} diff --git a/lsp/lua-ls.lua b/lsp/lua-ls.lua new file mode 100644 index 0000000..d5f743a --- /dev/null +++ b/lsp/lua-ls.lua @@ -0,0 +1,46 @@ +local blink = require("blink.cmp") +return { + cmd = { "lua-language-server" }, + filetypes = { "lua" }, + root_markers = { + ".luarc.json", + ".luarc.jsonc", + ".luacheckrc", + ".stylua.toml", + "stylua.toml", + "selene.toml", + "selene.yml", + ".git", + }, + settings = { + Lua = { + diagnostics = { + disable = { "missing-fields" }, + globals = { + "vim", + "Snacks", + }, + }, + hint = { + enable = true, + setType = false, + paramType = true, + paramName = "Disable", + semicolon = "Disable", + arrayIndex = "Disable", + }, + }, + }, + capabilities = vim.tbl_deep_extend( + "force", + {}, + vim.lsp.protocol.make_client_capabilities(), + blink.get_lsp_capabilities(), + { + fileOperations = { + didRename = true, + willRename = true, + }, + } + ), +} diff --git a/lsp/phpactor.lua b/lsp/phpactor.lua new file mode 100644 index 0000000..95aa133 --- /dev/null +++ b/lsp/phpactor.lua @@ -0,0 +1,12 @@ +return { + cmd = { "phpactor", "language-server" }, + filetypes = { "php" }, + root_dir = function(bufnr, on_dir) + local fname = vim.api.nvim_buf_get_name(bufnr) + local cwd = assert(vim.uv.cwd()) + local root = vim.fs.root(fname, { "composer.json", ".git", ".phpactor.json", ".phpactor.yml" }) + + -- prefer cwd if root is a descendant + on_dir(root and vim.fs.relpath(cwd, root) and cwd) + end, +} diff --git a/lsp/tailwindcss-language-server.lua b/lsp/tailwindcss-language-server.lua new file mode 100644 index 0000000..3d95532 --- /dev/null +++ b/lsp/tailwindcss-language-server.lua @@ -0,0 +1,5 @@ +return { + cmd = { "tailwindcss-language-server", "--stdio" }, + filetypes = { "twig" }, + root_markers = { ".git" }, +} diff --git a/lsp/ts-ls.lua b/lsp/ts-ls.lua new file mode 100644 index 0000000..95f8b85 --- /dev/null +++ b/lsp/ts-ls.lua @@ -0,0 +1,12 @@ +return { + cmd = { "typescript-language-server", "--stdio" }, + filetypes = { + "javascript", + "javascriptreact", + "javascript.jsx", + "typescript", + "typescriptreact", + "typescript.tsx", + }, + root_markers = { "tsconfig.json", "jsconfig.json", "package.json", ".git" }, +} diff --git a/lsp/twiggy-language-server.lua b/lsp/twiggy-language-server.lua new file mode 100644 index 0000000..7386373 --- /dev/null +++ b/lsp/twiggy-language-server.lua @@ -0,0 +1,8 @@ +return { + cmd = { "twiggy-language-server", "--stdio" }, + root_markers = { "composer.json", ".git", "twiggy.config.json" }, + filetypes = { "twig" }, + settings = { + twiggy = {}, + }, +} diff --git a/lua/config/commands.lua b/lua/config/commands.lua index af2e2c3..5d517bd 100644 --- a/lua/config/commands.lua +++ b/lua/config/commands.lua @@ -1,4 +1,4 @@ -vim.cmd("colorscheme astromars") +vim.cmd("colorscheme astrodark") vim.cmd("set termguicolors") local signs = { Error = " ", Warn = " ", Hint = " ", Info = " " } @@ -13,9 +13,24 @@ vim.api.nvim_set_keymap("n", "]t", ":tabnext", { noremap = true, silent = tr vim.api.nvim_set_keymap("n", "[t", ":tabprevious", { noremap = true, silent = true }) vim.cmd([[autocmd BufReadPost,FileReadPost * normal zM]]) vim.cmd("filetype plugin indent on") -vim.api.nvim_create_autocmd({"BufRead", "BufNewFile"}, { - pattern = "*.ofx", - callback = function() - vim.bo.filetype = "xml" - end, +vim.api.nvim_create_autocmd({ "BufRead", "BufNewFile" }, { + pattern = "*.ofx", + callback = function() + vim.bo.filetype = "xml" + end, }) + +local diagnostics_active = true + +function ToggleDiagnostics() + diagnostics_active = not diagnostics_active + if diagnostics_active then + vim.diagnostic.enable() + vim.notify("Diagnostics ON", vim.log.levels.INFO) + else + vim.diagnostic.disable() + vim.notify("Diagnostics OFF", vim.log.levels.WARN) + end +end + +vim.keymap.set("n", "xd", ToggleDiagnostics, { desc = "Toggle LSP diagnostics" }) diff --git a/lua/config/lazy.lua b/lua/config/lazy.lua index 30c4c19..aeffd68 100644 --- a/lua/config/lazy.lua +++ b/lua/config/lazy.lua @@ -13,7 +13,7 @@ if not (vim.uv or vim.loop).fs_stat(lazypath) then if vim.v.shell_error ~= 0 then vim.api.nvim_echo({ { "Failed to clone lazy.nvim:\n", "ErrorMsg" }, - { out, "WarningMsg" }, + { out, "WarningMsg" }, { "\nPress any key to exit..." }, }, true, {}) vim.fn.getchar() @@ -31,7 +31,7 @@ require("lazy").setup({ }, -- colorscheme that will be used when installing plugins. - install = { colorscheme = { "astromars" } }, + install = { colorscheme = { "astrdark" } }, checker = { enabled = true }, change_detection = { enabled = true, diff --git a/lua/config/lsp.lua b/lua/config/lsp.lua new file mode 100644 index 0000000..d5dcae2 --- /dev/null +++ b/lua/config/lsp.lua @@ -0,0 +1,345 @@ +vim.lsp.enable({ + "lua-ls", + -- "gopls", + -- "zls", + "ts-ls", + "twiggy-language-server", + -- "rust-analyzer", + "intelephense", + -- "phpactor", + "tailwindcss-language-server", +}) + +vim.diagnostic.config({ + virtual_text = true, + underline = true, + update_in_insert = false, + severity_sort = true, + float = { + border = "rounded", + source = true, + }, + signs = { + text = { + [vim.diagnostic.severity.ERROR] = "󰅚 ", + [vim.diagnostic.severity.WARN] = "󰀪 ", + [vim.diagnostic.severity.INFO] = "󰋽 ", + [vim.diagnostic.severity.HINT] = "󰌶 ", + }, + numhl = { + [vim.diagnostic.severity.ERROR] = "ErrorMsg", + [vim.diagnostic.severity.WARN] = "WarningMsg", + }, + }, +}) + +-- Extras + +local function restart_lsp(bufnr) + bufnr = bufnr or vim.api.nvim_get_current_buf() + local clients + if vim.lsp.get_clients then + clients = vim.lsp.get_clients({ bufnr = bufnr }) + else + ---@diagnostic disable-next-line: deprecated + clients = vim.lsp.get_active_clients({ bufnr = bufnr }) + end + + for _, client in ipairs(clients) do + vim.lsp.stop_client(client.id) + end + + vim.defer_fn(function() + vim.cmd("edit") + end, 100) +end + +vim.api.nvim_create_user_command("LspRestart", function() + restart_lsp() +end, {}) + +local function lsp_status() + local bufnr = vim.api.nvim_get_current_buf() + local clients = vim.lsp.get_clients and vim.lsp.get_clients({ bufnr = bufnr }) + or vim.lsp.get_active_clients({ bufnr = bufnr }) + + if #clients == 0 then + print("󰅚 No LSP clients attached") + return + end + + print("󰒋 LSP Status for buffer " .. bufnr .. ":") + print("─────────────────────────────────") + + for i, client in ipairs(clients) do + print(string.format("󰌘 Client %d: %s (ID: %d)", i, client.name, client.id)) + print(" Root: " .. (client.config.root_dir or "N/A")) + print(" Filetypes: " .. table.concat(client.config.filetypes or {}, ", ")) + + -- Check capabilities + local caps = client.server_capabilities + local features = {} + if caps.completionProvider then + table.insert(features, "completion") + end + if caps.hoverProvider then + table.insert(features, "hover") + end + if caps.definitionProvider then + table.insert(features, "definition") + end + if caps.referencesProvider then + table.insert(features, "references") + end + if caps.renameProvider then + table.insert(features, "rename") + end + if caps.codeActionProvider then + table.insert(features, "code_action") + end + if caps.documentFormattingProvider then + table.insert(features, "formatting") + end + + print(" Features: " .. table.concat(features, ", ")) + print("") + end +end + +vim.api.nvim_create_user_command("LspStatus", lsp_status, { desc = "Show detailed LSP status" }) + +local function check_lsp_capabilities() + local bufnr = vim.api.nvim_get_current_buf() + local clients = vim.lsp.get_clients and vim.lsp.get_clients({ bufnr = bufnr }) + or vim.lsp.get_active_clients({ bufnr = bufnr }) + + if #clients == 0 then + print("No LSP clients attached") + return + end + + for _, client in ipairs(clients) do + print("Capabilities for " .. client.name .. ":") + local caps = client.server_capabilities + + local capability_list = { + { "Completion", caps.completionProvider }, + { "Hover", caps.hoverProvider }, + { "Signature Help", caps.signatureHelpProvider }, + { "Go to Definition", caps.definitionProvider }, + { "Go to Declaration", caps.declarationProvider }, + { "Go to Implementation", caps.implementationProvider }, + { "Go to Type Definition", caps.typeDefinitionProvider }, + { "Find References", caps.referencesProvider }, + { "Document Highlight", caps.documentHighlightProvider }, + { "Document Symbol", caps.documentSymbolProvider }, + { "Workspace Symbol", caps.workspaceSymbolProvider }, + { "Code Action", caps.codeActionProvider }, + { "Code Lens", caps.codeLensProvider }, + { "Document Formatting", caps.documentFormattingProvider }, + { "Document Range Formatting", caps.documentRangeFormattingProvider }, + { "Rename", caps.renameProvider }, + { "Folding Range", caps.foldingRangeProvider }, + { "Selection Range", caps.selectionRangeProvider }, + } + + for _, cap in ipairs(capability_list) do + local status = cap[2] and "✓" or "✗" + print(string.format(" %s %s", status, cap[1])) + end + print("") + end +end + +vim.api.nvim_create_user_command("LspCapabilities", check_lsp_capabilities, { desc = "Show LSP capabilities" }) + +local function lsp_diagnostics_info() + local bufnr = vim.api.nvim_get_current_buf() + local diagnostics = vim.diagnostic.get(bufnr) + + local counts = { ERROR = 0, WARN = 0, INFO = 0, HINT = 0 } + + for _, diagnostic in ipairs(diagnostics) do + local severity = vim.diagnostic.severity[diagnostic.severity] + counts[severity] = counts[severity] + 1 + end + + print("󰒡 Diagnostics for current buffer:") + print(" Errors: " .. counts.ERROR) + print(" Warnings: " .. counts.WARN) + print(" Info: " .. counts.INFO) + print(" Hints: " .. counts.HINT) + print(" Total: " .. #diagnostics) +end + +vim.api.nvim_create_user_command("LspDiagnostics", lsp_diagnostics_info, { desc = "Show LSP diagnostics count" }) + +local function lsp_info() + local bufnr = vim.api.nvim_get_current_buf() + local clients = vim.lsp.get_clients and vim.lsp.get_clients({ bufnr = bufnr }) + or vim.lsp.get_active_clients({ bufnr = bufnr }) + + print("═══════════════════════════════════") + print(" LSP INFORMATION ") + print("═══════════════════════════════════") + print("") + + -- Basic info + print("󰈙 Language client log: " .. vim.lsp.get_log_path()) + print("󰈔 Detected filetype: " .. vim.bo.filetype) + print("󰈮 Buffer: " .. bufnr) + print("󰈔 Root directory: " .. (vim.fn.getcwd() or "N/A")) + print("") + + if #clients == 0 then + print("󰅚 No LSP clients attached to buffer " .. bufnr) + print("") + print("Possible reasons:") + print(" • No language server installed for " .. vim.bo.filetype) + print(" • Language server not configured") + print(" • Not in a project root directory") + print(" • File type not recognized") + return + end + + print("󰒋 LSP clients attached to buffer " .. bufnr .. ":") + print("─────────────────────────────────") + + for i, client in ipairs(clients) do + print(string.format("󰌘 Client %d: %s", i, client.name)) + print(" ID: " .. client.id) + print(" Root dir: " .. (client.config.root_dir or "Not set")) + print(" Command: " .. table.concat(client.config.cmd or {}, " ")) + print(" Filetypes: " .. table.concat(client.config.filetypes or {}, ", ")) + + -- Server status + if client.is_stopped() then + print(" Status: 󰅚 Stopped") + else + print(" Status: 󰄬 Running") + end + + -- Workspace folders + if client.workspace_folders and #client.workspace_folders > 0 then + print(" Workspace folders:") + for _, folder in ipairs(client.workspace_folders) do + print(" • " .. folder.name) + end + end + + -- Attached buffers count + local attached_buffers = {} + for buf, _ in pairs(client.attached_buffers or {}) do + table.insert(attached_buffers, buf) + end + print(" Attached buffers: " .. #attached_buffers) + + -- Key capabilities + local caps = client.server_capabilities + local key_features = {} + if caps.completionProvider then + table.insert(key_features, "completion") + end + if caps.hoverProvider then + table.insert(key_features, "hover") + end + if caps.definitionProvider then + table.insert(key_features, "definition") + end + if caps.documentFormattingProvider then + table.insert(key_features, "formatting") + end + if caps.codeActionProvider then + table.insert(key_features, "code_action") + end + + if #key_features > 0 then + print(" Key features: " .. table.concat(key_features, ", ")) + end + + print("") + end + + -- Diagnostics summary + local diagnostics = vim.diagnostic.get(bufnr) + if #diagnostics > 0 then + print("󰒡 Diagnostics Summary:") + local counts = { ERROR = 0, WARN = 0, INFO = 0, HINT = 0 } + + for _, diagnostic in ipairs(diagnostics) do + local severity = vim.diagnostic.severity[diagnostic.severity] + counts[severity] = counts[severity] + 1 + end + + print(" 󰅚 Errors: " .. counts.ERROR) + print(" 󰀪 Warnings: " .. counts.WARN) + print(" 󰋽 Info: " .. counts.INFO) + print(" 󰌶 Hints: " .. counts.HINT) + print(" Total: " .. #diagnostics) + else + print("󰄬 No diagnostics") + end + + print("") + print("Use :LspLog to view detailed logs") + print("Use :LspCapabilities for full capability list") +end + +-- Create command +vim.api.nvim_create_user_command("LspInfo", lsp_info, { desc = "Show comprehensive LSP information" }) + +local function lsp_status_short() + local bufnr = vim.api.nvim_get_current_buf() + local clients = vim.lsp.get_clients and vim.lsp.get_clients({ bufnr = bufnr }) + or vim.lsp.get_active_clients({ bufnr = bufnr }) + + if #clients == 0 then + return "" -- Return empty string when no LSP + end + + local names = {} + for _, client in ipairs(clients) do + table.insert(names, client.name) + end + + return "󰒋 " .. table.concat(names, ",") +end + +local function git_branch() + local ok, handle = pcall(io.popen, "git branch --show-current 2>/dev/null") + if not ok or not handle then + return "" + end + local branch = handle:read("*a") + handle:close() + if branch and branch ~= "" then + branch = branch:gsub("\n", "") + return "󰊢 " .. branch + end + return "" +end +-- Safe wrapper functions for statusline +local function safe_git_branch() + local ok, result = pcall(git_branch) + return ok and result or "" +end + +local function safe_lsp_status() + local ok, result = pcall(lsp_status_short) + return ok and result or "" +end + +_G.git_branch = safe_git_branch +_G.lsp_status = safe_lsp_status + +-- THEN set the statusline +vim.opt.statusline = table.concat({ + "%{v:lua.git_branch()}", -- Git branch + "%f", -- File name + "%m", -- Modified flag + "%r", -- Readonly flag + "%=", -- Right align + "%{v:lua.lsp_status()}", -- LSP status + " %l:%c", -- Line:Column + " %p%%", -- Percentage through file +}, " ") diff --git a/lua/config/options.lua b/lua/config/options.lua index c01908c..a8680cc 100644 --- a/lua/config/options.lua +++ b/lua/config/options.lua @@ -27,8 +27,8 @@ local options = { showmode = false, -- mode will be shown by statusline -- kickstart config - list = true, - listchars = { tab = "» ", trail = "·", nbsp = "␣" }, + -- list = true, + -- listchars = { tab = "» ", trail = "·", nbsp = "␣" }, -- tabs and indentations @@ -74,6 +74,7 @@ local options = { -- fixeol = true, } +-- Para .lua for parameter, value in pairs(options) do vim.opt[parameter] = value end diff --git a/lua/config/window_manager.lua b/lua/config/window_manager.lua new file mode 100644 index 0000000..e7c1934 --- /dev/null +++ b/lua/config/window_manager.lua @@ -0,0 +1,320 @@ +-- Este arquivo contém uma solução robusta para corrigir os problemas de layout +-- entre nvim-tree e dap-ui. Coloque este código em um arquivo separado, +-- por exemplo: ~/.config/nvim/lua/config/window_manager.lua + +local M = {} + +-- Estado global para controlar as diferentes janelas +M.state = { + nvim_tree_open = false, + dapui_open = false, + dapui_layouts = { left = false, right = false }, + saved_widths = { + nvim_tree = 30, + dapui_left = 40, + dapui_right = 40, + }, +} + +-- Encontra o buffer ID do nvim-tree +local function find_nvim_tree_win() + for _, win in ipairs(vim.api.nvim_list_wins()) do + local buf = vim.api.nvim_win_get_buf(win) + local buf_name = vim.api.nvim_buf_get_name(buf) + if buf_name:match("NvimTree") then + return win + end + end + return nil +end + +-- Encontra o buffer ID do dapui por posição +local function find_dapui_win(position) + -- Verifica todas as janelas + for _, win in ipairs(vim.api.nvim_list_wins()) do + local buf = vim.api.nvim_win_get_buf(win) + local buf_name = vim.api.nvim_buf_get_name(buf) + + -- DAP UI tem nomes específicos por painel + if position == "left" and buf_name:match("DAP") and buf_name:match("Breakpoints") then + return win + elseif position == "right" and buf_name:match("DAP") and buf_name:match("Scopes") then + return win + end + end + return nil +end + +-- Restaura as larguras corretas para todas as janelas +function M.restore_window_widths() + -- Pequena pausa para garantir que todos os buffers estejam carregados + vim.defer_fn(function() + -- Primeiro restaura a largura do nvim-tree se estiver aberto + local nvim_tree_win = find_nvim_tree_win() + if nvim_tree_win and M.state.nvim_tree_open then + vim.api.nvim_win_set_width(nvim_tree_win, M.state.saved_widths.nvim_tree) + end + + -- Restaura as larguras dos painéis DAP UI + local dapui_left_win = find_dapui_win("left") + if dapui_left_win and M.state.dapui_layouts.left then + vim.api.nvim_win_set_width(dapui_left_win, M.state.saved_widths.dapui_left) + end + + local dapui_right_win = find_dapui_win("right") + if dapui_right_win and M.state.dapui_layouts.right then + vim.api.nvim_win_set_width(dapui_right_win, M.state.saved_widths.dapui_right) + end + + -- Força o Neovim a recalcular as janelas + vim.cmd("redraw") + end, 100) +end + +-- Fecha todos os painéis abertos e redefine o estado +function M.close_all_panels() + local nvim_tree = require("nvim-tree.api") + local dapui = require("dapui") + + -- Fecha nvim-tree se estiver aberto + if M.state.nvim_tree_open then + nvim_tree.tree.close() + M.state.nvim_tree_open = false + end + + -- Fecha os painéis dapui se estiverem abertos + if M.state.dapui_open then + dapui.close() + M.state.dapui_open = false + M.state.dapui_layouts = { left = false, right = false } + end + + -- Força o Neovim a recalcular as janelas + vim.cmd("wincmd =") + vim.cmd("redraw") +end + +-- Abre o nvim-tree com gestão de estado +function M.toggle_nvim_tree() + local nvim_tree = require("nvim-tree.api") + + if M.state.nvim_tree_open then + nvim_tree.tree.close() + M.state.nvim_tree_open = false + else + nvim_tree.tree.open() + M.state.nvim_tree_open = true + end + + M.restore_window_widths() +end + +-- Abre o dapui com gestão de estado +function M.toggle_dapui(layout_number) + local dapui = require("dapui") + + if not layout_number then + -- Toggle todos os layouts + if M.state.dapui_open then + dapui.close() + M.state.dapui_open = false + M.state.dapui_layouts = { left = false, right = false } + else + dapui.open() + M.state.dapui_open = true + M.state.dapui_layouts = { left = true, right = true } + end + else + -- Toggle apenas o layout específico + if layout_number == 1 then + -- Layout esquerdo + if M.state.dapui_layouts.left then + dapui.close({ layout = 1 }) + M.state.dapui_layouts.left = false + else + dapui.open({ layout = 1 }) + M.state.dapui_layouts.left = true + end + M.state.dapui_open = M.state.dapui_layouts.left or M.state.dapui_layouts.right + elseif layout_number == 2 then + -- Layout direito (scopes) + if M.state.dapui_layouts.right then + dapui.close({ layout = 2 }) + M.state.dapui_layouts.right = false + else + dapui.open({ layout = 2 }) + M.state.dapui_layouts.right = true + end + M.state.dapui_open = M.state.dapui_layouts.left or M.state.dapui_layouts.right + end + end + + M.restore_window_widths() +end + +-- Configura o nvim-tree +function M.setup_nvim_tree() + require("nvim-tree").setup({ + sort = { + sorter = "case_sensitive", + }, + view = { + width = M.state.saved_widths.nvim_tree, + }, + renderer = { + group_empty = true, + }, + filters = { + dotfiles = false, + }, + actions = { + open_file = { + resize_window = true, + quit_on_open = false, + }, + }, + on_attach = function(bufnr) + local api = require("nvim-tree.api") + + local function opts(desc) + return { desc = "nvim-tree: " .. desc, buffer = bufnr, noremap = true, silent = true, nowait = true } + end + + -- Mapeamentos padrão + vim.keymap.set("n", "", api.node.open.edit, opts("Open")) + vim.keymap.set("n", "o", api.node.open.edit, opts("Open")) + vim.keymap.set("n", "<2-LeftMouse>", api.node.open.edit, opts("Open")) + vim.keymap.set("n", "I", api.tree.toggle_gitignore_filter, opts("Toggle Git Ignore")) + vim.keymap.set("n", "H", api.tree.toggle_hidden_filter, opts("Toggle Dotfiles")) + vim.keymap.set("n", "R", api.tree.reload, opts("Refresh")) + vim.keymap.set("n", "a", api.fs.create, opts("Create")) + vim.keymap.set("n", "d", api.fs.remove, opts("Delete")) + vim.keymap.set("n", "r", api.fs.rename, opts("Rename")) + vim.keymap.set("n", "x", api.fs.cut, opts("Cut")) + vim.keymap.set("n", "c", api.fs.copy.node, opts("Copy")) + vim.keymap.set("n", "p", api.fs.paste, opts("Paste")) + vim.keymap.set("n", "y", api.fs.copy.filename, opts("Copy Name")) + vim.keymap.set("n", "Y", api.fs.copy.relative_path, opts("Copy Relative Path")) + vim.keymap.set("n", "", api.node.open.vertical, opts("Open: Vertical Split")) + vim.keymap.set("n", "", api.node.open.horizontal, opts("Open: Horizontal Split")) + end, + }) + + -- Eventos para correto redimensionamento + vim.api.nvim_create_autocmd("User", { + pattern = "NvimTreeOpen", + callback = function() + M.state.nvim_tree_open = true + M.restore_window_widths() + end, + }) + + vim.api.nvim_create_autocmd("User", { + pattern = "NvimTreeClose", + callback = function() + M.state.nvim_tree_open = false + M.restore_window_widths() + end, + }) + + -- Mapear o toggle + vim.keymap.set("n", "e", function() + M.toggle_nvim_tree() + end, { desc = "Toggle NvimTree Explorer" }) +end + +-- Configura o dapui +function M.setup_dapui() + local dap = require("dap") + local dapui = require("dapui") + + dapui.setup({ + icons = { expanded = "▾", collapsed = "▸", current_frame = "▸" }, + mappings = { + expand = { "", "<2-LeftMouse>" }, + open = "o", + remove = "d", + edit = "e", + repl = "r", + toggle = "t", + }, + layouts = { + -- { + -- elements = { + -- { id = "watches", size = 0.25 }, + -- { id = "stacks", size = 0.25 }, + -- }, + -- size = M.state.saved_widths.dapui_left / 100, + -- position = "left", + -- }, + { + elements = { + { id = "scopes", size = 1.0 }, + { id = "repl", size = 0.25 }, + { id = "breakpoints", size = 0.25 }, + }, + size = M.state.saved_widths.dapui_right / 100, + position = "right", + }, + }, + floating = { + max_height = nil, + max_width = nil, + border = "single", + mappings = { + close = { "q", "" }, + }, + }, + controls = { + enabled = true, + }, + render = { + max_type_length = nil, + max_value_lines = 100, + }, + }) + + -- DAP eventos com gestão de estado + dap.listeners.after.event_initialized["dapui_config"] = function() + vim.defer_fn(function() + dapui.open() + M.state.dapui_open = true + M.state.dapui_layouts = { left = true, right = true } + M.restore_window_widths() + end, 100) + end + + dap.listeners.before.event_terminated["dapui_config"] = function() + vim.defer_fn(function() + dapui.close() + M.state.dapui_open = false + M.state.dapui_layouts = { left = false, right = false } + M.restore_window_widths() + end, 100) + end + + dap.listeners.before.event_exited["dapui_config"] = function() + vim.defer_fn(function() + dapui.close() + M.state.dapui_open = false + M.state.dapui_layouts = { left = false, right = false } + M.restore_window_widths() + end, 100) + end + + -- Atalhos para o dapui + vim.keymap.set("n", "du", function() + M.toggle_dapui() + end, { desc = "Toggle DAP UI" }) + + vim.keymap.set("n", "ds", function() + M.toggle_dapui(2) -- Alterna apenas o painel de scopes (lado direito) + end, { desc = "Toggle DAP Scopes" }) + + -- Teclado de emergência - força o fechamento de todos os painéis + vim.keymap.set("n", "dC", function() + M.close_all_panels() + end, { desc = "Close All Panels (Emergency)" }) +end + +return M diff --git a/lua/plugins/avante.lua b/lua/plugins/avante.lua index 7f52a4f..4585089 100644 --- a/lua/plugins/avante.lua +++ b/lua/plugins/avante.lua @@ -1,64 +1,78 @@ +-- if true then +-- return {} +-- end return { - "yetone/avante.nvim", - event = "VeryLazy", - lazy = false, - version = "*", -- Set this to "*" to always pull the latest release version, or set it to false to update to the latest code changes. - opts = { - -- add any opts here - -- for example - provider = "copilot", - openai = { - endpoint = "https://api.openai.com/v1", - model = "gpt-4o", -- your desired model (or use gpt-4o, etc.) - timeout = 30000, -- timeout in milliseconds - temperature = 0, -- adjust if needed - max_tokens = 4096, - }, - claude = { - endpoint = "https://api.anthropic.com", - model = "claude-3-5-sonnet-20241022", - temperature = 0, - max_tokens = 4096, - }, - }, - -- if you want to build from source then do `make BUILD_FROM_SOURCE=true` - build = "make", - -- build = "powershell -ExecutionPolicy Bypass -File Build.ps1 -BuildFromSource false" -- for windows - dependencies = { - "stevearc/dressing.nvim", - "nvim-lua/plenary.nvim", - "MunifTanjim/nui.nvim", - --- The below dependencies are optional, - "echasnovski/mini.pick", -- for file_selector provider mini.pick - "nvim-telescope/telescope.nvim", -- for file_selector provider telescope - "hrsh7th/nvim-cmp", -- autocompletion for avante commands and mentions - "ibhagwan/fzf-lua", -- for file_selector provider fzf - "nvim-tree/nvim-web-devicons", -- or echasnovski/mini.icons - "zbirenbaum/copilot.lua", -- for providers='copilot' - { - -- support for image pasting - "HakonHarnes/img-clip.nvim", - event = "VeryLazy", - opts = { - -- recommended settings - default = { - embed_image_as_base64 = false, - prompt_for_file_name = false, - drag_and_drop = { - insert_mode = true, - }, - -- required for Windows users - use_absolute_path = true, - }, - }, - }, - { - -- Make sure to set this up properly if you have lazy=true - "MeanderingProgrammer/render-markdown.nvim", - opts = { - file_types = { "markdown", "Avante" }, - }, - ft = { "markdown", "Avante" }, - }, - }, + "yetone/avante.nvim", + event = "VeryLazy", + lazy = false, + version = "*", -- Set this to "*" to always pull the latest release version, or set it to false to update to the latest code changes. + opts = { + -- add any opts here + -- for example + provider = "copilot", + providers = { + openai = { + endpoint = "https://api.openai.com/v1", + model = "gpt-4o", -- your desired model (or use gpt-4o, etc.) + timeout = 30000, -- timeout in milliseconds + extra_request_body = { + temperature = 0, + max_completion_tokens = 8192, -- Increase this to include reasoning tokens (for reasoning models) + reasoning_effort = "medium", -- low|medium|high, only used for reasoning models + }, + }, + claude = { + endpoint = "https://api.anthropic.com", + model = "claude-3-5-sonnet-20241022", + extra_request_body = { + temperature = 0, + max_completion_tokens = 8192, -- Increase this to include reasoning tokens (for reasoning models) + reasoning_effort = "medium", -- low|medium|high, only used for reasoning models + }, + }, + }, + }, + -- if you want to build from source then do `make BUILD_FROM_SOURCE=true` + build = "make", + -- build = "powershell -ExecutionPolicy Bypass -File Build.ps1 -BuildFromSource false" -- for windows + dependencies = { + "stevearc/dressing.nvim", + "nvim-lua/plenary.nvim", + "MunifTanjim/nui.nvim", + --- The below dependencies are optional, + "echasnovski/mini.pick", -- for file_selector provider mini.pick + "nvim-telescope/telescope.nvim", -- for file_selector provider telescope + "hrsh7th/nvim-cmp", -- autocompletion for avante commands and mentions + "ibhagwan/fzf-lua", -- for file_selector provider fzf + "nvim-tree/nvim-web-devicons", -- or echasnovski/mini.icons + "zbirenbaum/copilot.lua", -- for providers='copilot' + { + -- support for image pasting + "HakonHarnes/img-clip.nvim", + event = "VeryLazy", + opts = { + -- recommended settings + default = { + + suggestion = { enabled = false }, + panel = { enabled = false }, + embed_image_as_base64 = false, + prompt_for_file_name = false, + drag_and_drop = { + insert_mode = true, + }, + -- required for Windows users + -- use_absolute_path = true, + }, + }, + }, + { + -- Make sure to set this up properly if you have lazy=true + "MeanderingProgrammer/render-markdown.nvim", + opts = { + file_types = { "markdown", "Avante" }, + }, + ft = { "markdown", "Avante" }, + }, + }, } diff --git a/lua/plugins/bettertab.lua b/lua/plugins/bettertab.lua new file mode 100644 index 0000000..3feb88b --- /dev/null +++ b/lua/plugins/bettertab.lua @@ -0,0 +1,33 @@ +return { + "CRAG666/betterTerm.nvim", + keys = { + { + mode = { "n", "t" }, + ";", + function() + require("betterTerm").open() + end, + desc = "Open BetterTerm 0", + }, + { + mode = { "n", "t" }, + "", + function() + require("betterTerm").open(1) + end, + desc = "Open BetterTerm 1", + }, + { + "tt", + function() + require("betterTerm").select() + end, + desc = "Select terminal", + }, + }, + opts = { + position = "bot", + size = 12, + jump_tab_mapping = "", + }, +} diff --git a/lua/plugins/blink-cmp.lua b/lua/plugins/blink-cmp.lua index 33ee3dd..913f8fa 100644 --- a/lua/plugins/blink-cmp.lua +++ b/lua/plugins/blink-cmp.lua @@ -9,6 +9,7 @@ return { { "rafamadriz/friendly-snippets" }, { "onsails/lspkind.nvim" }, { "echasnovski/mini.icons", version = false }, + { "giuxtaposition/blink-cmp-copilot" }, }, -- use a release tag to download pre-built binaries diff --git a/lua/plugins/colorscheme.lua b/lua/plugins/colorscheme.lua index 1f0bf4b..2818bef 100644 --- a/lua/plugins/colorscheme.lua +++ b/lua/plugins/colorscheme.lua @@ -1,4 +1,6 @@ return { + + -- { "projekt0n/github-nvim-theme", name = "github-theme" }, { "AstroNvim/astrotheme", lazy = false, @@ -32,11 +34,11 @@ return { }) end, }, - { "bluz71/vim-moonfly-colors", name = "moonfly" }, - { "bluz71/vim-nightfly-colors", name = "nightfly" }, - { - "folke/tokyonight.nvim", - opts = {}, - }, - { "L-Colombo/oldschool.nvim" }, + -- { "bluz71/vim-moonfly-colors", name = "moonfly" }, + -- { "bluz71/vim-nightfly-colors", name = "nightfly" }, + -- { + -- "folke/tokyonight.nvim", + -- opts = {}, + -- }, + -- { "L-Colombo/oldschool.nvim" }, } diff --git a/lua/plugins/conform.lua b/lua/plugins/conform.lua index 141b8cf..9732320 100644 --- a/lua/plugins/conform.lua +++ b/lua/plugins/conform.lua @@ -7,11 +7,17 @@ return { conform.setup({ format_on_save = { -- These options will be passed to conform.format() - timeout_ms = 500, + timeout_ms = 2000, lsp_format = "fallback", }, formatters_by_ft = { - twig = { "ludtwig", "twig_cs_fixer" }, + twig = { "ludtwig" }, + lua = { "stylua" }, + json = { "prettier" }, + xml = { "prettier" }, + html = { "prettier" }, + javascript = { "biome" }, + typescript = { "biome" }, }, formatters = { ludtwig = { @@ -20,34 +26,6 @@ return { args = { "-f", "$FILENAME" }, stdin = false, }, - twig_cs_fixer = { - command = "docker-compose", - args = function(self, ctx) - -- Extrair apenas o nome do arquivo sem o caminho completo - local filename = vim.fn.fnamemodify(ctx.filename, ":t") - - return { - "exec", - "-T", - "web", - "bash", - "-c", - string.format( - [[ - temp_file=$(mktemp -p /tmp %s.XXXXXX) - cat > "$temp_file" - # Substitua o comando abaixo pelo comando real do seu twig-cs-fixer - WebSocialSaude/vendor/bin/twig-cs-fixer fix "$temp_file" --no-backup - cat "$temp_file" - rm "$temp_file" - ]], - filename - ), - } - end, - stdin = true, - require_cwd = false, - }, }, }) end, diff --git a/lua/plugins/copilot.lua b/lua/plugins/copilot.lua new file mode 100644 index 0000000..35128da --- /dev/null +++ b/lua/plugins/copilot.lua @@ -0,0 +1,12 @@ +if true then + return {} +end +return { + "zbirenbaum/copilot.lua", + cmd = "Copilot", + build = ":Copilot auth", + opts = { + suggestion = { enabled = true }, + panel = { enabled = false }, + }, +} diff --git a/lua/plugins/dadbod-claudeai.lua b/lua/plugins/dadbod-claudeai.lua new file mode 100644 index 0000000..e08844b --- /dev/null +++ b/lua/plugins/dadbod-claudeai.lua @@ -0,0 +1,78 @@ +if true then + return {} +end +return { + "kristijanhusak/vim-dadbod-ui", + dependencies = { + { "tpope/vim-dadbod", lazy = true }, + { "kristijanhusak/vim-dadbod-completion", ft = { "sql", "mysql", "plsql" }, lazy = true }, + }, + cmd = { "DBUI", "DBUIToggle", "DBUIAddConnection", "DBUIFindBuffer" }, + init = function() + -- Configuração básica do DBUI + vim.g.db_ui_use_nerd_fonts = 1 + + -- Abrir DBUI em uma nova tab + vim.g.db_ui_win_position = "left" + vim.g.db_ui_winwidth = 30 + + -- Função para abrir DBUI em uma nova tab + local function open_dbui_in_new_tab() + vim.cmd("tabnew") + vim.cmd("DBUI") + end + + -- Função para alternar DBUI em uma nova tab se não estiver aberto + local function toggle_dbui_in_tab() + -- Verifica se já existe um buffer DBUI aberto + local dbui_open = false + for _, buf in ipairs(vim.api.nvim_list_bufs()) do + local name = vim.api.nvim_buf_get_name(buf) + if name:match("dbui") then + dbui_open = true + break + end + end + + if not dbui_open then + open_dbui_in_new_tab() + else + vim.cmd("DBUIToggle") + end + end + + -- Configurar atalhos de teclado + vim.api.nvim_create_user_command("DBUINewTab", open_dbui_in_new_tab, {}) + + -- Definir atalhos globais + vim.keymap.set( + "n", + "Db", + toggle_dbui_in_tab, + { noremap = true, silent = true, desc = "Abrir DB UI em nova tab" } + ) + vim.keymap.set( + "n", + "Dc", + "DBUIAddConnection", + { noremap = true, silent = true, desc = "Adicionar conexão DB" } + ) + vim.keymap.set( + "n", + "Df", + "DBUIFindBuffer", + { noremap = true, silent = true, desc = "Encontrar buffer DB" } + ) + + -- Hook para manter os buffers do DBUI separados + local dbui_augroup = vim.api.nvim_create_augroup("dadbod_ui_config", { clear = true }) + vim.api.nvim_create_autocmd("FileType", { + group = dbui_augroup, + pattern = { "sql", "mysql", "plsql", "dbui", "dbout" }, + callback = function() + -- Definir opções locais para buffers relacionados ao DB + vim.opt_local.buflisted = false + end, + }) + end, +} diff --git a/lua/plugins/dadbod.lua b/lua/plugins/dadbod.lua deleted file mode 100644 index 2e67676..0000000 --- a/lua/plugins/dadbod.lua +++ /dev/null @@ -1,17 +0,0 @@ -return { - "kristijanhusak/vim-dadbod-ui", - dependencies = { - { "tpope/vim-dadbod", lazy = true }, - { "kristijanhusak/vim-dadbod-completion", ft = { "sql", "mysql", "plsql" }, lazy = true }, -- Optional - }, - cmd = { - "DBUI", - "DBUIToggle", - "DBUIAddConnection", - "DBUIFindBuffer", - }, - init = function() - -- Your DBUI configuration - vim.g.db_ui_use_nerd_fonts = 1 - end, -} diff --git a/lua/plugins/dadbode-chatgpe.lua b/lua/plugins/dadbode-chatgpe.lua new file mode 100644 index 0000000..3d9f68d --- /dev/null +++ b/lua/plugins/dadbode-chatgpe.lua @@ -0,0 +1,22 @@ +return { + "kristijanhusak/vim-dadbod-ui", + dependencies = { + { "tpope/vim-dadbod", lazy = true }, + { "kristijanhusak/vim-dadbod-completion", ft = { "sql", "mysql", "plsql" }, lazy = true }, + }, + cmd = { "DBUI", "DBUIToggle", "DBUIAddConnection", "DBUIFindBuffer" }, + init = function() + -- Usa ícones bonitinhos se tiver NerdFonts + vim.g.db_ui_use_nerd_fonts = 1 + + -- Abre DBUI sempre em uma nova tab + vim.api.nvim_create_user_command("DBUITab", function() + vim.cmd("tabnew | DBUI") + end, {}) + + -- Atalhos (coloque os que achar melhor) + vim.keymap.set("n", "Db", "DBUITab", { desc = "Abrir Dadbod UI em nova tab" }) + vim.keymap.set("n", "Dc", "DBUIAddConnection", { desc = "Adicionar conexão DB" }) + vim.keymap.set("n", "Dq", "tabclose", { desc = "Fechar tab atual (DBUI)" }) + end, +} diff --git a/lua/plugins/dap.lua b/lua/plugins/dap.lua index a197924..b1156d4 100644 --- a/lua/plugins/dap.lua +++ b/lua/plugins/dap.lua @@ -1,4 +1,7 @@ -- local icons = require("plugins.lib.icons") +-- if true then +-- return {} +-- end return { { "mfussenegger/nvim-dap", @@ -89,65 +92,65 @@ return { -- }, }, }, - { - "rcarriga/nvim-dap-ui", - dependencies = { "mfussenegger/nvim-dap", "nvim-neotest/nvim-nio" }, - config = function() - local dap, dapui = require("dap"), require("dapui") - dapui.setup({ - layouts = { - { - elements = { - { - id = "scopes", - size = 0.70, - }, - - { - id = "breakpoints", - size = 0.15, - }, - { - id = "console", - size = 0.15, - }, - -- { - -- id = "stacks", - -- size = 0.25, - -- }, - -- { - -- id = "watches", - -- size = 0.25, - -- }, - }, - position = "right", - size = 75, - }, - { - elements = { - - { - id = "repl", - size = 1, - }, - }, - position = "bottom", - size = 15, - }, - }, - }) - dap.listeners.before.attach.dapui_config = function() - dapui.open() - end - dap.listeners.before.launch.dapui_config = function() - dapui.open() - end - dap.listeners.before.event_terminated.dapui_config = function() - dapui.close() - end - dap.listeners.before.event_exited.dapui_config = function() - dapui.close() - end - end, - }, + -- { + -- "rcarriga/nvim-dap-ui", + -- dependencies = { "mfussenegger/nvim-dap", "nvim-neotest/nvim-nio" }, + -- config = function() + -- local dap, dapui = require("dap"), require("dapui") + -- dapui.setup({ + -- layouts = { + -- { + -- elements = { + -- { + -- id = "scopes", + -- size = 0.70, + -- }, + -- + -- { + -- id = "breakpoints", + -- size = 0.15, + -- }, + -- { + -- id = "console", + -- size = 0.15, + -- }, + -- -- { + -- -- id = "stacks", + -- -- size = 0.25, + -- -- }, + -- -- { + -- -- id = "watches", + -- -- size = 0.25, + -- -- }, + -- }, + -- position = "right", + -- size = 75, + -- }, + -- { + -- elements = { + -- + -- { + -- id = "repl", + -- size = 1, + -- }, + -- }, + -- position = "bottom", + -- size = 15, + -- }, + -- }, + -- }) + -- dap.listeners.before.attach.dapui_config = function() + -- dapui.open() + -- end + -- dap.listeners.before.launch.dapui_config = function() + -- dapui.open() + -- end + -- dap.listeners.before.event_terminated.dapui_config = function() + -- dapui.close() + -- end + -- dap.listeners.before.event_exited.dapui_config = function() + -- dapui.close() + -- end + -- end, + -- }, } diff --git a/lua/plugins/dapui.lua b/lua/plugins/dapui.lua new file mode 100644 index 0000000..2a8d005 --- /dev/null +++ b/lua/plugins/dapui.lua @@ -0,0 +1,179 @@ +-- return { +-- "rcarriga/nvim-dap-ui", +-- dependencies = { "mfussenegger/nvim-dap", "nvim-neotest/nvim-nio" }, +-- config = function() +-- local dap = require("dap") +-- local dapui = require("dapui") +-- +-- -- Configuração do dapui com elementos específicos e posicionamento otimizado +-- dapui.setup({ +-- icons = { expanded = "▾", collapsed = "▸", current_frame = "▸" }, +-- mappings = { +-- -- Use a key binding just like `:lua require("dapui").toggle()` +-- expand = { "", "<2-LeftMouse>" }, +-- open = "o", +-- remove = "d", +-- edit = "e", +-- repl = "r", +-- toggle = "t", +-- }, +-- layouts = { +-- { +-- elements = { +-- "breakpoints", +-- "stacks", +-- "watches", +-- }, +-- size = 0.25, -- Tamanho proporcional (25% da tela) +-- position = "left", +-- }, +-- { +-- elements = { +-- { +-- id = "scopes", +-- size = 0.70, +-- }, +-- }, +-- size = 0.25, -- Tamanho proporcional (25% da tela) +-- position = "right", +-- }, +-- }, +-- floating = { +-- max_height = nil, +-- max_width = nil, +-- border = "single", +-- mappings = { +-- close = { "q", "" }, +-- }, +-- }, +-- controls = { +-- enabled = true, +-- element = "repl", +-- icons = { +-- pause = "", +-- play = "", +-- step_into = "", +-- step_over = "", +-- step_out = "", +-- step_back = "", +-- run_last = "", +-- terminate = "", +-- }, +-- }, +-- render = { +-- max_type_length = nil, -- Pode ser útil para prevenir problemas de largura +-- max_value_lines = 100, +-- }, +-- }) +-- +-- -- Variável para controlar o estado da UI +-- local dapui_was_open = false +-- +-- -- Gerencia o redimensionamento e restauração das janelas +-- local function ensure_clean_window_state() +-- vim.cmd("wincmd =") -- Equilibrar janelas +-- vim.cmd("redraw") -- Redesenhar tela +-- end +-- +-- -- Função para abrir dapui com redimensionamento correto +-- local function dapui_open_with_resize() +-- dapui.open() +-- vim.defer_fn(ensure_clean_window_state, 50) +-- dapui_was_open = true +-- end +-- +-- -- Função para fechar dapui com redimensionamento correto +-- local function dapui_close_with_resize() +-- dapui.close() +-- vim.defer_fn(ensure_clean_window_state, 50) +-- dapui_was_open = false +-- end +-- +-- -- Função de toggle personalizada +-- local function dapui_toggle_with_resize(opts) +-- dapui.toggle(opts) +-- vim.defer_fn(ensure_clean_window_state, 50) +-- dapui_was_open = not dapui_was_open +-- end +-- +-- -- Listeners para eventos de depuração +-- dap.listeners.after.event_initialized["dapui_config"] = function() +-- dapui_open_with_resize() +-- end +-- +-- dap.listeners.before.event_terminated["dapui_config"] = function() +-- dapui_close_with_resize() +-- end +-- +-- dap.listeners.before.event_exited["dapui_config"] = function() +-- dapui_close_with_resize() +-- end +-- +-- -- Detectar mudança de buffer para redimensionar corretamente +-- vim.api.nvim_create_autocmd("BufEnter", { +-- callback = function() +-- if dapui_was_open then +-- vim.defer_fn(ensure_clean_window_state, 20) +-- end +-- end, +-- group = vim.api.nvim_create_augroup("DapUiResizeGroup", { clear = true }), +-- }) +-- +-- -- Atalhos para o dapui +-- vim.keymap.set("n", "du", function() +-- dapui_toggle_with_resize() +-- end, { desc = "Toggle DAP UI" }) +-- +-- vim.keymap.set("n", "ds", function() +-- dapui_toggle_with_resize({ layout = 2 }) -- Alterna apenas o painel de scopes (lado direito) +-- end, { desc = "Toggle DAP Scopes" }) +-- +-- -- Após fechar o NvimTree ou outro explorador, redimensionar as janelas +-- vim.api.nvim_create_autocmd("User", { +-- pattern = "NvimTreeClose", +-- callback = function() +-- if dapui_was_open then +-- vim.defer_fn(ensure_clean_window_state, 20) +-- end +-- end, +-- group = vim.api.nvim_create_augroup("NvimTreeResizeGroup", { clear = true }), +-- }) +-- end, +-- keys = { +-- { +-- "du", +-- function() +-- require("dapui").toggle() +-- vim.cmd("wincmd =") -- Equilibrar janelas após o toggle +-- end, +-- desc = "Toggle DAP UI", +-- }, +-- { +-- "ds", +-- function() +-- require("dapui").toggle({ layout = 2 }) +-- vim.cmd("wincmd =") -- Equilibrar janelas após o toggle +-- end, +-- desc = "Toggle DAP Scopes", +-- }, +-- }, +-- } +-- Arquivo de configuração para dap-ui utilizando o novo gerenciador de janelas +-- Coloque em: ~/.config/nvim/lua/plugins/dap-ui.lua + +return { + "rcarriga/nvim-dap-ui", + dependencies = { + "mfussenegger/nvim-dap", + "nvim-neotest/nvim-nio", + -- Podemos adicionar nvim-tree como dependência para garantir carregamento correto + "nvim-tree/nvim-tree.lua", + }, + config = function() + -- Carrega o gerenciador de janelas + local window_manager = require("config.window_manager") + + -- Configura o dap-ui através do gerenciador + window_manager.setup_dapui() + end, +} diff --git a/lua/plugins/harpoon2.lua b/lua/plugins/harpoon2.lua new file mode 100644 index 0000000..570549b --- /dev/null +++ b/lua/plugins/harpoon2.lua @@ -0,0 +1,40 @@ +return { + "ThePrimeagen/harpoon", + branch = "harpoon2", + dependencies = { "nvim-lua/plenary.nvim" }, + config = function() + local harpoon = require("harpoon") + + -- REQUIRED + harpoon:setup() + -- REQUIRED + + vim.keymap.set("n", "", function() + harpoon:list():add() + end) + vim.keymap.set("n", "", function() + harpoon.ui:toggle_quick_menu(harpoon:list()) + end) + + -- vim.keymap.set("n", "", function() + -- harpoon:list():select(1) + -- end) + vim.keymap.set("n", "", function() + harpoon:list():select(2) + end) + vim.keymap.set("n", "", function() + harpoon:list():select(3) + end) + vim.keymap.set("n", "", function() + harpoon:list():select(4) + end) + + -- Toggle previous & next buffers stored within Harpoon list + vim.keymap.set("n", "", function() + harpoon:list():prev() + end) + vim.keymap.set("n", "", function() + harpoon:list():next() + end) + end, +} diff --git a/lua/plugins/kulala.lua b/lua/plugins/kulala.lua new file mode 100644 index 0000000..dc43b40 --- /dev/null +++ b/lua/plugins/kulala.lua @@ -0,0 +1,14 @@ +return { + "mistweaverco/kulala.nvim", + keys = { + { "Rs", desc = "Send request" }, + { "Ra", desc = "Send all requests" }, + { "Rb", desc = "Open scratchpad" }, + }, + ft = { "http", "rest" }, + opts = { + global_keymaps = true, + global_keymaps_prefix = "R", + kulala_keymaps_prefix = "", + }, +} diff --git a/lua/plugins/lsp.lua b/lua/plugins/lsp.lua index 3cc7b16..74ccaec 100644 --- a/lua/plugins/lsp.lua +++ b/lua/plugins/lsp.lua @@ -1,18 +1,21 @@ +if true then + return {} +end return { { "onsails/lspkind.nvim" }, - { - "ray-x/lsp_signature.nvim", - event = "InsertEnter", - opts = { - bind = true, - handler_opts = { - border = "rounded", - }, - }, - config = function(_, opts) - require("lsp_signature").setup(opts) - end, - }, + -- { + -- "ray-x/lsp_signature.nvim", + -- event = "InsertEnter", + -- opts = { + -- bind = true, + -- handler_opts = { + -- border = "rounded", + -- }, + -- }, + -- config = function(_, opts) + -- require("lsp_signature").setup(opts) + -- end, + -- }, { "j-hui/fidget.nvim", opts = { @@ -30,7 +33,7 @@ return { enabled = false, }, ts_ls = { - enabled = false, + enabled = true, }, vtsls = { enabled = false }, }, @@ -51,31 +54,30 @@ return { local lspconfig = require("lspconfig") -- default - require("plugins.lsp.html").setup(lspconfig) - require("plugins.lsp.css").setup(lspconfig) - require("plugins.lsp.emmet_language_server").setup(lspconfig) - lspconfig.htmx.setup({}) + -- require("plugins.lsp.html").setup(lspconfig) + -- require("plugins.lsp.css").setup(lspconfig) + -- require("plugins.lsp.emmet_language_server").setup(lspconfig) -- require("plugins.lsp.sqlls").setup(lspconfig) -- require("plugins.lsp.sqls").setup(lspconfig) -- php require("plugins.lsp.intelephense").setup(lspconfig, blink_capabilities) - require("plugins.lsp.psalm").setup(lspconfig) - require("plugins.lsp.phan").setup(lspconfig) - require("plugins.lsp.twiggy_language_server").setup(lspconfig) + -- require("plugins.lsp.psalm").setup(lspconfig) + -- require("plugins.lsp.phan").setup(lspconfig) + -- require("plugins.lsp.twiggy_language_server").setup(lspconfig) -- ts/js - require("plugins.lsp.astro").setup(lspconfig, blink_capabilities) + -- require("plugins.lsp.astro").setup(lspconfig, blink_capabilities) -- require("plugins.lsp.vtsls").setup(lspconfig, blink_capabilities) - -- require("plugins.lsp.ts_ls").setup(lspconfig, blink_capabilities) - require("plugins.lsp.volar").setup(lspconfig, blink_capabilities) - require("plugins.lsp.eslint").setup(lspconfig) + require("plugins.lsp.ts_ls").setup(lspconfig, blink_capabilities) + -- require("plugins.lsp.volar").setup(lspconfig, blink_capabilities) + -- require("plugins.lsp.eslint").setup(lspconfig) -- ruby - require("plugins.lsp.ruby_lsp").setup(lspconfig, blink_capabilities) - require("plugins.lsp.solargraph").setup(lspconfig, blink_capabilities) - require("plugins.lsp.sorbet").setup(lspconfig, blink_capabilities) + -- require("plugins.lsp.ruby_lsp").setup(lspconfig, blink_capabilities) + -- require("plugins.lsp.solargraph").setup(lspconfig, blink_capabilities) + -- require("plugins.lsp.sorbet").setup(lspconfig, blink_capabilities) -- Disabled require("plugins.lsp.biome").setup(lspconfig, blink_capabilities) diff --git a/lua/plugins/lsp/htmx b/lua/plugins/lsp/htmx new file mode 100644 index 0000000..913df83 --- /dev/null +++ b/lua/plugins/lsp/htmx @@ -0,0 +1,51 @@ + + -- lspconfig.htmx.setup({ + -- filetypes = { -- filetypes copied and adjusted from tailwindcss-intellisense + -- html + -- "aspnetcorerazor", + -- "astro", + -- "astro-markdown", + -- "blade", + -- "clojure", + -- "django-html", + -- "htmldjango", + -- "edge", + -- "eelixir", -- vim ft + -- "elixir", + -- "ejs", + -- "erb", + -- "eruby", -- vim ft + -- "gohtml", + -- "gohtmltmpl", + -- "haml", + -- "handlebars", + -- "hbs", + -- "html", + -- "htmlangular", + -- "html-eex", + -- "heex", + -- "jade", + -- "leaf", + -- "liquid", + -- "markdown", + -- "mdx", + -- "mustache", + -- "njk", + -- "nunjucks", + -- "php", + -- "razor", + -- "slim", + -- "twig", + -- js + -- "javascript", + -- "javascriptreact", + -- "reason", + -- "rescript", + -- "typescript", + -- "typescriptreact", + -- mixed + -- "vue", + -- "svelte", + -- "templ", + -- }, + -- }) diff --git a/lua/plugins/lspsaga.lua b/lua/plugins/lspsaga.lua new file mode 100644 index 0000000..83826af --- /dev/null +++ b/lua/plugins/lspsaga.lua @@ -0,0 +1,18 @@ +if true then + return {} +end +return { + "nvimdev/lspsaga.nvim", + config = function() + require("lspsaga").setup({ + ui = { sign = false }, + }) + + vim.keymap.set("n", "ca", "Lspsaga code_action", { desc = "Code Action" }) + vim.keymap.set("v", "ca", "Lspsaga code_action", { desc = "Code Action" }) + end, + dependencies = { + "nvim-treesitter/nvim-treesitter", -- optional + "nvim-tree/nvim-web-devicons", -- optional + }, +} diff --git a/lua/plugins/marks.lua b/lua/plugins/marks.lua new file mode 100644 index 0000000..5abf267 --- /dev/null +++ b/lua/plugins/marks.lua @@ -0,0 +1,325 @@ +return { + "chentoast/marks.nvim", + dependencies = { "nvim-telescope/telescope.nvim" }, + config = function() + require("marks").setup({ + -- Mostrar marcações padrão + default_mappings = true, + + -- Marcações built-in para incluir + builtin_marks = { ".", "<", ">", "^" }, + + -- Navegação cíclica + cyclic = true, + + -- Forçar escrita no shada + force_write_shada = true, + + -- Intervalo de refresh + refresh_interval = 250, + + -- Prioridade dos sinais + sign_priority = { + lower = 10, + upper = 15, + builtin = 8, + bookmark = 20, + }, + + -- Filetypes excluídos + excluded_filetypes = { + "qf", + "NvimTree", + "toggleterm", + "TelescopePrompt", + "alpha", + "netrw", + "oil", + }, + + -- Configurações de bookmark + bookmark_0 = { + sign = "⚑", + virt_text = "bookmark", + annotate = false, + }, + bookmark_1 = { + sign = "⚐", + virt_text = "bookmark 1", + annotate = false, + }, + bookmark_2 = { + sign = "⚑", + virt_text = "bookmark 2", + annotate = false, + }, + bookmark_3 = { + sign = "⚐", + virt_text = "bookmark 3", + annotate = false, + }, + bookmark_4 = { + sign = "⚑", + virt_text = "bookmark 4", + annotate = false, + }, + bookmark_5 = { + sign = "⚐", + virt_text = "bookmark 5", + annotate = false, + }, + bookmark_6 = { + sign = "⚑", + virt_text = "bookmark 6", + annotate = false, + }, + bookmark_7 = { + sign = "⚐", + virt_text = "bookmark 7", + annotate = false, + }, + bookmark_8 = { + sign = "⚑", + virt_text = "bookmark 8", + annotate = false, + }, + bookmark_9 = { + sign = "⚐", + virt_text = "bookmark 9", + annotate = false, + }, + + -- Mapeamentos personalizados + mappings = { + -- Marcações de letras + set = "m", + delete_line = "dm", + delete_buf = "dm=", + next = "m]", + prev = "m[", + + -- Bookmarks numerados + set_bookmark0 = "m0", + set_bookmark1 = "m1", + set_bookmark2 = "m2", + set_bookmark3 = "m3", + set_bookmark4 = "m4", + set_bookmark5 = "m5", + set_bookmark6 = "m6", + set_bookmark7 = "m7", + set_bookmark8 = "m8", + set_bookmark9 = "m9", + + -- Deletar bookmarks + delete_bookmark0 = "dm0", + delete_bookmark1 = "dm1", + delete_bookmark2 = "dm2", + delete_bookmark3 = "dm3", + delete_bookmark4 = "dm4", + delete_bookmark5 = "dm5", + delete_bookmark6 = "dm6", + delete_bookmark7 = "dm7", + delete_bookmark8 = "dm8", + delete_bookmark9 = "dm9", + + -- Navegação em bookmarks + next_bookmark = "m}", + prev_bookmark = "m{", + next_bookmark0 = "m)0", + next_bookmark1 = "m)1", + next_bookmark2 = "m)2", + next_bookmark3 = "m)3", + next_bookmark4 = "m)4", + next_bookmark5 = "m)5", + next_bookmark6 = "m)6", + next_bookmark7 = "m)7", + next_bookmark8 = "m)8", + next_bookmark9 = "m)9", + + prev_bookmark0 = "m(0", + prev_bookmark1 = "m(1", + prev_bookmark2 = "m(2", + prev_bookmark3 = "m(3", + prev_bookmark4 = "m(4", + prev_bookmark5 = "m(5", + prev_bookmark6 = "m(6", + prev_bookmark7 = "m(7", + prev_bookmark8 = "m(8", + prev_bookmark9 = "m(9", + }, + }) + + -- Função personalizada para Telescope marks com preview melhorado + local function telescope_marks_enhanced() + local actions = require("telescope.actions") + local action_state = require("telescope.actions.state") + local pickers = require("telescope.pickers") + local finders = require("telescope.finders") + local conf = require("telescope.config").values + local previewers = require("telescope.previewers") + + -- Buscar todas as marcações + local marks = {} + local marks_list = vim.fn.getmarklist() + + -- Adicionar marcações do buffer atual + for _, mark in pairs(vim.fn.getmarklist("%")) do + local line = vim.api.nvim_buf_get_lines(0, mark.pos[2] - 1, mark.pos[2], false)[1] or "" + table.insert(marks, { + mark = mark.mark:sub(2, 2), -- Remove o ' + filename = vim.fn.expand("%:p"), + lnum = mark.pos[2], + col = mark.pos[3], + text = line:gsub("^%s*", ""), -- Remove espaços do início + bufnr = vim.api.nvim_get_current_buf(), + }) + end + + -- Adicionar marcações globais + for _, mark in pairs(marks_list) do + if mark.file then + local ok, lines = pcall(vim.fn.readfile, mark.file, "", mark.pos[2]) + local line = "" + if ok and lines[mark.pos[2]] then + line = lines[mark.pos[2]]:gsub("^%s*", "") + end + + table.insert(marks, { + mark = mark.mark:sub(2, 2), + filename = mark.file, + lnum = mark.pos[2], + col = mark.pos[3], + text = line, + bufnr = vim.fn.bufnr(mark.file), + }) + end + end + + if #marks == 0 then + vim.notify("No marks found", vim.log.levels.INFO) + return + end + + pickers + .new({}, { + prompt_title = "Marks", + finder = finders.new_table({ + results = marks, + entry_maker = function(entry) + return { + value = entry, + display = string.format( + "%-2s %s:%d %s", + entry.mark, + vim.fn.fnamemodify(entry.filename, ":t"), + entry.lnum, + entry.text + ), + ordinal = entry.mark .. " " .. entry.filename .. " " .. entry.text, + filename = entry.filename, + lnum = entry.lnum, + col = entry.col, + bufnr = entry.bufnr, + } + end, + }), + sorter = conf.generic_sorter({}), + previewer = previewers.new_buffer_previewer({ + title = "Mark Preview", + define_preview = function(self, entry, status) + local lines = vim.fn.readfile(entry.filename) + local start_line = math.max(1, entry.lnum - 10) + local end_line = math.min(#lines, entry.lnum + 10) + + local preview_lines = {} + for i = start_line, end_line do + local prefix = i == entry.lnum and ">>> " or " " + table.insert(preview_lines, prefix .. (lines[i] or "")) + end + + vim.api.nvim_buf_set_lines(self.state.bufnr, 0, -1, false, preview_lines) + + -- Highlight da linha da marcação + local highlight_line = entry.lnum - start_line + 1 + if highlight_line >= 1 and highlight_line <= #preview_lines then + vim.api.nvim_buf_add_highlight( + self.state.bufnr, + -1, + "Search", + highlight_line - 1, + 0, + -1 + ) + end + end, + }), + attach_mappings = function(prompt_bufnr, map) + local function go_to_mark() + local selection = action_state.get_selected_entry() + actions.close(prompt_bufnr) + + vim.cmd("edit " .. selection.filename) + vim.api.nvim_win_set_cursor(0, { selection.lnum, selection.col }) + vim.cmd("normal! zz") + end + + local function go_to_mark_split() + local selection = action_state.get_selected_entry() + actions.close(prompt_bufnr) + + vim.cmd("split " .. selection.filename) + vim.api.nvim_win_set_cursor(0, { selection.lnum, selection.col }) + vim.cmd("normal! zz") + end + + local function go_to_mark_vsplit() + local selection = action_state.get_selected_entry() + actions.close(prompt_bufnr) + + vim.cmd("vsplit " .. selection.filename) + vim.api.nvim_win_set_cursor(0, { selection.lnum, selection.col }) + vim.cmd("normal! zz") + end + + map("i", "", go_to_mark) + map("n", "", go_to_mark) + map("i", "", go_to_mark_split) + map("n", "", go_to_mark_split) + map("i", "", go_to_mark_vsplit) + map("n", "", go_to_mark_vsplit) + + return true + end, + }) + :find() + end + + -- Keymaps + vim.keymap.set("n", "sm", telescope_marks_enhanced, { desc = "Search marks" }) + vim.keymap.set("n", "ma", function() + require("telescope.builtin").marks() + end, { desc = "Marks (built-in telescope)" }) + + -- Keymaps para navegação rápida + vim.keymap.set("n", "m1", function() + vim.cmd("normal! `1") + end, { desc = "Go to mark 1" }) + vim.keymap.set("n", "m2", function() + vim.cmd("normal! `2") + end, { desc = "Go to mark 2" }) + vim.keymap.set("n", "m3", function() + vim.cmd("normal! `3") + end, { desc = "Go to mark 3" }) + vim.keymap.set("n", "m4", function() + vim.cmd("normal! `4") + end, { desc = "Go to mark 4" }) + vim.keymap.set("n", "m5", function() + vim.cmd("normal! `5") + end, { desc = "Go to mark 5" }) + + -- Mostrar todas as marcações + vim.keymap.set("n", "ml", function() + vim.cmd("marks") + end, { desc = "List all marks" }) + end, +} diff --git a/lua/plugins/mason-lspconfig.lua b/lua/plugins/mason-lspconfig.lua index d7ffa89..08c060f 100644 --- a/lua/plugins/mason-lspconfig.lua +++ b/lua/plugins/mason-lspconfig.lua @@ -1,3 +1,6 @@ +if true then + return {} +end return { { "williamboman/mason.nvim", @@ -13,8 +16,9 @@ return { }, config = function() require("mason-lspconfig").setup({ + automatic_enable = false, ensure_installed = { - "volar", + -- "volar", "lua_ls", "eslint", "intelephense", diff --git a/lua/plugins/mini.lua b/lua/plugins/mini.lua index 4c8aacb..656dd6f 100644 --- a/lua/plugins/mini.lua +++ b/lua/plugins/mini.lua @@ -1,4 +1,11 @@ return { + { + "echasnovski/mini.indentscope", + version = "*", + config = function() + require("mini.indentscope").setup() + end, + }, { "echasnovski/mini.tabline", version = "*" }, { "echasnovski/mini.pick", version = "*" }, { @@ -11,8 +18,7 @@ return { split = "", join = "", }, - } -) + }) end, }, { diff --git a/lua/plugins/none-ls.lua b/lua/plugins/none-ls.lua index 745a69f..7cc8b32 100644 --- a/lua/plugins/none-ls.lua +++ b/lua/plugins/none-ls.lua @@ -5,77 +5,6 @@ return { config = function() local null_ls = require("null-ls") local builtins = null_ls.builtins - local augroup = vim.api.nvim_create_augroup("LspFormatting", {}) - local h = require("null-ls.helpers") - - local twigcs = h.make_builtin({ - name = "docker-twigcs", - meta = { - url = "https://github.com/friendsoftwig/twigcs", - description = "Runs Twigcs in Docker against Twig files.", - }, - method = null_ls.methods.DIAGNOSTICS, - filetypes = { "twig" }, - generator_opts = { - command = "docker-compose", - args = function(params) - -- Extrair apenas o nome do arquivo sem o caminho completo - local filename = vim.fn.fnamemodify(params.bufname, ":t") - - return { - "exec", - "-T", - "web", - "bash", - "-c", - string.format( - [[ - content=$(cat) - temp_file=$(mktemp -p /tmp %s.XXXXXX) - echo "$content" > "$temp_file" - WebSocialSaude/vendor/bin/twigcs --reporter json "$temp_file" || true - rm "$temp_file" - ]], - filename - ), - } - end, - format = "json_raw", - to_stdin = true, - check_exit_code = function(code) - return code <= 1 - end, - on_output = function(params) - local output = params.output - if not output or not output.files or not output.files[1] or not output.files[1].violations then - return {} - end - - local violations = output.files[1].violations - - local parser = h.diagnostics.from_json({ - attributes = { - row = "line", - col = "column", - severity = "severity", - message = "message", - }, - severities = { - h.diagnostics.severities["information"], - h.diagnostics.severities["warning"], - h.diagnostics.severities["error"], - h.diagnostics.severities["hint"], - }, - }) - - return parser({ output = violations }) - end, - }, - factory = h.generator_factory, - }) - - null_ls.register(twigcs) - null_ls.setup({ debug = false, on_attach = function(client, bufnr) @@ -93,14 +22,13 @@ return { end end, sources = { - - require("plugins.sources.phpmd").setup(builtins, null_ls.methods.DIAGNOSTICS_ON_SAVE), - require("plugins.sources.phpstan").setup(builtins, null_ls.methods.DIAGNOSTICS_ON_SAVE), + -- require("plugins.sources.phpmd").setup(builtins, null_ls.methods.DIAGNOSTICS_ON_SAVE), + -- require("plugins.sources.phpstan").setup(builtins, null_ls.methods.DIAGNOSTICS_ON_SAVE), require("plugins.sources.phpcs").setup(builtins, null_ls.methods.DIAGNOSTICS_ON_SAVE), - require("plugins.sources.phpcsfixer").setup(builtins), - require("plugins.sources.phpcbf").setup(builtins), - require("plugins.sources.pint").setup(builtins), - require("plugins.sources.prettier").setup(builtins), + -- require("plugins.sources.phpcsfixer").setup(builtins), + -- require("plugins.sources.phpcbf").setup(builtins), + -- require("plugins.sources.pint").setup(builtins), + -- require("plugins.sources.prettier").setup(builtins), -- builtins.diagnostics.twigcs.with({ -- -- command = "./bin/twigcs-container.sh", -- -- args = { "$FILENAME" }, @@ -114,8 +42,8 @@ return { -- "$FILENAME", -- }, -- }), - builtins.formatting.stylua, - builtins.formatting.xmllint, + -- builtins.formatting.stylua, + -- builtins.formatting.xmllint, -- builtins.formatting.htmlbeautifier.with({ -- filetypes = { "eruby", "twig" }, -- }), diff --git a/lua/plugins/nvim-lint.lua b/lua/plugins/nvim-lint.lua new file mode 100644 index 0000000..970341c --- /dev/null +++ b/lua/plugins/nvim-lint.lua @@ -0,0 +1,25 @@ +if true then + return {} +end +return { + { + "mfussenegger/nvim-lint", + event = { "BufReadPre", "BufNewFile" }, + config = function() + require("lint").linters.phpcs = { + cmd = vim.fn.findfile("vendor/bin/phpcs", ".;") or "phpcs" + } + + require("lint").linters_by_ft = { + php = { "phpcs" } + } + + vim.api.nvim_create_autocmd({ "BufWritePost" }, { + callback = function() + require("lint").try_lint() + end, + }) + end, + } + -- ... seus outros plugins +} diff --git a/lua/plugins/nvim-tree.lua b/lua/plugins/nvim-tree.lua new file mode 100644 index 0000000..0ca4c15 --- /dev/null +++ b/lua/plugins/nvim-tree.lua @@ -0,0 +1,110 @@ +-- return { +-- "nvim-tree/nvim-tree.lua", +-- version = "*", +-- lazy = false, +-- dependencies = { +-- "nvim-tree/nvim-web-devicons", +-- }, +-- config = function() +-- -- Configuração básica do nvim-tree +-- require("nvim-tree").setup({ +-- sort = { +-- sorter = "case_sensitive", +-- }, +-- view = { +-- width = 30, +-- }, +-- renderer = { +-- group_empty = true, +-- }, +-- filters = { +-- dotfiles = false, +-- }, +-- actions = { +-- open_file = { +-- resize_window = true, -- Ajuda a redimensionar janelas corretamente ao abrir arquivos +-- }, +-- }, +-- on_attach = function(bufnr) +-- local api = require("nvim-tree.api") +-- +-- -- Função para criar mapeamentos mais facilmente +-- local function opts(desc) +-- return { desc = "nvim-tree: " .. desc, buffer = bufnr, noremap = true, silent = true, nowait = true } +-- end +-- +-- -- Mapeamentos padrão do nvim-tree que podem ser úteis +-- vim.keymap.set("n", "", api.node.open.edit, opts("Open")) +-- vim.keymap.set("n", "o", api.node.open.edit, opts("Open")) +-- vim.keymap.set("n", "<2-LeftMouse>", api.node.open.edit, opts("Open")) +-- vim.keymap.set("n", "I", api.tree.toggle_gitignore_filter, opts("Toggle Git Ignore")) +-- vim.keymap.set("n", "H", api.tree.toggle_hidden_filter, opts("Toggle Dotfiles")) +-- vim.keymap.set("n", "R", api.tree.reload, opts("Refresh")) +-- vim.keymap.set("n", "a", api.fs.create, opts("Create")) +-- vim.keymap.set("n", "d", api.fs.remove, opts("Delete")) +-- vim.keymap.set("n", "r", api.fs.rename, opts("Rename")) +-- vim.keymap.set("n", "x", api.fs.cut, opts("Cut")) +-- vim.keymap.set("n", "c", api.fs.copy.node, opts("Copy")) +-- vim.keymap.set("n", "p", api.fs.paste, opts("Paste")) +-- vim.keymap.set("n", "y", api.fs.copy.filename, opts("Copy Name")) +-- vim.keymap.set("n", "Y", api.fs.copy.relative_path, opts("Copy Relative Path")) +-- vim.keymap.set("n", "", api.node.open.vertical, opts("Open: Vertical Split")) +-- vim.keymap.set("n", "", api.node.open.horizontal, opts("Open: Horizontal Split")) +-- end, +-- }) +-- +-- -- Auto comandos para garantir que o redimensionamento funcione bem com dap-ui +-- vim.api.nvim_create_autocmd("User", { +-- pattern = "NvimTreeClose", +-- callback = function() +-- vim.cmd("wincmd =") -- Equilibrar janelas após o fechamento do NvimTree +-- end, +-- }) +-- +-- vim.api.nvim_create_autocmd("User", { +-- pattern = "NvimTreeOpen", +-- callback = function() +-- vim.cmd("wincmd =") -- Equilibrar janelas após a abertura do NvimTree +-- end, +-- }) +-- end, +-- keys = { +-- { +-- "e", +-- function() +-- require("nvim-tree.api").tree.toggle() +-- -- Equilibrar janelas após o toggle para garantir layout correto +-- vim.defer_fn(function() +-- vim.cmd("wincmd =") +-- end, 50) +-- end, +-- desc = "Toggle NvimTree Explorer", +-- }, +-- }, +-- } + +-- Arquivo de configuração para nvim-tree utilizando o novo gerenciador de janelas +-- Coloque em: ~/.config/nvim/lua/plugins/nvim-tree.lua + +return { + "nvim-tree/nvim-tree.lua", + version = "*", + lazy = false, + dependencies = { + "nvim-tree/nvim-web-devicons", + }, + config = function() + -- Carrega o gerenciador de janelas + local window_manager = require("config.window_manager") + + -- Configura o nvim-tree através do gerenciador + window_manager.setup_nvim_tree() + require("nvim-tree").setup({ + update_focused_file = { + enable = true, + update_cwd = true, -- opcional, se quiser atualizar o diretório atual do Neovim + ignore_list = {}, -- opcional, lista de buffers a ignorar + }, + }) + end, +} diff --git a/lua/plugins/oil.lua b/lua/plugins/oil.lua new file mode 100644 index 0000000..b2fe7fb --- /dev/null +++ b/lua/plugins/oil.lua @@ -0,0 +1,217 @@ +if true then + return {} +end +return { + "stevearc/oil.nvim", + dependencies = { "nvim-tree/nvim-web-devicons" }, + config = function() + require("oil").setup({ + -- Oil irá tomar conta da edição de diretórios + default_file_explorer = true, + + -- Colunas a serem exibidas + columns = { + "icon", + -- "permissions", + "size", + "mtime", + }, + + -- Buffer options + buf_options = { + buflisted = false, + bufhidden = "hide", + }, + + -- Window options + win_options = { + wrap = false, + signcolumn = "no", + cursorcolumn = false, + foldcolumn = "0", + spell = false, + list = false, + conceallevel = 3, + concealcursor = "nvic", + }, + + -- Opções de segurança + delete_to_trash = true, + skip_confirm_for_simple_edits = true, + prompt_save_on_select_new_entry = true, + cleanup_delay_ms = 2000, + lsp_file_methods = { + timeout_ms = 1000, + autosave_changes = false, + }, + + -- Constrains para edição + constrain_cursor = "editable", + + -- Configurações de exibição + view_options = { + show_hidden = false, + is_hidden_file = function(name, bufnr) + return vim.startswith(name, ".") + end, + is_always_hidden = function(name, bufnr) + return false + end, + natural_order = true, + sort = { + { "type", "asc" }, + { "name", "asc" }, + }, + }, + + -- Mapeamentos dentro do Oil + keymaps = { + ["g?"] = "actions.show_help", + [""] = "actions.select", + [""] = "actions.select_vsplit", + [""] = "actions.select_split", + [""] = "actions.select_tab", + [""] = "actions.preview", + [""] = "actions.close", + [""] = "actions.refresh", + ["-"] = "actions.parent", + ["_"] = "actions.open_cwd", + ["`"] = "actions.cd", + ["~"] = "actions.tcd", + ["gs"] = "actions.change_sort", + ["gx"] = "actions.open_external", + ["g."] = "actions.toggle_hidden", + ["g\\"] = "actions.toggle_trash", + + -- Mapeamentos personalizados + ["ff"] = { + desc = "Find files in current dir", + callback = function() + require("telescope.builtin").find_files({ + cwd = require("oil").get_current_dir(), + }) + end, + }, + ["fg"] = { + desc = "Live grep in current dir", + callback = function() + require("telescope.builtin").live_grep({ + cwd = require("oil").get_current_dir(), + }) + end, + }, + -- Criar novo arquivo + ["nf"] = { + desc = "Create new file", + callback = function() + local oil = require("oil") + local dir = oil.get_current_dir() + vim.ui.input({ prompt = "New file name: " }, function(input) + if input then + local file_path = dir .. "/" .. input + vim.cmd("edit " .. file_path) + end + end) + end, + }, + -- Criar novo diretório + ["nd"] = { + desc = "Create new directory", + callback = function() + local oil = require("oil") + local dir = oil.get_current_dir() + vim.ui.input({ prompt = "New directory name: " }, function(input) + if input then + local dir_path = dir .. "/" .. input + vim.fn.mkdir(dir_path, "p") + oil.open(dir_path) + end + end) + end, + }, + }, + + -- Use_default_keymaps = false se quiser apenas os seus mapeamentos + use_default_keymaps = true, + + -- Configurações de floating window + float = { + padding = 2, + max_width = 0.9, + max_height = 0.9, + border = "rounded", + win_options = { + winblend = 0, + }, + -- Abrir floating window ao invés de substituir o buffer + override = function(conf) + return conf + end, + }, + + -- Configurações de preview + preview = { + max_width = 0.9, + min_width = { 40, 0.4 }, + width = nil, + max_height = 0.9, + min_height = { 5, 0.1 }, + height = nil, + border = "rounded", + win_options = { + winblend = 0, + }, + -- Função para decidir se deve mostrar preview + update_on_cursor_moved = true, + }, + + -- Configurações de confirmação + confirmation = { + max_width = 0.9, + min_width = { 40, 0.4 }, + width = nil, + max_height = 0.9, + min_height = { 5, 0.1 }, + height = nil, + border = "rounded", + win_options = { + winblend = 0, + }, + }, + + -- Configurações de progresso + progress = { + max_width = 0.9, + min_width = { 40, 0.4 }, + width = nil, + max_height = { 10, 0.9 }, + min_height = { 5, 0.1 }, + height = nil, + border = "rounded", + minimized_border = "none", + win_options = { + winblend = 0, + }, + }, + + -- SSH options + ssh = { + border = "rounded", + }, + }) + + -- Keymaps globais + vim.keymap.set("n", "-", "Oil", { desc = "Open parent directory" }) + vim.keymap.set("n", "-", "Oil --float", { desc = "Open parent directory in floating window" }) + + -- Função para abrir Oil no diretório atual do arquivo + vim.keymap.set("n", "o", function() + require("oil").open(vim.fn.expand("%:p:h")) + end, { desc = "Open current file directory" }) + + -- Função para abrir Oil no root do projeto + vim.keymap.set("n", "O", function() + require("oil").open(vim.fn.getcwd()) + end, { desc = "Open project root directory" }) + end, +} diff --git a/lua/plugins/sllm.lua b/lua/plugins/sllm.lua new file mode 100644 index 0000000..873d514 --- /dev/null +++ b/lua/plugins/sllm.lua @@ -0,0 +1,31 @@ +return { + "mozanunal/sllm.nvim", + dependencies = { + "echasnovski/mini.notify", + "echasnovski/mini.pick", + }, + config = function() + require("sllm").setup({ + llm_cmd = "llm", -- command or path for the llm CLI + default_model = "openrouter/deepseek/deepseek-r1-distill-llama-70b:free", -- default llm model (set to "default" to use llm's default model) + show_usage = true, -- append usage stats to responses + on_start_new_chat = true, -- start fresh chat on setup + reset_ctx_each_prompt = true, -- clear file context each ask + window_type = "vertical", -- Default. Options: "vertical", "horizontal", "float" + -- function for item selection (like vim.ui.select) + pick_func = require("mini.pick").ui_select, + -- function for notifications (like vim.notify) + notify_func = require("mini.notify").make_notify(), + -- function for inputs (like vim.ui.input) + input_func = vim.ui.input, + -- See the "Customizing Keymaps" section for more details + keymaps = { + -- Change a default keymap + ask_llm = "la", + -- Disable a default keymap + add_url_to_ctx = false, + -- Other keymaps will use their default values + }, + }) + end, +} diff --git a/lua/plugins/snack.lua b/lua/plugins/snack.lua index 525a1a8..76e2c54 100644 --- a/lua/plugins/snack.lua +++ b/lua/plugins/snack.lua @@ -1,3 +1,6 @@ +if false then + return {} +end return { "folke/snacks.nvim", priority = 1000, @@ -6,8 +9,8 @@ return { opts = { bigfile = { enabled = false }, dashboard = { enabled = true }, - explorer = { enabled = true }, - indent = { enabled = true }, + explorer = { enabled = false }, + indent = { enabled = false }, input = { enabled = true }, notifier = { enabled = true, @@ -76,13 +79,13 @@ return { end, desc = "Notification History", }, - { - "e", - function() - Snacks.explorer() - end, - desc = "File Explorer", - }, + -- { + -- "e", + -- function() + -- Snacks.explorer() + -- end, + -- desc = "File Explorer", + -- }, -- find { "fb", diff --git a/lua/plugins/sources/phpstan.lua b/lua/plugins/sources/phpstan.lua index 3f6e7ab..84c1280 100644 --- a/lua/plugins/sources/phpstan.lua +++ b/lua/plugins/sources/phpstan.lua @@ -6,7 +6,7 @@ M.setup = function(builtins, method) extra_args = { "--memory-limit=1g" }, method = method, condition = function(utils) - return utils.root_has_file({ "phpstan.neon", "src/phpstan.neon" }) + return utils.root_has_file({ "phpstan.neon", "src/phpstan.neon", "composer.json" }) end, }) end diff --git a/lua/plugins/sources/prettier.lua b/lua/plugins/sources/prettier.lua index 365f339..6236964 100644 --- a/lua/plugins/sources/prettier.lua +++ b/lua/plugins/sources/prettier.lua @@ -23,7 +23,7 @@ M.setup = function(builtins) "svelte", "astro", "htmlangular", - -- "twig", + "twig", }, }) end diff --git a/lua/plugins/symbol-usage.lua b/lua/plugins/symbol-usage.lua index e7947d1..028c09e 100644 --- a/lua/plugins/symbol-usage.lua +++ b/lua/plugins/symbol-usage.lua @@ -1,6 +1,10 @@ +if true then + return {} +end return { "Wansmer/symbol-usage.nvim", event = "BufReadPre", -- need run before LspAttach if you use nvim 0.9. On 0.10 use 'LspAttach' + enabled = true, config = function() local function h(name) return vim.api.nvim_get_hl(0, { name = name }) diff --git a/lua/plugins/tiny-inline-diagnostic.lua b/lua/plugins/tiny-inline-diagnostic.lua index 1997fb5..b5db0c1 100644 --- a/lua/plugins/tiny-inline-diagnostic.lua +++ b/lua/plugins/tiny-inline-diagnostic.lua @@ -1,9 +1,34 @@ return { - "rachartier/tiny-inline-diagnostic.nvim", - event = "VeryLazy", -- Or `LspAttach` - priority = 1000, -- needs to be loaded in first - config = function() - require("tiny-inline-diagnostic").setup() - -- vim.diagnostic.config({ virtual_text = false }) -- Only if needed in your configuration, if you already have native LSP diagnostics - end, + { + "rachartier/tiny-inline-diagnostic.nvim", + event = "VeryLazy", -- Or `LspAttach` + priority = 1000, -- needs to be loaded in first + config = function() + require("tiny-inline-diagnostic").setup() + -- vim.diagnostic.config({ virtual_text = false }) -- Only if needed in your configuration, if you already have native LSP diagnostics + vim.keymap.set("n", "ca", function() + require("tiny-code-action").code_action() + end, { noremap = true, silent = true }) + end, + }, + { + "rachartier/tiny-code-action.nvim", + dependencies = { + { "nvim-lua/plenary.nvim" }, + + -- optional picker via telescope + { "nvim-telescope/telescope.nvim" }, + -- optional picker via fzf-lua + { "ibhagwan/fzf-lua" }, + -- .. or via snacks + { + "folke/snacks.nvim", + opts = { + terminal = {}, + }, + }, + }, + event = "LspAttach", + opts = {}, + }, } diff --git a/lua/plugins/trouble.lua b/lua/plugins/trouble.lua index b28ef4b..abf80b7 100644 --- a/lua/plugins/trouble.lua +++ b/lua/plugins/trouble.lua @@ -20,12 +20,12 @@ return { }, { "ls", - "Trouble symbols toggle focus=false", + "Trouble symbols toggle win.relative=win win.position=bottom focus=true", desc = "Symbols (Trouble)", }, { "lD", - "Trouble lsp toggle focus=false win.position=right", + "Trouble lsp toggle focus=false win.relative=win win.position=right", desc = "LSP Definitions / references / ... (Trouble)", }, {