Skip to content

Latest commit

 

History

History
65 lines (49 loc) · 1.98 KB

README.md

File metadata and controls

65 lines (49 loc) · 1.98 KB

code-refactor.nvim

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

Screen.Recording.2024-01-29.at.9.56.03.mov

🔒 Requirements

📦 Installation

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

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

🚀 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.

⚙️ 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.

require("code-refactor").setup({
    available_actions = {
        javascript = {
            file_types = {},
        },
    },
})

✨ 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