1
0
mirror of https://github.com/amix/vimrc synced 2025-06-23 23:15:01 +08: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

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