DEV Community

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

Posted on Edited on

How to add new TypeScript 7 Language server to Neovim

Microsoft has released the stable version of their new TypeScript compiler written in golang which they claim 10x faster than the previous TypeScript based implimentation. While I can't speak for 10x claim, it is definitely magnitudes faster in my old crappy dual core dev laptop. So you might feel some benifits based on the complexitity of your codebase and machine's performance.

Alright, enough chitchat, let's see how to get this wired into our sweat neovim editor. And btw this guide is for neovim's native LSP client. If you still use nvim-lspconfig I highly recommend you to move all your lsp configs to the native API.

Prerequisites

  1. Neovim v11+
  2. npm (or your package manager of choice)

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.
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)