227 lines
5.1 KiB
Lua
227 lines
5.1 KiB
Lua
local on_attach = require("nvchad.configs.lspconfig").on_attach
|
|
local capabilities = require("nvchad.configs.lspconfig").capabilities
|
|
|
|
local lspconfig = require("lspconfig")
|
|
|
|
-- List of servers to install and configure
|
|
local servers = {
|
|
"lua_ls",
|
|
"clangd",
|
|
"pyright",
|
|
"ts_ls", -- TypeScript/JavaScript
|
|
"html",
|
|
"cssls",
|
|
"emmet_ls",
|
|
"eslint",
|
|
}
|
|
|
|
-- Loop through servers and set them up
|
|
for _, lsp in ipairs(servers) do
|
|
lspconfig[lsp].setup({
|
|
on_attach = on_attach,
|
|
capabilities = capabilities,
|
|
})
|
|
end
|
|
|
|
-- C++ specific configuration
|
|
lspconfig.clangd.setup({
|
|
on_attach = on_attach,
|
|
capabilities = capabilities,
|
|
cmd = {
|
|
"clangd",
|
|
"--background-index",
|
|
"--suggest-missing-includes",
|
|
"--clang-tidy",
|
|
"--header-insertion=iwyu",
|
|
},
|
|
filetypes = { "c", "cpp", "objc", "objcpp" },
|
|
})
|
|
|
|
-- Python specific configuration
|
|
lspconfig.pyright.setup({
|
|
on_attach = on_attach,
|
|
capabilities = capabilities,
|
|
settings = {
|
|
pyright = {
|
|
autoImportCompletions = true,
|
|
typeCheckingMode = "basic", -- or "strict"
|
|
},
|
|
python = {
|
|
analysis = {
|
|
diagnosticSeverityOverrides = {
|
|
-- Customize diagnostic severity if needed
|
|
},
|
|
},
|
|
},
|
|
},
|
|
})
|
|
|
|
lspconfig.ts_ls.setup({
|
|
on_attach = on_attach,
|
|
capabilities = capabilities,
|
|
init_options = {
|
|
preferences = {
|
|
disableSuggestions = false,
|
|
},
|
|
},
|
|
settings = {
|
|
typescript = {
|
|
inlayHints = {
|
|
includeInlayParameterNameHints = "all",
|
|
includeInlayParameterNameHintsWhenArgumentMatchesName = false,
|
|
includeInlayFunctionParameterTypeHints = true,
|
|
includeInlayVariableTypeHints = true,
|
|
includeInlayPropertyDeclarationTypeHints = true,
|
|
includeInlayFunctionLikeReturnTypeHints = true,
|
|
includeInlayEnumMemberValueHints = true,
|
|
},
|
|
},
|
|
javascript = {
|
|
inlayHints = {
|
|
includeInlayParameterNameHints = "all",
|
|
includeInlayParameterNameHintsWhenArgumentMatchesName = false,
|
|
includeInlayFunctionParameterTypeHints = true,
|
|
includeInlayVariableTypeHints = true,
|
|
includeInlayPropertyDeclarationTypeHints = true,
|
|
includeInlayFunctionLikeReturnTypeHints = true,
|
|
includeInlayEnumMemberValueHints = true,
|
|
},
|
|
},
|
|
},
|
|
})
|
|
|
|
-- HTML configuration
|
|
lspconfig.html.setup({
|
|
on_attach = on_attach,
|
|
capabilities = capabilities,
|
|
filetypes = { "html", "htmldjango" },
|
|
})
|
|
|
|
-- CSS configuration
|
|
lspconfig.cssls.setup({
|
|
on_attach = on_attach,
|
|
capabilities = capabilities,
|
|
settings = {
|
|
css = {
|
|
validate = true,
|
|
lint = {
|
|
unknownAtRules = "ignore",
|
|
},
|
|
},
|
|
scss = {
|
|
validate = true,
|
|
lint = {
|
|
unknownAtRules = "ignore",
|
|
},
|
|
},
|
|
less = {
|
|
validate = true,
|
|
lint = {
|
|
unknownAtRules = "ignore",
|
|
},
|
|
},
|
|
},
|
|
})
|
|
|
|
-- Emmet configuration for HTML/CSS
|
|
lspconfig.emmet_ls.setup({
|
|
on_attach = on_attach,
|
|
capabilities = capabilities,
|
|
filetypes = { "html", "css", "scss", "javascript", "javascriptreact", "typescript", "typescriptreact" },
|
|
init_options = {
|
|
html = {
|
|
options = {
|
|
["bem.enabled"] = true,
|
|
},
|
|
},
|
|
},
|
|
})
|
|
|
|
-- ESLint configuration
|
|
lspconfig.eslint.setup({
|
|
on_attach = function(client, bufnr)
|
|
on_attach(client, bufnr)
|
|
-- Auto fix on save
|
|
vim.api.nvim_create_autocmd("BufWritePre", {
|
|
buffer = bufnr,
|
|
command = "EslintFixAll",
|
|
})
|
|
end,
|
|
capabilities = capabilities,
|
|
settings = {
|
|
codeAction = {
|
|
disableRuleComment = {
|
|
enable = true,
|
|
location = "separateLine",
|
|
},
|
|
showDocumentation = {
|
|
enable = true,
|
|
},
|
|
},
|
|
codeActionOnSave = {
|
|
enable = false,
|
|
mode = "all",
|
|
},
|
|
format = true,
|
|
nodePath = "",
|
|
onIgnoredFiles = "off",
|
|
packageManager = "npm",
|
|
quiet = false,
|
|
rulesCustomizations = {},
|
|
run = "onType",
|
|
useESLintClass = false,
|
|
validate = "on",
|
|
workingDirectory = {
|
|
mode = "location",
|
|
},
|
|
},
|
|
})
|
|
|
|
-- Configure tinymist (Typst LSP)
|
|
lspconfig.tinymist.setup({
|
|
cmd = { vim.fn.stdpath("data") .. "/mason/bin/tinymist" },
|
|
on_attach = on_attach,
|
|
capabilities = capabilities,
|
|
filetypes = { "typ", "typst" },
|
|
})
|
|
|
|
-- C# OmniSharp configuration - SINGLE CONFIGURATION
|
|
lspconfig.omnisharp.setup({
|
|
on_attach = function(client, bufnr)
|
|
on_attach(client, bufnr)
|
|
|
|
-- Set up C# specific keymaps
|
|
local opts = { noremap = true, silent = true, buffer = bufnr }
|
|
vim.keymap.set("n", "gd", require("omnisharp_extended").lsp_definitions, opts)
|
|
vim.keymap.set("n", "gr", require("omnisharp_extended").lsp_references, opts)
|
|
vim.keymap.set("n", "gi", require("omnisharp_extended").lsp_implementation, opts)
|
|
end,
|
|
capabilities = capabilities,
|
|
handlers = {
|
|
["textDocument/definition"] = require("omnisharp_extended").handler,
|
|
},
|
|
cmd = { "omnisharp", "--languageserver", "--hostPID", tostring(vim.fn.getpid()) },
|
|
root_dir = function(fname)
|
|
return require("lspconfig.util").root_pattern("*.sln", "*.csproj", "omnisharp.json", "function.json")(fname)
|
|
or require("lspconfig.util").find_git_ancestor(fname)
|
|
or vim.fn.getcwd()
|
|
end,
|
|
settings = {
|
|
FormattingOptions = {
|
|
EnableEditorConfigSupport = true,
|
|
OrganizeImports = true,
|
|
},
|
|
MsBuild = {
|
|
LoadProjectsOnDemand = false,
|
|
},
|
|
RoslynExtensionsOptions = {
|
|
EnableAnalyzersSupport = true,
|
|
EnableImportCompletion = true,
|
|
AnalyzeOpenDocumentsOnly = false,
|
|
},
|
|
Sdk = {
|
|
IncludePrereleases = true,
|
|
},
|
|
},
|
|
})
|