aboutsummaryrefslogtreecommitdiffstats
path: root/lua
diff options
context:
space:
mode:
Diffstat (limited to 'lua')
-rw-r--r--lua/alpha/lsp/init.lua12
-rw-r--r--lua/alpha/lsp/mason.lua15
-rw-r--r--lua/alpha/lsp/servers.lua101
-rw-r--r--lua/alpha/lsp/setups.lua78
4 files changed, 108 insertions, 98 deletions
diff --git a/lua/alpha/lsp/init.lua b/lua/alpha/lsp/init.lua
index 01bb3c1..07dc50c 100644
--- a/lua/alpha/lsp/init.lua
+++ b/lua/alpha/lsp/init.lua
@@ -2,13 +2,13 @@
-- install servers and tools
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 servers = R "alpha.lsp.servers"
+
+
+for server, setup in pairs(servers) do
+ lspconfig[server].setup(setup())
+end
require "alpha.lsp.null-ls"
diff --git a/lua/alpha/lsp/mason.lua b/lua/alpha/lsp/mason.lua
index 345301a..5ad4b77 100644
--- a/lua/alpha/lsp/mason.lua
+++ b/lua/alpha/lsp/mason.lua
@@ -1,12 +1,25 @@
local mason = require "mason"
local mason_lspconfig = require "mason-lspconfig"
+local servers = require "alpha.lsp.servers"
+local lspconfig = require "lspconfig"
mason.setup()
+local mason_servers = {}
+
+-- TODO: can be improve checking the setup function to see if sets the cmd
+for server, value in pairs(servers) do
+ local cmd = lspconfig[server].document_config.default_config.cmd[1]
+ if vim.fn.executable(cmd) == 0 then
+ table.insert(mason, server)
+ end
+end
+
mason_lspconfig.setup {
- ensure_installed = require "alpha.lsp.servers",
+ ensure_installed = mason_servers,
}
+-- filter the list for the ones not globally installed
require("mason-tool-installer").setup {
ensure_installed = require "alpha.lsp.tools",
}
diff --git a/lua/alpha/lsp/servers.lua b/lua/alpha/lsp/servers.lua
index fc18153..56e4a76 100644
--- a/lua/alpha/lsp/servers.lua
+++ b/lua/alpha/lsp/servers.lua
@@ -1,15 +1,90 @@
+local lsp_attach = require "alpha.lsp.attach"
+
+local lsp_flags = {
+ debounce_text_changes = 150,
+}
+
+local default = function()
+ return {
+ on_attach = lsp_attach,
+ flags = lsp_flags,
+ }
+ end
+
return {
- "emmet_ls",
- "gopls",
- "html",
- "jsonls",
- "lua_ls",
- "marksman",
- "nil_ls",
- "phpactor",
- "rust_analyzer",
- "svelte",
- "tailwindcss",
- "tsserver",
- "volar",
+ ["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,
+ ["gopls"] = function()
+ return {
+ on_attach = lsp_attach,
+ flags = lsp_flags,
+ }
+ end,
+ ["html"] = default,
+ ["jsonls"] = default,
+ ["lua_ls"] = 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,
+ ["marksman"] = default,
+ ["nil_ls"] = default,
+ ["phpactor"] = function()
+ return {
+ on_attach = lsp_attach,
+ flags = lsp_flags,
+ filetypes = { "php", "cucumber" },
+ }
+ end,
+ ["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,
+ ["svelte"] = default,
+ ["tailwindcss"] = default,
+ ["tsserver"] = default,
+ ["volar"] = default,
}
diff --git a/lua/alpha/lsp/setups.lua b/lua/alpha/lsp/setups.lua
deleted file mode 100644
index 34d3dd8..0000000
--- a/lua/alpha/lsp/setups.lua
+++ /dev/null
@@ -1,78 +0,0 @@
-local lsp_attach = require "alpha.lsp.attach"
-
-local lsp_flags = {
- 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",
- },
- },
- },
- },
- }
- 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,
- lua_ls = 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,
-})