olrtg / nvim-rename-state

Rename the getter and the setter of a state hook in react/solidjs at the same time.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

nvim-rename-state

Rename the getter and a setter of a state hook in react/solidjs at the same time using :RenameState.

// Initial code
const [anchorEl, setAnchorEl] = useState(null)

// After renaming with `:RenameState` or `:RenameState anchor`
const [anchor, setAnchor] = useState(null)

Features

  • Leverages Treesitter (requires neovim >= 0.5.0).
  • Supports Javascript and Typescript files.
  • Supports React and Solid state hooks.

Installation

lazy.nvim

{ "olrtg/nvim-rename-state" }

packer.nvim

use { "olrtg/nvim-rename-state" }

vim-plug

Plug 'olrtg/nvim-rename-state'

Usage

Put your cursor in the row of the defined useState or createSignal hook and use:

:RenameState

Or if you want to pass the new name for the hook in advance:

:RenameState <new_name>

Contributing

All contributions are welcomed! Just open a pull request or an issue.

About

Rename the getter and the setter of a state hook in react/solidjs at the same time.

License:MIT License


Languages

Language:Lua 100.0%