summaryrefslogtreecommitdiff
path: root/config/plugin/lsp.lua
diff options
context:
space:
mode:
authorseth <[email protected]>2024-04-09 19:49:37 -0400
committerseth <[email protected]>2024-04-09 19:49:37 -0400
commit16a1126200932407f9f4562fba961b514a1c91d1 (patch)
tree3ab1b6f1035436a644465757c38c17d7943cea11 /config/plugin/lsp.lua
parent43dbb8549d0ecc6dd62a5fd5f9b63beacbfc487b (diff)
auto import all files, cleanup + add a few things
Diffstat (limited to 'config/plugin/lsp.lua')
-rw-r--r--config/plugin/lsp.lua98
1 files changed, 98 insertions, 0 deletions
diff --git a/config/plugin/lsp.lua b/config/plugin/lsp.lua
new file mode 100644
index 0000000..0312523
--- /dev/null
+++ b/config/plugin/lsp.lua
@@ -0,0 +1,98 @@
+if vim.g.did_load_lsp_plugin then
+ return
+end
+vim.g.did_load_lsp_plugin = true
+
+local lsp_servers = {
+ bashls = {
+ binary = "bash-language-server",
+ },
+
+ clangd = {},
+
+ eslint = {},
+
+ efm = {
+ binary = "efm-langserver",
+ extraOptions = require("getchoo.efmls"),
+ },
+
+ lua_ls = {
+ binary = "lua-language-server",
+ extraOptions = {
+ settings = {
+ Lua = {
+ runtime = { version = "LuaJIT" },
+ diagnostics = { globals = "vim" },
+ workspace = { library = vim.api.nvim_get_runtime_file("", true) },
+ },
+ },
+ },
+ },
+
+ nil_ls = {
+ binary = "nil",
+ extraOptions = {
+ settings = {
+ ["nil"] = {
+ formatting = { command = { "alejandra" } },
+ },
+ },
+ },
+ },
+
+ pyright = {},
+ ruff_lsp = {
+ binary = "ruff-lsp",
+ extraOptions = {
+ on_attach = function(client, _)
+ require("lsp-format").on_attach(client)
+ -- pyright should handle this
+ client.server_capabilities.hoverProvider = false
+ end,
+ },
+ },
+
+ rust_analyzer = {
+ binary = "rust-analyzer",
+ extraOptions = {
+ settings = {
+ checkOnSave = { command = "clippy" },
+ },
+ },
+ },
+
+ denols = {
+ binary = "deno",
+ },
+
+ tsserver = {
+ binary = "typescript-language-server",
+ },
+}
+
+local caps = vim.tbl_deep_extend(
+ "force",
+ vim.lsp.protocol.make_client_capabilities(),
+ require("cmp_nvim_lsp").default_capabilities(),
+ -- for nil_ls
+ { workspace = { didChangeWatchedFiles = { dynamicRegistration = true } } }
+)
+
+local setup = {
+ on_attach = function(client, _)
+ require("lsp-format").on_attach(client)
+ end,
+
+ capabilities = caps,
+}
+
+for server, config in pairs(lsp_servers) do
+ local binary = config.binary or server
+
+ local options = (config.extraOptions == nil) and setup or vim.tbl_extend("keep", config.extraOptions, setup)
+
+ if vim.fn.executable(binary) == 1 then
+ require("lspconfig")[server].setup(options)
+ end
+end