SublimeCodeIntel icon indicating copy to clipboard operation
SublimeCodeIntel copied to clipboard

Format autocomplete in more modern way, without much effort

Open lumnn opened this issue 7 years ago • 4 comments

I didn't like the fact it had a lot of text in an entry, which at the same time didn't give quick feedback to user about what the completion is about.

So I started playing around with code, to improve this, and I got to this point: peek 2018-08-09 11-44

I wanted to create a pull request, but the changes are done to the version that's different from master. Also that's probably one of my first Python lines in my life.

Here I attach format_competions_by_language function:

def format_completions_by_language(cplns, language, text_in_current_line, trigger):
    function = None if 'import ' in text_in_current_line else 'function'
    
    def get_symbol(t):
        symbols = {
            'variable': '🅥',
            'constant': '🅓',
            'namespace': '🅝',
            'keyword': '🅚',
            'function': '🅕',
            'class': '🅒',
            'interface': '🅘',
        }
        
        if language == "PHP" and trigger and (trigger.name == "php-complete-object-members" or trigger.name == "php-complete-static-members"):
            symbols['variable'] = '🅟'
            symbols['function'] = '🅜'

        return symbols[t] if t in symbols else t

    def get_name(t, n):
        if t == 'variable' and language == 'PHP':
            return '$'+n
        elif t == 'function':
            return n+'(…)'

        return n

    return [('%s %s' % (get_symbol(t), get_name(t, n,)), (n).replace("$", "") + ('($0)' if t == function else '')) for t, n in cplns]

Feel free to use this code and I'll be happy if it gets implemented into master

lumnn avatar Aug 09 '18 10:08 lumnn

How to make Sublime show the symbols like in the gif?

🅥 is not working...

natanfelles avatar Feb 09 '19 23:02 natanfelles

@Kronuz Any plans for something like this?

EivindArvesen avatar Feb 10 '19 11:02 EivindArvesen

@natanfelles I believe it's either the fact your system misses a font that supports this kind of characters, or it may be becasue sublime text version is below 3146

lumnn avatar Feb 10 '19 11:02 lumnn

Yes. I thought it could be the FiraCode font, but even switching to it these special characters do not appear.

Tried to inject an image, but no success yet.

ST version: 3176

natanfelles avatar Feb 11 '19 03:02 natanfelles