diff --git a/README.md b/README.md index b7b09cb8..95a7a35d 100644 --- a/README.md +++ b/README.md @@ -73,10 +73,6 @@ Colors when editing a Python file: ![Screenshot 1](https://dnp4pehkvoo6n.cloudfront.net/07583008e4da885801657e8781777844/as/Python%20editing.png) -Opening recently opened files with the [mru.vim](https://github.com/vim-scripts/mru.vim) plugin: - -![Screenshot 2](https://dnp4pehkvoo6n.cloudfront.net/1d49a88f9bd5d013c025bb1e1272a7d8/as/MRU%20plugin.png) - [NERD Tree](https://github.com/scrooloose/nerdtree) plugin in a terminal window: ![Screenshot 3](https://dnp4pehkvoo6n.cloudfront.net/ae719203166585d64728f28398f4b1b7/as/Terminal%20usage.png) @@ -94,7 +90,6 @@ I recommend reading the docs of these plugins to understand them better. Each pl * [goyo.vim](https://github.com/junegunn/goyo.vim) and [vim-zenroom2](https://github.com/amix/vim-zenroom2): * [lightline.vim](https://github.com/itchyny/lightline.vim): A light and configurable statusline/tabline for Vim * [NERD Tree](https://github.com/scrooloose/nerdtree): A tree explorer plugin for vim -* [mru.vim](https://github.com/vim-scripts/mru.vim): Plugin to manage Most Recently Used (MRU) files. This plugin can be opened with `` * [open_file_under_cursor.vim](https://github.com/amix/open_file_under_cursor.vim): Open file under cursor when pressing `gf` * [pathogen.vim](https://github.com/tpope/vim-pathogen): Manage your vim runtimepath * [snipmate.vim](https://github.com/garbas/vim-snipmate): snipmate.vim aims to be a concise vim script that implements some of TextMate's snippets features in Vim @@ -232,7 +227,7 @@ Surround the visual selection in parenthesis/brackets/etc.: vnoremap $3 `>a}` vnoremap $$ `>a"` vnoremap $q `>a'` - vnoremap $e `>a"` + vnoremap $e `>a`` ### Insert mode mappings @@ -278,13 +273,16 @@ Open [bufexplorer](https://github.com/vim-scripts/bufexplorer.zip) to see and ma map o :BufExplorer -Open [MRU.vim](https://github.com/vim-scripts/mru.vim) to see the recently open files (`f`): +Open [ctrlp.vim](https://github.com/kien/ctrlp.vim) plugin to quickly find a file or a buffer (`j` or `f`): + " Quickly find and open a file in the CWD + let g:ctrlp_map = '' + + " Quickly find and open a recently opened file map f :MRU -Open [ctrlp.vim](https://github.com/kien/ctrlp.vim) plugin to quickly find a file or a buffer (`j` or `f`): - - let g:ctrlp_map = '' + " Quickly find and open a buffer + map b :CtrlPBuffer [NERD Tree](https://github.com/scrooloose/nerdtree) mappings: @@ -372,8 +370,8 @@ Just do following: * Remove any lines that reference `.vim_runtime` in your `~/.vimrc` -## Doist +## Looking for a remote-first job? -Maintaining this Vim configuration isn't my day job. Daily I am the founder of [Doist](https://doist.com/). You could come and help us build the workplace of the future while living a balanced life (anywhere in the world 🌍🌎🌏). +Maintaining this Vim configuration isn't my day job. Daily I am the founder/CEO of [Doist](https://doist.com/). You could come and help us build the workplace of the future while living a balanced life (anywhere in the world 🌍🌎🌏). PS: Using Vim isn't a requirement 😄 diff --git a/install_awesome_parameterized.sh b/install_awesome_parameterized.sh index d83f6dc6..ee4be411 100755 --- a/install_awesome_parameterized.sh +++ b/install_awesome_parameterized.sh @@ -16,9 +16,9 @@ source $1/my_configs.vim catch endtry" -if [ $2 == "--all" ]; then - USERS=($(ls -l /home | awk '{if(NR>1)print $9}')) - for user in ${USERS[*]}; do +if [ "$2" = "--all" ]; then + USERS=$(ls -l /home | awk '{if(NR>1)print $9}') + for user in $USERS; do homepath=$(eval echo "~$user") IFS='' echo $VIMRC > ${homepath}/.vimrc @@ -28,9 +28,9 @@ if [ $2 == "--all" ]; then echo "Installed the Ultimate Vim configuration successfully! Enjoy :-)" exit 0 else - SELECTED_USERS=(${@:2}) - echo "Selected users: ${SELECTED_USERS[@]}" - for user in ${SELECTED_USERS[@]}; do + SELECTED_USERS=${@:2} + echo "Selected users: $SELECTED_USERS" + for user in $SELECTED_USERS; do homepath=$(eval echo "~$user") IFS='' echo $VIMRC > ${homepath}/.vimrc diff --git a/sources_non_forked/ale/LICENSE b/sources_non_forked/ale/LICENSE index f8f3524d..471776e4 100644 --- a/sources_non_forked/ale/LICENSE +++ b/sources_non_forked/ale/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2016-2019, w0rp +Copyright (c) 2016-2020, w0rp All rights reserved. Redistribution and use in source and binary forms, with or without diff --git a/sources_non_forked/ale/ale_linters/ada/gcc.vim b/sources_non_forked/ale/ale_linters/ada/gcc.vim index 87496b81..5afc9ae3 100644 --- a/sources_non_forked/ale/ale_linters/ada/gcc.vim +++ b/sources_non_forked/ale/ale_linters/ada/gcc.vim @@ -18,7 +18,7 @@ function! ale_linters#ada#gcc#GetCommand(buffer) abort " -gnatc: Check syntax and semantics only (no code generation attempted) return '%e -x ada -c -gnatc' \ . ' -o ' . ale#Escape(l:out_file) - \ . ' -I ' . ale#Escape(fnamemodify(bufname(a:buffer), ':p:h')) + \ . ' -I %s:h' \ . ale#Pad(ale#Var(a:buffer, 'ada_gcc_options')) \ . ' %t' endfunction diff --git a/sources_non_forked/ale/ale_linters/asciidoc/languagetool.vim b/sources_non_forked/ale/ale_linters/asciidoc/languagetool.vim new file mode 100644 index 00000000..8e8de7f3 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/asciidoc/languagetool.vim @@ -0,0 +1,5 @@ +" Author: Horacio Sanson (hsanson [ät] gmail.com) +" Description: languagetool for asciidoc files, copied from markdown. + + +call ale#handlers#languagetool#DefineLinter('asciidoc') diff --git a/sources_non_forked/ale/ale_linters/asm/gcc.vim b/sources_non_forked/ale/ale_linters/asm/gcc.vim index eecab6ef..cda38923 100644 --- a/sources_non_forked/ale/ale_linters/asm/gcc.vim +++ b/sources_non_forked/ale/ale_linters/asm/gcc.vim @@ -9,7 +9,7 @@ function! ale_linters#asm#gcc#GetCommand(buffer) abort " -fsyntax-only doesn't catch everything. return '%e -x assembler' \ . ' -o ' . g:ale#util#nul_file - \ . '-iquote ' . ale#Escape(fnamemodify(bufname(a:buffer), ':p:h')) + \ . '-iquote %s:h' \ . ' ' . ale#Var(a:buffer, 'asm_gcc_options') . ' -' endfunction diff --git a/sources_non_forked/ale/ale_linters/bats/shellcheck.vim b/sources_non_forked/ale/ale_linters/bats/shellcheck.vim new file mode 100644 index 00000000..5c2a0ea9 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/bats/shellcheck.vim @@ -0,0 +1,4 @@ +" Author: Ian2020 +" Description: shellcheck linter for bats scripts. + +call ale#handlers#shellcheck#DefineLinter('bats') diff --git a/sources_non_forked/ale/ale_linters/bib/bibclean.vim b/sources_non_forked/ale/ale_linters/bib/bibclean.vim index 9056a9c3..f1610e00 100644 --- a/sources_non_forked/ale/ale_linters/bib/bibclean.vim +++ b/sources_non_forked/ale/ale_linters/bib/bibclean.vim @@ -18,7 +18,12 @@ function! ale_linters#bib#bibclean#get_type(str) abort endfunction function! ale_linters#bib#bibclean#match_msg(line) abort - return matchlist(a:line, '^\(.*\) "stdin", line \(.*\): \(.*\)$') + " Legacy message pattern works for bibclean <= v2.11.4. If empty, try + " the new message pattern for bibtex > v2.11.4 + let l:matches_legacy = matchlist(a:line, '^\(.*\) "stdin", line \(\d\+\): \(.*\)$') + + return ! empty(l:matches_legacy) ? l:matches_legacy + \ : matchlist(a:line, '^\(.*\) stdin:\(\d\+\):\(.*\)$') endfunction function! ale_linters#bib#bibclean#match_entry(line) abort diff --git a/sources_non_forked/ale/ale_linters/c/cc.vim b/sources_non_forked/ale/ale_linters/c/cc.vim new file mode 100644 index 00000000..5655fbf7 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/c/cc.vim @@ -0,0 +1,53 @@ +" Author: w0rp +" Description: A C compiler linter for C files with gcc/clang, etc. + +call ale#Set('c_cc_executable', '') +call ale#Set('c_cc_options', '-std=c11 -Wall') + +function! ale_linters#c#cc#GetExecutable(buffer) abort + let l:executable = ale#Var(a:buffer, 'c_cc_executable') + + " Default to either clang or gcc. + if l:executable is# '' + if ale#engine#IsExecutable(a:buffer, 'clang') + let l:executable = 'clang' + else + let l:executable = 'gcc' + endif + endif + + return l:executable +endfunction + +function! ale_linters#c#cc#GetCommand(buffer, output) abort + let l:cflags = ale#c#GetCFlags(a:buffer, a:output) + let l:ale_flags = ale#Var(a:buffer, 'c_cc_options') + + if l:cflags =~# '-std=' + let l:ale_flags = substitute( + \ l:ale_flags, + \ '-std=\(c\|gnu\)[0-9]\{2\}', + \ '', + \ 'g') + endif + + " -iquote with the directory the file is in makes #include work for + " headers in the same directory. + " + " `-o /dev/null` or `-o null` is needed to catch all errors, + " -fsyntax-only doesn't catch everything. + return '%e -S -x c' + \ . ' -o ' . g:ale#util#nul_file + \ . ' -iquote %s:h' + \ . ale#Pad(l:cflags) + \ . ale#Pad(l:ale_flags) . ' -' +endfunction + +call ale#linter#Define('c', { +\ 'name': 'cc', +\ 'aliases': ['gcc', 'clang'], +\ 'output_stream': 'stderr', +\ 'executable': function('ale_linters#c#cc#GetExecutable'), +\ 'command': {b -> ale#c#RunMakeCommand(b, function('ale_linters#c#cc#GetCommand'))}, +\ 'callback': 'ale#handlers#gcc#HandleGCCFormatWithIncludes', +\}) diff --git a/sources_non_forked/ale/ale_linters/c/ccls.vim b/sources_non_forked/ale/ale_linters/c/ccls.vim index 9e3dafe9..9f105712 100644 --- a/sources_non_forked/ale/ale_linters/c/ccls.vim +++ b/sources_non_forked/ale/ale_linters/c/ccls.vim @@ -3,6 +3,7 @@ call ale#Set('c_ccls_executable', 'ccls') call ale#Set('c_ccls_init_options', {}) +call ale#Set('c_build_dir', '') call ale#linter#Define('c', { \ 'name': 'ccls', @@ -10,5 +11,5 @@ call ale#linter#Define('c', { \ 'executable': {b -> ale#Var(b, 'c_ccls_executable')}, \ 'command': '%e', \ 'project_root': function('ale#handlers#ccls#GetProjectRoot'), -\ 'initialization_options': {b -> ale#Var(b, 'c_ccls_init_options')}, +\ 'initialization_options': {b -> ale#handlers#ccls#GetInitOpts(b, 'c_ccls_init_options')}, \}) diff --git a/sources_non_forked/ale/ale_linters/c/clang.vim b/sources_non_forked/ale/ale_linters/c/clang.vim deleted file mode 100644 index 681101fc..00000000 --- a/sources_non_forked/ale/ale_linters/c/clang.vim +++ /dev/null @@ -1,24 +0,0 @@ -" Author: Masahiro H https://github.com/mshr-h -" Description: clang linter for c files - -call ale#Set('c_clang_executable', 'clang') -call ale#Set('c_clang_options', '-std=c11 -Wall') - -function! ale_linters#c#clang#GetCommand(buffer, output) abort - let l:cflags = ale#c#GetCFlags(a:buffer, a:output) - - " -iquote with the directory the file is in makes #include work for - " headers in the same directory. - return '%e -S -x c -fsyntax-only' - \ . ' -iquote ' . ale#Escape(fnamemodify(bufname(a:buffer), ':p:h')) - \ . ale#Pad(l:cflags) - \ . ale#Pad(ale#Var(a:buffer, 'c_clang_options')) . ' -' -endfunction - -call ale#linter#Define('c', { -\ 'name': 'clang', -\ 'output_stream': 'stderr', -\ 'executable': {b -> ale#Var(b, 'c_clang_executable')}, -\ 'command': {b -> ale#c#RunMakeCommand(b, function('ale_linters#c#clang#GetCommand'))}, -\ 'callback': 'ale#handlers#gcc#HandleGCCFormatWithIncludes', -\}) diff --git a/sources_non_forked/ale/ale_linters/c/cppcheck.vim b/sources_non_forked/ale/ale_linters/c/cppcheck.vim index 309b2851..b671fc8b 100644 --- a/sources_non_forked/ale/ale_linters/c/cppcheck.vim +++ b/sources_non_forked/ale/ale_linters/c/cppcheck.vim @@ -10,9 +10,11 @@ function! ale_linters#c#cppcheck#GetCommand(buffer) abort let l:buffer_path_include = empty(l:compile_commands_option) \ ? ale#handlers#cppcheck#GetBufferPathIncludeOptions(a:buffer) \ : '' + let l:template = ' --template=''{file}:{line}:{column}: {severity}:{inconclusive:inconclusive:} {message} [{id}]\\n{code}''' return l:cd_command \ . '%e -q --language=c' + \ . l:template \ . ale#Pad(l:compile_commands_option) \ . ale#Pad(ale#Var(a:buffer, 'c_cppcheck_options')) \ . l:buffer_path_include diff --git a/sources_non_forked/ale/ale_linters/c/gcc.vim b/sources_non_forked/ale/ale_linters/c/gcc.vim deleted file mode 100644 index 1df1018e..00000000 --- a/sources_non_forked/ale/ale_linters/c/gcc.vim +++ /dev/null @@ -1,28 +0,0 @@ -" Author: w0rp -" Description: gcc linter for c files - -call ale#Set('c_gcc_executable', 'gcc') -call ale#Set('c_gcc_options', '-std=c11 -Wall') - -function! ale_linters#c#gcc#GetCommand(buffer, output) abort - let l:cflags = ale#c#GetCFlags(a:buffer, a:output) - - " -iquote with the directory the file is in makes #include work for - " headers in the same directory. - " - " `-o /dev/null` or `-o null` is needed to catch all errors, - " -fsyntax-only doesn't catch everything. - return '%e -S -x c' - \ . ' -o ' . g:ale#util#nul_file - \ . ' -iquote ' . ale#Escape(fnamemodify(bufname(a:buffer), ':p:h')) - \ . ale#Pad(l:cflags) - \ . ale#Pad(ale#Var(a:buffer, 'c_gcc_options')) . ' -' -endfunction - -call ale#linter#Define('c', { -\ 'name': 'gcc', -\ 'output_stream': 'stderr', -\ 'executable': {b -> ale#Var(b, 'c_gcc_executable')}, -\ 'command': {b -> ale#c#RunMakeCommand(b, function('ale_linters#c#gcc#GetCommand'))}, -\ 'callback': 'ale#handlers#gcc#HandleGCCFormatWithIncludes', -\}) diff --git a/sources_non_forked/ale/ale_linters/clojure/clj_kondo.vim b/sources_non_forked/ale/ale_linters/clojure/clj_kondo.vim index 5dd11c12..eb60ce77 100644 --- a/sources_non_forked/ale/ale_linters/clojure/clj_kondo.vim +++ b/sources_non_forked/ale/ale_linters/clojure/clj_kondo.vim @@ -29,6 +29,6 @@ call ale#linter#Define('clojure', { \ 'name': 'clj-kondo', \ 'output_stream': 'stdout', \ 'executable': 'clj-kondo', -\ 'command': 'clj-kondo --lint %t', +\ 'command': 'clj-kondo --cache --lint %t', \ 'callback': 'ale_linters#clojure#clj_kondo#HandleCljKondoFormat', \}) diff --git a/sources_non_forked/ale/ale_linters/cpp/cc.vim b/sources_non_forked/ale/ale_linters/cpp/cc.vim new file mode 100644 index 00000000..ffb8f068 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/cpp/cc.vim @@ -0,0 +1,53 @@ +" Author: w0rp +" Description: A C++ compiler linter for C++ files with gcc/clang, etc. + +call ale#Set('cpp_cc_executable', '') +call ale#Set('cpp_cc_options', '-std=c++14 -Wall') + +function! ale_linters#cpp#cc#GetExecutable(buffer) abort + let l:executable = ale#Var(a:buffer, 'cpp_cc_executable') + + " Default to either clang++ or gcc. + if l:executable is# '' + if ale#engine#IsExecutable(a:buffer, 'clang++') + let l:executable = 'clang++' + else + let l:executable = 'gcc' + endif + endif + + return l:executable +endfunction + +function! ale_linters#cpp#cc#GetCommand(buffer, output) abort + let l:cflags = ale#c#GetCFlags(a:buffer, a:output) + let l:ale_flags = ale#Var(a:buffer, 'cpp_cc_options') + + if l:cflags =~# '-std=' + let l:ale_flags = substitute( + \ l:ale_flags, + \ '-std=\(c\|gnu\)++[0-9]\{2\}', + \ '', + \ 'g') + endif + + " -iquote with the directory the file is in makes #include work for + " headers in the same directory. + " + " `-o /dev/null` or `-o null` is needed to catch all errors, + " -fsyntax-only doesn't catch everything. + return '%e -S -x c++' + \ . ' -o ' . g:ale#util#nul_file + \ . ' -iquote %s:h' + \ . ale#Pad(l:cflags) + \ . ale#Pad(l:ale_flags) . ' -' +endfunction + +call ale#linter#Define('cpp', { +\ 'name': 'cc', +\ 'aliases': ['gcc', 'clang', 'g++', 'clang++'], +\ 'output_stream': 'stderr', +\ 'executable': function('ale_linters#cpp#cc#GetExecutable'), +\ 'command': {b -> ale#c#RunMakeCommand(b, function('ale_linters#cpp#cc#GetCommand'))}, +\ 'callback': 'ale#handlers#gcc#HandleGCCFormatWithIncludes', +\}) diff --git a/sources_non_forked/ale/ale_linters/cpp/ccls.vim b/sources_non_forked/ale/ale_linters/cpp/ccls.vim index b265ff70..38f8df9c 100644 --- a/sources_non_forked/ale/ale_linters/cpp/ccls.vim +++ b/sources_non_forked/ale/ale_linters/cpp/ccls.vim @@ -3,6 +3,7 @@ call ale#Set('cpp_ccls_executable', 'ccls') call ale#Set('cpp_ccls_init_options', {}) +call ale#Set('c_build_dir', '') call ale#linter#Define('cpp', { \ 'name': 'ccls', @@ -10,5 +11,5 @@ call ale#linter#Define('cpp', { \ 'executable': {b -> ale#Var(b, 'cpp_ccls_executable')}, \ 'command': '%e', \ 'project_root': function('ale#handlers#ccls#GetProjectRoot'), -\ 'initialization_options': {b -> ale#Var(b, 'cpp_ccls_init_options')}, +\ 'initialization_options': {b -> ale#handlers#ccls#GetInitOpts(b, 'cpp_ccls_init_options')}, \}) diff --git a/sources_non_forked/ale/ale_linters/cpp/clang.vim b/sources_non_forked/ale/ale_linters/cpp/clang.vim deleted file mode 100644 index e48291eb..00000000 --- a/sources_non_forked/ale/ale_linters/cpp/clang.vim +++ /dev/null @@ -1,24 +0,0 @@ -" Author: Tomota Nakamura -" Description: clang linter for cpp files - -call ale#Set('cpp_clang_executable', 'clang++') -call ale#Set('cpp_clang_options', '-std=c++14 -Wall') - -function! ale_linters#cpp#clang#GetCommand(buffer, output) abort - let l:cflags = ale#c#GetCFlags(a:buffer, a:output) - - " -iquote with the directory the file is in makes #include work for - " headers in the same directory. - return '%e -S -x c++ -fsyntax-only' - \ . ' -iquote ' . ale#Escape(fnamemodify(bufname(a:buffer), ':p:h')) - \ . ale#Pad(l:cflags) - \ . ale#Pad(ale#Var(a:buffer, 'cpp_clang_options')) . ' -' -endfunction - -call ale#linter#Define('cpp', { -\ 'name': 'clang', -\ 'output_stream': 'stderr', -\ 'executable': {b -> ale#Var(b, 'cpp_clang_executable')}, -\ 'command': {b -> ale#c#RunMakeCommand(b, function('ale_linters#cpp#clang#GetCommand'))}, -\ 'callback': 'ale#handlers#gcc#HandleGCCFormatWithIncludes', -\}) diff --git a/sources_non_forked/ale/ale_linters/cpp/clangtidy.vim b/sources_non_forked/ale/ale_linters/cpp/clangtidy.vim index 212e0ab2..05a28401 100644 --- a/sources_non_forked/ale/ale_linters/cpp/clangtidy.vim +++ b/sources_non_forked/ale/ale_linters/cpp/clangtidy.vim @@ -25,6 +25,11 @@ function! ale_linters#cpp#clangtidy#GetCommand(buffer, output) abort let l:options .= !empty(l:options) ? ale#Pad(l:cflags) : l:cflags endif + " Tell clang-tidy a .h header with a C++ filetype in Vim is a C++ file. + if expand('#' . a:buffer) =~# '\.h$' + let l:options .= !empty(l:options) ? ' -x c++' : '-x c++' + endif + " Get the options to pass directly to clang-tidy let l:extra_options = ale#Var(a:buffer, 'cpp_clangtidy_extra_options') diff --git a/sources_non_forked/ale/ale_linters/cpp/cppcheck.vim b/sources_non_forked/ale/ale_linters/cpp/cppcheck.vim index 7cd80dbc..2c832246 100644 --- a/sources_non_forked/ale/ale_linters/cpp/cppcheck.vim +++ b/sources_non_forked/ale/ale_linters/cpp/cppcheck.vim @@ -10,9 +10,11 @@ function! ale_linters#cpp#cppcheck#GetCommand(buffer) abort let l:buffer_path_include = empty(l:compile_commands_option) \ ? ale#handlers#cppcheck#GetBufferPathIncludeOptions(a:buffer) \ : '' + let l:template = ' --template=''{file}:{line}:{column}: {severity}:{inconclusive:inconclusive:} {message} [{id}]\\n{code}''' return l:cd_command \ . '%e -q --language=c++' + \ . l:template \ . ale#Pad(l:compile_commands_option) \ . ale#Pad(ale#Var(a:buffer, 'cpp_cppcheck_options')) \ . l:buffer_path_include diff --git a/sources_non_forked/ale/ale_linters/cpp/gcc.vim b/sources_non_forked/ale/ale_linters/cpp/gcc.vim deleted file mode 100644 index 108d6d70..00000000 --- a/sources_non_forked/ale/ale_linters/cpp/gcc.vim +++ /dev/null @@ -1,29 +0,0 @@ -" Author: geam -" Description: gcc linter for cpp files -" -call ale#Set('cpp_gcc_executable', 'gcc') -call ale#Set('cpp_gcc_options', '-std=c++14 -Wall') - -function! ale_linters#cpp#gcc#GetCommand(buffer, output) abort - let l:cflags = ale#c#GetCFlags(a:buffer, a:output) - - " -iquote with the directory the file is in makes #include work for - " headers in the same directory. - " - " `-o /dev/null` or `-o null` is needed to catch all errors, - " -fsyntax-only doesn't catch everything. - return '%e -S -x c++' - \ . ' -o ' . g:ale#util#nul_file - \ . ' -iquote ' . ale#Escape(fnamemodify(bufname(a:buffer), ':p:h')) - \ . ale#Pad(l:cflags) - \ . ale#Pad(ale#Var(a:buffer, 'cpp_gcc_options')) . ' -' -endfunction - -call ale#linter#Define('cpp', { -\ 'name': 'gcc', -\ 'aliases': ['g++'], -\ 'output_stream': 'stderr', -\ 'executable': {b -> ale#Var(b, 'cpp_gcc_executable')}, -\ 'command': {b -> ale#c#RunMakeCommand(b, function('ale_linters#cpp#gcc#GetCommand'))}, -\ 'callback': 'ale#handlers#gcc#HandleGCCFormatWithIncludes', -\}) diff --git a/sources_non_forked/ale/ale_linters/cuda/nvcc.vim b/sources_non_forked/ale/ale_linters/cuda/nvcc.vim index f3af07b6..2734f6ec 100644 --- a/sources_non_forked/ale/ale_linters/cuda/nvcc.vim +++ b/sources_non_forked/ale/ale_linters/cuda/nvcc.vim @@ -5,9 +5,6 @@ call ale#Set('cuda_nvcc_executable', 'nvcc') call ale#Set('cuda_nvcc_options', '-std=c++11') function! ale_linters#cuda#nvcc#GetCommand(buffer) abort - " Unused: use ale#util#nul_file - " let l:output_file = ale#util#Tempname() . '.ii' - " call ale#command#ManageFile(a:buffer, l:output_file) return '%e -cuda' \ . ale#Pad(ale#c#IncludeOptions(ale#c#FindLocalHeaderPaths(a:buffer))) \ . ale#Pad(ale#Var(a:buffer, 'cuda_nvcc_options')) diff --git a/sources_non_forked/ale/ale_linters/dockerfile/dockerfile_lint.vim b/sources_non_forked/ale/ale_linters/dockerfile/dockerfile_lint.vim index 95768b12..0c0ad533 100644 --- a/sources_non_forked/ale/ale_linters/dockerfile/dockerfile_lint.vim +++ b/sources_non_forked/ale/ale_linters/dockerfile/dockerfile_lint.vim @@ -32,14 +32,29 @@ function! ale_linters#dockerfile#dockerfile_lint#Handle(buffer, lines) abort let l:line = get(l:object, 'line', -1) let l:message = l:object['message'] - if get(l:object, 'description', 'None') isnot# 'None' - let l:message = l:message . '. ' . l:object['description'] + let l:link = get(l:object, 'reference_url', '') + + if type(l:link) == v:t_list + " Somehow, reference_url is returned as two-part list. + " Anchor markers in that list are sometimes duplicated. + " See https://github.com/projectatomic/dockerfile_lint/issues/134 + let l:link = join(l:link, '') + let l:link = substitute(l:link, '##', '#', '') endif + let l:detail = l:message + + if get(l:object, 'description', 'None') isnot# 'None' + let l:detail .= "\n\n" . l:object['description'] + endif + + let l:detail .= "\n\n" . l:link + call add(l:messages, { \ 'lnum': l:line, \ 'text': l:message, \ 'type': ale_linters#dockerfile#dockerfile_lint#GetType(l:type), + \ 'detail': l:detail, \}) endfor endfor diff --git a/sources_non_forked/ale/ale_linters/elixir/credo.vim b/sources_non_forked/ale/ale_linters/elixir/credo.vim index 317ecab3..7c298502 100644 --- a/sources_non_forked/ale/ale_linters/elixir/credo.vim +++ b/sources_non_forked/ale/ale_linters/elixir/credo.vim @@ -46,7 +46,7 @@ function! ale_linters#elixir#credo#GetMode() abort endfunction function! ale_linters#elixir#credo#GetCommand(buffer) abort - let l:project_root = ale#handlers#elixir#FindMixProjectRoot(a:buffer) + let l:project_root = ale#handlers#elixir#FindMixUmbrellaRoot(a:buffer) let l:mode = ale_linters#elixir#credo#GetMode() return ale#path#CdString(l:project_root) diff --git a/sources_non_forked/ale/ale_linters/erlang/elvis.vim b/sources_non_forked/ale/ale_linters/erlang/elvis.vim new file mode 100644 index 00000000..31dea3dd --- /dev/null +++ b/sources_non_forked/ale/ale_linters/erlang/elvis.vim @@ -0,0 +1,39 @@ +" Author: Dmitri Vereshchagin +" Description: Elvis linter for Erlang files + +call ale#Set('erlang_elvis_executable', 'elvis') + +function! ale_linters#erlang#elvis#Handle(buffer, lines) abort + let l:pattern = '\v:(\d+):[^:]+:(.+)' + let l:loclist = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + call add(l:loclist, { + \ 'lnum': str2nr(l:match[1]), + \ 'text': s:AbbreviateMessage(l:match[2]), + \ 'type': 'W', + \}) + endfor + + return l:loclist +endfunction + +function! s:AbbreviateMessage(text) abort + let l:pattern = '\v\c^(line \d+ is too long):.*$' + + return substitute(a:text, l:pattern, '\1.', '') +endfunction + +function! s:GetCommand(buffer) abort + let l:file = ale#Escape(expand('#' . a:buffer . ':.')) + + return '%e rock --output-format=parsable ' . l:file +endfunction + +call ale#linter#Define('erlang', { +\ 'name': 'elvis', +\ 'callback': 'ale_linters#erlang#elvis#Handle', +\ 'executable': {b -> ale#Var(b, 'erlang_elvis_executable')}, +\ 'command': function('s:GetCommand'), +\ 'lint_file': 1, +\}) diff --git a/sources_non_forked/ale/ale_linters/eruby/ruumba.vim b/sources_non_forked/ale/ale_linters/eruby/ruumba.vim index 2e84acf7..f415f1ab 100644 --- a/sources_non_forked/ale/ale_linters/eruby/ruumba.vim +++ b/sources_non_forked/ale/ale_linters/eruby/ruumba.vim @@ -11,7 +11,7 @@ function! ale_linters#eruby#ruumba#GetCommand(buffer) abort return ale#ruby#EscapeExecutable(l:executable, 'ruumba') \ . ' --format json --force-exclusion ' \ . ale#Var(a:buffer, 'eruby_ruumba_options') - \ . ' --stdin ' . ale#Escape(expand('#' . a:buffer . ':p')) + \ . ' --stdin %s' endfunction function! ale_linters#eruby#ruumba#Handle(buffer, lines) abort diff --git a/sources_non_forked/ale/ale_linters/go/gofmt.vim b/sources_non_forked/ale/ale_linters/go/gofmt.vim index a233b422..b313f9ca 100644 --- a/sources_non_forked/ale/ale_linters/go/gofmt.vim +++ b/sources_non_forked/ale/ale_linters/go/gofmt.vim @@ -6,7 +6,6 @@ function! ale_linters#go#gofmt#GetCommand(buffer) abort \ . '%e -e %t' endfunction - call ale#linter#Define('go', { \ 'name': 'gofmt', \ 'output_stream': 'stderr', diff --git a/sources_non_forked/ale/ale_linters/go/revive.vim b/sources_non_forked/ale/ale_linters/go/revive.vim new file mode 100644 index 00000000..b14b5ab9 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/go/revive.vim @@ -0,0 +1,21 @@ +" Author: Penghui Liao +" Description: Adds support for revive + +call ale#Set('go_revive_executable', 'revive') +call ale#Set('go_revive_options', '') + +function! ale_linters#go#revive#GetCommand(buffer) abort + let l:options = ale#Var(a:buffer, 'go_revive_options') + + return ale#go#EnvString(a:buffer) . '%e' + \ . (!empty(l:options) ? ' ' . l:options : '') + \ . ' %t' +endfunction + +call ale#linter#Define('go', { +\ 'name': 'revive', +\ 'output_stream': 'both', +\ 'executable': {b -> ale#Var(b, 'go_revive_executable')}, +\ 'command': function('ale_linters#go#revive#GetCommand'), +\ 'callback': 'ale#handlers#unix#HandleAsWarning', +\}) diff --git a/sources_non_forked/ale/ale_linters/handlebars/embertemplatelint.vim b/sources_non_forked/ale/ale_linters/handlebars/embertemplatelint.vim index 74bd6a99..bd4d1d31 100644 --- a/sources_non_forked/ale/ale_linters/handlebars/embertemplatelint.vim +++ b/sources_non_forked/ale/ale_linters/handlebars/embertemplatelint.vim @@ -4,6 +4,28 @@ call ale#Set('handlebars_embertemplatelint_executable', 'ember-template-lint') call ale#Set('handlebars_embertemplatelint_use_global', get(g:, 'ale_use_global_executables', 0)) +function! ale_linters#handlebars#embertemplatelint#GetExecutable(buffer) abort + return ale#node#FindExecutable(a:buffer, 'handlebars_embertemplatelint', [ + \ 'node_modules/.bin/ember-template-lint', + \]) +endfunction + +function! ale_linters#handlebars#embertemplatelint#GetCommand(buffer, version) abort + " Reading from stdin was introduced in ember-template-lint@1.6.0 + return ale#semver#GTE(a:version, [1, 6, 0]) + \ ? '%e --json --filename %s' + \ : '%e --json %t' +endfunction + +function! ale_linters#handlebars#embertemplatelint#GetCommandWithVersionCheck(buffer) abort + return ale#semver#RunWithVersionCheck( + \ a:buffer, + \ ale_linters#handlebars#embertemplatelint#GetExecutable(a:buffer), + \ '%e --version', + \ function('ale_linters#handlebars#embertemplatelint#GetCommand'), + \) +endfunction + function! ale_linters#handlebars#embertemplatelint#Handle(buffer, lines) abort let l:output = [] let l:json = ale#util#FuzzyJSONDecode(a:lines, {}) @@ -30,10 +52,9 @@ function! ale_linters#handlebars#embertemplatelint#Handle(buffer, lines) abort endfunction call ale#linter#Define('handlebars', { -\ 'name': 'ember-template-lint', -\ 'executable': {b -> ale#node#FindExecutable(b, 'handlebars_embertemplatelint', [ -\ 'node_modules/.bin/ember-template-lint', -\ ])}, -\ 'command': '%e --json %t', +\ 'name': 'embertemplatelint', +\ 'aliases': ['ember-template-lint'], +\ 'executable': function('ale_linters#handlebars#embertemplatelint#GetExecutable'), +\ 'command': function('ale_linters#handlebars#embertemplatelint#GetCommandWithVersionCheck'), \ 'callback': 'ale_linters#handlebars#embertemplatelint#Handle', \}) diff --git a/sources_non_forked/ale/ale_linters/java/checkstyle.vim b/sources_non_forked/ale/ale_linters/java/checkstyle.vim index 7901ff7e..ec7339d1 100644 --- a/sources_non_forked/ale/ale_linters/java/checkstyle.vim +++ b/sources_non_forked/ale/ale_linters/java/checkstyle.vim @@ -52,7 +52,7 @@ endfunction function! ale_linters#java#checkstyle#GetCommand(buffer) abort let l:options = ale#Var(a:buffer, 'java_checkstyle_options') let l:config_option = ale#Var(a:buffer, 'java_checkstyle_config') - let l:config = l:options !~# '\v(^| )-c' && !empty(l:config_option) + let l:config = l:options !~# '\v(^| )-c ' && !empty(l:config_option) \ ? s:GetConfig(a:buffer, l:config_option) \ : '' diff --git a/sources_non_forked/ale/ale_linters/java/eclipselsp.vim b/sources_non_forked/ale/ale_linters/java/eclipselsp.vim index 2648893b..8bc09039 100644 --- a/sources_non_forked/ale/ale_linters/java/eclipselsp.vim +++ b/sources_non_forked/ale/ale_linters/java/eclipselsp.vim @@ -7,6 +7,7 @@ call ale#Set('java_eclipselsp_path', ale#path#Simplify($HOME . '/eclipse.jdt.ls' call ale#Set('java_eclipselsp_config_path', '') call ale#Set('java_eclipselsp_workspace_path', '') call ale#Set('java_eclipselsp_executable', 'java') +call ale#Set('java_eclipselsp_javaagent', '') function! ale_linters#java#eclipselsp#Executable(buffer) abort return ale#Var(a:buffer, 'java_eclipselsp_executable') @@ -19,25 +20,39 @@ endfunction function! ale_linters#java#eclipselsp#JarPath(buffer) abort let l:path = ale_linters#java#eclipselsp#TargetPath(a:buffer) - " Search jar file within repository path when manually built using mvn - let l:repo_path = l:path . '/org.eclipse.jdt.ls.product/target/repository' - let l:files = globpath(l:repo_path, '**/plugins/org.eclipse.equinox.launcher_\d\.\d\.\d\d\d\.*\.jar', 1, 1) + if has('win32') + let l:platform = 'win32' + elseif has('macunix') + let l:platform = 'macosx' + else + let l:platform = 'linux' + endif - if len(l:files) == 1 + " Search jar file within repository path when manually built using mvn + let l:files = globpath(l:path, '**/'.l:platform.'/**/plugins/org.eclipse.equinox.launcher_\d\.\d\.\d\d\d\.*\.jar', 1, 1) + + if len(l:files) >= 1 return l:files[0] endif " Search jar file within VSCode extensions folder. - let l:files = globpath(l:path, '**/plugins/org.eclipse.equinox.launcher_\d\.\d\.\d\d\d\.*\.jar', 1, 1) + let l:files = globpath(l:path, '**/'.l:platform.'/plugins/org.eclipse.equinox.launcher_\d\.\d\.\d\d\d\.*\.jar', 1, 1) - if len(l:files) == 1 + if len(l:files) >= 1 + return l:files[0] + endif + + " Search jar file within unzipped tar.gz file + let l:files = globpath(l:path, 'plugins/org.eclipse.equinox.launcher_\d\.\d\.\d\d\d\.*\.jar', 1, 1) + + if len(l:files) >= 1 return l:files[0] endif " Search jar file within system package path let l:files = globpath('/usr/share/java/jdtls/plugins', 'org.eclipse.equinox.launcher_\d\.\d\.\d\d\d\.*\.jar', 1, 1) - if len(l:files) == 1 + if len(l:files) >= 1 return l:files[0] endif @@ -100,12 +115,30 @@ function! ale_linters#java#eclipselsp#WorkspacePath(buffer) abort return ale#path#Dirname(ale#java#FindProjectRoot(a:buffer)) endfunction +function! ale_linters#java#eclipselsp#Javaagent(buffer) abort + let l:rets = [] + let l:raw = ale#Var(a:buffer, 'java_eclipselsp_javaagent') + + if empty(l:raw) + return '' + endif + + let l:jars = split(l:raw) + + for l:jar in l:jars + call add(l:rets, ale#Escape('-javaagent:' . l:jar)) + endfor + + return join(l:rets, ' ') +endfunction + function! ale_linters#java#eclipselsp#Command(buffer, version) abort let l:path = ale#Var(a:buffer, 'java_eclipselsp_path') let l:executable = ale_linters#java#eclipselsp#Executable(a:buffer) let l:cmd = [ ale#Escape(l:executable), + \ ale_linters#java#eclipselsp#Javaagent(a:buffer), \ '-Declipse.application=org.eclipse.jdt.ls.core.id1', \ '-Dosgi.bundles.defaultStartLevel=4', \ '-Declipse.product=org.eclipse.jdt.ls.core.product', @@ -147,7 +180,8 @@ function! ale_linters#java#eclipselsp#RunWithVersionCheck(buffer) abort return ale#command#Run( \ a:buffer, \ l:command, - \ function('ale_linters#java#eclipselsp#CommandWithVersion') + \ function('ale_linters#java#eclipselsp#CommandWithVersion'), + \ { 'output_stream': 'both' } \) endfunction diff --git a/sources_non_forked/ale/ale_linters/java/javac.vim b/sources_non_forked/ale/ale_linters/java/javac.vim index 8bb52c0b..a5e57e6c 100644 --- a/sources_non_forked/ale/ale_linters/java/javac.vim +++ b/sources_non_forked/ale/ale_linters/java/javac.vim @@ -6,15 +6,10 @@ let s:classpath_sep = has('unix') ? ':' : ';' call ale#Set('java_javac_executable', 'javac') call ale#Set('java_javac_options', '') call ale#Set('java_javac_classpath', '') +call ale#Set('java_javac_sourcepath', '') function! ale_linters#java#javac#RunWithImportPaths(buffer) abort - let l:command = '' - let l:pom_path = ale#path#FindNearestFile(a:buffer, 'pom.xml') - - if !empty(l:pom_path) && executable('mvn') - let l:command = ale#path#CdString(fnamemodify(l:pom_path, ':h')) - \ . 'mvn dependency:build-classpath' - endif + let l:command = ale#maven#BuildClasspathCommand(a:buffer) " Try to use Gradle if Maven isn't available. if empty(l:command) @@ -40,10 +35,15 @@ endfunction function! s:BuildClassPathOption(buffer, import_paths) abort " Filter out lines like [INFO], etc. let l:class_paths = filter(a:import_paths[:], 'v:val !~# ''[''') - call extend( - \ l:class_paths, - \ split(ale#Var(a:buffer, 'java_javac_classpath'), s:classpath_sep), - \) + let l:cls_path = ale#Var(a:buffer, 'java_javac_classpath') + + if !empty(l:cls_path) && type(l:cls_path) is v:t_string + call extend(l:class_paths, split(l:cls_path, s:classpath_sep)) + endif + + if !empty(l:cls_path) && type(l:cls_path) is v:t_list + call extend(l:class_paths, l:cls_path) + endif return !empty(l:class_paths) \ ? '-cp ' . ale#Escape(join(l:class_paths, s:classpath_sep)) @@ -79,6 +79,27 @@ function! ale_linters#java#javac#GetCommand(buffer, import_paths, meta) abort endif endif + let l:source_paths = [] + let l:source_path = ale#Var(a:buffer, 'java_javac_sourcepath') + + if !empty(l:source_path) && type(l:source_path) is v:t_string + let l:source_paths = split(l:source_path, s:classpath_sep) + endif + + if !empty(l:source_path) && type(l:source_path) is v:t_list + let l:source_paths = l:source_path + endif + + if !empty(l:source_paths) + for l:path in l:source_paths + let l:sp_path = ale#path#FindNearestDirectory(a:buffer, l:path) + + if !empty(l:sp_path) + call add(l:sp_dirs, l:sp_path) + endif + endfor + endif + if !empty(l:sp_dirs) let l:sp_option = '-sourcepath ' \ . ale#Escape(join(l:sp_dirs, s:classpath_sep)) diff --git a/sources_non_forked/ale/ale_linters/kotlin/kotlinc.vim b/sources_non_forked/ale/ale_linters/kotlin/kotlinc.vim index 3c6854fa..66c075be 100644 --- a/sources_non_forked/ale/ale_linters/kotlin/kotlinc.vim +++ b/sources_non_forked/ale/ale_linters/kotlin/kotlinc.vim @@ -174,6 +174,7 @@ endfunction call ale#linter#Define('kotlin', { \ 'name': 'kotlinc', \ 'executable': 'kotlinc', +\ 'output_stream': 'stderr', \ 'command': function('ale_linters#kotlin#kotlinc#RunWithImportPaths'), \ 'callback': 'ale_linters#kotlin#kotlinc#Handle', \ 'lint_file': 1, diff --git a/sources_non_forked/ale/ale_linters/kotlin/ktlint.vim b/sources_non_forked/ale/ale_linters/kotlin/ktlint.vim index f0384005..0bb64b19 100644 --- a/sources_non_forked/ale/ale_linters/kotlin/ktlint.vim +++ b/sources_non_forked/ale/ale_linters/kotlin/ktlint.vim @@ -6,5 +6,5 @@ call ale#linter#Define('kotlin', { \ 'executable': 'ktlint', \ 'command': function('ale#handlers#ktlint#GetCommand'), \ 'callback': 'ale#handlers#ktlint#Handle', -\ 'lint_file': 1 +\ 'output_stream': 'stderr' \}) diff --git a/sources_non_forked/ale/ale_linters/markdown/markdownlint.vim b/sources_non_forked/ale/ale_linters/markdown/markdownlint.vim index e935cbfe..7a293938 100644 --- a/sources_non_forked/ale/ale_linters/markdown/markdownlint.vim +++ b/sources_non_forked/ale/ale_linters/markdown/markdownlint.vim @@ -1,11 +1,22 @@ " Author: Ty-Lucas Kelley " Description: Adds support for markdownlint +call ale#Set('markdown_markdownlint_options', '') + +function! ale_linters#markdown#markdownlint#GetCommand(buffer) abort + let l:executable = 'markdownlint' + + let l:options = ale#Var(a:buffer, 'markdown_markdownlint_options') + + return ale#Escape(l:executable) + \ . (!empty(l:options) ? ' ' . l:options : '') . ' %s' +endfunction + call ale#linter#Define('markdown', { \ 'name': 'markdownlint', \ 'executable': 'markdownlint', \ 'lint_file': 1, \ 'output_stream': 'both', -\ 'command': 'markdownlint %s', +\ 'command': function('ale_linters#markdown#markdownlint#GetCommand'), \ 'callback': 'ale#handlers#markdownlint#Handle' \}) diff --git a/sources_non_forked/ale/ale_linters/nasm/nasm.vim b/sources_non_forked/ale/ale_linters/nasm/nasm.vim index 347abc1b..c4f53629 100644 --- a/sources_non_forked/ale/ale_linters/nasm/nasm.vim +++ b/sources_non_forked/ale/ale_linters/nasm/nasm.vim @@ -7,10 +7,9 @@ call ale#Set('nasm_nasm_options', '') function! ale_linters#nasm#nasm#GetCommand(buffer) abort " Note that NASM requires a trailing slash for the -I option. let l:separator = has('win32') ? '\' : '/' - let l:path = fnamemodify(bufname(a:buffer), ':p:h') . l:separator let l:output_null = has('win32') ? 'NUL' : '/dev/null' - return '%e -X gnu -I ' . ale#Escape(l:path) + return '%e -X gnu -I %s:h' . l:separator \ . ale#Pad(ale#Var(a:buffer, 'nasm_nasm_options')) \ . ' %s' \ . ' -o ' . l:output_null diff --git a/sources_non_forked/ale/ale_linters/objc/ccls.vim b/sources_non_forked/ale/ale_linters/objc/ccls.vim index 51ecf056..7aef5325 100644 --- a/sources_non_forked/ale/ale_linters/objc/ccls.vim +++ b/sources_non_forked/ale/ale_linters/objc/ccls.vim @@ -3,6 +3,7 @@ call ale#Set('objc_ccls_executable', 'ccls') call ale#Set('objc_ccls_init_options', {}) +call ale#Set('c_build_dir', '') call ale#linter#Define('objc', { \ 'name': 'ccls', @@ -10,5 +11,5 @@ call ale#linter#Define('objc', { \ 'executable': {b -> ale#Var(b, 'objc_ccls_executable')}, \ 'command': '%e', \ 'project_root': function('ale#handlers#ccls#GetProjectRoot'), -\ 'initialization_options': {b -> ale#Var(b, 'objc_ccls_init_options')}, +\ 'initialization_options': {b -> ale#handlers#ccls#GetInitOpts(b, 'objc_ccls_init_options')}, \}) diff --git a/sources_non_forked/ale/ale_linters/objc/clang.vim b/sources_non_forked/ale/ale_linters/objc/clang.vim index 7873dccd..cafb97db 100644 --- a/sources_non_forked/ale/ale_linters/objc/clang.vim +++ b/sources_non_forked/ale/ale_linters/objc/clang.vim @@ -10,7 +10,7 @@ function! ale_linters#objc#clang#GetCommand(buffer) abort " -iquote with the directory the file is in makes #include work for " headers in the same directory. return 'clang -S -x objective-c -fsyntax-only ' - \ . '-iquote ' . ale#Escape(fnamemodify(bufname(a:buffer), ':p:h')) + \ . '-iquote %s:h' \ . ' ' . ale#Var(a:buffer, 'objc_clang_options') . ' -' endfunction diff --git a/sources_non_forked/ale/ale_linters/objcpp/clang.vim b/sources_non_forked/ale/ale_linters/objcpp/clang.vim index 4dbe55b3..35a40c6f 100644 --- a/sources_non_forked/ale/ale_linters/objcpp/clang.vim +++ b/sources_non_forked/ale/ale_linters/objcpp/clang.vim @@ -10,7 +10,7 @@ function! ale_linters#objcpp#clang#GetCommand(buffer) abort " -iquote with the directory the file is in makes #include work for " headers in the same directory. return 'clang++ -S -x objective-c++ -fsyntax-only ' - \ . '-iquote ' . ale#Escape(fnamemodify(bufname(a:buffer), ':p:h')) + \ . '-iquote %s:h' \ . ' ' . ale#Var(a:buffer, 'objcpp_clang_options') . ' -' endfunction diff --git a/sources_non_forked/ale/ale_linters/ocaml/ols.vim b/sources_non_forked/ale/ale_linters/ocaml/ols.vim index d8208c52..ec71bdb4 100644 --- a/sources_non_forked/ale/ale_linters/ocaml/ols.vim +++ b/sources_non_forked/ale/ale_linters/ocaml/ols.vim @@ -9,6 +9,6 @@ call ale#linter#Define('ocaml', { \ 'lsp': 'stdio', \ 'executable': function('ale#handlers#ols#GetExecutable'), \ 'command': function('ale#handlers#ols#GetCommand'), -\ 'language_callback': 'ale#handlers#ols#GetLanguage', +\ 'language': function('ale#handlers#ols#GetLanguage'), \ 'project_root': function('ale#handlers#ols#GetProjectRoot'), \}) diff --git a/sources_non_forked/ale/ale_linters/php/intelephense.vim b/sources_non_forked/ale/ale_linters/php/intelephense.vim new file mode 100644 index 00000000..e9e07d1f --- /dev/null +++ b/sources_non_forked/ale/ale_linters/php/intelephense.vim @@ -0,0 +1,32 @@ +" Author: Eric Stern , +" Arnold Chand +" Description: Intelephense language server integration for ALE + +call ale#Set('php_intelephense_executable', 'intelephense') +call ale#Set('php_intelephense_use_global', 1) +call ale#Set('php_intelephense_config', {}) + +function! ale_linters#php#intelephense#GetProjectRoot(buffer) abort + let l:composer_path = ale#path#FindNearestFile(a:buffer, 'composer.json') + + if (!empty(l:composer_path)) + return fnamemodify(l:composer_path, ':h') + endif + + let l:git_path = ale#path#FindNearestDirectory(a:buffer, '.git') + + return !empty(l:git_path) ? fnamemodify(l:git_path, ':h:h') : '' +endfunction + +function! ale_linters#php#intelephense#GetInitializationOptions() abort + return ale#Get('php_intelephense_config') +endfunction + +call ale#linter#Define('php', { +\ 'name': 'intelephense', +\ 'lsp': 'stdio', +\ 'initialization_options': function('ale_linters#php#intelephense#GetInitializationOptions'), +\ 'executable': {b -> ale#node#FindExecutable(b, 'php_intelephense', [])}, +\ 'command': '%e --stdio', +\ 'project_root': function('ale_linters#php#intelephense#GetProjectRoot'), +\}) diff --git a/sources_non_forked/ale/ale_linters/php/phpcs.vim b/sources_non_forked/ale/ale_linters/php/phpcs.vim index 11b81e84..c5a3faa9 100644 --- a/sources_non_forked/ale/ale_linters/php/phpcs.vim +++ b/sources_non_forked/ale/ale_linters/php/phpcs.vim @@ -23,7 +23,7 @@ function! ale_linters#php#phpcs#Handle(buffer, lines) abort " Matches against lines like the following: " " /path/to/some-filename.php:18:3: error - Line indented incorrectly; expected 4 spaces, found 2 (Generic.WhiteSpace.ScopeIndent.IncorrectExact) - let l:pattern = '^.*:\(\d\+\):\(\d\+\): \(.\+\) - \(.\+\) (\(.\+\))$' + let l:pattern = '^.*:\(\d\+\):\(\d\+\): \(.\+\) - \(.\+\) (\(.\+\)).*$' let l:output = [] for l:match in ale#util#GetMatches(a:lines, l:pattern) diff --git a/sources_non_forked/ale/ale_linters/php/psalm.vim b/sources_non_forked/ale/ale_linters/php/psalm.vim index ab4dbbc9..286c8a96 100644 --- a/sources_non_forked/ale/ale_linters/php/psalm.vim +++ b/sources_non_forked/ale/ale_linters/php/psalm.vim @@ -1,9 +1,9 @@ " Author: Matt Brown " Description: plugin for Psalm, static analyzer for PHP -call ale#Set('psalm_langserver_executable', 'psalm') -call ale#Set('psalm_langserver_options', '') -call ale#Set('psalm_langserver_use_global', get(g:, 'ale_use_global_executables', 0)) +call ale#Set('php_psalm_executable', 'psalm') +call ale#Set('php_psalm_options', '') +call ale#Set('php_psalm_use_global', get(g:, 'ale_use_global_executables', 0)) function! ale_linters#php#psalm#GetProjectRoot(buffer) abort let l:git_path = ale#path#FindNearestDirectory(a:buffer, '.git') @@ -12,13 +12,13 @@ function! ale_linters#php#psalm#GetProjectRoot(buffer) abort endfunction function! ale_linters#php#psalm#GetCommand(buffer) abort - return '%e --language-server' . ale#Pad(ale#Var(a:buffer, 'psalm_langserver_options')) + return '%e --language-server' . ale#Pad(ale#Var(a:buffer, 'php_psalm_options')) endfunction call ale#linter#Define('php', { \ 'name': 'psalm', \ 'lsp': 'stdio', -\ 'executable': {b -> ale#node#FindExecutable(b, 'psalm_langserver', [ +\ 'executable': {b -> ale#node#FindExecutable(b, 'php_psalm', [ \ 'vendor/bin/psalm', \ ])}, \ 'command': function('ale_linters#php#psalm#GetCommand'), diff --git a/sources_non_forked/ale/ale_linters/php/tlint.vim b/sources_non_forked/ale/ale_linters/php/tlint.vim new file mode 100644 index 00000000..6bba8def --- /dev/null +++ b/sources_non_forked/ale/ale_linters/php/tlint.vim @@ -0,0 +1,80 @@ +" Author: Jose Soto +" +" Description: Tighten Opinionated PHP Linting +" Website: https://github.com/tightenco/tlint + +call ale#Set('php_tlint_executable', 'tlint') +call ale#Set('php_tlint_use_global', get(g:, 'ale_use_global_executables', 0)) +call ale#Set('php_tlint_options', '') + +function! ale_linters#php#tlint#GetProjectRoot(buffer) abort + let l:composer_path = ale#path#FindNearestFile(a:buffer, 'composer.json') + + if !empty(l:composer_path) + return fnamemodify(l:composer_path, ':h') + endif + + let l:git_path = ale#path#FindNearestDirectory(a:buffer, '.git') + + return !empty(l:git_path) ? fnamemodify(l:git_path, ':h:h') : '' +endfunction + +function! ale_linters#php#tlint#GetExecutable(buffer) abort + return ale#node#FindExecutable(a:buffer, 'php_tlint', [ + \ 'vendor/bin/tlint', + \ 'tlint', + \]) +endfunction + +function! ale_linters#php#tlint#GetCommand(buffer) abort + let l:executable = ale_linters#php#tlint#GetExecutable(a:buffer) + let l:options = ale#Var(a:buffer, 'php_tlint_options') + + return ale#node#Executable(a:buffer, l:executable) + \ . (!empty(l:options) ? ' ' . l:options : '') + \ . ' lint %s' +endfunction + +function! ale_linters#php#tlint#Handle(buffer, lines) abort + " Matches against lines like the following: + " + " ! There should be 1 space around `.` concatenations, and additional lines should always start with a `.` + " 22 : ` $something = 'a'.'name';` + " + let l:loop_count = 0 + let l:messages_pattern = '^\! \(.*\)' + let l:output = [] + let l:pattern = '^\(\d\+\) \:' + let l:temp_messages = [] + + for l:message in ale#util#GetMatches(a:lines, l:messages_pattern) + call add(l:temp_messages, l:message) + endfor + + let l:loop_count = 0 + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + let l:num = l:match[1] + let l:text = l:temp_messages[l:loop_count] + + call add(l:output, { + \ 'lnum': l:num, + \ 'col': 0, + \ 'text': l:text, + \ 'type': 'W', + \ 'sub_type': 'style', + \}) + + let l:loop_count += 1 + endfor + + return l:output +endfunction + +call ale#linter#Define('php', { +\ 'name': 'tlint', +\ 'executable': function('ale_linters#php#tlint#GetExecutable'), +\ 'command': function('ale_linters#php#tlint#GetCommand'), +\ 'callback': 'ale_linters#php#tlint#Handle', +\ 'project_root': function('ale_linters#php#tlint#GetProjectRoot'), +\}) diff --git a/sources_non_forked/ale/ale_linters/puppet/puppet.vim b/sources_non_forked/ale/ale_linters/puppet/puppet.vim index ae648615..59228dc8 100644 --- a/sources_non_forked/ale/ale_linters/puppet/puppet.vim +++ b/sources_non_forked/ale/ale_linters/puppet/puppet.vim @@ -8,13 +8,15 @@ function! ale_linters#puppet#puppet#Handle(buffer, lines) abort " Error: Could not parse for environment production: Syntax error at ':' at /root/puppetcode/modules/nginx/manifests/init.pp:43:12 " Error: Could not parse for environment production: Syntax error at '='; expected '}' at /root/puppetcode/modules/pancakes/manifests/init.pp:5" " Error: Could not parse for environment production: Syntax error at 'parameter1' (file: /tmp/modules/mariadb/manifests/slave.pp, line: 4, column: 5) - let l:pattern = '^Error: .*: \(.\+\) \((file:\|at\) .\+\.pp\(, line: \|:\)\(\d\+\)\(, column: \|:\)\=\(\d*\)' + " Error: Illegal attempt to assign to 'a Name'. Not an assignable reference (file: /tmp/modules/waffles/manifests/syrup.pp, line: 5, column: 11) + " Error: Could not parse for environment production: Syntax error at end of input (file: /tmp/modules/bob/manifests/init.pp) + let l:pattern = '^Error:\%(.*:\)\? \(.\+\) \((file:\|at\) .\+\.pp\(\(, line: \|:\)\(\d\+\)\(, column: \|:\)\=\(\d*\)\|)$\)' let l:output = [] for l:match in ale#util#GetMatches(a:lines, l:pattern) call add(l:output, { - \ 'lnum': l:match[4] + 0, - \ 'col': l:match[6] + 0, + \ 'lnum': l:match[5] + 0, + \ 'col': l:match[7] + 0, \ 'text': l:match[1], \}) endfor diff --git a/sources_non_forked/ale/ale_linters/pyrex/cython.vim b/sources_non_forked/ale/ale_linters/pyrex/cython.vim index 84382ba1..247c3060 100644 --- a/sources_non_forked/ale/ale_linters/pyrex/cython.vim +++ b/sources_non_forked/ale/ale_linters/pyrex/cython.vim @@ -6,9 +6,7 @@ call ale#Set('pyrex_cython_executable', 'cython') call ale#Set('pyrex_cython_options', '--warning-extra') function! ale_linters#pyrex#cython#GetCommand(buffer) abort - let l:local_dir = ale#Escape(fnamemodify(bufname(a:buffer), ':p:h')) - - return '%e --working ' . l:local_dir . ' --include-dir ' . l:local_dir + return '%e --working %s:h --include-dir %s:h' \ . ale#Pad(ale#Var(a:buffer, 'pyrex_cython_options')) \ . ' --output-file ' . g:ale#util#nul_file . ' %t' endfunction diff --git a/sources_non_forked/ale/ale_linters/python/flake8.vim b/sources_non_forked/ale/ale_linters/python/flake8.vim index e2e7b743..fc4ab692 100644 --- a/sources_non_forked/ale/ale_linters/python/flake8.vim +++ b/sources_non_forked/ale/ale_linters/python/flake8.vim @@ -4,7 +4,7 @@ call ale#Set('python_flake8_executable', 'flake8') call ale#Set('python_flake8_options', '') call ale#Set('python_flake8_use_global', get(g:, 'ale_use_global_executables', 0)) -call ale#Set('python_flake8_change_directory', 1) +call ale#Set('python_flake8_change_directory', 'project') call ale#Set('python_flake8_auto_pipenv', 0) function! s:UsingModule(buffer) abort @@ -38,10 +38,30 @@ function! ale_linters#python#flake8#RunWithVersionCheck(buffer) abort \) endfunction +function! ale_linters#python#flake8#GetCdString(buffer) abort + let l:change_directory = ale#Var(a:buffer, 'python_flake8_change_directory') + let l:cd_string = '' + + if l:change_directory is# 'project' + let l:project_root = ale#python#FindProjectRootIni(a:buffer) + + if !empty(l:project_root) + let l:cd_string = ale#path#CdString(l:project_root) + endif + endif + + if (l:change_directory is# 'project' && empty(l:cd_string)) + \|| l:change_directory is# 1 + \|| l:change_directory is# 'file' + let l:cd_string = ale#path#BufferCdString(a:buffer) + endif + + return l:cd_string +endfunction + function! ale_linters#python#flake8#GetCommand(buffer, version) abort - let l:cd_string = ale#Var(a:buffer, 'python_flake8_change_directory') - \ ? ale#path#BufferCdString(a:buffer) - \ : '' + let l:cd_string = ale_linters#python#flake8#GetCdString(a:buffer) + let l:executable = ale_linters#python#flake8#GetExecutable(a:buffer) let l:exec_args = l:executable =~? 'pipenv$' diff --git a/sources_non_forked/ale/ale_linters/python/jedils.vim b/sources_non_forked/ale/ale_linters/python/jedils.vim new file mode 100644 index 00000000..eae5fb07 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/python/jedils.vim @@ -0,0 +1,34 @@ +" Author: Dalius Dobravolskas +" Description: https://github.com/pappasam/jedi-language-server + +call ale#Set('python_jedils_executable', 'jedi-language-server') +call ale#Set('python_jedils_use_global', get(g:, 'ale_use_global_executables', 0)) +call ale#Set('python_jedils_auto_pipenv', 0) + +function! ale_linters#python#jedils#GetExecutable(buffer) abort + if (ale#Var(a:buffer, 'python_auto_pipenv') || ale#Var(a:buffer, 'python_jedils_auto_pipenv')) + \ && ale#python#PipenvPresent(a:buffer) + return 'pipenv' + endif + + return ale#python#FindExecutable(a:buffer, 'python_jedils', ['jedi-language-server']) +endfunction + +function! ale_linters#python#jedils#GetCommand(buffer) abort + let l:executable = ale_linters#python#jedils#GetExecutable(a:buffer) + + let l:exec_args = l:executable =~? 'pipenv$' + \ ? ' run jedi-language-server' + \ : '' + + return ale#Escape(l:executable) . l:exec_args +endfunction + +call ale#linter#Define('python', { +\ 'name': 'jedils', +\ 'lsp': 'stdio', +\ 'executable': function('ale_linters#python#jedils#GetExecutable'), +\ 'command': function('ale_linters#python#jedils#GetCommand'), +\ 'project_root': function('ale#python#FindProjectRoot'), +\ 'completion_filter': 'ale#completion#python#CompletionItemFilter', +\}) diff --git a/sources_non_forked/ale/ale_linters/python/pydocstyle.vim b/sources_non_forked/ale/ale_linters/python/pydocstyle.vim index 3901db4d..69ae3807 100644 --- a/sources_non_forked/ale/ale_linters/python/pydocstyle.vim +++ b/sources_non_forked/ale/ale_linters/python/pydocstyle.vim @@ -16,17 +16,15 @@ function! ale_linters#python#pydocstyle#GetExecutable(buffer) abort endfunction function! ale_linters#python#pydocstyle#GetCommand(buffer) abort - let l:dir = fnamemodify(bufname(a:buffer), ':p:h') let l:executable = ale_linters#python#pydocstyle#GetExecutable(a:buffer) - let l:exec_args = l:executable =~? 'pipenv$' \ ? ' run pydocstyle' \ : '' - return ale#path#CdString(l:dir) + return ale#path#BufferCdString(a:buffer) \ . ale#Escape(l:executable) . l:exec_args - \ . ' ' . ale#Var(a:buffer, 'python_pydocstyle_options') - \ . ' ' . ale#Escape(fnamemodify(bufname(a:buffer), ':p:t')) + \ . ale#Pad(ale#Var(a:buffer, 'python_pydocstyle_options')) + \ . ' %s:t' endfunction function! ale_linters#python#pydocstyle#Handle(buffer, lines) abort diff --git a/sources_non_forked/ale/ale_linters/python/pylint.vim b/sources_non_forked/ale/ale_linters/python/pylint.vim index b16d5355..44eea246 100644 --- a/sources_non_forked/ale/ale_linters/python/pylint.vim +++ b/sources_non_forked/ale/ale_linters/python/pylint.vim @@ -17,7 +17,7 @@ function! ale_linters#python#pylint#GetExecutable(buffer) abort return ale#python#FindExecutable(a:buffer, 'python_pylint', ['pylint']) endfunction -function! ale_linters#python#pylint#GetCommand(buffer) abort +function! ale_linters#python#pylint#GetCommand(buffer, version) abort let l:cd_string = '' if ale#Var(a:buffer, 'python_pylint_change_directory') @@ -38,17 +38,23 @@ function! ale_linters#python#pylint#GetCommand(buffer) abort return l:cd_string \ . ale#Escape(l:executable) . l:exec_args - \ . ' ' . ale#Var(a:buffer, 'python_pylint_options') + \ . ale#Pad(ale#Var(a:buffer, 'python_pylint_options')) \ . ' --output-format text --msg-template="{path}:{line}:{column}: {msg_id} ({symbol}) {msg}" --reports n' + \ . (ale#semver#GTE(a:version, [2, 4, 0]) ? ' --from-stdin' : '') \ . ' %s' endfunction function! ale_linters#python#pylint#Handle(buffer, lines) abort + let l:output = ale#python#HandleTraceback(a:lines, 10) + + if !empty(l:output) + return l:output + endif + " Matches patterns like the following: " " test.py:4:4: W0101 (unreachable) Unreachable code let l:pattern = '\v^[a-zA-Z]?:?[^:]+:(\d+):(\d+): ([[:alnum:]]+) \(([^(]*)\) (.*)$' - let l:output = [] for l:match in ale#util#GetMatches(a:lines, l:pattern) "let l:failed = append(0, l:match) @@ -71,13 +77,19 @@ function! ale_linters#python#pylint#Handle(buffer, lines) abort let l:code_out = l:match[4] endif - call add(l:output, { + let l:item = { \ 'lnum': l:match[1] + 0, \ 'col': l:match[2] + 1, \ 'text': l:match[5], \ 'code': l:code_out, - \ 'type': l:code[:0] is# 'E' ? 'E' : 'W', - \}) + \ 'type': 'W', + \} + + if l:code[:0] is# 'E' + let l:item.type = 'E' + endif + + call add(l:output, l:item) endfor return l:output @@ -86,7 +98,17 @@ endfunction call ale#linter#Define('python', { \ 'name': 'pylint', \ 'executable': function('ale_linters#python#pylint#GetExecutable'), -\ 'command': function('ale_linters#python#pylint#GetCommand'), +\ 'lint_file': {buffer -> ale#semver#RunWithVersionCheck( +\ buffer, +\ ale#Var(buffer, 'python_pylint_executable'), +\ '%e --version', +\ {buffer, version -> !ale#semver#GTE(version, [2, 4, 0])}, +\ )}, +\ 'command': {buffer -> ale#semver#RunWithVersionCheck( +\ buffer, +\ ale#Var(buffer, 'python_pylint_executable'), +\ '%e --version', +\ function('ale_linters#python#pylint#GetCommand'), +\ )}, \ 'callback': 'ale_linters#python#pylint#Handle', -\ 'lint_file': 1, \}) diff --git a/sources_non_forked/ale/ale_linters/python/pyright.vim b/sources_non_forked/ale/ale_linters/python/pyright.vim new file mode 100644 index 00000000..422ecd61 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/python/pyright.vim @@ -0,0 +1,43 @@ +call ale#Set('python_pyright_executable', 'pyright-langserver') +call ale#Set('python_pyright_config', {}) + +function! ale_linters#python#pyright#GetConfig(buffer) abort + let l:config = deepcopy(ale#Var(a:buffer, 'python_pyright_config')) + + if !has_key(l:config, 'python') + let l:config.python = {} + endif + + if type(l:config.python) is v:t_dict + " Automatically detect the virtualenv path and use it. + if !has_key(l:config.python, 'venvPath') + let l:venv = ale#python#FindVirtualenv(a:buffer) + + if !empty(l:venv) + let l:config.python.venvPath = l:venv + endif + endif + + " Automatically use the version of Python in virtualenv. + if type(get(l:config.python, 'venvPath')) is v:t_string + \&& !empty(l:config.python.venvPath) + \&& !has_key(l:config.python, 'pythonPath') + let l:config.python.pythonPath = ale#path#Simplify( + \ l:config.python.venvPath + \ . (has('win32') ? '/Scripts/python' : '/bin/python') + \) + endif + endif + + return l:config +endfunction + +call ale#linter#Define('python', { +\ 'name': 'pyright', +\ 'lsp': 'stdio', +\ 'executable': {b -> ale#Var(b, 'python_pyright_executable')}, +\ 'command': '%e --stdio', +\ 'project_root': function('ale#python#FindProjectRoot'), +\ 'completion_filter': 'ale#completion#python#CompletionItemFilter', +\ 'lsp_config': function('ale_linters#python#pyright#GetConfig'), +\}) diff --git a/sources_non_forked/ale/ale_linters/r/languageserver.vim b/sources_non_forked/ale/ale_linters/r/languageserver.vim new file mode 100644 index 00000000..febe66bd --- /dev/null +++ b/sources_non_forked/ale/ale_linters/r/languageserver.vim @@ -0,0 +1,26 @@ +" Author: Eric Zhao <21zhaoe@protonmail.com> +" Description: Implementation of the Language Server Protocol for R. + +call ale#Set('r_languageserver_cmd', 'languageserver::run()') +call ale#Set('r_languageserver_config', {}) + +function! ale_linters#r#languageserver#GetCommand(buffer) abort + let l:cmd_string = ale#Var(a:buffer, 'r_languageserver_cmd') + + return 'Rscript --vanilla -e ' . ale#Escape(l:cmd_string) +endfunction + +function! ale_linters#r#languageserver#GetProjectRoot(buffer) abort + let l:project_root = ale#path#FindNearestFile(a:buffer, '.Rprofile') + + return !empty(l:project_root) ? fnamemodify(l:project_root, ':h') : fnamemodify(a:buffer, ':h') +endfunction + +call ale#linter#Define('r', { +\ 'name': 'languageserver', +\ 'lsp': 'stdio', +\ 'lsp_config': {b -> ale#Var(b, 'r_languageserver_config')}, +\ 'executable': 'Rscript', +\ 'command': function('ale_linters#r#languageserver#GetCommand'), +\ 'project_root': function('ale_linters#r#languageserver#GetProjectRoot') +\}) diff --git a/sources_non_forked/ale/ale_linters/reason/ols.vim b/sources_non_forked/ale/ale_linters/reason/ols.vim index 66137e1b..9fbd9b4f 100644 --- a/sources_non_forked/ale/ale_linters/reason/ols.vim +++ b/sources_non_forked/ale/ale_linters/reason/ols.vim @@ -9,6 +9,6 @@ call ale#linter#Define('reason', { \ 'lsp': 'stdio', \ 'executable': function('ale#handlers#ols#GetExecutable'), \ 'command': function('ale#handlers#ols#GetCommand'), -\ 'language_callback': 'ale#handlers#ols#GetLanguage', +\ 'language': function('ale#handlers#ols#GetLanguage'), \ 'project_root': function('ale#handlers#ols#GetProjectRoot'), \}) diff --git a/sources_non_forked/ale/ale_linters/ruby/rubocop.vim b/sources_non_forked/ale/ale_linters/ruby/rubocop.vim index 410ed0ea..483806a6 100644 --- a/sources_non_forked/ale/ale_linters/ruby/rubocop.vim +++ b/sources_non_forked/ale/ale_linters/ruby/rubocop.vim @@ -10,7 +10,7 @@ function! ale_linters#ruby#rubocop#GetCommand(buffer) abort return ale#ruby#EscapeExecutable(l:executable, 'rubocop') \ . ' --format json --force-exclusion ' \ . ale#Var(a:buffer, 'ruby_rubocop_options') - \ . ' --stdin ' . ale#Escape(expand('#' . a:buffer . ':p')) + \ . ' --stdin %s' endfunction function! ale_linters#ruby#rubocop#GetType(severity) abort diff --git a/sources_non_forked/ale/ale_linters/ruby/standardrb.vim b/sources_non_forked/ale/ale_linters/ruby/standardrb.vim index f751e803..6ccfd2d6 100644 --- a/sources_non_forked/ale/ale_linters/ruby/standardrb.vim +++ b/sources_non_forked/ale/ale_linters/ruby/standardrb.vim @@ -11,7 +11,7 @@ function! ale_linters#ruby#standardrb#GetCommand(buffer) abort return ale#ruby#EscapeExecutable(l:executable, 'standardrb') \ . ' --format json --force-exclusion ' \ . ale#Var(a:buffer, 'ruby_standardrb_options') - \ . ' --stdin ' . ale#Escape(expand('#' . a:buffer . ':p')) + \ . ' --stdin %s' endfunction " standardrb is based on RuboCop so the callback is the same diff --git a/sources_non_forked/ale/ale_linters/rust/analyzer.vim b/sources_non_forked/ale/ale_linters/rust/analyzer.vim new file mode 100644 index 00000000..3666ec03 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/rust/analyzer.vim @@ -0,0 +1,24 @@ +" Author: Jon Gjengset +" Description: The next generation language server for Rust + +call ale#Set('rust_analyzer_executable', 'rust-analyzer') +call ale#Set('rust_analyzer_config', {}) + +function! ale_linters#rust#analyzer#GetCommand(buffer) abort + return '%e' +endfunction + +function! ale_linters#rust#analyzer#GetProjectRoot(buffer) abort + let l:cargo_file = ale#path#FindNearestFile(a:buffer, 'Cargo.toml') + + return !empty(l:cargo_file) ? fnamemodify(l:cargo_file, ':h') : '' +endfunction + +call ale#linter#Define('rust', { +\ 'name': 'analyzer', +\ 'lsp': 'stdio', +\ 'lsp_config': {b -> ale#Var(b, 'rust_analyzer_config')}, +\ 'executable': {b -> ale#Var(b, 'rust_analyzer_executable')}, +\ 'command': function('ale_linters#rust#analyzer#GetCommand'), +\ 'project_root': function('ale_linters#rust#analyzer#GetProjectRoot'), +\}) diff --git a/sources_non_forked/ale/ale_linters/rust/cargo.vim b/sources_non_forked/ale/ale_linters/rust/cargo.vim index 99178585..3407abed 100644 --- a/sources_non_forked/ale/ale_linters/rust/cargo.vim +++ b/sources_non_forked/ale/ale_linters/rust/cargo.vim @@ -11,6 +11,7 @@ call ale#Set('rust_cargo_default_feature_behavior', 'default') call ale#Set('rust_cargo_include_features', '') call ale#Set('rust_cargo_use_clippy', 0) call ale#Set('rust_cargo_clippy_options', '') +call ale#Set('rust_cargo_target_dir', '') function! ale_linters#rust#cargo#GetCargoExecutable(bufnr) abort if ale#path#FindNearestFile(a:bufnr, 'Cargo.toml') isnot# '' @@ -31,6 +32,9 @@ function! ale_linters#rust#cargo#GetCommand(buffer, version) abort \ && ale#semver#GTE(a:version, [0, 22, 0]) let l:use_tests = ale#Var(a:buffer, 'rust_cargo_check_tests') \ && ale#semver#GTE(a:version, [0, 22, 0]) + let l:target_dir = ale#Var(a:buffer, 'rust_cargo_target_dir') + let l:use_target_dir = !empty(l:target_dir) + \ && ale#semver#GTE(a:version, [0, 17, 0]) let l:include_features = ale#Var(a:buffer, 'rust_cargo_include_features') @@ -82,6 +86,7 @@ function! ale_linters#rust#cargo#GetCommand(buffer, version) abort \ . (l:use_all_targets ? ' --all-targets' : '') \ . (l:use_examples ? ' --examples' : '') \ . (l:use_tests ? ' --tests' : '') + \ . (l:use_target_dir ? (' --target-dir ' . ale#Escape(l:target_dir)) : '') \ . ' --frozen --message-format=json -q' \ . l:default_feature \ . l:include_features diff --git a/sources_non_forked/ale/ale_linters/scala/metals.vim b/sources_non_forked/ale/ale_linters/scala/metals.vim index f78c7119..da9e855d 100644 --- a/sources_non_forked/ale/ale_linters/scala/metals.vim +++ b/sources_non_forked/ale/ale_linters/scala/metals.vim @@ -32,6 +32,8 @@ function! ale_linters#scala#metals#GetProjectRoot(buffer) abort \) endif endfor + + return '' endfunction function! ale_linters#scala#metals#GetCommand(buffer) abort diff --git a/sources_non_forked/ale/ale_linters/sh/bashate.vim b/sources_non_forked/ale/ale_linters/sh/bashate.vim new file mode 100644 index 00000000..3cd84245 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/sh/bashate.vim @@ -0,0 +1,43 @@ +" Author: hsanson +" Description: Lints sh files using bashate +" URL: https://github.com/openstack/bashate + +call ale#Set('sh_bashate_executable', 'bashate') +call ale#Set('sh_bashate_options', '') + +function! ale_linters#sh#bashate#GetExecutable(buffer) abort + return ale#Var(a:buffer, 'sh_bashate_executable') +endfunction + +function! ale_linters#sh#bashate#GetCommand(buffer) abort + let l:options = ale#Var(a:buffer, 'sh_bashate_options') + let l:executable = ale_linters#sh#bashate#GetExecutable(a:buffer) + + return ale#Escape(l:executable) . ' ' . l:options . ' ' . '%t' +endfunction + +function! ale_linters#sh#bashate#Handle(buffer, lines) abort + " Matches patterns line the following: + " + " /path/to/script/file:694:1: E003 Indent not multiple of 4 + let l:pattern = ':\(\d\+\):\(\d\+\): \(.*\)$' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + call add(l:output, { + \ 'lnum': str2nr(l:match[1]), + \ 'col': str2nr(l:match[2]), + \ 'text': l:match[3], + \}) + endfor + + return l:output +endfunction + +call ale#linter#Define('sh', { +\ 'name': 'bashate', +\ 'output_stream': 'stdout', +\ 'executable': function('ale_linters#sh#bashate#GetExecutable'), +\ 'command': function('ale_linters#sh#bashate#GetCommand'), +\ 'callback': 'ale_linters#sh#bashate#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/sh/shell.vim b/sources_non_forked/ale/ale_linters/sh/shell.vim index 171fe64e..73ab3608 100644 --- a/sources_non_forked/ale/ale_linters/sh/shell.vim +++ b/sources_non_forked/ale/ale_linters/sh/shell.vim @@ -1,5 +1,5 @@ " Author: w0rp -" Description: Lints sh files using bash -n +" Description: Lints shell files by invoking the shell with -n " Backwards compatibility if exists('g:ale_linters_sh_shell_default_shell') diff --git a/sources_non_forked/ale/ale_linters/sh/shellcheck.vim b/sources_non_forked/ale/ale_linters/sh/shellcheck.vim index 1d8b6096..d9945126 100644 --- a/sources_non_forked/ale/ale_linters/sh/shellcheck.vim +++ b/sources_non_forked/ale/ale_linters/sh/shellcheck.vim @@ -1,107 +1,4 @@ " Author: w0rp -" Description: This file adds support for using the shellcheck linter with -" shell scripts. +" Description: shellcheck linter for shell scripts. -" This global variable can be set with a string of comma-separated error -" codes to exclude from shellcheck. For example: -" -" let g:ale_sh_shellcheck_exclusions = 'SC2002,SC2004' -call ale#Set('sh_shellcheck_exclusions', get(g:, 'ale_linters_sh_shellcheck_exclusions', '')) -call ale#Set('sh_shellcheck_executable', 'shellcheck') -call ale#Set('sh_shellcheck_dialect', 'auto') -call ale#Set('sh_shellcheck_options', '') -call ale#Set('sh_shellcheck_change_directory', 1) - -function! ale_linters#sh#shellcheck#GetDialectArgument(buffer) abort - let l:shell_type = ale#handlers#sh#GetShellType(a:buffer) - - if !empty(l:shell_type) - " Use the dash dialect for /bin/ash, etc. - if l:shell_type is# 'ash' - return 'dash' - endif - - return l:shell_type - endif - - " If there's no hashbang, try using Vim's buffer variables. - if getbufvar(a:buffer, 'is_bash', 0) - return 'bash' - elseif getbufvar(a:buffer, 'is_sh', 0) - return 'sh' - elseif getbufvar(a:buffer, 'is_kornshell', 0) - return 'ksh' - endif - - return '' -endfunction - -function! ale_linters#sh#shellcheck#GetCommand(buffer, version) abort - let l:options = ale#Var(a:buffer, 'sh_shellcheck_options') - let l:exclude_option = ale#Var(a:buffer, 'sh_shellcheck_exclusions') - let l:dialect = ale#Var(a:buffer, 'sh_shellcheck_dialect') - let l:external_option = ale#semver#GTE(a:version, [0, 4, 0]) ? ' -x' : '' - let l:cd_string = ale#Var(a:buffer, 'sh_shellcheck_change_directory') - \ ? ale#path#BufferCdString(a:buffer) - \ : '' - - if l:dialect is# 'auto' - let l:dialect = ale_linters#sh#shellcheck#GetDialectArgument(a:buffer) - endif - - return l:cd_string - \ . '%e' - \ . (!empty(l:dialect) ? ' -s ' . l:dialect : '') - \ . (!empty(l:options) ? ' ' . l:options : '') - \ . (!empty(l:exclude_option) ? ' -e ' . l:exclude_option : '') - \ . l:external_option - \ . ' -f gcc -' -endfunction - -function! ale_linters#sh#shellcheck#Handle(buffer, lines) abort - let l:pattern = '\v^([a-zA-Z]?:?[^:]+):(\d+):(\d+)?:? ([^:]+): (.+) \[([^\]]+)\]$' - let l:output = [] - - for l:match in ale#util#GetMatches(a:lines, l:pattern) - if l:match[4] is# 'error' - let l:type = 'E' - elseif l:match[4] is# 'note' - let l:type = 'I' - else - let l:type = 'W' - endif - - let l:item = { - \ 'lnum': str2nr(l:match[2]), - \ 'type': l:type, - \ 'text': l:match[5], - \ 'code': l:match[6], - \} - - if !empty(l:match[3]) - let l:item.col = str2nr(l:match[3]) - endif - - " If the filename is something like , or -, then - " this is an error for the file we checked. - if l:match[1] isnot# '-' && l:match[1][0] isnot# '<' - let l:item['filename'] = l:match[1] - endif - - call add(l:output, l:item) - endfor - - return l:output -endfunction - -call ale#linter#Define('sh', { -\ 'name': 'shellcheck', -\ 'executable': {buffer -> ale#Var(buffer, 'sh_shellcheck_executable')}, -\ 'command': {buffer -> ale#semver#RunWithVersionCheck( -\ buffer, -\ ale#Var(buffer, 'sh_shellcheck_executable'), -\ '%e --version', -\ function('ale_linters#sh#shellcheck#GetCommand'), -\ )}, -\ 'callback': 'ale_linters#sh#shellcheck#Handle', -\}) +call ale#handlers#shellcheck#DefineLinter('sh') diff --git a/sources_non_forked/ale/ale_linters/sql/sqllint.vim b/sources_non_forked/ale/ale_linters/sql/sqllint.vim new file mode 100644 index 00000000..78396fe9 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/sql/sqllint.vim @@ -0,0 +1,33 @@ +" ale_linters/sql/sqllint.vim +" Author: Joe Reynolds +" Description: sql-lint for SQL files. +" sql-lint can be found at +" https://www.npmjs.com/package/sql-lint +" https://github.com/joereynolds/sql-lint + +function! ale_linters#sql#sqllint#Handle(buffer, lines) abort + " Matches patterns like the following: + " + " stdin:1 [ER_NO_DB_ERROR] No database selected + let l:pattern = '\v^[^:]+:(\d+) (.*)' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + call add(l:output, { + \ 'lnum': l:match[1] + 0, + \ 'col': l:match[2] + 0, + \ 'type': l:match[3][0], + \ 'text': l:match[0], + \}) + endfor + + return l:output +endfunction + +call ale#linter#Define('sql', { +\ 'name': 'sqllint', +\ 'aliases': ['sql-lint'], +\ 'executable': 'sql-lint', +\ 'command': 'sql-lint', +\ 'callback': 'ale_linters#sql#sqllint#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/swift/swiftformat.vim b/sources_non_forked/ale/ale_linters/swift/swiftformat.vim new file mode 100644 index 00000000..2504511a --- /dev/null +++ b/sources_non_forked/ale/ale_linters/swift/swiftformat.vim @@ -0,0 +1,62 @@ +" Author: Klaas Pieter Annema +" Description: Support for swift-format https://github.com/apple/swift-format + +let s:default_executable = 'swift-format' +call ale#Set('swift_swiftformat_executable', s:default_executable) + +function! ale_linters#swift#swiftformat#UseSwift(buffer) abort + let l:swift_config = ale#path#FindNearestFile(a:buffer, 'Package.swift') + let l:executable = ale#Var(a:buffer, 'swift_swiftformat_executable') + + return !empty(l:swift_config) && l:executable is# s:default_executable +endfunction + +function! ale_linters#swift#swiftformat#GetExecutable(buffer) abort + if ale_linters#swift#swiftformat#UseSwift(a:buffer) + return 'swift' + endif + + return ale#Var(a:buffer, 'swift_swiftformat_executable') +endfunction + +function! ale_linters#swift#swiftformat#GetCommand(buffer) abort + let l:executable = ale_linters#swift#swiftformat#GetExecutable(a:buffer) + let l:args = '--mode lint %t' + + if ale_linters#swift#swiftformat#UseSwift(a:buffer) + let l:args = 'run swift-format' . ' ' . l:args + endif + + return ale#Escape(l:executable) . ' ' . l:args +endfunction + +function! ale_linters#swift#swiftformat#Handle(buffer, lines) abort + " Matches lines of the following pattern: + " + " Sources/main.swift:4:21: warning: [DoNotUseSemicolons]: remove ';' and move the next statement to the new line + " Sources/main.swift:3:12: warning: [Spacing]: remove 1 space + let l:pattern = '\v^.*:(\d+):(\d+): (\S+) \[(\S+)\]: (.*)$' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + call add(l:output, { + \ 'lnum': l:match[1] + 0, + \ 'col': l:match[2] + 0, + \ 'type': l:match[3] is# 'error' ? 'E' : 'W', + \ 'code': l:match[4], + \ 'text': l:match[5], + \}) + endfor + + return l:output +endfunction + + +call ale#linter#Define('swift', { +\ 'name': 'swift-format', +\ 'executable': function('ale_linters#swift#swiftformat#GetExecutable'), +\ 'command': function('ale_linters#swift#swiftformat#GetCommand'), +\ 'output_stream': 'stderr', +\ 'language': 'swift', +\ 'callback': 'ale_linters#swift#swiftformat#Handle' +\}) diff --git a/sources_non_forked/ale/ale_linters/terraform/terraform_lsp.vim b/sources_non_forked/ale/ale_linters/terraform/terraform_lsp.vim new file mode 100644 index 00000000..e2408c15 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/terraform/terraform_lsp.vim @@ -0,0 +1,25 @@ +" Author: OJFord +" Description: terraform-lsp integration for ALE (cf. https://github.com/juliosueiras/terraform-lsp) + +call ale#Set('terraform_langserver_executable', 'terraform-lsp') +call ale#Set('terraform_langserver_options', '') + +function! ale_linters#terraform#terraform_lsp#GetCommand(buffer) abort + return '%e' + \ . ale#Pad(ale#Var(a:buffer, 'terraform_langserver_options')) +endfunction + +function! ale_linters#terraform#terraform_lsp#GetProjectRoot(buffer) abort + let l:tf_dir = ale#path#FindNearestDirectory(a:buffer, '.terraform') + + return !empty(l:tf_dir) ? fnamemodify(l:tf_dir, ':h:h') : '' +endfunction + +call ale#linter#Define('terraform', { +\ 'name': 'terraform_lsp', +\ 'lsp': 'stdio', +\ 'executable': {b -> ale#Var(b, 'terraform_langserver_executable')}, +\ 'command': function('ale_linters#terraform#terraform_lsp#GetCommand'), +\ 'project_root': function('ale_linters#terraform#terraform_lsp#GetProjectRoot'), +\ 'language': 'terraform', +\}) diff --git a/sources_non_forked/ale/ale_linters/typescript/tsserver.vim b/sources_non_forked/ale/ale_linters/typescript/tsserver.vim index 840889f3..4726e40d 100644 --- a/sources_non_forked/ale/ale_linters/typescript/tsserver.vim +++ b/sources_non_forked/ale/ale_linters/typescript/tsserver.vim @@ -9,6 +9,7 @@ call ale#linter#Define('typescript', { \ 'name': 'tsserver', \ 'lsp': 'tsserver', \ 'executable': {b -> ale#node#FindExecutable(b, 'typescript_tsserver', [ +\ '.yarn/sdks/typescript/bin/tsserver', \ 'node_modules/.bin/tsserver', \ ])}, \ 'command': '%e', diff --git a/sources_non_forked/ale/ale_linters/verilog/hdl_checker.vim b/sources_non_forked/ale/ale_linters/verilog/hdl_checker.vim new file mode 100644 index 00000000..b05d8565 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/verilog/hdl_checker.vim @@ -0,0 +1,5 @@ +" Author: suoto +" Description: Adds support for HDL Code Checker, which wraps vcom/vlog, ghdl +" or xvhdl. More info on https://github.com/suoto/hdl_checker + +call ale#handlers#hdl_checker#DefineLinter('verilog') diff --git a/sources_non_forked/ale/ale_linters/verilog/verilator.vim b/sources_non_forked/ale/ale_linters/verilog/verilator.vim index 64bb6e41..029dd4c9 100644 --- a/sources_non_forked/ale/ale_linters/verilog/verilator.vim +++ b/sources_non_forked/ale/ale_linters/verilog/verilator.vim @@ -28,21 +28,30 @@ function! ale_linters#verilog#verilator#Handle(buffer, lines) abort " %Warning-UNDRIVEN: test.v:3: Signal is not driven: clk " %Warning-UNUSED: test.v:4: Signal is not used: dout " %Warning-BLKSEQ: test.v:10: Blocking assignments (=) in sequential (flop or latch) block; suggest delayed assignments (<=). - let l:pattern = '^%\(Warning\|Error\)[^:]*:\([^:]\+\):\(\d\+\): \(.\+\)$' + " Since version 4.032 (04/2020) verilator linter messages also contain the column number, + " and look like: + " %Error: /tmp/test.sv:3:1: syntax error, unexpected endmodule, expecting ';' + " + " to stay compatible with old versions of the tool, the column number is + " optional in the researched pattern + let l:pattern = '^%\(Warning\|Error\)[^:]*:\([^:]\+\):\(\d\+\):\(\d\+\)\?:\? \(.\+\)$' let l:output = [] for l:match in ale#util#GetMatches(a:lines, l:pattern) - let l:line = l:match[3] + 0 - let l:type = l:match[1] is# 'Error' ? 'E' : 'W' - let l:text = l:match[4] + let l:item = { + \ 'lnum': str2nr(l:match[3]), + \ 'text': l:match[5], + \ 'type': l:match[1] is# 'Error' ? 'E' : 'W', + \} + + if !empty(l:match[4]) + let l:item.col = str2nr(l:match[4]) + endif + let l:file = l:match[2] if l:file =~# '_verilator_linted.v' - call add(l:output, { - \ 'lnum': l:line, - \ 'text': l:text, - \ 'type': l:type, - \}) + call add(l:output, l:item) endif endfor diff --git a/sources_non_forked/ale/ale_linters/verilog/vlog.vim b/sources_non_forked/ale/ale_linters/verilog/vlog.vim index 951e2037..45e1977c 100644 --- a/sources_non_forked/ale/ale_linters/verilog/vlog.vim +++ b/sources_non_forked/ale/ale_linters/verilog/vlog.vim @@ -13,14 +13,15 @@ function! ale_linters#verilog#vlog#Handle(buffer, lines) abort "Matches patterns like the following: "** Warning: add.v(7): (vlog-2623) Undefined variable: C. "** Error: file.v(1): (vlog-13294) Identifier must be declared with a port mode: C. - let l:pattern = '^**\s\(\w*\):[a-zA-Z0-9\-\.\_\/ ]\+(\(\d\+\)):\s\+\(.*\)' + let l:pattern = '^**\s\(\w*\): \([a-zA-Z0-9\-\.\_\/ ]\+\)(\(\d\+\)):\s\+\(.*\)' let l:output = [] for l:match in ale#util#GetMatches(a:lines, l:pattern) call add(l:output, { - \ 'lnum': l:match[2] + 0, + \ 'lnum': l:match[3] + 0, \ 'type': l:match[1] is? 'Error' ? 'E' : 'W', - \ 'text': l:match[3], + \ 'text': l:match[4], + \ 'filename': l:match[2], \}) endfor @@ -28,13 +29,14 @@ function! ale_linters#verilog#vlog#Handle(buffer, lines) abort "** Warning: (vlog-2623) add.v(7): Undefined variable: C. "** Error: (vlog-13294) file.v(1): Identifier must be declared with a port mode: C. " let l:pattern = '^**\s\(\w*\):[a-zA-Z0-9\-\.\_\/ ]\+(\(\d\+\)):\s\+\(.*\)' - let l:pattern = '^**\s\(\w*\):\s\([^)]*)\)[a-zA-Z0-9\-\.\_\/ ]\+(\(\d\+\)):\s\+\(.*\)' + let l:pattern = '^**\s\(\w*\):\s\([^)]*)\) \([a-zA-Z0-9\-\.\_\/ ]\+\)(\(\d\+\)):\s\+\(.*\)' for l:match in ale#util#GetMatches(a:lines, l:pattern) call add(l:output, { - \ 'lnum': l:match[3] + 0, + \ 'lnum': l:match[4] + 0, \ 'type': l:match[1] is? 'Error' ? 'E' : 'W', - \ 'text': l:match[2] . ' ' . l:match[4], + \ 'text': l:match[2] . ' ' . l:match[5], + \ 'filename': l:match[3], \}) endfor diff --git a/sources_non_forked/ale/ale_linters/vhdl/hdl_checker.vim b/sources_non_forked/ale/ale_linters/vhdl/hdl_checker.vim new file mode 100644 index 00000000..c9d306b3 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/vhdl/hdl_checker.vim @@ -0,0 +1,5 @@ +" Author: suoto +" Description: Adds support for HDL Code Checker, which wraps vcom/vlog, ghdl +" or xvhdl. More info on https://github.com/suoto/hdl_checker + +call ale#handlers#hdl_checker#DefineLinter('vhdl') diff --git a/sources_non_forked/ale/ale_linters/vim/vimls.vim b/sources_non_forked/ale/ale_linters/vim/vimls.vim new file mode 100644 index 00000000..26014d66 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/vim/vimls.vim @@ -0,0 +1,61 @@ +" Author: Jeffrey Lau - https://github.com/zoonfafer +" Description: Vim Language Server integration for ALE + +call ale#Set('vim_vimls_executable', 'vim-language-server') +call ale#Set('vim_vimls_use_global', get(g:, 'ale_use_global_executables', 0)) +call ale#Set('vim_vimls_config', {}) + +function! ale_linters#vim#vimls#GetProjectRoot(buffer) abort + let l:trigger_file_candidates = [ + \ '.vimrc', + \ 'init.vim', + \] + + for l:candidate in l:trigger_file_candidates + let l:trigger_file = fnamemodify(bufname(a:buffer), ':t') + + if l:trigger_file is# l:candidate + return fnamemodify( + \ bufname(a:buffer), + \ ':h', + \) + endif + endfor + + let l:trigger_dir_candidates = [ + \ 'autoload', + \ 'plugin', + \ '.git', + \] + + let l:path_upwards = ale#path#Upwards(fnamemodify(bufname(a:buffer), ':p:h')) + + for l:path in l:path_upwards + for l:candidate in l:trigger_dir_candidates + let l:trigger_dir = ale#path#Simplify( + \ l:path . '/' . l:candidate, + \) + + if isdirectory(l:trigger_dir) + return fnamemodify( + \ l:trigger_dir, + \ ':p:h:h', + \) + endif + endfor + endfor + + return '' +endfunction + +call ale#linter#Define('vim', { +\ 'name': 'vimls', +\ 'lsp': 'stdio', +\ 'lsp_config': {b -> ale#Var(b, 'vim_vimls_config')}, +\ 'executable': {b -> ale#node#FindExecutable(b, 'vim_vimls', [ +\ 'node_modules/.bin/vim-language-server', +\ ])}, +\ 'command': '%e --stdio', +\ 'language': 'vim', +\ 'project_root': function('ale_linters#vim#vimls#GetProjectRoot'), +\}) diff --git a/sources_non_forked/ale/ale_linters/vim/vint.vim b/sources_non_forked/ale/ale_linters/vim/vint.vim index 65e19126..f7054ffb 100644 --- a/sources_non_forked/ale/ale_linters/vim/vint.vim +++ b/sources_non_forked/ale/ale_linters/vim/vint.vim @@ -5,7 +5,7 @@ call ale#Set('vim_vint_show_style_issues', 1) call ale#Set('vim_vint_executable', 'vint') let s:enable_neovim = has('nvim') ? ' --enable-neovim' : '' -let s:format = '-f "{file_path}:{line_number}:{column_number}: {severity}: {description} (see {reference})"' +let s:format = '-f "{file_path}:{line_number}:{column_number}: {severity}: {policy_name} - {description} (see {reference})"' function! ale_linters#vim#vint#GetCommand(buffer, version) abort let l:can_use_no_color_flag = empty(a:version) @@ -13,12 +13,17 @@ function! ale_linters#vim#vint#GetCommand(buffer, version) abort let l:warning_flag = ale#Var(a:buffer, 'vim_vint_show_style_issues') ? '-s' : '-w' + " Use the --stdin-display-name argument if supported, temp file otherwise. + let l:stdin_or_temp = ale#semver#GTE(a:version, [0, 4, 0]) + \ ? ' --stdin-display-name %s -' + \ : ' %t' + return '%e' \ . ' ' . l:warning_flag \ . (l:can_use_no_color_flag ? ' --no-color' : '') \ . s:enable_neovim \ . ' ' . s:format - \ . ' %t' + \ . l:stdin_or_temp endfunction let s:word_regex_list = [ diff --git a/sources_non_forked/ale/ale_linters/zig/zls.vim b/sources_non_forked/ale/ale_linters/zig/zls.vim new file mode 100644 index 00000000..1390f6b1 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/zig/zls.vim @@ -0,0 +1,20 @@ +" Author: CherryMan +" Description: A language server for Zig + +call ale#Set('zig_zls_executable', 'zls') +call ale#Set('zig_zls_config', {}) + +function! ale_linters#zig#zls#GetProjectRoot(buffer) abort + let l:build_rs = ale#path#FindNearestFile(a:buffer, 'build.zig') + + return !empty(l:build_rs) ? fnamemodify(l:build_rs, ':h') : '' +endfunction + +call ale#linter#Define('zig', { +\ 'name': 'zls', +\ 'lsp': 'stdio', +\ 'lsp_config': {b -> ale#Var(b, 'zig_zls_config')}, +\ 'executable': {b -> ale#Var(b, 'zig_zls_executable')}, +\ 'command': '%e', +\ 'project_root': function('ale_linters#zig#zls#GetProjectRoot'), +\}) diff --git a/sources_non_forked/ale/autoload/ale.vim b/sources_non_forked/ale/autoload/ale.vim index 755647e3..73fe2971 100644 --- a/sources_non_forked/ale/autoload/ale.vim +++ b/sources_non_forked/ale/autoload/ale.vim @@ -100,13 +100,7 @@ function! s:Lint(buffer, should_lint_file, timer_id) abort " Use the filetype from the buffer let l:filetype = getbufvar(a:buffer, '&filetype') let l:linters = ale#linter#Get(l:filetype) - - " Apply ignore lists for linters only if needed. - let l:ignore_config = ale#Var(a:buffer, 'linters_ignore') - let l:disable_lsp = ale#Var(a:buffer, 'disable_lsp') - let l:linters = !empty(l:ignore_config) || l:disable_lsp - \ ? ale#engine#ignore#Exclude(l:filetype, l:linters, l:ignore_config, l:disable_lsp) - \ : l:linters + let l:linters = ale#linter#RemoveIgnored(a:buffer, l:filetype, l:linters) " Tell other sources that they can start checking the buffer now. let g:ale_want_results_buffer = a:buffer @@ -163,11 +157,15 @@ function! ale#Queue(delay, ...) abort endif endfunction +<<<<<<< HEAD <<<<<<< HEAD let s:current_ale_version = [2, 5, 0] ======= let s:current_ale_version = [2, 6, 0] >>>>>>> 27ad0d07862847896f691309a544a206783c94d6 +======= +let s:current_ale_version = [3, 0, 0] +>>>>>>> master " A function used to check for ALE features in files outside of the project. function! ale#Has(feature) abort @@ -262,11 +260,33 @@ function! ale#GetLocItemMessage(item, format_string) abort " Replace special markers with certain information. " \=l:variable is used to avoid escaping issues. + let l:msg = substitute(l:msg, '\v\%([^\%]*)code([^\%]*)\%', l:code_repl, 'g') let l:msg = substitute(l:msg, '\V%severity%', '\=l:severity', 'g') let l:msg = substitute(l:msg, '\V%linter%', '\=l:linter_name', 'g') - let l:msg = substitute(l:msg, '\v\%([^\%]*)code([^\%]*)\%', l:code_repl, 'g') " Replace %s with the text. let l:msg = substitute(l:msg, '\V%s', '\=a:item.text', 'g') + " Windows may insert carriage return line endings (^M), strip these characters. + let l:msg = substitute(l:msg, '\r', '', 'g') return l:msg endfunction + +" Given a buffer and a linter or fixer name, return an Array of two-item +" Arrays describing how to map filenames to and from the local to foreign file +" systems. +function! ale#GetFilenameMappings(buffer, name) abort + let l:linter_mappings = ale#Var(a:buffer, 'filename_mappings') + + if type(l:linter_mappings) is v:t_list + return l:linter_mappings + endif + + let l:name = a:name + + if !has_key(l:linter_mappings, l:name) + " Use * as a default setting for all tools. + let l:name = '*' + endif + + return get(l:linter_mappings, l:name, []) +endfunction diff --git a/sources_non_forked/ale/autoload/ale/ant.vim b/sources_non_forked/ale/autoload/ale/ant.vim index 689b444b..7d02484e 100644 --- a/sources_non_forked/ale/autoload/ale/ant.vim +++ b/sources_non_forked/ale/autoload/ale/ant.vim @@ -1,4 +1,4 @@ -" Author: Andrew Lee . +" Author: Andrew Lee . " Inspired by ale/gradle.vim by Michael Pardo " Description: Functions for working with Ant projects. diff --git a/sources_non_forked/ale/autoload/ale/assert.vim b/sources_non_forked/ale/autoload/ale/assert.vim index 291edcee..934fcaa8 100644 --- a/sources_non_forked/ale/autoload/ale/assert.vim +++ b/sources_non_forked/ale/autoload/ale/assert.vim @@ -130,7 +130,7 @@ endfunction function! ale#assert#LSPLanguage(expected_language) abort let l:buffer = bufnr('') let l:linter = s:GetLinter() - let l:language = ale#util#GetFunction(l:linter.language_callback)(l:buffer) + let l:language = ale#linter#GetLanguage(l:buffer, l:linter) AssertEqual a:expected_language, l:language endfunction diff --git a/sources_non_forked/ale/autoload/ale/balloon.vim b/sources_non_forked/ale/autoload/ale/balloon.vim index 72f6b91c..8678376f 100644 --- a/sources_non_forked/ale/autoload/ale/balloon.vim +++ b/sources_non_forked/ale/autoload/ale/balloon.vim @@ -2,23 +2,39 @@ " Description: balloonexpr support for ALE. function! ale#balloon#MessageForPos(bufnr, lnum, col) abort + let l:set_balloons = ale#Var(a:bufnr, 'set_balloons') + let l:show_problems = 0 + let l:show_hover = 0 + + if l:set_balloons is 1 + let l:show_problems = 1 + let l:show_hover = 1 + elseif l:set_balloons is# 'hover' + let l:show_hover = 1 + endif + " Don't show balloons if they are disabled, or linting is disabled. - if !ale#Var(a:bufnr, 'set_balloons') + if !(l:show_problems || l:show_hover) \|| !g:ale_enabled \|| !getbufvar(a:bufnr, 'ale_enabled', 1) return '' endif - let l:loclist = get(g:ale_buffer_info, a:bufnr, {'loclist': []}).loclist - let l:index = ale#util#BinarySearch(l:loclist, a:bufnr, a:lnum, a:col) + if l:show_problems + let l:loclist = get(g:ale_buffer_info, a:bufnr, {'loclist': []}).loclist + let l:index = ale#util#BinarySearch(l:loclist, a:bufnr, a:lnum, a:col) + endif " Show the diagnostics message if found, 'Hover' output otherwise - if l:index >= 0 + if l:show_problems && l:index >= 0 return l:loclist[l:index].text - elseif exists('*balloon_show') || getbufvar( - \ a:bufnr, - \ 'ale_set_balloons_legacy_echo', - \ get(g:, 'ale_set_balloons_legacy_echo', 0) + elseif l:show_hover && ( + \ exists('*balloon_show') + \ || getbufvar( + \ a:bufnr, + \ 'ale_set_balloons_legacy_echo', + \ get(g:, 'ale_set_balloons_legacy_echo', 0) + \ ) \) " Request LSP/tsserver hover information, but only if this version of " Vim supports the balloon_show function, or if we turned a legacy diff --git a/sources_non_forked/ale/autoload/ale/c.vim b/sources_non_forked/ale/autoload/ale/c.vim index 9b428700..cff53125 100644 --- a/sources_non_forked/ale/autoload/ale/c.vim +++ b/sources_non_forked/ale/autoload/ale/c.vim @@ -2,20 +2,28 @@ " Description: Functions for integrating with C-family linters. call ale#Set('c_parse_makefile', 0) -call ale#Set('c_parse_compile_commands', 0) +call ale#Set('c_always_make', has('unix') && !has('macunix')) +call ale#Set('c_parse_compile_commands', 1) + let s:sep = has('win32') ? '\' : '/' " Set just so tests can override it. let g:__ale_c_project_filenames = ['.git/HEAD', 'configure', 'Makefile', 'CMakeLists.txt'] -function! ale#c#GetBuildDirectory(buffer) abort - " Don't include build directory for header files, as compile_commands.json - " files don't consider headers to be translation units, and provide no - " commands for compiling header files. - if expand('#' . a:buffer) =~# '\v\.(h|hpp)$' - return '' - endif +let g:ale_c_build_dir_names = get(g:, 'ale_c_build_dir_names', [ +\ 'build', +\ 'bin', +\]) +function! s:CanParseMakefile(buffer) abort + " Something somewhere seems to delete this setting in tests, so ensure we + " always have a default value. + call ale#Set('c_parse_makefile', 0) + + return ale#Var(a:buffer, 'c_parse_makefile') +endfunction + +function! ale#c#GetBuildDirectory(buffer) abort let l:build_dir = ale#Var(a:buffer, 'c_build_dir') " c_build_dir has the priority if defined @@ -68,14 +76,73 @@ function! ale#c#ShellSplit(line) abort return l:args endfunction -function! ale#c#ParseCFlags(path_prefix, cflag_line) abort - let l:cflags_list = [] +" Takes the path prefix and a list of cflags and expands @file arguments to +" the contents of the file. +" +" @file arguments are command line arguments recognised by gcc and clang. For +" instance, if @./path/to/file was given to gcc, it would load .path/to/file +" and use the contents of that file as arguments. +function! ale#c#ExpandAtArgs(path_prefix, raw_split_lines) abort + let l:out_lines = [] - let l:split_lines = ale#c#ShellSplit(a:cflag_line) + for l:option in a:raw_split_lines + if stridx(l:option, '@') == 0 + " This is an argument specifying a location of a file containing other arguments + let l:path = join(split(l:option, '\zs')[1:], '') + + " Make path absolute + if !ale#path#IsAbsolute(l:path) + let l:rel_path = substitute(l:path, '"', '', 'g') + let l:rel_path = substitute(l:rel_path, '''', '', 'g') + let l:path = ale#path#GetAbsPath(a:path_prefix, l:rel_path) + endif + + " Read the file and add all the arguments + try + let l:additional_args = readfile(l:path) + catch + continue " All we can really do is skip this argument + endtry + + let l:file_lines = [] + + for l:line in l:additional_args + let l:file_lines += ale#c#ShellSplit(l:line) + endfor + + " @file arguments can include other @file arguments, so we must + " recurse. + let l:out_lines += ale#c#ExpandAtArgs(a:path_prefix, l:file_lines) + else + " This is not an @file argument, so don't touch it. + let l:out_lines += [l:option] + endif + endfor + + return l:out_lines +endfunction + +" Quote C/C++ a compiler argument, if needed. +" +" Quoting arguments might cause issues with some systems/compilers, so we only +" quote them if we need to. +function! ale#c#QuoteArg(arg) abort + if a:arg !~# '\v[#$&*()\\|[\]{};''"<>/?! ^%]' + return a:arg + endif + + return ale#Escape(a:arg) +endfunction + +function! ale#c#ParseCFlags(path_prefix, should_quote, raw_arguments) abort + " Expand @file arguments now before parsing + let l:arguments = ale#c#ExpandAtArgs(a:path_prefix, a:raw_arguments) + " A list of [already_quoted, argument] + let l:items = [] let l:option_index = 0 - while l:option_index < len(l:split_lines) - let l:option = l:split_lines[l:option_index] + while l:option_index < len(l:arguments) + let l:option = l:arguments[l:option_index] let l:option_index = l:option_index + 1 " Include options, that may need relative path fix @@ -83,56 +150,67 @@ function! ale#c#ParseCFlags(path_prefix, cflag_line) abort \ || stridx(l:option, '-iquote') == 0 \ || stridx(l:option, '-isystem') == 0 \ || stridx(l:option, '-idirafter') == 0 + \ || stridx(l:option, '-iframework') == 0 + \ || stridx(l:option, '-include') == 0 if stridx(l:option, '-I') == 0 && l:option isnot# '-I' let l:arg = join(split(l:option, '\zs')[2:], '') let l:option = '-I' else - let l:arg = l:split_lines[l:option_index] + let l:arg = l:arguments[l:option_index] let l:option_index = l:option_index + 1 endif " Fix relative paths if needed - if stridx(l:arg, s:sep) != 0 && stridx(l:arg, '/') != 0 + if !ale#path#IsAbsolute(l:arg) let l:rel_path = substitute(l:arg, '"', '', 'g') let l:rel_path = substitute(l:rel_path, '''', '', 'g') - let l:arg = ale#Escape(a:path_prefix . s:sep . l:rel_path) + let l:arg = ale#path#GetAbsPath(a:path_prefix, l:rel_path) endif - call add(l:cflags_list, l:option) - call add(l:cflags_list, l:arg) + call add(l:items, [1, l:option]) + call add(l:items, [1, ale#Escape(l:arg)]) " Options with arg that can be grouped with the option or separate elseif stridx(l:option, '-D') == 0 || stridx(l:option, '-B') == 0 - call add(l:cflags_list, l:option) - if l:option is# '-D' || l:option is# '-B' - call add(l:cflags_list, l:split_lines[l:option_index]) + call add(l:items, [1, l:option]) + call add(l:items, [0, l:arguments[l:option_index]]) let l:option_index = l:option_index + 1 + else + call add(l:items, [0, l:option]) endif " Options that have an argument (always separate) elseif l:option is# '-iprefix' || stridx(l:option, '-iwithprefix') == 0 \ || l:option is# '-isysroot' || l:option is# '-imultilib' - call add(l:cflags_list, l:option) - call add(l:cflags_list, l:split_lines[l:option_index]) + call add(l:items, [0, l:option]) + call add(l:items, [0, l:arguments[l:option_index]]) let l:option_index = l:option_index + 1 " Options without argument elseif (stridx(l:option, '-W') == 0 && stridx(l:option, '-Wa,') != 0 && stridx(l:option, '-Wl,') != 0 && stridx(l:option, '-Wp,') != 0) \ || l:option is# '-w' || stridx(l:option, '-pedantic') == 0 \ || l:option is# '-ansi' || stridx(l:option, '-std=') == 0 - \ || (stridx(l:option, '-f') == 0 && stridx(l:option, '-fdump') != 0 && stridx(l:option, '-fdiagnostics') != 0 && stridx(l:option, '-fno-show-column') != 0) + \ || stridx(l:option, '-f') == 0 && l:option !~# '\v^-f(dump|diagnostics|no-show-column|stack-usage)' \ || stridx(l:option, '-O') == 0 \ || l:option is# '-C' || l:option is# '-CC' || l:option is# '-trigraphs' \ || stridx(l:option, '-nostdinc') == 0 || stridx(l:option, '-iplugindir=') == 0 \ || stridx(l:option, '--sysroot=') == 0 || l:option is# '--no-sysroot-suffix' \ || stridx(l:option, '-m') == 0 - call add(l:cflags_list, l:option) + call add(l:items, [0, l:option]) endif endwhile - return join(l:cflags_list, ' ') + if a:should_quote + " Quote C arguments that haven't already been quoted above. + " If and only if we've been asked to quote them. + call map(l:items, 'v:val[0] ? v:val[1] : ale#c#QuoteArg(v:val[1])') + else + call map(l:items, 'v:val[1]') + endif + + return join(l:items, ' ') endfunction function! ale#c#ParseCFlagsFromMakeOutput(buffer, make_output) abort - if !g:ale_c_parse_makefile + if !s:CanParseMakefile(a:buffer) return v:null endif @@ -150,7 +228,7 @@ function! ale#c#ParseCFlagsFromMakeOutput(buffer, make_output) abort let l:makefile_path = ale#path#FindNearestFile(a:buffer, 'Makefile') let l:makefile_dir = fnamemodify(l:makefile_path, ':p:h') - return ale#c#ParseCFlags(l:makefile_dir, l:cflag_line) + return ale#c#ParseCFlags(l:makefile_dir, 0, ale#c#ShellSplit(l:cflag_line)) endfunction " Given a buffer number, find the project directory containing @@ -218,6 +296,10 @@ if !exists('s:compile_commands_cache') let s:compile_commands_cache = {} endif +function! ale#c#ResetCompileCommandsCache() abort + let s:compile_commands_cache = {} +endfunction + function! s:GetLookupFromCompileCommandsFile(compile_commands_file) abort let l:empty = [{}, {}] @@ -248,9 +330,20 @@ function! s:GetLookupFromCompileCommandsFile(compile_commands_file) abort let l:dir_lookup = {} for l:entry in (type(l:raw_data) is v:t_list ? l:raw_data : []) + let l:filename = ale#path#GetAbsPath(l:entry.directory, l:entry.file) + + " Store a key for lookups by the absolute path to the filename. + let l:file_lookup[l:filename] = get(l:file_lookup, l:filename, []) + [l:entry] + + " Store a key for fuzzy lookups by the absolute path to the directory. + let l:dirname = fnamemodify(l:filename, ':h') + let l:dir_lookup[l:dirname] = get(l:dir_lookup, l:dirname, []) + [l:entry] + + " Store a key for fuzzy lookups by just the basename of the file. let l:basename = tolower(fnamemodify(l:entry.file, ':t')) let l:file_lookup[l:basename] = get(l:file_lookup, l:basename, []) + [l:entry] + " Store a key for fuzzy lookups by just the basename of the directory. let l:dirbasename = tolower(fnamemodify(l:entry.directory, ':p:h:t')) let l:dir_lookup[l:dirbasename] = get(l:dir_lookup, l:dirbasename, []) + [l:entry] endfor @@ -265,28 +358,80 @@ function! s:GetLookupFromCompileCommandsFile(compile_commands_file) abort return l:empty endfunction -function! ale#c#GetCompileCommand(json_item) abort - if has_key(a:json_item, 'command') - return a:json_item.command - elseif has_key(a:json_item, 'arguments') - return join(a:json_item.arguments, ' ') +" Get [should_quote, arguments] from either 'command' or 'arguments' +" 'arguments' should be quoted later, the split 'command' strings should not. +function! s:GetArguments(json_item) abort + if has_key(a:json_item, 'arguments') + return [1, a:json_item.arguments] + elseif has_key(a:json_item, 'command') + return [0, ale#c#ShellSplit(a:json_item.command)] endif - return '' + return [0, []] endfunction function! ale#c#ParseCompileCommandsFlags(buffer, file_lookup, dir_lookup) abort + let l:buffer_filename = ale#path#Simplify(expand('#' . a:buffer . ':p')) + let l:basename = tolower(fnamemodify(l:buffer_filename, ':t')) + " Look for any file in the same directory if we can't find an exact match. + let l:dir = fnamemodify(l:buffer_filename, ':h') + " Search for an exact file match first. - let l:basename = tolower(expand('#' . a:buffer . ':t')) - let l:file_list = get(a:file_lookup, l:basename, []) + let l:file_list = get(a:file_lookup, l:buffer_filename, []) + + " We may have to look for /foo/bar instead of C:\foo\bar + if empty(l:file_list) && has('win32') + let l:file_list = get( + \ a:file_lookup, + \ ale#path#RemoveDriveLetter(l:buffer_filename), + \ [] + \) + endif + + " Try the absolute path to the directory second. + let l:dir_list = get(a:dir_lookup, l:dir, []) + + if empty(l:dir_list) && has('win32') + let l:dir_list = get( + \ a:dir_lookup, + \ ale#path#RemoveDriveLetter(l:dir), + \ [] + \) + endif + + if empty(l:file_list) && empty(l:dir_list) + " If we can't find matches with the path to the file, try a + " case-insensitive match for any similarly-named file. + let l:file_list = get(a:file_lookup, l:basename, []) + + " If we can't find matches with the path to the directory, try a + " case-insensitive match for anything in similarly-named directory. + let l:dir_list = get(a:dir_lookup, tolower(fnamemodify(l:dir, ':t')), []) + endif + " A source file matching the header filename. let l:source_file = '' if empty(l:file_list) && l:basename =~? '\.h$\|\.hpp$' for l:suffix in ['.c', '.cpp'] - let l:key = fnamemodify(l:basename, ':r') . l:suffix + " Try to find a source file by an absolute path first. + let l:key = fnamemodify(l:buffer_filename, ':r') . l:suffix let l:file_list = get(a:file_lookup, l:key, []) + if empty(l:file_list) && has('win32') + let l:file_list = get( + \ a:file_lookup, + \ ale#path#RemoveDriveLetter(l:key), + \ [] + \) + endif + + if empty(l:file_list) + " Look fuzzy matches on the basename second. + let l:key = fnamemodify(l:basename, ':r') . l:suffix + let l:file_list = get(a:file_lookup, l:key, []) + endif + if !empty(l:file_list) let l:source_file = l:key break @@ -295,28 +440,31 @@ function! ale#c#ParseCompileCommandsFlags(buffer, file_lookup, dir_lookup) abort endif for l:item in l:file_list + let l:filename = ale#path#GetAbsPath(l:item.directory, l:item.file) + " Load the flags for this file, or for a source file matching the " header file. if ( - \ bufnr(l:item.file) is a:buffer + \ bufnr(l:filename) is a:buffer \ || ( \ !empty(l:source_file) - \ && l:item.file[-len(l:source_file):] is? l:source_file + \ && l:filename[-len(l:source_file):] is? l:source_file \ ) \) - return ale#c#ParseCFlags(l:item.directory, ale#c#GetCompileCommand(l:item)) + let [l:should_quote, l:args] = s:GetArguments(l:item) + + return ale#c#ParseCFlags(l:item.directory, l:should_quote, l:args) endif endfor - " Look for any file in the same directory if we can't find an exact match. - let l:dir = ale#path#Simplify(expand('#' . a:buffer . ':p:h')) - - let l:dirbasename = tolower(expand('#' . a:buffer . ':p:h:t')) - let l:dir_list = get(a:dir_lookup, l:dirbasename, []) - for l:item in l:dir_list - if ale#path#Simplify(fnamemodify(l:item.file, ':h')) is? l:dir - return ale#c#ParseCFlags(l:item.directory, ale#c#GetCompileCommand(l:item)) + let l:filename = ale#path#GetAbsPath(l:item.directory, l:item.file) + + if ale#path#RemoveDriveLetter(fnamemodify(l:filename, ':h')) + \ is? ale#path#RemoveDriveLetter(l:dir) + let [l:should_quote, l:args] = s:GetArguments(l:item) + + return ale#c#ParseCFlags(l:item.directory, l:should_quote, l:args) endif endfor @@ -334,10 +482,6 @@ endfunction function! ale#c#GetCFlags(buffer, output) abort let l:cflags = v:null - if ale#Var(a:buffer, 'c_parse_makefile') && !empty(a:output) - let l:cflags = ale#c#ParseCFlagsFromMakeOutput(a:buffer, a:output) - endif - if ale#Var(a:buffer, 'c_parse_compile_commands') let [l:root, l:json_file] = ale#c#FindCompileCommands(a:buffer) @@ -346,6 +490,10 @@ function! ale#c#GetCFlags(buffer, output) abort endif endif + if s:CanParseMakefile(a:buffer) && !empty(a:output) && !empty(l:cflags) + let l:cflags = ale#c#ParseCFlagsFromMakeOutput(a:buffer, a:output) + endif + if l:cflags is v:null let l:cflags = ale#c#IncludeOptions(ale#c#FindLocalHeaderPaths(a:buffer)) endif @@ -354,11 +502,14 @@ function! ale#c#GetCFlags(buffer, output) abort endfunction function! ale#c#GetMakeCommand(buffer) abort - if ale#Var(a:buffer, 'c_parse_makefile') - let l:makefile_path = ale#path#FindNearestFile(a:buffer, 'Makefile') + if s:CanParseMakefile(a:buffer) + let l:path = ale#path#FindNearestFile(a:buffer, 'Makefile') - if !empty(l:makefile_path) - return 'cd '. fnamemodify(l:makefile_path, ':p:h') . ' && make -n' + if !empty(l:path) + let l:always_make = ale#Var(a:buffer, 'c_always_make') + + return ale#path#CdString(fnamemodify(l:path, ':h')) + \ . 'make -n' . (l:always_make ? ' --always-make' : '') endif endif @@ -427,8 +578,3 @@ function! ale#c#IncludeOptions(include_paths) abort return join(l:option_list) endfunction - -let g:ale_c_build_dir_names = get(g:, 'ale_c_build_dir_names', [ -\ 'build', -\ 'bin', -\]) diff --git a/sources_non_forked/ale/autoload/ale/code_action.vim b/sources_non_forked/ale/autoload/ale/code_action.vim index 0af1bb70..69d40933 100644 --- a/sources_non_forked/ale/autoload/ale/code_action.vim +++ b/sources_non_forked/ale/autoload/ale/code_action.vim @@ -1,27 +1,69 @@ " Author: Jerko Steiner " Description: Code action support for LSP / tsserver -function! ale#code_action#HandleCodeAction(code_action) abort +function! ale#code_action#ReloadBuffer() abort + let l:buffer = bufnr('') + + execute 'augroup ALECodeActionReloadGroup' . l:buffer + autocmd! + augroup END + + silent! execute 'augroup! ALECodeActionReloadGroup' . l:buffer + + call ale#util#Execute(':e!') +endfunction + +function! ale#code_action#HandleCodeAction(code_action, options) abort let l:current_buffer = bufnr('') let l:changes = a:code_action.changes - - for l:file_code_edit in l:changes - let l:buf = bufnr(l:file_code_edit.fileName) - - if l:buf != -1 && l:buf != l:current_buffer && getbufvar(l:buf, '&mod') - call ale#util#Execute('echom ''Aborting action, file is unsaved''') - - return - endif - endfor + let l:should_save = get(a:options, 'should_save') for l:file_code_edit in l:changes call ale#code_action#ApplyChanges( - \ l:file_code_edit.fileName, l:file_code_edit.textChanges) + \ l:file_code_edit.fileName, + \ l:file_code_edit.textChanges, + \ l:should_save, + \) endfor endfunction -function! ale#code_action#ApplyChanges(filename, changes) abort +function! s:ChangeCmp(left, right) abort + if a:left.start.line < a:right.start.line + return -1 + endif + + if a:left.start.line > a:right.start.line + return 1 + endif + + if a:left.start.offset < a:right.start.offset + return -1 + endif + + if a:left.start.offset > a:right.start.offset + return 1 + endif + + if a:left.end.line < a:right.end.line + return -1 + endif + + if a:left.end.line > a:right.end.line + return 1 + endif + + if a:left.end.offset < a:right.end.offset + return -1 + endif + + if a:left.end.offset > a:right.end.offset + return 1 + endif + + return 0 +endfunction + +function! ale#code_action#ApplyChanges(filename, changes, should_save) abort let l:current_buffer = bufnr('') " The buffer is used to determine the fileformat, if available. let l:buffer = bufnr(a:filename) @@ -39,28 +81,14 @@ function! ale#code_action#ApplyChanges(filename, changes) abort let l:pos = [1, 1] endif - " We have to keep track of how many lines we have added, and offset - " changes accordingly. - let l:line_offset = 0 - let l:column_offset = 0 - let l:last_end_line = 0 - - for l:code_edit in a:changes - if l:code_edit.start.line isnot l:last_end_line - let l:column_offset = 0 - endif - - let l:line = l:code_edit.start.line + l:line_offset - let l:column = l:code_edit.start.offset + l:column_offset - let l:end_line = l:code_edit.end.line + l:line_offset - let l:end_column = l:code_edit.end.offset + l:column_offset + " Changes have to be sorted so we apply them from bottom-to-top + for l:code_edit in reverse(sort(copy(a:changes), function('s:ChangeCmp'))) + let l:line = l:code_edit.start.line + let l:column = l:code_edit.start.offset + let l:end_line = l:code_edit.end.line + let l:end_column = l:code_edit.end.offset let l:text = l:code_edit.newText - let l:cur_line = l:pos[0] - let l:cur_column = l:pos[1] - - let l:last_end_line = l:end_line - " Adjust the ends according to previous edits. if l:end_line > len(l:lines) let l:end_line_len = 0 @@ -78,6 +106,12 @@ function! ale#code_action#ApplyChanges(filename, changes) abort let l:start = l:lines[: l:line - 2] endif + " Special case when text must be added after new line + if l:column > len(l:lines[l:line - 1]) + call extend(l:start, [l:lines[l:line - 1]]) + let l:column = 1 + endif + if l:column is 1 " We need to handle column 1 specially, because we can't slice an " empty string ending on index 0. @@ -87,13 +121,17 @@ function! ale#code_action#ApplyChanges(filename, changes) abort endif call extend(l:middle, l:insertions[1:]) - let l:middle[-1] .= l:lines[l:end_line - 1][l:end_column - 1 :] + + if l:end_line <= len(l:lines) + " Only extend the last line if end_line is within the range of + " lines. + let l:middle[-1] .= l:lines[l:end_line - 1][l:end_column - 1 :] + endif let l:lines_before_change = len(l:lines) let l:lines = l:start + l:middle + l:lines[l:end_line :] let l:current_line_offset = len(l:lines) - l:lines_before_change - let l:line_offset += l:current_line_offset let l:column_offset = len(l:middle[-1]) - l:end_line_len let l:pos = s:UpdateCursor(l:pos, @@ -106,12 +144,33 @@ function! ale#code_action#ApplyChanges(filename, changes) abort call remove(l:lines, -1) endif - call ale#util#Writefile(l:buffer, l:lines, a:filename) + if a:should_save + call ale#util#Writefile(l:buffer, l:lines, a:filename) + else + call ale#util#SetBufferContents(l:buffer, l:lines) + endif if l:is_current_buffer - call ale#util#Execute(':e!') + if a:should_save + call ale#util#Execute(':e!') + endif + call setpos('.', [0, l:pos[0], l:pos[1], 0]) endif + + if a:should_save && l:buffer > 0 && !l:is_current_buffer + " Set up a one-time use event that will delete itself to reload the + " buffer next time it's entered to view the changes made to it. + execute 'augroup ALECodeActionReloadGroup' . l:buffer + autocmd! + + execute printf( + \ 'autocmd BufEnter ' + \ . ' call ale#code_action#ReloadBuffer()', + \ l:buffer + \) + augroup END + endif endfunction function! s:UpdateCursor(cursor, start, end, offset) abort @@ -161,3 +220,163 @@ function! s:UpdateCursor(cursor, start, end, offset) abort return [l:cur_line, l:cur_column] endfunction + +function! ale#code_action#GetChanges(workspace_edit) abort + let l:changes = {} + + if has_key(a:workspace_edit, 'changes') && !empty(a:workspace_edit.changes) + return a:workspace_edit.changes + elseif has_key(a:workspace_edit, 'documentChanges') + let l:document_changes = [] + + if type(a:workspace_edit.documentChanges) is v:t_dict + \ && has_key(a:workspace_edit.documentChanges, 'edits') + call add(l:document_changes, a:workspace_edit.documentChanges) + elseif type(a:workspace_edit.documentChanges) is v:t_list + let l:document_changes = a:workspace_edit.documentChanges + endif + + for l:text_document_edit in l:document_changes + let l:filename = l:text_document_edit.textDocument.uri + let l:edits = l:text_document_edit.edits + let l:changes[l:filename] = l:edits + endfor + endif + + return l:changes +endfunction + +function! ale#code_action#BuildChangesList(changes_map) abort + let l:changes = [] + + for l:file_name in keys(a:changes_map) + let l:text_edits = a:changes_map[l:file_name] + let l:text_changes = [] + + for l:edit in l:text_edits + let l:range = l:edit.range + let l:new_text = l:edit.newText + + call add(l:text_changes, { + \ 'start': { + \ 'line': l:range.start.line + 1, + \ 'offset': l:range.start.character + 1, + \ }, + \ 'end': { + \ 'line': l:range.end.line + 1, + \ 'offset': l:range.end.character + 1, + \ }, + \ 'newText': l:new_text, + \}) + endfor + + call add(l:changes, { + \ 'fileName': ale#path#FromURI(l:file_name), + \ 'textChanges': l:text_changes, + \}) + endfor + + return l:changes +endfunction + +function! s:EscapeMenuName(text) abort + return substitute(a:text, '\\\| \|\.\|&', '\\\0', 'g') +endfunction + +function! s:UpdateMenu(data, menu_items) abort + silent! aunmenu PopUp.Refactor\.\.\. + + if empty(a:data) + return + endif + + for [l:type, l:item] in a:menu_items + let l:name = l:type is# 'tsserver' ? l:item.name : l:item.title + let l:func_name = l:type is# 'tsserver' + \ ? 'ale#codefix#ApplyTSServerCodeAction' + \ : 'ale#codefix#ApplyLSPCodeAction' + + execute printf( + \ 'anoremenu PopUp.&Refactor\.\.\..%s' + \ . ' :call %s(%s, %s)', + \ s:EscapeMenuName(l:name), + \ l:func_name, + \ string(a:data), + \ string(l:item), + \) + endfor + + if empty(a:menu_items) + silent! anoremenu PopUp.Refactor\.\.\..(None) :silent + endif +endfunction + +function! s:GetCodeActions(linter, options) abort + let l:buffer = bufnr('') + let [l:line, l:column] = getpos('.')[1:2] + let l:column = min([l:column, len(getline(l:line))]) + + let l:location = { + \ 'buffer': l:buffer, + \ 'line': l:line, + \ 'column': l:column, + \ 'end_line': l:line, + \ 'end_column': l:column, + \} + let l:Callback = function('s:OnReady', [l:location, a:options]) + call ale#lsp_linter#StartLSP(l:buffer, a:linter, l:Callback) +endfunction + +function! ale#code_action#GetCodeActions(options) abort + silent! aunmenu PopUp.Rename + silent! aunmenu PopUp.Refactor\.\.\. + + " Only display the menu items if there's an LSP server. + let l:has_lsp = 0 + + for l:linter in ale#linter#Get(&filetype) + if !empty(l:linter.lsp) + let l:has_lsp = 1 + + break + endif + endfor + + if l:has_lsp + if !empty(expand('')) + silent! anoremenu PopUp.Rename :ALERename + endif + + silent! anoremenu PopUp.Refactor\.\.\..(None) :silent + + call ale#codefix#Execute( + \ mode() is# 'v' || mode() is# "\", + \ function('s:UpdateMenu') + \) + endif +endfunction + +function! s:Setup(enabled) abort + augroup ALECodeActionsGroup + autocmd! + + if a:enabled + autocmd MenuPopup * :call ale#code_action#GetCodeActions({}) + endif + augroup END + + if !a:enabled + silent! augroup! ALECodeActionsGroup + + silent! aunmenu PopUp.Rename + silent! aunmenu PopUp.Refactor\.\.\. + endif +endfunction + +function! ale#code_action#EnablePopUpMenu() abort + call s:Setup(1) +endfunction + +function! ale#code_action#DisablePopUpMenu() abort + call s:Setup(0) +endfunction diff --git a/sources_non_forked/ale/autoload/ale/codefix.vim b/sources_non_forked/ale/autoload/ale/codefix.vim new file mode 100644 index 00000000..69bf36fa --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/codefix.vim @@ -0,0 +1,484 @@ +" Author: Dalius Dobravolskas +" Description: Code Fix support for tsserver and LSP servers + +let s:codefix_map = {} + +" Used to get the codefix map in tests. +function! ale#codefix#GetMap() abort + return deepcopy(s:codefix_map) +endfunction + +" Used to set the codefix map in tests. +function! ale#codefix#SetMap(map) abort + let s:codefix_map = a:map +endfunction + +function! ale#codefix#ClearLSPData() abort + let s:codefix_map = {} +endfunction + +function! s:message(message) abort + call ale#util#Execute('echom ' . string(a:message)) +endfunction + +function! ale#codefix#ApplyTSServerCodeAction(data, item) abort + if has_key(a:item, 'changes') + let l:changes = a:item.changes + + call ale#code_action#HandleCodeAction( + \ { + \ 'description': 'codefix', + \ 'changes': l:changes, + \ }, + \ {}, + \) + else + let l:message = ale#lsp#tsserver_message#GetEditsForRefactor( + \ a:data.buffer, + \ a:data.line, + \ a:data.column, + \ a:data.end_line, + \ a:data.end_column, + \ a:item.id[0], + \ a:item.id[1], + \) + + let l:request_id = ale#lsp#Send(a:data.connection_id, l:message) + + let s:codefix_map[l:request_id] = a:data + endif +endfunction + +function! ale#codefix#HandleTSServerResponse(conn_id, response) abort + if !has_key(a:response, 'request_seq') + \ || !has_key(s:codefix_map, a:response.request_seq) + return + endif + + let l:data = remove(s:codefix_map, a:response.request_seq) + let l:MenuCallback = get(l:data, 'menu_callback', v:null) + + if get(a:response, 'command', '') is# 'getCodeFixes' + if get(a:response, 'success', v:false) is v:false + \&& l:MenuCallback is v:null + let l:message = get(a:response, 'message', 'unknown') + call s:message('Error while getting code fixes. Reason: ' . l:message) + + return + endif + + let l:result = get(a:response, 'body', []) + call filter(l:result, 'has_key(v:val, ''changes'')') + + if l:MenuCallback isnot v:null + call l:MenuCallback( + \ l:data, + \ map(copy(l:result), '[''tsserver'', v:val]') + \) + + return + endif + + if len(l:result) == 0 + call s:message('No code fixes available.') + + return + endif + + let l:code_fix_to_apply = 0 + + if len(l:result) == 1 + let l:code_fix_to_apply = 1 + else + let l:codefix_no = 1 + let l:codefixstring = "Code Fixes:\n" + + for l:codefix in l:result + let l:codefixstring .= l:codefix_no . ') ' + \ . l:codefix.description . "\n" + let l:codefix_no += 1 + endfor + + let l:codefixstring .= 'Type number and (empty cancels): ' + + let l:code_fix_to_apply = ale#util#Input(l:codefixstring, '') + let l:code_fix_to_apply = str2nr(l:code_fix_to_apply) + + if l:code_fix_to_apply == 0 + return + endif + endif + + call ale#codefix#ApplyTSServerCodeAction( + \ l:data, + \ l:result[l:code_fix_to_apply - 1], + \) + elseif get(a:response, 'command', '') is# 'getApplicableRefactors' + if get(a:response, 'success', v:false) is v:false + \&& l:MenuCallback is v:null + let l:message = get(a:response, 'message', 'unknown') + call s:message('Error while getting applicable refactors. Reason: ' . l:message) + + return + endif + + let l:result = get(a:response, 'body', []) + + if len(l:result) == 0 + call s:message('No applicable refactors available.') + + return + endif + + let l:refactors = [] + + for l:item in l:result + for l:action in l:item.actions + call add(l:refactors, { + \ 'name': l:action.description, + \ 'id': [l:item.name, l:action.name], + \}) + endfor + endfor + + if l:MenuCallback isnot v:null + call l:MenuCallback( + \ l:data, + \ map(copy(l:refactors), '[''tsserver'', v:val]') + \) + + return + endif + + let l:refactor_no = 1 + let l:refactorstring = "Applicable refactors:\n" + + for l:refactor in l:refactors + let l:refactorstring .= l:refactor_no . ') ' + \ . l:refactor.name . "\n" + let l:refactor_no += 1 + endfor + + let l:refactorstring .= 'Type number and (empty cancels): ' + + let l:refactor_to_apply = ale#util#Input(l:refactorstring, '') + let l:refactor_to_apply = str2nr(l:refactor_to_apply) + + if l:refactor_to_apply == 0 + return + endif + + let l:id = l:refactors[l:refactor_to_apply - 1].id + + call ale#codefix#ApplyTSServerCodeAction( + \ l:data, + \ l:refactors[l:refactor_to_apply - 1], + \) + elseif get(a:response, 'command', '') is# 'getEditsForRefactor' + if get(a:response, 'success', v:false) is v:false + let l:message = get(a:response, 'message', 'unknown') + call s:message('Error while getting edits for refactor. Reason: ' . l:message) + + return + endif + + call ale#code_action#HandleCodeAction( + \ { + \ 'description': 'editsForRefactor', + \ 'changes': a:response.body.edits, + \ }, + \ {}, + \) + endif +endfunction + +function! ale#codefix#ApplyLSPCodeAction(data, item) abort + if has_key(a:item, 'command') + \&& type(a:item.command) == v:t_dict + let l:command = a:item.command + let l:message = ale#lsp#message#ExecuteCommand( + \ l:command.command, + \ l:command.arguments, + \) + + let l:request_id = ale#lsp#Send(a:data.connection_id, l:message) + elseif has_key(a:item, 'edit') || has_key(a:item, 'arguments') + if has_key(a:item, 'edit') + let l:topass = a:item.edit + else + let l:topass = a:item.arguments[0] + endif + + let l:changes_map = ale#code_action#GetChanges(l:topass) + + if empty(l:changes_map) + return + endif + + let l:changes = ale#code_action#BuildChangesList(l:changes_map) + + call ale#code_action#HandleCodeAction( + \ { + \ 'description': 'codeaction', + \ 'changes': l:changes, + \ }, + \ {}, + \) + endif +endfunction + +function! ale#codefix#HandleLSPResponse(conn_id, response) abort + if has_key(a:response, 'method') + \ && a:response.method is# 'workspace/applyEdit' + \ && has_key(a:response, 'params') + let l:params = a:response.params + + let l:changes_map = ale#code_action#GetChanges(l:params.edit) + + if empty(l:changes_map) + return + endif + + let l:changes = ale#code_action#BuildChangesList(l:changes_map) + + call ale#code_action#HandleCodeAction( + \ { + \ 'description': 'applyEdit', + \ 'changes': l:changes, + \ }, + \ {} + \) + elseif has_key(a:response, 'id') + \&& has_key(s:codefix_map, a:response.id) + let l:data = remove(s:codefix_map, a:response.id) + let l:MenuCallback = get(l:data, 'menu_callback', v:null) + + let l:result = get(a:response, 'result') + + if type(l:result) != v:t_list + let l:result = [] + endif + + " Send the results to the menu callback, if set. + if l:MenuCallback isnot v:null + call l:MenuCallback(map(copy(l:result), '[''lsp'', v:val]')) + + return + endif + + if len(l:result) == 0 + call s:message('No code actions received from server') + + return + endif + + let l:codeaction_no = 1 + let l:codeactionstring = "Code Fixes:\n" + + for l:codeaction in l:result + let l:codeactionstring .= l:codeaction_no . ') ' + \ . l:codeaction.title . "\n" + let l:codeaction_no += 1 + endfor + + let l:codeactionstring .= 'Type number and (empty cancels): ' + + let l:codeaction_to_apply = ale#util#Input(l:codeactionstring, '') + let l:codeaction_to_apply = str2nr(l:codeaction_to_apply) + + if l:codeaction_to_apply == 0 + return + endif + + let l:item = l:result[l:codeaction_to_apply - 1] + + call ale#codefix#ApplyLSPCodeAction(l:data, l:item) + endif +endfunction + +function! s:FindError(buffer, line, column, end_line, end_column) abort + let l:nearest_error = v:null + + if a:line == a:end_line + \&& a:column == a:end_column + \&& has_key(g:ale_buffer_info, a:buffer) + let l:nearest_error_diff = -1 + + for l:error in get(g:ale_buffer_info[a:buffer], 'loclist', []) + if has_key(l:error, 'code') && l:error.lnum == a:line + let l:diff = abs(l:error.col - a:column) + + if l:nearest_error_diff == -1 || l:diff < l:nearest_error_diff + let l:nearest_error_diff = l:diff + let l:nearest_error = l:error + endif + endif + endfor + endif + + return l:nearest_error +endfunction + +function! s:OnReady( +\ line, +\ column, +\ end_line, +\ end_column, +\ MenuCallback, +\ linter, +\ lsp_details, +\) abort + let l:id = a:lsp_details.connection_id + + if !ale#lsp#HasCapability(l:id, 'code_actions') + return + endif + + let l:buffer = a:lsp_details.buffer + + if a:linter.lsp is# 'tsserver' + let l:nearest_error = + \ s:FindError(l:buffer, a:line, a:column, a:end_line, a:end_column) + + if l:nearest_error isnot v:null + let l:message = ale#lsp#tsserver_message#GetCodeFixes( + \ l:buffer, + \ a:line, + \ a:column, + \ a:line, + \ a:column, + \ [l:nearest_error.code], + \) + else + let l:message = ale#lsp#tsserver_message#GetApplicableRefactors( + \ l:buffer, + \ a:line, + \ a:column, + \ a:end_line, + \ a:end_column, + \) + endif + else + " Send a message saying the buffer has changed first, otherwise + " completions won't know what text is nearby. + call ale#lsp#NotifyForChanges(l:id, l:buffer) + + let l:diagnostics = [] + let l:nearest_error = + \ s:FindError(l:buffer, a:line, a:column, a:end_line, a:end_column) + + if l:nearest_error isnot v:null + let l:diagnostics = [ + \ { + \ 'code': l:nearest_error.code, + \ 'message': l:nearest_error.text, + \ 'range': { + \ 'start': { + \ 'line': l:nearest_error.lnum - 1, + \ 'character': l:nearest_error.col - 1, + \ }, + \ 'end': { + \ 'line': l:nearest_error.end_lnum - 1, + \ 'character': l:nearest_error.end_col, + \ }, + \ }, + \ }, + \] + endif + + let l:message = ale#lsp#message#CodeAction( + \ l:buffer, + \ a:line, + \ a:column, + \ a:end_line, + \ a:end_column, + \ l:diagnostics, + \) + endif + + let l:Callback = a:linter.lsp is# 'tsserver' + \ ? function('ale#codefix#HandleTSServerResponse') + \ : function('ale#codefix#HandleLSPResponse') + + call ale#lsp#RegisterCallback(l:id, l:Callback) + + let l:request_id = ale#lsp#Send(l:id, l:message) + + let s:codefix_map[l:request_id] = { + \ 'connection_id': l:id, + \ 'buffer': l:buffer, + \ 'line': a:line, + \ 'column': a:column, + \ 'end_line': a:end_line, + \ 'end_column': a:end_column, + \ 'menu_callback': a:MenuCallback, + \} +endfunction + +function! s:ExecuteGetCodeFix(linter, range, MenuCallback) abort + let l:buffer = bufnr('') + + if a:range == 0 + let [l:line, l:column] = getpos('.')[1:2] + let l:end_line = l:line + let l:end_column = l:column + + " Expand the range to cover the current word, if there is one. + let l:cword = expand('') + + if !empty(l:cword) + let l:search_pos = searchpos('\V' . l:cword, 'bn', l:line) + + if l:search_pos != [0, 0] + let l:column = l:search_pos[1] + let l:end_column = l:column + len(l:cword) - 1 + endif + endif + elseif mode() is# 'v' || mode() is# "\" + " You need to get the start and end in a different way when you're in + " visual mode. + let [l:line, l:column] = getpos('v')[1:2] + let [l:end_line, l:end_column] = getpos('.')[1:2] + else + let [l:line, l:column] = getpos("'<")[1:2] + let [l:end_line, l:end_column] = getpos("'>")[1:2] + endif + + let l:column = min([l:column, len(getline(l:line))]) + let l:end_column = min([l:end_column, len(getline(l:end_line))]) + + let l:Callback = function( + \ 's:OnReady', [l:line, l:column, l:end_line, l:end_column, a:MenuCallback] + \) + + call ale#lsp_linter#StartLSP(l:buffer, a:linter, l:Callback) +endfunction + +function! ale#codefix#Execute(range, ...) abort + if a:0 > 1 + throw 'Too many arguments' + endif + + let l:MenuCallback = get(a:000, 0, v:null) + let l:lsp_linters = [] + + for l:linter in ale#linter#Get(&filetype) + if !empty(l:linter.lsp) + call add(l:lsp_linters, l:linter) + endif + endfor + + if empty(l:lsp_linters) + if l:MenuCallback is v:null + call s:message('No active LSPs') + else + call l:MenuCallback({}, []) + endif + + return + endif + + for l:lsp_linter in l:lsp_linters + call s:ExecuteGetCodeFix(l:lsp_linter, a:range, l:MenuCallback) + endfor +endfunction diff --git a/sources_non_forked/ale/autoload/ale/command.vim b/sources_non_forked/ale/autoload/ale/command.vim index 1bbc4f4c..8f497169 100644 --- a/sources_non_forked/ale/autoload/ale/command.vim +++ b/sources_non_forked/ale/autoload/ale/command.vim @@ -133,11 +133,36 @@ function! ale#command#EscapeCommandPart(command_part) abort return substitute(a:command_part, '%', '%%', 'g') endfunction +" Format a filename, converting it with filename mappings, if non-empty, +" and escaping it for putting into a command string. +" +" The filename can be modified. +function! s:FormatFilename(filename, mappings, modifiers) abort + let l:filename = a:filename + + if !empty(a:mappings) + let l:filename = ale#filename_mapping#Map(l:filename, a:mappings) + endif + + if !empty(a:modifiers) + let l:filename = fnamemodify(l:filename, a:modifiers) + endif + + return ale#Escape(l:filename) +endfunction + " Given a command string, replace every... " %s -> with the current filename " %t -> with the name of an unused file in a temporary directory " %% -> with a literal % -function! ale#command#FormatCommand(buffer, executable, command, pipe_file_if_needed, input) abort +function! ale#command#FormatCommand( +\ buffer, +\ executable, +\ command, +\ pipe_file_if_needed, +\ input, +\ mappings, +\) abort let l:temporary_file = '' let l:command = a:command @@ -154,14 +179,24 @@ function! ale#command#FormatCommand(buffer, executable, command, pipe_file_if_ne " file. if l:command =~# '%s' let l:filename = fnamemodify(bufname(a:buffer), ':p') - let l:command = substitute(l:command, '%s', '\=ale#Escape(l:filename)', 'g') + let l:command = substitute( + \ l:command, + \ '\v\%s(%(:h|:t|:r|:e)*)', + \ '\=s:FormatFilename(l:filename, a:mappings, submatch(1))', + \ 'g' + \) endif if a:input isnot v:false && l:command =~# '%t' " Create a temporary filename, / " The file itself will not be created by this function. let l:temporary_file = s:TemporaryFilename(a:buffer) - let l:command = substitute(l:command, '%t', '\=ale#Escape(l:temporary_file)', 'g') + let l:command = substitute( + \ l:command, + \ '\v\%t(%(:h|:t|:r|:e)*)', + \ '\=s:FormatFilename(l:temporary_file, a:mappings, submatch(1))', + \ 'g' + \) endif " Finish formatting so %% becomes %. @@ -265,6 +300,7 @@ function! ale#command#Run(buffer, command, Callback, ...) abort \ a:command, \ get(l:options, 'read_buffer', 0), \ get(l:options, 'input', v:null), + \ get(l:options, 'filename_mappings', []), \) let l:command = ale#job#PrepareCommand(a:buffer, l:command) let l:job_options = { diff --git a/sources_non_forked/ale/autoload/ale/completion.vim b/sources_non_forked/ale/autoload/ale/completion.vim index 80684a30..39bfc094 100644 --- a/sources_non_forked/ale/autoload/ale/completion.vim +++ b/sources_non_forked/ale/autoload/ale/completion.vim @@ -5,7 +5,7 @@ scriptencoding utf-8 " The omnicompletion menu is shown through a special Plug mapping which is " only valid in Insert mode. This way, feedkeys() won't send these keys if you " quit Insert mode quickly enough. -inoremap (ale_show_completion_menu) +inoremap (ale_show_completion_menu) " If we hit the key sequence in normal mode, then we won't show the menu, so " we should restore the old settings right away. nnoremap (ale_show_completion_menu) :call ale#completion#RestoreCompletionOptions() @@ -16,7 +16,8 @@ onoremap (ale_show_completion_menu) let g:ale_completion_delay = get(g:, 'ale_completion_delay', 100) let g:ale_completion_excluded_words = get(g:, 'ale_completion_excluded_words', []) let g:ale_completion_max_suggestions = get(g:, 'ale_completion_max_suggestions', 50) -let g:ale_completion_tsserver_autoimport = get(g:, 'ale_completion_tsserver_autoimport', 0) +let g:ale_completion_autoimport = get(g:, 'ale_completion_autoimport', 0) +let g:ale_completion_tsserver_remove_warnings = get(g:, 'ale_completion_tsserver_remove_warnings', 0) let s:timer_id = -1 let s:last_done_pos = [] @@ -187,7 +188,13 @@ function! ale#completion#GetTriggerCharacter(filetype, prefix) abort return '' endfunction -function! ale#completion#Filter(buffer, filetype, suggestions, prefix) abort +function! ale#completion#Filter( +\ buffer, +\ filetype, +\ suggestions, +\ prefix, +\ exact_prefix_match, +\) abort let l:excluded_words = ale#Var(a:buffer, 'completion_excluded_words') if empty(a:prefix) @@ -214,10 +221,17 @@ function! ale#completion#Filter(buffer, filetype, suggestions, prefix) abort " Dictionaries is accepted here. let l:word = type(l:item) is v:t_string ? l:item : l:item.word - " Add suggestions if the suggestion starts with a - " case-insensitive match for the prefix. - if l:word[: len(a:prefix) - 1] is? a:prefix - call add(l:filtered_suggestions, l:item) + if a:exact_prefix_match + " Add suggestions if the word is an exact match. + if l:word is# a:prefix + call add(l:filtered_suggestions, l:item) + endif + else + " Add suggestions if the suggestion starts with a + " case-insensitive match for the prefix. + if l:word[: len(a:prefix) - 1] is? a:prefix + call add(l:filtered_suggestions, l:item) + endif endif endfor endif @@ -240,21 +254,17 @@ function! ale#completion#Filter(buffer, filetype, suggestions, prefix) abort return l:filtered_suggestions endfunction -function! s:ReplaceCompletionOptions() abort - let l:source = get(get(b:, 'ale_completion_info', {}), 'source', '') - - if l:source is# 'ale-automatic' || l:source is# 'ale-manual' - " Remember the old omnifunc value, if there is one. - " If we don't store an old one, we'll just never reset the option. - " This will stop some random exceptions from appearing. - if !exists('b:ale_old_omnifunc') && !empty(&l:omnifunc) - let b:ale_old_omnifunc = &l:omnifunc - endif - - let &l:omnifunc = 'ale#completion#AutomaticOmniFunc' +function! s:ReplaceCompletionOptions(source) abort + " Remember the old omnifunc value, if there is one. + " If we don't store an old one, we'll just never reset the option. + " This will stop some random exceptions from appearing. + if !exists('b:ale_old_omnifunc') && !empty(&l:omnifunc) + let b:ale_old_omnifunc = &l:omnifunc endif - if l:source is# 'ale-automatic' + let &l:omnifunc = 'ale#completion#AutomaticOmniFunc' + + if a:source is# 'ale-automatic' if !exists('b:ale_old_completeopt') let b:ale_old_completeopt = &l:completeopt endif @@ -317,41 +327,70 @@ function! ale#completion#AutomaticOmniFunc(findstart, base) abort else let l:result = ale#completion#GetCompletionResult() - call s:ReplaceCompletionOptions() + let l:source = get(get(b:, 'ale_completion_info', {}), 'source', '') + + if l:source is# 'ale-automatic' || l:source is# 'ale-manual' + call s:ReplaceCompletionOptions(l:source) + endif return l:result isnot v:null ? l:result : [] endif endfunction +function! s:OpenCompletionMenu(...) abort + if !&l:paste + call ale#util#FeedKeys("\(ale_show_completion_menu)") + endif +endfunction + function! ale#completion#Show(result) abort - if ale#util#Mode() isnot# 'i' + let l:source = get(get(b:, 'ale_completion_info', {}), 'source', '') + + if ale#util#Mode() isnot# 'i' && l:source isnot# 'ale-import' return endif - " Set the list in the buffer, temporarily replace omnifunc with our - " function, and then start omni-completion. + " Set the list in the buffer. let b:ale_completion_result = a:result " Don't try to open the completion menu if there's nothing to show. if empty(b:ale_completion_result) + if l:source is# 'ale-import' + " If we ran completion from :ALEImport, + " tell the user that nothing is going to happen. + call s:message('No possible imports found.') + endif + return endif " Replace completion options shortly before opening the menu. - call s:ReplaceCompletionOptions() - - let l:source = get(get(b:, 'ale_completion_info', {}), 'source', '') - if l:source is# 'ale-automatic' || l:source is# 'ale-manual' - call timer_start( - \ 0, - \ {-> ale#util#FeedKeys("\(ale_show_completion_menu)")} - \) + call s:ReplaceCompletionOptions(l:source) + + call timer_start(0, function('s:OpenCompletionMenu')) endif if l:source is# 'ale-callback' call b:CompleteCallback(b:ale_completion_result) endif + + if l:source is# 'ale-import' + call ale#completion#HandleUserData(b:ale_completion_result[0]) + + let l:text_changed = '' . g:ale_lint_on_text_changed + + " Check the buffer again right away, if linting is enabled. + if g:ale_enabled + \&& ( + \ l:text_changed is# '1' + \ || l:text_changed is# 'always' + \ || l:text_changed is# 'normal' + \ || l:text_changed is# 'insert' + \) + call ale#Queue(0, '') + endif + endif endfunction function! ale#completion#GetAllTriggers() abort @@ -382,14 +421,18 @@ endfunction function! s:CompletionStillValid(request_id) abort let [l:line, l:column] = getpos('.')[1:2] - return ale#util#Mode() is# 'i' - \&& has_key(b:, 'ale_completion_info') + return has_key(b:, 'ale_completion_info') + \&& ( + \ ale#util#Mode() is# 'i' + \ || b:ale_completion_info.source is# 'ale-import' + \) \&& b:ale_completion_info.request_id == a:request_id \&& b:ale_completion_info.line == l:line \&& ( \ b:ale_completion_info.column == l:column \ || b:ale_completion_info.source is# 'ale-omnifunc' \ || b:ale_completion_info.source is# 'ale-callback' + \ || b:ale_completion_info.source is# 'ale-import' \) endfunction @@ -397,10 +440,14 @@ function! ale#completion#ParseTSServerCompletions(response) abort let l:names = [] for l:suggestion in a:response.body - call add(l:names, { - \ 'word': l:suggestion.name, - \ 'source': get(l:suggestion, 'source', ''), - \}) + let l:kind = get(l:suggestion, 'kind', '') + + if g:ale_completion_tsserver_remove_warnings == 0 || l:kind isnot# 'warning' + call add(l:names, { + \ 'word': l:suggestion.name, + \ 'source': get(l:suggestion, 'source', ''), + \}) + endif endfor return l:names @@ -410,15 +457,26 @@ function! ale#completion#ParseTSServerCompletionEntryDetails(response) abort let l:buffer = bufnr('') let l:results = [] let l:names_with_details = [] + let l:info = get(b:, 'ale_completion_info', {}) for l:suggestion in a:response.body let l:displayParts = [] + let l:local_name = v:null for l:action in get(l:suggestion, 'codeActions', []) call add(l:displayParts, l:action.description . ' ') endfor for l:part in l:suggestion.displayParts + " Stop on stop on line breaks for the menu. + if get(l:part, 'kind') is# 'lineBreak' + break + endif + + if get(l:part, 'kind') is# 'localName' + let l:local_name = l:part.text + endif + call add(l:displayParts, l:part.text) endfor @@ -431,21 +489,35 @@ function! ale#completion#ParseTSServerCompletionEntryDetails(response) abort " See :help complete-items let l:result = { - \ 'word': l:suggestion.name, + \ 'word': ( + \ l:suggestion.name is# 'default' + \ && l:suggestion.kind is# 'alias' + \ && !empty(l:local_name) + \ ? l:local_name + \ : l:suggestion.name + \ ), \ 'kind': ale#completion#GetCompletionSymbols(l:suggestion.kind), \ 'icase': 1, \ 'menu': join(l:displayParts, ''), - \ 'dup': g:ale_completion_tsserver_autoimport, + \ 'dup': get(l:info, 'additional_edits_only', 0) + \ || g:ale_completion_autoimport, \ 'info': join(l:documentationParts, ''), \} + " This flag is used to tell if this completion came from ALE or not. + let l:user_data = {'_ale_completion_item': 1} if has_key(l:suggestion, 'codeActions') - let l:result.user_data = json_encode({ - \ 'codeActions': l:suggestion.codeActions, - \ }) + let l:user_data.code_actions = l:suggestion.codeActions endif - call add(l:results, l:result) + let l:result.user_data = json_encode(l:user_data) + + " Include this item if we'll accept any items, + " or if we only want items with additional edits, and this has them. + if !get(l:info, 'additional_edits_only', 0) + \|| has_key(l:user_data, 'code_actions') + call add(l:results, l:result) + endif endfor let l:names = getbufvar(l:buffer, 'ale_tsserver_completion_names', []) @@ -464,6 +536,7 @@ function! ale#completion#ParseTSServerCompletionEntryDetails(response) abort \ 'icase': 1, \ 'menu': '', \ 'info': '', + \ 'user_data': json_encode({'_ale_completion_item': 1}), \}) endfor endif @@ -517,23 +590,84 @@ function! ale#completion#ParseLSPCompletions(response) abort continue endif + " Don't use LSP items with additional text edits when autoimport for + " completions is turned off. + if !empty(get(l:item, 'additionalTextEdits')) + \&& !( + \ get(l:info, 'additional_edits_only', 0) + \ || g:ale_completion_autoimport + \) + continue + endif + let l:doc = get(l:item, 'documentation', '') if type(l:doc) is v:t_dict && has_key(l:doc, 'value') let l:doc = l:doc.value endif - call add(l:results, { + " Collapse whitespaces and line breaks into a single space. + let l:detail = substitute(get(l:item, 'detail', ''), '\_s\+', ' ', 'g') + + let l:result = { \ 'word': l:word, \ 'kind': ale#completion#GetCompletionSymbols(get(l:item, 'kind', '')), \ 'icase': 1, - \ 'menu': get(l:item, 'detail', ''), + \ 'menu': l:detail, \ 'info': (type(l:doc) is v:t_string ? l:doc : ''), - \}) + \} + " This flag is used to tell if this completion came from ALE or not. + let l:user_data = {'_ale_completion_item': 1} + + if has_key(l:item, 'additionalTextEdits') + \ && l:item.additionalTextEdits isnot v:null + let l:text_changes = [] + + for l:edit in l:item.additionalTextEdits + call add(l:text_changes, { + \ 'start': { + \ 'line': l:edit.range.start.line + 1, + \ 'offset': l:edit.range.start.character + 1, + \ }, + \ 'end': { + \ 'line': l:edit.range.end.line + 1, + \ 'offset': l:edit.range.end.character + 1, + \ }, + \ 'newText': l:edit.newText, + \}) + endfor + + if !empty(l:text_changes) + let l:user_data.code_actions = [{ + \ 'description': 'completion', + \ 'changes': [ + \ { + \ 'fileName': expand('#' . l:buffer . ':p'), + \ 'textChanges': l:text_changes, + \ }, + \ ], + \}] + endif + endif + + let l:result.user_data = json_encode(l:user_data) + + " Include this item if we'll accept any items, + " or if we only want items with additional edits, and this has them. + if !get(l:info, 'additional_edits_only', 0) + \|| has_key(l:user_data, 'code_actions') + call add(l:results, l:result) + endif endfor if has_key(l:info, 'prefix') - let l:results = ale#completion#Filter(l:buffer, &filetype, l:results, l:info.prefix) + let l:results = ale#completion#Filter( + \ l:buffer, + \ &filetype, + \ l:results, + \ l:info.prefix, + \ get(l:info, 'additional_edits_only', 0), + \) endif return l:results[: g:ale_completion_max_suggestions - 1] @@ -557,13 +691,18 @@ function! ale#completion#HandleTSServerResponse(conn_id, response) abort \ &filetype, \ ale#completion#ParseTSServerCompletions(a:response), \ b:ale_completion_info.prefix, + \ get(b:ale_completion_info, 'additional_edits_only', 0), \)[: g:ale_completion_max_suggestions - 1] " We need to remember some names for tsserver, as it doesn't send " details back for everything we send. call setbufvar(l:buffer, 'ale_tsserver_completion_names', l:names) - if !empty(l:names) + if empty(l:names) + " Response with no results now and skip making a redundant request + " for nothing. + call ale#completion#Show([]) + else let l:identifiers = [] for l:name in l:names @@ -628,12 +767,17 @@ function! s:OnReady(linter, lsp_details) abort call ale#lsp#RegisterCallback(l:id, l:Callback) if a:linter.lsp is# 'tsserver' + if get(g:, 'ale_completion_tsserver_autoimport') is 1 + execute 'echom `g:ale_completion_tsserver_autoimport` is deprecated. Use `g:ale_completion_autoimport` instead.''' + endif + let l:message = ale#lsp#tsserver_message#Completions( \ l:buffer, \ b:ale_completion_info.line, \ b:ale_completion_info.column, \ b:ale_completion_info.prefix, - \ g:ale_completion_tsserver_autoimport, + \ get(b:ale_completion_info, 'additional_edits_only', 0) + \ || g:ale_completion_autoimport, \) else " Send a message saying the buffer has changed first, otherwise @@ -692,9 +836,19 @@ function! ale#completion#GetCompletions(...) abort let b:CompleteCallback = l:CompleteCallback endif - let [l:line, l:column] = getpos('.')[1:2] + if has_key(l:options, 'line') && has_key(l:options, 'column') + " Use a provided line and column, if given. + let l:line = l:options.line + let l:column = l:options.column + else + let [l:line, l:column] = getpos('.')[1:2] + endif - let l:prefix = ale#completion#GetPrefix(&filetype, l:line, l:column) + if has_key(l:options, 'prefix') + let l:prefix = l:options.prefix + else + let l:prefix = ale#completion#GetPrefix(&filetype, l:line, l:column) + endif if l:source is# 'ale-automatic' && empty(l:prefix) return 0 @@ -713,6 +867,11 @@ function! ale#completion#GetCompletions(...) abort \} unlet! b:ale_completion_result + if has_key(l:options, 'additional_edits_only') + let b:ale_completion_info.additional_edits_only = + \ l:options.additional_edits_only + endif + let l:buffer = bufnr('') let l:Callback = function('s:OnReady') @@ -729,6 +888,37 @@ function! ale#completion#GetCompletions(...) abort return l:started endfunction +function! s:message(message) abort + call ale#util#Execute('echom ' . string(a:message)) +endfunction + +" This function implements the :ALEImport command. +function! ale#completion#Import() abort + let l:word = expand('') + + if empty(l:word) + call s:message('Nothing to complete at cursor!') + + return + endif + + let [l:line, l:column] = getpos('.')[1:2] + let l:column = searchpos('\V' . escape(l:word, '/\'), 'bn', l:line)[1] + + if l:column isnot 0 + let l:started = ale#completion#GetCompletions('ale-import', { + \ 'line': l:line, + \ 'column': l:column, + \ 'prefix': l:word, + \ 'additional_edits_only': 1, + \}) + + if !l:started + call s:message('No completion providers are available.') + endif + endif +endfunction + function! ale#completion#OmniFunc(findstart, base) abort if a:findstart let l:started = ale#completion#GetCompletions('ale-omnifunc') @@ -802,29 +992,29 @@ function! ale#completion#Queue() abort endfunction function! ale#completion#HandleUserData(completed_item) abort - let l:source = get(get(b:, 'ale_completion_info', {}), 'source', '') - - if l:source isnot# 'ale-automatic' - \&& l:source isnot# 'ale-manual' - \&& l:source isnot# 'ale-callback' - return - endif - let l:user_data_json = get(a:completed_item, 'user_data', '') - - if empty(l:user_data_json) - return - endif - - let l:user_data = json_decode(l:user_data_json) + let l:user_data = !empty(l:user_data_json) + \ ? json_decode(l:user_data_json) + \ : v:null if type(l:user_data) isnot v:t_dict + \|| get(l:user_data, '_ale_completion_item', 0) isnot 1 return endif - for l:code_action in get(l:user_data, 'codeActions', []) - call ale#code_action#HandleCodeAction(l:code_action) - endfor + let l:source = get(get(b:, 'ale_completion_info', {}), 'source', '') + + if l:source is# 'ale-automatic' + \|| l:source is# 'ale-manual' + \|| l:source is# 'ale-callback' + \|| l:source is# 'ale-import' + \|| l:source is# 'ale-omnifunc' + for l:code_action in get(l:user_data, 'code_actions', []) + call ale#code_action#HandleCodeAction(l:code_action, {}) + endfor + endif + + silent doautocmd User ALECompletePost endfunction function! ale#completion#Done() abort @@ -836,6 +1026,8 @@ function! ale#completion#Done() abort endfunction augroup ALECompletionActions + autocmd! + autocmd CompleteDone * call ale#completion#HandleUserData(v:completed_item) augroup END diff --git a/sources_non_forked/ale/autoload/ale/cursor.vim b/sources_non_forked/ale/autoload/ale/cursor.vim index 8c331c5c..9ca6fb15 100644 --- a/sources_non_forked/ale/autoload/ale/cursor.vim +++ b/sources_non_forked/ale/autoload/ale/cursor.vim @@ -39,6 +39,8 @@ function! ale#cursor#TruncatedEcho(original_message) abort endif exec 'echomsg l:message' + catch /E481/ + " Do nothing if running from a visual selection. endtry " Reset the cursor position if we moved off the end of the line. diff --git a/sources_non_forked/ale/autoload/ale/debugging.vim b/sources_non_forked/ale/autoload/ale/debugging.vim index 4e134f8c..5e6d5906 100644 --- a/sources_non_forked/ale/autoload/ale/debugging.vim +++ b/sources_non_forked/ale/autoload/ale/debugging.vim @@ -8,6 +8,7 @@ let s:global_variable_list = [ \ 'ale_completion_delay', \ 'ale_completion_enabled', \ 'ale_completion_max_suggestions', +\ 'ale_disable_lsp', \ 'ale_echo_cursor', \ 'ale_echo_msg_error_str', \ 'ale_echo_msg_format', @@ -28,6 +29,7 @@ let s:global_variable_list = [ \ 'ale_linter_aliases', \ 'ale_linters', \ 'ale_linters_explicit', +\ 'ale_linters_ignore', \ 'ale_list_vertical', \ 'ale_list_window_size', \ 'ale_loclist_msg_format', @@ -196,6 +198,7 @@ function! s:EchoLSPErrorMessages(all_linter_names) abort endfunction function! ale#debugging#Info() abort + let l:buffer = bufnr('') let l:filetype = &filetype " We get the list of enabled linters for free by the above function. @@ -222,10 +225,20 @@ function! ale#debugging#Info() abort let l:fixers = uniq(sort(l:fixers[0] + l:fixers[1])) let l:fixers_string = join(map(copy(l:fixers), '"\n " . v:val'), '') + let l:non_ignored_names = map( + \ copy(ale#linter#RemoveIgnored(l:buffer, l:filetype, l:enabled_linters)), + \ 'v:val[''name'']', + \) + let l:ignored_names = filter( + \ copy(l:enabled_names), + \ 'index(l:non_ignored_names, v:val) < 0' + \) + call s:Echo(' Current Filetype: ' . l:filetype) call s:Echo('Available Linters: ' . string(l:all_names)) call s:EchoLinterAliases(l:all_linters) call s:Echo(' Enabled Linters: ' . string(l:enabled_names)) + call s:Echo(' Ignored Linters: ' . string(l:ignored_names)) call s:Echo(' Suggested Fixers: ' . l:fixers_string) call s:Echo(' Linter Variables:') call s:Echo('') diff --git a/sources_non_forked/ale/autoload/ale/definition.vim b/sources_non_forked/ale/autoload/ale/definition.vim index 3915cac1..0c1fb7cf 100644 --- a/sources_non_forked/ale/autoload/ale/definition.vim +++ b/sources_non_forked/ale/autoload/ale/definition.vim @@ -5,6 +5,7 @@ let s:go_to_definition_map = {} " Enable automatic updates of the tagstack let g:ale_update_tagstack = get(g:, 'ale_update_tagstack', 1) +let g:ale_default_navigation = get(g:, 'ale_default_navigation', 'buffer') " Used to get the definition map in tests. function! ale#definition#GetMap() abort @@ -154,3 +155,33 @@ function! ale#definition#GoToType(options) abort endif endfor endfunction + +function! ale#definition#GoToCommandHandler(command, ...) abort + let l:options = {} + + if len(a:000) > 0 + for l:option in a:000 + if l:option is? '-tab' + let l:options.open_in = 'tab' + elseif l:option is? '-split' + let l:options.open_in = 'split' + elseif l:option is? '-vsplit' + let l:options.open_in = 'vsplit' + endif + endfor + endif + + if !has_key(l:options, 'open_in') + let l:default_navigation = ale#Var(bufnr(''), 'default_navigation') + + if index(['tab', 'split', 'vsplit'], l:default_navigation) >= 0 + let l:options.open_in = l:default_navigation + endif + endif + + if a:command is# 'type' + call ale#definition#GoToType(l:options) + else + call ale#definition#GoTo(l:options) + endif +endfunction diff --git a/sources_non_forked/ale/autoload/ale/engine.vim b/sources_non_forked/ale/autoload/ale/engine.vim index 491d3c2e..3cafa25c 100644 --- a/sources_non_forked/ale/autoload/ale/engine.vim +++ b/sources_non_forked/ale/autoload/ale/engine.vim @@ -4,6 +4,7 @@ " Remapping of linter problems. let g:ale_type_map = get(g:, 'ale_type_map', {}) +let g:ale_filename_mappings = get(g:, 'ale_filename_mappings', {}) if !has_key(s:, 'executable_cache_map') let s:executable_cache_map = {} @@ -104,42 +105,6 @@ function! ale#engine#IsCheckingBuffer(buffer) abort \ || !empty(get(l:info, 'active_other_sources_list', [])) endfunction -" Register a temporary file to be managed with the ALE engine for -" a current job run. -function! ale#engine#ManageFile(buffer, filename) abort - if !get(g:, 'ale_ignore_2_4_warnings') - execute 'echom ''ale#engine#ManageFile is deprecated. Use `let g:ale_ignore_2_4_warnings = 1` to disable this message.''' - endif - - call ale#command#ManageFile(a:buffer, a:filename) -endfunction - -" Same as the above, but manage an entire directory. -function! ale#engine#ManageDirectory(buffer, directory) abort - if !get(g:, 'ale_ignore_2_4_warnings') - execute 'echom ''ale#engine#ManageDirectory is deprecated. Use `let g:ale_ignore_2_4_warnings = 1` to disable this message.''' - endif - - call ale#command#ManageDirectory(a:buffer, a:directory) -endfunction - -function! ale#engine#CreateFile(buffer) abort - if !get(g:, 'ale_ignore_2_4_warnings') - execute 'echom ''ale#engine#CreateFile is deprecated. Use `let g:ale_ignore_2_4_warnings = 1` to disable this message.''' - endif - - return ale#command#CreateFile(a:buffer) -endfunction - -" Create a new temporary directory and manage it in one go. -function! ale#engine#CreateDirectory(buffer) abort - if !get(g:, 'ale_ignore_2_4_warnings') - execute 'echom ''ale#engine#CreateDirectory is deprecated. Use `let g:ale_ignore_2_4_warnings = 1` to disable this message.''' - endif - - return ale#command#CreateDirectory(a:buffer) -endfunction - function! ale#engine#HandleLoclist(linter_name, buffer, loclist, from_other_source) abort let l:info = get(g:ale_buffer_info, a:buffer, {}) @@ -192,7 +157,6 @@ function! s:HandleExit(job_info, buffer, output, data) abort let l:linter = a:job_info.linter let l:executable = a:job_info.executable - let l:next_chain_index = a:job_info.next_chain_index " Remove this job from the list. call ale#engine#MarkLinterInactive(l:buffer_info, l:linter.name) @@ -207,20 +171,6 @@ function! s:HandleExit(job_info, buffer, output, data) abort call remove(a:output, -1) endif - if l:next_chain_index < len(get(l:linter, 'command_chain', [])) - let [l:command, l:options] = ale#engine#ProcessChain( - \ a:buffer, - \ l:executable, - \ l:linter, - \ l:next_chain_index, - \ a:output, - \) - - call s:RunJob(l:command, l:options) - - return - endif - try let l:loclist = ale#util#GetFunction(l:linter.callback)(a:buffer, a:output) " Handle the function being unknown, or being deleted. @@ -307,6 +257,13 @@ function! s:RemapItemTypes(type_map, loclist) abort endfunction function! ale#engine#FixLocList(buffer, linter_name, from_other_source, loclist) abort + let l:mappings = ale#GetFilenameMappings(a:buffer, a:linter_name) + + if !empty(l:mappings) + " We need to apply reverse filename mapping here. + let l:mappings = ale#filename_mapping#Invert(l:mappings) + endif + let l:bufnr_map = {} let l:new_loclist = [] @@ -347,13 +304,19 @@ function! ale#engine#FixLocList(buffer, linter_name, from_other_source, loclist) let l:item.code = l:old_item.code endif - if has_key(l:old_item, 'filename') - \&& !ale#path#IsTempName(l:old_item.filename) + let l:old_name = get(l:old_item, 'filename', '') + + " Map parsed from output to local filesystem files. + if !empty(l:old_name) && !empty(l:mappings) + let l:old_name = ale#filename_mapping#Map(l:old_name, l:mappings) + endif + + if !empty(l:old_name) && !ale#path#IsTempName(l:old_name) " Use the filename given. " Temporary files are assumed to be for this buffer, " and the filename is not included then, because it looks bad " in the loclist window. - let l:filename = l:old_item.filename + let l:filename = l:old_name let l:item.filename = l:filename if has_key(l:old_item, 'bufnr') @@ -454,20 +417,19 @@ function! s:RunJob(command, options) abort let l:buffer = a:options.buffer let l:linter = a:options.linter let l:output_stream = a:options.output_stream - let l:next_chain_index = a:options.next_chain_index - let l:read_buffer = a:options.read_buffer + let l:read_buffer = a:options.read_buffer && !a:options.lint_file let l:info = g:ale_buffer_info[l:buffer] let l:Callback = function('s:HandleExit', [{ \ 'linter': l:linter, \ 'executable': l:executable, - \ 'next_chain_index': l:next_chain_index, \}]) let l:result = ale#command#Run(l:buffer, l:command, l:Callback, { \ 'output_stream': l:output_stream, \ 'executable': l:executable, \ 'read_buffer': l:read_buffer, - \ 'log_output': l:next_chain_index >= len(get(l:linter, 'command_chain', [])), + \ 'log_output': 1, + \ 'filename_mappings': ale#GetFilenameMappings(l:buffer, l:linter.name), \}) " Only proceed if the job is being run. @@ -482,69 +444,7 @@ function! s:RunJob(command, options) abort return 1 endfunction -" Determine which commands to run for a link in a command chain, or -" just a regular command. -function! ale#engine#ProcessChain(buffer, executable, linter, chain_index, input) abort - let l:output_stream = get(a:linter, 'output_stream', 'stdout') - let l:read_buffer = a:linter.read_buffer - let l:chain_index = a:chain_index - let l:input = a:input - - while l:chain_index < len(a:linter.command_chain) - " Run a chain of commands, one asynchronous command after the other, - " so that many programs can be run in a sequence. - let l:chain_item = a:linter.command_chain[l:chain_index] - - if l:chain_index == 0 - " The first callback in the chain takes only a buffer number. - let l:command = ale#util#GetFunction(l:chain_item.callback)( - \ a:buffer - \) - else - " The second callback in the chain takes some input too. - let l:command = ale#util#GetFunction(l:chain_item.callback)( - \ a:buffer, - \ l:input - \) - endif - - " If we have a command to run, execute that. - if !empty(l:command) - " The chain item can override the output_stream option. - if has_key(l:chain_item, 'output_stream') - let l:output_stream = l:chain_item.output_stream - endif - - " The chain item can override the read_buffer option. - if has_key(l:chain_item, 'read_buffer') - let l:read_buffer = l:chain_item.read_buffer - elseif l:chain_index != len(a:linter.command_chain) - 1 - " Don't read the buffer for commands besides the last one - " in the chain by default. - let l:read_buffer = 0 - endif - - break - endif - - " Command chain items can return an empty string to indicate that - " a command should be skipped, so we should try the next item - " with no input. - let l:input = [] - let l:chain_index += 1 - endwhile - - return [l:command, { - \ 'executable': a:executable, - \ 'buffer': a:buffer, - \ 'linter': a:linter, - \ 'output_stream': l:output_stream, - \ 'next_chain_index': l:chain_index + 1, - \ 'read_buffer': l:read_buffer, - \}] -endfunction - -function! s:StopCurrentJobs(buffer, clear_lint_file_jobs) abort +function! s:StopCurrentJobs(buffer, clear_lint_file_jobs, linter_slots) abort let l:info = get(g:ale_buffer_info, a:buffer, {}) call ale#command#StopJobs(a:buffer, 'linter') @@ -553,11 +453,25 @@ function! s:StopCurrentJobs(buffer, clear_lint_file_jobs) abort call ale#command#StopJobs(a:buffer, 'file_linter') let l:info.active_linter_list = [] else + let l:lint_file_map = {} + + " Use a previously computed map of `lint_file` values to find + " linters that are used for linting files. + for [l:lint_file, l:linter] in a:linter_slots + if l:lint_file is 1 + let l:lint_file_map[l:linter.name] = 1 + endif + endfor + " Keep jobs for linting files when we're only linting buffers. - call filter(l:info.active_linter_list, 'get(v:val, ''lint_file'')') + call filter(l:info.active_linter_list, 'get(l:lint_file_map, v:val.name)') endif endfunction +function! ale#engine#Stop(buffer) abort + call s:StopCurrentJobs(a:buffer, 1, []) +endfunction + function! s:RemoveProblemsForDisabledLinters(buffer, linters) abort " Figure out which linters are still enabled, and remove " problems for linters which are no longer enabled. @@ -608,10 +522,15 @@ function! s:AddProblemsFromOtherBuffers(buffer, linters) abort endif endfunction -function! s:RunIfExecutable(buffer, linter, executable) abort +function! s:RunIfExecutable(buffer, linter, lint_file, executable) abort if ale#command#IsDeferred(a:executable) let a:executable.result_callback = { - \ executable -> s:RunIfExecutable(a:buffer, a:linter, executable) + \ executable -> s:RunIfExecutable( + \ a:buffer, + \ a:linter, + \ a:lint_file, + \ executable + \ ) \} return 1 @@ -619,29 +538,17 @@ function! s:RunIfExecutable(buffer, linter, executable) abort if ale#engine#IsExecutable(a:buffer, a:executable) " Use different job types for file or linter jobs. - let l:job_type = a:linter.lint_file ? 'file_linter' : 'linter' + let l:job_type = a:lint_file ? 'file_linter' : 'linter' call setbufvar(a:buffer, 'ale_job_type', l:job_type) - if has_key(a:linter, 'command_chain') - let [l:command, l:options] = ale#engine#ProcessChain( - \ a:buffer, - \ a:executable, - \ a:linter, - \ 0, - \ [] - \) - - return s:RunJob(l:command, l:options) - endif - let l:command = ale#linter#GetCommand(a:buffer, a:linter) let l:options = { \ 'executable': a:executable, \ 'buffer': a:buffer, \ 'linter': a:linter, \ 'output_stream': get(a:linter, 'output_stream', 'stdout'), - \ 'next_chain_index': 1, \ 'read_buffer': a:linter.read_buffer, + \ 'lint_file': a:lint_file, \} return s:RunJob(l:command, l:options) @@ -653,22 +560,73 @@ endfunction " Run a linter for a buffer. " " Returns 1 if the linter was successfully run. -function! s:RunLinter(buffer, linter) abort +function! s:RunLinter(buffer, linter, lint_file) abort if !empty(a:linter.lsp) return ale#lsp_linter#CheckWithLSP(a:buffer, a:linter) else let l:executable = ale#linter#GetExecutable(a:buffer, a:linter) - return s:RunIfExecutable(a:buffer, a:linter, l:executable) + return s:RunIfExecutable(a:buffer, a:linter, a:lint_file, l:executable) endif return 0 endfunction -function! ale#engine#RunLinters(buffer, linters, should_lint_file) abort - " Initialise the buffer information if needed. - let l:new_buffer = ale#engine#InitBufferInfo(a:buffer) - call s:StopCurrentJobs(a:buffer, a:should_lint_file) +function! s:GetLintFileSlots(buffer, linters) abort + let l:linter_slots = [] + + for l:linter in a:linters + let l:LintFile = l:linter.lint_file + + if type(l:LintFile) is v:t_func + let l:LintFile = l:LintFile(a:buffer) + endif + + call add(l:linter_slots, [l:LintFile, l:linter]) + endfor + + return l:linter_slots +endfunction + +function! s:GetLintFileValues(slots, Callback) abort + let l:deferred_list = [] + let l:new_slots = [] + + for [l:lint_file, l:linter] in a:slots + while ale#command#IsDeferred(l:lint_file) && has_key(l:lint_file, 'value') + " If we've already computed the return value, use it. + let l:lint_file = l:lint_file.value + endwhile + + if ale#command#IsDeferred(l:lint_file) + " If we are going to return the result later, wait for it. + call add(l:deferred_list, l:lint_file) + else + " If we have the value now, coerce it to 0 or 1. + let l:lint_file = l:lint_file is 1 + endif + + call add(l:new_slots, [l:lint_file, l:linter]) + endfor + + if !empty(l:deferred_list) + for l:deferred in l:deferred_list + let l:deferred.result_callback = + \ {-> s:GetLintFileValues(l:new_slots, a:Callback)} + endfor + else + call a:Callback(l:new_slots) + endif +endfunction + +function! s:RunLinters( +\ buffer, +\ linters, +\ slots, +\ should_lint_file, +\ new_buffer, +\) abort + call s:StopCurrentJobs(a:buffer, a:should_lint_file, a:slots) call s:RemoveProblemsForDisabledLinters(a:buffer, a:linters) " We can only clear the results if we aren't checking the buffer. @@ -676,10 +634,10 @@ function! ale#engine#RunLinters(buffer, linters, should_lint_file) abort silent doautocmd User ALELintPre - for l:linter in a:linters + for [l:lint_file, l:linter] in a:slots " Only run lint_file linters if we should. - if !l:linter.lint_file || a:should_lint_file - if s:RunLinter(a:buffer, l:linter) + if !l:lint_file || a:should_lint_file + if s:RunLinter(a:buffer, l:linter, l:lint_file) " If a single linter ran, we shouldn't clear everything. let l:can_clear_results = 0 endif @@ -694,11 +652,32 @@ function! ale#engine#RunLinters(buffer, linters, should_lint_file) abort " disabled, or ALE itself is disabled. if l:can_clear_results call ale#engine#SetResults(a:buffer, []) - elseif l:new_buffer - call s:AddProblemsFromOtherBuffers(a:buffer, a:linters) + elseif a:new_buffer + call s:AddProblemsFromOtherBuffers( + \ a:buffer, + \ map(copy(a:slots), 'v:val[1]') + \) endif endfunction +function! ale#engine#RunLinters(buffer, linters, should_lint_file) abort + " Initialise the buffer information if needed. + let l:new_buffer = ale#engine#InitBufferInfo(a:buffer) + + call s:GetLintFileValues( + \ s:GetLintFileSlots(a:buffer, a:linters), + \ { + \ slots -> s:RunLinters( + \ a:buffer, + \ a:linters, + \ slots, + \ a:should_lint_file, + \ l:new_buffer, + \ ) + \ } + \) +endfunction + " Clean up a buffer. " " This function will stop all current jobs for the buffer, diff --git a/sources_non_forked/ale/autoload/ale/events.vim b/sources_non_forked/ale/autoload/ale/events.vim index da554ef9..3568c117 100644 --- a/sources_non_forked/ale/autoload/ale/events.vim +++ b/sources_non_forked/ale/autoload/ale/events.vim @@ -105,11 +105,11 @@ function! ale#events#Init() abort if g:ale_enabled if l:text_changed is? 'always' || l:text_changed is# '1' - autocmd TextChanged,TextChangedI * call ale#Queue(g:ale_lint_delay) + autocmd TextChanged,TextChangedI * call ale#Queue(ale#Var(str2nr(expand('')), 'lint_delay')) elseif l:text_changed is? 'normal' - autocmd TextChanged * call ale#Queue(g:ale_lint_delay) + autocmd TextChanged * call ale#Queue(ale#Var(str2nr(expand('')), 'lint_delay')) elseif l:text_changed is? 'insert' - autocmd TextChangedI * call ale#Queue(g:ale_lint_delay) + autocmd TextChangedI * call ale#Queue(ale#Var(str2nr(expand('')), 'lint_delay')) endif if g:ale_lint_on_enter @@ -147,6 +147,10 @@ function! ale#events#Init() abort autocmd InsertLeave * if exists('*ale#engine#Cleanup') | call ale#virtualtext#ShowCursorWarning() | endif endif + if g:ale_hover_cursor + autocmd CursorHold * if exists('*ale#lsp#Send') | call ale#hover#ShowTruncatedMessageAtCursor() | endif + endif + if g:ale_close_preview_on_insert autocmd InsertEnter * if exists('*ale#preview#CloseIfTypeMatches') | call ale#preview#CloseIfTypeMatches('ale-preview') | endif endif diff --git a/sources_non_forked/ale/autoload/ale/filename_mapping.vim b/sources_non_forked/ale/autoload/ale/filename_mapping.vim new file mode 100644 index 00000000..76d47acc --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/filename_mapping.vim @@ -0,0 +1,22 @@ +" Author: w0rp +" Description: Logic for handling mappings between files + +" Invert filesystem mappings so they can be mapped in reverse. +function! ale#filename_mapping#Invert(filename_mappings) abort + return map(copy(a:filename_mappings), '[v:val[1], v:val[0]]') +endfunction + +" Given a filename and some filename_mappings, map a filename. +function! ale#filename_mapping#Map(filename, filename_mappings) abort + let l:simplified_filename = ale#path#Simplify(a:filename) + + for [l:mapping_from, l:mapping_to] in a:filename_mappings + let l:mapping_from = ale#path#Simplify(l:mapping_from) + + if l:simplified_filename[:len(l:mapping_from) - 1] is# l:mapping_from + return l:mapping_to . l:simplified_filename[len(l:mapping_from):] + endif + endfor + + return a:filename +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fix.vim b/sources_non_forked/ale/autoload/ale/fix.vim index dad9e2bc..c3338fc5 100644 --- a/sources_non_forked/ale/autoload/ale/fix.vim +++ b/sources_non_forked/ale/autoload/ale/fix.vim @@ -1,57 +1,43 @@ -call ale#Set('fix_on_save_ignore', {}) +" Author: w0rp +" Description: Functions for fixing code with programs, or other means. + +let g:ale_fix_on_save_ignore = get(g:, 'ale_fix_on_save_ignore', {}) +let g:ale_filename_mappings = get(g:, 'ale_filename_mappings', {}) " Apply fixes queued up for buffers which may be hidden. " Vim doesn't let you modify hidden buffers. function! ale#fix#ApplyQueuedFixes(buffer) abort let l:data = get(g:ale_fix_buffer_data, a:buffer, {'done': 0}) - let l:has_bufline_api = exists('*deletebufline') && exists('*setbufline') - if !l:data.done || (!l:has_bufline_api && a:buffer isnot bufnr('')) + if !l:data.done || (!ale#util#HasBuflineApi() && a:buffer isnot bufnr('')) return endif call remove(g:ale_fix_buffer_data, a:buffer) - if l:data.changes_made - " If the file is in DOS mode, we have to remove carriage returns from - " the ends of lines before calling setline(), or we will see them - " twice. - let l:new_lines = getbufvar(a:buffer, '&fileformat') is# 'dos' - \ ? map(copy(l:data.output), 'substitute(v:val, ''\r\+$'', '''', '''')') - \ : l:data.output - let l:first_line_to_remove = len(l:new_lines) + 1 + try + if l:data.changes_made + let l:new_lines = ale#util#SetBufferContents(a:buffer, l:data.output) - " Use a Vim API for setting lines in other buffers, if available. - if l:has_bufline_api - call setbufline(a:buffer, 1, l:new_lines) - call deletebufline(a:buffer, l:first_line_to_remove, '$') - " Fall back on setting lines the old way, for the current buffer. - else - let l:old_line_length = len(l:data.lines_before) - - if l:old_line_length >= l:first_line_to_remove - let l:save = winsaveview() - silent execute - \ l:first_line_to_remove . ',' . l:old_line_length . 'd_' - call winrestview(l:save) - endif - - call setline(1, l:new_lines) - endif - - if l:data.should_save - if a:buffer is bufnr('') - if empty(&buftype) - noautocmd :w! + if l:data.should_save + if a:buffer is bufnr('') + if empty(&buftype) + noautocmd :w! + else + set nomodified + endif else - set nomodified + call writefile(l:new_lines, expand('#' . a:buffer . ':p')) " no-custom-checks + call setbufvar(a:buffer, '&modified', 0) endif - else - call writefile(l:new_lines, expand('#' . a:buffer . ':p')) " no-custom-checks - call setbufvar(a:buffer, '&modified', 0) endif endif - endif + catch /E21/ + " If we cannot modify the buffer now, try again later. + let g:ale_fix_buffer_data[a:buffer] = l:data + + return + endtry if l:data.should_save let l:should_lint = ale#Var(a:buffer, 'fix_on_save') @@ -89,7 +75,10 @@ function! ale#fix#ApplyFixes(buffer, output) abort if l:data.lines_before != l:lines call remove(g:ale_fix_buffer_data, a:buffer) - execute 'echoerr ''The file was changed before fixing finished''' + + if !l:data.ignore_file_changed_errors + execute 'echoerr ''The file was changed before fixing finished''' + endif return endif @@ -115,7 +104,6 @@ function! s:HandleExit(job_info, buffer, job_output, data) abort let l:output = a:job_output endif - let l:ChainCallback = get(a:job_info, 'chain_with', v:null) let l:ProcessWith = get(a:job_info, 'process_with', v:null) " Post-process the output with a function if we have one. @@ -127,27 +115,17 @@ function! s:HandleExit(job_info, buffer, job_output, data) abort " otherwise skip this job and use the input from before. " " We'll use the input from before for chained commands. - if l:ChainCallback is v:null && !empty(split(join(l:output))) + if !empty(split(join(l:output))) let l:input = l:output else let l:input = a:job_info.input endif - if l:ChainCallback isnot v:null && !get(g:, 'ale_ignore_2_4_warnings') - execute 'echom ''chain_with is deprecated. Use `let g:ale_ignore_2_4_warnings = 1` to disable this message.''' - endif - - let l:next_index = l:ChainCallback is v:null - \ ? a:job_info.callback_index + 1 - \ : a:job_info.callback_index - call s:RunFixer({ \ 'buffer': a:buffer, \ 'input': l:input, - \ 'output': l:output, \ 'callback_list': a:job_info.callback_list, - \ 'callback_index': l:next_index, - \ 'chain_callback': l:ChainCallback, + \ 'callback_index': a:job_info.callback_index + 1, \}) endfunction @@ -160,6 +138,7 @@ function! s:RunJob(result, options) abort let l:buffer = a:options.buffer let l:input = a:options.input + let l:fixer_name = a:options.fixer_name if a:result is 0 || type(a:result) is v:t_list if type(a:result) is v:t_list @@ -177,26 +156,21 @@ function! s:RunJob(result, options) abort endif let l:command = get(a:result, 'command', '') - let l:ChainWith = get(a:result, 'chain_with', v:null) if empty(l:command) - " If the command is empty, skip to the next item, or call the - " chain_with function. + " If the command is empty, skip to the next item. call s:RunFixer({ \ 'buffer': l:buffer, \ 'input': l:input, - \ 'callback_index': a:options.callback_index + (l:ChainWith is v:null), + \ 'callback_index': a:options.callback_index, \ 'callback_list': a:options.callback_list, - \ 'chain_callback': l:ChainWith, - \ 'output': [], \}) return endif let l:read_temporary_file = get(a:result, 'read_temporary_file', 0) - " Default to piping the buffer for the last fixer in the chain. - let l:read_buffer = get(a:result, 'read_buffer', l:ChainWith is v:null) + let l:read_buffer = get(a:result, 'read_buffer', 1) let l:output_stream = get(a:result, 'output_stream', 'stdout') if l:read_temporary_file @@ -205,7 +179,6 @@ function! s:RunJob(result, options) abort let l:Callback = function('s:HandleExit', [{ \ 'input': l:input, - \ 'chain_with': l:ChainWith, \ 'callback_index': a:options.callback_index, \ 'callback_list': a:options.callback_list, \ 'process_with': get(a:result, 'process_with', v:null), @@ -217,6 +190,7 @@ function! s:RunJob(result, options) abort \ 'read_buffer': l:read_buffer, \ 'input': l:input, \ 'log_output': 0, + \ 'filename_mappings': ale#GetFilenameMappings(l:buffer, l:fixer_name), \}) if empty(l:run_result) @@ -240,32 +214,22 @@ function! s:RunFixer(options) abort return endif - let l:ChainCallback = get(a:options, 'chain_callback', v:null) - - let l:Function = l:ChainCallback isnot v:null - \ ? ale#util#GetFunction(l:ChainCallback) - \ : a:options.callback_list[l:index] + let [l:fixer_name, l:Function] = a:options.callback_list[l:index] " Record new jobs started as fixer jobs. call setbufvar(l:buffer, 'ale_job_type', 'fixer') - if l:ChainCallback isnot v:null - " Chained commands accept (buffer, output, [input]) - let l:result = ale#util#FunctionArgCount(l:Function) == 2 - \ ? call(l:Function, [l:buffer, a:options.output]) - \ : call(l:Function, [l:buffer, a:options.output, copy(l:input)]) - else - " Regular fixer commands accept (buffer, [input]) - let l:result = ale#util#FunctionArgCount(l:Function) == 1 - \ ? call(l:Function, [l:buffer]) - \ : call(l:Function, [l:buffer, copy(l:input)]) - endif + " Regular fixer commands accept (buffer, [input]) + let l:result = ale#util#FunctionArgCount(l:Function) == 1 + \ ? call(l:Function, [l:buffer]) + \ : call(l:Function, [l:buffer, copy(l:input)]) call s:RunJob(l:result, { \ 'buffer': l:buffer, \ 'input': l:input, \ 'callback_list': a:options.callback_list, \ 'callback_index': l:index, + \ 'fixer_name': l:fixer_name, \}) endfunction @@ -333,16 +297,24 @@ function! s:GetCallbacks(buffer, fixing_flag, fixers) abort " Variables with capital characters are needed, or Vim will complain about " funcref variables. for l:Item in l:callback_list + " Try to capture the names of registered fixer names, so we can use + " them for filename mapping or other purposes later. + let l:fixer_name = v:null + if type(l:Item) is v:t_string let l:Func = ale#fix#registry#GetFunc(l:Item) if !empty(l:Func) + let l:fixer_name = l:Item let l:Item = l:Func endif endif try - call add(l:corrected_list, ale#util#GetFunction(l:Item)) + call add(l:corrected_list, [ + \ l:fixer_name, + \ ale#util#GetFunction(l:Item) + \]) catch /E475/ " Rethrow exceptions for failing to get a function so we can print " a friendly message about it. @@ -360,6 +332,7 @@ function! ale#fix#InitBufferData(buffer, fixing_flag) abort \ 'lines_before': getbufline(a:buffer, 1, '$'), \ 'done': 0, \ 'should_save': a:fixing_flag is# 'save_file', + \ 'ignore_file_changed_errors': a:fixing_flag is# '!', \ 'temporary_directory_list': [], \} endfunction @@ -368,19 +341,23 @@ endfunction " " Returns 0 if no fixes can be applied, and 1 if fixing can be done. function! ale#fix#Fix(buffer, fixing_flag, ...) abort - if a:fixing_flag isnot# '' && a:fixing_flag isnot# 'save_file' - throw "fixing_flag must be either '' or 'save_file'" + if a:fixing_flag isnot# '' + \&& a:fixing_flag isnot# '!' + \&& a:fixing_flag isnot# 'save_file' + throw "fixing_flag must be '', '!', or 'save_file'" endif try let l:callback_list = s:GetCallbacks(a:buffer, a:fixing_flag, a:000) catch /E700\|BADNAME/ - let l:function_name = join(split(split(v:exception, ':')[3])) - let l:echo_message = printf( - \ 'There is no fixer named `%s`. Check :ALEFixSuggest', - \ l:function_name, - \) - execute 'echom l:echo_message' + if a:fixing_flag isnot# '!' + let l:function_name = join(split(split(v:exception, ':')[3])) + let l:echo_message = printf( + \ 'There is no fixer named `%s`. Check :ALEFixSuggest', + \ l:function_name, + \) + execute 'echom l:echo_message' + endif return 0 endtry @@ -414,3 +391,4 @@ endfunction augroup ALEBufferFixGroup autocmd! autocmd BufEnter * call ale#fix#ApplyQueuedFixes(str2nr(expand(''))) +augroup END diff --git a/sources_non_forked/ale/autoload/ale/fix/registry.vim b/sources_non_forked/ale/autoload/ale/fix/registry.vim index 1b3ca1a8..0f146faa 100644 --- a/sources_non_forked/ale/autoload/ale/fix/registry.vim +++ b/sources_non_forked/ale/autoload/ale/fix/registry.vim @@ -12,6 +12,11 @@ let s:default_registry = { \ 'suggested_filetypes': ['help'], \ 'description': 'Align help tags to the right margin', \ }, +\ 'autoimport': { +\ 'function': 'ale#fixers#autoimport#Fix', +\ 'suggested_filetypes': ['python'], +\ 'description': 'Fix import issues with autoimport.', +\ }, \ 'autopep8': { \ 'function': 'ale#fixers#autopep8#Fix', \ 'suggested_filetypes': ['python'], @@ -105,6 +110,11 @@ let s:default_registry = { \ 'suggested_filetypes': [], \ 'description': 'Remove all trailing whitespace characters at the end of every line.', \ }, +\ 'yamlfix': { +\ 'function': 'ale#fixers#yamlfix#Fix', +\ 'suggested_filetypes': ['yaml'], +\ 'description': 'Fix yaml files with yamlfix.', +\ }, \ 'yapf': { \ 'function': 'ale#fixers#yapf#Fix', \ 'suggested_filetypes': ['python'], @@ -160,6 +170,11 @@ let s:default_registry = { \ 'suggested_filetypes': ['php'], \ 'description': 'Fix PHP files with php-cs-fixer.', \ }, +\ 'astyle': { +\ 'function': 'ale#fixers#astyle#Fix', +\ 'suggested_filetypes': ['c', 'cpp'], +\ 'description': 'Fix C/C++ with astyle.', +\ }, \ 'clangtidy': { \ 'function': 'ale#fixers#clangtidy#Fix', \ 'suggested_filetypes': ['c', 'cpp', 'objc'], @@ -360,11 +375,31 @@ let s:default_registry = { \ 'suggested_filetypes': ['nix'], \ 'description': 'A formatter for Nix code', \ }, +\ 'remark-lint': { +\ 'function': 'ale#fixers#remark_lint#Fix', +\ 'suggested_filetypes': ['markdown'], +\ 'description': 'Fix markdown files with remark-lint', +\ }, \ 'html-beautify': { \ 'function': 'ale#fixers#html_beautify#Fix', \ 'suggested_filetypes': ['html', 'htmldjango'], \ 'description': 'Fix HTML files with html-beautify.', \ }, +\ 'luafmt': { +\ 'function': 'ale#fixers#luafmt#Fix', +\ 'suggested_filetypes': ['lua'], +\ 'description': 'Fix Lua files with luafmt.', +\ }, +\ 'dhall': { +\ 'function': 'ale#fixers#dhall#Fix', +\ 'suggested_filetypes': ['dhall'], +\ 'description': 'Fix Dhall files with dhall-format.', +\ }, +\ 'ormolu': { +\ 'function': 'ale#fixers#ormolu#Fix', +\ 'suggested_filetypes': ['haskell'], +\ 'description': 'A formatter for Haskell source code.', +\ }, \} " Reset the function registry to the default entries. diff --git a/sources_non_forked/ale/autoload/ale/fixers/astyle.vim b/sources_non_forked/ale/autoload/ale/fixers/astyle.vim new file mode 100644 index 00000000..3a5a70a1 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/astyle.vim @@ -0,0 +1,59 @@ +" Author: James Kim +" Description: Fix C/C++ files with astyle. + +function! s:set_variables() abort + for l:ft in ['c', 'cpp'] + call ale#Set(l:ft . '_astyle_executable', 'astyle') + call ale#Set(l:ft . '_astyle_project_options', '') + endfor +endfunction + +call s:set_variables() + + +function! ale#fixers#astyle#Var(buffer, name) abort + let l:ft = getbufvar(str2nr(a:buffer), '&filetype') + let l:ft = l:ft =~# 'cpp' ? 'cpp' : 'c' + + return ale#Var(a:buffer, l:ft . '_astyle_' . a:name) +endfunction + +" Try to find a project options file. +function! ale#fixers#astyle#FindProjectOptions(buffer) abort + let l:proj_options = ale#fixers#astyle#Var(a:buffer, 'project_options') + + " If user has set project options variable then use it and skip any searching. + " This would allow users to use project files named differently than .astylerc. + if !empty(l:proj_options) + return l:proj_options + endif + + " Try to find nearest .astylerc file. + let l:proj_options = fnamemodify(ale#path#FindNearestFile(a:buffer, '.astylerc'), ':t') + + if !empty(l:proj_options) + return l:proj_options + endif + + " Try to find nearest _astylerc file. + let l:proj_options = fnamemodify(ale#path#FindNearestFile(a:buffer, '_astylerc'), ':t') + + if !empty(l:proj_options) + return l:proj_options + endif + + " If no project options file is found return an empty string. + return '' +endfunction + +function! ale#fixers#astyle#Fix(buffer) abort + let l:executable = ale#fixers#astyle#Var(a:buffer, 'executable') + let l:proj_options = ale#fixers#astyle#FindProjectOptions(a:buffer) + let l:command = ' --stdin=' . ale#Escape(expand('#' . a:buffer)) + + return { + \ 'command': ale#Escape(l:executable) + \ . (empty(l:proj_options) ? '' : ' --project=' . l:proj_options) + \ . l:command + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/autoimport.vim b/sources_non_forked/ale/autoload/ale/fixers/autoimport.vim new file mode 100644 index 00000000..37a52db8 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/autoimport.vim @@ -0,0 +1,25 @@ +" Author: lyz-code +" Description: Fixing Python imports with autoimport. + +call ale#Set('python_autoimport_executable', 'autoimport') +call ale#Set('python_autoimport_options', '') +call ale#Set('python_autoimport_use_global', get(g:, 'ale_use_global_executables', 0)) + +function! ale#fixers#autoimport#Fix(buffer) abort + let l:options = ale#Var(a:buffer, 'python_autoimport_options') + + let l:executable = ale#python#FindExecutable( + \ a:buffer, + \ 'python_autoimport', + \ ['autoimport'], + \) + + if !executable(l:executable) + return 0 + endif + + return { + \ 'command': ale#path#BufferCdString(a:buffer) + \ . ale#Escape(l:executable) . (!empty(l:options) ? ' ' . l:options : '') . ' -', + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/dhall.vim b/sources_non_forked/ale/autoload/ale/fixers/dhall.vim new file mode 100644 index 00000000..18f6006c --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/dhall.vim @@ -0,0 +1,23 @@ +" Author: Pat Brisbin +" Description: Integration of dhall-format with ALE. + +call ale#Set('dhall_format_executable', 'dhall') + +function! ale#fixers#dhall#GetExecutable(buffer) abort + let l:executable = ale#Var(a:buffer, 'dhall_format_executable') + + " Dhall is written in Haskell and commonly installed with Stack + return ale#handlers#haskell_stack#EscapeExecutable(l:executable, 'dhall') +endfunction + +function! ale#fixers#dhall#Fix(buffer) abort + let l:executable = ale#fixers#dhall#GetExecutable(a:buffer) + + return { + \ 'command': l:executable + \ . ' format' + \ . ' --inplace' + \ . ' %t', + \ 'read_temporary_file': 1, + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/eslint.vim b/sources_non_forked/ale/autoload/ale/fixers/eslint.vim index 62e692b1..f725875c 100644 --- a/sources_non_forked/ale/autoload/ale/fixers/eslint.vim +++ b/sources_non_forked/ale/autoload/ale/fixers/eslint.vim @@ -53,7 +53,8 @@ function! ale#fixers#eslint#ApplyFixForVersion(buffer, version) abort " Use --fix-to-stdout with eslint_d if l:executable =~# 'eslint_d$' && ale#semver#GTE(a:version, [3, 19, 0]) return { - \ 'command': ale#node#Executable(a:buffer, l:executable) + \ 'command': ale#handlers#eslint#GetCdString(a:buffer) + \ . ale#node#Executable(a:buffer, l:executable) \ . ale#Pad(l:options) \ . ' --stdin-filename %s --stdin --fix-to-stdout', \ 'process_with': 'ale#fixers#eslint#ProcessEslintDOutput', @@ -63,7 +64,8 @@ function! ale#fixers#eslint#ApplyFixForVersion(buffer, version) abort " 4.9.0 is the first version with --fix-dry-run if ale#semver#GTE(a:version, [4, 9, 0]) return { - \ 'command': ale#node#Executable(a:buffer, l:executable) + \ 'command': ale#handlers#eslint#GetCdString(a:buffer) + \ . ale#node#Executable(a:buffer, l:executable) \ . ale#Pad(l:options) \ . ' --stdin-filename %s --stdin --fix-dry-run --format=json', \ 'process_with': 'ale#fixers#eslint#ProcessFixDryRunOutput', @@ -71,7 +73,8 @@ function! ale#fixers#eslint#ApplyFixForVersion(buffer, version) abort endif return { - \ 'command': ale#node#Executable(a:buffer, l:executable) + \ 'command': ale#handlers#eslint#GetCdString(a:buffer) + \ . ale#node#Executable(a:buffer, l:executable) \ . ale#Pad(l:options) \ . (!empty(l:config) ? ' -c ' . ale#Escape(l:config) : '') \ . ' --fix %t', diff --git a/sources_non_forked/ale/autoload/ale/fixers/gofmt.vim b/sources_non_forked/ale/autoload/ale/fixers/gofmt.vim index d5a539b9..b9cfbb58 100644 --- a/sources_non_forked/ale/autoload/ale/fixers/gofmt.vim +++ b/sources_non_forked/ale/autoload/ale/fixers/gofmt.vim @@ -11,9 +11,6 @@ function! ale#fixers#gofmt#Fix(buffer) abort return { \ 'command': l:env . ale#Escape(l:executable) - \ . ' -l -w' \ . (empty(l:options) ? '' : ' ' . l:options) - \ . ' %t', - \ 'read_temporary_file': 1, \} endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/ktlint.vim b/sources_non_forked/ale/autoload/ale/fixers/ktlint.vim index cb975d6c..64d1340d 100644 --- a/sources_non_forked/ale/autoload/ale/fixers/ktlint.vim +++ b/sources_non_forked/ale/autoload/ale/fixers/ktlint.vim @@ -3,7 +3,6 @@ function! ale#fixers#ktlint#Fix(buffer) abort return { - \ 'command': ale#handlers#ktlint#GetCommand(a:buffer) . ' --format', - \ 'read_temporary_file': 1, + \ 'command': ale#handlers#ktlint#GetCommand(a:buffer) . ' --format' \} endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/latexindent.vim b/sources_non_forked/ale/autoload/ale/fixers/latexindent.vim index b0a0884a..54f1231e 100644 --- a/sources_non_forked/ale/autoload/ale/fixers/latexindent.vim +++ b/sources_non_forked/ale/autoload/ale/fixers/latexindent.vim @@ -10,9 +10,7 @@ function! ale#fixers#latexindent#Fix(buffer) abort return { \ 'command': ale#Escape(l:executable) - \ . ' -l -w' + \ . ' -l' \ . (empty(l:options) ? '' : ' ' . l:options) - \ . ' %t', - \ 'read_temporary_file': 1, \} endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/luafmt.vim b/sources_non_forked/ale/autoload/ale/fixers/luafmt.vim new file mode 100644 index 00000000..6cb9ef4a --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/luafmt.vim @@ -0,0 +1,13 @@ +call ale#Set('lua_luafmt_executable', 'luafmt') +call ale#Set('lua_luafmt_options', '') + +function! ale#fixers#luafmt#Fix(buffer) abort + let l:executable = ale#Var(a:buffer, 'lua_luafmt_executable') + let l:options = ale#Var(a:buffer, 'lua_luafmt_options') + + return { + \ 'command': ale#Escape(l:executable) + \ . (empty(l:options) ? '' : ' ' . l:options) + \ . ' --stdin', + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/ocamlformat.vim b/sources_non_forked/ale/autoload/ale/fixers/ocamlformat.vim index 9b7c3e12..b12d2eb9 100644 --- a/sources_non_forked/ale/autoload/ale/fixers/ocamlformat.vim +++ b/sources_non_forked/ale/autoload/ale/fixers/ocamlformat.vim @@ -5,14 +5,13 @@ call ale#Set('ocaml_ocamlformat_executable', 'ocamlformat') call ale#Set('ocaml_ocamlformat_options', '') function! ale#fixers#ocamlformat#Fix(buffer) abort - let l:filename = expand('#' . a:buffer . ':p') let l:executable = ale#Var(a:buffer, 'ocaml_ocamlformat_executable') let l:options = ale#Var(a:buffer, 'ocaml_ocamlformat_options') return { \ 'command': ale#Escape(l:executable) \ . (empty(l:options) ? '' : ' ' . l:options) - \ . ' --name=' . ale#Escape(l:filename) + \ . ' --name=%s' \ . ' -' \} endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/ormolu.vim b/sources_non_forked/ale/autoload/ale/fixers/ormolu.vim new file mode 100644 index 00000000..69b55c1f --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/ormolu.vim @@ -0,0 +1,12 @@ +call ale#Set('haskell_ormolu_executable', 'ormolu') +call ale#Set('haskell_ormolu_options', '') + +function! ale#fixers#ormolu#Fix(buffer) abort + let l:executable = ale#Var(a:buffer, 'haskell_ormolu_executable') + let l:options = ale#Var(a:buffer, 'haskell_ormolu_options') + + return { + \ 'command': ale#Escape(l:executable) + \ . (empty(l:options) ? '' : ' ' . l:options), + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/phpcbf.vim b/sources_non_forked/ale/autoload/ale/fixers/phpcbf.vim index f14b8406..0a61c657 100644 --- a/sources_non_forked/ale/autoload/ale/fixers/phpcbf.vim +++ b/sources_non_forked/ale/autoload/ale/fixers/phpcbf.vim @@ -2,6 +2,7 @@ " Description: Fixing files with phpcbf. call ale#Set('php_phpcbf_standard', '') +call ale#Set('php_phpcbf_options', '') call ale#Set('php_phpcbf_executable', 'phpcbf') call ale#Set('php_phpcbf_use_global', get(g:, 'ale_use_global_executables', 0)) @@ -20,6 +21,6 @@ function! ale#fixers#phpcbf#Fix(buffer) abort \ : '' return { - \ 'command': ale#Escape(l:executable) . ' --stdin-path=%s ' . l:standard_option . ' -' + \ 'command': ale#Escape(l:executable) . ' --stdin-path=%s ' . l:standard_option . ale#Pad(ale#Var(a:buffer, 'php_phpcbf_options')) . ' -' \} endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/prettier.vim b/sources_non_forked/ale/autoload/ale/fixers/prettier.vim index 23120777..e0f4972e 100644 --- a/sources_non_forked/ale/autoload/ale/fixers/prettier.vim +++ b/sources_non_forked/ale/autoload/ale/fixers/prettier.vim @@ -34,6 +34,21 @@ function! ale#fixers#prettier#ProcessPrettierDOutput(buffer, output) abort return a:output endfunction +function! ale#fixers#prettier#GetProjectRoot(buffer) abort + let l:config = ale#path#FindNearestFile(a:buffer, '.prettierignore') + + if !empty(l:config) + return fnamemodify(l:config, ':h') + endif + + " Fall back to the directory of the buffer + return fnamemodify(bufname(a:buffer), ':p:h') +endfunction + +function! ale#fixers#prettier#CdProjectRoot(buffer) abort + return ale#path#CdString(ale#fixers#prettier#GetProjectRoot(a:buffer)) +endfunction + function! ale#fixers#prettier#ApplyFixForVersion(buffer, version) abort let l:executable = ale#fixers#prettier#GetExecutable(a:buffer) let l:options = ale#Var(a:buffer, 'javascript_prettier_options') @@ -97,7 +112,7 @@ function! ale#fixers#prettier#ApplyFixForVersion(buffer, version) abort " 1.4.0 is the first version with --stdin-filepath if ale#semver#GTE(a:version, [1, 4, 0]) return { - \ 'command': ale#path#BufferCdString(a:buffer) + \ 'command': ale#fixers#prettier#CdProjectRoot(a:buffer) \ . ale#Escape(l:executable) \ . (!empty(l:options) ? ' ' . l:options : '') \ . ' --stdin-filepath %s --stdin', diff --git a/sources_non_forked/ale/autoload/ale/fixers/prettier_standard.vim b/sources_non_forked/ale/autoload/ale/fixers/prettier_standard.vim index b6e0a6f9..9d982ff6 100644 --- a/sources_non_forked/ale/autoload/ale/fixers/prettier_standard.vim +++ b/sources_non_forked/ale/autoload/ale/fixers/prettier_standard.vim @@ -17,8 +17,8 @@ function! ale#fixers#prettier_standard#Fix(buffer) abort return { \ 'command': ale#Escape(ale#fixers#prettier_standard#GetExecutable(a:buffer)) - \ . ' %t' + \ . ' --stdin' + \ . ' --stdin-filepath=%s' \ . ' ' . l:options, - \ 'read_temporary_file': 1, \} endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/remark_lint.vim b/sources_non_forked/ale/autoload/ale/fixers/remark_lint.vim new file mode 100644 index 00000000..3ce442f3 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/remark_lint.vim @@ -0,0 +1,24 @@ +" Author: blyoa +" Description: Fixing files with remark-lint. + +call ale#Set('markdown_remark_lint_executable', 'remark') +call ale#Set('markdown_remark_lint_use_global', get(g:, 'ale_use_global_executables', 0)) +call ale#Set('markdown_remark_lint_options', '') + +function! ale#fixers#remark_lint#GetExecutable(buffer) abort + return ale#node#FindExecutable(a:buffer, 'markdown_remark_lint', [ + \ 'node_modules/remark-cli/cli.js', + \ 'node_modules/.bin/remark', + \]) +endfunction + +function! ale#fixers#remark_lint#Fix(buffer) abort + let l:executable = ale#fixers#remark_lint#GetExecutable(a:buffer) + let l:options = ale#Var(a:buffer, 'markdown_remark_lint_options') + + return { + \ 'command': ale#Escape(l:executable) + \ . (!empty(l:options) ? ' ' . l:options : ''), + \} +endfunction + diff --git a/sources_non_forked/ale/autoload/ale/fixers/rubocop.vim b/sources_non_forked/ale/autoload/ale/fixers/rubocop.vim index 0c7441e4..cdfb014a 100644 --- a/sources_non_forked/ale/autoload/ale/fixers/rubocop.vim +++ b/sources_non_forked/ale/autoload/ale/fixers/rubocop.vim @@ -1,20 +1,40 @@ call ale#Set('ruby_rubocop_options', '') +call ale#Set('ruby_rubocop_auto_correct_all', 0) call ale#Set('ruby_rubocop_executable', 'rubocop') +" Rubocop fixer outputs diagnostics first and then the fixed +" output. These are delimited by a "=======" string that we +" look for to remove everything before it. +function! ale#fixers#rubocop#PostProcess(buffer, output) abort + let l:line = 0 + + for l:output in a:output + let l:line = l:line + 1 + + if l:output =~# "^=\\+$" + break + endif + endfor + + return a:output[l:line :] +endfunction + function! ale#fixers#rubocop#GetCommand(buffer) abort let l:executable = ale#Var(a:buffer, 'ruby_rubocop_executable') let l:config = ale#path#FindNearestFile(a:buffer, '.rubocop.yml') let l:options = ale#Var(a:buffer, 'ruby_rubocop_options') + let l:auto_correct_all = ale#Var(a:buffer, 'ruby_rubocop_auto_correct_all') return ale#ruby#EscapeExecutable(l:executable, 'rubocop') \ . (!empty(l:config) ? ' --config ' . ale#Escape(l:config) : '') \ . (!empty(l:options) ? ' ' . l:options : '') - \ . ' --auto-correct --force-exclusion %t' + \ . (l:auto_correct_all ? ' --auto-correct-all' : ' --auto-correct') + \ . ' --force-exclusion --stdin %s' endfunction function! ale#fixers#rubocop#Fix(buffer) abort return { \ 'command': ale#fixers#rubocop#GetCommand(a:buffer), - \ 'read_temporary_file': 1, + \ 'process_with': 'ale#fixers#rubocop#PostProcess' \} endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/standard.vim b/sources_non_forked/ale/autoload/ale/fixers/standard.vim index cffa9f9d..46decebf 100644 --- a/sources_non_forked/ale/autoload/ale/fixers/standard.vim +++ b/sources_non_forked/ale/autoload/ale/fixers/standard.vim @@ -27,7 +27,7 @@ function! ale#fixers#standard#Fix(buffer) abort return { \ 'command': ale#node#Executable(a:buffer, l:executable) \ . (!empty(l:options) ? ' ' . l:options : '') - \ . ' --fix %t', + \ . ' --fix --stdin < %s > %t', \ 'read_temporary_file': 1, \} endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/tslint.vim b/sources_non_forked/ale/autoload/ale/fixers/tslint.vim index b352af3a..15768fd5 100644 --- a/sources_non_forked/ale/autoload/ale/fixers/tslint.vim +++ b/sources_non_forked/ale/autoload/ale/fixers/tslint.vim @@ -16,7 +16,7 @@ function! ale#fixers#tslint#Fix(buffer) abort return { \ 'command': ale#node#Executable(a:buffer, l:executable) \ . l:tslint_config_option - \ . ' --fix %t', + \ . ' --outputAbsolutePaths --fix %t', \ 'read_temporary_file': 1, \} endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/yamlfix.vim b/sources_non_forked/ale/autoload/ale/fixers/yamlfix.vim new file mode 100644 index 00000000..966556c9 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/yamlfix.vim @@ -0,0 +1,25 @@ +" Author: lyz-code +" Description: Fixing yaml files with yamlfix. + +call ale#Set('yaml_yamlfix_executable', 'yamlfix') +call ale#Set('yaml_yamlfix_options', '') +call ale#Set('yaml_yamlfix_use_global', get(g:, 'ale_use_global_executables', 0)) + +function! ale#fixers#yamlfix#Fix(buffer) abort + let l:options = ale#Var(a:buffer, 'yaml_yamlfix_options') + + let l:executable = ale#python#FindExecutable( + \ a:buffer, + \ 'yaml_yamlfix', + \ ['yamlfix'], + \) + + if !executable(l:executable) + return 0 + endif + + return { + \ 'command': ale#path#BufferCdString(a:buffer) + \ . ale#Escape(l:executable) . (!empty(l:options) ? ' ' . l:options : '') . ' -', + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/handlers/ccls.vim b/sources_non_forked/ale/autoload/ale/handlers/ccls.vim index 1e2aa318..290f5852 100644 --- a/sources_non_forked/ale/autoload/ale/handlers/ccls.vim +++ b/sources_non_forked/ale/autoload/ale/handlers/ccls.vim @@ -17,3 +17,10 @@ function! ale#handlers#ccls#GetProjectRoot(buffer) abort " Fall back on default project root detection. return ale#c#FindProjectRoot(a:buffer) endfunction + +function! ale#handlers#ccls#GetInitOpts(buffer, init_options_var) abort + let l:build_dir = ale#c#GetBuildDirectory(a:buffer) + let l:init_options = empty(l:build_dir) ? {} : {'compilationDatabaseDirectory': l:build_dir} + + return extend(l:init_options, ale#Var(a:buffer, a:init_options_var)) +endfunction diff --git a/sources_non_forked/ale/autoload/ale/handlers/cppcheck.vim b/sources_non_forked/ale/autoload/ale/handlers/cppcheck.vim index 6d8fa15d..7f68ba67 100644 --- a/sources_non_forked/ale/autoload/ale/handlers/cppcheck.vim +++ b/sources_non_forked/ale/autoload/ale/handlers/cppcheck.vim @@ -44,16 +44,21 @@ endfunction function! ale#handlers#cppcheck#HandleCppCheckFormat(buffer, lines) abort " Look for lines like the following. " - " [test.cpp:5]: (error) Array 'a[10]' accessed at index 10, which is out of bounds - let l:pattern = '\v^\[(.+):(\d+)\]: \(([a-z]+)\) (.+)$' + "test.cpp:974:6: error: Array 'n[3]' accessed at index 3, which is out of bounds. [arrayIndexOutOfBounds]\ + " n[3]=3; + " ^ + let l:pattern = '\v^(\f+):(\d+):(\d+): (\w+): (.*) \[(\w+)\]\' let l:output = [] for l:match in ale#util#GetMatches(a:lines, l:pattern) if ale#path#IsBufferPath(a:buffer, l:match[1]) call add(l:output, { - \ 'lnum': str2nr(l:match[2]), - \ 'type': l:match[3] is# 'error' ? 'E' : 'W', - \ 'text': l:match[4], + \ 'lnum': str2nr(l:match[2]), + \ 'col': str2nr(l:match[3]), + \ 'type': l:match[4] is# 'error' ? 'E' : 'W', + \ 'sub_type': l:match[4] is# 'style' ? 'style' : '', + \ 'text': l:match[5], + \ 'code': l:match[6] \}) endif endfor diff --git a/sources_non_forked/ale/autoload/ale/handlers/eslint.vim b/sources_non_forked/ale/autoload/ale/handlers/eslint.vim index 8d53bdb7..e3504e16 100644 --- a/sources_non_forked/ale/autoload/ale/handlers/eslint.vim +++ b/sources_non_forked/ale/autoload/ale/handlers/eslint.vim @@ -1,6 +1,12 @@ " Author: w0rp " Description: Functions for working with eslint, for checking or fixing files. +let s:executables = [ +\ 'node_modules/.bin/eslint_d', +\ 'node_modules/eslint/bin/eslint.js', +\ 'node_modules/.bin/eslint', +\ '.yarn/sdks/eslint/bin/eslint', +\] let s:sep = has('win32') ? '\' : '/' call ale#Set('javascript_eslint_options', '') @@ -30,11 +36,31 @@ function! ale#handlers#eslint#FindConfig(buffer) abort endfunction function! ale#handlers#eslint#GetExecutable(buffer) abort - return ale#node#FindExecutable(a:buffer, 'javascript_eslint', [ - \ 'node_modules/.bin/eslint_d', - \ 'node_modules/eslint/bin/eslint.js', - \ 'node_modules/.bin/eslint', - \]) + return ale#node#FindExecutable(a:buffer, 'javascript_eslint', s:executables) +endfunction + +" Given a buffer, return a command prefix string which changes directory +" as necessary for running ESLint. +function! ale#handlers#eslint#GetCdString(buffer) abort + " ESLint 6 loads plugins/configs/parsers from the project root + " By default, the project root is simply the CWD of the running process. + " https://github.com/eslint/rfcs/blob/master/designs/2018-simplified-package-loading/README.md + " https://github.com/dense-analysis/ale/issues/2787 + " + " If eslint is installed in a directory which contains the buffer, assume + " it is the ESLint project root. Otherwise, use nearest node_modules. + " Note: If node_modules not present yet, can't load local deps anyway. + let l:executable = ale#node#FindNearestExecutable(a:buffer, s:executables) + + if !empty(l:executable) + let l:nmi = strridx(l:executable, 'node_modules') + let l:project_dir = l:executable[0:l:nmi - 2] + else + let l:modules_dir = ale#path#FindNearestDirectory(a:buffer, 'node_modules') + let l:project_dir = !empty(l:modules_dir) ? fnamemodify(l:modules_dir, ':h:h') : '' + endif + + return !empty(l:project_dir) ? ale#path#CdString(l:project_dir) : '' endfunction function! ale#handlers#eslint#GetCommand(buffer) abort @@ -42,17 +68,7 @@ function! ale#handlers#eslint#GetCommand(buffer) abort let l:options = ale#Var(a:buffer, 'javascript_eslint_options') - " ESLint 6 loads plugins/configs/parsers from the project root - " By default, the project root is simply the CWD of the running process. - " https://github.com/eslint/rfcs/blob/master/designs/2018-simplified-package-loading/README.md - " https://github.com/dense-analysis/ale/issues/2787 - " Identify project root from presence of node_modules dir. - " Note: If node_modules not present yet, can't load local deps anyway. - let l:modules_dir = ale#path#FindNearestDirectory(a:buffer, 'node_modules') - let l:project_dir = !empty(l:modules_dir) ? fnamemodify(l:modules_dir, ':h:h') : '' - let l:cd_command = !empty(l:project_dir) ? ale#path#CdString(l:project_dir) : '' - - return l:cd_command + return ale#handlers#eslint#GetCdString(a:buffer) \ . ale#node#Executable(a:buffer, l:executable) \ . (!empty(l:options) ? ' ' . l:options : '') \ . ' -f json --stdin --stdin-filename %s' diff --git a/sources_non_forked/ale/autoload/ale/handlers/gcc.vim b/sources_non_forked/ale/autoload/ale/handlers/gcc.vim index ec16b977..0b37c98a 100644 --- a/sources_non_forked/ale/autoload/ale/handlers/gcc.vim +++ b/sources_non_forked/ale/autoload/ale/handlers/gcc.vim @@ -10,7 +10,7 @@ let s:pragma_error = '#pragma once in main file' " :8:5: warning: conversion lacks type at end of format [-Wformat=] " :10:27: error: invalid operands to binary - (have ‘int’ and ‘char *’) " -:189:7: note: $/${} is unnecessary on arithmetic variables. [SC2004] -let s:pattern = '\v^([a-zA-Z]?:?[^:]+):(\d+):(\d+)?:? ([^:]+): (.+)$' +let s:pattern = '\v^([a-zA-Z]?:?[^:]+):(\d+)?:?(\d+)?:? ([^:]+): (.+)$' let s:inline_pattern = '\v inlined from .* at \:(\d+):(\d+):$' function! s:IsHeaderFile(filename) abort @@ -117,6 +117,23 @@ function! ale#handlers#gcc#HandleGCCFormat(buffer, lines) abort if !empty(l:output) if !has_key(l:output[-1], 'detail') let l:output[-1].detail = l:output[-1].text + + " handle macro expansion errors/notes + if l:match[5] =~? '^in expansion of macro ‘\w*\w’$' + " if the macro expansion is in the file we're in, add + " the lnum and col keys to the previous error + if l:match[1] is# '' + \ && !has_key(l:output[-1], 'col') + let l:output[-1].lnum = str2nr(l:match[2]) + let l:output[-1].col = str2nr(l:match[3]) + else + " the error is not in the current file, and since + " macro expansion errors don't show the full path to + " the error from the current file, we have to just + " give out a generic error message + let l:output[-1].text = 'Error found in macro expansion. See :ALEDetail' + endif + endif endif let l:output[-1].detail = l:output[-1].detail . "\n" diff --git a/sources_non_forked/ale/autoload/ale/handlers/go.vim b/sources_non_forked/ale/autoload/ale/handlers/go.vim index f17cd862..c969669d 100644 --- a/sources_non_forked/ale/autoload/ale/handlers/go.vim +++ b/sources_non_forked/ale/autoload/ale/handlers/go.vim @@ -6,9 +6,12 @@ " " Author: Ben Paxton " Description: moved to generic Golang file from govet +" +" Author: mostfunkyduck +" Description: updated to work with go 1.14 function! ale#handlers#go#Handler(buffer, lines) abort - let l:pattern = '\v^([a-zA-Z]?:?[^:]+):(\d+):?(\d+)?:? ?(.+)$' + let l:pattern = '\v^%(vet: )?([a-zA-Z]?:?[^:]+):(\d+):?(\d+)?:? ?(.+)$' let l:output = [] let l:dir = expand('#' . a:buffer . ':p:h') diff --git a/sources_non_forked/ale/autoload/ale/handlers/hdl_checker.vim b/sources_non_forked/ale/autoload/ale/handlers/hdl_checker.vim new file mode 100644 index 00000000..36dbd259 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/handlers/hdl_checker.vim @@ -0,0 +1,71 @@ +" Author: suoto +" Description: Adds support for HDL Code Checker, which wraps vcom/vlog, ghdl +" or xvhdl. More info on https://github.com/suoto/hdl_checker + +call ale#Set('hdl_checker_executable', 'hdl_checker') +call ale#Set('hdl_checker_config_file', has('unix') ? '.hdl_checker.config' : '_hdl_checker.config') +call ale#Set('hdl_checker_options', '') + +" Use this as a function so we can mock it on testing. Need to do this because +" test files are inside /testplugin (which refers to the ale repo), which will +" always have a .git folder +function! ale#handlers#hdl_checker#IsDotGit(path) abort + return ! empty(a:path) && isdirectory(a:path) +endfunction + +" Sould return (in order of preference) +" 1. Nearest config file +" 2. Nearest .git directory +" 3. The current path +function! ale#handlers#hdl_checker#GetProjectRoot(buffer) abort + let l:project_root = ale#path#FindNearestFile( + \ a:buffer, + \ ale#Var(a:buffer, 'hdl_checker_config_file')) + + if !empty(l:project_root) + return fnamemodify(l:project_root, ':h') + endif + + " Search for .git to use as root + let l:project_root = ale#path#FindNearestDirectory(a:buffer, '.git') + + if ale#handlers#hdl_checker#IsDotGit(l:project_root) + return fnamemodify(l:project_root, ':h:h') + endif +endfunction + +function! ale#handlers#hdl_checker#GetExecutable(buffer) abort + return ale#Var(a:buffer, 'hdl_checker_executable') +endfunction + +function! ale#handlers#hdl_checker#GetCommand(buffer) abort + let l:command = ale#Escape(ale#handlers#hdl_checker#GetExecutable(a:buffer)) . ' --lsp' + + " Add extra parameters only if config has been set + let l:options = ale#Var(a:buffer, 'hdl_checker_options') + + if ! empty(l:options) + let l:command = l:command . ' ' . l:options + endif + + return l:command +endfunction + +" To allow testing +function! ale#handlers#hdl_checker#GetInitOptions(buffer) abort + return {'project_file': ale#Var(a:buffer, 'hdl_checker_config_file')} +endfunction + +" Define the hdl_checker linter for a given filetype. +function! ale#handlers#hdl_checker#DefineLinter(filetype) abort + call ale#linter#Define(a:filetype, { + \ 'name': 'hdl-checker', + \ 'lsp': 'stdio', + \ 'language': a:filetype, + \ 'executable': function('ale#handlers#hdl_checker#GetExecutable'), + \ 'command': function('ale#handlers#hdl_checker#GetCommand'), + \ 'project_root': function('ale#handlers#hdl_checker#GetProjectRoot'), + \ 'initialization_options': function('ale#handlers#hdl_checker#GetInitOptions'), + \ }) +endfunction + diff --git a/sources_non_forked/ale/autoload/ale/handlers/ktlint.vim b/sources_non_forked/ale/autoload/ale/handlers/ktlint.vim index ad999485..77e7ab66 100644 --- a/sources_non_forked/ale/autoload/ale/handlers/ktlint.vim +++ b/sources_non_forked/ale/autoload/ale/handlers/ktlint.vim @@ -13,7 +13,7 @@ function! ale#handlers#ktlint#GetCommand(buffer) abort return ale#Escape(l:executable) \ . (empty(l:options) ? '' : ' ' . l:options) \ . (empty(l:rulesets) ? '' : ' ' . l:rulesets) - \ . ' %t' + \ . ' --stdin' endfunction function! ale#handlers#ktlint#GetRulesets(buffer) abort diff --git a/sources_non_forked/ale/autoload/ale/handlers/markdownlint.vim b/sources_non_forked/ale/autoload/ale/handlers/markdownlint.vim index daaa1d66..6c273bd0 100644 --- a/sources_non_forked/ale/autoload/ale/handlers/markdownlint.vim +++ b/sources_non_forked/ale/autoload/ale/handlers/markdownlint.vim @@ -2,15 +2,22 @@ " Description: Adds support for markdownlint function! ale#handlers#markdownlint#Handle(buffer, lines) abort - let l:pattern=': \(\d*\): \(MD\d\{3}\)\(\/\)\([A-Za-z0-9-]\+\)\(.*\)$' + let l:pattern=': \?\(\d\+\)\(:\(\d\+\)\?\)\? \(MD\d\{3}/[A-Za-z0-9-/]\+\) \(.*\)$' let l:output=[] for l:match in ale#util#GetMatches(a:lines, l:pattern) - call add(l:output, { + let l:result = ({ \ 'lnum': l:match[1] + 0, - \ 'text': '(' . l:match[2] . l:match[3] . l:match[4] . ')' . l:match[5], + \ 'code': l:match[4], + \ 'text': l:match[5], \ 'type': 'W', \}) + + if len(l:match[3]) > 0 + let l:result.col = (l:match[3] + 0) + endif + + call add(l:output, l:result) endfor return l:output diff --git a/sources_non_forked/ale/autoload/ale/handlers/sh.vim b/sources_non_forked/ale/autoload/ale/handlers/sh.vim index 75eaf71f..6ed9fea3 100644 --- a/sources_non_forked/ale/autoload/ale/handlers/sh.vim +++ b/sources_non_forked/ale/autoload/ale/handlers/sh.vim @@ -1,20 +1,37 @@ " Author: w0rp -" Get the shell type for a buffer, based on the hashbang line. function! ale#handlers#sh#GetShellType(buffer) abort - let l:bang_line = get(getbufline(a:buffer, 1), 0, '') + let l:shebang = get(getbufline(a:buffer, 1), 0, '') - " Take the shell executable from the hashbang, if we can. - if l:bang_line[:1] is# '#!' + let l:command = '' + + " Take the shell executable from the shebang, if we can. + if l:shebang[:1] is# '#!' " Remove options like -e, etc. - let l:command = substitute(l:bang_line, ' --\?[a-zA-Z0-9]\+', '', 'g') - - for l:possible_shell in ['bash', 'dash', 'ash', 'tcsh', 'csh', 'zsh', 'ksh', 'sh'] - if l:command =~# l:possible_shell . '\s*$' - return l:possible_shell - endif - endfor + let l:command = substitute(l:shebang, ' --\?[a-zA-Z0-9]\+', '', 'g') endif + " With no shebang line, attempt to use Vim's buffer-local variables. + if l:command is# '' + if getbufvar(a:buffer, 'is_bash', 0) + let l:command = 'bash' + elseif getbufvar(a:buffer, 'is_sh', 0) + let l:command = 'sh' + elseif getbufvar(a:buffer, 'is_kornshell', 0) + let l:command = 'ksh' + endif + endif + + " If we couldn't find a shebang, try the filetype + if l:command is# '' + let l:command = &filetype + endif + + for l:possible_shell in ['bash', 'dash', 'ash', 'tcsh', 'csh', 'zsh', 'ksh', 'sh'] + if l:command =~# l:possible_shell . '\s*$' + return l:possible_shell + endif + endfor + return '' endfunction diff --git a/sources_non_forked/ale/autoload/ale/handlers/shellcheck.vim b/sources_non_forked/ale/autoload/ale/handlers/shellcheck.vim new file mode 100644 index 00000000..701c43b2 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/handlers/shellcheck.vim @@ -0,0 +1,122 @@ +" Author: w0rp +" Description: This file adds support for using the shellcheck linter + +" Shellcheck supports shell directives to define the shell dialect for scripts +" that do not have a shebang for some reason. +" https://github.com/koalaman/shellcheck/wiki/Directive#shell +function! ale#handlers#shellcheck#GetShellcheckDialectDirective(buffer) abort + let l:linenr = 0 + let l:pattern = '\s\{-}#\s\{-}shellcheck\s\{-}shell=\(.*\)' + let l:possible_shell = ['bash', 'dash', 'ash', 'tcsh', 'csh', 'zsh', 'ksh', 'sh'] + + while l:linenr < min([50, line('$')]) + let l:linenr += 1 + let l:match = matchlist(getline(l:linenr), l:pattern) + + if len(l:match) > 1 && index(l:possible_shell, l:match[1]) >= 0 + return l:match[1] + endif + endwhile + + return '' +endfunction + +function! ale#handlers#shellcheck#GetDialectArgument(buffer) abort + let l:shell_type = ale#handlers#shellcheck#GetShellcheckDialectDirective(a:buffer) + + if empty(l:shell_type) + let l:shell_type = ale#handlers#sh#GetShellType(a:buffer) + endif + + if !empty(l:shell_type) + " Use the dash dialect for /bin/ash, etc. + if l:shell_type is# 'ash' + return 'dash' + endif + + return l:shell_type + endif + + return '' +endfunction + +function! ale#handlers#shellcheck#GetCommand(buffer, version) abort + let l:options = ale#Var(a:buffer, 'sh_shellcheck_options') + let l:exclude_option = ale#Var(a:buffer, 'sh_shellcheck_exclusions') + let l:dialect = ale#Var(a:buffer, 'sh_shellcheck_dialect') + let l:external_option = ale#semver#GTE(a:version, [0, 4, 0]) ? ' -x' : '' + let l:cd_string = ale#Var(a:buffer, 'sh_shellcheck_change_directory') + \ ? ale#path#BufferCdString(a:buffer) + \ : '' + + if l:dialect is# 'auto' + let l:dialect = ale#handlers#shellcheck#GetDialectArgument(a:buffer) + endif + + return l:cd_string + \ . '%e' + \ . (!empty(l:dialect) ? ' -s ' . l:dialect : '') + \ . (!empty(l:options) ? ' ' . l:options : '') + \ . (!empty(l:exclude_option) ? ' -e ' . l:exclude_option : '') + \ . l:external_option + \ . ' -f gcc -' +endfunction + +function! ale#handlers#shellcheck#Handle(buffer, lines) abort + let l:pattern = '\v^([a-zA-Z]?:?[^:]+):(\d+):(\d+)?:? ([^:]+): (.+) \[([^\]]+)\]$' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + if l:match[4] is# 'error' + let l:type = 'E' + elseif l:match[4] is# 'note' + let l:type = 'I' + else + let l:type = 'W' + endif + + let l:item = { + \ 'lnum': str2nr(l:match[2]), + \ 'type': l:type, + \ 'text': l:match[5], + \ 'code': l:match[6], + \} + + if !empty(l:match[3]) + let l:item.col = str2nr(l:match[3]) + endif + + " If the filename is something like , or -, then + " this is an error for the file we checked. + if l:match[1] isnot# '-' && l:match[1][0] isnot# '<' + let l:item['filename'] = l:match[1] + endif + + call add(l:output, l:item) + endfor + + return l:output +endfunction + +function! ale#handlers#shellcheck#DefineLinter(filetype) abort + " This global variable can be set with a string of comma-separated error + " codes to exclude from shellcheck. For example: + " let g:ale_sh_shellcheck_exclusions = 'SC2002,SC2004' + call ale#Set('sh_shellcheck_exclusions', get(g:, 'ale_linters_sh_shellcheck_exclusions', '')) + call ale#Set('sh_shellcheck_executable', 'shellcheck') + call ale#Set('sh_shellcheck_dialect', 'auto') + call ale#Set('sh_shellcheck_options', '') + call ale#Set('sh_shellcheck_change_directory', 1) + + call ale#linter#Define(a:filetype, { + \ 'name': 'shellcheck', + \ 'executable': {buffer -> ale#Var(buffer, 'sh_shellcheck_executable')}, + \ 'command': {buffer -> ale#semver#RunWithVersionCheck( + \ buffer, + \ ale#Var(buffer, 'sh_shellcheck_executable'), + \ '%e --version', + \ function('ale#handlers#shellcheck#GetCommand'), + \ )}, + \ 'callback': 'ale#handlers#shellcheck#Handle', + \}) +endfunction diff --git a/sources_non_forked/ale/autoload/ale/highlight.vim b/sources_non_forked/ale/autoload/ale/highlight.vim index 82ad57e0..473ad354 100644 --- a/sources_non_forked/ale/autoload/ale/highlight.vim +++ b/sources_non_forked/ale/autoload/ale/highlight.vim @@ -210,6 +210,12 @@ function! ale#highlight#SetHighlights(buffer, loclist) abort " Set the list in the buffer variable. call setbufvar(str2nr(a:buffer), 'ale_highlight_items', l:new_list) + let l:exclude_list = ale#Var(a:buffer, 'exclude_highlights') + + if !empty(l:exclude_list) + call filter(l:new_list, 'empty(ale#util#GetMatches(v:val.text, l:exclude_list))') + endif + " Update highlights for the current buffer, which may or may not " be the buffer we just set highlights for. call ale#highlight#UpdateHighlights() diff --git a/sources_non_forked/ale/autoload/ale/hover.vim b/sources_non_forked/ale/autoload/ale/hover.vim index 8fdd288c..1d38f3b9 100644 --- a/sources_non_forked/ale/autoload/ale/hover.vim +++ b/sources_non_forked/ale/autoload/ale/hover.vim @@ -24,6 +24,8 @@ function! ale#hover#HandleTSServerResponse(conn_id, response) abort if get(a:response, 'success', v:false) is v:true \&& get(a:response, 'body', v:null) isnot v:null + let l:set_balloons = ale#Var(l:options.buffer, 'set_balloons') + " If we pass the show_documentation flag, we should show the full " documentation, and always in the preview window. if get(l:options, 'show_documentation', 0) @@ -40,8 +42,10 @@ function! ale#hover#HandleTSServerResponse(conn_id, response) abort endif elseif get(l:options, 'hover_from_balloonexpr', 0) \&& exists('*balloon_show') - \&& ale#Var(l:options.buffer, 'set_balloons') + \&& (l:set_balloons is 1 || l:set_balloons is# 'hover') call balloon_show(a:response.body.displayString) + elseif get(l:options, 'truncated_echo', 0) + call ale#cursor#TruncatedEcho(split(a:response.body.displayString, "\n")[0]) elseif g:ale_hover_to_preview call ale#preview#Show(split(a:response.body.displayString, "\n"), { \ 'filetype': 'ale-preview.message', @@ -54,6 +58,137 @@ function! ale#hover#HandleTSServerResponse(conn_id, response) abort endif endfunction +" Convert a language name to another one. +" The language name could be an empty string or v:null +function! s:ConvertLanguageName(language) abort + return a:language +endfunction + +function! ale#hover#ParseLSPResult(contents) abort + let l:includes = {} + let l:highlights = [] + let l:lines = [] + let l:list = type(a:contents) is v:t_list ? a:contents : [a:contents] + let l:region_index = 0 + + for l:item in l:list + if !empty(l:lines) + call add(l:lines, '') + endif + + if type(l:item) is v:t_dict && has_key(l:item, 'kind') + if l:item.kind is# 'markdown' + " Handle markdown values as we handle strings below. + let l:item = get(l:item, 'value', '') + elseif l:item.kind is# 'plaintext' + " We shouldn't try to parse plaintext as markdown. + " Pass the lines on and skip parsing them. + call extend(l:lines, split(get(l:item, 'value', ''), "\n")) + + continue + endif + endif + + let l:marked_list = [] + + " If the item is a string, then we should parse it as Markdown text. + if type(l:item) is v:t_string + let l:fence_language = v:null + let l:fence_lines = [] + + for l:line in split(l:item, "\n") + if l:fence_language is v:null + " Look for the start of a code fence. (```python, etc.) + let l:match = matchlist(l:line, '^```\(.*\)$') + + if !empty(l:match) + let l:fence_language = l:match[1] + + if !empty(l:marked_list) + call add(l:fence_lines, '') + endif + else + if !empty(l:marked_list) + \&& l:marked_list[-1][0] isnot v:null + call add(l:marked_list, [v:null, ['']]) + endif + + call add(l:marked_list, [v:null, [l:line]]) + endif + elseif l:line =~# '^```$' + " When we hit the end of a code fence, pass the fenced + " lines on to the next steps below. + call add(l:marked_list, [l:fence_language, l:fence_lines]) + let l:fence_language = v:null + let l:fence_lines = [] + else + " Gather lines inside of a code fence. + call add(l:fence_lines, l:line) + endif + endfor + " If the result from the LSP server is a {language: ..., value: ...} + " Dictionary, then that should be interpreted as if it was: + " + " ```${language} + " ${value} + " ``` + elseif type(l:item) is v:t_dict + \&& has_key(l:item, 'language') + \&& type(l:item.language) is v:t_string + \&& has_key(l:item, 'value') + \&& type(l:item.value) is v:t_string + call add( + \ l:marked_list, + \ [l:item.language, split(l:item.value, "\n")], + \) + endif + + for [l:language, l:marked_lines] in l:marked_list + if l:language is v:null + " NOTE: We could handle other Markdown formatting here. + call map( + \ l:marked_lines, + \ 'substitute(v:val, ''\\_'', ''_'', ''g'')', + \) + else + let l:language = s:ConvertLanguageName(l:language) + + if !empty(l:language) + let l:includes[l:language] = printf( + \ 'syntax/%s.vim', + \ l:language, + \) + + let l:start = len(l:lines) + 1 + let l:end = l:start + len(l:marked_lines) + let l:region_index += 1 + + call add(l:highlights, 'syntax region' + \ . ' ALE_hover_' . l:region_index + \ . ' start=/\%' . l:start . 'l/' + \ . ' end=/\%' . l:end . 'l/' + \ . ' contains=@ALE_hover_' . l:language + \) + endif + endif + + call extend(l:lines, l:marked_lines) + endfor + endfor + + let l:include_commands = [] + + for [l:language, l:lang_path] in sort(items(l:includes)) + call add(l:include_commands, 'unlet! b:current_syntax') + call add( + \ l:include_commands, + \ printf('syntax include @ALE_hover_%s %s', l:language, l:lang_path), + \) + endfor + + return [l:include_commands + l:highlights, l:lines] +endfunction + function! ale#hover#HandleLSPResponse(conn_id, response) abort if has_key(a:response, 'id') \&& has_key(s:hover_map, a:response.id) @@ -80,37 +215,27 @@ function! ale#hover#HandleLSPResponse(conn_id, response) abort return endif - let l:result = l:result.contents + let [l:commands, l:lines] = ale#hover#ParseLSPResult(l:result.contents) - if type(l:result) is v:t_string - " The result can be just a string. - let l:result = [l:result] - endif + if !empty(l:lines) + let l:set_balloons = ale#Var(l:options.buffer, 'set_balloons') - if type(l:result) is v:t_dict - " If the result is an object, then it's markup content. - let l:result = [l:result.value] - endif - - if type(l:result) is v:t_list - " Replace objects with text values. - call map(l:result, 'type(v:val) is v:t_string ? v:val : v:val.value') - let l:str = join(l:result, "\n") - let l:str = substitute(l:str, '^\s*\(.\{-}\)\s*$', '\1', '') - - if !empty(l:str) - if get(l:options, 'hover_from_balloonexpr', 0) - \&& exists('*balloon_show') - \&& ale#Var(l:options.buffer, 'set_balloons') - call balloon_show(l:str) - elseif g:ale_hover_to_preview - call ale#preview#Show(split(l:str, "\n"), { - \ 'filetype': 'ale-preview.message', - \ 'stay_here': 1, - \}) - else - call ale#util#ShowMessage(l:str) - endif + if get(l:options, 'hover_from_balloonexpr', 0) + \&& exists('*balloon_show') + \&& (l:set_balloons is 1 || l:set_balloons is# 'hover') + call balloon_show(join(l:lines, "\n")) + elseif get(l:options, 'truncated_echo', 0) + call ale#cursor#TruncatedEcho(l:lines[0]) + elseif g:ale_hover_to_preview + call ale#preview#Show(l:lines, { + \ 'filetype': 'ale-preview.message', + \ 'stay_here': 1, + \ 'commands': l:commands, + \}) + else + call ale#util#ShowMessage(join(l:lines, "\n"), { + \ 'commands': l:commands, + \}) endif endif endif @@ -143,7 +268,10 @@ function! s:OnReady(line, column, opt, linter, lsp_details) abort " hover position probably won't make sense. call ale#lsp#NotifyForChanges(l:id, l:buffer) - let l:column = min([a:column, len(getbufline(l:buffer, a:line)[0])]) + let l:column = max([ + \ min([a:column, len(getbufline(l:buffer, a:line)[0])]), + \ 1, + \]) let l:message = ale#lsp#message#Hover(l:buffer, a:line, l:column) endif @@ -156,6 +284,7 @@ function! s:OnReady(line, column, opt, linter, lsp_details) abort \ 'column': l:column, \ 'hover_from_balloonexpr': get(a:opt, 'called_from_balloonexpr', 0), \ 'show_documentation': get(a:opt, 'show_documentation', 0), + \ 'truncated_echo': get(a:opt, 'truncated_echo', 0), \} endfunction @@ -181,6 +310,8 @@ function! ale#hover#Show(buffer, line, col, opt) abort endfor endfunction +let s:last_pos = [0, 0, 0] + " This function implements the :ALEHover command. function! ale#hover#ShowAtCursor() abort let l:buffer = bufnr('') @@ -189,6 +320,25 @@ function! ale#hover#ShowAtCursor() abort call ale#hover#Show(l:buffer, l:pos[1], l:pos[2], {}) endfunction +function! ale#hover#ShowTruncatedMessageAtCursor() abort + let l:buffer = bufnr('') + let l:pos = getpos('.')[0:2] + + if l:pos != s:last_pos + let s:last_pos = l:pos + let [l:info, l:loc] = ale#util#FindItemAtCursor(l:buffer) + + if empty(l:loc) + call ale#hover#Show( + \ l:buffer, + \ l:pos[1], + \ l:pos[2], + \ {'truncated_echo': 1}, + \) + endif + endif +endfunction + " This function implements the :ALEDocumentation command. function! ale#hover#ShowDocumentationAtCursor() abort let l:buffer = bufnr('') diff --git a/sources_non_forked/ale/autoload/ale/linter.vim b/sources_non_forked/ale/autoload/ale/linter.vim index 52cf1c0e..0a800546 100644 --- a/sources_non_forked/ale/autoload/ale/linter.vim +++ b/sources_non_forked/ale/autoload/ale/linter.vim @@ -14,6 +14,7 @@ let s:default_ale_linter_aliases = { \ 'csh': 'sh', \ 'javascriptreact': ['javascript', 'jsx'], \ 'plaintex': 'tex', +\ 'ps1': 'powershell', \ 'rmarkdown': 'r', <<<<<<< HEAD ======= @@ -34,7 +35,7 @@ let s:default_ale_linter_aliases = { " " No linters are used for plaintext files by default. " -" Only cargo is enabled for Rust by default. +" Only cargo and rls are enabled for Rust by default. " rpmlint is disabled by default because it can result in code execution. " hhast is disabled by default because it executes code in the project root. " @@ -47,8 +48,8 @@ let s:default_ale_linters = { \ 'help': [], \ 'perl': ['perlcritic'], \ 'perl6': [], -\ 'python': ['flake8', 'mypy', 'pylint'], -\ 'rust': ['cargo'], +\ 'python': ['flake8', 'mypy', 'pylint', 'pyright'], +\ 'rust': ['cargo', 'rls'], \ 'spec': [], \ 'text': [], \ 'vue': ['eslint', 'vls'], @@ -79,10 +80,6 @@ function! s:IsBoolean(value) abort return type(a:value) is v:t_number && (a:value == 0 || a:value == 1) endfunction -function! s:LanguageGetter(buffer) dict abort - return l:self.language -endfunction - function! ale#linter#PreProcess(filetype, linter) abort if type(a:linter) isnot v:t_dict throw 'The linter object must be a Dictionary' @@ -116,14 +113,7 @@ function! ale#linter#PreProcess(filetype, linter) abort if !l:needs_executable if has_key(a:linter, 'executable') - \|| has_key(a:linter, 'executable_callback') - throw '`executable` and `executable_callback` cannot be used when lsp == ''socket''' - endif - elseif has_key(a:linter, 'executable_callback') - let l:obj.executable_callback = a:linter.executable_callback - - if !s:IsCallback(l:obj.executable_callback) - throw '`executable_callback` must be a callback if defined' + throw '`executable` cannot be used when lsp == ''socket''' endif elseif has_key(a:linter, 'executable') let l:obj.executable = a:linter.executable @@ -133,54 +123,12 @@ function! ale#linter#PreProcess(filetype, linter) abort throw '`executable` must be a String or Function if defined' endif else - throw 'Either `executable` or `executable_callback` must be defined' + throw '`executable` must be defined' endif if !l:needs_command if has_key(a:linter, 'command') - \|| has_key(a:linter, 'command_callback') - \|| has_key(a:linter, 'command_chain') - throw '`command` and `command_callback` and `command_chain` cannot be used when lsp == ''socket''' - endif - elseif has_key(a:linter, 'command_chain') - let l:obj.command_chain = a:linter.command_chain - - if type(l:obj.command_chain) isnot v:t_list - throw '`command_chain` must be a List' - endif - - if empty(l:obj.command_chain) - throw '`command_chain` must contain at least one item' - endif - - let l:link_index = 0 - - for l:link in l:obj.command_chain - let l:err_prefix = 'The `command_chain` item ' . l:link_index . ' ' - - if !s:IsCallback(get(l:link, 'callback')) - throw l:err_prefix . 'must define a `callback` function' - endif - - if has_key(l:link, 'output_stream') - if type(l:link.output_stream) isnot v:t_string - \|| index(['stdout', 'stderr', 'both'], l:link.output_stream) < 0 - throw l:err_prefix . '`output_stream` flag must be ' - \ . "'stdout', 'stderr', or 'both'" - endif - endif - - if has_key(l:link, 'read_buffer') && !s:IsBoolean(l:link.read_buffer) - throw l:err_prefix . 'value for `read_buffer` must be `0` or `1`' - endif - - let l:link_index += 1 - endfor - elseif has_key(a:linter, 'command_callback') - let l:obj.command_callback = a:linter.command_callback - - if !s:IsCallback(l:obj.command_callback) - throw '`command_callback` must be a callback if defined' + throw '`command` cannot be used when lsp == ''socket''' endif elseif has_key(a:linter, 'command') let l:obj.command = a:linter.command @@ -190,22 +138,12 @@ function! ale#linter#PreProcess(filetype, linter) abort throw '`command` must be a String or Function if defined' endif else - throw 'Either `command`, `executable_callback`, `command_chain` ' - \ . 'must be defined' - endif - - if ( - \ has_key(a:linter, 'command') - \ + has_key(a:linter, 'command_chain') - \ + has_key(a:linter, 'command_callback') - \) > 1 - throw 'Only one of `command`, `command_callback`, or `command_chain` ' - \ . 'should be set' + throw '`command` must be defined' endif if !l:needs_address - if has_key(a:linter, 'address') || has_key(a:linter, 'address_callback') - throw '`address` or `address_callback` cannot be used when lsp != ''socket''' + if has_key(a:linter, 'address') + throw '`address` cannot be used when lsp != ''socket''' endif elseif has_key(a:linter, 'address') if type(a:linter.address) isnot v:t_string @@ -214,41 +152,17 @@ function! ale#linter#PreProcess(filetype, linter) abort endif let l:obj.address = a:linter.address - elseif has_key(a:linter, 'address_callback') - let l:obj.address_callback = a:linter.address_callback - - if !s:IsCallback(l:obj.address_callback) - throw '`address_callback` must be a callback if defined' - endif else - throw '`address` or `address_callback` must be defined for getting the LSP address' + throw '`address` must be defined for getting the LSP address' endif if l:needs_lsp_details - if has_key(a:linter, 'language_callback') - if has_key(a:linter, 'language') - throw 'Only one of `language` or `language_callback` ' - \ . 'should be set' - endif + " Default to using the filetype as the language. + let l:obj.language = get(a:linter, 'language', a:filetype) - let l:obj.language_callback = get(a:linter, 'language_callback') - - if !s:IsCallback(l:obj.language_callback) - throw '`language_callback` must be a callback for LSP linters' - endif - else - " Default to using the filetype as the language. - let l:Language = get(a:linter, 'language', a:filetype) - - if type(l:Language) is v:t_string - " Make 'language_callback' return the 'language' value. - let l:obj.language = l:Language - let l:obj.language_callback = function('s:LanguageGetter') - elseif type(l:Language) is v:t_func - let l:obj.language_callback = l:Language - else - throw '`language` must be a String or Funcref' - endif + if type(l:obj.language) isnot v:t_string + \&& type(l:obj.language) isnot v:t_func + throw '`language` must be a String or Funcref if defined' endif if has_key(a:linter, 'project_root') @@ -256,16 +170,10 @@ function! ale#linter#PreProcess(filetype, linter) abort if type(l:obj.project_root) isnot v:t_string \&& type(l:obj.project_root) isnot v:t_func - throw '`project_root` must be a String or Function if defined' - endif - elseif has_key(a:linter, 'project_root_callback') - let l:obj.project_root_callback = a:linter.project_root_callback - - if !s:IsCallback(l:obj.project_root_callback) - throw '`project_root_callback` must be a callback if defined' + throw '`project_root` must be a String or Function' endif else - throw '`project_root` or `project_root_callback` must be defined for LSP linters' + throw '`project_root` must be defined for LSP linters' endif if has_key(a:linter, 'completion_filter') @@ -276,37 +184,16 @@ function! ale#linter#PreProcess(filetype, linter) abort endif endif - if has_key(a:linter, 'initialization_options_callback') - if has_key(a:linter, 'initialization_options') - throw 'Only one of `initialization_options` or ' - \ . '`initialization_options_callback` should be set' - endif - - let l:obj.initialization_options_callback = a:linter.initialization_options_callback - - if !s:IsCallback(l:obj.initialization_options_callback) - throw '`initialization_options_callback` must be a callback if defined' - endif - elseif has_key(a:linter, 'initialization_options') + if has_key(a:linter, 'initialization_options') let l:obj.initialization_options = a:linter.initialization_options if type(l:obj.initialization_options) isnot v:t_dict \&& type(l:obj.initialization_options) isnot v:t_func - throw '`initialization_options` must be a String or Function if defined' + throw '`initialization_options` must be a Dictionary or Function if defined' endif endif - if has_key(a:linter, 'lsp_config_callback') - if has_key(a:linter, 'lsp_config') - throw 'Only one of `lsp_config` or `lsp_config_callback` should be set' - endif - - let l:obj.lsp_config_callback = a:linter.lsp_config_callback - - if !s:IsCallback(l:obj.lsp_config_callback) - throw '`lsp_config_callback` must be a callback if defined' - endif - elseif has_key(a:linter, 'lsp_config') + if has_key(a:linter, 'lsp_config') if type(a:linter.lsp_config) isnot v:t_dict \&& type(a:linter.lsp_config) isnot v:t_func throw '`lsp_config` must be a Dictionary or Function if defined' @@ -327,21 +214,17 @@ function! ale#linter#PreProcess(filetype, linter) abort " file on disk. let l:obj.lint_file = get(a:linter, 'lint_file', 0) - if !s:IsBoolean(l:obj.lint_file) - throw '`lint_file` must be `0` or `1`' + if !s:IsBoolean(l:obj.lint_file) && type(l:obj.lint_file) isnot v:t_func + throw '`lint_file` must be `0`, `1`, or a Function' endif " An option indicating that the buffer should be read. - let l:obj.read_buffer = get(a:linter, 'read_buffer', !l:obj.lint_file) + let l:obj.read_buffer = get(a:linter, 'read_buffer', 1) if !s:IsBoolean(l:obj.read_buffer) throw '`read_buffer` must be `0` or `1`' endif - if l:obj.lint_file && l:obj.read_buffer - throw 'Only one of `lint_file` or `read_buffer` can be `1`' - endif - let l:obj.aliases = get(a:linter, 'aliases', []) if type(l:obj.aliases) isnot v:t_list @@ -349,14 +232,6 @@ function! ale#linter#PreProcess(filetype, linter) abort throw '`aliases` must be a List of String values' endif - for l:key in filter(keys(a:linter), 'v:val[-9:] is# ''_callback'' || v:val is# ''command_chain''') - if !get(g:, 'ale_ignore_2_4_warnings') - execute 'echom l:key . '' is deprecated. Use `let g:ale_ignore_2_4_warnings = 1` to disable this message.''' - endif - - break - endfor - return l:obj endfunction @@ -522,11 +397,19 @@ function! ale#linter#Get(original_filetypes) abort return reverse(l:combined_linters) endfunction +function! ale#linter#RemoveIgnored(buffer, filetype, linters) abort + " Apply ignore lists for linters only if needed. + let l:ignore_config = ale#Var(a:buffer, 'linters_ignore') + let l:disable_lsp = ale#Var(a:buffer, 'disable_lsp') + + return !empty(l:ignore_config) || l:disable_lsp + \ ? ale#engine#ignore#Exclude(a:filetype, a:linters, l:ignore_config, l:disable_lsp) + \ : a:linters +endfunction + " Given a buffer and linter, get the executable String for the linter. function! ale#linter#GetExecutable(buffer, linter) abort - let l:Executable = has_key(a:linter, 'executable_callback') - \ ? function(a:linter.executable_callback) - \ : a:linter.executable + let l:Executable = a:linter.executable return type(l:Executable) is v:t_func \ ? l:Executable(a:buffer) @@ -534,24 +417,21 @@ function! ale#linter#GetExecutable(buffer, linter) abort endfunction " Given a buffer and linter, get the command String for the linter. -" The command_chain key is not supported. function! ale#linter#GetCommand(buffer, linter) abort - let l:Command = has_key(a:linter, 'command_callback') - \ ? function(a:linter.command_callback) - \ : a:linter.command + let l:Command = a:linter.command - return type(l:Command) is v:t_func - \ ? l:Command(a:buffer) - \ : l:Command + return type(l:Command) is v:t_func ? l:Command(a:buffer) : l:Command endfunction " Given a buffer and linter, get the address for connecting to the server. function! ale#linter#GetAddress(buffer, linter) abort - let l:Address = has_key(a:linter, 'address_callback') - \ ? function(a:linter.address_callback) - \ : a:linter.address + let l:Address = a:linter.address - return type(l:Address) is v:t_func - \ ? l:Address(a:buffer) - \ : l:Address + return type(l:Address) is v:t_func ? l:Address(a:buffer) : l:Address +endfunction + +function! ale#linter#GetLanguage(buffer, linter) abort + let l:Language = a:linter.language + + return type(l:Language) is v:t_func ? l:Language(a:buffer) : l:Language endfunction diff --git a/sources_non_forked/ale/autoload/ale/lsp.vim b/sources_non_forked/ale/autoload/ale/lsp.vim index 2509174e..cb0573aa 100644 --- a/sources_non_forked/ale/autoload/ale/lsp.vim +++ b/sources_non_forked/ale/autoload/ale/lsp.vim @@ -44,6 +44,7 @@ function! ale#lsp#Register(executable_or_address, project, init_options) abort \ 'definition': 0, \ 'typeDefinition': 0, \ 'symbol_search': 0, + \ 'code_actions': 0, \ }, \} endif @@ -64,6 +65,9 @@ endfunction " Used only in tests. function! ale#lsp#GetConnections() abort + " This command will throw from the sandbox. + let &l:equalprg=&l:equalprg + return s:connections endfunction @@ -196,14 +200,34 @@ function! s:UpdateCapabilities(conn, capabilities) abort let a:conn.capabilities.hover = 1 endif + if type(get(a:capabilities, 'hoverProvider')) is v:t_dict + let a:conn.capabilities.hover = 1 + endif + if get(a:capabilities, 'referencesProvider') is v:true let a:conn.capabilities.references = 1 endif + if type(get(a:capabilities, 'referencesProvider')) is v:t_dict + let a:conn.capabilities.references = 1 + endif + if get(a:capabilities, 'renameProvider') is v:true let a:conn.capabilities.rename = 1 endif + if type(get(a:capabilities, 'renameProvider')) is v:t_dict + let a:conn.capabilities.rename = 1 + endif + + if get(a:capabilities, 'codeActionProvider') is v:true + let a:conn.capabilities.code_actions = 1 + endif + + if type(get(a:capabilities, 'codeActionProvider')) is v:t_dict + let a:conn.capabilities.code_actions = 1 + endif + if !empty(get(a:capabilities, 'completionProvider')) let a:conn.capabilities.completion = 1 endif @@ -220,13 +244,25 @@ function! s:UpdateCapabilities(conn, capabilities) abort let a:conn.capabilities.definition = 1 endif + if type(get(a:capabilities, 'definitionProvider')) is v:t_dict + let a:conn.capabilities.definition = 1 + endif + if get(a:capabilities, 'typeDefinitionProvider') is v:true let a:conn.capabilities.typeDefinition = 1 endif + if type(get(a:capabilities, 'typeDefinitionProvider')) is v:t_dict + let a:conn.capabilities.typeDefinition = 1 + endif + if get(a:capabilities, 'workspaceSymbolProvider') is v:true let a:conn.capabilities.symbol_search = 1 endif + + if type(get(a:capabilities, 'workspaceSymbolProvider')) is v:t_dict + let a:conn.capabilities.symbol_search = 1 + endif endfunction " Update a connection's configuration dictionary and notify LSP servers @@ -323,6 +359,7 @@ function! ale#lsp#MarkConnectionAsTsserver(conn_id) abort let l:conn.capabilities.definition = 1 let l:conn.capabilities.symbol_search = 1 let l:conn.capabilities.rename = 1 + let l:conn.capabilities.code_actions = 1 endfunction function! s:SendInitMessage(conn) abort @@ -425,6 +462,7 @@ function! ale#lsp#StartProgram(conn_id, executable, command) abort endif if l:started && !l:conn.is_tsserver + let l:conn.initialized = 0 call s:SendInitMessage(l:conn) endif diff --git a/sources_non_forked/ale/autoload/ale/lsp/message.vim b/sources_non_forked/ale/autoload/ale/lsp/message.vim index 5b0cb8b7..38be4da6 100644 --- a/sources_non_forked/ale/autoload/ale/lsp/message.vim +++ b/sources_non_forked/ale/autoload/ale/lsp/message.vim @@ -172,3 +172,25 @@ function! ale#lsp#message#Rename(buffer, line, column, new_name) abort \ 'newName': a:new_name, \}] endfunction + +function! ale#lsp#message#CodeAction(buffer, line, column, end_line, end_column, diagnostics) abort + return [0, 'textDocument/codeAction', { + \ 'textDocument': { + \ 'uri': ale#path#ToURI(expand('#' . a:buffer . ':p')), + \ }, + \ 'range': { + \ 'start': {'line': a:line - 1, 'character': a:column - 1}, + \ 'end': {'line': a:end_line - 1, 'character': a:end_column}, + \ }, + \ 'context': { + \ 'diagnostics': a:diagnostics + \ }, + \}] +endfunction + +function! ale#lsp#message#ExecuteCommand(command, arguments) abort + return [0, 'workspace/executeCommand', { + \ 'command': a:command, + \ 'arguments': a:arguments, + \}] +endfunction diff --git a/sources_non_forked/ale/autoload/ale/lsp/response.vim b/sources_non_forked/ale/autoload/ale/lsp/response.vim index 30da77e1..a4f80980 100644 --- a/sources_non_forked/ale/autoload/ale/lsp/response.vim +++ b/sources_non_forked/ale/autoload/ale/lsp/response.vim @@ -56,6 +56,7 @@ function! ale#lsp#response#ReadDiagnostics(response) abort endif if has_key(l:diagnostic, 'relatedInformation') + \ && l:diagnostic.relatedInformation isnot v:null let l:related = deepcopy(l:diagnostic.relatedInformation) call map(l:related, {key, val -> \ ale#path#FromURI(val.location.uri) . diff --git a/sources_non_forked/ale/autoload/ale/lsp/tsserver_message.vim b/sources_non_forked/ale/autoload/ale/lsp/tsserver_message.vim index b9fafaa0..3c1b47ed 100644 --- a/sources_non_forked/ale/autoload/ale/lsp/tsserver_message.vim +++ b/sources_non_forked/ale/autoload/ale/lsp/tsserver_message.vim @@ -103,3 +103,39 @@ function! ale#lsp#tsserver_message#OrganizeImports(buffer) abort \ }, \}] endfunction + +function! ale#lsp#tsserver_message#GetCodeFixes(buffer, line, column, end_line, end_column, error_codes) abort + " The lines and columns are 1-based. + " The errors codes must be a list of tsserver error codes to fix. + return [0, 'ts@getCodeFixes', { + \ 'startLine': a:line, + \ 'startOffset': a:column, + \ 'endLine': a:end_line, + \ 'endOffset': a:end_column + 1, + \ 'file': expand('#' . a:buffer . ':p'), + \ 'errorCodes': a:error_codes, + \}] +endfunction + +function! ale#lsp#tsserver_message#GetApplicableRefactors(buffer, line, column, end_line, end_column) abort + " The arguments for this request can also be just 'line' and 'offset' + return [0, 'ts@getApplicableRefactors', { + \ 'startLine': a:line, + \ 'startOffset': a:column, + \ 'endLine': a:end_line, + \ 'endOffset': a:end_column + 1, + \ 'file': expand('#' . a:buffer . ':p'), + \}] +endfunction + +function! ale#lsp#tsserver_message#GetEditsForRefactor(buffer, line, column, end_line, end_column, refactor, action) abort + return [0, 'ts@getEditsForRefactor', { + \ 'startLine': a:line, + \ 'startOffset': a:column, + \ 'endLine': a:end_line, + \ 'endOffset': a:end_column + 1, + \ 'file': expand('#' . a:buffer . ':p'), + \ 'refactor': a:refactor, + \ 'action': a:action, + \}] +endfunction diff --git a/sources_non_forked/ale/autoload/ale/lsp_linter.vim b/sources_non_forked/ale/autoload/ale/lsp_linter.vim index e4148ceb..dcd76e8f 100644 --- a/sources_non_forked/ale/autoload/ale/lsp_linter.vim +++ b/sources_non_forked/ale/autoload/ale/lsp_linter.vim @@ -34,7 +34,11 @@ endfunction function! s:HandleLSPDiagnostics(conn_id, response) abort let l:linter_name = s:lsp_linter_map[a:conn_id] let l:filename = ale#path#FromURI(a:response.params.uri) - let l:buffer = bufnr('^' . l:filename . '$') + let l:escaped_name = escape( + \ fnameescape(l:filename), + \ has('win32') ? '^' : '^,}]' + \) + let l:buffer = bufnr('^' . l:escaped_name . '$') let l:info = get(g:ale_buffer_info, l:buffer, {}) if empty(l:info) @@ -52,7 +56,11 @@ endfunction function! s:HandleTSServerDiagnostics(response, error_type) abort let l:linter_name = 'tsserver' - let l:buffer = bufnr('^' . a:response.body.file . '$') + let l:escaped_name = escape( + \ fnameescape(a:response.body.file), + \ has('win32') ? '^' : '^,}]' + \) + let l:buffer = bufnr('^' . l:escaped_name . '$') let l:info = get(g:ale_buffer_info, l:buffer, {}) if empty(l:info) @@ -227,7 +235,7 @@ function! ale#lsp_linter#OnInit(linter, details, Callback) abort let l:command = a:details.command let l:config = ale#lsp_linter#GetConfig(l:buffer, a:linter) - let l:language_id = ale#util#GetFunction(a:linter.language_callback)(l:buffer) + let l:language_id = ale#linter#GetLanguage(l:buffer, a:linter) call ale#lsp#UpdateConfig(l:conn_id, l:buffer, l:config) @@ -265,7 +273,14 @@ function! s:StartLSP(options, address, executable, command) abort call ale#lsp#MarkConnectionAsTsserver(l:conn_id) endif - let l:command = ale#command#FormatCommand(l:buffer, a:executable, a:command, 0, v:false)[1] + let l:command = ale#command#FormatCommand( + \ l:buffer, + \ a:executable, + \ a:command, + \ 0, + \ v:false, + \ [], + \)[1] let l:command = ale#job#PrepareCommand(l:buffer, l:command) let l:ready = ale#lsp#StartProgram(l:conn_id, a:executable, l:command) endif diff --git a/sources_non_forked/ale/autoload/ale/maven.vim b/sources_non_forked/ale/autoload/ale/maven.vim new file mode 100644 index 00000000..745f8c93 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/maven.vim @@ -0,0 +1,51 @@ +" Description: Functions for working with Maven projects. +" +" Given a buffer number, find a Maven project root. +function! ale#maven#FindProjectRoot(buffer) abort + let l:wrapper_path = ale#path#FindNearestFile(a:buffer, 'mvnw') + + if !empty(l:wrapper_path) + return fnamemodify(l:wrapper_path, ':h') + endif + + let l:pom_path = ale#path#FindNearestFile(a:buffer, 'pom.xml') + + if !empty(l:pom_path) + return fnamemodify(l:pom_path, ':h') + endif + + return '' +endfunction + + +" Given a buffer number, find the path to the executable. +" First search on the path for 'mvnw' (mvnw.cmd on Windows), if nothing is found, +" try the global command. Returns an empty string if cannot find the executable. +function! ale#maven#FindExecutable(buffer) abort + let l:wrapper_cmd = has('unix') ? 'mvnw' : 'mvnw.cmd' + let l:wrapper_path = ale#path#FindNearestFile(a:buffer, l:wrapper_cmd) + + if executable(l:wrapper_path) + return l:wrapper_path + endif + + if executable('mvn') + return 'mvn' + endif + + return '' +endfunction + +" Given a buffer number, build a command to print the classpath of the root +" project. Returns an empty string if cannot build the command. +function! ale#maven#BuildClasspathCommand(buffer) abort + let l:executable = ale#maven#FindExecutable(a:buffer) + let l:project_root = ale#maven#FindProjectRoot(a:buffer) + + if !empty(l:executable) && !empty(l:project_root) + return ale#path#CdString(l:project_root) + \ . l:executable . ' dependency:build-classpath' + endif + + return '' +endfunction diff --git a/sources_non_forked/ale/autoload/ale/node.vim b/sources_non_forked/ale/autoload/ale/node.vim index 69060122..9b9b335a 100644 --- a/sources_non_forked/ale/autoload/ale/node.vim +++ b/sources_non_forked/ale/autoload/ale/node.vim @@ -12,6 +12,18 @@ function! ale#node#FindExecutable(buffer, base_var_name, path_list) abort return ale#Var(a:buffer, a:base_var_name . '_executable') endif + let l:nearest = ale#node#FindNearestExecutable(a:buffer, a:path_list) + + if !empty(l:nearest) + return l:nearest + endif + + return ale#Var(a:buffer, a:base_var_name . '_executable') +endfunction + +" Given a buffer number, a base variable name, and a list of paths to search +" for in ancestor directories, detect the executable path for a Node program. +function! ale#node#FindNearestExecutable(buffer, path_list) abort for l:path in a:path_list let l:executable = ale#path#FindNearestFile(a:buffer, l:path) @@ -20,7 +32,7 @@ function! ale#node#FindExecutable(buffer, base_var_name, path_list) abort endif endfor - return ale#Var(a:buffer, a:base_var_name . '_executable') + return '' endfunction " Create a executable string which executes a Node.js script command with a diff --git a/sources_non_forked/ale/autoload/ale/organize_imports.vim b/sources_non_forked/ale/autoload/ale/organize_imports.vim index bc9b829e..e2b1c0d2 100644 --- a/sources_non_forked/ale/autoload/ale/organize_imports.vim +++ b/sources_non_forked/ale/autoload/ale/organize_imports.vim @@ -12,10 +12,13 @@ function! ale#organize_imports#HandleTSServerResponse(conn_id, response) abort let l:file_code_edits = a:response.body - call ale#code_action#HandleCodeAction({ - \ 'description': 'Organize Imports', - \ 'changes': l:file_code_edits, - \}) + call ale#code_action#HandleCodeAction( + \ { + \ 'description': 'Organize Imports', + \ 'changes': l:file_code_edits, + \ }, + \ {} + \) endfunction function! s:OnReady(linter, lsp_details) abort diff --git a/sources_non_forked/ale/autoload/ale/path.vim b/sources_non_forked/ale/autoload/ale/path.vim index 30550503..fed95ccd 100644 --- a/sources_non_forked/ale/autoload/ale/path.vim +++ b/sources_non_forked/ale/autoload/ale/path.vim @@ -24,6 +24,14 @@ function! ale#path#Simplify(path) abort return substitute(simplify(l:win_path), '^\\\+', '\', 'g') " no-custom-checks endfunction +" Simplify a path without a Windows drive letter. +" This function can be used for checking if paths are equal. +function! ale#path#RemoveDriveLetter(path) abort + return has('win32') && a:path[1:2] is# ':\' + \ ? ale#path#Simplify(a:path[2:]) + \ : ale#path#Simplify(a:path) +endfunction + " Given a buffer and a filename, find the nearest file by searching upwards " through the paths relative to the given buffer. function! ale#path#FindNearestFile(buffer, filename) abort @@ -74,15 +82,19 @@ endfunction function! ale#path#CdString(directory) abort if has('win32') return 'cd /d ' . ale#Escape(a:directory) . ' && ' - else - return 'cd ' . ale#Escape(a:directory) . ' && ' endif + + return 'cd ' . ale#Escape(a:directory) . ' && ' endfunction " Output 'cd && ' " This function can be used changing the directory for a linter command. function! ale#path#BufferCdString(buffer) abort - return ale#path#CdString(fnamemodify(bufname(a:buffer), ':p:h')) + if has('win32') + return 'cd /d %s:h && ' + endif + + return 'cd %s:h && ' endfunction " Return 1 if a path is an absolute path. @@ -95,7 +107,7 @@ function! ale#path#IsAbsolute(filename) abort return a:filename[:0] is# '/' || a:filename[1:2] is# ':\' endfunction -let s:temp_dir = ale#path#Simplify(fnamemodify(ale#util#Tempname(), ':h')) +let s:temp_dir = ale#path#Simplify(fnamemodify(ale#util#Tempname(), ':h:h')) " Given a filename, return 1 if the file represents some temporary file " created by Vim. diff --git a/sources_non_forked/ale/autoload/ale/preview.vim b/sources_non_forked/ale/autoload/ale/preview.vim index 6d58aca9..8b94aa7a 100644 --- a/sources_non_forked/ale/autoload/ale/preview.vim +++ b/sources_non_forked/ale/autoload/ale/preview.vim @@ -1,6 +1,22 @@ " Author: w0rp " Description: Preview windows for showing whatever information in. +if !has_key(s:, 'last__list') + let s:last_list = [] +endif + +if !has_key(s:, 'last_options') + let s:last_options = {} +endif + +function! ale#preview#SetLastSelection(item_list, options) abort + let s:last_list = a:item_list + let s:last_options = { + \ 'open_in': get(a:options, 'open_in', 'current-buffer'), + \ 'use_relative_paths': get(a:options, 'use_relative_paths', 0), + \} +endfunction + " Open a preview window and show some lines in it. " A second argument can be passed as a Dictionary with options. They are... " @@ -23,6 +39,10 @@ function! ale#preview#Show(lines, ...) abort setlocal readonly let &l:filetype = get(l:options, 'filetype', 'ale-preview') + for l:command in get(l:options, 'commands', []) + call execute(l:command) + endfor + if get(l:options, 'stay_here') wincmd p endif @@ -67,9 +87,19 @@ function! ale#preview#ShowSelection(item_list, ...) abort call ale#preview#Show(l:lines, {'filetype': 'ale-preview-selection'}) let b:ale_preview_item_list = a:item_list + let b:ale_preview_item_open_in = get(l:options, 'open_in', 'current-buffer') + + " Remember preview state, so we can repeat it later. + call ale#preview#SetLastSelection(a:item_list, l:options) endfunction -function! s:Open(open_in_tab) abort +function! ale#preview#RepeatSelection() abort + if !empty(s:last_list) + call ale#preview#ShowSelection(s:last_list, s:last_options) + endif +endfunction + +function! s:Open(open_in) abort let l:item_list = get(b:, 'ale_preview_item_list', []) let l:item = get(l:item_list, getpos('.')[1] - 1, {}) @@ -77,22 +107,20 @@ function! s:Open(open_in_tab) abort return endif - if !a:open_in_tab - :q! - endif + :q! call ale#util#Open( \ l:item.filename, \ l:item.line, \ l:item.column, - \ {'open_in_tab': a:open_in_tab}, + \ {'open_in': a:open_in}, \) endfunction -function! ale#preview#OpenSelectionInBuffer() abort - call s:Open(0) +function! ale#preview#OpenSelection() abort + call s:Open(b:ale_preview_item_open_in) endfunction function! ale#preview#OpenSelectionInTab() abort - call s:Open(1) + call s:Open('tab') endfunction diff --git a/sources_non_forked/ale/autoload/ale/references.vim b/sources_non_forked/ale/autoload/ale/references.vim index b9725e1e..38ff0d3d 100644 --- a/sources_non_forked/ale/autoload/ale/references.vim +++ b/sources_non_forked/ale/autoload/ale/references.vim @@ -1,3 +1,5 @@ +let g:ale_default_navigation = get(g:, 'ale_default_navigation', 'buffer') + let s:references_map = {} " Used to get the references map in tests. @@ -99,7 +101,8 @@ function! s:OnReady(line, column, options, linter, lsp_details) abort let l:request_id = ale#lsp#Send(l:id, l:message) let s:references_map[l:request_id] = { - \ 'use_relative_paths': has_key(a:options, 'use_relative_paths') ? a:options.use_relative_paths : 0 + \ 'use_relative_paths': has_key(a:options, 'use_relative_paths') ? a:options.use_relative_paths : 0, + \ 'open_in': get(a:options, 'open_in', 'current-buffer'), \} endfunction @@ -110,10 +113,24 @@ function! ale#references#Find(...) abort for l:option in a:000 if l:option is? '-relative' let l:options.use_relative_paths = 1 + elseif l:option is? '-tab' + let l:options.open_in = 'tab' + elseif l:option is? '-split' + let l:options.open_in = 'split' + elseif l:option is? '-vsplit' + let l:options.open_in = 'vsplit' endif endfor endif + if !has_key(l:options, 'open_in') + let l:default_navigation = ale#Var(bufnr(''), 'default_navigation') + + if index(['tab', 'split', 'vsplit'], l:default_navigation) >= 0 + let l:options.open_in = l:default_navigation + endif + endif + let l:buffer = bufnr('') let [l:line, l:column] = getpos('.')[1:2] let l:column = min([l:column, len(getline(l:line))]) diff --git a/sources_non_forked/ale/autoload/ale/rename.vim b/sources_non_forked/ale/autoload/ale/rename.vim index 02b7b579..9030618e 100644 --- a/sources_non_forked/ale/autoload/ale/rename.vim +++ b/sources_non_forked/ale/autoload/ale/rename.vim @@ -33,9 +33,10 @@ function! ale#rename#HandleTSServerResponse(conn_id, response) abort return endif - let l:old_name = s:rename_map[a:response.request_seq].old_name - let l:new_name = s:rename_map[a:response.request_seq].new_name - call remove(s:rename_map, a:response.request_seq) + let l:options = remove(s:rename_map, a:response.request_seq) + + let l:old_name = l:options.old_name + let l:new_name = l:options.new_name if get(a:response, 'success', v:false) is v:false let l:message = get(a:response, 'message', 'unknown') @@ -77,16 +78,21 @@ function! ale#rename#HandleTSServerResponse(conn_id, response) abort return endif - call ale#code_action#HandleCodeAction({ - \ 'description': 'rename', - \ 'changes': l:changes, - \}) + call ale#code_action#HandleCodeAction( + \ { + \ 'description': 'rename', + \ 'changes': l:changes, + \ }, + \ { + \ 'should_save': 1, + \ }, + \) endfunction function! ale#rename#HandleLSPResponse(conn_id, response) abort if has_key(a:response, 'id') \&& has_key(s:rename_map, a:response.id) - call remove(s:rename_map, a:response.id) + let l:options = remove(s:rename_map, a:response.id) if !has_key(a:response, 'result') call s:message('No rename result received from server') @@ -94,51 +100,29 @@ function! ale#rename#HandleLSPResponse(conn_id, response) abort return endif - let l:workspace_edit = a:response.result + let l:changes_map = ale#code_action#GetChanges(a:response.result) - if !has_key(l:workspace_edit, 'changes') || empty(l:workspace_edit.changes) + if empty(l:changes_map) call s:message('No changes received from server') return endif - let l:changes = [] + let l:changes = ale#code_action#BuildChangesList(l:changes_map) - for l:file_name in keys(l:workspace_edit.changes) - let l:text_edits = l:workspace_edit.changes[l:file_name] - let l:text_changes = [] - - for l:edit in l:text_edits - let l:range = l:edit.range - let l:new_text = l:edit.newText - - call add(l:text_changes, { - \ 'start': { - \ 'line': l:range.start.line + 1, - \ 'offset': l:range.start.character + 1, - \ }, - \ 'end': { - \ 'line': l:range.end.line + 1, - \ 'offset': l:range.end.character + 1, - \ }, - \ 'newText': l:new_text, - \}) - endfor - - call add(l:changes, { - \ 'fileName': ale#path#FromURI(l:file_name), - \ 'textChanges': l:text_changes, - \}) - endfor - - call ale#code_action#HandleCodeAction({ - \ 'description': 'rename', - \ 'changes': l:changes, - \}) + call ale#code_action#HandleCodeAction( + \ { + \ 'description': 'rename', + \ 'changes': l:changes, + \ }, + \ { + \ 'should_save': 1, + \ }, + \) endif endfunction -function! s:OnReady(line, column, old_name, new_name, linter, lsp_details) abort +function! s:OnReady(line, column, options, linter, lsp_details) abort let l:id = a:lsp_details.connection_id if !ale#lsp#HasCapability(l:id, 'rename') @@ -170,19 +154,16 @@ function! s:OnReady(line, column, old_name, new_name, linter, lsp_details) abort \ l:buffer, \ a:line, \ a:column, - \ a:new_name + \ a:options.new_name \) endif let l:request_id = ale#lsp#Send(l:id, l:message) - let s:rename_map[l:request_id] = { - \ 'new_name': a:new_name, - \ 'old_name': a:old_name, - \} + let s:rename_map[l:request_id] = a:options endfunction -function! s:ExecuteRename(linter, old_name, new_name) abort +function! s:ExecuteRename(linter, options) abort let l:buffer = bufnr('') let [l:line, l:column] = getpos('.')[1:2] @@ -190,8 +171,7 @@ function! s:ExecuteRename(linter, old_name, new_name) abort let l:column = min([l:column, len(getline(l:line))]) endif - let l:Callback = function( - \ 's:OnReady', [l:line, l:column, a:old_name, a:new_name]) + let l:Callback = function('s:OnReady', [l:line, l:column, a:options]) call ale#lsp_linter#StartLSP(l:buffer, a:linter, l:Callback) endfunction @@ -220,6 +200,9 @@ function! ale#rename#Execute() abort endif for l:lsp_linter in l:lsp_linters - call s:ExecuteRename(l:lsp_linter, l:old_name, l:new_name) + call s:ExecuteRename(l:lsp_linter, { + \ 'old_name': l:old_name, + \ 'new_name': l:new_name, + \}) endfor endfunction diff --git a/sources_non_forked/ale/autoload/ale/sign.vim b/sources_non_forked/ale/autoload/ale/sign.vim index db0e1ab6..8109c60e 100644 --- a/sources_non_forked/ale/autoload/ale/sign.vim +++ b/sources_non_forked/ale/autoload/ale/sign.vim @@ -23,7 +23,7 @@ let g:ale_sign_offset = get(g:, 'ale_sign_offset', 1000000) let g:ale_sign_column_always = get(g:, 'ale_sign_column_always', 0) let g:ale_sign_highlight_linenrs = get(g:, 'ale_sign_highlight_linenrs', 0) -let s:supports_sign_groups = has('nvim-0.4.2') || (v:version >= 801 && has('patch614')) +let s:supports_sign_groups = has('nvim-0.4.2') || has('patch-8.1.614') if !hlexists('ALEErrorSign') highlight link ALEErrorSign error diff --git a/sources_non_forked/ale/autoload/ale/test.vim b/sources_non_forked/ale/autoload/ale/test.vim index 082d91ff..6fcbf35e 100644 --- a/sources_non_forked/ale/autoload/ale/test.vim +++ b/sources_non_forked/ale/autoload/ale/test.vim @@ -145,8 +145,8 @@ function! ale#test#WaitForJobs(deadline) abort " end, but before handlers are run. sleep 10ms - " We must check the buffer data again to see if new jobs started - " for command_chain linters. + " We must check the buffer data again to see if new jobs started for + " linters with chained commands. let l:has_new_jobs = 0 " Check again to see if any jobs are running. diff --git a/sources_non_forked/ale/autoload/ale/uri.vim b/sources_non_forked/ale/autoload/ale/uri.vim index 934637d9..e71c6340 100644 --- a/sources_non_forked/ale/autoload/ale/uri.vim +++ b/sources_non_forked/ale/autoload/ale/uri.vim @@ -1,9 +1,18 @@ -" This probably doesn't handle Unicode characters well. +function! s:EncodeChar(char) abort + let l:result = '' + + for l:index in range(strlen(a:char)) + let l:result .= printf('%%%02x', char2nr(a:char[l:index])) + endfor + + return l:result +endfunction + function! ale#uri#Encode(value) abort return substitute( \ a:value, \ '\([^a-zA-Z0-9\\/$\-_.!*''(),]\)', - \ '\=printf(''%%%02x'', char2nr(submatch(1)))', + \ '\=s:EncodeChar(submatch(1))', \ 'g' \) endfunction @@ -12,7 +21,7 @@ function! ale#uri#Decode(value) abort return substitute( \ a:value, \ '%\(\x\x\)', - \ '\=nr2char(''0x'' . submatch(1))', + \ '\=printf("%c", str2nr(submatch(1), 16))', \ 'g' \) endfunction diff --git a/sources_non_forked/ale/autoload/ale/util.vim b/sources_non_forked/ale/autoload/ale/util.vim index 99cd856a..fcc03eb7 100644 --- a/sources_non_forked/ale/autoload/ale/util.vim +++ b/sources_non_forked/ale/autoload/ale/util.vim @@ -16,7 +16,9 @@ endfunction " Vim 8 does not support echoing long messages from asynchronous callbacks, " but NeoVim does. Small messages can be echoed in Vim 8, and larger messages " have to be shown in preview windows. -function! ale#util#ShowMessage(string) abort +function! ale#util#ShowMessage(string, ...) abort + let l:options = get(a:000, 0, {}) + if !has('nvim') call ale#preview#CloseIfTypeMatches('ale-preview.message') endif @@ -25,10 +27,13 @@ function! ale#util#ShowMessage(string) abort if has('nvim') || (a:string !~? "\n" && len(a:string) < &columns) execute 'echo a:string' else - call ale#preview#Show(split(a:string, "\n"), { - \ 'filetype': 'ale-preview.message', - \ 'stay_here': 1, - \}) + call ale#preview#Show(split(a:string, "\n"), extend( + \ { + \ 'filetype': 'ale-preview.message', + \ 'stay_here': 1, + \ }, + \ l:options, + \)) endif endfunction @@ -91,17 +96,17 @@ endfunction " options['open_in'] can be: " current-buffer (default) " tab -" vertical-split -" horizontal-split +" split +" vsplit function! ale#util#Open(filename, line, column, options) abort 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' + elseif l:open_in is# 'split' call ale#util#Execute('split ' . l:args_to_open) - elseif l:open_in is# 'vertical-split' + elseif l:open_in is# 'vsplit' call ale#util#Execute('vsplit ' . l:args_to_open) elseif bufnr(a:filename) isnot bufnr('') " Open another file only if we need to. @@ -336,15 +341,11 @@ function! ale#util#GetMatches(lines, patterns) abort endfunction function! s:LoadArgCount(function) abort - let l:Function = a:function - - redir => l:output - silent! function Function - redir END - - if !exists('l:output') + try + let l:output = execute('function a:function') + catch /E123/ return 0 - endif + endtry let l:match = matchstr(split(l:output, "\n")[0], '\v\([^)]+\)')[1:-2] let l:arg_list = filter(split(l:match, ', '), 'v:val isnot# ''...''') @@ -422,7 +423,10 @@ function! ale#util#Writefile(buffer, lines, filename) abort \ ? map(copy(a:lines), 'substitute(v:val, ''\r*$'', ''\r'', '''')') \ : a:lines - call writefile(l:corrected_lines, a:filename, 'S') " no-custom-checks + " Set binary flag if buffer doesn't have eol and nofixeol to avoid appending newline + let l:flags = !getbufvar(a:buffer, '&eol') && exists('+fixeol') && !&fixeol ? 'bS' : 'S' + + call writefile(l:corrected_lines, a:filename, l:flags) " no-custom-checks endfunction if !exists('s:patial_timers') @@ -480,3 +484,47 @@ endfunction function! ale#util#Input(message, value) abort return input(a:message, a:value) endfunction + +function! ale#util#HasBuflineApi() abort + return exists('*deletebufline') && exists('*appendbufline') && exists('*getpos') && exists('*setpos') +endfunction + +" Sets buffer contents to lines +function! ale#util#SetBufferContents(buffer, lines) abort + let l:has_bufline_api = ale#util#HasBuflineApi() + + if !l:has_bufline_api && a:buffer isnot bufnr('') + return + endif + + " If the file is in DOS mode, we have to remove carriage returns from + " the ends of lines before calling setline(), or we will see them + " twice. + let l:new_lines = getbufvar(a:buffer, '&fileformat') is# 'dos' + \ ? map(copy(a:lines), 'substitute(v:val, ''\r\+$'', '''', '''')') + \ : a:lines + let l:first_line_to_remove = len(l:new_lines) + 1 + + " Use a Vim API for setting lines in other buffers, if available. + if l:has_bufline_api + let l:save_cursor = getpos('.') + call deletebufline(a:buffer, 1, '$') + call appendbufline(a:buffer, 1, l:new_lines) + call deletebufline(a:buffer, 1, 1) + call setpos('.', l:save_cursor) + " Fall back on setting lines the old way, for the current buffer. + else + let l:old_line_length = line('$') + + if l:old_line_length >= l:first_line_to_remove + let l:save = winsaveview() + silent execute + \ l:first_line_to_remove . ',' . l:old_line_length . 'd_' + call winrestview(l:save) + endif + + call setline(1, l:new_lines) + endif + + return l:new_lines +endfunction diff --git a/sources_non_forked/ale/doc/ale-bats.txt b/sources_non_forked/ale/doc/ale-bats.txt new file mode 100644 index 00000000..cf2199ec --- /dev/null +++ b/sources_non_forked/ale/doc/ale-bats.txt @@ -0,0 +1,13 @@ +=============================================================================== +ALE Bats Integration *ale-bats-options* + + +=============================================================================== +shellcheck *ale-bats-shellcheck* + +The `shellcheck` linter for Bats uses the sh options for `shellcheck`; see: +|ale-sh-shellcheck|. + + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-c.txt b/sources_non_forked/ale/doc/ale-c.txt index c9eb79db..b0d94b8e 100644 --- a/sources_non_forked/ale/doc/ale-c.txt +++ b/sources_non_forked/ale/doc/ale-c.txt @@ -1,22 +1,36 @@ =============================================================================== ALE C Integration *ale-c-options* +For basic checking of problems with C files, ALE offers the `cc` linter, which +runs either `clang`, or `gcc`. See |ale-c-cc|. + =============================================================================== Global Options +g:ale_c_always_make *g:ale_c_always_make* + *b:ale_c_always_make* + Type: |Number| + Default: `has('unix') && !has('macunix')` + + If set to `1`, use `--always-make` for `make`, which means that output will + always be parsed from `make` dry runs with GNU make. BSD `make` does not + support this option, so you probably want to turn this option off when using + a BSD variant. + + g:ale_c_build_dir_names *g:ale_c_build_dir_names* *b:ale_c_build_dir_names* Type: |List| Default: `['build', 'bin']` - A list of directory names to be used when searching upwards from cpp - files to discover compilation databases with. For directory named `'foo'`, - ALE will search for `'foo/compile_commands.json'` in all directories on and above - the directory containing the cpp file to find path to compilation database. - This feature is useful for the clang tools wrapped around LibTooling (namely - here, clang-tidy) + A list of directory names to be used when searching upwards from cpp files + to discover compilation databases with. For directory named `'foo'`, ALE + will search for `'foo/compile_commands.json'` in all directories on and + above the directory containing the cpp file to find path to compilation + database. This feature is useful for the clang tools wrapped around + LibTooling (namely here, clang-tidy) g:ale_c_build_dir *g:ale_c_build_dir* @@ -37,7 +51,7 @@ g:ale_c_build_dir *g:ale_c_build_dir* g:ale_c_parse_compile_commands *g:ale_c_parse_compile_commands* *b:ale_c_parse_compile_commands* Type: |Number| - Default: `0` + Default: `1` If set to `1`, ALE will parse `compile_commands.json` files to automatically determine flags for C or C++ compilers. ALE will first search for the @@ -45,9 +59,6 @@ g:ale_c_parse_compile_commands *g:ale_c_parse_compile_commands* `compile_commands.json` files in the directories for |g:ale_c_build_dir_names|. - If |g:ale_c_parse_makefile| or |b:ale_c_parse_makefile| is set to `1`, the - output of `make -n` will be preferred over `compile_commands.json` files. - g:ale_c_parse_makefile *g:ale_c_parse_makefile* *b:ale_c_parse_makefile* @@ -58,24 +69,102 @@ g:ale_c_parse_makefile *g:ale_c_parse_makefile* set for C or C++ compilers. This can make it easier to determine the correct build flags to use for different files. + NOTE: When using this option on BSD, you may need to set + |g:ale_c_always_make| to `0`, and `make -n` will not provide consistent + results if binaries have already been built, so use `make clean` when + editing your files. + + WARNING: Running `make -n` automatically can execute arbitrary code, even + though it's supposed to be a dry run, so enable this option with care. You + might prefer to use the buffer-local version of the option instead with + |g:ale_pattern_options|, or you own code for checking which project you're + in. + + You might want to disable this option if `make -n` takes too long to run for + projects you work on. + + If |g:ale_c_parse_compile_commands| or |b:ale_c_parse_compile_commands| is + set to `1`, flags taken from `compile_commands.json` will be preferred over + `make -n` output. + =============================================================================== -clang *ale-c-clang* +astyle *ale-c-astyle* -g:ale_c_clang_executable *g:ale_c_clang_executable* - *b:ale_c_clang_executable* +g:ale_c_astyle_executable *g:ale_c_astyle_executable* + *b:ale_c_astyle_executable* Type: |String| - Default: `'clang'` + Default: `'astyle'` - This variable can be changed to use a different executable for clang. + This variable can be changed to use a different executable for astyle. -g:ale_c_clang_options *g:ale_c_clang_options* - *b:ale_c_clang_options* +g:ale_c_astyle_project_options *g:ale_c_astyle_project_options* + *b:ale_c_astyle_project_options* + Type: |String| + Default: `''` + + This variable can be changed to use an option file for project level + configurations. Provide only the filename of the option file that should be + present at the project's root directory. + + For example, if .astylrc is specified, the file is searched in the parent + directories of the source file's directory. + + +=============================================================================== +cc *ale-c-cc* + *ale-c-gcc* + *ale-c-clang* + +g:ale_c_cc_executable *g:ale_c_cc_executable* + *b:ale_c_cc_executable* + Type: |String| + Default: `''` + + This variable can be changed to use a different executable for a C compiler. + + ALE will try to use `clang` if Clang is available, otherwise ALE will + default to checking C code with `gcc`. + + +g:ale_c_cc_options *g:ale_c_cc_options* + *b:ale_c_cc_options* Type: |String| Default: `'-std=c11 -Wall'` - This variable can be changed to modify flags given to clang. + This variable can be change to modify flags given to the C compiler. + + +=============================================================================== +ccls *ale-c-ccls* + +g:ale_c_ccls_executable *g:ale_c_ccls_executable* + *b:ale_c_ccls_executable* + Type: |String| + Default: `'ccls'` + + This variable can be changed to use a different executable for ccls. + + +g:ale_c_ccls_init_options *g:ale_c_ccls_init_options* + *b:ale_c_ccls_init_options* + Type: |Dictionary| + Default: `{}` + + This variable can be changed to customize ccls initialization options. + Example: > + { + \ 'cacheDirectory': '/tmp/ccls', + \ 'cacheFormat': 'binary', + \ 'diagnostics': { + \ 'onOpen': 0, + \ 'opChange': 1000, + \ }, + \ } +< + Visit https://github.com/MaskRay/ccls/wiki/Initialization-options for all + available options and explanations. =============================================================================== @@ -260,25 +349,6 @@ g:ale_c_flawfinder_error_severity *g:ale_c_flawfinder_error_severity* error. This setting also applies to flawfinder for c++. -=============================================================================== -gcc *ale-c-gcc* - -g:ale_c_gcc_executable *g:ale_c_gcc_executable* - *b:ale_c_gcc_executable* - Type: |String| - Default: `'gcc'` - - This variable can be changed to use a different executable for gcc. - - -g:ale_c_gcc_options *g:ale_c_gcc_options* - *b:ale_c_gcc_options* - Type: |String| - Default: `'-std=c11 -Wall'` - - This variable can be change to modify flags given to gcc. - - =============================================================================== uncrustify *ale-c-uncrustify* @@ -298,36 +368,5 @@ g:ale_c_uncrustify_options *g:ale_c_uncrustify_options* This variable can be change to modify flags given to uncrustify. -=============================================================================== -ccls *ale-c-ccls* - -g:ale_c_ccls_executable *g:ale_c_ccls_executable* - *b:ale_c_ccls_executable* - Type: |String| - Default: `'ccls'` - - This variable can be changed to use a different executable for ccls. - - -g:ale_c_ccls_init_options *g:ale_c_ccls_init_options* - *b:ale_c_ccls_init_options* - Type: |Dictionary| - Default: `{}` - - This variable can be changed to customize ccls initialization options. - Example: > - { - \ 'cacheDirectory': '/tmp/ccls', - \ 'cacheFormat': 'binary', - \ 'diagnostics': { - \ 'onOpen': 0, - \ 'opChange': 1000, - \ }, - \ } -< - Visit https://github.com/MaskRay/ccls/wiki/Initialization-options for all - available options and explanations. - - =============================================================================== vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-cloudformation.txt b/sources_non_forked/ale/doc/ale-cloudformation.txt index 59c6af06..9724403b 100644 --- a/sources_non_forked/ale/doc/ale-cloudformation.txt +++ b/sources_non_forked/ale/doc/ale-cloudformation.txt @@ -7,8 +7,40 @@ cfn-python-lint *ale-cloudformation-cfn-python-lint* cfn-python-lint is a linter for AWS CloudFormation template file. -https://github.com/awslabs/cfn-python-lint +Website: https://github.com/awslabs/cfn-python-lint +Installation +------------------------------------------------------------------------------- + + +Install cfn-python-lint using either pip or brew: > + +`pip install cfn-lint`. If pip is not available, run +`python setup.py clean --all` then `python setup.py install`. + + Homebrew (macOS): + +`brew install cfn-lint` + +< +Configuration +------------------------------------------------------------------------------- + +To get cloudformation linter to work on only CloudFormation files we must set +the buffer |filetype| to yaml.cloudformation. +This causes ALE to lint the file with linters configured for cloudformation and +yaml files. + +Just put: + +> + + au BufRead,BufNewFile *.template.yaml set filetype=yaml.cloudformation + +< + +on `ftdetect/cloudformation.vim` + +This will get both cloudformation and yaml linters to work on any file with `.template.yaml` ext. =============================================================================== vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: - diff --git a/sources_non_forked/ale/doc/ale-cpp.txt b/sources_non_forked/ale/doc/ale-cpp.txt index ead3be28..17894e6e 100644 --- a/sources_non_forked/ale/doc/ale-cpp.txt +++ b/sources_non_forked/ale/doc/ale-cpp.txt @@ -1,12 +1,16 @@ =============================================================================== ALE C++ Integration *ale-cpp-options* +For basic checking of problems with C++ files, ALE offers the `cc` linter, +which runs either `clang++`, or `gcc`. See |ale-cpp-cc|. + =============================================================================== Global Options The following C options also apply to some C++ linters too. +* |g:ale_c_always_make| * |g:ale_c_build_dir_names| * |g:ale_c_build_dir| * |g:ale_c_parse_makefile| @@ -14,41 +18,82 @@ The following C options also apply to some C++ linters too. =============================================================================== -clang *ale-cpp-clang* +astyle *ale-cpp-astyle* -g:ale_cpp_clang_executable *g:ale_cpp_clang_executable* - *b:ale_cpp_clang_executable* +g:ale_cpp_astyle_executable *g:ale_cpp_astyle_executable* + *b:ale_cpp_astyle_executable* Type: |String| - Default: `'clang++'` + Default: `'astyle'` - This variable can be changed to use a different executable for clang. + This variable can be changed to use a different executable for astyle. -g:ale_cpp_clang_options *g:ale_cpp_clang_options* - *b:ale_cpp_clang_options* - Type: |String| - Default: `'-std=c++14 -Wall'` - - This variable can be changed to modify flags given to clang. - - -=============================================================================== -clangd *ale-cpp-clangd* - -g:ale_cpp_clangd_executable *g:ale_cpp_clangd_executable* - *b:ale_cpp_clangd_executable* - Type: |String| - Default: `'clangd'` - - This variable can be changed to use a different executable for clangd. - - -g:ale_cpp_clangd_options *g:ale_cpp_clangd_options* - *b:ale_cpp_clangd_options* +g:ale_cpp_astyle_project_options *g:ale_cpp_astyle_project_options* + *b:ale_cpp_astyle_project_options* Type: |String| Default: `''` - This variable can be changed to modify flags given to clangd. + This variable can be changed to use an option file for project level + configurations. Provide only the filename of the option file that should be + present at the project's root directory. + + For example, if .astylrc is specified, the file is searched in the parent + directories of the source file's directory. + + +=============================================================================== +cc *ale-cpp-cc* + *ale-cpp-gcc* + *ale-cpp-clang* + +g:ale_cpp_cc_executable *g:ale_cpp_cc_executable* + *b:ale_cpp_cc_executable* + Type: |String| + Default: `''` + + This variable can be changed to use a different executable for a C++ compiler. + + ALE will try to use `clang++` if Clang is available, otherwise ALE will + default to checking C++ code with `gcc`. + + +g:ale_cpp_cc_options *g:ale_cpp_cc_options* + *b:ale_cpp_cc_options* + Type: |String| + Default: `'-std=c++14 -Wall'` + + This variable can be change to modify flags given to the C++ compiler. + + +=============================================================================== +ccls *ale-cpp-ccls* + +g:ale_cpp_ccls_executable *g:ale_cpp_ccls_executable* + *b:ale_cpp_ccls_executable* + Type: |String| + Default: `'ccls'` + + This variable can be changed to use a different executable for ccls. + + +g:ale_cpp_ccls_init_options *g:ale_cpp_ccls_init_options* + *b:ale_cpp_ccls_init_options* + Type: |Dictionary| + Default: `{}` + + This variable can be changed to customize ccls initialization options. + Example: > + { + \ 'cacheDirectory': '/tmp/ccls', + \ 'cacheFormat': 'binary', + \ 'diagnostics': { + \ 'onOpen': 0, + \ 'opChange': 1000, + \ }, + \ } +< + Visit https://github.com/MaskRay/ccls/wiki/Initialization-options for all + available options and explanations. =============================================================================== @@ -82,6 +127,25 @@ g:ale_cpp_clangcheck_options *g:ale_cpp_clangcheck_options* option. +=============================================================================== +clangd *ale-cpp-clangd* + +g:ale_cpp_clangd_executable *g:ale_cpp_clangd_executable* + *b:ale_cpp_clangd_executable* + Type: |String| + Default: `'clangd'` + + This variable can be changed to use a different executable for clangd. + + +g:ale_cpp_clangd_options *g:ale_cpp_clangd_options* + *b:ale_cpp_clangd_options* + Type: |String| + Default: `''` + + This variable can be changed to modify flags given to clangd. + + =============================================================================== clang-format *ale-cpp-clangformat* @@ -271,61 +335,11 @@ g:ale_cpp_flawfinder_options *g:ale-cpp-flawfinder* This variable can be used to pass extra options into the flawfinder command. -=============================================================================== -gcc *ale-cpp-gcc* - -g:ale_cpp_gcc_executable *g:ale_cpp_gcc_executable* - *b:ale_cpp_gcc_executable* - Type: |String| - Default: `'gcc'` - - This variable can be changed to use a different executable for gcc. - - -g:ale_cpp_gcc_options *g:ale_cpp_gcc_options* - *b:ale_cpp_gcc_options* - Type: |String| - Default: `'-std=c++14 -Wall'` - - This variable can be changed to modify flags given to gcc. - - =============================================================================== uncrustify *ale-cpp-uncrustify* See |ale-c-uncrustify| for information about the available options. -=============================================================================== -ccls *ale-cpp-ccls* - -g:ale_cpp_ccls_executable *g:ale_cpp_ccls_executable* - *b:ale_cpp_ccls_executable* - Type: |String| - Default: `'ccls'` - - This variable can be changed to use a different executable for ccls. - - -g:ale_cpp_ccls_init_options *g:ale_cpp_ccls_init_options* - *b:ale_cpp_ccls_init_options* - Type: |Dictionary| - Default: `{}` - - This variable can be changed to customize ccls initialization options. - Example: > - { - \ 'cacheDirectory': '/tmp/ccls', - \ 'cacheFormat': 'binary', - \ 'diagnostics': { - \ 'onOpen': 0, - \ 'opChange': 1000, - \ }, - \ } -< - Visit https://github.com/MaskRay/ccls/wiki/Initialization-options for all - available options and explanations. - - =============================================================================== vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-development.txt b/sources_non_forked/ale/doc/ale-development.txt index faa570c1..afd9798f 100644 --- a/sources_non_forked/ale/doc/ale-development.txt +++ b/sources_non_forked/ale/doc/ale-development.txt @@ -13,6 +13,7 @@ CONTENTS *ale-development-contents* 4. Testing ALE..........................|ale-development-tests| 4.1. Writing Linter Tests.............|ale-development-linter-tests| 4.2. Writing Fixer Tests..............|ale-development-fixer-tests| + 4.3. Running Tests in a Windows VM....|ale-development-windows-tests| =============================================================================== 1. Introduction *ale-development-introduction* @@ -170,6 +171,11 @@ will run all of the tests in Vader, Vint checks, and several Bash scripts for finding extra issues. Run `./run-tests --help` to see all of the options the script supports. Note that the script supports selecting particular test files. +Once you get used to dealing with Vim and NeoVim compatibility issues, you +probably want to use `./run-tests --fast -q` for running tests with only the +fastest available Vim version, and with success messages from tests +suppressed. + Generally write tests for any changes you make. The following types of tests are recommended for the following types of code. @@ -353,5 +359,81 @@ given the above setup are as follows. `AssertFixerNotExecuted` - Check that fixers will not be executed. +=============================================================================== +4.3 Running Tests in a Windows VM *ale-development-windows-tests* + +Tests are run for ALE in a build of Vim 8 for Windows via AppVeyor. These +tests can frequently break due to minor differences in paths and how escaping +is done for commands on Windows. If you are a Linux or Mac user, running these +tests locally can be difficult. Here is a process that will make that easier. + +First, you want to install a Windows image with VirtualBox. Install VirtualBox +and grab a VirtualBox image for Windows such as from here: +https://developer.microsoft.com/en-us/microsoft-edge/tools/vms/ + +NOTE: If you need to enter a password for the virtual machine at any point, +the password is "Passw0rd!" without the double quotes. + +NOTE: If your trial period for Windows runs out, run the commands like the +wallpaper tells you to. + +Your virtual machine will need to have PowerShell installed. Before you go any +further, confirm that PowerShell is installed in your Windows virtual machine. + +Consult the VirtualBox documentation on how to install "Guest Additions." +You probably want to install "Guest Additions" for most things to work +properly. + +After you've loaded your virtual machine image, go into "Settings" for your +virtual machine, and "Shared Folders." Add a shared folder with the name +"ale", and set the "Folder Path" to the path to your ALE repository, for +example: "/home/w0rp/ale" + +Find out which drive letter "ale" has been mounted as in Windows. We'll use +"E:" as the drive letter, for example. Open the command prompt as an +administrator by typing in `cmd` in the start menu, right clicking on the +command prompt application, and clicking "Run as administrator." Click "Yes" +when prompted to ask if you're sure you want to run the command prompt. You +should type in the following command to mount the "ale" directory for testing, +where "E:" is replaced with your drive letter. > + + mklink /D C:\testplugin E: +< +Close the administrator Command Prompt, and try running the command +`type C:\testplugin\LICENSE` in a new Command Prompt which you are NOT running +as administrator. You should see the license for ALE in your terminal. After +you have confirmed that you have mounted ALE on your machine, search in the +Start Menu for "power shell," run PowerShell as an administrator, and issue +the following commands to install the correct Vim and Vader versions for +running tests. > + + Add-Type -A System.IO.Compression.FileSystem + + Invoke-WebRequest ftp://ftp.vim.org/pub/vim/pc/vim80-586w32.zip -OutFile C:\vim.zip + [IO.Compression.ZipFile]::ExtractToDirectory('C:\vim.zip', 'C:\vim') + rm C:\vim.zip + + Invoke-WebRequest ftp://ftp.vim.org/pub/vim/pc/vim80-586rt.zip -OutFile C:\rt.zip + [IO.Compression.ZipFile]::ExtractToDirectory('C:\rt.zip', 'C:\vim') + rm C:\rt.zip + + Invoke-WebRequest https://github.com/junegunn/vader.vim/archive/c6243dd81c98350df4dec608fa972df98fa2a3af.zip -OutFile C:\vader.zip + [IO.Compression.ZipFile]::ExtractToDirectory('C:\vader.zip', 'C:\') + mv C:\vader.vim-c6243dd81c98350df4dec608fa972df98fa2a3af C:\vader + rm C:\vader.zip +< +After you have finished installing everything, you can run all of the tests +in Windows by opening a Command Prompt NOT as an administrator by navigating +to the directory where you've mounted the ALE code, which must be named +`C:\testplugin`, and by running the `run-tests.bat` batch file. > + + cd C:\testplugin + run-tests +< +It will probably take several minutes for all of the tests to run. Be patient. +You can run a specific test by passing the filename as an argument to the +batch file, for example: `run-tests test/test_c_flag_parsing.vader` . This will +give you results much more quickly. + =============================================================================== vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-elixir.txt b/sources_non_forked/ale/doc/ale-elixir.txt index 5864f728..de9daacf 100644 --- a/sources_non_forked/ale/doc/ale-elixir.txt +++ b/sources_non_forked/ale/doc/ale-elixir.txt @@ -6,7 +6,7 @@ ALE Elixir Integration *ale-elixir-options* mix *ale-elixir-mix* -The `mix` linter is disabled by default, as it can bee too expensive to run. +The `mix` linter is disabled by default, as it can be too expensive to run. See `:help g:ale_linters` diff --git a/sources_non_forked/ale/doc/ale-erlang.txt b/sources_non_forked/ale/doc/ale-erlang.txt index 59993a99..38762f08 100644 --- a/sources_non_forked/ale/doc/ale-erlang.txt +++ b/sources_non_forked/ale/doc/ale-erlang.txt @@ -31,6 +31,18 @@ g:ale_erlang_dialyzer_rebar3_profile *g:ale_erlang_dialyzer_rebar3_profile* This variable can be changed to specify the profile that is used to run dialyzer with rebar3. + +------------------------------------------------------------------------------- +elvis *ale-erlang-elvis* + +g:ale_erlang_elvis_executable *g:ale_erlang_elvis_executable* + *b:ale_erlang_elvis_executable* + Type: |String| + Default: `'elvis'` + + This variable can be changed to specify the elvis executable. + + ------------------------------------------------------------------------------- erlc *ale-erlang-erlc* diff --git a/sources_non_forked/ale/doc/ale-go.txt b/sources_non_forked/ale/doc/ale-go.txt index be53783e..5c0791bc 100644 --- a/sources_non_forked/ale/doc/ale-go.txt +++ b/sources_non_forked/ale/doc/ale-go.txt @@ -219,6 +219,25 @@ g:ale_go_govet_options *g:ale_go_govet_options* This variable can be set to pass additional options to the go vet linter. +=============================================================================== +revive *ale-go-revive* + +g:ale_go_revive_executable *g:ale_go_revive_executable* + *b:ale_go_revive_executable* + Type: |String| + Default: `'revive'` + + This variable can be set to change the revive executable path. + + +g:ale_go_revive_options *g:ale_go_revive_options* + *b:ale_go_revive_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to the revive + + =============================================================================== staticcheck *ale-go-staticcheck* diff --git a/sources_non_forked/ale/doc/ale-handlebars.txt b/sources_non_forked/ale/doc/ale-handlebars.txt index 5daec5b3..4a5a3870 100644 --- a/sources_non_forked/ale/doc/ale-handlebars.txt +++ b/sources_non_forked/ale/doc/ale-handlebars.txt @@ -14,7 +14,8 @@ ember-template-lint *ale-handlebars-embertemplatelint* g:ale_handlebars_embertemplatelint_executable *g:ale_handlebars_embertemplatelint_executable* - Type: |String| *b:ale_handlebars_embertemplatelint_executable* + *b:ale_handlebars_embertemplatelint_executable* + Type: |String| Default: `'ember-template-lint'` See |ale-integrations-local-executables| @@ -22,7 +23,8 @@ g:ale_handlebars_embertemplatelint_executable g:ale_handlebars_embertemplatelint_use_global *g:ale_handlebars_embertemplatelint_use_global* - Type: |Number| *b:ale_handlebars_embertemplatelint_use_global* + *b:ale_handlebars_embertemplatelint_use_global* + Type: |Number| Default: `get(g:, 'ale_use_global_executables', 0)` See |ale-integrations-local-executables| diff --git a/sources_non_forked/ale/doc/ale-haskell.txt b/sources_non_forked/ale/doc/ale-haskell.txt index 5dd3ec15..fde439fe 100644 --- a/sources_non_forked/ale/doc/ale-haskell.txt +++ b/sources_non_forked/ale/doc/ale-haskell.txt @@ -172,5 +172,25 @@ g:ale_haskell_hie_executable *g:ale_haskell_hie_executable* ide engine. i.e. `'hie-wrapper'` +=============================================================================== +ormolu *ale-haskell-ormolu* + +g:ale_haskell_ormolu_executable *g:ale_haskell_ormolu_executable* + *b:ale_haskell_ormolu_executable* + Type: |String| + Default: `'ormolu'` + + This variable can be changed to use a different executable for ormolu. + + +g:ale_haskell_ormolu_options *g:ale_haskell_ormolu_options* + *b:ale_haskell_ormolu_options* + Type: String + Default: '' + + This variable can be used to pass extra options to the underlying ormolu + executable. + + =============================================================================== vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-java.txt b/sources_non_forked/ale/doc/ale-java.txt index 32f0e6eb..0debc1af 100644 --- a/sources_non_forked/ale/doc/ale-java.txt +++ b/sources_non_forked/ale/doc/ale-java.txt @@ -46,7 +46,7 @@ javac *ale-java-javac* g:ale_java_javac_classpath *g:ale_java_javac_classpath* *b:ale_java_javac_classpath* - Type: |String| + Type: |String| or |List| Default: `''` This variable can be set to change the global classpath for Java. @@ -67,6 +67,30 @@ g:ale_java_javac_options *g:ale_java_javac_options* This variable can be set to pass additional options to javac. +g:ale_java_javac_sourcepath *g:ale_java_javac_sourcepath* + *b:ale_java_javac_sourcepath* + Type: |String| or |List| + Default: `''` + +This variable can set multiple source code paths, the source code path is a +relative path (relative to the project root directory). + +Example: + +String type: +Note that the unix system separator is a colon(`:`) window system +is a semicolon(`;`). +> + let g:ale_java_javac_sourcepath = 'build/gen/source/xx/main:build/gen/source' +< +List type: +> + let g:ale_java_javac_sourcepath = [ + \ 'build/generated/source/querydsl/main', + \ 'target/generated-sources/source/querydsl/main' + \ ] +< + =============================================================================== google-java-format *ale-java-google-java-format* @@ -107,18 +131,26 @@ javalsp *ale-java-javalsp* To enable Java LSP linter you need to download and build the vscode-javac language server from https://github.com/georgewfraser/java-language-server. -Simply download the source code and then build a distribution: - scripts/link_mac.sh +Before building the language server you need to install pre-requisites: npm, +maven, and protobuf. You also need to have Java 13 and JAVA_HOME properly +set. -or +After downloading the source code and installing all pre-requisites you can +build the language server with the included build.sh script: - scripts/link_windows.sh + scripts/build.sh -This generates a dist/mac or dist/windows directory that contains the -language server. To let ALE use this language server you need to set the +This will create launch scripts for Linux, Mac, and Windows in the dist folder +within the repo: + + - lang_server_linux.sh + - lang_server_mac.sh + - lang_server_windows.sh + +To let ALE use this language server you need to set the g:ale_java_javalsp_executable variable to the absolute path of the launcher -executable in this directory. +executable for your platform. g:ale_java_javalsp_executable *g:ale_java_javalsp_executable* *b:ale_java_javalsp_executable* @@ -128,7 +160,7 @@ g:ale_java_javalsp_executable *g:ale_java_javalsp_executable* This variable must be set to the absolute path of the language server launcher executable. For example: > - let g:ale_java_javalsp_executable=/java-language-server/dist/mac/bin/launcher + let g:ale_java_javalsp_executable=/java-language-server/dist/lang_server_linux.sh < g:ale_java_javalsp_config *g:ale_java_javalsp_config* @@ -140,7 +172,7 @@ The javalsp linter automatically detects external depenencies for Maven and Gradle projects. In case the javalsp fails to detect some of them, you can specify them setting a dictionary to |g:ale_java_javalsp_config| variable. > - let g:ale_java_javalsp_executable = + let g:ale_java_javalsp_config = \ { \ 'java': { \ 'externalDependencies': [ @@ -222,6 +254,17 @@ g:ale_java_eclipselsp_workspace_path *g:ale_java_eclipselsp_workspace_path* absolute path of the Eclipse workspace. If not set this value will be set to the parent folder of the project root. +g:ale_java_eclipselsp_javaagent *g:ale_java_eclipselsp_javaagent* + *b:ale_java_eclipselsp_javaagent* + + Type: |String| + Default: `''` + + A variable to add java agent for annotation processing such as Lombok. + If you have multiple java agent files, use space to separate them. For example: +> + let g:ale_java_eclipselsp_javaagent='/eclipse/lombok.jar /eclipse/jacoco.jar' +< =============================================================================== uncrustify *ale-java-uncrustify* diff --git a/sources_non_forked/ale/doc/ale-javascript.txt b/sources_non_forked/ale/doc/ale-javascript.txt index ea0a7089..13059eaa 100644 --- a/sources_non_forked/ale/doc/ale-javascript.txt +++ b/sources_non_forked/ale/doc/ale-javascript.txt @@ -138,7 +138,7 @@ g:ale_javascript_flow_use_respect_pragma By default, ALE will use the `--respect-pragma` option for `flow`, so only files with the `@flow` pragma are checked by ALE. This option can be set to - `0` to disable that behaviour, so all files can be checked by `flow`. + `0` to disable that behavior, so all files can be checked by `flow`. =============================================================================== diff --git a/sources_non_forked/ale/doc/ale-lua.txt b/sources_non_forked/ale/doc/ale-lua.txt index f1286f89..408f0c3c 100644 --- a/sources_non_forked/ale/doc/ale-lua.txt +++ b/sources_non_forked/ale/doc/ale-lua.txt @@ -30,5 +30,21 @@ g:ale_lua_luacheck_options *g:ale_lua_luacheck_options* This variable can be set to pass additional options to luacheck. +=============================================================================== +luafmt *ale-lua-luafmt* + +g:ale_lua_luafmt_executable *g:ale_lua_luafmt_executable* + *b:ale_lua_luafmt_executable* + Type: |String| + Default: `'luafmt'` + + This variable can be set to use a different executable for luafmt. + +g:ale_lua_luafmt_options *g:ale_lua_luafmt_options* + *b:ale_lua_luafmt_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to the luafmt fixer. =============================================================================== vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-markdown.txt b/sources_non_forked/ale/doc/ale-markdown.txt index 4e27eb91..99848878 100644 --- a/sources_non_forked/ale/doc/ale-markdown.txt +++ b/sources_non_forked/ale/doc/ale-markdown.txt @@ -2,6 +2,17 @@ ALE Markdown Integration *ale-markdown-options* +=============================================================================== +markdownlint *ale-markdown-markdownlint* + +g:ale_markdown_markdownlint_options *g:ale_markdown_markdownlint_options* + *b:ale_markdown_markdownlint_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to markdownlint. + + =============================================================================== mdl *ale-markdown-mdl* diff --git a/sources_non_forked/ale/doc/ale-php.txt b/sources_non_forked/ale/doc/ale-php.txt index 645decd7..4ee016fb 100644 --- a/sources_non_forked/ale/doc/ale-php.txt +++ b/sources_non_forked/ale/doc/ale-php.txt @@ -85,6 +85,14 @@ g:ale_php_phpcbf_use_global *g:ale_php_phpcbf_use_global* See |ale-integrations-local-executables| +g:ale_php_phpcbf_options *g:ale_php_phpcbf_options* + *b:ale_php_phpcbf_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to php-cbf + + =============================================================================== phpcs *ale-php-phpcs* @@ -189,46 +197,124 @@ g:ale_php_psalm_executable *g:ale_php_psalm_executable* This variable sets the executable used for psalm. -g:ale_psalm_langserver_options *g:ale_psalm_langserver_options* - *b:ale_psalm_langserver_options* + +g:ale_php_psalm_options *g:ale_php_psalm_options* + *b:ale_php_psalm_options* Type: |String| Default: `''` This variable can be set to pass additional options to psalm. -=============================================================================== -php-cs-fixer *ale-php-php-cs-fixer* -g:ale_php_cs_fixer_executable *g:ale_php_cs_fixer_executable* - *b:ale_php_cs_fixer_executable* +g:ale_php_psalm_use_global *g:ale_php_psalm_use_global* + *b:ale_php_psalm_use_global* + Type: |Boolean| + Default: `get(g:, 'ale_use_global_executables', 0)` + + See |ale-integrations-local-executables| + + +=============================================================================== +php-cs-fixer *ale-php-php-cs-fixer* + +g:ale_php_cs_fixer_executable *g:ale_php_cs_fixer_executable* + *b:ale_php_cs_fixer_executable* Type: |String| Default: `'php-cs-fixer'` This variable sets executable used for php-cs-fixer. -g:ale_php_cs_fixer_use_global *g:ale_php_cs_fixer_use_global* - *b:ale_php_cs_fixer_use_global* - Type: |Boolean| - Default: `get(g:, 'ale_use_global_executables', 0)` - This variable force globally installed fixer. - -g:ale_php_cs_fixer_options *g:ale_php_cs_fixer_options* - *b:ale_php_cs_fixer_options* +g:ale_php_cs_fixer_options *g:ale_php_cs_fixer_options* + *b:ale_php_cs_fixer_options* Type: |String| Default: `''` This variable can be set to pass additional options to php-cs-fixer. -=============================================================================== -php *ale-php-php* -g:ale_php_php_executable *g:ale_php_php_executable* - *b:ale_php_php_executable* +g:ale_php_cs_fixer_use_global *g:ale_php_cs_fixer_use_global* + *b:ale_php_cs_fixer_use_global* + Type: |Boolean| + Default: `get(g:, 'ale_use_global_executables', 0)` + + See |ale-integrations-local-executables| + + +=============================================================================== +php *ale-php-php* + +g:ale_php_php_executable *g:ale_php_php_executable* + *b:ale_php_php_executable* Type: |String| Default: `'php'` This variable sets the executable used for php. + +=============================================================================== +tlint *ale-php-tlint* + +g:ale_php_tlint_executable *g:ale_php_tlint_executable* + *b:ale_php_tlint_executable* + Type: |String| + Default: `'tlint'` + + See |ale-integrations-local-executables| + + +g:ale_php_tlint_use_global *g:ale_php_tlint_use_global* + *b:ale_php_tlint_use_global* + Type: |Number| + Default: `get(g:, 'ale_use_global_executables', 0)` + + See |ale-integrations-local-executables| + + +g:ale_php_tlint_options *g:ale_php_tlint_options* + *b:ale_php_tlint_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to tlint + + +=============================================================================== +intelephense *ale-php-intelephense* + +g:ale_php_intelephense_executable *g:ale_php_intelephense_executable* + *b:ale_php_intelephense_executable* + Type: |String| + Default: `'intelephense'` + + The variable can be set to configure the executable that will be used for + running the intelephense language server. `node_modules` directory + executable will be preferred instead of this setting if + |g:ale_php_intelephense_use_global| is `0`. + + See: |ale-integrations-local-executables| + + +g:ale_php_intelephense_use_global *g:ale_php_intelephense_use_global* + *b:ale_php_intelephense_use_global* + Type: |Number| + Default: `get(g:, 'ale_use_global_executables', 0)` + + This variable can be set to `1` to force the language server to be run with + the executable set for |g:ale_php_intelephense_executable|. + + See: |ale-integrations-local-executables| + + +g:ale_php_intelephense_config *g:ale_php_intelephense_config* + *b:ale_php_intelephense_config* + Type: |Dictionary| + Default: `{}` + + The initialization options config specified by Intelephense. Refer to the + installation docs provided by intelephense (github.com/bmewburn/intelephense + -docs). + + =============================================================================== vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-powershell.txt b/sources_non_forked/ale/doc/ale-powershell.txt index c28ef9ea..485c9bd0 100644 --- a/sources_non_forked/ale/doc/ale-powershell.txt +++ b/sources_non_forked/ale/doc/ale-powershell.txt @@ -25,13 +25,6 @@ Installation Install PSScriptAnalyzer by any means, so long as it can be automatically imported in PowerShell. -Some PowerShell plugins set the filetype of files to `ps1`. To continue using -these plugins, use the ale_linter_aliases global to alias `ps1` to `powershell` - -> - " Allow ps1 filetype to work with powershell linters - let g:ale_linter_aliases = {'ps1': 'powershell'} -< g:ale_powershell_psscriptanalyzer_executable *g:ale_powershell_psscriptanalyzer_executable* diff --git a/sources_non_forked/ale/doc/ale-python.txt b/sources_non_forked/ale/doc/ale-python.txt index 93f1d668..f0c8bfb8 100644 --- a/sources_non_forked/ale/doc/ale-python.txt +++ b/sources_non_forked/ale/doc/ale-python.txt @@ -41,6 +41,32 @@ ALE will look for configuration files with the following filenames. > The first directory containing any of the files named above will be used. +=============================================================================== +autoimport *ale-python-autoimport* + +g:ale_python_autoimport_executable *g:ale_python_autoimport_executable* + *b:ale_python_autoimport_executable* + Type: |String| + Default: `'autoimport'` + + See |ale-integrations-local-executables| + + +g:ale_python_autoimport_options *g:ale_python_autoimport_options* + *b:ale_python_autoimport_options* + Type: |String| + Default: `''` + + This variable can be set to pass extra options to autoimport. + + +g:ale_python_autoimport_use_global *g:ale_python_autoimport_use_global* + *b:ale_python_autoimport_use_global* + Type: |Number| + Default: `get(g:, 'ale_use_global_executables', 0)` + + See |ale-integrations-local-executables| + =============================================================================== autopep8 *ale-python-autopep8* @@ -169,13 +195,14 @@ flake8 *ale-python-flake8* g:ale_python_flake8_change_directory *g:ale_python_flake8_change_directory* *b:ale_python_flake8_change_directory* - Type: |Number| - Default: `1` + Type: |String| + Default: `project` - If set to `1`, ALE will switch to the directory the Python file being - checked with `flake8` is in before checking it. This helps `flake8` find - configuration files more easily. This option can be turned off if you want - to control the directory Python is executed from yourself. + If set to `project`, ALE will switch to the project root before checking file. + If set to `file`, ALE will switch to directory the Python file being + checked with `flake8` is in before checking it. + You can turn it off with `off` option if you want to control the directory + Python is executed from yourself. g:ale_python_flake8_executable *g:ale_python_flake8_executable* @@ -598,6 +625,7 @@ g:ale_python_pylint_use_msg_id *g:ale_python_pylint_use_msg_id* Use message for output (e.g. I0011) instead of symbolic name of the message (e.g. locally-disabled). + =============================================================================== pyls *ale-python-pyls* @@ -682,6 +710,65 @@ g:ale_python_pyre_auto_pipenv *g:ale_python_pyre_auto_pipenv* if true. This is overridden by a manually-set executable. +=============================================================================== +pyright *ale-python-pyright* + +The `pyright` linter requires a recent version of `pyright` which includes +the `pyright-langserver` executable. You can install `pyright` on your system +through `npm` with `sudo npm install -g pyright` or similar. + +Refer to their README for installation instructions: +https://github.com/Microsoft/pyright + +`pyright` needs to know the path to your Python executable and probably a +virtualenv to run. ALE will try to detect these automatically. +See |g:ale_python_pyright_config|. + + +g:ale_python_pyright_executable *g:ale_python_pyright_executable* + *b:ale_python_pyright_executable* + Type: |String| + Default: `'pyright-langserver'` + + The executable for running `pyright`, which is typically installed globally. + + +g:ale_python_pyright_config *g:ale_python_pyright_config* + *b:ale_python_pyright_config* + Type: |Dictionary| + Default: `{}` + + Settings for configuring the `pyright` language server. + + See pyright's documentation for a full list of options: + https://github.com/microsoft/pyright/blob/master/docs/settings.md + + ALE will automatically try to set defaults for `venvPath` and `pythonPath` + so your project can automatically be checked with the right libraries. + You can override these settings with whatever you want in your ftplugin + file like so: > + + let b:ale_python_pyright_config = { + \ 'python': { + \ 'pythonPath': '/bin/python', + \ 'venvPath': '/other/dir', + \ }, + \} +< + If `venvPath` is set, but `pythonPath` is not, + ALE will use `venvPath . '/bin/python'` or similar as `pythonPath`. + + A commonly used setting for `pyright` is disabling language services + apart from type checking and "hover" (|ale-hover|), you can set this + setting like so, or use whatever other settings you want: > + + let b:ale_python_pyright_config = { + \ 'pyright': { + \ 'disableLanguageServices': v:true, + \ }, + \} +< + =============================================================================== reorder-python-imports *ale-python-reorder_python_imports* diff --git a/sources_non_forked/ale/doc/ale-r.txt b/sources_non_forked/ale/doc/ale-r.txt index b5ccebe5..3fabf702 100644 --- a/sources_non_forked/ale/doc/ale-r.txt +++ b/sources_non_forked/ale/doc/ale-r.txt @@ -2,6 +2,29 @@ ALE R Integration *ale-r-options* +=============================================================================== +languageserver *ale-r-languageserver* + +g:ale_r_languageserver_cmd *g:ale_r_languageserver_cmd* + *b:ale_r_languageserver_cmd* + Type: |String| + Default: `'languageserver::run()'` + + This option can be configured to change the execution command for + languageserver. + + See the languageserver documentation for more options. + + +g:ale_r_languageserver_config *g:ale_r_languageserver_config* + *b:ale_r_languageserver_config* + Type: |Dictionary| + Default: `{}` + + This option can be configured to change settings for languageserver. See the + languageserver documentation for more information. + + =============================================================================== lintr *ale-r-lintr* @@ -22,7 +45,7 @@ g:ale_r_lintr_lint_package *g:ale_r_lintr_lint_package* Default: `0` When set to `1`, the file will be checked with `lintr::lint_package` instead - of `lintr::lint`. This prevents erroneous namespace warnings when linting + of `lintr::lint`. This prevents erroneous namespace warnings when linting package files. @@ -36,8 +59,8 @@ g:ale_r_styler_options *g:ale_r_styler_options* This option can be configured to change the options for styler. - The value of this option will be used as the `style` argument for the - `styler::style_file` options. Consult the styler documentation + The value of this option will be used as the `style` argument for the + `styler::style_file` options. Consult the styler documentation for more information. diff --git a/sources_non_forked/ale/doc/ale-ruby.txt b/sources_non_forked/ale/doc/ale-ruby.txt index a27a20b2..8815404a 100644 --- a/sources_non_forked/ale/doc/ale-ruby.txt +++ b/sources_non_forked/ale/doc/ale-ruby.txt @@ -114,6 +114,14 @@ g:ale_ruby_rubocop_options *g:ale_ruby_rubocop_options* This variable can be changed to modify flags given to rubocop. +g:ale_ruby_rubocop_auto_correct_all *g:ale_ruby_rubocop_auto_correct_all* + *b:ale_ruby_rubocop_auto_correct_all* + Type: Number + Default: `0` + + This variable can be changed to make rubocop to correct all offenses (unsafe). + + =============================================================================== ruby *ale-ruby-ruby* @@ -172,8 +180,8 @@ g:ale_ruby_sorbet_options *g:ale_ruby_sorbet_options* =============================================================================== standardrb *ale-ruby-standardrb* -g:ale_ruby_standardrb_executable *g:ale_ruby_standardrb_executable* - *b:ale_ruby_standardrb_executable* +g:ale_ruby_standardrb_executable *g:ale_ruby_standardrb_executable* + *b:ale_ruby_standardrb_executable* Type: String Default: `'standardrb'` diff --git a/sources_non_forked/ale/doc/ale-rust.txt b/sources_non_forked/ale/doc/ale-rust.txt index 44a79b18..3aa63673 100644 --- a/sources_non_forked/ale/doc/ale-rust.txt +++ b/sources_non_forked/ale/doc/ale-rust.txt @@ -9,7 +9,7 @@ Integration Information files for Rust distributed in Vim >=8.0.0501 or upstream: https://github.com/rust-lang/rust.vim - Note that there are three possible linters for Rust files: + Note that there are several possible linters and fixers for Rust files: 1. rustc -- The Rust compiler is used to check the currently edited file. So, if your project consists of multiple files, you will get some errors @@ -22,20 +22,45 @@ Integration Information 3. rls -- If you have `rls` installed, you might prefer using this linter over cargo. rls implements the Language Server Protocol for incremental compilation of Rust code, and can check Rust files while you type. `rls` - requires Rust files to contained in Cargo projects. - 4. rustfmt -- If you have `rustfmt` installed, you can use it as a fixer to + requires Rust files to be contained in Cargo projects. + 4. analyzer -- If you have rust-analyzer installed, you might prefer using + this linter over cargo and rls. rust-analyzer also implements the + Language Server Protocol for incremental compilation of Rust code, and is + the next iteration of rls. rust-analyzer, like rls, requires Rust files + to be contained in Cargo projects. + 5. rustfmt -- If you have `rustfmt` installed, you can use it as a fixer to consistently reformat your Rust code. - Only cargo is enabled by default. To switch to using rustc instead of cargo, - configure |g:ale_linters| appropriately: > + Only cargo and rls are enabled by default. To switch to using rustc instead + of cargo, configure |g:ale_linters| appropriately: > " See the help text for the option for more information. - let g:ale_linters = {'rust': ['rustc']} + let g:ale_linters = {'rust': ['rustc', 'rls']} < Also note that rustc 1.12. or later is needed. +=============================================================================== +analyzer *ale-rust-analyzer* + +g:ale_rust_analyzer_executable *g:ale_rust_analyzer_executable* + *b:ale_rust_analyzer_executable* + Type: |String| + Default: `'rust-analyzer'` + + This variable can be modified to change the executable path for + `rust-analyzer`. + + +g:ale_rust_analyzer_config *g:ale_rust_analyzer_config* + *b:ale_rust_analyzer_config* + Type: |Dictionary| + Default: `{}` + + Dictionary with configuration settings for rust-analyzer. + + =============================================================================== cargo *ale-rust-cargo* @@ -150,6 +175,18 @@ g:ale_rust_cargo_clippy_options only `cargo clippy` supports (e.g. `--deny`). +g:ale_rust_cargo_target_dir + *g:ale_rust_cargo_target_dir* + *b:ale_rust_cargo_target_dir* + + Type: |String| + Default: `''` + + Use a custom target directory when running the commands for ALE. This can + help to avoid "waiting for file lock on build directory" messages when + running `cargo` commands manually while ALE is performing its checks. + + =============================================================================== rls *ale-rust-rls* @@ -216,23 +253,25 @@ g:ale_rust_ignore_error_codes *g:ale_rust_ignore_error_codes* > let g:ale_rust_ignore_error_codes = ['E0432', 'E0433'] + g:ale_rust_ignore_secondary_spans *g:ale_rust_ignore_secondary_spans* *b:ale_rust_ignore_secondary_spans* Type: Number Default: 0 - When set to 1, instructs the Rust error repporting to ignore secondary - spans. The problem with secondary spans is that they sometimes appear in - error messages before the main cause of the error, for example: > + When set to 1, instructs the Rust error reporting to ignore secondary spans. + The problem with secondary spans is that they sometimes appear in error + messages before the main cause of the error, for example: > 1 src/main.rs|98 col 5 error| this function takes 4 parameters but 5 - parameters were supplied: defined here + parameters were supplied: defined here 2 src/main.rs|430 col 32 error| this function takes 4 parameters but 5 - parameters were supplied: expected 4 parameters + parameters were supplied: expected 4 parameters < This is due to the sorting by line numbers. With this option set to 1, the 'defined here' span will not be presented. + =============================================================================== rustfmt *ale-rust-rustfmt* diff --git a/sources_non_forked/ale/doc/ale-sh.txt b/sources_non_forked/ale/doc/ale-sh.txt index 3eac9038..c06f737a 100644 --- a/sources_non_forked/ale/doc/ale-sh.txt +++ b/sources_non_forked/ale/doc/ale-sh.txt @@ -2,6 +2,29 @@ ALE Shell Integration *ale-sh-options* +=============================================================================== +bashate *ale-sh-bashate* + +g:ale_sh_bashate_executable *g:ale_sh_bashate_executable* + *b:ale_sh_bashate_executable* + Type: |String| + Default: `'bashate'` + + This variable sets executable used for bashate. + + +g:ale_sh_bashate_options *g:ale_sh_bashate_options* + *b:ale_sh_bashate_options* + Type: |String| + Default: `''` + + With this variable we are able to pass extra arguments for bashate. For + example to ignore the indentation rule: + +> + let g:ale_sh_bashate_options = '-i E003' +< + =============================================================================== sh-language-server *ale-sh-language-server* diff --git a/sources_non_forked/ale/doc/ale-sql.txt b/sources_non_forked/ale/doc/ale-sql.txt index 2807271b..398e24d3 100644 --- a/sources_non_forked/ale/doc/ale-sql.txt +++ b/sources_non_forked/ale/doc/ale-sql.txt @@ -3,7 +3,7 @@ ALE SQL Integration *ale-sql-options* =============================================================================== -pgformatter *ale-sql-pgformatter* +pgformatter *ale-sql-pgformatter* g:ale_sql_pgformatter_executable *g:ale_sql_pgformatter_executable* *b:ale_sql_pgformatter_executable* diff --git a/sources_non_forked/ale/doc/ale-supported-languages-and-tools.txt b/sources_non_forked/ale/doc/ale-supported-languages-and-tools.txt index 365f9fb4..2fc84fae 100644 --- a/sources_non_forked/ale/doc/ale-supported-languages-and-tools.txt +++ b/sources_non_forked/ale/doc/ale-supported-languages-and-tools.txt @@ -21,6 +21,7 @@ Notes: * `drafter` * AsciiDoc * `alex`!! + * `languagetool`!! * `proselint` * `redpen` * `textlint` @@ -31,10 +32,13 @@ Notes: * Awk * `gawk` * Bash + * `bashate` * `language-server` * `shell` (-n flag) * `shellcheck` * `shfmt` +* Bats + * `shellcheck` * BibTeX * `bibclean` * Bourne Shell @@ -42,8 +46,9 @@ Notes: * `shellcheck` * `shfmt` * C + * `astyle` * `ccls` - * `clang` + * `clang` (`cc`) * `clangd` * `clang-format` * `clangtidy`!! @@ -51,7 +56,7 @@ Notes: * `cpplint`!! * `cquery` * `flawfinder` - * `gcc` + * `gcc` (`cc`) * `uncrustify` * C# * `csc`!! @@ -59,8 +64,9 @@ Notes: * `mcsc`!! * `uncrustify` * C++ (filetype cpp) + * `astyle` * `ccls` - * `clang` + * `clang` (`cc`) * `clangcheck`!! * `clangd` * `clang-format` @@ -70,7 +76,7 @@ Notes: * `cpplint`!! * `cquery` * `flawfinder` - * `gcc` + * `gcc` (`cc`) * `uncrustify` * Chef * `cookstyle` @@ -113,6 +119,8 @@ Notes: * `dartanalyzer`!! * `dartfmt`!! * `language_server` +* Dhall + * `dhall-format` * Dockerfile * `dockerfile_lint` * `hadolint` @@ -132,6 +140,7 @@ Notes: * `erubis` * `ruumba` * Erlang + * `elvis`!! * `erlc` * `SyntaxErl` * Fish @@ -162,6 +171,7 @@ Notes: * `gosimple`!! * `gotype`!! * `go vet`!! + * `revive`!! * `staticcheck`!! * GraphQL * `eslint` @@ -186,6 +196,7 @@ Notes: * `hie` * `hindent` * `hlint` + * `ormolu` * `stack-build`!! * `stack-ghc` * `stylish-haskell` @@ -256,6 +267,7 @@ Notes: * Lua * `luac` * `luacheck` + * `luafmt` * Mail * `alex`!! * `languagetool`!! @@ -315,6 +327,7 @@ Notes: * Perl6 * `perl6 -c` * PHP + * `intelephense` * `langserver` * `phan` * `phpcbf` @@ -324,6 +337,7 @@ Notes: * `phpmd` * `phpstan` * `psalm`!! + * `tlint` * PO * `alex`!! * `msgfmt` @@ -355,6 +369,7 @@ Notes: * `purty` >>>>>>> 27ad0d07862847896f691309a544a206783c94d6 * Python + * `autoimport` * `autopep8` * `bandit` * `black` @@ -369,6 +384,7 @@ Notes: * `pylint`!! * `pyls` * `pyre` + * `pyright` * `reorder-python-imports` * `vulture`!! * `yapf` @@ -376,6 +392,7 @@ Notes: * `qmlfmt` * `qmllint` * R + * `languageserver` * `lintr` * `styler` * Racket @@ -411,6 +428,7 @@ Notes: * Rust * `cargo`!! * `rls` + * `rust-analyzer` * `rustc` (see |ale-integration-rust|) * `rustfmt` * Sass @@ -441,11 +459,13 @@ Notes: * `sqlfmt` * `sqlformat` * `sqlint` + * `sql-lint` * Stylus * `stylelint` * SugarSS * `stylelint` * Swift + * Apple `swift-format` * `sourcekit-lsp` * `swiftformat` * `swiftlint` @@ -479,6 +499,7 @@ Notes: * VALA * `uncrustify` * Verilog + * `hdl-checker` * `iverilog` * `verilator` * `vlog` @@ -488,6 +509,7 @@ Notes: * `vcom` * `xvhdl` * Vim + * `vimls` * `vint` * Vim help^ * `alex`!! @@ -505,6 +527,9 @@ Notes: * YAML * `prettier` * `swaglint` + * `yamlfix` * `yamllint` * YANG * `yang-lsp` +* Zig + * `zls` diff --git a/sources_non_forked/ale/doc/ale-terraform.txt b/sources_non_forked/ale/doc/ale-terraform.txt index 387fd732..f62db190 100644 --- a/sources_non_forked/ale/doc/ale-terraform.txt +++ b/sources_non_forked/ale/doc/ale-terraform.txt @@ -32,6 +32,25 @@ g:ale_terraform_terraform_executable *g:ale_terraform_terraform_executable* This variable can be changed to use a different executable for terraform. +=============================================================================== +terraform-lsp *ale-terraform-terraform-lsp* + +g:ale_terraform_langserver_executable *g:ale_terraform_langserver_executable* + *b:ale_terraform_langserver_executable* + Type: |String| + Default: `'terraform-lsp'` + + This variable can be changed to use a different executable for terraform-lsp. + + +g:ale_terraform_langserver_options *g:ale_terraform_langserver_options* + *b:ale_terraform_langserver_options* + Type: |String| + Default: `''` + + This variable can be changed to pass custom CLI flags to terraform-lsp. + + =============================================================================== tflint *ale-terraform-tflint* diff --git a/sources_non_forked/ale/doc/ale-verilog.txt b/sources_non_forked/ale/doc/ale-verilog.txt index 94b820b8..01af63c2 100644 --- a/sources_non_forked/ale/doc/ale-verilog.txt +++ b/sources_non_forked/ale/doc/ale-verilog.txt @@ -3,7 +3,10 @@ ALE Verilog/SystemVerilog Integration *ale-verilog-options* =============================================================================== -ALE can use four different linters for Verilog HDL: +ALE can use five different linters for Verilog HDL: + + HDL Checker + Using `hdl_checker --lsp` iverilog: Using `iverilog -t null -Wall` @@ -26,6 +29,9 @@ defining 'g:ale_linters' variable: \ let g:ale_linters = {'systemverilog' : ['verilator'],} < +=============================================================================== +General notes + Linters/compilers that utilize a "work" directory for analyzing designs- such as ModelSim and Vivado- can be passed the location of these directories as part of their respective option strings listed below. This is useful for @@ -40,6 +46,16 @@ changing. This can happen in the form of hangs or crashes. To help prevent this when using these linters, it may help to run linting less frequently; for example, only when a file is saved. +HDL Checker is an alternative for some of the issues described above. It wraps +around ghdl, Vivado and ModelSim/Questa and, when using the latter, it can +handle mixed language (VHDL, Verilog, SystemVerilog) designs. + +=============================================================================== +hdl-checker *ale-verilog-hdl-checker* + +See |ale-vhdl-hdl-checker| + + =============================================================================== iverilog *ale-verilog-iverilog* diff --git a/sources_non_forked/ale/doc/ale-vhdl.txt b/sources_non_forked/ale/doc/ale-vhdl.txt index 3fea947d..c2870240 100644 --- a/sources_non_forked/ale/doc/ale-vhdl.txt +++ b/sources_non_forked/ale/doc/ale-vhdl.txt @@ -3,10 +3,10 @@ ALE VHDL Integration *ale-vhdl-options* =============================================================================== -ALE can use three different linters for VHDL: +ALE can use four different linters for VHDL: - iverilog: - Using `iverilog -t null -Wall` + ghdl: + Using `ghdl --std=08` ModelSim/Questa Using `vcom -2008 -quiet -lint` @@ -14,8 +14,15 @@ ALE can use three different linters for VHDL: Vivado Using `xvhdl --2008` -Note all linters default to VHDL-2008 support. This, and other options, can be -changed with each linter's respective option variable. + HDL Checker + Using `hdl_checker --lsp` + +=============================================================================== +General notes + +ghdl, ModelSim/Questa and Vivado linters default to VHDL-2008 support. This, +and other options, can be changed with each linter's respective option +variable. Linters/compilers that utilize a "work" directory for analyzing designs- such as ModelSim and Vivado- can be passed the location of these directories as @@ -31,6 +38,10 @@ changing. This can happen in the form of hangs or crashes. To help prevent this when using these linters, it may help to run linting less frequently; for example, only when a file is saved. +HDL Checker is an alternative for some of the issues described above. It wraps +around ghdl, Vivado and ModelSim/Questa and, when using the latter, it can +handle mixed language (VHDL, Verilog, SystemVerilog) designs. + =============================================================================== ghdl *ale-vhdl-ghdl* @@ -50,6 +61,60 @@ g:ale_vhdl_ghdl_options *g:ale_vhdl_ghdl_options* This variable can be changed to modify the flags/options passed to 'ghdl'. +=============================================================================== +hdl-checker *ale-vhdl-hdl-checker* + +HDL Checker is a wrapper for VHDL/Verilg/SystemVerilog tools that aims to +reduce the boilerplate code needed to set things up. It can automatically +infer libraries for VHDL sources, determine the compilation order and provide +some static checks. + +You can install it using pip: +> + $ pip install hdl-checker + +`hdl-checker` will be run from a detected project root, determined by the +following methods, in order: + +1. Find the first directory containing a configuration file (see + |g:ale_hdl_checker_config_file|) +2. If no configuration file can be found, find the first directory containing + a folder named `'.git' +3. If no such folder is found, use the directory of the current buffer + + +g:ale_hdl_checker_executable + *g:ale_hdl_checker_executable* + *b:ale_hdl_checker_executable* + Type: |String| + Default: `'hdl_checker'` + + This variable can be changed to the path to the 'hdl_checker' executable. + + +g:ale_hdl_checker_options *g:ale_hdl_checker_options* + *b:ale_hdl_checker_options* + Type: |String| + Default: `''` + + This variable can be changed to modify the flags/options passed to the + 'hdl_checker' server startup command. + + +g:ale_hdl_checker_config_file *g:ale_hdl_checker_config_file* + *b:ale_hdl_checker_config_file* + Type: |String| + Default: `'.hdl_checker.config'` (Unix), + `'_hdl_checker.config'` (Windows) + + This variable can be changed to modify the config file HDL Checker will try + to look for. It will also affect how the project's root directory is + determined (see |ale-vhdl-hdl-checker|). + + More info on the configuration file format can be found at: + https://github.com/suoto/hdl_checker/wiki/Setting-up-a-project + + =============================================================================== vcom *ale-vhdl-vcom* diff --git a/sources_non_forked/ale/doc/ale-vim.txt b/sources_non_forked/ale/doc/ale-vim.txt index 772bad23..f85b43eb 100644 --- a/sources_non_forked/ale/doc/ale-vim.txt +++ b/sources_non_forked/ale/doc/ale-vim.txt @@ -2,6 +2,61 @@ ALE Vim Integration *ale-vim-options* +=============================================================================== +vimls *ale-vim-vimls* + + The `vim-language-server` is the engine that powers VimL editor support + using the Language Server Protocol. See the installation instructions: + https://github.com/iamcco/vim-language-server#install + +g:ale_vim_vimls_executable *g:ale_vim_vimls_executable* + *b:ale_vim_vimls_executable* + Type: |String| + Default: `'vim-language-server'` + + This option can be set to change the executable path for vimls. + + +g:ale_vim_vimls_config *g:ale_vim_vimls_config* + *b:ale_vim_vimls_config* + Type: |Dictionary| + Default: `{}` + + Dictionary containing configuration settings that will be passed to the + language server. For example: > + { + \ 'vim': { + \ 'iskeyword': '@,48-57,_,192-255,-#', + \ 'vimruntime': '', + \ 'runtimepath': '', + \ 'diagnostic': { + \ 'enable': v:true + \ }, + \ 'indexes': { + \ 'runtimepath': v:true, + \ 'gap': 100, + \ 'count': 3, + \ 'projectRootPatterns' : ['.git', 'autoload', 'plugin'] + \ }, + \ 'suggest': { + \ 'fromVimruntime': v:true, + \ 'fromRuntimepath': v:false + \ }, + \ } + \} +< + Consult the vim-language-server documentation for more information about + settings. + + +g:ale_vim_vimls_use_global *g:ale_vim_vimls_use_global* + *b:ale_vim_vimls_use_global* + Type: |Number| + Default: `get(g:, 'ale_use_global_executables', 0)` + + See |ale-integrations-local-executables| + + =============================================================================== vint *ale-vim-vint* diff --git a/sources_non_forked/ale/doc/ale-yaml.txt b/sources_non_forked/ale/doc/ale-yaml.txt index c9a12ea1..61bfc139 100644 --- a/sources_non_forked/ale/doc/ale-yaml.txt +++ b/sources_non_forked/ale/doc/ale-yaml.txt @@ -15,7 +15,6 @@ Install prettier either globally or locally: > npm install prettier -g # global npm install prettier # local < - =============================================================================== swaglint *ale-yaml-swaglint* @@ -49,6 +48,43 @@ g:ale_yaml_swaglint_use_global *g:ale_yaml_swaglint_use_global* See |ale-integrations-local-executables| +=============================================================================== +yamlfix *ale-yaml-yamlfix* + +Website: https://lyz-code.github.io/yamlfix + + +Installation +------------------------------------------------------------------------------- + +Install yamlfix: > + + pip install yamlfix +< + +Options +------------------------------------------------------------------------------- +g:ale_yaml_yamlfix_executable *g:ale_yaml_yamlfix_executable* + *b:ale_yaml_yamlfix_executable* + Type: |String| + Default: `'yamlfix'` + + See |ale-integrations-local-executables| + + +g:ale_yaml_yamlfix_options *g:ale_yaml_yamlfix_options* + *b:ale_yaml_yamlfix_options* + Type: |String| + Default: `''` + + This variable can be set to pass extra options to yamlfix. + +g:ale_yaml_yamlfix_use_global *g:ale_yaml_yamlfix_use_global* + *b:ale_yaml_yamlfix_use_global* + Type: |Number| + Default: `get(g:, 'ale_use_global_executables', 0)` + + See |ale-integrations-local-executables| =============================================================================== yamllint *ale-yaml-yamllint* diff --git a/sources_non_forked/ale/doc/ale-zig.txt b/sources_non_forked/ale/doc/ale-zig.txt new file mode 100644 index 00000000..70a53bbb --- /dev/null +++ b/sources_non_forked/ale/doc/ale-zig.txt @@ -0,0 +1,33 @@ +=============================================================================== +ALE Zig Integration *ale-zig-options* + *ale-integration-zig* + +=============================================================================== +Integration Information + + Currently, the only supported linter for zig is zls. + +=============================================================================== +zls *ale-zig-zls* + +g:ale_zig_zls_executable *g:ale_zig_zls_executable* + *b:ale_zig_zls_executable* + Type: |String| + Default: `'zls'` + + This variable can be modified to change the executable path for `zls`. + + +g:ale_zig_zls_config *g:ale_zig_zls_config* + *b:ale_zig_zls_config* + Type: |Dictionary| + Default: `{}` + + WARNING: As of writing, zls does not support receiving configuration + from the client. This variable is a PLACEHOLDER until it does. + + Dictionary with configuration settings for zls. + + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale.txt b/sources_non_forked/ale/doc/ale.txt index eafbc119..f9f40d12 100644 --- a/sources_non_forked/ale/doc/ale.txt +++ b/sources_non_forked/ale/doc/ale.txt @@ -9,8 +9,9 @@ CONTENTS *ale-contents* 1. Introduction.........................|ale-introduction| 2. Supported Languages & Tools..........|ale-support| 3. Linting..............................|ale-lint| - 3.1 Adding Language Servers...........|ale-lint-language-servers| - 3.2 Other Sources.....................|ale-lint-other-sources| + 3.1 Linting On Other Machines.........|ale-lint-other-machines| + 3.2 Adding Language Servers...........|ale-lint-language-servers| + 3.3 Other Sources.....................|ale-lint-other-sources| 4. Fixing Problems......................|ale-fix| 5. Language Server Protocol Support.....|ale-lsp| 5.1 Completion........................|ale-completion| @@ -19,6 +20,7 @@ CONTENTS *ale-contents* 5.4 Find References...................|ale-find-references| 5.5 Hovering..........................|ale-hover| 5.6 Symbol Search.....................|ale-symbol-search| + 5.7 Refactoring: Rename, Actions......|ale-refactor| 6. Global Options.......................|ale-options| 6.1 Highlights........................|ale-highlights| 7. Linter/Fixer Options.................|ale-integration-options| @@ -127,7 +129,7 @@ their relevant options. * By showing balloons for your mouse cursor - |g:ale_set_balloons| Please consult the documentation for each option, which can reveal some other -ways of tweaking the behaviour of each way of displaying problems. You can +ways of tweaking the behavior of each way of displaying problems. You can disable or enable whichever options you prefer. Most settings can be configured for each buffer. (|b:| instead of |g:|), @@ -146,9 +148,68 @@ ALE offers several options for controlling which linters are run. * Disabling only a subset of linters. - |g:ale_linters_ignore| * Disabling LSP linters and `tsserver`. - |g:ale_disable_lsp| +You can stop ALE any currently running linters with the |ALELintStop| command. +Any existing problems will be kept. ------------------------------------------------------------------------------- -3.1 Adding Language Servers *ale-lint-language-servers* +3.1 Linting On Other Machines *ale-lint-other-machines* + +ALE offers support for running linters or fixers on files you are editing +locally on other machines, so long as the other machine has access to the file +you are editing. This could be a linter or fixer run inside of a Docker image, +running in a virtual machine, running on a remote server, etc. + +In order to run tools on other machines, you will need to configure your tools +to run via scripts that execute commands on those machines, such as by setting +the ALE `_executable` options for those tools to a path for a script to run, +or by using |g:ale_command_wrapper| to specify a script to wrap all commands +that are run by ALE, before they are executed. For tools that ALE runs where +ALE looks for locally installed executables first, you may need to set the +`_use_global` options for those tools to `1`, or you can set +|g:ale_use_global_executables| to `1` before ALE is loaded to only use global +executables for all tools. + +In order for ALE to properly lint or fix files which are running on another +file system, you must provide ALE with |List|s of strings for mapping paths to +and from your local file system and the remote file system, such as the file +system of your Docker container. See |g:ale_filename_mappings| for all of the +different ways these filename mappings can be configured. + +For example, you might configure `pylint` to run via Docker by creating a +script like so. > + + #!/usr/bin/env bash + + exec docker run -i --rm -v "$(pwd):/data" cytopia/pylint "$@" +< + +You will run to run Docker commands with `-i` in order to read from stdin. + +With the above script in mind, you might configure ALE to lint your Python +project with `pylint` by providing the path to the script to execute, and +mappings which describe how to between the two file systems in your +`python.vim` |ftplugin| file, like so: > + + if expand('%:p') =~# '^/home/w0rp/git/test-pylint/' + let b:ale_linters = ['pylint'] + let b:ale_python_pylint_use_global = 1 + " This is the path to the script above. + let b:ale_python_pylint_executable = '/home/w0rp/git/test-pylint/pylint.sh' + " /data matches the path in Docker. + let b:ale_filename_mappings = { + \ 'pylint': [ + \ ['/home/w0rp/git/test-pylint', '/data'], + \ ], + \} + endif +< + +You might consider using a Vim plugin for loading Vim configuration files +specific to each project, if you have a lot of projects to manage. + + +------------------------------------------------------------------------------- +3.2 Adding Language Servers *ale-lint-language-servers* ALE comes with many default configurations for language servers, so they can be detected and run automatically. ALE can connect to other language servers @@ -189,7 +250,7 @@ address to connect to instead. > ------------------------------------------------------------------------------- -3.2 Other Sources *ale-lint-other-sources* +3.3 Other Sources *ale-lint-other-sources* Problems for a buffer can be taken from other sources and rendered by ALE. This allows ALE to be used in combination with other plugins which also want @@ -246,7 +307,7 @@ A plugin might integrate its own checks with ALE like so: > function! WorkDone(buffer, results) abort " Send results to ALE after they have been collected. - call ale#other_source#ShowResults(buffer, 'some-name', a:results) + call ale#other_source#ShowResults(a:buffer, 'some-name', a:results) endfunction < @@ -287,6 +348,8 @@ are supported for running the commands. file will be created, containing the lines from the file after previous adjustment have been done. + See |ale-command-format-strings| for formatting options. + `read_temporary_file` When set to `1`, ALE will read the contents of the temporary file created for `%t`. This option can be used for commands which need to modify some file on disk in @@ -356,6 +419,10 @@ by default. Fixers can be disabled on save with |g:ale_fix_on_save_ignore|. They will still be run when you manually run |ALEFix|. +Fixers can be run on another machines, just like linters, such as fixers run +from a Docker container, running in a virtual machine, running a remote +server, etc. See |ale-lint-other-machines|. + =============================================================================== 5. Language Server Protocol Support *ale-lsp* @@ -402,12 +469,56 @@ is loaded. The delay for completion can be configured with |g:ale_completion_delay|. This setting should not be enabled if you wish to use ALE as a completion source for other plugins. +ALE automatic completion will not work when 'paste' is active. Only set +'paste' when you are copy and pasting text into your buffers. + +ALE automatic completion will interfere with default insert completion with +`CTRL-N` and so on (|compl-vim|). You can write your own keybinds and a +function in your |vimrc| file to force insert completion instead, like so: > + + function! SmartInsertCompletion() abort + " Use the default CTRL-N in completion menus + if pumvisible() + return "\" + endif + + " Exit and re-enter insert mode, and use insert completion + return "\a\" + endfunction + + inoremap =SmartInsertCompletion() +< ALE provides an 'omnifunc' function |ale#completion#OmniFunc| for triggering completion manually with CTRL-X CTRL-O. |i_CTRL-X_CTRL-O| > " Use ALE's function for omnicompletion. set omnifunc=ale#completion#OmniFunc < + *ale-completion-fallback* + +You can write your own completion function and fallback on other methods of +completion by checking if there are no results that ALE can determine. For +example, for Python code, you could fall back on the `python3complete` +function. > + + function! TestCompletionFunc(findstart, base) abort + let l:result = ale#completion#OmniFunc(a:findstart, a:base) + + " Check if ALE couldn't find anything. + if (a:findstart && l:result is -3) + \|| (!a:findstart && empty(l:result)) + " Defer to another omnifunc if ALE couldn't find anything. + return python3complete#Complete(a:findstart, a:base) + endif + + return l:result + endfunction + + set omnifunc=TestCompletionFunc +< +See |complete-functions| for documentation on how to write completion +functions. + ALE will only suggest so many possible matches for completion. The maximum number of items can be controlled with |g:ale_completion_max_suggestions|. @@ -418,9 +529,21 @@ The |ALEComplete| command can be used to show completion suggestions manually, even when |g:ale_completion_enabled| is set to `0`. For manually requesting completion information with Deoplete, consult Deoplete's documentation. -When working with TypeScript files, ALE by can support automatic imports -from external modules. This behavior can be enabled by setting the -|g:ale_completion_tsserver_autoimport| variable to `1`. +ALE by can support automatic imports from external modules. This behavior can +be enabled by setting the |g:ale_completion_autoimport| variable to `1`. + +You can manually request imports for symbols at the cursor with the +|ALEImport| command. The word at the cursor must be an exact match for some +potential completion result which includes additional text to insert into the +current buffer, which ALE will assume is code for an import line. This command +can be useful when your code already contains something you need to import. + +You can execute other commands whenever ALE inserts some completion text with +the |ALECompletePost| event. + +When working with TypeScript files, ALE can remove warnings from your +completions by setting the |g:ale_completion_tsserver_remove_warnings| +variable to 1. *ale-completion-completeopt-bug* @@ -478,12 +601,9 @@ would like to use. An example here shows the available options for symbols > ALE supports jumping to the files and locations where symbols are defined through any enabled LSP linters. The locations ALE will jump to depend on the -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. +information returned by LSP servers. The |ALEGoToDefinition| command will jump +to the definition of symbols under the cursor. See the documentation for the +command for configuring how the location will be displayed. ALE will update Vim's |tagstack| automatically unless |g:ale_update_tagstack| is set to `0`. @@ -493,28 +613,17 @@ set to `0`. ALE supports jumping to the files and locations where symbols' types are defined through any enabled LSP linters. The locations ALE will jump to depend -on the information returned by LSP servers. The following commands are -supported: - -|ALEGoToTypeDefinition| - Open the definition of the symbol's type under - the cursor. -|ALEGoToTypeDefinitionInTab| - The same, but for opening the file in a new tab. -|ALEGoToTypeDefinitionInSplit| - The same, but in a new split. -|ALEGoToTypeDefinitionInVSplit| - The same, but in a new vertical split. - +on the information returned by LSP servers. The |ALEGoToTypeDefinition| +command will jump to the definition of symbols under the cursor. See the +documentation for the command for configuring how the location will be +displayed. ------------------------------------------------------------------------------- 5.4 Find References *ale-find-references* -ALE supports finding references for symbols though any enabled LSP linters. -ALE will display a preview window showing the places where a symbol is -referenced in a codebase when a command is run. The following commands are -supported: - -|ALEFindReferences| - Find references for the word under the cursor. - -Options: - `-relative` Show file paths in the results relative to the working dir +ALE supports finding references for symbols though any enabled LSP linters +with the |ALEFindReferences| command. See the documentation for the command +for a full list of options. ------------------------------------------------------------------------------- 5.5 Hovering *ale-hover* @@ -524,6 +633,10 @@ at the cursor taken from LSP linters. The following commands are supported: |ALEHover| - Print information about the symbol at the cursor. +Truncated information will be displayed when the cursor rests on a symbol by +default, as long as there are no problems on the same line. You can disable +this behavior by setting |g:ale_hover_cursor| to `0`. + If |g:ale_set_balloons| is set to `1` and your version of Vim supports the |balloon_show()| function, then "hover" information also show up when you move the mouse over a symbol in a buffer. Diagnostic information will take priority @@ -553,14 +666,38 @@ Documentation for symbols at the cursor can be retrieved using the ------------------------------------------------------------------------------- 5.6 Symbol Search *ale-symbol-search* -ALE supports searching for workspace symbols via LSP linters. The following -commands are supported: +ALE supports searching for workspace symbols via LSP linters with the +|ALESymbolSearch| command. See the documentation for the command +for a full list of options. -|ALESymbolSearch| - Search for symbols in the workspace. +------------------------------------------------------------------------------- +5.7 Refactoring: Rename, Actions *ale-refactor* -Options: - `-relative` Show file paths in the results relative to the working dir +ALE supports renaming symbols in code such as variables or class names with +the |ALERename| command. +|ALECodeAction| will execute actions on the cursor or applied to a visual +range selection, such as automatically fixing errors. + +Actions will appear in the right click mouse menu by default for GUI versions +of Vim, unless disabled by setting |g:ale_popup_menu_enabled| to `0`. + +Make sure to set your Vim to move the cursor position whenever you right +click, and enable the mouse menu: > + + set mouse=a + set mousemodel=popup_setpos +< +You may wish to remove some other menu items you don't want to see: > + + silent! aunmenu PopUp.Select\ Word + silent! aunmenu PopUp.Select\ Sentence + silent! aunmenu PopUp.Select\ Paragraph + silent! aunmenu PopUp.Select\ Line + silent! aunmenu PopUp.Select\ Block + silent! aunmenu PopUp.Select\ Blockwise + silent! aunmenu PopUp.Select\ All +< =============================================================================== 6. Global Options *ale-options* @@ -666,7 +803,7 @@ g:ale_completion_delay *g:ale_completion_delay* g:ale_completion_enabled *g:ale_completion_enabled* -b:ale_completion_enabled *b:ale_completion_enabled* + *b:ale_completion_enabled* Type: |Number| Default: `0` @@ -679,6 +816,9 @@ b:ale_completion_enabled *b:ale_completion_enabled* This setting should not be enabled if you wish to use ALE as a completion source for other completion plugins. + ALE automatic completion will not work when 'paste' is active. Only set + 'paste' when you are copy and pasting text into your buffers. + A buffer-local version of this setting `b:ale_completion_enabled` can be set to `0` to disable ALE's automatic completion support for a single buffer. ALE's completion support must be enabled globally to be enabled locally. @@ -686,7 +826,18 @@ b:ale_completion_enabled *b:ale_completion_enabled* See |ale-completion| -g:ale_completion_tsserver_autoimport *g:ale_completion_tsserver_autoimport* + *g:ale_completion_tsserver_remove_warnings* +g:ale_completion_tsserver_remove_warnings + + Type: Number + Default: `0` + + When this option is set to `0`, ALE will return all completion items, + including those that are a warning. Warnings can be excluded from completed + items by setting it to `1`. + + +g:ale_completion_autoimport *g:ale_completion_autoimport* Type: Number Default: `0` @@ -793,6 +944,16 @@ g:ale_cursor_detail *g:ale_cursor_detail* loaded for messages to be displayed. See |ale-lint-settings-on-startup|. +g:ale_default_navigation *g:ale_default_navigation* + *b:ale_default_navigation* + + Type: |String| + Default: `'buffer'` + + The default method for navigating away from the current buffer to another + buffer, such as for |ALEFindReferences|, or |ALEGoToDefinition|. + + g:ale_disable_lsp *g:ale_disable_lsp* *b:ale_disable_lsp* @@ -845,7 +1006,7 @@ g:ale_echo_msg_error_str *g:ale_echo_msg_error_str* g:ale_echo_msg_format *g:ale_echo_msg_format* -b:ale_echo_msg_format *b:ale_echo_msg_format* + *b:ale_echo_msg_format* Type: |String| Default: `'%code: %%s'` @@ -923,6 +1084,21 @@ g:ale_enabled *g:ale_enabled* See |g:ale_pattern_options| for more information on that option. +g:ale_exclude_highlights *g:ale_exclude_highlights* + *b:ale_exclude_highlights* + + Type: |List| + Default: `[]` + + A list of regular expressions for matching against highlight messages to + remove. For example: > + + " Do not highlight messages matching strings like these. + let b:ale_exclude_highlights = ['line too long', 'foo.*bar'] +< + See also: |g:ale_set_highlights| + + g:ale_fixers *g:ale_fixers* *b:ale_fixers* @@ -946,7 +1122,7 @@ g:ale_fixers *g:ale_fixers* < g:ale_fix_on_save *g:ale_fix_on_save* -b:ale_fix_on_save *b:ale_fix_on_save* + *b:ale_fix_on_save* Type: |Number| Default: `0` @@ -968,7 +1144,7 @@ b:ale_fix_on_save *b:ale_fix_on_save* g:ale_fix_on_save_ignore *g:ale_fix_on_save_ignore* -b:ale_fix_on_save_ignore *b:ale_fix_on_save_ignore* + *b:ale_fix_on_save_ignore* Type: |Dictionary| or |List| Default: `{}` @@ -1031,9 +1207,27 @@ g:ale_history_log_output *g:ale_history_log_output* if you want to save on some memory usage. +g:ale_hover_cursor *g:ale_hover_cursor* + + Type: |Number| + Default: `1` + + If set to `1`, ALE will show truncated information in the echo line about + the symbol at the cursor automatically when the |CursorHold| event is fired. + The delay before requesting hover information is based on 'updatetime', as + with all |CursorHold| events. + + If there's a problem on the line where the cursor is resting, ALE will not + show any hover information. + + See |ale-hover| for more information on hover information. + + This setting must be set to `1` before ALE is loaded for this behavior + to be enabled. See |ale-lint-settings-on-startup|. + + g:ale_hover_to_preview *g:ale_hover_to_preview* *b:ale_hover_to_preview* - Type: |Number| Default: `0` @@ -1068,7 +1262,7 @@ g:ale_list_window_size *g:ale_list_window_size* g:ale_lint_delay *g:ale_lint_delay* - + *b:ale_lint_delay* Type: |Number| Default: `200` @@ -1076,6 +1270,9 @@ g:ale_lint_delay *g:ale_lint_delay* be run after text is changed. This option is only meaningful with the |g:ale_lint_on_text_changed| variable set to `always`, `insert`, or `normal`. + A buffer-local option, `b:ale_lint_delay`, can be set to change the delay + for different buffers, such as in |ftplugin| files. + g:ale_lint_on_enter *g:ale_lint_on_enter* @@ -1188,6 +1385,7 @@ g:ale_linter_aliases *g:ale_linter_aliases* \ 'csh': 'sh', \ 'javascriptreact': ['javascript', 'jsx'], \ 'plaintex': 'tex', + \ 'ps1': 'powershell', \ 'rmarkdown': 'r', \ 'rmd': 'r', \ 'systemverilog': 'verilog', @@ -1232,6 +1430,90 @@ g:ale_linter_aliases *g:ale_linter_aliases* < No linters will be loaded when the buffer's filetype is empty. + +g:ale_filename_mappings *g:ale_filename_mappings* + *b:ale_filename_mappings* + + Type: |Dictionary| or |List| + Default: `{}` + + Either a |Dictionary| mapping a linter or fixer name, as displayed in + |:ALEInfo|, to a |List| of two-item |List|s for filename mappings, or just a + |List| of two-item |List|s. When given some paths to files, the value of + this setting will be used to convert filenames on a local file system to + filenames on some remote file system, such as paths in a Docker image, + virtual machine, or network drive. + + For example: > + + let g:ale_filename_mappings = { + \ 'pylint': [ + \ ['/home/john/proj', '/data'], + \ ], + \} +< + With the above configuration, a filename such as `/home/john/proj/foo.py` + will be provided to the linter/fixer as `/data/foo.py`, and paths parsed + from linter results such as `/data/foo.py` will be converted back to + `/home/john/proj/foo.py`. + + You can use `*` as to apply a |List| of filename mappings to all other + linters or fixers not otherwise matched. > + + " Use one List of paths for pylint. + " Use another List of paths for everything else. + let g:ale_filename_mappings = { + \ 'pylint': [ + \ ['/home/john/proj', '/data'], + \ ], + \ '*': [ + \ ['/home/john/proj', '/other-data'], + \ ], + \} +< + If you just want every single linter or fixer to use the same filename + mapping, you can just use a |List|. > + + " Same as above, but for ALL linters and fixers. + let g:ale_filename_mappings = [ + \ ['/home/john/proj', '/data'], + \] +< + You can provide many such filename paths for multiple projects. Paths are + matched by checking if the start of a file path matches the given strings, + in a case-sensitive manner. Earlier entries in the |List| will be tried + before later entries when mapping to a given file system. + + Buffer-local options can be set to the same values to override the global + options, such as in |ftplugin| files. + + NOTE: Only fixers registered with a short name can support filename mapping + by their fixer names. See |ale-fix|. Filename mappings set for all tools by + using only a |List| for the setting will also be applied to fixers not in + the registry. + + NOTE: In order for this filename mapping to work correctly, linters and + fixers must exclusively determine paths to files to lint or fix via ALE + command formatting as per |ale-command-format-strings|, and paths parsed + from linter files must be provided in `filename` keys if a linter returns + results for more than one file at a time, as per |ale-loclist-format|. If + you discover a linter or fixer which does not behave properly, please report + it as an issue. + + If you are running a linter or fixer through Docker or another remote file + system, you may have to mount your temporary directory, which you can + discover with the following command: > + + :echo fnamemodify(tempname(), ':h:h') +< + You should provide a mapping from this temporary directory to whatever you + mount this directory to in Docker, or whatever remote file system you are + working with. + + You can inspect the filename mappings ALE will use with the + |ale#GetFilenameMappings()| function. + + g:ale_linters *g:ale_linters* *b:ale_linters* Type: |Dictionary| @@ -1251,8 +1533,8 @@ g:ale_linters *g:ale_linters* \ 'help': [], \ 'perl': ['perlcritic'], \ 'perl6': [], - \ 'python': ['flake8', 'mypy', 'pylint'], - \ 'rust': ['cargo'], + \ 'python': ['flake8', 'mypy', 'pylint', 'pyright'], + \ 'rust': ['cargo', 'rls'], \ 'spec': [], \ 'text': [], \ 'vue': ['eslint', 'vls'], @@ -1344,7 +1626,7 @@ g:ale_list_vertical *g:ale_list_vertical* g:ale_loclist_msg_format *g:ale_loclist_msg_format* -b:ale_loclist_msg_format *b:ale_loclist_msg_format* + *b:ale_loclist_msg_format* Type: |String| Default: `g:ale_echo_msg_format` @@ -1396,7 +1678,7 @@ g:ale_lsp_show_message_severity *g:ale_lsp_show_message_severity* g:ale_lsp_root *g:ale_lsp_root* -b:ale_lsp_root *b:ale_lsp_root* + *b:ale_lsp_root* Type: |Dictionary| or |String| Default: {} @@ -1412,6 +1694,7 @@ b:ale_lsp_root *b:ale_lsp_root* If neither variable yields a result, a linter-specific function is invoked to detect a project root. If this, too, yields no result, the linter is disabled. + g:ale_max_buffer_history_size *g:ale_max_buffer_history_size* Type: |Number| @@ -1520,6 +1803,19 @@ g:ale_pattern_options_enabled *g:ale_pattern_options_enabled* will not set buffer variables per |g:ale_pattern_options|. +g:ale_popup_menu_enabled *g:ale_popup_menu_enabled* + + Type: |Number| + Default: `has('gui_running')` + + When this option is set to `1`, ALE will show code actions and rename + capabilities in the right click mouse menu when there's a LSP server or + tsserver available. See |ale-refactor|. + + This setting must be set to `1` before ALE is loaded for this behavior + to be enabled. See |ale-lint-settings-on-startup|. + + g:ale_rename_tsserver_find_in_comments *g:ale_rename_tsserver_find_in_comments* Type: |Number| @@ -1544,7 +1840,7 @@ g:ale_rename_tsserver_find_in_strings *g:ale_rename_tsserver_find_in_strings* g:ale_set_balloons *g:ale_set_balloons* *b:ale_set_balloons* - Type: |Number| + Type: |Number| or |String| Default: `has('balloon_eval') && has('gui_running')` When this option is set to `1`, balloon messages will be displayed for @@ -1555,6 +1851,13 @@ g:ale_set_balloons *g:ale_set_balloons* supporting "Hover" information, per |ale-hover|, then brief information about the symbol under the cursor will be displayed in a balloon. + This option can be set to `'hover'` to only enable balloons for hover + message, so diagnostics are never shown in balloons. You may wish to + configure use this setting only in GUI Vim like so: > + + let g:ale_set_balloons = has('gui_running') ? 'hover' : 0 +< + Balloons can be enabled for terminal versions of Vim that support balloons, but some versions of Vim will produce strange mouse behavior when balloons are enabled. To configure balloons for your terminal, you should first @@ -1609,6 +1912,8 @@ g:ale_set_highlights *g:ale_set_highlights* match highlights, whereas the line highlights when signs are enabled will run to the edge of the screen. + Highlights can be excluded with the |g:ale_exclude_highlights| option. + g:ale_set_loclist *g:ale_set_loclist* @@ -1875,7 +2180,8 @@ g:ale_virtualtext_cursor *g:ale_virtualtext_cursor* g:ale_virtualtext_delay *g:ale_virtualtext_delay* -b:ale_virtualtext_delay *b:ale_virtualtext_delay* + *b:ale_virtualtext_delay* + Type: |Number| Default: `10` @@ -1894,7 +2200,7 @@ g:ale_virtualtext_prefix *g:ale_virtualtext_prefix* Prefix to be used with |g:ale_virtualtext_cursor|. g:ale_virtualenv_dir_names *g:ale_virtualenv_dir_names* -b:ale_virtualenv_dir_names *b:ale_virtualenv_dir_names* + *b:ale_virtualenv_dir_names* Type: |List| Default: `['.env', '.venv', 'env', 've-py3', 've', 'virtualenv', 'venv']` @@ -1908,7 +2214,7 @@ b:ale_virtualenv_dir_names *b:ale_virtualenv_dir_names* g:ale_warn_about_trailing_blank_lines *g:ale_warn_about_trailing_blank_lines* -b:ale_warn_about_trailing_blank_lines *b:ale_warn_about_trailing_blank_lines* + *b:ale_warn_about_trailing_blank_lines* Type: |Number| Default: `1` @@ -1920,7 +2226,7 @@ b:ale_warn_about_trailing_blank_lines *b:ale_warn_about_trailing_blank_lines* g:ale_warn_about_trailing_whitespace *g:ale_warn_about_trailing_whitespace* -b:ale_warn_about_trailing_whitespace *b:ale_warn_about_trailing_whitespace* + *b:ale_warn_about_trailing_whitespace* Type: |Number| Default: `1` @@ -2259,19 +2565,21 @@ documented in additional help files. gcc...................................|ale-asm-gcc| awk.....................................|ale-awk-options| gawk..................................|ale-awk-gawk| + bats....................................|ale-bats-options| + shellcheck............................|ale-bats-shellcheck| bib.....................................|ale-bib-options| bibclean..............................|ale-bib-bibclean| c.......................................|ale-c-options| - clang.................................|ale-c-clang| + astyle................................|ale-c-astyle| + cc....................................|ale-c-cc| + ccls..................................|ale-c-ccls| clangd................................|ale-c-clangd| clang-format..........................|ale-c-clangformat| clangtidy.............................|ale-c-clangtidy| cppcheck..............................|ale-c-cppcheck| cquery................................|ale-c-cquery| flawfinder............................|ale-c-flawfinder| - gcc...................................|ale-c-gcc| uncrustify............................|ale-c-uncrustify| - ccls..................................|ale-c-ccls| chef....................................|ale-chef-options| cookstyle.............................|ale-chef-cookstyle| foodcritic............................|ale-chef-foodcritic| @@ -2284,9 +2592,11 @@ documented in additional help files. cmakelint.............................|ale-cmake-cmakelint| cmake-format..........................|ale-cmake-cmakeformat| cpp.....................................|ale-cpp-options| - clang.................................|ale-cpp-clang| - clangd................................|ale-cpp-clangd| + astyle................................|ale-cpp-astyle| + cc....................................|ale-cpp-cc| + ccls..................................|ale-cpp-ccls| clangcheck............................|ale-cpp-clangcheck| + clangd................................|ale-cpp-clangd| clang-format..........................|ale-cpp-clangformat| clangtidy.............................|ale-cpp-clangtidy| clazy.................................|ale-cpp-clazy| @@ -2294,9 +2604,7 @@ documented in additional help files. cpplint...............................|ale-cpp-cpplint| cquery................................|ale-cpp-cquery| flawfinder............................|ale-cpp-flawfinder| - gcc...................................|ale-cpp-gcc| uncrustify............................|ale-cpp-uncrustify| - ccls..................................|ale-cpp-ccls| c#......................................|ale-cs-options| csc...................................|ale-cs-csc| mcs...................................|ale-cs-mcs| @@ -2331,6 +2639,7 @@ documented in additional help files. elm-make..............................|ale-elm-elm-make| erlang..................................|ale-erlang-options| dialyzer..............................|ale-erlang-dialyzer| + elvis.................................|ale-erlang-elvis| erlc..................................|ale-erlang-erlc| syntaxerl.............................|ale-erlang-syntaxerl| eruby...................................|ale-eruby-options| @@ -2357,6 +2666,7 @@ documented in additional help files. gometalinter..........................|ale-go-gometalinter| gopls.................................|ale-go-gopls| govet.................................|ale-go-govet| + revive................................|ale-go-revive| staticcheck...........................|ale-go-staticcheck| graphql.................................|ale-graphql-options| eslint................................|ale-graphql-eslint| @@ -2383,6 +2693,7 @@ documented in additional help files. stack-ghc.............................|ale-haskell-stack-ghc| stylish-haskell.......................|ale-haskell-stylish-haskell| hie...................................|ale-haskell-hie| + ormolu................................|ale-haskell-ormolu| hcl.....................................|ale-hcl-options| terraform-fmt.........................|ale-hcl-terraform-fmt| html....................................|ale-html-options| @@ -2442,7 +2753,9 @@ documented in additional help files. lua.....................................|ale-lua-options| luac..................................|ale-lua-luac| luacheck..............................|ale-lua-luacheck| + luafmt................................|ale-lua-luafmt| markdown................................|ale-markdown-options| + markdownlint..........................|ale-markdown-markdownlint| mdl...................................|ale-markdown-mdl| prettier..............................|ale-markdown-prettier| remark-lint...........................|ale-markdown-remark-lint| @@ -2492,6 +2805,8 @@ documented in additional help files. psalm.................................|ale-php-psalm| php-cs-fixer..........................|ale-php-php-cs-fixer| php...................................|ale-php-php| + tlint.................................|ale-php-tlint| + intelephense..........................|ale-php-intelephense| po......................................|ale-po-options| write-good............................|ale-po-write-good| pod.....................................|ale-pod-options| @@ -2517,6 +2832,7 @@ documented in additional help files. pyrex (cython)..........................|ale-pyrex-options| cython................................|ale-pyrex-cython| python..................................|ale-python-options| + autoimport............................|ale-python-autoimport| autopep8..............................|ale-python-autopep8| bandit................................|ale-python-bandit| black.................................|ale-python-black| @@ -2531,12 +2847,14 @@ documented in additional help files. pylint................................|ale-python-pylint| pyls..................................|ale-python-pyls| pyre..................................|ale-python-pyre| + pyright...............................|ale-python-pyright| reorder-python-imports................|ale-python-reorder_python_imports| vulture...............................|ale-python-vulture| yapf..................................|ale-python-yapf| qml.....................................|ale-qml-options| qmlfmt................................|ale-qml-qmlfmt| r.......................................|ale-r-options| + languageserver........................|ale-r-languageserver| lintr.................................|ale-r-lintr| styler................................|ale-r-styler| reasonml................................|ale-reasonml-options| @@ -2559,6 +2877,7 @@ documented in additional help files. sorbet................................|ale-ruby-sorbet| standardrb............................|ale-ruby-standardrb| rust....................................|ale-rust-options| + analyzer..............................|ale-rust-analyzer| cargo.................................|ale-rust-cargo| rls...................................|ale-rust-rls| rustc.................................|ale-rust-rustc| @@ -2576,6 +2895,7 @@ documented in additional help files. sasslint..............................|ale-scss-sasslint| stylelint.............................|ale-scss-stylelint| sh......................................|ale-sh-options| + bashate...............................|ale-sh-bashate| sh-language-server....................|ale-sh-language-server| shell.................................|ale-sh-shell| shellcheck............................|ale-sh-shellcheck| @@ -2603,6 +2923,7 @@ documented in additional help files. terraform...............................|ale-terraform-options| terraform-fmt-fixer...................|ale-terraform-fmt-fixer| terraform.............................|ale-terraform-terraform| + terraform-lsp.........................|ale-terraform-terraform-lsp| tflint................................|ale-terraform-tflint| tex.....................................|ale-tex-options| chktex................................|ale-tex-chktex| @@ -2625,15 +2946,18 @@ documented in additional help files. vala....................................|ale-vala-options| uncrustify............................|ale-vala-uncrustify| verilog/systemverilog...................|ale-verilog-options| + hdl-checker...........................|ale-verilog-hdl-checker| iverilog..............................|ale-verilog-iverilog| verilator.............................|ale-verilog-verilator| vlog..................................|ale-verilog-vlog| xvlog.................................|ale-verilog-xvlog| vhdl....................................|ale-vhdl-options| ghdl..................................|ale-vhdl-ghdl| + hdl-checker...........................|ale-vhdl-hdl-checker| vcom..................................|ale-vhdl-vcom| xvhdl.................................|ale-vhdl-xvhdl| vim.....................................|ale-vim-options| + vimls.................................|ale-vim-vimls| vint..................................|ale-vim-vint| vim help................................|ale-vim-help-options| write-good............................|ale-vim-help-write-good| @@ -2647,9 +2971,12 @@ documented in additional help files. yaml....................................|ale-yaml-options| prettier..............................|ale-yaml-prettier| swaglint..............................|ale-yaml-swaglint| + yamlfix...............................|ale-yaml-yamlfix| yamllint..............................|ale-yaml-yamllint| yang....................................|ale-yang-options| yang-lsp..............................|ale-yang-lsp| + zig.....................................|ale-zig-options| + zls...................................|ale-zig-zls| =============================================================================== @@ -2687,15 +3014,38 @@ ALEFindReferences *ALEFindReferences* Enter key (``) can be used to jump to a referencing location, or the `t` key can be used to jump to the location in a new tab. + The locations opened in different ways using the following variations. + + `:ALEFindReferences -tab` - Open the location in a new tab. + `:ALEFindReferences -split` - Open the location in a horizontal split. + `:ALEFindReferences -vsplit` - Open the location in a vertical split. + + The default method used for navigating to a new location can be changed + by modifying |g:ale_default_navigation|. + + You can add `-relative` to the command to view results with relatives paths, + instead of absolute paths. + + The selection can be opened again with the |ALERepeatSelection| command. + You can jump back to the position you were at before going to a reference of something with jump motions like CTRL-O. See |jump-motions|. A plug mapping `(ale_find_references)` is defined for this command. + You can define additional plug mapping with any additional options you want + like so: > + + nnoremap (my_mapping) :ALEFindReferences -relative +< ALEFix *ALEFix* Fix problems with the current buffer. See |ale-fix| for more information. + If the command is run with a bang (`:ALEFix!`), all warnings will be + suppressed, including warnings about no fixers being defined, and warnings + about not being able to apply fixes to a file because it has been changed. + A plug mapping `(ale_fix)` is defined for this command. @@ -2706,40 +3056,35 @@ ALEFixSuggest *ALEFixSuggest* See |ale-fix| for more information. -ALEGoToDefinition *ALEGoToDefinition* +ALEGoToDefinition `` *ALEGoToDefinition* Jump to the definition of a symbol under the cursor using the enabled LSP linters for the buffer. ALE will jump to a definition if an LSP server provides a location to jump to. Otherwise, ALE will do nothing. + The locations opened in different ways using the following variations. + + `:ALEGoToDefinition -tab` - Open the location in a new tab. + `:ALEGoToDefinition -split` - Open the location in a horizontal split. + `:ALEGoToDefinition -vsplit` - Open the location in a vertical split. + + The default method used for navigating to a new location can be changed + by modifying |g:ale_default_navigation|. + You can jump back to the position you were at before going to the definition of something with jump motions like CTRL-O. See |jump-motions|. - A plug mapping `(ale_go_to_definition)` is defined for this command. + You should consider using the 'hidden' option in combination with this + command. Otherwise, Vim will refuse to leave the buffer you're jumping from + unless you have saved your edits. + The following Plug mappings are defined for this command, which correspond + to the following commands. -ALEGoToDefinitionInTab *ALEGoToDefinitionInTab* - - The same as |ALEGoToDefinition|, but opens results in a new tab. - - A plug mapping `(ale_go_to_definition_in_tab)` is defined for this - 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. + `(ale_go_to_definition)` - `:ALEGoToDefinition` + `(ale_go_to_definition_in_tab)` - `:ALEGoToDefinition -tab` + `(ale_go_to_definition_in_split)` - `:ALEGoToDefinition -split` + `(ale_go_to_definition_in_vsplit)` - `:ALEGoToDefinition -vsplit` ALEGoToTypeDefinition *ALEGoToTypeDefinition* @@ -2749,36 +3094,25 @@ ALEGoToTypeDefinition *ALEGoToTypeDefinition* definition if an LSP server provides a location to jump to. Otherwise, ALE will do nothing. + The locations opened in different ways using the following variations. + + `:ALEGoToTypeDefinition -tab` - Open the location in a new tab. + `:ALEGoToTypeDefinition -split` - Open the location in a horizontal split. + `:ALEGoToTypeDefinition -vsplit` - Open the location in a vertical split. + + The default method used for navigating to a new location can be changed + by modifying |g:ale_default_navigation|. + You can jump back to the position you were at before going to the definition of something with jump motions like CTRL-O. See |jump-motions|. - A plug mapping `(ale_go_to_type_definition)` is defined for this - command. + The following Plug mappings are defined for this command, which correspond + to the following commands. - -ALEGoToTypeDefinitionInTab *ALEGoToTypeDefinitionInTab* - - The same as |ALEGoToTypeDefinition|, but opens results in a new tab. - - A plug mapping `(ale_go_to_type_definition_in_tab)` is defined for - this command. - - -ALEGoToTypeDefinitionInSplit *ALEGoToTypeDefinitionInSplit* - - The same as |ALEGoToTypeDefinition|, but opens results in a new split. - - A plug mapping `(ale_go_to_type_definition_in_split)` is defined for - this command. - - -ALEGoToTypeDefinitionInVSplit *ALEGoToTypeDefinitionInVSplit* - - The same as |ALEGoToTypeDefinition|, but opens results in a new vertical - split. - - A plug mapping `(ale_go_to_type_definition_in_vsplit)` is defined for - this command. + `(ale_go_to_type_definition)` - `:ALEGoToTypeDefinition` + `(ale_go_to_type_definition_in_tab)` - `:ALEGoToTypeDefinition -tab` + `(ale_go_to_type_definition_in_split)` - `:ALEGoToTypeDefinition -split` + `(ale_go_to_type_definition_in_vsplit)` - `:ALEGoToTypeDefinition -vsplit` ALEHover *ALEHover* @@ -2794,6 +3128,23 @@ ALEHover *ALEHover* A plug mapping `(ale_hover)` is defined for this command. +ALEImport *ALEImport* + + Try to import a symbol using `tsserver` or a Language Server. + + ALE will look for completions for the word at the cursor which contain + additional text edits that possible insert lines to import the symbol. The + first match with additional text edits will be used, and may add other code + to the current buffer other than import lines. + + If linting is enabled, and |g:ale_lint_on_text_changed| is set to ever check + buffers when text is changed, the buffer will be checked again after changes + are made. + + A Plug mapping `(ale_import)` is defined for this command. This + mapping should only be bound for normal mode. + + ALEOrganizeImports *ALEOrganizeImports* Organize imports using tsserver. Currently not implemented for LSPs. @@ -2801,9 +3152,27 @@ ALEOrganizeImports *ALEOrganizeImports* ALERename *ALERename* - Rename a symbol using TypeScript server or Language Server. + Rename a symbol using `tsserver` or a Language Server. - The user will be prompted for a new name. + The symbol where the cursor is resting will be the symbol renamed, and a + prompt will open to request a new name. + + +ALECodeAction *ALECodeAction* + + Apply a code action via LSP servers or `tsserver`. + + If there is an error present on a line that can be fixed, ALE will + automatically fix a line, unless there are multiple possible code fixes to + apply. + + This command can be run in visual mode apply actions, such as applicable + refactors. A menu will be shown to select code action to apply. + + +ALERepeatSelection *ALERepeatSelection* + + Repeat the last selection displayed in the preview window. ALESymbolSearch `` *ALESymbolSearch* @@ -2813,18 +3182,28 @@ ALESymbolSearch `` *ALESymbolSearch* The arguments provided to this command will be used as a search query for finding symbols in the workspace, such as functions, types, etc. + You can add `-relative` to the command to view results with relatives paths, + instead of absolute paths. + *:ALELint* ALELint *ALELint* Run ALE once for the current buffer. This command can be used to run ALE manually, instead of automatically, if desired. - This command will also run linters where `lint_file` is set to `1`, or in - other words linters which check the file instead of the Vim buffer. + This command will also run linters where `lint_file` is evaluates to `1`, + meaning linters which check the file instead of the Vim buffer. A plug mapping `(ale_lint)` is defined for this command. +ALELintStop *ALELintStop* + + Stop any currently running jobs for checking the current buffer. + + Any problems from previous linter results will continue to be shown. + + ALEPrevious *ALEPrevious* ALEPreviousWrap *ALEPreviousWrap* ALENext *ALENext* @@ -2842,7 +3221,7 @@ ALELast *ALELast* the last or first warning or error in the file, respectively. `ALEPrevious` and `ALENext` take optional flags arguments to custom their - behaviour : + behavior : `-wrap` enable wrapping around the file `-error`, `-warning` and `-info` enable jumping to errors, warnings or infos respectively, ignoring anything else. They are mutually exclusive and if @@ -3002,6 +3381,15 @@ ale#Env(variable_name, value) *ale#Env()* 'set VAR="some value" && command' # On Windows +ale#GetFilenameMappings(buffer, name) *ale#GetFilenameMappings()* + + Given a `buffer` and the `name` of either a linter for fixer, return a + |List| of two-item |List|s that describe mapping to and from the local and + foreign file systems for running a particular linter or fixer. + + See |g:ale_filename_mappings| for details on filename mapping. + + ale#Has(feature) *ale#Has()* Return `1` if ALE supports a given feature, like |has()| for Vim features. @@ -3024,9 +3412,9 @@ ale#Queue(delay, [linting_flag, buffer_number]) *ale#Queue()* The linters will always be run in the background. Calling this function again from the same buffer - An optional `linting_flag` argument can be given. If `linting_flag` - is `'lint_file'`, then linters where the `lint_file` option is set to `1` will be - run. Linters with `lint_file` set to `1` are not run by default. + An optional `linting_flag` argument can be given. If `linting_flag` is + `'lint_file'`, then linters where the `lint_file` option evaluates to `1` + will be run. Otherwise, those linters will not be run. An optional `buffer_number` argument can be given for specifying the buffer to check. The active buffer (`bufnr('')`) will be checked by default. @@ -3114,26 +3502,38 @@ ale#command#Run(buffer, command, callback, [options]) *ale#command#Run()* 'command': {b -> ale#command#Run(b, 'foo', function('s:GetCommand'))} < - The following `options` can be provided. - `output_stream` - Either `'stdout'`, `'stderr'`, `'both'`, or `'none`' for - selecting which output streams to read lines from. + `output_stream` - Either `'stdout'`, `'stderr'`, `'both'`, or + `'none`' for selecting which output streams to read + lines from. - The default is `'stdout'` + The default is `'stdout'` - `executable` - An executable for formatting into `%e` in the command. - If this option is not provided, formatting commands with - `%e` will not work. + `executable` - An executable for formatting into `%e` in the + command. If this option is not provided, formatting + commands with `%e` will not work. - `read_buffer` - If set to `1`, the buffer will be piped into the - command. + `read_buffer` - If set to `1`, the buffer will be piped into the + command. - The default is `0`. + The default is `0`. + + `input` - When creating temporary files with `%t` or piping + text into a command `input` can be set to a |List| of + text to use instead of the buffer's text. + + `filename_mappings` - A |List| of two-item |List|s describing filename + mappings to apply for formatted filenames in the + command string, as per |g:ale_filename_mappings|. + + If the call to this function is being used for a + linter or fixer, the mappings should be provided with + this option, and can be retrieved easily with + |ale#GetFilenameMappings()|. + + The default is `[]`. - `input` - When creating temporary files with `%t` or piping text - into a command `input` can be set to a |List| of text to - use instead of the buffer's text. ale#command#EscapeCommandPart(command_part) *ale#command#EscapeCommandPart()* @@ -3348,24 +3748,30 @@ ale#linter#Define(filetype, linter) *ale#linter#Define()* if a command manually reads from a temporary file instead, etc. + This option behaves as if it was set to `0` when the + `lint_file` option evaluates to `1`. + *ale-lint-file* - `lint_file` A |Number| (`0` or `1`) indicating whether a command - should read the file instead of the Vim buffer. This - option can be used for linters which must check the - file on disk, and which cannot check a Vim buffer - instead. + `lint_file` A |Number| (`0` or `1`), or a |Funcref| for a function + accepting a buffer number for computing either `0` or + `1`, indicating whether a command should read the file + instead of the Vim buffer. This option can be used + for linters which must check the file on disk, and + which cannot check a Vim buffer instead. - Linters set with this option will not be run as a - user types, per |g:ale_lint_on_text_changed|. Linters - will instead be run only when events occur against - the file on disk, including |g:ale_lint_on_enter| - and |g:ale_lint_on_save|. Linters with this option - set to `1` will also be run when linters are run - manually, per |ALELintPost-autocmd|. + The result can be computed with |ale#command#Run()|. - When this option is set to `1`, `read_buffer` will - be set automatically to `0`. The two options cannot - be used together. + Linters where the eventual value of this option + evaluates to `1` will not be run as a user types, per + |g:ale_lint_on_text_changed|. Linters will instead be + run only when events occur against the file on disk, + including |g:ale_lint_on_enter| and + |g:ale_lint_on_save|. Linters where this option + evaluates to `1` will also be run when the |ALELint| + command is run. + + When this option is evaluates to `1`, ALE will behave + as if `read_buffer` was set to `0`. *ale-lsp-linters* `lsp` A |String| for defining LSP (Language Server Protocol) @@ -3485,7 +3891,7 @@ ale#linter#Define(filetype, linter) *ale#linter#Define()* contents of the buffer being checked. All occurrences of `%t` in command strings will reference the one temporary file. The temporary file will be created inside a temporary directory, and the entire temporary directory - will be automatically deleted, following the behaviour of + will be automatically deleted, following the behavior of |ale#command#ManageDirectory|. This option can be used for some linters which do not support reading from stdin. @@ -3504,13 +3910,22 @@ ale#linter#Define(filetype, linter) *ale#linter#Define()* command, so literal character sequences `%s` and `%t` can be escaped by using `%%s` and `%%t` instead, etc. + Some |filename-modifiers| can be applied to `%s` and `%t`. Only `:h`, `:t`, + `:r`, and `:e` may be applied, other modifiers will be ignored. Filename + modifiers can be applied to the format markers by placing them after them. + + For example: > + 'command': '%s:h %s:e %s:h:t', +< + Given a path `/foo/baz/bar.txt`, the above command string will generate + something akin to `'/foo/baz' 'txt' 'baz'` + If a callback for a command generates part of a command string which might possibly contain `%%`, `%s`, `%t`, or `%e`, where the special formatting behavior is not desired, the |ale#command#EscapeCommandPart()| function can be used to replace those characters to avoid formatting issues. *ale-linter-loading-behavior* - *ale-linter-loading-behaviour* Linters for ALE will be loaded by searching |runtimepath| in the following format: > @@ -3654,6 +4069,23 @@ g:ale_want_results_buffer *g:ale_want_results_buffer* figure out which buffer other sources should lint. +ALECompletePost *ALECompletePost-autocmd* + *ALECompletePost* + + This |User| autocmd is triggered after ALE inserts an item on + |CompleteDone|. This event can be used to run commands after a buffer + is changed by ALE as the result of completion. For example, |ALEFix| can + be configured to run automatically when completion is done: > + + augroup FixAfterComplete + autocmd! + " Run ALEFix when completion items are added. + autocmd User ALECompletePost ALEFix! + " If ALE starts fixing a file, stop linters running for now. + autocmd User ALEFixPre ALELintStop + augroup END +< + ALELintPre *ALELintPre-autocmd* *ALELintPre* ALELintPost *ALELintPost-autocmd* diff --git a/sources_non_forked/ale/ftplugin/ale-preview-selection.vim b/sources_non_forked/ale/ftplugin/ale-preview-selection.vim index d77b4f98..7ec84068 100644 --- a/sources_non_forked/ale/ftplugin/ale-preview-selection.vim +++ b/sources_non_forked/ale/ftplugin/ale-preview-selection.vim @@ -12,5 +12,5 @@ noremap A noremap o noremap O " Keybinds for opening selection items. -noremap :call ale#preview#OpenSelectionInBuffer() +noremap :call ale#preview#OpenSelection() noremap t :call ale#preview#OpenSelectionInTab() diff --git a/sources_non_forked/ale/plugin/ale.vim b/sources_non_forked/ale/plugin/ale.vim index 8fea3bb4..5b7be116 100644 --- a/sources_non_forked/ale/plugin/ale.vim +++ b/sources_non_forked/ale/plugin/ale.vim @@ -97,6 +97,10 @@ let g:ale_fix_on_save = get(g:, 'ale_fix_on_save', 0) " should be used instead. let g:ale_enabled = get(g:, 'ale_enabled', 1) +" A Dictionary mapping linter or fixer names to Arrays of two-item Arrays +" mapping filename paths from one system to another. +let g:ale_filename_mappings = get(g:, 'ale_filename_mappings', {}) + " These flags dictates if ale uses the quickfix or the loclist (loclist is the " default, quickfix overrides loclist). let g:ale_set_loclist = get(g:, 'ale_set_loclist', 1) @@ -109,6 +113,9 @@ let g:ale_set_signs = get(g:, 'ale_set_signs', has('signs')) " This flag can be set to 0 to disable setting error highlights. let g:ale_set_highlights = get(g:, 'ale_set_highlights', has('syntax')) +" This List can be configured to exclude particular highlights. +let g:ale_exclude_highlights = get(g:, 'ale_exclude_highlights', []) + " This flag can be set to 0 to disable echoing when the cursor moves. let g:ale_echo_cursor = get(g:, 'ale_echo_cursor', 1) @@ -118,6 +125,9 @@ let g:ale_cursor_detail = get(g:, 'ale_cursor_detail', 0) " This flag can be set to 1 to enable virtual text when the cursor moves. let g:ale_virtualtext_cursor = get(g:, 'ale_virtualtext_cursor', 0) +" This flag can be set to 1 to enable LSP hover messages at the cursor. +let g:ale_hover_cursor = get(g:, 'ale_hover_cursor', 1) + " This flag can be set to 1 to automatically close the preview window upon " entering Insert Mode. let g:ale_close_preview_on_insert = get(g:, 'ale_close_preview_on_insert', 0) @@ -148,7 +158,10 @@ let g:ale_python_auto_pipenv = get(g:, 'ale_python_auto_pipenv', 0) " This variable can be overridden to set the GO111MODULE environment variable. let g:ale_go_go111module = get(g:, 'ale_go_go111module', '') -if g:ale_set_balloons +" If 1, enable a popup menu for commands. +let g:ale_popup_menu_enabled = get(g:, 'ale_popup_menu_enabled', has('gui_running')) + +if g:ale_set_balloons is 1 || g:ale_set_balloons is# 'hover' call ale#balloon#Enable() endif @@ -156,6 +169,10 @@ if g:ale_completion_enabled call ale#completion#Enable() endif +if g:ale_popup_menu_enabled + call ale#code_action#EnablePopUpMenu() +endif + " Define commands for moving through warnings and errors. command! -bar -nargs=* ALEPrevious \ :call ale#loclist_jumping#WrapJump('before', ) @@ -185,6 +202,8 @@ command! -bar ALEStopAllLSPs :call ale#lsp#reset#StopAllLSPs() " A command for linting manually. command! -bar ALELint :call ale#Queue(0, 'lint_file') +" Stop current jobs when linting. +command! -bar ALELintStop :call ale#engine#Stop(bufnr('')) " Define a command to get information about current filetype. command! -bar ALEInfo :call ale#debugging#Info() @@ -194,21 +213,18 @@ command! -bar ALEInfoToClipboard :call ale#debugging#InfoToClipboard() command! -bar -nargs=1 ALEInfoToFile :call ale#debugging#InfoToFile() " Fix problems in files. -command! -bar -nargs=* -complete=customlist,ale#fix#registry#CompleteFixers ALEFix :call ale#fix#Fix(bufnr(''), '', ) +command! -bar -bang -nargs=* -complete=customlist,ale#fix#registry#CompleteFixers ALEFix :call ale#fix#Fix(bufnr(''), '', ) " Suggest registered functions to use for fixing problems. 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'}) -command! -bar ALEGoToDefinitionInSplit :call ale#definition#GoTo({'open_in': 'horizontal-split'}) -command! -bar ALEGoToDefinitionInVSplit :call ale#definition#GoTo({'open_in': 'vertical-split'}) +command! -bar -nargs=* ALEGoToDefinition :call ale#definition#GoToCommandHandler('', ) " Go to type definition for tsserver and LSP -command! -bar ALEGoToTypeDefinition :call ale#definition#GoToType({}) -command! -bar ALEGoToTypeDefinitionInTab :call ale#definition#GoToType({'open_in': 'tab'}) -command! -bar ALEGoToTypeDefinitionInSplit :call ale#definition#GoToType({'open_in': 'horizontal-split'}) -command! -bar ALEGoToTypeDefinitionInVSplit :call ale#definition#GoToType({'open_in': 'vertical-split'}) +command! -bar -nargs=* ALEGoToTypeDefinition :call ale#definition#GoToCommandHandler('type', ) + +" Repeat a previous selection in the preview window +command! -bar ALERepeatSelection :call ale#preview#RepeatSelection() " Find references for tsserver and LSP command! -bar -nargs=* ALEFindReferences :call ale#references#Find() @@ -222,10 +238,17 @@ command! -bar ALEDocumentation :call ale#hover#ShowDocumentationAtCursor() " Search for appearances of a symbol, such as a type name or function name. command! -nargs=1 ALESymbolSearch :call ale#symbol#Search() +" Complete text with tsserver and LSP command! -bar ALEComplete :call ale#completion#GetCompletions('ale-manual') +" Try to find completions for the current symbol that add additional text. +command! -bar ALEImport :call ale#completion#Import() + " Rename symbols using tsserver and LSP -command! -bar ALERename :call ale#rename#Execute() +command! -bar -bang ALERename :call ale#rename#Execute() + +" Apply code actions to a range. +command! -bar -range ALECodeAction :call ale#codefix#Execute() " Organize import statements using tsserver command! -bar ALEOrganizeImports :call ale#organize_imports#Execute() @@ -257,18 +280,21 @@ nnoremap (ale_lint) :ALELint 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_go_to_definition_in_tab) :ALEGoToDefinition -tab +nnoremap (ale_go_to_definition_in_split) :ALEGoToDefinition -split +nnoremap (ale_go_to_definition_in_vsplit) :ALEGoToDefinition -vsplit nnoremap (ale_go_to_type_definition) :ALEGoToTypeDefinition -nnoremap (ale_go_to_type_definition_in_tab) :ALEGoToTypeDefinitionInTab -nnoremap (ale_go_to_type_definition_in_split) :ALEGoToTypeDefinitionInSplit -nnoremap (ale_go_to_type_definition_in_vsplit) :ALEGoToTypeDefinitionInVSplit +nnoremap (ale_go_to_type_definition_in_tab) :ALEGoToTypeDefinition -tab +nnoremap (ale_go_to_type_definition_in_split) :ALEGoToTypeDefinition -split +nnoremap (ale_go_to_type_definition_in_vsplit) :ALEGoToTypeDefinitionIn -vsplit nnoremap (ale_find_references) :ALEFindReferences nnoremap (ale_hover) :ALEHover nnoremap (ale_documentation) :ALEDocumentation inoremap (ale_complete) :ALEComplete +nnoremap (ale_import) :ALEImport nnoremap (ale_rename) :ALERename +nnoremap (ale_code_action) :ALECodeAction +nnoremap (ale_repeat_selection) :ALERepeatSelection " Set up autocmd groups now. call ale#events#Init() diff --git a/sources_non_forked/ale/rplugin/python3/deoplete/sources/ale.py b/sources_non_forked/ale/rplugin/python3/deoplete/sources/ale.py index ae1f4039..82d9bbf2 100644 --- a/sources_non_forked/ale/rplugin/python3/deoplete/sources/ale.py +++ b/sources_non_forked/ale/rplugin/python3/deoplete/sources/ale.py @@ -49,12 +49,13 @@ class Source(Base): if event == 'Async': result = self.vim.call('ale#completion#GetCompletionResult') + return result or [] if context.get('is_refresh'): self.vim.command( - "call ale#completion#GetCompletions('ale-callback', " + \ - "{'callback': {completions -> deoplete#auto_complete() }})" + "call ale#completion#GetCompletions('ale-callback', " + + "{'callback': {completions -> deoplete#auto_complete() }})" ) return [] diff --git a/sources_non_forked/ale/supported-tools.md b/sources_non_forked/ale/supported-tools.md index 0abc6b75..96ef273b 100644 --- a/sources_non_forked/ale/supported-tools.md +++ b/sources_non_forked/ale/supported-tools.md @@ -16,7 +16,7 @@ formatting. | Key | Definition | | ------------- | -------------------------------- | -| :floppy_disk: | Only checked when saved to disk | +| :floppy_disk: | May only run on files on disk | | :warning: | Disabled by default | --- @@ -30,6 +30,7 @@ formatting. * [drafter](https://github.com/apiaryio/drafter) * AsciiDoc * [alex](https://github.com/wooorm/alex) :floppy_disk: + * [languagetool](https://languagetool.org/) :floppy_disk: * [proselint](http://proselint.com/) * [redpen](http://redpen.cc/) * [textlint](https://textlint.github.io/) @@ -40,10 +41,13 @@ formatting. * Awk * [gawk](https://www.gnu.org/software/gawk/) * Bash + * [bashate](https://github.com/openstack/bashate) * [language-server](https://github.com/mads-hartmann/bash-language-server) * shell [-n flag](https://www.gnu.org/software/bash/manual/bash.html#index-set) * [shellcheck](https://www.shellcheck.net/) * [shfmt](https://github.com/mvdan/sh) +* Bats + * [shellcheck](https://www.shellcheck.net/) * BibTeX * [bibclean](http://ftp.math.utah.edu/pub/bibclean/) * Bourne Shell @@ -51,6 +55,7 @@ formatting. * [shellcheck](https://www.shellcheck.net/) * [shfmt](https://github.com/mvdan/sh) * C + * [astyle](http://astyle.sourceforge.net/) * [ccls](https://github.com/MaskRay/ccls) * [clang](http://clang.llvm.org/) * [clangd](https://clang.llvm.org/extra/clangd.html) @@ -68,6 +73,7 @@ formatting. * [mcsc](http://www.mono-project.com/docs/about-mono/languages/csharp/) :floppy_disk: see:`help ale-cs-mcsc` for details and configuration * [uncrustify](https://github.com/uncrustify/uncrustify) * C++ (filetype cpp) + * [astyle](http://astyle.sourceforge.net/) * [ccls](https://github.com/MaskRay/ccls) * [clang](http://clang.llvm.org/) * [clangcheck](http://clang.llvm.org/docs/ClangCheck.html) :floppy_disk: @@ -122,6 +128,8 @@ formatting. * [dartanalyzer](https://github.com/dart-lang/sdk/tree/master/pkg/analyzer_cli) :floppy_disk: * [dartfmt](https://github.com/dart-lang/sdk/tree/master/utils/dartfmt) * [language_server](https://github.com/natebosch/dart_language_server) +* Dhall + * [dhall-format](https://github.com/dhall-lang/dhall-lang) * Dockerfile * [dockerfile_lint](https://github.com/projectatomic/dockerfile_lint) * [hadolint](https://github.com/hadolint/hadolint) @@ -141,6 +149,7 @@ formatting. * [erubis](https://github.com/kwatch/erubis) * [ruumba](https://github.com/ericqweinstein/ruumba) * Erlang + * [elvis](https://github.com/inaka/elvis) :floppy_disk: * [erlc](http://erlang.org/doc/man/erlc.html) * [SyntaxErl](https://github.com/ten0s/syntaxerl) * Fish @@ -171,6 +180,7 @@ formatting. * [gosimple](https://github.com/dominikh/go-tools/tree/master/cmd/gosimple) :warning: :floppy_disk: * [gotype](https://godoc.org/golang.org/x/tools/cmd/gotype) :warning: :floppy_disk: * [go vet](https://golang.org/cmd/vet/) :floppy_disk: + * [revive](https://github.com/mgechev/revive) :warning: :floppy_disk: * [staticcheck](https://github.com/dominikh/go-tools/tree/master/cmd/staticcheck) :warning: :floppy_disk: * GraphQL * [eslint](http://eslint.org/) @@ -195,6 +205,7 @@ formatting. * [hie](https://github.com/haskell/haskell-ide-engine) * [hindent](https://hackage.haskell.org/package/hindent) * [hlint](https://hackage.haskell.org/package/hlint) + * [ormolu](https://github.com/tweag/ormolu) * [stack-build](https://haskellstack.org/) :floppy_disk: * [stack-ghc](https://haskellstack.org/) * [stylish-haskell](https://github.com/jaspervdj/stylish-haskell) @@ -265,6 +276,7 @@ formatting. * Lua * [luac](https://www.lua.org/manual/5.1/luac.html) * [luacheck](https://github.com/mpeterv/luacheck) + * [luafmt](https://github.com/trixnz/lua-fmt) * Mail * [alex](https://github.com/wooorm/alex) :floppy_disk: * [languagetool](https://languagetool.org/) :floppy_disk: @@ -324,6 +336,7 @@ formatting. * Perl6 * [perl6 -c](https://perl6.org) :warning: * PHP + * [intelephense](https://github.com/bmewburn/intelephense-docs) * [langserver](https://github.com/felixfbecker/php-language-server) * [phan](https://github.com/phan/phan) see `:help ale-php-phan` to instructions * [phpcbf](https://github.com/squizlabs/PHP_CodeSniffer) @@ -333,6 +346,7 @@ formatting. * [phpmd](https://phpmd.org) * [phpstan](https://github.com/phpstan/phpstan) * [psalm](https://getpsalm.org) :floppy_disk: + * [tlint](https://github.com/tightenco/tlint) * PO * [alex](https://github.com/wooorm/alex) :floppy_disk: * [msgfmt](https://www.gnu.org/software/gettext/manual/html_node/msgfmt-Invocation.html) @@ -361,6 +375,7 @@ formatting. * [purescript-language-server](https://github.com/nwolverson/purescript-language-server) * [purty](https://gitlab.com/joneshf/purty) * Python + * [autoimport](https://lyz-code.github.io/autoimport/) * [autopep8](https://github.com/hhatto/autopep8) * [bandit](https://github.com/PyCQA/bandit) :warning: * [black](https://github.com/ambv/black) @@ -375,6 +390,7 @@ formatting. * [pylint](https://www.pylint.org/) :floppy_disk: * [pyls](https://github.com/palantir/python-language-server) :warning: * [pyre](https://github.com/facebook/pyre-check) :warning: + * [pyright](https://github.com/microsoft/pyright) * [reorder-python-imports](https://github.com/asottile/reorder_python_imports) * [vulture](https://github.com/jendrikseipp/vulture) :warning: :floppy_disk: * [yapf](https://github.com/google/yapf) @@ -382,6 +398,7 @@ formatting. * [qmlfmt](https://github.com/jesperhh/qmlfmt) * [qmllint](https://github.com/qt/qtdeclarative/tree/5.11/tools/qmllint) * R + * [languageserver](https://github.com/REditorSupport/languageserver) * [lintr](https://github.com/jimhester/lintr) * [styler](https://github.com/r-lib/styler) * Racket @@ -417,6 +434,7 @@ formatting. * Rust * [cargo](https://github.com/rust-lang/cargo) :floppy_disk: (see `:help ale-integration-rust` for configuration instructions) * [rls](https://github.com/rust-lang-nursery/rls) :warning: + * [rust-analyzer](https://github.com/rust-analyzer/rust-analyzer) :warning: * [rustc](https://www.rust-lang.org/) :warning: * [rustfmt](https://github.com/rust-lang-nursery/rustfmt) * Sass @@ -447,11 +465,13 @@ formatting. * [sqlfmt](https://github.com/jackc/sqlfmt) * [sqlformat](https://github.com/andialbrecht/sqlparse) * [sqlint](https://github.com/purcell/sqlint) + * [sql-lint](https://github.com/joereynolds/sql-lint) * Stylus * [stylelint](https://github.com/stylelint/stylelint) * SugarSS * [stylelint](https://github.com/stylelint/stylelint) * Swift + * [Apple swift-format](https://github.com/apple/swift-format) * [sourcekit-lsp](https://github.com/apple/sourcekit-lsp) * [swiftformat](https://github.com/nicklockwood/SwiftFormat) * [swiftlint](https://github.com/realm/SwiftLint) @@ -485,6 +505,7 @@ formatting. * VALA * [uncrustify](https://github.com/uncrustify/uncrustify) * Verilog + * [hdl-checker](https://pypi.org/project/hdl-checker) * [iverilog](https://github.com/steveicarus/iverilog) * [verilator](http://www.veripool.org/projects/verilator/wiki/Intro) * [vlog](https://www.mentor.com/products/fv/questa/) @@ -494,6 +515,7 @@ formatting. * [vcom](https://www.mentor.com/products/fv/questa/) * [xvhdl](https://www.xilinx.com/products/design-tools/vivado.html) * Vim + * [vimls](https://github.com/iamcco/vim-language-server) * [vint](https://github.com/Kuniwak/vint) * Vim help * [alex](https://github.com/wooorm/alex) :warning: :floppy_disk: @@ -511,6 +533,9 @@ formatting. * YAML * [prettier](https://github.com/prettier/prettier) * [swaglint](https://github.com/byCedric/swaglint) + * [yamlfix](https://lyz-code.github.io/yamlfix) * [yamllint](https://yamllint.readthedocs.io/) * YANG * [yang-lsp](https://github.com/theia-ide/yang-lsp) +* Zig + * [zls](https://github.com/zigtools/zls) diff --git a/sources_non_forked/bufexplorer/README.md b/sources_non_forked/bufexplorer/README.md index 5ee9346e..2987bdd9 100644 --- a/sources_non_forked/bufexplorer/README.md +++ b/sources_non_forked/bufexplorer/README.md @@ -5,10 +5,14 @@ BufExplorer Plugin for Vim With bufexplorer, you can quickly and easily switch between buffers by using the one of the default public interfaces: - '\be' (normal open) or - '\bt' (toggle open / close) or - '\bs' (force horizontal split open) or - '\bv' (force vertical split open) +`\be` normal open + +`\bt` toggle open / close + +`\bs` force horizontal split open + +`\bv` force vertical split open + Once the bufexplorer window is open you can use the normal movement keys (hjkl) to move around and then use or to select the buffer you would like to open. If you would like to have the selected buffer opened in a new tab, simply press either or 't'. Please note that when opening a buffer in a tab, that if the buffer is already in another tab, bufexplorer can switch to that tab automatically for you if you would like. More about that in the supplied VIM help. diff --git a/sources_non_forked/ctrlp.vim/autoload/ctrlp.vim b/sources_non_forked/ctrlp.vim/autoload/ctrlp.vim index d1e23696..c8f5e1bc 100644 --- a/sources_non_forked/ctrlp.vim/autoload/ctrlp.vim +++ b/sources_non_forked/ctrlp.vim/autoload/ctrlp.vim @@ -414,26 +414,44 @@ fu! ctrlp#files() endf fu! s:InitCustomFuncs() - if s:igntype == 4 && has_key(s:usrign, 'func-init') && s:usrign['func-init'] != '' + if s:igntype == 4 && get(s:usrign, 'func-init', '') != '' exe call(s:usrign['func-init'], []) en endf fu! s:CloseCustomFuncs() - if s:igntype == 4 && has_key(s:usrign, 'func-close') && s:usrign['func-close'] != '' + if s:igntype == 4 && get(s:usrign, 'func-close', '') != '' exe call(s:usrign['func-close'], []) en endf -fu! s:GlobPath(dirs, depth) - let entries = split(globpath(a:dirs, s:glob), "\n") - let [dnf, depth] = [ctrlp#dirnfile(entries), a:depth + 1] - cal extend(g:ctrlp_allfiles, dnf[1]) - if !empty(dnf[0]) && !s:maxf(len(g:ctrlp_allfiles)) && depth <= s:maxdepth - sil! cal ctrlp#progress(len(g:ctrlp_allfiles), 1) - cal s:GlobPath(join(map(dnf[0], 's:fnesc(v:val, "g", ",")'), ','), depth) - en -endf +if has('patch-8.2-0995') + fu! s:GlobPath(dirs, depth) + let entries = [] + for e in split(a:dirs, ',') + sil let files = readdir(e, '1', {'sort': 'none'}) + if !s:showhidden | cal filter(files, 'v:val[0] != "."') | en + let entries += map(files, 'e.s:lash.v:val') + endfo + let [dnf, depth] = [ctrlp#dirnfile(entries), a:depth + 1] + if &wig != '' | cal filter(dnf[1], 'glob(v:val) != ""') | en + let g:ctrlp_allfiles += dnf[1] + if !empty(dnf[0]) && !s:maxf(len(g:ctrlp_allfiles)) && depth <= s:maxdepth + sil! cal ctrlp#progress(len(g:ctrlp_allfiles), 1) + cal s:GlobPath(join(dnf[0], ','), depth) + en + endf +el + fu! s:GlobPath(dirs, depth) + let entries = split(globpath(a:dirs, s:glob), "\n") + let [dnf, depth] = [ctrlp#dirnfile(entries), a:depth + 1] + let g:ctrlp_allfiles += dnf[1] + if !empty(dnf[0]) && !s:maxf(len(g:ctrlp_allfiles)) && depth <= s:maxdepth + sil! cal ctrlp#progress(len(g:ctrlp_allfiles), 1) + cal s:GlobPath(join(map(dnf[0], 's:fnesc(v:val, "g", ",")'), ','), depth) + en + endf +en fu! s:async_glob_update_progress(timer) let s:must_wait = 0 @@ -442,26 +460,26 @@ fu! s:async_glob_update_progress(timer) en if exists('s:timer') sil! cal ctrlp#statusline() - endif + en if !exists('s:job') call s:stop_timer_if_exists() - endif + en endf fu! s:async_glob_on_stdout(job, data, ...) if type(a:data) ==# type([]) - call extend(g:ctrlp_allfiles, filter(a:data, 'v:val !=# ""')) - else - call add(g:ctrlp_allfiles, a:data) - endif + let g:ctrlp_allfiles += filter(a:data, 'v:val !=# ""') + el + let g:ctrlp_allfiles += [a:data] + en endf fu! s:async_glob_on_exit(...) let s:must_wait = 0 if exists('s:job') - unlet s:job - endif + unl s:job + en cal s:stop_timer_if_exists() if exists('s:focus') && get(s:, 'setlines_post_ended', 0) sil! cal ctrlp#statusline() @@ -477,8 +495,8 @@ endf fu! s:stop_timer_if_exists() if exists('s:timer') - call timer_stop(s:timer) - unlet s:timer + cal timer_stop(s:timer) + unl s:timer en endf @@ -486,10 +504,10 @@ fu! s:stop_job_if_exists() if exists('s:job') if !has('nvim') cal job_stop(s:job) - else + el cal jobstop(s:job) - endif - unlet s:job + en + unl s:job en endf @@ -504,7 +522,7 @@ endf fu! s:UserCmd(lscmd) let [path, lscmd] = [s:dyncwd, a:lscmd] let do_ign = - \ type(s:usrcmd) == 4 && has_key(s:usrcmd, 'ignore') && s:usrcmd['ignore'] + \ type(s:usrcmd) == 4 && get(s:usrcmd, 'ignore', 0) if do_ign && ctrlp#igncwd(s:cwd) | retu | en if exists('+ssl') && &ssl && &shell !~ 'sh' let [ssl, &ssl, path] = [&ssl, 0, tr(path, '/', '\')] @@ -526,12 +544,12 @@ fu! s:UserCmd(lscmd) \ 'out_cb': function('s:async_glob_on_stdout'), \ 'exit_cb': function('s:async_glob_on_exit') \ }) - else + el let s:job = jobstart(argv, { \ 'on_stdout': function('s:async_glob_on_stdout'), \ 'on_exit': function('s:async_glob_on_exit') \ }) - endif + en let s:timer = timer_start(250, function('s:async_glob_update_progress'), {'repeat': -1}) while s:must_wait sleep 50m @@ -570,7 +588,7 @@ fu! s:lsCmd() retu cmd[1] elsei type(cmd) == 4 && ( has_key(cmd, 'types') || has_key(cmd, 'fallback') ) let fndroot = [] - if has_key(cmd, 'types') && cmd['types'] != {} + if get(cmd, 'types', {}) != {} let [markrs, cmdtypes] = [[], values(cmd['types'])] for pair in cmdtypes cal add(markrs, pair[0]) @@ -578,7 +596,7 @@ fu! s:lsCmd() let fndroot = s:findroot(s:dyncwd, markrs, 0, 1) en if fndroot == [] - retu has_key(cmd, 'fallback') ? cmd['fallback'] : '' + retu get(cmd, 'fallback', '') en for pair in cmdtypes if pair[0] == fndroot[0] | brea | en @@ -633,7 +651,7 @@ fu! s:MatchIt(items, pat, limit, exc) try if (s:matchcrfile || !( s:ispath && item ==# a:exc )) && \call(s:mfunc, [item, pat]) >= 0 - cal add(lines, item) + let lines += [item] en cat | brea | endt if a:limit > 0 && len(lines) >= a:limit | brea | en @@ -647,12 +665,12 @@ fu! s:MatchedItems(items, pat, limit) let items = s:narrowable() ? s:matched + s:mdata[3] : a:items let matcher = s:getextvar('matcher') if empty(matcher) || type(matcher) != 4 || !has_key(matcher, 'match') - unlet matcher + unl matcher let matcher = s:matcher en if matcher != {} let argms = - \ has_key(matcher, 'arg_type') && matcher['arg_type'] == 'dict' ? [{ + \ get(matcher, 'arg_type', '') == 'dict' ? [{ \ 'items': items, \ 'str': a:pat, \ 'limit': a:limit, @@ -723,12 +741,20 @@ fu! s:Render(lines, pat) " Sorting if !s:nosort() let s:compat = s:martcs.pat - cal sort(lines, 's:mixedsort') + if has('patch-8.1-0') + cal sort(lines, function('s:mixedsort2', [s:curtype()])) + el + cal sort(lines, 's:mixedsort') + en unl s:compat en if s:mw_order == 'btt' | cal reverse(lines) | en let s:lines = copy(lines) - cal map(lines, s:flfunc) + if has('patch-8.1-0') && s:flfunc ==# 's:formatline(v:val)' + cal map(lines, function('s:formatline2', [s:curtype()])) + el + cal map(lines, s:flfunc) + en cal setline(1, s:offset(lines, height)) cal s:unmarksigns() cal s:remarksigns() @@ -755,7 +781,7 @@ fu! s:Update(str) \ : s:MatchedItems(g:ctrlp_lines, pat, s:mw_res) if empty(str) | cal clearmatches() | en cal s:Render(lines, pat) - return lines + retu lines endf fu! s:ForceUpdate() @@ -790,6 +816,9 @@ fu! s:BuildPrompt(upd) if empty(prt[1]) && s:focus exe 'echoh' hibase '| echon "_" | echoh None' en + if a:upd + cal s:NotifySearch() + en endf " - SetDefTxt() {{{1 fu! s:SetDefTxt() @@ -1159,10 +1188,10 @@ fu! s:SetWD(args) \ && exists('s:dyncwd') cal ctrlp#setdir(s:dyncwd) | retu en - if has_key(a:args, 'dir') && a:args['dir'] != '' + if get(a:args, 'dir', '') != '' cal ctrlp#setdir(a:args['dir']) | retu en - let pmodes = has_key(a:args, 'mode') ? a:args['mode'] : s:pathmode + let pmodes = get(a:args, 'mode', s:pathmode) let [s:crfilerel, s:dyncwd] = [fnamemodify(s:crfile, ':.'), getcwd()] if (!type(pmodes)) let pmodes = @@ -1181,7 +1210,7 @@ fu! ctrlp#acceptfile(...) let useb = 0 if a:0 == 1 && type(a:1) == 4 let [md, line] = [a:1['action'], a:1['line']] - let atl = has_key(a:1, 'tail') ? a:1['tail'] : '' + let atl = get(a:1, 'tail', '') el let [md, line] = [a:1, a:2] let atl = a:0 > 2 ? a:3 : '' @@ -1273,7 +1302,7 @@ fu! s:AcceptSelection(action) " Do something with it if s:openfunc != {} && has_key(s:openfunc, s:ctype) let actfunc = s:openfunc[s:ctype] - let type = has_key(s:openfunc, 'arg_type') ? s:openfunc['arg_type'] : 'list' + let type = get(s:openfunc, 'arg_type', 'list') el if s:itemtype < len(s:coretypes) let [actfunc, type] = ['ctrlp#acceptfile', 'dict'] @@ -1348,7 +1377,7 @@ fu! s:MarkToOpen() if exists('s:marked') let vac = s:vacantdict(s:marked) let key = empty(vac) ? len(s:marked) + 1 : vac[0] - let s:marked = extend(s:marked, { key : filpath }) + cal extend(s:marked, { key : filpath }) el let [key, s:marked] = [1, { 1 : filpath }] en @@ -1457,13 +1486,13 @@ fu! s:OpenNoMarks(md, line) if a:md == 'a' let [s:marked, key] = [{}, 1] for line in s:lines - let s:marked = extend(s:marked, { key : fnamemodify(line, ':p') }) + cal extend(s:marked, { key : fnamemodify(line, ':p') }) let key += 1 endfo cal s:remarksigns() cal s:BuildPrompt(0) elsei a:md == 'x' - let type = has_key(s:openfunc, 'arg_type') ? s:openfunc['arg_type'] : 'dict' + let type = get(s:openfunc, 'arg_type', 'dict') let argms = type == 'dict' ? [{ 'action': a:md, 'line': a:line }] \ : [a:md, a:line] cal call(s:openfunc[s:ctype], argms, s:openfunc) @@ -1502,15 +1531,15 @@ fu! s:compmreb(...) " By last entered time (bufnr) let [id1, id2] = [index(s:mrbs, a:1), index(s:mrbs, a:2)] if id1 == id2 - return 0 - endif + retu 0 + en if id1 < 0 - return 1 - endif + retu 1 + en if id2 < 0 - return -1 - endif - return id1 > id2 ? 1 : -1 + retu -1 + en + retu id1 > id2 ? 1 : -1 endf fu! s:compmref(...) @@ -1546,7 +1575,7 @@ fu! s:matchlens(str, pat, ...) if nr > 20 | retu {} | en if match(a:str, a:pat, st) >= 0 let [mst, mnd] = [matchstr(a:str, a:pat, st), matchend(a:str, a:pat, st)] - let lens = extend(lens, { nr : [strlen(mst), mst] }) + cal extend(lens, { nr : [strlen(mst), mst] }) let lens = s:matchlens(a:str, a:pat, mnd, lens, nr + 1) en retu lens @@ -1556,6 +1585,32 @@ fu! s:shortest(lens) retu min(map(values(a:lens), 'v:val[0]')) endf +fu! s:mixedsort2(ct, ...) + if a:ct == 'buf' + let pat = '[\/]\?\[\d\+\*No Name\]$' + if a:1 =~# pat && a:2 =~# pat | retu 0 + elsei a:1 =~# pat | retu 1 + elsei a:2 =~# pat | retu -1 | en + en + let [cln, cml] = [ctrlp#complen(a:1, a:2), s:compmatlen(a:1, a:2)] + if s:ispath + let ms = [] + if s:res_count < 21 + let ms += [s:compfnlen(a:1, a:2)] + if a:ct !~ '^\(buf\|mru\)$' | let ms += [s:comptime(a:1, a:2)] | en + if !s:itemtype | let ms += [s:comparent(a:1, a:2)] | en + en + if a:ct =~ '^\(buf\|mru\)$' + let ms += [s:compmref(a:1, a:2)] + let cln = cml ? cln : 0 + en + let ms += [cml, 0, 0, 0] + let mp = call('s:multipliers', ms[:3]) + retu cln + ms[0] * mp[0] + ms[1] * mp[1] + ms[2] * mp[2] + ms[3] * mp[3] + en + retu cln + cml * 2 +endf + fu! s:mixedsort(...) let ct = s:curtype() if ct == 'buf' @@ -1614,7 +1669,7 @@ fu! ctrlp#statusline() \ exists('s:marked') ? ' <'.s:dismrk().'>' : ' <->' : '' if s:status != {} let argms = - \ has_key(s:status, 'arg_type') && s:status['arg_type'] == 'dict' ? [{ + \ get(s:status, 'arg_type', '') == 'dict' ? [{ \ 'focus': focus, \ 'byfname': byfname, \ 'regex': s:regexp, @@ -1647,7 +1702,7 @@ fu! ctrlp#progress(enum, ...) if has('macunix') || has('mac') | sl 1m | en let txt = a:0 ? '(press ctrl-c to abort)' : '' if s:status != {} - let argms = has_key(s:status, 'arg_type') && s:status['arg_type'] == 'dict' + let argms = get(s:status, 'arg_type', '') == 'dict' \ ? [{ 'str': a:enum }] : [a:enum] let &l:stl = call(s:status['prog'], argms, s:status) el @@ -1684,6 +1739,33 @@ fu! s:formatline(str) retu s:lineprefix.( cond ? s:pathshorten(str) : str ) endf +fu! s:formatline2(ct, key, str) + let str = a:str + if a:ct == 'buf' + let bufnr = s:bufnrfilpath(str)[0] + let parts = s:bufparts(bufnr) + let str = printf('%'.s:bufnr_width.'s', bufnr) + if s:has_conceal && has('syntax_items') + let str .= printf(' %-13s %s%-36s', + \ ''.parts[0].'', + \ ''.parts[1], '{'.parts[2].'}') + if (!empty(s:bufpath_mod)) + let str .= printf(' %s', ''.parts[3].'') + en + el + let str .= printf(' %-5s %-30s', + \ parts[0], + \ parts[2]) + if (!empty(s:bufpath_mod)) + let str .= printf(' %s', parts[3]) + en + en + en + let cond = a:ct != 'buf' &&s:ispath && ( s:winw - 4 ) < s:strwidth(str) + retu s:lineprefix.( cond ? s:pathshorten(str) : str ) +endf + + fu! s:pathshorten(str) retu matchstr(a:str, '^.\{9}').'...' \ .matchstr(a:str, '.\{'.( s:winw - 16 ).'}$') @@ -1750,19 +1832,19 @@ fu! ctrlp#dirnfile(entries) if s:igntype >= 0 && s:usrign(each, etype) | con | en if etype == 'dir' if s:showhidden | if each !~ '[\/]\.\{1,2}$' - cal add(items[0], each) + let items[0] += [each] en | el - cal add(items[0], each) + let items[0] += [each] en elsei etype == 'link' if s:folsym let isfile = !isdirectory(each) if s:folsym == 2 || !s:samerootsyml(each, isfile, cwd) - cal add(items[isfile], each) + let items[isfile] += [each] en en elsei etype == 'file' - cal add(items[1], each) + let items[1] += [each] en endfo retu items @@ -1770,17 +1852,12 @@ endf fu! s:usrign(item, type) if s:igntype == 1 | retu a:item =~ s:usrign | en - if s:igntype == 2 - if call(s:usrign, [a:item, a:type]) - retu 1 - en - elsei s:igntype == 4 - if has_key(s:usrign, a:type) && s:usrign[a:type] != '' - \ && a:item =~ s:usrign[a:type] - retu 1 - elsei has_key(s:usrign, 'func') && s:usrign['func'] != '' - \ && call(s:usrign['func'], [a:item, a:type]) - retu 1 + if s:igntype == 2 | retu call(s:usrign, [a:item, a:type]) | en + if s:igntype == 4 + if get(s:usrign, a:type, '') != '' + retu a:item =~ s:usrign[a:type] + elsei get(s:usrign, 'func', '') != '' + retu call(s:usrign['func'], [a:item, a:type]) en en retu 0 @@ -2021,7 +2098,7 @@ fu! s:ifilter(list, str) for each in a:list try if eval(estr) - cal add(rlist, each) + let rlist += [each] en cat | con | endt endfo @@ -2046,7 +2123,7 @@ endf fu! s:sublist7071(l, s, e) let [newlist, id, ae] = [[], a:s, a:e == -1 ? len(a:l) - 1 : a:e] wh id <= ae - cal add(newlist, get(a:l, id)) + let newlist += [get(a:l, id)] let id += 1 endw retu newlist @@ -2075,9 +2152,9 @@ endf fu! s:isabs(path) if (has('win32') || has('win64')) - return a:path =~ '^\([a-zA-Z]:\)\{-}[/\\]' + retu a:path =~ '^\([a-zA-Z]:\)\{-}[/\\]' el - return a:path =~ '^[/\\]' + retu a:path =~ '^[/\\]' en endf @@ -2289,14 +2366,14 @@ endf fu! s:getinput(...) let [prt, spi] = [s:prompt, ( a:0 ? a:1 : '' )] if s:abbrev != {} - let gmd = has_key(s:abbrev, 'gmode') ? s:abbrev['gmode'] : '' + let gmd = get(s:abbrev, 'gmode', '') let str = ( gmd =~ 't' && !a:0 ) || spi == 'c' ? prt[0] : join(prt, '') if gmd =~ 't' && gmd =~ 'k' && !a:0 && matchstr(str, '.$') =~ '\k' retu join(prt, '') en let [pf, rz] = [( s:byfname() ? 'f' : 'p' ), ( s:regexp ? 'r' : 'z' )] for dict in s:abbrev['abbrevs'] - let dmd = has_key(dict, 'mode') ? dict['mode'] : '' + let dmd = get(dict, 'mode', '') let pat = escape(dict['pattern'], '~') if ( dmd == '' || ( dmd =~ pf && dmd =~ rz && !a:0 ) \ || dmd =~ '['.spi.']' ) && str =~ pat @@ -2312,9 +2389,15 @@ fu! s:getinput(...) retu spi == 'c' ? prt[0] : join(prt, '') endf -fu! s:strwidth(str) - retu exists('*strdisplaywidth') ? strdisplaywidth(a:str) : strlen(a:str) -endf +if exists('*strdisplaywidth') + fu! s:strwidth(str) + retu strdisplaywidth(a:str) + endf +el + fu! s:strwidth(str) + retu strlen(a:str) + endf +en fu! ctrlp#j2l(nr) exe 'norm!' a:nr.'G' @@ -2507,7 +2590,7 @@ fu! s:buildpat(lst) endf fu! s:curtype() - return s:CurTypeName()[1] + retu s:CurTypeName()[1] endf fu! s:mfunc() @@ -2609,6 +2692,10 @@ fu! ctrlp#clearmarkedlist() let s:marked = {} endf +fu! ctrlp#input() + retu s:getinput() +endf + fu! ctrlp#exit() cal s:PrtExit() endf @@ -2665,9 +2752,9 @@ endf " Returns [lname, sname] fu! s:CurTypeName() if s:itemtype < len(s:coretypes) - return filter(copy(s:coretypes), 'v:val[1]==g:ctrlp_types[s:itemtype]')[0] + retu filter(copy(s:coretypes), 'v:val[1]==g:ctrlp_types[s:itemtype]')[0] el - return [s:getextvar("lname"), s:getextvar('sname')] + retu [s:getextvar("lname"), s:getextvar('sname')] en endfu @@ -2675,15 +2762,15 @@ fu! s:ExitIfSingleCandidate() if len(s:Update(s:prompt[0])) == 1 call s:AcceptSelection('e') call ctrlp#exit() - return 1 + retu 1 en - return 0 + retu 0 endfu fu! s:IsBuiltin() let builtins = ['tag', 'dir', 'bft', 'rts', 'bkd', 'lns', 'chs', 'mix', 'udo', 'qfx'] let curtype = s:getextvar('sname') - return s:itemtype < len(s:coretypes) || index(builtins, curtype) > -1 + retu s:itemtype < len(s:coretypes) || index(builtins, curtype) > -1 endfu fu! s:DetectFileType(type, ft) @@ -2731,12 +2818,26 @@ fu! ctrlp#init(type, ...) let curName = s:CurTypeName() let shouldExitSingle = index(s:opensingle, curName[0])>=0 || index(s:opensingle, curName[1])>=0 if shouldExitSingle && s:ExitIfSingleCandidate() - return 0 + retu 0 en cal s:BuildPrompt(1) if s:keyloop | cal s:KeyLoop() | en - return 1 + retu 1 endf + +" - Events {{{1 +fu! s:NotifySearch() + let l:cb = s:getextvar('search') + if l:cb != -1 + cal eval(l:cb) + en +endf + +fu! ctrlp#update(...) + cal s:ForceUpdate() + if a:0 | cal s:BuildPrompt(a:1) | en +endf + " - Autocmds {{{1 if has('autocmd') aug CtrlPAug diff --git a/sources_non_forked/ctrlp.vim/autoload/ctrlp/utils.vim b/sources_non_forked/ctrlp.vim/autoload/ctrlp/utils.vim index 91b9f24e..cfc9e6c8 100644 --- a/sources_non_forked/ctrlp.vim/autoload/ctrlp/utils.vim +++ b/sources_non_forked/ctrlp.vim/autoload/ctrlp/utils.vim @@ -75,9 +75,9 @@ fu! ctrlp#utils#globpath(...) retu call('globpath', s:wig_cond ? a:000 : a:000[:1]) endf -fu! ctrlp#utils#fnesc(path, type, ...) - if exists('*fnameescape') - if exists('+ssl') +if exists('*fnameescape') + if exists('+ssl') + fu! ctrlp#utils#fnesc(path, type, ...) if a:type == 'c' let path = escape(a:path, '%#') elsei a:type == 'f' @@ -86,11 +86,17 @@ fu! ctrlp#utils#fnesc(path, type, ...) let path = escape(a:path, '?*') en let path = substitute(path, '[', '[[]', 'g') - el - let path = fnameescape(a:path) - en + retu a:0 ? escape(path, a:1) : path + endf el - if exists('+ssl') + fu! ctrlp#utils#fnesc(path, type, ...) + let path = fnameescape(a:path) + retu a:0 ? escape(path, a:1) : path + endf + en +el + if exists('+ssl') + fu! ctrlp#utils#fnesc(path, type, ...) if a:type == 'c' let path = escape(a:path, '%#') elsei a:type == 'f' @@ -99,12 +105,15 @@ fu! ctrlp#utils#fnesc(path, type, ...) let path = escape(a:path, '?*') en let path = substitute(path, '[', '[[]', 'g') - el + retu a:0 ? escape(path, a:1) : path + endf + el + fu! ctrlp#utils#fnesc(path, type, ...) let path = escape(a:path, " \t\n*?[{`$\\%#'\"|!<") - en + retu a:0 ? escape(path, a:1) : path + endf en - retu a:0 ? escape(path, a:1) : path -endf +en "}}} " vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1:ts=2:sw=2:sts=2 diff --git a/sources_non_forked/ctrlp.vim/doc/ctrlp.cnx b/sources_non_forked/ctrlp.vim/doc/ctrlp.cnx index 32da378f..3cd91399 100644 --- a/sources_non_forked/ctrlp.vim/doc/ctrlp.cnx +++ b/sources_non_forked/ctrlp.vim/doc/ctrlp.cnx @@ -203,7 +203,7 @@ OPTIONS *ctrlp-options* w - 用来修饰r:使用当前工作目录而不是当前文件所在目录进行查找 0 或者 - 禁用这项功能。 -注意 #1: 如果 "a" 或者 "c" 和 "r"一起被包含,当无法找到根目录时使用 "a" 或者 +注意 #1: 如果 "a" 或者 "c" 和 "r"一起被包含,当无法找到根目录时使用 "a" 或者 "c" 的行为(作为备选)。 注意 #2: 你可以在每个缓冲区内使用 |b:var| 来设置该选项。 @@ -425,10 +425,12 @@ OPTIONS *ctrlp-options* 注意: 当命令使用 |g:ctrlp_user_command| 定义时该选项无效。 *'g:ctrlp_lazy_update'* -设置为1将开启延迟更新特性:只在输入停止一个确定的时间后才更新匹配窗口: > +设置为1将或更大可开启延迟更新特性:只在输入停止一个确定的时间后才更新匹配窗口: +> let g:ctrlp_lazy_update = 0 < -如果设置为1,在250毫秒后更新。如果大于1,数字会被作为延迟时间使用。 +如果设置为1,在250毫秒后更新該值作為默認值。如果大于1,数字会被作为延迟时间使 +用。 *'g:ctrlp_default_input'* 设置为1将为提示符面板提供当前文件的相对路径作为种子: > @@ -1045,7 +1047,7 @@ b) 在正则表达式模式,输入字符串被按照Vim的正则表达式模 例如: 'abc\d*efg' 会被解读为 'abc\d*efg'。 - 如何启用正则表达式模式参见 |ctrlp-fullregexp| (按键绑定)和 + 如何启用正则表达式模式参见 |ctrlp-fullregexp| (按键绑定)和 |g:ctrlp_regexp_search| (选项)。 c) 字符串末尾使用一个冒号':'跟随一个Vim命令来在打开那个文件后执行该命令。如果 @@ -1255,7 +1257,7 @@ h) 使用?打开帮助文件。 这样只会忽略包含 "build" 的目录和包含 "foo.txt" 的文件。不会忽略带 有 "build" 的文件或者反过来。 - 注意: 如果为了忽略名为 "build" 的目录,而不是『任何』包含 "build" + 注意: 如果为了忽略名为 "build" 的目录,而不是『任何』包含 "build" 的目录,你可以使用下面的正则: ^build$ - 常见问题: diff --git a/sources_non_forked/ctrlp.vim/doc/ctrlp.txt b/sources_non_forked/ctrlp.vim/doc/ctrlp.txt index 424dd36d..82eecfcb 100644 --- a/sources_non_forked/ctrlp.vim/doc/ctrlp.txt +++ b/sources_non_forked/ctrlp.vim/doc/ctrlp.txt @@ -437,12 +437,12 @@ Note: does not apply when a command defined with |g:ctrlp_user_command| is being used. *'g:ctrlp_lazy_update'* -Set this to 1 to enable the lazy-update feature: only update the match window -after typing's been stopped for a certain amount of time: > +Set this to 1 or bigger to enable the lazy-update feature: only update the +match window after typing's been stopped for a certain amount of time: > let g:ctrlp_lazy_update = 0 < -If is 1, update after 250ms. If bigger than 1, the number will be used as the -delay time in milliseconds. +If is 1, update after 250ms that value as default tuned. If bigger than 1, the +number will be used as the delay time in milliseconds. *'g:ctrlp_default_input'* Set this to 1 to enable seeding the prompt with the current file's relative @@ -462,7 +462,7 @@ Includes the current file in the match entries: > By default, the current file is excluded from the list. -Note: does not apply when |g:ctrlp_match_func| is used. +Note: does not apply when |g:ctrlp_match_func| is used. *'g:ctrlp_types'* Set this to list of names to customize core types: > @@ -1107,13 +1107,13 @@ c) End the string with a colon ':' followed by a Vim command to execute that See also: Vim's |++opt| and |+cmd|. -d) Submit two dots '..' to go upward the directory tree by 1 level. To go up +d) Input two dots '..' and then hit the key to go upward the directory tree by 1 level. To go up multiple levels, use one extra dot for each extra level: > Raw input Interpreted as - .. ../ - ... ../../ - .... ../../../ + .. ../ + ... ../../ + .... ../../../ < Note: if the parent directories are large and uncached, this can be slow. diff --git a/sources_non_forked/goyo.vim/autoload/goyo.vim b/sources_non_forked/goyo.vim/autoload/goyo.vim index 6667620e..0593f78c 100644 --- a/sources_non_forked/goyo.vim/autoload/goyo.vim +++ b/sources_non_forked/goyo.vim/autoload/goyo.vim @@ -203,7 +203,7 @@ function! s:goyo_on(dim) endif " vim-signify - let t:goyo_disabled_signify = exists('b:sy') && b:sy.active + let t:goyo_disabled_signify = !empty(getbufvar(bufnr(''), 'sy')) if t:goyo_disabled_signify SignifyToggle endif diff --git a/sources_non_forked/goyo.vim/doc/goyo.txt b/sources_non_forked/goyo.vim/doc/goyo.txt index b8050226..0dc57b2a 100644 --- a/sources_non_forked/goyo.vim/doc/goyo.txt +++ b/sources_non_forked/goyo.vim/doc/goyo.txt @@ -32,8 +32,6 @@ INSTALLATION *goyo-installation* Use your favorite plugin manager. - *:PlugInstall* - - {vim-plug}{3} 1. Add `Plug 'junegunn/goyo.vim'` to .vimrc 2. Run `:PlugInstall` diff --git a/sources_non_forked/gruvbox/README.md b/sources_non_forked/gruvbox/README.md index 4269786c..eca249c0 100644 --- a/sources_non_forked/gruvbox/README.md +++ b/sources_non_forked/gruvbox/README.md @@ -1,4 +1,4 @@ -

+ gruvbox is heavily inspired by [badwolf][], [jellybeans][] and [solarized][]. @@ -13,7 +13,7 @@ Attention 1. [Read this first](https://github.com/morhetz/gruvbox/wiki/Terminal-specific) 2. Typeface from gallery is [Fantasque Sans Mono](https://github.com/belluzj/fantasque-sans) -3. Typeface from screenshots below is [Fira Mono](http://www.carrois.com/fira-4-1/) +3. Typeface from screenshots below is [Fira Mono](https://mozilla.github.io/Fira/) Screenshots ----------- diff --git a/sources_non_forked/gruvbox/colors/gruvbox.vim b/sources_non_forked/gruvbox/colors/gruvbox.vim index a0c2c0ba..66246fba 100644 --- a/sources_non_forked/gruvbox/colors/gruvbox.vim +++ b/sources_non_forked/gruvbox/colors/gruvbox.vim @@ -454,6 +454,7 @@ call s:HL('GruvboxYellowSign', s:yellow, s:sign_column, s:invert_signs) call s:HL('GruvboxBlueSign', s:blue, s:sign_column, s:invert_signs) call s:HL('GruvboxPurpleSign', s:purple, s:sign_column, s:invert_signs) call s:HL('GruvboxAquaSign', s:aqua, s:sign_column, s:invert_signs) +call s:HL('GruvboxOrangeSign', s:orange, s:sign_column, s:invert_signs) " }}} @@ -888,6 +889,30 @@ hi! link NERDTreeToggleOff GruvboxRed call s:HL('multiple_cursors_cursor', s:none, s:none, s:inverse) call s:HL('multiple_cursors_visual', s:none, s:bg2) +" }}} +" coc.nvim: {{{ + +hi! link CocErrorSign GruvboxRedSign +hi! link CocWarningSign GruvboxOrangeSign +hi! link CocInfoSign GruvboxYellowSign +hi! link CocHintSign GruvboxBlueSign +hi! link CocErrorFloat GruvboxRed +hi! link CocWarningFloat GruvboxOrange +hi! link CocInfoFloat GruvboxYellow +hi! link CocHintFloat GruvboxBlue +hi! link CocDiagnosticsError GruvboxRed +hi! link CocDiagnosticsWarning GruvboxOrange +hi! link CocDiagnosticsInfo GruvboxYellow +hi! link CocDiagnosticsHint GruvboxBlue + +hi! link CocSelectedText GruvboxRed +hi! link CocCodeLens GruvboxGray + +call s:HL('CocErrorHighlight', s:none, s:none, s:undercurl, s:red) +call s:HL('CocWarningHighlight', s:none, s:none, s:undercurl, s:orange) +call s:HL('CocInfoHighlight', s:none, s:none, s:undercurl, s:yellow) +call s:HL('CocHintHighlight', s:none, s:none, s:undercurl, s:blue) + " }}} " Filetype specific ----------------------------------------------------------- diff --git a/sources_non_forked/lightline-ale/autoload/lightline/ale.vim b/sources_non_forked/lightline-ale/autoload/lightline/ale.vim index 0b34f7bc..c04f5ab7 100644 --- a/sources_non_forked/lightline-ale/autoload/lightline/ale.vim +++ b/sources_non_forked/lightline-ale/autoload/lightline/ale.vim @@ -52,6 +52,7 @@ endfunction function! lightline#ale#linted() abort return get(g:, 'ale_enabled', 0) == 1 + \ && getbufvar(bufnr(''), 'ale_enabled', 1) \ && getbufvar(bufnr(''), 'ale_linted', 0) > 0 \ && ale#engine#IsCheckingBuffer(bufnr('')) == 0 endfunction diff --git a/sources_non_forked/lightline.vim/.github/workflows/ci.yaml b/sources_non_forked/lightline.vim/.github/workflows/ci.yaml new file mode 100644 index 00000000..7d2a185b --- /dev/null +++ b/sources_non_forked/lightline.vim/.github/workflows/ci.yaml @@ -0,0 +1,38 @@ +name: CI + +on: + push: + branches: + - master + pull_request: + +jobs: + test: + name: Test + runs-on: ubuntu-latest + strategy: + matrix: + vim: + - v8.2.1000 + - v8.2.0000 + - v8.1.0000 + - v8.0.0000 + - v7.4 + - v7.3 + steps: + - name: Checkout code + uses: actions/checkout@main + - name: Checkout vim-themis + uses: actions/checkout@main + with: + repository: thinca/vim-themis + path: vim-themis + - name: Setup Vim + uses: rhysd/action-setup-vim@v1 + id: vim + with: + version: ${{ matrix.vim }} + - name: Test + env: + THEMIS_VIM: ${{ steps.vim.outputs.executable }} + run: ./vim-themis/bin/themis --reporter spec diff --git a/sources_non_forked/lightline.vim/.travis.yml b/sources_non_forked/lightline.vim/.travis.yml deleted file mode 100644 index e7e41c51..00000000 --- a/sources_non_forked/lightline.vim/.travis.yml +++ /dev/null @@ -1,28 +0,0 @@ -language: generic - -install: - - git clone --depth=1 https://github.com/thinca/vim-themis /tmp/themis - - (if ! test -d $HOME/vim-$VIM_VERSION/bin; then - git clone https://github.com/vim/vim $HOME/vim && - cd $HOME/vim && - git checkout v$VIM_VERSION && - ./configure --prefix=$HOME/vim-$VIM_VERSION && - make && - make install; - fi) - -cache: - directories: - - $HOME/vim-$VIM_VERSION - -env: - - VIM_VERSION=8.2.0000 - - VIM_VERSION=8.1.0000 - - VIM_VERSION=8.0.0000 - - VIM_VERSION=7.4 - - VIM_VERSION=7.3 - -script: - - export PATH=$HOME/vim-$VIM_VERSION/bin:$PATH - - vim --version - - /tmp/themis/bin/themis --reporter spec diff --git a/sources_non_forked/lightline.vim/README.md b/sources_non_forked/lightline.vim/README.md index bb116378..41f98022 100644 --- a/sources_non_forked/lightline.vim/README.md +++ b/sources_non_forked/lightline.vim/README.md @@ -17,23 +17,31 @@ https://github.com/itchyny/lightline.vim ### solarized dark -![lightline.vim - solarized_dark](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/solarized_dark.png) +![lightline.vim - solarized dark](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/solarized_dark.png) ### solarized light -![lightline.vim - solarized_light](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/solarized_light.png) +![lightline.vim - solarized light](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/solarized_light.png) + +### PaperColor dark + +![lightline.vim - PaperColor dark](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/PaperColor_dark.png) ### PaperColor light -![lightline.vim - PaperColor](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/PaperColor.png) +![lightline.vim - PaperColor light](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/PaperColor_light.png) ### seoul256 ![lightline.vim - seoul256](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/seoul256.png) -### one +### one dark -![lightline.vim - one](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/one.png) +![lightline.vim - one dark](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/one_dark.png) + +### one light + +![lightline.vim - one light](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/one_light.png) ### landscape @@ -55,7 +63,8 @@ For screenshots of all available colorshemes, see [this file](colorscheme.md). + Orthogonality. The plugin does not rely on the implementation of other plugins. Such plugin crossing settings should be configured by users. ## Installation -### [Vim packages](http://vimhelp.appspot.com/repeat.txt.html#packages) (since Vim 7.4.1528) +### [Vim packages](https://vimhelp.org/repeat.txt.html#packages) (since Vim 7.4.1528) +1. Clone the plugin with the following command. git clone https://github.com/itchyny/lightline.vim ~/.vim/pack/plugins/start/lightline diff --git a/sources_non_forked/lightline.vim/autoload/lightline.vim b/sources_non_forked/lightline.vim/autoload/lightline.vim index 07800f42..5862557f 100644 --- a/sources_non_forked/lightline.vim/autoload/lightline.vim +++ b/sources_non_forked/lightline.vim/autoload/lightline.vim @@ -2,7 +2,7 @@ " Filename: autoload/lightline.vim " Author: itchyny " License: MIT License -" Last Change: 2020/01/27 19:41:58. +" Last Change: 2020/11/21 14:03:29. " ============================================================================= let s:save_cpo = &cpo @@ -11,34 +11,35 @@ set cpo&vim let s:_ = 1 " 1: uninitialized, 2: disabled function! lightline#update() abort - if &buftype ==# 'popup' | return | endif + if s:skip() | return | endif if s:_ if s:_ == 2 | return | endif call lightline#init() call lightline#colorscheme() endif - if !s:lightline.enable.statusline - return + if s:lightline.enable.statusline + let w = winnr() + let s = winnr('$') == 1 && w > 0 ? [lightline#statusline(0)] : [lightline#statusline(0), lightline#statusline(1)] + for n in range(1, winnr('$')) + call setwinvar(n, '&statusline', s[n!=w]) + endfor endif - let w = winnr() - let s = winnr('$') == 1 && w > 0 ? [lightline#statusline(0)] : [lightline#statusline(0), lightline#statusline(1)] - for n in range(1, winnr('$')) - call setwinvar(n, '&statusline', s[n!=w]) - call setwinvar(n, 'lightline', n!=w) - endfor endfunction -function! lightline#update_once() abort - if !exists('w:lightline') || w:lightline - call lightline#update() - endif -endfunction +if exists('*win_gettype') + function! s:skip() abort " Vim 8.2.0257 (00f3b4e007), 8.2.0991 (0fe937fd86), 8.2.0996 (40a019f157) + return win_gettype() ==# 'popup' || win_gettype() ==# 'autocmd' + endfunction +else + function! s:skip() abort + return &buftype ==# 'popup' + endfunction +endif function! lightline#update_disable() abort - if !s:lightline.enable.statusline - return + if s:lightline.enable.statusline + call setwinvar(0, '&statusline', '') endif - call setwinvar(0, '&statusline', '') endfunction function! lightline#enable() abort @@ -46,14 +47,13 @@ function! lightline#enable() abort call lightline#update() augroup lightline autocmd! - autocmd WinEnter,BufEnter,SessionLoadPost * call lightline#update() + autocmd WinEnter,BufEnter,BufDelete,SessionLoadPost,FileChangedShellPost * call lightline#update() if !has('patch-8.1.1715') autocmd FileType qf call lightline#update() endif autocmd SessionLoadPost * call lightline#highlight() autocmd ColorScheme * if !has('vim_starting') || expand('') !=# 'macvim' \ | call lightline#update() | call lightline#highlight() | endif - autocmd CursorMoved,BufUnload * call lightline#update_once() augroup END augroup lightline-disable autocmd! @@ -110,7 +110,7 @@ let s:_lightline = { \ 'paste': '%{&paste?"PASTE":""}', 'readonly': '%R', 'charvalue': '%b', 'charvaluehex': '%B', \ 'spell': '%{&spell?&spelllang:""}', 'fileencoding': '%{&fenc!=#""?&fenc:&enc}', 'fileformat': '%{&ff}', \ 'filetype': '%{&ft!=#""?&ft:"no ft"}', 'percent': '%3p%%', 'percentwin': '%P', - \ 'lineinfo': '%3l:%-2v', 'line': '%l', 'column': '%c', 'close': '%999X X ', 'winnr': '%{winnr()}' + \ 'lineinfo': '%3l:%-2c', 'line': '%l', 'column': '%c', 'close': '%999X X ', 'winnr': '%{winnr()}' \ }, \ 'component_visible_condition': { \ 'modified': '&modified||!&modifiable', 'readonly': '&readonly', 'paste': '&paste', 'spell': '&spell' @@ -145,7 +145,6 @@ let s:_lightline = { \ }, \ 'mode_fallback': { 'replace': 'insert', 'terminal': 'insert', 'select': 'visual' }, \ 'palette': {}, - \ 'winwidth': winwidth(0), \ } function! lightline#init() abort let s:lightline = deepcopy(get(g:, 'lightline', {})) @@ -198,13 +197,7 @@ function! lightline#colorscheme() abort let s:lightline.palette = g:lightline#colorscheme#{s:lightline.colorscheme}#palette finally if has('win32') && !has('gui_running') && &t_Co < 256 - for u in values(s:lightline.palette) - for v in values(u) - for _ in v - let [_[2], _[3]] = [lightline#colortable#gui2cui(_[0], _[2]), lightline#colortable#gui2cui(_[1], _[3])] - endfor - endfor - endfor + call lightline#colortable#gui2cui_palette(s:lightline.palette) endif let s:highlight = {} call lightline#highlight('normal') @@ -224,7 +217,7 @@ endfunction let s:mode = '' function! lightline#link(...) abort let mode = get(s:lightline._mode_, a:0 ? a:1 : mode(), 'normal') - if s:mode == mode + if s:mode ==# mode return '' endif let s:mode = mode @@ -297,6 +290,7 @@ function! lightline#highlight(...) abort endfor exec printf('hi LightlineMiddle_%s guifg=%s guibg=%s ctermfg=%s ctermbg=%s %s', mode, ms[0], ms[1], ms[2], ms[3], s:term(ms)) endfor + if !a:0 | let s:mode = '' | endif endfunction function! s:subseparator(components, subseparator, expanded) abort @@ -342,45 +336,24 @@ function! s:evaluate_expand(component) abort endfunction function! s:convert(name, index) abort - if has_key(s:lightline.component_expand, a:name) + if !has_key(s:lightline.component_expand, a:name) + return [[[a:name], 0, a:index, a:index]] + else let type = get(s:lightline.component_type, a:name, a:index) let is_raw = get(s:lightline.component_raw, a:name) || type ==# 'raw' - return filter(s:map(s:evaluate_expand(s:lightline.component_expand[a:name]), + return filter(map(s:evaluate_expand(s:lightline.component_expand[a:name]), \ '[v:val, 1 + ' . is_raw . ', v:key == 1 && ' . (type !=# 'raw') . ' ? "' . type . '" : "' . a:index . '", "' . a:index . '"]'), 'v:val[0] != []') - else - return [[[a:name], 0, a:index, a:index]] endif endfunction -function! s:flatten_twice(xss) abort - let ys = [] - for xs in a:xss - for x in xs - let ys += x - endfor - endfor - return ys -endfunction - -if v:version > 702 || v:version == 702 && has('patch295') - let s:map = function('map') -else - function! s:map(xs, f) abort - let ys = [] - for i in range(len(a:xs)) - call extend(ys, map(a:xs[(i):(i)], substitute(a:f, 'v:key', i, 'g'))) - endfor - return ys - endfunction -endif - function! s:expand(components) abort let components = [] let expanded = [] let indices = [] let prevtype = '' let previndex = -1 - let xs = s:flatten_twice(s:map(deepcopy(a:components), 'map(v:val, "s:convert(v:val, ''" . v:key . "'')")')) + let xs = [] + call map(deepcopy(a:components), 'map(v:val, "extend(xs, s:convert(v:val, ''" . v:key . "''))")') for [component, expand, type, index] in xs if prevtype !=# type for i in range(previndex + 1, max([previndex, index - 1])) @@ -406,6 +379,10 @@ function! s:expand(components) abort return [components, expanded, indices] endfunction +function! s:func(name) abort + return exists('*' . a:name) ? '%{' . a:name . '()}' : '%{exists("*' . a:name . '")?' . a:name . '():""}' +endfunction + function! s:line(tabline, inactive) abort let _ = a:tabline ? '' : '%{lightline#link()}' if s:lightline.palette == {} @@ -415,32 +392,32 @@ function! s:line(tabline, inactive) abort let [p, s] = a:tabline ? [s:lightline.tabline_separator, s:lightline.tabline_subseparator] : [s:lightline.separator, s:lightline.subseparator] let [c, f, t, w] = [s:lightline.component, s:lightline.component_function, s:lightline.component_type, s:lightline.component_raw] let mode = a:tabline ? 'tabline' : a:inactive ? 'inactive' : 'active' - let l_ = has_key(s:lightline, mode) ? s:lightline[mode].left : s:lightline.active.left - let [lt, lc, ll] = s:expand(copy(l_)) - let r_ = has_key(s:lightline, mode) ? s:lightline[mode].right : s:lightline.active.right - let [rt, rc, rl] = s:expand(copy(r_)) - for i in range(len(lt)) - let _ .= '%#LightlineLeft_' . mode . '_' . ll[i] . '#' - for j in range(len(lt[i])) - let x = lc[i][j] ? lt[i][j] : has_key(f, lt[i][j]) ? (exists('*' . f[lt[i][j]]) ? '%{' . f[lt[i][j]] . '()}' : '%{exists("*' . f[lt[i][j]] . '")?' . f[lt[i][j]] . '():""}') : get(c, lt[i][j], '') - let _ .= has_key(t, lt[i][j]) && t[lt[i][j]] ==# 'raw' || get(w, lt[i][j]) || lc[i][j] ==# 2 || x ==# '' ? x : '%( ' . x . ' %)' - if j < len(lt[i]) - 1 && s.left !=# '' - let _ .= s:subseparator(lt[i][(j):], s.left, lc[i][(j):]) + let ls = has_key(s:lightline, mode) ? s:lightline[mode].left : s:lightline.active.left + let [lc, le, li] = s:expand(ls) + let rs = has_key(s:lightline, mode) ? s:lightline[mode].right : s:lightline.active.right + let [rc, re, ri] = s:expand(rs) + for i in range(len(lc)) + let _ .= '%#LightlineLeft_' . mode . '_' . li[i] . '#' + for j in range(len(lc[i])) + let x = le[i][j] ? lc[i][j] : has_key(f, lc[i][j]) ? s:func(f[lc[i][j]]) : get(c, lc[i][j], '') + let _ .= has_key(t, lc[i][j]) && t[lc[i][j]] ==# 'raw' || get(w, lc[i][j]) || le[i][j] ==# 2 || x ==# '' ? x : '%( ' . x . ' %)' + if j < len(lc[i]) - 1 && s.left !=# '' + let _ .= s:subseparator(lc[i][(j):], s.left, le[i][(j):]) endif endfor - let _ .= '%#LightlineLeft_' . mode . '_' . ll[i] . '_' . ll[i + 1] . '#' - let _ .= i < l + len(lt) - len(l_) && ll[i] < l || ll[i] != ll[i + 1] ? p.left : len(lt[i]) ? s.left : '' + let _ .= '%#LightlineLeft_' . mode . '_' . li[i] . '_' . li[i + 1] . '#' + let _ .= i < l + len(lc) - len(ls) && li[i] < l || li[i] != li[i + 1] ? p.left : len(lc[i]) ? s.left : '' endfor let _ .= '%#LightlineMiddle_' . mode . '#%=' - for i in range(len(rt) - 1, 0, -1) - let _ .= '%#LightlineRight_' . mode . '_' . rl[i] . '_' . rl[i + 1] . '#' - let _ .= i < r + len(rt) - len(r_) && rl[i] < r || rl[i] != rl[i + 1] ? p.right : len(rt[i]) ? s.right : '' - let _ .= '%#LightlineRight_' . mode . '_' . rl[i] . '#' - for j in range(len(rt[i])) - let x = rc[i][j] ? rt[i][j] : has_key(f, rt[i][j]) ? (exists('*' . f[rt[i][j]]) ? '%{' . f[rt[i][j]] . '()}' : '%{exists("*' . f[rt[i][j]] . '")?' . f[rt[i][j]] . '():""}') : get(c, rt[i][j], '') - let _ .= has_key(t, rt[i][j]) && t[rt[i][j]] ==# 'raw' || get(w, rt[i][j]) || rc[i][j] ==# 2 || x ==# '' ? x : '%( ' . x . ' %)' - if j < len(rt[i]) - 1 && s.right !=# '' - let _ .= s:subseparator(rt[i][(j):], s.right, rc[i][(j):]) + for i in range(len(rc) - 1, 0, -1) + let _ .= '%#LightlineRight_' . mode . '_' . ri[i] . '_' . ri[i + 1] . '#' + let _ .= i < r + len(rc) - len(rs) && ri[i] < r || ri[i] != ri[i + 1] ? p.right : len(rc[i]) ? s.right : '' + let _ .= '%#LightlineRight_' . mode . '_' . ri[i] . '#' + for j in range(len(rc[i])) + let x = re[i][j] ? rc[i][j] : has_key(f, rc[i][j]) ? s:func(f[rc[i][j]]) : get(c, rc[i][j], '') + let _ .= has_key(t, rc[i][j]) && t[rc[i][j]] ==# 'raw' || get(w, rc[i][j]) || re[i][j] ==# 2 || x ==# '' ? x : '%( ' . x . ' %)' + if j < len(rc[i]) - 1 && s.right !=# '' + let _ .= s:subseparator(rc[i][(j):], s.right, re[i][(j):]) endif endfor endfor @@ -449,14 +426,16 @@ endfunction let s:tabnr = -1 let s:tabcnt = -1 +let s:columns = -1 let s:tabline = '' function! lightline#tabline() abort if !has_key(s:highlight, 'tabline') call lightline#highlight('tabline') endif - if s:lightline.tabline_configured || s:tabnr != tabpagenr() || s:tabcnt != tabpagenr('$') + if s:lightline.tabline_configured || s:tabnr != tabpagenr() || s:tabcnt != tabpagenr('$') || s:columns != &columns let s:tabnr = tabpagenr() let s:tabcnt = tabpagenr('$') + let s:columns = &columns let s:tabline = s:line(1, 0) endif return s:tabline @@ -467,10 +446,10 @@ function! lightline#tabs() abort let nr = tabpagenr() let cnt = tabpagenr('$') for i in range(1, cnt) - call add(i < nr ? x : i == nr ? y : z, (i > nr + 3 ? '%<' : '') . '%'. i . 'T%{lightline#onetab(' . i . ',' . (i == nr) . ')}' . (i == cnt ? '%T' : '')) + call add(i < nr ? x : i == nr ? y : z, (i > nr + 3 ? '%<' : '') . '%' . i . 'T%{lightline#onetab(' . i . ',' . (i == nr) . ')}' . (i == cnt ? '%T' : '')) endfor let abbr = '...' - let n = min([max([s:lightline.winwidth / 40, 2]), 8]) + let n = min([max([&columns / 40, 2]), 8]) if len(x) > n && len(z) > n let x = extend(add(x[:n/2-1], abbr), x[-(n+1)/2:]) let z = extend(add(z[:(n+1)/2-1], abbr), z[-n/2:]) diff --git a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/16color.vim b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/16color.vim index 41e64970..19591024 100644 --- a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/16color.vim +++ b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/16color.vim @@ -1,49 +1,53 @@ " ============================================================================= " Filename: autoload/lightline/colorscheme/16color.vim -" Author: itchyny +" Author: itchyny, jackno " License: MIT License -" Last Change: 2017/11/25 11:14:04. " ============================================================================= -let s:base03 = [ '#808080', 8 ] -let s:base02 = [ '#000000', 0 ] -let s:base01 = [ '#00ff00', 10 ] -let s:base00 = [ '#ffff00', 11 ] -let s:base0 = [ '#0000ff', 12 ] -let s:base1 = [ '#00ffff', 14 ] -let s:base2 = [ '#c0c0c0', 7 ] -let s:base3 = [ '#ffffff', 15 ] -let s:yellow = [ '#808000', 3 ] -let s:orange = [ '#ff0000', 9 ] -let s:red = [ '#800000', 1 ] -let s:magenta = [ '#800080', 5 ] -let s:violet = [ '#ff00ff', 13 ] -let s:blue = [ '#000080', 4 ] -let s:cyan = [ '#008080', 6 ] +let s:black = [ '#000000', 0 ] +let s:maroon = [ '#800000', 1 ] let s:green = [ '#008000', 2 ] +let s:olive = [ '#808000', 3 ] +let s:navy = [ '#000080', 4 ] +let s:purple = [ '#800080', 5 ] +let s:teal = [ '#008080', 6 ] +let s:silver = [ '#c0c0c0', 7 ] +let s:gray = [ '#808080', 8] +let s:red = [ '#ff0000', 9 ] +let s:lime = [ '#00ff00', 10 ] +let s:yellow = [ '#ffff00', 11 ] +let s:blue = [ '#0000ff', 12 ] +let s:fuchsia = [ '#ff00ff', 13 ] +let s:aqua = [ '#00ffff', 14 ] +let s:white = [ '#ffffff', 15 ] if lightline#colorscheme#background() ==# 'light' - let [s:base03, s:base3] = [s:base3, s:base03] - let [s:base02, s:base2] = [s:base2, s:base02] - let [s:base01, s:base1] = [s:base1, s:base01] - let [s:base00, s:base0] = [s:base0, s:base00] + let [s:black, s:white] = [s:white, s:black] + let [s:silver, s:gray] = [s:gray, s:silver] + let [s:blue, s:aqua] = [s:aqua, s:blue] + let [s:purple, s:fuchsia] = [s:fuchsia, s:purple] + let [s:green, s:lime] = [s:lime, s:green] + let [s:red, s:yellow] = [s:yellow, s:red] endif let s:p = {'normal': {}, 'inactive': {}, 'insert': {}, 'replace': {}, 'visual': {}, 'tabline': {}} -let s:p.normal.left = [ [ s:base3, s:blue ], [ s:base3, s:base01 ] ] -let s:p.normal.right = [ [ s:base02, s:base0 ], [ s:base1, s:base01 ] ] -let s:p.inactive.right = [ [ s:base02, s:base01 ], [ s:base00, s:base02 ] ] -let s:p.inactive.left = [ [ s:base0, s:base02 ], [ s:base00, s:base02 ] ] -let s:p.insert.left = [ [ s:base3, s:green ], [ s:base3, s:base01 ] ] -let s:p.replace.left = [ [ s:base3, s:red ], [ s:base3, s:base01 ] ] -let s:p.visual.left = [ [ s:base3, s:magenta ], [ s:base3, s:base01 ] ] -let s:p.normal.middle = [ [ s:base1, s:base02 ] ] -let s:p.inactive.middle = [ [ s:base0, s:base02 ] ] -let s:p.tabline.left = [ [ s:base2, s:base01 ] ] -let s:p.tabline.tabsel = [ [ s:base2, s:base02 ] ] -let s:p.tabline.middle = [ [ s:base01, s:base2 ] ] +let s:p.normal.left = [ [ s:white, s:blue ], [ s:white, s:gray ] ] +let s:p.normal.middle = [ [ s:silver, s:black ] ] +let s:p.normal.right = [ [ s:white, s:blue ], [ s:white, s:gray ] ] +let s:p.normal.error = [ [ s:black, s:red ] ] +let s:p.normal.warning = [ [ s:black, s:yellow ] ] +let s:p.inactive.left = [ [ s:silver, s:gray ], [ s:gray, s:black ] ] +let s:p.inactive.middle = [ [ s:silver, s:black ] ] +let s:p.inactive.right = [ [ s:silver, s:gray ], [ s:gray, s:black ] ] +let s:p.insert.left = [ [ s:white, s:green ], [ s:white, s:gray ] ] +let s:p.insert.right = copy(s:p.insert.left) +let s:p.replace.left = [ [ s:white, s:red ], [ s:white, s:gray ] ] +let s:p.replace.right = copy(s:p.replace.left) +let s:p.visual.left = [ [ s:white, s:purple ], [ s:white, s:gray ] ] +let s:p.visual.right = copy(s:p.visual.left) +let s:p.tabline.left = [ [ s:silver, s:black ] ] +let s:p.tabline.tabsel = copy(s:p.normal.right) +let s:p.tabline.middle = [ [ s:silver, s:black ] ] let s:p.tabline.right = copy(s:p.normal.right) -let s:p.normal.error = [ [ s:base2, s:red ] ] -let s:p.normal.warning = [ [ s:base02, s:yellow ] ] let g:lightline#colorscheme#16color#palette = lightline#colorscheme#flatten(s:p) diff --git a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/ayu_dark.vim b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/ayu_dark.vim new file mode 100644 index 00000000..cb10a258 --- /dev/null +++ b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/ayu_dark.vim @@ -0,0 +1,42 @@ +" ============================================================================= +" Filename: autoload/lightline/colorscheme/ayu_dark.vim +" Author: danielpeng2 +" License: MIT License +" Last Change: 2020/05/01 19:37:33. +" ============================================================================= + +let s:base0 = '#e6e1cf' +let s:base1 = '#e6e1cf' +let s:base2 = '#3e4b59' +let s:base3 = '#e6e1cf' +let s:base00 = '#14191f' +let s:base01 = '#14191f' +let s:base02 = '#0f1419' +let s:base023 = '#0f1419' +let s:base03 = '#e6b673' +let s:yellow = '#e6b673' +let s:orange = '#ff7733' +let s:red = '#f07178' +let s:magenta = '#ffee99' +let s:blue = '#36a3d9' +let s:cyan = s:blue +let s:green = '#b8cc52' + +let s:p = {'normal': {}, 'inactive': {}, 'insert': {}, 'replace': {}, 'visual': {}, 'tabline': {}} +let s:p.normal.left = [ [ s:base02, s:blue ], [ s:base3, s:base01 ] ] +let s:p.normal.middle = [ [ s:base2, s:base02 ] ] +let s:p.normal.right = [ [ s:base02, s:base0 ], [ s:base1, s:base01 ] ] +let s:p.inactive.left = [ [ s:base1, s:base01 ], [ s:base3, s:base01 ] ] +let s:p.inactive.middle = [ [ s:base1, s:base023 ] ] +let s:p.inactive.right = [ [ s:base1, s:base01 ], [ s:base2, s:base02 ] ] +let s:p.insert.left = [ [ s:base02, s:green ], [ s:base3, s:base01 ] ] +let s:p.replace.left = [ [ s:base023, s:red ], [ s:base3, s:base01 ] ] +let s:p.visual.left = [ [ s:base02, s:magenta ], [ s:base3, s:base01 ] ] +let s:p.tabline.tabsel = [ [ s:base02, s:base03 ] ] +let s:p.tabline.left = [ [ s:base3, s:base00 ] ] +let s:p.tabline.middle = [ [ s:base2, s:base02 ] ] +let s:p.tabline.right = [ [ s:base2, s:base00 ] ] +let s:p.normal.error = [ [ s:base03, s:red ] ] +let s:p.normal.warning = [ [ s:base023, s:yellow ] ] + +let g:lightline#colorscheme#ayu_dark#palette = lightline#colorscheme#fill(s:p) diff --git a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/ayu_light.vim b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/ayu_light.vim new file mode 100644 index 00000000..d1f781aa --- /dev/null +++ b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/ayu_light.vim @@ -0,0 +1,42 @@ +" ============================================================================= +" Filename: autoload/lightline/colorscheme/ayu_light.vim +" Author: christalib +" License: MIT License +" Last Change: 2020/05/01 19:38:21. +" ============================================================================= + +let s:base0 = '#5C6773' +let s:base1 = '#5C6773' +let s:base2 = '#828C99' +let s:base3 = '#5C6773' +let s:base00 = '#FFFFFF' +let s:base01 = '#FFFFFF' +let s:base02 = '#FAFAFA' +let s:base023 = '#FAFAFA' +let s:base03 = '#E6B673' +let s:yellow = '#E6B673' +let s:orange = '#FF7733' +let s:red = '#f07178' +let s:magenta = '#A37ACC' +let s:blue = '#59c2ff' +let s:cyan = s:blue +let s:green = '#86B300' + +let s:p = {'normal': {}, 'inactive': {}, 'insert': {}, 'replace': {}, 'visual': {}, 'tabline': {}} +let s:p.normal.left = [ [ s:base02, s:blue ], [ s:base3, s:base01 ] ] +let s:p.normal.middle = [ [ s:base2, s:base02 ] ] +let s:p.normal.right = [ [ s:base02, s:base0 ], [ s:base1, s:base01 ] ] +let s:p.inactive.left = [ [ s:base1, s:base01 ], [ s:base3, s:base01 ] ] +let s:p.inactive.middle = [ [ s:base1, s:base023 ] ] +let s:p.inactive.right = [ [ s:base1, s:base01 ], [ s:base2, s:base02 ] ] +let s:p.insert.left = [ [ s:base02, s:green ], [ s:base3, s:base01 ] ] +let s:p.replace.left = [ [ s:base023, s:red ], [ s:base3, s:base01 ] ] +let s:p.visual.left = [ [ s:base02, s:magenta ], [ s:base3, s:base01 ] ] +let s:p.tabline.tabsel = [ [ s:base02, s:base03 ] ] +let s:p.tabline.left = [ [ s:base3, s:base00 ] ] +let s:p.tabline.middle = [ [ s:base2, s:base02 ] ] +let s:p.tabline.right = [ [ s:base2, s:base00 ] ] +let s:p.normal.error = [ [ s:base03, s:red ] ] +let s:p.normal.warning = [ [ s:base023, s:yellow ] ] + +let g:lightline#colorscheme#ayu_light#palette = lightline#colorscheme#fill(s:p) diff --git a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/ayu_mirage.vim b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/ayu_mirage.vim index 85da9025..fe7506fb 100644 --- a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/ayu_mirage.vim +++ b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/ayu_mirage.vim @@ -2,24 +2,26 @@ " Filename: autoload/lightline/colorscheme/ayu_mirage.vim " Author: impulse " License: MIT License -" Last Change: 2019/08/11 11:52:20. +" Last Change: 2020/05/01 19:37:21. " ============================================================================= -let s:base0 = [ '#d9d7ce', 244 ] -let s:base1 = [ '#d9d7ce', 247 ] -let s:base2 = [ '#607080', 248 ] -let s:base3 = [ '#d9d7ce', 252 ] -let s:base00 = [ '#272d38', 242 ] -let s:base01 = [ '#272d38', 240 ] -let s:base02 = [ '#212733', 238 ] -let s:base023 = [ '#212733', 236 ] -let s:base03 = [ '#ffc44c', 235 ] -let s:yellow = [ '#ffc44c', 180 ] -let s:orange = [ '#ffae57', 173 ] -let s:red = [ '#f07178', 203 ] -let s:magenta = [ '#d4bfff', 216 ] -let s:blue = [ '#59c2ff', 117 ] + +let s:base0 = '#d9d7ce' +let s:base1 = '#d9d7ce' +let s:base2 = '#607080' +let s:base3 = '#d9d7ce' +let s:base00 = '#272d38' +let s:base01 = '#272d38' +let s:base02 = '#212733' +let s:base023 = '#212733' +let s:base03 = '#ffc44c' +let s:yellow = '#ffc44c' +let s:orange = '#ffae57' +let s:red = '#f07178' +let s:magenta = '#d4bfff' +let s:blue = '#59c2ff' let s:cyan = s:blue -let s:green = [ '#bbe67e', 119 ] +let s:green = '#bbe67e' + let s:p = {'normal': {}, 'inactive': {}, 'insert': {}, 'replace': {}, 'visual': {}, 'tabline': {}} let s:p.normal.left = [ [ s:base02, s:blue ], [ s:base3, s:base01 ] ] let s:p.normal.middle = [ [ s:base2, s:base02 ] ] @@ -36,4 +38,5 @@ let s:p.tabline.middle = [ [ s:base2, s:base02 ] ] let s:p.tabline.right = [ [ s:base2, s:base00 ] ] let s:p.normal.error = [ [ s:base03, s:red ] ] let s:p.normal.warning = [ [ s:base023, s:yellow ] ] -let g:lightline#colorscheme#ayu_mirage#palette = lightline#colorscheme#flatten(s:p) + +let g:lightline#colorscheme#ayu_mirage#palette = lightline#colorscheme#fill(s:p) diff --git a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/deus.vim b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/deus.vim index 0a7da609..3f9f2265 100644 --- a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/deus.vim +++ b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/deus.vim @@ -2,7 +2,7 @@ " Filename: autoload/lightline/colorscheme/deus.vim " Author: nikersify " License: MIT License -" Last Change: 2018/01/24 13:26:00 +" Last Change: 2020/02/15 20:56:45. " ============================================================================= let s:term_red = 204 @@ -20,13 +20,12 @@ let s:p.normal.left = [ [ '#292c33', '#98c379', s:term_black, s:term_green, 'bol let s:p.normal.right = [ [ '#292c33', '#98c379', s:term_black, s:term_green ], [ '#abb2bf', '#3e4452', s:term_white, s:term_grey ], [ '#98c379', '#292c33', s:term_green, s:term_black ] ] let s:p.inactive.right = [ [ '#292c33', '#61afef', s:term_black, s:term_blue], [ '#abb2bf', '#3e4452', s:term_white, s:term_grey ] ] let s:p.inactive.left = s:p.inactive.right[1:] -" her let s:p.insert.left = [ [ '#292c33', '#61afef', s:term_black, s:term_blue, 'bold' ], [ '#61afef', '#292c33', s:term_blue, s:term_black ] ] let s:p.insert.right = [ [ '#292c33', '#61afef', s:term_black, s:term_blue ], [ '#ABB2BF', '#3E4452', s:term_white, s:term_grey ], [ '#61afef', '#292c33', s:term_blue, s:term_black ] ] let s:p.replace.left = [ [ '#292c33', '#e06c75', s:term_black, s:term_red, 'bold' ], [ '#e06c75', '#292c33', s:term_red, s:term_black ] ] -let s:p.replace.right = [ [ '#292c33', '#e06c75', s:term_black, s:term_red, 'bold' ], s:p.normal.right[1], [ '#e06c75', '#292c33', s:term_red, s:term_black ] ] +let s:p.replace.right = [ [ '#292c33', '#e06c75', s:term_black, s:term_red ], s:p.normal.right[1], [ '#e06c75', '#292c33', s:term_red, s:term_black ] ] let s:p.visual.left = [ [ '#292c33', '#c678dd', s:term_black, s:term_purple, 'bold' ], [ '#c678dd', '#292c33', s:term_purple, s:term_black ] ] -let s:p.visual.right = [ [ '#292c33', '#c678dd', s:term_black, s:term_purple, 'bold' ], s:p.normal.right[1], [ '#c678dd', '#292c33', s:term_purple, s:term_black ] ] +let s:p.visual.right = [ [ '#292c33', '#c678dd', s:term_black, s:term_purple ], s:p.normal.right[1], [ '#c678dd', '#292c33', s:term_purple, s:term_black ] ] let s:p.normal.middle = [ [ '#abb2bf', '#292c33', s:term_white, s:term_black ] ] let s:p.insert.middle = s:p.normal.middle let s:p.replace.middle = s:p.normal.middle diff --git a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/jellybeans.vim b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/jellybeans.vim index 15b2b35b..ba93f8ae 100644 --- a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/jellybeans.vim +++ b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/jellybeans.vim @@ -5,7 +5,7 @@ " Last Change: 2013/09/07 12:21:04. " ============================================================================= let s:base03 = [ '#151513', 233 ] -let s:base02 = [ '#30302c ', 236 ] +let s:base02 = [ '#30302c', 236 ] let s:base01 = [ '#4e4e43', 239 ] let s:base00 = [ '#666656', 242 ] let s:base0 = [ '#808070', 244 ] @@ -30,10 +30,10 @@ let s:p.replace.left = [ [ s:base02, s:red ], [ s:base3, s:base01 ] ] let s:p.visual.left = [ [ s:base02, s:magenta ], [ s:base3, s:base01 ] ] let s:p.normal.middle = [ [ s:base0, s:base02 ] ] let s:p.inactive.middle = [ [ s:base00, s:base02 ] ] -let s:p.tabline.left = [ [ s:base3, s:base00 ] ] -let s:p.tabline.tabsel = [ [ s:base3, s:base02 ] ] -let s:p.tabline.middle = [ [ s:base01, s:base1 ] ] -let s:p.tabline.right = copy(s:p.normal.right) +let s:p.tabline.left = copy(s:p.normal.middle) +let s:p.tabline.tabsel = [ [ s:base3, s:base00 ] ] +let s:p.tabline.middle = copy(s:p.normal.middle) +let s:p.tabline.right = copy(s:p.tabline.middle) let s:p.normal.error = [ [ s:red, s:base02 ] ] let s:p.normal.warning = [ [ s:yellow, s:base01 ] ] diff --git a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/molokai.vim b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/molokai.vim index 9d066a1b..c17cafbc 100644 --- a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/molokai.vim +++ b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/molokai.vim @@ -2,9 +2,9 @@ " Filename: autoload/lightline/colorscheme/molokai.vim " Author: challsted " License: MIT License -" Last Change: 2016/11/17 00:27:58. +" Last Change: 2020/02/15 20:57:45. " ============================================================================= -" + let s:black = [ '#232526', 233 ] let s:gray = [ '#808080', 244 ] let s:white = [ '#f8f8f2', 234 ] diff --git a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/selenized_black.vim b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/selenized_black.vim new file mode 100644 index 00000000..dc95139b --- /dev/null +++ b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/selenized_black.vim @@ -0,0 +1,49 @@ +" ============================================================================= +" Filename: autoload/lightline/colorscheme/selenized_black.vim +" Author: itchyny +" License: MIT License +" Last Change: 2020/05/02 16:56:50. +" ============================================================================= + +" https://github.com/jan-warchol/selenized/blob/master/the-values.md#selenized-black +let s:bg_1 = ['#252525', 0] +let s:bg_2 = ['#3b3b3b', 8] +let s:dim_0 = ['#777777', 7] +let s:red = ['#ed4a46', 1] +let s:green = ['#70b433', 2] +let s:yellow = ['#dbb32d', 3] +let s:blue = ['#368aeb', 4] +let s:magenta = ['#eb6eb7', 5] +let s:cyan = ['#3fc5b7', 6] +let s:brred = ['#ff5e56', 9] +let s:brgreen = ['#83c746', 10] +let s:bryellow = ['#efc541', 11] +let s:brblue = ['#4f9cfe', 12] +let s:brmagenta = ['#ff81ca', 13] +let s:brcyan = ['#56d8c9', 14] + +let s:p = {'normal': {}, 'inactive': {}, 'insert': {}, 'replace': {}, 'visual': {}, 'tabline': {}} + +let s:p.normal.right = [[ s:bg_1, s:blue ], [ s:cyan, s:bg_2 ], [ s:dim_0, s:bg_1 ]] +let s:p.normal.left = [[ s:bg_1, s:blue ], [ s:cyan, s:bg_2 ]] +let s:p.normal.middle = [[ s:dim_0, s:bg_1 ]] +let s:p.normal.error = [[ s:bg_1, s:red ]] +let s:p.normal.warning = [[ s:bg_1, s:yellow ]] + +let s:p.insert.right = [[ s:bg_1, s:green ], [ s:cyan, s:bg_2 ], [ s:dim_0, s:bg_1 ]] +let s:p.insert.left = [[ s:bg_1, s:green ], [ s:cyan, s:bg_2 ]] + +let s:p.visual.right = [[ s:bg_1, s:magenta ], [ s:cyan, s:bg_2 ], [ s:dim_0, s:bg_1 ]] +let s:p.visual.left = [[ s:bg_1, s:magenta ], [ s:cyan, s:bg_2 ]] + +let s:p.inactive.left = [[ s:brblue, s:bg_2 ], [ s:cyan, s:bg_2 ]] +let s:p.inactive.right = [[ s:brblue, s:bg_2 ], [ s:cyan, s:bg_2 ]] + +let s:p.replace.right = [[ s:bg_1, s:red ], [ s:cyan, s:bg_2 ], [ s:dim_0, s:bg_1 ]] +let s:p.replace.left = [[ s:bg_1, s:red ], [ s:cyan, s:bg_2 ]] + +let s:p.tabline.right = [[ s:bg_1, s:red ]] +let s:p.tabline.left = [[ s:cyan, s:bg_2 ]] +let s:p.tabline.tabsel = [[ s:bg_1, s:blue ]] + +let g:lightline#colorscheme#selenized_black#palette = lightline#colorscheme#flatten(s:p) diff --git a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/selenized_dark.vim b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/selenized_dark.vim index 585b948b..c3238384 100644 --- a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/selenized_dark.vim +++ b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/selenized_dark.vim @@ -2,49 +2,48 @@ " Filename: autoload/lightline/colorscheme/selenized_dark.vim " Author: Charles Hall " License: MIT License -" Last Change: 2019/07/22 11:05:34. +" Last Change: 2020/05/02 16:53:17. " ============================================================================= " https://github.com/jan-warchol/selenized/blob/master/the-values.md#selenized-dark -let s:black = [ "#184956", 0 ] -let s:red = [ "#fa5750", 1 ] -let s:green = [ "#75b938", 2 ] -let s:yellow = [ "#dbb32d", 3 ] -let s:blue = [ "#4695f7", 4 ] -let s:magenta = [ "#f275be", 5 ] -let s:cyan = [ "#41c7b9", 6 ] -let s:white = [ "#72898f", 7 ] -let s:brblack = [ "#2d5b69", 8 ] -let s:brred = [ "#ff665c", 9 ] -let s:brgreen = [ "#84c747", 10 ] -let s:bryellow = [ "#ebc13d", 11 ] -let s:brblue = [ "#58a3ff", 12 ] -let s:brmagenta = [ "#ff84cd", 13 ] -let s:brcyan = [ "#53d6c7", 14 ] -let s:brwhite = [ "#cad8d9", 15 ] +let s:bg_1 = ['#184956', 0] +let s:bg_2 = ['#2d5b69', 8] +let s:dim_0 = ['#72898f', 7] +let s:red = ['#fa5750', 1] +let s:green = ['#75b938', 2] +let s:yellow = ['#dbb32d', 3] +let s:blue = ['#4695f7', 4] +let s:magenta = ['#f275be', 5] +let s:cyan = ['#41c7b9', 6] +let s:brred = ['#ff665c', 9] +let s:brgreen = ['#84c747', 10] +let s:bryellow = ['#ebc13d', 11] +let s:brblue = ['#58a3ff', 12] +let s:brmagenta = ['#ff84cd', 13] +let s:brcyan = ['#53d6c7', 14] let s:p = {'normal': {}, 'inactive': {}, 'insert': {}, 'replace': {}, 'visual': {}, 'tabline': {}} -let s:p.normal.right = [[ s:black, s:blue ],[ s:cyan, s:brblack ],[ s:white, s:black ]] -let s:p.normal.left = [[ s:black, s:blue ],[ s:cyan, s:brblack ]] -let s:p.normal.middle = [[ s:black, s:black ]] -let s:p.normal.error = [[ s:black, s:red ]] -let s:p.normal.warning = [[ s:black, s:yellow ]] +let s:p.normal.right = [[ s:bg_1, s:blue ], [ s:cyan, s:bg_2 ], [ s:dim_0, s:bg_1 ]] +let s:p.normal.left = [[ s:bg_1, s:blue ], [ s:cyan, s:bg_2 ]] +let s:p.normal.middle = [[ s:dim_0, s:bg_1 ]] +let s:p.normal.error = [[ s:bg_1, s:red ]] +let s:p.normal.warning = [[ s:bg_1, s:yellow ]] -let s:p.insert.right = [[ s:black, s:green ],[ s:cyan, s:brblack ],[ s:white, s:black ]] -let s:p.insert.left = [[ s:black, s:green ],[ s:cyan, s:brblack ]] +let s:p.insert.right = [[ s:bg_1, s:green ], [ s:cyan, s:bg_2 ], [ s:dim_0, s:bg_1 ]] +let s:p.insert.left = [[ s:bg_1, s:green ], [ s:cyan, s:bg_2 ]] -let s:p.visual.right = [[ s:black, s:magenta ],[ s:cyan, s:brblack ],[ s:white, s:black ]] -let s:p.visual.left = [[ s:black, s:magenta ],[ s:cyan, s:brblack ]] +let s:p.visual.right = [[ s:bg_1, s:magenta ], [ s:cyan, s:bg_2 ], [ s:dim_0, s:bg_1 ]] +let s:p.visual.left = [[ s:bg_1, s:magenta ], [ s:cyan, s:bg_2 ]] -let s:p.inactive.left = [[ s:brblue, s:brblack ],[ s:cyan, s:brblack ]] -let s:p.inactive.right = [[ s:brblue, s:brblack ],[ s:cyan, s:brblack ]] +let s:p.inactive.left = [[ s:brblue, s:bg_2 ], [ s:cyan, s:bg_2 ]] +let s:p.inactive.right = [[ s:brblue, s:bg_2 ], [ s:cyan, s:bg_2 ]] -let s:p.replace.right = [[ s:black, s:red ],[ s:cyan, s:brblack ],[ s:white, s:black ]] -let s:p.replace.left = [[ s:black, s:red ],[ s:cyan, s:brblack ]] +let s:p.replace.right = [[ s:bg_1, s:red ], [ s:cyan, s:bg_2 ], [ s:dim_0, s:bg_1 ]] +let s:p.replace.left = [[ s:bg_1, s:red ], [ s:cyan, s:bg_2 ]] -let s:p.tabline.right = [[ s:black, s:red ]] -let s:p.tabline.left = [[ s:cyan, s:brblack ]] -let s:p.tabline.tabsel = [[ s:black, s:blue ]] +let s:p.tabline.right = [[ s:bg_1, s:red ]] +let s:p.tabline.left = [[ s:cyan, s:bg_2 ]] +let s:p.tabline.tabsel = [[ s:bg_1, s:blue ]] let g:lightline#colorscheme#selenized_dark#palette = lightline#colorscheme#flatten(s:p) diff --git a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/selenized_light.vim b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/selenized_light.vim new file mode 100644 index 00000000..979149d2 --- /dev/null +++ b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/selenized_light.vim @@ -0,0 +1,49 @@ +" ============================================================================= +" Filename: autoload/lightline/colorscheme/selenized_light.vim +" Author: itchyny +" License: MIT License +" Last Change: 2020/05/02 16:58:00. +" ============================================================================= + +" https://github.com/jan-warchol/selenized/blob/master/the-values.md#selenized-light +let s:bg_1 = ['#ece3cc', 0] +let s:bg_2 = ['#d5cdb6', 8] +let s:dim_0 = ['#909995', 7] +let s:red = ['#d2212d', 1] +let s:green = ['#489100', 2] +let s:yellow = ['#ad8900', 3] +let s:blue = ['#0072d4', 4] +let s:magenta = ['#ca4898', 5] +let s:cyan = ['#009c8f', 6] +let s:brred = ['#cc1729', 9] +let s:brgreen = ['#428b00', 10] +let s:bryellow = ['#a78300', 11] +let s:brblue = ['#006dce', 12] +let s:brmagenta = ['#c44392', 13] +let s:brcyan = ['#00978a', 14] + +let s:p = {'normal': {}, 'inactive': {}, 'insert': {}, 'replace': {}, 'visual': {}, 'tabline': {}} + +let s:p.normal.right = [[ s:bg_1, s:blue ], [ s:cyan, s:bg_2 ], [ s:dim_0, s:bg_1 ]] +let s:p.normal.left = [[ s:bg_1, s:blue ], [ s:cyan, s:bg_2 ]] +let s:p.normal.middle = [[ s:dim_0, s:bg_1 ]] +let s:p.normal.error = [[ s:bg_1, s:red ]] +let s:p.normal.warning = [[ s:bg_1, s:yellow ]] + +let s:p.insert.right = [[ s:bg_1, s:green ], [ s:cyan, s:bg_2 ], [ s:dim_0, s:bg_1 ]] +let s:p.insert.left = [[ s:bg_1, s:green ], [ s:cyan, s:bg_2 ]] + +let s:p.visual.right = [[ s:bg_1, s:magenta ], [ s:cyan, s:bg_2 ], [ s:dim_0, s:bg_1 ]] +let s:p.visual.left = [[ s:bg_1, s:magenta ], [ s:cyan, s:bg_2 ]] + +let s:p.inactive.left = [[ s:brblue, s:bg_2 ], [ s:cyan, s:bg_2 ]] +let s:p.inactive.right = [[ s:brblue, s:bg_2 ], [ s:cyan, s:bg_2 ]] + +let s:p.replace.right = [[ s:bg_1, s:red ], [ s:cyan, s:bg_2 ], [ s:dim_0, s:bg_1 ]] +let s:p.replace.left = [[ s:bg_1, s:red ], [ s:cyan, s:bg_2 ]] + +let s:p.tabline.right = [[ s:bg_1, s:red ]] +let s:p.tabline.left = [[ s:cyan, s:bg_2 ]] +let s:p.tabline.tabsel = [[ s:bg_1, s:blue ]] + +let g:lightline#colorscheme#selenized_light#palette = lightline#colorscheme#flatten(s:p) diff --git a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/selenized_white.vim b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/selenized_white.vim new file mode 100644 index 00000000..9da3a4e3 --- /dev/null +++ b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/selenized_white.vim @@ -0,0 +1,49 @@ +" ============================================================================= +" Filename: autoload/whiteline/colorscheme/selenized_white.vim +" Author: itchyny +" License: MIT License +" Last Change: 2020/05/03 19:34:07. +" ============================================================================= + +" https://github.com/jan-warchol/selenized/blob/master/the-values.md#selenized-white +let s:bg_1 = ['#ebebeb', 0] +let s:bg_2 = ['#cdcdcd', 8] +let s:dim_0 = ['#878787', 7] +let s:red = ['#d6000c', 1] +let s:green = ['#1d9700', 2] +let s:yellow = ['#c49700', 3] +let s:blue = ['#0064e4', 4] +let s:magenta = ['#dd0f9d', 5] +let s:cyan = ['#00ad9c', 6] +let s:brred = ['#bf0000', 9] +let s:brgreen = ['#008400', 10] +let s:bryellow = ['#af8500', 11] +let s:brblue = ['#0054cf', 12] +let s:brmagenta = ['#c7008b', 13] +let s:brcyan = ['#009a8a', 14] + +let s:p = {'normal': {}, 'inactive': {}, 'insert': {}, 'replace': {}, 'visual': {}, 'tabline': {}} + +let s:p.normal.right = [[ s:bg_1, s:blue ], [ s:cyan, s:bg_2 ], [ s:dim_0, s:bg_1 ]] +let s:p.normal.left = [[ s:bg_1, s:blue ], [ s:cyan, s:bg_2 ]] +let s:p.normal.middle = [[ s:dim_0, s:bg_1 ]] +let s:p.normal.error = [[ s:bg_1, s:red ]] +let s:p.normal.warning = [[ s:bg_1, s:yellow ]] + +let s:p.insert.right = [[ s:bg_1, s:green ], [ s:cyan, s:bg_2 ], [ s:dim_0, s:bg_1 ]] +let s:p.insert.left = [[ s:bg_1, s:green ], [ s:cyan, s:bg_2 ]] + +let s:p.visual.right = [[ s:bg_1, s:magenta ], [ s:cyan, s:bg_2 ], [ s:dim_0, s:bg_1 ]] +let s:p.visual.left = [[ s:bg_1, s:magenta ], [ s:cyan, s:bg_2 ]] + +let s:p.inactive.left = [[ s:brblue, s:bg_2 ], [ s:cyan, s:bg_2 ]] +let s:p.inactive.right = [[ s:brblue, s:bg_2 ], [ s:cyan, s:bg_2 ]] + +let s:p.replace.right = [[ s:bg_1, s:red ], [ s:cyan, s:bg_2 ], [ s:dim_0, s:bg_1 ]] +let s:p.replace.left = [[ s:bg_1, s:red ], [ s:cyan, s:bg_2 ]] + +let s:p.tabline.right = [[ s:bg_1, s:red ]] +let s:p.tabline.left = [[ s:cyan, s:bg_2 ]] +let s:p.tabline.tabsel = [[ s:bg_1, s:blue ]] + +let g:lightline#colorscheme#selenized_white#palette = lightline#colorscheme#flatten(s:p) diff --git a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/seoul256.vim b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/seoul256.vim index ca2d5a09..8bc3e5dd 100644 --- a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/seoul256.vim +++ b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/seoul256.vim @@ -5,7 +5,7 @@ " Last Change: 2015/11/02 08:23:27. " ============================================================================= let s:base03 = [ '#151513', 233 ] -let s:base02 = [ '#30302c ', 236 ] +let s:base02 = [ '#30302c', 236 ] let s:base01 = [ '#4e4e43', 239 ] let s:base00 = [ '#666656', 242 ] let s:base0 = [ '#808070', 244 ] diff --git a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/solarized.vim b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/solarized.vim index d6ee9c6b..53788311 100644 --- a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/solarized.vim +++ b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/solarized.vim @@ -2,7 +2,7 @@ " Filename: autoload/lightline/colorscheme/solarized.vim " Author: itchyny " License: MIT License -" Last Change: 2017/11/25 11:13:46. +" Last Change: 2020/04/06 19:22:53. " ============================================================================= let s:cuicolors = { @@ -73,7 +73,7 @@ let s:p.inactive.middle = [ [ s:base01, s:base02 ] ] let s:p.tabline.left = [ [ s:base03, s:base00 ] ] let s:p.tabline.tabsel = [ [ s:base03, s:base1 ] ] let s:p.tabline.middle = [ [ s:base0, s:base02 ] ] -let s:p.tabline.right = copy(s:p.normal.right) +let s:p.tabline.right = copy(s:p.tabline.left) let s:p.normal.error = [ [ s:base03, s:red ] ] let s:p.normal.warning = [ [ s:base03, s:yellow ] ] diff --git a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/srcery_drk.vim b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/srcery_drk.vim index f1c7e1dd..5aa3a8a9 100644 --- a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/srcery_drk.vim +++ b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/srcery_drk.vim @@ -5,7 +5,7 @@ " Last Change: 2018/05/19 " ============================================================================= let s:base03 = [ '#151513', 233 ] -let s:base02 = [ '#30302c ', 236 ] +let s:base02 = [ '#30302c', 236 ] let s:base01 = [ '#4e4e43', 239 ] let s:base00 = [ '#666656', 242 ] let s:base0 = [ '#808070', 244 ] diff --git a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/wombat.vim b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/wombat.vim index 96192476..9fee12e5 100644 --- a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/wombat.vim +++ b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/wombat.vim @@ -5,8 +5,8 @@ " Last Change: 2015/11/30 08:37:43. " ============================================================================= let s:base03 = [ '#242424', 235 ] -let s:base023 = [ '#353535 ', 236 ] -let s:base02 = [ '#444444 ', 238 ] +let s:base023 = [ '#353535', 236 ] +let s:base02 = [ '#444444', 238 ] let s:base01 = [ '#585858', 240 ] let s:base00 = [ '#666666', 242 ] let s:base0 = [ '#808080', 244 ] diff --git a/sources_non_forked/lightline.vim/autoload/lightline/colortable.vim b/sources_non_forked/lightline.vim/autoload/lightline/colortable.vim index 82617b20..6cdddd8d 100644 --- a/sources_non_forked/lightline.vim/autoload/lightline/colortable.vim +++ b/sources_non_forked/lightline.vim/autoload/lightline/colortable.vim @@ -2,7 +2,7 @@ " Filename: autoload/lightline/colortable.vim " Author: itchyny " License: MIT License -" Last Change: 2015/03/29 06:21:39. +" Last Change: 2020/06/19 11:07:13. " ============================================================================= let s:save_cpo = &cpo @@ -38,5 +38,15 @@ function! lightline#colortable#gui2cui(rgb, fallback) abort return rgb[0] + rgb[1] + rgb[2] endfunction +function! lightline#colortable#gui2cui_palette(palette) abort + for u in values(a:palette) + for v in values(u) + for w in v + let [w[2], w[3]] = [lightline#colortable#gui2cui(w[0], w[2]), lightline#colortable#gui2cui(w[1], w[3])] + endfor + endfor + endfor +endfunction + let &cpo = s:save_cpo unlet s:save_cpo diff --git a/sources_non_forked/lightline.vim/colorscheme.md b/sources_non_forked/lightline.vim/colorscheme.md index 5b944ab6..fefe85fe 100644 --- a/sources_non_forked/lightline.vim/colorscheme.md +++ b/sources_non_forked/lightline.vim/colorscheme.md @@ -22,7 +22,7 @@ ### PaperColor light -![lightline.vim - PaperColor light](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/PaperColor.png) +![lightline.vim - PaperColor light](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/PaperColor_light.png) ### Tomorrow @@ -48,6 +48,14 @@ ![lightline.vim - ayu mirage](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/ayu_mirage.png) +### ayu_light + +![lightline.vim - ayu light](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/ayu_light.png) + +### ayu_dark + +![lightline.vim - ayu dark](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/ayu_dark.png) + ### darcula ![lightline.vim - darcula](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/darcula.png) @@ -64,13 +72,25 @@ ![lightline.vim - selenized dark](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/selenized_dark.png) +### selenized black + +![lightline.vim - selenized black](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/selenized_black.png) + +### selenized light + +![lightline.vim - selenized light](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/selenized_light.png) + +### selenized white + +![lightline.vim - selenized white](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/selenized_white.png) + ### solarized dark -![lightline.vim - solarized_dark](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/solarized_dark.png) +![lightline.vim - solarized dark](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/solarized_dark.png) ### solarized light -![lightline.vim - solarized_light](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/solarized_light.png) +![lightline.vim - solarized light](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/solarized_light.png) ### materia @@ -92,9 +112,13 @@ ![lightline.vim - seoul256](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/seoul256.png) -### one +### one dark -![lightline.vim - one](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/one.png) +![lightline.vim - one dark](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/one_dark.png) + +### one light + +![lightline.vim - one light](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/one_light.png) ### srcery_drk @@ -108,6 +132,10 @@ ![lightline.vim - landscape](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/landscape.png) -### 16color +### 16color dark -![lightline.vim - 16color](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/16color.png) +![lightline.vim - 16color dark](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/16color_dark.png) + +### 16color light + +![lightline.vim - 16color light](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/16color_light.png) diff --git a/sources_non_forked/lightline.vim/doc/lightline.txt b/sources_non_forked/lightline.vim/doc/lightline.txt index 56c3f458..5e8330ee 100644 --- a/sources_non_forked/lightline.vim/doc/lightline.txt +++ b/sources_non_forked/lightline.vim/doc/lightline.txt @@ -1,27 +1,27 @@ *lightline.txt* A light and configurable statusline/tabline for Vim -Version: 0.1 Author: itchyny (https://github.com/itchyny) License: MIT License Repository: https://github.com/itchyny/lightline.vim <<<<<<< HEAD +<<<<<<< HEAD Last Change: 2019/06/12 18:47:11. ======= Last Change: 2020/01/28 18:40:21. >>>>>>> 27ad0d07862847896f691309a544a206783c94d6 +======= +Last Change: 2020/10/20 21:35:06. +>>>>>>> master CONTENTS *lightline-contents* Introduction |lightline-introduction| Spirit |lightline-spirit| Option |lightline-option| -Font |lightline-font| Function |lightline-function| Component Expansion |lightline-component-expansion| Colorscheme |lightline-colorscheme| Examples |lightline-examples| -Nice Examples |lightline-nice-examples| -Powerful Example |lightline-powerful-example| Troubleshooting |lightline-troubleshooting| ============================================================================== @@ -111,7 +111,7 @@ OPTIONS *lightline-option* \ 'percent': '%3p%%', \ 'percentwin': '%P', \ 'spell': '%{&spell?&spelllang:""}', - \ 'lineinfo': '%3l:%-2v', + \ 'lineinfo': '%3l:%-2c', \ 'line': '%l', \ 'column': '%c', \ 'close': '%999X X ', @@ -156,6 +156,10 @@ OPTIONS *lightline-option* \ }, \ } < + If you simply want to display the branch name instead of + installing a plugin for full git integration, you can use + vim-gitbranch (https://github.com/itchyny/vim-gitbranch). + g:lightline.component_function_visible_condition *g:lightline.component_function_visible_condition* A dictionary to store the visible conditions of the function @@ -237,12 +241,18 @@ OPTIONS *lightline-option* material, OldHope, nord, 16color and deus are available. ======= Currently, wombat, solarized, powerline, powerlineish, - jellybeans, molokai, seoul256, darcula, selenized_dark, + jellybeans, molokai, seoul256, darcula, + selenized_dark, selenized_black, selenized_light, selenized_white, Tomorrow, Tomorrow_Night, Tomorrow_Night_Blue, Tomorrow_Night_Bright, Tomorrow_Night_Eighties, PaperColor, landscape, one, materia, material, OldHope, nord, deus, +<<<<<<< HEAD srcery_drk, ayu_mirage and 16color are available. >>>>>>> 27ad0d07862847896f691309a544a206783c94d6 +======= + simpleblack, srcery_drk, ayu_mirage, ayu_light, ayu_dark and + 16color are available. +>>>>>>> master The default value is: > let g:lightline.colorscheme = 'default' @@ -300,78 +310,6 @@ OPTIONS *lightline-option* \ } < ============================================================================== -FONT *lightline-font* -You can use the patched font you used for |vim-powerline| and |powerline|. - -The patched fonts for |powerline| are available at -https://github.com/Lokaltog/powerline-fonts - -A tutorial to create a patched font for |vim-powerline| is available at -https://github.com/Lokaltog/vim-powerline/tree/develop/fontpatcher - -If you have installed the patched font for |powerline|, following settings look -nice. -> - let g:lightline = { - \ 'component': { - \ 'lineinfo': ' %3l:%-2v', - \ }, - \ 'component_function': { - \ 'readonly': 'LightlineReadonly', - \ 'fugitive': 'LightlineFugitive' - \ }, - \ 'separator': { 'left': '', 'right': '' }, - \ 'subseparator': { 'left': '', 'right': '' } - \ } - function! LightlineReadonly() - return &readonly ? '' : '' - endfunction - function! LightlineFugitive() - if exists('*FugitiveHead') - let branch = FugitiveHead() - return branch !=# '' ? ''.branch : '' - endif - return '' - endfunction -< -If you have installed the patched font for |vim-powerline|, following settings -look nice. -> - let g:lightline = { - \ 'component': { - \ 'lineinfo': '⭡ %3l:%-2v', - \ }, - \ 'component_function': { - \ 'readonly': 'LightlineReadonly', - \ 'fugitive': 'LightlineFugitive' - \ }, - \ 'separator': { 'left': '⮀', 'right': '⮂' }, - \ 'subseparator': { 'left': '⮁', 'right': '⮃' } - \ } - function! LightlineReadonly() - return &readonly ? '⭤' : '' - endfunction - function! LightlineFugitive() - if exists('*FugitiveHead') - let branch = FugitiveHead() - return branch !=# '' ? '⭠ '.branch : '' - endif - return '' - endfunction -< -If the statusline does not correctly show the special characters, use the -unicode numbers. For |powerline| font users: -> - \ 'separator': { 'left': "\ue0b0", 'right': "\ue0b2" }, - \ 'subseparator': { 'left': "\ue0b1", 'right': "\ue0b3" } -< -For |vim-powerline| font users: -> - \ 'separator': { 'left': "\u2b80", 'right': "\u2b82" }, - \ 'subseparator': { 'left': "\u2b81", 'right': "\u2b83" } -< -See |lightline-problem-9| for more detail. -============================================================================== FUNCTION *lightline-function* Exposed functions for lightline.vim. @@ -671,34 +609,27 @@ In order to change the colorscheme: \ 'colorscheme': 'wombat', \ } < - In order to define your own component: > let g:lightline = { - \ 'active': { - \ 'left': [ [ 'mode', 'paste' ], [ 'myfilename' ] ] - \ }, \ 'component_function': { - \ 'myfilename': 'LightlineFilename', - \ 'myreadonly': 'LightlineReadonly', - \ 'mymodified': 'LightlineModified', + \ 'filename': 'LightlineFilename', + \ 'readonly': 'LightlineReadonly', + \ 'modified': 'LightlineModified', \ } \ } function! LightlineFilename() - return (LightlineReadonly() !=# '' ? LightlineReadonly() . ' ' : '') . - \ (&ft ==# 'vimfiler' ? vimfiler#get_status_string() : + return &ft ==# 'vimfiler' ? vimfiler#get_status_string() : \ &ft ==# 'unite' ? unite#get_status_string() : - \ expand('%:t') !=# '' ? expand('%:t') : '[No Name]') . - \ (LightlineModified() !=# '' ? ' ' . LightlineModified() : '') + \ expand('%:t') !=# '' ? expand('%:t') : '[No Name]' endfunction function! LightlineReadonly() - return &ft !~? 'help' && &readonly ? 'RO' : '' + return &ft !~? 'help\|vimfiler' && &readonly ? 'RO' : '' endfunction function! LightlineModified() return &modifiable && &modified ? '+' : '' endfunction < - Separators settings: > let g:lightline = { @@ -706,30 +637,9 @@ Separators settings: \ 'subseparator': { 'left': '|', 'right': '|' } \ } < - -For |powerline| font users: +An example for fugitive, vimfiler and unite users. > let g:lightline = { - \ 'separator': { 'left': '', 'right': '' }, - \ 'subseparator': { 'left': '', 'right': '' } - \ } -< - -For |vim-powerline| font users: -> - let g:lightline = { - \ 'separator': { 'left': '⮀', 'right': '⮂' }, - \ 'subseparator': { 'left': '⮁', 'right': '⮃' } - \ } -< - ------------------------------------------------------------------------------- -NICE EXAMPLES *lightline-nice-examples* - -A nice example for non-patched font users. -> - let g:lightline = { - \ 'colorscheme': 'wombat', \ 'active': { \ 'left': [ [ 'mode', 'paste' ], [ 'fugitive', 'filename' ] ] \ }, @@ -748,61 +658,19 @@ A nice example for non-patched font users. return (LightlineReadonly() !=# '' ? LightlineReadonly() . ' ' : '') . \ (&ft ==# 'vimfiler' ? vimfiler#get_status_string() : \ &ft ==# 'unite' ? unite#get_status_string() : - \ &ft ==# 'vimshell' ? vimshell#get_status_string() : \ expand('%:t') !=# '' ? expand('%:t') : '[No Name]') . \ (LightlineModified() !=# '' ? ' ' . LightlineModified() : '') endfunction function! LightlineFugitive() - if &ft !~? 'vimfiler' && exists('*FugitiveHead') + if exists('*FugitiveHead') return FugitiveHead() endif return '' endfunction < -A nice example for |vim-powerline| font users: +For users of lots of plugins: > let g:lightline = { - \ 'colorscheme': 'wombat', - \ 'active': { - \ 'left': [ [ 'mode', 'paste' ], [ 'fugitive', 'filename' ] ] - \ }, - \ 'component_function': { - \ 'fugitive': 'LightlineFugitive', - \ 'filename': 'LightlineFilename' - \ }, - \ 'separator': { 'left': '⮀', 'right': '⮂' }, - \ 'subseparator': { 'left': '⮁', 'right': '⮃' } - \ } - function! LightlineModified() - return &ft =~# 'help\|vimfiler' ? '' : &modified ? '+' : &modifiable ? '' : '-' - endfunction - function! LightlineReadonly() - return &ft !~? 'help\|vimfiler' && &readonly ? '⭤' : '' - endfunction - function! LightlineFilename() - return (LightlineReadonly() !=# '' ? LightlineReadonly() . ' ' : '') . - \ (&ft ==# 'vimfiler' ? vimfiler#get_status_string() : - \ &ft ==# 'unite' ? unite#get_status_string() : - \ &ft ==# 'vimshell' ? vimshell#get_status_string() : - \ expand('%:t') !=# '' ? expand('%:t') : '[No Name]') . - \ (LightlineModified() !=# '' ? ' ' . LightlineModified() : '') - endfunction - function! LightlineFugitive() - if &ft !~? 'vimfiler' && exists('*FugitiveHead') - let branch = FugitiveHead() - return branch !=# '' ? '⭠ '.branch : '' - endif - return '' - endfunction -< - ------------------------------------------------------------------------------- -POWERFUL EXAMPLE *lightline-powerful-example* - -For users who uses lots of plugins: -> - let g:lightline = { - \ 'colorscheme': 'wombat', \ 'active': { \ 'left': [ [ 'mode', 'paste' ], [ 'fugitive', 'filename' ], ['ctrlpmark'] ], \ 'right': [ [ 'syntastic', 'lineinfo' ], ['percent'], [ 'fileformat', 'fileencoding', 'filetype' ] ] @@ -944,17 +812,7 @@ Problem 5: |lightline-problem-5| The statusline does not seem to be correctly colored. Problem 6: |lightline-problem-6| - How to install a patched font. - -Problem 7: |lightline-problem-7| - Right triangles do not stick to the right components with the - patched font. - -Problem 8: |lightline-problem-8| - Triangles do not appear. Triangles look weird. - -Problem 9: |lightline-problem-9| - Where can I find the list of all the cool characters for patched fonts? + How to use a powerline font and the triangles for separators. Problem 10: |lightline-problem-10| Cool statusline disappears in |unite|, |vimfiler| and |vimshell| @@ -993,20 +851,17 @@ Problem 17: |lightline-problem-17| Problem 1: *lightline-problem-1* How to install this plugin. - If you are to install this plugin manually: - - 1. Put all the files under $VIM. - - If you are to install this plugin using |vim-pathogen|: - - 1. Install this plugin with the following command. + If you install this plugin using Vim packages: +> + git clone https://github.com/itchyny/lightline.vim \ + ~/.vim/pack/plugins/start/lightline +< + If you install this plugin using |vim-pathogen|: > git clone https://github.com/itchyny/lightline.vim \ ~/.vim/bundle/lightline.vim < - 2. Generate help tags with |:Helptags|. - - If you are to install this plugin using |Vundle|: + If you install this plugin using |Vundle|: 1. Add the following configuration to your .vimrc(_vimrc). @@ -1015,7 +870,7 @@ Problem 1: *lightline-problem-1* < 2. Install with |:PluginInstall|. - If you are to install this plugin using |NeoBundle|: + If you install this plugin using |NeoBundle|: 1. Add the following configuration to your .vimrc(_vimrc). @@ -1024,7 +879,7 @@ Problem 1: *lightline-problem-1* < 2. Install with |:NeoBundleInstall|. - If you are to install this plugin using |vim-plug|: + If you install this plugin using |vim-plug|: 1. Add the following configuration to your .vimrc(_vimrc). @@ -1033,51 +888,76 @@ Problem 1: *lightline-problem-1* < 2. Install with |:PlugInstall|. + If you install this plugin using |dein|: + + 1. Add the following configuration to your + .vimrc(_vimrc). +> + call dein#add('itchyny/lightline.vim') +< + 2. Install with :call |dein#install()|. + Problem 2: *lightline-problem-2* How to update this plugin. - If you have installed this plugin manually: + If you installed this plugin using Vim packages: +> + git -C ~/.vim/pack/plugins/start/lightline pull +< + If you installed this plugin using |vim-pathogen|: +> + git -C ~/.vim/bundle/lightline.vim pull +< + If you installed this plugin using |Vundle|: - 1. Access https://github.com/itchyny/lightline.vim . - 2. Download the latest scripts. - 3. Place the scripts as written in Problem 1. + Execute |:PluginUpdate|. - If you have installed this plugin using Vundle: + If you installed this plugin using |NeoBundle|: - 1. Execute |:PluginUpdate|. + Execute |:NeoBundleUpdate|. - If you have installed this plugin using NeoBundle: + If you installed this plugin using |vim-plug|: - 1. Execute |:NeoBundleUpdate|. + Execute |:PlugUpdate|. - If you have installed this plugin using vim-plug: + If you installed this plugin using |dein|: - 1. Execute |:PlugUpdate|. + Execute :call |dein#update()|. Problem 3: *lightline-problem-3* How to uninstall this plugin. - If you have installed this plugin manually: + If you installed this plugin using Vim packages: +> + rm -rf ~/.vim/pack/plugins/start/lightline +< + If you installed this plugin using |vim-pathogen|: +> + rm -rf ~/.vim/bundle/lightline.vim +< + If you have installed this plugin using |Vundle|: - 1. Remove all the lightline.*s under $VIM. + 1. Remove `Plugin 'itchyny/lightline.vim'` + from your .vimrc(_vimrc). + 2. Execute |:PluginClean|. - If you have installed this plugin using Vundle: + If you installed this plugin using |NeoBundle|: - 1. Remove the :Plugin 'itchyny/lightline.vim' - configuration from your .vimrc(_vimrc). - 2. Update with |:PluginClean|. + 1. Remove `NeoBundle 'itchyny/lightline.vim'` + from your .vimrc(_vimrc). + 2. Remove the plugin directory. - If you have installed this plugin using NeoBundle: + If you installed this plugin using |vim-plug|: - 1. Remove the :NeoBundle 'itchyny/lightline.vim' - configuration from your .vimrc(_vimrc). - 2. Update with |:NeoBundleClean|. + 1. Remove `Plug 'itchyny/lightline.vim'` + from your .vimrc(_vimrc). + 2. Execute |:PlugClean|. - If you have installed this plugin using vim-plug: + If you installed this plugin using |dein|: - 1. Remove the :Plug 'itchyny/lightline.vim' - configuration from your .vimrc(_vimrc). - 2. Update with |:PlugClean|. + 1. Remove `call dein#add('itchyny/lightline.vim')` + from your .vimrc(_vimrc). + 2. Remove the plugin directory. Problem 4: *lightline-problem-4* Cool statuslines appear only on |:vsp|. @@ -1102,74 +982,22 @@ Problem 5: *lightline-problem-5* to your .vimrc(_vimrc). Problem 6: *lightline-problem-6* - How to install a patched font. + How to use a powerline font and the triangles for separators. - There are two kinds of patched fonts: + Using a patched font is not recommended due to less + portability. Also the powerline fonts project is not actively + maintained (https://github.com/powerline/fonts). - + The patched fonts for |vim-powerline| - (https://github.com/Lokaltog/vim-powerline): - follow the guide https://github.com/Lokaltog/vim-powerline/tree/develop/fontpatcher - + The patched fonts for |powerline| - (https://github.com/Lokaltog/powerline): - download from https://github.com/Lokaltog/powerline-fonts - -Problem 7: *lightline-problem-7* - Right triangles do not stick to the right components with patched - font. - - Remove the following setting from your .vimrc(_vimrc). -> - set ambiwidth=double -< - If you want to keep this setting, try the patched font for - |vim-powerline|. - -Problem 8: *lightline-problem-8* - Triangles do not appear. Triangles look weird. - - If the triangles do not appear (but you get some spaces or - weird characters like or ¿), firstly try adding -> - scriptencoding utf-8 - set encoding=utf-8 -< - to the head of your .vimrc(_vimrc). Still you have weird - characters, use the unicode numbers. For |powerline| font - users: + If you still want to use a patched font, you can configure > \ 'separator': { 'left': "\ue0b0", 'right': "\ue0b2" }, - \ 'subseparator': { 'left': "\ue0b1", 'right': "\ue0b3" } + \ 'subseparator': { 'left': "\ue0b1", 'right': "\ue0b3" }, < - For |vim-powerline| font users: + or > \ 'separator': { 'left': "\u2b80", 'right': "\u2b82" }, - \ 'subseparator': { 'left': "\u2b81", 'right': "\u2b83" } + \ 'subseparator': { 'left': "\u2b81", 'right': "\u2b83" }, < - The full list of unicode numbers for fancy characters is shown - in |lightline-problem-9|. - - If the triangles are shown in appropriate characters but the - colors do not look correctly, see the following. - If you are using iTerm2, change the following settings. - - + set Profiles>Colors>Minimum contrast to the Lowest. - + set Profiles>Window>Transparency to the Opaquest. - - For other terminals, this weird-triangle problem will be - resolved by disabling transparency or contrast adjustment. - -Problem 9: *lightline-problem-9* - Where can I find the list of all the cool characters for patched fonts? - - Default powerline vim-powerline - separator.left '' '' (\ue0b0) '⮀' (\u2b80) - separator.right '' '' (\ue0b2) '⮂' (\u2b82) - subseparator.left '|' '' (\ue0b1) '⮁' (\u2b81) - subseparator.right '|' '' (\ue0b3) '⮃' (\u2b83) - branch symbol -- '' (\ue0a0) '⭠' (\u2b60) - readonly symbol -- '' (\ue0a2) '⭤' (\u2b64) - linecolumn symbol -- '' (\ue0a1) '⭡' (\u2b61) - Problem 10: *lightline-problem-10* Cool statusline disappears on |unite|, |vimfiler| and |vimshell| buffers. @@ -1201,7 +1029,7 @@ Problem 11: *lightline-problem-11* return lightline#statusline(0) endfunction < - See |lightline-powerful-example| for more cool settings for + See |lightline-example| for more cool settings for these plugins. Problem 12: *lightline-problem-12* @@ -1296,8 +1124,8 @@ Problem 15: *lightline-problem-15* If you don't like the separators in the tabline, use: > let g:lightline = { - \ 'tabline_separator': { 'left': "", 'right': "" }, - \ 'tabline_subseparator': { 'left': "", 'right': "" }, + \ 'tabline_separator': { 'left': '', 'right': '' }, + \ 'tabline_subseparator': { 'left': '', 'right': '' }, \ } < Problem 16: *lightline-problem-16* diff --git a/sources_non_forked/lightline.vim/plugin/lightline.vim b/sources_non_forked/lightline.vim/plugin/lightline.vim index d08517d7..e1254b7b 100644 --- a/sources_non_forked/lightline.vim/plugin/lightline.vim +++ b/sources_non_forked/lightline.vim/plugin/lightline.vim @@ -2,10 +2,10 @@ " Filename: plugin/lightline.vim " Author: itchyny " License: MIT License -" Last Change: 2019/07/30 12:00:00. +" Last Change: 2020/11/05 20:05:40. " ============================================================================= -if exists('g:loaded_lightline') || v:version < 700 +if exists('g:loaded_lightline') || v:version < 703 finish endif let g:loaded_lightline = 1 @@ -15,14 +15,13 @@ set cpo&vim augroup lightline autocmd! - autocmd WinEnter,BufEnter,SessionLoadPost * call lightline#update() + autocmd WinEnter,BufEnter,BufDelete,SessionLoadPost,FileChangedShellPost * call lightline#update() if !has('patch-8.1.1715') autocmd FileType qf call lightline#update() endif autocmd SessionLoadPost * call lightline#highlight() autocmd ColorScheme * if !has('vim_starting') || expand('') !=# 'macvim' \ | call lightline#update() | call lightline#highlight() | endif - autocmd CursorMoved,BufUnload * call lightline#update_once() augroup END " This quickfix option was introduced at Vim 85850f3a5ef9, which is the commit diff --git a/sources_non_forked/lightline.vim/test/.themisrc b/sources_non_forked/lightline.vim/test/.themisrc index 6e0121ce..5c7018a1 100644 --- a/sources_non_forked/lightline.vim/test/.themisrc +++ b/sources_non_forked/lightline.vim/test/.themisrc @@ -20,3 +20,5 @@ function! SID(name) abort endfunction filetype plugin on + +call lightline#init() diff --git a/sources_non_forked/lightline.vim/test/autocmd.vim b/sources_non_forked/lightline.vim/test/autocmd.vim new file mode 100644 index 00000000..934509b8 --- /dev/null +++ b/sources_non_forked/lightline.vim/test/autocmd.vim @@ -0,0 +1,23 @@ +if !has("patch-8.2.0996") + finish +endif + +let s:suite = themis#suite('autocmd') +let s:assert = themis#helper('assert') + +function! s:suite.before_each() + let g:lightline = {} + call lightline#init() + tabnew + tabonly +endfunction + +function! s:suite.doautoall() + tabnew + tabnew + tabprevious + doautoall WinEnter + let statusline = getwinvar(1, '&statusline') + call s:assert.match(statusline, 'lightline') + call s:assert.match(statusline, '_active_') +endfunction diff --git a/sources_non_forked/lightline.vim/test/link.vim b/sources_non_forked/lightline.vim/test/link.vim index 98e409e6..3da8ea1d 100644 --- a/sources_non_forked/lightline.vim/test/link.vim +++ b/sources_non_forked/lightline.vim/test/link.vim @@ -141,3 +141,17 @@ function! s:suite.component_type() endfor endfor endfunction + +function! s:suite.hi_clear() + call lightline#link() + colorscheme default + call lightline#link() + call s:assert.match(s:hi('LightlineLeft_active_0'), 'LightlineLeft_normal_0') + call s:assert.match(s:hi('LightlineLeft_active_1'), 'LightlineLeft_normal_1') + call s:assert.match(s:hi('LightlineLeft_active_2'), 'E411: highlight group not found\|cleared') + call s:assert.match(s:hi('LightlineRight_active_0'), 'LightlineRight_normal_0') + call s:assert.match(s:hi('LightlineRight_active_1'), 'LightlineRight_normal_1') + call s:assert.match(s:hi('LightlineRight_active_2'), 'LightlineRight_normal_2') + call s:assert.match(s:hi('LightlineRight_active_3'), 'E411: highlight group not found\|cleared') + call s:assert.match(s:hi('LightlineMiddle_active'), 'LightlineMiddle_normal') +endfunction diff --git a/sources_non_forked/lightline.vim/test/tabs.vim b/sources_non_forked/lightline.vim/test/tabs.vim index 7851e705..863dd7fa 100644 --- a/sources_non_forked/lightline.vim/test/tabs.vim +++ b/sources_non_forked/lightline.vim/test/tabs.vim @@ -2,7 +2,7 @@ let s:suite = themis#suite('tabs') let s:assert = themis#helper('assert') function! s:suite.before_each() - let g:lightline = { 'winwidth': 180 } + set columns=180 call lightline#init() tabnew tabonly diff --git a/sources_non_forked/lightline.vim/test/toggle.vim b/sources_non_forked/lightline.vim/test/toggle.vim index 7df270f8..6f7eb5bd 100644 --- a/sources_non_forked/lightline.vim/test/toggle.vim +++ b/sources_non_forked/lightline.vim/test/toggle.vim @@ -29,6 +29,12 @@ function! s:suite.disable_enable() call s:assert.equals(exists('#lightline-disable'), 0) call s:assert.not_equals(&statusline, '') call s:assert.not_equals(&tabline, '') + call lightline#disable() + call lightline#disable() + call lightline#enable() + call lightline#enable() + call s:assert.equals(exists('#lightline'), 1) + call s:assert.equals(exists('#lightline-disable'), 0) endfunction function! s:suite.toggle() diff --git a/sources_non_forked/mru.vim/README b/sources_non_forked/mru.vim/README deleted file mode 100644 index 04c3a748..00000000 --- a/sources_non_forked/mru.vim/README +++ /dev/null @@ -1,192 +0,0 @@ -This is a mirror of http://www.vim.org/scripts/script.php?script_id=521 - -Overview - -The Most Recently Used (MRU) plugin provides an easy access to a list of -recently opened/edited files in Vim. This plugin automatically stores the -file names as you open/edit them in Vim. - -This plugin will work on all the platforms where Vim is supported. This -plugin will work in both console and GUI Vim. This version of the MRU -plugin needs Vim 7.0 and above. If you are using an earlier version of -Vim, then you should use an older version of the MRU plugin. - -The recently used filenames are stored in a file specified by the Vim -MRU_File variable. - -The Github repository for the MRU plugin is available at: - - http://github.com/yegappan/mru - -Usage - -To list and edit files from the MRU list, you can use the ":MRU" command. -The ":MRU" command displays the MRU file list in a temporary Vim window. If -the MRU window is already opened, then the MRU list displayed in the window -is refreshed. - -If you are using GUI Vim, then the names of the recently edited files are -added to the "File->Recent Files" menu. You can select the name of a file -from this sub-menu to edit the file. - -You can use the normal Vim commands to move around in the MRU window. You -cannot make changes in the MRU window. - -You can select a file name to edit by pressing the key or by double -clicking the left mouse button on a file name. The selected file will be -opened. If the file is already opened in a window, the cursor will be moved -to that window. Otherwise, the file is opened in the previous window. If the -previous window has a modified buffer or is the preview window or is used by -some other plugin, then the file is opened in a new window. - -You can press the 'o' key to open the file name under the cursor in the -MRU window in a new window. You can also press instead of 'o' -to open the file in a new window. - -To open a file from the MRU window in read-only mode (view), press the 'v' -key. - -To open a file from the MRU window in a new tab, press the 't' key. If the -file is already opened in a window in the current or in another tab, then -the cursor is moved to that tab. Otherwise, a new tab is opened. - -You can open multiple files from the MRU window by specifying a count before -pressing '' or 'v' or 'o' or 't'. You can also visually (using -linewise visual mode) select multiple filenames and invoke the commands to -open the files. Each selected file will be opened in a separate window or -tab. - -You can press the 'u' key in the MRU window to update the file list. This is -useful if you keep the MRU window open always. - -You can close the MRU window by pressing the 'q' key or the key or -using one of the Vim window commands. - -To display only files matching a pattern from the MRU list in the MRU -window, you can specify a pattern to the ":MRU" command. For example, to -display only file names matching "vim" in them, you can use the following -command ":MRU vim". When you specify a partial file name and only one -matching filename is found, then the ":MRU" command will edit that file. - -The ":MRU" command supports command-line completion of file names from -the MRU list. You can enter a partial file name and then press -or to complete or list all the matching file names. Note that -after typing the ":MRU" command, you have to enter a space before completing -the file names with . - -When a file supplied to the ":MRU" command is not present in the MRU list, -but it is a readable file, then the file will be opened (even though it is -not present in the MRU list). This is useful if you want to open a file -present in the same directory as a file in the MRU list. You can use the -command-line completion of the ":MRU" command to complete the full path of a -file and then modify the path to open another file present in the same path. - -Whenever the MRU list changes, the MRU file is updated with the latest MRU -list. When you have multiple instances of Vim running at the same time, the -latest MRU list will show up in all the instances of Vim. - -The MRUFilename syntax group is used to highlight the file names in the MRU -window. By default, this syntax group is linked to the Identifier highlight -group. You can change the highlight group by adding the following line in -your .vimrc: - - highlight link MRUFileName LineNr - -The MRU buffer uses the 'mru file type. You can use this file type to add -custom auto commands, syntax highlighting, etc. - -Configuration - -By changing the following variables you can configure the behavior of this -plugin. Set the following variables in your .vimrc file using the 'let' -command. - -The list of recently edited file names is stored in the file specified by the -MRU_File variable. The default setting for this variable is -$HOME/.vim_mru_files for Unix-like systems and $USERPROFILE/_vim_mru_files -for MS-Windows systems. You can change this variable to point to a file by -adding the following line to the .vimrc file: - - let MRU_File = 'd:\myhome\_vim_mru_files' - -By default, the plugin will remember the names of the last 100 used files. -As you edit more files, old file names will be removed from the MRU list. -You can set the 'MRU_Max_Entries' variable to remember more file names. For -example, to remember 1000 most recently used file names, you can use - - let MRU_Max_Entries = 1000 - -By default, all the edited file names will be added to the MRU list. If you -want to exclude file names matching a list of patterns, you can set the -MRU_Exclude_Files variable to a list of Vim regular expressions. By default, -this variable is set to an empty string. For example, to not include files -in the temporary (/tmp, /var/tmp and d:\temp) directories, you can set the -MRU_Exclude_Files variable to - - let MRU_Exclude_Files = '^/tmp/.*\|^/var/tmp/.*' " For Unix - let MRU_Exclude_Files = '^c:\\temp\\.*' " For MS-Windows - -The specified pattern should be a Vim regular expression pattern. - -If you want to add only file names matching a set of patterns to the MRU -list, then you can set the MRU_Include_Files variable. This variable should -be set to a Vim regular expression pattern. For example, to add only .c and -.h files to the MRU list, you can set this variable as below: - - let MRU_Include_Files = '\.c$\|\.h$' - -By default, MRU_Include_Files is set to an empty string and all the edited -filenames are added to the MRU list. - -The default height of the MRU window is 8. You can set the MRU_Window_Height -variable to change the window height. - - let MRU_Window_Height = 15 - -By default, when the :MRU command is invoked, the MRU list will be displayed -in a new window. Instead, if you want the MRU plugin to reuse the current -window, then you can set the 'MRU_Use_Current_Window' variable to one. - - let MRU_Use_Current_Window = 1 - -The MRU plugin will reuse the current window. When a file name is selected, -the file is also opened in the current window. - -When you select a file from the MRU window, the MRU window will be -automatically closed and the selected file will be opened in the previous -window. You can set the 'MRU_Auto_Close' variable to zero to keep the MRU -window open. - - let MRU_Auto_Close = 0 - -If you don't use the "File->Recent Files" menu and want to disable it, -then you can set the 'MRU_Add_Menu' variable to zero. By default, the -menu is enabled. - - let MRU_Add_Menu = 0 - -If too many file names are present in the MRU list, then updating the MRU -menu to list all the file names makes Vim slow. To avoid this, the -MRU_Max_Menu_Entries variable controls the number of file names to show in -the MRU menu. By default, this is set to 10. You can change this to show -more entries in the menu. - - let MRU_Max_Menu_Entries = 20 - -If many file names are present in the MRU list, then the MRU menu is split -into sub-menus. Each sub-menu contains MRU_Max_Submenu_Entries file names. -The default setting for this is 10. You can change this to increase the -number of file names displayed in a single sub-menu: - - let MRU_Max_Submenu_Entries = 15 - -In the MRU window, the filenames are displayed in two parts. The first part -contains the file name without the path and the second part contains the -full path to the file in parenthesis. This format is controlled by the -MRU_Filename_Format variable. If you prefer to change this to some other -format, then you can modify the MRU_Filename_Format variable. For example, -to display the full path without splitting it, you can set this variable -as shown below: - - let MRU_Filename_Format={'formatter':'v:val', 'parser':'.*'} - diff --git a/sources_non_forked/mru.vim/plugin/mru.vim b/sources_non_forked/mru.vim/plugin/mru.vim deleted file mode 100644 index 5cf7015d..00000000 --- a/sources_non_forked/mru.vim/plugin/mru.vim +++ /dev/null @@ -1,1039 +0,0 @@ -" File: mru.vim -" Author: Yegappan Lakshmanan (yegappan AT yahoo DOT com) -" Version: 3.9 -" Last Modified: Feb 3, 2015 -" Copyright: Copyright (C) 2003-2015 Yegappan Lakshmanan -" License: Permission is hereby granted to use and distribute this code, -" with or without modifications, provided that this copyright -" notice is copied with it. Like anything else that's free, -" mru.vim is provided *as is* and comes with no warranty of any -" kind, either expressed or implied. In no event will the copyright -" holder be liable for any damages resulting from the use of this -" software. -" -" Overview -" -------- -" The Most Recently Used (MRU) plugin provides an easy access to a list of -" recently opened/edited files in Vim. This plugin automatically stores the -" file names as you open/edit them in Vim. -" -" This plugin will work on all the platforms where Vim is supported. This -" plugin will work in both console and GUI Vim. This version of the MRU -" plugin needs Vim 7.0 and above. If you are using an earlier version of -" Vim, then you should use an older version of the MRU plugin. -" -" The recently used filenames are stored in a file specified by the Vim -" MRU_File variable. -" -" The Github repository for the MRU plugin is available at: -" -" http://github.com/yegappan/mru -" -" Installation -" ------------ -" 1. Copy the mru.vim file to one of the following directories: -" $HOME/.vim/plugin - Unix like systems -" $HOME/vimfiles/plugin - MS-Windows -" $VIM:vimfiles:plugin - Macintosh -" $VIM/vimfiles/plugin - All -" 2. Restart Vim. -" 3. You can use the ":MRU" command to list and edit the recently used files. -" In GUI Vim, you can use the 'File->Recent Files' menu to access the -" recently used files. -" -" To uninstall this plugin, remove this file (mru.vim) from the -" $HOME/.vim/plugin or $HOME/vimfiles/plugin or the $VIM/vimfile/plugin -" directory. -" -" Usage -" ----- -" To list and edit files from the MRU list, you can use the ":MRU" command. -" The ":MRU" command displays the MRU file list in a temporary Vim window. If -" the MRU window is already opened, then the MRU list displayed in the window -" is refreshed. -" -" If you are using GUI Vim, then the names of the recently edited files are -" added to the "File->Recent Files" menu. You can select the name of a file -" from this sub-menu to edit the file. -" -" You can use the normal Vim commands to move around in the MRU window. You -" cannot make changes in the MRU window. -" -" You can select a file name to edit by pressing the key or by double -" clicking the left mouse button on a file name. The selected file will be -" opened. If the file is already opened in a window, the cursor will be moved -" to that window. Otherwise, the file is opened in the previous window. If the -" previous window has a modified buffer or is the preview window or is used by -" some other plugin, then the file is opened in a new window. -" -" You can press the 'o' key to open the file name under the cursor in the -" MRU window in a new window. You can also press instead of 'o' -" to open the file in a new window. -" -" To open a file from the MRU window in read-only mode (view), press the 'v' -" key. -" -" To open a file from the MRU window in a new tab, press the 't' key. If the -" file is already opened in a window in the current or in another tab, then -" the cursor is moved to that tab. Otherwise, a new tab is opened. -" -" You can open multiple files from the MRU window by specifying a count before -" pressing '' or 'v' or 'o' or 't'. You can also visually (using -" linewise visual mode) select multiple filenames and invoke the commands to -" open the files. Each selected file will be opened in a separate window or -" tab. -" -" You can press the 'u' key in the MRU window to update the file list. This is -" useful if you keep the MRU window open always. -" -" You can close the MRU window by pressing the 'q' key or the key or -" using one of the Vim window commands. -" -" To display only files matching a pattern from the MRU list in the MRU -" window, you can specify a pattern to the ":MRU" command. For example, to -" display only file names matching "vim" in them, you can use the following -" command ":MRU vim". When you specify a partial file name and only one -" matching filename is found, then the ":MRU" command will edit that file. -" -" The ":MRU" command supports command-line completion of file names from -" the MRU list. You can enter a partial file name and then press -" or to complete or list all the matching file names. Note that -" after typing the ":MRU" command, you have to enter a space before completing -" the file names with . -" -" When a file supplied to the ":MRU" command is not present in the MRU list, -" but it is a readable file, then the file will be opened (even though it is -" not present in the MRU list). This is useful if you want to open a file -" present in the same directory as a file in the MRU list. You can use the -" command-line completion of the ":MRU" command to complete the full path of a -" file and then modify the path to open another file present in the same path. -" -" Whenever the MRU list changes, the MRU file is updated with the latest MRU -" list. When you have multiple instances of Vim running at the same time, the -" latest MRU list will show up in all the instances of Vim. -" -" The MRUFilename syntax group is used to highlight the file names in the MRU -" window. By default, this syntax group is linked to the Identifier highlight -" group. You can change the highlight group by adding the following line in -" your .vimrc: -" -" highlight link MRUFileName LineNr -" -" The MRU buffer uses the 'mru file type. You can use this file type to add -" custom auto commands, syntax highlighting, etc. -" -" Configuration -" ------------- -" By changing the following variables you can configure the behavior of this -" plugin. Set the following variables in your .vimrc file using the 'let' -" command. -" -" The list of recently edited file names is stored in the file specified by the -" MRU_File variable. The default setting for this variable is -" $HOME/.vim_mru_files for Unix-like systems and $USERPROFILE/_vim_mru_files -" for MS-Windows systems. You can change this variable to point to a file by -" adding the following line to the .vimrc file: -" -" let MRU_File = 'd:\myhome\_vim_mru_files' -" -" By default, the plugin will remember the names of the last 100 used files. -" As you edit more files, old file names will be removed from the MRU list. -" You can set the 'MRU_Max_Entries' variable to remember more file names. For -" example, to remember 1000 most recently used file names, you can use -" -" let MRU_Max_Entries = 1000 -" -" By default, all the edited file names will be added to the MRU list. If you -" want to exclude file names matching a list of patterns, you can set the -" MRU_Exclude_Files variable to a list of Vim regular expressions. By default, -" this variable is set to an empty string. For example, to not include files -" in the temporary (/tmp, /var/tmp and d:\temp) directories, you can set the -" MRU_Exclude_Files variable to -" -" let MRU_Exclude_Files = '^/tmp/.*\|^/var/tmp/.*' " For Unix -" let MRU_Exclude_Files = '^c:\\temp\\.*' " For MS-Windows -" -" The specified pattern should be a Vim regular expression pattern. -" -" If you want to add only file names matching a set of patterns to the MRU -" list, then you can set the MRU_Include_Files variable. This variable should -" be set to a Vim regular expression pattern. For example, to add only .c and -" .h files to the MRU list, you can set this variable as below: -" -" let MRU_Include_Files = '\.c$\|\.h$' -" -" By default, MRU_Include_Files is set to an empty string and all the edited -" filenames are added to the MRU list. -" -" The default height of the MRU window is 8. You can set the MRU_Window_Height -" variable to change the window height. -" -" let MRU_Window_Height = 15 -" -" By default, when the :MRU command is invoked, the MRU list will be displayed -" in a new window. Instead, if you want the MRU plugin to reuse the current -" window, then you can set the 'MRU_Use_Current_Window' variable to one. -" -" let MRU_Use_Current_Window = 1 -" -" The MRU plugin will reuse the current window. When a file name is selected, -" the file is also opened in the current window. -" -" When you select a file from the MRU window, the MRU window will be -" automatically closed and the selected file will be opened in the previous -" window. You can set the 'MRU_Auto_Close' variable to zero to keep the MRU -" window open. -" -" let MRU_Auto_Close = 0 -" -" If you don't use the "File->Recent Files" menu and want to disable it, -" then you can set the 'MRU_Add_Menu' variable to zero. By default, the -" menu is enabled. -" -" let MRU_Add_Menu = 0 -" -" If too many file names are present in the MRU list, then updating the MRU -" menu to list all the file names makes Vim slow. To avoid this, the -" MRU_Max_Menu_Entries variable controls the number of file names to show in -" the MRU menu. By default, this is set to 10. You can change this to show -" more entries in the menu. -" -" let MRU_Max_Menu_Entries = 20 -" -" If many file names are present in the MRU list, then the MRU menu is split -" into sub-menus. Each sub-menu contains MRU_Max_Submenu_Entries file names. -" The default setting for this is 10. You can change this to increase the -" number of file names displayed in a single sub-menu: -" -" let MRU_Max_Submenu_Entries = 15 -" -" In the MRU window, the filenames are displayed in two parts. The first part -" contains the file name without the path and the second part contains the -" full path to the file in parenthesis. This format is controlled by the -" MRU_Filename_Format variable. If you prefer to change this to some other -" format, then you can modify the MRU_Filename_Format variable. For example, -" to display the full path without splitting it, you can set this variable -" as shown below: -" -" let MRU_Filename_Format = -" \ {'formatter':'v:val', 'parser':'.*', 'syntax': '[^/\\]\+$'} -" -" ****************** Do not modify after this line ************************ -if exists('loaded_mru') - finish -endif -let loaded_mru=1 - -if v:version < 700 - finish -endif - -" Line continuation used here -let s:cpo_save = &cpo -set cpo&vim - -" MRU configuration variables {{{1 -" Maximum number of entries allowed in the MRU list -if !exists('MRU_Max_Entries') - let MRU_Max_Entries = 100 -endif - -" Files to exclude from the MRU list -if !exists('MRU_Exclude_Files') - let MRU_Exclude_Files = '' -endif - -" Files to include in the MRU list -if !exists('MRU_Include_Files') - let MRU_Include_Files = '' -endif - -" Height of the MRU window -" Default height is 8 -if !exists('MRU_Window_Height') - let MRU_Window_Height = 8 -endif - -if !exists('MRU_Use_Current_Window') - let MRU_Use_Current_Window = 0 -endif - -if !exists('MRU_Auto_Close') - let MRU_Auto_Close = 1 -endif - -if !exists('MRU_File') - if has('unix') || has('macunix') - let MRU_File = $HOME . '/.vim_mru_files' - else - let MRU_File = $VIM . '/_vim_mru_files' - if has('win32') - " MS-Windows - if $USERPROFILE != '' - let MRU_File = $USERPROFILE . '\_vim_mru_files' - endif - endif - endif -endif - -" Option for enabling or disabling the MRU menu -if !exists('MRU_Add_Menu') - let MRU_Add_Menu = 1 -endif - -" Maximum number of file names to show in the MRU menu. If too many files are -" listed in the menu, then Vim becomes slow when updating the menu. So set -" this to a low value. -if !exists('MRU_Max_Menu_Entries') - let MRU_Max_Menu_Entries = 10 -endif - -" Maximum number of file names to show in a MRU sub-menu. If the MRU list -" contains more file names than this setting, then the MRU menu is split into -" one or more sub-menus. -if !exists('MRU_Max_Submenu_Entries') - let MRU_Max_Submenu_Entries = 10 -endif - -" When only a single matching filename is found in the MRU list, the following -" option controls whether the file name is displayed in the MRU window or the -" file is directly opened. When this variable is set to 0 and a single -" matching file name is found, then the file is directly opened. -if !exists('MRU_Window_Open_Always') - let MRU_Window_Open_Always = 0 -endif - -" When opening a file from the MRU list, the file is opened in the current -" tab. If the selected file has to be opened in a tab always, then set the -" following variable to 1. If the file is already opened in a tab, then the -" cursor will be moved to that tab. -if !exists('MRU_Open_File_Use_Tabs') - let MRU_Open_File_Use_Tabs = 0 -endif - -" Format of the file names displayed in the MRU window. -" The default is to display the filename followed by the complete path to the -" file in parenthesis. This variable controls the expressions used to format -" and parse the path. This can be changed to display the filenames in a -" different format. The 'formatter' specifies how to split/format the filename -" and 'parser' specifies how to read the filename back; 'syntax' matches the -" part to be highlighted. -if !exists('MRU_Filename_Format') - let MRU_Filename_Format = { - \ 'formatter': 'fnamemodify(v:val, ":t") . " (" . v:val . ")"', - \ 'parser': '(\zs.*\ze)', - \ 'syntax': '^.\{-}\ze(' - \} -endif - -" Control to temporarily lock the MRU list. Used to prevent files from -" getting added to the MRU list when the ':vimgrep' command is executed. -let s:mru_list_locked = 0 - -" MRU_LoadList {{{1 -" Loads the latest list of file names from the MRU file -function! s:MRU_LoadList() - " If the MRU file is present, then load the list of filenames. Otherwise - " start with an empty list. - if filereadable(g:MRU_File) - let s:MRU_files = readfile(g:MRU_File) - if s:MRU_files[0] =~# '^\s*" Most recently edited files in Vim' - " Generated by the previous version of the MRU plugin. - " Discard the list. - let s:MRU_files = [] - elseif s:MRU_files[0] =~# '^#' - " Remove the comment line - call remove(s:MRU_files, 0) - else - " Unsupported format - let s:MRU_files = [] - endif - else - let s:MRU_files = [] - endif - - " Refresh the MRU menu with the latest list of filenames - call s:MRU_Refresh_Menu() -endfunction - -" MRU_SaveList {{{1 -" Saves the MRU file names to the MRU file -function! s:MRU_SaveList() - let l = [] - call add(l, '# Most recently edited files in Vim (version 3.0)') - call extend(l, s:MRU_files) - call writefile(l, g:MRU_File) -endfunction - -" MRU_AddFile {{{1 -" Adds a file to the MRU file list -" acmd_bufnr - Buffer number of the file to add -function! s:MRU_AddFile(acmd_bufnr) - if s:mru_list_locked - " MRU list is currently locked - return - endif - - " Get the full path to the filename - let fname = fnamemodify(bufname(a:acmd_bufnr + 0), ':p') - if fname == '' - return - endif - - " Skip temporary buffers with buftype set. The buftype is set for buffers - " used by plugins. - if &buftype != '' - return - endif - - if g:MRU_Include_Files != '' - " If MRU_Include_Files is set, include only files matching the - " specified pattern - if fname !~# g:MRU_Include_Files - return - endif - endif - - if g:MRU_Exclude_Files != '' - " Do not add files matching the pattern specified in the - " MRU_Exclude_Files to the MRU list - if fname =~# g:MRU_Exclude_Files - return - endif - endif - - " If the filename is not already present in the MRU list and is not - " readable then ignore it - let idx = index(s:MRU_files, fname) - if idx == -1 - if !filereadable(fname) - " File is not readable and is not in the MRU list - return - endif - endif - - " Load the latest MRU file list - call s:MRU_LoadList() - - " Remove the new file name from the existing MRU list (if already present) - call filter(s:MRU_files, 'v:val !=# fname') - - " Add the new file list to the beginning of the updated old file list - call insert(s:MRU_files, fname, 0) - - " Trim the list - if len(s:MRU_files) > g:MRU_Max_Entries - call remove(s:MRU_files, g:MRU_Max_Entries, -1) - endif - - " Save the updated MRU list - call s:MRU_SaveList() - - " Refresh the MRU menu - call s:MRU_Refresh_Menu() - - " If the MRU window is open, update the displayed MRU list - let bname = '__MRU_Files__' - let winnum = bufwinnr(bname) - if winnum != -1 - let cur_winnr = winnr() - call s:MRU_Open_Window() - if winnr() != cur_winnr - exe cur_winnr . 'wincmd w' - endif - endif -endfunction - -" MRU_escape_filename {{{1 -" Escape special characters in a filename. Special characters in file names -" that should be escaped (for security reasons) -let s:esc_filename_chars = ' *?[{`$%#"|!<>();&' . "'\t\n" -function! s:MRU_escape_filename(fname) - if exists("*fnameescape") - return fnameescape(a:fname) - else - return escape(a:fname, s:esc_filename_chars) - endif -endfunction - -" MRU_Edit_File {{{1 -" Edit the specified file -" filename - Name of the file to edit -" sanitized - Specifies whether the filename is already escaped for special -" characters or not. -function! s:MRU_Edit_File(filename, sanitized) - if !a:sanitized - let esc_fname = s:MRU_escape_filename(a:filename) - else - let esc_fname = a:filename - endif - - " If the user wants to always open the file in a tab, then open the file - " in a tab. If it is already opened in a tab, then the cursor will be - " moved to that tab. - if g:MRU_Open_File_Use_Tabs - call s:MRU_Open_File_In_Tab(a:filename, esc_fname) - return - endif - - " If the file is already open in one of the windows, jump to it - let winnum = bufwinnr('^' . a:filename . '$') - if winnum != -1 - if winnum != winnr() - exe winnum . 'wincmd w' - endif - else - if !&hidden && (&modified || &buftype != '' || &previewwindow) - " Current buffer has unsaved changes or is a special buffer or is - " the preview window. The 'hidden' option is also not set. - " So open the file in a new window. - exe 'split ' . esc_fname - else - " The current file can be replaced with the selected file. - exe 'edit ' . esc_fname - endif - endif -endfunction - -" MRU_Open_File_In_Tab -" Open a file in a tab. If the file is already opened in a tab, jump to the -" tab. Otherwise, create a new tab and open the file. -" fname : Name of the file to open -" esc_fname : File name with special characters escaped -function! s:MRU_Open_File_In_Tab(fname, esc_fname) - " If the selected file is already open in the current tab or in - " another tab, jump to it. Otherwise open it in a new tab - if bufwinnr('^' . a:fname . '$') == -1 - let tabnum = -1 - let i = 1 - let bnum = bufnr('^' . a:fname . '$') - while i <= tabpagenr('$') - if index(tabpagebuflist(i), bnum) != -1 - let tabnum = i - break - endif - let i += 1 - endwhile - - if tabnum != -1 - " Goto the tab containing the file - exe 'tabnext ' . i - else - " Open a new tab as the last tab page - exe '$tabnew ' . a:esc_fname - endif - endif - - " Jump to the window containing the file - let winnum = bufwinnr('^' . a:fname . '$') - if winnum != winnr() - exe winnum . 'wincmd w' - endif -endfunction - -" MRU_Window_Edit_File {{{1 -" fname : Name of the file to edit. May specify single or multiple -" files. -" edit_type : Specifies how to edit the file. Can be one of 'edit' or 'view'. -" 'view' - Open the file as a read-only file -" 'edit' - Edit the file as a regular file -" multi : Specifies whether a single file or multiple files need to be -" opened. -" open_type : Specifies where to open the file. -" useopen - If the file is already present in a window, then -" jump to that window. Otherwise, open the file in -" the previous window. -" newwin_horiz - Open the file in a new horizontal window. -" newwin_vert - Open the file in a new vertical window. -" newtab - Open the file in a new tab. If the file is already -" opened in a tab, then jump to that tab. -" preview - Open the file in the preview window -function! s:MRU_Window_Edit_File(fname, multi, edit_type, open_type) - let esc_fname = s:MRU_escape_filename(a:fname) - - if a:open_type ==# 'newwin_horiz' - " Edit the file in a new horizontally split window above the previous - " window - wincmd p - exe 'belowright new ' . esc_fname - elseif a:open_type ==# 'newwin_vert' - " Edit the file in a new vertically split window above the previous - " window - wincmd p - exe 'belowright vnew ' . esc_fname - elseif a:open_type ==# 'newtab' || g:MRU_Open_File_Use_Tabs - call s:MRU_Open_File_In_Tab(a:fname, esc_fname) - elseif a:open_type ==# 'preview' - " Edit the file in the preview window - exe 'topleft pedit ' . esc_fname - else - " If the selected file is already open in one of the windows, - " jump to it - let winnum = bufwinnr('^' . a:fname . '$') - if winnum != -1 - exe winnum . 'wincmd w' - else - if g:MRU_Auto_Close == 1 && g:MRU_Use_Current_Window == 0 - " Jump to the window from which the MRU window was opened - if exists('s:MRU_last_buffer') - let last_winnr = bufwinnr(s:MRU_last_buffer) - if last_winnr != -1 && last_winnr != winnr() - exe last_winnr . 'wincmd w' - endif - endif - else - if g:MRU_Use_Current_Window == 0 - " Goto the previous window - " If MRU_Use_Current_Window is set to one, then the - " current window is used to open the file - wincmd p - endif - endif - - let split_window = 0 - - if (!&hidden && (&modified || &previewwindow)) || a:multi - " Current buffer has unsaved changes or is the preview window - " or the user is opening multiple files - " So open the file in a new window - let split_window = 1 - endif - - if &buftype != '' - " Current buffer is a special buffer (maybe used by a plugin) - if g:MRU_Use_Current_Window == 0 || - \ bufnr('%') != bufnr('__MRU_Files__') - let split_window = 1 - endif - endif - - " Edit the file - if split_window - " Current buffer has unsaved changes or is a special buffer or - " is the preview window. So open the file in a new window - if a:edit_type ==# 'edit' - exe 'split ' . esc_fname - else - exe 'sview ' . esc_fname - endif - else - if a:edit_type ==# 'edit' - exe 'edit ' . esc_fname - else - exe 'view ' . esc_fname - endif - endif - endif - endif -endfunction - -" MRU_Select_File_Cmd {{{1 -" Open a file selected from the MRU window -" -" 'opt' has two values separated by comma. The first value specifies how to -" edit the file and can be either 'edit' or 'view'. The second value -" specifies where to open the file. It can take one of the following values: -" 'useopen' to open file in the previous window -" 'newwin_horiz' to open the file in a new horizontal split window -" 'newwin_vert' to open the file in a new vertical split window. -" 'newtab' to open the file in a new tab. -" If multiple file names are selected using visual mode, then open multiple -" files (either in split windows or tabs) -function! s:MRU_Select_File_Cmd(opt) range - let [edit_type, open_type] = split(a:opt, ',') - - let fnames = getline(a:firstline, a:lastline) - - if g:MRU_Auto_Close == 1 && g:MRU_Use_Current_Window == 0 - " Automatically close the window if the file window is - " not used to display the MRU list. - silent! close - endif - - let multi = 0 - - for f in fnames - if f == '' - continue - endif - - " The text in the MRU window contains the filename in parenthesis - let file = matchstr(f, g:MRU_Filename_Format.parser) - - call s:MRU_Window_Edit_File(file, multi, edit_type, open_type) - - if a:firstline != a:lastline - " Opening multiple files - let multi = 1 - endif - endfor -endfunction - -" MRU_Warn_Msg {{{1 -" Display a warning message -function! s:MRU_Warn_Msg(msg) - echohl WarningMsg - echo a:msg - echohl None -endfunction - -" MRU_Open_Window {{{1 -" Display the Most Recently Used file list in a temporary window. -" If the optional argument is supplied, then it specifies the pattern of files -" to selectively display in the MRU window. -function! s:MRU_Open_Window(...) - - " Load the latest MRU file list - call s:MRU_LoadList() - - " Check for empty MRU list - if empty(s:MRU_files) - call s:MRU_Warn_Msg('MRU file list is empty') - return - endif - - " Save the current buffer number. This is used later to open a file when a - " entry is selected from the MRU window. The window number is not saved, - " as the window number will change when new windows are opened. - let s:MRU_last_buffer = bufnr('%') - - let bname = '__MRU_Files__' - - " If the window is already open, jump to it - let winnum = bufwinnr(bname) - if winnum != -1 - if winnr() != winnum - " If not already in the window, jump to it - exe winnum . 'wincmd w' - endif - - setlocal modifiable - - " Delete the contents of the buffer to the black-hole register - silent! %delete _ - else - if g:MRU_Use_Current_Window - " Reuse the current window - " - " If the __MRU_Files__ buffer exists, then reuse it. Otherwise open - " a new buffer - let bufnum = bufnr(bname) - if bufnum == -1 - let cmd = 'edit ' . bname - else - let cmd = 'buffer ' . bufnum - endif - - exe cmd - - if bufnr('%') != bufnr(bname) - " Failed to edit the MRU buffer - return - endif - else - " Open a new window at the bottom - - " If the __MRU_Files__ buffer exists, then reuse it. Otherwise open - " a new buffer - let bufnum = bufnr(bname) - if bufnum == -1 - let wcmd = bname - else - let wcmd = '+buffer' . bufnum - endif - - exe 'silent! botright ' . g:MRU_Window_Height . 'split ' . wcmd - endif - endif - - setlocal modifiable - - " Mark the buffer as scratch - setlocal buftype=nofile - setlocal bufhidden=delete - setlocal noswapfile - setlocal nowrap - setlocal nobuflisted - " Set the 'filetype' to 'mru'. This allows the user to apply custom - " syntax highlighting or other changes to the MRU bufer. - setlocal filetype=mru - " Use fixed height for the MRU window - setlocal winfixheight - - " Setup the cpoptions properly for the maps to work - let old_cpoptions = &cpoptions - set cpoptions&vim - - " Create mappings to select and edit a file from the MRU list - nnoremap - \ :call MRU_Select_File_Cmd('edit,useopen') - vnoremap - \ :call MRU_Select_File_Cmd('edit,useopen') - nnoremap o - \ :call MRU_Select_File_Cmd('edit,newwin_horiz') - vnoremap o - \ :call MRU_Select_File_Cmd('edit,newwin_horiz') - nnoremap - \ :call MRU_Select_File_Cmd('edit,newwin_horiz') - vnoremap - \ :call MRU_Select_File_Cmd('edit,newwin_horiz') - nnoremap O - \ :call MRU_Select_File_Cmd('edit,newwin_vert') - vnoremap O - \ :call MRU_Select_File_Cmd('edit,newwin_vert') - nnoremap t - \ :call MRU_Select_File_Cmd('edit,newtab') - vnoremap t - \ :call MRU_Select_File_Cmd('edit,newtab') - nnoremap v - \ :call MRU_Select_File_Cmd('view,useopen') - nnoremap p - \ :call MRU_Select_File_Cmd('view,preview') - vnoremap p - \ :if line("'<") == line("'>") - \ call MRU_Select_File_Cmd('open,preview') - \ else - \ echoerr "Only a single file can be previewed" - \ endif - nnoremap u :MRU - nnoremap <2-LeftMouse> - \ :call MRU_Select_File_Cmd('edit,useopen') - nnoremap q :close - - " Restore the previous cpoptions settings - let &cpoptions = old_cpoptions - - " Display the MRU list - if a:0 == 0 - " No search pattern specified. Display the complete list - let m = copy(s:MRU_files) - else - " Display only the entries matching the specified pattern - " First try using it as a literal pattern - let m = filter(copy(s:MRU_files), 'stridx(v:val, a:1) != -1') - if len(m) == 0 - " No match. Try using it as a regular expression - let m = filter(copy(s:MRU_files), 'v:val =~# a:1') - endif - endif - - " Get the tail part of the file name (without the directory) and display - " it along with the full path in parenthesis. - let output = map(m, g:MRU_Filename_Format.formatter) - silent! 0put =output - - " Delete the empty line at the end of the buffer - silent! $delete _ - - " Move the cursor to the beginning of the file - normal! gg - - " Add syntax highlighting for the file names - if has_key(g:MRU_Filename_Format, 'syntax') - exe "syntax match MRUFileName '" . g:MRU_Filename_Format.syntax . "'" - highlight default link MRUFileName Identifier - endif - - setlocal nomodifiable -endfunction - -" MRU_Complete {{{1 -" Command-line completion function used by :MRU command -function! s:MRU_Complete(ArgLead, CmdLine, CursorPos) - if a:ArgLead == '' - " Return the complete list of MRU files - return s:MRU_files - else - " Return only the files matching the specified pattern - return filter(copy(s:MRU_files), 'v:val =~? a:ArgLead') - endif -endfunction - -" MRU_Cmd {{{1 -" Function to handle the MRU command -" pat - File name pattern passed to the MRU command -function! s:MRU_Cmd(pat) - if a:pat == '' - " No arguments specified. Open the MRU window - call s:MRU_Open_Window() - return - endif - - " Load the latest MRU file - call s:MRU_LoadList() - - " Empty MRU list - if empty(s:MRU_files) - call s:MRU_Warn_Msg('MRU file list is empty') - return - endif - - " First use the specified string as a literal string and search for - " filenames containing the string. If only one filename is found, - " then edit it (unless the user wants to open the MRU window always) - let m = filter(copy(s:MRU_files), 'stridx(v:val, a:pat) != -1') - if len(m) > 0 - if len(m) == 1 && !g:MRU_Window_Open_Always - call s:MRU_Edit_File(m[0], 0) - return - endif - - " More than one file matches. Try find an accurate match - let new_m = filter(m, 'v:val ==# a:pat') - if len(new_m) == 1 && !g:MRU_Window_Open_Always - call s:MRU_Edit_File(new_m[0], 0) - return - endif - - " Couldn't find an exact match, open the MRU window with all the - " files matching the pattern. - call s:MRU_Open_Window(a:pat) - return - endif - - " Use the specified string as a regular expression pattern and search - " for filenames matching the pattern - let m = filter(copy(s:MRU_files), 'v:val =~? a:pat') - - if len(m) == 0 - " If an existing file (not present in the MRU list) is specified, - " then open the file. - if filereadable(a:pat) - call s:MRU_Edit_File(a:pat, 0) - return - endif - - " No filenames matching the specified pattern are found - call s:MRU_Warn_Msg("MRU file list doesn't contain " . - \ "files matching " . a:pat) - return - endif - - if len(m) == 1 && !g:MRU_Window_Open_Always - call s:MRU_Edit_File(m[0], 0) - return - endif - - call s:MRU_Open_Window(a:pat) -endfunction - -" MRU_add_files_to_menu {{{1 -" Adds a list of files to the "Recent Files" sub menu under the "File" menu. -" prefix - Prefix to use for each of the menu entries -" file_list - List of file names to add to the menu -function! s:MRU_add_files_to_menu(prefix, file_list) - for fname in a:file_list - " Escape special characters in the filename - let esc_fname = escape(fnamemodify(fname, ':t'), ".\\" . - \ s:esc_filename_chars) - let esc_fname = substitute(esc_fname, '&', '&&', 'g') - - " Truncate the directory name if it is long - let dir_name = fnamemodify(fname, ':h') - let len = strlen(dir_name) - " Shorten long file names by adding only few characters from - " the beginning and end. - if len > 30 - let dir_name = strpart(dir_name, 0, 10) . - \ '...' . - \ strpart(dir_name, len - 20) - endif - let esc_dir_name = escape(dir_name, ".\\" . s:esc_filename_chars) - let esc_dir_name = substitute(esc_dir_name, '&', '&&', 'g') - - let menu_path = '&File.&Recent\ Files.' . a:prefix . esc_fname . - \ '\ (' . esc_dir_name . ')' - let esc_mfname = s:MRU_escape_filename(fname) - exe 'anoremenu ' . menu_path . - \ " :call MRU_Edit_File('" . esc_mfname . "', 1)" - exe 'tmenu ' . menu_path . ' Edit file ' . esc_mfname - endfor -endfunction - -" MRU_Refresh_Menu {{{1 -" Refresh the MRU menu -function! s:MRU_Refresh_Menu() - if !has('menu') || !g:MRU_Add_Menu - " No support for menus - return - endif - - " Setup the cpoptions properly for the maps to work - let old_cpoptions = &cpoptions - set cpoptions&vim - - " Remove the MRU menu - " To retain the teared-off MRU menu, we need to add a dummy entry - silent! unmenu &File.&Recent\ Files - " The menu priority of the File menu is 10. If the MRU plugin runs - " first before menu.vim, the File menu order may not be correct. - " So specify the priority of the File menu here. - 10noremenu &File.&Recent\ Files.Dummy - silent! unmenu! &File.&Recent\ Files - - anoremenu &File.&Recent\ Files.Refresh\ list - \ :call MRU_LoadList() - exe 'tmenu File.&Recent\ Files.Refresh\ list Reload the MRU file list from ' - \ . s:MRU_escape_filename(g:MRU_File) - anoremenu File.&Recent\ Files.-SEP1- : - - " Add the filenames in the MRU list to the menu - let entry_cnt = len(s:MRU_files) - if entry_cnt > g:MRU_Max_Menu_Entries - " Show only MRU_Max_Menu_Entries file names in the menu - let mru_list = s:MRU_files[0 : g:MRU_Max_Menu_Entries - 1] - let entry_cnt = g:MRU_Max_Menu_Entries - else - let mru_list = s:MRU_files - endif - if entry_cnt > g:MRU_Max_Submenu_Entries - " Split the MRU menu into sub-menus - for start_idx in range(0, entry_cnt, g:MRU_Max_Submenu_Entries) - let last_idx = start_idx + g:MRU_Max_Submenu_Entries - 1 - if last_idx >= entry_cnt - let last_idx = entry_cnt - 1 - endif - let prefix = 'Files\ (' . (start_idx + 1) . '\.\.\.' . - \ (last_idx + 1) . ').' - call s:MRU_add_files_to_menu(prefix, - \ mru_list[start_idx : last_idx]) - endfor - else - call s:MRU_add_files_to_menu('', mru_list) - endif - - " Remove the dummy menu entry - unmenu &File.&Recent\ Files.Dummy - - " Restore the previous cpoptions settings - let &cpoptions = old_cpoptions -endfunction - -" Load the MRU list on plugin startup -call s:MRU_LoadList() - -" MRU autocommands {{{1 -" Autocommands to detect the most recently used files -autocmd BufRead * call s:MRU_AddFile(expand('')) -autocmd BufNewFile * call s:MRU_AddFile(expand('')) -autocmd BufWritePost * call s:MRU_AddFile(expand('')) - -" The ':vimgrep' command adds all the files searched to the buffer list. -" This also modifies the MRU list, even though the user didn't edit the -" files. Use the following autocmds to prevent this. -autocmd QuickFixCmdPre *vimgrep* let s:mru_list_locked = 1 -autocmd QuickFixCmdPost *vimgrep* let s:mru_list_locked = 0 - -" Command to open the MRU window -command! -nargs=? -complete=customlist,s:MRU_Complete MRU - \ call s:MRU_Cmd() -command! -nargs=? -complete=customlist,s:MRU_Complete Mru - \ call s:MRU_Cmd() - -" }}} - -" restore 'cpo' -let &cpo = s:cpo_save -unlet s:cpo_save - -" vim:set foldenable foldmethod=marker: diff --git a/sources_non_forked/nerdtree/.github/PULL_REQUEST_TEMPLATE.md b/sources_non_forked/nerdtree/.github/PULL_REQUEST_TEMPLATE.md index 55dc0102..d4d74acf 100644 --- a/sources_non_forked/nerdtree/.github/PULL_REQUEST_TEMPLATE.md +++ b/sources_non_forked/nerdtree/.github/PULL_REQUEST_TEMPLATE.md @@ -1,5 +1,5 @@ ### Description of Changes -Closes # +Closes # --- @@ -28,5 +28,15 @@ Closes # - [ ] Update [CHANGELOG.md](https://github.com/scrooloose/nerdtree/blob/master/CHANGELOG.md), following the established pattern. #### Collaborator's Instructions - [ ] Review [CHANGELOG.md](https://github.com/scrooloose/nerdtree/blob/master/CHANGELOG.md), suggesting a different version number if necessary. +<<<<<<< HEAD - [ ] After merge, tag the merge commit, e.g. `git tag -a 3.1.4 -m "v3.1.4" && git push origin --tags` >>>>>>> 27ad0d07862847896f691309a544a206783c94d6 +======= +- [ ] After merging, tag the commit using these (Mac-compatible) bash commands: + ```bash + git checkout master + git pull + sed -n "$(grep -n -m2 '####' CHANGELOG.md | cut -f1 -d: | sed 'N;s/\n/,/')p" CHANGELOG.md | sed '$d' + git tag -a $(read -p "Tag Name: " tag;echo $tag) -m"$(git show --quiet --pretty=%s)";git push origin --tags + ``` +>>>>>>> master diff --git a/sources_non_forked/nerdtree/CHANGELOG.md b/sources_non_forked/nerdtree/CHANGELOG.md index 10d6508f..575073a8 100644 --- a/sources_non_forked/nerdtree/CHANGELOG.md +++ b/sources_non_forked/nerdtree/CHANGELOG.md @@ -125,14 +125,45 @@ - Add support for copy command in Windows (SkylerLipthay) [#231](https://github.com/scrooloose/nerdtree/pull/231) ======= # NERDTree Change Log - - +#### 6.9 +- **.10**: Open a mirrored NERDTree with correct width (PhilRunninger) [#1177](https://github.com/preservim/nerdtree/pull/1177) +- **.9**: Updated Readme, removed typo (H3RSKO) [#1167](https://github.com/preservim/nerdtree/pull/1167) +- **.8**: Refactor sort comparison functions, removing redundancy (PhilRunninger) [#1166](https://github.com/preservim/nerdtree/pull/1166) +- **.7**: Fix argument of `exists()` function calls checking for autocommands. (PhilRunninger) [#1165](https://github.com/preservim/nerdtree/pull/1165) +- **.6**: Don't use silent when raising User events (PhilRunninger) [#1164](https://github.com/preservim/nerdtree/pull/1164) +- **.5**: Fix highlight for file node. (pirey) [#1157](https://github.com/preservim/nerdtree/pull/1157) +- **.4**: Make sure symbolic links' flags are highlighted correctly. (PhilRunninger) [#1156](https://github.com/preservim/nerdtree/pull/1156) +- **.3**: Fix new NERDTrees' width when previous one was in the only window. (PhilRunninger) [#1153](https://github.com/preservim/nerdtree/pull/1153) +- **.2**: Fix the scope of several key mappings (lifecrisis, PhilRunninger) [#1151](https://github.com/preservim/nerdtree/pull/1151) +- **.1**: Respect user's `&shellslash` setting in CopyNode and RemoveNode functions (PhilRunninger) [#1150](https://github.com/preservim/nerdtree/pull/1150) +- **.0**: Enable opening bookmarks in split windows. (PhilRunninger) [#1144](https://github.com/preservim/nerdtree/pull/1144) +#### 6.8 +- **.0**: Allow concealed characters to show another character. (PhilRunninger) [#1138](https://github.com/preservim/nerdtree/pull/1138) +#### 6.7 +- **.15**: Add curly braces to the list of characters to be escaped. (PhilRunninger) [#1128](https://github.com/preservim/nerdtree/pull/1128) +- **.14**: Use backward-compatible `nerdtree#and()` in one place that was missed. (PhilRunninger) [#1134](https://github.com/preservim/nerdtree/pull/1134) +- **.13**: `cmd.exe /c start "" ` for windows default viewer support. (J. Altayó) [#1130](https://github.com/preservim/nerdtree/pull/1130) +- **.12**: Fixed a bug that caused the file-tree construction to slow down significantly. (Eugenij-W) [#1126](https://github.com/preservim/nerdtree/pull/1126) +- **.11**: Fix exception in NERDTreeFind (on windows OS and If the file is located in the root directory of the disk) (Eugenij-W) [#1122](https://github.com/preservim/nerdtree/pull/1122) +- **.10**: Do not consider the tree root to be "cascadable". (lifecrisis) [#1120](https://github.com/preservim/nerdtree/pull/1120) +- **.9**: Force `:NERDTreeFocus` to allow events to be fired when switching windows. (PhilRunninger) [#1118](https://github.com/preservim/nerdtree/pull/1118) +- **.8**: Fix example code for the `NERDTreeAddKeyMap()` function. (PhilRunninger) [#1116](https://github.com/preservim/nerdtree/pull/1116) +- **.7**: Put `'%'` argument in `bufname()` for backwards compatibility. (PhilRunninger) [#1105](https://github.com/preservim/nerdtree/pull/1105) +- **.6**: If a file's already open in the window, don't edit it again. (PhilRunninger) [#1103](https://github.com/preservim/nerdtree/pull/1103) +- **.5**: Prevent unneeded tree creation in `:NERDTreeToggle[VCS] ` (PhilRunninger) [#1101](https://github.com/preservim/nerdtree/pull/1101) +- **.4**: Add missing calls to the `shellescape()` function (lifecrisis) [#1099](https://github.com/preservim/nerdtree/pull/1099) +- **.3**: Fix vsplit to not open empty buffers when opening previously closed file (AwkwardKore) [#1098](https://github.com/preservim/nerdtree/pull/1098) +- **.2**: Fix infinity loop (on winvim) in FindParentVCSRoot (Eugenij-W) [#1095](https://github.com/preservim/nerdtree/pull/1095) +- **.1**: File Move: Escape existing directory name when looking for open files. (PhilRunninger) [#1094](https://github.com/preservim/nerdtree/pull/1094) +- **.0**: Open the parent directory when revealing a non-existent file with :NERDTreeFind (bouk) [#1090](https://github.com/preservim/nerdtree/pull/1090) +#### 6.6 +- **.1**: [add] How to install using dein.vim (kazukazuinaina) [#1087](https://github.com/preservim/nerdtree/pull/1087) +- **.0**: Add the ability to turn off directory arrows (PhilRunninger) [#1085](https://github.com/preservim/nerdtree/pull/1085) #### 6.5 - **.0**: `NERDTreeToggle ` always sets NERDTree root. (PhilRunninger) [#1083](https://github.com/preservim/nerdtree/pull/1083) #### 6.4 diff --git a/sources_non_forked/nerdtree/README.markdown b/sources_non_forked/nerdtree/README.markdown index e7632420..018923cf 100644 --- a/sources_non_forked/nerdtree/README.markdown +++ b/sources_non_forked/nerdtree/README.markdown @@ -28,7 +28,7 @@ git clone https://github.com/preservim/nerdtree.git ~/.vim/pack/vendor/start/ner vim -u NONE -c "helptags ~/.vim/pack/vendor/start/nerdtree/doc" -c q ``` -Otherwise, these are some of the several 3rd-party plugin managers you can choose from. Be sure you read the instructions for your chosen plugin, as there typically are additional steps you nee d to take. +Otherwise, these are some of the several 3rd-party plugin managers you can choose from. Be sure you read the instructions for your chosen plugin, as there typically are additional steps you need to take. #### [pathogen.vim](https://github.com/tpope/vim-pathogen) @@ -59,6 +59,13 @@ Plug 'preservim/nerdtree' call plug#end() ``` +#### [dein.vim](https://github.com/Shougo/dein.vim) +```vim +call dein#begin() +call dein#add('preservim/nerdtree') +call dein#end() +``` + #### [apt-vim](https://github.com/egalpin/apt-vim) ```bash apt-vim install -y https://github.com/preservim/nerdtree.git @@ -143,3 +150,8 @@ Use these variables in your vimrc. Note that below are default arrow symbols let g:NERDTreeDirArrowExpandable = '▸' let g:NERDTreeDirArrowCollapsible = '▾' ``` +You can remove the arrows altogether by setting these variables to empty strings, as shown below. This will remove not only the arrows, but a single space following them, shifting the whole tree two character positions to the left. +```vim +let g:NERDTreeDirArrowExpandable = '' +let g:NERDTreeDirArrowCollapsible = '' +``` diff --git a/sources_non_forked/nerdtree/autoload/nerdtree.vim b/sources_non_forked/nerdtree/autoload/nerdtree.vim index 0e691a8b..8a221640 100644 --- a/sources_non_forked/nerdtree/autoload/nerdtree.vim +++ b/sources_non_forked/nerdtree/autoload/nerdtree.vim @@ -46,6 +46,7 @@ endfunction " SECTION: General Functions {{{1 "============================================================ +<<<<<<< HEAD <<<<<<< HEAD function! nerdtree#slash() ======= @@ -53,6 +54,13 @@ function! nerdtree#slash() function! nerdtree#slash() abort >>>>>>> 27ad0d07862847896f691309a544a206783c94d6 +======= +" FUNCTION: nerdtree#slash() {{{2 +" Return the path separator used by the underlying file system. Special +" consideration is taken for the use of the 'shellslash' option on Windows +" systems. +function! nerdtree#slash() abort +>>>>>>> master if nerdtree#runningWindows() if exists('+shellslash') && &shellslash return '/' @@ -65,7 +73,7 @@ function! nerdtree#slash() abort endfunction "FUNCTION: nerdtree#and(x,y) {{{2 -" Implements and() function for Vim <= 7.2 +" Implements and() function for Vim <= 7.4 function! nerdtree#and(x,y) abort if exists('*and') return and(a:x, a:y) @@ -128,15 +136,15 @@ function! nerdtree#completeBookmarks(A,L,P) abort return filter(g:NERDTreeBookmark.BookmarkNames(), 'v:val =~# "^' . a:A . '"') endfunction -"FUNCTION: nerdtree#compareNodes(dir) {{{2 +"FUNCTION: nerdtree#compareNodes(n1, n2) {{{2 function! nerdtree#compareNodes(n1, n2) abort - return a:n1.path.compareTo(a:n2.path) + return nerdtree#compareNodePaths(a:n1.path, a:n2.path) endfunction -"FUNCTION: nerdtree#compareNodesBySortKey(n1, n2) {{{2 -function! nerdtree#compareNodesBySortKey(n1, n2) abort - let sortKey1 = a:n1.path.getSortKey() - let sortKey2 = a:n2.path.getSortKey() +"FUNCTION: nerdtree#compareNodePaths(p1, p2) {{{2 +function! nerdtree#compareNodePaths(p1, p2) abort + let sortKey1 = a:p1.getSortKey() + let sortKey2 = a:p2.getSortKey() let i = 0 while i < min([len(sortKey1), len(sortKey2)]) " Compare chunks upto common length. diff --git a/sources_non_forked/nerdtree/autoload/nerdtree/ui_glue.vim b/sources_non_forked/nerdtree/autoload/nerdtree/ui_glue.vim index 41653685..7e3957ac 100644 --- a/sources_non_forked/nerdtree/autoload/nerdtree/ui_glue.vim +++ b/sources_non_forked/nerdtree/autoload/nerdtree/ui_glue.vim @@ -32,12 +32,16 @@ function! nerdtree#ui_glue#createDefaultBindings() abort call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapPreview, 'scope': 'Bookmark', 'callback': s.'previewBookmark' }) call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapActivateNode, 'scope': 'all', 'callback': s.'activateAll' }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenSplit, 'scope': 'Node', 'callback': s.'openHSplit' }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenVSplit, 'scope': 'Node', 'callback': s.'openVSplit' }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenSplit, 'scope': 'FileNode', 'callback': s.'openHSplit' }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenSplit, 'scope': 'Bookmark', 'callback': s.'openHSplitBookmark' }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenVSplit, 'scope': 'FileNode', 'callback': s.'openVSplit' }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenVSplit, 'scope': 'Bookmark', 'callback': s.'openVSplitBookmark' }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapPreview, 'scope': 'Node', 'callback': s.'previewNodeCurrent' }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapPreviewVSplit, 'scope': 'Node', 'callback': s.'previewNodeVSplit' }) - call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapPreviewSplit, 'scope': 'Node', 'callback': s.'previewNodeHSplit' }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapPreview, 'scope': 'FileNode', 'callback': s.'previewNodeCurrent' }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapPreviewSplit, 'scope': 'FileNode', 'callback': s.'previewNodeHSplit' }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapPreviewSplit, 'scope': 'Bookmark', 'callback': s.'previewNodeHSplitBookmark' }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapPreviewVSplit, 'scope': 'FileNode', 'callback': s.'previewNodeVSplit' }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapPreviewVSplit, 'scope': 'Bookmark', 'callback': s.'previewNodeVSplitBookmark' }) call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenRecursively, 'scope': 'DirNode', 'callback': s.'openNodeRecursively' }) @@ -314,6 +318,7 @@ endfunction " FUNCTION: s:findAndRevealPath(pathStr) {{{1 function! s:findAndRevealPath(pathStr) abort let l:pathStr = !empty(a:pathStr) ? a:pathStr : expand('%:p') + let l:revealOpts = {} if empty(l:pathStr) call nerdtree#echoWarning('no file for the current buffer') @@ -322,6 +327,7 @@ function! s:findAndRevealPath(pathStr) abort if !filereadable(l:pathStr) let l:pathStr = fnamemodify(l:pathStr, ':h') + let l:revealOpts['open'] = 1 endif try @@ -357,7 +363,7 @@ function! s:findAndRevealPath(pathStr) abort call b:NERDTree.ui.setShowHidden(1) endif - let l:node = b:NERDTree.root.reveal(l:pathObj) + let l:node = b:NERDTree.root.reveal(l:pathObj, l:revealOpts) call b:NERDTree.render() call l:node.putCursorHere(1, 0) endfunction @@ -539,6 +545,28 @@ function! s:openVSplit(target) abort call a:target.activate({'where': 'v'}) endfunction +"FUNCTION: s:openHSplitBookmark(bookmark) {{{1 +"handle the user activating a bookmark +function! s:openHSplitBookmark(bm) abort + call a:bm.activate(b:NERDTree, !a:bm.path.isDirectory ? {'where': 'h'} : {}) +endfunction + +"FUNCTION: s:openVSplitBookmark(bookmark) {{{1 +"handle the user activating a bookmark +function! s:openVSplitBookmark(bm) abort + call a:bm.activate(b:NERDTree, !a:bm.path.isDirectory ? {'where': 'v'} : {}) +endfunction + +" FUNCTION: s:previewHSplitBookmark(bookmark) {{{1 +function! s:previewNodeHSplitBookmark(bookmark) abort + call a:bookmark.activate(b:NERDTree, !a:bookmark.path.isDirectory ? {'stay': 1, 'where': 'h', 'keepopen': 1} : {}) +endfunction + +" FUNCTION: s:previewVSplitBookmark(bookmark) {{{1 +function! s:previewNodeVSplitBookmark(bookmark) abort + call a:bookmark.activate(b:NERDTree, !a:bookmark.path.isDirectory ? {'stay': 1, 'where': 'v', 'keepopen': 1} : {}) +endfunction + " FUNCTION: s:openExplorer(node) {{{1 function! s:openExplorer(node) abort call a:node.openExplorer() @@ -566,11 +594,7 @@ endfunction " FUNCTION: s:previewBookmark(bookmark) {{{1 function! s:previewBookmark(bookmark) abort - if a:bookmark.path.isDirectory - execute 'NERDTreeFind '.a:bookmark.path.str() - else - call a:bookmark.activate(b:NERDTree, {'stay': 1, 'where': 'p', 'keepopen': 1}) - endif + call a:bookmark.activate(b:NERDTree, !a:bookmark.path.isDirectory ? {'stay': 1, 'where': 'h', 'keepopen': 1} : {}) endfunction "FUNCTION: s:previewNodeCurrent(node) {{{1 diff --git a/sources_non_forked/nerdtree/doc/NERDTree.txt b/sources_non_forked/nerdtree/doc/NERDTree.txt index e2dd56a3..2989718c 100644 --- a/sources_non_forked/nerdtree/doc/NERDTree.txt +++ b/sources_non_forked/nerdtree/doc/NERDTree.txt @@ -318,9 +318,8 @@ Applies to: files. If a file node or a bookmark that links to a file is selected, it is opened in the previous window, but the cursor does not move. -If a bookmark that links to a directory is selected, that directory is found -in the current NERDTree. If the directory couldn't be found, a new NERDTree is -created. +If a bookmark that links to a directory is selected then that directory +becomes the new root. The default key combo for this mapping is "g" + NERDTreeMapActivateNode (see |NERDTree-o|). @@ -350,7 +349,7 @@ The same as |NERDTree-t| except that the focus is kept in the current tab. *NERDTree-i* Default key: i Map setting: *NERDTreeMapOpenSplit* -Applies to: files. +Applies to: files, and bookmarks pointing to files. Opens the selected file in a new split window and puts the cursor in the new window. @@ -359,7 +358,7 @@ window. *NERDTree-gi* Default key: gi Map setting: *NERDTreeMapPreviewSplit* -Applies to: files. +Applies to: files, and bookmarks pointing to files. The same as |NERDTree-i| except that the cursor is not moved. @@ -370,7 +369,7 @@ The default key combo for this mapping is "g" + NERDTreeMapOpenSplit (see *NERDTree-s* Default key: s Map setting: *NERDTreeMapOpenVSplit* -Applies to: files. +Applies to: files, and bookmarks pointing to files. Opens the selected file in a new vertically split window and puts the cursor in the new window. @@ -379,7 +378,7 @@ in the new window. *NERDTree-gs* Default key: gs Map setting: *NERDTreeMapPreviewVSplit* -Applies to: files. +Applies to: files, and bookmarks pointing to files. The same as |NERDTree-s| except that the cursor is not moved. @@ -1223,13 +1222,19 @@ Values: Any single character. Defaults: Windows: ~ and + Others: ▾ and ▸ These characters indicate whether a directory is collapsible or expandable. - -They can be set to "\u00a0" to hide the arrows, but if you do this you may -need to change the node delimiter. See |NERDTreeNodeDelimiter|. You cannot use -the same character for both the arrows and the delimiter. Example: > +Example: > let NERDTreeDirArrowExpandable=">" let NERDTreeDirArrowCollapsible="v" < +They can be set to "\u00a0" to replace the arrows with a non-breaking space. +If you do this you may need to change the node delimiter. See +|NERDTreeNodeDelimiter|. You cannot use the same character for both the arrows +and the delimiter. + +Alternatively, they can be set to '' (an empty string). This removes the +arrows and the single space that follows them, shifting the entire tree two +character positions to the left. + ------------------------------------------------------------------------------ *NERDTreeNodeDelimiter* Values: Any single character. @@ -1347,12 +1352,12 @@ NERDTreeAddKeyMap({options}) *NERDTreeAddKeyMap()* Example: > call NERDTreeAddKeyMap({ \ 'key': 'foo', - \ 'callback': 'NERDTreeCDHandler', + \ 'callback': 'NERDTreeEchoPathHandler', \ 'quickhelpText': 'echo full path of current node', \ 'scope': 'DirNode' }) - function! NERDTreeCDHandler(dirnode) - call a:dirnode.changeToDir() + function! NERDTreeEchoPathHandler(dirnode) + echo a:dirnode.path.str() endfunction < This code should sit in a file like ~/.vim/nerdtree_plugin/mymapping.vim. diff --git a/sources_non_forked/nerdtree/lib/nerdtree/creator.vim b/sources_non_forked/nerdtree/lib/nerdtree/creator.vim index e2b3fa0a..b9d45dc9 100644 --- a/sources_non_forked/nerdtree/lib/nerdtree/creator.vim +++ b/sources_non_forked/nerdtree/lib/nerdtree/creator.vim @@ -28,7 +28,9 @@ endfunction " FUNCTION: s:Creator._broadcastInitEvent() {{{1 function! s:Creator._broadcastInitEvent() - silent doautocmd User NERDTreeInit + if exists('#User#NERDTreeInit') + doautocmd User NERDTreeInit + endif endfunction " FUNCTION: s:Creator.BufNamePrefix() {{{1 @@ -170,6 +172,7 @@ function! s:Creator.createMirror() let t:NERDTreeBufName = bufferName call self._createTreeWin() exec 'buffer ' . bufferName + call b:NERDTree.ui.restoreScreenState() if !&hidden call b:NERDTree.render() endif @@ -247,9 +250,13 @@ function! s:Creator._pathForString(str) "hack to get an absolute path if a relative path is given if dir =~# '^\.' - let dir = getcwd() . g:NERDTreePath.Slash() . dir + let dir = getcwd() . nerdtree#slash() . dir + endif + + "hack to prevent removing slash if dir is the root of the file system. + if dir !=# '/' + let dir = g:NERDTreePath.Resolve(dir) endif - let dir = g:NERDTreePath.Resolve(dir) try let path = g:NERDTreePath.New(dir) @@ -366,7 +373,7 @@ function! s:Creator.toggleTabTree(dir) if g:NERDTree.ExistsForTab() if !g:NERDTree.IsOpen() call self._createTreeWin() - if !empty(a:dir) + if !empty(a:dir) && a:dir !=# b:NERDTree.root.path.str() call self.createTabTree(a:dir) elseif !&hidden call b:NERDTree.render() diff --git a/sources_non_forked/nerdtree/lib/nerdtree/nerdtree.vim b/sources_non_forked/nerdtree/lib/nerdtree/nerdtree.vim index bdc993a1..33007384 100644 --- a/sources_non_forked/nerdtree/lib/nerdtree/nerdtree.vim +++ b/sources_non_forked/nerdtree/lib/nerdtree/nerdtree.vim @@ -27,7 +27,9 @@ function! s:NERDTree.changeRoot(node) call self.render() call self.root.putCursorHere(0, 0) - silent doautocmd User NERDTreeNewRoot + if exists('#User#NERDTreeNewRoot') + doautocmd User NERDTreeNewRoot + endif endfunction "FUNCTION: s:NERDTree.Close() {{{1 @@ -96,9 +98,9 @@ endfunction "FUNCTION: s:NERDTree.CursorToTreeWin(){{{1 "Places the cursor in the nerd tree window -function! s:NERDTree.CursorToTreeWin() +function! s:NERDTree.CursorToTreeWin(...) call g:NERDTree.MustBeOpen() - call nerdtree#exec(g:NERDTree.GetWinNum() . 'wincmd w', 1) + call nerdtree#exec(g:NERDTree.GetWinNum() . 'wincmd w', a:0 >0 ? a:1 : 1) endfunction " Function: s:NERDTree.ExistsForBuffer() {{{1 diff --git a/sources_non_forked/nerdtree/lib/nerdtree/opener.vim b/sources_non_forked/nerdtree/lib/nerdtree/opener.vim index d8dba34e..9c62b723 100644 --- a/sources_non_forked/nerdtree/lib/nerdtree/opener.vim +++ b/sources_non_forked/nerdtree/lib/nerdtree/opener.vim @@ -174,9 +174,8 @@ function! s:Opener._newSplit() "resize the tree window if no other window was open before if onlyOneWin - let size = exists('b:NERDTreeOldWindowSize') ? b:NERDTreeOldWindowSize : g:NERDTreeWinSize call nerdtree#exec('wincmd p', 1) - call nerdtree#exec('silent '. splitMode .' resize '. size, 1) + call nerdtree#exec('silent '. splitMode .' resize '. g:NERDTreeWinSize, 1) call nerdtree#exec('wincmd p', 0) endif @@ -195,7 +194,7 @@ function! s:Opener._newVSplit() endif call nerdtree#exec('wincmd p', 1) - call nerdtree#exec('vnew', 1) + call nerdtree#exec('vsplit', 1) let l:currentWindowNumber = winnr() @@ -219,7 +218,7 @@ endfunction " FUNCTION: Opener._openFile() {{{1 function! s:Opener._openFile() - if !self._stay && !and(g:NERDTreeQuitOnOpen,1) && exists('b:NERDTreeZoomed') && b:NERDTreeZoomed + if !self._stay && !nerdtree#and(g:NERDTreeQuitOnOpen,1) && exists('b:NERDTreeZoomed') && b:NERDTreeZoomed call b:NERDTree.ui.toggleZoom() endif diff --git a/sources_non_forked/nerdtree/lib/nerdtree/path.vim b/sources_non_forked/nerdtree/lib/nerdtree/path.vim index 6a23c7ba..786ccd90 100644 --- a/sources_non_forked/nerdtree/lib/nerdtree/path.vim +++ b/sources_non_forked/nerdtree/lib/nerdtree/path.vim @@ -25,10 +25,10 @@ function! s:Path.AbsolutePathFor(pathStr) if l:prependWorkingDir let l:result = getcwd() - if l:result[-1:] ==# s:Path.Slash() + if l:result[-1:] == nerdtree#slash() let l:result = l:result . a:pathStr else - let l:result = l:result . s:Path.Slash() . a:pathStr + let l:result = l:result . nerdtree#slash() . a:pathStr endif endif @@ -99,50 +99,6 @@ function! s:Path.changeToDir() endtry endfunction -" FUNCTION: Path.compareTo() {{{1 -" -" Compares this Path to the given path and returns 0 if they are equal, -1 if -" this Path is 'less than' the given path, or 1 if it is 'greater'. -" -" Args: -" path: the path object to compare this to -" -" Return: -" 1, -1 or 0 -function! s:Path.compareTo(path) - let thisPath = self.getLastPathComponent(1) - let thatPath = a:path.getLastPathComponent(1) - - "if the paths are the same then clearly we return 0 - if thisPath ==# thatPath - return 0 - endif - - let thisSS = self.getSortOrderIndex() - let thatSS = a:path.getSortOrderIndex() - - "compare the sort sequences, if they are different then the return - "value is easy - if thisSS < thatSS - return -1 - elseif thisSS > thatSS - return 1 - else - if !g:NERDTreeSortHiddenFirst - let thisPath = substitute(thisPath, '^[._]', '', '') - let thatPath = substitute(thatPath, '^[._]', '', '') - endif - "if the sort sequences are the same then compare the paths - "alphabetically - let pathCompare = g:NERDTreeCaseSensitiveSort ? thisPath <# thatPath : thisPath $" endif - return " \\`\|\"#%&,?()\*^<>[]$" + return " \\`\|\"#%&,?()\*^<>[]{}$" endfunction " FUNCTION: Path.getDir() {{{1 @@ -543,26 +502,36 @@ endfunction " return 1 if this path is somewhere above the given path in the filesystem. " " a:path should be a dir -function! s:Path.isAncestor(path) - if !self.isDirectory - return 0 - endif - - let this = self.str() - let that = a:path.str() - return stridx(that, this) ==# 0 +function! s:Path.isAncestor(child) + return a:child.isUnder(self) endfunction " FUNCTION: Path.isUnder(path) {{{1 " return 1 if this path is somewhere under the given path in the filesystem. -function! s:Path.isUnder(path) - if a:path.isDirectory ==# 0 +function! s:Path.isUnder(parent) + if a:parent.isDirectory ==# 0 return 0 endif - - let this = self.str() - let that = a:path.str() - return stridx(this, that . s:Path.Slash()) ==# 0 + if nerdtree#runningWindows() && a:parent.drive !=# self.drive + return 0 + endif + let l:this_count = len(self.pathSegments) + if l:this_count ==# 0 + return 0 + endif + let l:that_count = len(a:parent.pathSegments) + if l:that_count ==# 0 + return 1 + endif + if l:that_count >= l:this_count + return 0 + endif + for i in range(0, l:that_count-1) + if self.pathSegments[i] !=# a:parent.pathSegments[i] + return 0 + endif + endfor + return 1 endfunction " FUNCTION: Path.JoinPathStrings(...) {{{1 @@ -601,23 +570,6 @@ function! s:Path.New(pathStr) return l:newPath endfunction -" FUNCTION: Path.Slash() {{{1 -" Return the path separator used by the underlying file system. Special -" consideration is taken for the use of the 'shellslash' option on Windows -" systems. -function! s:Path.Slash() - - if nerdtree#runningWindows() - if exists('+shellslash') && &shellslash - return '/' - endif - - return '\' - endif - - return '/' -endfunction - " FUNCTION: Path.Resolve() {{{1 " Invoke the vim resolve() function and return the result " This is necessary because in some versions of vim resolve() removes trailing @@ -802,7 +754,7 @@ function! s:Path._strForEdit() " On Windows, the drive letter may be removed by "fnamemodify()". Add it " back, if necessary. - if nerdtree#runningWindows() && l:result[0] ==# s:Path.Slash() + if nerdtree#runningWindows() && l:result[0] == nerdtree#slash() let l:result = self.drive . l:result endif @@ -817,14 +769,14 @@ endfunction " FUNCTION: Path._strForGlob() {{{1 function! s:Path._strForGlob() - let lead = s:Path.Slash() + let lead = nerdtree#slash() "if we are running windows then slap a drive letter on the front if nerdtree#runningWindows() let lead = self.drive . '\' endif - let toReturn = lead . join(self.pathSegments, s:Path.Slash()) + let toReturn = lead . join(self.pathSegments, nerdtree#slash()) if !nerdtree#runningWindows() let toReturn = escape(toReturn, self._escChars()) @@ -836,7 +788,7 @@ endfunction " Return the absolute pathname associated with this Path object. The pathname " returned is appropriate for the underlying file system. function! s:Path._str() - let l:separator = s:Path.Slash() + let l:separator = nerdtree#slash() let l:leader = l:separator if nerdtree#runningWindows() diff --git a/sources_non_forked/nerdtree/lib/nerdtree/tree_dir_node.vim b/sources_non_forked/nerdtree/lib/nerdtree/tree_dir_node.vim index 4fb802fa..b0b5a90a 100644 --- a/sources_non_forked/nerdtree/lib/nerdtree/tree_dir_node.vim +++ b/sources_non_forked/nerdtree/lib/nerdtree/tree_dir_node.vim @@ -104,16 +104,11 @@ function! s:TreeDirNode.displayString() endfor " Select the appropriate open/closed status indicator symbol. - if l:cascade[-1].isOpen - let l:symbol = g:NERDTreeDirArrowCollapsible - else - let l:symbol = g:NERDTreeDirArrowExpandable - endif - + let l:symbol = (l:cascade[-1].isOpen ? g:NERDTreeDirArrowCollapsible : g:NERDTreeDirArrowExpandable ) + let l:symbol .= (g:NERDTreeDirArrowExpandable ==# '' ? '' : ' ') let l:flags = l:cascade[-1].path.flagSet.renderToString() - let l:result = l:symbol . ' ' . l:flags . l:label - return l:result + return l:symbol . l:flags . l:label endfunction " FUNCTION: TreeDirNode.findNode(path) {{{1 @@ -241,7 +236,7 @@ function! s:TreeDirNode.getChildIndex(path) let z = self.getChildCount() while a < z let mid = (a+z)/2 - let diff = a:path.compareTo(self.children[mid].path) + let diff = nerdtree#compareNodePaths(a:path, self.children[mid].path) if diff ==# -1 let z = mid @@ -283,8 +278,8 @@ function! s:TreeDirNode._glob(pattern, all) else let l:pathSpec = escape(fnamemodify(self.path.str({'format': 'Glob'}), ':.'), ',') - " On Windows, the drive letter may be removed by fnamemodify(). - if nerdtree#runningWindows() && l:pathSpec[0] ==# g:NERDTreePath.Slash() + " On Windows, the drive letter may be removed by "fnamemodify()". + if nerdtree#runningWindows() && l:pathSpec[0] == nerdtree#slash() let l:pathSpec = self.path.drive . l:pathSpec endif endif @@ -382,11 +377,17 @@ endfunction " 1. If cascaded, we don't know which dir is bookmarked or is a symlink. " 2. If the parent is a symlink or is bookmarked, you end up with unparsable " text, and NERDTree cannot get the path of any child node. +" Also, return false if this directory is the tree root, which should never be +" part of a cascade. function! s:TreeDirNode.isCascadable() if g:NERDTreeCascadeSingleChildDir ==# 0 return 0 endif + if self.isRoot() + return 0 + endif + if self.path.isSymLink return 0 endif @@ -430,6 +431,7 @@ function! s:TreeDirNode._initChildren(silent) endtry endfor + let g:NERDTreeOldSortOrder = g:NERDTreeSortOrder call self.sortChildren() call nerdtree#echo('') @@ -672,7 +674,7 @@ function! s:TreeDirNode.sortChildren() if count(g:NERDTreeSortOrder, '*') < 1 call add(g:NERDTreeSortOrder, '*') endif - let CompareFunc = function('nerdtree#compareNodesBySortKey') + let CompareFunc = function('nerdtree#compareNodes') call sort(self.children, CompareFunc) let g:NERDTreeOldSortOrder = g:NERDTreeSortOrder endfunction diff --git a/sources_non_forked/nerdtree/lib/nerdtree/tree_file_node.vim b/sources_non_forked/nerdtree/lib/nerdtree/tree_file_node.vim index 34074a25..957b98ac 100644 --- a/sources_non_forked/nerdtree/lib/nerdtree/tree_file_node.vim +++ b/sources_non_forked/nerdtree/lib/nerdtree/tree_file_node.vim @@ -321,13 +321,9 @@ function! s:TreeFileNode._renderToString(depth, drawText) if a:drawText ==# 1 let treeParts = repeat(' ', a:depth - 1) - - if !self.path.isDirectory - let treeParts = treeParts . ' ' - endif + let treeParts .= (self.path.isDirectory || g:NERDTreeDirArrowExpandable ==# '' ? '' : ' ') let line = treeParts . self.displayString() - let output = output . line . "\n" endif diff --git a/sources_non_forked/nerdtree/lib/nerdtree/ui.vim b/sources_non_forked/nerdtree/lib/nerdtree/ui.vim index f989aac8..a339530a 100644 --- a/sources_non_forked/nerdtree/lib/nerdtree/ui.vim +++ b/sources_non_forked/nerdtree/lib/nerdtree/ui.vim @@ -99,6 +99,10 @@ function! s:UI._dumpHelp() let help .= '" '. g:NERDTreeMapPreview .": find dir in tree\n" let help .= '" '. g:NERDTreeMapOpenInTab.": open in new tab\n" let help .= '" '. g:NERDTreeMapOpenInTabSilent .": open in new tab silently\n" + let help .= '" '. g:NERDTreeMapOpenSplit .": open split\n" + let help .= '" '. g:NERDTreeMapPreviewSplit .": preview split\n" + let help .= '" '. g:NERDTreeMapOpenVSplit .": open vsplit\n" + let help .= '" '. g:NERDTreeMapPreviewVSplit .": preview vsplit\n" let help .= '" '. g:NERDTreeMapCustomOpen .": custom open\n" let help .= '" '. g:NERDTreeMapDeleteBookmark .": delete bookmark\n" >>>>>>> 27ad0d07862847896f691309a544a206783c94d6 @@ -317,7 +321,11 @@ endfunction function! s:UI._indentLevelFor(line) " Replace multi-character DirArrows with a single space so the " indentation calculation doesn't get messed up. - let l:line = substitute(substitute(a:line, '\V'.g:NERDTreeDirArrowExpandable, ' ', ''), '\V'.g:NERDTreeDirArrowCollapsible, ' ', '') + if g:NERDTreeDirArrowExpandable ==# '' + let l:line = ' '.a:line + else + let l:line = substitute(substitute(a:line, '\V'.g:NERDTreeDirArrowExpandable, ' ', ''), '\V'.g:NERDTreeDirArrowCollapsible, ' ', '') + endif let leadChars = match(l:line, '\M\[^ ]') return leadChars / s:UI.IndentWid() endfunction @@ -393,7 +401,7 @@ function! s:UI.saveScreenState() call g:NERDTree.CursorToTreeWin() let self._screenState['oldPos'] = getpos('.') let self._screenState['oldTopLine'] = line('w0') - let self._screenState['oldWindowSize']= winwidth('') + let self._screenState['oldWindowSize'] = winnr('$')==1 ? g:NERDTreeWinSize : winwidth('') call nerdtree#exec(win . 'wincmd w', 1) catch endtry @@ -541,8 +549,7 @@ endfunction " zoom (maximize/minimize) the NERDTree window function! s:UI.toggleZoom() if exists('b:NERDTreeZoomed') && b:NERDTreeZoomed - let size = exists('b:NERDTreeOldWindowSize') ? b:NERDTreeOldWindowSize : g:NERDTreeWinSize - call nerdtree#exec('silent vertical resize '. size, 1) + call nerdtree#exec('silent vertical resize '. g:NERDTreeWinSize, 1) let b:NERDTreeZoomed = 0 else call nerdtree#exec('vertical resize '. get(g:, 'NERDTreeWinSizeMax', ''), 1) diff --git a/sources_non_forked/nerdtree/nerdtree_plugin/fs_menu.vim b/sources_non_forked/nerdtree/nerdtree_plugin/fs_menu.vim index 0ab1cd90..a836120b 100644 --- a/sources_non_forked/nerdtree/nerdtree_plugin/fs_menu.vim +++ b/sources_non_forked/nerdtree/nerdtree_plugin/fs_menu.vim @@ -34,6 +34,10 @@ if executable('xdg-open') call NERDTreeAddMenuItem({'text': '(o)pen the current node with system editor', 'shortcut': 'o', 'callback': 'NERDTreeExecuteFileLinux'}) endif +if nerdtree#runningWindows() + call NERDTreeAddMenuItem({'text': '(o)pen the current node with system editor', 'shortcut': 'o', 'callback': 'NERDTreeExecuteFileWindows'}) +endif + if g:NERDTreePath.CopyingSupported() call NERDTreeAddMenuItem({'text': '(c)opy the current node', 'shortcut': 'c', 'callback': 'NERDTreeCopyNode'}) endif @@ -165,7 +169,7 @@ endfunction function! NERDTreeAddNode() let curDirNode = g:NERDTreeDirNode.GetSelected() let prompt = s:inputPrompt('add') - let newNodeName = input(prompt, curDirNode.path.str() . g:NERDTreePath.Slash(), 'file') + let newNodeName = input(prompt, curDirNode.path.str() . nerdtree#slash(), 'file') if newNodeName ==# '' call nerdtree#echo('Node Creation Aborted.') @@ -213,7 +217,8 @@ function! NERDTreeMoveNode() try if curNode.path.isDirectory - let l:openBuffers = filter(range(1,bufnr('$')),'bufexists(v:val) && fnamemodify(bufname(v:val),":p") =~# curNode.path.str() . "/.*"') + let l:curPath = escape(curNode.path.str(),'\') . (nerdtree#runningWindows()?'\\':'/') . '.*' + let l:openBuffers = filter(range(1,bufnr('$')),'bufexists(v:val) && fnamemodify(bufname(v:val),":p") =~# "'.escape(l:curPath,'\').'"') else let l:openBuffers = filter(range(1,bufnr('$')),'bufexists(v:val) && fnamemodify(bufname(v:val),":p") ==# curNode.path.str()') endif @@ -251,8 +256,6 @@ endfunction " FUNCTION: NERDTreeDeleteNode() {{{1 function! NERDTreeDeleteNode() - let l:shellslash = &shellslash - let &shellslash = 0 let currentNode = g:NERDTreeFileNode.GetSelected() let confirmed = 0 @@ -288,7 +291,6 @@ function! NERDTreeDeleteNode() else call nerdtree#echo('delete aborted') endif - let &shellslash = l:shellslash endfunction " FUNCTION: NERDTreeListNode() {{{1 @@ -333,8 +335,6 @@ endfunction " FUNCTION: NERDTreeCopyNode() {{{1 function! NERDTreeCopyNode() - let l:shellslash = &shellslash - let &shellslash = 0 let currentNode = g:NERDTreeFileNode.GetSelected() let prompt = s:inputPrompt('copy') let newNodePath = input(prompt, currentNode.path.str(), 'file') @@ -370,7 +370,6 @@ function! NERDTreeCopyNode() else call nerdtree#echo('Copy aborted.') endif - let &shellslash = l:shellslash redraw! endfunction @@ -399,44 +398,78 @@ endfunction " FUNCTION: NERDTreeQuickLook() {{{1 function! NERDTreeQuickLook() - let treenode = g:NERDTreeFileNode.GetSelected() - if treenode !=# {} - call system("qlmanage -p 2>/dev/null '" . treenode.path.str() . "'") + let l:node = g:NERDTreeFileNode.GetSelected() + + if empty(l:node) + return endif + + call system('qlmanage -p 2>/dev/null ' . shellescape(l:node.path.str())) endfunction " FUNCTION: NERDTreeRevealInFinder() {{{1 function! NERDTreeRevealInFinder() - let treenode = g:NERDTreeFileNode.GetSelected() - if treenode !=# {} - call system("open -R '" . treenode.path.str() . "'") + let l:node = g:NERDTreeFileNode.GetSelected() + + if empty(l:node) + return endif + + call system('open -R ' . shellescape(l:node.path.str())) endfunction " FUNCTION: NERDTreeExecuteFile() {{{1 function! NERDTreeExecuteFile() - let treenode = g:NERDTreeFileNode.GetSelected() - if treenode !=# {} - call system("open '" . treenode.path.str() . "'") + let l:node = g:NERDTreeFileNode.GetSelected() + + if empty(l:node) + return endif + + call system('open ' . shellescape(l:node.path.str())) endfunction " FUNCTION: NERDTreeRevealFileLinux() {{{1 function! NERDTreeRevealFileLinux() - let treenode = g:NERDTreeFileNode.GetSelected() - let parentnode = treenode.parent - if parentnode !=# {} - call system("xdg-open '" . parentnode.path.str() . "' &") + let l:node = g:NERDTreeFileNode.GetSelected() + + if empty(l:node) + return endif + + " Handle the edge case of "/", which has no parent. + if l:node.path.str() ==# '/' + call system('xdg-open /') + return + endif + + if empty(l:node.parent) + return + endif + + call system('xdg-open ' . shellescape(l:node.parent.path.str())) endfunction " FUNCTION: NERDTreeExecuteFileLinux() {{{1 function! NERDTreeExecuteFileLinux() - let treenode = g:NERDTreeFileNode.GetSelected() - if treenode !=# {} - call system("xdg-open '" . treenode.path.str() . "' &") + let l:node = g:NERDTreeFileNode.GetSelected() + + if empty(l:node) + return endif + + call system('xdg-open ' . shellescape(l:node.path.str())) +endfunction + +" FUNCTION: NERDTreeExecuteFileWindows() {{{1 +function! NERDTreeExecuteFileWindows() + let l:node = g:NERDTreeFileNode.GetSelected() + + if empty(l:node) + return + endif + + call system('cmd.exe /c start "" ' . shellescape(l:node.path.str())) endfunction " vim: set sw=4 sts=4 et fdm=marker: - diff --git a/sources_non_forked/nerdtree/nerdtree_plugin/vcs.vim b/sources_non_forked/nerdtree/nerdtree_plugin/vcs.vim index 36d5427e..d20e35e5 100644 --- a/sources_non_forked/nerdtree/nerdtree_plugin/vcs.vim +++ b/sources_non_forked/nerdtree/nerdtree_plugin/vcs.vim @@ -34,7 +34,7 @@ endfunction function! s:FindParentVCSRoot(path) let l:path = a:path while !empty(l:path) && - \ l:path._str() !~# '^\(\a:\\\|\/\)$' && + \ l:path._str() !~# '^\(\a:[\\\/]\|\/\)$' && \ !isdirectory(l:path._str() . '/.git') && \ !isdirectory(l:path._str() . '/.svn') && \ !isdirectory(l:path._str() . '/.hg') && @@ -42,6 +42,6 @@ function! s:FindParentVCSRoot(path) \ !isdirectory(l:path._str() . '/_darcs') let l:path = l:path.getParent() endwhile - return (empty(l:path) || l:path._str() =~# '^\(\a:\\\|\/\)$') ? a:path : l:path + return (empty(l:path) || l:path._str() =~# '^\(\a:[\\\/]\|\/\)$') ? a:path : l:path endfunction diff --git a/sources_non_forked/nerdtree/plugin/NERD_tree.vim b/sources_non_forked/nerdtree/plugin/NERD_tree.vim index 651587d3..10f30386 100644 --- a/sources_non_forked/nerdtree/plugin/NERD_tree.vim +++ b/sources_non_forked/nerdtree/plugin/NERD_tree.vim @@ -26,105 +26,79 @@ let loaded_nerd_tree = 1 let s:old_cpo = &cpoptions set cpoptions&vim -"Function: s:initVariable() function {{{2 -"This function is used to initialise a given variable to a given value. The -"variable is only initialised if it does not exist prior -" -"Args: -"var: the name of the var to be initialised -"value: the value to initialise var to -" -"Returns: -"1 if the var is set, 0 otherwise -function! s:initVariable(var, value) - if !exists(a:var) - exec 'let ' . a:var . ' = ' . "'" . substitute(a:value, "'", "''", 'g') . "'" - return 1 - endif - return 0 -endfunction - -"SECTION: Init variable calls and other random constants {{{2 -call s:initVariable('g:NERDTreeAutoCenter', 1) -call s:initVariable('g:NERDTreeAutoCenterThreshold', 3) -call s:initVariable('g:NERDTreeCaseSensitiveSort', 0) -call s:initVariable('g:NERDTreeNaturalSort', 0) -call s:initVariable('g:NERDTreeSortHiddenFirst', 1) -call s:initVariable('g:NERDTreeUseTCD', 0) -call s:initVariable('g:NERDTreeChDirMode', 0) -call s:initVariable('g:NERDTreeCreatePrefix', 'silent') -call s:initVariable('g:NERDTreeMinimalUI', 0) -call s:initVariable('g:NERDTreeMinimalMenu', 0) -if !exists('g:NERDTreeIgnore') - let g:NERDTreeIgnore = ['\~$'] -endif -call s:initVariable('g:NERDTreeBookmarksFile', expand('$HOME') . '/.NERDTreeBookmarks') -call s:initVariable('g:NERDTreeBookmarksSort', 1) -call s:initVariable('g:NERDTreeHighlightCursorline', 1) -call s:initVariable('g:NERDTreeHijackNetrw', 1) -call s:initVariable('g:NERDTreeMarkBookmarks', 1) -call s:initVariable('g:NERDTreeMouseMode', 1) -call s:initVariable('g:NERDTreeNotificationThreshold', 100) -call s:initVariable('g:NERDTreeQuitOnOpen', 0) -call s:initVariable('g:NERDTreeRespectWildIgnore', 0) -call s:initVariable('g:NERDTreeShowBookmarks', 0) -call s:initVariable('g:NERDTreeShowFiles', 1) -call s:initVariable('g:NERDTreeShowHidden', 0) -call s:initVariable('g:NERDTreeShowLineNumbers', 0) -call s:initVariable('g:NERDTreeSortDirs', 1) +"SECTION: Initialize variable calls and other random constants {{{2 +let g:NERDTreeAutoCenter = get(g:, 'NERDTreeAutoCenter', 1) +let g:NERDTreeAutoCenterThreshold = get(g:, 'NERDTreeAutoCenterThreshold', 3) +let g:NERDTreeCaseSensitiveSort = get(g:, 'NERDTreeCaseSensitiveSort', 0) +let g:NERDTreeNaturalSort = get(g:, 'NERDTreeNaturalSort', 0) +let g:NERDTreeSortHiddenFirst = get(g:, 'NERDTreeSortHiddenFirst', 1) +let g:NERDTreeUseTCD = get(g:, 'NERDTreeUseTCD', 0) +let g:NERDTreeChDirMode = get(g:, 'NERDTreeChDirMode', 0) +let g:NERDTreeCreatePrefix = get(g:, 'NERDTreeCreatePrefix', 'silent') +let g:NERDTreeMinimalUI = get(g:, 'NERDTreeMinimalUI', 0) +let g:NERDTreeMinimalMenu = get(g:, 'NERDTreeMinimalMenu', 0) +let g:NERDTreeIgnore = get(g:, 'NERDTreeIgnore', ['\~$']) +let g:NERDTreeBookmarksFile = get(g:, 'NERDTreeBookmarksFile', expand('$HOME') . '/.NERDTreeBookmarks') +let g:NERDTreeBookmarksSort = get(g:, 'NERDTreeBookmarksSort', 1) +let g:NERDTreeHighlightCursorline = get(g:, 'NERDTreeHighlightCursorline', 1) +let g:NERDTreeHijackNetrw = get(g:, 'NERDTreeHijackNetrw', 1) +let g:NERDTreeMarkBookmarks = get(g:, 'NERDTreeMarkBookmarks', 1) +let g:NERDTreeMouseMode = get(g:, 'NERDTreeMouseMode', 1) +let g:NERDTreeNotificationThreshold = get(g:, 'NERDTreeNotificationThreshold', 100) +let g:NERDTreeQuitOnOpen = get(g:, 'NERDTreeQuitOnOpen', 0) +let g:NERDTreeRespectWildIgnore = get(g:, 'NERDTreeRespectWildIgnore', 0) +let g:NERDTreeShowBookmarks = get(g:, 'NERDTreeShowBookmarks', 0) +let g:NERDTreeShowFiles = get(g:, 'NERDTreeShowFiles', 1) +let g:NERDTreeShowHidden = get(g:, 'NERDTreeShowHidden', 0) +let g:NERDTreeShowLineNumbers = get(g:, 'NERDTreeShowLineNumbers', 0) +let g:NERDTreeSortDirs = get(g:, 'NERDTreeSortDirs', 1) if !nerdtree#runningWindows() && !nerdtree#runningCygwin() - call s:initVariable('g:NERDTreeDirArrowExpandable', '▸') - call s:initVariable('g:NERDTreeDirArrowCollapsible', '▾') + let g:NERDTreeDirArrowExpandable = get(g:, 'NERDTreeDirArrowExpandable', '▸') + let g:NERDTreeDirArrowCollapsible = get(g:, 'NERDTreeDirArrowCollapsible', '▾') else - call s:initVariable('g:NERDTreeDirArrowExpandable', '+') - call s:initVariable('g:NERDTreeDirArrowCollapsible', '~') + let g:NERDTreeDirArrowExpandable = get(g:, 'NERDTreeDirArrowExpandable', '+') + let g:NERDTreeDirArrowCollapsible = get(g:, 'NERDTreeDirArrowCollapsible', '~') endif -call s:initVariable('g:NERDTreeCascadeOpenSingleChildDir', 1) -call s:initVariable('g:NERDTreeCascadeSingleChildDir', 1) +let g:NERDTreeCascadeOpenSingleChildDir = get(g:, 'NERDTreeCascadeOpenSingleChildDir', 1) +let g:NERDTreeCascadeSingleChildDir = get(g:, 'NERDTreeCascadeSingleChildDir', 1) -if !exists('g:NERDTreeSortOrder') - let g:NERDTreeSortOrder = ['\/$', '*', '\.swp$', '\.bak$', '\~$'] -endif +let g:NERDTreeSortOrder = get(g:, 'NERDTreeSortOrder', ['\/$', '*', '\.swp$', '\.bak$', '\~$']) let g:NERDTreeOldSortOrder = [] -call s:initVariable('g:NERDTreeGlyphReadOnly', 'RO') +let g:NERDTreeGlyphReadOnly = get(g:, 'NERDTreeGlyphReadOnly', 'RO') if has('conceal') - call s:initVariable('g:NERDTreeNodeDelimiter', "\x07") + let g:NERDTreeNodeDelimiter = get(g:, 'NERDTreeNodeDelimiter', "\x07") elseif (g:NERDTreeDirArrowExpandable ==# "\u00a0" || g:NERDTreeDirArrowCollapsible ==# "\u00a0") - call s:initVariable('g:NERDTreeNodeDelimiter', "\u00b7") + let g:NERDTreeNodeDelimiter = get(g:, 'NERDTreeNodeDelimiter', "\u00b7") else - call s:initVariable('g:NERDTreeNodeDelimiter', "\u00a0") + let g:NERDTreeNodeDelimiter = get(g:, 'NERDTreeNodeDelimiter', "\u00a0") endif -if !exists('g:NERDTreeStatusline') +"the exists() crap here is a hack to stop vim spazzing out when +"loading a session that was created with an open nerd tree. It spazzes +"because it doesnt store b:NERDTree(its a b: var, and its a hash) +let g:NERDTreeStatusline = get(g:, 'NERDTreeStatusline', "%{exists('b:NERDTree')?b:NERDTree.root.path.str():''}") - "the exists() crap here is a hack to stop vim spazzing out when - "loading a session that was created with an open nerd tree. It spazzes - "because it doesnt store b:NERDTree(its a b: var, and its a hash) - let g:NERDTreeStatusline = "%{exists('b:NERDTree')?b:NERDTree.root.path.str():''}" - -endif -call s:initVariable('g:NERDTreeWinPos', 'left') -call s:initVariable('g:NERDTreeWinSize', 31) +let g:NERDTreeWinPos = get(g:, 'NERDTreeWinPos', 'left') +let g:NERDTreeWinSize = get(g:, 'NERDTreeWinSize', 31) "init the shell commands that will be used to copy nodes, and remove dir trees -" "Note: the space after the command is important if nerdtree#runningWindows() - call s:initVariable('g:NERDTreeRemoveDirCmd', 'rmdir /s /q ') - call s:initVariable('g:NERDTreeCopyDirCmd', 'xcopy /s /e /i /y /q ') - call s:initVariable('g:NERDTreeCopyFileCmd', 'copy /y ') + let g:NERDTreeRemoveDirCmd = get(g:, 'NERDTreeRemoveDirCmd', 'rmdir /s /q ') + let g:NERDTreeCopyDirCmd = get(g:, 'NERDTreeCopyDirCmd', 'xcopy /s /e /i /y /q ') + let g:NERDTreeCopyFileCmd = get(g:, 'NERDTreeCopyFileCmd', 'copy /y ') else - call s:initVariable('g:NERDTreeRemoveDirCmd', 'rm -rf ') - call s:initVariable('g:NERDTreeCopyCmd', 'cp -r ') + let g:NERDTreeRemoveDirCmd = get(g:, 'NERDTreeRemoveDirCmd', 'rm -rf ') + let g:NERDTreeCopyCmd = get(g:, 'NERDTreeCopyCmd', 'cp -r ') endif - "SECTION: Init variable calls for key mappings {{{2 <<<<<<< HEAD +<<<<<<< HEAD call s:initVariable("g:NERDTreeMapCustomOpen", "") call s:initVariable("g:NERDTreeMapActivateNode", "o") call s:initVariable("g:NERDTreeMapChangeRoot", "C") @@ -201,6 +175,45 @@ call s:initVariable('g:NERDTreeMapCWD', 'CD') call s:initVariable('g:NERDTreeMenuDown', 'j') call s:initVariable('g:NERDTreeMenuUp', 'k') >>>>>>> 27ad0d07862847896f691309a544a206783c94d6 +======= +let g:NERDTreeMapCustomOpen = get(g:, 'NERDTreeMapCustomOpen', '') +let g:NERDTreeMapActivateNode = get(g:, 'NERDTreeMapActivateNode', 'o') +let g:NERDTreeMapChangeRoot = get(g:, 'NERDTreeMapChangeRoot', 'C') +let g:NERDTreeMapChdir = get(g:, 'NERDTreeMapChdir', 'cd') +let g:NERDTreeMapCloseChildren = get(g:, 'NERDTreeMapCloseChildren', 'X') +let g:NERDTreeMapCloseDir = get(g:, 'NERDTreeMapCloseDir', 'x') +let g:NERDTreeMapDeleteBookmark = get(g:, 'NERDTreeMapDeleteBookmark', 'D') +let g:NERDTreeMapMenu = get(g:, 'NERDTreeMapMenu', 'm') +let g:NERDTreeMapHelp = get(g:, 'NERDTreeMapHelp', '?') +let g:NERDTreeMapJumpFirstChild = get(g:, 'NERDTreeMapJumpFirstChild', 'K') +let g:NERDTreeMapJumpLastChild = get(g:, 'NERDTreeMapJumpLastChild', 'J') +let g:NERDTreeMapJumpNextSibling = get(g:, 'NERDTreeMapJumpNextSibling', '') +let g:NERDTreeMapJumpParent = get(g:, 'NERDTreeMapJumpParent', 'p') +let g:NERDTreeMapJumpPrevSibling = get(g:, 'NERDTreeMapJumpPrevSibling', '') +let g:NERDTreeMapJumpRoot = get(g:, 'NERDTreeMapJumpRoot', 'P') +let g:NERDTreeMapOpenExpl = get(g:, 'NERDTreeMapOpenExpl', 'e') +let g:NERDTreeMapOpenInTab = get(g:, 'NERDTreeMapOpenInTab', 't') +let g:NERDTreeMapOpenInTabSilent = get(g:, 'NERDTreeMapOpenInTabSilent', 'T') +let g:NERDTreeMapOpenRecursively = get(g:, 'NERDTreeMapOpenRecursively', 'O') +let g:NERDTreeMapOpenSplit = get(g:, 'NERDTreeMapOpenSplit', 'i') +let g:NERDTreeMapOpenVSplit = get(g:, 'NERDTreeMapOpenVSplit', 's') +let g:NERDTreeMapPreview = get(g:, 'NERDTreeMapPreview', 'g'.NERDTreeMapActivateNode) +let g:NERDTreeMapPreviewSplit = get(g:, 'NERDTreeMapPreviewSplit', 'g'.NERDTreeMapOpenSplit) +let g:NERDTreeMapPreviewVSplit = get(g:, 'NERDTreeMapPreviewVSplit', 'g'.NERDTreeMapOpenVSplit) +let g:NERDTreeMapQuit = get(g:, 'NERDTreeMapQuit', 'q') +let g:NERDTreeMapRefresh = get(g:, 'NERDTreeMapRefresh', 'r') +let g:NERDTreeMapRefreshRoot = get(g:, 'NERDTreeMapRefreshRoot', 'R') +let g:NERDTreeMapToggleBookmarks = get(g:, 'NERDTreeMapToggleBookmarks', 'B') +let g:NERDTreeMapToggleFiles = get(g:, 'NERDTreeMapToggleFiles', 'F') +let g:NERDTreeMapToggleFilters = get(g:, 'NERDTreeMapToggleFilters', 'f') +let g:NERDTreeMapToggleHidden = get(g:, 'NERDTreeMapToggleHidden', 'I') +let g:NERDTreeMapToggleZoom = get(g:, 'NERDTreeMapToggleZoom', 'A') +let g:NERDTreeMapUpdir = get(g:, 'NERDTreeMapUpdir', 'u') +let g:NERDTreeMapUpdirKeepOpen = get(g:, 'NERDTreeMapUpdirKeepOpen', 'U') +let g:NERDTreeMapCWD = get(g:, 'NERDTreeMapCWD', 'CD') +let g:NERDTreeMenuDown = get(g:, 'NERDTreeMenuDown', 'j') +let g:NERDTreeMenuUp = get(g:, 'NERDTreeMenuUp', 'k') +>>>>>>> master "SECTION: Load class files{{{2 call nerdtree#loadClassFiles() @@ -257,7 +270,7 @@ endfunction function! NERDTreeFocus() if g:NERDTree.IsOpen() - call g:NERDTree.CursorToTreeWin() + call g:NERDTree.CursorToTreeWin(0) else call g:NERDTreeCreator.ToggleTabTree('') endif diff --git a/sources_non_forked/nerdtree/syntax/nerdtree.vim b/sources_non_forked/nerdtree/syntax/nerdtree.vim index 0df9d12e..bf523d15 100644 --- a/sources_non_forked/nerdtree/syntax/nerdtree.vim +++ b/sources_non_forked/nerdtree/syntax/nerdtree.vim @@ -19,32 +19,36 @@ syn match NERDTreeLinkTarget #->.*# containedin=NERDTreeDir,NERDTreeFile syn match NERDTreeLinkFile #.* ->#me=e-3 containedin=NERDTreeFile syn match NERDTreeLinkDir #.*/ ->#me=e-3 containedin=NERDTreeDir -"highlighing for directory nodes and file nodes -syn match NERDTreeDirSlash #/# containedin=NERDTreeDir - -exec 'syn match NERDTreeClosable #' . escape(g:NERDTreeDirArrowCollapsible, '~') . '\ze .*/# containedin=NERDTreeDir,NERDTreeFile' -exec 'syn match NERDTreeOpenable #' . escape(g:NERDTreeDirArrowExpandable, '~') . '\ze .*/# containedin=NERDTreeDir,NERDTreeFile' - -let s:dirArrows = escape(g:NERDTreeDirArrowCollapsible, '~]\-').escape(g:NERDTreeDirArrowExpandable, '~]\-') -exec 'syn match NERDTreeDir #[^'.s:dirArrows.' ].*/#' -syn match NERDTreeExecFile '^ .*\*\($\| \)' contains=NERDTreeRO,NERDTreeBookmark -exec 'syn match NERDTreeFile #^[^"\.'.s:dirArrows.'] *[^'.s:dirArrows.']*# contains=NERDTreeLink,NERDTreeRO,NERDTreeBookmark,NERDTreeExecFile' - -"highlighting for readonly files -exec 'syn match NERDTreeRO # *\zs.*\ze \['.g:NERDTreeGlyphReadOnly.'\]# contains=NERDTreeIgnore,NERDTreeBookmark,NERDTreeFile' - -syn match NERDTreeFlags #^ *\zs\[[^\]]*\]# containedin=NERDTreeFile,NERDTreeExecFile -syn match NERDTreeFlags #\[[^\]]*\]# containedin=NERDTreeDir - -"highlighing to conceal the delimiter around the file/dir name +"highlighting to conceal the delimiter around the file/dir name if has('conceal') exec 'syn match NERDTreeNodeDelimiters #\%d' . char2nr(g:NERDTreeNodeDelimiter) . '# conceal containedin=ALL' - setlocal conceallevel=3 concealcursor=nvic + setlocal conceallevel=2 concealcursor=nvic else exec 'syn match NERDTreeNodeDelimiters #\%d' . char2nr(g:NERDTreeNodeDelimiter) . '# containedin=ALL' hi! link NERDTreeNodeDelimiters Ignore endif +"highlighing for directory nodes and file nodes +syn match NERDTreeDirSlash #/# containedin=NERDTreeDir + +if g:NERDTreeDirArrowExpandable !=# '' + exec 'syn match NERDTreeClosable #' . escape(g:NERDTreeDirArrowCollapsible, '~') . '\ze .*/# containedin=NERDTreeDir,NERDTreeFile' + exec 'syn match NERDTreeOpenable #' . escape(g:NERDTreeDirArrowExpandable, '~') . '\ze .*/# containedin=NERDTreeDir,NERDTreeFile' + let s:dirArrows = escape(g:NERDTreeDirArrowCollapsible, '~]\-').escape(g:NERDTreeDirArrowExpandable, '~]\-') + exec 'syn match NERDTreeDir #[^'.s:dirArrows.' ].*/#' + exec 'syn match NERDTreeExecFile #^.*'.g:NERDTreeNodeDelimiter.'\*\($\| \)# contains=NERDTreeRO,NERDTreeBookmark' + exec 'syn match NERDTreeFile #^[^"\.'.s:dirArrows.'] *[^'.s:dirArrows.']*# contains=NERDTreeLink,NERDTreeRO,NERDTreeBookmark,NERDTreeExecFile' +else + exec 'syn match NERDTreeDir #[^'.g:NERDTreeNodeDelimiter.']\{-}/\ze\($\|'.g:NERDTreeNodeDelimiter.'\)#' + exec 'syn match NERDTreeExecFile #[^'.g:NERDTreeNodeDelimiter.']\{-}'.g:NERDTreeNodeDelimiter.'\*\($\| \)# contains=NERDTreeRO,NERDTreeBookmark' + exec 'syn match NERDTreeFile #^.*'.g:NERDTreeNodeDelimiter.'.*[^\/]\($\|'.g:NERDTreeNodeDelimiter.'.*\)# contains=NERDTreeLink,NERDTreeRO,NERDTreeBookmark,NERDTreeExecFile' +endif + +"highlighting for readonly files +exec 'syn match NERDTreeRO #.*'.g:NERDTreeNodeDelimiter.'\zs.*\ze'.g:NERDTreeNodeDelimiter.'.*\['.g:NERDTreeGlyphReadOnly.'\]# contains=NERDTreeIgnore,NERDTreeBookmark,NERDTreeFile' + +exec 'syn match NERDTreeFlags #\[[^\]]*\]\ze'.g:NERDTreeNodeDelimiter.'# containedin=NERDTreeFile,NERDTreeExecFile,NERDTreeLinkFile,NERDTreeRO,NERDTreeDir' + syn match NERDTreeCWD #^[(MatchitNormalForward)') ==# '' + keepjumps normal! % + else + " Prefer matchit.vim official plugin to native % since the plugin + " provides better behavior than original % (#391) + " To load the plugin, run: + " :packadd matchit + execute 'keepjumps' 'normal' "\(MatchitNormalForward)" + endif if line('.') < cursor_line return '' endif @@ -541,21 +549,20 @@ function! rust#Test(mods, winsize, all, options) abort let saved = getpos('.') try let func_name = s:SearchTestFunctionNameUnderCursor() - if func_name ==# '' - echohl ErrorMsg - echomsg 'No test function was found under the cursor. Please add ! to command if you want to run all tests' - echohl None - return - endif - if a:options ==# '' - execute cmd . 'cargo test --manifest-path' manifest func_name - else - execute cmd . 'cargo test --manifest-path' manifest func_name a:options - endif - return finally call setpos('.', saved) endtry + if func_name ==# '' + echohl ErrorMsg + echomsg 'No test function was found under the cursor. Please add ! to command if you want to run all tests' + echohl None + return + endif + if a:options ==# '' + execute cmd . 'cargo test --manifest-path' manifest func_name + else + execute cmd . 'cargo test --manifest-path' manifest func_name a:options + endif endfunction " }}}1 diff --git a/sources_non_forked/rust.vim/autoload/rustfmt.vim b/sources_non_forked/rust.vim/autoload/rustfmt.vim index 4a5f86cc..59a58e84 100644 --- a/sources_non_forked/rust.vim/autoload/rustfmt.vim +++ b/sources_non_forked/rust.vim/autoload/rustfmt.vim @@ -63,12 +63,12 @@ endfunction function! s:RustfmtConfigOptions() let l:rustfmt_toml = findfile('rustfmt.toml', expand('%:p:h') . ';') if l:rustfmt_toml !=# '' - return '--config-path '.fnamemodify(l:rustfmt_toml, ":p") + return '--config-path '.shellescape(fnamemodify(l:rustfmt_toml, ":p")) endif let l:_rustfmt_toml = findfile('.rustfmt.toml', expand('%:p:h') . ';') if l:_rustfmt_toml !=# '' - return '--config-path '.fnamemodify(l:_rustfmt_toml, ":p") + return '--config-path '.shellescape(fnamemodify(l:_rustfmt_toml, ":p")) endif " Default to edition 2018 in case no rustfmt.toml was found. @@ -107,7 +107,7 @@ function! s:DeleteLines(start, end) abort endfunction function! s:RunRustfmt(command, tmpname, from_writepre) - mkview! + let l:view = winsaveview() let l:stderr_tmpname = tempname() call writefile([], l:stderr_tmpname) @@ -213,7 +213,7 @@ function! s:RunRustfmt(command, tmpname, from_writepre) lwindow endif - silent! loadview + call winrestview(l:view) endfunction function! rustfmt#FormatRange(line1, line2) diff --git a/sources_non_forked/rust.vim/compiler/rustc.vim b/sources_non_forked/rust.vim/compiler/rustc.vim index c8e77005..9b70732a 100644 --- a/sources_non_forked/rust.vim/compiler/rustc.vim +++ b/sources_non_forked/rust.vim/compiler/rustc.vim @@ -24,7 +24,7 @@ else if has('patch-7.4.191') CompilerSet makeprg=rustc\ \%:S else - CompilerSet makeprg=rustc\ \% + CompilerSet makeprg=rustc\ \"%\" endif endif diff --git a/sources_non_forked/rust.vim/doc/rust.txt b/sources_non_forked/rust.vim/doc/rust.txt index c3efb461..9d5eb8cc 100644 --- a/sources_non_forked/rust.vim/doc/rust.txt +++ b/sources_non_forked/rust.vim/doc/rust.txt @@ -125,7 +125,7 @@ g:rustfmt_autosave~ < There is also a buffer-local b:rustfmt_autosave that can be set for the same purpose, and can override the global setting. - + *g:rustfmt_autosave_if_config_present* g:rustfmt_autosave_if_config_present~ Set this option to 1 to have *b:rustfmt_autosave* be set automatically @@ -187,6 +187,16 @@ g:cargo_makeprg_params~ let g:cargo_makeprg_params = 'build' < + *g:cargo_shell_command_runner* +g:cargo_shell_command_runner~ + Set this option to change how to run shell commands for cargo commands + |:Cargo|, |:Cbuild|, |:Crun|, ... + By default, |:terminal| is used to run shell command in terminal window + asynchronously. But if you prefer |:!| for running the commands, it can + be specified: > + let g:cargo_shell_command_runner = '!' +< + Integration with Syntastic *rust-syntastic* -------------------------- diff --git a/sources_non_forked/rust.vim/ftplugin/rust.vim b/sources_non_forked/rust.vim/ftplugin/rust.vim index ac1b438a..ce48116e 100644 --- a/sources_non_forked/rust.vim/ftplugin/rust.vim +++ b/sources_non_forked/rust.vim/ftplugin/rust.vim @@ -121,7 +121,7 @@ command! -nargs=* -buffer RustEmitAsm call rust#Emit("asm", ) command! -range=% RustPlay :call rust#Play(, , , ) " See |:RustFmt| for docs -command! -buffer RustFmt call rustfmt#Format() +command! -bar -buffer RustFmt call rustfmt#Format() " See |:RustFmtRange| for docs command! -range -buffer RustFmtRange call rustfmt#FormatRange(, ) diff --git a/sources_non_forked/rust.vim/syntax/rust.vim b/sources_non_forked/rust.vim/syntax/rust.vim index 423e8fba..8407b56e 100644 --- a/sources_non_forked/rust.vim/syntax/rust.vim +++ b/sources_non_forked/rust.vim/syntax/rust.vim @@ -65,11 +65,11 @@ syn match rustExternCrateString /".*"\_s*as/ contained nextgroup=rustIdentifie syn keyword rustObsoleteExternMod mod contained nextgroup=rustIdentifier skipwhite skipempty syn match rustIdentifier contains=rustIdentifierPrime "\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*" display contained -syn match rustFuncName "\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*" display contained +syn match rustFuncName "\%(r#\)\=\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*" display contained -syn region rustMacroRepeat matchgroup=rustMacroRepeatDelimiters start="$(" end=")" contains=TOP nextgroup=rustMacroRepeatCount -syn match rustMacroRepeatCount ".\?[*+]" contained +syn region rustMacroRepeat matchgroup=rustMacroRepeatDelimiters start="$(" end="),\=[*+]" contains=TOP syn match rustMacroVariable "$\w\+" +syn match rustRawIdent "\ 0 || getline(l:n-1)[-1:] == '\') && \ s:syn_at(l:n,1) =~? s:syng_str return l:n @@ -293,8 +293,9 @@ function GetTypescriptIndent() let l:line = '' endif - " the containing paren, bracket, or curly. Many hacks for performance - let idx = index([']',')','}'],l:line[0]) + " the containing paren, bracket, curly, or closing '>'. + " Many hacks for performance + let idx = index([']',')','}','>'],l:line[0]) if b:js_cache[0] >= l:lnum && b:js_cache[0] < v:lnum && \ (b:js_cache[0] > l:lnum || s:Balanced(l:lnum)) call call('cursor',b:js_cache[1:]) diff --git a/sources_non_forked/typescript-vim/syntax/typescript.vim b/sources_non_forked/typescript-vim/syntax/typescript.vim index 705016d1..474e2288 100644 --- a/sources_non_forked/typescript-vim/syntax/typescript.vim +++ b/sources_non_forked/typescript-vim/syntax/typescript.vim @@ -69,11 +69,11 @@ syn match typescriptNumber "-\=\<\d[0-9_]*L\=\>" display syn match typescriptNumber "-\=\<0[xX][0-9a-fA-F][0-9a-fA-F_]*\>" display syn match typescriptNumber "-\=\<0[bB][01][01_]*\>" display syn match typescriptNumber "-\=\<0[oO]\o[0-7_]*\>" display -syn region typescriptRegexpString start=+/[^/*]+me=e-1 skip=+\\\\\|\\/+ end=+/[gi]\{0,2\}\s*$+ end=+/[gi]\{0,2\}\s*[;.,)\]}]+me=e-1 contains=@htmlPreproc oneline +syn region typescriptRegexpString start=+/[^/*]+me=e-1 skip=+\\\\\|\\/+ end=+/[gimsuy]\{0,2\}\s*$+ end=+/[gimsuy]\{0,2\}\s*[;.,)\]}]+me=e-1 contains=@htmlPreproc oneline " syntax match typescriptSpecial "\\\d\d\d\|\\x\x\{2\}\|\\u\x\{4\}\|\\." " syntax region typescriptStringD start=+"+ skip=+\\\\\|\\$"+ end=+"+ contains=typescriptSpecial,@htmlPreproc " syntax region typescriptStringS start=+'+ skip=+\\\\\|\\$'+ end=+'+ contains=typescriptSpecial,@htmlPreproc -" syntax region typescriptRegexpString start=+/\(\*\|/\)\@!+ skip=+\\\\\|\\/+ end=+/[gim]\{,3}+ contains=typescriptSpecial,@htmlPreproc oneline +" syntax region typescriptRegexpString start=+/\(\*\|/\)\@!+ skip=+\\\\\|\\/+ end=+/[gimsuy]\{,3}+ contains=typescriptSpecial,@htmlPreproc oneline " syntax match typescriptNumber /\<-\=\d\+L\=\>\|\<0[xX]\x\+\>/ syntax match typescriptFloat /\<-\=\%(\d[0-9_]*\.\d[0-9_]*\|\d[0-9_]*\.\|\.\d[0-9]*\)\%([eE][+-]\=\d[0-9_]*\)\=\>/ " syntax match typescriptLabel /\(?\s*\)\@\|>=\|<=\|++\|+=\|--\|-=" syn match typescriptEndColons "[;,]" syn match typescriptLogicSymbols "\(&&\)\|\(||\)\|\(!\)" +syn match typescriptOpSymbols "=\{1,3}\|!==\|!=\|<\|>\|>=\|<=\|++\|+=\|--\|-=" " typescriptFold Function {{{ @@ -223,10 +224,11 @@ syn region foldBraces start=/{/ skip=/\(\/\/.*\)\|\(\/.*\/\)/ end=/}/ transparen " }}} " Define the default highlighting. -" For version 5.7 and earlier: only when not done already +" For version 5.7 and earlier: only when not done already by this script " For version 5.8 and later: only when an item doesn't have highlighting yet +" For version 8.1.1486 and later: only when not done already by this script (need to override vim's new typescript support) if version >= 508 || !exists("did_typescript_syn_inits") - if version < 508 + if version < 508 || has('patch-8.1.1486') let did_typescript_syn_inits = 1 command -nargs=+ HiLink hi link else @@ -287,6 +289,7 @@ if version >= 508 || !exists("did_typescript_syn_inits") HiLink typescriptSpecial Special HiLink typescriptSource Special HiLink typescriptGlobalObjects Special + HiLink typescriptGlobalNodeObjects Special HiLink typescriptExceptions Special HiLink typescriptDomErrNo Constant diff --git a/sources_non_forked/vim-abolish/plugin/abolish.vim b/sources_non_forked/vim-abolish/plugin/abolish.vim index 3b71f944..6fd332d0 100644 --- a/sources_non_forked/vim-abolish/plugin/abolish.vim +++ b/sources_non_forked/vim-abolish/plugin/abolish.vim @@ -588,6 +588,7 @@ function! s:coerce(type) abort let regbody = getreg('"') let regtype = getregtype('"') let c = v:count1 + let begin = getcurpos() while c > 0 let c -= 1 if a:type ==# 'line' @@ -600,9 +601,6 @@ function! s:coerce(type) abort silent exe 'normal!' move.'y' let word = @@ let @@ = s:send(g:Abolish.Coercions,s:transformation,word) - if !exists('begin') - let begin = getpos("'[") - endif if word !=# @@ let changed = 1 exe 'normal!' move.'p' @@ -618,7 +616,7 @@ function! s:coerce(type) abort endfunction nnoremap (abolish-coerce) coerce(nr2char(getchar())) -nnoremap (abolish-coerce) coerce(nr2char(getchar())) +vnoremap (abolish-coerce) coerce(nr2char(getchar())) nnoremap (abolish-coerce-word) coerce(nr2char(getchar())).'iw' " }}}1 diff --git a/sources_non_forked/vim-addon-mw-utils/autoload/glob_linux.vim b/sources_non_forked/vim-addon-mw-utils/autoload/glob_linux.vim index 6fd3f044..e93820c2 100644 --- a/sources_non_forked/vim-addon-mw-utils/autoload/glob_linux.vim +++ b/sources_non_forked/vim-addon-mw-utils/autoload/glob_linux.vim @@ -2,7 +2,8 @@ " TODO refactor: create glob function " noremap \og :callglob_linux#FileByGlobCurrentDir('**/*'.input('glob open '),"\\.git\\\\.hg\\node_modules\\\\.pyc" ) " noremap \og :callglob_linux#FileByGlobCurrentDir('**/*'.input('glob open '),"default" ) -function! glob_linux#FileByGlobCurrentDir(glob, exclude_pattern) +function! glob_linux#FileByGlobCurrentDir(glob, exclude_pattern, ...) + let opts = a:0 > 0 ? a:1 : {} if a:exclude_pattern == "default" let exclude_pattern = '\.git\|\.hg\|node_modules\|\.pyc' else @@ -16,7 +17,7 @@ function! glob_linux#FileByGlobCurrentDir(glob, exclude_pattern) let exclude = exclude_pattern == '' ? '' : ' | grep -v -e '.shellescape(exclude_pattern) - let cmd = 'find | grep -e '.shellescape(g).exclude + let cmd = get(opts, 'cmd_find', 'find'). ' . | grep -e '.shellescape(g).exclude let files = split(system(cmd),"\n") " for nom in a:excludes " call filter(files,nom) diff --git a/sources_non_forked/vim-flake8/README.mdown b/sources_non_forked/vim-flake8/README.mdown index 5d4e00c8..338e4450 100644 --- a/sources_non_forked/vim-flake8/README.mdown +++ b/sources_non_forked/vim-flake8/README.mdown @@ -104,6 +104,12 @@ To customize the colors used for markers, define the highlight groups, `Flake8_E highlight link Flake8_Naming WarningMsg highlight link Flake8_PyFlake WarningMsg +To show the error message of the current line in the ruler, call `flake8#ShowError()`: + + " add binding to call the function + nnoremap :call flake8#Flake8ShowError() + + Tips ---- A tip might be to run the Flake8 check every time you write a Python file, to diff --git a/sources_non_forked/vim-flake8/autoload/flake8.vim b/sources_non_forked/vim-flake8/autoload/flake8.vim index cf592cf7..180bcadb 100644 --- a/sources_non_forked/vim-flake8/autoload/flake8.vim +++ b/sources_non_forked/vim-flake8/autoload/flake8.vim @@ -20,6 +20,10 @@ function! flake8#Flake8UnplaceMarkers() call s:Warnings() endfunction +function! flake8#Flake8ShowError() + call s:ShowErrorMessage() +endfunction + "" }}} "" ** internal ** {{{ @@ -101,6 +105,7 @@ function! s:Setup() " {{{ let s:markerdata['F'].marker = s:flake8_pyflake_marker let s:markerdata['C'].marker = s:flake8_complexity_marker let s:markerdata['N'].marker = s:flake8_naming_marker + endfunction " }}} "" do flake8 @@ -154,11 +159,20 @@ function! s:Flake8() " {{{ let &shellpipe=l:old_shellpipe let &t_ti=l:old_t_ti let &t_te=l:old_t_te + " store mapping of line number to error string " process results + let s:resultDict = {} + let l:results=getqflist() let l:has_results=results != [] if l:has_results + " save line number of each error message + for result in l:results + let linenum = result.lnum + let s:resultDict[linenum] = result.text + endfor + " markers if !s:flake8_show_in_gutter == 0 || !s:flake8_show_in_file == 0 call s:PlaceMarkers(l:results) @@ -184,8 +198,9 @@ function! s:Flake8() " {{{ endif endfunction " }}} -"" markers + +"" markers function! s:PlaceMarkers(results) " {{{ " in gutter? if !s:flake8_show_in_gutter == 0 @@ -253,6 +268,29 @@ function! s:UnplaceMarkers() " {{{ endfor endfunction " }}} +function! s:ShowErrorMessage() " {{{ + let l:cursorPos = getpos(".") + if !exists('s:resultDict') + return + endif + + " if there is a message on the current line, + " then echo it + if has_key(s:resultDict, l:cursorPos[1]) + let l:errorText = get(s:resultDict, l:cursorPos[1]) + echo strpart(l:errorText, 0, &columns-1) + let b:showing_message = 1 + endif + + " if a message is already being shown, + " then clear it + if !b:showing_message == 0 + echo + let b:showing_message = 0 + endif + +endfunction " }}} + "" }}} let &cpo = s:save_cpo diff --git a/sources_non_forked/vim-fugitive/autoload/fugitive.vim b/sources_non_forked/vim-fugitive/autoload/fugitive.vim index 2ebae0a1..3372d67c 100644 --- a/sources_non_forked/vim-fugitive/autoload/fugitive.vim +++ b/sources_non_forked/vim-fugitive/autoload/fugitive.vim @@ -45,17 +45,31 @@ function! s:winshell() abort return has('win32') && &shellcmdflag !~# '^-' endfunction +function! s:WinShellEsc(arg) abort + if type(a:arg) == type([]) + return join(map(copy(a:arg), 's:shellesc(v:val)')) + elseif a:arg =~# '^[A-Za-z0-9_/:.-]\+$' + return a:arg + else + return '"' . s:gsub(s:gsub(a:arg, '"', '""'), '\%', '"%"') . '"' + endif +endfunction + function! s:shellesc(arg) abort if type(a:arg) == type([]) return join(map(copy(a:arg), 's:shellesc(v:val)')) +<<<<<<< HEAD <<<<<<< HEAD elseif a:arg =~ '^[A-Za-z0-9_/.-]\+$' ======= elseif a:arg =~ '^[A-Za-z0-9_/:.-]\+$' >>>>>>> 27ad0d07862847896f691309a544a206783c94d6 +======= + elseif a:arg =~# '^[A-Za-z0-9_/:.-]\+$' +>>>>>>> master return a:arg elseif s:winshell() - return '"'.s:gsub(s:gsub(a:arg, '"', '""'), '\%', '"%"').'"' + return '"' . s:gsub(s:gsub(a:arg, '"', '""'), '\%', '"%"') . '"' else return shellescape(a:arg) endif @@ -127,8 +141,13 @@ function! s:Resolve(path) abort return path endfunction +function! s:FileIgnoreCase(for_completion) abort + return (exists('+fileignorecase') && &fileignorecase) + \ || (a:for_completion && exists('+wildignorecase') && &wildignorecase) +endfunction + function! s:cpath(path, ...) abort - if exists('+fileignorecase') && &fileignorecase + if s:FileIgnoreCase(0) let path = FugitiveVimPath(tolower(a:path)) else let path = FugitiveVimPath(a:path) @@ -136,19 +155,6 @@ function! s:cpath(path, ...) abort return a:0 ? path ==# s:cpath(a:1) : path endfunction -function! s:Cd(...) abort - let cd = exists('*haslocaldir') && haslocaldir() ? 'lcd' : exists(':tcd') && haslocaldir(-1) ? 'tcd' : 'cd' - if !a:0 - return cd - endif - let cwd = getcwd() - if s:cpath(cwd, a:1) - return '' - endif - exe cd s:fnameescape(a:1) - return cd . ' ' . s:fnameescape(cwd) -endfunction - let s:executables = {} function! s:executable(binary) abort @@ -175,11 +181,13 @@ endif function! s:TempScript(...) abort let body = join(a:000, "\n") if !has_key(s:temp_scripts, body) - let temp = tempname() . '.sh' - call writefile(['#!/bin/sh'] + a:000, temp) - let s:temp_scripts[body] = temp + let s:temp_scripts[body] = tempname() . '.sh' endif - return FugitiveGitPath(s:temp_scripts[body]) + let temp = s:temp_scripts[body] + if !filereadable(temp) + call writefile(['#!/bin/sh'] + a:000, temp) + endif + return FugitiveGitPath(temp) endfunction function! s:DoAutocmd(cmd) abort @@ -225,6 +233,7 @@ function! s:Map(mode, lhs, rhs, ...) abort endfor endfunction +<<<<<<< HEAD " Section: Quickfix function! s:QuickfixGet(nr, ...) abort @@ -315,12 +324,23 @@ function! fugitive#Cwindow() abort endif endfunction +======= +>>>>>>> master " Section: Git >>>>>>> 27ad0d07862847896f691309a544a206783c94d6 function! s:UserCommandList(...) abort let git = split(get(g:, 'fugitive_git_command', g:fugitive_git_executable), '\s\+') - let dir = a:0 ? s:Dir(a:1) : '' + let flags = [] + if a:0 && type(a:1) == type({}) + let git = copy(get(a:1, 'git', git)) + let flags = get(a:1, 'flags', flags) + let dir = a:1.dir + elseif a:0 + let dir = a:1 + else + let dir = '' + endif if len(dir) let tree = s:Tree(dir) if empty(tree) @@ -339,7 +359,7 @@ function! s:UserCommandList(...) abort >>>>>>> 27ad0d07862847896f691309a544a206783c94d6 endif endif - return git + return git + flags endfunction function! s:UserCommand(...) abort @@ -459,9 +479,9 @@ function! fugitive#PrepareDirEnvArgv(...) abort let i = 0 while i < len(cmd) if cmd[i] =~# '^$\|[\/.]' && cmd[i] !~# '^-' - let dir = remove(cmd, 0) + let dir = remove(cmd, i) elseif cmd[i] =~# '^--git-dir=' - let dir = remove(cmd, 0)[10:-1] + let dir = remove(cmd, i)[10:-1] elseif type(cmd[i]) ==# type(0) let dir = s:Dir(remove(cmd, i)) elseif cmd[i] ==# '-c' && len(cmd) > i + 1 @@ -527,6 +547,25 @@ function! s:BuildEnvPrefix(env) abort endif endfunction +function! s:JobOpts(cmd, env) abort + if empty(a:env) + return [a:cmd, {}] + elseif has('patch-8.2.0239') || has('patch-8.1.0902') && !has('nvim') && (!has('win32') || empty(filter(keys(a:env), 'exists("$" . v:val)'))) + return [a:cmd, {'env': a:env}] + endif + let envlist = map(items(a:env), 'join(v:val, "=")') + if !has('win32') + return [['env'] + envlist + a:cmd, {}] + else + let pre = join(map(envlist, '"set " . substitute(v:val, "[&|<>^]", "^^^&", "g") . "& "'), '') + if len(a:cmd) == 3 && a:cmd[0] ==# 'cmd.exe' && a:cmd[1] ==# '/c' + return [a:cmd[0:1] + [pre . a:cmd[2]], {}] + else + return [['cmd.exe', '/c', pre . s:WinShellEsc(a:cmd)], {}] + endif + endif +endfunction + function! s:BuildShell(dir, env, args) abort let cmd = copy(a:args) let tree = s:Tree(a:dir) @@ -614,10 +653,20 @@ function! s:TreeChomp(...) abort endfunction function! s:EchoExec(...) abort +<<<<<<< HEAD echo call('s:ChompError', a:000)[0] call fugitive#ReloadStatus(-1, 1) return 'checktime' >>>>>>> 27ad0d07862847896f691309a544a206783c94d6 +======= + if s:RunJobs() + return 'Git ' . s:fnameescape(a:000) + else + echo call('s:ChompError', a:000)[0] + call fugitive#ReloadStatus(-1, 1) + return 'checktime' + endif +>>>>>>> master endfunction let s:head_cache = {} @@ -688,9 +737,9 @@ function! fugitive#Config(...) abort let dir = a:1 endif let name = substitute(name, '^[^.]\+\|[^.]\+$', '\L&', 'g') - let key = len(dir) ? dir : '_' - if has_key(s:config, key) && s:config[key][0] ==# s:ConfigTimestamps(dir, s:config[key][1]) - let dict = s:config[key][1] + let dir_key = len(dir) ? dir : '_' + if has_key(s:config, dir_key) && s:config[dir_key][0] ==# s:ConfigTimestamps(dir, s:config[dir_key][1]) + let dict = s:config[dir_key][1] else let dict = {} let [lines, message, exec_error] = s:NullError([dir, 'config', '--list', '-z']) @@ -702,9 +751,13 @@ function! fugitive#Config(...) abort if !has_key(dict, key) let dict[key] = [] endif - call add(dict[key], strpart(line, len(key) + 1)) + if len(key) ==# len(line) + call add(dict[key], 1) + else + call add(dict[key], strpart(line, len(key) + 1)) + endif endfor - let s:config[dir] = [s:ConfigTimestamps(dir, dict), dict] + let s:config[dir_key] = [s:ConfigTimestamps(dir, dict), dict] lockvar! dict endif return len(name) ? get(get(dict, name, []), 0, '') : dict @@ -731,6 +784,89 @@ function! fugitive#RemoteUrl(...) abort return s:ChompDefault('', [dir, 'remote', 'get-url', remote, '--']) endfunction +" Section: Quickfix + +function! s:QuickfixGet(nr, ...) abort + if a:nr < 0 + return call('getqflist', a:000) + else + return call('getloclist', [a:nr] + a:000) + endif +endfunction + +function! s:QuickfixSet(nr, ...) abort + if a:nr < 0 + return call('setqflist', a:000) + else + return call('setloclist', [a:nr] + a:000) + endif +endfunction + +function! s:QuickfixCreate(nr, opts) abort + if has('patch-7.4.2200') + call s:QuickfixSet(a:nr, [], ' ', a:opts) + else + call s:QuickfixSet(a:nr, [], ' ') + endif +endfunction + +function! s:QuickfixStream(nr, event, title, cmd, first, callback, ...) abort + let opts = {'title': a:title, 'context': {'items': []}} + call s:QuickfixCreate(a:nr, opts) + let event = (a:nr < 0 ? 'c' : 'l') . 'fugitive-' . a:event + silent exe s:DoAutocmd('QuickFixCmdPre ' . event) + let winnr = winnr() + exe a:nr < 0 ? 'copen' : 'lopen' + if winnr != winnr() + wincmd p + endif + + let buffer = [] + let lines = split(s:SystemError(s:shellesc(a:cmd))[0], "\n") + for line in lines + call extend(buffer, call(a:callback, a:000 + [line])) + if len(buffer) >= 20 + let contexts = map(copy(buffer), 'get(v:val, "context", {})') + lockvar contexts + call extend(opts.context.items, contexts) + unlet contexts + call s:QuickfixSet(a:nr, remove(buffer, 0, -1), 'a') + redraw + endif + endfor + call extend(buffer, call(a:callback, a:000 + [0])) + call extend(opts.context.items, map(copy(buffer), 'get(v:val, "context", {})')) + lockvar opts.context.items + call s:QuickfixSet(a:nr, buffer, 'a') + + silent exe s:DoAutocmd('QuickFixCmdPost ' . event) + if a:first && len(s:QuickfixGet(a:nr)) + call s:BlurStatus() + return a:nr < 0 ? 'cfirst' : 'lfirst' + else + return 'exe' + endif +endfunction + +let s:common_efm = '' + \ . '%+Egit:%.%#,' + \ . '%+Eusage:%.%#,' + \ . '%+Eerror:%.%#,' + \ . '%+Efatal:%.%#,' + \ . '%-G%.%#%\e[K%.%#,' + \ . '%-G%.%#%\r%.%\+' + +function! fugitive#Cwindow() abort + if &buftype == 'quickfix' + cwindow + else + botright cwindow + if &buftype == 'quickfix' + wincmd p + endif + endif +endfunction + " Section: Repository Object function! s:add_methods(namespace, method_names) abort @@ -796,23 +932,16 @@ function! s:repo_prepare(...) dict abort endfunction function! s:repo_git_command(...) dict abort - let git = s:UserCommand() . ' --git-dir='.s:shellesc(self.git_dir) + let git = g:fugitive_git_executable . ' --git-dir='.s:shellesc(self.git_dir) return git.join(map(copy(a:000),'" ".s:shellesc(v:val)'),'') endfunction function! s:repo_git_chomp(...) dict abort - let git = g:fugitive_git_executable . ' --git-dir='.s:shellesc(self.git_dir) - let output = git . join(map(copy(a:000),'" ".s:shellesc(v:val)'),'') - return s:sub(system(output), '\n$', '') + return s:sub(system(FugitivePrepare(a:000, self.git_dir)), '\n$', '') endfunction function! s:repo_git_chomp_in_tree(...) dict abort - let cdback = s:Cd(self.tree()) - try - return call(self.git_chomp, a:000, self) - finally - execute cdback - endtry + return call(self.git_chomp, a:000, self) endfunction function! s:repo_rev_parse(rev) dict abort @@ -1428,6 +1557,12 @@ function! fugitive#getfperm(url) abort return perm ==# '---------' ? '' : perm endfunction +function s:UpdateIndex(dir, info) abort + let info = join(a:info[0:-2]) . "\t" . a:info[-1] . "\n" + let [error, exec_error] = s:SystemError([a:dir, 'update-index', '--index-info'], info) + return !exec_error ? '' : len(error) ? error : 'fugitive: unknown update-index error' +endfunction + function! fugitive#setfperm(url, perm) abort let [dir, commit, file] = s:DirCommitFile(a:url) let entry = s:PathInfo(a:url) @@ -1436,9 +1571,8 @@ function! fugitive#setfperm(url, perm) abort \ substitute(perm, 'x', '-', 'g') !=# substitute(a:perm, 'x', '-', 'g') return -2 endif - let exec_error = s:SystemError([dir, 'update-index', '--index-info'], - \ (a:perm =~# 'x' ? '000755 ' : '000644 ') . entry[3] . ' ' . commit . "\t" . file[1:-1])[1] - return exec_error ? -1 : 0 + let error = s:UpdateIndex(dir, [a:perm =~# 'x' ? '000755' : '000644', entry[3], commit, file[1:-1]]) + return len(error) ? -1 : 0 endfunction function! s:TempCmd(out, cmd) abort @@ -1516,9 +1650,8 @@ function! fugitive#writefile(lines, url, ...) abort let [hash, exec_error] = s:ChompError([dir, 'hash-object', '-w', temp]) let mode = len(entry[1]) ? entry[1] : '100644' if !exec_error && hash =~# '^\x\{40,\}$' - let exec_error = s:SystemError([dir, 'update-index', '--index-info'], - \ mode . ' ' . hash . ' ' . commit . "\t" . file[1:-1])[1] - if !exec_error + let error = s:UpdateIndex(dir, [mode, hash, commit, file[1:-1]]) + if empty(error) return 0 endif endif @@ -1571,9 +1704,8 @@ function! fugitive#delete(url, ...) abort if entry[2] !=# 'blob' return -1 endif - let exec_error = s:SystemError([dir, 'update-index', '--index-info'], - \ '000000 0000000000000000000000000000000000000000 ' . commit . "\t" . file[1:-1])[1] - return exec_error ? -1 : 0 + let error = s:UpdateIndex(dir, ['000000', '0000000000000000000000000000000000000000', commit, file[1:-1]]) + return len(error) ? -1 : 0 endfunction " Section: Buffer Object @@ -1614,7 +1746,8 @@ function! s:FilterEscape(items, ...) abort let items = copy(a:items) call map(items, 's:fnameescape(v:val)') if a:0 && type(a:1) == type('') - call filter(items, 'strpart(v:val, 0, strlen(a:1)) ==# a:1') + let cmp = s:FileIgnoreCase(1) ? '==?' : '==#' + call filter(items, 'strpart(v:val, 0, strlen(a:1)) ' . cmp . ' a:1') endif return items endfunction @@ -1648,10 +1781,21 @@ function! s:GlobComplete(lead, pattern) abort endfunction function! fugitive#CompletePath(base, ...) abort - let dir = a:0 == 1 ? a:1 : a:0 == 3 ? a:3 : s:Dir() - let tree = s:Tree(dir) . '/' - let strip = '^\%(:/:\=\|:(top)\|:(top,literal)\|:(literal,top)\|:(literal)\)' - let base = substitute(a:base, strip, '', '') + let dir = a:0 == 1 ? a:1 : a:0 >= 3 ? a:3 : s:Dir() + let stripped = matchstr(a:base, '^\%(:/:\=\|:(top)\|:(top,literal)\|:(literal,top)\)') + let base = strpart(a:base, len(stripped)) + if len(stripped) || a:0 < 4 + let root = s:Tree(dir) + else + let root = a:4 + endif + if root !=# '/' && len(root) + let root .= '/' + endif + if empty(stripped) + let stripped = matchstr(a:base, '^\%(:(literal)\|:\)') + let base = strpart(a:base, len(stripped)) + endif if base =~# '^\.git/' let pattern = s:gsub(base[5:-1], '/', '*&').'*' let matches = s:GlobComplete(dir . '/', pattern) @@ -1663,14 +1807,14 @@ function! fugitive#CompletePath(base, ...) abort call map(matches, "'.git/' . v:val") elseif base =~# '^\~/' let matches = map(s:GlobComplete(expand('~/'), base[2:-1] . '*'), '"~/" . v:val') - elseif a:base =~# '^/\|^\a\+:\|^\.\.\=/\|^:(literal)' + elseif a:base =~# '^/\|^\a\+:\|^\.\.\=/' let matches = s:GlobComplete('', base . '*') - elseif len(tree) > 1 - let matches = s:GlobComplete(tree, s:gsub(base, '/', '*&').'*') + elseif len(root) + let matches = s:GlobComplete(root, s:gsub(base, '/', '*&').'*') else let matches = [] endif - call map(matches, 's:fnameescape(s:Slash(matchstr(a:base, strip) . v:val))') + call map(matches, 's:fnameescape(s:Slash(stripped . v:val))') return matches endfunction @@ -1679,18 +1823,21 @@ function! fugitive#PathComplete(...) abort endfunction function! s:CompleteHeads(dir) abort + if empty(a:dir) + return [] + endif let dir = fugitive#Find('.git/', a:dir) return sort(filter(['HEAD', 'FETCH_HEAD', 'ORIG_HEAD'] + s:merge_heads, 'filereadable(dir . v:val)')) + - \ sort(s:LinesError('rev-parse', '--symbolic', '--branches', '--tags', '--remotes')[0]) + \ sort(s:LinesError([a:dir, 'rev-parse', '--symbolic', '--branches', '--tags', '--remotes'])[0]) endfunction function! fugitive#CompleteObject(base, ...) abort - let dir = a:0 == 1 ? a:1 : a:0 == 3 ? a:3 : s:Dir() + let dir = a:0 == 1 ? a:1 : a:0 >= 3 ? a:3 : s:Dir() + let tree = s:Tree(dir) let cwd = getcwd() - let tree = s:Tree(dir) . '/' let subdir = '' - if len(tree) > 1 && s:cpath(tree, cwd[0 : len(tree) - 1]) - let subdir = strpart(cwd, len(tree)) . '/' + if len(tree) && s:cpath(tree . '/', cwd[0 : len(tree)]) + let subdir = strpart(cwd, len(tree) + 1) . '/' endif if a:base =~# '^\.\=/\|^:(' || a:base !~# ':' @@ -1712,9 +1859,7 @@ function! fugitive#CompleteObject(base, ...) abort endif let results += s:FilterEscape(heads, a:base) endif - if !empty(tree) - let results += a:0 == 1 ? fugitive#CompletePath(a:base, dir) : fugitive#CompletePath(a:base) - endif + let results += a:0 == 1 || a:0 >= 3 ? fugitive#CompletePath(a:base, 0, '', dir, a:0 >= 4 ? a:4 : tree) : fugitive#CompletePath(a:base) return results elseif a:base =~# '^:' @@ -1729,8 +1874,8 @@ function! fugitive#CompleteObject(base, ...) abort endif else - let tree = matchstr(a:base, '.*[:/]') - let entries = s:LinesError(['ls-tree', substitute(tree, ':\zs\./', '\=subdir', '')], dir)[0] + let parent = matchstr(a:base, '.*[:/]') + let entries = s:LinesError(['ls-tree', substitute(parent, ':\zs\./', '\=subdir', '')], dir)[0] call map(entries,'s:sub(v:val,"^04.*\\zs$","/")') call map(entries,'tree.s:sub(v:val,".*\t","")') @@ -1769,25 +1914,30 @@ function! s:CompleteSub(subcommand, A, L, P, ...) abort elseif !a:0 return fugitive#CompleteObject(a:A, s:Dir()) elseif type(a:1) == type(function('tr')) - return call(a:1, [a:A, a:L, a:P]) + return call(a:1, [a:A, a:L, a:P] + (a:0 > 1 ? a:2 : [])) else return s:FilterEscape(a:1, a:A) endif endfunction function! s:CompleteRevision(A, L, P, ...) abort +<<<<<<< HEAD return s:FilterEscape(s:CompleteHeads(s:Dir()), a:A) >>>>>>> 27ad0d07862847896f691309a544a206783c94d6 +======= + return s:FilterEscape(s:CompleteHeads(a:0 ? a:1 : s:Dir()), a:A) +>>>>>>> master endfunction -function! s:CompleteRemote(A, L, P) abort - let remote = matchstr(a:L, '\u\w*[! ] *\zs\S\+\ze ') +function! s:CompleteRemote(A, L, P, ...) abort + let dir = a:0 ? a:1 : s:Dir() + let remote = matchstr(a:L, '\u\w*[! ] *.\{-\}\s\@<=\zs[^-[:space:]]\S*\ze ') if !empty(remote) - let matches = s:LinesError('ls-remote', remote)[0] + let matches = s:LinesError([dir, 'ls-remote', remote])[0] call filter(matches, 'v:val =~# "\t" && v:val !~# "{"') call map(matches, 's:sub(v:val, "^.*\t%(refs/%(heads/|tags/)=)=", "")') else - let matches = s:LinesError('remote')[0] + let matches = s:LinesError([dir, 'remote'])[0] endif return s:FilterEscape(matches, a:A) endfunction @@ -1800,8 +1950,15 @@ function! s:ReplaceCmd(cmd) abort if exec_error call s:throw((len(err) ? err : filereadable(temp) ? join(readfile(temp), ' ') : 'unknown error running ' . a:cmd)) endif + setlocal noswapfile silent exe 'lockmarks keepalt 0read ++edit' s:fnameescape(temp) - silent keepjumps $delete _ + if &foldenable && foldlevel('$') > 0 + set nofoldenable + silent keepjumps $delete _ + set foldenable + else + silent keepjumps $delete _ + endif call delete(temp) if s:cpath(fnamemodify(bufname('$'), ':p'), temp) silent! execute bufnr('$') . 'bwipeout' @@ -1911,6 +2068,10 @@ function! fugitive#BufReadStatus() abort ======= >>>>>>> 27ad0d07862847896f691309a544a206783c94d6 + if fugitive#GitVersion(2, 15) + call add(cmd, '--no-optional-locks') + endif + let b:fugitive_files = {'Staged': {}, 'Unstaged': {}} let [staged, unstaged, untracked] = [[], [], []] let props = {} @@ -2121,6 +2282,10 @@ function! fugitive#BufReadStatus() abort if empty(s:Tree()) call s:AddHeader('Bare', 'yes') endif + if get(FugitiveConfigGetAll('advice.statusHints', config), 0, 'true') !~# '^\%(false\|no|off\|0\|\)$' + call s:AddHeader('Help', 'g?') + endif + call s:AddSection('Rebasing ' . rebasing_head, rebasing) call s:AddSection('Untracked', untracked) call s:AddSection('Unstaged', unstaged) @@ -2147,7 +2312,7 @@ function! fugitive#BufReadStatus() abort if &bufhidden ==# '' setlocal bufhidden=delete endif - let b:dispatch = ':Gfetch --all' + let b:dispatch = ':Git fetch --all' call fugitive#MapJumps() <<<<<<< HEAD let nowait = v:version >= 704 ? '' : '' @@ -2212,7 +2377,7 @@ function! fugitive#BufReadStatus() abort call s:MapMotion('gp', "exe StageJump(v:count, 'Unpushed')") call s:MapMotion('gP', "exe StageJump(v:count, 'Unpulled')") call s:MapMotion('gr', "exe StageJump(v:count, 'Rebasing')") - call s:Map('n', 'C', ":Gcommit:echohl WarningMsgecho ':Gstatus C is deprecated in favor of cc'echohl NONE", '') + call s:Map('n', 'C', ":echoerr ':Gstatus C has been removed in favor of cc'", '') call s:Map('n', 'a', ":execute Do('Toggle',0)", '') call s:Map('n', 'i', ":execute NextExpandedHunk(v:count1)", '') call s:Map('n', "=", ":execute StageInline('toggle',line('.'),v:count)", '') @@ -2308,9 +2473,8 @@ function! fugitive#FileWriteCmd(...) abort if empty(old_mode) let old_mode = executable(s:Tree(dir) . file) ? '100755' : '100644' endif - let info = old_mode.' '.sha1.' '.commit."\t".file[1:-1] - let [error, exec_error] = s:SystemError([dir, 'update-index', '--index-info'], info . "\n") - if !exec_error + let error = s:UpdateIndex(dir, [old_mode, sha1, commit, file[1:-1]]) + if empty(error) setlocal nomodified if exists('#' . autype . 'WritePost') execute s:DoAutocmd(autype . 'WritePost ' . s:fnameescape(amatch)) @@ -2399,13 +2563,13 @@ function! fugitive#BufReadCmd(...) abort keepjumps 1 keepjumps call search('^parent ') if getline('.') ==# 'parent ' - silent keepjumps delete_ + silent lockmarks keepjumps delete_ else silent exe (exists(':keeppatterns') ? 'keeppatterns' : '') 'keepjumps s/\m\C\%(^parent\)\@\)\=$','W',line('.')+3) if lnum - silent keepjumps delete_ + silent lockmarks keepjumps delete_ end silent exe (exists(':keeppatterns') ? 'keeppatterns' : '') 'keepjumps 1,/^diff --git\|\%$/s/\r$//e' keepjumps 1 @@ -2479,7 +2643,7 @@ function! s:TempReadPre(file) abort if has_key(s:temp_files, s:cpath(a:file)) let dict = s:temp_files[s:cpath(a:file)] setlocal nomodeline - setlocal bufhidden=delete nobuflisted + setlocal bufhidden=delete setlocal buftype=nowrite setlocal nomodifiable if len(dict.dir) @@ -2492,6 +2656,7 @@ endfunction function! s:TempReadPost(file) abort if has_key(s:temp_files, s:cpath(a:file)) let dict = s:temp_files[s:cpath(a:file)] + setlocal nobuflisted if has_key(dict, 'filetype') && dict.filetype !=# &l:filetype let &l:filetype = dict.filetype endif @@ -2533,6 +2698,7 @@ augroup END " Section: :Git +<<<<<<< HEAD <<<<<<< HEAD call s:command("-bang -nargs=? -range=-1 -complete=customlist,fugitive#CompleteGit Git", "Git") call s:command("-bar -bang -range=-1 -nargs=* -complete=customlist,fugitive#CompleteGit G", "") @@ -2563,10 +2729,35 @@ function! s:GitExec(line1, line2, range, count, bang, mods, reg, args, dir) abor if has('nvim') && executable('env') let pre .= 'env GIT_TERMINAL_PROMPT=0 ' ======= +======= +function! s:AskPassArgs(dir) abort + if (len($DISPLAY) || len($TERM_PROGRAM) || has('gui_running')) && fugitive#GitVersion(1, 8) && + \ empty($GIT_ASKPASS) && empty($SSH_ASKPASS) && empty(FugitiveConfigGetAll('core.askpass', a:dir)) + if s:executable(s:ExecPath() . '/git-gui--askpass') + return ['-c', 'core.askPass=' . s:ExecPath() . '/git-gui--askpass'] + elseif s:executable('ssh-askpass') + return ['-c', 'core.askPass=ssh-askpass'] + endif + endif + return [] +endfunction + +>>>>>>> master function! s:RunJobs() abort return exists('*job_start') || exists('*jobstart') endfunction +function! s:RunEdit(state, job) abort + if get(a:state, 'request', '') == 'edit' + call remove(a:state, 'request') + let file = readfile(a:state.temp . '.edit')[0] + exe substitute(a:state.mods, '\', '-tab', 'g') 'keepalt split' s:fnameescape(file) + set bufhidden=wipe + let s:edit_jobs[bufnr('')] = [a:state, a:job] + return 1 + endif +endfunction + function! s:RunReceive(state, job, data, ...) abort call add(a:state.log, a:data) let data = type(a:data) == type([]) ? join(a:data, "\n") : a:data @@ -2574,16 +2765,21 @@ function! s:RunReceive(state, job, data, ...) abort let data = remove(a:state, 'buffer') . data endif let escape = "\033]51;[^\007]*" - let a:state.buffer = matchstr(data, escape . "$\\|[\r\n]\\+$") - if len(a:state.buffer) - let data = strpart(data, 0, len(data) - len(a:state.buffer)) + let a:state.escape_buffer = matchstr(data, escape . '$') + if len(a:state.escape_buffer) + let data = strpart(data, 0, len(data) - len(a:state.escape_buffer)) endif let cmd = matchstr(data, escape . "\007")[5:-2] let data = substitute(data, escape . "\007", '', 'g') - echon substitute(data, "\r\\ze\n", '', 'g') if cmd =~# '^fugitive:' let a:state.request = strpart(cmd, 9) endif + let data = a:state.echo_buffer . data + let a:state.echo_buffer = matchstr(data, "[\r\n]\\+$") + if len(a:state.echo_buffer) + let data = strpart(data, 0, len(data) - len(a:state.echo_buffer)) + endif + echon substitute(data, "\r\\ze\n", '', 'g') endfunction function! s:RunSend(job, str) abort @@ -2605,29 +2801,34 @@ endif function! s:RunWait(state, job) abort let finished = 0 try - while get(a:state, 'request', '') !=# 'edit' && (type(a:job) == type(0) ? jobwait([a:job], 1)[0] == -1 : ch_status(a:job) !=# 'closed') + while get(a:state, 'request', '') !=# 'edit' && (type(a:job) == type(0) ? jobwait([a:job], 1)[0] == -1 : ch_status(a:job) !=# 'closed' || job_status(a:job) ==# 'run') if !exists('*jobwait') sleep 1m endif - let peek = getchar(1) - if peek != 0 && !(has('win32') && peek == 128) - let c = getchar() - let c = type(c) == type(0) ? nr2char(c) : c - call s:RunSend(a:job, c) - if !a:state.pty - echon c + if !get(a:state, 'closed') + let peek = getchar(1) + if peek != 0 && !(has('win32') && peek == 128) + let c = getchar() + let c = type(c) == type(0) ? nr2char(c) : c + if c ==# "\" + let a:state.closed = 1 + if type(a:job) ==# type(0) + call chanclose(a:job, 'stdin') + else + call ch_close_in(a:job) + endif + else + call s:RunSend(a:job, c) + if !a:state.pty + echon c + endif + endif endif endif endwhile sleep 1m echo - if get(a:state, 'request', '') == 'edit' - call remove(a:state, 'request') - let file = readfile(a:state.temp . '.edit')[0] - exe substitute(a:state.mods, '\', '-tab', 'g') 'keepalt split' s:fnameescape(file) - set bufhidden=wipe - let s:edit_jobs[bufnr('')] = [a:state, a:job] - endif + call s:RunEdit(a:state, a:job) let finished = 1 finally if !finished @@ -2653,15 +2854,15 @@ endif function! fugitive#Resume() abort while len(s:resume_queue) let [state, job] = remove(s:resume_queue, 0) + if filereadable(state.temp . '.edit') + call delete(state.temp . '.edit') + endif call s:RunWait(state, job) endwhile endfunction function! s:RunBufDelete(bufnr) abort if has_key(s:edit_jobs, a:bufnr) | - if filereadable(s:edit_jobs[a:bufnr][0].temp . '.edit') - call delete(s:edit_jobs[a:bufnr][0].temp . '.edit') - endif call add(s:resume_queue, remove(s:edit_jobs, a:bufnr)) call feedkeys(":redraw!|call fugitive#Resume()|silent checktime\r", 'n') endif @@ -2672,10 +2873,44 @@ augroup fugitive_job autocmd BufDelete * call s:RunBufDelete(expand('')) autocmd VimLeave * \ for s:jobbuf in keys(s:edit_jobs) | - \ call writefile([], remove(s:edit_jobs, s:jobbuf)[0].temp . '.exit') | + \ call writefile([], s:edit_jobs[s:jobbuf][0].temp . '.exit') | + \ redraw! | + \ call call('s:RunWait', remove(s:edit_jobs, s:jobbuf)) | \ endfor augroup END +function! fugitive#PagerFor(argv, ...) abort + let args = a:argv + if empty(args) + return 0 + elseif (args[0] ==# 'help' || get(args, 1, '') ==# '--help') && !s:HasOpt(args, '--web') + return 1 + endif + if args[0] ==# 'config' && (s:HasOpt(args, '-e', '--edit') || + \ !s:HasOpt(args, '--list', '--get-all', '--get-regexp', '--get-urlmatch')) || + \ args[0] =~# '^\%(tag\|branch\)$' && ( + \ s:HasOpt(args, '--edit-description', '--unset-upstream', '-m', '-M', '--move', '-c', '-C', '--copy', '-d', '-D', '--delete') || + \ len(filter(args[1:-1], 'v:val =~# "^[^-]\\|^--set-upstream-to="')) && + \ !s:HasOpt(args, '--contains', '--no-contains', '--merged', '--no-merged', '--points-at')) + return 0 + endif + let config = a:0 ? a:1 : fugitive#Config() + let value = get(FugitiveConfigGetAll('pager.' . args[0], config), 0, -1) + if value =~# '^\%(true\|yes\|on\|1\)$' + return 1 + elseif value =~# '^\%(false\|no|off\|0\|\)$' + return 0 + elseif type(value) == type('') + return value + elseif args[0] =~# 'diff\%(tool\)\@!\|log\|^show$\|^config$\|^branch$\|^tag$' || + \ (args[0] ==# 'stash' && get(args, 1, '') ==# 'show') || + \ (args[0] ==# 'am' && s:HasOpt(args, '--show-current-patch')) + return 1 + else + return 0 + endif +endfunction + let s:disable_colors = [] for s:colortype in ['advice', 'branch', 'diff', 'grep', 'interactive', 'pager', 'push', 'remote', 'showBranch', 'status', 'transport', 'ui'] call extend(s:disable_colors, ['-c', 'color.' . s:colortype . '=false']) @@ -2683,55 +2918,115 @@ endfor unlet s:colortype function! fugitive#Command(line1, line2, range, bang, mods, arg) abort let dir = s:Dir() + let config = copy(fugitive#Config(dir)) let [args, after] = s:SplitExpandChain(a:arg, s:Tree(dir)) - if empty(args) + let flags = [] + let pager = -1 + while len(args) + if args[0] ==# '-c' && len(args) > 1 + call extend(flags, remove(args, 0, 1)) + elseif args[0] =~# '^-p$\|^--paginate$' + let pager = 1 + call remove(args, 0) + elseif args[0] =~# '^-P$\|^--no-pager$' + let pager = 0 + call remove(args, 0) + elseif args[0] =~# '^--\%([[:lower:]-]\+-pathspecs\|no-optional-locks\)$' + call add(flags, remove(args, 0)) + elseif args[0] =~# '^-C$\|^--\%(exec-path=\|git-dir=\|work-tree=\|bare$\)' + return 'echoerr ' . string('fugitive: ' . args[0] . ' is not supported') + else + break + endif + endwhile + if pager is# 0 + call add(flags, '--no-pager') + endif + if empty(args) && pager is# -1 let cmd = s:StatusCommand(a:line1, a:line2, a:range, a:line2, a:bang, a:mods, '', '', []) return (empty(cmd) ? 'exe' : cmd) . after endif - let alias = get(s:Aliases(dir), args[0], '!') - if get(args, 1, '') !=# '--help' && alias !~# '^!\|[\"'']' && !filereadable(s:ExecPath() . '/git-' . args[0]) + let alias = fugitive#Config('alias.' . get(args, 0, ''), config) + if get(args, 1, '') !=# '--help' && alias !~# '^$\|^!\|[\"'']' && !filereadable(s:ExecPath() . '/git-' . args[0]) \ && !(has('win32') && filereadable(s:ExecPath() . '/git-' . args[0] . '.exe')) call remove(args, 0) call extend(args, split(alias, '\s\+'), 'keep') endif - let name = substitute(args[0], '\%(^\|-\)\(\l\)', '\u\1', 'g') - if exists('*s:' . name . 'Subcommand') && get(args, 1, '') !=# '--help' + let name = substitute(get(args, 0, ''), '\%(^\|-\)\(\l\)', '\u\1', 'g') + let git = split(get(g:, 'fugitive_git_command', g:fugitive_git_executable), '\s\+') + let options = {'git': git, 'dir': dir, 'flags': flags} + if pager is# -1 && exists('*s:' . name . 'Subcommand') && get(args, 1, '') !=# '--help' try - exe s:DirCheck(dir) - let opts = s:{name}Subcommand(a:line1, a:line2, a:range, a:bang, a:mods, args[1:-1]) - if type(opts) == type('') - return 'exe ' . string(opts) . after + let overrides = s:{name}Subcommand(a:line1, a:line2, a:range, a:bang, a:mods, extend({'command': args[0], 'args': args[1:-1]}, options)) + if type(overrides) == type('') + return 'exe ' . string(overrides) . after endif + let args = [get(overrides, 'command', args[0])] + get(overrides, 'insert_args', []) + args[1:-1] catch /^fugitive:/ return 'echoerr ' . string(v:exception) endtry else - let opts = {} + let overrides = {} endif - let args = get(opts, 'args', args) - if a:bang || args[0] =~# '^-p$\|^--paginate$\|diff\%(tool\)\@!\|log\|^show$' || - \ (args[0] ==# 'stash' && get(args, 1, '') ==# 'show') || - \ (args[0] ==# 'help' || get(args, 1, '') ==# '--help') && !s:HasOpt(args, '--web') - if args[0] =~# '^-p$\|^--paginate$' - call remove(args, 0) + let env = get(overrides, 'env', {}) + let i = 0 + while i < len(flags) - 1 + if flags[i] ==# '-c' + let i += 1 + let config_name = tolower(matchstr(flags[i], '^[^=]\+')) + if has_key(s:prepare_env, config_name) && flags[i] =~# '=.' + let env[s:prepare_env[config_name]] = matchstr(flags[i], '=\zs.*') + endif + if flags[i] =~# '=' + let config[config_name] = [matchstr(flags[i], '=\zs.*')] + else + let config[config_name] = [1] + endif + endif + let i += 1 + endwhile + let editcmd = a:line2 ? 'split' : 'edit' + if pager is# 1 + if a:bang && a:line2 >= 0 + let editcmd = 'read' + elseif a:bang + let editcmd = 'pedit' + endif + elseif pager is# -1 + let pager = fugitive#PagerFor(args, config) + if a:bang && pager isnot# 1 + return 'echoerr ' . string('fugitive: :Git! for temp buffer output has been replaced by :Git --paginate') + endif + endif + if pager is# 1 + if editcmd ==# 'read' + return s:ReadExec(a:line1, a:line2, a:range, a:mods, env, args, options) . after + else + return s:OpenExec(editcmd, a:mods, env, args, options) . after endif - return s:OpenExec((a:line2 > 0 ? a:line2 : '') . (a:line2 ? 'split' : 'edit'), a:mods, args, dir) . after endif if s:HasOpt(args, ['add', 'checkout', 'commit', 'stage', 'stash', 'reset'], '-p', '--patch') || - \ s:HasOpt(args, ['add', 'clean', 'stage'], '-i', '--interactive') + \ s:HasOpt(args, ['add', 'clean', 'stage'], '-i', '--interactive') || + \ type(pager) == type('') let mods = substitute(s:Mods(a:mods), '\', '-tab', 'g') let assign = len(dir) ? '|let b:git_dir = ' . string(dir) : '' if has('nvim') if &autowrite || &autowriteall | silent! wall | endif - return mods . (a:line2 ? 'split' : 'edit') . ' term://' . s:fnameescape(s:UserCommand(dir, args)) . assign . '|startinsert' . after + return mods . (a:line2 ? 'split' : 'edit') . ' term://' . s:fnameescape(s:UserCommand(options, args)) . assign . '|startinsert' . after elseif has('terminal') if &autowrite || &autowriteall | silent! wall | endif - return 'exe ' . string(mods . 'terminal ' . (a:line2 ? '' : '++curwin ') . join(map(s:UserCommandList(dir) + args, 's:fnameescape(v:val)'))) . assign . after + return 'exe ' . string(mods . 'terminal ' . (a:line2 ? '' : '++curwin ') . join(map(s:UserCommandList(options) + args, 's:fnameescape(v:val)'))) . assign . after endif endif - let env = get(opts, 'env', {}) if s:RunJobs() - let state = {'dir': dir, 'mods': s:Mods(a:mods), 'temp': tempname(), 'log': []} + let state = { + \ 'dir': dir, + \ 'mods': s:Mods(a:mods), + \ 'title': ':Git ' . a:arg, + \ 'echo_buffer': '', + \ 'escape_buffer': '', + \ 'log': [], + \ 'temp': tempname()} let state.pty = get(g:, 'fugitive_pty', has('unix') && (has('patch-8.0.0744') || has('nvim'))) if !state.pty let args = s:AskPassArgs(dir) + args @@ -2750,57 +3045,39 @@ function! fugitive#Command(line1, line2, range, bang, mods, arg) abort \ 'GIT_MERGE_AUTOEDIT': '1', \ 'GIT_PAGER': 'cat', \ 'PAGER': 'cat'}, 'keep') - let args = ['-c', 'advice.waitingForEditor=false'] + s:disable_colors + args - let argv = s:UserCommandList(dir) + args - if !has('patch-8.0.0902') || has('nvim') - let envlist = map(items(env), 'join(v:val, "=")') - if s:executable('env') - let argv = ['env'] + envlist + argv - elseif has('win32') - let argv = ['cmd.exe', '/c', - \ join(map(envlist, { _, v -> 'set ' . substitute(v, '[&|<>^]', '^^^&', 'g') }) + - \ [s:shellesc(argv)], '& ')] - else - return 'echoerr ' . string('fugitive: "env" command missing') - endif - let env = {} - endif + let args = s:disable_colors + flags + ['-c', 'advice.waitingForEditor=false'] + args + let argv = s:UserCommandList({'git': git, 'dir': dir}) + args + let [argv, jobopts] = s:JobOpts(argv, env) let state.cmd = argv let g:_fugitive_last_job = state if &autowrite || &autowriteall | silent! wall | endif if exists('*job_start') - let jobopts = { + call extend(jobopts, { \ 'mode': 'raw', \ 'callback': function('s:RunReceive', [state]), - \ } + \ }) if state.pty let jobopts.pty = 1 endif - if len(env) - let jobopts.env = env - endif let job = job_start(argv, jobopts) else - let job = jobstart(argv, { + let job = jobstart(argv, extend(jobopts, { \ 'pty': state.pty, - \ 'env': env, \ 'TERM': 'dumb', \ 'on_stdout': function('s:RunReceive', [state]), \ 'on_stderr': function('s:RunReceive', [state]), - \ }) + \ })) endif let state.job = job call s:RunWait(state, job) return 'silent checktime' . after + elseif has('win32') + return 'echoerr ' . string('fugitive: Vim 8 with job support required to use :Git on Windows') + elseif has('gui_running') + return 'echoerr ' . string('fugitive: Vim 8 with job support required to use :Git in GVim') else - if has('gui_running') && !has('win32') - call insert(args, '--no-pager') - endif - if has('nvim') - let env.GIT_TERMINAL_PROMPT = '0' - endif let pre = s:BuildEnvPrefix(env) - return 'exe ' . string('noautocmd !' . escape(pre . s:UserCommand(dir, args), '!#%')) . + return 'exe ' . string('noautocmd !' . escape(pre . s:UserCommand(options, args), '!#%')) . \ '|call fugitive#ReloadStatus(' . string(dir) . ', 1)' . \ after >>>>>>> 27ad0d07862847896f691309a544a206783c94d6 @@ -2835,28 +3112,34 @@ endfunction let s:aliases = {} function! s:Aliases(dir) abort - if !has_key(s:aliases, a:dir) - let s:aliases[a:dir] = {} + let dir_key = len(a:dir) ? a:dir : '_' + if !has_key(s:aliases, dir_key) + let s:aliases[dir_key] = {} let lines = s:NullError([a:dir, 'config', '-z', '--get-regexp', '^alias[.]'])[0] for line in lines - let s:aliases[a:dir][matchstr(line, '\.\zs.\{-}\ze\n')] = matchstr(line, '\n\zs.*') + let s:aliases[dir_key][matchstr(line, '\.\zs.\{-}\ze\n')] = matchstr(line, '\n\zs.*') endfor endif - return s:aliases[a:dir] + return s:aliases[dir_key] endfunction function! fugitive#Complete(lead, ...) abort - let dir = a:0 == 1 ? a:1 : a:0 == 3 ? a:3 : s:Dir() + let dir = a:0 == 1 ? a:1 : a:0 >= 3 ? a:3 : s:Dir() + let root = a:0 >= 4 ? a:4 : s:Tree(s:Dir()) let pre = a:0 > 1 ? strpart(a:1, 0, a:2) : '' let subcmd = matchstr(pre, '\u\w*[! ] *\zs[[:alnum:]-]\+\ze ') if empty(subcmd) let results = sort(s:Subcommands() + keys(s:Aliases(dir))) + elseif a:0 ==# 2 && subcmd =~# '^\%(commit\|revert\|push\|fetch\|pull\|merge\|rebase\)$' + let cmdline = substitute(a:1, '\u\w*\([! ] *\)' . subcmd, 'G' . subcmd, '') + let caps_subcmd = substitute(subcmd, '\%(^\|-\)\l', '\u&', 'g') + return fugitive#{caps_subcmd}Complete(a:lead, cmdline, a:2 + len(cmdline) - len(a:1), dir, root) elseif pre =~# ' -- ' - return fugitive#CompletePath(a:lead, dir) + return fugitive#CompletePath(a:lead, a:1, a:2, dir, root) elseif a:lead =~# '^-' let results = split(s:ChompDefault('', dir, subcmd, '--git-completion-helper'), ' ') else - return fugitive#CompleteObject(a:lead, dir) + return fugitive#CompleteObject(a:lead, a:1, a:2, dir, root) endif return filter(results, 'strpart(v:val, 0, strlen(a:lead)) ==# a:lead') <<<<<<< HEAD @@ -2868,6 +3151,11 @@ function! fugitive#Complete(...) abort >>>>>>> 27ad0d07862847896f691309a544a206783c94d6 endfunction +function! fugitive#CompleteForWorkingDir(A, L, P, ...) abort + let path = a:0 ? a:1 : getcwd() + return fugitive#Complete(a:A, a:L, a:P, FugitiveExtractGitDir(path), path) +endfunction + " Section: :Gcd, :Glcd function! fugitive#CdComplete(A, L, P) abort @@ -2923,7 +3211,7 @@ function! s:StatusCommand(line1, line2, range, count, bang, mods, reg, arg, args elseif a:bang return mods . 'pedit' . arg . '|wincmd P' else - return mods . (a:count > 0 ? a:count : '') . 'split' . arg + return mods . 'keepalt split' . arg endif catch /^fugitive:/ return 'echoerr ' . string(v:exception) @@ -3727,6 +4015,8 @@ function! s:StageInline(mode, ...) abort endif let start = index let mode = 'head' + elseif mode ==# 'head' && line =~# '^diff ' + let start = index elseif mode ==# 'head' && substitute(line, "\t$", '', '') ==# '--- ' . info.relative[-1] let mode = 'await' elseif mode ==# 'head' && substitute(line, "\t$", '', '') ==# '+++ ' . info.relative[0] @@ -3779,17 +4069,21 @@ function! s:StageDiff(diff) abort ======= if info.sub =~# '^S' if info.section ==# 'Staged' - return 'Git! diff --no-ext-diff --submodule=log --cached -- ' . info.paths[0] + return 'Git --paginate diff --no-ext-diff --submodule=log --cached -- ' . info.paths[0] elseif info.sub =~# '^SC' - return 'Git! diff --no-ext-diff --submodule=log -- ' . info.paths[0] + return 'Git --paginate diff --no-ext-diff --submodule=log -- ' . info.paths[0] else - return 'Git! diff --no-ext-diff --submodule=diff -- ' . info.paths[0] + return 'Git --paginate diff --no-ext-diff --submodule=diff -- ' . info.paths[0] endif elseif empty(info.paths) && info.section ==# 'Staged' +<<<<<<< HEAD >>>>>>> 27ad0d07862847896f691309a544a206783c94d6 return 'Git! diff --no-ext-diff --cached' +======= + return 'Git --paginate diff --no-ext-diff --cached' +>>>>>>> master elseif empty(info.paths) - return 'Git! diff --no-ext-diff' + return 'Git --paginate diff --no-ext-diff' elseif len(info.paths) > 1 execute 'Gedit' . prefix s:fnameescape(':0:' . info.paths[0]) <<<<<<< HEAD @@ -3828,12 +4122,12 @@ function! s:StageDiffEdit() abort let info = s:StageInfo(line('.')) let arg = (empty(info.paths) ? s:Tree() : info.paths[0]) if info.section ==# 'Staged' - return 'Git! diff --no-ext-diff --cached '.s:fnameescape(arg) + return 'Git --paginate diff --no-ext-diff --cached '.s:fnameescape(arg) elseif info.status ==# '?' call s:TreeChomp('add', '--intent-to-add', '--', arg) return s:ReloadStatus() else - return 'Git! diff --no-ext-diff '.s:fnameescape(arg) + return 'Git --paginate diff --no-ext-diff '.s:fnameescape(arg) endif endfunction @@ -3871,7 +4165,12 @@ function! s:StageApply(info, reverse, extra) abort let i = b:fugitive_expanded[info.section][info.filename][0] let head = [] while get(b:fugitive_diff[info.section], i, '@') !~# '^@' - call add(head, b:fugitive_diff[info.section][i]) + let line = b:fugitive_diff[info.section][i] + if line ==# '--- /dev/null' + call add(head, '--- ' . get(b:fugitive_diff[info.section], i + 1, '')[4:-1]) + elseif line !~# '^new file ' + call add(head, line) + endif let i += 1 endwhile call extend(lines, head, 'keep') @@ -4012,6 +4311,23 @@ function! s:DoToggleHeadHeader(value) abort call search('\C^index$', 'wc') endfunction +function! s:DoToggleHelpHeader(value) abort + exe 'help fugitive-map' +endfunction + +function! s:DoStagePushHeader(value) abort + let remote = matchstr(a:value, '\zs[^/]\+\ze/') + if empty(remote) + let remote = '.' + endif + let branch = matchstr(a:value, '\%([^/]\+/\)\=\zs\S\+') + call feedkeys(':Git push ' . remote . ' ' . branch) +endfunction + +function! s:DoTogglePushHeader(value) abort + return s:DoStagePushHeader(a:value) +endfunction + function! s:DoStageUnpushedHeading(heading) abort let remote = matchstr(a:heading, 'to \zs[^/]\+\ze/') if empty(remote) @@ -4055,7 +4371,7 @@ function! s:DoToggleUnpulled(record) abort endfunction function! s:DoUnstageUnpushed(record) abort - call feedkeys(':Git rebase --autosquash ' . a:record.commit . '^') + call feedkeys(':Git -c sequence.editor=true rebase --interactive --autosquash ' . a:record.commit . '^') endfunction function! s:DoToggleStagedHeading(...) abort @@ -4099,7 +4415,7 @@ function! s:DoUnstageStaged(record) abort endfunction function! s:DoToggleUnstaged(record) abort - if a:record.patch && a:record.status !=# 'A' + if a:record.patch return s:StageApply(a:record, 0, ['--cached']) else call s:TreeChomp(['add', '-A', '--'] + a:record.paths) @@ -4173,8 +4489,9 @@ function! s:StagePatch(lnum1,lnum2) abort return s:ReloadStatus() endfunction -" Section: :Gcommit, :Grevert +" Section: :Git commit, :Git revert +<<<<<<< HEAD <<<<<<< HEAD function! s:CommitCommand(line1, line2, range, count, bang, mods, reg, arg, args, ...) abort let mods = substitute(s:Mods(a:mods), '\C\', '-tab', 'g') @@ -4286,6 +4603,10 @@ function! s:CommitComplete(A, L, P) abort ======= function! s:CommitInteractive(line1, line2, range, bang, mods, args, patch) abort let status = s:StatusCommand(a:line1, a:line2, a:range, a:line2, a:bang, a:mods, '', '', []) +======= +function! s:CommitInteractive(line1, line2, range, bang, mods, options, patch) abort + let status = s:StatusCommand(a:line1, a:line2, a:range, a:line2, a:bang, a:mods, '', '', [], a:options.dir) +>>>>>>> master let status = len(status) ? status . '|' : '' if a:patch return status . 'if search("^Unstaged")|exe "normal >"|exe "+"|endif' @@ -4294,8 +4615,8 @@ function! s:CommitInteractive(line1, line2, range, bang, mods, args, patch) abor endif endfunction -function! s:CommitSubcommand(line1, line2, range, bang, mods, args) abort - let argv = copy(a:args) +function! s:CommitSubcommand(line1, line2, range, bang, mods, options) abort + let argv = copy(a:options.args) let i = 0 while get(argv, i, '--') !=# '--' if argv[i] =~# '^-[apzsneiovq].' @@ -4306,22 +4627,27 @@ function! s:CommitSubcommand(line1, line2, range, bang, mods, args) abort endif endwhile if s:HasOpt(argv, '-i', '--interactive') - return s:CommitInteractive(a:line1, a:line2, a:range, a:bang, a:mods, argv, 0) + return s:CommitInteractive(a:line1, a:line2, a:range, a:bang, a:mods, a:options, 0) elseif s:HasOpt(argv, '-p', '--patch') - return s:CommitInteractive(a:line1, a:line2, a:range, a:bang, a:mods, argv, 1) + return s:CommitInteractive(a:line1, a:line2, a:range, a:bang, a:mods, a:options, 1) else return {} endif endfunction -function! s:RevertSubcommand(line1, line2, range, bang, mods, args) abort - return {'args': ['revert', '--edit'] + a:args} +function! s:RevertSubcommand(line1, line2, range, bang, mods, options) abort + return {'insert_args': ['--edit']} endfunction +<<<<<<< HEAD function! fugitive#CommitComplete(A, L, P) abort >>>>>>> 27ad0d07862847896f691309a544a206783c94d6 +======= +function! fugitive#CommitComplete(A, L, P, ...) abort + let dir = a:0 ? a:1 : s:Dir() +>>>>>>> master if a:A =~# '^--fixup=\|^--squash=' - let commits = s:LinesError(['log', '--pretty=format:%s', '@{upstream}..'])[0] + let commits = s:LinesError([dir, 'log', '--pretty=format:%s', '@{upstream}..'])[0] let pre = matchstr(a:A, '^--\w*=''\=') . ':/^' if pre =~# "'" call map(commits, 'pre . string(tr(v:val, "|\"^$*[]", "......."))[1:-1]') @@ -4331,15 +4657,20 @@ function! fugitive#CommitComplete(A, L, P) abort return s:FilterEscape(map(commits, 'pre . tr(v:val, "\\ !^$*?[]()''\"`&;<>|#", "....................")'), a:A) endif else +<<<<<<< HEAD <<<<<<< HEAD return s:CompleteSubcommand('commit', a:A, a:L, a:P, function('fugitive#CompletePath')) ======= return s:CompleteSub('commit', a:A, a:L, a:P, function('fugitive#CompletePath')) >>>>>>> 27ad0d07862847896f691309a544a206783c94d6 +======= + return s:CompleteSub('commit', a:A, a:L, a:P, function('fugitive#CompletePath'), a:000) +>>>>>>> master endif return [] endfunction +<<<<<<< HEAD <<<<<<< HEAD function! s:FinishCommit() abort let buf = +expand('') @@ -4377,31 +4708,42 @@ function! s:PullComplete(A, L, P) abort ======= function! fugitive#MergeComplete(A, L, P) abort return s:CompleteSub('merge', a:A, a:L, a:P, function('s:CompleteRevision')) +======= +function! fugitive#RevertComplete(A, L, P, ...) abort + return s:CompleteSub('revert', a:A, a:L, a:P, function('s:CompleteRevision'), a:000) endfunction -function! fugitive#RebaseComplete(A, L, P) abort - return s:CompleteSub('rebase', a:A, a:L, a:P, function('s:CompleteRevision')) +" Section: :Git merge, :Git rebase, :Git pull + +function! fugitive#MergeComplete(A, L, P, ...) abort + return s:CompleteSub('merge', a:A, a:L, a:P, function('s:CompleteRevision'), a:000) +>>>>>>> master endfunction -function! fugitive#PullComplete(A, L, P) abort - return s:CompleteSub('pull', a:A, a:L, a:P, function('s:CompleteRemote')) +function! fugitive#RebaseComplete(A, L, P, ...) abort + return s:CompleteSub('rebase', a:A, a:L, a:P, function('s:CompleteRevision'), a:000) endfunction -function! s:MergeSubcommand(line1, line2, range, bang, mods, args) abort - let dir = s:Dir() - if empty(a:args) && ( +function! fugitive#PullComplete(A, L, P, ...) abort + return s:CompleteSub('pull', a:A, a:L, a:P, function('s:CompleteRemote'), a:000) +endfunction + +function! s:MergeSubcommand(line1, line2, range, bang, mods, options) abort + let dir = a:options.dir + if empty(a:options.args) && ( \ filereadable(fugitive#Find('.git/MERGE_MSG', dir)) || \ isdirectory(fugitive#Find('.git/rebase-apply', dir)) || \ !empty(s:TreeChomp(dir, 'diff-files', '--diff-filter=U'))) - return 'echohl WarningMsg|echo ":Git merge for loading conflicts is deprecated in favor of :Git mergetool"|echohl NONE|silent Git' . (a:bang ? '!' : '') . ' mergetool' + return 'echohl WarningMsg|echo ":Git merge for loading conflicts is deprecated in favor of :Git mergetool"|echohl NONE|silent Git' . (a:bang ? '!' : '') . s:fnameescape(a:options.flags + ['mergetool']) endif return {} >>>>>>> 27ad0d07862847896f691309a544a206783c94d6 endfunction -function! s:RebaseSubcommand(line1, line2, range, bang, mods, args) abort - if s:HasOpt(a:args, '--autosquash') && !s:HasOpt(a:args, '-i', '--interactive') - return {'env': {'GIT_SEQUENCE_EDITOR': 'true'}, 'args': ['rebase', '--interactive'] + a:args} +function! s:RebaseSubcommand(line1, line2, range, bang, mods, options) abort + let args = a:options.args + if s:HasOpt(args, '--autosquash') && !s:HasOpt(args, '-i', '--interactive') + return {'env': {'GIT_SEQUENCE_EDITOR': 'true'}, 'insert_args': ['--interactive']} endif return {} endfunction @@ -4489,7 +4831,7 @@ function! s:ToolParse(state, line) abort return [] endfunction -function! s:ToolStream(dir, line1, line2, range, bang, mods, args, state, title) abort +function! s:ToolStream(line1, line2, range, bang, mods, options, args, state) abort let i = 0 let argv = copy(a:args) let prompt = 1 @@ -4523,9 +4865,14 @@ function! s:ToolStream(dir, line1, line2, range, bang, mods, args, state, title) let a:state.mode = 'init' let a:state.from = '' let a:state.to = '' - let exec = s:UserCommandList(a:dir) + ['--no-pager', '-c', 'diff.context=0', 'diff', '--no-ext-diff', '--no-color', '--no-prefix'] + argv + let exec = s:UserCommandList({'git': a:options.git, 'dir': a:options.dir}) + if fugitive#GitVersion(1, 9) || (!s:HasOpt(argv, '--name-status') && !prompt) + let exec += ['-c', 'diff.context=0'] + endif + let exec += a:options.flags + ['--no-pager', 'diff', '--no-ext-diff', '--no-color', '--no-prefix'] + argv if prompt - return s:QuickfixStream(a:line2, 'difftool', a:title, exec, !a:bang, s:function('s:ToolParse'), a:state) + let title = ':Git ' . s:fnameescape(a:options.flags + [a:options.command] + a:options.args) + return s:QuickfixStream(a:line2, 'difftool', title, exec, !a:bang, s:function('s:ToolParse'), a:state) else let filename = '' let cmd = [] @@ -4546,6 +4893,7 @@ function! s:ToolStream(dir, line1, line2, range, bang, mods, args, state, title) endif endfunction +<<<<<<< HEAD <<<<<<< HEAD function! s:RebaseEdit(cmd, dir) abort let rebase_todo = s:fnameescape(fugitive#Find('.git/rebase-merge/git-rebase-todo', a:dir)) @@ -4603,21 +4951,25 @@ function! s:Merge(cmd, bang, mods, args, ...) abort ======= function! s:MergetoolSubcommand(line1, line2, range, bang, mods, args) abort let dir = s:Dir() +======= +function! s:MergetoolSubcommand(line1, line2, range, bang, mods, options) abort + let dir = a:options.dir + exe s:DirCheck(dir) +>>>>>>> master let i = 0 - let argv = copy(a:args) let prompt = 1 - let title = ':Git mergetool' . (len(a:args) ? ' ' . s:fnameescape(a:args) : '') let cmd = ['diff', '--diff-filter=U'] let state = {'name_only': 0} let state.diff = [{'prefix': ':2:', 'module': ':2:'}, {'prefix': ':3:', 'module': ':3:'}, {'prefix': ':(top)'}] call map(state.diff, 'extend(v:val, {"filename": fugitive#Find(v:val.prefix, dir)})') - return s:ToolStream(dir, a:line1, a:line2, a:range, a:bang, a:mods, ['--diff-filter=U'] + a:args, state, title) + return s:ToolStream(a:line1, a:line2, a:range, a:bang, a:mods, a:options, ['--diff-filter=U'] + a:options.args, state) endfunction -function! s:DifftoolSubcommand(line1, line2, range, bang, mods, args) abort - let dir = s:Dir() +function! s:DifftoolSubcommand(line1, line2, range, bang, mods, options) abort + let dir = a:options.dir + exe s:DirCheck(dir) let i = 0 - let argv = copy(a:args) + let argv = copy(a:options.args) let commits = [] let cached = 0 let reverse = 1 @@ -4671,7 +5023,6 @@ function! s:DifftoolSubcommand(line1, line2, range, bang, mods, args) abort endif let i += 1 endwhile - let title = ':Git difftool' . (len(a:args) ? ' ' . s:fnameescape(a:args) : '') if len(merge_base_against) call add(commits, merge_base_against) endif @@ -4806,7 +5157,7 @@ function! s:DifftoolSubcommand(line1, line2, range, bang, mods, args) abort endif call map(commits, 'extend(v:val, {"filename": fugitive#Find(v:val.prefix, dir)})') let state.diff = commits - return s:ToolStream(dir, a:line1, a:line2, a:range, a:bang, a:mods, argv, state, title) + return s:ToolStream(a:line1, a:line2, a:range, a:bang, a:mods, a:options, argv, state) endfunction <<<<<<< HEAD @@ -4911,32 +5262,31 @@ function! s:GrepParseLine(prefix, name_only, dir, line) abort return entry endfunction -function! s:GrepSubcommand(line1, line2, range, bang, mods, args) abort - let dir = s:Dir() +function! s:GrepSubcommand(line1, line2, range, bang, mods, options) abort + let dir = a:options.dir exe s:DirCheck(dir) let listnr = a:line1 == 0 ? a:line1 : a:line2 let cmd = ['--no-pager', 'grep', '-n', '--no-color', '--full-name'] - if fugitive#GitVersion(2, 19) - call add(cmd, '--column') - endif let tree = s:Tree(dir) - let args = a:args + let args = a:options.args + if get(args, 0, '') =~# '^-O\|--open-files-in-pager$' + let args = args[1:-1] + endif let name_only = s:HasOpt(args, '-l', '--files-with-matches', '--name-only', '-L', '--files-without-match') - let title = [listnr < 0 ? ':Ggrep' : ':Glgrep'] + args if listnr > 0 exe listnr 'wincmd w' else call s:BlurStatus() endif redraw - call s:QuickfixCreate(listnr, {'title': (listnr < 0 ? ':Ggrep ' : ':Glgrep ') . s:fnameescape(args)}) + call s:QuickfixCreate(listnr, {'title': (listnr < 0 ? ':Git grep ' : ':0Git grep ') . s:fnameescape(args)}) let tempfile = tempname() let event = listnr < 0 ? 'grep-fugitive' : 'lgrep-fugitive' silent exe s:DoAutocmd('QuickFixCmdPre ' . event) let prefix = FugitiveVimPath(s:HasOpt(args, '--cached') || empty(tree) ? \ 'fugitive://' . dir . '//0/' : \ s:cpath(getcwd(), tree) ? '' : tree . '/') - exe '!' . escape(s:UserCommand(dir, cmd + args), '%#!') + exe '!' . escape(s:UserCommand(a:options, cmd + args), '%#!') \ printf(&shellpipe . (&shellpipe =~# '%s' ? '' : ' %s'), s:shellesc(tempfile)) let list = map(readfile(tempfile), 's:GrepParseLine(prefix, name_only, dir, v:val)') call s:QuickfixSet(listnr, list, 'a') @@ -4951,11 +5301,16 @@ function! s:GrepSubcommand(line1, line2, range, bang, mods, args) abort endif endfunction +function! fugitive#GrepCommand(line1, line2, range, bang, mods, arg) abort + return fugitive#Command(a:line1, a:line2, a:range, a:bang, a:mods, + \ "grep -O " . (fugitive#GitVersion(2, 19) ? "--column " : "") . a:arg) +endfunction + let s:log_diff_context = '{"filename": fugitive#Find(v:val . from, a:dir), "lnum": get(offsets, v:key), "module": strpart(v:val, 0, len(a:state.base_module)) . from}' function! s:LogFlushQueue(state, dir) abort let queue = remove(a:state, 'queue') - if a:state.child_found && get(a:state, 'ignore_summary') + if a:state.child_found && get(a:state, 'ignore_commit') call remove(queue, 0) elseif len(queue) && len(a:state.target) && len(get(a:state, 'parents', [])) let from = substitute(a:state.target, '^/', ':', '') @@ -5117,11 +5472,13 @@ function! fugitive#LogCommand(line1, count, range, bang, mods, args, type) abort let state.ignore_summary = 1 endif endif + let state.ignore_commit = 1 elseif a:count > 0 if !s:HasOpt(args, '--merges', '--no-merges') call insert(extra_args, '--no-merges') endif call add(args, '-L' . a:line1 . ',' . a:count . ':' . path[1:-1]) + let state.ignore_commit = 1 endif if len(path) && empty(filter(copy(args), 'v:val =~# "^[^-]"')) let owner = s:Owner(@%, dir) @@ -5177,7 +5534,7 @@ function! fugitive#LogCommand(line1, count, range, bang, mods, args, type) abort \ args + extra_args + paths + extra_paths) let state.target = path let title = titlepre . (listnr < 0 ? 'Gclog ' : 'Gllog ') . s:fnameescape(args + paths) - if empty(paths + extra_paths) && empty(a:type) && len(s:Relative('/')) + if empty(paths + extra_paths) && empty(a:type) && a:count < 0 && len(s:Relative('/')) let after = '|echohl WarningMsg|echo ' . string('Use :0Glog or :0Gclog for old behavior of targeting current file') . '|echohl NONE' . after endif return s:QuickfixStream(listnr, 'log', title, s:UserCommandList(dir) + cmd, !a:bang, s:function('s:LogParse'), state, dir) . after @@ -5270,7 +5627,7 @@ function! s:OpenParse(args, wants_cmd) abort return [url, pre] endfunction -function! s:DiffClose() abort +function! fugitive#DiffClose() abort let mywinnr = winnr() for winnr in [winnr('#')] + range(winnr('$'),1,-1) if winnr != mywinnr && getwinvar(winnr,'&diff') @@ -5293,11 +5650,12 @@ function! s:BlurStatus() abort belowright new endif if &diff - call s:DiffClose() + call fugitive#DiffClose() endif endif endfunction +<<<<<<< HEAD function! s:OpenExec(cmd, mods, args, ...) abort <<<<<<< HEAD let dir = s:Dir(a:0 ? a:1 : -1) @@ -5311,10 +5669,14 @@ function! s:OpenExec(cmd, mods, args, ...) abort let s:temp_files[s:cpath(temp)] = { 'dir': dir, 'filetype': 'git' } ======= let dir = a:0 ? s:Dir(a:1) : s:Dir() +======= +function! s:OpenExec(cmd, mods, env, args, ...) abort + let options = a:0 ? a:1 : {'dir': s:Dir()} +>>>>>>> master let temp = tempname() let columns = get(g:, 'fugitive_columns', 80) - let env = s:BuildEnvPrefix({'COLUMNS': columns}) - silent! execute '!' . escape(env . s:UserCommand(dir, ['--no-pager'] + a:args), '!#%') . + let env = s:BuildEnvPrefix(extend({'COLUMNS': columns}, a:env)) + silent! execute '!' . escape(env . s:UserCommand(options, ['--no-pager'] + a:args), '!#%') . \ (&shell =~# 'csh' ? ' >& ' . temp : ' > ' . temp . ' 2>&1') redraw! let temp = s:Resolve(temp) @@ -5324,12 +5686,17 @@ function! s:OpenExec(cmd, mods, args, ...) abort else let filetype = 'git' endif +<<<<<<< HEAD let s:temp_files[s:cpath(temp)] = { 'dir': dir, 'filetype': filetype } >>>>>>> 27ad0d07862847896f691309a544a206783c94d6 +======= + let s:temp_files[s:cpath(temp)] = { 'dir': options.dir, 'filetype': filetype } +>>>>>>> master if a:cmd ==# 'edit' call s:BlurStatus() endif silent execute s:Mods(a:mods) . a:cmd temp +<<<<<<< HEAD call fugitive#ReloadStatus(dir, 1) <<<<<<< HEAD return 'echo ' . string(':!' . git . ' ' . args) @@ -5338,12 +5705,16 @@ endfunction function! s:Open(cmd, bang, mods, arg, args) abort ======= return 'echo ' . string(':!' . s:UserCommand(dir, a:args)) +======= + call fugitive#ReloadStatus(options.dir, 1) + return 'echo ' . string(':!' . s:UserCommand(options, a:args)) +>>>>>>> master endfunction function! fugitive#Open(cmd, bang, mods, arg, args) abort >>>>>>> 27ad0d07862847896f691309a544a206783c94d6 if a:bang - return s:OpenExec(a:cmd, a:mods, s:SplitExpand(a:arg, s:Tree())) + return s:OpenExec(a:cmd, a:mods, {}, s:SplitExpand(a:arg, s:Tree())) endif let mods = s:Mods(a:mods) @@ -5366,12 +5737,16 @@ function! fugitive#Open(cmd, bang, mods, arg, args) abort return mods . a:cmd . pre . ' ' . s:fnameescape(file) endfunction +<<<<<<< HEAD <<<<<<< HEAD function! s:ReadCommand(line1, line2, range, count, bang, mods, reg, arg, args) abort let mods = s:Mods(a:mods) let after = a:line2 ======= function! fugitive#ReadCommand(line1, count, range, bang, mods, arg, args) abort +======= +function! s:ReadPrepare(line1, count, range, mods) abort +>>>>>>> master let mods = s:Mods(a:mods) let after = a:count >>>>>>> 27ad0d07862847896f691309a544a206783c94d6 @@ -5383,6 +5758,24 @@ function! fugitive#ReadCommand(line1, count, range, bang, mods, arg, args) abort else let delete = '' endif + if foldlevel(after) + let pre = after . 'foldopen!|' + else + let pre = '' + endif + return [pre . mods . after . 'read', delete . 'diffupdate' . (a:count < 0 ? '|' . line('.') : '')] +endfunction + +function! s:ReadExec(line1, count, range, mods, env, args, options) abort + let [read, post] = s:ReadPrepare(a:line1, a:count, a:range, a:mods) + let env = s:BuildEnvPrefix(extend({'COLUMNS': &tw ? &tw : 80}, a:env)) + silent execute read . '!' escape(env . s:UserCommand(a:options, ['--no-pager'] + a:args), '!#%') + execute post + call fugitive#ReloadStatus(a:options.dir, 1) + return 'redraw|echo '.string(':!'.s:UserCommand(a:options, a:args)) +endfunction + +function! fugitive#ReadCommand(line1, count, range, bang, mods, arg, args) abort if a:bang <<<<<<< HEAD try @@ -5396,12 +5789,17 @@ function! fugitive#ReadCommand(line1, count, range, bang, mods, arg, args) abort ======= let dir = s:Dir() let args = s:SplitExpand(a:arg, s:Tree(dir)) +<<<<<<< HEAD silent execute mods . after . 'read!' escape(s:UserCommand(dir, ['--no-pager'] + args), '!#%') >>>>>>> 27ad0d07862847896f691309a544a206783c94d6 execute delete . 'diffupdate' call fugitive#ReloadStatus(dir, 1) return 'redraw|echo '.string(':!'.s:UserCommand(dir, args)) +======= + return s:ReadExec(a:line1, a:count, a:range, a:mods, {}, args, {'dir': dir}) +>>>>>>> master endif + let [read, post] = s:ReadPrepare(a:line1, a:count, a:range, a:mods) try <<<<<<< HEAD let [file, pre] = s:OpenParse(a:args) @@ -5412,13 +5810,10 @@ function! fugitive#ReadCommand(line1, count, range, bang, mods, arg, args) abort catch /^fugitive:/ return 'echoerr ' . string(v:exception) endtry - if file =~# '^fugitive:' && after is# 0 - return 'exe ' .string(mods . fugitive#FileReadCmd(file, 0, pre)) . '|diffupdate' + if file =~# '^fugitive:' && a:count is# 0 + return 'exe ' .string(s:Mods(a:mods) . fugitive#FileReadCmd(file, 0, pre)) . '|diffupdate' endif - if foldlevel(after) - exe after . 'foldopen!' - endif - return mods . after . 'read' . pre . ' ' . s:fnameescape(file) . '|' . delete . 'diffupdate' . (a:count < 0 ? '|' . line('.') : '') + return read . ' ' . pre . ' ' . s:fnameescape(file) . '|' . post endfunction function! fugitive#EditComplete(A, L, P) abort @@ -5440,12 +5835,10 @@ endfunction " Section: :Gwrite, :Gwq function! fugitive#WriteCommand(line1, line2, range, bang, mods, arg, args) abort - if exists('b:fugitive_commit_arguments') - return 'write|bdelete' - elseif expand('%:t') == 'COMMIT_EDITMSG' && $GIT_INDEX_FILE != '' - return 'wq' + if s:cpath(expand('%:p'), fugitive#Find('.git/COMMIT_EDITMSG')) + return (empty($GIT_INDEX_FILE) ? 'write|bdelete' : 'wq') . (a:bang ? '!' : '') elseif get(b:, 'fugitive_type', '') ==# 'index' - return 'Gcommit' + return 'Git commit' elseif &buftype ==# 'nowrite' && getline(4) =~# '^[+-]\{3\} ' return 'echoerr ' . string('fugitive: :Gwrite from :Git diff has been removed in favor of :Git add --edit') endif @@ -5572,7 +5965,7 @@ endfunction function! fugitive#WqCommand(...) abort let bang = a:4 ? '!' : '' - if exists('b:fugitive_commit_arguments') + if s:cpath(expand('%:p'), fugitive#Find('.git/COMMIT_EDITMSG')) return 'wq'.bang endif let result = call('fugitive#WriteCommand', a:000) @@ -5583,6 +5976,7 @@ function! fugitive#WqCommand(...) abort endif endfunction +<<<<<<< HEAD <<<<<<< HEAD augroup fugitive_commit autocmd! @@ -5599,15 +5993,19 @@ function! s:FetchComplete(A, L, P) abort return s:CompleteSubcommand('fetch', a:A, a:L, a:P, function('s:CompleteRemote')) ======= " Section: :Gpush, :Gfetch +======= +" Section: :Git push, :Git fetch +>>>>>>> master -function! fugitive#PushComplete(A, L, P) abort - return s:CompleteSub('push', a:A, a:L, a:P, function('s:CompleteRemote')) +function! fugitive#PushComplete(A, L, P, ...) abort + return s:CompleteSub('push', a:A, a:L, a:P, function('s:CompleteRemote'), a:000) endfunction -function! fugitive#FetchComplete(A, L, P) abort - return s:CompleteSub('fetch', a:A, a:L, a:P, function('s:CompleteRemote')) +function! fugitive#FetchComplete(A, L, P, ...) abort + return s:CompleteSub('fetch', a:A, a:L, a:P, function('s:CompleteRemote'), a:000) endfunction +<<<<<<< HEAD function! s:AskPassArgs(dir) abort if (len($DISPLAY) || len($TERM_PROGRAM) || has('gui_running')) && fugitive#GitVersion(1, 8) && \ empty($GIT_ASKPASS) && empty($SSH_ASKPASS) && empty(get(fugitive#Config(a:dir), 'core.askpass', [])) @@ -5623,12 +6021,17 @@ endfunction function! s:Dispatch(bang, cmd, args) abort let dir = s:Dir() +======= +function! s:Dispatch(bang, options) abort + let dir = a:options.dir + exe s:DirCheck(dir) +>>>>>>> master let [mp, efm, cc] = [&l:mp, &l:efm, get(b:, 'current_compiler', '')] try let b:current_compiler = 'git' let &l:errorformat = s:common_efm . \ ',%\&git_dir=' . escape(substitute(dir, '%', '%%', 'g'), '\,') - let &l:makeprg = s:UserCommand(dir, s:AskPassArgs(dir) + [a:cmd] + a:args) + let &l:makeprg = s:UserCommand({'git': a:options.git, 'dir': dir}, s:AskPassArgs(dir) + a:options.flags + [a:options.command] + a:options.args) if exists(':Make') == 2 Make return '' @@ -5666,6 +6069,7 @@ function! s:Dispatch(bang, cmd, args) abort endtry endfunction +<<<<<<< HEAD <<<<<<< HEAD call s:command("-nargs=? -bang -complete=customlist,s:PushComplete Gpush execute s:Dispatch('', 'push '.)") call s:command("-nargs=? -bang -complete=customlist,s:FetchComplete Gfetch execute s:Dispatch('', 'fetch '.)") @@ -5678,10 +6082,14 @@ call s:command("-bang -bar -nargs=* -complete=customlist,fugitive#CompleteObject ======= function! s:PushSubcommand(line1, line2, range, bang, mods, args) abort return s:Dispatch(a:bang ? '!' : '', 'push', a:args) +======= +function! s:PushSubcommand(line1, line2, range, bang, mods, options) abort + return s:Dispatch(a:bang ? '!' : '', a:options) +>>>>>>> master endfunction -function! s:FetchSubcommand(line1, line2, range, bang, mods, args) abort - return s:Dispatch(a:bang ? '!' : '', 'fetch', a:args) +function! s:FetchSubcommand(line1, line2, range, bang, mods, options) abort + return s:Dispatch(a:bang ? '!' : '', a:options) endfunction " Section: :Gdiff @@ -5689,11 +6097,11 @@ endfunction augroup fugitive_diff autocmd! - autocmd BufWinLeave * + autocmd BufWinLeave * nested \ if s:can_diffoff(+expand('')) && s:diff_window_count() == 2 | \ call s:diffoff_all(s:Dir(+expand(''))) | \ endif - autocmd BufWinEnter * + autocmd BufWinEnter * nested \ if s:can_diffoff(+expand('')) && s:diff_window_count() == 1 | \ call s:diffoff() | \ endif @@ -5752,25 +6160,30 @@ function! s:diffthis() abort endfunction function! s:diffoff() abort - if exists('w:fugitive_diff_restore') + if exists('w:fugitive_diff_restore') && v:version < 704 execute w:fugitive_diff_restore - unlet w:fugitive_diff_restore - else - diffoff endif + unlet! w:fugitive_diff_restore + diffoff endfunction function! s:diffoff_all(dir) abort let curwin = winnr() for nr in range(1,winnr('$')) if getwinvar(nr, '&diff') && !empty(getwinvar(nr, 'fugitive_diff_restore')) - if nr != winnr() - execute nr.'wincmd w' + if v:version < 704 + if nr != winnr() + execute nr.'wincmd w' + endif + execute w:fugitive_diff_restore endif - call s:diffoff() + call setwinvar(nr, 'fugitive_diff_restore', '') endif endfor - execute curwin.'wincmd w' + if curwin != winnr() + execute curwin.'wincmd w' + endif + diffoff! endfunction function! s:CompareAge(mine, theirs) abort @@ -6011,9 +6424,7 @@ function! s:Move(force, rename, destination) abort if s:DirCommitFile(@%)[1] !~# '^0\=$' || empty(@%) return 'echoerr ' . string('fugitive: mv not supported for this buffer') endif - if a:destination =~# '^\.\.\=\%(/\|$\)' - let destination = simplify(getcwd() . '/' . a:destination) - elseif a:destination =~# '^\a\+:\|^/' + if a:destination =~# '^\a\+:\|^/' let destination = a:destination elseif a:destination =~# '^:/:\=' let destination = s:Tree(dir) . substitute(a:destination, '^:/:\=', '', '') @@ -6022,7 +6433,9 @@ function! s:Move(force, rename, destination) abort elseif a:destination =~# '^:(literal)' let destination = simplify(getcwd() . '/' . matchstr(a:destination, ')\zs.*')) elseif a:rename - let destination = expand('%:p:s?[\/]$??:h') . '/' . a:destination + let destination = simplify(expand('%:p:s?[\/]$??:h') . '/' . a:destination) + elseif a:destination =~# '^\.\.\=\%(/\|$\)' + let destination = simplify(getcwd() . '/' . a:destination) else let destination = s:Tree(dir) . '/' . a:destination endif @@ -6105,14 +6518,14 @@ function! fugitive#DeleteCommand(line1, line2, range, bang, mods, arg, args) abo return s:Remove('bdelete', a:bang) endfunction -" Section: :Gblame +" Section: :Git blame function! s:Keywordprg() abort let args = ' --git-dir='.escape(s:Dir(),"\\\"' ") if has('gui_running') && !has('win32') - return s:UserCommand() . ' --no-pager' . args . ' log -1' + return g:fugitive_git_executable . ' --no-pager' . args . ' log -1' else - return s:UserCommand() . args . ' show' + return g:fugitive_git_executable . args . ' show' endif endfunction @@ -6152,11 +6565,11 @@ endfunction function! s:BlameCommitFileLnum(...) abort let line = a:0 ? a:1 : getline('.') let state = a:0 ? a:2 : s:TempState() - let commit = matchstr(line, '^\^\=\zs\x\+') + let commit = matchstr(line, '^\^\=[?*]*\zs\x\+') if commit =~# '^0\+$' let commit = '' elseif has_key(state, 'blame_reverse_end') - let commit = get(s:LinesError('rev-list', '--ancestry-path', '--reverse', commit . '..' . state.blame_reverse_end)[0], 0, '') + let commit = get(s:LinesError(state.dir, 'rev-list', '--ancestry-path', '--reverse', commit . '..' . state.blame_reverse_end)[0], 0, '') endif let lnum = +matchstr(line, ' \zs\d\+\ze \%((\| *\d\+)\)') let path = matchstr(line, '^\^\=[?*]*\x* \+\%(\d\+ \+\d\+ \+\)\=\zs.\{-\}\ze\s*\d\+ \%((\| *\d\+)\)') @@ -6191,9 +6604,10 @@ function! fugitive#BlameComplete(A, L, P) abort return s:CompleteSub('blame', a:A, a:L, a:P) endfunction -function! s:BlameSubcommand(line1, count, range, bang, mods, args) abort - exe s:DirCheck() - let flags = copy(a:args) +function! s:BlameSubcommand(line1, count, range, bang, mods, options) abort + let dir = s:Dir() + exe s:DirCheck(dir) + let flags = copy(a:options.args) let i = 0 let raw = 0 let commits = [] @@ -6258,7 +6672,7 @@ function! s:BlameSubcommand(line1, count, range, bang, mods, args) abort continue endif try - let dcf = s:DirCommitFile(fugitive#Find(arg)) + let dcf = s:DirCommitFile(fugitive#Find(arg, dir)) if len(dcf[1]) && empty(dcf[2]) call add(commits, remove(flags, i)) continue @@ -6270,13 +6684,13 @@ function! s:BlameSubcommand(line1, count, range, bang, mods, args) abort endif let i += 1 endwhile - let file = substitute(get(files, 0, get(s:TempState(), 'blame_file', s:Relative('./'))), '^\.\%(/\|$\)', '', '') + let file = substitute(get(files, 0, get(s:TempState(), 'blame_file', s:Relative('./', dir))), '^\.\%(/\|$\)', '', '') if empty(commits) && len(files) > 1 call add(commits, remove(files, 1)) endif exe s:BlameLeave() try - let cmd = ['--no-pager', '-c', 'blame.coloring=none', '-c', 'blame.blankBoundary=false', 'blame', '--show-number'] + let cmd = a:options.flags + ['--no-pager', '-c', 'blame.coloring=none', '-c', 'blame.blankBoundary=false', a:options.command, '--show-number'] call extend(cmd, filter(copy(flags), 'v:val !~# "\\v^%(-b|--%(no-)=color-.*|--progress)$"')) if a:count > 0 && empty(ranges) let cmd += ['-L', (a:line1 ? a:line1 : line('.')) . ',' . (a:line1 ? a:line1 : line('.'))] @@ -6290,7 +6704,7 @@ function! s:BlameSubcommand(line1, count, range, bang, mods, args) abort let cmd += ['--contents', '-'] >>>>>>> 27ad0d07862847896f691309a544a206783c94d6 endif - let basecmd = escape(fugitive#Prepare(cmd) . ' -- ' . s:shellesc(len(files) ? files : file), '!#%') + let basecmd = escape(s:UserCommand({'git': a:options.git, 'dir': dir}, cmd + ['--'] + (len(files) ? files : [file])), '!#%') let tempname = tempname() let error = tempname . '.err' let temp = tempname . (raw ? '' : '.fugitiveblame') @@ -6322,7 +6736,7 @@ function! s:BlameSubcommand(line1, count, range, bang, mods, args) abort endfor return '' endif - let temp_state = {'dir': s:Dir(), 'filetype': (raw ? '' : 'fugitiveblame'), 'blame_flags': flags, 'blame_file': file} + let temp_state = {'dir': dir, 'filetype': (raw ? '' : 'fugitiveblame'), 'options': a:options, 'blame_flags': flags, 'blame_file': file} if s:HasOpt(flags, '--reverse') let temp_state.blame_reverse_end = matchstr(get(commits, 0, ''), '\.\.\zs.*') endif @@ -6352,29 +6766,38 @@ function! s:BlameSubcommand(line1, count, range, bang, mods, args) abort if a:mods =~# '\' silent tabedit % endif + let bufnr = bufnr('') + let temp_state.bufnr = bufnr + let restore = [] let mods = substitute(a:mods, '\', '', 'g') for winnr in range(winnr('$'),1,-1) if getwinvar(winnr, '&scrollbind') - call setwinvar(winnr, '&scrollbind', 0) + if !&l:scrollbind + call setwinvar(winnr, '&scrollbind', 0) + elseif winnr != winnr() && getwinvar(winnr, '&foldenable') + call setwinvar(winnr, '&foldenable', 0) + call add(restore, 'call setwinvar(bufwinnr('.winbufnr(winnr).'),"&foldenable",1)') + endif endif - if exists('+cursorbind') && getwinvar(winnr, '&cursorbind') + if exists('+cursorbind') && !&l:cursorbind && getwinvar(winnr, '&cursorbind') call setwinvar(winnr, '&cursorbind', 0) endif if s:BlameBufnr(winbufnr(winnr)) > 0 execute winbufnr(winnr).'bdelete' endif endfor - let bufnr = bufnr('') - let temp_state.bufnr = bufnr - let restore = 'call setwinvar(bufwinnr('.bufnr.'),"&scrollbind",0)' - if exists('+cursorbind') - let restore .= '|call setwinvar(bufwinnr('.bufnr.'),"&cursorbind",0)' + let restore_winnr = 'bufwinnr(' . bufnr . ')' + if !&l:scrollbind + call add(restore, 'call setwinvar(' . restore_winnr . ',"&scrollbind",0)') + endif + if exists('+cursorbind') && !&l:cursorbind + call add(restore, 'call setwinvar(' . restore_winnr . ',"&cursorbind",0)') endif if &l:wrap - let restore .= '|call setwinvar(bufwinnr('.bufnr.'),"&wrap",1)' + call add(restore, 'call setwinvar(' . restore_winnr . ',"&wrap",1)') endif if &l:foldenable - let restore .= '|call setwinvar(bufwinnr('.bufnr.'),"&foldenable",1)' + call add(restore, 'call setwinvar(' . restore_winnr . ',"&foldenable",1)') endif setlocal scrollbind nowrap nofoldenable if exists('+cursorbind') @@ -6390,8 +6813,12 @@ function! s:BlameSubcommand(line1, count, range, bang, mods, args) abort let b:fugitive_type = 'blame' ======= exe 'silent keepalt' (a:bang ? s:Mods(mods) . 'split' : s:Mods(mods, 'leftabove') . 'vsplit') s:fnameescape(temp) +<<<<<<< HEAD >>>>>>> 27ad0d07862847896f691309a544a206783c94d6 let w:fugitive_leave = restore +======= + let w:fugitive_leave = join(restore, '|') +>>>>>>> master execute top normal! zt execute current @@ -6513,7 +6940,8 @@ function! s:BlameJump(suffix, ...) abort let suffix = '' endif let offset = line('.') - line('w0') - let flags = get(s:TempState(), 'blame_flags', []) + let state = s:TempState() + let flags = get(state, 'blame_flags', []) if a:0 && a:1 if s:HasOpt(flags, '--reverse') call remove(flags, '--reverse') @@ -6532,30 +6960,28 @@ function! s:BlameJump(suffix, ...) abort execute 'Gedit' s:fnameescape(commit . suffix . ':' . path) execute lnum endif - if exists(':Gblame') - let my_bufnr = bufnr('') - if blame_bufnr < 0 - let blame_args = flags + [commit . suffix, '--', path] - let result = s:BlameSubcommand(0, 0, 0, 0, '', blame_args) - else - let blame_args = flags - let result = s:BlameSubcommand(-1, -1, 0, 0, '', blame_args) - endif - if bufnr('') == my_bufnr - return result - endif - execute result - execute lnum - let delta = line('.') - line('w0') - offset - if delta > 0 - execute 'normal! '.delta."\" - elseif delta < 0 - execute 'normal! '.(-delta)."\" - endif - keepjumps syncbind - redraw - echo ':Gblame' s:fnameescape(blame_args) + let my_bufnr = bufnr('') + if blame_bufnr < 0 + let blame_args = flags + [commit . suffix, '--', path] + let result = s:BlameSubcommand(0, 0, 0, 0, '', extend({'args': blame_args}, state.options, 'keep')) + else + let blame_args = flags + let result = s:BlameSubcommand(-1, -1, 0, 0, '', extend({'args': blame_args}, state.options, 'keep')) endif + if bufnr('') == my_bufnr + return result + endif + execute result + execute lnum + let delta = line('.') - line('w0') - offset + if delta > 0 + execute 'normal! '.delta."\" + elseif delta < 0 + execute 'normal! '.(-delta)."\" + endif + keepjumps syncbind + redraw + echo ':Git blame' s:fnameescape(blame_args) return '' endfunction @@ -6563,6 +6989,7 @@ let s:hash_colors = {} function! fugitive#BlameSyntax() abort let conceal = has('conceal') ? ' conceal' : '' +<<<<<<< HEAD <<<<<<< HEAD syn match FugitiveblameBoundary "^\^" syn match FugitiveblameBlank "^\s\+\s\@=" nextgroup=FugitiveblameAnnotation,fugitiveblameOriginalFile,FugitiveblameOriginalLineNumber skipwhite @@ -6576,18 +7003,21 @@ function! fugitive#BlameSyntax() abort exec 'syn match FugitiveblameOriginalLineNumber " *\d\+\%(\s\+\d\+)\)\@=" contained nextgroup=FugitiveblameShort skipwhite' conceal ======= let config = fugitive#Config() +======= +>>>>>>> master let flags = get(s:TempState(), 'blame_flags', []) + syn spell notoplevel syn match FugitiveblameBlank "^\s\+\s\@=" nextgroup=FugitiveblameAnnotation,FugitiveblameScoreDebug,FugitiveblameOriginalFile,FugitiveblameOriginalLineNumber skipwhite syn match FugitiveblameHash "\%(^\^\=[?*]*\)\@<=\<\x\{7,\}\>" nextgroup=FugitiveblameAnnotation,FugitiveblameScoreDebug,FugitiveblameOriginalLineNumber,FugitiveblameOriginalFile skipwhite syn match FugitiveblameUncommitted "\%(^\^\=\)\@<=\<0\{7,\}\>" nextgroup=FugitiveblameAnnotation,FugitiveblameScoreDebug,FugitiveblameOriginalLineNumber,FugitiveblameOriginalFile skipwhite - if get(get(config, 'blame.blankboundary', ['x']), 0, 'x') =~# '^$\|^true$' || s:HasOpt(flags, '-b') + if s:HasOpt(flags, '-b') || FugitiveConfigGet('blame.blankBoundary') =~# '^1$\|^true$' syn match FugitiveblameBoundaryIgnore "^\^[*?]*\x\{7,\}\>" nextgroup=FugitiveblameAnnotation,FugitiveblameScoreDebug,FugitiveblameOriginalLineNumber,FugitiveblameOriginalFile skipwhite else syn match FugitiveblameBoundary "^\^" endif syn match FugitiveblameScoreDebug " *\d\+\s\+\d\+\s\@=" nextgroup=FugitiveblameAnnotation,FugitiveblameOriginalLineNumber,fugitiveblameOriginalFile contained skipwhite syn region FugitiveblameAnnotation matchgroup=FugitiveblameDelimiter start="(" end="\%(\s\d\+\)\@<=)" contained keepend oneline - syn match FugitiveblameTime "[0-9:/+-][0-9:/+ -]*[0-9:/+-]\%(\s\+\d\+)\)\@=" contained containedin=FugitiveblameAnnotation + syn match FugitiveblameTime "\<[0-9:/+-][0-9:/+ -]*[0-9:/+-]\%(\s\+\d\+)\)\@=" contained containedin=FugitiveblameAnnotation exec 'syn match FugitiveblameLineNumber "\s*\d\+)\@=" contained containedin=FugitiveblameAnnotation' conceal exec 'syn match FugitiveblameOriginalFile "\s\%(\f\+\D\@<=\|\D\@=\f\+\)\%(\%(\s\+\d\+\)\=\s\%((\|\s*\d\+)\)\)\@=" contained nextgroup=FugitiveblameOriginalLineNumber,FugitiveblameAnnotation skipwhite' (s:HasOpt(flags, '--show-name', '-f') ? '' : conceal) exec 'syn match FugitiveblameOriginalLineNumber "\s*\d\+\%(\s(\)\@=" contained nextgroup=FugitiveblameAnnotation skipwhite' (s:HasOpt(flags, '--show-number', '-n') ? '' : conceal) @@ -6661,10 +7091,10 @@ function! s:BlameFileType() abort if &modifiable return '' endif - call s:Map('n', '', ':help :Gblame', '') - call s:Map('n', 'g?', ':help :Gblame', '') + call s:Map('n', '', ':help :Git_blame', '') + call s:Map('n', 'g?', ':help :Git_blame', '') if mapcheck('q', 'n') =~# '^$\|bdelete' - call s:Map('n', 'q', ':exe BlameQuit()echohl WarningMsgecho ":Gblame q is deprecated in favor of gq"echohl NONE', '') + call s:Map('n', 'q', ':exe BlameQuit()echohl WarningMsgecho ":Git blame q is deprecated in favor of gq"echohl NONE', '') endif call s:Map('n', 'gq', ':exe BlameQuit()', '') call s:Map('n', '<2-LeftMouse>', ':exe BlameCommit("exe BlameLeave()edit")', '') @@ -6735,6 +7165,9 @@ function! fugitive#BrowseCommand(line1, count, range, bang, mods, arg, args) abo let type = 'blob' endif let path = path[1:-1] + elseif full =~? '^\a\a\+:[\/][\/]' + let path = s:Slash(full) + let type = 'url' elseif empty(s:Tree(dir)) let path = '.git/' . full[strlen(dir)+1:-1] let type = '' @@ -6881,13 +7314,17 @@ function! fugitive#BrowseCommand(line1, count, range, bang, mods, arg, args) abo \ 'line1': line1, \ 'line2': line2} - let url = '' - for Handler in get(g:, 'fugitive_browse_handlers', []) - let url = call(Handler, [copy(opts)]) - if !empty(url) - break - endif - endfor + if type ==# 'url' + let url = path + else + let url = '' + for Handler in get(g:, 'fugitive_browse_handlers', []) + let url = call(Handler, [copy(opts)]) + if !empty(url) + break + endif + endfor + endif if empty(url) call s:throw("No Gbrowse handler installed for '".raw."'") @@ -6918,6 +7355,8 @@ endfunction " Section: Go to file +let s:ref_header = '\%(Merge\|Rebase\|Upstream\|Pull\|Push\)' + nnoremap : :=v:count ? v:count : '' function! fugitive#MapCfile(...) abort exe 'cnoremap ' (a:0 ? a:1 : 'fugitive#Cfile()') @@ -6938,7 +7377,7 @@ endfunction function! s:SquashArgument(...) abort if &filetype == 'fugitive' - let commit = matchstr(getline('.'), '^\%(\%(\x\x\x\)\@!\l\+\s\+\)\=\zs[0-9a-f]\{4,\}\ze ') + let commit = matchstr(getline('.'), '^\%(\%(\x\x\x\)\@!\l\+\s\+\)\=\zs[0-9a-f]\{4,\}\ze \|^' . s:ref_header . ': \zs\S\+') elseif has_key(s:temp_files, s:cpath(expand('%:p'))) let commit = matchstr(getline('.'), '\<\x\{4,\}\>') else @@ -6988,7 +7427,7 @@ function! fugitive#MapJumps(...) abort ======= >>>>>>> 27ad0d07862847896f691309a544a206783c94d6 if get(b:, 'fugitive_type', '') ==# 'blob' - let blame_map = 'Gblame=v:count ? " --reverse" : ""' + let blame_map = 'Git blame=v:count ? " --reverse" : ""' call s:Map('n', '<2-LeftMouse>', ':0,1' . blame_map, '') call s:Map('n', '', ':0,1' . blame_map, '') call s:Map('n', 'o', ':0,2' . blame_map, '') @@ -6996,11 +7435,11 @@ function! fugitive#MapJumps(...) abort call s:Map('n', 'gO', ':0,4' . blame_map, '') call s:Map('n', 'O', ':0,5' . blame_map, '') - call s:Map('n', 'D', ":call DiffClose()Gdiffsplit!redrawechohl WarningMsg echo ':Gstatus D is deprecated in favor of dd'echohl NONE", '') - call s:Map('n', 'dd', ":call DiffClose()Gdiffsplit!", '') - call s:Map('n', 'dh', ":call DiffClose()Ghdiffsplit!", '') - call s:Map('n', 'ds', ":call DiffClose()Ghdiffsplit!", '') - call s:Map('n', 'dv', ":call DiffClose()Gvdiffsplit!", '') + call s:Map('n', 'D', ":call fugitive#DiffClose()Gdiffsplit!redrawechohl WarningMsg echo ':Gstatus D is deprecated in favor of dd'echohl NONE", '') + call s:Map('n', 'dd', ":call fugitive#DiffClose()Gdiffsplit!", '') + call s:Map('n', 'dh', ":call fugitive#DiffClose()Ghdiffsplit!", '') + call s:Map('n', 'ds', ":call fugitive#DiffClose()Ghdiffsplit!", '') + call s:Map('n', 'dv', ":call fugitive#DiffClose()Gvdiffsplit!", '') call s:Map('n', 'd?', ":help fugitive_d", '') else @@ -7054,7 +7493,7 @@ function! fugitive#MapJumps(...) abort call s:Map('nxo', '#', 'PatchSearchExpr(1)', '') endif call s:Map('n', 'S', ':echoerr "Use gO"', '') - call s:Map('n', 'dq', ":call DiffClose()", '') + call s:Map('n', 'dq', ":call fugitive#DiffClose()", '') call s:Map('n', '-', ":exe 'Gedit ' . fnameescape(NavigateUp(v:count1)) if getline(1) =~# '^tree \x\{40,\}$' && empty(getline(2))call search('^'.escape(expand('#:t'),'.*[]~\').'/\=$','wc')endif", '') call s:Map('n', 'P', ":exe 'Gedit ' . fnameescape(ContainingCommit().'^'.v:count1.Relative(':'))", '') call s:Map('n', '~', ":exe 'Gedit ' . fnameescape(ContainingCommit().'~'.v:count1.Relative(':'))", '') @@ -7065,6 +7504,7 @@ function! fugitive#MapJumps(...) abort call s:Map('n', 'gi', ":exe 'Gsplit' (v:count ? '.gitignore' : '.git/info/exclude')", '') call s:Map('x', 'gi', ":exe 'Gsplit' (v:count ? '.gitignore' : '.git/info/exclude')", '') +<<<<<<< HEAD nnoremap c :Git commit nnoremap c :Git commit nnoremap cv :tab Git commit -v @@ -7133,6 +7573,75 @@ function! fugitive#MapJumps(...) abort nnoremap re :Grebase --edit-todo nnoremap ra :Grebase --abort nnoremap r? :help fugitive_r +======= + call s:Map('n', 'c', ':Git commit') + call s:Map('n', 'c', ':Git commit') + call s:Map('n', 'cv', ':tab Git commit -v') + call s:Map('n', 'cv', ':tab Git commit -v') + call s:Map('n', 'ca', ':Git commit --amend', '') + call s:Map('n', 'cc', ':Git commit', '') + call s:Map('n', 'ce', ':Git commit --amend --no-edit', '') + call s:Map('n', 'cw', ':Git commit --amend --only', '') + call s:Map('n', 'cva', ':tab Git commit -v --amend', '') + call s:Map('n', 'cvc', ':tab Git commit -v', '') + call s:Map('n', 'cRa', ':Git commit --reset-author --amend', '') + call s:Map('n', 'cRe', ':Git commit --reset-author --amend --no-edit', '') + call s:Map('n', 'cRw', ':Git commit --reset-author --amend --only', '') + call s:Map('n', 'cf', ':Git commit --fixup==SquashArgument()') + call s:Map('n', 'cF', ':Git -c sequence.editor=true rebase --interactive --autosquash=RebaseArgument()Git commit --fixup==SquashArgument()') + call s:Map('n', 'cs', ':Git commit --no-edit --squash==SquashArgument()') + call s:Map('n', 'cS', ':Git -c sequence.editor=true rebase --interactive --autosquash=RebaseArgument()Git commit --no-edit --squash==SquashArgument()') + call s:Map('n', 'cA', ':Git commit --edit --squash==SquashArgument()') + call s:Map('n', 'c?', ':help fugitive_c', '') + + call s:Map('n', 'cr', ':Git revert') + call s:Map('n', 'cr', ':Git revert') + call s:Map('n', 'crc', ':Git revert =SquashArgument()', '') + call s:Map('n', 'crn', ':Git revert --no-commit =SquashArgument()', '') + call s:Map('n', 'cr?', ':help fugitive_cr', '') + + call s:Map('n', 'cm', ':Git merge') + call s:Map('n', 'cm', ':Git merge') + call s:Map('n', 'cmt', ':Git mergetool') + call s:Map('n', 'cm?', ':help fugitive_cm', '') + + call s:Map('n', 'cz', ':Git stash') + call s:Map('n', 'cz', ':Git stash') + call s:Map('n', 'cza', ':Git stash apply --quiet --index stash@{=v:count}') + call s:Map('n', 'czA', ':Git stash apply --quiet stash@{=v:count}') + call s:Map('n', 'czp', ':Git stash pop --quiet --index stash@{=v:count}') + call s:Map('n', 'czP', ':Git stash pop --quiet stash@{=v:count}') + call s:Map('n', 'czv', ':exe "Gedit" fugitive#RevParse("stash@{" . v:count . "}")', '') + call s:Map('n', 'czw', ':Git stash --keep-index=v:count > 1 ? " --all" : v:count ? " --include-untracked" : ""') + call s:Map('n', 'czz', ':Git stash =v:count > 1 ? " --all" : v:count ? " --include-untracked" : ""') + call s:Map('n', 'cz?', ':help fugitive_cz', '') + + call s:Map('n', 'co', ':Git checkout') + call s:Map('n', 'co', ':Git checkout') + call s:Map('n', 'coo', ':Git checkout =SquashArgument() --') + call s:Map('n', 'co?', ':help fugitive_co', '') + + call s:Map('n', 'cb', ':Git branch') + call s:Map('n', 'cb', ':Git branch') + call s:Map('n', 'cb?', ':help fugitive_cb', '') + + call s:Map('n', 'r', ':Git rebase') + call s:Map('n', 'r', ':Git rebase') + call s:Map('n', 'ri', ':Git rebase --interactive=RebaseArgument()', '') + call s:Map('n', 'rf', ':Git -c sequence.editor=true rebase --interactive --autosquash=RebaseArgument()', '') + call s:Map('n', 'ru', ':Git rebase --interactive @{upstream}', '') + call s:Map('n', 'rp', ':Git rebase --interactive @{push}', '') + call s:Map('n', 'rw', ':Git rebase --interactive=RebaseArgument()s/^pick/reword/e', '') + call s:Map('n', 'rm', ':Git rebase --interactive=RebaseArgument()s/^pick/edit/e', '') + call s:Map('n', 'rd', ':Git rebase --interactive=RebaseArgument()s/^pick/drop/e', '') + call s:Map('n', 'rk', ':Git rebase --interactive=RebaseArgument()s/^pick/drop/e', '') + call s:Map('n', 'rx', ':Git rebase --interactive=RebaseArgument()s/^pick/drop/e', '') + call s:Map('n', 'rr', ':Git rebase --continue', '') + call s:Map('n', 'rs', ':Git rebase --skip', '') + call s:Map('n', 're', ':Git rebase --edit-todo', '') + call s:Map('n', 'ra', ':Git rebase --abort', '') + call s:Map('n', 'r?', ':help fugitive_r', '') +>>>>>>> master call s:Map('n', '.', ": =fnameescape(fugitive#Real(@%))") call s:Map('x', '.', ": =fnameescape(fugitive#Real(@%))") @@ -7158,7 +7667,7 @@ function! s:StatusCfile(...) abort return [lead . info.relative[0]] elseif len(info.commit) return [info.commit] - elseif line =~# '^\%(Head\|Merge\|Rebase\|Upstream\|Pull\|Push\): ' + elseif line =~# '^' . s:ref_header . ': \|^Head: ' return [matchstr(line, ' \zs.*')] else return [''] diff --git a/sources_non_forked/vim-fugitive/doc/fugitive.txt b/sources_non_forked/vim-fugitive/doc/fugitive.txt index 18834513..7a7fb9c6 100644 --- a/sources_non_forked/vim-fugitive/doc/fugitive.txt +++ b/sources_non_forked/vim-fugitive/doc/fugitive.txt @@ -39,19 +39,22 @@ that are part of Git repositories). resume running the command. A few Git subcommands have different behavior; these are documented below. -:Git! {args} Run an arbitrary git command, capture output to a temp -:Git --paginate {args} file, and |:split| that temp file. Use :0Git to -:Git -p {args} |:edit| the temp file instead. A temp file is always - used for diff and log commands. + *:Git_--paginate* *:Git_-p* +:Git --paginate {args} Run an arbitrary git command, capture output to a temp +:Git -p {args} file, and |:split| that temp file. Use :0Git to +:G --paginate {args} |:edit| the temp file instead. A temp file is always +:G -p {args} used for commands like diff and log that typically + user a pager, and for any command that has the + pager. Git configuration option set. - *:Gstatus* -:Git Bring up a summary window vaguely akin to git-status. -:G Press g? or see |fugitive-maps| for usage. -:Gstatus + *fugitive-summary* +:Git With no arguments, bring up a summary window vaguely +:G akin to git-status. Press g? or see |fugitive-maps| + for usage. - *:Git-blame* *:Gblame* + *:Git_blame* :Git blame [flags] Run git-blame [flags] on the current file and open the -:Gblame [flags] results in a scroll-bound vertical split. The + results in a scroll-bound vertical split. The following maps, which work on the cursor line commit where sensible, are provided: @@ -71,11 +74,12 @@ that are part of Git repositories). P reblame at [count]th parent (like HEAD^[count]) >>>>>>> 27ad0d07862847896f691309a544a206783c94d6 -:[range]Gblame [flags] If a range is given, just that part of the file will -:Gblame [flags] {file} be blamed, and a horizontal split without -:Git blame ... scrollbinding is used. You can also give an arbitrary +:[range]Git blame [...] If a range is given, just that part of the file will +:Git blame [...] {file} be blamed, and a horizontal split without + scrollbinding is used. You can also give an arbitrary filename. +<<<<<<< HEAD *:Ggrep* *:Gcgrep* *:Git-grep* :Ggrep[!] [args] |:grep|[!] with git-grep as 'grepprg'. :Git[!] grep [args] @@ -113,6 +117,9 @@ that are part of Git repositories). list, and invoke |:cwindow| to reveal any errors. ======= *:Git-difftool* +======= + *:Git_difftool* +>>>>>>> master :Git[!] difftool [args] Invoke `git diff [args]` and load the changes into the quickfix list. Each changed hunk gets a separate quickfix entry unless you pass an option like @@ -120,28 +127,27 @@ that are part of Git repositories). change unless [!] is given. :Git difftool -y [args] Invoke `git diff [args]`, open each changed file in a - new tab, and invoke `:Gdiffsplit!` against the + new tab, and invoke |:Gdiffsplit!| against the appropriate commit. - *:Git-mergetool* -:Git mergetool [args] Like |:Git-difftool|, but target merge conflicts. + *:Git_mergetool* +:Git mergetool [args] Like |:Git_difftool|, but target merge conflicts. - *:Git-push* *:Gpush* + *:Git_push* :Git push [args] Invoke git-push, load the results into the |quickfix| +<<<<<<< HEAD :Gpush [args] list, and invoke |:cwindow| to reveal any errors. >>>>>>> 27ad0d07862847896f691309a544a206783c94d6 +======= + list, and invoke |:cwindow| to reveal any errors. +>>>>>>> master |:Dispatch| is used if available for asynchronous invocation. - *:Git-fetch* *:Gfetch* -:Git fetch [args] Like |:Gpush|, but for git-fetch. -:Gfetch [args] - - *:Git-merge* *:Gmerge* -:Gmerge [args] Deprecated alias for |:Git| merge. Use |:Git-mergetool| - to get the old behavior of loading merge conflicts - into the quickfix list. + *:Git_fetch* +:Git fetch [args] Like |:Git_push|, but for git-fetch. +<<<<<<< HEAD *:Git-pull* *:Gpull* :Gpull [args] Deprecated alias for |:Git| pull. @@ -158,15 +164,24 @@ that are part of Git repositories). ======= *:Git-commit* *:Gcommit* :Gcommit [args] Deprecated alias for |:Git| commit. +======= + *:Ggrep* *:Gcgrep* *:Git_grep* +:Ggrep[!] [args] |:grep|[!] with git-grep as 'grepprg'. +:Git[!] grep [args] +>>>>>>> master - *:Git-revert* *:Grevert* -:Grevert [args] Deprecated alias for |:Git| revert. + *:Glgrep* +:Glgrep[!] [args] |:lgrep|[!] with git-grep as 'grepprg'. +:0Git[!] grep [args] - *:Gclog* *:Glog* + *:Gclog* :Gclog[!] [args] Use git-log [args] to load the commit history into the -:Glog[!] [args] |quickfix| list. Jumps to the first commit unless [!] + |quickfix| list. Jumps to the first commit unless [!] is given. + The quickfix list can be slow and awkward for many use + cases. Consider using |:Git| log instead. + :{range}Gclog[!] [args] Use git-log -L to load previous revisions of the given >>>>>>> 27ad0d07862847896f691309a544a206783c94d6 range of the current file into the |quickfix| list. @@ -199,6 +214,7 @@ that are part of Git repositories). *:Gpedit* :Gpedit [object] |:pedit| a |fugitive-object|. +<<<<<<< HEAD <<<<<<< HEAD :Gsplit! [args] *fugitive-:Gsplit!* *fugitive-:Gvsplit!* :Gvsplit! [args] *fugitive-:Gtabedit!* *fugitive-:Gpedit!* @@ -211,6 +227,8 @@ that are part of Git repositories). :0Gsplit! to suppress the split and open it in the current window. +======= +>>>>>>> master *:Gread* *fugitive-:Gr* :Gread [object] Empty the buffer and |:read| a |fugitive-object|. When the argument is omitted, this is similar to @@ -289,27 +307,33 @@ that are part of Git repositories). *:Gvdiffsplit* :Gvdiffsplit [object] Like |:Gdiffsplit|, but always split vertically. - *:Ghdiffsplit* *:Gsdiff* + *:Ghdiffsplit* :Ghdiffsplit [object] Like |:Gdiffsplit|, but always split horizontally. +<<<<<<< HEAD *:Gmove* >>>>>>> 27ad0d07862847896f691309a544a206783c94d6 :Gmove {destination} Wrapper around git-mv that renames the buffer +======= + *:GMove* +:GMove {destination} Wrapper around git-mv that renames the buffer +>>>>>>> master afterward. Add a ! to pass -f. - *:Grename* -:Grename {destination} Like |:Gmove| but operates relative to the parent + *:GRename* +:GRename {destination} Like |:GMove| but operates relative to the parent directory of the current file. - *:Gdelete* -:Gdelete Wrapper around git-rm that deletes the buffer + *:GDelete* +:GDelete Wrapper around git-rm that deletes the buffer afterward. When invoked in an index file, --cached is passed. Add a ! to pass -f and forcefully discard the buffer. - *:Gremove* -:Gremove Like :Gdelete, but keep the (now empty) buffer around. + *:GRemove* +:GRemove Like |:GDelete|, but keep the (now empty) buffer around. +<<<<<<< HEAD <<<<<<< HEAD *fugitive-:Gblame* :Gblame [flags] Run git-blame on the file and open the results in a @@ -337,6 +361,10 @@ that are part of Git repositories). *:Gbrowse* >>>>>>> 27ad0d07862847896f691309a544a206783c94d6 :Gbrowse Open the current file, blob, tree, commit, or tag +======= + *:GBrowse* +:GBrowse Open the current file, blob, tree, commit, or tag +>>>>>>> master in your browser at the upstream hosting provider. If a range is given, it is appropriately appended to the URL as an anchor. @@ -346,27 +374,27 @@ that are part of Git repositories). supported by installing rhubarb.vim, available at . -:Gbrowse {object} Like :Gbrowse, but for a given |fugitive-object|. +:GBrowse {object} Like :GBrowse, but for a given |fugitive-object|. -:Gbrowse [...]@{remote} Force using the given remote rather than the remote +:GBrowse [...]@{remote} Force using the given remote rather than the remote for the current branch. The remote is used to determine which upstream repository to link to. -:{range}Gbrowse [args] Appends an anchor to the URL that emphasizes the +:{range}GBrowse [args] Appends an anchor to the URL that emphasizes the selected lines. This also forces the URL to include a commit rather than a branch name so it remains valid if the file changes. You can give a range of "0" to force this behavior without including an anchor. -:[range]Gbrowse! [args] Like :Gbrowse, but put the URL on the clipboard rather +:[range]GBrowse! [args] Like :GBrowse, but put the URL on the clipboard rather than opening it. MAPS *fugitive-maps* -These maps are available in both the |:Gstatus| buffer and Fugitive object -buffers, although not all maps make sense in all buffers. Mappings that -operate on the file or hunk under the cursor are generally available in visual -mode to operate on multiple files or partial hunks. +These maps are available in both the |fugitive-summary| buffer and Fugitive +object buffers, although not all maps make sense in all buffers. Mappings +that operate on the file or hunk under the cursor are generally available in +visual mode to operate on multiple files or partial hunks. *fugitive-staging-maps* Staging/unstaging maps ~ @@ -522,7 +550,7 @@ i Jump to the next file or hunk, expanding inline diffs ][ Jump [count] section ends forward. *fugitive_star* -* One the first column of a + or - diff line, search for +* On the first column of a + or - diff line, search for the corresponding - or + line. Otherwise, defer to built-in |star|. @@ -632,7 +660,7 @@ czz Push stash. Pass a [count] of 1 to add `--include-untracked` or 2 to add `--all`. czw Push stash of worktree. Like `czz` with - `--include-index`. + `--keep-index`. czA Apply topmost stash, or stash@{count}. @@ -741,7 +769,7 @@ Makefile The file named Makefile in the work tree !:Makefile The file named Makefile in the commit owning the current file !3^2 The second parent of the commit owning buffer #3 .git/config The repo config file -: Same as |:Gstatus| +: The |fugitive-summary| buffer. STATUSLINE *fugitive-statusline* @@ -758,6 +786,39 @@ HEAD is detached, FugitiveHead() will return the empty string, unless the optional argument is given, in which case the hash of the current commit will be truncated to the given number of characters. +DEPRECATIONS *fugitive-deprecated* + +The following commands are softly deprecated in favor of replacements that +adhere to a new naming scheme. They will eventually be removed, but probably +not in the near future. + +Remember that |:Git| can be shortened to |:G|, so replacements using it are +just one space character longer than the legacy version. + +*:Gremove* Superseded by |:GRemove|. +*:Gdelete* Superseded by |:GDelete|. +*:Gmove* Superseded by |:GMove|. +*:Grename* Superseded by |:GRename|. +*:Gbrowse* Superseded by |:GBrowse|. +*:Gdiff* Superseded by |:Gdiffsplit| +*:Gsdiff* Superseded by |:Ghdiffsplit| +*:Gvdiff* Superseded by |:Gvdiffsplit| or |:vert| |:Gdiffsplit|. +*:Gblame* Superseded by |:Git_blame|. +*:Gcommit* Superseded by |:Git| commit. +*:Gmerge* Superseded by |:Git| merge and |:Git_mergetool|. +*:Gpull* Superseded by |:Git| pull. +*:Grebase* Superseded by |:Git| rebase. +*:Grevert* Superseded by |:Git| revert. +*:Gpush* Superseded by |:Git_push|. +*:Gfetch* Superseded by |:Git_fetch|. +*:Glog* Superseded by |:Gclog|. +*:Gstatus* Superseded by |:Git| (with no arguments). +*:Git!* Superseded by |:Git_--paginate|. +*:Gsplit!* Superseded by |:Git_--paginate|. +*:Gvsplit!* Superseded by :vert Git --paginate. +*:Gtabsplit!* Superseded by :tab Git --paginate. +*:Gpedit!* Superseded by :Git! --paginate. + ABOUT *fugitive-about* Grab the latest version or report a bug on GitHub: diff --git a/sources_non_forked/vim-fugitive/plugin/fugitive.vim b/sources_non_forked/vim-fugitive/plugin/fugitive.vim index 94fc1324..a846dcad 100644 --- a/sources_non_forked/vim-fugitive/plugin/fugitive.vim +++ b/sources_non_forked/vim-fugitive/plugin/fugitive.vim @@ -424,30 +424,34 @@ let s:addr_other = has('patch-8.1.560') ? '-addr=other' : '' let s:addr_tabs = has('patch-7.4.542') ? '-addr=tabs' : '' let s:addr_wins = has('patch-7.4.542') ? '-addr=windows' : '' -exe 'command! -bang -nargs=? -range=-1' s:addr_other '-complete=customlist,fugitive#Complete G exe fugitive#Command(, , +"", 0, "", )' -exe 'command! -bang -nargs=? -range=-1' s:addr_other '-complete=customlist,fugitive#Complete Git exe fugitive#Command(, , +"", 0, "", )' +if exists(':G') != 2 + command! -bang -nargs=? -range=-1 -complete=customlist,fugitive#Complete G exe fugitive#Command(, , +"", 0, "", ) +endif +command! -bang -nargs=? -range=-1 -complete=customlist,fugitive#Complete Git exe fugitive#Command(, , +"", 0, "", ) -exe 'command! -bang -bar -range=-1' s:addr_other 'Gstatus exe fugitive#Command(, , +"", 0, "", )' +if exists(':Gstatus') !=# 2 + exe 'command! -bang -bar -range=-1' s:addr_other 'Gstatus exe fugitive#Command(, , +"", 0, "", )' +endif -exe 'command! -bang -nargs=? -range=-1' s:addr_other '-complete=customlist,fugitive#CommitComplete Gcommit exe fugitive#Command(, , +"", 0, "", "commit " . )' -exe 'command! -bang -nargs=? -range=-1' s:addr_other '-complete=customlist,fugitive#RevertComplete Grevert exe fugitive#Command(, , +"", 0, "", "revert " . )' -exe 'command! -bang -nargs=? -range=-1' s:addr_other '-complete=customlist,fugitive#MergeComplete Gmerge exe fugitive#Command(, , +"", 0, "", "merge " . )' -exe 'command! -bang -nargs=? -range=-1' s:addr_other '-complete=customlist,fugitive#RebaseComplete Grebase exe fugitive#Command(, , +"", 0, "", "rebase " . )' -exe 'command! -bang -nargs=? -range=-1' s:addr_other '-complete=customlist,fugitive#PullComplete Gpull exe fugitive#Command(, , +"", 0, "", "pull " . )' -exe 'command! -bang -nargs=? -range=-1' s:addr_other '-complete=customlist,fugitive#PushComplete Gpush exe fugitive#Command(, , +"", 0, "", "push " . )' -exe 'command! -bang -nargs=? -range=-1' s:addr_other '-complete=customlist,fugitive#FetchComplete Gfetch exe fugitive#Command(, , +"", 0, "", "fetch " . )' -exe 'command! -bang -nargs=? -range=-1 -complete=customlist,fugitive#BlameComplete Gblame exe fugitive#Command(, , +"", 0, "", "blame " . )' +for s:cmd in ['Commit', 'Revert', 'Merge', 'Rebase', 'Pull', 'Push', 'Fetch', 'Blame'] + if exists(':G' . tolower(s:cmd)) != 2 + exe 'command! -bang -nargs=? -range=-1 -complete=customlist,fugitive#' . s:cmd . 'Complete G' . tolower(s:cmd) 'exe fugitive#Command(, , +"", 0, "", "' . tolower(s:cmd) . ' " . )' + endif +endfor +unlet s:cmd exe "command! -bar -bang -nargs=? -complete=customlist,fugitive#CdComplete Gcd exe fugitive#Cd(, 0)" exe "command! -bar -bang -nargs=? -complete=customlist,fugitive#CdComplete Glcd exe fugitive#Cd(, 1)" -exe 'command! -bang -nargs=? -range=-1' s:addr_wins '-complete=customlist,fugitive#GrepComplete Ggrep exe fugitive#Command(, , +"", 0, "", "grep " . )' -exe 'command! -bang -nargs=? -range=-1' s:addr_wins '-complete=customlist,fugitive#GrepComplete Gcgrep exe fugitive#Command(, , +"", 0, "", "grep " . )' -exe 'command! -bang -nargs=? -range=-1' s:addr_wins '-complete=customlist,fugitive#GrepComplete Glgrep exe fugitive#Command(0, > 0 ? : 0, +"", 0, "", "grep " . )' +exe 'command! -bang -nargs=? -range=-1' s:addr_wins '-complete=customlist,fugitive#GrepComplete Ggrep exe fugitive#GrepCommand(, , +"", 0, "", )' +exe 'command! -bang -nargs=? -range=-1' s:addr_wins '-complete=customlist,fugitive#GrepComplete Gcgrep exe fugitive#GrepCommand(, , +"", 0, "", )' +exe 'command! -bang -nargs=? -range=-1' s:addr_wins '-complete=customlist,fugitive#GrepComplete Glgrep exe fugitive#GrepCommand(0, > 0 ? : 0, +"", 0, "", )' exe 'command! -bang -nargs=? -range=-1 -complete=customlist,fugitive#LogComplete Glog :exe fugitive#LogCommand(,,+"",0,"",, "")' exe 'command! -bang -nargs=? -range=-1 -complete=customlist,fugitive#LogComplete Gclog :exe fugitive#LogCommand(,,+"",0,"",, "c")' +exe 'command! -bang -nargs=? -range=-1 -complete=customlist,fugitive#LogComplete GcLog :exe fugitive#LogCommand(,,+"",0,"",, "c")' exe 'command! -bang -nargs=? -range=-1 -complete=customlist,fugitive#LogComplete Gllog :exe fugitive#LogCommand(,,+"",0,"",, "l")' +exe 'command! -bang -nargs=? -range=-1 -complete=customlist,fugitive#LogComplete GlLog :exe fugitive#LogCommand(,,+"",0,"",, "l")' exe 'command! -bar -bang -nargs=* -complete=customlist,fugitive#EditComplete Ge exe fugitive#Open("edit", 0, "", , [])' exe 'command! -bar -bang -nargs=* -complete=customlist,fugitive#EditComplete Gedit exe fugitive#Open("edit", 0, "", , [])' @@ -469,12 +473,27 @@ exe 'command! -bar -bang -nargs=* -complete=customlist,fugitive#EditComplete Gw exe 'command! -bar -bang -nargs=* -complete=customlist,fugitive#EditComplete Gwrite exe fugitive#WriteCommand(, , +"", 0, "", , [])' exe 'command! -bar -bang -nargs=* -complete=customlist,fugitive#EditComplete Gwq exe fugitive#WqCommand( , , +"", 0, "", , [])' -exe 'command! -bar -bang -nargs=0 -complete=customlist,fugitive#CompleteObject Gremove exe fugitive#RemoveCommand(, , +"", 0, "", , [])' -exe 'command! -bar -bang -nargs=0 -complete=customlist,fugitive#CompleteObject Gdelete exe fugitive#DeleteCommand(, , +"", 0, "", , [])' -exe 'command! -bar -bang -nargs=1 -complete=customlist,fugitive#CompleteObject Gmove exe fugitive#MoveCommand( , , +"", 0, "", , [])' -exe 'command! -bar -bang -nargs=1 -complete=customlist,fugitive#RenameComplete Grename exe fugitive#RenameCommand(, , +"", 0, "", , [])' +exe 'command! -bar -bang -nargs=0 -complete=customlist,fugitive#CompleteObject GRemove exe fugitive#RemoveCommand(, , +"", 0, "", , [])' +exe 'command! -bar -bang -nargs=0 -complete=customlist,fugitive#CompleteObject GDelete exe fugitive#DeleteCommand(, , +"", 0, "", , [])' +exe 'command! -bar -bang -nargs=1 -complete=customlist,fugitive#CompleteObject GMove exe fugitive#MoveCommand( , , +"", 0, "", , [])' +exe 'command! -bar -bang -nargs=1 -complete=customlist,fugitive#RenameComplete GRename exe fugitive#RenameCommand(, , +"", 0, "", , [])' +if exists(':Gremove') != 2 + exe 'command! -bar -bang -nargs=0 -complete=customlist,fugitive#CompleteObject Gremove exe fugitive#RemoveCommand(, , +"", 0, "", , [])' +endif +if exists(':Gdelete') != 2 + exe 'command! -bar -bang -nargs=0 -complete=customlist,fugitive#CompleteObject Gdelete exe fugitive#DeleteCommand(, , +"", 0, "", , [])' +endif +if exists(':Gmove') != 2 + exe 'command! -bar -bang -nargs=1 -complete=customlist,fugitive#CompleteObject Gmove exe fugitive#MoveCommand( , , +"", 0, "", , [])' +endif +if exists(':Grename') != 2 + exe 'command! -bar -bang -nargs=1 -complete=customlist,fugitive#RenameComplete Grename exe fugitive#RenameCommand(, , +"", 0, "", , [])' +endif -exe 'command! -bar -bang -range=-1 -nargs=* -complete=customlist,fugitive#CompleteObject Gbrowse exe fugitive#BrowseCommand(, , +"", 0, "", , [])' +exe 'command! -bar -bang -range=-1 -nargs=* -complete=customlist,fugitive#CompleteObject GBrowse exe fugitive#BrowseCommand(, , +"", 0, "", , [])' +if exists(':Gbrowse') != 2 + exe 'command! -bar -bang -range=-1 -nargs=* -complete=customlist,fugitive#CompleteObject Gbrowse exe fugitive#BrowseCommand(, , +"", 0, "", , [])' +endif if get(g:, 'fugitive_no_maps') finish diff --git a/sources_non_forked/vim-fugitive/syntax/fugitive.vim b/sources_non_forked/vim-fugitive/syntax/fugitive.vim index afc0c0bc..e84eba4e 100644 --- a/sources_non_forked/vim-fugitive/syntax/fugitive.vim +++ b/sources_non_forked/vim-fugitive/syntax/fugitive.vim @@ -8,6 +8,9 @@ syn spell notoplevel syn include @fugitiveDiff syntax/diff.vim syn match fugitiveHeader /^[A-Z][a-z][^:]*:/ nextgroup=fugitiveHash,fugitiveSymbolicRef skipwhite +syn match fugitiveBareHeader /^Bare:/ +syn match fugitiveHelpHeader /^Help:/ nextgroup=fugitiveHelpTag skipwhite +syn match fugitiveHelpTag /\S\+/ contained syn region fugitiveSection start=/^\%(.*(\d\+)$\)\@=/ contains=fugitiveHeading end=/^$/ syn cluster fugitiveSection contains=fugitiveSection @@ -20,8 +23,8 @@ syn match fugitiveDone /^done\>/ contained containedin=@fugitiveSection nextgrou syn match fugitiveStop /^stop\>/ contained containedin=@fugitiveSection nextgroup=fugitiveHash skipwhite syn match fugitiveModifier /^[MADRCU?]\{1,2} / contained containedin=@fugitiveSection syn match fugitiveSymbolicRef /\.\@!\%(\.\.\@!\|[^[:space:][:cntrl:]\:.]\)\+\.\@/ contained containedin=@fugitiveSection -syn match fugitiveHash /\<\x\{4,\}\>/ contained +syn match fugitiveHash /^\x\{4,\}\S\@!/ contained containedin=@fugitiveSection +syn match fugitiveHash /\S\@Gist + +- Create a private gist. + + :Gist -p + +- Create a public gist. + (Only relevant if you've set gists to be private by default.) + + :Gist -P + +> This is only relevant if you've set gists to be private by default; +> if you get an empty gist list, try ":Gist --abandon". + +- Create a gist anonymously. + + :Gist -a + +- Create a gist with all open buffers. + + :Gist -m + +- Edit the gist (you need to have opened the gist buffer first). + You can update the gist with the ":w" command within the gist buffer. + + :Gist -e + +- Edit the gist with name 'foo.js' (you need to have opened the gist buffer + first). + + :Gist -e foo.js + +- Post/Edit with the description " (you need to have opened the gist buffer + first). > + + :Gist -s something + :Gist -e -s something + +- Delete the gist (you need to have opened the gist buffer first). + Password authentication is needed. + + :Gist -d + +- Fork the gist (you need to have opened the gist buffer first). + Password authentication is needed. + + :Gist -f + +- Star the gist (you need to have opened the gist buffer first). + Password authentication is needed. + + :Gist +1 + +- Unstar the gist (you need to have opened the gist buffer first). + Password authentication is needed. + + :Gist -1 + +- Get gist XXXXX. + + :Gist XXXXX + +- Get gist XXXXX and add to clipboard. + + :Gist -c XXXXX + +- List your public gists. + + :Gist -l + +- List gists from user "mattn". + + :Gist -l mattn + +- List everyone's gists. + + :Gist -la + +- List gists from your starred gists. + + :Gist -ls + +- Open the gist on browser after you post or update it. + + :Gist -b + +## List Feature + +- Useful mappings on the gist-listing buffer: + - Both `o` or `Enter` open the gist file in a new buffer, and close the + vim-gist listing one. + - `b` opens the gist file in a browser; this is necessary because + `Shift-Enter` (as was originally) only works for GUI vim. + - `y` copies the contents of the selected gist to the clipboard, and + closes the vim-gist buffer. + - `p` pastes the contents of the selected gist to the buffer from where + vim-gist was called, and closes the vim-gist buffer. + - Hitting `Escape` or `Tab` at the vim-gist buffer closes it. + +- Gist listing has fixed-length columns now, more amenable to eye inspection. + Every line on the gist-listing buffer contains the gist id, name and + description, in that order. Columns are now padded and truncated to offer a + faster browsing, in the following way: + - The gist id string is fixed at 32 characters. + - The length (in characters) of the name of the gist is fixed and + can be set by the user using, for example: + + `let g:gistvim_namelength = 20` + + The default value for `gistvim_namelength` is 30. If the gist (file)name + exceeds that length, it is truncated to the specified length. + - Finally, the gist description is truncated in length to fit the remaining + of the line, avoiding wrapped lines that mess up the table layout. + - Note that the gist listing buffer now does not show the field 'code' + (not sure what that did in the first place). + +## Tips: + +If you set g:gist_clip_command, gist.vim will copy the gist code with option +'-c'. + +- Mac: + + let g:gist_clip_command = 'pbcopy' + +- Linux: + + let g:gist_clip_command = 'xclip -selection clipboard' + +- Others (cygwin?): + + let g:gist_clip_command = 'putclip' + +If you want to detect filetype from the filename: + + let g:gist_detect_filetype = 1 + +If you want to open browser after the post: + + let g:gist_open_browser_after_post = 1 + +If you want to change the browser: + + let g:gist_browser_command = 'w3m %URL%' + +or: + + let g:gist_browser_command = 'opera %URL% &' + +On windows, this should work with your user settings. + +If you want to show your private gists with ":Gist -l": + + let g:gist_show_privates = 1 + +If you want your gist to be private by default: + + let g:gist_post_private = 1 + +If you want your gist to be anonymous by default: + + let g:gist_post_anonymous = 1 + +If you want to manipulate multiple files in a gist: + + let g:gist_get_multiplefile = 1 + +If you want to use on GitHub Enterprise: + + let g:gist_api_url = 'http://your-github-enterprise-domain/api/v3' + +You need to either set global git config: + + $ git config --global github.user Username + +## License: + + Copyright 2010 by Yasuhiro Matsumoto + modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + OF THE POSSIBILITY OF SUCH DAMAGE. + + +## Install: + +Copy it to your plugin directory. +gist.vim will create a curl cookie-jar file in your runtimepath. + +- rtp: + - autoload/gist.vim + - plugin/gist.vim + +If you want to uninstall gist.vim, remember to also remove `~/.gist-vim`. + +You need to install webapi-vim also: + + http://www.vim.org/scripts/script.php?script_id=4019 + +If you want to use latest one: + + https://github.com/mattn/webapi-vim + +### Install with [Vundle](https://github.com/gmarik/vundle) + +Add the following lines to your `.vimrc`. + + Bundle 'mattn/webapi-vim' + Bundle 'mattn/vim-gist' + +Now restart Vim and run `:BundleInstall`. + +### Install with [NeoBundle](https://github.com/Shougo/neobundle.vim) + +Add the following line to your `.vimrc`. + + NeoBundle 'mattn/vim-gist', {'depends': 'mattn/webapi-vim'} + +## Requirements: + +- curl command (http://curl.haxx.se/) +- webapi-vim (https://github.com/mattn/webapi-vim) +- and if you want to use your git profile, the git command-line client. + +## Setup: + +This plugin supports both basic and two-factor authentication using GitHub +API v3. The plugin stores its credentials in `~/.gist-vim`. + +First, you need to set your GitHub username in git's global configuration: + + $ git config --global github.user + +Then vim-gist will ask for your password in order to create an access +token. If you have two-factor authentication enabled, vim-gist will also +prompt you to enter the two-factor key you receive. + +NOTE: +If you want you can set it directly to `g:github_user` and `g:gist_token`. + +Whichever type of authentication you use, your GitHub password will not be +stored, only a OAuth access token produced specifically for vim-gist. The +token is stored in `~/.gist-vim`. If you stop using the plugin, you can +easily remove this file. To revoke the associated GitHub token, go to the +list of ["Authorized applications" on GitHub's "Account Settings" +page][uas]. + +[uas]: https://github.com/settings/applications + +**Note:** the username is optional if you only send anonymous gists. diff --git a/sources_non_forked/vim-gist/autoload/gist.vim b/sources_non_forked/vim-gist/autoload/gist.vim new file mode 100644 index 00000000..bfe84a0c --- /dev/null +++ b/sources_non_forked/vim-gist/autoload/gist.vim @@ -0,0 +1,1165 @@ +"============================================================================= +" File: gist.vim +" Author: Yasuhiro Matsumoto +" Last Change: 10-Oct-2016. +" Version: 7.3 +" WebPage: http://github.com/mattn/vim-gist +" License: BSD + +let s:save_cpo = &cpoptions +set cpoptions&vim + +if exists('g:gist_disabled') && g:gist_disabled == 1 + function! gist#Gist(...) abort + endfunction + finish +endif + +if !exists('g:github_user') && !executable('git') + echohl ErrorMsg | echomsg 'Gist: require ''git'' command' | echohl None + finish +endif + +if !executable('curl') + echohl ErrorMsg | echomsg 'Gist: require ''curl'' command' | echohl None + finish +endif + +if globpath(&rtp, 'autoload/webapi/http.vim') ==# '' + echohl ErrorMsg | echomsg 'Gist: require ''webapi'', install https://github.com/mattn/webapi-vim' | echohl None + finish +else + call webapi#json#true() +endif + +let s:gist_token_file = expand(get(g:, 'gist_token_file', '~/.gist-vim')) +let s:system = function(get(g:, 'webapi#system_function', 'system')) + +if !exists('g:github_user') + let g:github_user = substitute(s:system('git config --get github.user'), "\n", '', '') + if strlen(g:github_user) == 0 + let g:github_user = $GITHUB_USER + end +endif + +if !exists('g:gist_api_url') + let g:gist_api_url = substitute(s:system('git config --get github.apiurl'), "\n", '', '') + if strlen(g:gist_api_url) == 0 + let g:gist_api_url = 'https://api.github.com/' + end + if exists('g:github_api_url') && !exists('g:gist_shutup_issue154') + if matchstr(g:gist_api_url, 'https\?://\zs[^/]\+\ze') != matchstr(g:github_api_url, 'https\?://\zs[^/]\+\ze') + echohl WarningMsg + echo '--- Warning ---' + echo 'It seems that you set different URIs for github_api_url/gist_api_url.' + echo 'If you want to remove this message: let g:gist_shutup_issue154 = 1' + echohl None + if confirm('Continue?', '&Yes\n&No') != 1 + let g:gist_disabled = 1 + finish + endif + redraw! + endif + endif +endif +if g:gist_api_url !~# '/$' + let g:gist_api_url .= '/' +endif + +if !exists('g:gist_update_on_write') + let g:gist_update_on_write = 1 +endif + +function! s:get_browser_command() abort + let gist_browser_command = get(g:, 'gist_browser_command', '') + if gist_browser_command ==# '' + if has('win32') || has('win64') + let gist_browser_command = '!start rundll32 url.dll,FileProtocolHandler %URL%' + elseif has('mac') || has('macunix') || has('gui_macvim') || system('uname') =~? '^darwin' + let gist_browser_command = 'open %URL%' + elseif executable('xdg-open') + let gist_browser_command = 'xdg-open %URL%' + elseif executable('firefox') + let gist_browser_command = 'firefox %URL% &' + else + let gist_browser_command = '' + endif + endif + return gist_browser_command +endfunction + +function! s:open_browser(url) abort + let cmd = s:get_browser_command() + if len(cmd) == 0 + redraw + echohl WarningMsg + echo 'It seems that you don''t have general web browser. Open URL below.' + echohl None + echo a:url + return + endif + let quote = &shellxquote == '"' ? "'" : '"' + if cmd =~# '^!' + let cmd = substitute(cmd, '%URL%', '\=quote.a:url.quote', 'g') + silent! exec cmd + elseif cmd =~# '^:[A-Z]' + let cmd = substitute(cmd, '%URL%', '\=a:url', 'g') + exec cmd + else + let cmd = substitute(cmd, '%URL%', '\=quote.a:url.quote', 'g') + call system(cmd) + endif +endfunction + +function! s:shellwords(str) abort + let words = split(a:str, '\%(\([^ \t\''"]\+\)\|''\([^\'']*\)''\|"\(\%([^\"\\]\|\\.\)*\)"\)\zs\s*\ze') + let words = map(words, 'substitute(v:val, ''\\\([\\ ]\)'', ''\1'', "g")') + let words = map(words, 'matchstr(v:val, ''^\%\("\zs\(.*\)\ze"\|''''\zs\(.*\)\ze''''\|.*\)$'')') + return words +endfunction + +function! s:truncate(str, num) + let mx_first = '^\(.\)\(.*\)$' + let str = a:str + let ret = '' + let width = 0 + while 1 + let char = substitute(str, mx_first, '\1', '') + let cells = strdisplaywidth(char) + if cells == 0 || width + cells > a:num + break + endif + let width = width + cells + let ret .= char + let str = substitute(str, mx_first, '\2', '') + endwhile + while width + 1 <= a:num + let ret .= ' ' + let width = width + 1 + endwhile + return ret +endfunction + +function! s:format_gist(gist) abort + let files = sort(keys(a:gist.files)) + if empty(files) + return '' + endif + let file = a:gist.files[files[0]] + let name = file.filename + if has_key(file, 'content') + let code = file.content + let code = "\n".join(map(split(code, "\n"), '" ".v:val'), "\n") + else + let code = '' + endif + let desc = type(a:gist.description)==0 || a:gist.description ==# '' ? '' : a:gist.description + let name = substitute(name, '[\r\n\t]', ' ', 'g') + let name = substitute(name, ' ', ' ', 'g') + let desc = substitute(desc, '[\r\n\t]', ' ', 'g') + let desc = substitute(desc, ' ', ' ', 'g') + " Display a nice formatted (and truncated if needed) table of gists on screen + " Calculate field lengths for gist-listing formatting on screen + redir =>a |exe 'sil sign place buffer='.bufnr('')|redir end + let signlist = split(a, '\n') + let width = winwidth(0) - ((&number||&relativenumber) ? &numberwidth : 0) - &foldcolumn - (len(signlist) > 2 ? 2 : 0) + let idlen = 33 + let namelen = get(g:, 'gist_namelength', 30) + let desclen = width - (idlen + namelen + 10) + return printf('gist: %s %s %s', s:truncate(a:gist.id, idlen), s:truncate(name, namelen), s:truncate(desc, desclen)) +endfunction + +" Note: A colon in the file name has side effects on Windows due to NTFS Alternate Data Streams; avoid it. +let s:bufprefix = 'gist' . (has('unix') ? ':' : '_') +function! s:GistList(gistls, page) abort + if a:gistls ==# '-all' + let url = g:gist_api_url.'gists/public' + elseif get(g:, 'gist_show_privates', 0) && a:gistls ==# 'starred' + let url = g:gist_api_url.'gists/starred' + elseif get(g:, 'gist_show_privates') && a:gistls ==# 'mine' + let url = g:gist_api_url.'gists' + else + let url = g:gist_api_url.'users/'.a:gistls.'/gists' + endif + let winnum = bufwinnr(bufnr(s:bufprefix.a:gistls)) + if winnum != -1 + if winnum != bufwinnr('%') + exe winnum 'wincmd w' + endif + setlocal modifiable + else + if get(g:, 'gist_list_vsplit', 0) + exec 'silent noautocmd vsplit +set\ winfixwidth ' s:bufprefix.a:gistls + elseif get(g:, 'gist_list_rightbelow', 0) + exec 'silent noautocmd rightbelow 5 split +set\ winfixheight ' s:bufprefix.a:gistls + else + exec 'silent noautocmd split' s:bufprefix.a:gistls + endif + endif + if a:page > 1 + let oldlines = getline(0, line('$')) + let url = url . '?page=' . a:page + endif + + setlocal modifiable + let old_undolevels = &undolevels + let oldlines = [] + silent %d _ + + redraw | echon 'Listing gists... ' + let auth = s:GistGetAuthHeader() + if len(auth) == 0 + bw! + redraw + echohl ErrorMsg | echomsg v:errmsg | echohl None + return + endif + let res = webapi#http#get(url, '', { 'Authorization': auth }) + if v:shell_error != 0 + bw! + redraw + echohl ErrorMsg | echomsg 'Gists not found' | echohl None + return + endif + let content = webapi#json#decode(res.content) + if type(content) == 4 && has_key(content, 'message') && len(content.message) + bw! + redraw + echohl ErrorMsg | echomsg content.message | echohl None + if content.message ==# 'Bad credentials' + call delete(s:gist_token_file) + endif + return + endif + + let lines = map(filter(content, '!empty(v:val.files)'), 's:format_gist(v:val)') + call setline(1, split(join(lines, "\n"), "\n")) + + $put='more...' + + let b:gistls = a:gistls + let b:page = a:page + setlocal buftype=nofile bufhidden=hide noswapfile + setlocal cursorline + setlocal nomodified + setlocal nomodifiable + syntax match SpecialKey /^gist:/he=e-1 + syntax match Title /^gist: \S\+/hs=s+5 contains=ALL + nnoremap :call GistListAction(0) + nnoremap o :call GistListAction(0) + nnoremap b :call GistListAction(1) + nnoremap y :call GistListAction(2) + nnoremap p :call GistListAction(3) + nnoremap :bw + nnoremap :call GistListAction(1) + + cal cursor(1+len(oldlines),1) + nohlsearch + redraw | echo '' +endfunction + +function! gist#list_recursively(user, ...) abort + let use_cache = get(a:000, 0, 1) + let limit = get(a:000, 1, -1) + let verbose = get(a:000, 2, 1) + if a:user ==# 'mine' + let url = g:gist_api_url . 'gists' + elseif a:user ==# 'starred' + let url = g:gist_api_url . 'gists/starred' + else + let url = g:gist_api_url.'users/'.a:user.'/gists' + endif + + let auth = s:GistGetAuthHeader() + if len(auth) == 0 + " anonymous user cannot get gists to prevent infinite recursive loading + return [] + endif + + if use_cache && exists('g:gist_list_recursively_cache') + if has_key(g:gist_list_recursively_cache, a:user) + return webapi#json#decode(g:gist_list_recursively_cache[a:user]) + endif + endif + + let page = 1 + let gists = [] + let lastpage = -1 + + function! s:get_lastpage(res) abort + let links = split(a:res.header[match(a:res.header, 'Link')], ',') + let link = links[match(links, 'rel=[''"]last[''"]')] + let page = str2nr(matchlist(link, '\%(page=\)\(\d\+\)')[1]) + return page + endfunction + + if verbose > 0 + redraw | echon 'Loading gists...' + endif + + while limit == -1 || page <= limit + let res = webapi#http#get(url.'?page='.page, '', {'Authorization': auth}) + if limit == -1 + " update limit to the last page + let limit = s:get_lastpage(res) + endif + if verbose > 0 + redraw | echon 'Loading gists... ' . page . '/' . limit . ' pages has loaded.' + endif + let gists = gists + webapi#json#decode(res.content) + let page = page + 1 + endwhile + let g:gist_list_recursively_cache = get(g:, 'gist_list_recursively_cache', {}) + let g:gist_list_recursively_cache[a:user] = webapi#json#encode(gists) + return gists +endfunction + +function! gist#list(user, ...) abort + let page = get(a:000, 0, 0) + if a:user ==# '-all' + let url = g:gist_api_url.'gists/public' + elseif get(g:, 'gist_show_privates', 0) && a:user ==# 'starred' + let url = g:gist_api_url.'gists/starred' + elseif get(g:, 'gist_show_privates') && a:user ==# 'mine' + let url = g:gist_api_url.'gists' + else + let url = g:gist_api_url.'users/'.a:user.'/gists' + endif + + let auth = s:GistGetAuthHeader() + if len(auth) == 0 + return [] + endif + let res = webapi#http#get(url, '', { 'Authorization': auth }) + return webapi#json#decode(res.content) +endfunction + +function! s:GistGetFileName(gistid) abort + let auth = s:GistGetAuthHeader() + if len(auth) == 0 + return '' + endif + let res = webapi#http#get(g:gist_api_url.'gists/'.a:gistid, '', { 'Authorization': auth }) + let gist = webapi#json#decode(res.content) + if has_key(gist, 'files') + return sort(keys(gist.files))[0] + endif + return '' +endfunction + +function! s:GistDetectFiletype(gistid) abort + let auth = s:GistGetAuthHeader() + if len(auth) == 0 + return '' + endif + let res = webapi#http#get(g:gist_api_url.'gists/'.a:gistid, '', { 'Authorization': auth }) + let gist = webapi#json#decode(res.content) + let filename = sort(keys(gist.files))[0] + let ext = fnamemodify(filename, ':e') + if has_key(s:extmap, ext) + let type = s:extmap[ext] + else + let type = get(gist.files[filename], 'type', 'text') + endif + silent! exec 'setlocal ft='.tolower(type) +endfunction + +function! s:GistWrite(fname) abort + if substitute(a:fname, '\\', '/', 'g') == expand("%:p:gs@\\@/@") + if g:gist_update_on_write != 2 || v:cmdbang + Gist -e + else + echohl ErrorMsg | echomsg 'Please type ":w!" to update a gist.' | echohl None + endif + else + exe 'w'.(v:cmdbang ? '!' : '') fnameescape(v:cmdarg) fnameescape(a:fname) + silent! exe 'file' fnameescape(a:fname) + silent! au! BufWriteCmd + endif +endfunction + +function! s:GistGet(gistid, clipboard) abort + redraw | echon 'Getting gist... ' + let res = webapi#http#get(g:gist_api_url.'gists/'.a:gistid, '', { 'Authorization': s:GistGetAuthHeader() }) + if res.status =~# '^2' + try + let gist = webapi#json#decode(res.content) + catch + redraw + echohl ErrorMsg | echomsg 'Gist seems to be broken' | echohl None + return + endtry + if get(g:, 'gist_get_multiplefile', 0) != 0 + let num_file = len(keys(gist.files)) + else + let num_file = 1 + endif + redraw + if num_file > len(keys(gist.files)) + echohl ErrorMsg | echomsg 'Gist not found' | echohl None + return + endif + augroup GistWrite + au! + augroup END + for n in range(num_file) + try + let old_undolevels = &undolevels + let filename = sort(keys(gist.files))[n] + + let winnum = bufwinnr(bufnr(s:bufprefix.a:gistid.'/'.filename)) + if winnum != -1 + if winnum != bufwinnr('%') + exe winnum 'wincmd w' + endif + setlocal modifiable + else + if num_file == 1 + if get(g:, 'gist_edit_with_buffers', 0) + let found = -1 + for wnr in range(1, winnr('$')) + let bnr = winbufnr(wnr) + if bnr != -1 && !empty(getbufvar(bnr, 'gist')) + let found = wnr + break + endif + endfor + if found != -1 + exe found 'wincmd w' + setlocal modifiable + else + if get(g:, 'gist_list_vsplit', 0) + exec 'silent noautocmd rightbelow vnew' + else + exec 'silent noautocmd rightbelow new' + endif + endif + else + silent only! + if get(g:, 'gist_list_vsplit', 0) + exec 'silent noautocmd rightbelow vnew' + else + exec 'silent noautocmd rightbelow new' + endif + endif + else + if get(g:, 'gist_list_vsplit', 0) + exec 'silent noautocmd rightbelow vnew' + else + exec 'silent noautocmd rightbelow new' + endif + endif + setlocal noswapfile + silent exec 'noautocmd file' s:bufprefix.a:gistid.'/'.fnameescape(filename) + endif + set undolevels=-1 + filetype detect + silent %d _ + + let content = gist.files[filename].content + call setline(1, split(content, "\n")) + let b:gist = { + \ 'filename': filename, + \ 'id': gist.id, + \ 'description': gist.description, + \ 'private': gist.public =~# 'true', + \} + catch + let &undolevels = old_undolevels + bw! + redraw + echohl ErrorMsg | echomsg 'Gist contains binary' | echohl None + return + endtry + let &undolevels = old_undolevels + setlocal buftype=acwrite bufhidden=hide noswapfile + setlocal nomodified + doau StdinReadPost,BufRead,BufReadPost + let gist_detect_filetype = get(g:, 'gist_detect_filetype', 0) + if (&ft ==# '' && gist_detect_filetype == 1) || gist_detect_filetype == 2 + call s:GistDetectFiletype(a:gistid) + endif + if a:clipboard + if exists('g:gist_clip_command') + exec 'silent w !'.g:gist_clip_command + elseif has('clipboard') + silent! %yank + + else + %yank + endif + endif + 1 + augroup GistWrite + au! BufWriteCmd call s:GistWrite(expand("")) + augroup END + endfor + else + bw! + redraw + echohl ErrorMsg | echomsg 'Gist not found' | echohl None + return + endif +endfunction + +function! s:GistListAction(mode) abort + let line = getline('.') + let mx = '^gist:\s*\zs\(\w\+\)\ze.*' + if line =~# mx + let gistid = matchstr(line, mx) + if a:mode == 1 + call s:open_browser('https://gist.github.com/' . gistid) + elseif a:mode == 0 + call s:GistGet(gistid, 0) + wincmd w + bw + elseif a:mode == 2 + call s:GistGet(gistid, 1) + " TODO close with buffe rname + bdelete + bdelete + elseif a:mode == 3 + call s:GistGet(gistid, 1) + " TODO close with buffe rname + bdelete + bdelete + normal! "+p + endif + return + endif + if line =~# '^more\.\.\.$' + call s:GistList(b:gistls, b:page+1) + return + endif +endfunction + +function! s:GistUpdate(content, gistid, gistnm, desc) abort + let gist = { 'id': a:gistid, 'files' : {}, 'description': '','public': function('webapi#json#true') } + if exists('b:gist') + if has_key(b:gist, 'filename') && len(a:gistnm) > 0 + let gist.files[b:gist.filename] = { 'content': '', 'filename': b:gist.filename } + let b:gist.filename = a:gistnm + endif + if has_key(b:gist, 'private') && b:gist.private | let gist['public'] = function('webapi#json#false') | endif + if has_key(b:gist, 'description') | let gist['description'] = b:gist.description | endif + if has_key(b:gist, 'filename') | let filename = b:gist.filename | endif + else + let filename = a:gistnm + if len(filename) == 0 | let filename = s:GistGetFileName(a:gistid) | endif + if len(filename) == 0 | let filename = s:get_current_filename(1) | endif + endif + + let auth = s:GistGetAuthHeader() + if len(auth) == 0 + redraw + echohl ErrorMsg | echomsg v:errmsg | echohl None + return + endif + + " Update description + " If no new description specified, keep the old description + if a:desc !=# ' ' + let gist['description'] = a:desc + else + let res = webapi#http#get(g:gist_api_url.'gists/'.a:gistid, '', { 'Authorization': auth }) + if res.status =~# '^2' + let old_gist = webapi#json#decode(res.content) + let gist['description'] = old_gist.description + endif + endif + + let gist.files[filename] = { 'content': a:content, 'filename': filename } + + redraw | echon 'Updating gist... ' + let res = webapi#http#post(g:gist_api_url.'gists/' . a:gistid, + \ webapi#json#encode(gist), { + \ 'Authorization': auth, + \ 'Content-Type': 'application/json', + \}) + if res.status =~# '^2' + let obj = webapi#json#decode(res.content) + let loc = obj['html_url'] + let b:gist = {'id': a:gistid, 'filename': filename} + setlocal nomodified + redraw | echomsg 'Done: '.loc + else + let loc = '' + echohl ErrorMsg | echomsg 'Post failed: ' . res.message | echohl None + endif + return loc +endfunction + +function! s:GistDelete(gistid) abort + let auth = s:GistGetAuthHeader() + if len(auth) == 0 + redraw + echohl ErrorMsg | echomsg v:errmsg | echohl None + return + endif + + redraw | echon 'Deleting gist... ' + let res = webapi#http#post(g:gist_api_url.'gists/'.a:gistid, '', { + \ 'Authorization': auth, + \ 'Content-Type': 'application/json', + \}, 'DELETE') + if res.status =~# '^2' + if exists('b:gist') + unlet b:gist + endif + redraw | echomsg 'Done: ' + else + echohl ErrorMsg | echomsg 'Delete failed: ' . res.message | echohl None + endif +endfunction + +function! s:get_current_filename(no) abort + let filename = expand('%:t') + if len(filename) == 0 && &ft !=# '' + let pair = filter(items(s:extmap), 'v:val[1] == &ft') + if len(pair) > 0 + let filename = printf('gistfile%d%s', a:no, pair[0][0]) + endif + endif + if filename ==# '' + let filename = printf('gistfile%d.txt', a:no) + endif + return filename +endfunction + +function! s:update_GistID(id) abort + let view = winsaveview() + normal! gg + let ret = 0 + if search('\:\s*$') + let line = getline('.') + let line = substitute(line, '\s\+$', '', 'g') + call setline('.', line . ' ' . a:id) + let ret = 1 + endif + call winrestview(view) + return ret +endfunction + +" GistPost function: +" Post new gist to github +" +" if there is an embedded gist url or gist id in your file, +" it will just update it. +" -- by c9s +" +" embedded gist id format: +" +" GistID: 123123 +" +function! s:GistPost(content, private, desc, anonymous) abort + let gist = { 'files' : {}, 'description': '','public': function('webapi#json#true') } + if a:desc !=# ' ' | let gist['description'] = a:desc | endif + if a:private | let gist['public'] = function('webapi#json#false') | endif + let filename = s:get_current_filename(1) + let gist.files[filename] = { 'content': a:content, 'filename': filename } + + let header = {'Content-Type': 'application/json'} + if !a:anonymous + let auth = s:GistGetAuthHeader() + if len(auth) == 0 + redraw + echohl ErrorMsg | echomsg v:errmsg | echohl None + return + endif + let header['Authorization'] = auth + endif + + redraw | echon 'Posting it to gist... ' + let res = webapi#http#post(g:gist_api_url.'gists', webapi#json#encode(gist), header) + if res.status =~# '^2' + let obj = webapi#json#decode(res.content) + let loc = obj['html_url'] + let b:gist = { + \ 'filename': filename, + \ 'id': matchstr(loc, '[^/]\+$'), + \ 'description': gist['description'], + \ 'private': a:private, + \} + if s:update_GistID(b:gist['id']) + Gist -e + endif + redraw | echomsg 'Done: '.loc + else + let loc = '' + echohl ErrorMsg | echomsg 'Post failed: '. res.message | echohl None + endif + return loc +endfunction + +function! s:GistPostBuffers(private, desc, anonymous) abort + let bufnrs = range(1, bufnr('$')) + let bn = bufnr('%') + let query = [] + + let gist = { 'files' : {}, 'description': '','public': function('webapi#json#true') } + if a:desc !=# ' ' | let gist['description'] = a:desc | endif + if a:private | let gist['public'] = function('webapi#json#false') | endif + + let index = 1 + for bufnr in bufnrs + if !bufexists(bufnr) || buflisted(bufnr) == 0 + continue + endif + echo 'Creating gist content'.index.'... ' + silent! exec 'buffer!' bufnr + let content = join(getline(1, line('$')), "\n") + let filename = s:get_current_filename(index) + let gist.files[filename] = { 'content': content, 'filename': filename } + let index = index + 1 + endfor + silent! exec 'buffer!' bn + + let header = {'Content-Type': 'application/json'} + if !a:anonymous + let auth = s:GistGetAuthHeader() + if len(auth) == 0 + redraw + echohl ErrorMsg | echomsg v:errmsg | echohl None + return + endif + let header['Authorization'] = auth + endif + + redraw | echon 'Posting it to gist... ' + let res = webapi#http#post(g:gist_api_url.'gists', webapi#json#encode(gist), header) + if res.status =~# '^2' + let obj = webapi#json#decode(res.content) + let loc = obj['html_url'] + let b:gist = { + \ 'filename': filename, + \ 'id': matchstr(loc, '[^/]\+$'), + \ 'description': gist['description'], + \ 'private': a:private, + \} + if s:update_GistID(b:gist['id']) + Gist -e + endif + redraw | echomsg 'Done: '.loc + else + let loc = '' + echohl ErrorMsg | echomsg 'Post failed: ' . res.message | echohl None + endif + return loc +endfunction + +function! gist#Gist(count, bang, line1, line2, ...) abort + redraw + let bufname = bufname('%') + " find GistID: in content , then we should just update + let gistid = '' + let gistls = '' + let gistnm = '' + let gistdesc = ' ' + let private = get(g:, 'gist_post_private', 0) + let multibuffer = 0 + let clipboard = 0 + let deletepost = 0 + let editpost = 0 + let anonymous = get(g:, 'gist_post_anonymous', 0) + let openbrowser = 0 + let listmx = '^\%(-l\|--list\)\s*\([^\s]\+\)\?$' + let bufnamemx = '^' . s:bufprefix .'\(\zs[0-9a-f]\+\ze\|\zs[0-9a-f]\+\ze[/\\].*\)$' + if strlen(g:github_user) == 0 && anonymous == 0 + echohl ErrorMsg | echomsg 'You have not configured a Github account. Read '':help gist-setup''.' | echohl None + return + endif + if a:bang == '!' + let gistidbuf = '' + elseif bufname =~# bufnamemx + let gistidbuf = matchstr(bufname, bufnamemx) + elseif exists('b:gist') && has_key(b:gist, 'id') + let gistidbuf = b:gist['id'] + else + let gistidbuf = matchstr(join(getline(a:line1, a:line2), "\n"), 'GistID:\s*\zs\w\+') + endif + + let args = (a:0 > 0) ? s:shellwords(a:1) : [] + for arg in args + if arg =~# '^\(-h\|--help\)$\C' + help :Gist + return + elseif arg =~# '^\(-g\|--git\)$\C' && gistidbuf !=# '' && g:gist_api_url ==# 'https://api.github.com/' && has_key(b:, 'gist') && has_key(b:gist, 'id') + echo printf('git clone git@github.com:%s', b:gist['id']) + return + elseif arg =~# '^\(-G\|--gitclone\)$\C' && gistidbuf !=# '' && g:gist_api_url ==# 'https://api.github.com/' && has_key(b:, 'gist') && has_key(b:gist, 'id') + exe '!' printf('git clone git@github.com:%s', b:gist['id']) + return + elseif arg =~# '^\(-la\|--listall\)$\C' + let gistls = '-all' + elseif arg =~# '^\(-ls\|--liststar\)$\C' + let gistls = 'starred' + elseif arg =~# '^\(-l\|--list\)$\C' + if get(g:, 'gist_show_privates') + let gistls = 'mine' + else + let gistls = g:github_user + endif + elseif arg =~# '^\(-m\|--multibuffer\)$\C' + let multibuffer = 1 + elseif arg =~# '^\(-p\|--private\)$\C' + let private = 1 + elseif arg =~# '^\(-P\|--public\)$\C' + let private = 0 + elseif arg =~# '^\(-a\|--anonymous\)$\C' + let anonymous = 1 + elseif arg =~# '^\(-s\|--description\)$\C' + let gistdesc = '' + elseif arg =~# '^\(-c\|--clipboard\)$\C' + let clipboard = 1 + elseif arg =~# '^--rawurl$\C' && gistidbuf !=# '' && g:gist_api_url ==# 'https://api.github.com/' + let gistid = gistidbuf + echo 'https://gist.github.com/raw/'.gistid + return + elseif arg =~# '^\(-d\|--delete\)$\C' && gistidbuf !=# '' + let gistid = gistidbuf + let deletepost = 1 + elseif arg =~# '^\(-e\|--edit\)$\C' + if gistidbuf !=# '' + let gistid = gistidbuf + endif + let editpost = 1 + elseif arg =~# '^\(+1\|--star\)$\C' && gistidbuf !=# '' + let auth = s:GistGetAuthHeader() + if len(auth) == 0 + echohl ErrorMsg | echomsg v:errmsg | echohl None + else + let gistid = gistidbuf + let res = webapi#http#post(g:gist_api_url.'gists/'.gistid.'/star', '', { 'Authorization': auth }, 'PUT') + if res.status =~# '^2' + echomsg 'Starred' gistid + else + echohl ErrorMsg | echomsg 'Star failed' | echohl None + endif + endif + return + elseif arg =~# '^\(-1\|--unstar\)$\C' && gistidbuf !=# '' + let auth = s:GistGetAuthHeader() + if len(auth) == 0 + echohl ErrorMsg | echomsg v:errmsg | echohl None + else + let gistid = gistidbuf + let res = webapi#http#post(g:gist_api_url.'gists/'.gistid.'/star', '', { 'Authorization': auth }, 'DELETE') + if res.status =~# '^2' + echomsg 'Unstarred' gistid + else + echohl ErrorMsg | echomsg 'Unstar failed' | echohl None + endif + endif + return + elseif arg =~# '^\(-f\|--fork\)$\C' && gistidbuf !=# '' + let auth = s:GistGetAuthHeader() + if len(auth) == 0 + echohl ErrorMsg | echomsg v:errmsg | echohl None + return + else + let gistid = gistidbuf + let res = webapi#http#post(g:gist_api_url.'gists/'.gistid.'/fork', '', { 'Authorization': auth }) + if res.status =~# '^2' + let obj = webapi#json#decode(res.content) + let gistid = obj['id'] + else + echohl ErrorMsg | echomsg 'Fork failed' | echohl None + return + endif + endif + elseif arg =~# '^\(-b\|--browser\)$\C' + let openbrowser = 1 + elseif arg !~# '^-' && len(gistnm) == 0 + if gistdesc !=# ' ' + let gistdesc = matchstr(arg, '^\s*\zs.*\ze\s*$') + elseif editpost == 1 || deletepost == 1 + let gistnm = arg + elseif len(gistls) > 0 && arg !=# '^\w\+$\C' + let gistls = arg + elseif arg =~# '^[0-9a-z]\+$\C' + let gistid = arg + else + echohl ErrorMsg | echomsg 'Invalid arguments: '.arg | echohl None + unlet args + return 0 + endif + elseif len(arg) > 0 + echohl ErrorMsg | echomsg 'Invalid arguments: '.arg | echohl None + unlet args + return 0 + endif + endfor + unlet args + "echom "gistid=".gistid + "echom "gistls=".gistls + "echom "gistnm=".gistnm + "echom "gistdesc=".gistdesc + "echom "private=".private + "echom "clipboard=".clipboard + "echom "editpost=".editpost + "echom "deletepost=".deletepost + + if gistidbuf !=# '' && gistid ==# '' && editpost == 0 && deletepost == 0 && anonymous == 0 + let editpost = 1 + let gistid = gistidbuf + endif + + if len(gistls) > 0 + call s:GistList(gistls, 1) + elseif len(gistid) > 0 && editpost == 0 && deletepost == 0 + call s:GistGet(gistid, clipboard) + else + let url = '' + if multibuffer == 1 + let url = s:GistPostBuffers(private, gistdesc, anonymous) + else + if a:count < 1 + let content = join(getline(a:line1, a:line2), "\n") + else + let save_regcont = @" + let save_regtype = getregtype('"') + silent! normal! gvy + let content = @" + call setreg('"', save_regcont, save_regtype) + endif + if editpost == 1 + let url = s:GistUpdate(content, gistid, gistnm, gistdesc) + elseif deletepost == 1 + call s:GistDelete(gistid) + else + let url = s:GistPost(content, private, gistdesc, anonymous) + endif + if a:count >= 1 && get(g:, 'gist_keep_selection', 0) == 1 + silent! normal! gv + endif + endif + if type(url) == 1 && len(url) > 0 + if get(g:, 'gist_open_browser_after_post', 0) == 1 || openbrowser + call s:open_browser(url) + endif + let gist_put_url_to_clipboard_after_post = get(g:, 'gist_put_url_to_clipboard_after_post', 1) + if gist_put_url_to_clipboard_after_post > 0 || clipboard + if gist_put_url_to_clipboard_after_post == 2 + let url = url . "\n" + endif + if exists('g:gist_clip_command') + call system(g:gist_clip_command, url) + elseif has('clipboard') + let @+ = url + else + let @" = url + endif + endif + endif + endif + return 1 +endfunction + +function! s:GistGetAuthHeader() abort + if get(g:, 'gist_use_password_in_gitconfig', 0) != 0 + let password = substitute(system('git config --get github.password'), "\n", '', '') + if password =~# '^!' | let password = system(password[1:]) | endif + return printf('basic %s', webapi#base64#b64encode(g:github_user.':'.password)) + endif + let auth = '' + if !empty(get(g:, 'gist_token', $GITHUB_TOKEN)) + let auth = 'token ' . get(g:, 'gist_token', $GITHUB_TOKEN) + elseif filereadable(s:gist_token_file) + let str = join(readfile(s:gist_token_file), '') + if type(str) == 1 + let auth = str + endif + endif + if len(auth) > 0 + return auth + endif + + redraw + echohl WarningMsg + echo 'Gist.vim requires authorization to use the GitHub API. These settings are stored in "~/.gist-vim". If you want to revoke, do "rm ~/.gist-vim".' + echohl None + let password = inputsecret('GitHub Password for '.g:github_user.':') + if len(password) == 0 + let v:errmsg = 'Canceled' + return '' + endif + let note = 'Gist.vim on '.hostname().' '.strftime('%Y/%m/%d-%H:%M:%S') + let note_url = 'http://www.vim.org/scripts/script.php?script_id=2423' + let insecureSecret = printf('basic %s', webapi#base64#b64encode(g:github_user.':'.password)) + let res = webapi#http#post(g:gist_api_url.'authorizations', webapi#json#encode({ + \ 'scopes' : ['gist'], + \ 'note' : note, + \ 'note_url' : note_url, + \}), { + \ 'Content-Type' : 'application/json', + \ 'Authorization' : insecureSecret, + \}) + let h = filter(res.header, 'stridx(v:val, "X-GitHub-OTP:") == 0') + if len(h) + let otp = inputsecret('OTP:') + if len(otp) == 0 + let v:errmsg = 'Canceled' + return '' + endif + let res = webapi#http#post(g:gist_api_url.'authorizations', webapi#json#encode({ + \ 'scopes' : ['gist'], + \ 'note' : note, + \ 'note_url' : note_url, + \}), { + \ 'Content-Type' : 'application/json', + \ 'Authorization' : insecureSecret, + \ 'X-GitHub-OTP' : otp, + \}) + endif + let authorization = webapi#json#decode(res.content) + if has_key(authorization, 'token') + let secret = printf('token %s', authorization.token) + call writefile([secret], s:gist_token_file) + if !(has('win32') || has('win64')) + call system('chmod go= '.s:gist_token_file) + endif + elseif has_key(authorization, 'message') + let secret = '' + let v:errmsg = authorization.message + endif + return secret +endfunction + +let s:extmap = extend({ +\'.adb': 'ada', +\'.ahk': 'ahk', +\'.arc': 'arc', +\'.as': 'actionscript', +\'.asm': 'asm', +\'.asp': 'asp', +\'.aw': 'php', +\'.b': 'b', +\'.bat': 'bat', +\'.befunge': 'befunge', +\'.bmx': 'bmx', +\'.boo': 'boo', +\'.c-objdump': 'c-objdump', +\'.c': 'c', +\'.cfg': 'cfg', +\'.cfm': 'cfm', +\'.ck': 'ck', +\'.cl': 'cl', +\'.clj': 'clj', +\'.cmake': 'cmake', +\'.coffee': 'coffee', +\'.cpp': 'cpp', +\'.cppobjdump': 'cppobjdump', +\'.cs': 'csharp', +\'.css': 'css', +\'.cw': 'cw', +\'.d-objdump': 'd-objdump', +\'.d': 'd', +\'.darcspatch': 'darcspatch', +\'.diff': 'diff', +\'.duby': 'duby', +\'.dylan': 'dylan', +\'.e': 'e', +\'.ebuild': 'ebuild', +\'.eclass': 'eclass', +\'.el': 'lisp', +\'.erb': 'erb', +\'.erl': 'erlang', +\'.f90': 'f90', +\'.factor': 'factor', +\'.feature': 'feature', +\'.fs': 'fs', +\'.fy': 'fy', +\'.go': 'go', +\'.groovy': 'groovy', +\'.gs': 'gs', +\'.gsp': 'gsp', +\'.haml': 'haml', +\'.hs': 'haskell', +\'.html': 'html', +\'.hx': 'hx', +\'.ik': 'ik', +\'.ino': 'ino', +\'.io': 'io', +\'.j': 'j', +\'.java': 'java', +\'.js': 'javascript', +\'.json': 'json', +\'.jsp': 'jsp', +\'.kid': 'kid', +\'.lhs': 'lhs', +\'.lisp': 'lisp', +\'.ll': 'll', +\'.lua': 'lua', +\'.ly': 'ly', +\'.m': 'objc', +\'.mak': 'mak', +\'.man': 'man', +\'.mao': 'mao', +\'.matlab': 'matlab', +\'.md': 'markdown', +\'.minid': 'minid', +\'.ml': 'ml', +\'.moo': 'moo', +\'.mu': 'mu', +\'.mustache': 'mustache', +\'.mxt': 'mxt', +\'.myt': 'myt', +\'.n': 'n', +\'.nim': 'nim', +\'.nu': 'nu', +\'.numpy': 'numpy', +\'.objdump': 'objdump', +\'.ooc': 'ooc', +\'.parrot': 'parrot', +\'.pas': 'pas', +\'.pasm': 'pasm', +\'.pd': 'pd', +\'.phtml': 'phtml', +\'.pir': 'pir', +\'.pl': 'perl', +\'.po': 'po', +\'.py': 'python', +\'.pytb': 'pytb', +\'.pyx': 'pyx', +\'.r': 'r', +\'.raw': 'raw', +\'.rb': 'ruby', +\'.rhtml': 'rhtml', +\'.rkt': 'rkt', +\'.rs': 'rs', +\'.rst': 'rst', +\'.s': 's', +\'.sass': 'sass', +\'.sc': 'sc', +\'.scala': 'scala', +\'.scm': 'scheme', +\'.scpt': 'scpt', +\'.scss': 'scss', +\'.self': 'self', +\'.sh': 'sh', +\'.sml': 'sml', +\'.sql': 'sql', +\'.st': 'smalltalk', +\'.swift': 'swift', +\'.tcl': 'tcl', +\'.tcsh': 'tcsh', +\'.tex': 'tex', +\'.textile': 'textile', +\'.tpl': 'smarty', +\'.twig': 'twig', +\'.txt' : 'text', +\'.v': 'verilog', +\'.vala': 'vala', +\'.vb': 'vbnet', +\'.vhd': 'vhdl', +\'.vim': 'vim', +\'.weechatlog': 'weechatlog', +\'.xml': 'xml', +\'.xq': 'xquery', +\'.xs': 'xs', +\'.yml': 'yaml', +\}, get(g:, 'gist_extmap', {})) + +let &cpo = s:save_cpo +unlet s:save_cpo + +" vim:set et: diff --git a/sources_non_forked/vim-gist/doc/gist-vim.txt b/sources_non_forked/vim-gist/doc/gist-vim.txt new file mode 100644 index 00000000..88c46d10 --- /dev/null +++ b/sources_non_forked/vim-gist/doc/gist-vim.txt @@ -0,0 +1,358 @@ +*Gist.vim* Vimscript for creating gists (http://gist.github.com) + +Usage |vim-gist-usage| +Tips |vim-gist-tips| +License |vim-gist-license| +Install |vim-gist-install| +Requirements |vim-gist-requirements| +Setup |vim-gist-setup| +FAQ |vim-gist-faq| + +This is a vimscript for creating gists (http://gist.github.com) + +For the latest version please see https://github.com/mattn/vim-gist. + +============================================================================== +USAGE *:Gist* *vim-gist-usage* + +- Post current buffer to gist, using default privacy option. > + + :Gist +< +- Post selected text to gist, using default privacy option. + This applies to all permutations listed below (except multi). > + + :'<,'>Gist +< +- Create a private gist. > + + :Gist -p + :Gist --private +< +- Create a public gist. + (Only relevant if you've set gists to be private by default.) > + + :Gist -P + :Gist --public +< +- Post whole text to gist as public. + This is only relevant if you've set gists to be private by default. +> + :Gist -P +< +- Create a gist anonymously. > + + :Gist -a + :Gist --anonymous +< +- Create a gist with all open buffers. > + + :Gist -m + :Gist --multibuffer +< +- Edit the gist (you need to have opened the gist buffer first). + You can update the gist with the {:w} command within the gist buffer. > + + :Gist -e + :Gist --edit +< +- Edit the gist with name "foo.js" (you need to have opened the gist buffer + first). > + + :Gist -e foo.js +< +- Post/Edit with the description " (you need to have opened the gist buffer + first). > + + :Gist -s something + :Gist --description something + :Gist -e -s something +< +- Delete the gist (you need to have opened the gist buffer first). + Password authentication is needed. > + + :Gist -d + :Gist --delete +< +- Fork the gist (you need to have opened the gist buffer first). + Password authentication is needed. > + + :Gist -f + :Gist --fork +< +- Star the gist (you need to have opened the gist buffer first). + Password authentication is needed. +> + :Gist +1 +< +- Unstar the gist (you need to have opened the gist buffer first). + Password authentication is needed. +> + :Gist -1 +< +- Get gist XXXXX. > + + :Gist XXXXX +< +- Get gist XXXXX and add to clipboard. > + + :Gist -c XXXXX +< +- List your public gists. > + + :Gist -l + :Gist --list +< +- List gists from user "mattn". > + + :Gist -l mattn +< +- List everyone's gists. > + + :Gist -la + :Gist --listall +< +- List gists from your starred gists. +> + :Gist -ls + :Gist --liststar + +- While the gist list is visible, the following mappings apply: + + - 'o' or 'Enter' will open the selected gist file in a new buffer + and close the vim-gist listing split. + - 'b' will open the selected gist file in a browser. If you are in + GUI vim you can also achieve this by pressing 'Shift-Enter'. + - 'y' will copy the contents of the selected gist to the clipboard, + and close the vim-gist listing split. + - 'p' will (copy and) paste the contents of the selected gist to the + buffer from which vim-gist was called, and close the vim-gist + listing split. + - 'Esc' will close the vim-gist listing split without performing any + further action. + +- Open the gist on browser after you post or update it. +> + :Gist -b + :Gist --browser +< +- Post as new gist after editing on the buffer. +> + :Gist! +< +============================================================================== +TIPS *vim-gist-tips* + +If you set "g:gist_clip_command", gist.vim will copy the gist code with option +"-c". + + - Mac: > + let g:gist_clip_command = 'pbcopy' +< + - Linux: > + let g:gist_clip_command = 'xclip -selection clipboard' +< + - Others (cygwin?): > + let g:gist_clip_command = 'putclip' +< +If you want to detect filetype from the filename: > + + let g:gist_detect_filetype = 1 +< +If you want to open the browser after the post: > + + let g:gist_open_browser_after_post = 1 +< +If you want to change the browser: > + + let g:gist_browser_command = 'w3m %URL%' +< +or: > + + let g:gist_browser_command = 'opera %URL% &' +< +On windows, this should work with your user settings. + +If you want to show your private gists with ":Gist -l": > + + let g:gist_show_privates = 1 +< +If you want your gist to be private by default: > + + let g:gist_post_private = 1 +< +If you want your gist to be anonymous by default: > + + let g:gist_post_anonymous = 1 +< +If you want to edit all files for gists containing more than one: > + + let g:gist_get_multiplefile = 1 +< +If you want to use on GitHub Enterprise: > + + let g:gist_api_url = 'http://your-github-enterprise-domain/api/v3' +< +If you want to open gist with current editing buffers: > + + let g:gist_edit_with_buffers = 1 + +If you want to open gist list/buffer as vertical split: > + + let g:gist_list_vsplit = 1 + +If you want to modify filetype for the file on github, or add mapping of +filetype/file-extension: > + + let g:gist_extmap = { ".swift": "swift" } +< + key is file-extension, value is filetype. + +If you want to update a gist, embed > + + GistID: xxxxx +> +in your local file, then call > + + :Gist + +The vim-gist listing split lists gists ids, names (filenames) as well as +their description. This is done following a table layout, with fixed space +for each column. For offering quick browsing, vim-gist will truncate all +output exceeding the available horizontal space, assuring that every gist +listed only takes one line on the table. Although the gist id field width is +fixed internally, the user can define the length of the (file)name field on +the vim-gist listing. This can be done by the following declaration: + + let g:gist_namelength = 20 + +Note that the default value for gist_namelength is 30. Again, if the gist +(file)name exceeds the specified number of characters, it will be truncated. + +If you want to update a gist when only |:w!|: > + + " :w and :w! update a gist. + let g:gist_update_on_write = 1 + + " Only :w! updates a gist. + let g:gist_update_on_write = 2 +> +All other values are treated as 1. +This variable's value is 1 by default. + +============================================================================== +LICENSE *vim-gist-license* + + + Copyright 2010 by Yasuhiro Matsumoto + modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + OF THE POSSIBILITY OF SUCH DAMAGE. + +============================================================================== +INSTALL *vim-gist-install* + +Copy following files into your plugin directory. + +rtp: + - autoload/gist.vim + - plugin/gist.vim + +If you want to uninstall gist.vim, remember to also remove `~/.vim-gist`. + +You need to install webapi-vim also: + + http://www.vim.org/scripts/script.php?script_id=4019 + +If you want to use latest one: + + https://github.com/mattn/webapi-vim + +============================================================================== +REQUIREMENTS *vim-gist-requirements* + + - curl command (http://curl.haxx.se/) + - webapi-vim (https://github.com/mattn/webapi-vim) + - and, if you want to use your git profile, the git command-line client. + +============================================================================== +SETUP *vim-gist-setup* + +This plugin uses GitHub API v3. The authentication value is stored in `~/.vim-gist`. +vim-gist provides two ways to authenticate against the GitHub APIs. + +First, you need to set your GitHub username in global git config: +> + $ git config --global github.user Username +< +Then, gist.vim will ask for your password to create an authorization when you +first use it. The password is not stored and only the OAuth access token will +be kept for later use. You can revoke the token at any time from the list of +"Authorized applications" on GitHub's "Account Settings" page. +(https://github.com/settings/applications) + +If you have two-factor authentication enabled on GitHub, you'll see the message +"Must specify two-factor authentication OTP code." In this case, you need to +create a "Personal Access Token" on GitHub's "Account Settings" page +(https://github.com/settings/applications) and place it in a file +named ~/.vim-gist like this: +> + token xxxxx +< +If you happen to have your password already written in ~/.gitconfig like +below: +> + [github] + password = xxxxx +< +Then, add following into your ~/.vimrc +> + let g:gist_use_password_in_gitconfig = 1 +< +This is not secure at all, so strongly discouraged. + +NOTE: the username is optional if you only send anonymous gists. + +============================================================================== +FAQ *vim-gist-faq* + +Q. :Gist returns a Forbidden error +A. Try deleting ~/.vim-gist and authenticating again. + +============================================================================== +THANKS *vim-gist-thanks* + + AD7six + Bruno Bigras + c9s + Daniel Bretoi + Jeremy Michael Cantrell + Kien N + kongo2002 + MATSUU Takuto + Matthew Weier O'Phinney + ornicar + Roland Schilter + steve + tyru + Will Gray + netj + + vim:tw=78:ts=8:ft=help:norl: diff --git a/sources_non_forked/vim-gist/plugin/gist.vim b/sources_non_forked/vim-gist/plugin/gist.vim new file mode 100644 index 00000000..4d4efe67 --- /dev/null +++ b/sources_non_forked/vim-gist/plugin/gist.vim @@ -0,0 +1,23 @@ +"============================================================================= +" File: gist.vim +" Author: Yasuhiro Matsumoto +" WebPage: http://github.com/mattn/vim-gist +" License: BSD +" GetLatestVimScripts: 2423 1 :AutoInstall: gist.vim +" script type: plugin + +if &compatible || (exists('g:loaded_gist_vim') && g:loaded_gist_vim) + finish +endif +let g:loaded_gist_vim = 1 + +function! s:CompleteArgs(arg_lead,cmdline,cursor_pos) + return filter(copy(["-p", "-P", "-a", "-m", "-e", "-s", "-d", "+1", "-1", "-f", "-c", "-l", "-la", "-ls", "-b", + \ "--listall", "--liststar", "--list", "--multibuffer", "--private", "--public", "--anonymous", "--description", "--clipboard", + \ "--rawurl", "--delete", "--edit", "--star", "--unstar", "--fork", "--browser" + \ ]), 'stridx(v:val, a:arg_lead)==0') +endfunction + +command! -nargs=? -range=% -bang -complete=customlist,s:CompleteArgs Gist :call gist#Gist(, "", , , ) + +" vim:set et: diff --git a/sources_non_forked/vim-gitgutter/README.mkd b/sources_non_forked/vim-gitgutter/README.mkd index 0c21f3c1..2a1c9fb9 100644 --- a/sources_non_forked/vim-gitgutter/README.mkd +++ b/sources_non_forked/vim-gitgutter/README.mkd @@ -1,9 +1,11 @@ ## vim-gitgutter -A Vim plugin which shows a git diff in the 'gutter' (sign column). It shows which lines have been added, modified, or removed. You can also preview, stage, and undo individual hunks; and stage partial hunks. The plugin also provides a hunk text object. +A Vim plugin which shows a git diff in the sign column. It shows which lines have been added, modified, or removed. You can also preview, stage, and undo individual hunks; and stage partial hunks. The plugin also provides a hunk text object. The signs are always up to date and the plugin never saves your buffer. +The name "gitgutter" comes from the Sublime Text 3 plugin which inspired this in 2013. + Features: * Shows signs for added, modified, and removed lines. @@ -33,6 +35,10 @@ Constraints: * Supports git only. If you work with other version control systems, I recommend [vim-signify](https://github.com/mhinz/vim-signify). * Relies on the `FocusGained` event. If your terminal doesn't report focus events, either use something like [Terminus][] or set `let g:gitgutter_terminal_reports_focus=0`. For tmux, `set -g focus-events on` in your tmux.conf. +Compatibility: + +Compatible back to Vim 7.4, and probably 7.3. + ### Screenshot @@ -88,6 +94,10 @@ You can jump between hunks with `[c` and `]c`. You can preview, stage, and undo You cannot unstage a staged hunk. +After updating the signs, the plugin fires the `GitGutter` User autocommand. + +After staging a hunk or part of a hunk, the plugin fires the `GitGutterStage` User autocommand. + #### Activation @@ -127,12 +137,15 @@ The same caveat applies to line number highlighting as to line highlighting just If you switch off both line highlighting and signs, you won't see the sign column. -To keep your Vim snappy, vim-gitgutter will suppress the signs when a file has more than 500 changes. As soon as the number of changes falls below the limit vim-gitgutter will show the signs again. You can configure the threshold with: +In older Vims (pre 8.1.0614 / Neovim 0.4.0) vim-gitgutter will suppress the signs when a file has more than 500 changes, to avoid slowing down the UI. As soon as the number of changes falls below the limit vim-gitgutter will show the signs again. You can configure the threshold with: ```viml -let g:gitgutter_max_signs = 500 " default value +let g:gitgutter_max_signs = 500 " default value (Vim < 8.1.0614, Neovim < 0.4.0) +let g:gitgutter_max_signs = -1 " default value (otherwise) ``` +You can also remove the limit by setting `g:gitgutter_max_signs = -1`. + #### Hunks You can jump between hunks: @@ -149,7 +162,17 @@ nmap ]h (GitGutterNextHunk) nmap [h (GitGutterPrevHunk) ``` -You can load all your hunks into the quickfix list with `:GitGutterQuickFix`. Note this ignores any unsaved changes in your buffers. If the option `g:gitgutter_use_location_list` is set, this command will load hunks into the current window's location list instead. +When you jump between hunks, a message like `Hunk 4 of 11` is shown on the command line. If you want to turn the message off, you can use: + +```viml +let g:gitgutter_show_msg_on_hunk_jumping = 0 +``` + +You can load all your hunks into the quickfix list with `:GitGutterQuickFix`. Note this ignores any unsaved changes in your buffers. If the option `g:gitgutter_use_location_list` is set, this command will load hunks into the current window's location list instead. Use `:copen` (or `:lopen`) to open the quickfix / location list or add a custom command like this: + +```viml +command! Gqf GitGutterQuickFix | copen +``` You can stage or undo an individual hunk when your cursor is in it: @@ -277,19 +300,14 @@ Please note that vim-gitgutter won't override any colours or highlights you've s #### Sign column -By default vim-gitgutter will make the sign column look like the line number column. - -To customise your sign column's background color, first tell vim-gitgutter to leave it alone: +Set the `SignColumn` highlight group to change the sign column's colour. For example: ```viml -let g:gitgutter_override_sign_column_highlight = 0 -``` +" vim-gitgutter used to do this by default: +highlight! link SignColumn LineNr -And then either update your colorscheme's `SignColumn` highlight group or set it in your vimrc: - -```viml -highlight SignColumn ctermbg=whatever " terminal Vim -highlight SignColumn guibg=whatever " gVim/MacVim +" or you could do this: +highlight SignColumn guibg=whatever ctermbg=whatever ``` By default the sign column will appear when there are signs to show and disappear when there aren't. To always have the sign column, add to your vimrc: @@ -308,31 +326,22 @@ let g:gitgutter_sign_allow_clobber = 1 #### Signs' colours and symbols -By default vim-gitgutter uses your colourscheme's `Diff*` highlight groups' foreground colours for the signs' foreground colours. For example, your `DiffAdd` foreground colour will be used for the `+` sign's foreground colour. +If you or your colourscheme has defined `GitGutter*` highlight groups, the plugin will use them for the signs' colours. -The signs' background colours will all be set to the sign column's background colour. - -If you don't like the default colours, you can either fix your colourscheme's `Diff*` highlights or configure your own `GitGutter*` highlight groups. These groups are: +If you want the background colours to match the sign column, but don't want to update the `GitGutter*` groups yourself, you can get the plugin to do it: ```viml -GitGutterAdd " an added line (default: links to DiffAdd) -GitGutterChange " a changed line (default: links to DiffChange) -GitGutterDelete " at least one removed line (default: links to DiffDelete) -GitGutterChangeDelete " a changed line followed by at least one removed line (default: links to GitGutterChange) +let g:gitgutter_set_sign_backgrounds = 1 ``` -You can either set these with `highlight GitGutterAdd {key}={arg}...` or link them to existing highlight groups with, say, `highlight link GitGutterAdd MyDiffAdd`. - -To get vim-gitgutter's original colours (based on git-diff's colours in my terminal): +If no `GitGutter*` highlight groups exist, the plugin will check the `Diff*` highlight groups. If their foreground colours differ the plugin will use them; if not, these colours will be used: ```viml -highlight GitGutterAdd guifg=#009900 guibg= ctermfg=2 ctermbg= -highlight GitGutterChange guifg=#bbbb00 guibg= ctermfg=3 ctermbg= -highlight GitGutterDelete guifg=#ff2222 guibg= ctermfg=1 ctermbg= +highlight GitGutterAdd guifg=#009900 ctermfg=2 +highlight GitGutterChange guifg=#bbbb00 ctermfg=3 +highlight GitGutterDelete guifg=#ff2222 ctermfg=1 ``` -– where you would replace `` and `` with the background colour of your `SignColumn` in the gui and the terminal respectively. For example, with the solarized colorscheme and a dark background, `guibg=#073642` and `ctermbg=0`. - To customise the symbols, add the following to your `~/.vimrc`: ```viml @@ -340,6 +349,7 @@ let g:gitgutter_sign_added = 'xx' let g:gitgutter_sign_modified = 'yy' let g:gitgutter_sign_removed = 'zz' let g:gitgutter_sign_removed_first_line = '^^' +let g:gitgutter_sign_removed_above_and_below = '{' let g:gitgutter_sign_modified_removed = 'ww' ``` @@ -399,6 +409,8 @@ By default buffers are diffed against the index. However you can diff against a let g:gitgutter_diff_base = '' ``` +If you are looking at a previous version of a file with Fugitive (e.g. via `:0Gclog`), gitgutter sets the diff base to the parent of the current revision. + This setting is ignored when the diffs are relative to the working tree. @@ -632,16 +644,6 @@ This plugin is for showing changes between the buffer and the index (and staging Your colorscheme is configuring the `SignColumn` highlight group weirdly. Please see the section above on customising the sign column. -> Why are the colours in the preview window weird? - -Probably because your colourscheme doesn't configure the `diff{Added,Changed,Removed}` highlight groups. Try this in `after/syntax/diff.vim`: - -```viml -highlight link diffAdded DiffAdd -highlight link diffChanged DiffChange -highlight link diffRemoved DiffDelete -``` - > What happens if I also use another plugin which uses signs (e.g. Syntastic)? You can configure whether GitGutter preserves or clobbers other signs using `g:gitgutter_sign_allow_clobber`. Set to `1` to clobber other signs (default on Vim >= 8.1.0614 and NeoVim >= 0.4.0) or `0` to preserve them. @@ -657,7 +659,10 @@ Here are some things you can check: * Verify `:echo system("git --version")` succeeds. * Verify your git config is compatible with the version of git returned by the command above. * Verify your Vim supports signs (`:echo has('signs')` should give `1`). -* Verify your file is being tracked by git and has unstaged changes. +* Verify your file is being tracked by git and has unstaged changes. Check whether the plugin thinks git knows about your file: `:echo b:gitgutter.path` should show the path to the file in the repo. +* Execute `:sign place group=gitgutter`; you should see a list of signs. + - If the signs are listed: this is a colorscheme / highlight problem. Compare `:highlight GitGutterAdd` with `:highlight SignColumn`. + - If no signs are listed: the call to git-diff is probably failing. Add `let g:gitgutter_log=1` to your vimrc, restart, reproduce the problem, and look at the `gitgutter.log` file in the plugin's directory. #### When the whole file is marked as added diff --git a/sources_non_forked/vim-gitgutter/autoload/gitgutter.vim b/sources_non_forked/vim-gitgutter/autoload/gitgutter.vim index 092d1089..ccb23962 100644 --- a/sources_non_forked/vim-gitgutter/autoload/gitgutter.vim +++ b/sources_non_forked/vim-gitgutter/autoload/gitgutter.vim @@ -1,5 +1,3 @@ -let s:t_string = type('') - " Primary functions {{{ function! gitgutter#all(force) abort @@ -42,7 +40,7 @@ function! gitgutter#process_buffer(bufnr, force) abort if a:force || s:has_fresh_changes(a:bufnr) - let diff = '' + let diff = 'NOT SET' try let diff = gitgutter#diff#run_diff(a:bufnr, g:gitgutter_diff_relative_to, 0) catch /gitgutter not tracked/ @@ -52,7 +50,7 @@ function! gitgutter#process_buffer(bufnr, force) abort call gitgutter#hunk#reset(a:bufnr) endtry - if diff != 'async' + if diff != 'async' && diff != 'NOT SET' call gitgutter#diff#handler(a:bufnr, diff) endif @@ -174,11 +172,7 @@ function! gitgutter#setup_maps() endfunction function! s:setup_path(bufnr, continuation) - let p = gitgutter#utility#repo_path(a:bufnr, 0) - - if type(p) == s:t_string && !empty(p) " if path is known - return - endif + if gitgutter#utility#has_repo_path(a:bufnr) | return | endif <<<<<<< HEAD call gitgutter#utility#setbufvar(a:bufnr, 'mapped', 1) @@ -219,9 +213,17 @@ endfunction " - it ignores unsaved changes in buffers " - it does not change to the repo root function! gitgutter#quickfix() + let cmd = g:gitgutter_git_executable.' '.g:gitgutter_git_args.' rev-parse --show-cdup' + let path_to_repo = get(systemlist(cmd), 0, '') + if !empty(path_to_repo) && path_to_repo[-1:] != '/' + let path_to_repo .= '/' + endif + let locations = [] - let cmd = g:gitgutter_git_executable.' '.g:gitgutter_git_args.' --no-pager '.g:gitgutter_git_args. - \ ' diff --no-ext-diff --no-color -U0 '.g:gitgutter_diff_args + let cmd = g:gitgutter_git_executable.' '.g:gitgutter_git_args.' --no-pager'. + \ ' diff --no-ext-diff --no-color -U0'. + \ ' --src-prefix=a/'.path_to_repo.' --dst-prefix=b/'.path_to_repo.' '. + \ g:gitgutter_diff_args. ' '. g:gitgutter_diff_base let diff = systemlist(cmd) let lnum = 0 for line in diff diff --git a/sources_non_forked/vim-gitgutter/autoload/gitgutter/async.vim b/sources_non_forked/vim-gitgutter/autoload/gitgutter/async.vim index 1cc2b167..d4767482 100644 --- a/sources_non_forked/vim-gitgutter/autoload/gitgutter/async.vim +++ b/sources_non_forked/vim-gitgutter/autoload/gitgutter/async.vim @@ -6,6 +6,8 @@ let s:available = has('nvim') || ( \ ) \ ) +let s:jobs = {} + function! gitgutter#async#available() return s:available endfunction @@ -28,11 +30,12 @@ function! gitgutter#async#execute(cmd, bufnr, handler) abort \ 'on_exit': function('s:on_exit_nvim') \ })) else - call job_start(command, { + let job = job_start(command, { \ 'out_cb': function('s:on_stdout_vim', options), \ 'err_cb': function('s:on_stderr_vim', options), \ 'close_cb': function('s:on_exit_vim', options) \ }) + let s:jobs[s:job_id(job)] = 1 endif endfunction @@ -83,6 +86,8 @@ endfunction function! s:on_exit_vim(channel) dict abort let job = ch_getjob(a:channel) + let jobid = s:job_id(job) + if has_key(s:jobs, jobid) | unlet s:jobs[jobid] | endif while 1 if job_status(job) == 'dead' let exit_code = job_info(job).exitval @@ -95,3 +100,8 @@ function! s:on_exit_vim(channel) dict abort call self.handler.out(self.buffer, join(self.stdoutbuffer, "\n")) endif endfunction + +function! s:job_id(job) + " Vim + return job_info(a:job).process +endfunction diff --git a/sources_non_forked/vim-gitgutter/autoload/gitgutter/debug.vim b/sources_non_forked/vim-gitgutter/autoload/gitgutter/debug.vim index 79d197ec..def5b806 100644 --- a/sources_non_forked/vim-gitgutter/autoload/gitgutter/debug.vim +++ b/sources_non_forked/vim-gitgutter/autoload/gitgutter/debug.vim @@ -22,16 +22,6 @@ function! gitgutter#debug#debug() call s:separator() call s:option('updatetime') - call s:option('shell') - call s:option('shellcmdflag') - call s:option('shellpipe') - call s:option('shellquote') - call s:option('shellredir') - call s:option('shellslash') - call s:option('shelltemp') - call s:option('shelltype') - call s:option('shellxescape') - call s:option('shellxquote') endfunction @@ -52,10 +42,10 @@ function! s:git_version() endfunction function! s:grep_version() - let v = system('grep --version') + let v = system(g:gitgutter_grep.' --version') call s:output( substitute(v, '\n$', '', '') ) - let v = system('grep --help') + let v = system(g:gitgutter_grep.' --help') call s:output( substitute(v, '\%x00', '', 'g') ) endfunction diff --git a/sources_non_forked/vim-gitgutter/autoload/gitgutter/diff.vim b/sources_non_forked/vim-gitgutter/autoload/gitgutter/diff.vim index 6d020712..8b47af67 100644 --- a/sources_non_forked/vim-gitgutter/autoload/gitgutter/diff.vim +++ b/sources_non_forked/vim-gitgutter/autoload/gitgutter/diff.vim @@ -1,3 +1,5 @@ +scriptencoding utf8 + let s:nomodeline = (v:version > 703 || (v:version == 703 && has('patch442'))) ? '' : '' let s:hunk_re = '^@@ -\(\d\+\),\?\(\d*\) +\(\d\+\),\?\(\d*\) @@' @@ -14,7 +16,6 @@ endfunction let s:c_flag = s:git_supports_command_line_config_override() - let s:temp_from = tempname() let s:temp_buffer = tempname() let s:counter = 0 @@ -122,7 +123,7 @@ function! gitgutter#diff#run_diff(bufnr, from, preserve_full_diff) abort endif " Write file from index to temporary file. - let index_name = g:gitgutter_diff_base.':'.gitgutter#utility#repo_path(a:bufnr, 1) + let index_name = gitgutter#utility#get_diff_base(a:bufnr).':'.gitgutter#utility#repo_path(a:bufnr, 1) let cmd .= g:gitgutter_git_executable.' '.g:gitgutter_git_args.' --no-pager show '.index_name.' > '.from_file.' && ' elseif a:from ==# 'working_tree' @@ -130,7 +131,7 @@ function! gitgutter#diff#run_diff(bufnr, from, preserve_full_diff) abort endif " Call git-diff. - let cmd .= g:gitgutter_git_executable.' '.g:gitgutter_git_args.' --no-pager '.g:gitgutter_git_args + let cmd .= g:gitgutter_git_executable.' '.g:gitgutter_git_args.' --no-pager' if s:c_flag let cmd .= ' -c "diff.autorefreshindex=0"' let cmd .= ' -c "diff.noprefix=false"' @@ -184,7 +185,7 @@ function! gitgutter#diff#handler(bufnr, diff) abort let modified_lines = gitgutter#diff#process_hunks(a:bufnr, gitgutter#hunk#hunks(a:bufnr)) let signs_count = len(modified_lines) - if signs_count > g:gitgutter_max_signs + if g:gitgutter_max_signs != -1 && signs_count > g:gitgutter_max_signs call gitgutter#utility#warn_once(a:bufnr, printf( \ 'exceeded maximum number of signs (%d > %d, configured by g:gitgutter_max_signs).', \ signs_count, g:gitgutter_max_signs), 'max_signs') @@ -402,12 +403,19 @@ function! s:write_buffer(bufnr, file) let bufcontents[0]=''.bufcontents[0] endif - call writefile(bufcontents, a:file, 'b') + " The file we are writing to is a temporary file. Sometimes the parent + " directory is deleted outside Vim but, because Vim caches the directory + " name at startup and does not check for its existence subsequently, Vim + " does not realise. This causes E482 errors. + try + call writefile(bufcontents, a:file, 'b') + catch /E482/ + call mkdir(fnamemodify(a:file, ':h'), '', '0700') + call writefile(bufcontents, a:file, 'b') + endtry endfunction function! s:save_last_seen_change(bufnr) abort call gitgutter#utility#setbufvar(a:bufnr, 'tick', getbufvar(a:bufnr, 'changedtick')) endfunction - - diff --git a/sources_non_forked/vim-gitgutter/autoload/gitgutter/highlight.vim b/sources_non_forked/vim-gitgutter/autoload/gitgutter/highlight.vim index 2375748c..2fa05868 100644 --- a/sources_non_forked/vim-gitgutter/autoload/gitgutter/highlight.vim +++ b/sources_non_forked/vim-gitgutter/autoload/gitgutter/highlight.vim @@ -64,14 +64,6 @@ function! gitgutter#highlight#linenr_toggle() abort endfunction -function! gitgutter#highlight#define_sign_column_highlight() abort - if g:gitgutter_override_sign_column_highlight - highlight! link SignColumn LineNr - else - highlight default link SignColumn LineNr - endif -endfunction - function! gitgutter#highlight#define_highlights() abort let [guibg, ctermbg] = s:get_background_colors('SignColumn') @@ -84,12 +76,24 @@ function! gitgutter#highlight#define_highlights() abort highlight default link GitGutterChangeDeleteInvisible GitGutterChangeInvisible " When they are visible. - " By default use Diff* foreground colors with SignColumn's background. - for type in ['Add', 'Change', 'Delete'] - let [guifg, ctermfg] = s:get_foreground_colors('Diff'.type) - execute "highlight GitGutter".type."Default guifg=".guifg." guibg=".guibg." ctermfg=".ctermfg." ctermbg=".ctermbg - execute "highlight default link GitGutter".type." GitGutter".type."Default" + for type in ["Add", "Change", "Delete"] + if hlexists("GitGutter".type) && s:get_foreground_colors("GitGutter".type) != ['NONE', 'NONE'] + if g:gitgutter_set_sign_backgrounds + execute "highlight GitGutter".type." guibg=".guibg." ctermbg=".ctermbg + endif + continue + elseif s:useful_diff_colours() + let [guifg, ctermfg] = s:get_foreground_colors('Diff'.type) + else + let [guifg, ctermfg] = s:get_foreground_fallback_colors(type) + endif + execute "highlight GitGutter".type." guifg=".guifg." guibg=".guibg." ctermfg=".ctermfg." ctermbg=".ctermbg endfor + + if hlexists("GitGutterChangeDelete") && g:gitgutter_set_sign_backgrounds + execute "highlight GitGutterChangeDelete guibg=".guibg." ctermbg=".ctermbg + endif + highlight default link GitGutterChangeDelete GitGutterChange " Highlights used for the whole line. @@ -107,6 +111,14 @@ function! gitgutter#highlight#define_highlights() abort " Highlights used intra line. highlight GitGutterAddIntraLine gui=reverse cterm=reverse highlight GitGutterDeleteIntraLine gui=reverse cterm=reverse + " Set diff syntax colours (used in the preview window) - diffAdded,diffChanged,diffRemoved - + " to match the signs, if not set aleady. + for [dtype,type] in [['Added','Add'], ['Changed','Change'], ['Removed','Delete']] + if !hlexists('diff'.dtype) + let [guifg, ctermfg] = s:get_foreground_colors('GitGutter'.type) + execute "highlight diff".dtype." guifg=".guifg." ctermfg=".ctermfg." guibg=NONE ctermbg=NONE" + endif + endfor endfunction function! gitgutter#highlight#define_signs() abort @@ -217,3 +229,20 @@ function! s:get_background_colors(group) abort let guibg = s:get_hl(a:group, 'bg', 'gui') return [guibg, ctermbg] endfunction + +function! s:useful_diff_colours() + let [guifg_add, ctermfg_add] = s:get_foreground_colors('DiffAdd') + let [guifg_del, ctermfg_del] = s:get_foreground_colors('DiffDelete') + + return guifg_add != guifg_del && ctermfg_add != ctermfg_del +endfunction + +function! s:get_foreground_fallback_colors(type) + if a:type == 'Add' + return ['#009900', '2'] + elseif a:type == 'Change' + return ['#bbbb00', '3'] + elseif a:type == 'Delete' + return ['#ff2222', '1'] + endif +endfunction diff --git a/sources_non_forked/vim-gitgutter/autoload/gitgutter/hunk.vim b/sources_non_forked/vim-gitgutter/autoload/gitgutter/hunk.vim index c51dd7a5..9d18d928 100644 --- a/sources_non_forked/vim-gitgutter/autoload/gitgutter/hunk.vim +++ b/sources_non_forked/vim-gitgutter/autoload/gitgutter/hunk.vim @@ -1,4 +1,6 @@ let s:winid = 0 +let s:preview_bufnr = 0 +let s:nomodeline = (v:version > 703 || (v:version == 703 && has('patch442'))) ? '' : '' function! gitgutter#hunk#set_hunks(bufnr, hunks) abort call gitgutter#utility#setbufvar(a:bufnr, 'hunks', a:hunks) @@ -44,39 +46,57 @@ endfunction function! gitgutter#hunk#next_hunk(count) abort let bufnr = bufnr('') - if gitgutter#utility#is_active(bufnr) - let current_line = line('.') - let hunk_count = 0 - for hunk in gitgutter#hunk#hunks(bufnr) - if hunk[2] > current_line - let hunk_count += 1 - if hunk_count == a:count - execute 'normal!' hunk[2] . 'Gzv' - return - endif - endif - endfor - call gitgutter#utility#warn('No more hunks') + if !gitgutter#utility#is_active(bufnr) | return | endif + + let hunks = gitgutter#hunk#hunks(bufnr) + if empty(hunks) + call gitgutter#utility#warn('No hunks in file') + return endif + + let current_line = line('.') + let hunk_count = 0 + for hunk in hunks + if hunk[2] > current_line + let hunk_count += 1 + if hunk_count == a:count + execute 'normal!' hunk[2] . 'Gzv' + if g:gitgutter_show_msg_on_hunk_jumping + redraw | echo printf('Hunk %d of %d', index(hunks, hunk) + 1, len(hunks)) + endif + return + endif + endif + endfor + call gitgutter#utility#warn('No more hunks') endfunction function! gitgutter#hunk#prev_hunk(count) abort let bufnr = bufnr('') - if gitgutter#utility#is_active(bufnr) - let current_line = line('.') - let hunk_count = 0 - for hunk in reverse(copy(gitgutter#hunk#hunks(bufnr))) - if hunk[2] < current_line - let hunk_count += 1 - if hunk_count == a:count - let target = hunk[2] == 0 ? 1 : hunk[2] - execute 'normal!' target . 'Gzv' - return - endif - endif - endfor - call gitgutter#utility#warn('No previous hunks') + if !gitgutter#utility#is_active(bufnr) | return | endif + + let hunks = gitgutter#hunk#hunks(bufnr) + if empty(hunks) + call gitgutter#utility#warn('No hunks in file') + return endif + + let current_line = line('.') + let hunk_count = 0 + for hunk in reverse(copy(hunks)) + if hunk[2] < current_line + let hunk_count += 1 + if hunk_count == a:count + let target = hunk[2] == 0 ? 1 : hunk[2] + execute 'normal!' target . 'Gzv' + if g:gitgutter_show_msg_on_hunk_jumping + redraw | echo printf('Hunk %d of %d', index(hunks, hunk) + 1, len(hunks)) + endif + return + endif + endif + endfor + call gitgutter#utility#warn('No previous hunks') endfunction " Returns the hunk the cursor is currently in or an empty list if the cursor @@ -172,6 +192,8 @@ endfunction function! gitgutter#hunk#stage(...) abort + if !s:in_hunk_preview_window() && !gitgutter#utility#has_repo_path(bufnr('')) | return | endif + if a:0 && (a:1 != 1 || a:2 != line('$')) call s:hunk_op(function('s:stage'), a:1, a:2) else @@ -181,11 +203,15 @@ function! gitgutter#hunk#stage(...) abort endfunction function! gitgutter#hunk#undo() abort + if !gitgutter#utility#has_repo_path(bufnr('')) | return | endif + call s:hunk_op(function('s:undo')) silent! call repeat#set("\(GitGutterUndoHunk)", -1) endfunction function! gitgutter#hunk#preview() abort + if !gitgutter#utility#has_repo_path(bufnr('')) | return | endif + call s:hunk_op(function('s:preview')) silent! call repeat#set("\(GitGutterPreviewHunk)", -1) endfunction @@ -268,6 +294,10 @@ function! s:stage(hunk_diff) \ diff) if v:shell_error call gitgutter#utility#warn('patch does not apply') + else + if exists('#User#GitGutterStage') + execute 'doautocmd' s:nomodeline 'User GitGutterStage' + endif endif " Refresh gitgutter's view of buffer. @@ -428,13 +458,23 @@ function! s:open_hunk_preview_window() endif silent! wincmd P - if !&previewwindow + if &previewwindow + file gitgutter://hunk-preview + else noautocmd execute g:gitgutter_preview_win_location &previewheight 'new gitgutter://hunk-preview' - let s:winid = win_getid() + doautocmd WinEnter set previewwindow - setlocal filetype=diff buftype=acwrite bufhidden=delete - " Reset some defaults in case someone else has changed them. - setlocal noreadonly modifiable noswapfile + endif + if exists('*win_getid') + let s:winid = win_getid() + else + let s:preview_bufnr = bufnr('') + endif + setlocal filetype=diff buftype=acwrite bufhidden=delete + " Reset some defaults in case someone else has changed them. + setlocal noreadonly modifiable noswapfile + if g:gitgutter_close_preview_on_escape + nnoremap :pclose endif endfunction @@ -443,17 +483,22 @@ endfunction " Preview window: assumes cursor is in preview window. function! s:populate_hunk_preview_window(header, body) let body_length = len(a:body) - let height = min([body_length, &previewheight]) if g:gitgutter_preview_win_floating if exists('*nvim_open_win') + let height = min([body_length, &previewheight]) + " Assumes cursor is not in previewing window. call nvim_buf_set_var(winbufnr(s:winid), 'hunk_header', a:header) + let [_scrolloff, &scrolloff] = [&scrolloff, 0] + let width = max(map(copy(a:body), 'strdisplaywidth(v:val)')) call nvim_win_set_width(s:winid, width) call nvim_win_set_height(s:winid, height) + let &scrolloff=_scrolloff + call nvim_buf_set_lines(winbufnr(s:winid), 0, -1, v:false, []) call nvim_buf_set_lines(winbufnr(s:winid), 0, -1, v:false, a:body) call nvim_buf_set_option(winbufnr(s:winid), 'modified', v:false) @@ -479,12 +524,16 @@ function! s:populate_hunk_preview_window(header, body) else let b:hunk_header = a:header - execute 'resize' height %delete _ call setline(1, a:body) setlocal nomodified + normal! G$ + let height = min([winline(), &previewheight]) + execute 'resize' height + 1 + call clearmatches() for region in gitgutter#diff_highlight#process(a:body) let group = region[1] == '+' ? 'GitGutterAddIntraLine' : 'GitGutterDeleteIntraLine' @@ -499,18 +548,21 @@ endfunction function! s:enable_staging_from_hunk_preview_window() augroup gitgutter_hunk_preview autocmd! - execute 'autocmd BufWriteCmd GitGutterStageHunk' + let bufnr = s:winid != 0 ? winbufnr(s:winid) : s:preview_bufnr + execute 'autocmd BufWriteCmd GitGutterStageHunk' augroup END endfunction function! s:goto_original_window() noautocmd wincmd p + doautocmd WinEnter endfunction function! s:close_hunk_preview_window() - call setbufvar(winbufnr(s:winid), '&modified', 0) + let bufnr = s:winid != 0 ? winbufnr(s:winid) : s:preview_bufnr + call setbufvar(bufnr, '&modified', 0) if g:gitgutter_preview_win_floating if win_id2win(s:winid) > 0 @@ -521,4 +573,5 @@ function! s:close_hunk_preview_window() endif let s:winid = 0 + let s:preview_bufnr = 0 endfunction diff --git a/sources_non_forked/vim-gitgutter/autoload/gitgutter/utility.vim b/sources_non_forked/vim-gitgutter/autoload/gitgutter/utility.vim index 3f533ba4..4a02c2fb 100644 --- a/sources_non_forked/vim-gitgutter/autoload/gitgutter/utility.vim +++ b/sources_non_forked/vim-gitgutter/autoload/gitgutter/utility.vim @@ -9,25 +9,19 @@ endfunction function! gitgutter#utility#setbufvar(buffer, varname, val) let buffer = +a:buffer " Default value for getbufvar() was introduced in Vim 7.3.831. - let bvars = getbufvar(buffer, '') - if empty(bvars) - let bvars = {} - endif - let dict = get(bvars, 'gitgutter', {}) - let needs_setting = empty(dict) - let dict[a:varname] = a:val - if needs_setting - call setbufvar(buffer, 'gitgutter', dict) + let ggvars = getbufvar(buffer, 'gitgutter') + if type(ggvars) == type('') + unlet ggvars + let ggvars = {} + call setbufvar(buffer, 'gitgutter', ggvars) endif + let ggvars[a:varname] = a:val endfunction function! gitgutter#utility#getbufvar(buffer, varname, ...) - let bvars = getbufvar(a:buffer, '') - if !empty(bvars) - let dict = get(bvars, 'gitgutter', {}) - if has_key(dict, a:varname) - return dict[a:varname] - endif + let ggvars = getbufvar(a:buffer, 'gitgutter') + if type(ggvars) == type({}) && has_key(ggvars, a:varname) + return ggvars[a:varname] endif if a:0 return a:1 @@ -105,6 +99,10 @@ function! gitgutter#utility#system(cmd, ...) abort return output endfunction +function! gitgutter#utility#has_repo_path(bufnr) + return index(['', -1, -2], gitgutter#utility#repo_path(a:bufnr, 0)) == -1 +endfunction + " Path of file relative to repo root. " " * empty string - not set @@ -112,7 +110,7 @@ endfunction " * -1 - pending " * -2 - not tracked by git function! gitgutter#utility#repo_path(bufnr, shellesc) abort - let p = gitgutter#utility#getbufvar(a:bufnr, 'path') + let p = gitgutter#utility#getbufvar(a:bufnr, 'path', '') return a:shellesc ? gitgutter#utility#shellescape(p) : p endfunction @@ -164,7 +162,7 @@ endfunction function! gitgutter#utility#cd_cmd(bufnr, cmd) abort - let cd = s:unc_path(a:bufnr) ? 'pushd' : (gitgutter#utility#windows() ? 'cd /d' : 'cd') + let cd = s:unc_path(a:bufnr) ? 'pushd' : (gitgutter#utility#windows() && s:dos_shell() ? 'cd /d' : 'cd') return cd.' '.s:dir(a:bufnr).' && '.a:cmd endfunction @@ -172,6 +170,10 @@ function! s:unc_path(bufnr) return s:abs_path(a:bufnr, 0) =~ '^\\\\' endfunction +function! s:dos_shell() + return &shell == 'cmd.exe' || &shell == 'command.com' +endfunction + function! s:use_known_shell() abort if has('unix') && &shell !=# 'sh' let [s:shell, s:shellcmdflag, s:shellredir] = [&shell, &shellcmdflag, &shellredir] @@ -186,8 +188,21 @@ function! s:restore_shell() abort endif endfunction +function! gitgutter#utility#get_diff_base(bufnr) + let p = resolve(expand('#'.a:bufnr.':p')) + let ml = matchlist(p, '\v^fugitive:/.*/(\x{40,})/') + if !empty(ml) && !empty(ml[1]) + return ml[1].'^' + endif + return g:gitgutter_diff_base +endfunction + function! s:abs_path(bufnr, shellesc) let p = resolve(expand('#'.a:bufnr.':p')) + + " Remove extra parts from fugitive's filepaths + let p = substitute(substitute(p, '^fugitive:', '', ''), '\v\.git/\x{40,}/', '', '') + return a:shellesc ? gitgutter#utility#shellescape(p) : p endfunction diff --git a/sources_non_forked/vim-gitgutter/doc/gitgutter.txt b/sources_non_forked/vim-gitgutter/doc/gitgutter.txt index 1f52989f..06b0be91 100644 --- a/sources_non_forked/vim-gitgutter/doc/gitgutter.txt +++ b/sources_non_forked/vim-gitgutter/doc/gitgutter.txt @@ -1,7 +1,7 @@ *gitgutter.txt* A Vim plugin which shows a git diff in the gutter. - Vim Git Gutter + Vim GitGutter Author: Andy Stewart @@ -27,13 +27,16 @@ CONTENTS *gitgutter* =============================================================================== INTRODUCTION *gitgutter-introduction* -GitGutter is a Vim plugin which shows a git diff in the 'gutter' (sign column). +GitGutter is a Vim plugin which shows a git diff in the sign column. It shows which lines have been added, modified, or removed. You can also preview, stage, and undo individual hunks. The plugin also provides a hunk text object. The signs are always up to date and the plugin never saves your buffer. +The name "gitgutter" comes from the Sublime Text 3 plugin which inspired this +one in 2013. + =============================================================================== INSTALLATION *gitgutter-installation* @@ -143,7 +146,13 @@ Commands for jumping between hunks:~ :GitGutterQuickFix Load all hunks into the |quickfix| list. Note this ignores any unsaved changes in your buffers. The |g:gitgutter_use_location_list| option can be set to - populate the location list of the current window instead + populate the location list of the current window + instead. Use |:copen| (or |:lopen|) to open a buffer + containing the search results in linked form; or add a + custom command like this: +> + command! Gqf GitGutterQuickFix | copen +< Commands for operating on a hunk:~ @@ -177,7 +186,7 @@ Commands for folds:~ =============================================================================== -AUTOCOMMAND *gitgutter-autocommand* +AUTOCOMMANDS *gitgutter-autocommands* User GitGutter~ @@ -189,6 +198,10 @@ event GitGutter. You can listen for this event, for example: A dictionary `g:gitgutter_hook_context` is made available during its execution, which contains an entry `bufnr` that contains the buffer number being updated. +User GitGutterStage~ + +After staging a hunk or part of a hunk vim-gitgutter fires a |User| |autocmd| +with the event GitGutterStage. Staging always happens in the current buffer. =============================================================================== MAPPINGS *gitgutter-mappings* @@ -299,11 +312,16 @@ Signs:~ |g:gitgutter_sign_removed| |g:gitgutter_sign_removed_first_line| |g:gitgutter_sign_modified_removed| - |g:gitgutter_override_sign_column_highlight| + |g:gitgutter_set_sign_backgrounds| + +Hunk jumping:~ + + |g:gitgutter_show_msg_on_hunk_jumping| Hunk previews:~ |g:gitgutter_preview_win_floating| + |g:gitgutter_close_preview_on_escape| Terminal:~ @@ -366,6 +384,9 @@ a revision instead. For example: let g:gitgutter_diff_base = '' < +If you are looking at a previous version of a file with Fugitive (e.g. +via :0Gclog), gitgutter sets the diff base to the parent of the current revision. + This setting is ignore when the diff is relative to the working tree (|g:gitgutter_diff_relative_to|). @@ -402,13 +423,16 @@ Default: 0 Determines whether or not to show line number highlights. *g:gitgutter_max_signs* -Default: 500 +Default: 500 (Vim < 8.1.0614, Neovim < 0.4.0) + -1 (otherwise) Sets the maximum number of signs to show in a buffer. Vim is slow at updating signs, so to avoid slowing down the GUI the number of signs is capped. When the number of changed lines exceeds this value, the plugin removes all signs and displays a warning message. +When set to -1 the limit is not applied. + *g:gitgutter_sign_priority* Default: 10 @@ -425,6 +449,7 @@ will not preserve non-gitgutter signs. *g:gitgutter_sign_modified* *g:gitgutter_sign_removed* *g:gitgutter_sign_removed_first_line* + *g:gitgutter_sign_removed_above_and_below* *g:gitgutter_sign_modified_removed* Defaults: > @@ -432,31 +457,20 @@ Defaults: let g:gitgutter_sign_modified = '~' let g:gitgutter_sign_removed = '_' let g:gitgutter_sign_removed_first_line = '‾' + let g:gitgutter_sign_removed_above_and_below = '_¯' let g:gitgutter_sign_modified_removed = '~_' < You can use unicode characters but not images. Signs must not take up more than 2 columns. - *g:gitgutter_override_sign_column_highlight* -Default: 1 + *g:gitgutter_set_sign_backgrounds* +Default: 0 -Controls whether to make the sign column look like the line-number column (i.e. -the |hl-LineNr| highlight group). - -To customise your sign column's background color, first tell vim-gitgutter to -leave it alone: -> - let g:gitgutter_override_sign_column_highlight = 0 -< - -And then either update your colorscheme's |hlSignColumn| highlight group or set -it in your |vimrc|: - - Desired appearance Command ~ - Same as line-number column highlight clear SignColumn - User-defined (terminal Vim) highlight SignColumn ctermbg={whatever} - User-defined (graphical Vim) highlight SignColumn guibg={whatever} +Only applies to existing GitGutter* highlight groups. See +|gitgutter-highlights|. +Controls whether to override the signs' background colours to match the +|hl-SignColumn|. *g:gitgutter_preview_win_floating* Default: 0 (Vim) @@ -467,6 +481,11 @@ Whether to use floating/popup windows for hunk previews. Note that if you use popup windows on Vim you will not be able to stage partial hunks via the preview window. + *g:gitgutter_close_preview_on_escape* +Default: 0 + +Whether pressing in a non-floating preview window closes it. + *g:gitgutter_terminal_reports_focus* Default: 1 @@ -515,24 +534,27 @@ Default: 0 When switched on, the :GitGutterQuickFix command populates the location list of the current window instead of the global quickfix list. + *g:gitgutter_show_msg_on_hunk_jumping* +Default: 1 + +When switched on, a message like "Hunk 4 of 11" is shown on hunk jumping. + =============================================================================== HIGHLIGHTS *gitgutter-highlights* -To change the signs' colours, set up the following highlight groups in your -colorscheme or |vimrc|: +To change the signs' colours, specify these highlight groups in your |vimrc|: > - GitGutterAdd " an added line - GitGutterChange " a changed line - GitGutterDelete " at least one removed line - GitGutterChangeDelete " a changed line followed by at least one removed line + highlight GitGutterAdd guifg=#009900 ctermfg=2 + highlight GitGutterChange guifg=#bbbb00 ctermfg=3 + highlight GitGutterDelete guifg=#ff2222 ctermfg=1 < -You can either set these with `highlight GitGutterAdd {key}={arg}...` or link -them to existing highlight groups with, say: -> - highlight link GitGutterAdd MyDiffAdd -< +See |highlight-guifg| and |highlight-ctermfg| for the values you can use. + +If you do not like the signs' background colours and you do not want to update +the GitGutter* highlight groups yourself, you can get the plugin to do it +|g:gitgutter_set_sign_backgrounds|. To change the line highlights, set up the following highlight groups in your colorscheme or |vimrc|: @@ -589,8 +611,11 @@ c. Why can't I unstage staged changes? d. Why are the colours in the sign column weird? Your colorscheme is configuring the |hl-SignColumn| highlight group weirdly. - Please see |g:gitgutter_override_sign_column_highlight| on customising the - sign column. + Here are two ways you could change the colours: +> + highlight! link SignColumn LineNr + highlight SignColumn guibg=whatever ctermbg=whatever +< e. What happens if I also use another plugin which uses signs (e.g. Syntastic)? @@ -629,6 +654,22 @@ When no signs are showing at all:~ < If the result is -2, the plugin thinks your file is not tracked by git. +6. Check whether the signs have been placed: +> + :sign place group=gitgutter +< + If you see a list of signs, this is a colorscheme / highlight problem. + Compare these two highlight values: +> + :highlight GitGutterAdd + :highlight SignColumn +< + If no signs are listed, the call to git-diff is probably failing. Turn on + logging by adding the following to your vimrc, restart, reproduce the problem, + and examing the gitgutter.log file in the plugin's directory. +> + let g:gitgutter_log = 1 +< When the whole file is marked as added:~ diff --git a/sources_non_forked/vim-gitgutter/plugin/gitgutter.vim b/sources_non_forked/vim-gitgutter/plugin/gitgutter.vim index dda93b86..a4e86caf 100644 --- a/sources_non_forked/vim-gitgutter/plugin/gitgutter.vim +++ b/sources_non_forked/vim-gitgutter/plugin/gitgutter.vim @@ -12,64 +12,72 @@ if v:version < 703 || (v:version == 703 && !has("patch105")) finish endif -function! s:set(var, default) abort - if !exists(a:var) - if type(a:default) - execute 'let' a:var '=' string(a:default) - else - execute 'let' a:var '=' a:default - endif +let s:nomodeline = (v:version > 703 || (v:version == 703 && has('patch442'))) ? '' : '' + +function! s:obsolete(var) + if exists(a:var) + call gitgutter#utility#warn(a:var.' is obsolete and has no effect.') endif endfunction -call s:set('g:gitgutter_preview_win_location', 'bo') + +let g:gitgutter_preview_win_location = get(g:, 'gitgutter_preview_win_location', 'bo') if exists('*nvim_open_win') - call s:set('g:gitgutter_preview_win_floating', 1) + let g:gitgutter_preview_win_floating = get(g:, 'gitgutter_preview_win_floating', 1) else - call s:set('g:gitgutter_preview_win_floating', 0) + let g:gitgutter_preview_win_floating = get(g:, 'gitgutter_preview_win_floating', 0) endif -call s:set('g:gitgutter_enabled', 1) -call s:set('g:gitgutter_max_signs', 500) -call s:set('g:gitgutter_signs', 1) -call s:set('g:gitgutter_highlight_lines', 0) -call s:set('g:gitgutter_highlight_linenrs', 0) -call s:set('g:gitgutter_sign_priority', 10) +let g:gitgutter_enabled = get(g:, 'gitgutter_enabled', 1) +if exists('*sign_unplace') + let g:gitgutter_max_signs = get(g:, 'gitgutter_max_signs', -1) +else + let g:gitgutter_max_signs = get(g:, 'gitgutter_max_signs', 500) +endif +let g:gitgutter_signs = get(g:, 'gitgutter_signs', 1) +let g:gitgutter_highlight_lines = get(g:, 'gitgutter_highlight_lines', 0) +let g:gitgutter_highlight_linenrs = get(g:, 'gitgutter_highlight_linenrs', 0) +let g:gitgutter_sign_priority = get(g:, 'gitgutter_sign_priority', 10) " Nvim 0.4.0 has an expanding sign column " The sign_place() function supports sign priority. if (has('nvim-0.4.0') || exists('*sign_place')) && !exists('g:gitgutter_sign_allow_clobber') let g:gitgutter_sign_allow_clobber = 1 endif -call s:set('g:gitgutter_sign_allow_clobber', 0) -call s:set('g:gitgutter_override_sign_column_highlight', 1) -call s:set('g:gitgutter_sign_added', '+') -call s:set('g:gitgutter_sign_modified', '~') -call s:set('g:gitgutter_sign_removed', '_') +let g:gitgutter_sign_allow_clobber = get(g:, 'gitgutter_sign_allow_clobber', 0) +let g:gitgutter_set_sign_backgrounds = get(g:, 'gitgutter_set_sign_backgrounds', 0) +let g:gitgutter_sign_added = get(g:, 'gitgutter_sign_added', '+') +let g:gitgutter_sign_modified = get(g:, 'gitgutter_sign_modified', '~') +let g:gitgutter_sign_removed = get(g:, 'gitgutter_sign_removed', '_') if gitgutter#utility#supports_overscore_sign() - call s:set('g:gitgutter_sign_removed_first_line', '‾') + let g:gitgutter_sign_removed_first_line = get(g:, 'gitgutter_sign_removed_first_line', '‾') else - call s:set('g:gitgutter_sign_removed_first_line', '_^') + let g:gitgutter_sign_removed_first_line = get(g:, 'gitgutter_sign_removed_first_line', '_^') endif -call s:set('g:gitgutter_sign_removed_above_and_below', '[') -call s:set('g:gitgutter_sign_modified_removed', '~_') -call s:set('g:gitgutter_git_args', '') -call s:set('g:gitgutter_diff_relative_to', 'index') -call s:set('g:gitgutter_diff_args', '') -call s:set('g:gitgutter_diff_base', '') -call s:set('g:gitgutter_map_keys', 1) -call s:set('g:gitgutter_terminal_reports_focus', 1) -call s:set('g:gitgutter_async', 1) -call s:set('g:gitgutter_log', 0) -call s:set('g:gitgutter_use_location_list', 0) +let g:gitgutter_sign_removed_above_and_below = get(g:, 'gitgutter_sign_removed_above_and_below', '_¯') +let g:gitgutter_sign_modified_removed = get(g:, 'gitgutter_sign_modified_removed', '~_') +let g:gitgutter_git_args = get(g:, 'gitgutter_git_args', '') +let g:gitgutter_diff_relative_to = get(g:, 'gitgutter_diff_relative_to', 'index') +let g:gitgutter_diff_args = get(g:, 'gitgutter_diff_args', '') +let g:gitgutter_diff_base = get(g:, 'gitgutter_diff_base', '') +let g:gitgutter_map_keys = get(g:, 'gitgutter_map_keys', 1) +let g:gitgutter_terminal_reports_focus = get(g:, 'gitgutter_terminal_reports_focus', 1) +let g:gitgutter_async = get(g:, 'gitgutter_async', 1) +let g:gitgutter_log = get(g:, 'gitgutter_log', 0) +let g:gitgutter_use_location_list = get(g:, 'gitgutter_use_location_list', 0) +let g:gitgutter_close_preview_on_escape = get(g:, 'gitgutter_close_preview_on_escape', 0) +let g:gitgutter_show_msg_on_hunk_jumping = get(g:, 'gitgutter_show_msg_on_hunk_jumping', 1) -call s:set('g:gitgutter_git_executable', 'git') +let g:gitgutter_git_executable = get(g:, 'gitgutter_git_executable', 'git') if !executable(g:gitgutter_git_executable) - call gitgutter#utility#warn('cannot find git. Please set g:gitgutter_git_executable.') + if g:gitgutter_enabled + call gitgutter#utility#warn('cannot find git. Please set g:gitgutter_git_executable.') + endif + finish endif let default_grep = 'grep' -call s:set('g:gitgutter_grep', default_grep) +let g:gitgutter_grep = get(g:, 'gitgutter_grep', default_grep) if !empty(g:gitgutter_grep) if executable(split(g:gitgutter_grep)[0]) if $GREP_OPTIONS =~# '--color=always' @@ -83,7 +91,6 @@ if !empty(g:gitgutter_grep) endif endif -call gitgutter#highlight#define_sign_column_highlight() call gitgutter#highlight#define_highlights() call gitgutter#highlight#define_signs() @@ -212,6 +219,21 @@ nnoremap GitGutterPreviewHunk :call gitgutter#utility#warn('ple function! s:on_bufenter() call gitgutter#setup_maps() + " To keep vim's start-up fast, do not process the buffer when vim is starting. + " Instead process it a short time later. Normally we would rely on our + " CursorHold autocommand to handle this but it turns out CursorHold is not + " guaranteed to fire if the user has not typed anything yet; so set up a + " timer instead. The disadvantage is that if CursorHold does fire, the + " plugin will do a round of unnecessary work; but since there will not have + " been any changes to the buffer since the first round, the second round + " will be cheap. + if has('vim_starting') && !$VIM_GITGUTTER_TEST + if exists('*timer_start') + call timer_start(&updatetime, 'GitGutterCursorHold') + endif + return + endif + if exists('t:gitgutter_didtabenter') && t:gitgutter_didtabenter let t:gitgutter_didtabenter = 0 call gitgutter#all(!g:gitgutter_terminal_reports_focus) @@ -220,6 +242,10 @@ function! s:on_bufenter() endif endfunction +function! GitGutterCursorHold(timer) + execute 'doautocmd' s:nomodeline 'gitgutter CursorHold' +endfunction + " Autocommands {{{ augroup gitgutter @@ -229,6 +255,11 @@ augroup gitgutter autocmd BufEnter * call s:on_bufenter() + " Ensure Vim is always checking for CursorMoved to avoid CursorMoved + " being fired at the wrong time in floating preview window on Neovim. + " See vim/vim#2053. + autocmd CursorMoved * execute '' + autocmd CursorHold,CursorHoldI * call gitgutter#process_buffer(bufnr(''), 0) if exists('*timer_start') && has('lambda') autocmd FileChangedShellPost * call timer_start(1, {-> gitgutter#process_buffer(bufnr(''), 1)}) @@ -256,14 +287,14 @@ augroup gitgutter " FocusGained gets triggered on startup with Neovim at least already. " Therefore this tracks also if it was lost before. let s:focus_was_lost = 0 - autocmd FocusGained * if s:focus_was_lost | let focus_was_lost = 0 | call gitgutter#all(1) | endif + autocmd FocusGained * if s:focus_was_lost | let s:focus_was_lost = 0 | call gitgutter#all(1) | endif autocmd FocusLost * let s:focus_was_lost = 1 if exists('##VimResume') autocmd VimResume * call gitgutter#all(1) endif - autocmd ColorScheme * call gitgutter#highlight#define_sign_column_highlight() | call gitgutter#highlight#define_highlights() + autocmd ColorScheme * call gitgutter#highlight#define_highlights() " Disable during :vimgrep autocmd QuickFixCmdPre *vimgrep* let g:gitgutter_enabled = 0 diff --git a/sources_non_forked/vim-gitgutter/unplace.vim b/sources_non_forked/vim-gitgutter/unplace.vim deleted file mode 100644 index a97993d9..00000000 --- a/sources_non_forked/vim-gitgutter/unplace.vim +++ /dev/null @@ -1,27 +0,0 @@ -" Measure how long it takes to unplace signs. -" -" Source this file with `:source %` or `vim -S unplace.vim` - - -let num = 500 -sign define Foo text=* - -new - -call append(0, range(1, num)) - -for i in range(1, num) - execute "sign place ".i." line=".i." name=Foo buffer=".bufnr('') -endfor - -let start = reltime() -for i in range(1, num) - execute "sign unplace ".i -endfor -let elapsed = reltime(start) - -bdelete! - -echom split(reltimestr(elapsed))[0]."s to remove ".num." signs" -echom string(reltimefloat(elapsed) * 1000 / num).' ms/sign' -echom string(float2nr(num / reltimefloat(elapsed))).' sign/s' diff --git a/sources_non_forked/vim-javascript/ftdetect/javascript.vim b/sources_non_forked/vim-javascript/ftdetect/javascript.vim index 6c4105e4..00487326 100644 --- a/sources_non_forked/vim-javascript/ftdetect/javascript.vim +++ b/sources_non_forked/vim-javascript/ftdetect/javascript.vim @@ -4,5 +4,5 @@ fun! s:SelectJavascript() endif endfun -autocmd BufNewFile,BufRead *.{js,mjs,jsm,es,es6},Jakefile setfiletype javascript +autocmd BufNewFile,BufRead *.{js,mjs,cjs,jsm,es,es6},Jakefile setfiletype javascript autocmd BufNewFile,BufRead * call s:SelectJavascript() diff --git a/sources_non_forked/vim-javascript/syntax/javascript.vim b/sources_non_forked/vim-javascript/syntax/javascript.vim index 4d1a7e50..6a13434a 100644 --- a/sources_non_forked/vim-javascript/syntax/javascript.vim +++ b/sources_non_forked/vim-javascript/syntax/javascript.vim @@ -51,8 +51,8 @@ syntax keyword jsFrom contained from skipwhite skipempty nextgroup syntax match jsModuleComma contained /,/ skipwhite skipempty nextgroup=jsModuleKeyword,jsModuleAsterisk,jsModuleGroup,jsFlowTypeKeyword " Strings, Templates, Numbers -syntax region jsString start=+\z(["']\)+ skip=+\\\%(\z1\|$\)+ end=+\z1+ end=+$+ contains=jsSpecial,@Spell extend -syntax region jsTemplateString start=+`+ skip=+\\`+ end=+`+ contains=jsTemplateExpression,jsSpecial,@Spell extend +syntax region jsString start=+\z(["']\)+ skip=+\\\%(\z1\|$\)+ end=+\z1+ end=+$+ contains=jsSpecial extend +syntax region jsTemplateString start=+`+ skip=+\\`+ end=+`+ contains=jsTemplateExpression,jsSpecial extend syntax match jsTaggedTemplate /\<\K\k*\ze`/ nextgroup=jsTemplateString syntax match jsNumber /\c\<\%(\d\+\%(e[+-]\=\d\+\)\=\|0b[01]\+\|0o\o\+\|0x\x\+\)\>/ syntax keyword jsNumber Infinity @@ -74,14 +74,14 @@ syntax cluster jsRegexpSpecial contains=jsSpecial,jsRegexpBoundary,jsRegexpBa " Objects syntax match jsObjectShorthandProp contained /\<\k*\ze\s*/ skipwhite skipempty nextgroup=jsObjectSeparator syntax match jsObjectKey contained /\<\k*\ze\s*:/ contains=jsFunctionKey skipwhite skipempty nextgroup=jsObjectValue -syntax region jsObjectKeyString contained start=+\z(["']\)+ skip=+\\\%(\z1\|$\)+ end=+\z1\|$+ contains=jsSpecial,@Spell skipwhite skipempty nextgroup=jsObjectValue +syntax region jsObjectKeyString contained start=+\z(["']\)+ skip=+\\\%(\z1\|$\)+ end=+\z1\|$+ contains=jsSpecial skipwhite skipempty nextgroup=jsObjectValue syntax region jsObjectKeyComputed contained matchgroup=jsBrackets start=/\[/ end=/]/ contains=@jsExpression skipwhite skipempty nextgroup=jsObjectValue,jsFuncArgs extend syntax match jsObjectSeparator contained /,/ syntax region jsObjectValue contained matchgroup=jsObjectColon start=/:/ end=/[,}]\@=/ contains=@jsExpression extend syntax match jsObjectFuncName contained /\<\K\k*\ze\_s*(/ skipwhite skipempty nextgroup=jsFuncArgs syntax match jsFunctionKey contained /\<\K\k*\ze\s*:\s*function\>/ syntax match jsObjectMethodType contained /\<[gs]et\ze\s\+\K\k*/ skipwhite skipempty nextgroup=jsObjectFuncName -syntax region jsObjectStringKey contained start=+\z(["']\)+ skip=+\\\%(\z1\|$\)+ end=+\z1\|$+ contains=jsSpecial,@Spell extend skipwhite skipempty nextgroup=jsFuncArgs,jsObjectValue +syntax region jsObjectStringKey contained start=+\z(["']\)+ skip=+\\\%(\z1\|$\)+ end=+\z1\|$+ contains=jsSpecial extend skipwhite skipempty nextgroup=jsFuncArgs,jsObjectValue exe 'syntax keyword jsNull null '.(exists('g:javascript_conceal_null') ? 'conceal cchar='.g:javascript_conceal_null : '') exe 'syntax keyword jsReturn return contained '.(exists('g:javascript_conceal_return') ? 'conceal cchar='.g:javascript_conceal_return : '').' skipwhite nextgroup=@jsExpression' @@ -184,10 +184,10 @@ syntax match jsClassNoise contained /\./ syntax match jsClassFuncName contained /\<\K\k*\ze\s*[(<]/ skipwhite skipempty nextgroup=jsFuncArgs,jsFlowClassFunctionGroup syntax match jsClassMethodType contained /\<\%([gs]et\|static\)\ze\s\+\K\k*/ skipwhite skipempty nextgroup=jsAsyncKeyword,jsClassFuncName,jsClassProperty syntax region jsClassDefinition start=/\/ end=/\(\\s\+\)\@ -1 + let l:line = substitute(l:line, '\v^#*[ ]*', '', '') + let l:line = substitute(l:line, '\v[ ]*#*$', '', '') + endif + " append line to list + let l:level = s:GetHeaderLevel(i) + let l:item = {'level': l:level, 'text': l:line, 'lnum': i, 'bufnr': bufnr} + let l:header_list = l:header_list + [l:item] + endif + endfor + return l:header_list +endfunction + " Returns the level of the header at the given line. " " If there is no header at the given line, returns `0`. @@ -175,6 +227,7 @@ endfunction function! s:MoveToParentHeader() let l:linenum = s:GetParentHeaderLineNumber() if l:linenum != 0 + call setpos("''", getpos('.')) call cursor(l:linenum, 1) else echo 'no parent header' @@ -303,65 +356,38 @@ function! s:Toc(...) endif - let l:bufnr = bufnr('%') let l:cursor_line = line('.') let l:cursor_header = 0 - let l:fenced_block = 0 - let l:front_matter = 0 - let l:header_list = [] - let l:header_max_len = 0 - let l:vim_markdown_toc_autofit = get(g:, "vim_markdown_toc_autofit", 0) - let l:vim_markdown_frontmatter = get(g:, "vim_markdown_frontmatter", 0) - for i in range(1, line('$')) - let l:lineraw = getline(i) - let l:l1 = getline(i+1) - let l:line = substitute(l:lineraw, "#", "\\\#", "g") - if l:line =~ '````*' || l:line =~ '\~\~\~\~*' - if l:fenced_block == 0 - let l:fenced_block = 1 - elseif l:fenced_block == 1 - let l:fenced_block = 0 - endif - elseif l:vim_markdown_frontmatter == 1 - if l:front_matter == 1 - if l:line == '---' - let l:front_matter = 0 - endif - elseif i == 1 - if l:line == '---' - let l:front_matter = 1 - endif - endif - endif - if l:line =~ '^#\+' || (l:l1 =~ '^=\+\s*$' || l:l1 =~ '^-\+\s*$') && l:line =~ '^\S' - let l:is_header = 1 - else - let l:is_header = 0 - endif - if l:is_header == 1 && l:fenced_block == 0 && l:front_matter == 0 - " append line to location list - let l:item = {'lnum': i, 'text': l:line, 'valid': 1, 'bufnr': l:bufnr, 'col': 1} - let l:header_list = l:header_list + [l:item] - " set header number of the cursor position - if l:cursor_header == 0 - if i == l:cursor_line - let l:cursor_header = len(l:header_list) - elseif i > l:cursor_line - let l:cursor_header = len(l:header_list) - 1 - endif - endif - " keep track of the longest header size (heading level + title) - let l:total_len = stridx(l:line, ' ') + strdisplaywidth(l:line) - if l:total_len > l:header_max_len - let l:header_max_len = l:total_len - endif - endif - endfor - call setloclist(0, l:header_list) + let l:header_list = s:GetHeaderList() + let l:indented_header_list = [] if len(l:header_list) == 0 echom "Toc: No headers." return endif + let l:header_max_len = 0 + let l:vim_markdown_toc_autofit = get(g:, "vim_markdown_toc_autofit", 0) + for h in l:header_list + " set header number of the cursor position + if l:cursor_header == 0 + let l:header_line = h.lnum + if l:header_line == l:cursor_line + let l:cursor_header = index(l:header_list, h) + 1 + elseif l:header_line > l:cursor_line + let l:cursor_header = index(l:header_list, h) + endif + endif + " indent header based on level + let l:text = repeat(' ', h.level-1) . h.text + " keep track of the longest header size (heading level + title) + let l:total_len = strdisplaywidth(l:text) + if l:total_len > l:header_max_len + let l:header_max_len = l:total_len + endif + " append indented line to list + let l:item = {'lnum': h.lnum, 'text': l:text, 'valid': 1, 'bufnr': h.bufnr, 'col': 1} + let l:indented_header_list = l:indented_header_list + [l:item] + endfor + call setloclist(0, l:indented_header_list) if l:window_type ==# 'horizontal' lopen @@ -369,7 +395,8 @@ function! s:Toc(...) vertical lopen " auto-fit toc window when possible to shrink it if (&columns/2) > l:header_max_len && l:vim_markdown_toc_autofit == 1 - execute 'vertical resize ' . (l:header_max_len + 1) + " header_max_len + 1 space for first header + 3 spaces for line numbers + execute 'vertical resize ' . (l:header_max_len + 1 + 3) else execute 'vertical resize ' . (&columns/2) endif @@ -382,27 +409,84 @@ function! s:Toc(...) for i in range(1, line('$')) " this is the location-list data for the current item let d = getloclist(0)[i-1] - " atx headers - if match(d.text, "^#") > -1 - let l:level = len(matchstr(d.text, '#*', 'g'))-1 - let d.text = substitute(d.text, '\v^#*[ ]*', '', '') - let d.text = substitute(d.text, '\v[ ]*#*$', '', '') - " setex headers - else - let l:next_line = getbufline(d.bufnr, d.lnum+1) - if match(l:next_line, "=") > -1 - let l:level = 0 - elseif match(l:next_line, "-") > -1 - let l:level = 1 - endif - endif - call setline(i, repeat(' ', l:level). d.text) + call setline(i, d.text) endfor setlocal nomodified setlocal nomodifiable execute 'normal! ' . l:cursor_header . 'G' endfunction +function! s:InsertToc(format, ...) + if a:0 > 0 + if type(a:1) != type(0) + echohl WarningMsg + echomsg '[vim-markdown] Invalid argument, must be an integer >= 2.' + echohl None + return + endif + let l:max_level = a:1 + if l:max_level < 2 + echohl WarningMsg + echomsg '[vim-markdown] Maximum level cannot be smaller than 2.' + echohl None + return + endif + else + let l:max_level = 0 + endif + + let l:toc = [] + let l:header_list = s:GetHeaderList() + if len(l:header_list) == 0 + echom "InsertToc: No headers." + return + endif + + if a:format ==# 'numbers' + let l:h2_count = 0 + for header in l:header_list + if header.level == 2 + let l:h2_count += 1 + endif + endfor + let l:max_h2_number_len = strlen(string(l:h2_count)) + else + let l:max_h2_number_len = 0 + endif + + let l:h2_count = 0 + for header in l:header_list + let l:level = header.level + if l:level == 1 + " skip level-1 headers + continue + elseif l:max_level != 0 && l:level > l:max_level + " skip unwanted levels + continue + elseif l:level == 2 + " list of level-2 headers can be bullets or numbers + if a:format ==# 'bullets' + let l:indent = '' + let l:marker = '* ' + else + let l:h2_count += 1 + let l:number_len = strlen(string(l:h2_count)) + let l:indent = repeat(' ', l:max_h2_number_len - l:number_len) + let l:marker = l:h2_count . '. ' + endif + else + let l:indent = repeat(' ', l:max_h2_number_len + 2 * (l:level - 2)) + let l:marker = '* ' + endif + let l:text = '[' . header.text . ']' + let l:link = '(#' . substitute(tolower(header.text), '\v[ ]+', '-', 'g') . ')' + let l:line = l:indent . l:marker . l:text . l:link + let l:toc = l:toc + [l:line] + endfor + + call append(line('.'), l:toc) +endfunction + " Convert Setex headers in range `line1 .. line2` to Atx. " " Return the number of conversions. @@ -679,6 +763,8 @@ command! -buffer Toc call s:Toc() command! -buffer Toch call s:Toc('horizontal') command! -buffer Tocv call s:Toc('vertical') command! -buffer Toct call s:Toc('tab') +command! -buffer -nargs=? InsertToc call s:InsertToc('bullets', ) +command! -buffer -nargs=? InsertNToc call s:InsertToc('numbers', ) " Heavily based on vim-notes - http://peterodding.com/code/vim/notes/ if exists('g:vim_markdown_fenced_languages') @@ -702,7 +788,7 @@ function! s:MarkdownHighlightSources(force) " Look for code blocks in the current file let filetypes = {} for line in getline(1, '$') - let ft = matchstr(line, '```\s*\zs[0-9A-Za-z_+-]*') + let ft = matchstr(line, '```\s*\zs[0-9A-Za-z_+-]*\ze.*') if !empty(ft) && ft !~ '^\d*$' | let filetypes[ft] = 1 | endif endfor if !exists('b:mkd_known_filetypes') @@ -733,7 +819,7 @@ function! s:MarkdownHighlightSources(force) else let include = '@' . toupper(filetype) endif - let command = 'syntax region %s matchgroup=%s start="^\s*```\s*%s$" matchgroup=%s end="\s*```$" keepend contains=%s%s' + let command = 'syntax region %s matchgroup=%s start="^\s*```\s*%s.*$" matchgroup=%s end="\s*```$" keepend contains=%s%s' execute printf(command, group, startgroup, ft, endgroup, include, has('conceal') && get(g:, 'vim_markdown_conceal', 1) && get(g:, 'vim_markdown_conceal_code_blocks', 1) ? ' concealends' : '') execute printf('syntax cluster mkdNonListItem add=%s', group) diff --git a/sources_non_forked/vim-markdown/syntax/markdown.vim b/sources_non_forked/vim-markdown/syntax/markdown.vim index c1a2b2ca..0a028507 100644 --- a/sources_non_forked/vim-markdown/syntax/markdown.vim +++ b/sources_non_forked/vim-markdown/syntax/markdown.vim @@ -70,10 +70,10 @@ execute 'syn region mkdLink matchgroup=mkdDelimiter start="\\\@ ]*>" end=">" @@ -103,8 +103,8 @@ execute 'syn region mkdCode matchgroup=mkdCodeDelimiter start=/\(\([^\\]\|^\)\\\ execute 'syn region mkdCode matchgroup=mkdCodeDelimiter start=/^\s*\z(`\{3,}\)[^`]*$/ end=/^\s*\z1`*\s*$/' . s:concealcode execute 'syn region mkdCode matchgroup=mkdCodeDelimiter start=/\(\([^\\]\|^\)\\\)\@]*\\\@" end=""' . s:concealcode -execute 'syn region mkdCode matchgroup=mkdCodeDelimiter start="]*\\\@" end=""' . s:concealcode +execute 'syn region mkdCode matchgroup=mkdCodeDelimiter start="]*\)\\\@" end=""' . s:concealcode +execute 'syn region mkdCode matchgroup=mkdCodeDelimiter start="]*\)\\\@" end=""' . s:concealcode syn region mkdFootnote start="\[^" end="\]" syn match mkdCode /^\s*\n\(\(\s\{8,}[^ ]\|\t\t\+[^\t]\).*\n\)\+/ syn match mkdCode /\%^\(\(\s\{4,}[^ ]\|\t\+[^\t]\).*\n\)\+/ diff --git a/sources_non_forked/vim-markdown/test/folding-toc.vader b/sources_non_forked/vim-markdown/test/folding-toc.vader index 79c54001..26590043 100644 --- a/sources_non_forked/vim-markdown/test/folding-toc.vader +++ b/sources_non_forked/vim-markdown/test/folding-toc.vader @@ -120,28 +120,28 @@ Execute (check TOC): let res = getloclist(0) let elem = res[0] AssertEqual elem.lnum, 1 - AssertEqual elem.text, '# chap 1' + AssertEqual elem.text, 'chap 1' let elem = res[1] AssertEqual elem.lnum, 15 - AssertEqual elem.text, '## chap 1.1' + AssertEqual elem.text, ' chap 1.1' let elem = res[2] AssertEqual elem.lnum, 25 - AssertEqual elem.text, '### chap 1.1.1' + AssertEqual elem.text, ' chap 1.1.1' let elem = res[3] AssertEqual elem.lnum, 30 - AssertEqual elem.text, '# chap 2' + AssertEqual elem.text, 'chap 2' let elem = res[4] AssertEqual elem.lnum, 34 - AssertEqual elem.text, '## chap 2.1' + AssertEqual elem.text, ' chap 2.1' let elem = res[5] AssertEqual elem.lnum, 41 - AssertEqual elem.text, '# chap 3' + AssertEqual elem.text, 'chap 3' let elem = res[6] AssertEqual elem.lnum, 45 AssertEqual elem.text, 'chap 4' let elem = res[7] AssertEqual elem.lnum, 50 - AssertEqual elem.text, 'chap 4.1' + AssertEqual elem.text, ' chap 4.1' Given markdown; --- @@ -174,5 +174,5 @@ Execute (check Toc of yaml front matter): AssertEqual len(res), 1 let elem = res[0] AssertEqual elem.lnum, 8 - AssertEqual elem.text, 'heading' + AssertEqual elem.text, ' heading' unlet g:vim_markdown_frontmatter diff --git a/sources_non_forked/vim-markdown/test/insert-toc.vader b/sources_non_forked/vim-markdown/test/insert-toc.vader new file mode 100644 index 00000000..b8d669bc --- /dev/null +++ b/sources_non_forked/vim-markdown/test/insert-toc.vader @@ -0,0 +1,147 @@ +Given markdown; +# a + +## Foo Level 2 + +### Foo Level 3 + +#### Foo Level 4 + +Bar Level 2 +----------- + +### Bar Level 3 + +Execute (InsertToc format): + :2 + :call append('.', '') + :InsertToc + +Expect (format): + # a + + * [Foo Level 2](#foo-level-2) + * [Foo Level 3](#foo-level-3) + * [Foo Level 4](#foo-level-4) + * [Bar Level 2](#bar-level-2) + * [Bar Level 3](#bar-level-3) + + ## Foo Level 2 + + ### Foo Level 3 + + #### Foo Level 4 + + Bar Level 2 + ----------- + + ### Bar Level 3 + +Given markdown; +# a + +## Foo Level 2 + +### Foo Level 3 + +#### Foo Level 4 + +Bar Level 2 +----------- + +### Bar Level 3 + +Execute (InsertToc only h2 headers): + :2 + :call append('.', '') + :InsertToc 2 + +Expect (only h2 headers): + # a + + * [Foo Level 2](#foo-level-2) + * [Bar Level 2](#bar-level-2) + + ## Foo Level 2 + + ### Foo Level 3 + + #### Foo Level 4 + + Bar Level 2 + ----------- + + ### Bar Level 3 + +Given markdown; +# a + +## Foo Level 2 + +### Foo Level 3 + +#### Foo Level 4 + +Bar Level 2 +----------- + +## Baz Level 2 + +## Foobar Level 2 + +## Foobaz Level 2 + +## Barfoo Level 2 + +## Barbaz Level 2 + +## Bazfoo Level 2 + +## Bazbar Level 2 + +## Foobarbaz Level 2 + +Execute (InsertNToc format, and up to h3 headers): + :2 + :call append('.', '') + :InsertNToc 3 + +Expect (format, and up to h3 headers): + # a + + 1. [Foo Level 2](#foo-level-2) + * [Foo Level 3](#foo-level-3) + 2. [Bar Level 2](#bar-level-2) + 3. [Baz Level 2](#baz-level-2) + 4. [Foobar Level 2](#foobar-level-2) + 5. [Foobaz Level 2](#foobaz-level-2) + 6. [Barfoo Level 2](#barfoo-level-2) + 7. [Barbaz Level 2](#barbaz-level-2) + 8. [Bazfoo Level 2](#bazfoo-level-2) + 9. [Bazbar Level 2](#bazbar-level-2) + 10. [Foobarbaz Level 2](#foobarbaz-level-2) + + ## Foo Level 2 + + ### Foo Level 3 + + #### Foo Level 4 + + Bar Level 2 + ----------- + + ## Baz Level 2 + + ## Foobar Level 2 + + ## Foobaz Level 2 + + ## Barfoo Level 2 + + ## Barbaz Level 2 + + ## Bazfoo Level 2 + + ## Bazbar Level 2 + + ## Foobarbaz Level 2 diff --git a/sources_non_forked/vim-markdown/test/syntax.vader b/sources_non_forked/vim-markdown/test/syntax.vader index 5ce94fc2..03496ced 100644 --- a/sources_non_forked/vim-markdown/test/syntax.vader +++ b/sources_non_forked/vim-markdown/test/syntax.vader @@ -634,7 +634,8 @@ Given markdown; Execute (link with url title): AssertEqual SyntaxOf('https://domain.tld'), 'mkdInlineURL' - AssertEqual SyntaxOf('https://domain.com'), 'mkdInlineURL' + AssertNotEqual SyntaxOf(']'), 'mkdInlineURL' + AssertEqual SyntaxOf('https://domain.com'), 'mkdURL' AssertNotEqual SyntaxOf('not_a_link'), 'mkdInlineURL' # Code Blocks @@ -738,12 +739,18 @@ def a end ``` +```ruby {linenos=table,hl_lines=[8,"15-17"],linenostart=199} +class b +end +``` + Execute (fenced code block syntax with a language specifier): let b:func = Markdown_GetFunc('vim-markdown/ftplugin/markdown.vim', 'MarkdownRefreshSyntax') call b:func(0) AssertEqual SyntaxOf('include'), 'cInclude' AssertEqual SyntaxOf('code'), 'mkdSnippetCPP' AssertEqual SyntaxOf('def'), 'rubyDefine' + AssertEqual SyntaxOf('class'), 'rubyClass' Given markdown; ``` c++ @@ -957,12 +964,12 @@ $$ \frac{a}{b} $$ Execute (math tex highlighting): let g:vim_markdown_math=0 syn off | syn on - AssertNotEqual SyntaxOf('sqrt'), 'texStatement' - AssertNotEqual SyntaxOf('frac'), 'texStatement' + AssertNotEqual SyntaxOf('sqrt')[0:2], 'tex' + AssertNotEqual SyntaxOf('frac')[0:2], 'tex' let g:vim_markdown_math=1 syn off | syn on - AssertEqual SyntaxOf('sqrt'), 'texStatement' - AssertEqual SyntaxOf('frac'), 'texStatement' + AssertEqual SyntaxOf('sqrt')[0:2], 'tex' + AssertEqual SyntaxOf('frac')[0:2], 'tex' Given markdown; $a b[$ c @@ -985,7 +992,7 @@ Execute (math ends with $$): AssertNotEqual SyntaxOf('c')[0:2], 'tex' Given markdown; -$(0 \le 1)$ +$(0 \leq 1)$ Execute (math conceal in $): if has('conceal') @@ -996,20 +1003,21 @@ Execute (math conceal in $): AssertEqual synconcealed(1, 2)[0], 0 AssertEqual synconcealed(1, 3)[0], 0 AssertEqual synconcealed(1, 4)[0], 0 - AssertEqual synconcealed(1, 5)[0], 1, '\le' + AssertEqual synconcealed(1, 5)[0], 1, '\leq' AssertEqual synconcealed(1, 6)[0], 1 AssertEqual synconcealed(1, 7)[0], 1 - AssertEqual synconcealed(1, 8)[0], 0 + AssertEqual synconcealed(1, 8)[0], 1 AssertEqual synconcealed(1, 9)[0], 0 AssertEqual synconcealed(1, 10)[0], 0 - AssertEqual synconcealed(1, 11)[0], 1, '$' + AssertEqual synconcealed(1, 11)[0], 0 + AssertEqual synconcealed(1, 12)[0], 1, '$' setlocal conceallevel=0 endif Given markdown; $$ \omega -0 \le 1 +0 \leq 1 $$ Execute (math conceal in $$): @@ -1020,8 +1028,8 @@ Execute (math conceal in $$): AssertEqual synconcealed(1, 1)[0], 1, '$$' AssertEqual synconcealed(2, 1)[0], 1, '\omega' AssertEqual synconcealed(3, 1)[0], 0, '0' - AssertEqual synconcealed(3, 3)[0], 1, '\le' - AssertEqual synconcealed(3, 7)[0], 0, '1' + AssertEqual synconcealed(3, 3)[0], 1, '\leq' + AssertEqual synconcealed(3, 8)[0], 0, '1' AssertEqual synconcealed(4, 1)[0], 1, '$$' setlocal conceallevel=0 endif diff --git a/sources_non_forked/vim-multiple-cursors/.travis.yml b/sources_non_forked/vim-multiple-cursors/.travis.yml index cfb198ab..98d432c2 100644 --- a/sources_non_forked/vim-multiple-cursors/.travis.yml +++ b/sources_non_forked/vim-multiple-cursors/.travis.yml @@ -1,11 +1,12 @@ -sudo: false +os: linux +dist: bionic language: ruby addons: apt: packages: - vim-gtk + - xvfb -before_script: - - "export DISPLAY=:99.0" - - "sh -e /etc/init.d/xvfb start" +script: + - xvfb-run bundle exec rake diff --git a/sources_non_forked/vim-multiple-cursors/README.md b/sources_non_forked/vim-multiple-cursors/README.md index 7a6eb479..fd473b0f 100644 --- a/sources_non_forked/vim-multiple-cursors/README.md +++ b/sources_non_forked/vim-multiple-cursors/README.md @@ -1,5 +1,7 @@ +# **❗ This plugin is deprecated, use [vim-visual-multi](https://github.com/mg979/vim-visual-multi) instead ❗** + # vim-multiple-cursors -[![Build Status](https://travis-ci.org/terryma/vim-multiple-cursors.svg)](https://travis-ci.org/terryma/vim-multiple-cursors) +[![Build Status](https://travis-ci.org/terryma/vim-multiple-cursors.svg?branch=master)](https://travis-ci.org/github/terryma/vim-multiple-cursors) ## Contents - [About](#about) @@ -103,6 +105,9 @@ let g:multi_cursor_quit_key = '' ## Settings Currently there are four additional global settings one can tweak: +### ```g:multi_cursor_support_imap``` (Default: 1) +If set to 0, insert mappings won't be supported in _Insert_ mode anymore. + ### ```g:multi_cursor_exit_from_visual_mode``` (Default: 0) If set to 1, then pressing `g:multi_cursor_quit_key` in _Visual_ mode will quit and delete all existing cursors, just skipping normal mode with multiple cursors. diff --git a/sources_non_forked/vim-multiple-cursors/autoload/multiple_cursors.vim b/sources_non_forked/vim-multiple-cursors/autoload/multiple_cursors.vim index c2739755..32a9aec3 100644 --- a/sources_non_forked/vim-multiple-cursors/autoload/multiple_cursors.vim +++ b/sources_non_forked/vim-multiple-cursors/autoload/multiple_cursors.vim @@ -1234,7 +1234,7 @@ function! s:wait_for_user_input(mode) " imap jj JJ " imap jjj JJJ " will always trigger the 'jj' mapping - if s:from_mode ==# 'i' && mapcheck(s:char, "i") != "" + if s:from_mode ==# 'i' && mapcheck(s:char, "i") != "" && g:multi_cursor_support_imap let map_dict = {} let s_time = s:get_time_in_ms() while 1 @@ -1285,7 +1285,7 @@ function! s:wait_for_user_input(mode) call s:start_latency_measure() " Clears any echoes we might've added - normal! : + normal! : " add chars to s:char if it start like a special/quit key let is_special_key = 0 diff --git a/sources_non_forked/vim-multiple-cursors/doc/multiple_cursors.txt b/sources_non_forked/vim-multiple-cursors/doc/multiple_cursors.txt index a01b4ed0..ab86815b 100644 --- a/sources_non_forked/vim-multiple-cursors/doc/multiple_cursors.txt +++ b/sources_non_forked/vim-multiple-cursors/doc/multiple_cursors.txt @@ -94,6 +94,10 @@ otherwise you'll have a tough time quitting from multicursor mode. Currently there are four additional global settings one can tweak: +*g:multi_cursor_support_imap* (Default: 1) + +If set to 0, insert mappings won't be supported in |insert-mode| anymore. + *g:multi_cursor_exit_from_visual_mode* (Default: 0) If set to 0, then pressing |g:multi_cursor_quit_key| in |visual-mode| will quit diff --git a/sources_non_forked/vim-multiple-cursors/plugin/multiple_cursors.vim b/sources_non_forked/vim-multiple-cursors/plugin/multiple_cursors.vim index 0f6e41f4..e7f975a1 100644 --- a/sources_non_forked/vim-multiple-cursors/plugin/multiple_cursors.vim +++ b/sources_non_forked/vim-multiple-cursors/plugin/multiple_cursors.vim @@ -31,6 +31,7 @@ let s:settings = { \ 'exit_from_insert_mode': 0, \ 'use_default_mapping': 1, \ 'debug_latency': 0, + \ 'support_imap': 1, \ } let s:settings_if_default = { diff --git a/sources_non_forked/vim-python-pep8-indent/indent/python.vim b/sources_non_forked/vim-python-pep8-indent/indent/python.vim index aca216e7..047ae3d7 100644 --- a/sources_non_forked/vim-python-pep8-indent/indent/python.vim +++ b/sources_non_forked/vim-python-pep8-indent/indent/python.vim @@ -158,8 +158,8 @@ function! s:find_start_of_block(lnum, types, skip, multiple) abort else let re_skip = '' endif - let lnum = a:lnum - let last_indent = indent(lnum) + 1 + let last_indent = indent(a:lnum) + 1 + let lnum = a:lnum - 1 while lnum > 0 && last_indent > 0 let indent = indent(lnum) if indent < last_indent @@ -260,7 +260,7 @@ function! s:indent_like_block(lnum) endif let [blocks, skip] = blocks_ignore - let indents = s:find_start_of_block(a:lnum - 1, blocks, skip, multiple) + let indents = s:find_start_of_block(a:lnum, blocks, skip, multiple) if empty(indents) return -1 endif diff --git a/sources_non_forked/vim-python-pep8-indent/spec/indent/indent_spec.rb b/sources_non_forked/vim-python-pep8-indent/spec/indent/indent_spec.rb index 55e2fba4..745e939d 100644 --- a/sources_non_forked/vim-python-pep8-indent/spec/indent/indent_spec.rb +++ b/sources_non_forked/vim-python-pep8-indent/spec/indent/indent_spec.rb @@ -774,3 +774,23 @@ describe "elif after else" do indent.should == 4 end end + +describe "elif after two ifs" do + before { + vim.feedkeys '\ggdG' + } + + it "keeps its indent to the outer if" do + vim.feedkeys 'iif 1:\if 2:\pass\elif 3:\pass\' + indent.should == 4 + vim.feedkeys '\' + indent.should == 0 + proposed_indent.should == shiftwidth + vim.feedkeys 'ielif 4:' + indent.should == 0 + proposed_indent.should == 0 + vim.feedkeys '\' + indent.should == 4 + proposed_indent.should == 4 + end +end diff --git a/sources_non_forked/vim-ruby/INSTALL.markdown b/sources_non_forked/vim-ruby/INSTALL.markdown index b767bb58..09e7b649 100644 --- a/sources_non_forked/vim-ruby/INSTALL.markdown +++ b/sources_non_forked/vim-ruby/INSTALL.markdown @@ -28,6 +28,9 @@ choosing another installation method. The version you download will supersede the version that ships with Vim, so you will now be responsible for keeping it up-to-date.) +If you're looking for stable releases from a particular version, you can find +them in [github](https://github.com/vim-ruby/vim-ruby/releases). + Manually -------- diff --git a/sources_non_forked/vim-ruby/README b/sources_non_forked/vim-ruby/README deleted file mode 100644 index 39d9d91f..00000000 --- a/sources_non_forked/vim-ruby/README +++ /dev/null @@ -1,73 +0,0 @@ - +---------------------------------+ - | vim-ruby github project README | - +---------------------------------+ - -Summary: - This project contains Vim configuration files for editing and compiling Ruby - within Vim. See the project homepage for more details. - -Web links: - Homepage: https://github.com/vim-ruby - Explanation: https://github.com/vim-ruby/vim-ruby/wiki - -For regular users: - - The project page should have two tarballs for download: - - vim-ruby-YYYY.MM.DD.tar.gz (the current stable release) - - vim-ruby-devel-YYYY.MM.DD.tar.gz (cutting-edge features we'd like you - to test) - - Please give feedback through the bug tracking and feature request features - of GitHub. - - Feel free to join discussions on the vim-ruby-devel mailing list: - http://rubyforge.org/mail/?group_id=16 - -For would-be contributors: - - Please get the latest from Git. - - Please join the mailing list and discuss changes, submit patches, etc. - - Thank you very much for taking an interest. - -Contents of the project: - - The autoload, compiler, ftdetect, ftplugin, indent and syntax directories - contain the ruby*.vim files that are to be copied to a location somewhere - in the Vim 'runtimepath'. - -How you get these files into Vim: - - By downloading the project via a snapshot or Git, you can keep up with - the latest, make changes, and install the files to a Vim directory. - - By downloading one of the tarballs, you can easily install the latest - stable or development version wherever you like on your machine. No - README etc. just Vim files. You would typically install these into either - $VIM/vimfiles, for system-wide use, or $HOME/.vim ($HOME/vimfiles on - Windows) for personal use. - - Remember that when you install Vim in the first place, all of these files - are present. The purpose of downloading and installing them from - GitHub is to get the latest version of them. - -Git topics: - - Project was migrated from CVS in August, 2008. - - Files are tagged according to which version of Vim they are released in. - - The project was initiated in July 2003, when the current version of Vim - was 6.2. Thus every file began its life tagged as vim6.2. - - Modifications to the files are made in the expectation that they need to - be tested by interested users. They therefore (probably) don't have a - tag, and are available via "git pull --rebase", or a development snapshot. - - When a modification is considered stable, it is given a tag. - Everything that is stable gets released in vim-ruby-YYY.MM.DD.tar.gz files. - - When a new version of Vim is about to be released, the stable tarball is - contributed to it. After it has been released, the files are tagged - accordingly. - - MORAL OF THE STORY: modifications are committed to the head of the tree; - when they are ready for release into userland, they are tagged "stable". - -Any questions or suggestions? - - If there's something about the project or its concepts that you don't - understand, send an email to the release coordinator, Doug Kearns - (dougkearns at gmail.com). - - To ask about the contents of the configuration files, open a GitHub issue - or ask on the mailing list, as different people maintain the different - files. - -Project gossip: - - While the individual effort to maintain these files has a long history, - this actual project began in late July 2003. - - --= End of Document =-- diff --git a/sources_non_forked/vim-ruby/README.markdown b/sources_non_forked/vim-ruby/README.markdown new file mode 100644 index 00000000..3a402271 --- /dev/null +++ b/sources_non_forked/vim-ruby/README.markdown @@ -0,0 +1,63 @@ +## Vim-ruby + +This project contains Vim's runtime files for ruby support. This includes syntax +highlighting, indentation, omnicompletion, and various useful tools and mappings. + +## Installation + +See the file [INSTALL.markdown](./INSTALL.markdown) for instructions. + +You might also find useful setup tips in the github wiki: +https://github.com/vim-ruby/vim-ruby/wiki/VimRubySupport + +## Usage + +Ideally, vim-ruby should work "correctly" for you out of the box. However, ruby +developers have varying preferences, so there are settings that control some of +the details. You can get more information on these by using the native `:help` +command: + +- [`:help vim-ruby-plugin`](./doc/ft-ruby-plugin.txt): Filetype settings and custom mappings +- [`:help vim-ruby-indent`](./doc/ft-ruby-indent.txt): Indentation settings +- [`:help vim-ruby-syntax`](./doc/ft-ruby-syntax.txt): Syntax-related tweaks +- [`:help vim-ruby-omni`](./doc/ft-ruby-omni.txt): Information and settings for omni completion + +## Issues + +If you have an issue or a feature request, it's recommended to use the github +issue tracker: https://github.com/vim-ruby/vim-ruby/issues. Try the search box +to look for an existing issue -- it might have already been reported. + +If you don't have a github account or would rather contact us in a different +way, you can find emails for individual maintainers in the +[CONTRIBUTORS](./CONTRIBUTORS) file. They're also in the comment headers of the +project's Vimscript files (`syntax/ruby.vim`, `indent/ruby.vim`, etc) under the +label "Maintainer". + +If you're not sure who the most relevant person to contact is for your +particular issue, you can send an email to the release coordinator, Doug Kearns +(dougkearns at gmail.com). + +## Contributing + +Vim-ruby is a mature project, which is one way of saying it moves slowly and it +can be a bit difficult to modify. It's far from impossible, but be warned that +issues and PRs may take time to be handled. Partly, it's because we don't want +to risk breaking Vim's core ruby support, partly because it takes a lot of time +and energy to debug and fix things. + +Contributing a fix for an issue would be very appreciated, even if it's a +proof-of-concept to start a conversation. Be warned that we're definitely going +to be conservative when considering changes to vim-ruby. + +The code is tested using [RSpec](https://rspec.info/) and +[Vimrunner](https://github.com/AndrewRadev/vimrunner). The tests are not +exhaustive, but they should cover a wide variety of cases. + +## Project history + +This project began in July 2003, when the current version of Vim was 6.2. It +was migrated from CVS in August, 2008. + +If you're curious about individual pre-git changes, you can read some of them +in the (unmaintained) [NEWS](./NEWS) and/or [ChangeLog](./ChangeLog) files. diff --git a/sources_non_forked/vim-ruby/autoload/rubycomplete.vim b/sources_non_forked/vim-ruby/autoload/rubycomplete.vim index c77884ad..8eff8003 100644 --- a/sources_non_forked/vim-ruby/autoload/rubycomplete.vim +++ b/sources_non_forked/vim-ruby/autoload/rubycomplete.vim @@ -500,13 +500,8 @@ class VimRubyCompletion return if rails_base == nil $:.push rails_base unless $:.index( rails_base ) - rails_config = rails_base + "config/" - rails_lib = rails_base + "lib/" - $:.push rails_config unless $:.index( rails_config ) - $:.push rails_lib unless $:.index( rails_lib ) - - bootfile = rails_config + "boot.rb" - envfile = rails_config + "environment.rb" + bootfile = rails_base + "config/boot.rb" + envfile = rails_base + "config/environment.rb" if File.exists?( bootfile ) && File.exists?( envfile ) begin require bootfile diff --git a/sources_non_forked/vim-ruby/doc/ft-ruby-indent.txt b/sources_non_forked/vim-ruby/doc/ft-ruby-indent.txt index 02f613e4..f59d7b32 100644 --- a/sources_non_forked/vim-ruby/doc/ft-ruby-indent.txt +++ b/sources_non_forked/vim-ruby/doc/ft-ruby-indent.txt @@ -1,8 +1,10 @@ RUBY *ft-ruby-indent* + *vim-ruby-indent* Ruby: Access modifier indentation |ruby-access-modifier-indentation| Ruby: Block style indentation |ruby-block-style-indentation| Ruby: Assignment style indentation |ruby-assignment-style-indentation| + Ruby: Hanging element indentation |ruby-hanging-element-indentation| *ruby-access-modifier-indentation* *g:ruby_indent_access_modifier_style* @@ -64,7 +66,7 @@ Different block indentation styles can be used by setting: > :let g:ruby_indent_block_style = 'expression' :let g:ruby_indent_block_style = 'do' < -By default, the "expression" block indent style is used. +By default, the "do" block indent style is used. Block indent style "expression": > @@ -105,5 +107,42 @@ Assignment indent style "variable": end < + *ruby-hanging-element-indentation* + *g:ruby_indent_hanging_elements* + Ruby: Hanging element indentation ~ + +Elements of multiline collections -- such as arrays, hashes, and method +argument lists -- can have hanging indentation enabled or disabled with the +following setting. +> + :let g:ruby_indent_hanging_elements = 1 + :let g:ruby_indent_hanging_elements = 0 +< +By default, this setting is "1" (true) meaning that hanging indentation is +enabled in some cases. + +Here is an example method call when the setting is true (non-zero): +> + render('product/show', + product: product, + on_sale: true, + ) +< +And the same method call when the setting is false (zero): +> + render('product/show', + product: product, + on_sale: true, + ) +< +Note that, even if the setting is turned on, you can still get non-hanging +indentation by putting each argument on a separate line: +> + render( + 'product/show', + product: product, + on_sale: true, + ) +< vim:tw=78:sw=4:ts=8:ft=help:norl: diff --git a/sources_non_forked/vim-ruby/doc/ft-ruby-omni.txt b/sources_non_forked/vim-ruby/doc/ft-ruby-omni.txt index f6780899..2abe97fd 100644 --- a/sources_non_forked/vim-ruby/doc/ft-ruby-omni.txt +++ b/sources_non_forked/vim-ruby/doc/ft-ruby-omni.txt @@ -1,4 +1,5 @@ RUBY *ft-ruby-omni* + *vim-ruby-omni* Completion of Ruby code requires that Vim be built with |+ruby|. diff --git a/sources_non_forked/vim-ruby/doc/ft-ruby-plugin.txt b/sources_non_forked/vim-ruby/doc/ft-ruby-plugin.txt index 527a8b66..80b451d8 100644 --- a/sources_non_forked/vim-ruby/doc/ft-ruby-plugin.txt +++ b/sources_non_forked/vim-ruby/doc/ft-ruby-plugin.txt @@ -1,4 +1,6 @@ RUBY *ft-ruby-plugin* + *vim-ruby-plugin* + Ruby: Recommended settings |ruby-recommended| Ruby: Motion commands |ruby-motion| diff --git a/sources_non_forked/vim-ruby/doc/ft-ruby-syntax.txt b/sources_non_forked/vim-ruby/doc/ft-ruby-syntax.txt index 72c826a9..2979f20c 100644 --- a/sources_non_forked/vim-ruby/doc/ft-ruby-syntax.txt +++ b/sources_non_forked/vim-ruby/doc/ft-ruby-syntax.txt @@ -1,4 +1,5 @@ RUBY *ruby.vim* *ft-ruby-syntax* + *vim-ruby-syntax* Ruby: Operator highlighting |ruby_operators| Ruby: Whitespace errors |ruby_space_errors| diff --git a/sources_non_forked/vim-ruby/ftplugin/eruby.vim b/sources_non_forked/vim-ruby/ftplugin/eruby.vim index 6d6e6167..f16715ab 100644 --- a/sources_non_forked/vim-ruby/ftplugin/eruby.vim +++ b/sources_non_forked/vim-ruby/ftplugin/eruby.vim @@ -117,7 +117,7 @@ endif " TODO: comments= setlocal commentstring=<%#%s%> -let b:undo_ftplugin = "setl cms< " +let b:undo_ftplugin = "setl cms< " . \ " | unlet! b:browsefilter b:match_words | " . s:undo_ftplugin let &cpo = s:save_cpo diff --git a/sources_non_forked/vim-ruby/ftplugin/ruby.vim b/sources_non_forked/vim-ruby/ftplugin/ruby.vim index 90a9bda8..81457288 100644 --- a/sources_non_forked/vim-ruby/ftplugin/ruby.vim +++ b/sources_non_forked/vim-ruby/ftplugin/ruby.vim @@ -111,7 +111,7 @@ else if !exists('g:ruby_default_path') if has("ruby") && has("win32") ruby ::VIM::command( 'let g:ruby_default_path = split("%s",",")' % $:.join(%q{,}) ) - elseif executable('ruby') + elseif executable('ruby') && !empty($HOME) let g:ruby_default_path = s:query_path($HOME) else let g:ruby_default_path = map(split($RUBYLIB,':'), 'v:val ==# "." ? "" : v:val') diff --git a/sources_non_forked/vim-ruby/indent/ruby.vim b/sources_non_forked/vim-ruby/indent/ruby.vim index bfc32e5a..fb3768da 100644 --- a/sources_non_forked/vim-ruby/indent/ruby.vim +++ b/sources_non_forked/vim-ruby/indent/ruby.vim @@ -26,7 +26,12 @@ endif if !exists('g:ruby_indent_block_style') " Possible values: "expression", "do" - let g:ruby_indent_block_style = 'expression' + let g:ruby_indent_block_style = 'do' +endif + +if !exists('g:ruby_indent_hanging_elements') + " Non-zero means hanging indents are enabled, zero means disabled + let g:ruby_indent_hanging_elements = 1 endif setlocal nosmartindent @@ -321,7 +326,11 @@ function! s:ClosingBracketOnEmptyLine(cline_info) abort if searchpair(escape(bracket_pair[0], '\['), '', bracket_pair[1], 'bW', s:skip_expr) > 0 if closing_bracket == ')' && col('.') != col('$') - 1 - let ind = virtcol('.') - 1 + if g:ruby_indent_hanging_elements + let ind = virtcol('.') - 1 + else + let ind = indent(line('.')) + end elseif g:ruby_indent_block_style == 'do' let ind = indent(line('.')) else " g:ruby_indent_block_style == 'expression' @@ -546,7 +555,9 @@ function! s:AfterUnbalancedBracket(pline_info) abort let [opening, closing] = s:ExtraBrackets(info.plnum) if opening.pos != -1 - if opening.type == '(' && searchpair('(', '', ')', 'bW', s:skip_expr) > 0 + if !g:ruby_indent_hanging_elements + return indent(info.plnum) + info.sw + elseif opening.type == '(' && searchpair('(', '', ')', 'bW', s:skip_expr) > 0 if col('.') + 1 == col('$') return indent(info.plnum) + info.sw else diff --git a/sources_non_forked/vim-ruby/spec/indent/blocks_spec.rb b/sources_non_forked/vim-ruby/spec/indent/blocks_spec.rb index eb43b046..c936e614 100644 --- a/sources_non_forked/vim-ruby/spec/indent/blocks_spec.rb +++ b/sources_non_forked/vim-ruby/spec/indent/blocks_spec.rb @@ -1,10 +1,6 @@ require 'spec_helper' describe "Indenting" do - after :each do - vim.command 'let g:ruby_indent_block_style = "expression"' - end - specify "indented blocks with expression style" do vim.command 'let g:ruby_indent_block_style = "expression"' @@ -103,6 +99,7 @@ describe "Indenting" do end specify "blocks with multiline parameters" do + vim.command 'let g:ruby_indent_block_style = "expression"' assert_correct_indenting <<~EOF def foo opts.on('--coordinator host=HOST[,port=PORT]', diff --git a/sources_non_forked/vim-ruby/spec/indent/continuations_spec.rb b/sources_non_forked/vim-ruby/spec/indent/continuations_spec.rb index 727da7d3..1d64a867 100644 --- a/sources_non_forked/vim-ruby/spec/indent/continuations_spec.rb +++ b/sources_non_forked/vim-ruby/spec/indent/continuations_spec.rb @@ -57,6 +57,7 @@ describe "Indenting" do end specify "continuations after round braces" do + vim.command 'let g:ruby_indent_block_style = "expression"' assert_correct_indenting <<~EOF opts.on('--coordinator host=HOST[,port=PORT]', 'Specify the HOST and the PORT of the coordinator') do |str| @@ -67,10 +68,6 @@ describe "Indenting" do end describe "assignments" do - after :each do - vim.command 'let g:ruby_indent_assignment_style = "hanging"' - end - specify "continuations after assignment" do assert_correct_indenting <<~EOF variable = diff --git a/sources_non_forked/vim-ruby/spec/indent/hanging_elements_spec.rb b/sources_non_forked/vim-ruby/spec/indent/hanging_elements_spec.rb new file mode 100644 index 00000000..1d6a15c9 --- /dev/null +++ b/sources_non_forked/vim-ruby/spec/indent/hanging_elements_spec.rb @@ -0,0 +1,78 @@ +require 'spec_helper' + +describe 'Indenting' do + + specify 'method args' do + assert_correct_indenting <<~EOF + render('product/show', + product: product, + on_sale: true, + ) + EOF + + vim.command 'let g:ruby_indent_hanging_elements = 0' + + assert_correct_indenting <<~EOF + render('product/show', + product: product, + on_sale: true, + ) + EOF + end + + specify 'method args with block' do + assert_correct_indenting <<~EOF + opts.on('--coordinator host=HOST[,port=PORT]', + 'Specify the HOST and the PORT of the coordinator') do |str| + h = sub_opts_to_hash(str) + puts h + end + EOF + + vim.command 'let g:ruby_indent_hanging_elements = 0' + + assert_correct_indenting <<~EOF + opts.on('--coordinator host=HOST[,port=PORT]', + 'Specify the HOST and the PORT of the coordinator') do |str| + h = sub_opts_to_hash(str) + puts h + end + EOF + end + + specify 'arrays' do + assert_correct_indenting <<~EOF + x = [1, + 2, + 3, + ] + EOF + + vim.command 'let g:ruby_indent_hanging_elements = 0' + + assert_correct_indenting <<~EOF + x = [1, + 2, + 3, + ] + EOF + end + + specify 'hashes' do + assert_correct_indenting <<~EOF + x = { a: 1, + b: 2, + c: 3, + } + EOF + + vim.command 'let g:ruby_indent_hanging_elements = 0' + + assert_correct_indenting <<~EOF + x = { a: 1, + b: 2, + c: 3, + } + EOF + end +end diff --git a/sources_non_forked/vim-ruby/spec/indent/indent_access_modifier_spec.rb b/sources_non_forked/vim-ruby/spec/indent/indent_access_modifier_spec.rb index c2781e90..8d157544 100644 --- a/sources_non_forked/vim-ruby/spec/indent/indent_access_modifier_spec.rb +++ b/sources_non_forked/vim-ruby/spec/indent/indent_access_modifier_spec.rb @@ -1,10 +1,6 @@ require 'spec_helper' describe "Indenting" do - after :each do - vim.command 'let g:ruby_indent_access_modifier_style = "normal"' - end - specify "default indented access modifiers" do assert_correct_indenting <<~EOF class OuterClass diff --git a/sources_non_forked/vim-ruby/spec/indent/nesting_spec.rb b/sources_non_forked/vim-ruby/spec/indent/nesting_spec.rb index 461aed2c..b402224c 100644 --- a/sources_non_forked/vim-ruby/spec/indent/nesting_spec.rb +++ b/sources_non_forked/vim-ruby/spec/indent/nesting_spec.rb @@ -20,6 +20,7 @@ describe "Indenting" do } EOF + vim.command 'let g:ruby_indent_block_style = "expression"' assert_correct_indenting <<~EOF var. func1(:param => 'value') { @@ -40,6 +41,7 @@ describe "Indenting" do } EOF + vim.command 'let g:ruby_indent_block_style = "expression"' assert_correct_indenting <<~EOF foo, bar = { @@ -53,6 +55,7 @@ describe "Indenting" do end specify "nested blocks with a continuation and function call inbetween" do + vim.command 'let g:ruby_indent_block_style = "expression"' assert_correct_indenting <<~EOF var. func1(:param => 'value') { diff --git a/sources_non_forked/vim-ruby/spec/indent/splat_spec.rb b/sources_non_forked/vim-ruby/spec/indent/splat_spec.rb index 1aa46844..dc89c008 100644 --- a/sources_non_forked/vim-ruby/spec/indent/splat_spec.rb +++ b/sources_non_forked/vim-ruby/spec/indent/splat_spec.rb @@ -20,6 +20,7 @@ describe "Indenting" do end specify "splats with blocks in assignment" do + vim.command 'let g:ruby_indent_block_style = "expression"' assert_correct_indenting <<~EOF x = * array.map do diff --git a/sources_non_forked/vim-ruby/spec/spec_helper.rb b/sources_non_forked/vim-ruby/spec/spec_helper.rb index db518e21..3cb20643 100644 --- a/sources_non_forked/vim-ruby/spec/spec_helper.rb +++ b/sources_non_forked/vim-ruby/spec/spec_helper.rb @@ -1,6 +1,16 @@ require 'vimrunner' require 'vimrunner/rspec' +RSpec.configure do |config| + # reset globals to default values before each test + config.before(:each) do + vim.command 'let g:ruby_indent_access_modifier_style = "normal"' + vim.command 'let g:ruby_indent_block_style = "do"' + vim.command 'let g:ruby_indent_assignment_style = "hanging"' + vim.command 'let g:ruby_indent_hanging_elements = 1' + end +end + Vimrunner::RSpec.configure do |config| config.reuse_server = true diff --git a/sources_non_forked/vim-ruby/spec/syntax/maxmempattern_limit_spec.rb b/sources_non_forked/vim-ruby/spec/syntax/maxmempattern_limit_spec.rb new file mode 100644 index 00000000..365ed63f --- /dev/null +++ b/sources_non_forked/vim-ruby/spec/syntax/maxmempattern_limit_spec.rb @@ -0,0 +1,12 @@ +require 'spec_helper' + +describe "Maxmempattern limit" do + specify "maxmempattern=1000 is enough even for long strings" do + str = <<~'EOF' + hash = { + "A-NOT-Managed-Strings" => "ABCDEfghe910dmckamks019292djdjOOOjjjd/cr3wdCA+1n/xHfHMgG+cC0EoUNngcBjgWvBMEF1CurBwTtDswJjQYa5wYRAQEBAQECCwGwAQEvI50CnwMNAwRrAQYBr9PPAoK7sQMBAQMCBAkICAQIAwEBAwYBAQQFFQEBAhQDAwMDCwEBAQUBAQHGAQEWBAEBDecBfS8CHQEKkAEMMxcMCQoUDwYHIjd3DQ4MFk0JWGYALSKLAQOLAYEBFBAjCBGDAQICAgMANjsZAg9fCxkCgLZKAwSEAQIBiwEZGAsrBCgFMmUEJShyFSfRBQEOSQY62AG0AVlCrQ", + } + EOF + assert_correct_highlighting str, %w[ABCDE], 'rubyString' + end +end diff --git a/sources_non_forked/vim-ruby/syntax/ruby.vim b/sources_non_forked/vim-ruby/syntax/ruby.vim index 563885ed..d797e46b 100644 --- a/sources_non_forked/vim-ruby/syntax/ruby.vim +++ b/sources_non_forked/vim-ruby/syntax/ruby.vim @@ -65,7 +65,7 @@ endfunction com! -nargs=* SynFold call s:run_syntax_fold() " Not-Top Cluster {{{1 -syn cluster rubyNotTop contains=@rubyCommentNotTop,@rubyStringNotTop,@rubyRegexpSpecial,@rubyDeclaration,@rubyExceptionHandler,@rubyClassOperator,rubyConditional,rubyModuleName,rubyClassName,rubySymbolDelimiter,rubyParentheses +syn cluster rubyNotTop contains=@rubyCommentNotTop,@rubyStringNotTop,@rubyRegexpSpecial,@rubyDeclaration,@rubyExceptionHandler,@rubyClassOperator,rubyConditional,rubyModuleName,rubyClassName,rubySymbolDelimiter,rubyParentheses,@Spell " Whitespace Errors {{{1 if exists("ruby_space_errors") @@ -331,7 +331,7 @@ SynFold '<<' syn region rubyString start=+\%(\%(class\|::\|\.\@1= 0 diff --git a/sources_non_forked/vim-snippets/UltiSnips/c.snippets b/sources_non_forked/vim-snippets/UltiSnips/c.snippets index e1eb81c2..c191d760 100644 --- a/sources_non_forked/vim-snippets/UltiSnips/c.snippets +++ b/sources_non_forked/vim-snippets/UltiSnips/c.snippets @@ -1,7 +1,33 @@ ########################################################################### # TextMate Snippets # ########################################################################### +# -------------- +# Functions +# -------------- +global !p +def printf_expand_args(snip): + """ + This will look how many placeholders printf has and adds the separated commas + at the end. + """ + + # now add so many "," as much as the amount of placeholders + amount_placeholders = snip.tabstops[1].current_text.count("%") + output = "" + + # Add the amount of tabstops + for placeholder_index in range(3, amount_placeholders + 3): + output += f", ${placeholder_index}" + + # convert them into tabstops + snip.expand_anon(output) + +endglobal + +# ============== +# Snippets +# ============== priority -50 snippet def "#define ..." @@ -49,6 +75,16 @@ for (${4:int} ${2:i} = 0; $2 < ${1:count}; ${3:++$2}) { } endsnippet +snippet fora "for-loop" b +for (${1:var}; ${2:condition}; `!p +if len(t[1]) > 0: + snip.rv = t[1].split('=')[0].split()[-1] +`++) { + + $0 +} /* for ($1; $2; `!p if len(t[1]) > 0: snip.rv = t[1].split('=')[0].split()[-1]`++) */ +endsnippet + snippet once "Include header once only guard" #ifndef ${1:`!p if not snip.c: @@ -75,8 +111,9 @@ else if (${1:/* condition */}) { } endsnippet -snippet printf "printf .. (printf)" -printf("${1:%s}\n"${1/([^%]|%%)*(%.)?.*/(?2:, :\);)/}$2${1/([^%]|%%)*(%.)?.*/(?2:\);)/} +post_jump "printf_expand_args(snip)" +snippet "printf" "printf with auto-expand args" wr +printf("$1\n"$2); endsnippet snippet st "struct" diff --git a/sources_non_forked/vim-snippets/UltiSnips/cpp.snippets b/sources_non_forked/vim-snippets/UltiSnips/cpp.snippets index 1abd5096..80120dae 100644 --- a/sources_non_forked/vim-snippets/UltiSnips/cpp.snippets +++ b/sources_non_forked/vim-snippets/UltiSnips/cpp.snippets @@ -30,6 +30,12 @@ endglobal ########################################################################### # TextMate Snippets # ########################################################################### +snippet forc "general for loop (for)" +for (${6:auto} ${1:i} = ${2:v.begin()}; `!p import re; snip.rv = re.split("[^\w]",t[1])[-1]` ${4:!=} ${3:`!p m = re.search(r'^(?:(.*)(\.|->)begin\(\)|((?:std|boost)::)?begin\((.*)\))$', t[2]); snip.rv = (((m.group(3) if m.group(3) else "") + "end(" + m.group(4) + ")") if m.group(4) else (m.group(1) + m.group(2) + "end()")) if m else ""`}; ${5:++`!p snip.rv = t[1].split(" ")[-1]`}) { + ${VISUAL}$0 +} +endsnippet + snippet beginend "$1.begin(), $1.end() (beginend)" ${1:v}${1/^.*?(-)?(>)?$/(?2::(?1:>:.))/}begin(), $1${1/^.*?(-)?(>)?$/(?2::(?1:>:.))/}end() endsnippet @@ -106,5 +112,68 @@ ${1:ReturnType} ${2:FunctionName}(${3:param}) { ${0:FunctionBody} } +endsnippet + +snippet boost_test "Boost test module" b +#define BOOST_TEST_MODULE ${1:TestModuleName} +#include + +BOOST_AUTO_TEST_CASE(${2:TestCaseName}) +{ + ${0:TestDefinition} +} + +endsnippet + +snippet boost_suite "Boost test suite module" b +#define BOOST_TEST_MODULE ${1:TestModuleName} +#include + +BOOST_AUTO_TEST_SUITE(${2:SuiteName}) + +BOOST_AUTO_TEST_CASE(${3:TestCaseName}) +{ + ${0:TestDefinition} +} + +BOOST_AUTO_TEST_SUITE_END() + +endsnippet +snippet boost_test_fixture "Boost test module with fixture" b +#define BOOST_TEST_MODULE ${1:TestModuleName} +#include + +struct ${2:FixtureName} { + $2() {} + virtual ~$2() {} + /* define members here */ +}; + +BOOST_FIXTURE_TEST_CASE(${3:SuiteName}, $2) +{ + ${0:TestDefinition} +} + +endsnippet + +snippet boost_suite_fixture "Boost test suite with fixture" b +#define BOOST_TEST_MODULE ${1:TestModuleName} +#include + +struct ${2:FixtureName} { + $2() {} + virtual ~$2() {} + /* define members here */ +}; + +BOOST_FIXTURE_TEST_SUITE(${3:SuiteName}, $2) + +BOOST_AUTO_TEST_CASE(${4:TestCaseName}) +{ + ${0:TestDefinition} +} + +BOOST_AUTO_TEST_SUITE_END() + endsnippet # vim:ft=snippets: diff --git a/sources_non_forked/vim-snippets/UltiSnips/cs.snippets b/sources_non_forked/vim-snippets/UltiSnips/cs.snippets index 303fd209..4c58bcbe 100644 --- a/sources_non_forked/vim-snippets/UltiSnips/cs.snippets +++ b/sources_non_forked/vim-snippets/UltiSnips/cs.snippets @@ -308,16 +308,29 @@ endsnippet # methods # ############# -snippet equals "Equals method" b -public override bool Equals(object obj) +snippet equals "Equality for a type" b +public override bool Equals(object obj) => Equals(obj as ${1:TYPE}); + +public bool Equals($1 other) // IEquatable<$1> { - if (obj == null || GetType() != obj.GetType()) - { + if (object.ReferenceEquals(other, null)) + return false; + if (object.ReferenceEquals(this, other)) + return true; + if (this.GetType() != other.GetType()) return false; - } $0 - return base.Equals(obj); + return base.Equals(other); } + +public override int GetHashCode() => base.GetHashCode(); + +public static bool operator ==($1 x, $1 y) => + (object.ReferenceEquals(x, null) && object.ReferenceEquals(y, null)) + || (!object.ReferenceEquals(x, null) && x.Equals(y)); + +public static bool operator !=($1 x, $1 y) => !(x == y); + endsnippet snippet mth "Method" b diff --git a/sources_non_forked/vim-snippets/UltiSnips/django.snippets b/sources_non_forked/vim-snippets/UltiSnips/django.snippets index d6e2d434..a03cf1e3 100644 --- a/sources_non_forked/vim-snippets/UltiSnips/django.snippets +++ b/sources_non_forked/vim-snippets/UltiSnips/django.snippets @@ -148,7 +148,6 @@ class ${1:MODELNAME}(models.Model): def save(self): return super($1, self).save() - @models.permalink def get_absolute_url(self): return ('') diff --git a/sources_non_forked/vim-snippets/UltiSnips/ejs.snippets b/sources_non_forked/vim-snippets/UltiSnips/ejs.snippets new file mode 100644 index 00000000..1e3c0044 --- /dev/null +++ b/sources_non_forked/vim-snippets/UltiSnips/ejs.snippets @@ -0,0 +1,10 @@ +snippet for "ejs for loop" b +<% for (let ${1:i = 0}; ${2:i + ${0:body} +<% } %> +endsnippet +snippet forE "ejs for Each loop" b +<% ${1:array}.forEach((${2:single var}) => { %> + ${0:body} +<% }) %> +endsnippet diff --git a/sources_non_forked/vim-snippets/UltiSnips/haskell.snippets b/sources_non_forked/vim-snippets/UltiSnips/haskell.snippets index 11d82c81..ed832715 100644 --- a/sources_non_forked/vim-snippets/UltiSnips/haskell.snippets +++ b/sources_non_forked/vim-snippets/UltiSnips/haskell.snippets @@ -1,5 +1,13 @@ priority -50 -snippet impq "Qualified import" -import qualified ${1:Data.Text} as ${0:`!p snip.rv = t[1].split(".")[-1]`} +snippet imp "Simple import" +import ${1:${2:Data}.${0:Text}} +endsnippet + +snippet imp2 "Selective import" b +import ${1:${2:Data}.${3:Text}} (${4})${0} +endsnippet + +snippet impq "Qualified import" +import qualified ${1:${2:Data}.${3:Text}} as ${0:`!p snip.rv = t[1].split(".")[-1]`} endsnippet diff --git a/sources_non_forked/vim-snippets/UltiSnips/html.snippets b/sources_non_forked/vim-snippets/UltiSnips/html.snippets index a81b1d88..75eff902 100644 --- a/sources_non_forked/vim-snippets/UltiSnips/html.snippets +++ b/sources_non_forked/vim-snippets/UltiSnips/html.snippets @@ -276,7 +276,7 @@ snippet htmll "HTML basic structure with the lang attribute" b - + ${2:`!p snip.rv = snip.basename.replace('-', ' ').capitalize()`} diff --git a/sources_non_forked/vim-snippets/UltiSnips/javascript_react.snippets b/sources_non_forked/vim-snippets/UltiSnips/javascript_react.snippets new file mode 100644 index 00000000..666c80e3 --- /dev/null +++ b/sources_non_forked/vim-snippets/UltiSnips/javascript_react.snippets @@ -0,0 +1,42 @@ +# Functional components +snippet rfc "react functional component" b +import React, {useState} from "react" + +function ${1:`!p snip.rv = snip.basename`}(${2}){ + return( +
+ ${3:

Body

} +
+ ) +} + +export default $4`!p snip.rv = snip.basename` +endsnippet +# React Hooks +snippet useS "useState Hook" b +const [${1}, set`!p snip.rv=t[1].title()`] = useState(${3:"${4}"}) +endsnippet +snippet useE "useEffect Hook" b +useEffect(() => { + ${1:${0}} + }${2}) +endsnippet +snippet useC "useContext Hook" b +const ${1:context} = useContext(${2}) +endsnippet +snippet useRe "useReducer Hook" b +const [${3:state}, ${4:dispatch}] = useReducer(${5:reducer}, ${2:initial_value}) +endsnippet +snippet useCB "useCallback(fn, inputs)" b +const ${1:callback} = useCallback((${2})) => ${3:{ + ${4} +}}, [${5}]) +endsnippet +snippet useM "useMemo(fn, inputs)" b +const ${1:memorized} = useMemo(() => ${2:{ + ${3} +}}, [${4}]) +endsnippet +snippet useR "useRef(defaultValue)" b +const ${1:ref} = useRef(${2:null}) +endsnippet diff --git a/sources_non_forked/vim-snippets/UltiSnips/markdown.snippets b/sources_non_forked/vim-snippets/UltiSnips/markdown.snippets index bc8664bb..1017c801 100644 --- a/sources_non_forked/vim-snippets/UltiSnips/markdown.snippets +++ b/sources_non_forked/vim-snippets/UltiSnips/markdown.snippets @@ -96,12 +96,15 @@ snippet *** "bold italics" ***${1:${VISUAL}}***$0 endsnippet +snippet /* "Comment" +$0 +endsnippet ################ # Common stuff # ################ snippet link "Link to something" -[${1:${VISUAL:Text}}](${3:http://${2:www.url.com}})$0 +[${1:${VISUAL:Text}}](${3:https://${2:www.url.com}})$0 endsnippet snippet img "Image" @@ -122,7 +125,7 @@ endsnippet snippet refl "Reference Link" [${1:${VISUAL:Text}}][${2:id}]$0 -[$2]:${4:http://${3:www.url.com}} "${5:$4}" +[$2]:${4:https://${3:www.url.com}} "${5:$4}" endsnippet snippet fnt "Footnote" @@ -131,6 +134,12 @@ snippet fnt "Footnote" [^$1]:${2:Text} endsnippet +snippet detail "Disclosure" + + ${1:${2}}$0 + +endsnippet + post_jump "create_table(snip)" snippet "tb([1-9][1-9])" "Fancy table" br `!p snip.rv = match.group(1)` diff --git a/sources_non_forked/vim-snippets/UltiSnips/rust.snippets b/sources_non_forked/vim-snippets/UltiSnips/rust.snippets index fbf459d1..6fc07e93 100644 --- a/sources_non_forked/vim-snippets/UltiSnips/rust.snippets +++ b/sources_non_forked/vim-snippets/UltiSnips/rust.snippets @@ -4,7 +4,7 @@ priority -50 -snippet fn "pub fn name(?) -> ? {}" +snippet fn "fn name(?) -> ? {}" fn ${1:function_name}($2)${3/..*/ -> /}$3 { ${VISUAL}$0 } @@ -16,6 +16,18 @@ pub fn ${1:function_name}($2)${3/..*/ -> /}$3 { } endsnippet +snippet afn "async fn name(?) -> ? {}" +async fn ${1:function_name}($2)${3/..*/ -> /}$3 { + ${VISUAL}$0 +} +endsnippet + +snippet pafn "pub async fn name(?) -> ? {}" +pub async fn ${1:function_name}($2)${3/..*/ -> /}$3 { + ${VISUAL}$0 +} +endsnippet + snippet pri "print!(..)" b print!("$1"${2/..*/, /}$2); endsnippet @@ -32,4 +44,10 @@ snippet .it ".iter()" i .iter()$0 endsnippet +snippet impl "Struct/Trait implementation" b +impl$4 ${1:Type/Trait}${2: for ${3:Type}}${4:<${5:T}>} { + ${0} +} +endsnippet + # vim:ft=snippets: diff --git a/sources_non_forked/vim-snippets/UltiSnips/svelte.snippets b/sources_non_forked/vim-snippets/UltiSnips/svelte.snippets new file mode 100644 index 00000000..4e09d0cc --- /dev/null +++ b/sources_non_forked/vim-snippets/UltiSnips/svelte.snippets @@ -0,0 +1 @@ +extends html, javascript, css diff --git a/sources_non_forked/vim-snippets/UltiSnips/tex.snippets b/sources_non_forked/vim-snippets/UltiSnips/tex.snippets index b5be4b74..5c5721f3 100644 --- a/sources_non_forked/vim-snippets/UltiSnips/tex.snippets +++ b/sources_non_forked/vim-snippets/UltiSnips/tex.snippets @@ -9,15 +9,15 @@ def create_table(snip): cols = snip.buffer[snip.line].split('x')[1] int_val = lambda string: int(''.join(s for s in string if s.isdigit())) - + rows = int_val(rows) cols = int_val(cols) offset = cols + 1 old_spacing = snip.buffer[snip.line][:snip.buffer[snip.line].rfind('\t') + 1] - + snip.buffer[snip.line] = '' - + final_str = old_spacing + "\\begin{tabular}{|" + "|".join(['$' + str(i + 1) for i in range(cols)]) + "|}\n" for i in range(rows): @@ -35,7 +35,7 @@ def add_row(snip): old_spacing = snip.buffer[snip.line][:snip.buffer[snip.line].rfind('\t') + 1] snip.buffer[snip.line] = '' - + final_str = old_spacing final_str += " & ".join(['$' + str(j + 1) for j in range(row_len)]) final_str += " \\\\\\" @@ -44,7 +44,7 @@ def add_row(snip): endglobal -snippet "b(egin)?" "begin{} / end{}" br +snippet "\\?b(egin)?" "begin{} / end{}" br \begin{${1:something}} ${0:${VISUAL}} \end{$1} @@ -63,7 +63,7 @@ $0${2/(?<=.)(c|l|r)|./(?1: & )/g} endsnippet pre_expand "create_table(snip)" -snippet "gentbl(\d+)x(\d+)" "Generate table of *width* by *height*" r +snippet "gentbl(\d+)x(\d+)" "Generate table of *width* by *height*" r endsnippet pre_expand "add_row(snip)" @@ -193,8 +193,6 @@ snippet acl "Acroynm expanded" b $0 endsnippet - - snippet ni "Non-indented paragraph" b \noindent $0 @@ -241,4 +239,20 @@ snippet glnl "New long glossary item" b ${0:description} } endsnippet + +# Bold text +snippet bf "Bold" +\textbf{$1} $0 +endsnippet + +# Italic text +snippet ita "Italics" +\textit{$1} $0 +endsnippet + +# Underlined text +snippet und "Underline" +\underline{$1} $0 +endsnippet + # vim:ft=snippets: diff --git a/sources_non_forked/vim-snippets/pythonx/vimsnippets.py b/sources_non_forked/vim-snippets/pythonx/vimsnippets.py index 3c638a17..eceb83c5 100644 --- a/sources_non_forked/vim-snippets/pythonx/vimsnippets.py +++ b/sources_non_forked/vim-snippets/pythonx/vimsnippets.py @@ -1,3 +1,5 @@ +# vim:set et fileencoding=utf8 sts=0 sw=4 ts=4: + """Helper methods used in UltiSnips snippets.""" import string, vim, re @@ -82,12 +84,13 @@ def get_comment_format(): def make_box(twidth, bwidth=None): b, m, e, i = (s.strip() for s in get_comment_format()) + m0 = m[0] if m else '' bwidth_inner = bwidth - 3 - max(len(b), len(i + e)) if bwidth else twidth + 2 - sline = b + m + bwidth_inner * m[0] + 2 * m[0] + sline = b + m + bwidth_inner * m0 + 2 * m0 nspaces = (bwidth_inner - twidth) // 2 mlines = i + m + " " + " " * nspaces mlinee = " " + " "*(bwidth_inner - twidth - nspaces) + m - eline = i + m + bwidth_inner * m[0] + 2 * m[0] + e + eline = i + m + bwidth_inner * m0 + 2 * m0 + e return sline, mlines, mlinee, eline def foldmarker(): @@ -114,5 +117,3 @@ def has_cjk(s): cjk_re = re.compile(u'[⺀-⺙⺛-⻳⼀-⿕々〇〡-〩〸-〺〻㐀-䶵一-鿃豈-鶴侮-頻並-龎]', re.UNICODE) return cjk_re.search(s) is not None - -# vim:set et sts=0 sw=4 ts=4: diff --git a/sources_non_forked/vim-snippets/snippets/awk.snippets b/sources_non_forked/vim-snippets/snippets/awk.snippets index 5c94734a..64f61c0c 100644 --- a/sources_non_forked/vim-snippets/snippets/awk.snippets +++ b/sources_non_forked/vim-snippets/snippets/awk.snippets @@ -1,88 +1,70 @@ # cannot use /usr/bin/env because it does not support parameters (as -f) snippet #! #!/usr/bin/awk -f #!/usr/bin/awk -f - # @include is a gawk extension snippet inc @include @include "${1}"${0} - # @load is a gawk extension snippet loa @load @load "${1}"${0} - snippet beg BEGIN { ... } BEGIN { ${0} } - # BEGINFILE is a gawk extension snippet begf BEGINFILE { ... } BEGINFILE { ${0} } - snippet end END { ... } END { ${0} } - # ENDFILE is a gawk extension snippet endf ENDFILE { ... } ENDFILE { ${0} } - snippet pri print print ${1:"${2}"}${0} - snippet printf printf printf("${1:%s}\n", ${2})${0} - snippet ign IGNORECASE IGNORECASE = ${1:1} - snippet if if {...} if (${1}) { ${0:${VISUAL}} } - snippet ife if ... else ... if (${1}) { ${2:${VISUAL}} } else { ${0} } - snippet eif else if ... else if (${1}) { ${0} } - snippet el else {...} else { ${0} } - snippet wh while while (${1}) { ${2} } - snippet do do ... while do { ${0} } while (${1}) - snippet for for for (${2:i} = 0; i < ${1:n}; ${3:++i}) { ${0} } - snippet fore for each for (${1:i} in ${2:array}) { ${0} } - # the switch is a gawk extension snippet sw switch switch (${1}) { @@ -93,10 +75,8 @@ snippet sw switch ${0} break } - # the switch is a gawk extension snippet case case case ${1}: ${0} break - diff --git a/sources_non_forked/vim-snippets/snippets/c.snippets b/sources_non_forked/vim-snippets/snippets/c.snippets index 614a4882..5c084154 100644 --- a/sources_non_forked/vim-snippets/snippets/c.snippets +++ b/sources_non_forked/vim-snippets/snippets/c.snippets @@ -1,7 +1,7 @@ ## Main # main snippet main - int main(int argc, const char *argv[]) + int main(int argc, char *argv[]) { ${0} return 0; diff --git a/sources_non_forked/vim-snippets/snippets/clojure.snippets b/sources_non_forked/vim-snippets/snippets/clojure.snippets index 152f896e..048ce9fe 100644 --- a/sources_non_forked/vim-snippets/snippets/clojure.snippets +++ b/sources_non_forked/vim-snippets/snippets/clojure.snippets @@ -8,21 +8,21 @@ snippet def (def ${0}) snippet defm (defmethod ${1:multifn} "${2:doc-string}" ${3:dispatch-val} [${4:args}] - ${0}) + ${0:code}) snippet defmm (defmulti ${1:name} "${2:doc-string}" ${0:dispatch-fn}) snippet defma (defmacro ${1:name} "${2:doc-string}" ${0:dispatch-fn}) snippet defn (defn ${1:name} "${2:doc-string}" [${3:arg-list}] - ${0}) + ${0:code}) snippet defp (defprotocol ${1:name} - ${0}) + ${0:code}) snippet defr (defrecord ${1:name} [${2:fields}] ${3:protocol} - ${0}) + ${0:code}) snippet deft (deftest ${1:name} (is (= ${0:assertion}))) @@ -31,12 +31,12 @@ snippet is snippet defty (deftype ${1:Name} [${2:fields}] ${3:Protocol} - ${0}) + ${0:code}) snippet doseq (doseq [${1:elem} ${2:coll}] - ${0}) + ${0:code}) snippet fn - (fn [${1:arg-list}] ${0}) + (fn [${1:arg-list}] ${0:code}) snippet if (if ${1:test-expr} ${2:then-expr} @@ -50,24 +50,24 @@ snippet imp & {:keys [${1:keys}] :or {${0:defaults}}} snippet let (let [${1:name} ${2:expr}] - ${0}) + ${0:code}) snippet letfn (letfn [(${1:name}) [${2:args}] - ${0})]) + ${0:code})]) snippet map (map ${1:func} ${0:coll}) snippet mapl (map #(${1:lambda}) ${0:coll}) snippet met (${1:name} [${2:this} ${3:args}] - ${0}) + ${0:code}) snippet ns (ns ${0:name}) snippet dotimes (dotimes [_ 10] (time (dotimes [_ ${1:times}] - ${0}))) + ${0:code}))) snippet pmethod (${1:name} [${2:this} ${0:args}]) snippet refer diff --git a/sources_non_forked/vim-snippets/snippets/dart-flutter.snippets b/sources_non_forked/vim-snippets/snippets/dart-flutter.snippets new file mode 100644 index 00000000..f3ded26a --- /dev/null +++ b/sources_non_forked/vim-snippets/snippets/dart-flutter.snippets @@ -0,0 +1,59 @@ +# Snippets for dart in flutter project, to use add the following to your .vimrc +# `autocmd BufRead,BufNewFile,BufEnter *.dart UltiSnipsAddFiletypes dart-flutter` +# Flutter stateless widget +snippet stless + class $1 extends StatelessWidget { + @override + Widget build(BuildContext context) { + return Container( + $2 + ); + } + } + +# Flutter stateful widget +snippet stful + class $1 extends StatefulWidget { + @override + _$1State createState() => _$1State(); + } + + class _$1State extends State<$1> { + @override + Widget build(BuildContext context) { + return Container( + $2 + ); + } + } + +# Flutter widget with AnimationController +snippet stanim + class $1 extends StatefulWidget { + @override + _$1State createState() => _$1State(); + } + + class _$1State extends State<$1> + with SingleTickerProviderStateMixin { + AnimationController _controller; + + @override + void initState() { + super.initState(); + _controller = AnimationController(vsync: this); + } + + @override + void dispose() { + super.dispose(); + _controller.dispose(); + } + + @override + Widget build(BuildContext context) { + return Container( + $2 + ); + } + } diff --git a/sources_non_forked/vim-snippets/snippets/elixir.snippets b/sources_non_forked/vim-snippets/snippets/elixir.snippets index 468575d0..ee093eb9 100644 --- a/sources_non_forked/vim-snippets/snippets/elixir.snippets +++ b/sources_non_forked/vim-snippets/snippets/elixir.snippets @@ -81,6 +81,8 @@ snippet cb @callback ${1:name}(${2:args}) :: ${3:returns} snippet df def ${1:name}, do: ${2} +snippet dfw + def ${1:name}(${2:args}) when ${3:guard}, do: snippet def def ${1:name} do ${0} @@ -92,12 +94,21 @@ snippet defd def ${2:name} do ${0} end +snippet defs + @spec ${1:name}(${2:arg types}) :: ${3:no_return} + def $1(${4:args}) do + ${0} + end snippet defsd @doc """ ${1:doc string} """ - @spec ${2:name} :: ${3:no_return} - def ${2} do + @spec ${2:name}(${3:arg types}) :: ${4:no_return} + def $2(${5:args}) do + ${0} + end +snippet defw + def ${1:name}(${2:args}) when ${3:guard} do ${0} end snippet defim @@ -112,12 +123,24 @@ snippet defmo defmodule ${1:`substitute(vim_snippets#Filename(), '\(_\|^\)\(.\)', '\u\2', 'g')`} do ${0} end +snippet %M + %__MODULE__{ + ${1:key_name}: ${2:value} + } +snippet enfk + @enforce_keys [:${1:key_name}] snippet dfp defp ${1:name}, do: ${2} +snippet dfpw + defp ${1:name}(${2:args}) when ${3:guard}, do: ${4} snippet defp defp ${1:name} do ${0} end +snippet defpw + defp ${1:name}(${2:args}) when ${3:guard} do + ${0} + end snippet defpr defprotocol ${1:name}, [${0:function}] snippet defr @@ -173,12 +196,28 @@ snippet des describe "${1:test group subject}" do ${0} end +snippet destag + @describetag :${1:describe tag} +snippet mtag + @moduletag :${1:module tag} +snippet dt + doctest ${1:filename} +snippet tp + @tag :pending snippet exunit defmodule ${1:`substitute(vim_snippets#Filename(), '\(_\|^\)\(.\)', '\u\2', 'g')`} do use ExUnit.Case, async: true ${0} end +snippet setup + setup do + ${1} + end +snippet setupa + setup_all do + ${1} + end snippet try try .. rescue .. end try do ${1:${VISUAL}} diff --git a/sources_non_forked/vim-snippets/snippets/eruby.snippets b/sources_non_forked/vim-snippets/snippets/eruby.snippets index b8879c5c..3d639160 100644 --- a/sources_non_forked/vim-snippets/snippets/eruby.snippets +++ b/sources_non_forked/vim-snippets/snippets/eruby.snippets @@ -46,8 +46,9 @@ snippet conf <% content_for :${1:head} do %> ${0} <% end %> -snippet cs - <%= collection_select <+object+>, <+method+>, <+collection+>, <+value_method+>, <+text_method+><+, <+[options]+>, <+[html_options]+>+> %> + +snippet cs + <%= collection_select(:${1:object}, :${2:method}, ${3:collection}, :${4:value_method}, :${5:text_method}, options = {${0:prompt: true}}) %> snippet ct <%= content_tag '${1:DIV}', ${2:content}${0:,options} %> snippet ff @@ -80,6 +81,8 @@ snippet ffta <%= ${1:f}.text_area :${0:attribute} %> snippet fftf <%= ${1:f}.text_field :${0:attribute} %> +snippet fcs + <%= ${1:f}.collection_select(:${2:method}, ${3:collection}, :${4:value_method}, :${5:text_method}, options = {${0:prompt: true}}) %> snippet fields <%= fields_for :${1:model}, @$1 do |${2:f}| %> ${0} diff --git a/sources_non_forked/vim-snippets/snippets/gitcommit.snippets b/sources_non_forked/vim-snippets/snippets/gitcommit.snippets new file mode 100644 index 00000000..93b2c5d0 --- /dev/null +++ b/sources_non_forked/vim-snippets/snippets/gitcommit.snippets @@ -0,0 +1,2 @@ +snippet co + Co-authored-by: ${1} <${2}> diff --git a/sources_non_forked/vim-snippets/snippets/go.snippets b/sources_non_forked/vim-snippets/snippets/go.snippets index b8d3e6f8..202b7e80 100644 --- a/sources_non_forked/vim-snippets/snippets/go.snippets +++ b/sources_non_forked/vim-snippets/snippets/go.snippets @@ -129,7 +129,7 @@ snippet fum "method" } ${0} -snippet fumh "http handler function on reciever" +snippet fumh "http handler function on receiver" func (${1:receiver} ${2:type}) ${3:funcName}(${4:w} http.ResponseWriter, ${5:r} *http.Request) { ${0:${VISUAL}} } diff --git a/sources_non_forked/vim-snippets/snippets/haskell.snippets b/sources_non_forked/vim-snippets/snippets/haskell.snippets index 3965f1da..585d3522 100644 --- a/sources_non_forked/vim-snippets/snippets/haskell.snippets +++ b/sources_non_forked/vim-snippets/snippets/haskell.snippets @@ -21,9 +21,9 @@ snippet info snippet imp import ${0:Data.Text} snippet import - import ${0:Data.Text} + import ${0:Data.Text} snippet import2 - import ${1:Data.Text} (${0:head}) + import ${1:Data.Text} (${0:head}) snippet impq import qualified ${1:Data.Text} as ${0:T} snippet importq diff --git a/sources_non_forked/vim-snippets/snippets/html.snippets b/sources_non_forked/vim-snippets/snippets/html.snippets index 0410d223..640a26fa 100644 --- a/sources_non_forked/vim-snippets/snippets/html.snippets +++ b/sources_non_forked/vim-snippets/snippets/html.snippets @@ -175,7 +175,7 @@ snippet aside# ${0} snippet audio - snippet b ${0} snippet base @@ -709,7 +709,7 @@ snippet samp ${0} snippet script - snippet scripts diff --git a/sources_non_forked/vim-snippets/snippets/java.snippets b/sources_non_forked/vim-snippets/snippets/java.snippets index 66821c16..739f20b7 100644 --- a/sources_non_forked/vim-snippets/snippets/java.snippets +++ b/sources_non_forked/vim-snippets/snippets/java.snippets @@ -175,9 +175,9 @@ snippet tryf ## ## Find Methods snippet findall - List<${1:listName}> ${2:items} = ${1}.findAll(); + List<${1:listName}> ${2:items} = $1.findAll(); snippet findbyid - ${1:var} ${2:item} = ${1}.findById(${3}); + ${1:var} ${2:item} = $1.findById(${3}); ## ## Javadocs snippet /** diff --git a/sources_non_forked/vim-snippets/snippets/javascript-es6-react.snippets b/sources_non_forked/vim-snippets/snippets/javascript-es6-react.snippets deleted file mode 100644 index c9138752..00000000 --- a/sources_non_forked/vim-snippets/snippets/javascript-es6-react.snippets +++ /dev/null @@ -1,82 +0,0 @@ -# Import only React -snippet ri1 - import React from 'react' - -# Import both React and Component -snippet ri2 - import React, { Component } from 'react' - import PropTypes from 'prop-types' - -# React class -snippet rcla - class ${1:MyComponent} extends Component { - render() { - return ( - ${0:
} - ) - } - } - -# React constructor -snippet rcon - constructor(props) { - super(props) - - this.state = { - ${1}: ${0}, - } - } - -# Proptypes for React Class -snippet rcpt - static propTypes = { - ${1}: PropTypes.${0}, - } - -# Default props for React Class -snippet rcdp - static defaultProps = { - ${1}: ${0}, - } - -# Presentational component -snippet rcom - props => { - return ( - ${0:
} - ) - } - -# Proptypes for Presentational component -snippet rpt - ${1}.propTypes = { - ${2}: PropTypes.${0}, - } - -# Default props for Presentational component -snippet rdp - ${1}.defaultProps = { - ${2}: ${0}, - } - -# Lifecycle Methods -snippet rcdm - componentDidMount() { - ${0:${VISUAL}} - } - -# State -snippet rsst - this.setState({ - ${1}: ${0}, - }) - -snippet rtst - this.state.${0} - -# Props -snippet rp - props.${0} - -snippet rtp - this.props.${0} diff --git a/sources_non_forked/vim-snippets/snippets/javascript/javascript-jasmine.snippets b/sources_non_forked/vim-snippets/snippets/javascript-jasmine.snippets similarity index 100% rename from sources_non_forked/vim-snippets/snippets/javascript/javascript-jasmine.snippets rename to sources_non_forked/vim-snippets/snippets/javascript-jasmine.snippets diff --git a/sources_non_forked/vim-snippets/snippets/javascript/javascript-react.snippets b/sources_non_forked/vim-snippets/snippets/javascript/javascript-react.snippets index 0e8d3602..65cb4e1d 100644 --- a/sources_non_forked/vim-snippets/snippets/javascript/javascript-react.snippets +++ b/sources_non_forked/vim-snippets/snippets/javascript/javascript-react.snippets @@ -1,98 +1,190 @@ -snippet ir +# Import +snippet ir import React import React from 'react'; -snippet irc + +snippet irc import React and Component import React, { Component } from 'react'; -snippet ird + +snippet irh import React hooks + import { use$1 } from 'react'; + +snippet ird import ReactDOM import ReactDOM from 'react-dom'; -snippet cdm + +snippet irp import PropTypes + import PropTypes from 'prop-types'; + +# Lifecycle Methods +snippet cdm componentDidMount componentDidMount() { ${1} - } -snippet cdup + }; + +snippet cdup componentDidUpdate componentDidUpdate(prevProps, prevState) { ${1} - } -snippet cwm + }; + +snippet cwm componentWillMount componentWillMount() { ${1} - } -snippet cwr + }; + +snippet cwr componentWillReceiveProps componentWillReceiveProps(nextProps) { ${1} - } -snippet cwun + }; + +snippet cwun componentWillUnmount componentWillUnmount() { ${1} - } -snippet cwu + }; + +snippet cwu componentWillUpdate componentWillUpdate(nextProps, nextState) { ${1} + }; + +snippet scu shouldComponentUpdate + shouldComponentUpdate(nextProps, nextState) { + ${1} } -snippet fup - forceUpdate(${1:callback}); -snippet dp + +# Props +snippet spt static propTypes + static propTypes = { + ${1}: PropTypes.${2} + }; + +snippet pt propTypes + ${1}.propTypes = { + ${2}: PropTypes.${2} + }; + +snippet sdp static defaultProps static defaultProps = { - ${1}: ${2}, - } + ${1}: ${2} + }; + +snippet dp defaultProps + ${1}.defaultProps = { + ${2}: ${3} + }; + +snippet pp props + props.${1}; + +snippet tp this props + this.props.${1}; + +# State snippet st state = { ${1}: ${2}, - } -snippet pt - static propTypes = { - ${1}: React.PropTypes.${2:type}, - } -snippet rfc - const ${1:ComponentName} = (${2:props}) => { - return ( -
- $1 -
- ); - } -snippet rcc - class ${1:ClassName} extends React.Component { - state = { + }; - } - render() { - return ( -
- $1 -
- ); - } - } -snippet rdr - ReactDOM.render(${1}, ${2}) -snippet ercc - export default class ${1:ClassName} extends React.Component { - render() { - return ( - ${0:
} - ); - } - } -snippet ctor - constructor() { - super(); - ${1} - } -snippet ren - render() { - return ( - ${1:
} - ); - } snippet sst this.setState({ ${1}: ${2} }); -snippet scu - shouldComponentUpdate(nextProps, nextState) { - ${1} + +snippet tst + this.state.${1}; + +# Component +snippet raf + const ${1:ComponentName} = (${2:props}) => { + ${3:state} + + return ( + <> + ${4} + + ); + }; + +snippet rcla + class ${1:ClassName} extends Component { + render() { + return ( + <> + ${2} + + ); + } } -snippet prp i - this.props.${1} -snippet ste i - this.state.${1} + +snippet ercla + export default class ${1:ClassName} extends Component { + render() { + return ( + <> + ${2} + + ); + }; + }; + +snippet ctor + constructor() { + super(); + + ${1:state} + } + +snippet ren + render() { + return ( + <> + ${2} + + ); + } + +snippet fup + forceUpdate(${1:callback}); + +# Hooks +snippet uses useState + const [${1:state}, set${2}] = useState(${3:initialState}); + +snippet usee useEffect + useEffect(() => { + ${1} + }); + +snippet userd useReducer + const [${1:state}, ${2:dispatch}] = useReducer(${3:reducer}); + +snippet userf useRef + const ${1:refContainer} = useRef(${2:initialValue}); + +snippet usect useContext + const ${1:value} = useContext(${2:MyContext}); + +snippet usecb useCallback + const ${1:memoizedCallback} = useCallback( + () => { + ${2}(${3}) + }, + [$3] + ); + +snippet usem useMemo + const ${1:memoizedCallback} = useMemo(() => ${2}(${3}), [$3]); + +snippet usei useImperativeHandle + useImperativeHandle(${1:ref}, ${2:createHandle}); + +snippet used useDebugValue + useDebugValue(${1:value}); + +# ReactDOM methods +snippet rdr ReactDOM.render + ReactDOM.render(${1}, ${2}); + +snippet rdh ReactDOM.hydrate + ReactDOM.hydrate(${1:element}, ${2:container}[, ${3:callback}]); + +snippet rdcp ReactDOM.createPortal + ReactDOM.createPortal(${1:child}, ${2:container}); diff --git a/sources_non_forked/vim-snippets/snippets/javascript/javascript.snippets b/sources_non_forked/vim-snippets/snippets/javascript/javascript.snippets index 358c7ea0..49b56147 100644 --- a/sources_non_forked/vim-snippets/snippets/javascript/javascript.snippets +++ b/sources_non_forked/vim-snippets/snippets/javascript/javascript.snippets @@ -318,6 +318,10 @@ snippet foro "for (const prop of object}) { ... }" for (const ${1:prop} of ${2:object}) { ${0:$1} } +snippet forl "for (let prop of object}) { ... }" + for (let ${1:prop} of ${2:object}) { + ${0:$1} + } snippet fun* function* ${1:function_name}(${2}) { ${0:${VISUAL}} @@ -326,15 +330,25 @@ snippet c=> const ${1:function_name} = (${2}) => { ${0:${VISUAL}} } +snippet ca=> + const ${1:function_name} = async (${2}) => { + ${0:${VISUAL}} + } snippet caf const ${1:function_name} = (${2}) => { ${0:${VISUAL}} } +snippet casf + const ${1:function_name} = async (${2}) => { + ${0:${VISUAL}} + } snippet => (${1}) => { ${0:${VISUAL}} } -snippet af +snippet af "() =>" + (${1}) => ${0:${VISUAL}} +snippet afb "() => {}" (${1}) => { ${0:${VISUAL}} } @@ -344,5 +358,7 @@ snippet ed export default ${0} snippet ${ ${${1}}${0} +snippet as "async" + async ${0} snippet aw "await" await ${0:${VISUAL}} diff --git a/sources_non_forked/vim-snippets/snippets/julia.snippets b/sources_non_forked/vim-snippets/snippets/julia.snippets index 490d050d..1e0d3f2f 100644 --- a/sources_non_forked/vim-snippets/snippets/julia.snippets +++ b/sources_non_forked/vim-snippets/snippets/julia.snippets @@ -89,14 +89,26 @@ snippet thr throw ${0} # Messages -snippet in - info("${1}") - ${0} +snippet @i + @info "${1}" ${0} -snippet wa - warn("${1}") - ${0} +snippet @w + @warn "${1}" ${0} -snippet err - error("${1}") - ${0} +snippet @e + @error "${1}" ${0} + +snippet @d + @debug "${1}" ${0} + +snippet @t @testset with @test + @testset "${1}" begin + ${2} + @test ${0} + end + +snippet @tt @testset with @test_throws + @testset "${1}" begin + ${2} + @test_throws ${0} + end diff --git a/sources_non_forked/vim-snippets/snippets/liquid.snippets b/sources_non_forked/vim-snippets/snippets/liquid.snippets index 4f11f086..a39a0876 100644 --- a/sources_non_forked/vim-snippets/snippets/liquid.snippets +++ b/sources_non_forked/vim-snippets/snippets/liquid.snippets @@ -63,6 +63,10 @@ snippet include {% include '${0:snippet}' %} snippet includewith {% include '${1:snippet}', ${2:variable}: ${0:value} %} +snippet render + {% render '${0:snippet}' %} +snippet renderwith + {% render '${1:snippet}', ${2:variable}: ${0:value} %} snippet section {% section '${1:snippet}' %} snippet raw diff --git a/sources_non_forked/vim-snippets/snippets/markdown.snippets b/sources_non_forked/vim-snippets/snippets/markdown.snippets index 303271ed..364066cf 100644 --- a/sources_non_forked/vim-snippets/snippets/markdown.snippets +++ b/sources_non_forked/vim-snippets/snippets/markdown.snippets @@ -5,19 +5,19 @@ # The suffix `c` stands for "Clipboard". snippet [ - [${1:text}](http://${2:address}) + [${1:text}](https://${2:address}) snippet [* [${1:link}](${2:`@*`}) snippet [c [${1:link}](${2:`@+`}) snippet [" - [${1:text}](http://${2:address} "${3:title}") + [${1:text}](https://${2:address} "${3:title}") snippet ["* [${1:link}](${2:`@*`} "${3:title}") snippet ["c [${1:link}](${2:`@+`} "${3:title}") snippet [: - [${1:id}]: http://${2:url} + [${1:id}]: https://${2:url} snippet [:* [${1:id}]: ${2:`@*`} @@ -26,7 +26,7 @@ snippet [:c [${1:id}]: ${2:`@+`} snippet [:" - [${1:id}]: http://${2:url} "${3:title}" + [${1:id}]: https://${2:url} "${3:title}" snippet [:"* [${1:id}]: ${2:`@*`} "${3:title}" @@ -129,6 +129,12 @@ snippet img snippet youtube {% youtube ${0:video_id} %} +snippet tb + | ${0:factors} | ${1:a} | ${2:b} | + | ------------- |------------- | ------- | + | ${3:f1} | Y | N | + | ${4:f2} | Y | N | + # The quote should appear only once in the text. It is inherently part of it. # See http://octopress.org/docs/plugins/pullquote/ for more info. diff --git a/sources_non_forked/vim-snippets/snippets/ocaml.snippets b/sources_non_forked/vim-snippets/snippets/ocaml.snippets index eb5a799c..aec43bed 100644 --- a/sources_non_forked/vim-snippets/snippets/ocaml.snippets +++ b/sources_non_forked/vim-snippets/snippets/ocaml.snippets @@ -1,7 +1,7 @@ snippet doc - (* - ${0} - *) + (** ${0} *) +snippet comment + (* ${0} *) snippet let let ${1} = ${2} in ${0} diff --git a/sources_non_forked/vim-snippets/snippets/perl.snippets b/sources_non_forked/vim-snippets/snippets/perl.snippets index 2ed2932a..b318d18c 100644 --- a/sources_non_forked/vim-snippets/snippets/perl.snippets +++ b/sources_non_forked/vim-snippets/snippets/perl.snippets @@ -357,6 +357,10 @@ snippet dump use Data::Dump qw(dump); warn dump ${1:variable} +snippet ddp + use DDP; + p ${1:variable} + snippet subtest subtest '${1: test_name}' => sub { ${2} diff --git a/sources_non_forked/vim-snippets/snippets/ps1.snippets b/sources_non_forked/vim-snippets/snippets/ps1.snippets index 41099d9d..08de1efd 100644 --- a/sources_non_forked/vim-snippets/snippets/ps1.snippets +++ b/sources_non_forked/vim-snippets/snippets/ps1.snippets @@ -29,8 +29,8 @@ snippet function # PowerShell Splatting snippet splatting $Params = @{ - ${1:Param1} = '{2:Value1}' - ${3:Param2} = '{4:Value2}' + ${1:Param1} = '${2:Value1}' + ${3:Param2} = '${4:Value2}' } ${5:CommandName} @Params @@ -99,4 +99,3 @@ snippet switch ${2:condition1} { ${3:action} } ${4:condition2} { ${5:action} } default { ${6:action} } - diff --git a/sources_non_forked/vim-snippets/snippets/python.snippets b/sources_non_forked/vim-snippets/snippets/python.snippets index 42832815..cd1224df 100644 --- a/sources_non_forked/vim-snippets/snippets/python.snippets +++ b/sources_non_forked/vim-snippets/snippets/python.snippets @@ -123,6 +123,8 @@ snippet ret return ${0} snippet . self. +snippet sa self.attribute = attribute + self.${1:attribute} = $1 snippet try Try/Except try: ${1:${VISUAL}} @@ -182,6 +184,10 @@ snippet ptpython # python console debugger (pudb) snippet pudb __import__('pudb').set_trace() +# python console debugger remote (pudb) +snippet pudbr + from pudb.remote import set_trace + set_trace() # pdb in nosetests snippet nosetrace __import__('nose').tools.set_trace() diff --git a/sources_non_forked/vim-snippets/snippets/r.snippets b/sources_non_forked/vim-snippets/snippets/r.snippets index 7bdeeec0..9dbe0f39 100644 --- a/sources_non_forked/vim-snippets/snippets/r.snippets +++ b/sources_non_forked/vim-snippets/snippets/r.snippets @@ -32,6 +32,10 @@ snippet for for (${1:item} in ${2:list}) { ${3} } +snippet foreach + foreach (${1:item} = ${2:list}) { + ${3} + } # functions snippet fun diff --git a/sources_non_forked/vim-snippets/snippets/racket.snippets b/sources_non_forked/vim-snippets/snippets/racket.snippets index 723d7383..5304cd8b 100644 --- a/sources_non_forked/vim-snippets/snippets/racket.snippets +++ b/sources_non_forked/vim-snippets/snippets/racket.snippets @@ -1,3 +1,4 @@ +# Languages snippet #r #lang racket snippet #tr @@ -10,56 +11,38 @@ snippet #d #lang datalog snippet #wi #lang web-server/insta + +# Defines snippet def (define ${1} ${0}) snippet defun (define (${1}) ${0}) +snippet defv "define-values" + (define-values (${1}) (${0})) +snippet defm "define/match" + (define/match (${1}) + [(${2}) ${3}] + ${0}) +snippet defs "define-syntax" + (define-syntax (${1}) + ${0}) + +# Conditionals snippet if (if ${1} ${2} ${0}) snippet ifn - (if (not ${1}) ${2} {0}) + (if (not ${1}) ${2} ${0}) snippet ifl (if ${1} - (let () - ${2}) + (let (${2}) + ${3}) ${0}) snippet ifnl (if (not ${1}) - (let () - ${2}) + (let (${2}) + ${3}) ${0}) -snippet when - (when ${1} - ${0}) -snippet cond - (cond - [(${1}) - ${0}]) -snippet case - (case ${1} - [(${2}) - ${0}]) -snippet match - (match ${1} - [(${2}) - ${0}]) -snippet letcc - (let/cc here (set! ${1} here) ${0}) -snippet for - (for ([${1} ${2}]) - ${0}) -snippet req - (require ${0}) -snippet unless - (unless ${1} ${2} ${0}) -snippet let - (let ([${1}]) ${0}) -snippet begin - (begin - ${0}) -snippet lambda - (lambda (${1}) ${0}) snippet ifb (if ${1} (begin @@ -70,3 +53,79 @@ snippet ifnb (begin ${2}) ${0}) +snippet when + (when ${1} + ${0}) +snippet unless + (unless ${1} ${2} ${0}) +snippet cond + (cond + [(${1}) ${0}]) +snippet conde + (cond + [(${1}) ${2}] + [else ${0}]) +snippet case + (case ${1} + [(${2}) ${0}]) +snippet match + (match ${1} + [(${2}) ${0}]) + +# For iterations +snippet for + (for ([${1}]) + ${0}) +snippet forl "for/list" + (for/list ([${1}]) + ${0}) +snippet forf "for/fold" + (for/fold + ([${1}]) + ([${2}]) + ${0}) +snippet forfr "for/foldr" + (for/foldr + ([${1}]) + ([${2}]) + ${0}) +snippet fora "for/and" + (for/and ([${1}]) + ${0}) +snippet foro "for/or" + (for/or ([${1}]) + ${0}) +snippet fors "for/sum" + (for/sum ([${1}]) + ${0}) +snippet forp "for/product" + (for/product ([${1}]) + ${0}) +snippet forfi "for/first" + (for/first ([${1}]) + ${0}) +snippet forla "for/last" + (for/last ([${1}]) + ${0}) + +snippet lambda + (lambda (${1}) ${0}) +snippet apply + (apply ${1} ${0}) +snippet map + (map ${1} ${0}) +snippet filter + (filter ${1} ${0}) + +snippet req + (require ${0}) +snippet prov + (provide ${0}) + +snippet let + (let ([${1}]) ${0}) +snippet letcc + (let/cc here (set! ${1} here) ${0}) +snippet begin + (begin + ${0}) diff --git a/sources_non_forked/vim-snippets/snippets/rmd.snippets b/sources_non_forked/vim-snippets/snippets/rmd.snippets new file mode 100644 index 00000000..96b0ea0e --- /dev/null +++ b/sources_non_forked/vim-snippets/snippets/rmd.snippets @@ -0,0 +1,205 @@ +# +# Snipmate Snippets for Pandoc Markdown +# +# Many snippets have starred versions, i.e., versions +# that end with an asterisk (`*`). These snippets use +# vim's `"*` register---i.e., the contents of the +# system clipboard---to insert text. + +# Insert Title Block +snippet %% + % ${1:`Filename('', 'title')`} + % ${2:`g:snips_author`} + % ${3:`strftime("%d %B %Y")`} + + ${4} +snippet %%* + % ${1:`Filename('', @*)`} + % ${2:`g:snips_author`} + % ${3:`strftime("%d %b %Y")`} + + ${4} + +# Insert Definition List +snippet :: + ${1:term} + ~ ${2:definition} + +# Underline with `=`s or `-`s +snippet === + `repeat('=', strlen(getline(line(".") - 1)))` + + ${1} +snippet --- + `repeat('-', strlen(getline(line(".") - 1)))` + + ${1} + +# Links and their kin +# ------------------- +# +# (These don't play very well with delimitMate) +# + +snippet [ + [${1:link}](http://${2:url} "${3:title}")${4} +snippet [* + [${1:link}](${2:`@*`} "${3:title}")${4} + +snippet [: + [${1:id}]: http://${2:url} "${3:title}" +snippet [:* + [${1:id}]: ${2:`@*`} "${3:title}" + +snippet [@ + [${1:link}](mailto:${2:email})${3} +snippet [@* + [${1:link}](mailto:${2:`@*`})${3} + +snippet [:@ + [${1:id}]: mailto:${2:email} "${3:title}" +snippet [:@* + [${1:id}]: mailto:${2:`@*`} "${3:title}" + +snippet ![ + ![${1:alt}](${2:url} "${3:title}")${4} +snippet ![* + ![${1:alt}](${2:`@*`} "${3:title}")${4} + +snippet ![: + ![${1:id}]: ${2:url} "${3:title}" +snippet ![:* + ![${1:id}]: ${2:`@*`} "${3:title}" + +snippet [^: + [^${1:id}]: ${2:note} +snippet [^:* + [^${1:id}]: ${2:`@*`} + +# + +# library() +snippet req + require(${1:}, quietly = TRUE) +# If Condition +snippet if + if ( ${1:condition} ) + { + ${2:} + } +snippet el + else + { + ${1:} + } + +# Function +snippet fun + ${1:funname} <- # ${2:} + function + ( + ${3:} + ) + { + ${4:} + } +# repeat +snippet re + repeat{ + ${2:} + if(${1:condition}) break + } + +# matrix +snippet ma + matrix(NA, nrow = ${1:}, ncol = ${2:}) + +# data frame +snippet df + data.frame(${1:}, header = TRUE) + +snippet cmdarg + args <- commandArgs(TRUE) + if (length(args) == 0) + stop("Please give ${1:}!") + if (!all(file.exists(args))) + stop("Couln't find input files!") + +snippet getopt + require('getopt', quietly = TRUE) + opt_spec <- matrix(c( + 'help', 'h', 0, "logical", "Getting help", + 'file', 'f', 1, "character","File to process" + ), ncol = 5, byrow = TRUE) + opt <- getopt(spec = opt_spec) + if ( !is.null(opt$help) || is.null(commandArgs()) ) { + cat(getopt(spec = opt_spec, usage = TRUE, command = "yourCmd")) + q(status=0) + } + # some inital value + if ( is.null(opt$???) ) { opt$??? <- ??? } + +snippet optparse + require("optparse", quietly = TRUE) + option_list <- + list(make_option(c("-n", "--add_numbers"), action="store_true", default=FALSE, + help="Print line number at the beginning of each line [default]") + ) + parser <- OptionParser(usage = "%prog [options] file", option_list=option_list) + arguments <- parse_args(parser, positional_arguments = TRUE) + opt <- arguments$options + + if(length(arguments$args) != 1) { + cat("Incorrect number of required positional arguments\n\n") + print_help(parser) + stop() + } else { + file <- arguments$args + } + + if( file.access(file) == -1) { + stop(sprintf("Specified file ( %s ) does not exist", file)) + } else { + file_text <- readLines(file) + } + +snippet #! + #!/usr/bin/env Rscript + +snippet debug + # Development & Debugging, don't forget to uncomment afterwards! + #-------------------------------------------------------------------------------- + #setwd("~/Projekte/${1:}") + #opt <- list(${2:} + # ) + #-------------------------------------------------------------------------------- + + +# Took from pandoc-plugin <<<< +# Underline with `=`s or `-`s +snippet #=== + #`repeat('=', strlen(getline(line(".") - 1)))` + ${1} +snippet #--- + #`repeat('-', strlen(getline(line(".") - 1)))` + ${1} + +# >>>> + +snippet r + \`\`\`{r ${1:chung_tag}, echo = FALSE ${2:options}} + ${3:} + \`\`\` +snippet ri + \`{r ${1:}}\` + +snippet copt + \`\`\` {r setup, echo = FALSE} + opts_chunk$set(fig.path='../figures/${1:}', cache.path='../cache/-' + , fig.align='center', fig.show='hold', par=TRUE) + #opts_knit$set(upload.fun = imgur_upload) # upload images + \`\`\` + + +# End of File =================================================================== +# vim: set noexpandtab: diff --git a/sources_non_forked/vim-snippets/snippets/rust.snippets b/sources_non_forked/vim-snippets/snippets/rust.snippets index 692a0bf1..71fe5909 100644 --- a/sources_non_forked/vim-snippets/snippets/rust.snippets +++ b/sources_non_forked/vim-snippets/snippets/rust.snippets @@ -11,6 +11,14 @@ snippet pfn "Function definition" pub fn ${1:function_name}(${2})${3} { ${0} } +snippet afn "Async function definition" + async fn ${1:function_name}(${2})${3} { + ${0} + } +snippet pafn "Async function definition" + pub async fn ${1:function_name}(${2})${3} { + ${0} + } snippet bench "Bench function" b #[bench] fn ${1:bench_function_name}(b: &mut test::Bencher) { @@ -102,7 +110,7 @@ snippet crate "Define create meta attributes" snippet opt "Option" Option<${1:i32}> snippet res "Result" - Result<${1:~str}, ${2:()}> + Result<${1:&str}, ${2:()}> # Control structures snippet if if ${1} { @@ -114,6 +122,10 @@ snippet ife "if / else" } else { ${0} } +snippet ifl "if let (...)" + if let ${1:Some($2)} = $3 { + ${0:${VISUAL}} + } snippet el "else" else { ${0:${VISUAL}} @@ -138,6 +150,10 @@ snippet wh "while loop" while ${1:condition} { ${0:${VISUAL}} } +snippet whl "while let (...)" + while let ${1:Some($2)} = $3 { + ${0:${VISUAL}} + } snippet for "for ... in ... loop" for ${1:i} in ${2} { ${0} @@ -153,7 +169,7 @@ snippet st "Struct definition" ${0} } snippet impl "Struct/Trait implementation" - impl ${1:Type/Trait}${2: for ${3:Type}} { + impl ${1:Type/Trait}${2: for $3} { ${0} } snippet stn "Struct with new constructor" @@ -161,9 +177,9 @@ snippet stn "Struct with new constructor" ${0} } - impl $1 { - pub fn new(${2}) -> Self { - $1 { ${3} } + impl$2 $1$2 { + pub fn new(${4}) -> Self { + $1 { ${5} } } } snippet ty "Type alias" @@ -182,7 +198,7 @@ snippet trait "Trait definition" ${0} } snippet drop "Drop trait implementation (destructor)" - impl Drop for ${1:Name} { + impl Drop for $1 { fn drop(&mut self) { ${0} } @@ -193,10 +209,6 @@ snippet ss "static string declaration" snippet stat "static item declaration" static ${1}: ${2:usize} = ${0}; # Concurrency -snippet scoped "spawn a scoped thread" - thread::scoped(${1:move }|| { - ${0} - }); snippet spawn "spawn a thread" thread::spawn(${1:move }|| { ${0} @@ -230,9 +242,11 @@ snippet macro "macro_rules!" b $3 ) } -snippet box "Box::new()" +snippet boxp "Box::new()" Box::new(${0:${VISUAL}}) snippet rc "Rc::new()" Rc::new(${0:${VISUAL}}) snippet unim "unimplemented!()" unimplemented!() +snippet use "use ...;" b + use ${1:std::$2}; diff --git a/sources_non_forked/vim-snippets/snippets/svelte.snippets b/sources_non_forked/vim-snippets/snippets/svelte.snippets new file mode 100644 index 00000000..4e09d0cc --- /dev/null +++ b/sources_non_forked/vim-snippets/snippets/svelte.snippets @@ -0,0 +1 @@ +extends html, javascript, css diff --git a/sources_non_forked/vim-snippets/snippets/tex.snippets b/sources_non_forked/vim-snippets/snippets/tex.snippets index 0f8f9c03..e13508a4 100644 --- a/sources_non_forked/vim-snippets/snippets/tex.snippets +++ b/sources_non_forked/vim-snippets/snippets/tex.snippets @@ -289,7 +289,9 @@ snippet sum \sum^{}_{} snippet lim \lim_{} \\lim_{${1:n \\to \\infty}} ${0} snippet frame frame environment - \\begin{frame}[${1:t}]{${2:title}} + \\begin{frame}[${1:t}] + \frametitle{${2:title}} + \framesubtitle{${3:subtitle}} ${0:${VISUAL}} \\end{frame} snippet block block environment @@ -356,3 +358,59 @@ snippet hrefc # enquote from package csquotes snippet enq enquote \\enquote{${1:${VISUAL:text}}} ${0} + +# Time derivative +snippet ddt time derivative + \\frac{d}{dt} {$1} {$0} + +# Limit +snippet lim limit + \\lim_{{$1}} {{$2}} {$0} + +# Partial derivative +snippet pdv partial derivation + \\frac{\\partial {$1}}{\partial {$2}} {$0} + +# Second order partial derivative +snippet ppdv second partial derivation + \\frac{\partial^2 {$1}}{\partial {$2} \partial {$3}} {$0} + +# Ordinary derivative +snippet dv derivative + \\frac{d {$1}}{d {$2}} {$0} + +# Summation +snippet summ summation + \\sum_{{$1}} {$0} + +# Shorthand for time derivative +snippet dot dot + \\dot{{$1}} {$0} + +# Shorthand for second order time derivative +snippet ddot ddot + \\ddot{{$1}} {$0} + +# Vector +snippet vec vector + \\vec{{$1}} {$0} + +# Cross product +snippet \x cross product + \\times {$0} + +# Dot product +snippet . dot product + \\cdot {$0} + +# Integral +snippet int integral + \\int_{{$1}}^{{$2}} {$3} \: d{$4} {$5} + +# Right arrow +snippet ra rightarrow + \\rightarrow {$0} + +# Long right arrow +snippet lra longrightarrow + \\longrightarrow {$0} diff --git a/sources_non_forked/vim-snippets/snippets/twig.snippets b/sources_non_forked/vim-snippets/snippets/twig.snippets index d0d7e1c9..8102984d 100644 --- a/sources_non_forked/vim-snippets/snippets/twig.snippets +++ b/sources_non_forked/vim-snippets/snippets/twig.snippets @@ -1,34 +1,177 @@ -snippet bl "{% block xyz %} .. {% endblock xyz %}" +# Tags +snippet apply "twig apply" + {% apply ${1} %} + ${0} + {% endapply %} +snippet autoescape "twig autoescape" + {% autoescape %} + ${0} + {% endautoescape %} +snippet endautoescape "twig endautoescape" + {% endautoescape %}${0} +snippet bl "twig block" {% block ${1} %} - ${2:${VISUAL}} - {% endblock $1 %} -snippet js "{% javascripts 'xyz' %} .. {% endjavascripts %}" - {% javascripts '${1}' %} - - {% endjavascripts %} -snippet css "{% stylesheets 'xyz' %} .. {% endstylesheets %}" - {% stylesheets '${1}' %} - - {% endstylesheets %} -snippet if "{% if %} .. {% endif %}" - {% if ${1} %} - ${2:${VISUAL}} - {% endif %} -snippet ife "{% if %} .. {% else %} .. {% endif %}" - {% if ${1} %} - ${2:${VISUAL}} - {% else %} - ${0} - {% endif %} -snippet el "{% else %}" - {% else %} - ${0:${VISUAL}} -snippet eif "{% elseif %}" - {% elseif ${1} %} - ${0} -snippet for "{% for x in y %} .. {% endfor %}" + ${0} + {% endblock %} +snippet block "twig block" + {% block ${1} %} + ${0} + {% endblock %} +snippet endblock "twig endblock" + {% endblock %}${0} +snippet cache "twig cache" + {% cache %} + ${0} + {% endcache %} +snippet endcache "twig endcache" + {% endcache %}${0} +snippet css "twig css" + {% css %} + ${0} + {% endcss %} +snippet endcss "twig endcss" + {% endcss %}${0} +snippet dd "twig dd" + {% dd ${1} %}${0} +snippet do "twig do" + {% do ${1} %}${0} +snippet embed "twig embed" + {% embed "${1}" %} + ${0} + {% endembed %} +snippet endembed "twig endembed" + {% endembed %}${0} +snippet exit "twig exit" + {% exit ${1} %} +snippet extends "twig extends" + {% extends "${1}" %}${0} +snippet ext "twig extends" + {% extends "${1}" %}${0} +snippet for "twig for" {% for ${1} in ${2} %} - ${3} + ${0} {% endfor %} -snippet ext "{% extends xyz %}" - {% extends ${1} %} +snippet fore "twig for else" + {% for ${1} in ${2} %} + ${3} + {% else %} + ${0} + {% endfor %} +snippet endfor "twig endfor" + {% endfor %}${0} +snippet from "twig from" + {% from "${1}" import ${2} %}${0} +snippet header "twig header" + {% header "${1}" %}${0} +snippet hook "twig hook" + {% hook "${1}" %}${0} +snippet html "twig html" + {% html %} + ${0} + {% endhtml %} +snippet endhtml "twig endhtml" + {% endhtml %}${0} +snippet if "twig if" + {% if ${1} %} + ${0} + {% endif %} +snippet ife "twig if else" + {% if ${1} %} + ${2} + {% else %} + ${0} + {% endif %} +snippet el "twig else" + {% else %} +snippet eif "twig elseif" + {% elseif ${1} %} + ${0} +snippet endif "twig endif" + {% endif %}${0} +snippet import "twig import" + {% import "${1}" as ${2} %}${0} +snippet include "twig include" + {% include "${1}" %}${0} +snippet includewith "twig include with parameters" + {% include "${1}" with ${2} %}${0} +snippet js "twig js" + {% js %} + ${0} + {% endjs %} +snippet endjs "twig endjs" + {% endjs %}${0} +snippet macro "twig macro" + {% macro ${1}(${2}) %} + ${0} + {% endmacro %} +snippet endmacro "twig endmacro" + {% endmacro %}${0} +snippet namespace "twig namespace" + {% namespace "${1}" %} + ${0} + {% endnamespace %} +snippet endnamespace "twig endnamespace" + {% endnamespace %}${0} +snippet nav "twig nav" + {% nav ${1} in ${2} %} + ${0} + {% endnav %} +snippet endnav "twig endnav" + {% endnav %}${0} +snippet paginate "twig paginate" + {% paginate ${1} as ${2} %}${0} +snippet redirect "twig redirect" + {% redirect "${1}" %}${0} +snippet requireguest "twig requireguest" + {% requireGuest %}${0} +snippet requirelogin "twig requirelogin" + {% requireLogin %}${0} +snippet requirepermission "twig requirepermission" + {% requirePermission "${1}" %}${0} +snippet set "twig set" + {% set ${1} = ${2} %}${0} +snippet setb "twig set block" + {% set ${1} %} + ${0} + {% endset %} +snippet endset "twig endset" + {% endset %}${0} +snippet switch "twig switch" + {% switch ${1} %} + {% case "${2}" %} + ${0} + {% default %} + + {% endswitch %} +snippet case "twig switch case" + {% case "${1}" %} + ${0} +snippet default "twig switch default" + {% default %} + ${0} +snippet endswitch "twig endswitch" + {% endswitch %}${0} +snippet use "twig use" + {% use "${1}" %}${0} +snippet verbatim "twig verbatim" + {% verbatim %} + ${0} + {% endverbatim %} +snippet endverbatim "twig endverbatim" + {% endverbatim %}${0} +snippet with "twig with" + {% with %} + ${0} + {% endwith %} +snippet endwith "twig endwith" + {% endwith %}${0} + +# Functions +snippet dump "twig dump" +
+		{{ dump(${1}) }}
+	
+ +# Filters +snippet translate "twig translate" + {{ "${1}"|t }}${0} diff --git a/sources_non_forked/vim-snippets/snippets/typescript.snippets b/sources_non_forked/vim-snippets/snippets/typescript.snippets index fddbeb1c..a784c5ef 100644 --- a/sources_non_forked/vim-snippets/snippets/typescript.snippets +++ b/sources_non_forked/vim-snippets/snippets/typescript.snippets @@ -9,8 +9,16 @@ snippet tlet "ts let" snippet tvar "ts var" var ${1}: ${2:any} = ${3}; ${0} -snippet + "var: type" +snippet + "ts create field" ${1}: ${0:any} +snippet #+ "ts create private field using #" + #${1}: ${0:any} +snippet tpfi "ts create public field" + public ${1}: ${0:any} +snippet tprfi "ts create private field" + private ${1}: ${0:any} +snippet tprofi "ts create protected field" + protected ${1}: ${0:any} snippet int "interface" interface ${1} { ${2}: ${3:any}; @@ -25,6 +33,22 @@ snippet tfun "ts function" function ${1}(${2}): ${3:any} { ${0} } +snippet tpmet "ts public method" + public ${1}(${2}): ${3:any} { + ${0} + } +snippet tpsmet "ts public static method" + public static ${1}(${2}): ${3:any} { + ${0} + } +snippet tprmet "ts private method" + private ${1}(${2}): ${3:any} { + ${0} + } +snippet tpromet "ts protected method" + protected ${1}(${2}): ${3:any} { + ${0} + } snippet tcla "ts class" class ${1} { ${2} diff --git a/sources_non_forked/vim-snippets/snippets/verilog.snippets b/sources_non_forked/vim-snippets/snippets/verilog.snippets index df5eeb81..e4a6b052 100644 --- a/sources_non_forked/vim-snippets/snippets/verilog.snippets +++ b/sources_non_forked/vim-snippets/snippets/verilog.snippets @@ -9,7 +9,7 @@ snippet ife ${2} end else begin - ${1} + ${3} end # Else if statement snippet eif diff --git a/sources_non_forked/vim-snippets/snippets/vhdl.snippets b/sources_non_forked/vim-snippets/snippets/vhdl.snippets index f13f5bf9..0683a218 100644 --- a/sources_non_forked/vim-snippets/snippets/vhdl.snippets +++ b/sources_non_forked/vim-snippets/snippets/vhdl.snippets @@ -3,7 +3,7 @@ snippet lib library ${1} - use ${1}.${2} + use $1.${2} # Standard Libraries snippet libs @@ -75,6 +75,16 @@ snippet prc ${2} end if; end process; +# process with clock and reset +snippet prcr + process (${1:clk}, ${2:nrst}) + begin + if ($2 = '${3:0}') then + ${4} + elsif rising_edge($1) then + ${5} + end if; + end process; # process all snippet pra process (${1:all}) diff --git a/sources_non_forked/vim-snippets/snippets/vim.snippets b/sources_non_forked/vim-snippets/snippets/vim.snippets index ad35df73..f19b3a46 100644 --- a/sources_non_forked/vim-snippets/snippets/vim.snippets +++ b/sources_non_forked/vim-snippets/snippets/vim.snippets @@ -43,7 +43,6 @@ snippet ife if ... else statement endif snippet au augroup ... autocmd block augroup ${1:AU_NAME} - " this one is which you're most likely to use? autocmd ${2:BufRead,BufNewFile} ${3:*.ext,*.ext3|} ${0} augroup end snippet bun Vundle.vim Plugin definition diff --git a/update_plugins.py b/update_plugins.py index 5e14e899..606fba04 100644 --- a/update_plugins.py +++ b/update_plugins.py @@ -50,19 +50,18 @@ vim-pug https://github.com/digitaltoad/vim-pug lightline.vim https://github.com/itchyny/lightline.vim lightline-ale https://github.com/maximbaz/lightline-ale vim-abolish https://github.com/tpope/tpope-vim-abolish -mru.vim https://github.com/vim-scripts/mru.vim rust.vim https://github.com/rust-lang/rust.vim vim-markdown https://github.com/plasticboy/vim-markdown -gist-vim https://github.com/mattn/gist-vim +vim-gist https://github.com/mattn/vim-gist vim-ruby https://github.com/vim-ruby/vim-ruby typescript-vim https://github.com/leafgarland/typescript-vim vim-javascript https://github.com/pangloss/vim-javascript vim-python-pep8-indent https://github.com/Vimjas/vim-python-pep8-indent """.strip() -GITHUB_ZIP = '%s/archive/master.zip' +GITHUB_ZIP = "%s/archive/master.zip" -SOURCE_DIR = path.join(path.dirname(__file__), 'sources_non_forked') +SOURCE_DIR = path.join(path.dirname(__file__), "sources_non_forked") def download_extract_replace(plugin_name, zip_path, temp_dir, source_dir): @@ -70,13 +69,14 @@ def download_extract_replace(plugin_name, zip_path, temp_dir, source_dir): # Download and extract file in temp dir req = requests.get(zip_path) - open(temp_zip_path, 'wb').write(req.content) + open(temp_zip_path, "wb").write(req.content) zip_f = zipfile.ZipFile(temp_zip_path) zip_f.extractall(temp_dir) plugin_temp_path = path.join( - temp_dir, path.join(temp_dir, '%s-master' % plugin_name)) + temp_dir, path.join(temp_dir, "%s-master" % plugin_name) + ) # Remove the current plugin and replace it with the extracted plugin_dest_path = path.join(source_dir, plugin_name) @@ -87,16 +87,16 @@ def download_extract_replace(plugin_name, zip_path, temp_dir, source_dir): pass shutil.move(plugin_temp_path, plugin_dest_path) - print('Updated {0}'.format(plugin_name)) + print("Updated {0}".format(plugin_name)) def update(plugin): - name, github_url = plugin.split(' ') + name, github_url = plugin.split(" ") zip_path = GITHUB_ZIP % github_url download_extract_replace(name, zip_path, temp_directory, SOURCE_DIR) -if __name__ == '__main__': +if __name__ == "__main__": temp_directory = tempfile.mkdtemp() try: diff --git a/vimrcs/extended.vim b/vimrcs/extended.vim index 5df62308..459b085a 100644 --- a/vimrcs/extended.vim +++ b/vimrcs/extended.vim @@ -85,7 +85,7 @@ vnoremap $2 `>a]` vnoremap $3 `>a}` vnoremap $$ `>a"` vnoremap $q `>a'` -vnoremap $e `>a"` +vnoremap $e `>a`` " Map auto complete of (, ", ', [ inoremap $1 ()i diff --git a/vimrcs/plugins_config.vim b/vimrcs/plugins_config.vim index 3ca2c6f6..2dd58855 100644 --- a/vimrcs/plugins_config.vim +++ b/vimrcs/plugins_config.vim @@ -46,9 +46,15 @@ nmap yankstack_substitute_newer_paste """""""""""""""""""""""""""""" let g:ctrlp_working_path_mode = 0 +" Quickly find and open a file in the current working directory let g:ctrlp_map = '' map j :CtrlP -map :CtrlPBuffer + +" Quickly find and open a buffer +map b :CtrlPBuffer + +" Quickly find and open a recently opened file +map f :CtrlPMRU let g:ctrlp_max_height = 20 let g:ctrlp_custom_ignore = 'node_modules\|^\.DS_Store\|^\.git\|^\.coffee' @@ -124,12 +130,12 @@ let g:lightline = { \ 'component': { \ 'readonly': '%{&filetype=="help"?"":&readonly?"🔒":""}', \ 'modified': '%{&filetype=="help"?"":&modified?"+":&modifiable?"":"-"}', - \ 'fugitive': '%{exists("*fugitive#head")?fugitive#head():""}' + \ 'fugitive': '%{exists("*FugitiveHead")?FugitiveHead():""}' \ }, \ 'component_visible_condition': { \ 'readonly': '(&filetype!="help"&& &readonly)', \ 'modified': '(&filetype!="help"&&(&modified||!&modifiable))', - \ 'fugitive': '(exists("*fugitive#head") && ""!=fugitive#head())' + \ 'fugitive': '(exists("*FugitiveHead") && ""!=FugitiveHead())' \ }, \ 'separator': { 'left': ' ', 'right': ' ' }, \ 'subseparator': { 'left': ' ', 'right': ' ' }