ts_ls
URL: https://github.com/typescript-language-server/typescript-language-server
plugins.lsp.servers.ts_ls.enable
Whether to enable https://github.com/typescript-language-server/typescript-language-server
ts_ls, aka typescript-language-server, is a Language Server Protocol
implementation for TypeScript wrapping tsserver. Note that ts_ls is
not tsserver.
typescript-language-server depends on typescript. Both packages can
be installed via npm:
npm install -g typescript typescript-language-server
To configure typescript language server, add a
tsconfig.json
or
jsconfig.json
to the root of your project.
Here’s an example that disables type checking in JavaScript files.
{
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"checkJs": false
},
"exclude": [
"node_modules"
]
}
Vue support
As of 2.0.0, Volar no longer supports TypeScript itself. Instead, a plugin adds Vue support to this language server.
IMPORTANT: It is crucial to ensure that @vue/typescript-plugin and
volarare of identical versions.
require'lspconfig'.ts_ls.setup{
init_options = {
plugins = {
{
name = "@vue/typescript-plugin",
location = "/usr/local/lib/node_modules/@vue/typescript-plugin",
languages = {"javascript", "typescript", "vue"},
},
},
},
filetypes = {
"javascript",
"typescript",
"vue",
},
}
-- You must make sure volar is setup
-- e.g. require'lspconfig'.volar.setup{}
-- See volar's section for more information
location MUST be defined. If the plugin is installed in
node_modules, location can have any value.
languages must include vue even if it is listed in filetypes.
filetypes is extended here to include Vue SFC.
.
Type: boolean
Default:
false
Example:
true
Declared by:
plugins.lsp.servers.ts_ls.package
The ts_ls package to use.
Type: null or package
Default:
pkgs.typescript-language-server
Declared by:
plugins.lsp.servers.ts_ls.autostart
Controls if the FileType autocommand that launches a language server is created.
If false, allows for deferring language servers until manually launched with
:LspStart (|lspconfig-commands|).
Type: null or boolean or raw lua code
Default:
null
Plugin default: true
Declared by:
plugins.lsp.servers.ts_ls.cmd
A list where each entry corresponds to the blankspace delimited part of the command that launches the server.
The first entry is the binary used to run the language server. Additional entries are passed as arguments.
Type: null or (list of string)
Default:
null when package is null, otherwise null
Declared by:
plugins.lsp.servers.ts_ls.extraOptions
Extra options for the ts_ls language server.
Type: attribute set of anything
Default:
{ }
Declared by:
plugins.lsp.servers.ts_ls.filetypes
Set of filetypes for which to attempt to resolve {root_dir}. May be empty, or server may specify a default value.
Type: null or (list of string)
Default:
null
Declared by:
plugins.lsp.servers.ts_ls.rootMarkers
A list of files that mark the root of the project/workspace.
Vim’s LSP will try to share the same language server instance for all
buffers matching filetypes within the same project.
A new server instance is only spawned when opening a buffer with a different project root.
See :h lsp-config and :h vim.fs.root().
Type: null or (list of (string or raw lua code)) or raw lua code
Default:
null
Plugin default: null
Declared by:
plugins.lsp.servers.ts_ls.settings
The settings for this LSP.
Type: attribute set of anything
Default:
{ }
Example:
{
callback = {
__raw = ''
function()
print('nixvim')
end
'';
};
foo_bar = 42;
hostname = "localhost:8080";
}
Declared by: