diff --git a/README.md b/README.md index 95a7a35d..4260714e 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ Naturally, `/opt/vim_runtime` can be any directory, as long as all the users spe ## Fonts -I recommend using [IBM Plex Mono font](https://github.com/IBM/plex) (it's an open-source and awesome font that can make your code beautiful). The Awesome vimrc is already setup to try to use it. +I recommend using [IBM Plex Mono font](https://github.com/IBM/plex) (it's an open-source and awesome font that can make your code look beautiful). The Awesome vimrc is already setup to try to use it. Some other fonts that Awesome will try to use: @@ -63,9 +63,14 @@ If you have vim aliased as `vi` instead of `vim`, make sure to either alias it: Just do a git rebase! cd ~/.vim_runtime + git reset --hard + git clean -d --force git pull --rebase - python update_plugins.py + python update_plugins.py # use python3 if python is unavailable +NOTE: If you get `ModuleNotFoundError: No module named 'requests'`, you must first install the `requests` python module using `pip`, `pip3`, or `easy_install`. + + pip install requests ## Some screenshots @@ -102,11 +107,14 @@ I recommend reading the docs of these plugins to understand them better. Each pl * [vim-yankstack](https://github.com/maxbrunsfeld/vim-yankstack): Maintains a history of previous yanks, changes and deletes * [vim-zenroom2](https://github.com/amix/vim-zenroom2) Remove all clutter and focus only on the essential. Similar to iA Writer or Write Room * [gist-vim](https://github.com/mattn/gist-vim) Easily create gists from Vim using the `:Gist` command +* [vim-indent-guides](https://github.com/nathanaelkane/vim-indent-guides) Is a plugin for visually displaying indent levels in Vim +* [editorconfig-vim](https://github.com/editorconfig/editorconfig-vim) EditorConfig helps maintain consistent coding styles for multiple developers working on the same project across various editors and IDEs. ## Included color schemes * [peaksea](https://github.com/vim-scripts/peaksea): The default +* [dracula](https://github.com/dracula/vim) * [vim-colors-solarized](https://github.com/altercation/vim-colors-solarized) * [vim-irblack](https://github.com/wgibbs/vim-irblack) * [mayansmoke](https://github.com/vim-scripts/mayansmoke) @@ -140,6 +148,13 @@ You can also install your plugins, for instance, via pathogen you can install [v cd ~/.vim_runtime git clone git://github.com/tpope/vim-rails.git my_plugins/vim-rails +You can also install plugins without any plugin manager (vim 8+ required): + Add `packloadall` to your .vimrc file + Create pack plugin directory: + `mkdir -p ~/.vim/pack/plugins/start` + Clone the plugin that you want in that directory, for example: + `git clone --depth=1 git://github.com/maxmellon/vim-jsx-pretty ~/.vim/pack/plugins/vim-jsx-pretty` + ## Key Mappings @@ -330,6 +345,13 @@ Open [ctrlp.vim](https://github.com/kien/ctrlp.vim) plugin to quickly find a fil nmap a (ale_next_wrap) +[vim-indent-guides](https://github.com/nathanaelkane/vim-indent-guides) the default mapping to toggle the plugin is (`ig`) + + You can also use the following commands inside Vim: + :IndentGuidesEnable + :IndentGuidesDisable + :IndentGuidesToggle + ### Spell checking Pressing `ss` will toggle spell checking: @@ -343,6 +365,13 @@ Shortcuts using `` instead of special characters: map sa zg map s? z= +### Running Code +To run code directly from vim, press `F5`. The currently open code will execute without you having to type anything. + +Can be used to execute code written in C, C++, Java, Python, Go, Octave, Bash scripts and HTML. To edit how you want your code to be executed, make changes in the file +``` +~/vim_runtime/vimrcs/extended.vim +``` ### Cope Query `:help cope` if you are unsure what cope is. It's super useful! @@ -375,3 +404,4 @@ Just do following: 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 ee4be411..1ca2ba5f 100755 --- a/install_awesome_parameterized.sh +++ b/install_awesome_parameterized.sh @@ -4,7 +4,10 @@ set -e echo 'Installing Awesome Vim from '$1 cd $1 -VIMRC="set runtimepath+=$1 +VIMRC="\" DO NOT EDIT THIS FILE +\" Add your own customizations in $1/my_configs.vim + +set runtimepath+=$1 source $1/vimrcs/basic.vim source $1/vimrcs/filetypes.vim @@ -12,7 +15,7 @@ source $1/vimrcs/plugins_config.vim source $1/vimrcs/extended.vim try -source $1/my_configs.vim + source $1/my_configs.vim catch endtry" diff --git a/install_awesome_vimrc.sh b/install_awesome_vimrc.sh index 6b94e519..29466977 100755 --- a/install_awesome_vimrc.sh +++ b/install_awesome_vimrc.sh @@ -3,15 +3,17 @@ set -e cd ~/.vim_runtime -echo 'set runtimepath+=~/.vim_runtime +echo '" DO NOT EDIT THIS FILE +" Add your own customizations in ~/.vim_runtime/my_configs.vim + +set runtimepath+=~/.vim_runtime source ~/.vim_runtime/vimrcs/basic.vim source ~/.vim_runtime/vimrcs/filetypes.vim source ~/.vim_runtime/vimrcs/plugins_config.vim source ~/.vim_runtime/vimrcs/extended.vim - try -source ~/.vim_runtime/my_configs.vim + source ~/.vim_runtime/my_configs.vim catch endtry' > ~/.vimrc diff --git a/sources_non_forked/ale/ale_linters/ada/adals.vim b/sources_non_forked/ale/ale_linters/ada/adals.vim new file mode 100644 index 00000000..9a41e1df --- /dev/null +++ b/sources_non_forked/ale/ale_linters/ada/adals.vim @@ -0,0 +1,26 @@ +" Author: Bartek Jasicki http://github.com/thindil +" Description: Support for Ada Language Server + +call ale#Set('ada_adals_executable', 'ada_language_server') +call ale#Set('ada_adals_project', 'default.gpr') +call ale#Set('ada_adals_encoding', 'utf-8') + +function! ale_linters#ada#adals#GetAdaLSConfig(buffer) abort + return { + \ 'ada.projectFile': ale#Var(a:buffer, 'ada_adals_project'), + \ 'ada.defaultCharset': ale#Var(a:buffer, 'ada_adals_encoding') + \} +endfunction + +function! ale_linters#ada#adals#GetRootDirectory(buffer) abort + return fnamemodify(bufname(a:buffer), ':p:h') +endfunction + +call ale#linter#Define('ada', { +\ 'name': 'adals', +\ 'lsp': 'stdio', +\ 'executable': {b -> ale#Var(b, 'ada_adals_executable')}, +\ 'command': '%e', +\ 'project_root': function('ale_linters#ada#adals#GetRootDirectory'), +\ 'lsp_config': function('ale_linters#ada#adals#GetAdaLSConfig') +\}) diff --git a/sources_non_forked/ale/ale_linters/ansible/ansible_lint.vim b/sources_non_forked/ale/ale_linters/ansible/ansible_lint.vim index c4affa31..3b443369 100644 --- a/sources_non_forked/ale/ale_linters/ansible/ansible_lint.vim +++ b/sources_non_forked/ale/ale_linters/ansible/ansible_lint.vim @@ -1,4 +1,4 @@ -" Author: Bjorn Neergaard +" Authors: Bjorn Neergaard , Vytautas Macionis " Description: ansible-lint for ansible-yaml files call ale#Set('ansible_ansible_lint_executable', 'ansible-lint') @@ -7,7 +7,7 @@ function! ale_linters#ansible#ansible_lint#GetExecutable(buffer) abort return ale#Var(a:buffer, 'ansible_ansible_lint_executable') endfunction -function! ale_linters#ansible#ansible_lint#Handle(buffer, lines) abort +function! ale_linters#ansible#ansible_lint#Handle(buffer, version, lines) abort for l:line in a:lines[:10] if match(l:line, '^Traceback') >= 0 return [{ @@ -18,39 +18,87 @@ function! ale_linters#ansible#ansible_lint#Handle(buffer, lines) abort endif endfor - " Matches patterns line the following: - " - " test.yml:35: [EANSIBLE0002] Trailing whitespace - let l:pattern = '\v^([a-zA-Z]?:?[^:]+):(\d+):?(\d+)?: \[?([[:alnum:]]+)\]? (.*)$' + let l:version_group = ale#semver#GTE(a:version, [5, 0, 0]) ? '>=5.0.0' : '<5.0.0' let l:output = [] - for l:match in ale#util#GetMatches(a:lines, l:pattern) - let l:code = l:match[4] + if '>=5.0.0' is# l:version_group + " Matches patterns line the following: + " test.yml:3:148: syntax-check 'var' is not a valid attribute for a Play + " roles/test/tasks/test.yml:8: [package-latest] [VERY_LOW] Package installs should not use latest + " D:\test\tasks\test.yml:8: [package-latest] [VERY_LOW] package installs should not use latest + let l:pattern = '\v^(%([a-zA-Z]:)?[^:]+):(\d+):%((\d+):)? %(\[([-[:alnum:]]+)\]) %(\[([_[:alnum:]]+)\]) (.*)$' + let l:error_codes = { 'VERY_HIGH': 'E', 'HIGH': 'E', 'MEDIUM': 'W', 'LOW': 'W', 'VERY_LOW': 'W', 'INFO': 'I' } - if l:code is# 'EANSIBLE0002' - \&& !ale#Var(a:buffer, 'warn_about_trailing_whitespace') - " Skip warnings for trailing whitespace if the option is off. - continue - endif + 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': l:match[2] + 0, + \ 'col': l:match[3] + 0, + \ 'text': l:match[6], + \ 'code': l:match[4], + \ 'type': l:error_codes[l:match[5]], + \}) + endif + endfor + endif - if ale#path#IsBufferPath(a:buffer, l:match[1]) - call add(l:output, { - \ 'lnum': l:match[2] + 0, - \ 'col': l:match[3] + 0, - \ 'text': l:match[5], - \ 'code': l:code, - \ 'type': l:code[:0] is# 'E' ? 'E' : 'W', - \}) - endif - endfor + if '<5.0.0' is# l:version_group + " Matches patterns line the following: + " test.yml:35: [EANSIBLE0002] Trailing whitespace + let l:pattern = '\v^([a-zA-Z]?:?[^:]+):(\d+):?(\d+)?: \[?([[:alnum:]]+)\]? (.*)$' + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + let l:code = l:match[4] + + if l:code is# 'EANSIBLE0002' + \&& !ale#Var(a:buffer, 'warn_about_trailing_whitespace') + " Skip warnings for trailing whitespace if the option is off. + continue + endif + + if ale#path#IsBufferPath(a:buffer, l:match[1]) + call add(l:output, { + \ 'lnum': l:match[2] + 0, + \ 'col': l:match[3] + 0, + \ 'text': l:match[5], + \ 'code': l:code, + \ 'type': l:code[:0] is# 'E' ? 'E' : 'W', + \}) + endif + endfor + endif return l:output endfunction +function! ale_linters#ansible#ansible_lint#GetCommand(buffer, version) abort + let l:commands = { + \ '>=5.0.0': '%e --nocolor --parseable-severity -x yaml %s', + \ '<5.0.0': '%e --nocolor -p %t' + \} + let l:command = ale#semver#GTE(a:version, [5, 0]) ? l:commands['>=5.0.0'] : l:commands['<5.0.0'] + + return l:command +endfunction + call ale#linter#Define('ansible', { \ 'name': 'ansible_lint', \ 'aliases': ['ansible', 'ansible-lint'], \ 'executable': function('ale_linters#ansible#ansible_lint#GetExecutable'), -\ 'command': '%e -p %t', -\ 'callback': 'ale_linters#ansible#ansible_lint#Handle', +\ 'command': {buffer -> ale#semver#RunWithVersionCheck( +\ buffer, +\ ale_linters#ansible#ansible_lint#GetExecutable(buffer), +\ '%e --version', +\ function('ale_linters#ansible#ansible_lint#GetCommand'), +\ )}, +\ 'lint_file': 1, +\ 'callback': {buffer, lines -> ale#semver#RunWithVersionCheck( +\ buffer, +\ ale_linters#ansible#ansible_lint#GetExecutable(buffer), +\ '%e --version', +\ {buffer, version -> ale_linters#ansible#ansible_lint#Handle( +\ buffer, +\ l:version, +\ lines)}, +\ )}, \}) diff --git a/sources_non_forked/ale/ale_linters/apkbuild/apkbuild_lint.vim b/sources_non_forked/ale/ale_linters/apkbuild/apkbuild_lint.vim new file mode 100644 index 00000000..285f5534 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/apkbuild/apkbuild_lint.vim @@ -0,0 +1,12 @@ +" Author: Leo +" Description: apkbuild-lint from atools linter for APKBUILDs + +call ale#Set('apkbuild_apkbuild_lint_executable', 'apkbuild-lint') + +call ale#linter#Define('apkbuild', { +\ 'name': 'apkbuild_lint', +\ 'output_stream': 'stdout', +\ 'executable': {b -> ale#Var(b, 'apkbuild_apkbuild_lint_executable')}, +\ 'command': '%e %t', +\ 'callback': 'ale#handlers#atools#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/apkbuild/secfixes_check.vim b/sources_non_forked/ale/ale_linters/apkbuild/secfixes_check.vim new file mode 100644 index 00000000..c65267fd --- /dev/null +++ b/sources_non_forked/ale/ale_linters/apkbuild/secfixes_check.vim @@ -0,0 +1,12 @@ +" Author: Leo +" Description: secfixes-check from atools linter for APKBUILDs + +call ale#Set('apkbuild_secfixes_check_executable', 'secfixes-check') + +call ale#linter#Define('apkbuild', { +\ 'name': 'secfixes_check', +\ 'output_stream': 'stdout', +\ 'executable': {b -> ale#Var(b, 'apkbuild_secfixes_check_executable')}, +\ 'command': '%e %t', +\ 'callback': 'ale#handlers#atools#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/c/cppcheck.vim b/sources_non_forked/ale/ale_linters/c/cppcheck.vim index b671fc8b..28c2861f 100644 --- a/sources_non_forked/ale/ale_linters/c/cppcheck.vim +++ b/sources_non_forked/ale/ale_linters/c/cppcheck.vim @@ -5,15 +5,13 @@ call ale#Set('c_cppcheck_executable', 'cppcheck') call ale#Set('c_cppcheck_options', '--enable=style') function! ale_linters#c#cppcheck#GetCommand(buffer) abort - let l:cd_command = ale#handlers#cppcheck#GetCdCommand(a:buffer) let l:compile_commands_option = ale#handlers#cppcheck#GetCompileCommandsOptions(a:buffer) 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}''' + let l:template = ' --template=' . ale#Escape('{file}:{line}:{column}: {severity}:{inconclusive:inconclusive:} {message} [{id}]\\n{code}') - return l:cd_command - \ . '%e -q --language=c' + return '%e -q --language=c' \ . l:template \ . ale#Pad(l:compile_commands_option) \ . ale#Pad(ale#Var(a:buffer, 'c_cppcheck_options')) @@ -25,6 +23,7 @@ call ale#linter#Define('c', { \ 'name': 'cppcheck', \ 'output_stream': 'both', \ 'executable': {b -> ale#Var(b, 'c_cppcheck_executable')}, +\ 'cwd': function('ale#handlers#cppcheck#GetCwd'), \ 'command': function('ale_linters#c#cppcheck#GetCommand'), \ 'callback': 'ale#handlers#cppcheck#HandleCppCheckFormat', \}) 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 eb60ce77..e3f93b6b 100644 --- a/sources_non_forked/ale/ale_linters/clojure/clj_kondo.vim +++ b/sources_non_forked/ale/ale_linters/clojure/clj_kondo.vim @@ -1,6 +1,18 @@ " Author: Masashi Iizuka " Description: linter for clojure using clj-kondo https://github.com/borkdude/clj-kondo +call ale#Set('clojure_clj_kondo_options', '--cache') + +function! ale_linters#clojure#clj_kondo#GetCommand(buffer) abort + let l:options = ale#Var(a:buffer, 'clojure_clj_kondo_options') + + let l:command = 'clj-kondo' + \ . ale#Pad(l:options) + \ . ' --lint %t' + + return l:command +endfunction + function! ale_linters#clojure#clj_kondo#HandleCljKondoFormat(buffer, lines) abort " output format " ::: : @@ -29,6 +41,6 @@ call ale#linter#Define('clojure', { \ 'name': 'clj-kondo', \ 'output_stream': 'stdout', \ 'executable': 'clj-kondo', -\ 'command': 'clj-kondo --cache --lint %t', +\ 'command': function('ale_linters#clojure#clj_kondo#GetCommand'), \ 'callback': 'ale_linters#clojure#clj_kondo#HandleCljKondoFormat', \}) diff --git a/sources_non_forked/ale/ale_linters/cloudformation/cfn_python_lint.vim b/sources_non_forked/ale/ale_linters/cloudformation/cfn_python_lint.vim index d0ac7b28..16841431 100644 --- a/sources_non_forked/ale/ale_linters/cloudformation/cfn_python_lint.vim +++ b/sources_non_forked/ale/ale_linters/cloudformation/cfn_python_lint.vim @@ -29,6 +29,7 @@ endfunction call ale#linter#Define('cloudformation', { \ 'name': 'cloudformation', +\ 'aliases': ['cfn-lint'], \ 'executable': 'cfn-lint', \ 'command': 'cfn-lint --template %t --format parseable', \ 'callback': 'ale_linters#cloudformation#cfn_python_lint#Handle', diff --git a/sources_non_forked/ale/ale_linters/cpp/clangtidy.vim b/sources_non_forked/ale/ale_linters/cpp/clangtidy.vim index 5e062d86..d6944aae 100644 --- a/sources_non_forked/ale/ale_linters/cpp/clangtidy.vim +++ b/sources_non_forked/ale/ale_linters/cpp/clangtidy.vim @@ -23,11 +23,13 @@ function! ale_linters#cpp#clangtidy#GetCommand(buffer, output) abort let l:options = ale#Var(a:buffer, 'cpp_clangtidy_options') let l:cflags = ale#c#GetCFlags(a:buffer, a:output) 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++' + " Tell clang-tidy a .h header with a C++ filetype in Vim is a C++ file + " only when compile-commands.json file is not there. Adding these + " flags makes clang-tidy completely ignore compile commmands. + if expand('#' . a:buffer) =~# '\.h$' + let l:options .= !empty(l:options) ? ' -x c++' : '-x c++' + endif endif " Get the options to pass directly to clang-tidy diff --git a/sources_non_forked/ale/ale_linters/cpp/cppcheck.vim b/sources_non_forked/ale/ale_linters/cpp/cppcheck.vim index 2c832246..eb86adf4 100644 --- a/sources_non_forked/ale/ale_linters/cpp/cppcheck.vim +++ b/sources_non_forked/ale/ale_linters/cpp/cppcheck.vim @@ -5,15 +5,13 @@ call ale#Set('cpp_cppcheck_executable', 'cppcheck') call ale#Set('cpp_cppcheck_options', '--enable=style') function! ale_linters#cpp#cppcheck#GetCommand(buffer) abort - let l:cd_command = ale#handlers#cppcheck#GetCdCommand(a:buffer) let l:compile_commands_option = ale#handlers#cppcheck#GetCompileCommandsOptions(a:buffer) 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}''' + let l:template = ' --template=' . ale#Escape('{file}:{line}:{column}: {severity}:{inconclusive:inconclusive:} {message} [{id}]\\n{code}') - return l:cd_command - \ . '%e -q --language=c++' + return '%e -q --language=c++' \ . l:template \ . ale#Pad(l:compile_commands_option) \ . ale#Pad(ale#Var(a:buffer, 'cpp_cppcheck_options')) @@ -25,6 +23,7 @@ call ale#linter#Define('cpp', { \ 'name': 'cppcheck', \ 'output_stream': 'both', \ 'executable': {b -> ale#Var(b, 'cpp_cppcheck_executable')}, +\ 'cwd': function('ale#handlers#cppcheck#GetCwd'), \ 'command': function('ale_linters#cpp#cppcheck#GetCommand'), \ 'callback': 'ale#handlers#cppcheck#HandleCppCheckFormat', \}) diff --git a/sources_non_forked/ale/ale_linters/cs/csc.vim b/sources_non_forked/ale/ale_linters/cs/csc.vim index 308abc77..5ee3de29 100644 --- a/sources_non_forked/ale/ale_linters/cs/csc.vim +++ b/sources_non_forked/ale/ale_linters/cs/csc.vim @@ -3,14 +3,10 @@ call ale#Set('cs_csc_source', '') call ale#Set('cs_csc_assembly_path', []) call ale#Set('cs_csc_assemblies', []) -function! s:GetWorkingDirectory(buffer) abort - let l:working_directory = ale#Var(a:buffer, 'cs_csc_source') +function! ale_linters#cs#csc#GetCwd(buffer) abort + let l:cwd = ale#Var(a:buffer, 'cs_csc_source') - if !empty(l:working_directory) - return l:working_directory - endif - - return expand('#' . a:buffer . ':p:h') + return !empty(l:cwd) ? l:cwd : expand('#' . a:buffer . ':p:h') endfunction function! ale_linters#cs#csc#GetCommand(buffer) abort @@ -34,8 +30,7 @@ function! ale_linters#cs#csc#GetCommand(buffer) abort " The code is compiled as a module and the output is redirected to a " temporary file. - return ale#path#CdString(s:GetWorkingDirectory(a:buffer)) - \ . 'csc /unsafe' + return 'csc /unsafe' \ . ale#Pad(ale#Var(a:buffer, 'cs_csc_options')) \ . ale#Pad(l:lib_option) \ . ale#Pad(l:r_option) @@ -57,8 +52,7 @@ function! ale_linters#cs#csc#Handle(buffer, lines) abort \ '^\v([^ ]+)\s+([Cc][sS][^ ]+):\s+(.+)$', \] let l:output = [] - - let l:dir = s:GetWorkingDirectory(a:buffer) + let l:dir = ale_linters#cs#csc#GetCwd(a:buffer) for l:match in ale#util#GetMatches(a:lines, l:patterns) if len(l:match) > 6 && strlen(l:match[5]) > 2 && l:match[5][:1] is? 'CS' @@ -89,6 +83,7 @@ call ale#linter#Define('cs',{ \ 'name': 'csc', \ 'output_stream': 'stdout', \ 'executable': 'csc', +\ 'cwd': function('ale_linters#cs#csc#GetCwd'), \ 'command': function('ale_linters#cs#csc#GetCommand'), \ 'callback': 'ale_linters#cs#csc#Handle', \ 'lint_file': 1 diff --git a/sources_non_forked/ale/ale_linters/cs/mcsc.vim b/sources_non_forked/ale/ale_linters/cs/mcsc.vim index 0e4e5667..2dd46661 100644 --- a/sources_non_forked/ale/ale_linters/cs/mcsc.vim +++ b/sources_non_forked/ale/ale_linters/cs/mcsc.vim @@ -3,14 +3,10 @@ call ale#Set('cs_mcsc_source', '') call ale#Set('cs_mcsc_assembly_path', []) call ale#Set('cs_mcsc_assemblies', []) -function! s:GetWorkingDirectory(buffer) abort - let l:working_directory = ale#Var(a:buffer, 'cs_mcsc_source') +function! ale_linters#cs#mcsc#GetCwd(buffer) abort + let l:cwd = ale#Var(a:buffer, 'cs_mcsc_source') - if !empty(l:working_directory) - return l:working_directory - endif - - return expand('#' . a:buffer . ':p:h') + return !empty(l:cwd) ? l:cwd : expand('#' . a:buffer . ':p:h') endfunction function! ale_linters#cs#mcsc#GetCommand(buffer) abort @@ -34,8 +30,7 @@ function! ale_linters#cs#mcsc#GetCommand(buffer) abort " The code is compiled as a module and the output is redirected to a " temporary file. - return ale#path#CdString(s:GetWorkingDirectory(a:buffer)) - \ . 'mcs -unsafe' + return 'mcs -unsafe' \ . ale#Pad(ale#Var(a:buffer, 'cs_mcsc_options')) \ . ale#Pad(l:lib_option) \ . ale#Pad(l:r_option) @@ -58,7 +53,7 @@ function! ale_linters#cs#mcsc#Handle(buffer, lines) abort \] let l:output = [] - let l:dir = s:GetWorkingDirectory(a:buffer) + let l:dir = ale_linters#cs#mcsc#GetCwd(a:buffer) for l:match in ale#util#GetMatches(a:lines, l:patterns) if len(l:match) > 6 && strlen(l:match[5]) > 2 && l:match[5][:1] is? 'CS' @@ -89,6 +84,7 @@ call ale#linter#Define('cs',{ \ 'name': 'mcsc', \ 'output_stream': 'stderr', \ 'executable': 'mcs', +\ 'cwd': function('ale_linters#cs#mcsc#GetCwd'), \ 'command': function('ale_linters#cs#mcsc#GetCommand'), \ 'callback': 'ale_linters#cs#mcsc#Handle', \ 'lint_file': 1 diff --git a/sources_non_forked/ale/ale_linters/css/stylelint.vim b/sources_non_forked/ale/ale_linters/css/stylelint.vim index 38cb0e0b..e508f392 100644 --- a/sources_non_forked/ale/ale_linters/css/stylelint.vim +++ b/sources_non_forked/ale/ale_linters/css/stylelint.vim @@ -11,7 +11,7 @@ endfunction call ale#linter#Define('css', { \ 'name': 'stylelint', -\ 'executable': {b -> ale#node#FindExecutable(b, 'css_stylelint', [ +\ 'executable': {b -> ale#path#FindExecutable(b, 'css_stylelint', [ \ 'node_modules/.bin/stylelint', \ ])}, \ 'command': function('ale_linters#css#stylelint#GetCommand'), diff --git a/sources_non_forked/ale/ale_linters/cuda/clangd.vim b/sources_non_forked/ale/ale_linters/cuda/clangd.vim new file mode 100644 index 00000000..bfda821b --- /dev/null +++ b/sources_non_forked/ale/ale_linters/cuda/clangd.vim @@ -0,0 +1,23 @@ +" Author: Tommy Chiang +" Description: Clangd language server for CUDA (modified from Andrey +" Melentyev's implementation for C++) + +call ale#Set('cuda_clangd_executable', 'clangd') +call ale#Set('cuda_clangd_options', '') +call ale#Set('c_build_dir', '') + +function! ale_linters#cuda#clangd#GetCommand(buffer) abort + let l:build_dir = ale#c#GetBuildDirectory(a:buffer) + + return '%e' + \ . ale#Pad(ale#Var(a:buffer, 'cuda_clangd_options')) + \ . (!empty(l:build_dir) ? ' -compile-commands-dir=' . ale#Escape(l:build_dir) : '') +endfunction + +call ale#linter#Define('cuda', { +\ 'name': 'clangd', +\ 'lsp': 'stdio', +\ 'executable': {b -> ale#Var(b, 'cuda_clangd_executable')}, +\ 'command': function('ale_linters#cuda#clangd#GetCommand'), +\ 'project_root': function('ale#c#FindProjectRoot'), +\}) diff --git a/sources_non_forked/ale/ale_linters/d/dmd.vim b/sources_non_forked/ale/ale_linters/d/dmd.vim index 14461ae6..f38e812c 100644 --- a/sources_non_forked/ale/ale_linters/d/dmd.vim +++ b/sources_non_forked/ale/ale_linters/d/dmd.vim @@ -1,64 +1,106 @@ " Author: w0rp " Description: "dmd for D files" -function! ale_linters#d#dmd#GetDUBCommand(buffer) abort +function! s:GetDUBCommand(buffer) abort " If we can't run dub, then skip this command. - if !executable('dub') + if executable('dub') " Returning an empty string skips to the DMD command. - return '' + let l:config = ale#d#FindDUBConfig(a:buffer) + + " To support older dub versions, we just change the directory to the + " directory where we found the dub config, and then run `dub describe` + " from that directory. + if !empty(l:config) + return [fnamemodify(l:config, ':h'), 'dub describe --data-list + \ --data=import-paths + \ --data=string-import-paths + \ --data=versions + \ --data=debug-versions + \'] + endif endif - let l:dub_file = ale#d#FindDUBConfig(a:buffer) - - if empty(l:dub_file) - return '' - endif - - " To support older dub versions, we just change the directory to - " the directory where we found the dub config, and then run `dub describe` - " from that directory. - return 'cd ' . ale#Escape(fnamemodify(l:dub_file, ':h')) - \ . ' && dub describe --import-paths' + return ['', ''] endfunction function! ale_linters#d#dmd#RunDUBCommand(buffer) abort - let l:command = ale_linters#d#dmd#GetDUBCommand(a:buffer) + let [l:cwd, l:command] = s:GetDUBCommand(a:buffer) if empty(l:command) " If we can't run DUB, just run DMD. return ale_linters#d#dmd#DMDCommand(a:buffer, [], {}) endif - return ale#command#Run(a:buffer, l:command, function('ale_linters#d#dmd#DMDCommand')) + return ale#command#Run( + \ a:buffer, + \ l:command, + \ function('ale_linters#d#dmd#DMDCommand'), + \ {'cwd': l:cwd}, + \) endfunction function! ale_linters#d#dmd#DMDCommand(buffer, dub_output, meta) abort let l:import_list = [] + let l:str_import_list = [] + let l:versions_list = [] + let l:deb_versions_list = [] + let l:list_ind = 1 + let l:seen_line = 0 - " Build a list of import paths generated from DUB, if available. + " Build a list of options generated from DUB, if available. + " DUB output each path or version on a single line. + " Each list is separated by a blank line. + " Empty list are represented by a blank line (followed and/or + " preceded by a separation blank line) for l:line in a:dub_output + " line still has end of line char on windows + let l:line = substitute(l:line, '[\r\n]*$', '', '') + if !empty(l:line) - " The arguments must be '-Ifilename', not '-I filename' - call add(l:import_list, '-I' . ale#Escape(l:line)) + if l:list_ind == 1 + call add(l:import_list, '-I' . ale#Escape(l:line)) + elseif l:list_ind == 2 + call add(l:str_import_list, '-J' . ale#Escape(l:line)) + elseif l:list_ind == 3 + call add(l:versions_list, '-version=' . ale#Escape(l:line)) + elseif l:list_ind == 4 + call add(l:deb_versions_list, '-debug=' . ale#Escape(l:line)) + endif + + let l:seen_line = 1 + elseif !l:seen_line + " if list is empty must skip one empty line + let l:seen_line = 1 + else + let l:seen_line = 0 + let l:list_ind += 1 endif endfor - return 'dmd '. join(l:import_list) . ' -o- -wi -vcolumns -c %t' + return 'dmd ' . join(l:import_list) . ' ' . + \ join(l:str_import_list) . ' ' . + \ join(l:versions_list) . ' ' . + \ join(l:deb_versions_list) . ' -o- -wi -vcolumns -c %t' endfunction function! ale_linters#d#dmd#Handle(buffer, lines) abort " Matches patterns lines like the following: " /tmp/tmp.qclsa7qLP7/file.d(1): Error: function declaration without return type. (Note that constructors are always named 'this') " /tmp/tmp.G1L5xIizvB.d(8,8): Error: module weak_reference is in file 'dstruct/weak_reference.d' which cannot be read - let l:pattern = '^[^(]\+(\([0-9]\+\)\,\?\([0-9]*\)): \([^:]\+\): \(.\+\)' + let l:pattern = '\v^(\f+)\((\d+)(,(\d+))?\): (\w+): (.+)$' let l:output = [] + let l:dir = expand('#' . a:buffer . ':p:h') for l:match in ale#util#GetMatches(a:lines, l:pattern) + " If dmd was invoked with relative path, match[1] is relative, otherwise it is absolute. + " As we invoke dmd with the buffer path (in /tmp), this will generally be absolute already + let l:fname = ale#path#GetAbsPath(l:dir, l:match[1]) call add(l:output, { - \ 'lnum': l:match[1], - \ 'col': l:match[2], - \ 'type': l:match[3] is# 'Warning' ? 'W' : 'E', - \ 'text': l:match[4], + \ 'filename': l:fname, + \ 'lnum': l:match[2], + \ 'col': l:match[4], + \ 'type': l:match[5] is# 'Warning' || l:match[5] is# 'Deprecation' ? 'W' : 'E', + \ 'text': l:match[6], \}) endfor diff --git a/sources_non_forked/ale/ale_linters/dafny/dafny.vim b/sources_non_forked/ale/ale_linters/dafny/dafny.vim index b5b90675..2a9f761a 100644 --- a/sources_non_forked/ale/ale_linters/dafny/dafny.vim +++ b/sources_non_forked/ale/ale_linters/dafny/dafny.vim @@ -6,7 +6,7 @@ function! ale_linters#dafny#dafny#Handle(buffer, lines) abort for l:match in ale#util#GetMatches(a:lines, l:pattern) call add(l:output, { - \ 'bufnr': a:buffer, + \ 'filename': l:match[1], \ 'col': l:match[3] + 0, \ 'lnum': l:match[2] + 0, \ 'text': l:match[5], @@ -14,13 +14,28 @@ function! ale_linters#dafny#dafny#Handle(buffer, lines) abort \ }) endfor + for l:match in ale#util#GetMatches(a:lines, '\v(.*)\((\d+),(\d+)\): (Verification of .{-} timed out after \d+ seconds)') + call add(l:output, { + \ 'filename': l:match[1], + \ 'col': l:match[3] + 0, + \ 'lnum': l:match[2] + 0, + \ 'text': l:match[4], + \ 'type': 'E', + \ }) + endfor + return l:output endfunction +function! ale_linters#dafny#dafny#GetCommand(buffer) abort + return printf('dafny %%s /compile:0 /timeLimit:%d', ale#Var(a:buffer, 'dafny_dafny_timelimit')) +endfunction + +call ale#Set('dafny_dafny_timelimit', 10) call ale#linter#Define('dafny', { \ 'name': 'dafny', \ 'executable': 'dafny', -\ 'command': 'dafny %s /compile:0', +\ 'command': function('ale_linters#dafny#dafny#GetCommand'), \ 'callback': 'ale_linters#dafny#dafny#Handle', \ 'lint_file': 1, \ }) diff --git a/sources_non_forked/ale/ale_linters/dart/analysis_server.vim b/sources_non_forked/ale/ale_linters/dart/analysis_server.vim new file mode 100644 index 00000000..a6870da9 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/dart/analysis_server.vim @@ -0,0 +1,29 @@ +" Author: Nelson Yeung +" Description: Check Dart files with dart analysis server LSP + +call ale#Set('dart_analysis_server_executable', 'dart') + +function! ale_linters#dart#analysis_server#GetProjectRoot(buffer) abort + " Note: pub only looks for pubspec.yaml, there's no point in adding + " support for pubspec.yml + let l:pubspec = ale#path#FindNearestFile(a:buffer, 'pubspec.yaml') + + return !empty(l:pubspec) ? fnamemodify(l:pubspec, ':h:h') : '.' +endfunction + +function! ale_linters#dart#analysis_server#GetCommand(buffer) abort + let l:executable = ale#Var(a:buffer, 'dart_analysis_server_executable') + let l:dart = resolve(exepath(l:executable)) + + return '%e ' + \ . fnamemodify(l:dart, ':h') . '/snapshots/analysis_server.dart.snapshot' + \ . ' --lsp' +endfunction + +call ale#linter#Define('dart', { +\ 'name': 'analysis_server', +\ 'lsp': 'stdio', +\ 'executable': {b -> ale#Var(b, 'dart_analysis_server_executable')}, +\ 'command': function('ale_linters#dart#analysis_server#GetCommand'), +\ 'project_root': function('ale_linters#dart#analysis_server#GetProjectRoot'), +\}) diff --git a/sources_non_forked/ale/ale_linters/dart/dart_analyze.vim b/sources_non_forked/ale/ale_linters/dart/dart_analyze.vim new file mode 100644 index 00000000..a00162d8 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/dart/dart_analyze.vim @@ -0,0 +1,28 @@ +" Author: ghsang +" Description: Check Dart files with dart analyze + +call ale#Set('dart_analyze_executable', 'dart') + +function! ale_linters#dart#dart_analyze#Handle(buffer, lines) abort + let l:pattern = '\v^ ([a-z]+) - (.+):(\d+):(\d+) - (.+) - (.+)$' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + call add(l:output, { + \ 'type': l:match[1] is# 'error' ? 'E' : 'W', + \ 'text': l:match[6] . ': ' . l:match[5], + \ 'lnum': str2nr(l:match[3]), + \ 'col': str2nr(l:match[4]), + \}) + endfor + + return l:output +endfunction + +call ale#linter#Define('dart', { +\ 'name': 'dart_analyze', +\ 'executable': {b -> ale#Var(b, 'dart_analyze_executable')}, +\ 'command': '%e analyze %s', +\ 'callback': 'ale_linters#dart#dart_analyze#Handle', +\ 'lint_file': 1, +\}) diff --git a/sources_non_forked/ale/ale_linters/desktop/desktop_file_validate.vim b/sources_non_forked/ale/ale_linters/desktop/desktop_file_validate.vim new file mode 100644 index 00000000..5a97d315 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/desktop/desktop_file_validate.vim @@ -0,0 +1,31 @@ +call ale#Set('desktop_desktop_file_validate_options', '') + +" Example matches for pattern: +" +" foo.desktop: warning: key "TerminalOptions" in group ... +" foo.desktop: error: action "new-private-window" is defined, ... +let s:pattern = '\v^(.+): ([a-z]+): (.+)$' + +function! ale_linters#desktop#desktop_file_validate#Handle(buffer, lines) abort + " The error format doesn't specify lines, so we can just put all of the + " errors on line 1. + return ale#util#MapMatches(a:lines, s:pattern, {match -> { + \ 'lnum': 1, + \ 'col': 1, + \ 'type': match[2] is? 'error' ? 'E' : 'W', + \ 'text': match[3], + \}}) +endfunction + +call ale#linter#Define('desktop', { +\ 'name': 'desktop_file_validate', +\ 'aliases': ['desktop-file-validate'], +\ 'executable': 'desktop-file-validate', +\ 'command': {b -> +\ '%e' +\ . ale#Pad(ale#Var(b, 'desktop_desktop_file_validate_options')) +\ . ' %t' +\ }, +\ 'callback': 'ale_linters#desktop#desktop_file_validate#Handle', +\ 'output_stream': 'both', +\}) diff --git a/sources_non_forked/ale/ale_linters/dockerfile/hadolint.vim b/sources_non_forked/ale/ale_linters/dockerfile/hadolint.vim index e57cd76d..45b03aed 100644 --- a/sources_non_forked/ale/ale_linters/dockerfile/hadolint.vim +++ b/sources_non_forked/ale/ale_linters/dockerfile/hadolint.vim @@ -7,9 +7,9 @@ call ale#Set('dockerfile_hadolint_docker_image', 'hadolint/hadolint') function! ale_linters#dockerfile#hadolint#Handle(buffer, lines) abort " Matches patterns line the following: " - " /dev/stdin:19 DL3001 Pipe chain should start with a raw value. + " -:19 DL3001 warning: Pipe chain should start with a raw value. " /dev/stdin:19:3 unexpected thing - let l:pattern = '\v^/dev/stdin:(\d+):?(\d+)? ((DL|SC)(\d+) )?(.+)$' + let l:pattern = '\v^%(/dev/stdin|-):(\d+):?(\d+)? ((DL|SC)(\d+) )?((.+)?: )?(.+)$' let l:output = [] for l:match in ale#util#GetMatches(a:lines, l:pattern) @@ -24,10 +24,22 @@ function! ale_linters#dockerfile#hadolint#Handle(buffer, lines) abort let l:colnum = l:match[2] + 0 endif - let l:type = 'W' - let l:text = l:match[6] - let l:detail = l:match[6] + " Shellcheck knows a 'style' severity - pin it to info level as well. + if l:match[7] is# 'style' + let l:type = 'I' + elseif l:match[7] is# 'info' + let l:type = 'I' + elseif l:match[7] is# 'warning' + let l:type = 'W' + else + let l:type = 'E' + endif + + let l:text = l:match[8] + let l:detail = l:match[8] let l:domain = 'https://github.com/hadolint/hadolint/wiki/' + let l:code = '' + let l:link = '' if l:match[4] is# 'SC' let l:domain = 'https://github.com/koalaman/shellcheck/wiki/' @@ -36,9 +48,11 @@ function! ale_linters#dockerfile#hadolint#Handle(buffer, lines) abort if l:match[5] isnot# '' let l:code = l:match[4] . l:match[5] let l:link = ' ( ' . l:domain . l:code . ' )' + let l:text = l:code . ': ' . l:detail let l:detail = l:code . l:link . "\n\n" . l:detail else let l:type = 'E' + let l:detail = 'hadolint could not parse the file because of a syntax error.' endif call add(l:output, { @@ -82,12 +96,15 @@ endfunction function! ale_linters#dockerfile#hadolint#GetCommand(buffer) abort let l:command = ale_linters#dockerfile#hadolint#GetExecutable(a:buffer) + let l:opts = '--no-color -' if l:command is# 'docker' - return 'docker run --rm -i ' . ale#Var(a:buffer, 'dockerfile_hadolint_docker_image') + return printf('docker run --rm -i %s hadolint %s', + \ ale#Var(a:buffer, 'dockerfile_hadolint_docker_image'), + \ l:opts) endif - return 'hadolint -' + return 'hadolint ' . l:opts endfunction diff --git a/sources_non_forked/ale/ale_linters/elixir/credo.vim b/sources_non_forked/ale/ale_linters/elixir/credo.vim index 7c298502..d6a861f4 100644 --- a/sources_non_forked/ale/ale_linters/elixir/credo.vim +++ b/sources_non_forked/ale/ale_linters/elixir/credo.vim @@ -45,19 +45,27 @@ function! ale_linters#elixir#credo#GetMode() abort endif endfunction -function! ale_linters#elixir#credo#GetCommand(buffer) abort - let l:project_root = ale#handlers#elixir#FindMixUmbrellaRoot(a:buffer) - let l:mode = ale_linters#elixir#credo#GetMode() +function! ale_linters#elixir#credo#GetConfigFile() abort + let l:config_file = get(g:, 'ale_elixir_credo_config_file', '') - return ale#path#CdString(l:project_root) - \ . 'mix help credo && ' + if empty(l:config_file) + return '' + endif + + return ' --config-file ' . l:config_file +endfunction + +function! ale_linters#elixir#credo#GetCommand(buffer) abort + return 'mix help credo && ' \ . 'mix credo ' . ale_linters#elixir#credo#GetMode() + \ . ale_linters#elixir#credo#GetConfigFile() \ . ' --format=flycheck --read-from-stdin %s' endfunction call ale#linter#Define('elixir', { \ 'name': 'credo', \ 'executable': 'mix', +\ 'cwd': function('ale#handlers#elixir#FindMixUmbrellaRoot'), \ 'command': function('ale_linters#elixir#credo#GetCommand'), \ 'callback': 'ale_linters#elixir#credo#Handle', \}) diff --git a/sources_non_forked/ale/ale_linters/elixir/dialyxir.vim b/sources_non_forked/ale/ale_linters/elixir/dialyxir.vim index c7da7757..9b8a5cda 100644 --- a/sources_non_forked/ale/ale_linters/elixir/dialyxir.vim +++ b/sources_non_forked/ale/ale_linters/elixir/dialyxir.vim @@ -25,17 +25,10 @@ function! ale_linters#elixir#dialyxir#Handle(buffer, lines) abort return l:output endfunction -function! ale_linters#elixir#dialyxir#GetCommand(buffer) abort - let l:project_root = ale#handlers#elixir#FindMixProjectRoot(a:buffer) - - return ale#path#CdString(l:project_root) - \ . ' mix help dialyzer && mix dialyzer' -endfunction - call ale#linter#Define('elixir', { \ 'name': 'dialyxir', \ 'executable': 'mix', -\ 'command': function('ale_linters#elixir#dialyxir#GetCommand'), +\ 'cwd': function('ale#handlers#elixir#FindMixProjectRoot'), +\ 'command': 'mix help dialyzer && mix dialyzer', \ 'callback': 'ale_linters#elixir#dialyxir#Handle', \}) - diff --git a/sources_non_forked/ale/ale_linters/elixir/dogma.vim b/sources_non_forked/ale/ale_linters/elixir/dogma.vim index 1c721158..28e7f420 100644 --- a/sources_non_forked/ale/ale_linters/elixir/dogma.vim +++ b/sources_non_forked/ale/ale_linters/elixir/dogma.vim @@ -29,17 +29,11 @@ function! ale_linters#elixir#dogma#Handle(buffer, lines) abort return l:output endfunction -function! ale_linters#elixir#dogma#GetCommand(buffer) abort - let l:project_root = ale#handlers#elixir#FindMixProjectRoot(a:buffer) - - return ale#path#CdString(l:project_root) - \ . ' mix help dogma && mix dogma %s --format=flycheck' -endfunction - call ale#linter#Define('elixir', { \ 'name': 'dogma', \ 'executable': 'mix', -\ 'command': function('ale_linters#elixir#dogma#GetCommand'), +\ 'cwd': function('ale#handlers#elixir#FindMixProjectRoot'), +\ 'command': 'mix help dogma && mix dogma %s --format=flycheck', \ 'lint_file': 1, \ 'callback': 'ale_linters#elixir#dogma#Handle', \}) diff --git a/sources_non_forked/ale/ale_linters/elixir/mix.vim b/sources_non_forked/ale/ale_linters/elixir/mix.vim index abf5d0aa..948c6d36 100644 --- a/sources_non_forked/ale/ale_linters/elixir/mix.vim +++ b/sources_non_forked/ale/ale_linters/elixir/mix.vim @@ -30,22 +30,15 @@ function! ale_linters#elixir#mix#Handle(buffer, lines) abort endfunction function! ale_linters#elixir#mix#GetCommand(buffer) abort - let l:project_root = ale#handlers#elixir#FindMixProjectRoot(a:buffer) - let l:temp_dir = ale#command#CreateDirectory(a:buffer) - let l:mix_build_path = has('win32') - \ ? 'set MIX_BUILD_PATH=' . ale#Escape(l:temp_dir) . ' &&' - \ : 'MIX_BUILD_PATH=' . ale#Escape(l:temp_dir) - - return ale#path#CdString(l:project_root) - \ . l:mix_build_path - \ . ' mix compile %s' + return ale#Env('MIX_BUILD_PATH', l:temp_dir) . 'mix compile %s' endfunction call ale#linter#Define('elixir', { \ 'name': 'mix', \ 'executable': 'mix', +\ 'cwd': function('ale#handlers#elixir#FindMixProjectRoot'), \ 'command': function('ale_linters#elixir#mix#GetCommand'), \ 'callback': 'ale_linters#elixir#mix#Handle', \ 'lint_file': 1, diff --git a/sources_non_forked/ale/ale_linters/elm/elm_ls.vim b/sources_non_forked/ale/ale_linters/elm/elm_ls.vim index 2fa71adb..a02dbf42 100644 --- a/sources_non_forked/ale/ale_linters/elm/elm_ls.vim +++ b/sources_non_forked/ale/ale_linters/elm/elm_ls.vim @@ -28,7 +28,7 @@ endfunction call ale#linter#Define('elm', { \ 'name': 'elm_ls', \ 'lsp': 'stdio', -\ 'executable': {b -> ale#node#FindExecutable(b, 'elm_ls', [ +\ 'executable': {b -> ale#path#FindExecutable(b, 'elm_ls', [ \ 'node_modules/.bin/elm-language-server', \ 'node_modules/.bin/elm-lsp', \ 'elm-lsp' diff --git a/sources_non_forked/ale/ale_linters/elm/make.vim b/sources_non_forked/ale/ale_linters/elm/make.vim index 6b93257f..a7f9ea7b 100644 --- a/sources_non_forked/ale/ale_linters/elm/make.vim +++ b/sources_non_forked/ale/ale_linters/elm/make.vim @@ -186,24 +186,23 @@ function! ale_linters#elm#make#IsTest(buffer) abort endif endfunction +function! ale_linters#elm#make#GetCwd(buffer) abort + let l:root_dir = ale_linters#elm#make#GetRootDir(a:buffer) + + return !empty(l:root_dir) ? l:root_dir : '' +endfunction + " Return the command to execute the linter in the projects directory. " If it doesn't, then this will fail when imports are needed. function! ale_linters#elm#make#GetCommand(buffer) abort let l:executable = ale_linters#elm#make#GetExecutable(a:buffer) - let l:root_dir = ale_linters#elm#make#GetRootDir(a:buffer) let l:is_v19 = ale_linters#elm#make#IsVersionGte19(a:buffer) let l:is_using_elm_test = l:executable =~# 'elm-test$' - if empty(l:root_dir) - let l:dir_set_cmd = '' - else - let l:dir_set_cmd = 'cd ' . ale#Escape(l:root_dir) . ' && ' - endif - " elm-test needs to know the path of elm-make if elm isn't installed globally. " https://github.com/rtfeldman/node-test-runner/blob/57728f10668f2d2ab3179e7e3208bcfa9a1f19aa/README.md#--compiler if l:is_v19 && l:is_using_elm_test - let l:elm_make_executable = ale#node#FindExecutable(a:buffer, 'elm_make', ['node_modules/.bin/elm']) + let l:elm_make_executable = ale#path#FindExecutable(a:buffer, 'elm_make', ['node_modules/.bin/elm']) let l:elm_test_compiler_flag = ' --compiler ' . l:elm_make_executable . ' ' else let l:elm_test_compiler_flag = ' ' @@ -213,7 +212,9 @@ function! ale_linters#elm#make#GetCommand(buffer) abort " a sort of flag to tell the compiler not to generate an output file, " which is why this is hard coded here. " Source: https://github.com/elm-lang/elm-compiler/blob/19d5a769b30ec0b2fc4475985abb4cd94cd1d6c3/builder/src/Generate/Output.hs#L253 - return l:dir_set_cmd . '%e make --report=json --output=/dev/null' . l:elm_test_compiler_flag . '%t' + return '%e make --report=json --output=/dev/null' + \ . l:elm_test_compiler_flag + \ . '%t' endfunction function! ale_linters#elm#make#GetExecutable(buffer) abort @@ -221,13 +222,13 @@ function! ale_linters#elm#make#GetExecutable(buffer) abort let l:is_v19 = ale_linters#elm#make#IsVersionGte19(a:buffer) if l:is_test && l:is_v19 - return ale#node#FindExecutable( + return ale#path#FindExecutable( \ a:buffer, \ 'elm_make', \ ['node_modules/.bin/elm-test', 'node_modules/.bin/elm'] \) else - return ale#node#FindExecutable(a:buffer, 'elm_make', ['node_modules/.bin/elm']) + return ale#path#FindExecutable(a:buffer, 'elm_make', ['node_modules/.bin/elm']) endif endfunction @@ -235,6 +236,7 @@ call ale#linter#Define('elm', { \ 'name': 'make', \ 'executable': function('ale_linters#elm#make#GetExecutable'), \ 'output_stream': 'both', +\ 'cwd': function('ale_linters#elm#make#GetCwd'), \ 'command': function('ale_linters#elm#make#GetCommand'), \ 'callback': 'ale_linters#elm#make#Handle' \}) diff --git a/sources_non_forked/ale/ale_linters/erlang/dialyzer.vim b/sources_non_forked/ale/ale_linters/erlang/dialyzer.vim index 395647a0..a97c9520 100644 --- a/sources_non_forked/ale/ale_linters/erlang/dialyzer.vim +++ b/sources_non_forked/ale/ale_linters/erlang/dialyzer.vim @@ -3,6 +3,11 @@ let g:ale_erlang_dialyzer_executable = \ get(g:, 'ale_erlang_dialyzer_executable', 'dialyzer') +let g:ale_erlang_dialyzer_options = +\ get(g:, 'ale_erlang_dialyzer_options', '-Wunmatched_returns' +\ . ' -Werror_handling' +\ . ' -Wrace_conditions' +\ . ' -Wunderspecs') let g:ale_erlang_dialyzer_plt_file = \ get(g:, 'ale_erlang_dialyzer_plt_file', '') let g:ale_erlang_dialyzer_rebar3_profile = @@ -47,13 +52,12 @@ function! ale_linters#erlang#dialyzer#GetExecutable(buffer) abort endfunction function! ale_linters#erlang#dialyzer#GetCommand(buffer) abort + let l:options = ale#Var(a:buffer, 'erlang_dialyzer_options') + let l:command = ale#Escape(ale_linters#erlang#dialyzer#GetExecutable(a:buffer)) \ . ' -n' \ . ' --plt ' . ale#Escape(ale_linters#erlang#dialyzer#GetPlt(a:buffer)) - \ . ' -Wunmatched_returns' - \ . ' -Werror_handling' - \ . ' -Wrace_conditions' - \ . ' -Wunderspecs' + \ . ' ' . l:options \ . ' %s' return l:command diff --git a/sources_non_forked/ale/ale_linters/erlang/erlc.vim b/sources_non_forked/ale/ale_linters/erlang/erlc.vim index a83bacc3..0c67a73f 100644 --- a/sources_non_forked/ale/ale_linters/erlang/erlc.vim +++ b/sources_non_forked/ale/ale_linters/erlang/erlc.vim @@ -1,14 +1,22 @@ " Author: Magnus Ottenklinger - https://github.com/evnu +let g:ale_erlang_erlc_executable = get(g:, 'ale_erlang_erlc_executable', 'erlc') let g:ale_erlang_erlc_options = get(g:, 'ale_erlang_erlc_options', '') +function! ale_linters#erlang#erlc#GetExecutable(buffer) abort + return ale#Var(a:buffer, 'erlang_erlc_executable') +endfunction + function! ale_linters#erlang#erlc#GetCommand(buffer) abort let l:output_file = ale#util#Tempname() call ale#command#ManageFile(a:buffer, l:output_file) - return 'erlc -o ' . ale#Escape(l:output_file) - \ . ' ' . ale#Var(a:buffer, 'erlang_erlc_options') - \ . ' %t' + let l:command = ale#Escape(ale_linters#erlang#erlc#GetExecutable(a:buffer)) + \ . ' -o ' . ale#Escape(l:output_file) + \ . ' ' . ale#Var(a:buffer, 'erlang_erlc_options') + \ . ' %t' + + return l:command endfunction function! ale_linters#erlang#erlc#Handle(buffer, lines) abort @@ -17,7 +25,7 @@ function! ale_linters#erlang#erlc#Handle(buffer, lines) abort " error.erl:4: variable 'B' is unbound " error.erl:3: Warning: function main/0 is unused " error.erl:4: Warning: variable 'A' is unused - let l:pattern = '\v^([a-zA-Z]?:?[^:]+):(\d+): (Warning: )?(.+)$' + let l:pattern = '\v^([a-zA-Z]?:?[^:]+):(\d+):(\d+:)? (Warning: )?(.+)$' " parse_transforms are a special case. The error message does not indicate a location: " error.erl: undefined parse transform 'some_parse_transform' @@ -57,8 +65,8 @@ function! ale_linters#erlang#erlc#Handle(buffer, lines) abort endif let l:line = l:match[2] - let l:warning_or_text = l:match[3] - let l:text = l:match[4] + let l:warning_or_text = l:match[4] + let l:text = l:match[5] " If this file is a header .hrl, ignore the following expected messages: " - 'no module definition' @@ -90,7 +98,7 @@ endfunction call ale#linter#Define('erlang', { \ 'name': 'erlc', -\ 'executable': 'erlc', +\ 'executable': function('ale_linters#erlang#erlc#GetExecutable'), \ 'command': function('ale_linters#erlang#erlc#GetCommand'), \ 'callback': 'ale_linters#erlang#erlc#Handle', \}) diff --git a/sources_non_forked/ale/ale_linters/go/gobuild.vim b/sources_non_forked/ale/ale_linters/go/gobuild.vim index 1dfb6daa..5210c5a8 100644 --- a/sources_non_forked/ale/ale_linters/go/gobuild.vim +++ b/sources_non_forked/ale/ale_linters/go/gobuild.vim @@ -10,8 +10,7 @@ function! ale_linters#go#gobuild#GetCommand(buffer) abort let l:options = ale#Var(a:buffer, 'go_gobuild_options') " Run go test in local directory with relative path - return ale#path#BufferCdString(a:buffer) - \ . ale#go#EnvString(a:buffer) + return ale#go#EnvString(a:buffer) \ . ale#Var(a:buffer, 'go_go_executable') . ' test' \ . (!empty(l:options) ? ' ' . l:options : '') \ . ' -c -o /dev/null ./' @@ -50,6 +49,7 @@ call ale#linter#Define('go', { \ 'name': 'gobuild', \ 'aliases': ['go build'], \ 'executable': {b -> ale#Var(b, 'go_go_executable')}, +\ 'cwd': '%s:h', \ 'command': function('ale_linters#go#gobuild#GetCommand'), \ 'output_stream': 'stderr', \ 'callback': 'ale_linters#go#gobuild#Handler', diff --git a/sources_non_forked/ale/ale_linters/go/golangci_lint.vim b/sources_non_forked/ale/ale_linters/go/golangci_lint.vim index dd0e975a..2c4b1a4f 100644 --- a/sources_non_forked/ale/ale_linters/go/golangci_lint.vim +++ b/sources_non_forked/ale/ale_linters/go/golangci_lint.vim @@ -12,14 +12,12 @@ function! ale_linters#go#golangci_lint#GetCommand(buffer) abort if l:lint_package - return ale#path#BufferCdString(a:buffer) - \ . ale#go#EnvString(a:buffer) + return ale#go#EnvString(a:buffer) \ . '%e run ' \ . l:options endif - return ale#path#BufferCdString(a:buffer) - \ . ale#go#EnvString(a:buffer) + return ale#go#EnvString(a:buffer) \ . '%e run ' \ . ale#Escape(l:filename) \ . ' ' . l:options @@ -53,6 +51,7 @@ endfunction call ale#linter#Define('go', { \ 'name': 'golangci-lint', \ 'executable': {b -> ale#Var(b, 'go_golangci_lint_executable')}, +\ 'cwd': '%s:h', \ 'command': function('ale_linters#go#golangci_lint#GetCommand'), \ 'callback': 'ale_linters#go#golangci_lint#Handler', \ 'lint_file': 1, diff --git a/sources_non_forked/ale/ale_linters/go/gometalinter.vim b/sources_non_forked/ale/ale_linters/go/gometalinter.vim index eed9550a..ac33a9f3 100644 --- a/sources_non_forked/ale/ale_linters/go/gometalinter.vim +++ b/sources_non_forked/ale/ale_linters/go/gometalinter.vim @@ -13,14 +13,12 @@ function! ale_linters#go#gometalinter#GetCommand(buffer) abort " BufferCdString is used so that we can be sure the paths output from gometalinter can " be calculated to absolute paths in the Handler if l:lint_package - return ale#path#BufferCdString(a:buffer) - \ . ale#go#EnvString(a:buffer) + return ale#go#EnvString(a:buffer) \ . '%e' \ . (!empty(l:options) ? ' ' . l:options : '') . ' .' endif - return ale#path#BufferCdString(a:buffer) - \ . ale#go#EnvString(a:buffer) + return ale#go#EnvString(a:buffer) \ . '%e' \ . ' --include=' . ale#Escape(ale#util#EscapePCRE(l:filename)) \ . (!empty(l:options) ? ' ' . l:options : '') . ' .' @@ -53,6 +51,7 @@ endfunction call ale#linter#Define('go', { \ 'name': 'gometalinter', \ 'executable': {b -> ale#Var(b, 'go_gometalinter_executable')}, +\ 'cwd': '%s:h', \ 'command': function('ale_linters#go#gometalinter#GetCommand'), \ 'callback': 'ale_linters#go#gometalinter#Handler', \ 'lint_file': 1, diff --git a/sources_non_forked/ale/ale_linters/go/gopls.vim b/sources_non_forked/ale/ale_linters/go/gopls.vim index dcff5ec7..80909830 100644 --- a/sources_non_forked/ale/ale_linters/go/gopls.vim +++ b/sources_non_forked/ale/ale_linters/go/gopls.vim @@ -4,6 +4,8 @@ call ale#Set('go_gopls_executable', 'gopls') call ale#Set('go_gopls_options', '--mode stdio') +call ale#Set('go_gopls_init_options', {}) +call ale#Set('go_gopls_use_global', get(g:, 'ale_use_global_executables', 0)) function! ale_linters#go#gopls#GetCommand(buffer) abort return ale#go#EnvString(a:buffer) @@ -28,7 +30,10 @@ endfunction call ale#linter#Define('go', { \ 'name': 'gopls', \ 'lsp': 'stdio', -\ 'executable': {b -> ale#Var(b, 'go_gopls_executable')}, +\ 'executable': {b -> ale#path#FindExecutable(b, 'go_gopls', [ +\ ale#go#GetGoPathExecutable('bin/gopls'), +\ ])}, \ 'command': function('ale_linters#go#gopls#GetCommand'), \ 'project_root': function('ale_linters#go#gopls#FindProjectRoot'), +\ 'initialization_options': {b -> ale#Var(b, 'go_gopls_init_options')}, \}) diff --git a/sources_non_forked/ale/ale_linters/go/gosimple.vim b/sources_non_forked/ale/ale_linters/go/gosimple.vim index ad52c621..490d15a9 100644 --- a/sources_non_forked/ale/ale_linters/go/gosimple.vim +++ b/sources_non_forked/ale/ale_linters/go/gosimple.vim @@ -1,15 +1,11 @@ " Author: Ben Reedy " Description: gosimple for Go files -function! ale_linters#go#gosimple#GetCommand(buffer) abort - return ale#path#BufferCdString(a:buffer) . ' ' - \ . ale#go#EnvString(a:buffer) . 'gosimple .' -endfunction - call ale#linter#Define('go', { \ 'name': 'gosimple', \ 'executable': 'gosimple', -\ 'command': function('ale_linters#go#gosimple#GetCommand'), +\ 'cwd': '%s:h', +\ 'command': {b -> ale#go#EnvString(b) . 'gosimple .'}, \ 'callback': 'ale#handlers#go#Handler', \ 'output_stream': 'both', \ 'lint_file': 1, diff --git a/sources_non_forked/ale/ale_linters/go/gotype.vim b/sources_non_forked/ale/ale_linters/go/gotype.vim index 6a5149ca..8fd6df27 100644 --- a/sources_non_forked/ale/ale_linters/go/gotype.vim +++ b/sources_non_forked/ale/ale_linters/go/gotype.vim @@ -1,19 +1,23 @@ " Author: Jelte Fennema " Description: gotype for Go files -function! ale_linters#go#gotype#GetCommand(buffer) abort +function! ale_linters#go#gotype#GetExecutable(buffer) abort if expand('#' . a:buffer . ':p') =~# '_test\.go$' return '' endif - return ale#path#BufferCdString(a:buffer) . ' ' - \ . ale#go#EnvString(a:buffer) . 'gotype -e .' + return 'gotype' +endfunction + +function! ale_linters#go#gotype#GetCommand(buffer) abort + return ale#go#EnvString(a:buffer) . 'gotype -e .' endfunction call ale#linter#Define('go', { \ 'name': 'gotype', \ 'output_stream': 'stderr', -\ 'executable': 'gotype', +\ 'executable': function('ale_linters#go#gotype#GetExecutable'), +\ 'cwd': '%s:h', \ 'command': function('ale_linters#go#gotype#GetCommand'), \ 'callback': 'ale#handlers#go#Handler', \ 'lint_file': 1, diff --git a/sources_non_forked/ale/ale_linters/go/govet.vim b/sources_non_forked/ale/ale_linters/go/govet.vim index dddafe17..5da8261c 100644 --- a/sources_non_forked/ale/ale_linters/go/govet.vim +++ b/sources_non_forked/ale/ale_linters/go/govet.vim @@ -10,8 +10,7 @@ call ale#Set('go_govet_options', '') function! ale_linters#go#govet#GetCommand(buffer) abort let l:options = ale#Var(a:buffer, 'go_govet_options') - return ale#path#BufferCdString(a:buffer) . ' ' - \ . ale#go#EnvString(a:buffer) + return ale#go#EnvString(a:buffer) \ . ale#Var(a:buffer, 'go_go_executable') . ' vet ' \ . (!empty(l:options) ? ' ' . l:options : '') \ . ' .' @@ -22,6 +21,7 @@ call ale#linter#Define('go', { \ 'aliases': ['go vet'], \ 'output_stream': 'stderr', \ 'executable': {b -> ale#Var(b, 'go_go_executable')}, +\ 'cwd': '%s:h', \ 'command': function('ale_linters#go#govet#GetCommand'), \ 'callback': 'ale#handlers#go#Handler', \ 'lint_file': 1, diff --git a/sources_non_forked/ale/ale_linters/go/staticcheck.vim b/sources_non_forked/ale/ale_linters/go/staticcheck.vim index ed40c6c2..36622440 100644 --- a/sources_non_forked/ale/ale_linters/go/staticcheck.vim +++ b/sources_non_forked/ale/ale_linters/go/staticcheck.vim @@ -1,32 +1,32 @@ " Author: Ben Reedy " Description: staticcheck for Go files +call ale#Set('go_staticcheck_executable', 'staticcheck') call ale#Set('go_staticcheck_options', '') -call ale#Set('go_staticcheck_lint_package', 0) +call ale#Set('go_staticcheck_lint_package', 1) +call ale#Set('go_staticcheck_use_global', get(g:, 'ale_use_global_executables', 0)) function! ale_linters#go#staticcheck#GetCommand(buffer) abort - let l:filename = expand('#' . a:buffer . ':t') let l:options = ale#Var(a:buffer, 'go_staticcheck_options') let l:lint_package = ale#Var(a:buffer, 'go_staticcheck_lint_package') let l:env = ale#go#EnvString(a:buffer) - " BufferCdString is used so that we can be sure the paths output from - " staticcheck can be calculated to absolute paths in the Handler if l:lint_package - return ale#path#BufferCdString(a:buffer) - \ . l:env . 'staticcheck' + return l:env . '%e' \ . (!empty(l:options) ? ' ' . l:options : '') . ' .' endif - return ale#path#BufferCdString(a:buffer) - \ . l:env . 'staticcheck' + return l:env . '%e' \ . (!empty(l:options) ? ' ' . l:options : '') - \ . ' ' . ale#Escape(l:filename) + \ . ' %s:t' endfunction call ale#linter#Define('go', { \ 'name': 'staticcheck', -\ 'executable': 'staticcheck', +\ 'executable': {b -> ale#path#FindExecutable(b, 'go_staticcheck', [ +\ ale#go#GetGoPathExecutable('bin/staticcheck'), +\ ])}, +\ 'cwd': '%s:h', \ 'command': function('ale_linters#go#staticcheck#GetCommand'), \ 'callback': 'ale#handlers#go#Handler', \ 'output_stream': 'both', diff --git a/sources_non_forked/ale/ale_linters/graphql/eslint.vim b/sources_non_forked/ale/ale_linters/graphql/eslint.vim index aed1a371..a98233e9 100644 --- a/sources_non_forked/ale/ale_linters/graphql/eslint.vim +++ b/sources_non_forked/ale/ale_linters/graphql/eslint.vim @@ -4,6 +4,7 @@ call ale#linter#Define('graphql', { \ 'name': 'eslint', \ 'executable': function('ale#handlers#eslint#GetExecutable'), +\ 'cwd': function('ale#handlers#eslint#GetCwd'), \ 'command': function('ale#handlers#eslint#GetCommand'), \ 'callback': 'ale#handlers#eslint#HandleJSON', \}) diff --git a/sources_non_forked/ale/ale_linters/graphql/gqlint.vim b/sources_non_forked/ale/ale_linters/graphql/gqlint.vim index d5029de1..6f1ca54a 100644 --- a/sources_non_forked/ale/ale_linters/graphql/gqlint.vim +++ b/sources_non_forked/ale/ale_linters/graphql/gqlint.vim @@ -1,15 +1,10 @@ " Author: Michiel Westerbeek " Description: Linter for GraphQL Schemas -function! ale_linters#graphql#gqlint#GetCommand(buffer) abort - return ale#path#BufferCdString(a:buffer) - \ . 'gqlint' - \ . ' --reporter=simple %t' -endfunction - call ale#linter#Define('graphql', { \ 'name': 'gqlint', \ 'executable': 'gqlint', -\ 'command': function('ale_linters#graphql#gqlint#GetCommand'), +\ 'cwd': '%s:h', +\ 'command': 'gqlint --reporter=simple %t', \ '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 bd4d1d31..8362bb1c 100644 --- a/sources_non_forked/ale/ale_linters/handlebars/embertemplatelint.vim +++ b/sources_non_forked/ale/ale_linters/handlebars/embertemplatelint.vim @@ -5,7 +5,7 @@ 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', [ + return ale#path#FindExecutable(a:buffer, 'handlebars_embertemplatelint', [ \ 'node_modules/.bin/ember-template-lint', \]) endfunction diff --git a/sources_non_forked/ale/ale_linters/haskell/cabal_ghc.vim b/sources_non_forked/ale/ale_linters/haskell/cabal_ghc.vim index f3f248f5..1bb31ebb 100644 --- a/sources_non_forked/ale/ale_linters/haskell/cabal_ghc.vim +++ b/sources_non_forked/ale/ale_linters/haskell/cabal_ghc.vim @@ -4,8 +4,7 @@ call ale#Set('haskell_cabal_ghc_options', '-fno-code -v0') function! ale_linters#haskell#cabal_ghc#GetCommand(buffer) abort - return ale#path#BufferCdString(a:buffer) - \ . 'cabal exec -- ghc ' + return 'cabal exec -- ghc ' \ . ale#Var(a:buffer, 'haskell_cabal_ghc_options') \ . ' %t' endfunction @@ -15,6 +14,7 @@ call ale#linter#Define('haskell', { \ 'aliases': ['cabal-ghc'], \ 'output_stream': 'stderr', \ 'executable': 'cabal', +\ 'cwd': '%s:h', \ 'command': function('ale_linters#haskell#cabal_ghc#GetCommand'), \ 'callback': 'ale#handlers#haskell#HandleGHCFormat', \}) diff --git a/sources_non_forked/ale/ale_linters/haskell/hls.vim b/sources_non_forked/ale/ale_linters/haskell/hls.vim new file mode 100644 index 00000000..ae0556a4 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/haskell/hls.vim @@ -0,0 +1,63 @@ +" Author: Yen3 +" Description: A language server for haskell +" The file is based on hie.vim (author: Luxed +" ). It search more project root files. +" +call ale#Set('haskell_hls_executable', 'haskell-language-server-wrapper') + +function! ale_linters#haskell#hls#FindRootFile(buffer) abort + let l:serach_root_files = [ + \ 'stack.yaml', + \ 'cabal.project', + \ 'package.yaml', + \ 'hie.yaml' + \ ] + + for l:path in ale#path#Upwards(expand('#' . a:buffer . ':p:h')) + for l:root_file in l:serach_root_files + if filereadable(l:path . l:root_file) + return l:path + endif + endfor + endfor + + return '' +endfunction + +function! ale_linters#haskell#hls#GetProjectRoot(buffer) abort + " Search for the project file first + let l:project_file = ale_linters#haskell#hls#FindRootFile(a:buffer) + + " If it's empty, search for the cabal file + if empty(l:project_file) + " Search all of the paths except for the root filesystem path. + let l:paths = join( + \ ale#path#Upwards(expand('#' . a:buffer . ':p:h'))[:-2], + \ ',' + \) + let l:project_file = globpath(l:paths, '*.cabal') + endif + + " If we still can't find one, use the current file. + if empty(l:project_file) + let l:project_file = expand('#' . a:buffer . ':p') + endif + + return fnamemodify(l:project_file, ':h') +endfunction + +function! ale_linters#haskell#hls#GetCommand(buffer) abort + let l:executable = ale#Var(a:buffer, 'haskell_hls_executable') + + return ale#handlers#haskell_stack#EscapeExecutable(l:executable, + \ 'haskell-language-server-wrapper') + \ . ' --lsp' +endfunction + +call ale#linter#Define('haskell', { +\ 'name': 'hls', +\ 'lsp': 'stdio', +\ 'command': function('ale_linters#haskell#hls#GetCommand'), +\ 'executable': {b -> ale#Var(b, 'haskell_hls_executable')}, +\ 'project_root': function('ale_linters#haskell#hls#GetProjectRoot'), +\}) diff --git a/sources_non_forked/ale/ale_linters/haskell/stack_ghc.vim b/sources_non_forked/ale/ale_linters/haskell/stack_ghc.vim index c345fe43..51ecc744 100644 --- a/sources_non_forked/ale/ale_linters/haskell/stack_ghc.vim +++ b/sources_non_forked/ale/ale_linters/haskell/stack_ghc.vim @@ -4,8 +4,7 @@ call ale#Set('haskell_stack_ghc_options', '-fno-code -v0') function! ale_linters#haskell#stack_ghc#GetCommand(buffer) abort - return ale#path#BufferCdString(a:buffer) - \ . ale#handlers#haskell#GetStackExecutable(a:buffer) + return ale#handlers#haskell#GetStackExecutable(a:buffer) \ . ' ghc -- ' \ . ale#Var(a:buffer, 'haskell_stack_ghc_options') \ . ' %t' @@ -16,6 +15,7 @@ call ale#linter#Define('haskell', { \ 'aliases': ['stack-ghc'], \ 'output_stream': 'stderr', \ 'executable': function('ale#handlers#haskell#GetStackExecutable'), +\ 'cwd': '%s:h', \ 'command': function('ale_linters#haskell#stack_ghc#GetCommand'), \ 'callback': 'ale#handlers#haskell#HandleGHCFormat', \}) diff --git a/sources_non_forked/ale/ale_linters/html/angular.vim b/sources_non_forked/ale/ale_linters/html/angular.vim new file mode 100644 index 00000000..17c0a751 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/html/angular.vim @@ -0,0 +1,52 @@ +" Author: w0rp +" Description: tsserver integration for ALE + +call ale#Set('html_angular_executable', 'ngserver') +call ale#Set('html_angular_use_global', get(g:, 'ale_use_global_executables', 0)) + +function! ale_linters#html#angular#GetProjectRoot(buffer) abort + return ale#path#Dirname( + \ ale#path#FindNearestDirectory(a:buffer, 'node_modules') + \) +endfunction + +function! ale_linters#html#angular#GetExecutable(buffer) abort + return ale#path#FindExecutable(a:buffer, 'html_angular', [ + \ 'node_modules/@angular/language-server/bin/ngserver', + \ 'node_modules/@angular/language-server/index.js', + \]) +endfunction + +function! ale_linters#html#angular#GetCommand(buffer) abort + let l:language_service_dir = ale#path#Simplify( + \ ale#path#FindNearestDirectory( + \ a:buffer, + \ 'node_modules/@angular/language-service' + \ ) + \) + + if empty(l:language_service_dir) + return '' + endif + + let l:language_service_dir = fnamemodify(l:language_service_dir, ':h') + let l:typescript_dir = ale#path#Simplify( + \ fnamemodify(l:language_service_dir, ':h:h') + \ . '/typescript' + \) + let l:executable = ale_linters#html#angular#GetExecutable(a:buffer) + + return ale#node#Executable(a:buffer, l:executable) + \ . ' --ngProbeLocations ' . ale#Escape(l:language_service_dir) + \ . ' --tsProbeLocations ' . ale#Escape(l:typescript_dir) + \ . ' --stdio' +endfunction + +call ale#linter#Define('html', { +\ 'name': 'angular', +\ 'aliases': ['angular-language-server'], +\ 'lsp': 'stdio', +\ 'executable': function('ale_linters#html#angular#GetExecutable'), +\ 'command': function('ale_linters#html#angular#GetCommand'), +\ 'project_root': function('ale_linters#html#angular#GetProjectRoot'), +\}) diff --git a/sources_non_forked/ale/ale_linters/html/htmlhint.vim b/sources_non_forked/ale/ale_linters/html/htmlhint.vim index 3e01f51a..25bf5137 100644 --- a/sources_non_forked/ale/ale_linters/html/htmlhint.vim +++ b/sources_non_forked/ale/ale_linters/html/htmlhint.vim @@ -24,7 +24,7 @@ endfunction call ale#linter#Define('html', { \ 'name': 'htmlhint', -\ 'executable': {b -> ale#node#FindExecutable(b, 'html_htmlhint', [ +\ 'executable': {b -> ale#path#FindExecutable(b, 'html_htmlhint', [ \ 'node_modules/.bin/htmlhint', \ ])}, \ 'command': function('ale_linters#html#htmlhint#GetCommand'), diff --git a/sources_non_forked/ale/ale_linters/html/stylelint.vim b/sources_non_forked/ale/ale_linters/html/stylelint.vim index ae8955f3..6b7aba40 100644 --- a/sources_non_forked/ale/ale_linters/html/stylelint.vim +++ b/sources_non_forked/ale/ale_linters/html/stylelint.vim @@ -5,7 +5,7 @@ call ale#Set('html_stylelint_options', '') call ale#Set('html_stylelint_use_global', 0) function! ale_linters#html#stylelint#GetExecutable(buffer) abort - return ale#node#FindExecutable(a:buffer, 'html_stylelint', [ + return ale#path#FindExecutable(a:buffer, 'html_stylelint', [ \ 'node_modules/.bin/stylelint', \]) endfunction diff --git a/sources_non_forked/ale/ale_linters/ink/ls.vim b/sources_non_forked/ale/ale_linters/ink/ls.vim index 1cc93583..00b2f323 100644 --- a/sources_non_forked/ale/ale_linters/ink/ls.vim +++ b/sources_non_forked/ale/ale_linters/ink/ls.vim @@ -6,7 +6,7 @@ call ale#Set('ink_ls_use_global', get(g:, 'ale_use_global_executables', 0)) call ale#Set('ink_ls_initialization_options', {}) function! ale_linters#ink#ls#GetExecutable(buffer) abort - return ale#node#FindExecutable(a:buffer, 'ink_ls', [ + return ale#path#FindExecutable(a:buffer, 'ink_ls', [ \ 'ink-language-server', \ 'node_modules/.bin/ink-language-server', \]) diff --git a/sources_non_forked/ale/ale_linters/inko/inko.vim b/sources_non_forked/ale/ale_linters/inko/inko.vim new file mode 100644 index 00000000..11558897 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/inko/inko.vim @@ -0,0 +1,33 @@ +" Author: Yorick Peterse +" Description: linting of Inko source code using the Inko compiler + +call ale#Set('inko_inko_executable', 'inko') + +function! ale_linters#inko#inko#GetCommand(buffer) abort + let l:include = '' + + " Include the tests source directory, but only for test files. + if expand('#' . a:buffer . ':p') =~? '\vtests[/\\]test[/\\]' + let l:test_dir = ale#path#FindNearestDirectory(a:buffer, 'tests') + + if isdirectory(l:test_dir) + let l:include = '--include ' . ale#Escape(l:test_dir) + endif + endif + + " We use %s instead of %t so the compiler determines the correct module + " names for the file being edited. Not doing so may lead to errors in + " certain cases. + return '%e build --check --format=json' + \ . ale#Pad(l:include) + \ . ' %s' +endfunction + +call ale#linter#Define('inko', { +\ 'name': 'inko', +\ 'executable': {b -> ale#Var(b, 'inko_inko_executable')}, +\ 'command': function('ale_linters#inko#inko#GetCommand'), +\ 'callback': 'ale#handlers#inko#Handle', +\ 'output_stream': 'stderr', +\ 'lint_file': 1 +\}) diff --git a/sources_non_forked/ale/ale_linters/java/checkstyle.vim b/sources_non_forked/ale/ale_linters/java/checkstyle.vim index ec7339d1..1ccbc505 100644 --- a/sources_non_forked/ale/ale_linters/java/checkstyle.vim +++ b/sources_non_forked/ale/ale_linters/java/checkstyle.vim @@ -9,11 +9,12 @@ function! ale_linters#java#checkstyle#Handle(buffer, lines) abort let l:output = [] " modern checkstyle versions - let l:pattern = '\v\[(WARN|ERROR)\] [a-zA-Z]?:?[^:]+:(\d+):(\d+)?:? (.*) \[(.+)\]$' + let l:pattern = '\v\[(WARN|ERROR)\] [a-zA-Z]?:?[^:]+:(\d+):(\d+)?:? (.*) \[(.+)\]' for l:match in ale#util#GetMatches(a:lines, l:pattern) call add(l:output, { \ 'type': l:match[1] is? 'WARN' ? 'W' : 'E', + \ 'sub_type': 'style', \ 'lnum': l:match[2] + 0, \ 'col': l:match[3] + 0, \ 'text': l:match[4], @@ -31,6 +32,7 @@ function! ale_linters#java#checkstyle#Handle(buffer, lines) abort for l:match in ale#util#GetMatches(a:lines, l:pattern) call add(l:output, { \ 'type': l:match[3] is? 'warning' ? 'W' : 'E', + \ 'sub_type': 'style', \ 'lnum': l:match[2] + 0, \ 'text': l:match[4], \}) diff --git a/sources_non_forked/ale/ale_linters/java/eclipselsp.vim b/sources_non_forked/ale/ale_linters/java/eclipselsp.vim index 8bc09039..adfd1b09 100644 --- a/sources_non_forked/ale/ale_linters/java/eclipselsp.vim +++ b/sources_non_forked/ale/ale_linters/java/eclipselsp.vim @@ -29,28 +29,28 @@ function! ale_linters#java#eclipselsp#JarPath(buffer) abort endif " 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) + let l:files = globpath(l:path, '**/'.l:platform.'/**/plugins/org.eclipse.equinox.launcher_*\.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, '**/'.l:platform.'/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_*\.jar', 1, 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) + let l:files = globpath(l:path, 'plugins/org.eclipse.equinox.launcher_*\.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) + let l:files = globpath('/usr/share/java/jdtls/plugins', 'org.eclipse.equinox.launcher_*\.jar', 1, 1) if len(l:files) >= 1 return l:files[0] diff --git a/sources_non_forked/ale/ale_linters/java/javac.vim b/sources_non_forked/ale/ale_linters/java/javac.vim index a5e57e6c..971e8de0 100644 --- a/sources_non_forked/ale/ale_linters/java/javac.vim +++ b/sources_non_forked/ale/ale_linters/java/javac.vim @@ -9,16 +9,16 @@ call ale#Set('java_javac_classpath', '') call ale#Set('java_javac_sourcepath', '') function! ale_linters#java#javac#RunWithImportPaths(buffer) abort - let l:command = ale#maven#BuildClasspathCommand(a:buffer) + let [l:cwd, l:command] = ale#maven#BuildClasspathCommand(a:buffer) " Try to use Gradle if Maven isn't available. if empty(l:command) - let l:command = ale#gradle#BuildClasspathCommand(a:buffer) + let [l:cwd, l:command] = ale#gradle#BuildClasspathCommand(a:buffer) endif " Try to use Ant if Gradle and Maven aren't available if empty(l:command) - let l:command = ale#ant#BuildClasspathCommand(a:buffer) + let [l:cwd, l:command] = ale#ant#BuildClasspathCommand(a:buffer) endif if empty(l:command) @@ -28,7 +28,8 @@ function! ale_linters#java#javac#RunWithImportPaths(buffer) abort return ale#command#Run( \ a:buffer, \ l:command, - \ function('ale_linters#java#javac#GetCommand') + \ function('ale_linters#java#javac#GetCommand'), + \ {'cwd': l:cwd}, \) endfunction @@ -110,8 +111,7 @@ function! ale_linters#java#javac#GetCommand(buffer, import_paths, meta) abort " Always run javac from the directory the file is in, so we can resolve " relative paths correctly. - return ale#path#BufferCdString(a:buffer) - \ . '%e -Xlint' + return '%e -Xlint' \ . ale#Pad(l:cp_option) \ . ale#Pad(l:sp_option) \ . ' -d ' . ale#Escape(l:class_file_directory) @@ -132,7 +132,9 @@ function! ale_linters#java#javac#Handle(buffer, lines) abort for l:match in ale#util#GetMatches(a:lines, [l:pattern, l:col_pattern, l:symbol_pattern]) if empty(l:match[2]) && empty(l:match[3]) - let l:output[-1].col = len(l:match[1]) + if !empty(l:match[1]) && !empty(l:output) + let l:output[-1].col = len(l:match[1]) + endif elseif empty(l:match[3]) " Add symbols to 'cannot find symbol' errors. if l:output[-1].text is# 'error: cannot find symbol' @@ -154,6 +156,7 @@ endfunction call ale#linter#Define('java', { \ 'name': 'javac', \ 'executable': {b -> ale#Var(b, 'java_javac_executable')}, +\ 'cwd': '%s:h', \ 'command': function('ale_linters#java#javac#RunWithImportPaths'), \ 'output_stream': 'stderr', \ 'callback': 'ale_linters#java#javac#Handle', diff --git a/sources_non_forked/ale/ale_linters/javascript/eslint.vim b/sources_non_forked/ale/ale_linters/javascript/eslint.vim index 31fb413f..cf4de6ec 100644 --- a/sources_non_forked/ale/ale_linters/javascript/eslint.vim +++ b/sources_non_forked/ale/ale_linters/javascript/eslint.vim @@ -5,6 +5,7 @@ call ale#linter#Define('javascript', { \ 'name': 'eslint', \ 'output_stream': 'both', \ 'executable': function('ale#handlers#eslint#GetExecutable'), +\ 'cwd': function('ale#handlers#eslint#GetCwd'), \ 'command': function('ale#handlers#eslint#GetCommand'), \ 'callback': 'ale#handlers#eslint#HandleJSON', \}) diff --git a/sources_non_forked/ale/ale_linters/javascript/flow.vim b/sources_non_forked/ale/ale_linters/javascript/flow.vim index 3135e2e9..601bac33 100644 --- a/sources_non_forked/ale/ale_linters/javascript/flow.vim +++ b/sources_non_forked/ale/ale_linters/javascript/flow.vim @@ -22,7 +22,7 @@ function! ale_linters#javascript#flow#GetExecutable(buffer) abort return '' endif - return ale#node#FindExecutable(a:buffer, 'javascript_flow', [ + return ale#path#FindExecutable(a:buffer, 'javascript_flow', [ \ 'node_modules/.bin/flow', \]) endfunction diff --git a/sources_non_forked/ale/ale_linters/javascript/flow_ls.vim b/sources_non_forked/ale/ale_linters/javascript/flow_ls.vim index accaaa73..fec34011 100644 --- a/sources_non_forked/ale/ale_linters/javascript/flow_ls.vim +++ b/sources_non_forked/ale/ale_linters/javascript/flow_ls.vim @@ -19,7 +19,7 @@ endfunction call ale#linter#Define('javascript', { \ 'name': 'flow-language-server', \ 'lsp': 'stdio', -\ 'executable': {b -> ale#node#FindExecutable(b, 'javascript_flow_ls', [ +\ 'executable': {b -> ale#path#FindExecutable(b, 'javascript_flow_ls', [ \ 'node_modules/.bin/flow', \ ])}, \ 'command': '%e lsp --from ale-lsp', diff --git a/sources_non_forked/ale/ale_linters/javascript/jscs.vim b/sources_non_forked/ale/ale_linters/javascript/jscs.vim index 8905b3a1..ae3be68c 100644 --- a/sources_non_forked/ale/ale_linters/javascript/jscs.vim +++ b/sources_non_forked/ale/ale_linters/javascript/jscs.vim @@ -53,7 +53,7 @@ endfunction call ale#linter#Define('javascript', { \ 'name': 'jscs', -\ 'executable': {b -> ale#node#FindExecutable(b, 'javascript_jscs', [ +\ 'executable': {b -> ale#path#FindExecutable(b, 'javascript_jscs', [ \ 'node_modules/.bin/jscs', \ ])}, \ 'command': function('ale_linters#javascript#jscs#GetCommand'), diff --git a/sources_non_forked/ale/ale_linters/javascript/jshint.vim b/sources_non_forked/ale/ale_linters/javascript/jshint.vim index d80a2250..26d4fda2 100644 --- a/sources_non_forked/ale/ale_linters/javascript/jshint.vim +++ b/sources_non_forked/ale/ale_linters/javascript/jshint.vim @@ -25,7 +25,7 @@ endfunction call ale#linter#Define('javascript', { \ 'name': 'jshint', -\ 'executable': {b -> ale#node#FindExecutable(b, 'javascript_jshint', [ +\ 'executable': {b -> ale#path#FindExecutable(b, 'javascript_jshint', [ \ 'node_modules/.bin/jshint', \ ])}, \ 'command': function('ale_linters#javascript#jshint#GetCommand'), diff --git a/sources_non_forked/ale/ale_linters/javascript/standard.vim b/sources_non_forked/ale/ale_linters/javascript/standard.vim index 1990adce..addf41dd 100644 --- a/sources_non_forked/ale/ale_linters/javascript/standard.vim +++ b/sources_non_forked/ale/ale_linters/javascript/standard.vim @@ -6,7 +6,7 @@ call ale#Set('javascript_standard_use_global', get(g:, 'ale_use_global_executabl call ale#Set('javascript_standard_options', '') function! ale_linters#javascript#standard#GetExecutable(buffer) abort - return ale#node#FindExecutable(a:buffer, 'javascript_standard', [ + return ale#path#FindExecutable(a:buffer, 'javascript_standard', [ \ 'node_modules/standardx/bin/cmd.js', \ 'node_modules/standard/bin/cmd.js', \ 'node_modules/semistandard/bin/cmd.js', diff --git a/sources_non_forked/ale/ale_linters/javascript/tsserver.vim b/sources_non_forked/ale/ale_linters/javascript/tsserver.vim index 68c252c5..caf6972b 100644 --- a/sources_non_forked/ale/ale_linters/javascript/tsserver.vim +++ b/sources_non_forked/ale/ale_linters/javascript/tsserver.vim @@ -8,7 +8,7 @@ call ale#Set('javascript_tsserver_use_global', get(g:, 'ale_use_global_executabl call ale#linter#Define('javascript', { \ 'name': 'tsserver', \ 'lsp': 'tsserver', -\ 'executable': {b -> ale#node#FindExecutable(b, 'javascript_tsserver', [ +\ 'executable': {b -> ale#path#FindExecutable(b, 'javascript_tsserver', [ \ 'node_modules/.bin/tsserver', \ ])}, \ 'command': '%e', diff --git a/sources_non_forked/ale/ale_linters/javascript/xo.vim b/sources_non_forked/ale/ale_linters/javascript/xo.vim index e24f4a82..5e04ad5c 100644 --- a/sources_non_forked/ale/ale_linters/javascript/xo.vim +++ b/sources_non_forked/ale/ale_linters/javascript/xo.vim @@ -1,26 +1,9 @@ " Author: Daniel Lupu " Description: xo for JavaScript files -call ale#Set('javascript_xo_executable', 'xo') -call ale#Set('javascript_xo_use_global', get(g:, 'ale_use_global_executables', 0)) -call ale#Set('javascript_xo_options', '') - -function! ale_linters#javascript#xo#GetExecutable(buffer) abort - return ale#node#FindExecutable(a:buffer, 'javascript_xo', [ - \ 'node_modules/.bin/xo', - \]) -endfunction - -function! ale_linters#javascript#xo#GetCommand(buffer) abort - return ale#Escape(ale_linters#javascript#xo#GetExecutable(a:buffer)) - \ . ' ' . ale#Var(a:buffer, 'javascript_xo_options') - \ . ' --reporter json --stdin --stdin-filename %s' -endfunction - -" xo uses eslint and the output format is the same call ale#linter#Define('javascript', { \ 'name': 'xo', -\ 'executable': function('ale_linters#javascript#xo#GetExecutable'), -\ 'command': function('ale_linters#javascript#xo#GetCommand'), -\ 'callback': 'ale#handlers#eslint#HandleJSON', +\ 'executable': function('ale#handlers#xo#GetExecutable'), +\ 'command': function('ale#handlers#xo#GetLintCommand'), +\ 'callback': 'ale#handlers#xo#HandleJSON', \}) diff --git a/sources_non_forked/ale/ale_linters/json/jq.vim b/sources_non_forked/ale/ale_linters/json/jq.vim new file mode 100644 index 00000000..2f36a29e --- /dev/null +++ b/sources_non_forked/ale/ale_linters/json/jq.vim @@ -0,0 +1,24 @@ +" Author: jD91mZM2 +call ale#Set('json_jq_executable', 'jq') +call ale#Set('json_jq_options', '') +call ale#Set('json_jq_filters', '.') + +" Matches patterns like the following: +" parse error: Expected another key-value pair at line 4, column 3 +let s:pattern = '^parse error: \(.\+\) at line \(\d\+\), column \(\d\+\)$' + +function! ale_linters#json#jq#Handle(buffer, lines) abort + return ale#util#MapMatches(a:lines, s:pattern, {match -> { + \ 'text': match[1], + \ 'lnum': match[2] + 0, + \ 'col': match[3] + 0, + \}}) +endfunction + +call ale#linter#Define('json', { +\ 'name': 'jq', +\ 'executable': {b -> ale#Var(b, 'json_jq_executable')}, +\ 'output_stream': 'stderr', +\ 'command': '%e', +\ 'callback': 'ale_linters#json#jq#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/json/jsonlint.vim b/sources_non_forked/ale/ale_linters/json/jsonlint.vim index f677b488..812540af 100644 --- a/sources_non_forked/ale/ale_linters/json/jsonlint.vim +++ b/sources_non_forked/ale/ale_linters/json/jsonlint.vim @@ -4,7 +4,7 @@ call ale#Set('json_jsonlint_executable', 'jsonlint') call ale#Set('json_jsonlint_use_global', get(g:, 'ale_use_global_executables', 0)) function! ale_linters#json#jsonlint#GetExecutable(buffer) abort - return ale#node#FindExecutable(a:buffer, 'json_jsonlint', [ + return ale#path#FindExecutable(a:buffer, 'json_jsonlint', [ \ 'node_modules/.bin/jsonlint', \ 'node_modules/jsonlint/lib/cli.js', \]) diff --git a/sources_non_forked/ale/ale_linters/json/spectral.vim b/sources_non_forked/ale/ale_linters/json/spectral.vim new file mode 100644 index 00000000..14129c56 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/json/spectral.vim @@ -0,0 +1,14 @@ +" Author: t2h5 +" Description: Integration of Stoplight Spectral CLI with ALE. + +call ale#Set('json_spectral_executable', 'spectral') +call ale#Set('json_spectral_use_global', get(g:, 'ale_use_global_executables', 0)) + +call ale#linter#Define('json', { +\ 'name': 'spectral', +\ 'executable': {b -> ale#path#FindExecutable(b, 'json_spectral', [ +\ 'node_modules/.bin/spectral', +\ ])}, +\ 'command': '%e lint --ignore-unknown-format -q -f text %t', +\ 'callback': 'ale#handlers#spectral#HandleSpectralOutput' +\}) diff --git a/sources_non_forked/ale/ale_linters/julia/languageserver.vim b/sources_non_forked/ale/ale_linters/julia/languageserver.vim index 564bec39..999ad815 100644 --- a/sources_non_forked/ale/ale_linters/julia/languageserver.vim +++ b/sources_non_forked/ale/ale_linters/julia/languageserver.vim @@ -6,9 +6,9 @@ call ale#Set('julia_executable', 'julia') function! ale_linters#julia#languageserver#GetCommand(buffer) abort let l:julia_executable = ale#Var(a:buffer, 'julia_executable') - let l:cmd_string = 'using LanguageServer; server = LanguageServer.LanguageServerInstance(isdefined(Base, :stdin) ? stdin : STDIN, isdefined(Base, :stdout) ? stdout : STDOUT, false); server.runlinter = true; run(server);' + let l:cmd_string = 'using LanguageServer; using Pkg; import StaticLint; import SymbolServer; server = LanguageServer.LanguageServerInstance(isdefined(Base, :stdin) ? stdin : STDIN, isdefined(Base, :stdout) ? stdout : STDOUT, dirname(Pkg.Types.Context().env.project_file)); server.runlinter = true; run(server);' - return ale#Escape(l:julia_executable) . ' --startup-file=no --history-file=no -e ' . ale#Escape(l:cmd_string) + return ale#Escape(l:julia_executable) . ' --project=@. --startup-file=no --history-file=no -e ' . ale#Escape(l:cmd_string) endfunction call ale#linter#Define('julia', { diff --git a/sources_non_forked/ale/ale_linters/kotlin/kotlinc.vim b/sources_non_forked/ale/ale_linters/kotlin/kotlinc.vim index 66c075be..e8bc924d 100644 --- a/sources_non_forked/ale/ale_linters/kotlin/kotlinc.vim +++ b/sources_non_forked/ale/ale_linters/kotlin/kotlinc.vim @@ -15,20 +15,15 @@ function! ale_linters#kotlin#kotlinc#RunWithImportPaths(buffer) abort let l:command = '' " exec maven/gradle only if classpath is not set - if ale#Var(a:buffer, 'kotlin_kotlinc_classpath') isnot# '' + if !empty(ale#Var(a:buffer, 'kotlin_kotlinc_classpath')) return ale_linters#kotlin#kotlinc#GetCommand(a:buffer, [], {}) endif - 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:cwd, l:command] = ale#maven#BuildClasspathCommand(a:buffer) " Try to use Gradle if Maven isn't available. if empty(l:command) - let l:command = ale#gradle#BuildClasspathCommand(a:buffer) + let [l:cwd, l:command] = ale#gradle#BuildClasspathCommand(a:buffer) endif if empty(l:command) @@ -38,7 +33,8 @@ function! ale_linters#kotlin#kotlinc#RunWithImportPaths(buffer) abort return ale#command#Run( \ a:buffer, \ l:command, - \ function('ale_linters#kotlin#kotlinc#GetCommand') + \ function('ale_linters#kotlin#kotlinc#GetCommand'), + \ {'cwd': l:cwd}, \) endfunction diff --git a/sources_non_forked/ale/ale_linters/less/lessc.vim b/sources_non_forked/ale/ale_linters/less/lessc.vim index 4ec8b00e..8e21f5b4 100644 --- a/sources_non_forked/ale/ale_linters/less/lessc.vim +++ b/sources_non_forked/ale/ale_linters/less/lessc.vim @@ -38,7 +38,7 @@ endfunction call ale#linter#Define('less', { \ 'name': 'lessc', -\ 'executable': {b -> ale#node#FindExecutable(b, 'less_lessc', [ +\ 'executable': {b -> ale#path#FindExecutable(b, 'less_lessc', [ \ 'node_modules/.bin/lessc', \ ])}, \ 'command': function('ale_linters#less#lessc#GetCommand'), diff --git a/sources_non_forked/ale/ale_linters/less/stylelint.vim b/sources_non_forked/ale/ale_linters/less/stylelint.vim index efb036c2..83f784c4 100644 --- a/sources_non_forked/ale/ale_linters/less/stylelint.vim +++ b/sources_non_forked/ale/ale_linters/less/stylelint.vim @@ -12,7 +12,7 @@ endfunction call ale#linter#Define('less', { \ 'name': 'stylelint', -\ 'executable': {b -> ale#node#FindExecutable(b, 'less_stylelint', [ +\ 'executable': {b -> ale#path#FindExecutable(b, 'less_stylelint', [ \ 'node_modules/.bin/stylelint', \ ])}, \ 'command': function('ale_linters#less#stylelint#GetCommand'), diff --git a/sources_non_forked/ale/ale_linters/markdown/remark_lint.vim b/sources_non_forked/ale/ale_linters/markdown/remark_lint.vim index ed87d1ad..6085e7ef 100644 --- a/sources_non_forked/ale/ale_linters/markdown/remark_lint.vim +++ b/sources_non_forked/ale/ale_linters/markdown/remark_lint.vim @@ -39,7 +39,7 @@ endfunction call ale#linter#Define('markdown', { \ 'name': 'remark_lint', \ 'aliases': ['remark-lint'], -\ 'executable': {b -> ale#node#FindExecutable(b, 'markdown_remark_lint', [ +\ 'executable': {b -> ale#path#FindExecutable(b, 'markdown_remark_lint', [ \ 'node_modules/.bin/remark', \ ])}, \ 'command': function('ale_linters#markdown#remark_lint#GetCommand'), diff --git a/sources_non_forked/ale/ale_linters/markdown/vale.vim b/sources_non_forked/ale/ale_linters/markdown/vale.vim index 838c4db2..06a64416 100644 --- a/sources_non_forked/ale/ale_linters/markdown/vale.vim +++ b/sources_non_forked/ale/ale_linters/markdown/vale.vim @@ -1,9 +1,24 @@ " Author: chew-z https://github.com/chew-z " Description: vale for Markdown files +call ale#Set('markdown_vale_executable', 'vale') +call ale#Set('markdown_vale_input_file', '%t') +call ale#Set('markdown_vale_options', '') + +function! ale_linters#markdown#vale#GetCommand(buffer) abort + let l:executable = ale#Var(a:buffer, 'markdown_vale_executable') + let l:input_file = ale#Var(a:buffer, 'markdown_vale_input_file') + + " Defaults to `vale --output=JSON %t` + return ale#Escape(l:executable) + \ . ' --output=JSON ' + \ . ale#Var(a:buffer, 'markdown_vale_options') + \ . ' ' . l:input_file +endfunction + call ale#linter#Define('markdown', { \ 'name': 'vale', -\ 'executable': 'vale', -\ 'command': 'vale --output=JSON %t', +\ 'executable': {b -> ale#Var(b, 'markdown_vale_executable')}, +\ 'command': function('ale_linters#markdown#vale#GetCommand'), \ 'callback': 'ale#handlers#vale#Handle', \}) diff --git a/sources_non_forked/ale/ale_linters/mercury/mmc.vim b/sources_non_forked/ale/ale_linters/mercury/mmc.vim index 8a9ccc0e..85969e10 100644 --- a/sources_non_forked/ale/ale_linters/mercury/mmc.vim +++ b/sources_non_forked/ale/ale_linters/mercury/mmc.vim @@ -5,12 +5,9 @@ call ale#Set('mercury_mmc_executable', 'mmc') call ale#Set('mercury_mmc_options', '--make --output-compile-error-lines 100') function! ale_linters#mercury#mmc#GetCommand(buffer) abort - let l:module_name = expand('#' . a:buffer . ':t:r') - - return ale#path#BufferCdString(a:buffer) - \ . '%e --errorcheck-only ' + return '%e --errorcheck-only ' \ . ale#Var(a:buffer, 'mercury_mmc_options') - \ . ' ' . l:module_name + \ . ' %s:t:r' endfunction function! ale_linters#mercury#mmc#Handle(buffer, lines) abort @@ -34,6 +31,7 @@ call ale#linter#Define('mercury', { \ 'name': 'mmc', \ 'output_stream': 'stderr', \ 'executable': {b -> ale#Var(b, 'mercury_mmc_executable')}, +\ 'cwd': '%s:h', \ 'command': function('ale_linters#mercury#mmc#GetCommand'), \ 'callback': 'ale_linters#mercury#mmc#Handle', \ 'lint_file': 1, diff --git a/sources_non_forked/ale/ale_linters/nix/nix.vim b/sources_non_forked/ale/ale_linters/nix/nix.vim index 0a0c5c3e..3d91a9ec 100644 --- a/sources_non_forked/ale/ale_linters/nix/nix.vim +++ b/sources_non_forked/ale/ale_linters/nix/nix.vim @@ -1,18 +1,51 @@ " Author: Alistair Bill <@alibabzo> +" Author: Maximilian Bosch " Description: nix-instantiate linter for nix files +function! ale_linters#nix#nix#Command(buffer, output, meta) abort + let l:version = a:output[0][22:] + + if l:version =~# '^\(2.4\|3\).*' + return 'nix-instantiate --log-format internal-json --parse -' + else + return 'nix-instantiate --parse -' + endif +endfunction + function! ale_linters#nix#nix#Handle(buffer, lines) abort - let l:pattern = '^\(.\+\): \(.\+\), at .*:\(\d\+\):\(\d\+\)$' let l:output = [] - for l:match in ale#util#GetMatches(a:lines, l:pattern) - call add(l:output, { - \ 'lnum': l:match[3] + 0, - \ 'col': l:match[4] + 0, - \ 'text': l:match[1] . ': ' . l:match[2], - \ 'type': l:match[1] =~# '^error' ? 'E' : 'W', - \}) - endfor + if empty(a:lines) + return l:output + endif + + if a:lines[0] =~# '^@nix .*' + for l:line in a:lines + if l:line =~# '^@nix .*' + let l:result = json_decode(strpart(l:line, 4)) + + if has_key(l:result, 'column') + call add(l:output, { + \ 'type': 'E', + \ 'lnum': l:result.line, + \ 'col': l:result.column, + \ 'text': l:result.raw_msg + \}) + endif + endif + endfor + else + let l:pattern = '^\(.\+\): \(.\+\) at .*:\(\d\+\):\(\d\+\)$' + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + call add(l:output, { + \ 'lnum': l:match[3] + 0, + \ 'col': l:match[4] + 0, + \ 'text': l:match[1] . ': ' . substitute(l:match[2], ',$', '', ''), + \ 'type': l:match[1] =~# '^error' ? 'E' : 'W', + \}) + endfor + endif return l:output endfunction @@ -21,6 +54,10 @@ call ale#linter#Define('nix', { \ 'name': 'nix', \ 'output_stream': 'stderr', \ 'executable': 'nix-instantiate', -\ 'command': 'nix-instantiate --parse -', +\ 'command': {buffer -> ale#command#Run( +\ buffer, +\ 'nix-instantiate --version', +\ function('ale_linters#nix#nix#Command') +\ )}, \ 'callback': 'ale_linters#nix#nix#Handle', \}) diff --git a/sources_non_forked/ale/ale_linters/nix/rnix_lsp.vim b/sources_non_forked/ale/ale_linters/nix/rnix_lsp.vim new file mode 100644 index 00000000..949bed1c --- /dev/null +++ b/sources_non_forked/ale/ale_linters/nix/rnix_lsp.vim @@ -0,0 +1,16 @@ +" Author: jD91mZM2 +" Description: rnix-lsp language client + +function! ale_linters#nix#rnix_lsp#GetProjectRoot(buffer) abort + " rnix-lsp does not yet use the project root, so getting it right is not + " important + return fnamemodify(a:buffer, ':h') +endfunction + +call ale#linter#Define('nix', { +\ 'name': 'rnix_lsp', +\ 'lsp': 'stdio', +\ 'executable': 'rnix-lsp', +\ 'command': '%e', +\ 'project_root': function('ale_linters#nix#rnix_lsp#GetProjectRoot'), +\}) diff --git a/sources_non_forked/ale/ale_linters/ocaml/ocamllsp.vim b/sources_non_forked/ale/ale_linters/ocaml/ocamllsp.vim new file mode 100644 index 00000000..4ff7419c --- /dev/null +++ b/sources_non_forked/ale/ale_linters/ocaml/ocamllsp.vim @@ -0,0 +1,13 @@ +" Author: Risto Stevcev +" Description: The official language server for OCaml + +call ale#Set('ocaml_ocamllsp_use_opam', 1) + +call ale#linter#Define('ocaml', { +\ 'name': 'ocamllsp', +\ 'lsp': 'stdio', +\ 'executable': function('ale#handlers#ocamllsp#GetExecutable'), +\ 'command': function('ale#handlers#ocamllsp#GetCommand'), +\ 'language': function('ale#handlers#ocamllsp#GetLanguage'), +\ 'project_root': function('ale#handlers#ocamllsp#GetProjectRoot'), +\}) diff --git a/sources_non_forked/ale/ale_linters/ocamlinterface/merlin.vim b/sources_non_forked/ale/ale_linters/ocamlinterface/merlin.vim new file mode 100644 index 00000000..799490f7 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/ocamlinterface/merlin.vim @@ -0,0 +1,17 @@ +" Author: Andrey Popp -- @andreypopp +" Description: Report errors in OCaml code with Merlin + +if !exists('g:merlin') + finish +endif + +function! ale_linters#ocamlinterface#merlin#Handle(buffer, lines) abort + return merlin#ErrorLocList() +endfunction + +call ale#linter#Define('ocamlinterface', { +\ 'name': 'merlin', +\ 'executable': 'ocamlmerlin', +\ 'command': 'true', +\ 'callback': 'ale_linters#ocamlinterface#merlin#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/ocamlinterface/ocamllsp.vim b/sources_non_forked/ale/ale_linters/ocamlinterface/ocamllsp.vim new file mode 100644 index 00000000..cd4bea80 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/ocamlinterface/ocamllsp.vim @@ -0,0 +1,13 @@ +" Author: Risto Stevcev +" Description: The official language server for OCaml + +call ale#Set('ocaml_ocamllsp_use_opam', 1) + +call ale#linter#Define('ocamlinterface', { +\ 'name': 'ocamllsp', +\ 'lsp': 'stdio', +\ 'executable': function('ale#handlers#ocamllsp#GetExecutable'), +\ 'command': function('ale#handlers#ocamllsp#GetCommand'), +\ 'language': function('ale#handlers#ocamllsp#GetLanguage'), +\ 'project_root': function('ale#handlers#ocamllsp#GetProjectRoot'), +\}) diff --git a/sources_non_forked/ale/ale_linters/openapi/ibm_validator.vim b/sources_non_forked/ale/ale_linters/openapi/ibm_validator.vim new file mode 100644 index 00000000..446931a2 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/openapi/ibm_validator.vim @@ -0,0 +1,58 @@ +" Author: Horacio Sanson + +call ale#Set('openapi_ibm_validator_executable', 'lint-openapi') +call ale#Set('openapi_ibm_validator_options', '') + +function! ale_linters#openapi#ibm_validator#GetCommand(buffer) abort + return '%e' . ale#Pad(ale#Var(a:buffer, 'openapi_ibm_validator_options')) + \ . ' %t' +endfunction + +function! ale_linters#openapi#ibm_validator#Handle(buffer, lines) abort + let l:output = [] + let l:type = 'E' + let l:message = '' + let l:nr = -1 + + for l:line in a:lines + let l:match = matchlist(l:line, '^errors$') + + if !empty(l:match) + let l:type = 'E' + endif + + let l:match = matchlist(l:line, '^warnings$') + + if !empty(l:match) + let l:type = 'W' + endif + + let l:match = matchlist(l:line, '^ *Message : *\(.\+\)$') + + if !empty(l:match) + let l:message = l:match[1] + endif + + let l:match = matchlist(l:line, '^ *Line *: *\(\d\+\)$') + + if !empty(l:match) + let l:nr = l:match[1] + + call add(l:output, { + \ 'lnum': l:nr + 0, + \ 'col': 0, + \ 'text': l:message, + \ 'type': l:type, + \}) + endif + endfor + + return l:output +endfunction + +call ale#linter#Define('openapi', { +\ 'name': 'ibm_validator', +\ 'executable': {b -> ale#Var(b, 'openapi_ibm_validator_executable')}, +\ 'command': function('ale_linters#openapi#ibm_validator#GetCommand'), +\ 'callback': 'ale_linters#openapi#ibm_validator#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/openapi/yamllint.vim b/sources_non_forked/ale/ale_linters/openapi/yamllint.vim new file mode 100644 index 00000000..2b8952cc --- /dev/null +++ b/sources_non_forked/ale/ale_linters/openapi/yamllint.vim @@ -0,0 +1,9 @@ +call ale#Set('yaml_yamllint_executable', 'yamllint') +call ale#Set('yaml_yamllint_options', '') + +call ale#linter#Define('openapi', { +\ 'name': 'yamllint', +\ 'executable': {b -> ale#Var(b, 'yaml_yamllint_executable')}, +\ 'command': function('ale#handlers#yamllint#GetCommand'), +\ 'callback': 'ale#handlers#yamllint#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/perl6/perl6.vim b/sources_non_forked/ale/ale_linters/perl6/perl6.vim index 68ef4769..444ae4d7 100644 --- a/sources_non_forked/ale/ale_linters/perl6/perl6.vim +++ b/sources_non_forked/ale/ale_linters/perl6/perl6.vim @@ -88,7 +88,7 @@ function! ale_linters#perl6#perl6#Handle(buffer, lines) abort try let l:json = json_decode(join(a:lines, '')) - catch /E474/ + catch /E474\|E491/ call add(l:output, { \ 'lnum': '1', \ 'text': 'Received output in the default Perl6 error format. See :ALEDetail for details', diff --git a/sources_non_forked/ale/ale_linters/php/intelephense.vim b/sources_non_forked/ale/ale_linters/php/intelephense.vim index e9e07d1f..0fdcc93e 100644 --- a/sources_non_forked/ale/ale_linters/php/intelephense.vim +++ b/sources_non_forked/ale/ale_linters/php/intelephense.vim @@ -18,15 +18,15 @@ function! ale_linters#php#intelephense#GetProjectRoot(buffer) abort 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') +function! ale_linters#php#intelephense#GetInitializationOptions(buffer) abort + return ale#Var(a:buffer, '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', [])}, +\ 'executable': {b -> ale#path#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/langserver.vim b/sources_non_forked/ale/ale_linters/php/langserver.vim index fdd1bf2b..c3d89a00 100644 --- a/sources_non_forked/ale/ale_linters/php/langserver.vim +++ b/sources_non_forked/ale/ale_linters/php/langserver.vim @@ -19,7 +19,7 @@ endfunction call ale#linter#Define('php', { \ 'name': 'langserver', \ 'lsp': 'stdio', -\ 'executable': {b -> ale#node#FindExecutable(b, 'php_langserver', [ +\ 'executable': {b -> ale#path#FindExecutable(b, 'php_langserver', [ \ 'vendor/bin/php-language-server.php', \ ])}, \ 'command': 'php %e', diff --git a/sources_non_forked/ale/ale_linters/php/phan.vim b/sources_non_forked/ale/ale_linters/php/phan.vim index 53cb1ea9..50c6d6e6 100644 --- a/sources_non_forked/ale/ale_linters/php/phan.vim +++ b/sources_non_forked/ale/ale_linters/php/phan.vim @@ -39,7 +39,7 @@ function! ale_linters#php#phan#Handle(buffer, lines) abort let l:pattern = '^Phan error: \(\w\+\): \(.\+\) in \(.\+\) on line \(\d\+\)$' else " /path/to/some-filename.php:18 ERRORTYPE message - let l:pattern = '^.*:\(\d\+\)\s\(\w\+\)\s\(.\+\)$' + let l:pattern = '^\(.*\):\(\d\+\)\s\(\w\+\)\s\(.\+\)$' endif let l:output = [] @@ -49,13 +49,15 @@ function! ale_linters#php#phan#Handle(buffer, lines) abort let l:dict = { \ 'lnum': l:match[4] + 0, \ 'text': l:match[2], + \ 'filename': l:match[3], \ 'type': 'W', \} else let l:dict = { - \ 'lnum': l:match[1] + 0, - \ 'text': l:match[3], + \ 'lnum': l:match[2] + 0, + \ 'text': l:match[4], \ 'type': 'W', + \ 'filename': l:match[1], \} endif diff --git a/sources_non_forked/ale/ale_linters/php/phpcs.vim b/sources_non_forked/ale/ale_linters/php/phpcs.vim index c5a3faa9..ce47a13b 100644 --- a/sources_non_forked/ale/ale_linters/php/phpcs.vim +++ b/sources_non_forked/ale/ale_linters/php/phpcs.vim @@ -13,8 +13,7 @@ function! ale_linters#php#phpcs#GetCommand(buffer) abort \ ? '--standard=' . ale#Escape(l:standard) \ : '' - return ale#path#BufferCdString(a:buffer) - \ . '%e -s --report=emacs --stdin-path=%s' + return '%e -s --report=emacs --stdin-path=%s' \ . ale#Pad(l:standard_option) \ . ale#Pad(ale#Var(a:buffer, 'php_phpcs_options')) endfunction @@ -45,10 +44,11 @@ endfunction call ale#linter#Define('php', { \ 'name': 'phpcs', -\ 'executable': {b -> ale#node#FindExecutable(b, 'php_phpcs', [ +\ 'executable': {b -> ale#path#FindExecutable(b, 'php_phpcs', [ \ 'vendor/bin/phpcs', \ 'phpcs' \ ])}, +\ 'cwd': '%s:h', \ 'command': function('ale_linters#php#phpcs#GetCommand'), \ 'callback': 'ale_linters#php#phpcs#Handle', \}) diff --git a/sources_non_forked/ale/ale_linters/php/phpstan.vim b/sources_non_forked/ale/ale_linters/php/phpstan.vim index 78f7dd10..58d4dce2 100644 --- a/sources_non_forked/ale/ale_linters/php/phpstan.vim +++ b/sources_non_forked/ale/ale_linters/php/phpstan.vim @@ -6,6 +6,7 @@ let g:ale_php_phpstan_executable = get(g:, 'ale_php_phpstan_executable', 'phpsta let g:ale_php_phpstan_level = get(g:, 'ale_php_phpstan_level', '') let g:ale_php_phpstan_configuration = get(g:, 'ale_php_phpstan_configuration', '') let g:ale_php_phpstan_autoload = get(g:, 'ale_php_phpstan_autoload', '') +call ale#Set('php_phpstan_use_global', get(g:, 'ale_use_global_executables', 0)) function! ale_linters#php#phpstan#GetCommand(buffer, version) abort let l:configuration = ale#Var(a:buffer, 'php_phpstan_configuration') @@ -20,8 +21,9 @@ function! ale_linters#php#phpstan#GetCommand(buffer, version) abort let l:level = ale#Var(a:buffer, 'php_phpstan_level') let l:config_file_exists = ale#path#FindNearestFile(a:buffer, 'phpstan.neon') + let l:dist_config_file_exists = ale#path#FindNearestFile(a:buffer, 'phpstan.neon.dist') - if empty(l:level) && empty(l:config_file_exists) + if empty(l:level) && empty(l:config_file_exists) && empty(l:dist_config_file_exists) " if no configuration file is found, then use 4 as a default level let l:level = '4' endif @@ -31,8 +33,8 @@ function! ale_linters#php#phpstan#GetCommand(buffer, version) abort \ : '' let l:error_format = ale#semver#GTE(a:version, [0, 10, 3]) - \ ? ' --error-format raw' - \ : ' --errorFormat raw' + \ ? ' --error-format json' + \ : ' --errorFormat json' return '%e analyze --no-progress' \ . l:error_format @@ -43,17 +45,17 @@ function! ale_linters#php#phpstan#GetCommand(buffer, version) abort endfunction function! ale_linters#php#phpstan#Handle(buffer, lines) abort - " Matches against lines like the following: - " - " filename.php:15:message - " C:\folder\filename.php:15:message - let l:pattern = '^\([a-zA-Z]:\)\?[^:]\+:\(\d\+\):\(.*\)$' + let l:res = ale#util#FuzzyJSONDecode(a:lines, {'files': []}) let l:output = [] - for l:match in ale#util#GetMatches(a:lines, l:pattern) + if type(l:res.files) is v:t_list + return l:output + endif + + for l:err in l:res.files[expand('#' . a:buffer .':p')].messages call add(l:output, { - \ 'lnum': l:match[2] + 0, - \ 'text': l:match[3], + \ 'lnum': l:err.line, + \ 'text': l:err.message, \ 'type': 'E', \}) endfor @@ -63,10 +65,16 @@ endfunction call ale#linter#Define('php', { \ 'name': 'phpstan', -\ 'executable': {b -> ale#Var(b, 'php_phpstan_executable')}, +\ 'executable': {buffer -> ale#path#FindExecutable(buffer, 'php_phpstan', [ +\ 'vendor/bin/phpstan', +\ 'phpstan' +\ ])}, \ 'command': {buffer -> ale#semver#RunWithVersionCheck( \ buffer, -\ ale#Var(buffer, 'php_phpstan_executable'), +\ ale#path#FindExecutable(buffer, 'php_phpstan', [ +\ 'vendor/bin/phpstan', +\ 'phpstan' +\ ]), \ '%e --version', \ function('ale_linters#php#phpstan#GetCommand'), \ )}, diff --git a/sources_non_forked/ale/ale_linters/php/psalm.vim b/sources_non_forked/ale/ale_linters/php/psalm.vim index 286c8a96..dbbe9453 100644 --- a/sources_non_forked/ale/ale_linters/php/psalm.vim +++ b/sources_non_forked/ale/ale_linters/php/psalm.vim @@ -18,7 +18,7 @@ endfunction call ale#linter#Define('php', { \ 'name': 'psalm', \ 'lsp': 'stdio', -\ 'executable': {b -> ale#node#FindExecutable(b, 'php_psalm', [ +\ 'executable': {b -> ale#path#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 index 6bba8def..80bdd1f6 100644 --- a/sources_non_forked/ale/ale_linters/php/tlint.vim +++ b/sources_non_forked/ale/ale_linters/php/tlint.vim @@ -20,7 +20,7 @@ function! ale_linters#php#tlint#GetProjectRoot(buffer) abort endfunction function! ale_linters#php#tlint#GetExecutable(buffer) abort - return ale#node#FindExecutable(a:buffer, 'php_tlint', [ + return ale#path#FindExecutable(a:buffer, 'php_tlint', [ \ 'vendor/bin/tlint', \ 'tlint', \]) diff --git a/sources_non_forked/ale/ale_linters/prolog/swipl.vim b/sources_non_forked/ale/ale_linters/prolog/swipl.vim index 5c601c40..82859eb0 100644 --- a/sources_non_forked/ale/ale_linters/prolog/swipl.vim +++ b/sources_non_forked/ale/ale_linters/prolog/swipl.vim @@ -35,10 +35,11 @@ function! s:Subst(format, vars) abort endfunction function! ale_linters#prolog#swipl#Handle(buffer, lines) abort - let l:pattern = '\v^(ERROR|Warning)+%(:\s*[^:]+:(\d+)%(:(\d+))?)?:\s*(.*)$' let l:output = [] let l:i = 0 + let l:pattern = '\v^(ERROR|Warning)+%(:\s*[^:]+:(\d+)%(:(\d+))?)?:\s*(.*)$' + while l:i < len(a:lines) let l:match = matchlist(a:lines[l:i], l:pattern) @@ -72,8 +73,17 @@ function! s:GetErrMsg(i, lines, text) abort let l:i = a:i + 1 let l:text = [] - while l:i < len(a:lines) && a:lines[l:i] =~# '^\s' - call add(l:text, s:Trim(a:lines[l:i])) + let l:pattern = '\v^(ERROR|Warning)?:?(.*)$' + + while l:i < len(a:lines) + let l:match = matchlist(a:lines[l:i], l:pattern) + + if empty(l:match) || empty(l:match[2]) + let l:i += 1 + break + endif + + call add(l:text, s:Trim(l:match[2])) let l:i += 1 endwhile diff --git a/sources_non_forked/ale/ale_linters/proto/protolint.vim b/sources_non_forked/ale/ale_linters/proto/protolint.vim new file mode 100644 index 00000000..2754c7b6 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/proto/protolint.vim @@ -0,0 +1,24 @@ +" Author: Yohei Yoshimuta +" Description: run the protolint for Protocol Buffer files + +call ale#Set('proto_protolint_executable', 'protolint') +call ale#Set('proto_protolint_config', '') + +function! ale_linters#proto#protolint#GetCommand(buffer) abort + let l:config = ale#Var(a:buffer, 'proto_protolint_config') + + return '%e lint' + \ . (!empty(l:config) ? ' -config_path=' . ale#Escape(l:config) : '') + \ . ' -reporter=unix' + \ . ' %s' +endfunction + +call ale#linter#Define('proto', { +\ 'name': 'protolint', +\ 'lint_file': 1, +\ 'output_stream': 'stderr', +\ 'executable': {b -> ale#Var(b, 'proto_protolint_executable')}, +\ 'command': function('ale_linters#proto#protolint#GetCommand'), +\ 'callback': 'ale#handlers#unix#HandleAsError', +\}) + diff --git a/sources_non_forked/ale/ale_linters/pug/puglint.vim b/sources_non_forked/ale/ale_linters/pug/puglint.vim index c819cc45..b552cc06 100644 --- a/sources_non_forked/ale/ale_linters/pug/puglint.vim +++ b/sources_non_forked/ale/ale_linters/pug/puglint.vim @@ -47,7 +47,7 @@ endfunction call ale#linter#Define('pug', { \ 'name': 'puglint', -\ 'executable': {b -> ale#node#FindExecutable(b, 'pug_puglint', [ +\ 'executable': {b -> ale#path#FindExecutable(b, 'pug_puglint', [ \ 'node_modules/.bin/pug-lint', \ ])}, \ 'output_stream': 'stderr', diff --git a/sources_non_forked/ale/ale_linters/purescript/ls.vim b/sources_non_forked/ale/ale_linters/purescript/ls.vim index 1c5f937f..a20fae47 100644 --- a/sources_non_forked/ale/ale_linters/purescript/ls.vim +++ b/sources_non_forked/ale/ale_linters/purescript/ls.vim @@ -6,7 +6,7 @@ call ale#Set('purescript_ls_use_global', get(g:, 'ale_use_global_executables', 0 call ale#Set('purescript_ls_config', {}) function! ale_linters#purescript#ls#GetExecutable(buffer) abort - return ale#node#FindExecutable(a:buffer, 'purescript_ls', [ + return ale#path#FindExecutable(a:buffer, 'purescript_ls', [ \ 'node_modules/.bin/purescript-language-server', \]) endfunction diff --git a/sources_non_forked/ale/ale_linters/python/bandit.vim b/sources_non_forked/ale/ale_linters/python/bandit.vim index 554f5000..9cfca7c0 100644 --- a/sources_non_forked/ale/ale_linters/python/bandit.vim +++ b/sources_non_forked/ale/ale_linters/python/bandit.vim @@ -6,6 +6,7 @@ call ale#Set('python_bandit_options', '') call ale#Set('python_bandit_use_config', 1) call ale#Set('python_bandit_use_global', get(g:, 'ale_use_global_executables', 0)) call ale#Set('python_bandit_auto_pipenv', 0) +call ale#Set('python_bandit_auto_poetry', 0) function! ale_linters#python#bandit#GetExecutable(buffer) abort if ( @@ -15,6 +16,13 @@ function! ale_linters#python#bandit#GetExecutable(buffer) abort return 'pipenv' endif + if ( + \ ale#Var(a:buffer, 'python_auto_poetry') + \ || ale#Var(a:buffer, 'python_bandit_auto_poetry') + \) && ale#python#PoetryPresent(a:buffer) + return 'poetry' + endif + return ale#python#FindExecutable(a:buffer, 'python_bandit', ['bandit']) endfunction @@ -31,7 +39,7 @@ function! ale_linters#python#bandit#GetCommand(buffer) abort endif endif - let l:exec_args = l:executable =~? 'pipenv$' + let l:exec_args = l:executable =~? 'pipenv\|poetry$' \ ? ' run bandit' \ : '' diff --git a/sources_non_forked/ale/ale_linters/python/flake8.vim b/sources_non_forked/ale/ale_linters/python/flake8.vim index fc4ab692..9950614a 100644 --- a/sources_non_forked/ale/ale_linters/python/flake8.vim +++ b/sources_non_forked/ale/ale_linters/python/flake8.vim @@ -6,6 +6,7 @@ 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', 'project') call ale#Set('python_flake8_auto_pipenv', 0) +call ale#Set('python_flake8_auto_poetry', 0) function! s:UsingModule(buffer) abort return ale#Var(a:buffer, 'python_flake8_options') =~# ' *-m flake8' @@ -17,6 +18,11 @@ function! ale_linters#python#flake8#GetExecutable(buffer) abort return 'pipenv' endif + if (ale#Var(a:buffer, 'python_auto_poetry') || ale#Var(a:buffer, 'python_flake8_auto_poetry')) + \ && ale#python#PoetryPresent(a:buffer) + return 'poetry' + endif + if !s:UsingModule(a:buffer) return ale#python#FindExecutable(a:buffer, 'python_flake8', ['flake8']) endif @@ -38,33 +44,31 @@ function! ale_linters#python#flake8#RunWithVersionCheck(buffer) abort \) endfunction -function! ale_linters#python#flake8#GetCdString(buffer) abort +function! ale_linters#python#flake8#GetCwd(buffer) abort let l:change_directory = ale#Var(a:buffer, 'python_flake8_change_directory') - let l:cd_string = '' + let l:cwd = '' 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) + let l:cwd = l:project_root endif endif - if (l:change_directory is# 'project' && empty(l:cd_string)) + if (l:change_directory is# 'project' && empty(l:cwd)) \|| l:change_directory is# 1 \|| l:change_directory is# 'file' - let l:cd_string = ale#path#BufferCdString(a:buffer) + let l:cwd = '%s:h' endif - return l:cd_string + return l:cwd endfunction function! ale_linters#python#flake8#GetCommand(buffer, version) abort - 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$' + let l:exec_args = l:executable =~? 'pipenv\|poetry$' \ ? ' run flake8' \ : '' @@ -76,8 +80,7 @@ function! ale_linters#python#flake8#GetCommand(buffer, version) abort let l:options = ale#Var(a:buffer, 'python_flake8_options') - return l:cd_string - \ . ale#Escape(l:executable) . l:exec_args + return ale#Escape(l:executable) . l:exec_args \ . (!empty(l:options) ? ' ' . l:options : '') \ . ' --format=default' \ . l:display_name_args . ' -' @@ -161,6 +164,7 @@ endfunction call ale#linter#Define('python', { \ 'name': 'flake8', \ 'executable': function('ale_linters#python#flake8#GetExecutable'), +\ 'cwd': function('ale_linters#python#flake8#GetCwd'), \ 'command': function('ale_linters#python#flake8#RunWithVersionCheck'), \ 'callback': 'ale_linters#python#flake8#Handle', \}) diff --git a/sources_non_forked/ale/ale_linters/python/mypy.vim b/sources_non_forked/ale/ale_linters/python/mypy.vim index 94dfae7d..9d469a1a 100644 --- a/sources_non_forked/ale/ale_linters/python/mypy.vim +++ b/sources_non_forked/ale/ale_linters/python/mypy.vim @@ -7,6 +7,7 @@ call ale#Set('python_mypy_show_notes', 1) call ale#Set('python_mypy_options', '') call ale#Set('python_mypy_use_global', get(g:, 'ale_use_global_executables', 0)) call ale#Set('python_mypy_auto_pipenv', 0) +call ale#Set('python_mypy_auto_poetry', 0) function! ale_linters#python#mypy#GetExecutable(buffer) abort if (ale#Var(a:buffer, 'python_auto_pipenv') || ale#Var(a:buffer, 'python_mypy_auto_pipenv')) @@ -14,11 +15,16 @@ function! ale_linters#python#mypy#GetExecutable(buffer) abort return 'pipenv' endif + if (ale#Var(a:buffer, 'python_auto_poetry') || ale#Var(a:buffer, 'python_mypy_auto_poetry')) + \ && ale#python#PoetryPresent(a:buffer) + return 'poetry' + endif + return ale#python#FindExecutable(a:buffer, 'python_mypy', ['mypy']) endfunction " The directory to change to before running mypy -function! s:GetDir(buffer) abort +function! ale_linters#python#mypy#GetCwd(buffer) abort " If we find a directory with "mypy.ini" in it use that, " else try and find the "python project" root, or failing " that, run from the same folder as the current file @@ -36,24 +42,19 @@ function! s:GetDir(buffer) abort endfunction function! ale_linters#python#mypy#GetCommand(buffer) abort - let l:dir = s:GetDir(a:buffer) let l:executable = ale_linters#python#mypy#GetExecutable(a:buffer) - - let l:exec_args = l:executable =~? 'pipenv$' + let l:exec_args = l:executable =~? 'pipenv\|poetry$' \ ? ' run mypy' \ : '' - " We have to always switch to an explicit directory for a command so - " we can know with certainty the base path for the 'filename' keys below. - return ale#path#CdString(l:dir) - \ . ale#Escape(l:executable) . l:exec_args - \ . ' --show-column-numbers ' - \ . ale#Var(a:buffer, 'python_mypy_options') + return '%e' . l:exec_args + \ . ale#Pad(ale#Var(a:buffer, 'python_mypy_options')) + \ . ' --show-column-numbers' \ . ' --shadow-file %s %t %s' endfunction function! ale_linters#python#mypy#Handle(buffer, lines) abort - let l:dir = s:GetDir(a:buffer) + let l:dir = ale_linters#python#mypy#GetCwd(a:buffer) " Look for lines like the following: " " file.py:4: error: No library stub file for module 'django.db' @@ -95,6 +96,7 @@ endfunction call ale#linter#Define('python', { \ 'name': 'mypy', \ 'executable': function('ale_linters#python#mypy#GetExecutable'), +\ 'cwd': function('ale_linters#python#mypy#GetCwd'), \ 'command': function('ale_linters#python#mypy#GetCommand'), \ 'callback': 'ale_linters#python#mypy#Handle', \ 'output_stream': 'both' diff --git a/sources_non_forked/ale/ale_linters/python/prospector.vim b/sources_non_forked/ale/ale_linters/python/prospector.vim index ee47012f..3623bda0 100644 --- a/sources_non_forked/ale/ale_linters/python/prospector.vim +++ b/sources_non_forked/ale/ale_linters/python/prospector.vim @@ -2,6 +2,7 @@ " Description: prospector linter python files call ale#Set('python_prospector_auto_pipenv', 0) +call ale#Set('python_prospector_auto_poetry', 0) let g:ale_python_prospector_executable = \ get(g:, 'ale_python_prospector_executable', 'prospector') @@ -17,13 +18,18 @@ function! ale_linters#python#prospector#GetExecutable(buffer) abort return 'pipenv' endif + if (ale#Var(a:buffer, 'python_auto_poetry') || ale#Var(a:buffer, 'python_prospector_auto_poetry')) + \ && ale#python#PoetryPresent(a:buffer) + return 'poetry' + endif + return ale#python#FindExecutable(a:buffer, 'python_prospector', ['prospector']) endfunction function! ale_linters#python#prospector#GetCommand(buffer) abort let l:executable = ale_linters#python#prospector#GetExecutable(a:buffer) - let l:exec_args = l:executable =~? 'pipenv$' + let l:exec_args = l:executable =~? 'pipenv\|poetry$' \ ? ' run prospector' \ : '' diff --git a/sources_non_forked/ale/ale_linters/python/pycodestyle.vim b/sources_non_forked/ale/ale_linters/python/pycodestyle.vim index fb521bc1..3fb94d69 100644 --- a/sources_non_forked/ale/ale_linters/python/pycodestyle.vim +++ b/sources_non_forked/ale/ale_linters/python/pycodestyle.vim @@ -5,6 +5,7 @@ call ale#Set('python_pycodestyle_executable', 'pycodestyle') call ale#Set('python_pycodestyle_options', '') call ale#Set('python_pycodestyle_use_global', get(g:, 'ale_use_global_executables', 0)) call ale#Set('python_pycodestyle_auto_pipenv', 0) +call ale#Set('python_pycodestyle_auto_poetry', 0) function! ale_linters#python#pycodestyle#GetExecutable(buffer) abort if (ale#Var(a:buffer, 'python_auto_pipenv') || ale#Var(a:buffer, 'python_pycodestyle_auto_pipenv')) @@ -12,13 +13,18 @@ function! ale_linters#python#pycodestyle#GetExecutable(buffer) abort return 'pipenv' endif + if (ale#Var(a:buffer, 'python_auto_poetry') || ale#Var(a:buffer, 'python_pycodestyle_auto_poetry')) + \ && ale#python#PoetryPresent(a:buffer) + return 'poetry' + endif + return ale#python#FindExecutable(a:buffer, 'python_pycodestyle', ['pycodestyle']) endfunction function! ale_linters#python#pycodestyle#GetCommand(buffer) abort let l:executable = ale_linters#python#pycodestyle#GetExecutable(a:buffer) - let l:exec_args = l:executable =~? 'pipenv$' + let l:exec_args = l:executable =~? 'pipenv\|poetry$' \ ? ' run pycodestyle' \ : '' diff --git a/sources_non_forked/ale/ale_linters/python/pydocstyle.vim b/sources_non_forked/ale/ale_linters/python/pydocstyle.vim index 69ae3807..aa0e8b20 100644 --- a/sources_non_forked/ale/ale_linters/python/pydocstyle.vim +++ b/sources_non_forked/ale/ale_linters/python/pydocstyle.vim @@ -5,6 +5,7 @@ call ale#Set('python_pydocstyle_executable', 'pydocstyle') call ale#Set('python_pydocstyle_options', '') call ale#Set('python_pydocstyle_use_global', get(g:, 'ale_use_global_executables', 0)) call ale#Set('python_pydocstyle_auto_pipenv', 0) +call ale#Set('python_pydocstyle_auto_poetry', 0) function! ale_linters#python#pydocstyle#GetExecutable(buffer) abort if (ale#Var(a:buffer, 'python_auto_pipenv') || ale#Var(a:buffer, 'python_pydocstyle_auto_pipenv')) @@ -12,17 +13,21 @@ function! ale_linters#python#pydocstyle#GetExecutable(buffer) abort return 'pipenv' endif + if (ale#Var(a:buffer, 'python_auto_poetry') || ale#Var(a:buffer, 'python_pydocstyle_auto_poetry')) + \ && ale#python#PoetryPresent(a:buffer) + return 'poetry' + endif + return ale#python#FindExecutable(a:buffer, 'python_pydocstyle', ['pydocstyle']) endfunction function! ale_linters#python#pydocstyle#GetCommand(buffer) abort let l:executable = ale_linters#python#pydocstyle#GetExecutable(a:buffer) - let l:exec_args = l:executable =~? 'pipenv$' + let l:exec_args = l:executable =~? 'pipenv\|poetry$' \ ? ' run pydocstyle' \ : '' - return ale#path#BufferCdString(a:buffer) - \ . ale#Escape(l:executable) . l:exec_args + return ale#Escape(l:executable) . l:exec_args \ . ale#Pad(ale#Var(a:buffer, 'python_pydocstyle_options')) \ . ' %s:t' endfunction @@ -66,6 +71,7 @@ endfunction call ale#linter#Define('python', { \ 'name': 'pydocstyle', \ 'executable': function('ale_linters#python#pydocstyle#GetExecutable'), +\ 'cwd': '%s:h', \ 'command': function('ale_linters#python#pydocstyle#GetCommand'), \ 'callback': 'ale_linters#python#pydocstyle#Handle', \}) diff --git a/sources_non_forked/ale/ale_linters/python/pyflakes.vim b/sources_non_forked/ale/ale_linters/python/pyflakes.vim index b5127022..2567c533 100644 --- a/sources_non_forked/ale/ale_linters/python/pyflakes.vim +++ b/sources_non_forked/ale/ale_linters/python/pyflakes.vim @@ -4,6 +4,7 @@ call ale#Set('python_pyflakes_executable', 'pyflakes') call ale#Set('python_pyflakes_use_global', get(g:, 'ale_use_global_executables', 0)) call ale#Set('python_pyflakes_auto_pipenv', 0) +call ale#Set('python_pyflakes_auto_poetry', 0) function! ale_linters#python#pyflakes#GetExecutable(buffer) abort if (ale#Var(a:buffer, 'python_auto_pipenv') || ale#Var(a:buffer, 'python_pyflakes_auto_pipenv')) @@ -11,13 +12,18 @@ function! ale_linters#python#pyflakes#GetExecutable(buffer) abort return 'pipenv' endif + if (ale#Var(a:buffer, 'python_auto_poetry') || ale#Var(a:buffer, 'python_pyflakes_auto_poetry')) + \ && ale#python#PoetryPresent(a:buffer) + return 'poetry' + endif + return ale#python#FindExecutable(a:buffer, 'python_pyflakes', ['pyflakes']) endfunction function! ale_linters#python#pyflakes#GetCommand(buffer) abort let l:executable = ale_linters#python#pyflakes#GetExecutable(a:buffer) - let l:exec_args = l:executable =~? 'pipenv$' + let l:exec_args = l:executable =~? 'pipenv\|poetry$' \ ? ' run pyflakes' \ : '' diff --git a/sources_non_forked/ale/ale_linters/python/pylama.vim b/sources_non_forked/ale/ale_linters/python/pylama.vim index 38dd2836..73b59b07 100644 --- a/sources_non_forked/ale/ale_linters/python/pylama.vim +++ b/sources_non_forked/ale/ale_linters/python/pylama.vim @@ -5,6 +5,7 @@ call ale#Set('python_pylama_executable', 'pylama') call ale#Set('python_pylama_options', '') call ale#Set('python_pylama_use_global', get(g:, 'ale_use_global_executables', 0)) call ale#Set('python_pylama_auto_pipenv', 0) +call ale#Set('python_pylama_auto_poetry', 0) call ale#Set('python_pylama_change_directory', 1) function! ale_linters#python#pylama#GetExecutable(buffer) abort @@ -13,32 +14,37 @@ function! ale_linters#python#pylama#GetExecutable(buffer) abort return 'pipenv' endif + if (ale#Var(a:buffer, 'python_auto_poetry') || ale#Var(a:buffer, 'python_pylama_auto_poetry')) + \ && ale#python#PoetryPresent(a:buffer) + return 'poetry' + endif + return ale#python#FindExecutable(a:buffer, 'python_pylama', ['pylama']) endfunction -function! ale_linters#python#pylama#GetCommand(buffer) abort - let l:cd_string = '' - +function! ale_linters#python#pylama#GetCwd(buffer) abort if ale#Var(a:buffer, 'python_pylama_change_directory') " Pylama loads its configuration from the current directory only, and " applies file masks using paths relative to the current directory. " Run from project root, if found, otherwise buffer dir. let l:project_root = ale#python#FindProjectRoot(a:buffer) - let l:cd_string = l:project_root isnot# '' - \ ? ale#path#CdString(l:project_root) - \ : ale#path#BufferCdString(a:buffer) + + return !empty(l:project_root) ? l:project_root : '%s:h' endif + return '' +endfunction + +function! ale_linters#python#pylama#GetCommand(buffer) abort let l:executable = ale_linters#python#pylama#GetExecutable(a:buffer) - let l:exec_args = l:executable =~? 'pipenv$' + let l:exec_args = l:executable =~? 'pipenv\|poetry$' \ ? ' run pylama' \ : '' " Note: Using %t to lint changes would be preferable, but many pylama " checks use surrounding paths (e.g. C0103 module name, E0402 relative " import beyond top, etc.). Neither is ideal. - return l:cd_string - \ . ale#Escape(l:executable) . l:exec_args + return ale#Escape(l:executable) . l:exec_args \ . ale#Pad(ale#Var(a:buffer, 'python_pylama_options')) \ . ' %s' endfunction @@ -86,6 +92,7 @@ endfunction call ale#linter#Define('python', { \ 'name': 'pylama', \ 'executable': function('ale_linters#python#pylama#GetExecutable'), +\ 'cwd': function('ale_linters#python#pylama#GetCwd'), \ 'command': function('ale_linters#python#pylama#GetCommand'), \ 'callback': 'ale_linters#python#pylama#Handle', \ 'lint_file': 1, diff --git a/sources_non_forked/ale/ale_linters/python/pylint.vim b/sources_non_forked/ale/ale_linters/python/pylint.vim index 44eea246..2ce5376f 100644 --- a/sources_non_forked/ale/ale_linters/python/pylint.vim +++ b/sources_non_forked/ale/ale_linters/python/pylint.vim @@ -6,6 +6,7 @@ call ale#Set('python_pylint_options', '') call ale#Set('python_pylint_use_global', get(g:, 'ale_use_global_executables', 0)) call ale#Set('python_pylint_change_directory', 1) call ale#Set('python_pylint_auto_pipenv', 0) +call ale#Set('python_pylint_auto_poetry', 0) call ale#Set('python_pylint_use_msg_id', 0) function! ale_linters#python#pylint#GetExecutable(buffer) abort @@ -14,30 +15,34 @@ function! ale_linters#python#pylint#GetExecutable(buffer) abort return 'pipenv' endif + if (ale#Var(a:buffer, 'python_auto_poetry') || ale#Var(a:buffer, 'python_pylint_auto_poetry')) + \ && ale#python#PoetryPresent(a:buffer) + return 'poetry' + endif + return ale#python#FindExecutable(a:buffer, 'python_pylint', ['pylint']) endfunction -function! ale_linters#python#pylint#GetCommand(buffer, version) abort - let l:cd_string = '' - +function! ale_linters#python#pylint#GetCwd(buffer) abort if ale#Var(a:buffer, 'python_pylint_change_directory') " pylint only checks for pylintrc in the packages above its current " directory before falling back to user and global pylintrc. " Run from project root, if found, otherwise buffer dir. let l:project_root = ale#python#FindProjectRoot(a:buffer) - let l:cd_string = l:project_root isnot# '' - \ ? ale#path#CdString(l:project_root) - \ : ale#path#BufferCdString(a:buffer) + + return !empty(l:project_root) ? l:project_root : '%s:h' endif - let l:executable = ale_linters#python#pylint#GetExecutable(a:buffer) + return '' +endfunction - let l:exec_args = l:executable =~? 'pipenv$' +function! ale_linters#python#pylint#GetCommand(buffer, version) abort + let l:executable = ale_linters#python#pylint#GetExecutable(a:buffer) + let l:exec_args = l:executable =~? 'pipenv\|poetry$' \ ? ' run pylint' \ : '' - return l:cd_string - \ . ale#Escape(l:executable) . l:exec_args + return ale#Escape(l:executable) . l:exec_args \ . 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' : '') @@ -104,6 +109,7 @@ call ale#linter#Define('python', { \ '%e --version', \ {buffer, version -> !ale#semver#GTE(version, [2, 4, 0])}, \ )}, +\ 'cwd': function('ale_linters#python#pylint#GetCwd'), \ 'command': {buffer -> ale#semver#RunWithVersionCheck( \ buffer, \ ale#Var(buffer, 'python_pylint_executable'), diff --git a/sources_non_forked/ale/ale_linters/python/pyls.vim b/sources_non_forked/ale/ale_linters/python/pyls.vim deleted file mode 100644 index c7f91430..00000000 --- a/sources_non_forked/ale/ale_linters/python/pyls.vim +++ /dev/null @@ -1,36 +0,0 @@ -" Author: aurieh -" Description: A language server for Python - -call ale#Set('python_pyls_executable', 'pyls') -call ale#Set('python_pyls_use_global', get(g:, 'ale_use_global_executables', 0)) -call ale#Set('python_pyls_auto_pipenv', 0) -call ale#Set('python_pyls_config', {}) - -function! ale_linters#python#pyls#GetExecutable(buffer) abort - if (ale#Var(a:buffer, 'python_auto_pipenv') || ale#Var(a:buffer, 'python_pyls_auto_pipenv')) - \ && ale#python#PipenvPresent(a:buffer) - return 'pipenv' - endif - - return ale#python#FindExecutable(a:buffer, 'python_pyls', ['pyls']) -endfunction - -function! ale_linters#python#pyls#GetCommand(buffer) abort - let l:executable = ale_linters#python#pyls#GetExecutable(a:buffer) - - let l:exec_args = l:executable =~? 'pipenv$' - \ ? ' run pyls' - \ : '' - - return ale#Escape(l:executable) . l:exec_args -endfunction - -call ale#linter#Define('python', { -\ 'name': 'pyls', -\ 'lsp': 'stdio', -\ 'executable': function('ale_linters#python#pyls#GetExecutable'), -\ 'command': function('ale_linters#python#pyls#GetCommand'), -\ 'project_root': function('ale#python#FindProjectRoot'), -\ 'completion_filter': 'ale#completion#python#CompletionItemFilter', -\ 'lsp_config': {b -> ale#Var(b, 'python_pyls_config')}, -\}) diff --git a/sources_non_forked/ale/ale_linters/python/pylsp.vim b/sources_non_forked/ale/ale_linters/python/pylsp.vim new file mode 100644 index 00000000..537d1e74 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/python/pylsp.vim @@ -0,0 +1,43 @@ +" Author: aurieh +" Description: A language server for Python + +call ale#Set('python_pylsp_executable', 'pylsp') +call ale#Set('python_pylsp_options', '') +call ale#Set('python_pylsp_use_global', get(g:, 'ale_use_global_executables', 0)) +call ale#Set('python_pylsp_auto_pipenv', 0) +call ale#Set('python_pylsp_auto_poetry', 0) +call ale#Set('python_pylsp_config', {}) + +function! ale_linters#python#pylsp#GetExecutable(buffer) abort + if (ale#Var(a:buffer, 'python_auto_pipenv') || ale#Var(a:buffer, 'python_pylsp_auto_pipenv')) + \ && ale#python#PipenvPresent(a:buffer) + return 'pipenv' + endif + + if (ale#Var(a:buffer, 'python_auto_poetry') || ale#Var(a:buffer, 'python_pylsp_auto_poetry')) + \ && ale#python#PoetryPresent(a:buffer) + return 'poetry' + endif + + return ale#python#FindExecutable(a:buffer, 'python_pylsp', ['pylsp']) +endfunction + +function! ale_linters#python#pylsp#GetCommand(buffer) abort + let l:executable = ale_linters#python#pylsp#GetExecutable(a:buffer) + + let l:exec_args = l:executable =~? 'pipenv\|poetry$' + \ ? ' run pylsp' + \ : '' + + return ale#Escape(l:executable) . l:exec_args . ale#Pad(ale#Var(a:buffer, 'python_pylsp_options')) +endfunction + +call ale#linter#Define('python', { +\ 'name': 'pylsp', +\ 'lsp': 'stdio', +\ 'executable': function('ale_linters#python#pylsp#GetExecutable'), +\ 'command': function('ale_linters#python#pylsp#GetCommand'), +\ 'project_root': function('ale#python#FindProjectRoot'), +\ 'completion_filter': 'ale#completion#python#CompletionItemFilter', +\ 'lsp_config': {b -> ale#Var(b, 'python_pylsp_config')}, +\}) diff --git a/sources_non_forked/ale/ale_linters/python/pyre.vim b/sources_non_forked/ale/ale_linters/python/pyre.vim index 4edd80f7..d9b46763 100644 --- a/sources_non_forked/ale/ale_linters/python/pyre.vim +++ b/sources_non_forked/ale/ale_linters/python/pyre.vim @@ -4,6 +4,7 @@ call ale#Set('python_pyre_executable', 'pyre') call ale#Set('python_pyre_use_global', get(g:, 'ale_use_global_executables', 0)) call ale#Set('python_pyre_auto_pipenv', 0) +call ale#Set('python_pyre_auto_poetry', 0) function! ale_linters#python#pyre#GetExecutable(buffer) abort if (ale#Var(a:buffer, 'python_auto_pipenv') || ale#Var(a:buffer, 'python_pyre_auto_pipenv')) @@ -11,13 +12,18 @@ function! ale_linters#python#pyre#GetExecutable(buffer) abort return 'pipenv' endif + if (ale#Var(a:buffer, 'python_auto_poetry') || ale#Var(a:buffer, 'python_pyre_auto_poetry')) + \ && ale#python#PoetryPresent(a:buffer) + return 'poetry' + endif + return ale#python#FindExecutable(a:buffer, 'python_pyre', ['pyre']) endfunction function! ale_linters#python#pyre#GetCommand(buffer) abort let l:executable = ale_linters#python#pyre#GetExecutable(a:buffer) - let l:exec_args = l:executable =~? 'pipenv$' + let l:exec_args = l:executable =~? 'pipenv\|poetry$' \ ? ' run pyre persistent' \ : ' persistent' diff --git a/sources_non_forked/ale/ale_linters/python/vulture.vim b/sources_non_forked/ale/ale_linters/python/vulture.vim index d328d262..a7ba1860 100644 --- a/sources_non_forked/ale/ale_linters/python/vulture.vim +++ b/sources_non_forked/ale/ale_linters/python/vulture.vim @@ -6,7 +6,6 @@ call ale#Set('python_vulture_options', '') call ale#Set('python_vulture_use_global', get(g:, 'ale_use_global_executables', 0)) call ale#Set('python_vulture_change_directory', 1) - " The directory to change to before running vulture function! s:GetDir(buffer) abort let l:project_root = ale#python#FindProjectRoot(a:buffer) @@ -16,29 +15,28 @@ function! s:GetDir(buffer) abort \ : expand('#' . a:buffer . ':p:h') endfunction - function! ale_linters#python#vulture#GetExecutable(buffer) abort return ale#python#FindExecutable(a:buffer, 'python_vulture', ['vulture']) endfunction +function! ale_linters#python#vulture#GetCwd(buffer) abort + if !ale#Var(a:buffer, 'python_vulture_change_directory') + return '' + endif + + return s:GetDir(a:buffer) +endfunction function! ale_linters#python#vulture#GetCommand(buffer) abort - let l:change_dir = ale#Var(a:buffer, 'python_vulture_change_directory') - \ ? ale#path#CdString(s:GetDir(a:buffer)) - \ : '' - let l:executable = ale_linters#python#vulture#GetExecutable(a:buffer) - - let l:exec_args = l:executable =~? 'pipenv$' + let l:exec_args = l:executable =~? 'pipenv\|poetry$' \ ? ' run vulture' \ : '' - let l:lint_dest = ale#Var(a:buffer, 'python_vulture_change_directory') \ ? ' .' \ : ' %s' - return l:change_dir - \ . ale#Escape(l:executable) . l:exec_args + return ale#Escape(l:executable) . l:exec_args \ . ' ' \ . ale#Var(a:buffer, 'python_vulture_options') \ . l:lint_dest @@ -74,6 +72,7 @@ endfunction call ale#linter#Define('python', { \ 'name': 'vulture', \ 'executable': function('ale_linters#python#vulture#GetExecutable'), +\ 'cwd': function('ale_linters#python#vulture#GetCwd'), \ 'command': function('ale_linters#python#vulture#GetCommand'), \ 'callback': 'ale_linters#python#vulture#Handle', \ 'lint_file': 1, diff --git a/sources_non_forked/ale/ale_linters/r/languageserver.vim b/sources_non_forked/ale/ale_linters/r/languageserver.vim index febe66bd..bab869d1 100644 --- a/sources_non_forked/ale/ale_linters/r/languageserver.vim +++ b/sources_non_forked/ale/ale_linters/r/languageserver.vim @@ -1,4 +1,5 @@ " Author: Eric Zhao <21zhaoe@protonmail.com> +" Author: ourigen " Description: Implementation of the Language Server Protocol for R. call ale#Set('r_languageserver_cmd', 'languageserver::run()') @@ -7,7 +8,7 @@ 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) + return 'Rscript --no-save --no-restore --no-site-file --no-init-file -e ' . ale#Escape(l:cmd_string) endfunction function! ale_linters#r#languageserver#GetProjectRoot(buffer) abort diff --git a/sources_non_forked/ale/ale_linters/r/lintr.vim b/sources_non_forked/ale/ale_linters/r/lintr.vim index 3164c06f..339ad2b0 100644 --- a/sources_non_forked/ale/ale_linters/r/lintr.vim +++ b/sources_non_forked/ale/ale_linters/r/lintr.vim @@ -1,5 +1,6 @@ " Author: Michel Lang , w0rp , -" Fenner Macrae +" Fenner Macrae , +" ourigen " Description: This file adds support for checking R code with lintr. let g:ale_r_lintr_options = get(g:, 'ale_r_lintr_options', 'with_defaults()') @@ -21,14 +22,13 @@ function! ale_linters#r#lintr#GetCommand(buffer) abort let l:cmd_string = 'suppressPackageStartupMessages(library(lintr));' \ . l:lint_cmd - return ale#path#BufferCdString(a:buffer) - \ . 'Rscript --vanilla -e ' - \ . ale#Escape(l:cmd_string) . ' %t' + return 'Rscript --no-save --no-restore --no-site-file --no-init-file -e ' . ale#Escape(l:cmd_string) . ' %t' endfunction call ale#linter#Define('r', { \ 'name': 'lintr', \ 'executable': 'Rscript', +\ 'cwd': '%s:h', \ 'command': function('ale_linters#r#lintr#GetCommand'), \ 'callback': 'ale#handlers#gcc#HandleGCCFormat', \ 'output_stream': 'both', diff --git a/sources_non_forked/ale/ale_linters/racket/langserver.vim b/sources_non_forked/ale/ale_linters/racket/langserver.vim new file mode 100644 index 00000000..ec80ed7b --- /dev/null +++ b/sources_non_forked/ale/ale_linters/racket/langserver.vim @@ -0,0 +1,7 @@ +call ale#linter#Define('racket', { +\ 'name': 'racket_langserver', +\ 'lsp': 'stdio', +\ 'executable': 'racket', +\ 'command': '%e -l racket-langserver', +\ 'project_root': function('ale#racket#FindProjectRoot'), +\}) diff --git a/sources_non_forked/ale/ale_linters/racket/raco.vim b/sources_non_forked/ale/ale_linters/racket/raco.vim index e5ee4fb4..5b26065f 100644 --- a/sources_non_forked/ale/ale_linters/racket/raco.vim +++ b/sources_non_forked/ale/ale_linters/racket/raco.vim @@ -14,6 +14,7 @@ function! ale_linters#racket#raco#Handle(buffer, lines) abort for l:match in ale#util#GetMatches(a:lines, l:pattern) call add(l:output, { + \ 'filename': l:match[2], \ 'lnum': l:match[3] + 0, \ 'col': l:match[4] + 0, \ 'type': 'E', diff --git a/sources_non_forked/ale/ale_linters/rst/rstcheck.vim b/sources_non_forked/ale/ale_linters/rst/rstcheck.vim index 39e11d6e..e0cf0798 100644 --- a/sources_non_forked/ale/ale_linters/rst/rstcheck.vim +++ b/sources_non_forked/ale/ale_linters/rst/rstcheck.vim @@ -1,6 +1,5 @@ " Author: John Nduli https://github.com/jnduli " Description: Rstcheck for reStructuredText files -" function! ale_linters#rst#rstcheck#Handle(buffer, lines) abort " matches: 'bad_rst.rst:1: (SEVERE/4) Title overline & underline @@ -22,17 +21,11 @@ function! ale_linters#rst#rstcheck#Handle(buffer, lines) abort return l:output endfunction -function! ale_linters#rst#rstcheck#GetCommand(buffer) abort - return ale#path#BufferCdString(a:buffer) - \ . 'rstcheck' - \ . ' %t' -endfunction - - call ale#linter#Define('rst', { \ 'name': 'rstcheck', \ 'executable': 'rstcheck', -\ 'command': function('ale_linters#rst#rstcheck#GetCommand'), +\ 'cwd': '%s:h', +\ 'command': 'rstcheck %t', \ 'callback': 'ale_linters#rst#rstcheck#Handle', \ 'output_stream': 'both', \}) diff --git a/sources_non_forked/ale/ale_linters/ruby/sorbet.vim b/sources_non_forked/ale/ale_linters/ruby/sorbet.vim index cae0683c..c67e20cc 100644 --- a/sources_non_forked/ale/ale_linters/ruby/sorbet.vim +++ b/sources_non_forked/ale/ale_linters/ruby/sorbet.vim @@ -1,14 +1,17 @@ call ale#Set('ruby_sorbet_executable', 'srb') call ale#Set('ruby_sorbet_options', '') +call ale#Set('ruby_sorbet_enable_watchman', 0) function! ale_linters#ruby#sorbet#GetCommand(buffer) abort let l:executable = ale#Var(a:buffer, 'ruby_sorbet_executable') let l:options = ale#Var(a:buffer, 'ruby_sorbet_options') + let l:enable_watchman = ale#Var(a:buffer, 'ruby_sorbet_enable_watchman') return ale#ruby#EscapeExecutable(l:executable, 'srb') \ . ' tc' \ . (!empty(l:options) ? ' ' . l:options : '') - \ . ' --lsp --disable-watchman' + \ . ' --lsp' + \ . (l:enable_watchman ? '' : ' --disable-watchman') endfunction call ale#linter#Define('ruby', { diff --git a/sources_non_forked/ale/ale_linters/rust/analyzer.vim b/sources_non_forked/ale/ale_linters/rust/analyzer.vim index 3666ec03..77d946f7 100644 --- a/sources_non_forked/ale/ale_linters/rust/analyzer.vim +++ b/sources_non_forked/ale/ale_linters/rust/analyzer.vim @@ -17,7 +17,7 @@ endfunction call ale#linter#Define('rust', { \ 'name': 'analyzer', \ 'lsp': 'stdio', -\ 'lsp_config': {b -> ale#Var(b, 'rust_analyzer_config')}, +\ 'initialization_options': {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 3407abed..37fd10a8 100644 --- a/sources_non_forked/ale/ale_linters/rust/cargo.vim +++ b/sources_non_forked/ale/ale_linters/rust/cargo.vim @@ -23,6 +23,19 @@ function! ale_linters#rust#cargo#GetCargoExecutable(bufnr) abort endif endfunction +function! ale_linters#rust#cargo#GetCwd(buffer) abort + if ale#Var(a:buffer, 'rust_cargo_avoid_whole_workspace') + let l:nearest_cargo = ale#path#FindNearestFile(a:buffer, 'Cargo.toml') + let l:nearest_cargo_dir = fnamemodify(l:nearest_cargo, ':h') + + if l:nearest_cargo_dir isnot# '.' + return l:nearest_cargo_dir + endif + endif + + return '' +endfunction + function! ale_linters#rust#cargo#GetCommand(buffer, version) abort let l:use_check = ale#Var(a:buffer, 'rust_cargo_use_check') \ && ale#semver#GTE(a:version, [0, 17, 0]) @@ -42,18 +55,6 @@ function! ale_linters#rust#cargo#GetCommand(buffer, version) abort let l:include_features = ' --features ' . ale#Escape(l:include_features) endif - let l:avoid_whole_workspace = ale#Var(a:buffer, 'rust_cargo_avoid_whole_workspace') - let l:nearest_cargo_prefix = '' - - if l:avoid_whole_workspace - let l:nearest_cargo = ale#path#FindNearestFile(a:buffer, 'Cargo.toml') - let l:nearest_cargo_dir = fnamemodify(l:nearest_cargo, ':h') - - if l:nearest_cargo_dir isnot# '.' - let l:nearest_cargo_prefix = 'cd '. ale#Escape(l:nearest_cargo_dir) .' && ' - endif - endif - let l:default_feature_behavior = ale#Var(a:buffer, 'rust_cargo_default_feature_behavior') if l:default_feature_behavior is# 'all' @@ -81,7 +82,7 @@ function! ale_linters#rust#cargo#GetCommand(buffer, version) abort endif endif - return l:nearest_cargo_prefix . 'cargo ' + return 'cargo ' \ . l:subcommand \ . (l:use_all_targets ? ' --all-targets' : '') \ . (l:use_examples ? ' --examples' : '') @@ -96,6 +97,7 @@ endfunction call ale#linter#Define('rust', { \ 'name': 'cargo', \ 'executable': function('ale_linters#rust#cargo#GetCargoExecutable'), +\ 'cwd': function('ale_linters#rust#cargo#GetCwd'), \ 'command': {buffer -> ale#semver#RunWithVersionCheck( \ buffer, \ ale_linters#rust#cargo#GetCargoExecutable(buffer), diff --git a/sources_non_forked/ale/ale_linters/salt/salt_lint.vim b/sources_non_forked/ale/ale_linters/salt/salt_lint.vim new file mode 100644 index 00000000..47f66d83 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/salt/salt_lint.vim @@ -0,0 +1,33 @@ +" Author: Benjamin BINIER +" Description: salt-lint, saltstack linter + +call ale#Set('salt_salt_lint_executable', 'salt-lint') +call ale#Set('salt_salt_lint_options', '') + +function! ale_linters#salt#salt_lint#GetCommand(buffer) abort + return '%e' . ale#Pad(ale#Var(a:buffer, 'salt_salt_lint_options')) + \ . ' --json' +endfunction + +function! ale_linters#salt#salt_lint#Handle(buffer, lines) abort + let l:output = [] + + for l:error in ale#util#FuzzyJSONDecode(a:lines, []) + call add(l:output, { + \ 'lnum': l:error.linenumber + 0, + \ 'code': l:error.id + 0, + \ 'text': l:error.message, + \ 'type': l:error.severity is# 'HIGH' ? 'E' : 'W', + \}) + endfor + + return l:output +endfunction + +call ale#linter#Define('salt', { +\ 'name': 'salt_lint', +\ 'aliases': ['salt-lint'], +\ 'executable': {b -> ale#Var(b, 'salt_salt_lint_executable')}, +\ 'command': function('ale_linters#salt#salt_lint#GetCommand'), +\ 'callback': 'ale_linters#salt#salt_lint#Handle' +\}) diff --git a/sources_non_forked/ale/ale_linters/sass/sasslint.vim b/sources_non_forked/ale/ale_linters/sass/sasslint.vim index 17cd3667..ff396e68 100644 --- a/sources_non_forked/ale/ale_linters/sass/sasslint.vim +++ b/sources_non_forked/ale/ale_linters/sass/sasslint.vim @@ -5,7 +5,7 @@ call ale#Set('sass_sasslint_options', '') call ale#Set('sass_sasslint_use_global', get(g:, 'ale_use_global_executables', 0)) function! ale_linters#sass#sasslint#GetExecutable(buffer) abort - return ale#node#FindExecutable(a:buffer, 'sass_sasslint', [ + return ale#path#FindExecutable(a:buffer, 'sass_sasslint', [ \ 'node_modules/sass-lint/bin/sass-lint.js', \ 'node_modules/.bin/sass-lint', \]) diff --git a/sources_non_forked/ale/ale_linters/sass/stylelint.vim b/sources_non_forked/ale/ale_linters/sass/stylelint.vim index 7b14c6b4..22abef9b 100644 --- a/sources_non_forked/ale/ale_linters/sass/stylelint.vim +++ b/sources_non_forked/ale/ale_linters/sass/stylelint.vim @@ -5,7 +5,7 @@ call ale#Set('sass_stylelint_use_global', get(g:, 'ale_use_global_executables', call ale#linter#Define('sass', { \ 'name': 'stylelint', -\ 'executable': {b -> ale#node#FindExecutable(b, 'sass_stylelint', [ +\ 'executable': {b -> ale#path#FindExecutable(b, 'sass_stylelint', [ \ 'node_modules/.bin/stylelint', \ ])}, \ 'command': '%e --stdin-filename %s', diff --git a/sources_non_forked/ale/ale_linters/scss/sasslint.vim b/sources_non_forked/ale/ale_linters/scss/sasslint.vim index cf13546e..99027051 100644 --- a/sources_non_forked/ale/ale_linters/scss/sasslint.vim +++ b/sources_non_forked/ale/ale_linters/scss/sasslint.vim @@ -5,7 +5,7 @@ call ale#Set('scss_sasslint_options', '') call ale#Set('scss_sasslint_use_global', get(g:, 'ale_use_global_executables', 0)) function! ale_linters#scss#sasslint#GetExecutable(buffer) abort - return ale#node#FindExecutable(a:buffer, 'scss_sasslint', [ + return ale#path#FindExecutable(a:buffer, 'scss_sasslint', [ \ 'node_modules/sass-lint/bin/sass-lint.js', \ 'node_modules/.bin/sass-lint', \]) diff --git a/sources_non_forked/ale/ale_linters/scss/stylelint.vim b/sources_non_forked/ale/ale_linters/scss/stylelint.vim index b5b21536..fea4ea8f 100644 --- a/sources_non_forked/ale/ale_linters/scss/stylelint.vim +++ b/sources_non_forked/ale/ale_linters/scss/stylelint.vim @@ -11,7 +11,7 @@ endfunction call ale#linter#Define('scss', { \ 'name': 'stylelint', -\ 'executable': {b -> ale#node#FindExecutable(b, 'scss_stylelint', [ +\ 'executable': {b -> ale#path#FindExecutable(b, 'scss_stylelint', [ \ 'node_modules/.bin/stylelint', \ ])}, \ 'command': function('ale_linters#scss#stylelint#GetCommand'), diff --git a/sources_non_forked/ale/ale_linters/sh/language_server.vim b/sources_non_forked/ale/ale_linters/sh/language_server.vim index 5a3b0e9a..c6781584 100644 --- a/sources_non_forked/ale/ale_linters/sh/language_server.vim +++ b/sources_non_forked/ale/ale_linters/sh/language_server.vim @@ -6,7 +6,7 @@ call ale#Set('sh_language_server_executable', 'bash-language-server') call ale#Set('sh_language_server_use_global', get(g:, 'ale_use_global_executables', 0)) function! ale_linters#sh#language_server#GetExecutable(buffer) abort - return ale#node#FindExecutable(a:buffer, 'sh_language_server', [ + return ale#path#FindExecutable(a:buffer, 'sh_language_server', [ \ 'node_modules/.bin/bash-language-server', \]) endfunction diff --git a/sources_non_forked/ale/ale_linters/solidity/solc.vim b/sources_non_forked/ale/ale_linters/solidity/solc.vim index e4f220ac..28977083 100644 --- a/sources_non_forked/ale/ale_linters/solidity/solc.vim +++ b/sources_non_forked/ale/ale_linters/solidity/solc.vim @@ -1,34 +1,52 @@ " Author: Karl Bartel - http://karl.berlin/ " Description: Report solc compiler errors in Solidity code +call ale#Set('solidity_solc_executable', 'solc') call ale#Set('solidity_solc_options', '') function! ale_linters#solidity#solc#Handle(buffer, lines) abort " Matches patterns like the following: - " /path/to/file/file.sol:1:10: Error: Identifier not found or not unique. - let l:pattern = '\v^[^:]+:(\d+):(\d+): (Error|Warning): (.*)$' + " Error: Expected ';' but got '(' + " --> /path/to/file/file.sol:1:10:) + let l:pattern = '\v(Error|Warning): (.*)$' + let l:line_and_column_pattern = '\v\.sol:(\d+):(\d+):' let l:output = [] - for l:match in ale#util#GetMatches(a:lines, l:pattern) - let l:isError = l:match[3] is? 'error' - call add(l:output, { - \ 'lnum': l:match[1] + 0, - \ 'col': l:match[2] + 0, - \ 'text': l:match[4], - \ 'type': l:isError ? 'E' : 'W', - \}) + for l:line in a:lines + let l:match = matchlist(l:line, l:pattern) + + if len(l:match) == 0 + let l:match = matchlist(l:line, l:line_and_column_pattern) + + if len(l:match) > 0 + let l:index = len(l:output) - 1 + let l:output[l:index]['lnum'] = l:match[1] + 0 + let l:output[l:index]['col'] = l:match[2] + 0 + endif + else + let l:isError = l:match[1] is? 'Error' + + call add(l:output, { + \ 'lnum': 0, + \ 'col': 0, + \ 'text': l:match[2], + \ 'type': l:isError ? 'E' : 'W', + \}) + endif endfor return l:output endfunction function! ale_linters#solidity#solc#GetCommand(buffer) abort - return 'solc' . ale#Pad(ale#Var(a:buffer, 'solidity_solc_options')) . ' %s' + let l:executable = ale#Var(a:buffer, 'solidity_solc_executable') + + return l:executable . ale#Pad(ale#Var(a:buffer, 'solidity_solc_options')) . ' %s' endfunction call ale#linter#Define('solidity', { \ 'name': 'solc', -\ 'executable': 'solc', +\ 'executable': {b -> ale#Var(b, 'solidity_solc_executable')}, \ 'command': function('ale_linters#solidity#solc#GetCommand'), \ 'callback': 'ale_linters#solidity#solc#Handle', \ 'output_stream': 'stderr', diff --git a/sources_non_forked/ale/ale_linters/solidity/solhint.vim b/sources_non_forked/ale/ale_linters/solidity/solhint.vim index 8ea33e07..505bd5bb 100644 --- a/sources_non_forked/ale/ale_linters/solidity/solhint.vim +++ b/sources_non_forked/ale/ale_linters/solidity/solhint.vim @@ -1,29 +1,12 @@ -" Author: Franco Victorio - https://github.com/fvictorio +" Authors: Franco Victorio - https://github.com/fvictorio, Henrique Barcelos +" https://github.com/hbarcelos " Description: Report errors in Solidity code with solhint -function! ale_linters#solidity#solhint#Handle(buffer, lines) abort - " Matches patterns like the following: - " /path/to/file/file.sol: line 1, col 10, Error - 'addOne' is defined but never used. (no-unused-vars) - let l:pattern = '\v^[^:]+: line (\d+), col (\d+), (Error|Warning) - (.*) \((.*)\)$' - let l:output = [] - - for l:match in ale#util#GetMatches(a:lines, l:pattern) - let l:isError = l:match[3] is? 'error' - call add(l:output, { - \ 'lnum': l:match[1] + 0, - \ 'col': l:match[2] + 0, - \ 'text': l:match[4], - \ 'code': l:match[5], - \ 'type': l:isError ? 'E' : 'W', - \}) - endfor - - return l:output -endfunction - call ale#linter#Define('solidity', { \ 'name': 'solhint', -\ 'executable': 'solhint', -\ 'command': 'solhint --formatter compact %t', -\ 'callback': 'ale_linters#solidity#solhint#Handle', +\ 'output_stream': 'both', +\ 'executable': function('ale#handlers#solhint#GetExecutable'), +\ 'cwd': function('ale#handlers#solhint#GetCwd'), +\ 'command': function('ale#handlers#solhint#GetCommand'), +\ 'callback': 'ale#handlers#solhint#Handle', \}) diff --git a/sources_non_forked/ale/ale_linters/spec/rpmlint.vim b/sources_non_forked/ale/ale_linters/spec/rpmlint.vim index 92ef4d63..5594e3b8 100644 --- a/sources_non_forked/ale/ale_linters/spec/rpmlint.vim +++ b/sources_non_forked/ale/ale_linters/spec/rpmlint.vim @@ -29,11 +29,18 @@ call ale#Set('spec_rpmlint_executable', 'rpmlint') call ale#Set('spec_rpmlint_options', '') -function! ale_linters#spec#rpmlint#GetCommand(buffer) abort +function! ale_linters#spec#rpmlint#GetCommand(buffer, version) abort + if ale#semver#GTE(a:version, [2, 0, 0]) + " The -o/--option flag was removed in version 2.0.0 + let l:version_dependent_args = '' + else + let l:version_dependent_args = ' -o "NetworkEnabled False"' + endif + return '%e' \ . ale#Pad(ale#Var(a:buffer, 'spec_rpmlint_options')) - \ . ' -o "NetworkEnabled False"' \ . ' -v' + \ . l:version_dependent_args \ . ' %t' endfunction @@ -73,6 +80,11 @@ endfunction call ale#linter#Define('spec', { \ 'name': 'rpmlint', \ 'executable': {b -> ale#Var(b, 'spec_rpmlint_executable')}, -\ 'command': function('ale_linters#spec#rpmlint#GetCommand'), +\ 'command': {buffer -> ale#semver#RunWithVersionCheck( +\ buffer, +\ ale#Var(buffer, 'spec_rpmlint_executable'), +\ '%e --version', +\ function('ale_linters#spec#rpmlint#GetCommand'), +\ )}, \ 'callback': 'ale_linters#spec#rpmlint#Handle', \}) diff --git a/sources_non_forked/ale/ale_linters/stylus/stylelint.vim b/sources_non_forked/ale/ale_linters/stylus/stylelint.vim index ce6f9426..b60e38ed 100644 --- a/sources_non_forked/ale/ale_linters/stylus/stylelint.vim +++ b/sources_non_forked/ale/ale_linters/stylus/stylelint.vim @@ -12,7 +12,7 @@ endfunction call ale#linter#Define('stylus', { \ 'name': 'stylelint', -\ 'executable': {b -> ale#node#FindExecutable(b, 'stylus_stylelint', [ +\ 'executable': {b -> ale#path#FindExecutable(b, 'stylus_stylelint', [ \ 'node_modules/.bin/stylelint', \ ])}, \ 'command': function('ale_linters#stylus#stylelint#GetCommand'), diff --git a/sources_non_forked/ale/ale_linters/sugarss/stylelint.vim b/sources_non_forked/ale/ale_linters/sugarss/stylelint.vim index 6c705e46..879ff0ca 100644 --- a/sources_non_forked/ale/ale_linters/sugarss/stylelint.vim +++ b/sources_non_forked/ale/ale_linters/sugarss/stylelint.vim @@ -13,7 +13,7 @@ endfunction call ale#linter#Define('sugarss', { \ 'name': 'stylelint', -\ 'executable': {b -> ale#node#FindExecutable(b, 'sugarss_stylelint', [ +\ 'executable': {b -> ale#path#FindExecutable(b, 'sugarss_stylelint', [ \ 'node_modules/.bin/stylelint', \ ])}, \ 'command': function('ale_linters#sugarss#stylelint#GetCommand'), diff --git a/sources_non_forked/ale/ale_linters/svelte/svelteserver.vim b/sources_non_forked/ale/ale_linters/svelte/svelteserver.vim new file mode 100644 index 00000000..2200b582 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/svelte/svelteserver.vim @@ -0,0 +1,21 @@ +" Author: Joakim Repomaa +" Description: Svelte Language Server integration for ALE + +call ale#Set('svelte_svelteserver_executable', 'svelteserver') +call ale#Set('svelte_svelteserver_use_global', get(g:, 'ale_use_global_executables', 0)) + +function! ale_linters#svelte#svelteserver#GetProjectRoot(buffer) abort + let l:package_path = ale#path#FindNearestFile(a:buffer, 'package.json') + + return !empty(l:package_path) ? fnamemodify(l:package_path, ':h') : '' +endfunction + +call ale#linter#Define('svelte', { +\ 'name': 'svelteserver', +\ 'lsp': 'stdio', +\ 'executable': {b -> ale#path#FindExecutable(b, 'svelte_svelteserver', [ +\ 'node_modules/.bin/svelteserver', +\ ])}, +\ 'command': '%e --stdio', +\ 'project_root': function('ale_linters#svelte#svelteserver#GetProjectRoot'), +\}) diff --git a/sources_non_forked/ale/ale_linters/swift/appleswiftformat.vim b/sources_non_forked/ale/ale_linters/swift/appleswiftformat.vim new file mode 100644 index 00000000..4c61764d --- /dev/null +++ b/sources_non_forked/ale/ale_linters/swift/appleswiftformat.vim @@ -0,0 +1,43 @@ +" Authors: Klaas Pieter Annema , bosr +" Description: Support for swift-format https://github.com/apple/swift-format + +function! ale_linters#swift#appleswiftformat#GetLinterCommand(buffer) abort + let l:command_args = ale#swift#GetAppleSwiftFormatCommand(a:buffer) . ' lint %t' + let l:config_args = ale#swift#GetAppleSwiftFormatConfigArgs(a:buffer) + + if l:config_args isnot# '' + let l:command_args = l:command_args . ' ' . l:config_args + endif + + return l:command_args +endfunction + +function! ale_linters#swift#appleswiftformat#Handle(buffer, lines) abort + " Matches the typical output of swift-format, that is 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': 'apple-swift-format', +\ 'executable': function('ale#swift#GetAppleSwiftFormatExecutable'), +\ 'command': function('ale_linters#swift#appleswiftformat#GetLinterCommand'), +\ 'output_stream': 'stderr', +\ 'language': 'swift', +\ 'callback': 'ale_linters#swift#appleswiftformat#Handle' +\}) diff --git a/sources_non_forked/ale/ale_linters/swift/swiftformat.vim b/sources_non_forked/ale/ale_linters/swift/swiftformat.vim deleted file mode 100644 index 2504511a..00000000 --- a/sources_non_forked/ale/ale_linters/swift/swiftformat.vim +++ /dev/null @@ -1,62 +0,0 @@ -" 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/swift/swiftlint.vim b/sources_non_forked/ale/ale_linters/swift/swiftlint.vim index 237c45d3..d08c68f6 100644 --- a/sources_non_forked/ale/ale_linters/swift/swiftlint.vim +++ b/sources_non_forked/ale/ale_linters/swift/swiftlint.vim @@ -5,7 +5,7 @@ call ale#Set('swift_swiftlint_executable', 'swiftlint') call ale#Set('swift_swiftlint_use_global', get(g:, 'ale_use_global_executables', 0)) function! ale_linters#swift#swiftlint#GetExecutable(buffer) abort - return ale#node#FindExecutable(a:buffer, 'swift_swiftlint', [ + return ale#path#FindExecutable(a:buffer, 'swift_swiftlint', [ \ 'Pods/SwiftLint/swiftlint', \ 'ios/Pods/SwiftLint/swiftlint', \ 'swiftlint', diff --git a/sources_non_forked/ale/ale_linters/systemd/systemd_analyze.vim b/sources_non_forked/ale/ale_linters/systemd/systemd_analyze.vim new file mode 100644 index 00000000..64eef8cf --- /dev/null +++ b/sources_non_forked/ale/ale_linters/systemd/systemd_analyze.vim @@ -0,0 +1,18 @@ +function! ale_linters#systemd#systemd_analyze#Handle(buffer, lines) abort + return ale#util#MapMatches(a:lines, '\v(.+):([0-9]+): (.+)', {match -> { + \ 'lnum': str2nr(match[2]), + \ 'col': 1, + \ 'type': 'W', + \ 'text': match[3], + \}}) +endfunction + +call ale#linter#Define('systemd', { +\ 'name': 'systemd_analyze', +\ 'aliases': ['systemd-analyze'], +\ 'executable': 'systemd-analyze', +\ 'command': 'SYSTEMD_LOG_COLOR=0 %e --user verify %s', +\ 'callback': 'ale_linters#systemd#systemd_analyze#Handle', +\ 'output_stream': 'both', +\ 'lint_file': 1, +\}) diff --git a/sources_non_forked/ale/ale_linters/terraform/terraform.vim b/sources_non_forked/ale/ale_linters/terraform/terraform.vim index 0429cb7a..cf134460 100644 --- a/sources_non_forked/ale/ale_linters/terraform/terraform.vim +++ b/sources_non_forked/ale/ale_linters/terraform/terraform.vim @@ -9,30 +9,44 @@ endfunction function! ale_linters#terraform#terraform#GetCommand(buffer) abort return ale#Escape(ale_linters#terraform#terraform#GetExecutable(a:buffer)) - \ . ' fmt -no-color --check=true -' + \ . ' validate -no-color -json ' +endfunction + +function! ale_linters#terraform#terraform#GetType(severity) abort + if a:severity is? 'warning' + return 'W' + endif + + return 'E' +endfunction + +function! ale_linters#terraform#terraform#GetDetail(error) abort + return get(a:error, 'detail', get(a:error, 'summary', '')) endfunction function! ale_linters#terraform#terraform#Handle(buffer, lines) abort - let l:head = '^Error running fmt: In : ' let l:output = [] - let l:patterns = [ - \ l:head.'At \(\d\+\):\(\d\+\): \(.*\)$', - \ l:head.'\(.*\)$' - \] - for l:match in ale#util#GetMatches(a:lines, l:patterns) - if len(l:match[2]) > 0 + let l:errors = ale#util#FuzzyJSONDecode(a:lines, {'diagnostics': []}) + let l:dir = expand('#' . a:buffer . ':p:h') + let l:file = expand('#' . a:buffer . ':p') + + for l:error in l:errors['diagnostics'] + if has_key(l:error, 'range') call add(l:output, { - \ 'lnum': str2nr(l:match[1]), - \ 'col': str2nr(l:match[2]), - \ 'text': l:match[3], - \ 'type': 'E', + \ 'filename': ale#path#GetAbsPath(l:dir, l:error['range']['filename']), + \ 'lnum': l:error['range']['start']['line'], + \ 'col': l:error['range']['start']['column'], + \ 'text': ale_linters#terraform#terraform#GetDetail(l:error), + \ 'type': ale_linters#terraform#terraform#GetType(l:error['severity']), \}) else call add(l:output, { - \ 'lnum': line('$'), - \ 'text': l:match[1], - \ 'type': 'E', + \ 'filename': l:file, + \ 'lnum': 0, + \ 'col': 0, + \ 'text': ale_linters#terraform#terraform#GetDetail(l:error), + \ 'type': ale_linters#terraform#terraform#GetType(l:error['severity']), \}) endif endfor @@ -42,7 +56,7 @@ endfunction call ale#linter#Define('terraform', { \ 'name': 'terraform', -\ 'output_stream': 'stderr', +\ 'output_stream': 'stdout', \ 'executable': function('ale_linters#terraform#terraform#GetExecutable'), \ 'command': function('ale_linters#terraform#terraform#GetCommand'), \ 'callback': 'ale_linters#terraform#terraform#Handle', diff --git a/sources_non_forked/ale/ale_linters/terraform/terraform_ls.vim b/sources_non_forked/ale/ale_linters/terraform/terraform_ls.vim new file mode 100644 index 00000000..ab35126e --- /dev/null +++ b/sources_non_forked/ale/ale_linters/terraform/terraform_ls.vim @@ -0,0 +1,38 @@ +" Author: Horacio Sanson +" Description: terraform-ls integration for ALE (cf. https://github.com/hashicorp/terraform-ls) + +call ale#Set('terraform_terraform_executable', 'terraform') +call ale#Set('terraform_ls_executable', 'terraform-ls') +call ale#Set('terraform_ls_options', '') + +function! ale_linters#terraform#terraform_ls#GetTerraformExecutable(buffer) abort + let l:terraform_executable = ale#Var(a:buffer, 'terraform_terraform_executable') + + if(ale#path#IsAbsolute(l:terraform_executable)) + return '-tf-exec ' . l:terraform_executable + endif + + return '' +endfunction + +function! ale_linters#terraform#terraform_ls#GetCommand(buffer) abort + return '%e' + \ . ale#Pad('serve') + \ . ale#Pad(ale_linters#terraform#terraform_ls#GetTerraformExecutable(a:buffer)) + \ . ale#Pad(ale#Var(a:buffer, 'terraform_ls_options')) +endfunction + +function! ale_linters#terraform#terraform_ls#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_ls', +\ 'lsp': 'stdio', +\ 'executable': {b -> ale#Var(b, 'terraform_ls_executable')}, +\ 'command': function('ale_linters#terraform#terraform_ls#GetCommand'), +\ 'project_root': function('ale_linters#terraform#terraform_ls#GetProjectRoot'), +\ 'language': 'terraform', +\}) diff --git a/sources_non_forked/ale/ale_linters/terraform/tflint.vim b/sources_non_forked/ale/ale_linters/terraform/tflint.vim index f57ee6b6..86b5b74a 100644 --- a/sources_non_forked/ale/ale_linters/terraform/tflint.vim +++ b/sources_non_forked/ale/ale_linters/terraform/tflint.vim @@ -91,7 +91,7 @@ function! ale_linters#terraform#tflint#GetCommand(buffer) abort let l:cmd .= ' ' . l:opts endif - let l:cmd .= ' -f json %t' + let l:cmd .= ' -f json' return l:cmd endfunction @@ -99,6 +99,7 @@ endfunction call ale#linter#Define('terraform', { \ 'name': 'tflint', \ 'executable': {b -> ale#Var(b, 'terraform_tflint_executable')}, +\ 'cwd': '%s:h', \ 'command': function('ale_linters#terraform#tflint#GetCommand'), \ 'callback': 'ale_linters#terraform#tflint#Handle', \}) diff --git a/sources_non_forked/ale/ale_linters/tex/texlab.vim b/sources_non_forked/ale/ale_linters/tex/texlab.vim index 5ead74b4..0794bf51 100644 --- a/sources_non_forked/ale/ale_linters/tex/texlab.vim +++ b/sources_non_forked/ale/ale_linters/tex/texlab.vim @@ -1,11 +1,14 @@ " Author: Ricardo Liang +" Author: ourigen " Description: Texlab language server (Rust rewrite) call ale#Set('tex_texlab_executable', 'texlab') call ale#Set('tex_texlab_options', '') function! ale_linters#tex#texlab#GetProjectRoot(buffer) abort - return '' + 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#tex#texlab#GetCommand(buffer) abort diff --git a/sources_non_forked/ale/ale_linters/thrift/thriftcheck.vim b/sources_non_forked/ale/ale_linters/thrift/thriftcheck.vim new file mode 100644 index 00000000..7b8cbee1 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/thrift/thriftcheck.vim @@ -0,0 +1,46 @@ +" Author: Jon Parise + +call ale#Set('thrift_thriftcheck_executable', 'thriftcheck') +call ale#Set('thrift_thriftcheck_options', '') + +function! ale_linters#thrift#thriftcheck#GetCommand(buffer) abort + return '%e' + \ . ale#Pad(ale#Var(a:buffer, 'thrift_thriftcheck_options')) + \ . ' --stdin-filename %s' + \ . ' %t' +endfunction + +function! ale_linters#thrift#thriftcheck#Handle(buffer, lines) abort + " Matches lines like the following: + " + " file.thrift:1:1:error: "py" namespace must match "^idl\\." (namespace.pattern) + " file.thrift:3:5:warning: 64-bit integer constant -2147483649 may not work in all languages (int.64bit) + let l:pattern = '\v^[a-zA-Z]?:?[^:]+:(\d+):(\d+):(\l+): (.*) \((.*)\)$' + + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + if l:match[3] is# 'warning' + let l:type = 'W' + else + let l:type = 'E' + endif + + call add(l:output, { + \ 'lnum': l:match[1] + 0, + \ 'col': l:match[2] + 0, + \ 'type': l:type, + \ 'text': l:match[4], + \ 'code': l:match[5], + \}) + endfor + + return l:output +endfunction + +call ale#linter#Define('thrift', { +\ 'name': 'thriftcheck', +\ 'executable': {b -> ale#Var(b, 'thrift_thriftcheck_executable')}, +\ 'command': function('ale_linters#thrift#thriftcheck#GetCommand'), +\ 'callback': 'ale_linters#thrift#thriftcheck#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/typescript/deno.vim b/sources_non_forked/ale/ale_linters/typescript/deno.vim new file mode 100644 index 00000000..f47fac7a --- /dev/null +++ b/sources_non_forked/ale/ale_linters/typescript/deno.vim @@ -0,0 +1,12 @@ +" Author: Mohammed Chelouti - https://github.com/motato1 +" Arnold Chand +" Description: Deno lsp linter for TypeScript files. + +call ale#linter#Define('typescript', { +\ 'name': 'deno', +\ 'lsp': 'stdio', +\ 'executable': function('ale#handlers#deno#GetExecutable'), +\ 'command': '%e lsp', +\ 'project_root': function('ale#handlers#deno#GetProjectRoot'), +\ 'initialization_options': function('ale#handlers#deno#GetInitializationOptions'), +\}) diff --git a/sources_non_forked/ale/ale_linters/typescript/eslint.vim b/sources_non_forked/ale/ale_linters/typescript/eslint.vim index 33a21440..eaeac307 100644 --- a/sources_non_forked/ale/ale_linters/typescript/eslint.vim +++ b/sources_non_forked/ale/ale_linters/typescript/eslint.vim @@ -4,6 +4,7 @@ call ale#linter#Define('typescript', { \ 'name': 'eslint', \ 'executable': function('ale#handlers#eslint#GetExecutable'), +\ 'cwd': function('ale#handlers#eslint#GetCwd'), \ 'command': function('ale#handlers#eslint#GetCommand'), \ 'callback': 'ale#handlers#eslint#HandleJSON', \}) diff --git a/sources_non_forked/ale/ale_linters/typescript/standard.vim b/sources_non_forked/ale/ale_linters/typescript/standard.vim index da8f14eb..1d524a10 100644 --- a/sources_non_forked/ale/ale_linters/typescript/standard.vim +++ b/sources_non_forked/ale/ale_linters/typescript/standard.vim @@ -6,7 +6,7 @@ call ale#Set('typescript_standard_use_global', get(g:, 'ale_use_global_executabl call ale#Set('typescript_standard_options', '') function! ale_linters#typescript#standard#GetExecutable(buffer) abort - return ale#node#FindExecutable(a:buffer, 'typescript_standard', [ + return ale#path#FindExecutable(a:buffer, 'typescript_standard', [ \ 'node_modules/standardx/bin/cmd.js', \ 'node_modules/standard/bin/cmd.js', \ 'node_modules/.bin/standard', diff --git a/sources_non_forked/ale/ale_linters/typescript/tslint.vim b/sources_non_forked/ale/ale_linters/typescript/tslint.vim index f70c2e45..886a3cd4 100644 --- a/sources_non_forked/ale/ale_linters/typescript/tslint.vim +++ b/sources_non_forked/ale/ale_linters/typescript/tslint.vim @@ -59,8 +59,7 @@ function! ale_linters#typescript#tslint#GetCommand(buffer) abort \ ? ' -r ' . ale#Escape(l:tslint_rules_dir) \ : '' - return ale#path#BufferCdString(a:buffer) - \ . ale#Escape(ale#handlers#tslint#GetExecutable(a:buffer)) + return ale#Escape(ale#handlers#tslint#GetExecutable(a:buffer)) \ . ' --format json' \ . l:tslint_config_option \ . l:tslint_rules_option @@ -70,6 +69,7 @@ endfunction call ale#linter#Define('typescript', { \ 'name': 'tslint', \ 'executable': function('ale#handlers#tslint#GetExecutable'), +\ 'cwd': '%s:h', \ 'command': function('ale_linters#typescript#tslint#GetCommand'), \ 'callback': 'ale_linters#typescript#tslint#Handle', \}) diff --git a/sources_non_forked/ale/ale_linters/typescript/tsserver.vim b/sources_non_forked/ale/ale_linters/typescript/tsserver.vim index 4726e40d..d97becca 100644 --- a/sources_non_forked/ale/ale_linters/typescript/tsserver.vim +++ b/sources_non_forked/ale/ale_linters/typescript/tsserver.vim @@ -8,7 +8,7 @@ call ale#Set('typescript_tsserver_use_global', get(g:, 'ale_use_global_executabl call ale#linter#Define('typescript', { \ 'name': 'tsserver', \ 'lsp': 'tsserver', -\ 'executable': {b -> ale#node#FindExecutable(b, 'typescript_tsserver', [ +\ 'executable': {b -> ale#path#FindExecutable(b, 'typescript_tsserver', [ \ '.yarn/sdks/typescript/bin/tsserver', \ 'node_modules/.bin/tsserver', \ ])}, diff --git a/sources_non_forked/ale/ale_linters/typescript/xo.vim b/sources_non_forked/ale/ale_linters/typescript/xo.vim index 0a3a717b..6f4ee50c 100644 --- a/sources_non_forked/ale/ale_linters/typescript/xo.vim +++ b/sources_non_forked/ale/ale_linters/typescript/xo.vim @@ -1,23 +1,6 @@ -call ale#Set('typescript_xo_executable', 'xo') -call ale#Set('typescript_xo_use_global', get(g:, 'ale_use_global_executables', 0)) -call ale#Set('typescript_xo_options', '') - -function! ale_linters#typescript#xo#GetExecutable(buffer) abort - return ale#node#FindExecutable(a:buffer, 'typescript_xo', [ - \ 'node_modules/.bin/xo', - \]) -endfunction - -function! ale_linters#typescript#xo#GetCommand(buffer) abort - return ale#Escape(ale_linters#typescript#xo#GetExecutable(a:buffer)) - \ . ale#Pad(ale#Var(a:buffer, 'typescript_xo_options')) - \ . ' --reporter json --stdin --stdin-filename %s' -endfunction - -" xo uses eslint and the output format is the same call ale#linter#Define('typescript', { \ 'name': 'xo', -\ 'executable': function('ale_linters#typescript#xo#GetExecutable'), -\ 'command': function('ale_linters#typescript#xo#GetCommand'), -\ 'callback': 'ale#handlers#eslint#HandleJSON', +\ 'executable': function('ale#handlers#xo#GetExecutable'), +\ 'command': function('ale#handlers#xo#GetLintCommand'), +\ 'callback': 'ale#handlers#xo#HandleJSON', \}) diff --git a/sources_non_forked/ale/ale_linters/v/v.vim b/sources_non_forked/ale/ale_linters/v/v.vim new file mode 100644 index 00000000..afa98c56 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/v/v.vim @@ -0,0 +1,82 @@ +" Author: fiatjaf +" Description: v build for V files + +call ale#Set('v_v_executable', 'v') +call ale#Set('v_v_options', '') + +function! ale_linters#v#v#GetCommand(buffer) abort + let l:options = ale#Var(a:buffer, 'v_v_options') + + " Run v in local directory with relative path + let l:command = ale#Var(a:buffer, 'v_v_executable') + \ . ale#Pad(l:options) + \ . ' .' . ' -o /tmp/vim-ale-v' + + return l:command +endfunction + +function! ale_linters#v#v#Handler(buffer, lines) abort + let l:dir = expand('#' . a:buffer . ':p:h') + let l:output = [] + + " Matches patterns like the following: + " + " ./const.v:4:3: warning: const names cannot contain uppercase letters, use snake_case instead + " 2 | + " 3 | const ( + " 4 | BUTTON_TEXT = 'OK' + " | ~~~~~~~~~~~ + " 5 | ) + " ./main.v:4:8: warning: module 'os' is imported but never used + " 2 | + " 3 | import ui + " 4 | import os + " | ~~ + " 5 | + " 6 | const ( + " ./main.v:20:10: error: undefined ident: `win_widt` + " 18 | mut app := &App{} + " 19 | app.window = ui.window({ + " 20 | width: win_widt + " | ~~~~~~~~ + " 21 | height: win_height + " 22 | title: 'Counter' + let l:current = {} + + for l:line in a:lines + " matches basic error description + let l:match = matchlist(l:line, + \ '\([^:]\+\):\([^:]\+\):\([^:]\+\): \([^:]\+\): \(.*\)') + + if !empty(l:match) + let l:current = { + \ 'filename': ale#path#GetAbsPath(l:dir, l:match[1]), + \ 'lnum': l:match[2] + 0, + \ 'col': l:match[3] + 0, + \ 'text': l:match[5], + \ 'type': l:match[4] is# 'error' ? 'E' : 'W', + \} + call add(l:output, l:current) + continue + endif + + " try to get information about the ending column + let l:tildematch = matchstr(l:line, '\~\+') + + if !empty(l:tildematch) + let l:current['end_col'] = l:current['col'] + len(l:tildematch) + endif + endfor + + return l:output +endfunction + +call ale#linter#Define('v', { +\ 'name': 'v', +\ 'aliases': [], +\ 'executable': {b -> ale#Var(b, 'v_v_executable')}, +\ 'command': function('ale_linters#v#v#GetCommand'), +\ 'output_stream': 'stderr', +\ 'callback': 'ale_linters#v#v#Handler', +\ 'lint_file': 1, +\}) diff --git a/sources_non_forked/ale/ale_linters/vala/vala_lint.vim b/sources_non_forked/ale/ale_linters/vala/vala_lint.vim new file mode 100644 index 00000000..7f8a566a --- /dev/null +++ b/sources_non_forked/ale/ale_linters/vala/vala_lint.vim @@ -0,0 +1,66 @@ +" Author: Atsuya Takagi +" Description: A linter for Vala using Vala-Lint. + +call ale#Set('vala_vala_lint_config_filename', 'vala-lint.conf') +call ale#Set('vala_vala_lint_executable', 'io.elementary.vala-lint') + +function! ale_linters#vala#vala_lint#GetExecutable(buffer) abort + return ale#Var(a:buffer, 'vala_vala_lint_executable') +endfunction + +function! ale_linters#vala#vala_lint#GetCommand(buffer) abort + let l:command = ale_linters#vala#vala_lint#GetExecutable(a:buffer) + + let l:config_filename = ale#Var(a:buffer, 'vala_vala_lint_config_filename') + let l:config_path = ale#path#FindNearestFile(a:buffer, l:config_filename) + + if !empty(l:config_path) + let l:command .= ' -c ' . l:config_path + endif + + return l:command . ' %s' +endfunction + +function! ale_linters#vala#vala_lint#Handle(buffer, lines) abort + let l:pattern = '^\s*\(\d\+\)\.\(\d\+\)\s\+\(error\|warn\)\s\+\(.\+\)\s\([A-Za-z0-9_\-]\+\)' + let l:output = [] + + for l:line in a:lines + " remove color escape sequences since vala-lint doesn't support + " output without colors + let l:cleaned_line = substitute(l:line, '\e\[[0-9;]\+[mK]', '', 'g') + let l:match = matchlist(l:cleaned_line, l:pattern) + + if len(l:match) == 0 + continue + endif + + let l:refined_type = l:match[3] is# 'warn' ? 'W' : 'E' + let l:cleaned_text = substitute(l:match[4], '^\s*\(.\{-}\)\s*$', '\1', '') + + let l:lnum = l:match[1] + 0 + let l:column = l:match[2] + 0 + let l:type = l:refined_type + let l:text = l:cleaned_text + let l:code = l:match[5] + + call add(l:output, { + \ 'lnum': l:lnum, + \ 'col': l:column, + \ 'text': l:text, + \ 'type': l:type, + \ 'code': l:code, + \}) + endfor + + return l:output +endfunction + +call ale#linter#Define('vala', { +\ 'name': 'vala_lint', +\ 'output_stream': 'stdout', +\ 'executable': function('ale_linters#vala#vala_lint#GetExecutable'), +\ 'command': function('ale_linters#vala#vala_lint#GetCommand'), +\ 'callback': 'ale_linters#vala#vala_lint#Handle', +\ 'lint_file': 1, +\}) diff --git a/sources_non_forked/ale/ale_linters/verilog/verilator.vim b/sources_non_forked/ale/ale_linters/verilog/verilator.vim index 029dd4c9..006e310d 100644 --- a/sources_non_forked/ale/ale_linters/verilog/verilator.vim +++ b/sources_non_forked/ale/ale_linters/verilog/verilator.vim @@ -7,16 +7,11 @@ if !exists('g:ale_verilog_verilator_options') endif function! ale_linters#verilog#verilator#GetCommand(buffer) abort - let l:filename = ale#util#Tempname() . '_verilator_linted.v' - - " Create a special filename, so we can detect it in the handler. - call ale#command#ManageFile(a:buffer, l:filename) - let l:lines = getbufline(a:buffer, 1, '$') - call ale#util#Writefile(a:buffer, l:lines, l:filename) - + " the path to the current file is systematically added to the search path return 'verilator --lint-only -Wall -Wno-DECLFILENAME ' + \ . '-I%s:h ' \ . ale#Var(a:buffer, 'verilog_verilator_options') .' ' - \ . ale#Escape(l:filename) + \ . '%t' endfunction function! ale_linters#verilog#verilator#Handle(buffer, lines) abort @@ -34,7 +29,7 @@ function! ale_linters#verilog#verilator#Handle(buffer, lines) abort " " 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:pattern = '^%\(Warning\|Error\)[^:]*:\s*\([^:]\+\):\(\d\+\):\(\d\+\)\?:\? \(.\+\)$' let l:output = [] for l:match in ale#util#GetMatches(a:lines, l:pattern) @@ -42,17 +37,14 @@ function! ale_linters#verilog#verilator#Handle(buffer, lines) abort \ 'lnum': str2nr(l:match[3]), \ 'text': l:match[5], \ 'type': l:match[1] is# 'Error' ? 'E' : 'W', + \ 'filename': l:match[2], \} 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, l:item) - endif + call add(l:output, l:item) endfor return l:output diff --git a/sources_non_forked/ale/ale_linters/verilog/yosys.vim b/sources_non_forked/ale/ale_linters/verilog/yosys.vim new file mode 100644 index 00000000..29657755 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/verilog/yosys.vim @@ -0,0 +1,42 @@ +" Author: Nathan Sharp +" Description: Yosys for Verilog files + +call ale#Set('verilog_yosys_executable', 'yosys') +call ale#Set('verilog_yosys_options', '-Q -T -p ''read_verilog %s''') + +function! ale_linters#verilog#yosys#GetCommand(buffer) abort + return '%e ' . ale#Var(a:buffer, 'verilog_yosys_options') . ' 2>&1' +endfunction + +function! ale_linters#verilog#yosys#Handle(buffer, lines) abort + let l:output = [] + let l:path = fnamemodify(bufname(a:buffer), ':p') + + for l:match in ale#util#GetMatches(a:lines, '^\([^:]\+\):\(\d\+\): \(WARNING\|ERROR\): \(.\+\)$') + call add(l:output, { + \ 'lnum': str2nr(l:match[2]), + \ 'text': l:match[4], + \ 'type': l:match[3][0], + \ 'filename': l:match[1], + \}) + endfor + + for l:match in ale#util#GetMatches(a:lines, '^\(Warning\|ERROR\): \(.\+\)$') + call add(l:output, { + \ 'lnum': 1, + \ 'text': l:match[2], + \ 'type': l:match[1][0], + \}) + endfor + + return l:output +endfunction + +call ale#linter#Define('verilog', { +\ 'name': 'yosys', +\ 'output_stream': 'stdout', +\ 'executable': {b -> ale#Var(b, 'verilog_yosys_executable')}, +\ 'command': function('ale_linters#verilog#yosys#GetCommand'), +\ 'callback': 'ale_linters#verilog#yosys#Handle', +\ 'lint_file': 1, +\}) diff --git a/sources_non_forked/ale/ale_linters/vim/ale_custom_linting_rules.vim b/sources_non_forked/ale/ale_linters/vim/ale_custom_linting_rules.vim index 822eb30a..5ca2f149 100644 --- a/sources_non_forked/ale/ale_linters/vim/ale_custom_linting_rules.vim +++ b/sources_non_forked/ale/ale_linters/vim/ale_custom_linting_rules.vim @@ -22,16 +22,20 @@ function! s:GetALEProjectDir(buffer) abort return ale#path#Dirname(ale#path#Dirname(ale#path#Dirname(l:executable))) endfunction -function! ale_linters#vim#ale_custom_linting_rules#GetCommand(buffer) abort - let l:dir = s:GetALEProjectDir(a:buffer) +function! ale_linters#vim#ale_custom_linting_rules#GetCwd(buffer) abort + let l:executable = ale_linters#vim#ale_custom_linting_rules#GetExecutable(a:buffer) + return ale#path#Dirname(ale#path#Dirname(ale#path#Dirname(l:executable))) +endfunction + +function! ale_linters#vim#ale_custom_linting_rules#GetCommand(buffer) abort let l:temp_dir = ale#command#CreateDirectory(a:buffer) let l:temp_file = l:temp_dir . '/example.vim' let l:lines = getbufline(a:buffer, 1, '$') call ale#util#Writefile(a:buffer, l:lines, l:temp_file) - return ale#path#CdString(l:dir) . '%e ' . ale#Escape(l:temp_dir) + return '%e ' . ale#Escape(l:temp_dir) endfunction function! ale_linters#vim#ale_custom_linting_rules#Handle(buffer, lines) abort @@ -59,6 +63,7 @@ endfunction call ale#linter#Define('vim', { \ 'name': 'ale_custom_linting_rules', \ 'executable': function('ale_linters#vim#ale_custom_linting_rules#GetExecutable'), +\ 'cwd': function('ale_linters#vim#ale_custom_linting_rules#GetCwd'), \ 'command': function('ale_linters#vim#ale_custom_linting_rules#GetCommand'), \ 'callback': 'ale_linters#vim#ale_custom_linting_rules#Handle', \ 'read_buffer': 0, diff --git a/sources_non_forked/ale/ale_linters/vim/vimls.vim b/sources_non_forked/ale/ale_linters/vim/vimls.vim index 26014d66..7003eb04 100644 --- a/sources_non_forked/ale/ale_linters/vim/vimls.vim +++ b/sources_non_forked/ale/ale_linters/vim/vimls.vim @@ -52,7 +52,7 @@ 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', [ +\ 'executable': {b -> ale#path#FindExecutable(b, 'vim_vimls', [ \ 'node_modules/.bin/vim-language-server', \ ])}, \ 'command': '%e --stdio', diff --git a/sources_non_forked/ale/ale_linters/vue/vls.vim b/sources_non_forked/ale/ale_linters/vue/vls.vim index ac451f3c..4bd75286 100644 --- a/sources_non_forked/ale/ale_linters/vue/vls.vim +++ b/sources_non_forked/ale/ale_linters/vue/vls.vim @@ -13,7 +13,7 @@ endfunction call ale#linter#Define('vue', { \ 'name': 'vls', \ 'lsp': 'stdio', -\ 'executable': {b -> ale#node#FindExecutable(b, 'vue_vls', [ +\ 'executable': {b -> ale#path#FindExecutable(b, 'vue_vls', [ \ 'node_modules/.bin/vls', \ ])}, \ 'command': '%e --stdio', diff --git a/sources_non_forked/ale/ale_linters/yaml/circleci.vim b/sources_non_forked/ale/ale_linters/yaml/circleci.vim new file mode 100644 index 00000000..3df61459 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/yaml/circleci.vim @@ -0,0 +1,35 @@ +function! ale_linters#yaml#circleci#Handle(buffer, lines) abort + let l:match_index = -1 + let l:output = [] + + for l:index in range(len(a:lines)) + let l:line = a:lines[l:index] + + if l:line =~? 'Error: ERROR IN CONFIG FILE:' + let l:match_index = l:index + 1 + break + endif + endfor + + if l:match_index > 0 + return [{ + \ 'type': 'E', + \ 'lnum': 1, + \ 'text': a:lines[l:match_index], + \ 'detail': join(a:lines[l:match_index :], "\n"), + \}] + endif + + return [] +endfunction + +" The circleci validate requires network requests, so we'll only run it when +" files are saved to prevent the server from being hammered. +call ale#linter#Define('yaml', { +\ 'name': 'circleci', +\ 'executable': {b -> expand('#' . b . ':p') =~? '\.circleci' ? 'circleci' : ''}, +\ 'command': 'circleci config validate - < %s', +\ 'callback': 'ale_linters#yaml#circleci#Handle', +\ 'output_stream': 'stderr', +\ 'lint_file': 1, +\}) diff --git a/sources_non_forked/ale/ale_linters/yaml/spectral.vim b/sources_non_forked/ale/ale_linters/yaml/spectral.vim new file mode 100644 index 00000000..13654f06 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/yaml/spectral.vim @@ -0,0 +1,14 @@ +" Author: t2h5 +" Description: Integration of Stoplight Spectral CLI with ALE. + +call ale#Set('yaml_spectral_executable', 'spectral') +call ale#Set('yaml_spectral_use_global', get(g:, 'ale_use_global_executables', 0)) + +call ale#linter#Define('yaml', { +\ 'name': 'spectral', +\ 'executable': {b -> ale#path#FindExecutable(b, 'yaml_spectral', [ +\ 'node_modules/.bin/spectral', +\ ])}, +\ 'command': '%e lint --ignore-unknown-format -q -f text %t', +\ 'callback': 'ale#handlers#spectral#HandleSpectralOutput' +\}) diff --git a/sources_non_forked/ale/ale_linters/yaml/swaglint.vim b/sources_non_forked/ale/ale_linters/yaml/swaglint.vim index 1f140e37..7fc2b430 100644 --- a/sources_non_forked/ale/ale_linters/yaml/swaglint.vim +++ b/sources_non_forked/ale/ale_linters/yaml/swaglint.vim @@ -32,7 +32,7 @@ endfunction call ale#linter#Define('yaml', { \ 'name': 'swaglint', -\ 'executable': {b -> ale#node#FindExecutable(b, 'yaml_swaglint', [ +\ 'executable': {b -> ale#path#FindExecutable(b, 'yaml_swaglint', [ \ 'node_modules/.bin/swaglint', \ ])}, \ 'command': '%e -r compact --stdin', diff --git a/sources_non_forked/ale/ale_linters/yaml/yamllint.vim b/sources_non_forked/ale/ale_linters/yaml/yamllint.vim index bedb7bf1..39011df1 100644 --- a/sources_non_forked/ale/ale_linters/yaml/yamllint.vim +++ b/sources_non_forked/ale/ale_linters/yaml/yamllint.vim @@ -3,48 +3,9 @@ call ale#Set('yaml_yamllint_executable', 'yamllint') call ale#Set('yaml_yamllint_options', '') -function! ale_linters#yaml#yamllint#GetCommand(buffer) abort - return '%e' . ale#Pad(ale#Var(a:buffer, 'yaml_yamllint_options')) - \ . ' -f parsable %t' -endfunction - -function! ale_linters#yaml#yamllint#Handle(buffer, lines) abort - " Matches patterns line the following: - " something.yaml:1:1: [warning] missing document start "---" (document-start) - " something.yml:2:1: [error] syntax error: expected the node content, but found '' - let l:pattern = '\v^.*:(\d+):(\d+): \[(error|warning)\] (.+)$' - let l:output = [] - - for l:match in ale#util#GetMatches(a:lines, l:pattern) - let l:item = { - \ 'lnum': l:match[1] + 0, - \ 'col': l:match[2] + 0, - \ 'text': l:match[4], - \ 'type': l:match[3] is# 'error' ? 'E' : 'W', - \} - - let l:code_match = matchlist(l:item.text, '\v^(.+) \(([^)]+)\)$') - - if !empty(l:code_match) - if l:code_match[2] is# 'trailing-spaces' - \&& !ale#Var(a:buffer, 'warn_about_trailing_whitespace') - " Skip warnings for trailing whitespace if the option is off. - continue - endif - - let l:item.text = l:code_match[1] - let l:item.code = l:code_match[2] - endif - - call add(l:output, l:item) - endfor - - return l:output -endfunction - call ale#linter#Define('yaml', { \ 'name': 'yamllint', \ 'executable': {b -> ale#Var(b, 'yaml_yamllint_executable')}, -\ 'command': function('ale_linters#yaml#yamllint#GetCommand'), -\ 'callback': 'ale_linters#yaml#yamllint#Handle', +\ 'command': function('ale#handlers#yamllint#GetCommand'), +\ 'callback': 'ale#handlers#yamllint#Handle', \}) diff --git a/sources_non_forked/ale/autoload/ale.vim b/sources_non_forked/ale/autoload/ale.vim index 3f59a6a4..97483b45 100644 --- a/sources_non_forked/ale/autoload/ale.vim +++ b/sources_non_forked/ale/autoload/ale.vim @@ -157,7 +157,7 @@ function! ale#Queue(delay, ...) abort endif endfunction -let s:current_ale_version = [3, 0, 0] +let s:current_ale_version = [3, 1, 0] " A function used to check for ALE features in files outside of the project. function! ale#Has(feature) abort diff --git a/sources_non_forked/ale/autoload/ale/ant.vim b/sources_non_forked/ale/autoload/ale/ant.vim index 7d02484e..b6d4217f 100644 --- a/sources_non_forked/ale/autoload/ale/ant.vim +++ b/sources_non_forked/ale/autoload/ale/ant.vim @@ -23,19 +23,23 @@ function! ale#ant#FindExecutable(buffer) abort 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. +" Given a buffer number, get a working directory and command to print the +" classpath of the root project. +" +" Returns an empty string for the command if Ant is not detected. function! ale#ant#BuildClasspathCommand(buffer) abort let l:executable = ale#ant#FindExecutable(a:buffer) - let l:project_root = ale#ant#FindProjectRoot(a:buffer) - if !empty(l:executable) && !empty(l:project_root) - return ale#path#CdString(l:project_root) - \ . ale#Escape(l:executable) - \ . ' classpath' - \ . ' -S' - \ . ' -q' + if !empty(l:executable) + let l:project_root = ale#ant#FindProjectRoot(a:buffer) + + if !empty(l:project_root) + return [ + \ l:project_root, + \ ale#Escape(l:executable) .' classpath -S -q' + \] + endif endif - return '' + return ['', ''] endfunction diff --git a/sources_non_forked/ale/autoload/ale/assert.vim b/sources_non_forked/ale/autoload/ale/assert.vim index 934fcaa8..141cd0f2 100644 --- a/sources_non_forked/ale/autoload/ale/assert.vim +++ b/sources_non_forked/ale/autoload/ale/assert.vim @@ -52,6 +52,36 @@ function! s:ProcessDeferredCommands(initial_result) abort return l:command endfunction +function! s:ProcessDeferredCwds(initial_command, initial_cwd) abort + let l:result = a:initial_command + let l:last_cwd = v:null + let l:command_index = 0 + let l:cwd_list = [] + + while ale#command#IsDeferred(l:result) + call add(l:cwd_list, l:result.cwd) + + if get(g:, 'ale_run_synchronously_emulate_commands') + " Don't run commands, but simulate the results. + let l:Callback = g:ale_run_synchronously_callbacks[0] + let l:output = get(s:command_output, l:command_index, []) + call l:Callback(0, l:output) + unlet g:ale_run_synchronously_callbacks + + let l:command_index += 1 + else + " Run the commands in the shell, synchronously. + call ale#test#FlushJobs() + endif + + let l:result = l:result.value + endwhile + + call add(l:cwd_list, a:initial_cwd is v:null ? l:last_cwd : a:initial_cwd) + + return l:cwd_list +endfunction + " Load the currently loaded linter for a test case, and check that the command " matches the given string. function! ale#assert#Linter(expected_executable, expected_command) abort @@ -85,6 +115,38 @@ function! ale#assert#Linter(expected_executable, expected_command) abort \ [l:executable, l:command] endfunction +function! ale#assert#LinterCwd(expected_cwd) abort + let l:buffer = bufnr('') + let l:linter = s:GetLinter() + + let l:initial_cwd = ale#linter#GetCwd(l:buffer, l:linter) + call ale#command#SetCwd(l:buffer, l:initial_cwd) + + let l:cwd = s:ProcessDeferredCwds( + \ ale#linter#GetCommand(l:buffer, l:linter), + \ l:initial_cwd, + \) + + call ale#command#ResetCwd(l:buffer) + + if type(a:expected_cwd) isnot v:t_list + let l:cwd = l:cwd[-1] + endif + + AssertEqual a:expected_cwd, l:cwd +endfunction + +function! ale#assert#FixerCwd(expected_cwd) abort + let l:buffer = bufnr('') + let l:cwd = s:ProcessDeferredCwds(s:FixerFunction(l:buffer), v:null) + + if type(a:expected_cwd) isnot v:t_list + let l:cwd = l:cwd[-1] + endif + + AssertEqual a:expected_cwd, l:cwd +endfunction + function! ale#assert#Fixer(expected_result) abort let l:buffer = bufnr('') let l:result = s:ProcessDeferredCommands(s:FixerFunction(l:buffer)) @@ -107,8 +169,21 @@ function! ale#assert#LinterNotExecuted() abort let l:buffer = bufnr('') let l:linter = s:GetLinter() let l:executable = ale#linter#GetExecutable(l:buffer, l:linter) + let l:executed = 1 - Assert empty(l:executable), "The linter will be executed when it shouldn't be" + if !empty(l:executable) + let l:command = ale#linter#GetCommand(l:buffer, l:linter) + + if type(l:command) is v:t_list + let l:command = l:command[-1] + endif + + let l:executed = !empty(l:command) + else + let l:executed = 0 + endif + + Assert !l:executed, "The linter will be executed when it shouldn't be" endfunction function! ale#assert#LSPOptions(expected_options) abort @@ -153,6 +228,7 @@ endfunction function! ale#assert#SetUpLinterTestCommands() abort command! -nargs=+ GivenCommandOutput :call ale#assert#GivenCommandOutput() + command! -nargs=+ AssertLinterCwd :call ale#assert#LinterCwd() command! -nargs=+ AssertLinter :call ale#assert#Linter() command! -nargs=0 AssertLinterNotExecuted :call ale#assert#LinterNotExecuted() command! -nargs=+ AssertLSPOptions :call ale#assert#LSPOptions() @@ -164,10 +240,35 @@ endfunction function! ale#assert#SetUpFixerTestCommands() abort command! -nargs=+ GivenCommandOutput :call ale#assert#GivenCommandOutput() + command! -nargs=+ AssertFixerCwd :call ale#assert#FixerCwd() command! -nargs=+ AssertFixer :call ale#assert#Fixer() command! -nargs=0 AssertFixerNotExecuted :call ale#assert#FixerNotExecuted() endfunction +function! ale#assert#ResetVariables(filetype, name, ...) abort + " If the suffix of the option names format is different, an additional + " argument can be used for that instead. + if a:0 > 1 + throw 'Too many arguments' + endif + + let l:option_suffix = get(a:000, 0, a:name) + let l:prefix = 'ale_' . a:filetype . '_' + \ . substitute(l:option_suffix, '-', '_', 'g') + let l:filter_expr = 'v:val[: len(l:prefix) - 1] is# l:prefix' + + " Save and clear linter variables. + " We'll load the runtime file to reset them to defaults. + for l:key in filter(keys(g:), l:filter_expr) + execute 'Save g:' . l:key + unlet g:[l:key] + endfor + + for l:key in filter(keys(b:), l:filter_expr) + unlet b:[l:key] + endfor +endfunction + " A dummy function for making sure this module is loaded. function! ale#assert#SetUpLinterTest(filetype, name) abort " Set up a marker so ALE doesn't create real random temporary filenames. @@ -177,35 +278,22 @@ function! ale#assert#SetUpLinterTest(filetype, name) abort call ale#linter#Reset() call ale#linter#PreventLoading(a:filetype) - let l:prefix = 'ale_' . a:filetype . '_' . a:name - let b:filter_expr = 'v:val[: len(l:prefix) - 1] is# l:prefix' + Save g:ale_root + let g:ale_root = {} - Save g:ale_lsp_root - let g:ale_lsp_root = {} + Save b:ale_root + unlet! b:ale_root - Save b:ale_lsp_root - unlet! b:ale_lsp_root + call ale#assert#ResetVariables(a:filetype, a:name) Save g:ale_c_build_dir unlet! g:ale_c_build_dir - - " Save and clear linter variables. - " We'll load the runtime file to reset them to defaults. - for l:key in filter(keys(g:), b:filter_expr) - execute 'Save g:' . l:key - unlet g:[l:key] - endfor - unlet! b:ale_c_build_dir - for l:key in filter(keys(b:), b:filter_expr) - unlet b:[l:key] - endfor - execute 'runtime ale_linters/' . a:filetype . '/' . a:name . '.vim' if !exists('g:dir') - call ale#test#SetDirectory('/testplugin/test/command_callback') + call ale#test#SetDirectory('/testplugin/test/linter') endif call ale#assert#SetUpLinterTestCommands() @@ -226,6 +314,10 @@ function! ale#assert#TearDownLinterTest() abort delcommand GivenCommandOutput endif + if exists(':AssertLinterCwd') + delcommand AssertLinterCwd + endif + if exists(':AssertLinter') delcommand AssertLinter endif @@ -281,18 +373,7 @@ function! ale#assert#SetUpFixerTest(filetype, name, ...) abort let s:FixerFunction = function(l:function_name) let l:option_suffix = get(a:000, 0, a:name) - let l:prefix = 'ale_' . a:filetype . '_' - \ . substitute(l:option_suffix, '-', '_', 'g') - let b:filter_expr = 'v:val[: len(l:prefix) - 1] is# l:prefix' - - for l:key in filter(keys(g:), b:filter_expr) - execute 'Save g:' . l:key - unlet g:[l:key] - endfor - - for l:key in filter(keys(b:), b:filter_expr) - unlet b:[l:key] - endfor + call ale#assert#ResetVariables(a:filetype, a:name, l:option_suffix) execute 'runtime autoload/ale/fixers/' . substitute(a:name, '-', '_', 'g') . '.vim' @@ -329,6 +410,10 @@ function! ale#assert#TearDownFixerTest() abort delcommand GivenCommandOutput endif + if exists(':AssertFixerCwd') + delcommand AssertFixerCwd + endif + if exists(':AssertFixer') delcommand AssertFixer endif diff --git a/sources_non_forked/ale/autoload/ale/c.vim b/sources_non_forked/ale/autoload/ale/c.vim index cff53125..e729aec8 100644 --- a/sources_non_forked/ale/autoload/ale/c.vim +++ b/sources_non_forked/ale/autoload/ale/c.vim @@ -151,7 +151,6 @@ function! ale#c#ParseCFlags(path_prefix, should_quote, raw_arguments) abort \ || 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' @@ -181,6 +180,7 @@ function! ale#c#ParseCFlags(path_prefix, should_quote, raw_arguments) abort " 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' + \ || l:option is# '-include' || l:option is# '-imacros' 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 @@ -490,7 +490,7 @@ function! ale#c#GetCFlags(buffer, output) abort endif endif - if s:CanParseMakefile(a:buffer) && !empty(a:output) && !empty(l:cflags) + if empty(l:cflags) && s:CanParseMakefile(a:buffer) && !empty(a:output) let l:cflags = ale#c#ParseCFlagsFromMakeOutput(a:buffer, a:output) endif @@ -505,19 +505,25 @@ function! ale#c#GetMakeCommand(buffer) abort if s:CanParseMakefile(a:buffer) let l:path = ale#path#FindNearestFile(a:buffer, 'Makefile') + if empty(l:path) + let l:path = ale#path#FindNearestFile(a:buffer, 'GNUmakefile') + endif + 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' : '') + return [ + \ fnamemodify(l:path, ':h'), + \ 'make -n' . (l:always_make ? ' --always-make' : ''), + \] endif endif - return '' + return ['', ''] endfunction function! ale#c#RunMakeCommand(buffer, Callback) abort - let l:command = ale#c#GetMakeCommand(a:buffer) + let [l:cwd, l:command] = ale#c#GetMakeCommand(a:buffer) if empty(l:command) return a:Callback(a:buffer, []) @@ -527,6 +533,7 @@ function! ale#c#RunMakeCommand(buffer, Callback) abort \ a:buffer, \ l:command, \ {b, output -> a:Callback(a:buffer, output)}, + \ {'cwd': l:cwd}, \) endfunction diff --git a/sources_non_forked/ale/autoload/ale/code_action.vim b/sources_non_forked/ale/autoload/ale/code_action.vim index 69d40933..917190be 100644 --- a/sources_non_forked/ale/autoload/ale/code_action.vim +++ b/sources_non_forked/ale/autoload/ale/code_action.vim @@ -71,6 +71,11 @@ function! ale#code_action#ApplyChanges(filename, changes, should_save) abort if l:buffer > 0 let l:lines = getbufline(l:buffer, 1, '$') + + " Add empty line if there's trailing newline, like readfile() does. + if getbufvar(l:buffer, '&eol') + let l:lines += [''] + endif else let l:lines = readfile(a:filename, 'b') endif @@ -89,62 +94,82 @@ function! ale#code_action#ApplyChanges(filename, changes, should_save) abort let l:end_column = l:code_edit.end.offset let l:text = l:code_edit.newText - " Adjust the ends according to previous edits. - if l:end_line > len(l:lines) - let l:end_line_len = 0 - else - let l:end_line_len = len(l:lines[l:end_line - 1]) - endif - let l:insertions = split(l:text, '\n', 1) - if l:line is 1 - " Same logic as for column below. Vimscript's slice [:-1] will not - " be an empty list. - let l:start = [] - else - let l:start = l:lines[: l:line - 2] + " Fix invalid columns + let l:column = l:column > 0 ? l:column : 1 + let l:end_column = l:end_column > 0 ? l:end_column : 1 + + " Clamp start to BOF + if l:line < 1 + let [l:line, l:column] = [1, 1] 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 + " Clamp start to EOF + if l:line > len(l:lines) || l:line == len(l:lines) && l:column > len(l:lines[-1]) + 1 + let [l:line, l:column] = [len(l:lines), len(l:lines[-1]) + 1] + " Special case when start is after EOL + elseif l:line < len(l:lines) && l:column > len(l:lines[l:line - 1]) + 1 + let [l:line, l:column] = [l:line + 1, 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. - let l:middle = [l:insertions[0]] - else - let l:middle = [l:lines[l:line - 1][: l:column - 2] . l:insertions[0]] + " Adjust end: clamp if invalid and/or adjust if we moved start + if l:end_line < l:line || l:end_line == l:line && l:end_column < l:column + let [l:end_line, l:end_column] = [l:line, l:column] endif - call extend(l:middle, l:insertions[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 :] + " Clamp end to EOF + if l:end_line > len(l:lines) || l:end_line == len(l:lines) && l:end_column > len(l:lines[-1]) + 1 + let [l:end_line, l:end_column] = [len(l:lines), len(l:lines[-1]) + 1] + " Special case when end is after EOL + elseif l:end_line < len(l:lines) && l:end_column > len(l:lines[l:end_line - 1]) + 1 + let [l:end_line, l:end_column] = [l:end_line + 1, 1] endif + " Careful, [:-1] is not an empty list + let l:start = l:line is 1 ? [] : l:lines[: l:line - 2] + let l:middle = l:column is 1 ? [''] : [l:lines[l:line - 1][: l:column - 2]] + + let l:middle[-1] .= l:insertions[0] + let l:middle += l:insertions[1:] + let l:middle[-1] .= l:lines[l:end_line - 1][l:end_column - 1 :] + + let l:end_line_len = len(l:lines[l:end_line - 1]) 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:column_offset = len(l:middle[-1]) - l:end_line_len - let l:pos = s:UpdateCursor(l:pos, - \ [l:line, l:column], - \ [l:end_line, l:end_column], - \ [l:current_line_offset, l:column_offset]) + " Keep cursor where it was (if outside of changes) or move it after + " the changed text (if inside), but don't touch it when the change + " spans the entire buffer, in which case we have no clue and it's + " better to not do anything. + if l:line isnot 1 || l:column isnot 1 + \|| l:end_line < l:lines_before_change + \|| l:end_line == l:lines_before_change && l:end_column <= l:end_line_len + let l:pos = s:UpdateCursor(l:pos, + \ [l:line, l:column], + \ [l:end_line, l:end_column], + \ [l:current_line_offset, l:column_offset]) + endif endfor - if l:lines[-1] is# '' + if l:buffer > 0 + " Make sure ale#util#{Writefile,SetBufferContents} add trailing + " newline if and only if it should be added. + if l:lines[-1] is# '' && getbufvar(l:buffer, '&eol') + call remove(l:lines, -1) + else + call setbufvar(l:buffer, '&eol', 0) + endif + elseif exists('+fixeol') && &fixeol && l:lines[-1] is# '' + " Not in buffer, ale#util#Writefile can't check &eol and always adds + " newline if &fixeol: remove to prevent double trailing newline. call remove(l:lines, -1) endif - if a:should_save + if a:should_save || l:buffer < 0 call ale#util#Writefile(l:buffer, l:lines, a:filename) else call ale#util#SetBufferContents(l:buffer, l:lines) @@ -222,6 +247,10 @@ function! s:UpdateCursor(cursor, start, end, offset) abort endfunction function! ale#code_action#GetChanges(workspace_edit) abort + if a:workspace_edit is v:null + return {} + endif + let l:changes = {} if has_key(a:workspace_edit, 'changes') && !empty(a:workspace_edit.changes) diff --git a/sources_non_forked/ale/autoload/ale/codefix.vim b/sources_non_forked/ale/autoload/ale/codefix.vim index 69bf36fa..4a78063b 100644 --- a/sources_non_forked/ale/autoload/ale/codefix.vim +++ b/sources_non_forked/ale/autoload/ale/codefix.vim @@ -261,7 +261,10 @@ function! ale#codefix#HandleLSPResponse(conn_id, response) abort " 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]')) + call l:MenuCallback( + \ l:data, + \ map(copy(l:result), '[''lsp'', v:val]') + \) return endif diff --git a/sources_non_forked/ale/autoload/ale/command.vim b/sources_non_forked/ale/autoload/ale/command.vim index 8f497169..c9dc8d94 100644 --- a/sources_non_forked/ale/autoload/ale/command.vim +++ b/sources_non_forked/ale/autoload/ale/command.vim @@ -7,6 +7,9 @@ if !exists('s:buffer_data') let s:buffer_data = {} endif +" The regular expression used for formatting filenames with modifiers. +let s:path_format_regex = '\v\%s(%(:h|:t|:r|:e)*)' + " Used to get the data in tests. function! ale#command#GetData() abort return deepcopy(s:buffer_data) @@ -26,6 +29,19 @@ function! ale#command#InitData(buffer) abort endif endfunction +" Set the cwd for commands that are about to run. +" Used internally. +function! ale#command#SetCwd(buffer, cwd) abort + call ale#command#InitData(a:buffer) + let s:buffer_data[a:buffer].cwd = a:cwd +endfunction + +function! ale#command#ResetCwd(buffer) abort + if has_key(s:buffer_data, a:buffer) + let s:buffer_data[a:buffer].cwd = v:null + endif +endfunction + function! ale#command#ManageFile(buffer, file) abort call ale#command#InitData(a:buffer) call add(s:buffer_data[a:buffer].file_list, a:file) @@ -151,6 +167,24 @@ function! s:FormatFilename(filename, mappings, modifiers) abort return ale#Escape(l:filename) endfunction +" Produce a command prefix to check to a particular directory for a command. +" %s format markers with filename-modifiers can be used as the directory, and +" will be returned verbatim for formatting in paths relative to files. +function! ale#command#CdString(directory) abort + let l:match = matchstrpos(a:directory, s:path_format_regex) + " Do not escape the directory here if it's a valid format string. + " This allows us to use sequences like %s:h, %s:h:h, etc. + let l:directory = l:match[1:] == [0, len(a:directory)] + \ ? a:directory + \ : ale#Escape(a:directory) + + if has('win32') + return 'cd /d ' . l:directory . ' && ' + endif + + return 'cd ' . l:directory . ' && ' +endfunction + " Given a command string, replace every... " %s -> with the current filename " %t -> with the name of an unused file in a temporary directory @@ -161,11 +195,16 @@ function! ale#command#FormatCommand( \ command, \ pipe_file_if_needed, \ input, +\ cwd, \ mappings, \) abort let l:temporary_file = '' let l:command = a:command + if !empty(a:cwd) + let l:command = ale#command#CdString(a:cwd) . l:command + endif + " First replace all uses of %%, used for literal percent characters, " with an ugly string. let l:command = substitute(l:command, '%%', '<>', 'g') @@ -181,7 +220,7 @@ function! ale#command#FormatCommand( let l:filename = fnamemodify(bufname(a:buffer), ':p') let l:command = substitute( \ l:command, - \ '\v\%s(%(:h|:t|:r|:e)*)', + \ s:path_format_regex, \ '\=s:FormatFilename(l:filename, a:mappings, submatch(1))', \ 'g' \) @@ -279,9 +318,16 @@ function! s:ExitCallback(buffer, line_list, Callback, data) abort let l:result = a:data.result let l:result.value = l:value - if get(l:result, 'result_callback', v:null) isnot v:null - call call(l:result.result_callback, [l:value]) - endif + " Set the default cwd for this buffer in this call stack. + call ale#command#SetCwd(a:buffer, l:result.cwd) + + try + if get(l:result, 'result_callback', v:null) isnot v:null + call call(l:result.result_callback, [l:value]) + endif + finally + call ale#command#ResetCwd(a:buffer) + endtry endfunction function! ale#command#Run(buffer, command, Callback, ...) abort @@ -293,6 +339,13 @@ function! ale#command#Run(buffer, command, Callback, ...) abort let l:output_stream = get(l:options, 'output_stream', 'stdout') let l:line_list = [] + let l:cwd = get(l:options, 'cwd', v:null) + + if l:cwd is v:null + " Default the working directory to whatever it was for the last + " command run in the chain. + let l:cwd = get(get(s:buffer_data, a:buffer, {}), 'cwd', v:null) + endif let [l:temporary_file, l:command, l:file_created] = ale#command#FormatCommand( \ a:buffer, @@ -300,6 +353,7 @@ function! ale#command#Run(buffer, command, Callback, ...) abort \ a:command, \ get(l:options, 'read_buffer', 0), \ get(l:options, 'input', v:null), + \ l:cwd, \ get(l:options, 'filename_mappings', []), \) let l:command = ale#job#PrepareCommand(a:buffer, l:command) @@ -366,10 +420,14 @@ function! ale#command#Run(buffer, command, Callback, ...) abort " The `_deferred_job_id` is used for both checking the type of object, and " for checking the job ID and status. " + " The cwd is kept and used as the default value for the next command in + " the chain. + " " The original command here is used in tests. let l:result = { \ '_deferred_job_id': l:job_id, \ 'executable': get(l:options, 'executable', ''), + \ 'cwd': l:cwd, \ 'command': a:command, \} diff --git a/sources_non_forked/ale/autoload/ale/completion.vim b/sources_non_forked/ale/autoload/ale/completion.vim index 39bfc094..5237288e 100644 --- a/sources_non_forked/ale/autoload/ale/completion.vim +++ b/sources_non_forked/ale/autoload/ale/completion.vim @@ -269,13 +269,19 @@ function! s:ReplaceCompletionOptions(source) abort let b:ale_old_completeopt = &l:completeopt endif - if &l:completeopt =~# 'preview' - let &l:completeopt = 'menu,menuone,preview,noselect,noinsert' - elseif &l:completeopt =~# 'popup' - let &l:completeopt = 'menu,menuone,popup,noselect,noinsert' - else - let &l:completeopt = 'menu,menuone,noselect,noinsert' - endif + let l:opt_list = split(&l:completeopt, ',') + " The menu and noinsert options must be set, or automatic completion + " will be annoying. + let l:new_opt_list = ['menu', 'menuone', 'noinsert'] + + " Permit some other completion options, provided users have set them. + for l:opt in ['preview', 'popup', 'noselect'] + if index(l:opt_list, l:opt) >= 0 + call add(l:new_opt_list, l:opt) + endif + endfor + + let &l:completeopt = join(l:new_opt_list, ',') endif endfunction @@ -614,6 +620,8 @@ function! ale#completion#ParseLSPCompletions(response) abort \ 'kind': ale#completion#GetCompletionSymbols(get(l:item, 'kind', '')), \ 'icase': 1, \ 'menu': l:detail, + \ 'dup': get(l:info, 'additional_edits_only', 0) + \ || g:ale_completion_autoimport, \ 'info': (type(l:doc) is v:t_string ? l:doc : ''), \} " This flag is used to tell if this completion came from ALE or not. @@ -994,7 +1002,7 @@ endfunction function! ale#completion#HandleUserData(completed_item) abort let l:user_data_json = get(a:completed_item, 'user_data', '') let l:user_data = !empty(l:user_data_json) - \ ? json_decode(l:user_data_json) + \ ? ale#util#FuzzyJSONDecode(l:user_data_json, v:null) \ : v:null if type(l:user_data) isnot v:t_dict diff --git a/sources_non_forked/ale/autoload/ale/cursor.vim b/sources_non_forked/ale/autoload/ale/cursor.vim index 9ca6fb15..e8478e93 100644 --- a/sources_non_forked/ale/autoload/ale/cursor.vim +++ b/sources_non_forked/ale/autoload/ale/cursor.vim @@ -9,7 +9,6 @@ let g:ale_echo_delay = get(g:, 'ale_echo_delay', 10) let g:ale_echo_msg_format = get(g:, 'ale_echo_msg_format', '%code: %%s') let s:cursor_timer = -1 -let s:last_pos = [0, 0, 0] function! ale#cursor#TruncatedEcho(original_message) abort let l:message = a:original_message @@ -118,14 +117,18 @@ function! ale#cursor#EchoCursorWarningWithDelay() abort let l:pos = getpos('.')[0:2] + if !exists('w:last_pos') + let w:last_pos = [0, 0, 0] + endif + " Check the current buffer, line, and column number against the last " recorded position. If the position has actually changed, *then* " we should echo something. Otherwise we can end up doing processing " the echo message far too frequently. - if l:pos != s:last_pos + if l:pos != w:last_pos let l:delay = ale#Var(l:buffer, 'echo_delay') - let s:last_pos = l:pos + let w:last_pos = l:pos let s:cursor_timer = timer_start( \ l:delay, \ function('ale#cursor#EchoCursorWarning') @@ -139,11 +142,16 @@ function! s:ShowCursorDetailForItem(loc, options) abort let s:last_detailed_line = line('.') let l:message = get(a:loc, 'detail', a:loc.text) let l:lines = split(l:message, "\n") - call ale#preview#Show(l:lines, {'stay_here': l:stay_here}) - " Clear the echo message if we manually displayed details. - if !l:stay_here - execute 'echo' + if g:ale_floating_preview || g:ale_detail_to_floating_preview + call ale#floating_preview#Show(l:lines) + else + call ale#preview#Show(l:lines, {'stay_here': l:stay_here}) + + " Clear the echo message if we manually displayed details. + if !l:stay_here + execute 'echo' + endif endif endfunction diff --git a/sources_non_forked/ale/autoload/ale/debugging.vim b/sources_non_forked/ale/autoload/ale/debugging.vim index 5e6d5906..efd52776 100644 --- a/sources_non_forked/ale/autoload/ale/debugging.vim +++ b/sources_non_forked/ale/autoload/ale/debugging.vim @@ -33,13 +33,13 @@ let s:global_variable_list = [ \ 'ale_list_vertical', \ 'ale_list_window_size', \ 'ale_loclist_msg_format', -\ 'ale_lsp_root', \ 'ale_max_buffer_history_size', \ 'ale_max_signs', \ 'ale_maximum_file_size', \ 'ale_open_list', \ 'ale_pattern_options', \ 'ale_pattern_options_enabled', +\ 'ale_root', \ 'ale_set_balloons', \ 'ale_set_highlights', \ 'ale_set_loclist', @@ -259,9 +259,7 @@ function! ale#debugging#InfoToClipboard() abort return endif - redir => l:output - silent call ale#debugging#Info() - redir END + let l:output = execute('call ale#debugging#Info()') let @+ = l:output call s:Echo('ALEInfo copied to your clipboard') @@ -270,9 +268,7 @@ endfunction function! ale#debugging#InfoToFile(filename) abort let l:expanded_filename = expand(a:filename) - redir => l:output - silent call ale#debugging#Info() - redir END + let l:output = execute('call ale#debugging#Info()') call writefile(split(l:output, "\n"), l:expanded_filename) call s:Echo('ALEInfo written to ' . l:expanded_filename) diff --git a/sources_non_forked/ale/autoload/ale/definition.vim b/sources_non_forked/ale/autoload/ale/definition.vim index 0c1fb7cf..9574017b 100644 --- a/sources_non_forked/ale/autoload/ale/definition.vim +++ b/sources_non_forked/ale/autoload/ale/definition.vim @@ -36,7 +36,7 @@ function! ale#definition#UpdateTagStack() abort endfunction function! ale#definition#HandleTSServerResponse(conn_id, response) abort - if get(a:response, 'command', '') is# 'definition' + if has_key(a:response, 'request_seq') \&& has_key(s:go_to_definition_map, a:response.request_seq) let l:options = remove(s:go_to_definition_map, a:response.request_seq) @@ -66,9 +66,17 @@ function! ale#definition#HandleLSPResponse(conn_id, response) abort endif for l:item in l:result - let l:filename = ale#path#FromURI(l:item.uri) - let l:line = l:item.range.start.line + 1 - let l:column = l:item.range.start.character + 1 + if has_key(l:item, 'targetUri') + " LocationLink items use targetUri + let l:filename = ale#path#FromURI(l:item.targetUri) + let l:line = l:item.targetRange.start.line + 1 + let l:column = l:item.targetRange.start.character + 1 + else + " LocationLink items use uri + let l:filename = ale#path#FromURI(l:item.uri) + let l:line = l:item.range.start.line + 1 + let l:column = l:item.range.start.character + 1 + endif call ale#definition#UpdateTagStack() call ale#util#Open(l:filename, l:line, l:column, l:options) @@ -92,11 +100,19 @@ function! s:OnReady(line, column, options, capability, linter, lsp_details) abor call ale#lsp#RegisterCallback(l:id, l:Callback) if a:linter.lsp is# 'tsserver' - let l:message = ale#lsp#tsserver_message#Definition( - \ l:buffer, - \ a:line, - \ a:column - \) + if a:capability is# 'definition' + let l:message = ale#lsp#tsserver_message#Definition( + \ l:buffer, + \ a:line, + \ a:column + \) + elseif a:capability is# 'typeDefinition' + let l:message = ale#lsp#tsserver_message#TypeDefinition( + \ l:buffer, + \ a:line, + \ a:column + \) + endif else " Send a message saying the buffer has changed first, or the " definition position probably won't make sense. @@ -145,12 +161,6 @@ endfunction function! ale#definition#GoToType(options) abort for l:linter in ale#linter#Get(&filetype) if !empty(l:linter.lsp) - " TODO: handle typeDefinition for tsserver if supported by the - " protocol - if l:linter.lsp is# 'tsserver' - continue - endif - call s:GoToLSPDefinition(l:linter, a:options, 'typeDefinition') endif endfor diff --git a/sources_non_forked/ale/autoload/ale/dhall.vim b/sources_non_forked/ale/autoload/ale/dhall.vim new file mode 100644 index 00000000..cc54418f --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/dhall.vim @@ -0,0 +1,24 @@ +" Author: Pat Brisbin , toastal +" Description: Functions for working with Dhall’s executable + +call ale#Set('dhall_executable', 'dhall') +call ale#Set('dhall_use_global', get(g:, 'ale_use_global_executables', 0)) +call ale#Set('dhall_options', '') + +function! ale#dhall#GetExecutable(buffer) abort + let l:executable = ale#Var(a:buffer, 'dhall_executable') + + " Dhall is written in Haskell and commonly installed with Stack + return ale#handlers#haskell_stack#EscapeExecutable(l:executable, 'dhall') +endfunction + +function! ale#dhall#GetExecutableWithOptions(buffer) abort + let l:executable = ale#dhall#GetExecutable(a:buffer) + + return l:executable + \ . ale#Pad(ale#Var(a:buffer, 'dhall_options')) +endfunction + +function! ale#dhall#GetCommand(buffer) abort + return '%e ' . ale#Pad(ale#Var(a:buffer, 'dhall_options')) +endfunction diff --git a/sources_non_forked/ale/autoload/ale/engine.vim b/sources_non_forked/ale/autoload/ale/engine.vim index 3cafa25c..5b9b1fca 100644 --- a/sources_non_forked/ale/autoload/ale/engine.vim +++ b/sources_non_forked/ale/autoload/ale/engine.vim @@ -413,6 +413,7 @@ function! s:RunJob(command, options) abort return 0 endif + let l:cwd = a:options.cwd let l:executable = a:options.executable let l:buffer = a:options.buffer let l:linter = a:options.linter @@ -425,6 +426,7 @@ function! s:RunJob(command, options) abort \ 'executable': l:executable, \}]) let l:result = ale#command#Run(l:buffer, l:command, l:Callback, { + \ 'cwd': l:cwd, \ 'output_stream': l:output_stream, \ 'executable': l:executable, \ 'read_buffer': l:read_buffer, @@ -541,8 +543,22 @@ function! s:RunIfExecutable(buffer, linter, lint_file, executable) abort let l:job_type = a:lint_file ? 'file_linter' : 'linter' call setbufvar(a:buffer, 'ale_job_type', l:job_type) + " Get the cwd for the linter and set it before we call GetCommand. + " This will ensure that ale#command#Run uses it by default. + let l:cwd = ale#linter#GetCwd(a:buffer, a:linter) + + if l:cwd isnot v:null + call ale#command#SetCwd(a:buffer, l:cwd) + endif + let l:command = ale#linter#GetCommand(a:buffer, a:linter) + + if l:cwd isnot v:null + call ale#command#ResetCwd(a:buffer) + endif + let l:options = { + \ 'cwd': l:cwd, \ 'executable': a:executable, \ 'buffer': a:buffer, \ 'linter': a:linter, diff --git a/sources_non_forked/ale/autoload/ale/filetypes.vim b/sources_non_forked/ale/autoload/ale/filetypes.vim index 6cdc9ece..340a9c4e 100644 --- a/sources_non_forked/ale/autoload/ale/filetypes.vim +++ b/sources_non_forked/ale/autoload/ale/filetypes.vim @@ -4,9 +4,7 @@ function! ale#filetypes#LoadExtensionMap() abort " Output includes: " '*.erl setf erlang' - redir => l:output - silent exec 'autocmd' - redir end + let l:output = execute('exec "autocmd"') let l:map = {} diff --git a/sources_non_forked/ale/autoload/ale/fix.vim b/sources_non_forked/ale/autoload/ale/fix.vim index c3338fc5..8ebba9fe 100644 --- a/sources_non_forked/ale/autoload/ale/fix.vim +++ b/sources_non_forked/ale/autoload/ale/fix.vim @@ -172,6 +172,7 @@ function! s:RunJob(result, options) abort let l:read_temporary_file = get(a:result, 'read_temporary_file', 0) let l:read_buffer = get(a:result, 'read_buffer', 1) let l:output_stream = get(a:result, 'output_stream', 'stdout') + let l:cwd = get(a:result, 'cwd', v:null) if l:read_temporary_file let l:output_stream = 'none' @@ -190,6 +191,7 @@ function! s:RunJob(result, options) abort \ 'read_buffer': l:read_buffer, \ 'input': l:input, \ 'log_output': 0, + \ 'cwd': l:cwd, \ 'filename_mappings': ale#GetFilenameMappings(l:buffer, l:fixer_name), \}) diff --git a/sources_non_forked/ale/autoload/ale/fix/registry.vim b/sources_non_forked/ale/autoload/ale/fix/registry.vim index 0f146faa..7a4d964e 100644 --- a/sources_non_forked/ale/autoload/ale/fix/registry.vim +++ b/sources_non_forked/ale/autoload/ale/fix/registry.vim @@ -17,6 +17,11 @@ let s:default_registry = { \ 'suggested_filetypes': ['python'], \ 'description': 'Fix import issues with autoimport.', \ }, +\ 'autoflake': { +\ 'function': 'ale#fixers#autoflake#Fix', +\ 'suggested_filetypes': ['python'], +\ 'description': 'Fix flake issues with autoflake.', +\ }, \ 'autopep8': { \ 'function': 'ale#fixers#autopep8#Fix', \ 'suggested_filetypes': ['python'], @@ -32,11 +37,42 @@ let s:default_registry = { \ 'suggested_filetypes': ['python'], \ 'description': 'Fix PEP8 issues with black.', \ }, +\ 'buildifier': { +\ 'function': 'ale#fixers#buildifier#Fix', +\ 'suggested_filetypes': ['bzl'], +\ 'description': 'Format BUILD and .bzl files with buildifier.', +\ }, +\ 'deno': { +\ 'function': 'ale#fixers#deno#Fix', +\ 'suggested_filetypes': ['typescript'], +\ 'description': 'Fix TypeScript using deno fmt.', +\ }, \ 'dfmt': { \ 'function': 'ale#fixers#dfmt#Fix', \ 'suggested_filetypes': ['d'], \ 'description': 'Fix D files with dfmt.', \ }, +\ 'dhall': { +\ 'function': 'ale#fixers#dhall#Fix', +\ 'suggested_filetypes': ['dhall'], +\ 'description': 'Fix Dhall files with dhall-format.', +\ }, +\ 'dhall-format': { +\ 'function': 'ale#fixers#dhall_format#Fix', +\ 'suggested_filetypes': ['dhall'], +\ 'description': 'Standard code formatter for the Dhall language', +\ 'aliases': ['dhall'], +\ }, +\ 'dhall-freeze': { +\ 'function': 'ale#fixers#dhall_freeze#Freeze', +\ 'suggested_filetypes': ['dhall'], +\ 'description': 'Add integrity checks to remote import statements of an expression for the Dhall language', +\ }, +\ 'dhall-lint': { +\ 'function': 'ale#fixers#dhall_lint#Fix', +\ 'suggested_filetypes': ['dhall'], +\ 'description': 'Standard code formatter for the Dhall language and removing dead code', +\ }, \ 'fecs': { \ 'function': 'ale#fixers#fecs#Fix', \ 'suggested_filetypes': ['javascript', 'css', 'html'], @@ -81,7 +117,7 @@ let s:default_registry = { \ }, \ 'prettier': { \ 'function': 'ale#fixers#prettier#Fix', -\ 'suggested_filetypes': ['javascript', 'typescript', 'css', 'less', 'scss', 'json', 'json5', 'graphql', 'markdown', 'vue', 'html', 'yaml'], +\ 'suggested_filetypes': ['javascript', 'typescript', 'css', 'less', 'scss', 'json', 'json5', 'graphql', 'markdown', 'vue', 'svelte', 'html', 'yaml', 'openapi', 'ruby'], \ 'description': 'Apply prettier to a file.', \ }, \ 'prettier_eslint': { @@ -132,7 +168,7 @@ let s:default_registry = { \ }, \ 'scalafmt': { \ 'function': 'ale#fixers#scalafmt#Fix', -\ 'suggested_filetypes': ['scala'], +\ 'suggested_filetypes': ['sbt', 'scala'], \ 'description': 'Fix Scala files using scalafmt', \ }, \ 'sorbet': { @@ -160,6 +196,11 @@ let s:default_registry = { \ 'suggested_filetypes': ['swift'], \ 'description': 'Apply SwiftFormat to a file.', \ }, +\ 'apple-swift-format': { +\ 'function': 'ale#fixers#appleswiftformat#Fix', +\ 'suggested_filetypes': ['swift'], +\ 'description': 'Apply apple/swift-format to a file.', +\ }, \ 'phpcbf': { \ 'function': 'ale#fixers#phpcbf#Fix', \ 'suggested_filetypes': ['php'], @@ -190,6 +231,11 @@ let s:default_registry = { \ 'suggested_filetypes': ['cmake'], \ 'description': 'Fix CMake files with cmake-format.', \ }, +\ 'fish_indent': { +\ 'function': 'ale#fixers#fish_indent#Fix', +\ 'suggested_filetypes': ['fish'], +\ 'description': 'Format fish scripts using fish_indent.', +\ }, \ 'gofmt': { \ 'function': 'ale#fixers#gofmt#Fix', \ 'suggested_filetypes': ['go'], @@ -262,12 +308,12 @@ let s:default_registry = { \ }, \ 'ocamlformat': { \ 'function': 'ale#fixers#ocamlformat#Fix', -\ 'suggested_filetypes': ['ocaml'], +\ 'suggested_filetypes': ['ocaml', 'ocamlinterface'], \ 'description': 'Fix OCaml files with ocamlformat.', \ }, \ 'ocp-indent': { \ 'function': 'ale#fixers#ocp_indent#Fix', -\ 'suggested_filetypes': ['ocaml'], +\ 'suggested_filetypes': ['ocaml', 'ocamlinterface'], \ 'description': 'Fix OCaml files with ocp-indent.', \ }, \ 'refmt': { @@ -275,6 +321,11 @@ let s:default_registry = { \ 'suggested_filetypes': ['reason'], \ 'description': 'Fix ReasonML files with refmt.', \ }, +\ 'pandoc': { +\ 'function': 'ale#fixers#pandoc#Fix', +\ 'suggested_filetypes': ['markdown'], +\ 'description': 'Fix markdown files with pandoc.', +\ }, \ 'shfmt': { \ 'function': 'ale#fixers#shfmt#Fix', \ 'suggested_filetypes': ['sh'], @@ -305,6 +356,11 @@ let s:default_registry = { \ 'suggested_filetypes': ['json'], \ 'description': 'Fix JSON files with jq.', \ }, +\ 'protolint': { +\ 'function': 'ale#fixers#protolint#Fix', +\ 'suggested_filetypes': ['proto'], +\ 'description': 'Fix Protocol Buffer files with protolint.', +\ }, \ 'perltidy': { \ 'function': 'ale#fixers#perltidy#Fix', \ 'suggested_filetypes': ['perl'], @@ -325,6 +381,11 @@ let s:default_registry = { \ 'suggested_filetypes': ['dart'], \ 'description': 'Fix Dart files with dartfmt.', \ }, +\ 'dart-format': { +\ 'function': 'ale#fixers#dart_format#Fix', +\ 'suggested_filetypes': ['dart'], +\ 'description': 'Fix Dart files with dart format.', +\ }, \ 'xmllint': { \ 'function': 'ale#fixers#xmllint#Fix', \ 'suggested_filetypes': ['xml'], @@ -342,7 +403,7 @@ let s:default_registry = { \ }, \ 'ktlint': { \ 'function': 'ale#fixers#ktlint#Fix', -\ 'suggested_filetypes': ['kt'], +\ 'suggested_filetypes': ['kt', 'kotlin'], \ 'description': 'Fix Kotlin files with ktlint.', \ }, \ 'styler': { @@ -370,6 +431,11 @@ let s:default_registry = { \ 'suggested_filetypes': ['ada'], \ 'description': 'Format Ada files with gnatpp.', \ }, +\ 'nixfmt': { +\ 'function': 'ale#fixers#nixfmt#Fix', +\ 'suggested_filetypes': ['nix'], +\ 'description': 'A nix formatter written in Haskell.', +\ }, \ 'nixpkgs-fmt': { \ 'function': 'ale#fixers#nixpkgsfmt#Fix', \ 'suggested_filetypes': ['nix'], @@ -385,21 +451,36 @@ let s:default_registry = { \ 'suggested_filetypes': ['html', 'htmldjango'], \ 'description': 'Fix HTML files with html-beautify.', \ }, +\ 'lua-format': { +\ 'function': 'ale#fixers#lua_format#Fix', +\ 'suggested_filetypes': ['lua'], +\ 'description': 'Fix Lua files with lua-format.', +\ }, \ '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.', +\ 'stylua': { +\ 'function': 'ale#fixers#stylua#Fix', +\ 'suggested_filetypes': ['lua'], +\ 'description': 'Fix Lua files with stylua.', \ }, \ 'ormolu': { \ 'function': 'ale#fixers#ormolu#Fix', \ 'suggested_filetypes': ['haskell'], \ 'description': 'A formatter for Haskell source code.', \ }, +\ 'ptop': { +\ 'function': 'ale#fixers#ptop#Fix', +\ 'suggested_filetypes': ['pascal'], +\ 'description': 'Fix Pascal files with ptop.', +\ }, +\ 'vfmt': { +\ 'function': 'ale#fixers#vfmt#Fix', +\ 'suggested_filetypes': ['v'], +\ 'description': 'A formatter for V source code.', +\ } \} " Reset the function registry to the default entries. diff --git a/sources_non_forked/ale/autoload/ale/fixers/appleswiftformat.vim b/sources_non_forked/ale/autoload/ale/fixers/appleswiftformat.vim new file mode 100644 index 00000000..ca27e82c --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/appleswiftformat.vim @@ -0,0 +1,16 @@ +" Author: (bosr) +" Description: Integration of apple/swift-format formatter with ALE. + +function! ale#fixers#appleswiftformat#Fix(buffer) abort + let l:command_args = ale#swift#GetAppleSwiftFormatCommand(a:buffer) . ' format --in-place %t' + let l:config_args = ale#swift#GetAppleSwiftFormatConfigArgs(a:buffer) + + if l:config_args isnot# '' + let l:command_args = l:command_args . ' ' . l:config_args + endif + + return { + \ 'read_temporary_file': 1, + \ 'command': l:command_args, + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/autoflake.vim b/sources_non_forked/ale/autoload/ale/fixers/autoflake.vim new file mode 100644 index 00000000..e2ad6536 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/autoflake.vim @@ -0,0 +1,28 @@ +" Author: circld +" Description: Fixing files with autoflake. + +call ale#Set('python_autoflake_executable', 'autoflake') +call ale#Set('python_autoflake_use_global', get(g:, 'ale_use_global_executables', 0)) +call ale#Set('python_autoflake_options', '') + +function! ale#fixers#autoflake#Fix(buffer) abort + let l:executable = ale#python#FindExecutable( + \ a:buffer, + \ 'python_autoflake', + \ ['autoflake'], + \) + + if !executable(l:executable) + return 0 + endif + + let l:options = ale#Var(a:buffer, 'python_autoflake_options') + + return { + \ 'command': ale#Escape(l:executable) + \ . (!empty(l:options) ? ' ' . l:options : '') + \ . ' --in-place ' + \ . ' %t', + \ 'read_temporary_file': 1, + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/autoimport.vim b/sources_non_forked/ale/autoload/ale/fixers/autoimport.vim index 37a52db8..700d36b5 100644 --- a/sources_non_forked/ale/autoload/ale/fixers/autoimport.vim +++ b/sources_non_forked/ale/autoload/ale/fixers/autoimport.vim @@ -19,7 +19,9 @@ function! ale#fixers#autoimport#Fix(buffer) abort endif return { - \ 'command': ale#path#BufferCdString(a:buffer) - \ . ale#Escape(l:executable) . (!empty(l:options) ? ' ' . l:options : '') . ' -', + \ 'cwd': '%s:h', + \ 'command': ale#Escape(l:executable) + \ . (!empty(l:options) ? ' ' . l:options : '') + \ . ' -', \} endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/black.vim b/sources_non_forked/ale/autoload/ale/fixers/black.vim index fba6c3b4..4a88c5cd 100644 --- a/sources_non_forked/ale/autoload/ale/fixers/black.vim +++ b/sources_non_forked/ale/autoload/ale/fixers/black.vim @@ -5,6 +5,7 @@ call ale#Set('python_black_executable', 'black') call ale#Set('python_black_use_global', get(g:, 'ale_use_global_executables', 0)) call ale#Set('python_black_options', '') call ale#Set('python_black_auto_pipenv', 0) +call ale#Set('python_black_auto_poetry', 0) call ale#Set('python_black_change_directory', 1) function! ale#fixers#black#GetExecutable(buffer) abort @@ -13,29 +14,39 @@ function! ale#fixers#black#GetExecutable(buffer) abort return 'pipenv' endif + if (ale#Var(a:buffer, 'python_auto_poetry') || ale#Var(a:buffer, 'python_black_auto_poetry')) + \ && ale#python#PoetryPresent(a:buffer) + return 'poetry' + endif + return ale#python#FindExecutable(a:buffer, 'python_black', ['black']) endfunction function! ale#fixers#black#Fix(buffer) abort - let l:cd_string = ale#Var(a:buffer, 'python_black_change_directory') - \ ? ale#path#BufferCdString(a:buffer) - \ : '' - let l:executable = ale#fixers#black#GetExecutable(a:buffer) + let l:cmd = [ale#Escape(l:executable)] - let l:exec_args = l:executable =~? 'pipenv$' - \ ? ' run black' - \ : '' + if l:executable =~? 'pipenv\|poetry$' + call extend(l:cmd, ['run', 'black']) + endif let l:options = ale#Var(a:buffer, 'python_black_options') - if expand('#' . a:buffer . ':e') is? 'pyi' - let l:options .= '--pyi' + if !empty(l:options) + call add(l:cmd, l:options) endif - return { - \ 'command': l:cd_string . ale#Escape(l:executable) . l:exec_args - \ . (!empty(l:options) ? ' ' . l:options : '') - \ . ' -', - \} + if expand('#' . a:buffer . ':e') is? 'pyi' + call add(l:cmd, '--pyi') + endif + + call add(l:cmd, '-') + + let l:result = {'command': join(l:cmd, ' ')} + + if ale#Var(a:buffer, 'python_black_change_directory') + let l:result.cwd = '%s:h' + endif + + return l:result endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/buildifier.vim b/sources_non_forked/ale/autoload/ale/fixers/buildifier.vim new file mode 100644 index 00000000..48103b2e --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/buildifier.vim @@ -0,0 +1,26 @@ +" Author: Jon Parise +" Description: Format Bazel BUILD and .bzl files with buildifier. +" +call ale#Set('bazel_buildifier_executable', 'buildifier') +call ale#Set('bazel_buildifier_use_global', get(g:, 'ale_use_global_executables', 0)) +call ale#Set('bazel_buildifier_options', '') + +function! ale#fixers#buildifier#GetExecutable(buffer) abort + return ale#path#FindExecutable(a:buffer, 'bazel_buildifier', [ + \ 'buildifier', + \]) +endfunction + +function! ale#fixers#buildifier#Fix(buffer) abort + let l:executable = ale#Escape(ale#fixers#buildifier#GetExecutable(a:buffer)) + let l:options = ale#Var(a:buffer, 'bazel_buildifier_options') + let l:filename = ale#Escape(bufname(a:buffer)) + + let l:command = l:executable . ' -mode fix -lint fix -path ' . l:filename + + if l:options isnot# '' + let l:command .= ' ' . l:options + endif + + return {'command': l:command . ' -'} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/clangformat.vim b/sources_non_forked/ale/autoload/ale/fixers/clangformat.vim index ea5743a5..81498ebd 100644 --- a/sources_non_forked/ale/autoload/ale/fixers/clangformat.vim +++ b/sources_non_forked/ale/autoload/ale/fixers/clangformat.vim @@ -5,9 +5,11 @@ scriptencoding utf-8 call ale#Set('c_clangformat_executable', 'clang-format') call ale#Set('c_clangformat_use_global', get(g:, 'ale_use_global_executables', 0)) call ale#Set('c_clangformat_options', '') +call ale#Set('c_clangformat_style_option', '') +call ale#Set('c_clangformat_use_local_file', 0) function! ale#fixers#clangformat#GetExecutable(buffer) abort - return ale#node#FindExecutable(a:buffer, 'c_clangformat', [ + return ale#path#FindExecutable(a:buffer, 'c_clangformat', [ \ 'clang-format', \]) endfunction @@ -16,6 +18,24 @@ function! ale#fixers#clangformat#Fix(buffer) abort let l:executable = ale#Escape(ale#fixers#clangformat#GetExecutable(a:buffer)) let l:filename = ale#Escape(bufname(a:buffer)) let l:options = ale#Var(a:buffer, 'c_clangformat_options') + let l:style_option = ale#Var(a:buffer, 'c_clangformat_style_option') + let l:use_local_file = ale#Var(a:buffer, 'c_clangformat_use_local_file') + + if l:style_option isnot# '' + let l:style_option = '-style=' . "'" . l:style_option . "'" + endif + + if l:use_local_file + let l:config = ale#path#FindNearestFile(a:buffer, '.clang-format') + + if !empty(l:config) + let l:style_option = '-style=file' + endif + endif + + if l:style_option isnot# '' + let l:options .= ' ' . l:style_option + endif let l:command = l:executable . ' --assume-filename=' . l:filename diff --git a/sources_non_forked/ale/autoload/ale/fixers/cmakeformat.vim b/sources_non_forked/ale/autoload/ale/fixers/cmakeformat.vim index f40ed6ed..dcc29cf3 100644 --- a/sources_non_forked/ale/autoload/ale/fixers/cmakeformat.vim +++ b/sources_non_forked/ale/autoload/ale/fixers/cmakeformat.vim @@ -10,9 +10,7 @@ function! ale#fixers#cmakeformat#Fix(buffer) abort return { \ 'command': ale#Escape(l:executable) - \ . ' -i ' \ . (empty(l:options) ? '' : ' ' . l:options) - \ . ' %t', - \ 'read_temporary_file': 1, + \ . ' -' \} endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/dart_format.vim b/sources_non_forked/ale/autoload/ale/fixers/dart_format.vim new file mode 100644 index 00000000..4b8f730b --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/dart_format.vim @@ -0,0 +1,18 @@ +" Author: ghsang +" Description: Integration of dart format with ALE. + +call ale#Set('dart_format_executable', 'dart') +call ale#Set('dart_format_options', '') + +function! ale#fixers#dart_format#Fix(buffer) abort + let l:executable = ale#Var(a:buffer, 'dart_format_executable') + let l:options = ale#Var(a:buffer, 'dart_format_options') + + return { + \ 'command': ale#Escape(l:executable) + \ . ' format' + \ . (empty(l:options) ? '' : ' ' . l:options) + \ . ' %t', + \ 'read_temporary_file': 1, + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/deno.vim b/sources_non_forked/ale/autoload/ale/fixers/deno.vim new file mode 100644 index 00000000..7154c6ee --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/deno.vim @@ -0,0 +1,17 @@ +function! ale#fixers#deno#Fix(buffer) abort + let l:executable = ale#handlers#deno#GetExecutable(a:buffer) + + if !executable(l:executable) + return 0 + endif + + let l:options = ' fmt -' + + if ale#Var(a:buffer, 'deno_unstable') + let l:options = l:options . ' --unstable' + endif + + return { + \ 'command': ale#Escape(l:executable) . 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 deleted file mode 100644 index 18f6006c..00000000 --- a/sources_non_forked/ale/autoload/ale/fixers/dhall.vim +++ /dev/null @@ -1,23 +0,0 @@ -" 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/dhall_format.vim b/sources_non_forked/ale/autoload/ale/fixers/dhall_format.vim new file mode 100644 index 00000000..d4021983 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/dhall_format.vim @@ -0,0 +1,14 @@ +" Author: toastal +" Description: Dhall’s built-in formatter +" +function! ale#fixers#dhall_format#Fix(buffer) abort + let l:executable = ale#dhall#GetExecutableWithOptions(a:buffer) + let l:command = l:executable + \ . ' format' + \ . ' --inplace %t' + + return { + \ 'command': l:command, + \ 'read_temporary_file': 1, + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/dhall_freeze.vim b/sources_non_forked/ale/autoload/ale/fixers/dhall_freeze.vim new file mode 100644 index 00000000..74ae7530 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/dhall_freeze.vim @@ -0,0 +1,18 @@ +" Author: toastal +" Description: Dhall’s package freezing + +call ale#Set('dhall_freeze_options', '') + +function! ale#fixers#dhall_freeze#Freeze(buffer) abort + let l:executable = ale#dhall#GetExecutableWithOptions(a:buffer) + let l:command = l:executable + \ . ' freeze' + \ . ale#Pad(ale#Var(a:buffer, 'dhall_freeze_options')) + \ . ' --inplace %t' + + + return { + \ 'command': l:command, + \ 'read_temporary_file': 1, + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/dhall_lint.vim b/sources_non_forked/ale/autoload/ale/fixers/dhall_lint.vim new file mode 100644 index 00000000..2abbe6f7 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/dhall_lint.vim @@ -0,0 +1,14 @@ +" Author: toastal +" Description: Dhall’s built-in linter/formatter + +function! ale#fixers#dhall_lint#Fix(buffer) abort + let l:executable = ale#dhall#GetExecutableWithOptions(a:buffer) + let l:command = l:executable + \ . ' lint' + \ . ' --inplace %t' + + return { + \ 'command': l:command, + \ 'read_temporary_file': 1, + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/elm_format.vim b/sources_non_forked/ale/autoload/ale/fixers/elm_format.vim index cd2be2c3..a4740db4 100644 --- a/sources_non_forked/ale/autoload/ale/fixers/elm_format.vim +++ b/sources_non_forked/ale/autoload/ale/fixers/elm_format.vim @@ -6,7 +6,7 @@ call ale#Set('elm_format_use_global', get(g:, 'ale_use_global_executables', 0)) call ale#Set('elm_format_options', '--yes') function! ale#fixers#elm_format#GetExecutable(buffer) abort - return ale#node#FindExecutable(a:buffer, 'elm_format', [ + return ale#path#FindExecutable(a:buffer, 'elm_format', [ \ 'node_modules/.bin/elm-format', \]) endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/erlfmt.vim b/sources_non_forked/ale/autoload/ale/fixers/erlfmt.vim new file mode 100644 index 00000000..f9951e9d --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/erlfmt.vim @@ -0,0 +1,21 @@ +" Author: AntoineGagne - https://github.com/AntoineGagne +" Description: Integration of erlfmt with ALE. + +call ale#Set('erlang_erlfmt_executable', 'erlfmt') +call ale#Set('erlang_erlfmt_use_global', get(g:, 'ale_use_global_executables', 0)) +call ale#Set('erlang_erlfmt_options', '') + +function! ale#fixers#erlfmt#GetExecutable(buffer) abort + return ale#path#FindExecutable(a:buffer, 'erlang_erlfmt', ['erlfmt']) +endfunction + +function! ale#fixers#erlfmt#Fix(buffer) abort + let l:options = ale#Var(a:buffer, 'erlang_erlfmt_options') + let l:executable = ale#fixers#erlfmt#GetExecutable(a:buffer) + + let l:command = ale#Escape(l:executable) . (empty(l:options) ? '' : ' ' . l:options) . ' %s' + + return { + \ 'command': l:command + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/eslint.vim b/sources_non_forked/ale/autoload/ale/fixers/eslint.vim index f725875c..c9535cb0 100644 --- a/sources_non_forked/ale/autoload/ale/fixers/eslint.vim +++ b/sources_non_forked/ale/autoload/ale/fixers/eslint.vim @@ -53,8 +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#handlers#eslint#GetCdString(a:buffer) - \ . ale#node#Executable(a:buffer, l:executable) + \ 'cwd': ale#handlers#eslint#GetCwd(a:buffer), + \ 'command': ale#node#Executable(a:buffer, l:executable) \ . ale#Pad(l:options) \ . ' --stdin-filename %s --stdin --fix-to-stdout', \ 'process_with': 'ale#fixers#eslint#ProcessEslintDOutput', @@ -64,8 +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#handlers#eslint#GetCdString(a:buffer) - \ . ale#node#Executable(a:buffer, l:executable) + \ 'cwd': ale#handlers#eslint#GetCwd(a:buffer), + \ 'command': 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', @@ -73,8 +73,8 @@ function! ale#fixers#eslint#ApplyFixForVersion(buffer, version) abort endif return { - \ 'command': ale#handlers#eslint#GetCdString(a:buffer) - \ . ale#node#Executable(a:buffer, l:executable) + \ 'cwd': ale#handlers#eslint#GetCwd(a:buffer), + \ 'command': 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/fish_indent.vim b/sources_non_forked/ale/autoload/ale/fixers/fish_indent.vim new file mode 100644 index 00000000..ebf17c5a --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/fish_indent.vim @@ -0,0 +1,19 @@ +" Author: Chen YuanYuan +" Description: Integration of fish_indent with ALE. + +call ale#Set('fish_fish_indent_executable', 'fish_indent') +call ale#Set('fish_fish_indent_options', '') + +function! ale#fixers#fish_indent#Fix(buffer) abort + let l:executable = ale#Var(a:buffer, 'fish_fish_indent_executable') + let l:options = ale#Var(a:buffer, 'fish_fish_indent_options') + let l:filename = ale#Escape(bufname(a:buffer)) + + return { + \ 'command': ale#Escape(l:executable) + \ . ' -w ' + \ . (empty(l:options) ? '' : ' ' . l:options) + \ . ' %t', + \ 'read_temporary_file': 1, + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/fixjson.vim b/sources_non_forked/ale/autoload/ale/fixers/fixjson.vim index 33ce0af3..4bad8f9b 100644 --- a/sources_non_forked/ale/autoload/ale/fixers/fixjson.vim +++ b/sources_non_forked/ale/autoload/ale/fixers/fixjson.vim @@ -6,7 +6,7 @@ call ale#Set('json_fixjson_options', '') call ale#Set('json_fixjson_use_global', get(g:, 'ale_use_global_executables', 0)) function! ale#fixers#fixjson#GetExecutable(buffer) abort - return ale#node#FindExecutable(a:buffer, 'json_fixjson', [ + return ale#path#FindExecutable(a:buffer, 'json_fixjson', [ \ 'node_modules/.bin/fixjson', \]) endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/isort.vim b/sources_non_forked/ale/autoload/ale/fixers/isort.vim index 9070fb27..a640d233 100644 --- a/sources_non_forked/ale/autoload/ale/fixers/isort.vim +++ b/sources_non_forked/ale/autoload/ale/fixers/isort.vim @@ -2,24 +2,34 @@ " Description: Fixing Python imports with isort. call ale#Set('python_isort_executable', 'isort') -call ale#Set('python_isort_options', '') call ale#Set('python_isort_use_global', get(g:, 'ale_use_global_executables', 0)) +call ale#Set('python_isort_options', '') +call ale#Set('python_isort_auto_pipenv', 0) + +function! ale#fixers#isort#GetExecutable(buffer) abort + if (ale#Var(a:buffer, 'python_auto_pipenv') || ale#Var(a:buffer, 'python_isort_auto_pipenv')) + \ && ale#python#PipenvPresent(a:buffer) + return 'pipenv' + endif + + return ale#python#FindExecutable(a:buffer, 'python_isort', ['isort']) +endfunction function! ale#fixers#isort#Fix(buffer) abort let l:options = ale#Var(a:buffer, 'python_isort_options') + let l:executable = ale#fixers#isort#GetExecutable(a:buffer) + let l:exec_args = l:executable =~? 'pipenv$' + \ ? ' run isort' + \ : '' - let l:executable = ale#python#FindExecutable( - \ a:buffer, - \ 'python_isort', - \ ['isort'], - \) - - if !executable(l:executable) + if !executable(l:executable) && l:executable isnot# 'pipenv' return 0 endif return { - \ 'command': ale#path#BufferCdString(a:buffer) - \ . ale#Escape(l:executable) . (!empty(l:options) ? ' ' . l:options : '') . ' -', + \ 'cwd': '%s:h', + \ 'command': ale#Escape(l:executable) . l:exec_args + \ . ale#Pad('--filename %s') + \ . (!empty(l:options) ? ' ' . l:options : '') . ' -', \} endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/lua_format.vim b/sources_non_forked/ale/autoload/ale/fixers/lua_format.vim new file mode 100644 index 00000000..98b155c0 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/lua_format.vim @@ -0,0 +1,16 @@ +" Author: Mathias Jean Johansen +" Description: Integration of LuaFormatter with ALE. + +call ale#Set('lua_lua_format_executable', 'lua-format') +call ale#Set('lua_lua_format_options', '') + +function! ale#fixers#lua_format#Fix(buffer) abort + let l:executable = ale#Var(a:buffer, 'lua_lua_format_executable') + let l:options = ale#Var(a:buffer, 'lua_lua_format_options') + + return { + \ 'command': ale#Escape(l:executable) + \ . ale#Pad(l:options) + \ . ' -i', + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/nixfmt.vim b/sources_non_forked/ale/autoload/ale/fixers/nixfmt.vim new file mode 100644 index 00000000..4a548b23 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/nixfmt.vim @@ -0,0 +1,15 @@ +scriptencoding utf-8 +" Author: houstdav000 +" Description: Fix files with nixfmt + +call ale#Set('nix_nixfmt_executable', 'nixfmt') +call ale#Set('nix_nixfmt_options', '') + +function! ale#fixers#nixfmt#Fix(buffer) abort + let l:executable = ale#Var(a:buffer, 'nix_nixfmt_executable') + let l:options = ale#Var(a:buffer, 'nix_nixfmt_options') + + return { + \ 'command': ale#Escape(l:executable) . ale#Pad(l:options), + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/pandoc.vim b/sources_non_forked/ale/autoload/ale/fixers/pandoc.vim new file mode 100644 index 00000000..d704c8a2 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/pandoc.vim @@ -0,0 +1,16 @@ +scriptencoding utf-8 +" Author: Jesse Hathaway +" Description: Fix markdown files with pandoc. + +call ale#Set('markdown_pandoc_executable', 'pandoc') +call ale#Set('markdown_pandoc_options', '-f gfm -t gfm -s -') + +function! ale#fixers#pandoc#Fix(buffer) abort + let l:executable = ale#Var(a:buffer, 'markdown_pandoc_executable') + let l:options = ale#Var(a:buffer, 'markdown_pandoc_options') + + return { + \ 'command': ale#Escape(l:executable) + \ . ' ' . l:options, + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/php_cs_fixer.vim b/sources_non_forked/ale/autoload/ale/fixers/php_cs_fixer.vim index 5c59e262..c8f9c7b0 100644 --- a/sources_non_forked/ale/autoload/ale/fixers/php_cs_fixer.vim +++ b/sources_non_forked/ale/autoload/ale/fixers/php_cs_fixer.vim @@ -6,7 +6,7 @@ call ale#Set('php_cs_fixer_use_global', get(g:, 'ale_use_global_executables', 0) call ale#Set('php_cs_fixer_options', '') function! ale#fixers#php_cs_fixer#GetExecutable(buffer) abort - return ale#node#FindExecutable(a:buffer, 'php_cs_fixer', [ + return ale#path#FindExecutable(a:buffer, 'php_cs_fixer', [ \ 'vendor/bin/php-cs-fixer', \ 'php-cs-fixer' \]) diff --git a/sources_non_forked/ale/autoload/ale/fixers/phpcbf.vim b/sources_non_forked/ale/autoload/ale/fixers/phpcbf.vim index 0a61c657..494bf346 100644 --- a/sources_non_forked/ale/autoload/ale/fixers/phpcbf.vim +++ b/sources_non_forked/ale/autoload/ale/fixers/phpcbf.vim @@ -7,7 +7,7 @@ call ale#Set('php_phpcbf_executable', 'phpcbf') call ale#Set('php_phpcbf_use_global', get(g:, 'ale_use_global_executables', 0)) function! ale#fixers#phpcbf#GetExecutable(buffer) abort - return ale#node#FindExecutable(a:buffer, 'php_phpcbf', [ + return ale#path#FindExecutable(a:buffer, 'php_phpcbf', [ \ 'vendor/bin/phpcbf', \ 'phpcbf' \]) diff --git a/sources_non_forked/ale/autoload/ale/fixers/prettier.vim b/sources_non_forked/ale/autoload/ale/fixers/prettier.vim index e0f4972e..8a67e2ff 100644 --- a/sources_non_forked/ale/autoload/ale/fixers/prettier.vim +++ b/sources_non_forked/ale/autoload/ale/fixers/prettier.vim @@ -7,7 +7,7 @@ call ale#Set('javascript_prettier_use_global', get(g:, 'ale_use_global_executabl call ale#Set('javascript_prettier_options', '') function! ale#fixers#prettier#GetExecutable(buffer) abort - return ale#node#FindExecutable(a:buffer, 'javascript_prettier', [ + return ale#path#FindExecutable(a:buffer, 'javascript_prettier', [ \ 'node_modules/.bin/prettier_d', \ 'node_modules/prettier-cli/index.js', \ 'node_modules/.bin/prettier', @@ -34,19 +34,11 @@ function! ale#fixers#prettier#ProcessPrettierDOutput(buffer, output) abort return a:output endfunction -function! ale#fixers#prettier#GetProjectRoot(buffer) abort +function! ale#fixers#prettier#GetCwd(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)) + return !empty(l:config) ? fnamemodify(l:config, ':h') : '%s:h' endfunction function! ale#fixers#prettier#ApplyFixForVersion(buffer, version) abort @@ -82,8 +74,11 @@ function! ale#fixers#prettier#ApplyFixForVersion(buffer, version) abort \ 'graphql': 'graphql', \ 'markdown': 'markdown', \ 'vue': 'vue', + \ 'svelte': 'svelte', \ 'yaml': 'yaml', + \ 'openapi': 'yaml', \ 'html': 'html', + \ 'ruby': 'ruby', \} for l:filetype in l:filetypes @@ -101,8 +96,8 @@ function! ale#fixers#prettier#ApplyFixForVersion(buffer, version) abort " Special error handling needed for prettier_d if l:executable =~# 'prettier_d$' return { - \ 'command': ale#path#BufferCdString(a:buffer) - \ . ale#Escape(l:executable) + \ 'cwd': '%s:h', + \ 'command':ale#Escape(l:executable) \ . (!empty(l:options) ? ' ' . l:options : '') \ . ' --stdin-filepath %s --stdin', \ 'process_with': 'ale#fixers#prettier#ProcessPrettierDOutput', @@ -112,8 +107,8 @@ 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#fixers#prettier#CdProjectRoot(a:buffer) - \ . ale#Escape(l:executable) + \ 'cwd': ale#fixers#prettier#GetCwd(a:buffer), + \ 'command': ale#Escape(l:executable) \ . (!empty(l:options) ? ' ' . l:options : '') \ . ' --stdin-filepath %s --stdin', \} diff --git a/sources_non_forked/ale/autoload/ale/fixers/prettier_eslint.vim b/sources_non_forked/ale/autoload/ale/fixers/prettier_eslint.vim index 1e66f49e..0b9c88b7 100644 --- a/sources_non_forked/ale/autoload/ale/fixers/prettier_eslint.vim +++ b/sources_non_forked/ale/autoload/ale/fixers/prettier_eslint.vim @@ -7,7 +7,7 @@ call ale#Set('javascript_prettier_eslint_use_global', get(g:, 'ale_use_global_ex call ale#Set('javascript_prettier_eslint_options', '') function! ale#fixers#prettier_eslint#GetExecutable(buffer) abort - return ale#node#FindExecutable(a:buffer, 'javascript_prettier_eslint', [ + return ale#path#FindExecutable(a:buffer, 'javascript_prettier_eslint', [ \ 'node_modules/prettier-eslint-cli/dist/index.js', \ 'node_modules/.bin/prettier-eslint', \]) @@ -37,8 +37,8 @@ function! ale#fixers#prettier_eslint#ApplyFixForVersion(buffer, version) abort " 4.4.0 is the first version with --stdin-filepath if ale#semver#GTE(a:version, [4, 4, 0]) return { - \ 'command': ale#path#BufferCdString(a:buffer) - \ . ale#Escape(l:executable) + \ 'cwd': '%s:h', + \ 'command': ale#Escape(l:executable) \ . l:eslint_config_option \ . (!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 9d982ff6..c8c09e31 100644 --- a/sources_non_forked/ale/autoload/ale/fixers/prettier_standard.vim +++ b/sources_non_forked/ale/autoload/ale/fixers/prettier_standard.vim @@ -6,7 +6,7 @@ call ale#Set('javascript_prettier_standard_use_global', get(g:, 'ale_use_global_ call ale#Set('javascript_prettier_standard_options', '') function! ale#fixers#prettier_standard#GetExecutable(buffer) abort - return ale#node#FindExecutable(a:buffer, 'javascript_prettier_standard', [ + return ale#path#FindExecutable(a:buffer, 'javascript_prettier_standard', [ \ 'node_modules/prettier-standard/lib/index.js', \ 'node_modules/.bin/prettier-standard', \]) diff --git a/sources_non_forked/ale/autoload/ale/fixers/protolint.vim b/sources_non_forked/ale/autoload/ale/fixers/protolint.vim new file mode 100644 index 00000000..9b8e72f1 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/protolint.vim @@ -0,0 +1,26 @@ +" Author: Yohei Yoshimuta +" Description: Integration of protolint with ALE. + +call ale#Set('proto_protolint_executable', 'protolint') +call ale#Set('proto_protolint_config', '') + +function! ale#fixers#protolint#GetExecutable(buffer) abort + let l:executable = ale#Var(a:buffer, 'proto_protolint_executable') + + return ale#Escape(l:executable) +endfunction + +function! ale#fixers#protolint#Fix(buffer) abort + let l:executable = ale#fixers#protolint#GetExecutable(a:buffer) + let l:config = ale#Var(a:buffer, 'proto_protolint_config') + + return { + \ 'command': l:executable + \ . (!empty(l:config) ? ' -config_path=' . ale#Escape(l:config) : '') + \ . ' -fix' + \ . ' %t', + \ 'read_temporary_file': 1, + \} +endfunction + + diff --git a/sources_non_forked/ale/autoload/ale/fixers/ptop.vim b/sources_non_forked/ale/autoload/ale/fixers/ptop.vim new file mode 100644 index 00000000..98345226 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/ptop.vim @@ -0,0 +1,17 @@ +" Author: BarrOff https://github.com/BarrOff +" Description: Integration of ptop with ALE. + +call ale#Set('pascal_ptop_executable', 'ptop') +call ale#Set('pascal_ptop_options', '') + +function! ale#fixers#ptop#Fix(buffer) abort + let l:executable = ale#Var(a:buffer, 'pascal_ptop_executable') + let l:options = ale#Var(a:buffer, 'pascal_ptop_options') + + return { + \ 'command': ale#Escape(l:executable) + \ . (empty(l:options) ? '' : ' ' . l:options) + \ . ' %s %t', + \ '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 index 3ce442f3..85593b44 100644 --- a/sources_non_forked/ale/autoload/ale/fixers/remark_lint.vim +++ b/sources_non_forked/ale/autoload/ale/fixers/remark_lint.vim @@ -6,7 +6,7 @@ call ale#Set('markdown_remark_lint_use_global', get(g:, 'ale_use_global_executab call ale#Set('markdown_remark_lint_options', '') function! ale#fixers#remark_lint#GetExecutable(buffer) abort - return ale#node#FindExecutable(a:buffer, 'markdown_remark_lint', [ + return ale#path#FindExecutable(a:buffer, 'markdown_remark_lint', [ \ 'node_modules/remark-cli/cli.js', \ 'node_modules/.bin/remark', \]) diff --git a/sources_non_forked/ale/autoload/ale/fixers/standard.vim b/sources_non_forked/ale/autoload/ale/fixers/standard.vim index 46decebf..b9d60ebb 100644 --- a/sources_non_forked/ale/autoload/ale/fixers/standard.vim +++ b/sources_non_forked/ale/autoload/ale/fixers/standard.vim @@ -6,7 +6,7 @@ call ale#Set('javascript_standard_use_global', get(g:, 'ale_use_global_executabl call ale#Set('javascript_standard_options', '') function! ale#fixers#standard#GetExecutable(buffer) abort - return ale#node#FindExecutable(a:buffer, 'javascript_standard', [ + return ale#path#FindExecutable(a:buffer, 'javascript_standard', [ \ 'node_modules/standardx/bin/cmd.js', \ 'node_modules/standard/bin/cmd.js', \ 'node_modules/.bin/standard', diff --git a/sources_non_forked/ale/autoload/ale/fixers/standardrb.vim b/sources_non_forked/ale/autoload/ale/fixers/standardrb.vim index 54330a37..acb310c6 100644 --- a/sources_non_forked/ale/autoload/ale/fixers/standardrb.vim +++ b/sources_non_forked/ale/autoload/ale/fixers/standardrb.vim @@ -12,12 +12,12 @@ function! ale#fixers#standardrb#GetCommand(buffer) abort return ale#ruby#EscapeExecutable(l:executable, 'standardrb') \ . (!empty(l:config) ? ' --config ' . ale#Escape(l:config) : '') \ . (!empty(l:options) ? ' ' . l:options : '') - \ . ' --fix --force-exclusion %t' + \ . ' --fix --force-exclusion --stdin %s' endfunction function! ale#fixers#standardrb#Fix(buffer) abort return { \ 'command': ale#fixers#standardrb#GetCommand(a:buffer), - \ 'read_temporary_file': 1, + \ 'process_with': 'ale#fixers#rubocop#PostProcess' \} endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/stylelint.vim b/sources_non_forked/ale/autoload/ale/fixers/stylelint.vim index 6f4cf177..650b9c4a 100644 --- a/sources_non_forked/ale/autoload/ale/fixers/stylelint.vim +++ b/sources_non_forked/ale/autoload/ale/fixers/stylelint.vim @@ -6,7 +6,7 @@ call ale#Set('stylelint_use_global', get(g:, 'ale_use_global_executables', 0)) call ale#Set('stylelint_options', '') function! ale#fixers#stylelint#GetExecutable(buffer) abort - return ale#node#FindExecutable(a:buffer, 'stylelint', [ + return ale#path#FindExecutable(a:buffer, 'stylelint', [ \ 'node_modules/stylelint/bin/stylelint.js', \ 'node_modules/.bin/stylelint', \]) @@ -17,11 +17,10 @@ function! ale#fixers#stylelint#Fix(buffer) abort let l:options = ale#Var(a:buffer, 'stylelint_options') return { - \ 'command': ale#path#BufferCdString(a:buffer) - \ . ale#node#Executable(a:buffer, l:executable) - \ . ' %t' + \ 'cwd': '%s:h', + \ 'command': ale#node#Executable(a:buffer, l:executable) \ . ale#Pad(l:options) - \ . ' --fix', - \ 'read_temporary_file': 1, + \ . ' --fix --stdin --stdin-filename %s', + \ 'read_temporary_file': 0, \} endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/stylua.vim b/sources_non_forked/ale/autoload/ale/fixers/stylua.vim new file mode 100644 index 00000000..3521c935 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/stylua.vim @@ -0,0 +1,14 @@ +" Author: Robert Liebowitz +" Description: https://github.com/johnnymorganz/stylua + +call ale#Set('lua_stylua_executable', 'stylua') +call ale#Set('lua_stylua_options', '') + +function! ale#fixers#stylua#Fix(buffer) abort + let l:executable = ale#Var(a:buffer, 'lua_stylua_executable') + let l:options = ale#Var(a:buffer, 'lua_stylua_options') + + return { + \ 'command': ale#Escape(l:executable) . ale#Pad(l:options) . ' -', + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/swiftformat.vim b/sources_non_forked/ale/autoload/ale/fixers/swiftformat.vim index 304182b2..cc553b7d 100644 --- a/sources_non_forked/ale/autoload/ale/fixers/swiftformat.vim +++ b/sources_non_forked/ale/autoload/ale/fixers/swiftformat.vim @@ -6,7 +6,7 @@ call ale#Set('swift_swiftformat_use_global', get(g:, 'ale_use_global_executables call ale#Set('swift_swiftformat_options', '') function! ale#fixers#swiftformat#GetExecutable(buffer) abort - return ale#node#FindExecutable(a:buffer, 'swift_swiftformat', [ + return ale#path#FindExecutable(a:buffer, 'swift_swiftformat', [ \ 'Pods/SwiftFormat/CommandLineTool/swiftformat', \ 'ios/Pods/SwiftFormat/CommandLineTool/swiftformat', \ 'swiftformat', diff --git a/sources_non_forked/ale/autoload/ale/fixers/tidy.vim b/sources_non_forked/ale/autoload/ale/fixers/tidy.vim index 1af4120b..2c79e73a 100644 --- a/sources_non_forked/ale/autoload/ale/fixers/tidy.vim +++ b/sources_non_forked/ale/autoload/ale/fixers/tidy.vim @@ -5,7 +5,7 @@ call ale#Set('html_tidy_executable', 'tidy') call ale#Set('html_tidy_use_global', get(g:, 'ale_use_global_executables', 0)) function! ale#fixers#tidy#Fix(buffer) abort - let l:executable = ale#node#FindExecutable( + let l:executable = ale#path#FindExecutable( \ a:buffer, \ 'html_tidy', \ ['tidy'], diff --git a/sources_non_forked/ale/autoload/ale/fixers/vfmt.vim b/sources_non_forked/ale/autoload/ale/fixers/vfmt.vim new file mode 100644 index 00000000..2e780318 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/vfmt.vim @@ -0,0 +1,13 @@ +" Author: fiatjaf +" Description: Integration of `v fmt` with ALE. + +call ale#Set('v_vfmt_options', '') + +function! ale#fixers#vfmt#Fix(buffer) abort + let l:executable = ale#Var(a:buffer, 'v_v_executable') + let l:options = ale#Var(a:buffer, 'v_vfmt_options') + + return { + \ 'command': ale#Escape(l:executable) . ' fmt' . ale#Pad(l:options) + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/xo.vim b/sources_non_forked/ale/autoload/ale/fixers/xo.vim index 882350be..dcf4c737 100644 --- a/sources_non_forked/ale/autoload/ale/fixers/xo.vim +++ b/sources_non_forked/ale/autoload/ale/fixers/xo.vim @@ -1,23 +1,36 @@ " Author: Albert Marquez - https://github.com/a-marquez " Description: Fixing files with XO. -call ale#Set('javascript_xo_executable', 'xo') -call ale#Set('javascript_xo_use_global', get(g:, 'ale_use_global_executables', 0)) -call ale#Set('javascript_xo_options', '') +function! ale#fixers#xo#Fix(buffer) abort + let l:executable = ale#handlers#xo#GetExecutable(a:buffer) + let l:options = ale#handlers#xo#GetOptions(a:buffer) -function! ale#fixers#xo#GetExecutable(buffer) abort - return ale#node#FindExecutable(a:buffer, 'javascript_xo', [ - \ 'node_modules/xo/cli.js', - \ 'node_modules/.bin/xo', - \]) + return ale#semver#RunWithVersionCheck( + \ a:buffer, + \ l:executable, + \ '%e --version', + \ {b, v -> ale#fixers#xo#ApplyFixForVersion(b, v, l:executable, l:options)} + \) endfunction -function! ale#fixers#xo#Fix(buffer) abort - let l:executable = ale#fixers#xo#GetExecutable(a:buffer) +function! ale#fixers#xo#ApplyFixForVersion(buffer, version, executable, options) abort + let l:executable = ale#node#Executable(a:buffer, a:executable) + let l:options = ale#Pad(a:options) + + " 0.30.0 is the first version with a working --stdin --fix + if ale#semver#GTE(a:version, [0, 30, 0]) + return { + \ 'command': l:executable + \ . ' --stdin --stdin-filename %s' + \ . ' --fix' + \ . l:options, + \} + endif return { - \ 'command': ale#node#Executable(a:buffer, l:executable) - \ . ' --fix %t', + \ 'command': l:executable + \ . ' --fix %t' + \ . l:options, \ '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 index 966556c9..6654a25c 100644 --- a/sources_non_forked/ale/autoload/ale/fixers/yamlfix.vim +++ b/sources_non_forked/ale/autoload/ale/fixers/yamlfix.vim @@ -7,7 +7,6 @@ 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', @@ -19,7 +18,8 @@ function! ale#fixers#yamlfix#Fix(buffer) abort endif return { - \ 'command': ale#path#BufferCdString(a:buffer) - \ . ale#Escape(l:executable) . (!empty(l:options) ? ' ' . l:options : '') . ' -', + \ 'cwd': '%s:h', + \ 'command': ale#Escape(l:executable) + \ . (!empty(l:options) ? ' ' . l:options : '') . ' -', \} endfunction diff --git a/sources_non_forked/ale/autoload/ale/floating_preview.vim b/sources_non_forked/ale/autoload/ale/floating_preview.vim new file mode 100644 index 00000000..f0bc8f80 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/floating_preview.vim @@ -0,0 +1,203 @@ +" Author: Jan-Grimo Sobez +" Author: Kevin Clark +" Author: D. Ben Knoble +" Description: Floating preview window for showing whatever information in. + +" Precondition: exists('*nvim_open_win') || has('popupwin') + +function! ale#floating_preview#Show(lines, ...) abort + if !exists('*nvim_open_win') && !has('popupwin') + execute 'echom ''Floating windows not supported in this vim instance.''' + + return + endif + + let l:options = get(a:000, 0, {}) + + if has('nvim') + call s:NvimShow(a:lines, l:options) + else + call s:VimShow(a:lines, l:options) + endif +endfunction + +function! s:NvimShow(lines, options) abort + " Remove the close autocmd so it doesn't happen mid update + augroup ale_floating_preview_window + autocmd! + augroup END + + " Only create a new window if we need it + if !exists('w:preview') || index(nvim_list_wins(), w:preview['id']) is# -1 + call s:NvimCreate(a:options) + else + call nvim_buf_set_option(w:preview['buffer'], 'modifiable', v:true) + endif + + " Execute commands in window context + let l:parent_window = nvim_get_current_win() + + call nvim_set_current_win(w:preview['id']) + + for l:command in get(a:options, 'commands', []) + call execute(l:command) + endfor + + call nvim_set_current_win(l:parent_window) + + " Return to parent context on move + augroup ale_floating_preview_window + autocmd! + + if g:ale_close_preview_on_insert + autocmd CursorMoved,TabLeave,WinLeave,InsertEnter ++once call s:NvimClose() + else + autocmd CursorMoved,TabLeave,WinLeave ++once call s:NvimClose() + endif + augroup END + + let [l:lines, l:width, l:height] = s:NvimPrepareWindowContent(a:lines) + + call nvim_win_set_width(w:preview['id'], l:width) + call nvim_win_set_height(w:preview['id'], l:height) + call nvim_buf_set_lines(w:preview['buffer'], 0, -1, v:false, l:lines) + call nvim_buf_set_option(w:preview['buffer'], 'modified', v:false) + call nvim_buf_set_option(w:preview['buffer'], 'modifiable', v:false) +endfunction + +function! s:VimShow(lines, options) abort + if g:ale_close_preview_on_insert + " Remove the close autocmd so it doesn't happen mid update + silent! autocmd! ale_floating_preview_window + endif + + " Only create a new window if we need it + if !exists('w:preview') || index(popup_list(), w:preview['id']) is# -1 + call s:VimCreate(a:options) + endif + + " Execute commands in window context + for l:command in get(a:options, 'commands', []) + call win_execute(w:preview['id'], l:command) + endfor + + call popup_settext(w:preview['id'], a:lines) + + if g:ale_close_preview_on_insert + augroup ale_floating_preview_window + autocmd! + autocmd InsertEnter * ++once call s:VimClose() + augroup END + endif +endfunction + +function! s:NvimPrepareWindowContent(lines) abort + let l:max_height = 10 + + let l:width = max(map(copy(a:lines), 'strdisplaywidth(v:val)')) + let l:height = min([len(a:lines), l:max_height]) + + if empty(g:ale_floating_window_border) + return [a:lines, l:width, l:height] + endif + + " Add the size of borders + let l:width += 2 + let l:height += 2 + + let l:hor = g:ale_floating_window_border[0] + let l:top = g:ale_floating_window_border[1] + let l:top_left = g:ale_floating_window_border[2] + let l:top_right = g:ale_floating_window_border[3] + let l:bottom_right = g:ale_floating_window_border[4] + let l:bottom_left = g:ale_floating_window_border[5] + + let l:lines = [l:top_left . repeat(l:top, l:width - 2) . l:top_right] + + for l:line in a:lines + let l:line_width = strchars(l:line) + let l:lines = add(l:lines, l:hor . l:line . repeat(' ', l:width - l:line_width - 2). l:hor) + endfor + + " Truncate the lines + if len(l:lines) > l:max_height + 1 + let l:lines = l:lines[0:l:max_height] + endif + + let l:lines = add(l:lines, l:bottom_left . repeat(l:top, l:width - 2) . l:bottom_right) + + return [l:lines, l:width, l:height] +endfunction + +function! s:NvimCreate(options) abort + let l:buffer = nvim_create_buf(v:false, v:false) + let l:winid = nvim_open_win(l:buffer, v:false, { + \ 'relative': 'cursor', + \ 'row': 1, + \ 'col': 0, + \ 'width': 42, + \ 'height': 4, + \ 'style': 'minimal' + \ }) + call nvim_buf_set_option(l:buffer, 'buftype', 'acwrite') + call nvim_buf_set_option(l:buffer, 'bufhidden', 'delete') + call nvim_buf_set_option(l:buffer, 'swapfile', v:false) + call nvim_buf_set_option(l:buffer, 'filetype', get(a:options, 'filetype', 'ale-preview')) + + let w:preview = {'id': l:winid, 'buffer': l:buffer} +endfunction + +function! s:VimCreate(options) abort + let l:popup_id = popup_create([], { + \ 'line': 'cursor+1', + \ 'col': 'cursor', + \ 'drag': v:true, + \ 'resize': v:true, + \ 'close': 'button', + \ 'padding': [0, 1, 0, 1], + \ 'border': [], + \ 'borderchars': empty(g:ale_floating_window_border) ? [' '] : [ + \ g:ale_floating_window_border[1], + \ g:ale_floating_window_border[0], + \ g:ale_floating_window_border[1], + \ g:ale_floating_window_border[0], + \ g:ale_floating_window_border[2], + \ g:ale_floating_window_border[3], + \ g:ale_floating_window_border[4], + \ g:ale_floating_window_border[5], + \ ], + \ 'moved': 'any', + \ }) + call setbufvar(winbufnr(l:popup_id), '&filetype', get(a:options, 'filetype', 'ale-preview')) + let w:preview = {'id': l:popup_id} +endfunction + +function! s:NvimClose() abort + let l:mode = mode() + let l:restore_visual = l:mode is# 'v' || l:mode is# 'V' || l:mode is# "\" + + if !exists('w:preview') + return + endif + + call setbufvar(w:preview['buffer'], '&modified', 0) + + if win_id2win(w:preview['id']) > 0 + execute win_id2win(w:preview['id']).'wincmd c' + endif + + unlet w:preview + + if l:restore_visual + normal! gv + endif +endfunction + +function! s:VimClose() abort + if !exists('w:preview') + return + endif + + call popup_close(w:preview['id']) + unlet w:preview +endfunction diff --git a/sources_non_forked/ale/autoload/ale/go.vim b/sources_non_forked/ale/autoload/ale/go.vim index 4a21e596..bce85a87 100644 --- a/sources_non_forked/ale/autoload/ale/go.vim +++ b/sources_non_forked/ale/autoload/ale/go.vim @@ -42,3 +42,17 @@ function! ale#go#EnvString(buffer) abort return l:env endfunction + +function! ale#go#GetGoPathExecutable(suffix) abort + let l:prefix = $GOPATH + + if !empty($GOPATH) + let l:prefix = $GOPATH + elseif has('win32') + let l:prefix = $USERPROFILE . '/go' + else + let l:prefix = $HOME . '/go' + endif + + return ale#path#Simplify(l:prefix . '/' . a:suffix) +endfunction diff --git a/sources_non_forked/ale/autoload/ale/gradle.vim b/sources_non_forked/ale/autoload/ale/gradle.vim index dc377fb9..ba1add4d 100644 --- a/sources_non_forked/ale/autoload/ale/gradle.vim +++ b/sources_non_forked/ale/autoload/ale/gradle.vim @@ -50,18 +50,25 @@ function! ale#gradle#FindExecutable(buffer) abort 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. +" Given a buffer number, get a working directory and command to print the +" classpath of the root project. +" +" Returns an empty string for the command if Gradle is not detected. function! ale#gradle#BuildClasspathCommand(buffer) abort let l:executable = ale#gradle#FindExecutable(a:buffer) - let l:project_root = ale#gradle#FindProjectRoot(a:buffer) - if !empty(l:executable) && !empty(l:project_root) - return ale#path#CdString(l:project_root) - \ . ale#Escape(l:executable) - \ . ' -I ' . ale#Escape(s:init_path) - \ . ' -q printClasspath' + if !empty(l:executable) + let l:project_root = ale#gradle#FindProjectRoot(a:buffer) + + if !empty(l:project_root) + return [ + \ l:project_root, + \ ale#Escape(l:executable) + \ . ' -I ' . ale#Escape(s:init_path) + \ . ' -q printClasspath' + \] + endif endif - return '' + return ['', ''] endfunction diff --git a/sources_non_forked/ale/autoload/ale/handlers/alex.vim b/sources_non_forked/ale/autoload/ale/handlers/alex.vim index 190a7f86..6ef4867f 100644 --- a/sources_non_forked/ale/autoload/ale/handlers/alex.vim +++ b/sources_non_forked/ale/autoload/ale/handlers/alex.vim @@ -3,7 +3,7 @@ scriptencoding utf-8 " Description: Error handling for errors in alex output format function! ale#handlers#alex#GetExecutable(buffer) abort - return ale#node#FindExecutable(a:buffer, 'alex', [ + return ale#path#FindExecutable(a:buffer, 'alex', [ \ 'node_modules/.bin/alex', \ 'node_modules/alex/cli.js', \]) diff --git a/sources_non_forked/ale/autoload/ale/handlers/atools.vim b/sources_non_forked/ale/autoload/ale/handlers/atools.vim new file mode 100644 index 00000000..c273fc40 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/handlers/atools.vim @@ -0,0 +1,41 @@ +" Author: Leo +" Description: Handlers for output expected from atools + +function! ale#handlers#atools#Handle(buffer, lines) abort + " Format: SEVERITY:[TAG]:PATH:LINENUM:MSG + " Example: MC:[AL5]:./APKBUILD:12:variable set to empty string: install= + let l:pattern = '\([^:]\+\):\([^:]\+\):\([^:]\+\):\(\d\+\):\(.\+\)$' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + " We are expected to receive 2 characters, the first character + " can be 'S', 'I', 'M' 'T', which are respectively: + " Serious (Error) + " Important (Error) + " Minor (Warning) + " Style (Warning) + " + " The second character can be either 'C' or 'P', which are respectively: + " Certain (Error) + " Possible (Warning) + let l:severity = matchstr(l:match[1], '^.') + let l:certainty = matchstr(l:match[1], '.$') + + let l:type = 'E' + " If the tag returns 'Minor' or 'Style' or is 'Possible' + " then return a warning + + if l:severity is# 'M' || l:severity is# 'T' || l:certainty is# 'P' + let l:type = 'W' + endif + + call add(l:output, { + \ 'lnum': l:match[4] + 0, + \ 'text': l:match[5], + \ 'type': l:type, + \ 'code': matchstr(l:match[2], 'AL[0-9]*'), + \}) + endfor + + return l:output +endfunction diff --git a/sources_non_forked/ale/autoload/ale/handlers/cppcheck.vim b/sources_non_forked/ale/autoload/ale/handlers/cppcheck.vim index 7f68ba67..b70ae1bf 100644 --- a/sources_non_forked/ale/autoload/ale/handlers/cppcheck.vim +++ b/sources_non_forked/ale/autoload/ale/handlers/cppcheck.vim @@ -1,10 +1,9 @@ " Description: Handle errors for cppcheck. -function! ale#handlers#cppcheck#GetCdCommand(buffer) abort +function! ale#handlers#cppcheck#GetCwd(buffer) abort let [l:dir, l:json_path] = ale#c#FindCompileCommands(a:buffer) - let l:cd_command = !empty(l:dir) ? ale#path#CdString(l:dir) : '' - return l:cd_command + return !empty(l:dir) ? l:dir : '' endfunction function! ale#handlers#cppcheck#GetBufferPathIncludeOptions(buffer) abort diff --git a/sources_non_forked/ale/autoload/ale/handlers/deno.vim b/sources_non_forked/ale/autoload/ale/handlers/deno.vim new file mode 100644 index 00000000..1b5e1718 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/handlers/deno.vim @@ -0,0 +1,74 @@ +" Author: Mohammed Chelouti - https://github.com/motato1 +" Arnold Chand +" Description: Handler functions for Deno. + +call ale#Set('deno_executable', 'deno') +call ale#Set('deno_unstable', 0) +call ale#Set('deno_importMap', 'import_map.json') +call ale#Set('deno_lsp_project_root', '') + +function! ale#handlers#deno#GetExecutable(buffer) abort + return ale#Var(a:buffer, 'deno_executable') +endfunction + +" Find project root for Deno's language server. +" +" Deno projects do not require a project or configuration file at the project root. +" This means the root directory has to be guessed, +" unless it is explicitly specified by the user. +" +" The project root is determined by ... +" 1. using a user-specified value from deno_lsp_project_root +" 2. looking for common top-level files/dirs +" 3. using the buffer's directory +function! ale#handlers#deno#GetProjectRoot(buffer) abort + let l:project_root = ale#Var(a:buffer, 'deno_lsp_project_root') + + if !empty(l:project_root) + return l:project_root + endif + + let l:possible_project_roots = [ + \ 'tsconfig.json', + \ '.git', + \ bufname(a:buffer), + \] + + for l:possible_root in l:possible_project_roots + let l:project_root = ale#path#FindNearestFile(a:buffer, l:possible_root) + + if empty(l:project_root) + let l:project_root = ale#path#FindNearestDirectory(a:buffer, l:possible_root) + endif + + if !empty(l:project_root) + " dir:p expands to /full/path/to/dir/ whereas + " file:p expands to /full/path/to/file (no trailing slash) + " Appending '/' ensures that :h:h removes the path's last segment + " regardless of whether it is a directory or not. + return fnamemodify(l:project_root . '/', ':p:h:h') + endif + endfor + + return '' +endfunction + +" Initialization Options for deno, for javascript and typescript +function! ale#handlers#deno#GetInitializationOptions(buffer) abort + let l:options = { + \ 'enable': v:true, + \ 'lint': v:true, + \ 'unstable': v:false, + \ 'importMap': ale#path#FindNearestFile(a:buffer, 'import_map.json'), + \ } + + if ale#Var(a:buffer, 'deno_unstable') + let l:options.unstable = v:true + endif + + if ale#Var(a:buffer, 'deno_importMap') isnot# '' + let l:options.importMap = ale#path#FindNearestFile(a:buffer, ale#Var(a:buffer, 'deno_importMap')) + endif + + return l:options +endfunction diff --git a/sources_non_forked/ale/autoload/ale/handlers/eslint.vim b/sources_non_forked/ale/autoload/ale/handlers/eslint.vim index b8610612..374460bc 100644 --- a/sources_non_forked/ale/autoload/ale/handlers/eslint.vim +++ b/sources_non_forked/ale/autoload/ale/handlers/eslint.vim @@ -2,10 +2,10 @@ " Description: Functions for working with eslint, for checking or fixing files. let s:executables = [ +\ '.yarn/sdks/eslint/bin/eslint.js', \ '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') ? '\' : '/' @@ -36,12 +36,11 @@ function! ale#handlers#eslint#FindConfig(buffer) abort endfunction function! ale#handlers#eslint#GetExecutable(buffer) abort - return ale#node#FindExecutable(a:buffer, 'javascript_eslint', s:executables) + return ale#path#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 +" Given a buffer, return an appropriate working directory for ESLint. +function! ale#handlers#eslint#GetCwd(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 @@ -50,17 +49,23 @@ function! ale#handlers#eslint#GetCdString(buffer) abort " 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) + let l:executable = ale#path#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] + let l:modules_index = strridx(l:executable, 'node_modules') + let l:modules_root = l:modules_index > -1 ? l:executable[0:l:modules_index - 2] : '' + + let l:sdks_index = strridx(l:executable, ale#path#Simplify('.yarn/sdks')) + let l:sdks_root = l:sdks_index > -1 ? l:executable[0:l:sdks_index - 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') : '' + let l:modules_root = !empty(l:modules_dir) ? fnamemodify(l:modules_dir, ':h:h') : '' + + let l:sdks_dir = ale#path#FindNearestDirectory(a:buffer, ale#path#Simplify('.yarn/sdks')) + let l:sdks_root = !empty(l:sdks_dir) ? fnamemodify(l:sdks_dir, ':h:h:h') : '' endif - return !empty(l:project_dir) ? ale#path#CdString(l:project_dir) : '' + return strlen(l:modules_root) > strlen(l:sdks_root) ? l:modules_root : l:sdks_root endfunction function! ale#handlers#eslint#GetCommand(buffer) abort @@ -68,8 +73,7 @@ function! ale#handlers#eslint#GetCommand(buffer) abort let l:options = ale#Var(a:buffer, 'javascript_eslint_options') - return ale#handlers#eslint#GetCdString(a:buffer) - \ . ale#node#Executable(a:buffer, l:executable) + return ale#node#Executable(a:buffer, l:executable) \ . (!empty(l:options) ? ' ' . l:options : '') \ . ' -f json --stdin --stdin-filename %s' endfunction diff --git a/sources_non_forked/ale/autoload/ale/handlers/fecs.vim b/sources_non_forked/ale/autoload/ale/handlers/fecs.vim index 5362edb9..064b927e 100644 --- a/sources_non_forked/ale/autoload/ale/handlers/fecs.vim +++ b/sources_non_forked/ale/autoload/ale/handlers/fecs.vim @@ -9,7 +9,7 @@ function! ale#handlers#fecs#GetCommand(buffer) abort endfunction function! ale#handlers#fecs#GetExecutable(buffer) abort - return ale#node#FindExecutable(a:buffer, 'javascript_fecs', [ + return ale#path#FindExecutable(a:buffer, 'javascript_fecs', [ \ 'node_modules/.bin/fecs', \ 'node_modules/fecs/bin/fecs', \]) diff --git a/sources_non_forked/ale/autoload/ale/handlers/hdl_checker.vim b/sources_non_forked/ale/autoload/ale/handlers/hdl_checker.vim index 36dbd259..e11c5377 100644 --- a/sources_non_forked/ale/autoload/ale/handlers/hdl_checker.vim +++ b/sources_non_forked/ale/autoload/ale/handlers/hdl_checker.vim @@ -32,6 +32,8 @@ function! ale#handlers#hdl_checker#GetProjectRoot(buffer) abort if ale#handlers#hdl_checker#IsDotGit(l:project_root) return fnamemodify(l:project_root, ':h:h') endif + + return '' endfunction function! ale#handlers#hdl_checker#GetExecutable(buffer) abort diff --git a/sources_non_forked/ale/autoload/ale/handlers/inko.vim b/sources_non_forked/ale/autoload/ale/handlers/inko.vim new file mode 100644 index 00000000..73f06871 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/handlers/inko.vim @@ -0,0 +1,37 @@ +" Author: Yorick Peterse +" Description: output handlers for the Inko JSON format + +function! ale#handlers#inko#GetType(severity) abort + if a:severity is? 'warning' + return 'W' + endif + + return 'E' +endfunction + +function! ale#handlers#inko#Handle(buffer, lines) abort + try + let l:errors = json_decode(join(a:lines, '')) + catch + return [] + endtry + + if empty(l:errors) + return [] + endif + + let l:output = [] + let l:dir = expand('#' . a:buffer . ':p:h') + + for l:error in l:errors + call add(l:output, { + \ 'filename': ale#path#GetAbsPath(l:dir, l:error['file']), + \ 'lnum': l:error['line'], + \ 'col': l:error['column'], + \ 'text': l:error['message'], + \ 'type': ale#handlers#inko#GetType(l:error['level']), + \}) + endfor + + return l:output +endfunction diff --git a/sources_non_forked/ale/autoload/ale/handlers/ocamllsp.vim b/sources_non_forked/ale/autoload/ale/handlers/ocamllsp.vim new file mode 100644 index 00000000..2738ea2b --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/handlers/ocamllsp.vim @@ -0,0 +1,30 @@ +" Author: Risto Stevcev +" Description: Handlers for the official OCaml language server + +let s:language_id_of_filetype = { +\ 'menhir': 'ocaml.menhir', +\ 'ocaml': 'ocaml', +\ 'ocamlinterface': 'ocaml.interface', +\ 'ocamllex': 'ocaml.lex' +\} + +function! ale#handlers#ocamllsp#GetExecutable(buffer) abort + return 'ocamllsp' +endfunction + +function! ale#handlers#ocamllsp#GetCommand(buffer) abort + let l:executable = ale#handlers#ocamllsp#GetExecutable(a:buffer) + let l:ocaml_ocamllsp_use_opam = ale#Var(a:buffer, 'ocaml_ocamllsp_use_opam') + + return l:ocaml_ocamllsp_use_opam ? 'opam config exec -- ' . l:executable : l:executable +endfunction + +function! ale#handlers#ocamllsp#GetLanguage(buffer) abort + return s:language_id_of_filetype[getbufvar(a:buffer, '&filetype')] +endfunction + +function! ale#handlers#ocamllsp#GetProjectRoot(buffer) abort + let l:dune_project_file = ale#path#FindNearestFile(a:buffer, 'dune-project') + + return !empty(l:dune_project_file) ? fnamemodify(l:dune_project_file, ':h') : '' +endfunction diff --git a/sources_non_forked/ale/autoload/ale/handlers/ols.vim b/sources_non_forked/ale/autoload/ale/handlers/ols.vim index 74130a26..c292c6d9 100644 --- a/sources_non_forked/ale/autoload/ale/handlers/ols.vim +++ b/sources_non_forked/ale/autoload/ale/handlers/ols.vim @@ -4,7 +4,7 @@ function! ale#handlers#ols#GetExecutable(buffer) abort let l:ols_setting = ale#handlers#ols#GetLanguage(a:buffer) . '_ols' - return ale#node#FindExecutable(a:buffer, l:ols_setting, [ + return ale#path#FindExecutable(a:buffer, l:ols_setting, [ \ 'node_modules/.bin/ocaml-language-server', \]) endfunction diff --git a/sources_non_forked/ale/autoload/ale/handlers/shellcheck.vim b/sources_non_forked/ale/autoload/ale/handlers/shellcheck.vim index 701c43b2..17de2912 100644 --- a/sources_non_forked/ale/autoload/ale/handlers/shellcheck.vim +++ b/sources_non_forked/ale/autoload/ale/handlers/shellcheck.vim @@ -40,21 +40,21 @@ function! ale#handlers#shellcheck#GetDialectArgument(buffer) abort return '' endfunction +function! ale#handlers#shellcheck#GetCwd(buffer) abort + return ale#Var(a:buffer, 'sh_shellcheck_change_directory') ? '%s:h' : '' +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' + return '%e' \ . (!empty(l:dialect) ? ' -s ' . l:dialect : '') \ . (!empty(l:options) ? ' ' . l:options : '') \ . (!empty(l:exclude_option) ? ' -e ' . l:exclude_option : '') @@ -111,6 +111,7 @@ function! ale#handlers#shellcheck#DefineLinter(filetype) abort call ale#linter#Define(a:filetype, { \ 'name': 'shellcheck', \ 'executable': {buffer -> ale#Var(buffer, 'sh_shellcheck_executable')}, + \ 'cwd': function('ale#handlers#shellcheck#GetCwd'), \ 'command': {buffer -> ale#semver#RunWithVersionCheck( \ buffer, \ ale#Var(buffer, 'sh_shellcheck_executable'), diff --git a/sources_non_forked/ale/autoload/ale/handlers/solhint.vim b/sources_non_forked/ale/autoload/ale/handlers/solhint.vim new file mode 100644 index 00000000..611aa7bd --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/handlers/solhint.vim @@ -0,0 +1,98 @@ +" Author: Henrique Barcelos <@hbarcelos> +" Description: Functions for working with local solhint for checking *.sol files. + +let s:executables = [ +\ 'node_modules/.bin/solhint', +\ 'node_modules/solhint/solhint.js', +\ 'solhint', +\] + +let s:sep = has('win32') ? '\' : '/' + +call ale#Set('solidity_solhint_options', '') +call ale#Set('solidity_solhint_executable', 'solhint') +call ale#Set('solidity_solhint_use_global', get(g:, 'ale_use_global_executables', 0)) + +function! ale#handlers#solhint#Handle(buffer, lines) abort + " Matches patterns like the following: + " /path/to/file/file.sol: line 1, col 10, Error - 'addOne' is defined but never used. (no-unused-vars) + let l:output = [] + + let l:lint_pattern = '\v^[^:]+: line (\d+), col (\d+), (Error|Warning) - (.*) \((.*)\)$' + + for l:match in ale#util#GetMatches(a:lines, l:lint_pattern) + let l:isError = l:match[3] is? 'error' + call add(l:output, { + \ 'lnum': l:match[1] + 0, + \ 'col': l:match[2] + 0, + \ 'text': l:match[4], + \ 'code': l:match[5], + \ 'type': l:isError ? 'E' : 'W', + \}) + endfor + + let l:syntax_pattern = '\v^[^:]+: line (\d+), col (\d+), (Error|Warning) - (Parse error): (.*)$' + + for l:match in ale#util#GetMatches(a:lines, l:syntax_pattern) + let l:isError = l:match[3] is? 'error' + call add(l:output, { + \ 'lnum': l:match[1] + 0, + \ 'col': l:match[2] + 0, + \ 'text': l:match[5], + \ 'code': l:match[4], + \ 'type': l:isError ? 'E' : 'W', + \}) + endfor + + return l:output +endfunction + +function! ale#handlers#solhint#FindConfig(buffer) abort + for l:path in ale#path#Upwards(expand('#' . a:buffer . ':p:h')) + for l:basename in [ + \ '.solhintrc.js', + \ '.solhintrc.json', + \ '.solhintrc', + \] + let l:config = ale#path#Simplify(join([l:path, l:basename], s:sep)) + + if filereadable(l:config) + return l:config + endif + endfor + endfor + + return ale#path#FindNearestFile(a:buffer, 'package.json') +endfunction + +function! ale#handlers#solhint#GetExecutable(buffer) abort + return ale#path#FindExecutable(a:buffer, 'solidity_solhint', s:executables) +endfunction + +" Given a buffer, return an appropriate working directory for solhint. +function! ale#handlers#solhint#GetCwd(buffer) abort + " If solhint is installed in a directory which contains the buffer, assume + " it is the solhint project root. Otherwise, use nearest node_modules. + " Note: If node_modules not present yet, can't load local deps anyway. + let l:executable = ale#path#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) ? l:project_dir : '' +endfunction + +function! ale#handlers#solhint#GetCommand(buffer) abort + let l:executable = ale#handlers#solhint#GetExecutable(a:buffer) + + let l:options = ale#Var(a:buffer, 'solidity_solhint_options') + + return ale#node#Executable(a:buffer, l:executable) + \ . (!empty(l:options) ? ' ' . l:options : '') + \ . ' --formatter compact %s' +endfunction diff --git a/sources_non_forked/ale/autoload/ale/handlers/spectral.vim b/sources_non_forked/ale/autoload/ale/handlers/spectral.vim new file mode 100644 index 00000000..1eb4a5de --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/handlers/spectral.vim @@ -0,0 +1,31 @@ +" Author: t2h5 +" Description: Integration of Stoplight Spectral CLI with ALE. + +function! ale#handlers#spectral#HandleSpectralOutput(buffer, lines) abort + " Matches patterns like the following: + " openapi.yml:1:1 error oas3-schema "Object should have required property `info`." + " openapi.yml:1:1 warning oas3-api-servers "OpenAPI `servers` must be present and non-empty array." + let l:pattern = '\v^.*:(\d+):(\d+) (error|warning) (.*)$' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + let l:obj = { + \ 'lnum': l:match[1] + 0, + \ 'col': l:match[2] + 0, + \ 'type': l:match[3] is# 'error' ? 'E' : 'W', + \ 'text': l:match[4], + \} + + let l:code_match = matchlist(l:obj.text, '\v^(.+) "(.+)"$') + + if !empty(l:code_match) + let l:obj.code = l:code_match[1] + let l:obj.text = l:code_match[2] + endif + + call add(l:output, l:obj) + endfor + + return l:output +endfunction + diff --git a/sources_non_forked/ale/autoload/ale/handlers/textlint.vim b/sources_non_forked/ale/autoload/ale/handlers/textlint.vim index 6d495b0d..7a648617 100644 --- a/sources_non_forked/ale/autoload/ale/handlers/textlint.vim +++ b/sources_non_forked/ale/autoload/ale/handlers/textlint.vim @@ -6,7 +6,7 @@ call ale#Set('textlint_use_global', get(g:, 'ale_use_global_executables', 0)) call ale#Set('textlint_options', '') function! ale#handlers#textlint#GetExecutable(buffer) abort - return ale#node#FindExecutable(a:buffer, 'textlint', [ + return ale#path#FindExecutable(a:buffer, 'textlint', [ \ 'node_modules/.bin/textlint', \ 'node_modules/textlint/bin/textlint.js', \]) diff --git a/sources_non_forked/ale/autoload/ale/handlers/tslint.vim b/sources_non_forked/ale/autoload/ale/handlers/tslint.vim index 90579344..ee091d24 100644 --- a/sources_non_forked/ale/autoload/ale/handlers/tslint.vim +++ b/sources_non_forked/ale/autoload/ale/handlers/tslint.vim @@ -7,7 +7,7 @@ function! ale#handlers#tslint#InitVariables() abort endfunction function! ale#handlers#tslint#GetExecutable(buffer) abort - return ale#node#FindExecutable(a:buffer, 'typescript_tslint', [ + return ale#path#FindExecutable(a:buffer, 'typescript_tslint', [ \ 'node_modules/.bin/tslint', \]) endfunction diff --git a/sources_non_forked/ale/autoload/ale/handlers/writegood.vim b/sources_non_forked/ale/autoload/ale/handlers/writegood.vim index 8ae61a38..b5b91b3f 100644 --- a/sources_non_forked/ale/autoload/ale/handlers/writegood.vim +++ b/sources_non_forked/ale/autoload/ale/handlers/writegood.vim @@ -11,7 +11,7 @@ endfunction call ale#handlers#writegood#ResetOptions() function! ale#handlers#writegood#GetExecutable(buffer) abort - return ale#node#FindExecutable(a:buffer, 'writegood', [ + return ale#path#FindExecutable(a:buffer, 'writegood', [ \ 'node_modules/.bin/write-good', \ 'node_modules/write-good/bin/write-good.js', \]) diff --git a/sources_non_forked/ale/autoload/ale/handlers/xo.vim b/sources_non_forked/ale/autoload/ale/handlers/xo.vim new file mode 100644 index 00000000..a87c6d8f --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/handlers/xo.vim @@ -0,0 +1,44 @@ +call ale#Set('javascript_xo_executable', 'xo') +call ale#Set('javascript_xo_use_global', get(g:, 'ale_use_global_executables', 0)) +call ale#Set('javascript_xo_options', '') + +call ale#Set('typescript_xo_executable', 'xo') +call ale#Set('typescript_xo_use_global', get(g:, 'ale_use_global_executables', 0)) +call ale#Set('typescript_xo_options', '') + +function! ale#handlers#xo#GetExecutable(buffer) abort + let l:type = ale#handlers#xo#GetType(a:buffer) + + return ale#path#FindExecutable(a:buffer, l:type . '_xo', [ + \ 'node_modules/xo/cli.js', + \ 'node_modules/.bin/xo', + \]) +endfunction + +function! ale#handlers#xo#GetLintCommand(buffer) abort + return ale#Escape(ale#handlers#xo#GetExecutable(a:buffer)) + \ . ale#Pad(ale#handlers#xo#GetOptions(a:buffer)) + \ . ' --reporter json --stdin --stdin-filename %s' +endfunction + +function! ale#handlers#xo#GetOptions(buffer) abort + let l:type = ale#handlers#xo#GetType(a:buffer) + + return ale#Var(a:buffer, l:type . '_xo_options') +endfunction + +" xo uses eslint and the output format is the same +function! ale#handlers#xo#HandleJSON(buffer, lines) abort + return ale#handlers#eslint#HandleJSON(a:buffer, a:lines) +endfunction + +function! ale#handlers#xo#GetType(buffer) abort + let l:filetype = getbufvar(a:buffer, '&filetype') + let l:type = 'javascript' + + if l:filetype =~# 'typescript' + let l:type = 'typescript' + endif + + return l:type +endfunction diff --git a/sources_non_forked/ale/autoload/ale/handlers/yamllint.vim b/sources_non_forked/ale/autoload/ale/handlers/yamllint.vim new file mode 100644 index 00000000..5e04577d --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/handlers/yamllint.vim @@ -0,0 +1,39 @@ +function! ale#handlers#yamllint#GetCommand(buffer) abort + return '%e' . ale#Pad(ale#Var(a:buffer, 'yaml_yamllint_options')) + \ . ' -f parsable %t' +endfunction + +function! ale#handlers#yamllint#Handle(buffer, lines) abort + " Matches patterns line the following: + " something.yaml:1:1: [warning] missing document start "---" (document-start) + " something.yml:2:1: [error] syntax error: expected the node content, but found '' + let l:pattern = '\v^.*:(\d+):(\d+): \[(error|warning)\] (.+)$' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + let l:item = { + \ 'lnum': l:match[1] + 0, + \ 'col': l:match[2] + 0, + \ 'text': l:match[4], + \ 'type': l:match[3] is# 'error' ? 'E' : 'W', + \} + + let l:code_match = matchlist(l:item.text, '\v^(.+) \(([^)]+)\)$') + + if !empty(l:code_match) + if l:code_match[2] is# 'trailing-spaces' + \&& !ale#Var(a:buffer, 'warn_about_trailing_whitespace') + " Skip warnings for trailing whitespace if the option is off. + continue + endif + + let l:item.text = l:code_match[1] + let l:item.code = l:code_match[2] + endif + + call add(l:output, l:item) + endfor + + return l:output +endfunction + diff --git a/sources_non_forked/ale/autoload/ale/hover.vim b/sources_non_forked/ale/autoload/ale/hover.vim index 1d38f3b9..cb0379fd 100644 --- a/sources_non_forked/ale/autoload/ale/hover.vim +++ b/sources_non_forked/ale/autoload/ale/hover.vim @@ -46,6 +46,10 @@ function! ale#hover#HandleTSServerResponse(conn_id, response) abort 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_floating_preview || g:ale_floating_preview + call ale#floating_preview#Show(split(a:response.body.displayString, "\n"), { + \ 'filetype': 'ale-preview.message', + \}) elseif g:ale_hover_to_preview call ale#preview#Show(split(a:response.body.displayString, "\n"), { \ 'filetype': 'ale-preview.message', @@ -226,6 +230,11 @@ function! ale#hover#HandleLSPResponse(conn_id, response) abort 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_floating_preview || g:ale_floating_preview + call ale#floating_preview#Show(l:lines, { + \ 'filetype': 'ale-preview.message', + \ 'commands': l:commands, + \}) elseif g:ale_hover_to_preview call ale#preview#Show(l:lines, { \ 'filetype': 'ale-preview.message', diff --git a/sources_non_forked/ale/autoload/ale/linter.vim b/sources_non_forked/ale/autoload/ale/linter.vim index 645c25f9..cbc79064 100644 --- a/sources_non_forked/ale/autoload/ale/linter.vim +++ b/sources_non_forked/ale/autoload/ale/linter.vim @@ -38,11 +38,13 @@ let s:default_ale_linter_aliases = { " " NOTE: Update the g:ale_linters documentation when modifying this. let s:default_ale_linters = { +\ 'apkbuild': ['apkbuild_lint', 'secfixes_check'], \ 'csh': ['shell'], \ 'elixir': ['credo', 'dialyxir', 'dogma'], -\ 'go': ['gofmt', 'golint', 'go vet'], +\ 'go': ['gofmt', 'golint', 'gopls', 'govet'], \ 'hack': ['hack'], \ 'help': [], +\ 'inko': ['inko'], \ 'perl': ['perlcritic'], \ 'perl6': [], \ 'python': ['flake8', 'mypy', 'pylint', 'pyright'], @@ -51,6 +53,7 @@ let s:default_ale_linters = { \ 'text': [], \ 'vue': ['eslint', 'vls'], \ 'zsh': ['shell'], +\ 'v': ['v'], \} " Testing/debugging helper to unload all linters. @@ -149,17 +152,30 @@ function! ale#linter#PreProcess(filetype, linter) abort endif let l:obj.address = a:linter.address + + if has_key(a:linter, 'cwd') + throw '`cwd` makes no sense for socket LSP connections' + endif else throw '`address` must be defined for getting the LSP address' endif + if has_key(a:linter, 'cwd') + let l:obj.cwd = a:linter.cwd + + if type(l:obj.cwd) isnot v:t_string + \&& type(l:obj.cwd) isnot v:t_func + throw '`cwd` must be a String or Function if defined' + endif + endif + if l:needs_lsp_details " Default to using the filetype as the language. let l:obj.language = get(a:linter, 'language', a:filetype) 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' + throw '`language` must be a String or Function if defined' endif if has_key(a:linter, 'project_root') @@ -413,6 +429,12 @@ function! ale#linter#GetExecutable(buffer, linter) abort \ : l:Executable endfunction +function! ale#linter#GetCwd(buffer, linter) abort + let l:Cwd = get(a:linter, 'cwd', v:null) + + return type(l:Cwd) is v:t_func ? l:Cwd(a:buffer) : l:Cwd +endfunction + " Given a buffer and linter, get the command String for the linter. function! ale#linter#GetCommand(buffer, linter) abort let l:Command = a:linter.command diff --git a/sources_non_forked/ale/autoload/ale/list.vim b/sources_non_forked/ale/autoload/ale/list.vim index 4bfe2a7b..089aa2c0 100644 --- a/sources_non_forked/ale/autoload/ale/list.vim +++ b/sources_non_forked/ale/autoload/ale/list.vim @@ -20,11 +20,17 @@ endif " Return 1 if there is a buffer with buftype == 'quickfix' in bufffer list function! ale#list#IsQuickfixOpen() abort - for l:buf in range(1, bufnr('$')) - if getbufvar(l:buf, '&buftype') is# 'quickfix' - return 1 - endif - endfor + let l:res = getqflist({ 'winid' : winnr() }) + + if has_key(l:res, 'winid') && l:res.winid > 0 + return 1 + endif + + let l:res = getloclist(0, { 'winid' : winnr() }) + + if has_key(l:res, 'winid') && l:res.winid > 0 + return 1 + endif return 0 endfunction @@ -38,6 +44,15 @@ function! s:ShouldOpen(buffer) abort return l:val is 1 || (l:val is# 'on_save' && l:saved) endfunction +function! s:Deduplicate(list) abort + let l:list = a:list + + call sort(l:list, function('ale#util#LocItemCompareWithText')) + call uniq(l:list, function('ale#util#LocItemCompareWithText')) + + return l:list +endfunction + function! ale#list#GetCombinedList() abort let l:list = [] @@ -45,10 +60,7 @@ function! ale#list#GetCombinedList() abort call extend(l:list, l:info.loclist) endfor - call sort(l:list, function('ale#util#LocItemCompareWithText')) - call uniq(l:list, function('ale#util#LocItemCompareWithText')) - - return l:list + return s:Deduplicate(l:list) endfunction function! s:FixList(buffer, list) abort @@ -93,11 +105,13 @@ function! s:SetListsImpl(timer_id, buffer, loclist) abort " but it's better than nothing. let l:ids = s:WinFindBuf(a:buffer) + let l:loclist = s:Deduplicate(a:loclist) + for l:id in l:ids if has('nvim') - call setloclist(l:id, s:FixList(a:buffer, a:loclist), ' ', l:title) + call setloclist(l:id, s:FixList(a:buffer, l:loclist), ' ', l:title) else - call setloclist(l:id, s:FixList(a:buffer, a:loclist)) + call setloclist(l:id, s:FixList(a:buffer, l:loclist)) call setloclist(l:id, [], 'r', {'title': l:title}) endif endfor diff --git a/sources_non_forked/ale/autoload/ale/lsp.vim b/sources_non_forked/ale/autoload/ale/lsp.vim index cb0573aa..1f854bc5 100644 --- a/sources_non_forked/ale/autoload/ale/lsp.vim +++ b/sources_non_forked/ale/autoload/ale/lsp.vim @@ -357,6 +357,7 @@ function! ale#lsp#MarkConnectionAsTsserver(conn_id) abort let l:conn.capabilities.completion = 1 let l:conn.capabilities.completion_trigger_characters = ['.'] let l:conn.capabilities.definition = 1 + let l:conn.capabilities.typeDefinition = 1 let l:conn.capabilities.symbol_search = 1 let l:conn.capabilities.rename = 1 let l:conn.capabilities.code_actions = 1 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 3c1b47ed..00213a75 100644 --- a/sources_non_forked/ale/autoload/ale/lsp/tsserver_message.vim +++ b/sources_non_forked/ale/autoload/ale/lsp/tsserver_message.vim @@ -64,6 +64,14 @@ function! ale#lsp#tsserver_message#Definition(buffer, line, column) abort \}] endfunction +function! ale#lsp#tsserver_message#TypeDefinition(buffer, line, column) abort + return [0, 'ts@typeDefinition', { + \ 'line': a:line, + \ 'offset': a:column, + \ 'file': expand('#' . a:buffer . ':p'), + \}] +endfunction + function! ale#lsp#tsserver_message#References(buffer, line, column) abort return [0, 'ts@references', { \ 'line': a:line, diff --git a/sources_non_forked/ale/autoload/ale/lsp_linter.vim b/sources_non_forked/ale/autoload/ale/lsp_linter.vim index dcd76e8f..b8885f31 100644 --- a/sources_non_forked/ale/autoload/ale/lsp_linter.vim +++ b/sources_non_forked/ale/autoload/ale/lsp_linter.vim @@ -85,12 +85,18 @@ function! s:HandleTSServerDiagnostics(response, error_type) abort endif let l:info.syntax_loclist = l:thislist - else + elseif a:error_type is# 'semantic' if len(l:thislist) is 0 && len(get(l:info, 'semantic_loclist', [])) is 0 let l:no_changes = 1 endif let l:info.semantic_loclist = l:thislist + else + if len(l:thislist) is 0 && len(get(l:info, 'suggestion_loclist', [])) is 0 + let l:no_changes = 1 + endif + + let l:info.suggestion_loclist = l:thislist endif if l:no_changes @@ -98,6 +104,7 @@ function! s:HandleTSServerDiagnostics(response, error_type) abort endif let l:loclist = get(l:info, 'semantic_loclist', []) + \ + get(l:info, 'suggestion_loclist', []) \ + get(l:info, 'syntax_loclist', []) call ale#engine#HandleLoclist(l:linter_name, l:buffer, l:loclist, 0) @@ -150,6 +157,10 @@ function! ale#lsp_linter#HandleLSPResponse(conn_id, response) abort elseif get(a:response, 'type', '') is# 'event' \&& get(a:response, 'event', '') is# 'syntaxDiag' call s:HandleTSServerDiagnostics(a:response, 'syntax') + elseif get(a:response, 'type', '') is# 'event' + \&& get(a:response, 'event', '') is# 'suggestionDiag' + \&& get(g:, 'ale_lsp_suggestions', '1') == 1 + call s:HandleTSServerDiagnostics(a:response, 'suggestion') endif endfunction @@ -190,7 +201,11 @@ function! ale#lsp_linter#GetConfig(buffer, linter) abort endfunction function! ale#lsp_linter#FindProjectRoot(buffer, linter) abort - let l:buffer_ale_root = getbufvar(a:buffer, 'ale_lsp_root', {}) + let l:buffer_ale_root = getbufvar( + \ a:buffer, + \ 'ale_root', + \ getbufvar(a:buffer, 'ale_lsp_root', {}) + \) if type(l:buffer_ale_root) is v:t_string return l:buffer_ale_root @@ -207,9 +222,15 @@ function! ale#lsp_linter#FindProjectRoot(buffer, linter) abort endif endif + let l:global_root = g:ale_root + + if empty(g:ale_root) && exists('g:ale_lsp_root') + let l:global_root = g:ale_lsp_root + endif + " Try to get a global setting for the root - if has_key(g:ale_lsp_root, a:linter.name) - let l:Root = g:ale_lsp_root[a:linter.name] + if has_key(l:global_root, a:linter.name) + let l:Root = l:global_root[a:linter.name] if type(l:Root) is v:t_func return l:Root(a:buffer) @@ -273,13 +294,15 @@ function! s:StartLSP(options, address, executable, command) abort call ale#lsp#MarkConnectionAsTsserver(l:conn_id) endif + let l:cwd = ale#linter#GetCwd(l:buffer, l:linter) let l:command = ale#command#FormatCommand( \ l:buffer, \ a:executable, \ a:command, \ 0, \ v:false, - \ [], + \ l:cwd, + \ ale#GetFilenameMappings(l:buffer, l:linter.name), \)[1] let l:command = ale#job#PrepareCommand(l:buffer, l:command) let l:ready = ale#lsp#StartProgram(l:conn_id, a:executable, l:command) diff --git a/sources_non_forked/ale/autoload/ale/maven.vim b/sources_non_forked/ale/autoload/ale/maven.vim index 745f8c93..4f87ebb7 100644 --- a/sources_non_forked/ale/autoload/ale/maven.vim +++ b/sources_non_forked/ale/autoload/ale/maven.vim @@ -17,7 +17,6 @@ function! ale#maven#FindProjectRoot(buffer) abort 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. @@ -25,7 +24,7 @@ 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) + if !empty(l:wrapper_path) && executable(l:wrapper_path) return l:wrapper_path endif @@ -36,16 +35,23 @@ function! ale#maven#FindExecutable(buffer) abort 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. +" Given a buffer number, get a working directory and command to print the +" classpath of the root project. +" +" Returns an empty string for the command if Maven is not detected. 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' + if !empty(l:executable) + let l:project_root = ale#maven#FindProjectRoot(a:buffer) + + if !empty(l:project_root) + return [ + \ l:project_root, + \ ale#Escape(l:executable) . ' dependency:build-classpath' + \] + endif endif - return '' + return ['', ''] endfunction diff --git a/sources_non_forked/ale/autoload/ale/node.vim b/sources_non_forked/ale/autoload/ale/node.vim index 9b9b335a..9e11ca7e 100644 --- a/sources_non_forked/ale/autoload/ale/node.vim +++ b/sources_non_forked/ale/autoload/ale/node.vim @@ -3,38 +3,6 @@ call ale#Set('windows_node_executable_path', 'node.exe') -" 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. -" -" The use_global and executable options for the relevant program will be used. -function! ale#node#FindExecutable(buffer, base_var_name, path_list) abort - if ale#Var(a:buffer, a:base_var_name . '_use_global') - 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) - - if !empty(l:executable) - return l:executable - endif - endfor - - return '' -endfunction - " Create a executable string which executes a Node.js script command with a " Node.js executable if needed. " diff --git a/sources_non_forked/ale/autoload/ale/path.vim b/sources_non_forked/ale/autoload/ale/path.vim index fed95ccd..c7bfd47e 100644 --- a/sources_non_forked/ale/autoload/ale/path.vim +++ b/sources_non_forked/ale/autoload/ale/path.vim @@ -77,24 +77,40 @@ function! ale#path#ResolveLocalPath(buffer, search_string, global_fallback) abor return l:path endfunction -" Output 'cd && ' -" This function can be used changing the directory for a linter command. -function! ale#path#CdString(directory) abort - if has('win32') - return 'cd /d ' . ale#Escape(a:directory) . ' && ' - endif +" 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 program. +function! ale#path#FindNearestExecutable(buffer, path_list) abort + for l:path in a:path_list + if ale#path#IsAbsolute(l:path) + let l:executable = filereadable(l:path) ? l:path : '' + else + let l:executable = ale#path#FindNearestFile(a:buffer, l:path) + endif - return 'cd ' . ale#Escape(a:directory) . ' && ' + if !empty(l:executable) + return l:executable + endif + endfor + + return '' endfunction -" Output 'cd && ' -" This function can be used changing the directory for a linter command. -function! ale#path#BufferCdString(buffer) abort - if has('win32') - return 'cd /d %s:h && ' +" 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 program. +" +" The use_global and executable options for the relevant program will be used. +function! ale#path#FindExecutable(buffer, base_var_name, path_list) abort + if ale#Var(a:buffer, a:base_var_name . '_use_global') + return ale#Var(a:buffer, a:base_var_name . '_executable') endif - return 'cd %s:h && ' + let l:nearest = ale#path#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 " Return 1 if a path is an absolute path. @@ -136,7 +152,7 @@ function! ale#path#Dirname(path) abort endif " For /foo/bar/ we need :h:h to get /foo - if a:path[-1:] is# '/' + if a:path[-1:] is# '/' || (has('win32') && a:path[-1:] is# '\') return fnamemodify(a:path, ':h:h') endif diff --git a/sources_non_forked/ale/autoload/ale/preview.vim b/sources_non_forked/ale/autoload/ale/preview.vim index 8b94aa7a..1aca03ea 100644 --- a/sources_non_forked/ale/autoload/ale/preview.vim +++ b/sources_non_forked/ale/autoload/ale/preview.vim @@ -1,7 +1,7 @@ " Author: w0rp " Description: Preview windows for showing whatever information in. -if !has_key(s:, 'last__list') +if !has_key(s:, 'last_list') let s:last_list = [] endif @@ -89,6 +89,13 @@ function! ale#preview#ShowSelection(item_list, ...) abort let b:ale_preview_item_list = a:item_list let b:ale_preview_item_open_in = get(l:options, 'open_in', 'current-buffer') + " Jump to an index for a previous selection, if set. + if has_key(l:options, 'jump_to_index') + let l:pos = getpos('.') + let l:pos[1] = l:options.jump_to_index + 1 + call setpos('.', l:pos) + endif + " Remember preview state, so we can repeat it later. call ale#preview#SetLastSelection(a:item_list, l:options) endfunction @@ -101,12 +108,16 @@ 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, {}) + let l:index = getpos('.')[1] - 1 + let l:item = get(l:item_list, l:index, {}) if empty(l:item) return endif + " Remember an index to jump to when repeating a selection. + let s:last_options.jump_to_index = l:index + :q! call ale#util#Open( diff --git a/sources_non_forked/ale/autoload/ale/python.vim b/sources_non_forked/ale/autoload/ale/python.vim index 7ed22367..ee856a27 100644 --- a/sources_non_forked/ale/autoload/ale/python.vim +++ b/sources_non_forked/ale/autoload/ale/python.vim @@ -2,6 +2,7 @@ " Description: Functions for integrating with Python linters. call ale#Set('python_auto_pipenv', '0') +call ale#Set('python_auto_poetry', '0') let s:sep = has('win32') ? '\' : '/' " bin is used for Unix virtualenv directories, and Scripts is for Windows. @@ -32,6 +33,9 @@ function! ale#python#FindProjectRootIni(buffer) abort \|| filereadable(l:path . '/.pylintrc') \|| filereadable(l:path . '/Pipfile') \|| filereadable(l:path . '/Pipfile.lock') + \|| filereadable(l:path . '/poetry.lock') + \|| filereadable(l:path . '/pyproject.toml') + \|| filereadable(l:path . '/.tool-versions') return l:path endif endfor @@ -155,3 +159,8 @@ endfunction function! ale#python#PipenvPresent(buffer) abort return findfile('Pipfile.lock', expand('#' . a:buffer . ':p:h') . ';') isnot# '' endfunction + +" Detects whether a poetry environment is present. +function! ale#python#PoetryPresent(buffer) abort + return findfile('poetry.lock', expand('#' . a:buffer . ':p:h') . ';') isnot# '' +endfunction diff --git a/sources_non_forked/ale/autoload/ale/racket.vim b/sources_non_forked/ale/autoload/ale/racket.vim new file mode 100644 index 00000000..ff896108 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/racket.vim @@ -0,0 +1,12 @@ +function! ale#racket#FindProjectRoot(buffer) abort + let l:cwd = expand('#' . a:buffer . ':p:h') + let l:highest_init = l:cwd + + for l:path in ale#path#Upwards(l:cwd) + if filereadable(l:path.'/init.rkt') + let l:highest_init = l:path + endif + endfor + + return l:highest_init +endfunction diff --git a/sources_non_forked/ale/autoload/ale/sign.vim b/sources_non_forked/ale/autoload/ale/sign.vim index 8109c60e..21e06313 100644 --- a/sources_non_forked/ale/autoload/ale/sign.vim +++ b/sources_non_forked/ale/autoload/ale/sign.vim @@ -50,9 +50,10 @@ if !hlexists('ALESignColumnWithErrors') endif function! ale#sign#SetUpDefaultColumnWithoutErrorsHighlight() abort - redir => l:output - 0verbose silent highlight SignColumn - redir end + let l:verbose = &verbose + set verbose=0 + let l:output = execute('highlight SignColumn', 'silent') + let &verbose = l:verbose let l:highlight_syntax = join(split(l:output)[2:]) let l:match = matchlist(l:highlight_syntax, '\vlinks to (.+)$') @@ -84,7 +85,7 @@ execute 'sign define ALEStyleWarningSign text=' . s:EscapeSignText(g:ale_sign_st \ . ' texthl=ALEStyleWarningSign linehl=ALEWarningLine' execute 'sign define ALEInfoSign text=' . s:EscapeSignText(g:ale_sign_info) \ . ' texthl=ALEInfoSign linehl=ALEInfoLine' -sign define ALEDummySign +sign define ALEDummySign text=\ texthl=SignColumn if g:ale_sign_highlight_linenrs && has('nvim-0.3.2') if !hlexists('ALEErrorSignLineNr') @@ -168,10 +169,10 @@ endfunction " Read sign data for a buffer to a list of lines. function! ale#sign#ReadSigns(buffer) abort - redir => l:output - silent execute 'sign place ' . s:GroupCmd() . s:PriorityCmd() - \ . ' buffer=' . a:buffer - redir end + let l:output = execute( + \ 'sign place ' . s:GroupCmd() . s:PriorityCmd() + \ . ' buffer=' . a:buffer + \ ) return split(l:output, "\n") endfunction @@ -200,6 +201,27 @@ function! ale#sign#ParsePattern() abort return l:pattern endfunction +" Given a buffer number, return a List of placed signs [line, id, group] +function! ale#sign#ParseSignsWithGetPlaced(buffer) abort + let l:signs = sign_getplaced(a:buffer, { 'group': s:supports_sign_groups ? 'ale' : '' })[0].signs + let l:result = [] + let l:is_dummy_sign_set = 0 + + for l:sign in l:signs + if l:sign['name'] is# 'ALEDummySign' + let l:is_dummy_sign_set = 1 + else + call add(l:result, [ + \ str2nr(l:sign['lnum']), + \ str2nr(l:sign['id']), + \ l:sign['name'], + \]) + endif + endfor + + return [l:is_dummy_sign_set, l:result] +endfunction + " Given a list of lines for sign output, return a List of [line, id, group] function! ale#sign#ParseSigns(line_list) abort let l:pattern =ale#sign#ParsePattern() @@ -226,9 +248,13 @@ function! ale#sign#ParseSigns(line_list) abort endfunction function! ale#sign#FindCurrentSigns(buffer) abort - let l:line_list = ale#sign#ReadSigns(a:buffer) + if exists('*sign_getplaced') + return ale#sign#ParseSignsWithGetPlaced(a:buffer) + else + let l:line_list = ale#sign#ReadSigns(a:buffer) - return ale#sign#ParseSigns(l:line_list) + return ale#sign#ParseSigns(l:line_list) + endif endfunction " Given a loclist, group the List into with one List per line. diff --git a/sources_non_forked/ale/autoload/ale/socket.vim b/sources_non_forked/ale/autoload/ale/socket.vim index 7e069fb5..61f11e70 100644 --- a/sources_non_forked/ale/autoload/ale/socket.vim +++ b/sources_non_forked/ale/autoload/ale/socket.vim @@ -72,9 +72,8 @@ function! ale#socket#Open(address, options) abort elseif exists('*chansend') && exists('*sockconnect') " NeoVim 0.3+ try - let l:channel_id = sockconnect('tcp', a:address, { - \ 'on_data': function('s:NeoVimOutputCallback'), - \}) + let l:channel_id = sockconnect(stridx(a:address, ':') != -1 ? 'tcp' : 'pipe', + \ a:address, {'on_data': function('s:NeoVimOutputCallback')}) let l:channel_info.last_line = '' catch /connection failed/ let l:channel_id = -1 diff --git a/sources_non_forked/ale/autoload/ale/swift.vim b/sources_non_forked/ale/autoload/ale/swift.vim index b31b8dc5..3232d42a 100644 --- a/sources_non_forked/ale/autoload/ale/swift.vim +++ b/sources_non_forked/ale/autoload/ale/swift.vim @@ -11,3 +11,60 @@ function! ale#swift#FindProjectRoot(buffer) abort return '' endfunction + +" Support Apple Swift Format {{{1 + +call ale#Set('swift_appleswiftformat_executable', 'swift-format') +call ale#Set('swift_appleswiftformat_use_swiftpm', 0) + +" Return the executable depending on whether or not to use Swift Package Manager. +" +" If not asked to use Swift Package Manager (use_swiftpm = 0), the returned +" value is the global executable, else the returned value is 'swift' because +" the final command line will be `swift run swift-format ...`. +" +" Failure is expected if use_swiftpm is `1` but no Package.swift can be located. +function! ale#swift#GetAppleSwiftFormatExecutable(buffer) abort + if !ale#Var(a:buffer, 'swift_appleswiftformat_use_swiftpm') + return ale#Var(a:buffer, 'swift_appleswiftformat_executable') + endif + + if ale#path#FindNearestFile(a:buffer, 'Package.swift') is# '' + " If there is no Package.swift file, we don't use swift-format even if it exists, + " so we return '' to indicate failure. + return '' + endif + + return 'swift' +endfunction + +" Return the command depending on whether or not to use Swift Package Manager. +" +" If asked to use Swift Package Manager (use_swiftpm = 1), the command +" arguments are prefixed with 'swift run'. +" +" In either case, the configuration file is located and added to the command. +function! ale#swift#GetAppleSwiftFormatCommand(buffer) abort + let l:executable = ale#swift#GetAppleSwiftFormatExecutable(a:buffer) + let l:command_args = '' + + if ale#Var(a:buffer, 'swift_appleswiftformat_use_swiftpm') + let l:command_args = ' ' . 'run swift-format' + endif + + return ale#Escape(l:executable) . l:command_args +endfunction + +" Locate the nearest '.swift-format' configuration file, and return the +" arguments, else return an empty string. +function! ale#swift#GetAppleSwiftFormatConfigArgs(buffer) abort + let l:config_filepath = ale#path#FindNearestFile(a:buffer, '.swift-format') + + if l:config_filepath isnot# '' + return '--configuration' . ' ' . l:config_filepath + endif + + return '' +endfunction + +" }}} diff --git a/sources_non_forked/ale/autoload/ale/test.vim b/sources_non_forked/ale/autoload/ale/test.vim index 6fcbf35e..4d75d515 100644 --- a/sources_non_forked/ale/autoload/ale/test.vim +++ b/sources_non_forked/ale/autoload/ale/test.vim @@ -34,12 +34,11 @@ function! ale#test#RestoreDirectory() abort unlet! g:dir endfunction -" Change the filename for the current buffer using a relative path to -" the script without running autocmd commands. +" Get a filename for the current buffer using a relative path to the script. " " If a g:dir variable is set, it will be used as the path to the directory " containing the test file. -function! ale#test#SetFilename(path) abort +function! ale#test#GetFilename(path) abort let l:dir = get(g:, 'dir', '') if empty(l:dir) @@ -50,7 +49,17 @@ function! ale#test#SetFilename(path) abort \ ? a:path \ : l:dir . '/' . a:path - silent! noautocmd execute 'file ' . fnameescape(ale#path#Simplify(l:full_path)) + return ale#path#Simplify(l:full_path) +endfunction + +" Change the filename for the current buffer using a relative path to +" the script without running autocmd commands. +" +" If a g:dir variable is set, it will be used as the path to the directory +" containing the test file. +function! ale#test#SetFilename(path) abort + let l:full_path = ale#test#GetFilename(a:path) + silent! noautocmd execute 'file ' . fnameescape(l:full_path) endfunction function! s:RemoveModule(results) abort diff --git a/sources_non_forked/ale/autoload/ale/util.vim b/sources_non_forked/ale/autoload/ale/util.vim index fcc03eb7..5b2bfcd7 100644 --- a/sources_non_forked/ale/autoload/ale/util.vim +++ b/sources_non_forked/ale/autoload/ale/util.vim @@ -340,6 +340,16 @@ function! ale#util#GetMatches(lines, patterns) abort return l:matches endfunction +" Given a single line, or a List of lines, and a single pattern, or a List of +" patterns, and a callback function for mapping the items matches, return the +" result of mapping all of the matches for the lines from the given patterns, +" using matchlist() +" +" Only the first pattern which matches a line will be returned. +function! ale#util#MapMatches(lines, patterns, Callback) abort + return map(ale#util#GetMatches(a:lines, a:patterns), 'a:Callback(v:val)') +endfunction + function! s:LoadArgCount(function) abort try let l:output = execute('function a:function') @@ -409,7 +419,7 @@ function! ale#util#FuzzyJSONDecode(data, default) abort endif return l:result - catch /E474/ + catch /E474\|E491/ return a:default endtry endfunction @@ -486,7 +496,7 @@ function! ale#util#Input(message, value) abort endfunction function! ale#util#HasBuflineApi() abort - return exists('*deletebufline') && exists('*appendbufline') && exists('*getpos') && exists('*setpos') + return exists('*deletebufline') && exists('*setbufline') endfunction " Sets buffer contents to lines @@ -507,11 +517,8 @@ function! ale#util#SetBufferContents(buffer, lines) abort " 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) + 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 = line('$') diff --git a/sources_non_forked/ale/doc/ale-ada.txt b/sources_non_forked/ale/doc/ale-ada.txt index 2ac30c0a..0fc55a9c 100644 --- a/sources_non_forked/ale/doc/ale-ada.txt +++ b/sources_non_forked/ale/doc/ale-ada.txt @@ -32,5 +32,35 @@ g:ale_ada_gnatpp_options *g:ale_ada_gnatpp_options* This variable can be set to pass extra options to the gnatpp fixer. +=============================================================================== +ada-language-server *ale-ada-language-server* + +g:ale_ada_adals_executable *g:ale_ada_adals_executable* + *b:ale_ada_adals_executable* + Type: |String| + Default: `'ada_language_server'` + + This variable can be changed to use a different executable for Ada Language + Server. + + +g:ale_ada_adals_project *g:ale_ada_adals_project* + *b:ale_ada_adals_project* + Type: |String| + Default: `'default.gpr'` + +This variable can be changed to use a different GPR file for +Ada Language Server. + + +g:ale_ada_adals_encoding *g:ale_ada_adals_encoding* + *b:ale_ada_adals_encoding* + Type: |String| + Default: `'utf-8'` + +This variable can be changed to use a different file encoding for +Ada Language Server. + + =============================================================================== vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-apkbuild.txt b/sources_non_forked/ale/doc/ale-apkbuild.txt new file mode 100644 index 00000000..05261400 --- /dev/null +++ b/sources_non_forked/ale/doc/ale-apkbuild.txt @@ -0,0 +1,30 @@ +=============================================================================== +ALE APKBUILD Integration *ale-apkbuild-options* + + +=============================================================================== +apkbuild-lint *ale-apkbuild-apkbuild-lint* + +g:ale_apkbuild_apkbuild_lint_executable + *g:ale_apkbuild_apkbuild_lint_executable* + *b:ale_apkbuild_apkbuild_lint_executable* + + Type: |String| + Default: `'apkbuild-lint'` + + This variable can be set to change the path to apkbuild-lint + +=============================================================================== +secfixes-check *ale-apkbuild-secfixes-check* + +g:ale_apkbuild_secfixes_check_executable + *g:ale_apkbuild_secfixes_check_executable* + *b:ale_apkbuild_secfixes_check_executable* + + Type: |String| + Default: `'secfixes-check'` + + This variable can be set to change the path to secfixes-check + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-bazel.txt b/sources_non_forked/ale/doc/ale-bazel.txt new file mode 100644 index 00000000..e2922aaf --- /dev/null +++ b/sources_non_forked/ale/doc/ale-bazel.txt @@ -0,0 +1,28 @@ +=============================================================================== +ALE Bazel Integration *ale-bazel-options* + +=============================================================================== +buildifier *ale-bazel-buildifier* + +g:ale_bazel_buildifier_executable *g:ale_bazel_buildifier_executable* + *b:ale_bazel_buildifier_executable* + Type: |String| + Default: `'buildifier'` + + See |ale-integrations-local-executables| + + +g:ale_bazel_buildifier_options *g:ale_bazel_buildifier_options* + *b:ale_bazel_buildifier_options* + Type: |String| + Default: `''` + + This variable can be set to pass extra options to buildifier. + + +g:ale_bazel_buildifier_use_global *g:ale_bazel_buildifier_use_global* + *b:ale_bazel_buildifier_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-c.txt b/sources_non_forked/ale/doc/ale-c.txt index b0d94b8e..3b9fbc44 100644 --- a/sources_non_forked/ale/doc/ale-c.txt +++ b/sources_non_forked/ale/doc/ale-c.txt @@ -202,7 +202,45 @@ g:ale_c_clangformat_options *g:ale_c_clangformat_options* Type: |String| Default: `''` - This variable can be change to modify flags given to clang-format. + This variable can be changed to modify flags given to clang-format. + + +g:ale_c_clangformat_style_option *g:ale_c_clangformat_style_option* + *b:ale_c_clangformat_style_option* + Type: |String| + Default: `''` + + This variable can be changed to modify only the style flag given to + clang-format. The contents of the variable are passed directly to the -style + flag of clang-format. + + Example: > + { + \ BasedOnStyle: Microsoft, + \ ColumnLimit: 80, + \ AllowShortBlocksOnASingleLine: Always, + \ AllowShortFunctionsOnASingleLine: Inline, + \ } +< + If you set this variable, ensure you don't modify -style in + |g:ale_c_clangformat_options|, as this will cause clang-format to error. + + +g:ale_c_clangformat_use_local_file *g:ale_c_clangformat_use_local_file* + *b:ale_c_clangformat_use_local_file* + Type: |Number| + Default: `0` + + This variable can be changed to modify whether to use a local .clang-format + file. If the file is found, the flag '-style=file' is passed to clang-format + and any options configured via |g:ale_c_clangformat_style_option| are not + passed. + + If this option is enabled but no .clang-format file is found, default back to + |g:ale_c_clangformat_style_option|, if it set. + + If you set this variable, ensure you don't modify -style in + |g:ale_c_clangformat_options|, as this will cause clang-format to error. =============================================================================== diff --git a/sources_non_forked/ale/doc/ale-clojure.txt b/sources_non_forked/ale/doc/ale-clojure.txt index 2bf00c03..3ff367f6 100644 --- a/sources_non_forked/ale/doc/ale-clojure.txt +++ b/sources_non_forked/ale/doc/ale-clojure.txt @@ -9,6 +9,14 @@ A minimal and opinionated linter for code that sparks joy. https://github.com/borkdude/clj-kondo +g:ale_clojure_clj_kondo_options *g:ale_clojure_clj_kondo_options* + *b:ale_clojure_clj_kondo_options* + Type: |String| + Default: `'--cache'` + + This variable can be changed to modify options passed to clj-kondo. + + =============================================================================== joker *ale-clojure-joker* diff --git a/sources_non_forked/ale/doc/ale-cuda.txt b/sources_non_forked/ale/doc/ale-cuda.txt index 0e53f756..06aa48ce 100644 --- a/sources_non_forked/ale/doc/ale-cuda.txt +++ b/sources_non_forked/ale/doc/ale-cuda.txt @@ -21,6 +21,24 @@ g:ale_cuda_nvcc_options *g:ale_cuda_nvcc_options* This variable can be changed to modify flags given to nvcc. +=============================================================================== +clangd *ale-cuda-clangd* + +g:ale_cuda_clangd_executable *g:ale_cuda_clangd_executable* + *b:ale_cuda_clangd_executable* + Type: |String| + Default: `'clangd'` + + This variable can be changed to use a different executable for clangd. + + +g:ale_cuda_clangd_options *g:ale_cuda_clangd_options* + *b:ale_cuda_clangd_options* + Type: |String| + Default: `''` + + This variable can be changed to modify flags given to clangd. + =============================================================================== clang-format *ale-cuda-clangformat* diff --git a/sources_non_forked/ale/doc/ale-dafny.txt b/sources_non_forked/ale/doc/ale-dafny.txt new file mode 100644 index 00000000..005170ad --- /dev/null +++ b/sources_non_forked/ale/doc/ale-dafny.txt @@ -0,0 +1,16 @@ +=============================================================================== +ALE Dafny Integration *ale-dafny-options* + + +=============================================================================== +dafny *ale-dafny-dafny* + +g:ale_dafny_dafny_timelimit *g:ale_dafny_dafny_timelimit* + *b:ale_dafny_dafny_timelimit* + Type: |Number| + Default: `10` + + This variable sets the `/timeLimit` used for dafny. + + + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-dart.txt b/sources_non_forked/ale/doc/ale-dart.txt index a6d88dd8..a046808b 100644 --- a/sources_non_forked/ale/doc/ale-dart.txt +++ b/sources_non_forked/ale/doc/ale-dart.txt @@ -2,6 +2,92 @@ ALE Dart Integration *ale-dart-options* +=============================================================================== +analysis_server *ale-dart-analysis_server* + +Installation +------------------------------------------------------------------------------- + +Install Dart via whatever means. `analysis_server` will be included in the SDK. + +In case that `dart` is not in your path, try to set the executable option to +its absolute path. : > + " Set the executable path for dart to the absolute path to it. + let g:ale_dart_analysis_server_executable = '/usr/local/bin/dart' +< + +Options +------------------------------------------------------------------------------- + +g:ale_dart_analysis_server_executable *g:ale_dart_analysis_server_executable* + *b:ale_dart_analysis_server_executable* + Type: |String| + Default: `'dart'` + + This variable can be set to change the path of dart. + + +=============================================================================== +dart-analyze *ale-dart-analyze* + +Installation +------------------------------------------------------------------------------- + +Installing Dart should probably ensure that `dart` is in your `$PATH`. + +In case it is not, try to set the executable option to its absolute path. : > + " Set the executable path for dart to the absolute path to it. + let g:ale_dart_format_executable = '/usr/lib/dart/bin/dart' + > + +Install Dart via whatever means. `dart analyze` will be included in the SDK. + +Options +------------------------------------------------------------------------------- + +g:ale_dart_analyze_executable *g:ale_dart_analyze_executable* + *b:ale_dart_analyze_executable* + Type: |String| + Default: `'dart'` + + This variable can be set to specify an absolute path to the + format executable (or to specify an alternate executable). + + +=============================================================================== +dart-format *ale-dart-format* + +Installation +------------------------------------------------------------------------------- + +Installing Dart should probably ensure that `dart` is in your `$PATH`. + +In case it is not, try to set the executable option to its absolute path. : > + " Set the executable path for dart to the absolute path to it. + let g:ale_dart_format_executable = '/usr/lib/dart/bin/dart' + > + +Options +------------------------------------------------------------------------------- + +g:ale_dart_format_executable *g:ale_dart_format_executable* + *b:ale_dart_format_executable* + Type: |String| + Default: `'dart'` + + This variable can be set to specify an absolute path to the + format executable (or to specify an alternate executable). + + +g:ale_dart_format_options *g:ale_dart_format_options* + *b:ale_dart_format_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to the dart format fixer. + + + =============================================================================== dartanalyzer *ale-dart-dartanalyzer* diff --git a/sources_non_forked/ale/doc/ale-desktop.txt b/sources_non_forked/ale/doc/ale-desktop.txt new file mode 100644 index 00000000..62269e9c --- /dev/null +++ b/sources_non_forked/ale/doc/ale-desktop.txt @@ -0,0 +1,21 @@ +=============================================================================== +ALE desktop Integration *ale-desktop-options* + + +=============================================================================== +desktop-file-validate *ale-desktop-desktop-file-validate* + +ALE supports checking .desktop files with `desktop-file-validate.` + + +g:ale_desktop_desktop_file_validate_options + *g:ale_desktop_desktop_file_validate_options* + *b:ale_desktop_desktop_file_validate_options* + Type: |String| + Default: `''` + + This variable can be changed to set options for `desktop-file-validate`, + such as `'--warn-kde'`. + +=============================================================================== + 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 afd9798f..7f8ec28f 100644 --- a/sources_non_forked/ale/doc/ale-development.txt +++ b/sources_non_forked/ale/doc/ale-development.txt @@ -148,13 +148,14 @@ Apply the following rules when writing Bash scripts. =============================================================================== 4. Testing ALE *ale-development-tests* *ale-dev-tests* *ale-tests* -ALE is tested with a suite of tests executed in Travis CI and AppVeyor. ALE -runs tests with the following versions of Vim in the following environments. +ALE is tested with a suite of tests executed via GitHub Actions and AppVeyor. +ALE runs tests with the following versions of Vim in the following +environments. -1. Vim 8.0.0027 on Linux via Travis CI. -2. Vim 8.1.0519 on Linux via Travis CI. -3. NeoVim 0.2.0 on Linux via Travis CI. -4. NeoVim 0.3.5 on Linux via Travis CI. +1. Vim 8.0.0027 on Linux via GitHub Actions. +2. Vim 8.2.2401 on Linux via GitHub Actions. +3. NeoVim 0.2.0 on Linux via GitHub Actions. +4. NeoVim 0.4.4 on Linux via GitHub Actions. 5. Vim 8 (stable builds) on Windows via AppVeyor. If you are developing ALE code on Linux, Mac OSX, or BSD, you can run ALEs @@ -180,19 +181,24 @@ Generally write tests for any changes you make. The following types of tests are recommended for the following types of code. * New/edited error handler callbacks -> Write tests in `test/handler` -* New/edited command callbacks -> Write tests in `test/command_callback` +* New/edited linter definition -> Write tests in `test/linter` * New/edited fixer functions -> Write tests in `test/fixers` Look at existing tests in the codebase for examples of how to write tests. Refer to the Vader documentation for general information on how to write Vader tests: https://github.com/junegunn/vader.vim +If you need to add any supporting files for tests, such as empty files present +to test searching upwards through paths for configuration files, they can be +added to the `test/test-files` directory. + See |ale-development-linter-tests| for more information on how to write linter tests. When you add new linters or fixers, make sure to add them into the tables in supported-tools.md and |ale-supported-languages-and-tools.txt|. If you forget to -keep them both in sync, you should see an error like the following in Travis CI. +keep them both in sync, you should see an error like the following in the +builds run for GitHub Actions. > ======================================== diff supported-tools.md and doc/ale-supported-languages-and-tools.txt tables @@ -272,8 +278,8 @@ be written like so. > \ '1:Something went wrong', \ ] < -Tests for what ALE runs should go in the `test/command_callback` directory, -and should be written like so. > +Tests for what ALE runs should go in the `test/linter` directory, and should +be written like so. > Before: " Load the linter and set up a series of commands, reset linter variables, @@ -309,6 +315,7 @@ The full list of commands that will be temporarily defined for linter tests given the above setup are as follows. `GivenCommandOutput [...]` - Define output for ale#command#Run. +`AssertLinterCwd cwd` - Check the `cwd` for the linter. `AssertLinter executable, command` - Check the executable and command. `AssertLinterNotExecuted` - Check that linters will not be executed. `AssertLSPLanguage language` - Check the language given to an LSP server. @@ -355,6 +362,7 @@ The full list of commands that will be temporarily defined for fixer tests given the above setup are as follows. `GivenCommandOutput [...]` - Define output for ale#command#Run. +`AssertFixerCwd cwd` - Check the `cwd` for the fixer. `AssertFixer results` - Check the fixer results `AssertFixerNotExecuted` - Check that fixers will not be executed. diff --git a/sources_non_forked/ale/doc/ale-dhall.txt b/sources_non_forked/ale/doc/ale-dhall.txt new file mode 100644 index 00000000..44b0bf32 --- /dev/null +++ b/sources_non_forked/ale/doc/ale-dhall.txt @@ -0,0 +1,52 @@ +=============================================================================== +ALE Dhall Integration *ale-dhall-options* + +g:ale_dhall_executable *g:ale_dhall_executable* + *b:ale_dhall_executable* + Type: |String| + Default: `'dhall'` + +g:ale_dhall_options g:ale_dhall_options + b:ale_dhall_options + Type: |String| + Default: `''` + + This variable can be set to pass additional options to the 'dhall` executable. + This is shared with `dhall-freeze` and `dhall-lint`. +> + let g:dhall_options = '--ascii' +< + +=============================================================================== +dhall-format *ale-dhall-format* + +Dhall + (https://dhall-lang.org/) + + +=============================================================================== +dhall-freeze *ale-dhall-freeze* + +Dhall + (https://dhall-lang.org/) + +g:ale_dhall_freeze_options g:ale_dhall_freeze_options + b:ale_dhall_freeze_options + Type: |String| + Default: `''` + + This variable can be set to pass additional options to the 'dhall freeze` + executable. +> + let g:dhall_freeze_options = '--all' +< + +=============================================================================== +dhall-lint *ale-dhall-lint* + +Dhall + (https://dhall-lang.org/) + + +=============================================================================== + 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 de9daacf..a4e5c2c6 100644 --- a/sources_non_forked/ale/doc/ale-elixir.txt +++ b/sources_non_forked/ale/doc/ale-elixir.txt @@ -85,5 +85,12 @@ g:ale_elixir_credo_strict *g:ale_elixir_credo_strict* Tells credo to run in strict mode or suggest mode. Set variable to 1 to enable --strict mode. +g:ale_elixir_credo_config_file g:ale_elixir_credo_config_file + + Type: String + Default: '' + + Tells credo to use a custom configuration file. + =============================================================================== vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-erlang.txt b/sources_non_forked/ale/doc/ale-erlang.txt index 38762f08..ede179d1 100644 --- a/sources_non_forked/ale/doc/ale-erlang.txt +++ b/sources_non_forked/ale/doc/ale-erlang.txt @@ -13,6 +13,14 @@ g:ale_erlang_dialyzer_executable *g:ale_erlang_dialyzer_executable* This variable can be changed to specify the dialyzer executable. +g:ale_erlang_dialyzer_options *g:ale_erlang_dialyzer_options* + *b:ale_erlang_dialyzer_options* + Type: |String| + Default: `'-Wunmatched_returns -Werror_handling -Wrace_conditions -Wunderspec'` + + This variable can be changed to specify the options to pass to the dialyzer + executable. + g:ale_erlang_dialyzer_plt_file *g:ale_erlang_dialyzer_plt_file* *b:ale_erlang_dialyzer_plt_file* Type: |String| @@ -46,6 +54,14 @@ g:ale_erlang_elvis_executable *g:ale_erlang_elvis_executable* ------------------------------------------------------------------------------- erlc *ale-erlang-erlc* +g:ale_erlang_erlc_executable *g:ale_erlang_erlc_executable* + *b:ale_erlang_erlc_executable* + Type: |String| + Default: `'erlc'` + + This variable can be changed to specify the erlc executable. + + g:ale_erlang_erlc_options *g:ale_erlang_erlc_options* *b:ale_erlang_erlc_options* Type: |String| @@ -55,6 +71,26 @@ g:ale_erlang_erlc_options *g:ale_erlang_erlc_options* or `-pa`. +------------------------------------------------------------------------------- +erlfmt *ale-erlang-erlfmt* + +g:ale_erlang_erlfmt_executable *g:ale_erlang_erlfmt_executable* + *b:ale_erlang_erlfmt_executable* + Type: |String| + Default: `'erlfmt'` + + This variable can be changed to specify the erlfmt executable. + + +g:ale_erlang_erlfmt_options *g:ale_erlang_erlfmt_options* + *b:ale_erlang_erlfmt_options* + Type: |String| + Default: `''` + + This variable controls additional parameters passed to `erlfmt`, such as + `--insert-pragma` or `--print-width`. + + ------------------------------------------------------------------------------- syntaxerl *ale-erlang-syntaxerl* diff --git a/sources_non_forked/ale/doc/ale-fish.txt b/sources_non_forked/ale/doc/ale-fish.txt index 8450b38a..7dbbc10c 100644 --- a/sources_non_forked/ale/doc/ale-fish.txt +++ b/sources_non_forked/ale/doc/ale-fish.txt @@ -10,5 +10,22 @@ displaying errors if an error message is not found. If ALE is not showing any errors but your file does not run as expected, run `fish -n ` from the command line. +=============================================================================== +fish_indent *ale-fish-fish_indent* + +g:ale_fish_fish_indent_executable *g:ale_fish_fish_indent_executable* + *b:ale_fish_fish_indent_executable* + Type: |String| + Default: `'fish_indent'` + + This variable can be changed to use a different executable for fish_indent. + +g:ale_fish_fish_indent_options *g:ale_fish_fish_indent_options* + *b:ale_fish_fish_indent_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to fish_indent. + =============================================================================== vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-go.txt b/sources_non_forked/ale/doc/ale-go.txt index 5c0791bc..7813c7b3 100644 --- a/sources_non_forked/ale/doc/ale-go.txt +++ b/sources_non_forked/ale/doc/ale-go.txt @@ -20,8 +20,8 @@ the benefit of running a number of linters, more than ALE would by default, while ensuring it doesn't run any linters known to be slow or resource intensive. -g:ale_go_go_executable *g:ale_go_go_options* - *b:ale_go_go_options* +g:ale_go_go_executable *g:ale_go_go_executable* + *b:ale_go_go_executable* Type: |String| Default: `'go'` @@ -194,12 +194,30 @@ g:ale_go_gometalinter_lint_package *g:ale_go_gometalinter_lint_package* =============================================================================== gopls *ale-go-gopls* +gopls is the official Go language server, and is enabled for use with ALE by +default. + +To install the latest stable version of `gopls` to your `$GOPATH`, try the +following command: > + + GO111MODULE=on go get golang.org/x/tools/gopls@latest +< +If `$GOPATH` is readable by ALE, it should probably work without you having to +do anything else. See the `gopls` README file for more information: + +https://github.com/golang/tools/blob/master/gopls/README.md + + g:ale_go_gopls_executable *g:ale_go_gopls_executable* *b:ale_go_gopls_executable* Type: |String| Default: `'gopls'` - Location of the gopls binary file. + See |ale-integrations-local-executables| + + ALE will search for `gopls` in locally installed directories first by + default, and fall back on a globally installed `gopls` if it can't be found + otherwise. g:ale_go_gopls_options *g:ale_go_gopls_options* @@ -207,6 +225,36 @@ g:ale_go_gopls_options *g:ale_go_gopls_options* Type: |String| Default: `''` + Command-line options passed to the gopls executable. See `gopls -h`. + + +g:ale_go_gopls_init_options *g:ale_go_gopls_init_options* + *b:ale_go_gopls_init_options* + Type: |Dictionary| + Default: `{}` + + LSP initialization options passed to gopls. This can be used to configure + the behaviour of gopls. + + Example: > + let g:ale_go_gopls_init_options = {'ui.diagnostic.analyses': { + \ 'composites': v:false, + \ 'unusedparams': v:true, + \ 'unusedresult': v:true, + \ }} +< + + For a full list of supported analyzers, see: + https://github.com/golang/tools/blob/master/gopls/doc/analyzers.md + + +g:ale_go_gopls_use_global *g:ale_go_gopls_use_global* + *b:ale_go_gopls_use_global* + Type: |String| + Default: `get(g:, 'ale_use_global_executables', 0)` + + See |ale-integrations-local-executables| + =============================================================================== govet *ale-go-govet* @@ -241,6 +289,18 @@ g:ale_go_revive_options *g:ale_go_revive_options* =============================================================================== staticcheck *ale-go-staticcheck* +g:ale_go_staticcheck_executable *g:ale_go_staticcheck_executable* + *b:ale_go_staticcheck_executable* + Type: |String| + Default: `'staticcheck'` + + See |ale-integrations-local-executables| + + ALE will search for `staticcheck` in locally installed directories first by + default, and fall back on a globally installed `staticcheck` if it can't be + found otherwise. + + g:ale_go_staticcheck_options *g:ale_go_staticcheck_options* *b:ale_go_staticcheck_options* Type: |String| @@ -259,5 +319,13 @@ g:ale_go_staticcheck_lint_package *g:ale_go_staticcheck_lint_package* current file. +g:ale_go_staticcheck_use_global *g:ale_go_staticcheck_use_global* + *b:ale_go_staticcheck_use_global* + Type: |String| + Default: `get(g:, 'ale_use_global_executables', 0)` + + See |ale-integrations-local-executables| + + =============================================================================== vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-haskell.txt b/sources_non_forked/ale/doc/ale-haskell.txt index fde439fe..09894340 100644 --- a/sources_non_forked/ale/doc/ale-haskell.txt +++ b/sources_non_forked/ale/doc/ale-haskell.txt @@ -124,6 +124,18 @@ g:ale_haskell_hlint_options g:ale_haskell_hlint_options executable. +=============================================================================== +hls *ale-haskell-hls* + +g:ale_haskell_hls_executable *g:ale_haskell_hls_executable* + *b:ale_haskell_his_executable* + Type: |String| + Default: `'haskell-language-server-wrapper'` + + This variable can be changed to use a different executable for the haskell + language server. + + =============================================================================== stack-build *ale-haskell-stack-build* diff --git a/sources_non_forked/ale/doc/ale-html.txt b/sources_non_forked/ale/doc/ale-html.txt index c78dc4cd..2c048148 100644 --- a/sources_non_forked/ale/doc/ale-html.txt +++ b/sources_non_forked/ale/doc/ale-html.txt @@ -2,13 +2,41 @@ ALE HTML Integration *ale-html-options* +=============================================================================== +angular *ale-html-angular* + +ALE supports language server features for Angular. You can install it via `npm`: > + + $ npm install --save-dev @angular/language-server +< +Angular 11 and up are supported. + + +g:ale_html_angular_executable *g:ale_html_angular_executable* + *b:ale_html_angular_executable* + Type: |String| + Default: `'ngserver'` + + See |ale-integrations-local-executables| + + +g:ale_html_angular_use_global *g:ale_html_angular_use_global* + *b:ale_html_angular_use_global* + Type: |String| + Default: `get(g:, 'ale_use_global_executables', 0)` + + See |ale-integrations-local-executables| + + =============================================================================== fecs *ale-html-fecs* -`fecs` options for HTMl is the same as the options for JavaScript, -and both of them reads `./.fecsrc` as the default configuration file. +`fecs` options for HTML are the same as the options for JavaScript, and both +of them read `./.fecsrc` as the default configuration file. + See: |ale-javascript-fecs|. + =============================================================================== html-beautify *ale-html-beautify* @@ -47,6 +75,40 @@ g:ale_html_htmlhint_use_global *g:ale_html_htmlhint_use_global* See |ale-integrations-local-executables| + +=============================================================================== +prettier *ale-html-prettier* + +See |ale-javascript-prettier| for information about the available options. + + +=============================================================================== +stylelint *ale-html-stylelint* + +g:ale_html_stylelint_executable *g:ale_html_stylelint_executable* + *b:ale_html_stylelint_executable* + Type: |String| + Default: `'stylelint'` + + See |ale-integrations-local-executables| + + +g:ale_html_stylelint_options *g:ale_html_stylelint_options* + *b:ale_html_stylelint_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to stylelint. + + +g:ale_html_stylelint_use_global *g:ale_html_stylelint_use_global* + *b:ale_html_stylelint_use_global* + Type: |String| + Default: `0` + + See |ale-integrations-local-executables| + + =============================================================================== tidy *ale-html-tidy* @@ -97,39 +159,6 @@ g:ale_html_tidy_use_global *g:html_tidy_use_global* See |ale-integrations-local-executables| -=============================================================================== -prettier *ale-html-prettier* - -See |ale-javascript-prettier| for information about the available options. - - -=============================================================================== -stylelint *ale-html-stylelint* - -g:ale_html_stylelint_executable *g:ale_html_stylelint_executable* - *b:ale_html_stylelint_executable* - Type: |String| - Default: `'stylelint'` - - See |ale-integrations-local-executables| - - -g:ale_html_stylelint_options *g:ale_html_stylelint_options* - *b:ale_html_stylelint_options* - Type: |String| - Default: `''` - - This variable can be set to pass additional options to stylelint. - - -g:ale_html_stylelint_use_global *g:ale_html_stylelint_use_global* - *b:ale_html_stylelint_use_global* - Type: |String| - Default: `0` - - See |ale-integrations-local-executables| - - =============================================================================== write-good *ale-html-write-good* diff --git a/sources_non_forked/ale/doc/ale-inko.txt b/sources_non_forked/ale/doc/ale-inko.txt new file mode 100644 index 00000000..5ca14af6 --- /dev/null +++ b/sources_non_forked/ale/doc/ale-inko.txt @@ -0,0 +1,22 @@ +=============================================================================== +ALE Inko Integration *ale-inko-options* + *ale-integration-inko* + +=============================================================================== +Integration Information + + Currently, the only supported linter for Inko is the Inko compiler itself. + +=============================================================================== +inko *ale-inko-inko* + +g:ale_inko_inko_executable *g:ale_inko_inko_executable* + *b:ale_inko_inko_executable* + Type: |String| + Default: `'inko'` + + This variable can be modified to change the executable path for `inko`. + + +=============================================================================== + 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 0debc1af..6bd04ef9 100644 --- a/sources_non_forked/ale/doc/ale-java.txt +++ b/sources_non_forked/ale/doc/ale-java.txt @@ -193,13 +193,13 @@ The Java language server will look for the dependencies you specify in =============================================================================== eclipselsp *ale-java-eclipselsp* -To enable Eclipse LSP linter you need to clone and build the eclipse.jdt.ls +To enable Eclipse JDT LSP linter you need to clone and build the eclipse.jdt.ls language server from https://github.com/eclipse/eclipse.jdt.ls. Simply clone the source code repo and then build the plugin: ./mvnw clean verify -Note: currently, the build can only run when launched with JDK 8. JDK 9 or more +Note: currently, the build can only run when launched with JDK 11. More recent versions can be used to run the server though. After build completes the files required to run the language server will be diff --git a/sources_non_forked/ale/doc/ale-json.txt b/sources_non_forked/ale/doc/ale-json.txt index 96499a04..dc91e14c 100644 --- a/sources_non_forked/ale/doc/ale-json.txt +++ b/sources_non_forked/ale/doc/ale-json.txt @@ -101,5 +101,37 @@ prettier *ale-json-prettier* See |ale-javascript-prettier| for information about the available options. +=============================================================================== +spectral *ale-json-spectral* + +Website: https://github.com/stoplightio/spectral + +Installation +------------------------------------------------------------------------------- + +Install spectral either globally or locally: > + + npm install @stoplight/spectral -g # global + npm install @stoplight/spectral # local +< + +Options +------------------------------------------------------------------------------- + +g:ale_json_spectral_executable *g:ale_json_spectral_executable* + *b:ale_json_spectral_executable* + Type: |String| + Default: `'spectral'` + + This variable can be set to change the path to spectral. + +g:ale_json_spectral_use_global *g:ale_json_spectral_use_global* + *b:ale_json_spectral_use_global* + Type: |String| + Default: `get(g:, 'ale_use_global_executables', 0)` + + See |ale-integrations-local-executables| + + =============================================================================== vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-lua.txt b/sources_non_forked/ale/doc/ale-lua.txt index 408f0c3c..ac92b9ac 100644 --- a/sources_non_forked/ale/doc/ale-lua.txt +++ b/sources_non_forked/ale/doc/ale-lua.txt @@ -1,6 +1,24 @@ =============================================================================== ALE Lua Integration *ale-lua-options* +=============================================================================== +lua-format *ale-lua-lua-format* + +g:ale_lua_lua_format_executable *g:ale_lua_lua_format_executable* + *b:ale_lua_lua_format_executable* + Type: |String| + Default: `'lua-format'` + + This variable can be changed to change the path to lua-format. + +g:ale_lua_lua_format_options *g:ale_lua_lua_format_options* + *b:ale_lua_lua_format_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to lua-format. + + =============================================================================== luac *ale-lua-luac* @@ -46,5 +64,25 @@ g:ale_lua_luafmt_options *g:ale_lua_luafmt_options* Default: `''` This variable can be set to pass additional options to the luafmt fixer. + + +=============================================================================== +stylua *ale-lua-stylua* + +g:ale_lua_stylua_executable *g:ale_lua_stylua_executable* + *b:ale_lua_stylua_executable* + Type: |String| + Default: `'stylua'` + + This variable can be set to use a different executable for stylua. + +g:ale_lua_stylua_options *g:ale_lua_stylua_options* + *b:ale_lua_stylua_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to the stylua 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 99848878..feb37fc9 100644 --- a/sources_non_forked/ale/doc/ale-markdown.txt +++ b/sources_non_forked/ale/doc/ale-markdown.txt @@ -33,6 +33,25 @@ g:ale_markdown_mdl_options *g:ale_markdown_mdl_options* This variable can be set to pass additional options to mdl. +=============================================================================== +pandoc *ale-markdown-pandoc* + +g:ale_markdown_pandoc_executable *g:ale_markdown_pandoc_executable* + *b:ale_markdown_pandoc_executable* + Type: |String| + Default: `'pandoc'` + + This variable can be set to specify where to find the pandoc executable + + +g:ale_markdown_pandoc_options *g:ale_markdown_pandoc_options* + *b:ale_markdown_pandoc_options* + Type: |String| + Default: `'-f gfm -t gfm -s -'` + + This variable can be set to change the default options passed to pandoc + + =============================================================================== prettier *ale-markdown-prettier* diff --git a/sources_non_forked/ale/doc/ale-nix.txt b/sources_non_forked/ale/doc/ale-nix.txt index 5b2bd6cb..c38b93db 100644 --- a/sources_non_forked/ale/doc/ale-nix.txt +++ b/sources_non_forked/ale/doc/ale-nix.txt @@ -2,6 +2,24 @@ ALE Nix Integration *ale-nix-options* +=============================================================================== +nixfmt *ale-nix-nixfmt* + +g:ale_nix_nixfmt_executable *g:ale_nix_nixfmt_executable* + *b:ale_nix_nixfmt_executable* + Type: String + Default: 'nixfmt' + + This variable sets the executable used for nixfmt. + +g:ale_nix_nixfmt_options *g:ale_nix_nixfmt_options* + *b:ale_nix_nixfmt_options* + Type: String + Default: '' + + This variable can be set to pass additional options to the nixfmt fixer. + + =============================================================================== nixpkgs-fmt *ale-nix-nixpkgs-fmt* diff --git a/sources_non_forked/ale/doc/ale-ocaml.txt b/sources_non_forked/ale/doc/ale-ocaml.txt index 8b644c17..afbc2386 100644 --- a/sources_non_forked/ale/doc/ale-ocaml.txt +++ b/sources_non_forked/ale/doc/ale-ocaml.txt @@ -10,6 +10,21 @@ merlin *ale-ocaml-merlin* detailed instructions (https://github.com/the-lambda-church/merlin/wiki/vim-from-scratch). +=============================================================================== +ocamllsp *ale-ocaml-ocamllsp* + + The `ocaml-lsp-server` is the official OCaml implementation of the Language + Server Protocol. See the installation instructions: + https://github.com/ocaml/ocaml-lsp#installation + +g:ale_ocaml_ocamllsp_use_opam *g:ale_ocaml_ocamllsp_use_opam* + *b:ale_ocaml_ocamllsp_use_opam* + Type: |Number| + Default: `get(g:, 'ale_ocaml_ocamllsp_use_opam', 1)` + + This variable can be set to change whether or not opam is used to execute + the language server. + =============================================================================== ols *ale-ocaml-ols* diff --git a/sources_non_forked/ale/doc/ale-openapi.txt b/sources_non_forked/ale/doc/ale-openapi.txt new file mode 100644 index 00000000..1fc41add --- /dev/null +++ b/sources_non_forked/ale/doc/ale-openapi.txt @@ -0,0 +1,74 @@ +=============================================================================== +ALE OpenApi Integration *ale-openapi-options* + +=============================================================================== +ibm_validator *ale-openapi-ibm-validator* + +Website: https://github.com/IBM/openapi-validator + + +Installation +------------------------------------------------------------------------------- + +Install ibm-openapi-validator either globally or locally: > + + npm install ibm-openapi-validator -g # global + npm install ibm-openapi-validator # local +< +Configuration +------------------------------------------------------------------------------- + +OpenAPI files can be written in YAML or JSON so in order for ALE plugins to +work with these files we must set the buffer |filetype| to either |openapi.yaml| +or |openapi.json| respectively. This causes ALE to lint the file with linters +configured for openapi and yaml files or openapi and json files respectively. + +For example setting filetype to |openapi.yaml| on a buffer and the following +|g:ale_linters| configuration will enable linting of openapi files using both +|ibm_validator| and |yamlint|: + +> + let g:ale_linters = { + \ 'yaml': ['yamllint'], + \ 'openapi': ['ibm_validator'] + \} +< + +The following plugin will detect openapi files automatically and set the +filetype to |openapi.yaml| or |openapi.json|: + + https://github.com/hsanson/vim-openapi + +Options +------------------------------------------------------------------------------- + +g:ale_openapi_ibm_validator_executable *g:ale_openapi_ibm_validator_executable* + *b:ale_openapi_ibm_validator_executable* + Type: |String| + Default: `'lint-openapi'` + + This variable can be set to change the path to lint-openapi. + + +g:ale_openapi_ibm_validator_options *g:ale_openapi_ibm_validator_options* + *b:ale_openapi_ibm_validator_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to lint-openapi. + + +=============================================================================== +prettier *ale-openapi-prettier* + +See |ale-javascript-prettier| for information about the available options. + + +=============================================================================== +yamllint *ale-openapi-yamllint* + +See |ale-yaml-yamllint| for information about the available options. + + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-pascal.txt b/sources_non_forked/ale/doc/ale-pascal.txt new file mode 100644 index 00000000..03d9a004 --- /dev/null +++ b/sources_non_forked/ale/doc/ale-pascal.txt @@ -0,0 +1,24 @@ +=============================================================================== +ALE Pascal Integration *ale-pascal-options* + +=============================================================================== +ptop *ale-pascal-ptop* + +g:ale_pascal_ptop_executable *g:ale_pascal_ptop_executable* + *b:ale_pascal_ptop_executable* + Type: |String| + Default: `'ptop'` + + This variable can be changed to specify the ptop executable. + + +g:ale_pascal_ptop_options *g:ale_pascal_ptop_options* + *b:ale_pascal_ptop_options* + Type: |String| + Default: `''` + +This variable can be set to pass additional options to the ptop fixer. + + +=============================================================================== +vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-proto.txt b/sources_non_forked/ale/doc/ale-proto.txt index 734e23d5..8ab56a14 100644 --- a/sources_non_forked/ale/doc/ale-proto.txt +++ b/sources_non_forked/ale/doc/ale-proto.txt @@ -5,14 +5,15 @@ ALE Proto Integration *ale-proto-options =============================================================================== Integration Information -Linting of `.proto` files requires that the `protoc` binary is installed in the -system path and that the `protoc-gen-lint` plugin for the `protoc` binary is also -installed. - To enable `.proto` file linting, update |g:ale_linters| as appropriate: > " Enable linter for .proto files - let g:ale_linters = {'proto': ['protoc-gen-lint']} + let g:ale_linters = {'proto': ['protoc-gen-lint', 'protolint']} + +To enable `.proto` file fixing, update |g:ale_fixers| as appropriate: +> + " Enable linter for .proto files + let b:ale_fixers = {'proto': ['protolint']} < =============================================================================== protoc-gen-lint *ale-proto-protoc-gen-lint* @@ -29,5 +30,31 @@ g:ale_proto_protoc_gen_lint_options *g:ale_proto_protoc_gen_lint_options* directory of the linted file is always passed as an include path with '-I' before any user-supplied options. +=============================================================================== +protolint *ale-proto-protolint* + + The linter is a pluggable tool that doesn't depend on the `protoc` binary. + This supports both linting and fixing. + Make sure the binary is available in the system path, or set + ale_proto_protolint_executable. + Note that the binary with v0.22.0 or above is supported. + +g:ale_proto_protolint_executable *g:ale_proto_protolint_executable* + + Type: |String| + Default: 'protolint' + + This variable can be changed to modify the executable used for protolint. + +g:ale_proto_protolint_config *g:ale_proto_protolint_config* + + Type: |String| + Default: `''` + + A path to a protolint configuration file. + + The path to the configuration file can be an absolute path or a relative + path. ALE will search for the relative path in parent directories. + =============================================================================== vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-purescript.txt b/sources_non_forked/ale/doc/ale-purescript.txt index e809f2c9..454bb7e4 100644 --- a/sources_non_forked/ale/doc/ale-purescript.txt +++ b/sources_non_forked/ale/doc/ale-purescript.txt @@ -26,7 +26,7 @@ g:ale_purescript_ls_config g:ale_purescript_ls_config \ 'purescript': { \ 'addSpagoSources': v:true, \ 'addNpmPath': v:true, - \ 'buildCommand': 'spago build -- --json-errors' + \ 'buildCommand': 'spago --quiet build --purs-args --json-errors' \ } \} =============================================================================== diff --git a/sources_non_forked/ale/doc/ale-python.txt b/sources_non_forked/ale/doc/ale-python.txt index f0c8bfb8..7f746147 100644 --- a/sources_non_forked/ale/doc/ale-python.txt +++ b/sources_non_forked/ale/doc/ale-python.txt @@ -10,6 +10,14 @@ g:ale_python_auto_pipenv *g:ale_python_auto_pipenv* Detect whether the file is inside a pipenv, and set the executable to `pipenv` if true. This is overridden by a manually-set executable. +g:ale_python_auto_poetry *g:ale_python_auto_poetry* + *b:ale_python_auto_poetry* + Type: |Number| + Default: `0` + + Detect whether the file is inside a poetry, and set the executable to `poetry` + if true. This is overridden by a manually-set executable. + =============================================================================== ALE Python Project Root Behavior *ale-python-root* @@ -36,11 +44,41 @@ ALE will look for configuration files with the following filenames. > .pylintrc Pipfile Pipfile.lock + poetry.lock + pyproject.toml + .tool-versions < The first directory containing any of the files named above will be used. +=============================================================================== +autoflake *ale-python-autoflake* + +g:ale_python_autoflake_executable *g:ale_python_autoflake_executable* + *b:ale_python_autoflake_executable* + Type: |String| + Default: `'autoflake'` + + See |ale-integrations-local-executables| + + +g:ale_python_autoflake_options *g:ale_python_autoflake_options* + *b:ale_python_autoflake_options* + Type: |String| + Default: `''` + + This variable can be set to pass extra options to autoflake. + + +g:ale_python_autoflake_use_global *g:ale_python_autoflake_use_global* + *b:ale_python_autoflake_use_global* + Type: |Number| + Default: `get(g:, 'ale_use_global_executables', 0)` + + See |ale-integrations-local-executables| + + =============================================================================== autoimport *ale-python-autoimport* @@ -67,6 +105,7 @@ g:ale_python_autoimport_use_global *g:ale_python_autoimport_use_glob See |ale-integrations-local-executables| + =============================================================================== autopep8 *ale-python-autopep8* @@ -105,6 +144,7 @@ g:ale_python_bandit_executable *g:ale_python_bandit_executable* See |ale-integrations-local-executables| Set this to `'pipenv'` to invoke `'pipenv` `run` `bandit'`. + Set this to `'poetry'` to invoke `'poetry` `run` `bandit'`. g:ale_python_bandit_options *g:ale_python_bandit_options* @@ -144,6 +184,15 @@ g:ale_python_bandit_auto_pipenv *g:ale_python_bandit_auto_pipenv* if true. This is overridden by a manually-set executable. +g:ale_python_bandit_auto_poetry *g:ale_python_bandit_auto_poetry* + *b:ale_python_bandit_auto_poetry* + Type: |Number| + Default: `0` + + Detect whether the file is inside a poetry, and set the executable to `poetry` + if true. This is overridden by a manually-set executable. + + =============================================================================== black *ale-python-black* @@ -179,6 +228,14 @@ g:ale_python_black_auto_pipenv *g:ale_python_black_auto_pipenv* Detect whether the file is inside a pipenv, and set the executable to `pipenv` if true. This is overridden by a manually-set executable. +g:ale_python_black_auto_poetry *g:ale_python_black_auto_poetry* + *b:ale_python_black_auto_poetry* + Type: |Number| + Default: `0` + + Detect whether the file is inside a poetry, and set the executable to `poetry` + if true. This is overridden by a manually-set executable. + g:ale_python_black_change_directory *g:ale_python_black_change_directory* *b:ale_python_black_change_directory* Type: |Number| @@ -211,7 +268,8 @@ g:ale_python_flake8_executable *g:ale_python_flake8_executable* Default: `'flake8'` This variable can be changed to modify the executable used for flake8. Set - this to `'pipenv'` to invoke `'pipenv` `run` `flake8'`. + this to `'pipenv'` to invoke `'pipenv` `run` `flake8'`. Set this to + `'poetry'` to invoke `'poetry` `run` `flake8'`. g:ale_python_flake8_options *g:ale_python_flake8_options* @@ -253,6 +311,15 @@ g:ale_python_flake8_auto_pipenv *g:ale_python_flake8_auto_pipenv* if true. This is overridden by a manually-set executable. +g:ale_python_flake8_auto_poetry *g:ale_python_flake8_auto_poetry* + *b:ale_python_flake8_auto_poetry* + Type: |Number| + Default: `0` + + Detect whether the file is inside a poetry, and set the executable to `poetry` + if true. This is overridden by a manually-set executable. + + =============================================================================== isort *ale-python-isort* @@ -280,6 +347,15 @@ g:ale_python_isort_use_global *g:ale_python_isort_use_global* See |ale-integrations-local-executables| +g:ale_python_isort_auto_pipenv *g:ale_python_isort_auto_pipenv* + *b:ale_python_isort_auto_pipenv* + Type: |Number| + Default: `0` + + Detect whether the file is inside a pipenv, and set the executable to `pipenv` + if true. This is overridden by a manually-set executable. + + =============================================================================== mypy *ale-python-mypy* @@ -299,6 +375,15 @@ g:ale_python_mypy_auto_pipenv *g:ale_python_mypy_auto_pipenv* if true. This is overridden by a manually-set executable. +g:ale_python_mypy_auto_poetry *g:ale_python_mypy_auto_poetry* + *b:ale_python_mypy_auto_poetry* + Type: |Number| + Default: `0` + + Detect whether the file is inside a poetry, and set the executable to `poetry` + if true. This is overridden by a manually-set executable. + + g:ale_python_mypy_executable *g:ale_python_mypy_executable* *b:ale_python_mypy_executable* Type: |String| @@ -307,6 +392,7 @@ g:ale_python_mypy_executable *g:ale_python_mypy_executable* See |ale-integrations-local-executables| Set this to `'pipenv'` to invoke `'pipenv` `run` `mypy'`. + Set this to `'poetry'` to invoke `'poetry` `run` `mypy'`. g:ale_python_mypy_ignore_invalid_syntax @@ -357,6 +443,7 @@ g:ale_python_prospector_executable *g:ale_python_prospector_executable* See |ale-integrations-local-executables| Set this to `'pipenv'` to invoke `'pipenv` `run` `prospector'`. + Set this to `'poetry'` to invoke `'poetry` `run` `prospector'`. g:ale_python_prospector_options *g:ale_python_prospector_options* @@ -397,6 +484,15 @@ g:ale_python_prospector_auto_pipenv *g:ale_python_prospector_auto_pipenv* if true. This is overridden by a manually-set executable. +g:ale_python_prospector_auto_poetry *g:ale_python_prospector_auto_poetry* + *b:ale_python_prospector_auto_poetry* + Type: |Number| + Default: `0` + + Detect whether the file is inside a poetry, and set the executable to `poetry` + if true. This is overridden by a manually-set executable. + + =============================================================================== pycodestyle *ale-python-pycodestyle* @@ -409,6 +505,7 @@ g:ale_python_pycodestyle_executable *g:ale_python_pycodestyle_executable* See |ale-integrations-local-executables| Set this to `'pipenv'` to invoke `'pipenv` `run` `pycodestyle'`. + Set this to `'poetry'` to invoke `'poetry` `run` `pycodestyle'`. g:ale_python_pycodestyle_options *g:ale_python_pycodestyle_options* @@ -437,6 +534,15 @@ g:ale_python_pycodestyle_auto_pipenv *g:ale_python_pycodestyle_auto_pipenv* if true. This is overridden by a manually-set executable. +g:ale_python_pycodestyle_auto_poetry *g:ale_python_pycodestyle_auto_poetry* + *b:ale_python_pycodestyle_auto_poetry* + Type: |Number| + Default: `0` + + Detect whether the file is inside a poetry, and set the executable to `poetry` + if true. This is overridden by a manually-set executable. + + =============================================================================== pydocstyle *ale-python-pydocstyle* @@ -449,6 +555,7 @@ g:ale_python_pydocstyle_executable *g:ale_python_pydocstyle_executable* See |ale-integrations-local-executables| Set this to `'pipenv'` to invoke `'pipenv` `run` `pydocstyle'`. + Set this to `'poetry'` to invoke `'poetry` `run` `pydocstyle'`. g:ale_python_pydocstyle_options *g:ale_python_pydocstyle_options* @@ -477,6 +584,15 @@ g:ale_python_pydocstyle_auto_pipenv *g:ale_python_pydocstyle_auto_pipenv* if true. This is overridden by a manually-set executable. +g:ale_python_pydocstyle_auto_poetry *g:ale_python_pydocstyle_auto_poetry* + *b:ale_python_pydocstyle_auto_poetry* + Type: |Number| + Default: `0` + + Detect whether the file is inside a poetry, and set the executable to `poetry` + if true. This is overridden by a manually-set executable. + + =============================================================================== pyflakes *ale-python-pyflakes* @@ -489,6 +605,7 @@ g:ale_python_pyflakes_executable *g:ale_python_pyflakes_executable* See |ale-integrations-local-executables| Set this to `'pipenv'` to invoke `'pipenv` `run` `pyflakes'`. + Set this to `'poetry'` to invoke `'poetry` `run` `pyflakes'`. g:ale_python_pyflakes_auto_pipenv *g:ale_python_pyflakes_auto_pipenv* @@ -500,6 +617,15 @@ g:ale_python_pyflakes_auto_pipenv *g:ale_python_pyflakes_auto_pipenv* if true. This is overridden by a manually-set executable. +g:ale_python_pyflakes_auto_poetry *g:ale_python_pyflakes_auto_poetry* + *b:ale_python_pyflakes_auto_poetry* + Type: |Number| + Default: `0` + + Detect whether the file is inside a poetry, and set the executable to `poetry` + if true. This is overridden by a manually-set executable. + + =============================================================================== pylama *ale-python-pylama* @@ -521,7 +647,8 @@ g:ale_python_pylama_executable *g:ale_python_pylama_executable* Default: `'pylama'` This variable can be changed to modify the executable used for pylama. Set - this to `'pipenv'` to invoke `'pipenv` `run` `pylama'`. + this to `'pipenv'` to invoke `'pipenv` `run` `pylama'`. Set this to + `'poetry'` to invoke `'poetry` `run` `pylama'`. g:ale_python_pylama_options *g:ale_python_pylama_options* @@ -554,6 +681,15 @@ g:ale_python_pylama_auto_pipenv *g:ale_python_pylama_auto_pipenv* if true. This is overridden by a manually-set executable. +g:ale_python_pylama_auto_poetry *g:ale_python_pylama_auto_poetry* + *b:ale_python_pylama_auto_poetry* + Type: |Number| + Default: `0` + + Detect whether the file is inside a poetry, and set the executable to `poetry` + if true. This is overridden by a manually-set executable. + + =============================================================================== pylint *ale-python-pylint* @@ -578,6 +714,7 @@ g:ale_python_pylint_executable *g:ale_python_pylint_executable* See |ale-integrations-local-executables| Set this to `'pipenv'` to invoke `'pipenv` `run` `pylint'`. + Set this to `'poetry'` to invoke `'poetry` `run` `pylint'`. g:ale_python_pylint_options *g:ale_python_pylint_options* @@ -617,6 +754,15 @@ g:ale_python_pylint_auto_pipenv *g:ale_python_pylint_auto_pipenv* if true. This is overridden by a manually-set executable. +g:ale_python_pylint_auto_poetry *g:ale_python_pylint_auto_poetry* + *b:ale_python_pylint_auto_poetry* + Type: |Number| + Default: `0` + + Detect whether the file is inside a poetry, and set the executable to `poetry` + if true. This is overridden by a manually-set executable. + + g:ale_python_pylint_use_msg_id *g:ale_python_pylint_use_msg_id* *b:ale_python_pylint_use_msg_id* Type: |Number| @@ -627,31 +773,32 @@ g:ale_python_pylint_use_msg_id *g:ale_python_pylint_use_msg_id* =============================================================================== -pyls *ale-python-pyls* +pylsp *ale-python-pylsp* -`pyls` will be run from a detected project root, per |ale-python-root|. +`pylsp` will be run from a detected project root, per |ale-python-root|. -g:ale_python_pyls_executable *g:ale_python_pyls_executable* - *b:ale_python_pyls_executable* +g:ale_python_pylsp_executable *g:ale_python_pylsp_executable* + *b:ale_python_pylsp_executable* Type: |String| - Default: `'pyls'` + Default: `'pylsp'` See |ale-integrations-local-executables| - Set this to `'pipenv'` to invoke `'pipenv` `run` `pyls'`. + Set this to `'pipenv'` to invoke `'pipenv` `run` `pylsp'`. + Set this to `'poetry'` to invoke `'poetry` `run` `pyls'`. -g:ale_python_pyls_use_global *g:ale_python_pyls_use_global* - *b:ale_python_pyls_use_global* +g:ale_python_pylsp_use_global *g:ale_python_pylsp_use_global* + *b:ale_python_pylsp_use_global* Type: |Number| Default: `get(g:, 'ale_use_global_executables', 0)` See |ale-integrations-local-executables| -g:ale_python_pyls_auto_pipenv *g:ale_python_pyls_auto_pipenv* - *b:ale_python_pyls_auto_pipenv* +g:ale_python_pylsp_auto_pipenv *g:ale_python_pylsp_auto_pipenv* + *b:ale_python_pylsp_auto_pipenv* Type: |Number| Default: `0` @@ -659,15 +806,24 @@ g:ale_python_pyls_auto_pipenv *g:ale_python_pyls_auto_pipenv* if true. This is overridden by a manually-set executable. -g:ale_python_pyls_config *g:ale_python_pyls_config* - *b:ale_python_pyls_config* +g:ale_python_pylsp_auto_poetry *g:ale_python_pylsp_auto_poetry* + *b:ale_python_pylsp_auto_poetry* + Type: |Number| + Default: `0` + + Detect whether the file is inside a poetry, and set the executable to `poetry` + if true. This is overridden by a manually-set executable. + + +g:ale_python_pylsp_config *g:ale_python_pylsp_config* + *b:ale_python_pylsp_config* Type: |Dictionary| Default: `{}` - Dictionary with configuration settings for pyls. For example, to disable + Dictionary with configuration settings for pylsp. For example, to disable the pycodestyle linter: > { - \ 'pyls': { + \ 'pylsp': { \ 'plugins': { \ 'pycodestyle': { \ 'enabled': v:false @@ -677,6 +833,25 @@ g:ale_python_pyls_config *g:ale_python_pyls_config* \ } < +g:ale_python_pylsp_options *g:ale_python_pylsp_options* + *b:ale_python_pylsp_options* + Type: |String| + Default: `''` + + This variable can be changed to add command-line arguments to the pylsp + invocation. Note that this is not the same thing as ale_python_pylsp_config, + which allows configuration of how pylsp functions; this is intended to + provide flexibility in how the pylsp command is invoked. + + For example, if you had installed `pylsp` but your `pylsp` executable was not + on your `PATH` for some reason, an alternative way to run the pylsp server + would be: + let g:ale_python_pylsp_executable = 'python3' + let g:ale_python_pylsp_options = '-m pylsp' + + An example stragety for installing `pylsp`: + `python3 -m pip install --user pylsp` + =============================================================================== pyre *ale-python-pyre* @@ -691,6 +866,7 @@ g:ale_python_pyre_executable *g:ale_python_pyre_executable* See |ale-integrations-local-executables| Set this to `'pipenv'` to invoke `'pipenv` `run` `pyre'`. + Set this to `'poetry'` to invoke `'poetry` `run` `pyre'`. g:ale_python_pyre_use_global *g:ale_python_pyre_use_global* @@ -710,6 +886,15 @@ g:ale_python_pyre_auto_pipenv *g:ale_python_pyre_auto_pipenv* if true. This is overridden by a manually-set executable. +g:ale_python_pyre_auto_poetry *g:ale_python_pyre_auto_poetry* + *b:ale_python_pyre_auto_poetry* + Type: |Number| + Default: `0` + + Detect whether the file is inside a poetry, and set the executable to `poetry` + if true. This is overridden by a manually-set executable. + + =============================================================================== pyright *ale-python-pyright* diff --git a/sources_non_forked/ale/doc/ale-ruby.txt b/sources_non_forked/ale/doc/ale-ruby.txt index 8815404a..69c643a9 100644 --- a/sources_non_forked/ale/doc/ale-ruby.txt +++ b/sources_non_forked/ale/doc/ale-ruby.txt @@ -41,6 +41,11 @@ g:ale_ruby_debride_options *g:ale_ruby_debride_options* This variable can be changed to modify flags given to debride. +=============================================================================== +prettier *ale-ruby-prettier* + +See |ale-javascript-prettier| for information about the available options. + =============================================================================== rails_best_practices *ale-ruby-rails_best_practices* @@ -177,6 +182,16 @@ g:ale_ruby_sorbet_options *g:ale_ruby_sorbet_options* This variable can be changed to modify flags given to sorbet. +g:ale_ruby_sorbet_enable_watchman *g:ale_ruby_sorbet_enable_watchman* + *b:ale_ruby_sorbet_enable_watchman* + Type: |Number| + Default: `0` + + Whether or not to use watchman to let the LSP server to know about changes + to files from outside of vim. Defaults to disable watchman because it + requires watchman to be installed separately from sorbet. + + =============================================================================== standardrb *ale-ruby-standardrb* diff --git a/sources_non_forked/ale/doc/ale-salt.tmt b/sources_non_forked/ale/doc/ale-salt.tmt new file mode 100644 index 00000000..ac500d37 --- /dev/null +++ b/sources_non_forked/ale/doc/ale-salt.tmt @@ -0,0 +1,43 @@ +=============================================================================== +ALE SALT Integration *ale-salt-options* + +=============================================================================== +salt-lint *ale-salt-salt-lint* + +Website: https://github.com/warpnet/salt-lint + + +Installation +------------------------------------------------------------------------------- + +Install salt-lint in your a virtualenv directory, locally, or globally: > + + pip install salt-lint # After activating virtualenv + pip install --user salt-lint # Install to ~/.local/bin + sudo pip install salt-lint # Install globally + +See |g:ale_virtualenv_dir_names| for configuring how ALE searches for +virtualenv directories. + + +Options +------------------------------------------------------------------------------- + +g:ale_salt_salt-lint_executable *g:ale_salt_salt_lint_executable* + *b:ale_salt_salt_lint_executable* + Type: |String| + Default: `'salt-lint'` + + This variable can be set to change the path to salt-lint. + + +g:ale_salt_salt-lint_options *g:ale_salt_salt-lint_options* + *b:ale_salt_salt-lint_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to salt-lint. + + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-solidity.txt b/sources_non_forked/ale/doc/ale-solidity.txt index b6e48675..c4d2f02f 100644 --- a/sources_non_forked/ale/doc/ale-solidity.txt +++ b/sources_non_forked/ale/doc/ale-solidity.txt @@ -5,6 +5,12 @@ ALE Solidity Integration *ale-solidity-options* =============================================================================== solc *ale-solidity-solc* +g:ale_solidity_solc_executable *g:ale_solidity_solc_executable* + *b:ale_solidity_solc_executable* + Type: |String| + Default: `'solc'` + + Override the invoked solc binary. For truffle/hardhat binaries. g:ale_solidity_solc_options *g:ale_solidity_solc_options* *b:ale_solidity_solc_options* @@ -33,4 +39,3 @@ solium *ale-solidity-solium* =============================================================================== vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: - 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 36e27932..eaad7411 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 @@ -13,12 +13,16 @@ Notes: `!!` These linters check only files on disk. See |ale-lint-file-linters| * Ada + * `ada_language_server` * `gcc` * `gnatpp` * Ansible * `ansible-lint` * API Blueprint * `drafter` +* APKBUILD + * `apkbuild-lint` + * `secfixes-check` * AsciiDoc * `alex`!! * `languagetool`!! @@ -39,6 +43,8 @@ Notes: * `shfmt` * Bats * `shellcheck` +* Bazel + * `buildifier` * BibTeX * `bibclean` * Bourne Shell @@ -49,8 +55,8 @@ Notes: * `astyle` * `ccls` * `clang` (`cc`) - * `clangd` * `clang-format` + * `clangd` * `clangtidy`!! * `cppcheck` * `cpplint`!! @@ -67,9 +73,9 @@ Notes: * `astyle` * `ccls` * `clang` (`cc`) + * `clang-format` * `clangcheck`!! * `clangd` - * `clang-format` * `clangtidy`!! * `clazy`!! * `cppcheck` @@ -103,6 +109,7 @@ Notes: * Cucumber * `cucumber` * CUDA + * `clangd` * `nvcc`!! * Cypher * `cypher-lint` @@ -116,11 +123,18 @@ Notes: * Dafny * `dafny`!! * Dart + * `analysis_server` + * `dart-analyze`!! + * `dart-format`!! * `dartanalyzer`!! * `dartfmt`!! * `language_server` +* desktop + * `desktop-file-validate` * Dhall * `dhall-format` + * `dhall-freeze` + * `dhall-lint` * Dockerfile * `dockerfile_lint` * `hadolint` @@ -140,11 +154,14 @@ Notes: * `erubis` * `ruumba` * Erlang + * `SyntaxErl` + * `dialyzer` * `elvis`!! * `erlc` - * `SyntaxErl` + * `erlfmt` * Fish * `fish` (-n flag) + * `fish_indent` * Fortran * `gcc` * `language_server` @@ -155,22 +172,22 @@ Notes: * Git Commit Messages * `gitlint` * GLSL - * glslang + * `glslang` * `glslls` * Go * `bingo` * `go build`!! + * `go mod`!! + * `go vet`!! * `gofmt` * `goimports` * `golangci-lint`!! * `golangserver` * `golint` * `gometalinter`!! - * `go mod`!! * `gopls` * `gosimple`!! * `gotype`!! - * `go vet`!! * `revive`!! * `staticcheck`!! * GraphQL @@ -196,6 +213,7 @@ Notes: * `hie` * `hindent` * `hlint` + * `hls` * `ormolu` * `stack-build`!! * `stack-ghc` @@ -204,9 +222,10 @@ Notes: * `terraform-fmt` * HTML * `alex`!! + * `angular` * `fecs` * `html-beautify` - * `HTMLHint` + * `htmlhint` * `prettier` * `proselint` * `tidy` @@ -215,15 +234,17 @@ Notes: * `idris` * Ink * `ink-language-server` +* Inko + * `inko` !! * ISPC * `ispc`!! * Java + * `PMD` * `checkstyle` * `eclipselsp` * `google-java-format` * `javac` * `javalsp` - * `PMD` * `uncrustify` * JavaScript * `eslint` @@ -242,6 +263,7 @@ Notes: * `jq` * `jsonlint` * `prettier` + * `spectral` * Julia * `languageserver` * Kotlin @@ -265,9 +287,11 @@ Notes: * LLVM * `llc` * Lua + * `lua-format` * `luac` * `luacheck` * `luafmt` + * `stylua` * Mail * `alex`!! * `languagetool`!! @@ -280,6 +304,7 @@ Notes: * `languagetool`!! * `markdownlint`!! * `mdl` + * `pandoc` * `prettier` * `proselint` * `redpen` @@ -299,7 +324,9 @@ Notes: * `nimpretty` * nix * `nix-instantiate` + * `nixfmt` * `nixpkgs-fmt` + * `rnix-lsp` * nroff * `alex`!! * `proselint` @@ -316,8 +343,15 @@ Notes: * OCaml * `merlin` (see |ale-ocaml-merlin|) * `ocamlformat` + * `ocamllsp` * `ocp-indent` * `ols` +* OpenApi + * `ibm_validator` + * `prettier` + * `yamllint` +* Pascal + * `ptop` * Pawn * `uncrustify` * Perl @@ -330,10 +364,10 @@ Notes: * `intelephense` * `langserver` * `phan` + * `php -l` + * `php-cs-fixer` * `phpcbf` * `phpcs` - * `php-cs-fixer` - * `php -l` * `phpmd` * `phpstan` * `psalm`!! @@ -356,6 +390,7 @@ Notes: * `swipl` * proto * `protoc-gen-lint` + * `protolint` * Pug * `pug-lint` * Puppet @@ -366,6 +401,7 @@ Notes: * `purescript-language-server` * `purty` * Python + * `autoflake`!! * `autoimport` * `autopep8` * `bandit` @@ -379,7 +415,7 @@ Notes: * `pyflakes` * `pylama`!! * `pylint`!! - * `pyls` + * `pylsp` * `pyre` * `pyright` * `reorder-python-imports` @@ -393,7 +429,10 @@ Notes: * `lintr` * `styler` * Racket + * `racket-langserver` * `raco` +* Re:VIEW + * `redpen` * ReasonML * `merlin` * `ols` @@ -407,13 +446,12 @@ Notes: * `textlint` * `vale` * `write-good` -* Re:VIEW - * `redpen` * RPM spec * `rpmlint` * Ruby * `brakeman` * `debride` + * `prettier` * `rails_best_practices`!! * `reek` * `rubocop` @@ -428,6 +466,8 @@ Notes: * `rust-analyzer` * `rustc` (see |ale-integration-rust|) * `rustfmt` +* Salt + * `salt-lint` * Sass * `sass-lint` * `stylelint` @@ -453,23 +493,31 @@ Notes: * `solium` * SQL * `pgformatter` + * `sql-lint` * `sqlfmt` * `sqlformat` * `sqlint` - * `sql-lint` * Stylus * `stylelint` * SugarSS * `stylelint` +* Svelte + * `prettier` + * `svelteserver` * Swift * Apple `swift-format` * `sourcekit-lsp` * `swiftformat` * `swiftlint` +* systemd + * `systemd-analyze`!! * Tcl * `nagelfar`!! * Terraform - * `fmt` + * `terraform` + * `terraform-fmt-fixer` + * `terraform-ls` + * `terraform-lsp` * `tflint` * Texinfo * `alex`!! @@ -485,7 +533,9 @@ Notes: * `write-good` * Thrift * `thrift` + * `thriftcheck` * TypeScript + * `deno` * `eslint` * `fecs` * `prettier` @@ -493,14 +543,19 @@ Notes: * `tslint` * `tsserver` * `typecheck` +* V + * `v` + * `vfmt` * VALA * `uncrustify` + * `vala_lint`!! * Verilog * `hdl-checker` * `iverilog` * `verilator` * `vlog` * `xvlog` + * `yosys` * VHDL * `ghdl` * `vcom` @@ -522,7 +577,9 @@ Notes: * XML * `xmllint` * YAML + * `circleci`!! * `prettier` + * `spectral` * `swaglint` * `yamlfix` * `yamllint` @@ -530,3 +587,6 @@ Notes: * `yang-lsp` * Zig * `zls` + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-svelte.txt b/sources_non_forked/ale/doc/ale-svelte.txt new file mode 100644 index 00000000..92f109f7 --- /dev/null +++ b/sources_non_forked/ale/doc/ale-svelte.txt @@ -0,0 +1,31 @@ +=============================================================================== +ALE Svelte Integration *ale-svelte-options* + + +=============================================================================== +prettier *ale-svelte-prettier* + +See |ale-javascript-prettier| for information about the available options. + + +=============================================================================== +svelteserver *ale-svelte-svelteserver* + +g:ale_svelte_svelteserver_executable *g:ale_svelte_svelteserver_executable* + *b:ale_svelte_svelteserver_executable* + Type: |String| + Default: `'svelteserver'` + + See |ale-integrations-local-executables| + + +g:ale_svelte_svelteserver_use_global *g:ale_svelte_svelteserver_use_global* + *b:ale_svelte_svelteserver_use_global* + Type: |Number| + Default: `get(g:, 'ale_use_global_executables', 0)` + + See |ale-integrations-local-executables| + + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-swift.txt b/sources_non_forked/ale/doc/ale-swift.txt index 8fa0c06c..6d53ca7c 100644 --- a/sources_non_forked/ale/doc/ale-swift.txt +++ b/sources_non_forked/ale/doc/ale-swift.txt @@ -2,6 +2,44 @@ ALE Swift Integration *ale-swift-options* +=============================================================================== +apple-swift-format *ale-swift-apple-swift-format* + +There are 3 options to enable linting and fixing with Apple's swift-format: + +1. Install the local executable in your path, as described here: + https://github.com/apple/swift-format +2. Install the executable via your OS package manager, for instance via + Homebrew with `brew install swift-format` +3. Your Swift project has a dependency on the swift-format package, so it can + be run with `swift run swift-format lint ...` In this case, you need to set + a variable, see |g:ale_swift_appleswiftformat_use_swiftpm|. + +Additionally, ALE tries to locate and use the nearest existing `.swift-format` +configuration file. + + +g:ale_swift_appleswiftformat_executable *g:ale_swift_appleswiftformat_executable* + *b:ale_swift_appleswiftformat_executable* + Type: |String| + Default: `'swift-format'` + + This variable can be modified to change the executable path for + `swift-format`. + + +g:ale_swift_appleswiftformat_use_swiftpm *g:ale_swift_appleswiftformat_use_swiftpm* + *b:ale_swift_appleswiftformat_use_swiftpm* + Type: |Number| + Default: `0` + + When set to `1`, this option will cause ALE to use + `swift run swift-format lint ...` instead of the global executable. Use this + option if your Swift project has a dependency on the swift-format package. + + See |ale-integrations-local-executables| + + =============================================================================== sourcekitlsp *ale-swift-sourcekitlsp* @@ -16,6 +54,7 @@ g:ale_sourcekit_lsp_executable *g:ale_sourcekit_lsp_executable* See |ale-integrations-local-executables| + =============================================================================== vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-systemd.txt b/sources_non_forked/ale/doc/ale-systemd.txt new file mode 100644 index 00000000..13c7037f --- /dev/null +++ b/sources_non_forked/ale/doc/ale-systemd.txt @@ -0,0 +1,14 @@ +=============================================================================== +ALE systemd Integration *ale-systemd-options* + + +=============================================================================== +systemd-analyze *ale-systemd-analyze* + +ALE supports checking user systemd units with `systemd-analyze --user verify` +Checks will only work with user unit files in their proper location. There +aren't any options, and checks can only run after saving the file. + + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-terraform.txt b/sources_non_forked/ale/doc/ale-terraform.txt index f62db190..175bdf5c 100644 --- a/sources_non_forked/ale/doc/ale-terraform.txt +++ b/sources_non_forked/ale/doc/ale-terraform.txt @@ -32,6 +32,28 @@ g:ale_terraform_terraform_executable *g:ale_terraform_terraform_executable* This variable can be changed to use a different executable for terraform. +=============================================================================== +terraform-ls *ale-terraform-terraform-ls* + +Official terraform language server. More stable than *terraform-lsp* but +currently has less features. + +g:ale_terraform_ls_executable *g:ale_terraform_ls_executable* + *b:ale_terraform_ls_executable* + Type: |String| + Default: `'terraform-ls'` + + This variable can be changed to use a different executable for terraform-ls. + + +g:ale_terraform_ls_options *g:ale_terraform_ls_options* + *b:ale_terraform_ls_options* + Type: |String| + Default: `''` + + This variable can be changed to pass custom CLI flags to terraform-ls. + + =============================================================================== terraform-lsp *ale-terraform-terraform-lsp* diff --git a/sources_non_forked/ale/doc/ale-thrift.txt b/sources_non_forked/ale/doc/ale-thrift.txt index bb2ec058..810127b4 100644 --- a/sources_non_forked/ale/doc/ale-thrift.txt +++ b/sources_non_forked/ale/doc/ale-thrift.txt @@ -42,5 +42,24 @@ g:ale_thrift_thrift_options *g:ale_thrift_thrift_options* This variable can be changed to customize the additional command-line arguments that are passed to the thrift compiler. +=============================================================================== +thriftcheck *ale-thrift-thriftcheck* + +g:ale_thrift_thriftcheck_executable *g:ale_thrift_thriftcheck_executable* + *b:ale_thrift_thriftcheck_executable* + Type: |String| + Default: `'thriftcheck'` + + See |ale-integrations-local-executables| + + +g:ale_thrift_thriftcheck_options *g:ale_thrift_thriftcheck_options* + *b:ale_thrift_thriftcheck_options* + Type: |String| + Default: `''` + + This variable can be changed to customize the additional command-line + arguments that are passed to thriftcheck. + =============================================================================== vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-typescript.txt b/sources_non_forked/ale/doc/ale-typescript.txt index 2c50d119..e2ee49c2 100644 --- a/sources_non_forked/ale/doc/ale-typescript.txt +++ b/sources_non_forked/ale/doc/ale-typescript.txt @@ -2,6 +2,45 @@ ALE TypeScript Integration *ale-typescript-options* +=============================================================================== +deno *ale-typescript-deno* + +Starting from version 1.6.0, Deno comes with its own language server. Earlier +versions are not supported. + +g:ale_deno_executable *g:ale_deno_executable* + *b:ale_deno_executable* + Type: |String| + Default: `'deno'` + + +g:ale_deno_lsp_project_root *g:ale_deno_lsp_project_root* + *b:ale_deno_lsp_project_root* + Type: |String| + Default: `''` + + If this variable is left unset, ALE will try to find the project root by + executing the following steps in the given order: + + 1. Find an ancestor directory containing a tsconfig.json. + 2. Find an ancestory irectory containing a .git folder. + 3. Use the directory of the current buffer (if the buffer was opened from + a file). + +g:ale_deno_unstable *g:ale_deno_unstable* + *b:ale_deno_unstable* + Type: |Number| + Default: `0` + + Enable or disable unstable Deno features and APIs. + +g:ale_deno_importMap *g:ale_deno_importMap* + *b:ale_deno_importMap* + Type: |String| + Default: `'import_map.json'` + + Specify the import map filename to load url maps in a deno project. + =============================================================================== eslint *ale-typescript-eslint* @@ -138,5 +177,32 @@ g:ale_typescript_tsserver_use_global *g:ale_typescript_tsserver_use_global* tsserver in node_modules. +=============================================================================== +xo *ale-typescript-xo* + +g:ale_typescript_xo_executable *g:ale_typescript_xo_executable* + *b:ale_typescript_xo_executable* + Type: |String| + Default: `'xo'` + + See |ale-integrations-local-executables| + + +g:ale_typescript_xo_options *g:ale_typescript_xo_options* + *b:ale_typescript_xo_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to xo. + + +g:ale_typescript_xo_use_global *g:ale_typescript_xo_use_global* + *b:ale_typescript_xo_use_global* + Type: |Number| + Default: `get(g:, 'ale_use_global_executables', 0)` + + See |ale-integrations-local-executables| + + =============================================================================== vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-v.txt b/sources_non_forked/ale/doc/ale-v.txt new file mode 100644 index 00000000..8c641447 --- /dev/null +++ b/sources_non_forked/ale/doc/ale-v.txt @@ -0,0 +1,45 @@ +=============================================================================== +ALE V Integration *ale-v-options* + + +=============================================================================== +Integration Information + +`v` is V's build tool. `vfmt` (called as `v fmt` from the same +executable that does the builds) is the autoformatter/fixer. + +g:ale_v_v_executable *g:ale_v_v_executable* + *b:ale_v_v_executable* + + Type: |String| + Default: `'v'` + + The executable that will be run for the `v` linter and the `vfmt` fixer. + + +=============================================================================== +v *ale-v-v* + +g:ale_v_v_options *g:ale_v_v_options* + *b:ale_v_v_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to the v linter. + They are injected directly after "v .". + + +=============================================================================== +vfmt *ale-v-vfmt* + +g:ale_v_vfmt_options *g:ale_v_vfmt_options* + *b:ale_v_vfmt_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to the vfmt fixer. + They are injected directly after "v fmt". + + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-vala.txt b/sources_non_forked/ale/doc/ale-vala.txt index ca24bcf4..d48f68bb 100644 --- a/sources_non_forked/ale/doc/ale-vala.txt +++ b/sources_non_forked/ale/doc/ale-vala.txt @@ -8,5 +8,26 @@ uncrustify *ale-vala-uncrustify* See |ale-c-uncrustify| for information about the available options. +=============================================================================== +Vala-Lint *ale-vala-vala-lint* + +g:vala_vala_lint_executable *g:vala_vala_lint_executable* + *b:vala_vala_lint_executable* + Type: |String| + Default: `'io.elementary.vala-lint'` + + This variable can be set to specify a Vala-Lint executable file. + + +g:vala_vala_lint_config_filename *g:vala_vala_lint_config_filename* + *b:vala_vala_lint_config_filename* + Type: |String| + Default: `'vala-lint.conf'` + + This variable can be set to specify a Vala-Lint config filename. When a file + with the specified name was not found or this variable was set to empty, + Vala-Lint will be executed without specifying a config filename. + + =============================================================================== vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-verilog.txt b/sources_non_forked/ale/doc/ale-verilog.txt index 01af63c2..11e988bb 100644 --- a/sources_non_forked/ale/doc/ale-verilog.txt +++ b/sources_non_forked/ale/doc/ale-verilog.txt @@ -3,7 +3,7 @@ ALE Verilog/SystemVerilog Integration *ale-verilog-options* =============================================================================== -ALE can use five different linters for Verilog HDL: +ALE can use six different linters for Verilog HDL: HDL Checker Using `hdl_checker --lsp` @@ -20,6 +20,9 @@ ALE can use five different linters for Verilog HDL: Vivado Using `xvlog` + Yosys + Using `ysoys -Q -T -p 'read_verilog'` + By default, both 'verilog' and 'systemverilog' filetypes are checked. You can limit 'systemverilog' files to be checked using only 'verilator' by @@ -114,5 +117,26 @@ g:ale_verilog_xvlog_options *g:ale_verilog_xvlog_options* This variable can be changed to modify the flags/options passed to 'xvlog'. +=============================================================================== +yosys *ale-verilog-yosys* + +g:ale_verilog_yosys_executable *g:ale_verilog_yosys_executable* + *b:ale_verilog_yosys_executable* + Type: |String| + Default: `'yosys'` + + This variable can be changed to the path to the 'yosys' executable. + + +g:ale_verilog_yosys_options *g:ale_verilog_yosys_options* + *b:ale_verilog_yosys_options* + Type: |String| + Default: `'-Q -T -p ''read_verilog %s'''` + + This variable can be changed to modify the flags/options passed to 'yosys'. + By default, Yosys is an interative program. To obtain linting functionality, + the `'read_verilog'` command is used. + + =============================================================================== vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-yaml.txt b/sources_non_forked/ale/doc/ale-yaml.txt index 61bfc139..65e0d069 100644 --- a/sources_non_forked/ale/doc/ale-yaml.txt +++ b/sources_non_forked/ale/doc/ale-yaml.txt @@ -1,6 +1,28 @@ =============================================================================== ALE YAML Integration *ale-yaml-options* + +=============================================================================== +circleci *ale-yaml-circleci* + +Website: https://circleci.com/docs/2.0/local-cli + + +Installation +------------------------------------------------------------------------------- + +Follow the instructions on the website, and make sure to test that you can +validate configuration files with: > + + circleci config validate - < .circleci/config.yml +< + +As long as the validator runs correctly, you should be able to see errors when +you save the configuration file. The validator doesn't run as you type because +it sends network requests, and running too often would overload the circleci +servers. + + =============================================================================== prettier *ale-yaml-prettier* @@ -15,6 +37,40 @@ Install prettier either globally or locally: > npm install prettier -g # global npm install prettier # local < + +=============================================================================== +spectral *ale-yaml-spectral* + +Website: https://github.com/stoplightio/spectral + + +Installation +------------------------------------------------------------------------------- + +Install spectral either globally or locally: > + + npm install @stoplight/spectral -g # global + npm install @stoplight/spectral # local +< + +Options +------------------------------------------------------------------------------- + +g:ale_yaml_spectral_executable *g:ale_yaml_spectral_executable* + *b:ale_yaml_spectral_executable* + Type: |String| + Default: `'spectral'` + + This variable can be set to change the path to spectral. + +g:ale_yaml_spectral_use_global *g:ale_yaml_spectral_use_global* + *b:ale_yaml_spectral_use_global* + Type: |String| + Default: `get(g:, 'ale_use_global_executables', 0)` + + See |ale-integrations-local-executables| + + =============================================================================== swaglint *ale-yaml-swaglint* @@ -48,6 +104,7 @@ g:ale_yaml_swaglint_use_global *g:ale_yaml_swaglint_use_global* See |ale-integrations-local-executables| + =============================================================================== yamlfix *ale-yaml-yamlfix* @@ -86,6 +143,7 @@ g:ale_yaml_yamlfix_use_global *g:ale_yaml_yamlfix_use_global* See |ale-integrations-local-executables| + =============================================================================== yamllint *ale-yaml-yamllint* diff --git a/sources_non_forked/ale/doc/ale.txt b/sources_non_forked/ale/doc/ale.txt index f9f40d12..2f77e7c1 100644 --- a/sources_non_forked/ale/doc/ale.txt +++ b/sources_non_forked/ale/doc/ale.txt @@ -228,8 +228,8 @@ A minimal configuration for a language server linter might look so. > \ 'project_root': '/path/to/root_of_project', \}) < -For language servers that use a TCP socket connection, you should define the -address to connect to instead. > +For language servers that use a TCP or named pipe socket connection, you +should define the address to connect to instead. > call ale#linter#Define('filetype_here', { \ 'name': 'any_name_you_want', @@ -342,6 +342,12 @@ the buffers being checked. When a |Dictionary| is returned for an |ALEFix| callback, the following keys are supported for running the commands. + `cwd` An optional |String| for setting the working directory + for the command. + + If not set, or `v:null`, the `cwd` of the last command + that spawn this one will be used. + `command` A |String| for the command to run. This key is required. When `%t` is included in a command string, a temporary @@ -454,7 +460,7 @@ integration should not be combined with ALE's own implementation. ALE additionally integrates with asyncomplete.vim for offering automatic completion data. ALE's asyncomplete source requires registration and should -use the defaults provided by the|asyncomplete#sources#ale#get_source_options| function > +use the defaults provided by the |asyncomplete#sources#ale#get_source_options| function > " Use ALE's function for asyncomplete defaults au User asyncomplete_setup call asyncomplete#register_source(asyncomplete#sources#ale#get_source_options({ @@ -555,7 +561,6 @@ vimrc, and your issues should go away. > set completeopt=menu,menuone,preview,noselect,noinsert < - Or alternatively, if you want to show documentation in popups: > set completeopt=menu,menuone,popup,noselect,noinsert @@ -646,6 +651,10 @@ problem will be displayed in a balloon instead of hover information. Hover information can be displayed in the preview window instead by setting |g:ale_hover_to_preview| to `1`. +When using Neovim or Vim with |popupwin|, if |g:ale_hover_to_floating_preview| +or |g:ale_floating_preview| is set to 1, the hover information will show in a +floating window. And |g:ale_floating_window_border| for the border setting. + For Vim 8.1+ terminals, mouse hovering is disabled by default. Enabling |balloonexpr| commands in terminals can cause scrolling issues in terminals, so ALE will not attempt to show balloons unless |g:ale_set_balloons| is set to @@ -954,6 +963,15 @@ g:ale_default_navigation *g:ale_default_navigation* buffer, such as for |ALEFindReferences|, or |ALEGoToDefinition|. +g:ale_detail_to_floating_preview *g:ale_detail_to_floating_preview* + *b:ale_detail_to_floating_preview* + Type: |Number| + Default: `0` + + When this option is set to `1`, Neovim or Vim with |popupwin| will use a + floating window for ALEDetail output. + + g:ale_disable_lsp *g:ale_disable_lsp* *b:ale_disable_lsp* @@ -1177,6 +1195,30 @@ g:ale_fix_on_save_ignore *g:ale_fix_on_save_ignore* let g:ale_fix_on_save_ignore = [g:AddBar] < +g:ale_floating_preview *g:ale_floating_preview* + + Type: |Number| + Default: `0` + + When set to `1`, Neovim or Vim with |popupwin| will use a floating window + for ale's preview window. + This is equivalent to setting |g:ale_hover_to_floating_preview| and + |g:ale_detail_to_floating_preview| to `1`. + + +g:ale_floating_window_border *g:ale_floating_window_border* + + Type: |List| + Default: `['|', '-', '+', '+', '+', '+']` + + When set to `[]`, window borders are disabled. The elements in the list set + the horizontal, top, top-left, top-right, bottom-right and bottom-left + border characters, respectively. + + If the terminal supports Unicode, you might try setting the value to + ` ['│', '─', '╭', '╮', '╯', '╰']`, to make it look nicer. + + g:ale_history_enabled *g:ale_history_enabled* Type: |Number| @@ -1235,6 +1277,15 @@ g:ale_hover_to_preview *g:ale_hover_to_preview* instead of in balloons or the message line. +g:ale_hover_to_floating_preview *g:ale_hover_to_floating_preview* + *b:ale_hover_to_floating_preview* + Type: |Number| + Default: `0` + + If set to `1`, Neovim or Vim with |popupwin| will use floating windows for + hover messages. + + g:ale_keep_list_window_open *g:ale_keep_list_window_open* *b:ale_keep_list_window_open* Type: |Number| @@ -1388,6 +1439,7 @@ g:ale_linter_aliases *g:ale_linter_aliases* \ 'ps1': 'powershell', \ 'rmarkdown': 'r', \ 'rmd': 'r', + \ 'svelte': ['svelte', 'javascript'], \ 'systemverilog': 'verilog', \ 'typescriptreact': ['typescript', 'tsx'], \ 'verilog_systemverilog': ['verilog_systemverilog', 'verilog'], @@ -1526,19 +1578,23 @@ g:ale_linters *g:ale_linters* following values: > { + \ 'apkbuild': ['apkbuild_lint', 'secfixes_check'], \ 'csh': ['shell'], \ 'elixir': ['credo', 'dialyxir', 'dogma'], - \ 'go': ['gofmt', 'golint', 'go vet'], + \ 'go': ['gofmt', 'golint', 'gopls', 'govet'], \ 'hack': ['hack'], \ 'help': [], + \ 'inko': ['inko'], \ 'perl': ['perlcritic'], \ 'perl6': [], \ 'python': ['flake8', 'mypy', 'pylint', 'pyright'], \ 'rust': ['cargo', 'rls'], \ 'spec': [], + \ 'svelte': ['eslint', 'svelteserver'], \ 'text': [], \ 'vue': ['eslint', 'vls'], \ 'zsh': ['shell'], + \ 'v': ['v'], \} < This option can be used to enable only a particular set of linters for a @@ -1677,22 +1733,13 @@ g:ale_lsp_show_message_severity *g:ale_lsp_show_message_severity* `'disabled'` - Doesn't display any information at all. -g:ale_lsp_root *g:ale_lsp_root* - *b:ale_lsp_root* +g:ale_lsp_suggestions *g:ale_lsp_suggestions* - Type: |Dictionary| or |String| - Default: {} + Type: |Number| + Default: `0` - This option is used to determine the project root for the LSP linter. If the - value is a |Dictionary|, it maps a linter to either a string containing the - project root or a |Funcref| to call to look up the root. The funcref is - provided the buffer number as its argument. - - The buffer-specific variable may additionally be a string containing the - project root itself. - - 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. + If set to `1`, show hints/suggestions from LSP servers or tsserver, in + addition to warnings and errors. g:ale_max_buffer_history_size *g:ale_max_buffer_history_size* @@ -1812,6 +1859,8 @@ g:ale_popup_menu_enabled *g:ale_popup_menu_enabled* capabilities in the right click mouse menu when there's a LSP server or tsserver available. See |ale-refactor|. + This feature is only supported in GUI versions of Vim. + This setting must be set to `1` before ALE is loaded for this behavior to be enabled. See |ale-lint-settings-on-startup|. @@ -1837,6 +1886,25 @@ g:ale_rename_tsserver_find_in_strings *g:ale_rename_tsserver_find_in_strings* `1`. +g:ale_root *g:ale_root* + *b:ale_root* + + Type: |Dictionary| or |String| + Default: {} + + This option is used to determine the project root for a linter. If the value + is a |Dictionary|, it maps a linter to either a |String| containing the + project root or a |Funcref| to call to look up the root. The |Funcref| is + provided the buffer number as its argument. + + The buffer-specific variable may additionally be a string containing the + project root itself. + + If neither variable yields a result, a linter-specific function is invoked to + detect a project root. If this, too, yields no result, and the linter is an + LSP linter, it will not run. + + g:ale_set_balloons *g:ale_set_balloons* *b:ale_set_balloons* @@ -2556,8 +2624,12 @@ documented in additional help files. ada.....................................|ale-ada-options| gcc...................................|ale-ada-gcc| gnatpp................................|ale-ada-gnatpp| + ada-language-server...................|ale-ada-language-server| ansible.................................|ale-ansible-options| ansible-lint..........................|ale-ansible-ansible-lint| + apkbuild................................|ale-apkbuild-options| + apkbuild-lint.........................|ale-apkbuild-apkbuild-lint| + secfixes-check........................|ale-apkbuild-secfixes-check| asciidoc................................|ale-asciidoc-options| write-good............................|ale-asciidoc-write-good| textlint..............................|ale-asciidoc-textlint| @@ -2567,6 +2639,8 @@ documented in additional help files. gawk..................................|ale-awk-gawk| bats....................................|ale-bats-options| shellcheck............................|ale-bats-shellcheck| + bazel...................................|ale-bazel-options| + buildifier............................|ale-bazel-buildifier| bib.....................................|ale-bib-options| bibclean..............................|ale-bib-bibclean| c.......................................|ale-c-options| @@ -2616,14 +2690,26 @@ documented in additional help files. stylelint.............................|ale-css-stylelint| cuda....................................|ale-cuda-options| nvcc..................................|ale-cuda-nvcc| + clangd................................|ale-cuda-clangd| clang-format..........................|ale-cuda-clangformat| d.......................................|ale-d-options| dfmt..................................|ale-d-dfmt| dls...................................|ale-d-dls| uncrustify............................|ale-d-uncrustify| + dafny...................................|ale-dafny-options| + dafny.................................|ale-dafny-dafny| dart....................................|ale-dart-options| + analysis_server.......................|ale-dart-analysis_server| + dart-analyze..........................|ale-dart-analyze| + dart-format...........................|ale-dart-format| dartanalyzer..........................|ale-dart-dartanalyzer| dartfmt...............................|ale-dart-dartfmt| + desktop.................................|ale-desktop-options| + desktop-file-validate.................|ale-desktop-desktop-file-validate| + dhall...................................|ale-dhall-options| + dhall-format..........................|ale-dhall-format| + dhall-freeze..........................|ale-dhall-freeze| + dhall-lint............................|ale-dhall-lint| dockerfile..............................|ale-dockerfile-options| dockerfile_lint.......................|ale-dockerfile-dockerfile_lint| hadolint..............................|ale-dockerfile-hadolint| @@ -2641,10 +2727,12 @@ documented in additional help files. dialyzer..............................|ale-erlang-dialyzer| elvis.................................|ale-erlang-elvis| erlc..................................|ale-erlang-erlc| + erlfmt................................|ale-erlang-erlfmt| syntaxerl.............................|ale-erlang-syntaxerl| eruby...................................|ale-eruby-options| ruumba................................|ale-eruby-ruumba| fish....................................|ale-fish-options| + fish_indent...........................|ale-fish-fish_indent| fortran.................................|ale-fortran-options| gcc...................................|ale-fortran-gcc| language_server.......................|ale-fortran-language-server| @@ -2689,6 +2777,7 @@ documented in additional help files. hfmt..................................|ale-haskell-hfmt| hindent...............................|ale-haskell-hindent| hlint.................................|ale-haskell-hlint| + hls...................................|ale-haskell-hls| stack-build...........................|ale-haskell-stack-build| stack-ghc.............................|ale-haskell-stack-ghc| stylish-haskell.......................|ale-haskell-stylish-haskell| @@ -2697,17 +2786,20 @@ documented in additional help files. hcl.....................................|ale-hcl-options| terraform-fmt.........................|ale-hcl-terraform-fmt| html....................................|ale-html-options| + angular...............................|ale-html-angular| fecs..................................|ale-html-fecs| html-beautify.........................|ale-html-beautify| htmlhint..............................|ale-html-htmlhint| - tidy..................................|ale-html-tidy| prettier..............................|ale-html-prettier| stylelint.............................|ale-html-stylelint| + tidy..................................|ale-html-tidy| write-good............................|ale-html-write-good| idris...................................|ale-idris-options| idris.................................|ale-idris-idris| ink.....................................|ale-ink-options| ink-language-server...................|ale-ink-language-server| + inko....................................|ale-inko-options| + inko..................................|ale-inko-inko| ispc....................................|ale-ispc-options| ispc..................................|ale-ispc-ispc| java....................................|ale-java-options| @@ -2735,6 +2827,7 @@ documented in additional help files. jsonlint..............................|ale-json-jsonlint| jq....................................|ale-json-jq| prettier..............................|ale-json-prettier| + spectral..............................|ale-json-spectral| julia...................................|ale-julia-options| languageserver........................|ale-julia-languageserver| kotlin..................................|ale-kotlin-options| @@ -2751,12 +2844,15 @@ documented in additional help files. llvm....................................|ale-llvm-options| llc...................................|ale-llvm-llc| lua.....................................|ale-lua-options| + lua-format............................|ale-lua-lua-format| luac..................................|ale-lua-luac| luacheck..............................|ale-lua-luacheck| luafmt................................|ale-lua-luafmt| + stylua................................|ale-lua-stylua| markdown................................|ale-markdown-options| markdownlint..........................|ale-markdown-markdownlint| mdl...................................|ale-markdown-mdl| + pandoc................................|ale-markdown-pandoc| prettier..............................|ale-markdown-prettier| remark-lint...........................|ale-markdown-remark-lint| textlint..............................|ale-markdown-textlint| @@ -2770,6 +2866,7 @@ documented in additional help files. nimlsp................................|ale-nim-nimlsp| nimpretty.............................|ale-nim-nimpretty| nix.....................................|ale-nix-options| + nixfmt................................|ale-nix-nixfmt| nixpkgs-fmt...........................|ale-nix-nixpkgs-fmt| nroff...................................|ale-nroff-options| write-good............................|ale-nroff-write-good| @@ -2784,9 +2881,16 @@ documented in additional help files. uncrustify............................|ale-objcpp-uncrustify| ocaml...................................|ale-ocaml-options| merlin................................|ale-ocaml-merlin| + ocamllsp..............................|ale-ocaml-ocamllsp| ols...................................|ale-ocaml-ols| ocamlformat...........................|ale-ocaml-ocamlformat| ocp-indent............................|ale-ocaml-ocp-indent| + openapi.................................|ale-openapi-options| + ibm_validator.........................|ale-openapi-ibm-validator| + prettier..............................|ale-openapi-prettier| + yamllint..............................|ale-openapi-yamllint| + pascal..................................|ale-pascal-options| + ptop..................................|ale-pascal-ptop| pawn....................................|ale-pawn-options| uncrustify............................|ale-pawn-uncrustify| perl....................................|ale-perl-options| @@ -2820,6 +2924,7 @@ documented in additional help files. swipl.................................|ale-prolog-swipl| proto...................................|ale-proto-options| protoc-gen-lint.......................|ale-proto-protoc-gen-lint| + protolint.............................|ale-proto-protolint| pug.....................................|ale-pug-options| puglint...............................|ale-pug-puglint| puppet..................................|ale-puppet-options| @@ -2832,6 +2937,7 @@ documented in additional help files. pyrex (cython)..........................|ale-pyrex-options| cython................................|ale-pyrex-cython| python..................................|ale-python-options| + autoflake.............................|ale-python-autoflake| autoimport............................|ale-python-autoimport| autopep8..............................|ale-python-autopep8| bandit................................|ale-python-bandit| @@ -2845,7 +2951,7 @@ documented in additional help files. pyflakes..............................|ale-python-pyflakes| pylama................................|ale-python-pylama| pylint................................|ale-python-pylint| - pyls..................................|ale-python-pyls| + pylsp.................................|ale-python-pylsp| pyre..................................|ale-python-pyre| pyright...............................|ale-python-pyright| reorder-python-imports................|ale-python-reorder_python_imports| @@ -2868,6 +2974,7 @@ documented in additional help files. ruby....................................|ale-ruby-options| brakeman..............................|ale-ruby-brakeman| debride...............................|ale-ruby-debride| + prettier..............................|ale-ruby-prettier| rails_best_practices..................|ale-ruby-rails_best_practices| reek..................................|ale-ruby-reek| rubocop...............................|ale-ruby-rubocop| @@ -2882,6 +2989,8 @@ documented in additional help files. rls...................................|ale-rust-rls| rustc.................................|ale-rust-rustc| rustfmt...............................|ale-rust-rustfmt| + salt....................................|ale-salt-options| + salt-lint.............................|ale-salt-salt-lint| sass....................................|ale-sass-options| sasslint..............................|ale-sass-sasslint| stylelint.............................|ale-sass-stylelint| @@ -2916,13 +3025,20 @@ documented in additional help files. stylelint.............................|ale-stylus-stylelint| sugarss.................................|ale-sugarss-options| stylelint.............................|ale-sugarss-stylelint| + svelte..................................|ale-svelte-options| + prettier..............................|ale-svelte-prettier| + svelteserver..........................|ale-svelte-svelteserver| swift...................................|ale-swift-options| + apple-swift-format....................|ale-swift-apple-swift-format| sourcekitlsp..........................|ale-swift-sourcekitlsp| + systemd.................................|ale-systemd-options| + systemd-analyze.......................|ale-systemd-analyze| tcl.....................................|ale-tcl-options| nagelfar..............................|ale-tcl-nagelfar| terraform...............................|ale-terraform-options| terraform-fmt-fixer...................|ale-terraform-fmt-fixer| terraform.............................|ale-terraform-terraform| + terraform-ls..........................|ale-terraform-terraform-ls| terraform-lsp.........................|ale-terraform-terraform-lsp| tflint................................|ale-terraform-tflint| tex.....................................|ale-tex-options| @@ -2937,12 +3053,18 @@ documented in additional help files. write-good............................|ale-text-write-good| thrift..................................|ale-thrift-options| thrift................................|ale-thrift-thrift| + thriftcheck...........................|ale-thrift-thriftcheck| typescript..............................|ale-typescript-options| + deno..................................|ale-typescript-deno| eslint................................|ale-typescript-eslint| prettier..............................|ale-typescript-prettier| standard..............................|ale-typescript-standard| tslint................................|ale-typescript-tslint| tsserver..............................|ale-typescript-tsserver| + xo....................................|ale-typescript-xo| + v.......................................|ale-v-options| + v.....................................|ale-v-v| + vfmt..................................|ale-v-vfmt| vala....................................|ale-vala-options| uncrustify............................|ale-vala-uncrustify| verilog/systemverilog...................|ale-verilog-options| @@ -2951,16 +3073,17 @@ documented in additional help files. verilator.............................|ale-verilog-verilator| vlog..................................|ale-verilog-vlog| xvlog.................................|ale-verilog-xvlog| + yosys.................................|ale-verilog-yosys| vhdl....................................|ale-vhdl-options| ghdl..................................|ale-vhdl-ghdl| hdl-checker...........................|ale-vhdl-hdl-checker| vcom..................................|ale-vhdl-vcom| xvhdl.................................|ale-vhdl-xvhdl| + vim help................................|ale-vim-help-options| + write-good............................|ale-vim-help-write-good| 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| vue.....................................|ale-vue-options| prettier..............................|ale-vue-prettier| vls...................................|ale-vue-vls| @@ -2969,7 +3092,9 @@ documented in additional help files. xml.....................................|ale-xml-options| xmllint...............................|ale-xml-xmllint| yaml....................................|ale-yaml-options| + circleci..............................|ale-yaml-circleci| prettier..............................|ale-yaml-prettier| + spectral..............................|ale-yaml-spectral| swaglint..............................|ale-yaml-swaglint| yamlfix...............................|ale-yaml-yamlfix| yamllint..............................|ale-yaml-yamllint| @@ -2987,7 +3112,7 @@ ALEComplete *ALEComplete* Manually trigger LSP autocomplete and show the menu. Works only when called from insert mode. > - inoremap :AleComplete + inoremap :ALEComplete < A plug mapping `(ale_complete)` is defined for this command. > @@ -3504,6 +3629,12 @@ ale#command#Run(buffer, command, callback, [options]) *ale#command#Run()* < The following `options` can be provided. + `cwd` - An optional |String| for setting the working directory + for the command, just as per |ale#linter#Define|. + + If not set, or `v:null`, the `cwd` of the last command + that spawned this one will be used. + `output_stream` - Either `'stdout'`, `'stderr'`, `'both'`, or `'none`' for selecting which output streams to read lines from. @@ -3613,6 +3744,21 @@ ale#fix#registry#Add(name, func, filetypes, desc, [aliases]) ALE will search for fixers in the registry first by `name`, then by their `aliases`. + For example to register a custom fixer for `luafmt`: > + + function! FormatLua(buffer) abort + return { + \ 'command': 'luafmt --stdin' + \} + endfunction + + execute ale#fix#registry#Add('luafmt', 'FormatLua', ['lua'], 'luafmt for lua') + + " You can now use it in g:ale_fixers + let g:ale_fixers = { + \ 'lua': ['luafmt'] + } +< ale#linter#Define(filetype, linter) *ale#linter#Define()* @@ -3729,10 +3875,33 @@ ale#linter#Define(filetype, linter) *ale#linter#Define()* The result can be computed with |ale#command#Run()|. + The command string can be formatted with format + markers. See |ale-command-format-strings|. + This command will be fed the lines from the buffer to check, and will produce the lines of output given to the `callback`. + `cwd` An optional |String| for setting the working + directory for the command, or a |Funcref| for a + function to call for computing the command, accepting + a buffer number. The working directory can be + specified as a format string for determining the path + dynamically. See |ale-command-format-strings|. + + To set the working directory to the directory + containing the file you're checking, you should + probably use `'%s:h'` as the option value. + + If this option is absent or the string is empty, the + `command` will be run with no determined working + directory in particular. + + The directory specified with this option will be used + as the default working directory for all commands run + in a chain with |ale#command#Run()|, unless otherwise + specified. + `output_stream` A |String| for the output stream the lines of output should be read from for the command which is run. The accepted values are `'stdout'`, `'stderr'`, and @@ -3788,7 +3957,7 @@ ale#linter#Define(filetype, linter) *ale#linter#Define()* When this argument is set to `'socket'`, then the linter will be defined as an LSP linter via a TCP - socket connection. `address` must be set. + or named pipe socket connection. `address` must be set. ALE will not start a server automatically. @@ -3813,7 +3982,10 @@ ale#linter#Define(filetype, linter) *ale#linter#Define()* `address` A |String| representing an address to connect to, or a |Funcref| accepting a buffer number and - returning the |String|. + returning the |String|. If the value contains a + colon, it is interpreted as referring to a TCP + socket; otherwise it is interpreted as the path of a + named pipe. The result can be computed with |ale#command#Run()|. diff --git a/sources_non_forked/ale/plugin/ale.vim b/sources_non_forked/ale/plugin/ale.vim index 5b7be116..d19824b1 100644 --- a/sources_non_forked/ale/plugin/ale.vim +++ b/sources_non_forked/ale/plugin/ale.vim @@ -87,8 +87,8 @@ let g:ale_lint_on_save = get(g:, 'ale_lint_on_save', 1) " This flag can be set to 1 to enable linting when the filetype is changed. let g:ale_lint_on_filetype_changed = get(g:, 'ale_lint_on_filetype_changed', 1) -" This Dictionary configures the default LSP roots for various linters. -let g:ale_lsp_root = get(g:, 'ale_lsp_root', {}) +" If set to 1, hints and suggestion from LSP servers and tsserver will be shown. +let g:ale_lsp_suggestions = get(g:, 'ale_lsp_suggestions', 0) " This flag can be set to 1 to enable automatically fixing files on save. let g:ale_fix_on_save = get(g:, 'ale_fix_on_save', 0) @@ -101,6 +101,9 @@ let g:ale_enabled = get(g:, 'ale_enabled', 1) " mapping filename paths from one system to another. let g:ale_filename_mappings = get(g:, 'ale_filename_mappings', {}) +" This Dictionary configures the default project roots for various linters. +let g:ale_root = get(g:, 'ale_root', {}) + " 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) @@ -138,6 +141,20 @@ let g:ale_set_balloons = get(g:, 'ale_set_balloons', has('balloon_eval') && has( " Use preview window for hover messages. let g:ale_hover_to_preview = get(g:, 'ale_hover_to_preview', 0) +" Float preview windows in Neovim +let g:ale_floating_preview = get(g:, 'ale_floating_preview', 0) + +" Hovers use floating windows in Neovim +let g:ale_hover_to_floating_preview = get(g:, 'ale_hover_to_floating_preview', 0) + +" Detail uses floating windows in Neovim +let g:ale_detail_to_floating_preview = get(g:, 'ale_detail_to_floating_preview', 0) + +" Border setting for floating preview windows in Neovim +" The element in the list presents - horizontal, top, top-left, top-right, +" bottom-right and bottom-left +let g:ale_floating_window_border = get(g:, 'ale_floating_window_border', ['|', '-', '+', '+', '+', '+']) + " This flag can be set to 0 to disable warnings for trailing whitespace let g:ale_warn_about_trailing_whitespace = get(g:, 'ale_warn_about_trailing_whitespace', 1) " This flag can be set to 0 to disable warnings for trailing blank lines @@ -155,9 +172,15 @@ let g:ale_completion_enabled = get(g:, 'ale_completion_enabled', 0) " Enable automatic detection of pipenv for Python linters. let g:ale_python_auto_pipenv = get(g:, 'ale_python_auto_pipenv', 0) +" Enable automatic detection of poetry for Python linters. +let g:ale_python_auto_poetry = get(g:, 'ale_python_auto_poetry', 0) + " This variable can be overridden to set the GO111MODULE environment variable. let g:ale_go_go111module = get(g:, 'ale_go_go111module', '') +" Default executable for deno, needed set before plugin start +let g:ale_deno_executable = get(g:, 'ale_deno_executable', 'deno') + " If 1, enable a popup menu for commands. let g:ale_popup_menu_enabled = get(g:, 'ale_popup_menu_enabled', has('gui_running')) diff --git a/sources_non_forked/ale/supported-tools.md b/sources_non_forked/ale/supported-tools.md index 96ef273b..5f36287e 100644 --- a/sources_non_forked/ale/supported-tools.md +++ b/sources_non_forked/ale/supported-tools.md @@ -22,12 +22,16 @@ formatting. --- * Ada + * [ada_language_server](https://github.com/AdaCore/ada_language_server) * [gcc](https://gcc.gnu.org) * [gnatpp](https://docs.adacore.com/gnat_ugn-docs/html/gnat_ugn/gnat_ugn/gnat_utility_programs.html#the-gnat-pretty-printer-gnatpp) :floppy_disk: * Ansible * [ansible-lint](https://github.com/willthames/ansible-lint) * API Blueprint * [drafter](https://github.com/apiaryio/drafter) +* APKBUILD + * [apkbuild-lint](https://gitlab.alpinelinux.org/Leo/atools) + * [secfixes-check](https://gitlab.alpinelinux.org/Leo/atools) * AsciiDoc * [alex](https://github.com/wooorm/alex) :floppy_disk: * [languagetool](https://languagetool.org/) :floppy_disk: @@ -48,6 +52,8 @@ formatting. * [shfmt](https://github.com/mvdan/sh) * Bats * [shellcheck](https://www.shellcheck.net/) +* Bazel + * [buildifier](https://github.com/bazelbuild/buildtools) * BibTeX * [bibclean](http://ftp.math.utah.edu/pub/bibclean/) * Bourne Shell @@ -58,8 +64,8 @@ formatting. * [astyle](http://astyle.sourceforge.net/) * [ccls](https://github.com/MaskRay/ccls) * [clang](http://clang.llvm.org/) - * [clangd](https://clang.llvm.org/extra/clangd.html) * [clang-format](https://clang.llvm.org/docs/ClangFormat.html) + * [clangd](https://clang.llvm.org/extra/clangd.html) * [clangtidy](http://clang.llvm.org/extra/clang-tidy/) :floppy_disk: * [cppcheck](http://cppcheck.sourceforge.net) * [cpplint](https://github.com/google/styleguide/tree/gh-pages/cpplint) @@ -76,9 +82,9 @@ formatting. * [astyle](http://astyle.sourceforge.net/) * [ccls](https://github.com/MaskRay/ccls) * [clang](http://clang.llvm.org/) + * [clang-format](https://clang.llvm.org/docs/ClangFormat.html) * [clangcheck](http://clang.llvm.org/docs/ClangCheck.html) :floppy_disk: * [clangd](https://clang.llvm.org/extra/clangd.html) - * [clang-format](https://clang.llvm.org/docs/ClangFormat.html) * [clangtidy](http://clang.llvm.org/extra/clang-tidy/) :floppy_disk: * [clazy](https://github.com/KDE/clazy) :floppy_disk: * [cppcheck](http://cppcheck.sourceforge.net) @@ -112,6 +118,7 @@ formatting. * Cucumber * [cucumber](https://cucumber.io/) * CUDA + * [clangd](https://clang.llvm.org/extra/clangd.html) * [nvcc](http://docs.nvidia.com/cuda/cuda-compiler-driver-nvcc/index.html) * Cypher * [cypher-lint](https://github.com/cleishm/libcypher-parser) @@ -125,11 +132,18 @@ formatting. * Dafny * [dafny](https://rise4fun.com/Dafny) :floppy_disk: * Dart + * [analysis_server](https://github.com/dart-lang/sdk/tree/master/pkg/analysis_server) + * [dart-analyze](https://github.com/dart-lang/sdk/tree/master/pkg/analyzer_cli) :floppy_disk: + * [dart-format](https://github.com/dart-lang/sdk/tree/master/utils/dartfmt) * [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) +* desktop + * [desktop-file-validate](https://www.freedesktop.org/wiki/Software/desktop-file-utils/) * Dhall * [dhall-format](https://github.com/dhall-lang/dhall-lang) + * [dhall-freeze](https://github.com/dhall-lang/dhall-lang) + * [dhall-lint](https://github.com/dhall-lang/dhall-lang) * Dockerfile * [dockerfile_lint](https://github.com/projectatomic/dockerfile_lint) * [hadolint](https://github.com/hadolint/hadolint) @@ -137,7 +151,7 @@ formatting. * [credo](https://github.com/rrrene/credo) * [dialyxir](https://github.com/jeremyjh/dialyxir) :floppy_disk: * [dogma](https://github.com/lpil/dogma) :floppy_disk: - * [elixir-ls](https://github.com/JakeBecker/elixir-ls) :warning: + * [elixir-ls](https://github.com/elixir-lsp/elixir-ls) :warning: * [mix](https://hexdocs.pm/mix/Mix.html) :warning: :floppy_disk: * Elm * [elm-format](https://github.com/avh4/elm-format) @@ -149,11 +163,14 @@ formatting. * [erubis](https://github.com/kwatch/erubis) * [ruumba](https://github.com/ericqweinstein/ruumba) * Erlang + * [SyntaxErl](https://github.com/ten0s/syntaxerl) + * [dialyzer](http://erlang.org/doc/man/dialyzer.html) * [elvis](https://github.com/inaka/elvis) :floppy_disk: * [erlc](http://erlang.org/doc/man/erlc.html) - * [SyntaxErl](https://github.com/ten0s/syntaxerl) + * [erlfmt](https://github.com/WhatsApp/erlfmt) * Fish * fish [-n flag](https://linux.die.net/man/1/fish) + * [fish_indent](https://fishshell.com/docs/current/cmds/fish_indent.html) * Fortran * [gcc](https://gcc.gnu.org/) * [language_server](https://github.com/hansec/fortran-language-server) @@ -169,17 +186,17 @@ formatting. * Go * [bingo](https://github.com/saibing/bingo) :warning: * [go build](https://golang.org/cmd/go/) :warning: :floppy_disk: + * [go mod](https://golang.org/cmd/go/) :warning: :floppy_disk: + * [go vet](https://golang.org/cmd/vet/) :floppy_disk: * [gofmt](https://golang.org/cmd/gofmt/) * [goimports](https://godoc.org/golang.org/x/tools/cmd/goimports) :warning: * [golangci-lint](https://github.com/golangci/golangci-lint) :warning: :floppy_disk: * [golangserver](https://github.com/sourcegraph/go-langserver) :warning: * [golint](https://godoc.org/github.com/golang/lint) * [gometalinter](https://github.com/alecthomas/gometalinter) :warning: :floppy_disk: - * [go mod](https://golang.org/cmd/go/) :warning: :floppy_disk: - * [gopls](https://github.com/golang/go/wiki/gopls) :warning: + * [gopls](https://github.com/golang/go/wiki/gopls) * [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 @@ -205,6 +222,7 @@ formatting. * [hie](https://github.com/haskell/haskell-ide-engine) * [hindent](https://hackage.haskell.org/package/hindent) * [hlint](https://hackage.haskell.org/package/hlint) + * [hls](https://github.com/haskell/haskell-language-server) * [ormolu](https://github.com/tweag/ormolu) * [stack-build](https://haskellstack.org/) :floppy_disk: * [stack-ghc](https://haskellstack.org/) @@ -213,9 +231,10 @@ formatting. * [terraform-fmt](https://github.com/hashicorp/terraform) * HTML * [alex](https://github.com/wooorm/alex) :floppy_disk: + * [angular](https://www.npmjs.com/package/@angular/language-server) * [fecs](http://fecs.baidu.com/) * [html-beautify](https://beautifier.io/) - * [HTMLHint](http://htmlhint.com/) + * [htmlhint](http://htmlhint.com/) * [prettier](https://github.com/prettier/prettier) * [proselint](http://proselint.com/) * [tidy](http://www.html-tidy.org/) @@ -224,15 +243,17 @@ formatting. * [idris](http://www.idris-lang.org/) * Ink * [ink-language-server](https://github.com/ephread/ink-language-server) +* Inko + * [inko](https://inko-lang.org/) :floppy_disk: * ISPC * [ispc](https://ispc.github.io/) :floppy_disk: * Java + * [PMD](https://pmd.github.io/) * [checkstyle](http://checkstyle.sourceforge.net) * [eclipselsp](https://github.com/eclipse/eclipse.jdt.ls) * [google-java-format](https://github.com/google/google-java-format) * [javac](http://www.oracle.com/technetwork/java/javase/downloads/index.html) * [javalsp](https://github.com/georgewfraser/vscode-javac) - * [PMD](https://pmd.github.io/) * [uncrustify](https://github.com/uncrustify/uncrustify) * JavaScript * [eslint](http://eslint.org/) @@ -249,8 +270,9 @@ formatting. * JSON * [fixjson](https://github.com/rhysd/fixjson) * [jq](https://stedolan.github.io/jq/) - * [jsonlint](http://zaa.ch/jsonlint/) + * [jsonlint](https://github.com/zaach/jsonlint) * [prettier](https://github.com/prettier/prettier) + * [spectral](https://github.com/stoplightio/spectral) * Julia * [languageserver](https://github.com/JuliaEditorSupport/LanguageServer.jl) * Kotlin @@ -274,9 +296,11 @@ formatting. * LLVM * [llc](https://llvm.org/docs/CommandGuide/llc.html) * Lua + * [lua-format](https://github.com/Koihik/LuaFormatter) * [luac](https://www.lua.org/manual/5.1/luac.html) * [luacheck](https://github.com/mpeterv/luacheck) * [luafmt](https://github.com/trixnz/lua-fmt) + * [stylua](https://github.com/johnnymorganz/stylua) * Mail * [alex](https://github.com/wooorm/alex) :floppy_disk: * [languagetool](https://languagetool.org/) :floppy_disk: @@ -289,6 +313,7 @@ formatting. * [languagetool](https://languagetool.org/) :floppy_disk: * [markdownlint](https://github.com/DavidAnson/markdownlint) :floppy_disk: * [mdl](https://github.com/mivok/markdownlint) + * [pandoc](https://pandoc.org) * [prettier](https://github.com/prettier/prettier) * [proselint](http://proselint.com/) * [redpen](http://redpen.cc/) @@ -308,7 +333,9 @@ formatting. * nimpretty * nix * [nix-instantiate](http://nixos.org/nix/manual/#sec-nix-instantiate) + * [nixfmt](https://github.com/serokell/nixfmt) * [nixpkgs-fmt](https://github.com/nix-community/nixpkgs-fmt) + * [rnix-lsp](https://github.com/nix-community/rnix-lsp) * nroff * [alex](https://github.com/wooorm/alex) :floppy_disk: * [proselint](http://proselint.com/) @@ -325,8 +352,15 @@ formatting. * OCaml * [merlin](https://github.com/the-lambda-church/merlin) see `:help ale-ocaml-merlin` for configuration instructions * [ocamlformat](https://github.com/ocaml-ppx/ocamlformat) + * [ocamllsp](https://github.com/ocaml/ocaml-lsp) * [ocp-indent](https://github.com/OCamlPro/ocp-indent) * [ols](https://github.com/freebroccolo/ocaml-language-server) +* OpenApi + * [ibm_validator](https://github.com/IBM/openapi-validator) + * [prettier](https://github.com/prettier/prettier) + * [yamllint](https://yamllint.readthedocs.io/) +* Pascal + * [ptop](https://www.freepascal.org/tools/ptop.var) * Pawn * [uncrustify](https://github.com/uncrustify/uncrustify) * Perl @@ -339,10 +373,10 @@ formatting. * [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 + * [php -l](https://secure.php.net/) + * [php-cs-fixer](http://cs.sensiolabs.org/) * [phpcbf](https://github.com/squizlabs/PHP_CodeSniffer) * [phpcs](https://github.com/squizlabs/PHP_CodeSniffer) - * [php-cs-fixer](http://cs.sensiolabs.org/) - * [php -l](https://secure.php.net/) * [phpmd](https://phpmd.org) * [phpstan](https://github.com/phpstan/phpstan) * [psalm](https://getpsalm.org) :floppy_disk: @@ -365,6 +399,7 @@ formatting. * [swipl](https://github.com/SWI-Prolog/swipl-devel) * proto * [protoc-gen-lint](https://github.com/ckaznocha/protoc-gen-lint) + * [protolint](https://github.com/yoheimuta/protolint) * Pug * [pug-lint](https://github.com/pugjs/pug-lint) * Puppet @@ -375,6 +410,7 @@ formatting. * [purescript-language-server](https://github.com/nwolverson/purescript-language-server) * [purty](https://gitlab.com/joneshf/purty) * Python + * [autoflake](https://github.com/myint/autoflake) * [autoimport](https://lyz-code.github.io/autoimport/) * [autopep8](https://github.com/hhatto/autopep8) * [bandit](https://github.com/PyCQA/bandit) :warning: @@ -388,7 +424,7 @@ formatting. * [pyflakes](https://github.com/PyCQA/pyflakes) * [pylama](https://github.com/klen/pylama) :floppy_disk: * [pylint](https://www.pylint.org/) :floppy_disk: - * [pyls](https://github.com/palantir/python-language-server) :warning: + * [pylsp](https://github.com/python-lsp/python-lsp-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) @@ -402,7 +438,10 @@ formatting. * [lintr](https://github.com/jimhester/lintr) * [styler](https://github.com/r-lib/styler) * Racket + * [racket-langserver](https://github.com/jeapostrophe/racket-langserver/tree/master) * [raco](https://docs.racket-lang.org/raco/) +* Re:VIEW + * [redpen](http://redpen.cc/) * ReasonML * [merlin](https://github.com/the-lambda-church/merlin) see `:help ale-reasonml-ols` for configuration instructions * [ols](https://github.com/freebroccolo/ocaml-language-server) @@ -416,13 +455,12 @@ formatting. * [textlint](https://textlint.github.io/) * [vale](https://github.com/ValeLint/vale) * [write-good](https://github.com/btford/write-good) -* Re:VIEW - * [redpen](http://redpen.cc/) * RPM spec * [rpmlint](https://github.com/rpm-software-management/rpmlint) :warning: (see `:help ale-integration-spec`) * Ruby * [brakeman](http://brakemanscanner.org/) :floppy_disk: * [debride](https://github.com/seattlerb/debride) :floppy_disk: + * [prettier](https://github.com/prettier/plugin-ruby) * [rails_best_practices](https://github.com/flyerhzm/rails_best_practices) :floppy_disk: * [reek](https://github.com/troessner/reek) * [rubocop](https://github.com/bbatsov/rubocop) @@ -437,6 +475,8 @@ formatting. * [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) +* Salt + * [salt-lint](https://github.com/warpnet/salt-lint) * Sass * [sass-lint](https://www.npmjs.com/package/sass-lint) * [stylelint](https://github.com/stylelint/stylelint) @@ -462,23 +502,31 @@ formatting. * [solium](https://github.com/duaraghav8/Solium) * SQL * [pgformatter](https://github.com/darold/pgFormatter) + * [sql-lint](https://github.com/joereynolds/sql-lint) * [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) +* Svelte + * [prettier](https://github.com/prettier/prettier) + * [svelteserver](https://github.com/sveltejs/language-tools/tree/master/packages/language-server) * 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) +* systemd + * [systemd-analyze](https://www.freedesktop.org/software/systemd/man/systemd-analyze.html) :floppy_disk: * Tcl * [nagelfar](http://nagelfar.sourceforge.net) :floppy_disk: * Terraform - * [fmt](https://github.com/hashicorp/terraform) + * [terraform](https://github.com/hashicorp/terraform) + * [terraform-fmt-fixer](https://github.com/hashicorp/terraform) + * [terraform-ls](https://github.com/hashicorp/terraform-ls) + * [terraform-lsp](https://github.com/juliosueiras/terraform-lsp) * [tflint](https://github.com/wata727/tflint) * Texinfo * [alex](https://github.com/wooorm/alex) :floppy_disk: @@ -494,7 +542,9 @@ formatting. * [write-good](https://github.com/btford/write-good) :warning: * Thrift * [thrift](http://thrift.apache.org/) + * [thriftcheck](https://github.com/pinterest/thriftcheck) * TypeScript + * [deno](https://deno.land/) * [eslint](http://eslint.org/) * [fecs](http://fecs.baidu.com/) * [prettier](https://github.com/prettier/prettier) @@ -502,14 +552,19 @@ formatting. * [tslint](https://github.com/palantir/tslint) * [tsserver](https://github.com/Microsoft/TypeScript/wiki/Standalone-Server-%28tsserver%29) * typecheck +* V + * [v](https://github.com/vlang/v/) + * [vfmt](https://github.com/vlang/v/) * VALA * [uncrustify](https://github.com/uncrustify/uncrustify) + * [vala_lint](https://github.com/vala-lang/vala-lint) :floppy_disk: * 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/) * [xvlog](https://www.xilinx.com/products/design-tools/vivado.html) + * [yosys](http://www.clifford.at/yosys/) * VHDL * [ghdl](https://github.com/ghdl/ghdl) * [vcom](https://www.mentor.com/products/fv/questa/) @@ -531,7 +586,9 @@ formatting. * XML * [xmllint](http://xmlsoft.org/xmllint.html) * YAML + * [circleci](https://circleci.com/docs/2.0/local-cli) :floppy_disk: * [prettier](https://github.com/prettier/prettier) + * [spectral](https://github.com/stoplightio/spectral) * [swaglint](https://github.com/byCedric/swaglint) * [yamlfix](https://lyz-code.github.io/yamlfix) * [yamllint](https://yamllint.readthedocs.io/) diff --git a/sources_non_forked/bufexplorer/README.md b/sources_non_forked/bufexplorer/README.md index 2987bdd9..6faed6bc 100644 --- a/sources_non_forked/bufexplorer/README.md +++ b/sources_non_forked/bufexplorer/README.md @@ -69,7 +69,7 @@ This plugin can also be found at http://www.vim.org/scripts/script.php?script_id git clone https://github.com/jlanzarotta/bufexplorer.git ~/.vim/bundle/bufexplorer.vim ## License -Copyright (c) 2001-2020, Jeff Lanzarotta +Copyright (c) 2001-2021, Jeff Lanzarotta All rights reserved. diff --git a/sources_non_forked/ctrlp.vim/readme.md b/sources_non_forked/ctrlp.vim/readme.md index 2f4c6aed..6ab8b246 100644 --- a/sources_non_forked/ctrlp.vim/readme.md +++ b/sources_non_forked/ctrlp.vim/readme.md @@ -105,5 +105,5 @@ CtrlP is distributed under Vim's [license][4]. [1]: http://i.imgur.com/aOcwHwt.png [2]: https://github.com/ctrlpvim/ctrlp.vim/tree/extensions -[3]: http://ctrlpvim.github.com/ctrlp.vim#installation +[3]: http://ctrlpvim.github.io/ctrlp.vim#installation [4]: http://vimdoc.sourceforge.net/htmldoc/uganda.html diff --git a/sources_non_forked/dracula/.github/issue_template.md b/sources_non_forked/dracula/.github/issue_template.md new file mode 100644 index 00000000..aae6b85e --- /dev/null +++ b/sources_non_forked/dracula/.github/issue_template.md @@ -0,0 +1,45 @@ + + +### What happened + +### What I expected to happen + +### Screenshot + +### Machine Info + +- **Vim type (`vim`/`gvim`/`neovim`)**: +- **Vim version**: +- **OS**: +- **Terminal/Terminal Emulator/VTE**: +- **`TERM` environment variable**: + +### Additional Info + + diff --git a/sources_non_forked/dracula/.github/pull_request_template.md b/sources_non_forked/dracula/.github/pull_request_template.md new file mode 100644 index 00000000..b2a1becd --- /dev/null +++ b/sources_non_forked/dracula/.github/pull_request_template.md @@ -0,0 +1,5 @@ + + diff --git a/sources_non_forked/dracula/.gitignore b/sources_non_forked/dracula/.gitignore new file mode 100644 index 00000000..926ccaaf --- /dev/null +++ b/sources_non_forked/dracula/.gitignore @@ -0,0 +1 @@ +doc/tags diff --git a/sources_non_forked/dracula/INSTALL.md b/sources_non_forked/dracula/INSTALL.md new file mode 100644 index 00000000..5fb2210e --- /dev/null +++ b/sources_non_forked/dracula/INSTALL.md @@ -0,0 +1,93 @@ +### [Vim](http://www.vim.org/) + +#### Install + +These are the default instructions using Vim 8's `|packages|` feature. See +sections below, if you use other plugin managers. + +1. Create theme folder (in case you don't have yet): + + +- \*nix: +``` +mkdir -p ~/.vim/pack/themes/start +``` + +- Windows: create directory `$HOME\vimfiles\pack\themes\start` + +If you use vim 8.0 (and not 8.2), you may need to use `~/.vim/pack/themes/opt` +or `$HOME\vimfiles\pack\themes\opt` instead. + +2. Navigate to the folder above: + + +- \*nix: +``` +cd ~/.vim/pack/themes/start +``` + +- Windows: navigate to `$HOME\vimfiles\pack\themes\start` + +3. Clone the repository using the "dracula" name: + +``` +git clone https://github.com/dracula/vim.git dracula +``` +(Or use your favorite GUI client, or download the ZIP) + +4. Edit your `vimrc` file with the following content: + +``` +packadd! dracula +syntax enable +colorscheme dracula +``` + +The location of the `vimrc` varies between platforms: +- \*nix: `~/.vim/vimrc` or `~/.vimrc` +- Windows: `$HOME\vimfiles\vimrc` or `$HOME\_vimrc` + +#### Install using other plugin managers + +- If you [use vim + pathogen + submodules](http://vimcasts.org/episodes/synchronizing-plugins-with-git-submodules-and-pathogen/): + +Navigate to your vim directory (\*nix: `~/.vim`; Windows: `$HOME\vimfiles`) + + git submodule add git@github.com:dracula/vim.git bundle/dracula + +Place `colorscheme dracula` after `execute pathogen#infect()`. + +- If you [use vim + vundle](https://github.com/VundleVim/Vundle): + + Plugin 'dracula/vim', { 'name': 'dracula' } + :PluginInstall + +Place `colorscheme dracula` after `call vundle#end()`. + +- If you [use vim-plug](https://github.com/junegunn/vim-plug) (\`as\` will install +the plugin in a directory called 'dracula' instead of just 'vim'): + + Plug 'dracula/vim', { 'as': 'dracula' } + :PlugInstall + +Place `colorscheme dracula` after `call plug#end()`. + +- If you [use spacevim](https://spacevim.org), put the +following in `~/.SpaceVim.d/init.toml`: + +```toml +[options] + colorscheme = "dracula" + colorscheme_bg = "dark" +[[custom_plugins]] + repo = "dracula/vim" + name = "dracula" + merged = false +``` + +--- + +Note that dracula must be in your `'runtimepath'` to load properly: Version 2.0 +introduced autoload functionality for part of the plugin, which doesn't work +without `'runtimepath'` properly set. Consult your plugin-managers documentation +to make sure you put dracula on the `'runtimepath'` before loading it. diff --git a/sources_non_forked/dracula/LICENSE b/sources_non_forked/dracula/LICENSE new file mode 100644 index 00000000..dcaf6d7f --- /dev/null +++ b/sources_non_forked/dracula/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2016 Dracula Theme + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/sources_non_forked/dracula/README.md b/sources_non_forked/dracula/README.md new file mode 100644 index 00000000..cea8721e --- /dev/null +++ b/sources_non_forked/dracula/README.md @@ -0,0 +1,25 @@ +# Dracula for [Vim](http://www.vim.org/) + +> A dark theme for [Vim](http://www.vim.org/). + +![Screenshot](./screenshot.png) + +Screenshot taken with the [pangloss/vim-javascript](https://github.com/pangloss/vim-javascript) +syntax plugin for javascript. + +## Install + +All instructions can be found at [draculatheme.com/vim](https://draculatheme.com/vim). + +## Team + +This theme is maintained by the following person(s) and a bunch of +[awesome contributors](https://github.com/dracula/vim/graphs/contributors). + +| [![Derek S.](https://avatars3.githubusercontent.com/u/5240018?v=3&s=70)](https://github.com/dsifford) | [![David Knoble](https://avatars0.githubusercontent.com/u/22802209?v=4&s=70)](https://github.com/benknoble) | +| ----------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------- | +| [Derek S.](https://github.com/dsifford) | [David Knoble](https://github.com/benknoble) | + +## License + +[MIT License](./LICENSE) diff --git a/sources_non_forked/dracula/after/plugin/dracula.vim b/sources_non_forked/dracula/after/plugin/dracula.vim new file mode 100644 index 00000000..61eaf5cf --- /dev/null +++ b/sources_non_forked/dracula/after/plugin/dracula.vim @@ -0,0 +1,95 @@ +if dracula#should_abort() + finish +endif + +" Fzf: {{{ +if exists('g:loaded_fzf') && ! exists('g:fzf_colors') + let g:fzf_colors = { + \ 'fg': ['fg', 'Normal'], + \ 'bg': ['bg', 'Normal'], + \ 'hl': ['fg', 'Search'], + \ 'fg+': ['fg', 'Normal'], + \ 'bg+': ['bg', 'Normal'], + \ 'hl+': ['fg', 'DraculaOrange'], + \ 'info': ['fg', 'DraculaPurple'], + \ 'border': ['fg', 'Ignore'], + \ 'prompt': ['fg', 'DraculaGreen'], + \ 'pointer': ['fg', 'Exception'], + \ 'marker': ['fg', 'Keyword'], + \ 'spinner': ['fg', 'Label'], + \ 'header': ['fg', 'Comment'], + \} +endif +"}}} +" ALE: {{{ +if exists('g:ale_enabled') + hi! link ALEError DraculaErrorLine + hi! link ALEWarning DraculaWarnLine + hi! link ALEInfo DraculaInfoLine + + hi! link ALEErrorSign DraculaRed + hi! link ALEWarningSign DraculaOrange + hi! link ALEInfoSign DraculaCyan + + hi! link ALEVirtualTextError Comment + hi! link ALEVirtualTextWarning Comment +endif +" }}} +" CtrlP: {{{ +if exists('g:loaded_ctrlp') + hi! link CtrlPMatch IncSearch + hi! link CtrlPBufferHid Normal +endif +" }}} +" GitGutter / gitsigns: {{{ +if exists('g:loaded_gitgutter') + hi! link GitGutterAdd DiffAdd + hi! link GitGutterChange DiffChange + hi! link GitGutterDelete DiffDelete +endif +if has('nvim-0.5') && luaeval("pcall(require, 'gitsigns')") + " https://github.com/lewis6991/gitsigns.nvim requires nvim > 0.5 + " has('nvim-0.5') checks >= 0.5, so this should be future-proof. + hi! link GitSignsAdd DiffAdd + hi! link GitSignsAddLn DiffAdd + hi! link GitSignsAddNr DiffAdd + hi! link GitSignsChange DiffChange + hi! link GitSignsChangeLn DiffChange + hi! link GitSignsChangeNr DiffChange + hi! link GitSignsDelete DiffDelete + hi! link GitSignsDeleteLn DiffDelete + hi! link GitSignsDeleteNr DiffDelete +endif +" }}} +" Tree-sitter: {{{ +if exists('g:loaded_nvim_treesitter') + " # Misc + hi! link TSPunctSpecial Special + " # Constants + hi! link TSConstMacro Macro + hi! link TSStringEscape Character + hi! link TSSymbol DraculaPurple + hi! link TSAnnotation DraculaYellow + hi! link TSAttribute DraculaGreenItalic + " # Functions + hi! link TSFuncBuiltin DraculaCyan + hi! link TSFuncMacro Function + hi! link TSParameter DraculaOrangeItalic + hi! link TSParameterReference DraculaOrange + hi! link TSField DraculaOrange + hi! link TSConstructor DraculaCyan + " # Keywords + hi! link TSLabel DraculaPurpleItalic + " # Variable + hi! link TSVariableBuiltin DraculaPurpleItalic + " # Text + hi! link TSStrong DraculaFgBold + hi! link TSEmphasis DraculaFg + hi! link TSUnderline Underlined + hi! link TSTitle DraculaYellow + hi! link TSLiteral DraculaYellow + hi! link TSURI DraculaYellow +endif +" }}} + +" vim: fdm=marker ts=2 sts=2 sw=2 fdl=0: diff --git a/sources_non_forked/dracula/after/syntax/css.vim b/sources_non_forked/dracula/after/syntax/css.vim new file mode 100644 index 00000000..764e0afc --- /dev/null +++ b/sources_non_forked/dracula/after/syntax/css.vim @@ -0,0 +1,15 @@ +if dracula#should_abort('css') + finish +endif + +hi! link cssAttrComma Delimiter +hi! link cssAttrRegion DraculaPink +hi! link cssAttributeSelector DraculaGreenItalic +hi! link cssBraces Delimiter +hi! link cssFunctionComma Delimiter +hi! link cssNoise DraculaPink +hi! link cssProp DraculaCyan +hi! link cssPseudoClass DraculaPink +hi! link cssPseudoClassId DraculaGreenItalic +hi! link cssUnitDecorators DraculaPink +hi! link cssVendor DraculaGreenItalic diff --git a/sources_non_forked/dracula/after/syntax/gitcommit.vim b/sources_non_forked/dracula/after/syntax/gitcommit.vim new file mode 100644 index 00000000..08099e50 --- /dev/null +++ b/sources_non_forked/dracula/after/syntax/gitcommit.vim @@ -0,0 +1,12 @@ +if dracula#should_abort('gitcommit') + finish +endif + +" The following two are misnomers. Colors are correct. +hi! link diffFile DraculaGreen +hi! link diffNewFile DraculaRed + +hi! link diffAdded DraculaGreen +hi! link diffLine DraculaCyanItalic +hi! link diffRemoved DraculaRed + diff --git a/sources_non_forked/dracula/after/syntax/html.vim b/sources_non_forked/dracula/after/syntax/html.vim new file mode 100644 index 00000000..243aef63 --- /dev/null +++ b/sources_non_forked/dracula/after/syntax/html.vim @@ -0,0 +1,9 @@ +if dracula#should_abort('html') + finish +endif + +hi! link htmlTag DraculaFg +hi! link htmlArg DraculaGreenItalic +hi! link htmlTitle DraculaFg +hi! link htmlH1 DraculaFg +hi! link htmlSpecialChar DraculaPurple diff --git a/sources_non_forked/dracula/after/syntax/javascript.vim b/sources_non_forked/dracula/after/syntax/javascript.vim new file mode 100644 index 00000000..e5754aec --- /dev/null +++ b/sources_non_forked/dracula/after/syntax/javascript.vim @@ -0,0 +1,45 @@ +if dracula#should_abort('javascript', 'javascriptreact', 'javascript.jsx') + finish +endif + +hi! link javaScriptBraces Delimiter +hi! link javaScriptNumber Constant +hi! link javaScriptNull Constant +hi! link javaScriptFunction Keyword + +" pangloss/vim-javascript {{{ + +hi! link jsArrowFunction Operator +hi! link jsBuiltins DraculaCyan +hi! link jsClassDefinition DraculaCyan +hi! link jsClassMethodType Keyword +hi! link jsDestructuringAssignment DraculaOrangeItalic +hi! link jsDocParam DraculaOrangeItalic +hi! link jsDocTags Keyword +hi! link jsDocType Type +hi! link jsDocTypeBrackets DraculaCyan +hi! link jsFuncArgOperator Operator +hi! link jsFuncArgs DraculaOrangeItalic +hi! link jsFunction Keyword +hi! link jsNull Constant +hi! link jsObjectColon DraculaPink +hi! link jsSuper DraculaPurpleItalic +hi! link jsTemplateBraces Special +hi! link jsThis DraculaPurpleItalic +hi! link jsUndefined Constant + +"}}} + +" maxmellon/vim-jsx-pretty {{{ + +hi! link jsxTag Keyword +hi! link jsxTagName Keyword +hi! link jsxComponentName Type +hi! link jsxCloseTag Type +hi! link jsxAttrib DraculaGreenItalic +hi! link jsxCloseString Identifier +hi! link jsxOpenPunct Identifier + +" }}} + +" vim: fdm=marker ts=2 sts=2 sw=2 fdl=0: diff --git a/sources_non_forked/dracula/after/syntax/javascriptreact.vim b/sources_non_forked/dracula/after/syntax/javascriptreact.vim new file mode 100644 index 00000000..b5b557c0 --- /dev/null +++ b/sources_non_forked/dracula/after/syntax/javascriptreact.vim @@ -0,0 +1 @@ +runtime! syntax/javascript.vim diff --git a/sources_non_forked/dracula/after/syntax/json.vim b/sources_non_forked/dracula/after/syntax/json.vim new file mode 100644 index 00000000..a45d135d --- /dev/null +++ b/sources_non_forked/dracula/after/syntax/json.vim @@ -0,0 +1,6 @@ +if dracula#should_abort('json') + finish +endif + +hi! link jsonKeyword DraculaCyan +hi! link jsonKeywordMatch DraculaPink diff --git a/sources_non_forked/dracula/after/syntax/lua.vim b/sources_non_forked/dracula/after/syntax/lua.vim new file mode 100644 index 00000000..664848df --- /dev/null +++ b/sources_non_forked/dracula/after/syntax/lua.vim @@ -0,0 +1,22 @@ +if dracula#should_abort('lua') + finish +endif + +hi! link luaFunc DraculaCyan +hi! link luaTable DraculaFg + +" tbastos/vim-lua {{{ + +hi! link luaBraces DraculaFg +hi! link luaBuiltIn Constant +hi! link luaDocTag Keyword +hi! link luaErrHand DraculaCyan +hi! link luaFuncArgName DraculaOrangeItalic +hi! link luaFuncCall Function +hi! link luaLocal Keyword +hi! link luaSpecialTable Constant +hi! link luaSpecialValue DraculaCyan + +" }}} + +" vim: fdm=marker ts=2 sts=2 sw=2 fdl=0: diff --git a/sources_non_forked/dracula/after/syntax/markdown.vim b/sources_non_forked/dracula/after/syntax/markdown.vim new file mode 100644 index 00000000..0283a86d --- /dev/null +++ b/sources_non_forked/dracula/after/syntax/markdown.vim @@ -0,0 +1,50 @@ +if dracula#should_abort('markdown', 'mkd') + finish +endif + +if b:current_syntax ==# 'mkd' +" plasticboy/vim-markdown {{{1 + hi! link htmlBold DraculaOrangeBold + hi! link htmlBoldItalic DraculaOrangeBoldItalic + hi! link htmlH1 DraculaPurpleBold + hi! link htmlItalic DraculaYellowItalic + hi! link mkdBlockquote DraculaYellowItalic + hi! link mkdBold DraculaOrangeBold + hi! link mkdBoldItalic DraculaOrangeBoldItalic + hi! link mkdCode DraculaGreen + hi! link mkdCodeEnd DraculaGreen + hi! link mkdCodeStart DraculaGreen + hi! link mkdHeading DraculaPurpleBold + hi! link mkdInlineUrl DraculaLink + hi! link mkdItalic DraculaYellowItalic + hi! link mkdLink DraculaPink + hi! link mkdListItem DraculaCyan + hi! link mkdRule DraculaComment + hi! link mkdUrl DraculaLink +"}}}1 +elseif b:current_syntax ==# 'markdown' +" Builtin: {{{1 + hi! link markdownBlockquote DraculaCyan + hi! link markdownBold DraculaOrangeBold + hi! link markdownBoldItalic DraculaOrangeBoldItalic + hi! link markdownCodeBlock DraculaGreen + hi! link markdownCode DraculaGreen + hi! link markdownCodeDelimiter DraculaGreen + hi! link markdownH1 DraculaPurpleBold + hi! link markdownH2 markdownH1 + hi! link markdownH3 markdownH1 + hi! link markdownH4 markdownH1 + hi! link markdownH5 markdownH1 + hi! link markdownH6 markdownH1 + hi! link markdownHeadingDelimiter markdownH1 + hi! link markdownHeadingRule markdownH1 + hi! link markdownItalic DraculaYellowItalic + hi! link markdownLinkText DraculaPink + hi! link markdownListMarker DraculaCyan + hi! link markdownOrderedListMarker DraculaCyan + hi! link markdownRule DraculaComment + hi! link markdownUrl DraculaLink +"}}} +endif + +" vim: fdm=marker ts=2 sts=2 sw=2 fdl=0: diff --git a/sources_non_forked/dracula/after/syntax/ocaml.vim b/sources_non_forked/dracula/after/syntax/ocaml.vim new file mode 100644 index 00000000..60c76c96 --- /dev/null +++ b/sources_non_forked/dracula/after/syntax/ocaml.vim @@ -0,0 +1,7 @@ +if dracula#should_abort('ocaml') + finish +endif + +hi! link ocamlModule Type +hi! link ocamlModPath Normal +hi! link ocamlLabel DraculaOrangeItalic diff --git a/sources_non_forked/dracula/after/syntax/perl.vim b/sources_non_forked/dracula/after/syntax/perl.vim new file mode 100644 index 00000000..67f39231 --- /dev/null +++ b/sources_non_forked/dracula/after/syntax/perl.vim @@ -0,0 +1,38 @@ +if dracula#should_abort('perl') + finish +endif + +" Regex +hi! link perlMatchStartEnd DraculaRed + +" Builtin functions +hi! link perlOperator DraculaCyan +hi! link perlStatementFiledesc DraculaCyan +hi! link perlStatementFiles DraculaCyan +hi! link perlStatementFlow DraculaCyan +hi! link perlStatementHash DraculaCyan +hi! link perlStatementIOfunc DraculaCyan +hi! link perlStatementIPC DraculaCyan +hi! link perlStatementList DraculaCyan +hi! link perlStatementMisc DraculaCyan +hi! link perlStatementNetwork DraculaCyan +hi! link perlStatementNumeric DraculaCyan +hi! link perlStatementProc DraculaCyan +hi! link perlStatementPword DraculaCyan +hi! link perlStatementRegexp DraculaCyan +hi! link perlStatementScalar DraculaCyan +hi! link perlStatementSocket DraculaCyan +hi! link perlStatementTime DraculaCyan +hi! link perlStatementVector DraculaCyan + +" Highlighting for quoting constructs, tied to existing option in vim-perl +if get(g:, 'perl_string_as_statement', 0) + hi! link perlStringStartEnd DraculaRed +endif + +" Signatures +hi! link perlSignature DraculaOrangeItalic +hi! link perlSubPrototype DraculaOrangeItalic + +" Hash keys +hi! link perlVarSimpleMemberName DraculaPurple diff --git a/sources_non_forked/dracula/after/syntax/php.vim b/sources_non_forked/dracula/after/syntax/php.vim new file mode 100644 index 00000000..1475b018 --- /dev/null +++ b/sources_non_forked/dracula/after/syntax/php.vim @@ -0,0 +1,10 @@ +if dracula#should_abort('php') + finish +endif + +hi! link phpClass Type +hi! link phpClasses Type +hi! link phpDocTags DraculaCyanItalic +hi! link phpFunction Function +hi! link phpParent Normal +hi! link phpSpecialFunction DraculaCyan diff --git a/sources_non_forked/dracula/after/syntax/plantuml.vim b/sources_non_forked/dracula/after/syntax/plantuml.vim new file mode 100644 index 00000000..b9bf3651 --- /dev/null +++ b/sources_non_forked/dracula/after/syntax/plantuml.vim @@ -0,0 +1,13 @@ +if dracula#should_abort('plantuml') + finish +endif + +hi! link plantumlClassPrivate SpecialKey +hi! link plantumlClassProtected DraculaOrange +hi! link plantumlClassPublic Function +hi! link plantumlColonLine String +hi! link plantumlDirectedOrVerticalArrowLR Constant +hi! link plantumlDirectedOrVerticalArrowRL Constant +hi! link plantumlHorizontalArrow Constant +hi! link plantumlSkinParamKeyword DraculaCyan +hi! link plantumlTypeKeyword Keyword diff --git a/sources_non_forked/dracula/after/syntax/purescript.vim b/sources_non_forked/dracula/after/syntax/purescript.vim new file mode 100644 index 00000000..ca328181 --- /dev/null +++ b/sources_non_forked/dracula/after/syntax/purescript.vim @@ -0,0 +1,9 @@ +if dracula#should_abort('purescript') + finish +endif + +hi! link purescriptModule Type +hi! link purescriptImport DraculaCyan +hi! link purescriptImportAs DraculaCyan +hi! link purescriptOperator Operator +hi! link purescriptBacktick Operator diff --git a/sources_non_forked/dracula/after/syntax/python.vim b/sources_non_forked/dracula/after/syntax/python.vim new file mode 100644 index 00000000..171eddde --- /dev/null +++ b/sources_non_forked/dracula/after/syntax/python.vim @@ -0,0 +1,11 @@ +if dracula#should_abort('python') + finish +endif + +hi! link pythonBuiltinObj Type +hi! link pythonBuiltinObject Type +hi! link pythonBuiltinType Type +hi! link pythonClassVar DraculaPurpleItalic +hi! link pythonExClass Type +hi! link pythonNone Type +hi! link pythonRun Comment diff --git a/sources_non_forked/dracula/after/syntax/rst.vim b/sources_non_forked/dracula/after/syntax/rst.vim new file mode 100644 index 00000000..8cb69240 --- /dev/null +++ b/sources_non_forked/dracula/after/syntax/rst.vim @@ -0,0 +1,26 @@ +if dracula#should_abort('rst') + finish +endif + +hi! link rstComment Comment +hi! link rstTransition Comment +hi! link rstCodeBlock DraculaGreen +hi! link rstInlineLiteral DraculaGreen +hi! link rstLiteralBlock DraculaGreen +hi! link rstQuotedLiteralBlock DraculaGreen +hi! link rstStandaloneHyperlink DraculaLink +hi! link rstStrongEmphasis DraculaOrangeBold +hi! link rstSections DraculaPurpleBold +hi! link rstEmphasis DraculaYellowItalic +hi! link rstDirective Keyword +hi! link rstSubstitutionDefinition Keyword +hi! link rstCitation String +hi! link rstExDirective String +hi! link rstFootnote String +hi! link rstCitationReference Tag +hi! link rstFootnoteReference Tag +hi! link rstHyperLinkReference Tag +hi! link rstHyperlinkTarget Tag +hi! link rstInlineInternalTargets Tag +hi! link rstInterpretedTextOrHyperlinkReference Tag +hi! link rstTodo Todo diff --git a/sources_non_forked/dracula/after/syntax/ruby.vim b/sources_non_forked/dracula/after/syntax/ruby.vim new file mode 100644 index 00000000..fec00584 --- /dev/null +++ b/sources_non_forked/dracula/after/syntax/ruby.vim @@ -0,0 +1,16 @@ +if dracula#should_abort('ruby') + finish +endif + +if ! exists('g:ruby_operators') + let g:ruby_operators=1 +endif + +hi! link rubyBlockArgument DraculaOrangeItalic +hi! link rubyBlockParameter DraculaOrangeItalic +hi! link rubyCurlyBlock DraculaPink +hi! link rubyGlobalVariable DraculaPurple +hi! link rubyInstanceVariable DraculaPurpleItalic +hi! link rubyInterpolationDelimiter DraculaPink +hi! link rubyRegexpDelimiter DraculaRed +hi! link rubyStringDelimiter DraculaYellow diff --git a/sources_non_forked/dracula/after/syntax/rust.vim b/sources_non_forked/dracula/after/syntax/rust.vim new file mode 100644 index 00000000..410334b2 --- /dev/null +++ b/sources_non_forked/dracula/after/syntax/rust.vim @@ -0,0 +1,5 @@ +if dracula#should_abort('rust') + finish +endif + +hi! link rustCommentLineDoc Comment diff --git a/sources_non_forked/dracula/after/syntax/sass.vim b/sources_non_forked/dracula/after/syntax/sass.vim new file mode 100644 index 00000000..35a810f9 --- /dev/null +++ b/sources_non_forked/dracula/after/syntax/sass.vim @@ -0,0 +1,12 @@ +if dracula#should_abort('sass') + finish +endif + +hi! link sassClass cssClassName +hi! link sassClassChar cssClassNameDot +hi! link sassId cssIdentifier +hi! link sassIdChar cssIdentifier +hi! link sassInterpolationDelimiter DraculaPink +hi! link sassMixinName Function +hi! link sassProperty cssProp +hi! link sassVariableAssignment Operator diff --git a/sources_non_forked/dracula/after/syntax/sh.vim b/sources_non_forked/dracula/after/syntax/sh.vim new file mode 100644 index 00000000..8d471ef7 --- /dev/null +++ b/sources_non_forked/dracula/after/syntax/sh.vim @@ -0,0 +1,8 @@ +if dracula#should_abort('bash', 'ksh', 'posix', 'sh') + finish +endif + +hi! link shCommandSub NONE +hi! link shEscape DraculaRed +hi! link shParen NONE +hi! link shParenError NONE diff --git a/sources_non_forked/dracula/after/syntax/tex.vim b/sources_non_forked/dracula/after/syntax/tex.vim new file mode 100644 index 00000000..a46132c8 --- /dev/null +++ b/sources_non_forked/dracula/after/syntax/tex.vim @@ -0,0 +1,16 @@ +if dracula#should_abort('tex') + finish +endif + +hi! link texBeginEndName DraculaOrangeItalic +hi! link texBoldItalStyle DraculaOrangeBoldItalic +hi! link texBoldStyle DraculaOrangeBold +hi! link texInputFile DraculaOrangeItalic +hi! link texItalStyle DraculaYellowItalic +hi! link texLigature DraculaPurple +hi! link texMath DraculaPurple +hi! link texMathMatcher DraculaPurple +hi! link texMathSymbol DraculaPurple +hi! link texSpecialChar DraculaPurple +hi! link texSubscripts DraculaPurple +hi! link texTitle DraculaFgBold diff --git a/sources_non_forked/dracula/after/syntax/typescript.vim b/sources_non_forked/dracula/after/syntax/typescript.vim new file mode 100644 index 00000000..c368fb57 --- /dev/null +++ b/sources_non_forked/dracula/after/syntax/typescript.vim @@ -0,0 +1,57 @@ +if dracula#should_abort('typescript', 'typescriptreact', 'typescript.tsx') + finish +endif + +" HerringtonDarkholme/yats.vim {{{ + +hi! link typescriptAliasDeclaration Type +hi! link typescriptArrayMethod Function +hi! link typescriptArrowFunc Operator +hi! link typescriptArrowFuncArg DraculaOrangeItalic +hi! link typescriptAssign Operator +hi! link typescriptBOMWindowProp Constant +hi! link typescriptBinaryOp Operator +hi! link typescriptBraces Delimiter +hi! link typescriptCall typescriptArrowFuncArg +hi! link typescriptClassHeritage Type +hi! link typescriptClassName Type +hi! link typescriptDateMethod DraculaCyan +hi! link typescriptDateStaticMethod Function +hi! link typescriptDecorator DraculaGreenItalic +hi! link typescriptDefaultParam Operator +hi! link typescriptES6SetMethod DraculaCyan +hi! link typescriptEndColons Delimiter +hi! link typescriptEnum Type +hi! link typescriptEnumKeyword Keyword +hi! link typescriptFuncComma Delimiter +hi! link typescriptFuncKeyword Keyword +hi! link typescriptFuncType DraculaOrangeItalic +hi! link typescriptFuncTypeArrow Operator +hi! link typescriptGlobal Type +hi! link typescriptGlobalMethod DraculaCyan +hi! link typescriptGlobalObjects Type +hi! link typescriptIdentifier DraculaPurpleItalic +hi! link typescriptInterfaceHeritage Type +hi! link typescriptInterfaceName Type +hi! link typescriptInterpolationDelimiter Keyword +hi! link typescriptKeywordOp Keyword +hi! link typescriptLogicSymbols Operator +hi! link typescriptMember Identifier +hi! link typescriptMemberOptionality Special +hi! link typescriptObjectColon Special +hi! link typescriptObjectLabel Identifier +hi! link typescriptObjectSpread Operator +hi! link typescriptOperator Operator +hi! link typescriptParamImpl DraculaOrangeItalic +hi! link typescriptParens Delimiter +hi! link typescriptPredefinedType Type +hi! link typescriptRestOrSpread Operator +hi! link typescriptTernaryOp Operator +hi! link typescriptTypeAnnotation Special +hi! link typescriptTypeCast Operator +hi! link typescriptTypeParameter DraculaOrangeItalic +hi! link typescriptTypeReference Type +hi! link typescriptUnaryOp Operator +hi! link typescriptVariable Keyword + +" }}} diff --git a/sources_non_forked/dracula/after/syntax/typescriptreact.vim b/sources_non_forked/dracula/after/syntax/typescriptreact.vim new file mode 100644 index 00000000..ec8062e9 --- /dev/null +++ b/sources_non_forked/dracula/after/syntax/typescriptreact.vim @@ -0,0 +1,22 @@ +if dracula#should_abort('typescriptreact', 'typescript.tsx') + finish +endif + +runtime! syntax/typescript.vim + +hi! link tsxAttrib DraculaGreenItalic +hi! link tsxEqual Operator +hi! link tsxIntrinsicTagName Keyword +hi! link tsxTagName Type + +" maxmellon/vim-jsx-pretty {{{ + +hi! link jsxTag Keyword +hi! link jsxTagName Keyword +hi! link jsxComponentName Type +hi! link jsxCloseTag Type +hi! link jsxAttrib DraculaGreenItalic +hi! link jsxCloseString Identifier +hi! link jsxOpenPunct Identifier + +" }}} diff --git a/sources_non_forked/dracula/after/syntax/vim.vim b/sources_non_forked/dracula/after/syntax/vim.vim new file mode 100644 index 00000000..a49a93a6 --- /dev/null +++ b/sources_non_forked/dracula/after/syntax/vim.vim @@ -0,0 +1,14 @@ +if dracula#should_abort('vim') + finish +endif + +hi! link vimAutoCmdSfxList Type +hi! link vimAutoEventList Type +hi! link vimEnvVar Constant +hi! link vimFunction Function +hi! link vimHiBang Keyword +hi! link vimOption Type +hi! link vimSetMod Keyword +hi! link vimSetSep Delimiter +hi! link vimUserAttrbCmpltFunc Function +hi! link vimUserFunc Function diff --git a/sources_non_forked/dracula/after/syntax/xml.vim b/sources_non_forked/dracula/after/syntax/xml.vim new file mode 100644 index 00000000..4b826983 --- /dev/null +++ b/sources_non_forked/dracula/after/syntax/xml.vim @@ -0,0 +1,13 @@ +if dracula#should_abort('xml') + finish +endif + +hi! link xmlAttrib DraculaGreenItalic +hi! link xmlEqual Operator +hi! link xmlTag Delimiter +hi! link xmlTagName Statement + +" Fixes missing highlight over end tags +syn region xmlTagName + \ matchgroup=xmlTag start=+"']\@=+ + \ matchgroup=xmlTag end=+>+ diff --git a/sources_non_forked/dracula/after/syntax/yaml.vim b/sources_non_forked/dracula/after/syntax/yaml.vim new file mode 100644 index 00000000..fedc41f5 --- /dev/null +++ b/sources_non_forked/dracula/after/syntax/yaml.vim @@ -0,0 +1,12 @@ +if dracula#should_abort('yaml') + finish +endif + +hi! link yamlAlias DraculaGreenItalicUnderline +hi! link yamlAnchor DraculaPinkItalic +hi! link yamlBlockMappingKey DraculaCyan +hi! link yamlFlowCollection DraculaPink +hi! link yamlFlowIndicator Delimiter +hi! link yamlNodeTag DraculaPink +hi! link yamlPlainScalar DraculaYellow + diff --git a/sources_non_forked/dracula/autoload/airline/themes/dracula.vim b/sources_non_forked/dracula/autoload/airline/themes/dracula.vim new file mode 100644 index 00000000..42172cad --- /dev/null +++ b/sources_non_forked/dracula/autoload/airline/themes/dracula.vim @@ -0,0 +1,160 @@ +" Dracula Airline Theme: {{{ +" +" Copyright 2016, All rights reserved +" +" Code licensed under the MIT license +" http://zenorocha.mit-license.org +" +" @author Extrante +" @author Zeno Rocha +"}}} +" Helpers: {{{ + +" Takes a foreground color name, background color name, and optionally one or +" more attr-list items as input, transforms it to the format accepted by +" airline#themes#generate_color_map and returns that value +func! s:clr(fg, bg, ...) + let l:fg = g:dracula#palette[a:fg] + let l:bg = g:dracula#palette[a:bg] + return [ l:fg[0], l:bg[0], l:fg[1], l:bg[1] ] + + \ filter(copy(a:000), 'type(v:val) == 1 && len(v:val) > 0') +endfunc + +" Takes three ['fg', 'bg'] color lists and optionally a dictionary of extra +" key-value pairs and returns the value generated by +" airline#themes#generate_color_map after optionally merging the dictionary of +" extra key-value pairs. +" +" a:a -> airline_a, airline_x +" a:b -> airline_b, airline_y +" a:c -> airline_c, airline_z +func! s:color_map(a, b, c, ...) + if a:0 == 0 + return call('airline#themes#generate_color_map', [call('s:clr', a:a), call('s:clr', a:b), call('s:clr', a:c)]) + else + return call('extend', [ call('airline#themes#generate_color_map', [call('s:clr', a:a), call('s:clr', a:b), call('s:clr', a:c)]) ] + a:000) + endif +endfunc + +"}}} + +let g:airline#themes#dracula#palette = { +\ 'normal': s:color_map( +\ ['bg', 'purple'], +\ ['fg', 'comment'], +\ ['fg', 'selection'], +\ { +\ 'airline_warning': s:clr('bg', 'orange'), +\ 'airline_error': s:clr('bg', 'red'), +\ }, +\ ), +\ 'normal_modified': s:color_map( +\ ['bg', 'purple'], +\ ['fg', 'comment'], +\ ['fg', 'bgdark'], +\ { +\ 'airline_warning': s:clr('bg', 'orange'), +\ 'airline_error': s:clr('bg', 'red'), +\ }, +\ ), +\ 'insert': s:color_map( +\ ['bg', 'green'], +\ ['fg', 'comment'], +\ ['fg', 'selection'], +\ { +\ 'airline_warning': s:clr('bg', 'orange'), +\ 'airline_error': s:clr('bg', 'red'), +\ }, +\ ), +\ 'insert_modified': s:color_map( +\ ['bg', 'green'], +\ ['fg', 'comment'], +\ ['fg', 'bgdark'], +\ { +\ 'airline_warning': s:clr('bg', 'orange'), +\ 'airline_error': s:clr('bg', 'red'), +\ }, +\ ), +\ 'replace': s:color_map( +\ ['bg', 'orange'], +\ ['fg', 'comment'], +\ ['fg', 'selection'], +\ { +\ 'airline_warning': s:clr('bg', 'orange'), +\ 'airline_error': s:clr('bg', 'red'), +\ }, +\ ), +\ 'replace_modified': s:color_map( +\ ['bg', 'orange'], +\ ['fg', 'comment'], +\ ['fg', 'bgdark'], +\ { +\ 'airline_warning': s:clr('bg', 'orange'), +\ 'airline_error': s:clr('bg', 'red'), +\ }, +\ ), +\ 'visual': s:color_map( +\ ['bg', 'yellow'], +\ ['fg', 'comment'], +\ ['fg', 'selection'], +\ { +\ 'airline_warning': s:clr('bg', 'orange'), +\ 'airline_error': s:clr('bg', 'red'), +\ }, +\ ), +\ 'visual_modified': s:color_map( +\ ['bg', 'yellow'], +\ ['fg', 'comment'], +\ ['fg', 'bgdark'], +\ { +\ 'airline_warning': s:clr('bg', 'orange'), +\ 'airline_error': s:clr('bg', 'red'), +\ }, +\ ), +\ 'inactive': s:color_map( +\ ['bg', 'comment'], +\ ['fg', 'bgdark'], +\ ['fg', 'selection'], +\ { +\ 'airline_warning': s:clr('bg', 'orange'), +\ 'airline_error': s:clr('bg', 'red'), +\ }, +\ ), +\ 'terminal': s:color_map( +\ ['bg', 'green'], +\ ['fg', 'comment'], +\ ['fg', 'selection'], +\ { +\ 'airline_term': s:clr('fg', 'selection'), +\ }, +\ ), +\} + +" Extensions: {{{ +" Tabline: {{{ +if get(g:, 'airline#extensions#tabline#enabled', 0) + let g:airline#themes#dracula#palette.tabline = { + \ 'airline_tabfill': s:clr('bg', 'bglight'), + \ + \ 'airline_tab': s:clr('comment', 'bg'), + \ 'airline_tabsel': s:clr('bg', 'purple'), + \ 'airline_tabmod': s:clr('green', 'bg'), + \ + \ 'airline_tab_right': s:clr('comment', 'bg'), + \ 'airline_tabsel_right': s:clr('fg', 'bg', ), + \ 'airline_tabmod_right': s:clr('green', 'bg'), + \} +endif +"}}} +" CtrlP: {{{2 +if exists('g:loaded_ctrlp') + let g:airline#themes#dracula#palette.ctrlp = airline#extensions#ctrlp#generate_color_map( + \ s:clr('fg', 'selection'), + \ s:clr('fg', 'comment'), + \ s:clr('fg', 'purple'), + \) +endif +"}}}2 +"}}} + +" vim: fdm=marker ts=2 sts=2 sw=2 fdl=0: diff --git a/sources_non_forked/dracula/autoload/dracula.vim b/sources_non_forked/dracula/autoload/dracula.vim new file mode 100644 index 00000000..23f96565 --- /dev/null +++ b/sources_non_forked/dracula/autoload/dracula.vim @@ -0,0 +1,57 @@ +" Palette: {{{ + +let g:dracula#palette = {} +let g:dracula#palette.fg = ['#F8F8F2', 253] + +let g:dracula#palette.bglighter = ['#424450', 238] +let g:dracula#palette.bglight = ['#343746', 237] +let g:dracula#palette.bg = ['#282A36', 236] +let g:dracula#palette.bgdark = ['#21222C', 235] +let g:dracula#palette.bgdarker = ['#191A21', 234] + +let g:dracula#palette.comment = ['#6272A4', 61] +let g:dracula#palette.selection = ['#44475A', 239] +let g:dracula#palette.subtle = ['#424450', 238] + +let g:dracula#palette.cyan = ['#8BE9FD', 117] +let g:dracula#palette.green = ['#50FA7B', 84] +let g:dracula#palette.orange = ['#FFB86C', 215] +let g:dracula#palette.pink = ['#FF79C6', 212] +let g:dracula#palette.purple = ['#BD93F9', 141] +let g:dracula#palette.red = ['#FF5555', 203] +let g:dracula#palette.yellow = ['#F1FA8C', 228] + +" +" ANSI +" +let g:dracula#palette.color_0 = '#21222C' +let g:dracula#palette.color_1 = '#FF5555' +let g:dracula#palette.color_2 = '#50FA7B' +let g:dracula#palette.color_3 = '#F1FA8C' +let g:dracula#palette.color_4 = '#BD93F9' +let g:dracula#palette.color_5 = '#FF79C6' +let g:dracula#palette.color_6 = '#8BE9FD' +let g:dracula#palette.color_7 = '#F8F8F2' +let g:dracula#palette.color_8 = '#6272A4' +let g:dracula#palette.color_9 = '#FF6E6E' +let g:dracula#palette.color_10 = '#69FF94' +let g:dracula#palette.color_11 = '#FFFFA5' +let g:dracula#palette.color_12 = '#D6ACFF' +let g:dracula#palette.color_13 = '#FF92DF' +let g:dracula#palette.color_14 = '#A4FFFF' +let g:dracula#palette.color_15 = '#FFFFFF' + +" }}} + +" Helper function that takes a variadic list of filetypes as args and returns +" whether or not the execution of the ftplugin should be aborted. +func! dracula#should_abort(...) + if ! exists('g:colors_name') || g:colors_name !=# 'dracula' + return 1 + elseif a:0 > 0 && (! exists('b:current_syntax') || index(a:000, b:current_syntax) == -1) + return 1 + endif + return 0 +endfunction + +" vim: fdm=marker ts=2 sts=2 sw=2 fdl=0: diff --git a/sources_non_forked/dracula/autoload/lightline/colorscheme/dracula.vim b/sources_non_forked/dracula/autoload/lightline/colorscheme/dracula.vim new file mode 100644 index 00000000..42ed79d3 --- /dev/null +++ b/sources_non_forked/dracula/autoload/lightline/colorscheme/dracula.vim @@ -0,0 +1,42 @@ +" ============================================================================= +" Filename: autoload/lightline/colorscheme/dracula.vim +" Author: adamalbrecht +" License: MIT License +" Last Change: 2018/04/11 +" ============================================================================= + +let s:black = g:dracula#palette.bg +let s:gray = g:dracula#palette.selection +let s:white = g:dracula#palette.fg +let s:darkblue = g:dracula#palette.comment +let s:cyan = g:dracula#palette.cyan +let s:green = g:dracula#palette.green +let s:orange = g:dracula#palette.orange +let s:purple = g:dracula#palette.purple +let s:red = g:dracula#palette.red +let s:yellow = g:dracula#palette.yellow + +if exists('g:lightline') + + let s:p = {'normal': {}, 'inactive': {}, 'insert': {}, 'replace': {}, 'visual': {}, 'tabline': {}} + let s:p.normal.left = [ [ s:black, s:purple ], [ s:cyan, s:gray ] ] + let s:p.normal.right = [ [ s:black, s:purple ], [ s:white, s:darkblue ] ] + let s:p.inactive.right = [ [ s:black, s:darkblue ], [ s:white, s:black ] ] + let s:p.inactive.left = [ [ s:cyan, s:black ], [ s:white, s:black ] ] + let s:p.insert.left = [ [ s:black, s:green ], [ s:cyan, s:gray ] ] + let s:p.replace.left = [ [ s:black, s:red ], [ s:cyan, s:gray ] ] + let s:p.visual.left = [ [ s:black, s:orange ], [ s:cyan, s:gray ] ] + let s:p.normal.middle = [ [ s:white, s:gray ] ] + let s:p.inactive.middle = [ [ s:white, s:gray ] ] + let s:p.tabline.left = [ [ s:darkblue, s:gray ] ] + let s:p.tabline.tabsel = [ [ s:cyan, s:black ] ] + let s:p.tabline.middle = [ [ s:darkblue, s:gray ] ] + let s:p.tabline.right = copy(s:p.normal.right) + let s:p.normal.error = [ [ s:red, s:black ] ] + let s:p.normal.warning = [ [ s:yellow, s:black ] ] + + let g:lightline#colorscheme#dracula#palette = lightline#colorscheme#flatten(s:p) + +endif + +" vim: fdm=marker ts=2 sts=2 sw=2 fdl=0: diff --git a/sources_non_forked/dracula/colors/dracula.vim b/sources_non_forked/dracula/colors/dracula.vim new file mode 100644 index 00000000..14f6542f --- /dev/null +++ b/sources_non_forked/dracula/colors/dracula.vim @@ -0,0 +1,319 @@ +" Dracula Theme: {{{ +" +" https://github.com/zenorocha/dracula-theme +" +" Copyright 2016, All rights reserved +" +" Code licensed under the MIT license +" http://zenorocha.mit-license.org +" +" @author Trevor Heins <@heinst> +" @author Éverton Ribeiro +" @author Derek Sifford +" @author Zeno Rocha +scriptencoding utf8 +" }}} + +" Configuration: {{{ + +if v:version > 580 + highlight clear + if exists('syntax_on') + syntax reset + endif +endif + +let g:colors_name = 'dracula' + +if !(has('termguicolors') && &termguicolors) && !has('gui_running') && &t_Co != 256 + finish +endif + +" Palette: {{{2 + +let s:fg = g:dracula#palette.fg + +let s:bglighter = g:dracula#palette.bglighter +let s:bglight = g:dracula#palette.bglight +let s:bg = g:dracula#palette.bg +let s:bgdark = g:dracula#palette.bgdark +let s:bgdarker = g:dracula#palette.bgdarker + +let s:comment = g:dracula#palette.comment +let s:selection = g:dracula#palette.selection +let s:subtle = g:dracula#palette.subtle + +let s:cyan = g:dracula#palette.cyan +let s:green = g:dracula#palette.green +let s:orange = g:dracula#palette.orange +let s:pink = g:dracula#palette.pink +let s:purple = g:dracula#palette.purple +let s:red = g:dracula#palette.red +let s:yellow = g:dracula#palette.yellow + +let s:none = ['NONE', 'NONE'] + +if has('nvim') + for s:i in range(16) + let g:terminal_color_{s:i} = g:dracula#palette['color_' . s:i] + endfor +endif + +if has('terminal') + let g:terminal_ansi_colors = [] + for s:i in range(16) + call add(g:terminal_ansi_colors, g:dracula#palette['color_' . s:i]) + endfor +endif + +" }}}2 +" User Configuration: {{{2 + +if !exists('g:dracula_bold') + let g:dracula_bold = 1 +endif + +if !exists('g:dracula_italic') + let g:dracula_italic = 1 +endif + +if !exists('g:dracula_underline') + let g:dracula_underline = 1 +endif + +if !exists('g:dracula_undercurl') + let g:dracula_undercurl = g:dracula_underline +endif + +if !exists('g:dracula_inverse') + let g:dracula_inverse = 1 +endif + +if !exists('g:dracula_colorterm') + let g:dracula_colorterm = 1 +endif + +"}}}2 +" Script Helpers: {{{2 + +let s:attrs = { + \ 'bold': g:dracula_bold == 1 ? 'bold' : 0, + \ 'italic': g:dracula_italic == 1 ? 'italic' : 0, + \ 'underline': g:dracula_underline == 1 ? 'underline' : 0, + \ 'undercurl': g:dracula_undercurl == 1 ? 'undercurl' : 0, + \ 'inverse': g:dracula_inverse == 1 ? 'inverse' : 0, + \} + +function! s:h(scope, fg, ...) " bg, attr_list, special + let l:fg = copy(a:fg) + let l:bg = get(a:, 1, ['NONE', 'NONE']) + + let l:attr_list = filter(get(a:, 2, ['NONE']), 'type(v:val) == 1') + let l:attrs = len(l:attr_list) > 0 ? join(l:attr_list, ',') : 'NONE' + + " Falls back to coloring foreground group on terminals because + " nearly all do not support undercurl + let l:special = get(a:, 3, ['NONE', 'NONE']) + if l:special[0] !=# 'NONE' && l:fg[0] ==# 'NONE' && !has('gui_running') + let l:fg[0] = l:special[0] + let l:fg[1] = l:special[1] + endif + + let l:hl_string = [ + \ 'highlight', a:scope, + \ 'guifg=' . l:fg[0], 'ctermfg=' . l:fg[1], + \ 'guibg=' . l:bg[0], 'ctermbg=' . l:bg[1], + \ 'gui=' . l:attrs, 'cterm=' . l:attrs, + \ 'guisp=' . l:special[0], + \] + + execute join(l:hl_string, ' ') +endfunction + +"}}}2 +" Dracula Highlight Groups: {{{2 + +call s:h('DraculaBgLight', s:none, s:bglight) +call s:h('DraculaBgLighter', s:none, s:bglighter) +call s:h('DraculaBgDark', s:none, s:bgdark) +call s:h('DraculaBgDarker', s:none, s:bgdarker) + +call s:h('DraculaFg', s:fg) +call s:h('DraculaFgUnderline', s:fg, s:none, [s:attrs.underline]) +call s:h('DraculaFgBold', s:fg, s:none, [s:attrs.bold]) + +call s:h('DraculaComment', s:comment) +call s:h('DraculaCommentBold', s:comment, s:none, [s:attrs.bold]) + +call s:h('DraculaSelection', s:none, s:selection) + +call s:h('DraculaSubtle', s:subtle) + +call s:h('DraculaCyan', s:cyan) +call s:h('DraculaCyanItalic', s:cyan, s:none, [s:attrs.italic]) + +call s:h('DraculaGreen', s:green) +call s:h('DraculaGreenBold', s:green, s:none, [s:attrs.bold]) +call s:h('DraculaGreenItalic', s:green, s:none, [s:attrs.italic]) +call s:h('DraculaGreenItalicUnderline', s:green, s:none, [s:attrs.italic, s:attrs.underline]) + +call s:h('DraculaOrange', s:orange) +call s:h('DraculaOrangeBold', s:orange, s:none, [s:attrs.bold]) +call s:h('DraculaOrangeItalic', s:orange, s:none, [s:attrs.italic]) +call s:h('DraculaOrangeBoldItalic', s:orange, s:none, [s:attrs.bold, s:attrs.italic]) +call s:h('DraculaOrangeInverse', s:bg, s:orange) + +call s:h('DraculaPink', s:pink) +call s:h('DraculaPinkItalic', s:pink, s:none, [s:attrs.italic]) + +call s:h('DraculaPurple', s:purple) +call s:h('DraculaPurpleBold', s:purple, s:none, [s:attrs.bold]) +call s:h('DraculaPurpleItalic', s:purple, s:none, [s:attrs.italic]) + +call s:h('DraculaRed', s:red) +call s:h('DraculaRedInverse', s:fg, s:red) + +call s:h('DraculaYellow', s:yellow) +call s:h('DraculaYellowItalic', s:yellow, s:none, [s:attrs.italic]) + +call s:h('DraculaError', s:red, s:none, [], s:red) + +call s:h('DraculaErrorLine', s:none, s:none, [s:attrs.undercurl], s:red) +call s:h('DraculaWarnLine', s:none, s:none, [s:attrs.undercurl], s:orange) +call s:h('DraculaInfoLine', s:none, s:none, [s:attrs.undercurl], s:cyan) + +call s:h('DraculaTodo', s:cyan, s:none, [s:attrs.bold, s:attrs.inverse]) +call s:h('DraculaSearch', s:green, s:none, [s:attrs.inverse]) +call s:h('DraculaBoundary', s:comment, s:bgdark) +call s:h('DraculaLink', s:cyan, s:none, [s:attrs.underline]) + +call s:h('DraculaDiffChange', s:orange, s:none) +call s:h('DraculaDiffText', s:bg, s:orange) +call s:h('DraculaDiffDelete', s:red, s:bgdark) + +" }}}2 + +" }}} +" User Interface: {{{ + +set background=dark + +" Required as some plugins will overwrite +call s:h('Normal', s:fg, g:dracula_colorterm || has('gui_running') ? s:bg : s:none ) +call s:h('StatusLine', s:none, s:bglighter, [s:attrs.bold]) +call s:h('StatusLineNC', s:none, s:bglight) +call s:h('StatusLineTerm', s:none, s:bglighter, [s:attrs.bold]) +call s:h('StatusLineTermNC', s:none, s:bglight) +call s:h('WildMenu', s:bg, s:purple, [s:attrs.bold]) +call s:h('CursorLine', s:none, s:subtle) + +hi! link ColorColumn DraculaBgDark +hi! link CursorColumn CursorLine +hi! link CursorLineNr DraculaYellow +hi! link DiffAdd DraculaGreen +hi! link DiffAdded DiffAdd +hi! link DiffChange DraculaDiffChange +hi! link DiffDelete DraculaDiffDelete +hi! link DiffRemoved DiffDelete +hi! link DiffText DraculaDiffText +hi! link Directory DraculaPurpleBold +hi! link ErrorMsg DraculaRedInverse +hi! link FoldColumn DraculaSubtle +hi! link Folded DraculaBoundary +hi! link IncSearch DraculaOrangeInverse +call s:h('LineNr', s:comment) +hi! link MoreMsg DraculaFgBold +hi! link NonText DraculaSubtle +hi! link Pmenu DraculaBgDark +hi! link PmenuSbar DraculaBgDark +hi! link PmenuSel DraculaSelection +hi! link PmenuThumb DraculaSelection +hi! link Question DraculaFgBold +hi! link Search DraculaSearch +call s:h('SignColumn', s:comment) +hi! link TabLine DraculaBoundary +hi! link TabLineFill DraculaBgDarker +hi! link TabLineSel Normal +hi! link Title DraculaGreenBold +hi! link VertSplit DraculaBoundary +hi! link Visual DraculaSelection +hi! link VisualNOS Visual +hi! link WarningMsg DraculaOrangeInverse + +" }}} +" Syntax: {{{ + +" Required as some plugins will overwrite +call s:h('MatchParen', s:green, s:none, [s:attrs.underline]) +call s:h('Conceal', s:cyan, s:none) + +" Neovim uses SpecialKey for escape characters only. Vim uses it for that, plus whitespace. +if has('nvim') + hi! link SpecialKey DraculaRed + hi! link LspReferenceText DraculaSelection + hi! link LspReferenceRead DraculaSelection + hi! link LspReferenceWrite DraculaSelection + hi! link LspDiagnosticsDefaultInformation DraculaCyan + hi! link LspDiagnosticsDefaultHint DraculaCyan + hi! link LspDiagnosticsDefaultError DraculaError + hi! link LspDiagnosticsDefaultWarning DraculaOrange + hi! link LspDiagnosticsUnderlineError DraculaErrorLine + hi! link LspDiagnosticsUnderlineHint DraculaInfoLine + hi! link LspDiagnosticsUnderlineInformation DraculaInfoLine + hi! link LspDiagnosticsUnderlineWarning DraculaWarnLine +else + hi! link SpecialKey DraculaPink +endif + +hi! link Comment DraculaComment +hi! link Underlined DraculaFgUnderline +hi! link Todo DraculaTodo + +hi! link Error DraculaError +hi! link SpellBad DraculaErrorLine +hi! link SpellLocal DraculaWarnLine +hi! link SpellCap DraculaInfoLine +hi! link SpellRare DraculaInfoLine + +hi! link Constant DraculaPurple +hi! link String DraculaYellow +hi! link Character DraculaPink +hi! link Number Constant +hi! link Boolean Constant +hi! link Float Constant + +hi! link Identifier DraculaFg +hi! link Function DraculaGreen + +hi! link Statement DraculaPink +hi! link Conditional DraculaPink +hi! link Repeat DraculaPink +hi! link Label DraculaPink +hi! link Operator DraculaPink +hi! link Keyword DraculaPink +hi! link Exception DraculaPink + +hi! link PreProc DraculaPink +hi! link Include DraculaPink +hi! link Define DraculaPink +hi! link Macro DraculaPink +hi! link PreCondit DraculaPink +hi! link StorageClass DraculaPink +hi! link Structure DraculaPink +hi! link Typedef DraculaPink + +hi! link Type DraculaCyanItalic + +hi! link Delimiter DraculaFg + +hi! link Special DraculaPink +hi! link SpecialComment DraculaCyanItalic +hi! link Tag DraculaCyan +hi! link helpHyperTextJump DraculaLink +hi! link helpCommand DraculaPurple +hi! link helpExample DraculaGreen +hi! link helpBacktick Special + +"}}} + +" vim: fdm=marker ts=2 sts=2 sw=2 fdl=0 et: diff --git a/sources_non_forked/dracula/doc/dracula.txt b/sources_non_forked/dracula/doc/dracula.txt new file mode 100644 index 00000000..b60abb45 --- /dev/null +++ b/sources_non_forked/dracula/doc/dracula.txt @@ -0,0 +1,157 @@ +*dracula.txt* For Vim version 8 Last change: 2018 May 08 +*dracula* *vim-dracula* + + |\ ,, ~ + \\ _ || _ ~ + / \\ ,._-_ < \, _-_ \\ \\ || < \, ~ + || || || /-|| || || || || /-|| ~ + || || || (( || || || || || (( || ~ + \\/ \\, \/\\ \\,/ \\/\\ \\ \/\\ ~ + + A dark theme for vim + +============================================================================== +CONTENTS *dracula-contents* + + 1. Intro ................................................... |dracula-intro| + 2. Usage ................................................... |dracula-usage| + 3. Configuration ................................... |dracula-configuration| + 4. Personal Customization .......................... |dracula-customization| + 5. License ............................................... |dracula-license| + 6. Bugs ..................................................... |dracula-bugs| + 7. Contributing ..................................... |dracula-contributing| + 8. Credits ............................................... |dracula-credits| + +============================================================================== +INTRO *dracula-intro* + +Dracula is a vim plugin that contains + + - a dark colorscheme for vim + - a similarly-themed colorscheme for the vim plugin airline + (https://github.com/vim-airline/vim-airline) + +============================================================================== +USAGE *dracula-usage* + +Install it with your favorite plugin manager, and then > + colorscheme dracula +in your vimrc! See also |dracula_runtimepath|. + +If you are an airline user, you can also do > + let g:airline_theme='dracula' +to have airline use Dracula. + + *dracula_runtimepath* + +Note that dracula must be in your 'runtimepath' for this command to work +properly: Version 2.0 introduced autoload functionality for part of the +plugin, which doesn't work without 'runtimepath' properly set. + +For users of Vim 8's |packages| feature, it suffices to put > + packadd! dracula + colorscheme dracula +in your vimrc. {name} Should be replaced by the directory you put the code in. +For example, if you use ~/.vim/pack/themes/start/my-dracula-theme, you would +do > + packadd! my-dracula-theme + +For users of other plugin managers, consult your documentation +to make sure you put dracula on the 'runtimepath' before loading it. + +============================================================================== +CONFIGURATION *dracula-configuration* + +There are a couple of variables used by Dracula that you might want to adjust +depending on your terminal's capabilities. + +Default values are shown. + +------------------------------------------------------------------------------ +In the following section, `1` signifies `on` and `0` signifies `off`. + +* *g:dracula_bold* +Include bold attributes in highlighting > + let g:dracula_bold = 1 + +* *g:dracula_italic* +Include italic attributes in highlighting > + let g:dracula_italic = 1 + +* *g:dracula_underline* +Include underline attributes in highlighting > + let g:dracula_underline = 1 + +* *g:dracula_undercurl* +Include undercurl attributes in highlighting (only if underline enabled) > + let g:dracula_undercurl = 1 + +* *g:dracula_inverse* +Include inverse attributes in highlighting > + let g:dracula_inverse = 1 + +* *g:dracula_colorterm* +Include background fill colors > + let g:dracula_colorterm = 1 + +============================================================================== +CUSTOMIZATION *dracula-customization* + +Like all colorschemes, Dracula is easy to customize with |autocmd|. Make use +of the |ColorScheme| event as in the following examples. + +It would be a good idea to put all of your personal changes in an |augroup|, +which you can do with the following code: > + augroup dracula_customization + au! + " autocmds... + augroup END +> + +- To add underline styling to |hl-CursorLine|, you can use the following: > + autocmd ColorScheme dracula hi CursorLine cterm=underline term=underline +< +============================================================================== +LICENSE *dracula-license* + +MIT License. Copyright © 2016 Dracula Theme. +Full text available at +https://github.com/dracula/vim/blob/master/LICENSE + +============================================================================== +BUGS *dracula-bugs* + +At the time of this writing, no major bugs have been found. + +If you find one and wish to report it, you can do so at +https://github.com/dracula/vim/issues + +============================================================================== +CONTRIBUTING *dracula-contributing* + +Want to submit a new feature, bugfix, or hack on Dracula? +Submit pull requests to +https://github.com/dracula/vim/pulls + +Existing code determines style guidelines. + +============================================================================== +CREDITS *dracula-credits* + +Proudly built by the Dracula Theme organization +https://github.com/dracula + +Dracula for other applications available at +https://draculatheme.com + +Further information available at +https://draculatheme.com/vim + +Maintained by: +- Derek S. (https://github.com/dsifford) +- D. Ben Knoble (https://github.com/benknoble) + +Git repository: +https://github.com/dracula/vim + + vim:tw=78:ts=8:ft=help:norl: diff --git a/sources_non_forked/dracula/screenshot.png b/sources_non_forked/dracula/screenshot.png new file mode 100644 index 00000000..cf0a36e1 Binary files /dev/null and b/sources_non_forked/dracula/screenshot.png differ diff --git a/sources_non_forked/editorconfig-vim/.appveyor.yml b/sources_non_forked/editorconfig-vim/.appveyor.yml new file mode 100644 index 00000000..630fc2f4 --- /dev/null +++ b/sources_non_forked/editorconfig-vim/.appveyor.yml @@ -0,0 +1,107 @@ +# appveyor.yml for editorconfig-vim. Currently only tests the core. +# Modified from https://github.com/ppalaga/ec4j/commit/1c849658fb189cd95bc41af95acd43b4f0d75a48 +# +# Copyright (c) 2017--2019 Angelo Zerr and other contributors as +# indicated by the @author tags. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# @author Chris White (cxw42) - Adapted to editorconfig-vim + +# === When to build === +# See https://www.appveyor.com/docs/how-to/filtering-commits/ + +skip_commits: + message: /\[minor\]/ + files: + - '**/*.md' + +# === Build matrix === + +# Win is default; Ubuntu is override. See +# https://www.appveyor.com/blog/2018/04/25/specialized-build-matrix-configuration-in-appveyor/ +image: + - Visual Studio 2013 + - Ubuntu1604 + +# === How to build === + +cache: + - C:\vim -> .appveyor.yml, tests\fetch-vim.bat + +environment: + VIM_EXE: C:\vim\vim\vim80\vim.exe + +for: + # Don't run the Windows build if the commit message includes "[ci-linux]" + - + matrix: + only: + - image: Visual Studio 2013 + skip_commits: + message: /\[ci-linux\]/ + + # Platform-specific configuration for Ubuntu + - + matrix: + only: + - image: Ubuntu1604 + # $APPVEYOR_BUILD_FOLDER isn't expanded in the environment section + # here, so I can't set $VIM_EXE the way I want to. Instead, + # I set $VIM_EXE in the sh-specific install steps below. + environment: + VIM_EXE: UNDEFINED + cache: + - $APPVEYOR_BUILD_FOLDER/vim -> .appveyor.yml, tests/fetch-vim.sh + + # Plus, don't run Ubuntu if the commit message includes [ci-win] + skip_commits: + message: /\[ci-win\]/ + +install: + # Ubuntu-specific setup. These carry forward to the build_script. + - sh: export VIM_EXE="$APPVEYOR_BUILD_FOLDER/vim/bin/vim" + - sh: export PATH="$PATH":$APPVEYOR_BUILD_FOLDER/vim/bin + - sh: echo "$VIM_EXE , $PATH" + + # Cross-platform - test the core + - cmake --version + - git submodule update --init --recursive + - cmd: tests\fetch-vim + - sh: tests/fetch-vim.sh + +build_script: + # Build the core tests + - cd tests + - cd core + - mkdir build + - cd build + - cmake .. + +# Note on multicore testing: +# Two cores are available per https://help.appveyor.com/discussions/questions/11179-how-many-cores-and-threads-can-be-used-in-free-appveyor-build . +# However, using -j2 seems to make each job take much longer. + +test_script: + # Run the core tests + - ctest . --output-on-failure -C Debug + + # CTestCustom specifies skipping UTF-8 tests on Windows. + - cmd: echo "Reminder - did not try UTF-8" + - sh: echo "Reminder - tried UTF-8" + +on_failure: + - echo "failed" + - cmd: type tests\core\build\Testing\Temporary\LastTest.log + - sh: cat tests/core/build/Testing/Temporary/LastTest.log + diff --git a/sources_non_forked/editorconfig-vim/.editorconfig b/sources_non_forked/editorconfig-vim/.editorconfig new file mode 100644 index 00000000..7eed9e11 --- /dev/null +++ b/sources_non_forked/editorconfig-vim/.editorconfig @@ -0,0 +1,27 @@ +root = true + +[*] +end_of_line = lf +charset = utf-8 +max_line_length = 80 + +[*.{vim,sh}] +indent_style = space +indent_size = 4 +insert_final_newline = true +trim_trailing_whitespace = true +max_line_length = 80 + +[*.rb] +indent_style = space +indent_size = 2 +insert_final_newline = true +trim_trailing_whitespace = true +max_line_length = 120 + +[*.yml] +indent_style = space +indent_size = 2 + +[*.{bat,vbs,ps1}] +end_of_line = CRLF diff --git a/sources_non_forked/editorconfig-vim/.gitignore b/sources_non_forked/editorconfig-vim/.gitignore new file mode 100644 index 00000000..1d86f15e --- /dev/null +++ b/sources_non_forked/editorconfig-vim/.gitignore @@ -0,0 +1,8 @@ +tags +tests/**/build +tests/**/.bundle + +# Editor backup files +*.swp +*~ +~* diff --git a/sources_non_forked/editorconfig-vim/.gitmodules b/sources_non_forked/editorconfig-vim/.gitmodules new file mode 100644 index 00000000..8cf01bc4 --- /dev/null +++ b/sources_non_forked/editorconfig-vim/.gitmodules @@ -0,0 +1,6 @@ +[submodule "plugin_tests"] + path = tests/plugin/spec/plugin_tests + url = https://github.com/editorconfig/editorconfig-plugin-tests.git +[submodule "core_tests"] + path = tests/core/tests + url = https://github.com/editorconfig/editorconfig-core-test.git diff --git a/sources_non_forked/editorconfig-vim/.travis.yml b/sources_non_forked/editorconfig-vim/.travis.yml new file mode 100644 index 00000000..1eaad3b3 --- /dev/null +++ b/sources_non_forked/editorconfig-vim/.travis.yml @@ -0,0 +1,30 @@ +# Make sure xvfb works - https://docs.travis-ci.com/user/gui-and-headless-browsers/#using-xvfb-directly +dist: trusty + +matrix: + include: + - name: "plugin" + env: TEST_WHICH=plugin + language: ruby + rvm: + - 2.2.4 + gemfile: tests/plugin/Gemfile + - name: "core" + env: TEST_WHICH=core + +addons: + apt: + packages: + - vim-gtk + +before_script: + - "export DISPLAY=:99.0" + - "sh -e /etc/init.d/xvfb start" + +script: + ./tests/travis-test.sh + +notifications: + email: + on_success: change + on_failure: always diff --git a/sources_non_forked/editorconfig-vim/CONTRIBUTORS b/sources_non_forked/editorconfig-vim/CONTRIBUTORS new file mode 100644 index 00000000..b799668c --- /dev/null +++ b/sources_non_forked/editorconfig-vim/CONTRIBUTORS @@ -0,0 +1,6 @@ +Contributors to the EditorConfig Vim Plugin: + +Hong Xu +Trey Hunner +Kent Frazier +Chris White diff --git a/sources_non_forked/editorconfig-vim/LICENSE b/sources_non_forked/editorconfig-vim/LICENSE new file mode 100644 index 00000000..ed9286e0 --- /dev/null +++ b/sources_non_forked/editorconfig-vim/LICENSE @@ -0,0 +1,26 @@ +Unless otherwise stated, all files are distributed under the Simplified BSD +license included below. + +Copyright (c) 2011-2019 EditorConfig Team +All rights reserved. + +Redistribution and use in source and binary forms, with or without +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 COPYRIGHT HOLDER 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. diff --git a/sources_non_forked/editorconfig-vim/LICENSE.PSF b/sources_non_forked/editorconfig-vim/LICENSE.PSF new file mode 100644 index 00000000..36eb8e0d --- /dev/null +++ b/sources_non_forked/editorconfig-vim/LICENSE.PSF @@ -0,0 +1,53 @@ +Some code in editorconfig-vim is derived from code licensed under the +PSF license. The following is the text of that license, retrieved 2019-05-05 +from https://docs.python.org/2.6/license.html#terms-and-conditions-for-accessing-or-otherwise-using-python + +PSF LICENSE AGREEMENT FOR PYTHON 2.6.9 + +1. This LICENSE AGREEMENT is between the Python Software Foundation +(``PSF''), and the Individual or Organization (``Licensee'') accessing and +otherwise using Python 2.6.9 software in source or binary form and its +associated documentation. + +2. Subject to the terms and conditions of this License Agreement, PSF +hereby grants Licensee a nonexclusive, royalty-free, world-wide +license to reproduce, analyze, test, perform and/or display publicly, +prepare derivative works, distribute, and otherwise use Python 2.6.9 +alone or in any derivative version, provided, however, that PSF's +License Agreement and PSF's notice of copyright, i.e., ``Copyright (c) +2001-2010 Python Software Foundation; All Rights Reserved'' are +retained in Python 2.6.9 alone or in any derivative version prepared +by Licensee. + +3. In the event Licensee prepares a derivative work that is based on +or incorporates Python 2.6.9 or any part thereof, and wants to make +the derivative work available to others as provided herein, then +Licensee hereby agrees to include in any such work a brief summary of +the changes made to Python 2.6.9. + +4. PSF is making Python 2.6.9 available to Licensee on an ``AS IS'' +basis. PSF MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED. +BY WAY OF EXAMPLE, BUT NOT LIMITATION, PSF MAKES NO AND DISCLAIMS ANY +REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS FOR ANY +PARTICULAR PURPOSE OR THAT THE USE OF PYTHON 2.6.9 WILL NOT INFRINGE +ANY THIRD PARTY RIGHTS. + +5. PSF SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF PYTHON +2.6.9 FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS AS +A RESULT OF MODIFYING, DISTRIBUTING, OR OTHERWISE USING PYTHON 2.6.9, +OR ANY DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF. + +6. This License Agreement will automatically terminate upon a material +breach of its terms and conditions. + +7. Nothing in this License Agreement shall be deemed to create any +relationship of agency, partnership, or joint venture between PSF and +Licensee. This License Agreement does not grant permission to use PSF +trademarks or trade name in a trademark sense to endorse or promote +products or services of Licensee, or any third party. + +8. By copying, installing or otherwise using Python 2.6.9, Licensee +agrees to be bound by the terms and conditions of this License +Agreement. + +# vi: set ft=: diff --git a/sources_non_forked/editorconfig-vim/README.md b/sources_non_forked/editorconfig-vim/README.md new file mode 100644 index 00000000..248d315e --- /dev/null +++ b/sources_non_forked/editorconfig-vim/README.md @@ -0,0 +1,148 @@ +# EditorConfig Vim Plugin + +[![Travis Build Status](https://img.shields.io/travis/cxw42/editorconfig-vim.svg?logo=travis)](https://travis-ci.org/editorconfig/editorconfig-vim) +[![Appveyor Build Status](https://img.shields.io/appveyor/ci/cxw42/editorconfig-vim.svg?logo=appveyor)](https://ci.appveyor.com/project/cxw42/editorconfig-vim) + +This is an [EditorConfig][] plugin for Vim. This plugin can be found on both +[GitHub][] and [Vim online][]. + +## Installation + +To install this plugin, you can use one of the following ways: + +### Install with the archive + +Download the [archive][] and extract it into your Vim runtime directory +(`~/.vim` on UNIX/Linux and `$VIM_INSTALLATION_FOLDER\vimfiles` on windows). +You should have 3 sub-directories in this runtime directory now: "autoload", +"doc" and "plugin". + +### Install as Vim8 plugin + +Install as a Vim 8 plugin. Note `local` can be any name, but some path +element must be present. On Windows, instead of `~/.vim` use +`$VIM_INSTALLATION_FOLDER\vimfiles`. +```shell +mkdir -p ~/.vim/pack/local/start +cd ~/.vim/pack/local/start +git clone https://github.com/editorconfig/editorconfig-vim.git +``` + +### Install with [pathogen][] + +Use pathogen (the git repository of this plugin is +https://github.com/editorconfig/editorconfig-vim.git) + +### Install with [Vundle][] + +Use Vundle by adding to your `.vimrc` Vundle plugins section: + +```viml +Plugin 'editorconfig/editorconfig-vim' +``` + +Then call `:PluginInstall`. + +### Install with [vim-plug][] + +Use vim-plug by adding to your `.vimrc` in your plugin section: + +```viml +Plug 'editorconfig/editorconfig-vim' +``` + +Source your `.vimrc` by calling `:source $MYVIMRC`. + +Then call `:PlugInstall`. + +### No external editorconfig core library is required + +Previous versions of this plugin also required a Python "core". +The core included the code to parse `.editorconfig` files. +This plugin **includes** the core, so you don't need to download the +core separately. + +## Supported properties + +The EditorConfig Vim plugin supports the following EditorConfig [properties][]: + +* `indent_style` +* `indent_size` +* `tab_width` +* `end_of_line` +* `charset` +* `insert_final_newline` (Feature `+fixendofline`, available on Vim 7.4.785+, + or [PreserveNoEOL][] is required for this property) +* `trim_trailing_whitespace` +* `max_line_length` +* `root` (only used by EditorConfig core) + +## Selected Options + +The supported options are documented in [editorconfig.txt][] +and can be viewed by executing the following: `:help editorconfig`. You may +need to execute `:helptags ALL` so that Vim is aware of editorconfig.txt. + +### Excluded patterns + +To ensure that this plugin works well with [Tim Pope's fugitive][], use the +following patterns array: + +```viml +let g:EditorConfig_exclude_patterns = ['fugitive://.*'] +``` + +If you wanted to avoid loading EditorConfig for any remote files over ssh: + +```viml +let g:EditorConfig_exclude_patterns = ['scp://.*'] +``` + +Of course these two items could be combined into the following: + +```viml +let g:EditorConfig_exclude_patterns = ['fugitive://.*', 'scp://.*'] +``` + +### Disable for a specific filetype + +You can disable this plugin for a specific buffer by setting +`b:EditorConfig_disable`. Therefore, you can disable the +plugin for all buffers of a specific filetype. For example, to disable +EditorConfig for all git commit messages (filetype `gitcommit`): + +```viml +au FileType gitcommit let b:EditorConfig_disable = 1 +``` + +### Disable rules + +In very rare cases, +you might need to override some project-specific EditorConfig rules in global +or local vimrc in some cases, e.g., to resolve conflicts of trailing whitespace +trimming and buffer autosaving. This is not recommended, but you can: + +```viml +let g:EditorConfig_disable_rules = ['trim_trailing_whitespace'] +``` + +You are able to disable any supported EditorConfig properties. + +## Bugs and Feature Requests + +Feel free to submit bugs, feature requests, and other issues to the +[issue tracker][]. Be sure you have read the [contribution guidelines][]! + +[EditorConfig]: http://editorconfig.org +[GitHub]: https://github.com/editorconfig/editorconfig-vim +[PreserveNoEOL]: http://www.vim.org/scripts/script.php?script_id=4550 +[Tim Pope's fugitive]: https://github.com/tpope/vim-fugitive +[Vim online]: http://www.vim.org/scripts/script.php?script_id=3934 +[Vundle]: https://github.com/gmarik/Vundle.vim +[archive]: https://github.com/editorconfig/editorconfig-vim/archive/master.zip +[contribution guidelines]: https://github.com/editorconfig/editorconfig/blob/master/CONTRIBUTING.md#submitting-an-issue +[issue tracker]: https://github.com/editorconfig/editorconfig-vim/issues +[pathogen]: https://github.com/tpope/vim-pathogen +[properties]: http://github.com/editorconfig/editorconfig/wiki/EditorConfig-Properties +[editorconfig.txt]: https://github.com/editorconfig/editorconfig-vim/blob/master/doc/editorconfig.txt +[vim-plug]: https://github.com/junegunn/vim-plug diff --git a/sources_non_forked/editorconfig-vim/autoload/editorconfig.vim b/sources_non_forked/editorconfig-vim/autoload/editorconfig.vim new file mode 100644 index 00000000..1f61a330 --- /dev/null +++ b/sources_non_forked/editorconfig-vim/autoload/editorconfig.vim @@ -0,0 +1,60 @@ +" autoload/editorconfig.vim: EditorConfig native Vimscript plugin +" Copyright (c) 2011-2019 EditorConfig Team +" All rights reserved. +" +" Redistribution and use in source and binary forms, with or without +" 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 COPYRIGHT HOLDER 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. +" + +if v:version < 700 + finish +endif + +let s:saved_cpo = &cpo +set cpo&vim + +" {{{1 variables +let s:hook_list = [] + +function! editorconfig#AddNewHook(func) " {{{1 + " Add a new hook + + call add(s:hook_list, a:func) +endfunction + +function! editorconfig#ApplyHooks(config) abort " {{{1 + " apply hooks + + for Hook in s:hook_list + let l:hook_ret = Hook(a:config) + + if type(l:hook_ret) != type(0) && l:hook_ret != 0 + " TODO print some debug info here + endif + endfor +endfunction + +" }}} + +let &cpo = s:saved_cpo +unlet! s:saved_cpo + +" vim: fdm=marker fdc=3 diff --git a/sources_non_forked/editorconfig-vim/autoload/editorconfig_core.vim b/sources_non_forked/editorconfig-vim/autoload/editorconfig_core.vim new file mode 100644 index 00000000..6885e17c --- /dev/null +++ b/sources_non_forked/editorconfig-vim/autoload/editorconfig_core.vim @@ -0,0 +1,147 @@ +" autoload/editorconfig_core.vim: top-level functions for +" editorconfig-core-vimscript and editorconfig-vim. + +" Copyright (c) 2018-2020 EditorConfig Team, including Chris White {{{1 +" All rights reserved. +" +" Redistribution and use in source and binary forms, with or without +" 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 COPYRIGHT HOLDER 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. }}}1 + +let s:saved_cpo = &cpo +set cpo&vim + +" Variables {{{1 + +" Note: we create this variable in every script that accesses it. Normally, I +" would put this in plugin/editorconfig.vim. However, in some of my tests, +" the command-line testing environment did not load plugin/* in the normal +" way. Therefore, I do the check everywhere so I don't have to special-case +" the command line. + +if !exists('g:editorconfig_core_vimscript_debug') + let g:editorconfig_core_vimscript_debug = 0 +endif +" }}}1 + +" The latest version of the specification that we support. +" See discussion at https://github.com/editorconfig/editorconfig/issues/395 +function! editorconfig_core#version() + return [0,13,0] +endfunction + +" === CLI =============================================================== {{{1 + +" For use from the command line. Output settings for in_name to +" the buffer named out_name. If an optional argument is provided, it is the +" name of the config file to use (default '.editorconfig'). +" TODO support multiple files +" +" filename (if any) +" @param names {Dictionary} The names of the files to use for this run +" - output [required] Where the editorconfig settings should be written +" - target [required] A string or list of strings to process. Each +" must be a full path. +" - dump [optional] If present, write debug info to this file +" @param job {Dictionary} What to do - same format as the input of +" editorconfig_core#handler#get_configurations(), +" except without the target member. + +function! editorconfig_core#currbuf_cli(names, job) " out_name, in_name, ... + let l:output = [] + + " Preprocess the job + let l:job = deepcopy(a:job) + + if has_key(l:job, 'version') " string to list + let l:ver = split(editorconfig_core#util#strip(l:job.version), '\v\.') + for l:idx in range(len(l:ver)) + let l:ver[l:idx] = str2nr(l:ver[l:idx]) + endfor + + let l:job.version = l:ver + endif + + " TODO provide version output from here instead of the shell script +" if string(a:names) ==? 'version' +" return +" endif +" + if type(a:names) != type({}) || type(a:job) != type({}) + throw 'Need two Dictionary arguments' + endif + + if has_key(a:names, 'dump') + execute 'redir! > ' . fnameescape(a:names.dump) + echom 'Names: ' . string(a:names) + echom 'Job: ' . string(l:job) + let g:editorconfig_core_vimscript_debug = 1 + endif + + if type(a:names['target']) == type([]) + let l:targets = a:names.target + else + let l:targets = [a:names.target] + endif + + for l:target in l:targets + + " Pre-process quoting weirdness so we are more flexible in the face + " of CMake+CTest+BAT+Powershell quoting. + + " Permit wrapping in double-quotes + let l:target = substitute(l:target, '\v^"(.*)"$', '\1', '') + + " Permit empty ('') entries in l:targets + if strlen(l:target)<1 + continue + endif + + if has_key(a:names, 'dump') + echom 'Trying: ' . string(l:target) + endif + + let l:job.target = l:target + let l:options = editorconfig_core#handler#get_configurations(l:job) + + if has_key(a:names, 'dump') + echom 'editorconfig_core#currbuf_cli result: ' . string(l:options) + endif + + if len(l:targets) > 1 + let l:output += [ '[' . l:target . ']' ] + endif + + for [ l:key, l:value ] in items(l:options) + let l:output += [ l:key . '=' . l:value ] + endfor + + endfor "foreach target + + " Write the output file + call writefile(l:output, a:names.output) +endfunction "editorconfig_core#currbuf_cli + +" }}}1 + +let &cpo = s:saved_cpo +unlet! s:saved_cpo + +" vi: set fdm=marker fo-=ro: diff --git a/sources_non_forked/editorconfig-vim/autoload/editorconfig_core/fnmatch.vim b/sources_non_forked/editorconfig-vim/autoload/editorconfig_core/fnmatch.vim new file mode 100644 index 00000000..6f60db5d --- /dev/null +++ b/sources_non_forked/editorconfig-vim/autoload/editorconfig_core/fnmatch.vim @@ -0,0 +1,465 @@ +" autoload/editorconfig_core/fnmatch.vim: Globbing for +" editorconfig-vim. Ported from the Python core's fnmatch.py. + +" Copyright (c) 2012-2019 EditorConfig Team {{{1 +" All rights reserved. +" +" Redistribution and use in source and binary forms, with or without +" 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 COPYRIGHT HOLDER 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. }}}1 + +"Filename matching with shell patterns. +" +"fnmatch(FILENAME, PATH, PATTERN) matches according to the local convention. +"fnmatchcase(FILENAME, PATH, PATTERN) always takes case in account. +" +"The functions operate by translating the pattern into a regular +"expression. They cache the compiled regular expressions for speed. +" +"The function translate(PATTERN) returns a regular expression +"corresponding to PATTERN. (It does not compile it.) + +let s:saved_cpo = &cpo +set cpo&vim + +" variables {{{1 +if !exists('g:editorconfig_core_vimscript_debug') + let g:editorconfig_core_vimscript_debug = 0 +endif +" }}}1 +" === Regexes =========================================================== {{{1 +let s:LEFT_BRACE = '\v%(^|[^\\])\{' +"LEFT_BRACE = re.compile( +" r""" +" +" (?: ^ | [^\\] ) # Beginning of string or a character besides "\" +" +" \{ # "{" +" +" """, re.VERBOSE +") + +let s:RIGHT_BRACE = '\v%(^|[^\\])\}' +"RIGHT_BRACE = re.compile( +" r""" +" +" (?: ^ | [^\\] ) # Beginning of string or a character besides "\" +" +" \} # "}" +" +" """, re.VERBOSE +") + +let s:NUMERIC_RANGE = '\v([+-]?\d+)' . '\.\.' . '([+-]?\d+)' +"NUMERIC_RANGE = re.compile( +" r""" +" ( # Capture a number +" [+-] ? # Zero or one "+" or "-" characters +" \d + # One or more digits +" ) +" +" \.\. # ".." +" +" ( # Capture a number +" [+-] ? # Zero or one "+" or "-" characters +" \d + # One or more digits +" ) +" """, re.VERBOSE +") + +" }}}1 +" === Internal functions ================================================ {{{1 + +" Dump the bytes of a:text. For debugging use. +function! s:dump_bytes(text) + let l:idx=0 + while l:idx < strlen(a:text) + let l:byte_val = char2nr(a:text[l:idx]) + echom printf('%10s%-5d%02x %s', '', l:idx, l:byte_val, + \ a:text[l:idx]) + let l:idx+=1 + endwhile +endfunction "s:dump_bytes + +" Dump the characters of a:text and their codepoints. For debugging use. +function! s:dump_chars(text) + let l:chars = split(a:text, '\zs') + let l:idx = 0 + let l:out1 = '' + let l:out2 = '' + while l:idx < len(l:chars) + let l:char = l:chars[l:idx] + let l:out1 .= printf('%5s', l:char) + let l:out2 .= printf('%5x', char2nr(l:char)) + let l:idx+=1 + endwhile + + echom l:out1 + echom l:out2 +endfunction "s:dump_chars + +" }}}1 +" === Translating globs to patterns ===================================== {{{1 + +" Used by s:re_escape: backslash-escape any character below U+0080; +" replace all others with a %U escape. +" See https://vi.stackexchange.com/a/19617/1430 by yours truly +" (https://vi.stackexchange.com/users/1430/cxw). +unlockvar s:replacement_expr +let s:replacement_expr = + \ '\=' . + \ '((char2nr(submatch(1)) >= 128) ? ' . + \ 'printf("%%U%08x", char2nr(submatch(1))) : ' . + \ '("\\" . submatch(1))' . + \ ')' +lockvar s:replacement_expr + +" Escaper for very-magic regexes +function! s:re_escape(text) + return substitute(a:text, '\v([^0-9a-zA-Z_])', s:replacement_expr, 'g') +endfunction + +"def translate(pat, nested=0): +" Translate a shell PATTERN to a regular expression. +" There is no way to quote meta-characters. +function! editorconfig_core#fnmatch#translate(pat, ...) + let l:nested = 0 + if a:0 + let l:nested = a:1 + endif + + if g:editorconfig_core_vimscript_debug + echom '- fnmatch#translate: pattern ' . a:pat + echom printf( + \ '- %d chars', strlen(substitute(a:pat, ".", "x", "g"))) + call s:dump_chars(a:pat) + endif + + let l:pat = a:pat " TODO remove if we wind up not needing this + + " Note: the Python sets MULTILINE and DOTALL, but Vim has \_. + " instead of DOTALL, and \_^ / \_$ instead of MULTILINE. + + let l:is_escaped = 0 + + " Find out whether the pattern has balanced braces. + let l:left_braces=[] + let l:right_braces=[] + call substitute(l:pat, s:LEFT_BRACE, '\=add(l:left_braces, 1)', 'g') + call substitute(l:pat, s:RIGHT_BRACE, '\=add(l:right_braces, 1)', 'g') + " Thanks to http://jeromebelleman.gitlab.io/posts/productivity/vimsub/ + let l:matching_braces = (len(l:left_braces) == len(l:right_braces)) + + " Unicode support (#2). Indexing l:pat[l:index] returns bytes, per + " https://github.com/neovim/neovim/issues/68#issue-28114985 . + " Instead, use split() per vimdoc to break the input string into an + " array of *characters*, and process that. + let l:characters = split(l:pat, '\zs') + + let l:index = 0 " character index + let l:length = len(l:characters) + let l:brace_level = 0 + let l:in_brackets = 0 + + let l:result = '' + let l:numeric_groups = [] + while l:index < l:length + let l:current_char = l:characters[l:index] + let l:index += 1 + +" if g:editorconfig_core_vimscript_debug +" echom ' - fnmatch#translate: ' . l:current_char . '@' . +" \ (l:index-1) . '; result ' . l:result +" endif + + if l:current_char ==# '*' + let l:pos = l:index + if l:pos < l:length && l:characters[l:pos] ==# '*' + let l:result .= '\_.*' + let l:index += 1 " skip the second star + else + let l:result .= '[^/]*' + endif + + elseif l:current_char ==# '?' + let l:result .= '\_[^/]' + + elseif l:current_char ==# '[' + if l:in_brackets + let l:result .= '\[' + else + let l:pos = l:index + let l:has_slash = 0 + while l:pos < l:length && l:characters[l:pos] != ']' + if l:characters[l:pos] ==# '/' && l:characters[l:pos-1] !=# '\' + let has_slash = 1 + break + endif + let l:pos += 1 + endwhile + if l:has_slash + " POSIX IEEE 1003.1-2017 sec. 2.13.3: '/' cannot occur + " in a bracket expression, so [/] matches a literal + " three-character string '[' . '/' . ']'. + let l:result .= '\[' + \ . s:re_escape(join(l:characters[l:index : l:pos-1], '')) + \ . '\/' + " escape the slash + let l:index = l:pos + 1 + " resume after the slash + else + if l:index < l:length && l:characters[l:index] =~# '\v%(\^|\!)' + let l:index += 1 + let l:result .= '[^' + else + let l:result .= '[' + endif + let l:in_brackets = 1 + endif + endif + + elseif l:current_char ==# '-' + if l:in_brackets + let l:result .= l:current_char + else + let l:result .= '\' . l:current_char + endif + + elseif l:current_char ==# ']' + if l:in_brackets && !l:is_escaped + let l:result .= ']' + let l:in_brackets = 0 + elseif l:is_escaped + let l:result .= '\]' + let l:is_escaped = 0 + else + let l:result .= '\]' + endif + + elseif l:current_char ==# '{' + let l:pos = l:index + let l:has_comma = 0 + while l:pos < l:length && (l:characters[l:pos] !=# '}' || l:is_escaped) + if l:characters[l:pos] ==# ',' && ! l:is_escaped + let l:has_comma = 1 + break + endif + let l:is_escaped = l:characters[l:pos] ==# '\' && ! l:is_escaped + let l:pos += 1 + endwhile + if ! l:has_comma && l:pos < l:length + let l:num_range = + \ matchlist(join(l:characters[l:index : l:pos-1], ''), + \ s:NUMERIC_RANGE) + if len(l:num_range) > 0 " Remember the ranges + call add(l:numeric_groups, [ 0+l:num_range[1], 0+l:num_range[2] ]) + let l:result .= '([+-]?\d+)' + else + let l:inner_xlat = editorconfig_core#fnmatch#translate( + \ join(l:characters[l:index : l:pos-1], ''), 1) + let l:inner_result = l:inner_xlat[0] + let l:inner_groups = l:inner_xlat[1] + let l:result .= '\{' . l:inner_result . '\}' + let l:numeric_groups += l:inner_groups + endif + let l:index = l:pos + 1 + elseif l:matching_braces + let l:result .= '%(' + let l:brace_level += 1 + else + let l:result .= '\{' + endif + + elseif l:current_char ==# ',' + if l:brace_level > 0 && ! l:is_escaped + let l:result .= '|' + else + let l:result .= '\,' + endif + + elseif l:current_char ==# '}' + if l:brace_level > 0 && ! l:is_escaped + let l:result .= ')' + let l:brace_level -= 1 + else + let l:result .= '\}' + endif + + elseif l:current_char ==# '/' + if join(l:characters[l:index : (l:index + 2)], '') ==# '**/' + let l:result .= '%(/|/\_.*/)' + let l:index += 3 + else + let l:result .= '\/' + endif + + elseif l:current_char != '\' + let l:result .= s:re_escape(l:current_char) + endif + + if l:current_char ==# '\' + if l:is_escaped + let l:result .= s:re_escape(l:current_char) + endif + let l:is_escaped = ! l:is_escaped + else + let l:is_escaped = 0 + endif + + endwhile + + if ! l:nested + let l:result .= '\_$' + endif + + return [l:result, l:numeric_groups] +endfunction " #editorconfig_core#fnmatch#translate + +let s:_cache = {} +function! s:cached_translate(pat) + if ! has_key(s:_cache, a:pat) + "regex = re.compile(res) + let s:_cache[a:pat] = + \ editorconfig_core#fnmatch#translate(a:pat) + " we don't compile the regex + endif + return s:_cache[a:pat] +endfunction " cached_translate + +" }}}1 +" === Matching functions ================================================ {{{1 + +function! editorconfig_core#fnmatch#fnmatch(name, path, pattern) +"def fnmatch(name, pat): +" """Test whether FILENAME matches PATH/PATTERN. +" +" Patterns are Unix shell style: +" +" - ``*`` matches everything except path separator +" - ``**`` matches everything +" - ``?`` matches any single character +" - ``[seq]`` matches any character in seq +" - ``[!seq]`` matches any char not in seq +" - ``{s1,s2,s3}`` matches any of the strings given (separated by commas) +" +" An initial period in FILENAME is not special. +" Both FILENAME and PATTERN are first case-normalized +" if the operating system requires it. +" If you don't want this, use fnmatchcase(FILENAME, PATTERN). +" """ +" + " Note: This throws away the backslash in '\.txt' on Cygwin, but that + " makes sense since it's Windows under the hood. + " We don't care about shellslash since we're going to change backslashes + " to slashes in just a moment anyway. + let l:localname = fnamemodify(a:name, ':p') + + if editorconfig_core#util#is_win() " normalize + let l:localname = substitute(tolower(l:localname), '\v\\', '/', 'g') + let l:path = substitute(tolower(a:path), '\v\\', '/', 'g') + let l:pattern = tolower(a:pattern) + else + let l:localname = l:localname + let l:path = a:path + let l:pattern = a:pattern + endif + + if g:editorconfig_core_vimscript_debug + echom '- fnmatch#fnmatch testing <' . l:localname . '> against <' . + \ l:pattern . '> wrt <' . l:path . '>' + endif + + return editorconfig_core#fnmatch#fnmatchcase(l:localname, l:path, l:pattern) +endfunction " fnmatch + +function! editorconfig_core#fnmatch#fnmatchcase(name, path, pattern) +"def fnmatchcase(name, pat): +" """Test whether FILENAME matches PATH/PATTERN, including case. +" +" This is a version of fnmatch() which doesn't case-normalize +" its arguments. +" """ +" + let [regex, num_groups] = s:cached_translate(a:pattern) + + let l:escaped_path = s:re_escape(a:path) + let l:regex = '\v' . l:escaped_path . l:regex + + if g:editorconfig_core_vimscript_debug + echom '- fnmatch#fnmatchcase: regex ' . l:regex + call s:dump_chars(l:regex) + echom '- fnmatch#fnmatchcase: checking ' . a:name + call s:dump_chars(a:name) + endif + + let l:match_groups = matchlist(a:name, l:regex)[1:] " [0] = full match + + if g:editorconfig_core_vimscript_debug + echom printf(' Got %d matches', len(l:match_groups)) + endif + + if len(l:match_groups) == 0 + return 0 + endif + + " Check numeric ranges + let pattern_matched = 1 + for l:idx in range(0,len(l:match_groups)) + let l:num = l:match_groups[l:idx] + if l:num ==# '' + break + endif + + let [min_num, max_num] = num_groups[l:idx] + if (min_num > (0+l:num)) || ((0+l:num) > max_num) + let pattern_matched = 0 + break + endif + + " Reject leading zeros without sign. This is very odd --- + " see editorconfig/editorconfig#371. + if match(l:num, '\v^0') != -1 + let pattern_matched = 0 + break + endif + endfor + + if g:editorconfig_core_vimscript_debug + echom '- fnmatch#fnmatchcase: ' . (pattern_matched ? 'matched' : 'did not match') + endif + + return pattern_matched +endfunction " fnmatchcase + +" }}}1 +" === Copyright notices ================================================= {{{1 +" Based on code from fnmatch.py file distributed with Python 2.6. +" Portions Copyright (c) 2001-2010 Python Software Foundation; +" All Rights Reserved. Licensed under PSF License (see LICENSE.PSF file). +" +" Changes to original fnmatch: +" +" - translate function supports ``*`` and ``**`` similarly to fnmatch C library +" }}}1 + +let &cpo = s:saved_cpo +unlet! s:saved_cpo + +" vi: set fdm=marker: diff --git a/sources_non_forked/editorconfig-vim/autoload/editorconfig_core/handler.vim b/sources_non_forked/editorconfig-vim/autoload/editorconfig_core/handler.vim new file mode 100644 index 00000000..c9a66e16 --- /dev/null +++ b/sources_non_forked/editorconfig-vim/autoload/editorconfig_core/handler.vim @@ -0,0 +1,183 @@ +" autoload/editorconfig_core/handler.vim: Main worker for +" editorconfig-core-vimscript and editorconfig-vim. +" Modified from the Python core's handler.py. + +" Copyright (c) 2012-2019 EditorConfig Team {{{1 +" All rights reserved. +" +" Redistribution and use in source and binary forms, with or without +" 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 COPYRIGHT HOLDER 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. }}}1 + +let s:saved_cpo = &cpo +set cpo&vim + +" Return full filepath for filename in each directory in and above path. {{{1 +" Input path must be an absolute path. +" TODO shellslash/shellescape? +function! s:get_filenames(path, config_filename) + let l:path = a:path + let l:path_list = [] + while 1 + call add(l:path_list, editorconfig_core#util#path_join(l:path, a:config_filename)) + let l:newpath = fnamemodify(l:path, ':h') + if l:path ==? l:newpath || !strlen(l:path) + break + endif + let l:path = l:newpath + endwhile + return l:path_list +endfunction " get_filenames + +" }}}1 +" === Main ============================================================== {{{1 + +" Find EditorConfig files and return all options matching target_filename. +" Throws on failure. +" @param job {Dictionary} required 'target'; optional 'config' and 'version' +function! editorconfig_core#handler#get_configurations(job) + " TODO? support VERSION checks? + +" Special exceptions that may be raised by this function include: +" - ``VersionError``: self.version is invalid EditorConfig version +" - ``PathError``: self.filepath is not a valid absolute filepath +" - ``ParsingError``: improperly formatted EditorConfig file found + + let l:job = deepcopy(a:job) + if has_key(l:job, 'config') + let l:config_filename = l:job.config + else + let l:config_filename = '.editorconfig' + let l:job.config = l:config_filename + endif + + if has_key(l:job, 'version') + let l:version = l:job.version + else + let l:version = editorconfig_core#version() + let l:job.version = l:version + endif + + let l:target_filename = l:job.target + + "echom 'Beginning job ' . string(l:job) + if !s:check_assertions(l:job) + throw "Assertions failed" + endif + + let l:fullpath = fnamemodify(l:target_filename,':p') + let l:path = fnamemodify(l:fullpath, ':h') + let l:conf_files = s:get_filenames(l:path, l:config_filename) + + " echom 'fullpath ' . l:fullpath + " echom 'path ' . l:path + + let l:retval = {} + + " Attempt to find and parse every EditorConfig file in filetree + for l:conf_fn in l:conf_files + "echom 'Trying ' . l:conf_fn + let l:parsed = editorconfig_core#ini#read_ini_file(l:conf_fn, l:target_filename) + if !has_key(l:parsed, 'options') + continue + endif + " echom ' Has options' + + " Merge new EditorConfig file's options into current options + let l:old_options = l:retval + let l:retval = l:parsed.options + " echom 'Old options ' . string(l:old_options) + " echom 'New options ' . string(l:retval) + call extend(l:retval, l:old_options, 'force') + + " Stop parsing if parsed file has a ``root = true`` option + if l:parsed.root + break + endif + endfor + + call s:preprocess_values(l:job, l:retval) + return l:retval +endfunction " get_configurations + +function! s:check_assertions(job) +" TODO +" """Raise error if filepath or version have invalid values""" + +" # Raise ``PathError`` if filepath isn't an absolute path +" if not os.path.isabs(self.filepath): +" raise PathError("Input file must be a full path name.") + + " Throw if version specified is greater than current + let l:v = a:job.version + let l:us = editorconfig_core#version() + " echom 'Comparing requested version ' . string(l:v) . + " \ ' to our version ' . string(l:us) + if l:v[0] > l:us[0] || l:v[1] > l:us[1] || l:v[2] > l:us[2] + throw 'Required version ' . string(l:v) . + \ ' is greater than the current version ' . string(l:us) + endif + + return 1 " All OK if we got here +endfunction " check_assertions + +" }}}1 + +" Preprocess option values for consumption by plugins. {{{1 +" Modifies its argument in place. +function! s:preprocess_values(job, opts) + + " Lowercase option value for certain options + for l:name in ['end_of_line', 'indent_style', 'indent_size', + \ 'insert_final_newline', 'trim_trailing_whitespace', + \ 'charset'] + if has_key(a:opts, l:name) + let a:opts[l:name] = tolower(a:opts[l:name]) + endif + endfor + + " Set indent_size to "tab" if indent_size is unspecified and + " indent_style is set to "tab", provided we are at least v0.10.0. + if get(a:opts, 'indent_style', '') ==? "tab" && + \ !has_key(a:opts, 'indent_size') && + \ ( a:job.version[0]>0 || a:job.version[1] >=10 ) + let a:opts['indent_size'] = 'tab' + endif + + " Set tab_width to indent_size if indent_size is specified and + " tab_width is unspecified + if has_key(a:opts, 'indent_size') && !has_key(a:opts, 'tab_width') && + \ get(a:opts, 'indent_size', '') !=? "tab" + let a:opts['tab_width'] = a:opts['indent_size'] + endif + + " Set indent_size to tab_width if indent_size is "tab" + if has_key(a:opts, 'indent_size') && has_key(a:opts, 'tab_width') && + \ get(a:opts, 'indent_size', '') ==? "tab" + let a:opts['indent_size'] = a:opts['tab_width'] + endif +endfunction " preprocess_values + +" }}}1 + +let &cpo = s:saved_cpo +unlet! s:saved_cpo + +" vi: set fdm=marker fdl=1: diff --git a/sources_non_forked/editorconfig-vim/autoload/editorconfig_core/ini.vim b/sources_non_forked/editorconfig-vim/autoload/editorconfig_core/ini.vim new file mode 100644 index 00000000..279b381d --- /dev/null +++ b/sources_non_forked/editorconfig-vim/autoload/editorconfig_core/ini.vim @@ -0,0 +1,273 @@ +" autoload/editorconfig_core/ini.vim: Config-file parser for +" editorconfig-core-vimscript and editorconfig-vim. +" Modifed from the Python core's ini.py. + +" Copyright (c) 2012-2019 EditorConfig Team {{{2 +" All rights reserved. +" +" Redistribution and use in source and binary forms, with or without +" 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 COPYRIGHT HOLDER 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. }}}2 + +let s:saved_cpo = &cpo +set cpo&vim + +" variables {{{2 +if !exists('g:editorconfig_core_vimscript_debug') + let g:editorconfig_core_vimscript_debug = 0 +endif +" }}}2 +" === Constants, including regexes ====================================== {{{2 +" Regular expressions for parsing section headers and options. +" Allow ``]`` and escaped ``;`` and ``#`` characters in section headers. +" In fact, allow \ to escape any single character - it needs to cover at +" least \ * ? [ ! ] { }. +unlockvar s:SECTCRE s:OPTCRE s:MAX_SECTION_NAME s:MAX_PROPERTY_NAME s:MAX_PROPERTY_VALUE +let s:SECTCRE = '\v^\s*\[(%([^\\#;]|\\.)+)\]' + +" Regular expression for parsing option name/values. +" Allow any amount of whitespaces, followed by separator +" (either ``:`` or ``=``), followed by any amount of whitespace and then +" any characters to eol +let s:OPTCRE = '\v\s*([^:=[:space:]][^:=]*)\s*([:=])\s*(.*)$' + +let s:MAX_SECTION_NAME = 4096 +let s:MAX_PROPERTY_NAME = 50 +let s:MAX_PROPERTY_VALUE = 255 + +lockvar s:SECTCRE s:OPTCRE s:MAX_SECTION_NAME s:MAX_PROPERTY_NAME s:MAX_PROPERTY_VALUE + +" }}}2 +" === Main ============================================================== {{{1 + +" Read \p config_filename and return the options applicable to +" \p target_filename. This is the main entry point in this file. +function! editorconfig_core#ini#read_ini_file(config_filename, target_filename) + let l:oldenc = &encoding + + if !filereadable(a:config_filename) + return {} + endif + + try " so &encoding will always be reset + let &encoding = 'utf-8' " so readfile() will strip BOM + let l:lines = readfile(a:config_filename) + let result = s:parse(a:config_filename, a:target_filename, l:lines) + catch + let &encoding = l:oldenc + " rethrow, but with a prefix since throw 'Vim...' fails. + throw 'Could not read editorconfig file at ' . v:throwpoint . ': ' . string(v:exception) + endtry + + let &encoding = l:oldenc + return result +endfunction + +function! s:parse(config_filename, target_filename, lines) +" Parse a sectioned setup file. +" The sections in setup file contains a title line at the top, +" indicated by a name in square brackets (`[]'), plus key/value +" options lines, indicated by `name: value' format lines. +" Continuations are represented by an embedded newline then +" leading whitespace. Blank lines, lines beginning with a '#', +" and just about everything else are ignored. + + let l:in_section = 0 + let l:matching_section = 0 + let l:optname = '' + let l:lineno = 0 + let l:e = [] " Errors, if any + + let l:options = {} " Options applicable to this file + let l:is_root = 0 " Whether a:config_filename declares root=true + + while 1 + if l:lineno == len(a:lines) + break + endif + + let l:line = a:lines[l:lineno] + let l:lineno = l:lineno + 1 + + " comment or blank line? + if editorconfig_core#util#strip(l:line) ==# '' + continue + endif + if l:line =~# '\v^[#;]' + continue + endif + + " is it a section header? + if g:editorconfig_core_vimscript_debug + echom "Header? <" . l:line . ">" + endif + + let l:mo = matchlist(l:line, s:SECTCRE) + if len(l:mo) + let l:sectname = l:mo[1] + let l:in_section = 1 + if strlen(l:sectname) > s:MAX_SECTION_NAME + " Section name too long => ignore the section + let l:matching_section = 0 + else + let l:matching_section = s:matches_filename( + \ a:config_filename, a:target_filename, l:sectname) + endif + + if g:editorconfig_core_vimscript_debug + echom 'In section ' . l:sectname . ', which ' . + \ (l:matching_section ? 'matches' : 'does not match') + \ ' file ' . a:target_filename . ' (config ' . + \ a:config_filename . ')' + endif + + " So sections can't start with a continuation line + let l:optname = '' + + " Is it an option line? + else + let l:mo = matchlist(l:line, s:OPTCRE) + if len(l:mo) + let l:optname = mo[1] + let l:optval = mo[3] + + if g:editorconfig_core_vimscript_debug + echom printf('Saw raw opt <%s>=<%s>', l:optname, l:optval) + endif + + if l:optval =~# '\v[;#]' + " ';' and '#' are comment delimiters only if + " preceded by a spacing character + let l:m = matchlist(l:optval, '\v(.{-})\s[;#]') + if len(l:m) + let l:optval = l:m[1] + endif + + " ; and # can be escaped with backslash. + let l:optval = substitute(l:optval, '\v\\([;#])', '\1', 'g') + + endif + let l:optval = editorconfig_core#util#strip(l:optval) + " allow empty values + if l:optval ==? '""' + let l:optval = '' + endif + let l:optname = s:optionxform(l:optname) + if !l:in_section && optname ==? 'root' + let l:is_root = (optval ==? 'true') + endif + if g:editorconfig_core_vimscript_debug + echom printf('Saw opt <%s>=<%s>', l:optname, l:optval) + endif + + if l:matching_section && + \ strlen(l:optname) <= s:MAX_PROPERTY_NAME && + \ strlen(l:optval) <= s:MAX_PROPERTY_VALUE + let l:options[l:optname] = l:optval + endif + else + " a non-fatal parsing error occurred. set up the + " exception but keep going. the exception will be + " raised at the end of the file and will contain a + " list of all bogus lines + call add(e, "Parse error in '" . a:config_filename . "' at line " . + \ l:lineno . ": '" . l:line . "'") + endif + endif + endwhile + + " if any parsing errors occurred, raise an exception + if len(l:e) + throw string(l:e) + endif + + return {'root': l:is_root, 'options': l:options} +endfunction! + +" }}}1 +" === Helpers =========================================================== {{{1 + +" Preprocess option names +function! s:optionxform(optionstr) + let l:result = substitute(a:optionstr, '\v\s+$', '', 'g') " rstrip + return tolower(l:result) +endfunction + +" Return true if \p glob matches \p target_filename +function! s:matches_filename(config_filename, target_filename, glob) +" config_dirname = normpath(dirname(config_filename)).replace(sep, '/') + let l:config_dirname = fnamemodify(a:config_filename, ':p:h') . '/' + + if editorconfig_core#util#is_win() + " Regardless of whether shellslash is set, make everything slashes + let l:config_dirname = + \ tolower(substitute(l:config_dirname, '\v\\', '/', 'g')) + endif + + let l:glob = substitute(a:glob, '\v\\([#;])', '\1', 'g') + + " Take account of the path to the editorconfig file. + " editorconfig-core-c/src/lib/editorconfig.c says: + " "Pattern would be: /dir/of/editorconfig/file[double_star]/[section] if + " section does not contain '/', or /dir/of/editorconfig/file[section] + " if section starts with a '/', or /dir/of/editorconfig/file/[section] if + " section contains '/' but does not start with '/'." + + if stridx(l:glob, '/') != -1 " contains a slash + if l:glob[0] ==# '/' + let l:glob = l:glob[1:] " trim leading slash + endif +" This will be done by fnmatch +" let l:glob = l:config_dirname . l:glob + else " does not contain a slash + let l:config_dirname = l:config_dirname[:-2] + " Trim trailing slash + let l:glob = '**/' . l:glob + endif + + if g:editorconfig_core_vimscript_debug + echom '- ini#matches_filename: checking <' . a:target_filename . + \ '> against <' . l:glob . '> with respect to config file <' . + \ a:config_filename . '>' + echom '- ini#matches_filename: config_dirname is ' . l:config_dirname + endif + + return editorconfig_core#fnmatch#fnmatch(a:target_filename, + \ l:config_dirname, l:glob) +endfunction " matches_filename + +" }}}1 +" === Copyright notices ================================================= {{{2 +" Based on code from ConfigParser.py file distributed with Python 2.6. +" Portions Copyright (c) 2001-2010 Python Software Foundation; +" All Rights Reserved. Licensed under PSF License (see LICENSE.PSF file). +" +" Changes to original ConfigParser: +" +" - Special characters can be used in section names +" - Octothorpe can be used for comments (not just at beginning of line) +" - Only track INI options in sections that match target filename +" - Stop parsing files with when ``root = true`` is found +" }}}2 + +let &cpo = s:saved_cpo +unlet! s:saved_cpo + +" vi: set fdm=marker fdl=1: diff --git a/sources_non_forked/editorconfig-vim/autoload/editorconfig_core/util.vim b/sources_non_forked/editorconfig-vim/autoload/editorconfig_core/util.vim new file mode 100644 index 00000000..c4df04af --- /dev/null +++ b/sources_non_forked/editorconfig-vim/autoload/editorconfig_core/util.vim @@ -0,0 +1,84 @@ +" util.vim: part of editorconfig-core-vimscript and editorconfig-vim. +" Copyright (c) 2018-2019 EditorConfig Team, including Chris White {{{1 +" All rights reserved. +" +" Redistribution and use in source and binary forms, with or without +" 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 COPYRIGHT HOLDER 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. }}}1 + +let s:saved_cpo = &cpo +set cpo&vim + +" A verbatim copy of ingo#fs#path#Separator() {{{1 +" from https://github.com/vim-scripts/ingo-library/blob/558132e2221db3af26dc2f2c6756d092d48a459f/autoload/ingo/fs/path.vim +" distributed under the Vim license. +function! editorconfig_core#util#Separator() + return (exists('+shellslash') && ! &shellslash ? '\' : '/') +endfunction " }}}1 + +" path_join(): ('a','b')->'a/b'; ('a/','b')->'a/b'. {{{1 +function! editorconfig_core#util#path_join(a, b) + " TODO shellescape/shellslash? + "echom 'Joining <' . a:a . '> and <' . a:b . '>' + "echom 'Length is ' . strlen(a:a) + "echom 'Last char is ' . char2nr(a:a[-1]) + if a:a !~# '\v%(\/|\\)$' + return a:a . editorconfig_core#util#Separator() . a:b + else + return a:a . a:b + endif +endfunction " }}}1 + +" is_win() by xolox {{{1 +" The following function is modified from +" https://github.com/xolox/vim-misc/blob/master/autoload/xolox/misc/os.vim +" Copyright (c) 2015 Peter Odding +" +" Permission is hereby granted, free of charge, to any person obtaining a copy +" of this software and associated documentation files (the "Software"), to deal +" in the Software without restriction, including without limitation the rights +" to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +" copies of the Software, and to permit persons to whom the Software is +" furnished to do so, subject to the following conditions: +" +" The above copyright notice and this permission notice shall be included in all +" copies or substantial portions of the Software. +" +" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +" IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +" FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +" AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +" LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +" OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +" SOFTWARE. +function! editorconfig_core#util#is_win() + " Returns 1 (true) when on Microsoft Windows, 0 (false) otherwise. + return has('win16') || has('win32') || has('win64') +endfunction " }}}1 + +" strip() {{{1 +function! editorconfig_core#util#strip(s) + return substitute(a:s, '\v^\s+|\s+$','','g') +endfunction " }}}1 + +let &cpo = s:saved_cpo +unlet! s:saved_cpo + +" vi: set fdm=marker: diff --git a/sources_non_forked/editorconfig-vim/doc/editorconfig.txt b/sources_non_forked/editorconfig-vim/doc/editorconfig.txt new file mode 100644 index 00000000..66e9e5bf --- /dev/null +++ b/sources_non_forked/editorconfig-vim/doc/editorconfig.txt @@ -0,0 +1,203 @@ +*editorconfig.txt* + +File: editorconfig.txt +Version: 1.1.1 +Maintainer: EditorConfig Team +Description: EditorConfig vim plugin + +License: + Copyright (c) 2011-2019 EditorConfig Team + All rights reserved. + + Redistribution and use in source and binary forms, with or without + 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 COPYRIGHT HOLDER 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. + + +CONTENTS~ + *editorconfig-contents* +---------------------------------------------------------------------------- +1. Overview |editorconfig-overview| +2. Installation |editorconfig-installation| +3. Commands |editorconfig-commands| +4. Settings |editorconfig-settings| +5. Advanced |editorconfig-advanced| + + +OVERVIEW~ + *editorconfig-overview* +---------------------------------------------------------------------------- +This is the EditorConfig plugin for vim. + + +INSTALLATION~ + *editorconfig-installation* +---------------------------------------------------------------------------- +Follow the instructions in the README.md file to install this plugin. + +COMMANDS~ + *editorconfig-commands* +---------------------------------------------------------------------------- + + *:EditorConfigReload* +Command: + :EditorConfigReload + +Reload the EditorConfig conf files. When `.editorconfig` files are modified, +this command could prevent you to reload the current edited file to load the +new configuration. + +SETTINGS~ + *editorconfig-settings* +---------------------------------------------------------------------------- + *g:EditorConfig_core_mode* +Specify the mode of EditorConfig core. Generally it is OK to leave this option +empty. Currently, the supported modes are "vim_core" (default) and +"external_command". + + vim_core: Use the included VimScript EditorConfig Core. + external_command: Run external EditorConfig Core. + +If "g:EditorConfig_core_mode" is not specified, this plugin will automatically +choose "vim_core". + +If you choose "external_command" mode, you must also set +|g:EditorConfig_exec_path|. + +Changes to "g:EditorConfig_core_mode" will not take effect until Vim +is restarted. + + *b:EditorConfig_disable* +This is a buffer-local variable that disables the EditorConfig plugin for a +single buffer. + +Example: Disable EditorConfig for the current buffer: +> + let b:EditorConfig_disable = 1 +< +Example: Disable EditorConfig for all git commit messages: +> + au FileType gitcommit let b:EditorConfig_disable = 1 +< + + *g:EditorConfig_exclude_patterns* +This is a list contains file path patterns which will be ignored by +EditorConfig plugin. When the path of the opened buffer (i.e. +"expand('%:p')") matches any of the patterns in the list, EditorConfig will +not load for this file. The default is an empty list. + +Example: Avoid loading EditorConfig for any remote files over ssh +> + let g:EditorConfig_exclude_patterns = ['scp://.*'] +< + + *g:EditorConfig_exec_path* +The file path to the EditorConfig core executable. You can set this value in +your |vimrc| like this: +> + let g:EditorConfig_exec_path = 'Path to your EditorConfig Core executable' +< +The default value is empty. + +If "g:EditorConfig_exec_path" is not set, the plugin will use the "vim_core" +mode regardless of the setting of |g:EditorConfig_core_mode|. + +Changes to "g:EditorConfig_exec_path" will not take effect until Vim +is restarted. + + *g:EditorConfig_max_line_indicator* +The way to show the line where the maximal length is reached. Accepted values +are "line", "fill", otherwise there will be no max line indicator. + + "line": the right column of the max line length column will be + highlighted, made possible by setting 'colorcolumn' to + "max_line_length + 1". + + "fill": all the columns to the right of the max line length column + will be highlighted, made possible by setting 'colorcolumn' + to a list of numbers starting from "max_line_length + 1" to + the number of columns on the screen. + + "exceeding": the right column of the max line length column will be + highlighted on lines that exceed the max line length, made + possible by adding a match for the ColorColumn group. + + "none": no max line length indicator will be shown. This is the + recommended value when you do not want any indicator to be + shown, but values other than "line" or "fill" would also work + as "none". + +To set this option, add any of the following lines to your |vimrc| file: +> + let g:EditorConfig_max_line_indicator = "line" + let g:EditorConfig_max_line_indicator = "fill" + let g:EditorConfig_max_line_indicator = "exceeding" + let g:EditorConfig_max_line_indicator = "none" +< +The default value is "line". + + *g:EditorConfig_preserve_formatoptions* +Set this to 1 if you don't want your formatoptions modified when +max_line_length is set: +> + let g:EditorConfig_preserve_formatoptions = 1 +< +This option defaults to 0. + + *g:EditorConfig_verbose* +Set this to 1 if you want debug info printed: +> + let g:EditorConfig_verbose = 1 +< + +ADVANCED~ + *editorconfig-advanced* +---------------------------------------------------------------------------- + *editorconfig-hook* + *EditorConfig#AddNewHook()* +While this plugin offers several builtin supported properties (as mentioned +here: https://github.com/editorconfig/editorconfig-vim#supported-properties), +we are also able to add our own hooks to support additional EditorConfig +properties, including those not in the EditorConfig standard. For example, we +are working on an Objective-C project, and all our "*.m" files should be +Objective-C source files. However, vim sometimes detect "*.m" files as MATLAB +source files, which causes incorrect syntax highlighting, code indentation, +etc. To solve the case, we could write the following code into the |vimrc| +file: +> + function! FiletypeHook(config) + if has_key(a:config, 'vim_filetype') + let &filetype = a:config['vim_filetype'] + endif + + return 0 " Return 0 to show no error happened + endfunction + + call editorconfig#AddNewHook(function('FiletypeHook')) +< +And add the following code to your .editorconfig file: +> + [*.m] + vim_filetype = objc +< +Then try to open an Objective-C file, you will find the |filetype| is set to +"objc". + +vim:ft=help:tw=78 diff --git a/sources_non_forked/editorconfig-vim/mkzip.sh b/sources_non_forked/editorconfig-vim/mkzip.sh new file mode 100644 index 00000000..811724ca --- /dev/null +++ b/sources_non_forked/editorconfig-vim/mkzip.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +zip -r editorconfig-vim-$*.zip plugin/* autoload/* doc/* diff --git a/sources_non_forked/editorconfig-vim/plugin/editorconfig.vim b/sources_non_forked/editorconfig-vim/plugin/editorconfig.vim new file mode 100644 index 00000000..e491ce7c --- /dev/null +++ b/sources_non_forked/editorconfig-vim/plugin/editorconfig.vim @@ -0,0 +1,521 @@ +" plugin/editorconfig.vim: EditorConfig native Vimscript plugin file +" Copyright (c) 2011-2019 EditorConfig Team +" All rights reserved. +" +" Redistribution and use in source and binary forms, with or without +" 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 COPYRIGHT HOLDER 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. +" + +" check for Vim versions and duplicate script loading. +if v:version < 700 || exists("g:loaded_EditorConfig") + finish +endif +let g:loaded_EditorConfig = 1 + +let s:saved_cpo = &cpo +set cpo&vim + +" variables {{{1 + +" Make sure the globals all exist +if !exists('g:EditorConfig_exec_path') + let g:EditorConfig_exec_path = '' +endif + +if !exists('g:EditorConfig_verbose') + let g:EditorConfig_verbose = 0 +endif + +if !exists('g:EditorConfig_preserve_formatoptions') + let g:EditorConfig_preserve_formatoptions = 0 +endif + +if !exists('g:EditorConfig_max_line_indicator') + let g:EditorConfig_max_line_indicator = 'line' +endif + +if !exists('g:EditorConfig_exclude_patterns') + let g:EditorConfig_exclude_patterns = [] +endif + +if !exists('g:EditorConfig_disable_rules') + let g:EditorConfig_disable_rules = [] +endif + +" Copy some of the globals into script variables --- changes to these +" globals won't affect the plugin until the plugin is reloaded. +if exists('g:EditorConfig_core_mode') && !empty(g:EditorConfig_core_mode) + let s:editorconfig_core_mode = g:EditorConfig_core_mode +else + let s:editorconfig_core_mode = '' +endif + +if exists('g:EditorConfig_exec_path') && !empty(g:EditorConfig_exec_path) + let s:editorconfig_exec_path = g:EditorConfig_exec_path +else + let s:editorconfig_exec_path = '' +endif + +let s:initialized = 0 + +" }}}1 + +" shellslash handling {{{1 +function! s:DisableShellSlash() " {{{2 + " disable shellslash for proper escaping of Windows paths + + " In Windows, 'shellslash' also changes the behavior of 'shellescape'. + " It makes 'shellescape' behave like in UNIX environment. So ':setl + " noshellslash' before evaluating 'shellescape' and restore the + " settings afterwards when 'shell' does not contain 'sh' somewhere. + if has('win32') && empty(matchstr(&shell, 'sh')) + let s:old_shellslash = &l:shellslash + setlocal noshellslash + endif +endfunction " }}}2 + +function! s:ResetShellSlash() " {{{2 + " reset shellslash to the user-set value, if any + if exists('s:old_shellslash') + let &l:shellslash = s:old_shellslash + unlet! s:old_shellslash + endif +endfunction " }}}2 +" }}}1 + +" Mode initialization functions {{{1 + +function! s:InitializeVimCore() +" Initialize vim core. Returns 1 on failure; 0 on success +" At the moment, all we need to do is to check that it is installed. + try + let l:vim_core_ver = editorconfig_core#version() + catch + return 1 + endtry + return 0 +endfunction + +function! s:InitializeExternalCommand() +" Initialize external_command mode + + if empty(s:editorconfig_exec_path) + echo 'Please specify a g:EditorConfig_exec_path' + return 1 + endif + + if g:EditorConfig_verbose + echo 'Checking for external command ' . s:editorconfig_exec_path . ' ...' + endif + + if !executable(s:editorconfig_exec_path) + echo 'File ' . s:editorconfig_exec_path . ' is not executable.' + return 1 + endif + + return 0 +endfunction +" }}}1 + +function! s:Initialize() " Initialize the plugin. {{{1 + " Returns truthy on error, falsy on success. + + if empty(s:editorconfig_core_mode) + let s:editorconfig_core_mode = 'vim_core' " Default core choice + endif + + if s:editorconfig_core_mode ==? 'external_command' + if s:InitializeExternalCommand() + echohl WarningMsg + echo 'EditorConfig: Failed to initialize external_command mode. ' . + \ 'Falling back to vim_core mode.' + echohl None + let s:editorconfig_core_mode = 'vim_core' + endif + endif + + if s:editorconfig_core_mode ==? 'vim_core' + if s:InitializeVimCore() + echohl ErrorMsg + echo 'EditorConfig: Failed to initialize vim_core mode. ' . + \ 'The plugin will not function.' + echohl None + return 1 + endif + + elseif s:editorconfig_core_mode ==? 'external_command' + " Nothing to do here, but this elseif is required to avoid + " external_command falling into the else clause. + + else " neither external_command nor vim_core + echohl ErrorMsg + echo "EditorConfig: I don't know how to use mode " . s:editorconfig_core_mode + echohl None + return 1 + endif + + let s:initialized = 1 + return 0 +endfunction " }}}1 + +function! s:GetFilenames(path, filename) " {{{1 +" Yield full filepath for filename in each directory in and above path + + let l:path_list = [] + let l:path = a:path + while 1 + let l:path_list += [l:path . '/' . a:filename] + let l:newpath = fnamemodify(l:path, ':h') + if l:path == l:newpath + break + endif + let l:path = l:newpath + endwhile + return l:path_list +endfunction " }}}1 + +function! s:UseConfigFiles() abort " Apply config to the current buffer {{{1 + let b:editorconfig_tried = 1 + let l:buffer_name = expand('%:p') + " ignore buffers without a name + if empty(l:buffer_name) + return + endif + + if exists("b:EditorConfig_disable") && b:EditorConfig_disable + if g:EditorConfig_verbose + echo 'Skipping EditorConfig for buffer "' . l:buffer_name . '"' + endif + return + endif + + " Check if any .editorconfig does exist + let l:conf_files = s:GetFilenames(expand('%:p:h'), '.editorconfig') + let l:conf_found = 0 + for conf_file in conf_files + if filereadable(conf_file) + let l:conf_found = 1 + break + endif + endfor + if !l:conf_found + return + endif + + if !s:initialized + if s:Initialize() + return + endif + endif + + if g:EditorConfig_verbose + echo 'Applying EditorConfig ' . s:editorconfig_core_mode . + \ ' on file "' . l:buffer_name . '"' + endif + + " Ignore specific patterns + for pattern in g:EditorConfig_exclude_patterns + if l:buffer_name =~ pattern + return + endif + endfor + + if s:editorconfig_core_mode ==? 'vim_core' + if s:UseConfigFiles_VimCore() == 0 + let b:editorconfig_applied = 1 + endif + elseif s:editorconfig_core_mode ==? 'external_command' + call s:UseConfigFiles_ExternalCommand() + let b:editorconfig_applied = 1 + else + echohl Error | + \ echo "Unknown EditorConfig Core: " . + \ s:editorconfig_core_mode | + \ echohl None + endif +endfunction " }}}1 + +" Custom commands, and autoloading {{{1 + +" Autocommands, and function to enable/disable the plugin {{{2 +function! s:EditorConfigEnable(should_enable) + augroup editorconfig + autocmd! + if a:should_enable + autocmd BufNewFile,BufReadPost,BufFilePost * call s:UseConfigFiles() + endif + augroup END +endfunction + +" }}}2 + +" Commands {{{2 +command! EditorConfigEnable call s:EditorConfigEnable(1) +command! EditorConfigDisable call s:EditorConfigEnable(0) + +command! EditorConfigReload call s:UseConfigFiles() " Reload EditorConfig files +" }}}2 + +" On startup, enable the autocommands +call s:EditorConfigEnable(1) + +" Always set the filetype for .editorconfig files +augroup editorconfig_dosini + autocmd! + autocmd BufNewFile,BufRead .editorconfig set filetype=dosini +augroup END + +" }}}1 + +" UseConfigFiles function for different modes {{{1 + +function! s:UseConfigFiles_VimCore() +" Use the vimscript EditorConfig core + try + let l:config = editorconfig_core#handler#get_configurations( + \ { 'target': expand('%:p') } ) + call s:ApplyConfig(l:config) + return 0 " success + catch + return 1 " failure + endtry +endfunction + +function! s:UseConfigFiles_ExternalCommand() +" Use external EditorConfig core (e.g., the C core) + + call s:DisableShellSlash() + let l:exec_path = shellescape(s:editorconfig_exec_path) + call s:ResetShellSlash() + + call s:SpawnExternalParser(l:exec_path) +endfunction + +function! s:SpawnExternalParser(cmd) " {{{2 +" Spawn external EditorConfig. Used by s:UseConfigFiles_ExternalCommand() + + let l:cmd = a:cmd + + if empty(l:cmd) + throw 'No cmd provided' + endif + + let l:config = {} + + call s:DisableShellSlash() + let l:cmd = l:cmd . ' ' . shellescape(expand('%:p')) + call s:ResetShellSlash() + + let l:parsing_result = split(system(l:cmd), '\v[\r\n]+') + + " if editorconfig core's exit code is not zero, give out an error + " message + if v:shell_error != 0 + echohl ErrorMsg + echo 'Failed to execute "' . l:cmd . '". Exit code: ' . + \ v:shell_error + echo '' + echo 'Message:' + echo l:parsing_result + echohl None + return + endif + + if g:EditorConfig_verbose + echo 'Output from EditorConfig core executable:' + echo l:parsing_result + endif + + for one_line in l:parsing_result + let l:eq_pos = stridx(one_line, '=') + + if l:eq_pos == -1 " = is not found. Skip this line + continue + endif + + let l:eq_left = strpart(one_line, 0, l:eq_pos) + if l:eq_pos + 1 < strlen(one_line) + let l:eq_right = strpart(one_line, l:eq_pos + 1) + else + let l:eq_right = '' + endif + + let l:config[l:eq_left] = l:eq_right + endfor + + call s:ApplyConfig(l:config) +endfunction " }}}2 + +" }}}1 + +function! s:ApplyConfig(config) abort " Set the buffer options {{{1 + " Only process normal buffers (do not treat help files as '.txt' files) + if !empty(&buftype) + return + endif + + if g:EditorConfig_verbose + echo 'Options: ' . string(a:config) + endif + + if s:IsRuleActive('indent_style', a:config) + if a:config["indent_style"] == "tab" + setl noexpandtab + elseif a:config["indent_style"] == "space" + setl expandtab + endif + endif + + if s:IsRuleActive('tab_width', a:config) + let &l:tabstop = str2nr(a:config["tab_width"]) + endif + + if s:IsRuleActive('indent_size', a:config) + " if indent_size is 'tab', set shiftwidth to tabstop; + " if indent_size is a positive integer, set shiftwidth to the integer + " value + if a:config["indent_size"] == "tab" + let &l:shiftwidth = &l:tabstop + let &l:softtabstop = &l:shiftwidth + else + let l:indent_size = str2nr(a:config["indent_size"]) + if l:indent_size > 0 + let &l:shiftwidth = l:indent_size + let &l:softtabstop = &l:shiftwidth + endif + endif + + endif + + if s:IsRuleActive('end_of_line', a:config) && + \ &l:modifiable + if a:config["end_of_line"] == "lf" + setl fileformat=unix + elseif a:config["end_of_line"] == "crlf" + setl fileformat=dos + elseif a:config["end_of_line"] == "cr" + setl fileformat=mac + endif + endif + + if s:IsRuleActive('charset', a:config) && + \ &l:modifiable + if a:config["charset"] == "utf-8" + setl fileencoding=utf-8 + setl nobomb + elseif a:config["charset"] == "utf-8-bom" + setl fileencoding=utf-8 + setl bomb + elseif a:config["charset"] == "latin1" + setl fileencoding=latin1 + setl nobomb + elseif a:config["charset"] == "utf-16be" + setl fileencoding=utf-16be + setl bomb + elseif a:config["charset"] == "utf-16le" + setl fileencoding=utf-16le + setl bomb + endif + endif + + augroup editorconfig_trim_trailing_whitespace + autocmd! BufWritePre + if s:IsRuleActive('trim_trailing_whitespace', a:config) && + \ get(a:config, 'trim_trailing_whitespace', 'false') ==# 'true' + autocmd BufWritePre call s:TrimTrailingWhitespace() + endif + augroup END + + if s:IsRuleActive('insert_final_newline', a:config) + if exists('+fixendofline') + if a:config["insert_final_newline"] == "false" + setl nofixendofline + else + setl fixendofline + endif + elseif exists(':SetNoEOL') == 2 + if a:config["insert_final_newline"] == "false" + silent! SetNoEOL " Use the PreserveNoEOL plugin to accomplish it + endif + endif + endif + + " highlight the columns following max_line_length + if s:IsRuleActive('max_line_length', a:config) && + \ a:config['max_line_length'] != 'off' + let l:max_line_length = str2nr(a:config['max_line_length']) + + if l:max_line_length >= 0 + let &l:textwidth = l:max_line_length + if g:EditorConfig_preserve_formatoptions == 0 + setlocal formatoptions+=tc + endif + endif + + if exists('+colorcolumn') + if l:max_line_length > 0 + if g:EditorConfig_max_line_indicator == 'line' + let &l:colorcolumn = l:max_line_length + 1 + elseif g:EditorConfig_max_line_indicator == 'fill' && + \ l:max_line_length < &l:columns + " Fill only if the columns of screen is large enough + let &l:colorcolumn = join( + \ range(l:max_line_length+1,&l:columns),',') + elseif g:EditorConfig_max_line_indicator == 'exceeding' + let &l:colorcolumn = '' + for l:match in getmatches() + if get(l:match, 'group', '') == 'ColorColumn' + call matchdelete(get(l:match, 'id')) + endif + endfor + call matchadd('ColorColumn', + \ '\%' . (l:max_line_length + 1) . 'v.', 100) + endif + endif + endif + endif + + call editorconfig#ApplyHooks(a:config) +endfunction + +" }}}1 + +function! s:TrimTrailingWhitespace() " {{{1 + if &l:modifiable + " don't lose user position when trimming trailing whitespace + let s:view = winsaveview() + try + silent! keeppatterns keepjumps %s/\s\+$//e + finally + call winrestview(s:view) + endtry + endif +endfunction " }}}1 + +function! s:IsRuleActive(name, config) " {{{1 + return index(g:EditorConfig_disable_rules, a:name) < 0 && + \ has_key(a:config, a:name) +endfunction "}}}1 + +let &cpo = s:saved_cpo +unlet! s:saved_cpo + +" vim: fdm=marker fdc=3 diff --git a/sources_non_forked/editorconfig-vim/tests/core/CMakeLists.txt b/sources_non_forked/editorconfig-vim/tests/core/CMakeLists.txt new file mode 100644 index 00000000..2c124403 --- /dev/null +++ b/sources_non_forked/editorconfig-vim/tests/core/CMakeLists.txt @@ -0,0 +1,53 @@ +# CMakeLists.txt for core testing in +# editorconfig-core-vimscript and editorconfig-vim. + +# Copyright (c) 2011-2019 EditorConfig Team +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# 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 COPYRIGHT HOLDER 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. + +# To perform the test, from the root of the project tree, run +# mkdir build +# cd build +# cmake .. +# ctest . + +cmake_minimum_required(VERSION 3.5) +#set(CMAKE_LEGACY_CYGWIN_WIN32 0) + +# Do not check any compiler +project(editorconfig-core-vimscript NONE) + +enable_testing() + +# The test executable to use +if(NOT WIN32) + set(EDITORCONFIG_CMD "${CMAKE_SOURCE_DIR}/editorconfig") +else() + set(EDITORCONFIG_CMD "${CMAKE_SOURCE_DIR}/editorconfig.bat") +endif() +set(EDITORCONFIG_CMD_IS_TARGET FALSE) + +add_subdirectory(tests) + +# CTestCustom.cmake contains platform-specific test configuration. +configure_file(CTestCustom.cmake ${CMAKE_CURRENT_BINARY_DIR} COPYONLY) diff --git a/sources_non_forked/editorconfig-vim/tests/core/CTestCustom.cmake b/sources_non_forked/editorconfig-vim/tests/core/CTestCustom.cmake new file mode 100644 index 00000000..5452f751 --- /dev/null +++ b/sources_non_forked/editorconfig-vim/tests/core/CTestCustom.cmake @@ -0,0 +1,34 @@ +# CTestCustom.cmake: Skip UTF-8 tests +# Part of editorconfig-vim + +# Copyright (c) 2011-2019 EditorConfig Team +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# 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 COPYRIGHT HOLDER 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. + +# Skip UTF8 tests on Windows for now per +# https://github.com/editorconfig/editorconfig-core-c/pull/31#issue-154810185 +if(WIN32 AND (NOT "$ENV{RUN_UTF8}")) + message(WARNING "Skipping UTF-8 tests on this platform") + set(CTEST_CUSTOM_TESTS_IGNORE ${CTEST_CUSTOM_TESTS_IGNORE} g_utf_8_char) + set(CTEST_CUSTOM_TESTS_IGNORE ${CTEST_CUSTOM_TESTS_IGNORE} utf_8_char) +endif() diff --git a/sources_non_forked/editorconfig-vim/tests/core/ecvbslib.vbs b/sources_non_forked/editorconfig-vim/tests/core/ecvbslib.vbs new file mode 100644 index 00000000..a1e05d24 --- /dev/null +++ b/sources_non_forked/editorconfig-vim/tests/core/ecvbslib.vbs @@ -0,0 +1,171 @@ +' ecvbslib.vbs: VBScript routines for use in +' editorconfig-core-vimscript and editorconfig-vim. +' Copyright (c) 2018--2019 Chris White. All rights reserved. +' Licensed CC-BY-SA, version 3.0 or any later version, at your option. + +' Remove CR and LF in a string +function nocrlf(strin) + nocrlf = Replace(Replace(strin, vbCr, ""), vbLf, "") +end function + +' === Base64 ================================================================ +' from https://stackoverflow.com/a/40118072/2877364 by +' https://stackoverflow.com/users/45375/mklement0 + +' Base64-encodes the specified string. +' Parameter fAsUtf16LE determines how the input text is encoded at the +' byte level before Base64 encoding is applied. +' * Pass False to use UTF-8 encoding. +' * Pass True to use UTF-16 LE encoding. +Function Base64Encode(ByVal sText, ByVal fAsUtf16LE) + + ' Use an aux. XML document with a Base64-encoded element. + ' Assigning the byte stream (array) returned by StrToBytes() to .NodeTypedValue + ' automatically performs Base64-encoding, whose result can then be accessed + ' as the element's text. + With CreateObject("Msxml2.DOMDocument").CreateElement("aux") + .DataType = "bin.base64" + if fAsUtf16LE then + .NodeTypedValue = StrToBytes(sText, "utf-16le", 2) + else + .NodeTypedValue = StrToBytes(sText, "utf-8", 3) + end if + Base64Encode = nocrlf(.Text) ' No line breaks; MSXML adds them. + End With + +End Function + +' Decodes the specified Base64-encoded string. +' If the decoded string's original encoding was: +' * UTF-8, pass False for fIsUtf16LE. +' * UTF-16 LE, pass True for fIsUtf16LE. +Function Base64Decode(ByVal sBase64EncodedText, ByVal fIsUtf16LE) + + Dim sTextEncoding + if fIsUtf16LE Then sTextEncoding = "utf-16le" Else sTextEncoding = "utf-8" + + ' Use an aux. XML document with a Base64-encoded element. + ' Assigning the encoded text to .Text makes the decoded byte array + ' available via .nodeTypedValue, which we can pass to BytesToStr() + With CreateObject("Msxml2.DOMDocument").CreateElement("aux") + .DataType = "bin.base64" + .Text = sBase64EncodedText + Base64Decode = BytesToStr(.NodeTypedValue, sTextEncoding) + End With + +End Function + +' Returns a binary representation (byte array) of the specified string in +' the specified text encoding, such as "utf-8" or "utf-16le". +' Pass the number of bytes that the encoding's BOM uses as iBomByteCount; +' pass 0 to include the BOM in the output. +function StrToBytes(ByVal sText, ByVal sTextEncoding, ByVal iBomByteCount) + + ' Create a text string with the specified encoding and then + ' get its binary (byte array) representation. + With CreateObject("ADODB.Stream") + ' Create a stream with the specified text encoding... + .Type = 2 ' adTypeText + .Charset = sTextEncoding + .Open + .WriteText sText + ' ... and convert it to a binary stream to get a byte-array + ' representation. + .Position = 0 + .Type = 1 ' adTypeBinary + .Position = iBomByteCount ' skip the BOM + StrToBytes = .Read + .Close + End With + +end function + +' Returns a string that corresponds to the specified byte array, interpreted +' with the specified text encoding, such as "utf-8" or "utf-16le". +function BytesToStr(ByVal byteArray, ByVal sTextEncoding) + + If LCase(sTextEncoding) = "utf-16le" then + ' UTF-16 LE happens to be VBScript's internal encoding, so we can + ' take a shortcut and use CStr() to directly convert the byte array + ' to a string. + BytesToStr = CStr(byteArray) + Else ' Convert the specified text encoding to a VBScript string. + ' Create a binary stream and copy the input byte array to it. + With CreateObject("ADODB.Stream") + .Type = 1 ' adTypeBinary + .Open + .Write byteArray + ' Now change the type to text, set the encoding, and output the + ' result as text. + .Position = 0 + .Type = 2 ' adTypeText + .CharSet = sTextEncoding + BytesToStr = .ReadText + .Close + End With + End If + +end function + +' === Runner ================================================================ + +' Run a command, copy its stdout/stderr to ours, and return its exit +' status. +' Modified from https://stackoverflow.com/a/32493083/2877364 by +' https://stackoverflow.com/users/3191599/nate-barbettini . +' See also https://www.vbsedit.com/html/4c5b06ac-dc45-4ec2-aca1-f168bab75483.asp +function RunCommandAndEcho(strCommand) + Const WshRunning = 0 + Const WshFinished = 1 + Const WshFailed = 2 + + Set WshShell = CreateObject("WScript.Shell") + 'WScript.Echo "Running >>" & strCommand & "<<..." + Set WshShellExec = WshShell.Exec(strCommand) + + Do While WshShellExec.Status = WshRunning + 'WScript.Echo "Waiting..." + WScript.Sleep 100 + Loop + + if not WshShellExec.StdOut.AtEndOfStream then + WScript.StdOut.Write(WshShellExec.StdOut.ReadAll()) + end if + + if not WshShellExec.StdErr.AtEndOfStream then + WScript.StdErr.Write(WshShellExec.StdErr.ReadAll()) + end if + + RunCommandAndEcho = WshShellExec.ExitCode +end function + +' === Argument processing =================================================== + +function MakeY64Args(args) + + dim b64args(100) ' 100 = arbitrary max + + ' Make Y64-flavored base64 versions of each arg so we don't have to + ' worry about quoting issues while executing PowerShell. + + idx=0 + For Each arg In args + b64args(idx) = Base64Encode(nocrlf(arg), False) + ' Y64 flavor of Base64 + b64args(idx) = replace( _ + replace( _ + replace(b64args(idx), "+", "."), _ + "/", "_" ), _ + "=", "-") + 'Wscript.Echo cstr(idx) & ": >" & arg & "< = >" & b64args(idx) & "<" + 'Wscript.Echo b64args(idx) + idx = idx+1 + Next + + MakeY64Args = b64args +end function + +Function QuoteForShell(strIn) + QuoteForShell = """" & _ + replace(strIn, """", """""") & """" +End Function diff --git a/sources_non_forked/editorconfig-vim/tests/core/ecvimlib.ps1 b/sources_non_forked/editorconfig-vim/tests/core/ecvimlib.ps1 new file mode 100644 index 00000000..45387d5a --- /dev/null +++ b/sources_non_forked/editorconfig-vim/tests/core/ecvimlib.ps1 @@ -0,0 +1,140 @@ +# ecvimlib.ps1: Editorconfig Vimscript core CLI, PowerShell version, +# library routines. +# Copyright (c) 2018--2019 Chris White. All rights reserved. +# Licensed CC-BY-SA, version 3.0 or any later version, at your option. +# +# N.B.: debug output uses Warning only because those are displayed by default. + +#Requires -Version 3 + +# Get the directory of this script. From +# https://stackoverflow.com/a/5466355/2877364 by +# https://stackoverflow.com/users/23283/jaredpar + +$global:DIR = $PSScriptRoot + +### Set up debugging output ============================================ + +$global:debug=$env:EDITORCONFIG_DEBUG # Debug filename + +if($global:debug -and ($global:debug -notmatch '^/')) { + # Relative to this script unless it starts with a slash. This is because + # cwd is usually not $DIR when testing. + $global:debug="${DIR}/${global:debug}" +} + +### Process args ======================================================= + +function de64_args($argv) { + $argv | % { + $b64 = $_ -replace '-','=' -replace '_','/' -replace '\.','+' + [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($b64)) + } +} + +### Helpers ============================================================ + +# Append a string to $debug in UTF-8 rather than the default UTF-16 +filter global:D($file = $debug) { + if($debug) { + echo $_ | Out-File -FilePath $file -Encoding utf8 -Append + } +} + +# Escape a string for Vim +function global:vesc($str) { + return "'" + ($str -replace "'","''") + "'" +} + +# Escape a string for a command-line argument. +# See https://docs.microsoft.com/en-us/dotnet/api/system.diagnostics.processstartinfo.arguments?view=netframework-4.7.2 +function global:argesc($arg) { + return '"' + ($arg -replace '"','"""') + '"' +} + +### Find the Vim EXE =================================================== + +function global:Find-Vim +{ + if($env:VIM_EXE) { + if($debug) { echo "Using env Vim $($env:VIM_EXE)" | D } + return $env:VIM_EXE + } + + $vims = @(get-childitem 'c:\program files*\vim\**\vim.exe' | ` + sort LastWriteTime -Descending) # @() => always array + + # write-host ($vims | format-table | out-string) # DEBUG + # write-host ($vims | get-member | out-string) + if($vims.count -gt 0) { + if($debug) { echo "Using found Vim $($vims[0].FullName)" | D } + return $vims[0].FullName + } + + throw "Could not find vim.exe. Please set VIM_EXE to the path to your Vim." +} #Find-Vim + +### Runner ============================================================= + +# Run a process with the given arguments. +function global:run_process +{ + param( + [Parameter(Mandatory=$true, Position=0)][string]$run, + [string]$extrapath, + [string]$stdout, # Redirect stdout to this file + [string]$stderr, # Redirect stderr to this file + [string[]]$argv # Arguments to $run + ) + $si = new-object Diagnostics.ProcessStartInfo + if($extrapath) { + $si.EnvironmentVariables['path']+=";${extrapath}" + } + $si.FileName=$run + + # Stringify the arguments (blech) + $argstr = $argv | % { (argesc $_) + ' ' } + $si.Arguments = $argstr; + + if($debug) { echo "Running process $run with arguments >>$argstr<<" | D } + + $si.UseShellExecute=$false + # DEBUG $si.RedirectStandardInput=$true + if($stdout) { + if($debug) { echo "Saving stdout to ${stdout}" | D } + $si.RedirectStandardOutput=$true; + } + if($stderr) { + if($debug) { echo "Saving stderr to ${stderr}" | D } + $si.RedirectStandardError=$true; + } + + $p = [Diagnostics.Process]::Start($si) + # DEBUG $p.StandardInput.Close() # < /dev/null + + $p.WaitForExit() + $retval = $p.ExitCode + + if($stdout) { + echo "Standard output:" | D $stdout + $p.StandardOutput.ReadToEnd() | ` + Out-File -FilePath $stdout -Encoding utf8 -Append + } + + if($stderr) { + echo "Standard error:" | D $stderr + $p.StandardError.ReadToEnd() | ` + Out-File -FilePath $stderr -Encoding utf8 -Append + } + + $p.Close() + + return $retval +} + +if($debug) { + echo "======================================================" | D + Get-Date -format F | D +} + +$global:VIM = Find-Vim diff --git a/sources_non_forked/editorconfig-vim/tests/core/editorconfig b/sources_non_forked/editorconfig-vim/tests/core/editorconfig new file mode 100644 index 00000000..bdb5971d --- /dev/null +++ b/sources_non_forked/editorconfig-vim/tests/core/editorconfig @@ -0,0 +1,219 @@ +#!/bin/bash +# editorconfig: Editorconfig Vimscript core CLI +# Copyright (c) 2018--2019 Chris White. All rights reserved. +# Licensed CC-BY-SA, version 3.0 or any later version, at your option. + +# Documentation {{{1 +helpstr=$(cat<<'EOF' +editorconfig: command-line invoker for the Vimscript editorconfig core + +Normal usage: + editorconfig [-f ] [-b ] + [-x ] + +The default is ".editorconfig". +If -b is given, behave as . +If -x is given, the is included in the debug-output file. + +Other options: + editorconfig -h, --help Show this help + editorconfig -v, --version Show version information + +Environment variables: + VIM_EXE File/path of vim (default "vim") + EDITORCONFIG_DEBUG File/path to which to append debug output + +EOF +) + +# }}}1 + +# Get the directory of this script into $this_script_dir. {{{1 +# From https://stackoverflow.com/a/246128/2877364 by +# https://stackoverflow.com/users/407731 et al. + +this_script_dir= +function get_dir() +{ + local script_source_path="${BASH_SOURCE[0]}" + while [ -h "$script_source_path" ]; do + # resolve $script_source_path until the file is no longer a symlink + this_script_dir="$( cd -P "$( dirname "$script_source_path" )" >/dev/null && pwd )" + script_source_path="$(readlink "$script_source_path")" + [[ $script_source_path != /* ]] && script_source_path="$this_script_dir/$script_source_path" + # if $script_source_path was a relative symlink, we need to resolve + # it relative to the path where the symlink file was located + done + this_script_dir="$( cd -P "$( dirname "$script_source_path" )" >/dev/null && pwd )" +} #get_dir() + +get_dir + +# }}}1 + +# Setup debug output, if $EDITORCONFIG_DEBUG is given {{{1 +debug="${EDITORCONFIG_DEBUG}" # Debug filename +if [[ $debug && $debug != /* ]]; then # Relative to this script unless it + debug="${this_script_dir}/${debug}" # starts with a slash. This is because +fi # cwd is usually not $this_script_dir when testing. +if [[ $debug ]] && ! touch "$debug"; then + echo "Could not write file '$debug' - aborting" 1>&2 + exit 1 +fi + +[[ $debug ]] && echo "$(date) ==================================" >> "$debug" + +# }}}1 + +# Option processing {{{1 + +# Use a manually-specified Vim, if any +if [[ $VIM_EXE ]]; then + vim_pgm="$VIM_EXE" +else + vim_pgm="vim" +fi + +# Command-line options +confname= +ver= +print_ver= +extra_info= + +while getopts 'hvf:b:-:x:' opt ; do + case "$opt" in + (v) print_ver=1 + ;; + + (f) confname="$OPTARG" + ;; + + (b) ver="$OPTARG" + ;; + + (-) case "$OPTARG" in # hacky long-option processing + version) print_ver=1 + ;; + dummy) # A dummy option so that I can test + # list-valued EDITORCONFIG_CMD + ;; + help) echo "$helpstr" + exit 0 + ;; + esac + ;; + + (h) echo "$helpstr" + exit 0 + ;; + + # A way to put the test name into the log + (x) extra_info="$OPTARG" + ;; + + esac +done + +shift $(( $OPTIND - 1 )) + +if [[ $print_ver ]]; then + echo "EditorConfig VimScript Core Version 0.12.2" + exit 0 +fi + +if (( "$#" < 1 )); then + exit 1 +fi + +if [[ $1 = '-' ]]; then + echo "Reading filenames from stdin not yet supported" 1>&2 # TODO + exit 1 +fi + +# }}}1 + +# Build the Vim command line {{{1 + +fn="$(mktemp)" # Vim will write the settings into here. ~stdout. +script_output_fn="${debug:+$(mktemp)}" # Vim's :messages. ~stderr. + +cmd="call editorconfig_core#currbuf_cli({" + +# Names +cmd+="'output':'${fn//\'/\'\'}', " + # filename to put the settings in +[[ $debug ]] && cmd+=" 'dump':'${script_output_fn//\'/\'\'}', " + # where to put debug info + +# Filenames to get the settings for +cmd+="'target':[" +for f in "$@" ; do + cmd+="'${f//\'/\'\'}', " +done +cmd+="]," + # filename to get the settings for + +# Job +cmd+="}, {" +[[ $confname ]] && cmd+="'config':'${confname//\'/\'\'}', " + # config name (e.g., .editorconfig) +[[ $ver ]] && cmd+="'version':'${ver//\'/\'\'}', " + # version number we should behave as +cmd+="})" + +vim_args=( + -c "set runtimepath+=$this_script_dir/../.." + -c "$cmd" +) + +# }}}1 + +# Run the editorconfig core through Vim {{{1 +# Thanks for options to +# http://vim.wikia.com/wiki/Vim_as_a_system_interpreter_for_vimscript . +# Add -V1 to the below for debugging output. +# Do not output anything to stdout or stderr, +# since it messes up ctest's interpretation +# of the results. + +"$vim_pgm" -nNes -i NONE -u NONE -U NONE \ + "${vim_args[@]}" \ + > "${debug:-/dev/null}" +vimstatus="$?" +if [[ $vimstatus -eq 0 ]]; then + cat "$fn" +fi + +# }}}1 + +# Produce debug output {{{1 +# Debug output cannot be included on stdout or stderr, because +# ctest's regex check looks both of those places. Therefore, dump to a +# separate debugging file. +if [[ $debug ]] +then + [[ $extra_info ]] && echo "--- $extra_info ---" >> "$debug" + echo "Vim in $vim_pgm" >> "$debug" + echo "Current directory: $(pwd)" >> "$debug" + echo "Script directory: $this_script_dir" >> "$debug" + echo Vim args: "${vim_args[@]}" >> "$debug" + #od -c <<<"${vim_args[@]}" >> "$debug" + echo "Vim returned $vimstatus" >> "$debug" + echo "Vim messages were: " >> "$debug" + cat "$script_output_fn" >> "$debug" + echo "Output was:" >> "$debug" + od -c "$fn" >> "$debug" + + rm -f "$script_output_fn" +fi + +# }}}1 + +# Cleanup {{{1 + +rm -f "$fn" + +# }}}1 + +exit "$vimstatus" # forward the Vim exit status to the caller +# vi: set ft=sh fdm=marker: diff --git a/sources_non_forked/editorconfig-vim/tests/core/editorconfig.bat b/sources_non_forked/editorconfig-vim/tests/core/editorconfig.bat new file mode 100644 index 00000000..77b54470 --- /dev/null +++ b/sources_non_forked/editorconfig-vim/tests/core/editorconfig.bat @@ -0,0 +1,11 @@ +@echo off +:: editorconfig.bat: First-level invoker for editorconfig-core-vimscript +:: and editorconfig-vim. +:: Just passes the full command line to editorconfig1.vbs, since VBScript +:: applies very simple quoting rules when it parses a command line. +:: Copyright (c) 2018--2019 Chris White. All rights reserved. +:: Licensed CC-BY-SA, version 3.0 or any later version, at your option. +set here=%~dp0 + +cscript //Nologo "%here%editorconfig1.vbs" %* +:: %* has the whole command line diff --git a/sources_non_forked/editorconfig-vim/tests/core/editorconfig1.vbs b/sources_non_forked/editorconfig-vim/tests/core/editorconfig1.vbs new file mode 100644 index 00000000..488411fc --- /dev/null +++ b/sources_non_forked/editorconfig-vim/tests/core/editorconfig1.vbs @@ -0,0 +1,39 @@ +' editorconfig1.vbs: run by editorconfig.bat +' runs editorconfig2.ps1 +' Part of editorconfig-core-vimscript and editorconfig-vim. +' +' Copyright (c) 2018--2019 Chris White. All rights reserved. +' Licensed CC-BY-SA, version 3.0 or any later version, at your option. +' +' Modified from +' https://stackoverflow.com/a/2470557/2877364 by +' https://stackoverflow.com/users/2441/aphoria + +' Thanks to https://www.geekshangout.com/vbs-script-to-get-the-location-of-the-current-script/ +currentScriptPath = Replace(WScript.ScriptFullName, WScript.ScriptName, "") + +' Load our common library. Thanks to https://stackoverflow.com/a/316169/2877364 +With CreateObject("Scripting.FileSystemObject") + executeGlobal .openTextFile(currentScriptPath & "ecvbslib.vbs").readAll() +End With + +' === MAIN ================================================================== + +' Encode all the arguments as modified base64 so there will be no quoting +' issues when we invoke powershell. +b64args = MakeY64Args(Wscript.Arguments) + +' Quote script name just in case +ps1name = QuoteForShell(currentScriptPath & "editorconfig2.ps1") +'Wscript.Echo "Script is in " & ps1name + +if True then + retval = RunCommandAndEcho( "powershell.exe" & _ + " -executionpolicy bypass -file " & ps1name & " " & join(b64args) _ + ) + ' add -noexit to leave window open so you can see error messages + + WScript.Quit retval +end if + +' vi: set ts=4 sts=4 sw=4 et ai: diff --git a/sources_non_forked/editorconfig-vim/tests/core/editorconfig2.ps1 b/sources_non_forked/editorconfig-vim/tests/core/editorconfig2.ps1 new file mode 100644 index 00000000..0bc3602a --- /dev/null +++ b/sources_non_forked/editorconfig-vim/tests/core/editorconfig2.ps1 @@ -0,0 +1,218 @@ +# editorconfig2.ps1: Editorconfig Vimscript core CLI, PowerShell version +# Copyright (c) 2018--2019 Chris White. All rights reserved. +# Licensed CC-BY-SA, version 3.0 or any later version, at your option. +# Thanks to https://cecs.wright.edu/~pmateti/Courses/233/Labs/Scripting/bashVsPowerShellTable.html +# by Gallagher and Mateti. + +#Requires -Version 3 + +. "$PSScriptRoot\ecvimlib.ps1" + +# Argument parsing =================================================== {{{1 + +$argv = @(de64_args($args)) + +# Defaults +$report_version = $false +$set_version = '' +$config_name = '.editorconfig' +$extra_info = '' +$files=@() + +# Hand-parse - pretend we're sort of like getopt. +$idx = 0 +while($idx -lt $argv.count) { + $a = $argv[$idx] + + switch -CaseSensitive -Regex ($a) { + '^(-v|--version)$' { $report_version = $true } + + '^--dummy$' { + # A dummy option so that I can test list-valued EDITORCONFIG_CMD + } + + '^-f$' { + if($idx -eq ($argv.count-1)) { + throw '-f : no filename provided' + } else { + ++$idx + $config_name = $argv[$idx] + } + } #-f + + '^-b$' { + if($idx -eq ($argv.count-1)) { + throw '-b : no version provided' + } else { + ++$idx + $set_version = $argv[$idx] + } + } #-b + + '^-x$' { + if($idx -eq ($argv.count-1)) { + throw '-x : no info provided' + } else { + ++$idx + $extra_info = $argv[$idx] + } + } #-x + + '^--$' { # End of options, so capture the rest as filenames + ++$idx; + while($idx -lt $argv.count) { + $files += $argv[$idx] + } + } + + default { $files += $a } + } + + ++$idx +} # end foreach argument + +# }}}1 +# Argument processing ================================================ {{{1 + +if($debug) { + if($extra_info -ne '') { + echo "--- $extra_info --- " | D + } + + echo "Running in $DIR" | D + echo "Vim executable: $VIM" | D + echo "report version? $report_version" | D + echo "set version to: $set_version" | D + echo "config filename: $config_name" | D + echo "Filenames: $files" | D + echo "Args: $args" | D + echo "Decoded args: $argv" | D +} + +if($report_version) { + echo "EditorConfig VimScript Core Version 0.12.2" + exit +} + +if($files.count -lt 1) { + exit +} + +if($files[0] -eq '-') { + echo "Reading filenames from stdin not yet supported" # TODO + exit 1 +} + +$fn=[System.IO.Path]::GetTempFileName(); + # Vim will write the settings into here. Sort of like stdout. +$script_output_fn = '' +if($debug) { + $script_output_fn = [System.IO.Path]::GetTempFileName() +} + +# Permit throwing in setup commands +$cmd = '' +if($env:EDITORCONFIG_EXTRA) { + $cmd += $env:EDITORCONFIG_EXTRA + ' | ' +} + +# }}}1 +# Build Vim command line ============================================= {{{1 +$cmd += 'call editorconfig_core#currbuf_cli({' + +# Names +$cmd += "'output':" + (vesc($fn)) + ", " + # filename to put the settings in +if($debug) { + $cmd += " 'dump':" + (vesc($script_output_fn)) + ", " + # where to put debug info +} + +# Filenames to get the settings for +$cmd += "'target':[" +ForEach ($item in $files) { + $cmd += (vesc($item)) + ", " +} +$cmd += "]," + +# Job +$cmd += "}, {" +if($config_name) { $cmd += "'config':" + (vesc($config_name)) + ", " } + # config name (e.g., .editorconfig) +if($set_version) { $cmd += "'version':" + (vesc($set_version)) + ", " } + # version number we should behave as +$cmd += "})" + +#$cmd =':q!' # DEBUG +if($debug) { echo "Using Vim command ${cmd}" | D } +$vim_args = @( + '-c', "set runtimepath+=${DIR}\..\..", + '-c', $cmd, + '-c', 'quit!' # TODO write a wrapper that will cquit on exception +) + +# Run editorconfig. Thanks for options to +# http://vim.wikia.com/wiki/Vim_as_a_system_interpreter_for_vimscript . +# Add -V1 to the below for debugging output. +# Do not output anything to stdout or stderr, +# since it messes up ctest's interpretation +# of the results. + +$basic_args = '-nNes','-i','NONE','-u','NONE','-U','NONE' #, '-V1' + +# }}}1 +# Run Vim ============================================================ {{{1 + +if($debug) { echo "Running vim ${VIM}" | D } +$vimstatus = run_process $VIM -stdout $debug -stderr $debug ` + -argv ($basic_args+$vim_args) +if($debug) { echo "Done running vim" | D } + +if($vimstatus -eq 0) { + cat $fn +} + +# }}}1 +# Produce debug output =============================================== {{{1 + +# Debug output cannot be included on stdout or stderr, because +# ctest's regex check looks both of those places. Therefore, dump to a +# separate debugging file. + +if($debug) { + echo "Current directory:" | D + (get-item -path '.').FullName | D + echo "Script directory: $DIR" | D +### echo Vim args: "${vim_args[@]}" >> "$debug" +### #od -c <<<"${vim_args[@]}" >> "$debug" + echo "Vim returned $vimstatus" | D + echo "Vim messages were: " | D + cat $script_output_fn | D + echo "Output was:" | D + + # Modified from https://www.itprotoday.com/powershell/get-hex-dumps-files-powershell + Get-Content $script_output_fn -Encoding Byte -ReadCount 16 | ` + ForEach-Object { + $output = "" + $chars = '' + foreach ( $byte in $_ ) { + $output += "{0:X2} " -f $byte + if( ($byte -ge 32) -and ($byte -le 127) ) { + $chars += [char]$byte + } else { + $chars += '.' + } + } + $output + ' ' + $chars + } | D + + del -Force $script_output_fn +} #endif $debug + +# }}}1 + +del -Force $fn + +exit $vimstatus + +# vi: set fdm=marker: diff --git a/sources_non_forked/editorconfig-vim/tests/fetch-vim.bat b/sources_non_forked/editorconfig-vim/tests/fetch-vim.bat new file mode 100644 index 00000000..c834fd74 --- /dev/null +++ b/sources_non_forked/editorconfig-vim/tests/fetch-vim.bat @@ -0,0 +1,12 @@ +:: fetch-vim.bat: Fetch vim if necessary +:: For use in the editorconfig-vim Appveyor build +:: Copyright (c) 2018--2019 Chris White. All rights reserved. +:: Licensed Apache 2.0, or any later version, at your option. + +:: If it's already been loaded from the cache, we're done +if exist C:\vim\vim\vim80\vim.exe exit + +:: Otherwise, download and unzip it. +appveyor DownloadFile https://github.com/cxw42/editorconfig-core-vimscript/releases/download/v0.1.0/vim.7z + +7z x vim.7z -oC:\vim diff --git a/sources_non_forked/editorconfig-vim/tests/fetch-vim.sh b/sources_non_forked/editorconfig-vim/tests/fetch-vim.sh new file mode 100644 index 00000000..22e7912a --- /dev/null +++ b/sources_non_forked/editorconfig-vim/tests/fetch-vim.sh @@ -0,0 +1,41 @@ +#!/bin/bash +# fetch-vim.bat: Fetch vim if necessary +# For use in the editorconfig-vim Appveyor build +# Copyright (c) 2018--2019 Chris White. All rights reserved. +# Licensed Apache 2.0, or any later version, at your option. + +# Debugging +set -x +set -o nounset +#set -o errexit + +# Basic system info +uname -a +pwd +ls -l + +echo "VIM_EXE: $VIM_EXE" +set + +# If it's already been loaded from the cache, we're done +if [[ -x "$VIM_EXE" ]]; then + echo Vim found in cache at "$VIM_EXE" + exit 0 +fi + +# Otherwise, clone and build it +WHITHER="$APPVEYOR_BUILD_FOLDER/vim" + +git clone https://github.com/vim/vim-appimage.git +cd vim-appimage +git submodule update --init --recursive + +cd vim/src +./configure --with-features=huge --prefix="$WHITHER" --enable-fail-if-missing +make -j2 # Free tier provides two cores +make install +./vim --version +cd $APPVEYOR_BUILD_FOLDER +find . -type f -name vim -exec ls -l {} + + +echo Done fetching and installing vim diff --git a/sources_non_forked/editorconfig-vim/tests/plugin/.gitignore b/sources_non_forked/editorconfig-vim/tests/plugin/.gitignore new file mode 100644 index 00000000..cee07667 --- /dev/null +++ b/sources_non_forked/editorconfig-vim/tests/plugin/.gitignore @@ -0,0 +1,2 @@ +# Where bundler installs local Gemfile dependencies +/vendor/ diff --git a/sources_non_forked/editorconfig-vim/tests/plugin/Gemfile b/sources_non_forked/editorconfig-vim/tests/plugin/Gemfile new file mode 100644 index 00000000..49270e49 --- /dev/null +++ b/sources_non_forked/editorconfig-vim/tests/plugin/Gemfile @@ -0,0 +1,5 @@ +source 'https://rubygems.org' + +gem 'rake', '~> 12.3.3' +gem 'rspec', '~> 3.4.0' +gem 'vimrunner', '~> 0.3.1' diff --git a/sources_non_forked/editorconfig-vim/tests/plugin/Gemfile.lock b/sources_non_forked/editorconfig-vim/tests/plugin/Gemfile.lock new file mode 100644 index 00000000..5d1c3f47 --- /dev/null +++ b/sources_non_forked/editorconfig-vim/tests/plugin/Gemfile.lock @@ -0,0 +1,27 @@ +GEM + remote: https://rubygems.org/ + specs: + diff-lcs (1.2.5) + rake (12.3.3) + rspec (3.4.0) + rspec-core (~> 3.4.0) + rspec-expectations (~> 3.4.0) + rspec-mocks (~> 3.4.0) + rspec-core (3.4.1) + rspec-support (~> 3.4.0) + rspec-expectations (3.4.0) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.4.0) + rspec-mocks (3.4.0) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.4.0) + rspec-support (3.4.1) + vimrunner (0.3.1) + +PLATFORMS + ruby + +DEPENDENCIES + rake (~> 12.3.3) + rspec (~> 3.4.0) + vimrunner (~> 0.3.1) diff --git a/sources_non_forked/editorconfig-vim/tests/plugin/Rakefile b/sources_non_forked/editorconfig-vim/tests/plugin/Rakefile new file mode 100644 index 00000000..3119d82e --- /dev/null +++ b/sources_non_forked/editorconfig-vim/tests/plugin/Rakefile @@ -0,0 +1,8 @@ +# +# run `rake` to run tests + +require 'rspec/core/rake_task' + +RSpec::Core::RakeTask.new(:spec) + +task :default => :spec diff --git a/sources_non_forked/editorconfig-vim/tests/plugin/spec/.editorconfig b/sources_non_forked/editorconfig-vim/tests/plugin/spec/.editorconfig new file mode 100644 index 00000000..834f0eb3 --- /dev/null +++ b/sources_non_forked/editorconfig-vim/tests/plugin/spec/.editorconfig @@ -0,0 +1,4 @@ +[*.rb] +indent_style = space +indent_size = 2 +end_of_line = lf diff --git a/sources_non_forked/editorconfig-vim/tests/plugin/spec/editorconfig_spec.rb b/sources_non_forked/editorconfig-vim/tests/plugin/spec/editorconfig_spec.rb new file mode 100644 index 00000000..0b3e654b --- /dev/null +++ b/sources_non_forked/editorconfig-vim/tests/plugin/spec/editorconfig_spec.rb @@ -0,0 +1,161 @@ +require 'vimrunner' + +def create_vim(*initial_commands) + vim = Vimrunner.start + initial_commands.each do |cmd| + vim.command cmd + end + vim.add_plugin(File.expand_path('../../../..', __FILE__), 'plugin/editorconfig.vim') + return vim +end + +# The base path of the testing files +BASE_PATH = File.expand_path('../plugin_tests/test_files/', __FILE__) + +# file_name is the file name that should be open by Vim +# expected_values is a Hash that contains all the Vim options we need to test +def test_editorconfig(vim, file_name, expected_values) + vim.edit(File.join(BASE_PATH, file_name)) + + expected_values.each do |key, val| + expect(vim.echo("&l:#{key}")).to eq(val) + end + + vim.command 'bd!' +end + +def test_instance(vim) + describe 'plugin/editorconfig.vim' do + after(:all) do + vim.kill + end + + describe '#all' do + it '3_space.py' do + test_editorconfig vim, '3_space.txt', + expandtab: '1', + shiftwidth: '3', + tabstop: '3' + end + end + + it '4_space.py' do + test_editorconfig vim, '4_space.py', + expandtab: '1', + shiftwidth: '4', + tabstop: '8' + end + + it 'space.txt' do + test_editorconfig vim, 'space.txt', + expandtab: '1', + shiftwidth: vim.echo('&l:tabstop') + end + + it 'tab.txt' do + test_editorconfig vim, 'tab.txt', + expandtab: '0' + end + + it '4_tab.txt' do + test_editorconfig vim, '4_tab.txt', + expandtab: '0', + shiftwidth: '4', + tabstop: '4' + end + + it '4_tab_width_of_8' do + test_editorconfig vim, '4_tab_width_of_8.txt', + expandtab: '0', + shiftwidth: '4', + tabstop: '8' + end + + it 'lf.txt' do + test_editorconfig vim, 'lf.txt', + fileformat: 'unix' + end + + it 'crlf.txt' do + test_editorconfig vim, 'crlf.txt', + fileformat: 'dos' + end + + it 'cr.txt' do + test_editorconfig vim, 'cr.txt', + fileformat: 'mac' + end + + it 'utf-8.txt' do + test_editorconfig vim, 'utf-8.txt', + fileencoding: 'utf-8', + bomb: '0' + end + + it 'utf-8-bom.txt' do + test_editorconfig vim, 'utf-8-bom.txt', + fileencoding: 'utf-8', + bomb: '1' + end + + it 'utf-16be.txt' do + test_editorconfig vim, 'utf-16be.txt', + fileencoding: 'utf-16' + end + + it 'utf-16le.txt' do + test_editorconfig vim, 'utf-16le.txt', + fileencoding: 'utf-16le' + end + + it 'latin1.txt' do + test_editorconfig vim, 'latin1.txt', + fileencoding: 'latin1' + end + + # insert_final_newline by PreserveNoEOL tests are omitted, since they are not supported + if vim.echo("exists('+fixendofline')") == '1' + it 'with_newline.txt' do + test_editorconfig vim, 'with_newline.txt', + fixendofline: '1' + end + + it 'without_newline.txt' do + test_editorconfig vim, 'without_newline.txt', + fixendofline: '0' + end + end + end +end + +# Test the vim core +(lambda do + puts 'Testing default' + vim = create_vim + test_instance vim +end).call + +# Test the vim core with an express setting +(lambda do + puts 'Testing with express vim_core mode' + vim = create_vim("let g:EditorConfig_core_mode='vim_core'") + test_instance vim +end).call + +# Test with external-core mode, but no external core defined +(lambda do + puts 'Testing with fallback to vim_core mode' + vim = create_vim("let g:EditorConfig_core_mode='external_command'") + test_instance vim +end).call + +# Test with an external core, if desired +extcore = ENV['EDITORCONFIG_VIM_EXTERNAL_CORE'] +if extcore + puts "Testing with external_command #{extcore}" + vim = create_vim( + "let g:EditorConfig_core_mode='external_command'", + "let g:EditorConfig_exec_path='#{extcore}'", + ) + test_instance vim +end diff --git a/sources_non_forked/editorconfig-vim/tests/travis-test.sh b/sources_non_forked/editorconfig-vim/tests/travis-test.sh new file mode 100644 index 00000000..76022a03 --- /dev/null +++ b/sources_non_forked/editorconfig-vim/tests/travis-test.sh @@ -0,0 +1,45 @@ +#!/bin/bash +# travis-test.sh: Script for running editorconfig-vim tests under Travis CI. +# Copyright (c) 2019 Chris White. All rights reserved. +# Licensed Apache, version 2.0 or any later version, at your option. + +# Error exit; debug output +set -vxEeuo pipefail + +# Permit `travis-test.sh plugin` if TEST_WHICH is unset +if [[ ( ! "${TEST_WHICH:-}" ) && "${1:-}" ]]; then + export TEST_WHICH="$1" +fi + +if [[ "$TEST_WHICH" = 'plugin' ]]; then # test plugin + + # If not running from Travis, do what Travis would have + # done for us. + if [[ ! "${BUNDLE_GEMFILE:-}" ]]; then + here="$(cd "$(dirname "$0")" &>/dev/null ; pwd)" + export BUNDLE_GEMFILE="${here}/plugin/Gemfile" + # Install into tests/plugin/vendor. Don't clear it first, + # since you can clear it yourself if you're running from a + # dev environment. + bundle install --jobs=3 --retry=3 --deployment + fi + + # Use the standalone Vimscript EditorConfig core to test the plugin's + # external_command mode + export EDITORCONFIG_VIM_EXTERNAL_CORE=tests/core/editorconfig + + bundle exec rspec tests/plugin/spec/editorconfig_spec.rb + +elif [[ "$TEST_WHICH" = 'core' ]]; then # test core + cd tests/core + mkdir -p build # May already exist if running from a dev env + cd build + cmake .. + ctest . --output-on-failure -VV -C Debug + # -C Debug: for Visual Studio builds, you have to specify + # a configuration. + +else + echo 'Invalid TEST_WHICH value' 1>&2 + exit 1 +fi diff --git a/sources_non_forked/lightline-ale/LICENSE b/sources_non_forked/lightline-ale/LICENSE index a69d8868..ef1d8a84 100644 --- a/sources_non_forked/lightline-ale/LICENSE +++ b/sources_non_forked/lightline-ale/LICENSE @@ -1,21 +1,15 @@ -MIT License +ISC License -Copyright (c) 2017 Maxim Baz +Copyright (c) 2017-2021, Maxim Baz -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. diff --git a/sources_non_forked/lightline-ale/README.md b/sources_non_forked/lightline-ale/README.md index ebfbc7e6..78a1e853 100644 --- a/sources_non_forked/lightline-ale/README.md +++ b/sources_non_forked/lightline-ale/README.md @@ -6,17 +6,17 @@ This plugin provides [ALE](https://github.com/w0rp/ale) indicator for the [light ## Table Of Contents -* [Installation](#installation) -* [Integration](#integration) -* [Configuration](#configuration) -* [License](#license) +- [Installation](#installation) +- [Integration](#integration) +- [Configuration](#configuration) +- [License](#license) ## Installation Install using a plugin manager of your choice, for example: ```viml -call dein#add('w0rp/ale') " Dependency: linter +call dein#add('dense-analysis/ale') " Dependency: linter call dein#add('itchyny/lightline.vim') " Dependency: status line call dein#add('maximbaz/lightline-ale') ``` @@ -55,6 +55,17 @@ let g:lightline.component_type = { let g:lightline.active = { 'right': [[ 'linter_checking', 'linter_errors', 'linter_warnings', 'linter_infos', 'linter_ok' ]] } ``` +3.1. Lineinfo, fileformat, etc. have to be added additionaly. Final example: + +```viml +let g:lightline.active = { + \ 'right': [ [ 'linter_checking', 'linter_errors', 'linter_warnings', 'linter_infos', 'linter_ok' ], + \ [ 'lineinfo' ], + \ [ 'percent' ], + \ [ 'fileformat', 'fileencoding', 'filetype'] ] } + +``` + ## Configuration ##### `g:lightline#ale#indicator_checking` @@ -83,18 +94,18 @@ If you would like to replace the default indicators with symbols like on the scr The following icons from the Font Awesome font are used in the screenshot: -* Checking: [f110](https://fontawesome.com/icons/spinner) -* Infos: [f129](https://fontawesome.com/icons/info) -* Warnings: [f071](https://fontawesome.com/icons/exclamation-triangle) -* Errors: [f05e](https://fontawesome.com/icons/ban) -* OK: [f00c](https://fontawesome.com/icons/check) (although I prefer to disable this component) +- Checking: [f110](https://fontawesome.com/icons/spinner) +- Infos: [f129](https://fontawesome.com/icons/info) +- Warnings: [f071](https://fontawesome.com/icons/exclamation-triangle) +- Errors: [f05e](https://fontawesome.com/icons/ban) +- OK: [f00c](https://fontawesome.com/icons/check) (although I prefer to disable this component) To specify icons in the configuration, use their unicode codes as `"\uXXXX"` (make sure to wrap them in double quotes). Alternatively copy the icons from a font website, or type \u\<4-digit-unicode\> or \U\<8-digit-unicode\> to insert the literal characters. See the code points here: -* Font Awesome: https://fontawesome.com/icons -* Nerd Fonts: https://github.com/ryanoasis/nerd-fonts#glyph-sets +- Font Awesome: https://fontawesome.com/icons +- Nerd Fonts: https://github.com/ryanoasis/nerd-fonts#glyph-sets Here's the configuration snippet used in the screenshot: @@ -108,4 +119,4 @@ let g:lightline#ale#indicator_ok = "\uf00c" ## License -Released under the [MIT License](LICENSE) +Released under the [ISC License](LICENSE) diff --git a/sources_non_forked/lightline.vim/.github/workflows/ci.yaml b/sources_non_forked/lightline.vim/.github/workflows/ci.yaml index 7d2a185b..411c7023 100644 --- a/sources_non_forked/lightline.vim/.github/workflows/ci.yaml +++ b/sources_non_forked/lightline.vim/.github/workflows/ci.yaml @@ -21,9 +21,9 @@ jobs: - v7.3 steps: - name: Checkout code - uses: actions/checkout@main + uses: actions/checkout@v2 - name: Checkout vim-themis - uses: actions/checkout@main + uses: actions/checkout@v2 with: repository: thinca/vim-themis path: vim-themis diff --git a/sources_non_forked/lightline.vim/LICENSE b/sources_non_forked/lightline.vim/LICENSE index ee9e0c80..3aab9e6a 100644 --- a/sources_non_forked/lightline.vim/LICENSE +++ b/sources_non_forked/lightline.vim/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2013-2020 itchyny +Copyright (c) 2013-2021 itchyny Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/sources_non_forked/lightline.vim/README.md b/sources_non_forked/lightline.vim/README.md index 41f98022..c2975e05 100644 --- a/sources_non_forked/lightline.vim/README.md +++ b/sources_non_forked/lightline.vim/README.md @@ -11,44 +11,29 @@ https://github.com/itchyny/lightline.vim ![lightline.vim - wombat](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/wombat.png) -### jellybeans +### solarized (`background=dark`) -![lightline.vim - jellybeans](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/jellybeans.png) +![lightline.vim - solarized_dark](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/solarized_dark.png) -### solarized dark +### solarized (`background=light`) -![lightline.vim - solarized dark](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/solarized_dark.png) +![lightline.vim - solarized_light](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/solarized_light.png) -### solarized light +### PaperColor (`background=dark`) -![lightline.vim - solarized light](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/solarized_light.png) +![lightline.vim - PaperColor_dark](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/PaperColor_dark.png) -### PaperColor dark +### PaperColor (`background=light`) -![lightline.vim - PaperColor dark](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/PaperColor_dark.png) +![lightline.vim - PaperColor_light](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/PaperColor_light.png) -### PaperColor light +### one (`background=dark`) -![lightline.vim - PaperColor light](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/PaperColor_light.png) +![lightline.vim - one_dark](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/one_dark.png) -### seoul256 - -![lightline.vim - seoul256](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/seoul256.png) - -### one dark - -![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 - -![lightline.vim - landscape](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/landscape.png) - -landscape is my colorscheme, which is a high-contrast cterm-supported colorscheme, available at https://github.com/itchyny/landscape.vim +### one (`background=light`) +![lightline.vim - one_light](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/one_light.png) For screenshots of all available colorshemes, see [this file](colorscheme.md). diff --git a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/apprentice.vim b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/apprentice.vim new file mode 100644 index 00000000..77d40bad --- /dev/null +++ b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/apprentice.vim @@ -0,0 +1,46 @@ +" ============================================================================= +" Filename: autoload/lightline/colorscheme/apprentice.vim +" Author: pt307 (based on work by romainl) +" License: MIT License +" Last Change: 2021/03/02 18:25:22. +" ============================================================================= + +" For the Apprentice colorscheme + +let s:almost_black = [ '#1c1c1c', 234 ] +let s:darker_grey = [ '#262626', 235 ] +let s:medium_grey = [ '#585858', 240 ] +let s:lighter_grey = [ '#bcbcbc', 250 ] +let s:green = [ '#5f875f', 65 ] +let s:red = [ '#af5f5f', 131 ] +let s:orange = [ '#ff8700', 208 ] +let s:ocre = [ '#87875f', 101 ] +let s:yellow = [ '#ffffaf', 229 ] + +let s:p = {'normal': {}, 'inactive': {}, 'insert': {}, 'replace': {}, 'visual': {}, 'tabline': {}} + +let s:p.normal.left = [ [ s:darker_grey, s:ocre ], [ s:darker_grey, s:medium_grey ] ] +let s:p.normal.middle = [ [ s:lighter_grey, s:darker_grey ] ] +let s:p.normal.right = [ [ s:darker_grey, s:ocre ], [ s:darker_grey, s:medium_grey ] ] +let s:p.normal.warning = [ [ s:almost_black, s:orange ] ] +let s:p.normal.error = [ [ s:almost_black, s:red ] ] + +let s:p.inactive.left = [ [ s:darker_grey, s:medium_grey ] ] +let s:p.inactive.middle = [ [ s:medium_grey, s:darker_grey ] ] +let s:p.inactive.right = [ [ s:darker_grey, s:medium_grey ] ] + +let s:p.insert.left = [ [ s:darker_grey, s:green ], [ s:darker_grey, s:medium_grey ] ] +let s:p.insert.right = [ [ s:darker_grey, s:green ], [ s:darker_grey, s:medium_grey ] ] + +let s:p.replace.left = [ [ s:darker_grey, s:red ], [ s:darker_grey, s:medium_grey ] ] +let s:p.replace.right = [ [ s:darker_grey, s:red ], [ s:darker_grey, s:medium_grey ] ] + +let s:p.visual.left = [ [ s:darker_grey, s:yellow ], [ s:darker_grey, s:medium_grey ] ] +let s:p.visual.right = [ [ s:darker_grey, s:yellow ], [ s:darker_grey, s:medium_grey ] ] + +let s:p.tabline.left = [ [ s:darker_grey, s:medium_grey ] ] +let s:p.tabline.middle = [ [ s:lighter_grey, s:darker_grey ] ] +let s:p.tabline.right = [ [ s:darker_grey, s:medium_grey ] ] +let s:p.tabline.tabsel = [ [ s:darker_grey, s:ocre ] ] + +let g:lightline#colorscheme#apprentice#palette = lightline#colorscheme#flatten(s:p) diff --git a/sources_non_forked/lightline.vim/colorscheme.md b/sources_non_forked/lightline.vim/colorscheme.md index fefe85fe..e9dd87f6 100644 --- a/sources_non_forked/lightline.vim/colorscheme.md +++ b/sources_non_forked/lightline.vim/colorscheme.md @@ -16,45 +16,45 @@ ![lightline.vim - OldHope](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/OldHope.png) -### PaperColor dark +### PaperColor (`background=dark`) -![lightline.vim - PaperColor dark](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/PaperColor_dark.png) +![lightline.vim - PaperColor_dark](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/PaperColor_dark.png) -### PaperColor light +### PaperColor (`background=light`) -![lightline.vim - PaperColor light](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/PaperColor_light.png) +![lightline.vim - PaperColor_light](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/PaperColor_light.png) ### Tomorrow ![lightline.vim - Tomorrow](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/Tomorrow.png) -### Tomorrow Night +### Tomorrow_Night -![lightline.vim - Tomorrow Night](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/Tomorrow_Night.png) +![lightline.vim - Tomorrow_Night](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/Tomorrow_Night.png) -### Tomorrow Night Blue +### Tomorrow_Night_Blue -![lightline.vim - Tomorrow Night Blue](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/Tomorrow_Night_Blue.png) +![lightline.vim_- Tomorrow_Night_Blue](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/Tomorrow_Night_Blue.png) -### Tomorrow Night Bright +### Tomorrow_Night_Bright -![lightline.vim - Tomorrow Night Bright](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/Tomorrow_Night_Bright.png) +![lightline.vim - Tomorrow_Night_Bright](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/Tomorrow_Night_Bright.png) -### Tomorrow Night Eighties +### Tomorrow_Night_Eighties -![lightline.vim - Tomorrow Night Eighties](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/Tomorrow_Night_Eighties.png) +![lightline.vim - Tomorrow_Night_Eighties](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/Tomorrow_Night_Eighties.png) ### ayu_mirage -![lightline.vim - ayu mirage](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/ayu_mirage.png) +![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) +![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) +![lightline.vim - ayu_dark](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/ayu_dark.png) ### darcula @@ -68,29 +68,29 @@ ![lightline.vim - jellybeans](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/jellybeans.png) -### selenized dark +### selenized_dark -![lightline.vim - selenized dark](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/selenized_dark.png) +![lightline.vim - selenized_dark](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/selenized_dark.png) -### selenized black +### selenized_black -![lightline.vim - selenized black](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/selenized_black.png) +![lightline.vim - selenized_black](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/selenized_black.png) -### selenized light +### selenized_light -![lightline.vim - selenized light](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/selenized_light.png) +![lightline.vim - selenized_light](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/selenized_light.png) -### selenized white +### selenized_white -![lightline.vim - selenized white](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/selenized_white.png) +![lightline.vim - selenized_white](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/selenized_white.png) -### solarized dark +### solarized (`background=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 +### solarized (`background=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 @@ -112,13 +112,13 @@ ![lightline.vim - seoul256](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/seoul256.png) -### one dark +### one (`background=dark`) -![lightline.vim - one dark](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/one_dark.png) +![lightline.vim - one_dark](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/one_dark.png) -### one light +### one (`background=light`) -![lightline.vim - one light](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/one_light.png) +![lightline.vim - one_light](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/one_light.png) ### srcery_drk @@ -128,14 +128,18 @@ ![lightline.vim - simpleblack](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/simpleblack.png) +### apprentice + +![lightline.vim - apprentice](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/apprentice.png) + ### landscape ![lightline.vim - landscape](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/landscape.png) -### 16color dark +### 16color (`background=dark`) -![lightline.vim - 16color dark](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/16color_dark.png) +![lightline.vim - 16color_dark](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/16color_dark.png) -### 16color light +### 16color (`background=light`) -![lightline.vim - 16color light](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/16color_light.png) +![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 bebc1e04..767c0075 100644 --- a/sources_non_forked/lightline.vim/doc/lightline.txt +++ b/sources_non_forked/lightline.vim/doc/lightline.txt @@ -232,8 +232,8 @@ OPTIONS *lightline-option* Tomorrow, Tomorrow_Night, Tomorrow_Night_Blue, Tomorrow_Night_Bright, Tomorrow_Night_Eighties, PaperColor, landscape, one, materia, material, OldHope, nord, deus, - simpleblack, srcery_drk, ayu_mirage, ayu_light, ayu_dark and - 16color are available. + simpleblack, srcery_drk, ayu_mirage, ayu_light, ayu_dark, + apprentice and 16color are available. The default value is: > let g:lightline.colorscheme = 'default' @@ -306,9 +306,6 @@ Exposed functions for lightline.vim. lightline#update() *lightline#update()* Updates all the statuslines of existing windows. - lightline#update_once() *lightline#update_once()* - Updates the statuslines only once. - lightline#enable() *lightline#enable()* Enables |lightline|. diff --git a/sources_non_forked/mru.vim/README b/sources_non_forked/mru.vim/README new file mode 100644 index 00000000..04c3a748 --- /dev/null +++ b/sources_non_forked/mru.vim/README @@ -0,0 +1,192 @@ +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 new file mode 100644 index 00000000..5cf7015d --- /dev/null +++ b/sources_non_forked/mru.vim/plugin/mru.vim @@ -0,0 +1,1039 @@ +" 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/ISSUE_TEMPLATE/bug.md b/sources_non_forked/nerdtree/.github/ISSUE_TEMPLATE/bug.md index dd351350..e2ce07b9 100644 --- a/sources_non_forked/nerdtree/.github/ISSUE_TEMPLATE/bug.md +++ b/sources_non_forked/nerdtree/.github/ISSUE_TEMPLATE/bug.md @@ -5,41 +5,42 @@ labels: bug --- +Keep in mind that others may have the same question in the future. The better your information, +the more likely they'll be able to help themselves. +--> #### Self-Diagnosis - -- [ ] I have searched the [issues](https://github.com/scrooloose/nerdtree/issues) for an answer to my question. -- [ ] I have reviewed the NERDTree documentation. `:h NERDTree` -- [ ] I have reviewed the [Wiki](https://github.com/scrooloose/nerdtree/wiki). -- [ ] I have searched the web for an answer to my question. +Before creating an issue, take some time to search these resources for an answer. It's possible that someone else has already seen and solved your issue. +- [old NERDTree issues](https://github.com/preservim/nerdtree/issues?q=is%3Aissue) +- NERDTree documentation - `:h NERDTree` +- [NERDTree Wiki](https://github.com/preservim/nerdtree/wiki) +- Other resources: , , etc. -#### Environment (for bug reports) -- [ ] Operating System: -- [ ] Vim/Neovim version `:echo v:version`: -- [ ] NERDTree version, found on 1st line in NERDTree quickhelp `?`: -- [ ] vimrc settings - - [ ] NERDTree variables - ```vim - ``` - - Other NERDTree-dependent Plugins - - [ ] jistr/vim-nerdtree-tabs - - [ ] ryanoasis/vim-devicons - - [ ] tiagofumo/vim-nerdtree-syntax-highlight - - [ ] Xuyuanp/nerdtree-git-plugin - - [ ] Others (specify): - - [ ] I've verified the issue occurs with only NERDTree installed. +#### Environment +- Operating System: +- Vim/Neovim version `:version`: +- NERDTree version, found on first line of quickhelp `?`: +- Are you using any of these NERDTree-dependent plugins? + - [ ] [Xuyuanp/nerdtree-git-plugin](https://github.com/Xuyuanp/nerdtree-git-plugin) + - [ ] [ryanoasis/vim-devicons](https://github.com/ryanoasis/vim-devicons) + - [ ] [tiagofumo/vim-nerdtree-syntax-highlight](https://github.com/tiagofumo/vim-nerdtree-syntax-highlight) + - [ ] [scrooloose/nerdtree-project-plugin](https://github.com/scrooloose/nerdtree-project-plugin) + - [ ] [PhilRunninger/nerdtree-buffer-ops](https://github.com/PhilRunninger/nerdtree-buffer-ops) + - [ ] [PhilRunninger/nerdtree-visual-selection](https://github.com/PhilRunninger/nerdtree-visual-selection) + - [ ] [jistr/vim-nerdtree-tabs](https://github.com/jistr/vim-nerdtree-tabs) + - [ ] Others (specify): +- Provide a minimal **.vimrc** file that will reproduce the issue. +```vim +``` #### Steps to Reproduce the Issue 1. -#### Current Result (Include screenshots where appropriate.) +#### Current Behavior (Include screenshots where appropriate.) #### Expected Result diff --git a/sources_non_forked/nerdtree/.github/ISSUE_TEMPLATE/question.md b/sources_non_forked/nerdtree/.github/ISSUE_TEMPLATE/question.md index 25f15b02..7e13b7ac 100644 --- a/sources_non_forked/nerdtree/.github/ISSUE_TEMPLATE/question.md +++ b/sources_non_forked/nerdtree/.github/ISSUE_TEMPLATE/question.md @@ -3,22 +3,11 @@ name: "General Question" about: "Having trouble setting up NERDTree? Need clarification on a setting? Ask your question here." labels: "general question" --- - - -#### Self-Diagnosis - -- [ ] I have searched the [issues](https://github.com/scrooloose/nerdtree/issues) for an answer to my question. -- [ ] I have reviewed the NERDTree documentation. `:h NERDTree` -- [ ] I have reviewed the [Wiki](https://github.com/scrooloose/nerdtree/wiki). -- [ ] I have searched the web for an answer to my question. +Before creating an issue, take some time to search these resources. It's possible that someone else has already asked your question and gotten an answer. +- [old NERDTree issues](https://github.com/preservim/nerdtree/issues?q=is%3Aissue) +- NERDTree documentation - `:h NERDTree` +- [NERDTree Wiki](https://github.com/preservim/nerdtree/wiki) +- Other resource: , , etc. #### State Your Question diff --git a/sources_non_forked/nerdtree/CHANGELOG.md b/sources_non_forked/nerdtree/CHANGELOG.md index e558036b..8bbc8f2c 100644 --- a/sources_non_forked/nerdtree/CHANGELOG.md +++ b/sources_non_forked/nerdtree/CHANGELOG.md @@ -4,7 +4,21 @@ version in an unordered list. The format is: - **.PATCH**: Pull Request Title (PR Author) [PR Number](Link to PR) --> +#### 6.10 +- **.10**: Improve F.A.Q. Answers and Issue Templates (PhilRunninger) [#1249](https://github.com/preservim/nerdtree/pull/1249) +- **.9**: `go` on a bookmark directory will NERDTreeFind it. (PhilRunninger) [#1236](https://github.com/preservim/nerdtree/pull/1236) +- **.8**: Put `Callback` function variables in local scope. (PhilRunninger) [#1230](https://github.com/preservim/nerdtree/pull/1230) +- **.7**: Fix mouse-clicking a file to open it. (PhilRunninger) [#1225](https://github.com/preservim/nerdtree/pull/1225) +- **.6**: Restore the default behavior of the `` key. (PhilRunninger) [#1221](https://github.com/preservim/nerdtree/pull/1221) +- **.5**: Fix `{'keepopen':0}` in NERDTreeCustomOpenArgs (PhilRunninger) [#1217](https://github.com/preservim/nerdtree/pull/1217) +- **.4**: Removed directory separator from sort key (Daniel E) [#1219](https://github.com/preservim/nerdtree/pull/1219) +- **.3**: Add new FAQ and answer: How to prevent buffers replacing NERDTree. (PhilRunninger) [#1215](https://github.com/preservim/nerdtree/pull/1215) +- **.2**: New menu command: Run a system command in this directory. (PhilRunninger) [#1214](https://github.com/preservim/nerdtree/pull/1214) +- **.1**: Escape quotation marks so they can be used in key mappings. (PhilRunninger) [#1213](https://github.com/preservim/nerdtree/pull/1213) +- **.0**: Enable full path specifications for NERDTreeIgnore (PhilRunninger) [#1207](https://github.com/preservim/nerdtree/pull/1207) #### 6.9 +- **.12**: Respect NERDTreeCustomOpenArgs when opening bookmark (przepompownia) [#1200](https://github.com/preservim/nerdtree/pull/1200) +- **.11**: Revamp the README. (buncis, PhilRunninger) [#1192](https://github.com/preservim/nerdtree/pull/1192), [#1193](https://github.com/preservim/nerdtree/pull/1193) - **.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) diff --git a/sources_non_forked/nerdtree/README.markdown b/sources_non_forked/nerdtree/README.markdown index 018923cf..ea10c119 100644 --- a/sources_non_forked/nerdtree/README.markdown +++ b/sources_non_forked/nerdtree/README.markdown @@ -1,157 +1,189 @@ -The NERDTree [![Vint](https://github.com/preservim/nerdtree/workflows/Vint/badge.svg)](https://github.com/preservim/nerdtree/actions?workflow=Vint) -============= +# The NERDTree [![Vint](https://github.com/preservim/nerdtree/workflows/Vint/badge.svg)](https://github.com/preservim/nerdtree/actions?workflow=Vint) -Introduction ------------- +## Introduction -The NERDTree is a file system explorer for the Vim editor. Using this plugin, -users can visually browse complex directory hierarchies, quickly open files for -reading or editing, and perform basic file system operations. - -This plugin can also be extended with custom mappings using a special API. The -details of this API and of other NERDTree features are described in the -included documentation. +The NERDTree is a file system explorer for the Vim editor. Using this plugin, users can visually browse complex directory hierarchies, quickly open files for reading or editing, and perform basic file system operations. ![NERDTree Screenshot](https://github.com/preservim/nerdtree/raw/master/screenshot.png) -Installation ------------- +## Installation -Below are just some of the methods for installing NERDTree. Do not follow all of these instructions; just pick your favorite one. Other plugin managers exist, and NERDTree should install just fine with any of them. +Use your favorite plugin manager to install this plugin. [tpope/vim-pathogen](https://github.com/tpope/vim-pathogen), [VundleVim/Vundle.vim](https://github.com/VundleVim/Vundle.vim), [junegunn/vim-plug](https://github.com/junegunn/vim-plug), and [Shougo/dein.vim](https://github.com/Shougo/dein.vim) are some of the more popular ones. A lengthy discussion of these and other managers can be found on [vi.stackexchange.com](https://vi.stackexchange.com/questions/388/what-is-the-difference-between-the-vim-plugin-managers). Basic instructions are provided below, but please **be sure to read, understand, and follow all the safety rules that come with your ~~power tools~~ plugin manager.** -#### Vim 8+ packages +If you have no favorite, or want to manage your plugins without 3rd-party dependencies, consider using Vim 8+ packages, as described in Greg Hurrell's excellent Youtube video: [Vim screencast #75: Plugin managers](https://www.youtube.com/watch?v=X2_R3uxDN6g). -If you are using VIM version 8 or higher you can use its built-in package management; see `:help packages` for more information. Just run these commands in your terminal: +
+Pathogen +Pathogen is more of a runtime path manager than a plugin manager. You must clone the plugins' repositories yourself to a specific location, and Pathogen makes sure they are available in Vim. + + +1. In the terminal, + ```bash + git clone https://github.com/preservim/nerdtree.git ~/.vim/bundle/nerdtree + ``` +1. In your `vimrc`, + ```vim + call pathogen#infect() + syntax on + filetype plugin indent on + ``` +1. Restart Vim, and run `:helptags ~/.vim/bundle/nerdtree/doc/` or `:Helptags`. +
+ +
+ Vundle + +1. Install Vundle, according to its instructions. +1. Add the following text to your `vimrc`. + ```vim + call vundle#begin() + Plugin 'preservim/nerdtree' + call vundle#end() + ``` +1. Restart Vim, and run the `:PluginInstall` statement to install your plugins. +
+ +
+ Vim-Plug + +1. Install Vim-Plug, according to its instructions. +1. Add the following text to your `vimrc`. +```vim +call plug#begin() + Plug 'preservim/nerdtree' +call plug#end() +``` +1. Restart Vim, and run the `:PlugInstall` statement to install your plugins. +
+ +
+ Dein + +1. Install Dein, according to its instructions. +1. Add the following text to your `vimrc`. + ```vim + call dein#begin() + call dein#add('preservim/nerdtree') + call dein#end() + ``` +1. Restart Vim, and run the `:call dein#install()` statement to install your plugins. +
+ +
+Vim 8+ packages + +If you are using Vim version 8 or higher you can use its built-in package management; see `:help packages` for more information. Just run these commands in your terminal: ```bash git clone https://github.com/preservim/nerdtree.git ~/.vim/pack/vendor/start/nerdtree 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 need to take. +## Getting Started +After installing NERDTree, the best way to learn it is to turn on the Quick Help. Open NERDTree with the `:NERDTree` command, and press `?` to turn on the Quick Help, which will show you all the mappings and commands available in the NERDTree. Of course, your most complete source of information is the documentation: `:help NERDTree`. -#### [pathogen.vim](https://github.com/tpope/vim-pathogen) +## NERDTree Plugins +NERDTree can be extended with custom mappings and functions using its built-in API. The details of this API and are described in the included documentation. Several plugins have been written, and are available on Github for installation like any other plugin. The plugins in this list are maintained (or not) by their respective owners, and certain combinations may be incompatible. -In the terminal, -```bash -git clone https://github.com/preservim/nerdtree.git ~/.vim/bundle/nerdtree -``` -In your vimrc, +* [Xuyuanp/nerdtree-git-plugin](https://github.com/Xuyuanp/nerdtree-git-plugin): Shows Git status flags for files and folders in NERDTree. +* [ryanoasis/vim-devicons](https://github.com/ryanoasis/vim-devicons): Adds filetype-specific icons to NERDTree files and folders, +* [tiagofumo/vim-nerdtree-syntax-highlight](https://github.com/tiagofumo/vim-nerdtree-syntax-highlight): Adds syntax highlighting to NERDTree based on filetype. +* [scrooloose/nerdtree-project-plugin](https://github.com/scrooloose/nerdtree-project-plugin): Saves and restores the state of the NERDTree between sessions. +* [PhilRunninger/nerdtree-buffer-ops](https://github.com/PhilRunninger/nerdtree-buffer-ops): 1) Highlights open files in a different color. 2) Closes a buffer directly from NERDTree. +* [PhilRunninger/nerdtree-visual-selection](https://github.com/PhilRunninger/nerdtree-visual-selection): Enables NERDTree to open, delete, move, or copy multiple Visually-selected files at once. + +If any others should be listed, mention them in an issue or pull request. + + +## Frequently Asked Questions + +In the answers to these questions, you will see code blocks that you can put in your `vimrc` file. + +### How can I map a specific key or shortcut to open NERDTree? + +NERDTree doesn't create any shortcuts outside of the NERDTree window, so as not to overwrite any of your other shortcuts. Use the `nnoremap` command in your `vimrc`. You, of course, have many keys and NERDTree commands to choose from. Here are but a few examples. ```vim -call pathogen#infect() -syntax on -filetype plugin indent on +nnoremap n :NERDTreeFocus +nnoremap :NERDTree +nnoremap :NERDTreeToggle +nnoremap :NERDTreeFind ``` -Then reload vim, run `:helptags ~/.vim/bundle/nerdtree/doc/` or `:Helptags`. +### How do I open NERDTree automatically when Vim starts? +Each code block below is slightly different, as described in the `" Comment lines`. -#### [Vundle.vim](https://github.com/VundleVim/Vundle.vim) ```vim -call vundle#begin() -Plugin 'preservim/nerdtree' -call vundle#end() +" Start NERDTree and leave the cursor in it. +autocmd VimEnter * NERDTree ``` - -#### [vim-plug](https://github.com/junegunn/vim-plug) -```vim -call plug#begin() -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 -``` - -F.A.Q. (here, and in the [Wiki](https://github.com/preservim/nerdtree/wiki)) ------- - -#### Is there any support for `git` flags? - -Yes, install [nerdtree-git-plugin](https://github.com/Xuyuanp/nerdtree-git-plugin). - --- -#### Can I have the nerdtree on every tab automatically? - -Nope. If this is something you want then chances are you aren't using tabs and -buffers as they were intended to be used. Read this -http://stackoverflow.com/questions/102384/using-vims-tabs-like-buffers - -If you are interested in this behaviour then consider [vim-nerdtree-tabs](https://github.com/jistr/vim-nerdtree-tabs) - ---- -#### How can I open a NERDTree automatically when vim starts up? - -Stick this in your vimrc: `autocmd vimenter * NERDTree` - ---- -#### How can I open a NERDTree automatically when vim starts up if no files were specified? - -Stick this in your vimrc: ```vim +" Start NERDTree and put the cursor back in the other window. +autocmd VimEnter * NERDTree | wincmd p +``` +--- +```vim +" Start NERDTree when Vim is started without file arguments. autocmd StdinReadPre * let s:std_in=1 -autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif +autocmd VimEnter * if argc() == 0 && !exists('s:std_in') | NERDTree | endif ``` - -Note: Now start vim with plain `vim`, not `vim .` - --- -#### What if I'm also opening a saved session, for example `vim -S session_file.vim`? I don't want NERDTree to open in that scenario. ```vim +" Start NERDTree. If a file is specified, move the cursor to its window. autocmd StdinReadPre * let s:std_in=1 -autocmd VimEnter * if argc() == 0 && !exists("s:std_in") && v:this_session == "" | NERDTree | endif +autocmd VimEnter * NERDTree | if argc() > 0 || exists("s:std_in") | wincmd p | endif ``` - --- -#### How can I open NERDTree automatically when vim starts up on opening a directory? ```vim +" Start NERDTree, unless a file or session is specified, eg. vim -S session_file.vim. autocmd StdinReadPre * let s:std_in=1 -autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists("s:std_in") | exe 'NERDTree' argv()[0] | wincmd p | ene | exe 'cd '.argv()[0] | endif +autocmd VimEnter * if argc() == 0 && !exists('s:std_in') && v:this_session == '' | NERDTree | endif ``` - -This window is tab-specific, meaning it's used by all windows in the tab. This trick also prevents NERDTree from hiding when first selecting a file. - -Note: Executing `vim ~/some-directory` will open NERDTree and a new edit window. `exe 'cd '.argv()[0]` sets the `pwd` of the new edit window to `~/some-directory` - --- -#### How can I map a specific key or shortcut to open NERDTree? - -Stick this in your vimrc to open NERDTree with `Ctrl+n` (you can set whatever key you want): ```vim -map :NERDTreeToggle +" Start NERDTree when Vim starts with a directory argument. +autocmd StdinReadPre * let s:std_in=1 +autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists('s:std_in') | + \ execute 'NERDTree' argv()[0] | wincmd p | enew | execute 'cd '.argv()[0] | endif ``` ---- -#### How can I close vim if the only window left open is a NERDTree? +### How can I close Vim or a tab automatically when NERDTree is the last window? -Stick this in your vimrc: ```vim -autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif +" Exit Vim if NERDTree is the only window remaining in the only tab. +autocmd BufEnter * if tabpagenr('$') == 1 && winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree() | quit | endif +``` +--- +```vim +" Close the tab if NERDTree is the only window remaining in it. +autocmd BufEnter * if winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree() | quit | endif ``` ---- -#### Can I have different highlighting for different file extensions? +### How can I prevent other buffers replacing NERDTree in its window? -See here: https://github.com/preservim/nerdtree/issues/433#issuecomment-92590696 +```vim +" If another buffer tries to replace NERDTree, put it in the other window, and bring back NERDTree. +autocmd BufEnter * if bufname('#') =~ 'NERD_tree_\d\+' && bufname('%') !~ 'NERD_tree_\d\+' && winnr('$') > 1 | + \ let buf=bufnr() | buffer# | execute "normal! \w" | execute 'buffer'.buf | endif +``` ---- -#### How can I change default arrows? +### Can I have the same NERDTree on every tab automatically? + +```vim +" Open the existing NERDTree on each new tab. +autocmd BufWinEnter * if getcmdwintype() == '' | silent NERDTreeMirror | endif +``` +or change your NERDTree-launching shortcut key like so: +```vim +" Mirror the NERDTree before showing it. This makes it the same on all tabs. +nnoremap :NERDTreeMirror:NERDTreeFocus +``` + +### How can I change the default arrows? -Use these variables in your vimrc. Note that below are default arrow symbols ```vim 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 = '' -``` +The preceding values are the non-Windows default arrow symbols. Setting these variables to empty strings will remove the arrows completely and shift the entire tree two character positions to the left. See `:h NERDTreeDirArrowExpandable` for more details. diff --git a/sources_non_forked/nerdtree/autoload/nerdtree.vim b/sources_non_forked/nerdtree/autoload/nerdtree.vim index 983bb621..e6f687a0 100644 --- a/sources_non_forked/nerdtree/autoload/nerdtree.vim +++ b/sources_non_forked/nerdtree/autoload/nerdtree.vim @@ -30,6 +30,16 @@ endfunction " SECTION: General Functions {{{1 "============================================================ +" FUNCTION: nerdtree#closeTreeOnOpen() {{{2 +function! nerdtree#closeTreeOnOpen() abort + return g:NERDTreeQuitOnOpen == 1 || g:NERDTreeQuitOnOpen == 3 +endfunction + +" FUNCTION: nerdtree#closeBookmarksOnOpen() {{{2 +function! nerdtree#closeBookmarksOnOpen() abort + return g:NERDTreeQuitOnOpen == 2 || g:NERDTreeQuitOnOpen == 3 +endfunction + " 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 @@ -46,28 +56,6 @@ function! nerdtree#slash() abort return '/' endfunction -"FUNCTION: nerdtree#and(x,y) {{{2 -" Implements and() function for Vim <= 7.4 -function! nerdtree#and(x,y) abort - if exists('*and') - return and(a:x, a:y) - else - let l:x = a:x - let l:y = a:y - let l:n = 0 - let l:result = 0 - while l:x > 0 && l:y > 0 - if (l:x % 2) && (l:y % 2) - let l:result += float2nr(pow(2, l:n)) - endif - let l:x = float2nr(l:x / 2) - let l:y = float2nr(l:y / 2) - let l:n += 1 - endwhile - return l:result - endif -endfunction - "FUNCTION: nerdtree#checkForBrowse(dir) {{{2 "inits a window tree in the current buffer if appropriate function! nerdtree#checkForBrowse(dir) abort diff --git a/sources_non_forked/nerdtree/autoload/nerdtree/ui_glue.vim b/sources_non_forked/nerdtree/autoload/nerdtree/ui_glue.vim index 78b3fa1f..fc22f216 100644 --- a/sources_non_forked/nerdtree/autoload/nerdtree/ui_glue.vim +++ b/sources_non_forked/nerdtree/autoload/nerdtree/ui_glue.vim @@ -108,10 +108,17 @@ function! s:customOpenBookmark(node) abort endfunction "FUNCTION: s:initCustomOpenArgs() {{{1 -" Make sure NERDTreeCustomOpenArgs has needed keys function! s:initCustomOpenArgs() abort - let g:NERDTreeCustomOpenArgs = get(g:, 'NERDTreeCustomOpenArgs', {}) - return extend(g:NERDTreeCustomOpenArgs, {'file':{'reuse': 'all', 'where': 'p'}, 'dir':{}}, 'keep') + let l:defaultOpenArgs = {'file': {'reuse': 'all', 'where': 'p', 'keepopen':!nerdtree#closeTreeOnOpen()}, 'dir': {}} + try + let g:NERDTreeCustomOpenArgs = get(g:, 'NERDTreeCustomOpenArgs', {}) + call extend(g:NERDTreeCustomOpenArgs, l:defaultOpenArgs, 'keep') + catch /^Vim(\a\+):E712:/ + call nerdtree#echoWarning('g:NERDTreeCustomOpenArgs is not set properly. Using default value.') + let g:NERDTreeCustomOpenArgs = l:defaultOpenArgs + finally + return g:NERDTreeCustomOpenArgs + endtry endfunction "FUNCTION: s:activateAll() {{{1 @@ -137,13 +144,13 @@ endfunction "FUNCTION: s:activateFileNode() {{{1 "handle the user activating a tree node function! s:activateFileNode(node) abort - call a:node.activate({'reuse': 'all', 'where': 'p'}) + call a:node.activate({'reuse': 'all', 'where': 'p', 'keepopen': !nerdtree#closeTreeOnOpen()}) endfunction "FUNCTION: s:activateBookmark(bookmark) {{{1 "handle the user activating a bookmark function! s:activateBookmark(bm) abort - call a:bm.activate(b:NERDTree, !a:bm.path.isDirectory ? {'where': 'p'} : {}) + call a:bm.activate(b:NERDTree, !a:bm.path.isDirectory ? {'where': 'p', 'keepopen': !nerdtree#closeTreeOnOpen()} : {}) endfunction " FUNCTION: nerdtree#ui_glue#bookmarkNode(name) {{{1 @@ -366,7 +373,7 @@ function! s:handleLeftClick() abort if currentNode.path.isDirectory call currentNode.activate() else - call currentNode.activate({'reuse': 'all', 'where': 'p'}) + call currentNode.activate({'reuse': 'all', 'where': 'p', 'keepopen':!nerdtree#closeTreeOnOpen()}) endif return endif @@ -500,31 +507,32 @@ function! nerdtree#ui_glue#openBookmark(name) abort endtry if l:bookmark.path.isDirectory call l:bookmark.open(b:NERDTree) - else - call l:bookmark.open(b:NERDTree, {'where': 'p'}) + return endif + + call l:bookmark.open(b:NERDTree, s:initCustomOpenArgs().file) endfunction " FUNCTION: s:openHSplit(target) {{{1 function! s:openHSplit(target) abort - call a:target.activate({'where': 'h'}) + call a:target.activate({'where': 'h', 'keepopen': !nerdtree#closeTreeOnOpen()}) endfunction " FUNCTION: s:openVSplit(target) {{{1 function! s:openVSplit(target) abort - call a:target.activate({'where': 'v'}) + call a:target.activate({'where': 'v', 'keepopen': !nerdtree#closeTreeOnOpen()}) 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'} : {}) + call a:bm.activate(b:NERDTree, !a:bm.path.isDirectory ? {'where': 'h', 'keepopen': !nerdtree#closeTreeOnOpen()} : {}) 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'} : {}) + call a:bm.activate(b:NERDTree, !a:bm.path.isDirectory ? {'where': 'v', 'keepopen': !nerdtree#closeTreeOnOpen()} : {}) endfunction " FUNCTION: s:previewHSplitBookmark(bookmark) {{{1 @@ -544,13 +552,13 @@ endfunction " FUNCTION: s:openInNewTab(target) {{{1 function! s:openInNewTab(target) abort - let l:opener = g:NERDTreeOpener.New(a:target.path, {'where': 't'}) + let l:opener = g:NERDTreeOpener.New(a:target.path, {'where': 't', 'keepopen': !nerdtree#closeTreeOnOpen()}) call l:opener.open(a:target) endfunction " FUNCTION: s:openInNewTabSilent(target) {{{1 function! s:openInNewTabSilent(target) abort - let l:opener = g:NERDTreeOpener.New(a:target.path, {'where': 't', 'stay': 1}) + let l:opener = g:NERDTreeOpener.New(a:target.path, {'where': 't', 'keepopen': !nerdtree#closeTreeOnOpen(), 'stay': 1}) call l:opener.open(a:target) endfunction @@ -564,7 +572,11 @@ endfunction " FUNCTION: s:previewBookmark(bookmark) {{{1 function! s:previewBookmark(bookmark) abort - call a:bookmark.activate(b:NERDTree, !a:bookmark.path.isDirectory ? {'stay': 1, 'where': 'h', 'keepopen': 1} : {}) + 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 endfunction "FUNCTION: s:previewNodeCurrent(node) {{{1 @@ -589,7 +601,7 @@ function! nerdtree#ui_glue#revealBookmark(name) abort let targetNode = g:NERDTreeBookmark.GetNodeForName(a:name, 0, b:NERDTree) call targetNode.putCursorHere(0, 1) catch /^NERDTree.BookmarkNotFoundError/ - call nerdtree#echo('Bookmark isnt cached under the current root') + call nerdtree#echo('Bookmark isn''t cached under the current root') endtry endfunction diff --git a/sources_non_forked/nerdtree/doc/NERDTree.txt b/sources_non_forked/nerdtree/doc/NERDTree.txt index 2989718c..4e75ad13 100644 --- a/sources_non_forked/nerdtree/doc/NERDTree.txt +++ b/sources_non_forked/nerdtree/doc/NERDTree.txt @@ -116,7 +116,7 @@ The following features and functionality are provided by the NERDTree: :NERDTreeVCS (opens root of repository containing CWD) < :NERDTreeFromBookmark *:NERDTreeFromBookmark* - Opens a fresh NERDTree with the root initialized to the dir for + Opens a fresh NERDTree with the root initialized to the directory for . The only reason to use this command over :NERDTree is for the completion (which is for bookmarks rather than directories). @@ -126,7 +126,7 @@ The following features and functionality are provided by the NERDTree: is set to that path. If no NERDTree exists for this tab then this command acts the same as the |:NERDTree| command. -:NERDTreeToggleVCS [ | ] *:NERDTreeToggleVCS* +:NERDTreeToggleVCS [ | ] *:NERDTreeToggleVCS* Like |:NERDTreeToggle|, but searches up the directory tree to find the top of the version control system repository, and roots the NERDTree there. It works with Git, Subversion, Mercurial, Bazaar, and Darcs repositories. A @@ -249,7 +249,7 @@ Key Description help-tag~ o........Open files, directories and bookmarks......................|NERDTree-o| go.......Open selected file, but leave cursor in the NERDTree......|NERDTree-go| - Open selected bookmark dir in current NERDTree + Find selected bookmark directory in current NERDTree t........Open selected node/bookmark in a new tab...................|NERDTree-t| T........Same as 't' but keep the focus on the current tab..........|NERDTree-T| i........Open selected file in a split window.......................|NERDTree-i| @@ -260,10 +260,10 @@ gs.......Same as s, but leave the cursor on the NERDTree...........|NERDTree-gs| O........Recursively open the selected directory....................|NERDTree-O| x........Close the current nodes parent.............................|NERDTree-x| X........Recursively close all children of the current node.........|NERDTree-X| -e........Edit the current dir.......................................|NERDTree-e| +e........Edit the current directory.................................|NERDTree-e| double-click....same as |NERDTree-o|. -middle-click....same as |NERDTree-i| for files, and |NERDTree-e| for dirs. +middle-click....same as |NERDTree-i| for files, and |NERDTree-e| for directories. D........Delete the current bookmark ...............................|NERDTree-D| @@ -274,13 +274,13 @@ J........Jump down inside directories at the current tree depth.....|NERDTree-J| ....Jump down to next sibling of the current directory.......|NERDTree-C-J| ....Jump up to previous sibling of the current directory.....|NERDTree-C-K| -C........Change the tree root to the selected dir...................|NERDTree-C| +C........Change the tree root to the selected directory.............|NERDTree-C| u........Move the tree root up one directory........................|NERDTree-u| U........Same as 'u' except the old root node is left open..........|NERDTree-U| r........Recursively refresh the current directory..................|NERDTree-r| R........Recursively refresh the current root.......................|NERDTree-R| m........Display the NERDTree menu..................................|NERDTree-m| -cd.......Change the CWD to the dir of the selected node............|NERDTree-cd| +cd.......Change the CWD to the directory of the selected node......|NERDTree-cd| CD.......Change tree root to the CWD...............................|NERDTree-CD| I........Toggle whether hidden files displayed......................|NERDTree-I| @@ -469,7 +469,7 @@ Jump to the first child of the current nodes parent. If the cursor is already on the first node then do the following: * loop back thru the siblings of the current nodes parent until we find an - open dir with children + open directory with children * go to the first child of that node ------------------------------------------------------------------------------ @@ -482,7 +482,7 @@ Jump to the last child of the current nodes parent. If the cursor is already on the last node then do the following: * loop forward thru the siblings of the current nodes parent until we find - an open dir with children + an open directory with children * go to the last child of that node ------------------------------------------------------------------------------ @@ -516,7 +516,7 @@ Default key: u Map setting: *NERDTreeMapUpdir* Applies to: no restrictions. -Move the tree root up a dir (like doing a "cd .."). +Move the tree root up a directory (like doing a "cd .."). ------------------------------------------------------------------------------ *NERDTree-U* @@ -532,8 +532,8 @@ Default key: r Map setting: *NERDTreeMapRefresh* Applies to: files and directories. -If a dir is selected, recursively refresh that dir, i.e. scan the filesystem -for changes and represent them in the tree. +If a directory is selected, recursively refresh that directory, i.e. scan the +filesystem for changes and represent them in the tree. If a file node is selected then the above is done on it's parent. @@ -634,8 +634,8 @@ file explorers have. The script comes with two default menu plugins: exec_menuitem.vim and fs_menu.vim. fs_menu.vim adds some basic filesystem operations to the menu for -creating/deleting/moving/copying files and dirs. exec_menuitem.vim provides a -menu item to execute executable files. +creating/deleting/moving/copying files and directories. exec_menuitem.vim +provides a menu item to execute executable files. Related tags: |NERDTree-m| |NERDTreeApi| @@ -921,7 +921,7 @@ Default: ['\~$']. This setting is used to specify which files the NERDTree should ignore. It must be a list of regular expressions. When the NERDTree is rendered, any -files/dirs that match any of the regex's in NERDTreeIgnore won't be +files/directories that match any of the regex's in NERDTreeIgnore won't be displayed. For example if you put the following line in your vimrc: > @@ -929,13 +929,18 @@ For example if you put the following line in your vimrc: > < then all files ending in .vim or ~ will be ignored. -There are 2 magic flags that can be appended to the end of each regular -expression to specify that the regex should match only files or only dirs. -These flags are "[[dir]]" and "[[file]]". Example: > - let NERDTreeIgnore=['\.d$[[dir]]', '\.o$[[file]]'] +There are 3 magic flags that can be appended to the end of each regular +expression to specify that the regex should match only filenames, only lowest +level directories, or a full path. These flags are "[[dir]]", "[[file]]", and +"[[path]]". Example: > + let NERDTreeIgnore=['\.d$[[dir]]', '\.o$[[file]]', 'tmp/cache$[[path]]'] < -This will cause all dirs ending in ".d" to be ignored and all files ending in -".o" to be ignored. +This will cause all directories ending in ".d" to be ignored, all files ending +in ".o" to be ignored, and the "cache" subdirectory of any "tmp" directory to +be ignored. All other "cache" directories will be displayed. + +When using the "[[path]]" tag on Windows, make sure you use escaped +backslashes for the separators in the regex, eg. 'Temp\\cache$[[path]]' Note: to tell the NERDTree not to ignore any files you must use the following line: > @@ -1099,8 +1104,8 @@ Examples: > < 1. Directories will appear last, everything else will appear above. 2. Everything will simply appear in alphabetical order. -3. Dirs will appear first, then ruby and php. Swap files, bak files and vim - backup files will appear last with everything else preceding them. +3. Directories will appear first, then ruby and php. Swap files, bak files + and vim backup files will appear last with everything else preceding them. 4. Everything is sorted by size, largest to smallest, with directories considered to have size 0 bytes. 5. Directories will appear first alphabetically, followed by files, sorted by @@ -1174,8 +1179,9 @@ Use one of the following lines for this setting: > Values: 0 or 1 Default: 1. -When displaying dir nodes, this setting tells NERDTree to collapse dirs that -have only one child. Use one of the following lines for this setting: > +When displaying directory nodes, this setting tells NERDTree to collapse +directories that have only one child. Use one of the following lines for this +setting: > let NERDTreeCascadeSingleChildDir=0 let NERDTreeCascadeSingleChildDir=1 < @@ -1184,11 +1190,12 @@ have only one child. Use one of the following lines for this setting: > Values: 0 or 1 Default: 1. -When opening dir nodes, this setting tells NERDTree to recursively open dirs -that have only one child which is also a dir. NERDTree will stop when it finds -a dir that contains anything but another single dir. This setting also causes -the |NERDTree-x| mapping to close dirs in the same manner. This setting may be -useful for Java projects. Use one of the following lines for this setting: > +When opening directory nodes, this setting tells NERDTree to recursively open +directories that have only one child which is also a directory. NERDTree will +stop when it finds a directory that contains anything but another single +directory. This setting also causes the |NERDTree-x| mapping to close +directories in the same manner. This setting may be useful for Java projects. +Use one of the following lines for this setting: > let NERDTreeCascadeOpenSingleChildDir=0 let NERDTreeCascadeOpenSingleChildDir=1 < @@ -1362,8 +1369,8 @@ NERDTreeAddKeyMap({options}) *NERDTreeAddKeyMap()* < This code should sit in a file like ~/.vim/nerdtree_plugin/mymapping.vim. It adds a (redundant) mapping on 'foo' which changes vim's CWD to that of - the current dir node. Note this mapping will only fire when the cursor is - on a directory node. + the current directory node. Note this mapping will only fire when the + cursor is on a directory node. ------------------------------------------------------------------------------ 4.2. Menu API *NERDTreeMenuAPI* diff --git a/sources_non_forked/nerdtree/lib/nerdtree/bookmark.vim b/sources_non_forked/nerdtree/lib/nerdtree/bookmark.vim index 248bb074..37be451c 100644 --- a/sources_non_forked/nerdtree/lib/nerdtree/bookmark.vim +++ b/sources_non_forked/nerdtree/lib/nerdtree/bookmark.vim @@ -256,7 +256,7 @@ endfunction function! s:Bookmark.open(nerdtree, ...) let opts = a:0 ? a:1 : {} - if nerdtree#and(g:NERDTreeQuitOnOpen,2) + if nerdtree#closeBookmarksOnOpen() call a:nerdtree.ui.toggleShowBookmarks() endif diff --git a/sources_non_forked/nerdtree/lib/nerdtree/key_map.vim b/sources_non_forked/nerdtree/lib/nerdtree/key_map.vim index f3268c26..ed791677 100644 --- a/sources_non_forked/nerdtree/lib/nerdtree/key_map.vim +++ b/sources_non_forked/nerdtree/lib/nerdtree/key_map.vim @@ -51,7 +51,7 @@ function! s:KeyMap.bind() else let keymapInvokeString = self.key endif - let keymapInvokeString = escape(keymapInvokeString, '\') + let keymapInvokeString = escape(keymapInvokeString, '\"') let premap = self.key ==# '' ? ' ' : ' ' @@ -66,11 +66,11 @@ endfunction "FUNCTION: KeyMap.invoke() {{{1 "Call the KeyMaps callback function function! s:KeyMap.invoke(...) - let Callback = type(self.callback) ==# type(function('tr')) ? self.callback : function(self.callback) + let l:Callback = type(self.callback) ==# type(function('tr')) ? self.callback : function(self.callback) if a:0 - call Callback(a:1) + call l:Callback(a:1) else - call Callback() + call l:Callback() endif endfunction diff --git a/sources_non_forked/nerdtree/lib/nerdtree/nerdtree.vim b/sources_non_forked/nerdtree/lib/nerdtree/nerdtree.vim index db9e2b55..61a11a96 100644 --- a/sources_non_forked/nerdtree/lib/nerdtree/nerdtree.vim +++ b/sources_non_forked/nerdtree/lib/nerdtree/nerdtree.vim @@ -65,14 +65,6 @@ function! s:NERDTree.Close() endif endfunction -"FUNCTION: s:NERDTree.CloseIfQuitOnOpen() {{{1 -"Closes the NERD tree window if the close on open option is set -function! s:NERDTree.CloseIfQuitOnOpen() - if nerdtree#and(g:NERDTreeQuitOnOpen,1) && s:NERDTree.IsOpen() - call s:NERDTree.Close() - endif -endfunction - "FUNCTION: s:NERDTree.CursorToBookmarkTable(){{{1 "Places the cursor at the top of the bookmarks table function! s:NERDTree.CursorToBookmarkTable() diff --git a/sources_non_forked/nerdtree/lib/nerdtree/notifier.vim b/sources_non_forked/nerdtree/lib/nerdtree/notifier.vim index fc3155d7..ffa2853a 100644 --- a/sources_non_forked/nerdtree/lib/nerdtree/notifier.vim +++ b/sources_non_forked/nerdtree/lib/nerdtree/notifier.vim @@ -15,8 +15,8 @@ function! s:Notifier.NotifyListeners(event, path, nerdtree, params) let event = g:NERDTreeEvent.New(a:nerdtree, a:path, a:event, a:params) for Listener in s:Notifier.GetListenersForEvent(a:event) - let Callback = type(Listener) == type(function('tr')) ? Listener : function(Listener) - call Callback(event) + let l:Callback = type(Listener) == type(function('tr')) ? Listener : function(Listener) + call l:Callback(event) endfor endfunction diff --git a/sources_non_forked/nerdtree/lib/nerdtree/opener.vim b/sources_non_forked/nerdtree/lib/nerdtree/opener.vim index 9c62b723..27993ac7 100644 --- a/sources_non_forked/nerdtree/lib/nerdtree/opener.vim +++ b/sources_non_forked/nerdtree/lib/nerdtree/opener.vim @@ -33,8 +33,7 @@ function! s:Opener._bufInWindows(bnum) endfunction " FUNCTION: Opener._checkToCloseTree(newtab) {{{1 -" Check the class options and global options (i.e. NERDTreeQuitOnOpen) to see -" if the tree should be closed now. +" Check the class options to see if the tree should be closed now. " " Args: " a:newtab - boolean. If set, only close the tree now if we are opening the @@ -46,7 +45,7 @@ function! s:Opener._checkToCloseTree(newtab) endif if (a:newtab && self._where ==# 't') || !a:newtab - call g:NERDTree.CloseIfQuitOnOpen() + call g:NERDTree.Close() endif endfunction @@ -218,7 +217,7 @@ endfunction " FUNCTION: Opener._openFile() {{{1 function! s:Opener._openFile() - if !self._stay && !nerdtree#and(g:NERDTreeQuitOnOpen,1) && exists('b:NERDTreeZoomed') && b:NERDTreeZoomed + if !self._stay && self._keepopen && get(b:, 'NERDTreeZoomed', 0) 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 786ccd90..997abf37 100644 --- a/sources_non_forked/nerdtree/lib/nerdtree/path.vim +++ b/sources_non_forked/nerdtree/lib/nerdtree/path.vim @@ -394,7 +394,7 @@ function! s:Path.getSortKey() let self._sortKey = [self.getSortOrderIndex()] + metadata endif - let path = self.getLastPathComponent(1) + let path = self.getLastPathComponent(0) if !g:NERDTreeSortHiddenFirst let path = substitute(path, '^[._]', '', '') endif @@ -459,10 +459,10 @@ function! s:Path.ignore(nerdtree) endif endfor - for Callback in g:NERDTree.PathFilters() - let Callback = type(Callback) ==# type(function('tr')) ? Callback : function(Callback) - if Callback({'path': self, 'nerdtree': a:nerdtree}) - return 1 + for l:Callback in g:NERDTree.PathFilters() + let l:Callback = type(l:Callback) ==# type(function('tr')) ? l:Callback : function(l:Callback) + if l:Callback({'path': self, 'nerdtree': a:nerdtree}) + return 1 endif endfor endif @@ -483,7 +483,10 @@ endfunction " returns true if this path matches the given ignore pattern function! s:Path._ignorePatternMatches(pattern) let pat = a:pattern - if strpart(pat,len(pat)-7) ==# '[[dir]]' + if strpart(pat,len(pat)-8) ==# '[[path]]' + let pat = strpart(pat,0, len(pat)-8) + return self.str() =~# pat + elseif strpart(pat,len(pat)-7) ==# '[[dir]]' if !self.isDirectory return 0 endif diff --git a/sources_non_forked/nerdtree/nerdtree_plugin/fs_menu.vim b/sources_non_forked/nerdtree/nerdtree_plugin/fs_menu.vim index b3ef42e7..09cb69b5 100644 --- a/sources_non_forked/nerdtree/nerdtree_plugin/fs_menu.vim +++ b/sources_non_forked/nerdtree/nerdtree_plugin/fs_menu.vim @@ -49,6 +49,10 @@ else call NERDTreeAddMenuItem({'text': '(l)ist the current node', 'shortcut': 'l', 'callback': 'NERDTreeListNodeWin32'}) endif +if exists('*system') + call NERDTreeAddMenuItem({'text': 'Run (s)ystem command in this directory', 'shortcut':'s', 'callback': 'NERDTreeSystemCommand'}) +endif + "FUNCTION: s:inputPrompt(action){{{1 "returns the string that should be prompted to the user for the given action " @@ -460,4 +464,21 @@ function! NERDTreeExecuteFileWindows() call system('cmd.exe /c start "" ' . shellescape(l:node.path.str())) endfunction +" FUNCTION: NERDTreeSystemCommand() {{{1 +function! NERDTreeSystemCommand() + let l:node = g:NERDTreeFileNode.GetSelected() + + if empty(l:node) + return + endif + + let l:cwd = getcwd() + let l:directory = l:node.path.isDirectory ? l:node.path.str() : l:node.parent.path.str() + execute 'cd '.l:directory + + let l:nl = nr2char(10) + echo l:nl . system(input(l:directory . (nerdtree#runningWindows() ? '> ' : ' $ '))) + execute 'cd '.l:cwd +endfunction + " vim: set sw=4 sts=4 et fdm=marker: diff --git a/sources_non_forked/nginx.vim/syntax/nginx.vim b/sources_non_forked/nginx.vim/syntax/nginx.vim index 9d3b92e2..18dd50cb 100644 --- a/sources_non_forked/nginx.vim/syntax/nginx.vim +++ b/sources_non_forked/nginx.vim/syntax/nginx.vim @@ -2276,7 +2276,6 @@ hi link ngxComment Comment hi link ngxVariable Identifier hi link ngxVariableBlock Identifier hi link ngxVariableString PreProc -hi link ngxBlock Normal hi link ngxString String hi link ngxIPaddr Delimiter hi link ngxBoolean Boolean diff --git a/sources_non_forked/rust.vim/autoload/rustfmt.vim b/sources_non_forked/rust.vim/autoload/rustfmt.vim index 59a58e84..5283b840 100644 --- a/sources_non_forked/rust.vim/autoload/rustfmt.vim +++ b/sources_non_forked/rust.vim/autoload/rustfmt.vim @@ -157,7 +157,14 @@ function! s:RunRustfmt(command, tmpname, from_writepre) endif call s:DeleteLines(len(l:content), line('$')) - call setline(1, l:content) + if has('nvim') && exists('*nvim_buf_set_lines') + " setline() gets called for every item on the array, + " this results on the neovim buffer callbacks being called n times, + " using nvim_buf_set_lines() makes the change in one call. + call nvim_buf_set_lines(0, 0, -1, v:true, l:content) + else + call setline(1, l:content) + endif " only clear location list if it was previously filled to prevent " clobbering other additions diff --git a/sources_non_forked/rust.vim/ftplugin/rust.vim b/sources_non_forked/rust.vim/ftplugin/rust.vim index ce48116e..fb048cac 100644 --- a/sources_non_forked/rust.vim/ftplugin/rust.vim +++ b/sources_non_forked/rust.vim/ftplugin/rust.vim @@ -47,7 +47,7 @@ setlocal smartindent nocindent if get(g:, 'rust_recommended_style', 1) let b:rust_set_style = 1 - setlocal tabstop=8 shiftwidth=4 softtabstop=4 expandtab + setlocal shiftwidth=4 softtabstop=4 expandtab setlocal textwidth=99 endif diff --git a/sources_non_forked/tlib/.gitignore b/sources_non_forked/tlib/.gitignore new file mode 100644 index 00000000..e626a86d --- /dev/null +++ b/sources_non_forked/tlib/.gitignore @@ -0,0 +1,13 @@ +tags +!doc/tags +Makefile +TODO.TXT +TODO_archived.viki +*.vba +*.vmb +*.zip +.last_* +test +test_* +tmp +var diff --git a/sources_non_forked/tlib/CHANGES.TXT b/sources_non_forked/tlib/CHANGES.TXT new file mode 100644 index 00000000..767ae5e4 --- /dev/null +++ b/sources_non_forked/tlib/CHANGES.TXT @@ -0,0 +1,909 @@ +0.1 +Initial release + +0.2 +- More list convenience functions +- tlib#EditList() +- tlib#InputList(): properly handle duplicate items; it type contains +'i', the list index + 1 is returned, not the element + +0.3 +- tlib#InputList(): Show feedback in statusline instead of the echo area +- tlib#GetVar(), tlib#GetValue() + +0.4 +- tlib#InputList(): Up/Down keys wrap around list +- tlib#InputList(): FIX: Problem when reducing the filter & using AND +- tlib#InputList(): Made work (can be configured via +- tlib#InputList(): special display_format: "filename" +- tlib#Object: experimental support for some kind of OOP +- tlib#World: Extracted some functions from tlib.vim to tlib/World.vim +- tlib#FileJoin(), tlib#FileSplit(), tlib#RelativeFilename() +- tlib#Let() +- tlib#EnsureDirectoryExists(dir) +- tlib#DirName(dir) +- tlib#DecodeURL(url), tlib#EncodeChar(char), tlib#EncodeURL(url) +- FIX: Problem when using shift-up/down with filtered lists + +0.5 +- tlib#InputList(): FIX: Selecting items in filtered view +- tlib#InputList(): : Remove last AND pattern from filter + +0.6 +- tlib#InputList(): Disabled map +- tlib#InputList(): try to be smart about user itentions only if a +list's length is < g:tlib_sortprefs_threshold (default: 200) +- tlib#Object: Super() method +- tlib#MyRuntimeDir() +- tlib#GetCacheName(), tlib#CacheSave(), tlib#CacheGet() +- tlib#Args(), tlib#GetArg() +- FIX: tlib#InputList(): Display problem with first item + +0.7 +- tlib#InputList(): ... Suspend/Resume input +- tlib#InputList(): ... Input text on the command line (useful on +slow systems when working with very large lists) +- tlib#InputList(): AND-pattern starting with '!' will work as 'exclude +matches' +- tlib#InputList(): FIX pop OR-patterns properly +- tlib#InputList(): display_format == filename: don't add '/' to +directory names (avoid filesystem access) + +0.8 +- FIX: Return empty cache name for buffers that have no files attached to it +- Some re-arranging + +0.9 +- Re-arrangements & modularization (this means many function names have +changed, on the other hand only those functions are loaded that are +actually needed) +- tlib#input#List(): Added maps with m-modifiers for , , +- tlib#input#List(): Make sure &fdm is manual +- tlib#input#List(): When exiting the list view, consume the next 5 +characters in the queue (if any) +- tlib#input#EditList(): Now has cut, copy, paste functionality. +- Added documentation and examples + +0.10 +- tlib#input#List(): (v)split type of commands leave the original window +untouched (you may use to replace its contents) +- tlib#file#With(): Check whether an existing buffer is loaded. +- Scratch related functions went to tlib/scratch.vim so that they are +accessible from other scripts. +- Configure the list window height via g:tlib_inputlist_pct (1..100%) + +0.11 +NEW: + - The :TLet command replaces :TLLet (which was removed) + - :TScratch[!] command (with ! don't split but use the whole window) + - tlib#rx#Escape(text, ?magic='m') + - tlib#buffer#GetList(?show_hidden=0) + - tlib#dir#CD(), tlib#dir#Push(), tlib#dir#Pop() + - tlib#input#ListW: A slightly remodeled version of tlib#input#List + that takes a World as second argument. + - Added some documentation doc/tlib.txt (most of it is automatically + compiled from the source files) +CHANGES: + - tlib#input#List(): The default keys for AND, NOT have changed to + be more Google-like (space, minus); the keys can be configured via + global variables. +IMPROVEMENTS: + - In file listings, indicate if a file is loaded, listed, modified + etc. + - tlib#input#List(): Highlight the filter pattern + - tlib#input#List(): scrolls g:tlib_scroll_lines + (default=10) lines +FIXES: + - tlib#input#List(): Centering line, clear match, clear & restore + the search register + - tlib#input#List(): Ensure the window layout doesn't change (if the + number of windows hasn't changed) + - tlib#arg#Ex(): Don't escape backslashes by default + +0.12 +NEW: + - tlib/tab.vim +CHANGES: + - Renamed tlib#win#SetWin() to tlib#win#Set() +IMPROVEMENTS: + - tlib#input#List(): , keys work in some lists + - tlib#input#List(): If an index_table is provided this will be used + instead of the item's list index. +FIXES: + - tlib#input#List(): Problem with scrolling, when the list was + shorter than the window (eg when using a vertical window). + - tlib#cache#Filename(): Don't rewrite name as relative filename if + explicitly given as argument. Avoid double (back)slashes. + - TLet: simplified + +0.13 +CHANGES: + - Scratch: Set &fdc=0. + - The cache directory can be configured via g:tlib_cache + - Renamed tlib#buffer#SetBuffer() to tlib#buffer#Set(). +FIXES: + - tlib#input#List(): Select the active item per mouse. + - TLet: simplified + +0.14 +NEW: + - tlib#buffer#InsertText() +CHANGES: + - tlib#win#[SG]etLayout(): Use a dictionnary, set &cmdheight. +FIXES: + - Wrong order with pre-defined filters. + +0.15 +NEW: + - tlib#string#TrimLeft(), tlib#string#TrimRight(), tlib#string#Strip() + - Progress bar + +0.16 +NEW: + - tlib#string#Printf1() + +0.17 +NEW: + - TBrowseOutput +- Some minor changes + +0.18 +NEW: + - tlib/time.vim + - g:tlib_inputlist_livesearch_threshold +CHANGES: + - tlib#input#ListD(), World: Don't redisplay the list while typing + new letters; calculate filter regexps only once before filtering the + list. + - World.vim: Minor changes to how filenames are handled. + +0.19 +NEW: + - tag.vim +FIX: + - dir.vim: Use plain dir name in tlib#dir#Ensure() + - tlib#input#List(): An initial filter argument creates [[filter]] + and not as before [[''], [filter]]. + - tlib#input#List(): When type was "si" and the item was picked by + filter, the wrong index was returned. + - tlib#input#List(): Don't check if chars are typed when displaying + the list for the first time. + +0.20 +- The arguments of tlib#tag#Collect() have changed. +- tlib#input#List(): The view can be "suspended" on initial display. +- tlib#input#List(): Follow/trace cursor functionality + +0.21 +- tlib#buffer#InsertText(): Respect tabs and (experimental) formatoptions+=or +- tlib/syntax.vim: Syntax-related functions + +0.22 +- FIX: very magic mode for tlib#rx#Escape() (thanks A Politz) +- FIX: tlib#arg#Ex: escape "!" + +0.23 +- Respect the setting of g:tlib_inputlist_filename_indicators +- tlib#input#List(): Reset syntax on resume; option to make list window "sticky" +- tlib#agent#ToggleStickyList() +- Simplified tlib#url#Decode() +- tlib#arg#Ex(): use fnameescape() if available + +0.24 +- s:prototype.SetInitialFilter: accept list as argument +- Maintain buffer MRU if required + +0.25 +- NEW: tlib#notify#TrimMessage(): trim message to prevent "Press ENTER" +messages (contributed by Erik Falor) +- NEW: tlib#notify#Echo() +- FIX: World.CloseScratch(): Set window +- FIX: tlib#input#ListW(): Set initial_display = 1 on reset + +0.26 +- NEW: tlib#normal#WithRegister() +- FIX: Try not to change numbered registers + +0.27 +- FIX: Cosmetic bug, wrong packaging (thanks Nathan Neff) +- Meaning of World#filter_format changed; new World#filter_options +- Filtering didn't work as advertised +- tlib#string#Count() + +0.28 +- tlib#input#List(): +-- Improved handling of sticky lists; and resume a +suspended list and immediately selects the item under the cursor +-- Experimental "seq" matching style: the conjunctions are sequentially +ordered, they are combined with "OR" (disjunctions), the regexp is +'magic', and "." is expanded to '.\{-}' +-- Experimental "cnfd" matching style: Same as cnf but with an "elastic" +dot "." that matches '\.\{-}' +-- Filtering acts as if &ic=1 && $sc=1 +-- Weighting is done by the filter +- tlib#agent#Input(): Consume when aborting input() +- INCOMPATIBLE CHANGE: Changed eligible values of g:tlib_inputlist_match +to "cnf", "cnfd", "seq" and "fuzzy" +- NEW: tlib#buffer#KeepCursorPosition() +- tlib#buffer#InsertText(): Take care of the extra line when appending +text to an empty buffer. + +0.29 +- tlib#string#Strip(): Strip also control characters (newlines etc.) +- tlib#rx#Suffixes(): 'suffixes' as Regexp +- World#RestoreOrigin(): Don't assume &splitbelow + +0.30 +- World#RestoreOrigin(): Don't assume &splitright + +0.31 +- :TRequire command +-tlib#input#List: For i-type list views, make sure agents are called +with the base indices. + +0.32 +- tlib#agent#Exit: explicitly return empty value (as a consequence, +pressing when browsing an index-list, returns 0 and not "") +- tlib#signs +- tlib#input#List: set local statusline + +0.33 +- Don't reset statusline +- Don't use fnamemodify() to split filenames (for performance reasons) +- scratch: Set ft after setting up scratch options +- tlib#map#PumAccept(key) + +0.34 +- tlib#buffer#HighlightLine(line): call tlib#autocmdgroup#Init() +(reported by Sergey Khorev) + +0.35 +- tlib#input#EditList(): return the list if the user presses esc + +0.36 +- Display a message when the filter is for whatever reason invalid +- Removed tlib#paragraph#Delete() +- New: tlib#paragraph#Define(), tlib#textobjects#StandardParagraph() +- Try to speed up list display (a rewrite of World.DisplayList() etc. is +required) + +0.37 +- g:tlib_inputlist_livesearch_threshold defaults to 1000 +- tlib#World: optional scratch_pos field +- tlib#input#List: By default selects by number but NUMBER is +interpreted as string +- tlib#date +- TTimeCommand + +0.38 +- tlib#World#Resize: set winfix{height|width} + +0.39 +- g:tlib#cache#dont_purge +- tlib#vim#RestoreWindow() +- tlib#ballon#...() + +0.40 +- tlib#agent#ViewFile: Use split/sbuffer if nohidden && modified +- tlib#buffer#GetList(): order by "basename" + +version: "0.41" + - World.UseScratch(): keepalt + - Really include balloon.vim + MD5 checksum: 3fcbc4f7556f5378d39622e62ab8f379 + +version: "0.42" + - tlib#input#List: inserts a *-like wildcard (represented as "__") + - Check if a cache file cannot be created because a directory of the same name exists (display a message if so) + - tlib#cache#Filename: Removed check if a directory of the same name exists (due to inconsistent use) + - Minor improvements related to buffer handling (scratch_split) + - .gitignore + - docs (thanks to blueyed) + - There is no "edit" answer possibility. + - Fix first purge: do nothing if no timestamp file. + - g:tlib_pick_single_item + - Removed pick_single_item. Changed the default behavour when a list has only 1 item. See doc for g:tlib_pick_last_item. + - Updated help for tlib#input#List(); help_extra attribute + - EXPERIMENTAL: cache_var, restore_from_cache, on_leave properties; #Initialize(), #Leave() + - added tlib#cmd#BrowseOutputWithCallback function and :TBrowseScriptnames command + - tlib#cmd#BrowseOutputWithCallback function and :TBrowseScriptnames command documentation + - s:prototype.Initialize(): unlet self.cache_var after restoring values + - tlib#input#List: filter-specific help + - Removed the seq filter (use cnfd or fuzzy instead) + - tlib#input#List: temp_prompt (for help message) + MD5 checksum: aa8b5a4602235cc1a5bc9ee45d801b81 + +version: "0.42" + - g:tlib#cache#silent: don't display messages when purging the cache (fixes #9) + - Changed message when deleting directories in the cache. + - g:tlib#input#use_popup: Don't rely on has('menu') but also check for gtk & win gui (fixes #10) + - debug + - tlib#input#ListW(): Didn't return a list when type == "m" + - docs (solves #11) + MD5 checksum: aa8b5a4602235cc1a5bc9ee45d801b81 + +version: "0.45" + - fuzzy mode: prototype.highlight defaults to g:tlib_inputlist_higroup + - tlib#scratch: Use noautocmd + - tlib#input#ListW(): Use world.RestoreOrigin() instead of tlib#win#SetLayout(world.winview) + - tlib#input#ListW(): Revert to tlib#win#SetLayout(world.winview) + - tlib#cmd#OutputAsList(): Also save output in g:tlib#cmd#last_output + - tlib#agent#Suspend(): Resume on BufEnter + - tlib#input#Resume(): Make sure we are in the right buffer + - tlib#agent#Suspend(): Use only BufEnter event to trigger a Resume + - tlib#input#ListW(): When redisplaying a list, make sure prefix > 0 + - tlib#vcs: Access vcs (initially only git is supported) + - tlib#vcs: improved + - tlib#persistent: Persistent data file names + - tlib#file#With(): Trigger BufRead autocommands + - Duplicate help tags (fixes #13) + - Make sure scrolloff is 0 while viewing the list (fixes https://github.com/tomtom/vikitasks_vim/issues/2) + MD5 checksum: 0af19ebc0e424727a598a988fdc90f4e + + - Support for tinykeymap (move paragraph) + - Moved para_move to autoload/tinykeymap/map + - tlib#vcs: some "diff" commands were defined as "ls"; updated hg def; %s is optional + MD5 checksum: f2f2fe0893e75bb9423c1ddcd01f38f6 +version: "0.46" + + - tlib#input#List: optimizations + - Prepare for multi-mode maps + - tlib#input#List: cnfx is new default filter + - Filters: minor changes to how the pattern is displayed + - g:tlib#input#format_filename: alternative method for formatting filenames + - tlib#input#List: allow multiple keymaps / modes + - Handle rezise events + - Don't initialize the same window twice + - Minor optimizations to how help is displayed + - Handle VimResize event per buffer + - Improve display of filenames & highlighting + - Filename highlighter: set Highlight_filename() + - RunStateHandlers(): set world variable + - Optimize help display + MD5 checksum: e3652927722bdc51935eb1a04238546b +version: "1.00" + + - Set g:tlib_inputlist_and to ' ' again + - g:tlib#input#filename_max_width: maximum display width of filenames + - tlib#input#List: , : run command by name + MD5 checksum: a42f90275cdbe9f7d92cac61b884a2d1 +version: "1.01" + + - #UseInputListScratch(): Make sure the TLib autogroup was created (fixes #14) + MD5 checksum: 5a6da7fc99c7fc7584e8fc2f7bf86fe4 +version: "1.02" + + - tlib#cache#Value(cfile, generator, ftime, ...): cache value & check timestamp + - Replaced g:tlib#cache#silent with g:tlib#cache#verbosity + - FormatFilenames: improved handling of utf8 characters + - tlib#persistent#Value() + - tlib#input#List: Allow filename indiactors defined by the caller + - Custom filename_indicators are displayed after (and clearly separted from) the standard indicators + - Check the return value of an unknown_key agent + - Format filename = "l": Allow ".." as start of a directory name + - Format filename = "l": If the filename is just a filename's tail, display it on both sides + - Set g:tlib_filename_sep to "\" on Windows (again) + - g:tlib#cache#max_filename: If the cache filename is longer than N characters, use |pathshorten()|. + MD5 checksum: b64ce6764f39f40bfc95f3916bbb0057 +version: "1.04" + +version: "1.05" + - tlib#hash: Adler32 & CRC32 (using zlib via ruby) algorithms + - tlib#cache#Filename(): If the cache filename is too long, add the Adler32 checksum to the shortened path + - tlib#cache#Filename(): Use tlib#hash#Adler32() only if the or() function exists + - tlib#hash#Adler32(): Raise error, if or() doesn't exist + - tlib#hash#CRC32(): Alternative implementation of crc32 (doesn't work yet, thus currently disabled) + - tlib#bitwise: Bitwise operations for older versions of vim + - tlib#number: Base conversion + - tlib#input#ListW(): Handle mouse clicks more correctly + - tlib#bitwise#Num2Bits(): Supports returning floats + - tlib#hash#CRC32(): Alternative implementation of crc32 (doesn't work yet) + - tlib#hash#CRC32(): Re-enable ruby version + - tlib#hash#CRC32B(): Implementation of CRC32B checksum in vimscript (used only if +ruby isn't available) + - tlib#hash#CRC32B(): vim version: cache the crc table + - tlib#cache#Filename(): Use tlib#hash#CRC32B(file) instead of not Adler32 for filenames too long + - tlib#hash#CRC32B(): ruby version: return upper case hex value + - g:tlib#hash#use_crc32: define which crc32b version should be used + - Moved spec files from vimtlib to tlib_vim + - tlib#bitwise#Add() and tlib#bitwise#Sub() + - tlib#file#Relative(): Wrong results for filenames that don't exist + - Implementation of hash#Adler32 for earlier vim versions; g:tlib#hash#use_adler32 + - tlib#cache#Filename(): Use adler32 again + - addon-info + - tlib#file#Absolute(): remove redundant "." parts in full filename + - win32: Fix moving window when using :vertical for tlib#inpu#List() + - tlib#cache#Filename(): Don't create wrong directory if the cache filename is too long + - tlib#file#Join(): if strip_slashes, also strip redundant (back)slashes + - tlib#input#ListW(): Always set post_keys variable + - tlib#file#With(): escape backslashes + - tlib#cmd#OutputAsList(): Support for nesting + - tlib#dir#NativeName(dirname) + MD5 checksum: 493f9beca44374de386f20d1613155e3 + + - Rename g:tlib_debug to g:tlib#debug + - Renamed g:tlib_sortprefs_threshold to g:tlib#input#sortprefs_threshold + - Renamed g:tlib#input#livesearch_threshold + - Renamed g:tlib_inputlist_match to g:tlib#input#filter_mode + - Renamed g:tlib_inputlist_higroup to g:tlib#input#higroup + - Renamed g:tlib#debug + - Moved g:tlib_pick_last_item + - Renamed g:tlib#input#and, g:tlib#input#or, g:tlib#input#not + - Moved g:tlib_numeric_chars to autoload/tlib/input.vim + - Renamed g:tlib#input#keyagents_InputList_s, g:tlib#input#keyagents_InputList_m, g:tlib#input#handlers_EditList + - Moved g:tlib_inputlist_pct, g:tlib_inputlist_width_filename, g:tlib_inputlist_filename_indicators, g:tlib_inputlist_shortmessage to autoload/tlib/World.vim + - Renamed tlib#input#pick_last_item (2) + - prototype.SelectItemsByNames() + - filtered_items: Restricted view + - prototype.PrintLines() + - Restricted view (2) + - Moved g:tlib_scroll_lines to autoload/tlib/agent.vim + - prototype.PrintLines() (2) + - tlib#input: Improved handling of popup menu (allows submenu) + - tlib#input: Allow mods in keys + - Moved g:tlib_scratch_pos to autoload/tlib/scratch.vim + - Moved g:tlib_tags_extra, g:tlib_tag_substitute to autoload/tlib/tag.vim + - tlib#agent#CompleteAgentNames(): Respect Arglead + - Move g:tlib_viewline_position to autoload/tlib/buffer.vim + - Move g:tlib_cache to autoload/tlib/cache.vim + - Renamed g:tlib_filename_sep to g:tlib#dir#sep + - prototype.UseScratch(): Set b:tlib_world + - tlib#input: f9 toggles resticted view + - tlib#input: next_agent, next_eval + - tlib#input: Revised use of the popup menu + - tlib#input: Disable popup menu for gui_gtk + - tlib#input: Re-enabled the popup menu for gtk gui + - tlib#input: FIX popup menu on Windows + - Renamed g:tlib_numeric_chars to g:tlib#input#numeric_chars (disabled per-buffer values) (fixes #35) + - Improve scratch list + - New: tlib#grep + - Merge branch 'master' of https://github.com/bruno-/tlib_vim into pull16 + - g:tlib_scratch_hidden: Configure how to "hide" the scratch buffer + - tlib#grep#Do: don't escape "*" in patterns + - Optimize use of visible scratch buffers + - World.scratch_hidden parameter + - scratch: Always use keepalt & keepjumps + MD5 checksum: 2e40449c47dc606ccef57aa0b1e22e8e +version: "1.06" + +version: "1.07" + - Help template + - prototype.Highlight_filename(): Use matchstr() instead of fnamemodify() + - Display buffer-related filename indicators only if g:tlib_inputlist_filename_indicators is true + - tlib#file#Join(): strip_slashes defaults to 1 + MD5 checksum: 6c8fa96fd3747be05df848ee93dd789b + +version: "1.08" + - list#input: Improved support for file indicators (closes #17) + - tlib#char#Get(): Optionally, also return mod + - tlib#input#ListW: Use #DisplayFormat(world.list) + - Renamed cnfx filter to glob & minor filter-related enhancements + - list#input: Make help available as command; help cannot be called via ? + - list#input: Improved help message + - list#input: Support Home & End keys + - list#input: Added glob filter + - tlib#agent#ShowInfo: Show full filename + - tlib#cmd#BrowseOutputWithCallback: Support calling callback with multiple results + - tlib#cmd#ParseScriptname: Properly parse results from :scriptnames + - tlib#tab#Set() + - Prepare for proper handling of scratch_split == -1 + - tlib#vim#CopyFunction() + - tlib#cache#Value(): If generator is empty, use the optional argument as start value + - tlib#persistent#Get() refers to tlib#cache#Get() + MD5 checksum: 459ec620168d1ae9b18c69eb3f991832 + + - tlib#cache#Filename(): Use sha256() for VIM >= 7.4 + - tlib#cache#Value(): Undo previous hack + - tlib#list#Uniq(): option to remove empty values + - tlib#cache#MTime(); tlib#persistent#Save() calls tlib#cache#Save() + - tlib#input#ListW: Temporarily set noshowmode + - tlib#list#Uniq(): Fix handling of empty items + - lis picker: Remove from help + - tlib#list#Uniq(): Implementation based on syntastic#util#unique(list) by scrooloose + MD5 checksum: b5fb4107d63930c2c8b1f0f6b3a7ff07 +version: "1.09" + + - tlib#cache#Filename(): Use sha256() for VIM >= 7.4 + - tlib#cache#Value(): Undo previous hack + - tlib#list#Uniq(): option to remove empty values + - tlib#cache#MTime(); tlib#persistent#Save() calls tlib#cache#Save() + - tlib#input#ListW: Temporarily set noshowmode + - tlib#list#Uniq(): Fix handling of empty items + - lis picker: Remove from help + - tlib#list#Uniq(): Implementation based on syntastic#util#unique(list) by scrooloose + MD5 checksum: b5fb4107d63930c2c8b1f0f6b3a7ff07 +version: "1.09" + + - tlib#string#Chomp: Optional argument: max number of chars that should be removed + MD5 checksum: 8c1b94e25045580874e2f892d509291b +version: "1.10" + + - tlib#vcs#FindVCS(filename): Wrong parameters to fnamemodifiy if filename is a directory + - Some system-related functions (e.g. facilitate use of cygwin tools) + - tlib#arg#StringAsKeyArgsEqual(), tlib#arg#StringAsKeyArgs(): Support "key=val" type argument lists + - tlib#vcs#Executable() + - scripts/create_crc_table.rb + - tlib#var#Get(): For namespaces other than global, replace "#" with "_" + MD5 checksum: 4a33f2f23e1fc6600b32e7f8323e001e +version: "1.11" + + - tlib#list#ToDictionary() + - tlib#dir#CanonicName(): Use tlib#file#Canonic() + - tlib#file#Canonic() + MD5 checksum: 7995ab58f31eb6673d20deab8761838e +version: "1.12" + + - SetInitialFilter(): Use deepcopy() + - tlib#var#List(): use keys(namespace) for newer versions of vim + - g:tlib#input#user_shortcuts (not functional yet) + - tlib#input#List: state "picked" + - UseInputListScratch(): Allow customization via self.index_next_syntax + - tlib#cmd#Capture() + - Facilitate customization of key agents via g:tlib_extend_keyagents_InputList_s, g:tlib_extend_keyagents_InputList_m + MD5 checksum: 7dd8b17a1a5b555df979381dcbd4c9aa +version: "1.13" + + - SetInitialFilter(): Use deepcopy() + - tlib#var#List(): use keys(namespace) for newer versions of vim + - g:tlib#input#user_shortcuts (not functional yet) + - tlib#input#List: state "picked" + - UseInputListScratch(): Allow customization via self.index_next_syntax + - tlib#cmd#Capture() + - Facilitate customization of key agents via g:tlib_extend_keyagents_InputList_s, g:tlib_extend_keyagents_InputList_m + MD5 checksum: 7dd8b17a1a5b555df979381dcbd4c9aa +version: "1.13" + +version: "1.14" + - FIX #18: Make sure the scratch isn't readonly + - FIX: display filter (properly handle backslashes) + - Remove loaded_* guard from autoload files + - tlib#notify#Echo(): minor changes + - tlib#file#Edit() (used by tlib#agent#ViewFile) + - tlib#buffer#GetList(): Buffer numbers are converted to numbers + - tlib#sys: Change order of functions (move tlib#sys#IsCygwinBin to the (possibly FIX #19) + - g:tlib#sys#check_cygpath: Call tlib#sys#IsExecutable('cygpath', 1) (possibly FIX #19) + MD5 checksum: 2cf6386218736a2d09db43c8e751e5a4 + +version: "1.15" + - tlib#file#Join(): New optional argument: maybe_absolute Drop preceding parts if a part looks like an absolute filename + - tlib#sys#Open(), tlib#sys#IsSpecial() (moved from viki) + - tlib#list#Uniq(): Handle hetergenous lists + - FIX #21: duplicate help tag + - NEW tlib#dictionary#Rev() + - tlib#input#List(): Use to complete current word + - NEW tlib#arg#GetOpts(); ENH tlib#arg#StringAsKeyArgsEqual() + - cache: Allow for in memory cache + - NEW tlib#eval#Extend() + - Move qfl/loclist browser from trag to tlib + - FIX tlib#eval#Extend() + - Simplify tlib#eval#Extend() + - World.index_next_syntax may be a dict + - tlib#qfl#QflList: Use copy() + - tlib#arg#GetOpts: Handle exit code + MD5 checksum: 13fd8b0e4ba9cd932c57fc40ac3f641f + +version: "1.15" + - tlib#file#Join(): New optional argument: maybe_absolute Drop preceding parts if a part looks like an absolute filename + - tlib#sys#Open(), tlib#sys#IsSpecial() (moved from viki) + - tlib#list#Uniq(): Handle hetergenous lists + - FIX #21: duplicate help tag + - NEW tlib#dictionary#Rev() + - tlib#input#List(): Use to complete current word + - NEW tlib#arg#GetOpts(); ENH tlib#arg#StringAsKeyArgsEqual() + - cache: Allow for in memory cache + - NEW tlib#eval#Extend() + - Move qfl/loclist browser from trag to tlib + - FIX tlib#eval#Extend() + - Simplify tlib#eval#Extend() + - World.index_next_syntax may be a dict + - tlib#qfl#QflList: Use copy() + - tlib#arg#GetOpts: Handle exit code + MD5 checksum: 13fd8b0e4ba9cd932c57fc40ac3f641f + + - tlib#arg#GetOpts: Handle short options + - tlib#arg: support short flags & facilitate completion + - NEW :TLibTrace + - tlib#sys#system_browser: FIX XDG string + - NEW tlib#sys#SystemInDir() (used by tlib#vcs#Ls) + - tlib#agent#Complete: improve fltrx + - Remove tlib#arg#Key(), :TKeyArg + - Move :TRequire, :TTimeCommand to macros/tlib.vim + - NEW tlib#cmd#TBrowseScriptnames() + - TScratch: use empty('') + - NEW :TLibTrace + - tlib#qfl: FIX TTagedFilesFilename regexp + - Remove tlib#arg#Key() + - tlib#buffer#InsertText(): Don't use TKeyArg + - tlib#eval#Extend: don't assign value + - NEW :TLibTrace, tlib#trace (was tlib#debug) + - NEW tlib#string#SplitCommaList() + - NEW tlib#time#FormatNow() + - tlib#arg#GetOpts: selectively disable "long", "short" flags + - tlib#arg#CComplete(): Support values completion (complete_customlist field) + - NEW tlib#date#Shift() + - tlib#qfl#Balloon(): Handle items with no bufnr + - NEW tlib#file#Glob, tlib#file#Globpath + - tlib#progressbar#Display(): optional "always" argument + - tlib#vcs#GitLsPostprocess(): Try to handle encoded filenames from git ls-files + - tlib#vcs#GitLsPostprocess: Eval only \ddd substrings + - FIX #22: duplicate tag + - tlib#buffer: Use 2match instead of 3match (incompatibility with matchparen) + - FIX #23: duplicate help tag + - tlib#string#SplitCommaList: optional "sep" argument + - Rename TLibTrace -> Tlibtrace; NEW Tlibtraceset command + - Rename s:SetSyntax -> tlib#qfl#SetSyntax + - mv tlib#rx#Convert to incubator + MD5 checksum: f3656fb35b7b3033084d6c5e504aca61 +version: "1.16" + + - tlib#input#List: #ReduceFilter: make sure the regexp is valid + - TTimeCommand -> Ttimecommand + - tlib#eval#Extend: mode argument for expand() compatibility + - tlib#input#List: Key handlers can have additional arguments + - tlib#qfl#AgentWithSelected: Set world + - prototype.UseInputListScratch: Run tlib_UseInputListScratch hook earlier + - tlib#qfl#AgentWithSelected: typo + - tlib#arg#GetOpts: type conversion (comma-separated lists etc.) + - tlib#arg: validators + - NEW tlib#date#IsDate() + - tlib#balloon#Remove: Unset &ballooneval, &balloonexpr + - NEW tlib#balloon#Expand() + - NEW tlib#date#Format() + - FIX tlib#date#Shift(..., "+Xm") for months + - NEW tlib#trace#Backtrace() + - NEW tlib#type#Is(), tlib#type#Are(), tlib#type#Has(), tlib#type#Have() + - NEW :Tlibassert + MD5 checksum: 3c4125a28ff1860accd254846651c251 +version: "1.17" + + - tlib#input#List: #ReduceFilter: make sure the regexp is valid + - TTimeCommand -> Ttimecommand + - tlib#eval#Extend: mode argument for expand() compatibility + - tlib#input#List: Key handlers can have additional arguments + - tlib#qfl#AgentWithSelected: Set world + - prototype.UseInputListScratch: Run tlib_UseInputListScratch hook earlier + - tlib#qfl#AgentWithSelected: typo + - tlib#arg#GetOpts: type conversion (comma-separated lists etc.) + - tlib#arg: validators + - NEW tlib#date#IsDate() + - tlib#balloon#Remove: Unset &ballooneval, &balloonexpr + - NEW tlib#balloon#Expand() + - NEW tlib#date#Format() + - FIX tlib#date#Shift(..., "+Xm") for months + - NEW tlib#trace#Backtrace() + - NEW tlib#type#Is(), tlib#type#Are(), tlib#type#Has(), tlib#type#Have() + - NEW :Tlibassert + MD5 checksum: 3c4125a28ff1860accd254846651c251 +version: "1.17" + + - tlib#input#List: #ReduceFilter: make sure the regexp is valid + - TTimeCommand -> Ttimecommand + - tlib#eval#Extend: mode argument for expand() compatibility + - tlib#input#List: Key handlers can have additional arguments + - tlib#qfl#AgentWithSelected: Set world + - prototype.UseInputListScratch: Run tlib_UseInputListScratch hook earlier + - tlib#qfl#AgentWithSelected: typo + - tlib#arg#GetOpts: type conversion (comma-separated lists etc.) + - tlib#arg: validators + - NEW tlib#date#IsDate() + - tlib#balloon#Remove: Unset &ballooneval, &balloonexpr + - NEW tlib#balloon#Expand() + - NEW tlib#date#Format() + - FIX tlib#date#Shift(..., "+Xm") for months + - NEW tlib#trace#Backtrace() + - NEW tlib#type#Is(), tlib#type#Are(), tlib#type#Has(), tlib#type#Have() + - NEW :Tlibassert + MD5 checksum: 3c4125a28ff1860accd254846651c251 +version: "1.17" + + - tlib#input#List: #ReduceFilter: make sure the regexp is valid + - TTimeCommand -> Ttimecommand + - tlib#eval#Extend: mode argument for expand() compatibility + - tlib#input#List: Key handlers can have additional arguments + - tlib#qfl#AgentWithSelected: Set world + - prototype.UseInputListScratch: Run tlib_UseInputListScratch hook earlier + - tlib#qfl#AgentWithSelected: typo + - tlib#arg#GetOpts: type conversion (comma-separated lists etc.) + - tlib#arg: validators + - NEW tlib#date#IsDate() + - tlib#balloon#Remove: Unset &ballooneval, &balloonexpr + - NEW tlib#balloon#Expand() + - NEW tlib#date#Format() + - FIX tlib#date#Shift(..., "+Xm") for months + - NEW tlib#trace#Backtrace() + - NEW tlib#type#Is(), tlib#type#Are(), tlib#type#Has(), tlib#type#Have() + - NEW :Tlibassert + MD5 checksum: 3c4125a28ff1860accd254846651c251 +version: "1.17" + + - tlib#arg: Completion for comma-separated lists + - Use "silent cd" + - NEW tlib#type#DefSchema(); FIX tlib#type#Has() + - tlib#cache#Value(): minor change + - tlib#date#IsDate() also checks whether the date is valid + - ! tlib#sys#Open(): escape special chars only once + - tlib#trace#Print: Allow for strings + - :Tlibtrace, :Tlibtraceset, :Tlibassert remove `-bar` + - NEW :Tlibtype (type/schema assertions); tlib#type#Is() also accepts schemas as "types" + - tlib#dir#CD(): Use haslocaldir() + - tlib#qfl#AgentGotoQFE: Don't use wincmd w + - NEW tlib#string#Input() + - FIX g:tlib#sys#system_rx; add OpenOffice exensions to g:tlib#sys#special_suffixes + - NEW tlib#selection#GetSelection() + - tlib#date#Shift(): Fix "Xm", ++specs + - tlib#trace#Set: FIX Properly handly "-label" + MD5 checksum: c3a1fe7d3cd86becbd3f7b0ba7ae9cd8 +version: "1.19" + +version: "1.20" + - tlib#arg: Completion for comma-separated lists + - Use "silent cd" + - NEW tlib#type#DefSchema(); FIX tlib#type#Has() + - tlib#cache#Value(): minor change + - tlib#date#IsDate() also checks whether the date is valid + - ! tlib#sys#Open(): escape special chars only once + - tlib#trace#Print: Allow for strings + - :Tlibtrace, :Tlibtraceset, :Tlibassert remove `-bar` + - NEW :Tlibtype (type/schema assertions); tlib#type#Is() also accepts schemas as "types" + - tlib#dir#CD(): Use haslocaldir() + - tlib#qfl#AgentGotoQFE: Don't use wincmd w + - NEW tlib#string#Input() + - FIX g:tlib#sys#system_rx; add OpenOffice exensions to g:tlib#sys#special_suffixes + - NEW tlib#selection#GetSelection() + - tlib#date#Shift(): Fix "Xm", ++specs + - tlib#trace#Set: FIX Properly handly "-label" + MD5 checksum: c919e0782931a8c628c6996903f989d3 + + - tlib#date#Shift(): Support for business days 'Nb' + - tlib#list#Uniq: Properly handle empty strings + - tlib#trace: Use g:tlib#trace#printer and tlib#trace#Printer_{printer} + - tlib#dictionary#Rev: Optional argument `opts = {}`; properly handle empty values etc. + - NEW g:tlib#trace#hl + - NEW spec/dictionary.vim + - tlib#agent#CompleteAgentNames: case insensitive + - tlib#arg#CComplete: --[no-]debug option + - tlib#date#Format: use localtime() if no arg is provided + - NEW tlib#file#IsAbsolute + - NEW tlib#notify#PrintError() + - tlib#trace#Print: FIX s/exec/call/ + - tlib#type#Is() match full type name + - NEW tlib#string#MatchAll() + - Tlibtraceset, tlib#trace#Set(): If no `+` or `-` is prepended, assume `+`. + - tlib#list#Input: fix highlighting for filenames + - tlib#input#ListW: use world.CloseScratch(1) + - tlib#agent#ViewFile: Ignore errors in :exec back + - NEW tlib#agent#EditFileInWindow() + - :Tlibtraceset uses tlib#arg#GetOpts(), i.e. you can set the log file more easily + MD5 checksum: 20a48e225f32b9f58808096a5377af04 +version: "1.22" + + - tlib#date#Shift(): Support for business days 'Nb' + - tlib#list#Uniq: Properly handle empty strings + - tlib#trace: Use g:tlib#trace#printer and tlib#trace#Printer_{printer} + - tlib#dictionary#Rev: Optional argument `opts = {}`; properly handle empty values etc. + - NEW g:tlib#trace#hl + - NEW spec/dictionary.vim + - tlib#agent#CompleteAgentNames: case insensitive + - tlib#arg#CComplete: --[no-]debug option + - tlib#date#Format: use localtime() if no arg is provided + - NEW tlib#file#IsAbsolute + - NEW tlib#notify#PrintError() + - tlib#trace#Print: FIX s/exec/call/ + - tlib#type#Is() match full type name + - NEW tlib#string#MatchAll() + - Tlibtraceset, tlib#trace#Set(): If no `+` or `-` is prepended, assume `+`. + - tlib#list#Input: fix highlighting for filenames + - tlib#input#ListW: use world.CloseScratch(1) + - tlib#agent#ViewFile: Ignore errors in :exec back + - NEW tlib#agent#EditFileInWindow() + - :Tlibtraceset uses tlib#arg#GetOpts(), i.e. you can set the log file more easily + MD5 checksum: 20a48e225f32b9f58808096a5377af04 +version: "1.22" + + - bump version 1.23 + misc changes + - FIX #24: avoid vim8 features + - tlib#win#GetID(): Alternative implementation sets a window variable to identify the window + - tlib#arg#GetOpts(): If args is a dict, return it + - tlib#file#FilterFiles(): FIX typo + - tlib#trace#Set: Experimental support for log levels + - tlib#input#ListW: make sure to close scratch when <= 1 items are in the list + - FIX #25: set win_nr again; fix some lint warnings + - tlib#progressbar#Init(): returns a statusline definition that can be used for restor + MD5 checksum: c4d6e018cbbd3b286a9b1648b748c1f3 +version: "1.23" + + - bump version 1.23 + misc changes + - FIX #24: avoid vim8 features + - tlib#win#GetID(): Alternative implementation sets a window variable to identify the window + - tlib#arg#GetOpts(): If args is a dict, return it + - tlib#file#FilterFiles(): FIX typo + - tlib#trace#Set: Experimental support for log levels + - tlib#input#ListW: make sure to close scratch when <= 1 items are in the list + - FIX #25: set win_nr again; fix some lint warnings + - tlib#progressbar#Init(): returns a statusline definition that can be used for restor + MD5 checksum: c4d6e018cbbd3b286a9b1648b748c1f3 +version: "1.23" + + - bump version 1.23 + misc changes + - FIX #24: avoid vim8 features + - tlib#win#GetID(): Alternative implementation sets a window variable to identify the window + - tlib#arg#GetOpts(): If args is a dict, return it + - tlib#file#FilterFiles(): FIX typo + - tlib#trace#Set: Experimental support for log levels + - tlib#input#ListW: make sure to close scratch when <= 1 items are in the list + - FIX #25: set win_nr again; fix some lint warnings + - tlib#progressbar#Init(): returns a statusline definition that can be used for restor + MD5 checksum: c4d6e018cbbd3b286a9b1648b748c1f3 +version: "1.23" + + - bump version 1.23 + misc changes + - FIX #24: avoid vim8 features + - tlib#win#GetID(): Alternative implementation sets a window variable to identify the window + - tlib#arg#GetOpts(): If args is a dict, return it + - tlib#file#FilterFiles(): FIX typo + - tlib#trace#Set: Experimental support for log levels + - tlib#input#ListW: make sure to close scratch when <= 1 items are in the list + - FIX #25: set win_nr again; fix some lint warnings + - tlib#progressbar#Init(): returns a statusline definition that can be used for restor + MD5 checksum: c4d6e018cbbd3b286a9b1648b748c1f3 +version: "1.23" + + - bump version 1.23 + misc changes + - FIX #24: avoid vim8 features + - tlib#win#GetID(): Alternative implementation sets a window variable to identify the window + - tlib#arg#GetOpts(): If args is a dict, return it + - tlib#file#FilterFiles(): FIX typo + - tlib#trace#Set: Experimental support for log levels + - tlib#input#ListW: make sure to close scratch when <= 1 items are in the list + - FIX #25: set win_nr again; fix some lint warnings + - tlib#progressbar#Init(): returns a statusline definition that can be used for restor + MD5 checksum: c4d6e018cbbd3b286a9b1648b748c1f3 +version: "1.23" + + - bump version 1.23 + misc changes + - FIX #24: avoid vim8 features + - tlib#win#GetID(): Alternative implementation sets a window variable to identify the window + - tlib#arg#GetOpts(): If args is a dict, return it + - tlib#file#FilterFiles(): FIX typo + - tlib#trace#Set: Experimental support for log levels + - tlib#input#ListW: make sure to close scratch when <= 1 items are in the list + - FIX #25: set win_nr again; fix some lint warnings + - tlib#progressbar#Init(): returns a statusline definition that can be used for restor + MD5 checksum: c4d6e018cbbd3b286a9b1648b748c1f3 +version: "1.23" + + - bump version 1.23 + misc changes + - FIX #24: avoid vim8 features + - tlib#win#GetID(): Alternative implementation sets a window variable to identify the window + - tlib#arg#GetOpts(): If args is a dict, return it + - tlib#file#FilterFiles(): FIX typo + - tlib#trace#Set: Experimental support for log levels + - tlib#input#ListW: make sure to close scratch when <= 1 items are in the list + - FIX #25: set win_nr again; fix some lint warnings + - tlib#progressbar#Init(): returns a statusline definition that can be used for restor + MD5 checksum: c4d6e018cbbd3b286a9b1648b748c1f3 +version: "1.23" + + - bump version 1.23 + misc changes + - FIX #24: avoid vim8 features + - tlib#win#GetID(): Alternative implementation sets a window variable to identify the window + - tlib#arg#GetOpts(): If args is a dict, return it + - tlib#file#FilterFiles(): FIX typo + - tlib#trace#Set: Experimental support for log levels + - tlib#input#ListW: make sure to close scratch when <= 1 items are in the list + - FIX #25: set win_nr again; fix some lint warnings + - tlib#progressbar#Init(): returns a statusline definition that can be used for restor + MD5 checksum: c4d6e018cbbd3b286a9b1648b748c1f3 +version: "1.23" + + - bump version 1.23 + misc changes + - FIX #24: avoid vim8 features + - tlib#win#GetID(): Alternative implementation sets a window variable to identify the window + - tlib#arg#GetOpts(): If args is a dict, return it + - tlib#file#FilterFiles(): FIX typo + - tlib#trace#Set: Experimental support for log levels + - tlib#input#ListW: make sure to close scratch when <= 1 items are in the list + - FIX #25: set win_nr again; fix some lint warnings + - tlib#progressbar#Init(): returns a statusline definition that can be used for restor + MD5 checksum: c4d6e018cbbd3b286a9b1648b748c1f3 +version: "1.23" + diff --git a/sources_non_forked/tlib/LICENSE.TXT b/sources_non_forked/tlib/LICENSE.TXT new file mode 100644 index 00000000..94a9ed02 --- /dev/null +++ b/sources_non_forked/tlib/LICENSE.TXT @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/sources_non_forked/tlib/README b/sources_non_forked/tlib/README index f5a6792e..98a20bb6 100644 --- a/sources_non_forked/tlib/README +++ b/sources_non_forked/tlib/README @@ -1,72 +1,32 @@ -This is a mirror of http://www.vim.org/scripts/script.php?script_id=1863 - This library provides some utility functions. There isn't much need to install it unless another plugin requires you to do so. -The most useful functions provided by this library probably are: +Most of the library is included in autoload files. No autocommands are +created. With the exception of loading ../plugin/02tlib.vim at startup +the library has no impact on startup time or anything else. -tlib#input#List(), tlib#input#ListW() - - Display a list - - Dynamically filter items matching a pattern (somethat like google) - - E.g. you filter for "foo -bar": show all entries containing foo but not bar. - - Select items from a list - - Do stuff - - Developers can define keys that trigger some action with the - selected items - - Demo: http://vimsomnia.blogspot.com/2010/11/selecting-items-from-list-with-tlibs.html +The change-log is included at the bottom of ../plugin/02tlib.vim +(move the cursor over the file name and type gfG) -tlib#input#EditList - + Edit a list (copy, cut, paste, delete, edit ...) - -:TLet VAR = VALUE - Set a variable only if it doesn't already exist. - -:TScratch - Open a scratch buffer (a buffer without a file). - -:TVarArg VAR1, [VAR2, DEFAULT2] ... - Handle "rest" (variable) arguments in functions. - EXAMPLES: - function! Foo(...) - TVarArg ['a', 1], 'b' - echo 'a='. a - echo 'b='. b - endf - -TBrowseOutput COMMAND - Every wondered how to effciently browse the output of a command - without redirecting it to a file? This command takes a command as - argument and presents the output via |tlib#input#List()| so that you - can easily search for a keyword (e.g. the name of a variable or - function) and the like. - - If you press enter, the selected line will be copied to the command - line. Press ESC to cancel browsing. - - EXAMPLES: - TBrowseOutput 20verb TeaseTheCulprit - TBrowseOutput let - TBrowseOutput map +Demo of |tlib#input#List()|: +http://vimsomnia.blogspot.com/2010/11/selecting-items-from-list-with-tlibs.html -Related (small) plugins that utilize tlib and thus provide some degree of uniform user experience: - tbibtools (vimscript #1915): bibtex-related utilities (sort, reformat, list contents ...) - tmarks (vimscript #2594): Browse, place, & delete marks - tmboxbrowser (vimscript #1906): A mbox browser -- Read your e-mails with vim - tmru (vimscript #1864): Most Recently Used Files - trag (vimscript #2033): A slightly language-aware alternative to grep - tregisters (vimscript #2017): List, edit, and run/execute registers/clipboards - tselectbuffer (vimscript #1866): A quick buffer selector/switcher - tselectfiles (vimscript #1865): A quick file selector/browser/explorer (sort of) - ttagecho (vimscript #2055): Show current tag information - ttagcomplete (vimscript #2069): Context-sensitive tags-based completion and code skeletons - ttags (vimscript #2018): Tag list browser (List, filter, preview, jump to tags) - ttoc (vimscript #2014): A regexp-based table of contents of the current buffer - vikitasks (vimscript #2894): Search viki files for tasks and display them in a list +----------------------------------------------------------------------- +Install~ + +Edit the vba file and type: > + + :so % + +See :help vimball for details. If you have difficulties, please make +sure, you have the current version of vimball (vimscript #1502) +installed. -For full details, please see: -http://github.com/tomtom/tlib_vim/blob/master/doc/tlib.txt -Also available via git -http://github.com/tomtom/tlib_vim + + +License: GPLv3 or later + + diff --git a/sources_non_forked/tlib/addon-info.json b/sources_non_forked/tlib/addon-info.json new file mode 100644 index 00000000..35855310 --- /dev/null +++ b/sources_non_forked/tlib/addon-info.json @@ -0,0 +1,9 @@ +{ + "name" : "tlib", + "version" : "dev", + "author" : "Tom Link ", + "maintainer" : "Tom Link ", + "repository" : {"type": "git", "url": "git://github.com/tomtom/tlib_vim.git"}, + "dependencies" : {}, + "description" : "tlib -- A library of vim functions" +} diff --git a/sources_non_forked/tlib/autoload/tinykeymap/map/para_move.vim b/sources_non_forked/tlib/autoload/tinykeymap/map/para_move.vim new file mode 100644 index 00000000..908f5f7d --- /dev/null +++ b/sources_non_forked/tlib/autoload/tinykeymap/map/para_move.vim @@ -0,0 +1,12 @@ +" para_move.vim +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2012-08-28. +" @Last Change: 2012-08-29. +" @Revision: 3 + +" Move paragraphs +call tinykeymap#EnterMap("para_move", "gp", {'name': 'move paragraph'}) +call tinykeymap#Map("para_move", "j", "silent call tlib#paragraph#Move('Down', '')") +call tinykeymap#Map("para_move", "k", "silent call tlib#paragraph#Move('Up', '')") + diff --git a/sources_non_forked/tlib/autoload/tlib/Filter_cnf.vim b/sources_non_forked/tlib/autoload/tlib/Filter_cnf.vim index 0bcb6c0e..bfdbda38 100644 --- a/sources_non_forked/tlib/autoload/tlib/Filter_cnf.vim +++ b/sources_non_forked/tlib/autoload/tlib/Filter_cnf.vim @@ -3,8 +3,8 @@ " @Website: http://www.vim.org/account/profile.php?user_id=4037 " @License: GPL (see http://www.gnu.org/licenses/gpl.txt) " @Created: 2008-11-25. -" @Last Change: 2014-11-18. -" @Revision: 0.0.114 +" @Last Change: 2017-09-28. +" @Revision: 11.0.114 let s:prototype = tlib#Object#New({'_class': ['Filter_cnf'], 'name': 'cnf'}) "{{{2 let s:prototype.highlight = g:tlib#input#higroup @@ -47,7 +47,8 @@ function! s:prototype.AssessName(world, name) dict "{{{3 " if flt =~# '\u' && a:name =~# flt " let xa += 5 " endif - + let rel = 1.0 + 5.0 * len(flt) / len(a:name) + let xa += float2nr(rel) if a:name =~ '\^'. flt let xa += 4 elseif a:name =~ '\<'. flt @@ -131,7 +132,7 @@ function! s:prototype.ReduceFrontFilter(world) dict "{{{3 if empty(str) let filter = filter[0 : -2] else - let filter = strpart(filter, 0, len(filter) - len(str)) + let filter = tlib#string#Strcharpart(filter, 0, len(filter) - len(str)) endif " TLogVAR str, filter let a:world.filter[0][0] = filter diff --git a/sources_non_forked/tlib/autoload/tlib/World.vim b/sources_non_forked/tlib/autoload/tlib/World.vim index fddf7b2f..0d0094ab 100644 --- a/sources_non_forked/tlib/autoload/tlib/World.vim +++ b/sources_non_forked/tlib/autoload/tlib/World.vim @@ -1,7 +1,8 @@ " @Author: Tom Link (micathom AT gmail com?subject=[vim]) " @Website: http://www.vim.org/account/profile.php?user_id=4037 " @License: GPL (see http://www.gnu.org/licenses/gpl.txt) -" @Revision: 1432 +" @Revision: 1482 + " :filedoc: " A prototype used by |tlib#input#List|. @@ -12,9 +13,15 @@ " See |tlib#input#List()|. TLet g:tlib_inputlist_pct = 50 +" Max height for a horizontal list. +TLet g:tlib_inputlist_max_lines = -1 + +" Max width for a vertical list. +TLet g:tlib_inputlist_max_cols = -1 + " Size of filename columns when listing filenames. " See |tlib#input#List()|. -TLet g:tlib_inputlist_width_filename = '&co / 3' +TLet g:tlib_inputlist_width_filename = '&columns / 3' " TLet g:tlib_inputlist_width_filename = 25 " If true, |tlib#input#List()| will show some indicators about the @@ -92,7 +99,7 @@ let s:prototype = tlib#Object#New({ \ 'timeout_resolution': 2, \ 'tabpagenr': -1, \ 'type': '', - \ 'win_wnr': -1, + \ 'win_id': g:tlib#win#null_id, \ 'win_height': -1, \ 'win_width': -1, \ 'win_pct': 25, @@ -100,7 +107,7 @@ let s:prototype = tlib#Object#New({ " \ 'handlers': [], " \ 'filter_options': '\c', -function! tlib#World#New(...) +function! tlib#World#New(...) abort let object = s:prototype.New(a:0 >= 1 ? a:1 : {}) call object.SetMatchMode(tlib#var#Get('tlib#input#filter_mode', 'g', 'cnf')) return object @@ -108,8 +115,8 @@ endf " :nodoc: -function! s:prototype.Set_display_format(value) dict "{{{3 - if a:value == 'filename' +function! s:prototype.Set_display_format(value) dict abort "{{{3 + if a:value ==# 'filename' call self.Set_highlight_filename() let self.display_format = 'world.FormatFilename(%s)' else @@ -119,14 +126,14 @@ endf " :nodoc: -function! s:prototype.DisplayFormat(list) dict "{{{3 +function! s:prototype.DisplayFormat(list) dict abort "{{{3 let display_format = self.display_format if !empty(display_format) if has_key(self, 'InitFormatName') call self.InitFormatName() endif let cache = self.fmt_display - " TLogVAR display_format, fmt_entries + Tlibtrace 'tlib', display_format return map(copy(a:list), 'self.FormatName(cache, display_format, v:val)') else return a:list @@ -135,15 +142,15 @@ endf " :nodoc: -function! s:prototype.Set_highlight_filename() dict "{{{3 +function! s:prototype.Set_highlight_filename() dict abort "{{{3 let self.tlib_UseInputListScratch = 'call world.Highlight_filename()' endf -if g:tlib#input#format_filename == 'r' +if g:tlib#input#format_filename ==# 'r' " :nodoc: - function! s:prototype.Highlight_filename() dict "{{{3 + function! s:prototype.Highlight_filename() dict abort "{{{3 syntax match TLibDir /\s\+\zs.\{-}[\/]\ze[^\/]\+$/ hi def link TLibDir Directory syntax match TLibFilename /[^\/]\+$/ @@ -151,16 +158,16 @@ if g:tlib#input#format_filename == 'r' endf " :nodoc: - function! s:prototype.FormatFilename(file) dict "{{{3 + function! s:prototype.FormatFilename(file) dict abort "{{{3 if !has_key(self.fmt_options, 'maxlen') - let maxco = &co - len(len(self.base)) - eval(g:tlib#input#filename_padding_r) + let maxco = &columns - len(len(self.base)) - eval(g:tlib#input#filename_padding_r) let maxfi = max(map(copy(self.base), 'strwidth(v:val)')) let self.fmt_options.maxlen = min([maxco, maxfi]) - " TLogVAR maxco, maxfi, self.fmt_options.maxlen + Tlibtrace 'tlib', maxco, maxfi, self.fmt_options.maxlen endif let max = self.fmt_options.maxlen if len(a:file) > max - let filename = '...' . strpart(a:file, len(a:file) - max + 3) + let filename = '...' . tlib#string#Strcharpart(a:file, len(a:file) - max + 3) else let filename = printf('% '. max .'s', a:file) endif @@ -170,16 +177,17 @@ if g:tlib#input#format_filename == 'r' else " :nodoc: - function! s:prototype.Highlight_filename() dict "{{{3 + function! s:prototype.Highlight_filename() dict abort "{{{3 " let self.width_filename = 1 + eval(g:tlib_inputlist_width_filename) - " TLogVAR self.base + Tlibtrace 'tlib', self.base let self.width_filename = min([ - \ get(self, 'width_filename', &co), - \ empty(g:tlib#input#filename_max_width) ? &co : eval(g:tlib#input#filename_max_width), + \ get(self, 'width_filename', &columns), + \ empty(g:tlib#input#filename_max_width) ? &columns : eval(g:tlib#input#filename_max_width), \ max(map(copy(self.base), 'strwidth(matchstr(v:val, "[^\\/]*$"))')) \ ]) " TLogVAR self.width_filename - exec 'syntax match TLibDir /\%>'. (1 + self.width_filename) .'c \(|\|\[[^]]*\]\) \zs\(\(\a:\|\.\.\|\.\.\..\{-}\)\?[\/][^&<>*|]\{-}\)\?[^\/]\+$/ contained containedin=TLibMarker contains=TLibFilename' + " exec 'syntax match TLibDir /\%>'. (1 + self.width_filename) .'c \(|\|\[[^]]*\]\) \zs\(\(\a:\|\.\.\|\.\.\..\{-}\)\?[\/][^&<>*|]\{-}\)\?[^\/]\+$/ contained containedin=TLibMarker contains=TLibFilename' + exec 'syntax match TLibDir /\%>'. (1 + self.width_filename) .'c \(|\|\[[^]]*\]\) \zs[^&<>*|]*$/ contained containedin=TLibMarker contains=TLibFilename' exec 'syntax match TLibMarker /\%>'. (1 + self.width_filename) .'c \(|\|\[[^]]*\]\) \S.*$/ contains=TLibDir' " exec 'syntax match TLibDir /\(|\|\[.\{-}\]\) \zs\(\(\a:\|\.\.\|\.\.\..\{-}\)\?[\/][^&<>*|]\{-}\)\?[^\/]\+$/ contained containedin=TLibMarker contains=TLibFilename' " exec 'syntax match TLibMarker /\(|\|\[.\{-}\]\) \S.*$/ contains=TLibDir' @@ -188,7 +196,7 @@ else hi def link TLibDir Directory hi def link TLibFilename NonText " :nodoc: - function! self.Highlighter(rx) dict + function! self.Highlighter(rx) dict abort let rx = '/\c\%>'. (1 + self.width_filename) .'c \(|\|\[[^]]*\]\) .\{-}\zs'. escape(a:rx, '/') .'/' exec 'match' self.matcher.highlight rx endf @@ -196,18 +204,18 @@ else " :nodoc: - function! s:prototype.UseFilenameIndicators() dict "{{{3 + function! s:prototype.UseFilenameIndicators() dict abort "{{{3 return g:tlib_inputlist_filename_indicators || has_key(self, 'filename_indicators') endf " :nodoc: - function! s:prototype.InitFormatName() dict "{{{3 + function! s:prototype.InitFormatName() dict abort "{{{3 if self.UseFilenameIndicators() let self._buffers = {} for bufnr in range(1, bufnr('$')) let filename = fnamemodify(bufname(bufnr), ':p') - " TLogVAR filename + Tlibtrace 'tlib', filename let bufdef = { \ 'bufnr': bufnr, \ } @@ -222,8 +230,8 @@ else " :nodoc: - function! s:prototype.FormatFilename(file) dict "{{{3 - " TLogVAR a:file + function! s:prototype.FormatFilename(file) dict abort "{{{3 + Tlibtrace 'tlib', a:file let width = self.width_filename let split = match(a:file, '[/\\]\zs[^/\\]\+$') if split == -1 @@ -231,15 +239,15 @@ else let dname = a:file else let fname = strpart(a:file, split) - " let dname = strpart(a:file, 0, split - 1) + " let dname = tlib#string#Strcharpart(a:file, 0, split - 1) let dname = a:file endif if strwidth(fname) > width - let fname = strpart(fname, 0, width - 3) .'...' + let fname = tlib#string#Strcharpart(fname, 0, width - 3) .'...' endif - let dnmax = &co - max([width, strwidth(fname)]) - 8 - self.index_width - &fdc + let dnmax = &columns - max([width, strwidth(fname)]) - 8 - self.index_width - &foldcolumn let use_indicators = self.UseFilenameIndicators() - " TLogVAR use_indicators + Tlibtrace 'tlib', use_indicators let marker = [] if use_indicators call insert(marker, '[') @@ -247,7 +255,7 @@ else let bufdef = get(self._buffers, a:file, {}) " let bnr = bufnr(a:file) let bnr = get(bufdef, 'bufnr', -1) - " TLogVAR a:file, bnr, self.bufnr + Tlibtrace 'tlib', a:file, bnr, self.bufnr if bnr != -1 if bnr == self.bufnr call add(marker, '%') @@ -257,7 +265,7 @@ else if get(bufdef, '&modified', 0) call add(marker, '+') endif - if get(bufdef, '&bufhidden', '') == 'hide' + if get(bufdef, '&bufhidden', '') ==# 'hide' call add(marker, 'h') endif " if !get(bufdef, '&buflisted', 1) @@ -284,9 +292,9 @@ else let dnmax -= len(markers) endif if strwidth(dname) > dnmax - let dname = '...'. strpart(dname, len(dname) - dnmax) + let dname = '...'. tlib#string#Strcharpart(dname, len(dname) - dnmax) endif - return printf("%-*s %s %s", + return printf('%-*s %s %s', \ self.width_filename + len(fname) - strwidth(fname), \ fname, markers, dname) endf @@ -295,15 +303,15 @@ endif " :nodoc: -function! s:prototype.GetSelectedItems(current) dict "{{{3 - " TLogVAR a:current +function! s:prototype.GetSelectedItems(current) dict abort "{{{3 + Tlibtrace 'tlib', a:current if stridx(self.type, 'i') != -1 let rv = copy(self.sel_idx) else let rv = map(copy(self.sel_idx), 'self.GetBaseItem(v:val)') endif if !empty(a:current) - " TLogVAR a:current, rv, type(a:current) + Tlibtrace 'tlib', a:current, rv, type(a:current) if tlib#type#IsNumber(a:current) || tlib#type#IsString(a:current) call s:InsertSelectedItems(rv, a:current) elseif tlib#type#IsList(a:current) @@ -319,16 +327,16 @@ function! s:prototype.GetSelectedItems(current) dict "{{{3 " TAssert empty(rv) || rv[0] == a:current if stridx(self.type, 'i') != -1 if !empty(self.index_table) - " TLogVAR rv, self.index_table + Tlibtrace 'tlib', rv, self.index_table call map(rv, 'self.index_table[v:val - 1]') - " TLogVAR rv + Tlibtrace 'tlib', rv endif endif return rv endf -function! s:InsertSelectedItems(rv, current) "{{{3 +function! s:InsertSelectedItems(rv, current) abort "{{{3 let ci = index(a:rv, a:current) if ci != -1 call remove(a:rv, ci) @@ -338,17 +346,17 @@ endf " :nodoc: -function! s:prototype.SelectItemsByNames(mode, items) dict "{{{3 +function! s:prototype.SelectItemsByNames(mode, items) dict abort "{{{3 for item in a:items let bi = index(self.base, item) + 1 - " TLogVAR item, bi + Tlibtrace 'tlib', item, bi if bi > 0 let si = index(self.sel_idx, bi) - " TLogVAR self.sel_idx - " TLogVAR si + Tlibtrace 'tlib', self.sel_idx + Tlibtrace 'tlib', si if si == -1 call add(self.sel_idx, bi) - elseif a:mode == 'toggle' + elseif a:mode ==# 'toggle' call remove(self.sel_idx, si) endif endif @@ -358,21 +366,21 @@ endf " :nodoc: -function! s:prototype.SelectItem(mode, index) dict "{{{3 - " TLogVAR a:mode, a:index +function! s:prototype.SelectItem(mode, index) dict abort "{{{3 + Tlibtrace 'tlib', a:mode, a:index let bi = self.GetBaseIdx(a:index) " if self.RespondTo('MaySelectItem') " if !self.MaySelectItem(bi) " return 0 " endif " endif - " TLogVAR bi + Tlibtrace 'tlib', bi let si = index(self.sel_idx, bi) - " TLogVAR self.sel_idx - " TLogVAR si + Tlibtrace 'tlib', self.sel_idx + Tlibtrace 'tlib', si if si == -1 call add(self.sel_idx, bi) - elseif a:mode == 'toggle' + elseif a:mode ==# 'toggle' call remove(self.sel_idx, si) endif return 1 @@ -388,26 +396,26 @@ endf " :nodoc: -function! s:prototype.FormatArgs(format_string, arg) dict "{{{3 +function! s:prototype.FormatArgs(format_string, arg) dict abort "{{{3 let nargs = len(substitute(a:format_string, '%%\|[^%]', '', 'g')) return [a:format_string] + repeat([string(a:arg)], nargs) endf " :nodoc: -function! s:prototype.GetRx(filter) dict "{{{3 - return '\('. join(filter(copy(a:filter), 'v:val[0] != "!"'), '\|') .'\)' +function! s:prototype.GetRx(filter) dict abort "{{{3 + return '\('. join(filter(copy(a:filter), 'v:val[0] !=# "!"'), '\|') .'\)' endf " :nodoc: -function! s:prototype.GetRx0(...) dict "{{{3 +function! s:prototype.GetRx0(...) dict abort "{{{3 exec tlib#arg#Let(['negative']) let rx0 = [] for filter in self.filter - " TLogVAR filter + Tlibtrace 'tlib', filter let rx = join(reverse(filter(copy(filter), '!empty(v:val)')), '\|') - " TLogVAR rx + Tlibtrace 'tlib', rx if !empty(rx) && (negative ? rx[0] == g:tlib#input#not : rx[0] != g:tlib#input#not) call add(rx0, rx) endif @@ -422,18 +430,16 @@ endf " :nodoc: -function! s:prototype.FormatName(cache, format, value) dict "{{{3 - " TLogVAR a:format, a:value - " TLogDBG has_key(self.fmt_display, a:value) +function! s:prototype.FormatName(cache, format, value) dict abort "{{{3 + Tlibtrace 'tlib', a:format, a:value if has_key(a:cache, a:value) - " TLogDBG "cached" return a:cache[a:value] else let world = self let ftpl = self.FormatArgs(a:format, a:value) - let fn = call(function("printf"), ftpl) + let fn = call(function('printf'), ftpl) let fmt = eval(fn) - " TLogVAR ftpl, fn, fmt + Tlibtrace 'tlib', ftpl, fn, fmt let a:cache[a:value] = fmt return fmt endif @@ -441,29 +447,29 @@ endf " :nodoc: -function! s:prototype.GetItem(idx) dict "{{{3 +function! s:prototype.GetItem(idx) dict abort "{{{3 return self.list[a:idx - 1] endf " :nodoc: -function! s:prototype.GetListIdx(baseidx) dict "{{{3 +function! s:prototype.GetListIdx(baseidx) dict abort "{{{3 " if empty(self.index_table) let baseidx = a:baseidx " else " let baseidx = 0 + self.index_table[a:baseidx - 1] - " " TLogVAR a:baseidx, baseidx, self.index_table + " Tlibtrace 'tlib', a:baseidx, baseidx, self.index_table " endif let rv = index(self.table, baseidx) - " TLogVAR rv, self.table + Tlibtrace 'tlib', rv, self.table return rv endf " :nodoc: " The first index is 1. -function! s:prototype.GetBaseIdx(idx) dict "{{{3 - " TLogVAR a:idx, self.table, self.index_table +function! s:prototype.GetBaseIdx(idx) dict abort "{{{3 + Tlibtrace 'tlib', a:idx, self.table, self.index_table if !empty(self.table) && a:idx > 0 && a:idx <= len(self.table) return self.table[a:idx - 1] else @@ -473,7 +479,7 @@ endf " :nodoc: -function! s:prototype.GetBaseIdx0(idx) dict "{{{3 +function! s:prototype.GetBaseIdx0(idx) dict abort "{{{3 let idx0 = self.GetBaseIdx(a:idx) - 1 if idx0 < 0 call tlib#notify#Echo('TLIB: Internal Error: GetBaseIdx0: idx0 < 0', 'WarningMsg') @@ -483,19 +489,19 @@ endf " :nodoc: -function! s:prototype.GetBaseItem(idx) dict "{{{3 +function! s:prototype.GetBaseItem(idx) dict abort "{{{3 return self.base[a:idx - 1] endf " :nodoc: -function! s:prototype.SetBaseItem(idx, item) dict "{{{3 +function! s:prototype.SetBaseItem(idx, item) dict abort "{{{3 let self.base[a:idx - 1] = a:item endf " :nodoc: -function! s:prototype.GetLineIdx(lnum) dict "{{{3 +function! s:prototype.GetLineIdx(lnum) dict abort "{{{3 let line = getline(a:lnum) let prefidx = substitute(matchstr(line, '^\d\+\ze[*:]'), '^0\+', '', '') return prefidx @@ -503,25 +509,24 @@ endf " :nodoc: -function! s:prototype.SetPrefIdx() dict "{{{3 +function! s:prototype.SetPrefIdx() dict abort "{{{3 " let pref = sort(range(1, self.llen), 'self.SortPrefs') " let self.prefidx = get(pref, 0, self.initial_index) let pref_idx = -1 let pref_weight = -1 - " TLogVAR self.filter_pos, self.filter_neg - " let t0 = localtime() " DBG + Tlibtrace 'tlib', self.filter_pos, self.filter_neg + let t0 = localtime() for idx in range(1, self.llen) let item = self.GetItem(idx) let weight = self.matcher.AssessName(self, item) - " TLogVAR item, weight + Tlibtrace 'tlib', item, weight if weight > pref_weight let pref_idx = idx let pref_weight = weight endif endfor - " TLogVAR localtime() - t0 - " TLogVAR pref_idx - " TLogDBG self.GetItem(pref_idx) + Tlibtrace 'tlib', localtime() - t0 + Tlibtrace 'tlib', pref_idx if pref_idx == -1 let self.prefidx = self.initial_index else @@ -531,16 +536,16 @@ endf " " :nodoc: -" function! s:prototype.GetCurrentItem() dict "{{{3 +" function! s:prototype.GetCurrentItem() dict abort "{{{3 " let idx = self.prefidx -" " TLogVAR idx +" Tlibtrace 'tlib', idx " if stridx(self.type, 'i') != -1 " return idx " elseif !empty(self.list) " if len(self.list) >= idx " let idx1 = idx - 1 " let rv = self.list[idx - 1] -" " TLogVAR idx, idx1, rv, self.list +" Tlibtrace 'tlib', idx, idx1, rv, self.list " return rv " endif " else @@ -550,19 +555,19 @@ endf " :nodoc: -function! s:prototype.CurrentItem() dict "{{{3 +function! s:prototype.CurrentItem() dict abort "{{{3 if stridx(self.type, 'i') != -1 return self.GetBaseIdx(self.llen == 1 ? 1 : self.prefidx) else if self.llen == 1 - " TLogVAR self.llen + Tlibtrace 'tlib', self.llen return self.list[0] elseif self.prefidx > 0 - " TLogVAR self.prefidx + Tlibtrace 'tlib', self.prefidx " return self.GetCurrentItem() if len(self.list) >= self.prefidx let rv = self.list[self.prefidx - 1] - " TLogVAR idx, rv, self.list + Tlibtrace 'tlib', self.prefidx, len(self.list), rv return rv endif else @@ -573,29 +578,29 @@ endf " :nodoc: -function! s:prototype.FilterRxPrefix() dict "{{{3 +function! s:prototype.FilterRxPrefix() dict abort "{{{3 return self.matcher.FilterRxPrefix() endf " :nodoc: -function! s:prototype.SetFilter() dict "{{{3 +function! s:prototype.SetFilter() dict abort "{{{3 " let mrx = '\V'. (a:0 >= 1 && a:1 ? '\C' : '') let mrx = self.FilterRxPrefix() . self.filter_options let self.filter_pos = [] let self.filter_neg = [] - " TLogVAR mrx, self.filter + Tlibtrace 'tlib', mrx, self.filter for filter in self.filter - " TLogVAR filter + Tlibtrace 'tlib', filter let rx = join(reverse(filter(copy(filter), '!empty(v:val)')), '\|') - " TLogVAR rx + Tlibtrace 'tlib', rx if !empty(rx) - if rx =~ '\u' + if rx =~# '\u' let mrx1 = mrx .'\C' else let mrx1 = mrx endif - " TLogVAR rx + Tlibtrace 'tlib', rx if rx[0] == g:tlib#input#not if len(rx) > 1 call add(self.filter_neg, mrx1 .'\('. rx[1:-1] .'\)') @@ -605,17 +610,17 @@ function! s:prototype.SetFilter() dict "{{{3 endif endif endfor - " TLogVAR self.filter_pos, self.filter_neg + Tlibtrace 'tlib', self.filter_pos, self.filter_neg endf " :nodoc: -function! s:prototype.IsValidFilter() dict "{{{3 +function! s:prototype.IsValidFilter() dict abort "{{{3 let last = self.FilterRxPrefix() .'\('. self.filter[0][0] .'\)' Tlibtrace 'tlib', last - " TLogVAR last + Tlibtrace 'tlib', last try - let a = match("", last) + let a = match('', last) return 1 catch Tlibtrace 'tlib', v:exception @@ -625,8 +630,8 @@ endf " :nodoc: -function! s:prototype.SetMatchMode(match_mode) dict "{{{3 - " TLogVAR a:match_mode +function! s:prototype.SetMatchMode(match_mode) dict abort "{{{3 + Tlibtrace 'tlib', a:match_mode if !empty(a:match_mode) unlet self.matcher try @@ -639,31 +644,31 @@ function! s:prototype.SetMatchMode(match_mode) dict "{{{3 endf -" function! s:prototype.Match(text) dict "{{{3 +" function! s:prototype.Match(text) dict abort "{{{3 " return self.matcher.Match(self, text) " endf " :nodoc: -function! s:prototype.MatchBaseIdx(idx) dict "{{{3 +function! s:prototype.MatchBaseIdx(idx) dict abort "{{{3 let text = self.GetBaseItem(a:idx) if !empty(self.filter_format) let text = self.FormatName(self.fmt_filter, self.filter_format, text) endif - " TLogVAR text + Tlibtrace 'tlib', text " return self.Match(text) return self.matcher.Match(self, text) endf " :nodoc: -function! s:prototype.BuildTableList() dict "{{{3 - " let time0 = str2float(reltimestr(reltime())) " DBG - " TLogVAR time0 +function! s:prototype.BuildTableList() dict abort "{{{3 + let time0 = str2float(reltimestr(reltime())) + Tlibtrace 'tlib', time0 call self.SetFilter() - " TLogVAR self.filter_neg, self.filter_pos + Tlibtrace 'tlib', self.filter_neg, self.filter_pos let self.table = range(1, len(self.base)) - " TLogVAR self.filtered_items + Tlibtrace 'tlib', self.filtered_items let copy_base = 1 if !empty(self.filtered_items) let self.table = filter(self.table, 'index(self.filtered_items, v:val) != -1') @@ -682,8 +687,8 @@ endf " :nodoc: -function! s:prototype.ReduceFilter() dict "{{{3 - " TLogVAR self.filter +function! s:prototype.ReduceFilter() dict abort "{{{3 + Tlibtrace 'tlib', self.filter let reduced = 0 while !reduced if self.filter[0] == [''] && len(self.filter) > 1 @@ -702,7 +707,7 @@ endf " :nodoc: " filter is either a string or a list of list of strings. -function! s:prototype.SetInitialFilter(filter) dict "{{{3 +function! s:prototype.SetInitialFilter(filter) dict abort "{{{3 " let self.initial_filter = [[''], [a:filter]] Tlibtrace 'tlib', a:filter if type(a:filter) == 3 @@ -714,8 +719,8 @@ endf " :nodoc: -function! s:prototype.PopFilter() dict "{{{3 - " TLogVAR self.filter +function! s:prototype.PopFilter() dict abort "{{{3 + Tlibtrace 'tlib', self.filter if len(self.filter[0]) > 1 call remove(self.filter[0], 0) elseif len(self.filter) > 1 @@ -727,17 +732,17 @@ endf " :nodoc: -function! s:prototype.FilterIsEmpty() dict "{{{3 - " TLogVAR self.filter +function! s:prototype.FilterIsEmpty() dict abort "{{{3 + Tlibtrace 'tlib', self.filter return self.filter == copy(self.initial_filter) endf " :nodoc: -function! s:prototype.DisplayFilter() dict "{{{3 +function! s:prototype.DisplayFilter() dict abort "{{{3 let filter1 = copy(self.filter) call filter(filter1, 'v:val != [""]') - " TLogVAR self.matcher['_class'] + Tlibtrace 'tlib', self.matcher['_class'] let rv = self.matcher.DisplayFilter(filter1) let rv = self.CleanFilter(rv) return rv @@ -745,29 +750,29 @@ endf " :nodoc: -function! s:prototype.SetFrontFilter(pattern) dict "{{{3 +function! s:prototype.SetFrontFilter(pattern) dict abort "{{{3 call self.matcher.SetFrontFilter(self, a:pattern) endf " :nodoc: -function! s:prototype.PushFrontFilter(char) dict "{{{3 +function! s:prototype.PushFrontFilter(char) dict abort "{{{3 call self.matcher.PushFrontFilter(self, a:char) endf " :nodoc: -function! s:prototype.CleanFilter(filter) dict "{{{3 +function! s:prototype.CleanFilter(filter) dict abort "{{{3 return self.matcher.CleanFilter(a:filter) endf " :nodoc: -function! s:prototype.UseScratch() dict "{{{3 +function! s:prototype.UseScratch() dict abort "{{{3 " if type(self.scratch) != 0 && get(self, 'buffer_local', 1) " if self.scratch != fnamemodify(self.scratch, ':p') " let self.scratch = tlib#file#Join([expand('%:p:h'), self.scratch]) - " " TLogVAR self.scratch + " Tlibtrace 'tlib', self.scratch " endif " " let self.scratch_hidden = 'wipe' " endif @@ -780,15 +785,15 @@ endf " :nodoc: -function! s:prototype.CloseScratch(...) dict "{{{3 +function! s:prototype.CloseScratch(...) dict abort "{{{3 TVarArg ['reset_scratch', 0] " TVarArg ['reset_scratch', 1] - " TLogVAR reset_scratch + Tlibtrace 'tlib', reset_scratch if self.sticky return 0 else let rv = tlib#scratch#CloseScratch(self, reset_scratch) - " TLogVAR rv + Tlibtrace 'tlib', rv if rv call self.SwitchWindow('win') endif @@ -798,7 +803,7 @@ endf " :nodoc: -function! s:prototype.Initialize() dict "{{{3 +function! s:prototype.Initialize() dict abort "{{{3 let self.initialized = 1 call self.SetOrigin(1) call self.Reset(1) @@ -812,7 +817,7 @@ endf " :nodoc: -function! s:prototype.Leave() dict "{{{3 +function! s:prototype.Leave() dict abort "{{{3 if !empty(self.cache_var) exec 'let '. self.cache_var .' = self' endif @@ -823,7 +828,7 @@ endf " :nodoc: -function! s:prototype.UseInputListScratch() dict "{{{3 +function! s:prototype.UseInputListScratch() dict abort "{{{3 let scratch = self.UseScratch() if !exists('b:tlib_list_init') call tlib#autocmdgroup#Init() @@ -832,7 +837,7 @@ function! s:prototype.UseInputListScratch() dict "{{{3 let b:tlib_list_init = 1 endif if !exists('w:tlib_list_init') - " TLogVAR scratch + Tlibtrace 'tlib', scratch if has_key(self, 'index_next_syntax') if type(self.index_next_syntax) == 1 exec 'syntax match InputlListIndex /^\d\+:\s/ nextgroup='. self.index_next_syntax @@ -864,9 +869,9 @@ endf " s:prototype.Reset(?initial=0) " :nodoc: -function! s:prototype.Reset(...) dict "{{{3 +function! s:prototype.Reset(...) dict abort "{{{3 TVarArg ['initial', 0] - " TLogVAR initial + Tlibtrace 'tlib', initial Tlibtrace 'tlib', initial, self.initial_filter let self.state = 'display' let self.offset = 1 @@ -885,23 +890,22 @@ endf " :nodoc: -function! s:prototype.ResetSelected() dict "{{{3 +function! s:prototype.ResetSelected() dict abort "{{{3 let self.sel_idx = [] endf " :nodoc: -function! s:prototype.Retrieve(anyway) dict "{{{3 - " TLogVAR a:anyway, self.base - " TLogDBG (a:anyway || empty(self.base)) +function! s:prototype.Retrieve(anyway) dict abort "{{{3 + Tlibtrace 'tlib', a:anyway, self.base if (a:anyway || empty(self.base)) let ra = self.retrieve_eval - " TLogVAR ra + Tlibtrace 'tlib', ra if !empty(ra) let back = self.SwitchWindow('win') let world = self let self.base = eval(ra) - " TLogVAR self.base + Tlibtrace 'tlib', self.base exec back return 1 endif @@ -910,25 +914,25 @@ function! s:prototype.Retrieve(anyway) dict "{{{3 endf -function! s:FormatHelp(help) "{{{3 - " TLogVAR a:help +function! s:FormatHelp(help) abort "{{{3 + Tlibtrace 'tlib', a:help let max = [0, 0] for item in a:help - " TLogVAR item + Tlibtrace 'tlib', item if type(item) == 3 let itemlen = map(copy(item), 'strwidth(v:val)') - " TLogVAR itemlen + Tlibtrace 'tlib', itemlen let max = map(range(2), 'max[v:val] >= itemlen[v:val] ? max[v:val] : itemlen[v:val]') endif unlet item endfor - " TLogVAR max + Tlibtrace 'tlib', max let cols = float2nr((winwidth(0) - &foldcolumn - 1) / (max[0] + max[1] + 2)) if cols < 1 let cols = 1 endif let fmt = printf('%%%ds: %%-%ds', max[0], max[1]) - " TLogVAR cols, fmt + Tlibtrace 'tlib', cols, fmt let help = [] let idx = -1 let maxidx = len(a:help) @@ -956,31 +960,31 @@ function! s:FormatHelp(help) "{{{3 call add(help, a:help[idx]) endif endwh - " TLogVAR help + Tlibtrace 'tlib', help return help endf -function! s:FormatHelpItem(item, fmt) "{{{3 +function! s:FormatHelpItem(item, fmt) abort "{{{3 let args = [join(repeat([a:fmt], len(a:item)), ' ')] for item in a:item - " TLogVAR item + Tlibtrace 'tlib', item let args += item endfor - " TLogVAR args + Tlibtrace 'tlib', args return call('printf', args) endf " :nodoc: -function! s:prototype.InitHelp() dict "{{{3 +function! s:prototype.InitHelp() dict abort "{{{3 return [] endf " :nodoc: -function! s:prototype.PushHelp(...) dict "{{{3 - " TLogVAR a:000 +function! s:prototype.PushHelp(...) dict abort "{{{3 + Tlibtrace 'tlib', a:000 if a:0 == 1 if type(a:1) == 3 let self.temp_lines += a:1 @@ -990,14 +994,14 @@ function! s:prototype.PushHelp(...) dict "{{{3 elseif a:0 == 2 call add(self.temp_lines, a:000) else - throw "TLIB: PushHelp: Wrong number of arguments: ". string(a:000) + throw 'TLIB: PushHelp: Wrong number of arguments: '. string(a:000) endif - " TLogVAR helpstring + Tlibtrace 'tlib', helpstring endf " :nodoc: -function! s:prototype.DisplayHelp() dict "{{{3 +function! s:prototype.DisplayHelp() dict abort "{{{3 let self.temp_lines = self.InitHelp() call self.PushHelp('', self.key_mode == 'default' ? 'Abort' : 'Reset keymap') call self.PushHelp('Enter, ', 'Pick the current item') @@ -1026,14 +1030,14 @@ function! s:prototype.DisplayHelp() dict "{{{3 endif endif - " TLogVAR len(self.temp_lines) + Tlibtrace 'tlib', len(self.temp_lines) call self.matcher.Help(self) - " TLogVAR self.key_mode + Tlibtrace 'tlib', self.key_mode for handler in values(self.key_map[self.key_mode]) - " TLogVAR handler + Tlibtrace 'tlib', handler let key = get(handler, 'key_name', '') - " TLogVAR key + Tlibtrace 'tlib', key if !empty(key) let desc = get(handler, 'help', '') if empty(desc) @@ -1051,7 +1055,7 @@ function! s:prototype.DisplayHelp() dict "{{{3 call self.PushHelp(self.help_extra) endif - " TLogVAR len(self.temp_lines) + Tlibtrace 'tlib', len(self.temp_lines) call self.PushHelp([ \ '', \ 'Matches at word boundaries are prioritized.', @@ -1061,7 +1065,7 @@ function! s:prototype.DisplayHelp() dict "{{{3 endf -function! s:prototype.PrintLines() dict "{{{3 +function! s:prototype.PrintLines() dict abort "{{{3 let self.temp_prompt = ['Press any key to continue.', 'Question'] call tlib#buffer#DeleteRange('1', '$') call append(0, self.temp_lines) @@ -1073,31 +1077,35 @@ endf " :nodoc: -function! s:prototype.Resize(hsize, vsize) dict "{{{3 - " TLogVAR self.scratch_vertical, a:hsize, a:vsize +function! s:prototype.Resize(hsize, vsize) dict abort "{{{3 + Tlibtrace 'tlib', self.scratch_vertical, a:hsize, a:vsize let world_resize = '' let winpos = '' let scratch_split = get(self, 'scratch_split', 1) - " TLogVAR scratch_split + Tlibtrace 'tlib', scratch_split if scratch_split > 0 if self.scratch_vertical if a:vsize let world_resize = 'vert resize '. a:vsize let winpos = tlib#fixes#Winpos() " let w:winresize = {'v': a:vsize} - setlocal winfixwidth + " setlocal winfixwidth endif else if a:hsize let world_resize = 'resize '. a:hsize " let w:winresize = {'h': a:hsize} - setlocal winfixheight + " setlocal winfixheight endif endif endif if !empty(world_resize) - " TLogVAR world_resize, winpos + Tlibtrace 'tlib', world_resize, winpos + setlocal nowinfixheight + setlocal nowinfixwidth exec world_resize + setlocal winfixheight + setlocal winfixwidth if !empty(winpos) exec winpos endif @@ -1107,31 +1115,36 @@ endf " :nodoc: -function! s:prototype.GetResize(size) dict "{{{3 +function! s:prototype.GetResize(size) dict abort "{{{3 let resize0 = get(self, 'resize', 0) let resize = empty(resize0) ? 0 : eval(resize0) - " TLogVAR resize0, resize + Tlibtrace 'tlib', resize0, resize let resize = resize == 0 ? a:size : min([a:size, resize]) " let min = self.scratch_vertical ? &cols : &lines let min1 = (self.scratch_vertical ? self.win_width : self.win_height) * g:tlib_inputlist_pct let min2 = (self.scratch_vertical ? &columns : &lines) * self.win_pct + let min3 = &previewheight let min = max([min1, min2]) - let resize = min([resize, (min / 100)]) - " TLogVAR resize, a:size, min, min1, min2 + let ns = [resize, (min / 100)] + let maxn = self.scratch_vertical ? g:tlib_inputlist_max_cols : g:tlib_inputlist_max_lines + if maxn > 0 + call add(ns, maxn) + endif + let resize = min(ns) + Tlibtrace 'tlib', resize, a:size, min, min1, min2 return resize endf " function! s:prototype.DisplayList(?query=self.Query(), ?list=[]) " :nodoc: -function! s:prototype.DisplayList(...) dict "{{{3 - " TLogVAR self.state +function! s:prototype.DisplayList(...) dict abort "{{{3 + Tlibtrace 'tlib', self.state let query = a:0 >= 1 ? a:1 : self.Query() let list = a:0 >= 2 ? a:2 : [] - " TLogVAR query, len(list) - " TLogDBG 'len(list) = '. len(list) + Tlibtrace 'tlib', query, len(list) call self.UseScratch() - " TLogVAR self.scratch + Tlibtrace 'tlib', self.scratch " TAssert IsNotEmpty(self.scratch) if self.state == 'scroll' call self.ScrollToOffset() @@ -1142,12 +1155,12 @@ function! s:prototype.DisplayList(...) dict "{{{3 call self.PrintLines() call self.SetStatusline(query) else - " TLogVAR query + Tlibtrace 'tlib', query " let ll = len(list) let ll = self.llen " let x = len(ll) + 1 let x = self.index_width + 1 - " TLogVAR ll + Tlibtrace 'tlib', ll if self.state =~ '\' call self.Resize(self.GetResize(ll), eval(get(self, 'resize_vertical', 0))) call tlib#normal#WithRegister('gg"tdG', 't') @@ -1155,17 +1168,17 @@ function! s:prototype.DisplayList(...) dict "{{{3 let lines = map(lines, 'substitute(v:val, ''[[:cntrl:][:space:]]'', " ", "g")') let w = winwidth(0) - &fdc " let w = winwidth(0) - &fdc - 1 - let lines = map(lines, 'printf("%-'. w .'.'. w .'s", v:val)') - " TLogVAR lines + let lines = map(lines, 'printf("%-'. w .'.'. w .'S", v:val)') + Tlibtrace 'tlib', lines call append(0, lines) call tlib#normal#WithRegister('G"tddgg', 't') endif - " TLogVAR self.prefidx + Tlibtrace 'tlib', self.prefidx let base_pref = self.GetBaseIdx(self.prefidx) - " TLogVAR base_pref + Tlibtrace 'tlib', base_pref if self.state =~ '\' call filter(b:tlibDisplayListMarks, 'index(self.sel_idx, v:val) == -1 && v:val != base_pref') - " TLogVAR b:tlibDisplayListMarks + Tlibtrace 'tlib', b:tlibDisplayListMarks call map(b:tlibDisplayListMarks, 'self.DisplayListMark(x, v:val, ":")') " let b:tlibDisplayListMarks = map(copy(self.sel_idx), 'self.DisplayListMark(x, v:val, "#")') " call add(b:tlibDisplayListMarks, self.prefidx) @@ -1176,10 +1189,10 @@ function! s:prototype.DisplayList(...) dict "{{{3 call self.DisplayListMark(x, base_pref, '*') call self.SetOffset() call self.SetStatusline(query) - " TLogVAR self.offset + Tlibtrace 'tlib', self.offset call self.ScrollToOffset() let rx0 = self.GetRx0() - " TLogVAR rx0 + Tlibtrace 'tlib', rx0 if !empty(self.matcher.highlight) if empty(rx0) match none @@ -1197,8 +1210,8 @@ endf " :nodoc: -function! s:prototype.SetStatusline(query) dict "{{{3 - " TLogVAR a:query +function! s:prototype.SetStatusline(query) dict abort "{{{3 + Tlibtrace 'tlib', a:query if !empty(self.temp_prompt) let echo = get(self.temp_prompt, 0, '') let hl = get(self.temp_prompt, 1, 'Normal') @@ -1226,7 +1239,7 @@ function! s:prototype.SetStatusline(query) dict "{{{3 let echo = query . ' ' . sopts " let query .= '%%='. sopts .' ' endif - " TLogVAR &l:statusline, query + Tlibtrace 'tlib', &l:statusline, query " let &l:statusline = query endif echo @@ -1241,7 +1254,7 @@ endf " :nodoc: -function! s:prototype.Query() dict "{{{3 +function! s:prototype.Query() dict abort "{{{3 let flt = self.DisplayFilter() if g:tlib_inputlist_shortmessage let query = 'Filter: '. flt @@ -1253,17 +1266,15 @@ endf " :nodoc: -function! s:prototype.ScrollToOffset() dict "{{{3 - " TLogVAR self.scratch_vertical, self.llen, winheight(0) +function! s:prototype.ScrollToOffset() dict abort "{{{3 + Tlibtrace 'tlib', self.scratch_vertical, self.llen, winheight(0) exec 'norm! '. self.offset .'zt' endf " :nodoc: -function! s:prototype.SetOffset() dict "{{{3 - " TLogVAR self.prefidx, self.offset - " TLogDBG winheight(0) - " TLogDBG self.prefidx > self.offset + winheight(0) - 1 +function! s:prototype.SetOffset() dict abort "{{{3 + Tlibtrace 'tlib', self.prefidx, self.offset let listtop = len(self.list) - winheight(0) + 1 if listtop < 1 let listtop = 1 @@ -1274,37 +1285,34 @@ function! s:prototype.SetOffset() dict "{{{3 let listoff = self.prefidx - winheight(0) + 1 let self.offset = min([listtop, listoff]) " TLogVAR self.prefidx - " TLogDBG len(self.list) - " TLogDBG winheight(0) " TLogVAR listtop, listoff, self.offset elseif self.prefidx < self.offset let self.offset = self.prefidx endif - " TLogVAR self.offset + Tlibtrace 'tlib', self.offset endf " :nodoc: -function! s:prototype.ClearAllMarks() dict "{{{3 +function! s:prototype.ClearAllMarks() dict abort "{{{3 let x = self.index_width + 1 call map(range(1, line('$')), 'self.DisplayListMark(x, v:val, ":")') endf " :nodoc: -function! s:prototype.MarkCurrent(y) dict "{{{3 +function! s:prototype.MarkCurrent(y) dict abort "{{{3 let x = self.index_width + 1 call self.DisplayListMark(x, a:y, '*') endf " :nodoc: -function! s:prototype.DisplayListMark(x, y, mark) dict "{{{3 - " TLogVAR a:y, a:mark +function! s:prototype.DisplayListMark(x, y, mark) dict abort "{{{3 + Tlibtrace 'tlib', a:y, a:mark if a:x > 0 && a:y >= 0 - " TLogDBG a:x .'x'. a:y .' '. a:mark let sy = self.GetListIdx(a:y) + 1 - " TLogVAR sy + Tlibtrace 'tlib', sy if sy >= 1 call setpos('.', [0, sy, a:x, 0]) exec 'norm! r'. a:mark @@ -1316,23 +1324,22 @@ endf " :nodoc: -function! s:prototype.SwitchWindow(where) dict "{{{3 - " TLogDBG string(tlib#win#List()) - if self.tabpagenr != tabpagenr() - call tlib#tab#Set(self.tabpagenr) - endif - let wnr = get(self, a:where.'_wnr') - " TLogVAR self, wnr - return tlib#win#Set(wnr) +function! s:prototype.SwitchWindow(where) dict abort "{{{3 + " if self.tabpagenr != tabpagenr() + " call tlib#tab#Set(self.tabpagenr) + " endif + " let wnr = get(self, a:where.'_wnr') + " Tlibtrace 'tlib', self, wnr + " return tlib#win#Set(wnr) + return tlib#win#SetById(self[a:where .'_id']) endf " :nodoc: -function! s:prototype.FollowCursor() dict "{{{3 +function! s:prototype.FollowCursor() dict abort "{{{3 if !empty(self.follow_cursor) let back = self.SwitchWindow('win') - " TLogVAR back - " TLogDBG winnr() + Tlibtrace 'tlib', back try call call(self.follow_cursor, [self, [self.CurrentItem()]]) finally @@ -1343,62 +1350,47 @@ endf " :nodoc: -function! s:prototype.SetOrigin(...) dict "{{{3 +function! s:prototype.SetOrigin(...) dict abort "{{{3 TVarArg ['winview', 0] - " TLogVAR self.win_wnr, self.bufnr - " TLogDBG bufname('%') - " TLogDBG winnr() - " TLogDBG winnr('$') + Tlibtrace 'tlib', 'SetOrigin', self.win_id, self.bufnr, bufnr('%'), winnr() let self.win_wnr = winnr() + let self.win_id = tlib#win#GetID() let self.win_height = winheight(self.win_wnr) let self.win_width = winwidth(self.win_wnr) - " TLogVAR self.win_wnr, self.win_height, self.win_width + Tlibtrace 'tlib', 'SetOrigin', self.win_id, self.win_height, self.win_width, bufnr('%'), winnr() let self.bufnr = bufnr('%') let self.tabpagenr = tabpagenr() let self.cursor = getpos('.') if winview let self.winview = tlib#win#GetLayout() endif - " TLogVAR self.win_wnr, self.bufnr, self.winview + Tlibtrace 'tlib', 'SetOrigin', self.win_id, self.bufnr, get(self,'winview','') return self endf " :nodoc: -function! s:prototype.RestoreOrigin(...) dict "{{{3 +function! s:prototype.RestoreWindow(...) dict abort "{{{3 TVarArg ['winview', 0] if winview - " TLogVAR winview + Tlibtrace 'tlib', winview call tlib#win#SetLayout(self.winview) endif - " TLogVAR self.win_wnr, self.bufnr, self.cursor, &splitbelow - " TLogDBG "RestoreOrigin0 ". string(tlib#win#List()) - " If &splitbelow or &splitright is false, we cannot rely on - " self.win_wnr to be our source buffer since, e.g, opening a buffer - " in a split window changes the whole layout. - " Possible solutions: - " - Restrict buffer switching to cases when the number of windows - " hasn't changed. - " - Guess the right window, which we try to do here. - if &splitbelow == 0 || &splitright == 0 - let wn = bufwinnr(self.bufnr) - " TLogVAR wn - if wn == -1 - let wn = 1 - end - else - let wn = self.win_wnr - endif - if wn != winnr() - exec wn .'wincmd w' - endif - exec 'buffer! '. self.bufnr - call setpos('.', self.cursor) - " TLogDBG "RestoreOrigin1 ". string(tlib#win#List()) + call tlib#win#GotoID(self.win_id) endf -function! s:prototype.Suspend() dict "{{{3 +" :nodoc: +function! s:prototype.RestoreOrigin(...) dict abort "{{{3 + call call(self.RestoreWindow, a:000) + if bufnr('%') != self.bufnr + exec 'buffer! '. self.bufnr + call setpos('.', self.cursor) + endif +endf + + +function! s:prototype.Suspend() dict abort "{{{3 call tlib#agent#Suspend(self, self.rv) endf diff --git a/sources_non_forked/tlib/autoload/tlib/agent.vim b/sources_non_forked/tlib/autoload/tlib/agent.vim index 98275f12..96f75274 100644 --- a/sources_non_forked/tlib/autoload/tlib/agent.vim +++ b/sources_non_forked/tlib/autoload/tlib/agent.vim @@ -1,8 +1,7 @@ " @Author: Tom Link (micathom AT gmail com?subject=[vim]) " @Website: http://www.vim.org/account/profile.php?user_id=4037 " @License: GPL (see http://www.gnu.org/licenses/gpl.txt) -" @Revision: 328 - +" @Revision: 362 " :filedoc: " Various agents for use as key handlers in tlib#input#List() @@ -14,7 +13,8 @@ TLet g:tlib_scroll_lines = 10 " General {{{1 function! tlib#agent#Exit(world, selected) "{{{3 - if a:world.key_mode == 'default' + Tlibtrace 'tlib', a:selected + if a:world.key_mode ==# 'default' call a:world.CloseScratch() let a:world.state = 'exit empty escape' let a:world.list = [] @@ -29,6 +29,7 @@ endf function! tlib#agent#CopyItems(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected let @* = join(a:selected, "\n") let a:world.state = 'redisplay' return a:world @@ -39,6 +40,7 @@ endf " InputList related {{{1 function! tlib#agent#PageUp(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected let a:world.offset -= (winheight(0) / 2) let a:world.state = 'scroll' return a:world @@ -46,6 +48,7 @@ endf function! tlib#agent#PageDown(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected let a:world.offset += (winheight(0) / 2) let a:world.state = 'scroll' return a:world @@ -53,6 +56,7 @@ endf function! tlib#agent#Home(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected let a:world.prefidx = 1 let a:world.state = 'redisplay' return a:world @@ -60,6 +64,7 @@ endf function! tlib#agent#End(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected let a:world.prefidx = len(a:world.list) let a:world.state = 'redisplay' return a:world @@ -68,6 +73,7 @@ endf function! tlib#agent#Up(world, selected, ...) "{{{3 TVarArg ['lines', 1] + Tlibtrace 'tlib', a:selected, lines let a:world.idx = '' if a:world.prefidx > lines let a:world.prefidx -= lines @@ -81,6 +87,7 @@ endf function! tlib#agent#Down(world, selected, ...) "{{{3 TVarArg ['lines', 1] + Tlibtrace 'tlib', a:selected, lines let a:world.idx = '' if a:world.prefidx <= (len(a:world.list) - lines) let a:world.prefidx += lines @@ -93,16 +100,19 @@ endf function! tlib#agent#UpN(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected return tlib#agent#Up(a:world, a:selected, g:tlib_scroll_lines) endf function! tlib#agent#DownN(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected return tlib#agent#Down(a:world, a:selected, g:tlib_scroll_lines) endf function! tlib#agent#ShiftLeft(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected let a:world.offset_horizontal -= (winwidth(0) / 2) if a:world.offset_horizontal < 0 let a:world.offset_horizontal = 0 @@ -113,6 +123,7 @@ endf function! tlib#agent#ShiftRight(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected let a:world.offset_horizontal += (winwidth(0) / 2) let a:world.state = 'display shift' return a:world @@ -120,12 +131,14 @@ endf function! tlib#agent#Reset(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected let a:world.state = 'reset' return a:world endf function! tlib#agent#ToggleRestrictView(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected if empty(a:world.filtered_items) return tlib#agent#RestrictView(a:world, a:selected) else @@ -135,11 +148,11 @@ endf function! tlib#agent#RestrictView(world, selected) "{{{3 - " TLogVAR a:selected + Tlibtrace 'tlib', a:selected let filtered_items = map(copy(a:selected), 'index(a:world.base, v:val) + 1') - " TLogVAR 1, filtered_items + Tlibtrace 'tlib', 1, filtered_items let filtered_items = filter(filtered_items, 'v:val > 0') - " TLogVAR 2, filtered_items + Tlibtrace 'tlib', 2, filtered_items if !empty(filtered_items) let a:world.filtered_items = filtered_items endif @@ -149,6 +162,7 @@ endf function! tlib#agent#UnrestrictView(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected let a:world.filtered_items = [] let a:world.state = 'display' return a:world @@ -156,6 +170,7 @@ endf function! tlib#agent#Input(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected let flt0 = a:world.CleanFilter(a:world.filter[0][0]) let flt1 = input('Filter: ', flt0) echo @@ -174,15 +189,16 @@ endf " Suspend (see |tlib#agent#Suspend|) the input loop and jump back to the " original position in the parent window. function! tlib#agent#SuspendToParentWindow(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected let world = a:world - let winnr = world.win_wnr - " TLogVAR winnr - if winnr != -1 + let wid = world.win_id + Tlibtrace 'tlib', wid + if wid != -1 let world = tlib#agent#Suspend(world, a:selected) - if world.state =~ '\' + if world.state =~# '\' call world.SwitchWindow('win') " let pos = world.cursor - " " TLogVAR pos + " Tlibtrace 'tlib', pos " if !empty(pos) " call setpos('.', pos) " endif @@ -200,17 +216,18 @@ endf " and will immediatly select the item under the cursor. " < will select the item but the window will remain opened. function! tlib#agent#Suspend(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected if a:world.allow_suspend " TAssert IsNotEmpty(a:world.scratch) " TLogDBG bufnr('%') let br = tlib#buffer#Set(a:world.scratch) - " TLogVAR br, a:world.bufnr, a:world.scratch + Tlibtrace 'tlib', br, a:world.bufnr, a:world.scratch if bufnr('%') != a:world.scratch echohl WarningMsg echom "tlib#agent#Suspend: Internal error: Not a scratch buffer:" bufname('%') echohl NONE endif - " TLogVAR bufnr('%'), bufname('%'), a:world.scratch + Tlibtrace 'tlib', bufnr('%'), bufname('%'), a:world.scratch call tlib#autocmdgroup#Init() exec 'autocmd TLib BufEnter call tlib#input#Resume("world", 0, '. a:world.scratch .')' let b:tlib_world = a:world @@ -225,12 +242,14 @@ endf function! tlib#agent#Help(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected let a:world.state = 'help' return a:world endf function! tlib#agent#OR(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected if !empty(a:world.filter[0]) call insert(a:world.filter[0], '') endif @@ -240,6 +259,7 @@ endf function! tlib#agent#AND(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected if !empty(a:world.filter[0]) call insert(a:world.filter, ['']) endif @@ -249,6 +269,7 @@ endf function! tlib#agent#ReduceFilter(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected call a:world.ReduceFilter() let a:world.offset = 1 let a:world.state = 'display' @@ -257,6 +278,7 @@ endf function! tlib#agent#PopFilter(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected call a:world.PopFilter() let a:world.offset = 1 let a:world.state = 'display' @@ -265,6 +287,7 @@ endf function! tlib#agent#Debug(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected " echo string(world.state) echo string(a:world.filter) echo string(a:world.idx) @@ -277,6 +300,7 @@ endf function! tlib#agent#Select(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected call a:world.SelectItem('toggle', a:world.prefidx) " let a:world.state = 'display keepcursor' let a:world.state = 'redisplay' @@ -285,6 +309,7 @@ endf function! tlib#agent#SelectUp(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected call a:world.SelectItem('toggle', a:world.prefidx) if a:world.prefidx > 1 let a:world.prefidx -= 1 @@ -295,6 +320,7 @@ endf function! tlib#agent#SelectDown(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected call a:world.SelectItem('toggle', a:world.prefidx) if a:world.prefidx < len(a:world.list) let a:world.prefidx += 1 @@ -305,6 +331,7 @@ endf function! tlib#agent#SelectAll(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected let listrange = range(1, len(a:world.list)) let mode = empty(filter(copy(listrange), 'index(a:world.sel_idx, a:world.GetBaseIdx(v:val)) == -1')) \ ? 'toggle' : 'set' @@ -317,6 +344,7 @@ endf function! tlib#agent#ToggleStickyList(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected let a:world.sticky = !a:world.sticky let a:world.state = 'display keepcursor' return a:world @@ -327,11 +355,11 @@ endf " EditList related {{{1 function! tlib#agent#EditItem(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected let lidx = a:world.prefidx - " TLogVAR lidx - " TLogVAR a:world.table + Tlibtrace 'tlib', lidx let bidx = a:world.GetBaseIdx(lidx) - " TLogVAR bidx + Tlibtrace 'tlib', bidx let item = a:world.GetBaseItem(bidx) let item = input(lidx .'@'. bidx .': ', item) if item != '' @@ -344,6 +372,7 @@ endf " Insert a new item below the current one. function! tlib#agent#NewItem(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected let basepi = a:world.GetBaseIdx(a:world.prefidx) let item = input('New item: ') call insert(a:world.base, item, basepi) @@ -353,6 +382,7 @@ endf function! tlib#agent#DeleteItems(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected let remove = copy(a:world.sel_idx) let basepi = a:world.GetBaseIdx(a:world.prefidx) if index(remove, basepi) == -1 @@ -370,12 +400,14 @@ endf function! tlib#agent#Cut(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected let world = tlib#agent#Copy(a:world, a:selected) return tlib#agent#DeleteItems(world, a:selected) endf function! tlib#agent#Copy(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected let a:world.clipboard = [] let bidxs = copy(a:world.sel_idx) call add(bidxs, a:world.GetBaseIdx(a:world.prefidx)) @@ -388,6 +420,7 @@ endf function! tlib#agent#Paste(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected if has_key(a:world, 'clipboard') for e in reverse(copy(a:world.clipboard)) call insert(a:world.base, e, a:world.prefidx) @@ -400,6 +433,7 @@ endf function! tlib#agent#EditReturnValue(world, rv) "{{{3 + Tlibtrace 'tlib', a:rv return [a:world.state !~ '\', a:world.base] endf @@ -408,22 +442,15 @@ endf " Files related {{{1 function! tlib#agent#ViewFile(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected if !empty(a:selected) let back = a:world.SwitchWindow('win') - " TLogVAR back + Tlibtrace 'tlib', back for filename in a:selected call tlib#file#Edit(filename) endfor - " if !&hidden && &l:modified - " let cmd0 = 'split' - " let cmd1 = 'sbuffer' - " else - " let cmd0 = 'edit' - " let cmd1 = 'buffer' - " endif - " call tlib#file#With(cmd0, cmd1, a:selected, a:world) - " TLogVAR &filetype - exec back + call a:world.SetOrigin(1) + silent! exec back let a:world.state = 'display' endif return a:world @@ -431,41 +458,53 @@ endf function! tlib#agent#EditFile(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected return tlib#agent#Exit(tlib#agent#ViewFile(a:world, a:selected), a:selected) endf function! tlib#agent#EditFileInSplit(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected call a:world.CloseScratch() - " call tlib#file#With('edit', 'buffer', a:selected[0:0], a:world) - " call tlib#file#With('split', 'sbuffer', a:selected[1:-1], a:world) - call tlib#file#With('split', 'sbuffer', a:selected, a:world) + call tlib#file#With('split', 'sbuffer', a:selected, a:world, 1) + call a:world.SetOrigin(1) return tlib#agent#Exit(a:world, a:selected) endf function! tlib#agent#EditFileInVSplit(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected call a:world.CloseScratch() - " call tlib#file#With('edit', 'buffer', a:selected[0:0], a:world) - " call tlib#file#With('vertical split', 'vertical sbuffer', a:selected[1:-1], a:world) let winpos = tlib#fixes#Winpos() - call tlib#file#With('vertical split', 'vertical sbuffer', a:selected, a:world) + call tlib#file#With('vertical split', 'vertical sbuffer', a:selected, a:world, 1) if !empty(winpos) exec winpos endif + call a:world.SetOrigin(1) return tlib#agent#Exit(a:world, a:selected) endf function! tlib#agent#EditFileInTab(world, selected) "{{{3 - " TLogVAR a:selected + Tlibtrace 'tlib', a:selected call a:world.CloseScratch() - call tlib#file#With('tabedit', 'tab sbuffer', a:selected, a:world) + call tlib#file#With('tabedit', 'tab sbuffer', a:selected, a:world, 1) + call a:world.SetOrigin(1) + return tlib#agent#Exit(a:world, a:selected) +endf + + +function! tlib#agent#EditFileInWindow(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected + call a:world.CloseScratch() + call tlib#file#With('hide edit', 'hide buffer', a:selected, a:world, 1) + call a:world.SetOrigin(1) return tlib#agent#Exit(a:world, a:selected) endf function! tlib#agent#ToggleScrollbind(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected let a:world.scrollbind = get(a:world, 'scrollbind') ? 0 : 1 let a:world.state = 'redisplay' return a:world @@ -473,6 +512,7 @@ endf function! tlib#agent#ShowInfo(world, selected) + Tlibtrace 'tlib', a:selected let lines = [] for f in a:selected if filereadable(f) @@ -490,12 +530,30 @@ endf " Buffer related {{{1 +function! tlib#agent#ViewBufferInWindow(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected + if !empty(a:selected) + let back = a:world.SwitchWindow('win') + Tlibtrace 'tlib', back + for bufname in a:selected + let cmd = &modified && !&hidden ? 'sbuffer' : 'buffer' + exec cmd fnameescape(bufname) + endfor + " exec back + endif + return tlib#agent#Exit(a:world, a:selected) +endf + + function! tlib#agent#PreviewLine(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected let l = a:selected[0] - let ww = winnr() - exec a:world.win_wnr .'wincmd w' + " let ww = winnr() + let wid = tlib#win#GetID() + call tlib#agent#SuspendToParentWindow(a:world, a:selected) call tlib#buffer#ViewLine(l, 1) - exec ww .'wincmd w' + call tlib#win#GotoID(wid) + " exec ww .'wincmd w' let a:world.state = 'redisplay' return a:world endf @@ -504,24 +562,12 @@ endf " If not called from the scratch, we assume/guess that we don't have to " suspend the input-evaluation loop. function! tlib#agent#GotoLine(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected if !empty(a:selected) - - " let l = a:selected[0] - " " TLogVAR l - " let back = a:world.SwitchWindow('win') - " " TLogVAR back - " " if a:world.win_wnr != winnr() - " " let world = tlib#agent#Suspend(a:world, a:selected) - " " exec a:world.win_wnr .'wincmd w' - " " endif - " call tlib#buffer#ViewLine(l) - " exec back - " let a:world.state = 'display' - let l = a:selected[0] - if a:world.win_wnr != winnr() + if a:world.win_id != tlib#win#GetID() let world = tlib#agent#Suspend(a:world, a:selected) - exec a:world.win_wnr .'wincmd w' + call tlib#win#GotoID(a:world.win_id) endif call tlib#buffer#ViewLine(l, 1) @@ -531,6 +577,7 @@ endf function! tlib#agent#DoAtLine(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected if !empty(a:selected) let cmd = input('Command: ', '', 'command') if !empty(cmd) @@ -552,6 +599,7 @@ endf function! tlib#agent#Wildcard(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected if !empty(a:world.filter[0]) let rx_type = a:world.matcher.FilterRxPrefix() let flt0 = a:world.CleanFilter(a:world.filter[0][0]) @@ -568,12 +616,14 @@ endf function! tlib#agent#Null(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected let a:world.state = 'redisplay' return a:world endf function! tlib#agent#ExecAgentByName(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected let s:agent_names_world = a:world let agent_names = {'Help': 'tlib#agent#Help'} for def in values(a:world.key_map[a:world.key_mode]) @@ -583,11 +633,11 @@ function! tlib#agent#ExecAgentByName(world, selected) "{{{3 endfor let s:agent_names = sort(keys(agent_names)) let command = input('Command: ', '', 'customlist,tlib#agent#CompleteAgentNames') - " TLogVAR command + Tlibtrace 'tlib', command if !has_key(agent_names, command) - " TLogVAR command + Tlibtrace 'tlib', command silent! let matches = filter(keys(agent_names), 'v:val =~ command') - " TLogVAR matches + Tlibtrace 'tlib', matches if len(matches) == 1 let command = matches[0] endif @@ -609,43 +659,45 @@ endf function! tlib#agent#CompleteAgentNames(ArgLead, CmdLine, CursorPos) - return filter(copy(s:agent_names), 'stridx(v:val, a:ArgLead) != -1') + let arglead = tolower(a:Arglead) + return filter(copy(s:agent_names), 'stridx(tolower(v:val), arglead) != -1') endf function! tlib#agent#Complete(world, selected) abort "{{{3 + Tlibtrace 'tlib', a:selected let rxprefix = a:world.matcher.FilterRxPrefix() let flt = a:world.filter[0][0] - " TLogVAR flt + Tlibtrace 'tlib', flt let fltrx = rxprefix . flt . '\m[^[:space:][:cntrl:][:punct:]<>*+?&~{}()\[\]\\/]\+' let fltrx0 = '\m^' . fltrx - " TLogVAR fltrx, fltrx0 + Tlibtrace 'tlib', fltrx, fltrx0 let words = {} for item in a:world.list let parts = split(item, '\ze'. fltrx) - " TLogVAR item, parts + Tlibtrace 'tlib', item, parts for part in parts let word = matchstr(part, fltrx0) - " TLogVAR part, word + Tlibtrace 'tlib', part, word if !empty(word) let words[word] = 1 endif endfor endfor - " TLogVAR keys(words) + Tlibtrace 'tlib', keys(words) let completions = keys(words) " let completions = filter(keys(words), 'matchstr(v:val, fltrx0)') let completions = sort(completions, 's:SortCompletions') let completions = tlib#list#Uniq(completions) - " TLogVAR 0, completions + Tlibtrace 'tlib', 0, completions while len(completions) > 1 let nchar = strwidth(completions[0]) - 1 - let completions = map(completions, 'strpart(v:val, 0, nchar)') - " TLogVAR 'reduce', completions + let completions = map(completions, 'tlib#string#Strcharpart(v:val, 0, nchar)') + Tlibtrace 'tlib', 'reduce', completions let completions = tlib#list#Uniq(completions) - " TLogVAR 'unique', len(completions), completions + Tlibtrace 'tlib', 'unique', len(completions), completions endwh - " TLogVAR 9, completions + Tlibtrace 'tlib', 9, completions if empty(completions) let a:world.state = 'redisplay update' else diff --git a/sources_non_forked/tlib/autoload/tlib/arg.vim b/sources_non_forked/tlib/autoload/tlib/arg.vim index 2e995146..498e6c73 100644 --- a/sources_non_forked/tlib/autoload/tlib/arg.vim +++ b/sources_non_forked/tlib/autoload/tlib/arg.vim @@ -1,8 +1,8 @@ " @Author: Tom Link (micathom AT gmail com?subject=[vim]) " @Website: http://www.vim.org/account/profile.php?user_id=4037 " @License: GPL (see http://www.gnu.org/licenses/gpl.txt) -" @Last Change: 2015-11-19. -" @Revision: 251 +" @Last Change: 2017-09-28. +" @Revision: 273 " :def: function! tlib#arg#Get(n, var, ?default="", ?test='') @@ -92,30 +92,34 @@ endf " ['-ab', '--', '--foo', '--bar=BAR'] " => {'a': 1, 'b': 1, '__rest__': ['--foo', '--bar=BAR']} function! tlib#arg#GetOpts(args, ...) abort "{{{3 - let throw = a:0 == 0 - TVarArg ['def', {}] - " TLogVAR def - let opts = {'__exit__': 0} - for [key, vdef] in items(get(def, 'values', {})) - if has_key(vdef, 'default') - let opts[key] = vdef.default - endif - endfor - let idx = 0 - for o in a:args - let [break, idx] = s:SetOpt(def, opts, idx, o) - if break == 1 - break - elseif break == 2 - if throw - throw 'tlib#arg#GetOpts: Show help' - else - let opts.__exit__ = 5 + if type(a:args) == 4 + reutrn a:args + else + let throw = a:0 == 0 + TVarArg ['def', {}] + " TLogVAR def + let opts = {'__exit__': 0} + for [key, vdef] in items(get(def, 'values', {})) + if has_key(vdef, 'default') + let opts[key] = vdef.default endif - endif - endfor - let opts.__rest__ = a:args[idx : -1] - return opts + endfor + let idx = 0 + for o in a:args + let [break, idx] = s:SetOpt(def, opts, idx, o) + if break == 1 + break + elseif break == 2 + if throw + throw 'tlib#arg#GetOpts: Show help' + else + let opts.__exit__ = 5 + endif + endif + endfor + let opts.__rest__ = a:args[idx : -1] + return opts + endif endf @@ -147,7 +151,7 @@ function! s:SetOpt(def, opts, idx, opt) abort "{{{3 let default = get(vdef, 'default', '') let type = s:GetValueType(vdef) if default =~ '^-\?\d\+\%(\.\d\+\)$' - if type == -1 + if type == -1 || type == 6 let opt .= ' (flag)' elseif type == 1 let opt .= '=INT' @@ -171,6 +175,11 @@ function! s:SetOpt(def, opts, idx, opt) abort "{{{3 endif endif let break = 2 + elseif long && a:opt =~# '^--\%(no-\)\?debug$' + if has_key(a:def, 'trace') + let mod = a:opt =~# '--no-' ? '-' : '+' + exec 'Tlibtraceset' mod . a:def.trace + endif elseif long && a:opt =~# '^--no-.\+' let key = matchstr(a:opt, '^--no-\zs.\+$') let a:opts[key] = s:Validate(a:def, key, 0) @@ -267,12 +276,14 @@ function! tlib#arg#CComplete(def, ArgLead) abort "{{{3 " endif endif if !empty(words) - let lead = substitute(a:ArgLead, '^--\w\+=', '', '') + let prefix = matchstr(a:ArgLead, '^--\w\+=\%([^,]\+,\s*\)*') + let lead = substitute(a:ArgLead, '^--\w\+=\%([^,]\+,\s*\)*', '', '') + " TLogVAR a:ArgLead, lead if !empty(lead) let nchar = len(lead) - call filter(words, 'strpart(v:val, 0, nchar) ==# lead') + call filter(words, 'tlib#string#Strcharpart(v:val, 0, nchar) ==# lead') endif - let words = map(words, '"--". opt ."=". v:val') + let words = map(words, 'prefix . v:val') return sort(words) endif endif @@ -294,9 +305,12 @@ function! tlib#arg#CComplete(def, ArgLead) abort "{{{3 endif let cs['-'. name] = 1 endfor + if has_key(a:def, 'trace') + let cs['--debug'] = 1 + endif let nchar = len(a:ArgLead) if nchar > 0 - call filter(cs, 'strpart(v:key, 0, nchar) ==# a:ArgLead') + call filter(cs, 'tlib#string#Strcharpart(v:key, 0, nchar) ==# a:ArgLead') endif return sort(keys(cs)) endf diff --git a/sources_non_forked/tlib/autoload/tlib/assert.vim b/sources_non_forked/tlib/autoload/tlib/assert.vim index dbf48369..3d58f59d 100644 --- a/sources_non_forked/tlib/autoload/tlib/assert.vim +++ b/sources_non_forked/tlib/autoload/tlib/assert.vim @@ -1,21 +1,21 @@ " @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) " @Website: https://github.com/tomtom " @License: GPL (see http://www.gnu.org/licenses/gpl.txt) -" @Last Change: 2015-11-23 -" @Revision: 38 +" @Last Change: 2017-02-22 +" @Revision: 42 " Enable tracing via |:Tlibassert|. function! tlib#assert#Enable() abort "{{{3 " :nodoc: - command! -nargs=+ -bar Tlibassert call tlib#assert#Assert(expand(''), , []) + command! -nargs=+ -bang Tlibassert call tlib#assert#Assert(expand(''), , []) endf " Disable tracing via |:Tlibassert|. function! tlib#assert#Disable() abort "{{{3 " :nodoc: - command! -nargs=+ -bang -bar Tlibassert : + command! -nargs=+ -bang Tlibassert : endf diff --git a/sources_non_forked/tlib/autoload/tlib/buffer.vim b/sources_non_forked/tlib/autoload/tlib/buffer.vim index 24e4e0a7..1cbcdb74 100644 --- a/sources_non_forked/tlib/autoload/tlib/buffer.vim +++ b/sources_non_forked/tlib/autoload/tlib/buffer.vim @@ -3,8 +3,8 @@ " @Website: http://www.vim.org/account/profile.php?user_id=4037 " @License: GPL (see http://www.gnu.org/licenses/gpl.txt) " @Created: 2007-06-30. -" @Last Change: 2015-11-06. -" @Revision: 7.1.352 +" @Last Change: 2017-09-28. +" @Revision: 12.1.352 " Where to display the line when using |tlib#buffer#ViewLine|. @@ -15,19 +15,19 @@ TLet g:tlib_viewline_position = 'zz' let s:bmru = [] -function! tlib#buffer#EnableMRU() "{{{3 +function! tlib#buffer#EnableMRU() abort "{{{3 call tlib#autocmdgroup#Init() autocmd TLib BufEnter * call s:BMRU_Push(bufnr('%')) endf -function! tlib#buffer#DisableMRU() "{{{3 +function! tlib#buffer#DisableMRU() abort "{{{3 call tlib#autocmdgroup#Init() autocmd! TLib BufEnter endf -function! s:BMRU_Push(bnr) "{{{3 +function! s:BMRU_Push(bnr) abort "{{{3 let i = index(s:bmru, a:bnr) if i >= 0 call remove(s:bmru, i) @@ -36,7 +36,7 @@ function! s:BMRU_Push(bnr) "{{{3 endf -function! s:CompareBuffernameByBasename(a, b) "{{{3 +function! s:CompareBuffernameByBasename(a, b) abort "{{{3 let rx = '"\zs.\{-}\ze" \+\S\+ \+\d\+$' let an = matchstr(a:a, rx) let an = fnamemodify(an, ':t') @@ -47,7 +47,7 @@ function! s:CompareBuffernameByBasename(a, b) "{{{3 endf -function! s:CompareBufferNrByMRU(a, b) "{{{3 +function! s:CompareBufferNrByMRU(a, b) abort "{{{3 let an = matchstr(a:a, '\s*\zs\d\+\ze') let bn = matchstr(a:b, '\s*\zs\d\+\ze') let ai = index(s:bmru, 0 + an) @@ -66,7 +66,7 @@ endf " Set the buffer to buffer and return a command as string that can be " evaluated by |:execute| in order to restore the original view. -function! tlib#buffer#Set(buffer) "{{{3 +function! tlib#buffer#Set(buffer) abort "{{{3 let lazyredraw = &lazyredraw set lazyredraw try @@ -91,12 +91,12 @@ function! tlib#buffer#Set(buffer) "{{{3 endf -" :def: function! tlib#buffer#Eval(buffer, code) +" :def: function! tlib#buffer#Eval(buffer, code) abort " Evaluate CODE in BUFFER. " " EXAMPLES: > " call tlib#buffer#Eval('foo.txt', 'echo b:bar') -function! tlib#buffer#Eval(buffer, code) "{{{3 +function! tlib#buffer#Eval(buffer, code) abort "{{{3 " let cb = bufnr('%') " let wb = bufwinnr('%') " " TLogVAR cb @@ -134,7 +134,7 @@ function! tlib#buffer#Eval(buffer, code) "{{{3 endf -" :def: function! tlib#buffer#GetList(?show_hidden=0, ?show_number=0, " ?order='bufnr') +" :def: function! tlib#buffer#GetList(?show_hidden=0, ?show_number=0, " ?order='bufnr') abort " Possible values for the "order" argument: " bufnr :: Default behaviour " mru :: Sort buffers according to most recent use @@ -142,7 +142,7 @@ endf " " NOTE: MRU order works on second invocation only. If you want to always " use MRU order, call tlib#buffer#EnableMRU() in your ~/.vimrc file. -function! tlib#buffer#GetList(...) +function! tlib#buffer#GetList(...) abort TVarArg ['show_hidden', 0], ['show_number', 0], ['order', ''] " TLogVAR show_hidden, show_number, order let ls_bang = show_hidden ? '!' : '' @@ -150,14 +150,14 @@ function! tlib#buffer#GetList(...) exec 'silent ls'. ls_bang redir END let buffer_list = split(bfs, '\n') - if order == 'mru' + if order ==# 'mru' if empty(s:bmru) call tlib#buffer#EnableMRU() echom 'tlib: Installed Buffer MRU logger; disable with: call tlib#buffer#DisableMRU()' else call sort(buffer_list, function('s:CompareBufferNrByMRU')) endif - elseif order == 'basename' + elseif order ==# 'basename' call sort(buffer_list, function('s:CompareBuffernameByBasename')) endif let buffer_nr = map(copy(buffer_list), 'str2nr(matchstr(v:val, ''\s*\zs\d\+\ze''))') @@ -176,11 +176,11 @@ function! tlib#buffer#GetList(...) endf -" :def: function! tlib#buffer#ViewLine(line, ?position='z') +" :def: function! tlib#buffer#ViewLine(line, ?position='z') abort " line is either a number or a string that begins with a number. " For possible values for position see |scroll-cursor|. " See also |g:tlib_viewline_position|. -function! tlib#buffer#ViewLine(line, ...) "{{{3 +function! tlib#buffer#ViewLine(line, ...) abort "{{{3 if a:line TVarArg 'pos' let ln = matchstr(a:line, '^\d\+') @@ -200,7 +200,7 @@ function! tlib#buffer#ViewLine(line, ...) "{{{3 endf -function! s:UndoHighlightLine() "{{{3 +function! s:UndoHighlightLine() abort "{{{3 2match none autocmd! TLib CursorMoved,CursorMovedI autocmd! TLib CursorHold,CursorHoldI @@ -209,7 +209,7 @@ function! s:UndoHighlightLine() "{{{3 endf -function! tlib#buffer#HighlightLine(...) "{{{3 +function! tlib#buffer#HighlightLine(...) abort "{{{3 TVarArg ['line', line('.')] " exec '2match MatchParen /^\%'. a:line .'l.*/' exec '2match Search /^\%'. line .'l.*/' @@ -222,7 +222,7 @@ endf " Delete the lines in the current buffer. Wrapper for |:delete|. -function! tlib#buffer#DeleteRange(line1, line2) "{{{3 +function! tlib#buffer#DeleteRange(line1, line2) abort "{{{3 let r = @t try exec a:line1.','.a:line2.'delete t' @@ -233,14 +233,14 @@ endf " Replace a range of lines. -function! tlib#buffer#ReplaceRange(line1, line2, lines) +function! tlib#buffer#ReplaceRange(line1, line2, lines) abort call tlib#buffer#DeleteRange(a:line1, a:line2) call append(a:line1 - 1, a:lines) endf " Initialize some scratch area at the bottom of the current buffer. -function! tlib#buffer#ScratchStart() "{{{3 +function! tlib#buffer#ScratchStart() abort "{{{3 norm! Go let b:tlib_inbuffer_scratch = line('$') return b:tlib_inbuffer_scratch @@ -248,7 +248,7 @@ endf " Remove the in-buffer scratch area. -function! tlib#buffer#ScratchEnd() "{{{3 +function! tlib#buffer#ScratchEnd() abort "{{{3 if !exists('b:tlib_inbuffer_scratch') echoerr 'tlib: In-buffer scratch not initalized' endif @@ -258,14 +258,14 @@ endf " Run exec on all buffers via bufdo and return to the original buffer. -function! tlib#buffer#BufDo(exec) "{{{3 +function! tlib#buffer#BufDo(exec) abort "{{{3 let bn = bufnr('%') exec 'bufdo '. a:exec exec 'buffer! '. bn endf -" :def: function! tlib#buffer#InsertText(text, keyargs) +" :def: function! tlib#buffer#InsertText(text, keyargs) abort " Keyargs: " 'shift': 0|N " 'col': col('.')|N @@ -273,7 +273,7 @@ endf " 'indent': 0|1 " 'pos': 'e'|'s' ... Where to locate the cursor (somewhat like s and e in {offset}) " Insert text (a string) in the buffer. -function! tlib#buffer#InsertText(text, ...) "{{{3 +function! tlib#buffer#InsertText(text, ...) abort "{{{3 TVarArg ['keyargs', {}] " TLogVAR a:text, keyargs let keyargs = extend({ @@ -298,16 +298,16 @@ function! tlib#buffer#InsertText(text, ...) "{{{3 " exec 'norm! '. keyargs.lineno .'G' call cursor(keyargs.lineno, keyargs.col) if keyargs.indent && keyargs.col > 1 - if &fo =~# '[or]' + if &formatoptions =~# '[or]' " FIXME: Is the simple version sufficient? " VERSION 1 " " This doesn't work because it's not guaranteed that the " " cursor is set. " let cline = getline('.') - " norm! a + " norm! a " "norm! o " " TAssertExec redraw | sleep 3 - " let idt = strpart(getline('.'), 0, keyargs.col('.') + keyargs.shift) + " let idt = tlib#string#Strcharpart(getline('.'), 0, keyargs.col('.') + keyargs.shift) " " TLogVAR idt " let idtl = len(idt) " -1,.delete @@ -346,10 +346,10 @@ function! tlib#buffer#InsertText(text, ...) "{{{3 let tlen = len(text) let posshift = matchstr(keyargs.pos, '\d\+') " TLogVAR keyargs.pos - if keyargs.pos =~ '^e' + if keyargs.pos =~# '^e' exec keyargs.lineno + tlen - 1 exec 'norm! 0'. (len(text[-1]) - len(post) + posshift - 1) .'l' - elseif keyargs.pos =~ '^s' + elseif keyargs.pos =~# '^s' " TLogVAR keyargs.lineno, pre, posshift exec keyargs.lineno exec 'norm! '. len(pre) .'|' @@ -363,7 +363,7 @@ function! tlib#buffer#InsertText(text, ...) "{{{3 endf -function! tlib#buffer#InsertText0(text, ...) "{{{3 +function! tlib#buffer#InsertText0(text, ...) abort "{{{3 TVarArg ['keyargs', {}] let mode = get(keyargs, 'mode', 'i') " TLogVAR mode @@ -382,13 +382,13 @@ function! tlib#buffer#InsertText0(text, ...) "{{{3 endf -function! tlib#buffer#CurrentByte() "{{{3 +function! tlib#buffer#CurrentByte() abort "{{{3 return line2byte(line('.')) + col('.') endf " Evaluate cmd while maintaining the cursor position and jump registers. -function! tlib#buffer#KeepCursorPosition(cmd) "{{{3 +function! tlib#buffer#KeepCursorPosition(cmd) abort "{{{3 " let pos = getpos('.') let view = winsaveview() try diff --git a/sources_non_forked/tlib/autoload/tlib/cache.vim b/sources_non_forked/tlib/autoload/tlib/cache.vim index 7d2266fd..5363ebd0 100644 --- a/sources_non_forked/tlib/autoload/tlib/cache.vim +++ b/sources_non_forked/tlib/autoload/tlib/cache.vim @@ -3,8 +3,8 @@ " @Website: http://www.vim.org/account/profile.php?user_id=4037 " @License: GPL (see http://www.gnu.org/licenses/gpl.txt) " @Created: 2007-06-30. -" @Last Change: 2015-10-24. -" @Revision: 31.1.243 +" @Last Change: 2019-01-02. +" @Revision: 125.1.243 " The cache directory. If empty, use |tlib#dir#MyRuntime|.'/cache'. @@ -45,21 +45,37 @@ TLet g:tlib#cache#dont_purge = ['[\/]\.last_purge$'] " |pathshorten()|. TLet g:tlib#cache#max_filename = 200 +TLet g:tlib#cache#use_json = 0 + +TLet g:tlib#cache#use_encoding = '' + + let s:cache = {} -" :display: tlib#cache#Dir(?mode = 'bg') +" :display: tlib#cache#Dir(?mode = 'bg', ?ensure_dir = true) " The default cache directory. function! tlib#cache#Dir(...) "{{{3 - TVarArg ['mode', 'bg'] + TVarArg ['mode', 'bg'], ['ensure_dir', 1] let dir = tlib#var#Get('tlib_cache', mode) if empty(dir) let dir = tlib#file#Join([tlib#dir#MyRuntime(), 'cache']) endif + if ensure_dir + call tlib#dir#Ensure(dir) + endif return dir endf +" :display: tlib#cache#EncodedFilename(type, file, ?mkdir=0, ?dir='') +" Encode `file` and call |tlib#cache#Filename()|. +function! tlib#cache#EncodedFilename(type, file, ...) "{{{3 + let file = tlib#url#Encode(a:file) + return call(function('tlib#cache#Filename'), [a:type, file] + a:000) +endf + + " :def: function! tlib#cache#Filename(type, ?file=%, ?mkdir=0, ?dir='') function! tlib#cache#Filename(type, ...) "{{{3 " TLogDBG 'bufname='. bufname('.') @@ -90,12 +106,15 @@ function! tlib#cache#Filename(type, ...) "{{{3 " TLogVAR file, dir, mkdir let cache_file = tlib#file#Join([dir, file]) if len(cache_file) > g:tlib#cache#max_filename + " echom "DBG long filename" cache_file + " echom "DBG long filename" dir if v:version >= 704 - let shortfilename = pathshorten(file) .'_'. sha256(file) + let shortfilename = sha256(file) else - let shortfilename = pathshorten(file) .'_'. tlib#hash#Adler32(file) + let shortfilename = tlib#hash#Adler32(file) endif - let cache_file = tlib#cache#Filename(a:type, shortfilename, mkdir, dir0) + " let cache_file = tlib#cache#Filename(a:type, shortfilename, mkdir, dir0) + let cache_file = tlib#file#Join([dir, shortfilename]) else if mkdir && !isdirectory(dir) try @@ -126,15 +145,45 @@ function! s:SetTimestamp(cfile, type) "{{{3 endf -function! tlib#cache#Save(cfile, dictionary, ...) "{{{3 +function! s:PutValue(cfile, value) abort "{{{3 + let s:cache[a:cfile] = {'mtime': localtime(), 'data': a:value} +endf + + +function! s:GetValue(cfile, default) abort "{{{3 + return get(get(s:cache, a:cfile, {}), 'data', a:default) +endf + + +function! s:GetCacheTime(cfile) abort "{{{3 + let not_found = !has_key(s:cache, a:cfile) + let cftime = not_found ? -1 : s:cache[a:cfile].mtime + return cftime +endf + + +function! tlib#cache#Save(cfile, value, ...) "{{{3 TVarArg ['options', {}] let in_memory = get(options, 'in_memory', 0) if in_memory " TLogVAR in_memory, a:cfile, localtime() - let s:cache[a:cfile] = {'mtime': localtime(), 'data': a:dictionary} + call s:PutValue(a:cfile, a:value) elseif !empty(a:cfile) - " TLogVAR a:dictionary - call writefile([string(a:dictionary)], a:cfile, 'b') + " TLogVAR a:value + let cfile = a:cfile + if g:tlib#cache#use_json && exists('*json_encode') + try + let value = json_encode(a:value) + let cfile .= '.json' + catch + echoerr v:exception + let value = string(a:value) + endtry + else + let value = string(a:value) + endif + Tlibtrace 'tlib', cfile, value + call writefile([value], cfile, 'b') call s:SetTimestamp(a:cfile, 'write') endif endf @@ -152,16 +201,57 @@ function! tlib#cache#Get(cfile, ...) "{{{3 let in_memory = get(options, 'in_memory', 0) if in_memory " TLogVAR in_memory, a:cfile - return get(get(s:cache, a:cfile, {}), 'data', default) + return s:GetValue(a:cfile, default) else call tlib#cache#MaybePurge() - if !empty(a:cfile) && filereadable(a:cfile) - let val = readfile(a:cfile, 'b') - call s:SetTimestamp(a:cfile, 'read') - return eval(join(val, "\n")) - else - return default + if !empty(a:cfile) + let jsonfile = a:cfile .'.json' + let use_json = g:tlib#cache#use_json && exists('*json_decode') && exists('v:none') && filereadable(jsonfile) + if use_json + let use_json = 1 + let cfile = jsonfile + else + let cfile = a:cfile + endif + let mt = s:GetCacheTime(cfile) + let ft = getftime(cfile) + if mt != -1 && mt >= ft + return s:GetValue(cfile, default) + elseif ft != -1 + call s:SetTimestamp(cfile, 'read') + let val = join(readfile(cfile, 'b'), '\n') + try + if use_json + " NOTE: Copy result of json_decode() in order to + " avoid "E741: value is locked" error in vim8. + let value = json_decode(val) + if value is v:none + let value = default + else + let value = copy(value) + endif + else + let value = eval(val) + endif + call s:PutValue(cfile, value) + return value + catch + echohl ErrorMsg + echom v:exception + echom 'tlib#cache#Get: Invalid value in:' cfile + echom 'Value:' string(val) + echom 'Please review the file and delete it if necessary' + echom 'Will use default value:' string(default) + echohl NONE + if g:tlib#debug + let @* = string(val) + endif + " call s:PutValue(cfile, default) + return default + endtry + endif endif + return default endif endf @@ -172,10 +262,14 @@ endf function! tlib#cache#Value(cfile, generator, ftime, ...) "{{{3 TVarArg ['args', []], ['options', {}] let in_memory = get(options, 'in_memory', 0) - let not_found = in_memory ? !has_key(s:cache, a:cfile) : !filereadable(a:cfile) - " TLogVAR in_memory, not_found - let cftime = in_memory ? (not_found ? 0 : s:cache[a:cfile].mtime) : getftime(a:cfile) - if not_found || (a:ftime != 0 && cftime < a:ftime) + if in_memory + let cftime = s:GetCacheTime(a:cfile) + else + let cftime = getftime(a:cfile) + endif + let ftime = a:ftime + " TLogVAR in_memory, cftime + if cftime == -1 || ftime == -1 || (ftime != 0 && cftime < ftime) " TLogVAR a:generator, args let val = call(a:generator, args) " TLogVAR val @@ -194,6 +288,12 @@ function! tlib#cache#Value(cfile, generator, ftime, ...) "{{{3 endf +function! tlib#cache#ValueFromName(type, name, ...) abort "{{{3 + let cfile = tlib#cache#Filename(a:type, tlib#url#Encode(a:name), 1) + return call(function('tlib#cache#Value'), [cfile] + a:000) +endf + + " Call |tlib#cache#Purge()| if the last purge was done before " |g:tlib#cache#purge_every_days|. function! tlib#cache#MaybePurge() "{{{3 @@ -251,16 +351,12 @@ function! tlib#cache#Purge() "{{{3 try for file in files if isdirectory(file) - if empty(filter(copy(newer), 'strpart(v:val, 0, len(file)) ==# file')) + if empty(filter(copy(newer), 'tlib#string#Strcharpart(v:val, 0, len(file)) ==# file')) call add(deldir, file) endif else if getftime(file) < threshold - if delete(file) - call add(msg, "TLib: Could not delete cache file: ". file) - elseif g:tlib#cache#verbosity >= 2 - call add(msg, "TLib: Delete cache file: ". file) - endif + call s:Delete(msg, file, '') else call add(newer, file) endif @@ -273,56 +369,68 @@ function! tlib#cache#Purge() "{{{3 echo join(msg, "\n") endif if !empty(deldir) - if &shell =~ 'sh\(\.exe\)\?$' - let scriptfile = 'deldir.sh' - let rmdir = 'rm -rf %s' - else - let scriptfile = 'deldir.bat' - let rmdir = 'rmdir /S /Q %s' - endif - let enc = g:tlib#cache#script_encoding - if has('multi_byte') && enc != &enc - call map(deldir, 'iconv(v:val, &enc, enc)') - endif - let scriptfile = tlib#file#Join([dir, scriptfile]) - if filereadable(scriptfile) - let script = readfile(scriptfile) - else - let script = [] - endif - let script += map(copy(deldir), 'printf(rmdir, shellescape(v:val, 1))') - let script = tlib#list#Uniq(script) - call writefile(script, scriptfile) - call inputsave() - if g:tlib#cache#run_script == 0 - if g:tlib#cache#verbosity >= 1 - echohl WarningMsg - if g:tlib#cache#verbosity >= 2 - echom "TLib: Purged cache. Need to run script to delete directories" - endif - echom "TLib: Please review and execute: ". scriptfile - echohl NONE + let deldir = filter(reverse(sort(deldir)), 's:Delete(msg, v:val, "d")') + if !empty(deldir) + if &shell =~ 'sh\(\.exe\)\?$' + let scriptfile = 'deldir.sh' + let rmdir = 'rm -rf %s' + else + let scriptfile = 'deldir.bat' + let rmdir = 'rmdir /S /Q %s' endif - else - try - let yn = g:tlib#cache#run_script == 2 ? 'y' : tlib#input#Dialog("TLib: About to delete directories by means of a shell script.\nDirectory removal script: ". scriptfile ."\nRun script to delete directories now?", ['yes', 'no', 'edit'], 'no') - if yn =~ '^y\%[es]$' - exec 'cd '. fnameescape(dir) - exec '! ' &shell shellescape(scriptfile, 1) - exec 'cd -' - call delete(scriptfile) - elseif yn =~ '^e\%[dit]$' - exec 'edit '. fnameescape(scriptfile) + let enc = g:tlib#cache#script_encoding + if has('multi_byte') && enc != &enc + call map(deldir, 'iconv(v:val, &enc, enc)') + endif + let scriptfile = tlib#file#Join([dir, scriptfile]) + if filereadable(scriptfile) + let script = readfile(scriptfile) + else + let script = [] + endif + let script += map(copy(deldir), 'printf(rmdir, shellescape(v:val, 1))') + let script = tlib#list#Uniq(script) + call writefile(script, scriptfile) + call inputsave() + if g:tlib#cache#run_script == 0 + if g:tlib#cache#verbosity >= 1 + echohl WarningMsg + if g:tlib#cache#verbosity >= 2 + echom "TLib: Purged cache. Need to run script to delete directories" + endif + echom "TLib: Please review and execute: ". scriptfile + echohl NONE endif - finally - call inputrestore() - endtry + else + try + let yn = g:tlib#cache#run_script == 2 ? 'y' : tlib#input#Dialog("TLib: About to delete directories by means of a shell script.\nDirectory removal script: ". scriptfile ."\nRun script to delete directories now?", ['yes', 'no', 'edit'], 'no') + if yn =~ '^y\%[es]$' + exec 'silent cd '. fnameescape(dir) + exec '! ' &shell shellescape(scriptfile, 1) + exec 'silent cd -' + call delete(scriptfile) + elseif yn =~ '^e\%[dit]$' + exec 'edit '. fnameescape(scriptfile) + endif + finally + call inputrestore() + endtry + endif endif endif call s:PurgeTimestamp(dir) endf +function! s:Delete(msg, file, flags) abort "{{{3 + let rv = delete(a:file, a:flags) + if !rv && g:tlib#cache#verbosity >= 2 + call add(a:msg, "TLib#cache: Delete ". file) + endif + return rv +endf + + function! s:PurgeTimestamp(dir) "{{{3 let last_purge = tlib#file#Join([a:dir, '.last_purge']) " TLogVAR last_purge @@ -338,7 +446,7 @@ function! tlib#cache#ListFilesInCache(...) "{{{3 endif let files = reverse(split(filess, '\n')) let pos0 = len(tlib#dir#CanonicName(dir)) - call filter(files, 's:ShouldPurge(strpart(v:val, pos0))') + call filter(files, 's:ShouldPurge(tlib#string#Strcharpart(v:val, pos0))') return files endf diff --git a/sources_non_forked/tlib/autoload/tlib/date.vim b/sources_non_forked/tlib/autoload/tlib/date.vim index 7be5e9fb..1b7559c8 100644 --- a/sources_non_forked/tlib/autoload/tlib/date.vim +++ b/sources_non_forked/tlib/autoload/tlib/date.vim @@ -3,8 +3,8 @@ " @Website: http://www.vim.org/account/profile.php?user_id=4037 " @License: GPL (see http://www.gnu.org/licenses/gpl.txt) " @Created: 2010-03-25. -" @Last Change: 2015-11-23. -" @Revision: 21.0.34 +" @Last Change: 2017-09-06. +" @Revision: 44.0.34 if !exists('g:tlib#date#ShortDatePrefix') | let g:tlib#date#ShortDatePrefix = '20' | endif "{{{2 @@ -17,12 +17,14 @@ let g:tlib#date#date_format = '%Y-%m-%d' function! tlib#date#IsDate(text) abort "{{{3 - return a:text =~# '^'. g:tlib#date#date_rx .'$' + return a:text =~# '^'. g:tlib#date#date_rx .'$' && + \ !empty(tlib#date#Parse(a:text, 0, 1)) endf -function! tlib#date#Format(secs1970) abort "{{{3 - return strftime(g:tlib#date#date_format, a:secs1970) +function! tlib#date#Format(...) abort "{{{3 + let secs1970 = a:0 >= 1 ? a:1 : localtime() + return strftime(g:tlib#date#date_format, secs1970) endf @@ -37,11 +39,16 @@ function! tlib#date#DiffInDays(date, ...) endf -" :display: tlib#date#Parse(date, ?allow_zero=0) "{{{3 +" :display: tlib#date#Parse(date, ?allow_zero=0, ?silent=0) "{{{3 function! tlib#date#Parse(date, ...) "{{{3 let min = a:0 >= 1 && a:1 ? 0 : 1 - " TLogVAR a:date, min + let silent = a:0 >= 2 ? a:2 : 0 + Tlibtype 'tlib', a:date, min, silent let m = matchlist(a:date, '^\(\d\{2}\|\d\{4}\)-\(\d\{1,2}\)-\(\d\{1,2}\)$') + Tlibtype 'tlib', m + let year = '' + let month = '' + let days = '' if !empty(m) let year = m[1] let month = m[2] @@ -61,13 +68,17 @@ function! tlib#date#Parse(date, ...) "{{{3 endif endif endif + Tlibtype 'tlib', year, month, days if empty(m) || year == '' || month == '' || days == '' || \ month < min || month > 12 || days < min || days > 31 - echoerr 'TLib: Invalid date: '. a:date + if !silent + echoerr 'TLib: Invalid date: '. a:date + endif return [] endif if strlen(year) == 2 let year = g:tlib#date#ShortDatePrefix . year + Tlibtype 'tlib', year endif return [0 + year, 0 + month, 0 + days] endf @@ -137,22 +148,35 @@ function! tlib#date#Shift(date, shift) abort "{{{3 let ml = matchlist(a:date, g:tlib#date#date_rx) " TLogVAR a:date, a:shift, n, ml if a:shift =~ 'd$' - let secs = tlib#date#SecondsSince1970(a:date) + g:tlib#date#dayshift * n - " TLogVAR secs + let date = tlib#date#AddDays(a:date, n) + elseif a:shift =~ 'b$' + let n1 = n + let secs = tlib#date#SecondsSince1970(a:date) + while n1 > 0 + let n1 -= 1 + let secs += g:tlib#date#dayshift + let uday = strftime('%u', secs) + if uday == 6 + let secs += g:tlib#date#dayshift * 2 + elseif uday == 7 + let secs += g:tlib#date#dayshift + endif + endwh let date = tlib#date#Format(secs) elseif a:shift =~ 'w$' - let secs = tlib#date#SecondsSince1970(a:date) + g:tlib#date#dayshift * n * 7 - let date = tlib#date#Format(secs) + let date = tlib#date#AddDays(a:date, n * 7) elseif a:shift =~ 'm$' let d = str2nr(ml[3]) let ms = str2nr(ml[2]) + n let m = (ms - 1) % 12 + 1 - let yr = str2nr(ml[1]) + ms / 12 + let yr = str2nr(ml[1]) + (ms - 1) / 12 let date = printf('%04d-%02d-%02d', yr, m, d) " TLogVAR d, ms, m, yr, date elseif a:shift =~ 'y$' let yr = str2nr(ml[1]) + n let date = substitute(a:date, '^\d\{4}', yr, '') + else + throw 'tlib#date#Shift: Unsupported arguments: '. string(a:shift) endif " if !empty(ml[4]) && date !~ '\s'. ml[4] .'$' " let date .= ' '. ml[4] @@ -161,3 +185,11 @@ function! tlib#date#Shift(date, shift) abort "{{{3 return date endf + +function! tlib#date#AddDays(date, n) abort "{{{3 + let secs = tlib#date#SecondsSince1970(a:date) + g:tlib#date#dayshift * a:n + " TLogVAR secs + let date = tlib#date#Format(secs) + return date +endf + diff --git a/sources_non_forked/tlib/autoload/tlib/dictionary.vim b/sources_non_forked/tlib/autoload/tlib/dictionary.vim index 77712b03..a7785196 100644 --- a/sources_non_forked/tlib/autoload/tlib/dictionary.vim +++ b/sources_non_forked/tlib/autoload/tlib/dictionary.vim @@ -1,14 +1,44 @@ " @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) " @Website: https://github.com/tomtom " @License: GPL (see http://www.gnu.org/licenses/gpl.txt) -" @Last Change: 2015-10-14 -" @Revision: 2 +" @Last Change: 2016-04-06 +" @Revision: 22 -function! tlib#dictionary#Rev(dict) abort "{{{3 +" :display: tlib#dictionary#Rev(dict, ?opts = {}) abort "{{{3 +function! tlib#dictionary#Rev(dict, ...) abort "{{{3 + let opts = a:0 >= 1 ? a:1 : {} + Tlibtype a:dict, 'dict', opts, 'dict' let rev = {} + let use_string = get(opts, 'use_string', 0) + let use_eval = get(opts, 'use_eval', 0) + let values_as_list = get(opts, 'values_as_list', 0) for [m, f] in items(a:dict) - let rev[f] = m + if use_string + let k = string(f) + else + let k = type(f) == 1 ? f : string(f) + if k ==# '' + let k = get(opts, 'empty', '') + if empty(k) + continue + endif + endif + endif + if use_eval + let v = eval(m) + else + let v = m + endif + if values_as_list + if has_key(rev, k) + call add(rev[k], v) + else + let rev[k] = [v] + endif + else + let rev[k] = v + endif endfor return rev endf diff --git a/sources_non_forked/tlib/autoload/tlib/dir.vim b/sources_non_forked/tlib/autoload/tlib/dir.vim index f6f3e4e9..02081079 100644 --- a/sources_non_forked/tlib/autoload/tlib/dir.vim +++ b/sources_non_forked/tlib/autoload/tlib/dir.vim @@ -1,7 +1,7 @@ " @Author: Tom Link (micathom AT gmail com?subject=[vim]) " @Website: http://www.vim.org/account/profile.php?user_id=4037 " @License: GPL (see http://www.gnu.org/licenses/gpl.txt) -" @Revision: 40 +" @Revision: 43 " TLet g:tlib#dir#sep = '/' TLet g:tlib#dir#sep = exists('+shellslash') && !&shellslash ? '\' : '/' @@ -65,12 +65,12 @@ endf " :def: function! tlib#dir#CD(dir, ?locally=0) => CWD function! tlib#dir#CD(dir, ...) "{{{3 - TVarArg ['locally', 0] + TVarArg ['locally', haslocaldir()] let cmd = locally ? 'lcd! ' : 'cd! ' " let cwd = getcwd() let cmd .= tlib#arg#Ex(a:dir) " TLogVAR a:dir, locally, cmd - exec cmd + exec 'silent' cmd " return cwd return getcwd() endf @@ -78,7 +78,7 @@ endf " :def: function! tlib#dir#Push(dir, ?locally=0) => CWD function! tlib#dir#Push(dir, ...) "{{{3 - TVarArg ['locally', 0] + TVarArg ['locally', haslocaldir()] call add(s:dir_stack, [getcwd(), locally]) return tlib#dir#CD(a:dir, locally) endf diff --git a/sources_non_forked/tlib/autoload/tlib/file.vim b/sources_non_forked/tlib/autoload/tlib/file.vim index d0f89b96..a52c1be3 100644 --- a/sources_non_forked/tlib/autoload/tlib/file.vim +++ b/sources_non_forked/tlib/autoload/tlib/file.vim @@ -1,7 +1,7 @@ " @Author: Tom Link (micathom AT gmail com?subject=[vim]) " @Website: http://www.vim.org/account/profile.php?user_id=4037 " @License: GPL (see http://www.gnu.org/licenses/gpl.txt) -" @Revision: 168 +" @Revision: 225 if !exists('g:tlib#file#drop') @@ -24,6 +24,12 @@ if !exists('g:tlib#file#absolute_filename_rx') let g:tlib#file#absolute_filename_rx = '^\~\?[\/]' "{{{2 endif + +if !exists('g:tlib#file#reject_rx') + let g:tlib#file#reject_rx = '\%(^\|[\/]\)\%(tags\|Thumbs\.db\)$' "{{{2 +endif + + """ File related {{{1 " For the following functions please see ../../test/tlib.vim for examples. @@ -31,9 +37,9 @@ endif " EXAMPLES: > " tlib#file#Split('foo/bar/filename.txt') " => ['foo', 'bar', 'filename.txt'] -function! tlib#file#Split(filename) "{{{3 +function! tlib#file#Split(filename) abort "{{{3 let prefix = matchstr(a:filename, '^\(\w\+:\)\?/\+') - " TLogVAR prefix + Tlibtrace 'tlib', prefix if !empty(prefix) let filename = a:filename[len(prefix) : -1] else @@ -52,9 +58,9 @@ endf " EXAMPLES: > " tlib#file#Join(['foo', 'bar', 'filename.txt']) " => 'foo/bar/filename.txt' -function! tlib#file#Join(filename_parts, ...) "{{{3 +function! tlib#file#Join(filename_parts, ...) abort "{{{3 TVarArg ['strip_slashes', 1], 'maybe_absolute' - " TLogVAR a:filename_parts, strip_slashes + Tlibtrace 'tlib', a:filename_parts, strip_slashes if maybe_absolute let filename_parts = [] for part in a:filename_parts @@ -70,7 +76,7 @@ function! tlib#file#Join(filename_parts, ...) "{{{3 " let rx = tlib#rx#Escape(g:tlib#dir#sep) .'$' let rx = '[/\\]\+$' let parts = map(copy(filename_parts), 'substitute(v:val, rx, "", "")') - " TLogVAR parts + Tlibtrace 'tlib', parts return join(parts, g:tlib#dir#sep) else return join(filename_parts, g:tlib#dir#sep) @@ -81,18 +87,18 @@ endf " EXAMPLES: > " tlib#file#Relative('foo/bar/filename.txt', 'foo') " => 'bar/filename.txt' -function! tlib#file#Relative(filename, basedir) "{{{3 - " TLogVAR a:filename, a:basedir +function! tlib#file#Relative(filename, basedir) abort "{{{3 + Tlibtrace 'tlib', a:filename, a:basedir " TLogDBG getcwd() " TLogDBG expand('%:p') let b0 = tlib#file#Absolute(a:basedir) let b = tlib#file#Split(b0) - " TLogVAR b + Tlibtrace 'tlib', b let f0 = tlib#file#Absolute(a:filename) let fn = fnamemodify(f0, ':t') let fd = fnamemodify(f0, ':h') let f = tlib#file#Split(fd) - " TLogVAR f0, fn, fd, f + Tlibtrace 'tlib', f0, fn, fd, f if f[0] != b[0] let rv = f0 else @@ -103,18 +109,23 @@ function! tlib#file#Relative(filename, basedir) "{{{3 call remove(f, 0) call remove(b, 0) endwh - " TLogVAR f, b + Tlibtrace 'tlib', f, b let rv = tlib#file#Join(repeat(['..'], len(b)) + f + [fn]) endif - " TLogVAR rv + Tlibtrace 'tlib', rv return rv endf -function! tlib#file#Absolute(filename, ...) "{{{3 +function! tlib#file#IsAbsolute(filename) abort "{{{3 + return a:filename =~? '^\%(/\|\w\+:/\)' +endf + + +function! tlib#file#Absolute(filename, ...) abort "{{{3 if filereadable(a:filename) let filename = fnamemodify(a:filename, ':p') - elseif a:filename =~ '^\(/\|[^\/]\+:\)' + elseif a:filename =~# '^\(/\|[^\/]\+:\)' let filename = a:filename else let cwd = a:0 >= 1 ? a:1 : getcwd() @@ -126,17 +137,19 @@ function! tlib#file#Absolute(filename, ...) "{{{3 endf -function! tlib#file#Canonic(filename, ...) "{{{3 +function! tlib#file#Canonic(filename, ...) abort "{{{3 TVarArg ['mode', ''] - if a:filename =~ '^\\\\' - let mode = 'windows' - elseif a:filename =~ '^\(file\|ftp\|http\)s\?:' - let mode = 'url' - elseif (empty(mode) && g:tlib#sys#windows) - let mode = 'windows' + if empty(mode) + if a:filename =~# '^\\\\' + let mode = 'windows' + elseif a:filename =~# '^\(file\|ftp\|http\)s\?:' + let mode = 'url' + elseif (empty(mode) && g:tlib#sys#windows) + let mode = 'windows' + endif endif let filename = a:filename - if mode == 'windows' + if mode ==# 'windows' let filename = substitute(filename, '/', '\\', 'g') else let filename = substitute(filename, '\\', '/', 'g') @@ -145,7 +158,7 @@ function! tlib#file#Canonic(filename, ...) "{{{3 endf -function! s:SetScrollBind(world) "{{{3 +function! s:SetScrollBind(world) abort "{{{3 let sb = get(a:world, 'scrollbind', &scrollbind) if sb != &scrollbind let &scrollbind = sb @@ -153,60 +166,81 @@ function! s:SetScrollBind(world) "{{{3 endf -" :def: function! tlib#file#With(fcmd, bcmd, files, ?world={}) -function! tlib#file#With(fcmd, bcmd, files, ...) "{{{3 - " TLogVAR a:fcmd, a:bcmd, a:files +" :def: function! tlib#file#With(fcmd, bcmd, files, ?world={}) abort +function! tlib#file#With(fcmd, bcmd, files, ...) abort "{{{3 + Tlibtrace 'tlib', a:fcmd, a:bcmd, a:files + let world = a:0 >= 1 ? a:1 : {} + let unset_switchbuf = a:0 >= 2 ? a:2 : 0 exec tlib#arg#Let([['world', {}]]) call tlib#autocmdgroup#Init() augroup TLibFileRead autocmd! augroup END - for f in a:files - let bn = bufnr('^'.f.'$') - " TLogVAR f, bn - let bufloaded = bufloaded(bn) - let ok = 0 - let s:bufread = "" - if bn != -1 && buflisted(bn) - if !empty(a:bcmd) - " TLogDBG a:bcmd .' '. bn - exec a:bcmd .' '. bn - let ok = 1 - call s:SetScrollBind(world) - endif - else - if filereadable(f) - if !empty(a:fcmd) - " TLogDBG a:fcmd .' '. tlib#arg#Ex(f) - exec 'autocmd TLibFileRead BufRead' escape(f, '\ ') 'let s:bufread=expand(":p")' - try - exec a:fcmd .' '. tlib#arg#Ex(f) - finally - exec 'autocmd! TLibFileRead BufRead' - endtry - let ok = 1 - call s:SetScrollBind(world) + if unset_switchbuf + let switchbuf = &switchbuf + set switchbuf& + endif + try + for f in a:files + try + let bn = bufnr('^'.f.'$') + Tlibtrace 'tlib', f, bn + let bufloaded = bufloaded(bn) + let ok = 0 + let s:bufread = "" + if bn != -1 && buflisted(bn) + if !empty(a:bcmd) + let bcmd = a:bcmd .' '. bn + Tlibtrace 'tlib', bcmd + exec bcmd + let ok = 1 + call s:SetScrollBind(world) + endif + else + if filereadable(f) + if !empty(a:fcmd) + " TLogDBG a:fcmd .' '. tlib#arg#Ex(f) + exec 'autocmd TLibFileRead BufRead' escape(f, '\ ') 'let s:bufread=expand(":p")' + try + let fcmd = a:fcmd .' '. tlib#arg#Ex(f) + Tlibtrace 'tlib', fcmd + exec fcmd + finally + exec 'autocmd! TLibFileRead BufRead' + endtry + let ok = 1 + call s:SetScrollBind(world) + endif + else + echohl error + echom 'File not readable: '. f + echohl NONE + endif endif - else - echohl error - echom 'File not readable: '. f + Tlibtrace 'tlib', ok, bufloaded, &filetype + if empty(s:bufread) && ok && !bufloaded && empty(&filetype) + doautocmd BufRead + endif + catch /^Vim\%((\a\+)\)\=:E325/ + echohl ErrorMsg + echom v:exception echohl NONE - endif + endtry + endfor + finally + augroup! TLibFileRead + if unset_switchbuf + let &switchbuf = switchbuf endif - " TLogVAR ok, bufloaded, &filetype - if empty(s:bufread) && ok && !bufloaded && empty(&filetype) - doautocmd BufRead - endif - endfor - augroup! TLibFileRead - unlet! s:bufread + unlet! s:bufread + endtry " TLogDBG "done" endf " Return 0 if the file isn't readable/doesn't exist. " Otherwise return 1. -function! tlib#file#Edit(fileid) "{{{3 +function! tlib#file#Edit(fileid) abort "{{{3 if type(a:fileid) == 0 let bn = a:fileid let filename = fnamemodify(bufname(bn), ':p') @@ -217,20 +251,26 @@ function! tlib#file#Edit(fileid) "{{{3 if filename == expand('%:p') return 1 else - " TLogVAR a:fileid, bn, filename, g:tlib#file#drop, filereadable(filename) + Tlibtrace 'tlib', a:fileid, bn, filename, g:tlib#file#drop, filereadable(filename), bufnr('%') if bn != -1 && buflisted(bn) if g:tlib#file#drop " echom "DBG" get(g:tlib#file#edit_cmds, 'drop', 'drop') fnameescape(filename) exec get(g:tlib#file#edit_cmds, 'drop', 'drop') fnameescape(filename) + " echom "DBG" bufnr('%') else " echom "DBG" get(g:tlib#file#edit_cmds, 'buffer', 'buffer') bn exec get(g:tlib#file#edit_cmds, 'buffer', 'buffer') bn + " echom "DBG" bufnr('%') endif return 1 - elseif filereadable(filename) + endif + if !filereadable(filename) && exists('#TLibPrepareFile#User') + exec 'doautocmd TLibPrepareFile User' filename + endif + if filereadable(filename) try " let file = tlib#arg#Ex(filename) - " " TLogVAR file + " Tlibtrace 'tlib', file " echom "DBG" get(g:tlib#file#edit_cmds, 'edit', 'edit') fnameescape(filename) exec get(g:tlib#file#edit_cmds, 'edit', 'edit') fnameescape(filename) catch /E325/ @@ -252,27 +292,65 @@ function! tlib#file#Edit(fileid) "{{{3 endf +function! tlib#file#FilterFiles(files, options) abort "{{{3 + Tlibtrace 'tlib', a:files, a:options, g:tlib#file#reject_rx + if !get(a:options, 'all', 0) + call filter(a:files, 'v:val !~# g:tlib#file#reject_rx') + endif + Tlibtrace 'tlib', a:files + let type = get(a:options, 'type', 'fd') + Tlibtrace 'tlib', type + if type !~# 'd' || type !~# 'f' + call filter(a:files, 'isdirectory(v:val) ? type =~# "d" : type =~# "f"') + endif + Tlibtrace 'tlib', a:files + return a:files +endf + + if v:version > 704 || (v:version == 704 && has('patch279')) - function! tlib#file#Glob(pattern) abort "{{{3 - return glob(a:pattern, 0, 1) + function! tlib#file#Glob(pattern, ...) abort "{{{3 + let all = a:0 >= 1 ? a:1 : 0 + let nosuf = a:0 >= 2 ? a:2 : 0 + return tlib#file#FilterFiles(glob(a:pattern, nosuf, 1), {'all': all}) endf - function! tlib#file#Globpath(path, pattern) abort "{{{3 - return globpath(a:path, a:pattern, 0, 1) + function! tlib#file#Globpath(path, pattern, ...) abort "{{{3 + let all = a:0 >= 1 ? a:1 : 0 + let nosuf = a:0 >= 2 ? a:2 : 0 + return tlib#file#FilterFiles(globpath(a:path, a:pattern, nosuf, 1), {'all': all}) endf else " :nodoc: - function! tlib#file#Glob(pattern) abort "{{{3 - return split(glob(a:pattern), '\n') + function! tlib#file#Glob(pattern, ...) abort "{{{3 + let all = a:0 >= 1 ? a:1 : 0 + let nosuf = a:0 >= 2 ? a:2 : 0 + return tlib#file#FilterFiles(split(glob(a:pattern, nosuf), '\n'), {'all': all}) endf " :nodoc: - function! tlib#file#Globpath(path, pattern) abort "{{{3 - return split(globpath(a:path, a:pattern), '\n') + function! tlib#file#Globpath(path, pattern, ...) abort "{{{3 + let all = a:0 >= 1 ? a:1 : 0 + let nosuf = a:0 >= 2 ? a:2 : 0 + return tlib#file#FilterFiles(split(globpath(a:path, a:pattern), '\n'), {'all': all}) endf endif + +let s:filereadable = {} + +augroup TLib + autocmd BufWritePost,FileWritePost,FocusLost * let s:filereadable = {} +augroup end + +function! tlib#file#Filereadable(filename) abort "{{{3 + if !has_key(s:filereadable, a:filename) + let s:filereadable[a:filename] = filereadable(a:filename) + endif + return s:filereadable[a:filename] +endf + diff --git a/sources_non_forked/tlib/autoload/tlib/input.vim b/sources_non_forked/tlib/autoload/tlib/input.vim index e8f892b0..e294e2ac 100644 --- a/sources_non_forked/tlib/autoload/tlib/input.vim +++ b/sources_non_forked/tlib/autoload/tlib/input.vim @@ -1,8 +1,7 @@ " @Author: Tom Link (micathom AT gmail com?subject=[vim]) " @Website: http://www.vim.org/account/profile.php?user_id=4037 " @License: GPL (see http://www.gnu.org/licenses/gpl.txt) -" @Revision: 1366 - +" @Revision: 1430 " :filedoc: " Input-related, select from a list etc. @@ -312,7 +311,7 @@ function! tlib#input#List(type, ...) "{{{3 if !empty(filter) " let world.initial_filter = [[''], [filter]] " let world.initial_filter = [[filter]] - " TLogVAR world.initial_filter + Tlibtrace 'tlib', world.initial_filter, filter call world.SetInitialFilter(filter) endif endif @@ -333,10 +332,11 @@ endf " (an instance of tlib#World as returned by |tlib#World#New|). function! tlib#input#ListW(world, ...) "{{{3 TVarArg 'cmd' - " let time0 = str2float(reltimestr(reltime())) " DBG - " TLogVAR time0 + let time0 = str2float(reltimestr(reltime())) + Tlibtrace 'tlib', time0 let world = a:world if world.pick_last_item >= 1 && stridx(world.type, 'e') == -1 && len(world.base) <= 1 + call world.CloseScratch(1) let rv = get(world.base, 0, world.rv) if stridx(world.type, 'm') != -1 return [rv] @@ -345,7 +345,7 @@ function! tlib#input#ListW(world, ...) "{{{3 endif endif call s:Init(world, cmd) - " TLogVAR world.state, world.sticky, world.initial_index + Tlibtrace 'tlib', world.state, world.sticky, world.initial_index " let statusline = &l:statusline " let laststatus = &laststatus let showmode = &showmode @@ -361,38 +361,24 @@ function! tlib#input#ListW(world, ...) "{{{3 try while !empty(world.state) && world.state !~ '^exit' && (world.show_empty || !empty(world.base)) let post_keys = '' - " TLogDBG 'while' - " TLogVAR world.state - " let time01 = str2float(reltimestr(reltime())) " DBG - " TLogVAR time01, time01 - time0 + Tlibtrace 'tlib', 'while', world.state + let time01 = str2float(reltimestr(reltime())) + Tlibtrace 'tlib', time01, time01 - time0 try let world = s:RunStateHandlers(world) - " if exists('b:tlib_world_event') - " let event = b:tlib_world_event - " unlet! b:tlib_world_event - " if event == 'WinLeave' - " " let world.resume_state = world.state - " let world = tlib#agent#Suspend(world, world.rv) - " break - " endif - " endif - - " let time02 = str2float(reltimestr(reltime())) " DBG - " TLogVAR time02, time02 - time0 + let time02 = str2float(reltimestr(reltime())) + Tlibtrace 'tlib', time02, time02 - time0 if world.state =~ '\' - " TLogDBG 'reset' - " call world.Reset(world.state =~ '\') call world.Reset() continue endif call s:SetOffset(world) - " let time02 = str2float(reltimestr(reltime())) " DBG - " TLogVAR time02, time02 - time0 - " TLogDBG 1 - " TLogVAR world.state + let time02 = str2float(reltimestr(reltime())) + Tlibtrace 'tlib', time02, time02 - time0 + Tlibtrace 'tlib', world.state if world.state == 'scroll' let world.prefidx = world.offset let world.state = 'redisplay' @@ -402,33 +388,26 @@ function! tlib#input#ListW(world, ...) "{{{3 let world.sticky = 1 endif - " TLogVAR world.filter - " TLogVAR world.sticky + Tlibtrace 'tlib', world.filter + Tlibtrace 'tlib', world.sticky if world.state =~ '\' - " TLogVAR world.rv + Tlibtrace 'tlib', world.rv throw 'picked' elseif world.state =~ '\' let world.rv = world.CurrentItem() - " TLogVAR world.rv + Tlibtrace 'tlib', world.rv throw 'picked' elseif world.state =~ 'display' if world.state =~ '^display' - " let time03 = str2float(reltimestr(reltime())) " DBG - " TLogVAR time03, time03 - time0 + let time03 = str2float(reltimestr(reltime())) + Tlibtrace 'tlib', time03, time03 - time0 if world.IsValidFilter() - - " let time1 = str2float(reltimestr(reltime())) " DBG - " TLogVAR time1, time1 - time0 + let time1 = str2float(reltimestr(reltime())) + Tlibtrace 'tlib', time1, time1 - time0 call world.BuildTableList() - " let time2 = str2float(reltimestr(reltime())) " DBG - " TLogVAR time2, time2 - time0 - " TLogDBG 2 - " TLogDBG len(world.table) - " TLogVAR world.table - " let world.list = map(copy(world.table), 'world.GetBaseItem(v:val)') - " TLogDBG 3 + let time2 = str2float(reltimestr(reltime())) + Tlibtrace 'tlib', time2, time2 - time0 let world.llen = len(world.list) - " TLogVAR world.index_table if empty(world.index_table) let dindex = range(1, world.llen) let world.index_width = len(world.llen) @@ -436,12 +415,11 @@ function! tlib#input#ListW(world, ...) "{{{3 let dindex = world.index_table let world.index_width = len(max(dindex)) endif - " let time3 = str2float(reltimestr(reltime())) " DBG - " TLogVAR time3, time3 - time0 + let time3 = str2float(reltimestr(reltime())) + Tlibtrace 'tlib', time3, time3 - time0 if world.llen == 0 && !world.show_empty call world.ReduceFilter() let world.offset = 1 - " TLogDBG 'ReduceFilter' continue else if world.llen == 1 @@ -449,18 +427,15 @@ function! tlib#input#ListW(world, ...) "{{{3 if world.pick_last_item >= 2 " echom 'Pick last item: '. world.list[0] let world.prefidx = '1' - " TLogDBG 'pick last item' throw 'pick' endif else let world.last_item = '' endif endif - " let time4 = str2float(reltimestr(reltime())) " DBG - " TLogVAR time4, time4 - time0 - " TLogDBG 4 - " TLogVAR world.idx, world.llen, world.state - " TLogDBG world.FilterIsEmpty() + let time4 = str2float(reltimestr(reltime())) + Tlibtrace 'tlib', time4, time4 - time0 + Tlibtrace 'tlib', world.idx, world.llen, world.state if world.state == 'display' if world.idx == '' && world.llen < g:tlib#input#sortprefs_threshold && !world.FilterIsEmpty() call world.SetPrefIdx() @@ -473,27 +448,22 @@ function! tlib#input#ListW(world, ...) "{{{3 let world.prefidx = 1 endif endif - " let time5 = str2float(reltimestr(reltime())) " DBG - " TLogVAR time5, time5 - time0 - " TLogVAR world.initial_index, world.prefidx - " TLogDBG 5 - " TLogDBG len(world.list) - " TLogVAR world.list + let time5 = str2float(reltimestr(reltime())) + Tlibtrace 'tlib', time5, time5 - time0 + Tlibtrace 'tlib', world.initial_index, world.prefidx + Tlibtrace 'tlib', len(world.list) let dlist = world.DisplayFormat(world.list) - " TLogVAR world.prefidx - " TLogDBG 6 - " let time6 = str2float(reltimestr(reltime())) " DBG - " TLogVAR time6, time6 - time0 + Tlibtrace 'tlib', world.prefidx + let time6 = str2float(reltimestr(reltime())) + Tlibtrace 'tlib', time6, time6 - time0 if world.offset_horizontal > 0 - call map(dlist, 'v:val[world.offset_horizontal:-1]') + call map(dlist, 'tlib#string#Strcharpart(v:val, world.offset_horizontal)') endif - " let time7 = str2float(reltimestr(reltime())) " DBG - " TLogVAR time7, time7 - time0 - " TLogVAR dindex + let time7 = str2float(reltimestr(reltime())) + Tlibtrace 'tlib', time7, time7 - time0 let dlist = map(range(0, world.llen - 1), 'printf("%0'. world.index_width .'d", dindex[v:val]) .": ". dlist[v:val]') - " TLogVAR dlist - " let time8 = str2float(reltimestr(reltime())) " DBG - " TLogVAR time8, time8 - time0 + let time8 = str2float(reltimestr(reltime())) + Tlibtrace 'tlib', time8, time8 - time0 else @@ -505,30 +475,14 @@ function! tlib#input#ListW(world, ...) "{{{3 let world.prefidx = 1 endif endif - " TLogVAR world.idx, world.prefidx + Tlibtrace 'tlib', world.idx, world.prefidx - " TLogDBG 7 - " TLogVAR world.prefidx, world.offset - " TLogDBG (world.prefidx > world.offset + winheight(0) - 1) - " if world.prefidx > world.offset + winheight(0) - 1 - " let listtop = world.llen - winheight(0) + 1 - " let listoff = world.prefidx - winheight(0) + 1 - " let world.offset = min([listtop, listoff]) - " TLogVAR world.prefidx - " TLogDBG len(list) - " TLogDBG winheight(0) - " TLogVAR listtop, listoff, world.offset - " elseif world.prefidx < world.offset - " let world.offset = world.prefidx - " endif - " TLogDBG 8 - " TLogVAR world.initial_display, !tlib#char#IsAvailable() + Tlibtrace 'tlib', world.prefidx, world.offset + Tlibtrace 'tlib', world.initial_display, !tlib#char#IsAvailable() if world.state =~ '\' || world.initial_display || !tlib#char#IsAvailable() - " TLogDBG len(dlist) call world.DisplayList(world.Query(), dlist) call world.FollowCursor() let world.initial_display = 0 - " TLogDBG 9 endif if world.state =~ '\' let world.state = 'suspend' @@ -548,9 +502,10 @@ function! tlib#input#ListW(world, ...) "{{{3 endif endif " TAssert IsNotEmpty(world.scratch) + let world.list_wid = tlib#win#GetID() let world.list_wnr = winnr() - " TLogVAR world.state, world.next_state + Tlibtrace 'tlib', world.state, world.next_state if !empty(world.next_state) let world.state = world.next_state let world.next_state = '' @@ -568,7 +523,7 @@ function! tlib#input#ListW(world, ...) "{{{3 endif if has('gui_win32') let exec_cmd = input(query, '') - " TLogVAR exec_cmd + Tlibtrace 'tlib', exec_cmd if exec_cmd == '' let world.state = 'redisplay' else @@ -576,17 +531,15 @@ function! tlib#input#ListW(world, ...) "{{{3 endif elseif has('gui_gtk') || has('gui_gtk2') let c = s:GetModdedChar(world) - " TLogVAR c + Tlibtrace 'tlib', c endif else - " TLogVAR world.timeout + Tlibtrace 'tlib', world.timeout let c = s:GetModdedChar(world) - " TLogVAR c, has_key(world.key_map[world.key_mode],c) + Tlibtrace 'tlib', c, has_key(world.key_map[world.key_mode],c) endif - " TLogVAR c - " TLogDBG string(sort(keys(world.key_map[world.key_mode]))) - - " TLogVAR world.next_agent, world.next_eval + Tlibtrace 'tlib', c + Tlibtrace 'tlib', world.next_agent, world.next_eval if !empty(world.next_agent) let nagent = world.next_agent let world.next_agent = '' @@ -604,19 +557,17 @@ function! tlib#input#ListW(world, ...) "{{{3 elseif has_key(world.key_map[world.key_mode], c) let sr = @/ silent! let @/ = lastsearch - " TLogVAR c, world.key_map[world.key_mode][c] + Tlibtrace 'tlib', c, world.key_map[world.key_mode][c] " TLog "Agent: ". string(world.key_map[world.key_mode][c]) let handler = world.key_map[world.key_mode][c] - " " TLogVAR handler - " let world = call(handler.agent, [world, world.GetSelectedItems(world.CurrentItem())]) - " call s:CheckAgentReturnValue(c, world) + Tlibtrace 'tlib', handler let world = s:CallAgent(handler, world, world.GetSelectedItems(world.CurrentItem())) silent! let @/ = sr " continue elseif c == 13 throw 'pick' elseif c == 27 - " TLogVAR c, world.key_mode + Tlibtrace 'tlib', c, world.key_mode if world.key_mode != 'default' let world.key_mode = 'default' let world.state = 'redisplay' @@ -666,7 +617,7 @@ function! tlib#input#ListW(world, ...) "{{{3 let world.state = 'exit empty' endif endif - " TLogVAR world.prefidx, world.state + Tlibtrace 'tlib', world.prefidx, world.state elseif has_key(world.key_map[world.key_mode], 'unknown_key') let agent = world.key_map[world.key_mode].unknown_key.agent " let world = call(agent, [world, c]) @@ -675,17 +626,17 @@ function! tlib#input#ListW(world, ...) "{{{3 elseif c >= 32 let world.state = 'display' let numbase = get(world.numeric_chars, c, -99999) - " TLogVAR numbase, world.numeric_chars, c + Tlibtrace 'tlib', numbase, world.numeric_chars, c if numbase != -99999 let world.idx .= (c - numbase) if len(world.idx) == world.index_width let world.prefidx = world.idx - " TLogVAR world.prefidx + Tlibtrace 'tlib', world.prefidx throw 'pick' endif else let world.idx = '' - " TLogVAR world.filter + Tlibtrace 'tlib', world.filter if world.llen > g:tlib#input#livesearch_threshold let pattern = input('Filter: ', world.CleanFilter(world.filter[0][0]) . nr2char(c)) if empty(pattern) @@ -718,61 +669,50 @@ function! tlib#input#ListW(world, ...) "{{{3 call world.ClearAllMarks() call world.MarkCurrent(world.prefidx) let world.state = '' - " TLogDBG 'Pick item #'. world.prefidx finally - " TLogDBG 'finally 1', world.state if world.state =~ '\' " if !world.allow_suspend " echom "Cannot be suspended" " let world.state = 'redisplay' " endif elseif !empty(world.list) && !empty(world.base) - " TLogVAR world.list if empty(world.state) let world.rv = world.CurrentItem() - " TLogVAR world.state, world.rv + Tlibtrace 'tlib', world.state, world.rv endif - " TLogVAR "postprocess" for handler in world.post_handlers let state = get(handler, 'postprocess', '') - " TLogVAR handler - " TLogVAR state - " TLogVAR world.state + Tlibtrace 'tlib', handler + Tlibtrace 'tlib', state + Tlibtrace 'tlib', world.state if state == world.state let agent = handler.agent let [world, world.rv] = call(agent, [world, world.rv]) - " TLogVAR world.state, world.rv + Tlibtrace 'tlib', world.state, world.rv call s:CheckAgentReturnValue(agent, world) endif endfor endif - " TLogDBG 'state0='. world.state endtry - " TLogDBG 'state1='. world.state endwh - " TLogVAR world.state - " TLogDBG string(tlib#win#List()) - " TLogDBG 'exit while loop' - " TLogVAR world.list - " TLogVAR world.sel_idx - " TLogVAR world.idx - " TLogVAR world.prefidx - " TLogVAR world.rv - " TLogVAR world.type, world.state, world.return_agent, world.index_table, world.rv + Tlibtrace 'tlib', world.state + Tlibtrace 'tlib', len(world.list) + Tlibtrace 'tlib', world.sel_idx + Tlibtrace 'tlib', world.idx + Tlibtrace 'tlib', world.prefidx + Tlibtrace 'tlib', world.rv if world.state =~ '\<\(empty\|escape\)\>' let world.sticky = 0 endif if world.state =~ '\' - " TLogDBG 'return suspended' - " TLogVAR world.prefidx + Tlibtrace 'tlib', world.prefidx " exec world.prefidx return elseif world.state =~ '\' " TLog "empty" - " TLogDBG 'return empty' - " TLogVAR world.type + Tlibtrace 'tlib', world.type if stridx(world.type, 'm') != -1 return [] elseif stridx(world.type, 'i') != -1 @@ -781,23 +721,18 @@ function! tlib#input#ListW(world, ...) "{{{3 return '' endif elseif !empty(world.return_agent) - " TLogDBG 'return agent' - " TLogVAR world.return_agent - call world.CloseScratch() - " TLogDBG "return_agent ". string(tlib#win#List()) + Tlibtrace 'tlib', world.return_agent + call world.CloseScratch(1) " TAssert IsNotEmpty(world.scratch) return call(world.return_agent, [world, world.GetSelectedItems(world.rv)]) elseif stridx(world.type, 'w') != -1 " TLog "return_world" - " TLogDBG 'return world' return world elseif stridx(world.type, 'm') != -1 " TLog "return_multi" - " TLogDBG 'return multi' return world.GetSelectedItems(world.rv) elseif stridx(world.type, 'i') != -1 " TLog "return_index" - " TLogDBG 'return index' if empty(world.index_table) return world.rv else @@ -805,14 +740,13 @@ function! tlib#input#ListW(world, ...) "{{{3 endif else " TLog "return_else" - " TLogDBG 'return normal' return world.rv endif finally call world.Leave() - " TLogVAR statusline + " Tlibtrace 'tlib', statusline " let &l:statusline = statusline " let &laststatus = laststatus if &showmode != showmode @@ -824,42 +758,39 @@ function! tlib#input#ListW(world, ...) "{{{3 silent! aunmenu ]TLibInputListPopupMenu endif - " TLogDBG 'finally 2' - " TLogDBG string(world.Methods()) - " TLogVAR world.state - " TLogDBG string(tlib#win#List()) + Tlibtrace 'tlib', world.state if world.state !~ '\' " redraw - " TLogVAR world.sticky, bufnr("%") + Tlibtrace 'tlib', world.sticky, bufnr("%") if world.sticky - " TLogDBG "sticky" - " TLogVAR world.bufnr - " TLogDBG bufwinnr(world.bufnr) + Tlibtrace 'tlib', world.bufnr if world.scratch_split > 0 if bufwinnr(world.bufnr) == -1 - " TLogDBG "UseScratch" call world.UseScratch() endif let world = tlib#agent#SuspendToParentWindow(world, world.GetSelectedItems(world.rv)) endif else - " TLogDBG "non sticky" - " TLogVAR world.state, world.win_wnr, world.bufnr - if world.CloseScratch() - " TLogVAR world.winview + Tlibtrace 'tlib', world.state, world.win_id, world.bufnr + if world.CloseScratch(1) + Tlibtrace 'tlib', get(world,'winview','') call tlib#win#SetLayout(world.winview) endif endif endif + if world.state !~ '\' + call world.RestoreWindow() + endif " for i in range(0,5) " call getchar(0) " endfor echo redraw! if !empty(post_keys) - " TLogVAR post_keys + Tlibtrace 'tlib', post_keys call feedkeys(post_keys) endif + let world.state = '' endtry endf @@ -871,7 +802,7 @@ function! s:CallAgent(handler, world, list) abort "{{{3 let args += a:handler.args endif let world = call(agent, args) - " TLogVAR world.state, world.rv + Tlibtrace 'tlib', world.state, world.rv call s:CheckAgentReturnValue(agent, world) return world endf @@ -887,7 +818,7 @@ endf function! s:Init(world, cmd) "{{{3 - " TLogVAR a:cmd + Tlibtrace 'tlib', a:cmd let a:world.initial_display = 1 if a:cmd =~ '\' let a:world.sticky = 1 @@ -905,7 +836,7 @@ function! s:Init(world, cmd) "{{{3 " let a:world.state = a:world.resume_state " endif elseif !a:world.initialized - " TLogVAR a:world.initialized, a:world.win_wnr, a:world.bufnr + Tlibtrace 'tlib', a:world.initialized, a:world.win_id, a:world.bufnr let a:world.filetype = &filetype let a:world.fileencoding = &fileencoding call a:world.SetMatchMode(tlib#var#Get('tlib#input#filter_mode', 'wb')) @@ -913,9 +844,9 @@ function! s:Init(world, cmd) "{{{3 if !has_key(a:world, 'key_mode') let a:world.key_mode = 'default' endif - " TLogVAR has_key(a:world,'key_map') + Tlibtrace 'tlib', has_key(a:world,'key_map') if has_key(a:world, 'key_map') - " TLogVAR has_key(a:world.key_map,a:world.key_mode) + Tlibtrace 'tlib', has_key(a:world.key_map,a:world.key_mode) if has_key(a:world.key_map, a:world.key_mode) let a:world.key_map[a:world.key_mode] = extend( \ a:world.key_map[a:world.key_mode], @@ -929,14 +860,14 @@ function! s:Init(world, cmd) "{{{3 \ a:world.key_mode : copy(g:tlib#input#keyagents_InputList_s) \ } endif - " TLogVAR a:world.type + Tlibtrace 'tlib', a:world.type if stridx(a:world.type, 'm') != -1 call extend(a:world.key_map[a:world.key_mode], g:tlib#input#keyagents_InputList_m, 'force') endif for key_mode in keys(a:world.key_map) let a:world.key_map[key_mode] = map(a:world.key_map[key_mode], 'type(v:val) == 4 ? v:val : {"agent": v:val}') endfor - " TLogVAR a:world.key_mode + Tlibtrace 'tlib', a:world.key_mode if type(a:world.key_handlers) == 3 call s:ExtendKeyMap(a:world, a:world.key_mode, a:world.key_handlers) elseif type(a:world.key_handlers) == 4 @@ -946,12 +877,12 @@ function! s:Init(world, cmd) "{{{3 else throw "tlib#input#ListW: key_handlers must be either a list or a dictionary" endif - " TLogVAR a:world.type, a:world.key_map + Tlibtrace 'tlib', a:world.type, a:world.key_map if !empty(a:cmd) let a:world.state .= ' '. a:cmd endif endif - " TLogVAR a:world.state, a:world.sticky + Tlibtrace 'tlib', a:world.state, a:world.sticky endf @@ -979,7 +910,7 @@ function! s:PopupmenuExists() let rv = 0 endtry endif - " TLogVAR rv + Tlibtrace 'tlib', rv return rv endf @@ -1144,9 +1075,9 @@ function! tlib#input#EditList(query, list, ...) "{{{3 let handlers = a:0 >= 1 && !empty(a:1) ? a:1 : g:tlib#input#handlers_EditList let default = a:0 >= 2 ? a:2 : [] let timeout = a:0 >= 3 ? a:3 : 0 - " TLogVAR handlers + Tlibtrace 'tlib', handlers let rv = tlib#input#List('me', a:query, copy(a:list), handlers, default, timeout) - " TLogVAR rv + Tlibtrace 'tlib', rv if empty(rv) return a:list else @@ -1157,7 +1088,7 @@ endf function! tlib#input#Resume(name, pick, bufnr) "{{{3 - " TLogVAR a:name, a:pick + Tlibtrace 'tlib', a:name, a:pick echo if bufnr('%') != a:bufnr if g:tlib#debug @@ -1182,10 +1113,8 @@ function! tlib#input#Resume(name, pick, bufnr) "{{{3 else call tlib#autocmdgroup#Init() autocmd! TLib BufEnter - if b:tlib_{a:name}.state =~ '\' + if b:tlib_{a:name}.state !~# 'display\>' let b:tlib_{a:name}.state = 'redisplay' - else - let b:tlib_{a:name}.state .= ' redisplay' endif " call tlib#input#List('resume '. a:name) let cmd = 'resume '. a:name @@ -1245,24 +1174,25 @@ endf " endif " endf " call tlib#input#Edit('foo', b:var, 'FooContinue') -function! tlib#input#Edit(name, value, callback, ...) "{{{3 - " TLogVAR a:value +function! tlib#input#EditW(world, name, value, callback, ...) "{{{3 + Tlibtrace 'tlib', a:value TVarArg ['args', []] - let sargs = {'scratch': '__EDIT__'. a:name .'__', 'win_wnr': winnr()} + let sargs = {'scratch': '__EDIT__'. a:name .'__', 'win_id': tlib#win#GetID()} let scr = tlib#scratch#UseScratch(sargs) + let b:tlib_world = a:world " :nodoc: - map c :call EditCallback(0) + map c :call tlib#input#EditCallback(0) " :nodoc: - imap c call EditCallback(0) + imap c call tlib#input#EditCallback(0) " :nodoc: - map :call EditCallback(1) + map :call tlib#input#EditCallback(1) " :nodoc: - imap call EditCallback(1) + imap call tlib#input#EditCallback(1) " :nodoc: - map :call EditCallback(1) + map :call tlib#input#EditCallback(1) " :nodoc: - imap call EditCallback(1) + imap call tlib#input#EditCallback(1) call tlib#normal#WithRegister('gg"tdG', 't') call append(1, split(a:value, "\", 1)) @@ -1285,14 +1215,17 @@ function! tlib#input#Edit(name, value, callback, ...) "{{{3 endif let b:tlib_scratch_edit_args = args let b:tlib_scratch_edit_scratch = sargs - " exec 'autocmd BufDelete,BufHidden,BufUnload call s:EditCallback('. string(a:name) .')' + " exec 'autocmd BufDelete,BufHidden,BufUnload call tlib#input#EditCallback('. string(a:name) .')' " echohl MoreMsg " echom 'Press to enter, c to cancel editing.' " echohl NONE + let world = getbufvar(scr, 'tlib_world', a:world) + let world.state .= ' norestore' + return world endf -function! s:EditCallback(...) "{{{3 +function! tlib#input#EditCallback(...) "{{{3 TVarArg ['ok', -1] " , ['bufnr', -1] " autocmd! BufDelete,BufHidden,BufUnload @@ -1304,10 +1237,11 @@ function! s:EditCallback(...) "{{{3 let cb = b:tlib_scratch_edit_callback let args = b:tlib_scratch_edit_args let sargs = b:tlib_scratch_edit_scratch - " TLogVAR cb, args, sargs + let world = b:tlib_world + Tlibtrace 'tlib', cb, args, sargs + call call(cb, args + [ok, text, world]) call tlib#scratch#CloseScratch(b:tlib_scratch_edit_scratch) - call tlib#win#Set(sargs.win_wnr) - call call(cb, args + [ok, text]) + call tlib#win#SetById(sargs.win_id) endf diff --git a/sources_non_forked/tlib/autoload/tlib/list.vim b/sources_non_forked/tlib/autoload/tlib/list.vim index dbbc702f..e3f681eb 100644 --- a/sources_non_forked/tlib/autoload/tlib/list.vim +++ b/sources_non_forked/tlib/autoload/tlib/list.vim @@ -3,18 +3,18 @@ " @Website: http://www.vim.org/account/profile.php?user_id=4037 " @License: GPL (see http://www.gnu.org/licenses/gpl.txt) " @Created: 2007-06-30. -" @Last Change: 2015-10-21. -" @Revision: 61 +" @Last Change: 2017-03-26. +" @Revision: 71 """ List related functions {{{1 " For the following functions please see ../../test/tlib.vim for examples. -" :def: function! tlib#list#Inject(list, initial_value, funcref) +" :def: function! tlib#list#Inject(list, initial_value, funcref) abort " EXAMPLES: > " echo tlib#list#Inject([1,2,3], 0, function('Add') " => 6 -function! tlib#list#Inject(list, value, Function) "{{{3 +function! tlib#list#Inject(list, value, Function) abort "{{{3 if empty(a:list) return a:value else @@ -29,7 +29,7 @@ endf " EXAMPLES: > " tlib#list#Compact([0,1,2,3,[], {}, ""]) " => [1,2,3] -function! tlib#list#Compact(list) "{{{3 +function! tlib#list#Compact(list) abort "{{{3 return filter(copy(a:list), '!empty(v:val)') endf @@ -37,7 +37,7 @@ endf " EXAMPLES: > " tlib#list#Flatten([0,[1,2,[3,""]]]) " => [0,1,2,3,""] -function! tlib#list#Flatten(list) "{{{3 +function! tlib#list#Flatten(list) abort "{{{3 let acc = [] for e in a:list if type(e) == 3 @@ -51,27 +51,27 @@ function! tlib#list#Flatten(list) "{{{3 endf -" :def: function! tlib#list#FindAll(list, filter, ?process_expr="") +" :def: function! tlib#list#FindAll(list, filter, ?process_expr="") abort " Basically the same as filter() " " EXAMPLES: > " tlib#list#FindAll([1,2,3], 'v:val >= 2') " => [2, 3] -function! tlib#list#FindAll(list, filter, ...) "{{{3 +function! tlib#list#FindAll(list, filter, ...) abort "{{{3 let rv = filter(copy(a:list), a:filter) - if a:0 >= 1 && a:1 != '' + if a:0 >= 1 && !empty(a:1) let rv = map(rv, a:1) endif return rv endf -" :def: function! tlib#list#Find(list, filter, ?default="", ?process_expr="") +" :def: function! tlib#list#Find(list, filter, ?default="", ?process_expr="") abort " " EXAMPLES: > " tlib#list#Find([1,2,3], 'v:val >= 2') " => 2 -function! tlib#list#Find(list, filter, ...) "{{{3 +function! tlib#list#Find(list, filter, ...) abort "{{{3 let default = a:0 >= 1 ? a:1 : '' let expr = a:0 >= 2 ? a:2 : '' return get(tlib#list#FindAll(a:list, a:filter, expr), 0, default) @@ -81,7 +81,7 @@ endf " EXAMPLES: > " tlib#list#Any([1,2,3], 'v:val >= 2') " => 1 -function! tlib#list#Any(list, expr) "{{{3 +function! tlib#list#Any(list, expr) abort "{{{3 return !empty(tlib#list#FindAll(a:list, a:expr)) endf @@ -89,7 +89,7 @@ endf " EXAMPLES: > " tlib#list#All([1,2,3], 'v:val >= 2') " => 0 -function! tlib#list#All(list, expr) "{{{3 +function! tlib#list#All(list, expr) abort "{{{3 return len(tlib#list#FindAll(a:list, a:expr)) == len(a:list) endf @@ -97,7 +97,7 @@ endf " EXAMPLES: > " tlib#list#Remove([1,2,1,2], 2) " => [1,1,2] -function! tlib#list#Remove(list, element) "{{{3 +function! tlib#list#Remove(list, element) abort "{{{3 let idx = index(a:list, a:element) if idx != -1 call remove(a:list, idx) @@ -109,17 +109,17 @@ endf " EXAMPLES: > " tlib#list#RemoveAll([1,2,1,2], 2) " => [1,1] -function! tlib#list#RemoveAll(list, element) "{{{3 +function! tlib#list#RemoveAll(list, element) abort "{{{3 call filter(a:list, 'v:val != a:element') return a:list endf -" :def: function! tlib#list#Zip(lists, ?default='') +" :def: function! tlib#list#Zip(lists, ?default='') abort " EXAMPLES: > " tlib#list#Zip([[1,2,3], [4,5,6]]) " => [[1,4], [2,5], [3,6]] -function! tlib#list#Zip(lists, ...) "{{{3 +function! tlib#list#Zip(lists, ...) abort "{{{3 TVarArg 'default' let lists = copy(a:lists) let max = 0 @@ -133,24 +133,30 @@ function! tlib#list#Zip(lists, ...) "{{{3 return map(range(0, max - 1), 's:GetNthElement(v:val, lists, default)') endf -function! s:GetNthElement(n, lists, default) "{{{3 +function! s:GetNthElement(n, lists, default) abort "{{{3 " TLogVAR a:n, a:lists, a:default return map(copy(a:lists), 'get(v:val, a:n, a:default)') endf -function! tlib#list#Uniq(list, ...) "{{{3 +function! tlib#list#Uniq(list, ...) abort "{{{3 " TLogVAR a:list TVarArg ['get_value', ''], ['remove_empty', 0] if remove_empty call filter(a:list, 'type(v:val) == 0 || !empty(v:val)') endif " CREDITS: Based on syntastic#util#unique(list) by scrooloose + let emptystring = 0 let seen = {} let uniques = [] if empty(get_value) for e in a:list - if !has_key(seen, e) + if empty(e) + if !emptystring + let emptystring = 1 + call add(uniques, e) + endif + elseif !has_key(seen, e) let seen[e] = 1 call add(uniques, e) endif @@ -159,18 +165,23 @@ function! tlib#list#Uniq(list, ...) "{{{3 else for e in a:list let v = eval(printf(get_value, string(e))) - if !has_key(seen, v) + if empty(v) + if !emptystring + let emptystring = 1 + call add(uniques, v) + endif + elseif !has_key(seen, v) let seen[v] = 1 - call add(uniques, e) + call add(uniques, v) endif - unlet e + unlet e v endfor endif return uniques endf -function! tlib#list#ToDictionary(list, default, ...) "{{{3 +function! tlib#list#ToDictionary(list, default, ...) abort "{{{3 TVarArg ['generator', ''] let dict = {} for item in a:list diff --git a/sources_non_forked/tlib/autoload/tlib/notify.vim b/sources_non_forked/tlib/autoload/tlib/notify.vim index 2f45bdb8..d12d1099 100644 --- a/sources_non_forked/tlib/autoload/tlib/notify.vim +++ b/sources_non_forked/tlib/autoload/tlib/notify.vim @@ -3,8 +3,8 @@ " @Website: http://www.vim.org/account/profile.php?user_id=4037 " @License: GPL (see http://www.gnu.org/licenses/gpl.txt) " @Created: 2008-09-19. -" @Last Change: 2015-04-07. -" @Revision: 0.3.19 +" @Last Change: 2017-09-28. +" @Revision: 3.3.19 let s:save_cpo = &cpo set cpo&vim @@ -24,7 +24,7 @@ function! tlib#notify#Echo(text, ...) if !empty(style) exec 'echohl' style endif - echo strpart(text, 0, &columns - 1) + echo tlib#string#Strcharpart(text, 0, &columns - 1) finally if !empty(style) echohl None @@ -93,13 +93,21 @@ function! tlib#notify#TrimMessage(message) "{{{3 let front = to_fill / 2 - 1 let back = front if to_fill % 2 == 0 | let back -= 1 | endif - return strpart(a:message, 0, front) . filler . - \strpart(a:message, strlen(a:message) - back) + return tlib#string#Strcharpart(a:message, 0, front) . filler . + \ tlib#string#Strcharpart(a:message, strlen(a:message) - back) else return a:message endif endfunction +function! tlib#notify#PrintError() abort "{{{3 + echohl ErrorMsg + echom v:exception + echom v:throwpoint + echohl NONE +endf + + let &cpo = s:save_cpo unlet s:save_cpo diff --git a/sources_non_forked/tlib/autoload/tlib/number.vim b/sources_non_forked/tlib/autoload/tlib/number.vim index 94fde02f..54cddc57 100644 --- a/sources_non_forked/tlib/autoload/tlib/number.vim +++ b/sources_non_forked/tlib/autoload/tlib/number.vim @@ -1,22 +1,21 @@ " @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) " @License: GPL (see http://www.gnu.org/licenses/gpl.txt) -" @Revision: 14 +" @Revision: 18 function! tlib#number#ConvertBase(num, base, ...) "{{{3 let rtype = a:0 >= 1 ? a:1 : 'string' + if a:base > 36 + throw 'tlib#number#ConvertBase: base > 36 is not supported' + endif " TLogVAR a:num, a:base, rtype let rv = [] let num = 0.0 + a:num + let chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" while floor(num) > 0.0 let div = floor(num / a:base) let num1 = float2nr(num - a:base * div) - if a:base <= 10 - call insert(rv, num1) - elseif a:base == 16 - let char = "0123456789ABCDEF"[num1] - call insert(rv, char) - endif + call insert(rv, chars[num1]) let num = num / a:base endwh " TLogVAR rv diff --git a/sources_non_forked/tlib/autoload/tlib/persistent.vim b/sources_non_forked/tlib/autoload/tlib/persistent.vim index de3d4878..8e633a6c 100644 --- a/sources_non_forked/tlib/autoload/tlib/persistent.vim +++ b/sources_non_forked/tlib/autoload/tlib/persistent.vim @@ -2,8 +2,8 @@ " @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) " @License: GPL (see http://www.gnu.org/licenses/gpl.txt) " @Created: 2012-05-11. -" @Last Change: 2012-05-11. -" @Revision: 12 +" @Last Change: 2017-03-29. +" @Revision: 15 " The directory for persistent data files. If empty, use " |tlib#dir#MyRuntime|.'/share'. @@ -21,6 +21,13 @@ function! tlib#persistent#Dir() "{{{3 return dir endf +" :display: tlib#persistent#EncodedFilename(type, file, ?mkdir=0, ?dir='') +" Encode `file` and call |tlib#persistent#Filename()|. +function! tlib#persistent#EncodedFilename(type, file, ...) "{{{3 + let file = tlib#url#Encode(a:file) + return call(function('tlib#persistent#Filename'), [a:type, file] + a:000) +endf + " :def: function! tlib#persistent#Filename(type, ?file=%, ?mkdir=0) function! tlib#persistent#Filename(type, ...) "{{{3 " TLogDBG 'bufname='. bufname('.') @@ -41,7 +48,7 @@ function! tlib#persistent#Value(...) "{{{3 return call('tlib#cache#Value', a:000) endf -function! tlib#persistent#Save(cfile, dictionary) "{{{3 - call tlib#cache#Save(a:cfile, a:dictionary) +function! tlib#persistent#Save(...) "{{{3 + call call(function('tlib#cache#Save'), a:000) endf diff --git a/sources_non_forked/tlib/autoload/tlib/progressbar.vim b/sources_non_forked/tlib/autoload/tlib/progressbar.vim index e739eb3c..c7e1f866 100644 --- a/sources_non_forked/tlib/autoload/tlib/progressbar.vim +++ b/sources_non_forked/tlib/autoload/tlib/progressbar.vim @@ -1,8 +1,10 @@ " @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) " @Website: http://www.vim.org/account/profile.php?user_id=4037 " @License: GPL (see http://www.gnu.org/licenses/gpl.txt) -" @Revision: 72 +" @Revision: 86 +let s:id = 0 +let s:ids = [] let s:statusline = [] let s:laststatus = [] let s:max = [] @@ -23,14 +25,48 @@ let s:timestamp = -1 " endtry function! tlib#progressbar#Init(max, ...) "{{{3 TVarArg ['format', '%s'], ['width', 10] + let s:id += 1 + call insert(s:ids, s:id) call insert(s:statusline, &statusline) call insert(s:laststatus, &laststatus) call insert(s:max, a:max) call insert(s:format, format) call insert(s:width, width) call insert(s:value, -1) + let sl = { + \ 'id': s:id, + \ 'statusline': &statusline, + \ 'laststatus': &laststatus, + \ 'max': a:max, + \ 'format': format, + \ 'width': width, + \ 'value': -1 + \ } let &laststatus = 2 let s:timestamp = localtime() + return sl +endf + + +function! tlib#progressbar#Restore(...) "{{{3 + if a:0 >= 1 + let sl = a:1 + let idx = index(s:ids, sl.id) + let &statusline = sl.statusline + let &laststatus = sl.laststatus + else + let idx = 0 + let &statusline = remove(s:statusline, idx) + let &laststatus = remove(s:laststatus, idx) + endif + call remove(s:ids, idx) + call remove(s:max, idx) + call remove(s:format, idx) + call remove(s:width, idx) + call remove(s:value, idx) + redrawstatus + " redraw + " echo endf @@ -48,7 +84,7 @@ function! tlib#progressbar#Display(value, ...) "{{{3 let pbl = repeat('#', val) let pbr = repeat('.', s:width[0] - val) let txt = printf(s:format[0], '['.pbl.pbr.']') . extra - let &l:statusline = txt + let &statusline = txt " TLogDBG txt redrawstatus " redraw @@ -57,16 +93,3 @@ function! tlib#progressbar#Display(value, ...) "{{{3 endf -function! tlib#progressbar#Restore() "{{{3 - let &l:statusline = remove(s:statusline, 0) - let &laststatus = remove(s:laststatus, 0) - redrawstatus - " redraw - " echo - call remove(s:max, 0) - call remove(s:format, 0) - call remove(s:width, 0) - call remove(s:value, 0) -endf - - diff --git a/sources_non_forked/tlib/autoload/tlib/qfl.vim b/sources_non_forked/tlib/autoload/tlib/qfl.vim index 7d4b442d..07eb9416 100644 --- a/sources_non_forked/tlib/autoload/tlib/qfl.vim +++ b/sources_non_forked/tlib/autoload/tlib/qfl.vim @@ -1,8 +1,8 @@ " @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) " @Website: https://github.com/tomtom " @License: GPL (see http://www.gnu.org/licenses/gpl.txt) -" @Last Change: 2015-11-13 -" @Revision: 59 +" @Last Change: 2018-02-08 +" @Revision: 69 " :nodoc: TLet g:tlib#qfl#world = { @@ -29,7 +29,10 @@ TLet g:tlib#qfl#world = { function! tlib#qfl#FormatQFLE(qfe) dict abort "{{{3 let filename = tlib#qfl#QfeFilename(a:qfe) - if get(self, 'qfl_short_filename', '') + let short_filename = get(self, 'qfl_short_filename', '') + if short_filename ==# 'basename' + let filename = matchstr(filename, '[^\\/]\+$') + elseif !empty(short_filename) let filename = pathshorten(filename) endif return printf("%s|%d| %s", filename, a:qfe.lnum, get(a:qfe, "text")) @@ -119,11 +122,11 @@ endf function! tlib#qfl#AgentEditQFE(world, selected, ...) "{{{3 - TVarArg ['cmd_edit', ''], ['cmd_buffer', ''] + TVarArg ['cmd_edit', ''], ['cmd_buffer', ''], ['set_origin', 1] " TVarArg ['cmd_edit', 'edit'], ['cmd_buffer', 'buffer'] " TLogVAR a:selected if empty(a:selected) - call a:world.RestoreOrigin() + " call a:world.RestoreOrigin() " call a:world.ResetSelected() else call a:world.RestoreOrigin() @@ -148,11 +151,13 @@ function! tlib#qfl#AgentEditQFE(world, selected, ...) "{{{3 " TLogDBG bufname('%') " TLogVAR &filetype call tlib#buffer#ViewLine(qfe.lnum) - " call a:world.SetOrigin() " exec back endif endif endfor + if set_origin + call a:world.SetOrigin() + endif endif return a:world endf @@ -161,7 +166,7 @@ endf function! tlib#qfl#AgentPreviewQFE(world, selected) "{{{3 " TLogVAR a:selected let back = a:world.SwitchWindow('win') - call tlib#qfl#AgentEditQFE(a:world, a:selected[0:0]) + call tlib#qfl#AgentEditQFE(a:world, a:selected[0:0], '', '', 0) exec back redraw let a:world.state = 'redisplay' @@ -170,14 +175,12 @@ endf function! tlib#qfl#AgentGotoQFE(world, selected) "{{{3 + let world = a:world if !empty(a:selected) - if a:world.win_wnr != winnr() - let world = tlib#agent#Suspend(a:world, a:selected) - exec a:world.win_wnr .'wincmd w' - endif - call tlib#qfl#AgentEditQFE(a:world, a:selected[0:0]) + let world = tlib#agent#Suspend(world, a:selected) + call tlib#qfl#AgentEditQFE(world, a:selected[0:0]) endif - return a:world + return world endf @@ -201,7 +204,7 @@ function! tlib#qfl#RunCmdOnSelected(world, selected, cmd, ...) "{{{3 " TLogVAR a:cmd for entry in a:selected " TLogVAR entry, a:world.GetBaseItem(entry) - call tlib#qfl#AgentEditQFE(a:world, [entry]) + call tlib#qfl#AgentEditQFE(a:world, [entry], '', '', 0) " TLogDBG bufname('%') exec a:cmd " let item = a:world.data[a:world.GetBaseIdx(entry - 1)] diff --git a/sources_non_forked/tlib/autoload/tlib/rx.vim b/sources_non_forked/tlib/autoload/tlib/rx.vim index 83899838..08e6ae42 100644 --- a/sources_non_forked/tlib/autoload/tlib/rx.vim +++ b/sources_non_forked/tlib/autoload/tlib/rx.vim @@ -1,7 +1,7 @@ " @Author: Tom Link (micathom AT gmail com?subject=[vim]) " @Website: http://www.vim.org/account/profile.php?user_id=4037 " @License: GPL (see http://www.gnu.org/licenses/gpl.txt) -" @Revision: 113 +" @Revision: 114 " :def: function! tlib#rx#Escape(text, ?magic='m') @@ -30,13 +30,7 @@ endf " Escape return |sub-replace-special|. function! tlib#rx#EscapeReplace(text, ...) "{{{3 TVarArg ['magic', 'm'] - if magic ==# 'm' || magic ==# 'v' - return escape(a:text, '\&~') - elseif magic ==# 'M' || magic ==# 'V' - return escape(a:text, '\') - else - echoerr 'magic must be one of: m, v, M, V' - endif + return escape(a:text, '\&~') endf diff --git a/sources_non_forked/tlib/autoload/tlib/selection.vim b/sources_non_forked/tlib/autoload/tlib/selection.vim new file mode 100644 index 00000000..e705f27e --- /dev/null +++ b/sources_non_forked/tlib/autoload/tlib/selection.vim @@ -0,0 +1,40 @@ +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Last Change: 2017-09-28 +" @Revision: 4 + + +" :display: tlib#selection#GetSelection(mode, ?mbeg="'<", ?mend="'>", ?opmode='selection') +" mode can be one of: selection, lines, block +function! tlib#selection#GetSelection(mode, ...) range "{{{3 + if a:0 >= 2 + let mbeg = a:1 + let mend = a:2 + else + let mbeg = "'<" + let mend = "'>" + endif + let opmode = a:0 >= 3 ? a:3 : 'selection' + let l0 = line(mbeg) + let l1 = line(mend) + let text = getline(l0, l1) + let c0 = col(mbeg) + let c1 = col(mend) + " TLogVAR mbeg, mend, opmode, l0, l1, c0, c1 + " TLogVAR text[-1] + " TLogVAR len(text[-1]) + if opmode == 'block' + let clen = c1 - c0 + call map(text, 'tlib#string#Strcharpart(v:val, c0, clen)') + elseif opmode == 'selection' + if c1 > 1 + let text[-1] = tlib#string#Strcharpart(text[-1], 0, c1 - (a:mode == 'o' || c1 > len(text[-1]) ? 0 : 1)) + endif + if c0 > 1 + let text[0] = tlib#string#Strcharpart(text[0], c0 - 1) + endif + endif + return text +endf + diff --git a/sources_non_forked/tlib/autoload/tlib/string.vim b/sources_non_forked/tlib/autoload/tlib/string.vim index e5f8943a..c15420ef 100644 --- a/sources_non_forked/tlib/autoload/tlib/string.vim +++ b/sources_non_forked/tlib/autoload/tlib/string.vim @@ -1,7 +1,7 @@ " @Author: Tom Link (micathom AT gmail com?subject=[vim]) " @Website: http://www.vim.org/account/profile.php?user_id=4037 " @License: GPL (see http://www.gnu.org/licenses/gpl.txt) -" @Revision: 121 +" @Revision: 148 " :def: function! tlib#string#RemoveBackslashes(text, ?chars=' ') @@ -22,11 +22,21 @@ function! tlib#string#Chomp(string, ...) "{{{3 endf -function! tlib#string#Format(template, dict) "{{{3 - let parts = split(a:template, '\ze%\({.\{-}}\|.\)') +" Format a template string. Placeholders have the format "%{NAME}". A +" "%" can be inserted as "%%". +" +" Examples: +" echo tlib#string#Format("foo %{bar} foo", {'bar': 123}, ?prefix='%') +" => foo 123 foo +function! tlib#string#Format(template, dict, ...) "{{{3 + let prefix = a:0 >= 1 ? a:1 : '%' + let pesc = prefix . prefix + let prx = tlib#rx#Escape(prefix) + let parts = split(a:template, '\ze'. prx .'\({.\{-}}\|.\)') + let partrx = '^'. prx .'\({\(.\{-}\)}\|\(.\)\)\(.*\)$' let out = [] for part in parts - let ml = matchlist(part, '^%\({\(.\{-}\)}\|\(.\)\)\(.*\)$') + let ml = matchlist(part, partrx) if empty(ml) let rest = part else @@ -34,8 +44,8 @@ function! tlib#string#Format(template, dict) "{{{3 let rest = ml[4] if has_key(a:dict, var) call add(out, a:dict[var]) - elseif var == '%%' - call add(out, '%') + elseif var ==# pesc + call add(out, prefix) else call add(out, ml[1]) endif @@ -156,3 +166,43 @@ function! tlib#string#SplitCommaList(text, ...) abort "{{{3 return parts endf + +function! tlib#string#Input(...) abort "{{{3 + TVarArg ['text', ''], ['completion', ''] + call inputsave() + let rv = call(function('input'), a:000) + call inputrestore() + return rv +endf + + +" :display: tlib#string#MatchAll(string, sep_regexp, ?item_regexp='') abort +function! tlib#string#MatchAll(string, regexp, ...) abort "{{{3 + let eregexp = a:0 >= 1 ? a:1 : '' + Tlibtrace 'tlib', a:string, a:regexp, eregexp + let ms = [] + if a:regexp =~ '\\ze' + let regexp1 = substitute(a:regexp, '\\ze.*$', '', '') + else + let regexp1 = a:regexp + endif + for m in split(a:string, '\ze'. regexp1) + let m1 = matchstr(m, !empty(eregexp) ? eregexp : a:regexp) + Tlibtrace 'tlib', m, m1 + if !empty(m1) + call add(ms, m1) + endif + endfor + return ms +endf + +if exists('*strcharpart') + function! tlib#string#Strcharpart(...) abort "{{{3 + return call(function('strcharpart'), a:000) + endf +else + function! tlib#string#Strcharpart(...) abort "{{{3 + return call(function('strpart'), a:000) + endf +endif + diff --git a/sources_non_forked/tlib/autoload/tlib/sys.vim b/sources_non_forked/tlib/autoload/tlib/sys.vim index affb86d1..667ecdc2 100644 --- a/sources_non_forked/tlib/autoload/tlib/sys.vim +++ b/sources_non_forked/tlib/autoload/tlib/sys.vim @@ -1,7 +1,7 @@ " @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) " @License: GPL (see http://www.gnu.org/licenses/gpl.txt) -" @Last Change: 2015-11-07. -" @Revision: 51 +" @Last Change: 2017-04-12. +" @Revision: 62 if !exists('g:tlib#sys#special_protocols') @@ -16,14 +16,14 @@ if !exists('g:tlib#sys#special_suffixes') " A list of |regexp|s matching suffixes that should be handled by " |g:tlib#sys#system_browser|. " CAVEAT: Must be a |\V| |regexp|. - let g:tlib#sys#special_suffixes = ['xlsx\?', 'docx\?', 'pptx\?', 'accdb', 'mdb', 'sqlite', 'pdf', 'jpg', 'png', 'gif'] "{{{2 + let g:tlib#sys#special_suffixes = ['xlsx\?', 'docx\?', 'pptx\?', 'accdb', 'mdb', 'sqlite', 'pdf', 'jpg', 'png', 'gif', 'od\[tspg]'] "{{{2 endif if !exists('g:tlib#sys#system_rx') " Open links matching this |regexp| with |g:tlib#sys#system_browser|. " CAVEAT: Must be a |\V| |regexp|. - let g:tlib#sys#system_rx = printf('\V\%(\^\%(%s\):\|.\%(%s\)\)', join(g:tlib#sys#special_protocols, '\|'), join(g:tlib#sys#special_suffixes, '\|')) "{{{2 + let g:tlib#sys#system_rx = printf('\V\%(\^\%(%s\):\|.\%(%s\)\$\)', join(g:tlib#sys#special_protocols, '\|'), join(g:tlib#sys#special_suffixes, '\|')) "{{{2 endif @@ -39,7 +39,7 @@ if !exists("g:tlib#sys#system_browser") let g:tlib#sys#system_browser = "exec 'silent !open' shellescape('%s')" elseif exists('$XDG_CURRENT_DESKTOP') && !empty($XDG_CURRENT_DESKTOP) let g:tlib#sys#system_browser = "exec 'silent !xdg-open' shellescape('%s') '&'" - elseif $GNOME_DESKTOP_SESSION_ID != "" || $DESKTOP_SESSION == 'gnome' + elseif !empty($GNOME_DESKTOP_SESSION_ID) || $DESKTOP_SESSION ==# 'gnome' let g:tlib#sys#system_browser = "exec 'silent !gnome-open' shellescape('%s')" elseif exists("$KDEDIR") && !empty($KDEDIR) let g:tlib#sys#system_browser = "exec 'silent !kfmclient exec' shellescape('%s')" @@ -185,9 +185,7 @@ function! tlib#sys#Open(filename) abort "{{{3 Tlibtrace 'tlib', a:filename if !empty(g:tlib#sys#system_browser) && tlib#sys#IsSpecial(a:filename) try - let cmd = printf(g:tlib#sys#system_browser, escape(a:filename, ' %#!')) - Tlibtrace 'tlib', cmd - exec cmd + call tlib#sys#OpenWithSystemViewer(a:filename) return 1 catch echohl ErrorMsg @@ -199,13 +197,22 @@ function! tlib#sys#Open(filename) abort "{{{3 endf +" Open filename with the default system viewer. +function! tlib#sys#OpenWithSystemViewer(filename) abort "{{{3 + let cmd = printf(g:tlib#sys#system_browser, a:filename) + " let cmd = printf(g:tlib#sys#system_browser, escape(a:filename, ' %#!')) + Tlibtrace 'tlib', cmd + exec cmd +endf + + " :def: function! tlib#sys#SystemInDir(dir, expr, ?input='') function! tlib#sys#SystemInDir(dir, ...) abort "{{{3 call tlib#dir#CD(a:dir) try return call(function('system'), a:000) finally - cd! - + silent cd! - endtry endf diff --git a/sources_non_forked/tlib/autoload/tlib/tag.vim b/sources_non_forked/tlib/autoload/tlib/tag.vim index e4239d37..b82643d1 100644 --- a/sources_non_forked/tlib/autoload/tlib/tag.vim +++ b/sources_non_forked/tlib/autoload/tlib/tag.vim @@ -1,7 +1,7 @@ " @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) " @Website: http://www.vim.org/account/profile.php?user_id=4037 " @License: GPL (see http://www.gnu.org/licenses/gpl.txt) -" @Revision: 59 +" @Revision: 64 " Extra tags for |tlib#tag#Retrieve()| (see there). Can also be buffer-local. @@ -47,7 +47,7 @@ TLet g:tlib_tag_substitute = { " < tags from the JDK will be included. function! tlib#tag#Retrieve(rx, ...) "{{{3 TVarArg ['extra_tags', 0] - " TLogVAR a:rx, extra_tags + Tlibtrace 'tlib', a:rx, extra_tags if extra_tags let tags_orig = &l:tags if empty(tags_orig) @@ -65,7 +65,8 @@ function! tlib#tag#Retrieve(rx, ...) "{{{3 else let taglist = taglist(a:rx) endif - return taglist + Tlibtrace 'tlib', len(taglist) + return copy(taglist) endf @@ -76,7 +77,7 @@ endf " :def: function! tlib#tag#Collect(constraints, ?use_extra=1, ?match_front=1) function! tlib#tag#Collect(constraints, ...) "{{{3 TVarArg ['use_extra', 0], ['match_end', 1], ['match_front', 1] - " TLogVAR a:constraints, use_extra + Tlibtrace 'tlib', a:constraints, use_extra, match_end, match_front let rx = get(a:constraints, 'name', '') if empty(rx) || rx == '*' let rx = '.' @@ -92,9 +93,9 @@ function! tlib#tag#Collect(constraints, ...) "{{{3 endif let rx = join(rxl, '') endif - " TLogVAR rx, use_extra + Tlibtrace 'tlib', rx, use_extra let tags = tlib#tag#Retrieve(rx, use_extra) - " TLogDBG len(tags) + Tlibtrace 'tlib', len(tags) for [field, rx] in items(a:constraints) if !empty(rx) && rx != '*' " TLogVAR field, rx @@ -105,7 +106,7 @@ function! tlib#tag#Collect(constraints, ...) "{{{3 endif endif endfor - " TLogVAR tags + Tlibtrace 'tlib', len(tags) return tags endf diff --git a/sources_non_forked/tlib/autoload/tlib/time.vim b/sources_non_forked/tlib/autoload/tlib/time.vim index 2273d555..130ef5bc 100644 --- a/sources_non_forked/tlib/autoload/tlib/time.vim +++ b/sources_non_forked/tlib/autoload/tlib/time.vim @@ -1,7 +1,7 @@ " @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) " @Website: http://www.vim.org/account/profile.php?user_id=4037 " @License: GPL (see http://www.gnu.org/licenses/gpl.txt) -" @Revision: 36 +" @Revision: 42 function! tlib#time#MSecs() "{{{3 @@ -65,3 +65,20 @@ function! tlib#time#DiffMSecs(a, b, ...) "{{{3 endf +function! tlib#time#Command(cmd, ...) abort "{{{3 + let loops = a:0 >= 1 ? a:1 : 1 + let silent = a:0 >= 1 ? a:1 : 0 + let start = tlib#time#Now() + for loop in range(loops) + if silent + silent! exec a:cmd + else + exec a:cmd + endif + endfor + let end = tlib#time#Now() + let diff = tlib#time#Diff(end, start) + echom 'Time:' diff + return diff +endf + diff --git a/sources_non_forked/tlib/autoload/tlib/trace.vim b/sources_non_forked/tlib/autoload/tlib/trace.vim index 0a98d1e9..25a00a23 100644 --- a/sources_non_forked/tlib/autoload/tlib/trace.vim +++ b/sources_non_forked/tlib/autoload/tlib/trace.vim @@ -1,8 +1,8 @@ " @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) " @Website: https://github.com/tomtom " @License: GPL (see http://www.gnu.org/licenses/gpl.txt) -" @Last Change: 2015-11-23 -" @Revision: 134 +" @Last Change: 2017-03-09 +" @Revision: 205 if !exists('g:tlib#trace#backtrace') @@ -12,19 +12,42 @@ if !exists('g:tlib#trace#backtrace') endif -if !exists('g:tlib#trace#printf') - " The command used for printing traces from |tlib#trace#Print()|. - let g:tlib#trace#printf = 'echom %s' "{{{2 +if !exists('g:tlib#trace#printer') + " Possible values: + " - 'echom' + " - ['file', FILENAME] + let g:tlib#trace#printer = 'echom' "{{{2 endif -let s:trace_hl = {'error': 'ErrorMsg', 'fatal': 'ErrorMsg', 'warning': 'WarningMsg'} +if !exists('g:tlib#trace#hl') + let g:tlib#trace#hl = {'error': 'ErrorMsg', 'fatal': 'ErrorMsg', 'warn': 'WarningMsg'} "{{{2 +endif -" Set |g:tlib#trace#printf| to make |tlib#trace#Print()| print to -" `filename`. -function! tlib#trace#PrintToFile(filename) abort "{{{3 - let g:tlib#trace#printf = 'call writefile([%s], '. string(a:filename) .', "a")' +" Print traces from |tlib#trace#Print()|. +function! tlib#trace#Printer_echom(type, text, args) abort "{{{3 + let hl = get(g:tlib#trace#hl, a:type, '') + try + if !empty(hl) + exec 'echohl' hl + endif + echom a:text + finally + if !empty(hl) + echohl NONE + endif + endtry +endf + + +function! tlib#trace#Printer_file(type, text, args) abort "{{{3 + let filename = get(a:args, 0, '') + if exists(filename) && !filewritable(filename) + throw 'tlib#trace#Printer_file: Cannot write to file: '. filename + else + call writefile([a:text], filename, 'a') + endif endf @@ -34,26 +57,58 @@ endf " Examples: " call tlib#trace#Set(["+foo", "-bar"]) " call tlib#trace#Set("+foo,-bar") -function! tlib#trace#Set(vars) abort "{{{3 +function! tlib#trace#Set(vars, ...) abort "{{{3 + let reset = a:0 >= 1 ? a:1 : 0 + if reset + call tlib#trace#Reset() + endif + if empty(a:vars) + return + endif call tlib#trace#Enable() - if type(a:vars) == 1 + if type(a:vars) == v:t_string let vars = tlib#string#SplitCommaList(a:vars, '[,[:space:]]\+') + let opts = {} + elseif type(a:vars) == v:t_dict + let vars = a:vars.__rest__ + if has_key(a:vars, 'file') + let g:tlib#trace#printer = ['file', a:vars.file] + endif + if has_key(a:vars, 'echo') + let g:tlib#trace#printer = 'echom' + endif else let vars = a:vars + let opts = {} endif + " TLogVAR vars for rx in vars let rx1 = substitute(rx, '^[+-]', '', 'g') - if rx1 !~# '^\%(error\|fatal\)$' && s:trace_rx !~# '[(|]'. tlib#rx#Escape(rx1) .'\\' + if rx1 !~# '^\%(error\|warn\|fatal\)$' + let erx1 = tlib#rx#Escape(rx1) " TLogVAR rx, rx1 - if rx =~ '^+' - let s:trace_rx = substitute(s:trace_rx, '\ze\\)\$', '\\|'. tlib#rx#EscapeReplace(rx1), '') - elseif rx =~ '^-' - let s:trace_rx = substitute(s:trace_rx, '\\|'. tlib#rx#Escape(rx1), '', '') + " echom "DBG" s:trace_rx + if rx =~ '^-' + let erx1 .= '\[0-\d\]\\?' + if s:trace_rx =~# '[(|]'. erx1 .'\\' + let s:trace_rx = substitute(s:trace_rx, '\\|'. erx1, '', '') + endif + " elseif rx =~ '^+' else - echohl WarningMsg - echom 'tlib#trace#Print: Unsupported syntax:' rx - echohl NONE + if erx1 =~ '\d$' + let erx1 = substitute(erx1, '\d$', '[0-\0]\\?', '') + else + let erx1 .= '[0-9]\?' + endif + if s:trace_rx !~# '[(|]'. erx1 .'\\' + let s:trace_rx = substitute(s:trace_rx, '\ze\\)\$', '\\|'. escape(erx1, '\'), '') + endif + " else + " echohl WarningMsg + " echom 'tlib#trace#Print: Unsupported syntax:' rx + " echohl NONE endif + " echom "DBG" s:trace_rx endif endfor echom "SetTrace:" s:trace_rx @@ -71,6 +126,7 @@ endf " Print the values of vars. The first value is a "guard" (see " |:Tlibtrace|). function! tlib#trace#Print(caller, vars, values) abort "{{{3 + " echom "DBG tlib#trace#Print" string(a:vars) string(a:values) let msg = ['TRACE'] let guard = a:values[0] if type(guard) == 0 @@ -88,22 +144,47 @@ function! tlib#trace#Print(caller, vars, values) abort "{{{3 call add(msg, bt .':') endif endif - for i in range(1, len(a:vars) - 1) - let v = substitute(a:vars[i], ',$', '', '') - let r = string(a:values[i]) - call add(msg, v .'='. r .';') - endfor - exec printf(g:tlib#trace#printf, string(join(msg))) + if len(a:vars) == len(a:values) + for i in range(1, len(a:vars) - 1) + let v = substitute(a:vars[i], ',$', '', '') + if type(a:values[i]) == v:t_func + let r = string(a:values[i]) + else + let r = a:values[i] + endif + if v =~# '^\([''"]\).\{-}\1$' + call add(msg, r .';') + else + call add(msg, v .'='. string(r) .';') + endif + unlet r + endfor + else + call add(msg, join(a:values[1:-1])) + endif + if type(g:tlib#trace#printer) == v:t_string + let printer = g:tlib#trace#printer + let args = [] + else + let [printer; args] = g:tlib#trace#printer + endif + call tlib#trace#Printer_{printer}(guard, join(msg), args) endif endf +function! tlib#trace#Reset() abort "{{{3 + let s:trace_rx = '^\%(error\|fatal\|warn\|info\)$' + let g:tlib#trace#printer = 'echom' +endf + + " Enable tracing via |:Tlibtrace|. function! tlib#trace#Enable() abort "{{{3 if !exists('s:trace_rx') - let s:trace_rx = '^\%(error\)$' + call tlib#trace#Reset() " :nodoc: - command! -nargs=+ -bar Tlibtrace call tlib#trace#Print(expand(''), [], []) + command! -nargs=+ -bang Tlibtrace call tlib#trace#Print(expand(''), [], []) endif endf @@ -111,7 +192,7 @@ endf " Disable tracing via |:Tlibtrace|. function! tlib#trace#Disable() abort "{{{3 " :nodoc: - command! -nargs=+ -bang -bar Tlibtrace : + command! -nargs=+ -bang Tlibtrace : unlet! s:trace_rx endf diff --git a/sources_non_forked/tlib/autoload/tlib/type.vim b/sources_non_forked/tlib/autoload/tlib/type.vim index 455343f9..6bac9228 100644 --- a/sources_non_forked/tlib/autoload/tlib/type.vim +++ b/sources_non_forked/tlib/autoload/tlib/type.vim @@ -2,8 +2,30 @@ " @Website: http://www.vim.org/account/profile.php?user_id=4037 " @License: GPL (see http://www.gnu.org/licenses/gpl.txt) " @Created: 2007-09-30. -" @Last Change: 2015-11-23. -" @Revision: 6 +" @Last Change: 2017-02-22. +" @Revision: 57 + + +let g:tlib#type#nil = [] + + +" Enable type assertiona via |:Tlibtype|. +function! tlib#type#Enable() abort "{{{3 + " :nodoc: + command! -nargs=+ Tlibtype call tlib#type#Check(expand(''), [], []) +endf + + +" Disable type assertiona via |:Tlibtype|. +function! tlib#type#Disable() abort "{{{3 + " :nodoc: + command! -nargs=+ Tlibtype : +endf + + +function! tlib#type#IsNil(expr) abort "{{{3 + return tlib#type#Is(a:expr, v:t_none) || a:expr is g:tlib#type#nil +endf function! tlib#type#IsNumber(expr) @@ -32,25 +54,37 @@ endf function! tlib#type#Is(val, type) abort "{{{3 - if type(a:type) == 0 - let type = a:type - elseif a:type =~? '^n\%[umber]' - let type = 0 - elseif a:type =~? '^s\%[tring]' - let type = 1 - elseif a:type =~? '^fu\%[ncref]' - let type = 2 - elseif a:type =~? '^l\%[ist]' - let type = 3 - elseif a:type =~? '^d\%[ictionary]' - let type = 4 - elseif a:type =~? '^fl\%[oat]' - let type = 5 + if has_key(s:schemas, a:type) + return tlib#type#Has(a:val, a:type) else - throw 'tlib#type#Is: Unknown type: ' a:type + if type(a:type) == 0 + let type = a:type + elseif a:type =~? '^b\%[oolean]$' + let type = v:t_bool + elseif a:type =~? '^c\%[hannel]$' + let type = v:t_channel + elseif a:type =~? '^d\%[ictionary]$' + let type = v:t_dict + elseif a:type =~? '^fl\%[oat]$' + let type = v:t_float + elseif a:type =~? '^fu\%[ncref]$' + let type = v:t_func + elseif a:type =~? '^j\%[ob]$' + let type = v:t_job + elseif a:type =~? '^l\%[ist]$' + let type = v:t_list + elseif a:type =~? '^\%(nil\|null\|none\)$' + let type = v:t_none + elseif a:type =~? '^n\%[umber]$' + let type = v:t_number + elseif a:type =~? '^s\%[tring]$' + let type = v:t_string + else + throw 'tlib#type#Is: Unknown type: ' a:type + endif + Tlibtrace 'tlib', a:val, a:type, type, type(a:val), type(a:val) == a:type + return type(a:val) == type endif - " TLogVAR a:val, a:type, type, type(a:val), type(a:val) == a:type - return type(a:val) == type endf @@ -59,13 +93,50 @@ function! tlib#type#Are(vals, type) abort "{{{3 endf -function! tlib#type#Has(val, lst) abort "{{{3 - return tlib#assert#All(map(a:lst, 'has_key(a:val, v:val)')) +let s:schemas = {} + + +function! tlib#type#Define(name, schema) abort "{{{3 + let s:schemas[a:name] = deepcopy(a:schema) endf -function! tlib#type#Have(vals, lst) abort "{{{3 - return tlib#assert#Map(a:vals, 'tlib#type#Has(v:val,'. string(a:lst) .')') +function! tlib#type#Has(val, schema) abort "{{{3 + Tlibtrace 'tlib', type(a:val), type(a:schema) + if !tlib#type#IsDictionary(a:val) + Tlibtrace 'tlib', 'not a dictionary', a:val + return 0 + endif + if tlib#type#IsString(a:schema) + Tlibtrace 'tlib', a:schema + let schema = copy(s:schemas[a:schema]) + else + let schema = copy(a:schema) + endif + if tlib#type#IsDictionary(schema) + return tlib#assert#All(map(schema, 'has_key(a:val, v:key) && tlib#type#Is(a:val[v:key], v:val)')) + else + Tlibtrace 'tlib', keys(a:val), schema + return tlib#assert#All(map(schema, 'has_key(a:val, v:val)')) + endif endf +function! tlib#type#Have(vals, schema) abort "{{{3 + return tlib#assert#Map(a:vals, 'tlib#type#Has(v:val,'. string(a:schema) .')') +endf + + +function! tlib#type#Check(caller, names, vals) abort "{{{3 + Tlibtrace 'tlib', a:names, a:vals, len(a:names) + for i in range(0, len(a:names) - 1, 2) + let val = a:vals[i] + let type = a:vals[i + 1] + Tlibtrace 'tlib', i, val, type + if !tlib#type#Is(val, type) + let name = matchstr(a:names[i], '^''\zs.\{-}\ze'',\?$') + throw 'tlib#type#Check: Type mismatch: '. name .':'. a:vals[i + 1] + endif + endfor +endf + diff --git a/sources_non_forked/tlib/autoload/tlib/var.vim b/sources_non_forked/tlib/autoload/tlib/var.vim index dcd9264b..cf0d2946 100644 --- a/sources_non_forked/tlib/autoload/tlib/var.vim +++ b/sources_non_forked/tlib/autoload/tlib/var.vim @@ -1,7 +1,7 @@ " @Author: Tom Link (micathom AT gmail com?subject=[vim]) " @Website: http://www.vim.org/account/profile.php?user_id=4037 " @License: GPL (see http://www.gnu.org/licenses/gpl.txt) -" @Revision: 30 +" @Revision: 34 " Define a variable called NAME if yet undefined. @@ -52,10 +52,17 @@ endf function! tlib#var#Get(var, namespace, ...) "{{{3 let var_ = substitute(a:var, '#', '_', 'g') for namespace in split(a:namespace, '\zs') - let vname = namespace == 'g' ? a:var : var_ + let vname = namespace ==# 'g' ? a:var : var_ let var = namespace .':'. vname if exists(var) return {var} + elseif namespace ==# 'g' + try + let val = {var} + catch /^Vim\%((\a\+)\)\=:E\(121\|15\)/ + continue + endtry + return val endif endfor return a:0 >= 1 ? a:1 : '' diff --git a/sources_non_forked/tlib/autoload/tlib/vcs.vim b/sources_non_forked/tlib/autoload/tlib/vcs.vim index 15d051fa..e551be22 100644 --- a/sources_non_forked/tlib/autoload/tlib/vcs.vim +++ b/sources_non_forked/tlib/autoload/tlib/vcs.vim @@ -1,8 +1,8 @@ " @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) " @License: GPL (see http://www.gnu.org/licenses/gpl.txt) " @Created: 2012-03-08. -" @Last Change: 2015-11-07. -" @Revision: 190 +" @Last Change: 2017-04-10. +" @Revision: 224 scriptencoding utf-8 @@ -14,21 +14,19 @@ TLet g:tlib#vcs#def = { \ 'dir': '.git', \ 'ls': 'git ls-files --full-name', \ 'ls.postprocess': '*tlib#vcs#GitLsPostprocess', - \ 'diff': 'git diff --no-ext-diff -U0 %s' - \ }, + \ 'diff': 'git diff --no-ext-diff -U0 %s', + \ 'status': 'git status -s', + \ 'status.filterrx': '^\C[ MADRCU!?]\{2}\s'}, \ 'hg': { \ 'dir': '.hg', \ 'diff': 'hg diff -U0 %s', - \ 'ls': 'hg manifest' - \ }, + \ 'ls': 'hg manifest'}, \ 'svn': { \ 'dir': '.svn', - \ 'diff': 'svn diff --diff-cmd diff --extensions -U0 %s', - \ }, + \ 'diff': 'svn diff --diff-cmd diff --extensions -U0 %s'}, \ 'bzr': { \ 'dir': '.bzr', - \ 'diff': 'bzr diff --diff-options=-U0 %s', - \ } + \ 'diff': 'bzr diff --diff-options=-U0 %s'} \ } @@ -36,7 +34,7 @@ TLet g:tlib#vcs#def = { " empty, support for that VCS will be removed. If no key is present, it " is assumed that the VCS "type" is the name of the executable. " :display: g:tlib#vcs#executables {...} -TLet g:tlib#vcs#executables = {} +TLet g:tlib#vcs#executables = {} " If non-empty, use it as a format string to check whether a VCS is @@ -60,36 +58,44 @@ function! tlib#vcs#Executable(type) "{{{3 endf +let s:vcs_cache = {} +autocmd TLib FocusGained * let s:vcs_cache = {} + + function! tlib#vcs#FindVCS(filename) "{{{3 let type = '' let dir = '' - let dirname = fnamemodify(a:filename, isdirectory(a:filename) ? ':p' : ':p:h') - let path = escape(dirname, ';') .';' - " TLogVAR a:filename, dirname, path - Tlibtrace 'tlib', a:filename, path - let depth = -1 - for vcs in keys(g:tlib#vcs#def) - let subdir = g:tlib#vcs#def[vcs].dir - let vcsdir = finddir(subdir, path) - " TLogVAR vcs, subdir, vcsdir - Tlibtrace 'tlib', vcs, subdir, vcsdir - if !empty(vcsdir) - let vcsdir_depth = len(split(fnamemodify(vcsdir, ':p'), '\/')) - if vcsdir_depth > depth - let depth = vcsdir_depth - let type = vcs - let dir = vcsdir - " TLogVAR type, depth + let filename = fnamemodify(a:filename, ':p') + let dirname = isdirectory(filename) ? filename : fnamemodify(filename, ':h') + if !has_key(s:vcs_cache, dirname) + let path = escape(dirname, ';') .';' + " TLogVAR filename, dirname, path + Tlibtrace 'tlib', filename, path + let depth = -1 + for vcs in keys(g:tlib#vcs#def) + let subdir = g:tlib#vcs#def[vcs].dir + let vcsdir = finddir(subdir, path) + " TLogVAR vcs, subdir, vcsdir + Tlibtrace 'tlib', vcs, subdir, vcsdir + if !empty(vcsdir) + let vcsdir_depth = len(split(fnamemodify(vcsdir, ':p'), '\/')) + if vcsdir_depth > depth + let depth = vcsdir_depth + let type = vcs + let dir = vcsdir + " TLogVAR type, depth + endif endif + endfor + Tlibtrace 'tlib', type, dir + " TLogVAR type, dir + if empty(type) + let s:vcs_cache[dirname] = ['', ''] + else + let s:vcs_cache[dirname] = [type, dir] endif - endfor - Tlibtrace 'tlib', type, dir - " TLogVAR type, dir - if empty(type) - return ['', ''] - else - return [type, dir] endif + return s:vcs_cache[dirname] endf @@ -97,7 +103,7 @@ function! s:GetCmd(vcstype, cmd) let vcsdef = get(g:tlib#vcs#def, a:vcstype, {}) if has_key(vcsdef, a:cmd) let cmd = vcsdef[a:cmd] - if cmd =~ '^\*' + if cmd =~# '^\*' let cmd = substitute(cmd, '^\*', '', '') else let bin = get(g:tlib#vcs#executables, a:vcstype, '') @@ -134,7 +140,7 @@ function! tlib#vcs#Ls(...) "{{{3 if !empty(ls) let rootdir = fnamemodify(vcsdir, ':p:h:h') " TLogVAR vcsdir, rootdir - if ls =~ '%s' + if ls =~# '%s' let cmd = printf(ls, shellescape(rootdir)) else let cmd = ls @@ -176,7 +182,7 @@ endf function! tlib#vcs#GitLsPostprocess(filename) abort "{{{3 - if a:filename =~ '^".\{-}"$' + if a:filename =~# '^".\{-}"$' let filename = matchstr(a:filename, '^"\zs.\{-}\ze"$') let filename = substitute(filename, '\%(\\\@= 1 ? a:1 : '%' + let vcs = a:0 >= 2 ? a:2 : tlib#vcs#FindVCS(filename) + if !empty(vcs) + let [vcstype, vcsdir] = vcs + let cstatus = s:GetCmd(vcstype, 'status') + if !empty(cstatus) + let status = exists('*systemlist') ? systemlist(cstatus) : split(system(cstatus), '\n') + let sfilter = s:GetCmd(vcstype, 'status.filterrx') + if !empty(sfilter) + let status = filter(status, 'v:val =~# sfilter') + endif + return status + endif + endif +endf + + +function! tlib#vcs#IsDirty(...) abort "{{{3 + let filename = a:0 >= 1 ? a:1 : '%' + let vcs = a:0 >= 2 ? a:2 : tlib#vcs#FindVCS(filename) + let status = tlib#vcs#Status(filename, vcs) + return empty(status) ? '' : vcs[0] .'!' +endf + + +" function! tlib#vcs#EnableTStatus() abort "{{{3 +" if has('vim_starting') +" autocmd VimEnter * TStatusregister1 --event=FocusGained,BufRead,BufWritePost %s tlib#vcs#IsDirty() +" else +" TStatusregister1 --event=FocusGained,BufRead,BufWritePost %s tlib#vcs#IsDirty() +" endif +" endf + diff --git a/sources_non_forked/tlib/autoload/tlib/win.vim b/sources_non_forked/tlib/autoload/tlib/win.vim index 4963af15..ee2ca00c 100644 --- a/sources_non_forked/tlib/autoload/tlib/win.vim +++ b/sources_non_forked/tlib/autoload/tlib/win.vim @@ -1,7 +1,12 @@ " @Author: Tom Link (micathom AT gmail com?subject=[vim]) " @Website: http://www.vim.org/account/profile.php?user_id=4037 " @License: GPL (see http://www.gnu.org/licenses/gpl.txt) -" @Revision: 55 +" @Revision: 84 + + +if !exists('g:tlib#win#use_winid') + let g:tlib#win#use_winid = exists('*win_gotoid') && exists('*win_getid') "{{{2 +endif " Return vim code to jump back to the original window. @@ -20,6 +25,70 @@ function! tlib#win#Set(winnr) "{{{3 endif return '' endf + + +if g:tlib#win#use_winid + let g:tlib#win#null_id = -1 + function! tlib#win#GetID() abort "{{{3 + return win_getid() + endf + function! tlib#win#GotoID(win_id) abort "{{{3 + call win_gotoid(a:win_id) + endf +else + let s:win_id = 0 + let g:tlib#win#null_id = {} + function! tlib#win#GetID() abort "{{{3 + if !exists('w:tlib_win_id') + let s:win_id += 1 + let w:tlib_win_id = s:win_id + endif + return {'tabpagenr': tabpagenr(), 'bufnr': bufnr('%'), 'winnr': winnr(), 'win_id': w:tlib_win_id} + endf + function! tlib#win#GotoID(win_id) abort "{{{3 + Tlibtrace 'tlib', a:win_id + if tabpagenr() != a:win_id.tabpagenr + exec 'tabnext' a:win_id.tabpagenr + endif + for wnr in range(1, winnr('$')) + let win_id = getwinvar(wnr, 'tlib_win_id', -1) + Tlibtrace 'tlib', wnr, win_id + if win_id == a:win_id.win_id + Tlibtrace 'tlib', wnr + exec wnr 'wincmd w' + return + endif + endfor + " Was the window closed? What should we do now? + if winnr() != a:win_id.winnr + exec a:win_id.winnr 'wincmd w' + endif + if bufnr('%') != a:win_id.bufnr + exec 'hide buffer' a:win_id.bufnr + endif + endf +endif + + +" Return vim code to jump back to the original window. +function! tlib#win#SetById(win_id) "{{{3 + if a:win_id != g:tlib#win#null_id + let win_id = tlib#win#GetID() + call tlib#win#GotoID(a:win_id) + return printf('call tlib#win#GotoID(%s)', win_id) + " " TLogVAR a:winnr + " " TLogDBG winnr() + " " TLogDBG string(tlib#win#List()) + " if winnr() != a:winnr && winbufnr(a:winnr) != -1 + " let rv = winnr().'wincmd w' + " exec a:winnr .'wincmd w' + " " TLogVAR rv + " " TLogDBG string(tlib#win#List()) + " return rv + " endif + endif + return '' +endf " :def: function! tlib#win#GetLayout(?save_view=0) diff --git a/sources_non_forked/tlib/doc/tags b/sources_non_forked/tlib/doc/tags new file mode 100644 index 00000000..26ad4085 --- /dev/null +++ b/sources_non_forked/tlib/doc/tags @@ -0,0 +1,223 @@ +:TBrowseOutput tlib.txt /*:TBrowseOutput* +:TBrowseScriptnames tlib.txt /*:TBrowseScriptnames* +:TLet tlib.txt /*:TLet* +:TScratch tlib.txt /*:TScratch* +:TVarArg tlib.txt /*:TVarArg* +:Tbrowseloc tlib.txt /*:Tbrowseloc* +:Tbrowseqfl tlib.txt /*:Tbrowseqfl* +:Texecloc tlib.txt /*:Texecloc* +:Texecqfl tlib.txt /*:Texecqfl* +:Tlibtrace tlib.txt /*:Tlibtrace* +:Tlibtraceset tlib.txt /*:Tlibtraceset* +autoload/tlib/Filter_cnf.vim tlib.txt /*autoload\/tlib\/Filter_cnf.vim* +autoload/tlib/Filter_cnfd.vim tlib.txt /*autoload\/tlib\/Filter_cnfd.vim* +autoload/tlib/Filter_fuzzy.vim tlib.txt /*autoload\/tlib\/Filter_fuzzy.vim* +autoload/tlib/Filter_glob.vim tlib.txt /*autoload\/tlib\/Filter_glob.vim* +autoload/tlib/Object.vim tlib.txt /*autoload\/tlib\/Object.vim* +autoload/tlib/World.vim tlib.txt /*autoload\/tlib\/World.vim* +autoload/tlib/agent.vim tlib.txt /*autoload\/tlib\/agent.vim* +autoload/tlib/arg.vim tlib.txt /*autoload\/tlib\/arg.vim* +autoload/tlib/assert.vim tlib.txt /*autoload\/tlib\/assert.vim* +autoload/tlib/buffer.vim tlib.txt /*autoload\/tlib\/buffer.vim* +autoload/tlib/cache.vim tlib.txt /*autoload\/tlib\/cache.vim* +autoload/tlib/char.vim tlib.txt /*autoload\/tlib\/char.vim* +autoload/tlib/cmd.vim tlib.txt /*autoload\/tlib\/cmd.vim* +autoload/tlib/comments.vim tlib.txt /*autoload\/tlib\/comments.vim* +autoload/tlib/date.vim tlib.txt /*autoload\/tlib\/date.vim* +autoload/tlib/dir.vim tlib.txt /*autoload\/tlib\/dir.vim* +autoload/tlib/file.vim tlib.txt /*autoload\/tlib\/file.vim* +autoload/tlib/hook.vim tlib.txt /*autoload\/tlib\/hook.vim* +autoload/tlib/input.vim tlib.txt /*autoload\/tlib\/input.vim* +autoload/tlib/list.vim tlib.txt /*autoload\/tlib\/list.vim* +autoload/tlib/map.vim tlib.txt /*autoload\/tlib\/map.vim* +autoload/tlib/normal.vim tlib.txt /*autoload\/tlib\/normal.vim* +autoload/tlib/notify.vim tlib.txt /*autoload\/tlib\/notify.vim* +autoload/tlib/paragraph.vim tlib.txt /*autoload\/tlib\/paragraph.vim* +autoload/tlib/persistent.vim tlib.txt /*autoload\/tlib\/persistent.vim* +autoload/tlib/progressbar.vim tlib.txt /*autoload\/tlib\/progressbar.vim* +autoload/tlib/rx.vim tlib.txt /*autoload\/tlib\/rx.vim* +autoload/tlib/scratch.vim tlib.txt /*autoload\/tlib\/scratch.vim* +autoload/tlib/selection.vim tlib.txt /*autoload\/tlib\/selection.vim* +autoload/tlib/signs.vim tlib.txt /*autoload\/tlib\/signs.vim* +autoload/tlib/string.vim tlib.txt /*autoload\/tlib\/string.vim* +autoload/tlib/sys.vim tlib.txt /*autoload\/tlib\/sys.vim* +autoload/tlib/tab.vim tlib.txt /*autoload\/tlib\/tab.vim* +autoload/tlib/tag.vim tlib.txt /*autoload\/tlib\/tag.vim* +autoload/tlib/textobjects.vim tlib.txt /*autoload\/tlib\/textobjects.vim* +autoload/tlib/trace.vim tlib.txt /*autoload\/tlib\/trace.vim* +autoload/tlib/type.vim tlib.txt /*autoload\/tlib\/type.vim* +autoload/tlib/url.vim tlib.txt /*autoload\/tlib\/url.vim* +autoload/tlib/var.vim tlib.txt /*autoload\/tlib\/var.vim* +autoload/tlib/vcs.vim tlib.txt /*autoload\/tlib\/vcs.vim* +autoload/tlib/vim.vim tlib.txt /*autoload\/tlib\/vim.vim* +autoload/tlib/win.vim tlib.txt /*autoload\/tlib\/win.vim* +g:tlib#Filter_glob#char tlib.txt /*g:tlib#Filter_glob#char* +g:tlib#Filter_glob#seq tlib.txt /*g:tlib#Filter_glob#seq* +g:tlib#cache#dont_purge tlib.txt /*g:tlib#cache#dont_purge* +g:tlib#cache#max_filename tlib.txt /*g:tlib#cache#max_filename* +g:tlib#cache#purge_days tlib.txt /*g:tlib#cache#purge_days* +g:tlib#cache#purge_every_days tlib.txt /*g:tlib#cache#purge_every_days* +g:tlib#cache#run_script tlib.txt /*g:tlib#cache#run_script* +g:tlib#cache#script_encoding tlib.txt /*g:tlib#cache#script_encoding* +g:tlib#cache#verbosity tlib.txt /*g:tlib#cache#verbosity* +g:tlib#dir#sep tlib.txt /*g:tlib#dir#sep* +g:tlib#file#drop tlib.txt /*g:tlib#file#drop* +g:tlib#input#filename_max_width tlib.txt /*g:tlib#input#filename_max_width* +g:tlib#input#filename_padding_r tlib.txt /*g:tlib#input#filename_padding_r* +g:tlib#input#filter_mode tlib.txt /*g:tlib#input#filter_mode* +g:tlib#input#format_filename tlib.txt /*g:tlib#input#format_filename* +g:tlib#input#higroup tlib.txt /*g:tlib#input#higroup* +g:tlib#input#keyagents_InputList_s tlib.txt /*g:tlib#input#keyagents_InputList_s* +g:tlib#input#livesearch_threshold tlib.txt /*g:tlib#input#livesearch_threshold* +g:tlib#input#numeric_chars tlib.txt /*g:tlib#input#numeric_chars* +g:tlib#input#sortprefs_threshold tlib.txt /*g:tlib#input#sortprefs_threshold* +g:tlib#input#use_popup tlib.txt /*g:tlib#input#use_popup* +g:tlib#input#user_shortcuts tlib.txt /*g:tlib#input#user_shortcuts* +g:tlib#scratch#hidden tlib.txt /*g:tlib#scratch#hidden* +g:tlib#sys#check_cygpath tlib.txt /*g:tlib#sys#check_cygpath* +g:tlib#sys#cygwin_expr tlib.txt /*g:tlib#sys#cygwin_expr* +g:tlib#sys#cygwin_path_rx tlib.txt /*g:tlib#sys#cygwin_path_rx* +g:tlib#sys#special_protocols tlib.txt /*g:tlib#sys#special_protocols* +g:tlib#sys#special_suffixes tlib.txt /*g:tlib#sys#special_suffixes* +g:tlib#sys#system_browser tlib.txt /*g:tlib#sys#system_browser* +g:tlib#sys#system_rx tlib.txt /*g:tlib#sys#system_rx* +g:tlib#trace#backtrace tlib.txt /*g:tlib#trace#backtrace* +g:tlib#trace#printer tlib.txt /*g:tlib#trace#printer* +g:tlib#vcs#check tlib.txt /*g:tlib#vcs#check* +g:tlib#vcs#def tlib.txt /*g:tlib#vcs#def* +g:tlib#vcs#executables tlib.txt /*g:tlib#vcs#executables* +g:tlib#vim#simalt_maximize tlib.txt /*g:tlib#vim#simalt_maximize* +g:tlib#vim#simalt_restore tlib.txt /*g:tlib#vim#simalt_restore* +g:tlib#vim#use_vimtweak tlib.txt /*g:tlib#vim#use_vimtweak* +g:tlib#vim#use_wmctrl tlib.txt /*g:tlib#vim#use_wmctrl* +g:tlib_cache tlib.txt /*g:tlib_cache* +g:tlib_inputlist_filename_indicators tlib.txt /*g:tlib_inputlist_filename_indicators* +g:tlib_inputlist_max_cols tlib.txt /*g:tlib_inputlist_max_cols* +g:tlib_inputlist_max_lines tlib.txt /*g:tlib_inputlist_max_lines* +g:tlib_inputlist_pct tlib.txt /*g:tlib_inputlist_pct* +g:tlib_inputlist_shortmessage tlib.txt /*g:tlib_inputlist_shortmessage* +g:tlib_inputlist_width_filename tlib.txt /*g:tlib_inputlist_width_filename* +g:tlib_persistent tlib.txt /*g:tlib_persistent* +g:tlib_pick_last_item tlib.txt /*g:tlib_pick_last_item* +g:tlib_scratch_pos tlib.txt /*g:tlib_scratch_pos* +g:tlib_scroll_lines tlib.txt /*g:tlib_scroll_lines* +g:tlib_tag_substitute tlib.txt /*g:tlib_tag_substitute* +g:tlib_tags_extra tlib.txt /*g:tlib_tags_extra* +g:tlib_viewline_position tlib.txt /*g:tlib_viewline_position* +plugin/02tlib.vim tlib.txt /*plugin\/02tlib.vim* +standard-paragraph tlib.txt /*standard-paragraph* +tlib#Filter_cnf#New() tlib.txt /*tlib#Filter_cnf#New()* +tlib#Filter_cnfd#New() tlib.txt /*tlib#Filter_cnfd#New()* +tlib#Filter_fuzzy#New() tlib.txt /*tlib#Filter_fuzzy#New()* +tlib#Filter_glob#New() tlib.txt /*tlib#Filter_glob#New()* +tlib#Object#New() tlib.txt /*tlib#Object#New()* +tlib#agent#GotoLine() tlib.txt /*tlib#agent#GotoLine()* +tlib#agent#NewItem() tlib.txt /*tlib#agent#NewItem()* +tlib#agent#Suspend() tlib.txt /*tlib#agent#Suspend()* +tlib#agent#SuspendToParentWindow() tlib.txt /*tlib#agent#SuspendToParentWindow()* +tlib#arg#Ex() tlib.txt /*tlib#arg#Ex()* +tlib#arg#Get() tlib.txt /*tlib#arg#Get()* +tlib#arg#GetOpts() tlib.txt /*tlib#arg#GetOpts()* +tlib#arg#Let() tlib.txt /*tlib#arg#Let()* +tlib#assert#Disable() tlib.txt /*tlib#assert#Disable()* +tlib#assert#Enable() tlib.txt /*tlib#assert#Enable()* +tlib#buffer#BufDo() tlib.txt /*tlib#buffer#BufDo()* +tlib#buffer#DeleteRange() tlib.txt /*tlib#buffer#DeleteRange()* +tlib#buffer#Eval() tlib.txt /*tlib#buffer#Eval()* +tlib#buffer#GetList() tlib.txt /*tlib#buffer#GetList()* +tlib#buffer#InsertText() tlib.txt /*tlib#buffer#InsertText()* +tlib#buffer#KeepCursorPosition() tlib.txt /*tlib#buffer#KeepCursorPosition()* +tlib#buffer#ReplaceRange() tlib.txt /*tlib#buffer#ReplaceRange()* +tlib#buffer#ScratchEnd() tlib.txt /*tlib#buffer#ScratchEnd()* +tlib#buffer#ScratchStart() tlib.txt /*tlib#buffer#ScratchStart()* +tlib#buffer#Set() tlib.txt /*tlib#buffer#Set()* +tlib#buffer#ViewLine() tlib.txt /*tlib#buffer#ViewLine()* +tlib#cache#Dir() tlib.txt /*tlib#cache#Dir()* +tlib#cache#EncodedFilename() tlib.txt /*tlib#cache#EncodedFilename()* +tlib#cache#MaybePurge() tlib.txt /*tlib#cache#MaybePurge()* +tlib#cache#Purge() tlib.txt /*tlib#cache#Purge()* +tlib#cache#Value() tlib.txt /*tlib#cache#Value()* +tlib#char#Get() tlib.txt /*tlib#char#Get()* +tlib#cmd#BrowseOutput() tlib.txt /*tlib#cmd#BrowseOutput()* +tlib#cmd#BrowseOutputWithCallback() tlib.txt /*tlib#cmd#BrowseOutputWithCallback()* +tlib#cmd#Time() tlib.txt /*tlib#cmd#Time()* +tlib#cmd#UseVertical() tlib.txt /*tlib#cmd#UseVertical()* +tlib#comments#Comments() tlib.txt /*tlib#comments#Comments()* +tlib#date#SecondsSince1970() tlib.txt /*tlib#date#SecondsSince1970()* +tlib#dir#CanonicName() tlib.txt /*tlib#dir#CanonicName()* +tlib#dir#Ensure() tlib.txt /*tlib#dir#Ensure()* +tlib#dir#MyRuntime() tlib.txt /*tlib#dir#MyRuntime()* +tlib#dir#NativeName() tlib.txt /*tlib#dir#NativeName()* +tlib#dir#PlainName() tlib.txt /*tlib#dir#PlainName()* +tlib#file#Edit() tlib.txt /*tlib#file#Edit()* +tlib#file#Join() tlib.txt /*tlib#file#Join()* +tlib#file#Relative() tlib.txt /*tlib#file#Relative()* +tlib#file#Split() tlib.txt /*tlib#file#Split()* +tlib#hook#Run() tlib.txt /*tlib#hook#Run()* +tlib#input#CommandSelect() tlib.txt /*tlib#input#CommandSelect()* +tlib#input#Edit() tlib.txt /*tlib#input#Edit()* +tlib#input#EditList() tlib.txt /*tlib#input#EditList()* +tlib#input#List() tlib.txt /*tlib#input#List()* +tlib#input#ListD() tlib.txt /*tlib#input#ListD()* +tlib#input#ListW() tlib.txt /*tlib#input#ListW()* +tlib#list#All() tlib.txt /*tlib#list#All()* +tlib#list#Any() tlib.txt /*tlib#list#Any()* +tlib#list#Compact() tlib.txt /*tlib#list#Compact()* +tlib#list#Find() tlib.txt /*tlib#list#Find()* +tlib#list#FindAll() tlib.txt /*tlib#list#FindAll()* +tlib#list#Flatten() tlib.txt /*tlib#list#Flatten()* +tlib#list#Inject() tlib.txt /*tlib#list#Inject()* +tlib#list#Remove() tlib.txt /*tlib#list#Remove()* +tlib#list#RemoveAll() tlib.txt /*tlib#list#RemoveAll()* +tlib#list#Zip() tlib.txt /*tlib#list#Zip()* +tlib#map#PumAccept() tlib.txt /*tlib#map#PumAccept()* +tlib#normal#WithRegister() tlib.txt /*tlib#normal#WithRegister()* +tlib#notify#Echo() tlib.txt /*tlib#notify#Echo()* +tlib#notify#TrimMessage() tlib.txt /*tlib#notify#TrimMessage()* +tlib#paragraph#GetMetric() tlib.txt /*tlib#paragraph#GetMetric()* +tlib#paragraph#Move() tlib.txt /*tlib#paragraph#Move()* +tlib#persistent#Dir() tlib.txt /*tlib#persistent#Dir()* +tlib#persistent#EncodedFilename() tlib.txt /*tlib#persistent#EncodedFilename()* +tlib#progressbar#Init() tlib.txt /*tlib#progressbar#Init()* +tlib#rx#Escape() tlib.txt /*tlib#rx#Escape()* +tlib#rx#EscapeReplace() tlib.txt /*tlib#rx#EscapeReplace()* +tlib#scratch#CloseScratch() tlib.txt /*tlib#scratch#CloseScratch()* +tlib#scratch#UseScratch() tlib.txt /*tlib#scratch#UseScratch()* +tlib#selection#GetSelection() tlib.txt /*tlib#selection#GetSelection()* +tlib#signs#ClearAll() tlib.txt /*tlib#signs#ClearAll()* +tlib#signs#ClearBuffer() tlib.txt /*tlib#signs#ClearBuffer()* +tlib#signs#Mark() tlib.txt /*tlib#signs#Mark()* +tlib#string#Format() tlib.txt /*tlib#string#Format()* +tlib#string#Printf1() tlib.txt /*tlib#string#Printf1()* +tlib#string#RemoveBackslashes() tlib.txt /*tlib#string#RemoveBackslashes()* +tlib#sys#IsSpecial() tlib.txt /*tlib#sys#IsSpecial()* +tlib#sys#MaybeUseCygpath() tlib.txt /*tlib#sys#MaybeUseCygpath()* +tlib#sys#Open() tlib.txt /*tlib#sys#Open()* +tlib#sys#OpenWithSystemViewer() tlib.txt /*tlib#sys#OpenWithSystemViewer()* +tlib#tab#BufMap() tlib.txt /*tlib#tab#BufMap()* +tlib#tab#TabWinNr() tlib.txt /*tlib#tab#TabWinNr()* +tlib#tag#Collect() tlib.txt /*tlib#tag#Collect()* +tlib#tag#Retrieve() tlib.txt /*tlib#tag#Retrieve()* +tlib#trace#Disable() tlib.txt /*tlib#trace#Disable()* +tlib#trace#Enable() tlib.txt /*tlib#trace#Enable()* +tlib#trace#Print() tlib.txt /*tlib#trace#Print()* +tlib#trace#Printer_echom() tlib.txt /*tlib#trace#Printer_echom()* +tlib#trace#Set() tlib.txt /*tlib#trace#Set()* +tlib#type#Disable() tlib.txt /*tlib#type#Disable()* +tlib#type#Enable() tlib.txt /*tlib#type#Enable()* +tlib#url#Decode() tlib.txt /*tlib#url#Decode()* +tlib#url#DecodeChar() tlib.txt /*tlib#url#DecodeChar()* +tlib#url#Encode() tlib.txt /*tlib#url#Encode()* +tlib#url#EncodeChar() tlib.txt /*tlib#url#EncodeChar()* +tlib#var#EGet() tlib.txt /*tlib#var#EGet()* +tlib#var#Get() tlib.txt /*tlib#var#Get()* +tlib#var#Let() tlib.txt /*tlib#var#Let()* +tlib#var#List() tlib.txt /*tlib#var#List()* +tlib#vcs#Diff() tlib.txt /*tlib#vcs#Diff()* +tlib#vcs#Ls() tlib.txt /*tlib#vcs#Ls()* +tlib#vim#Maximize() tlib.txt /*tlib#vim#Maximize()* +tlib#vim#RestoreWindow() tlib.txt /*tlib#vim#RestoreWindow()* +tlib#win#Set() tlib.txt /*tlib#win#Set()* +tlib#win#SetById() tlib.txt /*tlib#win#SetById()* +tlib.txt tlib.txt /*tlib.txt* +v_sp tlib.txt /*v_sp* diff --git a/sources_non_forked/tlib/doc/tlib.txt b/sources_non_forked/tlib/doc/tlib.txt index 379dc549..648181d9 100644 --- a/sources_non_forked/tlib/doc/tlib.txt +++ b/sources_non_forked/tlib/doc/tlib.txt @@ -30,396 +30,189 @@ installed. ======================================================================== Contents~ - :TLet .................................. |:TLet| - :TScratch .............................. |:TScratch| - :TVarArg ............................... |:TVarArg| - :TBrowseOutput ......................... |:TBrowseOutput| - :TBrowseScriptnames .................... |:TBrowseScriptnames| - :Tlibtrace ............................. |:Tlibtrace| - :Tlibtraceset .......................... |:Tlibtraceset| - :Tlibassert ............................ |:Tlibassert| - Add .................................... |Add()| - TestGetArg ............................. |TestGetArg()| - TestGetArg1 ............................ |TestGetArg1()| - TestArgs ............................... |TestArgs()| - TestArgs1 .............................. |TestArgs1()| - TestArgs2 .............................. |TestArgs2()| - TestArgs3 .............................. |TestArgs3()| - g:tlib#debug ........................... |g:tlib#debug| - tlib#notify#Echo ....................... |tlib#notify#Echo()| - tlib#notify#TrimMessage ................ |tlib#notify#TrimMessage()| - g:tlib#trace#backtrace ................. |g:tlib#trace#backtrace| - g:tlib#trace#printf .................... |g:tlib#trace#printf| - tlib#trace#PrintToFile ................. |tlib#trace#PrintToFile()| - tlib#trace#Set ......................... |tlib#trace#Set()| - tlib#trace#Backtrace ................... |tlib#trace#Backtrace()| - tlib#trace#Print ....................... |tlib#trace#Print()| - tlib#trace#Enable ...................... |tlib#trace#Enable()| - tlib#trace#Disable ..................... |tlib#trace#Disable()| - tlib#dictionary#Rev .................... |tlib#dictionary#Rev()| - g:tlib_persistent ...................... |g:tlib_persistent| - tlib#persistent#Dir .................... |tlib#persistent#Dir()| - tlib#persistent#Filename ............... |tlib#persistent#Filename()| - tlib#persistent#Get .................... |tlib#persistent#Get()| - tlib#persistent#MTime .................. |tlib#persistent#MTime()| - tlib#persistent#Value .................. |tlib#persistent#Value()| - tlib#persistent#Save ................... |tlib#persistent#Save()| - g:tlib#vim#simalt_maximize ............. |g:tlib#vim#simalt_maximize| - g:tlib#vim#simalt_restore .............. |g:tlib#vim#simalt_restore| - g:tlib#vim#use_vimtweak ................ |g:tlib#vim#use_vimtweak| - tlib#vim#Maximize ...................... |tlib#vim#Maximize()| - tlib#vim#RestoreWindow ................. |tlib#vim#RestoreWindow()| - g:tlib#vim#use_wmctrl .................. |g:tlib#vim#use_wmctrl| - tlib#vim#CopyFunction .................. |tlib#vim#CopyFunction()| - tlib#progressbar#Init .................. |tlib#progressbar#Init()| - tlib#progressbar#Display ............... |tlib#progressbar#Display()| - tlib#progressbar#Restore ............... |tlib#progressbar#Restore()| - tlib#eval#FormatValue .................. |tlib#eval#FormatValue()| - tlib#eval#Extend ....................... |tlib#eval#Extend()| - tlib#list#Inject ....................... |tlib#list#Inject()| - tlib#list#Compact ...................... |tlib#list#Compact()| - tlib#list#Flatten ...................... |tlib#list#Flatten()| - tlib#list#FindAll ...................... |tlib#list#FindAll()| - tlib#list#Find ......................... |tlib#list#Find()| - tlib#list#Any .......................... |tlib#list#Any()| - tlib#list#All .......................... |tlib#list#All()| - tlib#list#Remove ....................... |tlib#list#Remove()| - tlib#list#RemoveAll .................... |tlib#list#RemoveAll()| - tlib#list#Zip .......................... |tlib#list#Zip()| - tlib#list#Uniq ......................... |tlib#list#Uniq()| - tlib#list#ToDictionary ................. |tlib#list#ToDictionary()| - tlib#cmd#OutputAsList .................. |tlib#cmd#OutputAsList()| - tlib#cmd#BrowseOutput .................. |tlib#cmd#BrowseOutput()| - tlib#cmd#BrowseOutputWithCallback ...... |tlib#cmd#BrowseOutputWithCallback()| - tlib#cmd#DefaultBrowseOutput ........... |tlib#cmd#DefaultBrowseOutput()| - tlib#cmd#ParseScriptname ............... |tlib#cmd#ParseScriptname()| - tlib#cmd#TBrowseScriptnames ............ |tlib#cmd#TBrowseScriptnames()| - tlib#cmd#UseVertical ................... |tlib#cmd#UseVertical()| - tlib#cmd#Time .......................... |tlib#cmd#Time()| - tlib#cmd#Capture ....................... |tlib#cmd#Capture()| - tlib#syntax#Collect .................... |tlib#syntax#Collect()| - tlib#syntax#Names ...................... |tlib#syntax#Names()| - tlib#balloon#Register .................. |tlib#balloon#Register()| - tlib#balloon#Remove .................... |tlib#balloon#Remove()| - tlib#balloon#Expr ...................... |tlib#balloon#Expr()| - tlib#balloon#Expand .................... |tlib#balloon#Expand()| - g:tlib#vcs#def ......................... |g:tlib#vcs#def| - g:tlib#vcs#executables ................. |g:tlib#vcs#executables| - g:tlib#vcs#check ....................... |g:tlib#vcs#check| - tlib#vcs#Executable .................... |tlib#vcs#Executable()| - tlib#vcs#FindVCS ....................... |tlib#vcs#FindVCS()| - tlib#vcs#Ls ............................ |tlib#vcs#Ls()| - tlib#vcs#Diff .......................... |tlib#vcs#Diff()| - tlib#vcs#GitLsPostprocess .............. |tlib#vcs#GitLsPostprocess()| - tlib#char#Get .......................... |tlib#char#Get()| - tlib#char#IsAvailable .................. |tlib#char#IsAvailable()| - tlib#char#GetWithTimeout ............... |tlib#char#GetWithTimeout()| - g:tlib#Filter_glob#seq ................. |g:tlib#Filter_glob#seq| - g:tlib#Filter_glob#char ................ |g:tlib#Filter_glob#char| - tlib#Filter_glob#New ................... |tlib#Filter_glob#New()| - g:tlib_scratch_pos ..................... |g:tlib_scratch_pos| - g:tlib#scratch#hidden .................. |g:tlib#scratch#hidden| - tlib#scratch#UseScratch ................ |tlib#scratch#UseScratch()| - tlib#scratch#CloseScratch .............. |tlib#scratch#CloseScratch()| - tlib#autocmdgroup#Init ................. |tlib#autocmdgroup#Init()| - g:tlib_cache ........................... |g:tlib_cache| - g:tlib#cache#purge_days ................ |g:tlib#cache#purge_days| - g:tlib#cache#purge_every_days .......... |g:tlib#cache#purge_every_days| - g:tlib#cache#script_encoding ........... |g:tlib#cache#script_encoding| - g:tlib#cache#run_script ................ |g:tlib#cache#run_script| - g:tlib#cache#verbosity ................. |g:tlib#cache#verbosity| - g:tlib#cache#dont_purge ................ |g:tlib#cache#dont_purge| - g:tlib#cache#max_filename .............. |g:tlib#cache#max_filename| - tlib#cache#Dir ......................... |tlib#cache#Dir()| - tlib#cache#Filename .................... |tlib#cache#Filename()| - tlib#cache#Save ........................ |tlib#cache#Save()| - tlib#cache#MTime ....................... |tlib#cache#MTime()| - tlib#cache#Get ......................... |tlib#cache#Get()| - tlib#cache#Value ....................... |tlib#cache#Value()| - tlib#cache#MaybePurge .................. |tlib#cache#MaybePurge()| - tlib#cache#Purge ....................... |tlib#cache#Purge()| - tlib#cache#ListFilesInCache ............ |tlib#cache#ListFilesInCache()| - tlib#normal#WithRegister ............... |tlib#normal#WithRegister()| - tlib#time#MSecs ........................ |tlib#time#MSecs()| - tlib#time#Now .......................... |tlib#time#Now()| - tlib#time#FormatNow .................... |tlib#time#FormatNow()| - tlib#time#Diff ......................... |tlib#time#Diff()| - tlib#time#DiffMSecs .................... |tlib#time#DiffMSecs()| - tlib#var#Let ........................... |tlib#var#Let()| - tlib#var#EGet .......................... |tlib#var#EGet()| - tlib#var#Get ........................... |tlib#var#Get()| - tlib#var#List .......................... |tlib#var#List()| - g:tlib_scroll_lines .................... |g:tlib_scroll_lines| - tlib#agent#Exit ........................ |tlib#agent#Exit()| - tlib#agent#CopyItems ................... |tlib#agent#CopyItems()| - tlib#agent#PageUp ...................... |tlib#agent#PageUp()| - tlib#agent#PageDown .................... |tlib#agent#PageDown()| - tlib#agent#Home ........................ |tlib#agent#Home()| - tlib#agent#End ......................... |tlib#agent#End()| - tlib#agent#Up .......................... |tlib#agent#Up()| - tlib#agent#Down ........................ |tlib#agent#Down()| - tlib#agent#UpN ......................... |tlib#agent#UpN()| - tlib#agent#DownN ....................... |tlib#agent#DownN()| - tlib#agent#ShiftLeft ................... |tlib#agent#ShiftLeft()| - tlib#agent#ShiftRight .................. |tlib#agent#ShiftRight()| - tlib#agent#Reset ....................... |tlib#agent#Reset()| - tlib#agent#ToggleRestrictView .......... |tlib#agent#ToggleRestrictView()| - tlib#agent#RestrictView ................ |tlib#agent#RestrictView()| - tlib#agent#UnrestrictView .............. |tlib#agent#UnrestrictView()| - tlib#agent#Input ....................... |tlib#agent#Input()| - tlib#agent#SuspendToParentWindow ....... |tlib#agent#SuspendToParentWindow()| - tlib#agent#Suspend ..................... |tlib#agent#Suspend()| - tlib#agent#Help ........................ |tlib#agent#Help()| - tlib#agent#OR .......................... |tlib#agent#OR()| - tlib#agent#AND ......................... |tlib#agent#AND()| - tlib#agent#ReduceFilter ................ |tlib#agent#ReduceFilter()| - tlib#agent#PopFilter ................... |tlib#agent#PopFilter()| - tlib#agent#Debug ....................... |tlib#agent#Debug()| - tlib#agent#Select ...................... |tlib#agent#Select()| - tlib#agent#SelectUp .................... |tlib#agent#SelectUp()| - tlib#agent#SelectDown .................. |tlib#agent#SelectDown()| - tlib#agent#SelectAll ................... |tlib#agent#SelectAll()| - tlib#agent#ToggleStickyList ............ |tlib#agent#ToggleStickyList()| - tlib#agent#EditItem .................... |tlib#agent#EditItem()| - tlib#agent#NewItem ..................... |tlib#agent#NewItem()| - tlib#agent#DeleteItems ................. |tlib#agent#DeleteItems()| - tlib#agent#Cut ......................... |tlib#agent#Cut()| - tlib#agent#Copy ........................ |tlib#agent#Copy()| - tlib#agent#Paste ....................... |tlib#agent#Paste()| - tlib#agent#EditReturnValue ............. |tlib#agent#EditReturnValue()| - tlib#agent#ViewFile .................... |tlib#agent#ViewFile()| - tlib#agent#EditFile .................... |tlib#agent#EditFile()| - tlib#agent#EditFileInSplit ............. |tlib#agent#EditFileInSplit()| - tlib#agent#EditFileInVSplit ............ |tlib#agent#EditFileInVSplit()| - tlib#agent#EditFileInTab ............... |tlib#agent#EditFileInTab()| - tlib#agent#ToggleScrollbind ............ |tlib#agent#ToggleScrollbind()| - tlib#agent#ShowInfo .................... |tlib#agent#ShowInfo()| - tlib#agent#PreviewLine ................. |tlib#agent#PreviewLine()| - tlib#agent#GotoLine .................... |tlib#agent#GotoLine()| - tlib#agent#DoAtLine .................... |tlib#agent#DoAtLine()| - tlib#agent#Wildcard .................... |tlib#agent#Wildcard()| - tlib#agent#Null ........................ |tlib#agent#Null()| - tlib#agent#ExecAgentByName ............. |tlib#agent#ExecAgentByName()| - tlib#agent#CompleteAgentNames .......... |tlib#agent#CompleteAgentNames()| - tlib#agent#Complete .................... |tlib#agent#Complete()| - tlib#bitwise#Num2Bits .................. |tlib#bitwise#Num2Bits()| - tlib#bitwise#Bits2Num .................. |tlib#bitwise#Bits2Num()| - tlib#bitwise#AND ....................... |tlib#bitwise#AND()| - tlib#bitwise#OR ........................ |tlib#bitwise#OR()| - tlib#bitwise#XOR ....................... |tlib#bitwise#XOR()| - tlib#bitwise#ShiftRight ................ |tlib#bitwise#ShiftRight()| - tlib#bitwise#ShiftLeft ................. |tlib#bitwise#ShiftLeft()| - tlib#bitwise#Add ....................... |tlib#bitwise#Add()| - tlib#bitwise#Sub ....................... |tlib#bitwise#Sub()| - tlib#url#Decode ........................ |tlib#url#Decode()| - tlib#url#DecodeChar .................... |tlib#url#DecodeChar()| - tlib#url#EncodeChar .................... |tlib#url#EncodeChar()| - tlib#url#Encode ........................ |tlib#url#Encode()| - tlib#signs#ClearAll .................... |tlib#signs#ClearAll()| - tlib#signs#ClearBuffer ................. |tlib#signs#ClearBuffer()| - tlib#signs#Mark ........................ |tlib#signs#Mark()| - tlib#rx#Escape ......................... |tlib#rx#Escape()| - tlib#rx#EscapeReplace .................. |tlib#rx#EscapeReplace()| - tlib#rx#Suffixes ....................... |tlib#rx#Suffixes()| - tlib#rx#LooksLikeRegexp ................ |tlib#rx#LooksLikeRegexp()| - g:tlib_tags_extra ...................... |g:tlib_tags_extra| - g:tlib_tag_substitute .................. |g:tlib_tag_substitute| - tlib#tag#Retrieve ...................... |tlib#tag#Retrieve()| - tlib#tag#Collect ....................... |tlib#tag#Collect()| - tlib#tag#Format ........................ |tlib#tag#Format()| - tlib#map#PumAccept ..................... |tlib#map#PumAccept()| - tlib#Filter_cnfd#New ................... |tlib#Filter_cnfd#New()| - g:tlib#input#sortprefs_threshold ....... |g:tlib#input#sortprefs_threshold| - g:tlib#input#livesearch_threshold ...... |g:tlib#input#livesearch_threshold| - g:tlib#input#filter_mode ............... |g:tlib#input#filter_mode| - g:tlib#input#higroup ................... |g:tlib#input#higroup| - g:tlib_pick_last_item .................. |g:tlib_pick_last_item| - g:tlib#input#and ....................... |g:tlib#input#and| - g:tlib#input#or ........................ |g:tlib#input#or| - g:tlib#input#not ....................... |g:tlib#input#not| - g:tlib#input#numeric_chars ............. |g:tlib#input#numeric_chars| - g:tlib#input#keyagents_InputList_s ..... |g:tlib#input#keyagents_InputList_s| - g:tlib#input#keyagents_InputList_m ..... |g:tlib#input#keyagents_InputList_m| - g:tlib#input#handlers_EditList ......... |g:tlib#input#handlers_EditList| - g:tlib#input#user_shortcuts ............ |g:tlib#input#user_shortcuts| - g:tlib#input#use_popup ................. |g:tlib#input#use_popup| - g:tlib#input#format_filename ........... |g:tlib#input#format_filename| - g:tlib#input#filename_padding_r ........ |g:tlib#input#filename_padding_r| - g:tlib#input#filename_max_width ........ |g:tlib#input#filename_max_width| - tlib#input#List ........................ |tlib#input#List()| - tlib#input#ListD ....................... |tlib#input#ListD()| - tlib#input#ListW ....................... |tlib#input#ListW()| - tlib#input#EditList .................... |tlib#input#EditList()| - tlib#input#Resume ...................... |tlib#input#Resume()| - tlib#input#CommandSelect ............... |tlib#input#CommandSelect()| - tlib#input#Edit ........................ |tlib#input#Edit()| - tlib#input#Dialog ...................... |tlib#input#Dialog()| - tlib#number#ConvertBase ................ |tlib#number#ConvertBase()| - g:tlib#file#drop ....................... |g:tlib#file#drop| - g:tlib#file#use_tabs ................... |g:tlib#file#use_tabs| - g:tlib#file#edit_cmds .................. |g:tlib#file#edit_cmds| - g:tlib#file#absolute_filename_rx ....... |g:tlib#file#absolute_filename_rx| - tlib#file#Split ........................ |tlib#file#Split()| - tlib#file#Join ......................... |tlib#file#Join()| - tlib#file#Relative ..................... |tlib#file#Relative()| - tlib#file#Absolute ..................... |tlib#file#Absolute()| - tlib#file#Canonic ...................... |tlib#file#Canonic()| - tlib#file#With ......................... |tlib#file#With()| - tlib#file#Edit ......................... |tlib#file#Edit()| - tlib#file#Glob ......................... |tlib#file#Glob()| - tlib#file#Globpath ..................... |tlib#file#Globpath()| - g:tlib#sys#special_protocols ........... |g:tlib#sys#special_protocols| - g:tlib#sys#special_suffixes ............ |g:tlib#sys#special_suffixes| - g:tlib#sys#system_rx ................... |g:tlib#sys#system_rx| - g:tlib#sys#system_browser .............. |g:tlib#sys#system_browser| - g:tlib#sys#windows ..................... |g:tlib#sys#windows| - g:tlib#sys#null ........................ |g:tlib#sys#null| - tlib#sys#IsCygwinBin ................... |tlib#sys#IsCygwinBin()| - tlib#sys#IsExecutable .................. |tlib#sys#IsExecutable()| - g:tlib#sys#check_cygpath ............... |g:tlib#sys#check_cygpath| - g:tlib#sys#cygwin_path_rx .............. |g:tlib#sys#cygwin_path_rx| - g:tlib#sys#cygwin_expr ................. |g:tlib#sys#cygwin_expr| - tlib#sys#GetCmd ........................ |tlib#sys#GetCmd()| - tlib#sys#MaybeUseCygpath ............... |tlib#sys#MaybeUseCygpath()| - tlib#sys#ConvertPath ................... |tlib#sys#ConvertPath()| - tlib#sys#FileArgs ...................... |tlib#sys#FileArgs()| - tlib#sys#IsSpecial ..................... |tlib#sys#IsSpecial()| - tlib#sys#Open .......................... |tlib#sys#Open()| - tlib#sys#SystemInDir ................... |tlib#sys#SystemInDir()| - tlib#paragraph#GetMetric ............... |tlib#paragraph#GetMetric()| - tlib#paragraph#Move .................... |tlib#paragraph#Move()| - g:tlib_inputlist_pct ................... |g:tlib_inputlist_pct| - g:tlib_inputlist_width_filename ........ |g:tlib_inputlist_width_filename| - g:tlib_inputlist_filename_indicators ... |g:tlib_inputlist_filename_indicators| - g:tlib_inputlist_shortmessage .......... |g:tlib_inputlist_shortmessage| - tlib#World#New ......................... |tlib#World#New()| - prototype.PrintLines - prototype.Suspend - tlib#loclist#Browse .................... |tlib#loclist#Browse()| - tlib#tab#BufMap ........................ |tlib#tab#BufMap()| - tlib#tab#TabWinNr ...................... |tlib#tab#TabWinNr()| - tlib#tab#Set ........................... |tlib#tab#Set()| - tlib#date#IsDate ....................... |tlib#date#IsDate()| - tlib#date#Format ....................... |tlib#date#Format()| - tlib#date#DiffInDays ................... |tlib#date#DiffInDays()| - tlib#date#Parse ........................ |tlib#date#Parse()| - tlib#date#SecondsSince1970 ............. |tlib#date#SecondsSince1970()| - tlib#date#Shift ........................ |tlib#date#Shift()| - tlib#type#IsNumber ..................... |tlib#type#IsNumber()| - tlib#type#IsString ..................... |tlib#type#IsString()| - tlib#type#IsFuncref .................... |tlib#type#IsFuncref()| - tlib#type#IsList ....................... |tlib#type#IsList()| - tlib#type#IsDictionary ................. |tlib#type#IsDictionary()| - tlib#type#Is ........................... |tlib#type#Is()| - tlib#type#Are .......................... |tlib#type#Are()| - tlib#type#Has .......................... |tlib#type#Has()| - tlib#type#Have ......................... |tlib#type#Have()| - tlib#Filter_fuzzy#New .................. |tlib#Filter_fuzzy#New()| - tlib#assert#Enable ..................... |tlib#assert#Enable()| - tlib#assert#Disable .................... |tlib#assert#Disable()| - tlib#assert#Assert ..................... |tlib#assert#Assert()| - tlib#assert#Map ........................ |tlib#assert#Map()| - tlib#assert#All ........................ |tlib#assert#All()| - tlib#textobjects#StandardParagraph ..... |standard-paragraph| - tlib#textobjects#Init .................. |tlib#textobjects#Init()| - v_sp ................................... |v_sp| - o_sp ................................... |o_sp| - tlib#arg#Get ........................... |tlib#arg#Get()| - tlib#arg#Let ........................... |tlib#arg#Let()| - tlib#arg#StringAsKeyArgs ............... |tlib#arg#StringAsKeyArgs()| - tlib#arg#StringAsKeyArgsEqual .......... |tlib#arg#StringAsKeyArgsEqual()| - tlib#arg#GetOpts ....................... |tlib#arg#GetOpts()| - tlib#arg#Ex ............................ |tlib#arg#Ex()| - tlib#fixes#Winpos ...................... |tlib#fixes#Winpos()| - g:tlib#dir#sep ......................... |g:tlib#dir#sep| - tlib#dir#CanonicName ................... |tlib#dir#CanonicName()| - tlib#dir#NativeName .................... |tlib#dir#NativeName()| - tlib#dir#PlainName ..................... |tlib#dir#PlainName()| - tlib#dir#Ensure ........................ |tlib#dir#Ensure()| - tlib#dir#MyRuntime ..................... |tlib#dir#MyRuntime()| - tlib#dir#CD ............................ |tlib#dir#CD()| - tlib#dir#Push .......................... |tlib#dir#Push()| - tlib#dir#Pop ........................... |tlib#dir#Pop()| - g:tlib#hash#use_crc32 .................. |g:tlib#hash#use_crc32| - g:tlib#hash#use_adler32 ................ |g:tlib#hash#use_adler32| - tlib#hash#CRC32B ....................... |tlib#hash#CRC32B()| - tlib#hash#CRC32B_ruby .................. |tlib#hash#CRC32B_ruby()| - tlib#hash#CRC32B_vim ................... |tlib#hash#CRC32B_vim()| - tlib#hash#Adler32 ...................... |tlib#hash#Adler32()| - tlib#hash#Adler32_vim .................. |tlib#hash#Adler32_vim()| - tlib#hash#Adler32_tlib ................. |tlib#hash#Adler32_tlib()| - tlib#win#Set ........................... |tlib#win#Set()| - tlib#win#GetLayout ..................... |tlib#win#GetLayout()| - tlib#win#SetLayout ..................... |tlib#win#SetLayout()| - tlib#win#List .......................... |tlib#win#List()| - tlib#win#Width ......................... |tlib#win#Width()| - tlib#win#WinDo ......................... |tlib#win#WinDo()| - tlib#comments#Comments ................. |tlib#comments#Comments()| - tlib#grep#Do ........................... |tlib#grep#Do()| - tlib#grep#LocList ...................... |tlib#grep#LocList()| - tlib#grep#QuickFixList ................. |tlib#grep#QuickFixList()| - tlib#grep#List ......................... |tlib#grep#List()| - tlib#qfl#FormatQFLE .................... |tlib#qfl#FormatQFLE()| - tlib#qfl#QfeFilename ................... |tlib#qfl#QfeFilename()| - tlib#qfl#InitListBuffer ................ |tlib#qfl#InitListBuffer()| - tlib#qfl#SetSyntax ..................... |tlib#qfl#SetSyntax()| - tlib#qfl#Balloon ....................... |tlib#qfl#Balloon()| - tlib#qfl#AgentEditQFE .................. |tlib#qfl#AgentEditQFE()| - tlib#qfl#AgentPreviewQFE ............... |tlib#qfl#AgentPreviewQFE()| - tlib#qfl#AgentGotoQFE .................. |tlib#qfl#AgentGotoQFE()| - tlib#qfl#AgentWithSelected ............. |tlib#qfl#AgentWithSelected()| - tlib#qfl#RunCmdOnSelected .............. |tlib#qfl#RunCmdOnSelected()| - tlib#qfl#AgentSplitBuffer .............. |tlib#qfl#AgentSplitBuffer()| - tlib#qfl#AgentTabBuffer ................ |tlib#qfl#AgentTabBuffer()| - tlib#qfl#AgentVSplitBuffer ............. |tlib#qfl#AgentVSplitBuffer()| - tlib#qfl#AgentEditLine ................. |tlib#qfl#AgentEditLine()| - tlib#qfl#EditLine ...................... |tlib#qfl#EditLine()| - tlib#qfl#SetFollowCursor ............... |tlib#qfl#SetFollowCursor()| - tlib#qfl#QflList ....................... |tlib#qfl#QflList()| - tlib#qfl#Browse ........................ |tlib#qfl#Browse()| - tlib#Filter_cnf#New .................... |tlib#Filter_cnf#New()| - prototype.Pretty - tlib#Object#New ........................ |tlib#Object#New()| - prototype.New - prototype.Inherit - prototype.Extend - prototype.IsA - prototype.IsRelated - prototype.RespondTo - prototype.Super - tlib#Object#Methods .................... |tlib#Object#Methods()| - g:tlib_viewline_position ............... |g:tlib_viewline_position| - tlib#buffer#EnableMRU .................. |tlib#buffer#EnableMRU()| - tlib#buffer#DisableMRU ................. |tlib#buffer#DisableMRU()| - tlib#buffer#Set ........................ |tlib#buffer#Set()| - tlib#buffer#Eval ....................... |tlib#buffer#Eval()| - tlib#buffer#GetList .................... |tlib#buffer#GetList()| - tlib#buffer#ViewLine ................... |tlib#buffer#ViewLine()| - tlib#buffer#HighlightLine .............. |tlib#buffer#HighlightLine()| - tlib#buffer#DeleteRange ................ |tlib#buffer#DeleteRange()| - tlib#buffer#ReplaceRange ............... |tlib#buffer#ReplaceRange()| - tlib#buffer#ScratchStart ............... |tlib#buffer#ScratchStart()| - tlib#buffer#ScratchEnd ................. |tlib#buffer#ScratchEnd()| - tlib#buffer#BufDo ...................... |tlib#buffer#BufDo()| - tlib#buffer#InsertText ................. |tlib#buffer#InsertText()| - tlib#buffer#InsertText0 ................ |tlib#buffer#InsertText0()| - tlib#buffer#CurrentByte ................ |tlib#buffer#CurrentByte()| - tlib#buffer#KeepCursorPosition ......... |tlib#buffer#KeepCursorPosition()| - tlib#hook#Run .......................... |tlib#hook#Run()| - tlib#string#RemoveBackslashes .......... |tlib#string#RemoveBackslashes()| - tlib#string#Chomp ...................... |tlib#string#Chomp()| - tlib#string#Format ..................... |tlib#string#Format()| - tlib#string#Printf1 .................... |tlib#string#Printf1()| - tlib#string#TrimLeft ................... |tlib#string#TrimLeft()| - tlib#string#TrimRight .................. |tlib#string#TrimRight()| - tlib#string#Strip ...................... |tlib#string#Strip()| - tlib#string#Count ...................... |tlib#string#Count()| - tlib#string#SplitCommaList ............. |tlib#string#SplitCommaList()| + :TLet ................................... |:TLet| + :TScratch ............................... |:TScratch| + :TVarArg ................................ |:TVarArg| + :TBrowseOutput .......................... |:TBrowseOutput| + :TBrowseScriptnames ..................... |:TBrowseScriptnames| + :Texecqfl ............................... |:Texecqfl| + :Texecloc ............................... |:Texecloc| + :Tlibtrace .............................. |:Tlibtrace| + :Tlibtraceset ........................... |:Tlibtraceset| + :Tbrowseqfl ............................. |:Tbrowseqfl| + :Tbrowseloc ............................. |:Tbrowseloc| + tlib#Filter_cnf#New ..................... |tlib#Filter_cnf#New()| + tlib#Filter_cnfd#New .................... |tlib#Filter_cnfd#New()| + tlib#Filter_fuzzy#New ................... |tlib#Filter_fuzzy#New()| + g:tlib#Filter_glob#seq .................. |g:tlib#Filter_glob#seq| + g:tlib#Filter_glob#char ................. |g:tlib#Filter_glob#char| + tlib#Filter_glob#New .................... |tlib#Filter_glob#New()| + tlib#Object#New ......................... |tlib#Object#New()| + g:tlib_inputlist_pct .................... |g:tlib_inputlist_pct| + g:tlib_inputlist_max_lines .............. |g:tlib_inputlist_max_lines| + g:tlib_inputlist_max_cols ............... |g:tlib_inputlist_max_cols| + g:tlib_inputlist_width_filename ......... |g:tlib_inputlist_width_filename| + g:tlib_inputlist_filename_indicators .... |g:tlib_inputlist_filename_indicators| + g:tlib_inputlist_shortmessage ........... |g:tlib_inputlist_shortmessage| + g:tlib_scroll_lines ..................... |g:tlib_scroll_lines| + tlib#agent#SuspendToParentWindow ........ |tlib#agent#SuspendToParentWindow()| + tlib#agent#Suspend ...................... |tlib#agent#Suspend()| + tlib#agent#NewItem ...................... |tlib#agent#NewItem()| + tlib#agent#GotoLine ..................... |tlib#agent#GotoLine()| + tlib#arg#Get ............................ |tlib#arg#Get()| + tlib#arg#Let ............................ |tlib#arg#Let()| + tlib#arg#GetOpts ........................ |tlib#arg#GetOpts()| + tlib#arg#Ex ............................. |tlib#arg#Ex()| + tlib#assert#Enable ...................... |tlib#assert#Enable()| + tlib#assert#Disable ..................... |tlib#assert#Disable()| + g:tlib_viewline_position ................ |g:tlib_viewline_position| + tlib#buffer#Set ......................... |tlib#buffer#Set()| + tlib#buffer#Eval ........................ |tlib#buffer#Eval()| + tlib#buffer#GetList ..................... |tlib#buffer#GetList()| + tlib#buffer#ViewLine .................... |tlib#buffer#ViewLine()| + tlib#buffer#DeleteRange ................. |tlib#buffer#DeleteRange()| + tlib#buffer#ReplaceRange ................ |tlib#buffer#ReplaceRange()| + tlib#buffer#ScratchStart ................ |tlib#buffer#ScratchStart()| + tlib#buffer#ScratchEnd .................. |tlib#buffer#ScratchEnd()| + tlib#buffer#BufDo ....................... |tlib#buffer#BufDo()| + tlib#buffer#InsertText .................. |tlib#buffer#InsertText()| + tlib#buffer#KeepCursorPosition .......... |tlib#buffer#KeepCursorPosition()| + g:tlib_cache ............................ |g:tlib_cache| + g:tlib#cache#purge_days ................. |g:tlib#cache#purge_days| + g:tlib#cache#purge_every_days ........... |g:tlib#cache#purge_every_days| + g:tlib#cache#script_encoding ............ |g:tlib#cache#script_encoding| + g:tlib#cache#run_script ................. |g:tlib#cache#run_script| + g:tlib#cache#verbosity .................. |g:tlib#cache#verbosity| + g:tlib#cache#dont_purge ................. |g:tlib#cache#dont_purge| + g:tlib#cache#max_filename ............... |g:tlib#cache#max_filename| + tlib#cache#Dir .......................... |tlib#cache#Dir()| + tlib#cache#EncodedFilename .............. |tlib#cache#EncodedFilename()| + tlib#cache#Value ........................ |tlib#cache#Value()| + tlib#cache#MaybePurge ................... |tlib#cache#MaybePurge()| + tlib#cache#Purge ........................ |tlib#cache#Purge()| + tlib#char#Get ........................... |tlib#char#Get()| + tlib#cmd#BrowseOutput ................... |tlib#cmd#BrowseOutput()| + tlib#cmd#BrowseOutputWithCallback ....... |tlib#cmd#BrowseOutputWithCallback()| + tlib#cmd#UseVertical .................... |tlib#cmd#UseVertical()| + tlib#cmd#Time ........................... |tlib#cmd#Time()| + tlib#comments#Comments .................. |tlib#comments#Comments()| + tlib#date#SecondsSince1970 .............. |tlib#date#SecondsSince1970()| + g:tlib#dir#sep .......................... |g:tlib#dir#sep| + tlib#dir#CanonicName .................... |tlib#dir#CanonicName()| + tlib#dir#NativeName ..................... |tlib#dir#NativeName()| + tlib#dir#PlainName ...................... |tlib#dir#PlainName()| + tlib#dir#Ensure ......................... |tlib#dir#Ensure()| + tlib#dir#MyRuntime ...................... |tlib#dir#MyRuntime()| + g:tlib#file#drop ........................ |g:tlib#file#drop| + tlib#file#Split ......................... |tlib#file#Split()| + tlib#file#Join .......................... |tlib#file#Join()| + tlib#file#Relative ...................... |tlib#file#Relative()| + tlib#file#Edit .......................... |tlib#file#Edit()| + tlib#hook#Run ........................... |tlib#hook#Run()| + g:tlib#input#sortprefs_threshold ........ |g:tlib#input#sortprefs_threshold| + g:tlib#input#livesearch_threshold ....... |g:tlib#input#livesearch_threshold| + g:tlib#input#filter_mode ................ |g:tlib#input#filter_mode| + g:tlib#input#higroup .................... |g:tlib#input#higroup| + g:tlib_pick_last_item ................... |g:tlib_pick_last_item| + g:tlib#input#numeric_chars .............. |g:tlib#input#numeric_chars| + g:tlib#input#keyagents_InputList_s ...... |g:tlib#input#keyagents_InputList_s| + g:tlib#input#user_shortcuts ............. |g:tlib#input#user_shortcuts| + g:tlib#input#use_popup .................. |g:tlib#input#use_popup| + g:tlib#input#format_filename ............ |g:tlib#input#format_filename| + g:tlib#input#filename_padding_r ......... |g:tlib#input#filename_padding_r| + g:tlib#input#filename_max_width ......... |g:tlib#input#filename_max_width| + tlib#input#List ......................... |tlib#input#List()| + tlib#input#ListD ........................ |tlib#input#ListD()| + tlib#input#ListW ........................ |tlib#input#ListW()| + tlib#input#EditList ..................... |tlib#input#EditList()| + tlib#input#CommandSelect ................ |tlib#input#CommandSelect()| + tlib#input#Edit ......................... |tlib#input#Edit()| + tlib#list#Inject ........................ |tlib#list#Inject()| + tlib#list#Compact ....................... |tlib#list#Compact()| + tlib#list#Flatten ....................... |tlib#list#Flatten()| + tlib#list#FindAll ....................... |tlib#list#FindAll()| + tlib#list#Find .......................... |tlib#list#Find()| + tlib#list#Any ........................... |tlib#list#Any()| + tlib#list#All ........................... |tlib#list#All()| + tlib#list#Remove ........................ |tlib#list#Remove()| + tlib#list#RemoveAll ..................... |tlib#list#RemoveAll()| + tlib#list#Zip ........................... |tlib#list#Zip()| + tlib#map#PumAccept ...................... |tlib#map#PumAccept()| + tlib#normal#WithRegister ................ |tlib#normal#WithRegister()| + tlib#notify#Echo ........................ |tlib#notify#Echo()| + tlib#notify#TrimMessage ................. |tlib#notify#TrimMessage()| + tlib#paragraph#GetMetric ................ |tlib#paragraph#GetMetric()| + tlib#paragraph#Move ..................... |tlib#paragraph#Move()| + g:tlib_persistent ....................... |g:tlib_persistent| + tlib#persistent#Dir ..................... |tlib#persistent#Dir()| + tlib#persistent#EncodedFilename ......... |tlib#persistent#EncodedFilename()| + tlib#progressbar#Init ................... |tlib#progressbar#Init()| + tlib#rx#Escape .......................... |tlib#rx#Escape()| + tlib#rx#EscapeReplace ................... |tlib#rx#EscapeReplace()| + g:tlib_scratch_pos ...................... |g:tlib_scratch_pos| + g:tlib#scratch#hidden ................... |g:tlib#scratch#hidden| + tlib#scratch#UseScratch ................. |tlib#scratch#UseScratch()| + tlib#scratch#CloseScratch ............... |tlib#scratch#CloseScratch()| + tlib#selection#GetSelection ............. |tlib#selection#GetSelection()| + tlib#signs#ClearAll ..................... |tlib#signs#ClearAll()| + tlib#signs#ClearBuffer .................. |tlib#signs#ClearBuffer()| + tlib#signs#Mark ......................... |tlib#signs#Mark()| + tlib#string#RemoveBackslashes ........... |tlib#string#RemoveBackslashes()| + tlib#string#Format ...................... |tlib#string#Format()| + tlib#string#Printf1 ..................... |tlib#string#Printf1()| + g:tlib#sys#special_protocols ............ |g:tlib#sys#special_protocols| + g:tlib#sys#special_suffixes ............. |g:tlib#sys#special_suffixes| + g:tlib#sys#system_rx .................... |g:tlib#sys#system_rx| + g:tlib#sys#system_browser ............... |g:tlib#sys#system_browser| + g:tlib#sys#check_cygpath ................ |g:tlib#sys#check_cygpath| + g:tlib#sys#cygwin_path_rx ............... |g:tlib#sys#cygwin_path_rx| + g:tlib#sys#cygwin_expr .................. |g:tlib#sys#cygwin_expr| + tlib#sys#MaybeUseCygpath ................ |tlib#sys#MaybeUseCygpath()| + tlib#sys#IsSpecial ...................... |tlib#sys#IsSpecial()| + tlib#sys#Open ........................... |tlib#sys#Open()| + tlib#sys#OpenWithSystemViewer ........... |tlib#sys#OpenWithSystemViewer()| + tlib#tab#BufMap ......................... |tlib#tab#BufMap()| + tlib#tab#TabWinNr ....................... |tlib#tab#TabWinNr()| + g:tlib_tags_extra ....................... |g:tlib_tags_extra| + g:tlib_tag_substitute ................... |g:tlib_tag_substitute| + tlib#tag#Retrieve ....................... |tlib#tag#Retrieve()| + tlib#tag#Collect ........................ |tlib#tag#Collect()| + tlib#textobjects#StandardParagraph ...... |standard-paragraph| + v_sp .................................... |v_sp| + g:tlib#trace#backtrace .................. |g:tlib#trace#backtrace| + g:tlib#trace#printer .................... |g:tlib#trace#printer| + tlib#trace#Printer_echom ................ |tlib#trace#Printer_echom()| + tlib#trace#Set .......................... |tlib#trace#Set()| + tlib#trace#Print ........................ |tlib#trace#Print()| + tlib#trace#Enable ....................... |tlib#trace#Enable()| + tlib#trace#Disable ...................... |tlib#trace#Disable()| + tlib#type#Enable ........................ |tlib#type#Enable()| + tlib#type#Disable ....................... |tlib#type#Disable()| + tlib#url#Decode ......................... |tlib#url#Decode()| + tlib#url#DecodeChar ..................... |tlib#url#DecodeChar()| + tlib#url#EncodeChar ..................... |tlib#url#EncodeChar()| + tlib#url#Encode ......................... |tlib#url#Encode()| + tlib#var#Let ............................ |tlib#var#Let()| + tlib#var#EGet ........................... |tlib#var#EGet()| + tlib#var#Get ............................ |tlib#var#Get()| + tlib#var#List ........................... |tlib#var#List()| + g:tlib#vcs#def .......................... |g:tlib#vcs#def| + g:tlib#vcs#executables .................. |g:tlib#vcs#executables| + g:tlib#vcs#check ........................ |g:tlib#vcs#check| + tlib#vcs#Ls ............................. |tlib#vcs#Ls()| + tlib#vcs#Diff ........................... |tlib#vcs#Diff()| + g:tlib#vim#simalt_maximize .............. |g:tlib#vim#simalt_maximize| + g:tlib#vim#simalt_restore ............... |g:tlib#vim#simalt_restore| + g:tlib#vim#use_vimtweak ................. |g:tlib#vim#use_vimtweak| + tlib#vim#Maximize ....................... |tlib#vim#Maximize()| + tlib#vim#RestoreWindow .................. |tlib#vim#RestoreWindow()| + g:tlib#vim#use_wmctrl ................... |g:tlib#vim#use_wmctrl| + tlib#win#Set ............................ |tlib#win#Set()| + tlib#win#SetById ........................ |tlib#win#SetById()| -======================================================================== -plugin/02tlib.vim~ - +------------------------------------------------------------------------ + *plugin/02tlib.vim* *:TLet* :TLet VAR = VALUE Set a variable only if it doesn't already exist. @@ -478,6 +271,14 @@ plugin/02tlib.vim~ TBrowseScriptnames < + *:Texecqfl* +:Texecqfl CMD + Run CMD and display the quickfix list. + + *:Texecloc* +:Texecloc CMD + Run CMD and display the quickfix list. + *:Tlibtrace* :Tlibtrace GUARD, VAR1, VAR2... Do nothing unless |tlib#trace#Enable()| was called. @@ -490,443 +291,60 @@ plugin/02tlib.vim~ *:Tlibtraceset* :Tlibtraceset - :Tlibtraceset +RX1, -RX2... + :Tlibtraceset[!] [--file=FILE] +RX1 -RX2... If |tlib#trace#Enable()| was called: With the optional , users can add and remove GUARDs (actually a |regexp|) that should be traced. - *:Tlibassert* -:Tlibtrace ASSERTION + If no `+` or `-` is prepended, assume `+`. + With the optional bang '!', reset any options. -======================================================================== -test/tlib.vim~ + *:Tbrowseqfl* +:Tlibtype val, 'type', ... + Browse the current |quickfix| list. - *Add()* -Add(a,b) - List + *:Tbrowseloc* +:Tbrowseloc + Browse the current |location-list|. - *TestGetArg()* -TestGetArg(...) - Optional arguments - *TestGetArg1()* -TestGetArg1(...) +------------------------------------------------------------------------ + *autoload/tlib/Filter_cnf.vim* + *tlib#Filter_cnf#New()* +tlib#Filter_cnf#New(...) + The search pattern for |tlib#input#List()| is in conjunctive normal + form: (P1 OR P2 ...) AND (P3 OR P4 ...) ... + The pattern is a '/\V' very no-'/magic' regexp pattern. - *TestArgs()* -TestArgs(...) + Pressing joins two patterns with AND. + Pressing | joins two patterns with OR. + I.e. In order to get "lala AND (foo OR bar)", you type + "lala foo|bar". - *TestArgs1()* -TestArgs1(...) + This is also the base class for other filters. - *TestArgs2()* -TestArgs2(...) - *TestArgs3()* -TestArgs3(...) +------------------------------------------------------------------------ + *autoload/tlib/Filter_cnfd.vim* + *tlib#Filter_cnfd#New()* +tlib#Filter_cnfd#New(...) + The same as |tlib#Filter_cnf#New()| but a dot is expanded to '\.\{-}'. + As a consequence, patterns cannot match dots. + The pattern is a '/\V' very no-'/magic' regexp pattern. -======================================================================== -autoload/tlib.vim~ +------------------------------------------------------------------------ + *autoload/tlib/Filter_fuzzy.vim* + *tlib#Filter_fuzzy#New()* +tlib#Filter_fuzzy#New(...) + Support for "fuzzy" pattern matching in |tlib#input#List()|. + Patterns are interpreted as if characters were connected with '.\{-}'. - *g:tlib#debug* -g:tlib#debug + In "fuzzy" mode, the pretty printing of filenames is disabled. -======================================================================== -autoload/tlib/notify.vim~ - - *tlib#notify#Echo()* -tlib#notify#Echo(text, ?style='') - Print text in the echo area. Temporarily disable 'ruler' and 'showcmd' - in order to prevent |press-enter| messages. - - *tlib#notify#TrimMessage()* -tlib#notify#TrimMessage(message) - Contributed by Erik Falor: - If the line containing the message is too long, echoing it will cause - a 'Hit ENTER' prompt to appear. This function cleans up the line so - that does not happen. - The echoed line is too long if it is wider than the width of the - window, minus cmdline space taken up by the ruler and showcmd - features. - - -======================================================================== -autoload/tlib/trace.vim~ - - *g:tlib#trace#backtrace* -g:tlib#trace#backtrace (default: 2) - The length of the backtrace that should be included in - |tlib#trace#Print()|. - - *g:tlib#trace#printf* -g:tlib#trace#printf (default: 'echom %s') - The command used for printing traces from |tlib#trace#Print()|. - - *tlib#trace#PrintToFile()* -tlib#trace#PrintToFile(filename) - Set |g:tlib#trace#printf| to make |tlib#trace#Print()| print to - `filename`. - - *tlib#trace#Set()* -tlib#trace#Set(vars) - Set the tracing |regexp|. See |:Tlibtrace|. - This will also call |tlib#trace#Enable()|. - - Examples: - call tlib#trace#Set(["+foo", "-bar"]) - call tlib#trace#Set("+foo,-bar") - - *tlib#trace#Backtrace()* -tlib#trace#Backtrace(caller) - - *tlib#trace#Print()* -tlib#trace#Print(caller, vars, values) - Print the values of vars. The first value is a "guard" (see - |:Tlibtrace|). - - *tlib#trace#Enable()* -tlib#trace#Enable() - Enable tracing via |:Tlibtrace|. - - *tlib#trace#Disable()* -tlib#trace#Disable() - Disable tracing via |:Tlibtrace|. - - -======================================================================== -autoload/tlib/dictionary.vim~ - - *tlib#dictionary#Rev()* -tlib#dictionary#Rev(dict) - - -======================================================================== -autoload/tlib/persistent.vim~ - - *g:tlib_persistent* -g:tlib_persistent (default: '') - The directory for persistent data files. If empty, use - |tlib#dir#MyRuntime|.'/share'. - - *tlib#persistent#Dir()* -tlib#persistent#Dir(?mode = 'bg') - Return the full directory name for persistent data files. - - *tlib#persistent#Filename()* -tlib#persistent#Filename(type, ?file=%, ?mkdir=0) - - *tlib#persistent#Get()* -tlib#persistent#Get(...) - - *tlib#persistent#MTime()* -tlib#persistent#MTime(cfile) - - *tlib#persistent#Value()* -tlib#persistent#Value(...) - - *tlib#persistent#Save()* -tlib#persistent#Save(cfile, dictionary) - - -======================================================================== -autoload/tlib/vim.vim~ - - *g:tlib#vim#simalt_maximize* -g:tlib#vim#simalt_maximize (default: 'x') - The alt-key for maximizing the window. - CAUTION: The value of this paramter depends on your locale and - maybe the windows version you are running. - - *g:tlib#vim#simalt_restore* -g:tlib#vim#simalt_restore (default: 'r') - The alt-key for restoring the window. - CAUTION: The value of this paramter depends on your locale and - maybe the windows version you are running. - - *g:tlib#vim#use_vimtweak* -g:tlib#vim#use_vimtweak (default: 0) - If true, use the vimtweak.dll for windows. This will enable - tlib to remove the caption for fullscreen windows. - - *tlib#vim#Maximize()* -tlib#vim#Maximize(fullscreen) - Maximize the window. - You might need to redefine |g:tlib#vim#simalt_maximize| if it doesn't - work for you. - - *tlib#vim#RestoreWindow()* -tlib#vim#RestoreWindow() - Restore the original vimsize after having called |tlib#vim#Maximize()|. - - *g:tlib#vim#use_wmctrl* -g:tlib#vim#use_wmctrl (default: executable('wmctrl')) - If true, use wmctrl for X windows to make a window - maximized/fullscreen. - - This is the preferred method for maximizing windows under X - windows. Some window managers have problem coping with the - default method of setting 'lines' and 'columns' to a large - value. - - *tlib#vim#CopyFunction()* -tlib#vim##CopyFunction(old, new, overwrite=0) - - -======================================================================== -autoload/tlib/progressbar.vim~ - - *tlib#progressbar#Init()* -tlib#progressbar#Init(max, ...) - EXAMPLE: > - call tlib#progressbar#Init(20) - try - for i in range(20) - call tlib#progressbar#Display(i) - call DoSomethingThatTakesSomeTime(i) - endfor - finally - call tlib#progressbar#Restore() - endtry -< - - *tlib#progressbar#Display()* -tlib#progressbar#Display(value, ...) - - *tlib#progressbar#Restore()* -tlib#progressbar#Restore() - - -======================================================================== -autoload/tlib/eval.vim~ - - *tlib#eval#FormatValue()* -tlib#eval#FormatValue(value, ...) - - *tlib#eval#Extend()* -tlib#eval#Extend(a, b, ...) - - -======================================================================== -autoload/tlib/list.vim~ - - *tlib#list#Inject()* -tlib#list#Inject(list, initial_value, funcref) - EXAMPLES: > - echo tlib#list#Inject([1,2,3], 0, function('Add') - => 6 -< - - *tlib#list#Compact()* -tlib#list#Compact(list) - EXAMPLES: > - tlib#list#Compact([0,1,2,3,[], {}, ""]) - => [1,2,3] -< - - *tlib#list#Flatten()* -tlib#list#Flatten(list) - EXAMPLES: > - tlib#list#Flatten([0,[1,2,[3,""]]]) - => [0,1,2,3,""] -< - - *tlib#list#FindAll()* -tlib#list#FindAll(list, filter, ?process_expr="") - Basically the same as filter() - - EXAMPLES: > - tlib#list#FindAll([1,2,3], 'v:val >= 2') - => [2, 3] -< - - *tlib#list#Find()* -tlib#list#Find(list, filter, ?default="", ?process_expr="") - - EXAMPLES: > - tlib#list#Find([1,2,3], 'v:val >= 2') - => 2 -< - - *tlib#list#Any()* -tlib#list#Any(list, expr) - EXAMPLES: > - tlib#list#Any([1,2,3], 'v:val >= 2') - => 1 -< - - *tlib#list#All()* -tlib#list#All(list, expr) - EXAMPLES: > - tlib#list#All([1,2,3], 'v:val >= 2') - => 0 -< - - *tlib#list#Remove()* -tlib#list#Remove(list, element) - EXAMPLES: > - tlib#list#Remove([1,2,1,2], 2) - => [1,1,2] -< - - *tlib#list#RemoveAll()* -tlib#list#RemoveAll(list, element) - EXAMPLES: > - tlib#list#RemoveAll([1,2,1,2], 2) - => [1,1] -< - - *tlib#list#Zip()* -tlib#list#Zip(lists, ?default='') - EXAMPLES: > - tlib#list#Zip([[1,2,3], [4,5,6]]) - => [[1,4], [2,5], [3,6]] -< - - *tlib#list#Uniq()* -tlib#list#Uniq(list, ...) - - *tlib#list#ToDictionary()* -tlib#list#ToDictionary(list, default, ...) - - -======================================================================== -autoload/tlib/cmd.vim~ - - *tlib#cmd#OutputAsList()* -tlib#cmd#OutputAsList(command) - - *tlib#cmd#BrowseOutput()* -tlib#cmd#BrowseOutput(command) - See |:TBrowseOutput|. - - *tlib#cmd#BrowseOutputWithCallback()* -tlib#cmd#BrowseOutputWithCallback(callback, command) - Execute COMMAND and present its output in a |tlib#input#List()|; - when a line is selected, execute the function named as the CALLBACK - and pass in that line as an argument. - - The CALLBACK function gives you an opportunity to massage the COMMAND output - and possibly act on it in a meaningful way. For example, if COMMAND listed - all URIs found in the current buffer, CALLBACK could validate and then open - the selected URI in the system's default browser. - - This function is meant to be a tool to help compose the implementations of - powerful commands that use |tlib#input#List()| as a common interface. See - |TBrowseScriptnames| as an example. - - EXAMPLES: > - call tlib#cmd#BrowseOutputWithCallback('tlib#cmd#ParseScriptname', 'scriptnames') -< - - *tlib#cmd#DefaultBrowseOutput()* -tlib#cmd#DefaultBrowseOutput(cmd) - - *tlib#cmd#ParseScriptname()* -tlib#cmd#ParseScriptname(line) - - *tlib#cmd#TBrowseScriptnames()* -tlib#cmd#TBrowseScriptnames() - - *tlib#cmd#UseVertical()* -tlib#cmd#UseVertical(?rx='') - Look at the history whether the command was called with vertical. If - an rx is provided check first if the last entry in the history matches - this rx. - - *tlib#cmd#Time()* -tlib#cmd#Time(cmd) - Print the time in seconds or milliseconds (if your version of VIM - has |+reltime|) a command takes. - - *tlib#cmd#Capture()* -tlib#cmd#Capture(cmd) - - -======================================================================== -autoload/tlib/syntax.vim~ - - *tlib#syntax#Collect()* -tlib#syntax#Collect() - - *tlib#syntax#Names()* -tlib#syntax#Names(?rx='') - - -======================================================================== -autoload/tlib/balloon.vim~ - - *tlib#balloon#Register()* -tlib#balloon#Register(expr) - - *tlib#balloon#Remove()* -tlib#balloon#Remove(expr) - - *tlib#balloon#Expr()* -tlib#balloon#Expr() - - *tlib#balloon#Expand()* -tlib#balloon#Expand(expr) - - -======================================================================== -autoload/tlib/vcs.vim~ - - *g:tlib#vcs#def* -g:tlib#vcs#def {...} - A dictionarie of supported VCS (currently: git, hg, svn, bzr). - - *g:tlib#vcs#executables* -g:tlib#vcs#executables {...} - A dictionary of custom executables for VCS commands. If the value is - empty, support for that VCS will be removed. If no key is present, it - is assumed that the VCS "type" is the name of the executable. - - *g:tlib#vcs#check* -g:tlib#vcs#check (default: has('win16') || has('win32') || has('win64') ? '%s.exe' : '%s') - If non-empty, use it as a format string to check whether a VCS is - installed on your computer. - - *tlib#vcs#Executable()* -tlib#vcs#Executable(type) - - *tlib#vcs#FindVCS()* -tlib#vcs#FindVCS(filename) - - *tlib#vcs#Ls()* -tlib#vcs#Ls(?filename=bufname('%'), ?vcs=[type, dir]) - Return the files under VCS. - - *tlib#vcs#Diff()* -tlib#vcs#Diff(filename, ?vcs=[type, dir]) - Return the diff for "filename" - - *tlib#vcs#GitLsPostprocess()* -tlib#vcs#GitLsPostprocess(filename) - - -======================================================================== -autoload/tlib/char.vim~ - - *tlib#char#Get()* -tlib#char#Get(?timeout=0) - Get a character. - - EXAMPLES: > - echo tlib#char#Get() - echo tlib#char#Get(5) -< - - *tlib#char#IsAvailable()* -tlib#char#IsAvailable() - - *tlib#char#GetWithTimeout()* -tlib#char#GetWithTimeout(timeout, ...) - - -======================================================================== -autoload/tlib/Filter_glob.vim~ - +------------------------------------------------------------------------ + *autoload/tlib/Filter_glob.vim* *g:tlib#Filter_glob#seq* g:tlib#Filter_glob#seq (default: '*') A character that should be expanded to '\.\{-}'. @@ -943,46 +361,245 @@ tlib#Filter_glob#New(...) The pattern is a '/\V' very no-'/magic' regexp pattern. -======================================================================== -autoload/tlib/scratch.vim~ +------------------------------------------------------------------------ + *autoload/tlib/Object.vim* +Provides a prototype plus some OO-like methods. - *g:tlib_scratch_pos* -g:tlib_scratch_pos (default: 'botright') - Scratch window position. By default the list window is opened on the - bottom. Set this variable to 'topleft' or '' to change this behaviour. + *tlib#Object#New()* +tlib#Object#New(?fields={}) + This function creates a prototype that provides some kind of + inheritance mechanism and a way to call parent/super methods. + + The usage demonstrated in the following example works best when every + class/prototype is defined in a file of its own. + + The reason for why there is a dedicated constructor function is that + this layout facilitates the use of templates and that methods are + hidden from the user. Other solutions are possible. + + EXAMPLES: > + let s:prototype = tlib#Object#New({ + \ '_class': ['FooBar'], + \ 'foo': 1, + \ 'bar': 2, + \ }) + " Constructor + function! FooBar(...) + let object = s:prototype.New(a:0 >= 1 ? a:1 : {}) + return object + endf + function! s:prototype.babble() { + echo "I think, therefore I am ". (self.foo * self.bar) ." months old." + } + +< This could now be used like this: > + let myfoo = FooBar({'foo': 3}) + call myfoo.babble() + => I think, therefore I am 6 months old. + echo myfoo.IsA('FooBar') + => 1 + echo myfoo.IsA('object') + => 1 + echo myfoo.IsA('Foo') + => 0 + echo myfoo.RespondTo('babble') + => 1 + echo myfoo.RespondTo('speak') + => 0 +< + + +------------------------------------------------------------------------ + *autoload/tlib/World.vim* +A prototype used by |tlib#input#List|. +Inherits from |tlib#Object#New|. + + *g:tlib_inputlist_pct* +g:tlib_inputlist_pct (default: 50) + Size of the input list window (in percent) from the main size (of &lines). See |tlib#input#List()|. - *g:tlib#scratch#hidden* -g:tlib#scratch#hidden (default: 'hide') - If you want the scratch buffer to be fully removed, you might want to - set this variable to 'wipe'. - See also https://github.com/tomtom/tlib_vim/pull/16 + *g:tlib_inputlist_max_lines* +g:tlib_inputlist_max_lines (default: -1) + Max height for a horizontal list. - *tlib#scratch#UseScratch()* -tlib#scratch#UseScratch(?keyargs={}) - Display a scratch buffer (a buffer with no file). See :TScratch for an - example. - Return the scratch buffer's number. - Values for keyargs: - scratch_split ... 1: split, 0: window, -1: tab + *g:tlib_inputlist_max_cols* +g:tlib_inputlist_max_cols (default: -1) + Max width for a vertical list. - *tlib#scratch#CloseScratch()* -tlib#scratch#CloseScratch(keyargs, ...) - Close a scratch buffer as defined in keyargs (usually a World). - Return 1 if the scratch buffer is closed (or if it already was - closed). + *g:tlib_inputlist_width_filename* +g:tlib_inputlist_width_filename (default: '&columns / 3') + Size of filename columns when listing filenames. + See |tlib#input#List()|. + + *g:tlib_inputlist_filename_indicators* +g:tlib_inputlist_filename_indicators (default: 0) + If true, |tlib#input#List()| will show some indicators about the + status of a filename (e.g. buflisted(), bufloaded() etc.). + This is disabled by default because vim checks also for the file on + disk when doing this. + + *g:tlib_inputlist_shortmessage* +g:tlib_inputlist_shortmessage (default: 0) + If not null, display only a short info about the filter. -======================================================================== -autoload/tlib/autocmdgroup.vim~ +------------------------------------------------------------------------ + *autoload/tlib/agent.vim* +Various agents for use as key handlers in tlib#input#List() - *tlib#autocmdgroup#Init()* -tlib#autocmdgroup#Init() + *g:tlib_scroll_lines* +g:tlib_scroll_lines (default: 10) + Number of items to move when pressing in the input list window. + + *tlib#agent#SuspendToParentWindow()* +tlib#agent#SuspendToParentWindow(world, selected) + Suspend (see |tlib#agent#Suspend|) the input loop and jump back to the + original position in the parent window. + + *tlib#agent#Suspend()* +tlib#agent#Suspend(world, selected) + Suspend lets you temporarily leave the input loop of + |tlib#input#List|. You can resume editing the list by pressing , + . , or in the suspended window. + and will immediatly select the item under the cursor. + < will select the item but the window will remain opened. + + *tlib#agent#NewItem()* +tlib#agent#NewItem(world, selected) + Insert a new item below the current one. + + *tlib#agent#GotoLine()* +tlib#agent#GotoLine(world, selected) + If not called from the scratch, we assume/guess that we don't have to + suspend the input-evaluation loop. -======================================================================== -autoload/tlib/cache.vim~ +------------------------------------------------------------------------ + *autoload/tlib/arg.vim* + *tlib#arg#Get()* +tlib#arg#Get(n, var, ?default="", ?test='') + Set a positional argument from a variable argument list. + See tlib#string#RemoveBackslashes() for an example. + *tlib#arg#Let()* +tlib#arg#Let(list, ?default='') + Set a positional arguments from a variable argument list. + See tlib#input#List() for an example. + + *tlib#arg#GetOpts()* +tlib#arg#GetOpts(args, ?def={}) + Convert a list of strings of command-line arguments into a dictonary. + + The main use case is to pass [], i.e. the command-line + arguments of a command as list, from a command definition to this + function. + + Example: + ['-h'] + => If def contains a 'help' key, invoke |:help| on its value. + + ['-ab', '--foo', '--bar=BAR', 'bla', bla'] + => {'a': 1, 'b': 1, 'foo': 1, 'bar': 'BAR', '__rest__': ['bla', 'bla']} + + ['-ab', '--', '--foo', '--bar=BAR'] + => {'a': 1, 'b': 1, '__rest__': ['--foo', '--bar=BAR']} + + *tlib#arg#Ex()* +tlib#arg#Ex(arg, ?chars='%#! ') + Escape some characters in a string. + + Use |fnamescape()| if available. + + EXAMPLES: > + exec 'edit '. tlib#arg#Ex('foo%#bar.txt') +< + + +------------------------------------------------------------------------ + *autoload/tlib/assert.vim* + *tlib#assert#Enable()* +tlib#assert#Enable() + Enable tracing via |:Tlibassert|. + + *tlib#assert#Disable()* +tlib#assert#Disable() + Disable tracing via |:Tlibassert|. + + +------------------------------------------------------------------------ + *autoload/tlib/buffer.vim* + *g:tlib_viewline_position* +g:tlib_viewline_position (default: 'zz') + Where to display the line when using |tlib#buffer#ViewLine|. + For possible values for position see |scroll-cursor|. + + *tlib#buffer#Set()* +tlib#buffer#Set(buffer) + Set the buffer to buffer and return a command as string that can be + evaluated by |:execute| in order to restore the original view. + + *tlib#buffer#Eval()* +tlib#buffer#Eval(buffer, code) + Evaluate CODE in BUFFER. + + EXAMPLES: > + call tlib#buffer#Eval('foo.txt', 'echo b:bar') +< + + *tlib#buffer#GetList()* +tlib#buffer#GetList(?show_hidden=0, ?show_number=0, " ?order='bufnr') + Possible values for the "order" argument: + bufnr :: Default behaviour + mru :: Sort buffers according to most recent use + basename :: Sort by the file's basename (last component) + + NOTE: MRU order works on second invocation only. If you want to always + use MRU order, call tlib#buffer#EnableMRU() in your ~/.vimrc file. + + *tlib#buffer#ViewLine()* +tlib#buffer#ViewLine(line, ?position='z') + line is either a number or a string that begins with a number. + For possible values for position see |scroll-cursor|. + See also |g:tlib_viewline_position|. + + *tlib#buffer#DeleteRange()* +tlib#buffer#DeleteRange(line1, line2) + Delete the lines in the current buffer. Wrapper for |:delete|. + + *tlib#buffer#ReplaceRange()* +tlib#buffer#ReplaceRange(line1, line2, lines) + Replace a range of lines. + + *tlib#buffer#ScratchStart()* +tlib#buffer#ScratchStart() + Initialize some scratch area at the bottom of the current buffer. + + *tlib#buffer#ScratchEnd()* +tlib#buffer#ScratchEnd() + Remove the in-buffer scratch area. + + *tlib#buffer#BufDo()* +tlib#buffer#BufDo(exec) + Run exec on all buffers via bufdo and return to the original buffer. + + *tlib#buffer#InsertText()* +tlib#buffer#InsertText(text, keyargs) + Keyargs: + 'shift': 0|N + 'col': col('.')|N + 'lineno': line('.')|N + 'indent': 0|1 + 'pos': 'e'|'s' ... Where to locate the cursor (somewhat like s and e in {offset}) + Insert text (a string) in the buffer. + + *tlib#buffer#KeepCursorPosition()* +tlib#buffer#KeepCursorPosition(cmd) + Evaluate cmd while maintaining the cursor position and jump registers. + + +------------------------------------------------------------------------ + *autoload/tlib/cache.vim* *g:tlib_cache* g:tlib_cache (default: '') The cache directory. If empty, use |tlib#dir#MyRuntime|.'/cache'. @@ -1031,20 +648,12 @@ g:tlib#cache#max_filename (default: 200) |pathshorten()|. *tlib#cache#Dir()* -tlib#cache#Dir(?mode = 'bg') +tlib#cache#Dir(?mode = 'bg', ?ensure_dir = true) The default cache directory. - *tlib#cache#Filename()* -tlib#cache#Filename(type, ?file=%, ?mkdir=0, ?dir='') - - *tlib#cache#Save()* -tlib#cache#Save(cfile, dictionary, ...) - - *tlib#cache#MTime()* -tlib#cache#MTime(cfile) - - *tlib#cache#Get()* -tlib#cache#Get(cfile, ...) + *tlib#cache#EncodedFilename()* +tlib#cache#EncodedFilename(type, file, ?mkdir=0, ?dir='') + Encode `file` and call |tlib#cache#Filename()|. *tlib#cache#Value()* tlib#cache#Value(cfile, generator, ftime, ?generator_args=[], ?options={}) @@ -1060,421 +669,151 @@ tlib#cache#MaybePurge() tlib#cache#Purge() Delete old files. - *tlib#cache#ListFilesInCache()* -tlib#cache#ListFilesInCache(...) - -======================================================================== -autoload/tlib/normal.vim~ - - *tlib#normal#WithRegister()* -tlib#normal#WithRegister(cmd, ?register='t', ?norm_cmd='norm!') - Execute a normal command while maintaining all registers. - - -======================================================================== -autoload/tlib/time.vim~ - - *tlib#time#MSecs()* -tlib#time#MSecs() - - *tlib#time#Now()* -tlib#time#Now() - - *tlib#time#FormatNow()* -tlib#time#FormatNow() - - *tlib#time#Diff()* -tlib#time#Diff(a, b, ...) - - *tlib#time#DiffMSecs()* -tlib#time#DiffMSecs(a, b, ...) - - -======================================================================== -autoload/tlib/var.vim~ - - *tlib#var#Let()* -tlib#var#Let(name, val) - Define a variable called NAME if yet undefined. - You can also use the :TLLet command. +------------------------------------------------------------------------ + *autoload/tlib/char.vim* + *tlib#char#Get()* +tlib#char#Get(?timeout=0) + Get a character. EXAMPLES: > - exec tlib#var#Let('g:foo', 1) - TLet g:foo = 1 + echo tlib#char#Get() + echo tlib#char#Get(5) < - *tlib#var#EGet()* -tlib#var#EGet(var, namespace, ?default='') - Retrieve a variable by searching several namespaces. + +------------------------------------------------------------------------ + *autoload/tlib/cmd.vim* + *tlib#cmd#BrowseOutput()* +tlib#cmd#BrowseOutput(command) + See |:TBrowseOutput|. + + *tlib#cmd#BrowseOutputWithCallback()* +tlib#cmd#BrowseOutputWithCallback(callback, command) + Execute COMMAND and present its output in a |tlib#input#List()|; + when a line is selected, execute the function named as the CALLBACK + and pass in that line as an argument. + + The CALLBACK function gives you an opportunity to massage the COMMAND output + and possibly act on it in a meaningful way. For example, if COMMAND listed + all URIs found in the current buffer, CALLBACK could validate and then open + the selected URI in the system's default browser. + + This function is meant to be a tool to help compose the implementations of + powerful commands that use |tlib#input#List()| as a common interface. See + |TBrowseScriptnames| as an example. EXAMPLES: > - let g:foo = 1 - let b:foo = 2 - let w:foo = 3 - echo eval(tlib#var#EGet('foo', 'vg')) => 1 - echo eval(tlib#var#EGet('foo', 'bg')) => 2 - echo eval(tlib#var#EGet('foo', 'wbg')) => 3 + call tlib#cmd#BrowseOutputWithCallback('tlib#cmd#ParseScriptname', 'scriptnames') < - *tlib#var#Get()* -tlib#var#Get(var, namespace, ?default='') - Retrieve a variable by searching several namespaces. + *tlib#cmd#UseVertical()* +tlib#cmd#UseVertical(?rx='') + Look at the history whether the command was called with vertical. If + an rx is provided check first if the last entry in the history matches + this rx. + *tlib#cmd#Time()* +tlib#cmd#Time(cmd) + Print the time in seconds or milliseconds (if your version of VIM + has |+reltime|) a command takes. + + +------------------------------------------------------------------------ + *autoload/tlib/comments.vim* + *tlib#comments#Comments()* +tlib#comments#Comments(...) + function! tlib#comments#Comments(?rx='') + + +------------------------------------------------------------------------ + *autoload/tlib/date.vim* + *tlib#date#SecondsSince1970()* +tlib#date#Parse(date, ?allow_zero=0, ?silent=0) "{{{3 + tlib#date#SecondsSince1970(date, ?daysshift=0, ?allow_zero=0) + + +------------------------------------------------------------------------ + *autoload/tlib/dir.vim* + *g:tlib#dir#sep* +g:tlib#dir#sep (default: exists('+shellslash') && !&shellslash ? '\' : '/') + TLet g:tlib#dir#sep = '/' + + *tlib#dir#CanonicName()* +tlib#dir#CanonicName(dirname) EXAMPLES: > - let g:foo = 1 - let b:foo = 2 - let w:foo = 3 - echo tlib#var#Get('foo', 'bg') => 1 - echo tlib#var#Get('foo', 'bg') => 2 - echo tlib#var#Get('foo', 'wbg') => 3 + tlib#dir#CanonicName('foo/bar') + => 'foo/bar/' < - *tlib#var#List()* -tlib#var#List(rx, ?prefix='') - Get a list of variables matching rx. - EXAMPLE: - echo tlib#var#List('tlib_', 'g:') - - -======================================================================== -autoload/tlib/agent.vim~ -Various agents for use as key handlers in tlib#input#List() - - *g:tlib_scroll_lines* -g:tlib_scroll_lines (default: 10) - Number of items to move when pressing in the input list window. - - *tlib#agent#Exit()* -tlib#agent#Exit(world, selected) - - *tlib#agent#CopyItems()* -tlib#agent#CopyItems(world, selected) - - *tlib#agent#PageUp()* -tlib#agent#PageUp(world, selected) - - *tlib#agent#PageDown()* -tlib#agent#PageDown(world, selected) - - *tlib#agent#Home()* -tlib#agent#Home(world, selected) - - *tlib#agent#End()* -tlib#agent#End(world, selected) - - *tlib#agent#Up()* -tlib#agent#Up(world, selected, ...) - - *tlib#agent#Down()* -tlib#agent#Down(world, selected, ...) - - *tlib#agent#UpN()* -tlib#agent#UpN(world, selected) - - *tlib#agent#DownN()* -tlib#agent#DownN(world, selected) - - *tlib#agent#ShiftLeft()* -tlib#agent#ShiftLeft(world, selected) - - *tlib#agent#ShiftRight()* -tlib#agent#ShiftRight(world, selected) - - *tlib#agent#Reset()* -tlib#agent#Reset(world, selected) - - *tlib#agent#ToggleRestrictView()* -tlib#agent#ToggleRestrictView(world, selected) - - *tlib#agent#RestrictView()* -tlib#agent#RestrictView(world, selected) - - *tlib#agent#UnrestrictView()* -tlib#agent#UnrestrictView(world, selected) - - *tlib#agent#Input()* -tlib#agent#Input(world, selected) - - *tlib#agent#SuspendToParentWindow()* -tlib#agent#SuspendToParentWindow(world, selected) - Suspend (see |tlib#agent#Suspend|) the input loop and jump back to the - original position in the parent window. - - *tlib#agent#Suspend()* -tlib#agent#Suspend(world, selected) - Suspend lets you temporarily leave the input loop of - |tlib#input#List|. You can resume editing the list by pressing , - . , or in the suspended window. - and will immediatly select the item under the cursor. - < will select the item but the window will remain opened. - - *tlib#agent#Help()* -tlib#agent#Help(world, selected) - - *tlib#agent#OR()* -tlib#agent#OR(world, selected) - - *tlib#agent#AND()* -tlib#agent#AND(world, selected) - - *tlib#agent#ReduceFilter()* -tlib#agent#ReduceFilter(world, selected) - - *tlib#agent#PopFilter()* -tlib#agent#PopFilter(world, selected) - - *tlib#agent#Debug()* -tlib#agent#Debug(world, selected) - - *tlib#agent#Select()* -tlib#agent#Select(world, selected) - - *tlib#agent#SelectUp()* -tlib#agent#SelectUp(world, selected) - - *tlib#agent#SelectDown()* -tlib#agent#SelectDown(world, selected) - - *tlib#agent#SelectAll()* -tlib#agent#SelectAll(world, selected) - - *tlib#agent#ToggleStickyList()* -tlib#agent#ToggleStickyList(world, selected) - - *tlib#agent#EditItem()* -tlib#agent#EditItem(world, selected) - - *tlib#agent#NewItem()* -tlib#agent#NewItem(world, selected) - Insert a new item below the current one. - - *tlib#agent#DeleteItems()* -tlib#agent#DeleteItems(world, selected) - - *tlib#agent#Cut()* -tlib#agent#Cut(world, selected) - - *tlib#agent#Copy()* -tlib#agent#Copy(world, selected) - - *tlib#agent#Paste()* -tlib#agent#Paste(world, selected) - - *tlib#agent#EditReturnValue()* -tlib#agent#EditReturnValue(world, rv) - - *tlib#agent#ViewFile()* -tlib#agent#ViewFile(world, selected) - - *tlib#agent#EditFile()* -tlib#agent#EditFile(world, selected) - - *tlib#agent#EditFileInSplit()* -tlib#agent#EditFileInSplit(world, selected) - - *tlib#agent#EditFileInVSplit()* -tlib#agent#EditFileInVSplit(world, selected) - - *tlib#agent#EditFileInTab()* -tlib#agent#EditFileInTab(world, selected) - - *tlib#agent#ToggleScrollbind()* -tlib#agent#ToggleScrollbind(world, selected) - - *tlib#agent#ShowInfo()* -tlib#agent#ShowInfo(world, selected) - - *tlib#agent#PreviewLine()* -tlib#agent#PreviewLine(world, selected) - - *tlib#agent#GotoLine()* -tlib#agent#GotoLine(world, selected) - If not called from the scratch, we assume/guess that we don't have to - suspend the input-evaluation loop. - - *tlib#agent#DoAtLine()* -tlib#agent#DoAtLine(world, selected) - - *tlib#agent#Wildcard()* -tlib#agent#Wildcard(world, selected) - - *tlib#agent#Null()* -tlib#agent#Null(world, selected) - - *tlib#agent#ExecAgentByName()* -tlib#agent#ExecAgentByName(world, selected) - - *tlib#agent#CompleteAgentNames()* -tlib#agent#CompleteAgentNames(ArgLead, CmdLine, CursorPos) - - *tlib#agent#Complete()* -tlib#agent#Complete(world, selected) - - -======================================================================== -autoload/tlib/bitwise.vim~ - - *tlib#bitwise#Num2Bits()* -tlib#bitwise#Num2Bits(num) - - *tlib#bitwise#Bits2Num()* -tlib#bitwise#Bits2Num(bits, ...) - - *tlib#bitwise#AND()* -tlib#bitwise#AND(num1, num2, ...) - - *tlib#bitwise#OR()* -tlib#bitwise#OR(num1, num2, ...) - - *tlib#bitwise#XOR()* -tlib#bitwise#XOR(num1, num2, ...) - - *tlib#bitwise#ShiftRight()* -tlib#bitwise#ShiftRight(bits, n) - - *tlib#bitwise#ShiftLeft()* -tlib#bitwise#ShiftLeft(bits, n) - - *tlib#bitwise#Add()* -tlib#bitwise#Add(num1, num2, ...) - - *tlib#bitwise#Sub()* -tlib#bitwise#Sub(num1, num2, ...) - - -======================================================================== -autoload/tlib/url.vim~ - - *tlib#url#Decode()* -tlib#url#Decode(url) - Decode an encoded URL. - - *tlib#url#DecodeChar()* -tlib#url#DecodeChar(char) - Decode a single character. - - *tlib#url#EncodeChar()* -tlib#url#EncodeChar(char) - Encode a single character. - - *tlib#url#Encode()* -tlib#url#Encode(url, ...) - Encode an URL. - - -======================================================================== -autoload/tlib/signs.vim~ - - *tlib#signs#ClearAll()* -tlib#signs#ClearAll(sign) - Clear all signs with name SIGN. - - *tlib#signs#ClearBuffer()* -tlib#signs#ClearBuffer(sign, bufnr) - Clear all signs with name SIGN in buffer BUFNR. - - *tlib#signs#Mark()* -tlib#signs#Mark(sign, list) - Add signs for all locations in LIST. LIST must adhere with the - quickfix list format (see |getqflist()|; only the fields lnum and - bufnr are required). - - list:: a quickfix or location list - sign:: a sign defined with |:sign-define| - - -======================================================================== -autoload/tlib/rx.vim~ - - *tlib#rx#Escape()* -tlib#rx#Escape(text, ?magic='m') - magic can be one of: m, M, v, V - See :help 'magic' - - *tlib#rx#EscapeReplace()* -tlib#rx#EscapeReplace(text, ?magic='m') - Escape return |sub-replace-special|. - - *tlib#rx#Suffixes()* -tlib#rx#Suffixes(...) - - *tlib#rx#LooksLikeRegexp()* -tlib#rx#LooksLikeRegexp(text) - - -======================================================================== -autoload/tlib/tag.vim~ - - *g:tlib_tags_extra* -g:tlib_tags_extra (default: '') - Extra tags for |tlib#tag#Retrieve()| (see there). Can also be buffer-local. - - *g:tlib_tag_substitute* -g:tlib_tag_substitute - Filter the tag description through |substitute()| for these filetypes. - This applies only if the tag cmd field (see |taglist()|) is used. - - *tlib#tag#Retrieve()* -tlib#tag#Retrieve(rx, ?extra_tags=0) - Get all tags matching rx. Basically, this function simply calls - |taglist()|, but when extra_tags is true, the list of the tag files - (see 'tags') is temporarily expanded with |g:tlib_tags_extra|. - - Example use: - If you want to include tags for, eg, JDK, normal tags use can become - slow. You could proceed as follows: - 1. Create a tags file for the JDK sources. When creating the tags - file, make sure to include inheritance information and the like - (command-line options like --fields=+iaSm --extra=+q should be ok). - In this example, we want tags only for public methods (there are - most likely better ways to do this): > - ctags -R --fields=+iaSm --extra=+q ${JAVA_HOME}/src - head -n 6 tags > tags0 - grep access:public tags >> tags0 -< 2. Make 'tags' include project specific tags files. In - ~/vimfiles/after/ftplugin/java.vim insert: > - let b:tlib_tags_extra = $JAVA_HOME .'/tags0' -< 3. When this function is invoked as > - echo tlib#tag#Retrieve('print') -< it will return only project-local tags. If it is invoked as > - echo tlib#tag#Retrieve('print', 1) -< tags from the JDK will be included. - - *tlib#tag#Collect()* -tlib#tag#Collect(constraints, ?use_extra=1, ?match_front=1) - Retrieve tags that meet the constraints (a dictionnary of fields and - regexp, with the exception of the kind field which is a list of chars). - For the use of the optional use_extra argument see - |tlib#tag#Retrieve()|. - - *tlib#tag#Format()* -tlib#tag#Format(tag) - - -======================================================================== -autoload/tlib/map.vim~ - - *tlib#map#PumAccept()* -tlib#map#PumAccept(key) - If |pumvisible()| is true, return "\". Otherwise return a:key. - For use in maps like: > - imap tlib#map#PumAccept("\") + *tlib#dir#NativeName()* +tlib#dir#NativeName(dirname) + EXAMPLES: > + tlib#dir#NativeName('foo/bar/') + On Windows: + => 'foo\bar\' + On Linux: + => 'foo/bar/' < + *tlib#dir#PlainName()* +tlib#dir#PlainName(dirname) + EXAMPLES: > + tlib#dir#PlainName('foo/bar/') + => 'foo/bar' +< -======================================================================== -autoload/tlib/Filter_cnfd.vim~ + *tlib#dir#Ensure()* +tlib#dir#Ensure(dir) + Create a directory if it doesn't already exist. - *tlib#Filter_cnfd#New()* -tlib#Filter_cnfd#New(...) - The same as |tlib#Filter_cnf#New()| but a dot is expanded to '\.\{-}'. - As a consequence, patterns cannot match dots. - The pattern is a '/\V' very no-'/magic' regexp pattern. + *tlib#dir#MyRuntime()* +tlib#dir#MyRuntime() + Return the first directory in &rtp. -======================================================================== -autoload/tlib/input.vim~ +------------------------------------------------------------------------ + *autoload/tlib/file.vim* + *g:tlib#file#drop* +g:tlib#file#drop (default: has('gui')) + If true, use |:drop| to edit loaded buffers (only available with GUI). + + *tlib#file#Split()* +tlib#file#Split(filename) + EXAMPLES: > + tlib#file#Split('foo/bar/filename.txt') + => ['foo', 'bar', 'filename.txt'] +< + + *tlib#file#Join()* +tlib#file#Join(filename_parts, ?strip_slashes=1, ?maybe_absolute=0) + EXAMPLES: > + tlib#file#Join(['foo', 'bar', 'filename.txt']) + => 'foo/bar/filename.txt' +< + + *tlib#file#Relative()* +tlib#file#Relative(filename, basedir) + EXAMPLES: > + tlib#file#Relative('foo/bar/filename.txt', 'foo') + => 'bar/filename.txt' +< + + *tlib#file#Edit()* +tlib#file#Edit(fileid) + Return 0 if the file isn't readable/doesn't exist. + Otherwise return 1. + + +------------------------------------------------------------------------ + *autoload/tlib/hook.vim* + *tlib#hook#Run()* +tlib#hook#Run(hook, ?dict={}) + Execute dict[hook], w:{hook}, b:{hook}, or g:{hook} if existent. + + +------------------------------------------------------------------------ + *autoload/tlib/input.vim* Input-related, select from a list etc. *g:tlib#input#sortprefs_threshold* @@ -1546,15 +885,6 @@ g:tlib_pick_last_item (default: 1) Keys for |tlib#input#List|~ - *g:tlib#input#and* -g:tlib#input#and (default: ' ') - - *g:tlib#input#or* -g:tlib#input#or (default: '|') - - *g:tlib#input#not* -g:tlib#input#not (default: '-') - *g:tlib#input#numeric_chars* g:tlib#input#numeric_chars When editing a list with |tlib#input#List|, typing these numeric chars @@ -1580,12 +910,6 @@ g:tlib#input#keyagents_InputList_s \ 11: 'tlib#agent#Up' \ } - *g:tlib#input#keyagents_InputList_m* -g:tlib#input#keyagents_InputList_m - - *g:tlib#input#handlers_EditList* -g:tlib#input#handlers_EditList - *g:tlib#input#user_shortcuts* g:tlib#input#user_shortcuts (default: {}) A dictionary KEY => {'agent': AGENT, 'key_name': KEY_NAME} to @@ -1670,9 +994,6 @@ tlib#input#EditList(query, list, ?timeout=0) echo tlib#input#EditList('Edit:', [100,200,300]) < - *tlib#input#Resume()* -tlib#input#Resume(name, pick, bufnr) - *tlib#input#CommandSelect()* tlib#input#CommandSelect(command, ?keyargs={}) Take a command, view the output, and let the user select an item from @@ -1700,159 +1021,120 @@ tlib#input#Edit(name, value, callback, ?cb_args=[]) call tlib#input#Edit('foo', b:var, 'FooContinue') < - *tlib#input#Dialog()* -tlib#input#Dialog(text, options, default) - -======================================================================== -autoload/tlib/number.vim~ - - *tlib#number#ConvertBase()* -tlib#number#ConvertBase(num, base, ...) - - -======================================================================== -autoload/tlib/file.vim~ - - *g:tlib#file#drop* -g:tlib#file#drop (default: has('gui')) - If true, use |:drop| to edit loaded buffers (only available with GUI). - - *g:tlib#file#use_tabs* -g:tlib#file#use_tabs (default: 0) - - *g:tlib#file#edit_cmds* -g:tlib#file#edit_cmds (default: g:tlib#file#use_tabs ? {'buffer': 'tab split | buffer', 'edit': 'tabedit'} : {}) - - *g:tlib#file#absolute_filename_rx* -g:tlib#file#absolute_filename_rx (default: '^\~\?[\/]') - - *tlib#file#Split()* -tlib#file#Split(filename) +------------------------------------------------------------------------ + *autoload/tlib/list.vim* + *tlib#list#Inject()* +tlib#list#Inject(list, initial_value, funcref) EXAMPLES: > - tlib#file#Split('foo/bar/filename.txt') - => ['foo', 'bar', 'filename.txt'] + echo tlib#list#Inject([1,2,3], 0, function('Add') + => 6 < - *tlib#file#Join()* -tlib#file#Join(filename_parts, ?strip_slashes=1, ?maybe_absolute=0) + *tlib#list#Compact()* +tlib#list#Compact(list) EXAMPLES: > - tlib#file#Join(['foo', 'bar', 'filename.txt']) - => 'foo/bar/filename.txt' + tlib#list#Compact([0,1,2,3,[], {}, ""]) + => [1,2,3] < - *tlib#file#Relative()* -tlib#file#Relative(filename, basedir) + *tlib#list#Flatten()* +tlib#list#Flatten(list) EXAMPLES: > - tlib#file#Relative('foo/bar/filename.txt', 'foo') - => 'bar/filename.txt' + tlib#list#Flatten([0,[1,2,[3,""]]]) + => [0,1,2,3,""] < - *tlib#file#Absolute()* -tlib#file#Absolute(filename, ...) + *tlib#list#FindAll()* +tlib#list#FindAll(list, filter, ?process_expr="") + Basically the same as filter() - *tlib#file#Canonic()* -tlib#file#Canonic(filename, ...) + EXAMPLES: > + tlib#list#FindAll([1,2,3], 'v:val >= 2') + => [2, 3] +< - *tlib#file#With()* -tlib#file#With(fcmd, bcmd, files, ?world={}) + *tlib#list#Find()* +tlib#list#Find(list, filter, ?default="", ?process_expr="") - *tlib#file#Edit()* -tlib#file#Edit(fileid) - Return 0 if the file isn't readable/doesn't exist. - Otherwise return 1. + EXAMPLES: > + tlib#list#Find([1,2,3], 'v:val >= 2') + => 2 +< - *tlib#file#Glob()* -tlib#file#Glob(pattern) + *tlib#list#Any()* +tlib#list#Any(list, expr) + EXAMPLES: > + tlib#list#Any([1,2,3], 'v:val >= 2') + => 1 +< - *tlib#file#Globpath()* -tlib#file#Globpath(path, pattern) + *tlib#list#All()* +tlib#list#All(list, expr) + EXAMPLES: > + tlib#list#All([1,2,3], 'v:val >= 2') + => 0 +< + + *tlib#list#Remove()* +tlib#list#Remove(list, element) + EXAMPLES: > + tlib#list#Remove([1,2,1,2], 2) + => [1,1,2] +< + + *tlib#list#RemoveAll()* +tlib#list#RemoveAll(list, element) + EXAMPLES: > + tlib#list#RemoveAll([1,2,1,2], 2) + => [1,1] +< + + *tlib#list#Zip()* +tlib#list#Zip(lists, ?default='') + EXAMPLES: > + tlib#list#Zip([[1,2,3], [4,5,6]]) + => [[1,4], [2,5], [3,6]] +< -======================================================================== -autoload/tlib/sys.vim~ - - *g:tlib#sys#special_protocols* -g:tlib#sys#special_protocols (default: ['https\?', 'nntp', 'mailto']) - A list of |regexp|s matching protocol names that should be handled - by |g:tlib#sys#system_browser|. - CAVEAT: Must be a |\V| |regexp|. - - *g:tlib#sys#special_suffixes* -g:tlib#sys#special_suffixes (default: ['xlsx\?', 'docx\?', 'pptx\?', 'accdb', 'mdb', 'sqlite', 'pdf', 'jpg', 'png', 'gif']) - A list of |regexp|s matching suffixes that should be handled by - |g:tlib#sys#system_browser|. - CAVEAT: Must be a |\V| |regexp|. - - *g:tlib#sys#system_rx* -g:tlib#sys#system_rx (default: printf('\V\%(\^\%(%s\):\|.\%(%s\)\)', join(g:tlib#sys#special_protocols, '\|'), join(g:tlib#sys#special_suffixes, '\|'))) - Open links matching this |regexp| with |g:tlib#sys#system_browser|. - CAVEAT: Must be a |\V| |regexp|. - - *g:tlib#sys#system_browser* -g:tlib#sys#system_browser (default: ...) - Open files in the system browser. - - *g:tlib#sys#windows* -g:tlib#sys#windows (default: &shell !~ 'sh' && (has('win16') || has('win32') || has('win64'))) - - *g:tlib#sys#null* -g:tlib#sys#null (default: g:tlib#sys#windows ? 'NUL' : (filereadable('/dev/null') ? '/dev/null' : '')) - - *tlib#sys#IsCygwinBin()* -tlib#sys#IsCygwinBin(cmd) - - *tlib#sys#IsExecutable()* -tlib#sys#IsExecutable(cmd, ...) - - *g:tlib#sys#check_cygpath* -g:tlib#sys#check_cygpath (default: g:tlib#sys#windows && tlib#sys#IsExecutable('cygpath', 1)) - If true, check whether we have to convert a path via cyppath -- - see |tlib#sys#MaybeUseCygpath| - - *g:tlib#sys#cygwin_path_rx* -g:tlib#sys#cygwin_path_rx (default: '/cygwin/') - If a full windows filename (with slashes instead of backslashes) - matches this |regexp|, it is assumed to be a cygwin executable. - - *g:tlib#sys#cygwin_expr* -g:tlib#sys#cygwin_expr (default: '"bash -c ''". escape(%s, "''\\") ."''"') - For cygwin binaries, convert command calls using this vim - expression. - - *tlib#sys#GetCmd()* -tlib#sys#GetCmd(cmd) - - *tlib#sys#MaybeUseCygpath()* -tlib#sys#MaybeUseCygpath(cmd) - If cmd seems to be a cygwin executable, use cygpath to convert - filenames. This assumes that cygwin's which command returns full - filenames for non-cygwin executables. - - *tlib#sys#ConvertPath()* -tlib#sys#ConvertPath(converter, filename) - - *tlib#sys#FileArgs()* -tlib#sys#FileArgs(cmd, files) - - *tlib#sys#IsSpecial()* -tlib#sys#IsSpecial(filename) - Check whether filename matches |g:tlib#sys#system_rx|, i.e. whether it - is a special file that should not be opened in vim. - - *tlib#sys#Open()* -tlib#sys#Open(filename) - Open filename with the default OS application (see - |g:tlib#sys#system_browser|), if |tlib#sys#IsSpecial()| return 1. - Returns 1 if successful or 0 otherwise. - - *tlib#sys#SystemInDir()* -tlib#sys#SystemInDir(dir, expr, ?input='') +------------------------------------------------------------------------ + *autoload/tlib/map.vim* + *tlib#map#PumAccept()* +tlib#map#PumAccept(key) + If |pumvisible()| is true, return "\". Otherwise return a:key. + For use in maps like: > + imap tlib#map#PumAccept("\") +< -======================================================================== -autoload/tlib/paragraph.vim~ +------------------------------------------------------------------------ + *autoload/tlib/normal.vim* + *tlib#normal#WithRegister()* +tlib#normal#WithRegister(cmd, ?register='t', ?norm_cmd='norm!') + Execute a normal command while maintaining all registers. + +------------------------------------------------------------------------ + *autoload/tlib/notify.vim* + *tlib#notify#Echo()* +tlib#notify#Echo(text, ?style='') + Print text in the echo area. Temporarily disable 'ruler' and 'showcmd' + in order to prevent |press-enter| messages. + + *tlib#notify#TrimMessage()* +tlib#notify#TrimMessage(message) + Contributed by Erik Falor: + If the line containing the message is too long, echoing it will cause + a 'Hit ENTER' prompt to appear. This function cleans up the line so + that does not happen. + The echoed line is too long if it is wider than the width of the + window, minus cmdline space taken up by the ruler and showcmd + features. + + +------------------------------------------------------------------------ + *autoload/tlib/paragraph.vim* *tlib#paragraph#GetMetric()* tlib#paragraph#GetMetric() Return an object describing a |paragraph|. @@ -1872,50 +1154,193 @@ tlib#paragraph#Move(direction, count) < -======================================================================== -autoload/tlib/World.vim~ -A prototype used by |tlib#input#List|. -Inherits from |tlib#Object#New|. +------------------------------------------------------------------------ + *autoload/tlib/persistent.vim* + *g:tlib_persistent* +g:tlib_persistent (default: '') + The directory for persistent data files. If empty, use + |tlib#dir#MyRuntime|.'/share'. - *g:tlib_inputlist_pct* -g:tlib_inputlist_pct (default: 50) - Size of the input list window (in percent) from the main size (of &lines). + *tlib#persistent#Dir()* +tlib#persistent#Dir(?mode = 'bg') + Return the full directory name for persistent data files. + + *tlib#persistent#EncodedFilename()* +tlib#persistent#EncodedFilename(type, file, ?mkdir=0, ?dir='') + Encode `file` and call |tlib#persistent#Filename()|. + + +------------------------------------------------------------------------ + *autoload/tlib/progressbar.vim* + *tlib#progressbar#Init()* +tlib#progressbar#Init(max, ...) + EXAMPLE: > + call tlib#progressbar#Init(20) + try + for i in range(20) + call tlib#progressbar#Display(i) + call DoSomethingThatTakesSomeTime(i) + endfor + finally + call tlib#progressbar#Restore() + endtry +< + + +------------------------------------------------------------------------ + *autoload/tlib/rx.vim* + *tlib#rx#Escape()* +tlib#rx#Escape(text, ?magic='m') + magic can be one of: m, M, v, V + See :help 'magic' + + *tlib#rx#EscapeReplace()* +tlib#rx#EscapeReplace(text, ?magic='m') + Escape return |sub-replace-special|. + + +------------------------------------------------------------------------ + *autoload/tlib/scratch.vim* + *g:tlib_scratch_pos* +g:tlib_scratch_pos (default: 'botright') + Scratch window position. By default the list window is opened on the + bottom. Set this variable to 'topleft' or '' to change this behaviour. See |tlib#input#List()|. - *g:tlib_inputlist_width_filename* -g:tlib_inputlist_width_filename (default: '&co / 3') - Size of filename columns when listing filenames. - See |tlib#input#List()|. + *g:tlib#scratch#hidden* +g:tlib#scratch#hidden (default: 'hide') + If you want the scratch buffer to be fully removed, you might want to + set this variable to 'wipe'. + See also https://github.com/tomtom/tlib_vim/pull/16 - *g:tlib_inputlist_filename_indicators* -g:tlib_inputlist_filename_indicators (default: 0) - If true, |tlib#input#List()| will show some indicators about the - status of a filename (e.g. buflisted(), bufloaded() etc.). - This is disabled by default because vim checks also for the file on - disk when doing this. + *tlib#scratch#UseScratch()* +tlib#scratch#UseScratch(?keyargs={}) + Display a scratch buffer (a buffer with no file). See :TScratch for an + example. + Return the scratch buffer's number. + Values for keyargs: + scratch_split ... 1: split, 0: window, -1: tab - *g:tlib_inputlist_shortmessage* -g:tlib_inputlist_shortmessage (default: 0) - If not null, display only a short info about the filter. - - *tlib#World#New()* -tlib#World#New(...) - -prototype.PrintLines - -prototype.Suspend + *tlib#scratch#CloseScratch()* +tlib#scratch#CloseScratch(keyargs, ...) + Close a scratch buffer as defined in keyargs (usually a World). + Return 1 if the scratch buffer is closed (or if it already was + closed). -======================================================================== -autoload/tlib/loclist.vim~ - - *tlib#loclist#Browse()* -tlib#loclist#Browse(...) +------------------------------------------------------------------------ + *autoload/tlib/selection.vim* + *tlib#selection#GetSelection()* +tlib#selection#GetSelection(mode, ?mbeg="'<", ?mend="'>", ?opmode='selection') + mode can be one of: selection, lines, block -======================================================================== -autoload/tlib/tab.vim~ +------------------------------------------------------------------------ + *autoload/tlib/signs.vim* + *tlib#signs#ClearAll()* +tlib#signs#ClearAll(sign) + Clear all signs with name SIGN. + *tlib#signs#ClearBuffer()* +tlib#signs#ClearBuffer(sign, bufnr) + Clear all signs with name SIGN in buffer BUFNR. + + *tlib#signs#Mark()* +tlib#signs#Mark(sign, list) + Add signs for all locations in LIST. LIST must adhere with the + quickfix list format (see |getqflist()|; only the fields lnum and + bufnr are required). + + list:: a quickfix or location list + sign:: a sign defined with |:sign-define| + + +------------------------------------------------------------------------ + *autoload/tlib/string.vim* + *tlib#string#RemoveBackslashes()* +tlib#string#RemoveBackslashes(text, ?chars=' ') + Remove backslashes from text (but only in front of the characters in + chars). + + *tlib#string#Format()* +tlib#string#Chomp(string, ?max=0) + Format a template string. Placeholders have the format "%{NAME}". A + "%" can be inserted as "%%". + + Examples: + echo tlib#string#Format("foo %{bar} foo", {'bar': 123}, ?prefix='%') + => foo 123 foo + + *tlib#string#Printf1()* +tlib#string#Printf1(format, string) + This function deviates from |printf()| in certain ways. + Additional items: + %{rx} ... insert escaped regexp + %{fuzzyrx} ... insert typo-tolerant regexp + + +------------------------------------------------------------------------ + *autoload/tlib/sys.vim* + *g:tlib#sys#special_protocols* +g:tlib#sys#special_protocols (default: ['https\?', 'nntp', 'mailto']) + A list of |regexp|s matching protocol names that should be handled + by |g:tlib#sys#system_browser|. + CAVEAT: Must be a |\V| |regexp|. + + *g:tlib#sys#special_suffixes* +g:tlib#sys#special_suffixes (default: ['xlsx\?', 'docx\?', 'pptx\?', 'accdb', 'mdb', 'sqlite', 'pdf', 'jpg', 'png', 'gif', 'od\[tspg]']) + A list of |regexp|s matching suffixes that should be handled by + |g:tlib#sys#system_browser|. + CAVEAT: Must be a |\V| |regexp|. + + *g:tlib#sys#system_rx* +g:tlib#sys#system_rx (default: printf('\V\%(\^\%(%s\):\|.\%(%s\)\$\)', join(g:tlib#sys#special_protocols, '\|'), join(g:tlib#sys#special_suffixes, '\|'))) + Open links matching this |regexp| with |g:tlib#sys#system_browser|. + CAVEAT: Must be a |\V| |regexp|. + + *g:tlib#sys#system_browser* +g:tlib#sys#system_browser (default: ...) + Open files in the system browser. + + *g:tlib#sys#check_cygpath* +g:tlib#sys#check_cygpath (default: g:tlib#sys#windows && tlib#sys#IsExecutable('cygpath', 1)) + If true, check whether we have to convert a path via cyppath -- + see |tlib#sys#MaybeUseCygpath| + + *g:tlib#sys#cygwin_path_rx* +g:tlib#sys#cygwin_path_rx (default: '/cygwin/') + If a full windows filename (with slashes instead of backslashes) + matches this |regexp|, it is assumed to be a cygwin executable. + + *g:tlib#sys#cygwin_expr* +g:tlib#sys#cygwin_expr (default: '"bash -c ''". escape(%s, "''\\") ."''"') + For cygwin binaries, convert command calls using this vim + expression. + + *tlib#sys#MaybeUseCygpath()* +tlib#sys#MaybeUseCygpath(cmd) + If cmd seems to be a cygwin executable, use cygpath to convert + filenames. This assumes that cygwin's which command returns full + filenames for non-cygwin executables. + + *tlib#sys#IsSpecial()* +tlib#sys#IsSpecial(filename) + Check whether filename matches |g:tlib#sys#system_rx|, i.e. whether it + is a special file that should not be opened in vim. + + *tlib#sys#Open()* +tlib#sys#Open(filename) + Open filename with the default OS application (see + |g:tlib#sys#system_browser|), if |tlib#sys#IsSpecial()| return 1. + Returns 1 if successful or 0 otherwise. + + *tlib#sys#OpenWithSystemViewer()* +tlib#sys#OpenWithSystemViewer(filename) + Open filename with the default system viewer. + + +------------------------------------------------------------------------ + *autoload/tlib/tab.vim* *tlib#tab#BufMap()* tlib#tab#BufMap() Return a dictionary of bufnumbers => [[tabpage, winnr] ...] @@ -1924,99 +1349,54 @@ tlib#tab#BufMap() tlib#tab#TabWinNr(buffer) Find a buffer's window at some tab page. - *tlib#tab#Set()* -tlib#tab#Set(tabnr) + +------------------------------------------------------------------------ + *autoload/tlib/tag.vim* + *g:tlib_tags_extra* +g:tlib_tags_extra (default: '') + Extra tags for |tlib#tag#Retrieve()| (see there). Can also be buffer-local. + + *g:tlib_tag_substitute* +g:tlib_tag_substitute + Filter the tag description through |substitute()| for these filetypes. + This applies only if the tag cmd field (see |taglist()|) is used. + + *tlib#tag#Retrieve()* +tlib#tag#Retrieve(rx, ?extra_tags=0) + Get all tags matching rx. Basically, this function simply calls + |taglist()|, but when extra_tags is true, the list of the tag files + (see 'tags') is temporarily expanded with |g:tlib_tags_extra|. + + Example use: + If you want to include tags for, eg, JDK, normal tags use can become + slow. You could proceed as follows: + 1. Create a tags file for the JDK sources. When creating the tags + file, make sure to include inheritance information and the like + (command-line options like --fields=+iaSm --extra=+q should be ok). + In this example, we want tags only for public methods (there are + most likely better ways to do this): > + ctags -R --fields=+iaSm --extra=+q ${JAVA_HOME}/src + head -n 6 tags > tags0 + grep access:public tags >> tags0 +< 2. Make 'tags' include project specific tags files. In + ~/vimfiles/after/ftplugin/java.vim insert: > + let b:tlib_tags_extra = $JAVA_HOME .'/tags0' +< 3. When this function is invoked as > + echo tlib#tag#Retrieve('print') +< it will return only project-local tags. If it is invoked as > + echo tlib#tag#Retrieve('print', 1) +< tags from the JDK will be included. + + *tlib#tag#Collect()* +tlib#tag#Collect(constraints, ?use_extra=1, ?match_front=1) + Retrieve tags that meet the constraints (a dictionnary of fields and + regexp, with the exception of the kind field which is a list of chars). + For the use of the optional use_extra argument see + |tlib#tag#Retrieve()|. -======================================================================== -autoload/tlib/date.vim~ - - *tlib#date#IsDate()* -tlib#date#IsDate(text) - - *tlib#date#Format()* -tlib#date#Format(secs1970) - - *tlib#date#DiffInDays()* -tlib#date#DiffInDays(date1, ?date2=localtime(), ?allow_zero=0) - - *tlib#date#Parse()* -tlib#date#Parse(date, ?allow_zero=0) "{{{3 - - *tlib#date#SecondsSince1970()* -tlib#date#SecondsSince1970(date, ...) - tlib#date#SecondsSince1970(date, ?daysshift=0, ?allow_zero=0) - - *tlib#date#Shift()* -tlib#date#Shift(date, shift) - - -======================================================================== -autoload/tlib/type.vim~ - - *tlib#type#IsNumber()* -tlib#type#IsNumber(expr) - - *tlib#type#IsString()* -tlib#type#IsString(expr) - - *tlib#type#IsFuncref()* -tlib#type#IsFuncref(expr) - - *tlib#type#IsList()* -tlib#type#IsList(expr) - - *tlib#type#IsDictionary()* -tlib#type#IsDictionary(expr) - - *tlib#type#Is()* -tlib#type#Is(val, type) - - *tlib#type#Are()* -tlib#type#Are(vals, type) - - *tlib#type#Has()* -tlib#type#Has(val, lst) - - *tlib#type#Have()* -tlib#type#Have(vals, lst) - - -======================================================================== -autoload/tlib/Filter_fuzzy.vim~ - - *tlib#Filter_fuzzy#New()* -tlib#Filter_fuzzy#New(...) - Support for "fuzzy" pattern matching in |tlib#input#List()|. - Patterns are interpreted as if characters were connected with '.\{-}'. - - In "fuzzy" mode, the pretty printing of filenames is disabled. - - -======================================================================== -autoload/tlib/assert.vim~ - - *tlib#assert#Enable()* -tlib#assert#Enable() - Enable tracing via |:Tlibassert|. - - *tlib#assert#Disable()* -tlib#assert#Disable() - Disable tracing via |:Tlibassert|. - - *tlib#assert#Assert()* -tlib#assert#Assert(caller, check, vals) - - *tlib#assert#Map()* -tlib#assert#Map(vals, expr) - - *tlib#assert#All()* -tlib#assert#All(vals) - - -======================================================================== -autoload/tlib/textobjects.vim~ - +------------------------------------------------------------------------ + *autoload/tlib/textobjects.vim* *standard-paragraph* tlib#textobjects#StandardParagraph() Select a "Standard Paragraph", i.e. a text block followed by blank @@ -2029,468 +1409,201 @@ tlib#textobjects#StandardParagraph() < Return 1, if the paragraph is the last one in the document. - *tlib#textobjects#Init()* -tlib#textobjects#Init() - *v_sp* v_sp ... :call tlib#textobjects#StandardParagraph() sp ... Standard paragraph (for use as |text-objects|). - *o_sp* -o_sp ... :normal Vsp + +------------------------------------------------------------------------ + *autoload/tlib/trace.vim* + *g:tlib#trace#backtrace* +g:tlib#trace#backtrace (default: 2) + The length of the backtrace that should be included in + |tlib#trace#Print()|. + + *g:tlib#trace#printer* +g:tlib#trace#printer (default: 'echom') + Possible values: + - 'echom' + - ['file', FILENAME] + + *tlib#trace#Printer_echom()* +tlib#trace#Printer_echom(type, text, args) + Print traces from |tlib#trace#Print()|. + + *tlib#trace#Set()* +tlib#trace#Set(vars, ...) + Set the tracing |regexp|. See |:Tlibtrace|. + This will also call |tlib#trace#Enable()|. + + Examples: + call tlib#trace#Set(["+foo", "-bar"]) + call tlib#trace#Set("+foo,-bar") + + *tlib#trace#Print()* +tlib#trace#Print(caller, vars, values) + Print the values of vars. The first value is a "guard" (see + |:Tlibtrace|). + + *tlib#trace#Enable()* +tlib#trace#Enable() + Enable tracing via |:Tlibtrace|. + + *tlib#trace#Disable()* +tlib#trace#Disable() + Disable tracing via |:Tlibtrace|. -======================================================================== -autoload/tlib/arg.vim~ +------------------------------------------------------------------------ + *autoload/tlib/type.vim* + *tlib#type#Enable()* +tlib#type#Enable() + Enable type assertiona via |:Tlibtype|. - *tlib#arg#Get()* -tlib#arg#Get(n, var, ?default="", ?test='') - Set a positional argument from a variable argument list. - See tlib#string#RemoveBackslashes() for an example. + *tlib#type#Disable()* +tlib#type#Disable() + Disable type assertiona via |:Tlibtype|. - *tlib#arg#Let()* -tlib#arg#Let(list, ?default='') - Set a positional arguments from a variable argument list. - See tlib#input#List() for an example. - *tlib#arg#StringAsKeyArgs()* -tlib#arg#StringAsKeyArgs(string, ?keys=[], ?evaluate=0, ?sep=':', ?booleans=0) +------------------------------------------------------------------------ + *autoload/tlib/url.vim* + *tlib#url#Decode()* +tlib#url#Decode(url) + Decode an encoded URL. - *tlib#arg#StringAsKeyArgsEqual()* -tlib#arg#StringAsKeyArgsEqual(string) + *tlib#url#DecodeChar()* +tlib#url#DecodeChar(char) + Decode a single character. - *tlib#arg#GetOpts()* -tlib#arg#GetOpts(args, ?def={}) - Convert a list of strings of command-line arguments into a dictonary. + *tlib#url#EncodeChar()* +tlib#url#EncodeChar(char) + Encode a single character. - The main use case is to pass [], i.e. the command-line - arguments of a command as list, from a command definition to this - function. + *tlib#url#Encode()* +tlib#url#Encode(url, ...) + Encode an URL. - Example: - ['-h'] - => If def contains a 'help' key, invoke |:help| on its value. - ['-ab', '--foo', '--bar=BAR', 'bla', bla'] - => {'a': 1, 'b': 1, 'foo': 1, 'bar': 'BAR', '__rest__': ['bla', 'bla']} - - ['-ab', '--', '--foo', '--bar=BAR'] - => {'a': 1, 'b': 1, '__rest__': ['--foo', '--bar=BAR']} - - *tlib#arg#Ex()* -tlib#arg#Ex(arg, ?chars='%#! ') - Escape some characters in a string. - - Use |fnamescape()| if available. +------------------------------------------------------------------------ + *autoload/tlib/var.vim* + *tlib#var#Let()* +tlib#var#Let(name, val) + Define a variable called NAME if yet undefined. + You can also use the :TLLet command. EXAMPLES: > - exec 'edit '. tlib#arg#Ex('foo%#bar.txt') + exec tlib#var#Let('g:foo', 1) + TLet g:foo = 1 < + *tlib#var#EGet()* +tlib#var#EGet(var, namespace, ?default='') + Retrieve a variable by searching several namespaces. -======================================================================== -autoload/tlib/fixes.vim~ - - *tlib#fixes#Winpos()* -tlib#fixes#Winpos() - - -======================================================================== -autoload/tlib/dir.vim~ - - *g:tlib#dir#sep* -g:tlib#dir#sep (default: exists('+shellslash') && !&shellslash ? '\' : '/') - TLet g:tlib#dir#sep = '/' - - *tlib#dir#CanonicName()* -tlib#dir#CanonicName(dirname) EXAMPLES: > - tlib#dir#CanonicName('foo/bar') - => 'foo/bar/' + let g:foo = 1 + let b:foo = 2 + let w:foo = 3 + echo eval(tlib#var#EGet('foo', 'vg')) => 1 + echo eval(tlib#var#EGet('foo', 'bg')) => 2 + echo eval(tlib#var#EGet('foo', 'wbg')) => 3 < - *tlib#dir#NativeName()* -tlib#dir#NativeName(dirname) + *tlib#var#Get()* +tlib#var#Get(var, namespace, ?default='') + Retrieve a variable by searching several namespaces. + EXAMPLES: > - tlib#dir#NativeName('foo/bar/') - On Windows: - => 'foo\bar\' - On Linux: - => 'foo/bar/' + let g:foo = 1 + let b:foo = 2 + let w:foo = 3 + echo tlib#var#Get('foo', 'bg') => 1 + echo tlib#var#Get('foo', 'bg') => 2 + echo tlib#var#Get('foo', 'wbg') => 3 < - *tlib#dir#PlainName()* -tlib#dir#PlainName(dirname) - EXAMPLES: > - tlib#dir#PlainName('foo/bar/') - => 'foo/bar' -< - - *tlib#dir#Ensure()* -tlib#dir#Ensure(dir) - Create a directory if it doesn't already exist. - - *tlib#dir#MyRuntime()* -tlib#dir#MyRuntime() - Return the first directory in &rtp. - - *tlib#dir#CD()* -tlib#dir#CD(dir, ?locally=0) - - *tlib#dir#Push()* -tlib#dir#Push(dir, ?locally=0) - - *tlib#dir#Pop()* -tlib#dir#Pop() + *tlib#var#List()* +tlib#var#List(rx, ?prefix='') + Get a list of variables matching rx. + EXAMPLE: + echo tlib#var#List('tlib_', 'g:') -======================================================================== -autoload/tlib/hash.vim~ +------------------------------------------------------------------------ + *autoload/tlib/vcs.vim* + *g:tlib#vcs#def* +g:tlib#vcs#def {...} + A dictionarie of supported VCS (currently: git, hg, svn, bzr). - *g:tlib#hash#use_crc32* -g:tlib#hash#use_crc32 (default: '') + *g:tlib#vcs#executables* +g:tlib#vcs#executables {...} + A dictionary of custom executables for VCS commands. If the value is + empty, support for that VCS will be removed. If no key is present, it + is assumed that the VCS "type" is the name of the executable. - *g:tlib#hash#use_adler32* -g:tlib#hash#use_adler32 (default: '') + *g:tlib#vcs#check* +g:tlib#vcs#check (default: has('win16') || has('win32') || has('win64') ? '%s.exe' : '%s') + If non-empty, use it as a format string to check whether a VCS is + installed on your computer. - *tlib#hash#CRC32B()* -tlib#hash#CRC32B(chars) + *tlib#vcs#Ls()* +tlib#vcs#Ls(?filename=bufname('%'), ?vcs=[type, dir]) + Return the files under VCS. - *tlib#hash#CRC32B_ruby()* -tlib#hash#CRC32B_ruby(chars) - - *tlib#hash#CRC32B_vim()* -tlib#hash#CRC32B_vim(chars) - - *tlib#hash#Adler32()* -tlib#hash#Adler32(chars) - - *tlib#hash#Adler32_vim()* -tlib#hash#Adler32_vim(chars) - - *tlib#hash#Adler32_tlib()* -tlib#hash#Adler32_tlib(chars) + *tlib#vcs#Diff()* +tlib#vcs#Diff(filename, ?vcs=[type, dir]) + Return the diff for "filename" -======================================================================== -autoload/tlib/win.vim~ +------------------------------------------------------------------------ + *autoload/tlib/vim.vim* + *g:tlib#vim#simalt_maximize* +g:tlib#vim#simalt_maximize (default: 'x') + The alt-key for maximizing the window. + CAUTION: The value of this paramter depends on your locale and + maybe the windows version you are running. + *g:tlib#vim#simalt_restore* +g:tlib#vim#simalt_restore (default: 'r') + The alt-key for restoring the window. + CAUTION: The value of this paramter depends on your locale and + maybe the windows version you are running. + + *g:tlib#vim#use_vimtweak* +g:tlib#vim#use_vimtweak (default: 0) + If true, use the vimtweak.dll for windows. This will enable + tlib to remove the caption for fullscreen windows. + + *tlib#vim#Maximize()* +tlib#vim#Maximize(fullscreen) + Maximize the window. + You might need to redefine |g:tlib#vim#simalt_maximize| if it doesn't + work for you. + + *tlib#vim#RestoreWindow()* +tlib#vim#RestoreWindow() + Restore the original vimsize after having called |tlib#vim#Maximize()|. + + *g:tlib#vim#use_wmctrl* +g:tlib#vim#use_wmctrl (default: executable('wmctrl')) + If true, use wmctrl for X windows to make a window + maximized/fullscreen. + + This is the preferred method for maximizing windows under X + windows. Some window managers have problem coping with the + default method of setting 'lines' and 'columns' to a large + value. + + +------------------------------------------------------------------------ + *autoload/tlib/win.vim* *tlib#win#Set()* tlib#win#Set(winnr) Return vim code to jump back to the original window. - *tlib#win#GetLayout()* -tlib#win#GetLayout(?save_view=0) - - *tlib#win#SetLayout()* -tlib#win#SetLayout(layout) - - *tlib#win#List()* -tlib#win#List() - - *tlib#win#Width()* -tlib#win#Width(wnr) - - *tlib#win#WinDo()* -tlib#win#WinDo(ex) - - -======================================================================== -autoload/tlib/comments.vim~ - - *tlib#comments#Comments()* -tlib#comments#Comments(...) - function! tlib#comments#Comments(?rx='') - - -======================================================================== -autoload/tlib/grep.vim~ - - *tlib#grep#Do()* -tlib#grep#Do(cmd, rx, files) - - *tlib#grep#LocList()* -tlib#grep#LocList(rx, files) - - *tlib#grep#QuickFixList()* -tlib#grep#QuickFixList(rx, files) - - *tlib#grep#List()* -tlib#grep#List(rx, files) - - -======================================================================== -autoload/tlib/qfl.vim~ - - *tlib#qfl#FormatQFLE()* -tlib#qfl#FormatQFLE(qfe) - - *tlib#qfl#QfeFilename()* -tlib#qfl#QfeFilename(qfe) - - *tlib#qfl#InitListBuffer()* -tlib#qfl#InitListBuffer(world) - - *tlib#qfl#SetSyntax()* -tlib#qfl#SetSyntax() - - *tlib#qfl#Balloon()* -tlib#qfl#Balloon() - - *tlib#qfl#AgentEditQFE()* -tlib#qfl#AgentEditQFE(world, selected, ...) - - *tlib#qfl#AgentPreviewQFE()* -tlib#qfl#AgentPreviewQFE(world, selected) - - *tlib#qfl#AgentGotoQFE()* -tlib#qfl#AgentGotoQFE(world, selected) - - *tlib#qfl#AgentWithSelected()* -tlib#qfl#AgentWithSelected(world, selected, ...) - - *tlib#qfl#RunCmdOnSelected()* -tlib#qfl#RunCmdOnSelected(world, selected, cmd, ...) - - *tlib#qfl#AgentSplitBuffer()* -tlib#qfl#AgentSplitBuffer(world, selected) - - *tlib#qfl#AgentTabBuffer()* -tlib#qfl#AgentTabBuffer(world, selected) - - *tlib#qfl#AgentVSplitBuffer()* -tlib#qfl#AgentVSplitBuffer(world, selected) - - *tlib#qfl#AgentEditLine()* -tlib#qfl#AgentEditLine(world, selected) - - *tlib#qfl#EditLine()* -tlib#qfl#EditLine(lnum) - - *tlib#qfl#SetFollowCursor()* -tlib#qfl#SetFollowCursor(world, selected) - - *tlib#qfl#QflList()* -tlib#qfl#QflList(list, ...) - - *tlib#qfl#Browse()* -tlib#qfl#Browse(...) - - -======================================================================== -autoload/tlib/Filter_cnf.vim~ - - *tlib#Filter_cnf#New()* -tlib#Filter_cnf#New(...) - The search pattern for |tlib#input#List()| is in conjunctive normal - form: (P1 OR P2 ...) AND (P3 OR P4 ...) ... - The pattern is a '/\V' very no-'/magic' regexp pattern. - - Pressing joins two patterns with AND. - Pressing | joins two patterns with OR. - I.e. In order to get "lala AND (foo OR bar)", you type - "lala foo|bar". - - This is also the base class for other filters. - -prototype.Pretty - - -======================================================================== -autoload/tlib/Object.vim~ -Provides a prototype plus some OO-like methods. - - *tlib#Object#New()* -tlib#Object#New(?fields={}) - This function creates a prototype that provides some kind of - inheritance mechanism and a way to call parent/super methods. - - The usage demonstrated in the following example works best when every - class/prototype is defined in a file of its own. - - The reason for why there is a dedicated constructor function is that - this layout facilitates the use of templates and that methods are - hidden from the user. Other solutions are possible. - - EXAMPLES: > - let s:prototype = tlib#Object#New({ - \ '_class': ['FooBar'], - \ 'foo': 1, - \ 'bar': 2, - \ }) - " Constructor - function! FooBar(...) - let object = s:prototype.New(a:0 >= 1 ? a:1 : {}) - return object - endf - function! s:prototype.babble() { - echo "I think, therefore I am ". (self.foo * self.bar) ." months old." - } - -< This could now be used like this: > - let myfoo = FooBar({'foo': 3}) - call myfoo.babble() - => I think, therefore I am 6 months old. - echo myfoo.IsA('FooBar') - => 1 - echo myfoo.IsA('object') - => 1 - echo myfoo.IsA('Foo') - => 0 - echo myfoo.RespondTo('babble') - => 1 - echo myfoo.RespondTo('speak') - => 0 -< - -prototype.New - -prototype.Inherit - -prototype.Extend - -prototype.IsA - -prototype.IsRelated - -prototype.RespondTo - -prototype.Super - - *tlib#Object#Methods()* -tlib#Object#Methods(object, ...) - - -======================================================================== -autoload/tlib/buffer.vim~ - - *g:tlib_viewline_position* -g:tlib_viewline_position (default: 'zz') - Where to display the line when using |tlib#buffer#ViewLine|. - For possible values for position see |scroll-cursor|. - - *tlib#buffer#EnableMRU()* -tlib#buffer#EnableMRU() - - *tlib#buffer#DisableMRU()* -tlib#buffer#DisableMRU() - - *tlib#buffer#Set()* -tlib#buffer#Set(buffer) - Set the buffer to buffer and return a command as string that can be - evaluated by |:execute| in order to restore the original view. - - *tlib#buffer#Eval()* -tlib#buffer#Eval(buffer, code) - Evaluate CODE in BUFFER. - - EXAMPLES: > - call tlib#buffer#Eval('foo.txt', 'echo b:bar') -< - - *tlib#buffer#GetList()* -tlib#buffer#GetList(?show_hidden=0, ?show_number=0, " ?order='bufnr') - Possible values for the "order" argument: - bufnr :: Default behaviour - mru :: Sort buffers according to most recent use - basename :: Sort by the file's basename (last component) - - NOTE: MRU order works on second invocation only. If you want to always - use MRU order, call tlib#buffer#EnableMRU() in your ~/.vimrc file. - - *tlib#buffer#ViewLine()* -tlib#buffer#ViewLine(line, ?position='z') - line is either a number or a string that begins with a number. - For possible values for position see |scroll-cursor|. - See also |g:tlib_viewline_position|. - - *tlib#buffer#HighlightLine()* -tlib#buffer#HighlightLine(...) - - *tlib#buffer#DeleteRange()* -tlib#buffer#DeleteRange(line1, line2) - Delete the lines in the current buffer. Wrapper for |:delete|. - - *tlib#buffer#ReplaceRange()* -tlib#buffer#ReplaceRange(line1, line2, lines) - Replace a range of lines. - - *tlib#buffer#ScratchStart()* -tlib#buffer#ScratchStart() - Initialize some scratch area at the bottom of the current buffer. - - *tlib#buffer#ScratchEnd()* -tlib#buffer#ScratchEnd() - Remove the in-buffer scratch area. - - *tlib#buffer#BufDo()* -tlib#buffer#BufDo(exec) - Run exec on all buffers via bufdo and return to the original buffer. - - *tlib#buffer#InsertText()* -tlib#buffer#InsertText(text, keyargs) - Keyargs: - 'shift': 0|N - 'col': col('.')|N - 'lineno': line('.')|N - 'indent': 0|1 - 'pos': 'e'|'s' ... Where to locate the cursor (somewhat like s and e in {offset}) - Insert text (a string) in the buffer. - - *tlib#buffer#InsertText0()* -tlib#buffer#InsertText0(text, ...) - - *tlib#buffer#CurrentByte()* -tlib#buffer#CurrentByte() - - *tlib#buffer#KeepCursorPosition()* -tlib#buffer#KeepCursorPosition(cmd) - Evaluate cmd while maintaining the cursor position and jump registers. - - -======================================================================== -autoload/tlib/hook.vim~ - - *tlib#hook#Run()* -tlib#hook#Run(hook, ?dict={}) - Execute dict[hook], w:{hook}, b:{hook}, or g:{hook} if existent. - - -======================================================================== -autoload/tlib/string.vim~ - - *tlib#string#RemoveBackslashes()* -tlib#string#RemoveBackslashes(text, ?chars=' ') - Remove backslashes from text (but only in front of the characters in - chars). - - *tlib#string#Chomp()* -tlib#string#Chomp(string, ?max=0) - - *tlib#string#Format()* -tlib#string#Format(template, dict) - - *tlib#string#Printf1()* -tlib#string#Printf1(format, string) - This function deviates from |printf()| in certain ways. - Additional items: - %{rx} ... insert escaped regexp - %{fuzzyrx} ... insert typo-tolerant regexp - - *tlib#string#TrimLeft()* -tlib#string#TrimLeft(string) - - *tlib#string#TrimRight()* -tlib#string#TrimRight(string) - - *tlib#string#Strip()* -tlib#string#Strip(string) - - *tlib#string#Count()* -tlib#string#Count(string, rx) - - *tlib#string#SplitCommaList()* -tlib#string#SplitCommaList(text, ...) + *tlib#win#SetById()* +tlib#win#SetById(win_id) + Return vim code to jump back to the original window. diff --git a/sources_non_forked/tlib/etc/tpl_tlib.txt b/sources_non_forked/tlib/etc/tpl_tlib.txt new file mode 100644 index 00000000..f8059703 --- /dev/null +++ b/sources_non_forked/tlib/etc/tpl_tlib.txt @@ -0,0 +1,30 @@ +*tlib.txt* tlib -- A library of vim functions + Author: Tom Link, micathom at gmail com + +This library provides some utility functions. There isn't much need to +install it unless another plugin requires you to do so. + +Most of the library is included in autoload files. No autocommands are +created. With the exception of loading ../plugin/02tlib.vim at startup +the library has no impact on startup time or anything else. + +The change-log is included at the bottom of ../plugin/02tlib.vim +(move the cursor over the file name and type gfG) + +Demo of |tlib#input#List()|: +http://vimsomnia.blogspot.com/2010/11/selecting-items-from-list-with-tlibs.html + + +----------------------------------------------------------------------- +Install~ + +Edit the vba file and type: > + + :so % + +See :help vimball for details. If you have difficulties, please make +sure, you have the current version of vimball (vimscript #1502) +installed. + + +%s diff --git a/sources_non_forked/tlib/macros/tlib.vim b/sources_non_forked/tlib/macros/tlib.vim new file mode 100644 index 00000000..3e5a7912 --- /dev/null +++ b/sources_non_forked/tlib/macros/tlib.vim @@ -0,0 +1,38 @@ +" @Author: Tom Link (micathom AT gmail com?subject=[vim]) +" @GIT: http://github.com/tomtom/tlib_vim/ +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Last Change: 2015-11-09. +" @Revision: 10 + +if &cp || exists("loaded_tlib_macros") + finish +endif +let loaded_tlib_macros = 1 + +let s:save_cpo = &cpo +set cpo&vim + + +" :display: :TRequire NAME [VERSION [FILE]] +" Make a certain vim file is loaded. +" +" Conventions: If FILE isn't defined, plugin/NAME.vim is loaded. The +" file must provide a variable loaded_{NAME} that represents the version +" number. +command! -nargs=+ TRequire let s:require = [] + \ | if !exists('loaded_'. get(s:require, 0)) + \ | exec 'runtime '. get(s:require, 2, 'plugin/'. get(s:require, 0) .'.vim') + \ | if !exists('loaded_'. get(s:require, 0)) || loaded_{get(s:require, 0)} < get(s:require, 1, loaded_{get(s:require, 0)}) + \ | echoerr 'Require '. get(s:require, 0) .' >= '. get(s:require, 1, 'any version will do') + \ | finish + \ | endif + \ | endif | unlet s:require + + +" :display: :Ttimecommand CMD +" Time the execution time of CMD. +command! -nargs=1 -complete=command Ttimecommand call tlib#cmd#Time() + + +let &cpo = s:save_cpo +unlet s:save_cpo diff --git a/sources_non_forked/tlib/plugin/02tlib.vim b/sources_non_forked/tlib/plugin/02tlib.vim index cc2c3ca0..94a600f0 100644 --- a/sources_non_forked/tlib/plugin/02tlib.vim +++ b/sources_non_forked/tlib/plugin/02tlib.vim @@ -1,8 +1,8 @@ " @Author: Tom Link (micathom AT gmail com?subject=[vim]) " @Created: 2007-04-10. -" @Last Change: 2015-11-23. +" @Last Change: 2019-04-09. " @License: GPL (see http://www.gnu.org/licenses/gpl.txt) -" @Revision: 808 +" @Revision: 836 " @Website: http://www.vim.org/account/profile.php?user_id=4037 " GetLatestVimScripts: 1863 1 tlib.vim " tlib.vim -- Some utility functions @@ -14,7 +14,7 @@ if v:version < 700 "{{{2 echoerr "tlib requires Vim >= 7" finish endif -let g:loaded_tlib = 117 +let g:loaded_tlib = 127 let s:save_cpo = &cpo set cpo&vim @@ -74,7 +74,17 @@ command! -nargs=1 -complete=command TBrowseOutput call tlib#cmd#BrowseOutput( " TBrowseScriptnames -command! -nargs=0 -complete=command TBrowseScriptnames call tlib#cmd#TBrowseScriptnames() +command! -nargs=0 TBrowseScriptnames call tlib#cmd#TBrowseScriptnames() + + +" :display: :Texecqfl CMD +" Run CMD and display the quickfix list. +command! -nargs=1 Texecqfl | call tlib#qfl#QflList(getqflist()) + + +" :display: :Texecloc CMD +" Run CMD and display the quickfix list. +command! -nargs=1 Texecloc | call tlib#qfl#QflList(getloclist(0)) " :display: :Tlibtrace GUARD, VAR1, VAR2... @@ -85,17 +95,31 @@ command! -nargs=0 -complete=command TBrowseScriptnames call tlib#cmd#TBrowseScri " If GUARD is a number that evaluates to true or if it is a string that " matches a |regexp|, which was added using Tlibtrace! (with '!'), " display the values of VAR1, VAR2 ... -command! -nargs=+ -bang -bar Tlibtrace : +command! -nargs=+ -bang Tlibtrace : -" :Tlibtraceset +RX1, -RX2... +" :Tlibtraceset[!] [--file=FILE] +RX1 -RX2... " If |tlib#trace#Enable()| was called: With the optional , users " can add and remove GUARDs (actually a |regexp|) that should be traced. -command! -nargs=+ -bang -bar Tlibtraceset call tlib#trace#Set() +" +" If no `+` or `-` is prepended, assume `+`. +" +" With the optional bang '!', reset any options. +command! -nargs=+ -bang Tlibtraceset call tlib#trace#Set(tlib#arg#GetOpts([], {'short': 0}), !empty("")) " :display: :Tlibtrace ASSERTION -command! -nargs=+ -bang -bar Tlibassert : +command! -nargs=+ -bang Tlibassert : + +" :display: :Tlibtype val, 'type', ... +command! -nargs=+ Tlibtype : + + +" Browse the current |quickfix| list. +command! -bar Tbrowseqfl call tlib#qfl#Browse() + +" Browse the current |location-list|. +command! -bar Tbrowseloc call tlib#loclist#Browse() let &cpo = s:save_cpo diff --git a/sources_non_forked/tlib/samples/tlib/input/tlib_input_list.vim b/sources_non_forked/tlib/samples/tlib/input/tlib_input_list.vim new file mode 100644 index 00000000..4d668ffa --- /dev/null +++ b/sources_non_forked/tlib/samples/tlib/input/tlib_input_list.vim @@ -0,0 +1,50 @@ +" The following variable configures the way |tlib#input#ListD()| works. +" In this example, we allow selection of multiple items (we could also +" allow only a single choice and make |tlib#input#ListD()| work on the +" indices, not the items). +" +" We also set a prompt that will be displayed in the command area. +" +" By default, |tlib#input#ListD()| will automatically select an item if +" there is only one item left matching the filter. In this example, we +" disable this feature. +" +" For demonstration purposes, we also define a key handler that prints +" the selected items. +let s:state = { + \ 'type': 'm', + \ 'query': 'Select lines for command output', + \ 'pick_last_item': 0, + \ 'key_handlers': [ + \ {'key': 16, 'agent': 'PrintMe', 'key_name': '', 'help': 'Print line'}, + \ ], + \ } + +" A key handler takes two arguments: the current state of the list +" display and a list of selected items/indices (depending on the type +" parameter). +function! PrintMe(state, items) "{{{3 + echom "You selected:" + for i in a:items + echom i + endfor + call input("Press ENTER to continue") + let a:state.state = 'redisplay' + return a:state +endf + +" In this example, we evaluate an ex-command with |:execute| and display +" the command's output as list. The user can select certain lines by +" typing some pattern or by pressing to select an item by +" number. The user can then press to print the lines (see above) +" or to pick the selected lines. +function! SelectOutput(ex) "{{{3 + redir => lines + silent exec a:ex + redir END + let state = copy(s:state) + let state.base = split(lines, '\n') + let picked = tlib#input#ListD(state) + echom "You picked: ". join(picked, ', ') +endf + diff --git a/sources_non_forked/tlib/scripts/create_crc_table.rb b/sources_non_forked/tlib/scripts/create_crc_table.rb new file mode 100644 index 00000000..149fe11f --- /dev/null +++ b/sources_non_forked/tlib/scripts/create_crc_table.rb @@ -0,0 +1,67 @@ +# @Author: Tom Link (micathom AT gmail com) +# @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +# @Revision: 14 + + +def crc_vim_table + tbl = [0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, + 0x706af48f, 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, + 0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, + 0x90bf1d91, 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de, + 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, 0x136c9856, + 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9, + 0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, + 0xa2677172, 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, + 0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, + 0x45df5c75, 0xdcd60dcf, 0xabd13d59, 0x26d930ac, 0x51de003a, + 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, 0xcfba9599, + 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, + 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190, + 0x01db7106, 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, + 0x9fbfe4a5, 0xe8b8d433, 0x7807c9a2, 0x0f00f934, 0x9609a88e, + 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01, + 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, 0x6c0695ed, + 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950, + 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, + 0xfbd44c65, 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, + 0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, + 0x346ed9fc, 0xad678846, 0xda60b8d0, 0x44042d73, 0x33031de5, + 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa, 0xbe0b1010, + 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f, + 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, + 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, + 0x03b6e20c, 0x74b1d29a, 0xead54739, 0x9dd277af, 0x04db2615, + 0x73dc1683, 0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8, + 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, 0xf00f9344, + 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb, + 0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a, + 0x67dd4acc, 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, + 0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, + 0xa6bc5767, 0x3fb506dd, 0x48b2364b, 0xd80d2bda, 0xaf0a1b4c, + 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, 0x316e8eef, + 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, + 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe, + 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, + 0x2cd99e8b, 0x5bdeae1d, 0x9b64c2b0, 0xec63f226, 0x756aa39c, + 0x026d930a, 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713, + 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, 0x92d28e9b, + 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242, + 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, + 0x18b74777, 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, + 0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45, 0xa00ae278, + 0xd70dd2ee, 0x4e048354, 0x3903b3c2, 0xa7672661, 0xd06016f7, + 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc, 0x40df0b66, + 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9, + 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, + 0xcdd70693, 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, + 0x5d681b02, 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, + 0x2d02ef8d] + tbl.map! do |num| + b = "%b" % num + bits = b.split(//) + bits.map! {|b| b.to_i} + bits.reverse + end + VIM::command("let @t = '#{tbl.inspect}'") +end + diff --git a/sources_non_forked/tlib/spec/tlib/arg.vim b/sources_non_forked/tlib/spec/tlib/arg.vim new file mode 100644 index 00000000..cf060a26 --- /dev/null +++ b/sources_non_forked/tlib/spec/tlib/arg.vim @@ -0,0 +1,66 @@ +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2010-04-03. +" @Last Change: 2010-04-03. +" @Revision: 1 + +let s:save_cpo = &cpo +set cpo&vim + + + +SpecBegin 'title': 'tlib#arg' + +function! TestGetArg(...) "{{{3 + exec tlib#arg#Get(1, 'foo', 1) + return foo +endf + +function! TestGetArg1(...) "{{{3 + exec tlib#arg#Get(1, 'foo', 1, '!= ""') + return foo +endf + +Should be equal TestGetArg(), 1 +Should be equal TestGetArg(''), '' +Should be equal TestGetArg(2), 2 +Should be equal TestGetArg1(), 1 +Should be equal TestGetArg1(''), 1 +Should be equal TestGetArg1(2), 2 + +function! TestArgs(...) "{{{3 + exec tlib#arg#Let([['foo', "o"], ['bar', 2]]) + return repeat(foo, bar) +endf +Should be equal TestArgs(), 'oo' +Should be equal TestArgs('a'), 'aa' +Should be equal TestArgs('a', 3), 'aaa' + +function! TestArgs1(...) "{{{3 + exec tlib#arg#Let(['foo', ['bar', 2]]) + return repeat(foo, bar) +endf +Should be equal TestArgs1(), '' +Should be equal TestArgs1('a'), 'aa' +Should be equal TestArgs1('a', 3), 'aaa' + +function! TestArgs2(...) "{{{3 + exec tlib#arg#Let(['foo', 'bar'], 1) + return repeat(foo, bar) +endf +Should be equal TestArgs2(), '1' +Should be equal TestArgs2('a'), 'a' +Should be equal TestArgs2('a', 3), 'aaa' + +function! TestArgs3(...) + TVarArg ['a', 1], 'b' + return a . b +endf +Should be equal TestArgs3(), '1' +Should be equal TestArgs3('a'), 'a' +Should be equal TestArgs3('a', 3), 'a3' + + +let &cpo = s:save_cpo +unlet s:save_cpo diff --git a/sources_non_forked/tlib/spec/tlib/date.vim b/sources_non_forked/tlib/spec/tlib/date.vim new file mode 100644 index 00000000..42c336bd --- /dev/null +++ b/sources_non_forked/tlib/spec/tlib/date.vim @@ -0,0 +1,61 @@ +" @Author: Tom Link (micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @GIT: http://github.com/tomtom/vimtlib/ +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2010-09-17. +" @Last Change: 2016-03-16. +" @Revision: 21 + +SpecBegin 'title': 'tlib#date' + +Should be equal tlib#date#Parse('2000-1-0', 1), [2000, 1, 0] +Should be equal tlib#date#Parse('2000-1-2'), [2000, 1, 2] +Should be equal tlib#date#Parse('2000-01-02'), [2000, 1, 2] +Should be equal tlib#date#Parse('2000-10-20'), [2000, 10, 20] + +Should be equal tlib#date#Parse('00-1-0', 1), [2000, 1, 0] +Should be equal tlib#date#Parse('00-1-2'), [2000, 1, 2] +Should be equal tlib#date#Parse('00-01-02'), [2000, 1, 2] +Should be equal tlib#date#Parse('00-10-20'), [2000, 10, 20] + +Should be equal tlib#date#Parse('2000/2/1'), [2000, 1, 2] +Should be equal tlib#date#Parse('2000/02/01'), [2000, 1, 2] +Should be equal tlib#date#Parse('2000/20/10'), [2000, 10, 20] + +Should be equal tlib#date#Parse('00/2/1'), [2000, 1, 2] +Should be equal tlib#date#Parse('00/02/01'), [2000, 1, 2] +Should be equal tlib#date#Parse('00/20/10'), [2000, 10, 20] + +Should be equal tlib#date#Parse('2.1.2000'), [2000, 1, 2] +Should be equal tlib#date#Parse('2. 1. 2000'), [2000, 1, 2] +Should be equal tlib#date#Parse('02.01.2000'), [2000, 1, 2] +Should be equal tlib#date#Parse('02. 01. 2000'), [2000, 1, 2] +Should be equal tlib#date#Parse('20.10.2000'), [2000, 10, 20] +Should be equal tlib#date#Parse('20. 10. 2000'), [2000, 10, 20] + +Should throw exception "tlib#date#Parse('2000-14-2')", 'TLib: Invalid date' +Should throw exception "tlib#date#Parse('2000-011-02')", 'TLib: Invalid date' +Should throw exception "tlib#date#Parse('2000-10-40')", 'TLib: Invalid date' +Should throw exception "tlib#date#Parse('2000-10-0')", 'TLib: Invalid date' + +Should be equal tlib#date#Shift('2015-10-29', '1m'), '2015-11-29' +Should be equal tlib#date#Shift('2015-11-29', '1m'), '2015-12-29' +Should be equal tlib#date#Shift('2015-12-29', '1m'), '2016-01-29' +Should be equal tlib#date#Shift('2016-01-29', '1m'), '2016-02-29' +Should be equal tlib#date#Shift('2015-10-29', '2m'), '2015-12-29' +Should be equal tlib#date#Shift('2015-10-29', '3m'), '2016-01-29' +Should be equal tlib#date#Shift('2015-10-29', '4m'), '2016-02-29' +Should be equal tlib#date#Shift('2015-12-30', '1d'), '2015-12-31' +Should be equal tlib#date#Shift('2015-12-31', '1d'), '2016-01-01' +Should be equal tlib#date#Shift('2015-12-30', '2d'), '2016-01-01' +Should be equal tlib#date#Shift('2015-12-30', '3d'), '2016-01-02' + +Should be equal tlib#date#Shift('2016-03-16', '1b'), '2016-03-17' +Should be equal tlib#date#Shift('2016-03-16', '2b'), '2016-03-18' +Should be equal tlib#date#Shift('2016-03-16', '3b'), '2016-03-21' +Should be equal tlib#date#Shift('2016-03-16', '4b'), '2016-03-22' +Should be equal tlib#date#Shift('2016-03-16', '5b'), '2016-03-23' +Should be equal tlib#date#Shift('2016-03-16', '6b'), '2016-03-24' +Should be equal tlib#date#Shift('2016-03-16', '7b'), '2016-03-25' +Should be equal tlib#date#Shift('2016-03-16', '8b'), '2016-03-28' + diff --git a/sources_non_forked/tlib/spec/tlib/dictionary.vim b/sources_non_forked/tlib/spec/tlib/dictionary.vim new file mode 100644 index 00000000..52439e6d --- /dev/null +++ b/sources_non_forked/tlib/spec/tlib/dictionary.vim @@ -0,0 +1,28 @@ +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @Website: https://github.com/tomtom +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2016-04-03. +" @Last Change: 2016-04-03. + +let s:save_cpo = &cpo +set cpo&vim + + + +SpecBegin 'title': 'tlib#dictionary' + + +It should handle basic test cases for tlib#dictionary#Rev properly. + +Should be equal tlib#dictionary#Rev({}), {} +Should be equal tlib#dictionary#Rev({1: 2, 3: 4}), {'2': '1', '4': '3'} +Should be equal tlib#dictionary#Rev({1: '', 3: 4}, {'empty': '*'}), {'*': '1', '4': '3'} +Should be equal tlib#dictionary#Rev({1: '', 3: 4}, {'use_string': 1}), {'''''': '1', '4': '3'} +Should be equal tlib#dictionary#Rev({1: '', 3: 4}, {'use_string': 1, 'use_eval': 1}), {'''''': 1, '4': 3} +Should be equal tlib#dictionary#Rev(tlib#dictionary#Rev({1: '', 3: 4}, {'use_string': 1}), {'use_eval': 1}), {1: '', 3: 4} +Should be equal tlib#dictionary#Rev({1: 4, 2: 4}, {'values_as_list': 1}), {'4': ['1', '2']} +Should be equal tlib#dictionary#Rev({1: 4, 2: 4}, {'values_as_list': 1, 'use_eval': 1}), {'4': [1, 2]} + + +let &cpo = s:save_cpo +unlet s:save_cpo diff --git a/sources_non_forked/tlib/spec/tlib/eval.vim b/sources_non_forked/tlib/spec/tlib/eval.vim new file mode 100644 index 00000000..40c51386 --- /dev/null +++ b/sources_non_forked/tlib/spec/tlib/eval.vim @@ -0,0 +1,27 @@ +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @Website: https://github.com/tomtom +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2015-10-26. +" @Last Change: 2015-10-26. + +let s:save_cpo = &cpo +set cpo&vim + + +SpecBegin 'title': 'tlib#eval' + + +let g:eval_a = {'foo': range(0, 5), 'd': {'a': range(0, 5)}} +let g:eval_b = {'foo': range(6, 10), 'd': {'a': range(6, 10), 'b': 2}, 'bar': range(5)} +let g:eval_a0 = deepcopy(g:eval_a) +let g:eval_b0 = deepcopy(g:eval_b) +let g:eval_c = {'foo': range(0, 10), 'd': {'a': range(0, 10), 'b': 2}, 'bar': range(5)} + + +Should be equal tlib#eval#Extend(copy(g:eval_a), g:eval_b), g:eval_c +Should be equal g:eval_a, g:eval_a0 +Should be equal g:eval_b, g:eval_b0 + + +let &cpo = s:save_cpo +unlet s:save_cpo diff --git a/sources_non_forked/tlib/spec/tlib/file.vim b/sources_non_forked/tlib/spec/tlib/file.vim new file mode 100644 index 00000000..f692abfc --- /dev/null +++ b/sources_non_forked/tlib/spec/tlib/file.vim @@ -0,0 +1,59 @@ +" @Author: Thomas Link (micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @GIT: http://github.com/tomtom/vimtlib/ +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2009-02-25. +" @Last Change: 2010-04-03. +" @Revision: 13 + +let s:save_cpo = &cpo +set cpo&vim + + +SpecBegin 'title': 'tlib/file', + \ 'sfile': 'autoload/tlib/file.vim' + + + +It should split filenames. +Should be equal tlib#file#Split('foo/bar/filename.txt'), ['foo', 'bar', 'filename.txt'] +Should be equal tlib#file#Split('/foo/bar/filename.txt'), ['', 'foo', 'bar', 'filename.txt'] +Should be equal tlib#file#Split('ftp://foo/bar/filename.txt'), ['ftp:/', 'foo', 'bar', 'filename.txt'] + + +It should join filenames. +Should be#Equal tlib#file#Join(['foo', 'bar']), 'foo/bar' +Should be#Equal tlib#file#Join(['foo/', 'bar'], 1), 'foo/bar' +Should be#Equal tlib#file#Join(['', 'bar']), '/bar' +Should be#Equal tlib#file#Join(['/', 'bar'], 1), '/bar' +Should be#Equal tlib#file#Join(['foo', 'bar', 'filename.txt']), 'foo/bar/filename.txt' +Should be#Equal tlib#file#Join(['', 'foo', 'bar', 'filename.txt']), '/foo/bar/filename.txt' +Should be#Equal tlib#file#Join(['ftp:/', 'foo', 'bar', 'filename.txt']), 'ftp://foo/bar/filename.txt' +Should be#Equal tlib#file#Join(['ftp://', 'foo', 'bar', 'filename.txt'], 1), 'ftp://foo/bar/filename.txt' + +Should be equal tlib#file#Join(['foo', 'bar', 'filename.txt']), 'foo/bar/filename.txt' +Should be equal tlib#file#Join(['', 'foo', 'bar', 'filename.txt']), '/foo/bar/filename.txt' +Should be equal tlib#file#Join(['ftp:/', 'foo', 'bar', 'filename.txt']), 'ftp://foo/bar/filename.txt' + + +It should construct relative path names. +Should be#Equal tlib#file#Relative('foo/bar/filename.txt', 'foo'), 'bar/filename.txt' +Should be#Equal tlib#file#Relative('foo/bar/filename.txt', 'foo/base'), '../bar/filename.txt' +Should be#Equal tlib#file#Relative('filename.txt', 'foo/base'), '../../filename.txt' +Should be#Equal tlib#file#Relative('/foo/bar/filename.txt', '/boo/base'), '../../foo/bar/filename.txt' +Should be#Equal tlib#file#Relative('/bar/filename.txt', '/boo/base'), '../../bar/filename.txt' +Should be#Equal tlib#file#Relative('/foo/bar/filename.txt', '/base'), '../foo/bar/filename.txt' +Should be#Equal tlib#file#Relative('c:/bar/filename.txt', 'x:/boo/base'), 'c:/bar/filename.txt' + + +Should be equal tlib#file#Relative('foo/bar/filename.txt', 'foo'), 'bar/filename.txt' +Should be equal tlib#file#Relative('foo/bar/filename.txt', 'foo/base'), '../bar/filename.txt' +Should be equal tlib#file#Relative('filename.txt', 'foo/base'), '../../filename.txt' +Should be equal tlib#file#Relative('/foo/bar/filename.txt', '/boo/base'), '../../foo/bar/filename.txt' +Should be equal tlib#file#Relative('/bar/filename.txt', '/boo/base'), '../../bar/filename.txt' +Should be equal tlib#file#Relative('/foo/bar/filename.txt', '/base'), '../foo/bar/filename.txt' +Should be equal tlib#file#Relative('c:/bar/filename.txt', 'x:/boo/base'), 'c:/bar/filename.txt' + + +let &cpo = s:save_cpo +unlet s:save_cpo diff --git a/sources_non_forked/tlib/spec/tlib/hash.vim b/sources_non_forked/tlib/spec/tlib/hash.vim new file mode 100644 index 00000000..a2403a3d --- /dev/null +++ b/sources_non_forked/tlib/spec/tlib/hash.vim @@ -0,0 +1,58 @@ +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Revision: 31 + + +SpecBegin 'title': 'tlib#hash' + + +It should calculate CRC32B checksums. + +let g:tlib_hash_use_crc32 = g:tlib#hash#use_crc32 + +let g:tlib#hash#use_crc32 = 'ruby' +Should be equal tlib#hash#CRC32B('The quick brown fox jumps over the lazy dog'), '414FA339' +Should be equal tlib#hash#CRC32B('foo'), '8C736521' +Should be equal tlib#hash#CRC32B('f'), '76D32BE0' + +let g:tlib#hash#use_crc32 = 'vim' +Should be equal tlib#hash#CRC32B('The quick brown fox jumps over the lazy dog'), '414FA339' +Should be equal tlib#hash#CRC32B('foo'), '8C736521' +Should be equal tlib#hash#CRC32B('f'), '76D32BE0' + + +function! s:CompareHash(text) "{{{3 + if !empty(a:text) + exec 'It should calculate the crc32b checksum for:' a:text + let crc32ruby = tlib#hash#CRC32B_ruby(a:text) + let crc32vim = tlib#hash#CRC32B_vim(a:text) + exec 'Should be equal' string(crc32ruby) ',' string(crc32vim) + exec 'It should calculate the adler32 checksum for:' a:text + let adler32tlib = tlib#hash#Adler32_tlib(a:text) + let adler32vim = tlib#hash#Adler32_vim(a:text) + exec 'Should be equal' string(adler32tlib) ',' string(adler32vim) + endif +endf + +redir => s:scriptnames +silent scriptnames +redir END +for s:script in split(s:scriptnames, '\n') + let s:scriptfile = matchstr(s:script, '^\s*\d\+:\s\+\zs.*$') + call s:CompareHash(s:scriptfile) + try + let s:scriptlines = readfile(s:scriptfile) + call s:CompareHash(join(s:scriptlines, "\n")) + for s:scriptline in s:scriptlines + call s:CompareHash(s:scriptline) + endfor + catch /^Vim\%((\a\+)\)\=:E484/ + endtry +endfor +unlet s:scriptnames, :script, s:scriptfile, s:scriptlines, s:scriptline +delf s:CompareHash + + +let g:tlib#hash#use_crc32 = g:tlib_hash_use_crc32 + diff --git a/sources_non_forked/tlib/spec/tlib/input.vim b/sources_non_forked/tlib/spec/tlib/input.vim new file mode 100644 index 00000000..f82aea6c --- /dev/null +++ b/sources_non_forked/tlib/spec/tlib/input.vim @@ -0,0 +1,127 @@ +" @Author: Tom Link (micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @GIT: http://github.com/tomtom/vimtlib/ +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2009-02-28. +" @Last Change: 2009-03-14. +" @Revision: 73 + +let s:save_cpo = &cpo +set cpo&vim + + +SpecBegin 'title': 'tlib: Input', 'scratch': '%', + \ 'after': ':unlet! g:spec_lib_rv', + \ 'options': [ + \ 'vim', + \ ] + + +let g:spec_tlib_list = [10, 20, 30, 40, 'a50', 'aa60', 'b70', 'ba80', 90] + + + +It should return empty values when the user presses . +Replay :let g:spec_lib_rv = tlib#input#List('s', '', g:spec_tlib_list)\ + \ \\\ +Should be#Equal g:spec_lib_rv, '' + +Replay :let g:spec_lib_rv = tlib#input#List('m', '', g:spec_tlib_list)\ + \ \\\ +Should be#Equal g:spec_lib_rv, [] + +Replay :let g:spec_lib_rv = tlib#input#List('si', '', g:spec_tlib_list)\ + \ \\\ +Should be#Equal g:spec_lib_rv, 0 + + + +It should pick an item from s-type list. +Replay :let g:spec_lib_rv = tlib#input#List('s', '', g:spec_tlib_list)\ + \ \\\ +Should be#Equal g:spec_lib_rv, 30 + + + +It should return an index from si-type list. +Replay :let g:spec_lib_rv = tlib#input#List('si', '', g:spec_tlib_list)\ + \ \\\ +Should be#Equal g:spec_lib_rv, 3 + + + +It should return a list from a m-type list. +Replay :let g:spec_lib_rv = tlib#input#List('m', '', g:spec_tlib_list)\ + \ \#\\\ +Should be#Equal sort(g:spec_lib_rv), [20, 40] + +Replay :let g:spec_lib_rv = tlib#input#List('m', '', g:spec_tlib_list)\ + \ \\\ +Should be#Equal sort(g:spec_lib_rv), [20, 30] + +Replay :let g:spec_lib_rv = tlib#input#List('m', '', g:spec_tlib_list)\ + \ \\\\ +Should be#Equal sort(g:spec_lib_rv), [20, 30] + + + +It should return a list of indices from a mi-type list. +Replay :let g:spec_lib_rv = tlib#input#List('mi', '', g:spec_tlib_list)\ + \ \#\\\ +Should be#Equal sort(g:spec_lib_rv), [2, 4] + +Replay :let g:spec_lib_rv = tlib#input#List('mi', '', g:spec_tlib_list)\ + \ \\\ +Should be#Equal sort(g:spec_lib_rv), [2, 3] + +Replay :let g:spec_lib_rv = tlib#input#List('mi', '', g:spec_tlib_list)\ + \ \\\\ +Should be#Equal sort(g:spec_lib_rv), [2, 3] + + + +It should filter items from a s-type list. +Replay :let g:spec_lib_rv = tlib#input#List('s', '', g:spec_tlib_list)\ + \ \a\\ +Should be#Equal g:spec_lib_rv, 'aa60' + + + +It should filter items from a si-type list. +Replay :let g:spec_lib_rv = tlib#input#List('si', '', g:spec_tlib_list)\ + \ \a\\ +Should be#Equal g:spec_lib_rv, 6 + + + +It should filter items from a m-type list. +Replay :let g:spec_lib_rv = tlib#input#List('m', '', g:spec_tlib_list)\ + \ a\#\\ +Should be#Equal sort(g:spec_lib_rv), ['aa60', 'ba80'] + +Replay :let g:spec_lib_rv = tlib#input#List('m', '', g:spec_tlib_list)\ + \ a\\\ +Should be#Equal sort(g:spec_lib_rv), ['aa60', 'ba80'] + +Replay :let g:spec_lib_rv = tlib#input#List('m', '', g:spec_tlib_list)\ + \ a\\\\ +Should be#Equal sort(g:spec_lib_rv), ['aa60', 'ba80'] + + + +It should filter items from a mi-type list. +Replay :let g:spec_lib_rv = tlib#input#List('mi', '', g:spec_tlib_list)\ + \ a\#\\ +Should be#Equal sort(g:spec_lib_rv), [6, 8] + +Replay :let g:spec_lib_rv = tlib#input#List('mi', '', g:spec_tlib_list)\ + \ a\\\ +Should be#Equal sort(g:spec_lib_rv), [6, 8] + +Replay :let g:spec_lib_rv = tlib#input#List('mi', '', g:spec_tlib_list)\ + \ a\\\\ +Should be#Equal sort(g:spec_lib_rv), [6, 8] + + + +let &cpo = s:save_cpo diff --git a/sources_non_forked/tlib/spec/tlib/list.vim b/sources_non_forked/tlib/spec/tlib/list.vim new file mode 100644 index 00000000..d4aae54a --- /dev/null +++ b/sources_non_forked/tlib/spec/tlib/list.vim @@ -0,0 +1,67 @@ +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2010-04-03. +" @Last Change: 2010-04-03. +" @Revision: 4 + +let s:save_cpo = &cpo +set cpo&vim + + + +SpecBegin 'title': 'tlib: List' + " \, 'options': [vim, <+SET+>] + " \, 'sfile': '<+SCRIPT CONTEXT+>' + " \, 'scratch': '<+SCRATCH FILE+>' + " \, 'before': '<+BEFORE EX COMMANDS+>' + " \, 'after': '<+AFTER EX COMMANDS+>' + " \, 'cleanup': ['<+FUNCTION+>()'] + + +" List {{{2 +fun! Add(a,b) + return a:a + a:b +endf + +Should be equal tlib#list#Inject([], 0, function('Add')), 0 +Should be equal tlib#list#Inject([1,2,3], 0, function('Add')), 6 + +Should be equal tlib#list#Compact([]), [] +Should be equal tlib#list#Compact([0,1,2,3,[], {}, ""]), [1,2,3] + +Should be equal tlib#list#Flatten([]), [] +Should be equal tlib#list#Flatten([1,2,3]), [1,2,3] +Should be equal tlib#list#Flatten([1,2, [1,2,3], 3]), [1,2,1,2,3,3] +Should be equal tlib#list#Flatten([0,[1,2,[3,""]]]), [0,1,2,3,""] + +Should be equal tlib#list#FindAll([1,2,3], 'v:val >= 2'), [2,3] +Should be equal tlib#list#FindAll([1,2,3], 'v:val >= 2', 'v:val * 10'), [20,30] + +Should be equal tlib#list#Find([1,2,3], 'v:val >= 2'), 2 +Should be equal tlib#list#Find([1,2,3], 'v:val >= 2', 0, 'v:val * 10'), 20 +Should be equal tlib#list#Find([1,2,3], 'v:val >= 5', 10), 10 + +Should be equal tlib#list#Any([1,2,3], 'v:val >= 2'), 1 +Should be equal tlib#list#Any([1,2,3], 'v:val >= 5'), 0 + +Should be equal tlib#list#All([1,2,3], 'v:val < 5'), 1 +Should be equal tlib#list#All([1,2,3], 'v:val >= 2'), 0 + +Should be equal tlib#list#Remove([1,2,1,2], 2), [1,1,2] +Should be equal tlib#list#RemoveAll([1,2,1,2], 2), [1,1] + +Should be equal tlib#list#Zip([[1,2,3], [4,5,6]]), [[1,4], [2,5], [3,6]] +Should be equal tlib#list#Zip([[1,2,3], [4,5,6,7]]), [[1,4], [2,5], [3,6], ['', 7]] +Should be equal tlib#list#Zip([[1,2,3], [4,5,6,7]], -1), [[1,4], [2,5], [3,6], [-1,7]] +Should be equal tlib#list#Zip([[1,2,3,7], [4,5,6]], -1), [[1,4], [2,5], [3,6], [7,-1]] + + +Should be equal tlib#list#Uniq([]), [] +Should be equal tlib#list#Uniq([1,1]), [1] +Should be equal tlib#list#Uniq([1,2,2,3,2,3,4,2,1,7,2,3,2,3,7]), [1,2,3,4,7] + + + +let &cpo = s:save_cpo +unlet s:save_cpo diff --git a/sources_non_forked/tlib/spec/tlib/rx.vim b/sources_non_forked/tlib/spec/tlib/rx.vim new file mode 100644 index 00000000..fc281035 --- /dev/null +++ b/sources_non_forked/tlib/spec/tlib/rx.vim @@ -0,0 +1,27 @@ +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2010-04-03. +" @Last Change: 2010-04-03. +" @Revision: 2 + +let s:save_cpo = &cpo +set cpo&vim + + + +SpecBegin 'title': 'tlib#rx' + + +for c in split('^$.*+\()|{}[]~', '\zs') + let s = printf('%sfoo%sbar%s', c, c, c) + Should be like s, '\m^'. tlib#rx#Escape(s, 'm') .'$' + Should be like s, '\M^'. tlib#rx#Escape(s, 'M') .'$' + Should be like s, '\v^'. tlib#rx#Escape(s, 'v') .'$' + Should be like s, '\V\^'. tlib#rx#Escape(s, 'V') .'\$' +endfor + + + +let &cpo = s:save_cpo +unlet s:save_cpo diff --git a/sources_non_forked/tlib/spec/tlib/string.vim b/sources_non_forked/tlib/spec/tlib/string.vim new file mode 100644 index 00000000..4329d946 --- /dev/null +++ b/sources_non_forked/tlib/spec/tlib/string.vim @@ -0,0 +1,29 @@ +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2010-04-03. +" @Last Change: 2010-04-03. +" @Revision: 4 + +let s:save_cpo = &cpo +set cpo&vim + + + +SpecBegin 'title': 'tlib#string' + +Should be equal tlib#string#RemoveBackslashes('foo bar'), 'foo bar' +Should be equal tlib#string#RemoveBackslashes('foo\ bar'), 'foo bar' +Should be equal tlib#string#RemoveBackslashes('foo\ \\bar'), 'foo \\bar' +Should be equal tlib#string#RemoveBackslashes('foo\ \\bar', '\ '), 'foo \bar' + + +Should be equal tlib#string#Count("fooo", "o"), 3 +Should be equal tlib#string#Count("***", "\\*"), 3 +Should be equal tlib#string#Count("***foo", "\\*"), 3 +Should be equal tlib#string#Count("foo***", "\\*"), 3 + + + +let &cpo = s:save_cpo +unlet s:save_cpo diff --git a/sources_non_forked/tlib/spec/tlib/url.vim b/sources_non_forked/tlib/spec/tlib/url.vim new file mode 100644 index 00000000..80783e9c --- /dev/null +++ b/sources_non_forked/tlib/spec/tlib/url.vim @@ -0,0 +1,23 @@ +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2010-04-03. +" @Last Change: 2010-04-03. +" @Revision: 2 + +let s:save_cpo = &cpo +set cpo&vim + + + +SpecBegin 'title': 'tlib#url' + +Should be equal tlib#url#Decode('http://example.com/foo+bar%25bar'), 'http://example.com/foo bar%bar' +Should be equal tlib#url#Decode('Hello%20World.%20%20Good%2c%20bye.'), 'Hello World. Good, bye.' + +Should be equal tlib#url#Encode('foo bar%bar'), 'foo+bar%%bar' +Should be equal tlib#url#Encode('Hello World. Good, bye.'), 'Hello+World.+Good%2c+bye.' + + +let &cpo = s:save_cpo +unlet s:save_cpo diff --git a/sources_non_forked/tlib/spec/tlib/var.vim b/sources_non_forked/tlib/spec/tlib/var.vim new file mode 100644 index 00000000..28e3fac8 --- /dev/null +++ b/sources_non_forked/tlib/spec/tlib/var.vim @@ -0,0 +1,37 @@ +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2010-04-03. +" @Last Change: 2010-04-03. +" @Revision: 2 + +let s:save_cpo = &cpo +set cpo&vim + + + +SpecBegin 'title': 'tlib#var' + + +let g:foo = 1 +let g:bar = 2 +let b:bar = 3 +let s:bar = 4 + +Should be equal tlib#var#Get('bar', 'bg'), 3 +Should be equal tlib#var#Get('bar', 'g'), 2 +Should be equal tlib#var#Get('foo', 'bg'), 1 +Should be equal tlib#var#Get('foo', 'g'), 1 +Should be equal tlib#var#Get('none', 'l'), '' + +Should be equal eval(tlib#var#EGet('bar', 'bg')), 3 +Should be equal eval(tlib#var#EGet('bar', 'g')), 2 +" Should be equal eval(tlib#var#EGet('bar', 'sg')), 4 +Should be equal eval(tlib#var#EGet('foo', 'bg')), 1 +Should be equal eval(tlib#var#EGet('foo', 'g')), 1 +Should be equal eval(tlib#var#EGet('none', 'l')), '' + + + +let &cpo = s:save_cpo +unlet s:save_cpo diff --git a/sources_non_forked/typescript-vim/README.md b/sources_non_forked/typescript-vim/README.md index c4873812..a8809983 100644 --- a/sources_non_forked/typescript-vim/README.md +++ b/sources_non_forked/typescript-vim/README.md @@ -3,7 +3,7 @@ Typescript Syntax for Vim Syntax file and other settings for [TypeScript](http://typescriptlang.org). The syntax file is taken from this [blog -post](http://blogs.msdn.com/b/interoperability/archive/2012/10/01/sublime-text-vi-emacs-typescript-enabled.aspx). +post](https://docs.microsoft.com/en-us/archive/blogs/interoperability/sublime-text-vi-emacs-typescript-enabled). Checkout [Tsuquyomi](https://github.com/Quramy/tsuquyomi) for omni-completion and other features for TypeScript editing. diff --git a/sources_non_forked/typescript-vim/compiler/typescriptreact.vim b/sources_non_forked/typescript-vim/compiler/typescriptreact.vim new file mode 100644 index 00000000..0f734095 --- /dev/null +++ b/sources_non_forked/typescript-vim/compiler/typescriptreact.vim @@ -0,0 +1 @@ +runtime! compiler/typescript.vim diff --git a/sources_non_forked/typescript-vim/ftplugin/typescriptreact.vim b/sources_non_forked/typescript-vim/ftplugin/typescriptreact.vim new file mode 100644 index 00000000..c23ec132 --- /dev/null +++ b/sources_non_forked/typescript-vim/ftplugin/typescriptreact.vim @@ -0,0 +1 @@ +runtime! ftplugin/typescript.vim diff --git a/sources_non_forked/typescript-vim/indent/typescriptreact.vim b/sources_non_forked/typescript-vim/indent/typescriptreact.vim new file mode 100644 index 00000000..36f89ae2 --- /dev/null +++ b/sources_non_forked/typescript-vim/indent/typescriptreact.vim @@ -0,0 +1 @@ +runtime! indent/typescript.vim diff --git a/sources_non_forked/typescript-vim/syntax/typescriptreact.vim b/sources_non_forked/typescript-vim/syntax/typescriptreact.vim new file mode 100644 index 00000000..8fc4480f --- /dev/null +++ b/sources_non_forked/typescript-vim/syntax/typescriptreact.vim @@ -0,0 +1 @@ +runtime! syntax/typescript.vim diff --git a/sources_non_forked/vim-abolish/plugin/abolish.vim b/sources_non_forked/vim-abolish/plugin/abolish.vim index 6fd332d0..4be1122d 100644 --- a/sources_non_forked/vim-abolish/plugin/abolish.vim +++ b/sources_non_forked/vim-abolish/plugin/abolish.vim @@ -284,7 +284,7 @@ function! s:parse_subvert(bang,line1,line2,count,args) else let args = a:args endif - let separator = matchstr(args,'^.') + let separator = '\v((\\)@' diff --git a/sources_non_forked/vim-commentary/plugin/commentary.vim b/sources_non_forked/vim-commentary/plugin/commentary.vim index 17c285b7..7dfc96c4 100644 --- a/sources_non_forked/vim-commentary/plugin/commentary.vim +++ b/sources_non_forked/vim-commentary/plugin/commentary.vim @@ -50,6 +50,7 @@ function! s:go(...) abort let indent = '^\s*' endif + let lines = [] for lnum in range(lnum1,lnum2) let line = getline(lnum) if strlen(r) > 2 && l.r !~# '\\' @@ -62,8 +63,9 @@ function! s:go(...) abort else let line = substitute(line,'^\%('.matchstr(getline(lnum1),indent).'\|\s*\)\zs.*\S\@<=','\=l.submatch(0).r','') endif - call setline(lnum,line) + call add(lines, line) endfor + call setline(lnum1, lines) let modelines = &modelines try set modelines=0 diff --git a/sources_non_forked/vim-flake8/autoload/flake8.vim b/sources_non_forked/vim-flake8/autoload/flake8.vim index 180bcadb..c407b9be 100644 --- a/sources_non_forked/vim-flake8/autoload/flake8.vim +++ b/sources_non_forked/vim-flake8/autoload/flake8.vim @@ -146,7 +146,7 @@ function! s:Flake8() " {{{ set t_te= " perform the grep itself - let &grepformat="%f:%l:%c: %m\,%f:%l: %m" + let &grepformat="%f:%l:%c: %m\,%f:%l: %m,%-G%\\d" let &grepprg=s:flake8_cmd silent! grep! "%" " close any existing cwindows, @@ -273,6 +273,10 @@ function! s:ShowErrorMessage() " {{{ if !exists('s:resultDict') return endif + if !exists('b:showing_message') + " ensure showing msg is always defined + let b:showing_message = ' ' + endif " if there is a message on the current line, " then echo it @@ -295,4 +299,3 @@ endfunction " }}} let &cpo = s:save_cpo unlet s:save_cpo - diff --git a/sources_non_forked/vim-fugitive/autoload/fugitive.vim b/sources_non_forked/vim-fugitive/autoload/fugitive.vim index 4a5b1083..9816233f 100644 --- a/sources_non_forked/vim-fugitive/autoload/fugitive.vim +++ b/sources_non_forked/vim-fugitive/autoload/fugitive.vim @@ -1,17 +1,14 @@ " Location: autoload/fugitive.vim " Maintainer: Tim Pope +" The functions contained within this file are for internal use only. For the +" official API, see the commented functions in plugin/fugitive.vim. + if exists('g:autoloaded_fugitive') finish endif let g:autoloaded_fugitive = 1 -if !exists('g:fugitive_git_executable') - let g:fugitive_git_executable = 'git' -elseif g:fugitive_git_executable =~# '^\w\+=' - let g:fugitive_git_executable = 'env ' . g:fugitive_git_executable -endif - " Section: Utility function! s:function(name) abort @@ -47,7 +44,7 @@ endfunction function! s:WinShellEsc(arg) abort if type(a:arg) == type([]) - return join(map(copy(a:arg), 's:shellesc(v:val)')) + return join(map(copy(a:arg), 's:WinShellEsc(v:val)')) elseif a:arg =~# '^[A-Za-z0-9_/:.-]\+$' return a:arg else @@ -82,8 +79,28 @@ function! s:throw(string) abort throw 'fugitive: '.a:string endfunction +function! s:VersionCheck() abort + if v:version < 704 + return 'return ' . string('echoerr "fugitive: Vim 7.4 or newer required"') + elseif empty(fugitive#GitVersion()) + return 'return ' . string('echoerr "fugitive: cannot execute Git"') + elseif !fugitive#GitVersion(1, 8, 5) + return 'return ' . string('echoerr "fugitive: Git 1.8.5 or newer required"') + else + return '' + endif +endfunction + +let s:worktree_error = "core.worktree is required when using an external Git dir" function! s:DirCheck(...) abort - if !empty(a:0 ? s:Dir(a:1) : s:Dir()) + let vcheck = s:VersionCheck() + if !empty(vcheck) + return vcheck + endif + let dir = a:0 ? s:Dir(a:1) : s:Dir() + if !empty(dir) && FugitiveWorkTree(dir, 1) is# 0 + return 'return ' . string('echoerr "fugitive: ' . s:worktree_error . '"') + elseif !empty(dir) return '' elseif empty(bufname('')) return 'return ' . string('echoerr "fugitive: working directory does not belong to a Git repository"') @@ -101,13 +118,15 @@ function! s:Mods(mods, ...) abort return substitute(mods, '\s\+', ' ', 'g') endfunction -function! s:Slash(path) abort - if exists('+shellslash') +if exists('+shellslash') + function! s:Slash(path) abort return tr(a:path, '\', '/') - else + endfunction +else + function! s:Slash(path) abort return a:path - endif -endfunction + endfunction +endif function! s:Resolve(path) abort let path = resolve(a:path) @@ -197,10 +216,82 @@ function! s:Map(mode, lhs, rhs, ...) abort endfor endfunction +function! fugitive#Autowrite() abort + if &autowrite || &autowriteall + try + if &confirm + let reconfirm = 1 + setglobal noconfirm + endif + silent! wall + finally + if exists('reconfirm') + setglobal confirm + endif + endtry + endif + return '' +endfunction + +function! s:add_methods(namespace, method_names) abort + for name in a:method_names + let s:{a:namespace}_prototype[name] = s:function('s:'.a:namespace.'_'.name) + endfor +endfunction + " Section: Git +function! s:GitCmd() abort + if !exists('g:fugitive_git_executable') + return ['git'] + elseif type(g:fugitive_git_executable) == type([]) + return g:fugitive_git_executable + else + let dquote = '"\%([^"]\|""\|\\"\)*"\|' + let string = g:fugitive_git_executable + let list = [] + if string =~# '^\w\+=' + call add(list, '/usr/bin/env') + endif + while string =~# '\S' + let arg = matchstr(string, '^\s*\%(' . dquote . '''[^'']*''\|\\.\|[^[:space:] |]\)\+') + let string = strpart(string, len(arg)) + let arg = substitute(arg, '^\s\+', '', '') + let arg = substitute(arg, + \ '\(' . dquote . '''\%(''''\|[^'']\)*''\|\\[' . s:fnameescape . ']\|^\\[>+-]\|!\d*\)\|' . s:expand, + \ '\=submatch(0)[0] ==# "\\" ? submatch(0)[1] : submatch(0)[1:-2]', 'g') + call add(list, arg) + endwhile + return list + endif +endfunction + +function! s:GitShellCmd() abort + if !exists('g:fugitive_git_executable') + return 'git' + elseif type(g:fugitive_git_executable) == type([]) + return s:shellesc(g:fugitive_git_executable) + else + return g:fugitive_git_executable + endif +endfunction + +function! s:UserCommandCwd(dir) abort + let tree = s:Tree(a:dir) + return len(tree) ? FugitiveVimPath(tree) : getcwd() +endfunction + function! s:UserCommandList(...) abort - let git = split(get(g:, 'fugitive_git_command', g:fugitive_git_executable), '\s\+') + if !fugitive#GitVersion(1, 8, 5) + throw 'fugitive: Git 1.8.5 or higher required' + endif + if !exists('g:fugitive_git_command') + let git = s:GitCmd() + elseif type(g:fugitive_git_command) == type([]) + let git = g:fugitive_git_command + else + let git = split(g:fugitive_git_command, '\s\+') + endif let flags = [] if a:0 && type(a:1) == type({}) let git = copy(get(a:1, 'git', git)) @@ -216,11 +307,7 @@ function! s:UserCommandList(...) abort if empty(tree) call add(git, '--git-dir=' . FugitiveGitPath(dir)) elseif len(tree) && s:cpath(tree) !=# s:cpath(getcwd()) - if fugitive#GitVersion(1, 8, 5) - call extend(git, ['-C', FugitiveGitPath(tree)]) - else - throw 'fugitive: Git 1.8.5 or higher required to change directory' - endif + call extend(git, ['-C', FugitiveGitPath(tree)]) endif endif return git + flags @@ -232,13 +319,14 @@ endfunction let s:git_versions = {} function! fugitive#GitVersion(...) abort - if !has_key(s:git_versions, g:fugitive_git_executable) - let s:git_versions[g:fugitive_git_executable] = matchstr(system(g:fugitive_git_executable.' --version'), '\d[^[:space:]]\+') + let git = s:GitShellCmd() + if !has_key(s:git_versions, git) + let s:git_versions[git] = matchstr(s:SystemError(s:GitCmd() + ['--version'])[0], '\d[^[:space:]]\+') endif if !a:0 - return s:git_versions[g:fugitive_git_executable] + return s:git_versions[git] endif - let components = split(s:git_versions[g:fugitive_git_executable], '\D\+') + let components = split(s:git_versions[git], '\D\+') if empty(components) return -1 endif @@ -299,8 +387,7 @@ function! s:HasOpt(args, ...) abort endfunction function! s:PreparePathArgs(cmd, dir, literal) abort - let literal_supported = fugitive#GitVersion(1, 9) - if a:literal && literal_supported + if a:literal call insert(a:cmd, '--literal-pathspecs') endif let split = index(a:cmd, '--') @@ -317,8 +404,6 @@ function! s:PreparePathArgs(cmd, dir, literal) abort let a:cmd[i] = fugitive#Path(bufname(a:cmd[i]), './', a:dir) elseif a:literal let a:cmd[i] = fugitive#Path(a:cmd[i], './', a:dir) - elseif !literal_supported - let a:cmd[i] = substitute(a:cmd[i], '^:\%(/\|([^)]*)\)\=:\=', './', '') endif endfor return a:cmd @@ -329,7 +414,11 @@ let s:prepare_env = { \ 'core.editor': 'GIT_EDITOR', \ 'core.askpass': 'GIT_ASKPASS', \ } -function! fugitive#PrepareDirEnvArgv(...) abort +function! fugitive#PrepareDirEnvGitArgv(...) abort + if !fugitive#GitVersion(1, 8, 5) + throw 'fugitive: Git 1.8.5 or higher required' + endif + let git = s:GitCmd() if a:0 && type(a:1) ==# type([]) let cmd = a:000[1:-1] + a:1 else @@ -338,7 +427,15 @@ function! fugitive#PrepareDirEnvArgv(...) abort let env = {} let i = 0 while i < len(cmd) - if cmd[i] =~# '^$\|[\/.]' && cmd[i] !~# '^-' + if type(cmd[i]) == type({}) + if has_key(cmd[i], 'dir') + let dir = cmd[i].dir + endif + if has_key(cmd[i], 'git') + let git = cmd[i].git + endif + call remove(cmd, i) + elseif cmd[i] =~# '^$\|[\/.]' && cmd[i] !~# '^-' let dir = remove(cmd, i) elseif cmd[i] =~# '^--git-dir=' let dir = remove(cmd, i)[10:-1] @@ -351,18 +448,14 @@ function! fugitive#PrepareDirEnvArgv(...) abort let val = matchstr(cmd[i+1], '=\zs.*') let env[var] = val endif - if fugitive#GitVersion(1, 8) && cmd[i+1] =~# '\.' + if cmd[i+1] =~# '\.' let i += 2 else call remove(cmd, i, i + 1) endif elseif cmd[i] =~# '^--.*pathspecs$' let explicit_pathspec_option = 1 - if fugitive#GitVersion(1, 9) - let i += 1 - else - call remove(cmd, i) - endif + let i += 1 elseif cmd[i] !~# '^-' break else @@ -373,7 +466,7 @@ function! fugitive#PrepareDirEnvArgv(...) abort let dir = s:Dir() endif call s:PreparePathArgs(cmd, dir, !exists('explicit_pathspec_option')) - return [dir, env, cmd] + return [dir, env, git, cmd] endfunction function! s:BuildEnvPrefix(env) abort @@ -381,24 +474,24 @@ function! s:BuildEnvPrefix(env) abort let env = items(a:env) if empty(env) return '' - elseif &shellcmdflag =~# '-Command' + elseif &shell =~? '\%(powershell\|pwsh\)\%(\.exe\)\=$' return join(map(env, '"$Env:" . v:val[0] . " = ''" . substitute(v:val[1], "''", "''''", "g") . "''; "'), '') elseif s:winshell() return join(map(env, '"set " . substitute(join(v:val, "="), "[&|<>^]", "^^^&", "g") . "& "'), '') else - return 'env ' . s:shellesc(map(env, 'join(v:val, "=")')) . ' ' + return '/usr/bin/env ' . s:shellesc(map(env, 'join(v:val, "=")')) . ' ' 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)'))) + elseif has('patch-8.2.0239') || has('nvim-0.5.1') || 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, {}] + return [['/usr/bin/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' @@ -409,23 +502,21 @@ function! s:JobOpts(cmd, env) abort endif endfunction -function! s:BuildShell(dir, env, args) abort +function! s:BuildShell(dir, env, git, args) abort let cmd = copy(a:args) let tree = s:Tree(a:dir) let pre = s:BuildEnvPrefix(a:env) if empty(tree) || index(cmd, '--') == len(cmd) - 1 call insert(cmd, '--git-dir=' . FugitiveGitPath(a:dir)) - elseif fugitive#GitVersion(1, 8, 5) - call extend(cmd, ['-C', FugitiveGitPath(tree)], 'keep') else - let pre = 'cd ' . s:shellesc(tree) . (s:winshell() ? '& ' : '; ') . pre + call extend(cmd, ['-C', FugitiveGitPath(tree)], 'keep') endif - return pre . g:fugitive_git_executable . ' ' . join(map(cmd, 's:shellesc(v:val)')) + return pre . join(map(a:git + cmd, 's:shellesc(v:val)')) endfunction function! fugitive#Prepare(...) abort - let [dir, env, argv] = call('fugitive#PrepareDirEnvArgv', a:000) - return s:BuildShell(dir, env, argv) + let [dir, env, git, argv] = call('fugitive#PrepareDirEnvGitArgv', a:000) + return s:BuildShell(dir, env, git, argv) endfunction function! s:SystemError(cmd, ...) abort @@ -438,7 +529,11 @@ function! s:SystemError(cmd, ...) abort set shellredir=>%s\ 2>&1 endif endif - let out = call('system', [type(a:cmd) ==# type([]) ? fugitive#Prepare(a:cmd) : a:cmd] + a:000) + if exists('+guioptions') && &guioptions =~# '!' + let guioptions = &guioptions + set guioptions-=! + endif + let out = call('system', [type(a:cmd) == type([]) ? s:shellesc(a:cmd) : a:cmd] + a:000) return [out, v:shell_error] catch /^Vim\%((\a\+)\)\=:E484:/ let opts = ['shell', 'shellcmdflag', 'shellredir', 'shellquote', 'shellxquote', 'shellxescape', 'shellslash'] @@ -449,6 +544,9 @@ function! s:SystemError(cmd, ...) abort if exists('shellredir') let &shellredir = shellredir endif + if exists('guioptions') + let &guioptions = guioptions + endif endtry endfunction @@ -469,7 +567,13 @@ endfunction function! s:NullError(...) abort let [out, exec_error] = s:SystemError(call('fugitive#Prepare', a:000)) - return [exec_error ? [] : split(out, "\1"), exec_error ? substitute(out, "\n$", "", "") : '', exec_error] + if exec_error + return [[], substitute(out, "\n$", "", ""), exec_error] + else + let list = split(out, "\1", 1) + call remove(list, -1) + return [list, '', exec_error] + endif endfunction function! s:TreeChomp(...) abort @@ -535,29 +639,34 @@ function! s:ConfigTimestamps(dir, dict) abort return join(map(files, 'getftime(expand(v:val))'), ',') endfunction +let s:config_prototype = {} + let s:config = {} function! fugitive#Config(...) abort - let dir = s:Dir() let name = '' - if a:0 >= 2 && type(a:2) == type({}) - let name = substitute(a:1, '^[^.]\+\|[^.]\+$', '\L&', 'g') - return len(a:1) ? get(get(a:2, name, []), 0, '') : a:2 + let default = get(a:, 3, '') + if a:0 >= 2 && type(a:2) == type({}) && has_key(a:2, 'GetAll') + return fugitive#ConfigGetAll(a:1, a:2) elseif a:0 >= 2 - let dir = a:2 + let dir = s:Dir(a:2) let name = a:1 - elseif a:0 == 1 && type(a:1) == type({}) + elseif a:0 == 1 && type(a:1) == type({}) && !has_key(a:1, 'git_dir') return a:1 - elseif a:0 == 1 && a:1 =~# '^[[:alnum:]-]\+\.' + elseif a:0 == 1 && type(a:1) == type('') && a:1 =~# '^[[:alnum:]-]\+\.' + let dir = s:Dir() let name = a:1 elseif a:0 == 1 - let dir = a:1 + let dir = s:Dir(a:1) + else + let dir = s:Dir() endif let name = substitute(name, '^[^.]\+\|[^.]\+$', '\L&', 'g') 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 dict = copy(s:config_prototype) + let dict.git_dir = dir let [lines, message, exec_error] = s:NullError([dir, 'config', '--list', '-z']) if exec_error return {} @@ -576,28 +685,201 @@ function! fugitive#Config(...) abort let s:config[dir_key] = [s:ConfigTimestamps(dir, dict), dict] lockvar! dict endif - return len(name) ? get(get(dict, name, []), 0, '') : dict + return len(name) ? get(get(dict, name, []), 0, default) : dict endfunction +function! fugitive#ConfigGetAll(name, ...) abort + let config = fugitive#Config(a:0 ? a:1 : s:Dir()) + let name = substitute(a:name, '^[^.]\+\|[^.]\+$', '\L&', 'g') + return copy(get(config, name, [])) +endfunction + +function! fugitive#ConfigGetRegexp(pattern, ...) abort + let config = fugitive#Config(a:0 ? a:1 : s:Dir()) + let filtered = map(filter(copy(config), 'v:key =~# "\\." && v:key =~# a:pattern'), 'copy(v:val)') + if a:pattern !~# '\\\@ 0 - let head = matchstr(fugitive#Config('branch.' . head . '.merge'), 'refs/heads/\zs.*') - let remote = len(head) ? fugitive#Config('branch.' . head . '.remote') : '' + let head = matchstr(FugitiveConfigGet('branch.' . head . '.merge', a:dir), 'refs/heads/\zs.*') + let remote = len(head) ? FugitiveConfigGet('branch.' . head . '.remote', a:dir) : '' let i -= 1 endwhile return remote =~# '^\.\=$' ? 'origin' : remote endfunction -function! fugitive#RemoteUrl(...) abort - let dir = a:0 > 1 ? a:2 : s:Dir() - let remote = !a:0 || a:1 =~# '^\.\=$' ? s:Remote(dir) : a:1 - if !fugitive#GitVersion(2, 7) - return fugitive#Config('remote.' . remote . '.url') +function! s:SshParseHost(value) abort + let patterns = [] + let negates = [] + for host in split(a:value, '\s\+') + let pattern = substitute(host, '[\\^$.*~?]', '\=submatch(0) == "*" ? ".*" : submatch(0) == "?" ? "." : "\\" . submatch(0)', 'g') + if pattern[0] ==# '!' + call add(negates, '\&\%(^' . pattern[1 : -1] . '$\)\@!') + else + call add(patterns, pattern) + endif + endfor + return '^\%(' . join(patterns, '\|') . '\)$' . join(negates, '') +endfunction + +function! s:SshParseConfig(into, root, file, ...) abort + if !filereadable(a:file) + return a:into endif - return s:ChompDefault('', [dir, 'remote', 'get-url', remote, '--']) + let host = a:0 ? a:1 : '^\%(.*\)$' + for line in readfile(a:file) + let key = tolower(matchstr(line, '^\s*\zs\w\+\ze\s')) + let value = matchstr(line, '^\s*\w\+\s\+\zs.*\S') + if key ==# 'match' + let host = value ==# 'all' ? '^\%(.*\)$' : '' + elseif key ==# 'host' + let host = s:SshParseHost(value) + elseif key ==# 'include' + call s:SshParseInclude(a:into, a:root, host, value) + elseif len(key) && len(host) + call extend(a:into, {key: []}, 'keep') + call add(a:into[key], [host, value]) + endif + endfor + return a:into +endfunction + +function! s:SshParseInclude(into, root, host, value) abort + for glob in split(a:value) + if glob !~# '^/' + let glob = a:root . glob + endif + for file in split(glob(glob), "\n") + call s:SshParseConfig(a:into, a:root, file, a:host) + endfor + endfor +endfunction + +unlet! s:ssh_config +function! fugitive#SshConfig(host, ...) abort + if !exists('s:ssh_config') + let s:ssh_config = {} + for file in [expand("~/.ssh/config"), "/etc/ssh/ssh_config"] + call s:SshParseConfig(s:ssh_config, substitute(file, '\w*$', '', ''), file) + endfor + endif + let host_config = {} + for key in a:0 ? a:1 : keys(s:ssh_config) + for [host_pattern, value] in get(s:ssh_config, key, []) + if a:host =~# host_pattern + let host_config[key] = value + break + endif + endfor + endfor + return host_config +endfunction + +function! fugitive#SshHostAlias(authority) abort + let [_, user, host, port; __] = matchlist(a:authority, '^\%(\([^/@]\+\)@\)\=\(.\{-\}\)\%(:\(\d\+\)\)\=$') + let c = fugitive#SshConfig(host, ['user', 'hostname', 'port']) + if empty(user) + let user = get(c, 'user', '') + endif + if empty(port) + let port = get(c, 'port', '') + endif + return (len(user) ? user . '@' : '') . get(c, 'hostname', host) . (port =~# '^\%(22\)\=$' ? '' : ':' . port) +endfunction + +let s:redirects = {} + +function! fugitive#ResolveRemote(remote) abort + if a:remote =~# '^https\=://' && s:executable('curl') + if !has_key(s:redirects, a:remote) + let s:redirects[a:remote] = matchstr(s:SystemError( + \ ['curl', '--disable', '--silent', '--max-time', '5', '-I', + \ a:remote . '/info/refs?service=git-upload-pack'])[0], + \ 'Location: \zs\S\+\ze/info/refs?') + endif + if len(s:redirects[a:remote]) + return s:redirects[a:remote] + endif + elseif a:remote =~# '^ssh://' + let authority = matchstr(a:remote, '[^/?#]*', 6) + return 'ssh://' . fugitive#SshHostAlias(authority) . strpart(a:remote, 6 + len(authority)) + endif + let scp_authority = matchstr(a:remote, '^[^:/]\+\ze:\%(//\)\@!') + if empty(scp_authority) + return a:remote + endif + let path = strpart(a:remote, len(scp_authority) + 1) + let alias = fugitive#SshHostAlias(scp_authority) + if alias !~# ':' + return alias . ':' . path + elseif path =~# '^/' + return 'ssh://' . alias . path + else + return a:remote + endif +endfunction + +function! s:ConfigLengthSort(i1, i2) abort + return len(a:i2[0]) - len(a:i1[0]) +endfunction + +function! fugitive#RemoteUrl(...) abort + let dir = a:0 > 1 ? s:Dir(a:2) : s:Dir() + let url = !a:0 || a:1 =~# '^\.\=$' ? s:Remote(dir) : a:1 + if url !~# ':\|^/\|^\.\.\=/' + let config = fugitive#Config(a:0 > 1 ? a:2 : s:Dir()) + let url = FugitiveConfigGet('remote.' . url . '.url', config) + let instead_of = [] + for [k, vs] in items(fugitive#ConfigGetRegexp('^url\.\zs.\{-\}\ze\.insteadof$', config)) + for v in vs + call add(instead_of, [v, k]) + endfor + endfor + call sort(instead_of, 's:ConfigLengthSort') + for [orig, replacement] in instead_of + if strpart(url, 0, len(orig)) ==# orig + let url = replacement . strpart(url, len(orig)) + break + endif + endfor + endif + if !get(a:, 3, 0) + let url = fugitive#ResolveRemote(url) + endif + return url endfunction " Section: Quickfix @@ -626,7 +908,9 @@ function! s:QuickfixCreate(nr, opts) abort endif endfunction -function! s:QuickfixStream(nr, event, title, cmd, first, callback, ...) abort +function! s:QuickfixStream(nr, event, title, cmd, first, mods, callback, ...) abort + call s:BlurStatus() + let mods = s:Mods(a:mods) let opts = {'title': a:title, 'context': {'items': []}} call s:QuickfixCreate(a:nr, opts) let event = (a:nr < 0 ? 'c' : 'l') . 'fugitive-' . a:event @@ -638,7 +922,7 @@ function! s:QuickfixStream(nr, event, title, cmd, first, callback, ...) abort endif let buffer = [] - let lines = split(s:SystemError(s:shellesc(a:cmd))[0], "\n") + let lines = split(s:SystemError(a:cmd)[0], "\n") for line in lines call extend(buffer, call(a:callback, a:000 + [line])) if len(buffer) >= 20 @@ -647,7 +931,9 @@ function! s:QuickfixStream(nr, event, title, cmd, first, callback, ...) abort call extend(opts.context.items, contexts) unlet contexts call s:QuickfixSet(a:nr, remove(buffer, 0, -1), 'a') - redraw + if mods !~# '\' + redraw + endif endif endfor call extend(buffer, call(a:callback, a:000 + [0])) @@ -657,21 +943,12 @@ function! s:QuickfixStream(nr, event, title, cmd, first, callback, ...) abort silent exe s:DoAutocmd('QuickFixCmdPost ' . event) if a:first && len(s:QuickfixGet(a:nr)) - call s:BlurStatus() - return a:nr < 0 ? 'cfirst' : 'lfirst' + return mods . (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 @@ -685,12 +962,6 @@ endfunction " Section: Repository Object -function! s:add_methods(namespace, method_names) abort - for name in a:method_names - let s:{a:namespace}_prototype[name] = s:function('s:'.a:namespace.'_'.name) - endfor -endfunction - let s:repo_prototype = {} let s:repos = {} @@ -748,7 +1019,7 @@ function! s:repo_prepare(...) dict abort endfunction function! s:repo_git_command(...) dict abort - let git = g:fugitive_git_executable . ' --git-dir='.s:shellesc(self.git_dir) + let git = s:GitShellCmd() . ' --git-dir='.s:shellesc(self.git_dir) return git.join(map(copy(a:000),'" ".s:shellesc(v:val)'),'') endfunction @@ -773,7 +1044,7 @@ endfunction call s:add_methods('repo',['superglob']) function! s:repo_config(name) dict abort - return fugitive#Config(a:name, self.git_dir) + return FugitiveConfigGet(a:name, self.git_dir) endfunction function! s:repo_user() dict abort @@ -821,16 +1092,16 @@ function! s:Owner(path, ...) abort if commit =~# '^\x\{40,\}$' return commit elseif commit ==# '2' - return 'HEAD^{}' + return '@' elseif commit ==# '0' return '' endif - let merge_head = s:MergeHead() + let merge_head = s:MergeHead(dir) if empty(merge_head) return '' endif if commit ==# '3' - return merge_head . '^{}' + return merge_head elseif commit ==# '1' return s:TreeChomp('merge-base', 'HEAD', merge_head, '--') endif @@ -890,8 +1161,8 @@ function! fugitive#Path(url, ...) abort endif let url = a:url let temp_state = s:TempState(url) - if has_key(temp_state, 'bufnr') - let url = bufname(temp_state.bufnr) + if has_key(temp_state, 'origin_bufnr') + let url = bufname(temp_state.origin_bufnr) endif let url = s:Slash(fnamemodify(url, ':p')) if url =~# '/$' && s:Slash(a:url) !~# '/$' @@ -925,41 +1196,43 @@ function! fugitive#Find(object, ...) abort let prefix = matchstr(a:object, '^[~$]\i*') let owner = expand(prefix) return FugitiveVimPath((len(owner) ? owner : prefix) . strpart(a:object, len(prefix))) - elseif s:Slash(a:object) =~# '^$\|^/\|^\%(\a\a\+:\).*\%(//\|::\)' . (has('win32') ? '\|^\a:/' : '') + endif + let rev = s:Slash(a:object) + if rev =~# '^$\|^/\|^\%(\a\a\+:\).*\%(//\|::\)' . (has('win32') ? '\|^\a:/' : '') return FugitiveVimPath(a:object) - elseif s:Slash(a:object) =~# '^\.\.\=\%(/\|$\)' + elseif rev =~# '^\.\.\=\%(/\|$\)' return FugitiveVimPath(simplify(getcwd() . '/' . a:object)) endif let dir = a:0 ? a:1 : s:Dir() if empty(dir) - let file = matchstr(a:object, '^\%(:\d:\|[^:]*:\)\zs.*', '', '') + let file = matchstr(a:object, '^\%(:\d:\|[^:]*:\)\zs\%(\.\.\=$\|\.\.\=/.*\|/.*\|\w:/.*\)') let dir = FugitiveExtractGitDir(file) if empty(dir) - return fnamemodify(FugitiveVimPath(len(file) ? file : a:object), ':p') + return '' endif endif - let rev = s:Slash(a:object) let tree = s:Tree(dir) let base = len(tree) ? tree : 'fugitive://' . dir . '//0' if rev ==# '.git' let f = len(tree) ? tree . '/.git' : dir elseif rev =~# '^\.git/' - let f = substitute(rev, '^\.git', '', '') - let cdir = fugitive#CommonDir(dir) - if f =~# '^/\.\./\.\.\%(/\|$\)' - let f = simplify(len(tree) ? tree . f[3:-1] : dir . f) - elseif f =~# '^/\.\.\%(/\|$\)' - let f = base . f[3:-1] - elseif cdir !=# dir && ( - \ f =~# '^/\%(config\|hooks\|info\|logs/refs\|objects\|refs\|worktrees\)\%(/\|$\)' || - \ f !~# '^/\%(index$\|index\.lock$\|\w*MSG$\|\w*HEAD$\|logs/\w*HEAD$\|logs$\|rebase-\w\+\)\%(/\|$\)' && - \ getftime(FugitiveVimPath(dir . f)) < 0 && getftime(FugitiveVimPath(cdir . f)) >= 0) + let f = strpart(rev, 5) + let fdir = dir . '/' + let cdir = fugitive#CommonDir(dir) . '/' + if f =~# '^\.\./\.\.\%(/\|$\)' + let f = simplify(len(tree) ? tree . f[2:-1] : fdir . f) + elseif f =~# '^\.\.\%(/\|$\)' + let f = base . f[2:-1] + elseif cdir !=# fdir && ( + \ f =~# '^\%(config\|hooks\|info\|logs/refs\|objects\|refs\|worktrees\)\%(/\|$\)' || + \ f !~# '^\%(index$\|index\.lock$\|\w*MSG$\|\w*HEAD$\|logs/\w*HEAD$\|logs$\|rebase-\w\+\)\%(/\|$\)' && + \ getftime(FugitiveVimPath(fdir . f)) < 0 && getftime(FugitiveVimPath(cdir . f)) >= 0) let f = simplify(cdir . f) else - let f = simplify(dir . f) + let f = simplify(fdir . f) endif elseif rev ==# ':/' - let f = base + let f = tree elseif rev =~# '^\.\%(/\|$\)' let f = base . rev[1:-1] elseif rev =~# '^::\%(/\|\a\+\:\)' @@ -981,10 +1254,9 @@ function! fugitive#Find(object, ...) abort elseif rev =~# '^:[0-3]:' let f = 'fugitive://' . dir . '//' . rev[1] . '/' . rev[3:-1] elseif rev ==# ':' - if $GIT_INDEX_FILE =~# '/[^/]*index[^/]*\.lock$' && s:cpath(fnamemodify($GIT_INDEX_FILE,':p')[0:strlen(dir)]) ==# s:cpath(dir . '/') && filereadable($GIT_INDEX_FILE) + let f = FugitiveFind('.git/index', dir) + if $GIT_INDEX_FILE =~# '/[^/]*index[^/]*\.lock$' && s:cpath(fnamemodify($GIT_INDEX_FILE,':p')[0:strlen(f)-6], s:cpath(f[0 : -6])) && filereadable($GIT_INDEX_FILE) let f = fnamemodify($GIT_INDEX_FILE, ':p') - else - let f = fugitive#Find('.git/index', dir) endif elseif rev =~# '^:(\%(top\|top,literal\|literal,top\|literal\))' let f = matchstr(rev, ')\zs.*') @@ -997,7 +1269,7 @@ function! fugitive#Find(object, ...) abort let f = 'fugitive://' . dir . '//0/' . rev[1:-1] else if !exists('f') - let commit = substitute(matchstr(rev, '^\%([^:.-]\|\.\.[^/:]\)[^:]*\|^:.*'), '^@\%($\|[~^]\|@{\)\@=', 'HEAD', '') + let commit = matchstr(rev, '^\%([^:.-]\|\.\.[^/:]\)[^:]*\|^:.*') let file = substitute(matchstr(rev, '^\%([^:.-]\|\.\.[^/:]\)[^:]*\zs:.*'), '^:', '/', '') if file =~# '^/\.\.\=\%(/\|$\)\|^//\|^/\a\+:' let file = file =~# '^/\.' ? simplify(getcwd() . file) : file[1:-1] @@ -1013,11 +1285,14 @@ function! fugitive#Find(object, ...) abort endif let commits = split(commit, '\.\.\.-\@!', 1) if len(commits) == 2 - call map(commits, 'empty(v:val) || v:val ==# "@" ? "HEAD" : v:val') + call map(commits, 'empty(v:val) ? "@" : v:val') let commit = matchstr(s:ChompDefault('', [dir, 'merge-base'] + commits + ['--']), '\<[0-9a-f]\{40,\}\>') endif - if commit !~# '^[0-9a-f]\{40,\}$' + if commit !~# '^[0-9a-f]\{40,\}$\|^$' let commit = matchstr(s:ChompDefault('', [dir, 'rev-parse', '--verify', commit . (len(file) ? '^{}' : ''), '--']), '\<[0-9a-f]\{40,\}\>') + if empty(commit) && len(file) + let commit = repeat('0', 40) + endif endif if len(commit) let f = 'fugitive://' . dir . '//' . commit . file @@ -1029,8 +1304,16 @@ function! fugitive#Find(object, ...) abort return FugitiveVimPath(f) endfunction -function! s:Generate(rev, ...) abort - return fugitive#Find(a:rev, a:0 ? a:1 : s:Dir()) +function! s:Generate(object, ...) abort + let dir = a:0 ? a:1 : s:Dir() + let f = fugitive#Find(a:object, dir) + if !empty(f) + return f + elseif a:object ==# ':/' + return len(dir) ? FugitiveVimPath('fugitive://' . dir . '//0') : '.' + endif + let file = matchstr(a:object, '^\%(:\d:\|[^:]*:\)\zs.*') + return fnamemodify(FugitiveVimPath(len(file) ? file : a:object), ':p') endfunction function! s:DotRelative(path, ...) abort @@ -1049,7 +1332,7 @@ function! fugitive#Object(...) abort let rev = '' endif let tree = s:Tree(dir) - let full = a:0 ? a:1 : @% + let full = a:0 ? a:1 : s:BufName('%') let full = fnamemodify(full, ':p' . (s:Slash(full) =~# '/$' ? '' : ':s?/$??')) if empty(rev) && empty(tree) return FugitiveGitPath(full) @@ -1066,15 +1349,15 @@ function! fugitive#Object(...) abort endif endfunction -let s:var = '\%(%\|#<\=\d\+\|##\=\)' +let s:var = '\%(<\%(cword\|cWORD\|cexpr\|cfile\|sfile\|slnum\|afile\|abuf\|amatch' . (has('clientserver') ? '\|client' : '') . '\)>\|%\|#<\=\d\+\|##\=\)' let s:flag = '\%(:[p8~.htre]\|:g\=s\(.\).\{-\}\1.\{-\}\1\)' let s:expand = '\%(\(' . s:var . '\)\(' . s:flag . '*\)\(:S\)\=\)' function! s:BufName(var) abort if a:var ==# '%' - return bufname(get(s:TempState(), 'bufnr', '')) + return bufname(get(s:TempState(), 'origin_bufnr', '')) elseif a:var =~# '^#\d*$' - let nr = get(s:TempState(bufname(+a:var[1:-1])), 'bufnr', '') + let nr = get(s:TempState(bufname(+a:var[1:-1])), 'origin_bufnr', '') return bufname(nr ? nr : +a:var[1:-1]) else return expand(a:var) @@ -1101,20 +1384,51 @@ function! s:ExpandVar(other, var, flags, esc, ...) abort let buffer = s:BufName(len(a:other) > 1 ? '#'. a:other[1:-1] : '%') let owner = s:Owner(buffer) return len(owner) ? owner : '@' - endif - let flags = a:flags - let file = s:DotRelative(fugitive#Real(s:BufName(a:var)), cwd) - while len(flags) - let flag = matchstr(flags, s:flag) - let flags = strpart(flags, len(flag)) - if flag ==# ':.' - let file = s:DotRelative(file, cwd) - else - let file = fnamemodify(file, flag) + elseif a:var ==# '' + let bufnames = [expand('')] + if v:version >= 704 && get(maparg('', 'c', 0, 1), 'expr') + try + let bufnames = [eval(maparg('', 'c'))] + if bufnames[0] ==# "\\" + let bufnames = [expand('')] + endif + catch + endtry endif - endwhile - let file = s:Slash(file) - return (len(a:esc) ? shellescape(file) : file) + elseif a:var =~# '^<' + let bufnames = [s:BufName(a:var)] + elseif a:var ==# '##' + let bufnames = map(argv(), 'fugitive#Real(v:val)') + else + let bufnames = [fugitive#Real(s:BufName(a:var))] + endif + let files = [] + for bufname in bufnames + let flags = a:flags + let file = s:DotRelative(bufname, cwd) + while len(flags) + let flag = matchstr(flags, s:flag) + let flags = strpart(flags, len(flag)) + if flag ==# ':.' + let file = s:DotRelative(fugitive#Real(file), cwd) + else + let file = fnamemodify(file, flag) + endif + endwhile + let file = s:Slash(file) + if file =~# '^fugitive://' + let [dir, commit, file_candidate] = s:DirCommitFile(file) + let tree = s:Tree(dir) + if len(tree) && len(file_candidate) + let file = (commit =~# '^.$' ? ':' : '') . commit . ':' . + \ s:DotRelative(tree . file_candidate) + elseif empty(file_candidate) && commit !~# '^.$' + let file = commit + endif + endif + call add(files, len(a:esc) ? shellescape(file) : file) + endfor + return join(files, "\1") endfunction function! s:Expand(rev, ...) abort @@ -1131,26 +1445,25 @@ function! s:Expand(rev, ...) abort endif return substitute(file, \ '\(\\[' . s:fnameescape . ']\|^\\[>+-]\|!\d*\)\|' . s:expand, - \ '\=s:ExpandVar(submatch(1),submatch(2),submatch(3),"", a:0 ? a:1 : getcwd())', 'g') + \ '\=tr(s:ExpandVar(submatch(1),submatch(2),submatch(3),"", a:0 ? a:1 : getcwd()), "\1", " ")', 'g') endfunction function! fugitive#Expand(object) abort return substitute(a:object, \ '\(\\[' . s:fnameescape . ']\|^\\[>+-]\|!\d*\)\|' . s:expand, - \ '\=s:ExpandVar(submatch(1),submatch(2),submatch(3),submatch(5))', 'g') + \ '\=tr(s:ExpandVar(submatch(1),submatch(2),submatch(3),submatch(5)), "\1", " ")', 'g') endfunction -function! s:ExpandSplit(string, ...) abort +function! s:SplitExpandChain(string, ...) abort let list = [] let string = a:string - let handle_bar = a:0 && a:1 - let dquote = handle_bar ? '"\%([^"]\|""\|\\"\)*"\|' : '' - let cwd = a:0 > 1 ? a:2 : getcwd() + let dquote = '"\%([^"]\|""\|\\"\)*"\|' + let cwd = a:0 ? a:1 : getcwd() while string =~# '\S' - if handle_bar && string =~# '^\s*|' + if string =~# '^\s*|' return [list, substitute(string, '^\s*', '', '')] endif - let arg = matchstr(string, '^\s*\%(' . dquote . '''[^'']*''\|\\.\|[^[:space:] ' . (handle_bar ? '|' : '') . ']\)\+') + let arg = matchstr(string, '^\s*\%(' . dquote . '''[^'']*''\|\\.\|[^[:space:] |]\)\+') let string = strpart(string, len(arg)) let arg = substitute(arg, '^\s\+', '', '') if !exists('seen_separator') @@ -1160,20 +1473,12 @@ function! s:ExpandSplit(string, ...) abort let arg = substitute(arg, \ '\(' . dquote . '''\%(''''\|[^'']\)*''\|\\[' . s:fnameescape . ']\|^\\[>+-]\|!\d*\)\|' . s:expand, \ '\=s:ExpandVar(submatch(1),submatch(2),submatch(3),submatch(5), cwd)', 'g') - call add(list, arg) + call extend(list, split(arg, "\1", 1)) if arg ==# '--' let seen_separator = 1 endif endwhile - return handle_bar ? [list, ''] : list -endfunction - -function! s:SplitExpand(string, ...) abort - return s:ExpandSplit(a:string, 0, a:0 ? a:1 : getcwd()) -endfunction - -function! s:SplitExpandChain(string, ...) abort - return s:ExpandSplit(a:string, 1, a:0 ? a:1 : getcwd()) + return [list, ''] endfunction let s:trees = {} @@ -1318,10 +1623,10 @@ function! fugitive#getfperm(url) abort return perm ==# '---------' ? '' : perm endfunction -function s:UpdateIndex(dir, info) abort +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' + let [error, exec_error] = s:SystemError(fugitive#Prepare([a:dir, 'update-index', '--index-info']), info) + return !exec_error ? '' : len(error) ? error : 'unknown update-index error' endfunction function! fugitive#setfperm(url, perm) abort @@ -1340,9 +1645,11 @@ function! s:TempCmd(out, cmd) abort try let cmd = (type(a:cmd) == type([]) ? fugitive#Prepare(a:cmd) : a:cmd) let redir = ' > ' . a:out - if (s:winshell() || &shellcmdflag ==# '-Command') && !has('nvim') + if s:winshell() && !has('nvim') let cmd_escape_char = &shellxquote == '(' ? '^' : '^^^' return s:SystemError('cmd /c "' . s:gsub(cmd, '[<>%]', cmd_escape_char . '&') . redir . '"') + elseif &shell =~? '\%(powershell\|pwsh\)\%(\.exe\)\=$' + return s:SystemError(&shell . ' ' . &shellcmdflag . ' ' . s:shellesc(cmd . redir)) elseif &shell =~# 'fish' return s:SystemError(' begin;' . cmd . redir . ';end ') else @@ -1493,11 +1800,11 @@ function! s:FilterEscape(items, ...) abort return items endfunction -function! s:GlobComplete(lead, pattern) abort +function! s:GlobComplete(lead, pattern, ...) abort if a:lead ==# '/' return [] elseif v:version >= 704 - let results = glob(a:lead . a:pattern, 0, 1) + let results = glob(a:lead . a:pattern, a:0 ? a:1 : 0, 1) else let results = split(glob(a:lead . a:pattern), "\n") endif @@ -1522,12 +1829,13 @@ function! fugitive#CompletePath(base, ...) abort let stripped = matchstr(a:base, '^\%(:(literal)\|:\)') let base = strpart(a:base, len(stripped)) endif - if base =~# '^\.git/' + if base =~# '^\.git/' && len(dir) let pattern = s:gsub(base[5:-1], '/', '*&').'*' - let matches = s:GlobComplete(dir . '/', pattern) - let cdir = fugitive#CommonDir(dir) - if len(cdir) && s:cpath(dir) !=# s:cpath(cdir) - call extend(matches, s:GlobComplete(cdir . '/', pattern)) + let fdir = fugitive#Find(dir . '/') + let matches = s:GlobComplete(fdir, pattern) + let cdir = fugitive#Find('.git/refs', dir)[0 : -5] + if len(cdir) && s:cpath(fdir) !=# s:cpath(cdir) + call extend(matches, s:GlobComplete(cdir, pattern)) endif call s:Uniq(matches) call map(matches, "'.git/' . v:val") @@ -1569,7 +1877,8 @@ function! fugitive#CompleteObject(base, ...) abort if a:base =~# '^\.\=/\|^:(' || a:base !~# ':' let results = [] if a:base =~# '^refs/' - let results += map(s:GlobComplete(fugitive#CommonDir(dir) . '/', a:base . '*'), 's:Slash(v:val)') + let cdir = fugitive#Find('.git/refs', dir)[0 : -5] + let results += map(s:GlobComplete(cdir, a:base . '*'), 's:Slash(v:val)') call map(results, 's:fnameescape(v:val)') elseif a:base !~# '^\.\=/\|^:(' let heads = s:CompleteHeads(dir) @@ -1597,8 +1906,7 @@ function! fugitive#CompleteObject(base, ...) abort 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","")') - + call map(entries,'parent.s:sub(v:val,".*\t","")') endif return s:FilterEscape(entries, a:base) endfunction @@ -1641,7 +1949,7 @@ function! s:ReplaceCmd(cmd) abort let temp = tempname() let [err, exec_error] = s:TempCmd(temp, a:cmd) if exec_error - call s:throw((len(err) ? err : filereadable(temp) ? join(readfile(temp), ' ') : 'unknown error running ' . a:cmd)) + call s:throw((len(err) ? err : 'unknown error running ' . a:cmd)) endif setlocal noswapfile silent exe 'lockmarks keepalt 0read ++edit' s:fnameescape(temp) @@ -1660,8 +1968,8 @@ endfunction function! s:QueryLog(refspec) abort let lines = s:LinesError(['log', '-n', '256', '--pretty=format:%h%x09%s', a:refspec, '--'])[0] - call map(lines, 'split(v:val, "\t")') - call map(lines, '{"type": "Log", "commit": v:val[0], "subject": v:val[-1]}') + call map(lines, 'split(v:val, "\t", 1)') + call map(lines, '{"type": "Log", "commit": v:val[0], "subject": join(v:val[1 : -1], "\t")}') return lines endfunction @@ -1745,7 +2053,11 @@ function! fugitive#BufReadStatus() abort let [staged, unstaged, untracked] = [[], [], []] let props = {} - if fugitive#GitVersion(2, 11) + let pull = '' + if empty(s:Tree()) + let branch = FugitiveHead(0) + let head = FugitiveHead(11) + elseif fugitive#GitVersion(2, 11) let cmd += ['status', '--porcelain=v2', '-bz'] let [output, message, exec_error] = s:NullError(cmd) if exec_error @@ -1759,7 +2071,7 @@ function! fugitive#BufReadStatus() abort if len(prop) let props[prop[1]] = prop[2] elseif line[0] ==# '?' - call add(untracked, {'type': 'File', 'status': line[0], 'filename': line[2:-1]}) + call add(untracked, {'type': 'File', 'status': line[0], 'filename': line[2:-1], 'relative': [line[2:-1]]}) elseif line[0] !=# '#' if line[0] ==# 'u' let file = matchstr(line, '^.\{37\} \x\{40,\} \x\{40,\} \x\{40,\} \zs.*$') @@ -1769,16 +2081,18 @@ function! fugitive#BufReadStatus() abort if line[0] ==# '2' let i += 1 let file = matchstr(file, ' \zs.*') - let files = output[i] . ' -> ' . file + let relative = [file, output[i]] else - let files = file + let relative = [file] endif + let filename = join(reverse(copy(relative)), ' -> ') let sub = matchstr(line, '^[12u] .. \zs....') if line[2] !=# '.' - call add(staged, {'type': 'File', 'status': line[2], 'filename': files, 'sub': sub}) + call add(staged, {'type': 'File', 'status': line[2], 'filename': filename, 'relative': relative, 'submodule': sub}) endif if line[3] !=# '.' - call add(unstaged, {'type': 'File', 'status': get({'C':'M','M':'?','U':'?'}, matchstr(sub, 'S\.*\zs[CMU]'), line[3]), 'filename': file, 'sub': sub}) + let sub = matchstr(line, '^[12u] .. \zs....') + call add(unstaged, {'type': 'File', 'status': get({'C':'M','M':'?','U':'?'}, matchstr(sub, 'S\.*\zs[CMU]'), line[3]), 'filename': file, 'relative': [file], 'submodule': sub}) endif endif let i += 1 @@ -1803,7 +2117,6 @@ function! fugitive#BufReadStatus() abort call remove(output, 0) endwhile let head = matchstr(output[0], '^## \zs\S\+\ze\%($\| \[\)') - let pull = '' if head =~# '\.\.\.' let [head, pull] = split(head, '\.\.\.') let branch = head @@ -1818,30 +2131,28 @@ function! fugitive#BufReadStatus() abort while i < len(output) let line = output[i] let file = line[3:-1] - let files = file let i += 1 if line[2] !=# ' ' continue endif if line[0:1] =~# '[RC]' - let files = output[i] . ' -> ' . file + let relative = [file, output[i]] let i += 1 + else + let relative = [file] endif + let filename = join(reverse(copy(relative)), ' -> ') if line[0] !~# '[ ?!#]' - call add(staged, {'type': 'File', 'status': line[0], 'filename': files, 'sub': ''}) + call add(staged, {'type': 'File', 'status': line[0], 'filename': filename, 'relative': relative, 'submodule': ''}) endif if line[0:1] ==# '??' - call add(untracked, {'type': 'File', 'status': line[1], 'filename': files}) + call add(untracked, {'type': 'File', 'status': line[1], 'filename': filename, 'relative': relative}) elseif line[1] !~# '[ !#]' - call add(unstaged, {'type': 'File', 'status': line[1], 'filename': file, 'sub': ''}) + call add(unstaged, {'type': 'File', 'status': line[1], 'filename': file, 'relative': [file], 'submodule': ''}) endif endwhile endif - if empty(s:Tree()) - let [unstaged, untracked] = [[], []] - endif - for dict in staged let b:fugitive_files['Staged'][dict.filename] = dict endfor @@ -1851,9 +2162,9 @@ function! fugitive#BufReadStatus() abort let pull_type = 'Pull' if len(pull) - let rebase = fugitive#Config('branch.' . branch . '.rebase', config) + let rebase = FugitiveConfigGet('branch.' . branch . '.rebase', config) if empty(rebase) - let rebase = fugitive#Config('pull.rebase', config) + let rebase = FugitiveConfigGet('pull.rebase', config) endif if rebase =~# '^\%(true\|yes\|on\|1\|interactive\|merges\|preserve\)$' let pull_type = 'Rebase' @@ -1862,11 +2173,11 @@ function! fugitive#BufReadStatus() abort endif endif - let push_remote = fugitive#Config('branch.' . branch . '.pushRemote', config) + let push_remote = FugitiveConfigGet('branch.' . branch . '.pushRemote', config) if empty(push_remote) - let push_remote = fugitive#Config('remote.pushDefault', config) + let push_remote = FugitiveConfigGet('remote.pushDefault', config) endif - let fetch_remote = fugitive#Config('branch.' . branch . '.remote', config) + let fetch_remote = FugitiveConfigGet('branch.' . branch . '.remote', config) if empty(fetch_remote) let fetch_remote = 'origin' endif @@ -1874,7 +2185,7 @@ function! fugitive#BufReadStatus() abort let push_remote = fetch_remote endif - let push_default = fugitive#Config('push.default') + let push_default = FugitiveConfigGet('push.default', config) if empty(push_default) let push_default = fugitive#GitVersion(2) ? 'simple' : 'matching' endif @@ -1938,10 +2249,12 @@ function! fugitive#BufReadStatus() abort if push !=# pull call s:AddHeader('Push', push) endif - if empty(s:Tree()) + if get(fugitive#ConfigGetAll('core.bare', config), 0, 'true') !~# '^\%(false\|no|off\|0\|\)$' call s:AddHeader('Bare', 'yes') + elseif empty(s:Tree()) + call s:AddHeader('Error', s:worktree_error) endif - if get(FugitiveConfigGetAll('advice.statusHints', config), 0, 'true') !~# '^\%(false\|no|off\|0\|\)$' + if get(fugitive#ConfigGetAll('advice.statusHints', config), 0, 'true') !~# '^\%(false\|no|off\|0\|\)$' call s:AddHeader('Help', 'g?') endif @@ -1971,7 +2284,7 @@ function! fugitive#BufReadStatus() abort if &bufhidden ==# '' setlocal bufhidden=delete endif - let b:dispatch = ':Git fetch --all' + let b:dispatch = '-dir=' . fnameescape(len(s:Tree()) ? s:Tree() : s:Dir()) . ' ' . s:GitShellCmd() . ' fetch --all' call fugitive#MapJumps() call s:Map('n', '-', ":execute Do('Toggle',0)", '') call s:Map('x', '-', ":execute Do('Toggle',1)", '') @@ -1986,7 +2299,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', ":echoerr ':Gstatus C has been removed in favor of cc'", '') + call s:Map('n', 'C', ":echoerr 'fugitive: 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)", '') @@ -1995,7 +2308,7 @@ function! fugitive#BufReadStatus() abort call s:Map('x', "=", ":execute StageInline('toggle',line(\"'<\"),line(\"'>\")-line(\"'<\")+1)", '') call s:Map('x', "<", ":execute StageInline('hide', line(\"'<\"),line(\"'>\")-line(\"'<\")+1)", '') call s:Map('x', ">", ":execute StageInline('show', line(\"'<\"),line(\"'>\")-line(\"'<\")+1)", '') - call s:Map('n', 'D', ":execute StageDiff('Gdiffsplit')redrawechohl WarningMsg echo ':Gstatus D is deprecated in favor of dd'echohl NONE", '') + call s:Map('n', 'D', ":echoerr 'fugitive: D has been removed in favor of dd'", '') call s:Map('n', 'dd', ":execute StageDiff('Gdiffsplit')", '') call s:Map('n', 'dh', ":execute StageDiff('Ghdiffsplit')", '') call s:Map('n', 'ds', ":execute StageDiff('Ghdiffsplit')", '') @@ -2009,7 +2322,7 @@ function! fugitive#BufReadStatus() abort call s:Map('n', 'I', ":execute StagePatch(line('.'),line('.'))", '') call s:Map('x', 'I', ":execute StagePatch(line(\"'<\"),line(\"'>\"))", '') if empty(mapcheck('q', 'n')) - nnoremap q :if bufnr('$') == 1quitelsebdeleteendifechohl WarningMsgecho ':Gstatus q is deprecated in favor of gq or the built-in C-W>q'echohl NONE + nnoremap q :echoerr "fugitive: q removed in favor of gq (or :q)" endif call s:Map('n', 'gq', ":if bufnr('$') == 1quitelsebdeleteendif", '') call s:Map('n', 'R', ":echohl WarningMsgecho 'Reloading is automatic. Use :e to force'echohl NONE", '') @@ -2056,7 +2369,7 @@ function! fugitive#FileReadCmd(...) abort endfunction function! fugitive#FileWriteCmd(...) abort - let tmp = tempname() + let temp = tempname() let amatch = a:0 ? a:1 : expand('') let autype = a:0 > 1 ? 'Buf' : 'File' if exists('#' . autype . 'WritePre') @@ -2067,13 +2380,13 @@ function! fugitive#FileWriteCmd(...) abort if commit !~# '^[0-3]$' || !v:cmdbang && (line("'[") != 1 || line("']") != line('$')) return "noautocmd '[,']write" . (v:cmdbang ? '!' : '') . ' ' . s:fnameescape(amatch) endif - silent execute "'[,']write !".fugitive#Prepare(dir, 'hash-object', '-w', '--stdin', '--').' > '.tmp - let sha1 = readfile(tmp)[0] - let old_mode = matchstr(s:SystemError([dir, 'ls-files', '--stage', '.' . file])[0], '^\d\+') + silent execute "noautocmd keepalt '[,']write ".temp + let hash = s:TreeChomp([dir, 'hash-object', '-w', '--', temp]) + let old_mode = matchstr(s:ChompError(['ls-files', '--stage', '.' . file], dir)[0], '^\d\+') if empty(old_mode) let old_mode = executable(s:Tree(dir) . file) ? '100755' : '100644' endif - let error = s:UpdateIndex(dir, [old_mode, sha1, commit, file[1:-1]]) + let error = s:UpdateIndex(dir, [old_mode, hash, commit, file[1:-1]]) if empty(error) setlocal nomodified if exists('#' . autype . 'WritePost') @@ -2083,8 +2396,10 @@ function! fugitive#FileWriteCmd(...) abort else return 'echoerr '.string('fugitive: '.error) endif + catch /^fugitive:/ + return 'echoerr ' . string(v:exception) finally - call delete(tmp) + call delete(temp) endtry endfunction @@ -2095,6 +2410,7 @@ function! fugitive#BufReadCmd(...) abort if empty(dir) return 'echo "Invalid Fugitive URL"' endif + let b:git_dir = dir if rev =~# '^:\d$' let b:fugitive_type = 'stage' else @@ -2136,6 +2452,9 @@ function! fugitive#BufReadCmd(...) abort setlocal endofline try + if b:fugitive_type !=# 'blob' + setlocal foldmarker=<<<<<<<<,>>>>>>>> + endif silent exe s:DoAutocmd('BufReadPre') if b:fugitive_type ==# 'tree' let b:fugitive_display_format = b:fugitive_display_format % 2 @@ -2159,7 +2478,7 @@ function! fugitive#BufReadCmd(...) abort if b:fugitive_display_format call s:ReplaceCmd([dir, 'cat-file', b:fugitive_type, rev]) else - call s:ReplaceCmd([dir, 'show', '--no-color', '-m', '--first-parent', '--pretty=format:tree%x20%T%nparent%x20%P%nauthor%x20%an%x20<%ae>%x20%ad%ncommitter%x20%cn%x20<%ce>%x20%cd%nencoding%x20%e%n%n%s%n%n%b', rev]) + call s:ReplaceCmd([dir, '-c', 'diff.noprefix=false', 'show', '--no-color', '-m', '--first-parent', '--pretty=format:tree%x20%T%nparent%x20%P%nauthor%x20%an%x20<%ae>%x20%ad%ncommitter%x20%cn%x20<%ce>%x20%cd%nencoding%x20%e%n%n%s%n%n%b', rev]) keepjumps 1 keepjumps call search('^parent ') if getline('.') ==# 'parent ' @@ -2189,7 +2508,7 @@ function! fugitive#BufReadCmd(...) abort endif let &l:modifiable = modifiable if b:fugitive_type !=# 'blob' - setlocal filetype=git foldmethod=syntax + setlocal filetype=git call s:Map('n', 'a', ":let b:fugitive_display_format += v:count1exe fugitive#BufReadCmd(@%)", '') call s:Map('n', 'i', ":let b:fugitive_display_format -= v:count1exe fugitive#BufReadCmd(@%)", '') endif @@ -2198,12 +2517,6 @@ function! fugitive#BufReadCmd(...) abort setlocal modifiable - let browsex = maparg('NetrwBrowseX', 'n') - let remote_check = '\Cnetrw#CheckIfRemote(\%(netrw#GX()\)\=)' - if browsex =~# remote_check - exe 'nnoremap NetrwBrowseX' substitute(browsex, remote_check, '0', 'g') - endif - return 'silent ' . s:DoAutocmd('BufReadPost') . \ (modifiable ? '' : '|setl nomodifiable') . '|silent ' . \ s:DoAutocmd('User Fugitive' . substitute(b:fugitive_type, '^\l', '\u&', '')) @@ -2239,15 +2552,33 @@ function! s:TempState(...) abort return get(s:temp_files, s:cpath(fnamemodify(a:0 ? a:1 : @%, ':p')), {}) endfunction +function! fugitive#Result(...) abort + if !a:0 && exists('g:fugitive_event') + return get(g:, 'fugitive_result', {}) + elseif !a:0 || type(a:1) == type('') && a:1 =~# '^-\=$' + return get(g:, '_fugitive_last_job', {}) + elseif type(a:1) == type(0) + return s:TempState(bufname(a:1)) + elseif type(a:1) == type('') + return s:TempState(a:1) + elseif type(a:1) == type({}) && has_key(a:1, 'file') + return s:TempState(a:1.file) + else + return {} + endif +endfunction + 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 + if empty(&bufhidden) + setlocal bufhidden=delete + endif setlocal buftype=nowrite setlocal nomodifiable + let b:git_dir = dict.dir if len(dict.dir) - let b:git_dir = dict.dir call extend(b:, {'fugitive_type': 'temp'}, 'keep') endif endif @@ -2256,32 +2587,47 @@ 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 + if !has_key(dict, 'job') + setlocal nobuflisted + endif + if get(dict, 'filetype', '') ==# 'git' + call fugitive#MapJumps() + endif + if has_key(dict, 'filetype') let &l:filetype = dict.filetype endif - setlocal foldmarker=<<<<<<<,>>>>>>> - if empty(mapcheck('q', 'n')) - nnoremap q :bdeleteechohl WarningMsgecho "Temp file q is deprecated in favor of the built-in C-W>q"echohl NONE - endif + setlocal foldmarker=<<<<<<<<,>>>>>>>> if !&modifiable + if empty(mapcheck('q', 'n')) + nnoremap q :echoerr "fugitive: q is removed in favor of gq (or :q)" + endif call s:Map('n', 'gq', ":bdelete", ' ') endif endif return '' endfunction +function! s:TempDelete(file) abort + let key = s:cpath(a:file) + if has_key(s:temp_files, key) && !has_key(s:temp_files[key], 'job') && key !=# s:cpath(get(get(g:, '_fugitive_last_job', {}), 'file', '')) + call delete(a:file) + call remove(s:temp_files, key) + endif + return '' +endfunction + augroup fugitive_temp autocmd! autocmd BufReadPre * exe s:TempReadPre( expand(':p')) autocmd BufReadPost * exe s:TempReadPost(expand(':p')) + autocmd BufWipeout * exe s:TempDelete( expand(':p')) augroup END " Section: :Git 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 (len($DISPLAY) || len($TERM_PROGRAM) || has('gui_running')) && + \ empty($GIT_ASKPASS) && empty($SSH_ASKPASS) && empty(fugitive#ConfigGetAll('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') @@ -2292,42 +2638,141 @@ function! s:AskPassArgs(dir) abort endfunction function! s:RunJobs() abort - return exists('*job_start') || exists('*jobstart') + return (exists('*job_start') || exists('*jobstart')) && exists('*bufwinid') 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 +function! s:RunSave(state) abort + let s:temp_files[s:cpath(a:state.file)] = a:state 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 - if has_key(a:state, 'buffer') - let data = remove(a:state, 'buffer') . data +function! s:RunFinished(state, ...) abort + if has_key(get(g:, '_fugitive_last_job', {}), 'file') && bufnr(g:_fugitive_last_job.file) < 0 + exe s:TempDelete(remove(g:, '_fugitive_last_job').file) endif - let escape = "\033]51;[^\007]*" - 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)) + let g:_fugitive_last_job = a:state + let first = join(readfile(a:state.file, '', 2), "\n") + if get(a:state, 'filetype', '') ==# 'git' && first =~# '\<\([[:upper:][:digit:]_-]\+(\d\+)\).*\1' + let a:state.filetype = 'man' endif - let cmd = matchstr(data, escape . "\007")[5:-2] - let data = substitute(data, escape . "\007", '', 'g') - if cmd =~# '^fugitive:' - let a:state.request = strpart(cmd, 9) + if !has_key(a:state, 'capture_bufnr') + return 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)) + call fugitive#ReloadStatus(a:state, 1) +endfunction + +function! s:RunEdit(state, tmp, job) abort + if get(a:state, 'request', '') !=# 'edit' + return 0 endif - echon substitute(data, "\r\\ze\n", '', 'g') + call remove(a:state, 'request') + let sentinel = a:state.file . '.edit' + let file = FugitiveVimPath(readfile(sentinel, '', 1)[0]) + exe substitute(a:state.mods, '\', '-tab', 'g') 'keepalt split' s:fnameescape(file) + set bufhidden=wipe + let s:edit_jobs[bufnr('')] = [a:state, a:tmp, a:job, sentinel] + call fugitive#ReloadStatus(a:state.dir, 1) + return 1 +endfunction + +function! s:RunReceive(state, tmp, type, job, data, ...) abort + if a:type ==# 'err' || a:state.pty + let data = type(a:data) == type([]) ? join(a:data, "\n") : a:data + let data = a:tmp.escape . data + let escape = "\033]51;[^\007]*" + let a:tmp.escape = matchstr(data, escape . '$') + if len(a:tmp.escape) + let data = strpart(data, 0, len(data) - len(a:tmp.escape)) + endif + let cmd = matchstr(data, escape . "\007")[5:-2] + let data = substitute(data, escape . "\007", '', 'g') + if cmd =~# '^fugitive:' + let a:state.request = strpart(cmd, 9) + endif + let lines = split(a:tmp.err . data, "\r\\=\n", 1) + let a:tmp.err = lines[-1] + let lines[-1] = '' + call map(lines, 'substitute(v:val, ".*\r", "", "")') + else + let lines = type(a:data) == type([]) ? a:data : split(a:data, "\n", 1) + if len(a:tmp.out) + let lines[0] = a:tmp.out . lines[0] + endif + let a:tmp.out = lines[-1] + let lines[-1] = '' + endif + call writefile(lines, a:state.file, 'ba') + if has_key(a:tmp, 'echo') + if !exists('l:data') + let data = type(a:data) == type([]) ? join(a:data, "\n") : a:data + endif + let a:tmp.echo .= data + endif + let line_count = a:tmp.line_count + let a:tmp.line_count += len(lines) - 1 + if !has_key(a:state, 'capture_bufnr') || !bufloaded(a:state.capture_bufnr) + return + endif + call remove(lines, -1) + try + call setbufvar(a:state.capture_bufnr, '&modifiable', 1) + if !line_count && len(lines) > 1000 + let first = remove(lines, 0, 999) + call setbufline(a:state.capture_bufnr, 1, first) + redraw + call setbufline(a:state.capture_bufnr, 1001, lines) + else + call setbufline(a:state.capture_bufnr, line_count + 1, lines) + endif + call setbufvar(a:state.capture_bufnr, '&modifiable', 0) + if !getwinvar(bufwinid(a:state.capture_bufnr), '&previewwindow') + " no-op + elseif exists('*win_execute') + call win_execute(bufwinid(a:state.capture_bufnr), '$') + else + let winnr = bufwinnr(a:state.capture_bufnr) + if winnr > 0 + let old_winnr = winnr() + exe 'noautocmd' winnr.'wincmd w' + $ + exe 'noautocmd' old_winnr.'wincmd w' + endif + endif + catch + endtry +endfunction + +function! s:RunExit(state, tmp, job, exit_status) abort + let a:state.exit_status = a:exit_status + if has_key(a:state, 'job') + return + endif + call s:RunFinished(a:state) +endfunction + +function! s:RunClose(state, tmp, job, ...) abort + if a:0 + call s:RunExit(a:state, a:tmp, a:job, a:1) + endif + let noeol = substitute(substitute(a:tmp.err, "\r$", '', ''), ".*\r", '', '') . a:tmp.out + call writefile([noeol], a:state.file, 'ba') + call remove(a:state, 'job') + if has_key(a:state, 'capture_bufnr') && bufloaded(a:state.capture_bufnr) + if len(noeol) + call setbufvar(a:state.capture_bufnr, '&modifiable', 1) + call setbufline(a:state.capture_bufnr, a:tmp.line_count + 1, [noeol]) + call setbufvar(a:state.capture_bufnr, '&eol', 0) + call setbufvar(a:state.capture_bufnr, '&modifiable', 0) + endif + call setbufvar(a:state.capture_bufnr, '&modified', 0) + call setbufvar(a:state.capture_bufnr, '&buflisted', 0) + if a:state.filetype !=# getbufvar(a:state.capture_bufnr, '&filetype', '') + call setbufvar(a:state.capture_bufnr, '&filetype', a:state.filetype) + endif + endif + if !has_key(a:state, 'exit_status') + return + endif + call s:RunFinished(a:state) endfunction function! s:RunSend(job, str) abort @@ -2343,27 +2788,75 @@ function! s:RunSend(job, str) abort endtry endfunction +function! s:RunCloseIn(job) abort + try + if type(a:job) ==# type(0) + call chanclose(a:job, 'stdin') + else + call ch_close_in(a:job) + endif + return 1 + catch /^Vim\%((\a\+)\)\=:E90[06]:/ + return 0 + endtry +endfunction + +function! s:RunEcho(tmp) abort + if !has_key(a:tmp, 'echo') + return + endif + let data = a:tmp.echo + let a:tmp.echo = matchstr(data, "[\r\n]\\+$") + if len(a:tmp.echo) + let data = strpart(data, 0, len(data) - len(a:tmp.echo)) + endif + echon substitute(data, "\r\\ze\n", '', 'g') +endfunction + +function! s:RunTick(job) abort + if type(a:job) == v:t_number + return jobwait([a:job], 1)[0] == -1 + elseif type(a:job) == 8 + let running = ch_status(a:job) !~# '^closed$\|^failed$' || job_status(a:job) ==# 'run' + sleep 1m + return running + endif +endfunction + if !exists('s:edit_jobs') let s:edit_jobs = {} endif -function! s:RunWait(state, job) abort - let finished = 0 +function! s:RunWait(state, tmp, job, ...) abort + if a:0 && filereadable(a:1) + call delete(a:1) + endif try - 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 - if !get(a:state, 'closed') + while get(a:state, 'request', '') !=# 'edit' && s:RunTick(a:job) + call s:RunEcho(a:tmp) + if !get(a:state, 'closed_in') 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) + if c ==# "\" || c ==# "\" + let a:state.closed_in = 1 + let can_pedit = s:RunCloseIn(a:job) && exists('*setbufline') + for winnr in range(1, winnr('$')) + if getwinvar(winnr, '&previewwindow') && getbufvar(winbufnr(winnr), '&modified') + let can_pedit = 0 + endif + endfor + if can_pedit + if has_key(a:tmp, 'echo') + call remove(a:tmp, 'echo') + endif + call writefile(['fugitive: aborting edit due to background operation.'], a:state.file . '.exit') + exe (&splitbelow ? 'botright' : 'topleft') 'silent pedit ++ff=unix' fnameescape(a:state.file) + let a:state.capture_bufnr = bufnr(a:state.file) + call setbufvar(a:state.capture_bufnr, '&modified', 1) + let finished = 0 + redraw! + return '' endif else call s:RunSend(a:job, c) @@ -2374,14 +2867,19 @@ function! s:RunWait(state, job) abort endif endif endwhile - sleep 1m - echo - call s:RunEdit(a:state, a:job) - let finished = 1 + if !has_key(a:state, 'request') && has_key(a:state, 'job') && exists('*job_status') && job_status(a:job) ==# "dead" + throw 'fugitive: close callback did not fire; this should never happen' + endif + call s:RunEcho(a:tmp) + if has_key(a:tmp, 'echo') + let a:tmp.echo = substitute(a:tmp.echo, "^\r\\=\n", '', '') + echo + endif + let finished = !s:RunEdit(a:state, a:tmp, a:job) finally - if !finished + if !exists('finished') try - if a:state.pty + if a:state.pty && !get(a:state, 'closed_in') call s:RunSend(a:job, "\") elseif type(a:job) == type(0) call jobstop(a:job) @@ -2390,9 +2888,10 @@ function! s:RunWait(state, job) abort endif catch /.*/ endtry + elseif finished + call fugitive#ReloadStatus(a:state, 1) endif endtry - call fugitive#ReloadStatus(a:state.dir, 1) return '' endfunction @@ -2401,27 +2900,39 @@ if !exists('s:resume_queue') 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') + if s:resume_queue[0][2] isnot# '' + try + call call('s:RunWait', remove(s:resume_queue, 0)) + endtry endif - call s:RunWait(state, job) endwhile endfunction function! s:RunBufDelete(bufnr) abort + let state = s:TempState(bufname(+a:bufnr)) + if has_key(state, 'job') + try + if type(state.job) == type(0) + call jobstop(state.job) + else + call job_stop(state.job) + endif + catch + endtry + endif if has_key(s:edit_jobs, a:bufnr) | call add(s:resume_queue, remove(s:edit_jobs, a:bufnr)) - call feedkeys(":redraw!|call fugitive#Resume()|silent checktime\r", 'n') + call feedkeys(":redraw!|call delete(" . string(s:resume_queue[-1][0].file . '.edit') . + \ ")|call fugitive#Resume()|silent checktime\r", 'n') endif endfunction augroup fugitive_job autocmd! - autocmd BufDelete * call s:RunBufDelete(expand('')) + autocmd BufDelete * call s:RunBufDelete(+expand('')) autocmd VimLeave * \ for s:jobbuf in keys(s:edit_jobs) | - \ call writefile([], s:edit_jobs[s:jobbuf][0].temp . '.exit') | + \ call writefile(['Aborting edit due to Vim exit.'], s:edit_jobs[s:jobbuf][0].file . '.exit') | \ redraw! | \ call call('s:RunWait', remove(s:edit_jobs, s:jobbuf)) | \ endfor @@ -2443,15 +2954,16 @@ function! fugitive#PagerFor(argv, ...) abort return 0 endif let config = a:0 ? a:1 : fugitive#Config() - let value = get(FugitiveConfigGetAll('pager.' . args[0], config), 0, -1) + let value = get(fugitive#ConfigGetAll('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$' || + elseif args[0] =~# '^\%(branch\|config\|diff\|grep\|log\|range-diff\|shortlog\|show\|tag\|whatchanged\)$' || \ (args[0] ==# 'stash' && get(args, 1, '') ==# 'show') || + \ (args[0] ==# 'reflog' && get(args, 1, '') !~# '^\%(expire\|delete\|exists\)$') || \ (args[0] ==# 'am' && s:HasOpt(args, '--show-current-patch')) return 1 else @@ -2465,7 +2977,11 @@ for s:colortype in ['advice', 'branch', 'diff', 'grep', 'interactive', 'pager', endfor unlet s:colortype function! fugitive#Command(line1, line2, range, bang, mods, arg) abort + exe s:VersionCheck() let dir = s:Dir() + if len(dir) + exe s:DirCheck(dir) + endif let config = copy(fugitive#Config(dir)) let [args, after] = s:SplitExpandChain(a:arg, s:Tree(dir)) let flags = [] @@ -2494,18 +3010,18 @@ function! fugitive#Command(line1, line2, range, bang, mods, arg) abort 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 = fugitive#Config('alias.' . get(args, 0, ''), config) + let alias = FugitiveConfigGet('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(get(args, 0, ''), '\%(^\|-\)\(\l\)', '\u\1', 'g') - let git = split(get(g:, 'fugitive_git_command', g:fugitive_git_executable), '\s\+') + let git = s:UserCommandList() let options = {'git': git, 'dir': dir, 'flags': flags} - if pager is# -1 && exists('*s:' . name . 'Subcommand') && get(args, 1, '') !=# '--help' + if pager is# -1 && name =~# '^\a\+$' && exists('*s:' . name . 'Subcommand') && get(args, 1, '') !=# '--help' try - let overrides = s:{name}Subcommand(a:line1, a:line2, a:range, a:bang, a:mods, extend({'command': args[0], 'args': args[1:-1]}, options)) + let overrides = s:{name}Subcommand(a:line1, a:line2, a:range, a:bang, a:mods, extend({'subcommand': args[0], 'subcommand_args': args[1:-1]}, options)) if type(overrides) == type('') return 'exe ' . string(overrides) . after endif @@ -2546,45 +3062,54 @@ function! fugitive#Command(line1, line2, range, bang, mods, arg) abort 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 - endif - if s:HasOpt(args, ['add', 'checkout', 'commit', 'stage', 'stash', 'reset'], '-p', '--patch') || + if (s:HasOpt(args, ['add', 'checkout', 'commit', 'stage', 'stash', 'reset'], '-p', '--patch') || \ s:HasOpt(args, ['add', 'clean', 'stage'], '-i', '--interactive') || - \ type(pager) == type('') + \ type(pager) == type('')) && pager isnot# 1 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 + call fugitive#Autowrite() 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 + call fugitive#Autowrite() return 'exe ' . string(mods . 'terminal ' . (a:line2 ? '' : '++curwin ') . join(map(s:UserCommandList(options) + args, 's:fnameescape(v:val)'))) . assign . after endif endif - if s:RunJobs() - 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 pager is# 1 && editcmd ==# 'read' + return s:ReadExec(a:line1, a:line2, a:range, a:mods, env, args, options) . after + endif + let state = { + \ 'git': git, + \ 'flags': flags, + \ 'args': args, + \ 'dir': dir, + \ 'git_dir': dir, + \ 'cwd': s:UserCommandCwd(dir), + \ 'filetype': 'git', + \ 'mods': s:Mods(a:mods), + \ 'file': s:Resolve(tempname())} + if pager is# 1 + call extend(env, {'COLUMNS': '' . get(g:, 'fugitive_columns', 80)}, 'keep') + else + call extend(env, {'COLUMNS': '' . &columns - 1}, 'keep') + endif + if s:RunJobs() && pager isnot# 1 + let state.pty = get(g:, 'fugitive_pty', has('unix') && !has('win32unix') && (has('patch-8.0.0744') || has('nvim')) && fugitive#GitVersion() !~# '\.windows\>') if !state.pty let args = s:AskPassArgs(dir) + args endif - let env.FUGITIVE_TEMP = state.temp + let tmp = { + \ 'line_count': 0, + \ 'err': '', + \ 'out': '', + \ 'echo': '', + \ 'escape': ''} + let env.FUGITIVE = state.file let editor = 'sh ' . s:TempScript( - \ '[ -f "$FUGITIVE_TEMP.exit" ] && exit 1', - \ 'echo "$1" > "$FUGITIVE_TEMP.edit"', - \ 'printf "\033]51;fugitive:edit\007"', - \ 'while [ -f "$FUGITIVE_TEMP.edit" -a ! -f "$FUGITIVE_TEMP.exit" ]; do sleep 0.05 2>/dev/null || sleep 1; done', + \ '[ -f "$FUGITIVE.exit" ] && cat "$FUGITIVE.exit" >&2 && exit 1', + \ 'echo "$1" > "$FUGITIVE.edit"', + \ 'printf "\033]51;fugitive:edit\007" >&2', + \ 'while [ -f "$FUGITIVE.edit" -a ! -f "$FUGITIVE.exit" ]; do sleep 0.05 2>/dev/null || sleep 1; done', \ 'exit 0') call extend(env, { \ 'NO_COLOR': '1', @@ -2596,13 +3121,17 @@ function! fugitive#Command(line1, line2, range, bang, mods, arg) abort 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 + call fugitive#Autowrite() + call writefile([], state.file, 'b') + call s:RunSave(state) + echo "" if exists('*job_start') call extend(jobopts, { \ 'mode': 'raw', - \ 'callback': function('s:RunReceive', [state]), + \ 'out_cb': function('s:RunReceive', [state, tmp, 'out']), + \ 'err_cb': function('s:RunReceive', [state, tmp, 'err']), + \ 'close_cb': function('s:RunClose', [state, tmp]), + \ 'exit_cb': function('s:RunExit', [state, tmp]), \ }) if state.pty let jobopts.pty = 1 @@ -2612,13 +3141,37 @@ function! fugitive#Command(line1, line2, range, bang, mods, arg) abort let job = jobstart(argv, extend(jobopts, { \ 'pty': state.pty, \ 'TERM': 'dumb', - \ 'on_stdout': function('s:RunReceive', [state]), - \ 'on_stderr': function('s:RunReceive', [state]), + \ 'on_stdout': function('s:RunReceive', [state, tmp, 'out']), + \ 'on_stderr': function('s:RunReceive', [state, tmp, 'err']), + \ 'on_exit': function('s:RunClose', [state, tmp]), \ })) endif let state.job = job - call s:RunWait(state, job) - return 'silent checktime' . after + call add(s:resume_queue, [state, tmp, job]) + return 'call fugitive#Resume()|silent checktime' . after + elseif pager is# 1 + let pre = s:BuildEnvPrefix(env) + try + if exists('+guioptions') && &guioptions =~# '!' + let guioptions = &guioptions + set guioptions-=! + endif + silent! execute '!' . escape(pre . s:UserCommand({'git': git, 'dir': dir}, s:disable_colors + flags + ['--no-pager'] + args), '!#%') . + \ (&shell =~# 'csh' ? ' >& ' . s:shellesc(state.file) : ' > ' . s:shellesc(state.file) . ' 2>&1') + let state.exit_status = v:shell_error + finally + if exists('guioptions') + let &guioptions = guioptions + endif + endtry + redraw! + call s:RunSave(state) + call s:RunFinished(state) + if editcmd ==# 'edit' + call s:BlurStatus() + endif + return state.mods . editcmd . ' ' . s:fnameescape(state.file) . + \ '|call fugitive#ReloadStatus(fugitive#Result(' . string(state.file) . '), 1)' . after elseif has('win32') return 'echoerr ' . string('fugitive: Vim 8 with job support required to use :Git on Windows') elseif has('gui_running') @@ -2633,28 +3186,75 @@ endfunction let s:exec_paths = {} function! s:ExecPath() abort - if !has_key(s:exec_paths, g:fugitive_git_executable) - let s:exec_paths[g:fugitive_git_executable] = s:sub(system(g:fugitive_git_executable.' --exec-path'),'\n$','') + let git = s:GitShellCmd() + if !has_key(s:exec_paths, git) + let s:exec_paths[git] = s:sub(system(git.' --exec-path'),'\n$','') endif - return s:exec_paths[g:fugitive_git_executable] + return s:exec_paths[git] endfunction -function! s:Subcommands() abort - let exec_path = s:ExecPath() - return map(split(glob(exec_path.'/git-*'),"\n"),'s:sub(v:val[strlen(exec_path)+5 : -1],"\\.exe$","")') -endfunction - -let s:aliases = {} -function! s:Aliases(dir) abort - 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[dir_key][matchstr(line, '\.\zs.\{-}\ze\n')] = matchstr(line, '\n\zs.*') - endfor +let s:subcommands_before_2_5 = [ + \ 'add', 'am', 'apply', 'archive', 'bisect', 'blame', 'branch', 'bundle', + \ 'checkout', 'cherry', 'cherry-pick', 'citool', 'clean', 'clone', 'commit', 'config', + \ 'describe', 'diff', 'difftool', 'fetch', 'format-patch', 'fsck', + \ 'gc', 'grep', 'gui', 'help', 'init', 'instaweb', 'log', + \ 'merge', 'mergetool', 'mv', 'notes', 'pull', 'push', + \ 'rebase', 'reflog', 'remote', 'repack', 'replace', 'request-pull', 'reset', 'revert', 'rm', + \ 'send-email', 'shortlog', 'show', 'show-branch', 'stash', 'stage', 'status', 'submodule', + \ 'tag', 'whatchanged', + \ ] +let s:path_subcommands = {} +function! s:CompletableSubcommands(dir) abort + let c_exec_path = s:cpath(s:ExecPath()) + if !has_key(s:path_subcommands, c_exec_path) + if fugitive#GitVersion(2, 18) + let [lines, exec_error] = s:LinesError(a:dir, '--list-cmds=list-mainporcelain,nohelpers,list-complete') + call filter(lines, 'v:val =~# "^\\S\\+$"') + if !exec_error && len(lines) + let s:path_subcommands[c_exec_path] = lines + else + let s:path_subcommands[c_exec_path] = s:subcommands_before_2_5 + + \ ['maintenance', 'prune', 'range-diff', 'restore', 'sparse-checkout', 'switch', 'worktree'] + endif + else + let s:path_subcommands[c_exec_path] = s:subcommands_before_2_5 + + \ (fugitive#GitVersion(2, 5) ? ['worktree'] : []) + endif + endif + let commands = copy(s:path_subcommands[c_exec_path]) + for path in split($PATH, has('win32') ? ';' : ':') + if path !~# '^/\|^\a:[\\/]' + continue + endif + let cpath = s:cpath(path) + if !has_key(s:path_subcommands, cpath) + let s:path_subcommands[cpath] = filter(map(s:GlobComplete(path.'/git-', '*', 1),'substitute(v:val,"\\.exe$","","")'), 'v:val !~# "--\\|/"') + endif + call extend(commands, s:path_subcommands[cpath]) + endfor + call extend(commands, keys(fugitive#ConfigGetRegexp('^alias\.\zs[^.]\+$', a:dir))) + let configured = split(FugitiveConfigGet('completion.commands', a:dir), '\s\+') + let rejected = {} + for command in configured + if command =~# '^-.' + let rejected[strpart(command, 1)] = 1 + endif + endfor + call filter(configured, 'v:val !~# "^-"') + let results = filter(sort(commands + configured), '!has_key(rejected, v:val)') + if exists('*uniq') + return uniq(results) + else + let i = 1 + while i < len(results) + if results[i] ==# results[i-1] + call remove(results, i) + else + let i += 1 + endif + endwhile + return results endif - return s:aliases[dir_key] endfunction function! fugitive#Complete(lead, ...) abort @@ -2663,7 +3263,7 @@ function! fugitive#Complete(lead, ...) abort 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))) + let results = s:CompletableSubcommands(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') @@ -2707,20 +3307,24 @@ function! s:StatusCommand(line1, line2, range, count, bang, mods, reg, arg, args try let mods = s:Mods(a:mods, &splitbelow ? 'botright' : 'topleft') let file = fugitive#Find(':', dir) - let arg = ' +setl\ foldmethod=syntax\ foldlevel=1\|let\ w:fugitive_status=FugitiveGitDir() ' . + let arg = ' +setl\ foldmarker=<<<<<<<<,>>>>>>>>\|let\ w:fugitive_status=FugitiveGitDir() ' . \ s:fnameescape(file) - for winnr in range(1, winnr('$')) - if s:cpath(file, fnamemodify(bufname(winbufnr(winnr)), ':p')) - if winnr == winnr() - call s:ReloadStatus() - else - call s:ExpireStatus(dir) - exe winnr . 'wincmd w' + for tabnr in [tabpagenr()] + (mods =~# '\' ? range(1, tabpagenr('$')) : []) + let bufs = tabpagebuflist(tabnr) + for winnr in range(1, tabpagewinnr(tabnr, '$')) + if s:cpath(file, fnamemodify(bufname(bufs[winnr-1]), ':p')) + if tabnr == tabpagenr() && winnr == winnr() + call s:ReloadStatus() + else + call s:ExpireStatus(dir) + exe tabnr . 'tabnext' + exe winnr . 'wincmd w' + endif + let w:fugitive_status = dir + 1 + return '' endif - let w:fugitive_status = dir - 1 - return '' - endif + endfor endfor if a:count ==# 0 return mods . 'edit' . (a:bang ? '!' : '') . arg @@ -2763,10 +3367,10 @@ endfunction function! s:StageSeek(info, fallback) abort let info = a:info - if empty(info.section) + if empty(info.heading) return a:fallback endif - let line = search('^' . info.section, 'wn') + let line = search('^' . escape(info.heading, '^$.*[]~\') . ' (\d\+)$', 'wn') if !line for section in get({'Staged': ['Unstaged', 'Untracked'], 'Unstaged': ['Untracked', 'Staged'], 'Untracked': ['Unstaged', 'Staged']}, info.section, []) let line = search('^' . section, 'wn') @@ -2827,9 +3431,12 @@ function! s:DoAutocmdChanged(dir) abort endif try let g:fugitive_event = dir + if type(a:dir) == type({}) && has_key(a:dir, 'args') + let g:fugitive_result = a:dir + endif exe s:DoAutocmd('User FugitiveChanged') finally - unlet! g:fugitive_event + unlet! g:fugitive_event g:fugitive_result " Force statusline reload with the buffer's Git dir let &ro = &ro endtry @@ -2843,8 +3450,7 @@ function! s:ReloadStatusBuffer(...) abort let original_lnum = a:0 ? a:1 : line('.') let info = s:StageInfo(original_lnum) call fugitive#BufReadStatus() - exe s:StageSeek(info, original_lnum) - normal! 0 + call setpos('.', [0, s:StageSeek(info, original_lnum), 1, 0]) return '' endfunction @@ -2861,7 +3467,7 @@ if !exists('s:last_times') endif function! s:ExpireStatus(bufnr) abort - if a:bufnr == -2 + if a:bufnr is# -2 let s:head_cache = {} let s:last_time = reltime() return '' @@ -2894,7 +3500,8 @@ endfunction function! s:ReloadTabStatus(...) abort let mytab = tabpagenr() let tab = a:0 ? a:1 : mytab - for winnr in range(1, tabpagewinnr(tab, '$')) + let winnr = 1 + while winnr <= tabpagewinnr(tab, '$') if getbufvar(tabpagebuflist(tab)[winnr-1], 'fugitive_type') ==# 'index' execute 'tabnext '.tab if winnr != winnr() @@ -2911,7 +3518,8 @@ function! s:ReloadTabStatus(...) abort execute 'tabnext '.mytab endtry endif - endfor + let winnr += 1 + endwhile unlet! t:fugitive_reload_status endfunction @@ -2924,10 +3532,11 @@ function! fugitive#ReloadStatus(...) abort call settabvar(tabnr, 'fugitive_reload_status', t) endfor call s:ReloadTabStatus() - exe s:DoAutocmdChanged(a:0 ? a:1 : -1) else call s:ReloadWinStatus() + return '' endif + exe s:DoAutocmdChanged(a:0 ? a:1 : -1) return '' endfunction @@ -2981,26 +3590,28 @@ function! s:StageInfo(...) abort endwhile endif let slnum = lnum + 1 - let section = '' + let heading = '' let index = 0 - while len(getline(slnum - 1)) && empty(section) + while len(getline(slnum - 1)) && empty(heading) let slnum -= 1 - let section = matchstr(getline(slnum), '^\u\l\+\ze.* (\d\+)$') - if empty(section) && getline(slnum) !~# '^[ @\+-]' + let heading = matchstr(getline(slnum), '^\u\l\+.\{-\}\ze (\d\+)$') + if empty(heading) && getline(slnum) !~# '^[ @\+-]' let index += 1 endif endwhile let text = matchstr(getline(lnum), '^[A-Z?] \zs.*') - return {'section': section, - \ 'heading': getline(slnum), + let file = get(get(b:fugitive_files, heading, {}), text, {}) + let relative = get(file, 'relative', len(text) ? [text] : []) + return {'section': matchstr(heading, '^\u\l\+'), + \ 'heading': heading, \ 'sigil': sigil, \ 'offset': offset, \ 'filename': text, - \ 'relative': reverse(split(text, ' -> ')), - \ 'paths': map(reverse(split(text, ' -> ')), 's:Tree() . "/" . v:val'), + \ 'relative': copy(relative), + \ 'paths': map(copy(relative), 's:Tree() . "/" . v:val'), \ 'commit': matchstr(getline(lnum), '^\%(\%(\x\x\x\)\@!\l\+\s\+\)\=\zs[0-9a-f]\{4,\}\ze '), \ 'status': matchstr(getline(lnum), '^[A-Z?]\ze \|^\%(\x\x\x\)\@!\l\+\ze [0-9a-f]'), - \ 'sub': get(get(get(b:fugitive_files, section, {}), text, {}), 'sub', ''), + \ 'submodule': get(file, 'submodule', ''), \ 'index': index} endfunction @@ -3034,11 +3645,11 @@ function! s:Selection(arg1, ...) abort let flnum -= 1 endwhile let slnum = flnum + 1 - let section = '' + let heading = '' let index = 0 - while len(getline(slnum - 1)) && empty(section) + while empty(heading) let slnum -= 1 - let heading = matchstr(getline(slnum), '^\u\l\+.* (\d\+)$') + let heading = matchstr(getline(slnum), '^\u\l\+.\{-\}\ze (\d\+)$') if empty(heading) && getline(slnum) !~# '^[ @\+-]' let index += 1 endif @@ -3046,7 +3657,7 @@ function! s:Selection(arg1, ...) abort let results = [] let template = { \ 'heading': heading, - \ 'section': matchstr(heading, '^\u\l\+\ze.* (\d\+)$'), + \ 'section': matchstr(heading, '^\u\l\+'), \ 'filename': '', \ 'relative': [], \ 'paths': [], @@ -3058,9 +3669,10 @@ function! s:Selection(arg1, ...) abort let lnum = first - (arg1 == flnum ? 0 : 1) let root = s:Tree() . '/' while lnum <= last - if line =~# '^\u\l\+\ze.* (\d\+)$' - let template.heading = getline(lnum) - let template.section = matchstr(template.heading, '^\u\l\+\ze.* (\d\+)$') + let heading = matchstr(line, '^\u\l\+\ze.\{-\}\ze (\d\+)$') + if len(heading) + let template.heading = heading + let template.section = matchstr(heading, '^\u\l\+') let template.index = 0 elseif line =~# '^[ @\+-]' let template.index -= 1 @@ -3069,12 +3681,14 @@ function! s:Selection(arg1, ...) abort endif let results[-1].lnum = lnum elseif line =~# '^[A-Z?] ' - let filename = matchstr(line, '^[A-Z?] \zs.*') + let text = matchstr(line, '^[A-Z?] \zs.*') + let file = get(get(b:fugitive_files, template.heading, {}), text, {}) + let relative = get(file, 'relative', len(text) ? [text] : []) call add(results, extend(deepcopy(template), { \ 'lnum': lnum, - \ 'filename': filename, - \ 'relative': reverse(split(filename, ' -> ')), - \ 'paths': map(reverse(split(filename, ' -> ')), 'root . v:val'), + \ 'filename': text, + \ 'relative': copy(relative), + \ 'paths': map(copy(relative), 'root . v:val'), \ 'status': matchstr(line, '^[A-Z?]'), \ })) elseif line =~# '^\x\x\x\+ ' @@ -3368,7 +3982,9 @@ function! s:StageInline(mode, ...) abort endif let lnum1 = a:0 ? a:1 : line('.') let lnum = lnum1 + 1 - if a:0 > 1 && a:2 == 0 + if a:0 > 1 && a:2 == 0 && lnum1 == 1 + let lnum = line('$') - 1 + elseif a:0 > 1 && a:2 == 0 let info = s:StageInfo(lnum - 1) if empty(info.paths) && len(info.section) while len(getline(lnum)) @@ -3435,6 +4051,9 @@ function! s:StageInline(mode, ...) abort silent call append(lnum, diff) let b:fugitive_expanded[info.section][info.filename] = [start, len(diff)] setlocal nomodifiable readonly nomodified + if foldclosed(lnum+1) > 0 + silent exe (lnum+1) . ',' . (lnum+len(diff)) . 'foldopen!' + endif endif endwhile return lnum @@ -3452,10 +4071,10 @@ function! s:StageDiff(diff) abort let lnum = line('.') let info = s:StageInfo(lnum) let prefix = info.offset > 0 ? '+' . info.offset : '' - if info.sub =~# '^S' + if info.submodule =~# '^S' if info.section ==# 'Staged' return 'Git --paginate diff --no-ext-diff --submodule=log --cached -- ' . info.paths[0] - elseif info.sub =~# '^SC' + elseif info.submodule =~# '^SC' return 'Git --paginate diff --no-ext-diff --submodule=log -- ' . info.paths[0] else return 'Git --paginate diff --no-ext-diff --submodule=diff -- ' . info.paths[0] @@ -3466,7 +4085,7 @@ function! s:StageDiff(diff) abort return 'Git --paginate diff --no-ext-diff' elseif len(info.paths) > 1 execute 'Gedit' . prefix s:fnameescape(':0:' . info.paths[0]) - return a:diff . '! HEAD:'.s:fnameescape(info.paths[1]) + return a:diff . '! @:'.s:fnameescape(info.paths[1]) elseif info.section ==# 'Staged' && info.sigil ==# '-' execute 'Gedit' prefix s:fnameescape(':0:'.info.paths[0]) return a:diff . '! :0:%' @@ -3497,7 +4116,7 @@ endfunction function! s:StageApply(info, reverse, extra) abort if a:info.status ==# 'R' - call s:throw('fugitive: patching renamed file not yet supported') + throw 'fugitive: patching renamed file not yet supported' endif let cmd = ['apply', '-p0', '--recount'] + a:extra let info = a:info @@ -3507,9 +4126,9 @@ function! s:StageApply(info, reverse, extra) abort if empty(filter(copy(lines), 'v:val =~# "^[+-]"')) return -1 endif - while getline(end) =~# '^[-+ ]' + while getline(end) =~# '^[-+\ ]' let end += 1 - if getline(end) =~# '^[' . (a:reverse ? '+' : '-') . ' ]' + if getline(end) =~# '^[' . (a:reverse ? '+' : '-') . '\ ]' call add(lines, ' ' . getline(end)[1:-1]) endif endwhile @@ -3522,7 +4141,7 @@ function! s:StageApply(info, reverse, extra) abort endif endwhile if start == 0 - throw 'fugitive: cold not find hunk' + throw 'fugitive: could not find hunk' elseif getline(start) !~# '^@@ ' throw 'fugitive: cannot apply conflict hunk' endif @@ -3553,28 +4172,22 @@ endfunction function! s:StageDelete(lnum1, lnum2, count) abort let restore = [] + let err = '' + let did_conflict_err = 0 try for info in s:Selection(a:lnum1, a:lnum2) if empty(info.paths) continue endif - let sub = get(get(get(b:fugitive_files, info.section, {}), info.filename, {}), 'sub') - if sub =~# '^S' - if info.status ==# 'A' - continue - endif - if info.section ==# 'Staged' - call s:TreeChomp('reset', '--', info.paths[0]) - endif - if info.status =~# '[MD]' - call s:TreeChomp('submodule', 'update', '--', info.paths[0]) - call add(restore, ':Git -C ' . info.relative[0] . ' checkout -') - endif - continue - endif - if info.status ==# 'D' - let undo = 'Gremove' + let sub = get(get(get(b:fugitive_files, info.section, {}), info.filename, {}), 'submodule') + if sub =~# '^S' && info.status ==# 'M' + let undo = 'Git checkout ' . fugitive#RevParse('HEAD', FugitiveExtractGitDir(info.paths[0]))[0:10] . ' --' + elseif sub =~# '^S' + let err .= '|echoerr ' . string('fugitive: will not touch submodule ' . string(info.relative[0])) + break + elseif info.status ==# 'D' + let undo = 'GRemove' elseif info.paths[0] =~# '/$' let err .= '|echoerr ' . string('fugitive: will not delete directory ' . string(info.relative[0])) break @@ -3583,25 +4196,48 @@ function! s:StageDelete(lnum1, lnum2, count) abort endif if info.patch call s:StageApply(info, 1, info.section ==# 'Staged' ? ['--index'] : []) + elseif sub =~# '^S' + if info.section ==# 'Staged' + call s:TreeChomp('reset', '--', info.paths[0]) + endif + call s:TreeChomp('submodule', 'update', '--', info.paths[0]) elseif info.status ==# '?' call s:TreeChomp('clean', '-f', '--', info.paths[0]) elseif a:count == 2 - call s:TreeChomp('checkout', '--ours', '--', info.paths[0]) + if get(b:fugitive_files['Staged'], info.filename, {'status': ''}).status ==# 'D' + call delete(FugitiveVimPath(info.paths[0])) + else + call s:TreeChomp('checkout', '--ours', '--', info.paths[0]) + endif elseif a:count == 3 - call s:TreeChomp('checkout', '--theirs', '--', info.paths[0]) + if get(b:fugitive_files['Unstaged'], info.filename, {'status': ''}).status ==# 'D' + call delete(FugitiveVimPath(info.paths[0])) + else + call s:TreeChomp('checkout', '--theirs', '--', info.paths[0]) + endif elseif info.status =~# '[ADU]' && \ get(b:fugitive_files[info.section ==# 'Staged' ? 'Unstaged' : 'Staged'], info.filename, {'status': ''}).status =~# '[AU]' - call s:TreeChomp('checkout', info.section ==# 'Staged' ? '--ours' : '--theirs', '--', info.paths[0]) + if get(g:, 'fugitive_conflict_x', 0) + call s:TreeChomp('checkout', info.section ==# 'Unstaged' ? '--ours' : '--theirs', '--', info.paths[0]) + else + if !did_conflict_err + let err .= '|echoerr "Use 2X for --ours or 3X for --theirs"' + let did_conflict_err = 1 + endif + continue + endif elseif info.status ==# 'U' - call s:TreeChomp('rm', '--', info.paths[0]) + call delete(FugitiveVimPath(info.paths[0])) elseif info.status ==# 'A' call s:TreeChomp('rm', '-f', '--', info.paths[0]) elseif info.section ==# 'Unstaged' call s:TreeChomp('checkout', '--', info.paths[0]) else - call s:TreeChomp('checkout', 'HEAD^{}', '--', info.paths[0]) + call s:TreeChomp('checkout', '@', '--', info.paths[0]) + endif + if len(undo) + call add(restore, ':Gsplit ' . s:fnameescape(info.relative[0]) . '|' . undo) endif - call add(restore, ':Gsplit ' . s:fnameescape(info.relative[0]) . '|' . undo) endfor catch /^fugitive:/ let err .= '|echoerr ' . string(v:exception) @@ -3624,6 +4260,15 @@ function! s:StageIgnore(lnum1, lnum2, count) abort call extend(paths, info.relative) endfor call map(paths, '"/" . v:val') + if !a:0 + let dir = fugitive#Find('.git/info/') + if !isdirectory(dir) + try + call mkdir(dir) + catch + endtry + endif + endif exe 'Gsplit' (a:count ? '.gitignore' : '.git/info/exclude') let last = line('$') if last == 1 && empty(getline(1)) @@ -3663,7 +4308,7 @@ function! s:DoStageUnpushedHeading(heading) abort let remote = '.' endif let branch = matchstr(a:heading, 'to \%([^/]\+/\)\=\zs\S\+') - call feedkeys(':Git push ' . remote . ' ' . 'HEAD:' . 'refs/heads/' . branch) + call feedkeys(':Git push ' . remote . ' ' . '@:' . 'refs/heads/' . branch) endfunction function! s:DoToggleUnpushedHeading(heading) abort @@ -3828,7 +4473,7 @@ function! s:CommitInteractive(line1, line2, range, bang, mods, options, patch) a endfunction function! s:CommitSubcommand(line1, line2, range, bang, mods, options) abort - let argv = copy(a:options.args) + let argv = copy(a:options.subcommand_args) let i = 0 while get(argv, i, '--') !=# '--' if argv[i] =~# '^-[apzsneiovq].' @@ -3889,17 +4534,17 @@ endfunction function! s:MergeSubcommand(line1, line2, range, bang, mods, options) abort let dir = a:options.dir - if empty(a:options.args) && ( + if empty(a:options.subcommand_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 ? '!' : '') . s:fnameescape(a:options.flags + ['mergetool']) + return 'echoerr ":Git merge for loading conflicts hase been removed in favor of :Git mergetool"' endif return {} endfunction function! s:RebaseSubcommand(line1, line2, range, bang, mods, options) abort - let args = a:options.args + let args = a:options.subcommand_args if s:HasOpt(args, '--autosquash') && !s:HasOpt(args, '-i', '--interactive') return {'env': {'GIT_SEQUENCE_EDITOR': 'true'}, 'insert_args': ['--interactive']} endif @@ -4023,24 +4668,21 @@ function! s:ToolStream(line1, line2, range, bang, mods, options, args, state) ab let a:state.mode = 'init' let a:state.from = '' let a:state.to = '' - 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 = s:UserCommandList({'git': a:options.git, 'dir': a:options.dir}) + ['-c', 'diff.context=0'] let exec += a:options.flags + ['--no-pager', 'diff', '--no-ext-diff', '--no-color', '--no-prefix'] + argv if prompt - 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) + let title = ':Git ' . s:fnameescape(a:options.flags + [a:options.subcommand] + a:options.subcommand_args) + return s:QuickfixStream(a:line2, 'difftool', title, exec, !a:bang, a:mods, s:function('s:ToolParse'), a:state) else let filename = '' let cmd = [] let tabnr = tabpagenr() + 1 - for line in split(s:SystemError(s:shellesc(exec))[0], "\n") + for line in split(s:SystemError(exec)[0], "\n") for item in s:ToolParse(a:state, line) if len(get(item, 'filename', '')) && item.filename != filename call add(cmd, 'tabedit ' . s:fnameescape(item.filename)) for i in reverse(range(len(get(item.context, 'diff', [])))) - call add(cmd, (i ? 'rightbelow' : 'leftabove') . ' vert Gdiffsplit! ' . s:fnameescape(item.context.diff[i].filename)) + call add(cmd, (i ? 'rightbelow' : 'leftabove') . ' vertical Gdiffsplit! ' . s:fnameescape(item.context.diff[i].filename)) endfor call add(cmd, 'wincmd =') let filename = item.filename @@ -4060,14 +4702,14 @@ function! s:MergetoolSubcommand(line1, line2, range, bang, mods, options) abort 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(a:line1, a:line2, a:range, a:bang, a:mods, a:options, ['--diff-filter=U'] + a:options.args, state) + return s:ToolStream(a:line1, a:line2, a:range, a:bang, a:mods, a:options, ['--diff-filter=U'] + a:options.subcommand_args, state) endfunction 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:options.args) + let argv = copy(a:options.subcommand_args) let commits = [] let cached = 0 let reverse = 1 @@ -4198,8 +4840,8 @@ function! s:GrepSubcommand(line1, line2, range, bang, mods, options) abort let listnr = a:line1 == 0 ? a:line1 : a:line2 let cmd = ['--no-pager', 'grep', '-n', '--no-color', '--full-name'] let tree = s:Tree(dir) - let args = a:options.args - if get(args, 0, '') =~# '^-O\|--open-files-in-pager$' + let args = a:options.subcommand_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') @@ -4216,8 +4858,18 @@ function! s:GrepSubcommand(line1, line2, range, bang, mods, options) abort let prefix = FugitiveVimPath(s:HasOpt(args, '--cached') || empty(tree) ? \ 'fugitive://' . dir . '//0/' : \ s:cpath(getcwd(), tree) ? '' : tree . '/') - exe '!' . escape(s:UserCommand(a:options, cmd + args), '%#!') - \ printf(&shellpipe . (&shellpipe =~# '%s' ? '' : ' %s'), s:shellesc(tempfile)) + try + if exists('+guioptions') && &guioptions =~# '!' + let guioptions = &guioptions + set guioptions-=! + endif + exe '!' . escape(s:UserCommand(a:options, cmd + args), '%#!') + \ printf(&shellpipe . (&shellpipe =~# '%s' ? '' : ' %s'), s:shellesc(tempfile)) + finally + if exists('guioptions') + let &guioptions = guioptions + endif + endtry let list = map(readfile(tempfile), 's:GrepParseLine(prefix, name_only, dir, v:val)') call s:QuickfixSet(listnr, list, 'a') silent exe s:DoAutocmd('QuickFixCmdPost ' . event) @@ -4337,7 +4989,8 @@ function! fugitive#LogCommand(line1, count, range, bang, mods, args, type) abort let dir = s:Dir() exe s:DirCheck(dir) let listnr = a:type =~# '^l' ? 0 : -1 - let [args, after] = s:SplitExpandChain(a:args, s:Tree(dir)) + let [args, after] = s:SplitExpandChain('log ' . a:args, s:Tree(dir)) + call remove(args, 0) let split = index(args, '--') if split > 0 let paths = args[split : -1] @@ -4388,7 +5041,7 @@ function! fugitive#LogCommand(line1, count, range, bang, mods, args, type) abort if len(path) && empty(filter(copy(args), 'v:val =~# "^[^-]"')) let owner = s:Owner(@%, dir) if len(owner) - call add(args, owner) + call add(args, owner . (owner =~# '^\x\{40,}' ? '' : '^{}')) endif endif if empty(extra_paths) @@ -4400,20 +5053,12 @@ function! fugitive#LogCommand(line1, count, range, bang, mods, args, type) abort let format = "%h %P\t%H " . g:fugitive_summary_format endif let cmd = ['--no-pager'] - if fugitive#GitVersion(1, 9) - call extend(cmd, ['-c', 'diff.context=0', '-c', 'diff.noprefix=false', 'log']) - else - call extend(cmd, ['log', '-U0', '-s']) - endif - call extend(cmd, + call extend(cmd, ['-c', 'diff.context=0', '-c', 'diff.noprefix=false', 'log'] + \ ['--no-color', '--no-ext-diff', '--pretty=format:fugitive ' . format] + \ 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) && 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 + return s:QuickfixStream(listnr, 'log', title, s:UserCommandList(dir) + cmd, !a:bang, a:mods, s:function('s:LogParse'), state, dir) . after endfunction " Section: :Gedit, :Gpedit, :Gsplit, :Gvsplit, :Gtabedit, :Gread @@ -4422,13 +5067,25 @@ function! s:UsableWin(nr) abort return a:nr && !getwinvar(a:nr, '&previewwindow') && !getwinvar(a:nr, '&winfixwidth') && \ (empty(getwinvar(a:nr, 'fugitive_status')) || getbufvar(winbufnr(a:nr), 'fugitive_type') !=# 'index') && \ index(['gitrebase', 'gitcommit'], getbufvar(winbufnr(a:nr), '&filetype')) < 0 && - \ index(['nofile','help','quickfix'], getbufvar(winbufnr(a:nr), '&buftype')) < 0 + \ index(['nofile','help','quickfix', 'terminal'], getbufvar(winbufnr(a:nr), '&buftype')) < 0 endfunction -function! s:OpenParse(args, wants_cmd) abort +function! s:ArgSplit(string) abort + let string = a:string + let args = [] + while string =~# '\S' + let arg = matchstr(string, '^\s*\%(\\.\|[^[:space:]]\)\+') + let string = strpart(string, len(arg)) + let arg = substitute(arg, '^\s\+', '', '') + call add(args, substitute(arg, '\\\@' @@ -4449,7 +5114,7 @@ function! s:OpenParse(args, wants_cmd) abort endif let dir = s:Dir() let efile = s:Expand(file) - let url = fugitive#Find(efile, dir) + let url = s:Generate(efile, dir) if a:wants_cmd && file[0] ==# '>' && efile[0] !=# '>' && get(b:, 'fugitive_type', '') isnot# 'tree' && &filetype !=# 'netrw' let line = line('.') @@ -4525,43 +5190,21 @@ function! s:BlurStatus() abort endif endfunction -function! s:OpenExec(cmd, mods, env, args, ...) abort - let options = a:0 ? a:1 : {'dir': s:Dir()} - let temp = tempname() - let columns = get(g:, 'fugitive_columns', 80) - 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) - let first = join(readfile(temp, '', 2), "\n") - if first =~# '\<\([[:upper:][:digit:]_-]\+(\d\+)\).*\1' - let filetype = 'man' - else - let filetype = 'git' - endif - let s:temp_files[s:cpath(temp)] = { 'dir': options.dir, 'filetype': filetype } - if a:cmd ==# 'edit' - call s:BlurStatus() - endif - silent execute s:Mods(a:mods) . a:cmd temp - call fugitive#ReloadStatus(options.dir, 1) - return 'echo ' . string(':!' . s:UserCommand(options, a:args)) -endfunction - +let s:bang_edits = {'split': 'Git', 'vsplit': 'vertical Git', 'tabedit': 'tab Git', 'pedit': 'Git!'} function! fugitive#Open(cmd, bang, mods, arg, args) abort + exe s:VersionCheck() if a:bang - return s:OpenExec(a:cmd, a:mods, {}, s:SplitExpand(a:arg, s:Tree())) + return 'echoerr ' . string(':G' . a:cmd . '! for temp buffer output has been replaced by :' . get(s:bang_edits, a:cmd, 'Git') . ' --paginate') endif let mods = s:Mods(a:mods) try - let [file, pre] = s:OpenParse(a:args, 1) + let [file, pre] = s:OpenParse(a:arg, 1) catch /^fugitive:/ return 'echoerr ' . string(v:exception) endtry - if file !~# '^\a\a\+:' - let file = s:sub(file, '/$', '') + if file !~# '^\a\a\+:' && !(has('win32') && file =~# '^\a:/$') + let file = substitute(file, '.\zs' . (has('win32') ? '[\/]' : '/') . '$', '', '') endif if a:cmd ==# 'edit' call s:BlurStatus() @@ -4585,7 +5228,7 @@ function! s:ReadPrepare(line1, count, range, mods) abort else let pre = '' endif - return [pre . mods . after . 'read', delete . 'diffupdate' . (a:count < 0 ? '|' . line('.') : '')] + return [pre . 'keepalt ' . mods . after . 'read', delete . 'diffupdate' . (a:count < 0 ? '|' . line('.') : '')] endfunction function! s:ReadExec(line1, count, range, mods, env, args, options) abort @@ -4598,19 +5241,18 @@ function! s:ReadExec(line1, count, range, mods, env, args, options) abort endfunction function! fugitive#ReadCommand(line1, count, range, bang, mods, arg, args) abort + exe s:VersionCheck() if a:bang - let dir = s:Dir() - let args = s:SplitExpand(a:arg, s:Tree(dir)) - return s:ReadExec(a:line1, a:count, a:range, a:mods, {}, args, {'dir': dir}) + return 'echoerr ' . string(':Gread! for temp buffer output has been replaced by :{range}Git! --paginate') endif let [read, post] = s:ReadPrepare(a:line1, a:count, a:range, a:mods) try - let [file, pre] = s:OpenParse(a:args, 0) + let [file, pre] = s:OpenParse(a:arg, 0) catch /^fugitive:/ return 'echoerr ' . string(v:exception) endtry if file =~# '^fugitive:' && a:count is# 0 - return 'exe ' .string(s:Mods(a:mods) . fugitive#FileReadCmd(file, 0, pre)) . '|diffupdate' + return 'exe ' .string('keepalt ' . s:Mods(a:mods) . fugitive#FileReadCmd(file, 0, pre)) . '|diffupdate' endif return read . ' ' . pre . ' ' . s:fnameescape(file) . '|' . post endfunction @@ -4634,17 +5276,23 @@ endfunction " Section: :Gwrite, :Gwq function! fugitive#WriteCommand(line1, line2, range, bang, mods, arg, args) abort - if s:cpath(expand('%:p'), fugitive#Find('.git/COMMIT_EDITMSG')) + exe s:VersionCheck() + if s:cpath(expand('%:p'), fugitive#Find('.git/COMMIT_EDITMSG')) && empty(a:arg) return (empty($GIT_INDEX_FILE) ? 'write|bdelete' : 'wq') . (a:bang ? '!' : '') - elseif get(b:, 'fugitive_type', '') ==# 'index' + elseif get(b:, 'fugitive_type', '') ==# 'index' && empty(a:arg) 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 let mytab = tabpagenr() let mybufnr = bufnr('') + let args = s:ArgSplit(a:arg) + let after = '' + if get(args, 0) =~# '^+' + let after = '|' . remove(args, 0)[1:-1] + endif try - let file = len(a:args) ? s:Generate(s:Expand(join(a:args, ' '))) : fugitive#Real(@%) + let file = len(args) ? s:Generate(s:Expand(join(args, ' '))) : fugitive#Real(@%) catch /^fugitive:/ return 'echoerr ' . string(v:exception) endtry @@ -4717,9 +5365,9 @@ function! fugitive#WriteCommand(line1, line2, range, bang, mods, arg, args) abor setlocal nomodified endif - let one = s:Generate(':1:'.file) - let two = s:Generate(':2:'.file) - let three = s:Generate(':3:'.file) + let one = fugitive#Find(':1:'.file) + let two = fugitive#Find(':2:'.file) + let three = fugitive#Find(':3:'.file) for nr in range(1,bufnr('$')) let name = fnamemodify(bufname(nr), ':p') if bufloaded(nr) && !getbufvar(nr,'&modified') && (name ==# one || name ==# two || name ==# three) @@ -4728,7 +5376,7 @@ function! fugitive#WriteCommand(line1, line2, range, bang, mods, arg, args) abor endfor unlet! restorewinnr - let zero = s:Generate(':0:'.file) + let zero = fugitive#Find(':0:'.file) silent exe s:DoAutocmd('BufWritePost ' . s:fnameescape(zero)) for tab in range(1,tabpagenr('$')) for winnr in range(1,tabpagewinnr(tab,'$')) @@ -4759,7 +5407,7 @@ function! fugitive#WriteCommand(line1, line2, range, bang, mods, arg, args) abor endfor endfor call fugitive#ReloadStatus(-1, 1) - return 'checktime' + return 'silent checktime' . after endfunction function! fugitive#WqCommand(...) abort @@ -4785,45 +5433,6 @@ function! fugitive#FetchComplete(A, L, P, ...) abort return s:CompleteSub('fetch', a:A, a:L, a:P, function('s:CompleteRemote'), a:000) endfunction -function! s:Dispatch(bang, options) abort - let dir = a:options.dir - exe s:DirCheck(dir) - 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({'git': a:options.git, 'dir': dir}, s:AskPassArgs(dir) + a:options.flags + [a:options.command] + a:options.args) - if exists(':Make') == 2 - Make - return '' - else - if !has('patch-8.1.0334') && has('terminal') && &autowrite - let autowrite_was_set = 1 - set noautowrite - silent! wall - endif - silent noautocmd make! - redraw! - return 'call fugitive#Cwindow()|silent ' . s:DoAutocmd('ShellCmdPost') - endif - finally - let [&l:mp, &l:efm, b:current_compiler] = [mp, efm, cc] - if empty(cc) | unlet! b:current_compiler | endif - if exists('autowrite_was_set') - set autowrite - endif - endtry -endfunction - -function! s:PushSubcommand(line1, line2, range, bang, mods, options) abort - return s:Dispatch(a:bang ? '!' : '', a:options) -endfunction - -function! s:FetchSubcommand(line1, line2, range, bang, mods, options) abort - return s:Dispatch(a:bang ? '!' : '', a:options) -endfunction - " Section: :Gdiff augroup fugitive_diff @@ -4944,7 +5553,8 @@ function! s:IsConflicted() abort endfunction function! fugitive#Diffsplit(autodir, keepfocus, mods, arg, args) abort - let args = copy(a:args) + exe s:VersionCheck() + let args = s:ArgSplit(a:arg) let post = '' if get(args, 0) =~# '^+' let post = remove(args, 0)[1:-1] @@ -4963,12 +5573,12 @@ function! fugitive#Diffsplit(autodir, keepfocus, mods, arg, args) abort let back = exists('*win_getid') ? 'call win_gotoid(' . win_getid() . ')' : 'wincmd p' if (empty(args) || args[0] ==# ':') && a:keepfocus exe s:DirCheck() - if empty(commit) && s:IsConflicted() + if commit =~# '^1\=$' && s:IsConflicted() let parents = [s:Relative(':2:'), s:Relative(':3:')] elseif empty(commit) let parents = [s:Relative(':0:')] elseif commit =~# '^\d\=$' - let parents = [s:Relative('HEAD:')] + let parents = [s:Relative('@:')] elseif commit =~# '^\x\x\+$' let parents = s:LinesError(['rev-parse', commit . '^@'])[0] call map(parents, 's:Relative(v:val . ":")') @@ -4979,7 +5589,11 @@ function! fugitive#Diffsplit(autodir, keepfocus, mods, arg, args) abort exe pre let mods = (a:autodir ? s:diff_modifier(len(parents) + 1) : '') . s:Mods(mods, 'leftabove') let nr = bufnr('') - execute mods 'split' s:fnameescape(s:Generate(parents[0])) + if len(parents) > 1 && !&equalalways + let equalalways = 0 + set equalalways + endif + execute mods 'split' s:fnameescape(fugitive#Find(parents[0])) call s:Map('n', 'dp', ':diffput '.nr.'diffupdate', '') let nr2 = bufnr('') call s:diffthis() @@ -4987,7 +5601,7 @@ function! fugitive#Diffsplit(autodir, keepfocus, mods, arg, args) abort call s:Map('n', 'd2o', ':diffget '.nr2.'diffupdate', '') let mods = substitute(mods, '\Cleftabove\|rightbelow\|aboveleft\|belowright', '\=submatch(0) =~# "f" ? "rightbelow" : "leftabove"', '') for i in range(len(parents)-1, 1, -1) - execute mods 'split' s:fnameescape(s:Generate(parents[i])) + execute mods 'split' s:fnameescape(fugitive#Find(parents[i])) call s:Map('n', 'dp', ':diffput '.nr.'diffupdate', '') let nrx = bufnr('') call s:diffthis() @@ -4995,9 +5609,6 @@ function! fugitive#Diffsplit(autodir, keepfocus, mods, arg, args) abort call s:Map('n', 'd' . (i + 2) . 'o', ':diffget '.nrx.'diffupdate', '') endfor call s:diffthis() - if len(parents) > 1 - wincmd = - endif return post elseif len(args) let arg = join(args, ' ') @@ -5050,8 +5661,6 @@ function! fugitive#Diffsplit(autodir, keepfocus, mods, arg, args) abort set diffopt-=vertical endif execute mods 'diffsplit' s:fnameescape(spec) - let &l:readonly = &l:readonly - redraw let w:fugitive_diff_restore = restore let winnr = winnr() if getwinvar('#', '&diff') @@ -5063,13 +5672,16 @@ function! fugitive#Diffsplit(autodir, keepfocus, mods, arg, args) abort catch /^fugitive:/ return 'echoerr ' . string(v:exception) finally + if exists('l:equalalways') + let &l:equalalways = equalalways + endif if exists('diffopt') let &diffopt = diffopt endif endtry endfunction -" Section: :Gmove, :Gremove +" Section: :GMove, :GRemove function! s:Move(force, rename, destination) abort let dir = s:Dir() @@ -5168,9 +5780,9 @@ endfunction function! s:Keywordprg() abort let args = ' --git-dir='.escape(s:Dir(),"\\\"' ") if has('gui_running') && !has('win32') - return g:fugitive_git_executable . ' --no-pager' . args . ' log -1' + return s:GitShellCmd() . ' --no-pager' . args . ' log -1' else - return g:fugitive_git_executable . args . ' show' + return s:GitShellCmd() . args . ' show' endif endfunction @@ -5187,7 +5799,7 @@ endfunction function! s:BlameBufnr(...) abort let state = s:TempState(bufname(a:0 ? a:1 : '')) if get(state, 'filetype', '') ==# 'fugitiveblame' - return get(state, 'bufnr', -1) + return get(state, 'origin_bufnr', -1) else return -1 endif @@ -5195,7 +5807,10 @@ endfunction function! s:BlameCommitFileLnum(...) abort let line = a:0 ? a:1 : getline('.') - let state = a:0 ? a:2 : s:TempState() + let state = a:0 > 1 ? a:2 : s:TempState() + if get(state, 'filetype', '') !=# 'fugitiveblame' + return ['', '', 0] + endif let commit = matchstr(line, '^\^\=[?*]*\zs\x\+') if commit =~# '^0\+$' let commit = '' @@ -5238,7 +5853,7 @@ endfunction 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 flags = copy(a:options.subcommand_args) let i = 0 let raw = 0 let commits = [] @@ -5273,7 +5888,7 @@ function! s:BlameSubcommand(line1, count, range, bang, mods, options) abort let i += 1 if i == len(flags) echohl ErrorMsg - echo s:ChompError(['blame', arg])[0] + echo s:ChompError([dir, 'blame', arg])[0] echohl NONE return '' endif @@ -5311,33 +5926,32 @@ function! s:BlameSubcommand(line1, count, range, bang, mods, options) abort endif exe s:BlameLeave() try - let cmd = a:options.flags + ['--no-pager', '-c', 'blame.coloring=none', '-c', 'blame.blankBoundary=false', a:options.command, '--show-number'] + let cmd = a:options.flags + ['--no-pager', '-c', 'blame.coloring=none', '-c', 'blame.blankBoundary=false', a:options.subcommand, '--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('.'))] endif call extend(cmd, ranges) + let tempname = tempname() + let temp = tempname . (raw ? '' : '.fugitiveblame') if len(commits) let cmd += commits elseif empty(files) && len(matchstr(s:DirCommitFile(@%)[1], '^\x\x\+$')) let cmd += [matchstr(s:DirCommitFile(@%)[1], '^\x\x\+$')] elseif empty(files) && !s:HasOpt(flags, '--reverse') - let cmd += ['--contents', '-'] + let cmd += ['--contents', tempname . '.in'] + silent execute 'noautocmd keepalt %write ' . s:fnameescape(tempname . '.in') + let delete_in = 1 endif - 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') - if &shell =~# 'csh' - silent! execute '%write !('.basecmd.' > '.temp.') >& '.error - else - silent! execute '%write !'.basecmd.' > '.temp.' 2> '.error + let basecmd = [{'git': a:options.git, 'dir': dir}] + ['--literal-pathspecs'] + cmd + ['--'] + (len(files) ? files : [file]) + let [err, exec_error] = s:TempCmd(temp, basecmd) + if exists('delete_in') + call delete(tempname . '.in') endif - let l:shell_error = v:shell_error redraw try - if l:shell_error - let lines = readfile(error) + if exec_error + let lines = split(err, "\n") if empty(lines) let lines = readfile(temp) endif @@ -5356,7 +5970,17 @@ function! s:BlameSubcommand(line1, count, range, bang, mods, options) abort endfor return '' endif - let temp_state = {'dir': dir, 'filetype': (raw ? '' : 'fugitiveblame'), 'options': a:options, 'blame_flags': flags, 'blame_file': file} + let temp_state = { + \ 'git': a:options.git, + \ 'flags': a:options.flags, + \ 'args': [a:options.subcommand] + a:options.subcommand_args, + \ 'dir': dir, + \ 'git_dir': dir, + \ 'cwd': s:UserCommandCwd(dir), + \ 'filetype': (raw ? 'git' : 'fugitiveblame'), + \ 'blame_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 @@ -5365,23 +5989,25 @@ function! s:BlameSubcommand(line1, count, range, bang, mods, options) abort return s:BlameCommit(edit, get(readfile(temp), 0, ''), temp_state) else let temp = s:Resolve(temp) - let s:temp_files[s:cpath(temp)] = temp_state + let temp_state.file = temp + call s:RunSave(temp_state) if len(ranges + commits + files) || raw + let reload = '|call fugitive#ReloadStatus(fugitive#Result(' . string(temp_state.file) . '), 1)' let mods = s:Mods(a:mods) if a:count != 0 exe 'silent keepalt' mods 'split' s:fnameescape(temp) elseif !&modified || a:bang || &bufhidden ==# 'hide' || (empty(&bufhidden) && &hidden) exe 'silent' mods 'edit' . (a:bang ? '! ' : ' ') . s:fnameescape(temp) else - return mods . 'edit ' . s:fnameescape(temp) + return mods . 'edit ' . s:fnameescape(temp) . reload endif - return '' + return reload[1 : -1] endif if a:mods =~# '\' silent tabedit % endif let bufnr = bufnr('') - let temp_state.bufnr = bufnr + let temp_state.origin_bufnr = bufnr let restore = [] let mods = substitute(a:mods, '\', '', 'g') for winnr in range(winnr('$'),1,-1) @@ -5434,12 +6060,10 @@ function! s:BlameSubcommand(line1, count, range, bang, mods, options) abort if exists('+signcolumn') setlocal signcolumn=no endif - execute "vertical resize ".(s:linechars('.\{-\}\ze\s\+\d\+)')+1) - call s:Map('n', 'A', ":exe 'vertical resize '.(linechars('.\\{-\\}\\ze [0-9:/+-][0-9:/+ -]* \\d\\+)')+1+v:count)", '') - call s:Map('n', 'C', ":exe 'vertical resize '.(linechars('^\\S\\+')+1+v:count)", '') - call s:Map('n', 'D', ":exe 'vertical resize '.(linechars('.\\{-\\}\\ze\\d\\ze\\s\\+\\d\\+)')+1-v:count)", '') + execute "vertical resize ".(s:linechars('.\{-\}\s\+\d\+\ze)')+1) redraw syncbind + exe s:DoAutocmdChanged(temp_state) endif endtry return '' @@ -5510,7 +6134,7 @@ function! s:BlameJump(suffix, ...) abort return 'echoerr ' . string('fugitive: could not determine filename for blame') endif if commit =~# '^0*$' - let commit = 'HEAD' + let commit = '@' let suffix = '' endif let offset = line('.') - line('w0') @@ -5537,10 +6161,10 @@ function! s:BlameJump(suffix, ...) abort 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')) + let result = s:BlameSubcommand(0, 0, 0, 0, '', extend({'subcommand_args': blame_args}, state.blame_options, 'keep')) else let blame_args = flags - let result = s:BlameSubcommand(-1, -1, 0, 0, '', extend({'args': blame_args}, state.options, 'keep')) + let result = s:BlameSubcommand(-1, -1, 0, 0, '', extend({'subcommand_args': blame_args}, state.blame_options, 'keep')) endif if bufnr('') == my_bufnr return result @@ -5567,7 +6191,6 @@ function! fugitive#BlameSyntax() abort 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 s:HasOpt(flags, '-b') || FugitiveConfigGet('blame.blankBoundary') =~# '^1$\|^true$' syn match FugitiveblameBoundaryIgnore "^\^[*?]*\x\{7,\}\>" nextgroup=FugitiveblameAnnotation,FugitiveblameScoreDebug,FugitiveblameOriginalLineNumber,FugitiveblameOriginalFile skipwhite else @@ -5576,7 +6199,7 @@ function! fugitive#BlameSyntax() abort 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 - exec 'syn match FugitiveblameLineNumber "\s*\d\+)\@=" contained containedin=FugitiveblameAnnotation' conceal + exec 'syn match FugitiveblameLineNumber "\s[[:digit:][:space:]]\{0,' . (len(line('$'))-1). '\}\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) exec 'syn match FugitiveblameOriginalLineNumber "\s*\d\+\%(\s\+\d\+)\)\@=" contained nextgroup=FugitiveblameShort skipwhite' (s:HasOpt(flags, '--show-number', '-n') ? '' : conceal) @@ -5599,38 +6222,44 @@ function! fugitive#BlameSyntax() abort endif let seen = {} for lnum in range(1, line('$')) - let hash = matchstr(getline(lnum), '^\^\=\zs\x\{6\}') - if hash ==# '' || hash ==# '000000' || has_key(seen, hash) + let orig_hash = matchstr(getline(lnum), '^\^\=[*?]*\zs\x\{6\}') + let hash = orig_hash + let hash = substitute(hash, '\(\x\)\x', '\=submatch(1).printf("%x", 15-str2nr(submatch(1),16))', 'g') + let hash = substitute(hash, '\(\x\x\)', '\=printf("%02x", str2nr(submatch(1),16)*3/4+32)', 'g') + if hash ==# '' || orig_hash ==# '000000' || has_key(seen, hash) continue endif let seen[hash] = 1 - if &t_Co > 16 && get(g:, 'CSApprox_loaded') && !empty(findfile('autoload/csapprox/per_component.vim', escape(&rtp, ' '))) - \ && empty(get(s:hash_colors, hash)) - let [s, r, g, b; __] = map(matchlist(hash, '\(\x\x\)\(\x\x\)\(\x\x\)'), 'str2nr(v:val,16)') - let color = csapprox#per_component#Approximate(r, g, b) - if color == 16 && &background ==# 'dark' - let color = 8 + if &t_Co == 256 + let [s, r, g, b; __] = map(matchlist(orig_hash, '\(\x\)\x\(\x\)\x\(\x\)\x'), 'str2nr(v:val,16)') + let color = 16 + (r + 1) / 3 * 36 + (g + 1) / 3 * 6 + (b + 1) / 3 + if color == 16 + let color = 235 + elseif color == 231 + let color = 255 endif let s:hash_colors[hash] = ' ctermfg='.color else let s:hash_colors[hash] = '' endif - exe 'syn match FugitiveblameHash'.hash.' "\%(^\^\=\)\@<='.hash.'\x\{1,34\}\>" nextgroup=FugitiveblameAnnotation,FugitiveblameOriginalLineNumber,fugitiveblameOriginalFile skipwhite' + let pattern = substitute(orig_hash, '^\(\x\)\x\(\x\)\x\(\x\)\x$', '\1\\x\2\\x\3\\x', '') . '*\>' + exe 'syn match FugitiveblameHash'.hash.' "\%(^\^\=[*?]*\)\@<='.pattern.'" nextgroup=FugitiveblameAnnotation,FugitiveblameOriginalLineNumber,fugitiveblameOriginalFile skipwhite' endfor + syn match FugitiveblameUncommitted "\%(^\^\=[?*]*\)\@<=\<0\{7,\}\>" nextgroup=FugitiveblameAnnotation,FugitiveblameScoreDebug,FugitiveblameOriginalLineNumber,FugitiveblameOriginalFile skipwhite call s:BlameRehighlight() endfunction function! s:BlameRehighlight() abort for [hash, cterm] in items(s:hash_colors) if !empty(cterm) || has('gui_running') || has('termguicolors') && &termguicolors - exe 'hi FugitiveblameHash'.hash.' guifg=#'.hash.get(s:hash_colors, hash, '') + exe 'hi FugitiveblameHash'.hash.' guifg=#' . hash . cterm else exe 'hi link FugitiveblameHash'.hash.' Identifier' endif endfor endfunction -function! s:BlameFileType() abort +function! fugitive#BlameFileType() abort setlocal nomodeline setlocal foldmethod=manual if len(s:Dir()) @@ -5647,80 +6276,144 @@ function! s:BlameFileType() abort 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 ":Git blame q is deprecated in favor of gq"echohl NONE', '') + call s:Map('n', 'q', ':echoerr "fugitive: q removed in favor of gq (or :q)"', '') endif call s:Map('n', 'gq', ':exe BlameQuit()', '') call s:Map('n', '<2-LeftMouse>', ':exe BlameCommit("exe BlameLeave()edit")', '') call s:Map('n', '', ':exe BlameCommit("exe BlameLeave()edit")', '') call s:Map('n', '-', ':exe BlameJump("")', '') + call s:Map('n', 's', ':exe BlameJump("")', '') + call s:Map('n', 'u', ':exe BlameJump("")', '') call s:Map('n', 'P', ':exe BlameJump("^".v:count1)', '') call s:Map('n', '~', ':exe BlameJump("~".v:count1)', '') call s:Map('n', 'i', ':exe BlameCommit("exe BlameLeave()edit")', '') call s:Map('n', 'o', ':exe BlameCommit("split")', '') call s:Map('n', 'O', ':exe BlameCommit("tabedit")', '') call s:Map('n', 'p', ':exe BlameCommit("pedit")', '') + call s:Map('n', '.', ": =substitute(BlameCommitFileLnum()[0],'^$','@','')") + call s:Map('n', 'A', ":exe 'vertical resize '.(linechars('.\\{-\\}\\ze [0-9:/+-][0-9:/+ -]* \\d\\+)')+1+v:count)", '') + call s:Map('n', 'C', ":exe 'vertical resize '.(linechars('^\\S\\+')+1+v:count)", '') + call s:Map('n', 'D', ":exe 'vertical resize '.(linechars('.\\{-\\}\\ze\\d\\ze\\s\\+\\d\\+)')+1-v:count)", '') endfunction augroup fugitive_blame autocmd! - autocmd FileType fugitiveblame call s:BlameFileType() autocmd ColorScheme,GUIEnter * call s:BlameRehighlight() autocmd BufWinLeave * execute getwinvar(+bufwinnr(+expand('')), 'fugitive_leave') augroup END -" Section: :Gbrowse +" Section: :GBrowse -let s:redirects = {} +function! s:BrowserOpen(url, mods, echo_copy) abort + let url = substitute(a:url, '[ <>\|"]', '\="%".printf("%02X",char2nr(submatch(0)))', 'g') + let mods = s:Mods(a:mods) + if a:echo_copy + if has('clipboard') + let @+ = url + endif + return 'echo '.string(url) + elseif exists(':Browse') == 2 + return 'echo '.string(url).'|' . mods . 'Browse '.url + elseif exists(':OpenBrowser') == 2 + return 'echo '.string(url).'|' . mods . 'OpenBrowser '.url + else + if !exists('g:loaded_netrw') + runtime! autoload/netrw.vim + endif + if exists('*netrw#BrowseX') + return 'echo '.string(url).'|' . mods . 'call netrw#BrowseX('.string(url).', 0)' + elseif exists('*netrw#NetrwBrowseX') + return 'echo '.string(url).'|' . mods . 'call netrw#NetrwBrowseX('.string(url).', 0)' + else + return 'echoerr ' . string('Netrw not found. Define your own :Browse to use :GBrowse') + endif + endif +endfunction function! fugitive#BrowseCommand(line1, count, range, bang, mods, arg, args) abort + exe s:VersionCheck() let dir = s:Dir() - exe s:DirCheck(dir) try + let arg = a:arg + if arg =~# '^++remote=' + let remote = matchstr(arg, '^++remote=\zs\S\+') + let arg = matchstr(arg, '\s\zs\S.*') + endif let validremote = '\.\|\.\=/.*\|[[:alnum:]_-]\+\%(://.\{-\}\)\=' - if a:args ==# ['-'] - if a:count >= 0 - return 'echoerr ' . string('fugitive: ''-'' no longer required to get persistent URL if range given') - else - return 'echoerr ' . string('fugitive: use :0Gbrowse instead of :Gbrowse -') - endif - elseif len(a:args) - let remote = matchstr(join(a:args, ' '),'@\zs\%('.validremote.'\)$') - let rev = substitute(join(a:args, ' '),'@\%('.validremote.'\)$','','') - else + if arg ==# '-' let remote = '' let rev = '' - endif - if rev ==# '' - let rev = s:DirRev(@%)[1] - endif - if rev =~# '^:\=$' - let expanded = s:Relative() + let result = fugitive#Result() + if filereadable(get(result, 'file', '')) + let rev = s:fnameescape(result.file) + else + return 'echoerr ' . string('fugitive: could not find prior :Git invocation') + endif + elseif !exists('l:remote') + let remote = matchstr(arg, '@\zs\%('.validremote.'\)$') + let rev = substitute(arg, '@\%('.validremote.'\)$','','') else - let expanded = s:Expand(rev) + let rev = arg endif - let cdir = FugitiveVimPath(fugitive#CommonDir(dir)) + if rev =~? '^\a\a\+:[\/][\/]' && rev !~? '^fugitive:' + let rev = substitute(rev, '\\\@]*[^[:space:]<>.,;:"''!?]')) + if len(rev) + break + endif + endfor + if empty(rev) + return 'echoerr ' . string('fugitive: no URL found in output of :Git') + endif + endif + exe s:DirCheck(dir) + if empty(expanded) + let bufname = s:BufName('%') + let expanded = s:DirRev(bufname)[1] + if empty(expanded) + let expanded = fugitive#Path(bufname, ':(top)', dir) + endif + if a:count > 0 && bufname !=# bufname('') + let blame = s:BlameCommitFileLnum(getline(a:count)) + if len(blame[0]) + let expanded = blame[0] + endif + endif + endif + let refdir = fugitive#Find('.git/refs', dir) for subdir in ['tags/', 'heads/', 'remotes/'] - if expanded !~# '^[./]' && filereadable(cdir . '/refs/' . subdir . expanded) + if expanded !~# '^[./]' && filereadable(refdir . '/' . subdir . expanded) let expanded = '.git/refs/' . subdir . expanded endif endfor - let full = fugitive#Find(expanded, dir) + let full = s:Generate(expanded, dir) let commit = '' if full =~? '^fugitive:' - let [pathdir, commit, path] = s:DirCommitFile(full) + let [dir, commit, path] = s:DirCommitFile(full) if commit =~# '^:\=\d$' let commit = '' endif if commit =~ '..' - let type = s:TreeChomp('cat-file','-t',commit.s:sub(path,'^/',':')) + let type = s:TreeChomp(['cat-file','-t',commit.s:sub(path,'^/',':')], dir) let branch = matchstr(expanded, '^[^:]*') + elseif empty(path) || path ==# '/' + let type = 'tree' else 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 = '' @@ -5737,8 +6430,9 @@ function! fugitive#BrowseCommand(line1, count, range, bang, mods, arg, args) abo if type ==# 'tree' && !empty(path) let path = s:sub(path, '/\=$', '/') endif - if path =~# '^\.git/.*HEAD$' && filereadable(dir . '/' . path[5:-1]) - let body = readfile(dir . '/' . path[5:-1])[0] + let actual_dir = fugitive#Find('.git/', dir) + if path =~# '^\.git/.*HEAD$' && filereadable(actual_dir . path[5:-1]) + let body = readfile(actual_dir . path[5:-1])[0] if body =~# '^\x\{40,\}$' let commit = body let type = 'commit' @@ -5760,48 +6454,54 @@ function! fugitive#BrowseCommand(line1, count, range, bang, mods, arg, args) abo elseif path =~# '^\.git/refs/heads/.' let branch = path[16:-1] elseif !exists('branch') - let branch = FugitiveHead() + let branch = FugitiveHead(0, dir) endif if !empty(branch) - let r = fugitive#Config('branch.'.branch.'.remote') - let m = fugitive#Config('branch.'.branch.'.merge')[11:-1] + let r = FugitiveConfigGet('branch.'.branch.'.remote', dir) + let m = FugitiveConfigGet('branch.'.branch.'.merge', dir)[11:-1] if r ==# '.' && !empty(m) - let r2 = fugitive#Config('branch.'.m.'.remote') + let r2 = FugitiveConfigGet('branch.'.m.'.remote', dir) if r2 !~# '^\.\=$' let r = r2 - let m = fugitive#Config('branch.'.m.'.merge')[11:-1] + let m = FugitiveConfigGet('branch.'.m.'.merge', dir)[11:-1] endif endif if empty(remote) let remote = r endif if r ==# '.' || r ==# remote - let merge = m - if path =~# '^\.git/refs/heads/.' - let path = '.git/refs/heads/'.merge + let remote_ref = 'refs/remotes/' . remote . '/' . branch + if FugitiveConfigGet('push.default', dir) ==# 'upstream' || + \ !filereadable(FugitiveFind('.git/' . remote_ref, dir)) && s:ChompError(['rev-parse', '--verify', remote_ref, '--'], dir)[1] + let merge = m + if path =~# '^\.git/refs/heads/.' + let path = '.git/refs/heads/'.merge + endif + else + let merge = branch endif endif endif - let line1 = a:count > 0 ? a:line1 : 0 - let line2 = a:count > 0 ? a:count : 0 + let line1 = a:count > 0 && type ==# 'blob' ? a:line1 : 0 + let line2 = a:count > 0 && type ==# 'blob' ? a:count : 0 if empty(commit) && path !~# '^\.git/' if a:count < 0 && !empty(merge) let commit = merge else let commit = '' if len(merge) - let owner = s:Owner(@%) - let [commit, exec_error] = s:ChompError(['merge-base', 'refs/remotes/' . remote . '/' . merge, empty(owner) ? 'HEAD' : owner, '--']) + let owner = s:Owner(@%, dir) + let [commit, exec_error] = s:ChompError(['merge-base', 'refs/remotes/' . remote . '/' . merge, empty(owner) ? '@' : owner, '--'], dir) if exec_error let commit = '' endif - if a:count > 0 && empty(a:args) && commit =~# '^\x\{40,\}$' + if line2 > 0 && empty(arg) && commit =~# '^\x\{40,\}$' let blame_list = tempname() call writefile([commit, ''], blame_list, 'b') let blame_in = tempname() - silent exe '%write' blame_in - let [blame, exec_error] = s:LinesError(['-c', 'blame.coloring=none', 'blame', '--contents', blame_in, '-L', a:line1.','.a:count, '-S', blame_list, '-s', '--show-number', './' . path]) + silent exe 'noautocmd keepalt %write' blame_in + let [blame, exec_error] = s:LinesError(['-c', 'blame.coloring=none', 'blame', '--contents', blame_in, '-L', line1.','.line2, '-S', blame_list, '-s', '--show-number', './' . path], dir) if !exec_error let blame_regex = '^\^\x\+\s\+\zs\d\+\ze\s' if get(blame, 0) =~# blame_regex && get(blame, -1) =~# blame_regex @@ -5819,7 +6519,7 @@ function! fugitive#BrowseCommand(line1, count, range, bang, mods, arg, args) abo endif let i = 0 while commit =~# '^ref: ' && i < 10 - let ref_file = cdir . '/' . commit[5:-1] + let ref_file = refdir[0 : -5] . commit[5:-1] if getfsize(ref_file) > 0 let commit = readfile(ref_file, '', 1)[0] else @@ -5832,23 +6532,13 @@ function! fugitive#BrowseCommand(line1, count, range, bang, mods, arg, args) abo if empty(remote) let remote = '.' endif - let raw = fugitive#RemoteUrl(remote) + let raw = fugitive#RemoteUrl(remote, dir) if empty(raw) let raw = remote endif - if raw =~# '^https\=://' && s:executable('curl') - if !has_key(s:redirects, raw) - let s:redirects[raw] = matchstr(system('curl -I ' . - \ s:shellesc(raw . '/info/refs?service=git-upload-pack')), - \ 'Location: \zs\S\+\ze/info/refs?') - endif - if len(s:redirects[raw]) - let raw = s:redirects[raw] - endif - endif - let opts = { + \ 'git_dir': dir, \ 'dir': dir, \ 'repo': fugitive#repo(dir), \ 'remote': raw, @@ -5859,40 +6549,19 @@ function! fugitive#BrowseCommand(line1, count, range, bang, mods, arg, args) abo \ 'line1': line1, \ 'line2': line2} - 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 + let url = '' + for Handler in get(g:, 'fugitive_browse_handlers', []) + let url = call(Handler, [copy(opts)]) + if !empty(url) + break + endif + endfor if empty(url) - call s:throw("No Gbrowse handler installed for '".raw."'") + call s:throw("No GBrowse handler installed for '".raw."'") endif - let url = s:gsub(url, '[ <>]', '\="%".printf("%02X",char2nr(submatch(0)))') - if a:bang - if has('clipboard') - let @+ = url - endif - return 'echomsg '.string(url) - elseif exists(':Browse') == 2 - return 'echomsg '.string(url).'|Browse '.url - else - if !exists('g:loaded_netrw') - runtime! autoload/netrw.vim - endif - if exists('*netrw#BrowseX') - return 'echomsg '.string(url).'|call netrw#BrowseX('.string(url).', 0)' - else - return 'echomsg '.string(url).'|call netrw#NetrwBrowseX('.string(url).', 0)' - endif - endif + return s:BrowserOpen(url, a:mods, a:bang) catch /^fugitive:/ return 'echoerr ' . string(v:exception) endtry @@ -5917,14 +6586,14 @@ endfunction function! s:ContainingCommit() abort let commit = s:Owner(@%) - return empty(commit) ? 'HEAD' : commit + return empty(commit) ? '@' : commit endfunction function! s:SquashArgument(...) abort if &filetype == 'fugitive' 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,\}\>') + let commit = matchstr(getline('.'), '\S\@') else let commit = s:Owner(@%) endif @@ -5944,7 +6613,7 @@ function! s:NavigateUp(count) abort elseif rev =~# '.:.' let rev = matchstr(rev, '^.[^:]*:') elseif rev =~# '^:' - let rev = 'HEAD^{}' + let rev = '@^{}' elseif rev =~# ':$' let rev = rev[0:-2] else @@ -5972,7 +6641,7 @@ 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 fugitive#DiffClose()Gdiffsplit!redrawechohl WarningMsg echo ':Gstatus D is deprecated in favor of dd'echohl NONE", '') + call s:Map('n', 'D', ":echoerr 'fugitive: D has been removed in favor of dd'", '') 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!", '') @@ -6068,7 +6737,7 @@ function! fugitive#MapJumps(...) abort 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', 'coo', ':Git checkout =substitute(SquashArgument(),"^$",get(TempState(),"filetype","") ==# "git" ? expand("") : "","") --') call s:Map('n', 'co?', ':help fugitive_co', '') call s:Map('n', 'cb', ':Git branch') @@ -6097,10 +6766,31 @@ function! fugitive#MapJumps(...) abort call s:Map('n', 'g?', ":help fugitive-map", '') call s:Map('n', '', ":help fugitive-map", '') endif + + let old_browsex = maparg('NetrwBrowseX', 'n') + let new_browsex = substitute(old_browsex, '\Cnetrw#CheckIfRemote(\%(netrw#GX()\)\=)', '0', 'g') + let new_browsex = substitute(new_browsex, 'netrw#GX()\|expand((exists("g:netrw_gx")? g:netrw_gx : ''''))', 'fugitive#GX()', 'g') + if new_browsex !=# old_browsex + exe 'nnoremap NetrwBrowseX' new_browsex + endif +endfunction + +function! fugitive#GX() abort + try + let results = &filetype ==# 'fugitive' ? s:StatusCfile() : &filetype ==# 'git' ? s:cfile() : [] + if len(results) && len(results[0]) + return FugitiveReal(s:Generate(results[0])) + endif + catch /^fugitive:/ + endtry + return expand(get(g:, 'netrw_gx', expand(''))) endfunction function! s:StatusCfile(...) abort let tree = s:Tree() + if empty(tree) + return [''] + endif let lead = s:cpath(tree, getcwd()) ? './' : tree . '/' let info = s:StageInfo() let line = getline('.') @@ -6124,12 +6814,15 @@ function! s:StatusCfile(...) abort endfunction function! fugitive#StatusCfile() abort - let file = s:Generate(s:StatusCfile()[0]) + let file = fugitive#Find(s:StatusCfile()[0]) return empty(file) ? fugitive#Cfile() : s:fnameescape(file) endfunction function! s:MessageCfile(...) abort let tree = s:Tree() + if empty(tree) + return '' + endif let lead = s:cpath(tree, getcwd()) ? './' : tree . '/' if getline('.') =~# '^.\=\trenamed:.* -> ' return lead . matchstr(getline('.'),' -> \zs.*') @@ -6151,11 +6844,14 @@ function! s:MessageCfile(...) abort endfunction function! fugitive#MessageCfile() abort - let file = s:Generate(s:MessageCfile()) + let file = fugitive#Find(s:MessageCfile()) return empty(file) ? fugitive#Cfile() : s:fnameescape(file) endfunction function! s:cfile() abort + if empty(FugitiveGitDir()) + return [] + endif try let myhash = s:DirRev(@%)[1] if len(myhash) @@ -6165,8 +6861,15 @@ function! s:cfile() abort let myhash = '' endtry endif - if empty(myhash) && getline(1) =~# '^\%(commit\|tag\) \w' - let myhash = matchstr(getline(1),'^\w\+ \zs\S\+') + if empty(myhash) && get(s:TempState(), 'filetype', '') ==# 'git' + let lnum = line('.') + while lnum > 0 + if getline(lnum) =~# '^\%(commit\|tag\) \w' + let myhash = matchstr(getline(lnum),'^\w\+ \zs\S\+') + break + endif + let lnum -= 1 + endwhile endif let showtree = (getline(1) =~# '^tree ' && getline(2) == "") @@ -6288,9 +6991,9 @@ function! s:cfile() abort let prefixes.a = myhash.'^:' let prefixes.b = myhash.':' endif - let ref = substitute(ref, '^\(\w\)/', '\=get(prefixes, submatch(1), "HEAD:")', '') + let ref = substitute(ref, '^\(\w\)/', '\=get(prefixes, submatch(1), "@:")', '') if exists('dref') - let dref = substitute(dref, '^\(\w\)/', '\=get(prefixes, submatch(1), "HEAD:")', '') + let dref = substitute(dref, '^\(\w\)/', '\=get(prefixes, submatch(1), "@:")', '') endif if ref ==# '/dev/null' @@ -6402,9 +7105,11 @@ function! fugitive#Foldtext() abort if exists('binary') return 'Binary: '.filename else - return (add<10&&remove<100?' ':'') . add . '+ ' . (remove<10&&add<100?' ':'') . remove . '- ' . filename + return '+-' . v:folddashes . ' ' . (add<10&&remove<100?' ':'') . add . '+ ' . (remove<10&&add<100?' ':'') . remove . '- ' . filename endif - elseif line_foldstart =~# '^# .*:$' + elseif line_foldstart =~# '^@@\+ .* @@' + return '+-' . v:folddashes . ' ' . line_foldstart + elseif &filetype ==# 'gitcommit' && line_foldstart =~# '^# .*:$' let lines = getline(v:foldstart, v:foldend) call filter(lines, 'v:val =~# "^#\t"') cal map(lines, "s:sub(v:val, '^#\t%(modified: +|renamed: +)=', '')") diff --git a/sources_non_forked/vim-fugitive/doc/fugitive.txt b/sources_non_forked/vim-fugitive/doc/fugitive.txt index 3448c672..fd0ab2e6 100644 --- a/sources_non_forked/vim-fugitive/doc/fugitive.txt +++ b/sources_non_forked/vim-fugitive/doc/fugitive.txt @@ -59,6 +59,12 @@ that are part of Git repositories). ~ reblame at [count]th first grandparent P reblame at [count]th parent (like HEAD^[count]) + *g:fugitive_dynamic_colors* + In the GUI or a 256 color terminal, commit hashes will + highlighted in different colors. To disable this: +> + let g:fugitive_dynamic_colors = 0 +< :[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 @@ -78,15 +84,6 @@ that are part of Git repositories). *:Git_mergetool* :Git mergetool [args] Like |:Git_difftool|, but target merge conflicts. - *:Git_push* -:Git push [args] Invoke git-push, load the results into the |quickfix| - list, and invoke |:cwindow| to reveal any errors. - |:Dispatch| is used if available for asynchronous - invocation. - - *:Git_fetch* -:Git fetch [args] Like |:Git_push|, but for git-fetch. - *:Ggrep* *:Gcgrep* *:Git_grep* :Ggrep[!] [args] |:grep|[!] with git-grep as 'grepprg'. :Git[!] grep [args] @@ -100,8 +97,9 @@ that are part of Git repositories). |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. + The quickfix list can be awkward for many use cases + and exhibits extremely poor performance with larger + data sets. Consider using |:Git| log instead. :{range}Gclog[!] [args] Use git-log -L to load previous revisions of the given range of the current file into the |quickfix| list. @@ -214,9 +212,6 @@ that are part of Git repositories). *:GBrowse* :GBrowse Open the current file, blob, tree, commit, or tag in your browser at the upstream hosting provider. - If a range is given, it is appropriately appended to - the URL as an anchor. - Upstream providers can be added by installing an appropriate Vim plugin. For example, GitHub can be supported by installing rhubarb.vim, available at @@ -224,16 +219,18 @@ that are part of Git repositories). :GBrowse {object} Like :GBrowse, but for a given |fugitive-object|. -: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 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. +: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. + +:GBrowse {url} Open an arbitrary URL in your browser. + :[range]GBrowse! [args] Like :GBrowse, but put the URL on the clipboard rather than opening it. @@ -263,10 +260,9 @@ U Unstage everything. X Discard the change under the cursor. This uses `checkout` or `clean` under the hood. A command is echoed that shows how to undo the change. Consult - `:messages` to see it again. You can use this during - a merge conflict do discard "our" changes (--theirs) - in the "Unstaged" section or discard "their" changes - (--ours) in the "Staged" section. + `:messages` to see it again. During a merge conflict, + use 2X to call `checkout --ours` or 3X to call + `checkout --theirs` . *fugitive_=* = Toggle an inline diff of the file under the cursor. @@ -313,7 +309,7 @@ Navigation maps ~ *fugitive_* Open the file or |fugitive-object| under the cursor. - in a blob, this and similar maps jump to the patch + In a blob, this and similar maps jump to the patch from the diff where this was added, or where it was removed if a count was given. If the line is still in the work tree version, passing a count takes you to @@ -592,7 +588,9 @@ 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 -: The |fugitive-summary| buffer. +: The |fugitive-summary| buffer +- A temp file containing the last |:Git| invocation's output + The file or commit under the cursor STATUSLINE *fugitive-statusline* @@ -603,20 +601,47 @@ a statusline, this one matches the default when 'ruler' is set: > set statusline=%<%f\ %h%m%r%{FugitiveStatusline()}%=%-14.(%l,%c%V%)\ %P < - *FugitiveHead(...)* *fugitive#head(...)* -Use FugitiveHead() to return the name of the current branch. If the current -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. +AUTOCOMMANDS *fugitive-autocommands* + +A handful of |User| |autocommands| are provided to allow extending and +overriding Fugitive behaviors. Example usage: +> + autocmd User FugitiveBlob call s:BlobOverrides() +< + *User_FugitiveIndex* +FugitiveIndex After loading the |fugitive-summary| buffer. + + *User_FugitiveTag* +FugitiveTag After loading a tag object. + + *User_FugitiveCommit* +FugitiveCommit After loading a commit object. + + *User_FugitiveTree* +FugitiveTree After loading a tree (directory) object. + + *User_FugitiveBlob* +FugitiveBlob After loading a blob (file) object. This includes + both committed blobs which are read only, and staged + blobs which can be edited and written. Check + &modifiable to distinguish between the two. + + *User_FugitiveChanged* +FugitiveChanged After any event which can potentially change the + repository, for example, any invocation of |:Git|. + Originally intended for expiring caches, but can have + other uses. + +API *fugitive-api* + +Officially supported functions are documented inline in plugin/fugitive.vim. 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. +The following commands are deprecated in favor of replacements that adhere to +a new naming scheme. 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|. @@ -632,8 +657,8 @@ just one space character longer than the legacy version. *: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|. +*: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|. @@ -642,6 +667,14 @@ just one space character longer than the legacy version. *:Gtabsplit!* Superseded by :tab Git --paginate. *:Gpedit!* Superseded by :Git! --paginate. + *User_Fugitive* +Fugitive used to support `:autocmd User Fugitive` to run an autocommand after +loading any buffer belonging to a Git repository, but this is being phased +out. Instead, one can leverage regular autocommand events like |BufNewFile| +and |BufReadPost|, and check !empty(FugitiveGitDir()) to confirm Fugitive has +found a repository. See also |fugitive-autocommands| for other, more +selective events. + ABOUT *fugitive-about* Grab the latest version or report a bug on GitHub: diff --git a/sources_non_forked/vim-fugitive/ftplugin/fugitiveblame.vim b/sources_non_forked/vim-fugitive/ftplugin/fugitiveblame.vim new file mode 100644 index 00000000..1037b093 --- /dev/null +++ b/sources_non_forked/vim-fugitive/ftplugin/fugitiveblame.vim @@ -0,0 +1,6 @@ +if exists("b:did_ftplugin") || !exists("*FugitiveGitDir") + finish +endif +let b:did_ftplugin = 1 + +call fugitive#BlameFileType() diff --git a/sources_non_forked/vim-fugitive/plugin/fugitive.vim b/sources_non_forked/vim-fugitive/plugin/fugitive.vim index edb81e5e..6be65046 100644 --- a/sources_non_forked/vim-fugitive/plugin/fugitive.vim +++ b/sources_non_forked/vim-fugitive/plugin/fugitive.vim @@ -1,6 +1,6 @@ " fugitive.vim - A Git wrapper so awesome, it should be illegal " Maintainer: Tim Pope -" Version: 3.2 +" Version: 3.3 " GetLatestVimScripts: 2975 1 :AutoInstall: fugitive.vim if exists('g:loaded_fugitive') @@ -8,20 +8,38 @@ if exists('g:loaded_fugitive') endif let g:loaded_fugitive = 1 +let s:bad_git_dir = '/$\|^fugitive:' + +" FugitiveGitDir() returns the detected Git dir for the given buffer number, +" or the current buffer if no argument is passed. This will be an empty +" string if no Git dir was found. Use !empty(FugitiveGitDir()) to check if +" Fugitive is active in the current buffer. Do not rely on this for direct +" filesystem access; use FugitiveFind('.git/whatever') instead. function! FugitiveGitDir(...) abort - if !a:0 || type(a:1) == type(0) && a:1 < 0 + if v:version < 704 + return '' + elseif !a:0 || type(a:1) == type(0) && a:1 < 0 if exists('g:fugitive_event') return g:fugitive_event endif let dir = get(b:, 'git_dir', '') - if empty(dir) && (empty(bufname('')) || &buftype =~# '^\%(nofile\|acwrite\|quickfix\|prompt\)$') + if empty(dir) && (empty(bufname('')) || &buftype =~# '^\%(nofile\|acwrite\|quickfix\|terminal\|prompt\)$') return FugitiveExtractGitDir(getcwd()) + elseif (!exists('b:git_dir') || b:git_dir =~# s:bad_git_dir) && empty(&buftype) + let b:git_dir = FugitiveExtractGitDir(expand('%:p')) + return b:git_dir endif - return dir + return dir =~# s:bad_git_dir ? '' : dir elseif type(a:1) == type(0) - return getbufvar(a:1, 'git_dir') + if a:1 == bufnr('') && (!exists('b:git_dir') || b:git_dir =~# s:bad_git_dir) && empty(&buftype) + let b:git_dir = FugitiveExtractGitDir(expand('%:p')) + endif + let dir = getbufvar(a:1, 'git_dir') + return dir =~# s:bad_git_dir ? '' : dir elseif type(a:1) == type('') return substitute(s:Slash(a:1), '/$', '', '') + elseif type(a:1) == type({}) + return get(a:1, 'git_dir', '') else return '' endif @@ -81,6 +99,24 @@ function! FugitiveParse(...) abort throw v:errmsg endfunction +" FugitiveResult() returns an object encapsulating the result of the most +" recent :Git command. Will be empty if no result is available. During a +" User FugitiveChanged event, this is guaranteed to correspond to the :Git +" command that triggered the event, or be empty if :Git was not the trigger. +" Pass in the name of a temp buffer to get the result object for that command +" instead. Contains the following keys: +" +" * "args": List of command arguments, starting with the subcommand. Will be +" empty for usages like :Git --help. +" * "dir": Git dir of the relevant repository. +" * "exit_status": The integer exit code of the process. +" * "flags": Flags passed directly to Git, like -c and --help. +" * "file": Path to file containing command output. Not guaranteed to exist, +" so verify with filereadable() before trying to access it. +function! FugitiveResult(...) abort + return call('fugitive#Result', a:000) +endfunction + " FugitivePrepare() constructs a Git command string which can be executed with " functions like system() and commands like :!. Integer arguments will be " treated as buffer numbers, and the appropriate relative path inserted in @@ -93,38 +129,58 @@ function! FugitivePrepare(...) abort return call('fugitive#Prepare', a:000) endfunction +" FugitiveConfig() get returns an opaque structure that can be passed to other +" FugitiveConfig functions in lieu of a Git directory. This can be faster +" when performing multiple config queries. Do not rely on the internal +" structure of the return value as it is not guaranteed. If you want a full +" dictionary of every config value, use FugitiveConfigGetRegexp('.*'). +" +" An optional argument provides the Git dir, or the buffer number of a +" buffer with a Git dir. The default is the current buffer. Pass a blank +" string to limit to the global config. function! FugitiveConfig(...) abort - if a:0 == 2 && type(a:2) != type({}) - return fugitive#Config(a:1, FugitiveGitDir(a:2)) - elseif a:0 == 1 && a:1 !~# '^[[:alnum:]-]\+\.' - return fugitive#Config(FugitiveGitDir(a:1)) - else - return call('fugitive#Config', a:000) - endif + return call('fugitive#Config', a:000) endfunction -" Retrieve a Git configuration value. An optional second argument provides -" the Git dir as with FugitiveFind(). Pass a blank string to limit to the -" global config. +" FugitiveConfigGet() retrieves a Git configuration value. An optional second +" argument can be either the object returned by FugitiveConfig(), or a Git +" dir or buffer number to be passed along to FugitiveConfig(). function! FugitiveConfigGet(name, ...) abort - return call('FugitiveConfig', [a:name] + a:000) + return get(call('FugitiveConfigGetAll', [a:name] + (a:0 ? [a:1] : [])), 0, get(a:, 2, '')) endfunction -" Like FugitiveConfigGet(), but return a list of all values. +" FugitiveConfigGetAll() is like FugitiveConfigGet() but returns a list of +" all values. function! FugitiveConfigGetAll(name, ...) abort - if a:0 && type(a:1) ==# type({}) - let config = a:1 - else - let config = fugitive#Config(FugitiveGitDir(a:0 ? a:1 : -1)) - endif - let name = substitute(a:name, '^[^.]\+\|[^.]\+$', '\L&', 'g') - return copy(get(config, name, [])) + return call('fugitive#ConfigGetAll', [a:name] + a:000) endfunction +" FugitiveConfigGetRegexp() retrieves a dictionary of all configuration values +" with a key matching the given pattern. Like git config --get-regexp, but +" using a Vim regexp. Second argument has same semantics as +" FugitiveConfigGet(). +function! FugitiveConfigGetRegexp(pattern, ...) abort + return call('fugitive#ConfigGetRegexp', [a:pattern] + a:000) +endfunction + +" FugitiveRemoteUrl() retrieves the remote URL for the given remote name, +" defaulting to the current branch's remote or "origin" if no argument is +" given. Similar to `git remote get-url`, but also attempts to resolve HTTP +" redirects and SSH host aliases. +" +" An optional second argument provides the Git dir, or the buffer number of a +" buffer with a Git dir. The default is the current buffer. function! FugitiveRemoteUrl(...) abort - return fugitive#RemoteUrl(a:0 ? a:1 : '', FugitiveGitDir(a:0 > 1 ? a:2 : -1)) + return fugitive#RemoteUrl(a:0 ? a:1 : '', a:0 > 1 ? a:2 : -1, a:0 > 2 ? a:3 : 0) endfunction +" FugitiveHead() retrieves the name of the current branch. If the current 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. +" +" An optional second argument provides the Git dir, or the buffer number of a +" buffer with a Git dir. The default is the current buffer. function! FugitiveHead(...) abort let dir = FugitiveGitDir(a:0 > 1 ? a:2 : -1) if empty(dir) @@ -134,7 +190,7 @@ function! FugitiveHead(...) abort endfunction function! FugitiveStatusline(...) abort - if !exists('b:git_dir') + if empty(get(b:, 'git_dir', '')) return '' endif return fugitive#Statusline() @@ -145,11 +201,16 @@ function! FugitiveCommonDir(...) abort if empty(dir) return '' endif - return fugitive#CommonDir(dir) + return fugitive#Find('.git/refs/..', dir) endfunction function! FugitiveWorkTree(...) abort - return s:Tree(FugitiveGitDir(a:0 ? a:1 : -1)) + let tree = s:Tree(FugitiveGitDir(a:0 ? a:1 : -1)) + if tree isnot# 0 || a:0 > 1 + return tree + else + return '' + endif endfunction function! FugitiveIsGitDir(path) abort @@ -173,9 +234,14 @@ function! s:Tree(path) abort let config_file = dir . '/config' if filereadable(config_file) let config = readfile(config_file,'',10) - call filter(config,'v:val =~# "^\\s*worktree *="') - if len(config) == 1 - let worktree = FugitiveVimPath(matchstr(config[0], '= *\zs.*')) + let wt_config = filter(copy(config),'v:val =~# "^\\s*worktree *="') + if len(wt_config) == 1 + let worktree = FugitiveVimPath(matchstr(wt_config[0], '= *\zs.*')) + else + call filter(config,'v:val =~# "^\\s*bare *= *false *$"') + if len(config) + let s:worktree_for_dir[dir] = 0 + endif endif elseif filereadable(dir . '/gitdir') let worktree = fnamemodify(FugitiveVimPath(readfile(dir . '/gitdir')[0]), ':h') @@ -270,16 +336,16 @@ function! FugitiveExtractGitDir(path) abort endfunction function! FugitiveDetect(path) abort - if exists('b:git_dir') && b:git_dir =~# '^$\|/$\|^fugitive:' + if v:version < 704 + return '' + endif + if exists('b:git_dir') && b:git_dir =~# '^$\|' . s:bad_git_dir unlet b:git_dir endif if !exists('b:git_dir') - let dir = FugitiveExtractGitDir(a:path) - if dir !=# '' - let b:git_dir = dir - endif + let b:git_dir = FugitiveExtractGitDir(a:path) endif - if !exists('b:git_dir') || !exists('#User#Fugitive') + if empty(b:git_dir) || !exists('#User#Fugitive') return '' endif if v:version >= 704 || (v:version == 703 && has('patch442')) @@ -310,13 +376,15 @@ function! FugitiveGitPath(path) abort return s:Slash(a:path) endfunction -function! s:Slash(path) abort - if exists('+shellslash') +if exists('+shellslash') + function! s:Slash(path) abort return tr(a:path, '\', '/') - else + endfunction +else + function! s:Slash(path) abort return a:path - endif -endfunction + endfunction +endif function! s:ProjectionistDetect() abort let file = s:Slash(get(g:, 'projectionist_file', '')) @@ -325,7 +393,7 @@ function! s:ProjectionistDetect() abort if empty(base) let base = s:Tree(dir) endif - if len(base) + if !empty(base) if exists('+shellslash') && !&shellslash let base = tr(base, '/', '\') endif @@ -336,9 +404,96 @@ function! s:ProjectionistDetect() abort endif endfunction -if v:version + has('patch061') < 703 - runtime! autoload/fugitive.vim +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' : '' + +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, "", ) + +if exists(':Gstatus') != 2 && get(g:, 'fugitive_legacy_commands', 1) + exe 'command! -bang -bar -range=-1' s:addr_other 'Gstatus exe fugitive#Command(, , +"", 0, "", )' + \ '|echohl WarningMSG|echomsg ":Gstatus is deprecated in favor of :Git (with no arguments)"|echohl NONE' +endif + +for s:cmd in ['Commit', 'Revert', 'Merge', 'Rebase', 'Pull', 'Push', 'Fetch', 'Blame'] + if exists(':G' . tolower(s:cmd)) != 2 && get(g:, 'fugitive_legacy_commands', 1) + exe 'command! -bang -nargs=? -range=-1 -complete=customlist,fugitive#' . s:cmd . 'Complete G' . tolower(s:cmd) + \ 'echohl WarningMSG|echomsg ":G' . tolower(s:cmd) . ' is deprecated in favor of :Git ' . tolower(s:cmd) . '"|echohl NONE|' + \ '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#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, "", )' + +if exists(':Glog') != 2 && get(g:, 'fugitive_legacy_commands', 1) + exe 'command! -bang -nargs=? -range=-1 -complete=customlist,fugitive#LogComplete Glog :exe fugitive#LogCommand(,,+"",0,"",, "")' + \ '|echohl WarningMSG|echomsg ":Glog is deprecated in favor of :Gclog"|echohl NONE' +endif +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, "", , [])' +exe 'command! -bar -bang -nargs=* -complete=customlist,fugitive#ReadComplete Gpedit exe fugitive#Open("pedit", 0, "", , [])' +exe 'command! -bar -bang -nargs=* -range=-1' s:addr_other '-complete=customlist,fugitive#ReadComplete Gsplit exe fugitive#Open(( > 0 ? : "").( ? "split" : "edit"), 0, "", , [])' +exe 'command! -bar -bang -nargs=* -range=-1' s:addr_other '-complete=customlist,fugitive#ReadComplete Gvsplit exe fugitive#Open(( > 0 ? : "").( ? "vsplit" : "edit!"), 0, "", , [])' +exe 'command! -bar -bang -nargs=* -range=-1' s:addr_tabs '-complete=customlist,fugitive#ReadComplete Gtabedit exe fugitive#Open(( >= 0 ? : "")."tabedit", 0, "", , [])' + +if exists(':Gr') != 2 + exe 'command! -bar -bang -nargs=* -range=-1 -complete=customlist,fugitive#ReadComplete Gr exe fugitive#ReadCommand(, , +"", 0, "", , [])' +endif +exe 'command! -bar -bang -nargs=* -range=-1 -complete=customlist,fugitive#ReadComplete Gread exe fugitive#ReadCommand(, , +"", 0, "", , [])' + +exe 'command! -bar -bang -nargs=* -complete=customlist,fugitive#EditComplete Gdiffsplit exe fugitive#Diffsplit(1, 0, "", , [])' +exe 'command! -bar -bang -nargs=* -complete=customlist,fugitive#EditComplete Ghdiffsplit exe fugitive#Diffsplit(0, 0, "", , [])' +exe 'command! -bar -bang -nargs=* -complete=customlist,fugitive#EditComplete Gvdiffsplit exe fugitive#Diffsplit(0, 0, "vertical ", , [])' + +exe 'command! -bar -bang -nargs=* -complete=customlist,fugitive#EditComplete Gw exe fugitive#WriteCommand(, , +"", 0, "", , [])' +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 GRemove exe fugitive#RemoveCommand(, , +"", 0, "", , [])' +exe 'command! -bar -bang -nargs=0 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 && get(g:, 'fugitive_legacy_commands', 1) + exe 'command! -bar -bang -nargs=0 Gremove exe fugitive#RemoveCommand(, , +"", 0, "", , [])' + \ '|echohl WarningMSG|echomsg ":Gremove is deprecated in favor of :GRemove"|echohl NONE' +endif +if exists(':Gdelete') != 2 && get(g:, 'fugitive_legacy_commands', 1) + exe 'command! -bar -bang -nargs=0 Gdelete exe fugitive#DeleteCommand(, , +"", 0, "", , [])' + \ '|echohl WarningMSG|echomsg ":Gdelete is deprecated in favor of :GDelete"|echohl NONE' +endif +if exists(':Gmove') != 2 && get(g:, 'fugitive_legacy_commands', 1) + exe 'command! -bar -bang -nargs=1 -complete=customlist,fugitive#CompleteObject Gmove exe fugitive#MoveCommand( , , +"", 0, "", , [])' + \ '|echohl WarningMSG|echomsg ":Gmove is deprecated in favor of :GMove"|echohl NONE' +endif +if exists(':Grename') != 2 && get(g:, 'fugitive_legacy_commands', 1) + exe 'command! -bar -bang -nargs=1 -complete=customlist,fugitive#RenameComplete Grename exe fugitive#RenameCommand(, , +"", 0, "", , [])' + \ '|echohl WarningMSG|echomsg ":Grename is deprecated in favor of :GRename"|echohl NONE' +endif + +exe 'command! -bar -bang -range=-1 -nargs=* -complete=customlist,fugitive#CompleteObject GBrowse exe fugitive#BrowseCommand(, , +"", 0, "", , [])' +if exists(':Gbrowse') != 2 && get(g:, 'fugitive_legacy_commands', 1) + exe 'command! -bar -bang -range=-1 -nargs=* -complete=customlist,fugitive#CompleteObject Gbrowse exe fugitive#BrowseCommand(, , +"", 0, "", , [])' + \ '|if 1|redraw!|endif|echohl WarningMSG|echomsg ":Gbrowse is deprecated in favor of :GBrowse"|echohl NONE' +endif + +if v:version < 704 + finish +endif + let g:io_fugitive = { \ 'simplify': function('fugitive#simplify'), \ 'resolve': function('fugitive#resolve'), @@ -363,27 +518,20 @@ augroup fugitive autocmd FileType netrw call FugitiveDetect(fnamemodify(get(b:, 'netrw_curdir', expand('')), ':p')) autocmd FileType git - \ if len(FugitiveGitDir()) | - \ call fugitive#MapJumps() | - \ call fugitive#MapCfile() | - \ endif + \ call fugitive#MapCfile() autocmd FileType gitcommit - \ if len(FugitiveGitDir()) | - \ call fugitive#MapCfile('fugitive#MessageCfile()') | - \ endif + \ call fugitive#MapCfile('fugitive#MessageCfile()') autocmd FileType git,gitcommit - \ if len(FugitiveGitDir()) && &foldtext ==# 'foldtext()' | + \ if &foldtext ==# 'foldtext()' | \ setlocal foldtext=fugitive#Foldtext() | \ endif autocmd FileType fugitive - \ if len(FugitiveGitDir()) | - \ call fugitive#MapCfile('fugitive#StatusCfile()') | - \ endif + \ call fugitive#MapCfile('fugitive#StatusCfile()') autocmd FileType gitrebase \ let &l:include = '^\%(pick\|squash\|edit\|reword\|fixup\|drop\|[pserfd]\)\>' | - \ if len(FugitiveGitDir()) | - \ let &l:includeexpr = 'v:fname =~# ''^\x\{4,\}$'' ? FugitiveFind(v:fname) : ' . - \ (len(&l:includeexpr) ? &l:includeexpr : 'v:fname') | + \ if &l:includeexpr !~# 'Fugitive' | + \ let &l:includeexpr = 'v:fname =~# ''^\x\{4,\}$'' && len(FugitiveGitDir()) ? FugitiveFind(v:fname) : ' . + \ (len(&l:includeexpr) ? &l:includeexpr : 'v:fname') | \ endif | \ let b:undo_ftplugin = get(b:, 'undo_ftplugin', 'exe') . '|setl inex= inc=' @@ -416,81 +564,6 @@ augroup fugitive autocmd User ProjectionistDetect call s:ProjectionistDetect() augroup END -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' : '' - -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, "", ) - -if exists(':Gstatus') !=# 2 - exe 'command! -bang -bar -range=-1' s:addr_other 'Gstatus exe fugitive#Command(, , +"", 0, "", )' -endif - -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#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, "", , [])' -exe 'command! -bar -bang -nargs=* -complete=customlist,fugitive#ReadComplete Gpedit exe fugitive#Open("pedit", 0, "", , [])' -exe 'command! -bar -bang -nargs=* -range=-1' s:addr_other '-complete=customlist,fugitive#ReadComplete Gsplit exe fugitive#Open(( > 0 ? : "").( ? "split" : "edit"), 0, "", , [])' -exe 'command! -bar -bang -nargs=* -range=-1' s:addr_other '-complete=customlist,fugitive#ReadComplete Gvsplit exe fugitive#Open(( > 0 ? : "").( ? "vsplit" : "edit!"), 0, "", , [])' -exe 'command! -bar -bang -nargs=* -range=-1' s:addr_tabs '-complete=customlist,fugitive#ReadComplete Gtabedit exe fugitive#Open(( >= 0 ? : "")."tabedit", 0, "", , [])' - -if exists(':Gr') != 2 - exe 'command! -bar -bang -nargs=* -range=-1 -complete=customlist,fugitive#ReadComplete Gr exe fugitive#ReadCommand(, , +"", 0, "", , [])' -endif -exe 'command! -bar -bang -nargs=* -range=-1 -complete=customlist,fugitive#ReadComplete Gread exe fugitive#ReadCommand(, , +"", 0, "", , [])' - -exe 'command! -bar -bang -nargs=* -complete=customlist,fugitive#EditComplete Gdiffsplit exe fugitive#Diffsplit(1, 0, "", , [])' -exe 'command! -bar -bang -nargs=* -complete=customlist,fugitive#EditComplete Ghdiffsplit exe fugitive#Diffsplit(0, 0, "", , [])' -exe 'command! -bar -bang -nargs=* -complete=customlist,fugitive#EditComplete Gvdiffsplit exe fugitive#Diffsplit(0, 0, "vert ", , [])' - -exe 'command! -bar -bang -nargs=* -complete=customlist,fugitive#EditComplete Gw exe fugitive#WriteCommand(, , +"", 0, "", , [])' -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, "", , [])' -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, "", , [])' -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 endif diff --git a/sources_non_forked/vim-fugitive/syntax/fugitive.vim b/sources_non_forked/vim-fugitive/syntax/fugitive.vim index e84eba4e..0ed82dd7 100644 --- a/sources_non_forked/vim-fugitive/syntax/fugitive.vim +++ b/sources_non_forked/vim-fugitive/syntax/fugitive.vim @@ -7,8 +7,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 fugitiveHeader /^[A-Z][a-z][^:]*:/ +syn match fugitiveHeader /^Head:/ nextgroup=fugitiveHash,fugitiveSymbolicRef skipwhite +syn match fugitiveHeader /^Pull:\|^Rebase:\|^Merge:\|^Push:/ nextgroup=fugitiveSymbolicRef skipwhite syn match fugitiveHelpHeader /^Help:/ nextgroup=fugitiveHelpTag skipwhite syn match fugitiveHelpTag /\S\+/ contained @@ -26,7 +27,7 @@ syn match fugitiveSymbolicRef /\.\@!\%(\.\.\@!\|[^[:space:][:cntrl:]\:.]\)\+\.\@ syn match fugitiveHash /^\x\{4,\}\S\@!/ contained containedin=@fugitiveSection syn match fugitiveHash /\S\@ ++once call s:close_hunk_preview_window() + autocmd CursorMoved ++once call gitgutter#hunk#close_hunk_preview_window() + + if g:gitgutter_close_preview_on_escape + " Map to close the floating preview. + nnoremap :call gitgutter#hunk#close_hunk_preview_window() + " Ensure that when the preview window is closed, the map is removed. + autocmd User GitGutterPreviewClosed silent! nunmap + autocmd CursorMoved ++once silent! nunmap + execute "autocmd WinClosed doautocmd" s:nomodeline "User GitGutterPreviewClosed" + endif return endif if exists('*popup_create') - let s:winid = popup_create('', { + let opts = { \ 'line': 'cursor+1', \ 'col': 'cursor', \ 'moved': 'any', - \ }) + \ } + if g:gitgutter_close_preview_on_escape + let opts.filter = function('s:close_popup_on_escape') + endif + + let s:winid = popup_create('', opts) call setbufvar(winbufnr(s:winid), '&filetype', 'diff') @@ -457,14 +478,12 @@ function! s:open_hunk_preview_window() endif endif + " Specifying where to open the preview window can lead to the cursor going + " to an unexpected window when the preview window is closed (#769). + silent! noautocmd execute g:gitgutter_preview_win_location 'pedit gitgutter://hunk-preview' silent! wincmd P - if &previewwindow - file gitgutter://hunk-preview - else - noautocmd execute g:gitgutter_preview_win_location &previewheight 'new gitgutter://hunk-preview' - doautocmd WinEnter - set previewwindow - endif + setlocal statusline=%{''} + doautocmd WinEnter if exists('*win_getid') let s:winid = win_getid() else @@ -474,11 +493,21 @@ function! s:open_hunk_preview_window() " Reset some defaults in case someone else has changed them. setlocal noreadonly modifiable noswapfile if g:gitgutter_close_preview_on_escape - nnoremap :pclose + " Ensure cursor goes to the expected window. + nnoremap :wincmd ppclose endif endfunction +function! s:close_popup_on_escape(winid, key) + if a:key == "\" + call popup_close(a:winid) + return 1 + endif + return 0 +endfunction + + " Floating window: does not care where cursor is. " Preview window: assumes cursor is in preview window. function! s:populate_hunk_preview_window(header, body) @@ -530,7 +559,8 @@ function! s:populate_hunk_preview_window(header, body) setlocal nomodified normal! G$ - let height = min([winline(), &previewheight]) + let hunk_height = max([body_length, winline()]) + let height = min([hunk_height, &previewheight]) execute 'resize' height 1 @@ -560,7 +590,7 @@ function! s:goto_original_window() endfunction -function! s:close_hunk_preview_window() +function! gitgutter#hunk#close_hunk_preview_window() let bufnr = s:winid != 0 ? winbufnr(s:winid) : s:preview_bufnr call setbufvar(bufnr, '&modified', 0) @@ -575,3 +605,19 @@ function! s:close_hunk_preview_window() let s:winid = 0 let s:preview_bufnr = 0 endfunction + + +function gitgutter#hunk#is_preview_window_open() + if g:gitgutter_preview_win_floating + if win_id2win(s:winid) > 0 + execute win_id2win(s:winid).'wincmd c' + endif + else + for i in range(1, winnr('$')) + if getwinvar(i, '&previewwindow') + return 1 + endif + endfor + endif + return 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 4a02c2fb..5486c3b8 100644 --- a/sources_non_forked/vim-gitgutter/autoload/gitgutter/utility.vim +++ b/sources_non_forked/vim-gitgutter/autoload/gitgutter/utility.vim @@ -30,7 +30,7 @@ endfunction function! gitgutter#utility#warn(message) abort echohl WarningMsg - echo 'vim-gitgutter: ' . a:message + echo a:message echohl None let v:warningmsg = a:message endfunction @@ -39,7 +39,7 @@ function! gitgutter#utility#warn_once(bufnr, message, key) abort if empty(gitgutter#utility#getbufvar(a:bufnr, a:key)) call gitgutter#utility#setbufvar(a:bufnr, a:key, '1') echohl WarningMsg - redraw | echom 'vim-gitgutter: ' . a:message + redraw | echom a:message echohl None let v:warningmsg = a:message endif @@ -176,15 +176,20 @@ endfunction function! s:use_known_shell() abort if has('unix') && &shell !=# 'sh' - let [s:shell, s:shellcmdflag, s:shellredir] = [&shell, &shellcmdflag, &shellredir] + let [s:shell, s:shellcmdflag, s:shellredir, s:shellpipe, s:shellquote, s:shellxquote] = [&shell, &shellcmdflag, &shellredir, &shellpipe, &shellquote, &shellxquote] let &shell = 'sh' set shellcmdflag=-c shellredir=>%s\ 2>&1 endif + if has('win32') && (&shell =~# 'pwsh' || &shell =~# 'powershell') + let [s:shell, s:shellcmdflag, s:shellredir, s:shellpipe, s:shellquote, s:shellxquote] = [&shell, &shellcmdflag, &shellredir, &shellpipe, &shellquote, &shellxquote] + let &shell = 'cmd.exe' + set shellcmdflag=/s\ /c shellredir=>%s\ 2>&1 shellpipe=>%s\ 2>&1 shellquote= shellxquote=" + endif endfunction function! s:restore_shell() abort - if has('unix') && exists('s:shell') - let [&shell, &shellcmdflag, &shellredir] = [s:shell, s:shellcmdflag, s:shellredir] + if (has('unix') || has('win32')) && exists('s:shell') + let [&shell, &shellcmdflag, &shellredir, &shellpipe, &shellquote, &shellxquote] = [s:shell, s:shellcmdflag, s:shellredir, s:shellpipe, s:shellquote, s:shellxquote] endif endfunction diff --git a/sources_non_forked/vim-gitgutter/doc/gitgutter.txt b/sources_non_forked/vim-gitgutter/doc/gitgutter.txt index 06b0be91..7da0b49b 100644 --- a/sources_non_forked/vim-gitgutter/doc/gitgutter.txt +++ b/sources_non_forked/vim-gitgutter/doc/gitgutter.txt @@ -63,15 +63,20 @@ Neovim:~ =============================================================================== WINDOWS *gitgutter-windows* -I recommend configuring vim-gitgutter with the full path to your git executable. +There is a potential risk on Windows due to `cmd.exe` prioritising the current +folder over folders in `PATH`. If you have a file named `git.*` (i.e. with +any extension in `PATHEXT`) in your current folder, it will be executed +instead of git whenever the plugin calls git. + +You can avoid this risk by configuring the full path to your git executable. For example: > + " This path probably won't work let g:gitgutter_git_executable = 'C:\Program Files\Git\bin\git.exe' < -This is to avoid a problem which occurs if you have file named "git.*" (i.e. -with any extension in "PATHEXT") in your current folder. "cmd.exe" prioritises -the current folder over folders in 'PATH' and will try to execute your file -instead of the "git" binary. + +Unfortunately I don't know the correct escaping for the path - if you do, +please let me know! =============================================================================== @@ -153,6 +158,11 @@ Commands for jumping between hunks:~ > command! Gqf GitGutterQuickFix | copen < + *gitgutter-:GitGutterQuickFixCurrentFile* +:GitGutterQuickFixCurrentFile Same as :GitGutterQuickFix, but only load hunks for + the file in the focused buffer. This has the same + functionality as :GitGutterQuickFix when the focused + buffer is empty. Commands for operating on a hunk:~ @@ -172,13 +182,30 @@ Commands for operating on a hunk:~ *gitgutter-:GitGutterPreviewHunk* :GitGutterPreviewHunk Preview the hunk the cursor is in. - Use |:pclose| or |CTRL-W_CTRL-Z| to close the preview - window. To stage part of the hunk, move to the preview window, delete any lines you do not want to stage, and |GitGutterStageHunk|. + To close a non-floating preview window use |:pclose| + or |CTRL-W_z| or |CTRL-W_CTRL-Z|; or normal window- + closing (|:quit| or |:close| or |CTRL-W_c|) if your cursor + is in the preview window. + + To close a floating window when the cursor is in the + original buffer, move the cursor. + + To close a floating window when the cursor is in the + floating window use normal window-closing, or move to + the original window with |CTRL-W_p|. Alternatively set + |g:gitgutter_close_preview_on_escape| and use . + + Two functions are available for your own logic: +> + gitgutter#hunk#is_preview_window_open() + gitgutter#hunk#close_hunk_preview_window() +< + Commands for folds:~ *gitgutter-:GitGutterFold* @@ -484,7 +511,7 @@ preview window. *g:gitgutter_close_preview_on_escape* Default: 0 -Whether pressing in a non-floating preview window closes it. +Whether pressing in a preview window closes it. *g:gitgutter_terminal_reports_focus* Default: 1 @@ -695,3 +722,4 @@ Terminus (https://github.com/wincent/terminus) or set: let g:gitgutter_terminal_reports_focus = 0 < + vim:tw=78:et:ft=help:norl: diff --git a/sources_non_forked/vim-gitgutter/plugin/gitgutter.vim b/sources_non_forked/vim-gitgutter/plugin/gitgutter.vim index 5214adf8..915c83fe 100644 --- a/sources_non_forked/vim-gitgutter/plugin/gitgutter.vim +++ b/sources_non_forked/vim-gitgutter/plugin/gitgutter.vim @@ -8,7 +8,7 @@ let g:loaded_gitgutter = 1 " Initialisation {{{ if v:version < 703 || (v:version == 703 && !has("patch105")) - call gitgutter#utility#warn('requires Vim 7.3.105') + call gitgutter#utility#warn('Requires Vim 7.3.105') finish endif @@ -25,7 +25,8 @@ let g:gitgutter_preview_win_location = get(g:, 'gitgutter_preview_win_location', if exists('*nvim_open_win') let g:gitgutter_preview_win_floating = get(g:, 'gitgutter_preview_win_floating', 1) else - let g:gitgutter_preview_win_floating = get(g:, 'gitgutter_preview_win_floating', 0) + let default = exists('&previewpopup') ? !empty(&previewpopup) : 0 + let g:gitgutter_preview_win_floating = get(g:, 'gitgutter_preview_win_floating', default) endif let g:gitgutter_enabled = get(g:, 'gitgutter_enabled', 1) if exists('*sign_unplace') @@ -71,7 +72,7 @@ let g:gitgutter_show_msg_on_hunk_jumping = get(g:, 'gitgutter_show_msg_on_hu let g:gitgutter_git_executable = get(g:, 'gitgutter_git_executable', 'git') if !executable(g:gitgutter_git_executable) if g:gitgutter_enabled - call gitgutter#utility#warn('cannot find git. Please set g:gitgutter_git_executable.') + call gitgutter#utility#warn('Cannot find git. Please set g:gitgutter_git_executable.') endif finish endif @@ -85,7 +86,7 @@ if !empty(g:gitgutter_grep) endif else if g:gitgutter_grep !=# default_grep - call gitgutter#utility#warn('cannot find '.g:gitgutter_grep.'. Please check g:gitgutter_grep.') + call gitgutter#utility#warn('Cannot find '.g:gitgutter_grep.'. Please check g:gitgutter_grep.') endif let g:gitgutter_grep = '' endif @@ -117,7 +118,8 @@ command! -bar GitGutterBufferDisable call gitgutter#buffer_disable() command! -bar GitGutterBufferEnable call gitgutter#buffer_enable() command! -bar GitGutterBufferToggle call gitgutter#buffer_toggle() -command! -bar GitGutterQuickFix call gitgutter#quickfix() +command! -bar GitGutterQuickFix call gitgutter#quickfix(0) +command! -bar GitGutterQuickFixCurrentFile call gitgutter#quickfix(1) " }}} @@ -201,18 +203,18 @@ command! -bar GitGutterDebug call gitgutter#debug#debug() " Maps {{{ nnoremap (GitGutterNextHunk) &diff ? ']c' : ":\execute v:count1 . 'GitGutterNextHunk'\" -nnoremap GitGutterNextHunk &diff ? ']c' : ":\call gitgutter#utility#warn('please change your map \Plug>GitGutterNextHunk to \Plug>(GitGutterNextHunk)')\" +nnoremap GitGutterNextHunk &diff ? ']c' : ":\call gitgutter#utility#warn('Please change your map \Plug>GitGutterNextHunk to \Plug>(GitGutterNextHunk)')\" nnoremap (GitGutterPrevHunk) &diff ? '[c' : ":\execute v:count1 . 'GitGutterPrevHunk'\" -nnoremap GitGutterPrevHunk &diff ? '[c' : ":\call gitgutter#utility#warn('please change your map \Plug>GitGutterPrevHunk to \Plug>(GitGutterPrevHunk)')\" +nnoremap GitGutterPrevHunk &diff ? '[c' : ":\call gitgutter#utility#warn('Please change your map \Plug>GitGutterPrevHunk to \Plug>(GitGutterPrevHunk)')\" xnoremap (GitGutterStageHunk) :GitGutterStageHunk -xnoremap GitGutterStageHunk :call gitgutter#utility#warn('please change your map Plug>GitGutterStageHunk to Plug>(GitGutterStageHunk)') +xnoremap GitGutterStageHunk :call gitgutter#utility#warn('Please change your map Plug>GitGutterStageHunk to Plug>(GitGutterStageHunk)') nnoremap (GitGutterStageHunk) :GitGutterStageHunk -nnoremap GitGutterStageHunk :call gitgutter#utility#warn('please change your map Plug>GitGutterStageHunk to Plug>(GitGutterStageHunk)') +nnoremap GitGutterStageHunk :call gitgutter#utility#warn('Please change your map Plug>GitGutterStageHunk to Plug>(GitGutterStageHunk)') nnoremap (GitGutterUndoHunk) :GitGutterUndoHunk -nnoremap GitGutterUndoHunk :call gitgutter#utility#warn('please change your map Plug>GitGutterUndoHunk to Plug>(GitGutterUndoHunk)') +nnoremap GitGutterUndoHunk :call gitgutter#utility#warn('Please change your map Plug>GitGutterUndoHunk to Plug>(GitGutterUndoHunk)') nnoremap (GitGutterPreviewHunk) :GitGutterPreviewHunk -nnoremap GitGutterPreviewHunk :call gitgutter#utility#warn('please change your map Plug>GitGutterPreviewHunk to Plug>(GitGutterPreviewHunk)') +nnoremap GitGutterPreviewHunk :call gitgutter#utility#warn('Please change your map Plug>GitGutterPreviewHunk to Plug>(GitGutterPreviewHunk)') " }}} diff --git a/sources_non_forked/vim-gitgutter/test/test_gitgutter.vim b/sources_non_forked/vim-gitgutter/test/test_gitgutter.vim index e75f21bc..f9aac592 100644 --- a/sources_non_forked/vim-gitgutter/test/test_gitgutter.vim +++ b/sources_non_forked/vim-gitgutter/test/test_gitgutter.vim @@ -947,12 +947,27 @@ function Test_quickfix() call setline(5, ['A', 'B']) call setline(9, ['C', 'D']) write + let bufnr1 = bufnr('') + + edit fixture_dos.txt + call setline(2, ['A', 'B']) + write + let bufnr2 = bufnr('') GitGutterQuickFix let expected = [ - \ {'lnum': 5, 'bufnr': bufnr(''), 'text': '-e'}, - \ {'lnum': 9, 'bufnr': bufnr(''), 'text': '-i'} + \ {'lnum': 5, 'bufnr': bufnr1, 'text': '-e'}, + \ {'lnum': 9, 'bufnr': bufnr1, 'text': '-i'}, + \ {'lnum': 2, 'bufnr': bufnr2, 'text': "-b\r"} + \ ] + + call s:assert_list_of_dicts(expected, getqflist()) + + GitGutterQuickFixCurrentFile + + let expected = [ + \ {'lnum': 2, 'bufnr': bufnr(''), 'text': "-b\r"}, \ ] call s:assert_list_of_dicts(expected, getqflist()) diff --git a/sources_non_forked/vim-indent-guides/.gitignore b/sources_non_forked/vim-indent-guides/.gitignore new file mode 100644 index 00000000..926ccaaf --- /dev/null +++ b/sources_non_forked/vim-indent-guides/.gitignore @@ -0,0 +1 @@ +doc/tags diff --git a/sources_non_forked/vim-indent-guides/README.markdown b/sources_non_forked/vim-indent-guides/README.markdown new file mode 100644 index 00000000..366d41c9 --- /dev/null +++ b/sources_non_forked/vim-indent-guides/README.markdown @@ -0,0 +1,111 @@ +# Indent Guides +Indent Guides is a plugin for visually displaying indent levels in Vim. + + + +## Features: +* Can detect both tab and space indent styles. +* Automatically inspects your colorscheme and picks appropriate colors (gVim only). +* Will highlight indent levels with alternating colors. +* Full support for gVim and basic support for Terminal Vim. +* Seems to work on Windows gVim 7.3 (haven't done any extensive tests though). +* Customizable size for indent guides, eg. skinny guides (soft-tabs only). +* Customizable start indent level. +* Highlight support for files with a mixture of tab and space indent styles. + +## Requirements +* Vim 7.2+ + +## Installation +To install the plugin copy `autoload`, `plugin`, `doc` directories into your `.vim` directory. + +### Pathogen +If you have [Pathogen](http://www.vim.org/scripts/script.php?script_id=2332) installed, clone this repo into a subdirectory of your `.vim/bundle` directory like so: + +```bash +cd ~/.vim/bundle +git clone git://github.com/nathanaelkane/vim-indent-guides.git +``` + +### Vundle +If you have [Vundle](https://github.com/VundleVim/Vundle.vim) installed, add the following line to your `~/.vimrc` in the appropriate spot (see the Vundle.vim README for help): + +```vim +Plugin 'nathanaelkane/vim-indent-guides' +``` + +and then run the following command from inside Vim: + +```vim +:PluginInstall +``` + +## Usage +The default mapping to toggle the plugin is `ig`. + +You can also use the following commands inside Vim: + +```vim +:IndentGuidesEnable +:IndentGuidesDisable +:IndentGuidesToggle +``` + +If you would like to have indent guides enabled by default, you can add the following to your `~/.vimrc`: + +```vim +let g:indent_guides_enable_on_vim_startup = 1 +``` + +### gVim +**This plugin should work with gVim out of the box, no configuration needed.** It will automatically inspect your colorscheme and pick appropriate colors. + +### Setting custom indent colors +Here's an example of how to define custom colors instead of using the ones the plugin automatically generates for you. Add this to your `.vimrc` file: + +```vim +let g:indent_guides_auto_colors = 0 +autocmd VimEnter,Colorscheme * :hi IndentGuidesOdd guibg=red ctermbg=3 +autocmd VimEnter,Colorscheme * :hi IndentGuidesEven guibg=green ctermbg=4 +``` + +Alternatively you can add the following lines to your colorscheme file. + +```vim +hi IndentGuidesOdd guibg=red ctermbg=3 +hi IndentGuidesEven guibg=green ctermbg=4 +``` + +### Terminal Vim +At the moment Terminal Vim only has basic support. This means is that colors won't be automatically calculated based on your colorscheme. Instead, some preset colors are used depending on whether `background` is set to `dark` or `light`. + +When `set background=dark` is used, the following highlight colors will be defined: + +```vim +hi IndentGuidesOdd ctermbg=black +hi IndentGuidesEven ctermbg=darkgrey +``` + +Alternatively, when `set background=light` is used, the following highlight colors will be defined: + +```vim +hi IndentGuidesOdd ctermbg=white +hi IndentGuidesEven ctermbg=lightgrey +``` + +If for some reason it's incorrectly defining light highlight colors instead of dark ones or vice versa, the first thing you should check is that the `background` value is being set correctly for your colorscheme. Sometimes it's best to manually set the `background` value in your `.vimrc`, for example: + +```vim +colorscheme desert256 +set background=dark +``` + +Alternatively you can manually setup the highlight colors yourself, see `:help indent_guides_auto_colors` for an example. + +## Help +`:help indent-guides` + +## Screenshots + + + diff --git a/sources_non_forked/vim-indent-guides/autoload/color_helper.vim b/sources_non_forked/vim-indent-guides/autoload/color_helper.vim new file mode 100644 index 00000000..54d18c00 --- /dev/null +++ b/sources_non_forked/vim-indent-guides/autoload/color_helper.vim @@ -0,0 +1,879 @@ +" Author: Nate Kane +" Homepage: http://github.com/nathanaelkane/vim-indent-guides + +" +" Return hex string equivalent to given decimal string or number. +" +" Example: color_helper#dec_to_hex(255, 2) +" Returns: 'FF' +" +" Example: color_helper#dec_to_hex(255, 5) +" Returns: '000FF' +" +function! color_helper#dec_to_hex(arg, padding) + return toupper(printf('%0' . a:padding . 'x', a:arg + 0)) +endfunction + +" +" Return number equivalent to given hex string ('0x' is optional). +" +" Example: color_helper#hex_to_dec('FF') +" Returns: 255 +" +" Example: color_helper#hex_to_dec('88') +" Returns: 136 +" +" Example: color_helper#hex_to_dec('00') +" Returns: 0 +" +function! color_helper#hex_to_dec(arg) + return (a:arg =~? '^0x') ? a:arg + 0 : ('0x'.a:arg) + 0 +endfunction + +" +" Converts a given hex color string into an rgb list (eg. [red, green, blue]). +" +" Example: color_helper#hex_color_to_rgb('#0088FF') +" Returns: [0, 136, 255] +" +function! color_helper#hex_color_to_rgb(hex_color) + let l:rgb = [] + + if a:hex_color =~ g:indent_guides_color_hex_pattern + let l:red = color_helper#hex_to_dec(strpart(a:hex_color, 1, 2)) + let l:green = color_helper#hex_to_dec(strpart(a:hex_color, 3, 2)) + let l:blue = color_helper#hex_to_dec(strpart(a:hex_color, 5, 2)) + let l:rgb = [l:red, l:green, l:blue] + end + + return l:rgb +endfunction + +" +" Converts a given rgb list (eg. [red, green, blue]) into a hex color string. +" +" Example: color_helper#rgb_color_to_hex([0, 136, 255]) +" Returns: '#0088FF' +" +function! color_helper#rgb_color_to_hex(rgb_color) + let l:hex_color = '#' + let l:hex_color .= color_helper#dec_to_hex(a:rgb_color[0], 2) " red + let l:hex_color .= color_helper#dec_to_hex(a:rgb_color[1], 2) " green + let l:hex_color .= color_helper#dec_to_hex(a:rgb_color[2], 2) " blue + + return l:hex_color +endfunction + +" +" Returns a ligtened color using the given color and the percent to lighten it +" by. +" +" Example: color_helper#hex_color_lighten('#000000', 0.10) +" Returns: '#191919' +" +function! color_helper#hex_color_lighten(color, percent) + let l:rgb = color_helper#hex_color_to_rgb(a:color) + let l:rgb_lightened = [] + + for i in l:rgb + call add(l:rgb_lightened, float2nr(i + ((255 - i) * a:percent))) + endfor + + return color_helper#rgb_color_to_hex(l:rgb_lightened) +endfunction + +" +" Returns a darkened color using the given color and the percent to darken it +" by. +" +" Example: color_helper#hex_color_darken('#FFFFFF', 0.10) +" Returns: '#E5E5E5' +" +function! color_helper#hex_color_darken(color, percent) + let l:rgb = color_helper#hex_color_to_rgb(a:color) + let l:rgb_darkened = [] + + for i in l:rgb + call add(l:rgb_darkened, float2nr(i * (1 - a:percent))) + endfor + + return color_helper#rgb_color_to_hex(l:rgb_darkened) +endfunction + +" +" Returns a hex color code for the given color name. +" +" Example: color_helper#color_name_to_hex('darkslategray') +" Returns: '#2F4F4F' +" +function! color_helper#color_name_to_hex(color_name) + let l:hex_code = '' + let l:color_name = tolower(a:color_name) + + let l:color_list = { + \ 'alice blue' : '#F0F8FF', + \ 'aliceblue' : '#F0F8FF', + \ 'antique white' : '#FAEBD7', + \ 'antiquewhite' : '#FAEBD7', + \ 'antiquewhite1' : '#FFEFDB', + \ 'antiquewhite2' : '#EEDFCC', + \ 'antiquewhite3' : '#CDC0B0', + \ 'antiquewhite4' : '#8B8378', + \ 'aquamarine' : '#7FFFD4', + \ 'aquamarine1' : '#7FFFD4', + \ 'aquamarine2' : '#76EEC6', + \ 'aquamarine3' : '#66CDAA', + \ 'aquamarine4' : '#458B74', + \ 'azure' : '#F0FFFF', + \ 'azure1' : '#F0FFFF', + \ 'azure2' : '#E0EEEE', + \ 'azure3' : '#C1CDCD', + \ 'azure4' : '#838B8B', + \ 'beige' : '#F5F5DC', + \ 'bisque' : '#FFE4C4', + \ 'bisque1' : '#FFE4C4', + \ 'bisque2' : '#EED5B7', + \ 'bisque3' : '#CDB79E', + \ 'bisque4' : '#8B7D6B', + \ 'black' : '#000000', + \ 'blanched almond' : '#FFEBCD', + \ 'blanchedalmond' : '#FFEBCD', + \ 'blue violet' : '#8A2BE2', + \ 'blue' : '#0000FF', + \ 'blue1' : '#0000FF', + \ 'blue2' : '#0000EE', + \ 'blue3' : '#0000CD', + \ 'blue4' : '#00008B', + \ 'blueviolet' : '#8A2BE2', + \ 'brown' : '#A52A2A', + \ 'brown1' : '#FF4040', + \ 'brown2' : '#EE3B3B', + \ 'brown3' : '#CD3333', + \ 'brown4' : '#8B2323', + \ 'burlywood' : '#DEB887', + \ 'burlywood1' : '#FFD39B', + \ 'burlywood2' : '#EEC591', + \ 'burlywood3' : '#CDAA7D', + \ 'burlywood4' : '#8B7355', + \ 'cadet blue' : '#5F9EA0', + \ 'cadetblue' : '#5F9EA0', + \ 'cadetblue1' : '#98F5FF', + \ 'cadetblue2' : '#8EE5EE', + \ 'cadetblue3' : '#7AC5CD', + \ 'cadetblue4' : '#53868B', + \ 'chartreuse' : '#7FFF00', + \ 'chartreuse1' : '#7FFF00', + \ 'chartreuse2' : '#76EE00', + \ 'chartreuse3' : '#66CD00', + \ 'chartreuse4' : '#458B00', + \ 'chocolate' : '#D2691E', + \ 'chocolate1' : '#FF7F24', + \ 'chocolate2' : '#EE7621', + \ 'chocolate3' : '#CD661D', + \ 'chocolate4' : '#8B4513', + \ 'coral' : '#FF7F50', + \ 'coral1' : '#FF7256', + \ 'coral2' : '#EE6A50', + \ 'coral3' : '#CD5B45', + \ 'coral4' : '#8B3E2F', + \ 'cornflower blue' : '#6495ED', + \ 'cornflowerblue' : '#6495ED', + \ 'cornsilk' : '#FFF8DC', + \ 'cornsilk1' : '#FFF8DC', + \ 'cornsilk2' : '#EEE8CD', + \ 'cornsilk3' : '#CDC8B1', + \ 'cornsilk4' : '#8B8878', + \ 'cyan' : '#00FFFF', + \ 'cyan1' : '#00FFFF', + \ 'cyan2' : '#00EEEE', + \ 'cyan3' : '#00CDCD', + \ 'cyan4' : '#008B8B', + \ 'dark blue' : '#00008B', + \ 'dark cyan' : '#008B8B', + \ 'dark goldenrod' : '#B8860B', + \ 'dark gray' : '#A9A9A9', + \ 'dark green' : '#006400', + \ 'dark grey' : '#A9A9A9', + \ 'dark khaki' : '#BDB76B', + \ 'dark magenta' : '#8B008B', + \ 'dark olive green' : '#556B2F', + \ 'dark orange' : '#FF8C00', + \ 'dark orchid' : '#9932CC', + \ 'dark red' : '#8B0000', + \ 'dark salmon' : '#E9967A', + \ 'dark sea green' : '#8FBC8F', + \ 'dark slate blue' : '#483D8B', + \ 'dark slate gray' : '#2F4F4F', + \ 'dark slate grey' : '#2F4F4F', + \ 'dark turquoise' : '#00CED1', + \ 'dark violet' : '#9400D3', + \ 'dark yellow' : '#BBBB00', + \ 'darkblue' : '#00008B', + \ 'darkcyan' : '#008B8B', + \ 'darkgoldenrod' : '#B8860B', + \ 'darkgoldenrod1' : '#FFB90F', + \ 'darkgoldenrod2' : '#EEAD0E', + \ 'darkgoldenrod3' : '#CD950C', + \ 'darkgoldenrod4' : '#8B6508', + \ 'darkgray' : '#A9A9A9', + \ 'darkgreen' : '#006400', + \ 'darkgrey' : '#A9A9A9', + \ 'darkkhaki' : '#BDB76B', + \ 'darkmagenta' : '#8B008B', + \ 'darkolivegreen' : '#556B2F', + \ 'darkolivegreen1' : '#CAFF70', + \ 'darkolivegreen2' : '#BCEE68', + \ 'darkolivegreen3' : '#A2CD5A', + \ 'darkolivegreen4' : '#6E8B3D', + \ 'darkorange' : '#FF8C00', + \ 'darkorange1' : '#FF7F00', + \ 'darkorange2' : '#EE7600', + \ 'darkorange3' : '#CD6600', + \ 'darkorange4' : '#8B4500', + \ 'darkorchid' : '#9932CC', + \ 'darkorchid1' : '#BF3EFF', + \ 'darkorchid2' : '#B23AEE', + \ 'darkorchid3' : '#9A32CD', + \ 'darkorchid4' : '#68228B', + \ 'darkred' : '#8B0000', + \ 'darksalmon' : '#E9967A', + \ 'darkseagreen' : '#8FBC8F', + \ 'darkseagreen1' : '#C1FFC1', + \ 'darkseagreen2' : '#B4EEB4', + \ 'darkseagreen3' : '#9BCD9B', + \ 'darkseagreen4' : '#698B69', + \ 'darkslateblue' : '#483D8B', + \ 'darkslategray' : '#2F4F4F', + \ 'darkslategray1' : '#97FFFF', + \ 'darkslategray2' : '#8DEEEE', + \ 'darkslategray3' : '#79CDCD', + \ 'darkslategray4' : '#528B8B', + \ 'darkslategrey' : '#2F4F4F', + \ 'darkturquoise' : '#00CED1', + \ 'darkviolet' : '#9400D3', + \ 'darkyellow' : '#BBBB00', + \ 'deep pink' : '#FF1493', + \ 'deep sky blue' : '#00BFFF', + \ 'deeppink' : '#FF1493', + \ 'deeppink1' : '#FF1493', + \ 'deeppink2' : '#EE1289', + \ 'deeppink3' : '#CD1076', + \ 'deeppink4' : '#8B0A50', + \ 'deepskyblue' : '#00BFFF', + \ 'deepskyblue1' : '#00BFFF', + \ 'deepskyblue2' : '#00B2EE', + \ 'deepskyblue3' : '#009ACD', + \ 'deepskyblue4' : '#00688B', + \ 'dim gray' : '#696969', + \ 'dim grey' : '#696969', + \ 'dimgray' : '#696969', + \ 'dimgrey' : '#696969', + \ 'dodger blue' : '#1E90FF', + \ 'dodgerblue' : '#1E90FF', + \ 'dodgerblue1' : '#1E90FF', + \ 'dodgerblue2' : '#1C86EE', + \ 'dodgerblue3' : '#1874CD', + \ 'dodgerblue4' : '#104E8B', + \ 'firebrick' : '#B22222', + \ 'firebrick1' : '#FF3030', + \ 'firebrick2' : '#EE2C2C', + \ 'firebrick3' : '#CD2626', + \ 'firebrick4' : '#8B1A1A', + \ 'floral white' : '#FFFAF0', + \ 'floralwhite' : '#FFFAF0', + \ 'forest green' : '#228B22', + \ 'forestgreen' : '#228B22', + \ 'gainsboro' : '#DCDCDC', + \ 'ghost white' : '#F8F8FF', + \ 'ghostwhite' : '#F8F8FF', + \ 'gold' : '#FFD700', + \ 'gold1' : '#FFD700', + \ 'gold2' : '#EEC900', + \ 'gold3' : '#CDAD00', + \ 'gold4' : '#8B7500', + \ 'goldenrod' : '#DAA520', + \ 'goldenrod1' : '#FFC125', + \ 'goldenrod2' : '#EEB422', + \ 'goldenrod3' : '#CD9B1D', + \ 'goldenrod4' : '#8B6914', + \ 'gray' : '#BEBEBE', + \ 'gray0' : '#000000', + \ 'gray1' : '#030303', + \ 'gray10' : '#1A1A1A', + \ 'gray100' : '#FFFFFF', + \ 'gray11' : '#1C1C1C', + \ 'gray12' : '#1F1F1F', + \ 'gray13' : '#212121', + \ 'gray14' : '#242424', + \ 'gray15' : '#262626', + \ 'gray16' : '#292929', + \ 'gray17' : '#2B2B2B', + \ 'gray18' : '#2E2E2E', + \ 'gray19' : '#303030', + \ 'gray2' : '#050505', + \ 'gray20' : '#333333', + \ 'gray21' : '#363636', + \ 'gray22' : '#383838', + \ 'gray23' : '#3B3B3B', + \ 'gray24' : '#3D3D3D', + \ 'gray25' : '#404040', + \ 'gray26' : '#424242', + \ 'gray27' : '#454545', + \ 'gray28' : '#474747', + \ 'gray29' : '#4A4A4A', + \ 'gray3' : '#080808', + \ 'gray30' : '#4D4D4D', + \ 'gray31' : '#4F4F4F', + \ 'gray32' : '#525252', + \ 'gray33' : '#545454', + \ 'gray34' : '#575757', + \ 'gray35' : '#595959', + \ 'gray36' : '#5C5C5C', + \ 'gray37' : '#5E5E5E', + \ 'gray38' : '#616161', + \ 'gray39' : '#636363', + \ 'gray4' : '#0A0A0A', + \ 'gray40' : '#666666', + \ 'gray41' : '#696969', + \ 'gray42' : '#6B6B6B', + \ 'gray43' : '#6E6E6E', + \ 'gray44' : '#707070', + \ 'gray45' : '#737373', + \ 'gray46' : '#757575', + \ 'gray47' : '#787878', + \ 'gray48' : '#7A7A7A', + \ 'gray49' : '#7D7D7D', + \ 'gray5' : '#0D0D0D', + \ 'gray50' : '#7F7F7F', + \ 'gray51' : '#828282', + \ 'gray52' : '#858585', + \ 'gray53' : '#878787', + \ 'gray54' : '#8A8A8A', + \ 'gray55' : '#8C8C8C', + \ 'gray56' : '#8F8F8F', + \ 'gray57' : '#919191', + \ 'gray58' : '#949494', + \ 'gray59' : '#969696', + \ 'gray6' : '#0F0F0F', + \ 'gray60' : '#999999', + \ 'gray61' : '#9C9C9C', + \ 'gray62' : '#9E9E9E', + \ 'gray63' : '#A1A1A1', + \ 'gray64' : '#A3A3A3', + \ 'gray65' : '#A6A6A6', + \ 'gray66' : '#A8A8A8', + \ 'gray67' : '#ABABAB', + \ 'gray68' : '#ADADAD', + \ 'gray69' : '#B0B0B0', + \ 'gray7' : '#121212', + \ 'gray70' : '#B3B3B3', + \ 'gray71' : '#B5B5B5', + \ 'gray72' : '#B8B8B8', + \ 'gray73' : '#BABABA', + \ 'gray74' : '#BDBDBD', + \ 'gray75' : '#BFBFBF', + \ 'gray76' : '#C2C2C2', + \ 'gray77' : '#C4C4C4', + \ 'gray78' : '#C7C7C7', + \ 'gray79' : '#C9C9C9', + \ 'gray8' : '#141414', + \ 'gray80' : '#CCCCCC', + \ 'gray81' : '#CFCFCF', + \ 'gray82' : '#D1D1D1', + \ 'gray83' : '#D4D4D4', + \ 'gray84' : '#D6D6D6', + \ 'gray85' : '#D9D9D9', + \ 'gray86' : '#DBDBDB', + \ 'gray87' : '#DEDEDE', + \ 'gray88' : '#E0E0E0', + \ 'gray89' : '#E3E3E3', + \ 'gray9' : '#171717', + \ 'gray90' : '#E5E5E5', + \ 'gray91' : '#E8E8E8', + \ 'gray92' : '#EBEBEB', + \ 'gray93' : '#EDEDED', + \ 'gray94' : '#F0F0F0', + \ 'gray95' : '#F2F2F2', + \ 'gray96' : '#F5F5F5', + \ 'gray97' : '#F7F7F7', + \ 'gray98' : '#FAFAFA', + \ 'gray99' : '#FCFCFC', + \ 'green yellow' : '#ADFF2F', + \ 'green' : '#00FF00', + \ 'green1' : '#00FF00', + \ 'green2' : '#00EE00', + \ 'green3' : '#00CD00', + \ 'green4' : '#008B00', + \ 'greenyellow' : '#ADFF2F', + \ 'grey' : '#BEBEBE', + \ 'grey0' : '#000000', + \ 'grey1' : '#030303', + \ 'grey10' : '#1A1A1A', + \ 'grey100' : '#FFFFFF', + \ 'grey11' : '#1C1C1C', + \ 'grey12' : '#1F1F1F', + \ 'grey13' : '#212121', + \ 'grey14' : '#242424', + \ 'grey15' : '#262626', + \ 'grey16' : '#292929', + \ 'grey17' : '#2B2B2B', + \ 'grey18' : '#2E2E2E', + \ 'grey19' : '#303030', + \ 'grey2' : '#050505', + \ 'grey20' : '#333333', + \ 'grey21' : '#363636', + \ 'grey22' : '#383838', + \ 'grey23' : '#3B3B3B', + \ 'grey24' : '#3D3D3D', + \ 'grey25' : '#404040', + \ 'grey26' : '#424242', + \ 'grey27' : '#454545', + \ 'grey28' : '#474747', + \ 'grey29' : '#4A4A4A', + \ 'grey3' : '#080808', + \ 'grey30' : '#4D4D4D', + \ 'grey31' : '#4F4F4F', + \ 'grey32' : '#525252', + \ 'grey33' : '#545454', + \ 'grey34' : '#575757', + \ 'grey35' : '#595959', + \ 'grey36' : '#5C5C5C', + \ 'grey37' : '#5E5E5E', + \ 'grey38' : '#616161', + \ 'grey39' : '#636363', + \ 'grey4' : '#0A0A0A', + \ 'grey40' : '#666666', + \ 'grey41' : '#696969', + \ 'grey42' : '#6B6B6B', + \ 'grey43' : '#6E6E6E', + \ 'grey44' : '#707070', + \ 'grey45' : '#737373', + \ 'grey46' : '#757575', + \ 'grey47' : '#787878', + \ 'grey48' : '#7A7A7A', + \ 'grey49' : '#7D7D7D', + \ 'grey5' : '#0D0D0D', + \ 'grey50' : '#7F7F7F', + \ 'grey51' : '#828282', + \ 'grey52' : '#858585', + \ 'grey53' : '#878787', + \ 'grey54' : '#8A8A8A', + \ 'grey55' : '#8C8C8C', + \ 'grey56' : '#8F8F8F', + \ 'grey57' : '#919191', + \ 'grey58' : '#949494', + \ 'grey59' : '#969696', + \ 'grey6' : '#0F0F0F', + \ 'grey60' : '#999999', + \ 'grey61' : '#9C9C9C', + \ 'grey62' : '#9E9E9E', + \ 'grey63' : '#A1A1A1', + \ 'grey64' : '#A3A3A3', + \ 'grey65' : '#A6A6A6', + \ 'grey66' : '#A8A8A8', + \ 'grey67' : '#ABABAB', + \ 'grey68' : '#ADADAD', + \ 'grey69' : '#B0B0B0', + \ 'grey7' : '#121212', + \ 'grey70' : '#B3B3B3', + \ 'grey71' : '#B5B5B5', + \ 'grey72' : '#B8B8B8', + \ 'grey73' : '#BABABA', + \ 'grey74' : '#BDBDBD', + \ 'grey75' : '#BFBFBF', + \ 'grey76' : '#C2C2C2', + \ 'grey77' : '#C4C4C4', + \ 'grey78' : '#C7C7C7', + \ 'grey79' : '#C9C9C9', + \ 'grey8' : '#141414', + \ 'grey80' : '#CCCCCC', + \ 'grey81' : '#CFCFCF', + \ 'grey82' : '#D1D1D1', + \ 'grey83' : '#D4D4D4', + \ 'grey84' : '#D6D6D6', + \ 'grey85' : '#D9D9D9', + \ 'grey86' : '#DBDBDB', + \ 'grey87' : '#DEDEDE', + \ 'grey88' : '#E0E0E0', + \ 'grey89' : '#E3E3E3', + \ 'grey9' : '#171717', + \ 'grey90' : '#E5E5E5', + \ 'grey91' : '#E8E8E8', + \ 'grey92' : '#EBEBEB', + \ 'grey93' : '#EDEDED', + \ 'grey94' : '#F0F0F0', + \ 'grey95' : '#F2F2F2', + \ 'grey96' : '#F5F5F5', + \ 'grey97' : '#F7F7F7', + \ 'grey98' : '#FAFAFA', + \ 'grey99' : '#FCFCFC', + \ 'honeydew' : '#F0FFF0', + \ 'honeydew1' : '#F0FFF0', + \ 'honeydew2' : '#E0EEE0', + \ 'honeydew3' : '#C1CDC1', + \ 'honeydew4' : '#838B83', + \ 'hot pink' : '#FF69B4', + \ 'hotpink' : '#FF69B4', + \ 'hotpink1' : '#FF6EB4', + \ 'hotpink2' : '#EE6AA7', + \ 'hotpink3' : '#CD6090', + \ 'hotpink4' : '#8B3A62', + \ 'indian red' : '#CD5C5C', + \ 'indianred' : '#CD5C5C', + \ 'indianred1' : '#FF6A6A', + \ 'indianred2' : '#EE6363', + \ 'indianred3' : '#CD5555', + \ 'indianred4' : '#8B3A3A', + \ 'ivory' : '#FFFFF0', + \ 'ivory1' : '#FFFFF0', + \ 'ivory2' : '#EEEEE0', + \ 'ivory3' : '#CDCDC1', + \ 'ivory4' : '#8B8B83', + \ 'khaki' : '#F0E68C', + \ 'khaki1' : '#FFF68F', + \ 'khaki2' : '#EEE685', + \ 'khaki3' : '#CDC673', + \ 'khaki4' : '#8B864E', + \ 'lavender blush' : '#FFF0F5', + \ 'lavender' : '#E6E6FA', + \ 'lavenderblush' : '#FFF0F5', + \ 'lavenderblush1' : '#FFF0F5', + \ 'lavenderblush2' : '#EEE0E5', + \ 'lavenderblush3' : '#CDC1C5', + \ 'lavenderblush4' : '#8B8386', + \ 'lawn green' : '#7CFC00', + \ 'lawngreen' : '#7CFC00', + \ 'lemon chiffon' : '#FFFACD', + \ 'lemonchiffon' : '#FFFACD', + \ 'lemonchiffon1' : '#FFFACD', + \ 'lemonchiffon2' : '#EEE9BF', + \ 'lemonchiffon3' : '#CDC9A5', + \ 'lemonchiffon4' : '#8B8970', + \ 'light blue' : '#ADD8E6', + \ 'light coral' : '#F08080', + \ 'light cyan' : '#E0FFFF', + \ 'light goldenrod yellow' : '#FAFAD2', + \ 'light goldenrod' : '#EEDD82', + \ 'light gray' : '#D3D3D3', + \ 'light green' : '#90EE90', + \ 'light grey' : '#D3D3D3', + \ 'light magenta' : '#FFBBFF', + \ 'light pink' : '#FFB6C1', + \ 'light red' : '#FFBBBB', + \ 'light salmon' : '#FFA07A', + \ 'light sea green' : '#20B2AA', + \ 'light sky blue' : '#87CEFA', + \ 'light slate blue' : '#8470FF', + \ 'light slate gray' : '#778899', + \ 'light slate grey' : '#778899', + \ 'light steel blue' : '#B0C4DE', + \ 'light yellow' : '#FFFFE0', + \ 'lightblue' : '#ADD8E6', + \ 'lightblue1' : '#BFEFFF', + \ 'lightblue2' : '#B2DFEE', + \ 'lightblue3' : '#9AC0CD', + \ 'lightblue4' : '#68838B', + \ 'lightcoral' : '#F08080', + \ 'lightcyan' : '#E0FFFF', + \ 'lightcyan1' : '#E0FFFF', + \ 'lightcyan2' : '#D1EEEE', + \ 'lightcyan3' : '#B4CDCD', + \ 'lightcyan4' : '#7A8B8B', + \ 'lightgoldenrod' : '#EEDD82', + \ 'lightgoldenrod1' : '#FFEC8B', + \ 'lightgoldenrod2' : '#EEDC82', + \ 'lightgoldenrod3' : '#CDBE70', + \ 'lightgoldenrod4' : '#8B814C', + \ 'lightgoldenrodyellow' : '#FAFAD2', + \ 'lightgray' : '#D3D3D3', + \ 'lightgreen' : '#90EE90', + \ 'lightgrey' : '#D3D3D3', + \ 'lightmagenta' : '#FFBBFF', + \ 'lightpink' : '#FFB6C1', + \ 'lightpink1' : '#FFAEB9', + \ 'lightpink2' : '#EEA2AD', + \ 'lightpink3' : '#CD8C95', + \ 'lightpink4' : '#8B5F65', + \ 'lightred' : '#FFBBBB', + \ 'lightsalmon' : '#FFA07A', + \ 'lightsalmon1' : '#FFA07A', + \ 'lightsalmon2' : '#EE9572', + \ 'lightsalmon3' : '#CD8162', + \ 'lightsalmon4' : '#8B5742', + \ 'lightseagreen' : '#20B2AA', + \ 'lightskyblue' : '#87CEFA', + \ 'lightskyblue1' : '#B0E2FF', + \ 'lightskyblue2' : '#A4D3EE', + \ 'lightskyblue3' : '#8DB6CD', + \ 'lightskyblue4' : '#607B8B', + \ 'lightslateblue' : '#8470FF', + \ 'lightslategray' : '#778899', + \ 'lightslategrey' : '#778899', + \ 'lightsteelblue' : '#B0C4DE', + \ 'lightsteelblue1' : '#CAE1FF', + \ 'lightsteelblue2' : '#BCD2EE', + \ 'lightsteelblue3' : '#A2B5CD', + \ 'lightsteelblue4' : '#6E7B8B', + \ 'lightyellow' : '#FFFFE0', + \ 'lightyellow1' : '#FFFFE0', + \ 'lightyellow2' : '#EEEED1', + \ 'lightyellow3' : '#CDCDB4', + \ 'lightyellow4' : '#8B8B7A', + \ 'lime green' : '#32CD32', + \ 'limegreen' : '#32CD32', + \ 'linen' : '#FAF0E6', + \ 'magenta' : '#FF00FF', + \ 'magenta1' : '#FF00FF', + \ 'magenta2' : '#EE00EE', + \ 'magenta3' : '#CD00CD', + \ 'magenta4' : '#8B008B', + \ 'maroon' : '#B03060', + \ 'maroon1' : '#FF34B3', + \ 'maroon2' : '#EE30A7', + \ 'maroon3' : '#CD2990', + \ 'maroon4' : '#8B1C62', + \ 'medium aquamarine' : '#66CDAA', + \ 'medium blue' : '#0000CD', + \ 'medium orchid' : '#BA55D3', + \ 'medium purple' : '#9370DB', + \ 'medium sea green' : '#3CB371', + \ 'medium slate blue' : '#7B68EE', + \ 'medium spring green' : '#00FA9A', + \ 'medium turquoise' : '#48D1CC', + \ 'medium violet red' : '#C71585', + \ 'mediumaquamarine' : '#66CDAA', + \ 'mediumblue' : '#0000CD', + \ 'mediumorchid' : '#BA55D3', + \ 'mediumorchid1' : '#E066FF', + \ 'mediumorchid2' : '#D15FEE', + \ 'mediumorchid3' : '#B452CD', + \ 'mediumorchid4' : '#7A378B', + \ 'mediumpurple' : '#9370DB', + \ 'mediumpurple1' : '#AB82FF', + \ 'mediumpurple2' : '#9F79EE', + \ 'mediumpurple3' : '#8968CD', + \ 'mediumpurple4' : '#5D478B', + \ 'mediumseagreen' : '#3CB371', + \ 'mediumslateblue' : '#7B68EE', + \ 'mediumspringgreen' : '#00FA9A', + \ 'mediumturquoise' : '#48D1CC', + \ 'mediumvioletred' : '#C71585', + \ 'midnight blue' : '#191970', + \ 'midnightblue' : '#191970', + \ 'mint cream' : '#F5FFFA', + \ 'mintcream' : '#F5FFFA', + \ 'misty rose' : '#FFE4E1', + \ 'mistyrose' : '#FFE4E1', + \ 'mistyrose1' : '#FFE4E1', + \ 'mistyrose2' : '#EED5D2', + \ 'mistyrose3' : '#CDB7B5', + \ 'mistyrose4' : '#8B7D7B', + \ 'moccasin' : '#FFE4B5', + \ 'navajo white' : '#FFDEAD', + \ 'navajowhite' : '#FFDEAD', + \ 'navajowhite1' : '#FFDEAD', + \ 'navajowhite2' : '#EECFA1', + \ 'navajowhite3' : '#CDB38B', + \ 'navajowhite4' : '#8B795E', + \ 'navy blue' : '#000080', + \ 'navy' : '#000080', + \ 'navyblue' : '#000080', + \ 'old lace' : '#FDF5E6', + \ 'oldlace' : '#FDF5E6', + \ 'olive drab' : '#6B8E23', + \ 'olivedrab' : '#6B8E23', + \ 'olivedrab1' : '#C0FF3E', + \ 'olivedrab2' : '#B3EE3A', + \ 'olivedrab3' : '#9ACD32', + \ 'olivedrab4' : '#698B22', + \ 'orange red' : '#FF4500', + \ 'orange' : '#FFA500', + \ 'orange1' : '#FFA500', + \ 'orange2' : '#EE9A00', + \ 'orange3' : '#CD8500', + \ 'orange4' : '#8B5A00', + \ 'orangered' : '#FF4500', + \ 'orangered1' : '#FF4500', + \ 'orangered2' : '#EE4000', + \ 'orangered3' : '#CD3700', + \ 'orangered4' : '#8B2500', + \ 'orchid' : '#DA70D6', + \ 'orchid1' : '#FF83FA', + \ 'orchid2' : '#EE7AE9', + \ 'orchid3' : '#CD69C9', + \ 'orchid4' : '#8B4789', + \ 'pale goldenrod' : '#EEE8AA', + \ 'pale green' : '#98FB98', + \ 'pale turquoise' : '#AFEEEE', + \ 'pale violet red' : '#DB7093', + \ 'palegoldenrod' : '#EEE8AA', + \ 'palegreen' : '#98FB98', + \ 'palegreen1' : '#9AFF9A', + \ 'palegreen2' : '#90EE90', + \ 'palegreen3' : '#7CCD7C', + \ 'palegreen4' : '#548B54', + \ 'paleturquoise' : '#AFEEEE', + \ 'paleturquoise1' : '#BBFFFF', + \ 'paleturquoise2' : '#AEEEEE', + \ 'paleturquoise3' : '#96CDCD', + \ 'paleturquoise4' : '#668B8B', + \ 'palevioletred' : '#DB7093', + \ 'palevioletred1' : '#FF82AB', + \ 'palevioletred2' : '#EE799F', + \ 'palevioletred3' : '#CD6889', + \ 'palevioletred4' : '#8B475D', + \ 'papaya whip' : '#FFEFD5', + \ 'papayawhip' : '#FFEFD5', + \ 'peach puff' : '#FFDAB9', + \ 'peachpuff' : '#FFDAB9', + \ 'peachpuff1' : '#FFDAB9', + \ 'peachpuff2' : '#EECBAD', + \ 'peachpuff3' : '#CDAF95', + \ 'peachpuff4' : '#8B7765', + \ 'peru' : '#CD853F', + \ 'pink' : '#FFC0CB', + \ 'pink1' : '#FFB5C5', + \ 'pink2' : '#EEA9B8', + \ 'pink3' : '#CD919E', + \ 'pink4' : '#8B636C', + \ 'plum' : '#DDA0DD', + \ 'plum1' : '#FFBBFF', + \ 'plum2' : '#EEAEEE', + \ 'plum3' : '#CD96CD', + \ 'plum4' : '#8B668B', + \ 'powder blue' : '#B0E0E6', + \ 'powderblue' : '#B0E0E6', + \ 'purple' : '#A020F0', + \ 'purple1' : '#9B30FF', + \ 'purple2' : '#912CEE', + \ 'purple3' : '#7D26CD', + \ 'purple4' : '#551A8B', + \ 'red' : '#FF0000', + \ 'red1' : '#FF0000', + \ 'red2' : '#EE0000', + \ 'red3' : '#CD0000', + \ 'red4' : '#8B0000', + \ 'rosy brown' : '#BC8F8F', + \ 'rosybrown' : '#BC8F8F', + \ 'rosybrown1' : '#FFC1C1', + \ 'rosybrown2' : '#EEB4B4', + \ 'rosybrown3' : '#CD9B9B', + \ 'rosybrown4' : '#8B6969', + \ 'royal blue' : '#4169E1', + \ 'royalblue' : '#4169E1', + \ 'royalblue1' : '#4876FF', + \ 'royalblue2' : '#436EEE', + \ 'royalblue3' : '#3A5FCD', + \ 'royalblue4' : '#27408B', + \ 'saddle brown' : '#8B4513', + \ 'saddlebrown' : '#8B4513', + \ 'salmon' : '#FA8072', + \ 'salmon1' : '#FF8C69', + \ 'salmon2' : '#EE8262', + \ 'salmon3' : '#CD7054', + \ 'salmon4' : '#8B4C39', + \ 'sandy brown' : '#F4A460', + \ 'sandybrown' : '#F4A460', + \ 'sea green' : '#2E8B57', + \ 'seagreen' : '#2E8B57', + \ 'seagreen1' : '#54FF9F', + \ 'seagreen2' : '#4EEE94', + \ 'seagreen3' : '#43CD80', + \ 'seagreen4' : '#2E8B57', + \ 'seashell' : '#FFF5EE', + \ 'seashell1' : '#FFF5EE', + \ 'seashell2' : '#EEE5DE', + \ 'seashell3' : '#CDC5BF', + \ 'seashell4' : '#8B8682', + \ 'sienna' : '#A0522D', + \ 'sienna1' : '#FF8247', + \ 'sienna2' : '#EE7942', + \ 'sienna3' : '#CD6839', + \ 'sienna4' : '#8B4726', + \ 'sky blue' : '#87CEEB', + \ 'skyblue' : '#87CEEB', + \ 'skyblue1' : '#87CEFF', + \ 'skyblue2' : '#7EC0EE', + \ 'skyblue3' : '#6CA6CD', + \ 'skyblue4' : '#4A708B', + \ 'slate blue' : '#6A5ACD', + \ 'slate gray' : '#708090', + \ 'slate grey' : '#708090', + \ 'slateblue' : '#6A5ACD', + \ 'slateblue1' : '#836FFF', + \ 'slateblue2' : '#7A67EE', + \ 'slateblue3' : '#6959CD', + \ 'slateblue4' : '#473C8B', + \ 'slategray' : '#708090', + \ 'slategray1' : '#C6E2FF', + \ 'slategray2' : '#B9D3EE', + \ 'slategray3' : '#9FB6CD', + \ 'slategray4' : '#6C7B8B', + \ 'slategrey' : '#708090', + \ 'snow' : '#FFFAFA', + \ 'snow1' : '#FFFAFA', + \ 'snow2' : '#EEE9E9', + \ 'snow3' : '#CDC9C9', + \ 'snow4' : '#8B8989', + \ 'spring green' : '#00FF7F', + \ 'springgreen' : '#00FF7F', + \ 'springgreen1' : '#00FF7F', + \ 'springgreen2' : '#00EE76', + \ 'springgreen3' : '#00CD66', + \ 'springgreen4' : '#008B45', + \ 'steel blue' : '#4682B4', + \ 'steelblue' : '#4682B4', + \ 'steelblue1' : '#63B8FF', + \ 'steelblue2' : '#5CACEE', + \ 'steelblue3' : '#4F94CD', + \ 'steelblue4' : '#36648B', + \ 'tan' : '#D2B48C', + \ 'tan1' : '#FFA54F', + \ 'tan2' : '#EE9A49', + \ 'tan3' : '#CD853F', + \ 'tan4' : '#8B5A2B', + \ 'thistle' : '#D8BFD8', + \ 'thistle1' : '#FFE1FF', + \ 'thistle2' : '#EED2EE', + \ 'thistle3' : '#CDB5CD', + \ 'thistle4' : '#8B7B8B', + \ 'tomato' : '#FF6347', + \ 'tomato1' : '#FF6347', + \ 'tomato2' : '#EE5C42', + \ 'tomato3' : '#CD4F39', + \ 'tomato4' : '#8B3626', + \ 'turquoise' : '#40E0D0', + \ 'turquoise1' : '#00F5FF', + \ 'turquoise2' : '#00E5EE', + \ 'turquoise3' : '#00C5CD', + \ 'turquoise4' : '#00868B', + \ 'violet red' : '#D02090', + \ 'violet' : '#EE82EE', + \ 'violetred' : '#D02090', + \ 'violetred1' : '#FF3E96', + \ 'violetred2' : '#EE3A8C', + \ 'violetred3' : '#CD3278', + \ 'violetred4' : '#8B2252', + \ 'wheat' : '#F5DEB3', + \ 'wheat1' : '#FFE7BA', + \ 'wheat2' : '#EED8AE', + \ 'wheat3' : '#CDBA96', + \ 'wheat4' : '#8B7E66', + \ 'white smoke' : '#F5F5F5', + \ 'white' : '#FFFFFF', + \ 'whitesmoke' : '#F5F5F5', + \ 'yellow green' : '#9ACD32', + \ 'yellow' : '#FFFF00', + \ 'yellow1' : '#FFFF00', + \ 'yellow2' : '#EEEE00', + \ 'yellow3' : '#CDCD00', + \ 'yellow4' : '#8B8B00', + \ 'yellowgreen' : '#9ACD32', + \} + + if has_key(l:color_list, l:color_name) + let l:hex_code = l:color_list[l:color_name] + endif + + return l:hex_code +endfunction diff --git a/sources_non_forked/vim-indent-guides/autoload/indent_guides.vim b/sources_non_forked/vim-indent-guides/autoload/indent_guides.vim new file mode 100644 index 00000000..482d0adb --- /dev/null +++ b/sources_non_forked/vim-indent-guides/autoload/indent_guides.vim @@ -0,0 +1,286 @@ +" Author: Nate Kane +" Homepage: http://github.com/nathanaelkane/vim-indent-guides + +" +" Toggles the indent guides on and off. +" +function! indent_guides#toggle() + call indent_guides#init_matches() + + if empty(w:indent_guides_matches) + call indent_guides#enable() + else + call indent_guides#disable() + endif +endfunction + +" +" Called from autocmds, keeps indent guides enabled or disabled when entering +" other buffers and windows. +" +function! indent_guides#process_autocmds() + if g:indent_guides_autocmds_enabled + call indent_guides#enable() + else + call indent_guides#disable() + end +endfunction + +" +" Enables the indent guides for the current buffer and any other buffer upon +" entering it. +" +function! indent_guides#enable() + let g:indent_guides_autocmds_enabled = 1 + + if &diff || indent_guides#exclude_filetype() + call indent_guides#clear_matches() + return + end + + call indent_guides#init_script_vars() + call indent_guides#highlight_colors() + call indent_guides#clear_matches() + + " loop through each indent level and define a highlight pattern + " will automagically figure out whether to use tabs or spaces + for l:level in range(s:start_level, s:indent_levels) + let l:group = 'IndentGuides' . ((l:level % 2 == 0) ? 'Even' : 'Odd') + let l:column_start = (l:level - 1) * s:indent_size + 1 + + " define the higlight patterns and add to matches list + if g:indent_guides_space_guides + let l:soft_pattern = indent_guides#indent_highlight_pattern(g:indent_guides_soft_pattern, l:column_start, s:guide_size) + call add(w:indent_guides_matches, matchadd(l:group, l:soft_pattern)) + end + if g:indent_guides_tab_guides + let l:hard_pattern = indent_guides#indent_highlight_pattern('\t', l:column_start, s:indent_size) + call add(w:indent_guides_matches, matchadd(l:group, l:hard_pattern)) + end + endfor +endfunction + +" +" Disables the indent guides for the current buffer and any other buffer upon +" entering it. +" +function! indent_guides#disable() + let g:indent_guides_autocmds_enabled = 0 + call indent_guides#clear_matches() +endfunction + +" +" Clear all highlight matches for the current window. +" +function! indent_guides#clear_matches() + call indent_guides#init_matches() + if !empty(w:indent_guides_matches) + let l:index = 0 + for l:match_id in w:indent_guides_matches + try + call matchdelete(l:match_id) + catch /E803:/ + " Do nothing + endtry + call remove(w:indent_guides_matches, l:index) + let l:index += l:index + endfor + endif +endfunction + +" +" Automagically calculates and defines the indent highlight colors. +" +function! indent_guides#highlight_colors() + if s:auto_colors + if has('gui_running') || has('nvim') + call indent_guides#gui_highlight_colors() + else + call indent_guides#basic_highlight_colors() + endif + endif +endfunction + +" +" Defines some basic indent highlight colors that work for Terminal Vim and +" gVim when colors can't be automatically calculated. +" +function! indent_guides#basic_highlight_colors() + let l:cterm_colors = (&g:background == 'dark') ? ['darkgrey', 'black'] : ['lightgrey', 'white'] + let l:gui_colors = (&g:background == 'dark') ? ['grey15', 'grey30'] : ['grey70', 'grey85'] + + exe 'hi IndentGuidesEven guibg=' . l:gui_colors[0] . ' guifg=' . l:gui_colors[1] . ' ctermbg=' . l:cterm_colors[0] . ' ctermfg=' . l:cterm_colors[1] + exe 'hi IndentGuidesOdd guibg=' . l:gui_colors[1] . ' guifg=' . l:gui_colors[0] . ' ctermbg=' . l:cterm_colors[1] . ' ctermfg=' . l:cterm_colors[0] +endfunction + +" +" Automagically calculates and defines the indent highlight colors for gui +" vim. +" +function! indent_guides#gui_highlight_colors() + let l:hi_normal_guibg = '' + + " capture the backgroud color from the normal highlight + if s:hi_normal =~ s:color_hex_bg_pat + " hex color code is being used, eg. '#FFFFFF' + let l:hi_normal_guibg = matchstr(s:hi_normal, s:color_hex_bg_pat) + + elseif s:hi_normal =~ s:color_name_bg_pat + " color name is being used, eg. 'white' + let l:color_name = matchstr(s:hi_normal, s:color_name_bg_pat) + let l:hi_normal_guibg = color_helper#color_name_to_hex(l:color_name) + + else + " background color could not be detected, default to basic colors + call indent_guides#basic_highlight_colors() + endif + + if l:hi_normal_guibg =~ s:color_hex_pat + " calculate the highlight background colors + let l:hi_odd_bg = indent_guides#lighten_or_darken_color(l:hi_normal_guibg) + let l:hi_even_bg = indent_guides#lighten_or_darken_color(l:hi_odd_bg) + + " define the new highlights + exe 'hi IndentGuidesOdd guibg=' . l:hi_odd_bg . ' guifg=' . l:hi_even_bg + exe 'hi IndentGuidesEven guibg=' . l:hi_even_bg . ' guifg=' . l:hi_odd_bg + end +endfunction + +" +" Takes a color and darkens or lightens it depending on whether a dark or light +" colorscheme is being used. +" +function! indent_guides#lighten_or_darken_color(color) + let l:new_color = '' + + if (&g:background == 'dark') + let l:new_color = color_helper#hex_color_lighten(a:color, s:change_percent) + else + let l:new_color = color_helper#hex_color_darken (a:color, s:change_percent) + endif + + return l:new_color +endfunction + +" +" Define default highlights. +" +function! indent_guides#define_default_highlights() + hi default clear IndentGuidesOdd + hi default clear IndentGuidesEven +endfunction + +" +" Init the w:indent_guides_matches variable. +" +function! indent_guides#init_matches() + let w:indent_guides_matches = exists('w:indent_guides_matches') ? w:indent_guides_matches : [] +endfunction + +" +" We need to initialize these vars every time a buffer is entered while the +" plugin is enabled. +" +function! indent_guides#init_script_vars() + if &l:shiftwidth > 0 && &l:expandtab + let s:indent_size = &l:shiftwidth + else + let s:indent_size = &l:tabstop + endif + let s:guide_size = indent_guides#calculate_guide_size() + let s:hi_normal = indent_guides#capture_highlight('Normal') + + " remove 'font=' from the s:hi_normal string (only seems to happen on Vim startup in Windows) + let s:hi_normal = substitute(s:hi_normal, ' font=[A-Za-z0-9:]\+', "", "") + + " shortcuts to the global variables - this makes the code easier to read + let s:debug = g:indent_guides_debug + let s:indent_levels = g:indent_guides_indent_levels + let s:auto_colors = g:indent_guides_auto_colors + let s:color_hex_pat = g:indent_guides_color_hex_pattern + let s:color_hex_bg_pat = g:indent_guides_color_hex_guibg_pattern + let s:color_name_bg_pat = g:indent_guides_color_name_guibg_pattern + let s:start_level = g:indent_guides_start_level + + " str2float not available in vim versions <= 7.1 + if has('float') + let s:change_percent = g:indent_guides_color_change_percent / str2float('100.0') + else + let s:change_percent = g:indent_guides_color_change_percent / 100.0 + endif + + if s:debug + echo 's:indent_size = ' . s:indent_size + echo 's:guide_size = ' . s:guide_size + echo 's:hi_normal = ' . s:hi_normal + echo 's:indent_levels = ' . s:indent_levels + echo 's:auto_colors = ' . s:auto_colors + echo 's:change_percent = ' . string(s:change_percent) + echo 's:color_hex_pat = ' . s:color_hex_pat + echo 's:color_hex_bg_pat = ' . s:color_hex_bg_pat + echo 's:color_name_bg_pat = ' . s:color_name_bg_pat + echo 's:start_level = ' . s:start_level + endif +endfunction + +" +" Calculate the indent guide size. Ensures the guide size is less than or +" equal to the actual indent size, otherwise some weird things can occur. +" +" NOTE: Currently, this only works when soft-tabs are being used. +" +function! indent_guides#calculate_guide_size() + let l:guide_size = g:indent_guides_guide_size + + if l:guide_size == 0 || l:guide_size > s:indent_size + let l:guide_size = s:indent_size + endif + + return l:guide_size +endfunction + +" +" Captures and returns the output of highlight group definitions. +" +" Example: indent_guides#capture_highlight('normal') +" Returns: 'Normal xxx guifg=#323232 guibg=#ffffff' +" +function! indent_guides#capture_highlight(group_name) + redir => l:output + exe "silent hi " . a:group_name + redir END + + let l:output = substitute(l:output, "\n", "", "") + return l:output +endfunction + +" +" Returns a regex pattern for highlighting an indent level. +" +" Example: indent_guides#indent_highlight_pattern(' ', 1, 4) +" Returns: /^ *\%1v\zs *\%5v\ze/ +" +" Example: indent_guides#indent_highlight_pattern('\s', 5, 2) +" Returns: /^\s*\%5v\zs\s*\%7v\ze/ +" +" Example: indent_guides#indent_highlight_pattern('\t', 9, 2) +" Returns: /^\t*\%9v\zs\t*\%11v\ze/ +" +function! indent_guides#indent_highlight_pattern(indent_pattern, column_start, indent_size) + let l:pattern = '^' . a:indent_pattern . '*\%' . a:column_start . 'v\zs' + let l:pattern .= a:indent_pattern . '*\%' . (a:column_start + a:indent_size) . 'v' + let l:pattern .= '\ze' + return l:pattern +endfunction + +" +" Detect if any of the buffer filetypes should be excluded. +" +function! indent_guides#exclude_filetype() + for ft in split(&ft, '\.') + if index(g:indent_guides_exclude_filetypes, ft) > -1 + return 1 + end + endfor + return 0 +endfunction diff --git a/sources_non_forked/vim-indent-guides/doc/indent_guides.txt b/sources_non_forked/vim-indent-guides/doc/indent_guides.txt new file mode 100644 index 00000000..d51a3940 --- /dev/null +++ b/sources_non_forked/vim-indent-guides/doc/indent_guides.txt @@ -0,0 +1,351 @@ +*indent_guides.txt* A plugin for visually displaying indent levels in Vim. + + *indent-guides* + ____ __ __ ______ _ __ + / _/____ ____/ /___ ____ / /_ / ____/__ __(_)____/ /___ _____ + / / / __ \/ __ // _ \/ __ \/ __/ / / __ / / / / // __ // _ \/ ___/ + _/ / / / / / /_/ // __/ / / / /_ / /_/ // /_/ / // /_/ // __(__ ) + /___//_/ /_/\__,_/ \___/_/ /_/\__/ \____/ \__,_/_/ \__,_/ \___/____/ + + +Author: Nate Kane +Version: 1.7 +Last Change: 07 Mar 2013 + +============================================================================== +CONTENTS *indent-guides-contents* + + 1. Introduction.......................... |indent-guides-introduction| + 2. Commands.............................. |indent-guides-commands| + 3. Options............................... |indent-guides-options| + 4. Mappings.............................. |indent-guides-mappings| + 5. Terminal Vim.......................... |indent-guides-terminal-vim| + 6. About................................. |indent-guides-about| + 7. Changelog............................. |indent-guides-changelog| + 8. License............................... |indent-guides-license| + +============================================================================== +1. INTRODUCTION *indent-guides-introduction* + +Indent Guides is a plugin for visually displaying indent levels in Vim. + +This plugin should work with gVim out of the box, no configuration needed. + +Features:~ + * Can detect both tab and space indent styles. + * Automatically inspects your colorscheme and picks appropriate colors (gVim + only). + * Will highlight indent levels with alternating colors. + * Full support for gVim and basic support for Terminal Vim. + * Seems to work on Windows gVim 7.3 (haven't done any extensive tests + though). + * Customizable size for indent guides, eg. skinny guides (soft-tabs only). + * Customizable start indent level. + * Highlight support for files with a mixture of tab and space indent styles. + +============================================================================== +2. COMMANDS *indent-guides-commands* + +------------------------------------------------------------------------------ +:IndentGuidesToggle *:IndentGuidesToggle* + Toggles the indent guides on and off. + +------------------------------------------------------------------------------ +:IndentGuidesEnable *:IndentGuidesEnable* + Enables the indent guides for the current buffer and any other buffer upon + entering it. + +------------------------------------------------------------------------------ +:IndentGuidesDisable *:IndentGuidesDisable* + Disables the indent guides for the current buffer and any other buffer upon + entering it. + +============================================================================== +3. OPTIONS *indent-guides-options* + +------------------------------------------------------------------------------ + *'indent_guides_indent_levels'* +Use this option to control how many indent levels to display guides for. + +Default: 30. Values: integer. +> + let g:indent_guides_indent_levels = 30 +< + +------------------------------------------------------------------------------ + *'indent_guides_auto_colors'* +Use this option to control whether or not the plugin automatically calculates +the highlight colors. Will use the current colorscheme's background color as a +base color. + +Default: 1. Values: 0 or 1. +> + let g:indent_guides_auto_colors = 1 +< + +If you set this option to 0, be sure to manually define some highlight colors +in an autocmd. +> + let g:indent_guides_auto_colors = 0 + autocmd VimEnter,Colorscheme * :hi IndentGuidesOdd guibg=red ctermbg=3 + autocmd VimEnter,Colorscheme * :hi IndentGuidesEven guibg=green ctermbg=4 +< + +Alternatively you can add the following lines to your colorscheme file. +> + hi IndentGuidesOdd guibg=red ctermbg=3 + hi IndentGuidesEven guibg=green ctermbg=4 +< + +------------------------------------------------------------------------------ + *'indent_guides_color_change_percent'* +Use this option to control the percent at which the highlight colors will be +lightened or darkened. + +Default: 10 (10%). Values: between 0 and 100. +> + let g:indent_guides_color_change_percent = 10 +< + +------------------------------------------------------------------------------ + *'indent_guides_guide_size'* +Use this option to customize the size of the indent guide. By default the +value is set to 0, which will set the guide size to be the same as the +|shiftwidth|. Setting this value to be larger than the |shiftwidth| is essentially +the same as setting it to 0. + +A common use of this setting is to create skinny indent guides, which look +great with a |shiftwidth| of 4 or more. + +NOTE: This option only works for soft-tabs (spaces) and not hard-tabs. + +Default: 0. Values: between 0 and |shiftwidth|. +> + let g:indent_guides_guide_size = 1 +< + +------------------------------------------------------------------------------ + *'indent_guides_start_level'* +Use this option to control which indent level to start showing guides from. + +Default: 1. Values: between 1 and g:|indent_guides_indent_levels|. +> + let g:indent_guides_start_level = 2 +< + +------------------------------------------------------------------------------ + *'indent_guides_space_guides'* +Use this option to control whether the plugin considers spaces as indention. + +Default: 1. Values: 0 or 1. +> + let g:indent_guides_space_guides = 0 +< + +------------------------------------------------------------------------------ + *'indent_guides_tab_guides'* +Use this option to control whether the plugin considers tabs as indention. + +Default: 1. Values: 0 or 1. +> + let g:indent_guides_tab_guides = 0 +< + +------------------------------------------------------------------------------ + *'indent_guides_soft_pattern'* +Use this option to explicitly specify a pattern for soft indentation. For +example to match spaces only in the beginning of line use ' ' pattern. + +Default: '\s'. Values: Vim regexp. +> + let g:indent_guides_soft_pattern = ' ' +< + +------------------------------------------------------------------------------ + *'indent_guides_enable_on_vim_startup'* +Use this option to control whether the plugin is enabled on Vim startup. + +Default: 0. Values: 0 or 1. +> + let g:indent_guides_enable_on_vim_startup = 0 +< + +------------------------------------------------------------------------------ + *'indent_guides_exclude_filetypes'* +Use this option to specify a list of filetypes to disable the plugin for. + +Default: ['help']. Values: list of strings. +> + let g:indent_guides_exclude_filetypes = ['help', 'nerdtree'] +< + +------------------------------------------------------------------------------ + *'indent_guides_default_mapping'* +Use this option to control whether the default mapping (ig) gets set. + +Default: 1. Values: 0 or 1. +> + let g:indent_guides_default_mapping = 0 +< + +============================================================================== +4. MAPPINGS *indent-guides-mappings* + +The default mapping for toggling indent guides is ig. You can easily +map it to other keys. For example: +> + :nmap ig IndentGuidesToggle +< + +You can also map some other commands that are not mapped by default. For +example: +> + :nmap ie IndentGuidesEnable + :nmap id IndentGuidesDisable +< + +============================================================================== +5. TERMINAL VIM *indent-guides-terminal-vim* + +At the moment Terminal Vim only has basic support. This means is that colors +won't be automatically calculated based on your colorscheme. Instead, some +preset colors are used depending on whether `background` is set to `dark` or +`light`. + +When `set background=dark` is used, the following highlight colors will be +defined: +> + hi IndentGuidesOdd ctermbg=black + hi IndentGuidesEven ctermbg=darkgrey +< + +Alternatively, when `set background=light` is used, the following highlight +colors will be defined: +> + hi IndentGuidesOdd ctermbg=white + hi IndentGuidesEven ctermbg=lightgrey +< + +If for some reason it's incorrectly defining light highlight colors instead of +dark ones or vice versa, the first thing you should check is that the +`background` value is being set correctly for your colorscheme. Sometimes it's +best to manually set the `background` value in your `.vimrc`, for example: +> + colorscheme desert256 + set background=dark +< + +Alternatively you can manually setup the highlight colors yourself, see +|indent_guides_auto_colors| for an example. + +============================================================================== +6. ABOUT *indent-guides-about* + +Why did I build this plugin?~ + * I believe indent guides make nested code easier to read and understand. + * Other editors have them and it's high time Vim did. + * None of the existing indent guide plugins on the market suited my needs. + * I wanted to learn me some VimL. + +Links:~ + * Github: https://github.com/nathanaelkane/vim-indent-guides + * Bugs & Issues: https://github.com/nathanaelkane/vim-indent-guides/issues + +Credits:~ + * Matt Wozniski (godlygeek) for letting me use the list of color names and + hex codes from his CSApprox plugin. + +Contact:~ + * Twitter: @nathanaelkane + * Email: + +Bug reports, feedback, suggestions etc are welcomed. + +============================================================================== +7. CHANGELOG *indent-guides-changelog* + +1.8 (pending release)~ + * Added option g:|indent_guides_soft_pattern| to control the pattern for + soft indentation (thanks @sergey-vlasov). + * Added option g:|indent_guides_default_mapping| to control whether the + default mapping (ig) gets set (thanks @suy). + * Set size of indent guide to `tabstop` value when `shiftwidth=0` or + `noexpandtab` is used (thanks @darkfeline and @wilywampa). + * Don't load plugin in unsupported versions of Vim (thanks @dersaidin). + * Added option g:|indent_guides_tab_guides| to control whether tabs are + considered as indention (thanks @amerlyq). + +1.7~ + * Added way to override the default mapping (thanks @xuhdev). + * Added option g:|indent_guides_exclude_filetypes| to specify a list of + filetypes to disable the plugin for. + * Disable the plugin when in a diff. + * Various bug fixes. + +1.6~ + * Added option g:|indent_guides_space_guides| to control whether spaces are + considered as indention (thanks @scoz). + * Added 'doc/tags' to gitignore (thanks @lenniboy). + * Fixed E803 ID not found spam (thanks @mutewinter). + * Fixed str2float issue with Vim 7.1 (thanks @acx0). + +1.5~ + * Added highlight support for files with a mixture of tab and space indent + styles (thanks @graywh). + * Added -bar to all the :commands so they can chain with other :commands + (thanks @graywh). + * No longer overriding pre-defined custom highlight colors (thanks @graywh). + * Using str2float to work around a float bug in some versions of Vim 7.2 + (thanks @voidus). + +1.4~ + * Added the new plugin option g:|indent_guides_enable_on_vim_startup|. + * Improved Windows support. + +1.3~ + * Changed the default value of g:|indent_guides_color_change_percent| to 10. + * Added support for gVim themes that don't specify a `hi Normal guibg` + color. + +1.2~ + * Customizable size for indent guides, eg. skinny guides (soft-tabs only). + * Customizable start indent level. + * Refactored some internal logic. + +1.1~ + * Added basic support for Terminal Vim. See |indent-guides-terminal-vim| for + more information. + * Cut down on rgb to hex color conversions by adding a big dictionary of + color names and hex codes. + * Various bug fixes. + +1.0~ + * First public version. + +============================================================================== +8. LICENSE *indent-guides-license* + +The MIT Licence +http://www.opensource.org/licenses/mit-license.php + +Copyright (c) 2010-2013 Nate Kane + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + +vim:tw=78:ts=2:ft=help:norl: diff --git a/sources_non_forked/vim-indent-guides/plugin/indent_guides.vim b/sources_non_forked/vim-indent-guides/plugin/indent_guides.vim new file mode 100644 index 00000000..c94079be --- /dev/null +++ b/sources_non_forked/vim-indent-guides/plugin/indent_guides.vim @@ -0,0 +1,92 @@ +" Author: Nate Kane +" Homepage: http://github.com/nathanaelkane/vim-indent-guides + +" Do not load if vim is too old +if (v:version == 701 && !exists('*matchadd')) || (v:version < 701) + finish +endif + +if exists('g:loaded_indent_guides') || &cp + finish +endif +let g:loaded_indent_guides = 1 +call indent_guides#define_default_highlights() + +function! s:IndentGuidesToggle() + call indent_guides#toggle() +endfunction + +function! s:IndentGuidesEnable() + call indent_guides#enable() +endfunction + +function! s:IndentGuidesDisable() + call indent_guides#disable() +endfunction + +" Commands +command! -bar IndentGuidesToggle call s:IndentGuidesToggle() +command! -bar IndentGuidesEnable call s:IndentGuidesEnable() +command! -bar IndentGuidesDisable call s:IndentGuidesDisable() + +" +" Initializes a given variable to a given value. The variable is only +" initialized if it does not exist prior. +" +function s:InitVariable(var, value) + if !exists(a:var) + if type(a:value) == type("") + exec 'let ' . a:var . ' = ' . "'" . a:value . "'" + else + exec 'let ' . a:var . ' = ' . a:value + endif + endif +endfunction + +" Fixed global variables +let g:indent_guides_autocmds_enabled = 0 +let g:indent_guides_color_hex_pattern = '#[0-9A-Fa-f]\{6\}' +let g:indent_guides_color_hex_guibg_pattern = 'guibg=\zs' . g:indent_guides_color_hex_pattern . '\ze' +let g:indent_guides_color_name_guibg_pattern = "guibg='\\?\\zs[0-9A-Za-z ]\\+\\ze'\\?" + +" Configurable global variables +call s:InitVariable('g:indent_guides_indent_levels', 30) +call s:InitVariable('g:indent_guides_auto_colors', 1) +call s:InitVariable('g:indent_guides_color_change_percent', 10) " ie. 10% +call s:InitVariable('g:indent_guides_guide_size', 0) +call s:InitVariable('g:indent_guides_start_level', 1) +call s:InitVariable('g:indent_guides_enable_on_vim_startup', 0) +call s:InitVariable('g:indent_guides_debug', 0) +call s:InitVariable('g:indent_guides_space_guides', 1) +call s:InitVariable('g:indent_guides_tab_guides', 1) +call s:InitVariable('g:indent_guides_soft_pattern', '\s') +call s:InitVariable('g:indent_guides_default_mapping', 1) + +if !exists('g:indent_guides_exclude_filetypes') + let g:indent_guides_exclude_filetypes = ['help'] +endif + +" Default mapping +if !hasmapto('IndentGuidesToggle', 'n') && maparg('ig', 'n') == '' + \ && g:indent_guides_default_mapping != 0 + nmap ig IndentGuidesToggle +endif + +" Plug mappings +nnoremap