xavierd / clang_complete

Vim plugin that use clang for completing C/C++ code.
http://www.vim.org/scripts/script.php?script_id=3302
1.96k stars 308 forks source link

fix the way single quotes are escaped to match what vimscript expects #542

Closed bbaldino closed 6 years ago

bbaldino commented 7 years ago

python will escape a single quote in a string with a slash \', but vimscript wants it done via doubling the single quote ''. this commit introduces a new dictionary type used by the code which formats the completion results to properly escape single quotes

bbaldino commented 7 years ago

ran across this issue when getting completions after typing std::. there is a method in std called quoted which has an argument which defaults to the value of a double quote, which shows up in the signature as '"'. it looks like vimscript grabs the results of the dict using repr, which escapes that default argument as the string \'"\', but vimscript will complain about "Missing comma in Dictionary" since it expects single quotes to be escaped by doubling them (''), so it detects python's escaping as the end of the string and then the dictionary looks malformed.

bbaldino commented 7 years ago

link to where i found out about the special case for escaping ': http://learnvimscriptthehardway.stevelosh.com/chapters/26.html#literal-strings

racko commented 7 years ago

Thanks! I ran into this issue but didn't know enough to fix it :)

Here's how to reproduce the issue:

$ echo "-std=c++14" > .clang_complete
$ echo "#include <iomanip>" > main.cpp

Now edit main.cpp in vim with clang_complete and enter std:: below the include to get the "Missing comma in Dictionary" error.

bbaldino commented 7 years ago

@racko np, glad it helped!

xaizek commented 6 years ago

Thanks!