1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-02-03 19:10:06 +08:00
SpaceVim/bundle/nvim-lspconfig-0.1.4/lua/lspconfig/server_configurations/astro.lua

51 lines
1.4 KiB
Lua
Raw Normal View History

2023-03-29 11:59:27 +08:00
local util = require 'lspconfig.util'
local bin_name = 'astro-ls'
local cmd = { bin_name, '--stdio' }
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 = [[
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
```
]],
default_config = {
root_dir = [[root_pattern("package.json", "tsconfig.json", "jsconfig.json", ".git")]],
},
},
}