diff options
Diffstat (limited to 'lua/alpha/lsp')
| -rw-r--r-- | lua/alpha/lsp/attach.lua | 49 | ||||
| -rw-r--r-- | lua/alpha/lsp/init.lua | 18 | ||||
| -rw-r--r-- | lua/alpha/lsp/mason.lua | 16 | ||||
| -rw-r--r-- | lua/alpha/lsp/null-ls.lua | 55 | ||||
| -rw-r--r-- | lua/alpha/lsp/servers.lua | 22 | ||||
| -rw-r--r-- | lua/alpha/lsp/setups.lua | 134 | ||||
| -rw-r--r-- | lua/alpha/lsp/tools.lua | 4 |
7 files changed, 155 insertions, 143 deletions
diff --git a/lua/alpha/lsp/attach.lua b/lua/alpha/lsp/attach.lua index ce63e02..fa67b2e 100644 --- a/lua/alpha/lsp/attach.lua +++ b/lua/alpha/lsp/attach.lua @@ -1,29 +1,34 @@ -local telescope_mapper = require("alpha.telescope.mappings") +local telescope_mapper = require "alpha.telescope.mappings" local filetype_attach = setmetatable({}, { - __index = function() - return function() end - end, + __index = function() + return function() end + end, }) -return function (client, bufnr) - local filetype = vim.api.nvim_buf_get_option(0, "filetype") - -- keymaps for lsp - vim.keymap.set("n", "K", vim.lsp.buf.hover, { buffer = 0 }) - vim.keymap.set("n", "<leader>vrn", vim.lsp.buf.rename, { buffer = 0 }) - vim.keymap.set("i", "<c-h>", vim.lsp.buf.signature_help, { buffer = 0 }) - vim.keymap.set("n", "<leader>vo", ":LspRestart<cr>", { noremap = true }) - vim.keymap.set({ "n", "v" }, "<leader>vca", vim.lsp.buf.code_action, {}) - vim.keymap.set("n", "<leader>vf", function() - return vim.lsp.buf.format({ async = true }) - end, {}) +return function(client, bufnr) + local filetype = vim.api.nvim_buf_get_option(0, "filetype") + -- keymaps for lsp + vim.keymap.set("n", "K", vim.lsp.buf.hover, { buffer = 0 }) + vim.keymap.set("n", "<leader>vrn", vim.lsp.buf.rename, { buffer = 0 }) + vim.keymap.set("i", "<c-h>", vim.lsp.buf.signature_help, { buffer = 0 }) + vim.keymap.set("n", "<leader>vo", ":LspRestart<cr>", { noremap = true }) + vim.keymap.set({ "n", "v" }, "<leader>vca", vim.lsp.buf.code_action, {}) + vim.keymap.set("n", "<leader>vf", function() + return vim.lsp.buf.format { + async = true, + filter = function(cli) + return cli.name ~= "sumneko_lua" + end, + } + end, {}) - telescope_mapper("gr", "lsp_references", nil, true) - telescope_mapper("<leader>pv", "find_symbol", nil, true) - telescope_mapper("<leader>pd", "lsp_document_symbols", nil, true) - telescope_mapper("<c-]>", "lsp_definitions", nil, true) + telescope_mapper("gr", "lsp_references", nil, true) + telescope_mapper("<leader>pv", "find_symbol", nil, true) + telescope_mapper("<leader>pd", "lsp_document_symbols", nil, true) + telescope_mapper("<c-]>", "lsp_definitions", nil, true) - vim.bo.omnifunc = "v:lua.vim.lsp.omnifunc" + vim.bo.omnifunc = "v:lua.vim.lsp.omnifunc" - -- Attach any filetype specific options to the client - filetype_attach[filetype](client, bufnr) + -- Attach any filetype specific options to the client + filetype_attach[filetype](client, bufnr) end diff --git a/lua/alpha/lsp/init.lua b/lua/alpha/lsp/init.lua index c29472d..01bb3c1 100644 --- a/lua/alpha/lsp/init.lua +++ b/lua/alpha/lsp/init.lua @@ -1,14 +1,14 @@ -- LSP configuration -- install servers and tools -require('alpha.lsp.mason') -local setups = require("alpha.lsp.setups") +require "alpha.lsp.mason" +local setups = require "alpha.lsp.setups" -local lspconfig = require('lspconfig') -require('mason-lspconfig').setup_handlers({ - function (server_name) - lspconfig[server_name].setup(setups[server_name]()) - end -}) +local lspconfig = require "lspconfig" +require("mason-lspconfig").setup_handlers { + function(server_name) + lspconfig[server_name].setup(setups[server_name]()) + end, +} -require('alpha.lsp.null-ls') +require "alpha.lsp.null-ls" diff --git a/lua/alpha/lsp/mason.lua b/lua/alpha/lsp/mason.lua index 9dab32e..345301a 100644 --- a/lua/alpha/lsp/mason.lua +++ b/lua/alpha/lsp/mason.lua @@ -1,12 +1,12 @@ -local mason = require("mason") -local mason_lspconfig = require("mason-lspconfig") +local mason = require "mason" +local mason_lspconfig = require "mason-lspconfig" mason.setup() -mason_lspconfig.setup({ - ensure_installed = require('alpha.lsp.servers'), -}) +mason_lspconfig.setup { + ensure_installed = require "alpha.lsp.servers", +} -require('mason-tool-installer').setup({ - ensure_installed = require('alpha.lsp.tools'), -}) +require("mason-tool-installer").setup { + ensure_installed = require "alpha.lsp.tools", +} diff --git a/lua/alpha/lsp/null-ls.lua b/lua/alpha/lsp/null-ls.lua index d8280a8..f80b183 100644 --- a/lua/alpha/lsp/null-ls.lua +++ b/lua/alpha/lsp/null-ls.lua @@ -1,39 +1,42 @@ -local null_ls = require("null-ls") -local composer = require("composer") -local php_actions = require("php-code-actions") +local null_ls = require "null-ls" +local composer = require "composer" +local php_actions = require "php-code-actions" -- local laravel_actions = require("laravel.code-actions") local 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.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, - php_actions.getter_setter, - php_actions.file_creator, + 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, - }), + null_ls.builtins.diagnostics.phpstan.with { + to_temp_file = false, + method = null_ls.methods.DIAGNOSTICS_ON_SAVE, + }, } -if composer.query({ "require", "symfony/framework-bundle" }) ~= nil then - table.insert(sources, null_ls.builtins.diagnostics.phpcs.with({ - method = null_ls.methods.DIAGNOSTICS_ON_SAVE, - })) -elseif composer.query({ "require", "laravel/framework" }) ~= nil then - table.insert(sources, null_ls.builtins.formatting.pint) - -- table.insert(sources, laravel_actions.relationships) +if composer.query { "require", "symfony/framework-bundle" } ~= nil then + table.insert( + sources, + null_ls.builtins.diagnostics.phpcs.with { + method = null_ls.methods.DIAGNOSTICS_ON_SAVE, + } + ) +elseif composer.query { "require", "laravel/framework" } ~= nil then + table.insert(sources, null_ls.builtins.formatting.pint) + -- table.insert(sources, laravel_actions.relationships) end -null_ls.setup({ - sources = sources, -}) +null_ls.setup { + sources = sources, +} vim.keymap.set({ "n", "v" }, "<leader>vca", vim.lsp.buf.code_action, {}) vim.keymap.set("n", "<leader>vf", function() - return vim.lsp.buf.format({ async = true }) + return vim.lsp.buf.format { async = true } end, {}) diff --git a/lua/alpha/lsp/servers.lua b/lua/alpha/lsp/servers.lua index b3f70a0..f401510 100644 --- a/lua/alpha/lsp/servers.lua +++ b/lua/alpha/lsp/servers.lua @@ -1,13 +1,13 @@ return { - "emmet_ls", - "gopls", - "html", - "jsonls", - "marksman", - "phpactor", - "nil_ls", - "rust_analyzer", - "sumneko_lua", - "tsserver", - "volar", + "emmet_ls", + "gopls", + "html", + "jsonls", + "marksman", + "phpactor", + "nil_ls", + "rust_analyzer", + "sumneko_lua", + "tsserver", + "volar", } diff --git a/lua/alpha/lsp/setups.lua b/lua/alpha/lsp/setups.lua index 15ef064..a8bce09 100644 --- a/lua/alpha/lsp/setups.lua +++ b/lua/alpha/lsp/setups.lua @@ -1,74 +1,78 @@ -local lsp_attach = require("alpha.lsp.attach") +local lsp_attach = require "alpha.lsp.attach" local lsp_flags = { - debounce_text_changes = 150, + debounce_text_changes = 150, } return setmetatable({ - rust_analyzer = function() - return { - on_attach = lsp_attach, - flags = lsp_flags, - settings = { - ["rust-analyzer"] = { - checkOnSave = { - allFeatures = true, - overrideCommand = { - 'cargo', 'clippy', '--workspace', '--message-format=json', - '--all-targets', '--all-features' - } - } - }, + rust_analyzer = function() + return { + on_attach = lsp_attach, + flags = lsp_flags, + settings = { + ["rust-analyzer"] = { + checkOnSave = { + allFeatures = true, + overrideCommand = { + "cargo", + "clippy", + "--workspace", + "--message-format=json", + "--all-targets", + "--all-features", }, - } - end, - phpactor = function() - return { - on_attach = lsp_attach, - flags = lsp_flags, - filetypes = { "php", "cucumber" }, - } - end, - emmet_ls = function() - local capabilities = require("cmp_nvim_lsp").default_capabilities(vim.lsp.protocol.make_client_capabilities()) + }, + }, + }, + } + end, + phpactor = function() + return { + on_attach = lsp_attach, + flags = lsp_flags, + filetypes = { "php", "cucumber" }, + } + end, + emmet_ls = function() + local capabilities = require("cmp_nvim_lsp").default_capabilities(vim.lsp.protocol.make_client_capabilities()) - return { - on_attach = lsp_attach, - flags = lsp_flags, - capabilities = capabilities, - filetypes = { "html", "typescriptreact", "javascriptreact", "css", "sass", "scss", "less", "blade", "vue" }, - } - end, - sumneko_lua = function() - return { - 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, - }, - }, - }, - } - end, + return { + on_attach = lsp_attach, + flags = lsp_flags, + capabilities = capabilities, + filetypes = { "html", "typescriptreact", "javascriptreact", "css", "sass", "scss", "less", "blade", "vue" }, + } + end, + sumneko_lua = function() + return { + 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, + }, + }, + }, + } + end, }, { - __index = function() - return function() - return { - on_attach = lsp_attach, - flags = lsp_flags, - } - end - end, + __index = function() + return function() + return { + on_attach = lsp_attach, + flags = lsp_flags, + } + end + end, }) diff --git a/lua/alpha/lsp/tools.lua b/lua/alpha/lsp/tools.lua index 23ef226..68607d5 100644 --- a/lua/alpha/lsp/tools.lua +++ b/lua/alpha/lsp/tools.lua @@ -1,4 +1,4 @@ return { - "go-debug-adapter", - "php-debug-adapter", + "go-debug-adapter", + "php-debug-adapter", } |