Git Product home page Git Product logo

vim-import-js's People

Contributors

kosmaks avatar lencioni avatar mutewinter avatar razdvapoka avatar ryo33 avatar slaweet avatar tdooner avatar trotzig avatar williamboman avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

vim-import-js's Issues

Getting random failures in neovim

I tried to add the line :call ch_logfile('channel_log.txt', 'w') in neovim as line 1 of my init.vim file and it gave me an error that said...

line    1:
E117: Unknown function: ch_logfile

As for the error that ImportJS is giving me, Ive just closed out of vim and it went away, but it has been popping up regularly so I will post it here when it happens next

vim-Import-JS can update wrong buffer if import-js is slow

When ImportJS is slow (e.g. I didn't have watchman installed when I created this issue and I had a large mono-repo with a lot of dependencies), vim-import-js can behave badly in 2 ways:

  1. It can update the buffer AFTER other changes have been made to it (somewhat acceptable, I can imagine it's harder to know if the buffer has updated)
  2. It can update another buffer if a user has moved to this offer buffer by the time the results from import-js come back (which is really weird)

Works only once in macvim

Hey, awesome plugin! Works great in vim, but <Leader>i works only once in MacVim. On the second attempt to run this command an error is thrown.

screen shot 2017-07-18 at 5 42 24 am

Add message for folks on old versions of Vim

This plugin requires a relatively recent version of Vim. We should note this in the readme and provide some sort of intelligible warning for folks who try using this plugin on older versions.

Error detected while processing function importjs#Init:

Hello, thanks for the awesome plugin.

I have two osx machines, almost same neovim settings.

Working okay
NVIM 1.4.0
plugin manager: Vundle

Not working
NVIM 1.5.0
plugin manager: vim-plug

I am not sure this is about plugin manager or NVIM version.

below is from the one does not work.
Can you suggest a way to troubleshoot?

Thanks

 ~/.config/nvim   master ●  vi
Error detected while processing function importjs#Init:
line    3:
E117: Unknown function: job_start
E15: Invalid expression: job_start(['importjsd', 'start', '--parent-pid', getpid()], {'exit_cb': 'importjs#JobExit',})
line    7:
E121: Undefined variable: s:job
E116: Invalid arguments for function job_getchannel(s:job)
E15: Invalid expression: job_getchannel(s:job)
Press ENTER or type command to continue
 ~/.config/nvim   master ●  vi -v
NVIM 0.1.5
Build type: RelWithDebInfo
Compilation: /usr/local/Homebrew/Library/Homebrew/shims/super/clang -Wconversion -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -DDISABLE_LOG -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wvla -fstack-protector-strong -fdiagnostics-color=auto -DINCLUDE_GENERATED_DECLARATIONS -DHAVE_CONFIG_H -I/tmp/neovim-20161007-26331-14gl0zw/neovim-0.1.5/build/config -I/tmp/neovim-20161007-26331-14gl0zw/neovim-0.1.5/src -I/tmp/neovim-20161007-26331-14gl0zw/neovim-0.1.5/deps-build/usr/include -I/tmp/neovim-20161007-26331-14gl0zw/neovim-0.1.5/deps-build/usr/include -I/tmp/neovim-20161007-26331-14gl0zw/neovim-0.1.5/deps-build/usr/include -I/tmp/neovim-20161007-26331-14gl0zw/neovim-0.1.5/deps-build/usr/include -I/tmp/neovim-20161007-26331-14gl0zw/neovim-0.1.5/deps-build/usr/include -I/tmp/neovim-20161007-26331-14gl0zw/neovim-0.1.5/deps-build/usr/include -I/usr/local/opt/gettext/include -I/usr/include -I/usr/include -I/tmp/neovim-20161007-26331-14gl0zw/neovim-0.1.5/build/src/nvim/auto -I/tmp/neovim-20161007-26331-14gl0zw/neovim-0.1.5/build/include
Compiled by [email protected]

Optional features included (+) or not (-): +acl   +iconv    +jemalloc +tui
For differences from Vim, see :help vim-differences

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/usr/local/Cellar/neovim/0.1.5/share/nvim"

 ~/.config/nvim   master ● 

E387: Match is on current line

I'm using Neovim v0.2.2 on Mac OS High Sierra. Whenever I run :ImportJSWord for Sequelize I get the following error:

Error detected while processing function <SNR>40_JobHandler[2]..importjs#JoinNeovimOutput[11]..importjs#HandleJoinedNeovimInput
[2]..importjs#ParseResult[28]..importjs#Resolve:
line   11:
E387: Match is on current line

Which corresponds to the following line in the plugin code:

execute ":ijump " . wordWithBoundaries

After I press <CR>, the expected prompt is shown:

ImportJS: Select module to import for `Sequelize`:
1: import Sequelize from 'sequelize';
2: import { Sequelize } from 'sequelize';
Type number and <Enter> or click with mouse (empty cancels):

If I remove the problematic line, the plugin still seems to continue to work (both ImportJSFix and ImportJSWord work). I'm not an expert in vimscript so I'm wondering what's the reason for that line? Can it be removed?

Thanks!

Add a clear warning if importjs command does not work

For example, if the importjs command cannot be found, the error is pretty cryptic. Also, if an error happens, like

Error: Failed to load plugin import: Cannot find module 'eslint-plugin-import'

the failure mode is pretty bad.

Integrate goto functionality with tags

From @lencioni on January 31, 2016 18:40

This is a bit of an unfinished thought, but the goto functionality feels very similar to tags. (See :help tags) It occurred to me that perhaps we could integrate with tags somehow, but I'm not sure exactly what that would look like just yet. Some ideas come to mind:

  • Maybe there is a way to hook into the tags resolver built into vim. If this is possible, we should be able to call the goto feature at this time.
  • Perhaps a command could be added to parse a project and generate a tags file. This could be appended to the tags file generated by a tool like exuberant ctags. This fees pretty messy though, since the format of that file depends partly on the tool that created it and partly on the configuration given to that tool.
  • Exuberant ctags is able to be extended with new parsers. Perhaps we could figure out a way to integrate import-js in that way, but it seems a bit out of scope.

This is pretty low priority, so I'm adding the help wanted tag.

Copied from original issue: Galooshi/import-js#179

does not work well with NVM

I guess instances installed in different node versions collide with dependencies.

image

Error detected while processing function <SNR>245_JobHandler:
line    7:
import-js error: module.js:471     throw err;     ^  Error: Cannot find module '/
usr/local/lib/node_modules/import-js/node_modules/sqlite3/lib/binding/node-v48-da
rwin-x64/node_sqlite3.node'     at Function.Module._resolveFilename (module.js:46
9:15)     at Function.Module._load (module.js:417:25)     at Module.require (modu
le.js:497:17)     at require (internal/module.js:20:19)     at Object.<anonymous>
 (/usr/local/lib/node_modules/import-js/node_modules/sqlite3/lib/sqlite3.js:4:15)
     at Module._compile (module.js:570:32)     at Object.Module._extensions..js (
module.js:579:10)     at Module.load (module.js:487:32)     at tryModuleLoad (mod
ule.js:446:12)     at Function.Module._load (module.js:438:3)

reproducing it

  1. install nvm
  2. install node 6 and 8
  3. install import-js in both
  4. try to use one of them

importjs process not running when outside of react directory

this is probably a simple fix but I cannot see what is going on.

I installed the vim-import-js plugin and added a line in my vimrc to run it on the save of javascript files.

au BufWritePre *.js :ImportJSFix

I then noticed that if I was outside of the react directory that I was working in, and I tried to edit a normal file with vim, I would get an error that says

importjs process not running

how is it finding or running the process from inside of the react project but not from the outside (I have installed importjs globally)

Prompt can have bad interactions with some other plugins, like Ale

I am using Ale for async linting, which can update Vim in a way that messes up import JS when presented with the list of unresolved imports. This leaves Vim in a confusing state. Here's a demonstration:

import-js-ale

I imagine there are other plugins that might have similar interactions.

I wonder if we could fix this by using a nicer prompt. It would be great to use a command-t style prompt where one option is highlighted and I can press enter to select it and use arrow keys to move up and down the list. This would pave the way to add fuzzy text filtering as well, which could be helpful when presented with a lot of options.

importjs process not running

Getting this error, tried re-installing importjs globally with no change:

==== start log session ====
  5.288031 : ERROR: Error detected while processing function importjs#Goto[5]..importjs#ExecCommand:
  5.288230 : ERROR: line   18:
  5.288273 : ERROR: importjs process not running
  5.288338 : looking for messages on channels

doesn't detect undeclared React components

I was hoping that if I had something like in JSX of a file in a React app, this would find the file in my project that defines it and add an import for it. Any chance that will be implemented soon?

import-js can't find inspect from Node's util module

I have set env to contain node in the .importjs.js configuration file.

But if I have console.log(inspect(obj)) in my code, import-js won't find inspect and I have to add it manually. It should instead add const { inspect } = require('util').

Using vim and node 8.11

// .import-js.js
module.exports = {
  declarationKeyword: 'const',
  environments: ['node', 'jest', 'es2017'],
  importDevDependencies: true,
  sortImports: true,
};
No JS module to import for `inspect`

Importjs process starts up unnecessarily / lazy load

When opening vim, even without any file arguments, a node process for importjs starts up, as can be seen in htop.

This should not happen if there are no JavaScript/typescript/jsx/tsx files open as it is a waste of memory. I suspect that they shouldn't be hard to change this.

It might also be worth considering making the init call lazy loaded, i.e. only call it when the user first calls and import JS command.

Unresolved import error in neovim

I am getting an error that popped up for me recently, I do not think it is related to #17 because I have tried disabling the ale plugin and the symptom still persists.

ch_logfile does not work for neovim so here is the logfile when using verbose=9...

ImportJS: Select module to import for `PropTypes`:
1: import PropTypes from 'prop-types';
2: import { PropTypes } from 'react';
Type number and <Enter> or click with mouse (empty cancels): 
Executing CursorMoved Auto commands for "*"
autocommand call ale#cursor#EchoCursorWarningWithDelay()

Executing CursorMoved Auto commands for "*"
autocommand call s:Highlight_Matching_Pair()

Executing CursorMoved Auto commands for "*"
autocommand call <sid>sync_active_winnr()

autocommand call s:wordcount_update()

Executing TextChanged Auto commands for "*"
autocommand call ale#Queue(g:ale_lint_delay)

Executing TextChanged Auto commands for "*"
autocommand call s:Highlight_Matching_Pair()


--- Signs ---
Signs for App.js:
    line=1  id=1000000  name=ALEDummySign
    line=1  id=1000001  name=ALEErrorSign
    line=1  id=1000002  name=ALEErrorSign
    line=1  id=1000003  name=ALEErrorSign
    line=1  id=1000004  name=ALEErrorSign
    line=1  id=1000005  name=ALEErrorSign
    line=1  id=1000006  name=ALEErrorSign
    line=1  id=1000007  name=ALEErrorSign
    line=1  id=1000008  name=ALEErrorSign
    line=1  id=1000009  name=ALEErrorSign
    line=1  id=1000010  name=ALEErrorSign
    line=1  id=1000011  name=ALEErrorSign
    line=1  id=1000012  name=ALEErrorSign
    line=1  id=1000013  name=ALEErrorSign
    line=1  id=1000014  name=ALEErrorSign
    line=1  id=1000015  name=ALEErrorSign

No matching autocommands

ImportJS: Select module to import for `PropTypes`:
1: import PropTypes from 'prop-types';
2: import { PropTypes } from 'react';
Type number and <Enter> or click with mouse (empty cancels): 1
                                                              Error detected while processing function <SNR>53_JobHandler[2]..importjs#JoinNeovimOutput[11]..importjs#HandleJoinedNeovimInput[2]..importjs#ParseResult[28]..importjs#Resolve:
line   33:
E716: Key not present in Dictionary: data
Error detected while processing function <SNR>53_JobHandler[2]..importjs#JoinNeovimOutput[11]..importjs#HandleJoinedNeovimInput[2]..importjs#ParseResult[28]..importjs#Resolve:
line   33:
E15: Invalid expression: alternatives[selection - 1].data

I can see that vim-import-js finds the possible imports, but then it doesn't recognize the number when I enter the index of the one that I want to import. I am not sure where to go from here.

Prompt gets garbled when fixing and need to pick for multiple imports

From @lencioni on January 18, 2016 23:18

If I am working on a file that needs a lot of new modules fixed, and I run fix imports on it for the first time, and multiple modules have multiple matches, the prompt gets a bit garbled. Here's an example:

ImportJS: Imported `react` (0.0s)
ImportJS: Pick JS module to import for 'Foo':
1: ../../foo/foo
2: ./Foo
Type number and <Enter> or click with mouse (empty cancels): 2ImportJS: Pick JS module to import for 'Bar':
1: ../../apps/bar
2: ../../foo/bar

Notice the line: Type number and <Enter> or click with mouse (empty cancels): 2ImportJS: Pick JS module to import for 'Bar':.

Copied from original issue: Galooshi/import-js#137

Add support for import of styles.css

The plugin works as expected except for css files.
I import my css in react and use them like this:
<div className={styles.wrapper}>

The css file is in the same directory as the .js file.

Would it be possible to add this kind of support?

Typo in command mapping?

Hi! I see that you have mapping for <Leader> to :ImportJSWord, but README says it should be <Leader>j. Is this a typo?

Thanks for the plugin btw!

Allow to exclude some paths from import lookup

I want to import ActionBar component and it is only once in my source code, but the tool finds it also in coverage reports. I need a way to exclude the coverage folder.

ImportJS: Select module to import for `ActionBar`:
1: import ActionBar from '../actionBar';
2: import ActionBar from '../../../coverage/Chrome 59.0.3071 (Mac OS X 10.12.6)/components/actionBar';
3: import ActionBar from '../../../coverage/Chrome 60.0.3112 (Mac OS X 10.12.6)/src/components/actionBar';
4: import ActionBar from '../../../coverage/HeadlessChrome 0.0.0 (Mac OS X 10.12.6)/src/components/actionBar';
Type number a

Fails with Invalid expression: json_decode(resultString)

ImportJS in VIM fails with

Error detected while processing function importjs#Word[1]..importjs#ExecCommand:
line   10:
E117: Unknown function: json_decode
E15: Invalid expression: json_decode(resultString)
line   17:
E121: Undefined variable: result
E15: Invalid expression: (result.fileContent != fileContent)
line   21:
E121: Undefined variable: result
E116: Invalid arguments for function len(result.messages))
E15: Invalid expression: (len(result.messages))

