From bbbedb5311d0ecab93e62b3317b520cc7b2442a5 Mon Sep 17 00:00:00 2001 From: Kurtis Moxley Date: Mon, 8 Aug 2022 16:41:37 +0800 Subject: [PATCH] Update some plugins. --- .../vim-go/.github/workflows/test.yml | 2 +- sources_non_forked/vim-go/CHANGELOG.md | 6 + sources_non_forked/vim-go/Dockerfile | 2 +- .../vim-go/autoload/go/debug_test.vim | 11 +- .../vim-go/autoload/go/lint_test.vim | 107 +++++++++--------- .../vim-go/autoload/go/test_test.vim | 10 +- .../vim-go/autoload/go/util.vim | 30 +++-- sources_non_forked/vim-go/doc/vim-go.txt | 8 +- sources_non_forked/vim-go/plugin/go.vim | 10 ++ sources_non_forked/vim-ruby/indent/ruby.vim | 2 +- .../spec/indent/method_definitions_spec.rb | 4 + .../vim-snippets/UltiSnips/python.snippets | 34 +++++- .../vim-snippets/addon-info.json | 4 +- .../vim-snippets/snippets/python.snippets | 47 +++++++- .../vim-snippets/snippets/tex.snippets | 6 +- 15 files changed, 204 insertions(+), 79 deletions(-) diff --git a/sources_non_forked/vim-go/.github/workflows/test.yml b/sources_non_forked/vim-go/.github/workflows/test.yml index 95863cf7..4119946c 100644 --- a/sources_non_forked/vim-go/.github/workflows/test.yml +++ b/sources_non_forked/vim-go/.github/workflows/test.yml @@ -27,7 +27,7 @@ jobs: strategy: fail-fast: false matrix: - go: ['1.17','1.18'] + go: ['1.18','1.19'] vim: ['vim-8.0', 'vim-8.2', 'nvim'] steps: - name: setup Go diff --git a/sources_non_forked/vim-go/CHANGELOG.md b/sources_non_forked/vim-go/CHANGELOG.md index f33b6ce8..94a4aba9 100644 --- a/sources_non_forked/vim-go/CHANGELOG.md +++ b/sources_non_forked/vim-go/CHANGELOG.md @@ -8,8 +8,14 @@ IMPROVEMENTS: * Show diagnostics via go#tool#DescribeBalloon(). [[GH-3415]](https://github.com/fatih/vim-go/pull/3415) [[GH-3417]](https://github.com/fatih/vim-go/pull/3417) +* Allow version of individual tools to be installed with `:GoUpdateBinaries` + and `:GoInstallBinaries` to be overridden by users. + [[GH-3435]](https://github.com/fatih/vim-go/pull/3435) + [[GH-3436]](https://github.com/fatih/vim-go/pull/3436) BUG FIXES: +* Fix quoting of arguments when shell is set to pwsh on Windows. + [[GH-3422]](https://github.com/fatih/vim-go/pull/3422) ## v1.26 - (April 23, 2022) diff --git a/sources_non_forked/vim-go/Dockerfile b/sources_non_forked/vim-go/Dockerfile index 22b29962..f786c4e0 100644 --- a/sources_non_forked/vim-go/Dockerfile +++ b/sources_non_forked/vim-go/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.18.1 +FROM golang:1.19.0 RUN apt-get update -y --allow-insecure-repositories && \ apt-get install -y build-essential curl git libncurses5-dev python3-pip && \ diff --git a/sources_non_forked/vim-go/autoload/go/debug_test.vim b/sources_non_forked/vim-go/autoload/go/debug_test.vim index b7ce96a2..fa4e7acd 100644 --- a/sources_non_forked/vim-go/autoload/go/debug_test.vim +++ b/sources_non_forked/vim-go/autoload/go/debug_test.vim @@ -28,9 +28,18 @@ function! Test_GoDebugStart_Errors() abort let l:expected = [ \ {'lnum': 0, 'bufnr': 0, 'col': 0, 'valid': 0, 'vcol': 0, 'nr': -1, 'type': '', 'pattern': '', 'text': '# vim-go.test/debug/compilerror'}, - \ {'lnum': 6, 'bufnr': bufnr('%'), 'col': 22, 'valid': 1, 'vcol': 0, 'nr': -1, 'type': '', 'pattern': '', 'text': ' syntax error: unexpected newline, expecting comma or )'}, + \ {'lnum': 6, 'bufnr': bufnr('%'), 'col': 22, 'valid': 1, 'vcol': 0, 'nr': -1, 'type': '', 'pattern': '', 'text': ' syntax error: unexpected newline in argument list; possibly missing comma or )'}, \ {'lnum': 0, 'bufnr': 0, 'col': 0, 'valid': 0, 'vcol': 0, 'nr': -1, 'type': '', 'pattern': '', 'text': 'exit status 2'} \] + let [l:goversion, l:err] = go#util#Exec(['go', 'env', 'GOVERSION']) + let l:goversion = split(l:goversion, "\n")[0] + if l:goversion < 'go1.19' + let expected = [ + \ {'lnum': 0, 'bufnr': 0, 'col': 0, 'valid': 0, 'vcol': 0, 'nr': -1, 'type': '', 'pattern': '', 'text': '# vim-go.test/debug/compilerror'}, + \ {'lnum': 6, 'bufnr': bufnr('%'), 'col': 22, 'valid': 1, 'vcol': 0, 'nr': -1, 'type': '', 'pattern': '', 'text': ' syntax error: unexpected newline, expecting comma or )'}, + \ {'lnum': 0, 'bufnr': 0, 'col': 0, 'valid': 0, 'vcol': 0, 'nr': -1, 'type': '', 'pattern': '', 'text': 'exit status 2'} + \ ] + endif call setqflist([], 'r') call assert_false(exists(':GoDebugStop')) diff --git a/sources_non_forked/vim-go/autoload/go/lint_test.vim b/sources_non_forked/vim-go/autoload/go/lint_test.vim index 55118352..312ac424 100644 --- a/sources_non_forked/vim-go/autoload/go/lint_test.vim +++ b/sources_non_forked/vim-go/autoload/go/lint_test.vim @@ -44,8 +44,8 @@ func! s:gometa(metalinter) abort let actual = copy(getqflist()) endwhile - " sort the results, because golangci-lint seems to be returning the golint - " deprecation notice in a non-deterministic order. + " sort the results, because golangci-lint doesn't always return notices in + " a deterministic order. call sort(l:actual) call sort(l:expected) @@ -163,8 +163,8 @@ func! s:gometaautosave(metalinter, withList) abort let l:actual = copy(getloclist(0)) endwhile - " sort the results, because golangci-lint seems to be returning the golint - " deprecation notice in a non-deterministic order. + " sort the results, because golangci-lint doesn't always return notices in + " a deterministic order. call sort(l:actual) call sort(l:expected) @@ -176,48 +176,47 @@ func! s:gometaautosave(metalinter, withList) abort endtry endfunc -func! Test_GometaGolangciLint_importabs() abort - call s:gometa_importabs('golangci-lint') -endfunc - -func! s:gometa_importabs(metalinter) abort - let RestoreGOPATH = go#util#SetEnv('GOPATH', fnamemodify(getcwd(), ':p') . 'test-fixtures/lint') - silent exe 'e! ' . $GOPATH . '/src/lint/golangci-lint/problems/importabs/problems.go' - - try - let g:go_metalinter_command = a:metalinter - - let expected = [ - \ {'lnum': 3, 'bufnr': bufnr('%'), 'col': 8, 'pattern': '', 'valid': 1, 'vcol': 0, 'nr': -1, 'type': '', 'module': '', 'text': '"/quux" imported but not used (typecheck)'}, - \ {'lnum': 0, 'bufnr': 0, 'col': 0, 'pattern': '', 'valid': 1, 'vcol': 0, 'nr': -1, 'type': 'w', 'module': '', 'text': '[runner] The linter ''golint'' is deprecated (since v1.41.0) due to: The repository of the linter has been archived by the owner. Replaced by revive.'}, - \ ] - " clear the quickfix list - call setqflist([], 'r') - - let g:go_metalinter_enabled = ['golint'] - - call go#lint#Gometa(0, 0) - - let actual = getqflist() - let start = reltime() - while len(actual) == 0 && reltimefloat(reltime(start)) < 10 - sleep 100m - let actual = copy(getqflist()) - endwhile - - " sort the results, because golangci-lint seems to be returning the golint - " deprecation notice in a non-deterministic order. - call sort(l:actual) - call sort(l:expected) - - call gotest#assert_quickfix(actual, expected) - finally - call call(RestoreGOPATH, []) - unlet g:go_metalinter_enabled - unlet g:go_metalinter_command - endtry -endfunc - +"func! Test_GometaGolangciLint_importabs() abort +" call s:gometa_importabs('golangci-lint') +"endfunc +" +"func! s:gometa_importabs(metalinter) abort +" let RestoreGOPATH = go#util#SetEnv('GOPATH', fnamemodify(getcwd(), ':p') . 'test-fixtures/lint') +" silent exe 'e! ' . $GOPATH . '/src/lint/golangci-lint/problems/importabs/problems.go' +" +" try +" let g:go_metalinter_command = a:metalinter +" +" let expected = [ +" \ {'lnum': 3, 'bufnr': bufnr('%'), 'col': 8, 'pattern': '', 'valid': 1, 'vcol': 0, 'nr': -1, 'type': '', 'module': '', 'text': '"/quux" imported but not used (typecheck)'}, +" \ ] +" " clear the quickfix list +" call setqflist([], 'r') +" +" let g:go_metalinter_enabled = ['revive', 'typecheck'] +" +" call go#lint#Gometa(0, 0) +" +" let actual = getqflist() +" let start = reltime() +" while len(actual) == 0 && reltimefloat(reltime(start)) < 10 +" sleep 100m +" let actual = copy(getqflist()) +" endwhile +" +" " sort the results, because golangci-lint doesn't always return notices in +" " a deterministic order. +" call sort(l:actual) +" call sort(l:expected) +" +" call gotest#assert_quickfix(actual, expected) +" finally +" call call(RestoreGOPATH, []) +" unlet g:go_metalinter_enabled +" unlet g:go_metalinter_command +" endtry +"endfunc +" "func! Test_GometaAutoSaveGolangciLint_importabs() abort " call s:gometaautosave_importabs('golangci-lint') "endfunc @@ -266,7 +265,6 @@ func! s:gometa_multiple(metalinter) abort try let g:go_metalinter_command = a:metalinter let expected = [ - \ {'lnum': 0, 'bufnr': 0, 'col': 0, 'pattern': '', 'valid': 1, 'vcol': 0, 'nr': -1, 'type': 'w', 'module': '', 'text': '[runner] The linter ''golint'' is deprecated (since v1.41.0) due to: The repository of the linter has been archived by the owner. Replaced by revive.'}, \ {'lnum': 8, 'bufnr': bufnr('%'), 'col': 7, 'pattern': '', 'valid': 1, 'vcol': 0, 'nr': -1, 'type': '', 'module': '', 'text': 'time.Sleep undefined (type int has no field or method Sleep) (typecheck)'}, \ {'lnum': 4, 'bufnr': bufnr('%'), 'col': 2, 'pattern': '', 'valid': 1, 'vcol': 0, 'nr': -1, 'type': '', 'module': '', 'text': '"time" imported but not used (typecheck)'} \ ] @@ -274,7 +272,7 @@ func! s:gometa_multiple(metalinter) abort " clear the quickfix list call setqflist([], 'r') - let g:go_metalinter_enabled = ['revive'] + let g:go_metalinter_enabled = ['revive', 'typecheck'] call go#lint#Gometa(0, 0) @@ -285,8 +283,8 @@ func! s:gometa_multiple(metalinter) abort let actual = copy(getqflist()) endwhile - " sort the results, because golangci-lint seems to be returning the golint - " deprecation notice in a non-deterministic order. + " sort the results, because golangci-lint doesn't always return notices in + " a deterministic order. call sort(l:actual) call sort(l:expected) @@ -309,7 +307,6 @@ func! s:gometaautosave_multiple(metalinter) abort try let g:go_metalinter_command = a:metalinter let expected = [ - \ {'lnum': 0, 'bufnr': 0, 'col': 0, 'pattern': '', 'valid': 1, 'vcol': 0, 'nr': -1, 'type': 'w', 'module': '', 'text': '[runner] The linter ''golint'' is deprecated (since v1.41.0) due to: The repository of the linter has been archived by the owner. Replaced by revive.'}, \ {'lnum': 8, 'bufnr': bufnr('%'), 'col': 7, 'pattern': '', 'valid': 1, 'vcol': 0, 'nr': -1, 'type': '', 'module': '', 'text': 'time.Sleep undefined (type int has no field or method Sleep) (typecheck)'}, \ {'lnum': 4, 'bufnr': bufnr('%'), 'col': 2, 'pattern': '', 'valid': 1, 'vcol': 0, 'nr': -1, 'type': '', 'module': '', 'text': '"time" imported but not used (typecheck)'} \ ] @@ -317,7 +314,7 @@ func! s:gometaautosave_multiple(metalinter) abort " clear the location list call setloclist(0, [], 'r') - let g:go_metalinter_autosave_enabled = ['golint'] + let g:go_metalinter_autosave_enabled = ['revive', 'typecheck'] call go#lint#Gometa(0, 1) @@ -328,8 +325,8 @@ func! s:gometaautosave_multiple(metalinter) abort let actual = copy(getloclist(0)) endwhile - " sort the results, because golangci-lint seems to be returning the golint - " deprecation notice in a non-deterministic order. + " sort the results, because golangci-lint doesn't always return notices in + " a deterministic order. call sort(l:actual) call sort(l:expected) @@ -455,6 +452,7 @@ func! Test_Lint_GOPATH() abort compiler go let expected = [ + \ {'lnum': 1, 'bufnr': bufnr('%')+9, 'col': 1, 'valid': 1, 'vcol': 0, 'nr': -1, 'type': '', 'pattern': '', 'text': 'should have a package comment'}, \ {'lnum': 5, 'bufnr': bufnr('%'), 'col': 1, 'valid': 1, 'vcol': 0, 'nr': -1, 'type': '', 'pattern': '', 'text': 'exported function MissingDoc should have comment or be unexported'}, \ {'lnum': 5, 'bufnr': bufnr('test-fixtures/lint/src/lint/quux.go'), 'col': 1, 'valid': 1, 'vcol': 0, 'nr': -1, 'type': '', 'pattern': '', 'text': 'exported function AlsoMissingDoc should have comment or be unexported'} \ ] @@ -492,6 +490,7 @@ func! Test_Lint_NullModule() abort compiler go let expected = [ + \ {'lnum': 1, 'bufnr': bufnr('%')+9, 'col': 1, 'valid': 1, 'vcol': 0, 'nr': -1, 'type': '', 'pattern': '', 'text': 'should have a package comment'}, \ {'lnum': 5, 'bufnr': bufnr('%'), 'col': 1, 'valid': 1, 'vcol': 0, 'nr': -1, 'type': '', 'pattern': '', 'text': 'exported function MissingDoc should have comment or be unexported'}, \ {'lnum': 5, 'bufnr': bufnr('test-fixtures/lint/src/lint/quux.go'), 'col': 1, 'valid': 1, 'vcol': 0, 'nr': -1, 'type': '', 'pattern': '', 'text': 'exported function AlsoMissingDoc should have comment or be unexported'} \ ] diff --git a/sources_non_forked/vim-go/autoload/go/test_test.vim b/sources_non_forked/vim-go/autoload/go/test_test.vim index 4fcb3ed6..dabba84e 100644 --- a/sources_non_forked/vim-go/autoload/go/test_test.vim +++ b/sources_non_forked/vim-go/autoload/go/test_test.vim @@ -48,8 +48,16 @@ endfunc func! Test_GoTestCompilerError() abort let expected = [ - \ {'lnum': 6, 'bufnr': 6, 'col': 22, 'valid': 1, 'vcol': 0, 'nr': -1, 'type': '', 'pattern': '', 'text': 'syntax error: unexpected newline, expecting comma or )'} + \ {'lnum': 6, 'bufnr': 6, 'col': 22, 'valid': 1, 'vcol': 0, 'nr': -1, 'type': '', 'pattern': '', 'text': 'syntax error: unexpected newline in argument list; possibly missing comma or )'} \ ] + let [l:goversion, l:err] = go#util#Exec(['go', 'env', 'GOVERSION']) + let l:goversion = split(l:goversion, "\n")[0] + if l:goversion < 'go1.19' + let expected = [ + \ {'lnum': 6, 'bufnr': 6, 'col': 22, 'valid': 1, 'vcol': 0, 'nr': -1, 'type': '', 'pattern': '', 'text': 'syntax error: unexpected newline, expecting comma or )'} + \ ] + endif + call s:test('compilerror/compilerror_test.go', expected) endfunc diff --git a/sources_non_forked/vim-go/autoload/go/util.vim b/sources_non_forked/vim-go/autoload/go/util.vim index f6ebaf36..ad0d83c4 100644 --- a/sources_non_forked/vim-go/autoload/go/util.vim +++ b/sources_non_forked/vim-go/autoload/go/util.vim @@ -298,7 +298,21 @@ endfunction " Shelljoin returns a shell-safe string representation of arglist. The " {special} argument of shellescape() may optionally be passed. function! go#util#Shelljoin(arglist, ...) abort + " Preserve original shell. This needs to be kept in sync with how s:system + " sets shell. + let l:shell = &shell + try + if !go#util#IsWin() && executable('/bin/sh') + set shell=/bin/sh + endif + + if go#util#IsWin() + if executable($COMSPEC) + let &shell = $COMSPEC + endif + endif + let ssl_save = &shellslash set noshellslash if a:0 @@ -307,20 +321,12 @@ function! go#util#Shelljoin(arglist, ...) abort return join(map(copy(a:arglist), 'shellescape(v:val)'), ' ') finally + " Restore original values let &shellslash = ssl_save + let &shell = l:shell endtry endfunction -fu! go#util#Shellescape(arg) - try - let ssl_save = &shellslash - set noshellslash - return shellescape(a:arg) - finally - let &shellslash = ssl_save - endtry -endf - " Shelllist returns a shell-safe representation of the items in the given " arglist. The {special} argument of shellescape() may optionally be passed. function! go#util#Shelllist(arglist, ...) abort @@ -328,9 +334,9 @@ function! go#util#Shelllist(arglist, ...) abort let ssl_save = &shellslash set noshellslash if a:0 - return map(copy(a:arglist), 'shellescape(v:val, ' . a:1 . ')') + return map(copy(a:arglist), 'go#util#Shelljoin(v:val, ' . a:1 . ')') endif - return map(copy(a:arglist), 'shellescape(v:val)') + return map(copy(a:arglist), 'go#util#Shelljoin(v:val)') finally let &shellslash = ssl_save endtry diff --git a/sources_non_forked/vim-go/doc/vim-go.txt b/sources_non_forked/vim-go/doc/vim-go.txt index 0eefbecf..0432d33a 100644 --- a/sources_non_forked/vim-go/doc/vim-go.txt +++ b/sources_non_forked/vim-go/doc/vim-go.txt @@ -500,6 +500,9 @@ CTRL-t supplied, then only the specified binaries will be installed. The default is to install everything. + A specific version of a binary can be specified by appending Go's version + syntax to the binary name. e.g. `:GoInstallBinaries gopls@v0.9.1`. + Set |'g:go_get_update'| to disable updating dependencies. *:GoUpdateBinaries* @@ -510,6 +513,9 @@ CTRL-t supplied, then only the specified binaries will be updated. The default is to update everything. + A specific version of a binary can be specified by appending Go's version + syntax to the binary name. e.g. `:GoUpdateBinaries gopls@v0.9.1`. + Set |'g:go_get_update'| to disable updating dependencies. *:GoImplements* @@ -1989,7 +1995,7 @@ use different templates for different projects. *'g:go_template_test_file'* Like with |'g:go_template_file'|, this specifies the file to use for test -tempaltes. The template file should be under the `templates` folder, +templates. The template file should be under the `templates` folder, alternatively absolute paths can be used, too. Checkout |'g:go_template_autocreate'| for more info. By default, the `hello_world_test.go` file is used. diff --git a/sources_non_forked/vim-go/plugin/go.vim b/sources_non_forked/vim-go/plugin/go.vim index 5167e904..7855ce3b 100644 --- a/sources_non_forked/vim-go/plugin/go.vim +++ b/sources_non_forked/vim-go/plugin/go.vim @@ -113,11 +113,21 @@ function! s:GoInstallBinaries(updateBinaries, ...) let l:packages = {} if a:0 > 0 for l:bin in a:000 + let l:version = substitute(l:bin, '.*@', '', '') + if l:version == l:bin + let l:version = '' + endif + let l:bin = substitute(l:bin, '@.*', '', '') + let l:pkg = get(s:packages, l:bin, []) if len(l:pkg) == 0 call go#util#EchoError('unknown binary: ' . l:bin) return endif + + if l:version isnot '' + let l:pkg[0] = substitute(l:pkg[0], '@\zs.*', l:version, '') + endif let l:packages[l:bin] = l:pkg endfor else diff --git a/sources_non_forked/vim-ruby/indent/ruby.vim b/sources_non_forked/vim-ruby/indent/ruby.vim index f395fa7c..b65e3fd2 100644 --- a/sources_non_forked/vim-ruby/indent/ruby.vim +++ b/sources_non_forked/vim-ruby/indent/ruby.vim @@ -92,7 +92,7 @@ let s:ruby_indent_keywords = \ '\<\%(if\|for\|while\|until\|case\|unless\|begin\):\@!\>' " Def without an end clause: def method_call(...) = -let s:ruby_endless_def = '\ $6: + return ${0:self.$3 * self.$5} +endsnippet + + snippet contain "methods for emulating a container type" b def __len__(self): ${1:pass} @@ -603,9 +615,9 @@ $1 = property(**$1(), doc=$1.__doc__) endsnippet -#################### -# If / Else / Elif # -#################### +############################ +# If / Else / Elif / Match # +############################ snippet if "If" b if ${1:condition}: ${2:${VISUAL:pass}} @@ -627,6 +639,22 @@ else: ${5:pass} endsnippet +snippet match "Structural pattern matching" b +match ${1:expression}: + case ${2:pattern_1}: + ${3:pass} + case ${4:pattern_2}: + ${0:pass} +endsnippet + +snippet matchw "Pattern matching with wildcard" b +match ${1:expression}: + case ${2:pattern_1}: + ${3:pass} + case _: + ${0:pass} +endsnippet + ########################## # Try / Except / Finally # diff --git a/sources_non_forked/vim-snippets/addon-info.json b/sources_non_forked/vim-snippets/addon-info.json index 303bf285..22d8f375 100644 --- a/sources_non_forked/vim-snippets/addon-info.json +++ b/sources_non_forked/vim-snippets/addon-info.json @@ -1,8 +1,8 @@ { - "name" : "snipmate-snippets", + "name" : "vim-snippets", "author" : "community", "maintainer" : "honza @ github & others", - "repository" : {"type": "git", "url": "git://github.com/honza/snipmate-snippets.git"}, + "repository" : {"type": "git", "url": "git://github.com/honza/vim-snippets.git"}, "dependencies" : { }, "description" : "community driven set of snippets for snipmate" diff --git a/sources_non_forked/vim-snippets/snippets/python.snippets b/sources_non_forked/vim-snippets/snippets/python.snippets index 9b3798b8..b8f3822a 100644 --- a/sources_non_forked/vim-snippets/snippets/python.snippets +++ b/sources_non_forked/vim-snippets/snippets/python.snippets @@ -12,6 +12,7 @@ snippet uni ${0:representation} snippet from from ${1:package} import ${0:module} + # Module Docstring snippet docs """ @@ -29,18 +30,22 @@ snippet sk "skip unittests" b snippet wh while ${1:condition}: ${0:${VISUAL}} + # dowh - does the same as do...while in other languages snippet dowh while True: ${1} if ${0:condition}: break + snippet with with ${1:expr} as ${2:var}: ${0:${VISUAL}} + snippet awith async with ${1:expr} as ${2:var}: ${0:${VISUAL}} + # New Class snippet cl class ${1:ClassName}(${2:object}): @@ -52,11 +57,24 @@ snippet cl snippet cla class ${1:class_name}: """${0:description}""" + snippet clai class ${1:class_name}: """${2:description}""" def __init__(self, ${3:args}): ${0} + +# Data class +snippet dcl dataclass + @dataclass + class ${1:ClassName}: + """${2:description}""" + ${3:var_1}: ${4:int} + ${5:var_2}: ${6:float} = ${7:0} + + def ${8:total}(self): -> $6: + return ${0:self.$3 * self.$5} + # New Function snippet def def ${1:fname}(${2:`indent('.') ? 'self' : ''`}): @@ -72,6 +90,7 @@ snippet adef snippet adeff async def ${1:fname}(${2:`indent('.') ? 'self' : ''`}): ${0} + # New Method snippet defi def __init__(self, ${1:args}): @@ -104,10 +123,28 @@ snippet el snippet ei elif ${1:condition}: ${0:${VISUAL}} + +# Match +snippet match Structural pattern matching + match ${1:expression}: + case ${2:pattern_1}: + ${3:pass} + case ${4:pattern_2}: + ${5:pass} + +# Match with wildcard +snippet matchw Pattern matching with wildcard + match ${1:expression}: + case ${2:pattern_1}: + ${3:pass} + case _: + ${0:pass} + # For snippet for for ${1:item} in ${2:items}: ${0} + # Encodes snippet cutf8 # -*- coding: utf-8 -*- @@ -115,15 +152,18 @@ snippet clatin1 # -*- coding: latin-1 -*- snippet cascii # -*- coding: ascii -*- + # Lambda snippet ld ${1:var} = lambda ${2:vars} : ${0:action} + snippet ret return ${0} snippet . self. snippet sa self.attribute = attribute self.${1:attribute} = $1 + snippet try Try/Except try: ${1:${VISUAL}} @@ -152,6 +192,7 @@ snippet tryef Try/Except/Else/Finally ${5} finally: ${0} + # if __name__ == '__main__': snippet ifmain if __name__ == '__main__': @@ -196,9 +237,11 @@ snippet nosetrace __import__('nose').tools.set_trace() snippet pprint __import__('pprint').pprint(${1}) + snippet " """${0:doc} """ + # assertions snippet a= self.assertEqual(${0}, ${1}) @@ -219,6 +262,7 @@ snippet tgwt # then: ${3} snippet fut from __future__ import ${0} + #getopt snippet getopt try: @@ -236,6 +280,7 @@ snippet getopt ${0} elif option in ("-v", "--verbose"): verbose = argument + # argparse snippet addp parser = ${VISUAL:argparse.}ArgumentParser() @@ -279,7 +324,7 @@ snippet epydoc """ snippet dol def ${1:__init__}(self, *args, **kwargs): - super(${0:ClassName}, self).$1(*args, **kwargs) + super(${0:ClassName}, self).$1(*args, **kwargs) snippet kwg self.${1:var_name} = kwargs.get('$1', ${2:None}) snippet lkwg diff --git a/sources_non_forked/vim-snippets/snippets/tex.snippets b/sources_non_forked/vim-snippets/snippets/tex.snippets index ff94f187..e85e95f8 100644 --- a/sources_non_forked/vim-snippets/snippets/tex.snippets +++ b/sources_non_forked/vim-snippets/snippets/tex.snippets @@ -63,7 +63,7 @@ snippet eq equation environment snippet eql Labeled equation environment \\begin{equation} \\label{eq:${2}} - ${0:${VISUAL}} + ${0:${VISUAL}} \\end{equation} # Equation snippet eq* unnumbered equation environment @@ -406,6 +406,10 @@ snippet ddot ddot snippet vec vector \\vec{{$1}} {$0} +# Bar +snippet bar bar + \\bar{{$1}} {$0} + # Cross product snippet \x cross product \\times {$0}