51 lines
1.6 KiB
Lua
51 lines
1.6 KiB
Lua
-- TypeScript/JavaScript LSP configuration
|
|
-- Uses typescript-language-server installed via Mason
|
|
|
|
local status_ok, cmp_nvim_lsp = pcall(require, "cmp_nvim_lsp")
|
|
local capabilities = status_ok
|
|
and cmp_nvim_lsp.default_capabilities(vim.lsp.protocol.make_client_capabilities())
|
|
or vim.lsp.protocol.make_client_capabilities()
|
|
|
|
vim.lsp.config("ts_ls", {
|
|
cmd = { "typescript-language-server", "--stdio" },
|
|
filetypes = {
|
|
"typescript",
|
|
"typescriptreact",
|
|
"typescript.tsx",
|
|
"javascript",
|
|
"javascriptreact",
|
|
"javascript.jsx",
|
|
},
|
|
capabilities = capabilities,
|
|
root_markers = { "package.json", "tsconfig.json", "jsconfig.json", ".git" },
|
|
settings = {
|
|
javascript = {
|
|
format = {
|
|
enable = true,
|
|
insertSpaceAfterCommaDelimiter = true,
|
|
insertSpaceAfterSemicolon = true,
|
|
insertSpaceBeforeAndAfterOperator = true,
|
|
indentStyle = "smart",
|
|
indentSize = 2,
|
|
},
|
|
suggest = {
|
|
completeFunctionCalls = true,
|
|
},
|
|
},
|
|
typescript = {
|
|
format = {
|
|
enable = true,
|
|
insertSpaceAfterCommaDelimiter = true,
|
|
insertSpaceAfterSemicolon = true,
|
|
insertSpaceBeforeAndAfterOperator = true,
|
|
indentStyle = "smart",
|
|
indentSize = 2,
|
|
},
|
|
suggest = {
|
|
completeFunctionCalls = true,
|
|
},
|
|
},
|
|
},
|
|
})
|
|
|
|
vim.lsp.enable("ts_ls")
|