Giter Club home page Giter Club logo

Comments (13)

philippotto avatar philippotto commented on May 28, 2024 1

I agree! To rephrase it a bit: Every time ST shows autocompletions, a request should be made to the server. ST does this by default only for "alpha" characters. This is why the autocomplete_triggers should be used to invoke additional autocompletion queries.

from lsp.

deathaxe avatar deathaxe commented on May 28, 2024

In #4 was discussed how to easily setup these additional triggers. With the knowledge about language-servers providing these information, I could imagine to automatically add this setting to each supported view. This way no trigger needs to be configured by user.

from lsp.

tomv564 avatar tomv564 commented on May 28, 2024

This investigation supports your conclusion:
microsoft/language-server-protocol#268

and I am for turning on completions for alphanumeric characters.

But I would like to verify that the performance is acceptable, some recent implementations against the javascript/typescript implementations ran into problems: sourcegraph/javascript-typescript-langserver#331

from lsp.

tomv564 avatar tomv564 commented on May 28, 2024

@philippotto, it might be good to have the Flow language server additionally send ['.'] for triggerCharacters. Do you want to create an issue?

from lsp.

philippotto avatar philippotto commented on May 28, 2024

@tomv564 Sure, I created it here.

Regarding potential performance problems, this answer from your referenced issue is interesting:

Drastically reducing how often we called completion has solved problems on Atom. Now we just trigger it on . and when manually requested.

As long as autocompletions are not blazingly fast anyway, I would leave it at that logic (on . and manually requesting). Hitting CTRL + Space for requesting autocompletions is probably idiomatic? We could still have a setting for triggering it after each keystroke (throttled), which is off by default maybe?

from lsp.

deathaxe avatar deathaxe commented on May 28, 2024

The current implementation always cancels auto-completions not triggered by the triggerCharacter. No matter whether it is triggered automatically or manually by Ctrl+Space. A package doesn't know whether completion was triggered manually or automatically.

I saw implementations, which returned no completions with word and explicit completions disabled in on_query_completion() but only fired the request to the language server. If the respond is received, they manually called show_completion to open it. This may cause some delay but doesn't cause ST to block while waiting for an answer.

from lsp.

philippotto avatar philippotto commented on May 28, 2024

A package doesn't know whether completion was triggered manually or automatically.

Couldn't we add a keybinding for ctrl + space which calls show_completion?

from lsp.

tomv564 avatar tomv564 commented on May 28, 2024

@philippotto ctrl+space is already hooked up, but LSP disables most calls as it expects the character before the cursor to be a triggerCharacter.

@deathaxe can you think of a way to detect manually invoked completions? I think that's a fairly safe step forward for now.

As for your second suggestion, I like seeing sublime's word completions as they are often relevant and/or confirm that I'm typing the symbol correctly. Perhaps we can still return word completions and replaced with LSP completions when they arrive?

from lsp.

philippotto avatar philippotto commented on May 28, 2024

@philippotto ctrl+space is already hooked up, ...

With "hooked up" you mean that it's a default keybinding of ST? We we could either override it or choose another keybinding? I think this is the easiest way to distinguish between manually and automatically invoked completions. But maybe there's another way..

I like seeing sublime's word completions as they are often relevant and/or confirm that I'm typing the symbol correctly. Perhaps we can still return word completions and replaced with LSP completions when they arrive?

Totally agree. I like ST's fast completions and wouldn't want it to be aggravated by an extension. Adding the LSP completions when they arrive sounds good, but I'd suggest to add them to the bottom of the already provided list. Otherwise, the user might have already navigated in the list of completions and then the entire list gets replaced, which would be annoying.

from lsp.

deathaxe avatar deathaxe commented on May 28, 2024

Perhaps we can still return word completions and replaced with LSP completions when they arrive?

  1. Sublime Text merges all completions from plugins/sublime-completions/words in this order of priority. A plugin has the ability to tell ST to skip explicit and or word-completions (see: https://www.sublimetext.com/docs/3/api_reference.html#sublime_plugin.EventListener)

  2. Doing so will in most cases result flickering as simply returning None in on_query_completions() will show completions from sublime-completions/words and some milliseconds later it will reopen with the results from language-server. Try Anacoda, then you'll know what I mean. It is just a terrible feeling.

So the only two solutions from my point of view are:

  • block and wait for results from language-server
  • cancel completion and call show_completions if response arrived.

To handle automatic/manual completions, we may modify the "auto_complete" view setting to disable automatic completions, but I didn't check that right now.

from lsp.

tomv564 avatar tomv564 commented on May 28, 2024

Both word and manual completions are now enabled, hoping to iron out the remaining issues in the near future!

from lsp.

rwols avatar rwols commented on May 28, 2024

I stil need to write my own triggers per language, right?

from lsp.

tomv564 avatar tomv564 commented on May 28, 2024

Yes, for non-alphabetic characters.
LSP should honour manual completions (ctr+space) by default, if you want to try if a given trigger character gives good results with your language server.

from lsp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.