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

Unicode completion of suffix first, with exact matches low priority #146

Open
aaron-jack-manning opened this issue Mar 15, 2025 · 7 comments

Comments

@aaron-jack-manning
Copy link

This is possibly related to #50, but the issue is present for me in the case of Unicode completion.

I have Unicode completion set up for various mathematical symbols but it generally very hard to get the symbol I am after, even when the source text has an exact match to the symbol name.

For instance, if I type in I get completions for symbol names beginning with in (such as integral) before the symbol which is just called in.

Image Image

The same thing happens with suffixes, where I have an exact match typed in the buffer, but a partial match to the end of the word I am after is included and higher in the completion list.

Image Image

@estin
Copy link
Owner

estin commented Mar 17, 2025

Hi! Seems like you needs to disable tail-word completion and works only with unicode-input

[language-server.scls.config]
feature_snippets = true
snippets_first = true
snippets_inline_by_word_tail = false
feature_unicode_input = true

And yes unidecode-input completions append to the end of list.

Or try to use only tail-word completion for all cases, because both feature tail-word and unicode-input have same search logic.

@aaron-jack-manning
Copy link
Author

and works only with unicode-input

I'm not sure I fully understand what you mean by this. My goal with this is only to do unicode completion, my previous configuration was

[language-server.scls.config]
feature_unicode_input = true

and changing this to

[language-server.scls.config]
snippets_inline_by_word_tail = false
feature_unicode_input = true

or

[language-server.scls.config]
feature_snippets = true
snippets_first = true
snippets_inline_by_word_tail = false
feature_unicode_input = true

doesn't resolve the issue.

@estin
Copy link
Owner

estin commented Mar 19, 2025

Please build from master and try it. Filled sort_text for completion items and use ordered collections to search by.

    /// A string that should be used when comparing this item
    /// with other items. When `falsy` the label is used
    /// as the sort text for this item.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub sort_text: Option<String>,

Tail-word completion and unicode completion currently works by same logic but with different configuration ways

Tail-word configured by (regular snippet)

~/.config/helix/languages.toml

[language-server.scls.config]
snippets_inline_by_word_tail = true
feature_unicode_input = false

~/.config/helix/snippets/snippets.toml

[[snippets]]
prefix = "alpha"
body = "α"
description = "This is α. Used in math ... other markdown docs"

Image

Would have same completion logic as unicode-input completion with next config (simplified snippet)

~/.config/helix/languages.toml

[language-server.scls.config]
snippets_inline_by_word_tail = false
feature_unicode_input = true

~/.config/helix/unicode-input/base.toml

alpha = "α"

Image

@aaron-jack-manning
Copy link
Author

This does not seem to resolve the problem, although I have done a little more digging and it seems this is a consequence of when (within the word being typed) the completion logic first computes options.

I have recorded a video to explain what I mean. If I type the whole word before the completion can finish, it gives suggestions from the tail. If I type slowly, and let it give suggestions first, it then correctly filters those suggestions based on the new characters.

Screencast.From.2025-03-30.10-58-02.mp4

Notice that the first time I get completions for symbols that start with "ha" (short for harpoon, which is the start of each of those symbol names), but the second time I wait a moment after typing "alph" and get suggestions for "phi" instead (which is not given in the first case).

@estin
Copy link
Owner

estin commented Apr 1, 2025

Thanks! Now I can understand this behavior. And by yours helix-editor/helix#1438 (comment) unicode-input config generator I was feel this bug )

Please try this experimental branch to solve this issue

cargo install  --branch reverse-unicode-input-logic  --git https://github.com/estin/simple-completion-language-server.git

@aaron-jack-manning
Copy link
Author

There is still some level of inconsistency in the symbol list which depends on whether I stop typing part way through the symbol name.

Screencast.From.2025-04-08.22-34-36.mp4
Screencast.From.2025-04-08.22-37-10.mp4

That said, these changes have resulted in the symbol I am after far more often being at the top of the list, and much easier to access. So while there is still a little bit of strangeness in the behaviour, my main issue is mostly resolved.

@estin
Copy link
Owner

estin commented Apr 10, 2025

@aaron-jack-manning now fixed and pushed to main branch

Preserve ordering by CompletionItem.sortText attribute

      /**
	 * A string that should be used when comparing this item
	 * with other items. When omitted the label is used
	 * as the sort text for this item.
	 */
	sortText?: string;

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

2 participants