mooz / js2-mode

Improved JavaScript editing mode for GNU Emacs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Not getting syntax highlight for several ECMA functions & some keychords don't work

lljr opened this issue · comments

The ones I'm looking at are defined in js2-ecma-global-funcs line 6648.

also in js2-ecma-function-props, none of those are getting highlighted as well

Some commands in the key mode map don't work as well like js2-mode-toggle-warnings-and-errors. (Says C-c C-w is undefined).

Config

(setq js-indent-level 2
      js2-highlight-level 3
      js-chain-indent t)

(add-hook 'js-mode-hook 'js2-minor-mode)
(add-to-list 'interpreter-mode-alist '("node" . js2-mode)) ; hook it in for shell scripts running via node.js

js2-minor-mode

That's the thing: the minor mode is for having the parser available (e.g. for js2-refactor), but it doesn't add any syntax highlighting over what js-mode does (it sets js2-highlight-level to 0 locally). Perhaps it would be helpful to apply at least some of the highlightings over js-mode, but that would require some consideration.

I can switch over to it as a major mode. Nbd. However, now linting is disabled? I think that for me that is okay since I may end up using Flycheck + ESlint.

Btw, I'm working on an Emberjs project. I'm testing out imenu and it only works on the current file. Could there be a way to list all the functions written down in a group of files inside a directory?
for example:

app/components/
├── start-rating.hbs
├── start-rating.js

and

app/routes/
├── bands
│   ├── band
│   │   └── songs.js
│   ├── band.js
│   └── band.js~
├── bands.js
└── bands.js~

Last, js-eval does not work for me. I get an error: js--js-enter-repl: Symbol’s function definition is void: inferior-moz-process
EDIT: I forgot to mention I tested js-eval just with a console.log('hello'); statement

I can switch over to it as a major mode. Nbd. However, now linting is disabled?

With js2-mode linting should work. It's one of its upsides: syntax check without using external programs.

Btw, I'm working on an Emberjs project. I'm testing out imenu and it only works on the current file. Could there be a way to list all the functions written down in a group of files inside a directory?

That what imenu does: shows tags for the current file. But you can try https://github.com/vspinu/imenu-anywhere.

Or go old-school and use etags. You generate a TAGS file, then use it with standard key bindings.

Last, js-eval does not work for me. I get an error: js--js-enter-repl: Symbol’s function definition is void: inferior-moz-process

It was only supposed to work with MozRepl: Emacs doesn't have a JavaScript runtime built-in. Unfortunately, MozRepl is discontinued anyway, so while what you're seeing looks like a bug, there's no good way to fix it now. And it's a js-mode's problem, not in js2-mode.

syntax check without using external programs.

That's what brought me to js2-mode. It's useful but today I find myself using frameworks, some of which may introduce new syntax like decorators. When the linter gets to a line that uses the decorator syntax it will think it's broken (probably because the linter has not been specified to recognize decorator's syntax).

go old-school

I don't mind that. Have been looking into using ggtags with GNU Global. Apparently it supports Javascript. I used to use company-tern tool before with ternjs, but it's emacs company-mode maintainer archived his repo and no longer updates it.

js-mode's problem, not in js2-mode.

I realized after I noticed it was js-eval and not js2-eval.

When the linter gets to a line that uses the decorator syntax it will think it's broken (probably because the linter has not been specified to recognize decorator's syntax).

Yes, usually someone needs to teach the parser to recognize the new syntax. And JS always has something new.

Have been looking into using ggtags with GNU Global. Apparently it supports Javascript.

It's an option for sure. Another would be to try either of our LSP clients. I have little personal experience with them, so no particular recommendations.