diff options
| author | Tucker Hoog <77054686+Grahf0085@users.noreply.github.com> | 2025-04-17 01:51:05 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-04-17 13:51:05 +0800 |
| commit | 29db2cc0c4d517a1e09ceb85a3c43a4691f6ddd5 (patch) | |
| tree | 245ba7ccbd6564e844bd7a6baa628ed786aad15b | |
| parent | docs: update configs.md (diff) | |
| download | nvim-lspconfig-29db2cc0c4d517a1e09ceb85a3c43a4691f6ddd5.tar nvim-lspconfig-29db2cc0c4d517a1e09ceb85a3c43a4691f6ddd5.tar.gz nvim-lspconfig-29db2cc0c4d517a1e09ceb85a3c43a4691f6ddd5.tar.bz2 nvim-lspconfig-29db2cc0c4d517a1e09ceb85a3c43a4691f6ddd5.tar.lz nvim-lspconfig-29db2cc0c4d517a1e09ceb85a3c43a4691f6ddd5.tar.xz nvim-lspconfig-29db2cc0c4d517a1e09ceb85a3c43a4691f6ddd5.tar.zst nvim-lspconfig-29db2cc0c4d517a1e09ceb85a3c43a4691f6ddd5.zip | |
feat(astroJS): add vim.lsp.config support (#3738)
| -rw-r--r-- | lsp/astro.lua | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/lsp/astro.lua b/lsp/astro.lua new file mode 100644 index 00000000..c9b076cf --- /dev/null +++ b/lsp/astro.lua @@ -0,0 +1,27 @@ +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 (project_root .. '/node_modules/typescript/lib') or '' +end + +---@brief +--- +-- https://github.com/withastro/language-tools/tree/main/packages/language-server +-- +-- `astro-ls` can be installed via `npm`: +-- ```sh +-- npm install -g @astrojs/language-server +--``` + +return { + cmd = { 'astro-ls', '--stdio' }, + filetypes = { 'astro' }, + root_markers = { 'package.json', 'tsconfig.json', 'jsconfig.json', '.git' }, + init_options = { + typescript = {}, + }, + 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) + end + end, +} |
