diff --git a/README.md b/README.md index 217176ce..0fdb7bcf 100644 --- a/README.md +++ b/README.md @@ -99,6 +99,7 @@ Remove all clutter and focus only on the essential. Similar to iA Writer or Writ * [vim-bundle-mako](https://github.com/sophacles/vim-bundle-mako) * [vim-markdown](https://github.com/tpope/vim-markdown) * [nginx.vim](https://github.com/vim-scripts/nginx.vim): Highlights configuration files for nginx +* [vim-golang](https://github.com/jnwhiteh/vim-golang) ## How to include your own stuff? diff --git a/sources_non_forked/ack.vim/plugin/ack.vim b/sources_non_forked/ack.vim/plugin/ack.vim index ccd46861..3c664bd5 100644 --- a/sources_non_forked/ack.vim/plugin/ack.vim +++ b/sources_non_forked/ack.vim/plugin/ack.vim @@ -44,7 +44,7 @@ function! s:Ack(cmd, args) if a:cmd =~# '-g$' let g:ackformat="%f" else - let g:ackformat="%f:%l:%c:%m" + let g:ackformat="%f:%l:%c:%m,%f:%l:%m" end let grepprg_bak=&grepprg @@ -61,13 +61,15 @@ function! s:Ack(cmd, args) if a:cmd =~# '^l' exe g:ack_lhandler let l:apply_mappings = g:ack_apply_lmappings + let l:close_cmd = ':lclose' else exe g:ack_qhandler let l:apply_mappings = g:ack_apply_qmappings + let l:close_cmd = ':cclose' endif if l:apply_mappings - exec "nnoremap q :ccl" + exec "nnoremap q " . l:close_cmd exec "nnoremap t T" exec "nnoremap T TgT" exec "nnoremap o " @@ -80,7 +82,7 @@ function! s:Ack(cmd, args) " If highlighting is on, highlight the search keyword. if exists("g:ackhighlight") - let @/=a:args + let @/ = substitute(l:grepargs,'["'']','','g') set hlsearch end diff --git a/sources_non_forked/syntastic/README.markdown b/sources_non_forked/syntastic/README.markdown index fb4b8bb4..653bd7c6 100644 --- a/sources_non_forked/syntastic/README.markdown +++ b/sources_non_forked/syntastic/README.markdown @@ -43,7 +43,7 @@ LLVM intermediate language, Lua, MATLAB, NASM, Objective-C, Objective-C++, OCaml, Perl, Perl POD, PHP, gettext Portable Object, Puppet, Python, Racket, reStructuredText, Ruby, Rust, SASS/SCSS, Scala, Slim, Tcl, TeX, Texinfo, Twig, TypeScript, Vala, Verilog, VHDL, VimL, xHtml, XML, XSLT, YACC, YAML, z80, Zope -page templates, zsh. +page templates, and zsh. Below is a screenshot showing the methods that Syntastic uses to display syntax errors. Note that, in practise, you will only have a subset of these methods @@ -62,45 +62,48 @@ enabled. ## 2\. Installation -Installing syntastic is easy but first you need to have the pathogen plugin installed. If you already -have pathogen working then skip Step 1 and go to Step 2. +Installing syntastic is easy but first you need to have the [pathogen][1] +plugin installed. If you already have [pathogen][1] working then skip +[Step 1](#step1) and go to [Step 2](#step2). + ### 2.1\. Step 1: Install pathogen.vim -First I'll show you how to install tpope's [pathogen.vim][1] so that it's -easy to install syntastic. Do this in your Terminal so that you get the -pathogen.vim file and the directories it needs: - - mkdir -p ~/.vim/autoload ~/.vim/bundle; \ - curl -so ~/.vim/autoload/pathogen.vim \ - https://raw.github.com/tpope/vim-pathogen/master/autoload/pathogen.vim - -Next you *need to add this* to your ~/.vimrc: - - execute pathogen#infect() +First I'll show you how to install Tim Pope's [pathogen][1] so that it's easy to +install syntastic. Do this in your terminal so that you get the `pathogen.vim` +file and the directories it needs: +```sh +mkdir -p ~/.vim/autoload ~/.vim/bundle; \ +curl -so ~/.vim/autoload/pathogen.vim \ + https://raw.github.com/tpope/vim-pathogen/master/autoload/pathogen.vim +``` +Next you *need* to add this to your `~/.vimrc`: +```vim +execute pathogen#infect() +``` ### 2.2\. Step 2: Install syntastic as a pathogen bundle -You now have pathogen installed and can put syntastic into ~/.vim/bundle like this: - - - cd ~/.vim/bundle - git clone https://github.com/scrooloose/syntastic.git - +You now have pathogen installed and can put syntastic into `~/.vim/bundle` like +this: +```sh +cd ~/.vim/bundle +git clone https://github.com/scrooloose/syntastic.git +``` Quit vim and start it back up to reload it, then type: +```vim +:Helptags +``` +If you get an error when you do this, then you probably didn't install +[pathogen][1] right. Go back to [Step 1](#step1) and make sure you did the following: - :Helptags - -If you get an error when you do this, then you probably didn't install pathogen right. Go back to -step 1 and make sure you did the following: - -1. Created both the ~/.vim/autoload and ~/.vim/bundle directories. -2. Added the "call pathogen#infect()" line to your ~/.vimrc file -3. Did the git clone of syntastic inside ~/.vim/bundle +1. Created both the `~/.vim/autoload` and `~/.vim/bundle` directories. +2. Added the `call pathogen#infect()` line to your `~/.vimrc` file +3. Did the `git clone` of syntastic inside `~/.vim/bundle` 4. Have permissions to access all of these directories. @@ -111,56 +114,50 @@ step 1 and make sure you did the following: __Q. I installed syntastic but it isn't reporting any errors...__ A. The most likely reason is that none of the syntax checkers that it requires -is installed. For example: python requires either `flake8`, `pyflakes` -or `pylint` to be installed and in `$PATH`. To see which executables are -supported, just look in `syntax_checkers//*.vim`. Note that aliases -do not work; the actual executable must be available in your `$PATH`. Symbolic -links are okay. You can see syntastic's idea of available checkers by running -`:SyntasticInfo`. +is installed. For example: by default, python requires either `flake8` or +`pylint` to be installed and in your `$PATH`. To see which executables are +supported, look at the [wiki][3]. Note that aliases do not work; the actual +executables must be available in your `$PATH`. Symbolic links are okay though. +You can see syntastic's idea of available checkers by running `:SyntasticInfo`. Another reason it could fail is that either the command line options or the error output for a syntax checker may have changed. In this case, make sure you have the latest version of the syntax checker installed. If it still fails then create an issue - or better yet, create a pull request. -__Q. Recently some of my syntax checker options have stopped working...__ +__Q. The `perl` checker has stopped working...__ -A. The options are still there, they have just been renamed. Recently, -almost all syntax checkers were refactored to use the new `makeprgBuild()` -function. This made a lot of the old explicit options redundant - as they are -now implied. The new implied options usually have slightly different names to -the old options. - -e.g. Previously there was `g:syntastic_phpcs_conf`, now you must use -`g:syntastic_php_phpcs_args`. This completely overrides the arguments of -the checker, including any defaults, so you may need to look up the default -arguments of the checker and add these in. - -See `:help syntastic-checker-options` for more information. +A. The `perl` checker runs `perl -c` against your file, which in turn +__executes__ any `BEGIN`, `UNITCHECK`, and `CHECK` blocks, and any `use` +statements in your file (cf. [perlrun][10]). This is probably fine if you +wrote the file yourself, but it's a security problem if you're checking third +party files. Since there is currently no way to disable this behaviour while +still producing useful results, the checker is now disabled by default. To +(re-)enable it, set `g:syntastic_enable_perl_checker` to 1 in your vimrc: +```vim +let g:syntastic_enable_perl_checker = 1 +``` __Q. I run a checker and the location list is not updated...__ -A. By default, the location list is changed only when you run the `:Errors` +A. By default the location list is changed only when you run the `:Errors` command, in order to minimise conflicts with other plugins. If you want the location list to always be updated when you run the checkers, add this line to your vimrc: ```vim -let g:syntastic_always_populate_loc_list=1 +let g:syntastic_always_populate_loc_list = 1 ``` __Q. How can I pass additional arguments to a checker?__ A. Almost all syntax checkers use the `makeprgBuild()` function. Those checkers that do can be configured using global variables. The general form of the -global args variables are: -```vim -syntastic___args -``` +global `args` variables is `syntastic___args`. So, If you wanted to pass "--my --args --here" to the ruby mri checker you would add this line to your vimrc: ```vim -let g:syntastic_ruby_mri_args="--my --args --here" +let g:syntastic_ruby_mri_args = "--my --args --here" ``` See `:help syntastic-checker-options` for more information. @@ -170,24 +167,24 @@ which one(s) to use?__ A. Stick a line like this in your vimrc: ```vim -let g:syntastic__checkers=[''] +let g:syntastic__checkers = [''] ``` -To see the list of checkers for your filetype, look in -`syntax_checkers//`. +To see the list of supported checkers for your filetype look at the +[wiki][3]. -e.g. Python has the following checkers: `flake8`, `pyflakes`, `pylint` and a -native `python` checker. +e.g. Python has the following checkers, among others: `flake8`, `pyflakes`, +`pylint` and a native `python` checker. To tell syntastic to use `pylint`, you would use this setting: ```vim -let g:syntastic_python_checkers=['pylint'] +let g:syntastic_python_checkers = ['pylint'] ``` Some filetypes, like PHP, have style checkers as well as syntax checkers. These can be chained together like this: ```vim -let g:syntastic_php_checkers=['php', 'phpcs', 'phpmd'] +let g:syntastic_php_checkers = ['php', 'phpcs', 'phpmd'] ``` This is telling syntastic to run the `php` checker first, and if no errors are @@ -210,6 +207,13 @@ checkers. You can usually configure the options that are passed to the style checkers, or just disable them. Take a look at the [wiki][3] to see what options are available. +Alternatively, you can use `g:syntastic_quiet_messages` to filter out the +messages you don't want to see. e.g. To turn off all style messages: +```vim +let g:syntastic_quiet_messages = { "type": "style" } +``` +See `:help syntastic_quiet_messages` for details. + __Q. The error window is closed automatically when I :quit the current buffer but not when I :bdelete it?__ @@ -245,3 +249,4 @@ a look at [jedi-vim][7], [python-mode][8], or [YouCompleteMe][9]. [7]: https://github.com/davidhalter/jedi-vim [8]: https://github.com/klen/python-mode [9]: https://github.com/Valloric/YouCompleteMe +[10]: http://perldoc.perl.org/perlrun.html#*-c* diff --git a/sources_non_forked/syntastic/plugin/syntastic.vim b/sources_non_forked/syntastic/plugin/syntastic.vim index c59e42db..28f26381 100644 --- a/sources_non_forked/syntastic/plugin/syntastic.vim +++ b/sources_non_forked/syntastic/plugin/syntastic.vim @@ -1,7 +1,6 @@ "============================================================================ "File: syntastic.vim "Description: Vim plugin for on the fly syntax checking. -"Version: 3.4.0-pre "License: This program is free software. It comes without any warranty, " to the extent permitted by applicable law. You can redistribute " it and/or modify it under the terms of the Do What The Fuck You @@ -19,6 +18,8 @@ if has('reltime') let g:syntastic_start = reltime() endif +let g:syntastic_version = '3.4.0' + " Sanity checks {{{1 for s:feature in ['autocmd', 'eval', 'modify_fname', 'quickfix', 'user_commands'] @@ -286,6 +287,7 @@ function! s:CacheErrors(checker_names) " {{{2 if !s:skipFile() " debug logging {{{3 + call syntastic#log#debugShowVariables(g:SyntasticDebugTrace, 'version') call syntastic#log#debugShowOptions(g:SyntasticDebugTrace, s:debug_dump_options) call syntastic#log#debugDump(g:SyntasticDebugVariables) call syntastic#log#debugShowVariables(g:SyntasticDebugTrace, 'aggregate_errors') @@ -303,17 +305,16 @@ function! s:CacheErrors(checker_names) " {{{2 let names = [] for checker in clist - let type = checker.getFiletype() - let name = checker.getName() - call syntastic#log#debug(g:SyntasticDebugTrace, 'CacheErrors: Invoking checker: ' . type . '/' . name) + let cname = checker.getFiletype() . '/' . checker.getName() + call syntastic#log#debug(g:SyntasticDebugTrace, 'CacheErrors: Invoking checker: ' . cname) let loclist = checker.getLocList() if !loclist.isEmpty() if decorate_errors - call loclist.decorate(type, name) + call loclist.decorate(cname) endif - call add(names, [type, name]) + call add(names, cname) let newLoclist = newLoclist.extend(loclist) @@ -325,13 +326,13 @@ function! s:CacheErrors(checker_names) " {{{2 " set names {{{3 if !empty(names) - if len(syntastic#util#unique(map( copy(names), 'v:val[0]' ))) == 1 - let type = names[0][0] - let name = join(map(names, 'v:val[1]'), ', ') + if len(syntastic#util#unique(map( copy(names), 'substitute(v:val, "\\m/.*", "", "")' ))) == 1 + let type = substitute(names[0], '\m/.*', '', '') + let name = join(map( names, 'substitute(v:val, "\\m.\\{-}/", "", "")' ), ', ') call newLoclist.setName( name . ' ('. type . ')' ) else " checkers from mixed types - call newLoclist.setName(join(map(names, 'v:val[0] . "/" . v:val[1]'), ', ')) + call newLoclist.setName(join(names, ', ')) endif endif " }}}3 @@ -416,13 +417,16 @@ function! SyntasticMake(options) " {{{2 call syntastic#log#debug(g:SyntasticDebugLoclist, 'checker output:', err_lines) - if has_key(a:options, 'preprocess') + if has_key(a:options, 'Preprocess') + let err_lines = call(a:options['Preprocess'], [err_lines]) + call syntastic#log#debug(g:SyntasticDebugLoclist, 'preprocess (external):', err_lines) + elseif has_key(a:options, 'preprocess') let err_lines = call('syntastic#preprocess#' . a:options['preprocess'], [err_lines]) call syntastic#log#debug(g:SyntasticDebugLoclist, 'preprocess:', err_lines) endif lgetexpr err_lines - let errors = copy(getloclist(0)) + let errors = deepcopy(getloclist(0)) if has_key(a:options, 'cwd') execute 'lcd ' . fnameescape(old_cwd) @@ -456,7 +460,12 @@ function! SyntasticMake(options) " {{{2 call s:addToErrors(errors, { 'subtype': a:options['subtype'] }) endif - if has_key(a:options, 'postprocess') && !empty(a:options['postprocess']) + if has_key(a:options, 'Postprocess') && !empty(a:options['Postprocess']) + for rule in a:options['Postprocess'] + let errors = call(rule, [errors]) + endfor + call syntastic#log#debug(g:SyntasticDebugLoclist, 'postprocess (external):', errors) + elseif has_key(a:options, 'postprocess') && !empty(a:options['postprocess']) for rule in a:options['postprocess'] let errors = call('syntastic#postprocess#' . rule, [errors]) endfor diff --git a/sources_non_forked/syntastic/plugin/syntastic/loclist.vim b/sources_non_forked/syntastic/plugin/syntastic/loclist.vim index f95173b5..3d3a649e 100644 --- a/sources_non_forked/syntastic/plugin/syntastic/loclist.vim +++ b/sources_non_forked/syntastic/plugin/syntastic/loclist.vim @@ -114,9 +114,9 @@ function! g:SyntasticLoclist.setName(name) " {{{2 let self._name = a:name endfunction " }}}2 -function! g:SyntasticLoclist.decorate(filetype, name) " {{{2 +function! g:SyntasticLoclist.decorate(tag) " {{{2 for e in self._rawLoclist - let e['text'] .= ' [' . a:filetype . '/' . a:name . ']' + let e['text'] .= ' [' . a:tag . ']' endfor endfunction " }}}2 diff --git a/sources_non_forked/syntastic/plugin/syntastic/registry.vim b/sources_non_forked/syntastic/plugin/syntastic/registry.vim index d731fff2..09ca4c90 100644 --- a/sources_non_forked/syntastic/plugin/syntastic/registry.vim +++ b/sources_non_forked/syntastic/plugin/syntastic/registry.vim @@ -20,7 +20,7 @@ let s:defaultCheckers = { \ 'coq': ['coqtop'], \ 'cpp': ['gcc'], \ 'cs': ['mcs'], - \ 'css': ['csslint', 'phpcs'], + \ 'css': ['csslint'], \ 'cucumber': ['cucumber'], \ 'cuda': ['nvcc'], \ 'd': ['dmd'], @@ -54,7 +54,7 @@ let s:defaultCheckers = { \ 'objc': ['gcc'], \ 'objcpp': ['gcc'], \ 'ocaml': ['camlp4o'], - \ 'perl': ['perl', 'perlcritic'], + \ 'perl': ['perlcritic'], \ 'php': ['php', 'phpcs', 'phpmd'], \ 'po': ['msgfmt'], \ 'pod': ['podchecker'], @@ -142,14 +142,14 @@ function! g:SyntasticRegistry.getCheckers(ftalias, list) " {{{2 let ft = s:normaliseFiletype(a:ftalias) call self._checkDeprecation(ft) - let ft_list = + let names = \ !empty(a:list) ? a:list : \ exists('b:syntastic_checkers') ? b:syntastic_checkers : \ exists('g:syntastic_' . ft . '_checkers') ? g:syntastic_{ft}_checkers : - \ get(s:defaultCheckers, ft, []) + \ get(s:defaultCheckers, ft, 0) - return !empty(ft_list) ? - \ self._filterCheckersByName(checkers_map, ft_list) : [checkers_map[keys(checkers_map)[0]]] + return type(names) == type([]) ? + \ self._filterCheckersByName(checkers_map, names) : [checkers_map[keys(checkers_map)[0]]] endfunction " }}}2 function! g:SyntasticRegistry.getKnownFiletypes() " {{{2 diff --git a/sources_non_forked/syntastic/syntax_checkers/actionscript/mxmlc.vim b/sources_non_forked/syntastic/syntax_checkers/actionscript/mxmlc.vim index 8cfdc347..e423aa0d 100644 --- a/sources_non_forked/syntastic/syntax_checkers/actionscript/mxmlc.vim +++ b/sources_non_forked/syntastic/syntax_checkers/actionscript/mxmlc.vim @@ -41,7 +41,7 @@ function! SyntaxCheckers_actionscript_mxmlc_GetHighlightRegex(item) endif - return term != '' ? '\V\<' . term . '\>' : '' + return term != '' ? '\V\<' . escape(term, '\') . '\>' : '' endfunction function! SyntaxCheckers_actionscript_mxmlc_GetLocList() dict diff --git a/sources_non_forked/syntastic/syntax_checkers/css/prettycss.vim b/sources_non_forked/syntastic/syntax_checkers/css/prettycss.vim index 536568fa..10d6af3d 100644 --- a/sources_non_forked/syntastic/syntax_checkers/css/prettycss.vim +++ b/sources_non_forked/syntastic/syntax_checkers/css/prettycss.vim @@ -26,7 +26,7 @@ set cpo&vim function! SyntaxCheckers_css_prettycss_GetHighlightRegex(item) let term = matchstr(a:item["text"], '\m (\zs[^)]\+\ze)$') if term != '' - let term = '\V' . term + let term = '\V' . escape(term, '\') endif return term endfunction diff --git a/sources_non_forked/syntastic/syntax_checkers/erlang/erlang_check_file.erl b/sources_non_forked/syntastic/syntax_checkers/erlang/erlang_check_file.erl index 01622d9e..bd94870b 100644 --- a/sources_non_forked/syntastic/syntax_checkers/erlang/erlang_check_file.erl +++ b/sources_non_forked/syntastic/syntax_checkers/erlang/erlang_check_file.erl @@ -2,10 +2,11 @@ -export([main/1]). main([FileName]) -> - LibDirs = filelib:wildcard("{lib,deps}/*/ebin"), + LibDirs = (["ebin", "include", "src", "test"] ++ + filelib:wildcard("{apps,deps,lib}/*/{ebin,include}")), compile(FileName, LibDirs); -main([FileName | ["-rebar" | [Path | LibDirs]]]) -> +main([FileName, "-rebar", Path, LibDirs]) -> {ok, L} = file:consult(Path), P = dict:from_list(L), Root = filename:dirname(Path), @@ -31,23 +32,20 @@ main([FileName | ["-rebar" | [Path | LibDirs]]]) -> %io:format("~p~n", [LibDirs1]), compile(FileName, LibDirs1); -main([FileName | LibDirs]) -> +main([FileName, LibDirs]) -> compile(FileName, LibDirs). compile(FileName, LibDirs) -> Root = get_root(filename:dirname(FileName)), ok = code:add_pathsa(LibDirs), - compile:file(FileName, [warn_obsolete_guard, - warn_unused_import, - warn_shadow_vars, - warn_export_vars, - strong_validation, - report, - {i, filename:join(Root, "include")}, - {i, filename:join(Root, "deps")}, - {i, filename:join(Root, "apps")}, - {i, filename:join(Root, "lib")} - ]). + compile:file(FileName, + [warn_obsolete_guard, + warn_unused_import, + warn_shadow_vars, + warn_export_vars, + strong_validation, + report] ++ + [{i, filename:join(Root, I)} || I <- LibDirs]). get_root(Dir) -> Path = filename:split(filename:absname(Dir)), diff --git a/sources_non_forked/syntastic/syntax_checkers/javascript/jslint.vim b/sources_non_forked/syntastic/syntax_checkers/javascript/jslint.vim index c233cf34..89d3a802 100644 --- a/sources_non_forked/syntastic/syntax_checkers/javascript/jslint.vim +++ b/sources_non_forked/syntastic/syntax_checkers/javascript/jslint.vim @@ -22,7 +22,7 @@ set cpo&vim function! SyntaxCheckers_javascript_jslint_GetHighlightRegex(item) let term = matchstr(a:item['text'], '\mExpected .* and instead saw ''\zs.*\ze''') if term != '' - let term = '\V' . term + let term = '\V' . escape(term, '\') endif return term endfunction diff --git a/sources_non_forked/syntastic/syntax_checkers/lex/flex.vim b/sources_non_forked/syntastic/syntax_checkers/lex/flex.vim index c6e48340..b8bc6483 100644 --- a/sources_non_forked/syntastic/syntax_checkers/lex/flex.vim +++ b/sources_non_forked/syntastic/syntax_checkers/lex/flex.vim @@ -26,7 +26,7 @@ function! SyntaxCheckers_lex_flex_GetHighlightRegex(item) \ '\m^\(Definition value for\|undefined definition\) \zs{[^}]\+}\ze') endif - return term != '' ? '\V' . term : '' + return term != '' ? '\V' . escape(term, '\') : '' endfunction function! SyntaxCheckers_lex_flex_GetLocList() dict diff --git a/sources_non_forked/syntastic/syntax_checkers/lua/luac.vim b/sources_non_forked/syntastic/syntax_checkers/lua/luac.vim index b34778de..012f1490 100644 --- a/sources_non_forked/syntastic/syntax_checkers/lua/luac.vim +++ b/sources_non_forked/syntastic/syntax_checkers/lua/luac.vim @@ -28,7 +28,7 @@ function! SyntaxCheckers_lua_luac_GetHighlightRegex(pos) let a:pos['col'] = p[2] let result = '\%' . p[2] . 'c' else - let result = '\V' . near + let result = '\V' . escape(near, '\') endif " XXX the following piece of code is evil, and is likely to break @@ -38,7 +38,7 @@ function! SyntaxCheckers_lua_luac_GetHighlightRegex(pos) "if open != '' " let line = str2nr(matchstr(a:pos['text'], '\m(to close ''[^'']\+'' at line \zs[0-9]\+\ze)')) " let group = a:pos['type'] ==? 'E' ? 'SyntasticError' : 'SyntasticWarning' - " call matchadd(group, '\%' . line . 'l\V' . open) + " call matchadd(group, '\%' . line . 'l\V' . escape(open, '\')) "endif endif return result diff --git a/sources_non_forked/syntastic/syntax_checkers/perl/perl.vim b/sources_non_forked/syntastic/syntax_checkers/perl/perl.vim index f928ae98..2ac6ec98 100644 --- a/sources_non_forked/syntastic/syntax_checkers/perl/perl.vim +++ b/sources_non_forked/syntastic/syntax_checkers/perl/perl.vim @@ -11,6 +11,22 @@ " "============================================================================ " +" Security: +" +" This checker runs 'perl -c' against your file, which in turn executes +" any BEGIN, UNITCHECK, and CHECK blocks, and any use statements in +" your file. This is probably fine if you wrote the file yourself, +" but it can be a problem if you're trying to check third party files. +" If you are 100% willing to let Vim run the code in your file, set +" g:syntastic_enable_perl_checker to 1 in your vimrc to enable this +" checker: +" +" let g:syntastic_enable_perl_checker = 1 +" +" References: +" +" - http://perldoc.perl.org/perlrun.html#*-c* +" " Checker options: " " - g:syntastic_perl_interpreter (string; default: 'perl') @@ -24,11 +40,7 @@ if exists('g:loaded_syntastic_perl_perl_checker') finish endif -let g:loaded_syntastic_perl_perl_checker=1 - -if !exists('g:syntastic_perl_interpreter') - let g:syntastic_perl_interpreter = 'perl' -endif +let g:loaded_syntastic_perl_perl_checker = 1 if !exists('g:syntastic_perl_lib_path') let g:syntastic_perl_lib_path = [] @@ -38,6 +50,10 @@ let s:save_cpo = &cpo set cpo&vim function! SyntaxCheckers_perl_perl_IsAvailable() dict + if !exists('g:syntastic_perl_interpreter') + let g:syntastic_perl_interpreter = self.getExec() + endif + " don't call executable() here, to allow things like " let g:syntastic_perl_interpreter='/usr/bin/env perl' silent! call system(syntastic#util#shexpand(g:syntastic_perl_interpreter) . ' -e ' . syntastic#util#shescape('exit(0)')) @@ -45,6 +61,11 @@ function! SyntaxCheckers_perl_perl_IsAvailable() dict endfunction function! SyntaxCheckers_perl_perl_GetLocList() dict + if !exists('g:syntastic_enable_perl_checker') || !g:syntastic_enable_perl_checker + call syntastic#log#error('checker perl/perl: checks disabled for security reasons; set g:syntastic_enable_perl_checker to 1 to override') + return [] + endif + let exe = expand(g:syntastic_perl_interpreter) if type(g:syntastic_perl_lib_path) == type('') call syntastic#log#deprecationWarn('variable g:syntastic_perl_lib_path should be a list') diff --git a/sources_non_forked/syntastic/syntax_checkers/php/php.vim b/sources_non_forked/syntastic/syntax_checkers/php/php.vim index 3192d7dd..23c1db9e 100644 --- a/sources_non_forked/syntastic/syntax_checkers/php/php.vim +++ b/sources_non_forked/syntastic/syntax_checkers/php/php.vim @@ -20,7 +20,7 @@ set cpo&vim function! SyntaxCheckers_php_php_GetHighlightRegex(item) let term = matchstr(a:item['text'], "\\munexpected '\\zs[^']\\+\\ze'") - return term != '' ? '\V' . term : '' + return term != '' ? '\V' . escape(term, '\') : '' endfunction function! SyntaxCheckers_php_php_GetLocList() dict diff --git a/sources_non_forked/syntastic/syntax_checkers/po/msgfmt.vim b/sources_non_forked/syntastic/syntax_checkers/po/msgfmt.vim index 5b714de9..254aa91a 100644 --- a/sources_non_forked/syntastic/syntax_checkers/po/msgfmt.vim +++ b/sources_non_forked/syntastic/syntax_checkers/po/msgfmt.vim @@ -20,7 +20,7 @@ set cpo&vim function! SyntaxCheckers_po_msgfmt_GetHighlightRegex(item) let term = matchstr(a:item['text'], '\mkeyword "\zs[^"]\+\ze" unknown') - return term != '' ? '\V' . term : '' + return term != '' ? '\V' . escape(term, '\') : '' endfunction function! SyntaxCheckers_po_msgfmt_GetLocList() dict diff --git a/sources_non_forked/syntastic/syntax_checkers/python/frosted.vim b/sources_non_forked/syntastic/syntax_checkers/python/frosted.vim index 2b6119ce..5c47de5c 100644 --- a/sources_non_forked/syntastic/syntax_checkers/python/frosted.vim +++ b/sources_non_forked/syntastic/syntax_checkers/python/frosted.vim @@ -39,7 +39,7 @@ function! SyntaxCheckers_python_frosted_GetLocList() dict if len(parts) >= 4 let e["type"] = parts[1][0] let e["text"] = parts[3] . ' [' . parts[1] . ']' - let e["hl"] = '\V' . parts[2] + let e["hl"] = '\V' . escape(parts[2], '\') elseif e["text"] =~? '\v^I\d+:' let e["valid"] = 0 else diff --git a/sources_non_forked/syntastic/syntax_checkers/ruby/mri.vim b/sources_non_forked/syntastic/syntax_checkers/ruby/mri.vim index c0b0166d..aa7de267 100644 --- a/sources_non_forked/syntastic/syntax_checkers/ruby/mri.vim +++ b/sources_non_forked/syntastic/syntax_checkers/ruby/mri.vim @@ -21,7 +21,7 @@ set cpo&vim function! SyntaxCheckers_ruby_mri_GetHighlightRegex(i) if stridx(a:i['text'], 'assigned but unused variable') >= 0 let term = split(a:i['text'], ' - ')[1] - return '\V\<'.term.'\>' + return '\V\<' . escape(term, '\') . '\>' endif return '' diff --git a/sources_non_forked/syntastic/syntax_checkers/texinfo/makeinfo.vim b/sources_non_forked/syntastic/syntax_checkers/texinfo/makeinfo.vim index ccd3b2f2..63cae936 100644 --- a/sources_non_forked/syntastic/syntax_checkers/texinfo/makeinfo.vim +++ b/sources_non_forked/syntastic/syntax_checkers/texinfo/makeinfo.vim @@ -20,7 +20,7 @@ set cpo&vim function! SyntaxCheckers_texinfo_makeinfo_GetHighlightRegex(item) let term = matchstr(a:item['text'], "\\m`\\zs[^']\\+\\ze'") - return term != '' ? '\V' . term : '' + return term != '' ? '\V' . escape(term, '\') : '' endfunction function! SyntaxCheckers_texinfo_makeinfo_GetLocList() dict diff --git a/sources_non_forked/syntastic/syntax_checkers/text/atdtool.vim b/sources_non_forked/syntastic/syntax_checkers/text/atdtool.vim index 5a8ea0c7..b0f32c11 100644 --- a/sources_non_forked/syntastic/syntax_checkers/text/atdtool.vim +++ b/sources_non_forked/syntastic/syntax_checkers/text/atdtool.vim @@ -22,7 +22,7 @@ function! SyntaxCheckers_text_atdtool_GetHighlightRegex(item) let term = matchstr(a:item['text'], '\m "\zs[^"]\+\ze"\($\| | suggestions:\)') if term != '' let col = get(a:item, 'col', 0) - let term = (col != 0 ? '\%' . col . 'c' : '') . '\V' . term + let term = (col != 0 ? '\%' . col . 'c' : '') . '\V' . escape(term, '\') endif return term endfunction diff --git a/sources_non_forked/syntastic/syntax_checkers/vim/vimlint.vim b/sources_non_forked/syntastic/syntax_checkers/vim/vimlint.vim index 7f380d7b..d0916dce 100644 --- a/sources_non_forked/syntastic/syntax_checkers/vim/vimlint.vim +++ b/sources_non_forked/syntastic/syntax_checkers/vim/vimlint.vim @@ -29,7 +29,7 @@ function! SyntaxCheckers_vim_vimlint_GetHighlightRegex(item) endif endif - return '\V' . (col ? '\%' . col . 'c' : '') . term + return '\V' . (col ? '\%' . col . 'c' : '') . escape(term, '\') endif return '' diff --git a/sources_non_forked/tlib/autoload/tlib/Filter_cnf.vim b/sources_non_forked/tlib/autoload/tlib/Filter_cnf.vim index 0093c8b0..beb04943 100644 --- a/sources_non_forked/tlib/autoload/tlib/Filter_cnf.vim +++ b/sources_non_forked/tlib/autoload/tlib/Filter_cnf.vim @@ -3,8 +3,8 @@ " @Website: http://www.vim.org/account/profile.php?user_id=4037 " @License: GPL (see http://www.gnu.org/licenses/gpl.txt) " @Created: 2008-11-25. -" @Last Change: 2013-09-25. -" @Revision: 0.0.92 +" @Last Change: 2014-01-23. +" @Revision: 0.0.108 let s:prototype = tlib#Object#New({'_class': ['Filter_cnf'], 'name': 'cnf'}) "{{{2 let s:prototype.highlight = g:tlib#input#higroup @@ -147,7 +147,16 @@ endf " :nodoc: function! s:prototype.ReduceFrontFilter(world) dict "{{{3 - let a:world.filter[0][0] = a:world.filter[0][0][0:-2] + let filter = a:world.filter[0][0] + " TLogVAR filter + let str = matchstr(filter, '\(\\\(\.\\{-}\|[.?*+$^]\)\|\)$') + if empty(str) + let filter = filter[0 : -2] + else + let filter = strpart(filter, 0, len(filter) - len(str)) + endif + " TLogVAR str, filter + let a:world.filter[0][0] = filter endf diff --git a/sources_non_forked/tlib/autoload/tlib/Filter_cnfd.vim b/sources_non_forked/tlib/autoload/tlib/Filter_cnfd.vim index 0bac3c42..27f00fe1 100644 --- a/sources_non_forked/tlib/autoload/tlib/Filter_cnfd.vim +++ b/sources_non_forked/tlib/autoload/tlib/Filter_cnfd.vim @@ -3,8 +3,8 @@ " @Website: http://www.vim.org/account/profile.php?user_id=4037 " @License: GPL (see http://www.gnu.org/licenses/gpl.txt) " @Created: 2008-11-25. -" @Last Change: 2013-09-25. -" @Revision: 0.0.51 +" @Last Change: 2014-01-23. +" @Revision: 0.0.57 let s:prototype = tlib#Filter_cnf#New({'_class': ['Filter_cnfd'], 'name': 'cnfd'}) "{{{2 let s:prototype.highlight = g:tlib#input#higroup @@ -29,11 +29,7 @@ let s:Help = s:prototype.Help " :nodoc: function! s:prototype.Help(world) dict "{{{3 call call(s:Help, [a:world], self) - if self.name == 'cnfx' - call a:world.PushHelp(g:tlib#Filter_cnfx#expander, 'Any characters') - else - call a:world.PushHelp('.', 'Any characters') - endif + call a:world.PushHelp('.', 'Any characters') endf @@ -50,16 +46,6 @@ function! s:prototype.PushFrontFilter(world, char) dict "{{{3 endf -" :nodoc: -function! s:prototype.ReduceFrontFilter(world) dict "{{{3 - let flt = a:world.filter[0][0] - if flt =~ '\\\.\\{-}$' - let a:world.filter[0][0] = flt[0:-7] - else - let a:world.filter[0][0] = flt[0:-2] - endif -endf - " :nodoc: function! s:prototype.CleanFilter(filter) dict "{{{3 return substitute(a:filter, '\\.\\{-}', '.', 'g') diff --git a/sources_non_forked/tlib/autoload/tlib/Filter_cnfx.vim b/sources_non_forked/tlib/autoload/tlib/Filter_cnfx.vim deleted file mode 100644 index 1f48c5f4..00000000 --- a/sources_non_forked/tlib/autoload/tlib/Filter_cnfx.vim +++ /dev/null @@ -1,42 +0,0 @@ -" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) -" @Website: http://www.vim.org/account/profile.php?user_id=4037 -" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) -" @Created: 2008-11-25. -" @Last Change: 2013-09-25. -" @Revision: 0.0.62 - -let s:prototype = tlib#Filter_cnfd#New({'_class': ['Filter_cnfx'], 'name': 'cnfx'}) "{{{2 -let s:prototype.highlight = g:tlib#input#higroup - - -" A character that should be expanded to '\.\{-}'. -TLet g:tlib#Filter_cnfx#expander = '+' - - -" The same as |tlib#Filter_cnfd#New()| but a a customizable character -" |see tlib#Filter_cnfx#expander| is expanded to '\.\{-}'. -" The pattern is a '/\V' very no-'/magic' regexp pattern. -function! tlib#Filter_cnfx#New(...) "{{{3 - let object = s:prototype.New(a:0 >= 1 ? a:1 : {}) - return object -endf - - -" :nodoc: -function! s:prototype.SetFrontFilter(world, pattern) dict "{{{3 - let pattern = substitute(a:pattern, tlib#rx#Escape(g:tlib#Filter_cnfx#expander, 'V'), '\\.\\{-}', 'g') - let a:world.filter[0] = reverse(split(pattern, '\s*|\s*')) + a:world.filter[0][1 : -1] -endf - - -" :nodoc: -function! s:prototype.PushFrontFilter(world, char) dict "{{{3 - let a:world.filter[0][0] .= a:char == char2nr(g:tlib#Filter_cnfx#expander) ? '\.\{-}' : nr2char(a:char) -endf - - -" :nodoc: -function! s:prototype.CleanFilter(filter) dict "{{{3 - return substitute(a:filter, '\\.\\{-}', g:tlib#Filter_cnfx#expander, 'g') -endf - diff --git a/sources_non_forked/tlib/autoload/tlib/Filter_glob.vim b/sources_non_forked/tlib/autoload/tlib/Filter_glob.vim new file mode 100644 index 00000000..0ee55618 --- /dev/null +++ b/sources_non_forked/tlib/autoload/tlib/Filter_glob.vim @@ -0,0 +1,68 @@ +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2008-11-25. +" @Last Change: 2014-01-23. +" @Revision: 0.0.80 + +let s:prototype = tlib#Filter_cnf#New({'_class': ['Filter_glob'], 'name': 'glob'}) "{{{2 +let s:prototype.highlight = g:tlib#input#higroup + + +" A character that should be expanded to '\.\{-}'. +TLet g:tlib#Filter_glob#seq = '*' + + +" A character that should be expanded to '\.\?'. +TLet g:tlib#Filter_glob#char = '?' + + +" The same as |tlib#Filter_cnf#New()| but a a customizable character +" |see tlib#Filter_glob#seq| is expanded to '\.\{-}' and +" |g:tlib#Filter_glob#char| is expanded to '\.'. +" The pattern is a '/\V' very no-'/magic' regexp pattern. +function! tlib#Filter_glob#New(...) "{{{3 + let object = s:prototype.New(a:0 >= 1 ? a:1 : {}) + return object +endf + + +let s:Help = s:prototype.Help + +" :nodoc: +function! s:prototype.Help(world) dict "{{{3 + call call(s:Help, [a:world], self) + call a:world.PushHelp(g:tlib#Filter_glob#seq, 'Any characters') + call a:world.PushHelp(g:tlib#Filter_glob#char, 'Single characters') +endf + + +" :nodoc: +function! s:prototype.SetFrontFilter(world, pattern) dict "{{{3 + let pattern = substitute(a:pattern, tlib#rx#Escape(g:tlib#Filter_glob#seq, 'V'), '\\.\\{-}', 'g') + let pattern = substitute(a:pattern, tlib#rx#Escape(g:tlib#Filter_glob#char, 'V'), '\\.', 'g') + let a:world.filter[0] = reverse(split(pattern, '\s*|\s*')) + a:world.filter[0][1 : -1] +endf + + +" :nodoc: +function! s:prototype.PushFrontFilter(world, char) dict "{{{3 + " TLogVAR a:char, nr2char(a:char) + if a:char == char2nr(g:tlib#Filter_glob#seq) + let char = '\.\{-}' + elseif a:char == char2nr(g:tlib#Filter_glob#char) + let char = '\.' + else + let char = nr2char(a:char) + endif + let a:world.filter[0][0] .= char +endf + + +" :nodoc: +function! s:prototype.CleanFilter(filter) dict "{{{3 + let filter = substitute(a:filter, '\\.\\{-}', g:tlib#Filter_glob#seq, 'g') + let filter = substitute(filter, '\\.', g:tlib#Filter_glob#char, 'g') + return filter +endf + diff --git a/sources_non_forked/tlib/autoload/tlib/World.vim b/sources_non_forked/tlib/autoload/tlib/World.vim index 1387a350..584b6701 100644 --- a/sources_non_forked/tlib/autoload/tlib/World.vim +++ b/sources_non_forked/tlib/autoload/tlib/World.vim @@ -1,10 +1,7 @@ -" World.vim -- The World prototype for tlib#input#List() " @Author: Tom Link (micathom AT gmail com?subject=[vim]) " @Website: http://www.vim.org/account/profile.php?user_id=4037 " @License: GPL (see http://www.gnu.org/licenses/gpl.txt) -" @Created: 2007-05-01. -" @Last Change: 2013-12-03. -" @Revision: 0.1.1310 +" @Revision: 1389 " :filedoc: " A prototype used by |tlib#input#List|. @@ -75,6 +72,7 @@ let s:prototype = tlib#Object#New({ \ 'resize_vertical': 0, \ 'restore_from_cache': [], \ 'filtered_items': [], + \ 'resume_state': '', \ 'retrieve_eval': '', \ 'return_agent': '', \ 'rv': '', @@ -92,6 +90,7 @@ let s:prototype = tlib#Object#New({ \ 'temp_prompt': [], \ 'timeout': 0, \ 'timeout_resolution': 2, + \ 'tabpagenr': -1, \ 'type': '', \ 'win_wnr': -1, \ 'win_height': -1, @@ -119,6 +118,22 @@ function! s:prototype.Set_display_format(value) dict "{{{3 endf +" :nodoc: +function! s:prototype.DisplayFormat(list) dict "{{{3 + let display_format = self.display_format + if !empty(display_format) + if has_key(self, 'InitFormatName') + call self.InitFormatName() + endif + let cache = self.fmt_display + " TLogVAR display_format, fmt_entries + return map(copy(a:list), 'self.FormatName(cache, display_format, v:val)') + else + return a:list + endif +endf + + " :nodoc: function! s:prototype.Set_highlight_filename() dict "{{{3 let self.tlib_UseInputListScratch = 'call world.Highlight_filename()' @@ -180,6 +195,32 @@ else endf + " :nodoc: + function! s:prototype.UseFilenameIndicators() dict "{{{3 + return g:tlib_inputlist_filename_indicators || has_key(self, 'filename_indicators') + endf + + + " :nodoc: + function! s:prototype.InitFormatName() dict "{{{3 + if self.UseFilenameIndicators() + let self._buffers = {} + for bufnr in range(1, bufnr('$')) + let filename = fnamemodify(bufname(bufnr), ':p') + " TLogVAR filename + let bufdef = { + \ 'bufnr': bufnr, + \ } + " '&buflisted' + for opt in ['&modified', '&bufhidden'] + let bufdef[opt] = getbufvar(bufnr, opt) + endfor + let self._buffers[filename] = bufdef + endfor + endif + endf + + " :nodoc: function! s:prototype.FormatFilename(file) dict "{{{3 " TLogVAR a:file @@ -196,34 +237,30 @@ else if strwidth(fname) > width let fname = strpart(fname, 0, width - 3) .'...' endif - let dnmax = &co - max([width, strwidth(fname)]) - 10 - self.index_width - &fdc - if g:tlib_inputlist_filename_indicators - let dnmax -= 2 - endif - if strwidth(dname) > dnmax - let dname = '...'. strpart(dname, len(dname) - dnmax) - endif - let marker = [] - let use_indicators = g:tlib_inputlist_filename_indicators || has_key(self, 'filename_indicators') + let dnmax = &co - max([width, strwidth(fname)]) - 8 - self.index_width - &fdc + let use_indicators = self.UseFilenameIndicators() " TLogVAR use_indicators + let marker = [] if use_indicators call insert(marker, '[') if g:tlib_inputlist_filename_indicators - let bnr = bufnr(a:file) - TLogVAR a:file, bnr, self.bufnr + let bufdef = get(self._buffers, a:file, {}) + " let bnr = bufnr(a:file) + let bnr = get(bufdef, 'bufnr', -1) + " TLogVAR a:file, bnr, self.bufnr if bnr != -1 if bnr == self.bufnr call add(marker, '%') else call add(marker, bnr) endif - if getbufvar(bnr, '&modified') + if get(bufdef, '&modified', 0) call add(marker, '+') endif - if getbufvar(bnr, '&bufhidden') == 'hide' + if get(bufdef, '&bufhidden', '') == 'hide' call add(marker, 'h') endif - " if !buflisted(bnr) + " if !get(bufdef, '&buflisted', 1) " call add(marker, 'u') " endif " echom "DBG" a:file string(get(self,'filename_indicators')) @@ -242,9 +279,16 @@ else else call add(marker, '|') endif + let markers = join(marker, '') + if !empty(markers) + let dnmax -= len(markers) + endif + if strwidth(dname) > dnmax + let dname = '...'. strpart(dname, len(dname) - dnmax) + endif return printf("%-*s %s %s", \ self.width_filename + len(fname) - strwidth(fname), - \ fname, join(marker, ''), dname) + \ fname, markers, dname) endf endif @@ -764,6 +808,7 @@ function! s:prototype.UseInputListScratch() dict "{{{3 if !exists('b:tlib_list_init') call tlib#autocmdgroup#Init() autocmd TLib VimResized call feedkeys("\", 't') + " autocmd TLib WinLeave let b:tlib_world_event = 'WinLeave' | call feedkeys("\", 't') let b:tlib_list_init = 1 endif if !exists('w:tlib_list_init') @@ -923,16 +968,17 @@ function! s:prototype.DisplayHelp() dict "{{{3 let self.temp_lines = self.InitHelp() call self.PushHelp('', self.key_mode == 'default' ? 'Abort' : 'Reset keymap') call self.PushHelp('Enter, ', 'Pick the current item') - call self.PushHelp('', 'Pick an item') call self.PushHelp('Mouse', 'L: Pick item, R: Show menu') + call self.PushHelp('', 'Select an item') call self.PushHelp(', ', 'Reduce filter') call self.PushHelp(', ', 'Enter command') if self.key_mode == 'default' - call self.PushHelp('', 'Reset the display') + call self.PushHelp('', 'Reset the display') call self.PushHelp('Up/Down', 'Next/previous item') - call self.PushHelp('', 'Edit top filter string') + call self.PushHelp('', 'Edit top filter string') call self.PushHelp('Page Up/Down', 'Scroll') + call self.PushHelp('', 'Enter * Wildcard') if self.allow_suspend call self.PushHelp('', 'Suspend/Resume') call self.PushHelp('', 'Switch to origin') @@ -1164,7 +1210,7 @@ function! s:prototype.Query() dict "{{{3 if g:tlib_inputlist_shortmessage let query = 'Filter: '. self.DisplayFilter() else - let query = self.query .' (filter: '. self.DisplayFilter() .'; press "?" for help)' + let query = self.query .' (filter: '. self.DisplayFilter() .'; press for help)' endif return query endf @@ -1236,6 +1282,9 @@ endf " :nodoc: function! s:prototype.SwitchWindow(where) dict "{{{3 " TLogDBG string(tlib#win#List()) + if self.tabpagenr != tabpagenr() + call tlib#tab#Set(self.tabpagenr) + endif let wnr = get(self, a:where.'_wnr') " TLogVAR self, wnr return tlib#win#Set(wnr) @@ -1312,3 +1361,8 @@ function! s:prototype.RestoreOrigin(...) dict "{{{3 " TLogDBG "RestoreOrigin1 ". string(tlib#win#List()) endf + +function! s:prototype.Suspend() dict "{{{3 + call tlib#agent#Suspend(self, self.rv) +endf + diff --git a/sources_non_forked/tlib/autoload/tlib/agent.vim b/sources_non_forked/tlib/autoload/tlib/agent.vim index 61109e7b..766c5b33 100644 --- a/sources_non_forked/tlib/autoload/tlib/agent.vim +++ b/sources_non_forked/tlib/autoload/tlib/agent.vim @@ -3,8 +3,8 @@ " @Website: http://www.vim.org/account/profile.php?user_id=4037 " @License: GPL (see http://www.gnu.org/licenses/gpl.txt) " @Created: 2007-06-24. -" @Last Change: 2013-11-05. -" @Revision: 0.1.242 +" @Last Change: 2014-02-06. +" @Revision: 0.1.251 " :filedoc: @@ -55,6 +55,20 @@ function! tlib#agent#PageDown(world, selected) "{{{3 endf +function! tlib#agent#Home(world, selected) "{{{3 + let a:world.prefidx = 1 + let a:world.state = 'redisplay' + return a:world +endf + + +function! tlib#agent#End(world, selected) "{{{3 + let a:world.prefidx = len(a:world.list) + let a:world.state = 'redisplay' + return a:world +endf + + function! tlib#agent#Up(world, selected, ...) "{{{3 TVarArg ['lines', 1] let a:world.idx = '' @@ -463,7 +477,7 @@ function! tlib#agent#ShowInfo(world, selected) for f in a:selected if filereadable(f) let desc = [getfperm(f), strftime('%c', getftime(f)), getfsize(f) .' bytes', getftype(f)] - call add(lines, fnamemodify(f, ':t') .':') + call add(lines, fnamemodify(f, ':p')) call add(lines, ' '. join(desc, '; ')) endif endfor @@ -561,7 +575,7 @@ endf function! tlib#agent#ExecAgentByName(world, selected) "{{{3 let s:agent_names_world = a:world - let agent_names = {} + let agent_names = {'Help': 'tlib#agent#Help'} for def in values(a:world.key_map[a:world.key_mode]) if has_key(def, 'help') && !empty(def.help) && has_key(def, 'agent') && !empty(def.agent) let agent_names[def.help] = def.agent diff --git a/sources_non_forked/tlib/autoload/tlib/cache.vim b/sources_non_forked/tlib/autoload/tlib/cache.vim index 7380d6dd..0c2c7017 100644 --- a/sources_non_forked/tlib/autoload/tlib/cache.vim +++ b/sources_non_forked/tlib/autoload/tlib/cache.vim @@ -4,7 +4,7 @@ " @License: GPL (see http://www.gnu.org/licenses/gpl.txt) " @Created: 2007-06-30. " @Last Change: 2013-09-25. -" @Revision: 0.1.220 +" @Revision: 0.1.230 " The cache directory. If empty, use |tlib#dir#MyRuntime|.'/cache'. @@ -109,13 +109,20 @@ endf function! tlib#cache#Save(cfile, dictionary) "{{{3 + " TLogVAR a:cfile, a:dictionary call tlib#persistent#Save(a:cfile, a:dictionary) endf -function! tlib#cache#Get(cfile) "{{{3 +function! tlib#cache#Get(cfile, ...) "{{{3 call tlib#cache#MaybePurge() - return tlib#persistent#Get(a:cfile) + if !empty(a:cfile) && filereadable(a:cfile) + let val = readfile(a:cfile, 'b') + return eval(join(val, "\n")) + else + let default = a:0 >= 1 ? a:1 : {} + return default + endif endf @@ -123,10 +130,18 @@ endf " or does not exist, create it calling a generator function. function! tlib#cache#Value(cfile, generator, ftime, ...) "{{{3 if !filereadable(a:cfile) || (a:ftime != 0 && getftime(a:cfile) < a:ftime) - let args = a:0 >= 1 ? a:1 : [] - let val = call(a:generator, args) - " TLogVAR a:generator, args, val - call tlib#cache#Save(a:cfile, {'val': val}) + if empty(a:generator) && a:0 >= 1 + " TLogVAR a:1 + let val = a:1 + else + let args = a:0 >= 1 ? a:1 : [] + " TLogVAR a:generator, args + let val = call(a:generator, args) + endif + " TLogVAR val + let cval = {'val': val} + " TLogVAR cval + call tlib#cache#Save(a:cfile, cval) return val else let val = tlib#cache#Get(a:cfile) diff --git a/sources_non_forked/tlib/autoload/tlib/char.vim b/sources_non_forked/tlib/autoload/tlib/char.vim index 2efb47bb..277716d3 100644 --- a/sources_non_forked/tlib/autoload/tlib/char.vim +++ b/sources_non_forked/tlib/autoload/tlib/char.vim @@ -3,8 +3,8 @@ " @Website: http://www.vim.org/account/profile.php?user_id=4037 " @License: GPL (see http://www.gnu.org/licenses/gpl.txt) " @Created: 2007-06-30. -" @Last Change: 2009-02-15. -" @Revision: 0.0.30 +" @Last Change: 2014-01-20. +" @Revision: 0.0.37 if &cp || exists("loaded_tlib_char_autoload") finish @@ -19,13 +19,22 @@ let loaded_tlib_char_autoload = 1 " echo tlib#char#Get() " echo tlib#char#Get(5) function! tlib#char#Get(...) "{{{3 - TVarArg ['timeout', 0], ['resolution', 0] + TVarArg ['timeout', 0], ['resolution', 0], ['getmod', 0] + let char = -1 + let mode = 0 if timeout == 0 || !has('reltime') - return getchar() + let char = getchar() else - return tlib#char#GetWithTimeout(timeout, resolution) + let char = tlib#char#GetWithTimeout(timeout, resolution) + endif + if getmod + if char != -1 + let mode = getcharmod() + endif + return [char, mode] + else + return char endif - return -1 endf diff --git a/sources_non_forked/tlib/autoload/tlib/cmd.vim b/sources_non_forked/tlib/autoload/tlib/cmd.vim index e6ab3e88..01975b60 100644 --- a/sources_non_forked/tlib/autoload/tlib/cmd.vim +++ b/sources_non_forked/tlib/autoload/tlib/cmd.vim @@ -3,8 +3,8 @@ " @Website: http://www.vim.org/account/profile.php?user_id=4037 " @License: GPL (see http://www.gnu.org/licenses/gpl.txt) " @Created: 2007-08-23. -" @Last Change: 2013-05-14. -" @Revision: 0.0.46 +" @Last Change: 2014-02-05. +" @Revision: 0.0.53 if &cp || exists("loaded_tlib_cmd_autoload") finish @@ -58,10 +58,12 @@ endf " call tlib#cmd#BrowseOutputWithCallback('tlib#cmd#ParseScriptname', 'scriptnames') function! tlib#cmd#BrowseOutputWithCallback(callback, command) "{{{3 let list = tlib#cmd#OutputAsList(a:command) - let cmd = tlib#input#List('s', 'Output of: '. a:command, list) - if !empty(cmd) - let Callback = function(a:callback) - call call(Callback, [cmd]) + let cmds = tlib#input#List('m', 'Output of: '. a:command, list) + if !empty(cmds) + for cmd in cmds + let Callback = function(a:callback) + call call(Callback, [cmd]) + endfor endif endf @@ -70,8 +72,9 @@ function! tlib#cmd#DefaultBrowseOutput(cmd) "{{{3 endf function! tlib#cmd#ParseScriptname(line) "{{{3 - let parsedValue = substitute(a:line, '^.\{-}\/', '/', '') - exe ':e '. parsedValue + " let parsedValue = substitute(a:line, '^.\{-}\/', '/', '') + let parsedValue = matchstr(a:line, '^\s*\d\+:\s*\zs.*$') + exe 'drop '. fnameescape(parsedValue) endf " :def: function! tlib#cmd#UseVertical(?rx='') diff --git a/sources_non_forked/tlib/autoload/tlib/input.vim b/sources_non_forked/tlib/autoload/tlib/input.vim index b756f783..9805b305 100644 --- a/sources_non_forked/tlib/autoload/tlib/input.vim +++ b/sources_non_forked/tlib/autoload/tlib/input.vim @@ -1,10 +1,7 @@ -" input.vim " @Author: Tom Link (micathom AT gmail com?subject=[vim]) " @Website: http://www.vim.org/account/profile.php?user_id=4037 " @License: GPL (see http://www.gnu.org/licenses/gpl.txt) -" @Created: 2007-06-30. -" @Last Change: 2013-09-30. -" @Revision: 0.0.1262 +" @Revision: 1315 " :filedoc: @@ -23,16 +20,15 @@ TLet g:tlib#input#livesearch_threshold = 1000 " Determine how |tlib#input#List()| and related functions work. -" Can be "cnf", "cnfd", "cnfx", "seq", or "fuzzy". See: -" cnfx ... Like cnfd but |g:tlib#Filter_cnfx#expander| is interpreted -" as a wildcard (this is the default method) -" - A plus character ("+") acts as a wildcard as if ".\{-}" (see -" |/\{-|) were entered. +" Can be "glob", "cnf", "cnfd", "seq", or "fuzzy". See: +" glob ... Like cnf but "*" and "?" (see |g:tlib#Filter_glob#seq|, +" |g:tlib#Filter_glob#char|) are interpreted as glob-like +" |wildcards| (this is the default method) " - Examples: -" - "f+o" matches "fo", "fxo", and "fxxxoo", but doesn't match +" - "f*o" matches "fo", "fxo", and "fxxxoo", but doesn't match " "far". " - Otherwise it is a derivate of the cnf method (see below). -" - See also |tlib#Filter_cnfx#New()|. +" - See also |tlib#Filter_glob#New()|. " cnfd ... Like cnf but "." is interpreted as a wildcard, i.e. it is " expanded to "\.\{-}" " - A period character (".") acts as a wildcard as if ".\{-}" (see @@ -60,7 +56,7 @@ TLet g:tlib#input#livesearch_threshold = 1000 " - |tlib#Filter_seq#New()| " fuzzy .. Match fuzzy character sequences " - |tlib#Filter_fuzzy#New()| -TLet g:tlib#input#filter_mode = 'cnfx' +TLet g:tlib#input#filter_mode = 'glob' " The highlight group to use for showing matches in the input list @@ -126,6 +122,8 @@ TLet g:tlib#input#numeric_chars = { TLet g:tlib#input#keyagents_InputList_s = { \ "\": 'tlib#agent#PageUp', \ "\": 'tlib#agent#PageDown', + \ "\": 'tlib#agent#Home', + \ "\": 'tlib#agent#End', \ "\": 'tlib#agent#Up', \ "\": 'tlib#agent#Down', \ "\": 'tlib#agent#UpN', @@ -140,7 +138,6 @@ TLet g:tlib#input#keyagents_InputList_s = { \ 26: 'tlib#agent#Suspend', \ 250: 'tlib#agent#Suspend', \ 15: 'tlib#agent#SuspendToParentWindow', - \ 63: 'tlib#agent#Help', \ "\": 'tlib#agent#Help', \ "\": 'tlib#agent#ExecAgentByName', \ "\": 'tlib#agent#ExecAgentByName', @@ -155,6 +152,7 @@ TLet g:tlib#input#keyagents_InputList_s = { \ char2nr(g:tlib#input#or): 'tlib#agent#OR', \ char2nr(g:tlib#input#and): 'tlib#agent#AND', \ } + " \ 63: 'tlib#agent#Help', " :nodefault: @@ -345,6 +343,16 @@ function! tlib#input#ListW(world, ...) "{{{3 try call s:RunStateHandlers(world) + " if exists('b:tlib_world_event') + " let event = b:tlib_world_event + " unlet! b:tlib_world_event + " if event == 'WinLeave' + " " let world.resume_state = world.state + " let world = tlib#agent#Suspend(world, world.rv) + " break + " endif + " endif + " let time02 = str2float(reltimestr(reltime())) " DBG " TLogVAR time02, time02 - time0 if world.state =~ '\' @@ -443,14 +451,7 @@ function! tlib#input#ListW(world, ...) "{{{3 " TLogDBG 5 " TLogDBG len(world.list) " TLogVAR world.list - let dlist = copy(world.list) - " TLogVAR world.display_format - if !empty(world.display_format) - let display_format = world.display_format - let cache = world.fmt_display - " TLogVAR display_format, fmt_entries - call map(dlist, 'world.FormatName(cache, display_format, v:val)') - endif + let dlist = world.DisplayFormat(world.list) " TLogVAR world.prefidx " TLogDBG 6 " let time6 = str2float(reltimestr(reltime())) " DBG @@ -545,20 +546,15 @@ function! tlib#input#ListW(world, ...) "{{{3 exec exec_cmd endif elseif has('gui_gtk') || has('gui_gtk2') - let c = getchar() - let cmod = getcharmod() - " TLogVAR c, cmod - if c !~ '\D' && c > 0 && cmod != 0 - let c = printf("<%s-%s>", cmod, c) - endif + let c = s:GetModdedChar(world) + " TLogVAR c endif else " TLogVAR world.timeout - let c = tlib#char#Get(world.timeout, world.timeout_resolution) + let c = s:GetModdedChar(world) " TLogVAR c, has_key(world.key_map[world.key_mode],c) - let cmod = getcharmod() endif - " TLogVAR c, cmod + " TLogVAR c " TLogDBG string(sort(keys(world.key_map[world.key_mode]))) " TLogVAR world.next_agent, world.next_eval @@ -602,7 +598,7 @@ function! tlib#input#ListW(world, ...) "{{{3 " let world.offset = world.prefidx if empty(world.prefidx) " call feedkeys(c, 't') - let c = tlib#char#Get(world.timeout) + let c = s:GetModdedChar(world) let world.state = 'help' continue endif @@ -829,6 +825,16 @@ function! tlib#input#ListW(world, ...) "{{{3 endf +function! s:GetModdedChar(world) "{{{3 + let [char, mode] = tlib#char#Get(a:world.timeout, a:world.timeout_resolution, 1) + if char !~ '\D' && char > 0 && mode != 0 + return printf("<%s-%s>", mode, char) + else + return char + endif +endf + + function! s:Init(world, cmd) "{{{3 " TLogVAR a:cmd let a:world.initial_display = 1 @@ -844,6 +850,9 @@ function! s:Init(world, cmd) "{{{3 else call a:world.Retrieve(1) endif + " if !empty(a:world.resume_state) + " let a:world.state = a:world.resume_state + " endif elseif !a:world.initialized " TLogVAR a:world.initialized, a:world.win_wnr, a:world.bufnr let a:world.filetype = &filetype diff --git a/sources_non_forked/tlib/autoload/tlib/persistent.vim b/sources_non_forked/tlib/autoload/tlib/persistent.vim index b5791744..26232d59 100644 --- a/sources_non_forked/tlib/autoload/tlib/persistent.vim +++ b/sources_non_forked/tlib/autoload/tlib/persistent.vim @@ -3,7 +3,7 @@ " @License: GPL (see http://www.gnu.org/licenses/gpl.txt) " @Created: 2012-05-11. " @Last Change: 2012-05-11. -" @Revision: 7 +" @Revision: 9 " The directory for persistent data files. If empty, use " |tlib#dir#MyRuntime|.'/share'. @@ -29,13 +29,8 @@ function! tlib#persistent#Filename(type, ...) "{{{3 return tlib#cache#Filename(a:type, file, mkdir, tlib#persistent#Dir()) endf -function! tlib#persistent#Get(cfile) "{{{3 - if !empty(a:cfile) && filereadable(a:cfile) - let val = readfile(a:cfile, 'b') - return eval(join(val, "\n")) - else - return {} - endif +function! tlib#persistent#Get(...) "{{{3 + return call('tlib#cache#Get', a:000) endf function! tlib#persistent#Value(...) "{{{3 diff --git a/sources_non_forked/tlib/autoload/tlib/progressbar.vim b/sources_non_forked/tlib/autoload/tlib/progressbar.vim index 6ff5a77f..6ca0ce9b 100644 --- a/sources_non_forked/tlib/autoload/tlib/progressbar.vim +++ b/sources_non_forked/tlib/autoload/tlib/progressbar.vim @@ -4,7 +4,7 @@ " @License: GPL (see http://www.gnu.org/licenses/gpl.txt) " @Created: 2007-09-30. " @Last Change: 2010-01-07. -" @Revision: 0.0.66 +" @Revision: 0.0.69 if &cp || exists("loaded_tlib_progressbar_autoload") finish @@ -57,6 +57,7 @@ function! tlib#progressbar#Display(value, ...) "{{{3 let pbr = repeat('.', s:width[0] - val) let txt = printf(s:format[0], '['.pbl.pbr.']') . extra let &l:statusline = txt + " TLogDBG txt redrawstatus " redraw " call tlib#notify#Echo(txt) diff --git a/sources_non_forked/tlib/autoload/tlib/scratch.vim b/sources_non_forked/tlib/autoload/tlib/scratch.vim index e043f050..e64eb9e6 100644 --- a/sources_non_forked/tlib/autoload/tlib/scratch.vim +++ b/sources_non_forked/tlib/autoload/tlib/scratch.vim @@ -3,8 +3,8 @@ " @Website: http://www.vim.org/account/profile.php?user_id=4037 " @License: GPL (see http://www.gnu.org/licenses/gpl.txt) " @Created: 2007-07-18. -" @Last Change: 2013-11-11. -" @Revision: 0.0.251 +" @Last Change: 2014-02-06. +" @Revision: 0.0.252 if &cp || exists("loaded_tlib_scratch_autoload") finish @@ -100,6 +100,8 @@ function! tlib#scratch#UseScratch(...) "{{{3 endif endif let keyargs.scratch = bufnr('%') + let keyargs.scratch_tabpagenr = tabpagenr() + let keyargs.scratch_winnr = winnr() " TLogVAR 2, winnr(), bufnr('%'), bufname("%"), keyargs.scratch return keyargs.scratch endf diff --git a/sources_non_forked/tlib/autoload/tlib/tab.vim b/sources_non_forked/tlib/autoload/tlib/tab.vim index c6159586..6fc3bd46 100644 --- a/sources_non_forked/tlib/autoload/tlib/tab.vim +++ b/sources_non_forked/tlib/autoload/tlib/tab.vim @@ -3,8 +3,8 @@ " @Website: http://www.vim.org/account/profile.php?user_id=4037 " @License: GPL (see http://www.gnu.org/licenses/gpl.txt) " @Created: 2007-08-27. -" @Last Change: 2009-02-15. -" @Revision: 0.0.29 +" @Last Change: 2014-02-06. +" @Revision: 0.0.30 if &cp || exists("loaded_tlib_tab_autoload") finish @@ -50,6 +50,8 @@ endf function! tlib#tab#Set(tabnr) "{{{3 - exec a:tabnr .'tabnext' + if a:tabnr > 0 + exec a:tabnr .'tabnext' + endif endf diff --git a/sources_non_forked/tlib/autoload/tlib/vim.vim b/sources_non_forked/tlib/autoload/tlib/vim.vim index 150c4161..7154aeb1 100644 --- a/sources_non_forked/tlib/autoload/tlib/vim.vim +++ b/sources_non_forked/tlib/autoload/tlib/vim.vim @@ -4,7 +4,7 @@ " @License: GPL (see http://www.gnu.org/licenses/gpl.txt) " @Created: 2010-07-19. " @Last Change: 2012-06-08. -" @Revision: 35 +" @Revision: 37 let s:restoreframecmd = '' @@ -120,3 +120,33 @@ function! s:RestoreFrameParams() "{{{3 endif endf + +" :display: tlib#vim##CopyFunction(old, new, overwrite=0) +function! tlib#vim#CopyFunction(old, new, ...) "{{{3 + let overwrite = a:0 >= 1 ? a:1 : 0 + redir => oldfn + exec 'silent function' a:old + redir END + if exists('*'. a:new) + if overwrite > 0 + exec 'delfunction' a:new + elseif overwrite < 0 + throw 'tlib#vim##CopyFunction: Function already exists: '. a:old .' -> '. a:new + else + return + endif + endif + let fn = split(oldfn, '\n') + let fn = map(fn, 'substitute(v:val, ''^\d\+'', "", "")') + let fn[0] = substitute(fn[0], '\V\^\s\*fu\%[nction]!\?\s\+\zs'. a:old, a:new, '') + let t = @t + try + let @t = join(fn, "\n") + redir => out + @t + redir END + finally + let @t = t + endtry +endf + diff --git a/sources_non_forked/tlib/doc/tlib.txt b/sources_non_forked/tlib/doc/tlib.txt index a295ce19..816524b9 100644 --- a/sources_non_forked/tlib/doc/tlib.txt +++ b/sources_non_forked/tlib/doc/tlib.txt @@ -38,6 +38,13 @@ Contents~ :TBrowseOutput ......................... |:TBrowseOutput| :TBrowseScriptnames .................... |:TBrowseScriptnames| :TTimeCommand .......................... |:TTimeCommand| + Add .................................... |Add()| + TestGetArg ............................. |TestGetArg()| + TestGetArg1 ............................ |TestGetArg1()| + TestArgs ............................... |TestArgs()| + TestArgs1 .............................. |TestArgs1()| + TestArgs2 .............................. |TestArgs2()| + TestArgs3 .............................. |TestArgs3()| g:tlib#debug ........................... |g:tlib#debug| tlib#notify#Echo ....................... |tlib#notify#Echo()| tlib#notify#TrimMessage ................ |tlib#notify#TrimMessage()| @@ -53,6 +60,7 @@ Contents~ tlib#vim#Maximize ...................... |tlib#vim#Maximize()| tlib#vim#RestoreWindow ................. |tlib#vim#RestoreWindow()| g:tlib#vim#use_wmctrl .................. |g:tlib#vim#use_wmctrl| + tlib#vim#CopyFunction .................. |tlib#vim#CopyFunction()| tlib#progressbar#Init .................. |tlib#progressbar#Init()| tlib#progressbar#Display ............... |tlib#progressbar#Display()| tlib#progressbar#Restore ............... |tlib#progressbar#Restore()| @@ -89,6 +97,9 @@ Contents~ tlib#char#Get .......................... |tlib#char#Get()| tlib#char#IsAvailable .................. |tlib#char#IsAvailable()| tlib#char#GetWithTimeout ............... |tlib#char#GetWithTimeout()| + g:tlib#Filter_glob#seq ................. |g:tlib#Filter_glob#seq| + g:tlib#Filter_glob#char ................ |g:tlib#Filter_glob#char| + tlib#Filter_glob#New ................... |tlib#Filter_glob#New()| g:tlib_scratch_pos ..................... |g:tlib_scratch_pos| g:tlib#scratch#hidden .................. |g:tlib#scratch#hidden| tlib#scratch#UseScratch ................ |tlib#scratch#UseScratch()| @@ -124,6 +135,8 @@ Contents~ tlib#agent#CopyItems ................... |tlib#agent#CopyItems()| tlib#agent#PageUp ...................... |tlib#agent#PageUp()| tlib#agent#PageDown .................... |tlib#agent#PageDown()| + tlib#agent#Home ........................ |tlib#agent#Home()| + tlib#agent#End ......................... |tlib#agent#End()| tlib#agent#Up .......................... |tlib#agent#Up()| tlib#agent#Down ........................ |tlib#agent#Down()| tlib#agent#UpN ......................... |tlib#agent#UpN()| @@ -178,8 +191,6 @@ Contents~ tlib#bitwise#ShiftLeft ................. |tlib#bitwise#ShiftLeft()| tlib#bitwise#Add ....................... |tlib#bitwise#Add()| tlib#bitwise#Sub ....................... |tlib#bitwise#Sub()| - g:tlib#Filter_cnfx#expander ............ |g:tlib#Filter_cnfx#expander| - tlib#Filter_cnfx#New ................... |tlib#Filter_cnfx#New()| tlib#url#Decode ........................ |tlib#url#Decode()| tlib#url#DecodeChar .................... |tlib#url#DecodeChar()| tlib#url#EncodeChar .................... |tlib#url#EncodeChar()| @@ -235,6 +246,7 @@ Contents~ g:tlib_inputlist_shortmessage .......... |g:tlib_inputlist_shortmessage| tlib#World#New ......................... |tlib#World#New()| prototype.PrintLines + prototype.Suspend tlib#tab#BufMap ........................ |tlib#tab#BufMap()| tlib#tab#TabWinNr ...................... |tlib#tab#TabWinNr()| tlib#tab#Set ........................... |tlib#tab#Set()| @@ -409,6 +421,33 @@ plugin/02tlib.vim~ Time the execution time of CMD. +======================================================================== +test/tlib.vim~ + + *Add()* +Add(a,b) + List + + *TestGetArg()* +TestGetArg(...) + Optional arguments + + *TestGetArg1()* +TestGetArg1(...) + + *TestArgs()* +TestArgs(...) + + *TestArgs1()* +TestArgs1(...) + + *TestArgs2()* +TestArgs2(...) + + *TestArgs3()* +TestArgs3(...) + + ======================================================================== autoload/tlib.vim~ @@ -451,7 +490,7 @@ tlib#persistent#Dir(?mode = 'bg') tlib#persistent#Filename(type, ?file=%, ?mkdir=0) *tlib#persistent#Get()* -tlib#persistent#Get(cfile) +tlib#persistent#Get(...) *tlib#persistent#Value()* tlib#persistent#Value(...) @@ -500,6 +539,9 @@ g:tlib#vim#use_wmctrl (default: executable('wmctrl')) default method of setting 'lines' and 'columns' to a large value. + *tlib#vim#CopyFunction()* +tlib#vim##CopyFunction(old, new, overwrite=0) + ======================================================================== autoload/tlib/progressbar.vim~ @@ -731,6 +773,25 @@ tlib#char#IsAvailable() tlib#char#GetWithTimeout(timeout, ...) +======================================================================== +autoload/tlib/Filter_glob.vim~ + + *g:tlib#Filter_glob#seq* +g:tlib#Filter_glob#seq (default: '*') + A character that should be expanded to '\.\{-}'. + + *g:tlib#Filter_glob#char* +g:tlib#Filter_glob#char (default: '?') + A character that should be expanded to '\.\?'. + + *tlib#Filter_glob#New()* +tlib#Filter_glob#New(...) + The same as |tlib#Filter_cnf#New()| but a a customizable character + |see tlib#Filter_glob#seq| is expanded to '\.\{-}' and + |g:tlib#Filter_glob#char| is expanded to '\.'. + The pattern is a '/\V' very no-'/magic' regexp pattern. + + ======================================================================== autoload/tlib/scratch.vim~ @@ -829,7 +890,7 @@ tlib#cache#Filename(type, ?file=%, ?mkdir=0, ?dir='') tlib#cache#Save(cfile, dictionary) *tlib#cache#Get()* -tlib#cache#Get(cfile) +tlib#cache#Get(cfile, ...) *tlib#cache#Value()* tlib#cache#Value(cfile, generator, ftime, ...) @@ -939,6 +1000,12 @@ tlib#agent#PageUp(world, selected) *tlib#agent#PageDown()* tlib#agent#PageDown(world, selected) + *tlib#agent#Home()* +tlib#agent#Home(world, selected) + + *tlib#agent#End()* +tlib#agent#End(world, selected) + *tlib#agent#Up()* tlib#agent#Up(world, selected, ...) @@ -1116,20 +1183,6 @@ tlib#bitwise#Add(num1, num2, ...) tlib#bitwise#Sub(num1, num2, ...) -======================================================================== -autoload/tlib/Filter_cnfx.vim~ - - *g:tlib#Filter_cnfx#expander* -g:tlib#Filter_cnfx#expander (default: '+') - A character that should be expanded to '\.\{-}'. - - *tlib#Filter_cnfx#New()* -tlib#Filter_cnfx#New(...) - The same as |tlib#Filter_cnfd#New()| but a a customizable character - |see tlib#Filter_cnfx#expander| is expanded to '\.\{-}'. - The pattern is a '/\V' very no-'/magic' regexp pattern. - - ======================================================================== autoload/tlib/url.vim~ @@ -1274,18 +1327,17 @@ g:tlib#input#livesearch_threshold (default: 1000) filter. This is useful on slower machines or with very long lists. *g:tlib#input#filter_mode* -g:tlib#input#filter_mode (default: 'cnfx') +g:tlib#input#filter_mode (default: 'glob') Determine how |tlib#input#List()| and related functions work. - Can be "cnf", "cnfd", "cnfx", "seq", or "fuzzy". See: - cnfx ... Like cnfd but |g:tlib#Filter_cnfx#expander| is interpreted - as a wildcard (this is the default method) - - A plus character ("+") acts as a wildcard as if ".\{-}" (see - |/\{-|) were entered. + Can be "glob", "cnf", "cnfd", "seq", or "fuzzy". See: + glob ... Like cnf but "*" and "?" (see |g:tlib#Filter_glob#seq|, + |g:tlib#Filter_glob#char|) are interpreted as glob-like + |wildcards| (this is the default method) - Examples: - - "f+o" matches "fo", "fxo", and "fxxxoo", but doesn't match + - "f*o" matches "fo", "fxo", and "fxxxoo", but doesn't match "far". - Otherwise it is a derivate of the cnf method (see below). - - See also |tlib#Filter_cnfx#New()|. + - See also |tlib#Filter_glob#New()|. cnfd ... Like cnf but "." is interpreted as a wildcard, i.e. it is expanded to "\.\{-}" - A period character (".") acts as a wildcard as if ".\{-}" (see @@ -1568,6 +1620,8 @@ tlib#World#New(...) prototype.PrintLines +prototype.Suspend + ======================================================================== autoload/tlib/tab.vim~ diff --git a/sources_non_forked/tlib/plugin/02tlib.vim b/sources_non_forked/tlib/plugin/02tlib.vim index c60dfd3b..6cbab75d 100644 --- a/sources_non_forked/tlib/plugin/02tlib.vim +++ b/sources_non_forked/tlib/plugin/02tlib.vim @@ -4,7 +4,7 @@ " @License: GPL (see http://www.gnu.org/licenses/gpl.txt) " @Created: 2007-04-10. " @Last Change: 2013-09-25. -" @Revision: 748 +" @Revision: 749 " GetLatestVimScripts: 1863 1 tlib.vim if &cp || exists("loaded_tlib") @@ -14,7 +14,7 @@ if v:version < 700 "{{{2 echoerr "tlib requires Vim >= 7" finish endif -let loaded_tlib = 107 +let loaded_tlib = 108 let s:save_cpo = &cpo set cpo&vim diff --git a/sources_non_forked/vim-airline/autoload/airline/extensions/tabline/unique_tail_improved.vim b/sources_non_forked/vim-airline/autoload/airline/extensions/tabline/unique_tail_improved.vim index 1b4dfa3f..6b13dcf0 100644 --- a/sources_non_forked/vim-airline/autoload/airline/extensions/tabline/unique_tail_improved.vim +++ b/sources_non_forked/vim-airline/autoload/airline/extensions/tabline/unique_tail_improved.vim @@ -19,6 +19,7 @@ function! airline#extensions#tabline#unique_tail_improved#format(bufnr, buffers) let tokens = reverse(split(substitute(fnamemodify(name, ':p:.:h'), '\\', '/', 'g'), '/')) let token_index = 0 for token in tokens + if token == '' | continue | endif if token == '.' | break | endif if !has_key(path_tokens, token_index) let path_tokens[token_index] = {} diff --git a/sources_non_forked/vim-airline/autoload/airline/extensions/whitespace.vim b/sources_non_forked/vim-airline/autoload/airline/extensions/whitespace.vim index ba98b71e..e4e1b202 100644 --- a/sources_non_forked/vim-airline/autoload/airline/extensions/whitespace.vim +++ b/sources_non_forked/vim-airline/autoload/airline/extensions/whitespace.vim @@ -36,19 +36,17 @@ function! airline#extensions#whitespace#check() let mixed = 0 if index(checks, 'indent') > -1 - let indents = [search('^ \{2,}', 'nb'), search('^ \{2,}', 'n'), search('^\t', 'nb'), search('^\t', 'n')] - let mixed = indents[0] != 0 && indents[1] != 0 && indents[2] != 0 && indents[3] != 0 + let mixed = search('\v(^\t+ +)|(^ +\t+)', 'nw') endif - if trailing != 0 || mixed + if trailing != 0 || mixed != 0 let b:airline_whitespace_check = s:symbol if s:show_message if trailing != 0 let b:airline_whitespace_check .= (g:airline_symbols.space).printf(s:trailing_format, trailing) endif - if mixed - let mixnr = indents[0] == indents[1] ? indents[0] : indents[2] - let b:airline_whitespace_check .= (g:airline_symbols.space).printf(s:mixed_indent_format, mixnr) + if mixed != 0 + let b:airline_whitespace_check .= (g:airline_symbols.space).printf(s:mixed_indent_format, mixed) endif endif endif diff --git a/sources_non_forked/vim-commentary/CONTRIBUTING.markdown b/sources_non_forked/vim-commentary/CONTRIBUTING.markdown new file mode 100644 index 00000000..b3f00951 --- /dev/null +++ b/sources_non_forked/vim-commentary/CONTRIBUTING.markdown @@ -0,0 +1 @@ +See the [contribution guidelines for pathogen.vim](https://github.com/tpope/vim-pathogen/blob/master/CONTRIBUTING.markdown). diff --git a/sources_non_forked/vim-commentary/README.markdown b/sources_non_forked/vim-commentary/README.markdown index 4db3ed99..0b60009a 100644 --- a/sources_non_forked/vim-commentary/README.markdown +++ b/sources_non_forked/vim-commentary/README.markdown @@ -1,5 +1,4 @@ -commentary.vim -============== +# commentary.vim Comment stuff out. Use `gcc` to comment out a line (takes a count), `gc` to comment out the target of a motion (for example, `gcap` to @@ -15,10 +14,9 @@ minimalism, it weighs in at under 100 lines of code. Oh, and it uncomments, too. The above maps actually toggle, and `gcu` uncomments a set of adjacent commented lines. Install [repeat.vim](https://github.com/tpope/vim-repeat) to enable -repeating `gcu` with `.` (the other maps are repeatable without it). +repeating `gcu` with `.`. (The other maps are repeatable without it.) -Installation ------------- +## Installation If you don't have a preferred installation method, I recommend installing [pathogen.vim](https://github.com/tpope/vim-pathogen), and @@ -30,8 +28,7 @@ then simply copy and paste: Once help tags have been generated, you can view the manual with `:help commentary`. -FAQ ---- +## FAQ > My favorite file type isn't supported! @@ -39,14 +36,7 @@ Relax! You just have to adjust `'commentstring'`: autocmd FileType apache set commentstring=#\ %s -Contributing ------------- - -See the contribution guidelines for -[pathogen.vim](https://github.com/tpope/vim-pathogen#readme). - -Self-Promotion --------------- +## Self-Promotion Like commentary.vim? Follow the repository on [GitHub](https://github.com/tpope/vim-commentary) and vote for it on @@ -55,8 +45,7 @@ you're feeling especially charitable, follow [tpope](http://tpo.pe/) on [Twitter](http://twitter.com/tpope) and [GitHub](https://github.com/tpope). -License -------- +## License Copyright (c) Tim Pope. Distributed under the same terms as Vim itself. See `:help license`. diff --git a/sources_non_forked/vim-commentary/doc/commentary.txt b/sources_non_forked/vim-commentary/doc/commentary.txt index 63dbe267..e8c81ea4 100644 --- a/sources_non_forked/vim-commentary/doc/commentary.txt +++ b/sources_non_forked/vim-commentary/doc/commentary.txt @@ -4,7 +4,7 @@ Author: Tim Pope License: Same terms as Vim itself (see |license|) Comment stuff out. Then uncomment it later. Relies on 'commentstring' to be -correctly set. +correctly set, or uses b:commentary_format if it is set. The gc mappings are preferred, while the \\ mappings are provided for backwards compatibility. @@ -25,4 +25,7 @@ gcc Comment or uncomment [count] lines. gcu Uncomment the current and adjacent commented lines. \\u +The |User| CommentaryPost autocommand fires after a successful operation and +can be used for advanced customization. + vim:tw=78:et:ft=help:norl: diff --git a/sources_non_forked/vim-commentary/plugin/commentary.vim b/sources_non_forked/vim-commentary/plugin/commentary.vim index cc6f14b2..d7272d5b 100644 --- a/sources_non_forked/vim-commentary/plugin/commentary.vim +++ b/sources_non_forked/vim-commentary/plugin/commentary.vim @@ -1,6 +1,6 @@ " commentary.vim - Comment stuff out " Maintainer: Tim Pope -" Version: 1.1 +" Version: 1.2 " GetLatestVimScripts: 3695 1 :AutoInstall: commentary.vim if exists("g:loaded_commentary") || &cp || v:version < 700 @@ -8,6 +8,12 @@ if exists("g:loaded_commentary") || &cp || v:version < 700 endif let g:loaded_commentary = 1 +function! s:surroundings() abort + return split(substitute(substitute( + \ get(b:, 'commentary_format', &commentstring) + \ ,'\S\zs%s',' %s','') ,'%s\ze\S', '%s ', ''), '%s', 1) +endfunction + function! s:go(type,...) abort if a:0 let [lnum1, lnum2] = [a:type, a:1] @@ -15,7 +21,7 @@ function! s:go(type,...) abort let [lnum1, lnum2] = [line("'["), line("']")] endif - let [l, r] = split(substitute(substitute(&commentstring,'\S\zs%s',' %s',''),'%s\ze\S','%s ',''),'%s',1) + let [l, r] = s:surroundings() let uncomment = 2 for lnum in range(lnum1,lnum2) let line = matchstr(getline(lnum),'\S.*\s\@Commentary') || maparg('gc','n') ==# '' nmap gcu CommentaryUndo endif -if maparg('\\','n') ==# '' && maparg('\','n') ==# '' +if maparg('\\','n') ==# '' && maparg('\','n') ==# '' && get(g:, 'commentary_map_backslash', 1) xmap \\ Commentary nmap \\ Commentary nmap \\\ CommentaryLine diff --git a/sources_non_forked/vim-fugitive/CONTRIBUTING.markdown b/sources_non_forked/vim-fugitive/CONTRIBUTING.markdown index 8583e1e4..e651dcae 100644 --- a/sources_non_forked/vim-fugitive/CONTRIBUTING.markdown +++ b/sources_non_forked/vim-fugitive/CONTRIBUTING.markdown @@ -3,13 +3,13 @@ and removing other plugins. The sad truth about VimScript is that it is fraught with incompatibilities waiting to happen. I'm happy to work around them where I can, but it's up to you to isolate the conflict. -If your [commit message sucks](http://stopwritingramblingcommitmessages.com/), -I'm not going to accept your pull request. I've explained very politely -dozens of times that -[my general guidelines](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html) -are absolute rules on my own repositories, so I may lack the energy to explain -it to you yet another time. And please, if I ask you to change something, -`git commit --amend`. +Fugitive is particularly prone to regressions due to Git version issues, +platform issues, and interactions with other plugins. I end up bisecting a +lot more than other projects, and thus I'm especially meticulous here about +maintaining a clean, readable, history. Squash and force push any requested +changes to a pull request. And if your [commit message +sucks](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html), +I'm not going to accept it. Period. Beyond that, don't be shy about asking before patching. What takes you hours might take me minutes simply because I have both domain knowledge and a diff --git a/sources_non_forked/vim-fugitive/plugin/fugitive.vim b/sources_non_forked/vim-fugitive/plugin/fugitive.vim index 8ddb28da..80020dc6 100644 --- a/sources_non_forked/vim-fugitive/plugin/fugitive.vim +++ b/sources_non_forked/vim-fugitive/plugin/fugitive.vim @@ -139,6 +139,9 @@ function! fugitive#extract_git_dir(path) abort if index(split($GIT_CEILING_DIRECTORIES, ':'), root) >= 0 break endif + if root ==# $GIT_WORK_TREE && fugitive#is_git_dir($GIT_DIR) + return $GIT_DIR + endif let dir = s:sub(root, '[\/]$', '') . '/.git' let type = getftype(dir) if type ==# 'dir' && fugitive#is_git_dir(dir) @@ -736,14 +739,16 @@ function! s:stage_info(lnum) abort endwhile if !lnum return ['', ''] - elseif getline(lnum+1) =~# '^# .*\:p')) | - \ let b:git_dir = s:temp_files[expand(':p')] | + \ let b:git_dir = s:temp_files[expand(':p')].dir | \ let b:git_type = 'temp' | + \ let b:git_args = s:temp_files[expand(':p')].args | \ call fugitive#detect(expand(':p')) | \ setlocal bufhidden=delete | \ nnoremap q :bdelete| diff --git a/sources_non_forked/vim-golang/autoload/go/complete.vim b/sources_non_forked/vim-golang/autoload/go/complete.vim new file mode 100644 index 00000000..8dd43de4 --- /dev/null +++ b/sources_non_forked/vim-golang/autoload/go/complete.vim @@ -0,0 +1,103 @@ +" Copyright 2011 The Go Authors. All rights reserved. +" Use of this source code is governed by a BSD-style +" license that can be found in the LICENSE file. +" +" This file provides a utility function that performs auto-completion of +" package names, for use by other commands. + +let s:goos = $GOOS +let s:goarch = $GOARCH + +if len(s:goos) == 0 + if exists('g:golang_goos') + let s:goos = g:golang_goos + elseif has('win32') || has('win64') + let s:goos = 'windows' + elseif has('macunix') + let s:goos = 'darwin' + else + let s:goos = '*' + endif +endif + +if len(s:goarch) == 0 + if exists('g:golang_goarch') + let s:goarch = g:golang_goarch + else + let s:goarch = '*' + endif +endif + +function! go#complete#PackageMembers(package, member) + silent! let content = system('godoc ' . a:package) + if v:shell_error || !len(content) + return [] + endif + let lines = filter(split(content, "\n"),"v:val !~ '^\\s\\+$'") + try + let mx1 = '^\s\+\(\S+\)\s\+=\s\+.*' + let mx2 = '^\%(const\|var\|type\|func\) \([A-Z][^ (]\+\).*' + let candidates = + \ map(filter(copy(lines), 'v:val =~ mx1'), 'substitute(v:val, mx1, "\\1", "")') + \ + map(filter(copy(lines), 'v:val =~ mx2'), 'substitute(v:val, mx2, "\\1", "")') + return filter(candidates, '!stridx(v:val, a:member)') + catch + return [] + endtry +endfunction + +function! go#complete#Package(ArgLead, CmdLine, CursorPos) + let dirs = [] + + let words = split(a:CmdLine, '\s\+', 1) + if len(words) > 2 + " Complete package members + return go#complete#PackageMembers(words[1], words[2]) + endif + + if executable('go') + let goroot = substitute(system('go env GOROOT'), '\n', '', 'g') + if v:shell_error + echomsg '\'go env GOROOT\' failed' + endif + else + let goroot = $GOROOT + endif + + if len(goroot) != 0 && isdirectory(goroot) + let dirs += [goroot] + endif + + let pathsep = ':' + if s:goos == 'windows' + let pathsep = ';' + endif + let workspaces = split($GOPATH, pathsep) + if workspaces != [] + let dirs += workspaces + endif + + if len(dirs) == 0 + " should not happen + return [] + endif + + let ret = {} + for dir in dirs + " this may expand to multiple lines + let root = split(expand(dir . '/pkg/' . s:goos . '_' . s:goarch), "\n") + call add(root, expand(dir . '/src')) + for r in root + for i in split(globpath(r, a:ArgLead.'*'), "\n") + if isdirectory(i) + let i .= '/' + elseif i !~ '\.a$' + continue + endif + let i = substitute(substitute(i[len(r)+1:], '[\\]', '/', 'g'), '\.a$', '', 'g') + let ret[i] = i + endfor + endfor + endfor + return sort(keys(ret)) +endfunction diff --git a/sources_non_forked/vim-golang/compiler/go.vim b/sources_non_forked/vim-golang/compiler/go.vim new file mode 100644 index 00000000..2c8cce49 --- /dev/null +++ b/sources_non_forked/vim-golang/compiler/go.vim @@ -0,0 +1,30 @@ +" Copyright 2013 The Go Authors. All rights reserved. +" Use of this source code is governed by a BSD-style +" license that can be found in the LICENSE file. +" +" compiler/go.vim: Vim compiler file for Go. + +if exists("current_compiler") + finish +endif +let current_compiler = "go" + +if exists(":CompilerSet") != 2 + command -nargs=* CompilerSet setlocal +endif + +let s:save_cpo = &cpo +set cpo-=C + +CompilerSet makeprg=go\ build +CompilerSet errorformat= + \%-G#\ %.%#, + \%A%f:%l:%c:\ %m, + \%A%f:%l:\ %m, + \%C%*\\s%m, + \%-G%.%# + +let &cpo = s:save_cpo +unlet s:save_cpo + +" vim:ts=4:sw=4:et diff --git a/sources_non_forked/vim-golang/ftdetect/gofiletype.vim b/sources_non_forked/vim-golang/ftdetect/gofiletype.vim new file mode 100644 index 00000000..b658f6b0 --- /dev/null +++ b/sources_non_forked/vim-golang/ftdetect/gofiletype.vim @@ -0,0 +1,23 @@ +" We take care to preserve the user's fileencodings and fileformats, +" because those settings are global (not buffer local), yet we want +" to override them for loading Go files, which are defined to be UTF-8. +let s:current_fileformats = '' +let s:current_fileencodings = '' + +" define fileencodings to open as utf-8 encoding even if it's ascii. +function! s:gofiletype_pre() + let s:current_fileformats = &g:fileformats + let s:current_fileencodings = &g:fileencodings + set fileencodings=utf-8 fileformats=unix + setlocal filetype=go +endfunction + +" restore fileencodings as others +function! s:gofiletype_post() + let &g:fileformats = s:current_fileformats + let &g:fileencodings = s:current_fileencodings +endfunction + +au BufNewFile *.go setlocal filetype=go fileencoding=utf-8 fileformat=unix +au BufRead *.go call s:gofiletype_pre() +au BufReadPost *.go call s:gofiletype_post() diff --git a/sources_non_forked/vim-golang/ftplugin/go.vim b/sources_non_forked/vim-golang/ftplugin/go.vim new file mode 100644 index 00000000..8066733c --- /dev/null +++ b/sources_non_forked/vim-golang/ftplugin/go.vim @@ -0,0 +1,17 @@ +" Copyright 2013 The Go Authors. All rights reserved. +" Use of this source code is governed by a BSD-style +" license that can be found in the LICENSE file. +" +" go.vim: Vim filetype plugin for Go. + +if exists("b:did_ftplugin") + finish +endif +let b:did_ftplugin = 1 + +setlocal comments=s1:/*,mb:*,ex:*/,:// +setlocal commentstring=//\ %s + +let b:undo_ftplugin = "setl com< cms<" + +" vim:ts=4:sw=4:et diff --git a/sources_non_forked/vim-golang/ftplugin/go/fmt.vim b/sources_non_forked/vim-golang/ftplugin/go/fmt.vim new file mode 100644 index 00000000..359545bd --- /dev/null +++ b/sources_non_forked/vim-golang/ftplugin/go/fmt.vim @@ -0,0 +1,69 @@ +" Copyright 2011 The Go Authors. All rights reserved. +" Use of this source code is governed by a BSD-style +" license that can be found in the LICENSE file. +" +" fmt.vim: Vim command to format Go files with gofmt. +" +" This filetype plugin add a new commands for go buffers: +" +" :Fmt +" +" Filter the current Go buffer through gofmt. +" It tries to preserve cursor position and avoids +" replacing the buffer with stderr output. +" +" Options: +" +" g:go_fmt_commands [default=1] +" +" Flag to indicate whether to enable the commands listed above. +" +" g:gofmt_command [default="gofmt"] +" +" Flag naming the gofmt executable to use. +" +if exists("b:did_ftplugin_go_fmt") + finish +endif + +if !exists("g:go_fmt_commands") + let g:go_fmt_commands = 1 +endif + +if !exists("g:gofmt_command") + let g:gofmt_command = "gofmt" +endif + +if g:go_fmt_commands + command! -buffer Fmt call s:GoFormat() +endif + +function! s:GoFormat() + let view = winsaveview() + silent execute "%!" . g:gofmt_command + if v:shell_error + let errors = [] + for line in getline(1, line('$')) + let tokens = matchlist(line, '^\(.\{-}\):\(\d\+\):\(\d\+\)\s*\(.*\)') + if !empty(tokens) + call add(errors, {"filename": @%, + \"lnum": tokens[2], + \"col": tokens[3], + \"text": tokens[4]}) + endif + endfor + if empty(errors) + % | " Couldn't detect gofmt error format, output errors + endif + undo + if !empty(errors) + call setqflist(errors, 'r') + endif + echohl Error | echomsg "Gofmt returned error" | echohl None + endif + call winrestview(view) +endfunction + +let b:did_ftplugin_go_fmt = 1 + +" vim:ts=4:sw=4:et diff --git a/sources_non_forked/vim-golang/ftplugin/go/import.vim b/sources_non_forked/vim-golang/ftplugin/go/import.vim new file mode 100644 index 00000000..91c8697a --- /dev/null +++ b/sources_non_forked/vim-golang/ftplugin/go/import.vim @@ -0,0 +1,250 @@ +" Copyright 2011 The Go Authors. All rights reserved. +" Use of this source code is governed by a BSD-style +" license that can be found in the LICENSE file. +" +" import.vim: Vim commands to import/drop Go packages. +" +" This filetype plugin adds three new commands for go buffers: +" +" :Import {path} +" +" Import ensures that the provided package {path} is imported +" in the current Go buffer, using proper style and ordering. +" If {path} is already being imported, an error will be +" displayed and the buffer will be untouched. +" +" :ImportAs {localname} {path} +" +" Same as Import, but uses a custom local name for the package. +" +" :Drop {path} +" +" Remove the import line for the provided package {path}, if +" present in the current Go buffer. If {path} is not being +" imported, an error will be displayed and the buffer will be +" untouched. +" +" If you would like to add shortcuts, you can do so by doing the following: +" +" Import fmt +" au Filetype go nnoremap f :Import fmt +" +" Drop fmt +" au Filetype go nnoremap F :Drop fmt +" +" Import the word under your cursor +" au Filetype go nnoremap k +" \ :exe 'Import ' . expand('') +" +" The backslash '\' is the default maplocalleader, so it is possible that +" your vim is set to use a different character (:help maplocalleader). +" +" Options: +" +" g:go_import_commands [default=1] +" +" Flag to indicate whether to enable the commands listed above. +" +if exists("b:did_ftplugin_go_import") + finish +endif + +if !exists("g:go_import_commands") + let g:go_import_commands = 1 +endif + +if g:go_import_commands + command! -buffer -nargs=? -complete=customlist,go#complete#Package Drop call s:SwitchImport(0, '', ) + command! -buffer -nargs=1 -complete=customlist,go#complete#Package Import call s:SwitchImport(1, '', ) + command! -buffer -nargs=* -complete=customlist,go#complete#Package ImportAs call s:SwitchImport(1, ) +endif + +function! s:SwitchImport(enabled, localname, path) + let view = winsaveview() + let path = a:path + + " Quotes are not necessary, so remove them if provided. + if path[0] == '"' + let path = strpart(path, 1) + endif + if path[len(path)-1] == '"' + let path = strpart(path, 0, len(path) - 1) + endif + if path == '' + call s:Error('Import path not provided') + return + endif + + " Extract any site prefix (e.g. github.com/). + " If other imports with the same prefix are grouped separately, + " we will add this new import with them. + " Only up to and including the first slash is used. + let siteprefix = matchstr(path, "^[^/]*/") + + let qpath = '"' . path . '"' + if a:localname != '' + let qlocalpath = a:localname . ' ' . qpath + else + let qlocalpath = qpath + endif + let indentstr = 0 + let packageline = -1 " Position of package name statement + let appendline = -1 " Position to introduce new import + let deleteline = -1 " Position of line with existing import + let linesdelta = 0 " Lines added/removed + + " Find proper place to add/remove import. + let line = 0 + while line <= line('$') + let linestr = getline(line) + + if linestr =~# '^package\s' + let packageline = line + let appendline = line + + elseif linestr =~# '^import\s\+(' + let appendstr = qlocalpath + let indentstr = 1 + let appendline = line + let firstblank = -1 + let lastprefix = "" + while line <= line("$") + let line = line + 1 + let linestr = getline(line) + let m = matchlist(getline(line), '^\()\|\(\s\+\)\(\S*\s*\)"\(.\+\)"\)') + if empty(m) + if siteprefix == "" && a:enabled + " must be in the first group + break + endif + " record this position, but keep looking + if firstblank < 0 + let firstblank = line + endif + continue + endif + if m[1] == ')' + " if there's no match, add it to the first group + if appendline < 0 && firstblank >= 0 + let appendline = firstblank + endif + break + endif + let lastprefix = matchstr(m[4], "^[^/]*/") + if a:localname != '' && m[3] != '' + let qlocalpath = printf('%-' . (len(m[3])-1) . 's %s', a:localname, qpath) + endif + let appendstr = m[2] . qlocalpath + let indentstr = 0 + if m[4] == path + let appendline = -1 + let deleteline = line + break + elseif m[4] < path + " don't set candidate position if we have a site prefix, + " we've passed a blank line, and this doesn't share the same + " site prefix. + if siteprefix == "" || firstblank < 0 || match(m[4], "^" . siteprefix) >= 0 + let appendline = line + endif + elseif siteprefix != "" && match(m[4], "^" . siteprefix) >= 0 + " first entry of site group + let appendline = line - 1 + break + endif + endwhile + break + + elseif linestr =~# '^import ' + if appendline == packageline + let appendstr = 'import ' . qlocalpath + let appendline = line - 1 + endif + let m = matchlist(linestr, '^import\(\s\+\)\(\S*\s*\)"\(.\+\)"') + if !empty(m) + if m[3] == path + let appendline = -1 + let deleteline = line + break + endif + if m[3] < path + let appendline = line + endif + if a:localname != '' && m[2] != '' + let qlocalpath = printf("%s %" . len(m[2])-1 . "s", a:localname, qpath) + endif + let appendstr = 'import' . m[1] . qlocalpath + endif + + elseif linestr =~# '^\(var\|const\|type\|func\)\>' + break + + endif + let line = line + 1 + endwhile + + " Append or remove the package import, as requested. + if a:enabled + if deleteline != -1 + call s:Error(qpath . ' already being imported') + elseif appendline == -1 + call s:Error('No package line found') + else + if appendline == packageline + call append(appendline + 0, '') + call append(appendline + 1, 'import (') + call append(appendline + 2, ')') + let appendline += 2 + let linesdelta += 3 + let appendstr = qlocalpath + let indentstr = 1 + endif + call append(appendline, appendstr) + execute appendline + 1 + if indentstr + execute 'normal >>' + endif + let linesdelta += 1 + endif + else + if deleteline == -1 + call s:Error(qpath . ' not being imported') + else + execute deleteline . 'd' + let linesdelta -= 1 + + if getline(deleteline-1) =~# '^import\s\+(' && getline(deleteline) =~# '^)' + " Delete empty import block + let deleteline -= 1 + execute deleteline . "d" + execute deleteline . "d" + let linesdelta -= 2 + endif + + if getline(deleteline) == '' && getline(deleteline - 1) == '' + " Delete spacing for removed line too. + execute deleteline . "d" + let linesdelta -= 1 + endif + endif + endif + + " Adjust view for any changes. + let view.lnum += linesdelta + let view.topline += linesdelta + if view.topline < 0 + let view.topline = 0 + endif + + " Put buffer back where it was. + call winrestview(view) + +endfunction + +function! s:Error(s) + echohl Error | echo a:s | echohl None +endfunction + +let b:did_ftplugin_go_import = 1 + +" vim:ts=4:sw=4:et diff --git a/sources_non_forked/vim-golang/ftplugin/go/test.sh b/sources_non_forked/vim-golang/ftplugin/go/test.sh new file mode 100644 index 00000000..d8a5b895 --- /dev/null +++ b/sources_non_forked/vim-golang/ftplugin/go/test.sh @@ -0,0 +1,78 @@ +#!/bin/bash -e +# +# Copyright 2012 The Go Authors. All rights reserved. +# Use of this source code is governed by a BSD-style +# license that can be found in the LICENSE file. +# +# Tests for import.vim. + +cd $(dirname $0) + +cat > base.go <&1 -n "$1: " + vim -e -s -u /dev/null -U /dev/null --noplugin -c "source import.vim" \ + -c "$1" -c 'wq! test.go' base.go + # ensure blank lines are treated correctly + if ! gofmt test.go | cmp test.go -; then + echo 2>&1 "gofmt conflict" + gofmt test.go | diff -u test.go - | sed "s/^/ /" 2>&1 + fail=1 + return + fi + if ! [[ $(cat test.go) =~ $2 ]]; then + echo 2>&1 "$2 did not match" + cat test.go | sed "s/^/ /" 2>&1 + fail=1 + return + fi + echo 2>&1 "ok" +} + +# Tests for Import + +test_one "Import baz" '"baz".*"bytes"' +test_one "Import io/ioutil" '"io".*"io/ioutil".*"net"' +test_one "Import myc" '"io".*"myc".*"net"' # prefix of a site prefix +test_one "Import nat" '"io".*"nat".*"net"' +test_one "Import net/http" '"net".*"net/http".*"mycorp/foo"' +test_one "Import zoo" '"net".*"zoo".*"mycorp/foo"' +test_one "Import mycorp/bar" '"net".*"mycorp/bar".*"mycorp/foo"' +test_one "Import mycorp/goo" '"net".*"mycorp/foo".*"mycorp/goo"' + +# Tests for Drop + +cat > base.go <&1 "FAIL" + exit 1 +fi +echo 2>&1 "PASS" diff --git a/sources_non_forked/vim-golang/indent/go.vim b/sources_non_forked/vim-golang/indent/go.vim new file mode 100644 index 00000000..faf4d79e --- /dev/null +++ b/sources_non_forked/vim-golang/indent/go.vim @@ -0,0 +1,65 @@ +" Copyright 2011 The Go Authors. All rights reserved. +" Use of this source code is governed by a BSD-style +" license that can be found in the LICENSE file. +" +" indent/go.vim: Vim indent file for Go. +" +" TODO: +" - function invocations split across lines +" - general line splits (line ends in an operator) + +if exists("b:did_indent") + finish +endif +let b:did_indent = 1 + +" C indentation is too far off useful, mainly due to Go's := operator. +" Let's just define our own. +setlocal nolisp +setlocal autoindent +setlocal indentexpr=GoIndent(v:lnum) +setlocal indentkeys+=<:>,0=},0=) + +if exists("*GoIndent") + finish +endif + +function! GoIndent(lnum) + let prevlnum = prevnonblank(a:lnum-1) + if prevlnum == 0 + " top of file + return 0 + endif + + " grab the previous and current line, stripping comments. + let prevl = substitute(getline(prevlnum), '//.*$', '', '') + let thisl = substitute(getline(a:lnum), '//.*$', '', '') + let previ = indent(prevlnum) + + let ind = previ + + if prevl =~ '[({]\s*$' + " previous line opened a block + let ind += &sw + endif + if prevl =~# '^\s*\(case .*\|default\):$' + " previous line is part of a switch statement + let ind += &sw + endif + " TODO: handle if the previous line is a label. + + if thisl =~ '^\s*[)}]' + " this line closed a block + let ind -= &sw + endif + + " Colons are tricky. + " We want to outdent if it's part of a switch ("case foo:" or "default:"). + " We ignore trying to deal with jump labels because (a) they're rare, and + " (b) they're hard to disambiguate from a composite literal key. + if thisl =~# '^\s*\(case .*\|default\):$' + let ind -= &sw + endif + + return ind +endfunction diff --git a/sources_non_forked/vim-golang/mirror.txt b/sources_non_forked/vim-golang/mirror.txt new file mode 100644 index 00000000..7fc4f60f --- /dev/null +++ b/sources_non_forked/vim-golang/mirror.txt @@ -0,0 +1,6 @@ +This is a mirror of the misc/vim portion of the official Go repository. It is +automatically updated. + +Any contributions or issues should be made to the official repository. + +http://golang.org/doc/contribute.html diff --git a/sources_non_forked/vim-golang/plugin/godoc.vim b/sources_non_forked/vim-golang/plugin/godoc.vim new file mode 100644 index 00000000..a145d313 --- /dev/null +++ b/sources_non_forked/vim-golang/plugin/godoc.vim @@ -0,0 +1,130 @@ +" Copyright 2011 The Go Authors. All rights reserved. +" Use of this source code is governed by a BSD-style +" license that can be found in the LICENSE file. +" +" godoc.vim: Vim command to see godoc. +" +" +" Commands: +" +" :Godoc +" +" Open the relevant Godoc for either the word[s] passed to the command or +" the, by default, the word under the cursor. +" +" Options: +" +" g:go_godoc_commands [default=1] +" +" Flag to indicate whether to enable the commands listed above. + +if exists("g:loaded_godoc") + finish +endif +let g:loaded_godoc = 1 + +let s:buf_nr = -1 +let s:last_word = '' + +if !exists('g:go_godoc_commands') + let g:go_godoc_commands = 1 +endif + +if g:go_godoc_commands + command! -nargs=* -range -complete=customlist,go#complete#Package Godoc :call s:Godoc() +endif + +nnoremap (godoc-keyword) :call Godoc('') + +function! s:GodocView() + if !bufexists(s:buf_nr) + leftabove new + file `="[Godoc]"` + let s:buf_nr = bufnr('%') + elseif bufwinnr(s:buf_nr) == -1 + leftabove split + execute s:buf_nr . 'buffer' + delete _ + elseif bufwinnr(s:buf_nr) != bufwinnr('%') + execute bufwinnr(s:buf_nr) . 'wincmd w' + endif + + setlocal filetype=godoc + setlocal bufhidden=delete + setlocal buftype=nofile + setlocal noswapfile + setlocal nobuflisted + setlocal modifiable + setlocal nocursorline + setlocal nocursorcolumn + setlocal iskeyword+=: + setlocal iskeyword-=- + + nnoremap K :Godoc + + au BufHidden call let buf_nr = -1 +endfunction + +function! s:GodocWord(word) + if !executable('godoc') + echohl WarningMsg + echo "godoc command not found." + echo " install with: go get code.google.com/p/go.tools/cmd/godoc" + echohl None + return 0 + endif + let word = a:word + silent! let content = system('godoc ' . word) + if v:shell_error || !len(content) + if len(s:last_word) + silent! let content = system('godoc ' . s:last_word.'/'.word) + if v:shell_error || !len(content) + echo 'No documentation found for "' . word . '".' + return 0 + endif + let word = s:last_word.'/'.word + else + echo 'No documentation found for "' . word . '".' + return 0 + endif + endif + let s:last_word = word + silent! call s:GodocView() + setlocal modifiable + silent! %d _ + silent! put! =content + silent! normal gg + setlocal nomodifiable + setfiletype godoc + return 1 +endfunction + +function! s:Godoc(...) + if !len(a:000) + let oldiskeyword = &iskeyword + setlocal iskeyword+=. + let word = expand('') + let &iskeyword = oldiskeyword + let word = substitute(word, '[^a-zA-Z0-9\\/._~-]', '', 'g') + let words = split(word, '\.\ze[^./]\+$') + else + let words = a:000 + endif + if !len(words) + return + endif + if s:GodocWord(words[0]) + if len(words) > 1 + if search('^\%(const\|var\|type\|\s\+\) ' . words[1] . '\s\+=\s') + return + endif + if search('^func ' . words[1] . '(') + silent! normal zt + return + endif + echo 'No documentation found for "' . words[1] . '".' + endif + endif +endfunction + +" vim:ts=4:sw=4:et diff --git a/sources_non_forked/vim-golang/readme.txt b/sources_non_forked/vim-golang/readme.txt new file mode 100644 index 00000000..b8469f92 --- /dev/null +++ b/sources_non_forked/vim-golang/readme.txt @@ -0,0 +1,101 @@ +Vim plugins for Go (http://golang.org) +====================================== + +To use all the Vim plugins, add these lines to your $HOME/.vimrc. + + " Some Linux distributions set filetype in /etc/vimrc. + " Clear filetype flags before changing runtimepath to force Vim to reload them. + filetype off + filetype plugin indent off + set runtimepath+=$GOROOT/misc/vim + filetype plugin indent on + syntax on + +If you want to select fewer plugins, use the instructions in the rest of +this file. + +A popular configuration is to gofmt Go source files when they are saved. +To do that, add this line to the end of your $HOME/.vimrc. + + autocmd FileType go autocmd BufWritePre Fmt + + +Vim syntax highlighting +----------------------- + +To install automatic syntax highlighting for GO programs: + + 1. Copy or link the filetype detection script to the ftdetect directory + underneath your vim runtime directory (normally $HOME/.vim/ftdetect) + 2. Copy or link syntax/go.vim to the syntax directory underneath your vim + runtime directory (normally $HOME/.vim/syntax). Linking this file rather + than just copying it will ensure any changes are automatically reflected + in your syntax highlighting. + 3. Add the following line to your .vimrc file (normally $HOME/.vimrc): + + syntax on + +In a typical unix environment you might accomplish this using the following +commands: + + mkdir -p $HOME/.vim/ftdetect + mkdir -p $HOME/.vim/syntax + mkdir -p $HOME/.vim/autoload/go + ln -s $GOROOT/misc/vim/ftdetect/gofiletype.vim $HOME/.vim/ftdetect/ + ln -s $GOROOT/misc/vim/syntax/go.vim $HOME/.vim/syntax + ln -s $GOROOT/misc/vim/autoload/go/complete.vim $HOME/.vim/autoload/go + echo "syntax on" >> $HOME/.vimrc + + +Vim filetype plugins +-------------------- + +To install one of the available filetype plugins: + + 1. Same as 1 above. + 2. Copy or link ftplugin/go.vim to the ftplugin directory underneath your vim + runtime directory (normally $HOME/.vim/ftplugin). Copy or link one or more + additional plugins from ftplugin/go/*.vim to the Go-specific subdirectory + in the same place ($HOME/.vim/ftplugin/go/*.vim). + 3. Add the following line to your .vimrc file (normally $HOME/.vimrc): + + filetype plugin on + + +Vim indentation plugin +---------------------- + +To install automatic indentation: + + 1. Same as 1 above. + 2. Copy or link indent/go.vim to the indent directory underneath your vim + runtime directory (normally $HOME/.vim/indent). + 3. Add the following line to your .vimrc file (normally $HOME/.vimrc): + + filetype indent on + + +Vim compiler plugin +------------------- + +To install the compiler plugin: + + 1. Same as 1 above. + 2. Copy or link compiler/go.vim to the compiler directory underneath your vim + runtime directory (normally $HOME/.vim/compiler). + 3. Activate the compiler plugin with ":compiler go". To always enable the + compiler plugin in Go source files add an autocommand to your .vimrc file + (normally $HOME/.vimrc): + + autocmd FileType go compiler go + + +Godoc plugin +------------ + +To install godoc plugin: + + 1. Same as 1 above. + 2. Copy or link plugin/godoc.vim to $HOME/.vim/plugin/godoc, + syntax/godoc.vim to $HOME/.vim/syntax/godoc.vim, + and autoload/go/complete.vim to $HOME/.vim/autoload/go/complete.vim. diff --git a/sources_non_forked/vim-golang/syntax/go.vim b/sources_non_forked/vim-golang/syntax/go.vim new file mode 100644 index 00000000..1ce6cb27 --- /dev/null +++ b/sources_non_forked/vim-golang/syntax/go.vim @@ -0,0 +1,207 @@ +" Copyright 2009 The Go Authors. All rights reserved. +" Use of this source code is governed by a BSD-style +" license that can be found in the LICENSE file. +" +" go.vim: Vim syntax file for Go. +" +" Options: +" There are some options for customizing the highlighting; the recommended +" settings are the default values, but you can write: +" let OPTION_NAME = 0 +" in your ~/.vimrc file to disable particular options. You can also write: +" let OPTION_NAME = 1 +" to enable particular options. At present, all options default to on. +" +" - go_highlight_array_whitespace_error +" Highlights white space after "[]". +" - go_highlight_chan_whitespace_error +" Highlights white space around the communications operator that don't follow +" the standard style. +" - go_highlight_extra_types +" Highlights commonly used library types (io.Reader, etc.). +" - go_highlight_space_tab_error +" Highlights instances of tabs following spaces. +" - go_highlight_trailing_whitespace_error +" Highlights trailing white space. + +" Quit when a (custom) syntax file was already loaded +if exists("b:current_syntax") + finish +endif + +if !exists("go_highlight_array_whitespace_error") + let go_highlight_array_whitespace_error = 1 +endif +if !exists("go_highlight_chan_whitespace_error") + let go_highlight_chan_whitespace_error = 1 +endif +if !exists("go_highlight_extra_types") + let go_highlight_extra_types = 1 +endif +if !exists("go_highlight_space_tab_error") + let go_highlight_space_tab_error = 1 +endif +if !exists("go_highlight_trailing_whitespace_error") + let go_highlight_trailing_whitespace_error = 1 +endif + +syn case match + +syn keyword goDirective package import +syn keyword goDeclaration var const type +syn keyword goDeclType struct interface + +hi def link goDirective Statement +hi def link goDeclaration Keyword +hi def link goDeclType Keyword + +" Keywords within functions +syn keyword goStatement defer go goto return break continue fallthrough +syn keyword goConditional if else switch select +syn keyword goLabel case default +syn keyword goRepeat for range + +hi def link goStatement Statement +hi def link goConditional Conditional +hi def link goLabel Label +hi def link goRepeat Repeat + +" Predefined types +syn keyword goType chan map bool string error +syn keyword goSignedInts int int8 int16 int32 int64 rune +syn keyword goUnsignedInts byte uint uint8 uint16 uint32 uint64 uintptr +syn keyword goFloats float32 float64 +syn keyword goComplexes complex64 complex128 + +hi def link goType Type +hi def link goSignedInts Type +hi def link goUnsignedInts Type +hi def link goFloats Type +hi def link goComplexes Type + +" Treat func specially: it's a declaration at the start of a line, but a type +" elsewhere. Order matters here. +syn match goType /\/ +syn match goDeclaration /^func\>/ + +" Predefined functions and values +syn keyword goBuiltins append cap close complex copy delete imag len +syn keyword goBuiltins make new panic print println real recover +syn keyword goConstants iota true false nil + +hi def link goBuiltins Keyword +hi def link goConstants Keyword + +" Comments; their contents +syn keyword goTodo contained TODO FIXME XXX BUG +syn cluster goCommentGroup contains=goTodo +syn region goComment start="/\*" end="\*/" contains=@goCommentGroup,@Spell +syn region goComment start="//" end="$" contains=@goCommentGroup,@Spell + +hi def link goComment Comment +hi def link goTodo Todo + +" Go escapes +syn match goEscapeOctal display contained "\\[0-7]\{3}" +syn match goEscapeC display contained +\\[abfnrtv\\'"]+ +syn match goEscapeX display contained "\\x\x\{2}" +syn match goEscapeU display contained "\\u\x\{4}" +syn match goEscapeBigU display contained "\\U\x\{8}" +syn match goEscapeError display contained +\\[^0-7xuUabfnrtv\\'"]+ + +hi def link goEscapeOctal goSpecialString +hi def link goEscapeC goSpecialString +hi def link goEscapeX goSpecialString +hi def link goEscapeU goSpecialString +hi def link goEscapeBigU goSpecialString +hi def link goSpecialString Special +hi def link goEscapeError Error + +" Strings and their contents +syn cluster goStringGroup contains=goEscapeOctal,goEscapeC,goEscapeX,goEscapeU,goEscapeBigU,goEscapeError +syn region goString start=+"+ skip=+\\\\\|\\"+ end=+"+ contains=@goStringGroup +syn region goRawString start=+`+ end=+`+ + +hi def link goString String +hi def link goRawString String + +" Characters; their contents +syn cluster goCharacterGroup contains=goEscapeOctal,goEscapeC,goEscapeX,goEscapeU,goEscapeBigU +syn region goCharacter start=+'+ skip=+\\\\\|\\'+ end=+'+ contains=@goCharacterGroup + +hi def link goCharacter Character + +" Regions +syn region goBlock start="{" end="}" transparent fold +syn region goParen start='(' end=')' transparent + +" Integers +syn match goDecimalInt "\<\d\+\([Ee]\d\+\)\?\>" +syn match goHexadecimalInt "\<0x\x\+\>" +syn match goOctalInt "\<0\o\+\>" +syn match goOctalError "\<0\o*[89]\d*\>" + +hi def link goDecimalInt Integer +hi def link goHexadecimalInt Integer +hi def link goOctalInt Integer +hi def link Integer Number + +" Floating point +syn match goFloat "\<\d\+\.\d*\([Ee][-+]\d\+\)\?\>" +syn match goFloat "\<\.\d\+\([Ee][-+]\d\+\)\?\>" +syn match goFloat "\<\d\+[Ee][-+]\d\+\>" + +hi def link goFloat Float + +" Imaginary literals +syn match goImaginary "\<\d\+i\>" +syn match goImaginary "\<\d\+\.\d*\([Ee][-+]\d\+\)\?i\>" +syn match goImaginary "\<\.\d\+\([Ee][-+]\d\+\)\?i\>" +syn match goImaginary "\<\d\+[Ee][-+]\d\+i\>" + +hi def link goImaginary Number + +" Spaces after "[]" +if go_highlight_array_whitespace_error != 0 + syn match goSpaceError display "\(\[\]\)\@<=\s\+" +endif + +" Spacing errors around the 'chan' keyword +if go_highlight_chan_whitespace_error != 0 + " receive-only annotation on chan type + syn match goSpaceError display "\(<-\)\@<=\s\+\(chan\>\)\@=" + " send-only annotation on chan type + syn match goSpaceError display "\(\/ + syn match goExtraType /\/ + syn match goExtraType /\/ + syn match goExtraType /\/ +endif + +" Space-tab error +if go_highlight_space_tab_error != 0 + syn match goSpaceError display " \+\t"me=e-1 +endif + +" Trailing white space error +if go_highlight_trailing_whitespace_error != 0 + syn match goSpaceError display excludenl "\s\+$" +endif + +hi def link goExtraType Type +hi def link goSpaceError Error + +" Search backwards for a global declaration to start processing the syntax. +"syn sync match goSync grouphere NONE /^\(const\|var\|type\|func\)\>/ + +" There's a bug in the implementation of grouphere. For now, use the +" following as a more expensive/less precise workaround. +syn sync minlines=500 + +let b:current_syntax = "go" diff --git a/sources_non_forked/vim-golang/syntax/godoc.vim b/sources_non_forked/vim-golang/syntax/godoc.vim new file mode 100644 index 00000000..bd4443f7 --- /dev/null +++ b/sources_non_forked/vim-golang/syntax/godoc.vim @@ -0,0 +1,20 @@ +" Copyright 2011 The Go Authors. All rights reserved. +" Use of this source code is governed by a BSD-style +" license that can be found in the LICENSE file. + +if exists("b:current_syntax") + finish +endif + +syn case match +syn match godocTitle "^\([A-Z][A-Z ]*\)$" + +command -nargs=+ HiLink hi def link + +HiLink godocTitle Title + +delcommand HiLink + +let b:current_syntax = "godoc" + +" vim:ts=4 sts=2 sw=2: diff --git a/sources_non_forked/vim-snipmate/autoload/snipMate.vim b/sources_non_forked/vim-snipmate/autoload/snipMate.vim index 42a5f82e..4e16a923 100644 --- a/sources_non_forked/vim-snipmate/autoload/snipMate.vim +++ b/sources_non_forked/vim-snipmate/autoload/snipMate.vim @@ -640,27 +640,30 @@ fun! snipMate#ScopesByFile() endf " used by both: completion and insert snippet -fun! snipMate#GetSnippetsForWordBelowCursor(word, suffix, break_on_first_match) +fun! snipMate#GetSnippetsForWordBelowCursor(word, exact) " Setup lookups: '1.2.3' becomes [1.2.3] + [3, 2.3] let parts = split(a:word, '\W\zs') if len(parts) > 2 let parts = parts[-2:] " max 2 additional items, this might become a setting endif - let lookups = [a:word.a:suffix] + let lookups = [a:word] let lookup = '' for w in reverse(parts) let lookup = w . lookup if index(lookups, lookup) == -1 - call add(lookups, lookup.a:suffix) + call add(lookups, lookup) endif endfor " allow matching '.' if a:word =~ '\.$' - call add(lookups, '.'.a:suffix) + call add(lookups, '.') endif - call filter(lookups, 'v:val != ""') + " Remove empty lookup entries, but only if there are other nonempty lookups + if len(lookups) > 1 + call filter(lookups, 'v:val != ""') + endif let matching_snippets = [] let snippet = '' @@ -668,12 +671,14 @@ fun! snipMate#GetSnippetsForWordBelowCursor(word, suffix, break_on_first_match) for word in lookups let s:c.word = word for [k,snippetD] in items(funcref#Call(s:c['get_snippets'], [snipMate#ScopesByFile(), word])) - if a:suffix == '' - " hack: require exact match - if k !=# word | continue | endif + " hack: require exact match + if a:exact && k !=# word + continue endif call add(matching_snippets, [k, snippetD]) - if a:break_on_first_match | break| endif + if a:exact + break + endif endfor endfor return matching_snippets @@ -708,7 +713,7 @@ fun! snipMate#WordBelowCursor() endf fun! snipMate#GetSnippetsForWordBelowCursorForComplete(word) - let snippets = map(snipMate#GetSnippetsForWordBelowCursor(a:word, '*', 0), 'v:val[0]') + let snippets = map(snipMate#GetSnippetsForWordBelowCursor(a:word, 0), 'v:val[0]') return filter(snippets, 'v:val =~# "\\V\\^' . escape(a:word, '"\') . '"') endf @@ -769,7 +774,7 @@ function! snipMate#TriggerSnippet(...) endif let word = matchstr(getline('.'), '\S\+\%'.col('.').'c') - let list = snipMate#GetSnippetsForWordBelowCursor(word, '', 1) + let list = snipMate#GetSnippetsForWordBelowCursor(word, 1) if empty(list) let snippet = '' else diff --git a/sources_non_forked/vim-snippets/AUTHORS b/sources_non_forked/vim-snippets/AUTHORS deleted file mode 100644 index c5c68c6a..00000000 --- a/sources_non_forked/vim-snippets/AUTHORS +++ /dev/null @@ -1,45 +0,0 @@ -Aaron Broder -Adam Folmert -Alberto Pose -Angel Alonso -Ben Orenstein -Bill Casarin -Christopher Joslyn -Daniel Hahler -Elliot Murphy -Eustaquio Rangel -Henrik Nyh -Honza Pokorny -Iuri Fernandes Queiroz -Jakub Nawalaniec -James F. Herdman -Jon Bernard -Kozo NISHIDA -Leandro Pincini -Marc Weber -Marcin Kulik -Marjan.Hratson -Micah Elliott -Michael Sanders -Naveed Massjouni -Rob Hudson -Rok Garbas -Sebastian Schulze -Srushti Ambekallu -Stephen Tudor -Steven Oliver -Stuart Colville -Tom Adams -Zied ABID -fo60213 -marutanm -msanders -Povilas Balzaravičius Pawka -Dmitry Dementev -Travis Holton -Chrisyue -Erik Westrup -Matt Deacalion Stevens - -TODO: add contributors from github.com/SirVer/Ultisnip having contributed to -github.com/SirVer/Ultisnip/UltiSnips/* files diff --git a/sources_non_forked/vim-snippets/README.md b/sources_non_forked/vim-snippets/README.md index 64733ebc..7a94766f 100644 --- a/sources_non_forked/vim-snippets/README.md +++ b/sources_non_forked/vim-snippets/README.md @@ -1,5 +1,3 @@ -IMPORTANT: comment on: [What about merging with Ultisnip using its engine](https://github.com/garbas/vim-snipmate/issues/114) - Snipmate & UltiSnip Snippets ============================ @@ -9,51 +7,48 @@ It is community-maintained and many people have contributed snippet files and other improvements already. Contents -======== +-------- - snippets/*: snippets using snipmate format - UltiSnips/*: snippets using UltiSnips format +- `snippets/*`: snippets using snipmate format +- `UltiSnips/*`: snippets using UltiSnips format Snippet engines supporting vim-snippets -======================================== +---------------------------------------- There are different forks of snippet engines which allow the user to insert snippets by typing the name of a snippet hitting the expansion mapping. - github.com/garbas/vim-snipmate: - VimL, snipmate-snippets, engine sometimes behaves strange, supports - rewriting snippets on the fly (eg adding a second version with folding - markers) +- [github.com/SirVer/ultisnips](https://github.com/SirVer/ultisnips): + python, supports all snippets in this repo. +- [github.com/garbas/vim-snipmate](https://github.com/garbas/vim-snipmate): + VimL, snipmate-snippets, engine sometimes behaves strange. Supports + snippets/* +- [github.com/Shougo/neosnippet](https://github.com/Shougo/neosnippet.vim): + VimL, supports snippets/* with some configuration. +- [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 + here for completness) + +There tries to be a more comprehensive list (which still is incomplete) here: +http://vim-wiki.mawercer.de/wiki/topic/text-snippets-skeletons-templates.html - github.com/MarcWeber/UltiSnips: - python, snipmate-snippets and UltiSnips-snippets +UltiSnips has additional features such as high speed, nesting snippets, +expanding snippets in snippets and offers powerful transformations on text in +snippets (like visual selections or placeholder texts). - github.com/SirVer/ultisnips: - python, UltiSnips-snippets - - github.com/Shougo/neosnippet: - viml, has a compatible mode allowing to reuse most snipmate snippets ? - - 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 here for completness) - - This tries to be a more comprehensive list (which still is incomplete) - http://vim-wiki.mawercer.de/wiki/topic/text-snippets-skeletons-templates.html - -UltiSnips engine has additional features such as "nested snippets". - -Which one to use? If you have python give MarcWeber/UltiSnips a try because its -fast and supports all important features. You can prefer the UltiSnip versions -of the snippets by setting the "always_use_first_snippet" option to 1. +Which one to use? If you have python give +[SirVer/ultisnips](https://github.com/SirVer/ultisnips) a try because its fast +and has the most features. If you have VimL only (vim without python support) your best option is using -garbas/vim-snipmate and cope with the minor bugs found in the engine. +[garbas/vim-snipmate](https://github.com/garbas/vim-snipmate) and cope with the +minor bugs found in the engine. Installation -============ +------------ + First be aware that there are many options, see "Snippet engines" above. Second be aware than there are [tons of plugin managers](http://vim-wiki.mawercer.de/wiki/topic/vim%20plugin%20managment.html) which is why Marc Weber thinks that it doesn't make sense to repeat the same @@ -84,7 +79,8 @@ If you still have trouble getting this to work create a github ticket, ask on irc or the mailinglist. Policies / for contributors -=========================== +--------------------------- + Some snippets are useful for almost all languages, so let's try to have the same triggers for them: @@ -96,11 +92,7 @@ el : else .. wh : while (cond) ... ``` -If you're not satisfied with these defaults, open a ticket that we implement -aliasing. Then you can remap "else" to "el" or the like. - - -Don't add stupid placeholder default texts like +Don't add useless placeholder default texts like ``` if (${1:condition}){ ${2:some code here} @@ -127,7 +119,7 @@ Discuss at: https://github.com/honza/vim-snippets/issues/230 Related repositories -==================== +-------------------- We also encourage people to maintain sets of snippets for particular use cases so that all users can benefit from them. People can list their snippet repositories here: @@ -138,15 +130,15 @@ so that all users can benefit from them. People can list their snippet reposito Installation using VAM: "github:rbonvall/snipmate-snippets-bib" - Future - ideas - examples -========================= +------------------------- + [overview snippet engines](http://vim-wiki.mawercer.de/wiki/topic/text-snippets-skeletons-templates.html) If you have ideas you can add them to that list of "snippet engine features by example". Historical notes -================ +---------------- [vim-snipmate][1] was originally started by [Michael Sanders][2] who has now unfortunately abandoned the project. [Rok Garbas][3] is now maintaining a @@ -170,17 +162,6 @@ let g:snipMate.scope_aliases = {} let g:snipMate.scope_aliases['ruby'] = 'ruby,ruby-rails,ruby-1.9' ``` -or github.com/MarcWeber/UltiSnips this way: - - -```vim -let g:UltiSnips = {} - -let g:UltiSnips.snipmate_ft_filter = { - \ 'default' : {'filetypes': ["FILETYPE"] }, - \ 'ruby' : {'filetypes': ["ruby", "ruby-rails", "ruby-1.9"] }, -``` - If it happens that you work on a project requiring ruby-1.8 snippets instead, consider using vim-addon-local-vimrc and override the filetypes. @@ -192,16 +173,15 @@ ruby-library-version triplet. Sometimes postfixing a name such as will do it then if syntax has changed. + Language maintainers -------------------- No one can really be proficient in all programming languages. If you would like to maintain snippets for a language, please get in touch. -Notes: People are interested in snippets - and their interest may stop again -at will. So its ok if people maintain a language only for a short period of -time - or jump in and get things done - don't let the flow stop :) -vim-snippets is not like the "linux kernel". +Notes: People are interested in snippets - and their interest may wane again. +This list is kept up-to-date on a best effort basis. * Python - [honza](http://github.com/honza) * Javascript - [honza](http://github.com/honza) @@ -220,18 +200,13 @@ Until further work is done on `vim-snipmate`, please don't add folding markers into snippets. `vim-snipmate` has some comments about how to patch all snippets on the fly adding those. -Because MarcWeber/UltiSnips [6] supports also snipmate-snippets there is no -need to duplicate all snippets - only those snippets who use advanced UltiSnips -features should be duplicated in UltiSnips (?) +Because UltiSnips reads snipmate-snippets too there is no need to duplicate all +snippets - only those snippets who use advanced UltiSnips features should be +duplicated in UltiSnips. Currently all snippets from UltiSnips have been put into UltiSnips - some work on merging should be done (dropping duplicates etc) -Authors -------- - -For a list of authors, please see the `AUTHORS` files. - License ------- @@ -243,5 +218,4 @@ terms of the MIT license. [2]: http://github.com/msanders [3]: http://github.com/garbas [4]: http://github.com/garbas/vim-snipmate -[6]: http://github.com/MarcWeber/UltiSnips [7]: http://github.com/SirVer/ultisnips diff --git a/sources_non_forked/vim-snippets/UltiSnips/README b/sources_non_forked/vim-snippets/UltiSnips/README index eafd0866..41d85923 100644 --- a/sources_non_forked/vim-snippets/UltiSnips/README +++ b/sources_non_forked/vim-snippets/UltiSnips/README @@ -1,4 +1,5 @@ -This directory contains the main scripts that come bundled with UltiSnips. +This directory contains the snippets for UltiSnips. +https://github.com/sirver/ultisnips Standing On The Shoulders of Giants =================================== @@ -10,12 +11,7 @@ two projects: TextMate: http://svn.textmate.org/trunk/Bundles/ SnipMate: http://code.google.com/p/snipmate/ -All snippets from those sources were copied and cleaned up, so that they are - - not using shell script, only python (so they are cross platform compatible) - - not using any feature that UltiSnips doesn't offer - -UltiSnips has seen contributions by various individuals. Those contributions -have been merged into this collection seamlessly and without further comments. +UltiSnips has seen contributions by many individuals. Those contributions have +been merged into this collection seamlessly and without further comments. -- vim:ft=rst:nospell: - diff --git a/sources_non_forked/vim-snippets/UltiSnips/all.snippets b/sources_non_forked/vim-snippets/UltiSnips/all.snippets index 8844e281..532010e7 100644 --- a/sources_non_forked/vim-snippets/UltiSnips/all.snippets +++ b/sources_non_forked/vim-snippets/UltiSnips/all.snippets @@ -1,6 +1,11 @@ # This file contains snippets that are always defined. I personally # have snippets for signatures and often needed texts +# sligthly lower priority than everything else since specialized versions +# should overwrite. The user needs to adjust her priority in her snippets to +# ~-55 so that other filetypes will still overwrite. +priority -60 + ############## # NICE BOXES # ############## @@ -12,71 +17,62 @@ Automatically filled during usage""" _commentDict = { } def _parse_comments(s): - """ Parses vim's comments option to extract comment format """ - i = iter(s.split(",")) + """ Parses vim's comments option to extract comment format """ + i = iter(s.split(",")) - rv = [] - try: - while True: - # get the flags and text of a comment part - flags,text = i.next().split(':', 1) + rv = [] + try: + while True: + # get the flags and text of a comment part + flags, text = next(i).split(':', 1) - if len(flags) == 0: - if len(text) == 1: - rv.append((text,text,text, "")) - # parse 3-part comment, but ignore those with O flag - elif flags[0] == 's' and 'O' not in flags: - ctriple = [] - indent = "" + if len(flags) == 0: + rv.append((text, text, text, "")) + # parse 3-part comment, but ignore those with O flag + elif flags[0] == 's' and 'O' not in flags: + ctriple = [] + indent = "" - if flags[-1] in string.digits: - indent = " " * int(flags[-1]) - ctriple.append(text) + if flags[-1] in string.digits: + indent = " " * int(flags[-1]) + ctriple.append(text) - flags,text = i.next().split(':', 1) - assert(flags[0] == 'm') - ctriple.append(text) + flags,text = next(i).split(':', 1) + assert(flags[0] == 'm') + ctriple.append(text) - flags,text = i.next().split(':', 1) - assert(flags[0] == 'e') - ctriple.append(text) - ctriple.append(indent) + flags,text = next(i).split(':', 1) + assert(flags[0] == 'e') + ctriple.append(text) + ctriple.append(indent) - rv.append(ctriple) - - elif flags[0] == 'b': - if len(text) == 1: - rv.insert(0, (text,text,text, "")) - - except StopIteration: - return rv + rv.append(ctriple) + elif flags[0] == 'b': + if len(text) == 1: + rv.insert(0, (text,text,text, "")) + except StopIteration: + return rv def _get_comment_format(): - """ Returns a 4-element tuple representing the comment format for - the current file. """ - - ft = vim.eval("&filetype") - # check if the comment dict has the format for the current file - if _commentDict.has_key(ft): - return _commentDict[ft] - - # otherwise parse vim's comments and add it for later use - commentformat = _parse_comments(vim.eval("&comments"))[0] - _commentDict[ft] = commentformat - - return commentformat + """ Returns a 4-element tuple representing the comment format for + the current file. """ + return _parse_comments(vim.eval("&comments"))[0] -def make_box(twidth, bwidth = None): - if bwidth is None: - bwidth = twidth + 2 - b,m,e,i = _get_comment_format() - sline = b + m + bwidth*m + 2*m - nspaces = (bwidth - twidth)//2 - mlines = i + m + " " + " "*nspaces - mlinee = " " + " "*(bwidth-twidth-nspaces) + m - eline = i + 2*m + bwidth*m + m + e - return sline, mlines, mlinee, eline +def make_box(twidth, bwidth=None): + b, m, e, i = _get_comment_format() + bwidth_inner = bwidth - 3 - max(len(b), len(i + e)) if bwidth else twidth + 2 + sline = b + m + bwidth_inner * m[0] + 2 * m[0] + nspaces = (bwidth_inner - twidth) // 2 + mlines = i + m + " " + " " * nspaces + mlinee = " " + " "*(bwidth_inner - twidth - nspaces) + m + eline = i + m + bwidth_inner * m[0] + 2 * m[0] + e + return sline, mlines, mlinee, eline + +def foldmarker(): + "Return a tuple of (open fold marker, close fold marker)" + return vim.eval("&foldmarker").split(",") + endglobal snippet box "A nice box with the current comment symbol" b @@ -91,14 +87,29 @@ endsnippet snippet bbox "A nice box over the full width" b `!p -box = make_box(len(t[1]), 71) +width = int(vim.eval("&textwidth")) or 71 +box = make_box(len(t[1]), width) snip.rv = box[0] + '\n' + box[1] `${1:content}`!p -box = make_box(len(t[1]), 71) +box = make_box(len(t[1]), width) snip.rv = box[2] + '\n' + box[3]` $0 endsnippet +snippet fold "Insert a vim fold marker" b +`!p snip.rv = _get_comment_format()[0]` ${1:Fold description} `!p snip.rv = foldmarker()[0]`${2:1} `!p snip.rv = _get_comment_format()[2]` +endsnippet + +snippet foldc "Insert a vim fold close marker" b +`!p snip.rv = _get_comment_format()[0]` ${2:1}`!p snip.rv = foldmarker()[1]` `!p snip.rv = _get_comment_format()[2]` +endsnippet + +snippet foldp "Insert a vim fold marker pair" b +`!p snip.rv = _get_comment_format()[0]` ${1:Fold description} `!p snip.rv = foldmarker()[0]` `!p snip.rv = _get_comment_format()[2]` +${2:${VISUAL:Content}} +`!p snip.rv = _get_comment_format()[0]` `!p snip.rv = foldmarker()[1]` $1 `!p snip.rv = _get_comment_format()[2]` +endsnippet + ########################## # LOREM IPSUM GENERATORS # ########################## diff --git a/sources_non_forked/vim-snippets/UltiSnips/bib.snippets b/sources_non_forked/vim-snippets/UltiSnips/bib.snippets new file mode 100644 index 00000000..c9b8df5c --- /dev/null +++ b/sources_non_forked/vim-snippets/UltiSnips/bib.snippets @@ -0,0 +1,52 @@ +priority -50 + +snippet online "Online resource" b +@online{${1:name}, + author={${2:author}}, + title={${3:title}}, + date={${4:date}}, + url={${5:url}} +} +$0 +endsnippet + +snippet article "Article reference" b +@article{${1:name}, + author={${2:author}}, + title={${3:title}}, + journaltitle={${4:journal}}, + volume={${5:NN}}, + number={${6:NN}}, + year={${7:YYYY}}, + pages={${8:NN}--${9:NN}} +} +$0 +endsnippet + +snippet book "Book reference" b +@book{${1:name}, + author={${2:author}}, + title={${3:title}}, + subtitle={${4:subtitle}}, + year={${5:YYYY}}, + location={${6:somewhere}}, + publisher={${7:publisher}}, + pages={${8:NN}--${9:NN}} +} +$0 +endsnippet + +snippet inb "In Book reference" b +@inbook{${1:name}, + author={${2:author}}, + title={${3:title}}, + subtitle={${4:subtitle}}, + booktitle={${5:book}}, + editor={${6:editor}}, + year={${7:YYYY}}, + location={${8:somewhere}}, + publisher={${9:publisher}}, + pages={${10:NN}--${11:NN}} +} +$0 +endsnippet diff --git a/sources_non_forked/vim-snippets/UltiSnips/bindzone.snippets b/sources_non_forked/vim-snippets/UltiSnips/bindzone.snippets index 034ccdec..b8ab0dfd 100644 --- a/sources_non_forked/vim-snippets/UltiSnips/bindzone.snippets +++ b/sources_non_forked/vim-snippets/UltiSnips/bindzone.snippets @@ -1,27 +1,29 @@ +priority -50 + global !p def newsoa(): - import datetime - now = datetime.datetime.now() - # return standard SOA formatted serial for today - return now.strftime("%Y%m%d00") + import datetime + now = datetime.datetime.now() + # return standard SOA formatted serial for today + return now.strftime("%Y%m%d00") endglobal snippet zone "Bootstrap a new Bind zonefile" b $TTL 86400 -@ IN SOA ${1:example.net}. ${2:hostmaster.$1}.( - `!p snip.rv = newsoa()`; serial - 21600; refresh every 6 hours - 3600; retry after one hour - 604800; expire after a week - 86400 ); minimum TTL of 1 day +@ IN SOA ${1:example.net}. ${2:hostmaster.$1}.( + `!p snip.rv = newsoa()`; serial + 21600; refresh every 6 hours + 3600; retry after one hour + 604800; expire after a week + 86400 ); minimum TTL of 1 day - IN NS ns01.$1. - IN MX 10 mail.$1. + IN NS ns01.$1. + IN MX 10 mail.$1. -ns01.$1 IN A -mail.$1 IN A +ns01.$1 IN A +mail.$1 IN A endsnippet snippet A "Insert A Record" b -${1:hostname} IN A ${2:ip} +${1:hostname} IN A ${2:ip} endsnippet diff --git a/sources_non_forked/vim-snippets/UltiSnips/c.snippets b/sources_non_forked/vim-snippets/UltiSnips/c.snippets index 062a36ae..5b8eae84 100644 --- a/sources_non_forked/vim-snippets/UltiSnips/c.snippets +++ b/sources_non_forked/vim-snippets/UltiSnips/c.snippets @@ -2,6 +2,8 @@ # TextMate Snippets # ########################################################################### +priority -50 + snippet def "#define ..." #define ${1} endsnippet @@ -12,9 +14,9 @@ snippet ifndef "#ifndef ... #define ... #endif" #endif endsnippet -snippet #if "#if #endif" !b +snippet #if "#if #endif" b #if ${1:0} -${VISUAL:code}$0 +${VISUAL}${0:${VISUAL/(.*)/(?1::code)/}} #endif endsnippet @@ -36,17 +38,24 @@ $0 endsnippet snippet main "main() (main)" -int main(int argc, char const *argv[]) +int main(int argc, char *argv[]) { - ${0:/* code */} + ${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}} return 0; } endsnippet -snippet for "for int loop (fori)" -for (${4:size_t} ${2:i} = 0; $2 < ${1:count}; ${3:++$2}) +snippet for "for loop (for)" +for (${2:i} = 0; $2 < ${1:count}; ${3:++$2}) { - ${0:/* code */} + ${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}} +} +endsnippet + +snippet fori "for int loop (fori)" +for (${4:int} ${2:i} = 0; $2 < ${1:count}; ${3:++$2}) +{ + ${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}} } endsnippet @@ -62,7 +71,7 @@ if not snip.c: rand = ''.join(random.sample(string.ascii_letters+string.digits, 8)) snip.rv = ('%s_%s' % (name,rand)).upper() else: - snip.rv = snip.c`} + snip.rv = snip.c`} #define $1 ${0} @@ -75,9 +84,15 @@ snippet td "Typedef" typedef ${1:int} ${2:MyCustomType}; endsnippet +snippet wh "while loop" +while(${1:/* condition */}) { + ${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}} +} +endsnippet + snippet do "do...while loop (do)" do { - ${0:/* code */} + ${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}} } while(${1:/* condition */}); endsnippet @@ -88,18 +103,30 @@ endsnippet snippet if "if .. (if)" if (${1:/* condition */}) { - ${0:/* code */} + ${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}} +} +endsnippet + +snippet el "else .. (else)" +else { + ${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}} +} +endsnippet + +snippet eli "else if .. (eli)" +else if (${1:/* condition */}) { + ${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}} } endsnippet snippet ife "if .. else (ife)" if (${1:/* condition */}) { - ${2:/* code */} + ${2:/* code */} } else { - ${3:/* else */} + ${3:/* else */} } endsnippet @@ -114,4 +141,15 @@ struct ${1:`!p snip.rv = (snip.basename or "name") + "_t"`} }; endsnippet +snippet fun "function" b +${1:void} ${2:function_name}(${3}) +{ + ${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}} +} +endsnippet + +snippet fund "function declaration" b +${1:void} ${2:function_name}(${3}); +endsnippet + # vim:ft=snippets: diff --git a/sources_non_forked/vim-snippets/UltiSnips/coffee.snippets b/sources_non_forked/vim-snippets/UltiSnips/coffee.snippets index 68d40349..467b2b57 100644 --- a/sources_non_forked/vim-snippets/UltiSnips/coffee.snippets +++ b/sources_non_forked/vim-snippets/UltiSnips/coffee.snippets @@ -1,5 +1,4 @@ -# From the TextMate bundle -# with some modification +priority -50 snippet fun "Function" b ${1:name} = `!p snip.rv = "(" if t[2] else ""`${2:args}`!p snip.rv = ") " if t[2] else ""`-> @@ -10,52 +9,52 @@ snippet bfun "Function (bound)" i `!p snip.rv = "(" if t[1] else ""`${1:args}`!p snip.rv = ") " if t[1] else ""`=>`!p snip.rv = " " if t[2] and not t[2].startswith("\n") else ""`${2:expr} endsnippet -snippet if "If" +snippet if "If" b if ${1:condition} ${0:# body...} endsnippet -snippet ife "If .. Else" +snippet ife "If .. Else" b if ${1:condition} ${2:# body...} else ${3:# body...} endsnippet -snippet eif "Else if" b +snippet elif "Else if" b else if ${1:condition} ${0:# body...} endsnippet -snippet ifte "Ternary if" +snippet ifte "Ternary if" b if ${1:condition} then ${2:value} else ${3:other} endsnippet -snippet unl "Unless" +snippet unl "Unless" b ${1:action} unless ${2:condition} endsnippet -snippet fora "Array Comprehension" +snippet fora "Array Comprehension" b for ${1:name} in ${2:array} ${0:# body...} endsnippet -snippet foro "Object Comprehension" +snippet foro "Object Comprehension" b for ${1:key}, ${2:value} of ${3:Object} ${0:# body...} endsnippet -snippet forr "Range Comprehension (inclusive)" +snippet forr "Range Comprehension (inclusive)" b for ${1:name} in [${2:start}..${3:finish}]`!p snip.rv = " by " if t[4] else ""`${4:step} ${0:# body...} endsnippet -snippet forrex "Range Comprehension (exclusive)" +snippet forrex "Range Comprehension (exclusive)" b for ${1:name} in [${2:start}...${3:finish}]`!p snip.rv = " by " if t[4] else ""`${4:step} ${0:# body...} endsnippet -snippet swi "Switch" +snippet swi "Switch" b switch ${1:object} when ${2:value} ${3:# body...} @@ -63,7 +62,7 @@ switch ${1:object} $0 endsnippet -snippet swit "Switch when .. then" +snippet swit "Switch when .. then" b switch ${1:object} when ${2:condition}`!p snip.rv = " then " if t[3] else ""`${3:value} else`!p snip.rv = " " if t[4] and not t[4].startswith("\n") else ""`${4:value} @@ -77,7 +76,7 @@ class ${1:ClassName}`!p snip.rv = " extends " if t[2] else ""`${2:Ancestor} $0 endsnippet -snippet try "Try .. Catch" +snippet try "Try .. Catch" b try $1 catch ${2:error} @@ -95,4 +94,3 @@ endsnippet snippet log "Log" b console.log ${1:"${2:msg}"} endsnippet - diff --git a/sources_non_forked/vim-snippets/UltiSnips/coffee_jasmine.snippets b/sources_non_forked/vim-snippets/UltiSnips/coffee_jasmine.snippets index 47d1e6b5..0dd35cd6 100644 --- a/sources_non_forked/vim-snippets/UltiSnips/coffee_jasmine.snippets +++ b/sources_non_forked/vim-snippets/UltiSnips/coffee_jasmine.snippets @@ -2,8 +2,12 @@ # CoffeeScript versions -- adapted from the JS TextMate bundle + additions # for some jasmine-jquery matchers # +priority -50 + extends coffee +priority -49 + snippet des "Describe (coffee)" b describe '${1:description}', -> $0 @@ -160,4 +164,3 @@ endsnippet snippet noscw "expect was not called with (coffee)" b expect(${1:target}).wasNotCalledWith(${2:arguments}) endsnippet - diff --git a/sources_non_forked/vim-snippets/UltiSnips/cpp.snippets b/sources_non_forked/vim-snippets/UltiSnips/cpp.snippets index 6999c1f9..3d79a64e 100644 --- a/sources_non_forked/vim-snippets/UltiSnips/cpp.snippets +++ b/sources_non_forked/vim-snippets/UltiSnips/cpp.snippets @@ -1,3 +1,10 @@ +priority -50 + +extends c + +# We want to overwrite everything in parent ft. +priority -49 + ########################################################################### # TextMate Snippets # ########################################################################### @@ -20,7 +27,7 @@ endsnippet snippet ns "namespace .. (namespace)" namespace${1/.+/ /m}${1:`!p snip.rv = snip.basename or "name"`} { - $0 + ${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}} }${1/.+/ \/* /m}$1${1/.+/ *\/ /m} endsnippet diff --git a/sources_non_forked/vim-snippets/UltiSnips/cs.snippets b/sources_non_forked/vim-snippets/UltiSnips/cs.snippets new file mode 100644 index 00000000..aca245e5 --- /dev/null +++ b/sources_non_forked/vim-snippets/UltiSnips/cs.snippets @@ -0,0 +1,328 @@ +####################################################################### +# C# Snippets for UltiSnips # +####################################################################### + +priority -50 + +######################### +# classes and structs # +######################### + +snippet namespace "namespace" b +namespace ${1:MyNamespace} +{ + ${VISUAL}$0 +} +endsnippet + +snippet class "class" w +class ${1:MyClass} +{ + $0 +} +endsnippet + +snippet struct "struct" w +struct ${1:MyStruct} +{ + $0 +} +endsnippet + +snippet interface "interface" w +interface I${1:Interface} +{ + $0 +} +endsnippet + +snippet enum "enumeration" b +enum ${1:MyEnum} { ${2:Item} }; +endsnippet + + +############ +# Main() # +############ + +snippet sim "static int main" b +static int Main(string[] args) +{ + $0 +} +endsnippet + +snippet svm "static void main" b +static void Main(string[] args) +{ + $0 +} +endsnippet + + +################ +# properties # +################ + +snippet prop "Simple property declaration" b +public ${1:int} ${2:MyProperty} { get; set; } +endsnippet + +snippet propfull "Full property declaration" b +private ${1:int} ${2:_myProperty}; + +public $1 ${3:MyProperty} +{ + get { return $2; } + set { $2 = value; } +} +endsnippet + +snippet propg "Property with a private setter" b +public ${1:int} ${2:MyProperty} { get; private set; } +endsnippet + + +############ +# blocks # +############ + +snippet #if "#if #endif" b +#if ${1:DEBUG} +${VISUAL}$0 +#endif +endsnippet + +snippet #region "#region #endregion" b +#region ${1:Region} +${VISUAL}$0 +#endregion +endsnippet + + +########### +# loops # +########### + +snippet for "for loop" b +for (int ${1:i} = 0; $1 < ${2:10}; $1++) +{ + ${VISUAL}$0 +} +endsnippet + +snippet forr "for loop (reverse)" b +for (int ${1:i} = ${2:10}; $1 >= 0; $1--) +{ + ${VISUAL}$0 +} +endsnippet + +snippet foreach "foreach loop" b +foreach (${3:var} ${2:item} in ${1:items}) +{ + ${VISUAL}$0 +} +endsnippet + +snippet while "while loop" b +while (${1:true}) +{ + ${VISUAL}$0 +} +endsnippet + +snippet do "do loop" b +do +{ + ${VISUAL}$0 +} while (${1:true}); +endsnippet + + +############### +# branching # +############### + +snippet if "if statement" b +if ($1) +{ + ${VISUAL}$0 +} +endsnippet + +snippet ife "if else statement" b +if ($1) +{ + ${VISUAL}$0 +} +else +{ +} +endsnippet + +snippet elif "else if" b +else if ($1) +{ + $0 +} +endsnippet + +snippet elseif "else if" b +else if ($1) +{ + $0 +} +endsnippet + +snippet ifnn "if not null" b +if ($1 != null) +{ + ${VISUAL}$0 +} +endsnippet + +snippet switch "switch statement" b +switch (${1:statement}) +{ + case ${2:value}: + break; + + default: + $0break; +} +endsnippet + +snippet case "case" b +case ${1:value}: + $2 + break; +endsnippet + + +############## +# wrappers # +############## + +snippet using "using statement" b +using (${1:resource}) +{ + ${VISUAL}$0 +} +endsnippet + +snippet unchecked "unchecked block" b +unchecked +{ + ${VISUAL}$0 +} +endsnippet + +snippet checked "checked block" b +checked +{ + ${VISUAL}$0 +} +endsnippet + +snippet unsafe "unsafe" b +unsafe +{ + ${VISUAL}$0 +} +endsnippet + + +######################## +# exception handling # +######################## + +snippet try "try catch block" b +try +{ + ${VISUAL}$0 +} +catch (${1:Exception} ${2:e}) +{ + throw; +} +endsnippet + +snippet tryf "try finally block" b +try +{ + ${VISUAL}$0 +} +finally +{ +} +endsnippet + +snippet throw "throw" +throw new ${1}Exception("${2}"); +endsnippet + + +########## +# LINQ # +########## + +snippet from "LINQ syntax" b +var ${1:seq} = + from ${2:item1} in ${3:items1} + join ${4:item2} in ${5:items2} on $2.${6:prop1} equals $4.${7:prop2} + select ${8:$2.prop3} + where ${9:clause} +endsnippet + + +############################ +# feedback and debugging # +############################ + +snippet da "Debug.Assert" b +Debug.Assert(${1:true}); +endsnippet + +snippet cw "Console.WriteLine" b +Console.WriteLine("$1"); +endsnippet + +# as you first type comma-separated parameters on the right, {n} values appear in the format string +snippet cwp "Console.WriteLine with parameters" b +Console.WriteLine("${2:`!p +snip.rv = ' '.join(['{' + str(i) + '}' for i in range(t[1].count(','))]) +`}"${1:, something}); +endsnippet + +snippet mbox "Message box" b +MessageBox.Show("${1:message}"); +endsnippet + + +################## +# full methods # +################## + +snippet equals "Equals method" b +public override bool Equals(object obj) +{ + if (obj == null || GetType() != obj.GetType()) + { + return false; + } + $0 + return base.Equals(obj); +} +endsnippet + + +############## +# comments # +############## + +snippet /// "XML comment" b +/// +/// $1 +/// +endsnippet diff --git a/sources_non_forked/vim-snippets/UltiSnips/css.snippets b/sources_non_forked/vim-snippets/UltiSnips/css.snippets index d14d51c0..32c3f217 100644 --- a/sources_non_forked/vim-snippets/UltiSnips/css.snippets +++ b/sources_non_forked/vim-snippets/UltiSnips/css.snippets @@ -2,6 +2,8 @@ # Most of these came from TextMate # ########################################################################### +priority -50 + snippet ! "!important CSS (!)" ${1:!important} endsnippet diff --git a/sources_non_forked/vim-snippets/UltiSnips/d.snippets b/sources_non_forked/vim-snippets/UltiSnips/d.snippets index 7f38c6d8..99da292e 100644 --- a/sources_non_forked/vim-snippets/UltiSnips/d.snippets +++ b/sources_non_forked/vim-snippets/UltiSnips/d.snippets @@ -1,5 +1,7 @@ # Simple shortcuts +priority -50 + snippet imp "import (imp)" b import ${1:std.stdio}; endsnippet @@ -42,22 +44,22 @@ endsnippet snippet pub "public (pub)" b public: - ${1:/*members*/} + ${1:/*members*/} endsnippet snippet priv "private (priv)" b private: - ${1:/*members*/} + ${1:/*members*/} endsnippet snippet prot "protected (prot)" b protected: - ${1:/*members*/} + ${1:/*members*/} endsnippet snippet pack "package (pack)" b package: - ${1:/*members*/} + ${1:/*members*/} endsnippet snippet ret "return (ret)" @@ -96,7 +98,7 @@ endsnippet snippet enf "enforce (enf)" b enforce(${1:/*condition*/}, - new ${2}Exception(${3:/*args*/})); + new ${2}Exception(${3:/*args*/})); endsnippet # Branches @@ -104,67 +106,67 @@ endsnippet snippet if "if .. (if)" if(${1:/*condition*/}) { - ${VISUAL}${0:/*code*/} + ${VISUAL}${0:/*code*/} } endsnippet snippet ife "if .. else (ife)" b if(${1:/*condition*/}) { - ${2:/*code*/} + ${2:/*code*/} } else { - ${3:/*else*/} + ${3:/*else*/} } endsnippet snippet el "else (el)" b else { - ${VISUAL}${1:/*code*/} + ${VISUAL}${1:/*code*/} } endsnippet -snippet eif "else if (elif)" b +snippet elif "else if (elif)" b else if(${1:/*condition*/}) { - ${VISUAL}${0:/*code*/} + ${VISUAL}${0:/*code*/} } endsnippet snippet sw "switch (sw)" switch(${1:/*var*/}) { - case ${2:/*value*/}: - ${3:/*code*/} - break; - case ${4:/*value*/}: - ${5:/*code*/} - break; - ${7:/*more cases*/} - default: - ${6:assert(false);} + case ${2:/*value*/}: + ${3:/*code*/} + break; + case ${4:/*value*/}: + ${5:/*code*/} + break; + ${7:/*more cases*/} + default: + ${6:assert(false);} } endsnippet snippet fsw "final switch (fsw)" switch(${1:/*var*/}) { - case ${2:/*value*/}: - ${3:/*code*/} - break; - case ${4:/*value*/}: - ${5:/*code*/} - break; - ${7:/*more cases*/} + case ${2:/*value*/}: + ${3:/*code*/} + break; + case ${4:/*value*/}: + ${5:/*code*/} + break; + ${7:/*more cases*/} } endsnippet snippet case "case (case)" b case ${1:/*value*/}: - ${2:/*code*/} - break; + ${2:/*code*/} + break; endsnippet snippet ?: "ternary operator (?:)" @@ -176,42 +178,42 @@ endsnippet snippet do "do while (do)" b do { - ${VISUAL}${2:/*code*/} + ${VISUAL}${2:/*code*/} } while(${1:/*condition*/}); endsnippet snippet wh "while (wh)" b while(${1:/*condition*/}) { - ${VISUAL}${2:/*code*/} + ${VISUAL}${2:/*code*/} } endsnippet snippet for "for (for)" b for (${4:size_t} ${2:i} = 0; $2 < ${1:count}; ${3:++$2}) { - ${VISUAL}${0:/*code*/} + ${VISUAL}${0:/*code*/} } endsnippet snippet forever "forever (forever)" b for(;;) { - ${VISUAL}${0:/*code*/} + ${VISUAL}${0:/*code*/} } endsnippet snippet fore "foreach (fore)" foreach(${1:/*elem*/}; ${2:/*range*/}) { - ${VISUAL}${3:/*code*/} + ${VISUAL}${3:/*code*/} } endsnippet snippet forif "foreach if (forif)" b foreach(${1:/*elem*/}; ${2:/*range*/}) if(${3:/*condition*/}) { - ${VISUAL}${4:/*code*/} + ${VISUAL}${4:/*code*/} } endsnippet @@ -219,8 +221,8 @@ endsnippet snippet in "in contract (in)" b in { - assert(${1:/*condition*/}, "${2:error message}"); - ${3} + assert(${1:/*condition*/}, "${2:error message}"); + ${3} } body endsnippet @@ -228,8 +230,8 @@ endsnippet snippet out "out contract (out)" b out${1:(result)} { - assert(${2:/*condition*/}, "${3:error message}"); - ${4} + assert(${2:/*condition*/}, "${3:error message}"); + ${4} } body endsnippet @@ -237,8 +239,8 @@ endsnippet snippet inv "invariant (inv)" b invariant() { - assert(${1:/*condition*/}, "${2:error message}"); - ${3} + assert(${1:/*condition*/}, "${2:error message}"); + ${3} } endsnippet @@ -247,29 +249,29 @@ endsnippet snippet fun "function definition (fun)" ${1:void} ${2:/*function name*/}(${3:/*args*/}) ${4:@safe pure nothrow} { - ${VISUAL}${5:/*code*/} + ${VISUAL}${5:/*code*/} } endsnippet snippet void "void function definition (void)" void ${1:/*function name*/}(${2:/*args*/}) ${3:@safe pure nothrow} { - ${VISUAL}${4:/*code*/} + ${VISUAL}${4:/*code*/} } endsnippet snippet this "ctor (this)" w this(${1:/*args*/}) { - ${VISUAL}${2:/*code*/} + ${VISUAL}${2:/*code*/} } endsnippet -snippet get "getter property (get)" ! +snippet get "getter property (get)" @property ${1:/*type*/} ${2:/*member_name*/}() const pure nothrow {return ${3:$2_};} endsnippet -snippet set "setter property (set)" ! +snippet set "setter property (set)" @property void ${1:/*member_name*/}(${2:/*type*/} rhs) pure nothrow {${3:$1_} = rhs;} endsnippet @@ -278,7 +280,7 @@ endsnippet snippet main "Main" b void main(string[] args) { - ${VISUAL}${0: /*code*/} + ${VISUAL}${0: /*code*/} } endsnippet @@ -293,7 +295,7 @@ endsnippet snippet scope "scope (scope)" b scope(${1:exit}) { - ${VISUAL}${2:/*code*/} + ${VISUAL}${2:/*code*/} } endsnippet @@ -302,7 +304,7 @@ endsnippet snippet with "with (with)" with(${1}) { - ${VISUAL}${2:/*code*/} + ${VISUAL}${2:/*code*/} } endsnippet @@ -311,33 +313,33 @@ endsnippet snippet try "try/catch (try)" b try { - ${VISUAL}${1:/*code to try*/} + ${VISUAL}${1:/*code to try*/} } catch(${2}Exception e) { - ${3:/*handle exception*/} + ${3:/*handle exception*/} } endsnippet snippet tryf "try/catch/finally (tryf)" b try { - ${VISUAL}${1:/*code to try*/} + ${VISUAL}${1:/*code to try*/} } catch(${2}Exception e) { - ${3:/*handle exception*/} + ${3:/*handle exception*/} } finally { - ${4:/*cleanup*/} + ${4:/*cleanup*/} } endsnippet snippet catch "catch (catch)" b catch(${1}Exception e) { - ${2:/*handle exception*/} + ${2:/*handle exception*/} } endsnippet @@ -351,35 +353,35 @@ endsnippet snippet struct "struct (struct)" struct ${1:`!p snip.rv = (snip.basename or "name")`} { - ${2} + ${2} } endsnippet snippet union "union (union)" union ${1:`!p snip.rv = (snip.basename or "name")`} { - ${2} + ${2} } endsnippet snippet class "class (class)" class ${1:`!p snip.rv = (snip.basename or "name")`} { - ${2} + ${2} } endsnippet snippet inter "interface (inter)" interface ${1:`!p snip.rv = (snip.basename or "name")`} { - ${2} + ${2} } endsnippet snippet enum "enum (enum)" enum ${1:`!p snip.rv = (snip.basename or "name")`} { - ${2} + ${2} } endsnippet @@ -388,12 +390,12 @@ endsnippet snippet exc "exception declaration (exc)" b /// ${3:/*documentation*/} -class ${1}Exception : ${2}Exception +class ${1}Exception : ${2}Exception { - public this(string msg, string file = __FILE__, int line = __LINE__) - { - super(msg, file, line); - } + public this(string msg, string file = __FILE__, int line = __LINE__) + { + super(msg, file, line); + } } endsnippet @@ -403,14 +405,14 @@ endsnippet snippet version "version (version)" b version(${1:/*version name*/}) { - ${VISUAL}${2:/*code*/} + ${VISUAL}${2:/*code*/} } endsnippet snippet debug "debug" b debug { - ${VISUAL}${1:/*code*/} + ${VISUAL}${1:/*code*/} } endsnippet @@ -420,7 +422,7 @@ endsnippet snippet temp "template (temp)" b template ${2:/*name*/}(${1:/*args*/}) { - ${3:/*code*/} + ${3:/*code*/} } endsnippet @@ -438,7 +440,7 @@ endsnippet snippet unittest "unittest (unittest)" b unittest { - ${1:/*code*/} + ${1:/*code*/} } endsnippet @@ -448,41 +450,41 @@ endsnippet snippet opDis "opDispatch (opDis)" b ${1:/*return type*/} opDispatch(string s)() { - ${2:/*code*/}; + ${2:/*code*/}; } endsnippet snippet op= "opAssign (op=)" b void opAssign(${1} rhs) ${2:@safe pure nothrow} { - ${2:/*code*/} + ${2:/*code*/} } endsnippet snippet opCmp "opCmp (opCmp)" b int opCmp(${1} rhs) @safe const pure nothrow { - ${2:/*code*/} + ${2:/*code*/} } endsnippet snippet opApply "opApply (opApply)" b int opApply(int delegate(ref ${1:/*iterated type/s*/}) dg) { - int result = 0; - ${2:/*loop*/} - { - result = dg(${3:/*arg/s*/}); - if(result){break;} - } - return result; + int result = 0; + ${2:/*loop*/} + { + result = dg(${3:/*arg/s*/}); + if(result){break;} + } + return result; } endsnippet snippet toString "toString (toString)" b string toString() @safe const pure nothrow { - ${1:/*code*/} + ${1:/*code*/} } endsnippet @@ -490,12 +492,11 @@ endsnippet # Comments -snippet todo "TODO (todo)" ! +snippet todo "TODO (todo)" // TODO: ${1} endsnippet - # DDoc snippet doc "generic ddoc block (doc)" b @@ -508,7 +509,7 @@ snippet fdoc "function ddoc block (fdoc)" b /// ${1:description} /// /// ${2:Params: ${3:param} = ${4:param description} -/// ${5}} +/// ${5}} /// /// ${6:Returns: ${7:return value}} /// @@ -517,7 +518,7 @@ endsnippet snippet Par "Params (Par)" Params: ${1:param} = ${2:param description} -/// ${3} +/// ${3} endsnippet snippet Ret "Returns (Ret)" @@ -543,16 +544,16 @@ snippet gpl "GPL (gpl)" b // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. -// +// // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. -// +// // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -// +// // Copyright (C) ${1:Author}, `!v strftime("%Y")` ${2} diff --git a/sources_non_forked/vim-snippets/UltiSnips/django.snippets b/sources_non_forked/vim-snippets/UltiSnips/django.snippets index 553babab..9d6ce279 100644 --- a/sources_non_forked/vim-snippets/UltiSnips/django.snippets +++ b/sources_non_forked/vim-snippets/UltiSnips/django.snippets @@ -1,3 +1,5 @@ +priority -50 + # Generic Tags snippet % {% ${1} %}${2} @@ -5,7 +7,7 @@ endsnippet snippet %% {% ${1:tag_name} %} - ${2} + ${2} {% end$1 %} endsnippet @@ -17,14 +19,14 @@ endsnippet snippet autoescape {% autoescape ${1:off} %} - ${2} + ${2} {% endautoescape %} endsnippet snippet block {% block ${1} %} - ${2} -{% endblock %} + ${2} +{% endblock $1 %} endsnippet snippet # @@ -33,7 +35,7 @@ endsnippet snippet comment {% comment %} - ${1} + ${1} {% endcomment %} endsnippet @@ -51,7 +53,7 @@ endsnippet snippet filter {% filter ${1} %} - ${2} + ${2} {% endfilter %} endsnippet @@ -61,24 +63,24 @@ endsnippet snippet for {% for ${1} in ${2} %} - ${3} + ${3} {% endfor %} endsnippet snippet empty {% empty %} - ${1} + ${1} endsnippet snippet if {% if ${1} %} - ${2} + ${2} {% endif %} endsnippet -snippet el +snippet else {% else %} - ${1} + ${1} endsnippet snippet ifchanged @@ -87,13 +89,13 @@ endsnippet snippet ifequal {% ifequal ${1} ${2} %} - ${3} + ${3} {% endifequal %} endsnippet snippet ifnotequal {% ifnotequal ${1} ${2} %} - ${3} + ${3} {% endifnotequal %} endsnippet diff --git a/sources_non_forked/vim-snippets/UltiSnips/elixir.snippets b/sources_non_forked/vim-snippets/UltiSnips/elixir.snippets index ae7ea201..1f53edfb 100644 --- a/sources_non_forked/vim-snippets/UltiSnips/elixir.snippets +++ b/sources_non_forked/vim-snippets/UltiSnips/elixir.snippets @@ -1,4 +1,4 @@ -# Credit: @iurifg +priority -50 snippet do do diff --git a/sources_non_forked/vim-snippets/UltiSnips/erlang.snippets b/sources_non_forked/vim-snippets/UltiSnips/erlang.snippets index 78231626..e27fbefa 100644 --- a/sources_non_forked/vim-snippets/UltiSnips/erlang.snippets +++ b/sources_non_forked/vim-snippets/UltiSnips/erlang.snippets @@ -2,6 +2,8 @@ # TEXTMATE SNIPPETS # ########################################################################### +priority -50 + snippet pat "Case:Receive:Try Clause" ${1:pattern}${2: when ${3:guard}} ->; ${4:body} diff --git a/sources_non_forked/vim-snippets/UltiSnips/eruby.snippets b/sources_non_forked/vim-snippets/UltiSnips/eruby.snippets index cd462fb2..118cdfec 100644 --- a/sources_non_forked/vim-snippets/UltiSnips/eruby.snippets +++ b/sources_non_forked/vim-snippets/UltiSnips/eruby.snippets @@ -1,3 +1,5 @@ +priority -50 + # TextMate added these variables to cope with changes in ERB handling # in different versions of Rails -- for instance, Rails 3 automatically # strips whitespace so that it's no longer necessary to use a form like @@ -11,16 +13,15 @@ # global !p def textmate_var(var, snip): - lookup = dict( - TM_RAILS_TEMPLATE_START_RUBY_EXPR = snip.opt('g:tm_rails_template_start_ruby_expr', '<%= '), - TM_RAILS_TEMPLATE_END_RUBY_EXPR = snip.opt('g:tm_rails_template_end_ruby_expr', ' %>'), - TM_RAILS_TEMPLATE_START_RUBY_INLINE = snip.opt('g:tm_rails_template_start_ruby_inline', '<% '), - TM_RAILS_TEMPLATE_END_RUBY_INLINE = snip.opt('g:tm_rails_template_end_ruby_inline', ' %>'), - TM_RAILS_TEMPLATE_END_RUBY_BLOCK = '<% end %>' - ) - - snip.rv = lookup[var] - return + lookup = dict( + TM_RAILS_TEMPLATE_START_RUBY_EXPR = snip.opt('g:tm_rails_template_start_ruby_expr', '<%= '), + TM_RAILS_TEMPLATE_END_RUBY_EXPR = snip.opt('g:tm_rails_template_end_ruby_expr', ' %>'), + TM_RAILS_TEMPLATE_START_RUBY_INLINE = snip.opt('g:tm_rails_template_start_ruby_inline', '<% '), + TM_RAILS_TEMPLATE_END_RUBY_INLINE = snip.opt('g:tm_rails_template_end_ruby_inline', ' %>'), + TM_RAILS_TEMPLATE_END_RUBY_BLOCK = '<% end %>' + ) + snip.rv = lookup[var] + return endglobal @@ -42,7 +43,7 @@ endsnippet snippet ft "form_tag" `!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_INLINE', snip)`form_tag(${1::action => "${5:update}"}${6:, {:${8:class} => "${9:form}"\}}) do`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` - $0 + $0 `!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_BLOCK', snip)` endsnippet @@ -52,11 +53,11 @@ endsnippet snippet for "for loop (ERB)" <% if !${1:list}.blank? %> - <% for ${2:item} in ${1} %> - $3 - <% end %> + <% for ${2:item} in ${1} %> + $3 + <% end %> <% else %> - $4 + $4 <% end %> endsnippet @@ -74,7 +75,7 @@ snippet ffhf "form_for hidden_field 2" endsnippet snippet ffl "form_for label 2" -`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR}f.label :${1:attribute', snip)`${2:, "${3:${1/[[:alpha:]]+|(_)/(?1: :\u$0)/g}}"}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` +`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`f.label :${1:attribute}${2:, "${3:${1/[[:alpha:]]+|(_)/(?1: :\u$0)/g}}"}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` endsnippet snippet ffpf "form_for password_field 2" @@ -99,7 +100,7 @@ endsnippet snippet fields "fields_for" `!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_INLINE', snip)`fields_for :${1:model}, @${2:$1} do |$1|`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_INLINE', snip)` - $0 + $0 `!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_BLOCK', snip)` endsnippet @@ -122,7 +123,7 @@ snippet f. "f.hidden_field" endsnippet snippet f. "f.label" -`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR}f.label :${1:attribute', snip)`${2:, "${3:${1/[[:alpha:]]+|(_)/(?1: :\u$0)/g}}"}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` +`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`f.label :${1:attribute}${2:, "${3:${1/[[:alpha:]]+|(_)/(?1: :\u$0)/g}}"}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` endsnippet snippet f. "f.password_field" @@ -148,14 +149,14 @@ endsnippet snippet ffe "form_for with errors" `!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`error_messages_for :${1:model}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` -`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_INLINE', snip)`form_for @${2:$1} do |f|`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_INLINE', snip)` - $0 +`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`form_for @${2:$1} do |f|`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` + $0 `!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_BLOCK', snip)` endsnippet snippet ff "form_for" -`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_INLINE', snip)`form_for @${1:model} do |f|`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_INLINE', snip)` - $0 +`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`form_for @${1:model} do |f|`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` + $0 `!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_BLOCK', snip)` endsnippet @@ -271,9 +272,9 @@ snippet st "submit_tag" `!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`submit_tag "${1:Save changes}"${2:, :id => "${3:submit}"}${4:, :name => "${5:$3}"}${6:, :class => "${7:form_$3}"}${8:, :disabled => ${9:false}}${10:, :disable_with => "${11:Please wait...}"}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` endsnippet -snippet el "else (ERB)" +snippet else "else (ERB)" <% else %> - + $0 endsnippet snippet if "if (ERB)" diff --git a/sources_non_forked/vim-snippets/UltiSnips/go.snippets b/sources_non_forked/vim-snippets/UltiSnips/go.snippets index ea46931b..d01e3f1c 100644 --- a/sources_non_forked/vim-snippets/UltiSnips/go.snippets +++ b/sources_non_forked/vim-snippets/UltiSnips/go.snippets @@ -1,5 +1,7 @@ # Snippets for Go +priority -50 + # when to abbriviate and when not? # b doesn't work here, because it ignores whitespace # optional local name? @@ -31,37 +33,55 @@ const ( ) endsnippet +snippet struct "Struct declaration" b +type ${1:Struct} struct { + ${0:${VISUAL}} +} +endsnippet + +snippet interface "Interface declaration" b +type ${1:Interface} interface { + ${0:${VISUAL}} +} +endsnippet + # statements -snippet for "For loop" !b +snippet for "For loop" b for ${1:condition}${1/(.+)/ /}{ ${0:${VISUAL}} } endsnippet -snippet forr "For range loop" !b +snippet forr "For range loop" b for ${2:name} := range ${1:collection} { ${0:${VISUAL}} } endsnippet -snippet if "If statement" !b +snippet if "If statement" b if ${1:condition}${1/(.+)/ /}{ ${0:${VISUAL}} } endsnippet -snippet switch "Switch statement" !b +snippet switch "Switch statement" b switch ${1:expression}${1/(.+)/ /}{ case${0} } endsnippet -snippet case "Case clause" !b +snippet select "Select statement" b +select { +case${0} +} +endsnippet + +snippet case "Case clause" b case ${1:condition}: ${0:${VISUAL}} endsnippet -snippet default "Default clause" !b +snippet default "Default clause" b default: ${0:${VISUAL}} endsnippet @@ -86,22 +106,26 @@ func ${1:name}(${2:params})${3/(.+)/ /}${3:type} { endsnippet # types and variables -snippet map "Map type" !b +snippet map "Map type" b map[${1:keytype}]${2:valtype} endsnippet -snippet : "Variable declaration :=" !b +snippet : "Variable declaration :=" b ${1:name} := ${0:value} endsnippet -snippet var "Variable declaration" !b +snippet var "Variable declaration" b var ${1:name}${2/(.+)/ /}${2:type}${3: = ${0:value}} endsnippet -snippet vars "Variables declaration" !b +snippet vars "Variables declaration" b var ( ${1:name}${2/(.+)/ /}${2:type}${3: = ${0:value} } ) endsnippet +snippet json "JSON field" +\`json:"${1:displayName}"\` +endsnippet + # vim:ft=snippets: diff --git a/sources_non_forked/vim-snippets/UltiSnips/haskell.snippets b/sources_non_forked/vim-snippets/UltiSnips/haskell.snippets index 99f947f8..ad217fd8 100644 --- a/sources_non_forked/vim-snippets/UltiSnips/haskell.snippets +++ b/sources_non_forked/vim-snippets/UltiSnips/haskell.snippets @@ -1,13 +1,15 @@ -snippet ife "if ... then ... else ..." +priority -50 + +snippet if "if ... then ... else ..." if ${1:condition} - then ${2:expression} - else ${3:expression} + then ${2:expression} + else ${3:expression} endsnippet snippet case "case ... of ..." -case ${1} of - ${2} -> ${3} - ${4} -> ${5} +case ${1:expression} of + ${2:pattern} -> ${3:expression} + ${4:pattern} -> ${5:expression} endsnippet snippet :: "Type signature" diff --git a/sources_non_forked/vim-snippets/UltiSnips/help.snippets b/sources_non_forked/vim-snippets/UltiSnips/help.snippets index bd0bb12f..61327385 100644 --- a/sources_non_forked/vim-snippets/UltiSnips/help.snippets +++ b/sources_non_forked/vim-snippets/UltiSnips/help.snippets @@ -1,10 +1,12 @@ # Snippets for VIM Help Files +priority -50 + global !p def sec_title(snip, t): - file_start = snip.fn.split('.')[0] - sec_name = t[1].strip("1234567890. ").lower().replace(' ', '-') - return ("*%s-%s*" % (file_start, sec_name)).rjust(78-len(t[1])) + file_start = snip.fn.split('.')[0] + sec_name = t[1].strip("1234567890. ").lower().replace(' ', '-') + return ("*%s-%s*" % (file_start, sec_name)).rjust(78-len(t[1])) endglobal snippet sec "Section marker" b diff --git a/sources_non_forked/vim-snippets/UltiSnips/html.snippets b/sources_non_forked/vim-snippets/UltiSnips/html.snippets index fd11d70b..31f7cc34 100644 --- a/sources_non_forked/vim-snippets/UltiSnips/html.snippets +++ b/sources_non_forked/vim-snippets/UltiSnips/html.snippets @@ -1,13 +1,15 @@ +priority -50 + ########################################################################### # TextMate Snippets # ########################################################################### global !p def x(snip): - if snip.ft.startswith("x"): - snip.rv = '/' - else: - snip.rv = "" + if snip.ft.startswith("x"): + snip.rv = '/' + else: + snip.rv = "" endglobal ############ @@ -123,21 +125,21 @@ endsnippet ############# # HTML TAGS # ############# -snippet input "Input with Label" +snippet input "Input with Label" w endsnippet -snippet input "XHTML " +snippet input "XHTML " w endsnippet -snippet opt "Option" +snippet opt "Option" w ${3:$2} endsnippet -snippet select "Select Box" +snippet select "Select Box" w endsnippet -snippet mailto "XHTML " +snippet mailto "XHTML " w ${3:email me} endsnippet -snippet base "XHTML " +snippet base "XHTML " w endsnippet +snippet img "XHTML " w + +endsnippet + snippet body "XHTML " " - - $0 +snippet div "XHTML
" w + + $0
endsnippet -snippet form "XHTML
" +snippet form "XHTML " w @@ -182,7 +188,7 @@ snip.rv = (snip.basename or 'unnamed') + '_submit'
endsnippet -snippet h1 "XHTML

" +snippet h1 "XHTML

" w

${1}

endsnippet @@ -194,71 +200,70 @@ snippet head "XHTML " endsnippet -snippet link "XHTML " +snippet link "XHTML " w endsnippet -snippet meta "XHTML " +snippet meta "XHTML " w endsnippet -snippet scriptsrc "XHTML endsnippet -snippet script "XHTML endsnippet -snippet style "XHTML endsnippet -snippet table "XHTML " +snippet table "XHTML
" w
${5:Header}
${0:Data}
endsnippet -snippet a "Link" +snippet a "Link" w ${4:Anchor Text} endsnippet -snippet p "paragraph" +snippet p "paragraph" w

$0

endsnippet -snippet li "list item" -
  • +snippet li "list item" w +
  • $0
  • endsnippet -snippet ul "unordered list" +snippet ul "unordered list" w
      $0
    endsnippet -snippet td "table cell" +snippet td "table cell" w $0 endsnippet -snippet tr "table row" +snippet tr "table row" w $0 endsnippet -snippet title "XHTML " +snippet title "XHTML <title>" w <title>${1:`!p snip.rv = snip.basename or "Page Title"`} endsnippet -snippet fieldset "Fieldset" +snippet fieldset "Fieldset" w
    $1 - $0
    endsnippet @@ -282,7 +287,7 @@ snippet html5 "HTML5 Template" ${1} - +
    diff --git a/sources_non_forked/vim-snippets/UltiSnips/html_minimal.snippets b/sources_non_forked/vim-snippets/UltiSnips/html_minimal.snippets index 1f77ad7b..48ff4b72 100644 --- a/sources_non_forked/vim-snippets/UltiSnips/html_minimal.snippets +++ b/sources_non_forked/vim-snippets/UltiSnips/html_minimal.snippets @@ -1,6 +1,8 @@ # more can be found in snippets/html_minimal.snippets # these UltiSnips override snippets because nested placeholders are being used +priority -50 + snippet id id="${1}"${2} endsnippet diff --git a/sources_non_forked/vim-snippets/UltiSnips/htmldjango.snippets b/sources_non_forked/vim-snippets/UltiSnips/htmldjango.snippets index 9df5f788..5836a2f6 100644 --- a/sources_non_forked/vim-snippets/UltiSnips/htmldjango.snippets +++ b/sources_non_forked/vim-snippets/UltiSnips/htmldjango.snippets @@ -1 +1,3 @@ +priority -50 + extends html, django diff --git a/sources_non_forked/vim-snippets/UltiSnips/htmljinja.snippets b/sources_non_forked/vim-snippets/UltiSnips/htmljinja.snippets new file mode 100644 index 00000000..fa3b3c22 --- /dev/null +++ b/sources_non_forked/vim-snippets/UltiSnips/htmljinja.snippets @@ -0,0 +1,3 @@ +priority -50 + +extends html, jinja2 diff --git a/sources_non_forked/vim-snippets/UltiSnips/java.snippets b/sources_non_forked/vim-snippets/UltiSnips/java.snippets index 617c1616..96cc7a9e 100644 --- a/sources_non_forked/vim-snippets/UltiSnips/java.snippets +++ b/sources_non_forked/vim-snippets/UltiSnips/java.snippets @@ -1,27 +1,75 @@ -########################################################################### -# TEXTMATE SNIPPETS # -########################################################################### +priority -50 # Many of the snippets here use a global option called # "g:ultisnips_java_brace_style" which, if set to "nl" will put a newline # before '{' braces. +# Setting "g:ultisnips_java_junit" will change how the test method snippet +# looks, it is defaulted to junit4, setting this option to 3 will remove the +# @Test annotation from the method global !p +def junit(snip): + if snip.opt("g:ultisnips_java_junit", "") == "3": + snip += "" + else: + snip.rv += "@Test\n\t" + def nl(snip): - if snip.opt("g:ultisnips_java_brace_style", "") == "nl": - snip += "" - else: - snip.rv += " " + if snip.opt("g:ultisnips_java_brace_style", "") == "nl": + snip += "" + else: + snip.rv += " " +def getArgs(group): + import re + word = re.compile('[a-zA-Z><.]+ \w+') + return [i.split(" ") for i in word.findall(group) ] + +def camel(word): + return word[0].upper() + word[1:] + endglobal +snippet sleep "try sleep catch" b +try { + Thread.sleep(${1:1000}); +} catch (InterruptedException e){ + e.printStackTrace(); +} +endsnippet + +snippet /i|n/ "new primitive or int" br +${1:int} ${2:i} = ${3:1}; +$0 +endsnippet + +snippet /o|v/ "new Object or variable" br +${1:Object} ${2:var} = new $1(${3}); +endsnippet + +snippet f "field" b +${1:private} ${2:String} ${3:`!p snip.rv = t[2].lower()`}; +endsnippet + snippet ab "abstract" b -abstract +abstract $0 endsnippet snippet as "assert" b assert ${1:test}${2/(.+)/(?1: \: ")/}${2:Failure message}${2/(.+)/(?1:")/};$0 endsnippet +snippet at "assert true" b +assertTrue(${1:actual}); +endsnippet + +snippet af "assert false" b +assertFalse(${1:actual});$0 +endsnippet + +snippet ae "assert equals" b +assertEquals(${1:expected}, ${2:actual}); +endsnippet + snippet br "break" break; @@ -39,19 +87,85 @@ catch (${1:Exception} ${2:e})`!p nl(snip)`{ } endsnippet -snippet cl "class" b -class ${1:`!p +snippet cle "class extends" b +public class ${1:`!p snip.rv = snip.basename or "untitled"`} ${2:extends ${3:Parent} }${4:implements ${5:Interface} }{ $0 } endsnippet +snippet clc "class with constructor, fields, setter and getters" b +public class `!p +snip.rv = snip.basename or "untitled"` { +`!p +args = getArgs(t[1]) +if len(args) == 0: snip.rv = "" +for i in args: + snip.rv += "\n\tprivate " + i[0] + " " + i[1]+ ";" +if len(args) > 0: + snip.rv += "\n"` + public `!p snip.rv = snip.basename or "unknown"`($1) { `!p +args = getArgs(t[1]) +for i in args: + snip.rv += "\n\t\tthis." + i[1] + " = " + i[1] + ";" +if len(args) == 0: + snip.rv += "\n"` + }$0 +`!p +args = getArgs(t[1]) +if len(args) == 0: snip.rv = "" +for i in args: + snip.rv += "\n\tpublic void set" + camel(i[1]) + "(" + i[0] + " " + i[1] + ") {\n" + "\ + \tthis." + i[1] + " = " + i[1] + ";\n\t}\n" + + snip.rv += "\n\tpublic " + i[0] + " get" + camel(i[1]) + "() {\ + \n\t\treturn " + i[1] + ";\n\t}\n" +` +} +endsnippet + +snippet clc "class with constructor, with field names" b +public class `!p +snip.rv = snip.basename or "untitled"` { +`!p +args = getArgs(t[1]) +for i in args: + snip.rv += "\n\tprivate " + i[0] + " " + i[1]+ ";" +if len(args) > 0: + snip.rv += "\n"` + public `!p snip.rv = snip.basename or "unknown"`($1) { `!p +args = getArgs(t[1]) +for i in args: + snip.rv += "\n\t\tthis." + i[1] + " = " + i[1] +if len(args) == 0: + snip.rv += "\n"` + } +} +endsnippet + +snippet clc "class and constructor" b +public class `!p +snip.rv = snip.basename or "untitled"` { + + public `!p snip.rv = snip.basename or "untitled"`($2) { + $0 + } +} +endsnippet + +snippet cl "class" b +public class ${1:`!p +snip.rv = snip.basename or "untitled"`} { + $0 +} +endsnippet + snippet cos "constant string" b -static public final String ${1:var} = "$2";$0 +public static final String ${1:var} = "$2";$0 endsnippet snippet co "constant" b -static public final ${1:String} ${2:var} = $3;$0 +public static final ${1:String} ${2:var} = $3;$0 endsnippet snippet de "default" b @@ -59,7 +173,7 @@ default: $0 endsnippet -snippet eif "else if" b +snippet elif "else if" b else if ($1)`!p nl(snip)`{ $0 } @@ -72,7 +186,7 @@ else`!p nl(snip)`{ endsnippet snippet fi "final" b -final +final $0 endsnippet snippet fore "for (each)" b @@ -81,6 +195,12 @@ for ($1 : $2)`!p nl(snip)`{ } endsnippet +snippet fori "for" b +for (int ${1:i} = 0; $1 < ${2:10}; $1++)`!p nl(snip)`{ + $0 +} +endsnippet + snippet for "for" b for ($1; $2; $3)`!p nl(snip)`{ $0 @@ -99,7 +219,7 @@ $0 endsnippet snippet im "import" b -import +import ${1:java}.${2:util}.$0 endsnippet snippet in "interface" b @@ -108,6 +228,48 @@ interface ${1:`!p snip.rv = snip.basename or "untitled"`} ${2:extends ${3:Parent } endsnippet +snippet cc "constructor call or setter body" +this.${1:var} = $1; +endsnippet + +snippet list "Collections List" b +List<${1:String}> ${2:list} = new ${3:Array}List<$1>(); +endsnippet + +snippet map "Collections Map" b +Map<${1:String}, ${2:String}> ${3:map} = new ${4:Hash}Map<$1, $2>(); +endsnippet + +snippet set "Collections Set" b +Set<${1:String}> ${2:set} = new ${3:Hash}Set<$1>(); +endsnippet + +snippet /Str?|str/ "String" br +String $0 +endsnippet + +snippet cn "Constructor" b +public `!p snip.rv = snip.basename or "untitled"`(${1:}) { + $0 +} +endsnippet + +snippet cn "constructor, \w fields + assigments" b + `!p +args = getArgs(t[1]) +for i in args: + snip.rv += "\n\tprivate " + i[0] + " " + i[1]+ ";" +if len(args) > 0: + snip.rv += "\n"` +public `!p snip.rv = snip.basename or "unknown"`($1) { `!p +args = getArgs(t[1]) +for i in args: + snip.rv += "\n\t\tthis." + i[1] + " = " + i[1] +if len(args) == 0: + snip.rv += "\n"` +} +endsnippet + snippet j.b "java_beans_" i java.beans. endsnippet @@ -134,15 +296,70 @@ public static void main(String[] args)`!p nl(snip)`{ } endsnippet -snippet m "method" b -${1:void} ${2:method}($3) ${4:throws $5 }{ +snippet try "try/catch" b +try { + $1 +} catch(${2:Exception} ${3:e}){ + ${4:e.printStackTrace();} +} +endsnippet + +snippet mt "method throws" b +${1:private} ${2:void} ${3:method}(${4}) ${5:throws $6 }{ $0 } +endsnippet +snippet m "method" b +${1:private} ${2:void} ${3:method}(${4}) { + $0 +} +endsnippet + +snippet md "Method With javadoc" b +/** + * ${7:Short Description}`!p +for i in getArgs(t[4]): + snip.rv += "\n\t * @param " + i[1] + " usage..."` + * `!p +if "throws" in t[5]: + snip.rv = "\n\t * @throws " + t[6] +else: + snip.rv = ""` `!p +if not "void" in t[2]: + snip.rv = "\n\t * @return object" +else: + snip.rv = ""` + **/ +${1:public} ${2:void} ${3:method}($4) ${5:throws $6 }{ + $0 +} +endsnippet + +snippet /get(ter)?/ "getter" br +public ${1:String} get${2:Name}() { + return `!p snip.rv = t[2].lower()`; +} +endsnippet + +snippet /set(ter)?/ "setter" br +public void set${1:Name}(${2:String} $1) { + return this.`!p snip.rv = t[1].lower()` = `!p snip.rv = t[1].lower()`; +} +endsnippet + +snippet /se?tge?t|ge?tse?t|gs/ "setter and getter" br +public void set${1:Name}(${2:String} `!p snip.rv = t[1].lower()`) { + this.`!p snip.rv = t[1].lower()` = `!p snip.rv = t[1].lower()`; +} + +public $2 get$1() { + return `!p snip.rv = t[1].lower()`; +} endsnippet snippet pa "package" b -package +package $0 endsnippet snippet p "print" b @@ -154,33 +371,33 @@ System.out.println($1);$0 endsnippet snippet pr "private" b -private +private $0 endsnippet snippet po "protected" b -protected +protected $0 endsnippet snippet pu "public" b -public +public $0 endsnippet snippet re "return" b -return +return $0 endsnippet snippet st "static" -static +static $0 endsnippet snippet sw "switch" b switch ($1)`!p nl(snip)`{ - $0 + case $2: $0 } endsnippet snippet sy "synchronized" -synchronized +synchronized $0 endsnippet snippet tc "test case" @@ -190,17 +407,19 @@ public class ${1:`!p snip.rv = snip.basename or "untitled"`} extends ${2:TestCas endsnippet snippet t "test" b -public void test${1:Name}() throws Exception`!p nl(snip)`{ +`!p junit(snip)`public void test${1:Name}() { + $0 +} +endsnippet + +snippet tt "test throws" b +`!p junit(snip)`public void test${1:Name}() ${2:throws Exception }{ $0 } endsnippet snippet th "throw" b -throw $0 -endsnippet - -snippet v "variable" b -${1:String} ${2:var}${3: = ${0:null}}; +throw new $0 endsnippet snippet wh "while" b diff --git a/sources_non_forked/vim-snippets/UltiSnips/javascript.snippets b/sources_non_forked/vim-snippets/UltiSnips/javascript.snippets index 439ec874..f8d4790e 100644 --- a/sources_non_forked/vim-snippets/UltiSnips/javascript.snippets +++ b/sources_non_forked/vim-snippets/UltiSnips/javascript.snippets @@ -1,3 +1,5 @@ +priority -50 + ########################################################################### # TextMate Snippets # ########################################################################### @@ -6,19 +8,19 @@ getElement${1/(T)|.*/(?1:s)/}By${1:T}${1/(T)|(I)|.*/(?1:agName)(?2:d)/}('$2') endsnippet snippet '':f "object method string" -'${1:${2:#thing}:${3:click}}': function(element){ - $0 +'${1:${2:#thing}:${3:click}}': function(element) { + ${VISUAL}$0 }${10:,} endsnippet snippet :f "Object Method" -${1:method_name}: function(${3:attribute}){ - $0 +${1:method_name}: function(${3:attribute}) { + ${VISUAL}$0 }${10:,} endsnippet snippet :, "Object Value JS" -${1:value_name}:${0:value}, +${1:value_name}: ${0:value}, endsnippet snippet : "Object key key: 'value'" @@ -26,47 +28,135 @@ ${1:key}: ${2:"${3:value}"}${4:, } endsnippet snippet proto "Prototype (proto)" -${1:class_name}.prototype.${2:method_name} = function(${3:first_argument}) ,,{ - ${0} -} - +${1:class_name}.prototype.${2:method_name} = function(${3:first_argument}) { + ${VISUAL}$0 +}; + endsnippet -snippet for "for (...) {...} (faster)" -for (var ${2:i} = ${1:Things}.length - 1; $2 >= 0; $2--){ - ${3:$1[$2]}$0 +snippet for "for (...) {...} (counting up)" b +for (var ${1:i} = 0, ${2:len} = ${3:Things.length}; $1 < $2; $1++) { + ${VISUAL}$0 } endsnippet -snippet for "for (...) {...}" -for (var ${2:i}=0; $2 < ${1:Things}.length; $2++) { - ${3:$1[$2]}$0 +snippet ford "for (...) {...} (counting down, faster)" b +for (var ${2:i} = ${1:Things.length} - 1; $2 >= 0; $2--) { + ${VISUAL}$0 } endsnippet snippet fun "function (fun)" -function ${1:function_name} (${2:argument}) { - ${0} +function ${1:function_name}(${2:argument}) { + ${VISUAL}$0 } endsnippet -# for one line if .. else you usually use a ? b : c +snippet iife "Immediately-Invoked Function Expression (iife)" +(function (${1:argument}) { + ${VISUAL}$0 +}(${2:$1})); +endsnippet + snippet ife "if ___ else" -if (${1}) { - ${2} -} else { - ${3} +if (${1:condition}) { + ${2://code} +} +else { + ${3://code} } endsnippet snippet if "if" -if (${1}) { - ${2} +if (${1:condition}) { + ${VISUAL}$0 } endsnippet snippet timeout "setTimeout function" -setTimeout(function() {$0}${2:}, ${1:10}) +setTimeout(function() { + ${VISUAL}$0 +}${2:.bind(${3:this})}, ${1:10}); +endsnippet + +# Snippets for Console Debug Output + +snippet ca "console.assert" b +console.assert(${1:assertion}, ${2:"${3:message}"}); +endsnippet + +snippet cclear "console.clear" b +console.clear(); +endsnippet + +snippet cdir "console.dir" b +console.dir(${1:object}); +endsnippet + +snippet cdirx "console.dirxml" b +console.dirxml(${1:object}); +endsnippet + +snippet ce "console.error" b +console.error(${1:"${2:value}"}); +endsnippet + +snippet cgroup "console.group" b +console.group("${1:label}"); +${VISUAL}$0 +console.groupEnd(); +endsnippet + +snippet cgroupc "console.groupCollapsed" b +console.groupCollapsed("${1:label}"); +${VISUAL}$0 +console.groupEnd(); +endsnippet + +snippet ci "console.info" b +console.info(${1:"${2:value}"}); +endsnippet + +snippet cl "console.log" b +console.log(${1:"${2:value}"}); +endsnippet + +snippet cprof "console.profile" b +console.profile("${1:label}"); +${VISUAL}$0 +console.profileEnd(); +endsnippet + +snippet ctable "console.table" b +console.table(${1:"${2:value}"}); +endsnippet + +snippet ctime "console.time" b +console.time("${1:label}"); +${VISUAL}$0 +console.timeEnd("$1"); +endsnippet + +snippet ctimestamp "console.timeStamp" b +console.timeStamp("${1:label}"); +endsnippet + +snippet ctrace "console.trace" b +console.trace(); +endsnippet + +snippet cw "console.warn" b +console.warn(${1:"${2:value}"}); +endsnippet + +# AMD (Asynchronous Module Definition) snippets + +snippet def "define an AMD module" +define(${1:optional_name, }[${2:'jquery'}], ${3:callback}); +endsnippet + +snippet req "require an AMD module" +require([${1:'dependencies'}], ${2:callback}); endsnippet # vim:ft=snippets: diff --git a/sources_non_forked/vim-snippets/UltiSnips/javascript_ember.snippets b/sources_non_forked/vim-snippets/UltiSnips/javascript_ember.snippets index 543a26ad..1b7e7b8d 100644 --- a/sources_non_forked/vim-snippets/UltiSnips/javascript_ember.snippets +++ b/sources_non_forked/vim-snippets/UltiSnips/javascript_ember.snippets @@ -2,6 +2,8 @@ # Ember snippets # ################################################################### +priority -50 + # Application snippet eapp "App.Name = Ember.Application.create({});" ${1:App.Name} = Ember.Application.create({}); @@ -10,48 +12,48 @@ endsnippet # Models snippet emod "App.ModelName = Ember.Model.extend({...});" ${1:model_name} = Ember.Model.extend({ - ${0://Properties here...} + ${0://Properties here...} }); endsnippet # View snippet eview "App.ViewName = Ember.Model.extend({...});" ${1:view_name} = Ember.View.extend({ - ${0://Properties here...} + ${0://Properties here...} }); endsnippet # Controller snippet econtroller "App.ControllerName = Ember.Model.extend({...});" ${1:controller_name} = Ember.ObjectController.extend({ - ${0://Properties here...} + ${0://Properties here...} }); endsnippet # Route snippet eroute "App.RouteName = Ember.Route.extend({...});" ${1:route_name} = Ember.Route.extend({ - ${0://Properties here...} + ${0://Properties here...} }); endsnippet snippet eview "App.ViewName = Ember.Model.create({...});" ${1:view_name} = Ember.View.create({ - ${0://Properties here...} + ${0://Properties here...} }); endsnippet # Object snippet eobj "App.ObjectName = Ember.Object.extend({...});" ${1:object_name} = Ember.Object.create({ - ${0://Properties here...} + ${0://Properties here...} }); endsnippet # Mixin snippet emix "App.MixinName = Ember.Model.extend({...});" ${1:view_name} = Ember.Mixin.create({ - ${0://Properties here...} + ${0://Properties here...} }); endsnippet @@ -67,13 +69,13 @@ endsnippet # Computer properties snippet cpro "property_name: function() {...}.property()," ${1:property_name}: function() { - ${0://body...} + ${0://body...} }.property('${3:argumenet}'), endsnippet snippet cpro ": function() {...}.property('property')," ${1:property_name}: function() { - ${0://body...} + ${0://body...} }.property(), endsnippet @@ -81,7 +83,7 @@ endsnippet # Observes snippet proo "property_name: function() {...}.property()" ${1:property_name}: function() { - ${0://body...} + ${0://body...} }.observes('${3:property}'), endsnippet diff --git a/sources_non_forked/vim-snippets/UltiSnips/javascript_jasmine.snippets b/sources_non_forked/vim-snippets/UltiSnips/javascript_jasmine.snippets index 49e38a35..3a872985 100644 --- a/sources_non_forked/vim-snippets/UltiSnips/javascript_jasmine.snippets +++ b/sources_non_forked/vim-snippets/UltiSnips/javascript_jasmine.snippets @@ -1,8 +1,8 @@ -# +priority -50 + # JavaScript versions -- from the TextMate bundle + some additions # for jasmine-jquery matchers # -extends javascript snippet des "Describe (js)" b describe('${1:description}', function() { @@ -165,4 +165,3 @@ endsnippet snippet noscw "expect was not called with (js)" b expect(${1:target}).wasNotCalledWith(${2:arguments}); endsnippet - diff --git a/sources_non_forked/vim-snippets/UltiSnips/javascript_jsdoc.snippets b/sources_non_forked/vim-snippets/UltiSnips/javascript_jsdoc.snippets new file mode 100644 index 00000000..ca943fc7 --- /dev/null +++ b/sources_non_forked/vim-snippets/UltiSnips/javascript_jsdoc.snippets @@ -0,0 +1,51 @@ +priority -50 + +# JSDoc snippets + +snippet /* "A JSDoc comment" b +/** + * ${1:${VISUAL}}$0 + */ +endsnippet + +snippet @au "@author email (First Last)" +@author ${1:`!v g:snips_author_email`} (${2:`!v g:snips_author`}) +endsnippet + +snippet @li "@license Description" +@license ${1:MIT}$0 +endsnippet + +snippet @ver "@version Semantic version" +@version ${1:0.1.0}$0 +endsnippet + +snippet @fileo "@fileoverview Description" b +/** + * @fileoverview ${1:${VISUAL:A description of the file}}$0 + */ +endsnippet + +snippet @constr "@constructor" +@constructor +endsnippet + +snippet @p "@param {Type} varname Description" +@param {${1:Type}} ${2:varname} ${3:Description} +endsnippet + +snippet @ret "@return {Type} Description" +@return {${1:Type}} ${2:Description} +endsnippet + +snippet @pri "@private" +@private +endsnippet + +snippet @over "@override" +@override +endsnippet + +snippet @pro "@protected" +@protected +endsnippet diff --git a/sources_non_forked/vim-snippets/UltiSnips/jinja2.snippets b/sources_non_forked/vim-snippets/UltiSnips/jinja2.snippets index 6fef6edf..ded01dcf 100644 --- a/sources_non_forked/vim-snippets/UltiSnips/jinja2.snippets +++ b/sources_non_forked/vim-snippets/UltiSnips/jinja2.snippets @@ -1,3 +1,4 @@ +priority -50 # http://jinja.pocoo.org/ @@ -11,7 +12,7 @@ snippet block "block" b {% block ${1:name} %} - $2 + $2 {% endblock $1 %} endsnippet @@ -33,7 +34,7 @@ endsnippet snippet raw "escaped block" b {% raw %} - $1 + $1 {% endraw %} endsnippet @@ -60,7 +61,7 @@ endsnippet snippet filter "filter" b {% filter ${1:filter} %} - $2 + $2 {% endfilter %} endsnippet @@ -78,57 +79,57 @@ endsnippet snippet for "for" b {% for ${1:item} in ${2:sequence} %} - $3 + $3 {% endfor %} endsnippet snippet for "for/else" b {% for ${1:item} in ${2:sequence} %} - $3 + $3 {% else %} - $4 + $4 {% endfor %} endsnippet snippet if "if" b {% if ${1:expr} %} - $2 + $2 {% endif %} endsnippet snippet if "if/else" b {% if ${1:expr} %} - $2 + $2 {% else %} - $3 + $3 {% endif %} endsnippet snippet if "if/elif/else" b {% if ${1:expr} %} - $2 + $2 {% elif %} - $3 + $3 {% else %} - $4 + $4 {% endif %} endsnippet snippet macro "macro" b {% macro ${1:name}(${2:args}) %} - $3 + $3 {% endmacro %} endsnippet snippet call "call" b {% call ${1:name}(${2:args}) %} - $3 + $3 {% endcall %} endsnippet @@ -140,25 +141,24 @@ endsnippet snippet trans "translation" b {% trans %} - $1 + $1 {% endtrans %} endsnippet snippet with "with" b {% with %} - $1 + $1 {% endwith %} endsnippet - snippet autoescape "autoescape" b {% autoescape ${1:true} %} - $2 + $2 {% endautoescape %} endsnippet -# Filters +# Filters # @todo: expand only when snippet is preceeded by a | snippet batch "batch items" w diff --git a/sources_non_forked/vim-snippets/UltiSnips/json.snippets b/sources_non_forked/vim-snippets/UltiSnips/json.snippets index 81e65611..b0cad830 100644 --- a/sources_non_forked/vim-snippets/UltiSnips/json.snippets +++ b/sources_non_forked/vim-snippets/UltiSnips/json.snippets @@ -1,3 +1,5 @@ +priority -50 + snippet s "String" b "${1:key}": "${0:value}", endsnippet @@ -8,12 +10,11 @@ endsnippet snippet a "Array" b [ - ${VISUAL}$0 + ${VISUAL}$0 ], endsnippet snippet o "Object" b { - ${VISUAL}$0 + ${VISUAL}$0 }, endsnippet - diff --git a/sources_non_forked/vim-snippets/UltiSnips/ledger.snippets b/sources_non_forked/vim-snippets/UltiSnips/ledger.snippets new file mode 100644 index 00000000..4bf46916 --- /dev/null +++ b/sources_non_forked/vim-snippets/UltiSnips/ledger.snippets @@ -0,0 +1,8 @@ +priority -50 + +snippet t "Transaction" b +${1:`!v strftime("%Y")`}-${2:`!v strftime("%m")`}-${3:`!v strftime("%d")`} ${4:*} ${5:Payee} + ${6:Expenses} \$${7:0.00} + ${8:Assets:Checking} +$0 +endsnippet diff --git a/sources_non_forked/vim-snippets/UltiSnips/lhaskell.snippets b/sources_non_forked/vim-snippets/UltiSnips/lhaskell.snippets new file mode 100644 index 00000000..29169a55 --- /dev/null +++ b/sources_non_forked/vim-snippets/UltiSnips/lhaskell.snippets @@ -0,0 +1,3 @@ +priority -50 + +extends haskell diff --git a/sources_non_forked/vim-snippets/UltiSnips/lua.snippets b/sources_non_forked/vim-snippets/UltiSnips/lua.snippets index 1b82a245..bc59c60c 100644 --- a/sources_non_forked/vim-snippets/UltiSnips/lua.snippets +++ b/sources_non_forked/vim-snippets/UltiSnips/lua.snippets @@ -1,3 +1,5 @@ +priority -50 + ################################# # Snippets for the Lua language # ################################# @@ -8,25 +10,25 @@ endsnippet snippet !fun(ction)?! "New function" br function ${1:new_function}(${2:args}) - $0 + $0 end endsnippet snippet forp "pair for loop" b for ${1:name},${2:val} in pairs(${3:table_name}) do - $0 + $0 end endsnippet snippet fori "ipair for foop" b for ${1:idx},${2:val} in ipairs(${3:table_name}) do - $0 + $0 end endsnippet snippet for "numeric for loop" b for ${1:i}=${2:first},${3:last}${4/^..*/(?0:,:)/}${4:step} do - $0 + $0 end endsnippet diff --git a/sources_non_forked/vim-snippets/UltiSnips/mako.snippets b/sources_non_forked/vim-snippets/UltiSnips/mako.snippets index 92a7be38..fb31ec84 100644 --- a/sources_non_forked/vim-snippets/UltiSnips/mako.snippets +++ b/sources_non_forked/vim-snippets/UltiSnips/mako.snippets @@ -1,3 +1,5 @@ +priority -50 + ################# # From snipmate # ################# diff --git a/sources_non_forked/vim-snippets/UltiSnips/markdown.snippets b/sources_non_forked/vim-snippets/UltiSnips/markdown.snippets index c3189b8a..fa708ab8 100644 --- a/sources_non_forked/vim-snippets/UltiSnips/markdown.snippets +++ b/sources_non_forked/vim-snippets/UltiSnips/markdown.snippets @@ -1,6 +1,4 @@ -########################################################################### -# SNIPPETS for MARKDOWN # -########################################################################### +priority -50 ########################### # Sections and Paragraphs # diff --git a/sources_non_forked/vim-snippets/UltiSnips/objc.snippets b/sources_non_forked/vim-snippets/UltiSnips/objc.snippets index 0c676641..45e41fc1 100644 --- a/sources_non_forked/vim-snippets/UltiSnips/objc.snippets +++ b/sources_non_forked/vim-snippets/UltiSnips/objc.snippets @@ -1,3 +1,5 @@ +priority -50 + ########################################################################### # TextMate Snippets # ########################################################################### @@ -11,11 +13,11 @@ snippet Imp "#import <> (Imp)" endsnippet snippet cl "020 Class (objc)" -@interface ${1:`!p +@interface ${1:`!p if len(fn): - snip.rv = re.sub(r'\..*$', '', fn) + snip.rv = re.sub(r'\..*$', '', fn) else: - snip.rv = "object" + snip.rv = "object" `} : ${2:NSObject} { } @@ -118,7 +120,7 @@ snippet arracc "LoD array (arracc)" [${3:${1/./\l$0/}} addObject:anObject]; } -- (void)insertObject:($2)anObject in$1AtIndex:(unsigned int)i +- (void)insertObject:($2)anObject in$1AtIndex:(unsigned int)i { [$3 insertObject:anObject atIndex:i]; } @@ -189,7 +191,7 @@ if(choice == NSAlertDefaultReturn) // "$3" } else if(choice == NSAlertAlternateReturn) // "$4" { - + $0 } endsnippet @@ -217,7 +219,7 @@ endsnippet snippet responds "Responds to Selector" if ([${1:self} respondsToSelector:@selector(${2:someSelector:})]) { - [$1 ${3:${2/((:\s*$)|(:\s*))/:<>(?3: )/g}}]; + [$1 ${3:${2/((:\s*$)|(:\s*))/:<>(?3: )/g}}]; } endsnippet diff --git a/sources_non_forked/vim-snippets/UltiSnips/ocaml.snippets b/sources_non_forked/vim-snippets/UltiSnips/ocaml.snippets index 157eb91a..1ebc3477 100644 --- a/sources_non_forked/vim-snippets/UltiSnips/ocaml.snippets +++ b/sources_non_forked/vim-snippets/UltiSnips/ocaml.snippets @@ -1,20 +1,22 @@ +priority -50 + snippet rs "raise" b raise (${1:Not_found}) endsnippet snippet open "open" let open ${1:module} in -${2} +${2:e} endsnippet snippet try "try" -try ${1} +try ${1:e} with ${2:Not_found} -> ${3:()} endsnippet snippet ref "ref" -let ${1} = ref ${2} in -${3} +let ${1:name} = ref ${2:val} in +${3:e} endsnippet snippet matchl "pattern match on a list" @@ -24,83 +26,88 @@ match ${1:list} with endsnippet snippet matcho "pattern match on an option type" -match ${1} with -| Some(${2}) -> ${3:()} +match ${1:x} with +| Some(${2:y}) -> ${3:()} | None -> ${4:()} endsnippet snippet fun "anonymous function" -(fun ${1} -> ${2}) +(fun ${1:x} -> ${2:x}) endsnippet snippet cc "commment" -(* ${1} *) +(* ${1:comment} *) endsnippet snippet let "let .. in binding" -let ${1} = ${2} in -${3} +let ${1:x} = ${2:v} in +${3:e} endsnippet snippet lr "let rec" -let rec ${1} = - ${2} +let rec ${1:f} = + ${2:expr} endsnippet -snippet ife "if" -if ${1} then - ${2} +snippet if "if" +if ${1:(* condition *)} then + ${2:(* A *)} else - ${3} + ${3:(* B *)} endsnippet -snippet if "If" -if ${1} then - ${2} +snippet If "If" +if ${1:(* condition *)} then + ${2:(* A *)} endsnippet -snippet wh "while" -while ${1} do - ${2} +snippet while "while" +while ${1:(* condition *)} do + ${2:(* A *)} done endsnippet snippet for "for" for ${1:i} = ${2:1} to ${3:10} do - ${4} + ${4:(* BODY *)} done endsnippet snippet match "match" -match ${1} with -| ${2} -> ${3} +match ${1:(* e1 *)} with +| ${2:p} -> ${3:e2} +endsnippet + +snippet Match "match" +match ${1:(* e1 *)} with +| ${2:p} -> ${3:e2} endsnippet snippet class "class" class ${1:name} = object - ${2} + ${2:methods} end endsnippet snippet obj "obj" object - ${2} + ${2:methods} end endsnippet snippet Obj "object" object (self) - ${2} + ${2:methods} end endsnippet snippet {{ "object functional update" -{< ${1} = ${2} >} +{< ${1:x} = ${2:y} >} endsnippet snippet beg "beg" begin - ${1}${VISUAL} + ${1:block} end endsnippet @@ -110,19 +117,19 @@ endsnippet snippet mod "module - no signature" module ${1:(* Name *)} = struct - ${2} + ${2:(* BODY *)} end endsnippet snippet Mod "module with signature" module ${1:(* Name *)} : ${2:(* SIG *)} = struct - ${3} + ${3:(* BODY *)} end endsnippet snippet sig "anonymous signature" sig - ${2} + ${2:(* BODY *)} end endsnippet @@ -132,36 +139,36 @@ endsnippet snippet func "define functor - no signature" module ${1:M} (${2:Arg} : ${3:ARG}) = struct - ${4} + ${4:(* BODY *)} end endsnippet snippet Func "define functor - with signature" module ${1:M} (${2:Arg} : ${3:ARG}) : ${4:SIG} = struct - ${5} + ${5:(* BODY *)} end endsnippet snippet mot "Declare module signature" module type ${1:(* Name *)} = sig - ${2} + ${2:(* BODY *)} end endsnippet snippet module "Module with anonymous signature" module ${1:(* Name *)} : sig - ${2} + ${2:(* SIGNATURE *)} end = struct - ${3} + ${3:(* BODY *)} end endsnippet snippet oo "odoc" -(** ${1} *) +(** ${1:odoc} *) endsnippet snippet qt "inline qtest" (*$T ${1:name} - ${2:test} + ${2:test} *) endsnippet diff --git a/sources_non_forked/vim-snippets/UltiSnips/perl.snippets b/sources_non_forked/vim-snippets/UltiSnips/perl.snippets index e183b115..abaae3f5 100644 --- a/sources_non_forked/vim-snippets/UltiSnips/perl.snippets +++ b/sources_non_forked/vim-snippets/UltiSnips/perl.snippets @@ -1,10 +1,13 @@ +priority -50 + ########################################################################### # TextMate Snippets # ########################################################################### snippet ife "Conditional if..else (ife)" if ($1) { ${2:# body...} -} else { +} +else { ${3:# else...} } @@ -13,9 +16,11 @@ endsnippet snippet ifee "Conditional if..elsif..else (ifee)" if ($1) { ${2:# body...} -} elsif ($3) { +} +elsif ($3) { ${4:# elsif...} -} else { +} +else { ${5:# else...} } @@ -49,7 +54,7 @@ ${1:expression} while ${2:condition}; endsnippet snippet test "Test" -#!/usr/bin/perl -w +#!/usr/bin/env perl -w use strict; use Test::More tests => ${1:1}; @@ -62,7 +67,7 @@ endsnippet snippet class "class" package ${1:ClassName}; -${2:use base qw(${3:ParentClass});}${2/.+/\n\n/}sub new { +${2:use parent qw(${3:ParentClass});}${2/.+/\n\n/}sub new { my $class = shift; $class = ref $class if ref $class; my $self = bless {}, $class; @@ -74,11 +79,12 @@ ${2:use base qw(${3:ParentClass});}${2/.+/\n\n/}sub new { endsnippet snippet eval "eval" +local $@; eval { ${1:# do something risky...} }; -if ($@) { - ${2:# handle failure...} +if (my $${2:exception} = $@) { + ${3:# handle failure...} } endsnippet @@ -105,8 +111,7 @@ if ($1) { endsnippet snippet slurp "slurp" -my $${1:var}; -{ local $/ = undef; local *FILE; open FILE, "<${2:file}"; $$1 = ; close FILE } +my $${1:var} = do { local $/ = undef; open my $fh, '<', ${2:$file}; <$fh> }; endsnippet @@ -117,7 +122,7 @@ unless ($1) { endsnippet -snippet wh "while" +snippet while "while" while ($1) { ${2:# body...} } diff --git a/sources_non_forked/vim-snippets/UltiSnips/php.snippets b/sources_non_forked/vim-snippets/UltiSnips/php.snippets index b7d01670..24f6cc52 100644 --- a/sources_non_forked/vim-snippets/UltiSnips/php.snippets +++ b/sources_non_forked/vim-snippets/UltiSnips/php.snippets @@ -1,108 +1,264 @@ -snippet ${3});${4} endsnippet -snippet vdd "php var_dump and die" -var_dump(${1}); die(); +snippet def "def" +define('${1}'${2});${3} endsnippet -snippet ns "php namespace" b -namespace ${1:`!p -abspath = os.path.abspath(path) -m = re.search(r'[A-Z].+(?=/)', abspath) -if m: - snip.rv = m.group().replace('/', '\\') -`}; - +snippet do "do" +do { + ${2:// code... } +} while (${1:/* condition */});" endsnippet -snippet nc "php namespace and class or interface" b -namespace ${1:`!p -abspath = os.path.abspath(path) -m = re.search(r'[A-Z].+(?=/)', abspath) -if m: - snip.rv = m.group().replace('/', '\\') -`}; - +snippet doc_f "doc_f" /** - * ${3:@author `whoami`}${4} - */ -`!p -m = re.search(r'Abstract', path) -if m: - snip.rv = 'abstract ' -``!p -if re.search(r'Interface', path): - snip.rv = 'interface' -elif re.search(r'Trait', path): - snip.rv = 'trait' -else: - snip.rv = 'class' -` ${2:`!p -snip.rv = re.match(r'.*(?=\.)', fn).group() -`} -{ + * $2 + * @return ${4:void} + * @author ${5:`!v g:snips_author`} + **/ +${1:public }function ${2:someFunc}(${3}) +{${6} } endsnippet -snippet st "php static function" b -${1:public} static function $2($3) -{ - ${4} -} -endsnippet - -snippet __ "php constructor" b -${1:public} function __construct($2) -{ - ${3} -} -endsnippet - -snippet sg "Setter and Getter" b +snippet doc_i "doc_i" /** - * @var ${3:`!p snip.rv = t[2][0:1].upper() + t[2][1:]`} - * - * ${4} + * $1 + * @package ${2:default} + * @author ${3:`!v g:snips_author`} + **/ +interface ${1:someClass} +{${4} +} // END interface $1" +endsnippet + +snippet else "else" +else { + ${1:// code...} +} +endsnippet + +snippet for "for" +for ($${2:i} = 0; $$2 < ${1:count}; $$2${3:++}) { + ${4:// code...} +} +endsnippet + +snippet foreachk "foreachk" +foreach ($${1:variable} as $${2:key} => $${3:value}){ + ${4:// code...} +} +endsnippet + +snippet get "get" +$_GET['${1}']${2} +endsnippet + +snippet if "if" +if (${1:/* condition */}) { + ${2:// code...} +} +endsnippet + +snippet inc "inc" +include '${1:file}';${2} +endsnippet + +snippet log "log" +error_log(var_export(${1}, true));${2} +endsnippet + +snippet post "post" +$_POST['${1}']${2} +endsnippet + +snippet req1 "req1" +require_once '${1:file}';${2} +endsnippet + +snippet session "session" +$_SESSION['${1}']${2} +endsnippet + +snippet t "t" +$${1:retVal} = (${2:condition}) ? ${3:a} : ${4:b};${5} +endsnippet + +snippet var "var" +var_export(${1});${2} +endsnippet + +snippet getter "PHP Class Getter" b +/* + * Getter for $1 */ -${1:protected} $${2}; - -public function set`!p snip.rv = t[2][0:1].upper() + t[2][1:]`(`!p -if re.match(r'^(\\|[A-Z]).*', t[3]): - snip.rv = t[3] + ' ' -else: - snip.rv = '' -`$$2) +public function get${1/\w+\s*/\u$0/}() { - $this->$2 = $$2; - - return $this; -} - -public function get`!p snip.rv = t[2][0:1].upper() + t[2][1:]`() -{ - return $this->$2; + return $this->$1;$2 } +$4 endsnippet -snippet if "php if" !b -if (${1}) { - ${2} +snippet setter "PHP Class Setter" b +/* + * Setter for $1 + */ +public function set${1/\w+\s*/\u$0/}($$1) +{ + $this->$1 = $$1;$3 + ${4:return $this;} } +$0 endsnippet -snippet ife "php ife" !b -if (${1}) { - ${2} +snippet gs "PHP Class Getter Setter" b +/* + * Getter for ${1/(\w+)\s*;/$1/} + */ +public function get${1/(\w+)\s*;/\u$1/}() +{ + return $this->${1/(\w+)\s*;/$1/};$2 +} + +/* + * Setter for ${1/(\w+)\s*;/$1/} + */ +public function set${1/(\w+)\s*;/\u$1/}($${1/(\w+)\s*;/$1/}) +{ + $this->${1/(\w+)\s*;/$1/} = $${1/(\w+)\s*;/$1/};$3 + ${4:return $this;} +} +$0 +endsnippet + +snippet pub "Public function" b +public function ${1:name}(${2:$param}) +{ + ${VISUAL}${3:return null;} +} +$0 +endsnippet + +snippet pro "Protected function" b +protected function ${1:name}(${2:$param}) +{ + ${VISUAL}${3:return null;} +} +$0 +endsnippet + +snippet pri "Private function" b +private function ${1:name}(${2:$param}) +{ + ${VISUAL}${3:return null;} +} +$0 +endsnippet + +snippet pubs "Public static function" b +public static function ${1:name}(${2:$param}) +{ + ${VISUAL}${3:return null;} +} +$0 +endsnippet + +snippet pros "Protected static function" b +protected static function ${1:name}(${2:$param}) +{ + ${VISUAL}${3:return null;} +} +$0 +endsnippet + +snippet pris "Private static function" b +private static function ${1:name}(${2:$param}) +{ + ${VISUAL}${3:return null;} +} +$0 +endsnippet + +snippet fu "Function snip" b +function ${1:name}(${2:$param}) +{ + ${VISUAL}${3:return null;} +} +$0 +endsnippet + +snippet fore "Foreach loop" +foreach ($${1:variable} as $${3:value}){ + ${VISUAL}${4} +} +$0 +endsnippet + +snippet new "New class instance" b +$$1 = new $1($2); +$0 +endsnippet + +snippet ife "if else" +if (${1:/* condition */}) { + ${2:// code...} } else { + ${3:// code...} +} +$0 +endsnippet +snippet class "Class declaration template" b +/** + * Class ${1:`!p snip.rv=snip.fn.split('.')[0]`} + * @author ${2:`!v g:snips_author`} + */ +class $1 +{ + public function ${3:__construct}(${4:$options}) + { + ${4:// code} + } +} +$0 +endsnippet + +snippet construct "__construct()" b +/** + * @param $2mixed ${1/, /\n * \@param mixed /g} + */ +public function __construct(${1:$dependencies}) +{${1/\$(\w+)(, )*/\n $this->$1 = $$1;/g} +} +$0 +endsnippet + +snippet pr "Dumb debug helper in HTML" +echo '
    ' . var_export($1, 1) . '
    ';$0 +endsnippet + +snippet pc "Dumb debug helper in cli" +var_export($1);$0 +endsnippet + +# Symfony 2 based snippets +snippet sfa "Symfony 2 Controller action" +/** +* @Route("/${1:route_name}", name="$1") +* @Template() +*/ +public function $1Action($2) +{ + $3 + return ${4:array();}$0 } endsnippet -snippet /** "php comment block" b -/** - * @${1} - */ -endsnippet +# :vim:ft=snippets: diff --git a/sources_non_forked/vim-snippets/UltiSnips/php/phpunit.snippets b/sources_non_forked/vim-snippets/UltiSnips/php_phpunit.snippets similarity index 90% rename from sources_non_forked/vim-snippets/UltiSnips/php/phpunit.snippets rename to sources_non_forked/vim-snippets/UltiSnips/php_phpunit.snippets index 6609f3fa..1a310a19 100644 --- a/sources_non_forked/vim-snippets/UltiSnips/php/phpunit.snippets +++ b/sources_non_forked/vim-snippets/UltiSnips/php_phpunit.snippets @@ -1,7 +1,9 @@ -# sugguestion? report bugs? +# suggestion? report bugs? # please go to https://github.com/chrisyue/vim-snippets/issues +priority -50 + snippet test "phpunit test class" b -namespace `!p +namespace `!p abspath = os.path.abspath(path) m = re.search(r'[A-Z].+(?=/)', abspath) if m: diff --git a/sources_non_forked/vim-snippets/UltiSnips/php/symfony2.snippets b/sources_non_forked/vim-snippets/UltiSnips/php_symfony2.snippets similarity index 94% rename from sources_non_forked/vim-snippets/UltiSnips/php/symfony2.snippets rename to sources_non_forked/vim-snippets/UltiSnips/php_symfony2.snippets index 77f923f6..3d433169 100644 --- a/sources_non_forked/vim-snippets/UltiSnips/php/symfony2.snippets +++ b/sources_non_forked/vim-snippets/UltiSnips/php_symfony2.snippets @@ -1,8 +1,10 @@ -# sugguestion? report bugs? +# sugguestion? report bugs? # go to https://github.com/chrisyue/vim-snippets/issues +priority -50 + snippet contr "Symfony2 controller" b -namespace `!p +namespace `!p abspath = os.path.abspath(path) m = re.search(r'[A-Z].+(?=/)', abspath) if m: @@ -52,7 +54,7 @@ abspath = os.path.abspath(path)` endsnippet snippet comm "Symfony2 command" b -namespace `!p +namespace `!p abspath = os.path.abspath(path) m = re.search(r'[A-Z].+(?=/)', abspath) if m: @@ -89,7 +91,7 @@ snip.rv = re.match(r'.*(?=\.)', fn).group() endsnippet snippet subs "Symfony2 subscriber" b -namespace `!p +namespace `!p abspath = os.path.abspath(path) m = re.search(r'[A-Z].+(?=/)', abspath) if m: @@ -120,7 +122,7 @@ snip.rv = re.match(r'.*(?=\.)', fn).group() endsnippet snippet transf "Symfony2 form data transformer" b -namespace `!p +namespace `!p abspath = os.path.abspath(path) m = re.search(r'[A-Z].+(?=/)', abspath) if m: @@ -154,7 +156,7 @@ snip.rv = re.match(r'.*(?=\.)', fn).group() endsnippet snippet ent "Symfony2 doctrine entity" b -namespace `!p +namespace `!p abspath = os.path.abspath(path) m = re.search(r'[A-Z].+(?=/)', abspath) if m: @@ -167,7 +169,7 @@ use Doctrine\ORM\Mapping as ORM; * ${3:@author `whoami`} * * @ORM\Entity() - * @ORM\Table(name="`!p + * @ORM\Table(name="`!p tmp = re.match(r'.*(?=\.)', fn).group() tmp = re.sub(r'\B([A-Z])', r'_\1', tmp) snip.rv = tmp.lower() @@ -191,7 +193,7 @@ snip.rv = re.match(r'.*(?=\.)', fn).group() endsnippet snippet form "Symfony2 form type" b -namespace `!p +namespace `!p abspath = os.path.abspath(path) m = re.search(r'[A-Z].+(?=/)', abspath) if m: @@ -209,33 +211,33 @@ class `!p snip.rv = re.match(r'.*(?=\.)', fn).group() ` extends AbstractType { - /** - * {@inheritDoc} + /** + * {@inheritDoc} */ public function buildForm(FormBuilderInterface $builder, array $options) - { + { } - /** - * {@inheritDoc} + /** + * {@inheritDoc} */ public function setDefaultOptions(OptionsResolverInterface $resolver) - { - $resolver->setDefaults(); - } + { + $resolver->setDefaults(); + } - /** - * {@inheritDoc} + /** + * {@inheritDoc} */ public function getName() - { + { return '${1}'; } } endsnippet snippet ev "Symfony2 event" b -namespace `!p +namespace `!p abspath = os.path.abspath(path) m = re.search(r'[A-Z].+(?=/)', abspath) if m: diff --git a/sources_non_forked/vim-snippets/UltiSnips/puppet.snippets b/sources_non_forked/vim-snippets/UltiSnips/puppet.snippets index 68ae0fe4..1b2cfc57 100644 --- a/sources_non_forked/vim-snippets/UltiSnips/puppet.snippets +++ b/sources_non_forked/vim-snippets/UltiSnips/puppet.snippets @@ -1,78 +1,235 @@ -# Snippets for Puppet +priority -50 -snippet /^class/ "Class declaration" r -class ${1:name} { - ${0:# body} +######################################################################### +# Python helper code # +######################################################################### + +global !p +import vim +import os.path +def get_module_namespace_and_basename(): + """This function will try to guess the current class or define name you are + trying to create. Note that for this to work you should be using the module + structure as per the style guide. Examples inputs and it's output + * /home/nikolavp/puppet/modules/collectd/manifests/init.pp -> collectd + * /home/nikolavp/puppet/modules/collectd/manfistes/mysql.pp -> collectd::mysql + """ + first_time = True + current_file_path_without_ext = vim.eval('expand("%:p:r")') or "" + if not current_file_path_without_ext: + return "name" + parts = os.path.split(current_file_path_without_ext) + namespace = '' + while parts[0] and parts[0] != '/': + if parts[1] == 'init' and first_time and not namespace: + first_time = False + parts = os.path.split(parts[0]) + continue + if parts[1] == 'manifests': + return os.path.split(parts[0])[1] + ('::' + namespace).rstrip(':') + else: + namespace = parts[1] + '::' + namespace + parts = os.path.split(parts[0]) + # couldn't guess the namespace. The user is editing a raw file in no module like the site.pp file + return "name" +endglobal + +############################################################################### +# Puppet Language Constructs # +# See http://docs.puppetlabs.com/puppet/latest/reference/lang_summary.html # +############################################################################### + +snippet class "Class declaration" b +class ${1:`!p snip.rv = get_module_namespace_and_basename()`} { + ${0:# body} +} +endsnippet + +snippet define "Definition" b +define ${1:`!p snip.rv = get_module_namespace_and_basename()`} { + ${0:# body} +} +endsnippet + +################################################################# +# Puppet Types # +# See http://docs.puppetlabs.com/references/latest/type.html # +################################################################# + +snippet cron "Cron resource type" b +cron { '${1:name}': + user => ${2:user}, + command => '${3:command}', + minute => ${3:minute}, + hour => ${4:hour}, +} +endsnippet + +snippet exec "Exec resource type" b +exec { '${1:command}': + refreshonly => true, +} +endsnippet + +snippet file "File resource type" b +file { '${1:name}': + source => "puppet://${2:path}", + mode => ${3:mode}, } endsnippet snippet File "Defaults for file" b File { - owner => ${1:username}, - group => ${2:groupname}, + owner => ${1:username}, + group => ${2:groupname}, } endsnippet -# Resource types -snippet package "Package resource type" b -package { "${1:name}": - ensure => ${2:installed}, -} -endsnippet - -snippet file "File resource type" b -file { "${1:name}": - source => "puppet://${2:path}", - mode => ${3:mode}, -endsnippet - snippet group "Group resource type" b -group { "${1:groupname}": - ensure => ${3:present}, - gid => ${2:gid}, -endsnippet - -snippet user "user resource type" b -group { "${1:username}": - ensure => ${2:present}, - uid => ${3:uid}, - gid => ${4:gid}, - comment => ${5:gecos}, - home => ${6:homedirectory}, - managehome => false, - require => Group["${7:group"], -endsnippet - -snippet exec "Exec resource type" b -exec { "${1:command}": - refreshonly => true, -} -endsnippet - -snippet cron "Cron resource type" b -cron { "${1:name}": - user => ${2:user}, - command => "${3:command}", - minute => ${3:minute}, - hour => ${4:hour}, +group { '${1:groupname}': + ensure => ${3:present}, + gid => ${2:gid}, } endsnippet snippet mount "Mount resource type" b -mount { "${1:path}": - device => "${2:/dev}", - fstype => "${3:filesystem}", - ensure => mounted, - options => "rw,errors=remount-ro", +mount { '${1:path}': + device => '${2:/dev}', + fstype => '${3:filesystem}', + ensure => mounted, + options => 'rw,errors=remount-ro', +} +endsnippet + +snippet package "Package resource type" b +package { '${1:name}': + ensure => ${2:installed}, +} +endsnippet + +snippet user "user resource type" b +user { '${1:username}': + ensure => ${2:present}, + uid => ${3:uid}, + gid => ${4:gid}, + comment => ${5:gecos}, + home => ${6:homedirectory}, + managehome => false, + require => Group['${7:group'}], } endsnippet snippet service "Service resource type" b -service { "${1:name}": - hasstatus => true, - enable => true, - ensure => running, +service { '${1:name}': + hasstatus => true, + enable => true, + ensure => running, } endsnippet +######################################################################## +# Puppet Functions # +# See http://docs.puppetlabs.com/references/latest/function.html # +######################################################################## + +snippet alert "Alert Function" b +alert("${1:message}")${0} +endsnippet + +snippet crit "Crit Function" b +crit("${1:message}")${0} +endsnippet + +snippet debug "Debug Function" b +debug("${1:message}")${0} +endsnippet + +snippet defined "Defined Function" b +defined(${1:Resource}["${2:name}"])${0} +endsnippet + +snippet emerg "Emerg Function" b +emerg("${1:message}")${0} +endsnippet + +snippet extlookup "Simple Extlookup" b +$${1:Variable} = extlookup("${2:Lookup}")${0} +endsnippet + +snippet extlookup "Extlookup with defaults" b +$${1:Variable} = extlookup("${2:Lookup}", ${3:Default})${0} +endsnippet + +snippet extlookup "Extlookup with defaults and custom data file" b +$${1:Variable} = extlookup("${2:Lookup}", ${3:Default}, ${4:Data Source})${0} +endsnippet + +snippet fail "Fail Function" b +fail("${1:message}")${0} +endsnippet + +snippet hiera "Hiera Function" b +$${1:Variable} = hiera("${2:Lookup}")${0} +endsnippet + +snippet hiera "Hiera with defaults" b +$${1:Variable} = hiera("${2:Lookup}", ${3:Default})${0} +endsnippet + +snippet hiera "Hiera with defaults and override" b +$${1:Variable} = hiera("${2:Lookup}", ${3:Default}, ${4:Override})${0} +endsnippet + +snippet hiera_hash "Hiera Hash Function" b +$${1:Variable} = hiera_hash("${2:Lookup}")${0} +endsnippet + +snippet hiera_hash "Hiera Hash with defaults" b +$${1:Variable} = hiera_hash("${2:Lookup}", ${3:Default})${0} +endsnippet + +snippet hiera_hash "Hiera Hash with defaults and override" b +$${1:Variable} = hiera_hash("${2:Lookup}", ${3:Default}, ${4:Override})${0} +endsnippet + +snippet hiera_include "Hiera Include Function" b +hiera_include("${1:Lookup}")${0} +endsnippet + +snippet include "Include Function" b +include ${1:classname}${0} +endsnippet + +snippet info "Info Function" b +info("${1:message}")${0} +endsnippet + +snippet inline_template "Inline Template Function" b +inline_template("<%= ${1:template} %>")${0} +endsnippet + +snippet notice "Notice Function" b +notice("${1:message}")${0} +endsnippet + +snippet realize "Realize Function" b +realize(${1:Resource}["${2:name}"])${0} +endsnippet + +snippet regsubst "Regsubst Function" b +regsubst($${1:Target}, '${2:regexp}', '${3:replacement}')${0} +endsnippet + +snippet split "Split Function" b +$${1:Variable} = split($${1:Target}, '${2:regexp}')${0} +endsnippet + +snippet versioncmp "Version Compare Function" b +$${1:Variable} = versioncmp('${1:version}', '${2:version}')${0} +endsnippet + +snippet warning "Warning Function" b +warning("${1:message}")${0} +endsnippet + # vim:ft=snippets: diff --git a/sources_non_forked/vim-snippets/UltiSnips/python.snippets b/sources_non_forked/vim-snippets/UltiSnips/python.snippets index a770d2a9..357d01d3 100644 --- a/sources_non_forked/vim-snippets/UltiSnips/python.snippets +++ b/sources_non_forked/vim-snippets/UltiSnips/python.snippets @@ -1,3 +1,5 @@ +priority -50 + ########################################################################### # TEXTMATE SNIPPETS # ########################################################################### @@ -14,6 +16,10 @@ if __name__ == '__main__': ${1:main()}$0 endsnippet +snippet for "for loop" b +for ${1:item} in ${2:iterable}: + ${3:pass} +endsnippet ########## # COMMON # @@ -29,67 +35,81 @@ NORMAL = 0x1 DOXYGEN = 0x2 SPHINX = 0x3 +SINGLE_QUOTES = 0x1 +DOUBLE_QUOTES = 0x2 + def get_args(arglist): - args = [arg.split('=')[0].strip() for arg in arglist.split(',') if arg] - args = [arg for arg in args if arg and arg != "self"] + args = [arg.split('=')[0].strip() for arg in arglist.split(',') if arg] + args = [arg for arg in args if arg and arg != "self"] - return args + return args +def get_quoting_style(snip): + style = snip.opt("g:ultisnips_python_quoting_style", "double") + if style == 'single': + return SINGLE_QUOTES + return DOUBLE_QUOTES + +def tripple_quotes(snip): + if get_quoting_style(snip) == SINGLE_QUOTES: + return "'''" + return '"""' + def get_style(snip): - style = snip.opt("g:ultisnips_python_style", "normal") + style = snip.opt("g:ultisnips_python_style", "normal") - if style == "doxygen": return DOXYGEN - elif style == "sphinx": return SPHINX - else: return NORMAL + if style == "doxygen": return DOXYGEN + elif style == "sphinx": return SPHINX + else: return NORMAL def format_arg(arg, style): - if style == DOXYGEN: - return "@param %s @todo" % arg - elif style == SPHINX: - return ":param %s: @todo" % arg - elif style == NORMAL: - return ":%s: @todo" % arg + if style == DOXYGEN: + return "@param %s @todo" % arg + elif style == SPHINX: + return ":param %s: @todo" % arg + elif style == NORMAL: + return ":%s: @todo" % arg def format_return(style): - if style == DOXYGEN: - return "@return: @todo" - elif style in (NORMAL, SPHINX): - return ":returns: @todo" + if style == DOXYGEN: + return "@return: @todo" + elif style in (NORMAL, SPHINX): + return ":returns: @todo" def write_docstring_args(args, snip): - if not args: - snip.rv += ' """' - return + if not args: + snip.rv += ' {0}'.format(tripple_quotes(snip)) + return - snip.rv += '\n' + snip.mkline('', indent='') + snip.rv += '\n' + snip.mkline('', indent='') - style = get_style(snip) + style = get_style(snip) - for arg in args: - snip += format_arg(arg, style) + for arg in args: + snip += format_arg(arg, style) def write_init_body(args, parents, snip): - parents = [p.strip() for p in parents.split(",")] - parents = [p for p in parents if p != 'object'] + parents = [p.strip() for p in parents.split(",")] + parents = [p for p in parents if p != 'object'] - for p in parents: - snip += p + ".__init__(self)" + for p in parents: + snip += p + ".__init__(self)" - if parents: - snip.rv += '\n' + snip.mkline('', indent='') + if parents: + snip.rv += '\n' + snip.mkline('', indent='') - for arg in args: - snip += "self._%s = %s" % (arg, arg) + for arg in args: + snip += "self._%s = %s" % (arg, arg) def write_slots_args(args, snip): - args = ['"%s"' % arg for arg in args] - snip += '__slots__ = (%s,)' % ', '.join(args) + args = ['"_%s"' % arg for arg in args] + snip += '__slots__ = (%s,)' % ', '.join(args) endglobal @@ -99,10 +119,11 @@ endglobal snippet class "class with docstrings" b class ${1:MyClass}(${2:object}): - """${3:Docstring for $1 }""" + + `!p snip.rv = tripple_quotes(snip)`${3:Docstring for $1. }`!p snip.rv = tripple_quotes(snip)` def __init__(self$4): - """${5:@todo: to be defined}`!p + `!p snip.rv = tripple_quotes(snip)`${5:@todo: to be defined1.}`!p snip.rv = "" snip >> 2 @@ -110,8 +131,8 @@ args = get_args(t[4]) write_docstring_args(args, snip) if args: - snip.rv += '\n' + snip.mkline('', indent='') - snip += '"""' + snip.rv += '\n' + snip.mkline('', indent='') + snip += '{0}'.format(tripple_quotes(snip)) write_init_body(args, t[2], snip) ` @@ -121,7 +142,8 @@ endsnippet snippet slotclass "class with slots and docstrings" b class ${1:MyClass}(${2:object}): - """${3:Docstring for $1 }""" + + `!p snip.rv = tripple_quotes(snip)`${3:Docstring for $1. }`!p snip.rv = tripple_quotes(snip)` `!p snip >> 1 args = get_args(t[4]) @@ -129,7 +151,7 @@ write_slots_args(args, snip) ` def __init__(self$4): - """${5:@todo: to be defined}`!p + `!p snip.rv = tripple_quotes(snip)`${5:@todo: to be defined.}`!p snip.rv = "" snip >> 2 @@ -137,8 +159,8 @@ args = get_args(t[4]) write_docstring_args(args, snip) if args: - snip.rv += '\n' + snip.mkline('', indent='') - snip += '"""' + snip.rv += '\n' + snip.mkline('', indent='') + snip += tripple_quotes(snip) write_init_body(args, t[2], snip) ` @@ -330,19 +352,19 @@ endsnippet snippet def "function with docstrings" b def ${1:function}(`!p if snip.indent: - snip.rv = 'self' + (", " if len(t[2]) else "")`${2:arg1}): - """${4:@todo: Docstring for $1}`!p + snip.rv = 'self' + (", " if len(t[2]) else "")`${2:arg1}): + `!p snip.rv = tripple_quotes(snip)`${4:@todo: Docstring for $1.}`!p snip.rv = "" snip >> 1 args = get_args(t[2]) if args: - write_docstring_args(args, snip) + write_docstring_args(args, snip) style = get_style(snip) snip += format_return(style) snip.rv += '\n' + snip.mkline('', indent='') -snip += '"""' ` +snip += tripple_quotes(snip) ` ${0:pass} endsnippet @@ -362,23 +384,57 @@ endsnippet ############## snippet roprop "Read Only Property" b @property -def ${1:property}(self): +def ${1:name}(self): ${2:return self._$1}$0 endsnippet snippet rwprop "Read write property" b -def ${1:property}(): - ${2/.+/(?0:""")/}${2:The RW property $1}`!p if t[2]: - snip.rv += '"""' - snip >> 1 - snip += "" +def ${1:name}(): + `!p snip.rv = tripple_quotes(snip) if t[2] else '' +`${2:@todo: Docstring for $1.}`!p +if t[2]: + snip >> 1 + + style = get_style(snip) + snip.rv += '\n' + snip.mkline('', indent='') + snip += format_return(style) + snip.rv += '\n' + snip.mkline('', indent='') + snip += tripple_quotes(snip) else: - snip.rv = ""`def fget(self): + snip.rv = ""` + def fget(self): return self._$1$0 + def fset(self, value): self._$1 = value return locals() -$1 = property(**$1()) + +$1 = property(**$1(), doc=$1.__doc__) +endsnippet + + +#################### +# If / Else / Elif # +#################### +snippet if "If" b +if ${1:condition}: + ${2:pass} +endsnippet + +snippet ife "If / Else" b +if ${1:condition}: + ${2:pass} +else: + ${3:pass} +endsnippet + +snippet ifee "If / Elif / Else" b +if ${1:condition}: + ${2:pass} +elif ${3:condition}: + ${4:pass} +else: + ${5:pass} endsnippet @@ -430,6 +486,14 @@ snippet pdb "Set PDB breakpoint" b import pdb; pdb.set_trace() endsnippet +snippet ipdb "Set IPDB breakpoint" b +import ipdb; ipdb.set_trace() +endsnippet + +snippet pudb "Set PUDB breakpoint" b +import pudb; pudb.set_trace() +endsnippet + snippet ae "Assert equal" b self.assertEqual(${1:first},${2:second}) endsnippet @@ -453,7 +517,8 @@ endsnippet snippet testcase "pyunit testcase" b class Test${1:Class}(${2:unittest.TestCase}): - """${3:Test case docstring}""" + + `!p snip.rv = tripple_quotes(snip)`${3:Test case docstring.}`!p snip.rv = tripple_quotes(snip)` def setUp(self): ${4:pass} diff --git a/sources_non_forked/vim-snippets/UltiSnips/rails.snippets b/sources_non_forked/vim-snippets/UltiSnips/rails.snippets index 9e0e29f8..5c521795 100644 --- a/sources_non_forked/vim-snippets/UltiSnips/rails.snippets +++ b/sources_non_forked/vim-snippets/UltiSnips/rails.snippets @@ -1,6 +1,4 @@ -########################################################################### -# GENERATED FROM get_tm_snippets.py # -########################################################################### +priority -50 snippet anaf "accepts_nested_attributes_for" accepts_nested_attributes_for :${1:association_name}${2:${3:, :allow_destroy => true}${4:, :reject_if => proc \{ |obj| ${5:obj.blank?} \}}} @@ -77,90 +75,90 @@ endsnippet snippet resources "Create resources controller class" class ${1:Model}sController < ApplicationController - before_filter :find_${1/./\l$0/}, :only => [:show, :edit, :update, :destroy] + before_filter :find_${1/./\l$0/}, :only => [:show, :edit, :update, :destroy] - # GET /${1/./\l$0/}s - # GET /${1/./\l$0/}s.xml - def index - @${1/./\l$0/}s = ${1:Model}.all + # GET /${1/./\l$0/}s + # GET /${1/./\l$0/}s.xml + def index + @${1/./\l$0/}s = ${1:Model}.all - respond_to do |wants| - wants.html # index.html.erb - wants.xml { render :xml => @${1/./\l$0/}s } - end - end + respond_to do |wants| + wants.html # index.html.erb + wants.xml { render :xml => @${1/./\l$0/}s } + end + end - # GET /${1/./\l$0/}s/1 - # GET /${1/./\l$0/}s/1.xml - def show - respond_to do |wants| - wants.html # show.html.erb - wants.xml { render :xml => @${1/./\l$0/} } - end - end + # GET /${1/./\l$0/}s/1 + # GET /${1/./\l$0/}s/1.xml + def show + respond_to do |wants| + wants.html # show.html.erb + wants.xml { render :xml => @${1/./\l$0/} } + end + end - # GET /${1/./\l$0/}s/new - # GET /${1/./\l$0/}s/new.xml - def new - @${1/./\l$0/} = ${1:Model}.new + # GET /${1/./\l$0/}s/new + # GET /${1/./\l$0/}s/new.xml + def new + @${1/./\l$0/} = ${1:Model}.new - respond_to do |wants| - wants.html # new.html.erb - wants.xml { render :xml => @${1/./\l$0/} } - end - end + respond_to do |wants| + wants.html # new.html.erb + wants.xml { render :xml => @${1/./\l$0/} } + end + end - # GET /${1/./\l$0/}s/1/edit - def edit - end + # GET /${1/./\l$0/}s/1/edit + def edit + end - # POST /${1/./\l$0/}s - # POST /${1/./\l$0/}s.xml - def create - @${1/./\l$0/} = ${1:Model}.new(params[:${1/./\l$0/}]) + # POST /${1/./\l$0/}s + # POST /${1/./\l$0/}s.xml + def create + @${1/./\l$0/} = ${1:Model}.new(params[:${1/./\l$0/}]) - respond_to do |wants| - if @${1/./\l$0/}.save - flash[:notice] = '${1:Model} was successfully created.' - wants.html { redirect_to(@${1/./\l$0/}) } - wants.xml { render :xml => @${1/./\l$0/}, :status => :created, :location => @${1/./\l$0/} } - else - wants.html { render :action => "new" } - wants.xml { render :xml => @${1/./\l$0/}.errors, :status => :unprocessable_entity } - end - end - end + respond_to do |wants| + if @${1/./\l$0/}.save + flash[:notice] = '${1:Model} was successfully created.' + wants.html { redirect_to(@${1/./\l$0/}) } + wants.xml { render :xml => @${1/./\l$0/}, :status => :created, :location => @${1/./\l$0/} } + else + wants.html { render :action => "new" } + wants.xml { render :xml => @${1/./\l$0/}.errors, :status => :unprocessable_entity } + end + end + end - # PUT /${1/./\l$0/}s/1 - # PUT /${1/./\l$0/}s/1.xml - def update - respond_to do |wants| - if @${1/./\l$0/}.update_attributes(params[:${1/./\l$0/}]) - flash[:notice] = '${1:Model} was successfully updated.' - wants.html { redirect_to(@${1/./\l$0/}) } - wants.xml { head :ok } - else - wants.html { render :action => "edit" } - wants.xml { render :xml => @${1/./\l$0/}.errors, :status => :unprocessable_entity } - end - end - end + # PUT /${1/./\l$0/}s/1 + # PUT /${1/./\l$0/}s/1.xml + def update + respond_to do |wants| + if @${1/./\l$0/}.update_attributes(params[:${1/./\l$0/}]) + flash[:notice] = '${1:Model} was successfully updated.' + wants.html { redirect_to(@${1/./\l$0/}) } + wants.xml { head :ok } + else + wants.html { render :action => "edit" } + wants.xml { render :xml => @${1/./\l$0/}.errors, :status => :unprocessable_entity } + end + end + end - # DELETE /${1/./\l$0/}s/1 - # DELETE /${1/./\l$0/}s/1.xml - def destroy - @${1/./\l$0/}.destroy + # DELETE /${1/./\l$0/}s/1 + # DELETE /${1/./\l$0/}s/1.xml + def destroy + @${1/./\l$0/}.destroy - respond_to do |wants| - wants.html { redirect_to(${1/./\l$0/}s_url) } - wants.xml { head :ok } - end - end + respond_to do |wants| + wants.html { redirect_to(${1/./\l$0/}s_url) } + wants.xml { head :ok } + end + end - private - def find_${1/./\l$0/} - @${1/./\l$0/} = ${1:Model}.find(params[:id]) - end + private + def find_${1/./\l$0/} + @${1/./\l$0/} = ${1:Model}.find(params[:id]) + end end @@ -227,31 +225,31 @@ assert_response :${1:success}, @response.body$0 endsnippet snippet aftc "after_create" -after_create +after_create $0 endsnippet snippet aftd "after_destroy" -after_destroy +after_destroy $0 endsnippet snippet afts "after_save" -after_save +after_save $0 endsnippet snippet aftu "after_update" -after_update +after_update $0 endsnippet snippet aftv "after_validation" -after_validation +after_validation $0 endsnippet snippet aftvoc "after_validation_on_create" -after_validation_on_create +after_validation_on_create $0 endsnippet snippet aftvou "after_validation_on_update" -after_validation_on_update +after_validation_on_update $0 endsnippet snippet asg "assert(var = assigns(:var))" @@ -261,13 +259,13 @@ endsnippet snippet asd "assert_difference" assert_difference "${1:Model}.${2:count}", ${3:1} do - $0 + $0 end endsnippet snippet asnd "assert_no_difference" assert_no_difference "${1:Model}.${2:count}" do - $0 + $0 end endsnippet @@ -298,27 +296,27 @@ end} endsnippet snippet befc "before_create" -before_create +before_create $0 endsnippet snippet befd "before_destroy" -before_destroy +before_destroy $0 endsnippet snippet befs "before_save" -before_save +before_save $0 endsnippet snippet befu "before_update" -before_update +before_update $0 endsnippet snippet befv "before_validation" -before_validation +before_validation $0 endsnippet snippet befvoc "before_validation_on_create" -before_validation_on_create +before_validation_on_create $0 endsnippet snippet befvou "before_validation_on_update" @@ -456,13 +454,13 @@ endsnippet snippet mapr "map.resource" ${1:map}.resource :${2:resource}${10: do |${11:$2}| - $0 + $0 end} endsnippet snippet maprs "map.resources" ${1:map}.resources :${2:resource}${10: do |${11:$2}| - $0 + $0 end} endsnippet @@ -605,7 +603,7 @@ endsnippet snippet resw "respond_with" respond_with(${1:@${2:model}})${3: do |format| - format.${4:html} { $0 \} + format.${4:html} { $0 \} end} endsnippet @@ -807,32 +805,32 @@ endsnippet snippet sweeper "Create sweeper class" class ${1:Model}Sweeper < ActionController::Caching::Sweeper - observe ${1:Model} + observe ${1:Model} - def after_save(${1/./\l$0/}) - expire_cache(${1/./\l$0/}) - end + def after_save(${1/./\l$0/}) + expire_cache(${1/./\l$0/}) + end - def after_destroy(${1/./\l$0/}) - expire_cache(${1/./\l$0/}) - end + def after_destroy(${1/./\l$0/}) + expire_cache(${1/./\l$0/}) + end - private + private - def expire_cache(${1/./\l$0/}) - ${0:expire_page ${1/./\l$0/}s_path - expire_page ${1/./\l$0/}_path(${1/./\l$0/})} - end + def expire_cache(${1/./\l$0/}) + ${0:expire_page ${1/./\l$0/}s_path + expire_page ${1/./\l$0/}_path(${1/./\l$0/})} + end end endsnippet snippet col "collection routes" collection do - ${1:get :${2:action}} - ${3:put :${4:action}} - ${5:post :${6:action}} - ${7:delete :${8:action}} + ${1:get :${2:action}} + ${3:put :${4:action}} + ${5:post :${6:action}} + ${7:delete :${8:action}} end endsnippet @@ -854,16 +852,16 @@ endsnippet snippet member "member routes" member do - ${1:get :${2:action}} - ${3:put :${4:action}} - ${5:post :${6:action}} - ${7:delete :${8:action}} + ${1:get :${2:action}} + ${3:put :${4:action}} + ${5:post :${6:action}} + ${7:delete :${8:action}} end endsnippet snippet res "resources" resources :${1:posts}${2: do - $3 + $3 end} endsnippet @@ -877,9 +875,9 @@ endsnippet snippet scopee "scope with extension" scope :${1:name}, ${2:where(${3::${4:field} => ${5:'${6:value}'}})} do - def ${7:method_name} - $0 - end + def ${7:method_name} + $0 + end end endsnippet @@ -893,13 +891,13 @@ setup do end endsnippet -snippet trans "Translation snippet" +snippet trans "Translation snippet" I18n.t('`!v substitute(substitute(substitute(@%, substitute(getcwd() . "/", "\/", "\\\\/", "g"), "", ""), "\\(\\.\\(html\\|js\\)\\.\\(haml\\|erb\\)\\|\\(_controller\\)\\?\\.rb\\)$", "", ""), "/", ".", "g")`.${2:${1/[^\w]/_/g}}${3}', :default => "${1:some_text}"${4})${5:$0} endsnippet snippet route_spec it 'routes to #${1:action}' do - ${2:get}('/${3:url}').should route_to('`!v substitute(expand('%:t:r'), '_routing_spec$', '', '')`#$1'${4:, ${5:params}})${6} + ${2:get}('/${3:url}').should route_to('`!v substitute(expand('%:t:r'), '_routing_spec$', '', '')`#$1'${4:, ${5:params}})${6} end endsnippet diff --git a/sources_non_forked/vim-snippets/UltiSnips/rst.snippets b/sources_non_forked/vim-snippets/UltiSnips/rst.snippets index 88e0caaf..e8aef2b2 100644 --- a/sources_non_forked/vim-snippets/UltiSnips/rst.snippets +++ b/sources_non_forked/vim-snippets/UltiSnips/rst.snippets @@ -1,7 +1,9 @@ # -*- coding: utf-8 -*- +priority -50 + ########################################################################### -# General Stuff # +# General Stuff # ########################################################################### global !p import vim @@ -12,25 +14,25 @@ from collections import Counter #http://docutils.sourceforge.net/docs/ref/rst/roles.html TEXT_ROLES = ['emphasis','literal','code','math', - 'pep-reference','rfc-reference', - 'strong','subscript','superscript', - 'title-reference','raw'] + 'pep-reference','rfc-reference', + 'strong','subscript','superscript', + 'title-reference','raw'] TEXT_ROLES_REGEX = r'\.\.\srole::?\s(w+)' #http://docutils.sourceforge.net/docs/ref/rst/directives.html#specific-admonitions -SPECIFIC_ADMONITIONS = ["attention", "caution", "danger", - "error", "hint", "important", "note", - "tip", "warning"] +SPECIFIC_ADMONITIONS = ["attention", "caution", "danger", + "error", "hint", "important", "note", + "tip", "warning"] #http://docutils.sourceforge.net/docs/ref/rst/directives.html DIRECTIVES = ['topic','sidebar','math','epigraph', - 'parsed-literal','code','highlights', - 'pull-quote','compound','container', - 'list-table','class','sectnum', - 'role','default-role','unicode', - 'raw'] + 'parsed-literal','code','highlights', + 'pull-quote','compound','container', + 'list-table','class','sectnum', + 'role','default-role','unicode', + 'raw'] NONE_CONTENT_DIRECTIVES = ['rubric', 'contents', 'header', - 'footer', 'date', 'include', 'title'] + 'footer', 'date', 'include', 'title'] INCLUDABLE_DIRECTIVES = ['image', 'figure', 'include'] # CJK chars @@ -39,115 +41,115 @@ CJK_RE = re.compile(u'[⺀-⺙⺛-⻳⼀-⿕々〇〡-〩〸-〺〻㐀-䶵一- def has_cjk(char): - """ - Detect char contains CJK character - - :param char: characters needs to be detect - """ - try: - CJK_RE.finditer(char).next() - except StopIteration: - return False - else: - return True + """ + Detect char contains CJK character + + :param char: characters needs to be detect + """ + try: + CJK_RE.finditer(char).next() + except StopIteration: + return False + else: + return True def real_filename(filename): - """peal extension name off if possible - # i.e. "foo.bar.png will return "foo.bar" + """pealeextension name off if possible + # i.e. "foo.bar.png will return "foo.bar" """ - return ospath.splitext(filename)[0] + return ospath.splitext(filename)[0] def check_file_exist(rst_path, relative_path): - """ - For RST file, it can just include files as relative path. - - :param rst_path: absolute path to rst file - :param relative_path: path related to rst file - :return: relative file's absolute path if file exist - """ - abs_path = ospath.join(ospath.dirname(rst_path), relative_path) - if ospath.isfile(abs_path): - return abs_path + """ + For RST file, it can just include files as relative path. + + :param rst_path: absolute path to rst file + :param relative_path: path related to rst file + :return: relative file's absolute path if file exist + """ + abs_path = ospath.join(ospath.dirname(rst_path), relative_path) + if ospath.isfile(abs_path): + return abs_path def rst_char_len(char): - """ - return len of string which fit in rst - For instance:chinese "我" decode as only one character, - However, the rst interpreter needs 2 "=" instead of 1. + """ + return len of string which fit in rst + For instance:chinese "我" decode as only one character, + However, the rst interpreter needs 2 "=" instead of 1. - :param: char needs to be count - """ - return len(re.findall(r'[^\u4e00-\u9fff\s]', char))+len(char) + :param: char needs to be count + """ + return len(re.findall(r'[^\u4e00-\u9fff\s]', char))+len(char) def make_items(times, leading='+'): - """ - make lines with leading char multitimes - - :param: times, how many times you need - :param: leading, leading character - """ - times = int(times) - if leading == 1: - msg = "" - for x in xrange(1, times+1): - msg += "%s. Item\n" % x - return msg - else: - return ("%s Item\n" % leading) * times + """ + make lines with leading char multitimes + + :param: times, how many times you need + :param: leading, leading character + """ + times = int(times) + if leading == 1: + msg = "" + for x in xrange(1, times+1): + msg += "%s. Item\n" % x + return msg + else: + return ("%s Item\n" % leading) * times def look_up_directives(regex, fpath): - """ - find all directive args in given file - :param: regex, the regex that needs to match - :param: path, to path to rst file + """ + find all directive args in given file + :param: regex, the regex that needs to match + :param: path, to path to rst file - :return: list, empty list if nothing match - """ - try: - with open(fpath) as source: - match = re.findall(regex, source.read()) - except IOError: - match = [] - return match + :return: list, empty list if nothing match + """ + try: + with open(fpath) as source: + match = re.findall(regex, source.read()) + except IOError: + match = [] + return match def get_popular_code_type(): - """ - find most popular code type in the given rst + """ + find most popular code type in the given rst - :param path: file to detect + :param path: file to detect + + :return: string, most popular code type in file + """ + buf = "".join(vim.current.buffer) + types = re.findall(r'[:|\.\.\s]code::?\s(\w+)', buf) + try: + popular_type = Counter(types).most_common()[0][0] + except IndexError: + popular_type = "lua" # Don't break default + return popular_type - :return: string, most popular code type in file - """ - buf = "".join(vim.current.buffer) - types = re.findall(r'[:|\.\.\s]code::?\s(\w+)', buf) - try: - popular_type = Counter(types).most_common()[0][0] - except IndexError: - popular_type = "lua" # Don't break default - return popular_type - def complete(t, opts): - """ - get options that start with t + """ + get options that start with t - :param t: query string - :param opts: list that needs to be completed + :param t: query string + :param opts: list that needs to be completed - :return: a string that start with t - """ - msg = "({0})" - if t: - opts = [ m[len(t):] for m in opts if m.startswith(t) ] - if len(opts) == 1: - return opts[0] + :return: a string that start with t + """ + msg = "({0})" + if t: + opts = [ m[len(t):] for m in opts if m.startswith(t) ] + if len(opts) == 1: + return opts[0] - if not len(opts): - msg = "{0}" - return msg.format("|".join(opts)) + if not len(opts): + msg = "{0}" + return msg.format("|".join(opts)) endglobal @@ -199,22 +201,22 @@ snippet em "Emphasize string" i `!p # dirty but works with CJK charactor detection if has_cjk(vim.current.line): - snip.rv ="\ "`*${1:${VISUAL:Em}}*`!p -if has_cjk(vim.current.line): - snip.rv ="\ " + snip.rv ="\ "`*${1:${VISUAL:Em}}*`!p +if has_cjk(vim.current.line): + snip.rv ="\ " else: - snip.rv = " " + snip.rv = " " `$0 endsnippet snippet st "Strong string" i -`!p +`!p if has_cjk(vim.current.line): - snip.rv ="\ "`**${1:${VISUAL:Strong}}**`!p -if has_cjk(vim.current.line): - snip.rv ="\ " + snip.rv ="\ "`**${1:${VISUAL:Strong}}**`!p +if has_cjk(vim.current.line): + snip.rv ="\ " else: - snip.rv = " " + snip.rv = " " `$0 endsnippet @@ -236,12 +238,12 @@ snip.rv = make_items(match.groupdict()['num'], 1) ` endsnippet ########################################################################### -# More Specialized Stuff. # +# More Specialized Stuff. # ########################################################################### snippet cb "Code Block" b .. code-block:: ${1:`!p snip.rv = get_popular_code_type()`} - ${2:code} + ${2:code} $0 endsnippet @@ -249,7 +251,7 @@ endsnippet # match snippets : # img, inc, fig snippet id "Includable Directives" b -`!p +`!p real_name=real_filename(ospath.basename(t[2])) di=t[1][:2] @@ -257,28 +259,28 @@ link="" content="" if di == 'im': - link = "|{0}|".format(real_name) + link = "|{0}|".format(real_name) if di == 'fi': - content=""" - :alt: {0} - {0}""".format(real_name) + content=""" + :alt: {0} + {0}""".format(real_name) ` ..`!p snip.rv = " %s" % link if link else ""` $1`!p snip.rv=complete(t[1], INCLUDABLE_DIRECTIVES)`:: ${2:file}`!p if content: - snip.rv +=" "+content` + snip.rv +=" "+content` `!p # Tip of whether file is exist in comment type if not check_file_exist(path, t[2]): - snip.rv='.. FILE {0} does not exist'.format(t[2]) + snip.rv='.. FILE {0} does not exist'.format(t[2]) else: - snip.rv="" + snip.rv="" `$0 endsnippet snippet di "Directives" b .. $1`!p snip.rv=complete(t[1], DIRECTIVES)`:: $2 - ${3:Content} + ${3:Content} $0 endsnippet @@ -289,8 +291,8 @@ endsnippet snippet sa "Specific Admonitions" b .. $1`!p snip.rv =complete(t[1], SPECIFIC_ADMONITIONS)`:: - - ${2:Content} + + ${2:Content} $0 endsnippet @@ -298,8 +300,8 @@ endsnippet #it will be trigger at start of line or after a word snippet ro "Text Roles" w \ :$1`!p snip.rv=complete(t[1], - TEXT_ROLES+look_up_directives(TEXT_ROLES_REGEX, - path))`:\`$2\`\ + TEXT_ROLES+look_up_directives(TEXT_ROLES_REGEX, + path))`:\`$2\`\ endsnippet ############ @@ -309,6 +311,6 @@ endsnippet snippet sid "SideBar" b .. sidebar:: ${1:SideBar Title} - ${2:SideBar Content} + ${2:SideBar Content} endsnippet # vim:ft=snippets: diff --git a/sources_non_forked/vim-snippets/UltiSnips/ruby.snippets b/sources_non_forked/vim-snippets/UltiSnips/ruby.snippets index 90001b1a..09a114f6 100644 --- a/sources_non_forked/vim-snippets/UltiSnips/ruby.snippets +++ b/sources_non_forked/vim-snippets/UltiSnips/ruby.snippets @@ -1,3 +1,5 @@ +priority -50 + snippet "^#!" "#!/usr/bin/env ruby" r #!/usr/bin/env ruby $0 @@ -25,7 +27,7 @@ endsnippet snippet if "if ... end" if ${1:condition} - ${2} + ${2:# TODO} end endsnippet @@ -33,9 +35,9 @@ endsnippet snippet ife "if ... else ... end" if ${1:condition} - ${2} + ${2:# TODO} else - ${3} + ${3:# TODO} end endsnippet @@ -43,11 +45,11 @@ endsnippet snippet ifee "if ... elseif ... else ... end" if ${1:condition} - ${2} + ${2:# TODO} elsif ${3:condition} - ${4} + ${4:# TODO} else - ${0} + ${0:# TODO} end endsnippet @@ -55,7 +57,7 @@ endsnippet snippet unless "unless ... end" unless ${1:condition} - ${0} + ${0:# TODO} end endsnippet @@ -63,9 +65,9 @@ endsnippet snippet unlesse "unless ... else ... end" unless ${1:condition} - ${2} + ${2:# TODO} else - ${0} + ${0:# TODO} end endsnippet @@ -73,11 +75,11 @@ endsnippet snippet unlesee "unless ... elseif ... else ... end" unless ${1:condition} - ${2} + ${2:# TODO} elsif ${3:condition} - ${4} + ${4:# TODO} else - ${0} + ${0:# TODO} end endsnippet @@ -85,7 +87,7 @@ endsnippet snippet "\b(de)?f" "def ..." r def ${1:function_name}${2: ${3:*args}} - ${0} + ${0:# TODO} end endsnippet @@ -93,7 +95,7 @@ endsnippet snippet defi "def initialize ..." def initialize${1: ${2:*args}} - ${0} + ${0:# TODO} end endsnippet @@ -101,23 +103,23 @@ endsnippet snippet defr "def ... rescue ..." def ${1:function_name}${2: ${3:*args}} - ${4} + ${4:# TODO} rescue - ${0} + ${0:# TODO} end endsnippet snippet For "(..).each { || }" -(${1:from}..${2:to}).each { |${3:i}| ${4} } +(${1:from}..${2:to}).each { |${3:i}| ${4:# TODO} } endsnippet snippet for "(..).each do || end" (${1:from}..${2:to}).each do |${3:i}| - ${0} + ${0:# TODO} end endsnippet @@ -138,42 +140,42 @@ endsnippet snippet "(\S+)\.Del(ete)?_?if" ".delete_if { |,| }" r -`!p snip.rv=match.group(1)`.delete_if { |${1:key},${2:value}| ${3} } +`!p snip.rv=match.group(1)`.delete_if { |${1:key},${2:value}| ${3:# TODO} } endsnippet snippet "(\S+)\.del(ete)?_?if" ".delete_if do |,| end" r `!p snip.rv=match.group(1)`.delete_if do |${1:key},${2:value}| - ${0} + ${0:# TODO} end endsnippet snippet "(\S+)\.Keep_?if" ".keep_if { |,| }" r -`!p snip.rv=match.group(1)`.keep_if { |${1:key},${2:value}| ${3} } +`!p snip.rv=match.group(1)`.keep_if { |${1:key},${2:value}| ${3:# TODO} } endsnippet snippet "(\S+)\.keep_?if" ".keep_if do ,| end" r `!p snip.rv=match.group(1)`.keep_if do |${1:key},${2:value}| - ${0} + ${0:# TODO} end endsnippet snippet "(\S+)\.Reject" ".reject { |,| }" r -`!p snip.rv=match.group(1)`.reject { |${1:key},${2:value}| ${3} } +`!p snip.rv=match.group(1)`.reject { |${1:key},${2:value}| ${3:# TODO} } endsnippet snippet "(\S+)\.reject" ".reject do ,| end" r `!p snip.rv=match.group(1)`.reject do |${1:key},${2:value}| - ${0} + ${0:# TODO} end endsnippet @@ -194,71 +196,71 @@ endsnippet snippet "(\S+)\.Sort" ".sort { |,| }" r -`!p snip.rv=match.group(1)`.sort { |${1:a},${2:b}| ${3} } +`!p snip.rv=match.group(1)`.sort { |${1:a},${2:b}| ${3:# TODO} } endsnippet snippet "(\S+)\.sort" ".sort do |,| end" r `!p snip.rv=match.group(1)`.sort do |${1:a},${2:b}| - ${0} + ${0:# TODO} end endsnippet snippet "(\S+)\.Each_?k(ey)?" ".each_key { || }" r -`!p snip.rv=match.group(1)`.each_key { |${1:key}| ${2} } +`!p snip.rv=match.group(1)`.each_key { |${1:key}| ${2:# TODO} } endsnippet snippet "(\S+)\.each_?k(ey)?" ".each_key do |key| end" r `!p snip.rv=match.group(1)`.each_key do |${1:key}| - ${0} + ${0:# TODO} end endsnippet snippet "(\S+)\.Each_?val(ue)?" ".each_value { || }" r -`!p snip.rv=match.group(1)`.each_value { |${1:value}| ${2} } +`!p snip.rv=match.group(1)`.each_value { |${1:value}| ${2:# TODO} } endsnippet snippet "(\S+)\.each_?val(ue)?" ".each_value do || end" r `!p snip.rv=match.group(1)`.each_value do |${1:value}| - ${0} + ${0:# TODO} end endsnippet snippet Each ".each { || }" -${1:elements}.each { |${2:${1/s$//}}| ${3} } +${1:elements}.each { |${2:${1/s$//}}| ${3:# TODO} } endsnippet snippet each ".each do || end" ${1:elements}.each do |${2:${1/s$//}}| - ${0} + ${0:# TODO} end endsnippet -snippet each_?s(lice)? ".each_slice(n) do |slice| end" -each_slice(${1:2}) do |${2:slice}| - ${0} +snippet "each_?s(lice)?" ".each_slice(n) do |slice| end" r +${1:elements}.each_slice(${2:2}) do |${3:slice}| + ${0:# TODO} end endsnippet -snippet Each_?s(lice)? ".each_slice(n) { |slice| }" -each_slice(${1:2}) { |${2:slice}| ${3} } +snippet "Each_?s(lice)?" ".each_slice(n) { |slice| }" r +${1:elements}.each_slice(${2:2}) { |${3:slice}| ${0:# TODO} } endsnippet @@ -273,7 +275,7 @@ try: snip.rv = wmatch.group(1).lower() except: snip.rv = 'element' -`}| ${2} } +`}| ${2:# TODO} } endsnippet @@ -288,7 +290,7 @@ try: except: snip.rv = 'element' `}| - ${0} + ${0:# TODO} end endsnippet @@ -303,7 +305,7 @@ try: snip.rv = wmatch.group(1).lower() except: snip.rv = 'element' -`}| ${2} } +`}| ${2:# TODO} } endsnippet @@ -318,7 +320,7 @@ try: except: snip.rv = 'element' `}| - ${0} + ${0:# TODO} end endsnippet @@ -333,7 +335,7 @@ try: snip.rv = wmatch.group(1).lower() except: snip.rv = 'element' -`}| ${2} } +`}| ${2:# TODO} } endsnippet @@ -348,14 +350,14 @@ try: except: snip.rv = 'element' `}| - ${0} + ${0:# TODO} end endsnippet -snippet "(\S+)\.Each_w(ith)?_?i(ndex)?" ".each_with_index { |,| }" r +snippet "(\S+)\.Each_?w(ith)?_?i(ndex)?" ".each_with_index { |,| }" r `!p snip.rv=match.group(1)`.each_with_index { |${1:`!p element_name = match.group(1).lstrip('$@') ematch = re.search("([A-Za-z][A-Za-z0-9_]+?)s?[^A-Za-z0-9_]*?$", element_name) @@ -364,7 +366,7 @@ try: snip.rv = wmatch.group(1).lower() except: snip.rv = 'element' -`},${2:i}| ${3} }$0 +`},${2:i}| ${3:# TODO} }$0 endsnippet @@ -379,7 +381,7 @@ try: except: snip.rv = 'element' `},${2:i}| - ${0} + ${0:# TODO} end endsnippet @@ -387,14 +389,14 @@ endsnippet snippet "(\S+)\.Each_?p(air)?" ".each_pair { |,| }" r -`!p snip.rv=match.group(1)`.each_pair { |${1:key},${2:value}| ${3} } +`!p snip.rv=match.group(1)`.each_pair { |${1:key},${2:value}| ${3:# TODO} } endsnippet snippet "(\S+)\.each_?p(air)?" ".each_pair do |,| end" r `!p snip.rv=match.group(1)`.each_pair do |${1:key},${2:value}| - ${0} + ${0:# TODO} end endsnippet @@ -424,24 +426,26 @@ snippet "(\S+)\.Index" ".index do |item| ... end" r end endsnippet -# comments about do and dov see snippets/ruby.snippets -snippet do "do ... end" i + + +snippet do "do || ... end" i +do |${1:args}| + $0 +end +endsnippet + + + +snippet Do "do ... end" i do $0 end endsnippet -snippet dov "do || ... end" i -do |${1:v}| - $2 -end -endsnippet - - snippet until "until ... end" until ${1:expression} - ${0} + ${0:# TODO} end endsnippet @@ -449,15 +453,15 @@ endsnippet snippet Until "begin ... end until " begin - ${0} + ${0:# TODO} end until ${1:expression} endsnippet -snippet wh "while ... end" +snippet while "while ... end" while ${1:expression} - ${0} + ${0:# TODO} end endsnippet @@ -465,7 +469,7 @@ endsnippet snippet While "begin ... end while " begin - ${0} + ${0:# TODO} end while ${1:expression} endsnippet @@ -491,9 +495,9 @@ endsnippet snippet begin "begin ... rescue ... end" begin - ${1} + ${1:# TODO} rescue - ${0} + ${0:# TODO} end endsnippet @@ -559,7 +563,7 @@ endsnippet snippet ### =begin - $0 + $0 =end endsnippet diff --git a/sources_non_forked/vim-snippets/UltiSnips/scss.snippets b/sources_non_forked/vim-snippets/UltiSnips/scss.snippets new file mode 100644 index 00000000..70a44a07 --- /dev/null +++ b/sources_non_forked/vim-snippets/UltiSnips/scss.snippets @@ -0,0 +1,55 @@ +priority -50 + +snippet /@?imp/ "@import '...';" br +@import '${1:file}'; +endsnippet + +snippet /@?inc/ "@include mixin(...);" br +@include ${1:mixin}(${2:arguments}); +endsnippet + +snippet /@?ext?/ "@extend %placeholder;" br +@extend %${1:placeholder}; +endsnippet + +snippet /@?mixin/ "@mixin (...) { ... }" br +@mixin ${1:name}(${2:arguments}) { + ${VISUAL}$0 +} +endsnippet + +snippet /@?fun/ "@function (...) { ... }" br +@function ${1:name}(${2:arguments}) { + ${VISUAL}$0 +} +endsnippet + +snippet /@?if/ "@if (...) { ... }" br +@if ${1:condition} { + ${VISUAL}$0 +} +endsnippet + +snippet /(} )?@?else/ "@else { ... }" br +@else ${1:condition} { + ${VISUAL}$0 +} +endsnippet + +snippet /@?for/ "@for loop" br +@for ${1:$i} from ${2:1} through ${3:3} { + ${VISUAL}$0 +} +endsnippet + +snippet /@?each/ "@each loop" br +@each ${1:$item} in ${2:item, item, item} { + ${VISUAL}$0 +} +endsnippet + +snippet /@?while/ "@while loop" br +@while ${1:$i} ${2:>} ${3:0} { + ${VISUAL}$0 +} +endsnippet diff --git a/sources_non_forked/vim-snippets/UltiSnips/sh.snippets b/sources_non_forked/vim-snippets/UltiSnips/sh.snippets index cce06ef3..9cc45779 100644 --- a/sources_non_forked/vim-snippets/UltiSnips/sh.snippets +++ b/sources_non_forked/vim-snippets/UltiSnips/sh.snippets @@ -1,21 +1,25 @@ +priority -50 + global !p import vim # Tests for the existence of a variable declared by Vim's filetype detection # suggesting the type of shell script of the current file def testShell(scope, shell): - return vim.eval("exists('" + scope + ":is_" + shell + "')") + return vim.eval("exists('" + scope + ":is_" + shell + "')") # Loops over the possible variables, checking for global variables # first since they indicate an override by the user. def getShell(): - for scope in ["g", "b"]: - for shell in ["bash", "sh", "kornshell"]: - if testShell(scope, shell) == "1": - if shell == "kornshell": - return "ksh" - return shell - return "sh" + for scope in ["g", "b"]: + for shell in ["bash", "posix", "sh", "kornshell"]: + if testShell(scope, shell) == "1": + if shell == "kornshell": + return "ksh" + if shell == "posix": + return "sh" + return shell + return "sh" endglobal ########################################################################### @@ -79,7 +83,7 @@ until ${2:[[ ${1:condition} ]]}; do done endsnippet -snippet wh "while ... (done)" +snippet while "while ... (done)" while ${2:[[ ${1:condition} ]]}; do ${0:#statements} done diff --git a/sources_non_forked/vim-snippets/UltiSnips/snippets.snippets b/sources_non_forked/vim-snippets/UltiSnips/snippets.snippets index 414f350e..ee0c8c76 100644 --- a/sources_non_forked/vim-snippets/UltiSnips/snippets.snippets +++ b/sources_non_forked/vim-snippets/UltiSnips/snippets.snippets @@ -1,16 +1,14 @@ -######################### -# SNIPPETS for SNIPPETS # -######################### +priority -50 # We use a little hack so that the snippet is expanded # and parsed correctly -snippet snip "Snippet definition" ! -`!p snip.rv = "snippet"` ${1:Tab_trigger} "${2:Description}" ${3:!b} +snippet snip "Snippet definition" b +`!p snip.rv = "snippet"` ${1:Tab_trigger} "${2:Description}" ${3:b} $0 `!p snip.rv = "endsnippet"` endsnippet -snippet global "Global snippet" ! +snippet global "Global snippet" b `!p snip.rv = "global"` !p $0 `!p snip.rv = "endglobal"` diff --git a/sources_non_forked/vim-snippets/UltiSnips/tcl.snippets b/sources_non_forked/vim-snippets/UltiSnips/tcl.snippets index fd53d265..65849157 100644 --- a/sources_non_forked/vim-snippets/UltiSnips/tcl.snippets +++ b/sources_non_forked/vim-snippets/UltiSnips/tcl.snippets @@ -1,3 +1,5 @@ +priority -50 + ########################################################################### # TEXTMATE SNIPPETS # ########################################################################### @@ -16,14 +18,14 @@ foreach ${1:var} ${2:\$list} { endsnippet snippet if "if... (if)" b -if {${1}} { +if {${1:condition}} { ${2} } endsnippet snippet proc "proc... (proc)" b -proc ${1} {${2}} \ +proc ${1:name} {${2:args}} \ { ${3} } @@ -40,8 +42,8 @@ switch ${1:-exact} -- ${2:\$var} { endsnippet -snippet wh "while... (while)" b -while {${1}} { +snippet while "while... (while)" b +while {${1:condition}} { ${2} } diff --git a/sources_non_forked/vim-snippets/UltiSnips/tex.snippets b/sources_non_forked/vim-snippets/UltiSnips/tex.snippets index db533070..c32d21f1 100644 --- a/sources_non_forked/vim-snippets/UltiSnips/tex.snippets +++ b/sources_non_forked/vim-snippets/UltiSnips/tex.snippets @@ -1,38 +1,28 @@ +priority -50 -########################################################################### -# LATEX SNIPPETS # -########################################################################### +extends texmath -snippet r "\ref{}" w -\ref{$1} -endsnippet - -########################################################################### -# TEXTMATE SNIPPETS # -########################################################################### - -################# -# GENERAL STUFF # -################# snippet "b(egin)?" "begin{} / end{}" br \begin{${1:something}} ${0:${VISUAL}} \end{$1} endsnippet -#################### -# TABULARS, ARRAYS # -#################### - snippet tab \begin{${1:t}${1/(t)$|(a)$|(.*)/(?1:abular)(?2:rray)/}}{${2:c}} $0${2/((?<=.)c|l|r)|./(?1: & )/g} \end{$1${1/(t)$|(a)$|(.*)/(?1:abular)(?2:rray)/}} endsnippet -######################## -# ENUM, DESCR, ITEMIZE # -######################## +snippet fig "Figure environment" b +\begin{figure}${2:[htpb]} + \centering + \includegraphics[width=${3:0.8}\linewidth]{${4:name.ext}} + \caption{${4/(\w+)\.\w+/\u$1/}$0} + \label{fig:${4/(\w+)\.\w+/$1/}} +\end{figure} +endsnippet + snippet enum "Enumerate" b \begin{enumerate} \item $0 @@ -51,74 +41,70 @@ snippet desc "Description" b \end{description} endsnippet -##################################### -# SECTIONS, CHAPTERS AND THERE LIKE # -##################################### +snippet it "Individual item" b +\item ${1} +$0 +endsnippet snippet part "Part" b \part{${1:part name}} -\label{prt:${2:${1/(\w+)|\W+/(?1:\L$0\E:_)/g}}} +\label{prt:${2:${1/(\w+)|\W+/(?1:\L$0\E:_)/ga}}} ${0} - -% part $2 (end) endsnippet snippet cha "Chapter" b \chapter{${1:chapter name}} -\label{cha:${2:${1/\\\w+\{(.*?)\}|\\(.)|(\w+)|([^\w\\]+)/(?4:_:\L$1$2$3\E)/g}}} +\label{cha:${2:${1/\\\w+\{(.*?)\}|\\(.)|(\w+)|([^\w\\]+)/(?4:_:\L$1$2$3\E)/ga}}} ${0} - -% chapter $2 (end) endsnippet snippet sec "Section" b \section{${1:section name}} -\label{sec:${2:${1/\\\w+\{(.*?)\}|\\(.)|(\w+)|([^\w\\]+)/(?4:_:\L$1$2$3\E)/g}}} +\label{sec:${2:${1/\\\w+\{(.*?)\}|\\(.)|(\w+)|([^\w\\]+)/(?4:_:\L$1$2$3\E)/ga}}} ${0} - -% section $2 (end) endsnippet - snippet sub "Subsection" b \subsection{${1:subsection name}} -\label{sub:${2:${1/\\\w+\{(.*?)\}|\\(.)|(\w+)|([^\w\\]+)/(?4:_:\L$1$2$3\E)/g}}} +\label{sub:${2:${1/\\\w+\{(.*?)\}|\\(.)|(\w+)|([^\w\\]+)/(?4:_:\L$1$2$3\E)/ga}}} ${0} - -% subsection $2 (end) endsnippet snippet ssub "Subsubsection" b \subsubsection{${1:subsubsection name}} -\label{ssub:${2:${1/\\\w+\{(.*?)\}|\\(.)|(\w+)|([^\w\\]+)/(?4:_:\L$1$2$3\E)/g}}} +\label{ssub:${2:${1/\\\w+\{(.*?)\}|\\(.)|(\w+)|([^\w\\]+)/(?4:_:\L$1$2$3\E)/ga}}} ${0} - -% subsubsection $2 (end) - endsnippet snippet par "Paragraph" b \paragraph{${1:paragraph name}} -\label{par:${2:${1/\\\w+\{(.*?)\}|\\(.)|(\w+)|([^\w\\]+)/(?4:_:\L$1$2$3\E)/g}}} +\label{par:${2:${1/\\\w+\{(.*?)\}|\\(.)|(\w+)|([^\w\\]+)/(?4:_:\L$1$2$3\E)/ga}}} ${0} - -% paragraph $2 (end) endsnippet - snippet subp "Subparagraph" b \subparagraph{${1:subparagraph name}} -\label{par:${2:${1/\\\w+\{(.*?)\}|\\(.)|(\w+)|([^\w\\]+)/(?4:_:\L$1$2$3\E)/g}}} +\label{par:${2:${1/\\\w+\{(.*?)\}|\\(.)|(\w+)|([^\w\\]+)/(?4:_:\L$1$2$3\E)/ga}}} ${0} - -% subparagraph $2 (end) endsnippet +snippet ni "Non-indented paragraph" b +\noindent +${0} +endsnippet + +snippet pac "Package" b +\usepackage[${1:options}]{${2:package}}$0 +endsnippet + +snippet lp "Long parenthesis" +\left(${1:${VISUAL:contents}}\right)$0 +endsnippet # vim:ft=snippets: diff --git a/sources_non_forked/vim-snippets/UltiSnips/texmath.snippets b/sources_non_forked/vim-snippets/UltiSnips/texmath.snippets index 03589f0f..d0a25e9a 100644 --- a/sources_non_forked/vim-snippets/UltiSnips/texmath.snippets +++ b/sources_non_forked/vim-snippets/UltiSnips/texmath.snippets @@ -1,3 +1,5 @@ +priority -50 + ############## # MATH STUFF # ############## diff --git a/sources_non_forked/vim-snippets/UltiSnips/twig.snippets b/sources_non_forked/vim-snippets/UltiSnips/twig.snippets index 9db43f7d..156b981b 100644 --- a/sources_non_forked/vim-snippets/UltiSnips/twig.snippets +++ b/sources_non_forked/vim-snippets/UltiSnips/twig.snippets @@ -1,3 +1,5 @@ +priority -50 + snippet bl "twig block" b {% block ${1} %} ${2} diff --git a/sources_non_forked/vim-snippets/UltiSnips/vim.snippets b/sources_non_forked/vim-snippets/UltiSnips/vim.snippets index 5655c4b1..5ff22d2e 100644 --- a/sources_non_forked/vim-snippets/UltiSnips/vim.snippets +++ b/sources_non_forked/vim-snippets/UltiSnips/vim.snippets @@ -1,3 +1,5 @@ +priority -50 + ########################################################################### # SnipMate Snippets # ########################################################################### @@ -25,30 +27,30 @@ endsnippet snippet f fun ${1:function_name}(${2}) - ${3} + ${3:" code} endf endsnippet snippet for -for ${1} in ${2} - ${3} +for ${1:needle} in ${2:haystack} + ${3:" code} endfor endsnippet snippet wh -while ${1} - ${2} +while ${1:condition} + ${2:" code} endw endsnippet snippet if -if ${1} - ${2} +if ${1:condition} + ${2:" code} endif endsnippet snippet ife -if ${1} +if ${1:condition} ${2} else ${3} diff --git a/sources_non_forked/vim-snippets/UltiSnips/xhtml.snippets b/sources_non_forked/vim-snippets/UltiSnips/xhtml.snippets index e69de29b..a9c5a29a 100644 --- a/sources_non_forked/vim-snippets/UltiSnips/xhtml.snippets +++ b/sources_non_forked/vim-snippets/UltiSnips/xhtml.snippets @@ -0,0 +1,3 @@ +priority -50 + +extends html diff --git a/sources_non_forked/vim-snippets/UltiSnips/xml.snippets b/sources_non_forked/vim-snippets/UltiSnips/xml.snippets index 80b017ce..92dfb6e1 100644 --- a/sources_non_forked/vim-snippets/UltiSnips/xml.snippets +++ b/sources_non_forked/vim-snippets/UltiSnips/xml.snippets @@ -1,3 +1,10 @@ +priority -50 + +snippet xml "XML declaration" b + + +endsnippet + snippet t "Simple tag" b <${1:tag}> ${2:content} diff --git a/sources_non_forked/vim-snippets/UltiSnips/zsh.snippets b/sources_non_forked/vim-snippets/UltiSnips/zsh.snippets index 80394597..f7986ea5 100644 --- a/sources_non_forked/vim-snippets/UltiSnips/zsh.snippets +++ b/sources_non_forked/vim-snippets/UltiSnips/zsh.snippets @@ -1,9 +1,15 @@ -snippet #! "shebang" ! +priority -50 + +extends sh + +priority -49 + +snippet #! "shebang" b #!/bin/zsh endsnippet -snippet !env "#!/usr/bin/env (!env)" ! +snippet !env "#!/usr/bin/env (!env)" b #!/usr/bin/env zsh endsnippet diff --git a/sources_non_forked/vim-snippets/snippets/coffee.snippets b/sources_non_forked/vim-snippets/snippets/coffee.snippets deleted file mode 100644 index 7ed1ebf4..00000000 --- a/sources_non_forked/vim-snippets/snippets/coffee.snippets +++ /dev/null @@ -1,109 +0,0 @@ -# Closure loop -snippet forindo - for ${1:name} in ${2:array} - do ($1) -> - ${0:// body} -# Array comprehension -snippet fora - for ${1:name} in ${2:array} - ${0:# body...} -# Object comprehension -snippet foro - for ${1:key}, ${2:value} of ${3:object} - ${0:# body...} -# Range comprehension (inclusive) -snippet forr - for ${1:name} in [${2:start}..${3:finish}] - ${0:# body...} -snippet forrb - for ${1:name} in [${2:start}..${3:finish}] by ${4:step} - ${0:# body...} -# Range comprehension (exclusive) -snippet forrex - for ${1:name} in [${2:start}...${3:finish}] - ${0:# body...} -snippet forrexb - for ${1:name} in [${2:start}...${3:finish}] by ${4:step} - ${0:# body...} -# Function -snippet fun - (${1:args}) -> - ${0:# body...} -# Function (bound) -snippet bfun - (${1:args}) => - ${0:# body...} -# Class -snippet cla class .. - class ${1:`substitute(vim_snippets#Filename(), '\(_\|^\)\(.\)', '\u\2', 'g')`} - ${0} -snippet cla class .. constructor: .. - class ${1:`substitute(vim_snippets#Filename(), '\(_\|^\)\(.\)', '\u\2', 'g')`} - constructor: (${2:args}) -> - ${3} - - ${0} -snippet cla class .. extends .. - class ${1:`substitute(vim_snippets#Filename(), '\(_\|^\)\(.\)', '\u\2', 'g')`} extends ${2:ParentClass} - ${0} -snippet cla class .. extends .. constructor: .. - class ${1:`substitute(vim_snippets#Filename(), '\(_\|^\)\(.\)', '\u\2', 'g')`} extends ${2:ParentClass} - constructor: (${3:args}) -> - ${4} - - ${0} -# If -snippet if - if ${1:condition} - ${0:# body...} -# If __ Else -snippet ife - if ${1:condition} - ${2:# body...} - else - ${0:# body...} -# Else if -snippet eif - else if ${1:condition} - ${0:# body...} -# Ternary If -snippet ifte - if ${1:condition} then ${2:value} else ${0:other} -# Unless -snippet unl - ${1:action} unless ${0:condition} -# Switch -snippet swi - switch ${1:object} - when ${2:value} - ${0:# body...} - -# Log -snippet log - console.log ${0} -# Try __ Catch -snippet try - try - ${1} - catch ${2:error} - ${0} -# Require -snippet req - ${2:$1} = require '${1:sys}' -# Export -snippet exp - ${0:root} = exports ? this - - -snippet ajax - $.ajax - url: "${1:mydomain.com/url}" - type: "${2:POST}" - dataType: "${3:xml/html/script/json}" - data: ${4:data} - complete: (jqXHR, textStatus) -> - ${5:// callback} - success: (data, textStatus, jqXHR) -> - ${6:// success callback} - error: (jqXHR, textStatus, errorThrown) -> - ${0:// error callback} diff --git a/sources_non_forked/vim-snippets/snippets/html.snippets b/sources_non_forked/vim-snippets/snippets/html.snippets index d8892b5b..567003f7 100644 --- a/sources_non_forked/vim-snippets/snippets/html.snippets +++ b/sources_non_forked/vim-snippets/snippets/html.snippets @@ -361,15 +361,15 @@ snippet footer# ${0} snippet form -
    + ${0}
    snippet form. -
    + ${0}
    snippet form# -
    + ${0}
    snippet h1 diff --git a/sources_non_forked/vim-snippets/snippets/javascript-jquery.snippets b/sources_non_forked/vim-snippets/snippets/javascript-jquery.snippets deleted file mode 100644 index ef6f66c7..00000000 --- a/sources_non_forked/vim-snippets/snippets/javascript-jquery.snippets +++ /dev/null @@ -1,589 +0,0 @@ -snippet add - ${1:obj}.add('${2:selector expression}') -snippet addClass - ${1:obj}.addClass('${2:class name}') -snippet after - ${1:obj}.after('${2:Some text and bold!}') -snippet ajax - $.ajax({ - url: '${1:mydomain.com/url}', - type: '${2:POST}', - dataType: '${3:xml/html/script/json}', - data: $.param( $('${4:Element or Expression}') ), - complete: function (jqXHR, textStatus) { - ${5:// callback} - }, - success: function (data, textStatus, jqXHR) { - ${6:// success callback} - }, - error: function (jqXHR, textStatus, errorThrown) { - ${0:// error callback} - } - }); -snippet ajaxcomplete - ${1:obj}.ajaxComplete(function (${1:e}, xhr, settings) { - ${0:// callback} - }); -snippet ajaxerror - ${1:obj}.ajaxError(function (${1:e}, xhr, settings, thrownError) { - ${2:// error callback} - }); - ${0} -snippet ajaxget - $.get('${1:mydomain.com/url}', - ${2:{ param1: value1 },} - function (data, textStatus, jqXHR) { - ${0:// success callback} - } - ); -snippet ajaxpost - $.post('${1:mydomain.com/url}', - ${2:{ param1: value1 },} - function (data, textStatus, jqXHR) { - ${0:// success callback} - } - ); -snippet ajaxprefilter - $.ajaxPrefilter(function (${1:options}, ${2:originalOptions}, jqXHR) { - ${0: // Modify options, control originalOptions, store jqXHR, etc} - }); -snippet ajaxsend - ${1:obj}.ajaxSend(function (${1:request, settings}) { - ${2:// error callback} - }); - ${0} -snippet ajaxsetup - $.ajaxSetup({ - url: "${1:mydomain.com/url}", - type: "${2:POST}", - dataType: "${3:xml/html/script/json}", - data: $.param( $("${4:Element or Expression}") ), - complete: function (jqXHR, textStatus) { - ${5:// callback} - }, - success: function (data, textStatus, jqXHR) { - ${6:// success callback} - }, - error: function (jqXHR, textStatus, errorThrown) { - ${0:// error callback} - } - }); -snippet ajaxstart - $.ajaxStart(function () { - ${1:// handler for when an AJAX call is started and no other AJAX calls are in progress}; - }); - ${0} -snippet ajaxstop - $.ajaxStop(function () { - ${1:// handler for when all AJAX calls have been completed}; - }); - ${0} -snippet ajaxsuccess - $.ajaxSuccess(function (${1:e}, xhr, settings) { - ${2:// handler for when any AJAX call is successfully completed}; - }); - ${0} -snippet andself - ${1:obj}.andSelf() -snippet animate - ${1:obj}.animate({${2:param1: value1, param2: value2}}, ${3:speed}) -snippet append - ${1:obj}.append('${2:Some text and bold!}') -snippet appendTo - ${1:obj}.appendTo('${2:selector expression}') -snippet attr - ${1:obj}.attr('${2:attribute}', '${3:value}') -snippet attrm - ${1:obj}.attr({'${2:attr1}': '${3:value1}', '${4:attr2}': '${5:value2}'}) -snippet before - ${1:obj}.before('${2:Some text and bold!}') -snippet bind - ${1:obj}.bind('${2:event name}', function (${3:e}) { - ${0:// event handler} - }); -snippet blur - ${1:obj}.blur(function (${2:e}) { - ${0:// event handler} - }); -snippet C - $.Callbacks() -snippet Cadd - ${1:callbacks}.add(${2:callbacks}) -snippet Cdis - ${1:callbacks}.disable() -snippet Cempty - ${1:callbacks}.empty() -snippet Cfire - ${1:callbacks}.fire(${2:args}) -snippet Cfired - ${1:callbacks}.fired() -snippet Cfirew - ${1:callbacks}.fireWith(${2:this}, ${3:args}) -snippet Chas - ${1:callbacks}.has(${2:callback}) -snippet Clock - ${1:callbacks}.lock() -snippet Clocked - ${1:callbacks}.locked() -snippet Crem - ${1:callbacks}.remove(${2:callbacks}) -snippet change - ${1:obj}.change(function (${2:e}) { - ${0:// event handler} - }); -snippet children - ${1:obj}.children('${2:selector expression}') -snippet clearq - ${1:obj}.clearQueue(${2:'queue name'}) -snippet click - ${1:obj}.click(function (${2:e}) { - ${0:// event handler} - }); -snippet clone - ${1:obj}.clone() -snippet contains - $.contains(${1:container}, ${0:contents}); -snippet css - ${1:obj}.css('${2:attribute}', '${3:value}') -snippet csshooks - $.cssHooks['${1:CSS prop}'] = { - get: function (elem, computed, extra) { - ${2: // handle getting the CSS property} - }, - set: function (elem, value) { - ${0: // handle setting the CSS value} - } - }; -snippet cssm - ${1:obj}.css({${2:attribute1}: '${3:value1}', ${4:attribute2}: '${5:value2}'}) -snippet D - $.Deferred() -snippet Dalways - ${1:deferred}.always(${2:callbacks}) -snippet Ddone - ${1:deferred}.done(${2:callbacks}) -snippet Dfail - ${1:deferred}.fail(${2:callbacks}) -snippet Disrej - ${1:deferred}.isRejected() -snippet Disres - ${1:deferred}.isResolved() -snippet Dnotify - ${1:deferred}.notify(${2:args}) -snippet Dnotifyw - ${1:deferred}.notifyWith(${2:this}, ${3:args}) -snippet Dpipe - ${1:deferred}.then(${2:doneFilter}, ${3:failFilter}, ${4:progressFilter}) -snippet Dprog - ${1:deferred}.progress(${2:callbacks}) -snippet Dprom - ${1:deferred}.promise(${2:target}) -snippet Drej - ${1:deferred}.reject(${2:args}) -snippet Drejw - ${1:deferred}.rejectWith(${2:this}, ${3:args}) -snippet Dres - ${1:deferred}.resolve(${2:args}) -snippet Dresw - ${1:deferred}.resolveWith(${2:this}, ${3:args}) -snippet Dstate - ${1:deferred}.state() -snippet Dthen - ${1:deferred}.then(${2:doneCallbacks}, ${3:failCallbacks}, ${4:progressCallbacks}) -snippet Dwhen - $.when(${1:deferreds}) -snippet data - ${1:obj}.data(${2:obj}) -snippet dataa - $.data('${1:selector expression}', '${2:key}'${3:, 'value'}) -snippet dblclick - ${1:obj}.dblclick(function (${2:e}) { - ${0:// event handler} - }); -snippet delay - ${1:obj}.delay('${2:slow/400/fast}'${3:, 'queue name'}) -snippet dele - ${1:obj}.delegate('${2:selector expression}', '${3:event name}', function (${4:e}) { - ${0:// event handler} - }); -snippet deq - ${1:obj}.dequeue(${2:'queue name'}) -snippet deqq - $.dequeue('${1:selector expression}'${2:, 'queue name'}) -snippet detach - ${1:obj}.detach('${2:selector expression}') -snippet die - ${1:obj}.die(${2:event}, ${3:handler}) -snippet each - ${1:obj}.each(function (index) { - ${0:this.innerHTML = this + " is the element, " + index + " is the position";} - }); -snippet el - $('<${1}/>'${2:, {}}) -snippet eltrim - $.trim('${1:string}') -snippet empty - ${1:obj}.empty() -snippet end - ${1:obj}.end() -snippet eq - ${1:obj}.eq(${2:element index}) -snippet error - ${1:obj}.error(function (${2:e}) { - ${0:// event handler} - }); -snippet eventsmap - { - :f${0} - } -snippet extend - $.extend(${1:true, }${2:target}, ${3:obj}) -snippet fadein - ${1:obj}.fadeIn('${2:slow/400/fast}') -snippet fadeinc - ${1:obj}.fadeIn('slow/400/fast', function () { - ${0:// callback}; - }); -snippet fadeout - ${1:obj}.fadeOut('${2:slow/400/fast}') -snippet fadeoutc - ${1:obj}.fadeOut('slow/400/fast', function () { - ${0:// callback}; - }); -snippet fadeto - ${1:obj}.fadeTo('${2:slow/400/fast}', ${3:0.5}) -snippet fadetoc - ${1:obj}.fadeTo('slow/400/fast', ${2:0.5}, function () { - ${0:// callback}; - }); -snippet filter - ${1:obj}.filter('${2:selector expression}') -snippet filtert - ${1:obj}.filter(function (${2:index}) { - ${3} - }) -snippet find - ${1:obj}.find('${2:selector expression}') -snippet focus - ${1:obj}.focus(function (${2:e}) { - ${0:// event handler} - }); -snippet focusin - ${1:obj}.focusIn(function (${2:e}) { - ${0:// event handler} - }); -snippet focusout - ${1:obj}.focusOut(function (${2:e}) { - ${0:// event handler} - }); -snippet get - ${1:obj}.get(${2:element index}) -snippet getjson - $.getJSON('${1:mydomain.com/url}', - ${2:{ param1: value1 },} - function (data, textStatus, jqXHR) { - ${0:// success callback} - } - ); -snippet getscript - $.getScript('${1:mydomain.com/url}', function (script, textStatus, jqXHR) { - ${0:// callback} - }); -snippet grep - $.grep(${1:array}, function (item, index) { - ${2} - }${0:, true}); -snippet hasc - ${1:obj}.hasClass('${2:className}') -snippet hasd - $.hasData('${0:selector expression}'); -snippet height - ${1:obj}.height(${2:integer}) -snippet hide - ${1:obj}.hide('${2:slow/400/fast}') -snippet hidec - ${1:obj}.hide('${2:slow/400/fast}', function () { - ${0:// callback} - }); -snippet hover - ${1:obj}.hover(function (${2:e}) { - ${3:// event handler} - }, function ($2) { - ${4:// event handler} - }); -snippet html - ${1:obj}.html('${2:Some text and bold!}') -snippet inarr - $.inArray(${1:value}, ${0:array}); -snippet insa - ${1:obj}.insertAfter('${2:selector expression}') -snippet insb - ${1:obj}.insertBefore('${2:selector expression}') -snippet is - ${1:obj}.is('${2:selector expression}') -snippet isarr - $.isArray(${1:obj}) -snippet isempty - $.isEmptyObject(${1:obj}) -snippet isfunc - $.isFunction(${1:obj}) -snippet isnum - $.isNumeric(${1:value}) -snippet isobj - $.isPlainObject(${1:obj}) -snippet iswin - $.isWindow(${1:obj}) -snippet isxml - $.isXMLDoc(${1:node}) -snippet jj - $('${1:selector}') -snippet kdown - ${1:obj}.keydown(function (${2:e}) { - ${0:// event handler} - }); -snippet kpress - ${1:obj}.keypress(function (${2:e}) { - ${0:// event handler} - }); -snippet kup - ${1:obj}.keyup(function (${2:e}) { - ${0:// event handler} - }); -snippet last - ${1:obj}.last('${1:selector expression}') -snippet live - ${1:obj}.live('${2:events}', function (${3:e}) { - ${0:// event handler} - }); -snippet load - ${1:obj}.load(function (${2:e}) { - ${0:// event handler} - }); -snippet loadf - ${1:obj}.load('${2:mydomain.com/url}', - ${2:{ param1: value1 },} - function (responseText, textStatus, xhr) { - ${0:// success callback} - } - }); -snippet makearray - $.makeArray(${0:obj}); -snippet map - ${1:obj}.map(function (${2:index}, ${3:element}) { - ${0:// callback} - }); -snippet mapp - $.map(${1:arrayOrObject}, function (${2:value}, ${3:indexOrKey}) { - ${0:// callback} - }); -snippet merge - $.merge(${1:target}, ${0:original}); -snippet mdown - ${1:obj}.mousedown(function (${2:e}) { - ${0:// event handler} - }); -snippet menter - ${1:obj}.mouseenter(function (${2:e}) { - ${0:// event handler} - }); -snippet mleave - ${1:obj}.mouseleave(function (${2:e}) { - ${0:// event handler} - }); -snippet mmove - ${1:obj}.mousemove(function (${2:e}) { - ${0:// event handler} - }); -snippet mout - ${1:obj}.mouseout(function (${2:e}) { - ${0:// event handler} - }); -snippet mover - ${1:obj}.mouseover(function (${2:e}) { - ${0:// event handler} - }); -snippet mup - ${1:obj}.mouseup(function (${2:e}) { - ${0:// event handler} - }); -snippet next - ${1:obj}.next('${2:selector expression}') -snippet nexta - ${1:obj}.nextAll('${2:selector expression}') -snippet nextu - ${1:obj}.nextUntil('${2:selector expression}'${3:, 'filter expression'}) -snippet not - ${1:obj}.not('${2:selector expression}') -snippet off - ${1:obj}.off('${2:events}', '${3:selector expression}'${4:, handler}) -snippet offset - ${1:obj}.offset() -snippet offsetp - ${1:obj}.offsetParent() -snippet on - ${1:obj}.on('${2:events}', '${3:selector expression}', function (${4:e}) { - ${0:// event handler} - }); -snippet one - ${1:obj}.one('${2:event name}', function (${3:e}) { - ${0:// event handler} - }); -snippet outerh - ${1:obj}.outerHeight() -snippet outerw - ${1:obj}.outerWidth() -snippet param - $.param(${1:obj}) -snippet parent - ${1:obj}.parent('${2:selector expression}') -snippet parents - ${1:obj}.parents('${2:selector expression}') -snippet parentsu - ${1:obj}.parentsUntil('${2:selector expression}'${3:, 'filter expression'}) -snippet parsejson - $.parseJSON(${1:data}) -snippet parsexml - $.parseXML(${1:data}) -snippet pos - ${1:obj}.position() -snippet prepend - ${1:obj}.prepend('${2:Some text and bold!}') -snippet prependto - ${1:obj}.prependTo('${2:selector expression}') -snippet prev - ${1:obj}.prev('${2:selector expression}') -snippet preva - ${1:obj}.prevAll('${2:selector expression}') -snippet prevu - ${1:obj}.prevUntil('${2:selector expression}'${3:, 'filter expression'}) -snippet promise - ${1:obj}.promise(${2:'fx'}, ${3:target}) -snippet prop - ${1:obj}.prop('${2:property name}') -snippet proxy - $.proxy(${1:function}, ${2:this}) -snippet pushstack - ${1:obj}.pushStack(${2:elements}) -snippet queue - ${1:obj}.queue(${2:name}${3:, newQueue}) -snippet queuee - $.queue(${1:element}${2:, name}${3:, newQueue}) -snippet ready - $(function () { - ${0} - }); -snippet rem - ${1:obj}.remove() -snippet rema - ${1:obj}.removeAttr('${2:attribute name}') -snippet remc - ${1:obj}.removeClass('${2:class name}') -snippet remd - ${1:obj}.removeData('${2:key name}') -snippet remdd - $.removeData(${1:element}${2:, 'key name}') -snippet remp - ${1:obj}.removeProp('${2:property name}') -snippet repa - ${1:obj}.replaceAll(${2:target}) -snippet repw - ${1:obj}.replaceWith(${2:content}) -snippet reset - ${1:obj}.reset(function (${2:e}) { - ${0:// event handler} - }); -snippet resize - ${1:obj}.resize(function (${2:e}) { - ${0:// event handler} - }); -snippet scroll - ${1:obj}.scroll(function (${2:e}) { - ${0:// event handler} - }); -snippet scrolll - ${1:obj}.scrollLeft(${2:value}) -snippet scrollt - ${1:obj}.scrollTop(${2:value}) -snippet sdown - ${1:obj}.slideDown('${2:slow/400/fast}') -snippet sdownc - ${1:obj}.slideDown('${2:slow/400/fast}', function () { - ${0:// callback}; - }); -snippet select - ${1:obj}.select(function (${2:e}) { - ${0:// event handler} - }); -snippet serialize - ${1:obj}.serialize() -snippet serializea - ${1:obj}.serializeArray() -snippet show - ${1:obj}.show('${2:slow/400/fast}') -snippet showc - ${1:obj}.show('${2:slow/400/fast}', function () { - ${0:// callback} - }); -snippet sib - ${1:obj}.siblings('${2:selector expression}') -snippet size - ${1:obj}.size() -snippet slice - ${1:obj}.slice(${2:start}${3:, end}) -snippet stoggle - ${1:obj}.slideToggle('${2:slow/400/fast}') -snippet stop - ${1:obj}.stop('${2:queue}', ${3:false}, ${4:false}) -snippet submit - ${1:obj}.submit(function (${2:e}) { - ${0:// event handler} - }); -snippet sup - ${1:obj}.slideUp('${2:slow/400/fast}') -snippet supc - ${1:obj}.slideUp('${2:slow/400/fast}', function () { - ${0:// callback}; - }); -snippet text - ${1:obj}.text(${2:'some text'}) -snippet this - $(this) -snippet toarr - ${0:obj}.toArray() -snippet tog - ${1:obj}.toggle(function (${2:e}) { - ${3:// event handler} - }, function ($2) { - ${4:// event handler} - }); - ${0} -snippet togclass - ${1:obj}.toggleClass('${2:class name}') -snippet togsh - ${1:obj}.toggle('${2:slow/400/fast}') -snippet trig - ${1:obj}.trigger('${2:event name}') -snippet trigh - ${1:obj}.triggerHandler('${2:event name}') -snippet $trim - $.trim(${1:str}) -snippet $type - $.type(${1:obj}) -snippet unbind - ${1:obj}.unbind('${2:event name}') -snippet undele - ${1:obj}.undelegate(${2:selector expression}, ${3:event}, ${4:handler}) -snippet uniq - $.unique(${1:array}) -snippet unload - ${1:obj}.unload(function (${2:e}) { - ${0:// event handler} - }); -snippet unwrap - ${1:obj}.unwrap() -snippet val - ${1:obj}.val('${2:text}') -snippet width - ${1:obj}.width(${2:integer}) -snippet wrap - ${1:obj}.wrap('${2:<div class="extra-wrapper"></div>}') diff --git a/sources_non_forked/vim-snippets/snippets/javascript.d3.snippets b/sources_non_forked/vim-snippets/snippets/javascript.d3.snippets deleted file mode 100644 index a3f7fa7a..00000000 --- a/sources_non_forked/vim-snippets/snippets/javascript.d3.snippets +++ /dev/null @@ -1,30 +0,0 @@ -snippet .attr - .attr("${1}", ${2}) -snippet .style - .style("${1}", ${2}) -snippet axis - d3.svg.axis() - .orient(${1}) - .scale(${2}) -snippet fd - function(d) { ${1} } -snippet fdi - function(d, i) { ${1} } -snippet marginconvention - var ${1:margin} = { top: ${2:10}, right: ${3:10}, bottom: ${4:10}, left: ${5:10} }; - var ${6:width} = ${7:970} - $1.left - $1.right; - var ${8:height} = ${9:500} - $1.top - $1.bottom; - - var ${10:svg} = d3.select("${11}").append("svg") - .attr("width", $6) - .attr("height", $8) - .append("g") - .attr("transform", "translate(" + $1.left + "," + $1.top + ")") -snippet nest - d3.nest() - .key(${1}) - .entries(${2}) -snippet scale - d3.scale.linear() - .domain(${1}) - .range(${2}) diff --git a/sources_non_forked/vim-snippets/snippets/javascript.snippets b/sources_non_forked/vim-snippets/snippets/javascript.snippets deleted file mode 100644 index 0a046dbf..00000000 --- a/sources_non_forked/vim-snippets/snippets/javascript.snippets +++ /dev/null @@ -1,200 +0,0 @@ -# Prototype -snippet proto - ${1:class_name}.prototype.${2:method_name} = - function(${3:first_argument}) { - ${0:// body...} - }; -# Function -snippet fun - function ${1:function_name}(${2:argument}) { - ${0:// body...} - } -# Anonymous Function -snippet f - function (${1}) { - ${0} - }${2:;} -# Immediate function -snippet (f - (function (${1}) { - ${0} - }(${2})); -# if -snippet if - if (${1:true}) { - ${0} - } -# if ... else -snippet ife - if (${1:true}) { - ${2} - } else { - ${0} - } -# tertiary conditional -snippet ter - ${1:/* condition */} ? ${2:a} : ${0:b} -# switch -snippet switch - switch (${1:expression}) { - case '${3:case}': - ${4} - break; - ${0} - default: - ${2} - } -# case -snippet case - case '${1:case}': - ${2} - break; - ${0} -# for (...) {...} -snippet for - for (var ${2:i} = 0, l = ${1:arr}.length; $2 < l; $2 ++) { - var ${3:v} = $1[$2];${0:} - } -# for (...) {...} (Improved Native For-Loop) -snippet forr - for (var ${2:i} = ${1:arr}.length - 1; $2 >= 0; $2 --) { - var ${3:v} = $1[$2];${0:} - } -# while (...) {...} -snippet wh - while (${1:/* condition */}) { - ${0} - } -# try -snippet try - try { - ${1} - } catch (${2:e}) { - ${0:/* handle error */} - } -# do...while -snippet do - do { - ${0} - } while (${1:/* condition */}); -# Object Method -snippet :f - ${1:method_name}: function (${2:attribute}) { - ${0} - }${3:,} -# setTimeout function -snippet timeout - setTimeout(function () {${0}}${2}, ${1:10}); -# Get Elements -snippet get - getElementsBy${1:TagName}('${2}') -# Get Element -snippet gett - getElementBy${1:Id}('${2}') -# console.log (Firebug) -snippet cl - console.log(${0}); -# return -snippet ret - return ${0:result} -# for (property in object ) { ... } -snippet fori - for (var ${1:prop} in ${2:Things}) { - ${0:$2[$1]} - } -# hasOwnProperty -snippet has - hasOwnProperty(${0}) -# docstring -snippet /** - /** - * ${0:description} - * - */ -snippet @par - @param {${1:type}} ${2:name} ${0:description} -snippet @ret - @return {${1:type}} ${0:description} -# JSON.parse -snippet jsonp - JSON.parse(${0:jstr}); -# JSON.stringify -snippet jsons - JSON.stringify(${0:object}); -# self-defining function -snippet sdf - var ${1:function_name} = function (${2:argument}) { - ${3} - - $1 = function ($2) { - ${0} - }; - }; -# singleton -snippet sing - function ${1:Singleton} (${2:argument}) { - // the cached instance - var instance; - - // rewrite the constructor - $1 = function $1($2) { - return instance; - }; - - // carry over the prototype properties - $1.prototype = this; - - // the instance - instance = new $1(); - - // reset the constructor pointer - instance.constructor = $1; - - ${0} - - return instance; - } -# Crockford's object function -snippet obj - function object(o) { - function F() {} - F.prototype = o; - return new F(); - } -# Define multiple properties -snippet props - var ${1:my_object} = Object.defineProperties( - ${2:new Object()}, - { - ${3:property} : { - get : function $1_$3_getter() { - // getter code - }, - set : function $1_$3_setter(value) { - // setter code - }, - value : ${4:value}, - writeable : ${5:boolean}, - enumerable : ${6:boolean}, - configurable : ${0:boolean} - } - } - ); -# Define single property -snippet prop - Object.defineProperty( - ${1:object}, - "${2:property}", - { - get : function $1_$2_getter() { - // getter code - }, - set : function $1_$2_setter(value) { - // setter code - }, - value : ${3:value}, - writeable : ${4:boolean}, - enumerable : ${5:boolean}, - configurable : ${0:boolean} - } - ); diff --git a/sources_non_forked/vim-snippets/snippets/javascript_jquery.snippets b/sources_non_forked/vim-snippets/snippets/javascript_jquery.snippets deleted file mode 100644 index 9b4966db..00000000 --- a/sources_non_forked/vim-snippets/snippets/javascript_jquery.snippets +++ /dev/null @@ -1 +0,0 @@ -javascript-jquery.snippets \ No newline at end of file diff --git a/sources_non_forked/vim-snippets/snippets/vim.snippets b/sources_non_forked/vim-snippets/snippets/vim.snippets index dd1e65e8..8e8093b9 100644 --- a/sources_non_forked/vim-snippets/snippets/vim.snippets +++ b/sources_non_forked/vim-snippets/snippets/vim.snippets @@ -25,9 +25,8 @@ snippet for snippet forkv for [${1},${2}] in items(${3}) ${0} - unlet $1 $2 + unlet $1 $2 endfor - snippet wh while ${1} ${0} diff --git a/update_plugins.py b/update_plugins.py index 3dacaf08..78de7826 100644 --- a/update_plugins.py +++ b/update_plugins.py @@ -38,6 +38,7 @@ vim-zenroom2 https://github.com/amix/vim-zenroom2 syntastic https://github.com/scrooloose/syntastic vim-repeat https://github.com/tpope/vim-repeat vim-commentary https://github.com/tpope/vim-commentary +vim-golang https://github.com/jnwhiteh/vim-golang """.strip() GITHUB_ZIP = '%s/archive/master.zip'