Updated plugins. Added vim-golang as a mode
This commit is contained in:
parent
2b82c75631
commit
8f0740e307
125 changed files with 4121 additions and 2440 deletions
|
@ -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?
|
||||
|
|
|
@ -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<CR>'
|
||||
else
|
||||
exe g:ack_qhandler
|
||||
let l:apply_mappings = g:ack_apply_qmappings
|
||||
let l:close_cmd = ':cclose<CR>'
|
||||
endif
|
||||
|
||||
if l:apply_mappings
|
||||
exec "nnoremap <silent> <buffer> q :ccl<CR>"
|
||||
exec "nnoremap <silent> <buffer> q " . l:close_cmd
|
||||
exec "nnoremap <silent> <buffer> t <C-W><CR><C-W>T"
|
||||
exec "nnoremap <silent> <buffer> T <C-W><CR><C-W>TgT<C-W><C-W>"
|
||||
exec "nnoremap <silent> <buffer> o <CR>"
|
||||
|
@ -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
|
||||
|
||||
|
|
|
@ -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).
|
||||
|
||||
|
||||
<a name="step1"></a>
|
||||
|
||||
### 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:
|
||||
|
||||
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:
|
||||
|
||||
```
|
||||
Next you *need* to add this to your `~/.vimrc`:
|
||||
```vim
|
||||
execute pathogen#infect()
|
||||
```
|
||||
|
||||
<a name="step2"></a>
|
||||
|
||||
### 2.2\. Step 2: Install syntastic as a pathogen bundle
|
||||
|
||||
You now have pathogen installed and can put syntastic into ~/.vim/bundle like this:
|
||||
|
||||
|
||||
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:
|
||||
|
||||
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,36 +114,33 @@ 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/<filetype>/*.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:
|
||||
|
@ -152,10 +152,7 @@ __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_<filetype>_<subchecker>_args
|
||||
```
|
||||
global `args` variables is `syntastic_<filetype>_<checker>_args`.
|
||||
|
||||
So, If you wanted to pass "--my --args --here" to the ruby mri checker you
|
||||
would add this line to your vimrc:
|
||||
|
@ -173,11 +170,11 @@ A. Stick a line like this in your vimrc:
|
|||
let g:syntastic_<filetype>_checkers = ['<checker-name>']
|
||||
```
|
||||
|
||||
To see the list of checkers for your filetype, look in
|
||||
`syntax_checkers/<filetype>/`.
|
||||
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
|
||||
|
@ -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*
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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,
|
||||
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")}
|
||||
]).
|
||||
report] ++
|
||||
[{i, filename:join(Root, I)} || I <- LibDirs]).
|
||||
|
||||
get_root(Dir) ->
|
||||
Path = filename:split(filename:absname(Dir)),
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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')
|
||||
|
@ -26,10 +42,6 @@ if exists('g:loaded_syntastic_perl_perl_checker')
|
|||
endif
|
||||
let g:loaded_syntastic_perl_perl_checker = 1
|
||||
|
||||
if !exists('g:syntastic_perl_interpreter')
|
||||
let g:syntastic_perl_interpreter = 'perl'
|
||||
endif
|
||||
|
||||
if !exists('g:syntastic_perl_lib_path')
|
||||
let g:syntastic_perl_lib_path = []
|
||||
endif
|
||||
|
@ -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')
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 ''
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 ''
|
||||
|
|
|
@ -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
|
||||
|
||||
|
||||
|
|
|
@ -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
|
||||
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')
|
||||
|
|
|
@ -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
|
||||
|
68
sources_non_forked/tlib/autoload/tlib/Filter_glob.vim
Normal file
68
sources_non_forked/tlib/autoload/tlib/Filter_glob.vim
Normal file
|
@ -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
|
||||
|
|
@ -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 <buffer> call feedkeys("\<c-j>", 't')
|
||||
" autocmd TLib WinLeave <buffer> let b:tlib_world_event = 'WinLeave' | call feedkeys("\<c-j>", 't')
|
||||
let b:tlib_list_init = 1
|
||||
endif
|
||||
if !exists('w:tlib_list_init')
|
||||
|
@ -923,8 +968,8 @@ function! s:prototype.DisplayHelp() dict "{{{3
|
|||
let self.temp_lines = self.InitHelp()
|
||||
call self.PushHelp('<Esc>', self.key_mode == 'default' ? 'Abort' : 'Reset keymap')
|
||||
call self.PushHelp('Enter, <cr>', 'Pick the current item')
|
||||
call self.PushHelp('<M-Number>', 'Pick an item')
|
||||
call self.PushHelp('Mouse', 'L: Pick item, R: Show menu')
|
||||
call self.PushHelp('<M-Number>', 'Select an item')
|
||||
call self.PushHelp('<BS>, <C-BS>', 'Reduce filter')
|
||||
call self.PushHelp('<S-Esc>, <F10>', 'Enter command')
|
||||
|
||||
|
@ -933,6 +978,7 @@ function! s:prototype.DisplayHelp() dict "{{{3
|
|||
call self.PushHelp('Up/Down', 'Next/previous item')
|
||||
call self.PushHelp('<C|M-q>', 'Edit top filter string')
|
||||
call self.PushHelp('Page Up/Down', 'Scroll')
|
||||
call self.PushHelp('<S-Space>', 'Enter * Wildcard')
|
||||
if self.allow_suspend
|
||||
call self.PushHelp('<C|M-z>', 'Suspend/Resume')
|
||||
call self.PushHelp('<C-o>', '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 <F1> 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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
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)
|
||||
" TLogVAR a:generator, args, val
|
||||
call tlib#cache#Save(a:cfile, {'val': val})
|
||||
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)
|
||||
|
|
|
@ -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
|
||||
|
||||
|
||||
|
|
|
@ -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 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='')
|
||||
|
|
|
@ -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 = {
|
||||
\ "\<PageUp>": 'tlib#agent#PageUp',
|
||||
\ "\<PageDown>": 'tlib#agent#PageDown',
|
||||
\ "\<Home>": 'tlib#agent#Home',
|
||||
\ "\<End>": 'tlib#agent#End',
|
||||
\ "\<Up>": 'tlib#agent#Up',
|
||||
\ "\<Down>": 'tlib#agent#Down',
|
||||
\ "\<c-Up>": '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',
|
||||
\ "\<F1>": 'tlib#agent#Help',
|
||||
\ "\<F10>": 'tlib#agent#ExecAgentByName',
|
||||
\ "\<S-Esc>": '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 =~ '\<reset\>'
|
||||
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
if a:tabnr > 0
|
||||
exec a:tabnr .'tabnext'
|
||||
endif
|
||||
endf
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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~
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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] = {}
|
||||
|
|
|
@ -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
|
||||
|
|
1
sources_non_forked/vim-commentary/CONTRIBUTING.markdown
Normal file
1
sources_non_forked/vim-commentary/CONTRIBUTING.markdown
Normal file
|
@ -0,0 +1 @@
|
|||
See the [contribution guidelines for pathogen.vim](https://github.com/tpope/vim-pathogen/blob/master/CONTRIBUTING.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`.
|
||||
|
|
|
@ -4,7 +4,7 @@ Author: Tim Pope <http://tpo.pe/>
|
|||
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:
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
" commentary.vim - Comment stuff out
|
||||
" Maintainer: Tim Pope <http://tpo.pe/>
|
||||
" 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\@<!')
|
||||
|
@ -38,10 +44,11 @@ function! s:go(type,...) abort
|
|||
endif
|
||||
call setline(lnum,line)
|
||||
endfor
|
||||
silent doautocmd User CommentaryPost
|
||||
endfunction
|
||||
|
||||
function! s:undo()
|
||||
let [l, r] = split(substitute(substitute(&commentstring,'\S\zs%s',' %s',''),'%s\ze\S','%s ',''),'%s',1)
|
||||
function! s:undo() abort
|
||||
let [l, r] = s:surroundings()
|
||||
let lnums = [line('.')+1, line('.')-2]
|
||||
for [index, dir, bound, line] in [[0, -1, 1, ''], [1, 1, line('$'), '']]
|
||||
while lnums[index] != bound && line ==# '' || !(stridx(line,l) || line[strlen(line)-strlen(r) : -1] != r)
|
||||
|
@ -65,7 +72,7 @@ if !hasmapto('<Plug>Commentary') || maparg('gc','n') ==# ''
|
|||
nmap gcu <Plug>CommentaryUndo
|
||||
endif
|
||||
|
||||
if maparg('\\','n') ==# '' && maparg('\','n') ==# ''
|
||||
if maparg('\\','n') ==# '' && maparg('\','n') ==# '' && get(g:, 'commentary_map_backslash', 1)
|
||||
xmap \\ <Plug>Commentary
|
||||
nmap \\ <Plug>Commentary
|
||||
nmap \\\ <Plug>CommentaryLine
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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) =~# '^# .*\<git \%(reset\|rm --cached\) ' || getline(lnum) ==# '# Changes to be committed:'
|
||||
elseif (getline(lnum+1) =~# '^# .*\<git \%(reset\|rm --cached\) ' && getline(lnum+2) ==# '#') || getline(lnum) ==# '# Changes to be committed:'
|
||||
return [matchstr(filename, colon.' *\zs.*'), 'staged']
|
||||
elseif (getline(lnum+1) =~# '^# .*\<git add ' && getline(lnum+2) ==# '#') || getline(lnum) ==# '# Untracked files:'
|
||||
return [filename, 'untracked']
|
||||
elseif getline(lnum+2) =~# '^# .*\<git checkout ' || getline(lnum) ==# '# Changes not staged for commit:'
|
||||
return [matchstr(filename, colon.' *\zs.*'), 'unstaged']
|
||||
elseif getline(lnum+1) =~# '^# .*\<git add/rm ' || getline(lnum) ==# '# Unmerged paths:'
|
||||
elseif getline(lnum+2) =~# '^# .*\<git \%(add\|rm\)' || getline(lnum) ==# '# Unmerged paths:'
|
||||
return [matchstr(filename, colon.' *\zs.*'), 'unmerged']
|
||||
else
|
||||
return [filename, 'untracked']
|
||||
return ['', 'unknown']
|
||||
endif
|
||||
endfunction
|
||||
|
||||
|
@ -1142,7 +1147,8 @@ function! s:Edit(cmd,bang,...) abort
|
|||
endif
|
||||
|
||||
if a:bang
|
||||
let args = s:gsub(join(a:000, ' '), '\\@<!%(\\\\)*\zs[%#]', '\=s:buffer().expand(submatch(0))')
|
||||
let arglist = map(copy(a:000), 's:gsub(v:val, ''\\@<!%(\\\\)*\zs[%#]'', ''\=s:buffer().expand(submatch(0))'')')
|
||||
let args = join(arglist, ' ')
|
||||
if a:cmd =~# 'read'
|
||||
let git = buffer.repo().git_command()
|
||||
let last = line('$')
|
||||
|
@ -1155,7 +1161,7 @@ function! s:Edit(cmd,bang,...) abort
|
|||
return 'redraw|echo '.string(':!'.git.' '.args)
|
||||
else
|
||||
let temp = resolve(tempname())
|
||||
let s:temp_files[temp] = buffer.repo().dir()
|
||||
let s:temp_files[temp] = { 'dir': buffer.repo().dir(), 'args': arglist }
|
||||
silent execute a:cmd.' '.temp
|
||||
if a:cmd =~# 'pedit'
|
||||
wincmd P
|
||||
|
@ -1630,7 +1636,8 @@ function! s:Blame(bang,line1,line2,count,args) abort
|
|||
else
|
||||
let cmd += ['--contents', '-']
|
||||
endif
|
||||
let basecmd = escape(call(s:repo().git_command,cmd+['--',s:buffer().path()],s:repo()),'!')
|
||||
let cmd += ['--', s:buffer().path()]
|
||||
let basecmd = escape(call(s:repo().git_command,cmd,s:repo()),'!')
|
||||
try
|
||||
let cd = exists('*haslocaldir') && haslocaldir() ? 'lcd ' : 'cd '
|
||||
if !s:repo().bare()
|
||||
|
@ -1671,7 +1678,7 @@ function! s:Blame(bang,line1,line2,count,args) abort
|
|||
setlocal scrollbind nowrap nofoldenable
|
||||
let top = line('w0') + &scrolloff
|
||||
let current = line('.')
|
||||
let s:temp_files[temp] = s:repo().dir()
|
||||
let s:temp_files[temp] = { 'dir': s:repo().dir(), 'args': cmd }
|
||||
exe 'keepalt leftabove vsplit '.temp
|
||||
let b:fugitive_blamed_bufnr = bufnr
|
||||
let w:fugitive_leave = restore
|
||||
|
@ -2309,8 +2316,9 @@ augroup fugitive_temp
|
|||
autocmd!
|
||||
autocmd BufNewFile,BufReadPost *
|
||||
\ if has_key(s:temp_files,expand('<afile>:p')) |
|
||||
\ let b:git_dir = s:temp_files[expand('<afile>:p')] |
|
||||
\ let b:git_dir = s:temp_files[expand('<afile>:p')].dir |
|
||||
\ let b:git_type = 'temp' |
|
||||
\ let b:git_args = s:temp_files[expand('<afile>:p')].args |
|
||||
\ call fugitive#detect(expand('<afile>:p')) |
|
||||
\ setlocal bufhidden=delete |
|
||||
\ nnoremap <buffer> <silent> q :<C-U>bdelete<CR>|
|
||||
|
|
103
sources_non_forked/vim-golang/autoload/go/complete.vim
Normal file
103
sources_non_forked/vim-golang/autoload/go/complete.vim
Normal file
|
@ -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
|
30
sources_non_forked/vim-golang/compiler/go.vim
Normal file
30
sources_non_forked/vim-golang/compiler/go.vim
Normal file
|
@ -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 <args>
|
||||
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
|
23
sources_non_forked/vim-golang/ftdetect/gofiletype.vim
Normal file
23
sources_non_forked/vim-golang/ftdetect/gofiletype.vim
Normal file
|
@ -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()
|
17
sources_non_forked/vim-golang/ftplugin/go.vim
Normal file
17
sources_non_forked/vim-golang/ftplugin/go.vim
Normal file
|
@ -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
|
69
sources_non_forked/vim-golang/ftplugin/go/fmt.vim
Normal file
69
sources_non_forked/vim-golang/ftplugin/go/fmt.vim
Normal file
|
@ -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
|
250
sources_non_forked/vim-golang/ftplugin/go/import.vim
Normal file
250
sources_non_forked/vim-golang/ftplugin/go/import.vim
Normal file
|
@ -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 <buffer> <LocalLeader>f :Import fmt<CR>
|
||||
"
|
||||
" Drop fmt
|
||||
" au Filetype go nnoremap <buffer> <LocalLeader>F :Drop fmt<CR>
|
||||
"
|
||||
" Import the word under your cursor
|
||||
" au Filetype go nnoremap <buffer> <LocalLeader>k
|
||||
" \ :exe 'Import ' . expand('<cword>')<CR>
|
||||
"
|
||||
" 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, '', <f-args>)
|
||||
command! -buffer -nargs=1 -complete=customlist,go#complete#Package Import call s:SwitchImport(1, '', <f-args>)
|
||||
command! -buffer -nargs=* -complete=customlist,go#complete#Package ImportAs call s:SwitchImport(1, <f-args>)
|
||||
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
|
78
sources_non_forked/vim-golang/ftplugin/go/test.sh
Normal file
78
sources_non_forked/vim-golang/ftplugin/go/test.sh
Normal file
|
@ -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 <<EOF
|
||||
package test
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"io"
|
||||
"net"
|
||||
|
||||
"mycorp/foo"
|
||||
)
|
||||
EOF
|
||||
|
||||
fail=0
|
||||
|
||||
# usage: test_one command pattern
|
||||
# Pattern is a PCRE expression that will match across lines.
|
||||
test_one() {
|
||||
echo 2>&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 <<EOF
|
||||
package test
|
||||
|
||||
import (
|
||||
"foo"
|
||||
|
||||
"something"
|
||||
"zoo"
|
||||
)
|
||||
EOF
|
||||
|
||||
test_one "Drop something" '\([^"]*"foo"[^"]*"zoo"[^"]*\)'
|
||||
|
||||
rm -f base.go test.go
|
||||
if [ $fail -gt 0 ]; then
|
||||
echo 2>&1 "FAIL"
|
||||
exit 1
|
||||
fi
|
||||
echo 2>&1 "PASS"
|
65
sources_non_forked/vim-golang/indent/go.vim
Normal file
65
sources_non_forked/vim-golang/indent/go.vim
Normal file
|
@ -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
|
6
sources_non_forked/vim-golang/mirror.txt
Normal file
6
sources_non_forked/vim-golang/mirror.txt
Normal file
|
@ -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
|
130
sources_non_forked/vim-golang/plugin/godoc.vim
Normal file
130
sources_non_forked/vim-golang/plugin/godoc.vim
Normal file
|
@ -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(<f-args>)
|
||||
endif
|
||||
|
||||
nnoremap <silent> <Plug>(godoc-keyword) :<C-u>call <SID>Godoc('')<CR>
|
||||
|
||||
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 <buffer> <silent> K :Godoc<cr>
|
||||
|
||||
au BufHidden <buffer> call let <SID>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('<cword>')
|
||||
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
|
101
sources_non_forked/vim-golang/readme.txt
Normal file
101
sources_non_forked/vim-golang/readme.txt
Normal file
|
@ -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 <buffer> 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.
|
207
sources_non_forked/vim-golang/syntax/go.vim
Normal file
207
sources_non_forked/vim-golang/syntax/go.vim
Normal file
|
@ -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 /\<func\>/
|
||||
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 "\(\<chan\)\@<=\s\+\(<-\)\@="
|
||||
" value-ignoring receives in a few contexts
|
||||
syn match goSpaceError display "\(\(^\|[={(,;]\)\s*<-\)\@<=\s\+"
|
||||
endif
|
||||
|
||||
" Extra types commonly seen
|
||||
if go_highlight_extra_types != 0
|
||||
syn match goExtraType /\<bytes\.\(Buffer\)\>/
|
||||
syn match goExtraType /\<io\.\(Reader\|Writer\|ReadWriter\|ReadWriteCloser\)\>/
|
||||
syn match goExtraType /\<reflect\.\(Kind\|Type\|Value\)\>/
|
||||
syn match goExtraType /\<unsafe\.Pointer\>/
|
||||
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"
|
20
sources_non_forked/vim-golang/syntax/godoc.vim
Normal file
20
sources_non_forked/vim-golang/syntax/godoc.vim
Normal file
|
@ -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 <args>
|
||||
|
||||
HiLink godocTitle Title
|
||||
|
||||
delcommand HiLink
|
||||
|
||||
let b:current_syntax = "godoc"
|
||||
|
||||
" vim:ts=4 sts=2 sw=2:
|
|
@ -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
|
||||
|
||||
" 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
|
||||
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
|
||||
|
|
|
@ -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
|
|
@ -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)
|
||||
|
||||
github.com/MarcWeber/UltiSnips:
|
||||
python, snipmate-snippets and UltiSnips-snippets
|
||||
|
||||
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)
|
||||
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
|
||||
|
||||
UltiSnips engine has additional features such as "nested 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).
|
||||
|
||||
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
|
||||
|
|
|
@ -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:
|
||||
|
||||
|
|
|
@ -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 #
|
||||
##############
|
||||
|
@ -19,10 +24,9 @@ def _parse_comments(s):
|
|||
try:
|
||||
while True:
|
||||
# get the flags and text of a comment part
|
||||
flags,text = i.next().split(':', 1)
|
||||
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:
|
||||
|
@ -33,50 +37,42 @@ def _parse_comments(s):
|
|||
indent = " " * int(flags[-1])
|
||||
ctriple.append(text)
|
||||
|
||||
flags,text = i.next().split(':', 1)
|
||||
flags,text = next(i).split(':', 1)
|
||||
assert(flags[0] == 'm')
|
||||
ctriple.append(text)
|
||||
|
||||
flags,text = i.next().split(':', 1)
|
||||
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
|
||||
|
||||
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
|
||||
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
|
||||
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-twidth-nspaces) + m
|
||||
eline = i + 2*m + bwidth*m + m + e
|
||||
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 #
|
||||
##########################
|
||||
|
|
52
sources_non_forked/vim-snippets/UltiSnips/bib.snippets
Normal file
52
sources_non_forked/vim-snippets/UltiSnips/bib.snippets
Normal file
|
@ -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
|
|
@ -1,3 +1,5 @@
|
|||
priority -50
|
||||
|
||||
global !p
|
||||
def newsoa():
|
||||
import datetime
|
||||
|
|
|
@ -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
|
||||
|
||||
|
@ -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,7 +103,19 @@ 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
|
||||
|
||||
|
@ -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:
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
328
sources_non_forked/vim-snippets/UltiSnips/cs.snippets
Normal file
328
sources_non_forked/vim-snippets/UltiSnips/cs.snippets
Normal file
|
@ -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
|
||||
/// <summary>
|
||||
/// $1
|
||||
/// </summary>
|
||||
endsnippet
|
|
@ -2,6 +2,8 @@
|
|||
# Most of these came from TextMate #
|
||||
###########################################################################
|
||||
|
||||
priority -50
|
||||
|
||||
snippet ! "!important CSS (!)"
|
||||
${1:!important}
|
||||
endsnippet
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
# Simple shortcuts
|
||||
|
||||
priority -50
|
||||
|
||||
snippet imp "import (imp)" b
|
||||
import ${1:std.stdio};
|
||||
endsnippet
|
||||
|
@ -126,7 +128,7 @@ else
|
|||
}
|
||||
endsnippet
|
||||
|
||||
snippet eif "else if (elif)" b
|
||||
snippet elif "else if (elif)" b
|
||||
else if(${1:/*condition*/})
|
||||
{
|
||||
${VISUAL}${0:/*code*/}
|
||||
|
@ -265,11 +267,11 @@ this(${1:/*args*/})
|
|||
}
|
||||
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
|
||||
|
||||
|
@ -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
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
priority -50
|
||||
|
||||
# Generic Tags
|
||||
snippet %
|
||||
{% ${1} %}${2}
|
||||
|
@ -24,7 +26,7 @@ endsnippet
|
|||
snippet block
|
||||
{% block ${1} %}
|
||||
${2}
|
||||
{% endblock %}
|
||||
{% endblock $1 %}
|
||||
endsnippet
|
||||
|
||||
snippet #
|
||||
|
@ -76,7 +78,7 @@ snippet if
|
|||
{% endif %}
|
||||
endsnippet
|
||||
|
||||
snippet el
|
||||
snippet else
|
||||
{% else %}
|
||||
${1}
|
||||
endsnippet
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# Credit: @iurifg
|
||||
priority -50
|
||||
|
||||
snippet do
|
||||
do
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
# TEXTMATE SNIPPETS #
|
||||
###########################################################################
|
||||
|
||||
priority -50
|
||||
|
||||
snippet pat "Case:Receive:Try Clause"
|
||||
${1:pattern}${2: when ${3:guard}} ->;
|
||||
${4:body}
|
||||
|
|
|
@ -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
|
||||
|
@ -18,7 +20,6 @@ def textmate_var(var, snip):
|
|||
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
|
||||
|
@ -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"
|
||||
|
@ -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,13 +149,13 @@ 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)`
|
||||
`!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)`
|
||||
`!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)"
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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}
|
||||
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"
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
# Snippets for VIM Help Files
|
||||
|
||||
priority -50
|
||||
|
||||
global !p
|
||||
def sec_title(snip, t):
|
||||
file_start = snip.fn.split('.')[0]
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
priority -50
|
||||
|
||||
###########################################################################
|
||||
# TextMate Snippets #
|
||||
###########################################################################
|
||||
|
@ -123,21 +125,21 @@ endsnippet
|
|||
#############
|
||||
# HTML TAGS #
|
||||
#############
|
||||
snippet input "Input with Label"
|
||||
snippet input "Input with Label" w
|
||||
<label for="${2:${1/[[:alpha:]]+|( )/(?1:_:\L$0)/g}}">$1</label><input type="${3:text/submit/hidden/button}" name="${4:$2}" value="$5"${6: id="${7:$2}"}`!p x(snip)`>
|
||||
|
||||
endsnippet
|
||||
|
||||
snippet input "XHTML <input>"
|
||||
snippet input "XHTML <input>" w
|
||||
<input type="${1:text/submit/hidden/button}" name="${2:some_name}" value="$3"${4: id="${5:$2}"}`!p x(snip)`>
|
||||
endsnippet
|
||||
|
||||
|
||||
snippet opt "Option"
|
||||
snippet opt "Option" w
|
||||
<option${1: value="${2:option}"}>${3:$2}</option>
|
||||
endsnippet
|
||||
|
||||
snippet select "Select Box"
|
||||
snippet select "Select Box" w
|
||||
<select name="${1:some_name}" id="${2:$1}"${3:${4: multiple}${5: onchange="${6:}"}${7: size="${8:1}"}}>
|
||||
<option${9: value="${10:option1}"}>${11:$10}</option>
|
||||
<option${12: value="${13:option2}"}>${14:$13}</option>${15:}
|
||||
|
@ -146,18 +148,22 @@ snippet select "Select Box"
|
|||
endsnippet
|
||||
|
||||
|
||||
snippet textarea "XHTML <textarea>"
|
||||
snippet textarea "XHTML <textarea>" w
|
||||
<textarea name="${1:Name}" rows="${2:8}" cols="${3:40}">$0</textarea>
|
||||
endsnippet
|
||||
|
||||
snippet mailto "XHTML <a mailto: >"
|
||||
snippet mailto "XHTML <a mailto: >" w
|
||||
<a href="mailto:${1:joe@example.com}?subject=${2:feedback}">${3:email me}</a>
|
||||
endsnippet
|
||||
|
||||
snippet base "XHTML <base>"
|
||||
snippet base "XHTML <base>" w
|
||||
<base href="$1"${2: target="$3"}`!p x(snip)`>
|
||||
endsnippet
|
||||
|
||||
snippet img "XHTML <img>" w
|
||||
<img src="${1:imgsrc}">
|
||||
endsnippet
|
||||
|
||||
snippet body "XHTML <body>"
|
||||
<body id="${1:`!p
|
||||
snip.rv = snip.fn and 'Hallo' or 'Nothin'
|
||||
|
@ -166,13 +172,13 @@ snip.rv = snip.fn and 'Hallo' or 'Nothin'
|
|||
</body>
|
||||
endsnippet
|
||||
|
||||
snippet div "XHTML <div>"
|
||||
<div`!p snip.rv=' id="' if t[1] else ""`${1:name}`!p snip.rv = '"' if t[1] else ""`>
|
||||
snippet div "XHTML <div>" w
|
||||
<div`!p snip.rv=' id="' if t[1] else ""`${1:name}`!p snip.rv = '"' if t[1] else ""``!p snip.rv=' class="' if t[2] else ""`${2:name}`!p snip.rv = '"' if t[2] else ""`>
|
||||
$0
|
||||
</div>
|
||||
endsnippet
|
||||
|
||||
snippet form "XHTML <form>"
|
||||
snippet form "XHTML <form>" w
|
||||
<form action="${1:`!p
|
||||
snip.rv = (snip.basename or 'unnamed') + '_submit'
|
||||
`}" method="${2:get}" accept-charset="utf-8">
|
||||
|
@ -182,7 +188,7 @@ snip.rv = (snip.basename or 'unnamed') + '_submit'
|
|||
</form>
|
||||
endsnippet
|
||||
|
||||
snippet h1 "XHTML <h1>"
|
||||
snippet h1 "XHTML <h1>" w
|
||||
<h1 id="${1/[\w\d]+|( )/(?1:_:\L$0\E)/g}">${1}</h1>
|
||||
endsnippet
|
||||
|
||||
|
@ -194,71 +200,70 @@ snippet head "XHTML <head>"
|
|||
</head>
|
||||
endsnippet
|
||||
|
||||
snippet link "XHTML <link>"
|
||||
snippet link "XHTML <link>" w
|
||||
<link rel="${1:stylesheet}" href="${2:/css/master.css}" type="text/css" media="${3:screen}" title="${4:no title}" charset="${5:utf-8}"`!p x(snip)`>
|
||||
endsnippet
|
||||
|
||||
snippet meta "XHTML <meta>"
|
||||
snippet meta "XHTML <meta>" w
|
||||
<meta name="${1:name}" content="${2:content}"`!p x(snip)`>
|
||||
endsnippet
|
||||
|
||||
snippet scriptsrc "XHTML <script src...>"
|
||||
snippet scriptsrc "XHTML <script src...>" w
|
||||
<script src="$1" type="text/javascript" charset="${3:utf-8}"></script>
|
||||
endsnippet
|
||||
|
||||
snippet script "XHTML <script>"
|
||||
snippet script "XHTML <script>" w
|
||||
<script type="text/javascript" charset="utf-8">
|
||||
$0
|
||||
</script>
|
||||
endsnippet
|
||||
|
||||
snippet style "XHTML <style>"
|
||||
snippet style "XHTML <style>" w
|
||||
<style type="text/css" media="screen">
|
||||
$0
|
||||
</style>
|
||||
endsnippet
|
||||
|
||||
snippet table "XHTML <table>"
|
||||
snippet table "XHTML <table>" w
|
||||
<table border="${1:0}"${2: cellspacing="${3:5}" cellpadding="${4:5}"}>
|
||||
<tr><th>${5:Header}</th></tr>
|
||||
<tr><td>${0:Data}</td></tr>
|
||||
</table>
|
||||
endsnippet
|
||||
|
||||
snippet a "Link"
|
||||
snippet a "Link" w
|
||||
<a href="${1:http://www.${2:url.com}}"${3: target="_blank"}>${4:Anchor Text}</a>
|
||||
endsnippet
|
||||
|
||||
snippet p "paragraph"
|
||||
snippet p "paragraph" w
|
||||
<p>$0</p>
|
||||
endsnippet
|
||||
|
||||
snippet li "list item"
|
||||
<li></li>
|
||||
snippet li "list item" w
|
||||
<li>$0</li>
|
||||
endsnippet
|
||||
|
||||
snippet ul "unordered list"
|
||||
snippet ul "unordered list" w
|
||||
<ul>
|
||||
$0
|
||||
</ul>
|
||||
endsnippet
|
||||
|
||||
snippet td "table cell"
|
||||
snippet td "table cell" w
|
||||
<td>$0</td>
|
||||
endsnippet
|
||||
|
||||
snippet tr "table row"
|
||||
snippet tr "table row" w
|
||||
<tr>$0</tr>
|
||||
endsnippet
|
||||
|
||||
snippet title "XHTML <title>"
|
||||
snippet title "XHTML <title>" w
|
||||
<title>${1:`!p snip.rv = snip.basename or "Page Title"`}</title>
|
||||
endsnippet
|
||||
|
||||
snippet fieldset "Fieldset"
|
||||
snippet fieldset "Fieldset" w
|
||||
<fieldset id="${1/[\w\d]+|( )/(?1:_:\L$0\E)/g}" ${2:class="${3:}"}>
|
||||
<legend>$1</legend>
|
||||
|
||||
$0
|
||||
</fieldset>
|
||||
endsnippet
|
||||
|
@ -282,7 +287,7 @@ snippet html5 "HTML5 Template"
|
|||
<html>
|
||||
<head>
|
||||
<title>${1}</title>
|
||||
<meta charset="utf-8">
|
||||
<meta charset="utf-8" />
|
||||
</head>
|
||||
<body>
|
||||
<header>
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1 +1,3 @@
|
|||
priority -50
|
||||
|
||||
extends html, django
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
priority -50
|
||||
|
||||
extends html, jinja2
|
|
@ -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 += " "
|
||||
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
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
priority -50
|
||||
|
||||
###########################################################################
|
||||
# TextMate Snippets #
|
||||
###########################################################################
|
||||
|
@ -7,13 +9,13 @@ endsnippet
|
|||
|
||||
snippet '':f "object method string"
|
||||
'${1:${2:#thing}:${3:click}}': function(element) {
|
||||
$0
|
||||
${VISUAL}$0
|
||||
}${10:,}
|
||||
endsnippet
|
||||
|
||||
snippet :f "Object Method"
|
||||
${1:method_name}: function(${3:attribute}) {
|
||||
$0
|
||||
${VISUAL}$0
|
||||
}${10:,}
|
||||
endsnippet
|
||||
|
||||
|
@ -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}
|
||||
${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:
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
# Ember snippets #
|
||||
###################################################################
|
||||
|
||||
priority -50
|
||||
|
||||
# Application
|
||||
snippet eapp "App.Name = Ember.Application.create({});"
|
||||
${1:App.Name} = Ember.Application.create({});
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
|
@ -1,3 +1,4 @@
|
|||
priority -50
|
||||
|
||||
# http://jinja.pocoo.org/
|
||||
|
||||
|
@ -151,7 +152,6 @@ snippet with "with" b
|
|||
{% endwith %}
|
||||
endsnippet
|
||||
|
||||
|
||||
snippet autoescape "autoescape" b
|
||||
{% autoescape ${1:true} %}
|
||||
$2
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
priority -50
|
||||
|
||||
snippet s "String" b
|
||||
"${1:key}": "${0:value}",
|
||||
endsnippet
|
||||
|
@ -16,4 +18,3 @@ snippet o "Object" b
|
|||
${VISUAL}$0
|
||||
},
|
||||
endsnippet
|
||||
|
||||
|
|
|
@ -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
|
|
@ -0,0 +1,3 @@
|
|||
priority -50
|
||||
|
||||
extends haskell
|
|
@ -1,3 +1,5 @@
|
|||
priority -50
|
||||
|
||||
#################################
|
||||
# Snippets for the Lua language #
|
||||
#################################
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
priority -50
|
||||
|
||||
#################
|
||||
# From snipmate #
|
||||
#################
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
###########################################################################
|
||||
# SNIPPETS for MARKDOWN #
|
||||
###########################################################################
|
||||
priority -50
|
||||
|
||||
###########################
|
||||
# Sections and Paragraphs #
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
priority -50
|
||||
|
||||
###########################################################################
|
||||
# TextMate Snippets #
|
||||
###########################################################################
|
||||
|
@ -189,7 +191,7 @@ if(choice == NSAlertDefaultReturn) // "$3"
|
|||
}
|
||||
else if(choice == NSAlertAlternateReturn) // "$4"
|
||||
{
|
||||
|
||||
$0
|
||||
}
|
||||
endsnippet
|
||||
|
||||
|
|
|
@ -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,32 +139,32 @@ 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"
|
||||
|
|
|
@ -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 = <FILE>; 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...}
|
||||
}
|
||||
|
|
|
@ -1,108 +1,264 @@
|
|||
snippet <? "php open tag" b
|
||||
<?php
|
||||
priority -50
|
||||
|
||||
## Snippets from SnipMate, taken from
|
||||
## https://github.com/scrooloose/snipmate-snippets.git
|
||||
|
||||
snippet array "array"
|
||||
$${1:arrayName} = array('${2}' => ${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 '<pre>' . var_export($1, 1) . '</pre>';$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:
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
# 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
|
||||
abspath = os.path.abspath(path)
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue