Skip to content

Commit

Permalink
fix(volar): update example for volar 1.0 (neovim#2219)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikehaertl authored Oct 26, 2022
1 parent a035031 commit c31e977
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions lua/lspconfig/server_configurations/volar.lua
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,9 @@ e.g. when working on a [monorepo](https://monorepo.tools/). The alternatives are
require'lspconfig'.volar.setup{
init_options = {
typescript = {
serverPath = '/path/to/.npm/lib/node_modules/typescript/lib/tsserverlib.js'
tsdk = '/path/to/.npm/lib/node_modules/typescript/lib'
-- Alternative location if installed as root:
-- serverPath = '/usr/local/lib/node_modules/typescript/lib/tsserverlibrary.js'
-- tsdk = '/usr/local/lib/node_modules/typescript/lib'
}
}
}
Expand All @@ -120,12 +120,12 @@ require'lspconfig'.volar.setup{
local util = require 'lspconfig.util'
local function get_typescript_server_path(root_dir)
local global_ts = '/home/[yourusernamehere]/.npm/lib/node_modules/typescript/lib/tsserverlibrary.js'
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/tsserverlibrary.js'
-- 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', 'tsserverlibrary.js')
found_ts = util.path.join(path, 'node_modules', 'typescript', 'lib')
if util.path.exists(found_ts) then
return path
end
Expand All @@ -139,7 +139,7 @@ end
require'lspconfig'.volar.setup{
on_new_config = function(new_config, new_root_dir)
new_config.init_options.typescript.serverPath = get_typescript_server_path(new_root_dir)
new_config.init_options.typescript.tsdk = get_typescript_server_path(new_root_dir)
end,
}
```
Expand Down

0 comments on commit c31e977

Please sign in to comment.