DEV Community

Cover image for How to add new TypeScript 7 Language server to Neovim
Chamal Mallawaarachchi
Chamal Mallawaarachchi

Posted on

How to add new TypeScript 7 Language server to Neovim

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

  1. Neovim v11 or above
  2. npm (or any other node package manager)

Steps

  1. Download and install the new typescript version from npm registry.
npm i -g typescript
Enter fullscreen mode Exit fullscreen mode
  1. Check version. It should show v7.0.0 or above. (the new executable uses the name tsc)
tsc --version
Enter fullscreen mode Exit fullscreen mode
  1. Add the server to the init.lua file or define it in a new file and import to init.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')
Enter fullscreen mode Exit fullscreen mode
  1. Open up a TypeScript/JavaScript project and test.

Hover Action
Neovim Hover action using new typescript v7

Completions
Neovim autocompleteions with blinkcmp and typescript v7

  1. Upon exploring a huge codebase, you should feel the snapiness in goto definitions, references and completions popup.

Enjoy writing TypeScript!

Top comments (0)