1
0
Fork 0
mirror of synced 2024-09-11 16:59:03 -04:00

Updated plugins. Added vim-golang as a mode

This commit is contained in:
amix 2014-03-11 21:10:50 +01:00
parent 2b82c75631
commit 8f0740e307
125 changed files with 4121 additions and 2440 deletions

View file

@ -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?

View file

@ -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

View file

@ -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:
mkdir -p ~/.vim/autoload ~/.vim/bundle; \
curl -so ~/.vim/autoload/pathogen.vim \
https://raw.github.com/tpope/vim-pathogen/master/autoload/pathogen.vim
Next you *need to add this* to your ~/.vimrc:
execute pathogen#infect()
First I'll show you how to install Tim Pope's [pathogen][1] so that it's easy to
install syntastic. Do this in your terminal so that you get the `pathogen.vim`
file and the directories it needs:
```sh
mkdir -p ~/.vim/autoload ~/.vim/bundle; \
curl -so ~/.vim/autoload/pathogen.vim \
https://raw.github.com/tpope/vim-pathogen/master/autoload/pathogen.vim
```
Next you *need* to add this to your `~/.vimrc`:
```vim
execute pathogen#infect()
```
<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:
cd ~/.vim/bundle
git clone https://github.com/scrooloose/syntastic.git
You now have pathogen installed and can put syntastic into `~/.vim/bundle` like
this:
```sh
cd ~/.vim/bundle
git clone https://github.com/scrooloose/syntastic.git
```
Quit vim and start it back up to reload it, then type:
```vim
:Helptags
```
If you get an error when you do this, then you probably didn't install
[pathogen][1] right. Go back to [Step 1](#step1) and make sure you did the following:
:Helptags
If you get an error when you do this, then you probably didn't install pathogen right. Go back to
step 1 and make sure you did the following:
1. Created both the ~/.vim/autoload and ~/.vim/bundle directories.
2. Added the "call pathogen#infect()" line to your ~/.vimrc file
3. Did the git clone of syntastic inside ~/.vim/bundle
1. Created both the `~/.vim/autoload` and `~/.vim/bundle` directories.
2. Added the `call pathogen#infect()` line to your `~/.vimrc` file
3. Did the `git clone` of syntastic inside `~/.vim/bundle`
4. Have permissions to access all of these directories.
@ -111,56 +114,50 @@ step 1 and make sure you did the following:
__Q. I installed syntastic but it isn't reporting any errors...__
A. The most likely reason is that none of the syntax checkers that it requires
is installed. For example: python requires either `flake8`, `pyflakes`
or `pylint` to be installed and in `$PATH`. To see which executables are
supported, just look in `syntax_checkers/<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:
```vim
let g:syntastic_always_populate_loc_list=1
let g:syntastic_always_populate_loc_list = 1
```
__Q. How can I pass additional arguments to a checker?__
A. Almost all syntax checkers use the `makeprgBuild()` function. Those checkers
that do can be configured using global variables. The general form of the
global args variables are:
```vim
syntastic_<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:
```vim
let g:syntastic_ruby_mri_args="--my --args --here"
let g:syntastic_ruby_mri_args = "--my --args --here"
```
See `:help syntastic-checker-options` for more information.
@ -170,24 +167,24 @@ which one(s) to use?__
A. Stick a line like this in your vimrc:
```vim
let g:syntastic_<filetype>_checkers=['<checker-name>']
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
let g:syntastic_python_checkers=['pylint']
let g:syntastic_python_checkers = ['pylint']
```
Some filetypes, like PHP, have style checkers as well as syntax checkers. These
can be chained together like this:
```vim
let g:syntastic_php_checkers=['php', 'phpcs', 'phpmd']
let g:syntastic_php_checkers = ['php', 'phpcs', 'phpmd']
```
This is telling syntastic to run the `php` checker first, and if no errors are
@ -210,6 +207,13 @@ checkers. You can usually configure the options that are passed to the style
checkers, or just disable them. Take a look at the [wiki][3] to see what
options are available.
Alternatively, you can use `g:syntastic_quiet_messages` to filter out the
messages you don't want to see. e.g. To turn off all style messages:
```vim
let g:syntastic_quiet_messages = { "type": "style" }
```
See `:help syntastic_quiet_messages` for details.
__Q. The error window is closed automatically when I :quit the current buffer
but not when I :bdelete it?__
@ -245,3 +249,4 @@ a look at [jedi-vim][7], [python-mode][8], or [YouCompleteMe][9].
[7]: https://github.com/davidhalter/jedi-vim
[8]: https://github.com/klen/python-mode
[9]: https://github.com/Valloric/YouCompleteMe
[10]: http://perldoc.perl.org/perlrun.html#*-c*

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -2,10 +2,11 @@
-export([main/1]).
main([FileName]) ->
LibDirs = filelib:wildcard("{lib,deps}/*/ebin"),
LibDirs = (["ebin", "include", "src", "test"] ++
filelib:wildcard("{apps,deps,lib}/*/{ebin,include}")),
compile(FileName, LibDirs);
main([FileName | ["-rebar" | [Path | LibDirs]]]) ->
main([FileName, "-rebar", Path, LibDirs]) ->
{ok, L} = file:consult(Path),
P = dict:from_list(L),
Root = filename:dirname(Path),
@ -31,23 +32,20 @@ main([FileName | ["-rebar" | [Path | LibDirs]]]) ->
%io:format("~p~n", [LibDirs1]),
compile(FileName, LibDirs1);
main([FileName | LibDirs]) ->
main([FileName, LibDirs]) ->
compile(FileName, LibDirs).
compile(FileName, LibDirs) ->
Root = get_root(filename:dirname(FileName)),
ok = code:add_pathsa(LibDirs),
compile:file(FileName, [warn_obsolete_guard,
warn_unused_import,
warn_shadow_vars,
warn_export_vars,
strong_validation,
report,
{i, filename:join(Root, "include")},
{i, filename:join(Root, "deps")},
{i, filename:join(Root, "apps")},
{i, filename:join(Root, "lib")}
]).
compile:file(FileName,
[warn_obsolete_guard,
warn_unused_import,
warn_shadow_vars,
warn_export_vars,
strong_validation,
report] ++
[{i, filename:join(Root, I)} || I <- LibDirs]).
get_root(Dir) ->
Path = filename:split(filename:absname(Dir)),

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -11,6 +11,22 @@
"
"============================================================================
"
" Security:
"
" This checker runs 'perl -c' against your file, which in turn executes
" any BEGIN, UNITCHECK, and CHECK blocks, and any use statements in
" your file. This is probably fine if you wrote the file yourself,
" but it can be a problem if you're trying to check third party files.
" If you are 100% willing to let Vim run the code in your file, set
" g:syntastic_enable_perl_checker to 1 in your vimrc to enable this
" checker:
"
" let g:syntastic_enable_perl_checker = 1
"
" References:
"
" - http://perldoc.perl.org/perlrun.html#*-c*
"
" Checker options:
"
" - g:syntastic_perl_interpreter (string; default: 'perl')
@ -24,11 +40,7 @@
if exists('g:loaded_syntastic_perl_perl_checker')
finish
endif
let g:loaded_syntastic_perl_perl_checker=1
if !exists('g:syntastic_perl_interpreter')
let g:syntastic_perl_interpreter = 'perl'
endif
let g:loaded_syntastic_perl_perl_checker = 1
if !exists('g:syntastic_perl_lib_path')
let g:syntastic_perl_lib_path = []
@ -38,6 +50,10 @@ let s:save_cpo = &cpo
set cpo&vim
function! SyntaxCheckers_perl_perl_IsAvailable() dict
if !exists('g:syntastic_perl_interpreter')
let g:syntastic_perl_interpreter = self.getExec()
endif
" don't call executable() here, to allow things like
" let g:syntastic_perl_interpreter='/usr/bin/env perl'
silent! call system(syntastic#util#shexpand(g:syntastic_perl_interpreter) . ' -e ' . syntastic#util#shescape('exit(0)'))
@ -45,6 +61,11 @@ function! SyntaxCheckers_perl_perl_IsAvailable() dict
endfunction
function! SyntaxCheckers_perl_perl_GetLocList() dict
if !exists('g:syntastic_enable_perl_checker') || !g:syntastic_enable_perl_checker
call syntastic#log#error('checker perl/perl: checks disabled for security reasons; set g:syntastic_enable_perl_checker to 1 to override')
return []
endif
let exe = expand(g:syntastic_perl_interpreter)
if type(g:syntastic_perl_lib_path) == type('')
call syntastic#log#deprecationWarn('variable g:syntastic_perl_lib_path should be a list')

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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 ''

View file

@ -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

View file

@ -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

View file

@ -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 ''

View file

@ -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

View file

@ -3,8 +3,8 @@
" @Website: http://www.vim.org/account/profile.php?user_id=4037
" @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
" @Created: 2008-11-25.
" @Last Change: 2013-09-25.
" @Revision: 0.0.51
" @Last Change: 2014-01-23.
" @Revision: 0.0.57
let s:prototype = tlib#Filter_cnf#New({'_class': ['Filter_cnfd'], 'name': 'cnfd'}) "{{{2
let s:prototype.highlight = g:tlib#input#higroup
@ -29,11 +29,7 @@ let s:Help = s:prototype.Help
" :nodoc:
function! s:prototype.Help(world) dict "{{{3
call call(s:Help, [a:world], self)
if self.name == 'cnfx'
call a:world.PushHelp(g:tlib#Filter_cnfx#expander, 'Any characters')
else
call a:world.PushHelp('.', 'Any characters')
endif
call a:world.PushHelp('.', 'Any characters')
endf
@ -50,16 +46,6 @@ function! s:prototype.PushFrontFilter(world, char) dict "{{{3
endf
" :nodoc:
function! s:prototype.ReduceFrontFilter(world) dict "{{{3
let flt = a:world.filter[0][0]
if flt =~ '\\\.\\{-}$'
let a:world.filter[0][0] = flt[0:-7]
else
let a:world.filter[0][0] = flt[0:-2]
endif
endf
" :nodoc:
function! s:prototype.CleanFilter(filter) dict "{{{3
return substitute(a:filter, '\\.\\{-}', '.', 'g')

View file

@ -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

View 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

View file

@ -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,16 +968,17 @@ 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')
if self.key_mode == 'default'
call self.PushHelp('<C|M-r>', 'Reset the display')
call self.PushHelp('<C|M-r>', 'Reset the display')
call self.PushHelp('Up/Down', 'Next/previous item')
call self.PushHelp('<C|M-q>', 'Edit top filter string')
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

View file

@ -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

View file

@ -4,7 +4,7 @@
" @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
" @Created: 2007-06-30.
" @Last Change: 2013-09-25.
" @Revision: 0.1.220
" @Revision: 0.1.230
" The cache directory. If empty, use |tlib#dir#MyRuntime|.'/cache'.
@ -109,13 +109,20 @@ endf
function! tlib#cache#Save(cfile, dictionary) "{{{3
" TLogVAR a:cfile, a:dictionary
call tlib#persistent#Save(a:cfile, a:dictionary)
endf
function! tlib#cache#Get(cfile) "{{{3
function! tlib#cache#Get(cfile, ...) "{{{3
call tlib#cache#MaybePurge()
return tlib#persistent#Get(a:cfile)
if !empty(a:cfile) && filereadable(a:cfile)
let val = readfile(a:cfile, 'b')
return eval(join(val, "\n"))
else
let default = a:0 >= 1 ? a:1 : {}
return default
endif
endf
@ -123,10 +130,18 @@ endf
" or does not exist, create it calling a generator function.
function! tlib#cache#Value(cfile, generator, ftime, ...) "{{{3
if !filereadable(a:cfile) || (a:ftime != 0 && getftime(a:cfile) < a:ftime)
let args = a:0 >= 1 ? a:1 : []
let val = call(a:generator, args)
" TLogVAR a:generator, args, val
call tlib#cache#Save(a:cfile, {'val': val})
if empty(a:generator) && a:0 >= 1
" TLogVAR a:1
let val = a:1
else
let args = a:0 >= 1 ? a:1 : []
" TLogVAR a:generator, args
let val = call(a:generator, args)
endif
" TLogVAR val
let cval = {'val': val}
" TLogVAR cval
call tlib#cache#Save(a:cfile, cval)
return val
else
let val = tlib#cache#Get(a:cfile)

View file

@ -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

View file

@ -3,8 +3,8 @@
" @Website: http://www.vim.org/account/profile.php?user_id=4037
" @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
" @Created: 2007-08-23.
" @Last Change: 2013-05-14.
" @Revision: 0.0.46
" @Last Change: 2014-02-05.
" @Revision: 0.0.53
if &cp || exists("loaded_tlib_cmd_autoload")
finish
@ -58,10 +58,12 @@ endf
" call tlib#cmd#BrowseOutputWithCallback('tlib#cmd#ParseScriptname', 'scriptnames')
function! tlib#cmd#BrowseOutputWithCallback(callback, command) "{{{3
let list = tlib#cmd#OutputAsList(a:command)
let cmd = tlib#input#List('s', 'Output of: '. a:command, list)
if !empty(cmd)
let Callback = function(a:callback)
call call(Callback, [cmd])
let cmds = tlib#input#List('m', 'Output of: '. a:command, list)
if !empty(cmds)
for cmd in cmds
let Callback = function(a:callback)
call call(Callback, [cmd])
endfor
endif
endf
@ -70,8 +72,9 @@ function! tlib#cmd#DefaultBrowseOutput(cmd) "{{{3
endf
function! tlib#cmd#ParseScriptname(line) "{{{3
let parsedValue = substitute(a:line, '^.\{-}\/', '/'