All Projects β†’ tomarrell β†’ vim-npr

tomarrell / vim-npr

Licence: GPL-3.0 License
Sensible 'gf' for Node Path Relative JS module resolution per project 🐿

Programming Languages

Vim Script
2826 projects

Projects that are alternatives of or similar to vim-npr

laravel-any
πŸ“ Laravel collection macro that determine if `any` item from the collection passes the given truth test.
Stars: ✭ 38 (+100%)
Mutual labels:  package
angular-loading-button
Loading button directive for AngularJS
Stars: ✭ 27 (+42.11%)
Mutual labels:  package
ferryd
Fast, safe and reliable transit for the delivery of software updates to users.
Stars: ✭ 43 (+126.32%)
Mutual labels:  package
create-npm-package
Creates an npm package boilerplate that you don't have to write again πŸ“¦
Stars: ✭ 21 (+10.53%)
Mutual labels:  package
ContactEtc
Laraval package to instantly add a customisable contact form to your site.
Stars: ✭ 21 (+10.53%)
Mutual labels:  package
dynamic-utils
Utility functions to perform dynamic operations on Android.
Stars: ✭ 86 (+352.63%)
Mutual labels:  package
Ragnarok
Virus Package ( For Educational Purposes )
Stars: ✭ 23 (+21.05%)
Mutual labels:  package
repogen
Easy-to-use signed APT repository generator with a web-based package browser.
Stars: ✭ 34 (+78.95%)
Mutual labels:  package
caption-core
Caption Core acts as an abstraction layer for Caption’s core functionality.
Stars: ✭ 33 (+73.68%)
Mutual labels:  package
BETS
Package to obtain and analyze thousands of Brazilian economic time series
Stars: ✭ 34 (+78.95%)
Mutual labels:  package
atom-package-sync
Synchronize your atom packages and settings easily
Stars: ✭ 22 (+15.79%)
Mutual labels:  package
goto
Goto - The Good Way to Program
Stars: ✭ 14 (-26.32%)
Mutual labels:  goto
manjaro-sway
🚧 manjaro linux with wayland πŸ–Ό, sway 🌴 and a lot of β™₯
Stars: ✭ 326 (+1615.79%)
Mutual labels:  package
menu button
Flutter plugin to display a popup menu button widget with handsome design and easy to use.
Stars: ✭ 64 (+236.84%)
Mutual labels:  package
laravel-blog
Laravel Blog package
Stars: ✭ 116 (+510.53%)
Mutual labels:  package
grammarly
Grammarly API interface
Stars: ✭ 87 (+357.89%)
Mutual labels:  package
fusen
Inflate your package from a simple flat Rmd
Stars: ✭ 99 (+421.05%)
Mutual labels:  package
video-downloader
Video Downloader for Facebook.
Stars: ✭ 63 (+231.58%)
Mutual labels:  package
svelte-credit-card
A svelte component to render a credit card πŸ’³
Stars: ✭ 30 (+57.89%)
Mutual labels:  package
laravel-meta
a package for working with models meta in laravel
Stars: ✭ 78 (+310.53%)
Mutual labels:  package

Vim-NPR πŸ”ŽπŸ“‘

A plugin for sensible Node Path Relative module resolution in Javascript on a project-by-project basis. This will allow Vim to resolve modules using gf, even when they're using Node Path Relative, or custom resolution directories in your webpack configuration.

Installation

Supports Vim-Plug, Vundle, and likely any other vim plugin manager that uses a similar format.

Add the following line to your .vimrc file:

Plug 'tomarrell/vim-npr'

Configuration

Simply add a resolve key to your project's package.json file with an array of directories you would like the file to potentially be resolved relative to. The plugin will find this key and resolve your files as per the directories listed.

If a package.json file can be found, however no resolve key is present, the plugin will default to the following directories for resolution:

{
  // ...
  "resolve": ["src", "lib", "test", "public", "node_modules"],
  // ...
}

If these directories don't exist, or the plugin cannot find the file under the cursor, the plugin will simply fail to resolve the file.

By default, the plugin will resolve the package.json by traversing up 5 directories, this number is configurable using the g:vim_npr_max_levels variable.

The plugin will be active whenever you enter a buffer with the extension .js, .jsx, .css or .coffee.

Finally, if the exact file name with extension is not provided in the path, the plugin will attempt a list of defaults. These are appended to the path for each match attempt. The default list is:

let g:vim_npr_file_names = ["", ".js", "/index.js"]

Note that "" (empty string) and ".js" (plain .js extension) are important to resolve exact files and paths simply omitting the extension respectively.

Usage

Works with ES, AMD, and CommonJS module definitions.

An example of the possible module resolution types are below, provided correct configuration. {NPR} represents a configured or default relative directory, which can be specified in your package.json as the resolve array:

import Header from 'Header';            // will resolve {NPR}/Header/index.js
import Header from 'Header/index.js';   // will resolve {NPR}/Header/index.js
import Header from 'Header/style.css';  // will resolve {NPR}/Header/style.css
import Button from 'Header/Button';     // will resolve {NPR}/Header/Button/index.js

import Header from '~/components/Header';          // will resolve {NPR}/components/Header/index.js
import Header from '~/components/Header/index.js'; // will resolve {NPR}/components/Header/index.js

import React from 'react';              // will resolve {NPR}/react/index.js
import { connect } from 'react-redux';  // will resolve {NPR}/react-redux/lib/

It even works throughout your CSS.

@import 'variables.css';  /* will resolve {NPR}/variables.css */
@import 'Home/style.css'; /* will resolve {NPR}/Home/style.css */

It functions the same as the traditional vim gf command, without getting in the way of your other language file resolvers.

License

Licensed under the GNU GPL v3.0 license. Please see the extended license terms here.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].