Microsoft has released the stable version of their new TypeScript compiler written golang that is 10x faster than the previous TypeScript based implimentation on benchmarks.
This also comes with the Language server built in and we can plug it into Neovim right now!
In this article, I will be showing how to plug it to the Neovim's built in LSP client.
Prerequisites
- Neovim v11 or above
- npm (or any other node package manager)
Steps
- Download and install the new typescript version from npm registry.
npm i -g typescript
- Check version. It should show v7.0.0 or above. (the new executable uses the name
tsc)
tsc --version
- Add the server to the
init.luafile or define it in a new file and import toinit.lua.
-- define the LSP server
vim.lsp.config['tsc'] = {
cmd = {'tsc', '--lsp', '--stdio'},
filetypes = {'javascript', 'javascriptreact', 'typescript', 'typescriptreact'},
root_markers = {'package.json', 'tsconfig.json', '.git'},
}
-- enable
vim.lsp.enable('tsc')
- Open up a TypeScript/JavaScript project and test.
- Upon exploring a huge codebase, you should feel the snapiness in goto definitions, references and completions popup.
Enjoy writing TypeScript!


Top comments (0)