Lines Matching +full:python3 +full:- +full:github

1 # This file is a minimal clang-format vim-integration. To install:
2 # - Change 'binary' if clang-format is not on the path (see below).
3 # - Add to your .vimrc:
6 # map <C-I> :pyf <path-to-this-file>/clang-format.py<cr>
7 # imap <C-I> <c-o>:pyf <path-to-this-file>/clang-format.py<cr>
8 # elseif has('python3')
9 # map <C-I> :py3f <path-to-this-file>/clang-format.py<cr>
10 # imap <C-I> <c-o>:py3f <path-to-this-file>/clang-format.py<cr>
13 # The if-elseif-endif conditional should pick either the python3 or python2
16 # The first mapping enables clang-format for NORMAL and VISUAL mode, the second
17 # mapping adds support for INSERT mode. Change "C-I" to another binding if you
18 # need clang-format on a different key (C-I stands for Ctrl+i).
20 # With this integration you can press the bound key and clang-format will
32 # : pyf <path-to-this-file>/clang-format.py
33 # : elseif has('python3')
34 # : py3f <path-to-this-file>/clang-format.py
50 # set g:clang_format_path to the path to clang-format if it is not on the path
51 # Change this to the full path if clang-format is not on the path.
52 binary = "clang-format"
57 # 'clang-format --help' for a list of supported styles. The default looks for
58 # a '.clang-format' or '_clang-format' file to indicate the style that should be
81 lines = ["--lines", vim.eval("l:lines")]
91 lines += ["--lines", "%s:%s" % (op[3] + 1, op[4])]
96 "--lines",
101 # Don't use line2byte: https://github.com/vim/vim/issues/5930
102 _, cursor_line, cursor_col, _ = vim.eval('getpos(".")') # 1-based
104 for line in text.split(b"\n")[: int(cursor_line) - 1]:
106 cursor_byte += int(cursor_col) - 1
111 # Avoid flashing an ugly, ugly cmd prompt on Windows when invoking clang-format.
119 command = [binary, "--cursor", str(cursor_byte)]
120 if lines != ["--lines", "all"]:
123 command.extend(["--style", style])
125 command.extend(["--fallback-style", fallback_style])
127 command.extend(["--assume-filename", vim.current.buffer.name])
143 "No output from clang-format (crashed?).\n"
148 header = json.loads(header.decode("utf-8"))
151 # the -lines specification requests them to remain unchanged.
152 lines = content.decode(encoding).split("\n")[:-1]
158 print("clang-format: incomplete (syntax errors)")
160 # Don't use goto: https://github.com/vim/vim/issues/5930
164 cursor_column = 1 + len(prefix.rsplit(b"\n", 1)[-1])