Skip to content

Commit

Permalink
fix(mdx_analyzer): pass typescript lib as option
Browse files Browse the repository at this point in the history
Uses a similar setup as astro or volar
  • Loading branch information
Machine-Maker committed Jan 19, 2024
1 parent 7eed8b2 commit ae6aaa7
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions lua/lspconfig/server_configurations/mdx_analyzer.lua
Original file line number Diff line number Diff line change
@@ -1,12 +1,25 @@
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' },
filetypes = { 'markdown.mdx' },
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 = {
Expand Down

0 comments on commit ae6aaa7

Please sign in to comment.