]> git.madduck.net Git - etc/vim.git/blob - plugin/black.vim

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

Remove misleading phrase in Usage and Configuration (#3492)
[etc/vim.git] / plugin / black.vim
1 " black.vim
2 " Author: Łukasz Langa
3 " Created: Mon Mar 26 23:27:53 2018 -0700
4 " Requires: Vim Ver7.0+
5 " Version:  1.2
6 "
7 " Documentation:
8 "   This plugin formats Python files.
9 "
10 " History:
11 "  1.0:
12 "    - initial version
13 "  1.1:
14 "    - restore cursor/window position after formatting
15 "  1.2:
16 "    - use autoload script
17
18 if exists("g:load_black")
19   finish
20 endif
21
22 if v:version < 700 || !has('python3')
23     func! __BLACK_MISSING()
24         echo "The black.vim plugin requires vim7.0+ with Python 3.6 support."
25     endfunc
26     command! Black :call __BLACK_MISSING()
27     command! BlackUpgrade :call __BLACK_MISSING()
28     command! BlackVersion :call __BLACK_MISSING()
29     finish
30 endif
31
32 let g:load_black = "py1.0"
33 if !exists("g:black_virtualenv")
34   if has("nvim")
35     let g:black_virtualenv = "~/.local/share/nvim/black"
36   else
37     let g:black_virtualenv = "~/.vim/black"
38   endif
39 endif
40 if !exists("g:black_fast")
41   let g:black_fast = 0
42 endif
43 if !exists("g:black_linelength")
44   let g:black_linelength = 88
45 endif
46 if !exists("g:black_skip_string_normalization")
47   if exists("g:black_string_normalization")
48     let g:black_skip_string_normalization = !g:black_string_normalization
49   else
50     let g:black_skip_string_normalization = 0
51   endif
52 endif
53 if !exists("g:black_skip_magic_trailing_comma")
54   if exists("g:black_magic_trailing_comma")
55     let g:black_skip_magic_trailing_comma = !g:black_magic_trailing_comma
56   else
57     let g:black_skip_magic_trailing_comma = 0
58   endif
59 endif
60 if !exists("g:black_quiet")
61   let g:black_quiet = 0
62 endif
63 if !exists("g:black_target_version")
64   let g:black_target_version = ""
65 endif
66 if !exists("g:black_use_virtualenv")
67   let g:black_use_virtualenv = 1
68 endif
69 if !exists("g:black_preview")
70   let g:black_preview = 0
71 endif
72
73 function BlackComplete(ArgLead, CmdLine, CursorPos)
74   return [
75 \    'target_version=py27',
76 \    'target_version=py36',
77 \    'target_version=py37',
78 \    'target_version=py38',
79 \    'target_version=py39',
80 \    'target_version=py310',
81 \  ]
82 endfunction
83
84 command! -nargs=* -complete=customlist,BlackComplete Black :call black#Black(<f-args>)
85 command! BlackUpgrade :call black#BlackUpgrade()
86 command! BlackVersion :call black#BlackVersion()