From c6ba5aa440f61186139303af701bd8ae1a4e745e Mon Sep 17 00:00:00 2001 From: Amir Date: Tue, 20 Sep 2022 10:08:17 +0200 Subject: [PATCH 1/3] Updated plugins --- .../ale/ale_linters/bicep/bicep.vim | 63 ++++++++ .../ale/ale_linters/yaml/gitlablint.vim | 49 ++++++ .../ale/autoload/ale/fixers/syntax_tree.vim | 19 +++ sources_non_forked/ale/doc/ale-bicep.txt | 24 +++ .../vim-snippets/UltiSnips/smarty.snippets | 28 ++++ .../vim-snippets/snippets/all.snippets | 1 + .../vim-snippets/snippets/bash.snippets | 25 ++++ .../vim-snippets/snippets/smarty.snippets | 139 ++++++++++++++++++ 8 files changed, 348 insertions(+) create mode 100644 sources_non_forked/ale/ale_linters/bicep/bicep.vim create mode 100644 sources_non_forked/ale/ale_linters/yaml/gitlablint.vim create mode 100644 sources_non_forked/ale/autoload/ale/fixers/syntax_tree.vim create mode 100644 sources_non_forked/ale/doc/ale-bicep.txt create mode 100644 sources_non_forked/vim-snippets/UltiSnips/smarty.snippets create mode 100644 sources_non_forked/vim-snippets/snippets/all.snippets create mode 100644 sources_non_forked/vim-snippets/snippets/bash.snippets create mode 100644 sources_non_forked/vim-snippets/snippets/smarty.snippets diff --git a/sources_non_forked/ale/ale_linters/bicep/bicep.vim b/sources_non_forked/ale/ale_linters/bicep/bicep.vim new file mode 100644 index 00000000..5796f83e --- /dev/null +++ b/sources_non_forked/ale/ale_linters/bicep/bicep.vim @@ -0,0 +1,63 @@ +" Author: Carl Smedstad +" Description: bicep for bicep files + +let g:ale_bicep_bicep_executable = +\ get(g:, 'ale_bicep_bicep_executable', 'bicep') + +let g:ale_bicep_bicep_options = +\ get(g:, 'ale_bicep_bicep_options', '') + +function! ale_linters#bicep#bicep#Executable(buffer) abort + return ale#Var(a:buffer, 'bicep_bicep_executable') +endfunction + +function! ale_linters#bicep#bicep#Command(buffer) abort + let l:executable = ale_linters#bicep#bicep#Executable(a:buffer) + let l:options = ale#Var(a:buffer, 'bicep_bicep_options') + + if has('win32') + let l:nullfile = 'NUL' + else + let l:nullfile = '/dev/null' + endif + + return ale#Escape(l:executable) + \ . ' build --outfile ' + \ . l:nullfile + \ . ' ' + \ . l:options + \ . ' %t' +endfunction + +function! ale_linters#bicep#bicep#Handle(buffer, lines) abort + let l:pattern = '\v^.*\((\d+),(\d+)\)\s:\s([a-zA-Z]*)\s([-a-zA-Z0-9]*):\s(.*)' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + if l:match[3] is# 'Error' + let l:type = 'E' + elseif l:match[3] is# 'Warning' + let l:type = 'W' + else + let l:type = 'I' + endif + + call add(l:output, { + \ 'lnum': l:match[1] + 0, + \ 'col': l:match[2] + 0, + \ 'type': l:type, + \ 'code': l:match[4], + \ 'text': l:match[5], + \}) + endfor + + return l:output +endfunction + +call ale#linter#Define('bicep', { +\ 'name': 'bicep', +\ 'executable': function('ale_linters#bicep#bicep#Executable'), +\ 'command': function('ale_linters#bicep#bicep#Command'), +\ 'callback': 'ale_linters#bicep#bicep#Handle', +\ 'output_stream': 'both', +\}) diff --git a/sources_non_forked/ale/ale_linters/yaml/gitlablint.vim b/sources_non_forked/ale/ale_linters/yaml/gitlablint.vim new file mode 100644 index 00000000..ec48115a --- /dev/null +++ b/sources_non_forked/ale/ale_linters/yaml/gitlablint.vim @@ -0,0 +1,49 @@ +call ale#Set('yaml_gitlablint_executable', 'gll') +call ale#Set('yaml_gitlablint_options', '') + +function! ale_linters#yaml#gitlablint#GetCommand(buffer) abort + return '%e' . ale#Pad(ale#Var(a:buffer, 'yaml_gitlablint_options')) + \ . ' -p %t' +endfunction + +function! ale_linters#yaml#gitlablint#Handle(buffer, lines) abort + " Matches patterns line the following: + " (): mapping values are not allowed in this context at line 68 column 8 + " jobs:build:dev config contains unknown keys: ony + let l:pattern = '^\(.*\) at line \(\d\+\) column \(\d\+\)$' + let l:output = [] + + for l:line in a:lines + let l:match = matchlist(l:line, l:pattern) + + if !empty(l:match) + let l:item = { + \ 'lnum': l:match[2] + 0, + \ 'col': l:match[3] + 0, + \ 'text': l:match[1], + \ 'type': 'E', + \} + call add(l:output, l:item) + else + if l:line isnot# 'GitLab CI configuration is invalid' + let l:item = { + \ 'lnum': 0, + \ 'col': 0, + \ 'text': l:line, + \ 'type': 'E', + \} + call add(l:output, l:item) + endif + endif + endfor + + return l:output +endfunction + +call ale#linter#Define('yaml', { +\ 'name': 'gitlablint', +\ 'executable': {b -> ale#Var(b, 'yaml_gitlablint_executable')}, +\ 'command': function('ale_linters#yaml#gitlablint#GetCommand'), +\ 'callback': 'ale_linters#yaml#gitlablint#Handle', +\ 'output_stream': 'stderr', +\}) diff --git a/sources_non_forked/ale/autoload/ale/fixers/syntax_tree.vim b/sources_non_forked/ale/autoload/ale/fixers/syntax_tree.vim new file mode 100644 index 00000000..7ae03373 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/syntax_tree.vim @@ -0,0 +1,19 @@ +call ale#Set('ruby_syntax_tree_options', '') +call ale#Set('ruby_syntax_tree_executable', 'stree') + +function! ale#fixers#syntax_tree#GetCommand(buffer) abort + let l:executable = ale#Var(a:buffer, 'ruby_syntax_tree_executable') + let l:options = ale#Var(a:buffer, 'ruby_syntax_tree_options') + + return ale#ruby#EscapeExecutable(l:executable, 'stree') + \ . ' write' + \ . (!empty(l:options) ? ' ' . l:options : '') + \ . ' %t' +endfunction + +function! ale#fixers#syntax_tree#Fix(buffer) abort + return { + \ 'command': ale#fixers#syntax_tree#GetCommand(a:buffer), + \ 'read_temporary_file': 1, + \} +endfunction diff --git a/sources_non_forked/ale/doc/ale-bicep.txt b/sources_non_forked/ale/doc/ale-bicep.txt new file mode 100644 index 00000000..d26d67bc --- /dev/null +++ b/sources_non_forked/ale/doc/ale-bicep.txt @@ -0,0 +1,24 @@ +=============================================================================== +ALE Bicep Integration *ale-bicep-options* + + +=============================================================================== +bicep *ale-bicep-bicep* + +g:ale_bicep_bicep_executable *g:ale_bicep_bicep_executable* + *b:ale_bicep_bicep_executable* + Type: |String| + Default: `'bicep'` + + This variable can be set to change the path to bicep. + + +g:ale_bicep_bicep_options *g:ale_bicep_bicep_options* + *b:ale_bicep_bicep_options* + Type: |String| + Default: `'build --outfile /dev/null'` + + This variable can be set to pass additional options to bicep. + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/vim-snippets/UltiSnips/smarty.snippets b/sources_non_forked/vim-snippets/UltiSnips/smarty.snippets new file mode 100644 index 00000000..09677d6f --- /dev/null +++ b/sources_non_forked/vim-snippets/UltiSnips/smarty.snippets @@ -0,0 +1,28 @@ +# snippets for smarty3 + +extends html +extends javascript +extends css + + + + +# https://www.smarty.net/docs/en/language.function.append.tpl +snippet append "{append} is used for creating or appending template variable arrays during the execution of a template." +{append var='${1}' value='${2}'${3: index='${4|first,last|}'}${5: scope='${6|parent,root,global|}'}} +endsnippet + +# https://www.smarty.net/docs/en/language.function.assign.tpl +snippet assign "{assign} is used for assigning template variables during the execution of a template." +{assign var='${1}' value='${2}'${3: scope='${4|parent,root,global|}'}} +endsnippet + +# https://www.smarty.net/docs/en/language.function.config.load.tpl +snippet config_load "config_load" +{config_load file='${1}'${2: section='${3}'}${4: scope='${5|local,parent,global|}'}} +endsnippet + +# https://www.smarty.net/docs/en/language.function.include.tpl +snippet include "{include} tags are used for including other templates in the current template. Any variables available in the current template are also available within the included template." +{include file='${1}'${2: assign='${3}'}${4: cache_lifetime=${5}}${6: compile_id='${7}'}${8: cache_id='${9}'}${10: scope='${11|parent,root,global|}'}${12: variables}} +endsnippet diff --git a/sources_non_forked/vim-snippets/snippets/all.snippets b/sources_non_forked/vim-snippets/snippets/all.snippets new file mode 100644 index 00000000..2f276528 --- /dev/null +++ b/sources_non_forked/vim-snippets/snippets/all.snippets @@ -0,0 +1 @@ +extends _ diff --git a/sources_non_forked/vim-snippets/snippets/bash.snippets b/sources_non_forked/vim-snippets/snippets/bash.snippets new file mode 100644 index 00000000..65b07072 --- /dev/null +++ b/sources_non_forked/vim-snippets/snippets/bash.snippets @@ -0,0 +1,25 @@ +extends sh + +# Shebang +snippet #! + #!/usr/bin/env bash + +snippet s#! + #!/usr/bin/env bash + set -eu + +snippet if + if [[ $1 ]]; then + ${0:${VISUAL}} + fi +snippet elif + elif [[ $1 ]]; then + ${0:${VISUAL}} +snippet wh + while [[ $1 ]]; do + ${0:${VISUAL}} + done +snippet until + until [[ $1 ]]; do + ${0:${VISUAL}} + done diff --git a/sources_non_forked/vim-snippets/snippets/smarty.snippets b/sources_non_forked/vim-snippets/snippets/smarty.snippets new file mode 100644 index 00000000..070fcd7e --- /dev/null +++ b/sources_non_forked/vim-snippets/snippets/smarty.snippets @@ -0,0 +1,139 @@ +# snippets for smarty3 + +extends html +extends javascript +extends css + +# https://www.smarty.net/docs/en/language.function.if.tpl +snippet if "{if cond} ... {/if}" + {if ${1}} + ${0:${VISUAL}} + {/if} + +snippet ifn "{if !cond} ... {/if}" + {if ${1}} + ${0:${VISUAL}} + {/if} + +snippet ife "{if cond} ... {else} ... {/if}" + {if ${1}} + ${0:${VISUAL}} + {else} + ${2} + {/if} + +snippet eif "{elseif cond} ... {/if}" + {elseif ${1}} + ${0:${VISUAL}} + {/if} + +snippet el "{else} ... {/if}" + {else} + ${1} + {/if} + +# https://www.smarty.net/docs/en/language.function.for.tpl +snippet for "The {for} tag is used to create simple loops." + {for $${1:var}=${2:start} to ${3:end}${4: step ${5}}${6: max=${7}}} + ${0:${VISUAL}} + {/for} + +snippet forelse "The {for}{forelse} tag is used to create simple loops." + {for $${1:var}=${2:start} to ${3:end}${4: step ${5}}${6: max=${7}}} + ${0:${VISUAL}} + {forelse} + ${8} + {/for} + +# https://www.smarty.net/docs/en/language.function.foreach.tpl +snippet foreach "{foreach} is used for looping over arrays of data." + {foreach $${1:array_variable} as $${2:var_or_key}${3: => $${4:itemvar}}} + ${0:${VISUAL}} + {/foreach} + +snippet foreach2 "[Smarty2] {foreach} is used for looping over arrays of data." + {foreach from=$${1:collection} item='${2}'${3: key='${4}'}${5: name='${6}'}} + ${0:${VISUAL}} + {/foreach} + +snippet foreachelse "{foreach} is used for looping over arrays of data." + {foreach $${1:array_variable} as $${2:var_or_key}${3: => $${4:itemvar}}} + ${0:${VISUAL}} + {foreachelse} + ${5} + {/foreach} + +snippet wh "{while} loops in Smarty have much the same flexibility as PHP while statements, with a few added features for the template engine. Every {while} must be paired with a matching {/while}. All PHP conditionals and functions are recognized, such as ||, or, &&, and, is_array(), etc." + {while ${1}} + ${0:${VISUAL}} + {/while} + + + +# https://www.smarty.net/docs/en/language.function.append.tpl +#snippet append implemented in UltiSnips format + +# https://www.smarty.net/docs/en/language.function.assign.tpl +#snippet assign implemented in UltiSnips format + +# https://www.smarty.net/docs/en/language.function.block.tpl +snippet block "{block} is used to define a named area of template source for template inheritance." + {block name='${1}'} + ${0:${VISUAL}} + {/block} + +# https://www.smarty.net/docs/en/language.function.call.tpl +snippet call "{call} is used to call a template function defined by the {function} tag just like a plugin function." + {call name=${1}${2: assign=${3}}${4: variables}} + +# https://www.smarty.net/docs/en/language.function.capture.tpl +snippet capture "{capture} is used to collect the output of the template between the tags into a variable instead of displaying it. Any content between {capture name='foo'} and {/capture} is collected into the variable specified in the name attribute. " + {capture name='${1}'${2: assign='${3}' }${4: append='${5:array_variable}'}} + ${0:${VISUAL}} + {/capture} + +# https://www.smarty.net/docs/en/language.function.config.load.tpl +#snippet config_load implemented in UltiSnips format + +# https://www.smarty.net/docs/en/language.function.extends.tpl +snippet extends "{extends} tags are used in child templates in template inheritance for extending parent templates." + {extends file='${1}'} + +# https://www.smarty.net/docs/en/language.function.function.tpl +snippet function "{function} is used to create functions within a template and call them just like a plugin function. Instead of writing a plugin that generates presentational content, keeping it in the template is often a more manageable choice. It also simplifies data traversal, such as deeply nested menus." + {function name='${1}' ${2:variables}} + ${0:${VISUAL}} + {/function} + +# https://www.smarty.net/docs/en/language.function.include.tpl +#snippet include implemented in UltiSnips format + +# https://www.smarty.net/docs/en/language.function.literal.tpl +snippet literal "{literal} tags allow a block of data to be taken literally. This is typically used around Javascript or stylesheet blocks where {curly braces} would interfere with the template delimiter syntax" + {literal} + ${0:${VISUAL}} + {/literal} + +# https://www.smarty.net/docs/en/language.function.nocache.tpl +snippet nocache "{nocache} is used to disable caching of a template section. Every {nocache} must be paired with a matching {/nocache}." + {nocache} + ${0:${VISUAL}} + {/nocache} + +# https://www.smarty.net/docs/en/language.function.section.tpl +snippet section "A {section} is for looping over sequentially indexed arrays of data, unlike {foreach} which is used to loop over a single associative array. Every {section} tag must be paired with a closing {/section} tag." + {section name='${1}'${2: loop='${3}'}${4: start=${5}}${6: step=${7}}${8: max=${9}}${10: show=${11}}} + ${0:${VISUAL}} + {/section} + +# https://www.smarty.net/docs/en/language.function.setfilter.tpl +snippet setfilter "The {setfilter}...{/setfilter} block tag allows the definition of template instance's variable filters." + {setfilter ${1:filters}} + ${0:${VISUAL}} + {/setfilter} + +# https://www.smarty.net/docs/en/language.function.strip.tpl +snippet strip "Anything within {strip}{/strip} tags are stripped of the extra spaces or carriage returns at the beginnings and ends of the lines before they are displayed. This way you can keep your templates readable, and not worry about extra white space causing problems." + {strip} + ${0:${VISUAL}} + {/strip} From 3978f7b4674c3af4db49d5eb91f1b7322988a38c Mon Sep 17 00:00:00 2001 From: Amir Date: Tue, 20 Sep 2022 10:08:31 +0200 Subject: [PATCH 2/3] Forgot to check in the rest of the updated plugins :/ --- .../ale/ale_linters/proto/buf_lint.vim | 5 +- .../ale/ale_linters/vue/volar.vim | 4 +- .../ale/autoload/ale/completion.vim | 2 +- .../ale/autoload/ale/engine.vim | 6 +- .../ale/autoload/ale/events.vim | 2 +- .../ale/autoload/ale/fix/registry.vim | 5 + .../ale/autoload/ale/floating_preview.vim | 45 +++++-- .../ale/autoload/ale/handlers/deno.vim | 2 + sources_non_forked/ale/autoload/ale/hover.vim | 4 + .../ale/autoload/ale/lsp_linter.vim | 8 +- .../ale/autoload/ale/toggle.vim | 4 +- .../ale/autoload/ale/virtualtext.vim | 114 ++++++++++++------ sources_non_forked/ale/doc/ale-ruby.txt | 20 +++ .../doc/ale-supported-languages-and-tools.txt | 4 + sources_non_forked/ale/doc/ale-vue.txt | 2 +- sources_non_forked/ale/doc/ale-yaml.txt | 47 ++++++++ sources_non_forked/ale/doc/ale.txt | 30 +++++ sources_non_forked/ale/plugin/ale.vim | 2 +- sources_non_forked/ale/supported-tools.md | 4 + .../vim-flake8/ftplugin/python_flake8.vim | 2 + .../vim-fugitive/autoload/fugitive.vim | 27 +++-- .../vim-fugitive/plugin/fugitive.vim | 3 + .../autoload/gitgutter/async.vim | 6 +- .../vim-gitgutter/plugin/gitgutter.vim | 10 +- .../vim-javascript/extras/jsdoc.vim | 3 +- .../vim-javascript/syntax/javascript.vim | 2 +- .../vim-markdown/CONTRIBUTING.md | 2 +- sources_non_forked/vim-ruby/syntax/ruby.vim | 10 +- sources_non_forked/vim-snippets/README.md | 9 ++ .../vim-snippets/UltiSnips/cpp.snippets | 13 ++ .../vim-snippets/UltiSnips/lua.snippets | 4 +- .../vim-snippets/UltiSnips/tex.snippets | 21 ---- .../snippets/actionscript.snippets | 7 +- .../vim-snippets/snippets/arduino.snippets | 10 +- .../vim-snippets/snippets/autoit.snippets | 12 +- .../vim-snippets/snippets/c.snippets | 28 +++-- .../vim-snippets/snippets/clojure.snippets | 4 +- .../snippets/codeigniter.snippets | 2 +- .../snippets/coffee/coffee.snippets | 36 +++--- .../vim-snippets/snippets/cpp.snippets | 8 ++ .../vim-snippets/snippets/crystal.snippets | 12 +- .../vim-snippets/snippets/dart.snippets | 6 +- .../vim-snippets/snippets/elixir.snippets | 12 +- .../vim-snippets/snippets/erlang.snippets | 12 +- .../vim-snippets/snippets/falcon.snippets | 6 +- .../vim-snippets/snippets/fortran.snippets | 4 +- .../vim-snippets/snippets/go.snippets | 4 +- .../vim-snippets/snippets/haml.snippets | 4 +- .../vim-snippets/snippets/html.snippets | 5 +- .../snippets/htmltornado.snippets | 6 +- .../vim-snippets/snippets/java.snippets | 8 +- .../snippets/javascript/javascript.snippets | 12 +- .../vim-snippets/snippets/liquid.snippets | 24 ++-- .../vim-snippets/snippets/lpc.snippets | 8 +- .../vim-snippets/snippets/ls.snippets | 10 +- .../vim-snippets/snippets/lua.snippets | 50 ++++++-- .../vim-snippets/snippets/mako.snippets | 4 +- .../vim-snippets/snippets/markdown.snippets | 24 +++- .../vim-snippets/snippets/pandoc.snippets | 1 - .../vim-snippets/snippets/perl.snippets | 10 +- .../vim-snippets/snippets/perl6.snippets | 8 +- .../vim-snippets/snippets/php.snippets | 4 +- .../vim-snippets/snippets/plsql.snippets | 6 +- .../vim-snippets/snippets/processing.snippets | 2 +- .../vim-snippets/snippets/ps1.snippets | 12 +- .../vim-snippets/snippets/python.snippets | 21 +++- .../vim-snippets/snippets/r.snippets | 12 +- .../vim-snippets/snippets/rmd.snippets | 64 +--------- .../vim-snippets/snippets/rst.snippets | 2 +- .../vim-snippets/snippets/ruby.snippets | 26 ++-- .../vim-snippets/snippets/rust.snippets | 2 +- .../vim-snippets/snippets/sass.snippets | 6 +- .../vim-snippets/snippets/scss.snippets | 6 +- .../vim-snippets/snippets/sh.snippets | 22 ++-- .../vim-snippets/snippets/tex.snippets | 21 ++++ .../vim-snippets/snippets/yii.snippets | 22 ++-- .../vim-snippets/snippets/zsh.snippets | 14 ++- 77 files changed, 630 insertions(+), 371 deletions(-) diff --git a/sources_non_forked/ale/ale_linters/proto/buf_lint.vim b/sources_non_forked/ale/ale_linters/proto/buf_lint.vim index e68494a7..a22f8e53 100644 --- a/sources_non_forked/ale/ale_linters/proto/buf_lint.vim +++ b/sources_non_forked/ale/ale_linters/proto/buf_lint.vim @@ -3,12 +3,15 @@ call ale#Set('proto_buf_lint_executable', 'buf') call ale#Set('proto_buf_lint_config', '') +call ale#Set('proto_buf_lint_options', '') function! ale_linters#proto#buf_lint#GetCommand(buffer) abort let l:config = ale#Var(a:buffer, 'proto_buf_lint_config') + let l:options = ale#Var(a:buffer, 'proto_buf_lint_options') return '%e lint' \ . (!empty(l:config) ? ' --config=' . ale#Escape(l:config) : '') + \ . (!empty(l:options) ? ' ' . l:options : '') \ . ' %s#include_package_files=true' endfunction @@ -19,5 +22,5 @@ call ale#linter#Define('proto', { \ 'output_stream': 'stdout', \ 'executable': {b -> ale#Var(b, 'proto_buf_lint_executable')}, \ 'command': function('ale_linters#proto#buf_lint#GetCommand'), -\ 'callback': 'ale#handlers#unix#HandleAsError', +\ 'callback': 'ale#handlers#go#Handler', \}) diff --git a/sources_non_forked/ale/ale_linters/vue/volar.vim b/sources_non_forked/ale/ale_linters/vue/volar.vim index 360b1aa5..bb41b883 100644 --- a/sources_non_forked/ale/ale_linters/vue/volar.vim +++ b/sources_non_forked/ale/ale_linters/vue/volar.vim @@ -2,7 +2,7 @@ " Description: Volar Language Server integration for ALE adopted from " nvim-lspconfig and volar/packages/shared/src/types.ts -call ale#Set('vue_volar_executable', 'volar-server') +call ale#Set('vue_volar_executable', 'vue-language-server') call ale#Set('vue_volar_use_global', get(g:, 'ale_use_global_executables', 0)) call ale#Set('vue_volar_init_options', { \ 'documentFeatures': { @@ -73,7 +73,7 @@ call ale#linter#Define('vue', { \ 'name': 'volar', \ 'language': 'vue', \ 'lsp': 'stdio', -\ 'executable': {b -> ale#path#FindExecutable(b, 'vue_volar', ['node_modules/.bin/volar-server'])}, +\ 'executable': {b -> ale#path#FindExecutable(b, 'vue_volar', ['node_modules/.bin/vue-language-server'])}, \ 'command': '%e --stdio', \ 'project_root': function('ale_linters#vue#volar#GetProjectRoot'), \ 'initialization_options': function('ale_linters#vue#volar#GetInitializationOptions'), diff --git a/sources_non_forked/ale/autoload/ale/completion.vim b/sources_non_forked/ale/autoload/ale/completion.vim index 3d649732..920c03cc 100644 --- a/sources_non_forked/ale/autoload/ale/completion.vim +++ b/sources_non_forked/ale/autoload/ale/completion.vim @@ -139,7 +139,7 @@ let s:should_complete_map = { " Regular expressions for finding the start column to replace with completion. let s:omni_start_map = { \ '': '\v[a-zA-Z$_][a-zA-Z$_0-9]*$', -\ 'racket': '\k\+', +\ 'racket': '\k\+$', \} " A map of exact characters for triggering LSP completions. Do not forget to diff --git a/sources_non_forked/ale/autoload/ale/engine.vim b/sources_non_forked/ale/autoload/ale/engine.vim index 00789a2d..97c46656 100644 --- a/sources_non_forked/ale/autoload/ale/engine.vim +++ b/sources_non_forked/ale/autoload/ale/engine.vim @@ -203,6 +203,10 @@ function! ale#engine#SetResults(buffer, loclist) abort call ale#highlight#SetHighlights(a:buffer, a:loclist) endif + if g:ale_virtualtext_cursor == 2 + call ale#virtualtext#SetTexts(a:buffer, a:loclist) + endif + if l:linting_is_done if g:ale_echo_cursor " Try and echo the warning now. @@ -210,7 +214,7 @@ function! ale#engine#SetResults(buffer, loclist) abort call ale#cursor#EchoCursorWarning() endif - if g:ale_virtualtext_cursor + if g:ale_virtualtext_cursor == 1 " Try and show the warning now. " This will only do something meaningful if we're in normal mode. call ale#virtualtext#ShowCursorWarning() diff --git a/sources_non_forked/ale/autoload/ale/events.vim b/sources_non_forked/ale/autoload/ale/events.vim index b8350c79..4efb8a3b 100644 --- a/sources_non_forked/ale/autoload/ale/events.vim +++ b/sources_non_forked/ale/autoload/ale/events.vim @@ -139,7 +139,7 @@ function! ale#events#Init() abort autocmd InsertLeave * if exists('*ale#engine#Cleanup') | call ale#cursor#EchoCursorWarning() | endif endif - if g:ale_virtualtext_cursor + if g:ale_virtualtext_cursor == 1 autocmd CursorMoved,CursorHold * if exists('*ale#engine#Cleanup') | call ale#virtualtext#ShowCursorWarningWithDelay() | endif " Look for a warning to echo as soon as we leave Insert mode. " The script's position variable used when moving the cursor will diff --git a/sources_non_forked/ale/autoload/ale/fix/registry.vim b/sources_non_forked/ale/autoload/ale/fix/registry.vim index 85fef81d..9281ec61 100644 --- a/sources_non_forked/ale/autoload/ale/fix/registry.vim +++ b/sources_non_forked/ale/autoload/ale/fix/registry.vim @@ -221,6 +221,11 @@ let s:default_registry = { \ 'suggested_filetypes': ['swift'], \ 'description': 'Apply SwiftFormat to a file.', \ }, +\ 'syntax_tree': { +\ 'function': 'ale#fixers#syntax_tree#Fix', +\ 'suggested_filetypes': ['ruby'], +\ 'description': 'Fix ruby files with stree write', +\ }, \ 'apple-swift-format': { \ 'function': 'ale#fixers#appleswiftformat#Fix', \ 'suggested_filetypes': ['swift'], diff --git a/sources_non_forked/ale/autoload/ale/floating_preview.vim b/sources_non_forked/ale/autoload/ale/floating_preview.vim index 1063a2db..b6deec4c 100644 --- a/sources_non_forked/ale/autoload/ale/floating_preview.vim +++ b/sources_non_forked/ale/autoload/ale/floating_preview.vim @@ -1,6 +1,7 @@ " Author: Jan-Grimo Sobez " Author: Kevin Clark " Author: D. Ben Knoble +" Author: Shaun Duncan " Description: Floating preview window for showing whatever information in. " Precondition: exists('*nvim_open_win') || has('popupwin') @@ -133,15 +134,18 @@ function! s:NvimPrepareWindowContent(lines) abort endfunction function! s:NvimCreate(options) abort + let l:popup_opts = extend({ + \ 'relative': 'cursor', + \ 'row': 1, + \ 'col': 0, + \ 'width': 42, + \ 'height': 4, + \ 'style': 'minimal' + \ }, s:GetPopupOpts()) + 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' - \ }) + let l:winid = nvim_open_win(l:buffer, v:false, l:popup_opts) + 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) @@ -151,7 +155,8 @@ function! s:NvimCreate(options) abort endfunction function! s:VimCreate(options) abort - let l:popup_id = popup_create([], { + " default options + let l:popup_opts = extend({ \ 'line': 'cursor+1', \ 'col': 'cursor', \ 'drag': v:true, @@ -170,7 +175,9 @@ function! s:VimCreate(options) abort \ get(g:ale_floating_window_border, 5, '+'), \ ], \ 'moved': 'any', - \ }) + \ }, s:GetPopupOpts()) + + let l:popup_id = popup_create([], l:popup_opts) call setbufvar(winbufnr(l:popup_id), '&filetype', get(a:options, 'filetype', 'ale-preview')) let w:preview = {'id': l:popup_id} endfunction @@ -204,3 +211,21 @@ function! s:VimClose() abort call popup_close(w:preview['id']) unlet w:preview endfunction + +" get either the results of a function callback or dictionary for popup overrides +function! s:GetPopupOpts() abort + if exists('g:ale_floating_preview_popup_opts') + let l:ref = g:ale_floating_preview_popup_opts + + if type(l:ref) is# v:t_dict + return l:ref + elseif type(l:ref) is# v:t_string + try + return function(l:ref)() + catch /E700/ + endtry + endif + endif + + return {} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/handlers/deno.vim b/sources_non_forked/ale/autoload/ale/handlers/deno.vim index 1b5e1718..b762f983 100644 --- a/sources_non_forked/ale/autoload/ale/handlers/deno.vim +++ b/sources_non_forked/ale/autoload/ale/handlers/deno.vim @@ -29,6 +29,8 @@ function! ale#handlers#deno#GetProjectRoot(buffer) abort endif let l:possible_project_roots = [ + \ 'deno.json', + \ 'deno.jsonc', \ 'tsconfig.json', \ '.git', \ bufname(a:buffer), diff --git a/sources_non_forked/ale/autoload/ale/hover.vim b/sources_non_forked/ale/autoload/ale/hover.vim index 5b14df8c..0954b802 100644 --- a/sources_non_forked/ale/autoload/ale/hover.vim +++ b/sources_non_forked/ale/autoload/ale/hover.vim @@ -339,6 +339,10 @@ function! ale#hover#ShowTruncatedMessageAtCursor() abort let l:buffer = bufnr('') let l:pos = getpos('.')[0:2] + if !getbufvar(l:buffer, 'ale_enabled', 1) + return + endif + if l:pos != s:last_pos let s:last_pos = l:pos let [l:info, l:loc] = ale#util#FindItemAtCursor(l:buffer) diff --git a/sources_non_forked/ale/autoload/ale/lsp_linter.vim b/sources_non_forked/ale/autoload/ale/lsp_linter.vim index 39e3e322..1fb2e9b6 100644 --- a/sources_non_forked/ale/autoload/ale/lsp_linter.vim +++ b/sources_non_forked/ale/autoload/ale/lsp_linter.vim @@ -141,6 +141,10 @@ function! s:HandleLSPErrorMessage(linter_name, response) abort return endif + call ale#lsp_linter#AddErrorMessage(a:linter_name, l:message) +endfunction + +function! ale#lsp_linter#AddErrorMessage(linter_name, message) abort " This global variable is set here so we don't load the debugging.vim file " until someone uses :ALEInfo. let g:ale_lsp_error_messages = get(g:, 'ale_lsp_error_messages', {}) @@ -149,7 +153,7 @@ function! s:HandleLSPErrorMessage(linter_name, response) abort let g:ale_lsp_error_messages[a:linter_name] = [] endif - call add(g:ale_lsp_error_messages[a:linter_name], l:message) + call add(g:ale_lsp_error_messages[a:linter_name], a:message) endfunction function! ale#lsp_linter#HandleLSPResponse(conn_id, response) abort @@ -430,6 +434,8 @@ function! ale#lsp_linter#StartLSP(buffer, linter, Callback) abort if empty(l:root) && a:linter.lsp isnot# 'tsserver' " If there's no project root, then we can't check files with LSP, " unless we are using tsserver, which doesn't use project roots. + call ale#lsp_linter#AddErrorMessage(a:linter.name, "Failed to find project root, language server wont't start.") + return 0 endif diff --git a/sources_non_forked/ale/autoload/ale/toggle.vim b/sources_non_forked/ale/autoload/ale/toggle.vim index 122d6cc4..7f8957d4 100644 --- a/sources_non_forked/ale/autoload/ale/toggle.vim +++ b/sources_non_forked/ale/autoload/ale/toggle.vim @@ -14,8 +14,8 @@ function! s:DisablePostamble() abort call ale#highlight#UpdateHighlights() endif - if g:ale_virtualtext_cursor - call ale#virtualtext#Clear() + if g:ale_virtualtext_cursor == 1 + call ale#virtualtext#Clear(bufnr('')) endif endfunction diff --git a/sources_non_forked/ale/autoload/ale/virtualtext.vim b/sources_non_forked/ale/autoload/ale/virtualtext.vim index 345deb70..5fade39b 100644 --- a/sources_non_forked/ale/autoload/ale/virtualtext.vim +++ b/sources_non_forked/ale/autoload/ale/virtualtext.vim @@ -8,52 +8,59 @@ let g:ale_virtualtext_delay = get(g:, 'ale_virtualtext_delay', 10) let s:cursor_timer = -1 let s:last_pos = [0, 0, 0] let s:has_virt_text = 0 +let s:emulate_virt = 0 if has('nvim-0.3.2') let s:ns_id = nvim_create_namespace('ale') let s:has_virt_text = 1 elseif has('textprop') && has('popupwin') - call prop_type_add('ale', {}) - let s:last_popup = -1 let s:has_virt_text = 1 + let s:emulate_virt = !has('patch-9.0.0297') + let s:hl_list = [] + + if s:emulate_virt + call prop_type_add('ale', {}) + let s:last_virt = -1 + endif endif -function! ale#virtualtext#Clear() abort +function! ale#virtualtext#Clear(buf) abort if !s:has_virt_text return endif - let l:buffer = bufnr('') - if has('nvim') - call nvim_buf_clear_highlight(l:buffer, s:ns_id, 0, -1) + call nvim_buf_clear_namespace(a:buf, s:ns_id, 0, -1) else - if s:last_popup != -1 + if s:emulate_virt && s:last_virt != -1 call prop_remove({'type': 'ale'}) - call popup_close(s:last_popup) - let s:last_popup = -1 + call popup_close(s:last_virt) + let s:last_virt = -1 + elseif !empty(s:hl_list) + call prop_remove({ + \ 'types': s:hl_list, + \ 'all': 1, + \ 'bufnr': a:buf}) endif endif endfunction -function! ale#virtualtext#ShowMessage(message, hl_group) abort - if !s:has_virt_text +function! ale#virtualtext#ShowMessage(message, hl_group, buf, line) abort + if !s:has_virt_text || !bufexists(str2nr(a:buf)) return endif - let l:line = line('.') - let l:buffer = bufnr('') let l:prefix = get(g:, 'ale_virtualtext_prefix', '> ') let l:msg = l:prefix.trim(substitute(a:message, '\n', ' ', 'g')) if has('nvim') - call nvim_buf_set_virtual_text(l:buffer, s:ns_id, l:line-1, [[l:msg, a:hl_group]], {}) - else + call nvim_buf_set_virtual_text(a:buf, s:ns_id, a:line-1, [[l:msg, a:hl_group]], {}) + elseif s:emulate_virt let l:left_pad = col('$') - call prop_add(l:line, l:left_pad, { + call prop_add(a:line, l:left_pad, { \ 'type': 'ale', \}) - let s:last_popup = popup_create(l:msg, { + let s:last_virt = popup_create(l:msg, { \ 'line': -1, \ 'padding': [0, 0, 0, 1], \ 'mask': [[1, 1, 1, 1]], @@ -63,6 +70,19 @@ function! ale#virtualtext#ShowMessage(message, hl_group) abort \ 'wrap': 0, \ 'zindex': 2 \}) + else + let type = prop_type_get(a:hl_group) + + if type == {} + call add(s:hl_list, a:hl_group) + call prop_type_add(a:hl_group, {'highlight': a:hl_group}) + endif + + call prop_add(a:line, 0, { + \ 'type': a:hl_group, + \ 'text': ' ' . l:msg, + \ 'bufnr': a:buf + \}) endif endfunction @@ -73,8 +93,26 @@ function! s:StopCursorTimer() abort endif endfunction +function! ale#virtualtext#GetHlGroup(type, style) abort + if a:type is# 'E' + if a:style is# 'style' + return 'ALEVirtualTextStyleError' + else + return 'ALEVirtualTextError' + endif + elseif a:type is# 'W' + if a:style is# 'style' + return 'ALEVirtualTextStyleWarning' + else + return 'ALEVirtualTextWarning' + endif + else + return 'ALEVirtualTextInfo' + endif +endfunction + function! ale#virtualtext#ShowCursorWarning(...) abort - if !g:ale_virtualtext_cursor + if g:ale_virtualtext_cursor != 1 return endif @@ -90,35 +128,21 @@ function! ale#virtualtext#ShowCursorWarning(...) abort let [l:info, l:loc] = ale#util#FindItemAtCursor(l:buffer) - call ale#virtualtext#Clear() + call ale#virtualtext#Clear(l:buffer) if !empty(l:loc) let l:msg = l:loc.text - let l:hl_group = 'ALEVirtualTextInfo' let l:type = get(l:loc, 'type', 'E') - - if l:type is# 'E' - if get(l:loc, 'sub_type', '') is# 'style' - let l:hl_group = 'ALEVirtualTextStyleError' - else - let l:hl_group = 'ALEVirtualTextError' - endif - elseif l:type is# 'W' - if get(l:loc, 'sub_type', '') is# 'style' - let l:hl_group = 'ALEVirtualTextStyleWarning' - else - let l:hl_group = 'ALEVirtualTextWarning' - endif - endif - - call ale#virtualtext#ShowMessage(l:msg, l:hl_group) + let l:style = get(l:loc, 'sub_type', '') + let l:hl_group = ale#virtualtext#GetHlGroup(l:type, l:style) + call ale#virtualtext#ShowMessage(l:msg, l:hl_group, l:buffer, line('.')) endif endfunction function! ale#virtualtext#ShowCursorWarningWithDelay() abort let l:buffer = bufnr('') - if !g:ale_virtualtext_cursor + if g:ale_virtualtext_cursor != 1 return endif @@ -145,3 +169,19 @@ function! ale#virtualtext#ShowCursorWarningWithDelay() abort endif endfunction +function! ale#virtualtext#SetTexts(buf, loclist) abort + if !has('nvim') && s:emulate_virt + return + endif + + call ale#virtualtext#Clear(a:buf) + + for l in a:loclist + if l['bufnr'] != a:buf + continue + endif + + let hl = ale#virtualtext#GetHlGroup(l['type'], get(l, 'sub_type', '')) + call ale#virtualtext#ShowMessage(l['text'], hl, a:buf, l['lnum']) + endfor +endfunction diff --git a/sources_non_forked/ale/doc/ale-ruby.txt b/sources_non_forked/ale/doc/ale-ruby.txt index 4bc25b1a..bd7bd57d 100644 --- a/sources_non_forked/ale/doc/ale-ruby.txt +++ b/sources_non_forked/ale/doc/ale-ruby.txt @@ -219,5 +219,25 @@ g:ale_ruby_standardrb_options *g:ale_ruby_standardrb_options* This variable can be changed to modify flags given to standardrb. +=============================================================================== +syntax_tree *ale-ruby-syntax_tree* + +g:ale_ruby_syntax_tree_executable *g:ale_ruby_syntax_tree_executable* + *b:ale_ruby_syntax_tree_executable* + Type: String + Default: `'stree'` + + Override the invoked SyntaxTree binary. Set this to `'bundle'` to invoke + `'bundle` `exec` stree'. + + +g:ale_ruby_syntax_tree_options *g:ale_ruby_syntax_tree_options* + *b:ale_ruby_syntax_tree_options* + Type: |String| + Default: `''` + + This variable can be changed to modify flags given to SyntaxTree. + + =============================================================================== 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 a0a20c7e..080b7ec0 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 @@ -52,6 +52,8 @@ Notes: * `buildifier` * BibTeX * `bibclean` +* Bicep + * `bicep` * BitBake * `oelint-adv` * Bourne Shell @@ -529,6 +531,7 @@ Notes: * `solargraph` * `sorbet` * `standardrb` + * `syntax_tree` * Rust * `cargo`!! * `cspell` @@ -664,6 +667,7 @@ Notes: * YAML * `actionlint` * `circleci`!! + * `gitlablint` * `prettier` * `spectral` * `swaglint` diff --git a/sources_non_forked/ale/doc/ale-vue.txt b/sources_non_forked/ale/doc/ale-vue.txt index 98ac5808..40106b2b 100644 --- a/sources_non_forked/ale/doc/ale-vue.txt +++ b/sources_non_forked/ale/doc/ale-vue.txt @@ -42,7 +42,7 @@ volar *ale-vue-volar* g:ale_vue_volar_executable *g:ale_vue_volar_executable* *b:ale_vue_volar_executable* Type: |String| - Default: `'volar-server'` + Default: `'vue-language-server'` See |ale-integrations-local-executables| diff --git a/sources_non_forked/ale/doc/ale-yaml.txt b/sources_non_forked/ale/doc/ale-yaml.txt index 9733990e..b3450b87 100644 --- a/sources_non_forked/ale/doc/ale-yaml.txt +++ b/sources_non_forked/ale/doc/ale-yaml.txt @@ -280,5 +280,52 @@ g:ale_yaml_yamllint_options *g:ale_yaml_yamllint_options* This variable can be set to pass additional options to yamllint. +=============================================================================== +gitlablint *ale-yaml-gitlablint* + +Website: https://github.com/elijah-roberts/gitlab-lint + + +Installation +------------------------------------------------------------------------------- + +Install yamllint in your a virtualenv directory, locally, or globally: > + + pip3 install gitlab_lint # After activating virtualenv + pip3 install --user gitlab_lint # Install to ~/.local/bin + sudo pip3 install gitlab_lint # Install globally + +See |g:ale_virtualenv_dir_names| for configuring how ALE searches for +virtualenv directories. + +Is recommended to use |g:ale_pattern_options| to enable this linter so it only +applies to 'gitlab-ci.yml' files and not all yaml files: +> + let g:ale_pattern_options = { + \ '.gitlab-ci\.yml$': { + \ 'ale_linters': ['gitlablint'], + \ }, + \} +< + +Options +------------------------------------------------------------------------------- + +g:ale_yaml_gitlablint_executable *g:ale_yaml_gitlablint_executable* + *b:ale_yaml_gitlablint_executable* + Type: |String| + Default: `'gll'` + + This variable can be set to change the path to gll. + + +g:ale_yaml_gitlablint_options *g:ale_yaml_gitlablint_options* + *b:ale_yaml_gitlablint_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to gll. + + =============================================================================== vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale.txt b/sources_non_forked/ale/doc/ale.txt index ff1af720..c20924be 100644 --- a/sources_non_forked/ale/doc/ale.txt +++ b/sources_non_forked/ale/doc/ale.txt @@ -1234,6 +1234,29 @@ g:ale_floating_preview *g:ale_floating_preview* |g:ale_detail_to_floating_preview| to `1`. +g:ale_floating_preview_popup_opts *g:ale_floating_preview_popup_opts* + + Type: |String| or |Dictionary| + Default: `''` + + Either a dictionary of options or the string name of a function that returns a + dictionary of options. This will be used as an argument to |popup_create| for + Vim users or |nvim_open_win| for NeoVim users. Note that in either case, the + resulting dictionary is merged with ALE defaults rather than expliciting overriding + them. This only takes effect if |g:ale_floating_preview| is enabled. + + NOTE: for Vim users see |popup_create-arguments|, for NeoVim users see + |nvim_open_win| for argument details + + For example, to enhance popups with a title: > + + function! CustomOpts() abort { + let [l:info, l:loc] = ale#util#FindItemAtCursor(bufnr('')) + return {'title': ' ALE: ' . (l:loc.linter_name) . ' '} + endfunction +< + + g:ale_floating_window_border *g:ale_floating_window_border* Type: |List| @@ -2274,6 +2297,9 @@ g:ale_virtualtext_cursor *g:ale_virtualtext_cursor* column nearest to the cursor when the cursor is resting on a line which contains a warning or error. This option can be set to `0` to disable this behavior. + When this option is set to `2`, then all warnings will be shown for the + whole buffer, regardless of if the cursor is currently positioned in that + line. Messages are only displayed after a short delay. See |g:ale_virtualtext_delay|. @@ -2761,6 +2787,8 @@ documented in additional help files. buildifier............................|ale-bazel-buildifier| bib.....................................|ale-bib-options| bibclean..............................|ale-bib-bibclean| + bicep...................................|ale-bicep-options| + bicep.................................|ale-bicep-bicep| bitbake.................................|ale-bitbake-options| oelint-adv............................|ale-bitbake-oelint_adv| c.......................................|ale-c-options| @@ -3167,6 +3195,7 @@ documented in additional help files. solargraph............................|ale-ruby-solargraph| sorbet................................|ale-ruby-sorbet| standardrb............................|ale-ruby-standardrb| + syntax_tree...........................|ale-ruby-syntax_tree| rust....................................|ale-rust-options| analyzer..............................|ale-rust-analyzer| cargo.................................|ale-rust-cargo| @@ -3302,6 +3331,7 @@ documented in additional help files. yaml-language-server..................|ale-yaml-language-server| yamlfix...............................|ale-yaml-yamlfix| yamllint..............................|ale-yaml-yamllint| + gitlablint............................|ale-yaml-gitlablint| yang....................................|ale-yang-options| yang-lsp..............................|ale-yang-lsp| zeek....................................|ale-zeek-options| diff --git a/sources_non_forked/ale/plugin/ale.vim b/sources_non_forked/ale/plugin/ale.vim index 12373e11..4ba24c1d 100644 --- a/sources_non_forked/ale/plugin/ale.vim +++ b/sources_non_forked/ale/plugin/ale.vim @@ -322,7 +322,7 @@ nnoremap (ale_go_to_definition_in_vsplit) :ALEGoToDefinition -vsp nnoremap (ale_go_to_type_definition) :ALEGoToTypeDefinition nnoremap (ale_go_to_type_definition_in_tab) :ALEGoToTypeDefinition -tab nnoremap (ale_go_to_type_definition_in_split) :ALEGoToTypeDefinition -split -nnoremap (ale_go_to_type_definition_in_vsplit) :ALEGoToTypeDefinitionIn -vsplit +nnoremap (ale_go_to_type_definition_in_vsplit) :ALEGoToTypeDefinition -vsplit nnoremap (ale_go_to_implementation_in_tab) :ALEGoToImplementation -tab nnoremap (ale_go_to_implementation_in_split) :ALEGoToImplementation -split nnoremap (ale_go_to_implementation_in_vsplit) :ALEGoToImplementation -vsplit diff --git a/sources_non_forked/ale/supported-tools.md b/sources_non_forked/ale/supported-tools.md index bdad2b3b..ed4458f1 100644 --- a/sources_non_forked/ale/supported-tools.md +++ b/sources_non_forked/ale/supported-tools.md @@ -61,6 +61,8 @@ formatting. * [buildifier](https://github.com/bazelbuild/buildtools) * BibTeX * [bibclean](http://ftp.math.utah.edu/pub/bibclean/) +* Bicep + * [bicep](https://github.com/Azure/bicep) * BitBake * [oelint-adv](https://github.com/priv-kweihmann/oelint-adv) * Bourne Shell @@ -538,6 +540,7 @@ formatting. * [solargraph](https://solargraph.org) * [sorbet](https://github.com/sorbet/sorbet) * [standardrb](https://github.com/testdouble/standard) + * [syntax_tree](https://github.com/ruby-syntax-tree/syntax_tree) * Rust * [cargo](https://github.com/rust-lang/cargo) :floppy_disk: (see `:help ale-integration-rust` for configuration instructions) * [cspell](https://github.com/streetsidesoftware/cspell/tree/main/packages/cspell) @@ -673,6 +676,7 @@ formatting. * YAML * [actionlint](https://github.com/rhysd/actionlint) :warning: * [circleci](https://circleci.com/docs/2.0/local-cli) :floppy_disk: :warning: + * [gitlablint](https://github.com/elijah-roberts/gitlab-lint) * [prettier](https://github.com/prettier/prettier) * [spectral](https://github.com/stoplightio/spectral) * [swaglint](https://github.com/byCedric/swaglint) :warning: diff --git a/sources_non_forked/vim-flake8/ftplugin/python_flake8.vim b/sources_non_forked/vim-flake8/ftplugin/python_flake8.vim index dd062d91..cf4cdcff 100644 --- a/sources_non_forked/vim-flake8/ftplugin/python_flake8.vim +++ b/sources_non_forked/vim-flake8/ftplugin/python_flake8.vim @@ -50,6 +50,8 @@ if !exists("no_plugin_maps") && !exists("no_flake8_maps") endif endif +command! Flake :call flake8#Flake8() + 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 167cfb6e..f3746f63 100644 --- a/sources_non_forked/vim-fugitive/autoload/fugitive.vim +++ b/sources_non_forked/vim-fugitive/autoload/fugitive.vim @@ -1598,11 +1598,20 @@ function! fugitive#repo(...) abort endfunction function! s:repo_dir(...) dict abort - throw 'fugitive: fugitive#repo().dir() has been replaced by FugitiveGitDir()' + if !a:0 + return self.git_dir + endif + throw 'fugitive: fugitive#repo().dir("...") has been replaced by FugitiveFind(".git/...")' endfunction function! s:repo_tree(...) dict abort - throw 'fugitive: fugitive#repo().tree() has been replaced by FugitiveFind(":/")' + let tree = s:Tree(self.git_dir) + if empty(tree) + throw 'fugitive: no work tree' + elseif !a:0 + return tree + endif + throw 'fugitive: fugitive#repo().tree("...") has been replaced by FugitiveFind(":(top)...")' endfunction function! s:repo_bare() dict abort @@ -1628,11 +1637,11 @@ function! s:repo_git_command(...) dict abort endfunction function! s:repo_git_chomp(...) dict abort - throw 'fugitive: fugitive#repo().git_chomp(...) has been replaced by FugitiveExecute(...).stdout' + silent return substitute(system(fugitive#ShellCommand(a:000, self.git_dir)), '\n$', '', '') endfunction function! s:repo_git_chomp_in_tree(...) dict abort - throw 'fugitive: fugitive#repo().git_chomp_in_tree(...) has been replaced by FugitiveExecute(...).stdout' + return call(self.git_chomp, a:000, self) endfunction function! s:repo_rev_parse(rev) dict abort @@ -1642,7 +1651,7 @@ endfunction call s:add_methods('repo',['git_command','git_chomp','git_chomp_in_tree','rev_parse']) function! s:repo_config(name) dict abort - throw 'fugitive: fugitive#repo().config(...) has been replaced by FugitiveConfigGet(...)' + return FugitiveConfigGet(a:name, self.git_dir) endfunction call s:add_methods('repo',['config']) @@ -2388,7 +2397,7 @@ function! s:GlobComplete(lead, pattern, ...) abort if a:lead ==# '/' return [] else - let results = glob(a:lead . a:pattern, a:0 ? a:1 : 0, 1) + let results = glob(substitute(a:lead . a:pattern, '[\{}]', '\\&', 'g'), a:0 ? a:1 : 0, 1) endif call map(results, 'v:val !~# "/$" && isdirectory(v:val) ? v:val."/" : v:val') call map(results, 'v:val[ strlen(a:lead) : -1 ]') @@ -7196,9 +7205,9 @@ function! s:BlameMaps(is_ftplugin) abort call s:Map('n', 'o', ':exe BlameCommit("split")', '', ft) call s:Map('n', 'O', ':exe BlameCommit("tabedit")', '', ft) call s:Map('n', 'p', ':exe BlameCommit("pedit")', '', ft) - call s:Map('n', '.', ": =substitute(BlameCommitFileLnum()[0],'^$','@','')", ft) - call s:Map('n', '(', "-", ft) - call s:Map('n', ')', "+", ft) + exe s:Map('n', '.', ": =substitute(BlameCommitFileLnum()[0],'^$','@','')", '', ft) + exe s:Map('n', '(', "-", '', ft) + exe s:Map('n', ')', "+", '', ft) call s:Map('n', 'A', ":exe 'vertical resize '.(linechars('.\\{-\\}\\ze [0-9:/+-][0-9:/+ -]* \\d\\+)')+1+v:count)", '', ft) call s:Map('n', 'C', ":exe 'vertical resize '.(linechars('^\\S\\+')+1+v:count)", '', ft) call s:Map('n', 'D', ":exe 'vertical resize '.(linechars('.\\{-\\}\\ze\\d\\ze\\s\\+\\d\\+)')+1-v:count)", '', ft) diff --git a/sources_non_forked/vim-fugitive/plugin/fugitive.vim b/sources_non_forked/vim-fugitive/plugin/fugitive.vim index c17d8502..45bfc6d5 100644 --- a/sources_non_forked/vim-fugitive/plugin/fugitive.vim +++ b/sources_non_forked/vim-fugitive/plugin/fugitive.vim @@ -689,6 +689,9 @@ augroup fugitive \ if FugitiveIsGitDir(expand(':p:h')) | \ let b:git_dir = s:Slash(expand(':p:h')) | \ exe fugitive#BufReadStatus(v:cmdbang) | + \ echohl WarningMSG | + \ echo "fugitive: Direct editing of .git/" . expand('%:t') . " is deprecated" | + \ echohl NONE | \ elseif filereadable(expand('')) | \ silent doautocmd BufReadPre | \ keepalt noautocmd read | diff --git a/sources_non_forked/vim-gitgutter/autoload/gitgutter/async.vim b/sources_non_forked/vim-gitgutter/autoload/gitgutter/async.vim index d4767482..8b9f1301 100644 --- a/sources_non_forked/vim-gitgutter/autoload/gitgutter/async.vim +++ b/sources_non_forked/vim-gitgutter/autoload/gitgutter/async.vim @@ -1,8 +1,8 @@ let s:available = has('nvim') || ( \ has('job') && ( - \ (has('patch-7-4-1826') && !has('gui_running')) || - \ (has('patch-7-4-1850') && has('gui_running')) || - \ (has('patch-7-4-1832') && has('gui_macvim')) + \ (has('patch-7.4.1826') && !has('gui_running')) || + \ (has('patch-7.4.1850') && has('gui_running')) || + \ (has('patch-7.4.1832') && has('gui_macvim')) \ ) \ ) diff --git a/sources_non_forked/vim-gitgutter/plugin/gitgutter.vim b/sources_non_forked/vim-gitgutter/plugin/gitgutter.vim index 9e989cee..008724e3 100644 --- a/sources_non_forked/vim-gitgutter/plugin/gitgutter.vim +++ b/sources_non_forked/vim-gitgutter/plugin/gitgutter.vim @@ -245,8 +245,10 @@ function! s:on_bufenter() " been any changes to the buffer since the first round, the second round " will be cheap. if has('vim_starting') && !$VIM_GITGUTTER_TEST - if exists('*timer_start') - call timer_start(&updatetime, 'GitGutterCursorHold') + if exists('*timer_start') && has('lambda') + call s:next_tick("call gitgutter#process_buffer(+".bufnr('').", 0)") + else + call gitgutter#process_buffer(bufnr(''), 0) endif return endif @@ -259,10 +261,6 @@ function! s:on_bufenter() endif endfunction -function! GitGutterCursorHold(timer) - execute 'doautocmd' s:nomodeline 'gitgutter CursorHold' -endfunction - function! s:next_tick(cmd) call timer_start(1, {-> execute(a:cmd)}) endfunction diff --git a/sources_non_forked/vim-javascript/extras/jsdoc.vim b/sources_non_forked/vim-javascript/extras/jsdoc.vim index 92c4b8b2..a7189d1b 100644 --- a/sources_non_forked/vim-javascript/extras/jsdoc.vim +++ b/sources_non_forked/vim-javascript/extras/jsdoc.vim @@ -18,7 +18,8 @@ syntax region jsDocTypeRecord contained start=/{/ end=/}/ contains=jsDocTypeRe syntax region jsDocTypeRecord contained start=/\[/ end=/\]/ contains=jsDocTypeRecord extend syntax region jsDocTypeNoParam contained start="{" end="}" oneline syntax match jsDocTypeNoParam contained "\%(#\|\"\|\w\|\.\|:\|\/\)\+" -syntax match jsDocParam contained "\%(#\|\$\|-\|'\|\"\|{.\{-}}\|\w\|\.\|:\|\/\|\[.\{-}]\|=\)\+" +syntax match jsDocParam contained "\%(#\|\$\|-\|'\|\"\|{.\{-}}\|\w\|\~\|\.\|:\|\/\|\[.\{-}]\|=\)\+" + syntax region jsDocSeeTag contained matchgroup=jsDocSeeTag start="{" end="}" contains=jsDocTags if version >= 508 || !exists("did_javascript_syn_inits") diff --git a/sources_non_forked/vim-javascript/syntax/javascript.vim b/sources_non_forked/vim-javascript/syntax/javascript.vim index d482feb4..02b0c78c 100644 --- a/sources_non_forked/vim-javascript/syntax/javascript.vim +++ b/sources_non_forked/vim-javascript/syntax/javascript.vim @@ -28,7 +28,7 @@ syntax match jsNoise /[:;]/ syntax match jsNoise /,/ skipwhite skipempty nextgroup=@jsExpression syntax match jsDot /\./ skipwhite skipempty nextgroup=jsObjectProp,jsFuncCall,jsPrototype,jsTaggedTemplate syntax match jsObjectProp contained /\<\K\k*/ -syntax match jsFuncCall /\<\K\k*\ze\s*(/ +syntax match jsFuncCall /\<\K\k*\ze[\s\n]*(/ syntax match jsParensError /[)}\]]/ " Program Keywords diff --git a/sources_non_forked/vim-markdown/CONTRIBUTING.md b/sources_non_forked/vim-markdown/CONTRIBUTING.md index 31ccd893..736f0238 100644 --- a/sources_non_forked/vim-markdown/CONTRIBUTING.md +++ b/sources_non_forked/vim-markdown/CONTRIBUTING.md @@ -34,7 +34,7 @@ There are many flavors of markdown, each one with an unique feature set. This pl ## Style -When choosing between multiple valid Markdown syntaxes, the default behavior must be that specified at: +When choosing between multiple valid Markdown syntaxes, the default behavior must be that specified at: If you wish to have a behavior that differs from that style guide, add an option to turn it on or off, and leave it off by default. diff --git a/sources_non_forked/vim-ruby/syntax/ruby.vim b/sources_non_forked/vim-ruby/syntax/ruby.vim index b940e5a9..abe1b770 100644 --- a/sources_non_forked/vim-ruby/syntax/ruby.vim +++ b/sources_non_forked/vim-ruby/syntax/ruby.vim @@ -398,11 +398,6 @@ if !exists("b:ruby_no_expensive") && !exists("ruby_no_expensive") SynFold 'for' syn region rubyRepeatExpression start="\" start="\%(\%(^\|\.\.\.\=\|[{:,;([<>~\*/%&^|+=-]\|\%(\<\%(\h\|[^\x00-\x7F]\)\%(\w\|[^\x00-\x7F]\)*\)\@" matchgroup=rubyRepeat skip="\" nextgroup=rubyMethodDeclaration skipwhite skipnl syn match rubyControl "\" nextgroup=rubyClassDeclaration skipwhite skipnl @@ -411,6 +406,11 @@ else syn match rubyKeyword "\<\%(alias\|undef\)\>" endif +if !exists("ruby_minlines") + let ruby_minlines = 500 +endif +exe "syn sync minlines=" . ruby_minlines + " Special Methods {{{1 if !exists("ruby_no_special_methods") syn match rubyAccess "\<\%(public\|protected\|private\)\>" " use re=2 diff --git a/sources_non_forked/vim-snippets/README.md b/sources_non_forked/vim-snippets/README.md index c8a242a3..8b31f770 100644 --- a/sources_non_forked/vim-snippets/README.md +++ b/sources_non_forked/vim-snippets/README.md @@ -27,6 +27,12 @@ snippets by typing the name of a snippet hitting the expansion mapping. snippets/* - [github.com/Shougo/neosnippet](https://github.com/Shougo/neosnippet.vim): VimL, supports snippets/* with some configuration. +- [github.com/dcampos/nvim-snippy](https://github.com/dcampos/nvim-snippy): + Lua, supports snippets/* with some configuration. +- [github.com/L3MON4D3/LuaSnip](https://github.com/L3MON4D3/LuaSnip): + Lua, supports snippets/* with some configuration. + Also supports redefining snippets without changing the priority, unlike + nvim-snippy. - [github.com/drmingdrmer/xptemplate](https://github.com/drmingdrmer/xptemplate): Totally different syntax, does not read snippets contained in this file, but it is also very powerful. It does not support vim-snippets (just listing it @@ -46,6 +52,9 @@ If you have VimL only (vim without python support) your best option is using [garbas/vim-snipmate](https://github.com/garbas/vim-snipmate) and cope with the minor bugs found in the engine. +If you use Neovim and prefer Lua plugins, +[L3MON4D3/LuaSnip](https://github.com/L3MON4D3/LuaSnip) is the best option. + **Q**: Should snipMate be deprecated in favour of UltiSnips? **A**: No, because snipMate is VimL, and UltiSnips requires Python. diff --git a/sources_non_forked/vim-snippets/UltiSnips/cpp.snippets b/sources_non_forked/vim-snippets/UltiSnips/cpp.snippets index a997f001..4a22782f 100644 --- a/sources_non_forked/vim-snippets/UltiSnips/cpp.snippets +++ b/sources_non_forked/vim-snippets/UltiSnips/cpp.snippets @@ -30,6 +30,11 @@ endglobal ########################################################################### # TextMate Snippets # ########################################################################### +snippet ponce "#pragma once include guard" +#pragma once + +endsnippet + snippet main int main(int argc, char *argv[]) { @@ -67,6 +72,14 @@ namespace${1/.+/ /m}${1:`!p snip.rv = snip.basename or "name"`} }${1/.+/ \/* /m}$1${1/.+/ *\/ /m} endsnippet +snippet nsa "namespace alias" +namespace ${1:alias} = ${2:namespace}; +endsnippet + +snippet using "using directive/using declaration/type alias" +using ${1:namespace}`!p snip.rv = ' ' if t[1] == 'namespace' else ' = ' if t[1] != '' else ''`${2:name}; +endsnippet + snippet readfile "read file (readF)" std::vector v; if (FILE *fp = fopen(${1:"filename"}, "r")) diff --git a/sources_non_forked/vim-snippets/UltiSnips/lua.snippets b/sources_non_forked/vim-snippets/UltiSnips/lua.snippets index 51d8d58d..de54cdea 100644 --- a/sources_non_forked/vim-snippets/UltiSnips/lua.snippets +++ b/sources_non_forked/vim-snippets/UltiSnips/lua.snippets @@ -104,11 +104,11 @@ snippet local "local x = 1" local ${1:x} = ${0:1} endsnippet -snippet use "Use" Ab +snippet use "Use" b use { '$1' } endsnippet -snippet req "Require" +snippet req "Require" b require('$1') endsnippet diff --git a/sources_non_forked/vim-snippets/UltiSnips/tex.snippets b/sources_non_forked/vim-snippets/UltiSnips/tex.snippets index 3e7e3e8d..00e910de 100644 --- a/sources_non_forked/vim-snippets/UltiSnips/tex.snippets +++ b/sources_non_forked/vim-snippets/UltiSnips/tex.snippets @@ -454,27 +454,6 @@ snippet docls "Document Class" bA \documentclass{$1}$0 endsnippet -snippet tmplt "Template" -\documentclass{article} - -\usepackage{import} -\usepackage{pdfpages} -\usepackage{transparent} -\usepackage{xcolor} -$1 - -\newcommand{\incfig}[2][1]{% - \def\svgwidth{#1\columnwidth} - \import{./figures/}{#2.pdf_tex} -} -$2 -\pdfsuppresswarningpagegroup=1 - -\begin{document} - $0 -\end{document} -endsnippet - ######### # OTHER # diff --git a/sources_non_forked/vim-snippets/snippets/actionscript.snippets b/sources_non_forked/vim-snippets/snippets/actionscript.snippets index 5d744390..e4b8c93b 100644 --- a/sources_non_forked/vim-snippets/snippets/actionscript.snippets +++ b/sources_non_forked/vim-snippets/snippets/actionscript.snippets @@ -114,7 +114,7 @@ snippet forr } # If Condition snippet if - if (${1:/* condition */}) { + if ($1) { ${0:${VISUAL}} } snippet el @@ -122,8 +122,8 @@ snippet el ${0:${VISUAL}} } # Ternary conditional -snippet t - ${1:/* condition */} ? ${2:a} : ${0:b} +snippet t Ternary: `condition ? true : false` + $1 ? $2 : $0 snippet fun function ${1:function_name}(${2})${3} { @@ -150,4 +150,3 @@ snippet FlxSprite } } } - diff --git a/sources_non_forked/vim-snippets/snippets/arduino.snippets b/sources_non_forked/vim-snippets/snippets/arduino.snippets index a2732a5e..7a59a30d 100644 --- a/sources_non_forked/vim-snippets/snippets/arduino.snippets +++ b/sources_non_forked/vim-snippets/snippets/arduino.snippets @@ -19,7 +19,7 @@ snippet def # if snippet if - if (${1:/* condition */}) { + if ($1) { ${0:${VISUAL}} } # else @@ -29,12 +29,12 @@ snippet el } # else if snippet elif - else if (${1:/* condition */}) { + else if ($1) { ${2} } # ifi snippet ifi - if (${1:/* condition */}) ${2}; + if ($1) ${2}; # switch snippet switch @@ -63,14 +63,14 @@ snippet forr } # while snippet wh - while (${1:/* condition */}) { + while ($1) { ${2} } # do... while snippet do do { ${2} - } while (${1:/* condition */}); + } while ($1); ## ## Functions # function definition diff --git a/sources_non_forked/vim-snippets/snippets/autoit.snippets b/sources_non_forked/vim-snippets/snippets/autoit.snippets index f973fbc3..48713e57 100644 --- a/sources_non_forked/vim-snippets/snippets/autoit.snippets +++ b/sources_non_forked/vim-snippets/snippets/autoit.snippets @@ -1,16 +1,16 @@ snippet if - If ${1:condition} Then + If $1 Then ${0:; True code} EndIf snippet el Else ${0} snippet eif - ElseIf ${1:condition} Then + ElseIf $1 Then ${0:; True code} # If/Else block snippet ife - If ${1:condition} Then + If $1 Then ${2:; True code} Else ${0:; Else code} @@ -26,7 +26,7 @@ snippet ifelif EndIf # Switch block snippet switch - Switch (${1:condition}) + Switch ($1) Case ${2:case1}: ${3:; Case 1 code} Case Else: @@ -34,7 +34,7 @@ snippet switch EndSwitch # Select block snippet select - Select (${1:condition}) + Select ($1) Case ${2:case1}: ${3:; Case 1 code} Case Else: @@ -42,7 +42,7 @@ snippet select EndSelect # While loop snippet wh - While (${1:condition}) + While ($1) ${0:; code...} WEnd # For loop diff --git a/sources_non_forked/vim-snippets/snippets/c.snippets b/sources_non_forked/vim-snippets/snippets/c.snippets index 2af81e86..df5595b9 100644 --- a/sources_non_forked/vim-snippets/snippets/c.snippets +++ b/sources_non_forked/vim-snippets/snippets/c.snippets @@ -4,23 +4,23 @@ snippet main int main(int argc, char *argv[]) { ${0} - return 0; } # main(void) snippet mainn int main(void) { ${0} - return 0; } ## ## Preprocessor # #include <...> snippet inc #include <${1:stdio}.h> + $0 # #include "..." snippet Inc #include "${1:`vim_snippets#Filename("$1.h")`}" + $0 # ifndef...define...endif snippet ndef #ifndef $1 @@ -86,8 +86,8 @@ snippet elif snippet ifi if (${1:true}) ${0}; # ternary -snippet t - ${1:/* condition */} ? ${2:a} : ${3:b} +snippet t Ternary: `condition ? true : false` + $1 ? $2 : $0 # switch snippet switch switch (${1:/* variable */}) { @@ -111,6 +111,8 @@ snippet case ${3:break;} snippet ret return ${0}; +snippet ex + exit($0); ## ## Loops # for @@ -125,14 +127,18 @@ snippet forr } # while snippet wh - while (${1:/* condition */}) { + while (${1:1}) { + ${0:${VISUAL}} + } +snippet wht + while (true) { ${0:${VISUAL}} } # do... while snippet do do { ${0:${VISUAL}} - } while (${1:/* condition */}); + } while ($1); ## ## Functions # function definition @@ -277,6 +283,14 @@ snippet prf printf("${1:} = %f\n", $1); snippet prx printf("${1:} = %${2}\n", $1); +snippet warn + warn("${1:%s}"$0); +snippet warnx + warnx("${1:%s}"$0); +snippet err + err(${1:1}, "${2:%s}"$0); +snippet errx + errx(${1:1}, "${2:%s}"$0); # getopt snippet getopt int choice; @@ -337,7 +351,7 @@ snippet getopt ## Assertions snippet asr - assert(${1:condition}); + assert($1); snippet anl assert(${1:ptr} != NULL); diff --git a/sources_non_forked/vim-snippets/snippets/clojure.snippets b/sources_non_forked/vim-snippets/snippets/clojure.snippets index 048ce9fe..cc9d0704 100644 --- a/sources_non_forked/vim-snippets/snippets/clojure.snippets +++ b/sources_non_forked/vim-snippets/snippets/clojure.snippets @@ -81,7 +81,7 @@ snippet print snippet reduce (reduce ${1:(fn [p n] ${3})} ${2}) snippet when - (when ${1:test} ${0:body}) + (when ${1:test} $0) snippet when-let (when-let [${1:result} ${2:test}] - ${0:body}) + $0) diff --git a/sources_non_forked/vim-snippets/snippets/codeigniter.snippets b/sources_non_forked/vim-snippets/snippets/codeigniter.snippets index c38aa4db..afaf9638 100644 --- a/sources_non_forked/vim-snippets/snippets/codeigniter.snippets +++ b/sources_non_forked/vim-snippets/snippets/codeigniter.snippets @@ -99,7 +99,7 @@ snippet ci_db-select snippet ci_db-from $this->db->from("${1:table}");${2} snippet ci_db-join - $this->db->join("${1:table}", "${2:condition}", "${3:type}");${4} + $this->db->join("${1:table}", "$2", "${3:type}");${4} snippet ci_db-where $this->db->where("${1:key}", "${2:value}");${3} snippet ci_db-or_where diff --git a/sources_non_forked/vim-snippets/snippets/coffee/coffee.snippets b/sources_non_forked/vim-snippets/snippets/coffee/coffee.snippets index f23156cc..d07b1b62 100644 --- a/sources_non_forked/vim-snippets/snippets/coffee/coffee.snippets +++ b/sources_non_forked/vim-snippets/snippets/coffee/coffee.snippets @@ -2,37 +2,37 @@ snippet forindo for ${1:name} in ${2:array} do ($1) -> - ${0:// body} + $0 # Array comprehension snippet fora for ${1:name} in ${2:array} - ${0:# body...} + $0 # Object comprehension snippet foro for ${1:key}, ${2:value} of ${3:object} - ${0:# body...} + $0 # Range comprehension (inclusive) snippet forr for ${1:name} in [${2:start}..${3:finish}] - ${0:# body...} + $0 snippet forrb for ${1:name} in [${2:start}..${3:finish}] by ${4:step} - ${0:# body...} + $0 # Range comprehension (exclusive) snippet forrex for ${1:name} in [${2:start}...${3:finish}] - ${0:# body...} + $0 snippet forrexb for ${1:name} in [${2:start}...${3:finish}] by ${4:step} - ${0:# body...} + $0 # Function snippet fun (${1:args}) -> - ${0:# body...} + $0 # Function (bound) snippet bfun (${1:args}) => - ${0:# body...} + $0 # Class snippet cla class .. class ${1:`substitute(vim_snippets#Filename(), '\(_\|^\)\(.\)', '\u\2', 'g')`} @@ -54,29 +54,29 @@ snippet cla class .. extends .. constructor: .. ${0} # If snippet if - if ${1:condition} + if $1 ${0:${VISUAL}} # If __ Else snippet ife - if ${1:condition} + if $1 ${2:${VISUAL}} else - ${0:# body...} + ${0} # Else if snippet eif - else if ${1:condition} + else if $1 ${0:${VISUAL}} # Ternary If -snippet ifte - if ${1:condition} then ${2:value} else ${0:other} +snippet ifte Ternary + if $1 then $2 else $0 # Unless -snippet unl - ${1:action} unless ${0:condition} +snippet unl Unless + $1 unless $0 # Switch snippet swi switch ${1:object} when ${2:value} - ${0:# body...} + $0 # Log snippet log diff --git a/sources_non_forked/vim-snippets/snippets/cpp.snippets b/sources_non_forked/vim-snippets/snippets/cpp.snippets index 5d99f3d6..4e4155a8 100644 --- a/sources_non_forked/vim-snippets/snippets/cpp.snippets +++ b/sources_non_forked/vim-snippets/snippets/cpp.snippets @@ -1,5 +1,13 @@ extends c +## Main +# main() +snippet mainn + int main() + { + ${0} + return 0; + } ## ## Preprocessor # #include <...> diff --git a/sources_non_forked/vim-snippets/snippets/crystal.snippets b/sources_non_forked/vim-snippets/snippets/crystal.snippets index 34d25406..a5848f88 100644 --- a/sources_non_forked/vim-snippets/snippets/crystal.snippets +++ b/sources_non_forked/vim-snippets/snippets/crystal.snippets @@ -1,12 +1,12 @@ snippet req require require "${1}" snippet case - case ${1:object} - when ${2:condition} + case $1 + when $2 ${0} end snippet when - when ${1:condition} + when $1 ${0} snippet def def ${1:method_name} @@ -17,17 +17,17 @@ snippet pdef ${0} end snippet if - if ${1:condition} + if $1 ${0:${VISUAL}} end snippet ife - if ${1:condition} + if $1 ${2:${VISUAL}} else ${0} end snippet wh - while ${1:condition} + while $1 ${0:${VISUAL}} end snippet cla class .. end diff --git a/sources_non_forked/vim-snippets/snippets/dart.snippets b/sources_non_forked/vim-snippets/snippets/dart.snippets index de5cb623..f4fd4f13 100644 --- a/sources_non_forked/vim-snippets/snippets/dart.snippets +++ b/sources_non_forked/vim-snippets/snippets/dart.snippets @@ -61,15 +61,15 @@ snippet fore ${0} } snippet wh - while (${1:/* condition */}) { + while ($1) { ${0} } snippet dowh do { ${0} - } while (${0:/* condition */}); + } while ($0); snippet as - assert(${0:/* condition */}); + assert($0); snippet try try { ${0:${VISUAL}} diff --git a/sources_non_forked/vim-snippets/snippets/elixir.snippets b/sources_non_forked/vim-snippets/snippets/elixir.snippets index ee093eb9..c04c9ade 100644 --- a/sources_non_forked/vim-snippets/snippets/elixir.snippets +++ b/sources_non_forked/vim-snippets/snippets/elixir.snippets @@ -13,29 +13,29 @@ snippet if if .. do .. end ${0:${VISUAL}} end snippet if: if .. do: .. - if ${1:condition}, do: ${0} + if $1, do: ${0} snippet ife if .. do .. else .. end - if ${1:condition} do + if $1 do ${2:${VISUAL}} else ${0} end snippet ife: if .. do: .. else: - if ${1:condition}, do: ${2}, else: ${0} + if $1, do: ${2}, else: ${0} snippet unless unless .. do .. end unless ${1} do ${0:${VISUAL}} end snippet unless: unless .. do: .. - unless ${1:condition}, do: ${0} + unless $1, do: ${0} snippet unlesse unless .. do .. else .. end - unless ${1:condition} do + unless $1 do ${2:${VISUAL}} else ${0} end snippet unlesse: unless .. do: .. else: - unless ${1:condition}, do: ${2}, else: ${0} + unless $1, do: ${2}, else: ${0} snippet cond cond do ${1} -> diff --git a/sources_non_forked/vim-snippets/snippets/erlang.snippets b/sources_non_forked/vim-snippets/snippets/erlang.snippets index 7a0a6116..d655a9b9 100644 --- a/sources_non_forked/vim-snippets/snippets/erlang.snippets +++ b/sources_non_forked/vim-snippets/snippets/erlang.snippets @@ -17,7 +17,7 @@ snippet dt erlang:display({${1}, ${0}}), # define directive snippet def - -define(${1:macro}, ${2:body}). + -define(${1:macro}, $2). # export directive snippet exp -export([${1:function}/${0:arity}]). @@ -44,17 +44,17 @@ snippet undef snippet if if ${1:guard} -> - ${0:body} + $0 end # case expression snippet case case ${1:expression} of ${2:pattern} -> - ${0:body}; + $0; end # anonymous function snippet fun - fun (${1:Parameters}) -> ${2:body} end + fun (${1:Parameters}) -> $2 end # try...catch snippet try try @@ -65,10 +65,10 @@ snippet try snippet rcv "Receive Expression" receive ${1: ${2:pattern}${3: when ${4:guard}} -> - ${5:body}} + $5 ${6:after ${7:expression} -> - ${8:body}} + $8 end # record directive snippet rec diff --git a/sources_non_forked/vim-snippets/snippets/falcon.snippets b/sources_non_forked/vim-snippets/snippets/falcon.snippets index c523980d..5894fe1c 100644 --- a/sources_non_forked/vim-snippets/snippets/falcon.snippets +++ b/sources_non_forked/vim-snippets/snippets/falcon.snippets @@ -19,13 +19,13 @@ snippet class # If snippet if - if ${1:condition} + if $1 ${0} end # If else snippet ife - if ${1:condition} + if $1 ${0} else ${1} @@ -33,7 +33,7 @@ snippet ife # If else if snippet eif - elif ${1:condition} + elif $1 ${0} # Switch case diff --git a/sources_non_forked/vim-snippets/snippets/fortran.snippets b/sources_non_forked/vim-snippets/snippets/fortran.snippets index 8cb6f9a7..a073424e 100644 --- a/sources_non_forked/vim-snippets/snippets/fortran.snippets +++ b/sources_non_forked/vim-snippets/snippets/fortran.snippets @@ -64,7 +64,7 @@ snippet intent snippet / (/ $1 /) ${2:,&} ${0} snippet if - if (${1:condition}) then + if ($1) then ${0} end if snippet case @@ -78,7 +78,7 @@ snippet do ${0} end do snippet dow - do while (${1:condition}) + do while ($1) $2 end do snippet sub diff --git a/sources_non_forked/vim-snippets/snippets/go.snippets b/sources_non_forked/vim-snippets/snippets/go.snippets index 722e82fd..7245252c 100644 --- a/sources_non_forked/vim-snippets/snippets/go.snippets +++ b/sources_non_forked/vim-snippets/snippets/go.snippets @@ -64,13 +64,13 @@ snippet inf "full interface " } snippet if "if condition" - if ${1:/* condition */} { + if $1 { ${2:${VISUAL}} } snippet ife "if else condition" - if ${1:/* condition */} { + if $1 { ${2:${VISUAL}} } else { ${0} diff --git a/sources_non_forked/vim-snippets/snippets/haml.snippets b/sources_non_forked/vim-snippets/snippets/haml.snippets index b1feaa51..798c555e 100644 --- a/sources_non_forked/vim-snippets/snippets/haml.snippets +++ b/sources_non_forked/vim-snippets/snippets/haml.snippets @@ -26,12 +26,12 @@ snippet mt snippet mts = mail_to ${1:email_address}, ${2:name}, :subject => ${3}, :body => ${4} snippet ife - - if ${1:condition} + - if $1 ${2:${VISUAL}} - else ${0} snippet ifp - - if ${1:condition}.presence? + - if $1.presence? ${0:${VISUAL}} snippet ntc = number_to_currency(${1}) diff --git a/sources_non_forked/vim-snippets/snippets/html.snippets b/sources_non_forked/vim-snippets/snippets/html.snippets index 0ec6cd89..5388dbc8 100644 --- a/sources_non_forked/vim-snippets/snippets/html.snippets +++ b/sources_non_forked/vim-snippets/snippets/html.snippets @@ -441,10 +441,9 @@ snippet html5 ${1:`substitute(vim_snippets#Filename('', 'Page Title'), '^.', '\u&', '')`} - ${2:link} - ${0:body} + $0 snippet html5l @@ -457,7 +456,7 @@ snippet html5l ${3:link} - ${0:body} + $0 snippet i diff --git a/sources_non_forked/vim-snippets/snippets/htmltornado.snippets b/sources_non_forked/vim-snippets/snippets/htmltornado.snippets index 1620e11d..5dd81555 100644 --- a/sources_non_forked/vim-snippets/snippets/htmltornado.snippets +++ b/sources_non_forked/vim-snippets/snippets/htmltornado.snippets @@ -24,11 +24,11 @@ snippet for snippet from {% from ${1:x} import ${0:y} %} snippet if - {% if ${1:condition} %} + {% if $1 %} ${0} {% end %} snippet eif - {% elif ${0:condition} %} + {% elif $0 %} snippet el {% else %} snippet import @@ -50,6 +50,6 @@ snippet try ${0} {% end %} snippet wh - {% while ${1:condition} %} + {% while $1 %} ${0} {% end %} diff --git a/sources_non_forked/vim-snippets/snippets/java.snippets b/sources_non_forked/vim-snippets/snippets/java.snippets index 739f20b7..d3e69684 100644 --- a/sources_non_forked/vim-snippets/snippets/java.snippets +++ b/sources_non_forked/vim-snippets/snippets/java.snippets @@ -142,9 +142,9 @@ snippet ae snippet aae assertArrayEquals("${1:Failure message}", ${2:expecteds}, ${3:actuals}); snippet af - assertFalse("${1:Failure message}", ${2:condition}); + assertFalse("${1:Failure message}", $2); snippet at - assertTrue("${1:Failure message}", ${2:condition}); + assertTrue("${1:Failure message}", $2); snippet an assertNull("${1:Failure message}", ${2:object}); snippet ann @@ -211,7 +211,9 @@ snippet enfor snippet for for (${1}; ${2}; ${3}) ${0} snippet wh - while (${1}) ${0} + while (${1:true}) ${0} +snippet wht + while (true) ${0} ## ## Main method snippet psvm diff --git a/sources_non_forked/vim-snippets/snippets/javascript/javascript.snippets b/sources_non_forked/vim-snippets/snippets/javascript/javascript.snippets index 78c651eb..de1ca113 100644 --- a/sources_non_forked/vim-snippets/snippets/javascript/javascript.snippets +++ b/sources_non_forked/vim-snippets/snippets/javascript/javascript.snippets @@ -62,8 +62,8 @@ snippet ife "if (condition) { ... } else { ... }" ${2} } # tertiary conditional -snippet ter - ${1:/* condition */} ? ${2:/* if true */} : ${0:/* if false */} +snippet ter Ternary: `condition ? true : false` + $1 ? $2: $0 # switch snippet switch switch (${1:expression}) { @@ -107,13 +107,17 @@ snippet forr "reversed for (...) {...}" ${0:${VISUAL}} } snippet wh "(condition) { ... }" - while (${1:/* condition */}) { + while (${1:true}) { + ${0:${VISUAL}} + } +snippet wht "(true) { ... }" + while (true) { ${0:${VISUAL}} } snippet do "do { ... } while (condition)" do { ${0:${VISUAL}} - } while (${1:/* condition */}); + } while ($1); # For in loop snippet fori for (let ${1:prop} in ${2:object}) { diff --git a/sources_non_forked/vim-snippets/snippets/liquid.snippets b/sources_non_forked/vim-snippets/snippets/liquid.snippets index 72a78d0e..e12bf060 100644 --- a/sources_non_forked/vim-snippets/snippets/liquid.snippets +++ b/sources_non_forked/vim-snippets/snippets/liquid.snippets @@ -2,32 +2,32 @@ # https://marketplace.visualstudio.com/items?itemName=killalau.vscode-liquid-snippets snippet if - {% if ${1:condition} %} + {% if $1 %} ${0:${VISUAL}} {% endif %} snippet else {% else %} snippet elsif - {% elsif ${1:condition} %} + {% elsif $1 %} snippet ifelse - {% if ${1:condition} %} + {% if $1 %} ${2} {% else %} ${0} {% endif %} snippet unless - {% unless ${1:condition} %} + {% unless $1 %} ${0:${VISUAL}} {% endunless %} snippet case {% case ${1:variable} %} - {% when ${2:condition} %} + {% when $2 %} ${3} {% else %} ${0} {% endcase %} snippet when - {% when ${1:condition} %} + {% when $1 %} ${0:${VISUAL}} snippet cycle {% cycle '${1:odd}', '${2:even}' %} @@ -102,32 +102,32 @@ snippet javascript snippet comment- {%- comment -%}${0:${VISUAL}}{%- endcomment -%} snippet if- - {%- if ${1:condition} -%} + {%- if $1 -%} ${0:${VISUAL}} {%- endif -%} snippet else- {%- else -%} snippet elsif- - {%- elsif ${1:condition} -%} + {%- elsif $1 -%} snippet ifelse- - {%- if ${1:condition} -%} + {%- if $1 -%} ${2} {%- else -%} ${0} {%- endif -%} snippet unless- - {%- unless ${1:condition} -%} + {%- unless $1 -%} ${0:${VISUAL}} {%- endunless -%} snippet case- {%- case ${1:variable} -%} - {%- when ${2:condition} -%} + {%- when $2 -%} ${3} {%- else -%} ${0} {%- endcase -%} snippet when- - {%- when ${1:condition} -%} + {%- when $1 -%} ${0:${VISUAL}} snippet cycle- {%- cycle '${1:odd}', '${2:even}' -%} diff --git a/sources_non_forked/vim-snippets/snippets/lpc.snippets b/sources_non_forked/vim-snippets/snippets/lpc.snippets index 2a849efa..3410c93b 100644 --- a/sources_non_forked/vim-snippets/snippets/lpc.snippets +++ b/sources_non_forked/vim-snippets/snippets/lpc.snippets @@ -66,8 +66,8 @@ snippet elif snippet ifi if(${1:true}) ${0}; # ternary -snippet t - ${1:/* condition */} ? ${2:a} : ${3:b} +snippet t Ternary: `condition ? true : false` + $1 ? $2 : $0 # switch snippet switch switch(${1:/* variable */}) @@ -115,7 +115,7 @@ snippet forr } # while snippet wh - while(${1:/* condition */}) + while($1) { ${0:${VISUAL}} } @@ -123,7 +123,7 @@ snippet wh snippet do do{ ${0:${VISUAL}} - }while (${1:/* condition */}); + }while ($1); ## ## Functions # function definition diff --git a/sources_non_forked/vim-snippets/snippets/ls.snippets b/sources_non_forked/vim-snippets/snippets/ls.snippets index 7c924e64..822119d9 100644 --- a/sources_non_forked/vim-snippets/snippets/ls.snippets +++ b/sources_non_forked/vim-snippets/snippets/ls.snippets @@ -54,24 +54,24 @@ snippet cla class .. extends .. constructor: .. ${5} # If snippet if - if ${1:condition} + if $1 ${2} # If __ Else snippet ife - if ${1:condition} + if $1 ${2} else ${3} # Else if snippet elif - else if ${1:condition} + else if $1 ${2} # Ternary If snippet ifte - if ${1:condition} then ${2:value} else ${3:other} + if $1 then $2 else $0 # Unless snippet unl - ${1:action} unless ${2:condition} + $1 unless $0 # Switch snippet swi switch ${1:object} diff --git a/sources_non_forked/vim-snippets/snippets/lua.snippets b/sources_non_forked/vim-snippets/snippets/lua.snippets index ff6c0619..87cdc8e4 100644 --- a/sources_non_forked/vim-snippets/snippets/lua.snippets +++ b/sources_non_forked/vim-snippets/snippets/lua.snippets @@ -5,7 +5,7 @@ snippet local local ${1:x} = ${0:1} snippet fun function ${1:fname}(${2:...}) - ${0:-- body} + $0 end snippet for for ${1:i}=${2:1},${3:10} do @@ -13,34 +13,60 @@ snippet for end snippet forp for ${1:i},${2:v} in pairs(${3:table_name}) do - ${0:-- body} + $0 end snippet fori for ${1:i},${2:v} in ipairs(${3:table_name}) do - ${0:-- body} + $0 end snippet if - if ${1:condition} then - ${2:-- body} + if $1 then + $2 end snippet ife - if ${1:condition} then + if $1 then ${2:-- if condition} else ${0:-- else} end snippet elif - elseif ${1:condition} then - ${0:--body} + elseif $1 then + $0 snippet repeat repeat - ${1:--body} - until ${0:condition} + $1 + until $0 snippet while - while ${1:condition} do - ${0:--body} + while $1 do + $0 + end +snippet wh + while ${1:true} do + ${0} + end +snippet wht + while true do + ${0} end snippet print print("${1:string}") +snippet pr + print($0) +snippet prs + print("$0") +snippet prf + print(string.format("${1:%s}"$0)) +snippet wr + io.write($0) +snippet wrs + io.write("$0") +snippet wrf + io.write(string.format("${1:%s}"$0)) +snippet fwr + io.${1:stderr}:write($0) +snippet fwrs + io.${1:stderr}:write("$0") +snippet fwrf + io.${1:stderr}:write(string.format("${2:%s}"$0)) snippet im import "${1:import file}" diff --git a/sources_non_forked/vim-snippets/snippets/mako.snippets b/sources_non_forked/vim-snippets/snippets/mako.snippets index 659caf77..b2ff4052 100644 --- a/sources_non_forked/vim-snippets/snippets/mako.snippets +++ b/sources_non_forked/vim-snippets/snippets/mako.snippets @@ -19,11 +19,11 @@ snippet for ${0:} % endfor snippet if if - % if ${1:condition}: + % if $1: ${0:} % endif snippet ife if/else - % if ${1:condition}: + % if $1: ${2:} % else: ${0:} diff --git a/sources_non_forked/vim-snippets/snippets/markdown.snippets b/sources_non_forked/vim-snippets/snippets/markdown.snippets index 364066cf..39ccecd7 100644 --- a/sources_non_forked/vim-snippets/snippets/markdown.snippets +++ b/sources_non_forked/vim-snippets/snippets/markdown.snippets @@ -67,17 +67,21 @@ snippet <* <`@*`> snippet -snippet ** - **${1:bold}** -snippet __ - __${1:bold}__ -snippet === +snippet ** Bold + **$0** +snippet __ Bold + __$0__ +snippet --- Front matter + --- + $0 + --- +snippet ==== `repeat('=', strlen(getline(line('.') - 3)))` ${0} snippet - - ${0} -snippet --- +snippet ---- `repeat('-', strlen(getline(line('.') - 3)))` ${0} @@ -142,3 +146,11 @@ snippet pullquote {% pullquote %} ${1:text} {" ${2:quote} "} ${0:text} {% endpullquote %} + +# Definition lists +snippet : Definition list + $1 + : $0 +snippet :: Alternate definition list + $1 + - $0 diff --git a/sources_non_forked/vim-snippets/snippets/pandoc.snippets b/sources_non_forked/vim-snippets/snippets/pandoc.snippets index 1dd9e82e..c94e5343 100644 --- a/sources_non_forked/vim-snippets/snippets/pandoc.snippets +++ b/sources_non_forked/vim-snippets/snippets/pandoc.snippets @@ -1,2 +1 @@ extends markdown - diff --git a/sources_non_forked/vim-snippets/snippets/perl.snippets b/sources_non_forked/vim-snippets/snippets/perl.snippets index b318d18c..79ddad43 100644 --- a/sources_non_forked/vim-snippets/snippets/perl.snippets +++ b/sources_non_forked/vim-snippets/snippets/perl.snippets @@ -40,7 +40,7 @@ snippet eif } # Conditional One-line snippet xif - ${1:expression} if ${2:condition}; + $1 if $0; # Unless conditional snippet unless unless (${1}) { @@ -48,7 +48,7 @@ snippet unless } # Unless conditional One-line snippet xunless - ${1:expression} unless ${2:condition}; + $1 unless $0; # Try/Except snippet eval local $@; @@ -65,7 +65,7 @@ snippet wh } # While Loop One-line snippet xwh - ${1:expression} while ${2:condition}; + $1 while $0; # C-style For Loop snippet cfor for (my $${2:var} = 0; $$2 < ${1:count}; $$2${3:++}) { @@ -73,7 +73,7 @@ snippet cfor } # For loop one-line snippet xfor - ${1:expression} for @${2:array}; + $1 for @$0; # Foreach Loop snippet for foreach my $${1:x} (@${2:array}) { @@ -81,7 +81,7 @@ snippet for } # Foreach Loop One-line snippet fore - ${1:expression} foreach @${2:array}; + $1 foreach @$0; # Package snippet package package ${1:`expand('%:p:s?.*lib/??:r:gs?/?::?')`}; diff --git a/sources_non_forked/vim-snippets/snippets/perl6.snippets b/sources_non_forked/vim-snippets/snippets/perl6.snippets index aa740605..e7db89a1 100644 --- a/sources_non_forked/vim-snippets/snippets/perl6.snippets +++ b/sources_non_forked/vim-snippets/snippets/perl6.snippets @@ -33,7 +33,7 @@ snippet eif } # Conditional One-line snippet xif - ${1:expression} if ${2:condition}; + ${1} if $2; # Unless conditional snippet unless unless ${1} { @@ -41,14 +41,14 @@ snippet unless } # Unless conditional One-line snippet xunless - ${1:expression} unless ${2:condition}; + ${1} unless $2; # Ternary conditional snippet tc - ${1:condition} ?? ${2:value-if-true} !! ${3:value-if-false}; + $1 ?? ${2:value-if-true} !! ${3:value-if-false}; # given - when (perl6 switch) snippet switch given ${1:$var} { - when ${2:condition} { + when $2 { ${3:# code block ...} } ${4} diff --git a/sources_non_forked/vim-snippets/snippets/php.snippets b/sources_non_forked/vim-snippets/snippets/php.snippets index c769baab..b0bae1b3 100644 --- a/sources_non_forked/vim-snippets/snippets/php.snippets +++ b/sources_non_forked/vim-snippets/snippets/php.snippets @@ -86,7 +86,7 @@ snippet =?: snippet ?: ${1:true} ? ${2:a} : ${0} snippet t "$retVal = (condition) ? a : b" - $${1:retVal} = (${2:condition}) ? ${3:a} : ${4:b}; + $${1:retVal} = ($2) ? ${3:a} : ${4:b}; # Predefined variables snippet C $_COOKIE['${1:variable}'] @@ -283,7 +283,7 @@ snippet def "define('VARIABLE_NAME', 'definition')" snippet def? ${1}defined('${2}') snippet wh "while (condition) { ... }" - while (${1:/* condition */}) { + while ($1) { ${0:${VISUAL}} } snippet do "do { ... } while (condition)" diff --git a/sources_non_forked/vim-snippets/snippets/plsql.snippets b/sources_non_forked/vim-snippets/snippets/plsql.snippets index 2920758a..6a75f773 100644 --- a/sources_non_forked/vim-snippets/snippets/plsql.snippets +++ b/sources_non_forked/vim-snippets/snippets/plsql.snippets @@ -8,7 +8,7 @@ snippet ps snippet pb create or replace package body ${1:name} as - ${0:-- body} + $0 end; -- end of package body $1; # package procedure spec snippet pps @@ -18,7 +18,7 @@ snippet ppb procedure ${1:name}(${2:args}) as begin - ${0:-- body} + $0 end $2; # package function spec snippet pfs @@ -31,7 +31,7 @@ snippet pfb as l_res $3; begin - ${0:-- body}; + $0; return l_res; end $1; # snow errors diff --git a/sources_non_forked/vim-snippets/snippets/processing.snippets b/sources_non_forked/vim-snippets/snippets/processing.snippets index 798e5458..0fe69022 100644 --- a/sources_non_forked/vim-snippets/snippets/processing.snippets +++ b/sources_non_forked/vim-snippets/snippets/processing.snippets @@ -64,7 +64,7 @@ snippet for }; #loop while snippet wh - while (${1:/* condition */}) { + while ($1) { ${0} } #break diff --git a/sources_non_forked/vim-snippets/snippets/ps1.snippets b/sources_non_forked/vim-snippets/snippets/ps1.snippets index 08de1efd..652f0d86 100644 --- a/sources_non_forked/vim-snippets/snippets/ps1.snippets +++ b/sources_non_forked/vim-snippets/snippets/ps1.snippets @@ -43,13 +43,13 @@ snippet enum # PowerShell if..then snippet if - if (${1:condition}) { - ${2:statement} + if ($1) { + $0 } # PowerShell if..else snippet ife - if ( ${1:condition} ) { + if ( $1 ) { ${2} } else { @@ -58,8 +58,8 @@ snippet ife # PowerShell While Loop snippet while - while (${1:condition}) { - ${2:statement} + while ($1) { + $0 } # PowerShell Filter..Sort @@ -69,7 +69,7 @@ snippet filtersort # PowerShell foreach snippet foreach foreach ( $${1:iterator} in $${2:collection} ) { - ${3:statement} + $0 } # PowerShell export-csv diff --git a/sources_non_forked/vim-snippets/snippets/python.snippets b/sources_non_forked/vim-snippets/snippets/python.snippets index b8f3822a..75302a49 100644 --- a/sources_non_forked/vim-snippets/snippets/python.snippets +++ b/sources_non_forked/vim-snippets/snippets/python.snippets @@ -28,14 +28,14 @@ snippet sk "skip unittests" b @unittest.skip(${1:skip_reason}) snippet wh - while ${1:condition}: + while $1: ${0:${VISUAL}} # dowh - does the same as do...while in other languages snippet dowh while True: ${1} - if ${0:condition}: + if $0: break snippet with @@ -115,13 +115,13 @@ snippet property # Ifs snippet if - if ${1:condition}: + if $1: ${0:${VISUAL}} snippet el else: ${0:${VISUAL}} snippet ei - elif ${1:condition}: + elif $1: ${0:${VISUAL}} # Match @@ -508,3 +508,16 @@ snippet numeric "methods for emulating a numeric type" b def __coerce__(self, other): ${25:pass} +# Printing +snippet pr + print($0) +snippet prs + print("$0") +snippet prf + print(f"$0") +snippet fpr + print($0, file=${1:sys.stderr}) +snippet fprs + print("$0", file=${1:sys.stderr}) +snippet fprf + print(f"$0", file=${1:sys.stderr}) diff --git a/sources_non_forked/vim-snippets/snippets/r.snippets b/sources_non_forked/vim-snippets/snippets/r.snippets index 9dbe0f39..46f316c9 100644 --- a/sources_non_forked/vim-snippets/snippets/r.snippets +++ b/sources_non_forked/vim-snippets/snippets/r.snippets @@ -11,7 +11,7 @@ snippet source # conditionals snippet if - if (${1:condition}) { + if ($1) { ${0} } snippet el @@ -19,14 +19,18 @@ snippet el ${0} } snippet ei - else if (${1:condition}) { + else if ($1) { ${0} } # loops snippet wh - while(${1}) { - ${2} + while(${1:true}) { + ${0} + } +snippet wht + while(true) { + ${0} } snippet for for (${1:item} in ${2:list}) { diff --git a/sources_non_forked/vim-snippets/snippets/rmd.snippets b/sources_non_forked/vim-snippets/snippets/rmd.snippets index 96b0ea0e..13d55363 100644 --- a/sources_non_forked/vim-snippets/snippets/rmd.snippets +++ b/sources_non_forked/vim-snippets/snippets/rmd.snippets @@ -6,6 +6,8 @@ # vim's `"*` register---i.e., the contents of the # system clipboard---to insert text. +extends markdown + # Insert Title Block snippet %% % ${1:`Filename('', 'title')`} @@ -20,70 +22,12 @@ snippet %%* ${4} -# Insert Definition List -snippet :: - ${1:term} - ~ ${2:definition} - -# Underline with `=`s or `-`s -snippet === - `repeat('=', strlen(getline(line(".") - 1)))` - - ${1} -snippet --- - `repeat('-', strlen(getline(line(".") - 1)))` - - ${1} - -# Links and their kin -# ------------------- -# -# (These don't play very well with delimitMate) -# - -snippet [ - [${1:link}](http://${2:url} "${3:title}")${4} -snippet [* - [${1:link}](${2:`@*`} "${3:title}")${4} - -snippet [: - [${1:id}]: http://${2:url} "${3:title}" -snippet [:* - [${1:id}]: ${2:`@*`} "${3:title}" - -snippet [@ - [${1:link}](mailto:${2:email})${3} -snippet [@* - [${1:link}](mailto:${2:`@*`})${3} - -snippet [:@ - [${1:id}]: mailto:${2:email} "${3:title}" -snippet [:@* - [${1:id}]: mailto:${2:`@*`} "${3:title}" - -snippet ![ - ![${1:alt}](${2:url} "${3:title}")${4} -snippet ![* - ![${1:alt}](${2:`@*`} "${3:title}")${4} - -snippet ![: - ![${1:id}]: ${2:url} "${3:title}" -snippet ![:* - ![${1:id}]: ${2:`@*`} "${3:title}" - -snippet [^: - [^${1:id}]: ${2:note} -snippet [^:* - [^${1:id}]: ${2:`@*`} - -# - # library() snippet req require(${1:}, quietly = TRUE) # If Condition snippet if - if ( ${1:condition} ) + if ( $1 ) { ${2:} } @@ -107,7 +51,7 @@ snippet fun snippet re repeat{ ${2:} - if(${1:condition}) break + if($1) break } # matrix diff --git a/sources_non_forked/vim-snippets/snippets/rst.snippets b/sources_non_forked/vim-snippets/snippets/rst.snippets index 31b4fec2..8279af5a 100644 --- a/sources_non_forked/vim-snippets/snippets/rst.snippets +++ b/sources_non_forked/vim-snippets/snippets/rst.snippets @@ -1,7 +1,7 @@ # rst snippet : - :${1:field name}: ${0:field body} + :${1:field name}: $0 snippet * *${1:Emphasis}* ${0} snippet ** diff --git a/sources_non_forked/vim-snippets/snippets/ruby.snippets b/sources_non_forked/vim-snippets/snippets/ruby.snippets index 20c789b5..34d56fb2 100644 --- a/sources_non_forked/vim-snippets/snippets/ruby.snippets +++ b/sources_non_forked/vim-snippets/snippets/ruby.snippets @@ -34,11 +34,11 @@ snippet # # => snippet case case ${1:object} - when ${2:condition} + when $2 ${0} end snippet when - when ${1:condition} + when $1 ${0:${VISUAL}} snippet def def ${1:method_name} @@ -55,46 +55,46 @@ snippet descendants end end snippet if - if ${1:condition} + if $1 ${0:${VISUAL}} end snippet ife - if ${1:condition} + if $1 ${2:${VISUAL}} else ${0} end snippet eif - elsif ${1:condition} + elsif $1 ${0:${VISUAL}} snippet ifee - if ${1:condition} + if $1 $2 - elsif ${3:condition} + elsif $3 $4 else $0 end snippet unless - unless ${1:condition} + unless $1 ${0:${VISUAL}} end snippet unlesse - unless ${1:condition} + unless $1 $2 else $0 end snippet unlesee - unless ${1:condition} + unless $1 $2 - elsif ${3:condition} + elsif $3 $4 else $0 end snippet wh - while ${1:condition} + while $1 ${0:${VISUAL}} end snippet for @@ -102,7 +102,7 @@ snippet for ${0} end snippet until - until ${1:condition} + until $1 ${0:${VISUAL}} end snippet cla class .. end diff --git a/sources_non_forked/vim-snippets/snippets/rust.snippets b/sources_non_forked/vim-snippets/snippets/rust.snippets index 5e9eb2b1..04f05dd6 100644 --- a/sources_non_forked/vim-snippets/snippets/rust.snippets +++ b/sources_non_forked/vim-snippets/snippets/rust.snippets @@ -147,7 +147,7 @@ snippet loop "loop {}" b ${0:${VISUAL}} } snippet wh "while loop" - while ${1:condition} { + while $1 { ${0:${VISUAL}} } snippet whl "while let (...)" diff --git a/sources_non_forked/vim-snippets/snippets/sass.snippets b/sources_non_forked/vim-snippets/snippets/sass.snippets index 30bac6c7..992341e7 100644 --- a/sources_non_forked/vim-snippets/snippets/sass.snippets +++ b/sources_non_forked/vim-snippets/snippets/sass.snippets @@ -13,15 +13,15 @@ snippet fun @function ${1:name}(${2:args}) ${0} snippet if - @if ${1:condition} + @if $1 ${0:${VISUAL}} snippet ife - @if ${1:condition} + @if $1 ${2:${VISUAL}} @else ${0} snippet eif - @else if ${1:condition} + @else if $1 ${0:${VISUAL}} snippet for @for ${1:$i} from ${2:1} through ${3:3} diff --git a/sources_non_forked/vim-snippets/snippets/scss.snippets b/sources_non_forked/vim-snippets/snippets/scss.snippets index 998a1200..475c2b38 100644 --- a/sources_non_forked/vim-snippets/snippets/scss.snippets +++ b/sources_non_forked/vim-snippets/snippets/scss.snippets @@ -17,17 +17,17 @@ snippet fun ${0} } snippet if - @if ${1:condition} { + @if $1 { ${0} } snippet ife - @if ${1:condition} { + @if $1 { ${2} } @else { ${0} } snippet eif - @else if ${1:condition} { + @else if $1 { ${0} } snippet for diff --git a/sources_non_forked/vim-snippets/snippets/sh.snippets b/sources_non_forked/vim-snippets/snippets/sh.snippets index b92ae952..ef94e683 100644 --- a/sources_non_forked/vim-snippets/snippets/sh.snippets +++ b/sources_non_forked/vim-snippets/snippets/sh.snippets @@ -1,9 +1,9 @@ -# Shebang. Executing bash via /usr/bin/env makes scripts more portable. +# Shebang snippet #! - #!/usr/bin/env sh + #!/bin/sh snippet s#! - #!/usr/bin/env sh + #!/bin/sh set -eu snippet safe @@ -18,11 +18,11 @@ snippet sbash IFS=$'\n\t' snippet if - if [[ ${1:condition} ]]; then + if [ $1 ]; then ${0:${VISUAL}} fi snippet elif - elif [[ ${1:condition} ]]; then + elif [ $1 ]; then ${0:${VISUAL}} snippet for for (( ${2:i} = 0; $2 < ${1:count}; $2++ )); do @@ -33,11 +33,15 @@ snippet fori ${0:${VISUAL}} done snippet wh - while [[ ${1:condition} ]]; do + while [ $1 ]; do + ${0:${VISUAL}} + done +snippet wht + while true; do ${0:${VISUAL}} done snippet until - until [[ ${1:condition} ]]; do + until [ $1 ]; do ${0:${VISUAL}} done snippet case @@ -97,10 +101,10 @@ snippet root snippet fun-sh ${1:function_name}() { - ${0:#function_body} + $0 } snippet fun function ${1:function_name}() { - ${0:#function_body} + $0 } diff --git a/sources_non_forked/vim-snippets/snippets/tex.snippets b/sources_non_forked/vim-snippets/snippets/tex.snippets index e85e95f8..25f8f37f 100644 --- a/sources_non_forked/vim-snippets/snippets/tex.snippets +++ b/sources_non_forked/vim-snippets/snippets/tex.snippets @@ -6,6 +6,27 @@ snippet dcl \documentclass{} #documentclass with options snippet dclo \documentclass[]{} \\documentclass[${1:options}]{${2:class}} ${0} + +snippet tmplt "Template" + \\documentclass{${1:article}} + + \\usepackage{import} + \\usepackage{pdfpages} + \\usepackage{transparent} + \\usepackage{xcolor} + $2 + + \\newcommand{\incfig}[2][1]{% + \def\svgwidth{#1\columnwidth} + \import{./figures/}{#2.pdf_tex} + } + $3 + \\pdfsuppresswarningpagegroup=1 + + \\begin{document} + $0 + \\end{document} + #newcommand snippet nc \newcommand \\newcommand{\\${1:cmd}}[${2:opt}]{${3:realcmd}} ${0} diff --git a/sources_non_forked/vim-snippets/snippets/yii.snippets b/sources_non_forked/vim-snippets/snippets/yii.snippets index 1f9fc6f7..1aecad29 100644 --- a/sources_non_forked/vim-snippets/snippets/yii.snippets +++ b/sources_non_forked/vim-snippets/snippets/yii.snippets @@ -144,7 +144,7 @@ snippet yrp #----------------Yii Model----------------------------- #Yii Model count snippet ycountm - ${1:ModelName}::model()->count(${2:condition}, array('${3:key}'=>${0:value})); + ${1:ModelName}::model()->count($2, array('${3:key}'=>${0:value})); #Yii Model countBySql snippet ycountbs @@ -152,35 +152,35 @@ snippet ycountbs #Yii Model updateAll snippet yupdatea - ${1:ModelName}::model()->updateAll(${2:array('attributes')}, ${3:condition},array('${4:key}'=>${0:value})); + ${1:ModelName}::model()->updateAll(${2:array('attributes')}, $3,array('${4:key}'=>${0:value})); #Yii Model updateByPk snippet yupdatebp - ${1:ModelName}::model()->updateByPk(${2:pk}, ${3:array('attributes')}, ${4:condition},array('${5:key}'=>${0:value})); + ${1:ModelName}::model()->updateByPk(${2:pk}, ${3:array('attributes')}, $4,array('${5:key}'=>${0:value})); #Yii Model deleteAll snippet ydela - ${1:ModelName}::model()->deleteAll(${2:condition},array('${3:key}'=>${0:value})); + ${1:ModelName}::model()->deleteAll($2,array('${3:key}'=>${0:value})); #Yii Model deleteByPk snippet ydelbp - ${1:ModelName}::model()->deleteByPk(${2:pk}, ${3:condition}, array('${4:key}'=>${0:value})); + ${1:ModelName}::model()->deleteByPk(${2:pk}, $3, array('${4:key}'=>${0:value})); #Yii Model find snippet yfind - ${1:ModelName}::model()->find(${2:condition},array('${3:key}'=>${0:value})); + ${1:ModelName}::model()->find($2,array('${3:key}'=>${0:value})); #Yii Model findAll snippet yfinda - ${1:ModelName}::model()->findAll(${2:condition},array('${3:key}'=>${0:value})); + ${1:ModelName}::model()->findAll($2,array('${3:key}'=>${0:value})); #Yii Model findByPk snippet yfindbp - ${1:ModelName}::model()->findByPk(${2:pk}, ${3:condition}, array('${4:key}'=>${0:value})); + ${1:ModelName}::model()->findByPk(${2:pk}, $3, array('${4:key}'=>${0:value})); #Yii Model findAllByPk snippet yfindabp - ${1:ModelName}::model()->findAllByPk(${2:pk}, ${3:condition},array('${4:key}'=>${0:value})); + ${1:ModelName}::model()->findAllByPk(${2:pk}, $3,array('${4:key}'=>${0:value})); #Yii Model findBySql snippet yfindbs @@ -188,11 +188,11 @@ snippet yfindbs #Yii Model findAllByAttributes snippet yfindaba - ${1:ModelName}::model()->findAllByAttributes(array('${2:attributeName}'=>${3:attributeValue}), ${4:condition}, array('${5:key}'=>${0:value})); + ${1:ModelName}::model()->findAllByAttributes(array('${2:attributeName}'=>${3:attributeValue}), $4, array('${5:key}'=>${0:value})); #Yii Model exists snippet yexists - ${1:ModelName}::model()->exists(${2:condition}, array('${3:key}'=>${0:value})); + ${1:ModelName}::model()->exists($2, array('${3:key}'=>${0:value})); #Yii Create model class snippet ymodel diff --git a/sources_non_forked/vim-snippets/snippets/zsh.snippets b/sources_non_forked/vim-snippets/snippets/zsh.snippets index a8173c26..485766fe 100644 --- a/sources_non_forked/vim-snippets/snippets/zsh.snippets +++ b/sources_non_forked/vim-snippets/snippets/zsh.snippets @@ -1,19 +1,21 @@ # #!/bin/zsh +extends bash + snippet #! - #!/bin/zsh + #!/usr/bin/env zsh snippet if - if ${1:condition}; then + if $1; then ${0:${VISUAL}} fi snippet ife - if ${1:condition}; then + if $1; then ${2:${VISUAL}} else ${0:# statements} fi snippet eif - elif ${1:condition}; then + elif $1; then ${0:${VISUAL}} snippet for for (( ${2:i} = 0; $2 < ${1:count}; $2++ )); do @@ -28,11 +30,11 @@ snippet fore ${0:${VISUAL}} done snippet wh - while ${1:condition}; do + while $1; do ${0:${VISUAL}} done snippet until - until ${1:condition}; do + until $1; do ${0:${VISUAL}} done snippet repeat From 950b470eb9aa555b7b8a89ba294ce9fc8f7a56e6 Mon Sep 17 00:00:00 2001 From: Amir Date: Wed, 21 Sep 2022 10:47:47 +0200 Subject: [PATCH 3/3] Added jedi-vim --- README.md | 1 + .../jedi-vim/.github/FUNDING.yml | 1 + .../jedi-vim/.github/ISSUE_TEMPLATE.md | 44 + .../jedi-vim/.github/workflows/ci.yml | 63 + sources_non_forked/jedi-vim/.gitignore | 8 + sources_non_forked/jedi-vim/.gitmodules | 6 + sources_non_forked/jedi-vim/.travis.yml | 31 + sources_non_forked/jedi-vim/AUTHORS.txt | 61 + sources_non_forked/jedi-vim/CONTRIBUTING.md | 12 + sources_non_forked/jedi-vim/LICENSE.txt | 21 + sources_non_forked/jedi-vim/Makefile | 35 + sources_non_forked/jedi-vim/README.rst | 293 ++++ .../jedi-vim/after/ftplugin/python/jedi.vim | 3 + .../jedi-vim/after/syntax/python.vim | 34 + .../jedi-vim/autoload/health/jedi.vim | 4 + sources_non_forked/jedi-vim/autoload/jedi.vim | 732 ++++++++++ sources_non_forked/jedi-vim/codecov.yml | 7 + sources_non_forked/jedi-vim/doc/jedi-vim.txt | 578 ++++++++ .../jedi-vim/doc/logotype-a.svg | 140 ++ .../jedi-vim/ftplugin/python/jedi.vim | 53 + sources_non_forked/jedi-vim/plugin/jedi.vim | 77 ++ .../jedi-vim/pythonx/jedi_vim.py | 1211 +++++++++++++++++ .../jedi-vim/pythonx/jedi_vim_debug.py | 96 ++ sources_non_forked/jedi-vim/setup.cfg | 5 + sources_non_forked/jedi-vim/test/_utils.vim | 11 + .../jedi-vim/test/test_integration.py | 65 + sources_non_forked/jedi-vim/test/vimrc | 8 + .../jedi-vim/test/vspec/choose-venv.vim | 29 + .../jedi-vim/test/vspec/completions.vim | 131 ++ .../test/vspec/completions_disabled.vim | 20 + .../jedi-vim/test/vspec/documentation.vim | 34 + .../jedi-vim/test/vspec/goto.vim | 177 +++ .../jedi-vim/test/vspec/jedi_debug_info.vim | 13 + .../jedi-vim/test/vspec/pyimport.vim | 34 + .../jedi-vim/test/vspec/signatures.vim | 143 ++ update_plugins.py | 1 + vimrcs/plugins_config.vim | 11 + 37 files changed, 4193 insertions(+) create mode 100644 sources_non_forked/jedi-vim/.github/FUNDING.yml create mode 100644 sources_non_forked/jedi-vim/.github/ISSUE_TEMPLATE.md create mode 100644 sources_non_forked/jedi-vim/.github/workflows/ci.yml create mode 100644 sources_non_forked/jedi-vim/.gitignore create mode 100644 sources_non_forked/jedi-vim/.gitmodules create mode 100644 sources_non_forked/jedi-vim/.travis.yml create mode 100644 sources_non_forked/jedi-vim/AUTHORS.txt create mode 100644 sources_non_forked/jedi-vim/CONTRIBUTING.md create mode 100644 sources_non_forked/jedi-vim/LICENSE.txt create mode 100644 sources_non_forked/jedi-vim/Makefile create mode 100644 sources_non_forked/jedi-vim/README.rst create mode 100644 sources_non_forked/jedi-vim/after/ftplugin/python/jedi.vim create mode 100644 sources_non_forked/jedi-vim/after/syntax/python.vim create mode 100644 sources_non_forked/jedi-vim/autoload/health/jedi.vim create mode 100644 sources_non_forked/jedi-vim/autoload/jedi.vim create mode 100644 sources_non_forked/jedi-vim/codecov.yml create mode 100644 sources_non_forked/jedi-vim/doc/jedi-vim.txt create mode 100644 sources_non_forked/jedi-vim/doc/logotype-a.svg create mode 100644 sources_non_forked/jedi-vim/ftplugin/python/jedi.vim create mode 100644 sources_non_forked/jedi-vim/plugin/jedi.vim create mode 100644 sources_non_forked/jedi-vim/pythonx/jedi_vim.py create mode 100644 sources_non_forked/jedi-vim/pythonx/jedi_vim_debug.py create mode 100644 sources_non_forked/jedi-vim/setup.cfg create mode 100644 sources_non_forked/jedi-vim/test/_utils.vim create mode 100644 sources_non_forked/jedi-vim/test/test_integration.py create mode 100644 sources_non_forked/jedi-vim/test/vimrc create mode 100644 sources_non_forked/jedi-vim/test/vspec/choose-venv.vim create mode 100644 sources_non_forked/jedi-vim/test/vspec/completions.vim create mode 100644 sources_non_forked/jedi-vim/test/vspec/completions_disabled.vim create mode 100644 sources_non_forked/jedi-vim/test/vspec/documentation.vim create mode 100644 sources_non_forked/jedi-vim/test/vspec/goto.vim create mode 100644 sources_non_forked/jedi-vim/test/vspec/jedi_debug_info.vim create mode 100644 sources_non_forked/jedi-vim/test/vspec/pyimport.vim create mode 100644 sources_non_forked/jedi-vim/test/vspec/signatures.vim diff --git a/README.md b/README.md index 21e939a2..f4b2173e 100644 --- a/README.md +++ b/README.md @@ -109,6 +109,7 @@ I recommend reading the docs of these plugins to understand them better. Each pl * [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. +* [jedi-vim](https://github.com/davidhalter/jedi-vim) A great Python autocompletion library for VIM. ## Included color schemes diff --git a/sources_non_forked/jedi-vim/.github/FUNDING.yml b/sources_non_forked/jedi-vim/.github/FUNDING.yml new file mode 100644 index 00000000..418e47a8 --- /dev/null +++ b/sources_non_forked/jedi-vim/.github/FUNDING.yml @@ -0,0 +1 @@ +github: [davidhalter] diff --git a/sources_non_forked/jedi-vim/.github/ISSUE_TEMPLATE.md b/sources_non_forked/jedi-vim/.github/ISSUE_TEMPLATE.md new file mode 100644 index 00000000..582f51f5 --- /dev/null +++ b/sources_non_forked/jedi-vim/.github/ISSUE_TEMPLATE.md @@ -0,0 +1,44 @@ +### Issue + + + +### Steps to reproduce + + + +### Output of “:verbose JediDebugInfo” + + diff --git a/sources_non_forked/jedi-vim/.github/workflows/ci.yml b/sources_non_forked/jedi-vim/.github/workflows/ci.yml new file mode 100644 index 00000000..235f429b --- /dev/null +++ b/sources_non_forked/jedi-vim/.github/workflows/ci.yml @@ -0,0 +1,63 @@ +name: ci +on: [push, pull_request] + +jobs: + tests: + runs-on: ubuntu-20.04 + steps: + - name: Checkout code + uses: actions/checkout@v2 + with: + submodules: recursive + + - name: Setup + run: | + sudo pip install pytest + vim --version + + #- name: Setup tmate session + # uses: mxschmitt/action-tmate@v3 + + - name: Run tests + run: 'make test' + + code-quality: + runs-on: ubuntu-20.04 + steps: + - name: Checkout code + uses: actions/checkout@v2 + with: + submodules: recursive + + - name: Run tests + run: | + vim --version + make check + + coverage: + runs-on: ubuntu-20.04 + + steps: + - name: Checkout code + uses: actions/checkout@v2 + with: + submodules: recursive + + - name: Install dependencies + run: | + sudo add-apt-repository ppa:neovim-ppa/stable -y + sudo apt-get update -q + sudo apt-get install neovim -y + + sudo pip install pynvim pytest-cov + sudo pip list + nvim --version + + - name: Run tests + run: | + make --keep-going test_coverage BUILD_VIRTUAL_ENV=$VIRTUAL_ENV + + - name: Upload coverage data + run: | + coverage xml + bash <(curl -s https://codecov.io/bash) -X fix -f coverage.xml -F py${TRAVIS_PYTHON_VERSION//./} diff --git a/sources_non_forked/jedi-vim/.gitignore b/sources_non_forked/jedi-vim/.gitignore new file mode 100644 index 00000000..ebe32309 --- /dev/null +++ b/sources_non_forked/jedi-vim/.gitignore @@ -0,0 +1,8 @@ +*~ +*.sw? +*.py[cod] +.ropeproject +doc/tags +.pytest-cache +build +.coverage* diff --git a/sources_non_forked/jedi-vim/.gitmodules b/sources_non_forked/jedi-vim/.gitmodules new file mode 100644 index 00000000..04d8fe61 --- /dev/null +++ b/sources_non_forked/jedi-vim/.gitmodules @@ -0,0 +1,6 @@ +[submodule "jedi"] + path = pythonx/jedi + url = https://github.com/davidhalter/jedi.git +[submodule "pythonx/parso"] + path = pythonx/parso + url = https://github.com/davidhalter/parso.git diff --git a/sources_non_forked/jedi-vim/.travis.yml b/sources_non_forked/jedi-vim/.travis.yml new file mode 100644 index 00000000..7c2db150 --- /dev/null +++ b/sources_non_forked/jedi-vim/.travis.yml @@ -0,0 +1,31 @@ +dist: bionic +language: python +python: 3.8 +env: + - ENV=test + - ENV=check + - ENV=test_coverage +install: + - | + if [ "$ENV" = "test" ]; then + pip install pytest + elif [ "$ENV" = "test_coverage" ]; then + sudo add-apt-repository ppa:neovim-ppa/stable -y + sudo apt-get update -q + sudo apt-get install neovim -y + + pip install pynvim pytest-cov + pip list + nvim --version + else + vim --version + fi +script: + - make --keep-going "$ENV" BUILD_VIRTUAL_ENV=$VIRTUAL_ENV + +after_script: + - | + if [ "$ENV" = "test_coverage" ]; then + coverage xml + travis_retry bash <(curl -s https://codecov.io/bash) -X fix -f coverage.xml -F py${TRAVIS_PYTHON_VERSION//./} + fi diff --git a/sources_non_forked/jedi-vim/AUTHORS.txt b/sources_non_forked/jedi-vim/AUTHORS.txt new file mode 100644 index 00000000..0dc43efe --- /dev/null +++ b/sources_non_forked/jedi-vim/AUTHORS.txt @@ -0,0 +1,61 @@ +Main Authors +============ + +David Halter (@davidhalter) + + +Contributors (in order of contributions) +======================================== + +Patrice Peterson (@runiq) +tek (@tek) +heavenshell (@heavenshell) +Danilo Bargen (@dbrgn) +mattn (@mattn) +Enrico Batista da Luz (@ricobl) +coot (@coot) +Artur Dryomov (@ming13) +andviro (@andviro) +Jean-Louis Fuchs (@ganwell) +Mathieu Comandon (@strycore) +Nick Hurley (@todesschaf) +gpoulin (@gpoulin) +Akinori Hattori (@hattya) +Luper Rouch (@flupke) +Matthew Moses (@mlmoses) +Tyler Wymer (@twymer) +Artem Nezvigin (@artnez) +rogererens (@rogererens) +Emily Strickland (@emilyst) +Tin Tvrtković (@Tinche) +Zekeriya Koc (@zekzekus) +ethinx (@ethinx) +Wouter Overmeire (@lodagro) +Stephen J. Fuhry (@fuhrysteve) +Sheng Yun (@ShengYun) +Yann Thomas-Gérard (@inside) +Colin Su (@littleq0903) +Arthur Jaron (@eyetracker) +Justin M. Keyes (@justinmk) +nagev (@np1) +Chris Lasher (@gotgenes) +Doan Thanh Nam (@tndoan) +Markus Koller (@toupeira) +Justin Cheevers @justincheevers +Talha Ahmed (@talha81) +Matthew Tylee Atkinson (@matatk) +Pedro Ferrari (@petobens) +Daniel Hahler (@blueyed) +Dave Honneffer (@pearofducks) +Bagrat Aznauryan (@n9code) +Tomoyuki Kashiro (@kashiro) +Tommy Allen (@tweekmonster) +Mingliang (@Aulddays) +Brian Mego (@brianmego) +Stevan Milic (@stevanmilic) +Konstantin Glukhov (@Konstantin-Glukhov) +Seungchan An (@SeungChan92) +Thomas Blauth (@ThomasBlauth) +James Cherti (@jamescherti) + +@something are github user names. diff --git a/sources_non_forked/jedi-vim/CONTRIBUTING.md b/sources_non_forked/jedi-vim/CONTRIBUTING.md new file mode 100644 index 00000000..285eb308 --- /dev/null +++ b/sources_non_forked/jedi-vim/CONTRIBUTING.md @@ -0,0 +1,12 @@ +# We <3 pull requests! + + 1. Fork the Repo on github. + 2. Add yourself to AUTHORS.txt + 3. Add a test if possible. + 4. Push to your fork and submit a pull request. + +Please use PEP8 as a Python code style. For VIM, just try to style your +code similar to the jedi-vim code that is already there. + +# Bug reports +Please include the output of `:version` and `:JediDebugInfo`. diff --git a/sources_non_forked/jedi-vim/LICENSE.txt b/sources_non_forked/jedi-vim/LICENSE.txt new file mode 100644 index 00000000..12f223fc --- /dev/null +++ b/sources_non_forked/jedi-vim/LICENSE.txt @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) <2013> + +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/jedi-vim/Makefile b/sources_non_forked/jedi-vim/Makefile new file mode 100644 index 00000000..02a19917 --- /dev/null +++ b/sources_non_forked/jedi-vim/Makefile @@ -0,0 +1,35 @@ +BUILD_VIRTUAL_ENV:=build/venv + +test: + pytest + +test_nvim: + VSPEC_VIM=nvim pytest + +test_coverage: export PYTEST_ADDOPTS:=--cov pythonx --cov test --cov-report=term-missing:skip-covered +test_coverage: test_nvim + +$(dir $(BUILD_VIRTUAL_ENV)): + mkdir -p $@ + +$(BUILD_VIRTUAL_ENV): | $(dir $(BUILD_VIRTUAL_ENV)) + python -m venv $@ + +$(BUILD_VIRTUAL_ENV)/bin/vint: | $(BUILD_VIRTUAL_ENV) + $|/bin/python -m pip install vim-vint==0.3.21 + +$(BUILD_VIRTUAL_ENV)/bin/flake8: | $(BUILD_VIRTUAL_ENV) + $|/bin/python -m pip install -q flake8==3.7.8 + +vint: $(BUILD_VIRTUAL_ENV)/bin/vint + $(BUILD_VIRTUAL_ENV)/bin/vint after autoload ftplugin plugin + +flake8: $(BUILD_VIRTUAL_ENV)/bin/flake8 + $(BUILD_VIRTUAL_ENV)/bin/flake8 pythonx/jedi_*.py + +check: vint flake8 + +clean: + rm -rf build + +.PHONY: test check clean vint flake8 diff --git a/sources_non_forked/jedi-vim/README.rst b/sources_non_forked/jedi-vim/README.rst new file mode 100644 index 00000000..ac82362c --- /dev/null +++ b/sources_non_forked/jedi-vim/README.rst @@ -0,0 +1,293 @@ +.. image:: https://github.com/davidhalter/jedi-vim/blob/master/doc/logotype-a.svg + +################################################# +jedi-vim - awesome Python autocompletion with VIM +################################################# + +.. image:: https://travis-ci.org/davidhalter/jedi-vim.svg?branch=master + :target: https://travis-ci.org/davidhalter/jedi-vim + :alt: Travis-CI build status + +jedi-vim is a VIM binding to the autocompletion library +`Jedi `_. + +Here are some pictures: + +.. image:: https://github.com/davidhalter/jedi/raw/master/docs/_screenshots/screenshot_complete.png + +Completion for almost anything (Ctrl+Space). + +.. image:: https://github.com/davidhalter/jedi/raw/master/docs/_screenshots/screenshot_function.png + +Display of function/class bodies, docstrings. + +.. image:: https://github.com/davidhalter/jedi/raw/master/docs/_screenshots/screenshot_pydoc.png + +Documentation (Pydoc) support (with highlighting, Shift+k). + +There is also support for goto and renaming. + + +Get the latest from `github `_. + +Documentation +============= + +Documentation is available in your vim: ``:help jedi-vim``. You can also look +it up `on github `_. + +You can read the Jedi library documentation `here `_. + +If you want to report issues, just use the github issue tracker. In case of +questions about the software, please use `stackoverflow +`_ and tag your question with ``jedi-vim``. + + +Contributing +============ + +We love Pull Requests! Read the instructions in ``CONTRIBUTING.md``. + + +Features +======== + +The Jedi library understands most of Python's core features. From decorators to +generators, there is broad support. + +Apart from that, jedi-vim supports the following commands + +- Completion ```` +- Goto assignment ``g`` (typical goto function) +- Goto definition ``d`` (follow identifier as far as possible, + includes imports and statements) +- Goto (typing) stub ``s`` +- Show Documentation/Pydoc ``K`` (shows a popup with assignments) +- Renaming ``r`` +- Usages ``n`` (shows all the usages of a name) +- Open module, e.g. ``:Pyimport os`` (opens the ``os`` module) + + +Installation +============ + +Requirements +------------ +You need a VIM version that was compiled with Python 2.7 or later +(``+python`` or ``+python3``). You can check this from within VIM using +``:python3 import sys; print(sys.version)`` (use ``:python`` for Python 2). + +Manual installation +------------------- + +You might want to use `pathogen `_ or +`Vundle `_ to install jedi-vim. + +The first thing you need after that is an up-to-date version of Jedi. Install +``git submodule update --init --recursive`` in your jedi-vim repository. + +Example installation command using Pathogen: + +.. code-block:: sh + + git clone --recursive https://github.com/davidhalter/jedi-vim.git ~/.vim/bundle/jedi-vim + +Example installation using Vundle: + +Add the following line in your `~/.vimrc` + +.. code-block:: vim + + Plugin 'davidhalter/jedi-vim' + +For installing Jedi, ``pip install jedi`` will also work, but you might run +into issues when working in virtual environments. Please use git submodules. + + +Installation with your distribution +----------------------------------- + +On Arch Linux, you can also install jedi-vim from official repositories as +`vim-jedi `__. +It is also available on +`Debian (≥8) `__ and +`Ubuntu (≥14.04) `__ as +vim-python-jedi. +On Fedora Linux, it is available as +`vim-jedi `__. + +Please note that this version might be quite old compared to using jedi-vim +from Git. + +Caveats +------- + +Note that the `python-mode `_ VIM plugin seems +to conflict with jedi-vim, therefore you should disable it before enabling +jedi-vim. + +To enjoy the full features of jedi-vim, you should have VIM >= 7.3, compiled with +``+conceal`` (which is not the case on some platforms, including OS X). If your VIM +does not meet these requirements, the parameter recommendation list may not appear +when you type an open bracket after a function name. Please read +`the documentation `_ +for details. + + +Settings +======== + +Jedi is by default automatically initialized. If you don't want that I suggest +you disable the auto-initialization in your ``.vimrc``: + +.. code-block:: vim + + let g:jedi#auto_initialization = 0 + +There are also some VIM options (like ``completeopt`` and key defaults) which +are automatically initialized, but you can skip this: + +.. code-block:: vim + + let g:jedi#auto_vim_configuration = 0 + + +You can make jedi-vim use tabs when going to a definition etc: + +.. code-block:: vim + + let g:jedi#use_tabs_not_buffers = 1 + +If you are a person who likes to use VIM-splits, you might want to put this in your ``.vimrc``: + +.. code-block:: vim + + let g:jedi#use_splits_not_buffers = "left" + +This options could be "left", "right", "top", "bottom" or "winwidth". It will decide the direction where the split open. + +Jedi automatically starts the completion, if you type a dot, e.g. ``str.``, if +you don't want this: + +.. code-block:: vim + + let g:jedi#popup_on_dot = 0 + +Jedi selects the first line of the completion menu: for a better typing-flow +and usually saves one keypress. + +.. code-block:: vim + + let g:jedi#popup_select_first = 0 + +Jedi displays function call signatures in insert mode in real-time, highlighting +the current argument. The call signatures can be displayed as a pop-up in the +buffer (set to 1 by default (with the conceal feature), 2 otherwise), +which has the advantage of being easier to refer to (but is a hack with +many drawbacks since it changes the buffer's contents), +or in Vim's command line aligned with the function call (set to 2), which +can improve the integrity of Vim's undo history. + +.. code-block:: vim + + let g:jedi#show_call_signatures = "1" + +Here are a few more defaults for actions, read the docs (``:help jedi-vim``) to +get more information. If you set them to ``""``, they are not assigned. + +.. code-block:: vim + + NOTE: subject to change! + + let g:jedi#goto_command = "d" + let g:jedi#goto_assignments_command = "g" + let g:jedi#goto_stubs_command = "s" + let g:jedi#goto_definitions_command = "" + let g:jedi#documentation_command = "K" + let g:jedi#usages_command = "n" + let g:jedi#completions_command = "" + let g:jedi#rename_command = "r" + +An example for setting up your project: + +.. code-block:: vim + + let g:jedi#environment_path = "/usr/bin/python3.9" + +jedi-vim tries its best to guess your virtual env. If you want to work with a +specific virtual environment however, you can point jedi-vim towards it: + +.. code-block:: vim + + let g:jedi#environment_path = "venv" + +Finally, if you don't want completion, but all the other features, use: + +.. code-block:: vim + + let g:jedi#completions_enabled = 0 + +FAQ +=== + +I want to use Jedi with a Python 2 Environment, but it's not listed under "Known environments" +---------------------------------------------------------------------------------------------- + +Starting with version 0.18.0 Jedi dropped support for Python 2. + + +I don't want the docstring window to popup during completion +------------------------------------------------------------ + +This depends on the ``completeopt`` option. Jedi initializes it in its +``ftplugin``. Add the following line to your ``.vimrc`` to disable it: + +.. code-block:: vim + + autocmd FileType python setlocal completeopt-=preview + + +I want to do autocompletion +--------------------------------- + +Don't even think about changing the Jedi command to ````, +use `supertab `_! + + +The completion is too slow! +--------------------------- + +1. Completion of complex libraries (like Numpy) should only be slow the first + time you complete them. After that the results should be cached and very fast. + +2. If it is still slow after the initial completion and you have installed the + python-mode Vim plugin, try disabling its rope mode: + + .. code-block:: vim + + let g:pymode_rope = 0 + + See issue `#163 `__. + +3. You can also use `deoplete-jedi `__ + for completions, which uses Jedi, but does completions asynchronously + (requires Neovim). + It makes sense to use both jedi-vim and deoplete-jedi, but you should disable + jedi-vim's completions then: + + .. code-block:: vim + + let g:jedi#completions_enabled = 0 + +Testing +======= + +jedi-vim is being tested with a combination of `vspec +`_ and `py.test `_. + +The tests are in the ``test`` subdirectory, you can run them calling:: + + py.test + +The tests are automatically run with `travis +`_. diff --git a/sources_non_forked/jedi-vim/after/ftplugin/python/jedi.vim b/sources_non_forked/jedi-vim/after/ftplugin/python/jedi.vim new file mode 100644 index 00000000..f1983603 --- /dev/null +++ b/sources_non_forked/jedi-vim/after/ftplugin/python/jedi.vim @@ -0,0 +1,3 @@ +if jedi#init_python() && g:jedi#auto_initialization && g:jedi#completions_enabled + call jedi#setup_completion() +endif diff --git a/sources_non_forked/jedi-vim/after/syntax/python.vim b/sources_non_forked/jedi-vim/after/syntax/python.vim new file mode 100644 index 00000000..08d0d1e7 --- /dev/null +++ b/sources_non_forked/jedi-vim/after/syntax/python.vim @@ -0,0 +1,34 @@ +if !jedi#init_python() + finish +endif + +if g:jedi#show_call_signatures > 0 && has('conceal') + " +conceal is the default for vim >= 7.3 + + let s:e = g:jedi#call_signature_escape + let s:full = s:e.'jedi=.\{-}'.s:e.'.\{-}'.s:e.'jedi'.s:e + let s:ignore = s:e.'jedi.\{-}'.s:e + exe 'syn match jediIgnore "'.s:ignore.'" contained conceal' + setlocal conceallevel=2 + syn match jediFatSymbol "\*_\*" contained conceal + syn match jediFat "\*_\*.\{-}\*_\*" contained contains=jediFatSymbol + syn match jediSpace "\v[ ]+( )@=" contained + exe 'syn match jediFunction "'.s:full.'" keepend extend ' + \ .' contains=jediIgnore,jediFat,jediSpace' + \ .' containedin=pythonComment,pythonString,pythonRawString' + unlet! s:e s:full s:ignore + + hi def link jediIgnore Ignore + hi def link jediFatSymbol Ignore + hi def link jediSpace Normal + + if exists('g:colors_name') + hi def link jediFunction CursorLine + hi def link jediFat TabLine + else + hi def jediFunction term=NONE cterm=NONE ctermfg=6 guifg=Black gui=NONE ctermbg=0 guibg=Grey + hi def jediFat term=bold,underline cterm=bold,underline gui=bold,underline ctermbg=0 guibg=#555555 + endif +endif + +hi def jediUsage cterm=reverse gui=standout diff --git a/sources_non_forked/jedi-vim/autoload/health/jedi.vim b/sources_non_forked/jedi-vim/autoload/health/jedi.vim new file mode 100644 index 00000000..8c80e93f --- /dev/null +++ b/sources_non_forked/jedi-vim/autoload/health/jedi.vim @@ -0,0 +1,4 @@ +function! health#jedi#check() abort + call health#report_start('jedi') + silent call jedi#debug_info() +endfunction diff --git a/sources_non_forked/jedi-vim/autoload/jedi.vim b/sources_non_forked/jedi-vim/autoload/jedi.vim new file mode 100644 index 00000000..dcef9b6d --- /dev/null +++ b/sources_non_forked/jedi-vim/autoload/jedi.vim @@ -0,0 +1,732 @@ +scriptencoding utf-8 + +" ------------------------------------------------------------------------ +" Settings initialization +" ------------------------------------------------------------------------ +let s:deprecations = { + \ 'get_definition_command': 'goto_definitions_command', + \ 'pydoc': 'documentation_command', + \ 'related_names_command': 'usages_command', + \ 'autocompletion_command': 'completions_command', + \ 'show_function_definition': 'show_call_signatures', +\ } + +let s:default_settings = { + \ 'use_tabs_not_buffers': 0, + \ 'use_splits_not_buffers': 1, + \ 'auto_initialization': 1, + \ 'auto_vim_configuration': 1, + \ 'goto_command': "'d'", + \ 'goto_assignments_command': "'g'", + \ 'goto_definitions_command': "''", + \ 'goto_stubs_command': "'s'", + \ 'completions_command': "''", + \ 'call_signatures_command': "'n'", + \ 'usages_command': "'n'", + \ 'rename_command': "'r'", + \ 'completions_enabled': 1, + \ 'popup_on_dot': 'g:jedi#completions_enabled', + \ 'documentation_command': "'K'", + \ 'show_call_signatures': has('conceal') ? 1 : 2, + \ 'show_call_signatures_delay': 500, + \ 'call_signature_escape': "'?!?'", + \ 'auto_close_doc': 1, + \ 'max_doc_height': 30, + \ 'popup_select_first': 1, + \ 'quickfix_window_height': 10, + \ 'force_py_version': "'auto'", + \ 'environment_path': "'auto'", + \ 'added_sys_path': '[]', + \ 'project_path': "'auto'", + \ 'smart_auto_mappings': 0, + \ 'case_insensitive_completion': 1, + \ 'use_tag_stack': 1 +\ } + +for [s:key, s:val] in items(s:deprecations) + if exists('g:jedi#'.s:key) + echom "'g:jedi#".s:key."' is deprecated. Please use 'g:jedi#".s:val."' instead. Sorry for the inconvenience." + exe 'let g:jedi#'.s:val.' = g:jedi#'.s:key + endif +endfor + +for [s:key, s:val] in items(s:default_settings) + if !exists('g:jedi#'.s:key) + exe 'let g:jedi#'.s:key.' = '.s:val + endif +endfor + +let s:supports_buffer_usages = has('nvim') || exists('*prop_add') + + +" ------------------------------------------------------------------------ +" Python initialization +" ------------------------------------------------------------------------ +let s:script_path = expand(':p:h:h') + +function! s:init_python() abort + " Use g:jedi#force_py_version for loading Jedi, or fall back to using + " `has()` - preferring Python 3. + if !has('python3') + throw 'jedi-vim requires Vim with support for Python 3.' + endif + call jedi#setup_python_imports() + return 1 +endfunction + + +function! jedi#reinit_python() abort + let s:_init_python = -1 + call jedi#init_python() +endfunction + + +" This is meant to be called with `:unsilent` (for &shortmess+=F). +function! s:display_exception() abort + let error_lines = split(v:exception, '\n') + let msg = 'Error: jedi-vim failed to initialize Python: ' + \ .error_lines[0].' (in '.v:throwpoint.')' + if len(error_lines) > 1 + echohl ErrorMsg + echom 'jedi-vim error: '.error_lines[0] + for line in error_lines[1:] + echom line + endfor + echohl None + let help_cmd = ':JediDebugInfo' + if exists(':checkhealth') == 2 + let help_cmd .= ' / :checkhealth' + endif + let msg .= printf('. See :messages and/or %s for more information.', + \ help_cmd) + endif + redraw " Redraw to only have the main message by default. + echoerr msg +endfunction + + +let s:_init_python = -1 +function! jedi#init_python() abort + if s:_init_python == -1 + let s:_init_python = 0 + try + let s:_init_python = s:init_python() + let s:_init_python = 1 + catch /^jedi/ + " Only catch errors from jedi-vim itself here, so that for + " unexpected Python exceptions the traceback will be shown + " (e.g. with NameError in jedi#setup_python_imports's code). + if !exists('g:jedi#squelch_py_warning') + unsilent call s:display_exception() + endif + endtry + endif + return s:_init_python +endfunction + + +function! jedi#setup_python_imports() abort + let g:_jedi_init_error = 0 + let init_lines = [ + \ 'import vim', + \ 'def _jedi_handle_exc(exc_info):', + \ ' try:', + \ ' from jedi_vim_debug import format_exc_info', + \ ' vim.vars["_jedi_init_error"] = format_exc_info(exc_info)', + \ ' except Exception:', + \ ' import traceback', + \ ' vim.vars["_jedi_init_error"] = "\\n".join(traceback.format_exception(*exc_info))', + \ 'try:', + \ ' import jedi_vim', + \ ' if hasattr(jedi_vim, "jedi_import_error"):', + \ ' _jedi_handle_exc(jedi_vim.jedi_import_error)', + \ 'except Exception as exc:', + \ ' _jedi_handle_exc(sys.exc_info())', + \ ] + exe 'python3 exec('''.escape(join(init_lines, '\n'), "'").''')' + if g:_jedi_init_error isnot 0 + throw printf('jedi#setup_python_imports: %s', g:_jedi_init_error) + endif + return 1 +endfunction + + +function! jedi#debug_info() abort + if &verbose + if &filetype !=# 'python' + echohl WarningMsg | echo 'You should run this in a buffer with filetype "python".' | echohl None + endif + endif + let spath = shellescape(s:script_path) + echo '#### Jedi-vim debug information' + echo "\n" + echo '##### jedi-vim version' + echo "\n" + echo ' - jedi-vim git version: ' + echon substitute(system('git -C '.spath.' describe --tags --always --dirty'), '\v\n$', '', '') + echo ' - jedi git submodule status: ' + echon substitute(system('git -C '.spath.' submodule status pythonx/jedi'), '\v\n$', '', '') + echo ' - parso git submodule status: ' + echon substitute(system('git -C '.spath.' submodule status pythonx/parso'), '\v\n$', '', '') + echo "\n" + echo '##### Global Python' + echo "\n" + echo 'Using Python version 3 to access Jedi.' + let s:pythonjedi_called = 0 + try + python3 import vim; vim.command('let s:pythonjedi_called = 1') + catch + echo 'Error when trying to import vim: '.v:exception + endtry + if !s:pythonjedi_called + echohl WarningMsg + echom 'python3 failed to run, likely a Python config issue.' + if exists(':checkhealth') == 2 + echom 'Try :checkhealth for more information.' + endif + echohl None + else + try + python3 from jedi_vim_debug import display_debug_info + python3 display_debug_info() + catch + echohl WarningMsg + echo 'Error when running display_debug_info: '.v:exception + echohl None + endtry + endif + echo "\n" + echo '##### Settings' + echo "\n" + echo '```' + let jedi_settings = items(filter(copy(g:), "v:key =~# '\\v^jedi#'")) + let has_nondefault_settings = 0 + for [k, V] in jedi_settings + exe 'let default = '.get(s:default_settings, + \ substitute(k, '\v^jedi#', '', ''), "'-'") + " vint: -ProhibitUsingUndeclaredVariable + if default !=# V + echo printf('g:%s = %s (default: %s)', k, string(V), string(default)) + unlet! V " Fix variable type mismatch with Vim 7.3. + let has_nondefault_settings = 1 + endif + " vint: +ProhibitUsingUndeclaredVariable + endfor + if has_nondefault_settings + echo "\n" + endif + verb set omnifunc? completeopt? + echo '```' + + if &verbose + echo "\n" + echo '#### :version' + echo '```' + version + echo '```' + echo "\n" + echo '#### :messages' + echo '```' + messages + echo '```' + echo "\n" + echo '
:scriptnames' + echo "\n" + echo '```' + scriptnames + echo '```' + echo '
' + endif +endfunction + +" Helper function instead of `python vim.eval()`, and `.command()` because +" these also return error definitions. +function! jedi#_vim_exceptions(str, is_eval) abort + let l:result = {} + try + if a:is_eval + let l:result.result = eval(a:str) + else + execute a:str + let l:result.result = '' + endif + catch + let l:result.exception = v:exception + let l:result.throwpoint = v:throwpoint + endtry + return l:result +endfunction + +call jedi#init_python() " Might throw an error. + +" ------------------------------------------------------------------------ +" functions that call python code +" ------------------------------------------------------------------------ +function! jedi#goto() abort + python3 jedi_vim.goto(mode="goto") +endfunction + +function! jedi#goto_assignments() abort + python3 jedi_vim.goto(mode="assignment") +endfunction + +function! jedi#goto_definitions() abort + python3 jedi_vim.goto(mode="definition") +endfunction + +function! jedi#goto_stubs() abort + python3 jedi_vim.goto(mode="stubs") +endfunction + +function! jedi#usages() abort + if exists('#jedi_usages#BufWinEnter') + call jedi#clear_usages() + endif + python3 jedi_vim.usages() +endfunction + +if !s:supports_buffer_usages +" Hide usages in the current window. +" Only handles the current window due to matchdelete() restrictions. +function! jedi#_hide_usages_in_win() abort + let winnr = winnr() + let matchids = getwinvar(winnr, '_jedi_usages_vim_matchids', []) + + for matchid in matchids[1:] + call matchdelete(matchid) + endfor + call setwinvar(winnr, '_jedi_usages_vim_matchids', []) + + " Remove the autocommands that might have triggered this function. + augroup jedi_usages + exe 'autocmd! * ' + augroup END + unlet! b:_jedi_usages_needs_clear +endfunction + +" Show usages for current window (Vim without textprops only). +function! jedi#_show_usages_in_win() abort + python3 jedi_vim.highlight_usages_for_vim_win() + + if !exists('#jedi_usages#TextChanged#') + augroup jedi_usages + " Unset highlights on any changes to this buffer. + " NOTE: Neovim's API handles movement of highlights, but would only + " need to clear highlights that are changed inline. + autocmd TextChanged call jedi#_clear_buffer_usages() + + " Hide usages when the buffer is removed from the window, or when + " entering insert mode (but keep them for later). + autocmd BufWinLeave,InsertEnter call jedi#_hide_usages_in_win() + augroup END + endif +endfunction + +" Remove usages for the current buffer (and all its windows). +function! jedi#_clear_buffer_usages() abort + let bufnr = bufnr('%') + let nvim_src_ids = getbufvar(bufnr, '_jedi_usages_src_ids', []) + if !empty(nvim_src_ids) + for src_id in nvim_src_ids + " TODO: could only clear highlights below/after changed line?! + call nvim_buf_clear_highlight(bufnr, src_id, 0, -1) + endfor + else + call jedi#_hide_usages_in_win() + endif +endfunction +endif + +" Remove/unset global usages. +function! jedi#clear_usages() abort + augroup jedi_usages + autocmd! BufWinEnter + autocmd! WinEnter + augroup END + + if !s:supports_buffer_usages + " Vim without textprops: clear current window, + " autocommands will clean others on demand. + call jedi#_hide_usages_in_win() + + " Setup autocommands to clear remaining highlights on WinEnter. + augroup jedi_usages + for b in range(1, bufnr('$')) + if getbufvar(b, '_jedi_usages_needs_clear') + exe 'autocmd WinEnter call jedi#_hide_usages_in_win()' + endif + endfor + augroup END + endif + + python3 jedi_vim.clear_usages() +endfunction + +function! jedi#rename(...) abort + python3 jedi_vim.rename() +endfunction + +function! jedi#rename_visual(...) abort + python3 jedi_vim.rename_visual() +endfunction + +function! jedi#completions(findstart, base) abort + python3 jedi_vim.completions() +endfunction + +function! jedi#enable_speed_debugging() abort + python3 jedi_vim.jedi.set_debug_function(jedi_vim.print_to_stdout, speed=True, warnings=False, notices=False) +endfunction + +function! jedi#enable_debugging() abort + python3 jedi_vim.jedi.set_debug_function(jedi_vim.print_to_stdout) +endfunction + +function! jedi#disable_debugging() abort + python3 jedi_vim.jedi.set_debug_function(None) +endfunction + +function! jedi#py_import(args) abort + python3 jedi_vim.py_import() +endfun + +function! jedi#choose_environment(args) abort + python3 jedi_vim.choose_environment() +endfun + +function! jedi#load_project(args) abort + python3 jedi_vim.load_project() +endfun + +function! jedi#py_import_completions(argl, cmdl, pos) abort + python3 jedi_vim.py_import_completions() +endfun + +function! jedi#clear_cache(bang) abort + if a:bang + python3 jedi_vim.jedi.cache.clear_time_caches(True) + else + python3 jedi_vim.jedi.cache.clear_time_caches(False) + endif +endfunction + + +" ------------------------------------------------------------------------ +" show_documentation +" ------------------------------------------------------------------------ +function! jedi#show_documentation() abort + python3 if jedi_vim.show_documentation() is None: vim.command('return') + + let bn = bufnr('__doc__') + if bn > 0 + let wi=index(tabpagebuflist(tabpagenr()), bn) + if wi >= 0 + " If the __doc__ buffer is open in the current tab, jump to it + silent execute (wi+1).'wincmd w' + else + silent execute 'sbuffer '.bn + endif + else + split __doc__ + endif + + setlocal modifiable + setlocal noswapfile + setlocal buftype=nofile + silent normal! ggdG + silent $put=l:doc + silent normal! 1Gdd + setlocal nomodifiable + setlocal nomodified + setlocal filetype=rst + setlocal foldlevel=200 " do not fold in __doc__ + + if l:doc_lines > g:jedi#max_doc_height " max lines for plugin + let l:doc_lines = g:jedi#max_doc_height + endif + execute 'resize '.l:doc_lines + + " quit comands + nnoremap q ZQ + if len(g:jedi#documentation_command) + execute 'nnoremap '.g:jedi#documentation_command.' ZQ' + endif +endfunction + +" ------------------------------------------------------------------------ +" helper functions +" ------------------------------------------------------------------------ + +function! jedi#add_goto_window(for_usages, len) abort + let height = min([a:len, g:jedi#quickfix_window_height]) + + " Use :copen to go to the window always - the user should select an entry. + execute 'belowright copen '.height + + if &filetype !=# 'qf' + echoerr printf('jedi-vim: unexpected ft with current window (%s), please report!', &filetype) + endif + if g:jedi#use_tabs_not_buffers == 1 + noremap :call jedi#goto_window_on_enter() + endif + + augroup jedi_goto_window + if a:for_usages + autocmd BufWinLeave call jedi#clear_usages() + else + autocmd WinLeave q " automatically leave, if an option is chosen + endif + augroup END + + if a:for_usages && !has('nvim') + if s:supports_buffer_usages + " Setup autocommand for pending highlights with Vim's textprops. + " (cannot be added to unlisted buffers) + augroup jedi_usages + autocmd! BufWinEnter * call s:usages_for_pending_buffers() + augroup END + else + " Setup global autocommand to display any usages for a window. + " Gets removed when closing the quickfix window that displays them, or + " when clearing them (e.g. on TextChanged). + augroup jedi_usages + autocmd! BufWinEnter,WinEnter * call jedi#_show_usages_in_win() + augroup END + endif + endif +endfunction + +" Highlight usages for a buffer if not done so yet (Neovim only). +function! s:usages_for_pending_buffers() abort + python3 jedi_vim._handle_pending_usages_for_buf() +endfunction + + +function! jedi#goto_window_on_enter() abort + let l:list = getqflist() + let l:data = l:list[line('.') - 1] + if l:data.bufnr + " close goto_window buffer + normal! ZQ + python3 jedi_vim.set_buffer(vim.eval('bufname(l:data.bufnr)')) + call cursor(l:data.lnum, l:data.col) + else + echohl WarningMsg | echo 'Builtin module cannot be opened.' | echohl None + endif +endfunction + + +function! s:syn_stack() abort + if !exists('*synstack') + return [] + endif + return map(synstack(line('.'), col('.') - 1), "synIDattr(v:val, 'name')") +endfunc + + +function! jedi#do_popup_on_dot_in_highlight() abort + let highlight_groups = s:syn_stack() + for a in highlight_groups + if a ==# 'pythonDoctest' + return 1 + endif + endfor + + for a in highlight_groups + for b in ['pythonString', 'pythonComment', 'pythonNumber'] + if a == b + return 0 + endif + endfor + endfor + return 1 +endfunc + + +let s:show_call_signatures_last = [0, 0, ''] +function! jedi#show_call_signatures() abort + if s:_init_python == 0 + return 1 + endif + let [line, col] = [line('.'), col('.')] + let curline = getline(line) + let reload_signatures = 1 + + " Caching. On the same line only. + if line == s:show_call_signatures_last[0] + " Check if the number of special signs before or after the + " cursor has not changed since the last call, which means that the + " argument position was not changed and we can skip repainting. + let prevcol = s:show_call_signatures_last[1] + let prevline = s:show_call_signatures_last[2] + let no_special = '[^,()=]' + if substitute(curline[:col-2], no_special, '', 'g') + \ == substitute(prevline[:prevcol-2], no_special, '', 'g') + \ && substitute(curline[(col-2):], no_special, '', 'g') + \ == substitute(prevline[(prevcol-2):], no_special, '', 'g') + let reload_signatures = 0 + endif + endif + let s:show_call_signatures_last = [line, col, curline] + + if reload_signatures + python3 jedi_vim.show_call_signatures() + endif +endfunction + + +function! jedi#clear_call_signatures() abort + if s:_init_python == 0 + return 1 + endif + + let s:show_call_signatures_last = [0, 0, ''] + python3 jedi_vim.clear_call_signatures() +endfunction + + +function! jedi#configure_call_signatures() abort + augroup jedi_call_signatures + autocmd! * + if g:jedi#show_call_signatures == 2 " Command line call signatures + autocmd InsertEnter let g:jedi#first_col = s:save_first_col() + endif + autocmd InsertEnter let s:show_call_signatures_last = [0, 0, ''] + autocmd InsertLeave call jedi#clear_call_signatures() + if g:jedi#show_call_signatures_delay > 0 + autocmd InsertEnter let b:_jedi_orig_updatetime = &updatetime + \ | let &updatetime = g:jedi#show_call_signatures_delay + autocmd InsertLeave if exists('b:_jedi_orig_updatetime') + \ | let &updatetime = b:_jedi_orig_updatetime + \ | unlet b:_jedi_orig_updatetime + \ | endif + autocmd CursorHoldI call jedi#show_call_signatures() + else + autocmd CursorMovedI call jedi#show_call_signatures() + endif + augroup END +endfunction + + +" Determine where the current window is on the screen for displaying call +" signatures in the correct column. +function! s:save_first_col() abort + if bufname('%') ==# '[Command Line]' || winnr('$') == 1 + return 0 + endif + + let startwin = winnr() + let winwidth = winwidth(0) + if winwidth == &columns + return 0 + elseif winnr('$') == 2 + return startwin == 1 ? 0 : (winwidth(1) + 1) + elseif winnr('$') == 3 + if startwin == 1 + return 0 + endif + let ww1 = winwidth(1) + let ww2 = winwidth(2) + let ww3 = winwidth(3) + if ww1 + ww2 + ww3 + 2 == &columns + if startwin == 2 + return ww1 + 1 + else + return ww1 + ww2 + 2 + endif + elseif startwin == 2 + if ww2 + ww3 + 1 == &columns + return 0 + else + return ww1 + 1 + endif + else " startwin == 3 + if ww2 + ww3 + 1 == &columns + return ww2 + 1 + else + return ww1 + 1 + endif + endif + endif + return 0 +endfunction + + +function! jedi#complete_string(autocomplete) abort + if a:autocomplete + if !(g:jedi#popup_on_dot && jedi#do_popup_on_dot_in_highlight()) + return '' + endif + + let s:saved_completeopt = &completeopt + set completeopt-=longest + set completeopt+=menuone + set completeopt-=menu + if &completeopt !~# 'noinsert\|noselect' + " Patch 775 introduced noinsert and noselect, previously these + " options didn't exist. Setting them in earlier versions results in + " errors (E474). + if has('patch-7.4-775') + if g:jedi#popup_select_first + set completeopt+=noinsert + else + set completeopt+=noselect + endif + else + " To pass the tests we use this, it seems to get the closest to + " the other options. I'm really not sure if this properly + " works, but VIM 7.4-775 is already pretty old, so it might not + " be a problem anymore in a few years. + set completeopt+=longest + endif + endif + elseif pumvisible() + return "\" + endif + return "\\\=jedi#complete_opened(".a:autocomplete.")\" +endfunction + + +function! jedi#complete_opened(autocomplete) abort + if a:autocomplete + let &completeopt = s:saved_completeopt + unlet s:saved_completeopt + elseif pumvisible() && g:jedi#popup_select_first && stridx(&completeopt, 'longest') > -1 + return "\" + endif + return '' +endfunction + + +function! jedi#smart_auto_mappings() abort + " Auto put import statement after from module.name and complete + if search('\m^\s*from\s\+[A-Za-z0-9._]\{1,50}\%#\s*$', 'bcn', line('.')) + " Enter character and start completion. + return "\import \=jedi#complete_string(1)\" + endif + return "\" +endfunction + + +function! jedi#setup_completion() abort + " We need our own omnifunc, so this overrides the omnifunc set by + " $VIMRUNTIME/ftplugin/python.vim. + setlocal omnifunc=jedi#completions + + " map ctrl+space for autocompletion + if g:jedi#completions_command ==# '' + " In terminals, sometimes equals . + imap + smap + endif + if len(g:jedi#completions_command) + execute 'inoremap '.g:jedi#completions_command.' jedi#complete_string(0)' + " A separate mapping for select mode: deletes and completes. + execute 'snoremap '.g:jedi#completions_command." '\c'.jedi#complete_string(0)" + endif +endfunction + +"python3 jedi_vim.jedi.set_debug_function(jedi_vim.print_to_stdout, speed=True, warnings=False, notices=False) +"python3 jedi_vim.jedi.set_debug_function(jedi_vim.print_to_stdout) + +" vim: set et ts=4: diff --git a/sources_non_forked/jedi-vim/codecov.yml b/sources_non_forked/jedi-vim/codecov.yml new file mode 100644 index 00000000..a0a30858 --- /dev/null +++ b/sources_non_forked/jedi-vim/codecov.yml @@ -0,0 +1,7 @@ +coverage: + status: + project: true + patch: true + changes: true + +comment: off diff --git a/sources_non_forked/jedi-vim/doc/jedi-vim.txt b/sources_non_forked/jedi-vim/doc/jedi-vim.txt new file mode 100644 index 00000000..3b94a6d5 --- /dev/null +++ b/sources_non_forked/jedi-vim/doc/jedi-vim.txt @@ -0,0 +1,578 @@ +*jedi-vim.txt* - For Vim version 7.3 - Last change: 2014/07/29 + __ _______ _______ __ ____ ____ __ .___ ___.~ + | | | ____|| \ | | \ \ / / | | | \/ |~ + | | | |__ | .--. || | _____\ \/ / | | | \ / |~ +.--. | | | __| | | | || | |______\ / | | | |\/| |~ +| `--' | | |____ | '--' || | \ / | | | | | |~ + \______/ |_______||_______/ |__| \__/ |__| |__| |__|~ + + jedi-vim - awesome Python autocompletion with Vim + +============================================================================== +Contents *jedi-vim-contents* + +1. Introduction |jedi-vim-introduction| +2. Installation |jedi-vim-installation| + 2.0. Requirements |jedi-vim-installation-requirements| + 2.1. Manually |jedi-vim-installation-manually| + 2.2. Using Pathogen |jedi-vim-installation-pathogen| + 2.3. Using Vundle |jedi-vim-installation-vundle| + 2.4. Installing from Repositories |jedi-vim-installation-repos| +3. Supported Python features |jedi-vim-support| +4. Usage |jedi-vim-usage| +5. Mappings |jedi-vim-keybindings| + 5.1. Start completion |g:jedi#completions_command| + 5.2. Go to definition |g:jedi#goto_command| + 5.3. Go to assignment |g:jedi#goto_assignments_command| + 5.4 Go to stub |g:jedi#goto_stubs_command| + 5.5. Show documentation |g:jedi#documentation_command| + 5.6. Rename variables |g:jedi#rename_command| + 5.7. Show name usages |g:jedi#usages_command| + 5.8. Open module by name |:Pyimport| +6. Configuration |jedi-vim-configuration| + 6.1. auto_initialization |g:jedi#auto_initialization| + 6.2. auto_vim_configuration |g:jedi#auto_vim_configuration| + 6.3. popup_on_dot |g:jedi#popup_on_dot| + 6.4. popup_select_first |g:jedi#popup_select_first| + 6.5. auto_close_doc |g:jedi#auto_close_doc| + 6.6. show_call_signatures |g:jedi#show_call_signatures| + 6.7. show_call_signatures_delay |g:jedi#show_call_signatures_delay| + 6.8. use_tabs_not_buffers |g:jedi#use_tabs_not_buffers| + 6.9. squelch_py_warning |g:jedi#squelch_py_warning| + 6.10. completions_enabled |g:jedi#completions_enabled| + 6.11. use_splits_not_buffers |g:jedi#use_splits_not_buffers| + 6.12. force_py_version |g:jedi#force_py_version| + 6.13. smart_auto_mappings |g:jedi#smart_auto_mappings| + 6.14. use_tag_stack |g:jedi#use_tag_stack| + 6.15. environment_path |g:jedi#environment_path| + |b:jedi_environment_path| + 6.16. added_sys_path |g:jedi#added_sys_path| + |b:jedi_added_sys_path| + 6.17. case_insensitive_completion |g:jedi#case_insensitive_completion| + |b:jedi_case_insensitive_completion| +7. Testing |jedi-vim-testing| +8. Contributing |jedi-vim-contributing| +9. License |jedi-vim-license| + +============================================================================== +1. Introduction *jedi-vim-introduction* + +Jedi-vim is a Vim binding to the awesome Python autocompletion library +`jedi`. Among jedi's (and, therefore, jedi-vim's) features are: + +- Completion for a wide array of Python features (see |jedi-vim-support|) +- Robust in dealing with syntax errors and wrong indentation +- Parses complex module/function/class structures +- Infers function arguments from Sphinx/Epydoc strings +- Doesn't execute Python code +- Supports Virtualenv +- Supports Python 2.7 and 3.4+ + +By leveraging this library, jedi-vim adds the following capabilities to Vim: + +- Displaying function/class bodies +- "Go to definition" command +- Displaying docstrings +- Renaming and refactoring +- Looking up related names + +============================================================================== +2. Installation *jedi-vim-installation* + +------------------------------------------------------------------------------ +2.0. Requirements *jedi-vim-installation-requirements* + +First of all, jedi-vim requires Vim to be compiled with the `+python` option. + +It is best if you have VIM >= 7.3, compiled with the `+conceal` option. With +older versions, you will probably not see the parameter recommendation list +for functions after typing the open bracket. Some platforms (including OS X +releases) do not ship a VIM with `+conceal`. You can check if your VIM has the +feature with > + + :ver + +and look for "`+conceal`" (as opposed to "`-conceal`") or > + + :echo has('conceal') + +which will report 0 (not included) or 1 (included). If your VIM lacks this +feature and you would like function parameter completion, you will need to +build your own VIM, or use a package for your operating system that has this +feature (such as MacVim on OS X, which also contains a console binary). + +------------------------------------------------------------------------------ +2.1. Installing manually *jedi-vim-installation-manually* + +1. If you want to install jedi as a submodule instead, issue this command: > + + git clone --recursive http://github.com/davidhalter/jedi-vim + +2. Put the plugin files into their respective folders in your vim runtime + directory (usually ~/.vim). Be sure to pay attention to the directory + structure! +3. Update the Vim help tags with > + + :helptags /doc + +------------------------------------------------------------------------------ +2.2. Installing using Pathogen *jedi-vim-installation-pathogen* + +Pathogen simplifies installation considerably. + +1.a Clone the git repository into your bundles directory: > + + git clone http://github.com/davidhalter/jedi-vim path/to/bundles/jedi-vim + +1b. Again, if you want to install jedi as a submodule, use this command + instead: > + + git clone --recursive http://github.com/davidhalter/jedi-vim + +------------------------------------------------------------------------------ +2.3. Installing using Vundle *jedi-vim-installation-vundle* + +1. Vundle automatically downloads subrepositories as git submodules, so you + will automatically get the jedi library with the jedi-vim plugin. Add the + following to the Bundles section in your .vimrc file: > + + Plugin 'davidhalter/jedi-vim' + +2. Issue the following command in Vim: > + + :PluginInstall + +Help tags are generated automatically, so you should be good to go. + +------------------------------------------------------------------------------ +2.4. Installing from Repositories *jedi-vim-installation-repos* + +Some Linux distributions have jedi-vim packages in their official +repositories. On Arch Linux, install vim-jedi. On Debian (8+) or Ubuntu +(14.04+) install vim-python-jedi. + +============================================================================== +3. Supported Python features *jedi-vim-support* + +The Jedi library does all the hard work behind the scenes. It understands most +Python features, among them: + +- Builtins +- Multiple `return`s or `yield`s +- Tuple assignments/array indexing/dictionary indexing +- `with`-statement/exception handling +- `*args` and `**kwargs` +- Decorators, lambdas, closures +- Generators, iterators +- Some descriptors: `property`/`staticmethod`/`classmethod` +- Some magic methods: `__call__`, `__iter__`, `__next__`, `__get__`, + `__getitem__`, `__init__` +- `list.append()`, `set.add()`, `list.extend()`, etc. +- (Nested) list comprehensions and ternary expressions +- Relative `import`s +- `getattr()`/`__getattr__`/`__getattribute__` +- Function annotations (py3k feature, are being ignored at the moment, but are + parsed) +- Class decorators (py3k feature, are being ignored at the moment, but are + parsed) +- Simple/usual `sys.path` modifications +- `isinstance` checks for `if`/`while`/`assert` case, that doesn't work with + Jedi +- Stubs +- And more... + +Note: This list is not necessarily up to date. For a complete list of +features, please refer to the Jedi documentation at +http://jedi.readthedocs.io. + +============================================================================== +4. Usage *jedi-vim-usage* + +With the default settings, autocompletion can be triggered by typing +. The first entry will automatically be selected, so you can press + to insert it into your code or keep typing and narrow down your +completion options. The usual and / keybindings work as +well. Autocompletion is also triggered by typing a period in insert mode. +Since periods rarely occur in Python code outside of method/import lookups, +this is handy to have (but can be disabled). + +When it encounters a new module, jedi might take a few seconds to parse that +module's contents. Afterwards, the contents are cached and completion will be +almost instantaneous. + +============================================================================== +5. Key Bindings *jedi-vim-keybindings* + +All keybindings can be mapped by setting the appropriate global option. For +example, to set the keybinding for starting omnicompletion to instead of +, add the following setting to your .vimrc file: > + + let g:jedi#completions_command = "" + +Note: If you have |g:jedi#auto_initialization| set to 0, you have to create +a mapping yourself by calling a function: > + + " Using for omnicompletion + inoremap + " Use r (by default <\-r>) for renaming + nnoremap r :call jedi#rename() + " etc. + +Note: You can set commands to '', which means that they are empty and not +assigned. It's an easy way to "disable" functionality of jedi-vim. + +------------------------------------------------------------------------------ +5.1. `g:jedi#completions_command` *g:jedi#completions_command* +Function: n/a; see above +Default: Start completion + +Performs autocompletion (or omnicompletion, to be precise). + +Note: If you want to use for completion, please install Supertab: +https://github.com/ervandew/supertab. + +------------------------------------------------------------------------------ +5.2. `g:jedi#goto_command` *g:jedi#goto_command* +Function: `jedi#goto()` +Default: d Go to definition (or assignment) + +This function first tries |jedi#goto_definitions|, and falls back to +|jedi#goto_assignments| for builtin modules. It produces an error if nothing +could be found. +NOTE: this implementation is subject to change. +Ref: https://github.com/davidhalter/jedi/issues/570 + +This command tries to find the original definition of the function/class under +the cursor. Just like the `jedi#goto_assignments()` function, it does not work +if the definition isn't in a Python source file. + +The difference between `jedi#goto_assignments()` and `jedi#goto_definitions()` +is that the latter performs recursive lookups. Take, for example, the +following module structure: > + + # file1.py: + from file2 import foo + + # file2.py: + from file3 import bar as foo + + # file3.py + def bar(): + pass + +The `jedi#goto_assignments()` function will take you to the > + + from file2 import foo + +statement in file1.py, while the `jedi#goto_definitions()` function will take +you all the way to the > + + def bar(): + +line in file3.py. + +------------------------------------------------------------------------------ +5.3. `g:jedi#goto_assignments_command` *g:jedi#goto_assignments_command* +Function: `jedi#goto_assignments()` +Default: g Go to assignment + +This function finds the first definition of the function/class under the +cursor. It produces an error if the definition is not in a Python file. + +------------------------------------------------------------------------------ +5.4. `g:jedi#goto_stubs_command` *g:jedi#goto_stubs_command* +Function: `jedi#goto_stubs()` +Default: s Go to stub + +Finds the stub of the function/class under the cursor. + +------------------------------------------------------------------------------ +5.5. `g:jedi#documentation_command` *g:jedi#documentation_command* +Function: `jedi#show_documentation()` +Default: Show pydoc documentation + +This shows the pydoc documentation for the item currently under the cursor. +The documentation is opened in a horizontally split buffer. The height of this +buffer is controlled by `g:jedi#max_doc_height` (set by default to 30). + +------------------------------------------------------------------------------ +5.6. `g:jedi#rename_command` *g:jedi#rename_command* +Function: `jedi#rename()` +Default: r Rename variables + +Jedi-vim deletes the word currently under the cursor and puts Vim in insert +mode, where the user is expected to enter the new variable name. Upon leaving +insert mode, jedi-vim then renames all occurrences of the old variable name +with the new one. The number of performed renames is displayed in the command +line. + +------------------------------------------------------------------------------ +5.7. `g:jedi#usages_command` *g:jedi#usages_command* +Function: `jedi#usages()` +Default: n Show usages of a name. + +The quickfix window is populated with a list of all names which point to the +definition of the name under the cursor. + +------------------------------------------------------------------------------ +5.8. Open module by name *:Pyimport* +Function: `jedi#py_import(args)` +Default: :Pyimport e.g. `:Pyimport os` shows os.py in VIM. + +Simulate an import and open that module in VIM. + +============================================================================== +6. Configuration *jedi-vim-configuration* + +Note: You currently have to set these options in your .vimrc. Setting them in +an ftplugin (e.g. ~/.vim/ftplugin/python/jedi-vim-settings.vim) will not work +because jedi-vim is not set up as an filetype plugin, but as a "regular" +plugin. + +------------------------------------------------------------------------------ +6.1. `g:jedi#auto_initialization` *g:jedi#auto_initialization* + +Upon initialization, jedi-vim performs the following steps: + +1. Set the current buffers 'omnifunc' to its own completion function + `jedi#completions` +2. Create mappings to commands specified in |jedi-vim-keybindings| +3. Call `jedi#configure_call_signatures()` if + `g:jedi#show_call_signatures` is set + +You can disable the default initialization routine by setting this option to +0. Beware that you have to perform the above steps yourself, though. + +Options: 0 or 1 +Default: 1 (Perform automatic initialization) + +------------------------------------------------------------------------------ +6.2. `g:jedi#auto_vim_configuration` *g:jedi#auto_vim_configuration* + +Jedi-vim sets 'completeopt' to `menuone,longest,preview` by default, if +'completeopt' is not changed from Vim's default. +It also remaps to in insert mode. + +If you want to keep your own configuration, disable this setting. + +Options: 0 or 1 +Default: 1 (Set 'completeopt' and mapping as described above) + +------------------------------------------------------------------------------ +6.3. `g:jedi#popup_on_dot` *g:jedi#popup_on_dot* + +Jedi-vim automatically starts completion upon typing a period in insert mode. + +However, when working with large modules, this can slow down your typing flow +since you have to wait for jedi to parse the module and show the completion +menu. By disabling this setting, completion is only started when you manually +press the completion key. +You need to also have `g:jedi#completions_enabled` enabled for this. + +Options: 0 or 1 +Default: 1 (Start completion on typing a period) + +------------------------------------------------------------------------------ +6.4. `g:jedi#popup_select_first` *g:jedi#popup_select_first* + +Upon starting completion, jedi-vim can automatically select the first entry +that pops up (without actually inserting it). + +This leads to a better typing flow: As you type more characters, the entries +in the completion menu are narrowed down. If they are narrowed down enough, +you can just press to insert the first match. + +Options: 0 or 1 +Default: 1 (Automatically select first completion entry) + +------------------------------------------------------------------------------ +6.5. `g:jedi#auto_close_doc` *g:jedi#auto_close_doc* + +When doing completion, jedi-vim shows the docstring of the currently selected +item in a preview window. By default, this window is being closed after +insertion of a completion item. + +Set this to 0 to leave the preview window open even after leaving insert mode. +This could be useful if you want to browse longer docstrings. + +Options: 0 or 1 +Default: 1 (Automatically close preview window upon leaving insert mode) + +------------------------------------------------------------------------------ +6.6. `g:jedi#show_call_signatures` *g:jedi#show_call_signatures* + +Jedi-vim can display a small window detailing the arguments of the currently +completed function and highlighting the currently selected argument. This can +be disabled by setting this option to 0. Setting this option to 2 shows call +signatures in the command line instead of a popup window. + +Options: 0, 1, or 2 +Default: 1 (Show call signatures window) + +Note: 'showmode' must be disabled for command line call signatures to be +visible. + +Note: This setting is ignored if |g:jedi#auto_initialization| is set to 0. In +that case, if you want to see call signatures, you have to set it up +manually by calling a function in your configuration file: > + + call jedi#configure_call_signatures() + +------------------------------------------------------------------------------ +6.7. `g:jedi#show_call_signatures_delay` *g:jedi#show_call_signatures_delay* + +The delay to be used with |g:jedi#show_call_signatures|. If it is greater +than 0 it will use Vim's |CursorHoldI| event instead of |CursorMovedI|. +It will temporarily set Vim's |'updatetime'| option during insert mode. + +Options: delay in milliseconds +Default: 500 + +------------------------------------------------------------------------------ +6.8. `g:jedi#use_tabs_not_buffers` *g:jedi#use_tabs_not_buffers* + +You can make jedi-vim open a new tab if you use the "go to", "show +definition", or "related names" commands. When you leave this at the default +(0), they open in the current window instead. + +Options: 0 or 1 +Default: 0 (Command output reuses current window) + +------------------------------------------------------------------------------ +6.9. `g:jedi#squelch_py_warning` *g:jedi#squelch_py_warning* + +When Vim has not been compiled with +python, jedi-vim shows a warning to that +effect and aborts loading itself. Set this to 1 to suppress that warning. + +Options: 0 or 1 +Default: 0 (Warning is shown) + +------------------------------------------------------------------------------ +6.10. `g:jedi#completions_enabled` *g:jedi#completions_enabled* + +If you don't want Jedi completion, but all the other features, you can disable +it in favor of another completion engine (that probably also uses Jedi, like +YCM). + +Options: 0 or 1 +Default: 1 + +------------------------------------------------------------------------------ +6.11. `g:jedi#use_splits_not_buffers` *g:jedi#use_splits_not_buffers* + +If you want to open new split for "go to", you could set this option to the +direction which you want to open a split with. + +Options: top, left, right, bottom or winwidth +Default: "" (not enabled by default) + +Note: with the 'winwidth' option the window is split vertically or horizontally +depending on the width of the window relative to 'textwidth'. This essentially +means that if the window is big enough it will be split vertically but if it is +small a horizontal split happens. + +------------------------------------------------------------------------------ +6.12. `g:jedi#force_py_version` *g:jedi#force_py_version* + +If you have installed multiple Python versions, you can force the Python +version that is going to be used. +You don't have to compile VIM with multiple Python versions. +The variable can be set in the .vimrc like this to force python 2: + +let g:jedi#force_py_version = 2 + +By default jedi loads the latest Python version installed on your system that +can be found. + +This variable can be changed during runtime. + +Options: 2, 2.7, 3, 3.5, 3.6, ... +Default: "auto" +------------------------------------------------------------------------------ +6.13. `g:jedi#smart_auto_mappings` *g:jedi#smart_auto_mappings* + +When you start typing `from module.name` jedi-vim automatically +can add the "import" statement and trigger the autocompletion popup. + +You can enable this using: > + + let g:jedi#smart_auto_mappings = 1 +< +Options: 0 or 1 +Default: 0 (disabled by default) + +------------------------------------------------------------------------------ +6.14. `g:jedi#use_tag_stack` *g:jedi#use_tag_stack* + +Write results of |jedi#goto| to a temporary file and use the |:tjump| command +to enable full |tagstack| functionality. Use of the tag stack allows +returning to the usage of a function with CTRL-T after exploring the +definition with arbitrary changes to the |jumplist|. + +Options: 0 or 1 +Default: 1 (enabled by default) + +------------------------------------------------------------------------------ +6.15. `g:jedi#environment_path` *g:jedi#environment_path* + *b:jedi_environment_path* + +To use a specific virtualenv or a specific Python version it is possible to +set an interpreter. + +Both setting the directory and setting a project is working. + +Examples: "/usr/bin/python3.9", "venv", "../venv", "../venv/bin/python" + +The buffer-local variable `b:jedi_environment_path` can be used to override the +global variable `g:jedi#environment_path`. + +Default: "auto" + +------------------------------------------------------------------------------ +6.16. `g:jedi#added_sys_path` *g:jedi#added_sys_path* + *b:jedi_added_sys_path* + +To add extra sys_path. + +The buffer-local variable `b:jedi_added_sys_path` can be used to add +additional extra sys_path. + +Examples: ["../site-packages"] +Default: [] + +------------------------------------------------------------------------------ +6.17. `g:jedi#case_insensitive_completion` *g:jedi#case_insensitive_completion* + *b:jedi_case_insensitive_completion* + +0 to disable case insensitive completion. +1 to enable case insensitive completion (default). + +The buffer-local variable `b:jedi_case_insensitive_completion` can be used to +override the global variable `g:jedi#case_insensitive_completion`. + +Default: 1 + +============================================================================== +7. Testing *jedi-vim-testing* + +jedi-vim is being tested with a combination of vspec +https://github.com/kana/vim-vspec and py.test http://pytest.org/. + +The tests are in the test subdirectory, you can run them calling:: + + py.test + +The tests are automatically run with `travis +`_. + +============================================================================== +8. Contributing *jedi-vim-contributing* + +We love Pull Requests! Read the instructions in `CONTRIBUTING.md`. + +============================================================================== +9. License *jedi-vim-license* + +Jedi-vim is licensed with the MIT license. + + vim: textwidth=78 et filetype=help:norightleft: diff --git a/sources_non_forked/jedi-vim/doc/logotype-a.svg b/sources_non_forked/jedi-vim/doc/logotype-a.svg new file mode 100644 index 00000000..80380bdd --- /dev/null +++ b/sources_non_forked/jedi-vim/doc/logotype-a.svg @@ -0,0 +1,140 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sources_non_forked/jedi-vim/ftplugin/python/jedi.vim b/sources_non_forked/jedi-vim/ftplugin/python/jedi.vim new file mode 100644 index 00000000..5b97b9c2 --- /dev/null +++ b/sources_non_forked/jedi-vim/ftplugin/python/jedi.vim @@ -0,0 +1,53 @@ +if !jedi#init_python() + finish +endif +" ------------------------------------------------------------------------ +" Initialization of jedi-vim +" ------------------------------------------------------------------------ + +if g:jedi#auto_initialization + " goto / get_definition / usages + if len(g:jedi#goto_command) + execute 'nnoremap '.g:jedi#goto_command.' :call jedi#goto()' + endif + if len(g:jedi#goto_assignments_command) + execute 'nnoremap '.g:jedi#goto_assignments_command.' :call jedi#goto_assignments()' + endif + if len(g:jedi#goto_definitions_command) + execute 'nnoremap '.g:jedi#goto_definitions_command.' :call jedi#goto_definitions()' + endif + if len(g:jedi#goto_stubs_command) + execute 'nnoremap '.g:jedi#goto_stubs_command.' :call jedi#goto_stubs()' + endif + if len(g:jedi#usages_command) + execute 'nnoremap '.g:jedi#usages_command.' :call jedi#usages()' + endif + " rename + if len(g:jedi#rename_command) + execute 'nnoremap '.g:jedi#rename_command.' :call jedi#rename()' + execute 'vnoremap '.g:jedi#rename_command.' :call jedi#rename_visual()' + endif + " documentation/pydoc + if len(g:jedi#documentation_command) + execute 'nnoremap '.g:jedi#documentation_command.' :call jedi#show_documentation()' + endif + + if g:jedi#show_call_signatures > 0 + call jedi#configure_call_signatures() + endif + + if g:jedi#completions_enabled == 1 + inoremap . .=jedi#complete_string(1) + endif + + if g:jedi#smart_auto_mappings == 1 + inoremap =jedi#smart_auto_mappings() + end + + if g:jedi#auto_close_doc + " close preview if its still open after insert + augroup jedi_preview + autocmd! InsertLeave if pumvisible() == 0|pclose|endif + augroup END + endif +endif diff --git a/sources_non_forked/jedi-vim/plugin/jedi.vim b/sources_non_forked/jedi-vim/plugin/jedi.vim new file mode 100644 index 00000000..d409240c --- /dev/null +++ b/sources_non_forked/jedi-vim/plugin/jedi.vim @@ -0,0 +1,77 @@ +"jedi-vim - Omni Completion for python in vim +" Maintainer: David Halter +" +" This part of the software is just the vim interface. The really big deal is +" the Jedi Python library. + +if get(g:, 'jedi#auto_vim_configuration', 1) + " jedi-vim doesn't work in compatible mode (vim script syntax problems) + if &compatible + " vint: -ProhibitSetNoCompatible + set nocompatible + " vint: +ProhibitSetNoCompatible + endif + + " jedi-vim really needs, otherwise jedi-vim cannot start. + filetype plugin on + + augroup jedi_pyi + au! + autocmd BufNewFile,BufRead *.pyi set filetype=python + augroup END + + " Change completeopt, but only if it was not set already. + " This gets done on VimEnter, since otherwise Vim fails to restore the + " screen. Neovim is not affected, this is likely caused by using + " :redir/execute() before the (alternate) terminal is configured. + function! s:setup_completeopt() + if exists('*execute') + let completeopt = execute('silent verb set completeopt?') + else + redir => completeopt + silent verb set completeopt? + redir END + endif + if len(split(completeopt, '\n')) == 1 + set completeopt=menuone,longest,preview + endif + endfunction + if has('nvim') + call s:setup_completeopt() + else + augroup jedi_startup + au! + autocmd VimEnter * call s:setup_completeopt() + augroup END + endif + + if len(mapcheck('', 'i')) == 0 + inoremap + endif +endif + +" Pyimport command +command! -nargs=1 -complete=custom,jedi#py_import_completions Pyimport :call jedi#py_import() + +command! -nargs=? -complete=file JediChooseEnvironment :call jedi#choose_environment() +command! -nargs=? -complete=file JediLoadProject :call jedi#load_project() + + +function! s:jedi_debug_info() + " Ensure the autoload file has been loaded (and ignore any errors, which + " will be displayed with the debug info). + let unset = {} + let saved_squelch_py_warning = get(g:, 'jedi#squelch_py_warning', unset) + let g:jedi#squelch_py_warning = 1 + call jedi#init_python() + if saved_squelch_py_warning is unset + unlet g:jedi#squelch_py_warning + else + let g:jedi#squelch_py_warning = saved_squelch_py_warning + endif + call jedi#debug_info() +endfunction +command! -nargs=0 -bar JediDebugInfo call s:jedi_debug_info() +command! -nargs=0 -bang JediClearCache call jedi#clear_cache(0) + +" vim: set et ts=4: diff --git a/sources_non_forked/jedi-vim/pythonx/jedi_vim.py b/sources_non_forked/jedi-vim/pythonx/jedi_vim.py new file mode 100644 index 00000000..b140668a --- /dev/null +++ b/sources_non_forked/jedi-vim/pythonx/jedi_vim.py @@ -0,0 +1,1211 @@ +# -*- coding: utf-8 -*- +""" +The Python parts of the Jedi library for VIM. It is mostly about communicating +with VIM. +""" + +from typing import Optional +import traceback # for exception output +import re +import os +import sys +from shlex import split as shsplit +from contextlib import contextmanager +from pathlib import Path +try: + from itertools import zip_longest +except ImportError: + from itertools import izip_longest as zip_longest # Python 2 + +import vim + +is_py3 = sys.version_info[0] >= 3 +if is_py3: + ELLIPSIS = "…" + unicode = str +else: + ELLIPSIS = u"…" + + +try: + # Somehow sys.prefix is set in combination with VIM and virtualenvs. + # However the sys path is not affected. Just reset it to the normal value. + sys.prefix = sys.base_prefix + sys.exec_prefix = sys.base_exec_prefix +except AttributeError: + # If we're not in a virtualenv we don't care. Everything is fine. + pass + + +class PythonToVimStr(unicode): + """ Vim has a different string implementation of single quotes """ + __slots__ = [] + + def __new__(cls, obj, encoding='UTF-8'): + if not (is_py3 or isinstance(obj, unicode)): + obj = unicode.__new__(cls, obj, encoding) + + # Vim cannot deal with zero bytes: + obj = obj.replace('\0', '\\0') + return unicode.__new__(cls, obj) + + def __repr__(self): + # this is totally stupid and makes no sense but vim/python unicode + # support is pretty bad. don't ask how I came up with this... It just + # works... + # It seems to be related to that bug: http://bugs.python.org/issue5876 + if unicode is str: + s = self + else: + s = self.encode('UTF-8') + return '"%s"' % s.replace('\\', '\\\\').replace('"', r'\"') + + +class VimError(Exception): + def __init__(self, message, throwpoint, executing): + super(type(self), self).__init__(message) + self.message = message + self.throwpoint = throwpoint + self.executing = executing + + def __str__(self): + return "{}; created by {!r} (in {})".format( + self.message, self.executing, self.throwpoint + ) + + +def _catch_exception(string, is_eval): + """ + Interface between vim and python calls back to it. + Necessary, because the exact error message is not given by `vim.error`. + """ + result = vim.eval('jedi#_vim_exceptions({0}, {1})'.format( + repr(PythonToVimStr(string, 'UTF-8')), int(is_eval))) + if 'exception' in result: + raise VimError(result['exception'], result['throwpoint'], string) + return result['result'] + + +def vim_command(string): + _catch_exception(string, is_eval=False) + + +def vim_eval(string): + return _catch_exception(string, is_eval=True) + + +def no_jedi_warning(error=None): + vim.command('echohl WarningMsg') + vim.command('echom "Please install Jedi if you want to use jedi-vim."') + if error: + vim.command('echom "The error was: {0}"'.format(error)) + vim.command('echohl None') + + +def echo_highlight(msg): + vim_command('echohl WarningMsg | echom "jedi-vim: {0}" | echohl None'.format( + str(msg).replace('"', '\\"'))) + + +jedi_path = os.path.join(os.path.dirname(__file__), 'jedi') +sys.path.insert(0, jedi_path) +parso_path = os.path.join(os.path.dirname(__file__), 'parso') +sys.path.insert(0, parso_path) + +try: + import jedi +except ImportError: + jedi = None + jedi_import_error = sys.exc_info() +else: + try: + version = jedi.__version__ + except Exception as e: # e.g. AttributeError + echo_highlight( + "Error when loading the jedi python module ({0}). " + "Please ensure that Jedi is installed correctly (see Installation " + "in the README.".format(e)) + jedi = None + else: + if isinstance(version, str): + # the normal use case, now. + from jedi import utils + version = utils.version_info() + if version < (0, 7): + echo_highlight('Please update your Jedi version, it is too old.') +finally: + sys.path.remove(jedi_path) + sys.path.remove(parso_path) + + +class VimCompat: + _eval_cache = {} + _func_cache = {} + + @classmethod + def has(cls, what): + try: + return cls._eval_cache[what] + except KeyError: + ret = cls._eval_cache[what] = cls.call('has', what) + return ret + + @classmethod + def call(cls, func, *args): + try: + f = cls._func_cache[func] + except KeyError: + if IS_NVIM: + f = cls._func_cache[func] = getattr(vim.funcs, func) + else: + f = cls._func_cache[func] = vim.Function(func) + return f(*args) + + @classmethod + def setqflist(cls, items, title, context): + if cls.has('patch-7.4.2200'): # can set qf title. + what = {'title': title} + if cls.has('patch-8.0.0590'): # can set qf context + what['context'] = {'jedi_usages': context} + if cls.has('patch-8.0.0657'): # can set items via "what". + what['items'] = items + cls.call('setqflist', [], ' ', what) + else: + # Can set title (and maybe context), but needs two calls. + cls.call('setqflist', items) + cls.call('setqflist', items, 'a', what) + else: + cls.call('setqflist', items) + + @classmethod + def setqflist_title(cls, title): + if cls.has('patch-7.4.2200'): + cls.call('setqflist', [], 'a', {'title': title}) + + @classmethod + def can_update_current_qflist_for_context(cls, context): + if cls.has('patch-8.0.0590'): # can set qf context + return cls.call('getqflist', {'context': 1})['context'] == { + 'jedi_usages': context, + } + + +def catch_and_print_exceptions(func): + def wrapper(*args, **kwargs): + try: + return func(*args, **kwargs) + except (Exception, vim.error): + print(traceback.format_exc()) + return None + return wrapper + + +def _check_jedi_availability(show_error=False): + def func_receiver(func): + def wrapper(*args, **kwargs): + if jedi is None: + if show_error: + no_jedi_warning() + return + else: + return func(*args, **kwargs) + return wrapper + return func_receiver + + +# Tuple of cache key / project +_current_project_cache = None, None + + +def get_project(): + vim_environment_path = vim_eval( + "get(b:, 'jedi_environment_path', g:jedi#environment_path)" + ) + vim_project_path = vim_eval("g:jedi#project_path") + + vim_added_sys_path = vim_eval("get(g:, 'jedi#added_sys_path', [])") + vim_added_sys_path += vim_eval("get(b:, 'jedi_added_sys_path', [])") + + global _current_project_cache + cache_key = dict(project_path=vim_project_path, + environment_path=vim_environment_path, + added_sys_path=vim_added_sys_path) + if cache_key == _current_project_cache[0]: + return _current_project_cache[1] + + if vim_environment_path in ("auto", "", None): + environment_path = None + else: + environment_path = vim_environment_path + + if vim_project_path in ("auto", "", None): + project_path = jedi.get_default_project().path + else: + project_path = vim_project_path + + project = jedi.Project(project_path, + environment_path=environment_path, + added_sys_path=vim_added_sys_path) + + _current_project_cache = cache_key, project + return project + + +@catch_and_print_exceptions +def choose_environment(): + args = shsplit(vim.eval('a:args')) + + envs = list(jedi.find_system_environments()) + envs.extend(jedi.find_virtualenvs(paths=args or None)) + + env_paths = [env.executable for env in envs] + + vim_command('belowright new') + vim.current.buffer[:] = env_paths + vim.current.buffer.name = "Hit Enter to Choose an Environment" + vim_command( + 'setlocal buftype=nofile bufhidden=wipe noswapfile nobuflisted readonly nomodifiable') + vim_command('noremap :bw') + vim_command('noremap :python3 jedi_vim.choose_environment_hit_enter()') + + +@catch_and_print_exceptions +def choose_environment_hit_enter(): + vim.vars['jedi#environment_path'] = vim.current.line + vim_command('bd') + + +@catch_and_print_exceptions +def load_project(): + path = vim.eval('a:args') + vim.vars['jedi#project_path'] = path + env_path = vim_eval("g:jedi#environment_path") + if env_path == 'auto': + env_path = None + if path: + try: + project = jedi.Project.load(path) + except FileNotFoundError: + project = jedi.Project(path, environment_path=env_path) + project.save() + else: + project = jedi.get_default_project() + path = project.path + project.save() + + global _current_project_cache + cache_key = dict(project_path=path, + environment_path=env_path, + added_sys_path=[]) + _current_project_cache = cache_key, project + + +@catch_and_print_exceptions +def get_script(source=None): + jedi.settings.additional_dynamic_modules = [ + b.name for b in vim.buffers if ( + b.name is not None and + b.name.endswith('.py') and + b.options['buflisted'])] + if source is None: + source = '\n'.join(vim.current.buffer) + buf_path = vim.current.buffer.name + if not buf_path: + # If a buffer has no name its name is an empty string. + buf_path = None + + return jedi.Script(source, path=buf_path, project=get_project()) + + +def get_pos(column=None): + row = vim.current.window.cursor[0] + if column is None: + column = vim.current.window.cursor[1] + return row, column + + +@_check_jedi_availability(show_error=False) +@catch_and_print_exceptions +def completions(): + jedi.settings.case_insensitive_completion = \ + bool(int(vim_eval("get(b:, 'jedi_case_insensitive_completion', " + "g:jedi#case_insensitive_completion)"))) + + row, column = vim.current.window.cursor + # Clear call signatures in the buffer so they aren't seen by the completer. + # Call signatures in the command line can stay. + if int(vim_eval("g:jedi#show_call_signatures")) == 1: + clear_call_signatures() + if vim.eval('a:findstart') == '1': + count = 0 + for char in reversed(vim.current.line[:column]): + if not re.match(r'[\w\d]', char): + break + count += 1 + vim.command('return %i' % (column - count)) + else: + base = vim.eval('a:base') + source = '' + for i, line in enumerate(vim.current.buffer): + # enter this path again, otherwise source would be incomplete + if i == row - 1: + source += line[:column] + base + line[column:] + else: + source += line + source += '\n' + # here again hacks, because jedi has a different interface than vim + column += len(base) + try: + script = get_script(source=source) + completions = script.complete(*get_pos(column)) + signatures = script.get_signatures(*get_pos(column)) + + add_info = "preview" in vim.eval("&completeopt").split(",") + out = [] + for c in completions: + d = dict(word=PythonToVimStr(c.name[:len(base)] + c.complete), + abbr=PythonToVimStr(c.name_with_symbols), + # stuff directly behind the completion + menu=PythonToVimStr(c.description), + icase=1, # case insensitive + dup=1 # allow duplicates (maybe later remove this) + ) + if add_info: + try: + d["info"] = PythonToVimStr(c.docstring()) + except Exception: + print("jedi-vim: error with docstring for %r: %s" % ( + c, traceback.format_exc())) + out.append(d) + + strout = str(out) + except Exception: + # print to stdout, will be in :messages + print(traceback.format_exc()) + strout = '' + completions = [] + signatures = [] + + show_call_signatures(signatures) + vim.command('return ' + strout) + + +@contextmanager +def tempfile(content): + # Using this instead of the tempfile module because Windows won't read + # from a file not yet written to disk + with open(vim_eval('tempname()'), 'w') as f: + f.write(content) + try: + yield f + finally: + os.unlink(f.name) + + +@_check_jedi_availability(show_error=True) +@catch_and_print_exceptions +def goto(mode="goto"): + """ + :param str mode: "definition", "assignment", "goto" + :rtype: list of jedi.api.classes.Name + """ + script = get_script() + pos = get_pos() + if mode == "goto": + names = script.goto(*pos, follow_imports=True) + elif mode == "definition": + names = script.infer(*pos) + elif mode == "assignment": + names = script.goto(*pos) + elif mode == "stubs": + names = script.goto(*pos, follow_imports=True, only_stubs=True) + + if not names: + echo_highlight("Couldn't find any definitions for this.") + elif len(names) == 1 and mode != "related_name": + n = list(names)[0] + _goto_specific_name(n) + else: + show_goto_multi_results(names, mode) + return names + + +def _goto_specific_name(n, options=''): + if n.column is None: + if n.is_keyword: + echo_highlight("Cannot get the definition of Python keywords.") + else: + name = 'Namespaces' if n.type == 'namespace' else 'Builtin modules' + echo_highlight( + "%s cannot be displayed (%s)." + % (name, n.full_name or n.name) + ) + else: + using_tagstack = int(vim_eval('g:jedi#use_tag_stack')) == 1 + result = set_buffer(n.module_path, options=options, + using_tagstack=using_tagstack) + if not result: + return [] + if (using_tagstack and n.module_path and + n.module_path.exists()): + tagname = n.name + with tempfile('{0}\t{1}\t{2}'.format( + tagname, n.module_path, 'call cursor({0}, {1})'.format( + n.line, n.column + 1))) as f: + old_tags = vim.eval('&tags') + old_wildignore = vim.eval('&wildignore') + try: + # Clear wildignore to ensure tag file isn't ignored + vim.command('set wildignore=') + vim.command('let &tags = %s' % + repr(PythonToVimStr(f.name))) + vim.command('tjump %s' % tagname) + finally: + vim.command('let &tags = %s' % + repr(PythonToVimStr(old_tags))) + vim.command('let &wildignore = %s' % + repr(PythonToVimStr(old_wildignore))) + vim.current.window.cursor = n.line, n.column + + +def relpath(path): + """Make path relative to cwd if it is below.""" + abspath = os.path.abspath(path) + if abspath.startswith(os.getcwd()): + return os.path.relpath(path) + return path + + +def annotate_description(n): + code = n.get_line_code().strip() + if n.type == 'statement': + return code + if n.type == 'function': + if code.startswith('def'): + return code + typ = 'def' + else: + typ = n.type + return '[%s] %s' % (typ, code) + + +def show_goto_multi_results(names, mode): + """Create (or reuse) a quickfix list for multiple names.""" + global _current_names + + lst = [] + (row, col) = vim.current.window.cursor + current_idx = None + current_def = None + for n in names: + if n.column is None: + # Typically a namespace, in the future maybe other things as + # well. + lst.append(dict(text=PythonToVimStr(n.description))) + else: + text = annotate_description(n) + lst.append(dict(filename=PythonToVimStr(relpath(str(n.module_path))), + lnum=n.line, col=n.column + 1, + text=PythonToVimStr(text))) + + # Select current/nearest entry via :cc later. + if n.line == row and n.column <= col: + if (current_idx is None + or (abs(lst[current_idx]["col"] - col) + > abs(n.column - col))): + current_idx = len(lst) + current_def = n + + # Build qflist title. + qf_title = mode + if current_def is not None: + if current_def.full_name: + qf_title += ": " + current_def.full_name + else: + qf_title += ": " + str(current_def) + select_entry = current_idx + else: + select_entry = 0 + + qf_context = id(names) + if (_current_names + and VimCompat.can_update_current_qflist_for_context(qf_context)): + # Same list, only adjust title/selected entry. + VimCompat.setqflist_title(qf_title) + vim_command('%dcc' % select_entry) + else: + VimCompat.setqflist(lst, title=qf_title, context=qf_context) + for_usages = mode == "usages" + vim_eval('jedi#add_goto_window(%d, %d)' % (for_usages, len(lst))) + vim_command('%d' % select_entry) + + +def _same_names(a, b): + """Compare without _inference_state. + + Ref: https://github.com/davidhalter/jedi-vim/issues/952) + """ + return all( + x._name.start_pos == y._name.start_pos + and x.module_path == y.module_path + and x.name == y.name + for x, y in zip(a, b) + ) + + +@catch_and_print_exceptions +def usages(visuals=True): + script = get_script() + names = script.get_references(*get_pos()) + if not names: + echo_highlight("No usages found here.") + return names + + if visuals: + global _current_names + + if _current_names: + if _same_names(_current_names, names): + names = _current_names + else: + clear_usages() + assert not _current_names + + show_goto_multi_results(names, "usages") + if not _current_names: + _current_names = names + highlight_usages() + else: + assert names is _current_names # updated above + return names + + +_current_names = None +"""Current definitions to use for highlighting.""" +_pending_names = {} +"""Pending definitions for unloaded buffers.""" +_placed_names_in_buffers = set() +"""Set of buffers for faster cleanup.""" + + +IS_NVIM = hasattr(vim, 'from_nvim') +if IS_NVIM: + vim_prop_add = None +else: + vim_prop_type_added = False + try: + vim_prop_add = vim.Function("prop_add") + except ValueError: + vim_prop_add = None + else: + vim_prop_remove = vim.Function("prop_remove") + + +def clear_usages(): + """Clear existing highlights.""" + global _current_names + if _current_names is None: + return + _current_names = None + + if IS_NVIM: + for buf in _placed_names_in_buffers: + src_ids = buf.vars.get('_jedi_usages_src_ids') + if src_ids is not None: + for src_id in src_ids: + buf.clear_highlight(src_id) + elif vim_prop_add: + for buf in _placed_names_in_buffers: + vim_prop_remove({ + 'type': 'jediUsage', + 'all': 1, + 'bufnr': buf.number, + }) + else: + # Unset current window only. + assert _current_names is None + highlight_usages_for_vim_win() + + _placed_names_in_buffers.clear() + + +def highlight_usages(): + """Set usage names to be highlighted. + + With Neovim it will use the nvim_buf_add_highlight API to highlight all + buffers already. + + With Vim without support for text-properties only the current window is + highlighted via matchaddpos, and autocommands are setup to highlight other + windows on demand. Otherwise Vim's text-properties are used. + """ + global _current_names, _pending_names + + names = _current_names + _pending_names = {} + + if IS_NVIM or vim_prop_add: + bufs = {x.name: x for x in vim.buffers} + defs_per_buf = {} + for name in names: + try: + buf = bufs[str(name.module_path)] + except KeyError: + continue + defs_per_buf.setdefault(buf, []).append(name) + + if IS_NVIM: + # We need to remember highlight ids with Neovim's API. + buf_src_ids = {} + for buf, names in defs_per_buf.items(): + buf_src_ids[buf] = [] + for name in names: + src_id = _add_highlighted_name(buf, name) + buf_src_ids[buf].append(src_id) + for buf, src_ids in buf_src_ids.items(): + buf.vars['_jedi_usages_src_ids'] = src_ids + else: + for buf, names in defs_per_buf.items(): + try: + for name in names: + _add_highlighted_name(buf, name) + except vim.error as exc: + if exc.args[0].startswith('Vim:E275:'): + # "Cannot add text property to unloaded buffer" + _pending_names.setdefault(buf.name, []).extend( + names) + else: + highlight_usages_for_vim_win() + + +def _handle_pending_usages_for_buf(): + """Add (pending) highlights for the current buffer (Vim with textprops).""" + buf = vim.current.buffer + bufname = buf.name + try: + buf_names = _pending_names[bufname] + except KeyError: + return + for name in buf_names: + _add_highlighted_name(buf, name) + del _pending_names[bufname] + + +def _add_highlighted_name(buf, name): + lnum = name.line + start_col = name.column + + # Skip highlighting of module definitions that point to the start + # of the file. + if name.type == 'module' and lnum == 1 and start_col == 0: + return + + _placed_names_in_buffers.add(buf) + + # TODO: validate that name.name is at this position? + # Would skip the module definitions from above already. + + length = len(name.name) + if vim_prop_add: + # XXX: needs jediUsage highlight (via after/syntax/python.vim). + global vim_prop_type_added + if not vim_prop_type_added: + vim.eval("prop_type_add('jediUsage', {'highlight': 'jediUsage'})") + vim_prop_type_added = True + vim_prop_add(lnum, start_col+1, { + 'type': 'jediUsage', + 'bufnr': buf.number, + 'length': length, + }) + return + + assert IS_NVIM + end_col = name.column + length + src_id = buf.add_highlight('jediUsage', lnum-1, start_col, end_col, + src_id=0) + return src_id + + +def highlight_usages_for_vim_win(): + """Highlight usages in the current window. + + It stores the matchids in a window-local variable. + + (matchaddpos() only works for the current window.) + """ + win = vim.current.window + + cur_matchids = win.vars.get('_jedi_usages_vim_matchids') + if cur_matchids: + if cur_matchids[0] == vim.current.buffer.number: + return + + # Need to clear non-matching highlights. + for matchid in cur_matchids[1:]: + expr = 'matchdelete(%d)' % int(matchid) + vim.eval(expr) + + matchids = [] + if _current_names: + buffer_path = vim.current.buffer.name + for name in _current_names: + if (str(name.module_path) or '') == buffer_path: + positions = [ + [name.line, + name.column + 1, + len(name.name)] + ] + expr = "matchaddpos('jediUsage', %s)" % repr(positions) + matchids.append(int(vim_eval(expr))) + + if matchids: + vim.current.window.vars['_jedi_usages_vim_matchids'] = [ + vim.current.buffer.number] + matchids + elif cur_matchids is not None: + # Always set it (uses an empty list for "unset", which is not possible + # using del). + vim.current.window.vars['_jedi_usages_vim_matchids'] = [] + + # Remember if clearing is needed for later buffer autocommands. + vim.current.buffer.vars['_jedi_usages_needs_clear'] = bool(matchids) + + +@_check_jedi_availability(show_error=True) +@catch_and_print_exceptions +def show_documentation(): + script = get_script() + try: + names = script.help(*get_pos()) + except Exception: + # print to stdout, will be in :messages + names = [] + print("Exception, this shouldn't happen.") + print(traceback.format_exc()) + + if not names: + echo_highlight('No documentation found for that.') + vim.command('return') + return + + docs = [] + for n in names: + doc = n.docstring() + if doc: + title = 'Docstring for %s %s' % (n.type, n.full_name or n.name) + underline = '=' * len(title) + docs.append('%s\n%s\n%s' % (title, underline, doc)) + else: + docs.append('|No Docstring for %s|' % n) + text = ('\n' + '-' * 79 + '\n').join(docs) + vim.command('let l:doc = %s' % repr(PythonToVimStr(text))) + vim.command('let l:doc_lines = %s' % len(text.split('\n'))) + return True + + +@catch_and_print_exceptions +def clear_call_signatures(): + # Check if using command line call signatures + if int(vim_eval("g:jedi#show_call_signatures")) == 2: + vim_command('echo ""') + return + cursor = vim.current.window.cursor + e = vim_eval('g:jedi#call_signature_escape') + # We need two turns here to search and replace certain lines: + # 1. Search for a line with a call signature and save the appended + # characters + # 2. Actually replace the line and redo the status quo. + py_regex = r'%sjedi=([0-9]+), (.*?)%s.*?%sjedi%s'.replace( + '%s', re.escape(e)) + for i, line in enumerate(vim.current.buffer): + match = re.search(py_regex, line) + if match is not None: + # Some signs were added to minimize syntax changes due to call + # signatures. We have to remove them again. The number of them is + # specified in `match.group(1)`. + after = line[match.end() + int(match.group(1)):] + line = line[:match.start()] + match.group(2) + after + vim.current.buffer[i] = line + vim.current.window.cursor = cursor + + +@_check_jedi_availability(show_error=False) +@catch_and_print_exceptions +def show_call_signatures(signatures=()): + if int(vim_eval("has('conceal') && g:jedi#show_call_signatures")) == 0: + return + + # We need to clear the signatures before we calculate them again. The + # reason for this is that call signatures are unfortunately written to the + # buffer. + clear_call_signatures() + if signatures == (): + signatures = get_script().get_signatures(*get_pos()) + + if not signatures: + return + + if int(vim_eval("g:jedi#show_call_signatures")) == 2: + return cmdline_call_signatures(signatures) + + seen_sigs = [] + for i, signature in enumerate(signatures): + line, column = signature.bracket_start + # signatures are listed above each other + line_to_replace = line - i - 1 + # because there's a space before the bracket + insert_column = column - 1 + if insert_column < 0 or line_to_replace <= 0: + # Edge cases, when the call signature has no space on the screen. + break + + # TODO check if completion menu is above or below + line = vim_eval("getline(%s)" % line_to_replace) + + # Descriptions are usually looking like `param name`, remove the param. + params = [p.description.replace('\n', '').replace('param ', '', 1) + for p in signature.params] + try: + # *_*PLACEHOLDER*_* makes something fat. See after/syntax file. + params[signature.index] = '*_*%s*_*' % params[signature.index] + except (IndexError, TypeError): + pass + + # Skip duplicates. + if params in seen_sigs: + continue + seen_sigs.append(params) + + # This stuff is reaaaaally a hack! I cannot stress enough, that + # this is a stupid solution. But there is really no other yet. + # There is no possibility in VIM to draw on the screen, but there + # will be one (see :help todo Patch to access screen under Python. + # (Marko Mahni, 2010 Jul 18)) + text = " (%s) " % ', '.join(params) + text = ' ' * (insert_column - len(line)) + text + end_column = insert_column + len(text) - 2 # -2 due to bold symbols + + # Need to decode it with utf8, because vim returns always a python 2 + # string even if it is unicode. + e = vim_eval('g:jedi#call_signature_escape') + if hasattr(e, 'decode'): + e = e.decode('UTF-8') + # replace line before with cursor + regex = "xjedi=%sx%sxjedix".replace('x', e) + + prefix, replace = line[:insert_column], line[insert_column:end_column] + + # Check the replace stuff for strings, to append them + # (don't want to break the syntax) + regex_quotes = r'''\\*["']+''' + # `add` are all the quotation marks. + # join them with a space to avoid producing ''' + add = ' '.join(re.findall(regex_quotes, replace)) + # search backwards + if add and replace[0] in ['"', "'"]: + a = re.search(regex_quotes + '$', prefix) + add = ('' if a is None else a.group(0)) + add + + tup = '%s, %s' % (len(add), replace) + repl = prefix + (regex % (tup, text)) + add + line[end_column:] + + vim_eval('setline(%s, %s)' % (line_to_replace, repr(PythonToVimStr(repl)))) + + +@catch_and_print_exceptions +def cmdline_call_signatures(signatures): + def get_params(s): + return [p.description.replace('\n', '').replace('param ', '', 1) for p in s.params] + + def escape(string): + return string.replace('"', '\\"').replace(r'\n', r'\\n') + + def join(): + return ', '.join(filter(None, (left, center, right))) + + def too_long(): + return len(join()) > max_msg_len + + if len(signatures) > 1: + params = zip_longest(*map(get_params, signatures), fillvalue='_') + params = ['(' + ', '.join(p) + ')' for p in params] + else: + params = get_params(signatures[0]) + + index = next(iter(s.index for s in signatures if s.index is not None), None) + + # Allow 12 characters for showcmd plus 18 for ruler - setting + # noruler/noshowcmd here causes incorrect undo history + max_msg_len = int(vim_eval('&columns')) - 12 + if int(vim_eval('&ruler')): + max_msg_len -= 18 + max_msg_len -= len(signatures[0].name) + 2 # call name + parentheses + + if max_msg_len < (1 if params else 0): + return + elif index is None: + text = escape(', '.join(params)) + if params and len(text) > max_msg_len: + text = ELLIPSIS + elif max_msg_len < len(ELLIPSIS): + return + else: + left = escape(', '.join(params[:index])) + center = escape(params[index]) + right = escape(', '.join(params[index + 1:])) + while too_long(): + if left and left != ELLIPSIS: + left = ELLIPSIS + continue + if right and right != ELLIPSIS: + right = ELLIPSIS + continue + if (left or right) and center != ELLIPSIS: + left = right = None + center = ELLIPSIS + continue + if too_long(): + # Should never reach here + return + + max_num_spaces = max_msg_len + if index is not None: + max_num_spaces -= len(join()) + _, column = signatures[0].bracket_start + spaces = min(int(vim_eval('g:jedi#first_col +' + 'wincol() - col(".")')) + + column - len(signatures[0].name), + max_num_spaces) * ' ' + + if index is not None: + vim_command(' echon "%s" | ' + 'echohl Function | echon "%s" | ' + 'echohl None | echon "(" | ' + 'echohl jediFunction | echon "%s" | ' + 'echohl jediFat | echon "%s" | ' + 'echohl jediFunction | echon "%s" | ' + 'echohl None | echon ")"' + % (spaces, signatures[0].name, + left + ', ' if left else '', + center, ', ' + right if right else '')) + else: + vim_command(' echon "%s" | ' + 'echohl Function | echon "%s" | ' + 'echohl None | echon "(%s)"' + % (spaces, signatures[0].name, text)) + + +@_check_jedi_availability(show_error=True) +@catch_and_print_exceptions +def rename(): + if not int(vim.eval('a:0')): + # Need to save the cursor position before insert mode + cursor = vim.current.window.cursor + changenr = vim.eval('changenr()') # track undo tree + vim_command('augroup jedi_rename') + vim_command('autocmd InsertLeave call jedi#rename' + '({}, {}, {})'.format(cursor[0], cursor[1], changenr)) + vim_command('augroup END') + + vim_command("let s:jedi_replace_orig = expand('')") + line = vim_eval('getline(".")') + vim_command('normal! diw') + if re.match(r'\w+$', line[cursor[1]:]): + # In case the deleted word is at the end of the line we need to + # move the cursor to the end. + vim_command('startinsert!') + else: + vim_command('startinsert') + + else: + # Remove autocommand. + vim_command('autocmd! jedi_rename InsertLeave') + + args = vim.eval('a:000') + cursor = tuple(int(x) for x in args[:2]) + changenr = args[2] + + # Get replacement, if there is something on the cursor. + # This won't be the case when the user ends insert mode right away, + # and `` would pick up the nearest word instead. + if vim_eval('getline(".")[getpos(".")[2]-1]') != ' ': + replace = vim_eval("expand('')") + else: + replace = None + + vim_command('undo {}'.format(changenr)) + + vim.current.window.cursor = cursor + + if replace: + return do_rename(replace) + + +def rename_visual(): + replace = vim.eval('input("Rename to: ")') + orig = vim.eval('getline(".")[(getpos("\'<")[2]-1):getpos("\'>")[2]]') + do_rename(replace, orig) + + +def do_rename(replace, orig=None): + if not len(replace): + echo_highlight('No rename possible without name.') + return + + if orig is None: + orig = vim_eval('s:jedi_replace_orig') + + # Save original window / tab. + saved_tab = int(vim_eval('tabpagenr()')) + saved_win = int(vim_eval('winnr()')) + + temp_rename = usages(visuals=False) + # Sort the whole thing reverse (positions at the end of the line + # must be first, because they move the stuff before the position). + temp_rename = sorted(temp_rename, reverse=True, + key=lambda x: (str(x.module_path), x.line, x.column)) + buffers = set() + for r in temp_rename: + if r.in_builtin_module(): + continue + + result = set_buffer(r.module_path) + if not result: + echo_highlight('Failed to create buffer window for %s!' % (r.module_path)) + continue + + buffers.add(vim.current.buffer.name) + + # Replace original word. + r_line = vim.current.buffer[r.line - 1] + vim.current.buffer[r.line - 1] = (r_line[:r.column] + replace + + r_line[r.column + len(orig):]) + + # Restore previous tab and window. + vim_command('tabnext {0:d}'.format(saved_tab)) + vim_command('{0:d}wincmd w'.format(saved_win)) + + if len(buffers) > 1: + echo_highlight('Jedi did {0:d} renames in {1:d} buffers!'.format( + len(temp_rename), len(buffers))) + else: + echo_highlight('Jedi did {0:d} renames!'.format(len(temp_rename))) + + +@_check_jedi_availability(show_error=True) +@catch_and_print_exceptions +def py_import(): + args = shsplit(vim.eval('a:args')) + import_path = args.pop() + name = next(get_project().search(import_path), None) + if name is None: + echo_highlight('Cannot find %s in your project or on sys.path!' % import_path) + else: + cmd_args = ' '.join([a.replace(' ', '\\ ') for a in args]) + _goto_specific_name(name, options=cmd_args) + + +@catch_and_print_exceptions +def py_import_completions(): + argl = vim.eval('a:argl') + if jedi is None: + print('Pyimport completion requires jedi module: https://github.com/davidhalter/jedi') + comps = [] + else: + names = get_project().complete_search(argl) + comps = [argl + n for n in sorted(set(c.complete for c in names))] + vim.command("return '%s'" % '\n'.join(comps)) + + +@catch_and_print_exceptions +def set_buffer(path: Optional[Path], options='', using_tagstack=False): + """ + Opens a new buffer if we have to or does nothing. Returns True in case of + success. + """ + path = str(path or '') + # Check both, because it might be an empty string + if path in (vim.current.buffer.name, os.path.abspath(vim.current.buffer.name)): + return True + + path = relpath(path) + # options are what you can to edit the edit options + if int(vim_eval('g:jedi#use_tabs_not_buffers')) == 1: + _tabnew(path, options) + elif not vim_eval('g:jedi#use_splits_not_buffers') in [1, '1']: + user_split_option = vim_eval('g:jedi#use_splits_not_buffers') + split_options = { + 'top': 'topleft split', + 'left': 'topleft vsplit', + 'right': 'botright vsplit', + 'bottom': 'botright split', + 'winwidth': 'vs' + } + if (user_split_option == 'winwidth' and + vim.current.window.width <= 2 * int(vim_eval( + "&textwidth ? &textwidth : 80"))): + split_options['winwidth'] = 'sp' + if user_split_option not in split_options: + print('Unsupported value for g:jedi#use_splits_not_buffers: {0}. ' + 'Valid options are: {1}.'.format( + user_split_option, ', '.join(split_options.keys()))) + else: + vim_command(split_options[user_split_option] + " %s" % escape_file_path(path)) + else: + if int(vim_eval("!&hidden && &modified")) == 1: + if not vim_eval("bufname('%')"): + echo_highlight('Cannot open a new buffer, use `:set hidden` or save your buffer') + return False + else: + vim_command('w') + if using_tagstack: + return True + vim_command('edit %s %s' % (options, escape_file_path(path))) + # sometimes syntax is being disabled and the filetype not set. + if int(vim_eval('!exists("g:syntax_on")')) == 1: + vim_command('syntax enable') + if int(vim_eval("&filetype != 'python'")) == 1: + vim_command('set filetype=python') + return True + + +@catch_and_print_exceptions +def _tabnew(path, options=''): + """ + Open a file in a new tab or switch to an existing one. + + :param options: `:tabnew` options, read vim help. + """ + if int(vim_eval('has("gui")')) == 1: + vim_command('tab drop %s %s' % (options, escape_file_path(path))) + return + + for tab_nr in range(int(vim_eval("tabpagenr('$')"))): + for buf_nr in vim_eval("tabpagebuflist(%i + 1)" % tab_nr): + buf_nr = int(buf_nr) - 1 + try: + buf_path = vim.buffers[buf_nr].name + except (LookupError, ValueError): + # Just do good old asking for forgiveness. + # don't know why this happens :-) + pass + else: + if os.path.abspath(buf_path) == os.path.abspath(path): + # tab exists, just switch to that tab + vim_command('tabfirst | tabnext %i' % (tab_nr + 1)) + # Goto the buffer's window. + vim_command('exec bufwinnr(%i) . " wincmd w"' % (buf_nr + 1)) + break + else: + continue + break + else: + # tab doesn't exist, add a new one. + vim_command('tabnew %s' % escape_file_path(path)) + + +def escape_file_path(path): + return path.replace(' ', r'\ ') + + +def print_to_stdout(level, str_out): + print(str_out) diff --git a/sources_non_forked/jedi-vim/pythonx/jedi_vim_debug.py b/sources_non_forked/jedi-vim/pythonx/jedi_vim_debug.py new file mode 100644 index 00000000..2c673225 --- /dev/null +++ b/sources_non_forked/jedi-vim/pythonx/jedi_vim_debug.py @@ -0,0 +1,96 @@ +"""Used in jedi-vim's jedi#debug_info()""" +import sys + +import vim +from jedi_vim import PythonToVimStr, jedi + + +def echo(msg): + vim.command('echo %r' % PythonToVimStr(msg)) + + +def echo_error(msg): + vim.command('echohl ErrorMsg') + echo(msg) + vim.command('echohl None') + + +def format_exc_info(exc_info=None, tb_indent=2): + import traceback + + if exc_info is None: + exc_info = sys.exc_info() + + exc_msg = traceback.format_exception_only(exc_info[0], exc_info[1]) + lines = ''.join(exc_msg).rstrip('\n').split('\n') + + lines.append('Traceback (most recent call last):') + tb = traceback.format_tb(exc_info[2]) + lines.extend(''.join(tb).rstrip('\n').split('\n')) + + indent = ' ' * tb_indent + return '{0}'.format(('\n' + indent).join(lines)) + + +def get_known_environments(): + """Get known Jedi environments.""" + envs = list(jedi.find_virtualenvs()) + envs.extend(jedi.find_system_environments()) + return envs + + +def display_debug_info(): + echo(' - global sys.executable: `{0}`'.format(sys.executable)) + echo(' - global sys.version: `{0}`'.format( + ', '.join([x.strip() + for x in sys.version.split('\n')]))) + echo(' - global site module: `{0}`'.format(__import__('site').__file__)) + + try: + import jedi_vim + except Exception: + echo_error('ERROR: could not import jedi_vim: {0}'.format( + format_exc_info())) + return + + if jedi_vim.jedi is None: + if hasattr(jedi_vim, 'jedi_import_error'): + error_msg = format_exc_info(jedi_vim.jedi_import_error) + else: + error_msg = 'unknown error' + echo_error('ERROR: could not import the "jedi" Python module: {0}'.format( + error_msg)) + else: + echo('\n##### Jedi\n\n - path: `{0}`'.format(jedi_vim.jedi.__file__)) + echo(' - version: {0}'.format(jedi_vim.jedi.__version__)) + + try: + project = jedi_vim.get_project() + environment = project.get_environment() + except AttributeError: + script_evaluator = jedi_vim.jedi.Script('')._evaluator + try: + sys_path = script_evaluator.project.sys_path + except AttributeError: + sys_path = script_evaluator.sys_path + else: + echo('\n##### Jedi environment: {0}\n\n'.format(environment)) + echo(' - executable: {0}'.format(environment.executable)) + try: + sys_path = environment.get_sys_path() + except Exception: + echo_error('ERROR: failed to get sys path from environment: {0}'.format( + format_exc_info())) + return + + echo(' - sys_path:') + for p in sys_path: + echo(' - `{0}`'.format(p)) + + if environment: + echo('\n##### Known environments\n\n') + for environment in get_known_environments(): + echo(' - {0} ({1})\n'.format( + environment, + environment.executable, + )) diff --git a/sources_non_forked/jedi-vim/setup.cfg b/sources_non_forked/jedi-vim/setup.cfg new file mode 100644 index 00000000..93e190e5 --- /dev/null +++ b/sources_non_forked/jedi-vim/setup.cfg @@ -0,0 +1,5 @@ +[tool:pytest] +testpaths = test + +[flake8] +max-line-length = 100 diff --git a/sources_non_forked/jedi-vim/test/_utils.vim b/sources_non_forked/jedi-vim/test/_utils.vim new file mode 100644 index 00000000..5ad2a1d4 --- /dev/null +++ b/sources_non_forked/jedi-vim/test/_utils.vim @@ -0,0 +1,11 @@ +function! CurrentBufferIsModule(module_name) + return EndsWith(bufname('%'), a:module_name.'.py') +endfunction + + +function EndsWith(string, end) + let l:should = len(a:string) - strlen(a:end) + return l:should == stridx(a:string, a:end, should) +endfunction + +" vim: et:ts=4:sw=4 diff --git a/sources_non_forked/jedi-vim/test/test_integration.py b/sources_non_forked/jedi-vim/test/test_integration.py new file mode 100644 index 00000000..10a7b172 --- /dev/null +++ b/sources_non_forked/jedi-vim/test/test_integration.py @@ -0,0 +1,65 @@ +"""Runs tests from ./vspec in vim-vspec.""" +import os +import subprocess +try: + from urllib.request import urlretrieve +except ImportError: + from urllib import urlretrieve +import zipfile + +import pytest + +vspec_version = '1.9.0' + +VSPEC_URL = 'https://github.com/kana/vim-vspec/archive/%s.zip' % vspec_version +root = os.path.dirname(os.path.dirname(__file__)) +CACHE_FOLDER = os.path.join(root, 'build') +VSPEC_FOLDER = os.path.join(CACHE_FOLDER, 'vim-vspec-%s' % vspec_version) +VSPEC_RUNNER = os.path.join(VSPEC_FOLDER, 'bin/vspec') +TEST_DIR = os.path.join(root, 'test', 'vspec') + + +@pytest.fixture(scope='session') +def install_vspec(): + if not os.path.isdir(CACHE_FOLDER): + os.mkdir(CACHE_FOLDER) + + if not os.path.exists(VSPEC_FOLDER): + name, hdrs = urlretrieve(VSPEC_URL) + z = zipfile.ZipFile(name) + for n in z.namelist(): + dest = os.path.join(CACHE_FOLDER, n) + destdir = os.path.dirname(dest) + if not os.path.isdir(destdir): + os.makedirs(destdir) + data = z.read(n) + if not os.path.isdir(dest): + with open(dest, 'wb') as f: + f.write(data) + z.close() + os.chmod(VSPEC_RUNNER, 0o777) + + +def get_vspec_tests(): + for f in os.listdir(TEST_DIR): + yield os.path.relpath(os.path.join(TEST_DIR, f)) + + +@pytest.mark.parametrize('path', get_vspec_tests()) +def test_integration(install_vspec, path): + output = subprocess.check_output( + [VSPEC_RUNNER, '.', VSPEC_FOLDER, os.path.relpath(path, root)], + cwd=root, + ) + had_ok = False + for line in output.splitlines(): + if (line.startswith(b'not ok') or + line.startswith(b'Error') or + line.startswith(b'Bail out!')): + pytest.fail(u"{0} failed:\n{1}".format( + path, output.decode('utf-8')), pytrace=False) + if not had_ok and line.startswith(b'ok'): + had_ok = True + if not had_ok: + pytest.fail(u"{0} failed: no 'ok' found:\n{1}".format( + path, output.decode('utf-8')), pytrace=False) diff --git a/sources_non_forked/jedi-vim/test/vimrc b/sources_non_forked/jedi-vim/test/vimrc new file mode 100644 index 00000000..82111f3d --- /dev/null +++ b/sources_non_forked/jedi-vim/test/vimrc @@ -0,0 +1,8 @@ +" Minimal vimrc to use jedi-vim. +" +" Not used anywhere yet, but allows for easy testing. +let script_dir = fnamemodify(expand(''), ':h:h') +let &runtimepath = script_dir.','.&runtimepath.','.script_dir.'/after' + +syntax on +filetype plugin indent on diff --git a/sources_non_forked/jedi-vim/test/vspec/choose-venv.vim b/sources_non_forked/jedi-vim/test/vspec/choose-venv.vim new file mode 100644 index 00000000..d93ea075 --- /dev/null +++ b/sources_non_forked/jedi-vim/test/vspec/choose-venv.vim @@ -0,0 +1,29 @@ +source plugin/jedi.vim +source test/_utils.vim + +describe 'simple:' + before + new + normal! ifoo + end + + after + bd! + end + + it 'choose' + Expect g:jedi#environment_path == 'auto' + Expect bufname('%') == '' + + JediChooseEnvironment + " A Python executable needs to be a few letters + Expect len(getline('.')) > 5 + Expect bufname('%') == 'Hit Enter to Choose an Environment' + + execute "normal \" + Expect g:jedi#environment_path != 'auto' + bd " TODO why is this necessary? There seems to be a random buffer. + Expect bufname('%') == '' + Expect getline('.') == 'foo' + end +end diff --git a/sources_non_forked/jedi-vim/test/vspec/completions.vim b/sources_non_forked/jedi-vim/test/vspec/completions.vim new file mode 100644 index 00000000..068e5392 --- /dev/null +++ b/sources_non_forked/jedi-vim/test/vspec/completions.vim @@ -0,0 +1,131 @@ +let g:jedi#completions_command = 'X' +source plugin/jedi.vim + +describe 'completions' + before + new + set filetype=python + end + + after + " default + let g:jedi#popup_select_first = 1 + bd! + end + + it 'longest in completeopt' + " This gets set up with Vim only on VimEnter. + if has('nvim') + Expect stridx(&completeopt, 'longest') > -1 + else + Expect stridx(&completeopt, 'longest') == -1 + doautocmd VimEnter + Expect stridx(&completeopt, 'longest') > -1 + endif + + " Do not use it for following tests. + set completeopt-=longest + end + + it 'no smart import by default' + exec "normal ifrom os " + Expect getline('.') == 'from os ' + end + + it 'import' + " X is the completion command + normal oimporX + Expect getline('.') == 'import' + normal a subproX + Expect getline('.') == 'import subprocess' + end + + it 'exception' + normal oIndentationErrX + Expect getline('.') == 'IndentationError' + + " Do not remap keys (".") here, otherwise this triggers completion in + " Neovim already. + normal! a().filena + + normal aX + Expect getline('.') == 'IndentationError().filename' + end + + it 'multi complete' + " NOTE: nvim results in "importErr()" here with completeopt+=longest, + " but Vim is fine. + " This is due to `pumvisible()` in jedi#complete_opened being true + " with nvim still, but it is 0 with Vim, i.e. Vim appears to close + " the pum already (with the tests). + " + " This might be a misunderstanding though, since the test might not + " expect the "import" keyword to be offered for completion?! + normal oImpXErrX() + Expect getline('.') == 'ImportError()' + end + + it 'cycling through entries popup_select_first=0' + set completeopt+=longest + let g:jedi#popup_select_first = 0 + execute "normal oraise impX\" + + Expect getline('.') == 'raise ImportError' + set completeopt-=longest + end + + it 'cycling through entries popup_select_first=1' + execute "normal oraise impX\" + Expect getline('.') == 'raise ImportWarning' + end + + it 'cycling through entries popup_select_first=1 and longest' + set completeopt+=longest + execute "normal oraise impX" + Expect getline('.') == 'raise Import' + + " With Neovim pumvisible() is 1 in jedi#complete_opened, which then + " triggers the . This is not the case with Vim. + if has('nvim') + execute "normal oraise impX\" + Expect getline('.') == 'raise ImportWarning' + + execute "normal oraise impX\\" + Expect getline('.') == 'raise imp' + else + execute "normal oraise impX\" + Expect getline('.') == 'raise ImportError' + + execute "normal oraise impX\\" + Expect getline('.') == 'raise ImportWarning' + endif + set completeopt-=longest + end +end + +describe 'smart completions' + before + new + let g:jedi#smart_auto_mappings = 1 + set filetype=python + end + + after + " default + let g:jedi#smart_auto_mappings = 0 + bd! + end + + it 'smart import' + exec "normal ifrom os " + Expect getline('.') == 'from os import ' + end + + it 'no smart import after space' + exec "normal! ifrom os " + exec "normal a " + Expect getline('.') == 'from os ' + end +end + +" vim: et:ts=4:sw=4 diff --git a/sources_non_forked/jedi-vim/test/vspec/completions_disabled.vim b/sources_non_forked/jedi-vim/test/vspec/completions_disabled.vim new file mode 100644 index 00000000..03d17c5f --- /dev/null +++ b/sources_non_forked/jedi-vim/test/vspec/completions_disabled.vim @@ -0,0 +1,20 @@ +let g:jedi#completions_command = 'X' +let g:jedi#completions_enabled = 0 +source plugin/jedi.vim + +describe 'completions_disabled' + before + set filetype=python + end + + after + try | %bwipeout! | catch | endtry + end + + it 'typing' + normal oraise ImportErrX + Expect getline('.') == 'raise ImportErrX' + end +end + +" vim: et:ts=4:sw=4 diff --git a/sources_non_forked/jedi-vim/test/vspec/documentation.vim b/sources_non_forked/jedi-vim/test/vspec/documentation.vim new file mode 100644 index 00000000..c97c1a89 --- /dev/null +++ b/sources_non_forked/jedi-vim/test/vspec/documentation.vim @@ -0,0 +1,34 @@ +source plugin/jedi.vim + +describe 'documentation docstrings' + before + set filetype=python + end + + after + try | %bwipeout! | catch | endtry + end + + it 'simple' + Expect maparg('K') == ':call jedi#show_documentation()' + put = 'ImportError' + normal GK + Expect bufname('%') == "__doc__" + Expect &filetype == 'rst' + let header = getline(1, 2) + Expect header[0] == "Docstring for class builtins.ImportError" + Expect header[1] == "========================================" + let content = join(getline(3, '$'), "\n") + Expect stridx(content, "Import can't find module") > 0 + normal K + Expect bufname('%') == '' + end + + it 'no documentation' + put = 'x = 2' + normal oGK + Expect bufname('%') == '' + end +end + +" vim: et:ts=4:sw=4 diff --git a/sources_non_forked/jedi-vim/test/vspec/goto.vim b/sources_non_forked/jedi-vim/test/vspec/goto.vim new file mode 100644 index 00000000..f5116f22 --- /dev/null +++ b/sources_non_forked/jedi-vim/test/vspec/goto.vim @@ -0,0 +1,177 @@ +let mapleader = '\' +source plugin/jedi.vim +source test/_utils.vim + +describe 'goto simple:' + before + new + set filetype=python + put =[ + \ 'def a(): pass', + \ 'b = a', + \ 'c = b', + \ ] + normal! ggdd + normal! G$ + Expect line('.') == 3 + end + + after + bd! + end + + it 'goto definitions' + normal \d + Expect line('.') == 2 + Expect col('.') == 1 + end + + it 'goto assignments' + normal \g + Expect line('.') == 2 + Expect col('.') == 1 + + " cursor before `=` means that it stays there. + normal \g + Expect line('.') == 2 + Expect col('.') == 1 + + " going to the last line changes it. + normal! $ + normal \g + Expect line('.') == 1 + Expect col('.') == 5 + end +end + + +describe 'goto with tabs:' + before + set filetype=python + let g:jedi#use_tabs_not_buffers = 1 + end + + after + try | %bwipeout! | catch | endtry + end + + it 'follow import' + put = ['import subprocess', 'subprocess'] + normal G\g + Expect getline('.') == 'import subprocess' + Expect line('.') == 2 + Expect col('.') == 8 + + normal G\d + Expect CurrentBufferIsModule('subprocess') == 1 + Expect line('.') == 1 + Expect col('.') == 1 + Expect tabpagenr('$') == 2 + Expect winnr('$') == 1 + bwipe + + Expect tabpagenr('$') == 1 + Expect bufname('%') == '' + end +end + + +describe 'goto with buffers' + before + set filetype=python + let g:jedi#use_tabs_not_buffers = 0 + end + + after + try | %bwipeout! | catch | endtry + set nohidden + end + + it 'no new tabs' + put = ['import os'] + normal G$ + call jedi#goto_assignments() + python3 jedi_vim.goto() + Expect CurrentBufferIsModule('os') == 0 + " Without hidden, it's not possible to open a new buffer, when the old + " one is not saved. + set hidden + call jedi#goto_assignments() + Expect CurrentBufferIsModule('os') == 1 + Expect winnr('$') == 1 + Expect tabpagenr('$') == 1 + Expect line('.') == 1 + Expect col('.') == 1 + end +end + + + +describe 'goto with splits' + before + enew! + set filetype=python + let g:jedi#use_splits_not_buffers = 'left' + end + + after + try | %bwipeout! | catch | endtry + end + + it 'follow import' + put = ['import subprocess', 'subprocess'] + normal G\g + Expect getline('.') == 'import subprocess' + Expect line('.') == 2 + Expect col('.') == 8 + + normal G\d + Expect CurrentBufferIsModule('subprocess') == 1 + Expect line('.') == 1 + Expect col('.') == 1 + Expect winnr('$') == 2 + wincmd l + Expect bufname('%') == '' + end + +end + + +describe 'goto wildignore' + before + enew! + set filetype=python + set wildignore=*,with\ spaces,*.pyc + set hidden + let g:jedi#use_tag_stack = 1 + let g:jedi#use_tabs_not_buffers = 0 + " Need to use splits for code coverage in new_buffer() + let g:jedi#use_splits_not_buffers = 1 + + put = ['from subprocess import Popen', 'Popen'] + Expect CurrentBufferIsModule('subprocess') == 0 + normal G + end + + after + try | %bwipeout! | catch | endtry + set wildignore&vim + end + + it 'restores wildignore' + let before = &wildignore + call jedi#goto() + Expect getline('.') =~ 'Popen' + Expect &wildignore == before + end + + it 'not using tagstack' + let g:jedi#use_tag_stack = 0 + call jedi#goto() + Expect CurrentBufferIsModule('subprocess') == 1 + Expect getline('.') =~ 'Popen' + end +end + + +" vim: et:ts=4:sw=4 diff --git a/sources_non_forked/jedi-vim/test/vspec/jedi_debug_info.vim b/sources_non_forked/jedi-vim/test/vspec/jedi_debug_info.vim new file mode 100644 index 00000000..a7b9b014 --- /dev/null +++ b/sources_non_forked/jedi-vim/test/vspec/jedi_debug_info.vim @@ -0,0 +1,13 @@ +source plugin/jedi.vim + +describe 'JediDebugInfo' + it 'works' + redir @a | JediDebugInfo | redir END + let output = split(@a, '\n') + Expect output[0] == 'You should run this in a buffer with filetype "python".' + Expect output[1] == '#### Jedi-vim debug information' + Expect output[-1] == '' + end +end + +" vim: et:ts=4:sw=4 diff --git a/sources_non_forked/jedi-vim/test/vspec/pyimport.vim b/sources_non_forked/jedi-vim/test/vspec/pyimport.vim new file mode 100644 index 00000000..fb4bc52f --- /dev/null +++ b/sources_non_forked/jedi-vim/test/vspec/pyimport.vim @@ -0,0 +1,34 @@ +source plugin/jedi.vim +source test/_utils.vim + +describe 'pyimport' + before + let g:jedi#use_tabs_not_buffers = 1 + let g:jedi#project_path = 'autoload' + end + + after + try | %bwipeout! | catch | endtry + unlet g:jedi#project_path + end + + it 'open_tab' + Pyimport os + Expect CurrentBufferIsModule('os') == 1 + Pyimport subprocess + Expect CurrentBufferIsModule('subprocess') == 1 + " the empty tab is sometimes also a tab + Expect tabpagenr('$') >= 2 + end + + it 'completion' + " don't know how to test this directly + "execute "Pyimport subproc\" + "Expect CurrentBufferIsModule('subprocess') == 1 + + Expect jedi#py_import_completions('subproc', 0, 0) == 'subprocess' + Expect jedi#py_import_completions('subprocess', 0, 0) == 'subprocess' + let g:comp = jedi#py_import_completions('sre_', 0, 0) + Expect g:comp == "sre_compile\nsre_constants\nsre_parse" + end +end diff --git a/sources_non_forked/jedi-vim/test/vspec/signatures.vim b/sources_non_forked/jedi-vim/test/vspec/signatures.vim new file mode 100644 index 00000000..8ac0ed95 --- /dev/null +++ b/sources_non_forked/jedi-vim/test/vspec/signatures.vim @@ -0,0 +1,143 @@ +source plugin/jedi.vim + +describe 'signatures' + before + enew + set filetype=python + end + + after + try | %bwipeout! | catch | endtry + end + + it 'simple' + normal odef xyz(number): return + normal o + normal oxyz() + doautocmd CursorHoldI + Expect getline(3) == '?!?jedi=0, ?!? (*_*number*_*) ?!?jedi?!?' + + doautocmd InsertLeave + Expect getline(3) == '' + end + + it 'multiple buffers' + set hidden + new + setfiletype python + redir => autocmds + autocmd jedi_call_signatures * + redir END + Expect autocmds =~# 'jedi_call_signatures' + buffer # + redir => autocmds + autocmd jedi_call_signatures * + redir END + Expect autocmds =~# 'jedi_call_signatures' + end + + it 'simple after CursorHoldI with only parenthesis' + noautocmd normal o + doautocmd CursorHoldI + noautocmd normal istaticmethod() + doautocmd CursorHoldI + Expect getline(1) == '?!?jedi=0, ?!? (*_*f: Callable[..., Any]*_*) ?!?jedi?!?' + end + + it 'highlights correct argument' + noautocmd normal o + doautocmd CursorHoldI + noautocmd normal iformat(42, "x") + " Move to x - highlights "x". + noautocmd normal 2h + doautocmd CursorHoldI + Expect getline(1) == '?!?jedi=0, ?!? (value: object, *_*format_spec: str=...*_*) ?!?jedi?!?' + " Move left to 42 - hightlights first argument ("value"). + noautocmd normal 4h + doautocmd CursorHoldI + Expect getline(1) == '?!?jedi=0, ?!? (*_*value: object*_*, format_spec: str=...) ?!?jedi?!?' + end + + it 'no signature' + exe 'normal ostr ' + python3 jedi_vim.show_call_signatures() + Expect getline(1, '$') == ['', 'str '] + end + + it 'signatures disabled' + let g:jedi#show_call_signatures = 0 + + exe 'normal ostr( ' + python3 jedi_vim.show_call_signatures() + Expect getline(1, '$') == ['', 'str( '] + + let g:jedi#show_call_signatures = 1 + end + + it 'command line simple' + let g:jedi#show_call_signatures = 2 + call jedi#configure_call_signatures() + + exe 'normal ostaticmethod( ' + redir => msg + python3 jedi_vim.show_call_signatures() + redir END + Expect msg == "\nstaticmethod(f: Callable[..., Any])" + + redir => msg + doautocmd InsertLeave + redir END + Expect msg == "\n" + + normal Sdef foo(a, b): pass + exe 'normal ofoo(a, b, c, ' + redir => msg + python3 jedi_vim.show_call_signatures() + redir END + Expect msg == "\nfoo(a, b)" + end + + it 'command line truncation' + let g:jedi#show_call_signatures = 2 + call jedi#configure_call_signatures() + + function! Signature() + redir => msg + python3 jedi_vim.show_call_signatures() + redir END + return msg + endfunction + + let funcname = repeat('a', &columns - (30 + (&ruler ? 18 : 0))) + put = 'def '.funcname.'(arg1, arg2, arg3, a, b, c):' + put = ' pass' + execute "normal o\".funcname."( " + Expect Signature() == "\n".funcname."(arg1, …)" + + exe 'normal sarg1, ' + Expect Signature() == "\n".funcname."(…, arg2, …)" + + exe 'normal sarg2, arg3, ' + Expect Signature() == "\n".funcname."(…, a, b, c)" + + exe 'normal sa, b, ' + Expect Signature() == "\n".funcname."(…, c)" + + g/^/d + put = 'def '.funcname.'('.repeat('b', 20).', arg2):' + put = ' pass' + execute "normal o\".funcname."( " + Expect Signature() == "\n".funcname."(…)" + end + + it 'command line no signature' + let g:jedi#show_call_signatures = 2 + call jedi#configure_call_signatures() + + exe 'normal ostr ' + redir => msg + python3 jedi_vim.show_call_signatures() + redir END + Expect msg == "\n" + end +end diff --git a/update_plugins.py b/update_plugins.py index e71905cf..a0e130af 100644 --- a/update_plugins.py +++ b/update_plugins.py @@ -63,6 +63,7 @@ vim-indent-guides https://github.com/nathanaelkane/vim-indent-guides mru.vim https://github.com/vim-scripts/mru.vim editorconfig-vim https://github.com/editorconfig/editorconfig-vim dracula https://github.com/dracula/vim +jedi-vim https://github.com/davidhalter/jedi-vim """.strip() GITHUB_ZIP = "%s/archive/master.zip" diff --git a/vimrcs/plugins_config.vim b/vimrcs/plugins_config.vim index f510083c..d177de89 100644 --- a/vimrcs/plugins_config.vim +++ b/vimrcs/plugins_config.vim @@ -186,3 +186,14 @@ let g:EditorConfig_exclude_patterns = ['fugitive://.*'] " Copy the link to the line of a Git repository to the clipboard nnoremap v :.GBrowse! xnoremap v :'<'>GBrowse! + + +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" => jedi-vim +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +let g:jedi#auto_vim_configuration = 0 +let g:jedi#goto_assignments_command = "a" +let g:jedi#usages_command = "u" +let g:jedi#completions_command = "" +let g:jedi#rename_command = "r" +let g:jedi#popup_on_dot = 0