volar
URL: https://github.com/vuejs/language-tools#readme
plugins.lsp.servers.volar.enable
Whether to enable https://github.com/vuejs/language-tools/tree/master/packages/language-server
Volar language server for Vue
Volar can be installed via npm:
npm install -g @vue/language-server
Volar by default supports Vue 3 projects. For Vue 2 projects, additional configuration are required.
Hybrid Mode (by default)
In this mode, the Vue Language Server exclusively manages the CSS/HTML
sections. You need the ts_ls
server with the @vue/typescript-plugin
plugin to support TypeScript in .vue
files. See ts_ls
section for
more information
No Hybrid Mode
Volar will run embedded ts_ls
therefore there is no need to run it
separately.
local lspconfig = require('lspconfig')
lspconfig.volar.setup {
-- add filetypes for typescript, javascript and vue
filetypes = { 'typescript', 'javascript', 'javascriptreact', 'typescriptreact', 'vue' },
init_options = {
vue = {
-- disable hybrid mode
hybridMode = false,
},
},
}
-- you must remove ts_ls setup
-- lspconfig.ts_ls.setup {}
Overriding the default TypeScript Server used by Volar
The default config looks for TypeScript in the local node_modules
.
This can lead to issues e.g. when working on a
monorepo. The alternatives are:
- use a global TypeScript Server installation
require'lspconfig'.volar.setup {
init_options = {
typescript = {
-- replace with your global TypeScript library path
tsdk = '/path/to/node_modules/typescript/lib'
}
}
}
- use a local server and fall back to a global TypeScript Server installation
require'lspconfig'.volar.setup {
init_options = {
typescript = {
-- replace with your global TypeScript library path
tsdk = '/path/to/node_modules/typescript/lib'
}
},
on_new_config = function(new_config, new_root_dir)
local lib_path = vim.fs.find('node_modules/typescript/lib', { path = new_root_dir, upward = true })[1]
if lib_path then
new_config.init_options.typescript.tsdk = lib_path
end
end
}
.
Type: boolean
Default:
false
Example:
true
Declared by:
plugins.lsp.servers.volar.package
The volar package to use.
Type: null or package
Default:
pkgs.vue-language-server
Declared by:
plugins.lsp.servers.volar.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.volar.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.volar.extraOptions
Extra options for the volar language server.
Type: attribute set of anything
Default:
{ }
Declared by:
plugins.lsp.servers.volar.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.volar.rootDir
A function (or function handle) which returns the root of the project used to determine if lspconfig should launch a new language server, or attach a previously launched server when you open a new buffer matching the filetype of the server.
Type: null or lua function string
Default:
null
Plugin default: "nil"
Declared by:
plugins.lsp.servers.volar.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:
plugins.lsp.servers.volar.tslsIntegration
Enable integration with TypeScript language server.
Type: boolean
Default:
true
Example:
false
Declared by: