how to custom the root dir config
I want typescript tools not to attach to the buffer where the denols is active. I have declared my deno search and made the custom root_dir in opts, but typescript-tools still attach to my buffer. Am I on the right track to configure this?
return {
opts = {
root_dir = function(fname)
-- NOTE: https://github.com/pmizio/typescript-tools.nvim/blob/master/lua/typescript-tools/init.lua
local util = require "lspconfig.util"
local deno = require("plugins.lsp.settings.denols").root_dir(fname) -- Dont mind this here
if deno ~= "" then
return -- THIS, HOW TO?
end
local root_dir = util.root_pattern "tsconfig.json"(fname)
or util.root_pattern("package.json", "jsconfig.json", ".git")(fname)
local node_modules_index = root_dir and root_dir:find("node_modules", 1, true)
if node_modules_index and node_modules_index > 0 then
root_dir = root_dir:sub(1, node_modules_index - 2)
end
return root_dir
end,
}
}
I'm having the exact same issue.
I've tried using a function as you have, giving the value to root_dir directly, setting it explicitly to nil... typescript-tools will always activate for typescript etc. files regardless.
Maybe this is a 0.11 compatibility issue?
I gave up using typescripttools and moved to vtsls 🫥
Also having this issue and had to stop using typescript tools! Would love to see this get fixed.
Also having this issue and had to stop using typescript tools! Would love to see this get fixed.
I think we should wait for tsgo
See if this works as it does look like it does the trick for me:
local ts_tools = require("typescript-tools")
ts_tools.setup({
single_file_support = false,
root_dir = function(fname)
if lspconfig_util.root_pattern("deno.json", "deno.jsonc")(fname) then
return nil
end
return lspconfig_util.root_pattern("package.json", "tsconfig.json")(fname)
end,
})