galooshi / emacs-import-js Goto Github PK
View Code? Open in Web Editor NEWEmacs plugin for ImportJS
License: MIT License
Emacs plugin for ImportJS
License: MIT License
I install import-js layer in my .spacemacs.
dotspacemacs-configuration-layers
'(
import-js
...
)
install the import-js:
$ npm install -g import-js
also the exec-path:
Its value is
(... "/Users/xxxx/.nvs/node/16.15.0/x64/bin")
when I exec SPC m i i
, the error occurs:
Process import-js not running
In both pre- and post [email protected], the Emacs plugin doesn't support the case of multiple import matches due to name collisions. The newer version uses the 'add' command to specify which match to use. The emacs plugin would need to implement a method to select one of multiple possible matches from the 'word' command.
after I upgrade import-js to latest version (3.1.0), import-js always get "JSON readtable error".
Is there a way to trigger import js after yasnippet completion?
I know I can use a custom hook or even yasnippet's 'expand-env' function but what import-js function should I use?
import-js-import will import only on-point expressions,
I would need to use something that takes part of the snippet text as argument
Launching [M-x] run-import-js
will give me the following error:
error in process filter: JSON readtable error: 105
I can manually launch the daemon and importjs fix <file>
successfully.
Let me know if I can provide any help debugging the issue.
I wrote a next-js page which displays a Example
component.
pages/index.tsx
import Head from 'next/head'
export default function Home() {
return (
<>
<Head>
<title>Create Next App</title>
</Head>
<main>
<Example />
</main>
</>
)
}
And I put the components/Example.tsx
like this.
export default function Example() {
return (
<div>
<p>hello </p>
</div>
)
}
Then I want to import the Example component, and I run the M-x import-js-import
at the index.ts buffer.
But I can't import the Example function.
Is it supported typescript?
Hi, thanks for this awesome time saving tool!
I configured import-js-fix
to be run via after-save-hook
. I also have configured a hook that saves the buffer when I am switching to another buffer/window. Sometimes, when I switch to another window, the "fixed code" (of the buffer I was switching away from) is written to the newly selected window buffer.
I will see whether I find time to investigate this week. I suppose a save-excursion
and a buffer switch before updating fixed imports would suffice. Maybe you have a quick idea.
Peace & Love
Already installed the npm package.
Changing this function fix:
(after! import-js
;;;###autoload
(defun run-import-js ()
"Start the import-js daemon"
(interactive)
(kill-import-js)
(let ((process-connection-type nil))
(setq import-js-process (start-process "import-js" nil "importjs" "start" (format "--parent-pid=%s" (emacs-pid))))
(set-process-filter import-js-process 'import-js-handle-data))))
Hey,
I noticed that the IPC is broken when json-encoding-pretty-print
is set, because import-js
reads input via readline
and there'll be linebreaks in the json when pretty-printing.
Here's a PR that fixes the issue: #22
This is the melpa description of the package I just installed:
Status: Available from melpa -- Install
Archive: melpa
Version: 20220215.1948
Commit: d2bbb53f96395415f9f01de4fa88d82c1f59ba63
Summary: Import Javascript dependencies
Requires: grizzl-0.1.0, emacs-24
Homepage: http://github.com/Galooshi/emacs-import-js/
Keywords: javascript
Maintainer: Kevin Kehl <[email protected]>
Author: Kevin Kehl <[email protected]>
Quick start:
run-import-js
Bind the following commands:
import-js-import
import-js-goto
For a detailed introduction see:
http://github.com/Galooshi/emacs-import-js/blob/master/README.md
Then M-x run-import-js
returns on the message buffer:
apply: Searching for program: No such file or directory, importjsd
I do have importjs installed globally with npm:
>> importjs --version
5.0.0
And from inside emacs I can actually run it with e-shell.
I noticed the step 2 on README points to itself, so I can't see if I am missing some config.
Any help?
Thanks!
I use helm-find-files
(a default package in Spacemacs) to browse directories. It lists all files in the current buffer file's directory.
When I run import-js-import
and then execute helm-find-files
it now starts me in my import-js-project-root
instead of the current buffer file's directory. Regardless of plugins, mutating global state in a plugin like this seems like a scary idea.
According to the emacs documentation, call-process
uses the default-directory
variable as its working directory. We should be able to wrap the call-process
call in a let
and change it just for the scope of this call (similar to this SO post).
I'd like to send a PR with this change, but I'm still a bit of an Emacs newb and not sure how to test package changes on my local filesystem. Posting here in case someone else can get to it before I can figure all that out.
The current version in MELPA Stable is 0.6.0, so we need a higher version tag.
In order to prevent spinning up a new node.js runtime on every import (which can take some time, depending on the system), use the importjsd
daemon instead of the CLI tool importjs
.
More than 2 months ago import-js has been updated to v5.0 and
importjsd does not exist anymore.
when will you update?
I use importjs in terminal, it works fine:
chris2@W530-chris:~/Desktop/uhs$
importjs word NormalButton src/containers/PatientDetail/FollowUpRecordView/HomeFollowupDetailView/index.js
{"messages":["Imported `../../../../components/NormalButton (main: index.js)`"],"fileContent":"/**\n * Created by isaac on 16/4/29.\n............
but when I use importjs in my emacs it warn: cd: No such directory found via CDPATH environment variable
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.