helix icon indicating copy to clipboard operation
helix copied to clipboard

Completion sources

Open QiBaobin opened this issue 4 years ago • 13 comments

Describe your feature request

It's sweet to use the complete when there is a lsp server, but for all other cases, there is none of useful completion. Could we have some of below vim features, like completions keywords or lines from open files, I think it's also useful when lsp enabled. Thanks!

Completion can be done for:

1. Whole lines						|i_CTRL-X_CTRL-L|
2. keywords in the current file				|i_CTRL-X_CTRL-N|
3. keywords in 'dictionary'				|i_CTRL-X_CTRL-K|
4. keywords in 'thesaurus', thesaurus-style		|i_CTRL-X_CTRL-T|
5. keywords in the current and included files		|i_CTRL-X_CTRL-I|
6. tags							|i_CTRL-X_CTRL-]|
7. file names						|i_CTRL-X_CTRL-F|
8. definitions or macros				|i_CTRL-X_CTRL-D|
9. Vim command-line					|i_CTRL-X_CTRL-V|
10. User defined completion				|i_CTRL-X_CTRL-U|
11. omni completion					|i_CTRL-X_CTRL-O|
12. Spelling suggestions				|i_CTRL-X_s|
13. keywords in 'complete'				|i_CTRL-N| |i_CTRL-P|

QiBaobin avatar Nov 08 '21 13:11 QiBaobin

I think we should keep this issue small, maybe we can start with something simple such keyword completion, whole lines or files. Then close this issue, and open as we see fit.

pickfire avatar Nov 17 '21 14:11 pickfire

I find that path completion also comes in handy (currently using nvim-cmp with https://github.com/hrsh7th/cmp-path completion source enabled)

bram209 avatar Dec 17 '21 09:12 bram209

when having multiple completion sources:

  • Results need to be prioritized (if LSP is enabled, those completions will likely be better suggestions since they are context-aware)
  • It may be annoying if the simple keyword completions already show up, before the slightly delayed LSP is done processing the request
  • if however, you are dealing with a big codebase and a slow language server (looking at you, tsserver), it may take a while for the LSP to come with completions, in these scenario's it would come in handy to have a fallback on the simple keyword completions in the meanwhile

Some configurable threshold(s) could work, i.e. if LSP is enabled and completion request takes longer than X, show Y completion source(s) instead

thoughts?

bram209 avatar Dec 17 '21 09:12 bram209

@pickfire by keeping it small, are you intending to initially start with just some fallback completions in the case LSP is not loaded, or would you prefer that the completion system is set up in a way that completion sources are pluggable and multiple sources may be allowed at the same time?

bram209 avatar Dec 17 '21 09:12 bram209

Of course multiple sources and asynchronous results is the best, but I believe no one is focusing on this yet.

pickfire avatar Dec 18 '21 06:12 pickfire

anyone focus on this issue?

Lingzo avatar May 08 '22 05:05 Lingzo

@altair-albert see the latest pull request on #2403, but other than that most likely no. If you would like, feel free to give it a try to work on this issue.

pickfire avatar May 08 '22 14:05 pickfire

Support word and line completions here #4816

QiBaobin avatar Nov 19 '22 12:11 QiBaobin

Having code completion in ~/.config/helix/config.toml would be super extra nice, and having a generic completion provider infra would help with that.

matklad avatar Dec 14 '22 14:12 matklad

Having code completion in ~/.config/helix/config.toml would be super extra nice, and having a generic completion provider infra would help with that.

Would be nice if we have a (generated) json schema for the helix config, related: https://github.com/helix-editor/helix/issues/1282

bram209 avatar Dec 14 '22 22:12 bram209

Also related to that: https://github.com/helix-editor/helix/issues/2894, https://github.com/helix-editor/helix/issues/3901, https://github.com/helix-editor/helix/issues/3383#issuecomment-1210662079

the-mikedavis avatar Dec 14 '22 23:12 the-mikedavis

it would be better if it support highlight all the same variable presents. As well as, put the goto reference file list in a split window like file tree, and highlight all the keyword presents in file, that would really helpful to keep tracking changes to those references. What i mentioned already in vscode and i found it helpful when I am using them. :)

suqin-haha avatar Aug 14 '23 23:08 suqin-haha

  • How should suggestions be prioritized for, say, words ? Does it make sense to prioritize words that appear the most in the current file ? Or the closest ones to the cursor ? A mix of both ? The "closest ones" rule should be less resource intensive, I guess, as we could stop the search on the first few matches, but it makes sense to give a weight to words that are more frequently used.

  • Should words that are less than 3 chars long be excluded ? I think so.

  • Should the search be limited to a portion of the current file around the cursor if it is too big ? I guess it makes sense because I don’t see a scenario where it is super useful to autocomplete a word that appeared 10 000 lines before (and if you need it, you probably need an LSP Server anyway).

fonskip avatar Aug 22 '24 08:08 fonskip