Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

vtsls

URL: https://github.com/yioneko/vtsls

plugins.lsp.servers.vtsls.enable

Whether to enable https://github.com/yioneko/vtsls vtsls can be installed with npm:

npm install -g @vtsls/language-server

To configure a TypeScript project, add a tsconfig.json or jsconfig.json to the root of your project. ### Vue support Since v3.0.0, the Vue language server requires vtsls to support TypeScript.

-- If you are using mason.nvim, you can get the ts_plugin_path like this
-- For Mason v1,
-- local mason_registry = require('mason-registry')
-- local vue_language_server_path = mason_registry.get_package('vue-language-server'):get_install_path() .. '/node_modules/@vue/language-server'
-- For Mason v2,
-- local vue_language_server_path = vim.fn.expand '$MASON/packages' .. '/vue-language-server' .. '/node_modules/@vue/language-server'
-- or even
-- local vue_language_server_path = vim.fn.stdpath('data') .. "/mason/packages/vue-language-server/node_modules/@vue/language-server"
local vue_language_server_path = '/path/to/@vue/language-server'
local vue_plugin = {
  name = '@vue/typescript-plugin',
  location = vue_language_server_path,
  languages = { 'vue' },
  configNamespace = 'typescript',
}
vim.lsp.config('vtsls', {
  settings = {
    vtsls = {
      tsserver = {
        globalPlugins = {
          vue_plugin,
        },
      },
    },
  },
  filetypes = { 'typescript', 'javascript', 'javascriptreact', 'typescriptreact', 'vue' },
})
  • 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. You must make sure the Vue language server is setup. For example,
vim.lsp.enable('vue_ls')

See vue_ls section and https://github.com/vuejs/language-tools/wiki/Neovim for more information. ### Monorepo support vtsls supports monorepos by default. It will automatically find the tsconfig.json or jsconfig.json corresponding to the package you are working on. This works without the need of spawning multiple instances of vtsls, saving memory. It is recommended to use the same version of TypeScript in all packages, and therefore have it available in your workspace root. The location of the TypeScript binary will be determined automatically, but only once…

Type: boolean

Default: false

Example: true

Declared by:

plugins.lsp.servers.vtsls.package

The vtsls package to use.

Alternatively, vtsls should be installed on your $PATH.

Type: null or package

Default: pkgs.vtsls

Declared by:

plugins.lsp.servers.vtsls.packageFallback

When enabled, the language server package will be added to the end of the PATH (suffix) instead of the beginning (prefix).

This can be useful if you want local versions of the language server (e.g. from a devshell) to override the nixvim version.

Type: boolean

Default: false

Declared by:

plugins.lsp.servers.vtsls.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.vtsls.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.vtsls.extraOptions

Extra options for the vtsls language server.

Type: attribute set of anything

Default: { }

Declared by:

plugins.lsp.servers.vtsls.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.vtsls.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.vtsls.settings

The settings for this LSP.

Type: open submodule of attribute set of anything

Default: { }

Example:

{
  callback = {
    __raw = ''
      function()
        print('nixvim')
      end
    '';
  };
  foo_bar = 42;
  hostname = "localhost:8080";
}

Declared by: