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:
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.
Our first file inside configs folder is plugs.vim. This file is just a list of all plugins we have installed in environment.
This is the file where we put all the Neovim basic and some plugins defaults configurations.
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.
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.
Finally, we have our mappings file, where we put all key mappings to improve our experience inside Neovim.
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 definition||gd|
Go to definition example and back:
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:
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.