[PATCH] D33273: Recommit "[include-fixer] Don't throw exception when parsing unknown ar… …guments in vim script."

Haojian Wu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed May 17 05:33:19 PDT 2017


hokein created this revision.

To make it work in neovim.


https://reviews.llvm.org/D33273

Files:
  include-fixer/tool/clang-include-fixer.py


Index: include-fixer/tool/clang-include-fixer.py
===================================================================
--- include-fixer/tool/clang-include-fixer.py
+++ include-fixer/tool/clang-include-fixer.py
@@ -136,7 +136,12 @@
                       help='clang-include-fixer input format.')
   parser.add_argument('-input', default='',
                       help='String to initialize the database.')
-  args = parser.parse_args()
+  # Don't throw exception when parsing unknown arguements to make the script
+  # work in neovim.
+  # Neovim (at least v0.2.1) somehow mangles the sys.argv in a weird way: it
+  # will pass additional arguments (e.g. "-c script_host.py") to sys.argv,
+  # which makes the script fail.
+  args, _ = parser.parse_known_args()
 
   # Get the current text.
   buf = vim.current.buffer


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D33273.99275.patch
Type: text/x-patch
Size: 819 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170517/b890fef7/attachment.bin>


More information about the cfe-commits mailing list