From c9f387fab1d09ed59d877a08a05d283195df95e7 Mon Sep 17 00:00:00 2001 From: Hugo Date: Tue, 5 Mar 2024 07:13:18 +0100 Subject: docs: update documentation for Volar >= 2.0.0 (#3049) See: https://github.com/vuejs/language-tools/issues/3925 --- lua/lspconfig/server_configurations/tsserver.lua | 31 ++++++++++++++++++++++++ lua/lspconfig/server_configurations/volar.lua | 7 +++++- 2 files changed, 37 insertions(+), 1 deletion(-) (limited to 'lua') diff --git a/lua/lspconfig/server_configurations/tsserver.lua b/lua/lspconfig/server_configurations/tsserver.lua index 735889b3..347b15d7 100644 --- a/lua/lspconfig/server_configurations/tsserver.lua +++ b/lua/lspconfig/server_configurations/tsserver.lua @@ -43,6 +43,37 @@ Here's an example that disables type checking in JavaScript files. ] } ``` + +# Vue support + +As of 2.0.0, Volar no longer supports TypeScript itself. Instead, a plugin adds +adds Vue support to this language server. + +```lua +require'lspconfig'.tsserver.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", + }, +} +``` + +`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. ]], default_config = { root_dir = [[root_pattern("tsconfig.json", "package.json", "jsconfig.json", ".git")]], diff --git a/lua/lspconfig/server_configurations/volar.lua b/lua/lspconfig/server_configurations/volar.lua index 30c7ec70..4875b1ff 100644 --- a/lua/lspconfig/server_configurations/volar.lua +++ b/lua/lspconfig/server_configurations/volar.lua @@ -43,9 +43,14 @@ npm install -g @vue/language-server Volar by default supports Vue 3 projects. Vue 2 projects need [additional configuration](https://github.com/vuejs/language-tools/tree/master/packages/vscode-vue#usage). +**TypeScript support** +As of release 2.0.0, Volar no longer wraps around tsserver. For typescript +support, `tsserver` needs to be configured with the `@vue/typescript-plugin` +plugin. + **Take Over Mode** -Volar can serve as a language server for both Vue and TypeScript via [Take Over Mode](https://github.com/johnsoncodehk/volar/discussions/471). +Volar (prior to 2.0.0), can serve as a language server for both Vue and TypeScript via [Take Over Mode](https://github.com/johnsoncodehk/volar/discussions/471). To enable Take Over Mode, override the default filetypes in `setup{}` as follows: -- cgit v1.2.3-70-g09d2