LSP and DAP for Python, Golang, Rust, and Typescript/Javascript.
Overview
In my previous article, I walked through with you how to convert existing .vimrc
to a Lua-based configuration and set up LSP for Lua.
In this article let’s add LSP and DAP support. Particularly I will focus on Python, Typescript, Golang, and Rust.
Installation of Language Servers
Let’s get started by installing the language server.
If you are using coc.nvim, normally the language server is installed automatically for you. For Neovim LSP, there are available plugins to automate this process. Here I will go through the manual installation steps.
Python
For Python, let’s install pyright.
$ npm install -g pyright
Golang
For Golang, let’s install gopls.
$ GO111MODULE=on go get golang.org/x/tools/gopls@latest
Rust
For Rust, let’s use rust_analyzer. The easiest way to install is to download the binary, copy it to a folder, and add the folder to the environment PATH.
Typescript
For Typescript, let’s install typescript-language-server.
$ npm install -g typescript-language-server
Configure LSP
Plugins
Under plugins.lua,
install nvim-lspconfig and completion-nvim.
-- LSP and completion
use { 'neovim/nvim-lspconfig' }
use { 'nvim-lua/completion-nvim' }
Run :luafile %
and then :PackerInstall
.
Configuration
The current configuration already supports Lua LSP. I am going to leverage the existing configuration.
- Under
lua
folder, create a new folder calledlang
.