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

[WIP] Support of ultisnips snippet #3682

Merged
merged 29 commits into from
Mar 10, 2022
Merged

[WIP] Support of ultisnips snippet #3682

merged 29 commits into from
Mar 10, 2022

Conversation

chemzqm
Copy link
Member

@chemzqm chemzqm commented Mar 5, 2022

The goal is better support for ultinips python features, including:

  • Dependencies of placeholder with python block, like:
    ${1:`!p snip.rv = t[2]`} ${2:`!p snip.rv = t[3]`} ${3:`!p snip.rv = t[4][0]`} ${4:bar}
  • Variables like snip.c:
    #ifndef ${1:`!p
    if not snip.c:
    	import random, string
    	name = re.sub(r'[^A-Za-z0-9]+','_', snip.fn).upper()
    	rand = ''.join(random.sample(string.ascii_letters+string.digits, 8))
    	snip.rv = ('%s_%s' % (name,rand)).upper()
    else:
    	snip.rv = snip.c`}
    #define $1
  • Calculate code blocks on placeholder change, like:
    `!p
    box = make_box(len(t[1]))
    snip.rv = box[0]
    snip += box[1]
    `${1:${VISUAL:content}}`!p
    box = make_box(len(t[1]))
    snip.rv = box[2]
    snip += box[3]`
    $0

Other changes:

  • Fixed the changed placeholder could be wrong.
  • Add highlight support for current active placeholders.
  • Improved text edit on change by reduce the range as much as possible.
  • Nested placeholder support when insert nested snippet.
  • New synchronize logic which support cancellation.
  • Not jump to last placeholder when invoke g:coc_snippet_prev on first placeholder
  • Use <Cmd> for key mapping to avoid mode change.
  • Improve python code error by include python code.
  • Improve snippet preview by resolve python code.

New VSCode snippet variables:

  • RELATIVE_FILEPATH
  • RANDOM
  • RANDOM_HEX
  • UUID
  • BLOCK_COMMENT_START
  • BLOCK_COMMENT_END
  • LINE_COMMENT
  • WORKSPACE_NAME
  • WORKSPACE_FOLDER

@codecov
Copy link

codecov bot commented Mar 5, 2022

Codecov Report

Merging #3682 (3012045) into master (1f60c3d) will increase coverage by 0.56%.
The diff coverage is 90.03%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3682      +/-   ##
==========================================
+ Coverage   78.44%   79.00%   +0.56%     
==========================================
  Files         210      211       +1     
  Lines       20912    21402     +490     
  Branches     4724     4848     +124     
==========================================
+ Hits        16404    16909     +505     
+ Misses       2776     2755      -21     
- Partials     1732     1738       +6     
Impacted Files Coverage Δ
src/model/document.ts 73.94% <ø> (+0.28%) ⬆️
src/types.ts 100.00% <ø> (ø)
src/util/position.ts 100.00% <ø> (+9.63%) ⬆️
src/sources/source-language.ts 60.15% <55.26%> (+0.69%) ⬆️
src/commands.ts 46.84% <66.66%> (+1.33%) ⬆️
src/model/status.ts 90.90% <85.71%> (-1.60%) ⬇️
src/snippets/variableResolve.ts 90.58% <87.87%> (-3.03%) ⬇️
src/snippets/parser.ts 86.76% <89.50%> (+4.07%) ⬆️
src/snippets/session.ts 88.27% <91.37%> (+6.62%) ⬆️
src/snippets/eval.ts 93.50% <93.50%> (ø)
... and 22 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1f60c3d...3012045. Read the comment docs.

@chemzqm chemzqm merged commit 8401279 into master Mar 10, 2022
@chemzqm chemzqm deleted the ultisnips branch March 10, 2022 06:00
chemzqm added a commit that referenced this pull request Mar 10, 2022
8401279 Support of ultisnips snippet (#3682)
33d8a71 chore(esbuild): not use revision on development
b24a4ad chore(package): upgrade esbuild
5e2ecc4 feat(esbuild): add commit date to CocInfo (#3689)
5b363b8 fix(TreeView): silent exe (#3690)
@oblitum
Copy link
Member

oblitum commented Mar 10, 2022

@chemzqm hi. I'm a little confused, do I need coc-snippets to have ultisnip snippet support or this builtin support is sufficient? Maybe wikipage on snippets now needs an update? https://github.com/neoclide/coc.nvim/wiki/Using-snippets

@chemzqm
Copy link
Member Author

chemzqm commented Mar 10, 2022

It only add support for parse ultisnips snippets, not provide them, https://github.com/neoclide/coc.nvim/pull/3682/files#diff-4f45caa500ef03d94d3c2bfa556caa1642df95d4e2b980d76b876a8fd2e8c522 coc-snippets needs upgrade to make use of it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants