Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/Ivo-Donchev/vim-react-goto-definition
Goto definition pluigin for React JS written in Python
https://github.com/Ivo-Donchev/vim-react-goto-definition
goto-definition javascript plugin react-js reactjs vim
Last synced: 8 days ago
JSON representation
Goto definition pluigin for React JS written in Python
- Host: GitHub
- URL: https://github.com/Ivo-Donchev/vim-react-goto-definition
- Owner: Ivo-Donchev
- Created: 2018-06-02T11:12:30.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2019-01-05T11:51:55.000Z (almost 6 years ago)
- Last Synced: 2024-10-29T23:07:38.585Z (22 days ago)
- Topics: goto-definition, javascript, plugin, react-js, reactjs, vim
- Language: Python
- Homepage:
- Size: 188 KB
- Stars: 20
- Watchers: 2
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Goto definition plugin for React JS
# Overview
A python powered vim plugin for goto defintion functionality for functions/components/constants... handling *imports* and *exports* for `Javascript` and especially `React JS`.
The implementation is entirely written in Python 3 using regular expressions.Covered import types:
- relative imports (`import Something from '../components/Something'`) - will search for any of:
- '../components/Something.jsx' or
- '../components/Something.js' or
- '../components/Something/index.js' or
- '../components/Something/index.jsx'- absolute imports (`import Page1 from 'pages/Page1'`) - will search into **src/** folder for the import:
- 'src/pages/Page1.jsx' or
- 'src/pages/Page1.js' or
- 'src/pages/Page1/index.js' or
- 'src/pages/Page1/index.jsx'- default imports (`import A from './A'` or `import {default as A} from './A'`) and non-default imports (`import {a, b as c} from 'module')`)
Covered definition types:
- `class <...>`
- `function <...>`
- `function* <...>`
- `<...> = ` - for variables, constants and arrow functionsSearching algorythm works as follows:
1. Soft scraping:
- Search in current file
- Search for import
- Search for export from another file2. Hard scraping (if soft scraping fails :( ) - searches for wanted definition over the whole project
# Installation
### Vundle
Add the following line to your `~/.vimrc` :
```
Plugin 'Ivo-Donchev/vim-react-goto-definition'
```
and run:```
:PluginInstall
```# Usage
Set you cursor on the imported function/component and type:
```
:call ReactGotoDef()
```You can also map this function call with:
```
" To map to D:
noremap D :call ReactGotoDef()
```**NOTE**: Your vim needs to support python3+ scripting. You can check this with:
```
:python3 print('ReactJS')
```