dotfiles/nvim/lua/my/lsp.lua

140 lines
4.3 KiB
Lua
Raw Normal View History

2024-02-23 09:38:57 +00:00
local lspconfig = require "lspconfig"
require "neodev".setup()
2023-01-01 14:16:21 +00:00
local capabilities = {}
local has_cmp, cmp_lsp = pcall(require, "cmp_nvim_lsp")
if has_cmp then
capabilities = cmp_lsp.default_capabilities()
end
2023-07-12 09:22:46 +00:00
local eslint = {
lintCommand = [[eslint_d -f visualstudio --stdin --stdin-filename ${INPUT}]],
lintIgnoreExitCode = true,
lintStdin = true,
lintFormats = {
"%f(%l,%c): %tarning %m",
"%f(%l,%c): %rror %m",
},
lintSource = "eslint",
}
2023-07-21 13:57:29 +00:00
local shellcheck = {
lintCommand = "shellcheck -f gcc -x",
lintSource = "shellcheck",
lintFormats = {
"%f:%l:%c: %trror: %m",
"%f:%l:%c: %tarning: %m",
"%f:%l:%c: %tote: %m",
},
}
2023-01-01 14:16:21 +00:00
local servers = {
2023-07-12 09:22:46 +00:00
efm = {
2024-12-19 20:50:42 +00:00
filetypes = { "javascript", "javascriptreact", "typescript", "typescriptreact", "sh" },
2023-07-12 09:22:46 +00:00
init_options = { documentFormatting = true },
settings = {
rootMarkers = { ".git/" },
languages = {
2024-12-19 20:50:42 +00:00
typescript = { eslint },
typescriptreact = { eslint },
javascript = { eslint },
javascriptreact = { eslint },
2023-07-21 13:57:29 +00:00
sh = { shellcheck },
2023-07-12 09:22:46 +00:00
},
},
},
2023-01-01 14:16:21 +00:00
gopls = {},
2023-09-26 17:40:23 +00:00
nil_ls = {
settings = {
['nil'] = {
formatting = {
command = { "nixpkgs-fmt" },
},
},
},
},
2023-01-01 14:16:21 +00:00
rust_analyzer = {
assist = {
importGranularity = "module",
importPrefix = "self",
},
cargo = {
2023-04-22 17:31:30 +00:00
buildScripts = {
enable = true,
},
2023-01-01 14:16:21 +00:00
},
procMacro = {
enable = true,
},
},
2023-02-14 09:43:58 +00:00
lua_ls = {
2023-01-01 14:16:21 +00:00
settings = {
Lua = {
runtime = {
version = "LuaJIT",
},
diagnostics = {
globals = { "vim" },
},
workspace = {
2023-07-12 09:59:53 +00:00
checkThirdParty = false,
2023-01-01 14:16:21 +00:00
library = vim.api.nvim_get_runtime_file("", true),
},
telemetry = {
enable = false,
},
},
},
},
2024-03-02 21:09:33 +00:00
lexical = {
cmd = { "lexical" },
2023-07-12 09:22:46 +00:00
},
2024-04-18 18:37:45 +00:00
gleam = {},
2024-09-07 07:59:36 +00:00
ts_ls = {
2024-06-25 06:04:27 +00:00
root_dir = function(filename, _)
local deno = lspconfig.util.root_pattern("deno.json", "deno.jsonc")(filename)
if deno then
return nil
end
return lspconfig.util.root_pattern("package.json")(filename)
end,
2024-06-03 08:42:28 +00:00
single_file_support = false,
},
denols = {
root_dir = lspconfig.util.root_pattern("deno.json", "deno.jsonc"),
},
2024-04-27 06:47:30 +00:00
intelephense = {
settings = {
intelephense = {
2024-06-19 09:12:58 +00:00
files = { maxSize = 1000000000 },
format = { enable = false },
2024-12-19 20:50:42 +00:00
stubs = { "apache", "bcmath", "bz2", "calendar", "com_dotnet", "Core", "ctype", "curl", "date", "dba", "dom", "enchant", "exif", "FFI", "fileinfo", "filter", "fpm", "ftp", "gd", "gettext", "gmp", "hash", "iconv", "imap", "intl", "json", "ldap", "libxml", "mbstring", "meta", "mysqli", "oci8", "odbc", "openssl", "pcntl", "pcre", "PDO", "pdo_ibm", "pdo_mysql", "pdo_pgsql", "pdo_sqlite", "pgsql", "Phar", "posix", "pspell", "readline", "Reflection", "session", "shmop", "SimpleXML", "snmp", "soap", "sockets", "sodium", "SPL", "sqlite3", "standard", "superglobals", "sysvmsg", "sysvsem", "sysvshm", "tidy", "tokenizer", "xml", "xmlreader", "xmlrpc", "xmlwriter", "xsl", "wordpress", "Zend OPcache", "zip", "zlib", },
2024-04-27 06:47:30 +00:00
},
}
},
2024-10-03 06:35:44 +00:00
zls = {},
2024-10-31 07:37:30 +00:00
bashls = {},
2023-01-01 14:16:21 +00:00
}
for lsp, settings in pairs(servers) do
2024-12-07 13:30:19 +00:00
lspconfig[lsp].setup(vim.tbl_extend("force", { capabilities = capabilities }, settings))
2023-01-01 14:16:21 +00:00
end
2024-12-07 13:30:19 +00:00
vim.api.nvim_create_autocmd("LspAttach", {
callback = function(args)
local client = vim.lsp.get_client_by_id(args.data.client_id)
if client.server_capabilities.documentHighlightProvider then
vim.api.nvim_create_autocmd({ "CursorHold" }, {
callback = vim.lsp.buf.document_highlight,
buffer = args.buf,
})
vim.api.nvim_create_autocmd({ "CursorMoved" }, {
callback = vim.lsp.buf.clear_references,
buffer = args.buf,
})
end
end,
})