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

Can I get completion from specific files using other modes? #936

Open
alienbogart opened this issue Dec 7, 2019 · 8 comments
Open

Can I get completion from specific files using other modes? #936

alienbogart opened this issue Dec 7, 2019 · 8 comments

Comments

@alienbogart
Copy link

First of all thank you very much for this awesome project.

Let's say I'm working on index.html using web-mode and on style. css using css-mode. If I create a class on style. css, would it be possible for it to be completed on the index.html? (setq company-dabbrev-other-buffers 't) only get completions from the same mode, and (setq company-dabbrev-other-buffers 'all) will get it from files in all modes, and that's not what I want.

Maybe there's a way to have completions by project using something projectile?

@dgutov
Copy link
Member

dgutov commented Dec 8, 2019

This sounds similar to #709, which is unresolved.

But you could around-advice company-dabbrev-code to bind major-mode to a different value depending on the context inside the file. That would require some coding.

@alienbogart
Copy link
Author

That would require some coding

Okay. I'm not really a programmer yet (I wish I could study Lisp, but right now I can only use Emacs to learn other languages...), so that's a bit complicated for me at the moment. But, if you can give a bit more details on how to achieve that, I'm great at recognizing patterns and following instructions.

Thanks, @dgutov!

@dgutov
Copy link
Member

dgutov commented Dec 9, 2019

Around-advice is done with advice-add.

Temporary value binding is done with let.

As for how to figure out the exact language context at point... that would require some digging. Maybe html-mode has some function, though.

@rileyrg
Copy link

rileyrg commented Dec 30, 2019

Just a little "beep" here. Any advances? I had hoped company-lsp would work in an mhtml mode buffer but i doesn't despite html-ls chugging away in lsp-mode for mhtml.

@dgutov
Copy link
Member

dgutov commented Dec 30, 2019

@rileyrg If lsp-html is working fine in mhtml, how could company-lsp not work?

If it's the case, please report that to https://github.com/tigersoldier/company-lsp/issues

@rileyrg
Copy link

rileyrg commented Dec 30, 2019

Maybe I'm doing something wrong? Before I raise any issues maybe you could cast your eye here. I'm calling lsp mode for mhtml buffers (triggered for my .html.twig file just fine). company-diag shows that only company-dabbrev is providing completions and that comes after company-lsp. I have required lsp-html but it's unclear to me just how I should configure to actually modify or direct company-lsp further. As you can see here lsp is connected to htlm-ls

Screenshot from 2019-12-30 23-08-53

company-backends: (company-lsp company-capf company-files company-web-html
(company-dabbrev-code company-gtags company-keywords)
company-dabbrev)

Used backend: company-dabbrev
Major mode: mhtml-mode
Prefix: ""
Completions:
"2018"
"TODO"
"from"

https://github.com/rileyrg/Emacs-Customisations/blob/master/lisp/emacs-config.org

@dgutov
Copy link
Member

dgutov commented Dec 31, 2019

mxhtml? 😕

In any case, the answer is "I don't know". lsp-html and company-lsp are maintained by roughly the same people, so your best bet is to ask them.

@rileyrg
Copy link

rileyrg commented Dec 31, 2019

Apologies. mhtml.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants