From e012ef0557d8fe7dc1b8d07a9376f7602c7a2e6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20B=C3=B6ger?= Date: Mon, 16 Oct 2017 22:39:53 +0200 Subject: [PATCH 1/2] Add optional snippet placeholders at the end again Having the option clang_trailing_placeholder set to 1, there should be a trailing placeholder at the end of every completion string, if the snippets engine is clang_complete. This has previously been implemented by 742694b, but apparently wasn't ported to the newer python implementation of the snippet construction. --- plugin/libclang.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/plugin/libclang.py b/plugin/libclang.py index 5f9ed450..eb8f9615 100644 --- a/plugin/libclang.py +++ b/plugin/libclang.py @@ -388,6 +388,8 @@ 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" def roll_out_optional(chunks): result = [] @@ -434,6 +436,9 @@ def roll_out_optional(chunks): if returnValue: menu = decode(returnValue.spelling) + " " + menu + if add_trailing_placeholders and use_clang_complete_snippets: + word += snippetsFormatPlaceHolder('') + completion['word'] = snippetsAddSnippet(info, word, abbr) completion['abbr'] = abbr completion['menu'] = menu From 87dd189c224d0f52f813c6dfa9943edfed457ebf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20B=C3=B6ger?= Date: Tue, 17 Oct 2017 14:18:45 +0200 Subject: [PATCH 2/2] No trailing placeholder for completions without args --- plugin/libclang.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/plugin/libclang.py b/plugin/libclang.py index eb8f9615..83c37959 100644 --- a/plugin/libclang.py +++ b/plugin/libclang.py @@ -390,6 +390,7 @@ def formatResult(result): 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 = [] @@ -422,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 @@ -436,7 +439,7 @@ def roll_out_optional(chunks): if returnValue: menu = decode(returnValue.spelling) + " " + menu - if add_trailing_placeholders and use_clang_complete_snippets: + if added_placeholder and add_trailing_placeholders and use_clang_complete_snippets: word += snippetsFormatPlaceHolder('') completion['word'] = snippetsAddSnippet(info, word, abbr)