aboutsummaryrefslogtreecommitdiffstats
path: root/lua
diff options
context:
space:
mode:
authorEmilia <zapata.contact@gmail.com>2022-09-15 00:21:27 +1200
committerGitHub <noreply@github.com>2022-09-14 20:21:27 +0800
commit800eb42600b62cf362b2d5d598927187e33b4493 (patch)
treed770b7ac4dcf51187e10a888c837b4c4f76acc83 /lua
parentfix(lspinfo): nil-check config.get_root_dir (#2137) (diff)
downloadnvim-lspconfig-800eb42600b62cf362b2d5d598927187e33b4493.tar
nvim-lspconfig-800eb42600b62cf362b2d5d598927187e33b4493.tar.gz
nvim-lspconfig-800eb42600b62cf362b2d5d598927187e33b4493.tar.bz2
nvim-lspconfig-800eb42600b62cf362b2d5d598927187e33b4493.tar.lz
nvim-lspconfig-800eb42600b62cf362b2d5d598927187e33b4493.tar.xz
nvim-lspconfig-800eb42600b62cf362b2d5d598927187e33b4493.tar.zst
nvim-lspconfig-800eb42600b62cf362b2d5d598927187e33b4493.zip
fix(astro): enable typescript server (#2139)
As of version 0.24 of the LSP, a `typescript` field is required, with the same convention as `volar`.
Diffstat (limited to 'lua')
-rw-r--r--lua/lspconfig/server_configurations/astro.lua18
1 files changed, 18 insertions, 0 deletions
diff --git a/lua/lspconfig/server_configurations/astro.lua b/lua/lspconfig/server_configurations/astro.lua
index 61d5d301..b643e16d 100644
--- a/lua/lspconfig/server_configurations/astro.lua
+++ b/lua/lspconfig/server_configurations/astro.lua
@@ -7,14 +7,32 @@ if vim.fn.has 'win32' == 1 then
cmd = { 'cmd.exe', '/C', bin_name, '--stdio' }
end
+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', 'tsserverlibrary.js'))
+ or ''
+end
+
return {
default_config = {
cmd = cmd,
filetypes = { 'astro' },
root_dir = util.root_pattern('package.json', 'tsconfig.json', 'jsconfig.json', '.git'),
init_options = {
+ typescript = {
+ serverPath = '',
+ },
configuration = {},
},
+ 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.serverPath == ''
+ then
+ new_config.init_options.typescript.serverPath = get_typescript_server_path(new_root_dir)
+ end
+ end,
},
docs = {
description = [[