diff options
| author | github-actions[bot] <github-actions[bot]@users.noreply.github.com> | 2024-12-10 05:11:05 +0000 |
|---|---|---|
| committer | github-actions[bot] <github-actions[bot]@users.noreply.github.com> | 2024-12-10 05:11:05 +0000 |
| commit | 5a812abc65d529ea7673059a348814c21d7f87ff (patch) | |
| tree | b1326bd45a9bb5250297bc40df6cfa374272fb27 /doc | |
| parent | docs(volar): fix dead links and remove outdated content (#3498) (diff) | |
| download | nvim-lspconfig-5a812abc65d529ea7673059a348814c21d7f87ff.tar nvim-lspconfig-5a812abc65d529ea7673059a348814c21d7f87ff.tar.gz nvim-lspconfig-5a812abc65d529ea7673059a348814c21d7f87ff.tar.bz2 nvim-lspconfig-5a812abc65d529ea7673059a348814c21d7f87ff.tar.lz nvim-lspconfig-5a812abc65d529ea7673059a348814c21d7f87ff.tar.xz nvim-lspconfig-5a812abc65d529ea7673059a348814c21d7f87ff.tar.zst nvim-lspconfig-5a812abc65d529ea7673059a348814c21d7f87ff.zip | |
docs: update configs.md
skip-checks: true
Diffstat (limited to 'doc')
| -rw-r--r-- | doc/configs.md | 80 | ||||
| -rw-r--r-- | doc/configs.txt | 80 |
2 files changed, 74 insertions, 86 deletions
diff --git a/doc/configs.md b/doc/configs.md index bb72c2bd..1fcad92d 100644 --- a/doc/configs.md +++ b/doc/configs.md @@ -11537,82 +11537,76 @@ Default config: ## volar -https://github.com/johnsoncodehk/volar/tree/20d713b/packages/vue-language-server +https://github.com/vuejs/language-tools/tree/master/packages/language-server Volar language server for Vue Volar can be installed via npm: - ```sh 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 ts_ls. For typescript -support, `ts_ls` needs to be configured with the `@vue/typescript-plugin` -plugin. +Volar by default supports Vue 3 projects. +For Vue 2 projects, [additional configuration](https://github.com/vuejs/language-tools/blob/master/extensions/vscode/README.md?plain=1#L19) are required. -**Take Over Mode** +**Hybrid Mode (by default)** -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). +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 -To enable Take Over Mode, override the default filetypes in `setup{}` as follows: +**No Hybrid Mode** +Volar will run embedded `ts_ls` therefore there is no need to run it separately. ```lua -require'lspconfig'.volar.setup{ - filetypes = {'typescript', 'javascript', 'javascriptreact', 'typescriptreact', 'vue', 'json'} +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 TS in the local `node_modules`. This can lead to issues +The default config looks for TypeScript in the local `node_modules`. This can lead to issues e.g. when working on a [monorepo](https://monorepo.tools/). The alternatives are: - use a global TypeScript Server installation - ```lua -require'lspconfig'.volar.setup{ +require'lspconfig'.volar.setup { init_options = { typescript = { - tsdk = '/path/to/.npm/lib/node_modules/typescript/lib' - -- Alternative location if installed as root: - -- tsdk = '/usr/local/lib/node_modules/typescript/lib' + -- 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 - ```lua -local util = require 'lspconfig.util' -local function get_typescript_server_path(root_dir) - - local global_ts = '/home/[yourusernamehere]/.npm/lib/node_modules/typescript/lib' - -- Alternative location if installed as root: - -- local global_ts = '/usr/local/lib/node_modules/typescript/lib' - local found_ts = '' - local function check_dir(path) - found_ts = util.path.join(path, 'node_modules', 'typescript', 'lib') - if vim.loop.fs_stat(found_ts) then - return path +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 - if util.search_ancestors(root_dir, check_dir) then - return found_ts - else - return global_ts - end -end - -require'lspconfig'.volar.setup{ - on_new_config = function(new_config, new_root_dir) - new_config.init_options.typescript.tsdk = get_typescript_server_path(new_root_dir) - end, } ``` diff --git a/doc/configs.txt b/doc/configs.txt index bb72c2bd..1fcad92d 100644 --- a/doc/configs.txt +++ b/doc/configs.txt @@ -11537,82 +11537,76 @@ Default config: ## volar -https://github.com/johnsoncodehk/volar/tree/20d713b/packages/vue-language-server +https://github.com/vuejs/language-tools/tree/master/packages/language-server Volar language server for Vue Volar can be installed via npm: - ```sh 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 ts_ls. For typescript -support, `ts_ls` needs to be configured with the `@vue/typescript-plugin` -plugin. +Volar by default supports Vue 3 projects. +For Vue 2 projects, [additional configuration](https://github.com/vuejs/language-tools/blob/master/extensions/vscode/README.md?plain=1#L19) are required. -**Take Over Mode** +**Hybrid Mode (by default)** -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). +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 -To enable Take Over Mode, override the default filetypes in `setup{}` as follows: +**No Hybrid Mode** +Volar will run embedded `ts_ls` therefore there is no need to run it separately. ```lua -require'lspconfig'.volar.setup{ - filetypes = {'typescript', 'javascript', 'javascriptreact', 'typescriptreact', 'vue', 'json'} +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 TS in the local `node_modules`. This can lead to issues +The default config looks for TypeScript in the local `node_modules`. This can lead to issues e.g. when working on a [monorepo](https://monorepo.tools/). The alternatives are: - use a global TypeScript Server installation - ```lua -require'lspconfig'.volar.setup{ +require'lspconfig'.volar.setup { init_options = { typescript = { - tsdk = '/path/to/.npm/lib/node_modules/typescript/lib' - -- Alternative location if installed as root: - -- tsdk = '/usr/local/lib/node_modules/typescript/lib' + -- 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 - ```lua -local util = require 'lspconfig.util' -local function get_typescript_server_path(root_dir) - - local global_ts = '/home/[yourusernamehere]/.npm/lib/node_modules/typescript/lib' - -- Alternative location if installed as root: - -- local global_ts = '/usr/local/lib/node_modules/typescript/lib' - local found_ts = '' - local function check_dir(path) - found_ts = util.path.join(path, 'node_modules', 'typescript', 'lib') - if vim.loop.fs_stat(found_ts) then - return path +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 - if util.search_ancestors(root_dir, check_dir) then - return found_ts - else - return global_ts - end -end - -require'lspconfig'.volar.setup{ - on_new_config = function(new_config, new_root_dir) - new_config.init_options.typescript.tsdk = get_typescript_server_path(new_root_dir) - end, } ``` |
