Neovim for Beginners — LSP (Part 2)

Enhance our coding experience using LSP.

alpha2phi

--

Neovim for Beginners — LSP

From the previous article, we now have a very basic LSP setup. Let’s continue to enhance the configuration.

This article is part of the Neovim for Beginners series.

The Neovim configuration files can be found in this repository.

Table of Content

· LSP Basics
LSP Methods
LSP Handlers
· Configure LSP Handlers
Default Behaviors
Configure LSP Handlers
· Configure Lua for Neovim
· Status Line
· Document Highlight
· Signature Help without Plugin
· nvim-cmp
Signature Help
Icons for Completion Menu
· LSP Plugins
· References

LSP Basics

Neovim acts as a client to the LSP servers and sends requests and receives responses or notifications from the servers.

The LSP request or response handlers are implemented as Lua functions (:h lsp-handler).

The vim.lsp.handlers (:h vim.lsp.handlers) table defines default handlers used when creating a new client.

Type :lua print(vim.inspect(vim.tbl_keys(vim.lsp.handlers)))and we can see the LSP method names for the LSP handlers. vim.lsp.handlers is a global table that contains the default mapping of lsp-method names to lsp-handlers.

LSP Methods

Methods (:h lsp-method) are the names of requests and notifications as defined by the LSP specification.

callHierarchy/incomingCalls
callHierarchy/outgoingCalls
textDocument/codeAction
textDocument/completion
textDocument/declaration*
textDocument/definition
textDocument/documentHighlight
textDocument/documentSymbol
textDocument/formatting
textDocument/hover
textDocument/implementation*
textDocument/publishDiagnostics
textDocument/rangeFormatting
textDocument/references
textDocument/rename
textDocument/signatureHelp…

--

--

alpha2phi

Software engineer, Data Science and ML practitioner.