Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/jdrupal-dev/code-refactor.nvim
- Owner: jdrupal-dev
- License: mit
- Created: 2024-01-18T14:56:59.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-03-14T15:36:39.000Z (11 months ago)
- Last Synced: 2024-03-14T17:06:51.994Z (11 months ago)
- Topics: code-action, neovim-plugin, refactoring
- Language: Lua
- Homepage:
- Size: 13.7 KB
- Stars: 18
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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 | |