2024-12-28 20:38:15 +00:00
|
|
|
local function config()
|
|
|
|
local lspconfig = require "lspconfig"
|
|
|
|
require "neodev".setup()
|
|
|
|
|
|
|
|
local capabilities = {}
|
|
|
|
|
|
|
|
local has_cmp, cmp_lsp = pcall(require, "cmp_nvim_lsp")
|
|
|
|
if has_cmp then
|
|
|
|
capabilities = cmp_lsp.default_capabilities()
|
|
|
|
end
|
|
|
|
|
|
|
|
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",
|
|
|
|
}
|
|
|
|
|
|
|
|
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",
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
local servers = {
|
|
|
|
efm = {
|
|
|
|
filetypes = { "javascript", "javascriptreact", "typescript", "typescriptreact", "sh" },
|
|
|
|
init_options = { documentFormatting = true },
|
|
|
|
settings = {
|
|
|
|
rootMarkers = { ".git/" },
|
|
|
|
languages = {
|
|
|
|
typescript = { eslint },
|
|
|
|
typescriptreact = { eslint },
|
|
|
|
javascript = { eslint },
|
|
|
|
javascriptreact = { eslint },
|
|
|
|
sh = { shellcheck },
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
gopls = {},
|
|
|
|
nil_ls = {
|
|
|
|
settings = {
|
|
|
|
['nil'] = {
|
|
|
|
formatting = {
|
|
|
|
command = { "nixpkgs-fmt" },
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
rust_analyzer = {
|
|
|
|
assist = {
|
|
|
|
importGranularity = "module",
|
|
|
|
importPrefix = "self",
|
|
|
|
},
|
|
|
|
cargo = {
|
|
|
|
buildScripts = {
|
|
|
|
enable = true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
procMacro = {
|
|
|
|
enable = true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
lua_ls = {
|
|
|
|
settings = {
|
|
|
|
Lua = {
|
|
|
|
runtime = {
|
|
|
|
version = "LuaJIT",
|
|
|
|
},
|
|
|
|
diagnostics = {
|
|
|
|
globals = { "vim" },
|
|
|
|
},
|
|
|
|
workspace = {
|
|
|
|
checkThirdParty = false,
|
|
|
|
library = vim.api.nvim_get_runtime_file("", true),
|
|
|
|
},
|
|
|
|
telemetry = {
|
|
|
|
enable = false,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
lexical = {
|
|
|
|
cmd = { "lexical" },
|
|
|
|
},
|
|
|
|
gleam = {},
|
|
|
|
ts_ls = {
|
|
|
|
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,
|
|
|
|
single_file_support = false,
|
|
|
|
},
|
|
|
|
denols = {
|
|
|
|
root_dir = lspconfig.util.root_pattern("deno.json", "deno.jsonc"),
|
|
|
|
},
|
|
|
|
intelephense = {
|
2025-01-03 09:22:57 +00:00
|
|
|
init_options = { licenceKey = vim.fn.stdpath("config") .. "/intelephense-license" },
|
2024-12-28 20:38:15 +00:00
|
|
|
settings = {
|
|
|
|
intelephense = {
|
|
|
|
files = { maxSize = 1000000000 },
|
|
|
|
format = { enable = false },
|
2025-01-03 09:22:57 +00:00
|
|
|
stubs = require "intelephense_stubs",
|
2024-12-28 20:38:15 +00:00
|
|
|
},
|
|
|
|
}
|
|
|
|
},
|
|
|
|
zls = {},
|
|
|
|
bashls = {},
|
|
|
|
}
|
|
|
|
for lsp, settings in pairs(servers) do
|
|
|
|
lspconfig[lsp].setup(vim.tbl_extend("force", { capabilities = capabilities }, settings))
|
|
|
|
end
|
|
|
|
|
|
|
|
vim.api.nvim_create_autocmd("LspAttach", {
|
|
|
|
callback = function(args)
|
|
|
|
local client = vim.lsp.get_client_by_id(args.data.client_id)
|
|
|
|
|
|
|
|
if not client then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
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,
|
|
|
|
})
|
|
|
|
end
|
|
|
|
|
2024-02-23 09:38:57 +00:00
|
|
|
return {
|
|
|
|
{
|
|
|
|
"neovim/nvim-lspconfig",
|
2024-12-28 20:38:15 +00:00
|
|
|
dependencies = { "folke/neodev.nvim", },
|
|
|
|
config = config,
|
2024-02-23 09:38:57 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"j-hui/fidget.nvim",
|
2024-12-19 20:50:42 +00:00
|
|
|
tag = "v1.5.0",
|
2024-03-12 09:06:02 +00:00
|
|
|
opts = {
|
|
|
|
progress = {
|
|
|
|
display = {
|
|
|
|
progress_ttl = 2,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
notification = {
|
|
|
|
override_vim_notify = true,
|
|
|
|
},
|
|
|
|
},
|
2024-02-23 09:38:57 +00:00
|
|
|
event = "LspAttach"
|
|
|
|
},
|
|
|
|
}
|