neovim + TypeScript = ⚡️
March 15, 2023This is a rave about neovim. I've been using (neo)vim for nearly a decade now. Investing my time into learning how to operate it was the best decision I've made, as far as tech skills goes.
Why? #
- It enables me to take full advantage of my "flow moments" by helping me work faster
- It's distraction-free. There are no shiny buttons or panels like in IDEs, and nothing that takes my focus away
- It runs in the Terminal, my native environment for everything. I don't have to choose between my editor or Terminal or jankily embed a Terminal into my editor
- It lightens the load on my wrists since I never have to use the mouse when editing or writing (which is a huge life-saver when working on laptops)
- It's lightweight - the CPU/memory footprint is 5-10x lesser than an IDE or other editors (except Sublime Text) on average
Here's what I can do: #
...without touching the mouse at all :-)
Auto-complete #
CTRL + N
lets me to cycle through completions, with a small window displaying
type information and docstrings.
Navigate quickly #
I can open up a project tree with <leader>;
(powered by
NERDTree),
and do a filename fuzzy-search using <leader>t
(powered by fzf.vim).
Fuzzy-search all files in directory #
<leader>s
brings up a ripgrep window
for fuzzy-searching text across the entire directory.
Browse to type signatures #
SHIFT + K
gives me a popup with the type signature and docstring. It's a
general function for displaying information about the current symbol. It can
use the LSP or even man
pages, so I can SHIFT + K
almost anything to
bring up its documentation when available.
Browsing to the full type definition (.d.ts
) is triggered by gd
keybind,
which calls the jumpDefinition
function of
coc.nvim.
Autofix #
<leader>i
sorts and organize imports. It calls the LSP's (tsserver
in this
case) organizeImport
function via
coc.nvim.
<leader>f
formats the file using the same method via a configured formatter
on the LSP (I'm using Prettier).
My set-up #
- NERDTree for directory navigation
- coc.nvim as an extension host for language servers
- neoclide/coc-tsserver on top of
coc.nvim
for TypeScript - fzf.vim for fuzzy search (filename and contents) powered by ripgrep
You can find all of my neovim config here.
Like what you see? #
Give (neo)vim a whirl! Once you get past the learning curve and start building muscle memory, you'll wonder why you didn't start using it earlier.