Note
This plugin is experimental and currently only supports Flutter/Dart code.
If you'd like it to work for a specific language, feel free to submit an issue.
As a Flutter developer, handling deeply nested class and function definitions is a regular experience. Regardless of language/framework, needing to convert an auto-generated fat arrow function into a standard, return statement function notation is a drag. Manually finding where these definitions end to insert that semicolon and closing brace always proves annoying and tiring.
Check out the gif above for a clear illustration of what this does!
Install like any other vim plugin. Here are examples using some popular package managers:
lazy.nvim
{
'rafaelcolladojr/arrowhead.nvim',
dependencies = { 'nvim-treesitter' }
}
packer.nvim
use {
'rafaelcolladojr/arrowhead.nvim',
requires = { {'nvim-treesitter/nvim-treesitter'} }
}
vim-plug
Plug 'nvim-treesitter/nvim-treesitter'
Plug 'rafaelcolladojr/arrowhead.nvim'
To swap the notation of the function/method under the cursor simply run:
:lua require('arrowhead').swap_notation(true)
In this case, we're setting the ignore_comments
parameter to true
. (This defaults to false
)
You can set it to a normal mode binding like:
vim.keymap.set('n', '<leader>ah', ':lua R("arrowhead").swap_notation()<CR>')
- Basic conversion logic
- Support functions as arguments
- Ignore comments (#1)
- Popular language coverage