reddit / emacs
VSCode Includes Invalid/Undefined Symbols in Completion Suggestions, How Can I Make This Happen in Emacs With lsp-mode Using typescript-language-server?
_analysis230_ · 2022-09-22 13:00
PsychologicalOwl496 · 2022-09-22 13:09
This is not a symbol completion.
It's done from dictionary (whatever words you type, including comments) as indicated from the "abc" symbol.
If it was a valid identifier / symbol completion suggestion, the icon on the left would look different, like in your screenshot the example with newObjectWithModifier, the purple cube.
_analysis230_ · 2022-09-22 13:20
I did try typing "house" instead of "modifier" and that didn't show "house" as a suggestion. But, if I go up and change the first mention of the word "modifier" to "house" and then go down, code completion shows "house" as an option.
I did say in the title that I want the suggestions to show "invalid" symbols. I want this functionality however VSCode is accomplishing it is rather irrelevant to me.
LynxOfTheWastes · 2022-09-22 13:25
I think this is some sort of predictive completion bloatware that predicts what word you might want to use even if it hasn't been used yet. Could be wrong though.
_analysis230_ · 2022-09-22 13:31
I don't remember installing any such extra plugins, anyway javascript-language-server on Emacs does the same thing. I don't use it because it's been deprecated for 2 years now.
panickbr · 2022-09-22 14:45
This is called dabbrev (complete words from current buffers). Since you’re using `lsp-mode`, you’re probably using `company`, look here https://emacs.stackexchange.com/questions/15246/how-add-company-dabbrev-to-the-company-completion-popup (sorry i don’t use company but that should point you to the right way)
Otherwise look for dabbrev in whichever completion framework you’re using
big_lentil · 2022-09-22 15:14
I think you missed the explanation within the parentheses in the comment that you're replying
You need to configure company-backends to include dabbrev which is the name of the functionality you want. IIRC it has its own weird little syntax and lsp-mode may also be configuring it depending on your config so you're gonna have to do some digging on your own. Looking up the documentation for company-backends and lsp-completion-provider values should help you get started. Since company-backends can be buffer-local you may need to test it in your source files with lsp on via M-: (eval-expression)
_analysis230_ · 2022-09-22 17:11
Thank you so much. I'm a newb but now you've given me words and links that I can lookup and read so I'm sure I'd be able to figure out.
I have no clue what company is but I'd readup now and thank you so very much.
_analysis230_ · 2022-09-22 17:13
I'm going to be 100% honest to you, only half of what you said made sense to me. Not because you are confusing but because I'm a newb. Thank you so very much though. You've pointed me in the right direction and I'd soon figrue it out.
hkjels · 2022-09-22 19:08
If you are using company-mode, you will want to set company-backends to something like ‘(company-capf :with company-dabbrev)
chmouelb · 2022-09-22 19:47
If you want to get into another completion system called "Vertico" https://github.com/minad/vertico you can use its companion completion at point system "Corfu" https://github.com/minad/corfu and it has a bunch of completions sources provided by the library "Cape" https://github.com/minad/cape which has a bunch of completion "sources" you can include, the dabbrev ones (like the ABC thing on VSC) and a bunch of others. I think the time invested in this is worth it.
_analysis230_ · 2022-09-22 19:49
Okay. So now I have things to read up.
Honestly I'm a bit out of my depth here.
I don't know what's what.
If I should stick with company or vertico or how lsp factors into all this but I'm trying to figure it all out.
chmouelb · 2022-09-22 19:53
yeah I think this may be a bit much when you are just starting into emacs.
alternatively you may want to give a try to doom-emacs, it should have all of these built-in and nicely integrated.. https://github.com/doomemacs/
_analysis230_ · 2022-09-22 19:54
Oh... I am running doom
Lsp and everything is working just fine for me.
I'm using it for my job and the experience is great.
Just tweaking little things now.
_analysis230_ · 2022-09-22 19:56
Oh... I am running doom
Lsp and everything is working just fine for me.
I'm using it for my job and the experience is great.
Just tweaking little things now.
MunsterPlop · 2022-09-23 02:09
Others have already provided you with ways to achieve what you want so I will not repeat it.
However, I think it is actually important you understand how things work a bit better, so I will give it a shot.
VSCode does not give you suggestions for "invalid" symbols. It just looks if what you're trying to type has already appeared somewhere in your opened files.
That is why in the example in one of your comments, "house" did not get suggested until you replaced "modifier" on a previous line.
I believe it might also have a dictionary of commonly used words (I may be wrong).
In vanilla Emacs, there is a built-in feature which does all that.
It is called `dabbrev` (for dynamic abbreviations).
In Doom Emacs, by default, completions are handled by `company`.
It is a package that gives you the nice completion popup (the frontend) and processes the different results that will be suggested to you in it (the backend).
Company can have multiple backends.
`company-dabbrev` is the one that will
integrate the built-in `dabbrev` with `company`.
An alternative to `company` which was suggested to you is `corfu`.
Unlike `company`, it uses Emacs' built-in `completion-at-point` functions instead of its own backend.
I hope this was understandable enough.
_analysis230_ · 2022-09-23 03:00
Thank you so much for going above and beyond and helping me learn a thing or two. Thank a lot.
I'd try crafting my own config.