aboutsummaryrefslogtreecommitdiffstats
path: root/lua/alpha/lsp
diff options
context:
space:
mode:
Diffstat (limited to 'lua/alpha/lsp')
-rw-r--r--lua/alpha/lsp/attach.lua4
-rw-r--r--lua/alpha/lsp/init.lua6
-rw-r--r--lua/alpha/lsp/mason.lua7
-rw-r--r--lua/alpha/lsp/null-ls.lua23
-rw-r--r--lua/alpha/lsp/servers.lua32
-rw-r--r--lua/alpha/lsp/tools.lua6
6 files changed, 62 insertions, 16 deletions
diff --git a/lua/alpha/lsp/attach.lua b/lua/alpha/lsp/attach.lua
index 45ce904..bf5b645 100644
--- a/lua/alpha/lsp/attach.lua
+++ b/lua/alpha/lsp/attach.lua
@@ -29,6 +29,10 @@ return function(client, bufnr)
vim.bo.omnifunc = "v:lua.vim.lsp.omnifunc"
+ if client.server_capabilities.inlayHintProvider then
+ vim.lsp.inlay_hint(bufnr, true)
+ end
+
-- 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 d280e53..03bd61d 100644
--- a/lua/alpha/lsp/init.lua
+++ b/lua/alpha/lsp/init.lua
@@ -1,14 +1,12 @@
-- LSP configuration
--- install servers and tools
-require "alpha.lsp.mason"
-
local lspconfig = require "lspconfig"
local servers = require "alpha.lsp.servers"
-
for server, setup in pairs(servers) do
lspconfig[server].setup(setup())
end
+-- install servers and tools
+require "alpha.lsp.mason"
require "alpha.lsp.null-ls"
diff --git a/lua/alpha/lsp/mason.lua b/lua/alpha/lsp/mason.lua
index e164562..161a205 100644
--- a/lua/alpha/lsp/mason.lua
+++ b/lua/alpha/lsp/mason.lua
@@ -7,9 +7,8 @@ mason.setup()
local mason_servers = {}
--- TODO: can be improve checking the setup function to see if sets the cmd
for server, _ in pairs(servers) do
- local cmd = lspconfig[server].document_config.default_config.cmd[1]
+ local cmd = lspconfig[server].cmd[1]
if vim.fn.executable(cmd) == 0 then
table.insert(mason_servers, server)
end
@@ -21,5 +20,7 @@ mason_lspconfig.setup {
-- filter the list for the ones not globally installed
require("mason-tool-installer").setup {
- ensure_installed = require "alpha.lsp.tools",
+ 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
index be3d4e9..3428ec6 100644
--- a/lua/alpha/lsp/null-ls.lua
+++ b/lua/alpha/lsp/null-ls.lua
@@ -11,16 +11,18 @@ null_ls.setup {
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
+ -- 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,
@@ -36,3 +38,16 @@ vim.keymap.set({ "n", "v" }, "<leader>vca", vim.lsp.buf.code_action, {desc = "LS
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.lua b/lua/alpha/lsp/servers.lua
index f09f523..d2233a1 100644
--- a/lua/alpha/lsp/servers.lua
+++ b/lua/alpha/lsp/servers.lua
@@ -28,8 +28,28 @@ return {
flags = lsp_flags,
}
end,
- ["html"] = default,
- ["jsonls"] = default,
+ ["html"] = function ()
+ local config = {
+ on_attach = lsp_attach,
+ flags = lsp_flags,
+ }
+ if vim.fn.executable("html-languageserver") == 1 then
+ config.cmd = { "html-languageserver", "--stdio" }
+ end
+
+ return config
+ end,
+ ["jsonls"] = function ()
+ local config = {
+ on_attach = lsp_attach,
+ flags = lsp_flags,
+ }
+ if vim.fn.executable("json-languageserver") == 1 then
+ config.cmd = { "json-languageserver", "--stdio" }
+ end
+
+ return config
+ end,
["lua_ls"] = function()
return {
on_attach = lsp_attach,
@@ -51,7 +71,7 @@ return {
},
hint = {
enable = true,
- }
+ },
},
},
}
@@ -63,8 +83,14 @@ return {
on_attach = lsp_attach,
flags = lsp_flags,
filetypes = { "php", "cucumber" },
+ init_options = {
+ ["language_server_worse_reflection.inlay_hints.enable"] = true,
+ -- ["language_server_worse_reflection.inlay_hints.types"] = true,
+ -- ["language_server_worse_reflection.inlay_hints.params"] = true,
+ },
}
end,
+ ["pyright"] = default,
["rust_analyzer"] = function()
return {
on_attach = lsp_attach,
diff --git a/lua/alpha/lsp/tools.lua b/lua/alpha/lsp/tools.lua
index 4eb40b3..7919521 100644
--- a/lua/alpha/lsp/tools.lua
+++ b/lua/alpha/lsp/tools.lua
@@ -1,6 +1,8 @@
return {
+ "codelldb",
"go-debug-adapter",
- "php-debug-adapter",
"js-debug-adapter",
- "codelldb",
+ "php-debug-adapter",
+ "phpcs",
+ "phpstan",
}