@@ -142,6 +142,28 @@ opts = {
142142 return true
143143 end ,
144144 vtsls = function (_ , opts )
145+ if vim .lsp .config .denols and vim .lsp .config .vtsls then
146+ --- @param server string
147+ local resolve = function (server )
148+ local markers , root_dir = vim .lsp .config [server ].root_markers , vim .lsp .config [server ].root_dir
149+ vim .lsp .config (server , {
150+ root_dir = function (bufnr , on_dir )
151+ local is_deno = vim .fs .root (bufnr , { " deno.json" , " deno.jsonc" }) ~= nil
152+ if is_deno == (server == " denols" ) then
153+ if root_dir then
154+ return root_dir (bufnr , on_dir )
155+ elseif type (markers ) == " table" then
156+ local root = vim .fs .root (bufnr , markers )
157+ return root and on_dir (root )
158+ end
159+ end
160+ end ,
161+ })
162+ end
163+ resolve (" denols" )
164+ resolve (" vtsls" )
165+ end
166+
145167 LazyVim .lsp .on_attach (function (client , buffer )
146168 client .commands [" _typescript.moveToFileRefactoring" ] = function (command , ctx )
147169 --- @type string , string , lsp.Range
@@ -323,6 +345,28 @@ opts = {
323345 return true
324346 end ,
325347 vtsls = function (_ , opts )
348+ if vim .lsp .config .denols and vim .lsp .config .vtsls then
349+ --- @param server string
350+ local resolve = function (server )
351+ local markers , root_dir = vim .lsp .config [server ].root_markers , vim .lsp .config [server ].root_dir
352+ vim .lsp .config (server , {
353+ root_dir = function (bufnr , on_dir )
354+ local is_deno = vim .fs .root (bufnr , { " deno.json" , " deno.jsonc" }) ~= nil
355+ if is_deno == (server == " denols" ) then
356+ if root_dir then
357+ return root_dir (bufnr , on_dir )
358+ elseif type (markers ) == " table" then
359+ local root = vim .fs .root (bufnr , markers )
360+ return root and on_dir (root )
361+ end
362+ end
363+ end ,
364+ })
365+ end
366+ resolve (" denols" )
367+ resolve (" vtsls" )
368+ end
369+
326370 LazyVim .lsp .on_attach (function (client , buffer )
327371 client .commands [" _typescript.moveToFileRefactoring" ] = function (command , ctx )
328372 --- @type string , string , lsp.Range
0 commit comments