summaryrefslogtreecommitdiff
path: root/.config/nvim/lsp/mdx_analyzer.lua
blob: 0f13bc3d56aaca5f1ab2ff1f80a92d4ddfa92eac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
-- https://github.com/mdx-js/mdx-analyzer

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

return {
    cmd = { 'mdx-language-server', '--stdio' },
    filetypes = { 'mdx' },
    root_markers = { 'package.json' },
    settings = {},
    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,
}