ternjs / tern_for_sublime

Sublime Text package adding Tern support
MIT License
803 stars 54 forks source link

Option to show autocompletions after dot is typed #7

Closed gvn closed 11 years ago

gvn commented 11 years ago

It would be nice to expose an option to automatically show the autocompletion list after you type a dot on an object instead of having to use ctrl-space.

marijnh commented 11 years ago

I'm not too familiar with the Sublime Text plugin ecosystem, but what Tern does is simply provide an on_query_completions hook -- how those are triggered is up to the editor. I'm sure there is a way to get them to open when a dot is typed without touching the Tern plugin itself. I unfortunately don't know what that way is.

gvn commented 11 years ago

I can look into it as I'm not sure either. In the meantime, shall we leave this issue open in case someone can provide a PR for it? This behavior is pretty standard in most IDEs for intellisense/autocomplete and would be really nice to have. Thanks!

subhaze commented 11 years ago

The setting to adjust is:

// Enable auto complete to be triggered automatically when typing.
    "auto_complete": true,

Within: SublimeText > Preferences > Settings - User

This is set to true by default (for ST3 at least).

gvn commented 11 years ago

So, at least in ST2, that preference only shows autocompletions after a dot and subsequent letter are typed. (It does appear to be true by default in ST2 as well.)

Ideally, I would like to type just myObject. and have all possible autocompletions presented after the dot is typed.

subhaze commented 11 years ago

Ohhh, ok sorry misunderstood when you wanted this to happen. For that you need to modify the following:

change:

// Additional situations to trigger auto complete
    "auto_complete_triggers": [ {"selector": "text.html", "characters": "<"} ],

To something like this:

    // Additional situations to trigger auto complete
    "auto_complete_triggers": [ {"selector": "text.html", "characters": "<"}, {"selector": "source.js", "characters": "."} ],
gvn commented 11 years ago

No worries. That worked like a charm! Exactly what I was looking for.

I'm assuming more people will want this, so I'll see if I can do a PR to update the docs. Thanks for your help!

marijnh commented 11 years ago

Great, that's how I hoped things would work. Closing this issue.