diff options
| author | Justin M. Keyes <justinkz@gmail.com> | 2024-10-01 05:39:12 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-10-01 05:39:12 -0700 |
| commit | bedb2a0df105f68a624a49b867f269b6d55a2c89 (patch) | |
| tree | 877aa3ef8277575a7ffea1ff8f280eeb69b47489 /lua/lspconfig/server_configurations/volar.lua | |
| parent | docs: CONTRIBUTING.md cleanup (diff) | |
| download | nvim-lspconfig-bedb2a0df105f68a624a49b867f269b6d55a2c89.tar nvim-lspconfig-bedb2a0df105f68a624a49b867f269b6d55a2c89.tar.gz nvim-lspconfig-bedb2a0df105f68a624a49b867f269b6d55a2c89.tar.bz2 nvim-lspconfig-bedb2a0df105f68a624a49b867f269b6d55a2c89.tar.lz nvim-lspconfig-bedb2a0df105f68a624a49b867f269b6d55a2c89.tar.xz nvim-lspconfig-bedb2a0df105f68a624a49b867f269b6d55a2c89.tar.zst nvim-lspconfig-bedb2a0df105f68a624a49b867f269b6d55a2c89.zip | |
refactor: rename "server_configurations" => "configs" #3330
Problem:
The name `server_configurations` is extremely verbose and irritatingly
formal and dogmatic. This overlong name is a constant nuisance when
reading, writing, and coding.
It's also not even correct: these configurations are just as much
"client" configurations as they are "server" configurations.
Solution:
- Rename to a shorter name.
- Leave placeholder files for any old URLs that link to the old
location.
Diffstat (limited to 'lua/lspconfig/server_configurations/volar.lua')
| -rw-r--r-- | lua/lspconfig/server_configurations/volar.lua | 113 |
1 files changed, 0 insertions, 113 deletions
diff --git a/lua/lspconfig/server_configurations/volar.lua b/lua/lspconfig/server_configurations/volar.lua deleted file mode 100644 index 888cd165..00000000 --- a/lua/lspconfig/server_configurations/volar.lua +++ /dev/null @@ -1,113 +0,0 @@ -local util = require 'lspconfig.util' - -local function get_typescript_server_path(root_dir) - local project_root = util.find_node_modules_ancestor(root_dir) - return project_root and (util.path.join(project_root, 'node_modules', 'typescript', 'lib')) or '' -end - --- https://github.com/johnsoncodehk/volar/blob/20d713b/packages/shared/src/types.ts -local volar_init_options = { - typescript = { - tsdk = '', - }, -} - -return { - default_config = { - cmd = { 'vue-language-server', '--stdio' }, - filetypes = { 'vue' }, - root_dir = util.root_pattern 'package.json', - init_options = volar_init_options, - on_new_config = function(new_config, new_root_dir) - if - new_config.init_options - and new_config.init_options.typescript - and new_config.init_options.typescript.tsdk == '' - then - new_config.init_options.typescript.tsdk = get_typescript_server_path(new_root_dir) - end - end, - }, - docs = { - description = [[ -https://github.com/johnsoncodehk/volar/tree/20d713b/packages/vue-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. - -**Take Over Mode** - -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: - -```lua -require'lspconfig'.volar.setup{ - filetypes = {'typescript', 'javascript', 'javascriptreact', 'typescriptreact', 'vue', 'json'} -} -``` - -**Overriding the default TypeScript Server used by Volar** - -The default config looks for TS 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{ - 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' - } - } -} -``` - -- 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 util.path.exists(found_ts) then - return 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, -} -``` - ]], - }, -} |
