Skip to content

Easily switch between fat arrow and standard function notation

License

Notifications You must be signed in to change notification settings

rafaelcolladojr/arrowhead.nvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 

Repository files navigation

🏹 arrowhead


Easily switch between fat arrow and standard function notation.



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.


Why does this exist?

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!


Installation

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'

Usage

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)


Example

You can set it to a normal mode binding like:

vim.keymap.set('n', '<leader>ah', ':lua R("arrowhead").swap_notation()<CR>')

TODO

  • Basic conversion logic
  • Support functions as arguments
  • Ignore comments (#1)
  • Popular language coverage

About

Easily switch between fat arrow and standard function notation

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages