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

Company based realtime imcremental drop-down completion menu for lsp-mode, ispell, and yasnippet. #1124

Closed
hongyi-zhao opened this issue Jun 17, 2021 · 27 comments
Labels

Comments

@hongyi-zhao
Copy link

hongyi-zhao commented Jun 17, 2021

On Ubuntu 20.04, I'm using auctex, eglot, texlab, and company to build a vanilla Emacs based LaTeX document preparation system.
The detailed settings are described here. The company relevant configuration is shown below:

(use-package company)
(add-hook 'after-init-hook 'global-company-mode)

And the real effect is represented in the following screenshot:

image

But, I want to know if it's possible to do the regexp-based search and completion result filtering displayed on the incremental drop-down menu. For example, if I typeset \?*arrow*, then all LaTeX commands including arrow will be shown up in the drop-down menu list.

Any hints for this feature will be highly appreciated.

Regards,
HY

@dgutov
Copy link
Member

dgutov commented Jun 17, 2021

Not regexp search, but you can type C-s arrow.

@hongyi-zhao
Copy link
Author

hongyi-zhao commented Jun 17, 2021

Really/exactly. Wonderful. Thank you for your insightful comments. See the screenshot below:

image

@hongyi-zhao hongyi-zhao changed the title Feature request: regexp-based search and completion result filtering displayed on the incremental drop-down menu. Regexp-based search and completion result filtering displayed on the incremental drop-down menu. Jun 17, 2021
@hongyi-zhao hongyi-zhao changed the title Regexp-based search and completion result filtering displayed on the incremental drop-down menu. How to display regexp-filtered results on the incremental drop-down menu? Jun 18, 2021
@hongyi-zhao
Copy link
Author

hongyi-zhao commented Jun 18, 2021

Another question I would like to know is, why do some commands have ICONS and others don't, appeared in the second to last column.

@dgutov
Copy link
Member

dgutov commented Jun 18, 2021

Which of the icons do you mean?

@dgutov
Copy link
Member

dgutov commented Jun 18, 2021

Ah, the arrows? Those are returned by the backend.

@hongyi-zhao
Copy link
Author

hongyi-zhao commented Jun 18, 2021

I mean, say, for the Dirac notation, there are no icons rendered in the middle column of the drop-down menu.

image

But for some mathematical symbols, the corresponding icons are represented at the middle column of the drop-down menu.

image

@dgutov
Copy link
Member

dgutov commented Jun 18, 2021

That's up to the backend. The language server, probably (if you're using lsp or eglot).

@hongyi-zhao
Copy link
Author

hongyi-zhao commented Jun 18, 2021

Another issue: can I have a drop-down menu for normal writing/typesetting, just as we have for command completion with company, which is triggered by a specific threshold of the minimum number of input characters, say, 3, and then incrementally narrowed down as the input sequence increases. See here for detailed discussion.

@dgutov
Copy link
Member

dgutov commented Jun 18, 2021

Meaning completions from words-in-buffers? Or from installed dictionaries?

@hongyi-zhao
Copy link
Author

hongyi-zhao commented Jun 18, 2021

From installed dictionaries. Only this way is of practical application value for document writing. We can't expect all intended input words are existed in the buffer, obviously.

@dgutov
Copy link
Member

dgutov commented Jun 18, 2021

Something like this should work:

(push '(company-capf :with company-ispell) company-backends)

Or without :with, if you're fine with only using these two backends in all your buffers.

@hongyi-zhao
Copy link
Author

I tried with it, but noting appeared.

@dgutov
Copy link
Member

dgutov commented Jun 18, 2021

Does M-x company-ispell work?

@hongyi-zhao
Copy link
Author

hongyi-zhao commented Jun 18, 2021

Wonderful. See below:

image

But once I hint RET to insert the result at the point, I must re-run M-x company-ispell again. This makes it useless for a document preparation - the efficiency will be very poor due to run M-x company-ispell over and over.

@dgutov
Copy link
Member

dgutov commented Jun 18, 2021

What does M-x company-diag say?

@hongyi-zhao hongyi-zhao changed the title How to display regexp-filtered results on the incremental drop-down menu? Company based real imcremental results on the in-situ drop-down menu for lsp-mode, ispell, and yasnippet. Jun 18, 2021
@hongyi-zhao hongyi-zhao changed the title Company based real imcremental results on the in-situ drop-down menu for lsp-mode, ispell, and yasnippet. Company based real imcremental at-the-point drop-down menu for lsp-mode, ispell, and yasnippet. Jun 18, 2021
@hongyi-zhao
Copy link
Author

What does M-x company-diag say?

image

@dgutov
Copy link
Member

dgutov commented Jun 18, 2021

And what does it say after you evaluate (push '(company-capf :with company-ispell) company-backends), which you said didn't help?

@hongyi-zhao
Copy link
Author

image

@dgutov
Copy link
Member

dgutov commented Jun 18, 2021

And M-x company-diag says..?

@hongyi-zhao
Copy link
Author

image

@dgutov
Copy link
Member

dgutov commented Jun 19, 2021

The first 10 lines of that buffer are not visible, and they are the most important.

@hongyi-zhao
Copy link
Author

Sorry for my cursory.

image

@dgutov
Copy link
Member

dgutov commented Jun 19, 2021

OK, so does completion work fine in this buffer?

But it doesn't offer dictionary completions in latex buffers? If so, you have a place in your config where you set up a buffer-local value of company-backends in latex buffers. When you find it, you can add that snippet to the function that's executing there.

@hongyi-zhao
Copy link
Author

hongyi-zhao commented Jun 19, 2021

I don't understand your meaning at all. As I've said, each completion only and must be triggered by M-x company-ispell, regardless which buffer I'm in. See the screenshots below for more detailed info.

First, run M-x company-ispell RET:

image

Now, the completion will be triggered:

image

After I hit the RET to insert the appropriate candidates from the drop-down menu, the completion will be disabled for the next word typesetting, till I re-run M-x company-ispell RET again:

image

@hongyi-zhao hongyi-zhao changed the title Company based real imcremental at-the-point drop-down menu for lsp-mode, ispell, and yasnippet. Company based realtime imcremental drop-down completion menu for lsp-mode, ispell, and yasnippet. Jun 19, 2021
@hongyi-zhao
Copy link
Author

hongyi-zhao commented Jun 19, 2021

Company-wordfreq is a company-backend for human language texts based on word frequency dictionaries. But I still fail to try it out, as described by this issue.

@dgutov
Copy link
Member

dgutov commented Jun 19, 2021

Hmm, I though you were using Eglot, which works through company-capf.

Try (push '(company-capf company-ispell) company-backends), then. It won't matter if capf is not used.

Or (push '(company-capf company-wordfreq) company-backends).

@hongyi-zhao
Copy link
Author

hongyi-zhao commented Jun 19, 2021

No, this can't solve the problem. I still must run M-x company-ispell RET before type each word to trigger the dropdown completion menu. See here for relevant discussion.

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

No branches or pull requests

2 participants