aboutsummaryrefslogtreecommitdiffstats
path: root/lua
diff options
context:
space:
mode:
authorWilliam Boman <william@redwill.se>2022-02-16 10:03:57 +0100
committerGitHub <noreply@github.com>2022-02-16 10:03:57 +0100
commit1980f30cbfb70ca3bf10f8c2b5b7e34167de3649 (patch)
tree01e9f753263b5034b92cb412150eef55120ca8b9 /lua
parentfeat(ui): display language hints for installed servers as well (diff)
downloadmason-1980f30cbfb70ca3bf10f8c2b5b7e34167de3649.tar
mason-1980f30cbfb70ca3bf10f8c2b5b7e34167de3649.tar.gz
mason-1980f30cbfb70ca3bf10f8c2b5b7e34167de3649.tar.bz2
mason-1980f30cbfb70ca3bf10f8c2b5b7e34167de3649.tar.lz
mason-1980f30cbfb70ca3bf10f8c2b5b7e34167de3649.tar.xz
mason-1980f30cbfb70ca3bf10f8c2b5b7e34167de3649.tar.zst
mason-1980f30cbfb70ca3bf10f8c2b5b7e34167de3649.zip
fix(volar): vendor tsserver (#485)
Closes #481.
Diffstat (limited to 'lua')
-rw-r--r--lua/nvim-lsp-installer/servers/volar/init.lua23
1 files changed, 22 insertions, 1 deletions
diff --git a/lua/nvim-lsp-installer/servers/volar/init.lua b/lua/nvim-lsp-installer/servers/volar/init.lua
index 25721b6d..2be49183 100644
--- a/lua/nvim-lsp-installer/servers/volar/init.lua
+++ b/lua/nvim-lsp-installer/servers/volar/init.lua
@@ -1,15 +1,36 @@
+local path = require "nvim-lsp-installer.path"
+local fs = require "nvim-lsp-installer.fs"
local server = require "nvim-lsp-installer.server"
local npm = require "nvim-lsp-installer.installers.npm"
return function(name, root_dir)
+ ---@param dir string
+ local function get_tsserverlib_path(dir)
+ return path.concat { dir, "node_modules", "typescript", "lib", "tsserverlibrary.js" }
+ end
+
+ ---@param workspace_dir string|nil
+ local function get_typescript_server_path(workspace_dir)
+ local local_tsserverlib = workspace_dir ~= nil and get_tsserverlib_path(workspace_dir)
+ local vendored_tsserverlib = get_tsserverlib_path(root_dir)
+ if local_tsserverlib and fs.file_exists(local_tsserverlib) then
+ return local_tsserverlib
+ else
+ return vendored_tsserverlib
+ end
+ end
+
return server.Server:new {
name = name,
root_dir = root_dir,
homepage = "https://github.com/johnsoncodehk/volar",
languages = { "vue" },
- installer = npm.packages { "@volar/server" },
+ installer = npm.packages { "@volar/server", "typescript" },
default_options = {
cmd_env = npm.env(root_dir),
+ on_new_config = function(new_config, new_root_dir)
+ new_config.init_options.typescript.serverPath = get_typescript_server_path(new_root_dir)
+ end,
},
}
end