This is an extension to my first vim-ide post. But this part focuses on setup for intellisense features that increase coding performance, like scanning for errors, autocompletion, refractoring and more.
install languages to the system
Install the languages/tools your vim will need to support. If your language is constantly updated, your distribution may not have the latest package, for example ubuntu generally has verions of nodejs and npm that aren’t compatible with each other.
curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash - sudo apt-get install -y nodejs
- python interpreter, pip3 package manager
sudo apt install -y python3 pip3
- texlive cross platofrm latex system, latexmk compiler
sudo apt install texlive-latex-extra sudo apt install latexmk
linters and fixers
Linters are programs that scan a file for errors and style problems in your code, they then present these errors to you.
Fixers detect style problems and maybe some errors, and then they automatically fix them after a certain condition, for example every time you save the file.
Using multiple linter/fixer plugins and configuring them can be difficult, so its better to use a large all in one solution. Ale is a plugin that lints asyncronously, so it will run scans every time you change vim mode.
Linter and fixer programs generally apply to one language, so we will need at least one per language.
install the linters and fixers
Eslint can serve as a linter and a fixer.
sudo npm install eslint -g
Pyflakes just lints for errors, and the python software foundations black autoformats code to confirm to official style rules.
pip3 install pyflakes pip3 install black
Depending for what tex package you downloaded, some linters may aready be installed.
sudo apt install chktex sudo apt install lacheck
if you cant find a linter or fixer, you can check ales linter scripts, all supported linters with be there https://github.com/dense-analysis/ale/tree/master/ale_linters
then tell ale to use them in vimrc
language servers (LSPs)
Microsofts language server protocol uses a server to provide intellisense to the editor (client), since the functionality instant build stright into the editor, it can easyily be implemented across many editors. The main lsp functionality is autocomplete, but most provide many more features: go to definition, refractor, lint, …
Vim needs a plugin to act as a client for the language server. Coc.nvim is one that gets activate development, and has many language servers from vs-code extensions.
Coc.nvim has lsps to support most languages and most LSPs can be installed without any configuration as an extension via
- :CocInstall coc-tsserver
- :CocInstall coc-python
- :CocInstall coc-pyright
If you cant find a working/compatible linter/fixer/lsp for a language or need more functionality, then you get an individual plugin for that language.
For example vimtex for latex.
- live preview latex documents from a variety of pdf viewers
- key bindings to naviage documents quicker
- better syntax highlighting
May also need additional packages, vimtex requires latexmk to compile docs.