Can I use swank-js to complete node.js APIs in js2-mode?
Asked Answered
C

2

7

I use swank-js in js2-mode in emacs. Can I use it to complete node.js build-in or third-party APIs such as fs.readFile, fs.writeFile, express.use, async.forEach etc. in js2-mode ? If yes, what would be the best setup for it ?

Any help is appreciated :)

Cheka answered 8/12, 2012 at 14:30 Comment(0)
C
5

swank-js support auto completion. I used it for a while with auto-complete mode and ac-slime. Here's my setup:

(eval-after-load 'auto-complete
  '(progn
     (add-to-list 'ac-modes 'slime-repl-mode)
     (add-to-list 'ac-modes 'js2-mode)
     (add-to-list 'ac-modes 'js-mode)
     (add-hook 'slime-mode-hook 'set-up-slime-ac)
     (add-hook 'slime-repl-mode-hook 'set-up-slime-ac)))

(eval-after-load 'slime
  '(progn
     (setq slime-protocol-version 'ignore
           slime-net-coding-system 'utf-8-unix
           slime-complete-symbol*-fancy t
           slime-complete-symbol-function 'slime-fuzzy-complete-symbol)
     (slime-setup '(slime-repl slime-js))))

I'm not sure about 3rd party API but I was able to auto complete my own defined modules.

Edit: Apparently it can auto complete anything require-able. If you connect to web remote, it can even complete DOM API.

swank-js

Canister answered 9/12, 2012 at 3:40 Comment(2)
Have you been able to complete module names, or also function names inside them?Daggna
Thanks for updating the answer. I've already know that works well in the repl. But I eval the blocks in a js source file much more than using the repl. I mean: can it complete APIs in js files (as ac-sources or whatever)?Cheka
N
0

@Ispinfx Maybe you can try the ac-js2-mode https://github.com/ScottyB/ac-js2 this mode can make auto-complete in the js files.

Nat answered 20/2, 2013 at 6:0 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.