Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/jdrupal-dev/code-refactor.nvim

A collection of nifty neovim code actions
https://github.com/jdrupal-dev/code-refactor.nvim

code-action neovim-plugin refactoring

Last synced: 2 months ago
JSON representation

A collection of nifty neovim code actions

Awesome Lists containing this project

README

        

# code-refactor.nvim

**code-refactor.nvim** a collection of nifty code actions that do not require a LSP.

https://github.com/jdrupal-dev/code-refactor.nvim/assets/13871894/f559ed26-26a5-4011-8312-e39d31cc907e

## :lock: Requirements

- [nvim-treesitter](https://github.com/nvim-treesitter/nvim-treesitter)

## :package: Installation

Install this plugin using your favorite plugin manager, and then call
`require("code-refactor").setup()`.

### [lazy.nvim](https://github.com/folke/lazy.nvim)

```lua
{
"jdrupal-dev/code-refactor.nvim",
dependencies = { "nvim-treesitter/nvim-treesitter" },
keys = {
{ "cc", "CodeActions all", desc = "Show code-refactor.nvim (not LSP code actions)" },
},
config = function()
require("code-refactor").setup({
-- Configuration here, or leave empty to use defaults.
})
end
}
```

## :rocket: Usage

Run the `:CodeActions all` command to show a select list of available actions under the cursor.

Run `:CodeActions [x]` to run a specific code action.\
For example: `:CodeActions toggle_arrow_function_braces`.

## :gear: Configuration

The default configuration is found in `lua/code-refactor/config.lua`.\
Simply call `require("code-refactor").setup` with the desired options.

To disable code actions for any given language, simply return an empty table in `file_types`.
```lua
require("code-refactor").setup({
available_actions = {
javascript = {
file_types = {},
},
},
})
```

## :sparkles: Available actions

| Name | JavaScript | PHP |
|------------------------------|:----------:|:----------:|
| **General** | | |
| Flip ternary | yes | yes |
| Negate expression | yes | yes |
| Convert arrow function | yes | yes |
| **JavaScript** | | |
| Toggle arrow function braces | yes | |