Created
March 12, 2025 16:12
-
-
Save kr-alt/24aaf4bad50d603c3c6a270502e57209 to your computer and use it in GitHub Desktop.
lsp config to test out the new tsgo LSP
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local function start_tsgo() | |
local root_files = { "tsconfig.json", "jsconfig.json", "package.json", ".git" } | |
local paths = vim.fs.find(root_files, { stop = vim.env.HOME }) | |
local root_dir = vim.fs.dirname(paths[1]) | |
if root_dir == nil then | |
-- root directory was not found | |
return | |
end | |
vim.lsp.start({ | |
name = "tsgo", | |
cmd = { "/path/to/tsgo", "lsp", "--stdio" }, | |
root_dir = root_dir, | |
-- init_options = { hostInfo = "neovim" }, -- not implemented yet | |
}) | |
end | |
vim.api.nvim_create_autocmd("FileType", { | |
pattern = { "javascript", "javascriptreact", "javascript.jsx", "typescript", "typescriptreact", "typescript.tsx" }, | |
desc = "Start tsgo LSP", | |
callback = start_tsgo, | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
tysm!