Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/Balagha/nvim-ReFact
https://github.com/Balagha/nvim-ReFact
Last synced: 14 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/Balagha/nvim-ReFact
- Owner: Balagha
- License: apache-2.0
- Created: 2021-04-16T15:24:39.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-03-29T16:55:45.000Z (over 1 year ago)
- Last Synced: 2024-08-01T19:50:00.680Z (3 months ago)
- Language: Lua
- Size: 16.6 KB
- Stars: 2
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# nvim-ReFact
>A [Neovim](https://neovim.io/) plugin Inspired by VSCode extension [Glean](https://github.com/wix/vscode-glean)
The plugin provides refactoring tools for your React codebase. Extract JSX into a new component, wrapping with Hooks and more!
## Highlights
- Allows extracting JSX into new component
- Allows wrapping JSX with conditional## Requirements
- [nvim-treesitter](https://github.com/nvim-treesitter/nvim-treesitter) including a parser for your language
- [nui.nvim](https://github.com/MunifTanjim/nui.nvim)
## Installation
```lua
use 'Balagha/nvim-ReFact'
``````vim
Plug 'Balagha/nvim-ReFact'
```
## Extracting JSX into a new Component
treesitter-refact-react allows easy extraction of JSX into new React components (in the same or other file). Just select the JSX to extract, and it will handle all the rest:
- Generate Functional Component, such that the extracted JSX will continue to function.
- It will identify all inputs to the newly created component.
- Replace extracted JSX with newly created component, while providing it with all the props.Examples:
- `vv` to select the inner unit
- `r` to change the JSX into new React componentsgif...
### Useful mappings
```lua
vim.api.nvim_set_keymap('n', 'vv', ':lua require"nvim-ReFact".select()', {noremap=true})vim.api.nvim_set_keymap('v', 'r', ':lua require"nvim-ReFact".change()', {noremap=true})
``````vim
xnoremap vv :lua require"nvim-ReFact".select()xnoremap r :lua require"nvim-ReFact".change()
```
## How to run this project into your machine
make sure you have fulfilled the [requirements](https://github.com/tamanna190101/nvim-ReFact#requirements) and necessary [key mappings](https://github.com/tamanna190101/nvim-ReFact#useful-mappings)
```sh
# clone this repo
$ git clone https://github.com/tamanna190101/nvim-ReFact.git$ cd nvim-ReFact
# set runtime path and open lua init.lua file and example.js file for test lua implementation
$ nvim --cmd "set rtp+=./" lua/nvim-ReFact/init.lua -O example.js
```
To setup Neovim Treesitter Playground follow this [link](https://github.com/nvim-treesitter/playground).
## LicensingLicensed under the Apache License. Check the [LICENSE](LICENSE) file for details.