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

Add optional snippet placeholders at the end again #544

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions plugin/libclang.py
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,9 @@ def formatResult(result):
word = ""
info = ""
place_markers_for_optional_args = int(vim.eval("g:clang_complete_optional_args_in_snippets")) == 1
add_trailing_placeholders = int(vim.eval("g:clang_trailing_placeholder")) == 1
use_clang_complete_snippets = vim.eval("g:clang_snippets_engine") == "clang_complete"
added_placeholder = False

def roll_out_optional(chunks):
result = []
Expand Down Expand Up @@ -420,10 +423,12 @@ def roll_out_optional(chunks):
for optional_arg in roll_out_optional(chunk.string):
if place_markers_for_optional_args:
word += snippetsFormatPlaceHolder(optional_arg)
added_placeholder = True
info += optional_arg + "=?"

if chunk.isKindPlaceHolder():
word += snippetsFormatPlaceHolder(chunk_spelling)
added_placeholder = True
else:
word += chunk_spelling

Expand All @@ -434,6 +439,9 @@ def roll_out_optional(chunks):
if returnValue:
menu = decode(returnValue.spelling) + " " + menu

if added_placeholder and add_trailing_placeholders and use_clang_complete_snippets:
word += snippetsFormatPlaceHolder('')

completion['word'] = snippetsAddSnippet(info, word, abbr)
completion['abbr'] = abbr
completion['menu'] = menu
Expand Down