Skip to content

Neovim plugin to automatically add or remove Go function return parenthesis while you are typing

License

Notifications You must be signed in to change notification settings

Jay-Madden/auto-fix-return.nvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🧰 auto-fix-return.nvim

Adds or removes parenthesis from Golang return defintions as you type.

Supports

  • Single returns
  • Multi returns
  • Named returns
  • Functions
  • Methods
  • Lambdas
  • Interfaces

and hopefully all combinations of the above. If you find a bug please report it as an issue.

Preview

high_res_final

Note

The plugin attempts to add parenthesis as you type. Which means that its mostly working off of invalid parse trees. This is very nice to use but makes it difficult to cover all edgecases from a parsing standpoint, as different error states of the tree can be matched incorectly. If you find an error state that is not covered please report it as an issue.

You can run the command AutoFixReturnDisable to turn off the autocommnd and make whatever changes you need to that line. Then reenable the plugin with AutoFixReturnEnable and the line will not be edited again unless you touch the declaration again.

Installation

Important

Requires the Go treesitter parser to be installed TSInstall go if using nvim-treesitter.

Lazy

return {
  "Jay-Madden/auto-fix-return.nvim",
  config = function()
    require("auto-fix-return").setup({})
  end
}

⚙️ Configuration

Defaults

require("auto-fix-return").setup({
  enable_autocmds = true, -- Enable or disable the autofix on type behvaior
})

Commands

AutoFixReturn: Format the function definition under the cursor, adding or removing parenthesis as needed

AutoFixReturnEnable: Enable the autofix on type autocommands

AutoFixReturnDisable: Disable the autofix on type autocommands

About

Neovim plugin to automatically add or remove Go function return parenthesis while you are typing

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages