diff --git a/sources_non_forked/ale/ale_linters/elm/make.vim b/sources_non_forked/ale/ale_linters/elm/make.vim index ddea983f..76622028 100644 --- a/sources_non_forked/ale/ale_linters/elm/make.vim +++ b/sources_non_forked/ale/ale_linters/elm/make.vim @@ -137,9 +137,7 @@ function! ale_linters#elm#make#ParseMessageItem(item) abort endif endfunction -" Return the command to execute the linter in the projects directory. -" If it doesn't, then this will fail when imports are needed. -function! ale_linters#elm#make#GetCommand(buffer) abort +function! ale_linters#elm#make#GetPackageFile(buffer) abort let l:elm_json = ale#path#FindNearestFile(a:buffer, 'elm.json') if empty(l:elm_json) @@ -147,10 +145,55 @@ function! ale_linters#elm#make#GetCommand(buffer) abort let l:elm_json = ale#path#FindNearestFile(a:buffer, 'elm-package.json') endif + return l:elm_json +endfunction + +function! ale_linters#elm#make#IsVersionGte19(buffer) abort + let l:elm_json = ale_linters#elm#make#GetPackageFile(a:buffer) + + if l:elm_json =~# '-package' + return 0 + else + return 1 + endif +endfunction + +function! ale_linters#elm#make#GetRootDir(buffer) abort + let l:elm_json = ale_linters#elm#make#GetPackageFile(a:buffer) + if empty(l:elm_json) + return '' + else + return fnamemodify(l:elm_json, ':p:h') + endif +endfunction + +function! ale_linters#elm#make#IsTest(buffer) abort + let l:root_dir = ale_linters#elm#make#GetRootDir(a:buffer) + + if empty(l:root_dir) + return 0 + endif + + let l:tests_dir = join([l:root_dir, 'tests', ''], has('win32') ? '\' : '/') + + let l:buffer_path = fnamemodify(bufname(a:buffer), ':p') + + if stridx(l:buffer_path, l:tests_dir) == 0 + return 1 + else + return 0 + endif +endfunction + +" Return the command to execute the linter in the projects directory. +" If it doesn't, then this will fail when imports are needed. +function! ale_linters#elm#make#GetCommand(buffer) abort + let l:root_dir = ale_linters#elm#make#GetRootDir(a:buffer) + + if empty(l:root_dir) let l:dir_set_cmd = '' else - let l:root_dir = fnamemodify(l:elm_json, ':p:h') let l:dir_set_cmd = 'cd ' . ale#Escape(l:root_dir) . ' && ' endif @@ -161,11 +204,24 @@ function! ale_linters#elm#make#GetCommand(buffer) abort return l:dir_set_cmd . '%e make --report=json --output=/dev/null %t' endfunction +function! ale_linters#elm#make#GetExecutable(buffer) abort + let l:is_test = ale_linters#elm#make#IsTest(a:buffer) + let l:is_v19 = ale_linters#elm#make#IsVersionGte19(a:buffer) + + if l:is_test && l:is_v19 + return ale#node#FindExecutable( +\ a:buffer, +\ 'elm_make', +\ ['node_modules/.bin/elm-test', 'node_modules/.bin/elm'] +\ ) + else + return ale#node#FindExecutable(a:buffer, 'elm_make', ['node_modules/.bin/elm']) + endif +endfunction + call ale#linter#Define('elm', { \ 'name': 'make', -\ 'executable_callback': ale#node#FindExecutableFunc('elm_make', [ -\ 'node_modules/.bin/elm', -\ ]), +\ 'executable_callback': 'ale_linters#elm#make#GetExecutable', \ 'output_stream': 'both', \ 'command_callback': 'ale_linters#elm#make#GetCommand', \ 'callback': 'ale_linters#elm#make#Handle' diff --git a/sources_non_forked/ale/ale_linters/graphql/gqlint.vim b/sources_non_forked/ale/ale_linters/graphql/gqlint.vim index 882cc697..e45bf4c8 100644 --- a/sources_non_forked/ale/ale_linters/graphql/gqlint.vim +++ b/sources_non_forked/ale/ale_linters/graphql/gqlint.vim @@ -1,9 +1,15 @@ " Author: Michiel Westerbeek " Description: Linter for GraphQL Schemas +function! ale_linters#graphql#gqlint#GetCommand(buffer) abort + return ale#path#BufferCdString(a:buffer) + \ . 'gqlint' + \ . ' --reporter=simple %t' +endfunction + call ale#linter#Define('graphql', { \ 'name': 'gqlint', \ 'executable': 'gqlint', -\ 'command': 'gqlint --reporter=simple %t', +\ 'command_callback': 'ale_linters#graphql#gqlint#GetCommand', \ 'callback': 'ale#handlers#unix#HandleAsWarning', \}) diff --git a/sources_non_forked/ale/ale_linters/perl/perl.vim b/sources_non_forked/ale/ale_linters/perl/perl.vim index 1cb20fa7..4b954f0d 100644 --- a/sources_non_forked/ale/ale_linters/perl/perl.vim +++ b/sources_non_forked/ale/ale_linters/perl/perl.vim @@ -18,7 +18,7 @@ function! ale_linters#perl#perl#Handle(buffer, lines) abort return [] endif - let l:pattern = '\(.\+\) at \(.\+\) line \(\d\+\)' + let l:pattern = '\(..\{-}\) at \(..\{-}\) line \(\d\+\)' let l:output = [] let l:basename = expand('#' . a:buffer . ':t') diff --git a/sources_non_forked/ale/autoload/ale/c.vim b/sources_non_forked/ale/autoload/ale/c.vim index ce5105b6..617e81f6 100644 --- a/sources_non_forked/ale/autoload/ale/c.vim +++ b/sources_non_forked/ale/autoload/ale/c.vim @@ -48,26 +48,38 @@ endfunction function! ale#c#ParseCFlags(path_prefix, cflag_line) abort let l:cflags_list = [] - let l:previous_options = [] + let l:previous_options = '' - let l:split_lines = split(a:cflag_line, '-') + let l:split_lines = split(a:cflag_line, ' ') let l:option_index = 0 while l:option_index < len(l:split_lines) - let l:option = l:split_lines[l:option_index] + let l:option = l:previous_options . l:split_lines[l:option_index] let l:option_index = l:option_index + 1 - call add(l:previous_options, l:option) - " Check if cflag contained a '-' and should not have been splitted - let l:option_list = split(l:option, '\zs') - if len(l:option_list) > 0 && l:option_list[-1] isnot# ' ' && l:option_index < len(l:split_lines) + " Check if cflag contained an unmatched characters and should not have been splitted + let l:option_special = substitute(l:option, '\\"', '', 'g') + let l:option_special = substitute(l:option_special, '[^"''()`]', '', 'g') + let l:option_special = substitute(l:option_special, '""', '', 'g') + let l:option_special = substitute(l:option_special, '''''', '', 'g') + let l:option_special = substitute(l:option_special, '``', '', 'g') + let l:option_special = substitute(l:option_special, '((', '(', 'g') + let l:option_special = substitute(l:option_special, '))', ')', 'g') + let l:option_special = substitute(l:option_special, '()', '', 'g') + + if len(l:option_special) > 0 && l:option_index < len(l:split_lines) + let l:previous_options = l:option . ' ' continue endif - let l:option = join(l:previous_options, '-') - let l:previous_options = [] + " Check if there was spaces after -D/-I and the flag should not have been splitted + if l:option is# '-D' || l:option is# '-I' + let l:previous_options = l:option + continue + endif + + let l:previous_options = '' - let l:option = '-' . substitute(l:option, '^\s*\(.\{-}\)\s*$', '\1', '') " Fix relative paths if needed if stridx(l:option, '-I') >= 0 && diff --git a/sources_non_forked/ale/autoload/ale/definition.vim b/sources_non_forked/ale/autoload/ale/definition.vim index 984a4f9d..79d12596 100644 --- a/sources_non_forked/ale/autoload/ale/definition.vim +++ b/sources_non_forked/ale/autoload/ale/definition.vim @@ -86,7 +86,7 @@ function! s:OnReady(linter, lsp_details, line, column, options, ...) abort let l:request_id = ale#lsp#Send(l:id, l:message) let s:go_to_definition_map[l:request_id] = { - \ 'open_in_tab': get(a:options, 'open_in_tab', 0), + \ 'open_in': get(a:options, 'open_in', 'current-buffer'), \} endfunction diff --git a/sources_non_forked/ale/autoload/ale/fix.vim b/sources_non_forked/ale/autoload/ale/fix.vim index 03652ecf..423e85be 100644 --- a/sources_non_forked/ale/autoload/ale/fix.vim +++ b/sources_non_forked/ale/autoload/ale/fix.vim @@ -315,10 +315,10 @@ function! s:RunFixer(options) abort \ ? call(l:Function, [l:buffer, a:options.output]) \ : call(l:Function, [l:buffer, a:options.output, copy(l:input)]) else - " Chained commands accept (buffer, [input]) + " Chained commands accept (buffer, [done, input]) let l:result = ale#util#FunctionArgCount(l:Function) == 1 \ ? call(l:Function, [l:buffer]) - \ : call(l:Function, [l:buffer, copy(l:input)]) + \ : call(l:Function, [l:buffer, v:null, copy(l:input)]) endif if type(l:result) is v:t_number && l:result == 0 diff --git a/sources_non_forked/ale/autoload/ale/fixers/black.vim b/sources_non_forked/ale/autoload/ale/fixers/black.vim index 4169322a..27249c55 100644 --- a/sources_non_forked/ale/autoload/ale/fixers/black.vim +++ b/sources_non_forked/ale/autoload/ale/fixers/black.vim @@ -4,22 +4,28 @@ call ale#Set('python_black_executable', 'black') call ale#Set('python_black_use_global', get(g:, 'ale_use_global_executables', 0)) call ale#Set('python_black_options', '') +call ale#Set('python_black_auto_pipenv', 0) + +function! ale#fixers#black#GetExecutable(buffer) abort + if (ale#Var(a:buffer, 'python_auto_pipenv') || ale#Var(a:buffer, 'python_black_auto_pipenv')) + \ && ale#python#PipenvPresent(a:buffer) + return 'pipenv' + endif + + return ale#python#FindExecutable(a:buffer, 'python_black', ['black']) +endfunction function! ale#fixers#black#Fix(buffer) abort - let l:executable = ale#python#FindExecutable( - \ a:buffer, - \ 'python_black', - \ ['black'], - \) + let l:executable = ale#fixers#black#GetExecutable(a:buffer) - if !executable(l:executable) - return 0 - endif + let l:exec_args = l:executable =~? 'pipenv$' + \ ? ' run black' + \ : '' let l:options = ale#Var(a:buffer, 'python_black_options') return { - \ 'command': ale#Escape(l:executable) + \ 'command': ale#Escape(l:executable) . l:exec_args \ . (!empty(l:options) ? ' ' . l:options : '') \ . ' -', \} diff --git a/sources_non_forked/ale/autoload/ale/fixers/generic.vim b/sources_non_forked/ale/autoload/ale/fixers/generic.vim index cb8865b4..1d88553e 100644 --- a/sources_non_forked/ale/autoload/ale/fixers/generic.vim +++ b/sources_non_forked/ale/autoload/ale/fixers/generic.vim @@ -1,7 +1,7 @@ " Author: w0rp " Description: Generic functions for fixing files with. -function! ale#fixers#generic#RemoveTrailingBlankLines(buffer, lines) abort +function! ale#fixers#generic#RemoveTrailingBlankLines(buffer, done, lines) abort let l:end_index = len(a:lines) - 1 while l:end_index > 0 && empty(a:lines[l:end_index]) @@ -12,7 +12,7 @@ function! ale#fixers#generic#RemoveTrailingBlankLines(buffer, lines) abort endfunction " Remove all whitespaces at the end of lines -function! ale#fixers#generic#TrimWhitespace(buffer, lines) abort +function! ale#fixers#generic#TrimWhitespace(buffer, done, lines) abort let l:index = 0 let l:lines_new = range(len(a:lines)) diff --git a/sources_non_forked/ale/autoload/ale/fixers/generic_python.vim b/sources_non_forked/ale/autoload/ale/fixers/generic_python.vim index d55a23c3..9a929b96 100644 --- a/sources_non_forked/ale/autoload/ale/fixers/generic_python.vim +++ b/sources_non_forked/ale/autoload/ale/fixers/generic_python.vim @@ -2,7 +2,7 @@ " Description: Generic fixer functions for Python. " Add blank lines before control statements. -function! ale#fixers#generic_python#AddLinesBeforeControlStatements(buffer, lines) abort +function! ale#fixers#generic_python#AddLinesBeforeControlStatements(buffer, done, lines) abort let l:new_lines = [] let l:last_indent_size = 0 let l:last_line_is_blank = 0 @@ -41,7 +41,7 @@ endfunction " This function breaks up long lines so that autopep8 or other tools can " fix the badly-indented code which is produced as a result. -function! ale#fixers#generic_python#BreakUpLongLines(buffer, lines) abort +function! ale#fixers#generic_python#BreakUpLongLines(buffer, done, lines) abort " Default to a maximum line length of 79 let l:max_line_length = 79 let l:conf = ale#path#FindNearestFile(a:buffer, 'setup.cfg') diff --git a/sources_non_forked/ale/autoload/ale/fixers/help.vim b/sources_non_forked/ale/autoload/ale/fixers/help.vim index b20740fe..9fb0717b 100644 --- a/sources_non_forked/ale/autoload/ale/fixers/help.vim +++ b/sources_non_forked/ale/autoload/ale/fixers/help.vim @@ -1,7 +1,7 @@ " Author: w0rp " Description: Generic fixer functions for Vim help documents. -function! ale#fixers#help#AlignTags(buffer, lines) abort +function! ale#fixers#help#AlignTags(buffer, done, lines) abort let l:new_lines = [] for l:line in a:lines diff --git a/sources_non_forked/ale/autoload/ale/fixers/standard.vim b/sources_non_forked/ale/autoload/ale/fixers/standard.vim index 2b1f6f92..77712d40 100644 --- a/sources_non_forked/ale/autoload/ale/fixers/standard.vim +++ b/sources_non_forked/ale/autoload/ale/fixers/standard.vim @@ -14,9 +14,11 @@ endfunction function! ale#fixers#standard#Fix(buffer) abort let l:executable = ale#fixers#standard#GetExecutable(a:buffer) + let l:options = ale#Var(a:buffer, 'javascript_standard_options') return { \ 'command': ale#node#Executable(a:buffer, l:executable) + \ . (!empty(l:options) ? ' ' . l:options : '') \ . ' --fix %t', \ 'read_temporary_file': 1, \} diff --git a/sources_non_forked/ale/autoload/ale/job.vim b/sources_non_forked/ale/autoload/ale/job.vim index 0117c7dd..f9a917e1 100644 --- a/sources_non_forked/ale/autoload/ale/job.vim +++ b/sources_non_forked/ale/autoload/ale/job.vim @@ -173,10 +173,6 @@ endfunction function! ale#job#PrepareCommand(buffer, command) abort let l:wrapper = ale#Var(a:buffer, 'command_wrapper') - let l:command = !empty(l:wrapper) - \ ? s:PrepareWrappedCommand(l:wrapper, a:command) - \ : a:command - " The command will be executed in a subshell. This fixes a number of " issues, including reading the PATH variables correctly, %PATHEXT% " expansion on Windows, etc. @@ -184,6 +180,17 @@ function! ale#job#PrepareCommand(buffer, command) abort " NeoVim handles this issue automatically if the command is a String, " but we'll do this explicitly, so we use the same exact command for both " versions. + let l:command = !empty(l:wrapper) + \ ? s:PrepareWrappedCommand(l:wrapper, a:command) + \ : a:command + + " If a custom shell is specified, use that. + if exists('g:ale_shell') + let l:shell_arguments = get(g:, 'ale_shell_arguments', &shellcmdflag) + + return split(g:ale_shell) + split(l:shell_arguments) + [l:command] + endif + if has('win32') return 'cmd /s/c "' . l:command . '"' endif diff --git a/sources_non_forked/ale/autoload/ale/references.vim b/sources_non_forked/ale/autoload/ale/references.vim index d00a1fa9..24267bb4 100644 --- a/sources_non_forked/ale/autoload/ale/references.vim +++ b/sources_non_forked/ale/autoload/ale/references.vim @@ -27,6 +27,7 @@ function! ale#references#HandleTSServerResponse(conn_id, response) abort \ 'filename': l:response_item.file, \ 'line': l:response_item.start.line, \ 'column': l:response_item.start.offset, + \ 'match': substitute(l:response_item.lineText, '^\s*\(.\{-}\)\s*$', '\1', ''), \}) endfor diff --git a/sources_non_forked/ale/autoload/ale/util.vim b/sources_non_forked/ale/autoload/ale/util.vim index bb478957..ee9359f8 100644 --- a/sources_non_forked/ale/autoload/ale/util.vim +++ b/sources_non_forked/ale/autoload/ale/util.vim @@ -87,12 +87,25 @@ function! ale#util#GetFunction(string_or_ref) abort return a:string_or_ref endfunction +" Open the file (at the given line). +" options['open_in'] can be: +" current-buffer (default) +" tab +" vertical-split +" horizontal-split function! ale#util#Open(filename, line, column, options) abort - if get(a:options, 'open_in_tab', 0) - call ale#util#Execute('tabedit +' . a:line . ' ' . fnameescape(a:filename)) + let l:open_in = get(a:options, 'open_in', 'current-buffer') + let l:args_to_open = '+' . a:line . ' ' . fnameescape(a:filename) + + if l:open_in is# 'tab' + call ale#util#Execute('tabedit ' . l:args_to_open) + elseif l:open_in is# 'horizontal-split' + call ale#util#Execute('split ' . l:args_to_open) + elseif l:open_in is# 'vertical-split' + call ale#util#Execute('vsplit ' . l:args_to_open) elseif bufnr(a:filename) isnot bufnr('') " Open another file only if we need to. - call ale#util#Execute('edit +' . a:line . ' ' . fnameescape(a:filename)) + call ale#util#Execute('edit ' . l:args_to_open) else normal! m` endif diff --git a/sources_non_forked/ale/doc/ale-go.txt b/sources_non_forked/ale/doc/ale-go.txt index 43289bd5..3fbc6fb9 100644 --- a/sources_non_forked/ale/doc/ale-go.txt +++ b/sources_non_forked/ale/doc/ale-go.txt @@ -7,7 +7,7 @@ Integration Information The `gometalinter` linter is disabled by default. ALE enables `gofmt`, `golint` and `go vet` by default. It also supports `staticcheck`, `go -build`, `gosimple`, and `golangserver`. +build`, `gosimple`, `golangserver`. To enable `gometalinter`, update |g:ale_linters| as appropriate: > @@ -195,5 +195,21 @@ g:ale_go_golangci_lint_package *g:ale_go_golangci_lint_package* current file. +=============================================================================== +bingo *ale-go-bingo* + +g:ale_go_bingo_executable *g:ale_go_bingo_executable* + *b:ale_go_bingo_executable* + Type: |String| + Default: `'go-bingo'` + + Location of the go-bingo binary file. + +g:ale_go_bingo_options *g:ale_go_bingo_options* + *b:ale_go_bingo_options* + Type: |String| + Default: `''` + + =============================================================================== vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-python.txt b/sources_non_forked/ale/doc/ale-python.txt index f3f2801a..a1ad1500 100644 --- a/sources_non_forked/ale/doc/ale-python.txt +++ b/sources_non_forked/ale/doc/ale-python.txt @@ -75,7 +75,7 @@ g:ale_python_black_executable *g:ale_python_black_executable* See |ale-integrations-local-executables| -autopep8 + g:ale_python_black_options *g:ale_python_black_options* *b:ale_python_black_options* Type: |String| @@ -92,6 +92,15 @@ g:ale_python_black_use_global *g:ale_python_black_use_global* See |ale-integrations-local-executables| +g:ale_python_black_auto_pipenv *g:ale_python_black_auto_pipenv* + *b:ale_python_black_auto_pipenv* + Type: |Number| + Default: `0` + + Detect whether the file is inside a pipenv, and set the executable to `pipenv` + if true. This is overridden by a manually-set executable. + + =============================================================================== flake8 *ale-python-flake8* diff --git a/sources_non_forked/ale/doc/ale.txt b/sources_non_forked/ale/doc/ale.txt index 0b127725..1cfa7898 100644 --- a/sources_non_forked/ale/doc/ale.txt +++ b/sources_non_forked/ale/doc/ale.txt @@ -118,6 +118,7 @@ CONTENTS *ale-contents* staticcheck.........................|ale-go-staticcheck| golangserver........................|ale-go-golangserver| golangci-lint.......................|ale-go-golangci-lint| + bingo...............................|ale-go-bingo| graphql...............................|ale-graphql-options| eslint..............................|ale-graphql-eslint| gqlint..............................|ale-graphql-gqlint| @@ -438,7 +439,7 @@ Notes: * FusionScript: `fusion-lint` * Git Commit Messages: `gitlint` * GLSL: glslang, `glslls` -* Go: `gofmt`, `goimports`, `go mod`!!, `go vet`!!, `golint`, `gotype`!!, `gometalinter`!!, `go build`!!, `gosimple`!!, `staticcheck`!!, `golangserver`, `golangci-lint`!! +* Go: `gofmt`, `goimports`, `go mod`!!, `go vet`!!, `golint`, `gotype`!!, `gometalinter`!!, `go build`!!, `gosimple`!!, `staticcheck`!!, `golangserver`, `golangci-lint`!!, `bingo` * GraphQL: `eslint`, `gqlint`, `prettier` * Hack: `hack`, `hackfmt`, `hhast` * Haml: `haml-lint` @@ -675,10 +676,14 @@ The values for `g:ale_fixers` can be a list of |String|, |Funcref|, or for a function set in the ALE fixer registry. Each function for fixing errors must accept either one argument `(buffer)` or -two arguments `(buffer, lines)`, representing the buffer being fixed and the -lines to fix. The functions must return either `0`, for changing nothing, a -|List| for new lines to set, or a |Dictionary| for describing a command to be -run in the background. +three arguments `(buffer, done, lines)`, representing the buffer being fixed, +a function to call with results, and the lines to fix. The functions must +return either `0`, for changing nothing, a |List| for new lines to set, a +|Dictionary| for describing a command to be run in the background, or `v:true` +for indicating that results will be provided asynchronously via the `done` +callback. + +NOTE: The `done` function has not been implemented yet. Functions receiving a variable number of arguments will not receive the second argument `lines`. Functions should name two arguments if the `lines` argument @@ -836,6 +841,8 @@ information returned by LSP servers. The following commands are supported: |ALEGoToDefinition| - Open the definition of the symbol under the cursor. |ALEGoToDefinitionInTab| - The same, but for opening the file in a new tab. +|ALEGoToDefinitionInSplit| - The same, but in a new split. +|ALEGoToDefinitionInVSplit| - The same, but in a new vertical split. ------------------------------------------------------------------------------- @@ -1787,6 +1794,33 @@ g:ale_set_signs *g:ale_set_signs* To limit the number of signs ALE will set, see |g:ale_max_signs|. +g:ale_shell *g:ale_shell* + + Type: |String| + Default: not set + + Override the shell used by ALE for executing commands. ALE uses 'shell' by + default, but falls back in `/bin/sh` if the default shell looks like `fish` + or `pwsh`, which are not compatible with all of the commands run by ALE. The + shell specified with this option will be used even if it might not work in + all cases. + + For Windows, ALE uses `cmd` when this option isn't set. Setting this option + will apply shell escaping to the command string, even on Windows. + + NOTE: Consider setting |g:ale_shell_arguments| if this option is defined. + + +g:ale_shell_arguments *g:ale_shell_arguments* + + Type: |String| + Default: not set + + This option specifies the arguments to use for executing a command with a + custom shell, per |g:ale_shell|. If this option is not set, 'shellcmdflag' + will be used instead. + + g:ale_sign_column_always *g:ale_sign_column_always* Type: |Number| @@ -2262,6 +2296,22 @@ ALEGoToDefinitionInTab *ALEGoToDefinitionInTab* command. +ALEGoToDefinitionInSplit *ALEGoToDefinitionInSplit* + + The same as |ALEGoToDefinition|, but opens results in a new split. + + A plug mapping `(ale_go_to_definition_in_split)` is defined for this + command. + + +ALEGoToDefinitionInVSplit *ALEGoToDefinitionInVSplit* + + The same as |ALEGoToDefinition|, but opens results in a new vertical split. + + A plug mapping `(ale_go_to_definition_in_vsplit)` is defined for this + command. + + ALEHover *ALEHover* Print brief information about the symbol under the cursor, taken from any diff --git a/sources_non_forked/ale/plugin/ale.vim b/sources_non_forked/ale/plugin/ale.vim index 610ff142..f57a495c 100644 --- a/sources_non_forked/ale/plugin/ale.vim +++ b/sources_non_forked/ale/plugin/ale.vim @@ -188,7 +188,9 @@ command! -bar ALEFixSuggest :call ale#fix#registry#Suggest(&filetype) " Go to definition for tsserver and LSP command! -bar ALEGoToDefinition :call ale#definition#GoTo({}) -command! -bar ALEGoToDefinitionInTab :call ale#definition#GoTo({'open_in_tab': 1}) +command! -bar ALEGoToDefinitionInTab :call ale#definition#GoTo({'open_in': 'tab'}) +command! -bar ALEGoToDefinitionInSplit :call ale#definition#GoTo({'open_in': 'horizontal-split'}) +command! -bar ALEGoToDefinitionInVSplit :call ale#definition#GoTo({'open_in': 'vertical-split'}) " Find references for tsserver and LSP command! -bar ALEFindReferences :call ale#references#Find() @@ -222,6 +224,8 @@ nnoremap (ale_detail) :ALEDetail nnoremap (ale_fix) :ALEFix nnoremap (ale_go_to_definition) :ALEGoToDefinition nnoremap (ale_go_to_definition_in_tab) :ALEGoToDefinitionInTab +nnoremap (ale_go_to_definition_in_split) :ALEGoToDefinitionInSplit +nnoremap (ale_go_to_definition_in_vsplit) :ALEGoToDefinitionInVSplit nnoremap (ale_find_references) :ALEFindReferences nnoremap (ale_hover) :ALEHover nnoremap (ale_documentation) :ALEDocumentation diff --git a/sources_non_forked/auto-pairs/.gitignore b/sources_non_forked/auto-pairs/.gitignore deleted file mode 100644 index 926ccaaf..00000000 --- a/sources_non_forked/auto-pairs/.gitignore +++ /dev/null @@ -1 +0,0 @@ -doc/tags diff --git a/sources_non_forked/auto-pairs/README.md b/sources_non_forked/auto-pairs/README.md deleted file mode 100644 index 7cdcbf92..00000000 --- a/sources_non_forked/auto-pairs/README.md +++ /dev/null @@ -1,325 +0,0 @@ -Auto Pairs -========== -Insert or delete brackets, parens, quotes in pair. - -Installation ------------- -copy plugin/auto-pairs.vim to ~/.vim/plugin - -or if you are using `pathogen`: - -```git clone git://github.com/jiangmiao/auto-pairs.git ~/.vim/bundle/auto-pairs``` - -Features --------- -* Insert in pair - - input: [ - output: [|] - -* Delete in pair - - input: foo[] - output: foo - -* Insert new indented line after Return - - input: {|} (press at |) - output: { - | - } - -* Insert spaces before closing characters, only for [], (), {} - - input: {|} (press at |) - output: { | } - - input: {|} (press foo} at |) - output: { foo }| - - input: '|' (press at |) - output: ' |' - -* Skip ' when inside a word - - input: foo| (press ' at |) - output: foo' - -* Skip closed bracket. - - input: [] - output: [] - -* Ignore auto pair when previous character is \ - - input: "\' - output: "\'" - -* Fast Wrap - - input: |'hello' (press ( at |) - output: ('hello') - - wrap string, only support c style string - input: |'h\\el\'lo' (press ( at |) - output ('h\\ello\'') - - input: |[foo, bar()] (press ( at |) - output: ([foo, bar()]) - -* Quick move char to closed pair - - input: (|){["foo"]} (press at |) - output: ({["foo"]}|) - - input: |[foo, bar()] (press ( at |) - output: ([foo, bar()]|) - -* Quick jump to closed pair. - - input: - { - something;| - } - - (press } at |) - - output: - { - - }| - -* Support ``` ''' and """ - - input: - ''' - - output: - '''|''' - -* Delete Repeated Pairs in one time - - input: """|""" (press at |) - output: | - - input: {{|}} (press at |) - output: | - - input: [[[[[[|]]]]]] (press at |) - output: | - -* Fly Mode - - input: if(a[3) - output: if(a[3])| (In Fly Mode) - output: if(a[3)]) (Without Fly Mode) - - input: - { - hello();| - world(); - } - - (press } at |) - - output: - { - hello(); - world(); - }| - - (then press at | to do backinsert) - output: - { - hello();}| - world(); - } - - See Fly Mode section for details - -Fly Mode --------- -Fly Mode will always force closed-pair jumping instead of inserting. only for ")", "}", "]" - -If jumps in mistake, could use AutoPairsBackInsert(Default Key: ``) to jump back and insert closed pair. - -the most situation maybe want to insert single closed pair in the string, eg ")" - -Fly Mode is DISABLED by default. - -add **let g:AutoPairsFlyMode = 1** .vimrc to turn it on - -Default Options: - - let g:AutoPairsFlyMode = 0 - let g:AutoPairsShortcutBackInsert = '' - -Shortcuts ---------- - - System Shortcuts: - : Insert new indented line after return if cursor in blank brackets or quotes. - : Delete brackets in pair - : Toggle Autopairs (g:AutoPairsShortcutToggle) - : Fast Wrap (g:AutoPairsShortcutFastWrap) - : Jump to next closed pair (g:AutoPairsShortcutJump) - : BackInsert (g:AutoPairsShortcutBackInsert) - - If or conflict with another keys or want to bind to another keys, add - - let g:AutoPairsShortcutToggle = '' - - to .vimrc, if the key is empty string '', then the shortcut will be disabled. - -Options -------- -* g:AutoPairs - - Default: {'(':')', '[':']', '{':'}',"'":"'",'"':'"', '`':'`'} - -* b:AutoPairs - - Default: g:AutoPairs - - Buffer level pairs set. - -* g:AutoPairsShortcutToggle - - Default: '' - - The shortcut to toggle autopairs. - -* g:AutoPairsShortcutFastWrap - - Default: '' - - Fast wrap the word. all pairs will be consider as a block (include <>). - (|)'hello' after fast wrap at |, the word will be ('hello') - (|) after fast wrap at |, the word will be () - -* g:AutoPairsShortcutJump - - Default: '' - - Jump to the next closed pair - -* g:AutoPairsMapBS - - Default : 1 - - Map to delete brackets, quotes in pair - execute 'inoremap =AutoPairsDelete()' - -* g:AutoPairsMapCh - - Default : 1 - - Map to delete brackets, quotes in pair - -* g:AutoPairsMapCR - - Default : 1 - - Map to insert a new indented line if cursor in (|), {|} [|], '|', "|" - execute 'inoremap =AutoPairsReturn()' - -* g:AutoPairsCenterLine - - Default : 1 - - When g:AutoPairsMapCR is on, center current line after return if the line is at the bottom 1/3 of the window. - -* g:AutoPairsMapSpace - - Default : 1 - - Map to insert a space after the opening character and before the closing one. - execute 'inoremap =AutoPairsSpace()' - -* g:AutoPairsFlyMode - - Default : 0 - - set it to 1 to enable FlyMode. - see FlyMode section for details. - -* g:AutoPairsMultilineClose - - Default : 1 - - When you press the key for the closing pair (e.g. `)`) it jumps past it. - If set to 1, then it'll jump to the next line, if there is only whitespace. - If set to 0, then it'll only jump to a closing pair on the same line. - -* g:AutoPairsShortcutBackInsert - - Default : - - Work with FlyMode, insert the key at the Fly Mode jumped postion - -* g:AutoPairsMoveCharacter - - Default: "()[]{}\"'" - - Map to - move character under the cursor to the pair. - -Buffer Level Pairs Setting --------------------------- - -Set b:AutoPairs before BufEnter - -eg: - - " When the filetype is FILETYPE then make AutoPairs only match for parenthesis - au Filetype FILETYPE let b:AutoPairs = {"(": ")"} - -TroubleShooting ---------------- - The script will remap keys ([{'"}]) , - If auto pairs cannot work, use :imap ( to check if the map is corrected. - The correct map should be =AutoPairsInsert("\(") - Or the plugin conflict with some other plugins. - use command :call AutoPairsInit() to remap the keys. - - -* How to insert parens purely - - There are 3 ways - - 1. use Ctrl-V ) to insert paren without trigger the plugin. - - 2. use Alt-P to turn off the plugin. - - 3. use DEL or x to delete the character insert by plugin. - -* Swedish Character Conflict - - Because AutoPairs uses Meta(Alt) key as shortcut, it is conflict with some Swedish character such as å. - To fix the issue, you need remap or disable the related shortcut. - -Known Issues ------------------------ -Breaks '.' - [issue #3](https://github.com/jiangmiao/auto-pairs/issues/3) - - Description: After entering insert mode and inputing `[hello` then leave insert - mode by ``. press '.' will insert 'hello' instead of '[hello]'. - Reason: `[` actually equals `[]\` and \ will break '.'. - After version 7.4.849, Vim implements new keyword U to avoid the break - Solution: Update Vim to 7.4.849+ - -Contributors ------------- -* [camthompson](https://github.com/camthompson) - - -License -------- - -Copyright (C) 2011-2013 Miao Jiang - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/sources_non_forked/auto-pairs/doc/AutoPairs.txt b/sources_non_forked/auto-pairs/doc/AutoPairs.txt deleted file mode 100644 index afe589ef..00000000 --- a/sources_non_forked/auto-pairs/doc/AutoPairs.txt +++ /dev/null @@ -1,356 +0,0 @@ -*AutoPairs.txt* Insert or delete brackets, parens, quotes in pair - -Author: jiangmiao -License: MIT -URL: https://github.com/jiangmiao/auto-pairs - -============================================================================== -CONTENTS *autopairs-contents* - - 1. Installation ............................. |autopairs-installation| - 2. Features ..................................... |autopairs-features| - 3. Fly Mode ..................................... |autopairs-fly-mode| - 4. Shortcuts ................................... |autopairs-shortcuts| - 5. Options ....................................... |autopairs-options| - 6. Troubleshooting ...................... |autopairs-troubleshooting| - -============================================================================== -1. Introduction *autopairs-installation* - -Copy `plugin/auto-pairs.vim` to `~/.vim/plugin`. - -Or if you are using `pathogen`: > - - git clone git://github.com/jiangmiao/auto-pairs.git ~/.vim/bundle/auto-pairs - -============================================================================== -2. Features *autopairs-features* - -Insert in pair: > - - input: [ - output: [|] - -Delete in pair: > - - input: foo[] - output: foo - -Insert new indented line after Return: > - - input: {|} (press at |) - output: { - | - } - -Insert spaces before closing characters, only for [], (), {}: > - - input: {|} (press at |) - output: { | } - - input: {|} (press foo} at |) - output: { foo }| - - input: '|' (press at |) - output: ' |' - -Skip ' when inside a word: > - - input: foo| (press ' at |) - output: foo' - -Skip closed bracket: > - - input: [] - output: [] - -Ignore auto pair when previous character is '\': > - - input: "\' - output: "\'" - -Fast Wrap: > - - input: |'hello' (press ( at |) - output: ('hello') - - Wrap string, only support c style string. - input: |'h\\el\'lo' (press ( at |) - output ('h\\ello\'') - - input: |[foo, bar()] (press ( at |) - output: ([foo, bar()]) - -Quick jump to closed pair: > - - input: - { - something;| - } - - (press } at |) - - output: - { - - }| - -Support ```, ''' and """: > - - input: - ''' - - output: - '''|''' - -Delete Repeated Pairs in one time: > - - input: """|""" (press at |) - output: | - - input: {{|}} (press at |) - output: | - - input: [[[[[[|]]]]]] (press at |) - output: | - -Fly Mode (|autopairs-flymode|): > - - input: if(a[3) - output: if(a[3])| (In Fly Mode) - output: if(a[3)]) (Without Fly Mode) - - input: - { - hello();| - world(); - } - - (press } at |) - - output: - { - hello(); - world(); - }| - - (then press at | to do backinsert) - output: - { - hello();}| - world(); - } - - See |Fly Mode| section for details - -============================================================================== -3. Fly Mode *autopairs-flymode* - -Fly Mode will always force closed-pair jumping instead of inserting. Only for -")", "}", "]". If jumps in mistake, you can use |g:AutoPairsBackInsert| (default -Key: ) to jump back and insert closed pair. - -The most situation maybe you want to insert single closed pair in the string, -eg: > - - ")" - -Fly Mode is DISABLED by default. To enable Fly Mode add following to your -'.vimrc': > - - let g:AutoPairsFlyMode = 1 - -Default Options: > - - let g:AutoPairsFlyMode = 0 - let g:AutoPairsShortcutBackInsert = '' - -============================================================================== -4. Shortcuts *autopairs-shortcuts* - -System Shortcuts: - : Insert new indented line after return if cursor in blank brackets - or quotes. - : Delete brackets in pair - : Toggle Autopairs (|g:AutoPairsShortcutToggle|) - : Fast Wrap (|g:AutoPairsShortcutFastWrap|) - : Jump to next closed pair (|g:AutoPairsShortcutJump|) - : BackInsert (|g:AutoPairsShortcutBackInsert|) - - - To rebind keys , or or in case of conflicts with - another keys: - - let g:AutoPairsShortcutToggle = '' - - If the key is empty string '', then the shortcut will be disabled. - -============================================================================== -5. Options *autopairs-options* - - *g:AutoPairs* -|g:AutoPairs| dict - -Default: > - {'(':')', '[':']', '{':'}',"'":"'",'"':'"', '`':'`'} - -Specifies which symbols should be automatically paired. - -To append new pairs without overwriting defaults, add values in your `.vimrc`.: - - let g:AutoPairs['<']='>' - -This example will enable matching of `<` with `>`. - - - *b:AutoPairs* -|b:AutoPairs| dict - -Default: |g:AutoPairs| - -Buffer level pairs set. - -You can set |b:AutoPairs| before |BufEnter|: > - - au Filetype FILETYPE let b:AutoPairs = {"(": ")"} - -This sets |AutoPairs| to only match for parenthesis for 'FILETYPE'. - - - - *g:AutoPairsShortcutToggle* -|g:AutoPairsShortcutToggle| string - -Default: - -The shortcut to toggle autopairs. - - - - *g:AutoPairsShortcutFastWrap* -|g:AutoPairsShortcutFastWrap| string - -Default: - -Fast wrap the word. All pairs will be considered as a block (including <>). - - (|)'hello' after fast wrap at |, the word will be ('hello') - (|) after fast wrap at |, the word will be () - - - - *g:AutoPairsShortcutJump* -|g:AutoPairsShortcutJump| string - -Default: - -Jump to the next closed pair. - - - *g:AutoPairsShortcutBackInsert* -|g:AutoPairsShortcutBackInsert| string - -Default: - -Work with |autopairs-flymode|, insert the key at the Fly Mode jumped position. - - - - *g:AutoPairsMapBS* -|g:AutoPairsMapBS| int - -Default: 1 - -Map to delete brackets and quotes in pair, executes: - - inoremap =AutoPairsDelete() - - - *g:AutoPairsMapCh* -|g:AutoPairsMapCh| int - -Default: 1 - -Map to delete brackets and quotes in pair. - - - *g:AutoPairsMapCR* -|g:AutoPairsMapCR| int - -Default: 1 - -Map to insert a new indented line if cursor in (|), {|} [|], '|', "|". -Executes: - - inoremap =AutoPairsReturn() - - - *g:AutoPairsCenterLine* -|g:AutoPairsCenterLine| int - -Default: 1 - -When |g:AutoPairsMapCR| is on, center current line after return if the line -is at the bottom 1/3 of the window. - - - *g:AutoPairsMapSpace* -|g:AutoPairsMapSpace| int - -Default: 1 - -Map to insert a space after the opening character and before the -closing one. - -Executes: - - inoremap =AutoPairsSpace() - - - *g:AutoPairsFlyMode* -|g:AutoPairsFlyMode| int - -Default: 0 - -Set it to 1 to enable |autopairs-flymode|. - - - *g:AutoPairsMultilineClose* -|g:AutoPairsMultilineClose| int - -Default: 1 - -When you press the key for the closing pair (e.g. `)`) it jumps past it. -If set to 1, then it'll jump to the next line, if there is only 'whitespace'. -If set to 0, then it'll only jump to a closing pair on the same line. - -============================================================================== -6. Troubleshooting *autopairs-troubleshooting* - -This plugin remaps keys `([{'"}]) ` - -If auto pairs cannot work, use |:imap| to check if the map is corrected. - -The correct map should be: > - - =AutoPairsInsert("\(") - -Or the plugin conflicts with some other plugins. Use command: > - - :call AutoPairsInit() to remap the keys. - ---- How to insert parens purely? --- - -There are 3 ways: - - 1. Use Ctrl-V ) to insert paren without trigger the plugin. - - 2. Use Alt-P to turn off the plugin. - - 3. Use DEL or x to delete the character insert by plugin. - ---- Swedish Character Conflict --- - -Because AutoPairs uses Meta(Alt) key as a shortcut, it conflicts with some -Swedish character such as å. To fix the issue, you need remap or disable the -related shortcut. diff --git a/sources_non_forked/auto-pairs/plugin/auto-pairs.vim b/sources_non_forked/auto-pairs/plugin/auto-pairs.vim deleted file mode 100644 index b2a9af7d..00000000 --- a/sources_non_forked/auto-pairs/plugin/auto-pairs.vim +++ /dev/null @@ -1,582 +0,0 @@ -" Insert or delete brackets, parens, quotes in pairs. -" Maintainer: JiangMiao -" Contributor: camthompson -" Last Change: 2017-06-17 -" Version: 1.3.3 -" Homepage: http://www.vim.org/scripts/script.php?script_id=3599 -" Repository: https://github.com/jiangmiao/auto-pairs -" License: MIT - -if exists('g:AutoPairsLoaded') || &cp - finish -end -let g:AutoPairsLoaded = 1 - -if !exists('g:AutoPairs') - let g:AutoPairs = {'(':')', '[':']', '{':'}',"'":"'",'"':'"', '`':'`'} -end - -if !exists('g:AutoPairsParens') - let g:AutoPairsParens = {'(':')', '[':']', '{':'}'} -end - -if !exists('g:AutoPairsMapBS') - let g:AutoPairsMapBS = 1 -end - -" Map as the same BS -if !exists('g:AutoPairsMapCh') - let g:AutoPairsMapCh = 1 -end - -if !exists('g:AutoPairsMapCR') - let g:AutoPairsMapCR = 1 -end - -if !exists('g:AutoPairsMapSpace') - let g:AutoPairsMapSpace = 1 -end - -if !exists('g:AutoPairsCenterLine') - let g:AutoPairsCenterLine = 1 -end - -if !exists('g:AutoPairsShortcutToggle') - let g:AutoPairsShortcutToggle = '' -end - -if !exists('g:AutoPairsShortcutFastWrap') - let g:AutoPairsShortcutFastWrap = '' -end - -if !exists('g:AutoPairsMoveCharacter') - let g:AutoPairsMoveCharacter = "()[]{}\"'" -end - -if !exists('g:AutoPairsShortcutJump') - let g:AutoPairsShortcutJump = '' -endif - -" Fly mode will for closed pair to jump to closed pair instead of insert. -" also support AutoPairsBackInsert to insert pairs where jumped. -if !exists('g:AutoPairsFlyMode') - let g:AutoPairsFlyMode = 0 -endif - -" When skipping the closed pair, look at the current and -" next line as well. -if !exists('g:AutoPairsMultilineClose') - let g:AutoPairsMultilineClose = 1 -endif - -" Work with Fly Mode, insert pair where jumped -if !exists('g:AutoPairsShortcutBackInsert') - let g:AutoPairsShortcutBackInsert = '' -endif - -if !exists('g:AutoPairsSmartQuotes') - let g:AutoPairsSmartQuotes = 1 -endif - -" 7.4.849 support U to avoid breaking '.' -" Issue talk: https://github.com/jiangmiao/auto-pairs/issues/3 -" Vim note: https://github.com/vim/vim/releases/tag/v7.4.849 -if v:version > 704 || v:version == 704 && has("patch849") - let s:Go = "\U" -else - let s:Go = "" -endif - -let s:Left = s:Go."\" -let s:Right = s:Go."\" - - -" Will auto generated {']' => '[', ..., '}' => '{'}in initialize. -let g:AutoPairsClosedPairs = {} - - -function! AutoPairsInsert(key) - if !b:autopairs_enabled - return a:key - end - - let line = getline('.') - let pos = col('.') - 1 - let before = strpart(line, 0, pos) - let after = strpart(line, pos) - let next_chars = split(after, '\zs') - let current_char = get(next_chars, 0, '') - let next_char = get(next_chars, 1, '') - let prev_chars = split(before, '\zs') - let prev_char = get(prev_chars, -1, '') - - let eol = 0 - if col('$') - col('.') <= 1 - let eol = 1 - end - - " Ignore auto close if prev character is \ - if prev_char == '\' - return a:key - end - - " The key is difference open-pair, then it means only for ) ] } by default - if !has_key(b:AutoPairs, a:key) - let b:autopairs_saved_pair = [a:key, getpos('.')] - - " Skip the character if current character is the same as input - if current_char == a:key - return s:Right - end - - if !g:AutoPairsFlyMode - " Skip the character if next character is space - if current_char == ' ' && next_char == a:key - return s:Right.s:Right - end - - " Skip the character if closed pair is next character - if current_char == '' - if g:AutoPairsMultilineClose - let next_lineno = line('.')+1 - let next_line = getline(nextnonblank(next_lineno)) - let next_char = matchstr(next_line, '\s*\zs.') - else - let next_char = matchstr(line, '\s*\zs.') - end - if next_char == a:key - return "\e^a" - endif - endif - endif - - " Fly Mode, and the key is closed-pairs, search closed-pair and jump - if g:AutoPairsFlyMode && has_key(b:AutoPairsClosedPairs, a:key) - let n = stridx(after, a:key) - if n != -1 - return repeat(s:Right, n+1) - end - if search(a:key, 'W') - " force break the '.' when jump to different line - return "\" - endif - endif - - " Insert directly if the key is not an open key - return a:key - end - - let open = a:key - let close = b:AutoPairs[open] - - if current_char == close && open == close - return s:Right - end - - " Ignore auto close ' if follows a word - " MUST after closed check. 'hello|' - if a:key == "'" && prev_char =~ '\v\w' - return a:key - end - - " support for ''' ``` and """ - if open == close - " The key must be ' " ` - let pprev_char = line[col('.')-3] - if pprev_char == open && prev_char == open - " Double pair found - return repeat(a:key, 4) . repeat(s:Left, 3) - end - end - - let quotes_num = 0 - " Ignore comment line for vim file - if &filetype == 'vim' && a:key == '"' - if before =~ '^\s*$' - return a:key - end - if before =~ '^\s*"' - let quotes_num = -1 - end - end - - " Keep quote number is odd. - " Because quotes should be matched in the same line in most of situation - if g:AutoPairsSmartQuotes && open == close - " Remove \\ \" \' - let cleaned_line = substitute(line, '\v(\\.)', '', 'g') - let n = quotes_num - let pos = 0 - while 1 - let pos = stridx(cleaned_line, open, pos) - if pos == -1 - break - end - let n = n + 1 - let pos = pos + 1 - endwhile - if n % 2 == 1 - return a:key - endif - endif - - return open.close.s:Left -endfunction - -function! AutoPairsDelete() - if !b:autopairs_enabled - return "\" - end - - let line = getline('.') - let pos = col('.') - 1 - let current_char = get(split(strpart(line, pos), '\zs'), 0, '') - let prev_chars = split(strpart(line, 0, pos), '\zs') - let prev_char = get(prev_chars, -1, '') - let pprev_char = get(prev_chars, -2, '') - - if pprev_char == '\' - return "\" - end - - " Delete last two spaces in parens, work with MapSpace - if has_key(b:AutoPairs, pprev_char) && prev_char == ' ' && current_char == ' ' - return "\\" - endif - - " Delete Repeated Pair eg: '''|''' [[|]] {{|}} - if has_key(b:AutoPairs, prev_char) - let times = 0 - let p = -1 - while get(prev_chars, p, '') == prev_char - let p = p - 1 - let times = times + 1 - endwhile - - let close = b:AutoPairs[prev_char] - let left = repeat(prev_char, times) - let right = repeat(close, times) - - let before = strpart(line, pos-times, times) - let after = strpart(line, pos, times) - if left == before && right == after - return repeat("\\", times) - end - end - - - if has_key(b:AutoPairs, prev_char) - let close = b:AutoPairs[prev_char] - if match(line,'^\s*'.close, col('.')-1) != -1 - " Delete (|___) - let space = matchstr(line, '^\s*', col('.')-1) - return "\". repeat("\", len(space)+1) - elseif match(line, '^\s*$', col('.')-1) != -1 - " Delete (|__\n___) - let nline = getline(line('.')+1) - if nline =~ '^\s*'.close - if &filetype == 'vim' && prev_char == '"' - " Keep next line's comment - return "\" - end - - let space = matchstr(nline, '^\s*') - return "\\". repeat("\", len(space)+1) - end - end - end - - return "\" -endfunction - -function! AutoPairsJump() - call search('["\]'')}]','W') -endfunction -" string_chunk cannot use standalone -let s:string_chunk = '\v%(\\\_.|[^\1]|[\r\n]){-}' -let s:ss_pattern = '\v''' . s:string_chunk . '''' -let s:ds_pattern = '\v"' . s:string_chunk . '"' - -func! s:RegexpQuote(str) - return substitute(a:str, '\v[\[\{\(\<\>\)\}\]]', '\\&', 'g') -endf - -func! s:RegexpQuoteInSquare(str) - return substitute(a:str, '\v[\[\]]', '\\&', 'g') -endf - -" Search next open or close pair -func! s:FormatChunk(open, close) - let open = s:RegexpQuote(a:open) - let close = s:RegexpQuote(a:close) - let open2 = s:RegexpQuoteInSquare(a:open) - let close2 = s:RegexpQuoteInSquare(a:close) - if open == close - return '\v'.open.s:string_chunk.close - else - return '\v%(' . s:ss_pattern . '|' . s:ds_pattern . '|' . '[^'.open2.close2.']|[\r\n]' . '){-}(['.open2.close2.'])' - end -endf - -" Fast wrap the word in brackets -function! AutoPairsFastWrap() - let line = getline('.') - let current_char = line[col('.')-1] - let next_char = line[col('.')] - let open_pair_pattern = '\v[({\[''"]' - let at_end = col('.') >= col('$') - 1 - normal! x - " Skip blank - if next_char =~ '\v\s' || at_end - call search('\v\S', 'W') - let line = getline('.') - let next_char = line[col('.')-1] - end - - if has_key(b:AutoPairs, next_char) - let followed_open_pair = next_char - let inputed_close_pair = current_char - let followed_close_pair = b:AutoPairs[next_char] - if followed_close_pair != followed_open_pair - " TODO replace system searchpair to skip string and nested pair. - " eg: (|){"hello}world"} will transform to ({"hello})world"} - call searchpair('\V'.followed_open_pair, '', '\V'.followed_close_pair, 'W') - else - call search(s:FormatChunk(followed_open_pair, followed_close_pair), 'We') - end - return s:Right.inputed_close_pair.s:Left - else - normal! he - return s:Right.current_char.s:Left - end -endfunction - -function! AutoPairsMap(key) - " | is special key which separate map command from text - let key = a:key - if key == '|' - let key = '' - end - let escaped_key = substitute(key, "'", "''", 'g') - " use expr will cause search() doesn't work - execute 'inoremap '.key." =AutoPairsInsert('".escaped_key."')" - -endfunction - -function! AutoPairsToggle() - if b:autopairs_enabled - let b:autopairs_enabled = 0 - echo 'AutoPairs Disabled.' - else - let b:autopairs_enabled = 1 - echo 'AutoPairs Enabled.' - end - return '' -endfunction - -function! AutoPairsMoveCharacter(key) - let c = getline(".")[col(".")-1] - let escaped_key = substitute(a:key, "'", "''", 'g') - return "\\:call search("."'".escaped_key."'".")\a".c."\" -endfunction - -function! AutoPairsReturn() - if b:autopairs_enabled == 0 - return '' - end - let line = getline('.') - let pline = getline(line('.')-1) - let prev_char = pline[strlen(pline)-1] - let cmd = '' - let cur_char = line[col('.')-1] - if has_key(b:AutoPairs, prev_char) && b:AutoPairs[prev_char] == cur_char - if g:AutoPairsCenterLine && winline() * 3 >= winheight(0) * 2 - " Recenter before adding new line to avoid replacing line content - let cmd = "zz" - end - - " If equalprg has been set, then avoid call = - " https://github.com/jiangmiao/auto-pairs/issues/24 - if &equalprg != '' - return "\".cmd."O" - endif - - " conflict with javascript and coffee - " javascript need indent new line - " coffeescript forbid indent new line - if &filetype == 'coffeescript' || &filetype == 'coffee' - return "\".cmd."k==o" - else - return "\".cmd."=ko" - endif - end - return '' -endfunction - -function! AutoPairsSpace() - let line = getline('.') - let prev_char = line[col('.')-2] - let cmd = '' - let cur_char =line[col('.')-1] - if has_key(g:AutoPairsParens, prev_char) && g:AutoPairsParens[prev_char] == cur_char - let cmd = "\".s:Left - endif - return "\".cmd -endfunction - -function! AutoPairsBackInsert() - if exists('b:autopairs_saved_pair') - let pair = b:autopairs_saved_pair[0] - let pos = b:autopairs_saved_pair[1] - call setpos('.', pos) - return pair - endif - return '' -endfunction - -function! AutoPairsInit() - let b:autopairs_loaded = 1 - if !exists('b:autopairs_enabled') - let b:autopairs_enabled = 1 - end - let b:AutoPairsClosedPairs = {} - - if !exists('b:AutoPairs') - let b:AutoPairs = g:AutoPairs - end - - if !exists('b:AutoPairsMoveCharacter') - let b:AutoPairsMoveCharacter = g:AutoPairsMoveCharacter - end - - " buffer level map pairs keys - for [open, close] in items(b:AutoPairs) - call AutoPairsMap(open) - if open != close - call AutoPairsMap(close) - end - let b:AutoPairsClosedPairs[close] = open - endfor - - for key in split(b:AutoPairsMoveCharacter, '\s*') - let escaped_key = substitute(key, "'", "''", 'g') - execute 'inoremap =AutoPairsMoveCharacter('".escaped_key."')" - endfor - - " Still use level mapping for - if g:AutoPairsMapBS - " Use instead of for issue #14 sometimes press BS output strange words - execute 'inoremap =AutoPairsDelete()' - end - - if g:AutoPairsMapCh - execute 'inoremap =AutoPairsDelete()' - endif - - if g:AutoPairsMapSpace - " Try to respect abbreviations on a - let do_abbrev = "" - if v:version == 703 && has("patch489") || v:version > 703 - let do_abbrev = "" - endif - execute 'inoremap '.do_abbrev.'=AutoPairsSpace()' - end - - if g:AutoPairsShortcutFastWrap != '' - execute 'inoremap '.g:AutoPairsShortcutFastWrap.' =AutoPairsFastWrap()' - end - - if g:AutoPairsShortcutBackInsert != '' - execute 'inoremap '.g:AutoPairsShortcutBackInsert.' =AutoPairsBackInsert()' - end - - if g:AutoPairsShortcutToggle != '' - " use to ensure showing the status when toggle - execute 'inoremap '.g:AutoPairsShortcutToggle.' AutoPairsToggle()' - execute 'noremap '.g:AutoPairsShortcutToggle.' :call AutoPairsToggle()' - end - - if g:AutoPairsShortcutJump != '' - execute 'inoremap ' . g:AutoPairsShortcutJump. ' :call AutoPairsJump()a' - execute 'noremap ' . g:AutoPairsShortcutJump. ' :call AutoPairsJump()' - end - -endfunction - -function! s:ExpandMap(map) - let map = a:map - let map = substitute(map, '\(\w\+\)', '\=maparg(submatch(1), "i")', 'g') - return map -endfunction - -function! AutoPairsTryInit() - if exists('b:autopairs_loaded') - return - end - - " for auto-pairs starts with 'a', so the priority is higher than supertab and vim-endwise - " - " vim-endwise doesn't support AutoPairsReturn - " when use AutoPairsReturn will cause isn't expanded - " - " supertab doesn't support AutoPairsReturn - " when use AutoPairsReturn will cause Duplicated - " - " and when load after vim-endwise will cause unexpected endwise inserted. - " so always load AutoPairs at last - - " Buffer level keys mapping - " comptible with other plugin - if g:AutoPairsMapCR - if v:version == 703 && has('patch32') || v:version > 703 - " VIM 7.3 supports advancer maparg which could get info - " then auto-pairs could remap in any case. - let info = maparg('', 'i', 0, 1) - if empty(info) - let old_cr = '' - let is_expr = 0 - else - let old_cr = info['rhs'] - let old_cr = s:ExpandMap(old_cr) - let old_cr = substitute(old_cr, '', '' . info['sid'] . '_', 'g') - let is_expr = info['expr'] - let wrapper_name = 'AutoPairsOldCRWrapper73' - endif - else - " VIM version less than 7.3 - " the mapping's info is lost, so guess it is expr or not, it's - " not accurate. - let old_cr = maparg('', 'i') - if old_cr == '' - let old_cr = '' - let is_expr = 0 - else - let old_cr = s:ExpandMap(old_cr) - " old_cr contain (, I guess the old cr is in expr mode - let is_expr = old_cr =~ '\V(' && toupper(old_cr) !~ '\V' - - " The old_cr start with " it must be in expr mode - let is_expr = is_expr || old_cr =~ '\v^"' - let wrapper_name = 'AutoPairsOldCRWrapper' - end - end - - if old_cr !~ 'AutoPairsReturn' - if is_expr - " remap to `name` to avoid mix expr and non-expr mode - execute 'inoremap