Emacs LSP and DAP

alpha2phi
5 min readFeb 27, 2021

LSP and DAP for Python, Golang, Rust and Typescript/Javascript.

Emacs LSP and DAP

Overview

In previous article I developed a configuration for Emacs beginner. In this article let’s continue to set up LSP (Language Server Protocol) and DAP (Debug Adapter Protocol). Particularly the languages that I will focus on are Python, Golang, Rust and Typescript.

Language Servers Installation

I am going to use the same language servers in my earlier article on setting up Neovim LSP using Lua.

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 to a folder, and add the folder to environment PATH.

Typescript

For Typescript, let’s install typescript-language-server.

$ npm install -g typescript-language-server$ npm install -g typescript

lsp-mode and dap-mode

I am going to use lsp-mode and dap-mode for Emacs.

Create a file called lang.el under the elisp folder with the following content.

Besides lsp-mode, I installed dap-mode, dap-node, dap-gdb-lldb, and dap-go in this package.

In init.el, require this package.

(require 'lang)   ;; base extensions

Python LSP and DAP

--

--

alpha2phi

Software engineer, Data Science and ML practitioner.