diff options
| author | Jake Potrebic <jake.m.potrebic@gmail.com> | 2024-01-28 17:20:18 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-01-28 17:20:18 -0800 |
| commit | e20a85188e616be5ba6e7e22cd74153e8838fb85 (patch) | |
| tree | fb4e358f5261a99ce6adfc304f338a3d092ac46b /lua | |
| parent | docs: update server_configurations.md (diff) | |
| download | nvim-lspconfig-e20a85188e616be5ba6e7e22cd74153e8838fb85.tar nvim-lspconfig-e20a85188e616be5ba6e7e22cd74153e8838fb85.tar.gz nvim-lspconfig-e20a85188e616be5ba6e7e22cd74153e8838fb85.tar.bz2 nvim-lspconfig-e20a85188e616be5ba6e7e22cd74153e8838fb85.tar.lz nvim-lspconfig-e20a85188e616be5ba6e7e22cd74153e8838fb85.tar.xz nvim-lspconfig-e20a85188e616be5ba6e7e22cd74153e8838fb85.tar.zst nvim-lspconfig-e20a85188e616be5ba6e7e22cd74153e8838fb85.zip | |
fix(mdx_analyzer): pass typescript lib as option (#2974)
Per https://github.com/orgs/mdx-js/discussions/2427 and my own testing, mdx_analyzer needs a similar treatment as volar and astro to pass the typescript library into the lsp. Otherwise you get the error mentioned in that discussion.
Diffstat (limited to 'lua')
| -rw-r--r-- | lua/lspconfig/server_configurations/mdx_analyzer.lua | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/lua/lspconfig/server_configurations/mdx_analyzer.lua b/lua/lspconfig/server_configurations/mdx_analyzer.lua index d41ba84e..1dfbcb5a 100644 --- a/lua/lspconfig/server_configurations/mdx_analyzer.lua +++ b/lua/lspconfig/server_configurations/mdx_analyzer.lua @@ -1,5 +1,10 @@ local util = require 'lspconfig.util' +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')) or '' +end + return { default_config = { cmd = { 'mdx-language-server', '--stdio' }, @@ -7,6 +12,14 @@ return { root_dir = util.root_pattern 'package.json', single_file_support = true, settings = {}, + init_options = { + typescript = {}, + }, + on_new_config = function(new_config, new_root_dir) + if vim.tbl_get(new_config.init_options, 'typescript') and not new_config.init_options.typescript.tsdk then + new_config.init_options.typescript.tsdk = get_typescript_server_path(new_root_dir) + end + end, }, commands = {}, docs = { |
