diff options
| author | Elvis Claros Castro <elvis@claros.ar> | 2024-07-12 11:18:14 -0300 |
|---|---|---|
| committer | Elvis Claros Castro <elvis@claros.ar> | 2024-07-12 11:18:14 -0300 |
| commit | ea0f4bf8ffade657b1d45152dbc183d4679e75c4 (patch) | |
| tree | cc1fb023bc308e019ddce33a4b0aed39f56805dc /lua/alpha/lsp | |
| parent | 1fd0af14d592d612c2aaab7717c04c8806ba3daa (diff) | |
| download | nvim-conf-ea0f4bf8ffade657b1d45152dbc183d4679e75c4.tar.gz nvim-conf-ea0f4bf8ffade657b1d45152dbc183d4679e75c4.zip | |
Feat: PI
Diffstat (limited to 'lua/alpha/lsp')
| -rw-r--r-- | lua/alpha/lsp/attach.lua | 29 | ||||
| -rw-r--r-- | lua/alpha/lsp/default.lua | 30 | ||||
| -rw-r--r-- | lua/alpha/lsp/flags.lua | 3 | ||||
| -rw-r--r-- | lua/alpha/lsp/init.lua | 65 | ||||
| -rw-r--r-- | lua/alpha/lsp/mason.lua | 23 | ||||
| -rw-r--r-- | lua/alpha/lsp/null-ls.lua | 53 | ||||
| -rw-r--r-- | lua/alpha/lsp/servers/emmet_ls.lua | 12 | ||||
| -rw-r--r-- | lua/alpha/lsp/servers/html.lua | 14 | ||||
| -rw-r--r-- | lua/alpha/lsp/servers/jsonls.lua | 14 | ||||
| -rw-r--r-- | lua/alpha/lsp/servers/kotlin_language_server.lua | 12 | ||||
| -rw-r--r-- | lua/alpha/lsp/servers/lua_ls.lua | 36 | ||||
| -rw-r--r-- | lua/alpha/lsp/servers/phpactor.lua | 80 | ||||
| -rw-r--r-- | lua/alpha/lsp/servers/python.lua | 16 | ||||
| -rw-r--r-- | lua/alpha/lsp/servers/rust_analyzer.lua | 24 | ||||
| -rw-r--r-- | lua/alpha/lsp/servers/texlab.lua | 16 | ||||
| -rw-r--r-- | lua/alpha/lsp/servers/tsserver.lua | 33 | ||||
| -rw-r--r-- | lua/alpha/lsp/servers/vscode_smarty_langserver.lua | 25 | ||||
| -rw-r--r-- | lua/alpha/lsp/tools.lua | 8 |
18 files changed, 0 insertions, 493 deletions
diff --git a/lua/alpha/lsp/attach.lua b/lua/alpha/lsp/attach.lua deleted file mode 100644 index 7c7413c..0000000 --- a/lua/alpha/lsp/attach.lua +++ /dev/null @@ -1,29 +0,0 @@ -local telescope_mapper = require "alpha.telescope.mappings" - -return function(client, bufnr) - -- keymaps for lsp - vim.keymap.set("n", "K", vim.lsp.buf.hover, { buffer = 0, desc = "LSP Help information of symbol under the cursor" }) - vim.keymap.set("n", "<leader>vrn", vim.lsp.buf.rename, { buffer = 0, desc = "LSP Rename symbol under cursor" }) - vim.keymap.set("i", "<c-h>", vim.lsp.buf.signature_help, { buffer = 0, desc = "LSP Signature help" }) - vim.keymap.set("n", "<leader>vo", ":LspRestart<cr>", { noremap = true, desc = "LSP Restart Server" }) - vim.keymap.set({ "n", "v" }, "<leader>vca", vim.lsp.buf.code_action, { buffer = 0, desc = "LSP Code actions" }) - vim.keymap.set("n", "<leader>vf", function() - return vim.lsp.buf.format { - async = true, - filter = function(cli) - return cli.name ~= "lua_ls" - end, - } - end, { buffer = 0, desc = "LSP format file" }) - - telescope_mapper("gr", "lsp_references", { buffer = true, desc = "LSP References of symbol on cursor" }) - telescope_mapper("<leader>pv", "find_symbol", { buffer = true, desc = "LSP find symbol on the project" }) - telescope_mapper("<leader>pd", "lsp_document_symbols", { buffer = true, desc = "LSP document symbols" }) - telescope_mapper("gd", "lsp_definitions", { buffer = true, desc = "LSP go to definition" }) - - vim.bo.omnifunc = "v:lua.vim.lsp.omnifunc" - - if client.server_capabilities.inlayHintProvider then - vim.lsp.inlay_hint.enable(bufnr) - end -end diff --git a/lua/alpha/lsp/default.lua b/lua/alpha/lsp/default.lua deleted file mode 100644 index 61e1b28..0000000 --- a/lua/alpha/lsp/default.lua +++ /dev/null @@ -1,30 +0,0 @@ -return { - mason = { - enable = true, - auto_install = false, - }, - servers = { - emmet_ls = { enable = true }, - gopls = { enable = true }, - html = { enable = true }, - jsonls = { enable = true }, - lua_ls = { enable = true, neodev = true }, - nil_ls = { enable = true }, - phpactor = {enable = true }, - rust_analyzer = { enable = true }, - svelte = { enable = true }, - tailwindcss = { enable = true, filetypes = {"blade", "html", "svelte"} }, - tsserver = { enable = true }, - volar = { enable = true }, - texlab = { enable = true, filetypes = {"tex", "bib"} }, - pyright = { enable = true, filetypes = {"python"} }, - kotlin_language_server = { enable = true, filetypes = {"kotlin"}, root_dir = require("lspconfig.util").root_pattern("build.gradle.kts", "pom.xml", ".git") }, - smarty_ls = { enable = true, filetypes = {"smarty"}, root_dir = require("lspconfig.util").root_pattern("composer.json", ".git") }, - }, - default_options = function (options) - return vim.tbl_deep_extend("force", { - on_attach = require"alpha.lsp.attach", - flags = require "alpha.lsp.flags", - }, options) - end, -} diff --git a/lua/alpha/lsp/flags.lua b/lua/alpha/lsp/flags.lua deleted file mode 100644 index f70b467..0000000 --- a/lua/alpha/lsp/flags.lua +++ /dev/null @@ -1,3 +0,0 @@ -return { - debounce_text_changes = 150, -} diff --git a/lua/alpha/lsp/init.lua b/lua/alpha/lsp/init.lua deleted file mode 100644 index 0d69f07..0000000 --- a/lua/alpha/lsp/init.lua +++ /dev/null @@ -1,65 +0,0 @@ -return { - setup = function(ops) - ops = vim.tbl_deep_extend("force", require "alpha.lsp.default", ops) - - local lspconfig = require "lspconfig" - - local mason_servers = {} - for server, options in pairs(ops.servers) do - if options.enable == true then - local ok, definition = pcall(require, "alpha.lsp.servers." .. server) - local server_options - if not ok then - server_options = ops.default_options(options) - else - server_options = definition(options) - end - lspconfig[server].setup(server_options) - 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 - require "alpha.lsp.null-ls" - - local servers = {} - for server, options in pairs(ops.servers) do - table.insert(servers, string.format("%s <%s>", server, options.enable)) - end - - -- TODO: create an auto command that on write of the configuration, calls again the setup and restart the server if it's up. - -- can get the client by name of the file - - vim.api.nvim_create_user_command("AlphaLSP", function() - vim.ui.select(servers, { prompt = "LSP Servers" }, function(server) - if server == nil then - return - end - - server = string.match(server, "^(.+) <") - local path = string.format("%s/lua/alpha/lsp/servers/%s.lua", vim.fn.stdpath "config", server) - if vim.fn.filereadable(path) == 0 then - local create = vim.fn.confirm("Server Does Not exist. Create new server?", "&Yes\n&No\n&Cancel") - if create ~= 1 then - return - end - end - - local uri = vim.uri_from_fname(path) - local buffer = vim.uri_to_bufnr(uri) - - vim.api.nvim_win_set_buf(0, buffer) - end) - end, {}) - end, -} diff --git a/lua/alpha/lsp/mason.lua b/lua/alpha/lsp/mason.lua deleted file mode 100644 index a8c6ce7..0000000 --- a/lua/alpha/lsp/mason.lua +++ /dev/null @@ -1,23 +0,0 @@ -local mason_lspconfig = require "mason-lspconfig" -local servers = require "alpha.lsp.servers" -local lspconfig = require "lspconfig" - -local mason_servers = {} - -for server, _ in pairs(servers) do - local cmd = lspconfig[server].cmd[1] - 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 "alpha.lsp.tools"), --- } diff --git a/lua/alpha/lsp/null-ls.lua b/lua/alpha/lsp/null-ls.lua deleted file mode 100644 index b329ba6..0000000 --- a/lua/alpha/lsp/null-ls.lua +++ /dev/null @@ -1,53 +0,0 @@ -local null_ls = require "null-ls" --- local php_actions = require "php-code-actions" --- local laravel_actions = require("laravel.code-actions") - -null_ls.setup { - sources = { - -- null_ls.builtins.code_actions.gitsigns, - null_ls.builtins.formatting.jq, - null_ls.builtins.code_actions.refactoring, - null_ls.builtins.formatting.alejandra, - null_ls.builtins.diagnostics.luacheck, - null_ls.builtins.formatting.stylua, - - null_ls.builtins.diagnostics.yamllint, - - -- php_actions.getter_setter, - -- php_actions.file_creator, - - -- null_ls.builtins.diagnostics.phpstan.with { - -- to_temp_file = false, - -- method = null_ls.methods.DIAGNOSTICS_ON_SAVE, - -- -- command = "./bin/phpstan", - -- -- condition = function () - -- -- return vim.fn.findfile("bin/phpstan") ~= "" - -- -- end - -- }, - null_ls.builtins.diagnostics.phpcs.with { - method = null_ls.methods.DIAGNOSTICS_ON_SAVE, - condition = function(utils) - return utils.root_has_file "phpcs.xml" - end, - }, - null_ls.builtins.formatting.pint, - }, -} - -vim.keymap.set({ "n", "v" }, "<leader>vca", vim.lsp.buf.code_action, {desc = "LSP (null ls) Code actions"}) -vim.keymap.set("n", "<leader>vf", function() - return vim.lsp.buf.format { async = true } -end, {desc = "LSP (null ls) Format file"}) - --- function to toogle and possible restart it -vim.api.nvim_create_user_command("NullLsToggle", function() - local sources = vim.tbl_map(function(el) - return el.name - end, null_ls.get_sources()) - vim.ui.select(sources, {}, function(selected) - if not selected then - return - end - null_ls.toggle(selected) - end) -end, {}) diff --git a/lua/alpha/lsp/servers/emmet_ls.lua b/lua/alpha/lsp/servers/emmet_ls.lua deleted file mode 100644 index c4f1cb6..0000000 --- a/lua/alpha/lsp/servers/emmet_ls.lua +++ /dev/null @@ -1,12 +0,0 @@ -local lsp_attach = require "alpha.lsp.attach" -local lsp_flags = require "alpha.lsp.flags" - -return function(ops) - local capabilities = require("cmp_nvim_lsp").default_capabilities(vim.lsp.protocol.make_client_capabilities()) - return vim.tbl_extend("force", { - on_attach = lsp_attach, - flags = lsp_flags, - capabilities = capabilities, - filetypes = { "html", "typescriptreact", "javascriptreact", "css", "sass", "scss", "less", "blade", "vue" }, - }, ops) -end diff --git a/lua/alpha/lsp/servers/html.lua b/lua/alpha/lsp/servers/html.lua deleted file mode 100644 index 7b8ef54..0000000 --- a/lua/alpha/lsp/servers/html.lua +++ /dev/null @@ -1,14 +0,0 @@ -local lsp_attach = require "alpha.lsp.attach" -local lsp_flags = require "alpha.lsp.flags" - -return function(ops) - local config = { - on_attach = lsp_attach, - flags = lsp_flags, - } - if vim.fn.executable "html-languageserver" == 1 then - config.cmd = { "html-languageserver", "--stdio" } - end - - return vim.tbl_extend("force", config, ops) -end diff --git a/lua/alpha/lsp/servers/jsonls.lua b/lua/alpha/lsp/servers/jsonls.lua deleted file mode 100644 index 9c731ab..0000000 --- a/lua/alpha/lsp/servers/jsonls.lua +++ /dev/null @@ -1,14 +0,0 @@ -local lsp_attach = require "alpha.lsp.attach" -local lsp_flags = require "alpha.lsp.flags" - -return function(ops) - local config = { - on_attach = lsp_attach, - flags = lsp_flags, - } - if vim.fn.executable "json-languageserver" == 1 then - config.cmd = { "json-languageserver", "--stdio" } - end - - return vim.tbl_extend("force", config, ops) -end diff --git a/lua/alpha/lsp/servers/kotlin_language_server.lua b/lua/alpha/lsp/servers/kotlin_language_server.lua deleted file mode 100644 index 2a02f7d..0000000 --- a/lua/alpha/lsp/servers/kotlin_language_server.lua +++ /dev/null @@ -1,12 +0,0 @@ -local lsp_attach = require "alpha.lsp.attach" -local lsp_flags = require "alpha.lsp.flags" -return function(ops) - return vim.tbl_extend("force", { - on_attach = lsp_attach, - flags = lsp_flags, - settings = { - ["kotlin-language-server"] = { - } - } - }, ops) -end diff --git a/lua/alpha/lsp/servers/lua_ls.lua b/lua/alpha/lsp/servers/lua_ls.lua deleted file mode 100644 index c5f72bf..0000000 --- a/lua/alpha/lsp/servers/lua_ls.lua +++ /dev/null @@ -1,36 +0,0 @@ -local lsp_attach = require "alpha.lsp.attach" -local lsp_flags = require "alpha.lsp.flags" - -return function(ops) - if ops.neodev == true then - require("neodev").setup() - end - - return vim.tbl_extend("force", { - on_attach = lsp_attach, - flags = lsp_flags, - settings = { - Lua = { - runtime = { - version = "LuaJIT", - }, - diagnostics = { - globals = { "vim" }, - }, - workspace = { - library = vim.api.nvim_get_runtime_file("", true), - checkThirdParty = false, - }, - telemetry = { - enable = false, - }, - hint = { - enable = true, - }, - completion = { - callSnippet = "Replace", - }, - }, - }, - }, ops) -end diff --git a/lua/alpha/lsp/servers/phpactor.lua b/lua/alpha/lsp/servers/phpactor.lua deleted file mode 100644 index ab5d21d..0000000 --- a/lua/alpha/lsp/servers/phpactor.lua +++ /dev/null @@ -1,80 +0,0 @@ -local lsp_attach = require "alpha.lsp.attach" -local lsp_flags = require "alpha.lsp.flags" - -local function phpactor_attach(_, bufnr) - vim.api.nvim_buf_create_user_command(bufnr, "LspPhpactorReindex", function() - vim.lsp.buf_notify(bufnr, "phpactor/index/reindex", {}) - end, {}) - - vim.api.nvim_buf_create_user_command(bufnr, "LspPhpactorStatus", function() - local results, _ = vim.lsp.buf_request_sync(bufnr, "phpactor/status", { ["return"] = true }) - - local content = "" - - for _, res in pairs(results or {}) do - if res ~= nil and res["result"] ~= nil then - content = content .. res["result"] - end - end - - local Popup = require "nui.popup" - local event = require("nui.utils.autocmd").event - - local popup = Popup { - enter = true, - focusable = true, - border = { - style = "rounded", - }, - position = "50%", - size = { - width = "80%", - height = "60%", - }, - } - - -- mount/open the component - popup:mount() - - -- unmount component when cursor leaves buffer - popup:on(event.BufLeave, function() - popup:unmount() - end) - local out = {} - for match in string.gmatch(content, "[^\n]+") do - table.insert(out, match) - end - - -- vim.api.nvim_buf_set_option(popup.bufnr, "filetype", "markdown") - vim.api.nvim_buf_set_lines(popup.bufnr, 0, 1, false, out) - end, {}) -end - -return function(ops) - return vim.tbl_extend("force", { - on_attach = function(client, bufnr) - lsp_attach(client, bufnr) - phpactor_attach(client, bufnr) - end, - flags = lsp_flags, - filetypes = { "php", "blade" }, - init_options = { - ["language_server_worse_reflection.inlay_hints.enable"] = true, - ["language_server_worse_reflection.inlay_hints.params"] = true, - ["language_server_worse_reflection.inlay_hints.types"] = true, - ["language_server_configuration.auto_config"] = false, - ["code_transform.import_globals"] = true, - ["language_server_phpstan.enabled"] = true, - ["language_server_phpstan.level"] = 7, - ["language_server_phpstan.bin"] = "phpstan", - }, - handlers = { - ["textDocument/inlayHint"] = function(err, result, ...) - for _, res in ipairs(result) do - res.label = res.label .. ": " - end - vim.lsp.handlers["textDocument/inlayHint"](err, result, ...) - end, - }, - }, ops) -end diff --git a/lua/alpha/lsp/servers/python.lua b/lua/alpha/lsp/servers/python.lua deleted file mode 100644 index 6cdbf9e..0000000 --- a/lua/alpha/lsp/servers/python.lua +++ /dev/null @@ -1,16 +0,0 @@ -local lsp_attach = require "alpha.lsp.attach" -local lsp_flags = require "alpha.lsp.flags" -return function (ops) - return vim.tbl_extend("force", { - on_attach = lsp_attach, - flags = lsp_flags, - settings = { - ["pyright"] = { - disableOrganizeImports = false, - disableDiagnostics = false, - disableLanguageServices = false, - typeCheckingMode = "strict", - } - } - }, ops) -end diff --git a/lua/alpha/lsp/servers/rust_analyzer.lua b/lua/alpha/lsp/servers/rust_analyzer.lua deleted file mode 100644 index c0db321..0000000 --- a/lua/alpha/lsp/servers/rust_analyzer.lua +++ /dev/null @@ -1,24 +0,0 @@ -local lsp_attach = require "alpha.lsp.attach" -local lsp_flags = require "alpha.lsp.flags" - -return function(ops) - return vim.tbl_extend("force", { - on_attach = lsp_attach, - flags = lsp_flags, - settings = { - ["rust-analyzer"] = { - checkOnSave = { - allFeatures = true, - overrideCommand = { - "cargo", - "clippy", - "--workspace", - "--message-format=json", - "--all-targets", - "--all-features", - }, - }, - }, - }, - }, ops) -end diff --git a/lua/alpha/lsp/servers/texlab.lua b/lua/alpha/lsp/servers/texlab.lua deleted file mode 100644 index d749db9..0000000 --- a/lua/alpha/lsp/servers/texlab.lua +++ /dev/null @@ -1,16 +0,0 @@ -local lsp_attach = require "alpha.lsp.attach" -local lsp_flags = require "alpha.lsp.flags" -return function(ops) - return vim.tbl_extend("force", { - on_attach = lsp_attach, - flags = lsp_flags, - settings = { - ["texlab"] = { - latexFormatter = "latexindent", - latexindent = { - modifyLineBreaks = false - } - } - } - }, ops) -end diff --git a/lua/alpha/lsp/servers/tsserver.lua b/lua/alpha/lsp/servers/tsserver.lua deleted file mode 100644 index e27d94a..0000000 --- a/lua/alpha/lsp/servers/tsserver.lua +++ /dev/null @@ -1,33 +0,0 @@ -local lsp_attach = require "alpha.lsp.attach" -local lsp_flags = require "alpha.lsp.flags" - -return function(ops) - return vim.tbl_extend("force", { - on_attach = lsp_attach, - flags = lsp_flags, - settings = { - typescript = { - inlayHints = { - includeInlayParameterNameHints = "all", - includeInlayParameterNameHintsWhenArgumentMatchesName = false, - includeInlayFunctionParameterTypeHints = true, - includeInlayVariableTypeHints = true, - includeInlayPropertyDeclarationTypeHints = true, - includeInlayFunctionLikeReturnTypeHints = true, - includeInlayEnumMemberValueHints = true, - }, - }, - javascript = { - inlayHints = { - includeInlayParameterNameHints = "all", - includeInlayParameterNameHintsWhenArgumentMatchesName = false, - includeInlayFunctionParameterTypeHints = true, - includeInlayVariableTypeHints = true, - includeInlayPropertyDeclarationTypeHints = true, - includeInlayFunctionLikeReturnTypeHints = true, - includeInlayEnumMemberValueHints = true, - }, - }, - }, - }, ops) -end diff --git a/lua/alpha/lsp/servers/vscode_smarty_langserver.lua b/lua/alpha/lsp/servers/vscode_smarty_langserver.lua deleted file mode 100644 index e404698..0000000 --- a/lua/alpha/lsp/servers/vscode_smarty_langserver.lua +++ /dev/null @@ -1,25 +0,0 @@ -local lsp_attach = require "alpha.lsp.attach" -local lsp_flags = require "alpha.lsp.flags" - -return function(ops) - return vim.tbl_extend("force", { - on_attach = lsp_attach, - flags = lsp_flags, - settings = { - css = { - validate = true - }, - smarty = { - pluginDirs = {} - }, - ["smarty_ls"] = { - checkOnSave = { - overrideCommand = { - "smarty-language-server", - "--stdio", - }, - }, - }, - }, - }, ops) -end diff --git a/lua/alpha/lsp/tools.lua b/lua/alpha/lsp/tools.lua deleted file mode 100644 index 7919521..0000000 --- a/lua/alpha/lsp/tools.lua +++ /dev/null @@ -1,8 +0,0 @@ -return { - "codelldb", - "go-debug-adapter", - "js-debug-adapter", - "php-debug-adapter", - "phpcs", - "phpstan", -} |