Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to properly setup company-tern in JS mode? #4903

Closed
domi91c opened this issue Jan 31, 2016 · 6 comments
Closed

How to properly setup company-tern in JS mode? #4903

domi91c opened this issue Jan 31, 2016 · 6 comments
Labels
- Forum - Auto-completion JavaScript stale marked as a stale issue/pr (usually by a bot)

Comments

@domi91c
Copy link

domi91c commented Jan 31, 2016

When in a Javascript file, hitting tab to complete uses basic auto-completion instead of company-tern. I can run the company-tern command by typing it in which gives me the company-tern completion popup, but I'm not sure how to activate it by hitting tab. I haven't customized the JS layer at all.

@izahn
Copy link
Contributor

izahn commented Feb 1, 2016

Getting tab to complete or indent depending on context is a mess in emacs. Some things depend on the value of tab-always-indent, other package implement their own hacks, and in general getting this to work consistently is very difficult.

My advice (and what I do) is to forget about fighting over tab key completion, and just bind something else to company-complete. In my .spacemacs I have this:

  (with-eval-after-load "company"
    (global-set-key (kbd "S-SPC") 'company-complete))

so I can complete with Shift-Space.

Ultimately I think there should be a conventional key binding for this in spacemacs, but in the meantime just pick one you like.

You may also wish to set tab-always-indent to nil or t, since you have another key for completion.

This is all just my opinion, there are other options including trying to beat the tab key into submission. I've tried that in the past and concluded it wasn't worth it, but your mileage may vary.

@domi91c
Copy link
Author

domi91c commented Feb 1, 2016

Alright, I'll give that a try. I'm assuming having the company popup appear automatically would also be difficult?

@izahn
Copy link
Contributor

izahn commented Feb 1, 2016

The company popup should appear automatically after typing at least company-minimum-prefix-length characters. If that doesn't happen than either something is wrong or you've configured it not to complete automatically. Do you get company completion in other buffers (e.g. emacs lisp buffers)?

@domi91c
Copy link
Author

domi91c commented Feb 1, 2016

Yah, it works perfectly in Lisp, even using tab. Actually, I was just trying again with Javascript and company works with tab, but it opens the company-tern mini-buffer instead of automatically opening the autocomplete popup while I'm typing. Not sure why tab wasn't working before. So now I just need to figure out why the mini buffer is triggered on tab instead of the autocomplete popup.

@andrew-kennedy
Copy link

Any progress here? I'm trying to figure out how to use company tern myself and am stuck.

@github-actions
Copy link

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Please let us know if this issue is still valid!

@github-actions github-actions bot added the stale marked as a stale issue/pr (usually by a bot) label Feb 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
- Forum - Auto-completion JavaScript stale marked as a stale issue/pr (usually by a bot)
Projects
None yet
Development

No branches or pull requests

4 participants