Home Download Buy Blog Forum Support

Autocomplete over all tabs/project

Autocomplete over all tabs/project

Postby max.hauser on Thu Jan 12, 2012 8:15 am

Hi there,

first of all - thank you for this great editor!

I have one question: Is there a possibility to broaden the scope of the smart auto completion data base to all open files or even all files inside the current project instead of just the current file? That would be awesome.

Thanks,
Max
max.hauser
 
Posts: 2
Joined: Wed Oct 19, 2011 2:19 pm

Re: Autocomplete over all tabs/project

Postby rmichnik on Thu Jan 12, 2012 1:19 pm

That would be awesome [2]
rmichnik
 
Posts: 1
Joined: Thu Jan 12, 2012 1:18 pm

Re: Autocomplete over all tabs/project

Postby obiefernandez on Fri Jan 13, 2012 5:49 pm

Bumping to the top...

Would love this feature: Have autocomplete work across buffers, not only the currently active file. Would work wonders for web development.
obiefernandez
 
Posts: 1
Joined: Fri Jan 13, 2012 5:33 pm

Re: Autocomplete over all tabs/project

Postby SackOfWrenches on Fri Jan 13, 2012 6:01 pm

+1 for global/language-aware auto completion. +2 if it's aware of function signatures & arguments.

Essential for large projects. This would allow most of the people on my team to break the tractor-beam hold that Eclipse has on them and move to an editor that doesn't have all the visual appeal of a bucket of rusty nails. My Python sucks, but I'll set aside some time this weekend to see how much work this would be -- perhaps easier if a TAGS-like file format can be made that a Sublime plugin can slurp down.
SackOfWrenches
 
Posts: 2
Joined: Fri Jan 13, 2012 5:49 pm

Re: Autocomplete over all tabs/project

Postby jepessen on Sun Jan 15, 2012 5:09 pm

Agree. It will be great for my C#, C++ projects...
jepessen
 
Posts: 3
Joined: Sun Nov 13, 2011 7:21 pm

Re: Autocomplete over all tabs/project

Postby hibbelig on Sun Jan 15, 2012 6:17 pm

There is SublimeCodeIntel which offers code completion for some languages.

There is a ctags package for Sublime (https://github.com/SublimeText/CTags), too.

I vaguely remember that there is also a package dedicated to C/C++ projects, but I forgot its name.
hibbelig
 
Posts: 77
Joined: Wed Dec 21, 2011 11:24 pm

Re: Autocomplete over all tabs/project

Postby sspringerb on Sun Jan 15, 2012 7:47 pm

+1 for autocompletion over files in a project, *but* only over files with the same extension
sspringerb
 
Posts: 1
Joined: Sun Jan 15, 2012 7:44 pm

Re: Autocomplete over all tabs/project

Postby iamnoah on Sat Feb 11, 2012 6:20 pm

I wrote a plugin that pulls completions from every open tab:

Code: Select all
import sublime_plugin, sublime

class AutocompleteAll(sublime_plugin.EventListener):

    def on_query_completions(self, view, prefix, locations):
        window = sublime.active_window()
        # get results from each tab
        results = [v.extract_completions(prefix) for v in window.views() if v.buffer_id() != view.buffer_id()]
        results = [(item,item) for sublist in results for item in sublist] #flatten
        results = list(set(results)) # make unique
        results.sort() # sort
        return results


If you want to limit it to files with the same extension, add something like this:

Code: Select all
        if(view.file_name() is None):
            extension = ''
        else:
            name, extension = view.file_name().rsplit('.',2)
        extension = '.' + extension

        views = []
        for v in window.views():
            fileName = v.file_name()
            if (fileName is None or v.buffer_id() != view.buffer_id() and fileName.endswith(extension)):
                views.append(v)
        # get results from each tab
        results = [v.extract_completions(prefix) for v in views]
        # the rest is the same
iamnoah
 
Posts: 1
Joined: Sat Feb 11, 2012 4:43 pm

Re: Autocomplete over all tabs/project

Postby ask on Sun Feb 12, 2012 8:44 am

Nice, didn't now about extract_completions method.
By the way, when was it introduced ?
ask
 
Posts: 26
Joined: Wed Sep 14, 2011 12:40 pm

Re: Autocomplete over all tabs/project

Postby sublimator on Sun Feb 12, 2012 11:15 am

extract_completions has been around since ST1 days
It is better to remain silent and be thought a fool, than to speak out and remove all doubt
sublimator
 
Posts: 649
Joined: Thu Mar 20, 2008 5:41 am

Next

Return to General Discussion

Who is online

Users browsing this forum: Exabot [Bot], Google [Bot] and 19 guests