I am running vim 7.4

Error at the beginning on :ImportJSGoto (and probalby others) command

Sometimes I got an error after trying to jump to another file in my react project. Usually (as I remember) it happens at the beginning, but as some time goes on everything works just fine. There is some logging:

 14.583151 on 0: Blocking NL read, timeout: 2000 msec
 14.583159 on 0: Waiting for up to 2000 msec
 14.713704 RECV on 0(out): 'ImportJS (v4.0.2) DAEMON active. Logs will go to: /tmp/importjs.log
'
 14.713723 on 0: Returning 67 bytes
 14.713889 : ERROR: Error detected while processing function importjs#Goto[5]..importjs#ExecCommand[26]..importjs#ParseResult:
 14.714096 : ERROR: line    1:
 14.714133 : ERROR: E474: Invalid argument
 14.714170 : ERROR: line    3:
 14.714187 : ERROR: E715: Dictionary required
 14.714223 : ERROR: line    8:
 14.714240 : ERROR: E715: Dictionary required
 14.714275 : ERROR: line   13:
 14.714291 : ERROR: E715: Dictionary required
 14.714629 : ERROR: line   24:
 14.714653 : ERROR: E715: Dictionary required
 14.714691 : ERROR: line   27:
 14.714707 : ERROR: E715: Dictionary required

I have import-js 4.0.2 installed globally.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.