1
0
mirror of https://github.com/amix/vimrc synced 2025-02-28 14:12:51 +08:00

Merge pull request #1 from amix/master

Update_20170105
This commit is contained in:
evilX 2017-01-05 02:58:01 +08:00 committed by GitHub
commit b5bf204cb5
238 changed files with 20060 additions and 5849 deletions

3
.gitignore vendored
View File

@ -1,8 +1,9 @@
temp_dirs/undodir*
temp_dirs/undodir/*
sources_non_forked/ack.vim/.netrwhist
temp_dirs/yankring_history_v2.txt
sources_forked/yankring/doc/tags
sources_non_forked/tlib/doc/tags
sources_non_forked/ctrlp.vim/doc/tags*
my_configs.vim
tags
.DS_Store

View File

@ -31,6 +31,10 @@ This is useful to install on remote servers where you don't need many plugins an
Use [msysgit](http://msysgit.github.com/) to checkout the repository and run the installation instructions above. No special instructions needed ;-)
## How to install on Linux
If you have vim aliased as `vi` instead of `vim`, make sure to either alias it: `alias vi=vim`. Otherwise, `apt-get install vim`
## How to update to latest version?
Simply just do a git rebase!
@ -121,43 +125,34 @@ Now you have vim-rails installed ;-)
### Plugin related mappings
Open [bufexplorer](https://github.com/vim-scripts/bufexplorer.zip) and see and manage the current buffers:
Open [bufexplorer](https://github.com/vim-scripts/bufexplorer.zip) and see and manage the current buffers (`<leader>o`):
map <leader>o :BufExplorer<cr>
Open [MRU.vim](https://github.com/vim-scripts/mru.vim) and see the recently open files:
Open [MRU.vim](https://github.com/vim-scripts/mru.vim) and see the recently open files (`<leader>f`):
map <leader>f :MRU<CR>
Open [ctrlp.vim](https://github.com/kien/ctrlp.vim) plugin:
Open [ctrlp.vim](https://github.com/kien/ctrlp.vim) plugin (`<leader>j` or `<ctrl>f`):
let g:ctrlp_map = '<c-f>'
Open [PeepOpen](http://topfunky.github.io/PeepOpen/) plugin:
map <leader>j :PeepOpen<cr>
Managing the [NERD Tree](https://github.com/scrooloose/nerdtree) plugin:
map <leader>nn :NERDTreeToggle<cr>
map <leader>nb :NERDTreeFromBookmark
map <leader>nf :NERDTreeFind<cr>
[goyo.vim](https://github.com/junegunn/goyo.vim) and [vim-zenroom2](https://github.com/amix/vim-zenroom2) lets you only focus on one thing at a time. It removes all the distractions and centers the content. It has a special look when editing Markdown, reStructuredText and textfiles. It only has one mapping.
[goyo.vim](https://github.com/junegunn/goyo.vim) and [vim-zenroom2](https://github.com/amix/vim-zenroom2) lets you only focus on one thing at a time. It removes all the distractions and centers the content. It has a special look when editing Markdown, reStructuredText and textfiles. It only has one mapping. (`<leader>z`)
map <leader>z :Goyo<cr>
### Normal mode mappings
Fast saving of a buffer:
Fast saving of a buffer (`<leader>w`):
nmap <leader>w :w!<cr>
Treat long lines as break lines (useful when moving around in them):
map j gj
map k gk
Map `<Space>` to `/` (search) and `<Ctrl>+<Space>` to `?` (backwards search):
map <space> /
@ -168,14 +163,14 @@ Disable highlight when `<leader><cr>` is pressed:
map <silent> <leader><cr> :noh<cr>
Smart way to move between windows:
Smart way to move between windows (`<ctrl>j` etc.):
map <C-j> <C-W>j
map <C-k> <C-W>k
map <C-h> <C-W>h
map <C-l> <C-W>l
Closing of current buffer(s):
Closing of current buffer(s) (`<leader>bd` and (`<leader>ba`)):
" Close current buffer
map <leader>bd :Bclose<cr>
@ -312,18 +307,6 @@ Vimscript mappings:
map <leader>n :cn<cr>
map <leader>p :cp<cr>
## Useful blog tips regarding my Vim setup
* [Vim: Annotate strings with gettext (the macro way)](http://amix.dk/blog/post/19678#Vim-Annotate-strings-with-gettext-the-macro-way)
* [vimgrep: Searching through multiple file extensions](http://amix.dk/blog/post/19672#vimgrep-Searching-through-multiple-file-extensions)
* [Filtering through vimgrep results using regular expressions](http://amix.dk/blog/post/19666#Filtering-through-vimgrep-results-using-regular-expressions)
* [PeepOpen - File auto completion for Mac editors](http://amix.dk/blog/post/19601#PeepOpen-File-auto-completion-for-Mac-editors)
* [Vim 7.3: Persistent undo and encryption!](http://amix.dk/blog/post/19548#Vim-7-3-Persistent-undo-and-encryption)
* [Vim tips: Visual Search](http://amix.dk/blog/post/19334#Vim-tips-Visual-Search)
* [Folding in Vim](http://amix.dk/blog/post/19132#Folding-in-Vim)
* [
Zen room for Vim: Focusing only on the essential](http://amix.dk/blog/post/19744#zenroom-for-Vim-Focsuing-only-on-the-essential)
## How to uninstall
Do following:
* Remove `~/.vim_runtime`

View File

@ -122,6 +122,19 @@ nice code clean-up (which ack.vim is now hopefully getting), and ack.vim picked
up a few features that haven't made their way to ag.vim, like `:AckWindow`,
optional background search execution with [vim-dispatch], and auto-previewing.
#### I don't want to jump to the first result automatically. ####
Use `:Ack!`, with bang. If you want this behavior most of the time, you might
like an abbreviation or mapping in your personal config, something like these:
```vim
cnoreabbrev Ack Ack!
nnoremap <Leader>a :Ack!<Space>
```
Most of the `:[L]Ack*` commands support this. Note that this behavior follows
the convention of Vim's built-in `:grep` and `:make` commands.
[The Silver Searcher]: https://github.com/ggreer/the_silver_searcher
[sadface]: https://github.com/mileszs/ack.vim/commit/d97090fb502d40229e6976dfec0e06636ba227d5#commitcomment-5771145

View File

@ -1,3 +1,7 @@
if exists('g:autoloaded_ack') || &cp
finish
endif
if exists('g:ack_use_dispatch')
if g:ack_use_dispatch && !exists(':Dispatch')
call s:Warn('Dispatch not loaded! Falling back to g:ack_use_dispatch = 0.')
@ -238,4 +242,5 @@ function! s:Warn(msg) "{{{
echohl WarningMsg | echomsg 'Ack: ' . a:msg | echohl None
endf "}}}
let g:autoloaded_ack = 1
" vim:set et sw=2 ts=2 tw=78 fdm=marker

View File

@ -4,6 +4,10 @@
Author: Antoine Imbert <antoine.imbert+ackvim@gmail.com> *ack-author*
License: Same terms as Vim itself (see |license|)
This plugin is only available if 'compatible' is not set.
{Vi does not have any of this}
==============================================================================
INTRODUCTION *ack*
@ -16,7 +20,7 @@ shows the results in a split window.
Search recursively in {directory} (which defaults to the current
directory) for the {pattern}. Behaves just like the |:grep| command, but
will open the |Quickfix| window for you. If [!] is not given the first
occurence is jumped to.
occurrence is jumped to.
:AckAdd [options] {pattern} [{directory}] *:AckAdd*
@ -90,7 +94,6 @@ Example:
>
let g:ackprg = "ag --vimgrep"
<
*g:ack_default_options*
g:ack_default_options
Default: " -s -H --nocolor --nogroup --column"
@ -107,18 +110,17 @@ Example:
let g:ack_default_options =
\ " -s -H --nocolor --nogroup --column --smart-case --follow"
<
*g:ack_apply_qmappings*
g:ack_apply_qmappings
Default: 1
This option enable mappings on quickview window.
This option enables mappings on the |quickfix| window.
*g:ack_apply_lmappings*
g:ack_apply_lmappings
Default: 1
This option enable mappings on Location list window.
This option enables mappings on |location-list| windows.
*g:ack_mappings*
g:ack_mappings
@ -139,7 +141,6 @@ Example, if you want to open the result in the middle of the screen:
>
let g:ack_mappings = { "o": "<CR>zz" }
<
*g:ack_qhandler*
g:ack_qhandler
Default: "botright copen"
@ -150,7 +151,6 @@ If you want to open a quickview window with 30 lines you can do:
>
let g:ack_qhandler = "botright copen 30"
<
*g:ack_lhandler*
g:ack_lhandler
Default: "botright lopen"
@ -161,9 +161,7 @@ If you want to open a Location list window with 30 lines you can do:
>
let g:ack_lhandler = "botright lopen 30"
<
*g:ackhighlight*
g:ackhighlight
Default: 0
@ -173,7 +171,6 @@ Example:
>
let g:ackhighlight = 1
<
*g:ack_autoclose*
g:ack_autoclose
Default: 0
@ -185,9 +182,7 @@ Example:
>
let g:ack_autoclose = 1
<
*g:ack_autofold_results*
g:ack_autofold_results
Default: 0
@ -200,9 +195,7 @@ Example:
>
let g:ack_autofold_results = 1
<
*g:ackpreview*
g:ackpreview
Default: 0
@ -212,9 +205,7 @@ Example:
>
let g:ackpreview = 1
<
*g:ack_use_dispatch*
g:ack_use_dispatch
Default: 0
@ -229,9 +220,7 @@ Example:
>
let g:ack_use_dispatch = 1
<
*g:ack_use_cword_for_empty_search*
g:ack_use_cword_for_empty_search
Default: 1
@ -239,34 +228,88 @@ Use this option to enable blank searches to run against the word under the
cursor. When this option is not set, blank searches will only output an error
message.
Example:
>
let g:ack_use_cword_for_empty_search = 0
<
==============================================================================
MAPPINGS *ack-mappings*
The following keyboard shortcuts are available in the quickfix window:
The following keyboard shortcuts are available in the |quickfix| and
|location-list| windows:
o open file (same as enter).
? display a quick summary of these mappings.
O open file and close quickfix window.
o open file (same as Enter).
O open file and close the quickfix window.
go preview file (open but maintain focus on ack.vim results).
t open in a new tab.
T open in new tab silently.
T open in new tab without moving to it.
h open in horizontal split.
H open in horizontal split silently.
H open in horizontal split, keeping focus on the results.
v open in vertical split.
gv open in vertical split silently.
gv open in vertical split, keeping focus on the results.
q close the quickfix window.
To adjust these, see |g:ack_mappings|.
==============================================================================
Ignoring files *ack-ignore*
If you're using this plugin with ag, The Silver Searcher, bear in mind that:
- It ignores file patterns from your .gitignore and .hgignore.
- If there are other files in your source repository you don't wish to
search, you can add their patterns to an .agignore file.
==============================================================================
ISSUES AND FAQ *ack-issues-and-faq*
I don't want to jump to the first result automatically.~
Use `:Ack!`, with bang. If you want this behavior most of the time, you
might like an abbreviation or mapping in your personal config, something
like these:
>
cnoreabbrev Ack Ack!
nnoremap <Leader>a :Ack!<Space>
<
Most of the `:[L]Ack*` commands support this. Note that this behavior
follows the convention of Vim's built-in |:grep| and |:make| commands.
I use NERDTree and opening ack.vim results in a vertical split displacing it.~
You are probably using NERDTree with its default alignment at the left
side of the window. Set these custom mappings in your vimrc to work around
this:
>
let g:ack_mappings = {
\ 'v': '<C-W><CR><C-W>L<C-W>p<C-W>J<C-W>p',
\ 'gv': '<C-W><CR><C-W>L<C-W>p<C-W>J' }
<
This solution will be improved in the future.
Results show a mix of relative and absolute paths, making them hard to read.~
This is a quirk of Vim that can happen with plain |:vimgrep| too. You can
try this in your vimrc to work around it:
>
autocmd BufAdd * exe "cd" fnameescape(getcwd())
<
but for some users this may be disruptive to their Vim workflow. For more
details, see:
http://vi.stackexchange.com/a/4816/7174
https://github.com/mileszs/ack.vim/issues/143
vim:set et sw=4 ts=4 tw=78:

View File

@ -1,4 +1,4 @@
if exists('g:loaded_ack')
if exists('g:loaded_ack') || &cp
finish
endif

View File

@ -1,5 +1,7 @@
# ag.vim #
## Deprecated: See [this comment](https://github.com/rking/ag.vim/issues/124#issuecomment-227038003) for more info. Maybe try [ack.vim](https://github.com/mileszs/ack.vim#can-i-use-ag-the-silver-searcher-with-this) as an alternative. ##
This plugin is a front for ag, A.K.A.
[the_silver_searcher](https://github.com/ggreer/the_silver_searcher). Ag can
be used as a replacement for 153% of the uses of `ack`. This plugin will allow

View File

@ -0,0 +1,7 @@
*.markdown
*.zip
note.txt
tags
tags-cn
.hg*
tmp/*

View File

@ -1,8 +1,9 @@
" =============================================================================
" File: autoload/ctrlp.vim
" Description: Fuzzy file, buffer, mru, tag, etc finder.
" Author: Kien Nguyen <github.com/kien>
" Version: 1.79
" Author: CtrlP Dev Team
" Original: Kien Nguyen <github.com/kien>
" Version: 1.80
" =============================================================================
" ** Static variables {{{1
@ -93,9 +94,12 @@ let [s:pref, s:bpref, s:opts, s:new_opts, s:lc_opts] =
\ 'open_single_match': ['s:opensingle', []],
\ 'brief_prompt': ['s:brfprt', 0],
\ 'match_current_file': ['s:matchcrfile', 0],
\ 'match_natural_name': ['s:matchnatural', 0],
\ 'compare_lim': ['s:compare_lim', 3000],
\ 'bufname_mod': ['s:bufname_mod', ':t'],
\ 'bufpath_mod': ['s:bufpath_mod', ':~:.:h'],
\ 'formatline_func': ['s:flfunc', 's:formatline(v:val)'],
\ 'user_command_async': ['s:usrcmdasync', 0],
\ }, {
\ 'open_multiple_files': 's:opmul',
\ 'regexp': 's:regexp',
@ -148,6 +152,7 @@ let [s:lcmap, s:prtmaps] = ['nn <buffer> <silent>', {
\ 'CreateNewFile()': ['<c-y>'],
\ 'MarkToOpen()': ['<c-z>'],
\ 'OpenMulti()': ['<c-o>'],
\ 'YankLine()': [],
\ 'PrtExit()': ['<esc>', '<c-c>', '<c-g>'],
\ }]
@ -201,11 +206,21 @@ let s:hlgrps = {
\ }
" lname, sname of the basic(non-extension) modes
let s:coretypes = [
\ ['files', 'fil'],
\ ['buffers', 'buf'],
\ ['mru files', 'mru'],
\ ]
let s:types = ['fil', 'buf', 'mru']
if !exists('g:ctrlp_types')
let g:ctrlp_types = s:types
el
call filter(g:ctrlp_types, "index(['fil', 'buf', 'mru'], v:val)!=-1")
en
let g:ctrlp_builtins = len(g:ctrlp_types)-1
let s:coretype_names = {
\ 'fil' : 'files',
\ 'buf' : 'buffers',
\ 'mru' : 'mru files',
\ }
let s:coretypes = map(copy(g:ctrlp_types), '[s:coretype_names[v:val], v:val]')
" Get the options {{{2
fu! s:opts(...)
@ -420,12 +435,17 @@ fu! s:GlobPath(dirs, depth)
en
endf
fu! ctrlp#addfile(ch, file)
call add(g:ctrlp_allfiles, a:file)
cal s:BuildPrompt(1)
endf
fu! s:UserCmd(lscmd)
let [path, lscmd] = [s:dyncwd, a:lscmd]
let do_ign =
\ type(s:usrcmd) == 4 && has_key(s:usrcmd, 'ignore') && s:usrcmd['ignore']
if do_ign && ctrlp#igncwd(s:cwd) | retu | en
if exists('+ssl') && &ssl
if exists('+ssl') && &ssl && &shell !~ 'sh'
let [ssl, &ssl, path] = [&ssl, 0, tr(path, '/', '\')]
en
if (has('win32') || has('win64')) && match(&shellcmdflag, "/") != -1
@ -435,11 +455,17 @@ fu! s:UserCmd(lscmd)
if (has('win32') || has('win64')) && match(&shell, 'sh') != -1
let path = tr(path, '\', '/')
en
if has('patch-7.4-597') && !(has('win32') || has('win64'))
if s:usrcmdasync && v:version >= 800 && exists('*job_start')
if exists('s:job')
call job_stop(s:job)
en
let g:ctrlp_allfiles = []
let s:job = job_start([&shell, &shellcmdflag, printf(lscmd, path)], {'callback': 'ctrlp#addfile'})
elsei has('patch-7.4-597') && !(has('win32') || has('win64'))
let g:ctrlp_allfiles = systemlist(printf(lscmd, path))
else
el
let g:ctrlp_allfiles = split(system(printf(lscmd, path)), "\n")
end
en
if exists('+ssl') && exists('ssl')
let &ssl = ssl
cal map(g:ctrlp_allfiles, 'tr(v:val, "\\", "/")')
@ -622,7 +648,7 @@ fu! s:Render(lines, pat)
en
if s:mw_order == 'btt' | cal reverse(lines) | en
let s:lines = copy(lines)
cal map(lines, 's:formatline(v:val)')
cal map(lines, s:flfunc)
cal setline(1, s:offset(lines, height))
cal s:unmarksigns()
cal s:remarksigns()
@ -647,15 +673,15 @@ fu! s:Update(str)
let pat = s:matcher == {} ? s:SplitPattern(str) : str
let lines = s:nolim == 1 && empty(str) ? copy(g:ctrlp_lines)
\ : s:MatchedItems(g:ctrlp_lines, pat, s:mw_res)
if empty(str) | call clearmatches() | en
if empty(str) | cal clearmatches() | en
cal s:Render(lines, pat)
return lines
endf
fu! s:ForceUpdate()
let wv = winsaveview()
let pos = exists('*getcurpos') ? getcurpos() : getpos('.')
sil! cal s:Update(escape(s:getinput(), '\'))
cal winrestview(wv)
cal setpos('.', pos)
endf
fu! s:BuildPrompt(upd)
@ -717,7 +743,7 @@ fu! s:PrtBS()
if empty(s:prompt[0]) && s:brfprt != 0
cal s:PrtExit()
retu
endif
en
unl! s:hstgot
let [s:prompt[0], s:matches] = [substitute(s:prompt[0], '.$', '', ''), 1]
cal s:BuildPrompt(1)
@ -839,9 +865,9 @@ fu! s:PrtSelectMove(dir)
let wht = winheight(0)
let dirs = {'t': 'gg','b': 'G','j': 'j','k': 'k','u': wht.'k','d': wht.'j'}
exe 'keepj norm!' dirs[a:dir]
let wv = winsaveview()
let pos = exists('*getcurpos') ? getcurpos() : getpos('.')
cal s:BuildPrompt(0)
cal winrestview(wv)
cal setpos('.', pos)
endf
fu! s:PrtSelectJump(char)
@ -864,9 +890,9 @@ fu! s:PrtSelectJump(char)
let [jmpln, s:jmpchr] = [npos == -1 ? pos : npos, [chr, npos]]
en
exe 'keepj norm!' ( jmpln + 1 ).'G'
let wv = winsaveview()
let pos = exists('*getcurpos') ? getcurpos() : getpos('.')
cal s:BuildPrompt(0)
cal winrestview(wv)
cal setpos('.', pos)
en
endf
" Misc {{{2
@ -875,12 +901,13 @@ fu! s:PrtFocusMap(char)
endf
fu! s:PrtClearCache()
if s:itemtype == 0
let ct = s:curtype()
if ct == 'fil'
cal ctrlp#clr()
elsei s:itemtype > 2
elsei s:itemtype >= len(s:coretypes)
cal ctrlp#clr(s:statypes[s:itemtype][1])
en
if s:itemtype == 2
if ct == 'mru'
let g:ctrlp_lines = ctrlp#mrufiles#refresh()
el
cal ctrlp#setlines()
@ -891,9 +918,10 @@ fu! s:PrtClearCache()
endf
fu! s:PrtDeleteEnt()
if s:itemtype == 2
let ct = s:curtype()
if ct == 'mru'
cal s:PrtDeleteMRU()
elsei s:itemtype == 1
elsei ct == 'buf'
cal s:delbuf()
elsei type(s:getextvar('wipe')) == 1
cal s:delent(s:getextvar('wipe'))
@ -901,15 +929,19 @@ fu! s:PrtDeleteEnt()
endf
fu! s:PrtDeleteMRU()
if s:itemtype == 2
if s:curtype() == 'mru'
cal s:delent('ctrlp#mrufiles#remove')
en
endf
fu! s:PrtExit()
let bw = bufwinnr('%')
exe bufwinnr(s:bufnr).'winc w'
if bufnr('%') == s:bufnr && bufname('%') == 'ControlP'
noa cal s:Close()
noa winc p
els
exe bw.'winc w'
en
endf
@ -1008,7 +1040,7 @@ fu! s:ToggleByFname()
endf
fu! s:ToggleType(dir)
let max = len(g:ctrlp_ext_vars) + 2
let max = len(g:ctrlp_ext_vars) + len(s:coretypes) - 1
let next = s:walker(max, s:itemtype, a:dir)
cal ctrlp#setlines(next)
cal ctrlp#syntax()
@ -1148,7 +1180,7 @@ fu! s:AcceptSelection(action)
if subm | if s:SpecInputs(str) | retu | en | en
" Get the selected line
let line = ctrlp#getcline()
if !subm && !s:itemtype && line == '' && line('.') > s:offset
if !subm && s:curtype() != 'fil' && line == '' && line('.') > s:offset
\ && str !~ '\v^(\.\.([\/]\.\.)*[\/]?[.\/]*|/|\\|\?|\@.+)$'
cal s:CreateNewFile(md) | retu
en
@ -1158,7 +1190,7 @@ fu! s:AcceptSelection(action)
let actfunc = s:openfunc[s:ctype]
let type = has_key(s:openfunc, 'arg_type') ? s:openfunc['arg_type'] : 'list'
el
if s:itemtype < 3
if s:itemtype < len(s:coretypes)
let [actfunc, type] = ['ctrlp#acceptfile', 'dict']
el
let [actfunc, exttype] = [s:getextvar('accept'), s:getextvar('act_farg')]
@ -1203,15 +1235,16 @@ fu! s:CreateNewFile(...)
endf
" * OpenMulti() {{{1
fu! s:MarkToOpen()
let ct = s:curtype()
if s:bufnr <= 0 || s:opmul == '0'
\ || ( s:itemtype > 2 && s:getextvar('opmul') != 1 )
\ || ( s:itemtype >= len(s:coretypes) && s:getextvar('opmul') != 1 )
retu
en
let line = ctrlp#getcline()
" Do not allow to mark modified or current buffer
let bufnr = s:bufnrfilpath(line)[0]
if (s:itemtype == 1 && s:delbufcond(bufnr))
if (ct == 'buf' && s:delbufcond(bufnr))
retu
en
@ -1244,7 +1277,7 @@ endf
fu! s:OpenMulti(...)
let has_marked = exists('s:marked')
if ( !has_marked && a:0 ) || s:opmul == '0' || !s:ispath
\ || ( s:itemtype > 2 && s:getextvar('opmul') != 1 )
\ || ( s:itemtype >= len(s:coretypes) && s:getextvar('opmul') != 1 )
retu -1
en
" Get the options
@ -1323,6 +1356,18 @@ fu! s:OpenMulti(...)
unl! s:tabct
endf
fu! s:YankLine(...)
let @" = s:getinput()
let has_marked = exists('s:marked')
if !has_marked
let line = ctrlp#getcline()
if line == '' | retu | en
let marked = { 1 : fnamemodify(line, ':p') }
en
let @" = join(values(has_marked ? s:marked : marked), "\n")
cal s:PrtExit()
endf
fu! s:OpenNoMarks(md, line)
if a:md == 'a'
let [s:marked, key] = [{}, 1]
@ -1427,7 +1472,8 @@ fu! s:shortest(lens)
endf
fu! s:mixedsort(...)
if s:itemtype == 1
let ct = s:curtype()
if ct == 'buf'
let pat = '[\/]\?\[\d\+\*No Name\]$'
if a:1 =~# pat && a:2 =~# pat | retu 0
elsei a:1 =~# pat | retu 1
@ -1438,10 +1484,10 @@ fu! s:mixedsort(...)
let ms = []
if s:res_count < 21
let ms += [s:compfnlen(a:1, a:2)]
if s:itemtype !~ '^[12]$' | let ms += [s:comptime(a:1, a:2)] | en
if ct !~ '^\(buf\|mru\)$' | let ms += [s:comptime(a:1, a:2)] | en
if !s:itemtype | let ms += [s:comparent(a:1, a:2)] | en
en
if s:itemtype =~ '^[12]$'
if ct =~ '^\(buf\|mru\)$'
let ms += [s:compmref(a:1, a:2)]
let cln = cml ? cln : 0
en
@ -1525,7 +1571,8 @@ endf
" Line formatting {{{3
fu! s:formatline(str)
let str = a:str
if s:itemtype == 1
let ct = s:curtype()
if ct == 'buf'
let bufnr = s:bufnrfilpath(str)[0]
let parts = s:bufparts(bufnr)
let str = printf('%'.s:bufnr_width.'s', bufnr)
@ -1537,7 +1584,7 @@ fu! s:formatline(str)
let str .= printf(' %s', '<bp>'.parts[3].'</bp>')
en
el
let str .= printf(' %-5s %-30s %s',
let str .= printf(' %-5s %-30s',
\ parts[0],
\ parts[2])
if (!empty(s:bufpath_mod))
@ -1545,7 +1592,7 @@ fu! s:formatline(str)
en
en
en
let cond = s:itemtype != 1 &&s:ispath && ( s:winw - 4 ) < s:strwidth(str)
let cond = ct != 'buf' &&s:ispath && ( s:winw - 4 ) < s:strwidth(str)
retu s:lineprefix.( cond ? s:pathshorten(str) : str )
endf
@ -1600,7 +1647,7 @@ fu! s:lash(...)
endf
fu! s:ispathitem()
retu s:itemtype < 3 || ( s:itemtype > 2 && s:getextvar('type') == 'path' )
retu s:itemtype < len(s:coretypes) || s:getextvar('type') == 'path'
endf
fu! ctrlp#igncwd(cwd)
@ -1634,11 +1681,11 @@ fu! ctrlp#dirnfile(entries)
endf
fu! s:usrign(item, type)
if s:igntype == 1 | retu a:item =~ s:usrign | end
if s:igntype == 1 | retu a:item =~ s:usrign | en
if s:igntype == 2
if call(s:usrign, [a:item, a:type])
retu 1
end
en
elsei s:igntype == 4
if has_key(s:usrign, a:type) && s:usrign[a:type] != ''
\ && a:item =~ s:usrign[a:type]
@ -1646,8 +1693,8 @@ fu! s:usrign(item, type)
elsei has_key(s:usrign, 'func') && s:usrign['func'] != ''
\ && call(s:usrign['func'], [a:item, a:type])
retu 1
end
end
en
en
retu 0
endf
@ -1754,10 +1801,10 @@ fu! ctrlp#syntax()
en
sy match CtrlPNoEntries '^ == NO ENTRIES ==$'
if hlexists('CtrlPLinePre')
sy match CtrlPLinePre '^>'
exe "sy match CtrlPLinePre '^".escape(get(g:, 'ctrlp_line_prefix', '>'),'^$.*~\')."'"
en
if s:itemtype == 1 && s:has_conceal
if s:curtype() == 'buf' && s:has_conceal
sy region CtrlPBufferNr matchgroup=CtrlPLinePre start='^>\s\+' end='\s'
sy region CtrlPBufferInd concealends matchgroup=Ignore start='<bi>' end='</bi>'
sy region CtrlPBufferRegion concealends matchgroup=Ignore start='<bn>' end='</bn>'
@ -1795,7 +1842,7 @@ fu! s:highlight(pat, grp)
if s:byfname()
" Make sure there are no slashes in our match
let beginning = beginning.'\([^\/]*$\)\@='
end
en
for i in range(len(chars))
" Surround our current target letter with \zs and \ze so it only
@ -1807,14 +1854,14 @@ fu! s:highlight(pat, grp)
if i == 0
let charcopy[i] = '\zs'.charcopy[i].'\ze'
let middle = join(charcopy, '.\{-}')
else
el
let before = join(charcopy[0:i-1], '.\{-}')
let after = join(charcopy[i+1:-1], '.\{-}')
let c = charcopy[i]
" for abc, match either ab.\{-}c or a.*b.\{-}c in that order
let cpat = '\(\zs'.c.'\|'.'.*\zs'.c.'\)\ze.*'
let middle = before.cpat.after
endif
en
" Now we matchadd for each letter, the basic form being:
" ^.*\zsx\ze.*$, but with our pattern we built above for the letter,
@ -1822,7 +1869,7 @@ fu! s:highlight(pat, grp)
" occurrence of our letters. We also ensure that our matcher is case
" insensitive or sensitive depending.
cal matchadd(a:grp, beginning.middle.ending)
endfor
endfo
en
cal matchadd('CtrlPLinePre', '^>')
@ -1941,7 +1988,7 @@ fu! s:isabs(path)
endf
fu! s:bufnrfilpath(line)
if s:isabs(a:line) || a:line =~ '^\~[/\\]'
if s:isabs(a:line) || a:line =~ '^\~[/\\]' || a:line =~ '^\w\+:\/\/'
let filpath = a:line
el
let filpath = s:dyncwd.s:lash().a:line
@ -1956,9 +2003,10 @@ fu! s:bufnrfilpath(line)
endf
fu! ctrlp#normcmd(cmd, ...)
let buftypes = [ 'quickfix', 'help' ]
if a:0 < 2 && s:nosplit() | retu a:cmd | en
let norwins = filter(range(1, winnr('$')),
\ 'empty(getbufvar(winbufnr(v:val), "&bt")) || s:isneovimterminal(winbufnr(v:val))')
\ 'index(buftypes, getbufvar(winbufnr(v:val), "&bt")) == -1 || s:isneovimterminal(winbufnr(v:val))')
for each in norwins
let bufnr = winbufnr(each)
if empty(bufname(bufnr)) && empty(getbufvar(bufnr, '&ft'))
@ -2010,7 +2058,7 @@ fu! s:checkbuf()
endf
fu! s:iscmdwin()
let ermsg = v:errmsg
let [ermsg, v:errmsg] = [v:errmsg, '']
sil! noa winc p
sil! noa winc p
let [v:errmsg, ermsg] = [ermsg, v:errmsg]
@ -2124,12 +2172,13 @@ fu! s:modevar()
endf
fu! s:nosort()
retu s:matcher != {} || s:nolim == 1 || ( s:itemtype == 2 && s:mrudef )
\ || ( s:itemtype =~ '\v^(1|2)$' && s:prompt == ['', '', ''] ) || !s:dosort
let ct = s:curtype()
retu s:matcher != {} || s:nolim == 1 || ( ct == 'mru' && s:mrudef )
\ || ( ct =~ '^\(buf\|mru\)$' && s:prompt == ['', '', ''] ) || !s:dosort
endf
fu! s:byfname()
retu s:itemtype != 1 && s:ispath && s:byfname
retu s:curtype() != 'buf' && s:ispath && s:byfname
endf
fu! s:narrowable()
@ -2345,19 +2394,30 @@ endf
fu! s:buildpat(lst)
let pat = a:lst[0]
for item in range(1, len(a:lst) - 1)
let pat .= '[^'.a:lst[item - 1].']\{-}'.a:lst[item]
endfo
if s:matchnatural == 1
for item in range(1, len(a:lst) - 1)
let c = a:lst[item - 1]
let pat .= (c == '/' ? '[^/]\{-}' : '[^'.c.'/]\{-}').a:lst[item]
endfo
else
for item in range(1, len(a:lst) - 1)
let pat .= '[^'.a:lst[item - 1].']\{-}'.a:lst[item]
endfo
en
retu pat
endf
fu! s:curtype()
return s:CurTypeName()[1]
endf
fu! s:mfunc()
let mfunc = 'match'
if s:byfname()
let mfunc = 's:matchfname'
elsei s:itemtype == 1
elsei s:curtype() == 'buf'
let mfunc = 's:matchbuf'
elsei s:itemtype > 2
elsei s:itemtype >= len(s:coretypes)
let matchtypes = { 'tabs': 's:matchtabs', 'tabe': 's:matchtabe' }
if has_key(matchtypes, s:matchtype)
let mfunc = matchtypes[s:matchtype]
@ -2416,7 +2476,7 @@ fu! s:insertcache(str)
endf
" Extensions {{{2
fu! s:mtype()
retu s:itemtype > 2 ? s:getextvar('type') : 'path'
retu s:itemtype >= len(s:coretypes) ? s:getextvar('type') : 'path'
endf
fu! s:execextvar(key)
@ -2427,8 +2487,8 @@ fu! s:execextvar(key)
endf
fu! s:getextvar(key)
if s:itemtype > 2
let vars = g:ctrlp_ext_vars[s:itemtype - 3]
if s:itemtype >= len(s:coretypes) && len(g:ctrlp_ext_vars) > 0
let vars = g:ctrlp_ext_vars[s:itemtype - len(s:coretypes)]
retu has_key(vars, a:key) ? vars[a:key] : -1
en
retu get(g:, 'ctrlp_' . s:matchtype . '_' . a:key, -1)
@ -2482,7 +2542,8 @@ endf
fu! ctrlp#setlines(...)
if a:0 | let s:itemtype = a:1 | en
cal s:modevar()
let types = ['ctrlp#files()', 'ctrlp#buffers()', 'ctrlp#mrufiles#list()']
let inits = {'fil': 'ctrlp#files()', 'buf': 'ctrlp#buffers()', 'mru': 'ctrlp#mrufiles#list()'}
let types = map(copy(g:ctrlp_types), 'inits[v:val]')
if !empty(g:ctrlp_ext_vars)
cal map(copy(g:ctrlp_ext_vars), 'add(types, v:val["init"])')
en
@ -2491,11 +2552,11 @@ endf
" Returns [lname, sname]
fu! s:CurTypeName()
if s:itemtype < 3
return s:coretypes[s:itemtype]
else
if s:itemtype < len(s:coretypes)
return filter(copy(s:coretypes), 'v:val[1]==g:ctrlp_types[s:itemtype]')[0]
el
return [s:getextvar("lname"), s:getextvar('sname')]
endif
en
endfu
fu! s:ExitIfSingleCandidate()
@ -2503,7 +2564,7 @@ fu! s:ExitIfSingleCandidate()
call s:AcceptSelection('e')
call ctrlp#exit()
return 1
endif
en
return 0
endfu
@ -2516,14 +2577,27 @@ fu! ctrlp#init(type, ...)
cal s:SetWD(a:0 ? a:1 : {})
cal s:MapNorms()
cal s:MapSpecs()
cal ctrlp#setlines(s:settype(a:type))
if empty(g:ctrlp_types) && empty(g:ctrlp_ext_vars)
call ctrlp#exit()
retu
en
if type(a:type) == 0
let type = a:type
el
let type = index(g:ctrlp_types, a:type)
if type == -1
call ctrlp#exit()
retu
en
en
cal ctrlp#setlines(s:settype(type))
cal ctrlp#syntax()
cal s:SetDefTxt()
let curName = s:CurTypeName()
let shouldExitSingle = index(s:opensingle, curName[0])>=0 || index(s:opensingle, curName[1])>=0
if shouldExitSingle && s:ExitIfSingleCandidate()
return 0
endif
en
cal s:BuildPrompt(1)
if s:keyloop | cal s:KeyLoop() | en
return 1

View File

@ -59,6 +59,7 @@ let s:types = {
\ 'erlang' : '%serlang%serlang%sdrmf',
\ 'expect' : '%stcl%stcl%scfp',
\ 'fortran': '%sfortran%sfortran%spbceiklmntvfs',
\ 'go' : '%sgo%sgo%sfctv',
\ 'html' : '%shtml%shtml%saf',
\ 'java' : '%sjava%sjava%spcifm',
\ 'javascript': '%sjavascript%sjavascript%sf',

View File

@ -885,7 +885,8 @@ MRU mode options:~
在匹配窗口和提示符面板之间切换焦点。
<esc>,
<c-c>
<c-c>,
<c-g>
退出CtrlP。
移动:~

View File

@ -68,6 +68,7 @@ Overview:~
|ctrlp_open_single_match|.....Automatically accept when only one candidate.
|ctrlp_brief_prompt|..........Exit CtrlP on empty prompt by <bs>.
|ctrlp_match_current_file|....Include current file in match entries.
|ctrlp_types|.................Names of builtin types.
MRU mode:
|ctrlp_mruf_max|..............Max MRU entries to remember.
@ -254,8 +255,9 @@ plugins look for .git/, .hg/,... some other plugins look for external *.exe
tools on Windows). So be a little mindful of what you put in your |wildignore|.
*'g:ctrlp_custom_ignore'*
In addition to |'wildignore'|, use this for files and directories you want only
CtrlP to not show. Use regexp to specify the patterns: >
In addition to |'wildignore'| and |g:ctrlp_show_hidden|, use this for files
and directories you want only CtrlP to not show. Use regexp to specify the
patterns: >
let g:ctrlp_custom_ignore = ''
<
Examples: >
@ -454,13 +456,19 @@ This option works well together with |g:ctrlp_open_single_match|
*'g:ctrlp_match_current_file'*
Includes the current file in the match entries:
Includes the current file in the match entries: >
let g:ctrlp_match_current_file = 1
By default, the current file is excluded from the list.
Note: does not apply when |g:ctrlp_match_func| is used.
*'g:ctrlp_types'*
Set this to list of names to customize core types: >
let g:ctrlp_types = ['mru', 'fil']
By default, the types are: >
let g:ctrlp_types = ['fil', 'buf', 'mru'].
*'g:ctrlp_abbrev'*
Define input abbreviations that can be expanded (either internally or visibly)
@ -853,7 +861,8 @@ COMMANDS *ctrlp-commands*
Open CtrlP in find file mode.
If no argument is given, the value of |g:ctrlp_working_path_mode| will be
used to determine the starting directory.
used to determine the starting directory. See |:CtrlPCurFile| and
|:CtrlPCurWD| to temporarily override the setting.
You can use <tab> to auto-complete the [starting-directory] when typing it.
@ -861,6 +870,16 @@ COMMANDS *ctrlp-commands*
:CtrlPBuffer
Open CtrlP in find buffer mode.
*:CtrlPCurFile*
:CtrlPCurFile
This acts like |:CtrlP| with |g:ctrlp_working_path_mode| = '' and ignores
the variable's current value.
*:CtrlPCurWD*
:CtrlPCurWD
This acts like |:CtrlP| with |g:ctrlp_working_path_mode| = '' and ignores
the variable's current value.
*:CtrlPMRU*
:CtrlPMRU
Open CtrlP in find Most-Recently-Used file mode.
@ -924,7 +943,8 @@ Once inside the prompt:~
Toggle the focus between the match window and the prompt.
<esc>,
<c-c>
<c-c>,
<c-g>
Exit CtrlP.
Moving:~
@ -1322,7 +1342,8 @@ Available extensions:~
Buffer Tag mode options:~
*'g:ctrlp_buftag_ctags_bin'*
If ctags isn't in your $PATH, use this to set its location: >
If ctags isn't in your $PATH, or a ctags binary exists in either
/opt/local/bin or /usr/local/bin, us this to set its location: >
let g:ctrlp_buftag_ctags_bin = ''
<
@ -1476,6 +1497,28 @@ Special thanks:~
===============================================================================
CHANGELOG *ctrlp-changelog*
Before 2016/11/28~
+ New command: |YankLine()| to yank current line.
+ New option: |g:ctrlp_types| to select builtin modes.
+ New feature: asynchronized spawn of |g:ctrlp_user_command|. This enable
with set |g:user_command_async| to 1.
+ Support buffertag for delphi, rust and golang.
+ New option: |g:ctrlp_brief_prompt|,
|g:match_current_file|,
|g:ctrlp_compare_lim|.
+ New feature: Auto-ignore extension.
+ Support buffertag for ant, tex, dosbatch, matlab and vhdl.
+ New option |g:ctrlp_line_prefix| for integrating third party plugins.
+ New option |g:open_single_match| to open single file in matches.
+ Add <plug>(ctrlp) for launch CtrlP.
+ Accept bang for CtrlPBookmarkDirAdd to avoid confirm.
+ Handle variable like "g:ctrlp_TYPE_MODE".
ex: let g:ctrlp_path_sort
+ New option: |g:ctrlp_custom_ancestors|
Before 2014/08/08~
+ New buffer explorer mode with highlighting (|+conceal| recommended)
+ New options: |g:ctrlp_bufname_mod|,
|g:ctrlp_bufpath_mod|

View File

@ -18,9 +18,9 @@ if !exists('g:ctrlp_map') | let g:ctrlp_map = '<c-p>' | en
if !exists('g:ctrlp_cmd') | let g:ctrlp_cmd = 'CtrlP' | en
com! -n=? -com=dir CtrlP cal ctrlp#init(0, { 'dir': <q-args> })
com! -n=? -com=dir CtrlPMRUFiles cal ctrlp#init(2, { 'dir': <q-args> })
com! -n=? -com=dir CtrlPMRUFiles cal ctrlp#init('mru', { 'dir': <q-args> })
com! -bar CtrlPBuffer cal ctrlp#init(1)
com! -bar CtrlPBuffer cal ctrlp#init('buf')
com! -n=? CtrlPLastMode cal ctrlp#init(-1, { 'args': <q-args> })
com! -bar CtrlPClearCache cal ctrlp#clr()
@ -29,9 +29,9 @@ com! -bar CtrlPClearAllCaches cal ctrlp#clra()
com! -bar ClearCtrlPCache cal ctrlp#clr()
com! -bar ClearAllCtrlPCaches cal ctrlp#clra()
com! -bar CtrlPCurWD cal ctrlp#init(0, { 'mode': '' })
com! -bar CtrlPCurFile cal ctrlp#init(0, { 'mode': 'c' })
com! -bar CtrlPRoot cal ctrlp#init(0, { 'mode': 'r' })
com! -bar CtrlPCurWD cal ctrlp#init('fil', { 'mode': '' })
com! -bar CtrlPCurFile cal ctrlp#init('fil', { 'mode': 'c' })
com! -bar CtrlPRoot cal ctrlp#init('fil', { 'mode': 'r' })
exe 'nn <silent> <plug>(ctrlp) :<c-u>'.g:ctrlp_cmd.'<cr>'
@ -55,10 +55,10 @@ com! -bar CtrlPRTS cal ctrlp#init(ctrlp#rtscript#id())
com! -bar CtrlPUndo cal ctrlp#init(ctrlp#undo#id())
com! -n=? -com=buffer CtrlPLine
\ cal ctrlp#init(ctrlp#line#cmd(1, <q-args>))
\ cal ctrlp#init(ctrlp#line#cmd('buf', <q-args>))
com! -n=? -com=buffer CtrlPChange
\ cal ctrlp#init(ctrlp#changes#cmd(0, <q-args>))
\ cal ctrlp#init(ctrlp#changes#cmd('fil', <q-args>))
com! -bar CtrlPChangeAll cal ctrlp#init(ctrlp#changes#cmd(1))
com! -bar CtrlPMixed cal ctrlp#init(ctrlp#mixed#id())

View File

@ -64,6 +64,10 @@ Use `:diffthis` when opening multiple files to run `:diffthis` on the first 4 fi
If more than one mode is specified, they will be tried in order until a directory is located.
* If a file is already open, open it again in a new pane instead of switching to the existing pane
`let g:ctrlp_switch_buffer = 'et'`
* Exclude files and directories using Vim's `wildignore` and CtrlP's own `g:ctrlp_custom_ignore`. If a custom listing command is being used, exclusions are ignored:
```vim

View File

@ -272,7 +272,7 @@ set noshowmode
```
Now, let us get back to the tutorial (with the patched font for vim-powerline).
Now, let's get back to the tutorial (with the patched font for vim-powerline).
You look into a help file to find the marks annoying.
![lightline.vim - tutorial](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/tutorial/6.png)
@ -293,8 +293,8 @@ let g:lightline = {
![lightline.vim - tutorial](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/tutorial/7.png)
Huh? Weird!
The components do not collapse even if they have no information!
In order to avoid this situation, you set expressions to `g:lightline.component_visible_condition`, which should become 1 only when the corresponding components have information.
The subseparators are visible even if the components are empty.
In order to hide the subseparators, you can set expressions to `g:lightline.component_visible_condition`, which should be 1 only when the corresponding component is not empty.
```vim
let g:lightline = {
\ 'colorscheme': 'wombat',
@ -313,8 +313,8 @@ let g:lightline = {
![lightline.vim - tutorial](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/tutorial/8.png)
Okay. It works nice.
The configuration `component_visible_condition` is used to control the visibility of the subseparators.
You cannot use this variable to control the visibility of the components themselves.
How does lightline decide the components to show in the statusline?
It's very simple.
@ -340,16 +340,9 @@ let g:lightline = {
\ }
```
If the plugin arranges all the components (in a situation you `set paste` and the file `.vimrc` is read-only, try to modify):
![lightline.vim - tutorial](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/tutorial/9.png)
The mode component, the paste component, read-only component, filename component and modified component in a row.
Normally, the paste component does not show up.
![lightline.vim - tutorial](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/tutorial/10.png)
If the file is not read-only (more common cases), the read-only component does not show up.
![lightline.vim - tutorial](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/tutorial/11.png)
Again look into `g:lightline.active.left`.
```vim
let g:lightline = {
@ -357,8 +350,6 @@ let g:lightline = {
\ 'left': [ [ 'mode', 'paste' ],
\ [ 'readonly', 'filename', 'modified' ] ] ...
```
And the screen shot of all the components.
![lightline.vim - tutorial](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/tutorial/9.png)
The mode and paste component are displayed in the same group.
The read-only, filename and modified component are in the second group.
@ -369,11 +360,11 @@ You can configure the components in the statusline by the following four variabl
+ `g:lightline.inactive.left`
+ `g:lightline.inactive.right`
Of course, your settings in `.vimrc` have priority over the default settings in lightline.
Of course, your configurations in `.vimrc` have priority over the default settings in lightline.
GitHub branch is important for us.
Git branch is important for us.
And it is a default component in [powerline](https://github.com/Lokaltog/powerline) and [vim-powerline](https://github.com/Lokaltog/vim-powerline).
However, lightline does not provide the branch feature by default.
@ -424,15 +415,15 @@ let g:lightline = {
\ [ 'fugitive', 'readonly', 'filename', 'modified' ] ]
\ },
\ 'component_function': {
\ 'fugitive': 'LightLineFugitive',
\ 'readonly': 'LightLineReadonly',
\ 'modified': 'LightLineModified'
\ 'fugitive': 'LightlineFugitive',
\ 'readonly': 'LightlineReadonly',
\ 'modified': 'LightlineModified'
\ },
\ 'separator': { 'left': '⮀', 'right': '⮂' },
\ 'subseparator': { 'left': '⮁', 'right': '⮃' }
\ }
function! LightLineModified()
function! LightlineModified()
if &filetype == "help"
return ""
elseif &modified
@ -444,7 +435,7 @@ function! LightLineModified()
endif
endfunction
function! LightLineReadonly()
function! LightlineReadonly()
if &filetype == "help"
return ""
elseif &readonly
@ -454,7 +445,7 @@ function! LightLineReadonly()
endif
endfunction
function! LightLineFugitive()
function! LightlineFugitive()
return exists('*fugitive#head') ? fugitive#head() : ''
endfunction
```
@ -473,16 +464,16 @@ let g:lightline = {
\ [ 'fugitive', 'filename' ] ]
\ },
\ 'component_function': {
\ 'fugitive': 'LightLineFugitive',
\ 'readonly': 'LightLineReadonly',
\ 'modified': 'LightLineModified',
\ 'filename': 'LightLineFilename'
\ 'fugitive': 'LightlineFugitive',
\ 'readonly': 'LightlineReadonly',
\ 'modified': 'LightlineModified',
\ 'filename': 'LightlineFilename'
\ },
\ 'separator': { 'left': '⮀', 'right': '⮂' },
\ 'subseparator': { 'left': '⮁', 'right': '⮃' }
\ }
function! LightLineModified()
function! LightlineModified()
if &filetype == "help"
return ""
elseif &modified
@ -494,7 +485,7 @@ function! LightLineModified()
endif
endfunction
function! LightLineReadonly()
function! LightlineReadonly()
if &filetype == "help"
return ""
elseif &readonly
@ -504,24 +495,24 @@ function! LightLineReadonly()
endif
endfunction
function! LightLineFugitive()
function! LightlineFugitive()
return exists('*fugitive#head') ? fugitive#head() : ''
endfunction
function! LightLineFilename()
return ('' != LightLineReadonly() ? LightLineReadonly() . ' ' : '') .
function! LightlineFilename()
return ('' != LightlineReadonly() ? LightlineReadonly() . ' ' : '') .
\ ('' != expand('%:t') ? expand('%:t') : '[No Name]') .
\ ('' != LightLineModified() ? ' ' . LightLineModified() : '')
\ ('' != LightlineModified() ? ' ' . LightlineModified() : '')
endfunction
```
![lightline.vim - tutorial](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/tutorial/14.png)
Oops! We forgot the cool mark for the branch component! (work with the patched font for vim-powerline)
```vim
function! LightLineFugitive()
function! LightlineFugitive()
if exists("*fugitive#head")
let _ = fugitive#head()
return _ !=# '' ? '⭠ '._ : ''
let branch = fugitive#head()
return branch !=# '' ? '⭠ '.branch : ''
endif
return ''
endfunction
@ -537,7 +528,7 @@ let g:lightline = {
\ 'left': [ [ 'mode', 'paste' ],
\ [ 'my_component' ] ] },
\ 'component_function': {
\ 'my_component': 'LightLineComponent', ...
\ 'my_component': 'LightlineComponent', ...
```
This is the end of the tutorial. For more information, see `:help lightline`. Good luck with your nice statuslines.
@ -552,7 +543,7 @@ subseparator.left | '\|' | '' (\ue0b1) | '⮁' (\u2b81)
subseparator.right | '\|' | '' (\ue0b3) | '⮃' (\u2b83)
branch symbol | -- | '' (\ue0a0) | '⭠' (\u2b60)
readonly symbol | -- | '' (\ue0a2) | '⭤' (\u2b64)
linecolumn symbol | -- | '' (\ue0a1) | '⭡' (\u2b81)
linecolumn symbol | -- | '' (\ue0a1) | '⭡' (\u2b61)
### My settings
I show my settings. I use the patched font for vim-powerline.
@ -564,57 +555,57 @@ let g:lightline = {
\ 'left': [ [ 'mode', 'paste' ], [ 'fugitive', 'filename' ] ]
\ },
\ 'component_function': {
\ 'modified': 'LightLineModified',
\ 'readonly': 'LightLineReadonly',
\ 'fugitive': 'LightLineFugitive',
\ 'filename': 'LightLineFilename',
\ 'fileformat': 'LightLineFileformat',
\ 'filetype': 'LightLineFiletype',
\ 'fileencoding': 'LightLineFileencoding',
\ 'mode': 'LightLineMode',
\ 'modified': 'LightlineModified',
\ 'readonly': 'LightlineReadonly',
\ 'fugitive': 'LightlineFugitive',
\ 'filename': 'LightlineFilename',
\ 'fileformat': 'LightlineFileformat',
\ 'filetype': 'LightlineFiletype',
\ 'fileencoding': 'LightlineFileencoding',
\ 'mode': 'LightlineMode',
\ },
\ 'separator': { 'left': '⮀', 'right': '⮂' },
\ 'subseparator': { 'left': '⮁', 'right': '⮃' }
\ }
function! LightLineModified()
function! LightlineModified()
return &ft =~ 'help\|vimfiler\|gundo' ? '' : &modified ? '+' : &modifiable ? '' : '-'
endfunction
function! LightLineReadonly()
function! LightlineReadonly()
return &ft !~? 'help\|vimfiler\|gundo' && &readonly ? '⭤' : ''
endfunction
function! LightLineFilename()
return ('' != LightLineReadonly() ? LightLineReadonly() . ' ' : '') .
function! LightlineFilename()
return ('' != LightlineReadonly() ? LightlineReadonly() . ' ' : '') .
\ (&ft == 'vimfiler' ? vimfiler#get_status_string() :
\ &ft == 'unite' ? unite#get_status_string() :
\ &ft == 'vimshell' ? vimshell#get_status_string() :
\ '' != expand('%:t') ? expand('%:t') : '[No Name]') .
\ ('' != LightLineModified() ? ' ' . LightLineModified() : '')
\ ('' != LightlineModified() ? ' ' . LightlineModified() : '')
endfunction
function! LightLineFugitive()
function! LightlineFugitive()
if &ft !~? 'vimfiler\|gundo' && exists("*fugitive#head")
let _ = fugitive#head()
return _ !=# '' ? '⭠ '._ : ''
let branch = fugitive#head()
return branch !=# '' ? '⭠ '.branch : ''
endif
return ''
endfunction
function! LightLineFileformat()
function! LightlineFileformat()
return winwidth(0) > 70 ? &fileformat : ''
endfunction
function! LightLineFiletype()
function! LightlineFiletype()
return winwidth(0) > 70 ? (&filetype !=# '' ? &filetype : 'no ft') : ''
endfunction
function! LightLineFileencoding()
function! LightlineFileencoding()
return winwidth(0) > 70 ? (&fenc !=# '' ? &fenc : &enc) : ''
endfunction
function! LightLineMode()
function! LightlineMode()
return winwidth(0) > 60 ? lightline#mode() : ''
endfunction
```
@ -649,12 +640,12 @@ let g:lightline = {
\ 'right': [ [ 'syntastic', 'lineinfo' ], ['percent'], [ 'fileformat', 'fileencoding', 'filetype' ] ]
\ },
\ 'component_function': {
\ 'fugitive': 'LightLineFugitive',
\ 'filename': 'LightLineFilename',
\ 'fileformat': 'LightLineFileformat',
\ 'filetype': 'LightLineFiletype',
\ 'fileencoding': 'LightLineFileencoding',
\ 'mode': 'LightLineMode',
\ 'fugitive': 'LightlineFugitive',
\ 'filename': 'LightlineFilename',
\ 'fileformat': 'LightlineFileformat',
\ 'filetype': 'LightlineFiletype',
\ 'fileencoding': 'LightlineFileencoding',
\ 'mode': 'LightlineMode',
\ 'ctrlpmark': 'CtrlPMark',
\ },
\ 'component_expand': {
@ -666,15 +657,15 @@ let g:lightline = {
\ 'subseparator': { 'left': '|', 'right': '|' }
\ }
function! LightLineModified()
function! LightlineModified()
return &ft =~ 'help' ? '' : &modified ? '+' : &modifiable ? '' : '-'
endfunction
function! LightLineReadonly()
function! LightlineReadonly()
return &ft !~? 'help' && &readonly ? 'RO' : ''
endfunction
function! LightLineFilename()
function! LightlineFilename()
let fname = expand('%:t')
return fname == 'ControlP' && has_key(g:lightline, 'ctrlp_item') ? g:lightline.ctrlp_item :
\ fname == '__Tagbar__' ? g:lightline.fname :
@ -682,36 +673,36 @@ function! LightLineFilename()
\ &ft == 'vimfiler' ? vimfiler#get_status_string() :
\ &ft == 'unite' ? unite#get_status_string() :
\ &ft == 'vimshell' ? vimshell#get_status_string() :
\ ('' != LightLineReadonly() ? LightLineReadonly() . ' ' : '') .
\ ('' != LightlineReadonly() ? LightlineReadonly() . ' ' : '') .
\ ('' != fname ? fname : '[No Name]') .
\ ('' != LightLineModified() ? ' ' . LightLineModified() : '')
\ ('' != LightlineModified() ? ' ' . LightlineModified() : '')
endfunction
function! LightLineFugitive()
function! LightlineFugitive()
try
if expand('%:t') !~? 'Tagbar\|Gundo\|NERD' && &ft !~? 'vimfiler' && exists('*fugitive#head')
let mark = '' " edit here for cool mark
let _ = fugitive#head()
return _ !=# '' ? mark._ : ''
let branch = fugitive#head()
return branch !=# '' ? mark.branch : ''
endif
catch
endtry
return ''
endfunction
function! LightLineFileformat()
function! LightlineFileformat()
return winwidth(0) > 70 ? &fileformat : ''
endfunction
function! LightLineFiletype()
function! LightlineFiletype()
return winwidth(0) > 70 ? (&filetype !=# '' ? &filetype : 'no ft') : ''
endfunction
function! LightLineFileencoding()
function! LightlineFileencoding()
return winwidth(0) > 70 ? (&fenc !=# '' ? &fenc : &enc) : ''
endfunction
function! LightLineMode()
function! LightlineMode()
let fname = expand('%:t')
return fname == '__Tagbar__' ? 'Tagbar' :
\ fname == 'ControlP' ? 'CtrlP' :

View File

@ -2,7 +2,7 @@
" Filename: autoload/lightline.vim
" Author: itchyny
" License: MIT License
" Last Change: 2016/05/14 13:20:45.
" Last Change: 2016/12/03 12:08:08.
" =============================================================================
let s:save_cpo = &cpo
@ -111,6 +111,7 @@ let s:_lightline = {
\ 'modified': '&modified||!&modifiable', 'readonly': '&readonly', 'paste': '&paste', 'spell': '&spell'
\ },
\ 'component_function': {},
\ 'component_function_visible_condition': {},
\ 'component_expand': {
\ 'tabs': 'lightline#tabs'
\ },
@ -155,7 +156,7 @@ function! lightline#init() abort
endfor
call extend(s:lightline.tabline_separator, s:lightline.separator, 'keep')
call extend(s:lightline.tabline_subseparator, s:lightline.subseparator, 'keep')
let s:lightline.tabline_configured = 0
let s:lightline.tabline_configured = has_key(get(get(g:, 'lightline', {}), 'component_expand', {}), 'tabs')
for components in deepcopy(s:lightline.tabline.left + s:lightline.tabline.right)
if len(filter(components, 'v:val !=# "tabs" && v:val !=# "close"')) > 0
let s:lightline.tabline_configured = 1
@ -190,10 +191,6 @@ function! lightline#colorscheme() abort
let s:lightline.colorscheme = 'default'
let s:lightline.palette = g:lightline#colorscheme#{s:lightline.colorscheme}#palette
finally
let s:highlight = {}
call lightline#highlight('normal')
call lightline#link()
let s:_ = 0
if has('win32') && !has('gui_running') && &t_Co < 256
for u in values(s:lightline.palette)
for v in values(u)
@ -203,6 +200,10 @@ function! lightline#colorscheme() abort
endfor
endfor
endif
let s:highlight = {}
call lightline#highlight('normal')
call lightline#link()
let s:_ = 0
endtry
endfunction
@ -228,16 +229,16 @@ function! lightline#link(...) abort
for [p, l] in [['Left', len(s:lightline.active.left)], ['Right', len(s:lightline.active.right)]]
for [i, t] in map(range(0, l), '[v:val, 0]') + types
if i != l
exec printf('hi link LightLine%s_active_%s LightLine%s_%s_%s', p, i, p, mode, i)
exec printf('hi link Lightline%s_active_%s Lightline%s_%s_%s', p, i, p, mode, i)
endif
for [j, s] in map(range(0, l), '[v:val, 0]') + types
if i + 1 == j || t || s && i != l
exec printf('hi link LightLine%s_active_%s_%s LightLine%s_%s_%s_%s', p, i, j, p, mode, i, j)
exec printf('hi link Lightline%s_active_%s_%s Lightline%s_%s_%s_%s', p, i, j, p, mode, i, j)
endif
endfor
endfor
endfor
exec printf('hi link LightLineMiddle_active LightLineMiddle_%s', mode)
exec printf('hi link LightlineMiddle_active LightlineMiddle_%s', mode)
return ''
endfunction
@ -263,7 +264,7 @@ endif
function! lightline#highlight(...) abort
let [c, f] = [s:lightline.palette, s:lightline.mode_fallback]
let [s:lightline.llen, s:lightline.rlen] = [len(c.normal.left), len(c.normal.right)]
let [s:lightline.tab_llen, s:lightline.tab_rlen] = [len(has_key(get(c, 'tabline', {}), 'left') ? c.tabline.left : c.normal.left), len(has_key(get(c, 'tabline', {}), 'right') ? c.tabline.right : c.normal.right)]
let [s:lightline.tab_llen, s:lightline.tab_rlen] = [len(has_key(get(c, 'tabline', {}), 'left') ? c.tabline.left : c.normal.left), len(has_key(get(c, 'tabline', {}), 'right') ? c.tabline.right : c.normal.right)]
let types = map(s:uniq(sort(filter(values(s:lightline.component_type), 'v:val !=# "raw"'))), '[v:val, 1]')
let modes = a:0 ? [a:1] : extend(['normal', 'insert', 'replace', 'visual', 'inactive', 'command', 'select', 'tabline'], has('nvim') ? ['terminal'] : [])
for mode in modes
@ -276,28 +277,28 @@ function! lightline#highlight(...) abort
let rs = has_key(get(c, d, {}), 'right') ? c[d].right : has_key(f, d) && has_key(get(c, f[d], {}), 'right') ? c[f[d]].right : c.normal.right
for [p, l, zs] in [['Left', len(left), ls], ['Right', len(right), rs]]
for [i, t] in map(range(0, l), '[v:val, 0]') + types
if i != l
if i < l || i < 1
let r = t ? (has_key(get(c, d, []), i) ? c[d][i][0] : has_key(get(c, 'tabline', {}), i) ? c.tabline[i][0] : get(c.normal, i, zs)[0]) : get(zs, i, ms)
exec printf('hi LightLine%s_%s_%s guifg=%s guibg=%s ctermfg=%s ctermbg=%s %s', p, mode, i, r[0], r[1], r[2], r[3], s:term(r))
exec printf('hi Lightline%s_%s_%s guifg=%s guibg=%s ctermfg=%s ctermbg=%s %s', p, mode, i, r[0], r[1], r[2], r[3], s:term(r))
endif
for [j, s] in map(range(0, l), '[v:val, 0]') + types
if i + 1 == j || t || s && i != l
let q = s ? (has_key(get(c, d, []), j) ? c[d][j][0] : has_key(get(c, 'tabline', {}), j) ? c.tabline[j][0] : get(c.normal, j, zs)[0]) : (j != l ? get(zs, j, ms) :ms)
exec printf('hi LightLine%s_%s_%s_%s guifg=%s guibg=%s ctermfg=%s ctermbg=%s', p, mode, i, j, r[1], q[1], r[3], q[3])
exec printf('hi Lightline%s_%s_%s_%s guifg=%s guibg=%s ctermfg=%s ctermbg=%s', p, mode, i, j, r[1], q[1], r[3], q[3])
endif
endfor
endfor
endfor
exec printf('hi LightLineMiddle_%s guifg=%s guibg=%s ctermfg=%s ctermbg=%s %s', mode, ms[0], ms[1], ms[2], ms[3], s:term(ms))
exec printf('hi LightlineMiddle_%s guifg=%s guibg=%s ctermfg=%s ctermbg=%s %s', mode, ms[0], ms[1], ms[2], ms[3], s:term(ms))
endfor
endfunction
function! s:subseparator(components, subseparator, expanded) abort
let [a, c, f, v] = [ a:components, s:lightline.component, s:lightline.component_function, s:lightline.component_visible_condition ]
let [a, c, f, v, u ] = [ a:components, s:lightline.component, s:lightline.component_function, s:lightline.component_visible_condition, s:lightline.component_function_visible_condition ]
let xs = map(range(len(a:components)), 'a:expanded[v:val] ? "1" :
\ has_key(f, a[v:val]) ? (exists("*".f[a[v:val]]) ? "" : "exists(\"*".f[a[v:val]]."\")&&").f[a[v:val]]."()!=#\"\"" :
\ has_key(v, a[v:val]) ? "(" . v[a[v:val]] . ")" : has_key(c, a[v:val]) ? "1" : "0"')
return '%{' . (xs[0] ==# '1' ? '' : xs[0] . '&&(') . join(xs[1:], '||') . (xs[0] ==# '1' ? '' : ')') . '?"' . a:subseparator . '":""}'
\ has_key(f, a[v:val]) ? (has_key(u, a[v:val]) ? "(".u[a[v:val]].")" : (exists("*".f[a[v:val]]) ? "" : "exists(\"*".f[a[v:val]]."\")&&").f[a[v:val]]."()!=#\"\"") :
\ has_key(v, a[v:val]) ? "(".v[a[v:val]].")" : has_key(c, a[v:val]) ? "1" : "0"')
return '%{' . (xs[0] ==# '1' || xs[0] ==# '(1)' ? '' : xs[0] . '&&(') . join(xs[1:], '||') . (xs[0] ==# '1' || xs[0] ==# '(1)' ? '' : ')') . '?"' . a:subseparator . '":""}'
endfunction
function! lightline#concatenate(xs, right) abort
@ -324,7 +325,7 @@ endfunction
function! s:evaluate_expand(component) abort
try
let result = call(a:component, [])
let result = eval(a:component . '()')
if type(result) == 1 && result ==# ''
return []
endif
@ -399,7 +400,7 @@ function! s:line(tabline, inactive) abort
let r_ = has_key(s:lightline, mode) ? s:lightline[mode].right : s:lightline.active.right
let [rt, rc, rl] = s:expand(copy(r_))
for i in range(len(lt))
let _ .= '%#LightLineLeft_' . mode . '_' . ll[i] . '#'
let _ .= '%#LightlineLeft_' . mode . '_' . ll[i] . '#'
for j in range(len(lt[i]))
let x = lc[i][j] ? lt[i][j] : has_key(f, lt[i][j]) ? (exists('*' . f[lt[i][j]]) ? '%{' . f[lt[i][j]] . '()}' : '%{exists("*' . f[lt[i][j]] . '")?' . f[lt[i][j]] . '():""}') : get(c, lt[i][j], '')
let _ .= has_key(t, lt[i][j]) && t[lt[i][j]] ==# 'raw' || x ==# '' ? x : '%( ' . x . ' %)'
@ -407,14 +408,14 @@ function! s:line(tabline, inactive) abort
let _ .= s:subseparator(lt[i][(j):], s.left, lc[i][(j):])
endif
endfor
let _ .= '%#LightLineLeft_' . mode . '_' . ll[i] . '_' . ll[i + 1] . '#'
let _ .= '%#LightlineLeft_' . mode . '_' . ll[i] . '_' . ll[i + 1] . '#'
let _ .= i < l + len(lt) - len(l_) && ll[i] < l || ll[i] != ll[i + 1] ? p.left : len(lt[i]) ? s.left : ''
endfor
let _ .= '%#LightLineMiddle_' . mode . '#%='
let _ .= '%#LightlineMiddle_' . mode . '#%='
for i in reverse(range(len(rt)))
let _ .= '%#LightLineRight_' . mode . '_' . rl[i] . '_' . rl[i + 1] . '#'
let _ .= '%#LightlineRight_' . mode . '_' . rl[i] . '_' . rl[i + 1] . '#'
let _ .= i < r + len(rt) - len(r_) && rl[i] < r || rl[i] != rl[i + 1] ? p.right : len(rt[i]) ? s.right : ''
let _ .= '%#LightLineRight_' . mode . '_' . rl[i] . '#'
let _ .= '%#LightlineRight_' . mode . '_' . rl[i] . '#'
for j in range(len(rt[i]))
let x = rc[i][j] ? rt[i][j] : has_key(f, rt[i][j]) ? (exists('*' . f[rt[i][j]]) ? '%{' . f[rt[i][j]] . '()}' : '%{exists("*' . f[rt[i][j]] . '")?' . f[rt[i][j]] . '():""}') : get(c, rt[i][j], '')
let _ .= has_key(t, rt[i][j]) && t[rt[i][j]] ==# 'raw' || x ==# '' ? x : '%( ' . x . ' %)'

View File

@ -0,0 +1,36 @@
" =============================================================================
" Filename: autoload/lightline/colorscheme/Dracula.vim
" Author: itchyny
" License: MIT License
" Last Change: 2016/11/06 01:08:03.
" =============================================================================
let s:black = [ '#282a36', 235 ]
let s:gray = [ '#44475a', 236 ]
let s:white = [ '#f8f8f2', 231 ]
let s:darkblue = [ '#6272a4', 61 ]
let s:cyan = [ '#8be9fd', 117 ]
let s:green = [ '#50fa7b', 84 ]
let s:orange = [ '#ffb86c', 215 ]
let s:purple = [ '#bd93f9', 141 ]
let s:red = [ '#ff79c6', 212 ]
let s:yellow = [ '#f1fa8c', 228 ]
let s:p = {'normal': {}, 'inactive': {}, 'insert': {}, 'replace': {}, 'visual': {}, 'tabline': {}}
let s:p.normal.left = [ [ s:black, s:purple ], [ s:cyan, s:gray ] ]
let s:p.normal.right = [ [ s:black, s:purple ], [ s:white, s:darkblue ] ]
let s:p.inactive.right = [ [ s:black, s:gray ], [ s:white, s:black ] ]
let s:p.inactive.left = [ [ s:cyan, s:black ], [ s:white, s:black ] ]
let s:p.insert.left = [ [ s:black, s:green ], [ s:cyan, s:gray ] ]
let s:p.replace.left = [ [ s:black, s:red ], [ s:cyan, s:gray ] ]
let s:p.visual.left = [ [ s:black, s:orange ], [ s:cyan, s:gray ] ]
let s:p.normal.middle = [ [ s:white, s:gray ] ]
let s:p.inactive.middle = [ [ s:white, s:gray ] ]
let s:p.tabline.left = [ [ s:darkblue, s:gray ] ]
let s:p.tabline.tabsel = [ [ s:cyan, s:black ] ]
let s:p.tabline.middle = [ [ s:darkblue, s:gray ] ]
let s:p.tabline.right = copy(s:p.normal.right)
let s:p.normal.error = [ [ s:red, s:black ] ]
let s:p.normal.warning = [ [ s:yellow, s:black ] ]
let g:lightline#colorscheme#Dracula#palette = lightline#colorscheme#flatten(s:p)

View File

@ -0,0 +1,36 @@
" =============================================================================
" Filename: autoload/lightline/colorscheme/molokai.vim
" Author: challsted
" License: MIT License
" Last Change: 2016/11/17 00:27:58.
" =============================================================================
"
let s:black = [ '#232526', 233 ]
let s:gray = [ '#808080', 244 ]
let s:white = [ '#f8f8f2', 234 ]
let s:cyan = [ '#66d9ef', 81 ]
let s:green = [ '#a6e22e', 118 ]
let s:orange = [ '#ef5939', 166 ]
let s:pink = [ '#f92672', 161 ]
let s:red = [ '#ff0000', 160 ]
let s:yellow = [ '#e6db74', 229 ]
let s:p = {'normal': {}, 'inactive': {}, 'insert': {}, 'replace': {}, 'visual': {}, 'tabline': {}}
let s:p.normal.left = [ [ s:black, s:cyan ], [ s:orange, s:black ] ]
let s:p.normal.middle = [ [ s:orange, s:black ] ]
let s:p.normal.right = [ [ s:pink, s:black ], [ s:black, s:pink ] ]
let s:p.normal.error = [ [ s:pink, s:black ] ]
let s:p.normal.warning = [ [ s:yellow, s:black ] ]
let s:p.insert.left = [ [ s:black, s:green ], [ s:green, s:black ] ]
let s:p.visual.left = [ [ s:black, s:yellow ], [ s:yellow, s:black ] ]
let s:p.replace.left = [ [ s:black, s:red ], [ s:red, s:black ] ]
let s:p.inactive.left = [ [ s:pink, s:black ], [ s:white, s:black ] ]
let s:p.inactive.middle = [ [ s:gray, s:black ] ]
let s:p.inactive.right = [ [ s:white, s:pink ], [ s:pink, s:black ] ]
let s:p.tabline.left = [ [ s:pink, s:black ] ]
let s:p.tabline.middle = [ [ s:pink, s:black] ]
let s:p.tabline.right = copy(s:p.normal.right)
let s:p.tabline.tabsel = [ [ s:black, s:pink ] ]
let g:lightline#colorscheme#molokai#palette = lightline#colorscheme#flatten(s:p)

View File

@ -0,0 +1,63 @@
" =============================================================================
" Filename: autoload/lightline/colorscheme/one.vim
" Author: Zoltan Dalmadi
" License: MIT License
" Last Change: 2016/11/2 17:34:27.
" =============================================================================
" Common colors
let s:fg = '#abb2bf'
let s:blue = '#61afef'
let s:green = '#98c379'
let s:purple = '#c678dd'
let s:red1 = '#e06c75'
let s:red2 = '#be5046'
let s:yellow = '#e5c07b'
let s:p = {'normal': {}, 'inactive': {}, 'insert': {}, 'replace': {}, 'visual': {}, 'tabline': {}}
if &background ==# 'light'
" Light variant
let s:bg = '#fafafa'
let s:gray1 = '#494b53'
let s:gray2 = '#f0f0f0'
let s:gray3 = '#d0d0d0'
let s:p.normal.left = [ [ s:bg, s:green, 'bold' ], [ s:gray1, s:gray3 ] ]
let s:p.normal.middle = [ [ s:gray1, s:gray2 ] ]
let s:p.inactive.left = [ [ s:bg, s:gray3 ], [ s:bg, s:gray3 ] ]
let s:p.inactive.middle = [ [ s:gray3, s:gray2 ] ]
let s:p.inactive.right = [ [ s:bg, s:gray3 ], [ s:bg, s:gray3 ] ]
let s:p.insert.left = [ [ s:bg, s:blue, 'bold' ], [ s:gray1, s:gray3 ] ]
let s:p.replace.left = [ [ s:bg, s:red1, 'bold' ], [ s:gray1, s:gray3 ] ]
let s:p.visual.left = [ [ s:bg, s:purple, 'bold' ], [ s:gray1, s:gray3 ] ]
else
" Dark variant
let s:bg = '#282c34'
let s:gray1 = '#5c6370'
let s:gray2 = '#2c323d'
let s:gray3 = '#3e4452'
let s:p.normal.left = [ [ s:bg, s:green, 'bold' ], [ s:fg, s:gray3 ] ]
let s:p.normal.middle = [ [ s:fg, s:gray2 ] ]
let s:p.inactive.left = [ [ s:gray1, s:bg ], [ s:gray1, s:bg ] ]
let s:p.inactive.middle = [ [ s:gray1, s:gray2 ] ]
let s:p.inactive.right = [ [ s:gray1, s:bg ], [ s:gray1, s:bg ] ]
let s:p.insert.left = [ [ s:bg, s:blue, 'bold' ], [ s:fg, s:gray3 ] ]
let s:p.replace.left = [ [ s:bg, s:red1, 'bold' ], [ s:fg, s:gray3 ] ]
let s:p.visual.left = [ [ s:bg, s:purple, 'bold' ], [ s:fg, s:gray3 ] ]
endif
" Common
let s:p.normal.right = [ [ s:bg, s:green, 'bold' ], [ s:bg, s:green, 'bold' ] ]
let s:p.normal.error = [ [ s:red2, s:bg ] ]
let s:p.normal.warning = [ [ s:yellow, s:bg ] ]
let s:p.insert.right = [ [ s:bg, s:blue, 'bold' ], [ s:bg, s:blue, 'bold' ] ]
let s:p.replace.right = [ [ s:bg, s:red1, 'bold' ], [ s:bg, s:red1, 'bold' ] ]
let s:p.visual.right = [ [ s:bg, s:purple, 'bold' ], [ s:bg, s:purple, 'bold' ] ]
let s:p.tabline.left = [ [ s:bg, s:gray3 ] ]
let s:p.tabline.tabsel = [ [ s:bg, s:purple, 'bold' ] ]
let s:p.tabline.middle = [ [ s:gray3, s:gray2 ] ]
let s:p.tabline.right = copy(s:p.normal.right)
let g:lightline#colorscheme#one#palette = lightline#colorscheme#fill(s:p)

View File

@ -2,10 +2,79 @@
" Filename: autoload/lightline/colorscheme/solarized.vim
" Author: itchyny
" License: MIT License
" Last Change: 2013/08/27 10:24:28.
" Last Change: 2016/08/08 10:31:00.
" =============================================================================
if &background ==# 'light'
let g:lightline#colorscheme#solarized#palette = g:lightline#colorscheme#solarized_light#palette
let s:cuicolors = {
\ 'base03': [ '8', '234', 'DarkGray' ],
\ 'base02': [ '0', '235', 'Black' ],
\ 'base01': [ '10', '239', 'LightGreen' ],
\ 'base00': [ '11', '240', 'LightYellow' ],
\ 'base0': [ '12', '244', 'LightBlue' ],
\ 'base1': [ '14', '245', 'LightCyan' ],
\ 'base2': [ '7', '187', 'LightGray' ],
\ 'base3': [ '15', '230', 'White' ],
\ 'yellow': [ '3', '136', 'DarkYellow' ],
\ 'orange': [ '9', '166', 'LightRed' ],
\ 'red': [ '1', '124', 'DarkRed' ],
\ 'magenta': [ '5', '125', 'DarkMagenta' ],
\ 'violet': [ '13', '61', 'LightMagenta' ],
\ 'blue': [ '4', '33', 'DarkBlue' ],
\ 'cyan': [ '6', '37', 'DarkCyan' ],
\ 'green': [ '2', '64', 'DarkGreen' ],
\ }
" The following condition only applies for the console and is the same
" condition vim-colors-solarized uses to determine which set of colors
" to use.
let s:solarized_termcolors = get(g:, 'solarized_termcolors', 256)
if s:solarized_termcolors != 256 && &t_Co >= 16
let s:cuiindex = 0
elseif s:solarized_termcolors == 256
let s:cuiindex = 1
else
let g:lightline#colorscheme#solarized#palette = g:lightline#colorscheme#solarized_dark#palette
let s:cuiindex = 2
endif
let s:base03 = [ '#002b36', s:cuicolors.base03[s:cuiindex] ]
let s:base02 = [ '#073642', s:cuicolors.base02[s:cuiindex] ]
let s:base01 = [ '#586e75', s:cuicolors.base01[s:cuiindex] ]
let s:base00 = [ '#657b83', s:cuicolors.base00[s:cuiindex] ]
let s:base0 = [ '#839496', s:cuicolors.base0[s:cuiindex] ]
let s:base1 = [ '#93a1a1', s:cuicolors.base1[s:cuiindex] ]
let s:base2 = [ '#eee8d5', s:cuicolors.base2[s:cuiindex] ]
let s:base3 = [ '#fdf6e3', s:cuicolors.base3[s:cuiindex] ]
let s:yellow = [ '#b58900', s:cuicolors.yellow[s:cuiindex] ]
let s:orange = [ '#cb4b16', s:cuicolors.orange[s:cuiindex] ]
let s:red = [ '#dc322f', s:cuicolors.red[s:cuiindex] ]
let s:magenta = [ '#d33682', s:cuicolors.magenta[s:cuiindex] ]
let s:violet = [ '#6c71c4', s:cuicolors.violet[s:cuiindex] ]
let s:blue = [ '#268bd2', s:cuicolors.blue[s:cuiindex] ]
let s:cyan = [ '#2aa198', s:cuicolors.cyan[s:cuiindex] ]
let s:green = [ '#859900', s:cuicolors.green[s:cuiindex] ]
if &background ==# 'light'
let [ s:base03, s:base3 ] = [ s:base3, s:base03 ]
let [ s:base02, s:base2 ] = [ s:base2, s:base02 ]
let [ s:base01, s:base1 ] = [ s:base1, s:base01 ]
let [ s:base00, s:base0 ] = [ s:base0, s:base00 ]
endif
let s:p = {'normal': {}, 'inactive': {}, 'insert': {}, 'replace': {}, 'visual': {}, 'tabline': {}}
let s:p.normal.left = [ [ s:base03, s:blue ], [ s:base03, s:base00 ] ]
let s:p.normal.right = [ [ s:base03, s:base1 ], [ s:base03, s:base00 ] ]
let s:p.inactive.right = [ [ s:base03, s:base00 ], [ s:base0, s:base02 ] ]
let s:p.inactive.left = [ [ s:base0, s:base02 ], [ s:base0, s:base02 ] ]
let s:p.insert.left = [ [ s:base03, s:green ], [ s:base03, s:base00 ] ]
let s:p.replace.left = [ [ s:base03, s:red ], [ s:base03, s:base00 ] ]
let s:p.visual.left = [ [ s:base03, s:magenta ], [ s:base03, s:base00 ] ]
let s:p.normal.middle = [ [ s:base1, s:base02 ] ]
let s:p.inactive.middle = [ [ s:base01, s:base02 ] ]
let s:p.tabline.left = [ [ s:base03, s:base00 ] ]
let s:p.tabline.tabsel = [ [ s:base03, s:base1 ] ]
let s:p.tabline.middle = [ [ s:base0, s:base02 ] ]
let s:p.tabline.right = copy(s:p.normal.right)
let s:p.normal.error = [ [ s:base03, s:red ] ]
let s:p.normal.warning = [ [ s:base03, s:yellow ] ]
let g:lightline#colorscheme#solarized#palette = lightline#colorscheme#flatten(s:p)

View File

@ -1,73 +0,0 @@
" =============================================================================
" Filename: autoload/lightline/colorscheme/solarized_dark.vim
" Author: itchyny
" License: MIT License
" Last Change: 2014/05/31 01:04:15.
" =============================================================================
let s:cuicolors = {
\ 'base03': [ '8', '234', 'DarkGray' ],
\ 'base02': [ '0', '235', 'Black' ],
\ 'base01': [ '10', '239', 'LightGreen' ],
\ 'base00': [ '11', '240', 'LightYellow' ],
\ 'base0': [ '12', '244', 'LightBlue' ],
\ 'base1': [ '14', '245', 'LightCyan' ],
\ 'base2': [ '7', '187', 'LightGray' ],
\ 'base3': [ '15', '230', 'White' ],
\ 'yellow': [ '3', '136', 'DarkYellow' ],
\ 'orange': [ '9', '166', 'LightRed' ],
\ 'red': [ '1', '124', 'DarkRed' ],
\ 'magenta': [ '5', '125', 'DarkMagenta' ],
\ 'violet': [ '13', '61', 'LightMagenta' ],
\ 'blue': [ '4', '33', 'DarkBlue' ],
\ 'cyan': [ '6', '37', 'DarkCyan' ],
\ 'green': [ '2', '64', 'DarkGreen' ],
\ }
" The following condition only applies for the console and is the same
" condition vim-colors-solarized uses to determine which set of colors
" to use.
let s:solarized_termcolors = get(g:, 'solarized_termcolors', 256)
if s:solarized_termcolors != 256 && &t_Co >= 16
let s:cuiindex = 0
elseif s:solarized_termcolors == 256
let s:cuiindex = 1
else
let s:cuiindex = 2
endif
let s:base03 = [ '#002b36', s:cuicolors.base03[s:cuiindex] ]
let s:base02 = [ '#073642', s:cuicolors.base02[s:cuiindex] ]
let s:base01 = [ '#586e75', s:cuicolors.base01[s:cuiindex] ]
let s:base00 = [ '#657b83', s:cuicolors.base00[s:cuiindex] ]
let s:base0 = [ '#839496', s:cuicolors.base0[s:cuiindex] ]
let s:base1 = [ '#93a1a1', s:cuicolors.base1[s:cuiindex] ]
let s:base2 = [ '#eee8d5', s:cuicolors.base2[s:cuiindex] ]
let s:base3 = [ '#fdf6e3', s:cuicolors.base3[s:cuiindex] ]
let s:yellow = [ '#b58900', s:cuicolors.yellow[s:cuiindex] ]
let s:orange = [ '#cb4b16', s:cuicolors.orange[s:cuiindex] ]
let s:red = [ '#dc322f', s:cuicolors.red[s:cuiindex] ]
let s:magenta = [ '#d33682', s:cuicolors.magenta[s:cuiindex] ]
let s:violet = [ '#6c71c4', s:cuicolors.violet[s:cuiindex] ]
let s:blue = [ '#268bd2', s:cuicolors.blue[s:cuiindex] ]
let s:cyan = [ '#2aa198', s:cuicolors.cyan[s:cuiindex] ]
let s:green = [ '#859900', s:cuicolors.green[s:cuiindex] ]
let s:p = {'normal': {}, 'inactive': {}, 'insert': {}, 'replace': {}, 'visual': {}, 'tabline': {}}
let s:p.normal.left = [ [ s:base3, s:blue ], [ s:base3, s:base01 ] ]
let s:p.normal.right = [ [ s:base02, s:base0 ], [ s:base1, s:base01 ] ]
let s:p.inactive.right = [ [ s:base02, s:base01 ], [ s:base00, s:base02 ] ]
let s:p.inactive.left = [ [ s:base0, s:base02 ], [ s:base00, s:base02 ] ]
let s:p.insert.left = [ [ s:base3, s:green ], [ s:base3, s:base01 ] ]
let s:p.replace.left = [ [ s:base3, s:red ], [ s:base3, s:base01 ] ]
let s:p.visual.left = [ [ s:base3, s:magenta ], [ s:base3, s:base01 ] ]
let s:p.normal.middle = [ [ s:base1, s:base02 ] ]
let s:p.inactive.middle = [ [ s:base0, s:base02 ] ]
let s:p.tabline.left = [ [ s:base1, s:base00 ] ]
let s:p.tabline.tabsel = [ [ s:base3, s:base0 ] ]
let s:p.tabline.middle = [ [ s:base01, s:base02 ] ]
let s:p.tabline.right = copy(s:p.normal.right)
let s:p.normal.error = [ [ s:base2, s:red ] ]
let s:p.normal.warning = [ [ s:base02, s:yellow ] ]
let g:lightline#colorscheme#solarized_dark#palette = lightline#colorscheme#flatten(s:p)

View File

@ -1,80 +0,0 @@
" =============================================================================
" Filename: autoload/lightline/colorscheme/solarized_light.vim
" Author: itchyny
" License: MIT License
" Last Change: 2014/05/31 01:04:21.
" =============================================================================
let s:cuicolors = {
\ 'base03': [ '8', '234', 'DarkGray' ],
\ 'base02': [ '0', '235', 'Black' ],
\ 'base01': [ '10', '239', 'LightGreen' ],
\ 'base00': [ '11', '240', 'LightYellow' ],
\ 'base0': [ '12', '244', 'LightBlue' ],
\ 'base1': [ '14', '245', 'LightCyan' ],
\ 'base2': [ '7', '187', 'LightGray' ],
\ 'base3': [ '15', '230', 'White' ],
\ 'yellow': [ '3', '136', 'DarkYellow' ],
\ 'orange': [ '9', '166', 'LightRed' ],
\ 'red': [ '1', '124', 'DarkRed' ],
\ 'magenta': [ '5', '125', 'DarkMagenta' ],
\ 'violet': [ '13', '61', 'LightMagenta' ],
\ 'blue': [ '4', '33', 'DarkBlue' ],
\ 'cyan': [ '6', '37', 'DarkCyan' ],
\ 'green': [ '2', '64', 'DarkGreen' ],
\ }
" The following condition only applies for the console and is the same
" condition vim-colors-solarized uses to determine which set of colors
" to use.
let s:solarized_termcolors = get(g:, 'solarized_termcolors', 256)
if s:solarized_termcolors != 256 && &t_Co >= 16
let s:cuiindex = 0
elseif s:solarized_termcolors == 256
let s:cuiindex = 1
else
let s:cuiindex = 2
endif
let s:base03 = [ '#002b36', s:cuicolors.base03[s:cuiindex] ]
let s:base02 = [ '#073642', s:cuicolors.base02[s:cuiindex] ]
let s:base01 = [ '#586e75', s:cuicolors.base01[s:cuiindex] ]
let s:base00 = [ '#657b83', s:cuicolors.base00[s:cuiindex] ]
let s:base0 = [ '#839496', s:cuicolors.base0[s:cuiindex] ]
let s:base1 = [ '#93a1a1', s:cuicolors.base1[s:cuiindex] ]
let s:base2 = [ '#eee8d5', s:cuicolors.base2[s:cuiindex] ]
let s:base3 = [ '#fdf6e3', s:cuicolors.base3[s:cuiindex] ]
let s:yellow = [ '#b58900', s:cuicolors.yellow[s:cuiindex] ]
let s:orange = [ '#cb4b16', s:cuicolors.orange[s:cuiindex] ]
let s:red = [ '#dc322f', s:cuicolors.red[s:cuiindex] ]
let s:magenta = [ '#d33682', s:cuicolors.magenta[s:cuiindex] ]
let s:violet = [ '#6c71c4', s:cuicolors.violet[s:cuiindex] ]
let s:blue = [ '#268bd2', s:cuicolors.blue[s:cuiindex] ]
let s:cyan = [ '#2aa198', s:cuicolors.cyan[s:cuiindex] ]
let s:green = [ '#859900', s:cuicolors.green[s:cuiindex] ]
let [s:base03, s:base3] = [s:base3, s:base03]
let [s:base02, s:base2] = [s:base2, s:base02]
let [s:base01, s:base1] = [s:base1, s:base01]
let [s:base00, s:base0] = [s:base0, s:base00]
let s:p = {'normal': {}, 'inactive': {}, 'insert': {}, 'replace': {}, 'visual': {}, 'tabline': {}}
let s:p.normal.left = [ [ s:base3, s:blue ], [ s:base3, s:base01 ] ]
let s:p.normal.right = [ [ s:base02, s:base0 ], [ s:base1, s:base01 ] ]
let s:p.inactive.right = [ [ s:base02, s:base01 ], [ s:base00, s:base02 ] ]
let s:p.inactive.left = [ [ s:base0, s:base02 ], [ s:base00, s:base02 ] ]
let s:p.insert.left = [ [ s:base3, s:green ], [ s:base3, s:base01 ] ]
let s:p.replace.left = [ [ s:base3, s:red ], [ s:base3, s:base01 ] ]
let s:p.visual.left = [ [ s:base3, s:magenta ], [ s:base3, s:base01 ] ]
let s:p.normal.middle = [ [ s:base1, s:base02 ] ]
let s:p.inactive.middle = [ [ s:base0, s:base02 ] ]
let s:p.tabline.left = [ [ s:base2, s:base01 ] ]
let s:p.tabline.tabsel = [ [ s:base2, s:base03 ] ]
let s:p.tabline.middle = [ [ s:base1, s:base02 ] ]
let s:p.tabline.right = copy(s:p.normal.right)
let s:p.normal.error = [ [ s:red, s:base01 ] ]
let s:p.normal.warning = [ [ s:yellow, s:base01 ] ]
let s:p.normal.error = [ [ s:base02, s:red ] ]
let s:p.normal.warning = [ [ s:base2, s:yellow ] ]
let g:lightline#colorscheme#solarized_light#palette = lightline#colorscheme#flatten(s:p)

View File

@ -1,10 +1,10 @@
*lightline.txt* A light and configurable statusline/tabline for Vim
Version: 0.0
Version: 0.1
Author: itchyny (https://github.com/itchyny)
License: MIT License
Repository: https://github.com/itchyny/lightline.vim
Last Change: 2016/05/08 13:56:19.
Last Change: 2016/10/24 08:12:28.
CONTENTS *lightline-contents*
@ -19,7 +19,6 @@ Examples |lightline-examples|
Nice Examples |lightline-nice-examples|
Powerful Example |lightline-powerful-example|
Troubleshooting |lightline-troubleshooting|
Changelog |lightline-changelog|
==============================================================================
INTRODUCTION *lightline-introduction*
@ -115,10 +114,13 @@ OPTIONS *lightline-option*
\ 'column': '%c'
\ 'close': '%999X X ' }
<
g:lightline.component_visible_condition *g:lightline.component_visible_condition*
Dictionary of boolean expressions for the components.
g:lightline.component_visible_condition
*g:lightline.component_visible_condition*
Dictionary to store the visible condition of the components.
Each expression should correspond to the condition each
component have non-zero length.
component is not empty. This configuration is used to control
the visibility of the subseparators. You cannot use this
configuration to control the visibility of the components.
The default value is:
>
let g:lightline.component_visible_condition = {
@ -135,6 +137,11 @@ OPTIONS *lightline-option*
because the user does not have to set both component and
component_visible_condition. If a component set to both component and
component_function, the setting of component_function has priority.
The default value is:
>
let g:lightline.component_function = {}
<
For example, if you want a component for read-only mark, which
disappears in help windows:
>
@ -144,12 +151,25 @@ OPTIONS *lightline-option*
\ [ 'myreadonly', 'filename', 'modified' ] ],
\ },
\ 'component_function': {
\ 'myreadonly': 'LightLineReadonly'
\ 'myreadonly': 'LightlineReadonly'
\ },
\ }
function! LightLineReadonly()
function! LightlineReadonly()
return &ft !~? 'help' && &readonly ? 'RO' : ''
endfunction
<
g:lightline.component_function_visible_condition
*g:lightline.component_function_visible_condition*
Dictionary to store the visible conditions of the function
components. Each expression should correspond to the condition
each component is not empty. This configuration is used to
control the visibility of the subseparators. You can use this
configuration to reduce the number of function calls for
function components by setting the value 1 (to tell lightline
that the component is always visible).
The default value is:
>
let g:lightline.component_function_visible_condition = {}
<
g:lightline.component_expand *g:lightline.component_expand*
Another dictionary for components. You can create a component
@ -175,14 +195,18 @@ OPTIONS *lightline-option*
|g:lightline.component_expand|. The types are used to specify
the color. Specifically, the type raw is used to specify a
component which should not be wrapped by item group: %(...%).
>
The default value is: >
let g:lightline.component_type = {
\ 'tabs': 'tabsel',
\ 'close': 'raw' }
<
g:lightline.tab_component *g:lightline.tab_component*
A dictionary for components in one tab.
The default value is: >
let g:lightline.tab_component = {}
<
g:lightline.tab_component_function *g:lightline.tab_component_function*
Another dictionary for components in one tab.
A function specified as a tab component takes one argument:
@ -199,7 +223,7 @@ OPTIONS *lightline-option*
The colorscheme for lightline.vim.
Currently, wombat, solarized, powerline, jellybeans, Tomorrow,
Tomorrow_Night, Tomorrow_Night_Blue, Tomorrow_Night_Eighties,
PaperColor, seoul256, landscape and 16color are available.
PaperColor, seoul256, landscape, one, Dracula, Molokai and 16color are available.
The default value is:
>
let g:lightline.colorscheme = 'default'
@ -275,19 +299,19 @@ nice.
\ 'lineinfo': ' %3l:%-2v',
\ },
\ 'component_function': {
\ 'readonly': 'LightLineReadonly',
\ 'fugitive': 'LightLineFugitive'
\ 'readonly': 'LightlineReadonly',
\ 'fugitive': 'LightlineFugitive'
\ },
\ 'separator': { 'left': '', 'right': '' },
\ 'subseparator': { 'left': '', 'right': '' }
\ }
function! LightLineReadonly()
function! LightlineReadonly()
return &readonly ? '' : ''
endfunction
function! LightLineFugitive()
function! LightlineFugitive()
if exists('*fugitive#head')
let _ = fugitive#head()
return _ !=# '' ? ''._ : ''
let branch = fugitive#head()
return branch !=# '' ? ''.branch : ''
endif
return ''
endfunction
@ -300,19 +324,19 @@ look nice.
\ 'lineinfo': '⭡ %3l:%-2v',
\ },
\ 'component_function': {
\ 'readonly': 'LightLineReadonly',
\ 'fugitive': 'LightLineFugitive'
\ 'readonly': 'LightlineReadonly',
\ 'fugitive': 'LightlineFugitive'
\ },
\ 'separator': { 'left': '⮀', 'right': '⮂' },
\ 'subseparator': { 'left': '⮁', 'right': '⮃' }
\ }
function! LightLineReadonly()
function! LightlineReadonly()
return &readonly ? '⭤' : ''
endfunction
function! LightLineFugitive()
function! LightlineFugitive()
if exists('*fugitive#head')
let _ = fugitive#head()
return _ !=# '' ? '⭠ '._ : ''
let branch = fugitive#head()
return branch !=# '' ? '⭠ '.branch : ''
endif
return ''
endfunction
@ -337,7 +361,7 @@ Exposed functions for lightline.vim.
Returns the mode of the Vim using |g:lightline.mode_map|.
lightline#init() *lightline#init()*
Initializes the variable |g:lightline|.
Initializes the internal state from |g:lightline|.
lightline#colorscheme() *lightline#colorscheme()*
Initializes the colorscheme and the highlight groups.
@ -612,6 +636,16 @@ compiled version of your colorscheme.
<
Then copy and paste the result to the colorscheme file.
If you want to contribute a new colorscheme that is not currently available
please follow the following rules:
*) All hex codes should be lowercase only
*) Use 2 space soft tabs
*) If your colorscheme has both light and dark variants, use a single file
*) Normal Mode should default to Cyan
*) Insert Mode should default to Green
*) Visual Mode should default to Yellow
*) Replace Mode should default to Red
==============================================================================
EXAMPLES *lightline-examples*
You can configure the appearance of statusline.
@ -631,22 +665,22 @@ In order to define your own component:
\ 'left': [ [ 'mode', 'paste' ], [ 'myfilename' ] ]
\ },
\ 'component_function': {
\ 'myfilename': 'LightLineFilename',
\ 'myreadonly': 'LightLineReadonly',
\ 'mymodified': 'LightLineModified',
\ 'myfilename': 'LightlineFilename',
\ 'myreadonly': 'LightlineReadonly',
\ 'mymodified': 'LightlineModified',
\ }
\ }
function! LightLineFilename()
return ('' != LightLineReadonly() ? LightLineReadonly() . ' ' : '') .
function! LightlineFilename()
return ('' != LightlineReadonly() ? LightlineReadonly() . ' ' : '') .
\ (&ft == 'vimfiler' ? vimfiler#get_status_string() :
\ &ft == 'unite' ? unite#get_status_string() :
\ '' != expand('%:t') ? expand('%:t') : '[No Name]') .
\ ('' != LightLineModified() ? ' ' . LightLineModified() : '')
\ ('' != LightlineModified() ? ' ' . LightlineModified() : '')
endfunction
function! LightLineReadonly()
function! LightlineReadonly()
return &ft !~? 'help' && &readonly ? 'RO' : ''
endfunction
function! LightLineModified()
function! LightlineModified()
return &modifiable && &modified ? '+' : ''
endfunction
<
@ -686,25 +720,25 @@ A nice example for non-patched font users.
\ 'left': [ [ 'mode', 'paste' ], [ 'fugitive', 'filename' ] ]
\ },
\ 'component_function': {
\ 'fugitive': 'LightLineFugitive',
\ 'filename': 'LightLineFilename'
\ 'fugitive': 'LightlineFugitive',
\ 'filename': 'LightlineFilename'
\ }
\ }
function! LightLineModified()
function! LightlineModified()
return &ft =~ 'help\|vimfiler' ? '' : &modified ? '+' : &modifiable ? '' : '-'
endfunction
function! LightLineReadonly()
function! LightlineReadonly()
return &ft !~? 'help\|vimfiler' && &readonly ? 'RO' : ''
endfunction
function! LightLineFilename()
return ('' != LightLineReadonly() ? LightLineReadonly() . ' ' : '') .
function! LightlineFilename()
return ('' != LightlineReadonly() ? LightlineReadonly() . ' ' : '') .
\ (&ft == 'vimfiler' ? vimfiler#get_status_string() :
\ &ft == 'unite' ? unite#get_status_string() :
\ &ft == 'vimshell' ? vimshell#get_status_string() :
\ '' != expand('%:t') ? expand('%:t') : '[No Name]') .
\ ('' != LightLineModified() ? ' ' . LightLineModified() : '')
\ ('' != LightlineModified() ? ' ' . LightlineModified() : '')
endfunction
function! LightLineFugitive()
function! LightlineFugitive()
if &ft !~? 'vimfiler' && exists('*fugitive#head')
return fugitive#head()
endif
@ -719,30 +753,30 @@ A nice example for |vim-powerline| font users:
\ 'left': [ [ 'mode', 'paste' ], [ 'fugitive', 'filename' ] ]
\ },
\ 'component_function': {
\ 'fugitive': 'LightLineFugitive',
\ 'filename': 'LightLineFilename'
\ 'fugitive': 'LightlineFugitive',
\ 'filename': 'LightlineFilename'
\ },
\ 'separator': { 'left': '⮀', 'right': '⮂' },
\ 'subseparator': { 'left': '⮁', 'right': '⮃' }
\ }
function! LightLineModified()
function! LightlineModified()
return &ft =~ 'help\|vimfiler' ? '' : &modified ? '+' : &modifiable ? '' : '-'
endfunction
function! LightLineReadonly()
function! LightlineReadonly()
return &ft !~? 'help\|vimfiler' && &readonly ? '⭤' : ''
endfunction
function! LightLineFilename()
return ('' != LightLineReadonly() ? LightLineReadonly() . ' ' : '') .
function! LightlineFilename()
return ('' != LightlineReadonly() ? LightlineReadonly() . ' ' : '') .
\ (&ft == 'vimfiler' ? vimfiler#get_status_string() :
\ &ft == 'unite' ? unite#get_status_string() :
\ &ft == 'vimshell' ? vimshell#get_status_string() :
\ '' != expand('%:t') ? expand('%:t') : '[No Name]') .
\ ('' != LightLineModified() ? ' ' . LightLineModified() : '')
\ ('' != LightlineModified() ? ' ' . LightlineModified() : '')
endfunction
function! LightLineFugitive()
function! LightlineFugitive()
if &ft !~? 'vimfiler' && exists('*fugitive#head')
let _ = fugitive#head()
return _ !=# '' ? '⭠ '._ : ''
let branch = fugitive#head()
return branch !=# '' ? '⭠ '.branch : ''
endif
return ''
endfunction
@ -760,12 +794,12 @@ For users who uses lots of plugins:
\ 'right': [ [ 'syntastic', 'lineinfo' ], ['percent'], [ 'fileformat', 'fileencoding', 'filetype' ] ]
\ },
\ 'component_function': {
\ 'fugitive': 'LightLineFugitive',
\ 'filename': 'LightLineFilename',
\ 'fileformat': 'LightLineFileformat',
\ 'filetype': 'LightLineFiletype',
\ 'fileencoding': 'LightLineFileencoding',
\ 'mode': 'LightLineMode',
\ 'fugitive': 'LightlineFugitive',
\ 'filename': 'LightlineFilename',
\ 'fileformat': 'LightlineFileformat',
\ 'filetype': 'LightlineFiletype',
\ 'fileencoding': 'LightlineFileencoding',
\ 'mode': 'LightlineMode',
\ 'ctrlpmark': 'CtrlPMark',
\ },
\ 'component_expand': {
@ -777,15 +811,15 @@ For users who uses lots of plugins:
\ 'subseparator': { 'left': '|', 'right': '|' }
\ }
function! LightLineModified()
function! LightlineModified()
return &ft =~ 'help' ? '' : &modified ? '+' : &modifiable ? '' : '-'
endfunction
function! LightLineReadonly()
function! LightlineReadonly()
return &ft !~? 'help' && &readonly ? 'RO' : ''
endfunction
function! LightLineFilename()
function! LightlineFilename()
let fname = expand('%:t')
return fname == 'ControlP' && has_key(g:lightline, 'ctrlp_item') ? g:lightline.ctrlp_item :
\ fname == '__Tagbar__' ? g:lightline.fname :
@ -793,36 +827,36 @@ For users who uses lots of plugins:
\ &ft == 'vimfiler' ? vimfiler#get_status_string() :
\ &ft == 'unite' ? unite#get_status_string() :
\ &ft == 'vimshell' ? vimshell#get_status_string() :
\ ('' != LightLineReadonly() ? LightLineReadonly() . ' ' : '') .
\ ('' != LightlineReadonly() ? LightlineReadonly() . ' ' : '') .
\ ('' != fname ? fname : '[No Name]') .
\ ('' != LightLineModified() ? ' ' . LightLineModified() : '')
\ ('' != LightlineModified() ? ' ' . LightlineModified() : '')
endfunction
function! LightLineFugitive()
function! LightlineFugitive()
try
if expand('%:t') !~? 'Tagbar\|Gundo\|NERD' && &ft !~? 'vimfiler' && exists('*fugitive#head')
let mark = '' " edit here for cool mark
let _ = fugitive#head()
return _ !=# '' ? mark._ : ''
let branch = fugitive#head()
return branch !=# '' ? mark.branch : ''
endif
catch
endtry
return ''
endfunction
function! LightLineFileformat()
function! LightlineFileformat()
return winwidth(0) > 70 ? &fileformat : ''
endfunction
function! LightLineFiletype()
function! LightlineFiletype()
return winwidth(0) > 70 ? (&filetype !=# '' ? &filetype : 'no ft') : ''
endfunction
function! LightLineFileencoding()
function! LightlineFileencoding()
return winwidth(0) > 70 ? (&fenc !=# '' ? &fenc : &enc) : ''
endfunction
function! LightLineMode()
function! LightlineMode()
let fname = expand('%:t')
return fname == '__Tagbar__' ? 'Tagbar' :
\ fname == 'ControlP' ? 'CtrlP' :
@ -1122,7 +1156,7 @@ Problem 9: *lightline-problem-9*
subseparator.right '|' '' (\ue0b3) '⮃' (\u2b83)
branch symbol -- '' (\ue0a0) '⭠' (\u2b60)
readonly symbol -- '' (\ue0a2) '⭤' (\u2b64)
linecolumn symbol -- '' (\ue0a1) '⭡' (\u2b81)
linecolumn symbol -- '' (\ue0a1) '⭡' (\u2b61)
Problem 10: *lightline-problem-10*
Cool statusline disappears on |unite|, |vimfiler| and |vimshell|
@ -1165,10 +1199,10 @@ Problem 12: *lightline-problem-12*
>
let g:lightline = {
\ 'component': {
\ 'modified': '%#ModifiedColor#%{LightLineModified()}',
\ 'modified': '%#ModifiedColor#%{LightlineModified()}',
\ }
\ }
function! LightLineModified()
function! LightlineModified()
let map = { 'V': 'n', "\<C-v>": 'n', 's': 'n', 'v': 'n', "\<C-s>": 'n', 'c': 'n', 'R': 'n'}
let mode = get(map, mode()[0], mode()[0])
let bgcolor = {'n': [240, '#585858'], 'i': [31, '#0087af']}
@ -1187,7 +1221,7 @@ Problem 13: *lightline-problem-13*
Add the following settings to your .vimrc(_vimrc).
>
augroup LightLineColorscheme
augroup LightlineColorscheme
autocmd!
autocmd ColorScheme * call s:lightline_update()
augroup END
@ -1198,8 +1232,7 @@ Problem 13: *lightline-problem-13*
try
if g:colors_name =~# 'wombat\|solarized\|landscape\|jellybeans\|seoul256\|Tomorrow'
let g:lightline.colorscheme =
\ substitute(substitute(g:colors_name, '-', '_', 'g'), '256.*', '', '') .
\ (g:colors_name ==# 'solarized' ? '_' . &background : '')
\ substitute(substitute(g:colors_name, '-', '_', 'g'), '256.*', '', '')
call lightline#init()
call lightline#colorscheme()
call lightline#update()
@ -1267,11 +1300,5 @@ Problem 17: *lightline-problem-17*
Report/Request the issue/feature at
https://github.com/itchyny/lightline.vim/issues.
==============================================================================
CHANGELOG *lightline-changelog*
0.0 2013-08-21, ...
- Initial commit and implementation
==============================================================================
vim:tw=78:sw=4:ts=8:ft=help:norl:noet:

View File

@ -610,3 +610,15 @@ function! s:suite.duplicated_type_both_nil_right_most()
\ [[['filename'], ['y0', 'y1', 'y0', 'y1']], [[0], [1, 1, 1, 1]], ['0', 'custom', '1']])
delfunction Custom
endfunction
function! s:suite.dictionary_function()
let g:lightline = { 'component_expand': { 'custom': 'g:lightline.Custom' } }
function! g:lightline.Custom()
return [ ['left'], ['middle'], ['right'] ]
endfunction
call lightline#init()
call s:assert.equals(s:expand([['readonly', 'filename'], ['custom'], ['modified']]),
\ [[['readonly', 'filename'], ['left', 'middle', 'right'], ['modified']], [[0, 0], [1, 1, 1], [0]], ['0', '1', '2', '3']])
call s:assert.equals(s:expand([['readonly', 'filename', 'custom', 'modified']]),
\ [[['readonly', 'filename', 'left', 'middle', 'right', 'modified']], [[0, 0, 1, 1, 1, 0]], ['0', '1']])
endfunction

View File

@ -3,9 +3,6 @@ let s:assert = themis#helper('assert')
function! s:suite.before_each()
hi clear
let g:lightline = {}
call lightline#init()
call lightline#colorscheme()
endfunction
function! s:hi(name)
@ -22,55 +19,67 @@ function! s:pattern(xs, ...) abort
endfunction
function! s:suite.highlight()
let g:lightline = {}
call lightline#init()
call lightline#colorscheme()
let palette = lightline#palette()
call s:assert.match(s:hi('LightLineLeft_normal_0'), s:pattern(palette.normal.left[0]))
call s:assert.match(s:hi('LightLineLeft_normal_1'), s:pattern(palette.normal.left[1]))
call s:assert.match(s:hi('LightLineLeft_normal_2'), 'E411: highlight group not found\|cleared')
call s:assert.match(s:hi('LightLineRight_normal_0'), s:pattern(palette.normal.right[0]))
call s:assert.match(s:hi('LightLineRight_normal_1'), s:pattern(palette.normal.right[1]))
call s:assert.match(s:hi('LightLineRight_normal_2'), s:pattern(palette.normal.right[2]))
call s:assert.match(s:hi('LightLineRight_normal_3'), 'E411: highlight group not found\|cleared')
call s:assert.match(s:hi('LightLineMiddle_normal'), s:pattern(palette.normal.middle[0]))
call s:assert.match(s:hi('LightlineLeft_normal_0'), s:pattern(palette.normal.left[0]))
call s:assert.match(s:hi('LightlineLeft_normal_1'), s:pattern(palette.normal.left[1]))
call s:assert.match(s:hi('LightlineLeft_normal_2'), 'E411: highlight group not found\|cleared')
call s:assert.match(s:hi('LightlineRight_normal_0'), s:pattern(palette.normal.right[0]))
call s:assert.match(s:hi('LightlineRight_normal_1'), s:pattern(palette.normal.right[1]))
call s:assert.match(s:hi('LightlineRight_normal_2'), s:pattern(palette.normal.right[2]))
call s:assert.match(s:hi('LightlineRight_normal_3'), 'E411: highlight group not found\|cleared')
call s:assert.match(s:hi('LightlineMiddle_normal'), s:pattern(palette.normal.middle[0]))
endfunction
function! s:suite.insert()
let g:lightline = {}
call lightline#init()
call lightline#colorscheme()
call lightline#highlight('insert')
let palette = lightline#palette()
call s:assert.match(s:hi('LightLineLeft_insert_0'), s:pattern(palette.insert.left[0]))
call s:assert.match(s:hi('LightLineLeft_insert_1'), s:pattern(palette.insert.left[1]))
call s:assert.match(s:hi('LightLineLeft_insert_2'), 'E411: highlight group not found\|cleared')
call s:assert.match(s:hi('LightLineRight_insert_0'), s:pattern(palette.insert.right[0]))
call s:assert.match(s:hi('LightLineRight_insert_1'), s:pattern(palette.insert.right[1]))
call s:assert.match(s:hi('LightLineRight_insert_2'), s:pattern(palette.insert.right[2]))
call s:assert.match(s:hi('LightLineRight_insert_3'), 'E411: highlight group not found\|cleared')
call s:assert.match(s:hi('LightLineMiddle_insert'), s:pattern(palette.insert.middle[0]))
call s:assert.match(s:hi('LightlineLeft_insert_0'), s:pattern(palette.insert.left[0]))
call s:assert.match(s:hi('LightlineLeft_insert_1'), s:pattern(palette.insert.left[1]))
call s:assert.match(s:hi('LightlineLeft_insert_2'), 'E411: highlight group not found\|cleared')
call s:assert.match(s:hi('LightlineRight_insert_0'), s:pattern(palette.insert.right[0]))
call s:assert.match(s:hi('LightlineRight_insert_1'), s:pattern(palette.insert.right[1]))
call s:assert.match(s:hi('LightlineRight_insert_2'), s:pattern(palette.insert.right[2]))
call s:assert.match(s:hi('LightlineRight_insert_3'), 'E411: highlight group not found\|cleared')
call s:assert.match(s:hi('LightlineMiddle_insert'), s:pattern(palette.insert.middle[0]))
endfunction
function! s:suite.visual()
let g:lightline = {}
call lightline#init()
call lightline#colorscheme()
call lightline#highlight('visual')
let palette = lightline#palette()
call s:assert.match(s:hi('LightLineLeft_visual_0'), s:pattern(palette.visual.left[0]))
call s:assert.match(s:hi('LightLineLeft_visual_1'), s:pattern(palette.visual.left[1]))
call s:assert.match(s:hi('LightLineLeft_visual_2'), 'E411: highlight group not found\|cleared')
call s:assert.match(s:hi('LightLineRight_visual_0'), s:pattern(palette.normal.right[0]))
call s:assert.match(s:hi('LightLineRight_visual_1'), s:pattern(palette.normal.right[1]))
call s:assert.match(s:hi('LightLineRight_visual_2'), s:pattern(palette.normal.right[2]))
call s:assert.match(s:hi('LightLineRight_visual_3'), 'E411: highlight group not found\|cleared')
call s:assert.match(s:hi('LightLineMiddle_normal'), s:pattern(palette.normal.middle[0]))
call s:assert.match(s:hi('LightlineLeft_visual_0'), s:pattern(palette.visual.left[0]))
call s:assert.match(s:hi('LightlineLeft_visual_1'), s:pattern(palette.visual.left[1]))
call s:assert.match(s:hi('LightlineLeft_visual_2'), 'E411: highlight group not found\|cleared')
call s:assert.match(s:hi('LightlineRight_visual_0'), s:pattern(palette.normal.right[0]))
call s:assert.match(s:hi('LightlineRight_visual_1'), s:pattern(palette.normal.right[1]))
call s:assert.match(s:hi('LightlineRight_visual_2'), s:pattern(palette.normal.right[2]))
call s:assert.match(s:hi('LightlineRight_visual_3'), 'E411: highlight group not found\|cleared')
call s:assert.match(s:hi('LightlineMiddle_normal'), s:pattern(palette.normal.middle[0]))
endfunction
function! s:suite.replace()
let g:lightline = {}
call lightline#init()
call lightline#colorscheme()
call lightline#highlight('replace')
let palette = lightline#palette()
call s:assert.match(s:hi('LightLineLeft_replace_0'), s:pattern(palette.replace.left[0]))
call s:assert.match(s:hi('LightLineLeft_replace_1'), s:pattern(palette.replace.left[1]))
call s:assert.match(s:hi('LightLineLeft_replace_2'), 'E411: highlight group not found\|cleared')
call s:assert.match(s:hi('LightLineRight_replace_0'), s:pattern(palette.replace.right[0]))
call s:assert.match(s:hi('LightLineRight_replace_1'), s:pattern(palette.replace.right[1]))
call s:assert.match(s:hi('LightLineRight_replace_2'), s:pattern(palette.replace.right[2]))
call s:assert.match(s:hi('LightLineRight_replace_3'), 'E411: highlight group not found\|cleared')
call s:assert.match(s:hi('LightLineMiddle_replace'), s:pattern(palette.replace.middle[0]))
call s:assert.match(s:hi('LightlineLeft_replace_0'), s:pattern(palette.replace.left[0]))
call s:assert.match(s:hi('LightlineLeft_replace_1'), s:pattern(palette.replace.left[1]))
call s:assert.match(s:hi('LightlineLeft_replace_2'), 'E411: highlight group not found\|cleared')
call s:assert.match(s:hi('LightlineRight_replace_0'), s:pattern(palette.replace.right[0]))
call s:assert.match(s:hi('LightlineRight_replace_1'), s:pattern(palette.replace.right[1]))
call s:assert.match(s:hi('LightlineRight_replace_2'), s:pattern(palette.replace.right[2]))
call s:assert.match(s:hi('LightlineRight_replace_3'), 'E411: highlight group not found\|cleared')
call s:assert.match(s:hi('LightlineMiddle_replace'), s:pattern(palette.replace.middle[0]))
endfunction
function! s:suite.left_right()
@ -83,18 +92,39 @@ function! s:suite.left_right()
call lightline#init()
call lightline#colorscheme()
let palette = lightline#palette()
call s:assert.match(s:hi('LightLineLeft_normal_0'), s:pattern(palette.normal.left[0]))
call s:assert.match(s:hi('LightLineLeft_normal_1'), s:pattern(palette.normal.left[1]))
call s:assert.match(s:hi('LightLineLeft_normal_2'), s:pattern(palette.normal.middle[0]))
call s:assert.match(s:hi('LightLineLeft_normal_3'), s:pattern(palette.normal.middle[0]))
call s:assert.match(s:hi('LightLineLeft_normal_4'), 'E411: highlight group not found\|cleared')
call s:assert.match(s:hi('LightLineRight_normal_0'), s:pattern(palette.normal.right[0]))
call s:assert.match(s:hi('LightLineRight_normal_1'), s:pattern(palette.normal.right[1]))
call s:assert.match(s:hi('LightLineRight_normal_2'), s:pattern(palette.normal.right[2]))
call s:assert.match(s:hi('LightLineRight_normal_3'), s:pattern(palette.normal.middle[0]))
call s:assert.match(s:hi('LightLineRight_normal_4'), s:pattern(palette.normal.middle[0]))
call s:assert.match(s:hi('LightLineRight_normal_5'), 'E411: highlight group not found\|cleared')
call s:assert.match(s:hi('LightLineMiddle_normal'), s:pattern(palette.normal.middle[0]))
call s:assert.match(s:hi('LightlineLeft_normal_0'), s:pattern(palette.normal.left[0]))
call s:assert.match(s:hi('LightlineLeft_normal_1'), s:pattern(palette.normal.left[1]))
call s:assert.match(s:hi('LightlineLeft_normal_2'), s:pattern(palette.normal.middle[0]))
call s:assert.match(s:hi('LightlineLeft_normal_3'), s:pattern(palette.normal.middle[0]))
call s:assert.match(s:hi('LightlineLeft_normal_4'), 'E411: highlight group not found\|cleared')
call s:assert.match(s:hi('LightlineRight_normal_0'), s:pattern(palette.normal.right[0]))
call s:assert.match(s:hi('LightlineRight_normal_1'), s:pattern(palette.normal.right[1]))
call s:assert.match(s:hi('LightlineRight_normal_2'), s:pattern(palette.normal.right[2]))
call s:assert.match(s:hi('LightlineRight_normal_3'), s:pattern(palette.normal.middle[0]))
call s:assert.match(s:hi('LightlineRight_normal_4'), s:pattern(palette.normal.middle[0]))
call s:assert.match(s:hi('LightlineRight_normal_5'), 'E411: highlight group not found\|cleared')
call s:assert.match(s:hi('LightlineMiddle_normal'), s:pattern(palette.normal.middle[0]))
endfunction
function! s:suite.no_components()
let g:lightline = {
\ 'active': {
\ 'left': [],
\ 'right': []
\ },
\ 'inactive': {
\ 'left': [],
\ 'right': []
\ },
\ }
call lightline#init()
call lightline#colorscheme()
let palette = lightline#palette()
call s:assert.match(s:hi('LightlineLeft_normal_0'), s:pattern(palette.normal.left[0]))
call s:assert.match(s:hi('LightlineLeft_normal_1'), 'E411: highlight group not found\|cleared')
call s:assert.match(s:hi('LightlineRight_normal_0'), s:pattern(palette.normal.right[0]))
call s:assert.match(s:hi('LightlineRight_normal_1'), 'E411: highlight group not found\|cleared')
call s:assert.match(s:hi('LightlineMiddle_normal'), s:pattern(palette.normal.middle[0]))
endfunction
function! s:suite.subseparator()
@ -110,9 +140,9 @@ function! s:suite.subseparator()
for i in range(4)
for j in range(5)
if i + 1 == j
call s:assert.match(s:hi(printf('LightLineLeft_normal_%s_%s', i, j)), s:pattern(get(palette.normal.left, i, palette.normal.middle[0]), get(palette.normal.left, j, palette.normal.middle[0])))
call s:assert.match(s:hi(printf('LightlineLeft_normal_%s_%s', i, j)), s:pattern(get(palette.normal.left, i, palette.normal.middle[0]), get(palette.normal.left, j, palette.normal.middle[0])))
else
call s:assert.match(s:hi(printf('LightLineLeft_normal_%s_%s', i, j)), 'E411: highlight group not found\|cleared')
call s:assert.match(s:hi(printf('LightlineLeft_normal_%s_%s', i, j)), 'E411: highlight group not found\|cleared')
endif
endfor
endfor
@ -124,18 +154,18 @@ function! s:suite.component_type()
call lightline#colorscheme()
let palette = lightline#palette()
for type in ['error', 'warning']
call s:assert.match(s:hi(printf('LightLineLeft_normal_%s', type)), s:pattern(palette.normal[type][0]))
call s:assert.match(s:hi(printf('LightLineLeft_normal_0_%s', type)), s:pattern(palette.normal.left[0], palette.normal[type][0]))
call s:assert.match(s:hi(printf('LightLineLeft_normal_1_%s', type)), s:pattern(palette.normal.left[1], palette.normal[type][0]))
call s:assert.match(s:hi(printf('LightLineLeft_normal_2_%s', type)), 'E411: highlight group not found\|cleared')
call s:assert.match(s:hi(printf('LightLineLeft_normal_%s_0', type)), s:pattern(palette.normal[type][0], palette.normal.left[0]))
call s:assert.match(s:hi(printf('LightLineLeft_normal_%s_1', type)), s:pattern(palette.normal[type][0], palette.normal.left[1]))
call s:assert.match(s:hi(printf('LightLineLeft_normal_%s_2', type)), s:pattern(palette.normal[type][0], palette.normal.middle[0]))
call s:assert.match(s:hi(printf('LightLineLeft_normal_%s_3', type)), 'E411: highlight group not found\|cleared')
call s:assert.match(s:hi(printf('LightlineLeft_normal_%s', type)), s:pattern(palette.normal[type][0]))
call s:assert.match(s:hi(printf('LightlineLeft_normal_0_%s', type)), s:pattern(palette.normal.left[0], palette.normal[type][0]))
call s:assert.match(s:hi(printf('LightlineLeft_normal_1_%s', type)), s:pattern(palette.normal.left[1], palette.normal[type][0]))
call s:assert.match(s:hi(printf('LightlineLeft_normal_2_%s', type)), 'E411: highlight group not found\|cleared')
call s:assert.match(s:hi(printf('LightlineLeft_normal_%s_0', type)), s:pattern(palette.normal[type][0], palette.normal.left[0]))
call s:assert.match(s:hi(printf('LightlineLeft_normal_%s_1', type)), s:pattern(palette.normal[type][0], palette.normal.left[1]))
call s:assert.match(s:hi(printf('LightlineLeft_normal_%s_2', type)), s:pattern(palette.normal[type][0], palette.normal.middle[0]))
call s:assert.match(s:hi(printf('LightlineLeft_normal_%s_3', type)), 'E411: highlight group not found\|cleared')
endfor
for type1 in ['error', 'warning']
for type2 in ['error', 'warning']
call s:assert.match(s:hi(printf('LightLineLeft_normal_%s_%s', type1, type2)), s:pattern(palette.normal[type1][0], palette.normal[type2][0]))
call s:assert.match(s:hi(printf('LightlineLeft_normal_%s_%s', type1, type2)), s:pattern(palette.normal[type1][0], palette.normal[type2][0]))
endfor
endfor
endfunction

View File

@ -17,50 +17,50 @@ endfunction
function! s:suite.link()
call lightline#link()
call s:assert.match(s:hi('LightLineLeft_active_0'), 'LightLineLeft_normal_0')
call s:assert.match(s:hi('LightLineLeft_active_1'), 'LightLineLeft_normal_1')
call s:assert.match(s:hi('LightLineLeft_active_2'), 'E411: highlight group not found')
call s:assert.match(s:hi('LightLineRight_active_0'), 'LightLineRight_normal_0')
call s:assert.match(s:hi('LightLineRight_active_1'), 'LightLineRight_normal_1')
call s:assert.match(s:hi('LightLineRight_active_2'), 'LightLineRight_normal_2')
call s:assert.match(s:hi('LightLineRight_active_3'), 'E411: highlight group not found')
call s:assert.match(s:hi('LightLineMiddle_active'), 'LightLineMiddle_normal')
call s:assert.match(s:hi('LightlineLeft_active_0'), 'LightlineLeft_normal_0')
call s:assert.match(s:hi('LightlineLeft_active_1'), 'LightlineLeft_normal_1')
call s:assert.match(s:hi('LightlineLeft_active_2'), 'E411: highlight group not found')
call s:assert.match(s:hi('LightlineRight_active_0'), 'LightlineRight_normal_0')
call s:assert.match(s:hi('LightlineRight_active_1'), 'LightlineRight_normal_1')
call s:assert.match(s:hi('LightlineRight_active_2'), 'LightlineRight_normal_2')
call s:assert.match(s:hi('LightlineRight_active_3'), 'E411: highlight group not found')
call s:assert.match(s:hi('LightlineMiddle_active'), 'LightlineMiddle_normal')
endfunction
function! s:suite.insert()
call lightline#link('i')
call s:assert.match(s:hi('LightLineLeft_active_0'), 'LightLineLeft_insert_0')
call s:assert.match(s:hi('LightLineLeft_active_1'), 'LightLineLeft_insert_1')
call s:assert.match(s:hi('LightLineLeft_active_2'), 'E411: highlight group not found')
call s:assert.match(s:hi('LightLineRight_active_0'), 'LightLineRight_insert_0')
call s:assert.match(s:hi('LightLineRight_active_1'), 'LightLineRight_insert_1')
call s:assert.match(s:hi('LightLineRight_active_2'), 'LightLineRight_insert_2')
call s:assert.match(s:hi('LightLineRight_active_3'), 'E411: highlight group not found')
call s:assert.match(s:hi('LightLineMiddle_active'), 'LightLineMiddle_insert')
call s:assert.match(s:hi('LightlineLeft_active_0'), 'LightlineLeft_insert_0')
call s:assert.match(s:hi('LightlineLeft_active_1'), 'LightlineLeft_insert_1')
call s:assert.match(s:hi('LightlineLeft_active_2'), 'E411: highlight group not found')
call s:assert.match(s:hi('LightlineRight_active_0'), 'LightlineRight_insert_0')
call s:assert.match(s:hi('LightlineRight_active_1'), 'LightlineRight_insert_1')
call s:assert.match(s:hi('LightlineRight_active_2'), 'LightlineRight_insert_2')
call s:assert.match(s:hi('LightlineRight_active_3'), 'E411: highlight group not found')
call s:assert.match(s:hi('LightlineMiddle_active'), 'LightlineMiddle_insert')
endfunction
function! s:suite.visual()
call lightline#link('v')
call s:assert.match(s:hi('LightLineLeft_active_0'), 'LightLineLeft_visual_0')
call s:assert.match(s:hi('LightLineLeft_active_1'), 'LightLineLeft_visual_1')
call s:assert.match(s:hi('LightLineLeft_active_2'), 'E411: highlight group not found')
call s:assert.match(s:hi('LightLineRight_active_0'), 'LightLineRight_visual_0')
call s:assert.match(s:hi('LightLineRight_active_1'), 'LightLineRight_visual_1')
call s:assert.match(s:hi('LightLineRight_active_2'), 'LightLineRight_visual_2')
call s:assert.match(s:hi('LightLineRight_active_3'), 'E411: highlight group not found')
call s:assert.match(s:hi('LightLineMiddle_active'), 'LightLineMiddle_visual')
call s:assert.match(s:hi('LightlineLeft_active_0'), 'LightlineLeft_visual_0')
call s:assert.match(s:hi('LightlineLeft_active_1'), 'LightlineLeft_visual_1')
call s:assert.match(s:hi('LightlineLeft_active_2'), 'E411: highlight group not found')
call s:assert.match(s:hi('LightlineRight_active_0'), 'LightlineRight_visual_0')
call s:assert.match(s:hi('LightlineRight_active_1'), 'LightlineRight_visual_1')
call s:assert.match(s:hi('LightlineRight_active_2'), 'LightlineRight_visual_2')
call s:assert.match(s:hi('LightlineRight_active_3'), 'E411: highlight group not found')
call s:assert.match(s:hi('LightlineMiddle_active'), 'LightlineMiddle_visual')
endfunction
function! s:suite.replace()
call lightline#link('R')
call s:assert.match(s:hi('LightLineLeft_active_0'), 'LightLineLeft_replace_0')
call s:assert.match(s:hi('LightLineLeft_active_1'), 'LightLineLeft_replace_1')
call s:assert.match(s:hi('LightLineLeft_active_2'), 'E411: highlight group not found')
call s:assert.match(s:hi('LightLineRight_active_0'), 'LightLineRight_replace_0')
call s:assert.match(s:hi('LightLineRight_active_1'), 'LightLineRight_replace_1')
call s:assert.match(s:hi('LightLineRight_active_2'), 'LightLineRight_replace_2')
call s:assert.match(s:hi('LightLineRight_active_3'), 'E411: highlight group not found')
call s:assert.match(s:hi('LightLineMiddle_active'), 'LightLineMiddle_replace')
call s:assert.match(s:hi('LightlineLeft_active_0'), 'LightlineLeft_replace_0')
call s:assert.match(s:hi('LightlineLeft_active_1'), 'LightlineLeft_replace_1')
call s:assert.match(s:hi('LightlineLeft_active_2'), 'E411: highlight group not found')
call s:assert.match(s:hi('LightlineRight_active_0'), 'LightlineRight_replace_0')
call s:assert.match(s:hi('LightlineRight_active_1'), 'LightlineRight_replace_1')
call s:assert.match(s:hi('LightlineRight_active_2'), 'LightlineRight_replace_2')
call s:assert.match(s:hi('LightlineRight_active_3'), 'E411: highlight group not found')
call s:assert.match(s:hi('LightlineMiddle_active'), 'LightlineMiddle_replace')
endfunction
function! s:suite.left_right()
@ -73,18 +73,18 @@ function! s:suite.left_right()
call lightline#init()
call lightline#colorscheme()
call lightline#link()
call s:assert.match(s:hi('LightLineLeft_active_0'), 'LightLineLeft_normal_0')
call s:assert.match(s:hi('LightLineLeft_active_1'), 'LightLineLeft_normal_1')
call s:assert.match(s:hi('LightLineLeft_active_2'), 'LightLineLeft_normal_2')
call s:assert.match(s:hi('LightLineLeft_active_3'), 'LightLineLeft_normal_3')
call s:assert.match(s:hi('LightLineLeft_active_4'), 'E411: highlight group not found')
call s:assert.match(s:hi('LightLineRight_active_0'), 'LightLineRight_normal_0')
call s:assert.match(s:hi('LightLineRight_active_1'), 'LightLineRight_normal_1')
call s:assert.match(s:hi('LightLineRight_active_2'), 'LightLineRight_normal_2')
call s:assert.match(s:hi('LightLineRight_active_3'), 'LightLineRight_normal_3')
call s:assert.match(s:hi('LightLineRight_active_4'), 'LightLineRight_normal_4')
call s:assert.match(s:hi('LightLineRight_active_5'), 'E411: highlight group not found')
call s:assert.match(s:hi('LightLineMiddle_active'), 'LightLineMiddle_normal')
call s:assert.match(s:hi('LightlineLeft_active_0'), 'LightlineLeft_normal_0')
call s:assert.match(s:hi('LightlineLeft_active_1'), 'LightlineLeft_normal_1')
call s:assert.match(s:hi('LightlineLeft_active_2'), 'LightlineLeft_normal_2')
call s:assert.match(s:hi('LightlineLeft_active_3'), 'LightlineLeft_normal_3')
call s:assert.match(s:hi('LightlineLeft_active_4'), 'E411: highlight group not found')
call s:assert.match(s:hi('LightlineRight_active_0'), 'LightlineRight_normal_0')
call s:assert.match(s:hi('LightlineRight_active_1'), 'LightlineRight_normal_1')
call s:assert.match(s:hi('LightlineRight_active_2'), 'LightlineRight_normal_2')
call s:assert.match(s:hi('LightlineRight_active_3'), 'LightlineRight_normal_3')
call s:assert.match(s:hi('LightlineRight_active_4'), 'LightlineRight_normal_4')
call s:assert.match(s:hi('LightlineRight_active_5'), 'E411: highlight group not found')
call s:assert.match(s:hi('LightlineMiddle_active'), 'LightlineMiddle_normal')
endfunction
function! s:suite.subseparator()
@ -100,9 +100,9 @@ function! s:suite.subseparator()
for i in range(4)
for j in range(5)
if i + 1 == j
call s:assert.match(s:hi(printf('LightLineLeft_active_%s_%s', i, j)), printf('LightLineLeft_normal_%s_%s', i, j))
call s:assert.match(s:hi(printf('LightlineLeft_active_%s_%s', i, j)), printf('LightlineLeft_normal_%s_%s', i, j))
else
call s:assert.match(s:hi(printf('LightLineLeft_active_%s_%s', i, j)), 'E411: highlight group not found')
call s:assert.match(s:hi(printf('LightlineLeft_active_%s_%s', i, j)), 'E411: highlight group not found')
endif
endfor
endfor
@ -114,18 +114,18 @@ function! s:suite.component_type()
call lightline#colorscheme()
call lightline#link()
for type in ['error', 'warning']
call s:assert.match(s:hi(printf('LightLineLeft_active_%s', type)), printf('LightLineLeft_normal_%s', type))
call s:assert.match(s:hi(printf('LightLineLeft_active_0_%s', type)), printf('LightLineLeft_normal_0_%s', type))
call s:assert.match(s:hi(printf('LightLineLeft_active_1_%s', type)), printf('LightLineLeft_normal_1_%s', type))
call s:assert.match(s:hi(printf('LightLineLeft_active_2_%s', type)), 'E411: highlight group not found')
call s:assert.match(s:hi(printf('LightLineLeft_active_%s_0', type)), printf('LightLineLeft_normal_%s_0', type))
call s:assert.match(s:hi(printf('LightLineLeft_active_%s_1', type)), printf('LightLineLeft_normal_%s_1', type))
call s:assert.match(s:hi(printf('LightLineLeft_active_%s_2', type)), printf('LightLineLeft_normal_%s_2', type))
call s:assert.match(s:hi(printf('LightLineLeft_active_%s_3', type)), 'E411: highlight group not found')
call s:assert.match(s:hi(printf('LightlineLeft_active_%s', type)), printf('LightlineLeft_normal_%s', type))
call s:assert.match(s:hi(printf('LightlineLeft_active_0_%s', type)), printf('LightlineLeft_normal_0_%s', type))
call s:assert.match(s:hi(printf('LightlineLeft_active_1_%s', type)), printf('LightlineLeft_normal_1_%s', type))
call s:assert.match(s:hi(printf('LightlineLeft_active_2_%s', type)), 'E411: highlight group not found')
call s:assert.match(s:hi(printf('LightlineLeft_active_%s_0', type)), printf('LightlineLeft_normal_%s_0', type))
call s:assert.match(s:hi(printf('LightlineLeft_active_%s_1', type)), printf('LightlineLeft_normal_%s_1', type))
call s:assert.match(s:hi(printf('LightlineLeft_active_%s_2', type)), printf('LightlineLeft_normal_%s_2', type))
call s:assert.match(s:hi(printf('LightlineLeft_active_%s_3', type)), 'E411: highlight group not found')
endfor
for type1 in ['error', 'warning']
for type2 in ['error', 'warning']
call s:assert.match(s:hi(printf('LightLineLeft_active_%s_%s', type1, type2)), printf('LightLineLeft_normal_%s_%s', type1, type2))
call s:assert.match(s:hi(printf('LightlineLeft_active_%s_%s', type1, type2)), printf('LightlineLeft_normal_%s_%s', type1, type2))
endfor
endfor
endfunction

View File

@ -177,6 +177,111 @@ function! s:suite.subseparator_component_function_7()
delfunction Custom3
endfunction
function! s:suite.subseparator_component_function_visible_condition_1()
function! Custom1()
return 'custom1'
endfunction
function! Custom2()
return 'custom2'
endfunction
function! Custom3()
return 'custom3'
endfunction
let g:lightline = { 'component_function': { 'custom1': 'Custom1', 'custom2': 'Custom2', 'custom3': 'Custom3' }, 'component_function_visible_condition': { 'custom1': '1', 'custom2': '1', 'custom3': '1' } }
call lightline#init()
call s:assert.equals(s:subseparator(['custom1', 'custom2', 'custom3'], '|', [0, 0, 0]), '|')
endfunction
function! s:suite.subseparator_component_function_visible_condition_2()
function! Custom1()
return 'custom1'
endfunction
function! Custom2()
return 'custom2'
endfunction
function! Custom3()
return 'custom3'
endfunction
let g:lightline = { 'component_function': { 'custom1': 'Custom1', 'custom2': 'Custom2', 'custom3': 'Custom3' }, 'component_function_visible_condition': { 'custom1': '0', 'custom2': '1', 'custom3': '1' } }
call lightline#init()
call s:assert.equals(s:subseparator(['custom1', 'custom2', 'custom3'], '|', [0, 0, 0]), '')
endfunction
function! s:suite.subseparator_component_function_visible_condition_3()
function! Custom1()
return 'custom1'
endfunction
function! Custom2()
return 'custom2'
endfunction
function! Custom3()
return 'custom3'
endfunction
let g:lightline = { 'component_function': { 'custom1': 'Custom1', 'custom2': 'Custom2', 'custom3': 'Custom3' }, 'component_function_visible_condition': { 'custom1': '1', 'custom2': '0', 'custom3': '1' } }
call lightline#init()
call s:assert.equals(s:subseparator(['custom1', 'custom2', 'custom3'], '|', [0, 0, 0]), '|')
endfunction
function! s:suite.subseparator_component_function_visible_condition_4()
function! Custom1()
return 'custom1'
endfunction
function! Custom2()
return 'custom2'
endfunction
function! Custom3()
return 'custom3'
endfunction
let g:lightline = { 'component_function': { 'custom1': 'Custom1', 'custom2': 'Custom2', 'custom3': 'Custom3' }, 'component_function_visible_condition': { 'custom1': '1', 'custom2': '0', 'custom3': '0' } }
call lightline#init()
call s:assert.equals(s:subseparator(['custom1', 'custom2', 'custom3'], '|', [0, 0, 0]), '')
endfunction
function! s:suite.subseparator_component_function_visible_condition_5()
function! Custom1()
return 'custom1'
endfunction
function! Custom2()
return ''
endfunction
function! Custom3()
return ''
endfunction
let g:lightline = { 'component_function': { 'custom1': 'Custom1', 'custom2': 'Custom2', 'custom3': 'Custom3' }, 'component_function_visible_condition': { 'custom1': '0' } }
call lightline#init()
call s:assert.equals(s:subseparator(['custom1', 'custom2', 'custom3'], '|', [0, 0, 0]), '')
endfunction
function! s:suite.subseparator_component_function_visible_condition_6()
function! Custom1()
return ''
endfunction
function! Custom2()
return 'custom2'
endfunction
function! Custom3()
return 'custom3'
endfunction
let g:lightline = { 'component_function': { 'custom1': 'Custom1', 'custom2': 'Custom2', 'custom3': 'Custom3' }, 'component_function_visible_condition': { 'custom2': '1', 'custom3': '1' } }
call lightline#init()
call s:assert.equals(s:subseparator(['custom1', 'custom2', 'custom3'], '|', [0, 0, 0]), '')
endfunction
function! s:suite.subseparator_component_function_visible_condition_7()
function! Custom1()
return 'custom1'
endfunction
function! Custom2()
return ''
endfunction
function! Custom3()
return 'custom3'
endfunction
let g:lightline = { 'component_function': { 'custom1': 'Custom1', 'custom2': 'Custom2', 'custom3': 'Custom3' }, 'component_function_visible_condition': { 'custom3': '1' } }
call lightline#init()
call s:assert.equals(s:subseparator(['custom1', 'custom2', 'custom3'], '|', [0, 0, 0]), '|')
endfunction
function! s:suite.subseparator_component_expand()
function! Custom1()
return 'custom1'

View File

@ -1,4 +1,20 @@
Next
- Reuse/reopen existing window trees where possible #244
- Remove NERDTree.previousBuf()
- Change color of arrow (Leeiio) #630
- Improved a tip in README.markdown (ggicci) #628
- Shorten delete confimration of empty directory to 'y' (mikeperri) #530
- Fix API call to open directory tree in window (devm33) #533
- Change default arrows on non-Windows platforms (gwilk) #546
- Update to README - combine cd and git clone (zwhitchcox) #584
- Update to README - Tip: start NERDTree when vim starts (therealplato) #593
- Escape filename when moving an open buffer (zacharyvoase) #595
- Fixed incorrect :helptags command in README (curran) #619
- Fixed incomplete escaping of folder arrows (adityanatraj) #548
- Added NERDTreeCascadeSingleChildDir option (juanibiapina) #558
- Replace strchars() with backward compatible workaround.
- Add support for copy command in Windows (SkylerLipthay) #231
- Fixed typo in README.markdown - :Helptags -> :helptags
- Rename "primary" and "secondary" trees to "tab" and "window" trees.
- Move a bunch of buffer level variables into the NERDTree and UI classes.
- Display cascading dirs on one line to save vertical/horizontal space (@matt-gardner: brainstorming/testing)

View File

@ -57,10 +57,9 @@ Installation
####[pathogen.vim](https://github.com/tpope/vim-pathogen)
cd ~/.vim/bundle
git clone https://github.com/scrooloose/nerdtree.git
git clone https://github.com/scrooloose/nerdtree.git ~/.vim/bundle/nerdtree
Then reload vim, run `:Helptags`, and check out `:help NERD_tree.txt`.
Then reload vim, run `:helptags ~/.vim/bundle/nerdtree/doc/`, and check out `:help NERD_tree.txt`.
####[apt-vim](https://github.com/egalpin/apt-vim)
@ -101,6 +100,14 @@ Stick this in your vimrc:
Note: Now start vim with plain `vim`, not `vim .`
---
> How can I open NERDTree automatically when vim starts up on opening a directory?
autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists("s:std_in") | exe 'NERDTree' argv()[0] | wincmd p | ene | endif
This window is tab-specific, meaning it's used by all windows in the tab. This trick also prevents NERDTree from hiding when first selecting a file.
---
> How can I map a specific key or shortcut to open NERDTree?

View File

@ -13,9 +13,37 @@ endfunction
"FUNCTION: nerdtree#checkForBrowse(dir) {{{2
"inits a window tree in the current buffer if appropriate
function! nerdtree#checkForBrowse(dir)
if a:dir != '' && isdirectory(a:dir)
call g:NERDTreeCreator.CreateWindowTree(a:dir)
if !isdirectory(a:dir)
return
endif
if s:reuseWin(a:dir)
return
endif
call g:NERDTreeCreator.CreateWindowTree(a:dir)
endfunction
"FUNCTION: s:reuseWin(dir) {{{2
"finds a NERDTree buffer with root of dir, and opens it.
function! s:reuseWin(dir) abort
let path = g:NERDTreePath.New(fnamemodify(a:dir, ":p"))
for i in range(1, bufnr("$"))
unlet! nt
let nt = getbufvar(i, "NERDTree")
if empty(nt)
continue
endif
if nt.isWinTree() && nt.root.path.equals(path)
call nt.setPreviousBuf(bufnr("#"))
exec "buffer " . i
return 1
endif
endfor
return 0
endfunction
" FUNCTION: nerdtree#completeBookmarks(A,L,P) {{{2

View File

@ -187,17 +187,17 @@ endfunction
" closes the parent dir of the current node
function! s:closeCurrentDir(node)
let parent = a:node.parent
while g:NERDTreeCascadeOpenSingleChildDir && !parent.isRoot()
let childNodes = parent.getVisibleChildren()
if len(childNodes) == 1 && childNodes[0].path.isDirectory
let parent = parent.parent
else
break
endif
endwhile
if parent ==# {} || parent.isRoot()
call nerdtree#echo("cannot close tree root")
else
while g:NERDTreeCascadeOpenSingleChildDir && !parent.parent.isRoot()
if parent.parent.getVisibleChildCount() == 1
call parent.close()
let parent = parent.parent
else
break
endif
endwhile
call parent.close()
call b:NERDTree.render()
call parent.putCursorHere(0, 0)
@ -280,7 +280,7 @@ function! s:findAndRevealPath()
else
call g:NERDTree.CursorToTreeWin()
endif
call b:NERDTree.setShowHidden(g:NERDTreeShowHidden)
call b:NERDTree.ui.setShowHidden(g:NERDTreeShowHidden)
call s:chRoot(g:NERDTreeDirNode.New(p.getParent(), b:NERDTree))
else
if !g:NERDTree.IsOpen()

View File

@ -671,6 +671,10 @@ NERD tree. These options should be set in your vimrc.
|'NERDTreeMinimalUI'| Disables display of the 'Bookmarks' label and
'Press ? for help' text.
|'NERDTreeCascadeSingleChildDir'|
Collapses on the same line directories that
have only one child directory.
|'NERDTreeCascadeOpenSingleChildDir'|
Cascade open while selected directory has only
one child that also is a directory.
@ -987,7 +991,18 @@ of the following lines to set this option: >
<
------------------------------------------------------------------------------
*'NERDTreeCascadeOpenSingleChildDir'*
*'NERDTreeCascadeSingleChildDir'*
Values: 0 or 1
Default: 1.
When displaying dir nodes, this option tells NERDTree to collapse dirs that
have only one child. Use one of the follow lines to set this option: >
let NERDTreeCascadeSingleChildDir=0
let NERDTreeCascadeSingleChildDir=1
<
------------------------------------------------------------------------------
*'NERDTreeCascadeOpenSingleChildDir'*
Values: 0 or 1
Default: 1.
@ -1001,7 +1016,7 @@ useful for Java projects. Use one of the follow lines to set this option: >
<
------------------------------------------------------------------------------
*'NERDTreeAutoDeleteBuffer'*
*'NERDTreeAutoDeleteBuffer'*
Values: 0 or 1
Default: 0.

View File

@ -186,6 +186,10 @@ function! s:NERDTree.previousBuf()
return self._previousBuf
endfunction
function! s:NERDTree.setPreviousBuf(bnum)
let self._previousBuf = a:bnum
endfunction
"FUNCTION: s:NERDTree.render() {{{1
"A convenience function - since this is called often
function! s:NERDTree.render()

View File

@ -257,7 +257,7 @@ endfunction
function! s:Opener._openDirectory(node)
if self._nerdtree.isWinTree()
call self._gotoTargetWin()
call g:NERDTreeCreator.CreateWindow(a:node.path.str())
call g:NERDTreeCreator.CreateWindowTree(a:node.path.str())
else
call self._gotoTargetWin()
if empty(self._where)

View File

@ -174,11 +174,15 @@ function! s:Path.copy(dest)
call s:Path.createParentDirectories(a:dest)
let dest = s:Path.WinToUnixPath(a:dest)
if exists('g:NERDTreeCopyCmd')
let cmd_prefix = g:NERDTreeCopyCmd
else
let cmd_prefix = (self.isDirectory ? g:NERDTreeCopyDirCmd : g:NERDTreeCopyFileCmd)
endif
let cmd = g:NERDTreeCopyCmd . " " . escape(self.str(), self._escChars()) . " " . escape(dest, self._escChars())
let cmd = cmd_prefix . " " . escape(self.str(), self._escChars()) . " " . escape(a:dest, self._escChars())
let success = system(cmd)
if success != 0
if v:shell_error != 0
throw "NERDTree.CopyError: Could not copy ''". self.str() ."'' to: '" . a:dest . "'"
endif
endfunction
@ -187,7 +191,7 @@ endfunction
"
"returns 1 if copying is supported for this OS
function! s:Path.CopyingSupported()
return exists('g:NERDTreeCopyCmd')
return exists('g:NERDTreeCopyCmd') || (exists('g:NERDTreeCopyDirCmd') && exists('g:NERDTreeCopyFileCmd'))
endfunction
"FUNCTION: Path.copyingWillOverwrite(dest) {{{1
@ -213,7 +217,7 @@ endfunction
"FUNCTION: Path.createParentDirectories(path) {{{1
"
"create parent directories for this path if needed
"without throwing any errors is those directories already exist
"without throwing any errors if those directories already exist
"
"Args:
"path: full path of the node whose parent directories may need to be created
@ -226,8 +230,7 @@ endfunction
"FUNCTION: Path.delete() {{{1
"
"Deletes the file represented by this path.
"Deletion of directories is not supported
"Deletes the file or directory represented by this path.
"
"Throws NERDTree.Path.Deletion exceptions
function! s:Path.delete()

View File

@ -117,28 +117,14 @@ endfunction
"FUNCTION: TreeDirNode.getCascade() {{{1
"Return an array of dir nodes (starting from self) that can be cascade opened.
function! s:TreeDirNode.getCascade()
if !self.isCascadable()
return [self]
endif
let rv = [self]
let node = self
let vc = self.getVisibleChildren()
let visChild = vc[0]
while 1
let vc = node.getVisibleChildren()
if len(vc) != 1
break
endif
let visChild = vc[0]
"TODO: optimize
if !visChild.path.isDirectory
break
endif
call add(rv, visChild)
let node = visChild
endwhile
return rv
return [self] + visChild.getCascade()
endfunction
"FUNCTION: TreeDirNode.getChildCount() {{{1
@ -264,6 +250,10 @@ endfunction
"FUNCTION: TreeDirNode.isCascadable() {{{1
"true if this dir has only one visible child - which is also a dir
function! s:TreeDirNode.isCascadable()
if g:NERDTreeCascadeSingleChildDir == 0
return 0
endif
let c = self.getVisibleChildren()
return len(c) == 1 && c[0].path.isDirectory
endfunction

View File

@ -282,7 +282,8 @@ endfunction
function! s:UI._indentLevelFor(line)
"have to do this work around because match() returns bytes, not chars
let numLeadBytes = match(a:line, '\M\[^ '.g:NERDTreeDirArrowExpandable.g:NERDTreeDirArrowCollapsible.']')
let leadChars = strchars(a:line[0:numLeadBytes-1])
" The next line is a backward-compatible workaround for strchars(a:line(0:numLeadBytes-1]). strchars() is in 7.3+
let leadChars = len(split(a:line[0:numLeadBytes-1], '\zs'))
return leadChars / s:UI.IndentWid()
endfunction

View File

@ -74,7 +74,7 @@ endfunction
function! s:promptToRenameBuffer(bufnum, msg, newFileName)
echo a:msg
if g:NERDTreeAutoDeleteBuffer || nr2char(getchar()) ==# 'y'
let quotedFileName = "'" . a:newFileName . "'"
let quotedFileName = fnameescape(a:newFileName)
" 1. ensure that a new buffer is loaded
exec "badd " . quotedFileName
" 2. ensure that all windows which display the just deleted filename
@ -160,10 +160,10 @@ function! NERDTreeDeleteNode()
let currentNode = g:NERDTreeFileNode.GetSelected()
let confirmed = 0
if currentNode.path.isDirectory
if currentNode.path.isDirectory && currentNode.getChildCount() > 0
let choice =input("Delete the current node\n" .
\ "==========================================================\n" .
\ "STOP! To delete this entire directory, type 'yes'\n" .
\ "STOP! Directory is not empty! To delete, type 'yes'\n" .
\ "" . currentNode.path.str() . ": ")
let confirmed = choice ==# 'yes'
else

View File

@ -75,6 +75,7 @@ else
call s:initVariable("g:NERDTreeDirArrowCollapsible", "~")
endif
call s:initVariable("g:NERDTreeCascadeOpenSingleChildDir", 1)
call s:initVariable("g:NERDTreeCascadeSingleChildDir", 1)
if !exists("g:NERDTreeSortOrder")
let g:NERDTreeSortOrder = ['\/$', '*', '\.swp$', '\.bak$', '\~$']
@ -103,6 +104,8 @@ call s:initVariable("g:NERDTreeWinSize", 31)
"Note: the space after the command is important
if nerdtree#runningWindows()
call s:initVariable("g:NERDTreeRemoveDirCmd", 'rmdir /s /q ')
call s:initVariable("g:NERDTreeCopyDirCmd", 'xcopy /s /e /i /y /q ')
call s:initVariable("g:NERDTreeCopyFileCmd", 'copy /y ')
else
call s:initVariable("g:NERDTreeRemoveDirCmd", 'rm -rf ')
call s:initVariable("g:NERDTreeCopyCmd", 'cp -r ')

View File

@ -25,7 +25,7 @@ syn match NERDTreeDirSlash #/# containedin=NERDTreeDir
exec 'syn match NERDTreeClosable #'.escape(g:NERDTreeDirArrowCollapsible, '~').'# containedin=NERDTreeDir,NERDTreeFile'
exec 'syn match NERDTreeOpenable #'.escape(g:NERDTreeDirArrowExpandable, '~').'# containedin=NERDTreeDir,NERDTreeFile'
let s:dirArrows = escape(g:NERDTreeDirArrowCollapsible, '~').escape(g:NERDTreeDirArrowExpandable, '~')
let s:dirArrows = escape(g:NERDTreeDirArrowCollapsible, '~]\-').escape(g:NERDTreeDirArrowExpandable, '~]\-')
exec 'syn match NERDTreeDir #[^'.s:dirArrows.' ].*/#'
syn match NERDTreeExecFile #^ .*\*\($\| \)# contains=NERDTreeRO,NERDTreeBookmark
exec 'syn match NERDTreeFile #^[^"\.'.s:dirArrows.'] *[^'.s:dirArrows.']*# contains=NERDTreeLink,NERDTreeRO,NERDTreeBookmark,NERDTreeExecFile'
@ -72,8 +72,8 @@ hi def link NERDTreeDir Directory
hi def link NERDTreeUp Directory
hi def link NERDTreeFile Normal
hi def link NERDTreeCWD Statement
hi def link NERDTreeOpenable Title
hi def link NERDTreeClosable Title
hi def link NERDTreeOpenable Directory
hi def link NERDTreeClosable Directory
hi def link NERDTreeIgnore ignore
hi def link NERDTreeRO WarningMsg
hi def link NERDTreeBookmark Statement

View File

@ -11,7 +11,7 @@
## 1. Bug reports / GitHub issues
Please note that the preferred channel for posting bug reports is the
[issue tracker at GitHub][0]. Reports posted elsewhere are less likely
[issue tracker at GitHub][bug_tracker]. Reports posted elsewhere are less likely
to be seen by the core team.
When reporting a bug make sure you search the existing GitHub issues
@ -39,14 +39,14 @@ too:
## 2. Submitting a patch
Before you consider adding features to syntastic, _please_ spend a few minutes
(re-)reading the latest version of the [manual][1]. Syntastic is changing
(re-)reading the latest version of the [manual][manual]. Syntastic is changing
rapidly at times, and it's possible that some features you want to add exist
already.
To submit a patch:
* fork the [repo][2] on GitHub;
* make a [topic branch][3] and start hacking;
* fork the [repo][github] on GitHub;
* make a [topic branch][branches] and start hacking;
* submit a pull request based off your topic branch.
Small, focused patches are preferred.
@ -69,14 +69,14 @@ Follow the coding conventions/styles used in the syntastic core:
* don't use `l:` prefixes for variables unless actually required (i.e.
almost never);
* code for maintainability; we would rather a function be a couple of
lines longer and have (for example) some [explaining variables][4] to
lines longer and have (for example) some [explaining variables][variables] to
aid readability.
<a name="checkerstyle"></a>
## 4. Syntax checker notes
Make sure to read the [guide][5] if you plan to add new syntax checkers.
Make sure to read the [guide][guide] if you plan to add new syntax checkers.
Use the existing checkers as templates, rather than writing everything
from scratch.
@ -97,9 +97,9 @@ let errorformat =
\ '%-G%.%#'
```
[0]: https://github.com/scrooloose/syntastic/issues
[1]: https://github.com/scrooloose/syntastic/blob/master/doc/syntastic.txt
[2]: https://github.com/scrooloose/syntastic
[3]: https://github.com/dchelimsky/rspec/wiki/Topic-Branches#using-topic-branches-when-contributing-patches
[4]: http://www.refactoring.com/catalog/extractVariable.html
[5]: https://github.com/scrooloose/syntastic/wiki/Syntax-Checker-Guide
[bug_tracker]: https://github.com/vim-syntastic/syntastic/issues
[manual]: https://github.com/vim-syntastic/syntastic/blob/master/doc/syntastic.txt
[github]: https://github.com/vim-syntastic/syntastic
[branches]: https://github.com/dchelimsky/rspec/wiki/Topic-Branches#using-topic-branches-when-contributing-patches
[variables]: http://www.refactoring.com/catalog/extractVariable.html
[guide]: https://github.com/vim-syntastic/syntastic/wiki/Syntax-Checker-Guide

View File

@ -25,19 +25,22 @@
3. [Recommended settings](#settings)
4. [FAQ](#faq)
4.1. [I installed syntastic but it isn't reporting any errors...](#faqinfo)
4.2. [The `python` checker complains about syntactically valid Python 3 constructs...](#faqpython3)
4.3. [Are there any local checkers for HTML5 that I can use with syntastic?](#faqhtml5)
4.4. [The `perl` checker has stopped working...](#faqperl)
4.5. [What happened to the `rustc` checker?](#faqrust)
4.6. [What happened to the `xcrun` checker?](#faqxcrun)
4.7. [I run a checker and the location list is not updated...](#faqloclist)
4.7. [I run`:lopen` or `:lwindow` and the error window is empty...](#faqloclist)
4.8. [How can I pass additional arguments to a checker?](#faqargs)
4.9. [Syntastic supports several checkers for my filetype - how do I tell which one(s) to use?](#faqcheckers)
4.2. [Syntastic supports several checkers for my filetype, how do I tell it which one(s) to use?](#faqcheckers)
4.3. [How can I run checkers for "foreign" filetypes against the current file?](#faqforeign)
4.4. [I have enabled multiple checkers for the current filetype. How can I display all errors from all checkers together?](#faqaggregate)
4.5. [How can I pass additional arguments to a checker?](#faqargs)
4.6. [I run a checker and the location list is not updated...](#faqloclist)
4.6. [I run`:lopen` or `:lwindow` and the error window is empty...](#faqloclist)
4.7. [How can I jump between the different errors without using the location list at the bottom of the window?](#faqlnext)
4.8. [The error window is closed automatically when I `:quit` the current buffer but not when I `:bdelete` it?](#faqbdelete)
4.9. [My favourite checker needs to load a configuration file from the project's root rather than the current directory...](#faqconfig)
4.10. [What is the difference between syntax checkers and style checkers?](#faqstyle)
4.11. [I have enabled multiple checkers for the current filetype. How can I display all errors from all checkers together?](#faqaggregate)
4.12. [How can I jump between the different errors without using the location list at the bottom of the window?](#faqlnext)
4.13. [The error window is closed automatically when I :quit the current buffer but not when I :bdelete it?](#faqbdelete)
4.11. [How can I check scripts written for different versions of Python?](#faqpython)
4.12. [How can I check scripts written for different versions of Ruby?](#faqruby)
4.13. [The `perl` checker has stopped working...](#faqperl)
4.14. [What happened to the `rustc` checker?](#faqrust)
4.15. [What happened to the `tsc` checker?](#faqtsc)
4.16. [What happened to the `xcrun` checker?](#faqxcrun)
5. [Resources](#otherresources)
- - -
@ -46,37 +49,39 @@
## 1\. Introduction
Syntastic is a syntax checking plugin for [Vim][13] that runs files through
external syntax checkers and displays any resulting errors to the user. This
can be done on demand, or automatically as files are saved. If syntax errors
are detected, the user is notified and is happy because they didn't have to
compile their code or execute their script to find them.
Syntastic is a syntax checking plugin for [Vim][vim] created by
[Martin Grenfell][scrooloose]. It runs files through external syntax checkers
and displays any resulting errors to the user. This can be done on demand, or
automatically as files are saved. If syntax errors are detected, the user is
notified and is happy because they didn't have to compile their code or execute
their script to find them.
At the time of this writing, syntastic has checking plugins for ActionScript,
Ada, Ansible configurations, API Blueprint, AppleScript, AsciiDoc, ASM,
BEMHTML, Bro, Bourne shell, C, C++, C#, Cabal, Chef, CoffeeScript, Coco,
Coq, CSS, Cucumber, CUDA, D, Dart, DocBook, Dockerfile, Dust, Elixir,
Erlang, eRuby, Fortran, Gentoo metadata, GLSL, Go, Haml, Haskell, Haxe,
Handlebars, HSS, HTML, Java, JavaScript, JSON, JSX, LESS, Lex, Limbo, LISP,
LLVM intermediate language, Lua, Markdown, MATLAB, Mercury, NASM, Nix,
Objective-C, Objective-C++, OCaml, Perl, Perl POD, PHP, gettext Portable
Object, OS X and iOS property lists, Pug (formerly Jade), Puppet, Python, QML,
R, Racket, RDF TriG, RDF Turtle, Relax NG, reStructuredText, RPM spec, Ruby,
SASS/SCSS, Scala, Slim, SML, Sphinx, SQL, Stylus, Tcl, TeX, Texinfo, Twig,
TypeScript, Vala, Verilog, VHDL, VimL, xHtml, XML, XSLT, XQuery, YACC, YAML,
YANG data models, z80, Zope page templates, and zsh. See the [wiki][3] for
details about the corresponding supported checkers.
At the time of this writing, syntastic has checking plugins for ACPI
Source Language, ActionScript, Ada, Ansible configurations, API Blueprint,
AppleScript, AsciiDoc, Assembly languages, BEMHTML, Bro, Bourne shell, C,
C++, C#, Cabal, Chef, CoffeeScript, Coco, Coq, CSS, Cucumber, CUDA, D, Dart,
DocBook, Dockerfile, Dust, Elixir, Erlang, eRuby, Fortran, Gentoo metadata,
GLSL, Go, Haml, Haskell, Haxe, Handlebars, HSS, HTML, Java, JavaScript, JSON,
JSX, LESS, Lex, Limbo, LISP, LLVM intermediate language, Lua, Markdown,
MATLAB, Mercury, NASM, Nix, Objective-C, Objective-C++, OCaml, Perl, Perl
POD, PHP, gettext Portable Object, OS X and iOS property lists, Pug (formerly
Jade), Puppet, Python, QML, R, Racket, RDF TriG, RDF Turtle, Relax NG,
reStructuredText, RPM spec, Ruby, SASS/SCSS, Scala, Slim, SML, Solidity,
Sphinx, SQL, Stylus, Tcl, TeX, Texinfo, Twig, TypeScript, Vala, Verilog, VHDL,
Vim help, VimL, xHtml, XML, XSLT, XQuery, YACC, YAML, YANG data models, z80,
Zope page templates, and Zsh. See the [manual][checkers] for details about the
corresponding supported checkers (`:help syntastic-checkers` in Vim).
A number of third-party Vim plugins also provide checkers for syntastic,
for example: [merlin][30], [omnisharp-vim][25], [rust.vim][12],
[syntastic-extras][26], [syntastic-more][27], [vim-crystal][29],
[vim-eastwood][28], and [vim-swift][24].
A number of third-party Vim plugins also provide checkers for syntastic, for
example: [merlin][merlin], [omnisharp-vim][omnisharp], [rust.vim][rust],
[syntastic-extras][myint], [syntastic-more][roktas], [tsuquyomi][tsuquyomi],
[vim-crystal][crystal], [vim-eastwood][eastwood], and [vim-swift][swift].
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
enabled.
![Screenshot 1][0]
![Screenshot 1][screenshot]
1. Errors are loaded into the location list for the corresponding window.
2. When the cursor is on a line containing an error, the error message is echoed in the command window.
@ -94,7 +99,7 @@ enabled.
### 2.1\. Requirements
Syntastic itself has rather relaxed requirements: it doesn't have any external
dependencies, and it needs a version of [Vim][13] compiled with a few common
dependencies, and it needs a version of [Vim][vim] compiled with a few common
features: `autocmd`, `eval`, `file_in_path`, `modify_fname`, `quickfix`,
`reltime`, and `user_commands`. Not all possible combinations of features that
include the ones above make equal sense on all operating systems, but Vim
@ -102,9 +107,9 @@ version 7 or later with the "normal", "big", or "huge" feature sets should be
fine.
Syntastic should work with any modern plugin managers for Vim, such as
[NeoBundle][14], [Pathogen][1], [Vim-Addon-Manager][15], [Vim-Plug][16], or
[Vundle][17]. Instructions for installing syntastic with [Pathogen][1] are
included below for completeness.
[NeoBundle][neobundle], [Pathogen][pathogen], [Vim-Addon-Manager][vam],
[Vim-Plug][plug], or [Vundle][vundle]. Instructions for installing syntastic
with [Pathogen][pathogen] are included below for completeness.
Starting with Vim version 7.4.1486 you can also load syntastic using the
standard mechanism of packages, without the help of third-party plugin managers
@ -115,20 +120,21 @@ syntastic is present only in versions 7.4.1486 and later.
Last but not least: syntastic doesn't know how to do any syntax checks by
itself. In order to get meaningful results you need to install external
checkers corresponding to the types of files you use. Please consult the
[wiki][3] for a list of supported checkers.
[manual][checkers] (`:help syntastic-checkers` in Vim) for a list of supported
checkers.
<a name="installpathogen"></a>
### 2.2\. Installing syntastic with Pathogen
If you already have [Pathogen][1] working then skip [Step 1](#step1) and go to
If you already have [Pathogen][pathogen] working then skip [Step 1](#step1) and go to
[Step 2](#step2).
<a name="step1"></a>
#### 2.2.1\. Step 1: Install pathogen.vim
First I'll show you how to install Tim Pope's [Pathogen][1] so that it's easy to
First I'll show you how to install Tim Pope's [Pathogen][pathogen] 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
@ -148,14 +154,14 @@ 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
git clone --depth=1 https://github.com/vim-syntastic/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
[Pathogen][pathogen] right. Go back to [Step 1](#step1) and make sure you did the
following:
1. Created both the `~/.vim/autoload` and `~/.vim/bundle` directories.
@ -192,10 +198,11 @@ __4.1. 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
are 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`.
`pylint` to be installed and in your `$PATH`. Read the [manual][checkers]
(`:help syntastic-checkers` in Vim) to find out what executables are
supported. 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`.
A second probable reason is that none of the available checkers are
enabled. Syntastic comes preconfigured with a default list of enabled checkers
@ -222,115 +229,24 @@ on Windows.
Finally, 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 post an [issue][4] - or better yet, create a pull request.
<a name="faqpython3"></a>
__4.2. Q. The `python` checker complains about syntactically valid Python 3 constructs...__
A. Configure the `python` checker to call a Python 3 interpreter rather than
Python 2, e.g:
```vim
let g:syntastic_python_python_exec = '/path/to/python3'
```
<a name="faqhtml5"></a>
__4.3. Q. Are there any local checkers for HTML5 that I can use with syntastic?__
[HTML Tidy][18] has a fork named [HTML Tidy for HTML5][19]. It's a drop
in replacement, and syntastic can use it without changes. Just install it
somewhere and point `g:syntastic_html_tidy_exec` to its executable:
```vim
let g:syntastic_html_tidy_exec = 'tidy5'
```
Alternatively, you can install [vnu.jar][21] from the [validator.nu][20]
project and run it as a [HTTP server][23]:
```sh
$ java -Xss512k -cp /path/to/vnu.jar nu.validator.servlet.Main 8888
```
Then you can [configure][22] syntastic to use it:
```vim
let g:syntastic_html_validator_api = 'http://localhost:8888/'
```
<a name="faqperl"></a>
__4.4. Q. The `perl` checker has stopped working...__
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, make sure the `g:syntastic_perl_checkers` list includes
`perl`, and set `g:syntastic_enable_perl_checker` to 1 in your `vimrc`:
```vim
let g:syntastic_enable_perl_checker = 1
```
<a name="faqrust"></a>
__4.5. Q. What happened to the `rustc` checker?__
A. It is now part of the [rust.vim][12] plugin. If you install this plugin the
checker should be picked up automatically by syntastic.
<a name="faqxcrun"></a>
__4.6. Q. What happened to the `xcrun` checker?__
A. The `xcrun` checker used to have a security problem and it has been removed.
A better checker for __Swift__ is part of the [vim-swift][24] plugin. If you
install this plugin the checker should be picked up automatically by syntastic.
<a name="faqloclist"></a>
__4.7. Q. I run a checker and the location list is not updated...__
__4.7. Q. I run`:lopen` or `:lwindow` and the error window is empty...__
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
```
<a name="faqargs"></a>
__4.8. 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 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"
```
See `:help syntastic-checker-options` for more information.
fails then post an [issue][bug_tracker] - or better yet, create a pull request.
<a name="faqcheckers"></a>
__4.9. Q. Syntastic supports several checkers for my filetype - how do I tell it
__4.2. Q. Syntastic supports several checkers for my filetype, how do I tell it
which one(s) to use?__
A. Stick a line like this in your `vimrc`:
A. Add a line like this to your `vimrc`:
```vim
let g:syntastic_<filetype>_checkers = ['<checker-name>']
```
To see the list of supported checkers for your filetype look at the
[wiki][3].
To see the list of supported checkers for your filetype read the
[manual][checkers] (`:help syntastic-checkers` in Vim).
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:
For example, 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']
```
@ -344,16 +260,131 @@ This is telling syntastic to run the `php` checker first, and if no errors are
found, run `phpcs`, and then `phpmd`.
You can also run checkers explicitly by calling `:SyntasticCheck <checker>`.
e.g. to run `phpcs` and `phpmd`:
For example to run `phpcs` and `phpmd`:
```vim
:SyntasticCheck phpcs phpmd
```
This works for any checkers available for the current filetype, even if they
aren't listed in `g:syntastic_<filetype>_checkers`. You can't run checkers for
"foreign" filetypes though (e.g. you can't run, say, a Python checker if the
filetype of the current file is `php`).
aren't listed in `g:syntastic_<filetype>_checkers`.
<a name="faqforeign"></a>
__4.3. Q. How can I run checkers for "foreign" filetypes against the current
file?__
A. You need to qualify the name of the "foreign" checker with the name
of its filetype. For example to check `tex` files with the checker
`language_check` (which normally acts only on files of type `text`), you can
add `text/language_check` to the list fo checkers for `tex`:
```vim
let g:syntastic_tex_checkers = ['lacheck', 'text/language_check']
```
This also works with `:SyntasticCheck`, e.g. the following command runs
`text/language_check` against the current file regardless of the current
filetype:
```vim
:SyntasticCheck text/language_check
```
Of course, the checkers specified this way need to be known to syntastic, and
they need to be shown as available when you run `:SyntasticInfo`. You can't
just make up a combination of a filetype and a program name and expect it to
work as a checker.
<a name="faqaggregate"></a>
__4.4. Q. I have enabled multiple checkers for the current filetype. How can I
display all errors from all checkers together?__
A. Set `g:syntastic_aggregate_errors` to 1 in your `vimrc`:
```vim
let g:syntastic_aggregate_errors = 1
```
See `:help syntastic-aggregating-errors` for more details.
<a name="faqargs"></a>
__4.5. Q. How can I pass additional arguments to a checker?__
A. In most cases a command line is constructed using an internal function
named `makeprgBuild()`, which provides a number of options that allow you to
customise every part of the command that gets run. You can set these options
using global variables.
The general form of the global `args` variable is
`syntastic_<filetype>_<checker>_args`. Thus 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"
```
See `:help syntastic-checker-options` for more information.
A number of checkers don't use the `makeprgBuild()` function mentioned above,
or have additional options that can be configured. For these checkers the exact
list of options should be included in the [manual][checkers]
(`:help syntastic-checkers` in Vim).
<a name="faqloclist"></a>
__4.6. Q. I run a checker and the location list is not updated...__
__4.6. Q. I run`:lopen` or `:lwindow` and the error window is empty...__
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
```
<a name="faqlnext"></a>
__4.7. Q. How can I jump between the different errors without using the location
list at the bottom of the window?__
A. Vim provides several built-in commands for this. See `:help :lnext` and
`:help :lprevious`.
If you use these commands a lot then you may want to add shortcut mappings to
your `vimrc`, or install something like [unimpaired][unimpaired], which provides such
mappings (among other things).
<a name="faqbdelete"></a>
__4.8. Q. The error window is closed automatically when I `:quit` the current buffer
but not when I `:bdelete` it?__
A. There is no safe way to handle that situation automatically, but you can
work around it:
```vim
nnoremap <silent> <C-d> :lclose<CR>:bdelete<CR>
cabbrev <silent> bd <C-r>=(getcmdtype()==#':' && getcmdpos()==1 ? 'lclose\|bdelete' : 'bd')<CR>
```
<a name="faqconfig"></a>
__4.9. My favourite checker needs to load a configuration file from the
project's root rather than the current directory...__
A. You can set up an `autocmd` to search for the configuration file in the
current directory and upwards, and add it to the checker's options when found.
For example for `jscs`:
```vim
function! FindConfig(prefix, what, where)
let cfg = findfile(a:what, escape(a:where, ' ') . ';')
return cfg !=# '' ? ' ' . a:prefix . ' ' . shellescape(cfg) : ''
endfunction
autocmd FileType javascript let b:syntastic_javascript_jscs_args =
\ get(g:, 'syntastic_javascript_jscs_args', '') .
\ FindConfig('-c', '.jscsrc', expand('<afile>:p:h', 1))
```
<a name="faqstyle"></a>
@ -367,13 +398,13 @@ to syntax, and messages produced by style checkers to be _mostly_ about style.
But there can be no formal guarantee that, say, a style checker that runs into
a syntax error wouldn't die with a fatal message, nor that a syntax checker
wouldn't give you warnings against using some constructs as being bad practice.
There is also no guarantee that messages marked as "style" are less severe than
the ones marked as "syntax" (whatever that might mean). And there are even a
There is also no guarantee that messages marked as `style` are less severe than
the ones marked as `syntax` (whatever that might mean). And there are even a
few Frankenstein checkers (for example `flake8` and `pylama`) that, by their
nature, produce both kinds of messages. Syntastic is not smart enough to be
able to sort out these things by itself.
In fact it's more useful to look at this from the perspective of filtering
Generally it's more useful to look at this from the perspective of filtering
unwanted messages, rather than as an indicator of severity levels. The
distinction between syntax and style is orthogonal to the distinction between
errors and warnings, and thus you can turn off messages based on level, on
@ -383,94 +414,131 @@ e.g. To disable all style messages:
```vim
let g:syntastic_quiet_messages = { "type": "style" }
```
See `:help syntastic_quiet_messages` for details.
See `:help syntastic_quiet_messages` for more information.
<a name="faqaggregate"></a>
<a name="faqpython"></a>
__4.11. Q. I have enabled multiple checkers for the current filetype. How can I
display all errors from all checkers together?__
__4.11. Q. How can I check scripts written for different versions of Python?__
A. Set `g:syntastic_aggregate_errors` to 1 in your `vimrc`:
A. Install a Python version manager such as [virtualenv][virtualenv]
or [pyenv][pyenv], activate the environment for the relevant version
of Python, and install in it the checkers you want to use. Set
`g:syntastic_python_checkers` accordingly in your `vimrc`, and run [Vim][vim]
from the virtual environment.
If you're starting Vim from a desktop manager rather than from a terminal you
might need to write wrapper scripts around your checkers, to activate the
virtual environment before running the actual checks. Then you'll need to
point the relevant `g:syntastic_python_<checker>_exec` variables to the wrapper
scripts.
<a name="faqruby"></a>
__4.12. Q. How can I check scripts written for different versions of Ruby?__
A. Install a Ruby version manager such as [rvm][rvm] or [rbenv][rbenv],
activate the environment for the relevant version of Ruby, and install in it
the checkers you want to use. Set `g:syntastic_ruby_checkers` accordingly in
your `vimrc`, and run [Vim][vim] from the virtual environment.
If you're starting Vim from a desktop manager rather than from a terminal you
might need to write wrapper scripts around your checkers, to activate the
virtual environment before running the actual checks. Then you'll need to
point the relevant `g:syntastic_ruby_<checker>_exec` variables to the wrapper
scripts.
<a name="faqperl"></a>
__4.13. Q. The `perl` checker has stopped working...__
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][perlrun]). 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, make sure the `g:syntastic_perl_checkers` list includes
`perl`, and set `g:syntastic_enable_perl_checker` to 1 in your `vimrc`:
```vim
let g:syntastic_aggregate_errors = 1
let g:syntastic_enable_perl_checker = 1
```
See `:help syntastic-aggregating-errors` for more details.
<a name="faqrust"></a>
<a name="faqlnext"></a>
__4.14. Q. What happened to the `rustc` checker?__
__4.12. Q. How can I jump between the different errors without using the location
list at the bottom of the window?__
A. It is now part of the [rust.vim][rust] plugin. If you install this plugin the
checker should be picked up automatically by syntastic.
A. Vim provides several built-in commands for this. See `:help :lnext` and
`:help :lprevious`.
<a name="faqtsc"></a>
If you use these commands a lot then you may want to add shortcut mappings to
your `vimrc`, or install something like [unimpaired][2], which provides such
mappings (among other things).
__4.15. Q. What happened to the `tsc` checker?__
<a name="faqbdelete"></a>
A. It didn't meet people's expectations and it has been removed. The plugin
[tsuquyomi][tsuquyomi] comes packaged with a checker for TypeScript. If you
install this plugin the checker should be picked up automatically by syntastic.
__4.13. Q. The error window is closed automatically when I :quit the current buffer
but not when I :bdelete it?__
<a name="faqxcrun"></a>
A. There is no safe way to handle that situation automatically, but you can
work around it:
__4.16. Q. What happened to the `xcrun` checker?__
```vim
nnoremap <silent> <C-d> :lclose<CR>:bdelete<CR>
cabbrev <silent> bd <C-r>=(getcmdtype()==#':' && getcmdpos()==1 ? 'lclose\|bdelete' : 'bd')<CR>
```
A. The `xcrun` checker used to have a security problem and it has been removed.
A better checker for __Swift__ is part of the [vim-swift][swift] plugin. If you
install this plugin the checker should be picked up automatically by syntastic.
<a name="otherresources"></a>
## 5\. Resources
The preferred place for posting suggestions, reporting bugs, and general
discussions related to syntastic is the [issue tracker at GitHub][4].
A guide for writing syntax checkers can be found in the [wiki][11].
There are also a dedicated [google group][5], and a
[syntastic tag at StackOverflow][6].
discussions related to syntastic is the [issue tracker at GitHub][bug_tracker].
A guide for writing syntax checkers can be found in the [wiki][guide].
There are also a dedicated [google group][google_group], and a
[syntastic tag at StackOverflow][stack_overflow].
Syntastic aims to provide a common interface to syntax checkers for as many
languages as possible. For particular languages, there are, of course, other
plugins that provide more functionality than syntastic. You might want to take
a look at [ghcmod-vim][31], [jedi-vim][7], [python-mode][8], [vim-go][32], or
[YouCompleteMe][9].
a look at [ghcmod-vim][ghcmod], [jedi-vim][jedi], [python-mode][python_mode], [vim-go][vimgo], or
[YouCompleteMe][ycm].
[0]: https://github.com/scrooloose/syntastic/raw/master/_assets/screenshot_1.png
[1]: https://github.com/tpope/vim-pathogen
[2]: https://github.com/tpope/vim-unimpaired
[3]: https://github.com/scrooloose/syntastic/wiki/Syntax-Checkers
[4]: https://github.com/scrooloose/syntastic/issues
[5]: https://groups.google.com/group/vim-syntastic
[6]: http://stackoverflow.com/questions/tagged/syntastic
[7]: https://github.com/davidhalter/jedi-vim
[8]: https://github.com/klen/python-mode
[9]: http://valloric.github.io/YouCompleteMe/
[10]: http://perldoc.perl.org/perlrun.html#*-c*
[11]: https://github.com/scrooloose/syntastic/wiki/Syntax-Checker-Guide
[12]: https://github.com/rust-lang/rust.vim
[13]: http://www.vim.org/
[14]: https://github.com/Shougo/neobundle.vim
[15]: https://github.com/MarcWeber/vim-addon-manager
[16]: https://github.com/junegunn/vim-plug/
[17]: https://github.com/gmarik/Vundle.vim
[18]: http://tidy.sourceforge.net/
[19]: http://www.htacg.org/tidy-html5/
[20]: http://about.validator.nu/
[21]: https://github.com/validator/validator/releases/latest
[22]: https://github.com/scrooloose/syntastic/wiki/HTML%3A---validator
[23]: http://validator.github.io/validator/#standalone
[24]: https://github.com/kballard/vim-swift
[25]: https://github.com/OmniSharp/omnisharp-vim
[26]: https://github.com/myint/syntastic-extras
[27]: https://github.com/roktas/syntastic-more
[28]: https://github.com/venantius/vim-eastwood
[29]: https://github.com/rhysd/vim-crystal
[30]: https://github.com/the-lambda-church/merlin
[31]: https://github.com/eagletmt/ghcmod-vim
[32]: https://github.com/fatih/vim-go
[scrooloose]: https://github.com/scrooloose
[screenshot]: https://github.com/vim-syntastic/syntastic/raw/master/_assets/screenshot_1.png
[bug_tracker]: https://github.com/vim-syntastic/syntastic/issues
[checkers]: https://github.com/vim-syntastic/syntastic/blob/master/doc/syntastic-checkers.txt
[crystal]: https://github.com/rhysd/vim-crystal
[eastwood]: https://github.com/venantius/vim-eastwood
[ghcmod]: https://github.com/eagletmt/ghcmod-vim
[google_group]: https://groups.google.com/group/vim-syntastic
[guide]: https://github.com/vim-syntastic/syntastic/wiki/Syntax-Checker-Guide
[jedi]: https://github.com/davidhalter/jedi-vim
[merlin]: https://github.com/the-lambda-church/merlin
[myint]: https://github.com/myint/syntastic-extras
[neobundle]: https://github.com/Shougo/neobundle.vim
[omnisharp]: https://github.com/OmniSharp/omnisharp-vim
[pathogen]: https://github.com/tpope/vim-pathogen
[perlrun]: http://perldoc.perl.org/perlrun.html#*-c*
[plug]: https://github.com/junegunn/vim-plug/
[pyenv]: https://github.com/yyuu/pyenv
[python_mode]: https://github.com/klen/python-mode
[rbenv]: https://github.com/rbenv/rbenv
[roktas]: https://github.com/roktas/syntastic-more
[rust]: https://github.com/rust-lang/rust.vim
[rvm]: https://rvm.io/
[stack_overflow]: http://stackoverflow.com/questions/tagged/syntastic
[swift]: https://github.com/kballard/vim-swift
[tsuquyomi]: https://github.com/Quramy/tsuquyomi/
[unimpaired]: https://github.com/tpope/vim-unimpaired
[vam]: https://github.com/MarcWeber/vim-addon-manager
[vim]: http://www.vim.org/
[vimgo]: https://github.com/fatih/vim-go
[virtualenv]: https://virtualenv.pypa.io/en/stable/
[vnu]: http://about.validator.nu/
[vnu_jar]: https://github.com/validator/validator/releases/latest
[vnu_server]: http://validator.github.io/validator/#standalone
[vundle]: https://github.com/gmarik/Vundle.vim
[ycm]: http://valloric.github.io/YouCompleteMe/
<!--
vim:tw=79:sw=4:

View File

@ -21,7 +21,7 @@ function! syntastic#log#warn(msg) abort " {{{2
endfunction " }}}2
function! syntastic#log#error(msg) abort " {{{2
execute "normal \<Esc>"
execute 'normal! \<Esc>'
echohl ErrorMsg
echomsg 'syntastic: error: ' . a:msg
echohl None
@ -68,7 +68,7 @@ function! syntastic#log#debug(level, msg, ...) abort " {{{2
let leader = s:_log_timestamp()
call s:_logRedirect(1)
if a:0 > 0
if a:0
" filter out dictionary functions
echomsg leader . a:msg . ' ' .
\ strtrans(string(type(a:1) == type({}) || type(a:1) == type([]) ?

View File

@ -89,11 +89,11 @@ function! syntastic#preprocess#dockerfile_lint(errors) abort " {{{2
call add(out, msg)
endfor
catch /\m^Vim\%((\a\+)\)\=:E716/
call syntastic#log#warn('checker dockerfile/dockerfile_lint: unrecognized error format')
call syntastic#log#warn('checker dockerfile/dockerfile_lint: unrecognized error format (crashed checker?)')
let out = []
endtry
else
call syntastic#log#warn('checker dockerfile/dockerfile_lint: unrecognized error format')
call syntastic#log#warn('checker dockerfile/dockerfile_lint: unrecognized error format (crashed checker?)')
endif
return out
endfunction " }}}2
@ -132,18 +132,18 @@ function! syntastic#preprocess#flow(errors) abort " {{{2
call add(out, msg)
catch /\m^Vim\%((\a\+)\)\=:E716/
call syntastic#log#warn('checker javascript/flow: unrecognized error format')
call syntastic#log#warn('checker javascript/flow: unrecognized error format (crashed checker?)')
let out = []
break
endtry
else
call syntastic#log#warn('checker javascript/flow: unrecognized error format')
call syntastic#log#warn('checker javascript/flow: unrecognized error format (crashed checker?)')
let out = []
break
endif
endfor
else
call syntastic#log#warn('checker javascript/flow: unrecognized error format')
call syntastic#log#warn('checker javascript/flow: unrecognized error format (crashed checker?)')
endif
return out
@ -178,11 +178,11 @@ function! syntastic#preprocess#jscs(errors) abort " {{{2
endtry
endfor
else
call syntastic#log#warn('checker javascript/jscs: unrecognized error format')
call syntastic#log#warn('checker javascript/jscs: unrecognized error format (crashed checker?)')
endif
endfor
else
call syntastic#log#warn('checker javascript/jscs: unrecognized error format')
call syntastic#log#warn('checker javascript/jscs: unrecognized error format (crashed checker?)')
endif
return out
endfunction " }}}2
@ -238,7 +238,7 @@ function! syntastic#preprocess#prospector(errors) abort " {{{2
endif
endfor
else
call syntastic#log#warn('checker python/prospector: unrecognized error format')
call syntastic#log#warn('checker python/prospector: unrecognized error format (crashed checker?)')
endif
endif
@ -311,11 +311,11 @@ function! syntastic#preprocess#scss_lint(errors) abort " {{{2
endtry
endfor
else
call syntastic#log#warn('checker scss/scss_lint: unrecognized error format')
call syntastic#log#warn('checker scss/scss_lint: unrecognized error format (crashed checker?)')
endif
endfor
else
call syntastic#log#warn('checker scss/scss_lint: unrecognized error format')
call syntastic#log#warn('checker scss/scss_lint: unrecognized error format (crashed checker?)')
endif
return out
endfunction " }}}2
@ -351,12 +351,60 @@ function! syntastic#preprocess#stylelint(errors) abort " {{{2
endtry
endfor
else
call syntastic#log#warn('checker css/stylelint: unrecognized error format')
call syntastic#log#warn('checker css/stylelint: unrecognized error format (crashed checker?)')
endif
endif
return out
endfunction " }}}2
function! syntastic#preprocess#tern_lint(errors) abort " {{{2
let errs = join(a:errors, '')
let json = s:_decode_JSON(errs)
echomsg string(json)
let out = []
if type(json) == type({}) && has_key(json, 'messages') && type(json['messages']) == type([])
for e in json['messages']
try
let line_from = byte2line(e['from'] + 1)
if line_from > 0
let line = line_from
let column = e['from'] - line2byte(line_from) + 2
let line_to = byte2line(e['from'] + 1)
let hl = line_to == line ? e['to'] - line2byte(line_to) + 1 : 0
else
let line = 0
let column = 0
let hl = 0
endif
if column < 0
let column = 0
endif
if hl < 0
let hl = 0
endif
call add(out,
\ e['file'] . ':' .
\ e['severity'][0] . ':' .
\ line . ':' .
\ column . ':' .
\ hl . ':' .
\ e['message'])
catch /\m^Vim\%((\a\+)\)\=:E716/
call syntastic#log#warn('checker javascript/tern_lint: unrecognized error item ' . string(e))
let out = []
endtry
endfor
else
call syntastic#log#warn('checker javascript/tern_lint: unrecognized error format (crashed checker?)')
endif
echomsg string(out)
return out
endfunction " }}}2
function! syntastic#preprocess#tslint(errors) abort " {{{2
return map(copy(a:errors), 'substitute(v:val, ''\m^\(([^)]\+)\)\s\(.\+\)$'', ''\2 \1'', "")')
endfunction " }}}2
@ -405,7 +453,7 @@ function! syntastic#preprocess#vint(errors) abort " {{{2
endif
endfor
else
call syntastic#log#warn('checker vim/vint: unrecognized error format')
call syntastic#log#warn('checker vim/vint: unrecognized error format (crashed checker?)')
endif
return out

View File

@ -37,13 +37,35 @@ function! syntastic#util#system(command) abort " {{{2
let $LC_MESSAGES = 'C'
let $LC_ALL = ''
let out = system(a:command)
let crashed = 0
let cmd_start = reltime()
try
let out = system(a:command)
catch
let crashed = 1
call syntastic#log#error('exception running system(' . string(a:command) . '): ' . v:exception)
if syntastic#util#isRunningWindows()
call syntastic#log#debug(g:_SYNTASTIC_DEBUG_CHECKERS, '$TMP = ' . string($TMP) . ', $TEMP = ' . string($TEMP))
else
call syntastic#log#debug(g:_SYNTASTIC_DEBUG_CHECKERS, '$TERM = ' . string($TERM))
call syntastic#log#debug(g:_SYNTASTIC_DEBUG_CHECKERS, '$TMPDIR = ' . string($TMPDIR))
endif
call syntastic#log#debug(g:_SYNTASTIC_DEBUG_TRACE, '$PATH = ' . string($PATH))
call syntastic#log#debug(g:_SYNTASTIC_DEBUG_TRACE, 'getcwd() = ' . string(getcwd()))
call syntastic#log#debugShowOptions(g:_SYNTASTIC_DEBUG_TRACE, g:_SYNTASTIC_SHELL_OPTIONS)
let out = ''
endtry
let cmd_time = split(reltimestr(reltime(cmd_start)))[0]
let $LC_ALL = old_lc_all
let $LC_MESSAGES = old_lc_messages
let &shell = old_shell
if !crashed && exists('g:_SYNTASTIC_DEBUG_TRACE')
call syntastic#log#debug(g:_SYNTASTIC_DEBUG_TRACE, 'system: command run in ' . cmd_time . 's')
endif
return out
endfunction " }}}2
@ -96,6 +118,10 @@ function! syntastic#util#rmrf(what) abort " {{{2
endif
endfunction " }}}2
function! syntastic#util#getbufvar(buf, name, ...) abort " {{{2
return a:0 ? s:_getbufvar(a:buf, a:name, a:1) : getbufvar(a:buf, a:name)
endfunction " }}}2
" Search the first 5 lines of the file for a magic number and return a map
" containing the args and the executable
"
@ -120,9 +146,19 @@ function! syntastic#util#parseShebang() abort " {{{2
return { 'exe': '', 'args': [] }
endfunction " }}}2
" Get the value of a Vim variable. Allow buffer variables to override global ones.
function! syntastic#util#bufRawVar(buf, name, ...) abort " {{{2
return s:_getbufvar(a:buf, a:name, get(g:, a:name, a:0 ? a:1 : ''))
endfunction "}}}2
" Get the value of a syntastic variable. Allow buffer variables to override global ones.
function! syntastic#util#bufVar(buf, name, ...) abort " {{{2
return call('syntastic#util#bufRawVar', [a:buf, 'syntastic_' . a:name] + a:000)
endfunction "}}}2
" Get the value of a Vim variable. Allow local variables to override global ones.
function! syntastic#util#rawVar(name, ...) abort " {{{2
return get(b:, a:name, get(g:, a:name, a:0 > 0 ? a:1 : ''))
return get(b:, a:name, get(g:, a:name, a:0 ? a:1 : ''))
endfunction " }}}2
" Get the value of a syntastic variable. Allow local variables to override global ones.
@ -159,11 +195,6 @@ function! syntastic#util#compareLexi(a, b) abort " {{{2
return 0
endfunction " }}}2
" strwidth() was added in Vim 7.3; if it doesn't exist, we use strlen()
" and hope for the best :)
let s:_width = function(exists('*strwidth') ? 'strwidth' : 'strlen')
lockvar s:_width
function! syntastic#util#screenWidth(str, tabstop) abort " {{{2
let chunks = split(a:str, "\t", 1)
let width = s:_width(chunks[-1])
@ -265,6 +296,36 @@ function! syntastic#util#findGlobInParent(what, where) abort " {{{2
return ''
endfunction " }}}2
" Returns the buffer number of a filename
" @vimlint(EVL104, 1, l:old_shellslash)
function! syntastic#util#fname2buf(fname) abort " {{{2
if exists('+shellslash')
" bufnr() can't cope with backslashes
let old_shellslash = &shellslash
let &shellslash = 1
endif
" this is a best-effort attempt to escape file patterns (cf. :h file-pattern)
" XXX it fails for filenames containing something like \{2,3}
for md in [':~:.', ':~', ':p']
let buf = bufnr('^' . escape(fnamemodify(a:fname, md), '\*?,{}[') . '$')
if buf != -1
break
endif
endfor
if buf == -1
" XXX definitely wrong, but hope is the last thing to die :)
let buf = bufnr(fnamemodify(a:fname, ':p'))
endif
if exists('+shellslash')
let &shellslash = old_shellslash
endif
return buf
endfunction " }}}2
" @vimlint(EVL104, 0, l:old_shellslash)
" Returns unique elements in a list
function! syntastic#util#unique(list) abort " {{{2
let seen = {}
@ -336,10 +397,8 @@ function! syntastic#util#stamp() abort " {{{2
return split( split(reltimestr(reltime(g:_SYNTASTIC_START)))[0], '\.' )
endfunction " }}}2
function! syntastic#util#setChangedtick() abort " {{{2
unlockvar! b:syntastic_changedtick
let b:syntastic_changedtick = b:changedtick
lockvar! b:syntastic_changedtick
function! syntastic#util#setLastTick(buf) abort " {{{2
call setbufvar(a:buf, 'syntastic_lasttick', getbufvar(a:buf, 'changedtick'))
endfunction " }}}2
let s:_wid_base = 'syntastic_' . getpid() . '_' . reltimestr(g:_SYNTASTIC_START) . '_'
@ -357,9 +416,6 @@ function! syntastic#util#setWids() abort " {{{2
endfor
endfunction " }}}2
let s:_str2float = function(exists('*str2float') ? 'str2float' : 'str2nr')
lockvar s:_str2float
function! syntastic#util#str2float(val) abort " {{{2
return s:_str2float(a:val)
endfunction " }}}2
@ -481,6 +537,11 @@ function! s:_translateElement(key, term) abort " {{{2
return ret
endfunction " }}}2
" strwidth() was added in Vim 7.3; if it doesn't exist, we use strlen()
" and hope for the best :)
let s:_width = function(exists('*strwidth') ? 'strwidth' : 'strlen')
lockvar s:_width
" @vimlint(EVL103, 1, a:flags)
function! s:_delete_dumb(what, flags) abort " {{{2
if !exists('s:rmrf')
@ -527,6 +588,9 @@ function! s:_rmrf(what) abort " {{{2
endif
endfunction " }}}2
let s:_str2float = function(exists('*str2float') ? 'str2float' : 'str2nr')
lockvar s:_str2float
function! s:_float2str_smart(val) abort " {{{2
return printf('%.1f', a:val)
endfunction " }}}2
@ -538,6 +602,18 @@ endfunction " }}}2
let s:_float2str = function(has('float') ? 's:_float2str_smart' : 's:_float2str_dumb')
lockvar s:_float2str
function! s:_getbufvar_dumb(buf, name, ...) abort " {{{2
let ret = getbufvar(a:buf, a:name)
if a:0 && type(ret) == type('') && ret ==# ''
unlet! ret
let ret = a:1
endif
return ret
endfunction "}}}2
let s:_getbufvar = function(v:version > 703 || (v:version == 703 && has('patch831')) ? 'getbufvar' : 's:_getbufvar_dumb')
lockvar s:_getbufvar
" }}}1
let &cpo = s:save_cpo

File diff suppressed because it is too large Load Diff

View File

@ -44,20 +44,24 @@ CONTENTS *syntastic-contents*
6.2.Editing files over network.............|syntastic-netrw|
6.3.The 'shellslash' option................|syntastic-shellslash|
6.4.Saving Vim sessions....................|syntastic-sessions|
6.5.The location list callback.............|syntastic-loclist-callback|
7.Compatibility with other software............|syntastic-compatibility|
7.1.The csh and tcsh shells................|syntastic-csh|
7.2.Eclim..................................|syntastic-eclim|
7.3.The fish shell.........................|syntastic-fish|
7.4.The fizsh shell........................|syntastic-fizsh|
7.5.flagship...............................|syntastic-flagship|
7.6.powerline..............................|syntastic-powerline|
7.7.The PowerShell shell...................|syntastic-powershell|
7.8.python-mode............................|syntastic-pymode|
7.9.vim-auto-save..........................|syntastic-vim-auto-save|
7.10.vim-go................................|syntastic-vim-go|
7.11.vim-virtualenv........................|syntastic-vim-virtualenv|
7.12.YouCompleteMe.........................|syntastic-ycm|
7.13.The zsh shell and MacVim..............|syntastic-zsh|
7.1.airline................................|syntastic-airline|
7.2.The csh and tcsh shells................|syntastic-csh|
7.3.EasyGrep...............................|syntastic-easygrep|
7.4.Eclim..................................|syntastic-eclim|
7.5.ferret.................................|syntastic-ferret|
7.6.The fish shell.........................|syntastic-fish|
7.7.The fizsh shell........................|syntastic-fizsh|
7.8.flagship...............................|syntastic-flagship|
7.9.powerline..............................|syntastic-powerline|
7.10.The PowerShell shell..................|syntastic-powershell|
7.11.python-mode...........................|syntastic-pymode|
7.12.vim-auto-save.........................|syntastic-vim-auto-save|
7.13.vim-go................................|syntastic-vim-go|
7.14.vim-virtualenv........................|syntastic-vim-virtualenv|
7.15.YouCompleteMe.........................|syntastic-ycm|
7.16.The zsh shell and MacVim..............|syntastic-zsh|
8.About........................................|syntastic-about|
9.License......................................|syntastic-license|
@ -76,14 +80,12 @@ syntax checker plugins are defined on a per-filetype basis where each one wraps
up an external syntax checking program. The core script delegates off to these
plugins and uses their output to provide the syntastic functionality.
Take a look at the wiki for a list of supported filetypes and checkers:
https://github.com/scrooloose/syntastic/wiki/Syntax-Checkers
Take a look at the list of supported filetypes and checkers: |syntastic-checkers|.
Note: This doc only deals with using syntastic. To learn how to write syntax
checker integrations, see the guide on the GitHub wiki:
https://github.com/scrooloose/syntastic/wiki/Syntax-Checker-Guide
https://github.com/vim-syntastic/syntastic/wiki/Syntax-Checker-Guide
------------------------------------------------------------------------------
1.1. Quick start *syntastic-quickstart*
@ -159,12 +161,17 @@ Something like this could be more useful: >
set statusline+=%*
<
When syntax errors are detected a flag will be shown. The content of the flag
is derived from the |syntastic_stl_format| option.
is derived from the |'syntastic_stl_format'| option.
Please note that these settings might conflict with other Vim plugins that
change the way statusline works. Refer to these plugins' documentation for
possible solutions. See also |syntastic-powerline| below if you're using the
"powerline" Vim plugin (https://github.com/powerline/powerline).
change the way statusline works. Refer to the |syntastic-compatibility| notes
below and to the respective plugins' documentation for possible solutions.
In particular see |syntastic-airline| below if you're using the "airline" Vim
plugin (https://github.com/vim-airline/vim-airline). See |syntastic-flagship|
if you're using "flagship" (https://github.com/tpope/vim-flagship). See also
|syntastic-powerline| if you're using the "powerline" Vim plugin
(https://github.com/powerline/powerline).
------------------------------------------------------------------------------
2.2. Error signs *syntastic-error-signs*
@ -196,6 +203,10 @@ following highlight groups:
Example: >
highlight SyntasticErrorLine guibg=#2f0000
<
With Vim 8.0 or later you can ask Vim not to turn off the sign column when no
errors are found, by setting 'signcolumn' to "yes": >
set signcolumn=yes
<
------------------------------------------------------------------------------
2.3. The error window *syntastic-error-window*
@ -249,7 +260,7 @@ grouped together, and sorting within each group is decided by the variables
|'syntastic_<filetype>_<checker>_sort'|.
------------------------------------------------------------------------------
2.6 Filtering errors *syntastic-filtering-errors*
2.6. Filtering errors *syntastic-filtering-errors*
You can selectively disable some of the errors found by checkers either
using |'syntastic_quiet_messages'|, or by specifying a list of patterns in
@ -291,12 +302,22 @@ the order specified. The set by |'syntastic_aggregate_errors'| still apply.
Example: >
:SyntasticCheck flake8 pylint
<
You can also run checkers for filetypes different from the current filetype
by qualifying their names with their respective filetypes, like this:
"<filetype>/<checker>".
Example: >
:SyntasticCheck lacheck text/language_check
<
:SyntasticInfo *:SyntasticInfo*
The command takes an optional argument, and outputs information about the
checkers available for the filetype named by said argument, or for the current
filetype if no argument was provided.
Example: >
:SyntasticInfo python
<
:SyntasticReset *:SyntasticReset*
Resets the list of errors and turns off all error notifiers.
@ -563,7 +584,7 @@ option should be set to something like: >
\ "file:p": ['\m^/usr/include/', '\m\c\.h$'] }
<
Each element turns off messages matching the patterns specified by the
corresponding value. Values are lists, but if a list consist of a single
corresponding value. Values are lists, but if a list consists of a single
element you may omit the brackets (e.g. you may write "style" instead of
["style"]). Elements with values [] or "" are ignored (this is useful for
overriding filters, cf. |filter-overrides|).
@ -733,7 +754,7 @@ filetypes.
5. Checker Options *syntastic-checker-options*
------------------------------------------------------------------------------
5.1 Choosing which checkers to use *syntastic-filetype-checkers*
5.1. Choosing which checkers to use *syntastic-filetype-checkers*
*'g:syntastic_<filetype>_checkers'*
You can tell syntastic which checkers to run for a given filetype by setting a
@ -751,15 +772,17 @@ If neither |'g:syntastic_<filetype>_checkers'| nor |'b:syntastic_checkers'|
is set, a default list of checker is used. Beware however that this list
deliberately kept minimal, for performance reasons.
Take a look at the wiki to find out what checkers and filetypes are supported
by syntastic:
https://github.com/scrooloose/syntastic/wiki/Syntax-Checkers
You can specify checkers for other filetypes anywhere in these lists, by
qualifying their names with their respective filetypes: >
let g:syntastic_tex_checkers = ["lacheck", "text/language_check"]
<
Take a look elsewhere in this manual to find out what checkers and filetypes
are supported by syntastic: |syntastic-checkers|.
Use `:SyntasticInfo` to see which checkers are available for a given filetype.
------------------------------------------------------------------------------
5.2 Choosing the executable *syntastic-config-exec*
5.2. Choosing the executable *syntastic-config-exec*
*'syntastic_<filetype>_<checker>_exec'*
The executable run by a checker is normally defined automatically, when the
@ -776,7 +799,7 @@ takes precedence over both 'b:syntastic_<filetype>_<checker>_exec' and
'g:syntastic_<filetype>_<checker>_exec' in the buffers where it is defined.
------------------------------------------------------------------------------
5.3 Configuring specific checkers *syntastic-config-makeprg*
5.3. Configuring specific checkers *syntastic-config-makeprg*
Checkers are run by constructing a command line and by passing it to a shell
(see |'shell'| and |'syntastic_shell'|). In most cases this command line is
@ -800,7 +823,7 @@ The result is a command line of the form: >
All fields above are optional, and can be overridden by setting global
variables 'g:syntastic_<filetype>_<checker-name>_<option-name>' - even
parameters not specified in the call to "makeprgBuild()". For example to
override the argguments and the tail: >
override the arguments and the tail: >
let g:syntastic_c_pc_lint_args = "-w5 -Iz:/usr/include/linux"
let g:syntastic_c_pc_lint_tail = "2>/dev/null"
<
@ -846,14 +869,12 @@ omitting the filename from the command line: >
let g:syntastic_sml_smlnj_fname = ""
<
*syntastic-config-no-makeprgbuild*
For checkers that do not use the "makeprgBuild()" function you will have to
look at the source code of the checker in question. If there are specific
options that can be set, they are normally documented in the wiki:
https://github.com/scrooloose/syntastic/wiki/Syntax-Checkers
For checkers that do not use the "makeprgBuild()" function any specific
options that can be set should be documented in this manual (see
|syntastic-checkers|).
------------------------------------------------------------------------------
5.4 Sorting errors *syntastic-config-sort*
5.4. Sorting errors *syntastic-config-sort*
*'syntastic_<filetype>_<checker>_sort'*
Syntastic may decide to group the errors produced by some checkers by file,
@ -872,7 +893,7 @@ For aggregated lists (see |syntastic-aggregating-errors|) these variables are
ignored if |'syntastic_sort_aggregated_errors'| is set (which is the default).
------------------------------------------------------------------------------
5.5 Filtering errors *syntastic-config-filtering*
5.5. Filtering errors *syntastic-config-filtering*
*'syntastic_<filetype>_<checker>_quiet_messages'*
Finally, variables 'g:syntastic_<filetype>_<checker-name>_quiet_messages' can
@ -886,7 +907,8 @@ from the corresponding checkers are filtered. Example: >
The syntax is of course identical to that of |syntastic_quiet_messages|.
------------------------------------------------------------------------------
5.6 Debugging *syntastic-config-debug*
5.6. Debugging *syntastic-config-debug*
*syntastic-debug*
Syntastic can log a trace of its working to Vim's |message-history|. To verify
the command line constructed by syntastic to run a checker, set the variable
@ -905,7 +927,7 @@ Debug logs can be saved to a file; see |'syntastic_debug_file'| for details.
Setting |'syntastic_debug'| to 0 turns off logging.
------------------------------------------------------------------------------
5.7 Profiling *syntastic-profiling*
5.7. Profiling *syntastic-profiling*
A very useful tool for debugging performance problems is Vim's built-in
|profiler|. In order to enable profiling for syntastic you need to add two lines
@ -935,7 +957,7 @@ composite filetypes to simple ones using |'syntastic_filetype_map'|, e.g.: >
let g:syntastic_filetype_map = { "handlebars.html": "handlebars" }
<
------------------------------------------------------------------------------
6.2 Editing files over network *syntastic-netrw*
6.2. Editing files over network *syntastic-netrw*
The standard plugin |netrw| allows Vim to transparently edit files over
network and inside archives. Currently syntastic doesn't support this mode
@ -943,7 +965,7 @@ of operation. It can only check files that can be accessed directly by local
checkers, without any translation or conversion.
------------------------------------------------------------------------------
6.3 The 'shellslash' option *syntastic-shellslash*
6.3. The 'shellslash' option *syntastic-shellslash*
The 'shellslash' option is relevant only on Windows systems. This option
determines (among other things) the rules for quoting command lines, and there
@ -954,7 +976,7 @@ shell. It should be turned off if your 'shell' (or |'syntastic_shell'|) is
value.
------------------------------------------------------------------------------
6.4 Saving Vim sessions *syntastic-sessions*
6.4. Saving Vim sessions *syntastic-sessions*
If you use `:mksession` to save Vim sessions you should probably make sure to
remove option "blank" from 'sessionoptions': >
@ -963,11 +985,44 @@ remove option "blank" from 'sessionoptions': >
This will prevent `:mksession` from saving |syntastic-error-window| as empty
quickfix windows.
------------------------------------------------------------------------------
6.5. The location list callback *syntastic-loclist-callback*
*SyntasticCheckHook()*
Syntastic also gives you direct access to the list of errors. A function
named |SyntasticCheckHook()| is called by syntastic (if it exists) right
before populating the |location-list| and enabling the notifiers. The function
takes exactly one argument, the list of errors in |location-list| format (see
|getqflist()| for details). format. You can do essentially anything with this
list, as long as you don't change its format, and you don't add or remove
elements.
For example the following function will make the error window smaller if fewer
than 10 errors are found: >
function! SyntasticCheckHook(errors)
if !empty(a:errors)
let g:syntastic_loc_list_height = min([len(a:errors), 10])
endif
endfunction
<
(Please keep in mind however that Vim options |winheight| and |winminheight|
also affect window sizes.)
==============================================================================
7. Compatibility with other software *syntastic-compatibility*
------------------------------------------------------------------------------
7.1 The csh and tcsh shells *syntastic-csh*
7.1. airline *syntastic-airline*
The "airline" Vim plugin (https://github.com/vim-airline/vim-airline) comes
packaged with a mechanism of showing flags on the |'statusline'| according
to your |'syntastic_stl_format'|. When using this plugin you do NOT need to
follow the recommendation outlined in the |syntastic-statusline-flag| section
above to modify your |'statusline'|; "airline" will make all necessary changes
automatically.
------------------------------------------------------------------------------
7.2. The csh and tcsh shells *syntastic-csh*
The "csh" and "tcsh" shells are mostly compatible with syntastic. However,
some checkers assume Bourne shell syntax for redirecting "stderr". For this
@ -976,7 +1031,16 @@ such as "zsh", "bash", "ksh", or even the original Bourne "sh": >
let g:syntastic_shell = "/bin/sh"
<
------------------------------------------------------------------------------
7.2. Eclim *syntastic-eclim*
7.3. EasyGrep *syntastic-easygrep*
The "EasyGrep" Vim plugin (https://github.com/dkprice/vim-easygrep) can use
either |quickfix| lists, or location lists (see |location-list|). Syntastic can
be run along with "EasyGrep" provided that the latter is configured to use
|quickfix| lists (which is the default at the time of this writing): >
let g:EasyGrepWindow = 0
<
------------------------------------------------------------------------------
7.4. Eclim *syntastic-eclim*
Syntastic can be used together with "Eclim" (see http://eclim.org/). However,
by default Eclim disables syntastic's checks for the filetypes it supports, in
@ -989,7 +1053,15 @@ run Eclim's validation for others. Please consult Eclim's documentation for
details.
------------------------------------------------------------------------------
7.3 The fish shell *syntastic-fish*
7.5. ferret *syntastic-ferret*
At the time of this writing syntastic conflicts with the "ferret" Vim plugin
(https://github.com/wincent/ferret). The "ferret" plugin assumes control over
loclist windows even when configured to use |quickfix| lists. This interferes
with syntastic's functioning.
------------------------------------------------------------------------------
7.6. The fish shell *syntastic-fish*
At the time of this writing the "fish" shell (see http://fishshell.com/)
doesn't support the standard UNIX syntax for file redirections, and thus it
@ -999,7 +1071,7 @@ original Bourne "sh": >
let g:syntastic_shell = "/bin/sh"
<
------------------------------------------------------------------------------
7.4. The fizsh shell *syntastic-fizsh*
7.7. The fizsh shell *syntastic-fizsh*
Using syntastic with the "fizsh" shell (see https://github.com/zsh-users/fizsh)
is possible, but potentially problematic. In order to do it you'll need to set
@ -1012,7 +1084,7 @@ interactive features of "fizsh". Using a more traditional shell such as "zsh",
let g:syntastic_shell = "/bin/sh"
<
------------------------------------------------------------------------------
7.5 flagship *syntastic-flagship*
7.8. flagship *syntastic-flagship*
The "flagship" Vim plugin (https://github.com/tpope/vim-flagship) has its
own mechanism of showing flags on the |'statusline'|. To allow "flagship"
@ -1022,7 +1094,7 @@ described in the |syntastic-statusline-flag| section above: >
autocmd User Flags call Hoist("window", "SyntasticStatuslineFlag")
<
------------------------------------------------------------------------------
7.6. powerline *syntastic-powerline*
7.9. powerline *syntastic-powerline*
The "powerline" Vim plugin (https://github.com/powerline/powerline) comes
packaged with a syntastic segment. To customize this segment create a file
@ -1039,16 +1111,18 @@ packaged with a syntastic segment. To customize this segment create a file
}
<
------------------------------------------------------------------------------
7.7. The PowerShell shell *syntastic-powershell*
7.10. The PowerShell shell *syntastic-powershell*
At the time of this writing, syntastic is not compatible with using "Windows
PowerShell" (http://technet.microsoft.com/en-us/library/bb978526.aspx) as Vim's
'shell'. You may still run Vim from 'PowerShell', but you do have to point
Vim's 'shell' to a more traditional program, such as "cmd.exe": >
set shell=cmd.exe
At the time of this writing syntastic is not compatible with using
"PowerShell" (https://msdn.microsoft.com/en-us/powershell) as Vim's 'shell'.
You may still run Vim from "PowerShell", but you do have to point Vim's
'shell' to a more traditional program, such as "cmd.exe" on Windows, or
"/bin/sh" on UNIX: >
set shell=c:\Windows\system32\cmd.exe
set shell=/bin/sh
<
------------------------------------------------------------------------------
7.8 python-mode *syntastic-pymode*
7.11. python-mode *syntastic-pymode*
Syntastic can be used along with the "python-mode" Vim plugin (see
https://github.com/klen/python-mode). However, they both run syntax checks by
@ -1059,14 +1133,14 @@ for python in syntastic (see |'syntastic_mode_map'|), or disable lint checks in
let g:pymode_lint_on_write = 0
<
------------------------------------------------------------------------------
7.9. vim-auto-save *syntastic-vim-auto-save*
7.12. vim-auto-save *syntastic-vim-auto-save*
Syntastic can be used together with the "vim-auto-save" Vim plugin (see
https://github.com/907th/vim-auto-save). However, syntastic checks in active
mode only work with "vim-auto-save" version 0.1.7 or later.
------------------------------------------------------------------------------
7.10. vim-go *syntastic-vim-go*
7.13. vim-go *syntastic-vim-go*
Syntastic can be used along with the "vim-go" Vim plugin (see
https://github.com/fatih/vim-go). However, both "vim-go" and syntastic run
@ -1083,7 +1157,7 @@ stick with |quickfix| lists: >
let g:go_list_type = "quickfix"
<
------------------------------------------------------------------------------
7.11. vim-virtualenv *syntastic-vim-virtualenv*
7.14. vim-virtualenv *syntastic-vim-virtualenv*
At the time of this writing, syntastic can't run checkers installed
in Python virtual environments activated by "vim-virtualenv" (see
@ -1091,7 +1165,7 @@ https://github.com/jmcantrell/vim-virtualenv). This is a limitation of
"vim-virtualenv".
------------------------------------------------------------------------------
7.12 YouCompleteMe *syntastic-ycm*
7.15. YouCompleteMe *syntastic-ycm*
Syntastic can be used together with the "YouCompleteMe" Vim plugin (see
http://valloric.github.io/YouCompleteMe/). However, by default "YouCompleteMe"
@ -1102,7 +1176,7 @@ have to set |g:ycm_show_diagnostics_ui| to 0. E.g.: >
let g:ycm_show_diagnostics_ui = 0
<
------------------------------------------------------------------------------
7.13 The zsh shell and MacVim *syntastic-zsh*
7.16. The zsh shell and MacVim *syntastic-zsh*
If you're running MacVim together with the "zsh" shell (http://www.zsh.org/)
you need to be aware that MacVim does not source your .zshrc file, but will
@ -1122,7 +1196,7 @@ The core maintainers of syntastic are:
Find the latest version of syntastic at:
http://github.com/scrooloose/syntastic
http://github.com/vim-syntastic/syntastic
==============================================================================
9. License *syntastic-license*

View File

@ -19,7 +19,7 @@ if has('reltime')
lockvar! g:_SYNTASTIC_START
endif
let g:_SYNTASTIC_VERSION = '3.7.0-137'
let g:_SYNTASTIC_VERSION = '3.8.0-10'
lockvar g:_SYNTASTIC_VERSION
" Sanity checks {{{1
@ -57,7 +57,7 @@ elseif executable('uname')
try
let g:_SYNTASTIC_UNAME = split(syntastic#util#system('uname'), "\n")[0]
catch /\m^Vim\%((\a\+)\)\=:E484/
call syntastic#log#error("your shell " . syntastic#util#var('shell') . " can't handle traditional UNIX syntax for redirections")
call syntastic#log#error("can't run external programs (misconfigured shell options?)")
finish
catch /\m^Vim\%((\a\+)\)\=:E684/
let g:_SYNTASTIC_UNAME = 'Unknown'
@ -126,20 +126,26 @@ endif
" Debug {{{1
let s:_DEBUG_DUMP_OPTIONS = [
let g:_SYNTASTIC_SHELL_OPTIONS = [
\ 'shell',
\ 'shellcmdflag',
\ 'shellpipe',
\ 'shellquote',
\ 'shellredir',
\ 'shellslash',
\ 'shelltemp',
\ 'shellxquote'
\ ]
if exists('+shellxescape')
call add(s:_DEBUG_DUMP_OPTIONS, 'shellxescape')
endif
lockvar! s:_DEBUG_DUMP_OPTIONS
for s:feature in [
\ 'autochdir',
\ 'shellslash',
\ 'shellxescape',
\ ]
if exists('+' . s:feature)
call add(g:_SYNTASTIC_SHELL_OPTIONS, s:feature)
endif
endfor
lockvar! g:_SYNTASTIC_SHELL_OPTIONS
" debug constants
let g:_SYNTASTIC_DEBUG_TRACE = 1
@ -163,6 +169,7 @@ let s:registry = g:SyntasticRegistry.Instance()
let s:notifiers = g:SyntasticNotifiers.Instance()
let s:modemap = g:SyntasticModeMap.Instance()
let s:_check_stack = []
let s:_quit_pre = []
" Commands {{{1
@ -171,11 +178,20 @@ let s:_quit_pre = []
" @vimlint(EVL103, 1, a:cmdLine)
" @vimlint(EVL103, 1, a:argLead)
function! s:CompleteCheckerName(argLead, cmdLine, cursorPos) abort " {{{2
let checker_names = []
for ft in s:_resolve_filetypes([])
call extend(checker_names, s:registry.getNamesOfAvailableCheckers(ft))
endfor
return join(checker_names, "\n")
let names = []
let sep_idx = stridx(a:argLead, '/')
if sep_idx >= 1
let ft = a:argLead[: sep_idx-1]
call extend(names, map( s:registry.getNamesOfAvailableCheckers(ft), 'ft . "/" . v:val' ))
else
for ft in s:registry.resolveFiletypes(&filetype)
call extend(names, s:registry.getNamesOfAvailableCheckers(ft))
endfor
call extend(names, map( copy(s:registry.getKnownFiletypes()), 'v:val . "/"' ))
endif
return join(names, "\n")
endfunction " }}}2
" @vimlint(EVL103, 0, a:cursorPos)
" @vimlint(EVL103, 0, a:cmdLine)
@ -207,14 +223,16 @@ command! SyntasticJavacEditConfig runtime! syntax_checkers/java/*.vim | Synta
" Public API {{{1
function! SyntasticCheck(...) abort " {{{2
call s:UpdateErrors(0, a:000)
call s:UpdateErrors(bufnr(''), 0, a:000)
call syntastic#util#redraw(g:syntastic_full_redraws)
endfunction " }}}2
function! SyntasticInfo(...) abort " {{{2
call s:modemap.modeInfo(a:000)
call s:registry.echoInfoFor(s:_resolve_filetypes(a:000))
call s:registry.echoInfoFor(a:000)
call s:_explain_skip(a:000)
call syntastic#log#debugShowOptions(g:_SYNTASTIC_DEBUG_TRACE, g:_SYNTASTIC_SHELL_OPTIONS)
call syntastic#log#debugDump(g:_SYNTASTIC_DEBUG_VARIABLES)
endfunction " }}}2
function! SyntasticErrors() abort " {{{2
@ -222,19 +240,19 @@ function! SyntasticErrors() abort " {{{2
endfunction " }}}2
function! SyntasticReset() abort " {{{2
call s:ClearCache()
call s:ClearCache(bufnr(''))
call s:notifiers.refresh(g:SyntasticLoclist.New([]))
endfunction " }}}2
function! SyntasticToggleMode() abort " {{{2
call s:modemap.toggleMode()
call s:ClearCache()
call s:ClearCache(bufnr(''))
call s:notifiers.refresh(g:SyntasticLoclist.New([]))
call s:modemap.echoMode()
endfunction " }}}2
function! SyntasticSetLoclist() abort " {{{2
call g:SyntasticLoclist.current().setloclist()
call g:SyntasticLoclist.current().setloclist(0)
endfunction " }}}2
" }}}1
@ -243,54 +261,68 @@ endfunction " }}}2
augroup syntastic
autocmd!
autocmd BufEnter * call s:BufEnterHook()
autocmd VimEnter * call s:VimEnterHook()
autocmd BufEnter * call s:BufEnterHook(expand('<afile>', 1))
autocmd BufWinEnter * call s:BufWinEnterHook(expand('<afile>', 1))
augroup END
if g:syntastic_nested_autocommands
augroup syntastic
autocmd BufReadPost * nested call s:BufReadPostHook()
autocmd BufWritePost * nested call s:BufWritePostHook()
autocmd BufReadPost * nested call s:BufReadPostHook(expand('<afile>', 1))
autocmd BufWritePost * nested call s:BufWritePostHook(expand('<afile>', 1))
augroup END
else
augroup syntastic
autocmd BufReadPost * call s:BufReadPostHook()
autocmd BufWritePost * call s:BufWritePostHook()
autocmd BufReadPost * call s:BufReadPostHook(expand('<afile>', 1))
autocmd BufWritePost * call s:BufWritePostHook(expand('<afile>', 1))
augroup END
endif
if exists('##QuitPre')
" QuitPre was added in Vim 7.3.544
augroup syntastic
autocmd QuitPre * call s:QuitPreHook(expand('<amatch>', 1))
autocmd QuitPre * call s:QuitPreHook(expand('<afile>', 1))
augroup END
endif
function! s:BufReadPostHook() abort " {{{2
if g:syntastic_check_on_open
function! s:BufReadPostHook(fname) abort " {{{2
let buf = syntastic#util#fname2buf(a:fname)
if g:syntastic_check_on_open && buf > 0
call syntastic#log#debug(g:_SYNTASTIC_DEBUG_AUTOCOMMANDS,
\ 'autocmd: BufReadPost, buffer ' . bufnr('') . ' = ' . string(bufname(str2nr(bufnr('')))))
call s:UpdateErrors(1, [])
\ 'autocmd: BufReadPost, buffer ' . buf . ' = ' . string(a:fname))
if index(s:_check_stack, buf) == -1
call add(s:_check_stack, buf)
endif
endif
endfunction " }}}2
function! s:BufWritePostHook() abort " {{{2
function! s:BufWritePostHook(fname) abort " {{{2
let buf = syntastic#util#fname2buf(a:fname)
call syntastic#log#debug(g:_SYNTASTIC_DEBUG_AUTOCOMMANDS,
\ 'autocmd: BufWritePost, buffer ' . bufnr('') . ' = ' . string(bufname(str2nr(bufnr('')))))
call s:UpdateErrors(1, [])
\ 'autocmd: BufWritePost, buffer ' . buf . ' = ' . string(a:fname))
call s:UpdateErrors(buf, 1, [])
endfunction " }}}2
function! s:BufEnterHook() abort " {{{2
function! s:BufEnterHook(fname) abort " {{{2
let buf = syntastic#util#fname2buf(a:fname)
call syntastic#log#debug(g:_SYNTASTIC_DEBUG_AUTOCOMMANDS,
\ 'autocmd: BufEnter, buffer ' . bufnr('') . ' = ' . string(bufname(str2nr(bufnr('')))) .
\ ', &buftype = ' . string(&buftype))
if &buftype ==# ''
call s:notifiers.refresh(g:SyntasticLoclist.current())
\ 'autocmd: BufEnter, buffer ' . buf . ' = ' . string(a:fname) . ', &buftype = ' . string(&buftype))
if buf > 0 && getbufvar(buf, '&buftype') ==# ''
let idx = index(reverse(copy(s:_check_stack)), buf)
if idx >= 0
if !has('vim_starting')
call remove(s:_check_stack, -idx - 1)
call s:UpdateErrors(buf, 1, [])
endif
elseif &buftype ==# ''
call s:notifiers.refresh(g:SyntasticLoclist.current())
endif
elseif &buftype ==# 'quickfix'
" TODO: this is needed because in recent versions of Vim lclose
" can no longer be called from BufWinLeave
" TODO: at this point there is no b:syntastic_loclist
let loclist = filter(copy(getloclist(0)), 'v:val["valid"] == 1')
let owner = str2nr(getbufvar(bufnr(''), 'syntastic_owner_buffer'))
let loclist = filter(copy(getloclist(0)), 'v:val["valid"]')
let owner = str2nr(getbufvar(buf, 'syntastic_owner_buffer'))
let buffers = syntastic#util#unique(map(loclist, 'v:val["bufnr"]') + (owner ? [owner] : []))
if !empty(get(w:, 'syntastic_loclist_set', [])) && !empty(loclist) && empty(filter( buffers, 'syntastic#util#bufIsActive(v:val)' ))
call SyntasticLoclistHide()
@ -298,8 +330,39 @@ function! s:BufEnterHook() abort " {{{2
endif
endfunction " }}}2
function! s:BufWinEnterHook(fname) abort " {{{2
let buf = syntastic#util#fname2buf(a:fname)
call syntastic#log#debug(g:_SYNTASTIC_DEBUG_AUTOCOMMANDS,
\ 'autocmd: BufWinEnter, buffer ' . buf . ' = ' . string(a:fname) . ', &buftype = ' . string(&buftype))
if buf > 0 && getbufvar(buf, '&buftype') ==# ''
let idx = index(reverse(copy(s:_check_stack)), buf)
if idx >= 0 && !has('vim_starting')
call remove(s:_check_stack, -idx - 1)
call s:UpdateErrors(buf, 1, [])
endif
endif
endfunction " }}}2
function! s:VimEnterHook() abort " {{{2
let g:syntastic_version =
\ g:_SYNTASTIC_VERSION .
\ ' (Vim ' . v:version . (has('nvim') ? ', Neovim' : '') . ', ' .
\ g:_SYNTASTIC_UNAME .
\ (has('gui') ? ', GUI' : '') . ')'
lockvar g:syntastic_version
let buf = bufnr('')
call syntastic#log#debug(g:_SYNTASTIC_DEBUG_AUTOCOMMANDS,
\ 'autocmd: VimEnter, buffer ' . buf . ' = ' . string(bufname(buf)) . ', &buftype = ' . string(&buftype))
let idx = index(reverse(copy(s:_check_stack)), buf)
if idx >= 0 && getbufvar(buf, '&buftype') ==# ''
call remove(s:_check_stack, -idx - 1)
call s:UpdateErrors(buf, 1, [])
endif
endfunction " }}}2
function! s:QuitPreHook(fname) abort " {{{2
let buf = bufnr(fnameescape(a:fname))
let buf = syntastic#util#fname2buf(a:fname)
call syntastic#log#debug(g:_SYNTASTIC_DEBUG_AUTOCOMMANDS, 'autocmd: QuitPre, buffer ' . buf . ' = ' . string(a:fname))
if !syntastic#util#var('check_on_wq')
@ -317,30 +380,28 @@ endfunction " }}}2
" Main {{{1
"refresh and redraw all the error info for this buf when saving or reading
function! s:UpdateErrors(auto_invoked, checker_names) abort " {{{2
function! s:UpdateErrors(buf, auto_invoked, checker_names) abort " {{{2
call syntastic#log#debugShowVariables(g:_SYNTASTIC_DEBUG_TRACE, 'version')
call syntastic#log#debugShowOptions(g:_SYNTASTIC_DEBUG_TRACE, s:_DEBUG_DUMP_OPTIONS)
call syntastic#log#debugShowOptions(g:_SYNTASTIC_DEBUG_TRACE, g:_SYNTASTIC_SHELL_OPTIONS)
call syntastic#log#debugDump(g:_SYNTASTIC_DEBUG_VARIABLES)
call syntastic#log#debug(g:_SYNTASTIC_DEBUG_TRACE, 'UpdateErrors' . (a:auto_invoked ? ' (auto)' : '') .
\ ': ' . (len(a:checker_names) ? join(a:checker_names) : 'default checkers'))
call s:modemap.synch()
if s:_skip_file()
if s:_skip_file(a:buf)
return
endif
let run_checks = !a:auto_invoked || s:modemap.doAutoChecking()
let run_checks = !a:auto_invoked || s:modemap.doAutoChecking(a:buf)
if run_checks
call s:CacheErrors(a:checker_names)
call syntastic#util#setChangedtick()
else
if a:auto_invoked
return
endif
call s:CacheErrors(a:buf, a:checker_names)
call syntastic#util#setLastTick(a:buf)
elseif a:auto_invoked
return
endif
let loclist = g:SyntasticLoclist.current()
let loclist = g:SyntasticLoclist.current(a:buf)
if exists('*SyntasticCheckHook')
call SyntasticCheckHook(loclist.getRaw())
@ -356,14 +417,8 @@ function! s:UpdateErrors(auto_invoked, checker_names) abort " {{{2
let do_jump = 0
endif
let w:syntastic_loclist_set = []
if syntastic#util#var('always_populate_loc_list') || do_jump
call syntastic#log#debug(g:_SYNTASTIC_DEBUG_NOTIFICATIONS, 'loclist: setloclist (new)')
call setloclist(0, loclist.getRaw())
if !exists('b:syntastic_changedtick')
call syntastic#util#setChangedtick()
endif
let w:syntastic_loclist_set = [bufnr(''), b:syntastic_changedtick]
call loclist.setloclist(1)
if run_checks && do_jump && !loclist.isEmpty()
call syntastic#log#debug(g:_SYNTASTIC_DEBUG_NOTIFICATIONS, 'loclist: jump')
execute 'silent! lrewind ' . do_jump
@ -383,39 +438,44 @@ function! s:UpdateErrors(auto_invoked, checker_names) abort " {{{2
endfunction " }}}2
"clear the loc list for the buffer
function! s:ClearCache() abort " {{{2
call s:notifiers.reset(g:SyntasticLoclist.current())
call b:syntastic_loclist.destroy()
function! s:ClearCache(buf) abort " {{{2
let loclist = g:SyntasticLoclist.current(a:buf)
call s:notifiers.reset(loclist)
call loclist.destroy()
endfunction " }}}2
"detect and cache all syntax errors in this buffer
function! s:CacheErrors(checker_names) abort " {{{2
function! s:CacheErrors(buf, checker_names) abort " {{{2
call syntastic#log#debug(g:_SYNTASTIC_DEBUG_TRACE, 'CacheErrors: ' .
\ (len(a:checker_names) ? join(a:checker_names) : 'default checkers'))
call s:ClearCache()
call s:ClearCache(a:buf)
let newLoclist = g:SyntasticLoclist.New([])
call newLoclist.setOwner(a:buf)
if !s:_skip_file()
if !s:_skip_file(a:buf)
" debug logging {{{3
call syntastic#log#debugShowVariables(g:_SYNTASTIC_DEBUG_TRACE, 'aggregate_errors')
if syntastic#util#isRunningWindows()
call syntastic#log#debug(g:_SYNTASTIC_DEBUG_CHECKERS, '$TMP = ' . string($TMP) . ', $TEMP = ' . string($TEMP))
else
call syntastic#log#debug(g:_SYNTASTIC_DEBUG_CHECKERS, '$TERM = ' . string($TERM))
call syntastic#log#debug(g:_SYNTASTIC_DEBUG_CHECKERS, '$TMPDIR = ' . string($TMPDIR))
endif
call syntastic#log#debug(g:_SYNTASTIC_DEBUG_CHECKERS, '$PATH = ' . string($PATH))
call syntastic#log#debug(g:_SYNTASTIC_DEBUG_TRACE, 'getcwd() = ' . string(getcwd()))
" }}}3
let filetypes = s:_resolve_filetypes([])
let aggregate_errors = syntastic#util#var('aggregate_errors') || len(filetypes) > 1
let clist = s:registry.getCheckers(getbufvar(a:buf, '&filetype'), a:checker_names)
let aggregate_errors =
\ syntastic#util#var('aggregate_errors') || len(syntastic#util#unique(map(copy(clist), 'v:val.getFiletype()'))) > 1
let decorate_errors = aggregate_errors && syntastic#util#var('id_checkers')
let sort_aggregated_errors = aggregate_errors && syntastic#util#var('sort_aggregated_errors')
let clist = []
for type in filetypes
call extend(clist, s:registry.getCheckers(type, a:checker_names))
endfor
let names = []
let unavailable_checkers = 0
for checker in clist
let cname = checker.getFiletype() . '/' . checker.getName()
let cname = checker.getCName()
if !checker.isAvailable()
call syntastic#log#debug(g:_SYNTASTIC_DEBUG_TRACE, 'CacheErrors: Checker ' . cname . ' is not available')
let unavailable_checkers += 1
@ -436,7 +496,7 @@ function! s:CacheErrors(checker_names) abort " {{{2
call syntastic#log#debug(g:_SYNTASTIC_DEBUG_LOCLIST, 'sorted:', loclist)
endif
let newLoclist = newLoclist.extend(loclist)
call newLoclist.extend(loclist)
if !aggregate_errors
break
@ -522,7 +582,7 @@ function! SyntasticMake(options) abort " {{{2
let env_save = {}
if has_key(a:options, 'env') && len(a:options['env'])
for key in keys(a:options['env'])
if key =~? '\m^[a-z_]\+$'
if key =~? '\m^[a-z_][a-z0-9_]*$'
execute 'let env_save[' . string(key) . '] = $' . key
execute 'let $' . key . ' = ' . string(a:options['env'][key])
endif
@ -556,7 +616,7 @@ function! SyntasticMake(options) abort " {{{2
let err_lines = call('syntastic#preprocess#' . a:options['preprocess'], [err_lines])
call syntastic#log#debug(g:_SYNTASTIC_DEBUG_LOCLIST, 'preprocess:', err_lines)
endif
lgetexpr err_lines
noautocmd lgetexpr err_lines
let errors = deepcopy(getloclist(0))
@ -569,6 +629,12 @@ function! SyntasticMake(options) abort " {{{2
catch /\m^Vim\%((\a\+)\)\=:E380/
" E380: At bottom of quickfix stack
call setloclist(0, [], 'r')
try
" Vim 7.4.2200 or later
call setloclist(0, [], 'r', { 'title': '' })
catch /\m^Vim\%((\a\+)\)\=:E\%(118\|731\)/
" do nothing
endtry
catch /\m^Vim\%((\a\+)\)\=:E776/
" E776: No location list
" do nothing
@ -630,11 +696,6 @@ endfunction " }}}2
" Utilities {{{1
function! s:_resolve_filetypes(filetypes) abort " {{{2
let type = len(a:filetypes) ? a:filetypes[0] : &filetype
return split( get(g:syntastic_filetype_map, type, type), '\m\.' )
endfunction " }}}2
function! s:_ignore_file(filename) abort " {{{2
let fname = fnamemodify(a:filename, ':p')
for pattern in g:syntastic_ignore_files
@ -660,10 +721,10 @@ function! s:_is_quitting(buf) abort " {{{2
endfunction " }}}2
" Skip running in special buffers
function! s:_skip_file() abort " {{{2
let fname = expand('%', 1)
let skip = s:_is_quitting(bufnr('%')) || get(b:, 'syntastic_skip_checks', 0) ||
\ (&buftype !=# '') || !filereadable(fname) || getwinvar(0, '&diff') ||
function! s:_skip_file(buf) abort " {{{2
let fname = bufname(a:buf)
let skip = s:_is_quitting(a:buf) || getbufvar(a:buf, 'syntastic_skip_checks') ||
\ (getbufvar(a:buf, '&buftype') !=# '') || !filereadable(fname) || getwinvar(0, '&diff') ||
\ getwinvar(0, '&previewwindow') || s:_ignore_file(fname) ||
\ fnamemodify(fname, ':e') =~? g:syntastic_ignore_extensions
if skip
@ -674,17 +735,19 @@ endfunction " }}}2
" Explain why checks will be skipped for the current file
function! s:_explain_skip(filetypes) abort " {{{2
if empty(a:filetypes) && s:_skip_file()
let buf = bufnr('')
if empty(a:filetypes) && s:_skip_file(buf)
let why = []
let fname = expand('%', 1)
let fname = bufname(buf)
let bt = getbufvar(buf, '&buftype')
if s:_is_quitting(bufnr('%'))
if s:_is_quitting(buf)
call add(why, 'quitting buffer')
endif
if get(b:, 'syntastic_skip_checks', 0)
if getbufvar(buf, 'syntastic_skip_checks')
call add(why, 'b:syntastic_skip_checks set')
endif
if &buftype !=# ''
if bt !=# ''
call add(why, 'buftype = ' . string(&buftype))
endif
if !filereadable(fname)

View File

@ -25,10 +25,27 @@ function! g:SyntasticAutoloclistNotifier.AutoToggle(loclist) abort " {{{2
call a:loclist.show()
endif
else
if auto_loc_list == 1 || auto_loc_list == 2
"TODO: this will close the loc list window if one was opened by
"something other than syntastic
lclose
if (auto_loc_list == 1 || auto_loc_list == 2) && !empty(get(w:, 'syntastic_loclist_set', []))
try
" Vim 7.4.2200 or later
let title = get(getloclist(0, { 'title': 1 }), 'title', ':SyntasticCheck ')
catch /\m^Vim\%((\a\+)\)\=:E\%(118\|731\)/
let title = ':SyntasticCheck '
endtry
if strpart(title, 0, 16) ==# ':SyntasticCheck '
" TODO: this will close the loc list window if one was opened
" by something other than syntastic
call SyntasticLoclistHide()
try
" Vim 7.4.2200 or later
call setloclist(0, [], 'r', { 'title': '' })
catch /\m^Vim\%((\a\+)\)\=:E\%(118\|731\)/
" do nothing
endtry
let w:syntastic_loclist_set = []
endif
endif
endif
endfunction " }}}2

View File

@ -15,7 +15,7 @@ function! g:SyntasticChecker.New(args, ...) abort " {{{2
if a:0
" redirected checker
let newObj._exec = get(a:args, 'exec', a:1['_exec'])
let newObj._exec_default = get(a:args, 'exec', a:1['_exec_default'])
let filetype = a:1['_filetype']
let name = a:1['_name']
@ -31,7 +31,10 @@ function! g:SyntasticChecker.New(args, ...) abort " {{{2
let newObj._enable = a:1['_enable']
endif
else
let newObj._exec = get(a:args, 'exec', newObj._name)
let newObj._exec_default = get(a:args, 'exec', newObj._name)
if newObj._exec_default ==# ''
let newObj._exec_default = '<dummy>'
endif
let prefix = 'SyntaxCheckers_' . newObj._filetype . '_' . newObj._name . '_'
if has_key(a:args, 'enable')
@ -62,23 +65,24 @@ function! g:SyntasticChecker.getName() abort " {{{2
return self._name
endfunction " }}}2
function! g:SyntasticChecker.getCName() abort " {{{2
return self._filetype . '/' . self._name
endfunction " }}}2
" Synchronise _exec with user's setting. Force re-validation if needed.
"
" XXX: This function must be called at least once before calling either
" getExec() or getExecEscaped(). Normally isAvailable() does that for you
" automatically, but you should keep still this in mind if you change the
" current checker workflow.
function! g:SyntasticChecker.syncExec() abort " {{{2
let user_exec =
\ expand( exists('b:syntastic_' . self._name . '_exec') ? b:syntastic_{self._name}_exec :
\ syntastic#util#var(self._filetype . '_' . self._name . '_exec'), 1 )
if user_exec !=# '' && user_exec !=# self._exec
let self._exec = user_exec
if has_key(self, '_available')
" we have a new _exec on the block, it has to be validated
call remove(self, '_available')
endif
function! g:SyntasticChecker.syncExec(...) abort " {{{2
if a:0
let self._exec = a:1
else
let suffix = self._name . '_exec'
let self._exec = expand(
\ syntastic#util#var(self._filetype . '_' . suffix,
\ syntastic#util#var(suffix, self._exec_default)), 1 )
endif
endfunction " }}}2
@ -91,7 +95,8 @@ function! g:SyntasticChecker.getExecEscaped() abort " {{{2
endfunction " }}}2
function! g:SyntasticChecker.getLocListRaw() abort " {{{2
let name = self._filetype . '/' . self._name
let checker_start = reltime()
let name = self.getCName()
if has_key(self, '_enable')
let status = syntastic#util#var(self._enable, -1)
@ -128,6 +133,8 @@ function! g:SyntasticChecker.getLocListRaw() abort " {{{2
call self._populateHighlightRegexes(list)
call syntastic#log#debug(g:_SYNTASTIC_DEBUG_LOCLIST, name . ' raw:', list)
call self._quietMessages(list)
call syntastic#log#debug(g:_SYNTASTIC_DEBUG_TRACE,
\ 'getLocList: checker ' . name . ' run in ' . split(reltimestr(reltime(checker_start)))[0] . 's')
return list
endfunction " }}}2
@ -147,7 +154,7 @@ function! g:SyntasticChecker.getVersion(...) abort " {{{2
call self.setVersion(parsed_ver)
else
call syntastic#log#ndebug(g:_SYNTASTIC_DEBUG_LOCLIST, 'checker output:', split(version_output, "\n", 1))
call syntastic#log#error("checker " . self._filetype . "/" . self._name . ": can't parse version string (abnormal termination?)")
call syntastic#log#error("checker " . self.getCName() . ": can't parse version string (abnormal termination?)")
endif
endif
return get(self, '_version', [])
@ -161,8 +168,8 @@ function! g:SyntasticChecker.setVersion(version) abort " {{{2
endfunction " }}}2
function! g:SyntasticChecker.log(msg, ...) abort " {{{2
let leader = self._filetype . '/' . self._name . ': '
if a:0 > 0
let leader = self.getCName() . ': '
if a:0
call syntastic#log#debug(g:_SYNTASTIC_DEBUG_CHECKERS, leader . a:msg, a:1)
else
call syntastic#log#debug(g:_SYNTASTIC_DEBUG_CHECKERS, leader . a:msg)
@ -184,10 +191,15 @@ endfunction " }}}2
function! g:SyntasticChecker.isAvailable() abort " {{{2
call self.syncExec()
if !has_key(self, '_available')
let self._available = self._isAvailableFunc()
let self._available = {}
endif
return self._available
if !has_key(self._available, self._exec)
let self._available[self._exec] = self._isAvailableFunc()
endif
return self._available[self._exec]
endfunction " }}}2
function! g:SyntasticChecker.isDisabled() abort " {{{2

View File

@ -10,7 +10,7 @@ let g:SyntasticLoclist = {}
function! g:SyntasticLoclist.New(rawLoclist) abort " {{{2
let newObj = copy(self)
let llist = filter(copy(a:rawLoclist), 'v:val["valid"] == 1')
let llist = filter(copy(a:rawLoclist), 'v:val["valid"]')
for e in llist
if get(e, 'type', '') ==# ''
@ -27,17 +27,18 @@ function! g:SyntasticLoclist.New(rawLoclist) abort " {{{2
return newObj
endfunction " }}}2
function! g:SyntasticLoclist.current() abort " {{{2
if !exists('b:syntastic_loclist') || empty(b:syntastic_loclist)
let b:syntastic_loclist = g:SyntasticLoclist.New([])
function! g:SyntasticLoclist.current(...) abort " {{{2
let buf = a:0 ? a:1 : bufnr('')
let loclist = syntastic#util#getbufvar(buf, 'syntastic_loclist', {})
if type(loclist) != type({}) || empty(loclist)
unlet! loclist
let loclist = g:SyntasticLoclist.New([])
endif
return b:syntastic_loclist
return loclist
endfunction " }}}2
function! g:SyntasticLoclist.extend(other) abort " {{{2
let list = self.copyRaw()
call extend(list, a:other.copyRaw())
return g:SyntasticLoclist.New(list)
call extend(self._rawLoclist, a:other.copyRaw())
endfunction " }}}2
function! g:SyntasticLoclist.sort() abort " {{{2
@ -167,7 +168,6 @@ function! g:SyntasticLoclist.setOwner(buffer) abort " {{{2
endfunction " }}}2
function! g:SyntasticLoclist.deploy() abort " {{{2
call self.setOwner(bufnr(''))
let self._stamp = syntastic#util#stamp()
for buf in self.getBuffers()
call setbufvar(buf, 'syntastic_loclist', self)
@ -281,7 +281,7 @@ endfunction " }}}2
"
"would return all errors for buffer 10.
"
"Note that all comparisons are done with ==?
"Note that all string comparisons are done with ==?
function! g:SyntasticLoclist.filter(filters) abort " {{{2
let conditions = values(map(copy(a:filters), 's:_translate(v:key, v:val)'))
let filter = len(conditions) == 1 ?
@ -289,23 +289,29 @@ function! g:SyntasticLoclist.filter(filters) abort " {{{2
return filter(copy(self._rawLoclist), filter)
endfunction " }}}2
function! g:SyntasticLoclist.setloclist() abort " {{{2
function! g:SyntasticLoclist.setloclist(new) abort " {{{2
if !exists('w:syntastic_loclist_set')
let w:syntastic_loclist_set = []
endif
if empty(w:syntastic_loclist_set) || w:syntastic_loclist_set != [bufnr(''), b:changedtick]
let replace = g:syntastic_reuse_loc_lists && !empty(w:syntastic_loclist_set)
if a:new || empty(w:syntastic_loclist_set) || w:syntastic_loclist_set != [self._owner, getbufvar(self._owner, 'changedtick')]
let replace = !a:new && g:syntastic_reuse_loc_lists && !empty(w:syntastic_loclist_set)
call syntastic#log#debug(g:_SYNTASTIC_DEBUG_NOTIFICATIONS, 'loclist: setloclist ' . (replace ? '(replace)' : '(new)'))
call setloclist(0, self.getRaw(), replace ? 'r' : ' ')
call syntastic#util#setChangedtick()
let w:syntastic_loclist_set = [bufnr(''), b:syntastic_changedtick]
try
" Vim 7.4.2200 or later
call setloclist(0, [], 'r', { 'title': ':SyntasticCheck ' . self._name })
catch /\m^Vim\%((\a\+)\)\=:E\%(118\|731\)/
" do nothing
endtry
call syntastic#util#setLastTick(self._owner)
let w:syntastic_loclist_set = [self._owner, getbufvar(self._owner, 'syntastic_lasttick')]
endif
endfunction " }}}2
"display the cached errors for this buf in the location list
function! g:SyntasticLoclist.show() abort " {{{2
call syntastic#log#debug(g:_SYNTASTIC_DEBUG_NOTIFICATIONS, 'loclist: show')
call self.setloclist()
call self.setloclist(0)
if !self.isEmpty()
let num = winnr()

View File

@ -29,7 +29,8 @@ function! g:SyntasticModeMap.synch() abort " {{{2
endfunction " }}}2
function! g:SyntasticModeMap.allowsAutoChecking(filetype) abort " {{{2
let fts = split(a:filetype, '\m\.')
let registry = g:SyntasticRegistry.Instance()
let fts = registry.resolveFiletypes(a:filetype)
if self.isPassive()
return self._isOneFiletypeActive(fts)
@ -38,13 +39,13 @@ function! g:SyntasticModeMap.allowsAutoChecking(filetype) abort " {{{2
endif
endfunction " }}}2
function! g:SyntasticModeMap.doAutoChecking() abort " {{{2
let local_mode = get(b:, 'syntastic_mode', '')
function! g:SyntasticModeMap.doAutoChecking(buf) abort " {{{2
let local_mode = getbufvar(a:buf, 'syntastic_mode')
if local_mode ==# 'active' || local_mode ==# 'passive'
return local_mode ==# 'active'
endif
return self.allowsAutoChecking(&filetype)
return self.allowsAutoChecking(getbufvar(a:buf, '&filetype'))
endfunction " }}}2
function! g:SyntasticModeMap.isPassive() abort " {{{2
@ -72,7 +73,7 @@ function! g:SyntasticModeMap.echoMode() abort " {{{2
endfunction " }}}2
function! g:SyntasticModeMap.modeInfo(filetypes) abort " {{{2
echomsg 'Syntastic version: ' . g:_SYNTASTIC_VERSION . ' (Vim ' . v:version . ', ' . g:_SYNTASTIC_UNAME . ')'
echomsg 'Syntastic version: ' . g:syntastic_version
let type = len(a:filetypes) ? a:filetypes[0] : &filetype
echomsg 'Info for filetype: ' . type
@ -96,7 +97,7 @@ function! g:SyntasticModeMap.modeInfo(filetypes) abort " {{{2
echomsg 'Local mode: ' . b:syntastic_mode
endif
echomsg 'The current file will ' . (self.doAutoChecking() ? '' : 'not ') . 'be checked automatically'
echomsg 'The current file will ' . (self.doAutoChecking(bufnr('')) ? '' : 'not ') . 'be checked automatically'
endif
endfunction " }}}2

View File

@ -23,7 +23,7 @@ function! g:SyntasticNotifiers.Instance() abort " {{{2
endfunction " }}}2
function! g:SyntasticNotifiers.refresh(loclist) abort " {{{2
if !a:loclist.isEmpty() && !a:loclist.isNewerThan([])
if !syntastic#util#bufIsActive(bufnr('')) || (!a:loclist.isEmpty() && !a:loclist.isNewerThan([]))
" loclist not fully constructed yet
return
endif

View File

@ -12,6 +12,7 @@ let s:_DEFAULT_CHECKERS = {
\ 'apiblueprint': ['drafter'],
\ 'applescript': ['osacompile'],
\ 'asciidoc': ['asciidoc'],
\ 'asl': ['iasl'],
\ 'asm': ['gcc'],
\ 'bro': ['bro'],
\ 'bemhtml': ['bemhtmllint'],
@ -42,6 +43,7 @@ let s:_DEFAULT_CHECKERS = {
\ 'handlebars': ['handlebars'],
\ 'haskell': ['hdevtools', 'hlint'],
\ 'haxe': ['haxe'],
\ 'help': [],
\ 'hss': ['hss'],
\ 'html': ['tidy'],
\ 'jade': ['jade_lint'],
@ -84,6 +86,7 @@ let s:_DEFAULT_CHECKERS = {
\ 'slim': ['slimrb'],
\ 'sml': ['smlnj'],
\ 'spec': ['rpmlint'],
\ 'solidity': ['solc'],
\ 'sql': ['sqlint'],
\ 'stylus': ['stylint'],
\ 'tcl': ['nagelfar'],
@ -93,7 +96,7 @@ let s:_DEFAULT_CHECKERS = {
\ 'trig': ['rapper'],
\ 'turtle': ['rapper'],
\ 'twig': ['twiglint'],
\ 'typescript': ['tsc'],
\ 'typescript': [],
\ 'vala': ['valac'],
\ 'verilog': ['verilator'],
\ 'vhdl': ['ghdl'],
@ -186,24 +189,39 @@ endfunction " }}}2
" not checked for availability (that is, the corresponding IsAvailable() are
" not run).
function! g:SyntasticRegistry.getCheckers(ftalias, hints_list) abort " {{{2
let ft = s:_normalise_filetype(a:ftalias)
call self._loadCheckersFor(ft, 0)
let checkers_map = self._checkerMap[ft]
if empty(checkers_map)
return []
endif
call self._checkDeprecation(ft)
let ftlist = self.resolveFiletypes(a:ftalias)
let names =
\ !empty(a:hints_list) ? syntastic#util#unique(a:hints_list) :
\ exists('b:syntastic_checkers') ? b:syntastic_checkers :
\ exists('g:syntastic_' . ft . '_checkers') ? g:syntastic_{ft}_checkers :
\ get(s:_DEFAULT_CHECKERS, ft, 0)
\ !empty(a:hints_list) ? a:hints_list :
\ exists('b:syntastic_checkers') ? b:syntastic_checkers : []
return type(names) == type([]) ?
\ self._filterCheckersByName(checkers_map, names) : [checkers_map[keys(checkers_map)[0]]]
let cnames = []
if !empty(names)
for name in names
if name !~# '/'
for ft in ftlist
call add(cnames, ft . '/' . name)
endfor
else
call add(cnames, name)
endif
endfor
else
for ft in ftlist
call self._sanityCheck(ft)
let defs =
\ exists('g:syntastic_' . ft . '_checkers') ? g:syntastic_{ft}_checkers :
\ get(s:_DEFAULT_CHECKERS, ft, [])
call extend(cnames, map(copy(defs), 'stridx(v:val, "/") < 0 ? ft . "/" . v:val : v:val' ))
endfor
endif
let cnames = syntastic#util#unique(cnames)
for ft in syntastic#util#unique(map( copy(cnames), 'v:val[: stridx(v:val, "/")-1]' ))
call self._loadCheckersFor(ft, 0)
endfor
return self._filterCheckersByName(cnames)
endfunction " }}}2
" Same as getCheckers(), but keep only the available checkers. This runs the
@ -240,8 +258,12 @@ function! g:SyntasticRegistry.getNamesOfAvailableCheckers(ftalias) abort " {{{2
return keys(filter( copy(self._checkerMap[ft]), 'v:val.isAvailable()' ))
endfunction " }}}2
function! g:SyntasticRegistry.resolveFiletypes(ftalias) abort " {{{2
return map(split( get(g:syntastic_filetype_map, a:ftalias, a:ftalias), '\m\.' ), 's:_normalise_filetype(v:val)')
endfunction " }}}2
function! g:SyntasticRegistry.echoInfoFor(ftalias_list) abort " {{{2
let ft_list = syntastic#util#unique(map( copy(a:ftalias_list), 's:_normalise_filetype(v:val)' ))
let ft_list = syntastic#util#unique(self.resolveFiletypes(empty(a:ftalias_list) ? &filetype : a:ftalias_list[0]))
if len(ft_list) != 1
let available = []
let active = []
@ -255,8 +277,8 @@ function! g:SyntasticRegistry.echoInfoFor(ftalias_list) abort " {{{2
else
let ft = ft_list[0]
let available = self.getNamesOfAvailableCheckers(ft)
let active = map(self.getCheckersAvailable(ft, []), 'v:val.getName()')
let disabled = map(self.getCheckersDisabled(ft, []), 'v:val.getName()')
let active = map(self.getCheckersAvailable(ft, []), 'ft ==# v:val.getFiletype() ? v:val.getName() : v:val.getCName()')
let disabled = map(self.getCheckersDisabled(ft, []), 'ft ==# v:val.getFiletype() ? v:val.getName() : v:val.getCName()')
endif
let cnt = len(available)
@ -272,7 +294,7 @@ function! g:SyntasticRegistry.echoInfoFor(ftalias_list) abort " {{{2
let cnt = len(disabled)
let plural = cnt != 1 ? 's' : ''
if len(disabled)
let cklist = join(sort(disabled))
let cklist = join(sort(disabled, 's:_compare_checker_names'))
echomsg 'Checker' . plural . ' disabled for security reasons: ' . cklist
endif
@ -319,8 +341,20 @@ function! g:SyntasticRegistry._registerChecker(checker) abort " {{{2
let self._checkerMap[ft][name] = a:checker
endfunction " }}}2
function! g:SyntasticRegistry._filterCheckersByName(checkers_map, list) abort " {{{2
return filter( map(copy(a:list), 'get(a:checkers_map, v:val, {})'), '!empty(v:val)' )
function! g:SyntasticRegistry._findChecker(cname) abort " {{{2
let sep_idx = stridx(a:cname, '/')
if sep_idx > 0
let ft = a:cname[: sep_idx-1]
let name = a:cname[sep_idx+1 :]
else
let ft = &filetype
let name = a:cname
endif
return get(self._checkerMap[ft], name, {})
endfunction "}}}2
function! g:SyntasticRegistry._filterCheckersByName(cnames) abort " {{{2
return filter( map(copy(a:cnames), 'self._findChecker(v:val)'), '!empty(v:val)' )
endfunction " }}}2
function! g:SyntasticRegistry._loadCheckersFor(filetype, force) abort " {{{2
@ -336,8 +370,18 @@ function! g:SyntasticRegistry._loadCheckersFor(filetype, force) abort " {{{2
endfunction " }}}2
" Check for obsolete variable g:syntastic_<filetype>_checker
function! g:SyntasticRegistry._checkDeprecation(filetype) abort " {{{2
if exists('g:syntastic_' . a:filetype . '_checker') && !exists('g:syntastic_' . a:filetype . '_checkers')
function! g:SyntasticRegistry._sanityCheck(filetype) abort " {{{2
if exists('g:syntastic_' . a:filetype . '_checkers') &&
\ type(g:syntastic_{a:filetype}_checkers) != type([])
unlet! g:syntastic_{a:filetype}_checkers
call syntastic#log#error('variable g:syntastic_' . a:filetype . '_checkers has to be a list of strings')
endif
if exists('g:syntastic_' . a:filetype . '_checker') &&
\ !exists('g:syntastic_' . a:filetype . '_checkers') &&
\ type(g:syntastic_{a:filetype}_checker) == type('')
let g:syntastic_{a:filetype}_checkers = [g:syntastic_{a:filetype}_checker]
call syntastic#log#oneTimeWarn('variable g:syntastic_' . a:filetype . '_checker is deprecated')
endif
@ -370,6 +414,26 @@ function! s:_disabled_by_ycm(filetype) abort " {{{2
return index(s:_YCM_TYPES, a:filetype) >= 0
endfunction " }}}2
function! s:_compare_checker_names(a, b) abort " {{{2
if a:a ==# a:b
return 0
endif
if stridx(a:a, '/') < 0
if stridx(a:b, '/') < 0
return a:a < a:b ? -1 : 1
else
return -1
endif
else
if stridx(a:b, '/') < 0
return 1
else
return a:a < a:b ? -1 : 1
endif
endif
endfunction " }}}2
" }}}1
" vim: set sw=4 sts=4 et fdm=marker:

View File

@ -28,7 +28,9 @@ endfunction
function! SyntaxCheckers_ansible_ansible_lint_GetLocList() dict
let makeprg = self.makeprgBuild({ 'args_after': '-p' })
let errorformat = '%f:%l: [ANSIBLE%n] %m'
let errorformat =
\ '%f:%l: [EANSIBLE%n] %m,' .
\ '%f:%l: [ANSIBLE%n] %m'
let env = syntastic#util#isRunningWindows() ? {} : { 'TERM': 'dumb' }

View File

@ -0,0 +1,23 @@
"============================================================================
"File: proselint.vim
"Description: Syntax checking plugin for syntastic
"Maintainer: LCD 47 <lcd047 at gmail dot com>
"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
" Want To Public License, Version 2, as published by Sam Hocevar.
" See http://sam.zoy.org/wtfpl/COPYING for more details.
"
"============================================================================
if exists('g:loaded_syntastic_asciidoc_proselint_checker')
finish
endif
let g:loaded_syntastic_asciidoc_proselint_checker = 1
call g:SyntasticRegistry.CreateAndRegisterChecker({
\ 'filetype': 'asciidoc',
\ 'name': 'proselint',
\ 'redirect': 'text/proselint'})
" vim: set sw=4 sts=4 et fdm=marker:

View File

@ -0,0 +1,59 @@
"============================================================================
"File: iasl.vim
"Description: Syntax checking plugin for syntastic using iasl
"Maintainer: Peter Wu <peter@lekensteyn.nl>
"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
" Want To Public License, Version 2, as published by Sam Hocevar.
" See http://sam.zoy.org/wtfpl/COPYING for more details.
"============================================================================
if exists('g:loaded_syntastic_asl_iasl_checker')
finish
endif
let g:loaded_syntastic_asl_iasl_checker = 1
let s:save_cpo = &cpo
set cpo&vim
function! SyntaxCheckers_asl_iasl_GetLocList() dict
let tmpdir = syntastic#util#tmpdir() . syntastic#util#Slash()
let makeprg = self.makeprgBuild({
\ 'args': '-vi',
\ 'args_after': ['-p', tmpdir] })
let errorformat =
\ '%f(%l) : %trror %n - %m,' .
\ '%f(%l) : %tarning %n - %m,' .
\ '%f(%l) : %temark %n - %m,' .
\ '%f(%l) : %tptimize %n - %m,' .
\ '%f(%l) : %m'
let loclist = SyntasticMake({
\ 'makeprg': makeprg,
\ 'errorformat': errorformat,
\ 'returns': [0, 255] })
for e in loclist
if e['type'] =~? 'r'
let e['type'] = 'W'
elseif e['type'] =~? 'o'
let e['type'] = 'W'
let e['subtype'] = 'Style'
endif
endfor
call syntastic#util#rmrf(tmpdir)
return loclist
endfunction
call g:SyntasticRegistry.CreateAndRegisterChecker({
\ 'filetype': 'asl',
\ 'name': 'iasl'})
let &cpo = s:save_cpo
unlet s:save_cpo
" vim: set sw=4 sts=4 et fdm=marker:

View File

@ -1,6 +1,6 @@
"============================================================================
"File: avrgcc.vim
"Description: Syntax checking plugin for syntastic.vim
"Description: Syntax checking plugin for syntastic
"Maintainer: Karel <karelishere at gmail dot com>
"License: This program is free software. It comes without any warranty,
" to the extent permitted by applicable law. You can redistribute
@ -22,10 +22,12 @@ endif
let s:save_cpo = &cpo
set cpo&vim
let s:opt_x = { 'c': 'c', 'cpp': 'c++' }
function! SyntaxCheckers_c_avrgcc_GetLocList() dict
let makeprg = self.makeprgBuild({
\ 'args_before': syntastic#c#ReadConfig(g:syntastic_avrgcc_config_file),
\ 'args_after': '-x c -fsyntax-only' })
\ 'args_after': '-x ' . get(s:opt_x, self.getFiletype(), '') . ' -fsyntax-only' })
let errorformat =
\ '%-G%f:%s:,' .

View File

@ -0,0 +1,24 @@
"============================================================================
"File: avrgcc.vim
"Description: Syntax checking plugin for syntastic
"Maintainer: Sławek Piotrowski <sentinel at atteo dot com>
"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
" Want To Public License, Version 2, as published by Sam Hocevar.
" See http://sam.zoy.org/wtfpl/COPYING for more details.
"
"============================================================================
if exists('g:loaded_syntastic_cpp_avrgcc_checker')
finish
endif
let g:loaded_syntastic_cpp_avrgcc_checker = 1
call g:SyntasticRegistry.CreateAndRegisterChecker({
\ 'filetype': 'cpp',
\ 'name': 'avrgcc',
\ 'exec': 'avr-g++',
\ 'redirect': 'c/avrgcc'})
" vim: set sw=4 sts=4 et fdm=marker:

View File

@ -17,7 +17,6 @@ let g:loaded_syntastic_cpp_clang_check_checker = 1
call g:SyntasticRegistry.CreateAndRegisterChecker({
\ 'filetype': 'cpp',
\ 'name': 'clang_check',
\ 'exec': 'clang-check',
\ 'redirect': 'c/clang_check'})
" vim: set sw=4 sts=4 et fdm=marker:

View File

@ -17,7 +17,6 @@ let g:loaded_syntastic_cpp_clang_tidy_checker = 1
call g:SyntasticRegistry.CreateAndRegisterChecker({
\ 'filetype': 'cpp',
\ 'name': 'clang_tidy',
\ 'exec': 'clang-tidy',
\ 'redirect': 'c/clang_tidy'})
" vim: set sw=4 sts=4 et fdm=marker:

View File

@ -18,7 +18,6 @@ let g:loaded_syntastic_cpp_pc_lint_checker = 1
call g:SyntasticRegistry.CreateAndRegisterChecker({
\ 'filetype': 'cpp',
\ 'name': 'pc_lint',
\ 'exec': 'lint-nt',
\ 'redirect': 'c/pc_lint'})
" vim: set sw=4 sts=4 et fdm=marker:

View File

@ -10,19 +10,41 @@ if exists('g:loaded_syntastic_cuda_nvcc_checker')
endif
let g:loaded_syntastic_cuda_nvcc_checker = 1
if !exists('g:syntastic_cuda_config_file')
let g:syntastic_cuda_config_file = '.syntastic_cuda_config'
endif
let s:save_cpo = &cpo
set cpo&vim
function! SyntaxCheckers_cuda_nvcc_GetLocList() dict
if syntastic#util#var('cuda_arch') !=# ''
let arch_flag = '-arch=' . g:syntastic_cuda_arch
else
let arch_flag = ''
let arch_flag = syntastic#util#var('cuda_arch')
if arch_flag !=# ''
let arch_flag = '-arch=' . arch_flag
call syntastic#log#oneTimeWarn('variable g:syntastic_cuda_arch is deprecated, ' .
\ 'please add ' . string(arch_flag) . ' to g:syntastic_cuda_nvcc_args instead')
endif
let makeprg =
\ self.getExecEscaped() . ' ' . arch_flag .
\ ' --cuda -O0 -I . -Xcompiler -fsyntax-only ' .
\ syntastic#util#shexpand('%') . ' ' . syntastic#c#NullOutput()
let build_opts = {}
let dummy = ''
if index(['h', 'hpp', 'cuh'], expand('%:e', 1), 0, 1) >= 0
if syntastic#util#var('cuda_check_header', 0)
let dummy = expand('%:p:h', 1) . syntastic#util#Slash() . '.syntastic_dummy.cu'
let build_opts = {
\ 'exe_before': 'echo > ' . syntastic#util#shescape(dummy) . ' ;',
\ 'fname_before': '.syntastic_dummy.cu -include' }
else
return []
endif
endif
call extend(build_opts, {
\ 'args_before': arch_flag . ' --cuda -O0 -I .',
\ 'args': syntastic#c#ReadConfig(g:syntastic_cuda_config_file),
\ 'args_after': '-Xcompiler -fsyntax-only',
\ 'tail_after': syntastic#c#NullOutput() })
let makeprg = self.makeprgBuild(build_opts)
let errorformat =
\ '%*[^"]"%f"%*\D%l: %m,'.
@ -40,19 +62,13 @@ function! SyntaxCheckers_cuda_nvcc_GetLocList() dict
\ '%DMaking %*\a in %f,'.
\ '%f|%l| %m'
if index(['h', 'hpp', 'cuh'], expand('%:e', 1), 0, 1) >= 0
if syntastic#util#var('cuda_check_header', 0)
let makeprg =
\ 'echo > .syntastic_dummy.cu ; ' .
\ self.getExecEscaped() . ' ' . arch_flag .
\ ' --cuda -O0 -I . .syntastic_dummy.cu -Xcompiler -fsyntax-only -include ' .
\ syntastic#util#shexpand('%') . ' ' . syntastic#c#NullOutput()
else
return []
endif
let loclist = SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat })
if dummy !=# ''
call delete(dummy)
endif
return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat })
return loclist
endfunction
call g:SyntasticRegistry.CreateAndRegisterChecker({

View File

@ -1,7 +1,7 @@
"============================================================================
"File: dockerfile_lint.vim
"Description: Syntax checking plugin for syntastic.vim using dockerfile-lint
" (https://github.com/projectatomic/dockerfile-lint).
" (https://github.com/projectatomic/dockerfile_lint).
"Maintainer: Tim Carry <tim at pixelastic dot com>
"License: This program is free software. It comes without any warranty,
" to the extent permitted by applicable law. You can redistribute

View File

@ -1,94 +0,0 @@
"============================================================================
"File: ghc-mod.vim
"Description: Syntax checking plugin for syntastic.vim
"Maintainer: Anthony Carapetis <anthony.carapetis at gmail dot com>
"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
" Want To Public License, Version 2, as published by Sam Hocevar.
" See http://sam.zoy.org/wtfpl/COPYING for more details.
"
"============================================================================
if exists('g:loaded_syntastic_haskell_ghc_mod_checker')
finish
endif
let g:loaded_syntastic_haskell_ghc_mod_checker = 1
let s:ghc_mod_new = -1
let s:save_cpo = &cpo
set cpo&vim
function! SyntaxCheckers_haskell_ghc_mod_IsAvailable() dict " {{{1
if !executable(self.getExec())
return 0
endif
" ghc-mod 5.0.0 and later needs the "version" command to print the
" version. But the "version" command appeared in 4.1.0. Thus, we need to
" know the version in order to know how to find out the version. :)
" Try "ghc-mod version".
let version_output = split(syntastic#util#system(self.getExecEscaped() . ' version'), '\n', 1)
let ver = filter(copy(version_output), 'v:val =~# ''\m\sversion''')
if !len(ver)
" That didn't work. Try "ghc-mod" alone.
let version_output = split(syntastic#util#system(self.getExecEscaped()), '\n', 1)
let ver = filter(copy(version_output), 'v:val =~# ''\m\sversion''')
endif
let parsed_ver = len(ver) ? syntastic#util#parseVersion(ver[0]) : []
if len(parsed_ver)
" Encouraged by the great success in finding out the version, now we
" need either a Vim that can handle NULs in system() output, or a
" ghc-mod that has the "--boundary" option.
call self.setVersion(parsed_ver)
let s:ghc_mod_new = syntastic#util#versionIsAtLeast(parsed_ver, [2, 1, 2])
else
call syntastic#log#ndebug(g:_SYNTASTIC_DEBUG_LOCLIST, 'checker output:', version_output)
call syntastic#log#error("checker haskell/ghc_mod: can't parse version string (abnormal termination?)")
let s:ghc_mod_new = -1
endif
" ghc-mod 5.4.0 wants to run in the root directory of the project;
" syntastic can't cope with the resulting complications
"
" References:
" https://hackage.haskell.org/package/ghc-mod-5.4.0.0/changelog
let s:ghc_mod_bailout = syntastic#util#versionIsAtLeast(parsed_ver, [5, 4])
return (s:ghc_mod_new >= 0) && (v:version >= 704 || s:ghc_mod_new) && !s:ghc_mod_bailout
endfunction " }}}1
function! SyntaxCheckers_haskell_ghc_mod_GetLocList() dict " {{{1
let makeprg = self.makeprgBuild({
\ 'exe': self.getExecEscaped() . ' check' . (s:ghc_mod_new ? ' --boundary=""' : '') })
let errorformat =
\ '%-G%\s%#,' .
\ '%f:%l:%c:%trror: %m,' .
\ '%f:%l:%c:%tarning: %m,'.
\ '%f:%l:%c: %trror: %m,' .
\ '%f:%l:%c: %tarning: %m,' .
\ '%f:%l:%c:%m,' .
\ '%E%f:%l:%c:,' .
\ '%Z%m'
return SyntasticMake({
\ 'makeprg': makeprg,
\ 'errorformat': errorformat,
\ 'preprocess': 'iconv',
\ 'postprocess': ['compressWhitespace'],
\ 'returns': [0] })
endfunction " }}}1
call g:SyntasticRegistry.CreateAndRegisterChecker({
\ 'filetype': 'haskell',
\ 'name': 'ghc_mod',
\ 'exec': 'ghc-mod' })
let &cpo = s:save_cpo
unlet s:save_cpo
" vim: set sw=4 sts=4 et fdm=marker:

View File

@ -31,12 +31,12 @@ function! SyntaxCheckers_haskell_hdevtools_GetLocList() dict
let errorformat =
\ '%-Z %#,'.
\ '%W%f:%l:%v: Warning: %m,'.
\ '%W%f:%l:%v: Warning:,'.
\ '%E%f:%l:%v: %m,'.
\ '%E%>%f:%l:%v:,'.
\ '%W%\m%f:%l:%v%\%%(-%\d%\+%\)%\=: Warning: %m,'.
\ '%W%\m%f:%l:%v%\%%(-%\d%\+%\)%\=: Warning:,'.
\ '%E%\m%f:%l:%v%\%%(-%\d%\+%\)%\=: %m,'.
\ '%E%>%\m%f:%l:%v%\%%(-%\d%\+%\)%\=:,'.
\ '%+C %#%m,'.
\ '%W%>%f:%l:%v:,'.
\ '%W%>%\m%f:%l:%v%\%%(-%\d%\+%\)%\=:,'.
\ '%+C %#%tarning: %m,'
return SyntasticMake({

View File

@ -0,0 +1,23 @@
"============================================================================
"File: proselint.vim
"Description: Syntax checking plugin for syntastic
"Maintainer: LCD 47 <lcd047 at gmail dot com>
"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
" Want To Public License, Version 2, as published by Sam Hocevar.
" See http://sam.zoy.org/wtfpl/COPYING for more details.
"
"============================================================================
if exists('g:loaded_syntastic_help_proselint_checker')
finish
endif
let g:loaded_syntastic_help_proselint_checker = 1
call g:SyntasticRegistry.CreateAndRegisterChecker({
\ 'filetype': 'help',
\ 'name': 'proselint',
\ 'redirect': 'text/proselint'})
" vim: set sw=4 sts=4 et fdm=marker:

View File

@ -0,0 +1,23 @@
"============================================================================
"File: eslint.vim
"Description: Syntax checking plugin for syntastic
"Maintainer: LCD 47 <lcd047 at gmail dot com>
"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
" Want To Public License, Version 2, as published by Sam Hocevar.
" See http://sam.zoy.org/wtfpl/COPYING for more details.
"
"============================================================================
if exists('g:loaded_syntastic_html_eslint_checker')
finish
endif
let g:loaded_syntastic_html_eslint_checker = 1
call g:SyntasticRegistry.CreateAndRegisterChecker({
\ 'filetype': 'html',
\ 'name': 'eslint',
\ 'redirect': 'javascript/eslint'})
" vim: set sw=4 sts=4 et fdm=marker:

View File

@ -0,0 +1,46 @@
"============================================================================
"File: html.vim
"Description: Syntax checking plugin for syntastic
"Maintainer: LCD 47 <lcd047 at gmail dot com>
"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
" Want To Public License, Version 2, as published by Sam Hocevar.
" See http://sam.zoy.org/wtfpl/COPYING for more details.
"
"============================================================================
if exists('g:loaded_syntastic_html_htmlhint_checker')
finish
endif
let g:loaded_syntastic_html_htmlhint_checker = 1
let s:save_cpo = &cpo
set cpo&vim
function! SyntaxCheckers_html_htmlhint_IsAvailable() dict
if !executable(self.getExec())
return 0
endif
return syntastic#util#versionIsAtLeast(self.getVersion(), [0, 9, 13])
endfunction
function! SyntaxCheckers_html_htmlhint_GetLocList() dict
let makeprg = self.makeprgBuild({ 'args_before': '--format unix' })
let errorformat = '%f:%l:%c: %m'
return SyntasticMake({
\ 'makeprg': makeprg,
\ 'errorformat': errorformat,
\ 'returns': [0, 1] })
endfunction
call g:SyntasticRegistry.CreateAndRegisterChecker({
\ 'filetype': 'html',
\ 'name': 'htmlhint'})
let &cpo = s:save_cpo
unlet s:save_cpo
" vim: set sw=4 sts=4 et fdm=marker:

View File

@ -0,0 +1,23 @@
"============================================================================
"File: proselint.vim
"Description: Syntax checking plugin for syntastic
"Maintainer: LCD 47 <lcd047 at gmail dot com>
"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
" Want To Public License, Version 2, as published by Sam Hocevar.
" See http://sam.zoy.org/wtfpl/COPYING for more details.
"
"============================================================================
if exists('g:loaded_syntastic_html_proselint_checker')
finish
endif
let g:loaded_syntastic_html_proselint_checker = 1
call g:SyntasticRegistry.CreateAndRegisterChecker({
\ 'filetype': 'html',
\ 'name': 'proselint',
\ 'redirect': 'text/proselint'})
" vim: set sw=4 sts=4 et fdm=marker:

View File

@ -25,7 +25,7 @@ function! SyntaxCheckers_javascript_flow_IsAvailable() dict
if !executable(self.getExec())
return 0
endif
return syntastic#util#versionIsAtLeast(self.getVersion(), [0, 6])
return syntastic#util#versionIsAtLeast(self.getVersion(self.getExecEscaped() . ' version'), [0, 18, 1])
endfunction
function! SyntaxCheckers_javascript_flow_GetLocList() dict

View File

@ -0,0 +1,53 @@
"============================================================================
"File: tern_lint.vim
"Description: Syntax checking plugin for syntastic
"Maintainer: LCD 47 <lcd047@gmail.com>
"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
" Want To Public License, Version 2, as published by Sam Hocevar.
" See http://sam.zoy.org/wtfpl/COPYING for more details.
"============================================================================
if exists('g:loaded_syntastic_javascript_tern_lint_checker')
finish
endif
let g:loaded_syntastic_javascript_tern_lint_checker = 1
let s:save_cpo = &cpo
set cpo&vim
function! SyntaxCheckers_javascript_tern_lint_IsAvailable() dict
return has('byte_offset') && executable(self.getExec())
endfunction
function! SyntaxCheckers_javascript_tern_lint_GetLocList() dict
let makeprg = self.makeprgBuild({})
let errorformat = '%f:%t:%l:%c:%n:%m'
let loclist = SyntasticMake({
\ 'makeprg': makeprg,
\ 'errorformat': errorformat,
\ 'preprocess': 'tern_lint',
\ 'returns': [0] })
for e in loclist
if get(e, 'col', 0) && get(e, 'nr', 0)
let e['hl'] = '\%>' . (e['col'] - 1) . 'c\%<' . (e['nr'] + 1) . 'c'
endif
let e['nr'] = 0
endfor
return loclist
endfunction
call g:SyntasticRegistry.CreateAndRegisterChecker({
\ 'filetype': 'javascript',
\ 'name': 'tern_lint',
\ 'exec': 'tern-lint' })
let &cpo = s:save_cpo
unlet s:save_cpo
" vim: set sw=4 sts=4 et fdm=marker:

View File

@ -47,7 +47,7 @@ endfunction
function! SyntaxCheckers_lua_luac_GetLocList() dict
let makeprg = self.makeprgBuild({ 'args_after': '-p' })
let errorformat = 'luac: %#%f:%l: %m'
let errorformat = '%*\f: %#%f:%l: %m'
return SyntasticMake({
\ 'makeprg': makeprg,

View File

@ -0,0 +1,23 @@
"============================================================================
"File: proselint.vim
"Description: Syntax checking plugin for syntastic
"Maintainer: LCD 47 <lcd047 at gmail dot com>
"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
" Want To Public License, Version 2, as published by Sam Hocevar.
" See http://sam.zoy.org/wtfpl/COPYING for more details.
"
"============================================================================
if exists('g:loaded_syntastic_markdown_proselint_checker')
finish
endif
let g:loaded_syntastic_markdown_proselint_checker = 1
call g:SyntasticRegistry.CreateAndRegisterChecker({
\ 'filetype': 'markdown',
\ 'name': 'proselint',
\ 'redirect': 'text/proselint'})
" vim: set sw=4 sts=4 et fdm=marker:

View File

@ -19,7 +19,7 @@ let s:save_cpo = &cpo
set cpo&vim
function! SyntaxCheckers_matlab_mlint_GetLocList() dict
let makeprg = self.makeprgBuild({ 'args_after': '-id $*' })
let makeprg = self.makeprgBuild({ 'args_after': '-id' })
let errorformat =
\ 'L %l (C %c): %*[a-zA-Z0-9]: %m,'.

View File

@ -20,7 +20,7 @@ set cpo&vim
function! SyntaxCheckers_nasm_nasm_GetLocList() dict
let makeprg = self.makeprgBuild({
\ 'args_after': '-X gnu -f elf' .
\ 'args_after': '-X gnu' .
\ ' -I ' . syntastic#util#shescape(expand('%:p:h', 1) . syntastic#util#Slash()) .
\ ' ' . syntastic#c#NullOutput() })

View File

@ -0,0 +1,23 @@
"============================================================================
"File: proselint.vim
"Description: Syntax checking plugin for syntastic
"Maintainer: LCD 47 <lcd047 at gmail dot com>
"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
" Want To Public License, Version 2, as published by Sam Hocevar.
" See http://sam.zoy.org/wtfpl/COPYING for more details.
"
"============================================================================
if exists('g:loaded_syntastic_nroff_proselint_checker')
finish
endif
let g:loaded_syntastic_nroff_proselint_checker = 1
call g:SyntasticRegistry.CreateAndRegisterChecker({
\ 'filetype': 'nroff',
\ 'name': 'proselint',
\ 'redirect': 'text/proselint'})
" vim: set sw=4 sts=4 et fdm=marker:

View File

@ -1,6 +1,6 @@
"============================================================================
"File: perl.vim
"Description: Syntax checking plugin for syntastic.vim
"Description: Syntax checking plugin for syntastic
"Maintainer: Anthony Carapetis <anthony.carapetis at gmail dot com>,
" Eric Harmon <http://eharmon.net>
"License: This program is free software. It comes without any warranty,
@ -23,7 +23,7 @@
"
" let g:syntastic_enable_perl_checker = 1
"
" References:
" Reference:
"
" - http://perldoc.perl.org/perlrun.html#*-c*
@ -55,15 +55,15 @@ function! SyntaxCheckers_perl_perl_GetLocList() dict " {{{1
call syntastic#log#oneTimeWarn('variable g:syntastic_perl_lib_path should be a list')
let includes = split(g:syntastic_perl_lib_path, ',')
else
let includes = copy(syntastic#util#var('perl_lib_path'))
let includes = copy(syntastic#util#var('perl_lib_path', []))
endif
let shebang = syntastic#util#parseShebang()
let extra = join(map(includes, '"-I" . v:val')) .
\ (index(shebang['args'], '-T') >= 0 ? ' -T' : '') .
\ (index(shebang['args'], '-t') >= 0 ? ' -t' : '')
let extra = map(includes, '"-I" . v:val') +
\ (index(shebang['args'], '-T') >= 0 ? ['-T'] : []) +
\ (index(shebang['args'], '-t') >= 0 ? ['-t'] : [])
let errorformat = '%f:%l:%m'
let makeprg = self.makeprgBuild({ 'args_before': '-c -X ' . extra })
let makeprg = self.makeprgBuild({ 'args_before': ['-c', '-X '] + extra })
let errors = SyntasticMake({
\ 'makeprg': makeprg,
@ -74,7 +74,7 @@ function! SyntaxCheckers_perl_perl_GetLocList() dict " {{{1
return errors
endif
let makeprg = self.makeprgBuild({ 'args_before': '-c -Mwarnings ' . extra })
let makeprg = self.makeprgBuild({ 'args_before': ['-c', '-Mwarnings'] + extra })
return SyntasticMake({
\ 'makeprg': makeprg,

View File

@ -0,0 +1,23 @@
"============================================================================
"File: proselint.vim
"Description: Syntax checking plugin for syntastic
"Maintainer: LCD 47 <lcd047 at gmail dot com>
"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
" Want To Public License, Version 2, as published by Sam Hocevar.
" See http://sam.zoy.org/wtfpl/COPYING for more details.
"
"============================================================================
if exists('g:loaded_syntastic_pod_proselint_checker')
finish
endif
let g:loaded_syntastic_pod_proselint_checker = 1
call g:SyntasticRegistry.CreateAndRegisterChecker({
\ 'filetype': 'pod',
\ 'name': 'proselint',
\ 'redirect': 'text/proselint'})
" vim: set sw=4 sts=4 et fdm=marker:

View File

@ -1,6 +1,6 @@
"============================================================================
"File: pep8.vim
"Description: Syntax checking plugin for syntastic.vim
"Description: Syntax checking plugin for syntastic
"Maintainer: LCD 47 <lcd047 at gmail dot com>
"License: This program is free software. It comes without any warranty,
" to the extent permitted by applicable law. You can redistribute
@ -15,34 +15,9 @@ if exists('g:loaded_syntastic_python_pep8_checker')
endif
let g:loaded_syntastic_python_pep8_checker = 1
let s:save_cpo = &cpo
set cpo&vim
function! SyntaxCheckers_python_pep8_GetLocList() dict
let makeprg = self.makeprgBuild({})
let errorformat = '%f:%l:%c: %m'
let env = syntastic#util#isRunningWindows() ? {} : { 'TERM': 'dumb' }
let loclist = SyntasticMake({
\ 'makeprg': makeprg,
\ 'errorformat': errorformat,
\ 'env': env,
\ 'subtype': 'Style' })
for e in loclist
let e['type'] = e['text'] =~? '^W' ? 'W' : 'E'
endfor
return loclist
endfunction
call g:SyntasticRegistry.CreateAndRegisterChecker({
\ 'filetype': 'python',
\ 'name': 'pep8'})
let &cpo = s:save_cpo
unlet s:save_cpo
\ 'name': 'pep8',
\ 'redirect': 'python/pycodestyle'})
" vim: set sw=4 sts=4 et fdm=marker:

View File

@ -0,0 +1,48 @@
"============================================================================
"File: pycodestyle.vim
"Description: Syntax checking plugin for syntastic
"Maintainer: LCD 47 <lcd047 at gmail dot com>
"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
" Want To Public License, Version 2, as published by Sam Hocevar.
" See http://sam.zoy.org/wtfpl/COPYING for more details.
"
"============================================================================
if exists('g:loaded_syntastic_python_pycodestyle_checker')
finish
endif
let g:loaded_syntastic_python_pycodestyle_checker = 1
let s:save_cpo = &cpo
set cpo&vim
function! SyntaxCheckers_python_pycodestyle_GetLocList() dict
let makeprg = self.makeprgBuild({})
let errorformat = '%f:%l:%c: %m'
let env = syntastic#util#isRunningWindows() ? {} : { 'TERM': 'dumb' }
let loclist = SyntasticMake({
\ 'makeprg': makeprg,
\ 'errorformat': errorformat,
\ 'env': env,
\ 'subtype': 'Style' })
for e in loclist
let e['type'] = e['text'] =~? '^W' ? 'W' : 'E'
endfor
return loclist
endfunction
call g:SyntasticRegistry.CreateAndRegisterChecker({
\ 'filetype': 'python',
\ 'name': 'pycodestyle'})
let &cpo = s:save_cpo
unlet s:save_cpo
" vim: set sw=4 sts=4 et fdm=marker:

View File

@ -42,7 +42,8 @@ endfunction
call g:SyntasticRegistry.CreateAndRegisterChecker({
\ 'filetype': 'racket',
\ 'name': 'racket'})
\ 'name': 'racket',
\ 'enable': 'enable_racket_racket_checker' })
let &cpo = s:save_cpo
unlet s:save_cpo

View File

@ -0,0 +1,23 @@
"============================================================================
"File: proselint.vim
"Description: Syntax checking plugin for syntastic
"Maintainer: LCD 47 <lcd047 at gmail dot com>
"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
" Want To Public License, Version 2, as published by Sam Hocevar.
" See http://sam.zoy.org/wtfpl/COPYING for more details.
"
"============================================================================
if exists('g:loaded_syntastic_rst_proselint_checker')
finish
endif
let g:loaded_syntastic_rst_proselint_checker = 1
call g:SyntasticRegistry.CreateAndRegisterChecker({
\ 'filetype': 'rst',
\ 'name': 'proselint',
\ 'redirect': 'text/proselint'})
" vim: set sw=4 sts=4 et fdm=marker:

View File

@ -0,0 +1,51 @@
"============================================================================
"File: sass_lint.vim
"Description: Syntax checking plugin for syntastic
"Maintainer: LCD 47 <lcd047 at gmail dot com>
"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
" Want To Public License, Version 2, as published by Sam Hocevar.
" See http://sam.zoy.org/wtfpl/COPYING for more details.
"
"============================================================================
if exists('g:loaded_syntastic_sass_sass_lint_checker')
finish
endif
let g:loaded_syntastic_sass_sass_lint_checker = 1
let s:save_cpo = &cpo
set cpo&vim
function! SyntaxCheckers_sass_sass_lint_IsAvailable() dict
if !executable(self.getExec())
return 0
endif
return syntastic#util#versionIsAtLeast(self.getVersion(), [1, 5])
endfunction
function! SyntaxCheckers_sass_sass_lint_GetLocList() dict
let makeprg = self.makeprgBuild({
\ 'args': '-v',
\ 'args_after': '-q -f compact' })
let errorformat =
\ '%f: line %l\, col %c\, %trror - %m,' .
\ '%f: line %l\, col %c\, %tarning - %m'
return SyntasticMake({
\ 'makeprg': makeprg,
\ 'errorformat': errorformat,
\ 'returns': [0, 1] })
endfunction
call g:SyntasticRegistry.CreateAndRegisterChecker({
\ 'filetype': 'sass',
\ 'name': 'sass_lint',
\ 'exec': 'sass-lint' })
let &cpo = s:save_cpo
unlet s:save_cpo
" vim: set sw=4 sts=4 et fdm=marker:

View File

@ -25,11 +25,12 @@ function! SyntaxCheckers_scala_fsc_GetLocList() dict
" working directory changing after being started
" that's why we better pass an absolute path
let makeprg = self.makeprgBuild({
\ 'args_after': '-Ystop-after:parser',
\ 'args': '-Ystop-after:parser',
\ 'fname': syntastic#util#shexpand('%:p') })
let errorformat =
\ '%E%f:%l: %trror: %m,' .
\ '%W%f:%l: %tarning:%m,' .
\ '%Z%p^,' .
\ '%-G%.%#'

View File

@ -0,0 +1,23 @@
"============================================================================
"File: sass_lint.vim
"Description: Syntax checking plugin for syntastic
"Maintainer: LCD 47 <lcd047 at gmail dot com>
"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
" Want To Public License, Version 2, as published by Sam Hocevar.
" See http://sam.zoy.org/wtfpl/COPYING for more details.
"
"============================================================================
if exists('g:loaded_syntastic_scss_sass_lint_checker')
finish
endif
let g:loaded_syntastic_scss_sass_lint_checker = 1
call g:SyntasticRegistry.CreateAndRegisterChecker({
\ 'filetype': 'scss',
\ 'name': 'sass_lint',
\ 'redirect': 'sass/sass_lint'})
" vim: set sw=4 sts=4 et fdm=marker:

View File

@ -0,0 +1,38 @@
"============================================================================
"File: solc.vim
"Description: Solidity syntax checker - using solc
"Maintainer: Jacob Cholewa <jacob@cholewa.dk>
"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
" Want To Public License, Version 2, as published by Sam Hocevar.
" See http://sam.zoy.org/wtfpl/COPYING for more details.
"
"============================================================================
if exists('g:loaded_syntastic_solidity_solc_checker')
finish
endif
let g:loaded_syntastic_solidity_solc_checker = 1
let s:save_cpo = &cpo
set cpo&vim
function! SyntaxCheckers_solidity_solc_GetLocList() dict
let makeprg = self.makeprgBuild({})
let errorformat = '%f:%l:%c: %trror: %m'
return SyntasticMake({
\ 'makeprg': makeprg,
\ 'errorformat': errorformat })
endfunction
call g:SyntasticRegistry.CreateAndRegisterChecker({
\ 'filetype': 'solidity',
\ 'name': 'solc'})
let &cpo = s:save_cpo
unlet s:save_cpo
" vim: set sw=4 sts=4 et fdm=marker:

View File

@ -19,13 +19,25 @@ let s:save_cpo = &cpo
set cpo&vim
function! SyntaxCheckers_stylus_stylint_GetLocList() dict
if !exists('s:stylint_new')
let s:stylint_new = syntastic#util#versionIsAtLeast(self.getVersion(), [1, 5, 7])
endif
let makeprg = self.makeprgBuild({})
let errorformat =
\ '%WWarning: %m,' .
\ '%EError: %m,' .
\ '%CFile: %f,' .
\ '%CLine: %l:%.%#'
if s:stylint_new
let errorformat =
\ '%P%f,' .
\ '%-Q,' .
\ '%\m%l:%c%\s%\+%t%\%%(rror%\|arning%\)%\s%\+%m%\s%\+%\S%\+%\s%#,' .
\ '%\m%l%\s%\+%t%\%%(rror%\|arning%\)%\s%\+%m%\s%\+%\S%\+%\s%#'
else
let errorformat =
\ '%WWarning: %m,' .
\ '%EError: %m,' .
\ '%CFile: %f,' .
\ '%CLine: %l:%.%#'
endif
return SyntasticMake({
\ 'makeprg': makeprg,

View File

@ -0,0 +1,23 @@
"============================================================================
"File: proselint.vim
"Description: Syntax checking plugin for syntastic
"Maintainer: LCD 47 <lcd047 at gmail dot com>
"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
" Want To Public License, Version 2, as published by Sam Hocevar.
" See http://sam.zoy.org/wtfpl/COPYING for more details.
"
"============================================================================
if exists('g:loaded_syntastic_tex_proselint_checker')
finish
endif
let g:loaded_syntastic_tex_proselint_checker = 1
call g:SyntasticRegistry.CreateAndRegisterChecker({
\ 'filetype': 'tex',
\ 'name': 'proselint',
\ 'redirect': 'text/proselint'})
" vim: set sw=4 sts=4 et fdm=marker:

View File

@ -0,0 +1,23 @@
"============================================================================
"File: proselint.vim
"Description: Syntax checking plugin for syntastic
"Maintainer: LCD 47 <lcd047 at gmail dot com>
"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
" Want To Public License, Version 2, as published by Sam Hocevar.
" See http://sam.zoy.org/wtfpl/COPYING for more details.
"
"============================================================================
if exists('g:loaded_syntastic_texinfo_proselint_checker')
finish
endif
let g:loaded_syntastic_texinfo_proselint_checker = 1
call g:SyntasticRegistry.CreateAndRegisterChecker({
\ 'filetype': 'texinfo',
\ 'name': 'proselint',
\ 'redirect': 'text/proselint'})
" vim: set sw=4 sts=4 et fdm=marker:

View File

@ -0,0 +1,45 @@
"============================================================================
"File: proselint.vim
"Description: Syntax checking plugin for syntastic
"Maintainer: LCD 47 <lcd047 at gmail dot com>
"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
" Want To Public License, Version 2, as published by Sam Hocevar.
" See http://sam.zoy.org/wtfpl/COPYING for more details.
"
"============================================================================
if exists('g:loaded_syntastic_text_proselint_checker')
finish
endif
let g:loaded_syntastic_text_proselint_checker = 1
if !exists('g:syntastic_text_proselint_sort')
let g:syntastic_text_proselint_sort = 1
endif
let s:save_cpo = &cpo
set cpo&vim
function! SyntaxCheckers_text_proselint_GetLocList() dict
let makeprg = self.makeprgBuild({})
let errorformat = '%f:%l:%c: %m'
return SyntasticMake({
\ 'makeprg': makeprg,
\ 'errorformat': errorformat,
\ 'defaults': { 'type': 'W', 'subtype': 'Style' },
\ 'preprocess': 'iconv',
\ 'returns': [0, 1] })
endfunction
call g:SyntasticRegistry.CreateAndRegisterChecker({
\ 'filetype': 'text',
\ 'name': 'proselint'})
let &cpo = s:save_cpo
unlet s:save_cpo
" vim: set sw=4 sts=4 et fdm=marker:

View File

@ -1,66 +0,0 @@
"============================================================================
"File: tsc.vim
"Description: TypeScript syntax checker
"Maintainer: Bill Casarin <bill@casarin.ca>
"
"============================================================================
if exists('g:loaded_syntastic_typescript_tsc_checker')
finish
endif
let g:loaded_syntastic_typescript_tsc_checker = 1
if !exists('g:syntastic_typescript_tsc_sort')
let g:syntastic_typescript_tsc_sort = 1
endif
let s:save_cpo = &cpo
set cpo&vim
function! SyntaxCheckers_typescript_tsc_IsAvailable() dict
if !executable(self.getExec())
return 0
endif
let version_output = split(syntastic#util#system(self.getExecEscaped() . ' --version'), '\n', 1)
let ver = filter(copy(version_output), 'v:val =~# ''\m\<Version ''')
let parsed_ver = len(ver) ? syntastic#util#parseVersion(ver[0], '\v<Version \zs\d+(\.\d+)\ze') : []
if len(parsed_ver)
call self.setVersion(parsed_ver)
let s:tsc_new = syntastic#util#versionIsAtLeast(parsed_ver, [1, 5])
else
call syntastic#log#ndebug(g:_SYNTASTIC_DEBUG_LOCLIST, 'checker output:', version_output)
call syntastic#log#error("checker typescript/tsc: can't parse version string (abnormal termination?)")
let s:tsc_new = -1
endif
return s:tsc_new >= 0
endfunction
function! SyntaxCheckers_typescript_tsc_GetLocList() dict
let makeprg = self.makeprgBuild({
\ 'args': '--module commonjs',
\ 'args_after': (s:tsc_new ? '--noEmit' : '--out ' . syntastic#util#DevNull()) })
let errorformat =
\ '%E%f %#(%l\,%c): error %m,' .
\ '%E%f %#(%l\,%c): %m,' .
\ '%Eerror %m,' .
\ '%C%\s%\+%m'
return SyntasticMake({
\ 'makeprg': makeprg,
\ 'errorformat': errorformat,
\ 'postprocess': ['guards'],
\ 'defaults': {'bufnr': bufnr('')} })
endfunction
call g:SyntasticRegistry.CreateAndRegisterChecker({
\ 'filetype': 'typescript',
\ 'name': 'tsc'})
let &cpo = s:save_cpo
unlet s:save_cpo
" vim: set sw=4 sts=4 et fdm=marker:

View File

@ -41,35 +41,37 @@ endfunction " }}}1
" Utilities {{{1
function! s:GetValaModules() " {{{2
if exists('g:syntastic_vala_modules')
if type(g:syntastic_vala_modules) == type('')
return split(g:syntastic_vala_modules, '\s\+')
elseif type(g:syntastic_vala_modules) == type([])
return copy(g:syntastic_vala_modules)
if exists('g:syntastic_vala_modules') || exists('b:syntastic_vala_modules')
let modules = syntastic#util#var('vala_modules')
if type(modules) == type('')
return split(modules, '\m\s\+')
elseif type(modules) == type([])
return copy(modules)
else
echoerr 'g:syntastic_vala_modules must be either list or string: fallback to in file modules string'
echoerr 'syntastic_vala_modules must be either list or string: fallback to in file modules string'
endif
endif
let modules_line = search('^// modules: ', 'n')
let modules_str = getline(modules_line)
return split(strpart(modules_str, 12), '\s\+')
return split(strpart(modules_str, 12), '\m\s\+')
endfunction " }}}2
function! s:GetValaVapiDirs() " {{{2
if exists('g:syntastic_vala_vapi_dirs')
if type(g:syntastic_vala_vapi_dirs) == type('')
return split(g:syntastic_vala_vapi_dirs, '\s\+')
elseif type(g:syntastic_vala_vapi_dirs) == type([])
return copy(g:syntastic_vala_vapi_dirs)
if exists('g:syntastic_vala_vapi_dirs') || exists('b:syntastic_vala_vapi_dirs')
let vapi_dirs = syntastic#util#var('vala_vapi_dirs')
if type(vapi_dirs) == type('')
return split(vapi_dirs, '\m\s\+')
elseif type(vapi_dirs) == type([])
return copy(vapi_dirs)
else
echoerr 'g:syntastic_vala_vapi_dirs must be either a list, or a string: fallback to in-file modules string'
echoerr 'syntastic_vala_vapi_dirs must be either a list, or a string: fallback to in-file modules string'
endif
endif
let vapi_line = search('^//\s*vapidirs:\s*','n')
let vapi_str = getline(vapi_line)
return split( substitute( vapi_str, '^//\s*vapidirs:\s*', '', 'g' ), '\s\+' )
return split( substitute( vapi_str, '\m^//\s*vapidirs:\s*', '', 'g' ), '\m\s\+' )
endfunction " }}}2
" }}}1

View File

@ -67,9 +67,10 @@ function! SyntaxCheckers_vim_vimlint_GetLocList() dict " {{{1
\ 'EVL204': 3,
\ 'EVL205': 3 }
if exists('g:syntastic_vimlint_options')
if type(g:syntastic_vimlint_options) == type({})
let options = filter(copy(g:syntastic_vimlint_options), 'v:key =~# "\\m^EVL"')
if exists('g:syntastic_vimlint_options') || exists('b:syntastic_vimlint_options')
let opts = syntastic#util#var('vimlint_options')
if type(opts) == type({})
let options = filter(copy(opts), 'v:key =~# "\\m^EVL"')
call extend(param, options, 'force')
endif
endif
@ -98,8 +99,7 @@ endfunction " }}}2
call g:SyntasticRegistry.CreateAndRegisterChecker({
\ 'filetype': 'vim',
\ 'name': 'vimlint',
\ 'exec': '' })
\ 'name': 'vimlint' })
let &cpo = s:save_cpo
unlet s:save_cpo

View File

@ -0,0 +1,23 @@
"============================================================================
"File: proselint.vim
"Description: Syntax checking plugin for syntastic
"Maintainer: LCD 47 <lcd047 at gmail dot com>
"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
" Want To Public License, Version 2, as published by Sam Hocevar.
" See http://sam.zoy.org/wtfpl/COPYING for more details.
"
"============================================================================
if exists('g:loaded_syntastic_xhtml_proselint_checker')
finish
endif
let g:loaded_syntastic_xhtml_proselint_checker = 1
call g:SyntasticRegistry.CreateAndRegisterChecker({
\ 'filetype': 'xhtml',
\ 'name': 'proselint',
\ 'redirect': 'text/proselint'})
" vim: set sw=4 sts=4 et fdm=marker:

1
sources_non_forked/tabular/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/doc/tags

View File

@ -0,0 +1,24 @@
Copyright (c) 2016, Matthew J. Wozniski
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* The names of the contributors may not be used to endorse or promote
products derived from this software without specific prior written
permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER ``AS IS'' AND ANY EXPRESS
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

View File

@ -0,0 +1,29 @@
Tabular
==============
Sometimes, it's useful to line up text. Naturally, it's nicer to have the
computer do this for you, since aligning things by hand quickly becomes
unpleasant. While there are other plugins for aligning text, the ones I've
tried are either impossibly difficult to understand and use, or too simplistic
to handle complicated tasks. This plugin aims to make the easy things easy
and the hard things possible, without providing an unnecessarily obtuse
interface. It's still a work in progress, and criticisms are welcome.
See [Aligning Text with Tabular.vim](http://vimcasts.org/episodes/aligning-text-with-tabular-vim/)
for a screencast that shows how Tabular.vim works.
See [doc/Tabular.txt](http://raw.github.com/godlygeek/tabular/master/doc/Tabular.txt)
for detailed documentation.
Installation
==============
If you don't have a preferred installation method, I recommend installing
[pathogen.vim](https://github.com/tpope/vim-pathogen), and then simply
copy and paste:
mkdir -p ~/.vim/bundle
cd ~/.vim/bundle
git clone git://github.com/godlygeek/tabular.git
Once help tags have been generated (either using Pathogen's `:Helptags`
command, or by pointing vim's `:helptags` command at the directory where you
installed Tabular), you can view the manual with `:help tabular`.

View File

@ -0,0 +1,73 @@
" Copyright (c) 2016, Matthew J. Wozniski
" All rights reserved.
"
" Redistribution and use in source and binary forms, with or without
" modification, are permitted provided that the following conditions are met:
" * Redistributions of source code must retain the above copyright notice,
" this list of conditions and the following disclaimer.
" * Redistributions in binary form must reproduce the above copyright
" notice, this list of conditions and the following disclaimer in the
" documentation and/or other materials provided with the distribution.
" * The names of the contributors may not be used to endorse or promote
" products derived from this software without specific prior written
" permission.
"
" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER ``AS IS'' AND ANY EXPRESS
" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
" NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY DIRECT, INDIRECT,
" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
" OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
" LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
" NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
" EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
if !exists(':Tabularize') || get(g:, 'no_default_tabular_maps', 0)
finish " Tabular.vim wasn't loaded or the default maps are unwanted
endif
let s:save_cpo = &cpo
set cpo&vim
AddTabularPattern! assignment /[|&+*/%<>=!~-]\@<!\([<>!=]=\|=\~\)\@![|&+*/%<>=!~-]*=/l1r1
AddTabularPattern! two_spaces / /l0
AddTabularPipeline! multiple_spaces / / map(a:lines, "substitute(v:val, ' *', ' ', 'g')") | tabular#TabularizeStrings(a:lines, ' ', 'l0')
AddTabularPipeline! argument_list /(.*)/ map(a:lines, 'substitute(v:val, ''\s*\([(,)]\)\s*'', ''\1'', ''g'')')
\ | tabular#TabularizeStrings(a:lines, '[(,)]', 'l0')
\ | map(a:lines, 'substitute(v:val, ''\(\s*\),'', '',\1 '', "g")')
\ | map(a:lines, 'substitute(v:val, ''\s*)'', ")", "g")')
function! SplitCDeclarations(lines)
let rv = []
for line in a:lines
" split the line into declaractions
let split = split(line, '\s*[,;]\s*')
" separate the type from the first declaration
let type = substitute(split[0], '\%(\%([&*]\s*\)*\)\=\k\+$', '', '')
" add the ; back on every declaration
call map(split, 'v:val . ";"')
" add the first element to the return as-is, and remove it from the list
let rv += [ remove(split, 0) ]
" transform the other elements by adding the type on at the beginning
call map(split, 'type . v:val')
" and add them all to the return
let rv += split
endfor
return rv
endfunction
AddTabularPipeline! split_declarations /,.*;/ SplitCDeclarations(a:lines)
AddTabularPattern! ternary_operator /^.\{-}\zs?\|:/l1
AddTabularPattern! cpp_io /<<\|>>/l1
AddTabularPattern! pascal_assign /:=/l1
AddTabularPattern! trailing_c_comments /\/\*\|\*\/\|\/\//l1
let &cpo = s:save_cpo
unlet s:save_cpo

View File

@ -0,0 +1,409 @@
" Tabular: Align columnar data using regex-designated column boundaries
" Maintainer: Matthew Wozniski (godlygeek@gmail.com)
" Date: Thu, 03 May 2012 20:49:32 -0400
" Version: 1.0
"
" Long Description:
" Sometimes, it's useful to line up text. Naturally, it's nicer to have the
" computer do this for you, since aligning things by hand quickly becomes
" unpleasant. While there are other plugins for aligning text, the ones I've
" tried are either impossibly difficult to understand and use, or too simplistic
" to handle complicated tasks. This plugin aims to make the easy things easy
" and the hard things possible, without providing an unnecessarily obtuse
" interface. It's still a work in progress, and criticisms are welcome.
"
" License:
" Copyright (c) 2012, Matthew J. Wozniski
" All rights reserved.
"
" Redistribution and use in source and binary forms, with or without
" modification, are permitted provided that the following conditions are met:
" * Redistributions of source code must retain the above copyright notice,
" this list of conditions and the following disclaimer.
" * Redistributions in binary form must reproduce the above copyright
" notice, this list of conditions and the following disclaimer in the
" documentation and/or other materials provided with the distribution.
" * The names of the contributors may not be used to endorse or promote
" products derived from this software without specific prior written
" permission.
"
" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER ``AS IS'' AND ANY EXPRESS
" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
" NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY DIRECT, INDIRECT,
" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
" OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
" LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
" NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
" EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
" Stupid vimscript crap {{{1
let s:savecpo = &cpo
set cpo&vim
" Private Functions {{{1
" Return the number of bytes in a string after expanding tabs to spaces. {{{2
" This expansion is done based on the current value of 'tabstop'
if exists('*strdisplaywidth')
" Needs vim 7.3
let s:Strlen = function("strdisplaywidth")
else
function! s:Strlen(string)
" Implement the tab handling part of strdisplaywidth for vim 7.2 and
" earlier - not much that can be done about handling doublewidth
" characters.
let rv = 0
let i = 0
for char in split(a:string, '\zs')
if char == "\t"
let rv += &ts - i
let i = 0
else
let rv += 1
let i = (i + 1) % &ts
endif
endfor
return rv
endfunction
endif
" Align a string within a field {{{2
" These functions do not trim leading and trailing spaces.
" Right align 'string' in a field of size 'fieldwidth'
function! s:Right(string, fieldwidth)
let spaces = a:fieldwidth - s:Strlen(a:string)
return matchstr(a:string, '^\s*') . repeat(" ", spaces) . substitute(a:string, '^\s*', '', '')
endfunction
" Left align 'string' in a field of size 'fieldwidth'
function! s:Left(string, fieldwidth)
let spaces = a:fieldwidth - s:Strlen(a:string)
return a:string . repeat(" ", spaces)
endfunction
" Center align 'string' in a field of size 'fieldwidth'
function! s:Center(string, fieldwidth)
let spaces = a:fieldwidth - s:Strlen(a:string)
let right = spaces / 2
let left = right + (right * 2 != spaces)
return repeat(" ", left) . a:string . repeat(" ", right)
endfunction
" Remove spaces around a string {{{2
" Remove all trailing spaces from a string.
function! s:StripTrailingSpaces(string)
return matchstr(a:string, '^.\{-}\ze\s*$')
endfunction
" Remove all leading spaces from a string.
function! s:StripLeadingSpaces(string)
return matchstr(a:string, '^\s*\zs.*$')
endfunction
" Split a string into fields and delimiters {{{2
" Like split(), but include the delimiters as elements
" All odd numbered elements are delimiters
" All even numbered elements are non-delimiters (including zero)
function! s:SplitDelim(string, delim)
let rv = []
let beg = 0
let len = len(a:string)
let searchoff = 0
while 1
let mid = match(a:string, a:delim, beg + searchoff, 1)
if mid == -1 || mid == len
break
endif
let matchstr = matchstr(a:string, a:delim, beg + searchoff, 1)
let length = strlen(matchstr)
if length == 0 && beg == mid
" Zero-length match for a zero-length delimiter - advance past it
let searchoff += 1
continue
endif
if beg == mid
let rv += [ "" ]
else
let rv += [ a:string[beg : mid-1] ]
endif
let rv += [ matchstr ]
let beg = mid + length
let searchoff = 0
endwhile
let rv += [ strpart(a:string, beg) ]
return rv
endfunction
" Replace lines from `start' to `start + len - 1' with the given strings. {{{2
" If more lines are needed to show all strings, they will be added.
" If there are too few strings to fill all lines, lines will be removed.
function! s:SetLines(start, len, strings)
if a:start > line('$') + 1 || a:start < 1
throw "Invalid start line!"
endif
if len(a:strings) > a:len
let fensave = &fen
let view = winsaveview()
call append(a:start + a:len - 1, repeat([''], len(a:strings) - a:len))
call winrestview(view)
let &fen = fensave
elseif len(a:strings) < a:len
let fensave = &fen
let view = winsaveview()
sil exe (a:start + len(a:strings)) . ',' . (a:start + a:len - 1) . 'd_'
call winrestview(view)
let &fen = fensave
endif
call setline(a:start, a:strings)
endfunction
" Runs the given commandstring argument as an expression. {{{2
" The commandstring expression is expected to reference the a:lines argument.
" If the commandstring expression returns a list the items of that list will
" replace the items in a:lines, otherwise the expression is assumed to have
" modified a:lines itself.
function! s:FilterString(lines, commandstring)
exe 'let rv = ' . a:commandstring
if type(rv) == type(a:lines) && rv isnot a:lines
call filter(a:lines, 0)
call extend(a:lines, rv)
endif
endfunction
" Public API {{{1
if !exists("g:tabular_default_format")
let g:tabular_default_format = "l1"
endif
let s:formatelempat = '\%([lrc]\d\+\)'
function! tabular#ElementFormatPattern()
return s:formatelempat
endfunction
" Given a list of strings and a delimiter, split each string on every
" occurrence of the delimiter pattern, format each element according to either
" the provided format (optional) or the default format, and join them back
" together with enough space padding to guarantee that the nth delimiter of
" each string is aligned.
function! tabular#TabularizeStrings(strings, delim, ...)
if a:0 > 1
echoerr "TabularizeStrings accepts only 2 or 3 arguments (got ".(a:0+2).")"
return 1
endif
let formatstr = (a:0 ? a:1 : g:tabular_default_format)
if formatstr !~? s:formatelempat . '\+'
echoerr "Tabular: Invalid format \"" . formatstr . "\" specified!"
return 1
endif
let format = split(formatstr, s:formatelempat . '\zs')
let lines = map(a:strings, 's:SplitDelim(v:val, a:delim)')
" Strip spaces
" - Only from non-delimiters; spaces in delimiters must have been matched
" intentionally
" - Don't strip leading spaces from the first element; we like indenting.
for line in lines
if len(line) == 1 && s:do_gtabularize
continue " Leave non-matching lines unchanged for GTabularize
endif
if line[0] !~ '^\s*$'
let line[0] = s:StripTrailingSpaces(line[0])
endif
if len(line) >= 3
for i in range(2, len(line)-1, 2)
let line[i] = s:StripLeadingSpaces(s:StripTrailingSpaces(line[i]))
endfor
endif
endfor
" Find the max length of each field
let maxes = []
for line in lines
if len(line) == 1 && s:do_gtabularize
continue " non-matching lines don't affect field widths for GTabularize
endif
for i in range(len(line))
if i == len(maxes)
let maxes += [ s:Strlen(line[i]) ]
else
let maxes[i] = max( [ maxes[i], s:Strlen(line[i]) ] )
endif
endfor
endfor
let lead_blank = empty(filter(copy(lines), 'v:val[0] =~ "\\S"'))
" Concatenate the fields, according to the format pattern.
for idx in range(len(lines))
let line = lines[idx]
if len(line) == 1 && s:do_gtabularize
let lines[idx] = line[0] " GTabularize doesn't change non-matching lines
continue
endif
for i in range(len(line))
let how = format[i % len(format)][0]
let pad = format[i % len(format)][1:-1]
if how =~? 'l'
let field = s:Left(line[i], maxes[i])
elseif how =~? 'r'
let field = s:Right(line[i], maxes[i])
elseif how =~? 'c'
let field = s:Center(line[i], maxes[i])
endif
let line[i] = field . (lead_blank && i == 0 ? '' : repeat(" ", pad))
endfor
let lines[idx] = s:StripTrailingSpaces(join(line, ''))
endfor
endfunction
" Apply 0 or more filters, in sequence, to selected text in the buffer {{{2
" The lines to be filtered are determined as follows:
" If the function is called with a range containing multiple lines, then
" those lines will be used as the range.
" If the function is called with no range or with a range of 1 line, then
" if GTabularize mode is being used,
" the range will not be adjusted
" if "includepat" is not specified,
" that 1 line will be filtered,
" if "includepat" is specified and that line does not match it,
" no lines will be filtered
" if "includepat" is specified and that line does match it,
" all contiguous lines above and below the specified line matching the
" pattern will be filtered.
"
" The remaining arguments must each be a filter to apply to the text.
" Each filter must either be a String evaluating to a function to be called.
function! tabular#PipeRange(includepat, ...) range
exe a:firstline . ',' . a:lastline
\ . 'call tabular#PipeRangeWithOptions(a:includepat, a:000, {})'
endfunction
" Extended version of tabular#PipeRange, which
" 1) Takes the list of filters as an explicit list rather than as varargs
" 2) Supports passing a dictionary of options to control the routine.
" Currently, the only supported option is 'mode', which determines whether
" to behave as :Tabularize or as :GTabularize
" This allows me to add new features here without breaking API compatibility
" in the future.
function! tabular#PipeRangeWithOptions(includepat, filterlist, options) range
let top = a:firstline
let bot = a:lastline
let s:do_gtabularize = (get(a:options, 'mode', '') ==# 'GTabularize')
if !s:do_gtabularize
" In the default mode, apply range extension logic
if a:includepat != '' && top == bot
if top < 0 || top > line('$') || getline(top) !~ a:includepat
return
endif
while top > 1 && getline(top-1) =~ a:includepat
let top -= 1
endwhile
while bot < line('$') && getline(bot+1) =~ a:includepat
let bot += 1
endwhile
endif
endif
let lines = map(range(top, bot), 'getline(v:val)')
for filter in a:filterlist
if type(filter) != type("")
echoerr "PipeRange: Bad filter: " . string(filter)
endif
call s:FilterString(lines, filter)
unlet filter
endfor
call s:SetLines(top, bot - top + 1, lines)
endfunction
" Part of the public interface so interested pipelines can query this and
" adjust their behavior appropriately.
function! tabular#DoGTabularize()
return s:do_gtabularize
endfunction
function! s:SplitDelimTest(string, delim, expected)
let result = s:SplitDelim(a:string, a:delim)
if result !=# a:expected
echomsg 'Test failed!'
echomsg ' string=' . string(a:string) . ' delim=' . string(a:delim)
echomsg ' Returned=' . string(result)
echomsg ' Expected=' . string(a:expected)
endif
endfunction
function! tabular#SplitDelimUnitTest()
let assignment = '[|&+*/%<>=!~-]\@<!\([<>!=]=\|=\~\)\@![|&+*/%<>=!~-]*='
let two_spaces = ' '
let ternary_operator = '^.\{-}\zs?\|:'
let cpp_io = '<<\|>>'
let pascal_assign = ':='
let trailing_c_comments = '\/\*\|\*\/\|\/\/'
call s:SplitDelimTest('a+=b', assignment, ['a', '+=', 'b'])
call s:SplitDelimTest('a-=b', assignment, ['a', '-=', 'b'])
call s:SplitDelimTest('a!=b', assignment, ['a!=b'])
call s:SplitDelimTest('a==b', assignment, ['a==b'])
call s:SplitDelimTest('a&=b', assignment, ['a', '&=', 'b'])
call s:SplitDelimTest('a|=b', assignment, ['a', '|=', 'b'])
call s:SplitDelimTest('a=b=c', assignment, ['a', '=', 'b', '=', 'c'])
call s:SplitDelimTest('a b c', two_spaces, ['a', ' ', 'b', ' ', 'c'])
call s:SplitDelimTest('a b c', two_spaces, ['a b', ' ', ' c'])
call s:SplitDelimTest('ab c', two_spaces, ['ab', ' ', '', ' ', 'c'])
call s:SplitDelimTest('a?b:c', ternary_operator, ['a', '?', 'b', ':', 'c'])
call s:SplitDelimTest('a<<b<<c', cpp_io, ['a', '<<', 'b', '<<', 'c'])
call s:SplitDelimTest('a:=b=c', pascal_assign, ['a', ':=', 'b=c'])
call s:SplitDelimTest('x//foo', trailing_c_comments, ['x', '//', 'foo'])
call s:SplitDelimTest('x/*foo*/',trailing_c_comments, ['x', '/*', 'foo', '*/', ''])
call s:SplitDelimTest('#ab#cd#ef', '[^#]*', ['#', 'ab', '#', 'cd', '#', 'ef', ''])
call s:SplitDelimTest('#ab#cd#ef', '#\zs', ['#', '', 'ab#', '', 'cd#', '', 'ef'])
endfunction
" Stupid vimscript crap, part 2 {{{1
let &cpo = s:savecpo
unlet s:savecpo
" vim:set sw=2 sts=2 fdm=marker:

Some files were not shown because too many files have changed in this diff Show More