goerr-nvim
goerr-nvim copied to clipboard
fold go `if err != nil` and show other lines
goerr-nvim
The plugin folds Go's if err != nil and shows other lines like in Goland, it greatly reduces code length and doesn't affect readability.
The plugin converts popular words that is used in handling errors to just Greek letters.
Also it folds errors on buffer enter, and remove dots in folding.
Before:
After:
Installation
- Install it with your favorite plugin manager
- Make sure you set
syntax onandset foldmethod=syntax, since this plugin closes folds based on syntax.- Or you can use any other foldmethod that creates folds on error handling, e.g. treesitter's one;
- If you know the better way of creating and closing folds, make me know in an issue or PR :)
- The plugin uses
softtabstopsetting under the cover. If the indentation level isn't right, you can adjust the setting accordingly or contribute to the plugin development :) - If you don't use folds much and just want this plugin to work, you can set
foldnestmaxandfoldlevelsettings to high numbers (e.g. 10 and 9 respectively).- It enables folding, but all your folds would be open by default (except
if err != nilones)
- It enables folding, but all your folds would be open by default (except
Features
- Auto close
if err != nilblocks of code, show inner lines; - Remove distracted dots via
'fillchars'; - Truncate long inner lines;
- Change
returnto 1 Unicode symbol (arrows); - Change
logandloggerto lambda; - Change
can't,cannot,can notto justc'; - Change
fmtanderrorsto phi and epsilon respectively.
TODO
- Add parameters for this stuff;
- Handle long
if's.