This repository was archived by the owner on Feb 28, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtsgo.lua
More file actions
37 lines (34 loc) · 1.43 KB
/
Copy pathtsgo.lua
File metadata and controls
37 lines (34 loc) · 1.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
---@type vim.lsp.Config
return {
cmd = function(dispatchers, config)
local cmd = 'tsgo'
local local_cmd = (config or {}).root_dir and config.root_dir .. '/node_modules/.bin/tsgo'
if local_cmd and vim.fn.executable(local_cmd) == 1 then cmd = local_cmd end
return vim.lsp.rpc.start({ cmd, '--lsp', '--stdio' }, dispatchers)
end,
filetypes = {
'javascript',
'javascriptreact',
'typescript',
'typescriptreact',
},
root_dir = function(bufnr, on_dir)
-- The project root is where the LSP can be started from
-- As stated in the documentation above, this LSP supports monorepos and simple projects.
-- We select then from the project root, which is identified by the presence of a package
-- manager lock file.
local root_markers =
{ 'package-lock.json', 'yarn.lock', 'pnpm-lock.yaml', 'bun.lockb', 'bun.lock' }
-- Give the root markers equal priority by wrapping them in a table
root_markers = { root_markers, { '.git' } }
-- exclude deno
if vim.fs.root(bufnr, { 'deno.json', 'deno.jsonc', 'deno.lock' }) then return end
-- We fallback to the current working directory if no project root is found
local project_root = vim.fs.root(bufnr, root_markers) or vim.fn.getcwd()
on_dir(project_root)
end,
on_init = function(client)
client.server_capabilities.documentFormattingProvider = false
client.server_capabilities.documentRangeFormattingProvider = false
end,
}