From 9c6bbb5d1125491c7c7547e15188ae3e42647143 Mon Sep 17 00:00:00 2001 From: Alexis Tacnet Date: Mon, 28 Apr 2025 14:11:00 +0200 Subject: fix: improve typescript server path search for ts-dependent lsp #3795 --- lsp/astro.lua | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'lsp/astro.lua') diff --git a/lsp/astro.lua b/lsp/astro.lua index 2bd64310..6f33439c 100644 --- a/lsp/astro.lua +++ b/lsp/astro.lua @@ -7,10 +7,7 @@ --- npm install -g @astrojs/language-server --- ``` -local function get_typescript_server_path(root_dir) - local project_root = vim.fs.dirname(vim.fs.find('node_modules', { path = root_dir, upward = true })[1]) - return project_root and vim.fs.joinpath(project_root, 'node_modules', 'typescript', 'lib') or '' -end +local util = require 'lspconfig.util' return { cmd = { 'astro-ls', '--stdio' }, @@ -21,7 +18,7 @@ return { }, before_init = function(_, config) if config.init_options and config.init_options.typescript and not config.init_options.typescript.tsdk then - config.init_options.typescript.tsdk = get_typescript_server_path(config.root_dir) + config.init_options.typescript.tsdk = util.get_typescript_server_path(config.root_dir) end end, } -- cgit v1.2.3-70-g09d2