Home Download Buy Blog Forum Support

Completions package

Re: Completions package

Postby Sinled on Thu Oct 25, 2012 3:33 pm

It seems i found root of the problem, and it is "unnecessary characters", such as spaces, tabs and parentheses in completion trigger.

And what is interesting, when i created sublime-snippet, similar to completion - it works fine with parentheses and spaces in <tabTrigger>
Sinled
 
Posts: 30
Joined: Thu Jan 12, 2012 6:14 pm
Location: Ukraine

Re: Completions package

Postby agibsonsw on Thu Oct 25, 2012 4:53 pm

Sinled wrote:It seems i found root of the problem, and it is "unnecessary characters", such as spaces, tabs and parentheses in completion trigger.

And what is interesting, when i created sublime-snippet, similar to completion - it works fine with parentheses and spaces in <tabTrigger>


Thank you. It must be the brackets, as there are no spaces and the tab (\t) is used to separate the trigger from the description. This will affect my other completion files as well - but not my Python completions.

I don't think I'll edit the files though.. At least, not just yet. Andy.
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
agibsonsw
 
Posts: 901
Joined: Fri Jan 27, 2012 9:11 pm

Re: Completions package

Postby agibsonsw on Thu Oct 25, 2012 10:21 pm

I could correct this by converting to a .py completions file, similar to my Python completions. This has the advantage that I could include 'Default' for the file/standard completions - which is a nice touch 8-).

I might tackle this at the weekend. Andy.
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
agibsonsw
 
Posts: 901
Joined: Fri Jan 27, 2012 9:11 pm

Re: Completions package

Postby pier on Sun Nov 11, 2012 8:16 am

Has this been solved?

I'm having trouble with a completions file with a list of strings that contain spaces, points, parentheses, etc.
pier
 
Posts: 92
Joined: Fri Jun 15, 2012 2:47 am

Re: Completions package

Postby agibsonsw on Tue Nov 13, 2012 12:50 am

pier wrote:Has this been solved?

I'm having trouble with a completions file with a list of strings that contain spaces, points, parentheses, etc.


Don't know if you've resolved this yet, but I can resolve it by converting my completions file to a .py using on_query_completions (similar to my Python completions) and deliberately appending the default (file) completions to the returned completions list. My issue relates to brackets () rather than spaces or dots, but I believe it would solve for these as well.

You could also remove the spaces, etc., from the trigger and make use of the \t description for your completions.

Code: Select all
    "completions":
    [
        { "trigger": "action\tform", "contents": "action=\"$1\"$0" },
        { "trigger": "abbr", "contents": "abbr=\"$1\"$0" },

Doing so also allows you to re-use the same trigger ('import') for similar completions.
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
agibsonsw
 
Posts: 901
Joined: Fri Jan 27, 2012 9:11 pm

Re: Completions package

Postby pier on Wed Nov 14, 2012 8:58 pm

Well it turned out that the problem was more complex than just removing some special characters.

To make it short, when my sublime-completions file is short it works as expected, even with special characters. But when the file is long, anything but letters makes auto complete ignore words buffer from current file. I already tried using tabs with /t but it didn't work. Word buffer was ignored... I will try again, maybe I was doing something wrong as I'm auto generating the sublime-completion file.

So in my AS3 sublime-completions I have like 4 "addchild" triggers, and because I can't add special characters to the trigger nor a description to the snippet, I don't know which snippet I will trigger...

I filled a bug report here
http://sublimetext.userecho.com/topic/1 ... rd-buffer/

I filled a feature request to add descriptions to snippets in sublime-completions
http://sublimetext.userecho.com/topic/1 ... -triggers/

I hope someone (Jon Skinner) will notice this and make something about it... although it seems there aren't many people complaining about it.

I know nothing about Python, but I will take a look at your idea. Thanks.
pier
 
Posts: 92
Joined: Fri Jun 15, 2012 2:47 am

Re: Completions package

Postby agibsonsw on Wed Nov 14, 2012 9:16 pm

It is backslash \t that separates the description.

We can already add descriptions to snippets using <description></description>.

There is a max-filesize setting to display completions, but it is set very large by default:

Code: Select all
    // The maximum file size where auto complete will be automatically triggered.
    "auto_complete_size_limit": 4194304,

[This refers to the current view-size (I believe).]

If you are auto-generating completions (presumably using on_query_completions?) then you can reinstate the default completions by adding them to your completions list:

Code: Select all
        compl_default = [view.extract_completions(prefix)]
        compl_default = [(item + "\tDefault", item) for sublist in compl_default
            for item in sublist if len(item) > 3]       # flatten
        compl_default = list(set(compl_default))        # make unique
        compl_full = list(completions)
        compl_full.extend(compl_default)
        compl_full.sort()
        return (compl_full, sublime.INHIBIT_WORD_COMPLETIONS |
            sublime.INHIBIT_EXPLICIT_COMPLETIONS)

I do this in my Python completions file. Andy.
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
agibsonsw
 
Posts: 901
Joined: Fri Jan 27, 2012 9:11 pm

Re: Completions package

Postby pier on Wed Nov 14, 2012 10:04 pm

agibsonsw wrote:It is backslash \t that separates the description.


My bad, it is a typo... but I used a blackslash when doing the completions file.

We can already add descriptions to snippets using <description></description>.


Yes, but not on completions files AFAIK... I tried adding a description parameter but didn't work.

Code: Select all
{ "trigger": "yeah" , "contents": "Yeah($1);" , "description" : "This is a great snippet" }


If you are auto-generating completions (presumably using on_query_completions?) then you can reinstate the default completions by adding them to your completions list:


Thanks for the code. I'm generating a text file from AS3 based on an xml describing Adobe's classes and methods, not auto generating the completions in real time using python. It seems I will have to study some python. :)
pier
 
Posts: 92
Joined: Fri Jun 15, 2012 2:47 am

Re: Completions package

Postby agibsonsw on Wed Nov 14, 2012 10:17 pm

Code: Select all
{ "trigger": "coords\tArea", "contents": "coords" }
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
agibsonsw
 
Posts: 901
Joined: Fri Jan 27, 2012 9:11 pm

Previous

Return to Plugin Development

Who is online

Users browsing this forum: No registered users and 4 guests