galooshi / vim-import-js Goto Github PK
View Code? Open in Web Editor NEWVim plugin for ImportJS
License: MIT License
Vim plugin for ImportJS
License: MIT License
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
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:
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.
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 ●
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:
vim-import-js/autoload/importjs.vim
Line 123 in 96447e4
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!
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.
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:
This is pretty low priority, so I'm adding the help wanted tag.
Copied from original issue: Galooshi/import-js#179
Newer versions of Vim added some async functionality. It might be worth taking advantage of that in this plugin.
I guess instances installed in different node versions collide with dependencies.
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
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)
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:
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.
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
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?
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`
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.
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.
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
When replacing the buffer we track the cursor position and then simply move it by the number of lines that were added. If you happen to be in the imports block, this can be incorrect.
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?
From @trotzig on March 3, 2016 17:35
As suggested by @wincent in Galooshi/import-js#206
Might also want to use mappings moving forward, as those are considered a little more useful: http://whileimautomaton.net/2008/09/27022735
Copied from original issue: Galooshi/import-js#209
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!
Would be nice to have an option to not have semicolons after each import.
Not all projects use semicolons.
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
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
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.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.