aboutsummaryrefslogtreecommitdiffstats
path: root/doc
diff options
context:
space:
mode:
authorgithub-actions <github-actions@github.com>2022-05-21 03:53:53 +0000
committergithub-actions <github-actions@github.com>2022-05-21 03:53:53 +0000
commit9e6bcf5a8915e8423d5cc7f82c5069c11272184d (patch)
tree7c603dc8286283fe6a084cfe6d5c65c072fded94 /doc
parentdocs(volar): Improve config example for monorepos (#1909) (diff)
downloadnvim-lspconfig-9e6bcf5a8915e8423d5cc7f82c5069c11272184d.tar
nvim-lspconfig-9e6bcf5a8915e8423d5cc7f82c5069c11272184d.tar.gz
nvim-lspconfig-9e6bcf5a8915e8423d5cc7f82c5069c11272184d.tar.bz2
nvim-lspconfig-9e6bcf5a8915e8423d5cc7f82c5069c11272184d.tar.lz
nvim-lspconfig-9e6bcf5a8915e8423d5cc7f82c5069c11272184d.tar.xz
nvim-lspconfig-9e6bcf5a8915e8423d5cc7f82c5069c11272184d.tar.zst
nvim-lspconfig-9e6bcf5a8915e8423d5cc7f82c5069c11272184d.zip
docs: update server_configurations.md
skip-checks: true
Diffstat (limited to 'doc')
-rw-r--r--doc/server_configurations.md33
-rw-r--r--doc/server_configurations.txt33
2 files changed, 44 insertions, 22 deletions
diff --git a/doc/server_configurations.md b/doc/server_configurations.md
index 25c2f22e..1569f21c 100644
--- a/doc/server_configurations.md
+++ b/doc/server_configurations.md
@@ -6286,9 +6286,11 @@ Volar can be installed via npm:
npm install -g @volar/vue-language-server
```
-Volar by default supports Vue 3 projects. Vue 2 projects need [additional configuration](https://github.com/johnsoncodehk/volar/blob/master/extensions/vscode-vue-language-features/README.md?plain=1#L28-L63).
+Volar by default supports Vue 3 projects. Vue 2 projects need
+[additional configuration](https://github.com/johnsoncodehk/volar/blob/master/extensions/vscode-vue-language-features/README.md?plain=1#L28-L63).
**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).
To enable Take Over Mode, override the default filetypes in `setup{}` as follows:
@@ -6300,7 +6302,9 @@ require'lspconfig'.volar.setup{
```
**Overriding the default TypeScript Server used by Volar**
-The default config looks for TS in the local node_modules. The alternatives are:
+
+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
@@ -6309,26 +6313,33 @@ require'lspconfig'.volar.setup{
init_options = {
typescript = {
serverPath = '/path/to/.npm/lib/node_modules/typescript/lib/tsserverlib.js'
+ -- Alternative location if installed as root:
+ -- serverPath = '/usr/local/lib/node_modules/typescript/lib/tsserverlibrary.js'
}
}
}
```
-- use a global TypeScript Server installation if a local server is not found
+- 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 project_root = util.find_node_modules_ancestor(root_dir)
- local local_tsserverlib = project_root ~= nil and util.path.join(project_root, 'node_modules', 'typescript', 'lib', 'tsserverlibrary.js')
- local global_tsserverlib = '/home/[yourusernamehere]/.npm/lib/node_modules/typescript/lib/tsserverlibrary.js'
-
- if local_tsserverlib and util.path.exists(local_tsserverlib) then
- return local_tsserverlib
+ local global_ts = '/home/[yourusernamehere]/.npm/lib/node_modules/typescript/lib/tsserverlibrary.js'
+ -- Alternative location if installed as root:
+ -- local global_ts = '/usr/local/lib/node_modules/typescript/lib/tsserverlibrary.js'
+ local found_ts = ''
+ local function check_dir(path)
+ found_ts = util.path.join(path, 'node_modules', 'typescript', 'lib', 'tsserverlibrary.js')
+ 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_tsserverlib
+ return global_ts
end
end
diff --git a/doc/server_configurations.txt b/doc/server_configurations.txt
index 25c2f22e..1569f21c 100644
--- a/doc/server_configurations.txt
+++ b/doc/server_configurations.txt
@@ -6286,9 +6286,11 @@ Volar can be installed via npm:
npm install -g @volar/vue-language-server
```
-Volar by default supports Vue 3 projects. Vue 2 projects need [additional configuration](https://github.com/johnsoncodehk/volar/blob/master/extensions/vscode-vue-language-features/README.md?plain=1#L28-L63).
+Volar by default supports Vue 3 projects. Vue 2 projects need
+[additional configuration](https://github.com/johnsoncodehk/volar/blob/master/extensions/vscode-vue-language-features/README.md?plain=1#L28-L63).
**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).
To enable Take Over Mode, override the default filetypes in `setup{}` as follows:
@@ -6300,7 +6302,9 @@ require'lspconfig'.volar.setup{
```
**Overriding the default TypeScript Server used by Volar**
-The default config looks for TS in the local node_modules. The alternatives are:
+
+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
@@ -6309,26 +6313,33 @@ require'lspconfig'.volar.setup{
init_options = {
typescript = {
serverPath = '/path/to/.npm/lib/node_modules/typescript/lib/tsserverlib.js'
+ -- Alternative location if installed as root:
+ -- serverPath = '/usr/local/lib/node_modules/typescript/lib/tsserverlibrary.js'
}
}
}
```
-- use a global TypeScript Server installation if a local server is not found
+- 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 project_root = util.find_node_modules_ancestor(root_dir)
- local local_tsserverlib = project_root ~= nil and util.path.join(project_root, 'node_modules', 'typescript', 'lib', 'tsserverlibrary.js')
- local global_tsserverlib = '/home/[yourusernamehere]/.npm/lib/node_modules/typescript/lib/tsserverlibrary.js'
-
- if local_tsserverlib and util.path.exists(local_tsserverlib) then
- return local_tsserverlib
+ local global_ts = '/home/[yourusernamehere]/.npm/lib/node_modules/typescript/lib/tsserverlibrary.js'
+ -- Alternative location if installed as root:
+ -- local global_ts = '/usr/local/lib/node_modules/typescript/lib/tsserverlibrary.js'
+ local found_ts = ''
+ local function check_dir(path)
+ found_ts = util.path.join(path, 'node_modules', 'typescript', 'lib', 'tsserverlibrary.js')
+ 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_tsserverlib
+ return global_ts
end
end