Neovim LSP commands, LSP Saga configuration and functionalities

Take a deep look at what LSP and LSP Saga could offer to improve our development process

Anchieta Júnior's photo
Anchieta Júnior
·Aug 7, 2021·

3 min read

Neovim LSP commands, LSP Saga configuration and functionalities

This is a continuation of this other post

Since my last post about my Neovim for Ruby and Rails development with LSP, i have updated some of my configurations, then i decided to publish here all updates that i've been setting up. Take a look how coolest it is now!

Content of this post

Splitting settings into multiple files

In my last post i decided to write only the init.vim file (this is the main neovim configuration file) containing all configurations only to be more understandable. But now we are going to split all configurations into multiple files to be more maintainable (one file only for plugins, another file only for key mappings and etc).

Our file structure will look something like this:

  • init.vim
    • configs/
      • compe.vim
      • defaults.vim
      • lsp.vim
      • mappings.vim
      • plugs.vim
      • saga.vim


Our init.vim file now basically import other files. In the end of the file we have some auto commands like open NERDTree when Neovim is executed.

Link to Github file


Our first file inside configs folder is plugs.vim. This file is just a list of all plugins we have installed in environment.

Link to Github file


This is the file where we put all the Neovim basic and some plugins defaults configurations.

Link to Github file


This is the file where we put all the LSP (Language Server Protocol) custom configurations. Here i have made some updates since my last post, removed mappings i don't use for example.

Link to Github file


Here we drop some nvim-compe plugin configurations. I decided to put it into a separated file because like lsp.vim file here we have Lua code and not VimScript, so to maintain i feel more comfortable this way.

Just to remember, nvim-compe is a plugin that works together with lsp and provide a lot of auto-completions options.

Link to Github file


Finally, we have our mappings file, where we put all key mappings to improve our experience inside Neovim.

Link to Github file

LSP commands

One thing i didn't do at all in my last post was talk about some amazing options that LSP provide us, like go to definition of a class or method, show all recurrences of a class name inside our code base and other things, so if you want to try it here are some default LSP mappings you can find inside the configs/lsp.vim file.

Go to definitiongd
Formattingspace f

Go to definition example and back:


LSP Saga

Well, LSP Saga showed me things i didn't think i could do inside Neovim like preview one method or class in a popup without have to open a new file and i have to say, this is awesome! Other thing i can do is hide all the LSP messages like Rubocop messages and show it with a key mapping when i need.

To install it, you just have to add to your plugs.vim file:

Plug 'glepnir/lspsaga.nvim'

The settings are splitted into saga.vim and mappings.vim files. Checkout these examples:

Show rubocop messages

I mapped the show_line_diagnostics functionality with: ;l (comma and l)


Show a class preview

I mapped the preview_definition functionality with: ;; (comma twice)


That's all! Be happy and use Neovim.

Share this