Neovim config for frontend development

In this article I will explain how did I set up my neovim to work with React and Vue projects. It should also work for Vim 8+

TL:DR My complete neovim config can be found here:

After learning Vim basics I found that can't leave without it and started using plugins which provided such ability in my IDE-s - first was Idea, then vscode. Also I have tried multiple times to migrate to original Vim editor but without success. Okay, vim recognizes syntax of javascript/typescript files, with some plugins it can also recognize .vue and jsx syntax. But there is no autosuggestions and linting and of course any intelligent refactoring/go_to_definition possibilities. Some additional plugins could add it but I couldn't manage it to work fully as alternative to VsCode.

Fortunately last time Language Server Protocol (LSP) appeared. Such protocol allows to use language-specific feature independently to editor. Thanks to LSP I could now manage to setup Neovim to work as frontend IDE.

How it looks in my machine

So, main plugin is a coc.nvim. Now thanks to this plugin it is possible to use different Language servers plus some extra plugins which are not available in vim directly. Also you probably should install some syntax-related vim plugins and some other that makes coding simplier.

My list of plugins. I'm using neovim, but believe all of them also work in Vim 8 and newer. It is a copy-paste from my config which is using vim-plug plugin manager:

Plug 'ctrlpvim/ctrlp.vim'                                   " File navigation, similar to Ctrl+p hotkey in vscode
Plug 'scrooloose/nerdtree'                                  " side bar with file tree view
Plug 'Xuyuanp/nerdtree-git-plugin'                          " show git status in file tree view
Plug 'itchyny/lightline.vim'                                " better look of vim status line
Plug 'ap/vim-buftabline'                                    " buffers to tabline, shows buffers as tabs on top of window
Plug 'tomasr/molokai'                                       " sublime theme
Plug 'dunstontc/vim-vscode-theme'                           " vscode theme

Plug 'neoclide/coc.nvim', {'do': { -> coc#util#install()}}  " Completion as in vscode

Plug 'janko-m/vim-test'                                     " Tests runner (Jest)

Plug 'scrooloose/nerdcommenter'                             " NERD commenter. Quickly comment lines
Plug 'editorconfig/editorconfig-vim'                        " Editorconfig file support. see
Plug 'herringtondarkholme/yats.vim'                         " Typescript syntax
Plug 'posva/vim-vue'                                        " Vue JS syntax highlighting
Plug 'maxmellon/vim-jsx-pretty'                             " JSX syntax
Plug 'prettier/vim-prettier'                                " Prettier - automatically format file according to rules/editorconfig
Plug 'othree/xml.vim'                                       " to work with HTML/XML tags, see
Plug 'othree/html5.vim'                                     " html5
Plug 'cakebaker/scss-syntax.vim'                            " SCSS syntax

Plug 'iamcco/markdown-preview.nvim', { 'do': { -> mkdp#util#install() }} " Markdown preview

Plug 'tpope/vim-fugitive'                                   " Git wrapper, execute git commant from vim
Plug 'airblade/vim-gitgutter'                               " A Vim plugin which shows a git diff in the 'gutter' (sign column)

And while installed coc it is possible to add extensions (language servers) into it. Simply use :CocInstall extension-name. Here are my extensions i've installed:

coc-tsserver        " javascript/typescript server - completion, refactor etc
coc-tslint-plugin   " javascript/tyescript linting
coc-snippets        " provides snippets engine as in vscode (see my previous article)
coc-highlight       " provides basic highlight of words selected
coc-emmet           " emmet! works as in vscode
coc-marketplace     " marketplace to simplify search and installation of coc extensions
coc-html            " html - completion, refactor etc
coc-json            " json - completion, refactor etc
coc-vetur           " famous vscode plugin - completion,refactor,linting and much more
coc-css             " css

Also, you will probably need to set up these plugins. For information check my config below and check documentation for each plugin.

Here is my neovim config. Save it as $HOME_DIR/.config/nvim/init.vim for Neovim or $HOME_DIR/.vimrc for Vim (linux paths, for windows check neovim documentation).

Currently I am trying to completely migrate from vscode to neovim. Here is list of known problems I've discovered and their possible solutions:

Problem Solution
There is no debugger available in vim/neovim I couldn't find any working debugger plugin for javascript/typescript yet. As a temporary solution is to use debugger; statement in code and debug in browser. Also there are framework-specific devtools available as browser extensions. Check and
How to search for text in project files? It is possible different ways. At the moment I'm using :vimgrep /text-to-search/g * command. Also it can be configured to exclude some directories, find in specific files by mask etc. Most probably should add some hotkey for it. For more information check


And that's it! Happy coding :)