Feeling inspired by watching togglebit's Rust/Vim setup and having some spare time due to my summer vacation I started re-investigating my Vim setup. For my setup I was looking for the following features/areas to improve:
- Git integration
- Debugging projects in vim
- Language server features, completion, go to definition, etc.
- Searching through files/git repository/file system
For Git integration I already used vim-futigive and vim-gitgutter. These still serve their purposes well, combined with a few handy keyboard shortcuts. So for git integration nothing really has changed.
In the past I used vim-vdebug in combination with PHP's xdebug, while learning Rust I was curious to see if having debugger integration would help me learn and understand Rust better. Following togglebit's blog post on debugging Rust in vim, I've mostly copied his rust.vim setup.
This provides an easy way to launch a debugger instance using
:call RunDebugger() which spawns a
rust-gdb session in one window and another window for terminal output. Using termdebug's
:Break a breakpoint can be set and other Gdb related actions. In my
rust.vim I've set up the following keybinding to start a debug session
nmap <F5> :call RunDebugger()<CR>.
What I was really missing in the my editor was language features such as, go to definition, auto completion and displaying function information. I've tried vim-lsp and coc.vim but both seemed to require more effort and required me to switch away from ale.vim. Luckily it turns out ale.vim already supports language servers. For rust this worked out of the box, however I can recommend using
rust-anaylzer. For Python
python-language-server used to be the default but is now replaced with
typescript which provides the
tsserver language server.
The following keybindings where added to my
nmap gd :ALEGoToDefinition<CR> nmap gr :ALEFindReferences<CR> nmap gR :ALERename<CR> nmap K :ALEHover<CR>
Further more adding
rust.vim and togglebit's
rust.vim adds the option to configure some useful keybindings for running
:Cargo run in a new Vim terminal pane.
One of my biggest annoyances was finding things easily from vim, which was mostly solved by installing fzf.vim and the
fzf package. With
:Files the files in the current working directory are shown and can be filtered, for files tracked in git
:GFiles. To find things in files I've added a keybinding for
:Ag and installed
the_Silver_searcher, the fzf plugin offers more functionality such as listing and searching through ultisnip snippets.
I'm fairly content with my new Vim setup, slowly becoming more efficient, building up muscle memory and started writing some vimscript for more automation. For example to
bump pkgrel's easily in PKGBUILD's. There are some other plugins I have installed such as
vim-surround and hardly use as I'm not that familiar with them yet. Lastly, I've started reading the help files of my plugins and already discovered some nice new tips / features.