Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update snippets.json for better autocomplete #75

Merged
merged 1 commit into from
Dec 23, 2019

Conversation

jerrylususu
Copy link
Contributor

Replace the numbered prefix to more detailed items.

Before:
图片
After:
图片

How is this done?

import json
with open("snippets.json") as f:
    snippets = json.load(f)
another_dict = {}
for k,v in snippets.items():
#     print(k,"_".join(v["description"].split()))
    concated = "_".join(v["description"].split())
    if not concated in snippets:
        if not concated in another_dict: 
            another_dict[concated] = v.copy()
            another_dict[concated]["prefix"] = concated
        else:
            print(concated, v)
    else:
        another_dict[k] = v.copy()
# output:
# keyPressed {'prefix': 'key', 'body': 'void keyPressed() {\n\t${1}\n}', 'description': 'keyPressed', 'scope': 'source.pde'}
# mousePressed {'prefix': 'mouse', 'body': 'void mousePressed() {\n\t${1}\n}', 'description': 'mousePressed', 'scope': 'source.pde'}
# These two have duplicated var name and method, so add the `_func` postfix for method.
with open('edited.json','w') as f:
    json.dump(another_dict, f)

Replace the numbered prefix to more detailed items.
@AvinZarlez AvinZarlez self-requested a review September 29, 2019 21:37
@AvinZarlez AvinZarlez self-assigned this Sep 29, 2019
@AvinZarlez
Copy link
Owner

This looks excellent! I'm traveling at the moment, but when I can I'll sit down and test + release this. Thank you!

@AvinZarlez AvinZarlez merged commit 94e4a57 into AvinZarlez:master Dec 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants