Adamson Vispo
Adamson Vispo

Reputation: 31

How to setup compilerOptions during tsserver.setup({})?

Hi I've been trying to setup my nvim lsp tsserver compilerOptions during initialization of my lsp but failed. Current docs does not specifically have the compilerOptions in their examples.

I tried to load the tsconfig.json located at my home dir. I was able to do so but now my lsp root_dir is located at my home dir and forcing the root_dir to my project folder now seems like ignoring my global tsconfig because it not has fewer autocompletion. I can't store the tsconfig in each of my projects because I'm working on a team.

here is my current setup

lsp.lua

lspconfig.ts_ls.setup({
  root_dir = function (fname)
    local root = util.root_pattern('.git')(fname)
    if root == vim.env.HOME then
      return vim.fn.getcwd()
    end

    return root
  end,
  init_options = {
    tsconfig = 'my/home/dir/tsconfig.json', -- now seems like it's ignored
    plugins = {},
  },
})

tsconfig.json

{
  "compilerOptions": {
    "baseUrl": "./",
    "moduleResolution": "bundler",
    "allowJs": true,
  }
}

Hoping someone can guide me ways to figured this out. Thanks

Upvotes: 3

Views: 18

Answers (0)

Related Questions