summaryrefslogtreecommitdiff
path: root/plugin/lsp.lua
diff options
context:
space:
mode:
authorseth <[email protected]>2024-07-13 20:12:35 -0400
committerseth <[email protected]>2024-07-14 13:47:39 -0400
commit5ec30e9a2b9047713c060c90a5e7930fafc2a3d6 (patch)
tree4c10736c3f5a69d2e214575f0ed1fc0e6d3f2f90 /plugin/lsp.lua
parentc9fb0eded5c69af78a1af12e5fdce7b347c40da3 (diff)
flatten plugin structure
Diffstat (limited to 'plugin/lsp.lua')
-rw-r--r--plugin/lsp.lua129
1 files changed, 129 insertions, 0 deletions
diff --git a/plugin/lsp.lua b/plugin/lsp.lua
new file mode 100644
index 0000000..356add3
--- /dev/null
+++ b/plugin/lsp.lua
@@ -0,0 +1,129 @@
+if vim.g.did_load_lsp_plugin then
+ return
+end
+vim.g.did_load_lsp_plugin = true
+
+local lsp_servers = {
+ astro = {
+ binary = "astro-ls",
+ },
+
+ bashls = {
+ binary = "bash-language-server",
+ },
+
+ biome = {},
+
+ clangd = {},
+
+ denols = {
+ binary = "deno",
+ },
+
+ dprint = {},
+
+ eslint = {
+ binary = "vscode-eslint-language-server",
+ },
+
+ 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 = { "nixfmt" } },
+ },
+ },
+ },
+ },
+
+ nim_langserver = {
+ binary = "nimlangserver",
+ },
+
+ pyright = {
+ extraOptions = {
+ settings = {
+ -- ruff is used instead
+ pyright = { disableOrganizeImports = true },
+ python = { ignore = { "*" } },
+ },
+ },
+ },
+
+ 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" },
+ },
+ },
+ },
+
+ tsserver = {
+ binary = "typescript-language-server",
+ },
+
+ typos_lsp = {
+ binary = "typos-lsp",
+ },
+
+ typst_lsp = {
+ binary = "typst-lsp",
+ },
+}
+
+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