Home Download Buy Blog Forum Support

If lots of sublime-completions, then variable names never sh

If lots of sublime-completions, then variable names never sh

Postby robertcollier4 on Tue Jul 30, 2013 10:29 pm

I am quite shocked that Sublime has "Words in the buffer" set at the lowest priority to show in the completions list. The words in the buffer contain the variables that you are currently using for your current program. Those are the most likely to be used with the highest occurrence. For Sublime to instead show a long list of all the available function names and all the other crap from the .sublime-completions file is very inconvenient.

Because of this, I am having to remove and not use my .sublime-completions files. Because when I am typing in a variable name that I am using in my current program - I want it to show up in the auto-completion list so I don't have to keep typing that variable-name - but that variable from the buffer contents shows up very late in the sublime-completions list because it always gets superceded by all the other completions from all the other sources.

What about an option to have "Words in the buffer" as the first priority displayed auto completions in the auto completion list?

From: http://docs.sublimetext.info/en/latest/ ... tions.html
This is the order in which completions are prioritized:
- Snippets
- API-injected completions
- .sublime-completions files
- Words in the buffer
Last edited by robertcollier4 on Fri Feb 07, 2014 12:41 pm, edited 1 time in total.
robertcollier4
 
Posts: 154
Joined: Sun Feb 24, 2013 5:37 pm

Re: Autocompletion - give words in the buffer highest priority

Postby robertcollier4 on Fri Feb 07, 2014 12:39 pm

Related:

​​http://www.sublimetext.com/forum/viewtopic.php?f=4&t=13583

​​http://sublimetext.userecho.com/topic/151308-change-completion-priority/

​​http://sublimetext.userecho.com/topic/115795-snippets-always-take-priority-over-autocomplete/

​​http://sublimetext.userecho.com/topic/116149-autocomplete-snippets-shadow-variables-with-the-same-name/
robertcollier4
 
Posts: 154
Joined: Sun Feb 24, 2013 5:37 pm

Re: If lots of sublime-completions, then variable names never sh

Postby Binocular222 on Fri Feb 07, 2014 4:09 pm

+1
But I guess a plugin EventListener.on_query_completions() will be able to insert Words in Buffer to the top
something similar to this: https://sublimetext.com/forum/viewtopic.php?f=3&t=11687
But I'm so incompetent at Py
Binocular222
 
Posts: 55
Joined: Sat May 18, 2013 4:10 pm

Re: If lots of sublime-completions, then variable names never sh

Postby robertcollier4 on Sat Feb 15, 2014 9:26 am

Binocular222 wrote:+1
But I guess a plugin EventListener.on_query_completions() will be able to insert Words in Buffer to the top
something similar to this: https://sublimetext.com/forum/viewtopic.php?f=3&t=11687
But I'm so incompetent at Py


This is the order in which completions are prioritized:
- Snippets
- API-injected completions
- .sublime-completions files
- Words in the buffer


So it seems you can return additional completions from on_query_completions which would then take the #2 Rank of "API-injected completions".
And we can disable "Words in the buffer" via flag - "sublime.INHIBIT_WORD_COMPLETIONS".
But how to get the "Words from Buffer" completion-list in Python and return it from on_query_completions so that those completions would take the rank of "API-injected completions"?

Here's a start, can't figure out how to get the "Words from Buffer" completion list in Python.
Code: Select all
import sublime
import sublime_plugin

class CustomCompletionListener(sublime_plugin.EventListener):
    def on_query_completions(self, view, prefix, locations):
        return ([], sublime.INHIBIT_WORD_COMPLETIONS)
robertcollier4
 
Posts: 154
Joined: Sun Feb 24, 2013 5:37 pm

Re: If lots of sublime-completions, then variable names never sh

Postby robertcollier4 on Sat Feb 15, 2014 9:33 am

Tried this, with code borrowed from here but the words still are not prioritized above the entries in .sublime-completions files
So seems this is not possible until developer prioritizes this.

Code: Select all
import sublime
import sublime_plugin
import re

class CustomCompletionListener(sublime_plugin.EventListener):
   def on_query_completions(self, view, prefix, locations):
      code = view.substr(sublime.Region(0, view.size()))
      words = set(re.findall(r'\b[A-Za-z_]\w+\b', code))
        return (words, sublime.INHIBIT_WORD_COMPLETIONS)


Ideally, I would like my completions list to show with following priority:
1. API-injected completions
2. Words in Buffer
3 .sublime-completions files
4. Snippets
robertcollier4
 
Posts: 154
Joined: Sun Feb 24, 2013 5:37 pm


Return to Ideas and Feature Requests

Who is online

Users browsing this forum: Exabot [Bot] and 13 guests