mirror of
https://github.com/gryf/.vim.git
synced 2025-12-17 19:40:29 +01:00
Removed git repositories in favor of subprepos.
This commit is contained in:
18
.hgsub
Normal file
18
.hgsub
Normal file
@@ -0,0 +1,18 @@
|
||||
bundle/git_ack = [git]https://github.com/mileszs/ack.vim.git
|
||||
bundle/git_calendar = [git]https://github.com/mattn/calendar-vim.git
|
||||
bundle/git_gundo = [git]https://github.com/sjl/gundo.vim.git
|
||||
bundle/doc_git_py2stdlib = [git]https://github.com/vim-scripts/Python-2.x-Standard-Library-Reference.git
|
||||
bundle/ft_git_pyflakes-vim = [git]https://github.com/kevinw/pyflakes-vim.git
|
||||
bundle/ft_git_pydoc = [git]https://github.com/fs111/pydoc.vim.git
|
||||
bundle/git_vcscommand = [git]git://repo.or.cz/vcscommand.git
|
||||
bundle/git_tagbar = [git]https://github.com/majutsushi/tagbar.git
|
||||
bundle/git_surround = [git]https://github.com/tpope/vim-surround.git
|
||||
bundle/git_snipmate = [git]https://github.com/msanders/snipmate.vim.git
|
||||
bundle/git_repeat = [git]https://github.com/tpope/vim-repeat.git
|
||||
bundle/git_nerdcommenter = [git]https://github.com/scrooloose/nerdcommenter.git
|
||||
bundle/git_ctrlp = [git]https://github.com/kien/ctrlp.vim.git
|
||||
bundle/git_syntastic = [git]https://github.com/scrooloose/syntastic.git
|
||||
bundle/git_taglisttoo = [git]https://github.com/ervandew/taglisttoo.git
|
||||
bundle/git_gitgutter = [git]git://github.com/airblade/vim-gitgutter.git
|
||||
bundle/git_vim-javascript = [git]https://github.com/pangloss/vim-javascript.git
|
||||
bundle/git_vim-nodejs-complete = [git]https://github.com/myhere/vim-nodejs-complete.git
|
||||
18
.hgsubstate
Normal file
18
.hgsubstate
Normal file
@@ -0,0 +1,18 @@
|
||||
305b08a99a6e3e3c4df6f6936869ba69a6b21fcf bundle/doc_git_py2stdlib
|
||||
efdfd226575ab0ee4ad01c822b3e80d3a090e4d4 bundle/ft_git_pydoc
|
||||
28747f3a246312f03c79110c1b7f84e1d47cde8a bundle/ft_git_pyflakes-vim
|
||||
f183a345a0c10caed7684d07dabae33e007c7590 bundle/git_ack
|
||||
bf72f81769380d7f6328b84615032cc6a16be489 bundle/git_calendar
|
||||
c1646e3c28d75bcc834af4836f4c6e12296ba891 bundle/git_ctrlp
|
||||
3f9cf5a44d56d8356001c6c47928b2b9b19d2540 bundle/git_gitgutter
|
||||
4c376a8061fa335228da420937ce385b847dd56a bundle/git_gundo
|
||||
0b3d928dce8262dedfc2f83b9aeb59a94e4f0ae4 bundle/git_nerdcommenter
|
||||
a81bef76031ca1c71766b516417480caeb01c932 bundle/git_repeat
|
||||
f5a75d075d3c005ebe69e3f5e56cf99516e8aa3b bundle/git_snipmate
|
||||
02199ea0080d744ec76b79d74ce56d51d25cf7ae bundle/git_surround
|
||||
75a234231ba0c43883e0a84c48caf3acc1229a0e bundle/git_syntastic
|
||||
cc222f5d8c22825af2906453ebe3833dfa670689 bundle/git_tagbar
|
||||
73e67619cd3b8de34608a0e410e580587d6bcfea bundle/git_taglisttoo
|
||||
bffbab0357b89fed164dbe114649c9d82993ee1a bundle/git_vcscommand
|
||||
870ffca4738f0de1772291c580bb17f852ba36ce bundle/git_vim-javascript
|
||||
1e2f98f4366c6dec27fa8df72971fa9fa33e9f07 bundle/git_vim-nodejs-complete
|
||||
@@ -1,29 +1,18 @@
|
||||
ScriptID SourceID Filename
|
||||
--------------------------
|
||||
### plugins
|
||||
2572 10433 ack.vim
|
||||
102 16171 DirDiff.vim
|
||||
311 7645 grep.vim
|
||||
3304 18081 gundo.vim
|
||||
2727 11120 jsbeautify.vim
|
||||
2289 8922 loremipsum
|
||||
2666 18811 Mark
|
||||
1218 14455 nerdcommenter
|
||||
2262 8944 occur.vim
|
||||
2136 8206 repeat.vim
|
||||
152 3342 showmarks.vim
|
||||
2540 11006 snipMate.vim
|
||||
1697 12566 surround.vim
|
||||
3465 18273 Tagbar
|
||||
90 17031 vcscommand.vim
|
||||
2226 18232 vimwiki.vim
|
||||
1334 6377 vst.vim
|
||||
2321 9055 zoom.vim
|
||||
52 14880 calendar.vim
|
||||
### ftplugin
|
||||
3818 16921 MatchTag
|
||||
910 18164 pydoc.vim
|
||||
2441 14403 pyflakes.vim
|
||||
3818 19533 MatchTag
|
||||
30 9196 python_fn.vim
|
||||
435 12010 pythonhelper.vim
|
||||
2527 10034 jpythonfold.vim
|
||||
@@ -34,9 +23,6 @@ ScriptID SourceID Filename
|
||||
# changes doesn't put it on vim.org scripts. it can be (still) found on
|
||||
# http://monkey.org/~caz/python.vim
|
||||
### syntax
|
||||
790 17430 python.vim
|
||||
2651 10658 fitnesse.vim
|
||||
790 19619 python.vim
|
||||
1858 9244 mako.vim
|
||||
2539 9949 css.vim
|
||||
### doc
|
||||
3277 14056 py2stdlib
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
*ack.txt* Plugin that integrates ack with Vim
|
||||
|
||||
==============================================================================
|
||||
Author: Antoine Imbert <antoine.imbert+ackvim@gmail.com> *ack-author*
|
||||
License: Same terms as Vim itself (see |license|)
|
||||
|
||||
==============================================================================
|
||||
INTRODUCTION *ack*
|
||||
|
||||
This plugin is a front for the Perl module App::Ack. Ack can be used as a
|
||||
replacement for grep. This plugin will allow you to run ack from vim, and
|
||||
shows the results in a split window.
|
||||
|
||||
:Ack [options] {pattern} [{directory}] *:Ack*
|
||||
|
||||
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.
|
||||
|
||||
:AckAdd [options] {pattern} [{directory}] *:AckAdd*
|
||||
|
||||
Just like |:Ack| + |:grepadd|. Appends the |quickfix| with the results
|
||||
|
||||
:LAck [options] {pattern} [{directory}] *:LAck*
|
||||
|
||||
Just like |:Ack| + |:lgrep|. Searches, but opens in |location-list|
|
||||
|
||||
:LAckAdd [options] {pattern} [{directory}] *:LAckAdd*
|
||||
|
||||
Just like |:Ack| + |:lgrepadd|. Searches, but appends results to
|
||||
|location-list|
|
||||
|
||||
Files containing the search term will be listed in the split window, along
|
||||
with the line number of the occurrence, once for each occurrence. <Enter> on
|
||||
a line in this window will open the file, and place the cursor on the matching
|
||||
line.
|
||||
|
||||
See http://search.cpan.org/~petdance/ack/ack for more information.
|
||||
@@ -1,50 +0,0 @@
|
||||
" NOTE: You must, of course, install the ack script
|
||||
" in your path.
|
||||
" On Ubuntu:
|
||||
" sudo apt-get install ack-grep
|
||||
" ln -s /usr/bin/ack-grep /usr/bin/ack
|
||||
" With MacPorts:
|
||||
" sudo port install p5-app-ack
|
||||
|
||||
let g:ackprg="ack\\ -H\\ --nocolor\\ --nogroup"
|
||||
|
||||
function! Ack(args)
|
||||
let grepprg_bak=&grepprg
|
||||
exec "set grepprg=" . g:ackprg
|
||||
execute "silent! grep " . a:args
|
||||
botright copen
|
||||
let &grepprg=grepprg_bak
|
||||
exec "redraw!"
|
||||
endfunction
|
||||
|
||||
function! AckAdd(args)
|
||||
let grepprg_bak=&grepprg
|
||||
exec "set grepprg=" . g:ackprg
|
||||
execute "silent! grepadd " . a:args
|
||||
botright copen
|
||||
let &grepprg=grepprg_bak
|
||||
exec "redraw!"
|
||||
endfunction
|
||||
|
||||
function! LAck(args)
|
||||
let grepprg_bak=&grepprg
|
||||
exec "set grepprg=" . g:ackprg
|
||||
execute "silent! lgrep " . a:args
|
||||
botright lopen
|
||||
let &grepprg=grepprg_bak
|
||||
exec "redraw!"
|
||||
endfunction
|
||||
|
||||
function! LAckAdd(args)
|
||||
let grepprg_bak=&grepprg
|
||||
exec "set grepprg=" . g:ackprg
|
||||
execute "silent! lgrepadd " . a:args
|
||||
botright lopen
|
||||
let &grepprg=grepprg_bak
|
||||
exec "redraw!"
|
||||
endfunction
|
||||
|
||||
command! -nargs=* -complete=file Ack call Ack(<q-args>)
|
||||
command! -nargs=* -complete=file AckAdd call AckAdd(<q-args>)
|
||||
command! -nargs=* -complete=file LAck call LAck(<q-args>)
|
||||
command! -nargs=* -complete=file LAckAdd call LAckAdd(<q-args>)
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,196 +0,0 @@
|
||||
" Vim ftplugin file
|
||||
" Language: Python
|
||||
" Authors: André Kelpe <efeshundertelf at googlemail dot com>
|
||||
" Romain Chossart <romainchossat at gmail dot com>
|
||||
" Matthias Vogelgesang
|
||||
" Ricardo Catalinas Jiménez <jimenezrick at gmail dot com>
|
||||
" Patches and suggestions from all sorts of fine people
|
||||
"
|
||||
" More info and updates at:
|
||||
"
|
||||
" http://www.vim.org/scripts/script.php?script_id=910
|
||||
"
|
||||
"
|
||||
" This plugin integrates the Python documentation view and search tool pydoc
|
||||
" into Vim. It allows you to view the documentation of a Python module or class
|
||||
" by typing:
|
||||
"
|
||||
" :Pydoc foo.bar.baz (e.g. :Pydoc re.compile)
|
||||
"
|
||||
" Or search a word (uses pydoc -k) in the documentation by typing:
|
||||
"
|
||||
" :PydocSearch foobar (e.g. :PydocSearch socket)
|
||||
"
|
||||
" Vim will split the current window to show the Python documentation found by
|
||||
" pydoc (the buffer will be called '__doc__', Pythonic, isn't it ;-) ). The
|
||||
" name may cause problems if you have a file with the same name, but usually
|
||||
" this should not happen.
|
||||
"
|
||||
" pydoc.vim also allows you to view the documentation of the 'word' (see :help
|
||||
" word) under the cursor by pressing <Leader>pw or the 'WORD' (see :help WORD)
|
||||
" under the cursor by pressing <Leader>pW. This is very useful if you want to
|
||||
" jump to the docs of a module or class found by 'PydocSearch' or if you want
|
||||
" to see the docs of a module/class in your source code. Additionally K is
|
||||
" mapped to show invoke pydoc as well, when you are editing python files.
|
||||
"
|
||||
" The script is developed in GitHub at:
|
||||
"
|
||||
" http://github.com/fs111/pydoc.vim
|
||||
"
|
||||
"
|
||||
" If you want to use the script and pydoc is not in your PATH, just put a
|
||||
" line like this in your .vimrc:
|
||||
"
|
||||
" let g:pydoc_cmd = '/usr/bin/pydoc'
|
||||
"
|
||||
" or more portable
|
||||
"
|
||||
" let g:pydoc_cmd = 'python -m pydoc'
|
||||
"
|
||||
" If you want to open pydoc files in vertical splits or tabs, give the
|
||||
" appropriate command in your .vimrc with:
|
||||
"
|
||||
" let g:pydoc_open_cmd = 'vsplit'
|
||||
"
|
||||
" or
|
||||
"
|
||||
" let g:pydoc_open_cmd = 'tabnew'
|
||||
"
|
||||
" The script will highlight the search term by default. To disable this behaviour
|
||||
" put in your .vimrc:
|
||||
"
|
||||
" let g:pydoc_highlight=0
|
||||
"
|
||||
"
|
||||
" In order to install pydoc.vim download it from vim.org or clone the repository
|
||||
" on githubi and put it in your .vim/ftplugin directory. pydoc.vim is also fully
|
||||
" compatible with pathogen, so cloning the repository into your bundle directory
|
||||
" is also a valid way to install it. (I do this myself. see
|
||||
" https://github.com/fs111/dotvim).
|
||||
"
|
||||
" pydoc.vim is free software; you can redistribute it and/or
|
||||
" modify it under the terms of the GNU General Public License
|
||||
" as published by the Free Software Foundation; either version 2
|
||||
" of the License, or (at your option) any later version.
|
||||
"
|
||||
" Please feel free to contact me and follow me on twitter (@fs111).
|
||||
|
||||
" IMPORTANT: We don't use here the `exists("b:did_ftplugin")' guard becase we
|
||||
" want to let the Python filetype script that comes with Vim to execute as
|
||||
" normal.
|
||||
|
||||
" Don't redefine the functions if this ftplugin has been executed previously
|
||||
" and before finish create the local mappings in the current buffer
|
||||
if exists('*s:ShowPyDoc') && g:pydoc_perform_mappings
|
||||
call s:PerformMappings()
|
||||
finish
|
||||
endif
|
||||
|
||||
if !exists('g:pydoc_perform_mappings')
|
||||
let g:pydoc_perform_mappings = 1
|
||||
endif
|
||||
|
||||
if !exists('g:pydoc_highlight')
|
||||
let g:pydoc_highlight = 1
|
||||
endif
|
||||
|
||||
if !exists('g:pydoc_cmd')
|
||||
let g:pydoc_cmd = 'pydoc'
|
||||
endif
|
||||
|
||||
if !exists('g:pydoc_open_cmd')
|
||||
let g:pydoc_open_cmd = 'split'
|
||||
endif
|
||||
|
||||
setlocal switchbuf=useopen
|
||||
highlight pydoc cterm=reverse gui=reverse
|
||||
|
||||
function s:ShowPyDoc(name, type)
|
||||
if a:name == ''
|
||||
return
|
||||
endif
|
||||
|
||||
if g:pydoc_open_cmd == 'split'
|
||||
let l:pydoc_wh = 10
|
||||
endif
|
||||
|
||||
if bufloaded("__doc__")
|
||||
let l:buf_is_new = 0
|
||||
if bufname("%") == "__doc__"
|
||||
" The current buffer is __doc__, thus do not
|
||||
" recreate nor resize it
|
||||
let l:pydoc_wh = -1
|
||||
else
|
||||
" If the __doc__ buffer is open, jump to it
|
||||
silent execute "sbuffer" bufnr("__doc__")
|
||||
let l:pydoc_wh = -1
|
||||
endif
|
||||
else
|
||||
let l:buf_is_new = 1
|
||||
silent execute g:pydoc_open_cmd '__doc__'
|
||||
if g:pydoc_perform_mappings
|
||||
call s:PerformMappings()
|
||||
endif
|
||||
endif
|
||||
|
||||
setlocal modifiable
|
||||
setlocal noswapfile
|
||||
setlocal buftype=nofile
|
||||
setlocal bufhidden=delete
|
||||
setlocal syntax=man
|
||||
|
||||
silent normal ggdG
|
||||
" Remove function/method arguments
|
||||
let s:name2 = substitute(a:name, '(.*', '', 'g' )
|
||||
" Remove all colons
|
||||
let s:name2 = substitute(s:name2, ':', '', 'g' )
|
||||
if a:type == 1
|
||||
execute "silent read !" g:pydoc_cmd s:name2
|
||||
else
|
||||
execute "silent read !" g:pydoc_cmd "-k" s:name2
|
||||
endif
|
||||
normal 1G
|
||||
|
||||
if exists('l:pydoc_wh') && l:pydoc_wh != -1
|
||||
execute "silent resize" l:pydoc_wh
|
||||
end
|
||||
|
||||
if g:pydoc_highlight == 1
|
||||
execute 'syntax match pydoc' "'" . s:name2 . "'"
|
||||
endif
|
||||
|
||||
let l:line = getline(2)
|
||||
if l:line =~ "^no Python documentation found for.*$"
|
||||
if l:buf_is_new
|
||||
execute "bdelete!"
|
||||
else
|
||||
normal u
|
||||
setlocal nomodified
|
||||
setlocal nomodifiable
|
||||
endif
|
||||
redraw
|
||||
echohl WarningMsg | echo l:line | echohl None
|
||||
else
|
||||
setlocal nomodified
|
||||
setlocal nomodifiable
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Mappings
|
||||
function s:PerformMappings()
|
||||
nnoremap <silent> <buffer> <Leader>pw :call <SID>ShowPyDoc('<C-R><C-W>', 1)<CR>
|
||||
nnoremap <silent> <buffer> <Leader>pW :call <SID>ShowPyDoc('<C-R><C-A>', 1)<CR>
|
||||
nnoremap <silent> <buffer> <Leader>pk :call <SID>ShowPyDoc('<C-R><C-W>', 0)<CR>
|
||||
nnoremap <silent> <buffer> <Leader>pK :call <SID>ShowPyDoc('<C-R><C-A>', 0)<CR>
|
||||
|
||||
" remap the K (or 'help') key
|
||||
nnoremap <silent> <buffer> K :call <SID>ShowPyDoc(expand("<cword>"), 1)<CR>
|
||||
endfunction
|
||||
|
||||
if g:pydoc_perform_mappings
|
||||
call s:PerformMappings()
|
||||
endif
|
||||
|
||||
" Commands
|
||||
command -nargs=1 Pydoc :call s:ShowPyDoc('<args>', 1)
|
||||
command -nargs=* PydocSearch :call s:ShowPyDoc('<args>', 0)
|
||||
@@ -1,82 +0,0 @@
|
||||
pyflakes-vim
|
||||
============
|
||||
|
||||
A Vim plugin for checking Python code on the fly.
|
||||
|
||||
PyFlakes catches common Python errors like mistyping a variable name or
|
||||
accessing a local before it is bound, and also gives warnings for things like
|
||||
unused imports.
|
||||
|
||||
pyflakes-vim uses the output from PyFlakes to highlight errors in your code.
|
||||
To locate errors quickly, use quickfix_ commands like :cc.
|
||||
|
||||
Make sure to check vim.org_ for the latest updates.
|
||||
|
||||
.. _pyflakes.vim: http://www.vim.org/scripts/script.php?script_id=2441
|
||||
.. _vim.org: http://www.vim.org/scripts/script.php?script_id=2441
|
||||
.. _quickfix: http://vimdoc.sourceforge.net/htmldoc/quickfix.html#quickfix
|
||||
|
||||
Quick Installation
|
||||
------------------
|
||||
|
||||
1. Make sure your ``.vimrc`` has::
|
||||
|
||||
filetype on " enables filetype detection
|
||||
filetype plugin on " enables filetype specific plugins
|
||||
|
||||
2. Download the latest release_.
|
||||
|
||||
3. If you're using pathogen_, unzip the contents of ``pyflakes-vim.zip`` into
|
||||
its own bundle directory, i.e. into ``~/.vim/bundle/pyflakes-vim/``.
|
||||
|
||||
Otherwise unzip ``pyflakes.vim`` and the ``pyflakes`` directory into
|
||||
``~/.vim/ftplugin/python`` (or somewhere similar on your
|
||||
`runtime path`_ that will be sourced for Python files).
|
||||
|
||||
.. _release: http://www.vim.org/scripts/script.php?script_id=2441
|
||||
.. _pathogen: http://www.vim.org/scripts/script.php?script_id=2332
|
||||
.. _runtime path: http://vimdoc.sourceforge.net/htmldoc/options.html#'runtimepath'
|
||||
|
||||
Running from source
|
||||
-------------------
|
||||
|
||||
If you're running pyflakes-vim "from source," you'll need the PyFlakes library
|
||||
on your PYTHONPATH somewhere. (It is included in the vim.org zipfile.) I recommend
|
||||
getting my PyFlakes_ fork, which retains column number information, giving more
|
||||
specific error locations.
|
||||
|
||||
.. _vim.org: http://www.vim.org/scripts/script.php?script_id=2441
|
||||
.. _PyFlakes: http://github.com/kevinw/pyflakes
|
||||
|
||||
Hacking
|
||||
-------
|
||||
|
||||
::
|
||||
|
||||
git clone git://github.com/kevinw/pyflakes-vim.git
|
||||
cd pyflakes-vim
|
||||
git clone git://github.com/kevinw/pyflakes.git
|
||||
|
||||
Options
|
||||
-------
|
||||
|
||||
Set this option to you vimrc file to disable quickfix support::
|
||||
|
||||
let g:pyflakes_use_quickfix = 0
|
||||
|
||||
The value is set to 1 by default.
|
||||
|
||||
TODO
|
||||
----
|
||||
* signs_ support (show warning and error icons to left of the buffer area)
|
||||
* configuration variables
|
||||
* parse or intercept useful output from the warnings module
|
||||
|
||||
.. _signs: http://www.vim.org/htmldoc/sign.html
|
||||
|
||||
Changelog
|
||||
---------
|
||||
|
||||
Please see http://www.vim.org/scripts/script.php?script_id=2441 for a history of
|
||||
all changes.
|
||||
|
||||
@@ -1,321 +0,0 @@
|
||||
" pyflakes.vim - A script to highlight Python code on the fly with warnings
|
||||
" from Pyflakes, a Python lint tool.
|
||||
"
|
||||
" Place this script and the accompanying pyflakes directory in
|
||||
" .vim/ftplugin/python.
|
||||
"
|
||||
" See README for additional installation and information.
|
||||
"
|
||||
" Thanks to matlib.vim for ideas/code on interactive linting.
|
||||
"
|
||||
" Maintainer: Kevin Watters <kevin.watters@gmail.com>
|
||||
" Version: 0.1
|
||||
|
||||
if exists("b:did_pyflakes_plugin")
|
||||
finish " only load once
|
||||
else
|
||||
let b:did_pyflakes_plugin = 1
|
||||
endif
|
||||
|
||||
if !exists('g:pyflakes_builtins')
|
||||
let g:pyflakes_builtins = []
|
||||
endif
|
||||
|
||||
if !exists("b:did_python_init")
|
||||
let b:did_python_init = 0
|
||||
|
||||
if !has('python')
|
||||
echoerr "Error: the pyflakes.vim plugin requires Vim to be compiled with +python"
|
||||
finish
|
||||
endif
|
||||
|
||||
if !exists('g:pyflakes_use_quickfix')
|
||||
let g:pyflakes_use_quickfix = 1
|
||||
endif
|
||||
|
||||
|
||||
python << EOF
|
||||
import vim
|
||||
import os.path
|
||||
import sys
|
||||
|
||||
if sys.version_info[:2] < (2, 5):
|
||||
raise AssertionError('Vim must be compiled with Python 2.5 or higher; you have ' + sys.version)
|
||||
|
||||
# get the directory this script is in: the pyflakes python module should be installed there.
|
||||
scriptdir = os.path.join(os.path.dirname(vim.eval('expand("<sfile>")')), 'pyflakes')
|
||||
sys.path.insert(0, scriptdir)
|
||||
|
||||
import ast
|
||||
from pyflakes import checker, messages
|
||||
from operator import attrgetter
|
||||
import re
|
||||
|
||||
class loc(object):
|
||||
def __init__(self, lineno, col=None):
|
||||
self.lineno = lineno
|
||||
self.col_offset = col
|
||||
|
||||
class SyntaxError(messages.Message):
|
||||
message = 'could not compile: %s'
|
||||
def __init__(self, filename, lineno, col, message):
|
||||
messages.Message.__init__(self, filename, loc(lineno, col))
|
||||
self.message_args = (message,)
|
||||
|
||||
class blackhole(object):
|
||||
write = flush = lambda *a, **k: None
|
||||
|
||||
def check(buffer):
|
||||
filename = buffer.name
|
||||
contents = buffer[:]
|
||||
|
||||
# shebang usually found at the top of the file, followed by source code encoding marker.
|
||||
# assume everything else that follows is encoded in the encoding.
|
||||
encoding_found = False
|
||||
for n, line in enumerate(contents):
|
||||
if n >= 2:
|
||||
break
|
||||
elif re.match(r'#.*coding[:=]\s*([-\w.]+)', line):
|
||||
contents = ['']*(n+1) + contents[n+1:]
|
||||
break
|
||||
|
||||
contents = '\n'.join(contents) + '\n'
|
||||
|
||||
vimenc = vim.eval('&encoding')
|
||||
if vimenc:
|
||||
contents = contents.decode(vimenc)
|
||||
|
||||
builtins = set(['__file__'])
|
||||
try:
|
||||
builtins.update(set(eval(vim.eval('string(g:pyflakes_builtins)'))))
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
try:
|
||||
# TODO: use warnings filters instead of ignoring stderr
|
||||
old_stderr, sys.stderr = sys.stderr, blackhole()
|
||||
try:
|
||||
tree = ast.parse(contents, filename or '<unknown>')
|
||||
finally:
|
||||
sys.stderr = old_stderr
|
||||
except:
|
||||
try:
|
||||
value = sys.exc_info()[1]
|
||||
lineno, offset, line = value[1][1:]
|
||||
except IndexError:
|
||||
lineno, offset, line = 1, 0, ''
|
||||
if line and line.endswith("\n"):
|
||||
line = line[:-1]
|
||||
|
||||
return [SyntaxError(filename, lineno, offset, str(value))]
|
||||
else:
|
||||
# pyflakes looks to _MAGIC_GLOBALS in checker.py to see which
|
||||
# UndefinedNames to ignore
|
||||
old_globals = getattr(checker,' _MAGIC_GLOBALS', [])
|
||||
checker._MAGIC_GLOBALS = set(old_globals) | builtins
|
||||
|
||||
w = checker.Checker(tree, filename)
|
||||
|
||||
checker._MAGIC_GLOBALS = old_globals
|
||||
|
||||
w.messages.sort(key = attrgetter('lineno'))
|
||||
return w.messages
|
||||
|
||||
|
||||
def vim_quote(s):
|
||||
return s.replace("'", "''")
|
||||
EOF
|
||||
let b:did_python_init = 1
|
||||
endif
|
||||
|
||||
if !b:did_python_init
|
||||
finish
|
||||
endif
|
||||
|
||||
au BufLeave <buffer> call s:ClearPyflakes()
|
||||
|
||||
au BufEnter <buffer> call s:RunPyflakes()
|
||||
au InsertLeave <buffer> call s:RunPyflakes()
|
||||
au InsertEnter <buffer> call s:RunPyflakes()
|
||||
au BufWritePost <buffer> call s:RunPyflakes()
|
||||
|
||||
au CursorHold <buffer> call s:RunPyflakes()
|
||||
au CursorHoldI <buffer> call s:RunPyflakes()
|
||||
|
||||
au CursorHold <buffer> call s:GetPyflakesMessage()
|
||||
au CursorMoved <buffer> call s:GetPyflakesMessage()
|
||||
|
||||
if !exists("*s:PyflakesUpdate")
|
||||
function s:PyflakesUpdate()
|
||||
silent call s:RunPyflakes()
|
||||
call s:GetPyflakesMessage()
|
||||
endfunction
|
||||
endif
|
||||
|
||||
" Call this function in your .vimrc to update PyFlakes
|
||||
if !exists(":PyflakesUpdate")
|
||||
command PyflakesUpdate :call s:PyflakesUpdate()
|
||||
endif
|
||||
|
||||
" Hook common text manipulation commands to update PyFlakes
|
||||
" TODO: is there a more general "text op" autocommand we could register
|
||||
" for here?
|
||||
noremap <buffer><silent> dd dd:PyflakesUpdate<CR>
|
||||
noremap <buffer><silent> dw dw:PyflakesUpdate<CR>
|
||||
noremap <buffer><silent> u u:PyflakesUpdate<CR>
|
||||
noremap <buffer><silent> <C-R> <C-R>:PyflakesUpdate<CR>
|
||||
|
||||
" WideMsg() prints [long] message up to (&columns-1) length
|
||||
" guaranteed without "Press Enter" prompt.
|
||||
if !exists("*s:WideMsg")
|
||||
function s:WideMsg(msg)
|
||||
let x=&ruler | let y=&showcmd
|
||||
set noruler noshowcmd
|
||||
redraw
|
||||
echo strpart(a:msg, 0, &columns-1)
|
||||
let &ruler=x | let &showcmd=y
|
||||
endfun
|
||||
endif
|
||||
|
||||
if !exists("*s:GetQuickFixStackCount")
|
||||
function s:GetQuickFixStackCount()
|
||||
let l:stack_count = 0
|
||||
try
|
||||
silent colder 9
|
||||
catch /E380:/
|
||||
endtry
|
||||
|
||||
try
|
||||
for i in range(9)
|
||||
silent cnewer
|
||||
let l:stack_count = l:stack_count + 1
|
||||
endfor
|
||||
catch /E381:/
|
||||
return l:stack_count
|
||||
endtry
|
||||
endfunction
|
||||
endif
|
||||
|
||||
if !exists("*s:ActivatePyflakesQuickFixWindow")
|
||||
function s:ActivatePyflakesQuickFixWindow()
|
||||
try
|
||||
silent colder 9 " go to the bottom of quickfix stack
|
||||
catch /E380:/
|
||||
endtry
|
||||
|
||||
if s:pyflakes_qf > 0
|
||||
try
|
||||
exe "silent cnewer " . s:pyflakes_qf
|
||||
catch /E381:/
|
||||
echoerr "Could not activate Pyflakes Quickfix Window."
|
||||
endtry
|
||||
endif
|
||||
endfunction
|
||||
endif
|
||||
|
||||
if !exists("*s:RunPyflakes")
|
||||
function s:RunPyflakes()
|
||||
highlight link PyFlakes SpellBad
|
||||
|
||||
if exists("b:cleared")
|
||||
if b:cleared == 0
|
||||
silent call s:ClearPyflakes()
|
||||
let b:cleared = 1
|
||||
endif
|
||||
else
|
||||
let b:cleared = 1
|
||||
endif
|
||||
|
||||
let b:matched = []
|
||||
let b:matchedlines = {}
|
||||
|
||||
let b:qf_list = []
|
||||
let b:qf_window_count = -1
|
||||
|
||||
python << EOF
|
||||
for w in check(vim.current.buffer):
|
||||
vim.command('let s:matchDict = {}')
|
||||
vim.command("let s:matchDict['lineNum'] = " + str(w.lineno))
|
||||
vim.command("let s:matchDict['message'] = '%s'" % vim_quote(w.message % w.message_args))
|
||||
vim.command("let b:matchedlines[" + str(w.lineno) + "] = s:matchDict")
|
||||
|
||||
vim.command("let l:qf_item = {}")
|
||||
vim.command("let l:qf_item.bufnr = bufnr('%')")
|
||||
vim.command("let l:qf_item.filename = expand('%')")
|
||||
vim.command("let l:qf_item.lnum = %s" % str(w.lineno))
|
||||
vim.command("let l:qf_item.text = '%s'" % vim_quote(w.message % w.message_args))
|
||||
vim.command("let l:qf_item.type = 'E'")
|
||||
|
||||
if getattr(w, 'col', None) is None or isinstance(w, SyntaxError):
|
||||
# without column information, just highlight the whole line
|
||||
# (minus the newline)
|
||||
vim.command(r"let s:mID = matchadd('PyFlakes', '\%" + str(w.lineno) + r"l\n\@!')")
|
||||
else:
|
||||
# with a column number, highlight the first keyword there
|
||||
vim.command(r"let s:mID = matchadd('PyFlakes', '^\%" + str(w.lineno) + r"l\_.\{-}\zs\k\+\k\@!\%>" + str(w.col) + r"c')")
|
||||
|
||||
vim.command("let l:qf_item.vcol = 1")
|
||||
vim.command("let l:qf_item.col = %s" % str(w.col + 1))
|
||||
|
||||
vim.command("call add(b:matched, s:matchDict)")
|
||||
vim.command("call add(b:qf_list, l:qf_item)")
|
||||
EOF
|
||||
if g:pyflakes_use_quickfix == 1
|
||||
if exists("s:pyflakes_qf")
|
||||
" if pyflakes quickfix window is already created, reuse it
|
||||
call s:ActivatePyflakesQuickFixWindow()
|
||||
call setqflist(b:qf_list, 'r')
|
||||
else
|
||||
" one pyflakes quickfix window for all buffer
|
||||
call setqflist(b:qf_list, '')
|
||||
let s:pyflakes_qf = s:GetQuickFixStackCount()
|
||||
endif
|
||||
endif
|
||||
|
||||
let b:cleared = 0
|
||||
endfunction
|
||||
end
|
||||
|
||||
" keep track of whether or not we are showing a message
|
||||
let b:showing_message = 0
|
||||
|
||||
if !exists("*s:GetPyflakesMessage")
|
||||
function s:GetPyflakesMessage()
|
||||
let s:cursorPos = getpos(".")
|
||||
|
||||
" Bail if RunPyflakes hasn't been called yet.
|
||||
if !exists('b:matchedlines')
|
||||
return
|
||||
endif
|
||||
|
||||
" if there's a message for the line the cursor is currently on, echo
|
||||
" it to the console
|
||||
if has_key(b:matchedlines, s:cursorPos[1])
|
||||
let s:pyflakesMatch = get(b:matchedlines, s:cursorPos[1])
|
||||
call s:WideMsg(s:pyflakesMatch['message'])
|
||||
let b:showing_message = 1
|
||||
return
|
||||
endif
|
||||
|
||||
" otherwise, if we're showing a message, clear it
|
||||
if b:showing_message == 1
|
||||
echo
|
||||
let b:showing_message = 0
|
||||
endif
|
||||
endfunction
|
||||
endif
|
||||
|
||||
if !exists('*s:ClearPyflakes')
|
||||
function s:ClearPyflakes()
|
||||
let s:matches = getmatches()
|
||||
for s:matchId in s:matches
|
||||
if s:matchId['group'] == 'PyFlakes'
|
||||
call matchdelete(s:matchId['id'])
|
||||
endif
|
||||
endfor
|
||||
let b:matched = []
|
||||
let b:matchedlines = {}
|
||||
let b:cleared = 1
|
||||
endfunction
|
||||
endif
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
|
||||
Copyright (c) 2005 Divmod, Inc., http://www.divmod.com/
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
@@ -1,29 +0,0 @@
|
||||
0.4.0 (2009-11-25):
|
||||
- Fix reporting for certain SyntaxErrors which lack line number
|
||||
information.
|
||||
- Check for syntax errors more rigorously.
|
||||
- Support checking names used with the class decorator syntax in versions
|
||||
of Python which have it.
|
||||
- Detect local variables which are bound but never used.
|
||||
- Handle permission errors when trying to read source files.
|
||||
- Handle problems with the encoding of source files.
|
||||
- Support importing dotted names so as not to incorrectly report them as
|
||||
redefined unused names.
|
||||
- Support all forms of the with statement.
|
||||
- Consider static `__all__` definitions and avoid reporting unused names
|
||||
if the names are listed there.
|
||||
- Fix incorrect checking of class names with respect to the names of their
|
||||
bases in the class statement.
|
||||
- Support the `__path__` global in `__init__.py`.
|
||||
|
||||
0.3.0 (2009-01-30):
|
||||
- Display more informative SyntaxError messages.
|
||||
- Don't hang flymake with unmatched triple quotes (only report a single
|
||||
line of source for a multiline syntax error).
|
||||
- Recognize __builtins__ as a defined name.
|
||||
- Improve pyflakes support for python versions 2.3-2.5
|
||||
- Support for if-else expressions and with statements.
|
||||
- Warn instead of error on non-existant file paths.
|
||||
- Check for __future__ imports after other statements.
|
||||
- Add reporting for some types of import shadowing.
|
||||
- Improve reporting of unbound locals
|
||||
@@ -1,4 +0,0 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
from pyflakes.scripts.pyflakes import main
|
||||
main()
|
||||
@@ -1,2 +0,0 @@
|
||||
|
||||
__version__ = '0.4.0'
|
||||
@@ -1,625 +0,0 @@
|
||||
# -*- test-case-name: pyflakes -*-
|
||||
# (c) 2005-2010 Divmod, Inc.
|
||||
# See LICENSE file for details
|
||||
|
||||
import __builtin__
|
||||
import os.path
|
||||
import _ast
|
||||
|
||||
from pyflakes import messages
|
||||
|
||||
|
||||
# utility function to iterate over an AST node's children, adapted
|
||||
# from Python 2.6's standard ast module
|
||||
try:
|
||||
import ast
|
||||
iter_child_nodes = ast.iter_child_nodes
|
||||
except (ImportError, AttributeError):
|
||||
def iter_child_nodes(node, astcls=_ast.AST):
|
||||
"""
|
||||
Yield all direct child nodes of *node*, that is, all fields that are nodes
|
||||
and all items of fields that are lists of nodes.
|
||||
"""
|
||||
for name in node._fields:
|
||||
field = getattr(node, name, None)
|
||||
if isinstance(field, astcls):
|
||||
yield field
|
||||
elif isinstance(field, list):
|
||||
for item in field:
|
||||
yield item
|
||||
|
||||
|
||||
class Binding(object):
|
||||
"""
|
||||
Represents the binding of a value to a name.
|
||||
|
||||
The checker uses this to keep track of which names have been bound and
|
||||
which names have not. See L{Assignment} for a special type of binding that
|
||||
is checked with stricter rules.
|
||||
|
||||
@ivar used: pair of (L{Scope}, line-number) indicating the scope and
|
||||
line number that this binding was last used
|
||||
"""
|
||||
|
||||
def __init__(self, name, source):
|
||||
self.name = name
|
||||
self.source = source
|
||||
self.used = False
|
||||
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
|
||||
|
||||
def __repr__(self):
|
||||
return '<%s object %r from line %r at 0x%x>' % (self.__class__.__name__,
|
||||
self.name,
|
||||
self.source.lineno,
|
||||
id(self))
|
||||
|
||||
|
||||
|
||||
class UnBinding(Binding):
|
||||
'''Created by the 'del' operator.'''
|
||||
|
||||
|
||||
|
||||
class Importation(Binding):
|
||||
"""
|
||||
A binding created by an import statement.
|
||||
|
||||
@ivar fullName: The complete name given to the import statement,
|
||||
possibly including multiple dotted components.
|
||||
@type fullName: C{str}
|
||||
"""
|
||||
def __init__(self, name, source):
|
||||
self.fullName = name
|
||||
name = name.split('.')[0]
|
||||
super(Importation, self).__init__(name, source)
|
||||
|
||||
|
||||
|
||||
class Argument(Binding):
|
||||
"""
|
||||
Represents binding a name as an argument.
|
||||
"""
|
||||
|
||||
|
||||
|
||||
class Assignment(Binding):
|
||||
"""
|
||||
Represents binding a name with an explicit assignment.
|
||||
|
||||
The checker will raise warnings for any Assignment that isn't used. Also,
|
||||
the checker does not consider assignments in tuple/list unpacking to be
|
||||
Assignments, rather it treats them as simple Bindings.
|
||||
"""
|
||||
|
||||
|
||||
|
||||
class FunctionDefinition(Binding):
|
||||
pass
|
||||
|
||||
|
||||
|
||||
class ExportBinding(Binding):
|
||||
"""
|
||||
A binding created by an C{__all__} assignment. If the names in the list
|
||||
can be determined statically, they will be treated as names for export and
|
||||
additional checking applied to them.
|
||||
|
||||
The only C{__all__} assignment that can be recognized is one which takes
|
||||
the value of a literal list containing literal strings. For example::
|
||||
|
||||
__all__ = ["foo", "bar"]
|
||||
|
||||
Names which are imported and not otherwise used but appear in the value of
|
||||
C{__all__} will not have an unused import warning reported for them.
|
||||
"""
|
||||
def names(self):
|
||||
"""
|
||||
Return a list of the names referenced by this binding.
|
||||
"""
|
||||
names = []
|
||||
if isinstance(self.source, _ast.List):
|
||||
for node in self.source.elts:
|
||||
if isinstance(node, _ast.Str):
|
||||
names.append(node.s)
|
||||
return names
|
||||
|
||||
|
||||
|
||||
class Scope(dict):
|
||||
importStarred = False # set to True when import * is found
|
||||
|
||||
|
||||
def __repr__(self):
|
||||
return '<%s at 0x%x %s>' % (self.__class__.__name__, id(self), dict.__repr__(self))
|
||||
|
||||
|
||||
def __init__(self):
|
||||
super(Scope, self).__init__()
|
||||
|
||||
|
||||
|
||||
class ClassScope(Scope):
|
||||
pass
|
||||
|
||||
|
||||
|
||||
class FunctionScope(Scope):
|
||||
"""
|
||||
I represent a name scope for a function.
|
||||
|
||||
@ivar globals: Names declared 'global' in this function.
|
||||
"""
|
||||
def __init__(self):
|
||||
super(FunctionScope, self).__init__()
|
||||
self.globals = {}
|
||||
|
||||
|
||||
|
||||
class ModuleScope(Scope):
|
||||
pass
|
||||
|
||||
|
||||
# Globally defined names which are not attributes of the __builtin__ module.
|
||||
_MAGIC_GLOBALS = ['__file__', '__builtins__']
|
||||
|
||||
|
||||
|
||||
class Checker(object):
|
||||
"""
|
||||
I check the cleanliness and sanity of Python code.
|
||||
|
||||
@ivar _deferredFunctions: Tracking list used by L{deferFunction}. Elements
|
||||
of the list are two-tuples. The first element is the callable passed
|
||||
to L{deferFunction}. The second element is a copy of the scope stack
|
||||
at the time L{deferFunction} was called.
|
||||
|
||||
@ivar _deferredAssignments: Similar to C{_deferredFunctions}, but for
|
||||
callables which are deferred assignment checks.
|
||||
"""
|
||||
|
||||
nodeDepth = 0
|
||||
traceTree = False
|
||||
|
||||
def __init__(self, tree, filename='(none)'):
|
||||
self._deferredFunctions = []
|
||||
self._deferredAssignments = []
|
||||
self.dead_scopes = []
|
||||
self.messages = []
|
||||
self.filename = filename
|
||||
self.scopeStack = [ModuleScope()]
|
||||
self.futuresAllowed = True
|
||||
self.handleChildren(tree)
|
||||
self._runDeferred(self._deferredFunctions)
|
||||
# Set _deferredFunctions to None so that deferFunction will fail
|
||||
# noisily if called after we've run through the deferred functions.
|
||||
self._deferredFunctions = None
|
||||
self._runDeferred(self._deferredAssignments)
|
||||
# Set _deferredAssignments to None so that deferAssignment will fail
|
||||
# noisly if called after we've run through the deferred assignments.
|
||||
self._deferredAssignments = None
|
||||
del self.scopeStack[1:]
|
||||
self.popScope()
|
||||
self.check_dead_scopes()
|
||||
|
||||
|
||||
def deferFunction(self, callable):
|
||||
'''
|
||||
Schedule a function handler to be called just before completion.
|
||||
|
||||
This is used for handling function bodies, which must be deferred
|
||||
because code later in the file might modify the global scope. When
|
||||
`callable` is called, the scope at the time this is called will be
|
||||
restored, however it will contain any new bindings added to it.
|
||||
'''
|
||||
self._deferredFunctions.append((callable, self.scopeStack[:]))
|
||||
|
||||
|
||||
def deferAssignment(self, callable):
|
||||
"""
|
||||
Schedule an assignment handler to be called just after deferred
|
||||
function handlers.
|
||||
"""
|
||||
self._deferredAssignments.append((callable, self.scopeStack[:]))
|
||||
|
||||
|
||||
def _runDeferred(self, deferred):
|
||||
"""
|
||||
Run the callables in C{deferred} using their associated scope stack.
|
||||
"""
|
||||
for handler, scope in deferred:
|
||||
self.scopeStack = scope
|
||||
handler()
|
||||
|
||||
|
||||
def scope(self):
|
||||
return self.scopeStack[-1]
|
||||
scope = property(scope)
|
||||
|
||||
def popScope(self):
|
||||
self.dead_scopes.append(self.scopeStack.pop())
|
||||
|
||||
|
||||
def check_dead_scopes(self):
|
||||
"""
|
||||
Look at scopes which have been fully examined and report names in them
|
||||
which were imported but unused.
|
||||
"""
|
||||
for scope in self.dead_scopes:
|
||||
export = isinstance(scope.get('__all__'), ExportBinding)
|
||||
if export:
|
||||
all = scope['__all__'].names()
|
||||
if os.path.split(self.filename)[1] != '__init__.py':
|
||||
# Look for possible mistakes in the export list
|
||||
undefined = set(all) - set(scope)
|
||||
for name in undefined:
|
||||
self.report(
|
||||
messages.UndefinedExport,
|
||||
scope['__all__'].source,
|
||||
name)
|
||||
else:
|
||||
all = []
|
||||
|
||||
# Look for imported names that aren't used.
|
||||
for importation in scope.itervalues():
|
||||
if isinstance(importation, Importation):
|
||||
if not importation.used and importation.name not in all:
|
||||
self.report(
|
||||
messages.UnusedImport,
|
||||
importation.source,
|
||||
importation.name)
|
||||
|
||||
|
||||
def pushFunctionScope(self):
|
||||
self.scopeStack.append(FunctionScope())
|
||||
|
||||
def pushClassScope(self):
|
||||
self.scopeStack.append(ClassScope())
|
||||
|
||||
def report(self, messageClass, *args, **kwargs):
|
||||
self.messages.append(messageClass(self.filename, *args, **kwargs))
|
||||
|
||||
def handleChildren(self, tree):
|
||||
for node in iter_child_nodes(tree):
|
||||
self.handleNode(node, tree)
|
||||
|
||||
def isDocstring(self, node):
|
||||
"""
|
||||
Determine if the given node is a docstring, as long as it is at the
|
||||
correct place in the node tree.
|
||||
"""
|
||||
return isinstance(node, _ast.Str) or \
|
||||
(isinstance(node, _ast.Expr) and
|
||||
isinstance(node.value, _ast.Str))
|
||||
|
||||
def handleNode(self, node, parent):
|
||||
node.parent = parent
|
||||
if self.traceTree:
|
||||
print ' ' * self.nodeDepth + node.__class__.__name__
|
||||
self.nodeDepth += 1
|
||||
if self.futuresAllowed and not \
|
||||
(isinstance(node, _ast.ImportFrom) or self.isDocstring(node)):
|
||||
self.futuresAllowed = False
|
||||
nodeType = node.__class__.__name__.upper()
|
||||
try:
|
||||
handler = getattr(self, nodeType)
|
||||
handler(node)
|
||||
finally:
|
||||
self.nodeDepth -= 1
|
||||
if self.traceTree:
|
||||
print ' ' * self.nodeDepth + 'end ' + node.__class__.__name__
|
||||
|
||||
def ignore(self, node):
|
||||
pass
|
||||
|
||||
# "stmt" type nodes
|
||||
RETURN = DELETE = PRINT = WHILE = IF = WITH = RAISE = TRYEXCEPT = \
|
||||
TRYFINALLY = ASSERT = EXEC = EXPR = handleChildren
|
||||
|
||||
CONTINUE = BREAK = PASS = ignore
|
||||
|
||||
# "expr" type nodes
|
||||
BOOLOP = BINOP = UNARYOP = IFEXP = DICT = SET = YIELD = COMPARE = \
|
||||
CALL = REPR = ATTRIBUTE = SUBSCRIPT = LIST = TUPLE = handleChildren
|
||||
|
||||
NUM = STR = ELLIPSIS = ignore
|
||||
|
||||
# "slice" type nodes
|
||||
SLICE = EXTSLICE = INDEX = handleChildren
|
||||
|
||||
# expression contexts are node instances too, though being constants
|
||||
LOAD = STORE = DEL = AUGLOAD = AUGSTORE = PARAM = ignore
|
||||
|
||||
# same for operators
|
||||
AND = OR = ADD = SUB = MULT = DIV = MOD = POW = LSHIFT = RSHIFT = \
|
||||
BITOR = BITXOR = BITAND = FLOORDIV = INVERT = NOT = UADD = USUB = \
|
||||
EQ = NOTEQ = LT = LTE = GT = GTE = IS = ISNOT = IN = NOTIN = ignore
|
||||
|
||||
# additional node types
|
||||
COMPREHENSION = EXCEPTHANDLER = KEYWORD = handleChildren
|
||||
|
||||
def addBinding(self, loc, value, reportRedef=True):
|
||||
'''Called when a binding is altered.
|
||||
|
||||
- `loc` is the location (an object with lineno and optionally
|
||||
col_offset attributes) of the statement responsible for the change
|
||||
- `value` is the optional new value, a Binding instance, associated
|
||||
with the binding; if None, the binding is deleted if it exists.
|
||||
- if `reportRedef` is True (default), rebinding while unused will be
|
||||
reported.
|
||||
'''
|
||||
if (isinstance(self.scope.get(value.name), FunctionDefinition)
|
||||
and isinstance(value, FunctionDefinition)):
|
||||
self.report(messages.RedefinedFunction,
|
||||
loc, value.name, self.scope[value.name].source)
|
||||
|
||||
if not isinstance(self.scope, ClassScope):
|
||||
for scope in self.scopeStack[::-1]:
|
||||
existing = scope.get(value.name)
|
||||
if (isinstance(existing, Importation)
|
||||
and not existing.used
|
||||
and (not isinstance(value, Importation) or value.fullName == existing.fullName)
|
||||
and reportRedef):
|
||||
|
||||
self.report(messages.RedefinedWhileUnused,
|
||||
loc, value.name, scope[value.name].source)
|
||||
|
||||
if isinstance(value, UnBinding):
|
||||
try:
|
||||
del self.scope[value.name]
|
||||
except KeyError:
|
||||
self.report(messages.UndefinedName, loc, value.name)
|
||||
else:
|
||||
self.scope[value.name] = value
|
||||
|
||||
def GLOBAL(self, node):
|
||||
"""
|
||||
Keep track of globals declarations.
|
||||
"""
|
||||
if isinstance(self.scope, FunctionScope):
|
||||
self.scope.globals.update(dict.fromkeys(node.names))
|
||||
|
||||
def LISTCOMP(self, node):
|
||||
# handle generators before element
|
||||
for gen in node.generators:
|
||||
self.handleNode(gen, node)
|
||||
self.handleNode(node.elt, node)
|
||||
|
||||
GENERATOREXP = SETCOMP = LISTCOMP
|
||||
|
||||
# dictionary comprehensions; introduced in Python 2.7
|
||||
def DICTCOMP(self, node):
|
||||
for gen in node.generators:
|
||||
self.handleNode(gen, node)
|
||||
self.handleNode(node.key, node)
|
||||
self.handleNode(node.value, node)
|
||||
|
||||
def FOR(self, node):
|
||||
"""
|
||||
Process bindings for loop variables.
|
||||
"""
|
||||
vars = []
|
||||
def collectLoopVars(n):
|
||||
if isinstance(n, _ast.Name):
|
||||
vars.append(n.id)
|
||||
elif isinstance(n, _ast.expr_context):
|
||||
return
|
||||
else:
|
||||
for c in iter_child_nodes(n):
|
||||
collectLoopVars(c)
|
||||
|
||||
collectLoopVars(node.target)
|
||||
for varn in vars:
|
||||
if (isinstance(self.scope.get(varn), Importation)
|
||||
# unused ones will get an unused import warning
|
||||
and self.scope[varn].used):
|
||||
self.report(messages.ImportShadowedByLoopVar,
|
||||
node, varn, self.scope[varn].source)
|
||||
|
||||
self.handleChildren(node)
|
||||
|
||||
def NAME(self, node):
|
||||
"""
|
||||
Handle occurrence of Name (which can be a load/store/delete access.)
|
||||
"""
|
||||
# Locate the name in locals / function / globals scopes.
|
||||
if isinstance(node.ctx, (_ast.Load, _ast.AugLoad)):
|
||||
# try local scope
|
||||
importStarred = self.scope.importStarred
|
||||
try:
|
||||
self.scope[node.id].used = (self.scope, node)
|
||||
except KeyError:
|
||||
pass
|
||||
else:
|
||||
return
|
||||
|
||||
# try enclosing function scopes
|
||||
|
||||
for scope in self.scopeStack[-2:0:-1]:
|
||||
importStarred = importStarred or scope.importStarred
|
||||
if not isinstance(scope, FunctionScope):
|
||||
continue
|
||||
try:
|
||||
scope[node.id].used = (self.scope, node)
|
||||
except KeyError:
|
||||
pass
|
||||
else:
|
||||
return
|
||||
|
||||
# try global scope
|
||||
|
||||
importStarred = importStarred or self.scopeStack[0].importStarred
|
||||
try:
|
||||
self.scopeStack[0][node.id].used = (self.scope, node)
|
||||
except KeyError:
|
||||
if ((not hasattr(__builtin__, node.id))
|
||||
and node.id not in _MAGIC_GLOBALS
|
||||
and not importStarred):
|
||||
if (os.path.basename(self.filename) == '__init__.py' and
|
||||
node.id == '__path__'):
|
||||
# the special name __path__ is valid only in packages
|
||||
pass
|
||||
else:
|
||||
self.report(messages.UndefinedName, node, node.id)
|
||||
elif isinstance(node.ctx, (_ast.Store, _ast.AugStore)):
|
||||
# if the name hasn't already been defined in the current scope
|
||||
if isinstance(self.scope, FunctionScope) and node.id not in self.scope:
|
||||
# for each function or module scope above us
|
||||
for scope in self.scopeStack[:-1]:
|
||||
if not isinstance(scope, (FunctionScope, ModuleScope)):
|
||||
continue
|
||||
# if the name was defined in that scope, and the name has
|
||||
# been accessed already in the current scope, and hasn't
|
||||
# been declared global
|
||||
if (node.id in scope
|
||||
and scope[node.id].used
|
||||
and scope[node.id].used[0] is self.scope
|
||||
and node.id not in self.scope.globals):
|
||||
# then it's probably a mistake
|
||||
self.report(messages.UndefinedLocal,
|
||||
scope[node.id].used[1],
|
||||
node.id,
|
||||
scope[node.id].source)
|
||||
break
|
||||
|
||||
if isinstance(node.parent,
|
||||
(_ast.For, _ast.comprehension, _ast.Tuple, _ast.List)):
|
||||
binding = Binding(node.id, node)
|
||||
elif (node.id == '__all__' and
|
||||
isinstance(self.scope, ModuleScope)):
|
||||
binding = ExportBinding(node.id, node.parent.value)
|
||||
else:
|
||||
binding = Assignment(node.id, node)
|
||||
if node.id in self.scope:
|
||||
binding.used = self.scope[node.id].used
|
||||
self.addBinding(node, binding)
|
||||
elif isinstance(node.ctx, _ast.Del):
|
||||
if isinstance(self.scope, FunctionScope) and \
|
||||
node.id in self.scope.globals:
|
||||
del self.scope.globals[node.id]
|
||||
else:
|
||||
self.addBinding(node, UnBinding(node.id, node))
|
||||
else:
|
||||
# must be a Param context -- this only happens for names in function
|
||||
# arguments, but these aren't dispatched through here
|
||||
raise RuntimeError(
|
||||
"Got impossible expression context: %r" % (node.ctx,))
|
||||
|
||||
|
||||
def FUNCTIONDEF(self, node):
|
||||
# the decorators attribute is called decorator_list as of Python 2.6
|
||||
if hasattr(node, 'decorators'):
|
||||
for deco in node.decorators:
|
||||
self.handleNode(deco, node)
|
||||
else:
|
||||
for deco in node.decorator_list:
|
||||
self.handleNode(deco, node)
|
||||
self.addBinding(node, FunctionDefinition(node.name, node))
|
||||
self.LAMBDA(node)
|
||||
|
||||
def LAMBDA(self, node):
|
||||
for default in node.args.defaults:
|
||||
self.handleNode(default, node)
|
||||
|
||||
def runFunction():
|
||||
args = []
|
||||
|
||||
def addArgs(arglist):
|
||||
for arg in arglist:
|
||||
if isinstance(arg, _ast.Tuple):
|
||||
addArgs(arg.elts)
|
||||
else:
|
||||
if arg.id in args:
|
||||
self.report(messages.DuplicateArgument,
|
||||
node, arg.id)
|
||||
args.append(arg.id)
|
||||
|
||||
self.pushFunctionScope()
|
||||
addArgs(node.args.args)
|
||||
# vararg/kwarg identifiers are not Name nodes
|
||||
if node.args.vararg:
|
||||
args.append(node.args.vararg)
|
||||
if node.args.kwarg:
|
||||
args.append(node.args.kwarg)
|
||||
for name in args:
|
||||
self.addBinding(node, Argument(name, node), reportRedef=False)
|
||||
if isinstance(node.body, list):
|
||||
# case for FunctionDefs
|
||||
for stmt in node.body:
|
||||
self.handleNode(stmt, node)
|
||||
else:
|
||||
# case for Lambdas
|
||||
self.handleNode(node.body, node)
|
||||
def checkUnusedAssignments():
|
||||
"""
|
||||
Check to see if any assignments have not been used.
|
||||
"""
|
||||
for name, binding in self.scope.iteritems():
|
||||
if (not binding.used and not name in self.scope.globals
|
||||
and isinstance(binding, Assignment)):
|
||||
self.report(messages.UnusedVariable,
|
||||
binding.source, name)
|
||||
self.deferAssignment(checkUnusedAssignments)
|
||||
self.popScope()
|
||||
|
||||
self.deferFunction(runFunction)
|
||||
|
||||
|
||||
def CLASSDEF(self, node):
|
||||
"""
|
||||
Check names used in a class definition, including its decorators, base
|
||||
classes, and the body of its definition. Additionally, add its name to
|
||||
the current scope.
|
||||
"""
|
||||
# decorator_list is present as of Python 2.6
|
||||
for deco in getattr(node, 'decorator_list', []):
|
||||
self.handleNode(deco, node)
|
||||
for baseNode in node.bases:
|
||||
self.handleNode(baseNode, node)
|
||||
self.pushClassScope()
|
||||
for stmt in node.body:
|
||||
self.handleNode(stmt, node)
|
||||
self.popScope()
|
||||
self.addBinding(node, Binding(node.name, node))
|
||||
|
||||
def ASSIGN(self, node):
|
||||
self.handleNode(node.value, node)
|
||||
for target in node.targets:
|
||||
self.handleNode(target, node)
|
||||
|
||||
def AUGASSIGN(self, node):
|
||||
# AugAssign is awkward: must set the context explicitly and visit twice,
|
||||
# once with AugLoad context, once with AugStore context
|
||||
node.target.ctx = _ast.AugLoad()
|
||||
self.handleNode(node.target, node)
|
||||
self.handleNode(node.value, node)
|
||||
node.target.ctx = _ast.AugStore()
|
||||
self.handleNode(node.target, node)
|
||||
|
||||
def IMPORT(self, node):
|
||||
for alias in node.names:
|
||||
name = alias.asname or alias.name
|
||||
importation = Importation(name, node)
|
||||
self.addBinding(node, importation)
|
||||
|
||||
def IMPORTFROM(self, node):
|
||||
if node.module == '__future__':
|
||||
if not self.futuresAllowed:
|
||||
self.report(messages.LateFutureImport, node,
|
||||
[n.name for n in node.names])
|
||||
else:
|
||||
self.futuresAllowed = False
|
||||
|
||||
for alias in node.names:
|
||||
if alias.name == '*':
|
||||
self.scope.importStarred = True
|
||||
self.report(messages.ImportStarUsed, node, node.module)
|
||||
continue
|
||||
name = alias.asname or alias.name
|
||||
importation = Importation(name, node)
|
||||
if node.module == '__future__':
|
||||
importation.used = (self.scope, node)
|
||||
self.addBinding(node, importation)
|
||||
@@ -1,96 +0,0 @@
|
||||
# (c) 2005 Divmod, Inc. See LICENSE file for details
|
||||
|
||||
class Message(object):
|
||||
message = ''
|
||||
message_args = ()
|
||||
def __init__(self, filename, loc, use_column=True):
|
||||
self.filename = filename
|
||||
self.lineno = loc.lineno
|
||||
self.col = getattr(loc, 'col_offset', None) if use_column else None
|
||||
|
||||
def __str__(self):
|
||||
return '%s:%s: %s' % (self.filename, self.lineno, self.message % self.message_args)
|
||||
|
||||
|
||||
class UnusedImport(Message):
|
||||
message = '%r imported but unused'
|
||||
def __init__(self, filename, loc, name):
|
||||
Message.__init__(self, filename, loc, use_column=False)
|
||||
self.message_args = (name,)
|
||||
|
||||
|
||||
class RedefinedWhileUnused(Message):
|
||||
message = 'redefinition of unused %r from line %r'
|
||||
def __init__(self, filename, loc, name, orig_loc):
|
||||
Message.__init__(self, filename, loc)
|
||||
self.message_args = (name, orig_loc.lineno)
|
||||
|
||||
|
||||
class ImportShadowedByLoopVar(Message):
|
||||
message = 'import %r from line %r shadowed by loop variable'
|
||||
def __init__(self, filename, loc, name, orig_loc):
|
||||
Message.__init__(self, filename, loc)
|
||||
self.message_args = (name, orig_loc.lineno)
|
||||
|
||||
|
||||
class ImportStarUsed(Message):
|
||||
message = "'from %s import *' used; unable to detect undefined names"
|
||||
def __init__(self, filename, loc, modname):
|
||||
Message.__init__(self, filename, loc)
|
||||
self.message_args = (modname,)
|
||||
|
||||
|
||||
class UndefinedName(Message):
|
||||
message = 'undefined name %r'
|
||||
def __init__(self, filename, loc, name):
|
||||
Message.__init__(self, filename, loc)
|
||||
self.message_args = (name,)
|
||||
|
||||
|
||||
|
||||
class UndefinedExport(Message):
|
||||
message = 'undefined name %r in __all__'
|
||||
def __init__(self, filename, loc, name):
|
||||
Message.__init__(self, filename, loc)
|
||||
self.message_args = (name,)
|
||||
|
||||
|
||||
|
||||
class UndefinedLocal(Message):
|
||||
message = "local variable %r (defined in enclosing scope on line %r) referenced before assignment"
|
||||
def __init__(self, filename, loc, name, orig_loc):
|
||||
Message.__init__(self, filename, loc)
|
||||
self.message_args = (name, orig_loc.lineno)
|
||||
|
||||
|
||||
class DuplicateArgument(Message):
|
||||
message = 'duplicate argument %r in function definition'
|
||||
def __init__(self, filename, loc, name):
|
||||
Message.__init__(self, filename, loc)
|
||||
self.message_args = (name,)
|
||||
|
||||
|
||||
class RedefinedFunction(Message):
|
||||
message = 'redefinition of function %r from line %r'
|
||||
def __init__(self, filename, loc, name, orig_loc):
|
||||
Message.__init__(self, filename, loc)
|
||||
self.message_args = (name, orig_loc.lineno)
|
||||
|
||||
|
||||
class LateFutureImport(Message):
|
||||
message = 'future import(s) %r after other statements'
|
||||
def __init__(self, filename, loc, names):
|
||||
Message.__init__(self, filename, loc)
|
||||
self.message_args = (names,)
|
||||
|
||||
|
||||
class UnusedVariable(Message):
|
||||
"""
|
||||
Indicates that a variable has been explicity assigned to but not actually
|
||||
used.
|
||||
"""
|
||||
|
||||
message = 'local variable %r is assigned to but never used'
|
||||
def __init__(self, filename, loc, names):
|
||||
Message.__init__(self, filename, loc)
|
||||
self.message_args = (names,)
|
||||
@@ -1,90 +0,0 @@
|
||||
|
||||
"""
|
||||
Implementation of the command-line I{pyflakes} tool.
|
||||
"""
|
||||
|
||||
import sys
|
||||
import os
|
||||
import _ast
|
||||
|
||||
checker = __import__('pyflakes.checker').checker
|
||||
|
||||
def check(codeString, filename):
|
||||
"""
|
||||
Check the Python source given by C{codeString} for flakes.
|
||||
|
||||
@param codeString: The Python source to check.
|
||||
@type codeString: C{str}
|
||||
|
||||
@param filename: The name of the file the source came from, used to report
|
||||
errors.
|
||||
@type filename: C{str}
|
||||
|
||||
@return: The number of warnings emitted.
|
||||
@rtype: C{int}
|
||||
"""
|
||||
# First, compile into an AST and handle syntax errors.
|
||||
try:
|
||||
tree = compile(codeString, filename, "exec", _ast.PyCF_ONLY_AST)
|
||||
except SyntaxError, value:
|
||||
msg = value.args[0]
|
||||
|
||||
(lineno, offset, text) = value.lineno, value.offset, value.text
|
||||
|
||||
# If there's an encoding problem with the file, the text is None.
|
||||
if text is None:
|
||||
# Avoid using msg, since for the only known case, it contains a
|
||||
# bogus message that claims the encoding the file declared was
|
||||
# unknown.
|
||||
print >> sys.stderr, "%s: problem decoding source" % (filename, )
|
||||
else:
|
||||
line = text.splitlines()[-1]
|
||||
|
||||
if offset is not None:
|
||||
offset = offset - (len(text) - len(line))
|
||||
|
||||
print >> sys.stderr, '%s:%d: %s' % (filename, lineno, msg)
|
||||
print >> sys.stderr, line
|
||||
|
||||
if offset is not None:
|
||||
print >> sys.stderr, " " * offset, "^"
|
||||
|
||||
return 1
|
||||
else:
|
||||
# Okay, it's syntactically valid. Now check it.
|
||||
w = checker.Checker(tree, filename)
|
||||
w.messages.sort(lambda a, b: cmp(a.lineno, b.lineno))
|
||||
for warning in w.messages:
|
||||
print warning
|
||||
return len(w.messages)
|
||||
|
||||
|
||||
def checkPath(filename):
|
||||
"""
|
||||
Check the given path, printing out any warnings detected.
|
||||
|
||||
@return: the number of warnings printed
|
||||
"""
|
||||
try:
|
||||
return check(file(filename, 'U').read() + '\n', filename)
|
||||
except IOError, msg:
|
||||
print >> sys.stderr, "%s: %s" % (filename, msg.args[1])
|
||||
return 1
|
||||
|
||||
|
||||
def main():
|
||||
warnings = 0
|
||||
args = sys.argv[1:]
|
||||
if args:
|
||||
for arg in args:
|
||||
if os.path.isdir(arg):
|
||||
for dirpath, dirnames, filenames in os.walk(arg):
|
||||
for filename in filenames:
|
||||
if filename.endswith('.py'):
|
||||
warnings += checkPath(os.path.join(dirpath, filename))
|
||||
else:
|
||||
warnings += checkPath(arg)
|
||||
else:
|
||||
warnings += check(sys.stdin.read(), '<stdin>')
|
||||
|
||||
raise SystemExit(warnings > 0)
|
||||
@@ -1,27 +0,0 @@
|
||||
|
||||
import textwrap
|
||||
import _ast
|
||||
|
||||
from twisted.trial import unittest
|
||||
|
||||
from pyflakes import checker
|
||||
|
||||
|
||||
class Test(unittest.TestCase):
|
||||
|
||||
def flakes(self, input, *expectedOutputs, **kw):
|
||||
ast = compile(textwrap.dedent(input), "<test>", "exec",
|
||||
_ast.PyCF_ONLY_AST)
|
||||
w = checker.Checker(ast, **kw)
|
||||
outputs = [type(o) for o in w.messages]
|
||||
expectedOutputs = list(expectedOutputs)
|
||||
outputs.sort()
|
||||
expectedOutputs.sort()
|
||||
self.assert_(outputs == expectedOutputs, '''\
|
||||
for input:
|
||||
%s
|
||||
expected outputs:
|
||||
%s
|
||||
but got:
|
||||
%s''' % (input, repr(expectedOutputs), '\n'.join([str(o) for o in w.messages])))
|
||||
return w
|
||||
@@ -1,673 +0,0 @@
|
||||
|
||||
from sys import version_info
|
||||
|
||||
from pyflakes import messages as m
|
||||
from pyflakes.test import harness
|
||||
|
||||
class Test(harness.Test):
|
||||
|
||||
def test_unusedImport(self):
|
||||
self.flakes('import fu, bar', m.UnusedImport, m.UnusedImport)
|
||||
self.flakes('from baz import fu, bar', m.UnusedImport, m.UnusedImport)
|
||||
|
||||
def test_aliasedImport(self):
|
||||
self.flakes('import fu as FU, bar as FU', m.RedefinedWhileUnused, m.UnusedImport)
|
||||
self.flakes('from moo import fu as FU, bar as FU', m.RedefinedWhileUnused, m.UnusedImport)
|
||||
|
||||
def test_usedImport(self):
|
||||
self.flakes('import fu; print fu')
|
||||
self.flakes('from baz import fu; print fu')
|
||||
|
||||
def test_redefinedWhileUnused(self):
|
||||
self.flakes('import fu; fu = 3', m.RedefinedWhileUnused)
|
||||
self.flakes('import fu; del fu', m.RedefinedWhileUnused)
|
||||
self.flakes('import fu; fu, bar = 3', m.RedefinedWhileUnused)
|
||||
self.flakes('import fu; [fu, bar] = 3', m.RedefinedWhileUnused)
|
||||
|
||||
def test_redefinedByFunction(self):
|
||||
self.flakes('''
|
||||
import fu
|
||||
def fu():
|
||||
pass
|
||||
''', m.RedefinedWhileUnused)
|
||||
|
||||
def test_redefinedInNestedFunction(self):
|
||||
"""
|
||||
Test that shadowing a global name with a nested function definition
|
||||
generates a warning.
|
||||
"""
|
||||
self.flakes('''
|
||||
import fu
|
||||
def bar():
|
||||
def baz():
|
||||
def fu():
|
||||
pass
|
||||
''', m.RedefinedWhileUnused, m.UnusedImport)
|
||||
|
||||
def test_redefinedByClass(self):
|
||||
self.flakes('''
|
||||
import fu
|
||||
class fu:
|
||||
pass
|
||||
''', m.RedefinedWhileUnused)
|
||||
|
||||
|
||||
def test_redefinedBySubclass(self):
|
||||
"""
|
||||
If an imported name is redefined by a class statement which also uses
|
||||
that name in the bases list, no warning is emitted.
|
||||
"""
|
||||
self.flakes('''
|
||||
from fu import bar
|
||||
class bar(bar):
|
||||
pass
|
||||
''')
|
||||
|
||||
|
||||
def test_redefinedInClass(self):
|
||||
"""
|
||||
Test that shadowing a global with a class attribute does not produce a
|
||||
warning.
|
||||
"""
|
||||
self.flakes('''
|
||||
import fu
|
||||
class bar:
|
||||
fu = 1
|
||||
print fu
|
||||
''')
|
||||
|
||||
def test_usedInFunction(self):
|
||||
self.flakes('''
|
||||
import fu
|
||||
def fun():
|
||||
print fu
|
||||
''')
|
||||
|
||||
def test_shadowedByParameter(self):
|
||||
self.flakes('''
|
||||
import fu
|
||||
def fun(fu):
|
||||
print fu
|
||||
''', m.UnusedImport)
|
||||
|
||||
self.flakes('''
|
||||
import fu
|
||||
def fun(fu):
|
||||
print fu
|
||||
print fu
|
||||
''')
|
||||
|
||||
def test_newAssignment(self):
|
||||
self.flakes('fu = None')
|
||||
|
||||
def test_usedInGetattr(self):
|
||||
self.flakes('import fu; fu.bar.baz')
|
||||
self.flakes('import fu; "bar".fu.baz', m.UnusedImport)
|
||||
|
||||
def test_usedInSlice(self):
|
||||
self.flakes('import fu; print fu.bar[1:]')
|
||||
|
||||
def test_usedInIfBody(self):
|
||||
self.flakes('''
|
||||
import fu
|
||||
if True: print fu
|
||||
''')
|
||||
|
||||
def test_usedInIfConditional(self):
|
||||
self.flakes('''
|
||||
import fu
|
||||
if fu: pass
|
||||
''')
|
||||
|
||||
def test_usedInElifConditional(self):
|
||||
self.flakes('''
|
||||
import fu
|
||||
if False: pass
|
||||
elif fu: pass
|
||||
''')
|
||||
|
||||
def test_usedInElse(self):
|
||||
self.flakes('''
|
||||
import fu
|
||||
if False: pass
|
||||
else: print fu
|
||||
''')
|
||||
|
||||
def test_usedInCall(self):
|
||||
self.flakes('import fu; fu.bar()')
|
||||
|
||||
def test_usedInClass(self):
|
||||
self.flakes('''
|
||||
import fu
|
||||
class bar:
|
||||
bar = fu
|
||||
''')
|
||||
|
||||
def test_usedInClassBase(self):
|
||||
self.flakes('''
|
||||
import fu
|
||||
class bar(object, fu.baz):
|
||||
pass
|
||||
''')
|
||||
|
||||
def test_notUsedInNestedScope(self):
|
||||
self.flakes('''
|
||||
import fu
|
||||
def bleh():
|
||||
pass
|
||||
print fu
|
||||
''')
|
||||
|
||||
def test_usedInFor(self):
|
||||
self.flakes('''
|
||||
import fu
|
||||
for bar in range(9):
|
||||
print fu
|
||||
''')
|
||||
|
||||
def test_usedInForElse(self):
|
||||
self.flakes('''
|
||||
import fu
|
||||
for bar in range(10):
|
||||
pass
|
||||
else:
|
||||
print fu
|
||||
''')
|
||||
|
||||
def test_redefinedByFor(self):
|
||||
self.flakes('''
|
||||
import fu
|
||||
for fu in range(2):
|
||||
pass
|
||||
''', m.RedefinedWhileUnused)
|
||||
|
||||
def test_shadowedByFor(self):
|
||||
"""
|
||||
Test that shadowing a global name with a for loop variable generates a
|
||||
warning.
|
||||
"""
|
||||
self.flakes('''
|
||||
import fu
|
||||
fu.bar()
|
||||
for fu in ():
|
||||
pass
|
||||
''', m.ImportShadowedByLoopVar)
|
||||
|
||||
def test_shadowedByForDeep(self):
|
||||
"""
|
||||
Test that shadowing a global name with a for loop variable nested in a
|
||||
tuple unpack generates a warning.
|
||||
"""
|
||||
self.flakes('''
|
||||
import fu
|
||||
fu.bar()
|
||||
for (x, y, z, (a, b, c, (fu,))) in ():
|
||||
pass
|
||||
''', m.ImportShadowedByLoopVar)
|
||||
|
||||
def test_usedInReturn(self):
|
||||
self.flakes('''
|
||||
import fu
|
||||
def fun():
|
||||
return fu
|
||||
''')
|
||||
|
||||
def test_usedInOperators(self):
|
||||
self.flakes('import fu; 3 + fu.bar')
|
||||
self.flakes('import fu; 3 % fu.bar')
|
||||
self.flakes('import fu; 3 - fu.bar')
|
||||
self.flakes('import fu; 3 * fu.bar')
|
||||
self.flakes('import fu; 3 ** fu.bar')
|
||||
self.flakes('import fu; 3 / fu.bar')
|
||||
self.flakes('import fu; 3 // fu.bar')
|
||||
self.flakes('import fu; -fu.bar')
|
||||
self.flakes('import fu; ~fu.bar')
|
||||
self.flakes('import fu; 1 == fu.bar')
|
||||
self.flakes('import fu; 1 | fu.bar')
|
||||
self.flakes('import fu; 1 & fu.bar')
|
||||
self.flakes('import fu; 1 ^ fu.bar')
|
||||
self.flakes('import fu; 1 >> fu.bar')
|
||||
self.flakes('import fu; 1 << fu.bar')
|
||||
|
||||
def test_usedInAssert(self):
|
||||
self.flakes('import fu; assert fu.bar')
|
||||
|
||||
def test_usedInSubscript(self):
|
||||
self.flakes('import fu; fu.bar[1]')
|
||||
|
||||
def test_usedInLogic(self):
|
||||
self.flakes('import fu; fu and False')
|
||||
self.flakes('import fu; fu or False')
|
||||
self.flakes('import fu; not fu.bar')
|
||||
|
||||
def test_usedInList(self):
|
||||
self.flakes('import fu; [fu]')
|
||||
|
||||
def test_usedInTuple(self):
|
||||
self.flakes('import fu; (fu,)')
|
||||
|
||||
def test_usedInTry(self):
|
||||
self.flakes('''
|
||||
import fu
|
||||
try: fu
|
||||
except: pass
|
||||
''')
|
||||
|
||||
def test_usedInExcept(self):
|
||||
self.flakes('''
|
||||
import fu
|
||||
try: fu
|
||||
except: pass
|
||||
''')
|
||||
|
||||
def test_redefinedByExcept(self):
|
||||
self.flakes('''
|
||||
import fu
|
||||
try: pass
|
||||
except Exception, fu: pass
|
||||
''', m.RedefinedWhileUnused)
|
||||
|
||||
def test_usedInRaise(self):
|
||||
self.flakes('''
|
||||
import fu
|
||||
raise fu.bar
|
||||
''')
|
||||
|
||||
def test_usedInYield(self):
|
||||
self.flakes('''
|
||||
import fu
|
||||
def gen():
|
||||
yield fu
|
||||
''')
|
||||
|
||||
def test_usedInDict(self):
|
||||
self.flakes('import fu; {fu:None}')
|
||||
self.flakes('import fu; {1:fu}')
|
||||
|
||||
def test_usedInParameterDefault(self):
|
||||
self.flakes('''
|
||||
import fu
|
||||
def f(bar=fu):
|
||||
pass
|
||||
''')
|
||||
|
||||
def test_usedInAttributeAssign(self):
|
||||
self.flakes('import fu; fu.bar = 1')
|
||||
|
||||
def test_usedInKeywordArg(self):
|
||||
self.flakes('import fu; fu.bar(stuff=fu)')
|
||||
|
||||
def test_usedInAssignment(self):
|
||||
self.flakes('import fu; bar=fu')
|
||||
self.flakes('import fu; n=0; n+=fu')
|
||||
|
||||
def test_usedInListComp(self):
|
||||
self.flakes('import fu; [fu for _ in range(1)]')
|
||||
self.flakes('import fu; [1 for _ in range(1) if fu]')
|
||||
|
||||
def test_redefinedByListComp(self):
|
||||
self.flakes('import fu; [1 for fu in range(1)]', m.RedefinedWhileUnused)
|
||||
|
||||
|
||||
def test_usedInTryFinally(self):
|
||||
self.flakes('''
|
||||
import fu
|
||||
try: pass
|
||||
finally: fu
|
||||
''')
|
||||
|
||||
self.flakes('''
|
||||
import fu
|
||||
try: fu
|
||||
finally: pass
|
||||
''')
|
||||
|
||||
def test_usedInWhile(self):
|
||||
self.flakes('''
|
||||
import fu
|
||||
while 0:
|
||||
fu
|
||||
''')
|
||||
|
||||
self.flakes('''
|
||||
import fu
|
||||
while fu: pass
|
||||
''')
|
||||
|
||||
def test_usedInGlobal(self):
|
||||
self.flakes('''
|
||||
import fu
|
||||
def f(): global fu
|
||||
''', m.UnusedImport)
|
||||
|
||||
def test_usedInBackquote(self):
|
||||
self.flakes('import fu; `fu`')
|
||||
|
||||
def test_usedInExec(self):
|
||||
self.flakes('import fu; exec "print 1" in fu.bar')
|
||||
|
||||
def test_usedInLambda(self):
|
||||
self.flakes('import fu; lambda: fu')
|
||||
|
||||
def test_shadowedByLambda(self):
|
||||
self.flakes('import fu; lambda fu: fu', m.UnusedImport)
|
||||
|
||||
def test_usedInSliceObj(self):
|
||||
self.flakes('import fu; "meow"[::fu]')
|
||||
|
||||
def test_unusedInNestedScope(self):
|
||||
self.flakes('''
|
||||
def bar():
|
||||
import fu
|
||||
fu
|
||||
''', m.UnusedImport, m.UndefinedName)
|
||||
|
||||
def test_methodsDontUseClassScope(self):
|
||||
self.flakes('''
|
||||
class bar:
|
||||
import fu
|
||||
def fun(self):
|
||||
fu
|
||||
''', m.UnusedImport, m.UndefinedName)
|
||||
|
||||
def test_nestedFunctionsNestScope(self):
|
||||
self.flakes('''
|
||||
def a():
|
||||
def b():
|
||||
fu
|
||||
import fu
|
||||
''')
|
||||
|
||||
def test_nestedClassAndFunctionScope(self):
|
||||
self.flakes('''
|
||||
def a():
|
||||
import fu
|
||||
class b:
|
||||
def c(self):
|
||||
print fu
|
||||
''')
|
||||
|
||||
def test_importStar(self):
|
||||
self.flakes('from fu import *', m.ImportStarUsed)
|
||||
|
||||
|
||||
def test_packageImport(self):
|
||||
"""
|
||||
If a dotted name is imported and used, no warning is reported.
|
||||
"""
|
||||
self.flakes('''
|
||||
import fu.bar
|
||||
fu.bar
|
||||
''')
|
||||
|
||||
|
||||
def test_unusedPackageImport(self):
|
||||
"""
|
||||
If a dotted name is imported and not used, an unused import warning is
|
||||
reported.
|
||||
"""
|
||||
self.flakes('import fu.bar', m.UnusedImport)
|
||||
|
||||
|
||||
def test_duplicateSubmoduleImport(self):
|
||||
"""
|
||||
If a submodule of a package is imported twice, an unused import warning
|
||||
and a redefined while unused warning are reported.
|
||||
"""
|
||||
self.flakes('''
|
||||
import fu.bar, fu.bar
|
||||
fu.bar
|
||||
''', m.RedefinedWhileUnused)
|
||||
self.flakes('''
|
||||
import fu.bar
|
||||
import fu.bar
|
||||
fu.bar
|
||||
''', m.RedefinedWhileUnused)
|
||||
|
||||
|
||||
def test_differentSubmoduleImport(self):
|
||||
"""
|
||||
If two different submodules of a package are imported, no duplicate
|
||||
import warning is reported for the package.
|
||||
"""
|
||||
self.flakes('''
|
||||
import fu.bar, fu.baz
|
||||
fu.bar, fu.baz
|
||||
''')
|
||||
self.flakes('''
|
||||
import fu.bar
|
||||
import fu.baz
|
||||
fu.bar, fu.baz
|
||||
''')
|
||||
|
||||
def test_assignRHSFirst(self):
|
||||
self.flakes('import fu; fu = fu')
|
||||
self.flakes('import fu; fu, bar = fu')
|
||||
self.flakes('import fu; [fu, bar] = fu')
|
||||
self.flakes('import fu; fu += fu')
|
||||
|
||||
def test_tryingMultipleImports(self):
|
||||
self.flakes('''
|
||||
try:
|
||||
import fu
|
||||
except ImportError:
|
||||
import bar as fu
|
||||
''')
|
||||
test_tryingMultipleImports.todo = ''
|
||||
|
||||
def test_nonGlobalDoesNotRedefine(self):
|
||||
self.flakes('''
|
||||
import fu
|
||||
def a():
|
||||
fu = 3
|
||||
return fu
|
||||
fu
|
||||
''')
|
||||
|
||||
def test_functionsRunLater(self):
|
||||
self.flakes('''
|
||||
def a():
|
||||
fu
|
||||
import fu
|
||||
''')
|
||||
|
||||
def test_functionNamesAreBoundNow(self):
|
||||
self.flakes('''
|
||||
import fu
|
||||
def fu():
|
||||
fu
|
||||
fu
|
||||
''', m.RedefinedWhileUnused)
|
||||
|
||||
def test_ignoreNonImportRedefinitions(self):
|
||||
self.flakes('a = 1; a = 2')
|
||||
|
||||
def test_importingForImportError(self):
|
||||
self.flakes('''
|
||||
try:
|
||||
import fu
|
||||
except ImportError:
|
||||
pass
|
||||
''')
|
||||
test_importingForImportError.todo = ''
|
||||
|
||||
def test_importedInClass(self):
|
||||
'''Imports in class scope can be used through self'''
|
||||
self.flakes('''
|
||||
class c:
|
||||
import i
|
||||
def __init__(self):
|
||||
self.i
|
||||
''')
|
||||
test_importedInClass.todo = 'requires evaluating attribute access'
|
||||
|
||||
def test_futureImport(self):
|
||||
'''__future__ is special'''
|
||||
self.flakes('from __future__ import division')
|
||||
self.flakes('''
|
||||
"docstring is allowed before future import"
|
||||
from __future__ import division
|
||||
''')
|
||||
|
||||
def test_futureImportFirst(self):
|
||||
"""
|
||||
__future__ imports must come before anything else.
|
||||
"""
|
||||
self.flakes('''
|
||||
x = 5
|
||||
from __future__ import division
|
||||
''', m.LateFutureImport)
|
||||
self.flakes('''
|
||||
from foo import bar
|
||||
from __future__ import division
|
||||
bar
|
||||
''', m.LateFutureImport)
|
||||
|
||||
|
||||
|
||||
class TestSpecialAll(harness.Test):
|
||||
"""
|
||||
Tests for suppression of unused import warnings by C{__all__}.
|
||||
"""
|
||||
def test_ignoredInFunction(self):
|
||||
"""
|
||||
An C{__all__} definition does not suppress unused import warnings in a
|
||||
function scope.
|
||||
"""
|
||||
self.flakes('''
|
||||
def foo():
|
||||
import bar
|
||||
__all__ = ["bar"]
|
||||
''', m.UnusedImport, m.UnusedVariable)
|
||||
|
||||
|
||||
def test_ignoredInClass(self):
|
||||
"""
|
||||
An C{__all__} definition does not suppress unused import warnings in a
|
||||
class scope.
|
||||
"""
|
||||
self.flakes('''
|
||||
class foo:
|
||||
import bar
|
||||
__all__ = ["bar"]
|
||||
''', m.UnusedImport)
|
||||
|
||||
|
||||
def test_warningSuppressed(self):
|
||||
"""
|
||||
If a name is imported and unused but is named in C{__all__}, no warning
|
||||
is reported.
|
||||
"""
|
||||
self.flakes('''
|
||||
import foo
|
||||
__all__ = ["foo"]
|
||||
''')
|
||||
|
||||
|
||||
def test_unrecognizable(self):
|
||||
"""
|
||||
If C{__all__} is defined in a way that can't be recognized statically,
|
||||
it is ignored.
|
||||
"""
|
||||
self.flakes('''
|
||||
import foo
|
||||
__all__ = ["f" + "oo"]
|
||||
''', m.UnusedImport)
|
||||
self.flakes('''
|
||||
import foo
|
||||
__all__ = [] + ["foo"]
|
||||
''', m.UnusedImport)
|
||||
|
||||
|
||||
def test_unboundExported(self):
|
||||
"""
|
||||
If C{__all__} includes a name which is not bound, a warning is emitted.
|
||||
"""
|
||||
self.flakes('''
|
||||
__all__ = ["foo"]
|
||||
''', m.UndefinedExport)
|
||||
|
||||
# Skip this in __init__.py though, since the rules there are a little
|
||||
# different.
|
||||
for filename in ["foo/__init__.py", "__init__.py"]:
|
||||
self.flakes('''
|
||||
__all__ = ["foo"]
|
||||
''', filename=filename)
|
||||
|
||||
|
||||
def test_usedInGenExp(self):
|
||||
"""
|
||||
Using a global in a generator expression results in no warnings.
|
||||
"""
|
||||
self.flakes('import fu; (fu for _ in range(1))')
|
||||
self.flakes('import fu; (1 for _ in range(1) if fu)')
|
||||
|
||||
|
||||
def test_redefinedByGenExp(self):
|
||||
"""
|
||||
Re-using a global name as the loop variable for a generator
|
||||
expression results in a redefinition warning.
|
||||
"""
|
||||
self.flakes('import fu; (1 for fu in range(1))', m.RedefinedWhileUnused)
|
||||
|
||||
|
||||
def test_usedAsDecorator(self):
|
||||
"""
|
||||
Using a global name in a decorator statement results in no warnings,
|
||||
but using an undefined name in a decorator statement results in an
|
||||
undefined name warning.
|
||||
"""
|
||||
self.flakes('''
|
||||
from interior import decorate
|
||||
@decorate
|
||||
def f():
|
||||
return "hello"
|
||||
''')
|
||||
|
||||
self.flakes('''
|
||||
from interior import decorate
|
||||
@decorate('value')
|
||||
def f():
|
||||
return "hello"
|
||||
''')
|
||||
|
||||
self.flakes('''
|
||||
@decorate
|
||||
def f():
|
||||
return "hello"
|
||||
''', m.UndefinedName)
|
||||
|
||||
|
||||
class Python26Tests(harness.Test):
|
||||
"""
|
||||
Tests for checking of syntax which is valid in PYthon 2.6 and newer.
|
||||
"""
|
||||
if version_info < (2, 6):
|
||||
skip = "Python 2.6 required for class decorator tests."
|
||||
|
||||
|
||||
def test_usedAsClassDecorator(self):
|
||||
"""
|
||||
Using an imported name as a class decorator results in no warnings,
|
||||
but using an undefined name as a class decorator results in an
|
||||
undefined name warning.
|
||||
"""
|
||||
self.flakes('''
|
||||
from interior import decorate
|
||||
@decorate
|
||||
class foo:
|
||||
pass
|
||||
''')
|
||||
|
||||
self.flakes('''
|
||||
from interior import decorate
|
||||
@decorate("foo")
|
||||
class bar:
|
||||
pass
|
||||
''')
|
||||
|
||||
self.flakes('''
|
||||
@decorate
|
||||
class foo:
|
||||
pass
|
||||
''', m.UndefinedName)
|
||||
@@ -1,575 +0,0 @@
|
||||
# (c) 2005-2010 Divmod, Inc.
|
||||
# See LICENSE file for details
|
||||
|
||||
"""
|
||||
Tests for various Pyflakes behavior.
|
||||
"""
|
||||
|
||||
from sys import version_info
|
||||
|
||||
from pyflakes import messages as m
|
||||
from pyflakes.test import harness
|
||||
|
||||
|
||||
class Test(harness.Test):
|
||||
|
||||
def test_duplicateArgs(self):
|
||||
self.flakes('def fu(bar, bar): pass', m.DuplicateArgument)
|
||||
|
||||
def test_localReferencedBeforeAssignment(self):
|
||||
self.flakes('''
|
||||
a = 1
|
||||
def f():
|
||||
a; a=1
|
||||
f()
|
||||
''', m.UndefinedName)
|
||||
test_localReferencedBeforeAssignment.todo = 'this requires finding all assignments in the function body first'
|
||||
|
||||
def test_redefinedFunction(self):
|
||||
"""
|
||||
Test that shadowing a function definition with another one raises a
|
||||
warning.
|
||||
"""
|
||||
self.flakes('''
|
||||
def a(): pass
|
||||
def a(): pass
|
||||
''', m.RedefinedFunction)
|
||||
|
||||
def test_redefinedClassFunction(self):
|
||||
"""
|
||||
Test that shadowing a function definition in a class suite with another
|
||||
one raises a warning.
|
||||
"""
|
||||
self.flakes('''
|
||||
class A:
|
||||
def a(): pass
|
||||
def a(): pass
|
||||
''', m.RedefinedFunction)
|
||||
|
||||
def test_functionDecorator(self):
|
||||
"""
|
||||
Test that shadowing a function definition with a decorated version of
|
||||
that function does not raise a warning.
|
||||
"""
|
||||
self.flakes('''
|
||||
from somewhere import somedecorator
|
||||
|
||||
def a(): pass
|
||||
a = somedecorator(a)
|
||||
''')
|
||||
|
||||
def test_classFunctionDecorator(self):
|
||||
"""
|
||||
Test that shadowing a function definition in a class suite with a
|
||||
decorated version of that function does not raise a warning.
|
||||
"""
|
||||
self.flakes('''
|
||||
class A:
|
||||
def a(): pass
|
||||
a = classmethod(a)
|
||||
''')
|
||||
|
||||
def test_unaryPlus(self):
|
||||
'''Don't die on unary +'''
|
||||
self.flakes('+1')
|
||||
|
||||
|
||||
def test_undefinedBaseClass(self):
|
||||
"""
|
||||
If a name in the base list of a class definition is undefined, a
|
||||
warning is emitted.
|
||||
"""
|
||||
self.flakes('''
|
||||
class foo(foo):
|
||||
pass
|
||||
''', m.UndefinedName)
|
||||
|
||||
|
||||
def test_classNameUndefinedInClassBody(self):
|
||||
"""
|
||||
If a class name is used in the body of that class's definition and
|
||||
the name is not already defined, a warning is emitted.
|
||||
"""
|
||||
self.flakes('''
|
||||
class foo:
|
||||
foo
|
||||
''', m.UndefinedName)
|
||||
|
||||
|
||||
def test_classNameDefinedPreviously(self):
|
||||
"""
|
||||
If a class name is used in the body of that class's definition and
|
||||
the name was previously defined in some other way, no warning is
|
||||
emitted.
|
||||
"""
|
||||
self.flakes('''
|
||||
foo = None
|
||||
class foo:
|
||||
foo
|
||||
''')
|
||||
|
||||
|
||||
def test_comparison(self):
|
||||
"""
|
||||
If a defined name is used on either side of any of the six comparison
|
||||
operators, no warning is emitted.
|
||||
"""
|
||||
self.flakes('''
|
||||
x = 10
|
||||
y = 20
|
||||
x < y
|
||||
x <= y
|
||||
x == y
|
||||
x != y
|
||||
x >= y
|
||||
x > y
|
||||
''')
|
||||
|
||||
|
||||
def test_identity(self):
|
||||
"""
|
||||
If a deefined name is used on either side of an identity test, no
|
||||
warning is emitted.
|
||||
"""
|
||||
self.flakes('''
|
||||
x = 10
|
||||
y = 20
|
||||
x is y
|
||||
x is not y
|
||||
''')
|
||||
|
||||
|
||||
def test_containment(self):
|
||||
"""
|
||||
If a defined name is used on either side of a containment test, no
|
||||
warning is emitted.
|
||||
"""
|
||||
self.flakes('''
|
||||
x = 10
|
||||
y = 20
|
||||
x in y
|
||||
x not in y
|
||||
''')
|
||||
|
||||
|
||||
def test_loopControl(self):
|
||||
"""
|
||||
break and continue statements are supported.
|
||||
"""
|
||||
self.flakes('''
|
||||
for x in [1, 2]:
|
||||
break
|
||||
''')
|
||||
self.flakes('''
|
||||
for x in [1, 2]:
|
||||
continue
|
||||
''')
|
||||
|
||||
|
||||
def test_ellipsis(self):
|
||||
"""
|
||||
Ellipsis in a slice is supported.
|
||||
"""
|
||||
self.flakes('''
|
||||
[1, 2][...]
|
||||
''')
|
||||
|
||||
|
||||
def test_extendedSlice(self):
|
||||
"""
|
||||
Extended slices are supported.
|
||||
"""
|
||||
self.flakes('''
|
||||
x = 3
|
||||
[1, 2][x,:]
|
||||
''')
|
||||
|
||||
|
||||
|
||||
class TestUnusedAssignment(harness.Test):
|
||||
"""
|
||||
Tests for warning about unused assignments.
|
||||
"""
|
||||
|
||||
def test_unusedVariable(self):
|
||||
"""
|
||||
Warn when a variable in a function is assigned a value that's never
|
||||
used.
|
||||
"""
|
||||
self.flakes('''
|
||||
def a():
|
||||
b = 1
|
||||
''', m.UnusedVariable)
|
||||
|
||||
|
||||
def test_assignToGlobal(self):
|
||||
"""
|
||||
Assigning to a global and then not using that global is perfectly
|
||||
acceptable. Do not mistake it for an unused local variable.
|
||||
"""
|
||||
self.flakes('''
|
||||
b = 0
|
||||
def a():
|
||||
global b
|
||||
b = 1
|
||||
''')
|
||||
|
||||
|
||||
def test_assignToMember(self):
|
||||
"""
|
||||
Assigning to a member of another object and then not using that member
|
||||
variable is perfectly acceptable. Do not mistake it for an unused
|
||||
local variable.
|
||||
"""
|
||||
# XXX: Adding this test didn't generate a failure. Maybe not
|
||||
# necessary?
|
||||
self.flakes('''
|
||||
class b:
|
||||
pass
|
||||
def a():
|
||||
b.foo = 1
|
||||
''')
|
||||
|
||||
|
||||
def test_assignInForLoop(self):
|
||||
"""
|
||||
Don't warn when a variable in a for loop is assigned to but not used.
|
||||
"""
|
||||
self.flakes('''
|
||||
def f():
|
||||
for i in range(10):
|
||||
pass
|
||||
''')
|
||||
|
||||
|
||||
def test_assignInListComprehension(self):
|
||||
"""
|
||||
Don't warn when a variable in a list comprehension is assigned to but
|
||||
not used.
|
||||
"""
|
||||
self.flakes('''
|
||||
def f():
|
||||
[None for i in range(10)]
|
||||
''')
|
||||
|
||||
|
||||
def test_generatorExpression(self):
|
||||
"""
|
||||
Don't warn when a variable in a generator expression is assigned to but not used.
|
||||
"""
|
||||
self.flakes('''
|
||||
def f():
|
||||
(None for i in range(10))
|
||||
''')
|
||||
|
||||
|
||||
def test_assignmentInsideLoop(self):
|
||||
"""
|
||||
Don't warn when a variable assignment occurs lexically after its use.
|
||||
"""
|
||||
self.flakes('''
|
||||
def f():
|
||||
x = None
|
||||
for i in range(10):
|
||||
if i > 2:
|
||||
return x
|
||||
x = i * 2
|
||||
''')
|
||||
|
||||
|
||||
def test_tupleUnpacking(self):
|
||||
"""
|
||||
Don't warn when a variable included in tuple unpacking is unused. It's
|
||||
very common for variables in a tuple unpacking assignment to be unused
|
||||
in good Python code, so warning will only create false positives.
|
||||
"""
|
||||
self.flakes('''
|
||||
def f():
|
||||
(x, y) = 1, 2
|
||||
''')
|
||||
|
||||
|
||||
def test_listUnpacking(self):
|
||||
"""
|
||||
Don't warn when a variable included in list unpacking is unused.
|
||||
"""
|
||||
self.flakes('''
|
||||
def f():
|
||||
[x, y] = [1, 2]
|
||||
''')
|
||||
|
||||
|
||||
def test_closedOver(self):
|
||||
"""
|
||||
Don't warn when the assignment is used in an inner function.
|
||||
"""
|
||||
self.flakes('''
|
||||
def barMaker():
|
||||
foo = 5
|
||||
def bar():
|
||||
return foo
|
||||
return bar
|
||||
''')
|
||||
|
||||
|
||||
def test_doubleClosedOver(self):
|
||||
"""
|
||||
Don't warn when the assignment is used in an inner function, even if
|
||||
that inner function itself is in an inner function.
|
||||
"""
|
||||
self.flakes('''
|
||||
def barMaker():
|
||||
foo = 5
|
||||
def bar():
|
||||
def baz():
|
||||
return foo
|
||||
return bar
|
||||
''')
|
||||
|
||||
|
||||
|
||||
class Python25Test(harness.Test):
|
||||
"""
|
||||
Tests for checking of syntax only available in Python 2.5 and newer.
|
||||
"""
|
||||
if version_info < (2, 5):
|
||||
skip = "Python 2.5 required for if-else and with tests"
|
||||
|
||||
def test_ifexp(self):
|
||||
"""
|
||||
Test C{foo if bar else baz} statements.
|
||||
"""
|
||||
self.flakes("a = 'moo' if True else 'oink'")
|
||||
self.flakes("a = foo if True else 'oink'", m.UndefinedName)
|
||||
self.flakes("a = 'moo' if True else bar", m.UndefinedName)
|
||||
|
||||
|
||||
def test_withStatementNoNames(self):
|
||||
"""
|
||||
No warnings are emitted for using inside or after a nameless C{with}
|
||||
statement a name defined beforehand.
|
||||
"""
|
||||
self.flakes('''
|
||||
from __future__ import with_statement
|
||||
bar = None
|
||||
with open("foo"):
|
||||
bar
|
||||
bar
|
||||
''')
|
||||
|
||||
def test_withStatementSingleName(self):
|
||||
"""
|
||||
No warnings are emitted for using a name defined by a C{with} statement
|
||||
within the suite or afterwards.
|
||||
"""
|
||||
self.flakes('''
|
||||
from __future__ import with_statement
|
||||
with open('foo') as bar:
|
||||
bar
|
||||
bar
|
||||
''')
|
||||
|
||||
|
||||
def test_withStatementAttributeName(self):
|
||||
"""
|
||||
No warnings are emitted for using an attribute as the target of a
|
||||
C{with} statement.
|
||||
"""
|
||||
self.flakes('''
|
||||
from __future__ import with_statement
|
||||
import foo
|
||||
with open('foo') as foo.bar:
|
||||
pass
|
||||
''')
|
||||
|
||||
|
||||
def test_withStatementSubscript(self):
|
||||
"""
|
||||
No warnings are emitted for using a subscript as the target of a
|
||||
C{with} statement.
|
||||
"""
|
||||
self.flakes('''
|
||||
from __future__ import with_statement
|
||||
import foo
|
||||
with open('foo') as foo[0]:
|
||||
pass
|
||||
''')
|
||||
|
||||
|
||||
def test_withStatementSubscriptUndefined(self):
|
||||
"""
|
||||
An undefined name warning is emitted if the subscript used as the
|
||||
target of a C{with} statement is not defined.
|
||||
"""
|
||||
self.flakes('''
|
||||
from __future__ import with_statement
|
||||
import foo
|
||||
with open('foo') as foo[bar]:
|
||||
pass
|
||||
''', m.UndefinedName)
|
||||
|
||||
|
||||
def test_withStatementTupleNames(self):
|
||||
"""
|
||||
No warnings are emitted for using any of the tuple of names defined by
|
||||
a C{with} statement within the suite or afterwards.
|
||||
"""
|
||||
self.flakes('''
|
||||
from __future__ import with_statement
|
||||
with open('foo') as (bar, baz):
|
||||
bar, baz
|
||||
bar, baz
|
||||
''')
|
||||
|
||||
|
||||
def test_withStatementListNames(self):
|
||||
"""
|
||||
No warnings are emitted for using any of the list of names defined by a
|
||||
C{with} statement within the suite or afterwards.
|
||||
"""
|
||||
self.flakes('''
|
||||
from __future__ import with_statement
|
||||
with open('foo') as [bar, baz]:
|
||||
bar, baz
|
||||
bar, baz
|
||||
''')
|
||||
|
||||
|
||||
def test_withStatementComplicatedTarget(self):
|
||||
"""
|
||||
If the target of a C{with} statement uses any or all of the valid forms
|
||||
for that part of the grammar (See
|
||||
U{http://docs.python.org/reference/compound_stmts.html#the-with-statement}),
|
||||
the names involved are checked both for definedness and any bindings
|
||||
created are respected in the suite of the statement and afterwards.
|
||||
"""
|
||||
self.flakes('''
|
||||
from __future__ import with_statement
|
||||
c = d = e = g = h = i = None
|
||||
with open('foo') as [(a, b), c[d], e.f, g[h:i]]:
|
||||
a, b, c, d, e, g, h, i
|
||||
a, b, c, d, e, g, h, i
|
||||
''')
|
||||
|
||||
|
||||
def test_withStatementSingleNameUndefined(self):
|
||||
"""
|
||||
An undefined name warning is emitted if the name first defined by a
|
||||
C{with} statement is used before the C{with} statement.
|
||||
"""
|
||||
self.flakes('''
|
||||
from __future__ import with_statement
|
||||
bar
|
||||
with open('foo') as bar:
|
||||
pass
|
||||
''', m.UndefinedName)
|
||||
|
||||
|
||||
def test_withStatementTupleNamesUndefined(self):
|
||||
"""
|
||||
An undefined name warning is emitted if a name first defined by a the
|
||||
tuple-unpacking form of the C{with} statement is used before the
|
||||
C{with} statement.
|
||||
"""
|
||||
self.flakes('''
|
||||
from __future__ import with_statement
|
||||
baz
|
||||
with open('foo') as (bar, baz):
|
||||
pass
|
||||
''', m.UndefinedName)
|
||||
|
||||
|
||||
def test_withStatementSingleNameRedefined(self):
|
||||
"""
|
||||
A redefined name warning is emitted if a name bound by an import is
|
||||
rebound by the name defined by a C{with} statement.
|
||||
"""
|
||||
self.flakes('''
|
||||
from __future__ import with_statement
|
||||
import bar
|
||||
with open('foo') as bar:
|
||||
pass
|
||||
''', m.RedefinedWhileUnused)
|
||||
|
||||
|
||||
def test_withStatementTupleNamesRedefined(self):
|
||||
"""
|
||||
A redefined name warning is emitted if a name bound by an import is
|
||||
rebound by one of the names defined by the tuple-unpacking form of a
|
||||
C{with} statement.
|
||||
"""
|
||||
self.flakes('''
|
||||
from __future__ import with_statement
|
||||
import bar
|
||||
with open('foo') as (bar, baz):
|
||||
pass
|
||||
''', m.RedefinedWhileUnused)
|
||||
|
||||
|
||||
def test_withStatementUndefinedInside(self):
|
||||
"""
|
||||
An undefined name warning is emitted if a name is used inside the
|
||||
body of a C{with} statement without first being bound.
|
||||
"""
|
||||
self.flakes('''
|
||||
from __future__ import with_statement
|
||||
with open('foo') as bar:
|
||||
baz
|
||||
''', m.UndefinedName)
|
||||
|
||||
|
||||
def test_withStatementNameDefinedInBody(self):
|
||||
"""
|
||||
A name defined in the body of a C{with} statement can be used after
|
||||
the body ends without warning.
|
||||
"""
|
||||
self.flakes('''
|
||||
from __future__ import with_statement
|
||||
with open('foo') as bar:
|
||||
baz = 10
|
||||
baz
|
||||
''')
|
||||
|
||||
|
||||
def test_withStatementUndefinedInExpression(self):
|
||||
"""
|
||||
An undefined name warning is emitted if a name in the I{test}
|
||||
expression of a C{with} statement is undefined.
|
||||
"""
|
||||
self.flakes('''
|
||||
from __future__ import with_statement
|
||||
with bar as baz:
|
||||
pass
|
||||
''', m.UndefinedName)
|
||||
|
||||
self.flakes('''
|
||||
from __future__ import with_statement
|
||||
with bar as bar:
|
||||
pass
|
||||
''', m.UndefinedName)
|
||||
|
||||
|
||||
|
||||
class Python27Test(harness.Test):
|
||||
"""
|
||||
Tests for checking of syntax only available in Python 2.7 and newer.
|
||||
"""
|
||||
if version_info < (2, 7):
|
||||
skip = "Python 2.7 required for dict/set comprehension tests"
|
||||
|
||||
def test_dictComprehension(self):
|
||||
"""
|
||||
Dict comprehensions are properly handled.
|
||||
"""
|
||||
self.flakes('''
|
||||
a = {1: x for x in range(10)}
|
||||
''')
|
||||
|
||||
def test_setComprehensionAndLiteral(self):
|
||||
"""
|
||||
Set comprehensions are properly handled.
|
||||
"""
|
||||
self.flakes('''
|
||||
a = {1, 2, 3}
|
||||
b = {x for x in range(10)}
|
||||
''')
|
||||
@@ -1,185 +0,0 @@
|
||||
|
||||
"""
|
||||
Tests for L{pyflakes.scripts.pyflakes}.
|
||||
"""
|
||||
|
||||
import sys
|
||||
from StringIO import StringIO
|
||||
|
||||
from twisted.python.filepath import FilePath
|
||||
from twisted.trial.unittest import TestCase
|
||||
|
||||
from pyflakes.scripts.pyflakes import checkPath
|
||||
|
||||
def withStderrTo(stderr, f):
|
||||
"""
|
||||
Call C{f} with C{sys.stderr} redirected to C{stderr}.
|
||||
"""
|
||||
(outer, sys.stderr) = (sys.stderr, stderr)
|
||||
try:
|
||||
return f()
|
||||
finally:
|
||||
sys.stderr = outer
|
||||
|
||||
|
||||
|
||||
class CheckTests(TestCase):
|
||||
"""
|
||||
Tests for L{check} and L{checkPath} which check a file for flakes.
|
||||
"""
|
||||
def test_missingTrailingNewline(self):
|
||||
"""
|
||||
Source which doesn't end with a newline shouldn't cause any
|
||||
exception to be raised nor an error indicator to be returned by
|
||||
L{check}.
|
||||
"""
|
||||
fName = self.mktemp()
|
||||
FilePath(fName).setContent("def foo():\n\tpass\n\t")
|
||||
self.assertFalse(checkPath(fName))
|
||||
|
||||
|
||||
def test_checkPathNonExisting(self):
|
||||
"""
|
||||
L{checkPath} handles non-existing files.
|
||||
"""
|
||||
err = StringIO()
|
||||
count = withStderrTo(err, lambda: checkPath('extremo'))
|
||||
self.assertEquals(err.getvalue(), 'extremo: No such file or directory\n')
|
||||
self.assertEquals(count, 1)
|
||||
|
||||
|
||||
def test_multilineSyntaxError(self):
|
||||
"""
|
||||
Source which includes a syntax error which results in the raised
|
||||
L{SyntaxError.text} containing multiple lines of source are reported
|
||||
with only the last line of that source.
|
||||
"""
|
||||
source = """\
|
||||
def foo():
|
||||
'''
|
||||
|
||||
def bar():
|
||||
pass
|
||||
|
||||
def baz():
|
||||
'''quux'''
|
||||
"""
|
||||
|
||||
# Sanity check - SyntaxError.text should be multiple lines, if it
|
||||
# isn't, something this test was unprepared for has happened.
|
||||
def evaluate(source):
|
||||
exec source
|
||||
exc = self.assertRaises(SyntaxError, evaluate, source)
|
||||
self.assertTrue(exc.text.count('\n') > 1)
|
||||
|
||||
sourcePath = FilePath(self.mktemp())
|
||||
sourcePath.setContent(source)
|
||||
err = StringIO()
|
||||
count = withStderrTo(err, lambda: checkPath(sourcePath.path))
|
||||
self.assertEqual(count, 1)
|
||||
|
||||
self.assertEqual(
|
||||
err.getvalue(),
|
||||
"""\
|
||||
%s:8: invalid syntax
|
||||
'''quux'''
|
||||
^
|
||||
""" % (sourcePath.path,))
|
||||
|
||||
|
||||
def test_eofSyntaxError(self):
|
||||
"""
|
||||
The error reported for source files which end prematurely causing a
|
||||
syntax error reflects the cause for the syntax error.
|
||||
"""
|
||||
source = "def foo("
|
||||
sourcePath = FilePath(self.mktemp())
|
||||
sourcePath.setContent(source)
|
||||
err = StringIO()
|
||||
count = withStderrTo(err, lambda: checkPath(sourcePath.path))
|
||||
self.assertEqual(count, 1)
|
||||
self.assertEqual(
|
||||
err.getvalue(),
|
||||
"""\
|
||||
%s:1: unexpected EOF while parsing
|
||||
def foo(
|
||||
^
|
||||
""" % (sourcePath.path,))
|
||||
|
||||
|
||||
def test_nonDefaultFollowsDefaultSyntaxError(self):
|
||||
"""
|
||||
Source which has a non-default argument following a default argument
|
||||
should include the line number of the syntax error. However these
|
||||
exceptions do not include an offset.
|
||||
"""
|
||||
source = """\
|
||||
def foo(bar=baz, bax):
|
||||
pass
|
||||
"""
|
||||
sourcePath = FilePath(self.mktemp())
|
||||
sourcePath.setContent(source)
|
||||
err = StringIO()
|
||||
count = withStderrTo(err, lambda: checkPath(sourcePath.path))
|
||||
self.assertEqual(count, 1)
|
||||
self.assertEqual(
|
||||
err.getvalue(),
|
||||
"""\
|
||||
%s:1: non-default argument follows default argument
|
||||
def foo(bar=baz, bax):
|
||||
""" % (sourcePath.path,))
|
||||
|
||||
|
||||
def test_nonKeywordAfterKeywordSyntaxError(self):
|
||||
"""
|
||||
Source which has a non-keyword argument after a keyword argument should
|
||||
include the line number of the syntax error. However these exceptions
|
||||
do not include an offset.
|
||||
"""
|
||||
source = """\
|
||||
foo(bar=baz, bax)
|
||||
"""
|
||||
sourcePath = FilePath(self.mktemp())
|
||||
sourcePath.setContent(source)
|
||||
err = StringIO()
|
||||
count = withStderrTo(err, lambda: checkPath(sourcePath.path))
|
||||
self.assertEqual(count, 1)
|
||||
self.assertEqual(
|
||||
err.getvalue(),
|
||||
"""\
|
||||
%s:1: non-keyword arg after keyword arg
|
||||
foo(bar=baz, bax)
|
||||
""" % (sourcePath.path,))
|
||||
|
||||
|
||||
def test_permissionDenied(self):
|
||||
"""
|
||||
If the a source file is not readable, this is reported on standard
|
||||
error.
|
||||
"""
|
||||
sourcePath = FilePath(self.mktemp())
|
||||
sourcePath.setContent('')
|
||||
sourcePath.chmod(0)
|
||||
err = StringIO()
|
||||
count = withStderrTo(err, lambda: checkPath(sourcePath.path))
|
||||
self.assertEquals(count, 1)
|
||||
self.assertEquals(
|
||||
err.getvalue(), "%s: Permission denied\n" % (sourcePath.path,))
|
||||
|
||||
|
||||
def test_misencodedFile(self):
|
||||
"""
|
||||
If a source file contains bytes which cannot be decoded, this is
|
||||
reported on stderr.
|
||||
"""
|
||||
source = u"""\
|
||||
# coding: ascii
|
||||
x = "\N{SNOWMAN}"
|
||||
""".encode('utf-8')
|
||||
sourcePath = FilePath(self.mktemp())
|
||||
sourcePath.setContent(source)
|
||||
err = StringIO()
|
||||
count = withStderrTo(err, lambda: checkPath(sourcePath.path))
|
||||
self.assertEquals(count, 1)
|
||||
self.assertEquals(
|
||||
err.getvalue(), "%s: problem decoding source\n" % (sourcePath.path,))
|
||||
@@ -1,265 +0,0 @@
|
||||
|
||||
from _ast import PyCF_ONLY_AST
|
||||
|
||||
from twisted.trial.unittest import TestCase
|
||||
|
||||
from pyflakes import messages as m, checker
|
||||
from pyflakes.test import harness
|
||||
|
||||
|
||||
class Test(harness.Test):
|
||||
def test_undefined(self):
|
||||
self.flakes('bar', m.UndefinedName)
|
||||
|
||||
def test_definedInListComp(self):
|
||||
self.flakes('[a for a in range(10) if a]')
|
||||
|
||||
|
||||
def test_functionsNeedGlobalScope(self):
|
||||
self.flakes('''
|
||||
class a:
|
||||
def b():
|
||||
fu
|
||||
fu = 1
|
||||
''')
|
||||
|
||||
def test_builtins(self):
|
||||
self.flakes('range(10)')
|
||||
|
||||
|
||||
def test_magicGlobalsFile(self):
|
||||
"""
|
||||
Use of the C{__file__} magic global should not emit an undefined name
|
||||
warning.
|
||||
"""
|
||||
self.flakes('__file__')
|
||||
|
||||
|
||||
def test_magicGlobalsBuiltins(self):
|
||||
"""
|
||||
Use of the C{__builtins__} magic global should not emit an undefined
|
||||
name warning.
|
||||
"""
|
||||
self.flakes('__builtins__')
|
||||
|
||||
|
||||
def test_magicGlobalsName(self):
|
||||
"""
|
||||
Use of the C{__name__} magic global should not emit an undefined name
|
||||
warning.
|
||||
"""
|
||||
self.flakes('__name__')
|
||||
|
||||
|
||||
def test_magicGlobalsPath(self):
|
||||
"""
|
||||
Use of the C{__path__} magic global should not emit an undefined name
|
||||
warning, if you refer to it from a file called __init__.py.
|
||||
"""
|
||||
self.flakes('__path__', m.UndefinedName)
|
||||
self.flakes('__path__', filename='package/__init__.py')
|
||||
|
||||
|
||||
def test_globalImportStar(self):
|
||||
'''Can't find undefined names with import *'''
|
||||
self.flakes('from fu import *; bar', m.ImportStarUsed)
|
||||
|
||||
def test_localImportStar(self):
|
||||
'''A local import * still allows undefined names to be found in upper scopes'''
|
||||
self.flakes('''
|
||||
def a():
|
||||
from fu import *
|
||||
bar
|
||||
''', m.ImportStarUsed, m.UndefinedName)
|
||||
|
||||
def test_unpackedParameter(self):
|
||||
'''Unpacked function parameters create bindings'''
|
||||
self.flakes('''
|
||||
def a((bar, baz)):
|
||||
bar; baz
|
||||
''')
|
||||
|
||||
def test_definedByGlobal(self):
|
||||
'''"global" can make an otherwise undefined name in another function defined'''
|
||||
self.flakes('''
|
||||
def a(): global fu; fu = 1
|
||||
def b(): fu
|
||||
''')
|
||||
test_definedByGlobal.todo = ''
|
||||
|
||||
def test_globalInGlobalScope(self):
|
||||
"""
|
||||
A global statement in the global scope is ignored.
|
||||
"""
|
||||
self.flakes('''
|
||||
global x
|
||||
def foo():
|
||||
print x
|
||||
''', m.UndefinedName)
|
||||
|
||||
def test_del(self):
|
||||
'''del deletes bindings'''
|
||||
self.flakes('a = 1; del a; a', m.UndefinedName)
|
||||
|
||||
def test_delGlobal(self):
|
||||
'''del a global binding from a function'''
|
||||
self.flakes('''
|
||||
a = 1
|
||||
def f():
|
||||
global a
|
||||
del a
|
||||
a
|
||||
''')
|
||||
|
||||
def test_delUndefined(self):
|
||||
'''del an undefined name'''
|
||||
self.flakes('del a', m.UndefinedName)
|
||||
|
||||
def test_globalFromNestedScope(self):
|
||||
'''global names are available from nested scopes'''
|
||||
self.flakes('''
|
||||
a = 1
|
||||
def b():
|
||||
def c():
|
||||
a
|
||||
''')
|
||||
|
||||
def test_laterRedefinedGlobalFromNestedScope(self):
|
||||
"""
|
||||
Test that referencing a local name that shadows a global, before it is
|
||||
defined, generates a warning.
|
||||
"""
|
||||
self.flakes('''
|
||||
a = 1
|
||||
def fun():
|
||||
a
|
||||
a = 2
|
||||
return a
|
||||
''', m.UndefinedLocal)
|
||||
|
||||
def test_laterRedefinedGlobalFromNestedScope2(self):
|
||||
"""
|
||||
Test that referencing a local name in a nested scope that shadows a
|
||||
global declared in an enclosing scope, before it is defined, generates
|
||||
a warning.
|
||||
"""
|
||||
self.flakes('''
|
||||
a = 1
|
||||
def fun():
|
||||
global a
|
||||
def fun2():
|
||||
a
|
||||
a = 2
|
||||
return a
|
||||
''', m.UndefinedLocal)
|
||||
|
||||
|
||||
def test_intermediateClassScopeIgnored(self):
|
||||
"""
|
||||
If a name defined in an enclosing scope is shadowed by a local variable
|
||||
and the name is used locally before it is bound, an unbound local
|
||||
warning is emitted, even if there is a class scope between the enclosing
|
||||
scope and the local scope.
|
||||
"""
|
||||
self.flakes('''
|
||||
def f():
|
||||
x = 1
|
||||
class g:
|
||||
def h(self):
|
||||
a = x
|
||||
x = None
|
||||
print x, a
|
||||
print x
|
||||
''', m.UndefinedLocal)
|
||||
|
||||
|
||||
def test_doubleNestingReportsClosestName(self):
|
||||
"""
|
||||
Test that referencing a local name in a nested scope that shadows a
|
||||
variable declared in two different outer scopes before it is defined
|
||||
in the innermost scope generates an UnboundLocal warning which
|
||||
refers to the nearest shadowed name.
|
||||
"""
|
||||
exc = self.flakes('''
|
||||
def a():
|
||||
x = 1
|
||||
def b():
|
||||
x = 2 # line 5
|
||||
def c():
|
||||
x
|
||||
x = 3
|
||||
return x
|
||||
return x
|
||||
return x
|
||||
''', m.UndefinedLocal).messages[0]
|
||||
self.assertEqual(exc.message_args, ('x', 5))
|
||||
|
||||
|
||||
def test_laterRedefinedGlobalFromNestedScope3(self):
|
||||
"""
|
||||
Test that referencing a local name in a nested scope that shadows a
|
||||
global, before it is defined, generates a warning.
|
||||
"""
|
||||
self.flakes('''
|
||||
def fun():
|
||||
a = 1
|
||||
def fun2():
|
||||
a
|
||||
a = 1
|
||||
return a
|
||||
return a
|
||||
''', m.UndefinedLocal)
|
||||
|
||||
def test_nestedClass(self):
|
||||
'''nested classes can access enclosing scope'''
|
||||
self.flakes('''
|
||||
def f(foo):
|
||||
class C:
|
||||
bar = foo
|
||||
def f(self):
|
||||
return foo
|
||||
return C()
|
||||
|
||||
f(123).f()
|
||||
''')
|
||||
|
||||
def test_badNestedClass(self):
|
||||
'''free variables in nested classes must bind at class creation'''
|
||||
self.flakes('''
|
||||
def f():
|
||||
class C:
|
||||
bar = foo
|
||||
foo = 456
|
||||
return foo
|
||||
f()
|
||||
''', m.UndefinedName)
|
||||
|
||||
def test_definedAsStarArgs(self):
|
||||
'''star and double-star arg names are defined'''
|
||||
self.flakes('''
|
||||
def f(a, *b, **c):
|
||||
print a, b, c
|
||||
''')
|
||||
|
||||
def test_definedInGenExp(self):
|
||||
"""
|
||||
Using the loop variable of a generator expression results in no
|
||||
warnings.
|
||||
"""
|
||||
self.flakes('(a for a in xrange(10) if a)')
|
||||
|
||||
|
||||
|
||||
class NameTests(TestCase):
|
||||
"""
|
||||
Tests for some extra cases of name handling.
|
||||
"""
|
||||
def test_impossibleContext(self):
|
||||
"""
|
||||
A Name node with an unrecognized context results in a RuntimeError being
|
||||
raised.
|
||||
"""
|
||||
tree = compile("x = 10", "<test>", "exec", PyCF_ONLY_AST)
|
||||
# Make it into something unrecognizable.
|
||||
tree.body[0].targets[0].ctx = object()
|
||||
self.assertRaises(RuntimeError, checker.Checker, tree)
|
||||
@@ -1,28 +0,0 @@
|
||||
#!/usr/bin/python
|
||||
# (c) 2005-2009 Divmod, Inc. See LICENSE file for details
|
||||
|
||||
from distutils.core import setup
|
||||
|
||||
setup(
|
||||
name="pyflakes",
|
||||
license="MIT",
|
||||
version="0.4.0",
|
||||
description="passive checker of Python programs",
|
||||
author="Phil Frost",
|
||||
maintainer="Moe Aboulkheir",
|
||||
maintainer_email="moe@divmod.com",
|
||||
url="http://www.divmod.org/trac/wiki/DivmodPyflakes",
|
||||
packages=["pyflakes", "pyflakes.scripts", "pyflakes.test"],
|
||||
scripts=["bin/pyflakes"],
|
||||
long_description="""Pyflakes is program to analyze Python programs and detect various errors. It
|
||||
works by parsing the source file, not importing it, so it is safe to use on
|
||||
modules with side effects. It's also much faster.""",
|
||||
classifiers=[
|
||||
"Development Status :: 6 - Mature",
|
||||
"Environment :: Console",
|
||||
"Intended Audience :: Developers",
|
||||
"License :: OSI Approved :: MIT License",
|
||||
"Programming Language :: Python",
|
||||
"Topic :: Software Development",
|
||||
"Topic :: Utilities",
|
||||
])
|
||||
6
bundle/git_ctrlp/.gitignore
vendored
6
bundle/git_ctrlp/.gitignore
vendored
@@ -1,6 +0,0 @@
|
||||
*.markdown
|
||||
*.zip
|
||||
note.txt
|
||||
tags
|
||||
.hg*
|
||||
tmp/*
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,140 +0,0 @@
|
||||
" =============================================================================
|
||||
" File: autoload/ctrlp/bookmarkdir.vim
|
||||
" Description: Bookmarked directories extension
|
||||
" Author: Kien Nguyen <github.com/kien>
|
||||
" =============================================================================
|
||||
|
||||
" Init {{{1
|
||||
if exists('g:loaded_ctrlp_bookmarkdir') && g:loaded_ctrlp_bookmarkdir
|
||||
fini
|
||||
en
|
||||
let g:loaded_ctrlp_bookmarkdir = 1
|
||||
|
||||
cal add(g:ctrlp_ext_vars, {
|
||||
\ 'init': 'ctrlp#bookmarkdir#init()',
|
||||
\ 'accept': 'ctrlp#bookmarkdir#accept',
|
||||
\ 'lname': 'bookmarked dirs',
|
||||
\ 'sname': 'bkd',
|
||||
\ 'type': 'tabs',
|
||||
\ 'opmul': 1,
|
||||
\ 'nolim': 1,
|
||||
\ 'wipe': 'ctrlp#bookmarkdir#remove',
|
||||
\ })
|
||||
|
||||
let s:id = g:ctrlp_builtins + len(g:ctrlp_ext_vars)
|
||||
" Utilities {{{1
|
||||
fu! s:getinput(str, ...)
|
||||
echoh Identifier
|
||||
cal inputsave()
|
||||
let input = call('input', a:0 ? [a:str] + a:000 : [a:str])
|
||||
cal inputrestore()
|
||||
echoh None
|
||||
retu input
|
||||
endf
|
||||
|
||||
fu! s:cachefile()
|
||||
if !exists('s:cadir') || !exists('s:cafile')
|
||||
let s:cadir = ctrlp#utils#cachedir().ctrlp#utils#lash().'bkd'
|
||||
let s:cafile = s:cadir.ctrlp#utils#lash().'cache.txt'
|
||||
en
|
||||
retu s:cafile
|
||||
endf
|
||||
|
||||
fu! s:writecache(lines)
|
||||
cal ctrlp#utils#writecache(a:lines, s:cadir, s:cafile)
|
||||
endf
|
||||
|
||||
fu! s:getbookmarks()
|
||||
retu ctrlp#utils#readfile(s:cachefile())
|
||||
endf
|
||||
|
||||
fu! s:savebookmark(name, cwd)
|
||||
let cwds = exists('+ssl') ? [tr(a:cwd, '\', '/'), tr(a:cwd, '/', '\')] : [a:cwd]
|
||||
let entries = filter(s:getbookmarks(), 'index(cwds, s:parts(v:val)[1]) < 0')
|
||||
cal s:writecache(insert(entries, a:name.' '.a:cwd))
|
||||
endf
|
||||
|
||||
fu! s:setentries()
|
||||
let time = getftime(s:cachefile())
|
||||
if !( exists('s:bookmarks') && time == s:bookmarks[0] )
|
||||
let s:bookmarks = [time, s:getbookmarks()]
|
||||
en
|
||||
endf
|
||||
|
||||
fu! s:parts(str)
|
||||
let mlist = matchlist(a:str, '\v([^\t]+)\t(.*)$')
|
||||
retu mlist != [] ? mlist[1:2] : ['', '']
|
||||
endf
|
||||
|
||||
fu! s:process(entries, type)
|
||||
retu map(a:entries, 's:modify(v:val, a:type)')
|
||||
endf
|
||||
|
||||
fu! s:modify(entry, type)
|
||||
let [name, dir] = s:parts(a:entry)
|
||||
let dir = fnamemodify(dir, a:type)
|
||||
retu name.' '.( dir == '' ? '.' : dir )
|
||||
endf
|
||||
|
||||
fu! s:msg(name, cwd)
|
||||
redr
|
||||
echoh Identifier | echon 'Bookmarked ' | echoh Constant
|
||||
echon a:name.' ' | echoh Directory | echon a:cwd
|
||||
echoh None
|
||||
endf
|
||||
|
||||
fu! s:syntax()
|
||||
if !ctrlp#nosy()
|
||||
cal ctrlp#hicheck('CtrlPBookmark', 'Identifier')
|
||||
cal ctrlp#hicheck('CtrlPTabExtra', 'Comment')
|
||||
sy match CtrlPBookmark '^> [^\t]\+' contains=CtrlPLinePre
|
||||
sy match CtrlPTabExtra '\zs\t.*\ze$'
|
||||
en
|
||||
endf
|
||||
" Public {{{1
|
||||
fu! ctrlp#bookmarkdir#init()
|
||||
cal s:setentries()
|
||||
cal s:syntax()
|
||||
retu s:process(copy(s:bookmarks[1]), ':.')
|
||||
endf
|
||||
|
||||
fu! ctrlp#bookmarkdir#accept(mode, str)
|
||||
let parts = s:parts(s:modify(a:str, ':p'))
|
||||
cal call('s:savebookmark', parts)
|
||||
if a:mode =~ 't\|v\|h'
|
||||
cal ctrlp#exit()
|
||||
en
|
||||
cal ctrlp#setdir(parts[1], a:mode =~ 't\|h' ? 'chd!' : 'lc!')
|
||||
if a:mode == 'e'
|
||||
cal ctrlp#switchtype(0)
|
||||
cal ctrlp#recordhist()
|
||||
cal ctrlp#prtclear()
|
||||
en
|
||||
endf
|
||||
|
||||
fu! ctrlp#bookmarkdir#add(dir)
|
||||
let str = 'Directory to bookmark: '
|
||||
let cwd = a:dir != '' ? a:dir : s:getinput(str, getcwd(), 'dir')
|
||||
if cwd == '' | retu | en
|
||||
let cwd = fnamemodify(cwd, ':p')
|
||||
let name = s:getinput('Bookmark as: ', cwd)
|
||||
if name == '' | retu | en
|
||||
let name = tr(name, ' ', ' ')
|
||||
cal s:savebookmark(name, cwd)
|
||||
cal s:msg(name, cwd)
|
||||
endf
|
||||
|
||||
fu! ctrlp#bookmarkdir#remove(entries)
|
||||
cal s:process(a:entries, ':p')
|
||||
cal s:writecache(a:entries == [] ? [] :
|
||||
\ filter(s:getbookmarks(), 'index(a:entries, v:val) < 0'))
|
||||
cal s:setentries()
|
||||
retu s:process(copy(s:bookmarks[1]), ':.')
|
||||
endf
|
||||
|
||||
fu! ctrlp#bookmarkdir#id()
|
||||
retu s:id
|
||||
endf
|
||||
"}}}
|
||||
|
||||
" vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1:ts=2:sw=2:sts=2
|
||||
@@ -1,261 +0,0 @@
|
||||
" =============================================================================
|
||||
" File: autoload/ctrlp/buffertag.vim
|
||||
" Description: Buffer Tag extension
|
||||
" Maintainer: Kien Nguyen <github.com/kien>
|
||||
" Credits: Much of the code was taken from tagbar.vim by Jan Larres, plus
|
||||
" a few lines from taglist.vim by Yegappan Lakshmanan and from
|
||||
" buffertag.vim by Takeshi Nishida.
|
||||
" =============================================================================
|
||||
|
||||
" Init {{{1
|
||||
if exists('g:loaded_ctrlp_buftag') && g:loaded_ctrlp_buftag
|
||||
fini
|
||||
en
|
||||
let g:loaded_ctrlp_buftag = 1
|
||||
|
||||
cal add(g:ctrlp_ext_vars, {
|
||||
\ 'init': 'ctrlp#buffertag#init(s:crfile)',
|
||||
\ 'accept': 'ctrlp#buffertag#accept',
|
||||
\ 'lname': 'buffer tags',
|
||||
\ 'sname': 'bft',
|
||||
\ 'exit': 'ctrlp#buffertag#exit()',
|
||||
\ 'type': 'tabs',
|
||||
\ 'opts': 'ctrlp#buffertag#opts()',
|
||||
\ })
|
||||
|
||||
let s:id = g:ctrlp_builtins + len(g:ctrlp_ext_vars)
|
||||
|
||||
let [s:pref, s:opts] = ['g:ctrlp_buftag_', {
|
||||
\ 'systemenc': ['s:enc', &enc],
|
||||
\ 'ctags_bin': ['s:bin', ''],
|
||||
\ 'types': ['s:usr_types', {}],
|
||||
\ }]
|
||||
|
||||
let s:bins = [
|
||||
\ 'ctags-exuberant',
|
||||
\ 'exuberant-ctags',
|
||||
\ 'exctags',
|
||||
\ '/usr/local/bin/ctags',
|
||||
\ '/opt/local/bin/ctags',
|
||||
\ 'ctags',
|
||||
\ 'ctags.exe',
|
||||
\ 'tags',
|
||||
\ ]
|
||||
|
||||
let s:types = {
|
||||
\ 'asm' : '%sasm%sasm%sdlmt',
|
||||
\ 'aspperl': '%sasp%sasp%sfsv',
|
||||
\ 'aspvbs' : '%sasp%sasp%sfsv',
|
||||
\ 'awk' : '%sawk%sawk%sf',
|
||||
\ 'beta' : '%sbeta%sbeta%sfsv',
|
||||
\ 'c' : '%sc%sc%sdgsutvf',
|
||||
\ 'cpp' : '%sc++%sc++%snvdtcgsuf',
|
||||
\ 'cs' : '%sc#%sc#%sdtncEgsipm',
|
||||
\ 'cobol' : '%scobol%scobol%sdfgpPs',
|
||||
\ 'eiffel' : '%seiffel%seiffel%scf',
|
||||
\ 'erlang' : '%serlang%serlang%sdrmf',
|
||||
\ 'expect' : '%stcl%stcl%scfp',
|
||||
\ 'fortran': '%sfortran%sfortran%spbceiklmntvfs',
|
||||
\ 'html' : '%shtml%shtml%saf',
|
||||
\ 'java' : '%sjava%sjava%spcifm',
|
||||
\ 'javascript': '%sjavascript%sjavascript%sf',
|
||||
\ 'lisp' : '%slisp%slisp%sf',
|
||||
\ 'lua' : '%slua%slua%sf',
|
||||
\ 'make' : '%smake%smake%sm',
|
||||
\ 'pascal' : '%spascal%spascal%sfp',
|
||||
\ 'perl' : '%sperl%sperl%sclps',
|
||||
\ 'php' : '%sphp%sphp%scdvf',
|
||||
\ 'python' : '%spython%spython%scmf',
|
||||
\ 'rexx' : '%srexx%srexx%ss',
|
||||
\ 'ruby' : '%sruby%sruby%scfFm',
|
||||
\ 'scheme' : '%sscheme%sscheme%ssf',
|
||||
\ 'sh' : '%ssh%ssh%sf',
|
||||
\ 'csh' : '%ssh%ssh%sf',
|
||||
\ 'zsh' : '%ssh%ssh%sf',
|
||||
\ 'slang' : '%sslang%sslang%snf',
|
||||
\ 'sml' : '%ssml%ssml%secsrtvf',
|
||||
\ 'sql' : '%ssql%ssql%scFPrstTvfp',
|
||||
\ 'tcl' : '%stcl%stcl%scfmp',
|
||||
\ 'vera' : '%svera%svera%scdefgmpPtTvx',
|
||||
\ 'verilog': '%sverilog%sverilog%smcPertwpvf',
|
||||
\ 'vim' : '%svim%svim%savf',
|
||||
\ 'yacc' : '%syacc%syacc%sl',
|
||||
\ }
|
||||
|
||||
cal map(s:types, 'printf(v:val, "--language-force=", " --", "-types=")')
|
||||
|
||||
if executable('jsctags')
|
||||
cal extend(s:types, { 'javascript': { 'args': '-f -', 'bin': 'jsctags' } })
|
||||
en
|
||||
|
||||
fu! ctrlp#buffertag#opts()
|
||||
for [ke, va] in items(s:opts)
|
||||
let {va[0]} = exists(s:pref.ke) ? {s:pref.ke} : va[1]
|
||||
endfo
|
||||
" Ctags bin
|
||||
if empty(s:bin)
|
||||
for bin in s:bins | if executable(bin)
|
||||
let s:bin = bin
|
||||
brea
|
||||
en | endfo
|
||||
el
|
||||
let s:bin = expand(s:bin, 1)
|
||||
en
|
||||
" Types
|
||||
cal extend(s:types, s:usr_types)
|
||||
endf
|
||||
" Utilities {{{1
|
||||
fu! s:validfile(fname, ftype)
|
||||
if ( !empty(a:fname) || !empty(a:ftype) ) && filereadable(a:fname)
|
||||
\ && index(keys(s:types), a:ftype) >= 0 | retu 1 | en
|
||||
retu 0
|
||||
endf
|
||||
|
||||
fu! s:exectags(cmd)
|
||||
if exists('+ssl')
|
||||
let [ssl, &ssl] = [&ssl, 0]
|
||||
en
|
||||
if &sh =~ 'cmd\.exe'
|
||||
let [sxq, &sxq, shcf, &shcf] = [&sxq, '"', &shcf, '/s /c']
|
||||
en
|
||||
let output = system(a:cmd)
|
||||
if &sh =~ 'cmd\.exe'
|
||||
let [&sxq, &shcf] = [sxq, shcf]
|
||||
en
|
||||
if exists('+ssl')
|
||||
let &ssl = ssl
|
||||
en
|
||||
retu output
|
||||
endf
|
||||
|
||||
fu! s:exectagsonfile(fname, ftype)
|
||||
let [ags, ft] = ['-f - --sort=no --excmd=pattern --fields=nKs ', a:ftype]
|
||||
if type(s:types[ft]) == 1
|
||||
let ags .= s:types[ft]
|
||||
let bin = s:bin
|
||||
elsei type(s:types[ft]) == 4
|
||||
let ags = s:types[ft]['args']
|
||||
let bin = expand(s:types[ft]['bin'], 1)
|
||||
en
|
||||
if empty(bin) | retu '' | en
|
||||
let cmd = s:esctagscmd(bin, ags, a:fname)
|
||||
if empty(cmd) | retu '' | en
|
||||
let output = s:exectags(cmd)
|
||||
if v:shell_error || output =~ 'Warning: cannot open' | retu '' | en
|
||||
retu output
|
||||
endf
|
||||
|
||||
fu! s:esctagscmd(bin, args, ...)
|
||||
if exists('+ssl')
|
||||
let [ssl, &ssl] = [&ssl, 0]
|
||||
en
|
||||
let fname = a:0 ? shellescape(a:1) : ''
|
||||
let cmd = shellescape(a:bin).' '.a:args.' '.fname
|
||||
if &sh =~ 'cmd\.exe'
|
||||
let cmd = substitute(cmd, '[&()@^<>|]', '^\0', 'g')
|
||||
en
|
||||
if exists('+ssl')
|
||||
let &ssl = ssl
|
||||
en
|
||||
if has('iconv')
|
||||
let last = s:enc != &enc ? s:enc : !empty($LANG) ? $LANG : &enc
|
||||
let cmd = iconv(cmd, &enc, last)
|
||||
en
|
||||
retu cmd
|
||||
endf
|
||||
|
||||
fu! s:process(fname, ftype)
|
||||
if !s:validfile(a:fname, a:ftype) | retu [] | endif
|
||||
let ftime = getftime(a:fname)
|
||||
if has_key(g:ctrlp_buftags, a:fname)
|
||||
\ && g:ctrlp_buftags[a:fname]['time'] >= ftime
|
||||
let lines = g:ctrlp_buftags[a:fname]['lines']
|
||||
el
|
||||
let data = s:exectagsonfile(a:fname, a:ftype)
|
||||
let [raw, lines] = [split(data, '\n\+'), []]
|
||||
for line in raw
|
||||
if line !~# '^!_TAG_' && len(split(line, ';"')) == 2
|
||||
let parsed_line = s:parseline(line)
|
||||
if parsed_line != ''
|
||||
cal add(lines, parsed_line)
|
||||
en
|
||||
en
|
||||
endfo
|
||||
let cache = { a:fname : { 'time': ftime, 'lines': lines } }
|
||||
cal extend(g:ctrlp_buftags, cache)
|
||||
en
|
||||
retu lines
|
||||
endf
|
||||
|
||||
fu! s:parseline(line)
|
||||
let vals = matchlist(a:line,
|
||||
\ '\v^([^\t]+)\t(.+)\t[?/]\^?(.{-1,})\$?[?/]\;\"\t(.+)\tline(no)?\:(\d+)')
|
||||
if vals == [] | retu '' | en
|
||||
let [bufnr, bufname] = [bufnr('^'.vals[2].'$'), fnamemodify(vals[2], ':p:t')]
|
||||
retu vals[1].' '.vals[4].'|'.bufnr.':'.bufname.'|'.vals[6].'| '.vals[3]
|
||||
endf
|
||||
|
||||
fu! s:syntax()
|
||||
if !ctrlp#nosy()
|
||||
cal ctrlp#hicheck('CtrlPTagKind', 'Title')
|
||||
cal ctrlp#hicheck('CtrlPBufName', 'Directory')
|
||||
cal ctrlp#hicheck('CtrlPTabExtra', 'Comment')
|
||||
sy match CtrlPTagKind '\zs[^\t|]\+\ze|\d\+:[^|]\+|\d\+|'
|
||||
sy match CtrlPBufName '|\d\+:\zs[^|]\+\ze|\d\+|'
|
||||
sy match CtrlPTabExtra '\zs\t.*\ze$' contains=CtrlPBufName,CtrlPTagKind
|
||||
en
|
||||
endf
|
||||
|
||||
fu! s:chknearby(pat)
|
||||
if match(getline('.'), a:pat) < 0
|
||||
let [int, forw, maxl] = [1, 1, line('$')]
|
||||
wh !search(a:pat, 'W'.( forw ? '' : 'b' ))
|
||||
if !forw
|
||||
if int > maxl | brea | en
|
||||
let int += int
|
||||
en
|
||||
let forw = !forw
|
||||
endw
|
||||
en
|
||||
endf
|
||||
" Public {{{1
|
||||
fu! ctrlp#buffertag#init(fname)
|
||||
let bufs = exists('s:btmode') && s:btmode
|
||||
\ ? filter(ctrlp#buffers(), 'filereadable(v:val)')
|
||||
\ : [exists('s:bufname') ? s:bufname : a:fname]
|
||||
let lines = []
|
||||
for each in bufs
|
||||
let bname = fnamemodify(each, ':p')
|
||||
let tftype = get(split(getbufvar('^'.bname.'$', '&ft'), '\.'), 0, '')
|
||||
cal extend(lines, s:process(bname, tftype))
|
||||
endfo
|
||||
cal s:syntax()
|
||||
retu lines
|
||||
endf
|
||||
|
||||
fu! ctrlp#buffertag#accept(mode, str)
|
||||
let vals = matchlist(a:str,
|
||||
\ '\v^[^\t]+\t+[^\t|]+\|(\d+)\:[^\t|]+\|(\d+)\|\s(.+)$')
|
||||
let bufnr = str2nr(get(vals, 1))
|
||||
if bufnr
|
||||
cal ctrlp#acceptfile(a:mode, bufname(bufnr))
|
||||
exe 'norm!' str2nr(get(vals, 2, line('.'))).'G'
|
||||
cal s:chknearby('\V\C'.get(vals, 3, ''))
|
||||
sil! norm! zvzz
|
||||
en
|
||||
endf
|
||||
|
||||
fu! ctrlp#buffertag#cmd(mode, ...)
|
||||
let s:btmode = a:mode
|
||||
if a:0 && !empty(a:1)
|
||||
let s:bufname = fnamemodify(a:1, ':p')
|
||||
en
|
||||
retu s:id
|
||||
endf
|
||||
|
||||
fu! ctrlp#buffertag#exit()
|
||||
unl! s:btmode s:bufname
|
||||
endf
|
||||
"}}}
|
||||
|
||||
" vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1:ts=2:sw=2:sts=2
|
||||
@@ -1,95 +0,0 @@
|
||||
" =============================================================================
|
||||
" File: autoload/ctrlp/changes.vim
|
||||
" Description: Change list extension
|
||||
" Author: Kien Nguyen <github.com/kien>
|
||||
" =============================================================================
|
||||
|
||||
" Init {{{1
|
||||
if exists('g:loaded_ctrlp_changes') && g:loaded_ctrlp_changes
|
||||
fini
|
||||
en
|
||||
let g:loaded_ctrlp_changes = 1
|
||||
|
||||
cal add(g:ctrlp_ext_vars, {
|
||||
\ 'init': 'ctrlp#changes#init(s:bufnr, s:crbufnr)',
|
||||
\ 'accept': 'ctrlp#changes#accept',
|
||||
\ 'lname': 'changes',
|
||||
\ 'sname': 'chs',
|
||||
\ 'exit': 'ctrlp#changes#exit()',
|
||||
\ 'type': 'tabe',
|
||||
\ 'sort': 0,
|
||||
\ 'nolim': 1,
|
||||
\ })
|
||||
|
||||
let s:id = g:ctrlp_builtins + len(g:ctrlp_ext_vars)
|
||||
" Utilities {{{1
|
||||
fu! s:changelist(bufnr)
|
||||
sil! exe 'noa hid b' a:bufnr
|
||||
redi => result
|
||||
sil! changes
|
||||
redi END
|
||||
retu map(split(result, "\n")[1:], 'tr(v:val, " ", " ")')
|
||||
endf
|
||||
|
||||
fu! s:process(clines, ...)
|
||||
let [clines, evas] = [[], []]
|
||||
for each in a:clines
|
||||
let parts = matchlist(each, '\v^.\s*\d+\s+(\d+)\s+(\d+)\s(.*)$')
|
||||
if !empty(parts)
|
||||
if parts[3] == '' | let parts[3] = ' ' | en
|
||||
cal add(clines, parts[3].' |'.a:1.':'.a:2.'|'.parts[1].':'.parts[2].'|')
|
||||
en
|
||||
endfo
|
||||
retu reverse(filter(clines, 'count(clines, v:val) == 1'))
|
||||
endf
|
||||
|
||||
fu! s:syntax()
|
||||
if !ctrlp#nosy()
|
||||
cal ctrlp#hicheck('CtrlPBufName', 'Directory')
|
||||
cal ctrlp#hicheck('CtrlPTabExtra', 'Comment')
|
||||
sy match CtrlPBufName '\t|\d\+:\zs[^|]\+\ze|\d\+:\d\+|$'
|
||||
sy match CtrlPTabExtra '\zs\t.*\ze$' contains=CtrlPBufName
|
||||
en
|
||||
endf
|
||||
" Public {{{1
|
||||
fu! ctrlp#changes#init(original_bufnr, bufnr)
|
||||
let bufnr = exists('s:bufnr') ? s:bufnr : a:bufnr
|
||||
let bufs = exists('s:clmode') && s:clmode ? ctrlp#buffers('id') : [bufnr]
|
||||
cal filter(bufs, 'v:val > 0')
|
||||
let [swb, &swb] = [&swb, '']
|
||||
let lines = []
|
||||
for each in bufs
|
||||
let fnamet = fnamemodify(bufname(each), ':t')
|
||||
cal extend(lines, s:process(s:changelist(each), each, fnamet))
|
||||
endfo
|
||||
sil! exe 'noa hid b' a:original_bufnr
|
||||
let &swb = swb
|
||||
cal ctrlp#syntax()
|
||||
cal s:syntax()
|
||||
retu lines
|
||||
endf
|
||||
|
||||
fu! ctrlp#changes#accept(mode, str)
|
||||
let info = matchlist(a:str, '\t|\(\d\+\):[^|]\+|\(\d\+\):\(\d\+\)|$')
|
||||
let bufnr = str2nr(get(info, 1))
|
||||
if bufnr
|
||||
cal ctrlp#acceptfile(a:mode, bufname(bufnr))
|
||||
cal cursor(get(info, 2), get(info, 3))
|
||||
sil! norm! zvzz
|
||||
en
|
||||
endf
|
||||
|
||||
fu! ctrlp#changes#cmd(mode, ...)
|
||||
let s:clmode = a:mode
|
||||
if a:0 && !empty(a:1)
|
||||
let s:bufnr = bufnr('^'.fnamemodify(a:1, ':p').'$')
|
||||
en
|
||||
retu s:id
|
||||
endf
|
||||
|
||||
fu! ctrlp#changes#exit()
|
||||
unl! s:clmode s:bufnr
|
||||
endf
|
||||
"}}}
|
||||
|
||||
" vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1:ts=2:sw=2:sts=2
|
||||
@@ -1,93 +0,0 @@
|
||||
" =============================================================================
|
||||
" File: autoload/ctrlp/dir.vim
|
||||
" Description: Directory extension
|
||||
" Author: Kien Nguyen <github.com/kien>
|
||||
" =============================================================================
|
||||
|
||||
" Init {{{1
|
||||
if exists('g:loaded_ctrlp_dir') && g:loaded_ctrlp_dir
|
||||
fini
|
||||
en
|
||||
let [g:loaded_ctrlp_dir, g:ctrlp_newdir] = [1, 0]
|
||||
|
||||
let s:ars = ['s:maxdepth', 's:maxfiles', 's:compare_lim', 's:glob', 's:caching']
|
||||
|
||||
cal add(g:ctrlp_ext_vars, {
|
||||
\ 'init': 'ctrlp#dir#init('.join(s:ars, ', ').')',
|
||||
\ 'accept': 'ctrlp#dir#accept',
|
||||
\ 'lname': 'dirs',
|
||||
\ 'sname': 'dir',
|
||||
\ 'type': 'path',
|
||||
\ 'specinput': 1,
|
||||
\ })
|
||||
|
||||
let s:id = g:ctrlp_builtins + len(g:ctrlp_ext_vars)
|
||||
|
||||
let s:dircounts = {}
|
||||
" Utilities {{{1
|
||||
fu! s:globdirs(dirs, depth)
|
||||
let entries = split(globpath(a:dirs, s:glob), "\n")
|
||||
let [dirs, depth] = [ctrlp#dirnfile(entries)[0], a:depth + 1]
|
||||
cal extend(g:ctrlp_alldirs, dirs)
|
||||
let nr = len(g:ctrlp_alldirs)
|
||||
if !empty(dirs) && !s:max(nr, s:maxfiles) && depth <= s:maxdepth
|
||||
sil! cal ctrlp#progress(nr)
|
||||
cal map(dirs, 'ctrlp#utils#fnesc(v:val, "g", ",")')
|
||||
cal s:globdirs(join(dirs, ','), depth)
|
||||
en
|
||||
endf
|
||||
|
||||
fu! s:max(len, max)
|
||||
retu a:max && a:len > a:max
|
||||
endf
|
||||
|
||||
fu! s:nocache()
|
||||
retu !s:caching || ( s:caching > 1 && get(s:dircounts, s:cwd) < s:caching )
|
||||
endf
|
||||
" Public {{{1
|
||||
fu! ctrlp#dir#init(...)
|
||||
let s:cwd = getcwd()
|
||||
for each in range(len(s:ars))
|
||||
let {s:ars[each]} = a:{each + 1}
|
||||
endfo
|
||||
let cadir = ctrlp#utils#cachedir().ctrlp#utils#lash().'dir'
|
||||
let cafile = cadir.ctrlp#utils#lash().ctrlp#utils#cachefile('dir')
|
||||
if g:ctrlp_newdir || s:nocache() || !filereadable(cafile)
|
||||
let [s:initcwd, g:ctrlp_alldirs] = [s:cwd, []]
|
||||
cal s:globdirs(ctrlp#utils#fnesc(s:cwd, 'g', ','), 0)
|
||||
cal ctrlp#rmbasedir(g:ctrlp_alldirs)
|
||||
if len(g:ctrlp_alldirs) <= s:compare_lim
|
||||
cal sort(g:ctrlp_alldirs, 'ctrlp#complen')
|
||||
en
|
||||
cal ctrlp#utils#writecache(g:ctrlp_alldirs, cadir, cafile)
|
||||
let g:ctrlp_newdir = 0
|
||||
el
|
||||
if !( exists('s:initcwd') && s:initcwd == s:cwd )
|
||||
let s:initcwd = s:cwd
|
||||
let g:ctrlp_alldirs = ctrlp#utils#readfile(cafile)
|
||||
en
|
||||
en
|
||||
cal extend(s:dircounts, { s:cwd : len(g:ctrlp_alldirs) })
|
||||
retu g:ctrlp_alldirs
|
||||
endf
|
||||
|
||||
fu! ctrlp#dir#accept(mode, str)
|
||||
let path = a:mode == 'h' ? getcwd() : s:cwd.ctrlp#utils#lash().a:str
|
||||
if a:mode =~ 't\|v\|h'
|
||||
cal ctrlp#exit()
|
||||
en
|
||||
cal ctrlp#setdir(path, a:mode =~ 't\|h' ? 'chd!' : 'lc!')
|
||||
if a:mode == 'e'
|
||||
sil! cal ctrlp#statusline()
|
||||
cal ctrlp#setlines(s:id)
|
||||
cal ctrlp#recordhist()
|
||||
cal ctrlp#prtclear()
|
||||
en
|
||||
endf
|
||||
|
||||
fu! ctrlp#dir#id()
|
||||
retu s:id
|
||||
endf
|
||||
"}}}
|
||||
|
||||
" vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1:ts=2:sw=2:sts=2
|
||||
@@ -1,62 +0,0 @@
|
||||
" =============================================================================
|
||||
" File: autoload/ctrlp/line.vim
|
||||
" Description: Line extension
|
||||
" Author: Kien Nguyen <github.com/kien>
|
||||
" =============================================================================
|
||||
|
||||
" Init {{{1
|
||||
if exists('g:loaded_ctrlp_line') && g:loaded_ctrlp_line
|
||||
fini
|
||||
en
|
||||
let g:loaded_ctrlp_line = 1
|
||||
|
||||
cal add(g:ctrlp_ext_vars, {
|
||||
\ 'init': 'ctrlp#line#init()',
|
||||
\ 'accept': 'ctrlp#line#accept',
|
||||
\ 'lname': 'lines',
|
||||
\ 'sname': 'lns',
|
||||
\ 'type': 'tabe',
|
||||
\ })
|
||||
|
||||
let s:id = g:ctrlp_builtins + len(g:ctrlp_ext_vars)
|
||||
" Utilities {{{1
|
||||
fu! s:syntax()
|
||||
if !ctrlp#nosy()
|
||||
cal ctrlp#hicheck('CtrlPBufName', 'Directory')
|
||||
cal ctrlp#hicheck('CtrlPTabExtra', 'Comment')
|
||||
sy match CtrlPBufName '\t|\zs[^|]\+\ze|\d\+:\d\+|$'
|
||||
sy match CtrlPTabExtra '\zs\t.*\ze$' contains=CtrlPBufName
|
||||
en
|
||||
endf
|
||||
" Public {{{1
|
||||
fu! ctrlp#line#init()
|
||||
let [bufs, lines] = [ctrlp#buffers('id'), []]
|
||||
for bufnr in bufs
|
||||
let [lfb, bufn] = [getbufline(bufnr, 1, '$'), bufname(bufnr)]
|
||||
let lfb = lfb == [] ? ctrlp#utils#readfile(fnamemodify(bufn, ':p')) : lfb
|
||||
cal map(lfb, 'tr(v:val, '' '', '' '')')
|
||||
let [linenr, len_lfb, buft] = [1, len(lfb), fnamemodify(bufn, ':t')]
|
||||
wh linenr <= len_lfb
|
||||
let lfb[linenr - 1] .= ' |'.buft.'|'.bufnr.':'.linenr.'|'
|
||||
let linenr += 1
|
||||
endw
|
||||
cal extend(lines, filter(lfb, 'v:val !~ ''^\s*\t|[^|]\+|\d\+:\d\+|$'''))
|
||||
endfo
|
||||
cal s:syntax()
|
||||
retu lines
|
||||
endf
|
||||
|
||||
fu! ctrlp#line#accept(mode, str)
|
||||
let info = matchlist(a:str, '\t|[^|]\+|\(\d\+\):\(\d\+\)|$')
|
||||
let bufnr = str2nr(get(info, 1))
|
||||
if bufnr
|
||||
cal ctrlp#acceptfile(a:mode, bufname(bufnr), get(info, 2))
|
||||
en
|
||||
endf
|
||||
|
||||
fu! ctrlp#line#id()
|
||||
retu s:id
|
||||
endf
|
||||
"}}}
|
||||
|
||||
" vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1:ts=2:sw=2:sts=2
|
||||
@@ -1,83 +0,0 @@
|
||||
" =============================================================================
|
||||
" File: autoload/ctrlp/mixed.vim
|
||||
" Description: Mixing Files + MRU + Buffers
|
||||
" Author: Kien Nguyen <github.com/kien>
|
||||
" =============================================================================
|
||||
|
||||
" Init {{{1
|
||||
if exists('g:loaded_ctrlp_mixed') && g:loaded_ctrlp_mixed
|
||||
fini
|
||||
en
|
||||
let [g:loaded_ctrlp_mixed, g:ctrlp_newmix] = [1, 0]
|
||||
|
||||
cal add(g:ctrlp_ext_vars, {
|
||||
\ 'init': 'ctrlp#mixed#init(s:compare_lim)',
|
||||
\ 'accept': 'ctrlp#acceptfile',
|
||||
\ 'lname': 'fil + mru + buf',
|
||||
\ 'sname': 'mix',
|
||||
\ 'type': 'path',
|
||||
\ 'opmul': 1,
|
||||
\ 'specinput': 1,
|
||||
\ })
|
||||
|
||||
let s:id = g:ctrlp_builtins + len(g:ctrlp_ext_vars)
|
||||
" Utilities {{{1
|
||||
fu! s:newcache(cwd)
|
||||
if g:ctrlp_newmix || !has_key(g:ctrlp_allmixes, 'data') | retu 1 | en
|
||||
retu g:ctrlp_allmixes['cwd'] != a:cwd
|
||||
\ || g:ctrlp_allmixes['filtime'] < getftime(ctrlp#utils#cachefile())
|
||||
\ || g:ctrlp_allmixes['mrutime'] < getftime(ctrlp#mrufiles#cachefile())
|
||||
\ || g:ctrlp_allmixes['bufs'] < len(ctrlp#mrufiles#bufs())
|
||||
endf
|
||||
|
||||
fu! s:getnewmix(cwd, clim)
|
||||
if g:ctrlp_newmix
|
||||
cal ctrlp#mrufiles#refresh('raw')
|
||||
let g:ctrlp_newcache = 1
|
||||
en
|
||||
let g:ctrlp_lines = copy(ctrlp#files())
|
||||
cal ctrlp#progress('Mixing...')
|
||||
let mrufs = copy(ctrlp#mrufiles#list('raw'))
|
||||
if exists('+ssl') && &ssl
|
||||
cal map(mrufs, 'tr(v:val, "\\", "/")')
|
||||
en
|
||||
let bufs = map(ctrlp#buffers('id'), 'fnamemodify(bufname(v:val), ":p")')
|
||||
let mrufs = bufs + filter(mrufs, 'index(bufs, v:val) < 0')
|
||||
if len(mrufs) > len(g:ctrlp_lines)
|
||||
cal filter(mrufs, 'stridx(v:val, a:cwd)')
|
||||
el
|
||||
let cwd_mrufs = filter(copy(mrufs), '!stridx(v:val, a:cwd)')
|
||||
let cwd_mrufs = ctrlp#rmbasedir(cwd_mrufs)
|
||||
for each in cwd_mrufs
|
||||
let id = index(g:ctrlp_lines, each)
|
||||
if id >= 0 | cal remove(g:ctrlp_lines, id) | en
|
||||
endfo
|
||||
en
|
||||
cal map(mrufs, 'fnamemodify(v:val, ":.")')
|
||||
let g:ctrlp_lines = len(mrufs) > len(g:ctrlp_lines)
|
||||
\ ? g:ctrlp_lines + mrufs : mrufs + g:ctrlp_lines
|
||||
if len(g:ctrlp_lines) <= a:clim
|
||||
cal sort(g:ctrlp_lines, 'ctrlp#complen')
|
||||
en
|
||||
let g:ctrlp_allmixes = { 'filtime': getftime(ctrlp#utils#cachefile()),
|
||||
\ 'mrutime': getftime(ctrlp#mrufiles#cachefile()), 'cwd': a:cwd,
|
||||
\ 'bufs': len(ctrlp#mrufiles#bufs()), 'data': g:ctrlp_lines }
|
||||
endf
|
||||
" Public {{{1
|
||||
fu! ctrlp#mixed#init(clim)
|
||||
let cwd = getcwd()
|
||||
if s:newcache(cwd)
|
||||
cal s:getnewmix(cwd, a:clim)
|
||||
el
|
||||
let g:ctrlp_lines = g:ctrlp_allmixes['data']
|
||||
en
|
||||
let g:ctrlp_newmix = 0
|
||||
retu g:ctrlp_lines
|
||||
endf
|
||||
|
||||
fu! ctrlp#mixed#id()
|
||||
retu s:id
|
||||
endf
|
||||
"}}}
|
||||
|
||||
" vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1:ts=2:sw=2:sts=2
|
||||
@@ -1,136 +0,0 @@
|
||||
" =============================================================================
|
||||
" File: autoload/ctrlp/mrufiles.vim
|
||||
" Description: Most Recently Used Files extension
|
||||
" Author: Kien Nguyen <github.com/kien>
|
||||
" =============================================================================
|
||||
|
||||
" Static variables {{{1
|
||||
let [s:mrbs, s:mrufs] = [[], []]
|
||||
|
||||
fu! ctrlp#mrufiles#opts()
|
||||
let [pref, opts] = ['g:ctrlp_mruf_', {
|
||||
\ 'max': ['s:max', 250],
|
||||
\ 'include': ['s:in', ''],
|
||||
\ 'exclude': ['s:ex', ''],
|
||||
\ 'case_sensitive': ['s:cseno', 1],
|
||||
\ 'relative': ['s:re', 0],
|
||||
\ 'save_on_update': ['s:soup', 1],
|
||||
\ }]
|
||||
for [ke, va] in items(opts)
|
||||
let [{va[0]}, {pref.ke}] = [pref.ke, exists(pref.ke) ? {pref.ke} : va[1]]
|
||||
endfo
|
||||
endf
|
||||
cal ctrlp#mrufiles#opts()
|
||||
" Utilities {{{1
|
||||
fu! s:excl(fn)
|
||||
retu !empty({s:ex}) && a:fn =~# {s:ex}
|
||||
endf
|
||||
|
||||
fu! s:mergelists()
|
||||
let diskmrufs = ctrlp#utils#readfile(ctrlp#mrufiles#cachefile())
|
||||
cal filter(diskmrufs, 'index(s:mrufs, v:val) < 0')
|
||||
let mrufs = s:mrufs + diskmrufs
|
||||
retu s:chop(mrufs)
|
||||
endf
|
||||
|
||||
fu! s:chop(mrufs)
|
||||
if len(a:mrufs) > {s:max} | cal remove(a:mrufs, {s:max}, -1) | en
|
||||
retu a:mrufs
|
||||
endf
|
||||
|
||||
fu! s:reformat(mrufs)
|
||||
if {s:re}
|
||||
let cwd = exists('+ssl') ? tr(getcwd(), '/', '\') : getcwd()
|
||||
cal filter(a:mrufs, '!stridx(v:val, cwd)')
|
||||
en
|
||||
retu map(a:mrufs, 'fnamemodify(v:val, ":.")')
|
||||
endf
|
||||
|
||||
fu! s:record(bufnr)
|
||||
if s:locked | retu | en
|
||||
let bufnr = a:bufnr + 0
|
||||
let bufname = bufname(bufnr)
|
||||
if bufnr > 0 && !empty(bufname)
|
||||
cal filter(s:mrbs, 'v:val != bufnr')
|
||||
cal insert(s:mrbs, bufnr)
|
||||
cal s:addtomrufs(bufname)
|
||||
en
|
||||
endf
|
||||
|
||||
fu! s:addtomrufs(fname)
|
||||
let fn = fnamemodify(a:fname, ':p')
|
||||
let fn = exists('+ssl') ? tr(fn, '/', '\') : fn
|
||||
if ( !empty({s:in}) && fn !~# {s:in} ) || ( !empty({s:ex}) && fn =~# {s:ex} )
|
||||
\ || !empty(getbufvar('^'.fn.'$', '&bt')) || !filereadable(fn) | retu
|
||||
en
|
||||
if ( {s:cseno} && get(s:mrufs, 0, '') !=# fn )
|
||||
\ || ( !{s:cseno} && get(s:mrufs, 0, '') !=? fn )
|
||||
cal filter(s:mrufs, 'v:val !='.( {s:cseno} ? '#' : '?' ).' fn')
|
||||
cal insert(s:mrufs, fn)
|
||||
if {s:soup}
|
||||
cal s:savetofile(s:mergelists())
|
||||
en
|
||||
en
|
||||
endf
|
||||
|
||||
fu! s:savetofile(mrufs)
|
||||
cal ctrlp#utils#writecache(a:mrufs, s:cadir, s:cafile)
|
||||
endf
|
||||
" Public {{{1
|
||||
fu! ctrlp#mrufiles#refresh(...)
|
||||
let s:mrufs = s:mergelists()
|
||||
cal filter(s:mrufs, '!empty(ctrlp#utils#glob(v:val, 1)) && !s:excl(v:val)')
|
||||
if exists('+ssl')
|
||||
cal map(s:mrufs, 'tr(v:val, "/", "\\")')
|
||||
cal filter(s:mrufs, 'count(s:mrufs, v:val) == 1')
|
||||
en
|
||||
cal s:savetofile(s:mrufs)
|
||||
retu a:0 && a:1 == 'raw' ? [] : s:reformat(copy(s:mrufs))
|
||||
endf
|
||||
|
||||
fu! ctrlp#mrufiles#remove(files)
|
||||
let s:mrufs = []
|
||||
if a:files != []
|
||||
let s:mrufs = s:mergelists()
|
||||
cal filter(s:mrufs, 'index(a:files, v:val, 0, '.(!{s:cseno}).') < 0')
|
||||
en
|
||||
cal s:savetofile(s:mrufs)
|
||||
retu s:reformat(copy(s:mrufs))
|
||||
endf
|
||||
|
||||
fu! ctrlp#mrufiles#add(fn)
|
||||
if !empty(a:fn)
|
||||
cal s:addtomrufs(a:fn)
|
||||
en
|
||||
endf
|
||||
|
||||
fu! ctrlp#mrufiles#list(...)
|
||||
retu a:0 ? a:1 == 'raw' ? s:mergelists() : 0 : s:reformat(s:mergelists())
|
||||
endf
|
||||
|
||||
fu! ctrlp#mrufiles#bufs()
|
||||
retu s:mrbs
|
||||
endf
|
||||
|
||||
fu! ctrlp#mrufiles#cachefile()
|
||||
if !exists('s:cadir') || !exists('s:cafile')
|
||||
let s:cadir = ctrlp#utils#cachedir().ctrlp#utils#lash().'mru'
|
||||
let s:cafile = s:cadir.ctrlp#utils#lash().'cache.txt'
|
||||
en
|
||||
retu s:cafile
|
||||
endf
|
||||
|
||||
fu! ctrlp#mrufiles#init()
|
||||
if !has('autocmd') | retu | en
|
||||
let s:locked = 0
|
||||
aug CtrlPMRUF
|
||||
au!
|
||||
au BufAdd,BufEnter,BufLeave,BufWritePost * cal s:record(expand('<abuf>', 1))
|
||||
au QuickFixCmdPre *vimgrep* let s:locked = 1
|
||||
au QuickFixCmdPost *vimgrep* let s:locked = 0
|
||||
au VimLeavePre * cal s:savetofile(s:mergelists())
|
||||
aug END
|
||||
endf
|
||||
"}}}
|
||||
|
||||
" vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1:ts=2:sw=2:sts=2
|
||||
@@ -1,59 +0,0 @@
|
||||
" =============================================================================
|
||||
" File: autoload/ctrlp/quickfix.vim
|
||||
" Description: Quickfix extension
|
||||
" Author: Kien Nguyen <github.com/kien>
|
||||
" =============================================================================
|
||||
|
||||
" Init {{{1
|
||||
if exists('g:loaded_ctrlp_quickfix') && g:loaded_ctrlp_quickfix
|
||||
fini
|
||||
en
|
||||
let g:loaded_ctrlp_quickfix = 1
|
||||
|
||||
cal add(g:ctrlp_ext_vars, {
|
||||
\ 'init': 'ctrlp#quickfix#init()',
|
||||
\ 'accept': 'ctrlp#quickfix#accept',
|
||||
\ 'lname': 'quickfix',
|
||||
\ 'sname': 'qfx',
|
||||
\ 'type': 'line',
|
||||
\ 'sort': 0,
|
||||
\ 'nolim': 1,
|
||||
\ })
|
||||
|
||||
let s:id = g:ctrlp_builtins + len(g:ctrlp_ext_vars)
|
||||
|
||||
fu! s:lineout(dict)
|
||||
retu printf('%s|%d:%d| %s', bufname(a:dict['bufnr']), a:dict['lnum'],
|
||||
\ a:dict['col'], matchstr(a:dict['text'], '\s*\zs.*\S'))
|
||||
endf
|
||||
" Utilities {{{1
|
||||
fu! s:syntax()
|
||||
if !ctrlp#nosy()
|
||||
cal ctrlp#hicheck('CtrlPqfLineCol', 'Search')
|
||||
sy match CtrlPqfLineCol '|\zs\d\+:\d\+\ze|'
|
||||
en
|
||||
endf
|
||||
" Public {{{1
|
||||
fu! ctrlp#quickfix#init()
|
||||
cal s:syntax()
|
||||
retu map(getqflist(), 's:lineout(v:val)')
|
||||
endf
|
||||
|
||||
fu! ctrlp#quickfix#accept(mode, str)
|
||||
let vals = matchlist(a:str, '^\([^|]\+\ze\)|\(\d\+\):\(\d\+\)|')
|
||||
if vals == [] || vals[1] == '' | retu | en
|
||||
cal ctrlp#acceptfile(a:mode, vals[1])
|
||||
let cur_pos = getpos('.')[1:2]
|
||||
if cur_pos != [1, 1] && cur_pos != map(vals[2:3], 'str2nr(v:val)')
|
||||
mark '
|
||||
en
|
||||
cal cursor(vals[2], vals[3])
|
||||
sil! norm! zvzz
|
||||
endf
|
||||
|
||||
fu! ctrlp#quickfix#id()
|
||||
retu s:id
|
||||
endf
|
||||
"}}}
|
||||
|
||||
" vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1:ts=2:sw=2:sts=2
|
||||
@@ -1,59 +0,0 @@
|
||||
" =============================================================================
|
||||
" File: autoload/ctrlp/rtscript.vim
|
||||
" Description: Runtime scripts extension
|
||||
" Author: Kien Nguyen <github.com/kien>
|
||||
" =============================================================================
|
||||
|
||||
" Init {{{1
|
||||
if exists('g:loaded_ctrlp_rtscript') && g:loaded_ctrlp_rtscript
|
||||
fini
|
||||
en
|
||||
let [g:loaded_ctrlp_rtscript, g:ctrlp_newrts] = [1, 0]
|
||||
|
||||
cal add(g:ctrlp_ext_vars, {
|
||||
\ 'init': 'ctrlp#rtscript#init(s:caching)',
|
||||
\ 'accept': 'ctrlp#acceptfile',
|
||||
\ 'lname': 'runtime scripts',
|
||||
\ 'sname': 'rts',
|
||||
\ 'type': 'path',
|
||||
\ 'opmul': 1,
|
||||
\ })
|
||||
|
||||
let s:id = g:ctrlp_builtins + len(g:ctrlp_ext_vars)
|
||||
|
||||
let s:filecounts = {}
|
||||
" Utilities {{{1
|
||||
fu! s:nocache()
|
||||
retu g:ctrlp_newrts ||
|
||||
\ !s:caching || ( s:caching > 1 && get(s:filecounts, s:cwd) < s:caching )
|
||||
endf
|
||||
" Public {{{1
|
||||
fu! ctrlp#rtscript#init(caching)
|
||||
let [s:caching, s:cwd] = [a:caching, getcwd()]
|
||||
if s:nocache() ||
|
||||
\ !( exists('g:ctrlp_rtscache') && g:ctrlp_rtscache[0] == &rtp )
|
||||
sil! cal ctrlp#progress('Indexing...')
|
||||
let entries = split(globpath(ctrlp#utils#fnesc(&rtp, 'g'), '**/*.*'), "\n")
|
||||
cal filter(entries, 'count(entries, v:val) == 1')
|
||||
let [entries, echoed] = [ctrlp#dirnfile(entries)[1], 1]
|
||||
el
|
||||
let [entries, results] = g:ctrlp_rtscache[2:3]
|
||||
en
|
||||
if s:nocache() ||
|
||||
\ !( exists('g:ctrlp_rtscache') && g:ctrlp_rtscache[:1] == [&rtp, s:cwd] )
|
||||
if !exists('echoed')
|
||||
sil! cal ctrlp#progress('Processing...')
|
||||
en
|
||||
let results = map(copy(entries), 'fnamemodify(v:val, '':.'')')
|
||||
en
|
||||
let [g:ctrlp_rtscache, g:ctrlp_newrts] = [[&rtp, s:cwd, entries, results], 0]
|
||||
cal extend(s:filecounts, { s:cwd : len(results) })
|
||||
retu results
|
||||
endf
|
||||
|
||||
fu! ctrlp#rtscript#id()
|
||||
retu s:id
|
||||
endf
|
||||
"}}}
|
||||
|
||||
" vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1:ts=2:sw=2:sts=2
|
||||
@@ -1,125 +0,0 @@
|
||||
" =============================================================================
|
||||
" File: autoload/ctrlp/tag.vim
|
||||
" Description: Tag file extension
|
||||
" Author: Kien Nguyen <github.com/kien>
|
||||
" =============================================================================
|
||||
|
||||
" Init {{{1
|
||||
if exists('g:loaded_ctrlp_tag') && g:loaded_ctrlp_tag
|
||||
fini
|
||||
en
|
||||
let g:loaded_ctrlp_tag = 1
|
||||
|
||||
cal add(g:ctrlp_ext_vars, {
|
||||
\ 'init': 'ctrlp#tag#init()',
|
||||
\ 'accept': 'ctrlp#tag#accept',
|
||||
\ 'lname': 'tags',
|
||||
\ 'sname': 'tag',
|
||||
\ 'enter': 'ctrlp#tag#enter()',
|
||||
\ 'type': 'tabs',
|
||||
\ })
|
||||
|
||||
let s:id = g:ctrlp_builtins + len(g:ctrlp_ext_vars)
|
||||
" Utilities {{{1
|
||||
fu! s:findcount(str)
|
||||
let [tg, fname] = split(a:str, '\t\+\ze[^\t]\+$')
|
||||
let tgs = taglist('^'.tg.'$')
|
||||
if len(tgs) < 2
|
||||
retu [1, 1]
|
||||
en
|
||||
let bname = fnamemodify(bufname('%'), ':p')
|
||||
let fname = expand(fnamemodify(simplify(fname), ':s?^[.\/]\+??:p:.'), 1)
|
||||
let [fnd, ct, pos, idx] = [0, 0, 0, 0]
|
||||
wh idx < len(tgs)
|
||||
if bname == fnamemodify(tgs[idx]["filename"], ':p')
|
||||
cal insert(tgs, remove(tgs, idx))
|
||||
brea
|
||||
en
|
||||
let idx += 1
|
||||
endw
|
||||
for each in tgs
|
||||
let ct += 1
|
||||
let fulname = fnamemodify(each["filename"], ':p')
|
||||
if stridx(fulname, fname) >= 0
|
||||
\ && strlen(fname) + stridx(fulname, fname) == strlen(fulname)
|
||||
let fnd += 1
|
||||
let pos = ct
|
||||
en
|
||||
if fnd > 1 | brea | en
|
||||
endfo
|
||||
retu [fnd, pos]
|
||||
endf
|
||||
|
||||
fu! s:filter(tags)
|
||||
let nr = 0
|
||||
wh 0 < 1
|
||||
if a:tags == [] | brea | en
|
||||
if a:tags[nr] =~ '^!' && a:tags[nr] !~# '^!_TAG_'
|
||||
let nr += 1
|
||||
con
|
||||
en
|
||||
if a:tags[nr] =~# '^!_TAG_' && len(a:tags) > nr
|
||||
cal remove(a:tags, nr)
|
||||
el
|
||||
brea
|
||||
en
|
||||
endw
|
||||
retu a:tags
|
||||
endf
|
||||
|
||||
fu! s:syntax()
|
||||
if !ctrlp#nosy()
|
||||
cal ctrlp#hicheck('CtrlPTabExtra', 'Comment')
|
||||
sy match CtrlPTabExtra '\zs\t.*\ze$'
|
||||
en
|
||||
endf
|
||||
" Public {{{1
|
||||
fu! ctrlp#tag#init()
|
||||
if empty(s:tagfiles) | retu [] | en
|
||||
let g:ctrlp_alltags = []
|
||||
let tagfiles = sort(filter(s:tagfiles, 'count(s:tagfiles, v:val) == 1'))
|
||||
for each in tagfiles
|
||||
let alltags = s:filter(ctrlp#utils#readfile(each))
|
||||
cal extend(g:ctrlp_alltags, alltags)
|
||||
endfo
|
||||
cal s:syntax()
|
||||
retu g:ctrlp_alltags
|
||||
endf
|
||||
|
||||
fu! ctrlp#tag#accept(mode, str)
|
||||
cal ctrlp#exit()
|
||||
let str = matchstr(a:str, '^[^\t]\+\t\+[^\t]\+\ze\t')
|
||||
let [tg, fnd] = [split(str, '^[^\t]\+\zs\t')[0], s:findcount(str)]
|
||||
let cmds = {
|
||||
\ 't': ['tab sp', 'tab stj'],
|
||||
\ 'h': ['sp', 'stj'],
|
||||
\ 'v': ['vs', 'vert stj'],
|
||||
\ 'e': ['', 'tj'],
|
||||
\ }
|
||||
let cmd = fnd[0] == 1 ? cmds[a:mode][0] : cmds[a:mode][1]
|
||||
let cmd = a:mode == 'e' && ctrlp#modfilecond(!&aw)
|
||||
\ ? ( cmd == 'tj' ? 'stj' : 'sp' ) : cmd
|
||||
let cmd = a:mode == 't' ? ctrlp#tabcount().cmd : cmd
|
||||
if fnd[0] == 1
|
||||
if cmd != ''
|
||||
exe cmd
|
||||
en
|
||||
exe fnd[1].'ta' tg
|
||||
el
|
||||
exe cmd tg
|
||||
en
|
||||
cal ctrlp#setlcdir()
|
||||
endf
|
||||
|
||||
fu! ctrlp#tag#id()
|
||||
retu s:id
|
||||
endf
|
||||
|
||||
fu! ctrlp#tag#enter()
|
||||
let tfs = tagfiles()
|
||||
let s:tagfiles = tfs != [] ? filter(map(tfs, 'fnamemodify(v:val, ":p")'),
|
||||
\ 'filereadable(v:val)') : []
|
||||
endf
|
||||
"}}}
|
||||
|
||||
" vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1:ts=2:sw=2:sts=2
|
||||
@@ -1,154 +0,0 @@
|
||||
" =============================================================================
|
||||
" File: autoload/ctrlp/undo.vim
|
||||
" Description: Undo extension
|
||||
" Author: Kien Nguyen <github.com/kien>
|
||||
" =============================================================================
|
||||
|
||||
" Init {{{1
|
||||
if ( exists('g:loaded_ctrlp_undo') && g:loaded_ctrlp_undo )
|
||||
fini
|
||||
en
|
||||
let g:loaded_ctrlp_undo = 1
|
||||
|
||||
cal add(g:ctrlp_ext_vars, {
|
||||
\ 'init': 'ctrlp#undo#init()',
|
||||
\ 'accept': 'ctrlp#undo#accept',
|
||||
\ 'lname': 'undo',
|
||||
\ 'sname': 'udo',
|
||||
\ 'enter': 'ctrlp#undo#enter()',
|
||||
\ 'exit': 'ctrlp#undo#exit()',
|
||||
\ 'type': 'line',
|
||||
\ 'sort': 0,
|
||||
\ 'nolim': 1,
|
||||
\ })
|
||||
|
||||
let s:id = g:ctrlp_builtins + len(g:ctrlp_ext_vars)
|
||||
|
||||
let s:text = map(['second', 'seconds', 'minutes', 'hours', 'days', 'weeks',
|
||||
\ 'months', 'years'], '" ".v:val." ago"')
|
||||
" Utilities {{{1
|
||||
fu! s:getundo()
|
||||
if exists('*undotree')
|
||||
\ && ( v:version > 703 || ( v:version == 703 && has('patch005') ) )
|
||||
retu [1, undotree()]
|
||||
el
|
||||
redi => result
|
||||
sil! undol
|
||||
redi END
|
||||
retu [0, split(result, "\n")[1:]]
|
||||
en
|
||||
endf
|
||||
|
||||
fu! s:flatten(tree, cur)
|
||||
let flatdict = {}
|
||||
for each in a:tree
|
||||
let saved = has_key(each, 'save') ? 'saved' : ''
|
||||
let current = each['seq'] == a:cur ? 'current' : ''
|
||||
cal extend(flatdict, { each['seq'] : [each['time'], saved, current] })
|
||||
if has_key(each, 'alt')
|
||||
cal extend(flatdict, s:flatten(each['alt'], a:cur))
|
||||
en
|
||||
endfo
|
||||
retu flatdict
|
||||
endf
|
||||
|
||||
fu! s:elapsed(nr)
|
||||
let [text, time] = [s:text, localtime() - a:nr]
|
||||
let mins = time / 60
|
||||
let hrs = time / 3600
|
||||
let days = time / 86400
|
||||
let wks = time / 604800
|
||||
let mons = time / 2592000
|
||||
let yrs = time / 31536000
|
||||
if yrs > 1
|
||||
retu yrs.text[7]
|
||||
elsei mons > 1
|
||||
retu mons.text[6]
|
||||
elsei wks > 1
|
||||
retu wks.text[5]
|
||||
elsei days > 1
|
||||
retu days.text[4]
|
||||
elsei hrs > 1
|
||||
retu hrs.text[3]
|
||||
elsei mins > 1
|
||||
retu mins.text[2]
|
||||
elsei time == 1
|
||||
retu time.text[0]
|
||||
elsei time < 120
|
||||
retu time.text[1]
|
||||
en
|
||||
endf
|
||||
|
||||
fu! s:syntax()
|
||||
if ctrlp#nosy() | retu | en
|
||||
for [ke, va] in items({'T': 'Directory', 'Br': 'Comment', 'Nr': 'String',
|
||||
\ 'Sv': 'Comment', 'Po': 'Title'})
|
||||
cal ctrlp#hicheck('CtrlPUndo'.ke, va)
|
||||
endfo
|
||||
sy match CtrlPUndoT '\v\d+ \zs[^ ]+\ze|\d+:\d+:\d+'
|
||||
sy match CtrlPUndoBr '\[\|\]'
|
||||
sy match CtrlPUndoNr '\[\d\+\]' contains=CtrlPUndoBr
|
||||
sy match CtrlPUndoSv 'saved'
|
||||
sy match CtrlPUndoPo 'current'
|
||||
endf
|
||||
|
||||
fu! s:dict2list(dict)
|
||||
for ke in keys(a:dict)
|
||||
let a:dict[ke][0] = s:elapsed(a:dict[ke][0])
|
||||
endfo
|
||||
retu map(keys(a:dict), 'eval(''[v:val, a:dict[v:val]]'')')
|
||||
endf
|
||||
|
||||
fu! s:compval(...)
|
||||
retu a:2[0] - a:1[0]
|
||||
endf
|
||||
|
||||
fu! s:format(...)
|
||||
let saved = !empty(a:1[1][1]) ? ' '.a:1[1][1] : ''
|
||||
let current = !empty(a:1[1][2]) ? ' '.a:1[1][2] : ''
|
||||
retu a:1[1][0].' ['.a:1[0].']'.saved.current
|
||||
endf
|
||||
|
||||
fu! s:formatul(...)
|
||||
let parts = matchlist(a:1,
|
||||
\ '\v^\s+(\d+)\s+\d+\s+([^ ]+\s?[^ ]+|\d+\s\w+\s\w+)(\s*\d*)$')
|
||||
retu parts == [] ? '----'
|
||||
\ : parts[2].' ['.parts[1].']'.( parts[3] != '' ? ' saved' : '' )
|
||||
endf
|
||||
" Public {{{1
|
||||
fu! ctrlp#undo#init()
|
||||
let entries = s:undos[0] ? s:undos[1]['entries'] : s:undos[1]
|
||||
if empty(entries) | retu [] | en
|
||||
if !exists('s:lines')
|
||||
if s:undos[0]
|
||||
let entries = s:dict2list(s:flatten(entries, s:undos[1]['seq_cur']))
|
||||
let s:lines = map(sort(entries, 's:compval'), 's:format(v:val)')
|
||||
el
|
||||
let s:lines = map(reverse(entries), 's:formatul(v:val)')
|
||||
en
|
||||
en
|
||||
cal s:syntax()
|
||||
retu s:lines
|
||||
endf
|
||||
|
||||
fu! ctrlp#undo#accept(mode, str)
|
||||
let undon = matchstr(a:str, '\[\zs\d\+\ze\]')
|
||||
if empty(undon) | retu | en
|
||||
cal ctrlp#exit()
|
||||
exe 'u' undon
|
||||
endf
|
||||
|
||||
fu! ctrlp#undo#id()
|
||||
retu s:id
|
||||
endf
|
||||
|
||||
fu! ctrlp#undo#enter()
|
||||
let s:undos = s:getundo()
|
||||
endf
|
||||
|
||||
fu! ctrlp#undo#exit()
|
||||
unl! s:lines
|
||||
endf
|
||||
"}}}
|
||||
|
||||
" vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1:ts=2:sw=2:sts=2
|
||||
@@ -1,120 +0,0 @@
|
||||
" =============================================================================
|
||||
" File: autoload/ctrlp/utils.vim
|
||||
" Description: Utilities
|
||||
" Author: Kien Nguyen <github.com/kien>
|
||||
" =============================================================================
|
||||
|
||||
" Static variables {{{1
|
||||
fu! ctrlp#utils#lash()
|
||||
retu &ssl || !exists('+ssl') ? '/' : '\'
|
||||
endf
|
||||
|
||||
fu! s:lash(...)
|
||||
retu ( a:0 ? a:1 : getcwd() ) !~ '[\/]$' ? s:lash : ''
|
||||
endf
|
||||
|
||||
fu! ctrlp#utils#opts()
|
||||
let s:lash = ctrlp#utils#lash()
|
||||
let usrhome = $HOME.s:lash($HOME)
|
||||
let cahome = exists('$XDG_CACHE_HOME') ? $XDG_CACHE_HOME : usrhome.'.cache'
|
||||
let cadir = isdirectory(usrhome.'.ctrlp_cache')
|
||||
\ ? usrhome.'.ctrlp_cache' : cahome.s:lash(cahome).'ctrlp'
|
||||
if exists('g:ctrlp_cache_dir')
|
||||
let cadir = expand(g:ctrlp_cache_dir, 1)
|
||||
if isdirectory(cadir.s:lash(cadir).'.ctrlp_cache')
|
||||
let cadir = cadir.s:lash(cadir).'.ctrlp_cache'
|
||||
en
|
||||
en
|
||||
let s:cache_dir = cadir
|
||||
endf
|
||||
cal ctrlp#utils#opts()
|
||||
|
||||
let s:wig_cond = v:version > 702 || ( v:version == 702 && has('patch051') )
|
||||
" Files and Directories {{{1
|
||||
fu! ctrlp#utils#cachedir()
|
||||
retu s:cache_dir
|
||||
endf
|
||||
|
||||
fu! ctrlp#utils#cachefile(...)
|
||||
let [tail, dir] = [a:0 == 1 ? '.'.a:1 : '', a:0 == 2 ? a:1 : getcwd()]
|
||||
let cache_file = substitute(dir, '\([\/]\|^\a\zs:\)', '%', 'g').tail.'.txt'
|
||||
retu a:0 == 1 ? cache_file : s:cache_dir.s:lash(s:cache_dir).cache_file
|
||||
endf
|
||||
|
||||
fu! ctrlp#utils#readfile(file)
|
||||
if filereadable(a:file)
|
||||
let data = readfile(a:file)
|
||||
if empty(data) || type(data) != 3
|
||||
unl data
|
||||
let data = []
|
||||
en
|
||||
retu data
|
||||
en
|
||||
retu []
|
||||
endf
|
||||
|
||||
fu! ctrlp#utils#mkdir(dir)
|
||||
if exists('*mkdir') && !isdirectory(a:dir)
|
||||
sil! cal mkdir(a:dir, 'p')
|
||||
en
|
||||
retu a:dir
|
||||
endf
|
||||
|
||||
fu! ctrlp#utils#writecache(lines, ...)
|
||||
if isdirectory(ctrlp#utils#mkdir(a:0 ? a:1 : s:cache_dir))
|
||||
sil! cal writefile(a:lines, a:0 >= 2 ? a:2 : ctrlp#utils#cachefile())
|
||||
en
|
||||
endf
|
||||
|
||||
fu! ctrlp#utils#glob(...)
|
||||
let path = ctrlp#utils#fnesc(a:1, 'g')
|
||||
retu s:wig_cond ? glob(path, a:2) : glob(path)
|
||||
endf
|
||||
|
||||
fu! ctrlp#utils#globpath(...)
|
||||
retu call('globpath', s:wig_cond ? a:000 : a:000[:1])
|
||||
endf
|
||||
|
||||
fu! ctrlp#utils#fnesc(path, type, ...)
|
||||
if exists('*fnameescape')
|
||||
if exists('+ssl')
|
||||
if a:type == 'c'
|
||||
let path = escape(a:path, '%#')
|
||||
elsei a:type == 'f'
|
||||
let path = fnameescape(a:path)
|
||||
elsei a:type == 'g'
|
||||
let path = escape(a:path, '?*')
|
||||
en
|
||||
let path = substitute(path, '[', '[[]', 'g')
|
||||
el
|
||||
let path = fnameescape(a:path)
|
||||
en
|
||||
el
|
||||
if exists('+ssl')
|
||||
if a:type == 'c'
|
||||
let path = escape(a:path, '%#')
|
||||
elsei a:type == 'f'
|
||||
let path = escape(a:path, " \t\n%#*?|<\"")
|
||||
elsei a:type == 'g'
|
||||
let path = escape(a:path, '?*')
|
||||
en
|
||||
let path = substitute(path, '[', '[[]', 'g')
|
||||
el
|
||||
let path = escape(a:path, " \t\n*?[{`$\\%#'\"|!<")
|
||||
en
|
||||
en
|
||||
retu a:0 ? escape(path, a:1) : path
|
||||
endf
|
||||
|
||||
fu! ctrlp#utils#dircompl(...)
|
||||
let [hsl, str] = [match(a:1, '[\/]'), '']
|
||||
let par = substitute(a:1, '[^\/]*$', '', '')
|
||||
let path = !hsl ? par : hsl > 0 ? getcwd().s:lash().par : getcwd()
|
||||
for dir in split(globpath(ctrlp#utils#fnesc(path, 'g', ','), '*/'), '\n')
|
||||
let str .= par.split(dir, '[\/]')[-1]."\n"
|
||||
endfo
|
||||
retu str
|
||||
endf
|
||||
"}}}
|
||||
|
||||
" vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1:ts=2:sw=2:sts=2
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,69 +0,0 @@
|
||||
" =============================================================================
|
||||
" File: plugin/ctrlp.vim
|
||||
" Description: Fuzzy file, buffer, mru, tag, etc finder.
|
||||
" Author: Kien Nguyen <github.com/kien>
|
||||
" =============================================================================
|
||||
" GetLatestVimScripts: 3736 1 :AutoInstall: ctrlp.zip
|
||||
|
||||
if ( exists('g:loaded_ctrlp') && g:loaded_ctrlp ) || v:version < 700 || &cp
|
||||
fini
|
||||
en
|
||||
let g:loaded_ctrlp = 1
|
||||
|
||||
let [g:ctrlp_lines, g:ctrlp_allfiles, g:ctrlp_alltags, g:ctrlp_alldirs,
|
||||
\ g:ctrlp_allmixes, g:ctrlp_buftags, g:ctrlp_ext_vars, g:ctrlp_builtins]
|
||||
\ = [[], [], [], [], {}, {}, [], 2]
|
||||
|
||||
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=custom,ctrlp#utils#dircompl CtrlP
|
||||
\ cal ctrlp#init(0, { 'dir': <q-args> })
|
||||
|
||||
com! -n=? -com=custom,ctrlp#utils#dircompl CtrlPMRUFiles
|
||||
\ cal ctrlp#init(2, { 'dir': <q-args> })
|
||||
|
||||
com! -bar CtrlPBuffer cal ctrlp#init(1)
|
||||
com! -n=? CtrlPLastMode cal ctrlp#init(-1, { 'args': <q-args> })
|
||||
|
||||
com! -bar CtrlPClearCache cal ctrlp#clr()
|
||||
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' })
|
||||
|
||||
if g:ctrlp_map != '' && !hasmapto(':<c-u>'.g:ctrlp_cmd.'<cr>', 'n')
|
||||
exe 'nn <silent>' g:ctrlp_map ':<c-u>'.g:ctrlp_cmd.'<cr>'
|
||||
en
|
||||
|
||||
cal ctrlp#mrufiles#init()
|
||||
|
||||
com! -bar CtrlPTag cal ctrlp#init(ctrlp#tag#id())
|
||||
com! -bar CtrlPQuickfix cal ctrlp#init(ctrlp#quickfix#id())
|
||||
|
||||
com! -n=? -com=custom,ctrlp#utils#dircompl CtrlPDir
|
||||
\ cal ctrlp#init(ctrlp#dir#id(), { 'dir': <q-args> })
|
||||
|
||||
com! -n=? -com=buffer CtrlPBufTag
|
||||
\ cal ctrlp#init(ctrlp#buffertag#cmd(0, <q-args>))
|
||||
|
||||
com! -bar CtrlPBufTagAll cal ctrlp#init(ctrlp#buffertag#cmd(1))
|
||||
com! -bar CtrlPRTS cal ctrlp#init(ctrlp#rtscript#id())
|
||||
com! -bar CtrlPUndo cal ctrlp#init(ctrlp#undo#id())
|
||||
com! -bar CtrlPLine cal ctrlp#init(ctrlp#line#id())
|
||||
|
||||
com! -n=? -com=buffer CtrlPChange
|
||||
\ cal ctrlp#init(ctrlp#changes#cmd(0, <q-args>))
|
||||
|
||||
com! -bar CtrlPChangeAll cal ctrlp#init(ctrlp#changes#cmd(1))
|
||||
com! -bar CtrlPMixed cal ctrlp#init(ctrlp#mixed#id())
|
||||
com! -bar CtrlPBookmarkDir cal ctrlp#init(ctrlp#bookmarkdir#id())
|
||||
|
||||
com! -n=? -com=custom,ctrlp#utils#dircompl CtrlPBookmarkDirAdd
|
||||
\ cal ctrlp#call('ctrlp#bookmarkdir#add', <q-args>)
|
||||
|
||||
" vim:ts=2:sw=2:sts=2
|
||||
@@ -1,86 +0,0 @@
|
||||
# ctrlp.vim
|
||||
Full path fuzzy __file__, __buffer__, __mru__, __tag__, __...__ finder for Vim.
|
||||
|
||||
* Written in pure Vimscript for MacVim, gVim and Vim 7.0+.
|
||||
* Full support for Vim's regexp as search patterns.
|
||||
* Built-in Most Recently Used (MRU) files monitoring.
|
||||
* Built-in project's root finder.
|
||||
* Open multiple files at once.
|
||||
* Create new files and directories.
|
||||
* [Extensible][2].
|
||||
|
||||
![ctrlp][1]
|
||||
|
||||
## Basic Usage
|
||||
* Run `:CtrlP` or `:CtrlP [starting-directory]` to invoke CtrlP in find file mode.
|
||||
* Run `:CtrlPBuffer` or `:CtrlPMRU` to invoke CtrlP in find buffer or find MRU file mode.
|
||||
* Run `:CtrlPMixed` to search in Files, Buffers and MRU files at the same time.
|
||||
|
||||
Check `:help ctrlp-commands` and `:help ctrlp-extensions` for other commands.
|
||||
|
||||
##### Once CtrlP is open:
|
||||
* Press `<F5>` to purge the cache for the current directory to get new files, remove deleted files and apply new ignore options.
|
||||
* Press `<c-f>` and `<c-b>` to cycle between modes.
|
||||
* Press `<c-d>` to switch to filename only search instead of full path.
|
||||
* Press `<c-r>` to switch to regexp mode.
|
||||
* Use `<c-n>`, `<c-p>` to select the next/previous string in the prompt's history.
|
||||
* Use `<c-y>` to create a new file and its parent directories.
|
||||
* Use `<c-z>` to mark/unmark multiple files and `<c-o>` to open them.
|
||||
|
||||
Run `:help ctrlp-mappings` or submit `?` in CtrlP for more mapping help.
|
||||
|
||||
* Submit two or more dots `..` to go up the directory tree by one or multiple levels.
|
||||
* End the input string with a colon `:` followed by a command to execute it on the opening file(s):
|
||||
Use `:25` to jump to line 25.
|
||||
Use `:diffthis` when opening multiple files to run `:diffthis` on the first 4 files.
|
||||
|
||||
## Basic Options
|
||||
* Change the default mapping and the default command to invoke CtrlP:
|
||||
|
||||
```vim
|
||||
let g:ctrlp_map = '<c-p>'
|
||||
let g:ctrlp_cmd = 'CtrlP'
|
||||
```
|
||||
|
||||
* When invoked, unless a starting directory is specified, CtrlP will set its local working directory according to this variable:
|
||||
|
||||
```vim
|
||||
let g:ctrlp_working_path_mode = 'ra'
|
||||
```
|
||||
|
||||
`'c'` - the directory of the current file.
|
||||
`'r'` - the nearest ancestor that contains one of these directories or files: `.git` `.hg` `.svn` `.bzr` `_darcs`
|
||||
`'a'` - like c, but only if the current working directory outside of CtrlP is not a direct ancestor of the directory of the current file.
|
||||
`0` or `''` (empty string) - disable this feature.
|
||||
|
||||
Define additional root markers with the `g:ctrlp_root_markers` option.
|
||||
|
||||
* Exclude files and directories using Vim's `wildignore` and CtrlP's own `g:ctrlp_custom_ignore`:
|
||||
|
||||
```vim
|
||||
set wildignore+=*/tmp/*,*.so,*.swp,*.zip " MacOSX/Linux
|
||||
set wildignore+=*\\tmp\\*,*.swp,*.zip,*.exe " Windows
|
||||
|
||||
let g:ctrlp_custom_ignore = '\v[\/]\.(git|hg|svn)$'
|
||||
let g:ctrlp_custom_ignore = {
|
||||
\ 'dir': '\v[\/]\.(git|hg|svn)$',
|
||||
\ 'file': '\v\.(exe|so|dll)$',
|
||||
\ 'link': 'some_bad_symbolic_links',
|
||||
\ }
|
||||
```
|
||||
|
||||
* Use a custom file listing command:
|
||||
|
||||
```vim
|
||||
let g:ctrlp_user_command = 'find %s -type f' " MacOSX/Linux
|
||||
let g:ctrlp_user_command = 'dir %s /-n /b /s /a-d' " Windows
|
||||
```
|
||||
|
||||
Check `:help ctrlp-options` for other options.
|
||||
|
||||
## Installation
|
||||
Use your favorite method or check the homepage for a [quick installation guide][3].
|
||||
|
||||
[1]: http://i.imgur.com/yIynr.png
|
||||
[2]: https://github.com/kien/ctrlp.vim/tree/extensions
|
||||
[3]: http://kien.github.com/ctrlp.vim#installation
|
||||
4
bundle/git_syntastic/.gitignore
vendored
4
bundle/git_syntastic/.gitignore
vendored
@@ -1,4 +0,0 @@
|
||||
*~
|
||||
*.swp
|
||||
tags
|
||||
.DS_Store
|
||||
@@ -1,13 +0,0 @@
|
||||
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
||||
Version 2, December 2004
|
||||
|
||||
Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
|
||||
|
||||
Everyone is permitted to copy and distribute verbatim or modified
|
||||
copies of this license document, and changing it is allowed as long
|
||||
as the name is changed.
|
||||
|
||||
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. You just DO WHAT THE FUCK YOU WANT TO.
|
||||
@@ -1,160 +0,0 @@
|
||||
,
|
||||
/ \,,_ .'|
|
||||
,{{| /}}}}/_.' _____________________________________________
|
||||
}}}}` '{{' '. / \
|
||||
{{{{{ _ ;, \ / Ladies and Gentlemen, \
|
||||
,}}}}}} /o`\ ` ;) | |
|
||||
{{{{{{ / ( | this is ... |
|
||||
}}}}}} | \ | |
|
||||
{{{{{{{{ \ \ | |
|
||||
}}}}}}}}} '.__ _ | | _____ __ __ _ |
|
||||
{{{{{{{{ /`._ (_\ / | / ___/__ ______ / /_____ ______/ /_(_)____ |
|
||||
}}}}}}' | //___/ --=: \__ \/ / / / __ \/ __/ __ `/ ___/ __/ / ___/ |
|
||||
jgs `{{{{` | '--' | ___/ / /_/ / / / / /_/ /_/ (__ ) /_/ / /__ |
|
||||
}}}` | /____/\__, /_/ /_/\__/\__,_/____/\__/_/\___/ |
|
||||
| /____/ |
|
||||
| /
|
||||
\_____________________________________________/
|
||||
|
||||
|
||||
|
||||
|
||||
Syntastic is a syntax checking plugin 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.
|
||||
|
||||
At the time of this writing, syntax checking plugins exist for applescript, c,
|
||||
coffee, cpp, css, cucumber, cuda, docbk, erlang, eruby, fortran,
|
||||
gentoo_metadata, go, haml, haskell, html, javascript, json, less, lua, matlab,
|
||||
perl, php, puppet, python, rst, ruby, sass/scss, sh, tcl, tex, vala, xhtml,
|
||||
xml, xslt, yaml, zpt
|
||||
|
||||
Screenshot
|
||||
----------
|
||||
|
||||
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.
|
||||
|
||||

|
||||
|
||||
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.
|
||||
3. Signs are placed beside lines with errors - note that warnings are displayed in a different color.
|
||||
4. There is a configurable statusline flag you can include in your statusline config.
|
||||
5. Hover the mouse over a line containing an error and the error message is displayed as a balloon.
|
||||
6. (not shown) Highlighting errors with syntax highlighting. Erroneous parts of lines can be highlighted.
|
||||
|
||||
Installation
|
||||
------------
|
||||
|
||||
Installing syntastic is easy but first you need to have the pathogen plugin installed. If you already
|
||||
have pathogen working then skip Step 1 and go to Step 2.
|
||||
|
||||
Step 1: Install pathogen.vim
|
||||
----------------------------
|
||||
|
||||
First I'll show you how to install tpope's [pathogen.vim](https://github.com/tpope/vim-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:
|
||||
|
||||
mkdir -p ~/.vim/autoload ~/.vim/bundle; \
|
||||
curl -so ~/.vim/autoload/pathogen.vim \
|
||||
https://raw.github.com/tpope/vim-pathogen/master/autoload/pathogen.vim
|
||||
|
||||
Next you *need to add this* to your ~/.vimrc:
|
||||
|
||||
call pathogen#infect()
|
||||
|
||||
Step 2: Install syntastic as a pathogen bundle
|
||||
----------------------------------------------
|
||||
|
||||
You now have pathogen installed and can put syntastic into ~/.vim/bundle like this:
|
||||
|
||||
|
||||
cd ~/.vim/bundle
|
||||
git clone https://github.com/scrooloose/syntastic.git
|
||||
|
||||
Quit vim and start it back up to reload it, then type:
|
||||
|
||||
:Helptags
|
||||
|
||||
If you get an error when you do this, then you probably didn't install pathogen right. Go back to
|
||||
step 1 and make sure you did the following:
|
||||
|
||||
1. Created both the ~/.vim/autoload and ~/.vim/bundle directories.
|
||||
2. Added the "call pathogen#infect()" line to your ~/.vimrc file
|
||||
3. Did the git clone of syntastic inside ~/.vim/bundle
|
||||
4. Have permissions to access all of these directories.
|
||||
|
||||
|
||||
Google group
|
||||
------------
|
||||
|
||||
To get information or make suggestions check out the [google group](https://groups.google.com/group/vim-syntastic).
|
||||
|
||||
|
||||
FAQ
|
||||
---
|
||||
|
||||
__Q. I installed syntastic but it isn't reporting any errors ...__
|
||||
|
||||
A. The most likely reason is that the syntax checker that it requires isn't installed. For example: python requires either `flake8`, `pyflakes` or `pylint` to be installed and in `$PATH`. To see which executable is required, just look in `syntax_checkers/<filetype>.vim`. Note that aliases do not work; the actual executable must be available in your `$PATH`. Symbolic links are okay.
|
||||
|
||||
Another reason it could fail is that the error output for the syntax checker may have changed. In this case, make sure you have the latest version of the syntax checker installed. If it still fails then create an issue - or better yet, create a pull request.
|
||||
|
||||
__Q. 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 :lprev`.
|
||||
|
||||
If you use these commands a lot then you may want to add shortcut mappings to your vimrc, or install something like [unimpaired](https://github.com/tpope/vim-unimpaired) - which provides such mappings (among other things).
|
||||
|
||||
Changelog
|
||||
---------
|
||||
2.3.0 (16-feb-2012)
|
||||
|
||||
* Add syntastic_loc_list_height option
|
||||
* Allow errors to have a "subtype" that is signed differently to standard
|
||||
errors. Currently geared towards differentiating style errors from
|
||||
syntax errors. Currently implemented for phpcs (technosophos).
|
||||
* New checkers for:
|
||||
* yaml
|
||||
* haxe (davidB)
|
||||
* ocaml (edwintorok)
|
||||
* pylint (parantapa)
|
||||
* rust (cjab)
|
||||
* Updates to existing checkers:
|
||||
* jslint
|
||||
* jshint (gillesruppert)
|
||||
* fortran (bmattern)
|
||||
* sass
|
||||
* html (darcyparker)
|
||||
* coffee (darcyparker)
|
||||
* docbk (darcyparker)
|
||||
* xml
|
||||
* xslt
|
||||
* less (irrationalfab)
|
||||
* php (AD7six, technosophos)
|
||||
* cuda
|
||||
* python (mitchellh, pneff)
|
||||
* perl (Anthony Carapetis)
|
||||
* c (naoina, zsprackett)
|
||||
* puppet (frimik)
|
||||
|
||||
2.2.0 (24-dec-2011)
|
||||
|
||||
* only do syntax checks when files are saved (not when first opened) - add g:syntastic_check_on_open option to get the old behavior back
|
||||
* bug fix with echoing error messages; fixes incompatability with cmd-t (datanoise)
|
||||
* dont allow warnings to mask errors when signing/echoing errors (ashikase)
|
||||
* auto close location list when leaving buffer. (millermedeiros)
|
||||
* update errors appropriately when :SyntasticToggleMode is called
|
||||
* updates/fixes to existing checkers:
|
||||
* javascript/jshint (millermedeiros)
|
||||
* javascript/jslint
|
||||
* c (kongo2002)
|
||||
* Support for new filetypes:
|
||||
* JSON (millermedeiros, tocer)
|
||||
* rst (reStructuredText files) (JNRowe)
|
||||
* gentoo-metadata (JNRowe)
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 90 KiB |
@@ -1,245 +0,0 @@
|
||||
if exists("g:loaded_syntastic_c_autoload")
|
||||
finish
|
||||
endif
|
||||
let g:loaded_syntastic_c_autoload = 1
|
||||
|
||||
let s:save_cpo = &cpo
|
||||
set cpo&vim
|
||||
|
||||
" initialize c/cpp syntax checker handlers
|
||||
function! s:Init()
|
||||
let s:handlers = []
|
||||
let s:cflags = {}
|
||||
|
||||
call s:RegHandler('gtk', 'syntastic#c#CheckPKG',
|
||||
\ ['gtk', 'gtk+-2.0', 'gtk+', 'glib-2.0', 'glib'])
|
||||
call s:RegHandler('glib', 'syntastic#c#CheckPKG',
|
||||
\ ['glib', 'glib-2.0', 'glib'])
|
||||
call s:RegHandler('glade', 'syntastic#c#CheckPKG',
|
||||
\ ['glade', 'libglade-2.0', 'libglade'])
|
||||
call s:RegHandler('libsoup', 'syntastic#c#CheckPKG',
|
||||
\ ['libsoup', 'libsoup-2.4', 'libsoup-2.2'])
|
||||
call s:RegHandler('webkit', 'syntastic#c#CheckPKG',
|
||||
\ ['webkit', 'webkit-1.0'])
|
||||
call s:RegHandler('cairo', 'syntastic#c#CheckPKG',
|
||||
\ ['cairo', 'cairo'])
|
||||
call s:RegHandler('pango', 'syntastic#c#CheckPKG',
|
||||
\ ['pango', 'pango'])
|
||||
call s:RegHandler('libxml', 'syntastic#c#CheckPKG',
|
||||
\ ['libxml', 'libxml-2.0', 'libxml'])
|
||||
call s:RegHandler('freetype', 'syntastic#c#CheckPKG',
|
||||
\ ['freetype', 'freetype2', 'freetype'])
|
||||
call s:RegHandler('SDL', 'syntastic#c#CheckPKG',
|
||||
\ ['sdl', 'sdl'])
|
||||
call s:RegHandler('opengl', 'syntastic#c#CheckPKG',
|
||||
\ ['opengl', 'gl'])
|
||||
call s:RegHandler('ruby', 'syntastic#c#CheckRuby', [])
|
||||
call s:RegHandler('Python\.h', 'syntastic#c#CheckPython', [])
|
||||
call s:RegHandler('php\.h', 'syntastic#c#CheckPhp', [])
|
||||
endfunction
|
||||
|
||||
" default include directories
|
||||
let s:default_includes = [ '.', '..', 'include', 'includes',
|
||||
\ '../include', '../includes' ]
|
||||
|
||||
" uniquify the input list
|
||||
function! s:Unique(list)
|
||||
let l = []
|
||||
for elem in a:list
|
||||
if index(l, elem) == -1
|
||||
let l = add(l, elem)
|
||||
endif
|
||||
endfor
|
||||
return l
|
||||
endfunction
|
||||
|
||||
" convenience function to determine the 'null device' parameter
|
||||
" based on the current operating system
|
||||
function! syntastic#c#GetNullDevice()
|
||||
if has('win32')
|
||||
return '-o nul'
|
||||
elseif has('unix') || has('mac')
|
||||
return '-o /dev/null'
|
||||
endif
|
||||
return ''
|
||||
endfunction
|
||||
|
||||
" get the gcc include directory argument depending on the default
|
||||
" includes and the optional user-defined 'g:syntastic_c_include_dirs'
|
||||
function! syntastic#c#GetIncludeDirs(filetype)
|
||||
let include_dirs = copy(s:default_includes)
|
||||
|
||||
if exists('g:syntastic_'.a:filetype.'_include_dirs')
|
||||
call extend(include_dirs, g:syntastic_{a:filetype}_include_dirs)
|
||||
endif
|
||||
|
||||
return join(map(s:Unique(include_dirs), '"-I" . v:val'), ' ')
|
||||
endfunction
|
||||
|
||||
" read additional compiler flags from the given configuration file
|
||||
" the file format and its parsing mechanism is inspired by clang_complete
|
||||
function! syntastic#c#ReadConfig(file)
|
||||
" search in the current file's directory upwards
|
||||
let config = findfile(a:file, '.;')
|
||||
if config == '' || !filereadable(config) | return '' | endif
|
||||
|
||||
" convert filename into absolute path
|
||||
let filepath = substitute(fnamemodify(config, ':p:h'), '\', '/', 'g')
|
||||
|
||||
" try to read config file
|
||||
try
|
||||
let lines = map(readfile(config),
|
||||
\ 'substitute(v:val, ''\'', ''/'', ''g'')')
|
||||
catch /E484/
|
||||
return ''
|
||||
endtry
|
||||
|
||||
let parameters = []
|
||||
for line in lines
|
||||
let matches = matchlist(line, '^\s*-I\s*\(\S\+\)')
|
||||
if matches != [] && matches[1] != ''
|
||||
" this one looks like an absolute path
|
||||
if match(matches[1], '^\%(/\|\a:\)') != -1
|
||||
call add(parameters, '-I' . matches[1])
|
||||
else
|
||||
call add(parameters, '-I' . filepath . '/' . matches[1])
|
||||
endif
|
||||
else
|
||||
call add(parameters, line)
|
||||
endif
|
||||
endfor
|
||||
|
||||
return join(parameters, ' ')
|
||||
endfunction
|
||||
|
||||
" search the first 100 lines for include statements that are
|
||||
" given in the handlers dictionary
|
||||
function! syntastic#c#SearchHeaders()
|
||||
let includes = ''
|
||||
let files = []
|
||||
let found = []
|
||||
let lines = filter(getline(1, 100), 'v:val =~# "#\s*include"')
|
||||
|
||||
" search current buffer
|
||||
for line in lines
|
||||
let file = matchstr(line, '"\zs\S\+\ze"')
|
||||
if file != ''
|
||||
call add(files, file)
|
||||
continue
|
||||
endif
|
||||
for handler in s:handlers
|
||||
if line =~# handler["regex"]
|
||||
let includes .= call(handler["func"], handler["args"])
|
||||
call add(found, handler["regex"])
|
||||
break
|
||||
endif
|
||||
endfor
|
||||
endfor
|
||||
|
||||
" search included headers
|
||||
for hfile in files
|
||||
if hfile != ''
|
||||
let filename = expand('%:p:h') . (has('win32') ?
|
||||
\ '\' : '/') . hfile
|
||||
try
|
||||
let lines = readfile(filename, '', 100)
|
||||
catch /E484/
|
||||
continue
|
||||
endtry
|
||||
let lines = filter(lines, 'v:val =~# "#\s*include"')
|
||||
for handler in s:handlers
|
||||
if index(found, handler["regex"]) != -1
|
||||
continue
|
||||
endif
|
||||
for line in lines
|
||||
if line =~# handler["regex"]
|
||||
let includes .= call(handler["func"], handler["args"])
|
||||
call add(found, handler["regex"])
|
||||
break
|
||||
endif
|
||||
endfor
|
||||
endfor
|
||||
endif
|
||||
endfor
|
||||
|
||||
return includes
|
||||
endfunction
|
||||
|
||||
" try to find library with 'pkg-config'
|
||||
" search possible libraries from first to last given
|
||||
" argument until one is found
|
||||
function! syntastic#c#CheckPKG(name, ...)
|
||||
if executable('pkg-config')
|
||||
if !has_key(s:cflags, a:name)
|
||||
for i in range(a:0)
|
||||
let l:cflags = system('pkg-config --cflags '.a:000[i])
|
||||
" since we cannot necessarily trust the pkg-config exit code
|
||||
" we have to check for an error output as well
|
||||
if v:shell_error == 0 && l:cflags !~? 'not found'
|
||||
let l:cflags = ' '.substitute(l:cflags, "\n", '', '')
|
||||
let s:cflags[a:name] = l:cflags
|
||||
return l:cflags
|
||||
endif
|
||||
endfor
|
||||
else
|
||||
return s:cflags[a:name]
|
||||
endif
|
||||
endif
|
||||
return ''
|
||||
endfunction
|
||||
|
||||
" try to find PHP includes with 'php-config'
|
||||
function! syntastic#c#CheckPhp()
|
||||
if executable('php-config')
|
||||
if !exists('s:php_flags')
|
||||
let s:php_flags = system('php-config --includes')
|
||||
let s:php_flags = ' ' . substitute(s:php_flags, "\n", '', '')
|
||||
endif
|
||||
return s:php_flags
|
||||
endif
|
||||
return ''
|
||||
endfunction
|
||||
|
||||
" try to find the ruby headers with 'rbconfig'
|
||||
function! syntastic#c#CheckRuby()
|
||||
if executable('ruby')
|
||||
if !exists('s:ruby_flags')
|
||||
let s:ruby_flags = system('ruby -r rbconfig -e '
|
||||
\ . '''puts Config::CONFIG["archdir"]''')
|
||||
let s:ruby_flags = substitute(s:ruby_flags, "\n", '', '')
|
||||
let s:ruby_flags = ' -I' . s:ruby_flags
|
||||
endif
|
||||
return s:ruby_flags
|
||||
endif
|
||||
return ''
|
||||
endfunction
|
||||
|
||||
" try to find the python headers with distutils
|
||||
function! syntastic#c#CheckPython()
|
||||
if executable('python')
|
||||
if !exists('s:python_flags')
|
||||
let s:python_flags = system('python -c ''from distutils import '
|
||||
\ . 'sysconfig; import sys; sys.stdout.write(sysconfig.get_python_inc())''')
|
||||
let s:python_flags = substitute(s:python_flags, "\n", '', '')
|
||||
let s:python_flags = ' -I' . s:python_flags
|
||||
endif
|
||||
return s:python_flags
|
||||
endif
|
||||
return ''
|
||||
endfunction
|
||||
|
||||
" return a handler dictionary object
|
||||
function! s:RegHandler(regex, function, args)
|
||||
let handler = {}
|
||||
let handler["regex"] = a:regex
|
||||
let handler["func"] = function(a:function)
|
||||
let handler["args"] = a:args
|
||||
call add(s:handlers, handler)
|
||||
endfunction
|
||||
|
||||
call s:Init()
|
||||
|
||||
let &cpo = s:save_cpo
|
||||
unlet s:save_cpo
|
||||
|
||||
" vim: set et sts=4 sw=4:
|
||||
@@ -1,18 +0,0 @@
|
||||
if exists("g:loaded_syntastic_util_autoload")
|
||||
finish
|
||||
endif
|
||||
let g:loaded_syntastic_util_autoload = 1
|
||||
|
||||
let s:save_cpo = &cpo
|
||||
set cpo&vim
|
||||
|
||||
function! syntastic#util#DevNull()
|
||||
if has('win32')
|
||||
return 'NUL'
|
||||
endif
|
||||
return '/dev/null'
|
||||
endfunction
|
||||
|
||||
let &cpo = s:save_cpo
|
||||
unlet s:save_cpo
|
||||
" vim: set et sts=4 sw=4:
|
||||
@@ -1,588 +0,0 @@
|
||||
*syntastic.txt* Syntax checking on the fly has never been so pimp.
|
||||
*syntastic*
|
||||
|
||||
|
||||
It's a bird! It's a plane! ZOMG It's ... ~
|
||||
|
||||
_____ __ __ _ ~
|
||||
/ ___/__ ______ / /_____ ______/ /_(_)____ ~
|
||||
\__ \/ / / / __ \/ __/ __ `/ ___/ __/ / ___/ ~
|
||||
___/ / /_/ / / / / /_/ /_/ (__ ) /_/ / /__ ~
|
||||
/____/\__, /_/ /_/\__/\__,_/____/\__/_/\___/ ~
|
||||
/____/ ~
|
||||
|
||||
|
||||
|
||||
Reference Manual~
|
||||
|
||||
|
||||
==============================================================================
|
||||
CONTENTS *syntastic-contents*
|
||||
|
||||
1.Intro...................................|syntastic-intro|
|
||||
2.Functionality provided..................|syntastic-functionality|
|
||||
2.1.The statusline flag...............|syntastic-statusline-flag|
|
||||
2.2.Error signs.......................|syntastic-error-signs|
|
||||
2.3.Error window......................|syntastic-error-window|
|
||||
3.Commands................................|syntastic-commands|
|
||||
4.Options.................................|syntastic-options|
|
||||
5.Writing syntax checkers.................|syntastic-syntax-checkers|
|
||||
6.About...................................|syntastic-about|
|
||||
7.Changelog...............................|syntastic-changelog|
|
||||
8.Credits.................................|syntastic-credits|
|
||||
9.License.................................|syntastic-license|
|
||||
|
||||
|
||||
==============================================================================
|
||||
1. Intro *syntastic-intro*
|
||||
|
||||
Syntastic is a syntax checking plugin that runs files through external syntax
|
||||
checkers. This can be done on demand, or automatically as files are saved and
|
||||
opened. 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 comes in two parts: the syntax checker plugins, and the core script
|
||||
(i.e. syntastic.vim). The 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. At the time of this writing, syntax checking plugins
|
||||
exist for c, coffee, cpp, css, cucumber, cuda, docbk, erlang, eruby, fortran,
|
||||
go, haml, haskell, html, javascript, less, lua, matlab, perl, php, puppet,
|
||||
python, ruby, sass/scss, sh, tcl, tex, vala, xhtml, xml, xslt, zpt
|
||||
|
||||
Take a look in the syntax_checkers directory for the most up to date list.
|
||||
|
||||
If your language is not supported then see |syntastic-syntax-checkers| for
|
||||
details on how to implement a syntax checking plugin, and be sure to send me a
|
||||
patch ;-)
|
||||
|
||||
This plugin is currently only recommended for *nix users. It is functional on
|
||||
Windows, but since the syntax checking plugins shell out, the command window
|
||||
briefly appears whenever one is executed.
|
||||
|
||||
|
||||
==============================================================================
|
||||
2. Functionality provided *syntastic-functionality*
|
||||
|
||||
Syntax checking can be done automatically or on demand (see
|
||||
|'syntastic_mode_map'| for configuring this).
|
||||
|
||||
When syntax checking is done, the features below can be used to notify the
|
||||
user of errors. See |syntastic-options| for how to configure and
|
||||
activate/deactivate these features.
|
||||
|
||||
* A configurable statusline flag
|
||||
* Lines with errors can have |signs| placed beside them - where a different
|
||||
sign is used for errors and warnings.
|
||||
* A |location-list| can be displayed with error messages for erroneous
|
||||
buffers.
|
||||
* Offending parts of lines can be highlighted (this functionality is only
|
||||
provided by some syntax checkers).
|
||||
* Balloons (if compiled in) can be used to display error messages for
|
||||
erroneous lines when hovering the mouse over them.
|
||||
|
||||
|
||||
Note: This functionality is only available if a syntax checker plugin is
|
||||
present for the filetype of the buffer in question. See
|
||||
|syntastic-syntax-checkers| for details.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
2.1. The statusline flag *syntastic-statusline-flag*
|
||||
|
||||
To use the statusline flag, this must appear in your |'statusline'| setting >
|
||||
%{SyntasticStatuslineFlag()}
|
||||
<
|
||||
Something like this could be more useful: >
|
||||
set statusline+=%#warningmsg#
|
||||
set statusline+=%{SyntasticStatuslineFlag()}
|
||||
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
|
||||
------------------------------------------------------------------------------
|
||||
2.2. Error signs *syntastic-error-signs*
|
||||
|
||||
Syntastic uses the |:sign| commands to mark lines with errors and warnings in
|
||||
the sign column. To enable this feature, use the |'syntastic_enable_signs'|
|
||||
option.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
2.3. The error window *:Errors* *syntastic-error-window*
|
||||
|
||||
You can use the :Errors command to display the errors for the current buffer
|
||||
in the |location-list|.
|
||||
|
||||
Note that when you use :Errors, the current location list is overwritten with
|
||||
Syntastic's own location list.
|
||||
|
||||
|
||||
==============================================================================
|
||||
3. Commands *syntastic-commands*
|
||||
|
||||
:Errors *:SyntasticErrors*
|
||||
|
||||
When errors have been detected, use this command to pop up the |location-list|
|
||||
and display the error messages.
|
||||
|
||||
|
||||
:SyntasticToggleMode *:SyntasticToggleMode*
|
||||
|
||||
Toggles syntastic between active and passive mode. See |'syntastic_mode_map'|
|
||||
for more info.
|
||||
|
||||
|
||||
:SyntasticCheck *:SyntasticCheck*
|
||||
|
||||
Manually cause a syntax check to be done. Useful in passive mode, or if the
|
||||
current filetype is set to passive. See |'syntastic_mode_map'| for more info.
|
||||
|
||||
|
||||
==============================================================================
|
||||
4. Options *syntastic-options*
|
||||
|
||||
|
||||
*'syntastic_check_on_open'*
|
||||
Default: 0
|
||||
If enabled, syntastic will do syntax checks when buffers are first loaded as
|
||||
well as on saving >
|
||||
let g:syntastic_check_on_open=1
|
||||
<
|
||||
|
||||
*'syntastic_echo_current_error'*
|
||||
Default: 1
|
||||
If enabled, syntastic will error message associated with the current line to
|
||||
the command window. If multiple errors are found, the first will be used. >
|
||||
let g:syntastic_echo_current_error=1
|
||||
<
|
||||
|
||||
*'syntastic_enable_signs'*
|
||||
Default: 1
|
||||
Use this option to tell syntastic whether to use the |:sign| interface to mark
|
||||
syntax errors: >
|
||||
let g:syntastic_enable_signs=1
|
||||
<
|
||||
|
||||
*'syntastic_error_symbol'* *'syntastic_style_error_symbol'*
|
||||
*'syntastic_warning_symbol'* *'syntastic_style_warning_symbol'*
|
||||
Use this option to control what the syntastic |:sign| text contains. Several
|
||||
error symobls can be customized:
|
||||
syntastic_error_symbol - For syntax errors, defaults to '>>'
|
||||
syntastic_style_error_symbol - For style errors, defaults to 'S>'
|
||||
syntastic_warning_symbol - For syntax warnings, defaults to '>>'
|
||||
syntastic_style_warning_symbol - For style warnings, defaults to 'S>'
|
||||
|
||||
Example: >
|
||||
let g:syntastic_error_symbol='✗'
|
||||
let g:syntastic_warning_symbol='⚠'
|
||||
<
|
||||
|
||||
*'syntastic_enable_balloons'*
|
||||
Default: 1
|
||||
Use this option to tell syntastic whether to display error messages in balloons
|
||||
when the mouse is hovered over erroneous lines: >
|
||||
let g:syntastic_enable_balloons = 1
|
||||
<
|
||||
Note that vim must be compiled with |+balloon_eval|.
|
||||
|
||||
*'syntastic_enable_highlighting'*
|
||||
Default: 1
|
||||
Use this option to tell syntastic whether to use syntax highlighting to mark
|
||||
errors (where possible). Highlighting can be turned off with the following >
|
||||
let g:syntastic_enable_highlighting = 0
|
||||
<
|
||||
|
||||
*'syntastic_auto_jump'*
|
||||
Default: 0
|
||||
Enable this option if you want the cursor to jump to the first detected error
|
||||
when saving or opening a file: >
|
||||
let g:syntastic_auto_jump=1
|
||||
<
|
||||
|
||||
*'syntastic_auto_loc_list'*
|
||||
Default: 2
|
||||
Use this option to tell syntastic to automatically open and/or close the
|
||||
|location-list| (see |syntastic-error-window|).
|
||||
|
||||
When set to 0 the error window will not be opened or closed automatically. >
|
||||
let g:syntastic_auto_loc_list=0
|
||||
<
|
||||
|
||||
When set to 1 the error window will be automatically opened when errors are
|
||||
detected, and closed when none are detected. >
|
||||
let g:syntastic_auto_loc_list=1
|
||||
<
|
||||
When set to 2 the error window will be automatically closed when no errors are
|
||||
detected, but not opened automatically. >
|
||||
let g:syntastic_auto_loc_list=2
|
||||
<
|
||||
|
||||
*'syntastic_loc_list_height'*
|
||||
Default: 10
|
||||
Use this option to specify the height of the location lists that syntastic
|
||||
opens. >
|
||||
let g:syntastic_loc_list_height=5
|
||||
<
|
||||
|
||||
|
||||
*'syntastic_mode_map'*
|
||||
Default: { "mode": "active",
|
||||
"active_filetypes": [],
|
||||
"passive_filetypes": [] }
|
||||
|
||||
Use this option to fine tune when automatic syntax checking is done (or not
|
||||
done).
|
||||
|
||||
The option should be set to something like: >
|
||||
|
||||
let g:syntastic_mode_map = { 'mode': 'active',
|
||||
\ 'active_filetypes': ['ruby', 'php'],
|
||||
\ 'passive_filetypes': ['puppet'] }
|
||||
<
|
||||
|
||||
"mode" can be mapped to one of two values - "active" or "passive". When set to
|
||||
active, syntastic does automatic checking whenever a buffer is saved or
|
||||
initially opened. When set to "passive" syntastic only checks when the user
|
||||
calls :SyntasticCheck.
|
||||
|
||||
The exceptions to these rules are defined with "active_filetypes" and
|
||||
"passive_filetypes". In passive mode, automatic checks are still done
|
||||
for all filetypes in the "active_filetypes" array. In active mode,
|
||||
automatic checks are not done for any filetypes in the
|
||||
"passive_filetypes" array.
|
||||
|
||||
At runtime, the |:SyntasticToggleMode| command can be used to switch between
|
||||
active and passive mode.
|
||||
|
||||
If any of "mode", "active_filetypes", or "passive_filetypes" are not specified
|
||||
then they will default to their default value as above.
|
||||
|
||||
*'syntastic_quiet_warnings'*
|
||||
|
||||
Use this option if you only care about syntax errors, not warnings. When set,
|
||||
this option has the following effects:
|
||||
* no |signs| appear unless there is at least one error, whereupon both
|
||||
errors and warnings are displayed
|
||||
* the |'syntastic_auto_loc_list'| option only pops up the error window if
|
||||
there's at least one error, whereupon both errors and warnings are
|
||||
displayed
|
||||
>
|
||||
let g:syntastic_quiet_warnings=1
|
||||
<
|
||||
|
||||
*'syntastic_stl_format'*
|
||||
|
||||
Default: [Syntax: line:%F (%t)]
|
||||
Use this option to control what the syntastic statusline text contains. Several
|
||||
magic flags are available to insert information:
|
||||
%e - number of errors
|
||||
%w - number of warnings
|
||||
%t - total number of warnings and errors
|
||||
%fe - line number of first error
|
||||
%fw - line number of first warning
|
||||
%F - line number of first warning or error
|
||||
|
||||
Several additional flags are available to hide text under certain conditions:
|
||||
%E{...} - hide the text in the brackets unless there are errors
|
||||
%W{...} - hide the text in the brackets unless there are warnings
|
||||
%B{...} - hide the text in the brackets unless there are both warnings AND
|
||||
errors
|
||||
These flags cant be nested.
|
||||
|
||||
Example: >
|
||||
let g:syntastic_stl_format = '[%E{Err: %fe #%e}%B{, }%W{Warn: %fw #%w}]'
|
||||
<
|
||||
If this format is used and the current buffer has 5 errors and 1 warning
|
||||
starting on lines 20 and 10 respectively then this would appear on the
|
||||
statusline: >
|
||||
[Err: 20 #5, Warn: 10 #1]
|
||||
<
|
||||
If the buffer had 2 warnings, starting on line 5 then this would appear: >
|
||||
[Warn: 5 #2]
|
||||
<
|
||||
|
||||
|
||||
==============================================================================
|
||||
5. Writing syntax checkers *syntastic-syntax-checkers*
|
||||
|
||||
|
||||
A syntax checker plugin is really nothing more than a single function. You
|
||||
should define them in ~/.vim/syntax_checkers/<filetype>.vim, but this is
|
||||
purely for convenience; Syntastic doesn't actually care where these functions
|
||||
are defined.
|
||||
|
||||
A syntax checker plugin must define a function of the form:
|
||||
>
|
||||
SyntaxCheckers_<filetype>_GetLocList()
|
||||
<
|
||||
The output of this function must be of the same format as that returned by
|
||||
the |getloclist()| function. See |getloclist()| and |getqflist()| for
|
||||
details.
|
||||
|
||||
To achieve this, the function should call |SyntasticMake()| or shell out to a
|
||||
syntax checker, parse the output and munge it into the format.
|
||||
|
||||
There are several syntax checker plugins provided with this plugin. The ruby
|
||||
one is a good example of |SyntasticMake()|, while the haml one is a good
|
||||
example of how to create the data structure manually.
|
||||
|
||||
|
||||
SyntasticMake({options}) *SyntasticMake()*
|
||||
{options} must be a dictionary. It can contain "makeprg" and "errorformat"
|
||||
as keys (both optional).
|
||||
|
||||
SyntasticMake will run |:lmake| with the given |'makeprg'| and
|
||||
|'errorformat'| (using the current settings if none are supplied). It will
|
||||
store the resulting error list and use it to provide all of the
|
||||
|syntastic-functionality|. The previous makeprg and errorformat settings
|
||||
will then be restored, as well as the location list for the window. From
|
||||
the user's perspective, it will be as though |:lmake| was never run.
|
||||
|
||||
Note that the given "makeprg" and "errorformat" will be set using |:let-&|,
|
||||
so you should not escape spaces.
|
||||
|
||||
|
||||
==============================================================================
|
||||
6. About *syntastic-about*
|
||||
|
||||
The author of syntastic is a mighty wild stallion, hear him roar! >
|
||||
_ _ _____ _____ ___ ___ ___ ____ _ _ _
|
||||
| \ | | ____| ____|_ _|_ _|_ _/ ___| | | | |
|
||||
| \| | _| | _| | | | | | | | _| |_| | |
|
||||
| |\ | |___| |___ | | | | | | |_| | _ |_|
|
||||
|_| \_|_____|_____|___|___|___\____|_| |_(_)
|
||||
|
||||
<
|
||||
He likes to trot around in the back yard reading his emails and sipping a
|
||||
scalding hot cup of Earl Grey. Email him at martin.grenfell at gmail dot com.
|
||||
He can also be found trolling the #vim channel on the freenode IRC network as
|
||||
scrooloose.
|
||||
|
||||
Bug reports, feedback, suggestions etc are welcomed.
|
||||
|
||||
|
||||
The latest official releases will be on vim.org at some point.
|
||||
|
||||
The latest dev versions are on github
|
||||
http://github.com/scrooloose/syntastic
|
||||
|
||||
==============================================================================
|
||||
7. Changelog *syntastic-changelog*
|
||||
|
||||
2.3.0
|
||||
- Add syntastic_loc_list_height option
|
||||
- Allow errors to have a "subtype" that is signed differently to standard
|
||||
errors. Currently geared towards differentiating style errors from
|
||||
syntax errors. Currently implemented for phpcs (technosophos).
|
||||
- New checkers for:
|
||||
- yaml
|
||||
- haxe (davidB)
|
||||
- ocaml (edwintorok)
|
||||
- pylint (parantapa)
|
||||
- rust (cjab)
|
||||
|
||||
- Updates to existing checkers:
|
||||
- jslint
|
||||
- jshint (gillesruppert)
|
||||
- fortran (bmattern)
|
||||
- sass
|
||||
- html (darcyparker)
|
||||
- coffee (darcyparker)
|
||||
- docbk (darcyparker)
|
||||
- xml
|
||||
- xslt
|
||||
- less (irrationalfab)
|
||||
- php (AD7six, technosophos)
|
||||
- cuda
|
||||
- python (mitchellh, pneff)
|
||||
- perl (Anthony Carapetis)
|
||||
- c (naoina, zsprackett)
|
||||
- puppet (frimik)
|
||||
|
||||
2.2.0
|
||||
- only do syntax checks when files are saved (not when first opened) - add
|
||||
g:syntastic_check_on_open option to get the old behavior back
|
||||
- bug fix with echoing error messages; fixes incompatability with cmd-t (datanoise)
|
||||
- dont allow warnings to mask errors when signing/echoing errors (ashikase)
|
||||
- auto close location list when leaving buffer. (millermedeiros)
|
||||
- update errors appropriately when :SyntasticToggleMode is called
|
||||
- updates/fixes to existing checkers:
|
||||
- javascript/jshint (millermedeiros)
|
||||
- javascript/jslint
|
||||
- c (kongo2002)
|
||||
- Support for new filetypes:
|
||||
- JSON (millermedeiros, tocer)
|
||||
- rst (reStructuredText files) (JNRowe)
|
||||
- gentoo-metadata (JNRowe)
|
||||
|
||||
|
||||
2.1.0
|
||||
- when the cursor is on a line containing an error, echo the
|
||||
error msg (kevinw)
|
||||
- various bug fixes and refactoring
|
||||
- updates/fixes to existing checkers:
|
||||
- html (millermedeiros)
|
||||
- erlang
|
||||
- coffeescript
|
||||
- javascript
|
||||
- sh
|
||||
- php (add support for phpcs - technosophos)
|
||||
- add an applescript checker (Zhai Cai)
|
||||
- add support for hyphenated filetypes (JNRowe)
|
||||
|
||||
2.0.0
|
||||
- Add support for highlighting the erroneous parts of lines (kstep)
|
||||
- Add support for displaying errors via balloons (kstep)
|
||||
- Add syntastic_mode_map option to give more control over when checking
|
||||
should be done.
|
||||
- Add :SyntasticCheck command to force a syntax check - useful in passive
|
||||
mode (justone).
|
||||
- Add the option to automatically close the location list, but not
|
||||
automatically open it (milkypostman)
|
||||
- Add syntastic_auto_jump option to automatically jump to the first
|
||||
error (milkypostman)
|
||||
- Only source syntax checkers as needed - instead of loading all of them
|
||||
when vim starts
|
||||
|
||||
- Support for new filetypes:
|
||||
- less (julienXX)
|
||||
- docbook (tpope)
|
||||
- matlab (jasongraham)
|
||||
- go (dtjm)
|
||||
- puppet (uggedal, roman, zsprackett)
|
||||
- haskell (baldo, roman)
|
||||
- tcl (et)
|
||||
- vala (kstep)
|
||||
- cuda (temporaer)
|
||||
- css (oryband, sitedyno)
|
||||
- fortran (Karl Yngve Lervåg)
|
||||
- xml (kusnier)
|
||||
- xslt (kusnier)
|
||||
- erlang (kTT)
|
||||
- zpt (claytron)
|
||||
|
||||
- updates to existing checkers:
|
||||
- javascript (mogren, bryanforbes, cjab, ajduncan)
|
||||
- sass/scss (tmm1, atourino, dlee, epeli)
|
||||
- ruby (changa)
|
||||
- perl (harleypig)
|
||||
- haml (bmihelac)
|
||||
- php (kstep, docteurklein)
|
||||
- python (kstep, soli)
|
||||
- lua (kstep)
|
||||
- html (kstep)
|
||||
- xhtml (kstep)
|
||||
- c (kongo2002, brandonw)
|
||||
- cpp (kongo2002)
|
||||
- coffee (industrial)
|
||||
- eruby (sergevm)
|
||||
|
||||
1.2.0
|
||||
- New syntax checkers from github:kongo2002
|
||||
- c (thanks also to github:jperras)
|
||||
- cpp
|
||||
- lua
|
||||
- sh (thanks also to github:jmcantrell)
|
||||
- add coffee syntax checked by github:lstoll
|
||||
- add tex syntax checker
|
||||
- make html checker play nicer with html5, thanks to github:enaeseth
|
||||
- escape filenames properly when invoking syntax checkers, thanks to
|
||||
github:jmcantrell
|
||||
- adjust the ruby syntax checker to avoid some common annoying warnings,
|
||||
thanks to github:robertwahler
|
||||
|
||||
1.1.0 [codenamed: tpimp]
|
||||
- Dont load rubygems for ruby/eruby syntax checkers. Thanks tpope.
|
||||
- Improve the javascript syntax checker to catch some warnings that were
|
||||
getting missed. Thanks tpope.
|
||||
- Dont automatically focus the error window. Thanks tpope.
|
||||
- Add support for cucumber [tpope], haskell & perl [Anthony Carapetis],
|
||||
and xhtml
|
||||
- Add commands to enable/disable syntax checking at runtime. See :help
|
||||
syntastic-commands.
|
||||
- Add an option to specifiy syntax checkers that should be disabled by
|
||||
default. See :help syntastic_disabled_filetypes.
|
||||
- Dont use :signs if vim wasnt compiled with support for them.
|
||||
)
|
||||
|
||||
==============================================================================
|
||||
8. Credits *syntastic-credits*
|
||||
|
||||
Thanks to the following people for testing, bug reports, patches etc. They own,
|
||||
hard.
|
||||
|
||||
Mikael Fridh (frimik)
|
||||
Patrice Neff (pneff )
|
||||
Gilles Ruppert (gillesruppert)
|
||||
Naoya INADA (naoina)
|
||||
Mitchell Hashimoto (mitchellh)
|
||||
irrationalfab
|
||||
Andy Dawson (AD7six)
|
||||
Parantapa Bhattacharya (parantapa)
|
||||
edwintorok
|
||||
Darcy Parker (darcyparker)
|
||||
bmattern
|
||||
David Bernard (davidB)
|
||||
Aleksey V. Zapparov (ixti)
|
||||
Benji Fisher (benjifisher)
|
||||
Lance Fetters (ashikase)
|
||||
datanoise
|
||||
Giuseppe Rota (grota)
|
||||
tocer
|
||||
James Rowe (JNRowe)
|
||||
Zhai Cai
|
||||
Matt Butcher (technosophos)
|
||||
Kevin Watters (kevinw)
|
||||
Miller Medeiros (millermedeiros)
|
||||
Pawel Salata (kTT)
|
||||
Fjölnir Ásgeirsson (aptiva)
|
||||
Clayton Parker (claytron)
|
||||
S. Zachariah Sprackett (zsprackett)
|
||||
Sylvain Soliman (soli)
|
||||
Ricardo Catalinas Jiménez (jimenezrick)
|
||||
kusnier
|
||||
Klein Florian (docteurklein)
|
||||
sitedyno
|
||||
Matthew Batema (mlb-)
|
||||
Nate Jones (justone)
|
||||
sergevm
|
||||
Karl Yngve Lervåg
|
||||
Pavel Argentov (argent-smith)
|
||||
Andy Duncan (ajduncan)
|
||||
Antonio Touriño (atourino)
|
||||
Chad Jablonski (cjab)
|
||||
Roman Gonzalez (roman)
|
||||
Tom Wieland (industrial)
|
||||
Ory Band (oryband)
|
||||
Esa-Matti Suuronen (epeli)
|
||||
Brandon Waskiewicz (brandonw)
|
||||
dlee
|
||||
temporaer
|
||||
Jason Graham (jasongraham)
|
||||
Sam Nguyen (dtjm)
|
||||
Claes Mogren (mogren)
|
||||
Eivind Uggedal (uggedal)
|
||||
kstep
|
||||
Andreas Baldeau (baldo)
|
||||
Eric Thomas (et)
|
||||
Brian Donovan (eventualbuddha)
|
||||
Bryan Forbes (bryanforbes)
|
||||
Aman Gupta (tmm1)
|
||||
Donald Ephraim Curtis (milkypostman)
|
||||
Dominique Rose-Rosette (changa)
|
||||
Harley Pig (harleypig)
|
||||
bmihelac
|
||||
Julien Blanchard (julienXX)
|
||||
Gregor Uhlenheuer (kongo2002)
|
||||
Lincoln Stoll
|
||||
Tim Carey-Smith (halorgium)
|
||||
Tim Pope (tpope)
|
||||
Travis Jeffery
|
||||
Anthony Carapetis
|
||||
|
||||
|
||||
==============================================================================
|
||||
9. License *syntastic-license*
|
||||
|
||||
Syntastic is released under the wtfpl.
|
||||
See http://sam.zoy.org/wtfpl/COPYING.
|
||||
@@ -1,683 +0,0 @@
|
||||
"============================================================================
|
||||
"File: syntastic.vim
|
||||
"Description: vim plugin for on the fly syntax checking
|
||||
"Maintainer: Martin Grenfell <martin.grenfell at gmail dot com>
|
||||
"Version: 2.3.0
|
||||
"Last Change: 16 Feb, 2012
|
||||
"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_plugin")
|
||||
finish
|
||||
endif
|
||||
let g:loaded_syntastic_plugin = 1
|
||||
|
||||
let s:running_windows = has("win16") || has("win32")
|
||||
|
||||
if !exists("g:syntastic_enable_signs")
|
||||
let g:syntastic_enable_signs = 1
|
||||
endif
|
||||
|
||||
if !exists("g:syntastic_error_symbol")
|
||||
let g:syntastic_error_symbol = '>>'
|
||||
endif
|
||||
|
||||
if !exists("g:syntastic_warning_symbol")
|
||||
let g:syntastic_warning_symbol = '>>'
|
||||
endif
|
||||
|
||||
if !exists("g:syntastic_style_error_symbol")
|
||||
let g:syntastic_style_error_symbol = 'S>'
|
||||
endif
|
||||
|
||||
if !exists("g:syntastic_style_warning_symbol")
|
||||
let g:syntastic_style_warning_symbol = 'S>'
|
||||
endif
|
||||
|
||||
if !has('signs')
|
||||
let g:syntastic_enable_signs = 0
|
||||
endif
|
||||
|
||||
if !exists("g:syntastic_enable_balloons")
|
||||
let g:syntastic_enable_balloons = 1
|
||||
endif
|
||||
if !has('balloon_eval')
|
||||
let g:syntastic_enable_balloons = 0
|
||||
endif
|
||||
|
||||
if !exists("g:syntastic_enable_highlighting")
|
||||
let g:syntastic_enable_highlighting = 1
|
||||
endif
|
||||
|
||||
" highlighting requires getmatches introduced in 7.1.040
|
||||
if v:version < 701 || (v:version == 701 && !has('patch040'))
|
||||
let g:syntastic_enable_highlighting = 0
|
||||
endif
|
||||
|
||||
if !exists("g:syntastic_echo_current_error")
|
||||
let g:syntastic_echo_current_error = 1
|
||||
endif
|
||||
|
||||
if !exists("g:syntastic_auto_loc_list")
|
||||
let g:syntastic_auto_loc_list = 2
|
||||
endif
|
||||
|
||||
if !exists("g:syntastic_auto_jump")
|
||||
let syntastic_auto_jump=0
|
||||
endif
|
||||
|
||||
if !exists("g:syntastic_quiet_warnings")
|
||||
let g:syntastic_quiet_warnings = 0
|
||||
endif
|
||||
|
||||
if !exists("g:syntastic_stl_format")
|
||||
let g:syntastic_stl_format = '[Syntax: line:%F (%t)]'
|
||||
endif
|
||||
|
||||
if !exists("g:syntastic_mode_map")
|
||||
let g:syntastic_mode_map = {}
|
||||
endif
|
||||
|
||||
if !has_key(g:syntastic_mode_map, "mode")
|
||||
let g:syntastic_mode_map['mode'] = 'active'
|
||||
endif
|
||||
|
||||
if !has_key(g:syntastic_mode_map, "active_filetypes")
|
||||
let g:syntastic_mode_map['active_filetypes'] = []
|
||||
endif
|
||||
|
||||
if !has_key(g:syntastic_mode_map, "passive_filetypes")
|
||||
let g:syntastic_mode_map['passive_filetypes'] = []
|
||||
endif
|
||||
|
||||
if !exists("g:syntastic_check_on_open")
|
||||
let g:syntastic_check_on_open = 0
|
||||
endif
|
||||
|
||||
if !exists("g:syntastic_loc_list_height")
|
||||
let g:syntastic_loc_list_height = 10
|
||||
endif
|
||||
|
||||
command! SyntasticToggleMode call s:ToggleMode()
|
||||
command! SyntasticCheck call s:UpdateErrors(0) <bar> redraw!
|
||||
command! Errors call s:ShowLocList()
|
||||
|
||||
highlight link SyntasticError SpellBad
|
||||
highlight link SyntasticWarning SpellCap
|
||||
|
||||
augroup syntastic
|
||||
if g:syntastic_echo_current_error
|
||||
autocmd cursormoved * call s:EchoCurrentError()
|
||||
endif
|
||||
|
||||
autocmd BufReadPost * if g:syntastic_check_on_open | call s:UpdateErrors(1) | endif
|
||||
autocmd BufWritePost * call s:UpdateErrors(1)
|
||||
|
||||
autocmd BufWinEnter * if empty(&bt) | call s:AutoToggleLocList() | endif
|
||||
autocmd BufWinLeave * if empty(&bt) | lclose | endif
|
||||
augroup END
|
||||
|
||||
|
||||
"refresh and redraw all the error info for this buf when saving or reading
|
||||
function! s:UpdateErrors(auto_invoked)
|
||||
if !empty(&buftype)
|
||||
return
|
||||
endif
|
||||
|
||||
if !a:auto_invoked || s:ModeMapAllowsAutoChecking()
|
||||
call s:CacheErrors()
|
||||
end
|
||||
|
||||
call setloclist(0, s:LocList())
|
||||
|
||||
if g:syntastic_enable_balloons
|
||||
call s:RefreshBalloons()
|
||||
endif
|
||||
|
||||
if g:syntastic_enable_signs
|
||||
call s:RefreshSigns()
|
||||
endif
|
||||
|
||||
if g:syntastic_enable_highlighting
|
||||
call s:HighlightErrors()
|
||||
endif
|
||||
|
||||
if g:syntastic_auto_jump && s:BufHasErrorsOrWarningsToDisplay()
|
||||
silent! ll
|
||||
endif
|
||||
|
||||
call s:AutoToggleLocList()
|
||||
endfunction
|
||||
|
||||
"automatically open/close the location list window depending on the users
|
||||
"config and buffer error state
|
||||
function! s:AutoToggleLocList()
|
||||
if s:BufHasErrorsOrWarningsToDisplay()
|
||||
if g:syntastic_auto_loc_list == 1
|
||||
call s:ShowLocList()
|
||||
endif
|
||||
else
|
||||
if g:syntastic_auto_loc_list > 0
|
||||
|
||||
"TODO: this will close the loc list window if one was opened by
|
||||
"something other than syntastic
|
||||
lclose
|
||||
endif
|
||||
endif
|
||||
endfunction
|
||||
|
||||
"lazy init the loc list for the current buffer
|
||||
function! s:LocList()
|
||||
if !exists("b:syntastic_loclist")
|
||||
let b:syntastic_loclist = []
|
||||
endif
|
||||
return b:syntastic_loclist
|
||||
endfunction
|
||||
|
||||
"clear the loc list for the buffer
|
||||
function! s:ClearCache()
|
||||
let b:syntastic_loclist = []
|
||||
unlet! b:syntastic_errors
|
||||
unlet! b:syntastic_warnings
|
||||
endfunction
|
||||
|
||||
"detect and cache all syntax errors in this buffer
|
||||
"
|
||||
"depends on a function called SyntaxCheckers_{&ft}_GetLocList() existing
|
||||
"elsewhere
|
||||
function! s:CacheErrors()
|
||||
call s:ClearCache()
|
||||
|
||||
if filereadable(expand("%"))
|
||||
|
||||
"sub - for _ in filetypes otherwise we cant name syntax checker
|
||||
"functions legally for filetypes like "gentoo-metadata"
|
||||
let fts = substitute(&ft, '-', '_', 'g')
|
||||
for ft in split(fts, '\.')
|
||||
if SyntasticCheckable(ft)
|
||||
let errors = SyntaxCheckers_{ft}_GetLocList()
|
||||
"keep only lines that effectively match an error/warning
|
||||
let errors = s:FilterLocList({'valid': 1}, errors)
|
||||
"make errors have type "E" by default
|
||||
call SyntasticAddToErrors(errors, {'type': 'E'})
|
||||
call extend(s:LocList(), errors)
|
||||
endif
|
||||
endfor
|
||||
endif
|
||||
endfunction
|
||||
|
||||
"toggle the g:syntastic_mode_map['mode']
|
||||
function! s:ToggleMode()
|
||||
if g:syntastic_mode_map['mode'] == "active"
|
||||
let g:syntastic_mode_map['mode'] = "passive"
|
||||
else
|
||||
let g:syntastic_mode_map['mode'] = "active"
|
||||
endif
|
||||
|
||||
call s:ClearCache()
|
||||
call s:UpdateErrors(1)
|
||||
|
||||
echo "Syntastic: " . g:syntastic_mode_map['mode'] . " mode enabled"
|
||||
endfunction
|
||||
|
||||
"check the current filetypes against g:syntastic_mode_map to determine whether
|
||||
"active mode syntax checking should be done
|
||||
function! s:ModeMapAllowsAutoChecking()
|
||||
let fts = split(&ft, '\.')
|
||||
|
||||
if g:syntastic_mode_map['mode'] == 'passive'
|
||||
"check at least one filetype is active
|
||||
let actives = g:syntastic_mode_map["active_filetypes"]
|
||||
return !empty(filter(fts, 'index(actives, v:val) != -1'))
|
||||
else
|
||||
"check no filetypes are passive
|
||||
let passives = g:syntastic_mode_map["passive_filetypes"]
|
||||
return empty(filter(fts, 'index(passives, v:val) != -1'))
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:BufHasErrorsOrWarningsToDisplay()
|
||||
if empty(s:LocList())
|
||||
return 0
|
||||
endif
|
||||
return len(s:Errors()) || !g:syntastic_quiet_warnings
|
||||
endfunction
|
||||
|
||||
function! s:Errors()
|
||||
if !exists("b:syntastic_errors")
|
||||
let b:syntastic_errors = s:FilterLocList({'type': "E"})
|
||||
endif
|
||||
return b:syntastic_errors
|
||||
endfunction
|
||||
|
||||
function! s:Warnings()
|
||||
if !exists("b:syntastic_warnings")
|
||||
let b:syntastic_warnings = s:FilterLocList({'type': "W"})
|
||||
endif
|
||||
return b:syntastic_warnings
|
||||
endfunction
|
||||
|
||||
"Filter a loc list (defaults to s:LocList()) by a:filters
|
||||
"e.g.
|
||||
" s:FilterLocList({'bufnr': 10, 'type': 'e'})
|
||||
"
|
||||
"would return all errors in s:LocList() for buffer 10.
|
||||
"
|
||||
"Note that all comparisons are done with ==?
|
||||
function! s:FilterLocList(filters, ...)
|
||||
let llist = a:0 ? a:1 : s:LocList()
|
||||
|
||||
let rv = []
|
||||
|
||||
for error in llist
|
||||
|
||||
let passes_filters = 1
|
||||
for key in keys(a:filters)
|
||||
if error[key] !=? a:filters[key]
|
||||
let passes_filters = 0
|
||||
break
|
||||
endif
|
||||
endfor
|
||||
|
||||
if passes_filters
|
||||
call add(rv, error)
|
||||
endif
|
||||
endfor
|
||||
return rv
|
||||
endfunction
|
||||
|
||||
if g:syntastic_enable_signs
|
||||
"define the signs used to display syntax and style errors/warns
|
||||
exe 'sign define SyntasticError text='.g:syntastic_error_symbol.' texthl=error'
|
||||
exe 'sign define SyntasticWarning text='.g:syntastic_warning_symbol.' texthl=todo'
|
||||
exe 'sign define SyntasticStyleError text='.g:syntastic_style_error_symbol.' texthl=error'
|
||||
exe 'sign define SyntasticStyleWarning text='.g:syntastic_style_warning_symbol.' texthl=todo'
|
||||
endif
|
||||
|
||||
"start counting sign ids at 5000, start here to hopefully avoid conflicting
|
||||
"with any other code that places signs (not sure if this precaution is
|
||||
"actually needed)
|
||||
let s:first_sign_id = 5000
|
||||
let s:next_sign_id = s:first_sign_id
|
||||
|
||||
"place signs by all syntax errs in the buffer
|
||||
function! s:SignErrors()
|
||||
if s:BufHasErrorsOrWarningsToDisplay()
|
||||
|
||||
let errors = s:FilterLocList({'bufnr': bufnr('')})
|
||||
for i in errors
|
||||
let sign_severity = 'Error'
|
||||
let sign_subtype = ''
|
||||
if has_key(i,'subtype')
|
||||
let sign_subtype = i['subtype']
|
||||
endif
|
||||
if i['type'] ==? 'w'
|
||||
let sign_severity = 'Warning'
|
||||
endif
|
||||
let sign_type = 'Syntastic' . sign_subtype . sign_severity
|
||||
|
||||
if !s:WarningMasksError(i, errors)
|
||||
exec "sign place ". s:next_sign_id ." line=". i['lnum'] ." name=". sign_type ." file=". expand("%:p")
|
||||
call add(s:BufSignIds(), s:next_sign_id)
|
||||
let s:next_sign_id += 1
|
||||
endif
|
||||
endfor
|
||||
endif
|
||||
endfunction
|
||||
|
||||
"return true if the given error item is a warning that, if signed, would
|
||||
"potentially mask an error if displayed at the same time
|
||||
function! s:WarningMasksError(error, llist)
|
||||
if a:error['type'] !=? 'w'
|
||||
return 0
|
||||
endif
|
||||
|
||||
return len(s:FilterLocList({ 'type': "E", 'lnum': a:error['lnum'] }, a:llist)) > 0
|
||||
endfunction
|
||||
|
||||
"remove the signs with the given ids from this buffer
|
||||
function! s:RemoveSigns(ids)
|
||||
for i in a:ids
|
||||
exec "sign unplace " . i
|
||||
call remove(s:BufSignIds(), index(s:BufSignIds(), i))
|
||||
endfor
|
||||
endfunction
|
||||
|
||||
"get all the ids of the SyntaxError signs in the buffer
|
||||
function! s:BufSignIds()
|
||||
if !exists("b:syntastic_sign_ids")
|
||||
let b:syntastic_sign_ids = []
|
||||
endif
|
||||
return b:syntastic_sign_ids
|
||||
endfunction
|
||||
|
||||
"update the error signs
|
||||
function! s:RefreshSigns()
|
||||
let old_signs = copy(s:BufSignIds())
|
||||
call s:SignErrors()
|
||||
call s:RemoveSigns(old_signs)
|
||||
let s:first_sign_id = s:next_sign_id
|
||||
endfunction
|
||||
|
||||
"display the cached errors for this buf in the location list
|
||||
function! s:ShowLocList()
|
||||
if !empty(s:LocList())
|
||||
call setloclist(0, s:LocList())
|
||||
let num = winnr()
|
||||
exec "lopen " . g:syntastic_loc_list_height
|
||||
if num != winnr()
|
||||
wincmd p
|
||||
endif
|
||||
endif
|
||||
endfunction
|
||||
|
||||
"highlight the current errors using matchadd()
|
||||
"
|
||||
"The function `Syntastic_{&ft}_GetHighlightRegex` is used to get the regex to
|
||||
"highlight errors that do not have a 'col' key (and hence cant be done
|
||||
"automatically). This function must take one arg (an error item) and return a
|
||||
"regex to match that item in the buffer.
|
||||
"
|
||||
"If the 'force_highlight_callback' key is set for an error item, then invoke
|
||||
"the callback even if it can be highlighted automatically.
|
||||
function! s:HighlightErrors()
|
||||
call s:ClearErrorHighlights()
|
||||
|
||||
let fts = substitute(&ft, '-', '_', 'g')
|
||||
for ft in split(fts, '\.')
|
||||
|
||||
for item in s:LocList()
|
||||
|
||||
let force_callback = has_key(item, 'force_highlight_callback') && item['force_highlight_callback']
|
||||
|
||||
let group = item['type'] == 'E' ? 'SyntasticError' : 'SyntasticWarning'
|
||||
if get( item, 'col' ) && !force_callback
|
||||
let lastcol = col([item['lnum'], '$'])
|
||||
let lcol = min([lastcol, item['col']])
|
||||
call matchadd(group, '\%'.item['lnum'].'l\%'.lcol.'c')
|
||||
else
|
||||
|
||||
if exists("*SyntaxCheckers_". ft ."_GetHighlightRegex")
|
||||
let term = SyntaxCheckers_{ft}_GetHighlightRegex(item)
|
||||
if len(term) > 0
|
||||
call matchadd(group, '\%' . item['lnum'] . 'l' . term)
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endfor
|
||||
endfor
|
||||
endfunction
|
||||
|
||||
"remove all error highlights from the window
|
||||
function! s:ClearErrorHighlights()
|
||||
for match in getmatches()
|
||||
if stridx(match['group'], 'Syntastic') == 0
|
||||
call matchdelete(match['id'])
|
||||
endif
|
||||
endfor
|
||||
endfunction
|
||||
|
||||
"set up error ballons for the current set of errors
|
||||
function! s:RefreshBalloons()
|
||||
let b:syntastic_balloons = {}
|
||||
if s:BufHasErrorsOrWarningsToDisplay()
|
||||
for i in s:LocList()
|
||||
let b:syntastic_balloons[i['lnum']] = i['text']
|
||||
endfor
|
||||
set beval bexpr=SyntasticErrorBalloonExpr()
|
||||
endif
|
||||
endfunction
|
||||
|
||||
"print as much of a:msg as possible without "Press Enter" prompt appearing
|
||||
function! s:WideMsg(msg)
|
||||
let old_ruler = &ruler
|
||||
let old_showcmd = &showcmd
|
||||
|
||||
"convert tabs to spaces so that the tabs count towards the window width
|
||||
"as the proper amount of characters
|
||||
let msg = substitute(a:msg, "\t", repeat(" ", &tabstop), "g")
|
||||
let msg = strpart(msg, 0, winwidth(0)-1)
|
||||
|
||||
"This is here because it is possible for some error messages to begin with
|
||||
"\n which will cause a "press enter" prompt. I have noticed this in the
|
||||
"javascript:jshint checker and have been unable to figure out why it
|
||||
"happens
|
||||
let msg = substitute(msg, "\n", "", "g")
|
||||
|
||||
set noruler noshowcmd
|
||||
redraw
|
||||
|
||||
echo msg
|
||||
|
||||
let &ruler=old_ruler
|
||||
let &showcmd=old_showcmd
|
||||
endfunction
|
||||
|
||||
"echo out the first error we find for the current line in the cmd window
|
||||
function! s:EchoCurrentError()
|
||||
"If we have an error or warning at the current line, show it
|
||||
let errors = s:FilterLocList({'lnum': line("."), "type": 'e'})
|
||||
let warnings = s:FilterLocList({'lnum': line("."), "type": 'w'})
|
||||
|
||||
let b:syntastic_echoing_error = len(errors) || len(warnings)
|
||||
if len(errors)
|
||||
return s:WideMsg(errors[0]['text'])
|
||||
endif
|
||||
if len(warnings)
|
||||
return s:WideMsg(warnings[0]['text'])
|
||||
endif
|
||||
|
||||
"Otherwise, clear the status line
|
||||
if b:syntastic_echoing_error
|
||||
echo
|
||||
let b:syntastic_echoing_error = 0
|
||||
endif
|
||||
endfunction
|
||||
|
||||
"load the chosen checker for the current filetype - useful for filetypes like
|
||||
"javascript that have more than one syntax checker
|
||||
function! s:LoadChecker(checker, ft)
|
||||
exec "runtime syntax_checkers/" . a:ft . "/" . a:checker . ".vim"
|
||||
endfunction
|
||||
|
||||
"the script changes &shellpipe and &shell to stop the screen flicking when
|
||||
"shelling out to syntax checkers. Not all OSs support the hacks though
|
||||
function! s:OSSupportsShellpipeHack()
|
||||
return !s:running_windows && (s:uname() !~ "FreeBSD") && (s:uname() !~ "OpenBSD")
|
||||
endfunction
|
||||
|
||||
function! s:IsRedrawRequiredAfterMake()
|
||||
return !s:running_windows && (s:uname() =~ "FreeBSD" || s:uname() =~ "OpenBSD")
|
||||
endfunction
|
||||
|
||||
function! s:uname()
|
||||
if !exists('s:uname')
|
||||
let s:uname = system('uname')
|
||||
endif
|
||||
return s:uname
|
||||
endfunction
|
||||
|
||||
"check if a syntax checker exists for the given filetype - and attempt to
|
||||
"load one
|
||||
function! SyntasticCheckable(ft)
|
||||
if !exists("g:loaded_" . a:ft . "_syntax_checker")
|
||||
exec "runtime syntax_checkers/" . a:ft . ".vim"
|
||||
endif
|
||||
|
||||
return exists("*SyntaxCheckers_". a:ft ."_GetLocList")
|
||||
endfunction
|
||||
|
||||
"the args must be arrays of the form [major, minor, macro]
|
||||
function SyntasticIsVersionAtLeast(installed, required)
|
||||
if a:installed[0] != a:required[0]
|
||||
return a:installed[0] > a:required[0]
|
||||
endif
|
||||
|
||||
if a:installed[1] != a:required[1]
|
||||
return a:installed[1] > a:required[1]
|
||||
endif
|
||||
|
||||
return a:installed[2] >= a:required[2]
|
||||
endfunction
|
||||
|
||||
"return a string representing the state of buffer according to
|
||||
"g:syntastic_stl_format
|
||||
"
|
||||
"return '' if no errors are cached for the buffer
|
||||
function! SyntasticStatuslineFlag()
|
||||
if s:BufHasErrorsOrWarningsToDisplay()
|
||||
let errors = s:Errors()
|
||||
let warnings = s:Warnings()
|
||||
|
||||
let num_errors = len(errors)
|
||||
let num_warnings = len(warnings)
|
||||
|
||||
let output = g:syntastic_stl_format
|
||||
|
||||
"hide stuff wrapped in %E(...) unless there are errors
|
||||
let output = substitute(output, '\C%E{\([^}]*\)}', num_errors ? '\1' : '' , 'g')
|
||||
|
||||
"hide stuff wrapped in %W(...) unless there are warnings
|
||||
let output = substitute(output, '\C%W{\([^}]*\)}', num_warnings ? '\1' : '' , 'g')
|
||||
|
||||
"hide stuff wrapped in %B(...) unless there are both errors and warnings
|
||||
let output = substitute(output, '\C%B{\([^}]*\)}', (num_warnings && num_errors) ? '\1' : '' , 'g')
|
||||
|
||||
"sub in the total errors/warnings/both
|
||||
let output = substitute(output, '\C%w', num_warnings, 'g')
|
||||
let output = substitute(output, '\C%e', num_errors, 'g')
|
||||
let output = substitute(output, '\C%t', len(s:LocList()), 'g')
|
||||
|
||||
"first error/warning line num
|
||||
let output = substitute(output, '\C%F', s:LocList()[0]['lnum'], 'g')
|
||||
|
||||
"first error line num
|
||||
let output = substitute(output, '\C%fe', num_errors ? errors[0]['lnum'] : '', 'g')
|
||||
|
||||
"first warning line num
|
||||
let output = substitute(output, '\C%fw', num_warnings ? warnings[0]['lnum'] : '', 'g')
|
||||
|
||||
return output
|
||||
else
|
||||
return ''
|
||||
endif
|
||||
endfunction
|
||||
|
||||
"A wrapper for the :lmake command. Sets up the make environment according to
|
||||
"the options given, runs make, resets the environment, returns the location
|
||||
"list
|
||||
"
|
||||
"a:options can contain the following keys:
|
||||
" 'makeprg'
|
||||
" 'errorformat'
|
||||
"
|
||||
"The corresponding options are set for the duration of the function call. They
|
||||
"are set with :let, so dont escape spaces.
|
||||
"
|
||||
"a:options may also contain:
|
||||
" 'defaults' - a dict containing default values for the returned errors
|
||||
" 'subtype' - all errors will be assigned the given subtype
|
||||
function! SyntasticMake(options)
|
||||
let old_loclist = getloclist(0)
|
||||
let old_makeprg = &l:makeprg
|
||||
let old_shellpipe = &shellpipe
|
||||
let old_shell = &shell
|
||||
let old_errorformat = &l:errorformat
|
||||
|
||||
if s:OSSupportsShellpipeHack()
|
||||
"this is a hack to stop the screen needing to be ':redraw'n when
|
||||
"when :lmake is run. Otherwise the screen flickers annoyingly
|
||||
let &shellpipe='&>'
|
||||
let &shell = '/bin/bash'
|
||||
endif
|
||||
|
||||
if has_key(a:options, 'makeprg')
|
||||
let &l:makeprg = a:options['makeprg']
|
||||
endif
|
||||
|
||||
if has_key(a:options, 'errorformat')
|
||||
let &l:errorformat = a:options['errorformat']
|
||||
endif
|
||||
|
||||
silent lmake!
|
||||
let errors = getloclist(0)
|
||||
|
||||
call setloclist(0, old_loclist)
|
||||
let &l:makeprg = old_makeprg
|
||||
let &l:errorformat = old_errorformat
|
||||
let &shellpipe=old_shellpipe
|
||||
let &shell=old_shell
|
||||
|
||||
if s:IsRedrawRequiredAfterMake()
|
||||
redraw!
|
||||
endif
|
||||
|
||||
if has_key(a:options, 'defaults')
|
||||
call SyntasticAddToErrors(errors, a:options['defaults'])
|
||||
endif
|
||||
|
||||
" Add subtype info if present.
|
||||
if has_key(a:options, 'subtype')
|
||||
call SyntasticAddToErrors(errors, {'subtype': a:options['subtype']})
|
||||
endif
|
||||
|
||||
return errors
|
||||
endfunction
|
||||
|
||||
"get the error balloon for the current mouse position
|
||||
function! SyntasticErrorBalloonExpr()
|
||||
if !exists('b:syntastic_balloons')
|
||||
return ''
|
||||
endif
|
||||
return get(b:syntastic_balloons, v:beval_lnum, '')
|
||||
endfunction
|
||||
|
||||
"take a list of errors and add default values to them from a:options
|
||||
function! SyntasticAddToErrors(errors, options)
|
||||
for i in range(0, len(a:errors)-1)
|
||||
for key in keys(a:options)
|
||||
if !has_key(a:errors[i], key) || empty(a:errors[i][key])
|
||||
let a:errors[i][key] = a:options[key]
|
||||
endif
|
||||
endfor
|
||||
endfor
|
||||
return a:errors
|
||||
endfunction
|
||||
|
||||
"take a list of syntax checkers for the current filetype and load the right
|
||||
"one based on the global settings and checker executable availabity
|
||||
"
|
||||
"a:checkers should be a list of syntax checker names. These names are assumed
|
||||
"to be the names of the vim syntax checker files that should be sourced, as
|
||||
"well as the names of the actual syntax checker executables. The checkers
|
||||
"should be listed in order of default preference.
|
||||
"
|
||||
"a:ft should be the filetype for the checkers being loaded
|
||||
"
|
||||
"if a option called 'g:syntastic_{a:ft}_checker' exists then attempt to
|
||||
"load the checker that it points to
|
||||
function! SyntasticLoadChecker(checkers, ft)
|
||||
let opt_name = "g:syntastic_" . a:ft . "_checker"
|
||||
|
||||
if exists(opt_name)
|
||||
let opt_val = {opt_name}
|
||||
if index(a:checkers, opt_val) != -1
|
||||
call s:LoadChecker(opt_val, a:ft)
|
||||
else
|
||||
echoerr &ft . " syntax not supported or not installed."
|
||||
endif
|
||||
else
|
||||
for checker in a:checkers
|
||||
if executable(checker)
|
||||
return s:LoadChecker(checker, a:ft)
|
||||
endif
|
||||
endfor
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" vim: set et sts=4 sw=4:
|
||||
@@ -1,132 +0,0 @@
|
||||
"============================================================================
|
||||
"File: ada.vim
|
||||
"Description: Syntax checking plugin for syntastic.vim
|
||||
"Maintainer: Alfredo Di Napoli <alfredo.dinapoli@gmail.com>
|
||||
"License: This program is free software. It comes without any warranty,
|
||||
" to the extent permitted by applicable law.
|
||||
"
|
||||
"============================================================================
|
||||
|
||||
" in order to also check header files add this to your .vimrc:
|
||||
" (this usually creates a .gch file in your source directory)
|
||||
"
|
||||
" let g:syntastic_ada_check_header = 1
|
||||
"
|
||||
" To disable the search of included header files after special
|
||||
" libraries like gtk and glib add this line to your .vimrc:
|
||||
"
|
||||
" let g:syntastic_ada_no_include_search = 1
|
||||
"
|
||||
" In order to add some custom include directories that should be added to the
|
||||
" gcc command line you can add those to the global variable
|
||||
" g:syntastic_ada_include_dirs. This list can be used like this:
|
||||
"
|
||||
" let g:syntastic_ada_include_dirs = [ 'includes', 'headers' ]
|
||||
"
|
||||
" To enable header files being re-checked on every file write add the
|
||||
" following line to your .vimrc. Otherwise the header files are checked only
|
||||
" one time on initially loading the file.
|
||||
" In order to force syntastic to refresh the header includes simply
|
||||
" unlet b:syntastic_ada_includes. Then the header files are being re-checked
|
||||
" on the next file write.
|
||||
"
|
||||
" let g:syntastic_ada_auto_refresh_includes = 1
|
||||
"
|
||||
" Alternatively you can set the buffer local variable b:syntastic_ada_cflags.
|
||||
" If this variable is set for the current buffer no search for additional
|
||||
" libraries is done. I.e. set the variable like this:
|
||||
"
|
||||
" let b:syntastic_ada_cflags = ' -I/usr/include/libsoup-2.4'
|
||||
"
|
||||
" Moreover it is possible to add additional compiler options to the syntax
|
||||
" checking execution via the variable 'g:syntastic_ada_compiler_options':
|
||||
"
|
||||
" let g:syntastic_ada_compiler_options = ' -std=c++0x'
|
||||
"
|
||||
" Additionally the setting 'g:syntastic_ada_config_file' allows you to define
|
||||
" a file that contains additional compiler arguments like include directories
|
||||
" or CFLAGS. The file is expected to contain one option per line. If none is
|
||||
" given the filename defaults to '.syntastic_ada_config':
|
||||
"
|
||||
" let g:syntastic_ada_config_file = '.config'
|
||||
"
|
||||
" Using the global variable 'g:syntastic_ada_remove_include_errors' you can
|
||||
" specify whether errors of files included via the
|
||||
" g:syntastic_ada_include_dirs' setting are removed from the result set:
|
||||
"
|
||||
" let g:syntastic_ada_remove_include_errors = 1
|
||||
|
||||
if exists('loaded_ada_syntax_checker')
|
||||
finish
|
||||
endif
|
||||
let loaded_ada_syntax_checker = 1
|
||||
|
||||
if !executable('gcc')
|
||||
finish
|
||||
endif
|
||||
|
||||
let s:save_cpo = &cpo
|
||||
set cpo&vim
|
||||
|
||||
if !exists('g:syntastic_ada_config_file')
|
||||
let g:syntastic_ada_config_file = '.syntastic_ada_config'
|
||||
endif
|
||||
|
||||
function! SyntaxCheckers_ada_GetLocList()
|
||||
let makeprg = 'gcc -c -fsyntax-only '
|
||||
let errorformat = '%-G%f:%s:,%f:%l:%c: %m,%f:%l: %m'
|
||||
|
||||
if exists('g:syntastic_ada_compiler_options')
|
||||
let makeprg .= g:syntastic_ada_compiler_options
|
||||
endif
|
||||
|
||||
let makeprg .= ' ' . shellescape(expand('%')) .
|
||||
\ ' ' . syntastic#c#GetIncludeDirs('ada')
|
||||
|
||||
if expand('%') =~? '\%(.h\|.hpp\|.hh\)$'
|
||||
if exists('g:syntastic_ada_check_header')
|
||||
let makeprg = 'g++ -c '.shellescape(expand('%')).
|
||||
\ ' ' . syntastic#c#GetIncludeDirs('ada')
|
||||
else
|
||||
return []
|
||||
endif
|
||||
endif
|
||||
|
||||
if !exists('b:syntastic_ada_cflags')
|
||||
if !exists('g:syntastic_ada_no_include_search') ||
|
||||
\ g:syntastic_ada_no_include_search != 1
|
||||
if exists('g:syntastic_ada_auto_refresh_includes') &&
|
||||
\ g:syntastic_ada_auto_refresh_includes != 0
|
||||
let makeprg .= syntastic#c#SearchHeaders()
|
||||
else
|
||||
if !exists('b:syntastic_ada_includes')
|
||||
let b:syntastic_ada_includes = syntastic#c#SearchHeaders()
|
||||
endif
|
||||
let makeprg .= b:syntastic_ada_includes
|
||||
endif
|
||||
endif
|
||||
else
|
||||
let makeprg .= b:syntastic_ada_cflags
|
||||
endif
|
||||
|
||||
" add optional config file parameters
|
||||
let makeprg .= ' ' . syntastic#c#ReadConfig(g:syntastic_ada_config_file)
|
||||
|
||||
" process makeprg
|
||||
let errors = SyntasticMake({ 'makeprg': makeprg,
|
||||
\ 'errorformat': errorformat })
|
||||
|
||||
" filter the processed errors if desired
|
||||
if exists('g:syntastic_ada_remove_include_errors') &&
|
||||
\ g:syntastic_ada_remove_include_errors != 0
|
||||
return filter(errors,
|
||||
\ 'has_key(v:val, "bufnr") && v:val["bufnr"]=='.bufnr(''))
|
||||
else
|
||||
return errors
|
||||
endif
|
||||
endfunction
|
||||
|
||||
let &cpo = s:save_cpo
|
||||
unlet s:save_cpo
|
||||
|
||||
" vim: set et sts=4 sw=4:
|
||||
@@ -1,43 +0,0 @@
|
||||
"==============================================================================
|
||||
" FileName: applescript.vim
|
||||
" Desc: Syntax checking plugin for syntastic.vim
|
||||
" Author: Zhao Cai
|
||||
" Email: caizhaoff@gmail.com
|
||||
" Version: 0.2.1
|
||||
" Date Created: Thu 09 Sep 2011 10:30:09 AM EST
|
||||
" Last Modified: Fri 09 Dec 2011 01:10:24 PM EST
|
||||
"
|
||||
" History: 0.1.0 - working, but it will run the script everytime to check
|
||||
" syntax. Should use osacompile but strangely it does not give
|
||||
" errors.
|
||||
"
|
||||
" 0.2.0 - switch to osacompile, it gives less errors compared
|
||||
" with osascript.
|
||||
"
|
||||
" 0.2.1 - remove g:syntastic_applescript_tempfile. use
|
||||
" tempname() instead.
|
||||
"
|
||||
" 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("loaded_applescript_syntax_checker")
|
||||
finish
|
||||
endif
|
||||
let loaded_applescript_syntax_checker = 1
|
||||
|
||||
"bail if the user doesnt have osacompile installed
|
||||
if !executable("osacompile")
|
||||
finish
|
||||
endif
|
||||
|
||||
function! SyntaxCheckers_applescript_GetLocList()
|
||||
let makeprg = 'osacompile -o ' . tempname() . '.scpt '. shellescape(expand('%'))
|
||||
let errorformat = '%f:%l:%m'
|
||||
|
||||
return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat })
|
||||
endfunction
|
||||
@@ -1,39 +0,0 @@
|
||||
"============================================================================
|
||||
"File: c.vim
|
||||
"Description: Syntax checking plugin for syntastic.vim
|
||||
"Maintainer: Martin Grenfell <martin.grenfell 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("loaded_c_syntax_checker")
|
||||
finish
|
||||
endif
|
||||
let loaded_c_syntax_checker = 1
|
||||
|
||||
if !exists('g:syntastic_c_checker')
|
||||
let g:syntastic_c_checker = "gcc"
|
||||
endif
|
||||
|
||||
if g:syntastic_c_checker == "gcc"
|
||||
if executable("gcc")
|
||||
runtime! syntax_checkers/c/gcc.vim
|
||||
endif
|
||||
elseif g:syntastic_c_checker == "checkpatch"
|
||||
if executable("checkpatch.pl") || executable("./scripts/checkpatch.pl")
|
||||
runtime! syntax_checkers/c/checkpatch.vim
|
||||
endif
|
||||
elseif g:syntastic_c_checker == "checkpatch-kernel-only"
|
||||
if executable("./scripts/checkpatch.pl")
|
||||
runtime! syntax_checkers/c/checkpatch.vim
|
||||
elseif executable("gcc")
|
||||
runtime! syntax_checkers/c/gcc.vim
|
||||
endif
|
||||
elseif g:syntastic_c_checker == "sparse"
|
||||
if executable("cgcc")
|
||||
runtime! syntax_checkers/c/sparse.vim
|
||||
endif
|
||||
endif
|
||||
@@ -1,35 +0,0 @@
|
||||
"============================================================================
|
||||
"File: checkpatch.vim
|
||||
"Description: Syntax checking plugin for syntastic.vim using checkpatch.pl
|
||||
"Maintainer: Daniel Walker <dwalker at fifo99 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("loaded_checkpatch_syntax_checker")
|
||||
finish
|
||||
endif
|
||||
let loaded_checkpatch_syntax_checker = 1
|
||||
|
||||
" Bail if the user doesn't have `checkpatch.pl` or ./scripts/checkpatch.pl installed.
|
||||
if executable("checkpatch.pl")
|
||||
let g:syntastic_c_checker_checkpatch_location = 'checkpatch.pl'
|
||||
elseif executable("./scripts/checkpatch.pl")
|
||||
let g:syntastic_c_checker_checkpatch_location = './scripts/checkpatch.pl'
|
||||
else
|
||||
finish
|
||||
endif
|
||||
|
||||
function! SyntaxCheckers_c_GetLocList()
|
||||
let makeprg = g:syntastic_c_checker_checkpatch_location
|
||||
let makeprg .= " --no-summary --no-tree --terse --file ".shellescape(expand('%'))
|
||||
|
||||
let errorformat = '%f:%l: %tARNING: %m,%f:%l: %tRROR: %m'
|
||||
|
||||
let loclist = SyntasticMake({ 'makeprg': makeprg,
|
||||
\ 'errorformat': errorformat,
|
||||
\ 'defaults': {'bufnr': bufnr("")} })
|
||||
return loclist
|
||||
endfunction
|
||||
@@ -1,159 +0,0 @@
|
||||
"============================================================================
|
||||
"File: c.vim
|
||||
"Description: Syntax checking plugin for syntastic.vim
|
||||
"Maintainer: Gregor Uhlenheuer <kongo2002 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.
|
||||
"
|
||||
"============================================================================
|
||||
|
||||
" In order to also check header files add this to your .vimrc:
|
||||
"
|
||||
" let g:syntastic_c_check_header = 1
|
||||
"
|
||||
" To disable the search of included header files after special
|
||||
" libraries like gtk and glib add this line to your .vimrc:
|
||||
"
|
||||
" let g:syntastic_c_no_include_search = 1
|
||||
"
|
||||
" To enable header files being re-checked on every file write add the
|
||||
" following line to your .vimrc. Otherwise the header files are checked only
|
||||
" one time on initially loading the file.
|
||||
" In order to force syntastic to refresh the header includes simply
|
||||
" unlet b:syntastic_c_includes. Then the header files are being re-checked on
|
||||
" the next file write.
|
||||
"
|
||||
" let g:syntastic_c_auto_refresh_includes = 1
|
||||
"
|
||||
" Alternatively you can set the buffer local variable b:syntastic_c_cflags.
|
||||
" If this variable is set for the current buffer no search for additional
|
||||
" libraries is done. I.e. set the variable like this:
|
||||
"
|
||||
" let b:syntastic_c_cflags = ' -I/usr/include/libsoup-2.4'
|
||||
"
|
||||
" In order to add some custom include directories that should be added to the
|
||||
" gcc command line you can add those to the global variable
|
||||
" g:syntastic_c_include_dirs. This list can be used like this:
|
||||
"
|
||||
" let g:syntastic_c_include_dirs = [ 'includes', 'headers' ]
|
||||
"
|
||||
" Moreover it is possible to add additional compiler options to the syntax
|
||||
" checking execution via the variable 'g:syntastic_c_compiler_options':
|
||||
"
|
||||
" let g:syntastic_c_compiler_options = ' -ansi'
|
||||
"
|
||||
" Additionally the setting 'g:syntastic_c_config_file' allows you to define a
|
||||
" file that contains additional compiler arguments like include directories or
|
||||
" CFLAGS. The file is expected to contain one option per line. If none is
|
||||
" given the filename defaults to '.syntastic_c_config':
|
||||
"
|
||||
" let g:syntastic_c_config_file = '.config'
|
||||
"
|
||||
" Using the global variable 'g:syntastic_c_remove_include_errors' you can
|
||||
" specify whether errors of files included via the g:syntastic_c_include_dirs'
|
||||
" setting are removed from the result set:
|
||||
"
|
||||
" let g:syntastic_c_remove_include_errors = 1
|
||||
"
|
||||
" Use the variable 'g:syntastic_c_errorformat' to override the default error
|
||||
" format:
|
||||
"
|
||||
" let g:syntastic_c_errorformat = '%f:%l:%c: %trror: %m'
|
||||
|
||||
if exists('loaded_gcc_syntax_checker')
|
||||
finish
|
||||
endif
|
||||
let loaded_gcc_syntax_checker = 1
|
||||
|
||||
if !executable('gcc')
|
||||
finish
|
||||
endif
|
||||
|
||||
let s:save_cpo = &cpo
|
||||
set cpo&vim
|
||||
|
||||
if !exists('g:syntastic_c_compiler_options')
|
||||
let g:syntastic_c_compiler_options = '-std=gnu99'
|
||||
endif
|
||||
|
||||
if !exists('g:syntastic_c_config_file')
|
||||
let g:syntastic_c_config_file = '.syntastic_c_config'
|
||||
endif
|
||||
|
||||
function! SyntaxCheckers_c_GetLocList()
|
||||
let makeprg = 'gcc -fsyntax-only '
|
||||
let errorformat = '%-G%f:%s:,%-G%f:%l: %#error: %#(Each undeclared '.
|
||||
\ 'identifier is reported only%.%#,%-G%f:%l: %#error: %#for '.
|
||||
\ 'each function it appears%.%#,%-GIn file included%.%#,'.
|
||||
\ '%-G %#from %f:%l\,,%f:%l:%c: %trror: %m,%f:%l:%c: '.
|
||||
\ '%tarning: %m,%f:%l:%c: %m,%f:%l: %trror: %m,'.
|
||||
\ '%f:%l: %tarning: %m,%f:%l: %m'
|
||||
|
||||
if exists('g:syntastic_c_errorformat')
|
||||
let errorformat = g:syntastic_c_errorformat
|
||||
endif
|
||||
|
||||
" add optional user-defined compiler options
|
||||
let makeprg .= g:syntastic_c_compiler_options
|
||||
|
||||
let makeprg .= ' '.shellescape(expand('%')).
|
||||
\ ' '.syntastic#c#GetIncludeDirs('c')
|
||||
|
||||
" determine whether to parse header files as well
|
||||
if expand('%') =~? '.h$'
|
||||
if exists('g:syntastic_c_check_header')
|
||||
let makeprg = 'gcc -c '.shellescape(expand('%')) .
|
||||
\ ' ' . g:syntastic_c_compiler_options .
|
||||
\ ' ' . syntastic#c#GetNullDevice() .
|
||||
\ ' ' . syntastic#c#GetIncludeDirs('c')
|
||||
else
|
||||
return []
|
||||
endif
|
||||
endif
|
||||
|
||||
" check if the user manually set some cflags
|
||||
if !exists('b:syntastic_c_cflags')
|
||||
" check whether to search for include files at all
|
||||
if !exists('g:syntastic_c_no_include_search') ||
|
||||
\ g:syntastic_c_no_include_search != 1
|
||||
" refresh the include file search if desired
|
||||
if exists('g:syntastic_c_auto_refresh_includes') &&
|
||||
\ g:syntastic_c_auto_refresh_includes != 0
|
||||
let makeprg .= syntastic#c#SearchHeaders()
|
||||
else
|
||||
" search for header includes if not cached already
|
||||
if !exists('b:syntastic_c_includes')
|
||||
let b:syntastic_c_includes = syntastic#c#SearchHeaders()
|
||||
endif
|
||||
let makeprg .= b:syntastic_c_includes
|
||||
endif
|
||||
endif
|
||||
else
|
||||
" use the user-defined cflags
|
||||
let makeprg .= b:syntastic_c_cflags
|
||||
endif
|
||||
|
||||
" add optional config file parameters
|
||||
let makeprg .= ' '.syntastic#c#ReadConfig(g:syntastic_c_config_file)
|
||||
|
||||
" process makeprg
|
||||
let errors = SyntasticMake({ 'makeprg': makeprg,
|
||||
\ 'errorformat': errorformat })
|
||||
|
||||
" filter the processed errors if desired
|
||||
if exists('g:syntastic_c_remove_include_errors') &&
|
||||
\ g:syntastic_c_remove_include_errors != 0
|
||||
return filter(errors,
|
||||
\ 'has_key(v:val, "bufnr") && v:val["bufnr"]=='.bufnr(''))
|
||||
else
|
||||
return errors
|
||||
endif
|
||||
endfunction
|
||||
|
||||
let &cpo = s:save_cpo
|
||||
unlet s:save_cpo
|
||||
|
||||
" vim: set et sts=4 sw=4:
|
||||
@@ -1,34 +0,0 @@
|
||||
"============================================================================
|
||||
"File: sparse.vim
|
||||
"Description: Syntax checking plugin for syntastic.vim using sparse.pl
|
||||
"Maintainer: Daniel Walker <dwalker at fifo99 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("loaded_sparse_syntax_checker")
|
||||
finish
|
||||
endif
|
||||
let loaded_sparse_syntax_checker = 1
|
||||
|
||||
" Bail if the user doesn't have `sparse.pl` or ./scripts/checkpatch.pl installed.
|
||||
if !executable("sparse")
|
||||
finish
|
||||
endif
|
||||
|
||||
function! SyntaxCheckers_c_GetLocList()
|
||||
let makeprg = "sparse "
|
||||
|
||||
let makeprg .= ' '.syntastic#c#ReadConfig(g:syntastic_sparse_config_file).' '
|
||||
|
||||
let makeprg .= shellescape(expand('%'))
|
||||
|
||||
let errorformat = '%f:%l:%c: %trror: %m,%f:%l:%c: %tarning: %m,'
|
||||
|
||||
let loclist = SyntasticMake({ 'makeprg': makeprg,
|
||||
\ 'errorformat': errorformat,
|
||||
\ 'defaults': {'bufnr': bufnr("")} })
|
||||
return loclist
|
||||
endfunction
|
||||
@@ -1,27 +0,0 @@
|
||||
"============================================================================
|
||||
"File: co.vim
|
||||
"Description: Syntax checking plugin for syntastic.vim
|
||||
"Maintainer: Andrew Kelley <superjoe30@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("loaded_co_syntax_checker")
|
||||
finish
|
||||
endif
|
||||
let loaded_co_syntax_checker = 1
|
||||
|
||||
"bail if the user doesnt have coco installed
|
||||
if !executable("coco")
|
||||
finish
|
||||
endif
|
||||
|
||||
function! SyntaxCheckers_co_GetLocList()
|
||||
let makeprg = 'coco -c -o /tmp '.shellescape(expand('%'))
|
||||
let errorformat = '%EFailed at: %f,%ZSyntax%trror: %m on line %l,%EFailed at: %f,%Z%trror: Parse error on line %l: %m'
|
||||
|
||||
return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat })
|
||||
endfunction
|
||||
@@ -1,49 +0,0 @@
|
||||
"============================================================================
|
||||
"File: coffee.vim
|
||||
"Description: Syntax checking plugin for syntastic.vim
|
||||
"Maintainer: Lincoln Stoll <l@lds.li>
|
||||
"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("loaded_coffee_syntax_checker")
|
||||
finish
|
||||
endif
|
||||
let loaded_coffee_syntax_checker = 1
|
||||
|
||||
"bail if the user doesnt have coffee installed
|
||||
if !executable("coffee")
|
||||
finish
|
||||
endif
|
||||
|
||||
if !exists('g:syntastic_coffee_lint_options')
|
||||
let g:syntastic_coffee_lint_options = ""
|
||||
endif
|
||||
|
||||
|
||||
function! SyntaxCheckers_coffee_GetLocList()
|
||||
let makeprg = 'coffee -c -l -o /tmp '.shellescape(expand('%'))
|
||||
let errorformat = 'Syntax%trror: In %f\, %m on line %l,%EError: In %f\, Parse error on line %l: %m,%EError: In %f\, %m on line %l,%W%f(%l): lint warning: %m,%-Z%p^,%W%f(%l): warning: %m,%-Z%p^,%E%f(%l): SyntaxError: %m,%-Z%p^,%-G%.%#'
|
||||
|
||||
let coffee_results = SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat })
|
||||
|
||||
if !empty(coffee_results)
|
||||
return coffee_results
|
||||
endif
|
||||
|
||||
if executable("coffeelint")
|
||||
return s:GetCoffeeLintErrors()
|
||||
endif
|
||||
|
||||
return []
|
||||
endfunction
|
||||
|
||||
function s:GetCoffeeLintErrors()
|
||||
let coffeelint = 'coffeelint --csv '.g:syntastic_coffee_lint_options.' '.shellescape(expand('%'))
|
||||
let lint_results = SyntasticMake({ 'makeprg': coffeelint, 'errorformat': '%f\,%l\,%trror\,%m', 'subtype': 'Style' })
|
||||
|
||||
return lint_results
|
||||
endfunction
|
||||
@@ -1,156 +0,0 @@
|
||||
"============================================================================
|
||||
"File: cpp.vim
|
||||
"Description: Syntax checking plugin for syntastic.vim
|
||||
"Maintainer: Gregor Uhlenheuer <kongo2002 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.
|
||||
"
|
||||
"============================================================================
|
||||
|
||||
" in order to also check header files add this to your .vimrc:
|
||||
"
|
||||
" let g:syntastic_cpp_check_header = 1
|
||||
"
|
||||
" To disable the search of included header files after special
|
||||
" libraries like gtk and glib add this line to your .vimrc:
|
||||
"
|
||||
" let g:syntastic_cpp_no_include_search = 1
|
||||
"
|
||||
" In order to add some custom include directories that should be added to the
|
||||
" gcc command line you can add those to the global variable
|
||||
" g:syntastic_cpp_include_dirs. This list can be used like this:
|
||||
"
|
||||
" let g:syntastic_cpp_include_dirs = [ 'includes', 'headers' ]
|
||||
"
|
||||
" To enable header files being re-checked on every file write add the
|
||||
" following line to your .vimrc. Otherwise the header files are checked only
|
||||
" one time on initially loading the file.
|
||||
" In order to force syntastic to refresh the header includes simply
|
||||
" unlet b:syntastic_cpp_includes. Then the header files are being re-checked
|
||||
" on the next file write.
|
||||
"
|
||||
" let g:syntastic_cpp_auto_refresh_includes = 1
|
||||
"
|
||||
" Alternatively you can set the buffer local variable b:syntastic_cpp_cflags.
|
||||
" If this variable is set for the current buffer no search for additional
|
||||
" libraries is done. I.e. set the variable like this:
|
||||
"
|
||||
" let b:syntastic_cpp_cflags = ' -I/usr/include/libsoup-2.4'
|
||||
"
|
||||
" Moreover it is possible to add additional compiler options to the syntax
|
||||
" checking execution via the variable 'g:syntastic_cpp_compiler_options':
|
||||
"
|
||||
" let g:syntastic_cpp_compiler_options = ' -std=c++0x'
|
||||
"
|
||||
" Additionally the setting 'g:syntastic_cpp_config_file' allows you to define
|
||||
" a file that contains additional compiler arguments like include directories
|
||||
" or CFLAGS. The file is expected to contain one option per line. If none is
|
||||
" given the filename defaults to '.syntastic_cpp_config':
|
||||
"
|
||||
" let g:syntastic_cpp_config_file = '.config'
|
||||
"
|
||||
" Using the global variable 'g:syntastic_cpp_remove_include_errors' you can
|
||||
" specify whether errors of files included via the
|
||||
" g:syntastic_cpp_include_dirs' setting are removed from the result set:
|
||||
"
|
||||
" let g:syntastic_cpp_remove_include_errors = 1
|
||||
"
|
||||
" Use the variable 'g:syntastic_cpp_errorformat' to override the default error
|
||||
" format:
|
||||
"
|
||||
" let g:syntastic_cpp_errorformat = '%f:%l:%c: %trror: %m'
|
||||
"
|
||||
" Set your compiler executable with e.g. (defaults to g++)
|
||||
"
|
||||
" let g:syntastic_cpp_compiler = 'clang++'
|
||||
|
||||
if exists('loaded_cpp_syntax_checker')
|
||||
finish
|
||||
endif
|
||||
let loaded_cpp_syntax_checker = 1
|
||||
|
||||
if !exists('g:syntastic_cpp_compiler')
|
||||
let g:syntastic_cpp_compiler = 'g++'
|
||||
endif
|
||||
|
||||
if !exists('g:syntastic_cpp_compiler_options')
|
||||
let g:syntastic_cpp_compiler_options = ''
|
||||
endif
|
||||
|
||||
if !executable(g:syntastic_cpp_compiler)
|
||||
finish
|
||||
endif
|
||||
|
||||
let s:save_cpo = &cpo
|
||||
set cpo&vim
|
||||
|
||||
if !exists('g:syntastic_cpp_config_file')
|
||||
let g:syntastic_cpp_config_file = '.syntastic_cpp_config'
|
||||
endif
|
||||
|
||||
function! SyntaxCheckers_cpp_GetLocList()
|
||||
let makeprg = g:syntastic_cpp_compiler . ' -fsyntax-only ' .
|
||||
\ g:syntastic_cpp_compiler_options
|
||||
let errorformat = '%-G%f:%s:,%f:%l:%c: %trror: %m,%f:%l:%c: %tarning: '.
|
||||
\ '%m,%f:%l:%c: %m,%f:%l: %trror: %m,%f:%l: %tarning: %m,'.
|
||||
\ '%f:%l: %m'
|
||||
|
||||
if exists('g:syntastic_cpp_errorformat')
|
||||
let errorformat = g:syntastic_cpp_errorformat
|
||||
endif
|
||||
|
||||
let makeprg .= ' ' . shellescape(expand('%')) .
|
||||
\ ' ' . syntastic#c#GetIncludeDirs('cpp')
|
||||
|
||||
if expand('%') =~? '\%(.h\|.hpp\|.hh\)$'
|
||||
if exists('g:syntastic_cpp_check_header')
|
||||
let makeprg = g:syntastic_cpp_compiler.' -c '.shellescape(expand('%')) .
|
||||
\ ' ' . g:syntastic_cpp_compiler_options .
|
||||
\ ' ' . syntastic#c#GetNullDevice() .
|
||||
\ ' ' . syntastic#c#GetIncludeDirs('cpp')
|
||||
else
|
||||
return []
|
||||
endif
|
||||
endif
|
||||
|
||||
if !exists('b:syntastic_cpp_cflags')
|
||||
if !exists('g:syntastic_cpp_no_include_search') ||
|
||||
\ g:syntastic_cpp_no_include_search != 1
|
||||
if exists('g:syntastic_cpp_auto_refresh_includes') &&
|
||||
\ g:syntastic_cpp_auto_refresh_includes != 0
|
||||
let makeprg .= syntastic#c#SearchHeaders()
|
||||
else
|
||||
if !exists('b:syntastic_cpp_includes')
|
||||
let b:syntastic_cpp_includes = syntastic#c#SearchHeaders()
|
||||
endif
|
||||
let makeprg .= b:syntastic_cpp_includes
|
||||
endif
|
||||
endif
|
||||
else
|
||||
let makeprg .= b:syntastic_cpp_cflags
|
||||
endif
|
||||
|
||||
" add optional config file parameters
|
||||
let makeprg .= ' ' . syntastic#c#ReadConfig(g:syntastic_cpp_config_file)
|
||||
|
||||
" process makeprg
|
||||
let errors = SyntasticMake({ 'makeprg': makeprg,
|
||||
\ 'errorformat': errorformat })
|
||||
|
||||
" filter the processed errors if desired
|
||||
if exists('g:syntastic_cpp_remove_include_errors') &&
|
||||
\ g:syntastic_cpp_remove_include_errors != 0
|
||||
return filter(errors,
|
||||
\ 'has_key(v:val, "bufnr") && v:val["bufnr"]=='.bufnr(''))
|
||||
else
|
||||
return errors
|
||||
endif
|
||||
endfunction
|
||||
|
||||
let &cpo = s:save_cpo
|
||||
unlet s:save_cpo
|
||||
|
||||
" vim: set et sts=4 sw=4:
|
||||
@@ -1,30 +0,0 @@
|
||||
"============================================================================
|
||||
"File: cs.vim
|
||||
"Description: Syntax checking plugin for syntastic.vim
|
||||
"Maintainer: Daniel Walker <dwalker@fifo99.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('loaded_cs_syntax_checker')
|
||||
finish
|
||||
endif
|
||||
let loaded_cs_syntax_checker = 1
|
||||
|
||||
if !executable('mcs')
|
||||
finish
|
||||
endif
|
||||
|
||||
function! SyntaxCheckers_cs_GetLocList()
|
||||
let makeprg = "mcs --parse ".shellescape(expand('%'))
|
||||
let errorformat = '%f(%l\,%c): %trror %m'
|
||||
let loclist = SyntasticMake({ 'makeprg': makeprg,
|
||||
\ 'errorformat': errorformat,
|
||||
\ 'defaults': {'bufnr': bufnr("")} })
|
||||
return loclist
|
||||
endfunction
|
||||
|
||||
@@ -1,42 +0,0 @@
|
||||
"============================================================================
|
||||
"File: css.vim
|
||||
"Description: Syntax checking plugin for syntastic.vim using `csslint` CLI tool (http://csslint.net).
|
||||
"Maintainer: Ory Band <oryband 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.
|
||||
"============================================================================
|
||||
"
|
||||
" Specify additional options to csslint with this option. e.g. to disable
|
||||
" warnings:
|
||||
"
|
||||
" let g:syntastic_csslint_options = "--warnings=none"
|
||||
|
||||
if exists("loaded_css_syntax_checker")
|
||||
finish
|
||||
endif
|
||||
let loaded_css_syntax_checker = 1
|
||||
|
||||
if !exists('g:syntastic_csslint_options')
|
||||
let g:syntastic_csslint_options = ""
|
||||
endif
|
||||
|
||||
" Bail if the user doesn't have `csslint` installed.
|
||||
if !executable("csslint")
|
||||
finish
|
||||
endif
|
||||
|
||||
function! SyntaxCheckers_css_GetLocList()
|
||||
let makeprg = 'csslint --format=compact '.g:syntastic_csslint_options.' '.
|
||||
\ shellescape(expand('%'))
|
||||
|
||||
" Print CSS Lint's error/warning messages from compact format. Ignores blank lines.
|
||||
let errorformat = '%-G,%-G%f: lint free!,%f: line %l\, col %c\, %trror - %m,%f: line %l\, col %c\, %tarning - %m,%f: line %l\, col %c\, %m,'
|
||||
|
||||
return SyntasticMake({ 'makeprg': makeprg,
|
||||
\ 'errorformat': errorformat,
|
||||
\ 'defaults': {'bufnr': bufnr("")} })
|
||||
|
||||
endfunction
|
||||
@@ -1,27 +0,0 @@
|
||||
"============================================================================
|
||||
"File: cucumber.vim
|
||||
"Description: Syntax checking plugin for syntastic.vim
|
||||
"Maintainer: Martin Grenfell <martin.grenfell 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("loaded_cucumber_syntax_checker")
|
||||
finish
|
||||
endif
|
||||
let loaded_cucumber_syntax_checker = 1
|
||||
|
||||
"bail if the user doesnt have cucumber installed
|
||||
if !executable("cucumber")
|
||||
finish
|
||||
endif
|
||||
|
||||
function! SyntaxCheckers_cucumber_GetLocList()
|
||||
let makeprg = 'cucumber --dry-run --quiet --strict --format pretty '.shellescape(expand('%'))
|
||||
let errorformat = '%f:%l:%c:%m,%W %.%# (%m),%-Z%f:%l:%.%#,%-G%.%#'
|
||||
|
||||
return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat })
|
||||
endfunction
|
||||
@@ -1,49 +0,0 @@
|
||||
"============================================================================
|
||||
"File: cuda.vim
|
||||
"Description: Syntax checking plugin for syntastic.vim
|
||||
"
|
||||
"Author: Hannes Schulz <schulz at ais dot uni-bonn dot de>
|
||||
"
|
||||
"============================================================================
|
||||
|
||||
" in order to also check header files add this to your .vimrc:
|
||||
" (this creates an empty .syntastic_dummy.cu file in your source directory)
|
||||
"
|
||||
" let g:syntastic_cuda_check_header = 1
|
||||
|
||||
" By default, nvcc and thus syntastic, defaults to the most basic architecture.
|
||||
" This can produce false errors if the developer intends to compile for newer
|
||||
" hardware and use newer features, eg. double precision numbers. To pass a
|
||||
" specific target arch to nvcc, e.g. add the following to your .vimrc:
|
||||
"
|
||||
" let g:syntastic_cuda_arch = "sm_20"
|
||||
|
||||
if exists('loaded_cuda_syntax_checker')
|
||||
finish
|
||||
endif
|
||||
let loaded_cuda_syntax_checker = 1
|
||||
|
||||
if !executable('nvcc')
|
||||
finish
|
||||
endif
|
||||
|
||||
function! SyntaxCheckers_cuda_GetLocList()
|
||||
if exists('g:syntastic_cuda_arch')
|
||||
let arch_flag = '-arch='.g:syntastic_cuda_arch
|
||||
else
|
||||
let arch_flag = ''
|
||||
endif
|
||||
let makeprg = 'nvcc '.arch_flag.' --cuda -O0 -I . -Xcompiler -fsyntax-only '.shellescape(expand('%')).' -o /dev/null'
|
||||
"let errorformat = '%-G%f:%s:,%f:%l:%c: %m,%f:%l: %m'
|
||||
let errorformat = '%*[^"]"%f"%*\D%l: %m,"%f"%*\D%l: %m,%-G%f:%l: (Each undeclared identifier is reported only once,%-G%f:%l: for each function it appears in.),%f:%l:%c:%m,%f(%l):%m,%f:%l:%m,"%f"\, line %l%*\D%c%*[^ ] %m,%D%*\a[%*\d]: Entering directory `%f'',%X%*\a[%*\d]: Leaving directory `%f'',%D%*\a: Entering directory `%f'',%X%*\a: Leaving directory `%f'',%DMaking %*\a in %f,%f|%l| %m'
|
||||
|
||||
if expand('%') =~? '\%(.h\|.hpp\|.cuh\)$'
|
||||
if exists('g:syntastic_cuda_check_header')
|
||||
let makeprg = 'echo > .syntastic_dummy.cu ; nvcc '.arch_flag.' --cuda -O0 -I . .syntastic_dummy.cu -Xcompiler -fsyntax-only -include '.shellescape(expand('%')).' -o /dev/null'
|
||||
else
|
||||
return []
|
||||
endif
|
||||
endif
|
||||
|
||||
return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat })
|
||||
endfunction
|
||||
@@ -1,140 +0,0 @@
|
||||
"============================================================================
|
||||
"File: d.vim
|
||||
"Description: Syntax checking plugin for syntastic.vim
|
||||
"Maintainer: Alfredo Di Napoli <alfredo dot dinapoli at gmail dot com>
|
||||
"License: Based on the original work of Gregor Uhlenheuer and his
|
||||
" cpp.vim checker so credits are dued.
|
||||
" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
" EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||
" OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
" NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
" HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
" WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
" FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
" OTHER DEALINGS IN THE SOFTWARE.
|
||||
"
|
||||
"============================================================================
|
||||
|
||||
" in order to also check header files add this to your .vimrc:
|
||||
" (this usually creates a .gch file in your source directory)
|
||||
"
|
||||
" let g:syntastic_d_check_header = 1
|
||||
"
|
||||
" To disable the search of included header files after special
|
||||
" libraries like gtk and glib add this line to your .vimrc:
|
||||
"
|
||||
" let g:syntastic_d_no_include_search = 1
|
||||
"
|
||||
" In order to add some custom include directories that should be added to the
|
||||
" gcc command line you can add those to the global variable
|
||||
" g:syntastic_d_include_dirs. This list can be used like this:
|
||||
"
|
||||
" let g:syntastic_d_include_dirs = [ 'includes', 'headers' ]
|
||||
"
|
||||
" To enable header files being re-checked on every file write add the
|
||||
" following line to your .vimrc. Otherwise the header files are checked only
|
||||
" one time on initially loading the file.
|
||||
" In order to force syntastic to refresh the header includes simply
|
||||
" unlet b:syntastic_d_includes. Then the header files are being re-checked
|
||||
" on the next file write.
|
||||
"
|
||||
" let g:syntastic_d_auto_refresh_includes = 1
|
||||
"
|
||||
" Alternatively you can set the buffer local variable b:syntastic_d_cflags.
|
||||
" If this variable is set for the current buffer no search for additional
|
||||
" libraries is done. I.e. set the variable like this:
|
||||
"
|
||||
" let b:syntastic_d_cflags = ' -I/usr/include/libsoup-2.4'
|
||||
"
|
||||
" Moreover it is possible to add additional compiler options to the syntax
|
||||
" checking execution via the variable 'g:syntastic_d_compiler_options':
|
||||
"
|
||||
" let g:syntastic_d_compiler_options = ' -std=c++0x'
|
||||
"
|
||||
" Additionally the setting 'g:syntastic_d_config_file' allows you to define
|
||||
" a file that contains additional compiler arguments like include directories
|
||||
" or CFLAGS. The file is expected to contain one option per line. If none is
|
||||
" given the filename defaults to '.syntastic_d_config':
|
||||
"
|
||||
" let g:syntastic_d_config_file = '.config'
|
||||
"
|
||||
" Using the global variable 'g:syntastic_d_remove_include_errors' you can
|
||||
" specify whether errors of files included via the
|
||||
" g:syntastic_d_include_dirs' setting are removed from the result set:
|
||||
"
|
||||
" let g:syntastic_d_remove_include_errors = 1
|
||||
|
||||
if exists('loaded_d_syntax_checker')
|
||||
finish
|
||||
endif
|
||||
let loaded_d_syntax_checker = 1
|
||||
|
||||
if !executable('dmd')
|
||||
finish
|
||||
endif
|
||||
|
||||
let s:save_cpo = &cpo
|
||||
set cpo&vim
|
||||
|
||||
if !exists('g:syntastic_d_config_file')
|
||||
let g:syntastic_d_config_file = '.syntastic_d_config'
|
||||
endif
|
||||
|
||||
function! SyntaxCheckers_d_GetLocList()
|
||||
let makeprg = 'dmd -of/dev/null -c '
|
||||
let errorformat = '%-G%f:%s:,%f(%l): %m,%f:%l: %m'
|
||||
|
||||
if exists('g:syntastic_d_compiler_options')
|
||||
let makeprg .= g:syntastic_d_compiler_options
|
||||
endif
|
||||
|
||||
let makeprg .= ' ' . shellescape(expand('%')) .
|
||||
\ ' ' . syntastic#c#GetIncludeDirs('d')
|
||||
|
||||
if expand('%') =~? '\%(.di\)$'
|
||||
if exists('g:syntastic_d_check_header')
|
||||
let makeprg = 'dmd -c '.shellescape(expand('%')).
|
||||
\ ' ' . syntastic#c#GetIncludeDirs('d')
|
||||
else
|
||||
return []
|
||||
endif
|
||||
endif
|
||||
|
||||
if !exists('b:syntastic_d_cflags')
|
||||
if !exists('g:syntastic_d_no_include_search') ||
|
||||
\ g:syntastic_d_no_include_search != 1
|
||||
if exists('g:syntastic_d_auto_refresh_includes') &&
|
||||
\ g:syntastic_d_auto_refresh_includes != 0
|
||||
let makeprg .= syntastic#c#SearchHeaders()
|
||||
else
|
||||
if !exists('b:syntastic_d_includes')
|
||||
let b:syntastic_d_includes = syntastic#c#SearchHeaders()
|
||||
endif
|
||||
let makeprg .= b:syntastic_d_includes
|
||||
endif
|
||||
endif
|
||||
else
|
||||
let makeprg .= b:syntastic_d_cflags
|
||||
endif
|
||||
|
||||
" add optional config file parameters
|
||||
let makeprg .= ' ' . syntastic#c#ReadConfig(g:syntastic_d_config_file)
|
||||
|
||||
" process makeprg
|
||||
let errors = SyntasticMake({ 'makeprg': makeprg,
|
||||
\ 'errorformat': errorformat })
|
||||
|
||||
" filter the processed errors if desired
|
||||
if exists('g:syntastic_d_remove_include_errors') &&
|
||||
\ g:syntastic_d_remove_include_errors != 0
|
||||
return filter(errors,
|
||||
\ 'has_key(v:val, "bufnr") && v:val["bufnr"]=='.bufnr(''))
|
||||
else
|
||||
return errors
|
||||
endif
|
||||
endfunction
|
||||
|
||||
let &cpo = s:save_cpo
|
||||
unlet s:save_cpo
|
||||
|
||||
" vim: set et sts=4 sw=4:
|
||||
@@ -1,29 +0,0 @@
|
||||
"============================================================================
|
||||
"File: docbk.vim
|
||||
"Description: Syntax checking plugin for syntastic.vim
|
||||
"Maintainer: Martin Grenfell <martin.grenfell 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("loaded_docbk_syntax_checker")
|
||||
finish
|
||||
endif
|
||||
let loaded_docbk_syntax_checker = 1
|
||||
|
||||
"bail if the user doesnt have tidy or grep installed
|
||||
if !executable("xmllint")
|
||||
finish
|
||||
endif
|
||||
|
||||
function! SyntaxCheckers_docbk_GetLocList()
|
||||
|
||||
let makeprg="xmllint --xinclude --noout --postvalid ".shellescape(expand(%:p))
|
||||
let errorformat='%E%f:%l: parser error : %m,%W%f:%l: parser warning : %m,%E%f:%l:%.%# validity error : %m,%W%f:%l:%.%# validity warning : %m,%-Z%p^,%-C%.%#,%-G%.%#'
|
||||
let loclist = SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat })
|
||||
|
||||
return loclist
|
||||
endfunction
|
||||
@@ -1,176 +0,0 @@
|
||||
#!/usr/bin/perl -w
|
||||
|
||||
# vimparse.pl - Reformats the error messages of the Perl interpreter for use
|
||||
# with the quickfix mode of Vim
|
||||
#
|
||||
# Copyright (<28>) 2001 by J<>rg Ziefle <joerg.ziefle@gmx.de>
|
||||
# Copyright (c) 2012 Eric Harmon <http://eharmon.net>
|
||||
# You may use and distribute this software under the same terms as Perl itself.
|
||||
#
|
||||
# Usage: put one of the two configurations below in your ~/.vimrc (without the
|
||||
# description and '# ') and enjoy (be sure to adjust the paths to vimparse.pl
|
||||
# before):
|
||||
#
|
||||
# Program is run interactively with 'perl -w':
|
||||
#
|
||||
# set makeprg=$HOME/bin/vimparse.pl\ %\ $*
|
||||
# set errorformat=%t:%f:%l:%m
|
||||
#
|
||||
# Program is only compiled with 'perl -wc':
|
||||
#
|
||||
# set makeprg=$HOME/bin/vimparse.pl\ -c\ %\ $*
|
||||
# set errorformat=%t:%f:%l:%m
|
||||
#
|
||||
# Usage:
|
||||
# vimparse.pl [-c] [-w] [-f <errorfile>] <programfile> [programargs]
|
||||
#
|
||||
# -c compile only, don't run (perl -wc)
|
||||
# -w output warnings as warnings instead of errors (slightly slower)
|
||||
# -f write errors to <errorfile>
|
||||
#
|
||||
# Example usages:
|
||||
# * From the command line:
|
||||
# vimparse.pl program.pl
|
||||
#
|
||||
# vimparse.pl -c -w -f errorfile program.pl
|
||||
# Then run vim -q errorfile to edit the errors with Vim.
|
||||
# This uses the custom errorformat: %t:%f:%l:%m.
|
||||
#
|
||||
# * From Vim:
|
||||
# Edit in Vim (and save, if you don't have autowrite on), then
|
||||
# type ':mak' or ':mak args' (args being the program arguments)
|
||||
# to error check.
|
||||
#
|
||||
# Version history:
|
||||
# 0.3 (05/31/2012):
|
||||
# * Added support for the seperate display of warnings
|
||||
# * Switched output format to %t:%f:%l:%m to support error levels
|
||||
# 0.2 (04/12/2001):
|
||||
# * First public version (sent to Bram)
|
||||
# * -c command line option for compiling only
|
||||
# * grammatical fix: 'There was 1 error.'
|
||||
# * bug fix for multiple arguments
|
||||
# * more error checks
|
||||
# * documentation (top of file, &usage)
|
||||
# * minor code clean ups
|
||||
# 0.1 (02/02/2001):
|
||||
# * Initial version
|
||||
# * Basic functionality
|
||||
#
|
||||
# Todo:
|
||||
# * test on more systems
|
||||
# * use portable way to determine the location of perl ('use Config')
|
||||
# * include option that shows perldiag messages for each error
|
||||
# * allow to pass in program by STDIN
|
||||
# * more intuitive behaviour if no error is found (show message)
|
||||
#
|
||||
# Tested under SunOS 5.7 with Perl 5.6.0. Let me know if it's not working for
|
||||
# you.
|
||||
|
||||
use strict;
|
||||
use Getopt::Std;
|
||||
|
||||
use vars qw/$opt_I $opt_c $opt_w $opt_f $opt_h/; # needed for Getopt in combination with use strict 'vars'
|
||||
|
||||
use constant VERSION => 0.2;
|
||||
|
||||
getopts('cwf:hI:');
|
||||
|
||||
&usage if $opt_h; # not necessarily needed, but good for further extension
|
||||
|
||||
if (defined $opt_f) {
|
||||
|
||||
open FILE, "> $opt_f" or do {
|
||||
warn "Couldn't open $opt_f: $!. Using STDOUT instead.\n";
|
||||
undef $opt_f;
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
my $handle = (defined $opt_f ? \*FILE : \*STDOUT);
|
||||
|
||||
(my $file = shift) or &usage; # display usage if no filename is supplied
|
||||
my $args = (@ARGV ? ' ' . join ' ', @ARGV : '');
|
||||
|
||||
my $libs = join ' ', map {"-I$_"} split ',', $opt_I;
|
||||
my @error_lines = `perl $libs @{[defined $opt_c ? '-c ' : '' ]} @{[defined $opt_w ? '-X ' : '-w ']} "$file$args" 2>&1`;
|
||||
|
||||
my @lines = map { "E:$_" } @error_lines;
|
||||
|
||||
my @warn_lines;
|
||||
if(defined($opt_w)) {
|
||||
@warn_lines = `perl $libs @{[defined $opt_c ? '-c ' : '' ]} -w "$file$args" 2>&1`;
|
||||
}
|
||||
|
||||
# Any new errors must be warnings
|
||||
foreach my $line (@warn_lines) {
|
||||
if(!grep { $_ eq $line } @error_lines) {
|
||||
push(@lines, "W:$line");
|
||||
}
|
||||
}
|
||||
|
||||
my $errors = 0;
|
||||
foreach my $line (@lines) {
|
||||
|
||||
chomp($line);
|
||||
my ($file, $lineno, $message, $rest, $severity);
|
||||
|
||||
if ($line =~ /^([EW]):(.*)\sat\s(.*)\sline\s(\d+)(.*)$/) {
|
||||
($severity, $message, $file, $lineno, $rest) = ($1, $2, $3, $4, $5);
|
||||
$errors++;
|
||||
$message .= $rest if ($rest =~ s/^,//);
|
||||
print $handle "$severity:$file:$lineno:$message\n";
|
||||
|
||||
} else { next };
|
||||
|
||||
}
|
||||
|
||||
if (defined $opt_f) {
|
||||
|
||||
my $msg;
|
||||
if ($errors == 1) {
|
||||
|
||||
$msg = "There was 1 error.\n";
|
||||
|
||||
} else {
|
||||
|
||||
$msg = "There were $errors errors.\n";
|
||||
|
||||
};
|
||||
|
||||
print STDOUT $msg;
|
||||
close FILE;
|
||||
unlink $opt_f unless $errors;
|
||||
|
||||
};
|
||||
|
||||
sub usage {
|
||||
|
||||
(local $0 = $0) =~ s/^.*\/([^\/]+)$/$1/; # remove path from name of program
|
||||
print<<EOT;
|
||||
Usage:
|
||||
$0 [-c] [-w] [-f <errorfile>] <programfile> [programargs]
|
||||
|
||||
-c compile only, don't run (executes 'perl -c')
|
||||
-w output warnings as warnings instead of errors (slightly slower)
|
||||
-f write errors to <errorfile>
|
||||
-I specify \@INC/#include directory <perl_lib_path>
|
||||
|
||||
Examples:
|
||||
* At the command line:
|
||||
$0 program.pl
|
||||
Displays output on STDOUT.
|
||||
|
||||
$0 -c -w -f errorfile program.pl
|
||||
Then run 'vim -q errorfile' to edit the errors with Vim.
|
||||
This uses the custom errorformat: %t:%f:%l:%m.
|
||||
|
||||
* In Vim:
|
||||
Edit in Vim (and save, if you don't have autowrite on), then
|
||||
type ':mak' or ':mak args' (args being the program arguments)
|
||||
to error check.
|
||||
EOT
|
||||
|
||||
exit 0;
|
||||
|
||||
};
|
||||
@@ -1,30 +0,0 @@
|
||||
"============================================================================
|
||||
"File: elixir.vim
|
||||
"Description: Syntax checking plugin for syntastic.vim
|
||||
"Maintainer: Richard Ramsden <rramsden 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("loaded_elixir_syntax_checker")
|
||||
finish
|
||||
endif
|
||||
let loaded_elixir_syntax_checker = 1
|
||||
|
||||
if !executable('elixir')
|
||||
finish
|
||||
endif
|
||||
|
||||
function! SyntaxCheckers_elixir_GetLocList()
|
||||
let makeprg = 'elixir ' . shellescape(expand('%'))
|
||||
let errorformat = '** %*[^\ ] %f:%l: %m'
|
||||
|
||||
let elixir_results = SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat })
|
||||
|
||||
if !empty(elixir_results)
|
||||
return elixir_results
|
||||
endif
|
||||
endfunction
|
||||
@@ -1,46 +0,0 @@
|
||||
"============================================================================
|
||||
"File: erlang.vim
|
||||
"Description: Syntax checking plugin for syntastic.vim
|
||||
"Maintainer: Pawel Salata <rockplayer.pl 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("loaded_erlang_syntax_checker")
|
||||
finish
|
||||
endif
|
||||
let loaded_erlang_syntax_checker = 1
|
||||
|
||||
"bail if the user doesnt have escript installed
|
||||
if !executable("escript")
|
||||
finish
|
||||
endif
|
||||
|
||||
let s:check_file = expand('<sfile>:p:h') . '/erlang_check_file.erl'
|
||||
if !exists("g:syntastic_erlc_include_path")
|
||||
let g:syntastic_erlc_include_path=""
|
||||
endif
|
||||
|
||||
|
||||
function! SyntaxCheckers_erlang_GetLocList()
|
||||
let extension = expand('%:e')
|
||||
if match(extension, 'hrl') >= 0
|
||||
return []
|
||||
endif
|
||||
let shebang = getbufline(bufnr('%'), 1)[0]
|
||||
if len(shebang) > 0
|
||||
if match(shebang, 'escript') >= 0
|
||||
let makeprg = 'escript -s '.shellescape(expand('%:p'))
|
||||
else
|
||||
let makeprg = s:check_file . ' '. shellescape(expand('%:p')).' '.g:syntastic_erlc_include_path
|
||||
endif
|
||||
else
|
||||
let makeprg = s:check_file . ' ' . shellescape(expand('%:p')).' '.g:syntastic_erlc_include_path
|
||||
endif
|
||||
let errorformat = '%f:%l:\ %tarning:\ %m,%E%f:%l:\ %m'
|
||||
|
||||
return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat })
|
||||
endfunction
|
||||
@@ -1,18 +0,0 @@
|
||||
#!/usr/bin/env escript
|
||||
-export([main/1]).
|
||||
|
||||
main([FileName| LibDirs=[_|_]]) ->
|
||||
code:add_pathsa(LibDirs),
|
||||
main([FileName]);
|
||||
|
||||
main([FileName]) ->
|
||||
compile:file(FileName, [warn_obsolete_guard,
|
||||
warn_unused_import,
|
||||
warn_shadow_vars,
|
||||
warn_export_vars,
|
||||
strong_validation,
|
||||
report,
|
||||
{i, filename:dirname(FileName) ++ "/../include"},
|
||||
{i, filename:dirname(FileName) ++ "/../deps"},
|
||||
{i, filename:dirname(FileName) ++ "/../../../deps"}
|
||||
]).
|
||||
@@ -1,40 +0,0 @@
|
||||
"============================================================================
|
||||
"File: eruby.vim
|
||||
"Description: Syntax checking plugin for syntastic.vim
|
||||
"Maintainer: Martin Grenfell <martin.grenfell 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("loaded_eruby_syntax_checker")
|
||||
finish
|
||||
endif
|
||||
let loaded_eruby_syntax_checker = 1
|
||||
|
||||
if !exists("g:syntastic_ruby_exec")
|
||||
let g:syntastic_ruby_exec = "ruby"
|
||||
endif
|
||||
|
||||
"bail if the user doesnt have ruby installed
|
||||
if !executable(expand(g:syntastic_ruby_exec))
|
||||
finish
|
||||
endif
|
||||
|
||||
function! SyntaxCheckers_eruby_GetLocList()
|
||||
let ruby_exec=expand(g:syntastic_ruby_exec)
|
||||
if !has('win32')
|
||||
let ruby_exec='RUBYOPT= ' . ruby_exec
|
||||
endif
|
||||
|
||||
"gsub fixes issue #7 rails has it's own eruby syntax
|
||||
let makeprg=ruby_exec . ' -rerb -e "puts ERB.new(File.read(''' .
|
||||
\ (expand("%")) .
|
||||
\ ''').gsub(''<\%='',''<\%''), nil, ''-'').src" \| ' . ruby_exec . ' -c'
|
||||
|
||||
let errorformat='%-GSyntax OK,%E-:%l: syntax error\, %m,%Z%p^,%W-:%l: warning: %m,%Z%p^,%-C%.%#'
|
||||
|
||||
return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat})
|
||||
endfunction
|
||||
@@ -1,44 +0,0 @@
|
||||
"============================================================================
|
||||
"File: fortran.vim
|
||||
"Description: Syntax checking plugin for syntastic.vim
|
||||
"Maintainer: Karl Yngve Lervåg <karl.yngve@lervag.net>
|
||||
"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.
|
||||
"Note: This syntax checker uses gfortran with the option -fsyntax-only
|
||||
" to check for errors and warnings. Additional flags may be
|
||||
" supplied through both local and global variables,
|
||||
" b:syntastic_fortran_flags,
|
||||
" g:syntastic_fortran_flags.
|
||||
" This is particularly useful when the source requires module files
|
||||
" in order to compile (that is when it needs modules defined in
|
||||
" separate files).
|
||||
"
|
||||
"============================================================================
|
||||
|
||||
if exists("loaded_fortran_syntax_checker")
|
||||
finish
|
||||
endif
|
||||
let loaded_fortran_syntax_checker = 1
|
||||
|
||||
"bail if the user doesnt have fortran installed
|
||||
if !executable("gfortran")
|
||||
finish
|
||||
endif
|
||||
|
||||
if !exists('g:syntastic_fortran_flags')
|
||||
let g:syntastic_fortran_flags = ''
|
||||
endif
|
||||
|
||||
function! SyntaxCheckers_fortran_GetLocList()
|
||||
let makeprg = 'gfortran -fsyntax-only'
|
||||
let makeprg .= g:syntastic_fortran_flags
|
||||
if exists('b:syntastic_fortran_flags')
|
||||
let makeprg .= b:syntastic_fortran_flags
|
||||
endif
|
||||
let makeprg .= ' ' . shellescape(expand('%'))
|
||||
let errorformat = '%-C %#,%-C %#%.%#,%A%f:%l.%c:,%Z%m,%G%.%#'
|
||||
return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat })
|
||||
endfunction
|
||||
@@ -1,37 +0,0 @@
|
||||
"============================================================================
|
||||
"File: gentoo-metadata.vim
|
||||
"Description: Syntax checking plugin for Gentoo's metadata.xml files
|
||||
"Maintainer: James Rowe <jnrowe 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.
|
||||
"
|
||||
"============================================================================
|
||||
|
||||
" The DTDs required to validate metadata.xml files are available in
|
||||
" $PORTDIR/metadata/dtd, and these local files can be used to significantly
|
||||
" speed up validation. You can create a catalog file with:
|
||||
"
|
||||
" xmlcatalog --create --add rewriteURI http://www.gentoo.org/dtd/ \
|
||||
" ${PORTDIR:-/usr/portage}/metadata/dtd/ /etc/xml/gentoo
|
||||
"
|
||||
" See xmlcatalog(1) and http://www.xmlsoft.org/catalog.html for more
|
||||
" information.
|
||||
|
||||
if exists("loaded_gentoo_metadata_syntax_checker")
|
||||
finish
|
||||
endif
|
||||
let loaded_gentoo_metadata_syntax_checker = 1
|
||||
|
||||
"bail if the user doesn't have xmllint installed
|
||||
if !executable("xmllint")
|
||||
finish
|
||||
endif
|
||||
|
||||
runtime syntax_checkers/xml.vim
|
||||
|
||||
function! SyntaxCheckers_gentoo_metadata_GetLocList()
|
||||
return SyntaxCheckers_xml_GetLocList()
|
||||
endfunction
|
||||
@@ -1,22 +0,0 @@
|
||||
"============================================================================
|
||||
"File: go.vim
|
||||
"Description: Loads a go syntax checker from the go directory
|
||||
"Maintainer: Martin Grenfell <martin.grenfell 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.
|
||||
"
|
||||
" Use g:syntastic_go_checker option to specify which go executable
|
||||
" should be used (see below for a list of supported checkers).
|
||||
" If g:syntastic_go_checker is not set, just use the first syntax
|
||||
" checker that we find installed.
|
||||
"============================================================================
|
||||
if exists("loaded_go_syntax_checker")
|
||||
finish
|
||||
endif
|
||||
let loaded_go_syntax_checker = 1
|
||||
|
||||
let s:supported_checkers = ["go", "gofmt"]
|
||||
call SyntasticLoadChecker(s:supported_checkers, 'go')
|
||||
@@ -1,51 +0,0 @@
|
||||
"============================================================================
|
||||
"File: go.vim
|
||||
"Description: Check go syntax using 'gofmt -l' followed by 'go [build|test]'
|
||||
"Maintainer: Kamil Kisiel <kamil@kamilkisiel.net>
|
||||
"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.
|
||||
"
|
||||
" This syntax checker does not reformat your source code.
|
||||
" Use a BufWritePre autocommand to that end:
|
||||
" autocmd FileType go autocmd BufWritePre <buffer> Fmt
|
||||
"============================================================================
|
||||
function! SyntaxCheckers_go_GetLocList()
|
||||
" Check with gofmt first, since `go build` and `go test` might not report
|
||||
" syntax errors in the current file if another file with syntax error is
|
||||
" compiled first.
|
||||
let makeprg = 'gofmt -l % 1>/dev/null'
|
||||
let errorformat = '%f:%l:%c: %m,%-G%.%#'
|
||||
let errors = SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat, 'defaults': {'type': 'e'} })
|
||||
|
||||
if !empty(errors)
|
||||
return errors
|
||||
endif
|
||||
|
||||
" Test files, i.e. files with a name ending in `_test.go`, are not
|
||||
" compiled by `go build`, therefore `go test` must be called for those.
|
||||
if match(expand('%'), '_test.go$') == -1
|
||||
let makeprg = 'go build -o /dev/null'
|
||||
else
|
||||
let makeprg = 'go test -c -o /dev/null'
|
||||
endif
|
||||
let errorformat = '%f:%l:%c:%m,%f:%l%m,%-G#%.%#'
|
||||
|
||||
" The go compiler needs to either be run with an import path as an
|
||||
" argument or directly from the package directory. Since figuring out
|
||||
" the poper import path is fickle, just pushd/popd to the package.
|
||||
let popd = getcwd()
|
||||
let pushd = expand('%:p:h')
|
||||
"
|
||||
" pushd
|
||||
exec 'lcd ' . fnameescape(pushd)
|
||||
|
||||
let errors = SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat })
|
||||
|
||||
" popd
|
||||
exec 'lcd ' . fnameescape(popd)
|
||||
|
||||
return errors
|
||||
endfunction
|
||||
@@ -1,19 +0,0 @@
|
||||
"============================================================================
|
||||
"File: gofmt.vim
|
||||
"Description: Check go syntax using 'gofmt -l'
|
||||
"Maintainer: Brandon Thomson <bt@brandonthomson.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.
|
||||
"
|
||||
" This syntax checker does not reformat your source code.
|
||||
" Use a BufWritePre autocommand to that end:
|
||||
" autocmd FileType go autocmd BufWritePre <buffer> Fmt
|
||||
"============================================================================
|
||||
function! SyntaxCheckers_go_GetLocList()
|
||||
let makeprg = 'gofmt -l % 1>/dev/null'
|
||||
let errorformat = '%f:%l:%c: %m,%-G%.%#'
|
||||
return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat, 'defaults': {'type': 'e'} })
|
||||
endfunction
|
||||
@@ -1,26 +0,0 @@
|
||||
"============================================================================
|
||||
"File: haml.vim
|
||||
"Description: Syntax checking plugin for syntastic.vim
|
||||
"Maintainer: Martin Grenfell <martin.grenfell 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("loaded_haml_syntax_checker")
|
||||
finish
|
||||
endif
|
||||
let loaded_haml_syntax_checker = 1
|
||||
|
||||
"bail if the user doesnt have the haml binary installed
|
||||
if !executable("haml")
|
||||
finish
|
||||
endif
|
||||
|
||||
function! SyntaxCheckers_haml_GetLocList()
|
||||
let makeprg = "haml -c " . shellescape(expand("%"))
|
||||
let errorformat = 'Haml error on line %l: %m,Syntax error on line %l: %m,%-G%.%#'
|
||||
return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat })
|
||||
endfunction
|
||||
@@ -1,31 +0,0 @@
|
||||
"============================================================================
|
||||
"File: haskell.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_haskell_syntax_checker')
|
||||
finish
|
||||
endif
|
||||
let g:loaded_haskell_syntax_checker = 1
|
||||
|
||||
if !exists('g:syntastic_haskell_checker')
|
||||
if executable('hdevtools')
|
||||
runtime! syntax_checkers/haskell/hdevtools.vim
|
||||
elseif executable('ghc-mod')
|
||||
runtime! syntax_checkers/haskell/ghc-mod.vim
|
||||
endif
|
||||
elseif g:syntastic_haskell_checker == 'hdevtools'
|
||||
if executable('hdevtools')
|
||||
runtime! syntax_checkers/haskell/hdevtools.vim
|
||||
endif
|
||||
elseif g:syntastic_haskell_checker == 'ghc-mod'
|
||||
if executable('ghc-mod')
|
||||
runtime! syntax_checkers/haskell/ghc-mod.vim
|
||||
endif
|
||||
endif
|
||||
@@ -1,33 +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:syntastic_haskell_checker_args')
|
||||
let g:syntastic_haskell_checker_args = '--hlintOpt="--language=XmlSyntax"'
|
||||
endif
|
||||
|
||||
function! SyntaxCheckers_haskell_GetLocList()
|
||||
let ghcmod = 'ghc-mod ' . g:syntastic_haskell_checker_args
|
||||
let makeprg =
|
||||
\ "{ ".
|
||||
\ ghcmod . " check ". shellescape(expand('%')) . "; " .
|
||||
\ ghcmod . " lint " . shellescape(expand('%')) . ";" .
|
||||
\ " }"
|
||||
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 })
|
||||
endfunction
|
||||
|
||||
function! SyntaxCheckers_lhaskell_GetLocList()
|
||||
return SyntaxCheckers_haskell_GetLocList()
|
||||
endfunction
|
||||
@@ -1,30 +0,0 @@
|
||||
"============================================================================
|
||||
"File: hdevtools.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.
|
||||
"
|
||||
"============================================================================
|
||||
|
||||
function! SyntaxCheckers_haskell_GetLocList()
|
||||
let makeprg = 'hdevtools check ' . get(g:, 'hdevtools_options', '') .
|
||||
\ ' ' . shellescape(expand('%'))
|
||||
|
||||
let errorformat= '\%-Z\ %#,'.
|
||||
\ '%W%f:%l:%c:\ Warning:\ %m,'.
|
||||
\ '%E%f:%l:%c:\ %m,'.
|
||||
\ '%E%>%f:%l:%c:,'.
|
||||
\ '%+C\ \ %#%m,'.
|
||||
\ '%W%>%f:%l:%c:,'.
|
||||
\ '%+C\ \ %#%tarning:\ %m,'
|
||||
|
||||
return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat })
|
||||
endfunction
|
||||
|
||||
function! SyntaxCheckers_lhaskell_GetLocList()
|
||||
return SyntaxCheckers_haskell_GetLocList()
|
||||
endfunction
|
||||
@@ -1,55 +0,0 @@
|
||||
"============================================================================
|
||||
"File: haxe.vim
|
||||
"Description: Syntax checking plugin for syntastic.vim
|
||||
"Maintainer: David Bernard <david.bernard.31 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("loaded_haxe_syntax_checker")
|
||||
finish
|
||||
endif
|
||||
let loaded_haxe_syntax_checker = 1
|
||||
|
||||
"bail if the user doesn't have haxe installed
|
||||
if !executable("haxe")
|
||||
finish
|
||||
endif
|
||||
|
||||
" s:FindInParent
|
||||
" find the file argument and returns the path to it.
|
||||
" Starting with the current working dir, it walks up the parent folders
|
||||
" until it finds the file, or it hits the stop dir.
|
||||
" If it doesn't find it, it returns "Nothing"
|
||||
function! s:FindInParent(fln,flsrt,flstp)
|
||||
let here = a:flsrt
|
||||
while ( strlen( here) > 0 )
|
||||
let p = split(globpath(here, a:fln), '\n')
|
||||
if len(p) > 0
|
||||
return ['ok', here, fnamemodify(p[0], ':p:t')]
|
||||
endif
|
||||
let fr = match(here, '/[^/]*$')
|
||||
if fr == -1
|
||||
break
|
||||
endif
|
||||
let here = strpart(here, 0, fr)
|
||||
if here == a:flstp
|
||||
break
|
||||
endif
|
||||
endwhile
|
||||
return ['fail', '', '']
|
||||
endfunction
|
||||
|
||||
function! SyntaxCheckers_haxe_GetLocList()
|
||||
let [success, hxmldir, hxmlname] = s:FindInParent('*.hxml', expand('%:p:h'), '/')
|
||||
if success == 'ok'
|
||||
let makeprg = 'cd ' . hxmldir . '; haxe ' . hxmlname
|
||||
let errorformat = '%E%f:%l: characters %c-%*[0-9] : %m'
|
||||
return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat })
|
||||
else
|
||||
return SyntasticMake({})
|
||||
endif
|
||||
endfunction
|
||||
@@ -1,29 +0,0 @@
|
||||
"============================================================================
|
||||
"File: html.vim
|
||||
"Description: Syntax checking plugin for syntastic.vim
|
||||
"Maintainer: Martin Grenfell <martin.grenfell 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("loaded_html_syntax_checker")
|
||||
finish
|
||||
endif
|
||||
let loaded_html_syntax_checker = 1
|
||||
|
||||
if !exists('g:syntastic_html_checker')
|
||||
let g:syntastic_html_checker = "tidy"
|
||||
endif
|
||||
|
||||
if g:syntastic_html_checker == "tidy"
|
||||
if executable("tidy") && executable("grep")
|
||||
runtime! syntax_checkers/html/tidy.vim
|
||||
endif
|
||||
elseif g:syntastic_html_checker == "w3"
|
||||
if executable("curl") && executable("sed")
|
||||
runtime! syntax_checkers/html/w3.vim
|
||||
endif
|
||||
endif
|
||||
@@ -1,74 +0,0 @@
|
||||
"============================================================================
|
||||
"File: tidy.vim
|
||||
"Description: Syntax checking plugin for syntastic.vim
|
||||
"Maintainer: Martin Grenfell <martin.grenfell 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.
|
||||
"
|
||||
"============================================================================
|
||||
" TODO: join this with xhtml.vim for DRY's sake?
|
||||
function! s:TidyEncOptByFenc()
|
||||
let tidy_opts = {
|
||||
\'utf-8' : '-utf8',
|
||||
\'ascii' : '-ascii',
|
||||
\'latin1' : '-latin1',
|
||||
\'iso-2022-jp' : '-iso-2022',
|
||||
\'cp1252' : '-win1252',
|
||||
\'macroman' : '-mac',
|
||||
\'utf-16le' : '-utf16le',
|
||||
\'utf-16' : '-utf16',
|
||||
\'big5' : '-big5',
|
||||
\'sjis' : '-shiftjis',
|
||||
\'cp850' : '-ibm858',
|
||||
\}
|
||||
return get(tidy_opts, &fileencoding, '-utf8')
|
||||
endfunction
|
||||
|
||||
let s:ignore_html_errors = [
|
||||
\ "<table> lacks \"summary\" attribute",
|
||||
\ "not approved by W3C",
|
||||
\ "attribute \"placeholder\"",
|
||||
\ "<meta> proprietary attribute \"charset\"",
|
||||
\ "<meta> lacks \"content\" attribute",
|
||||
\ "inserting \"type\" attribute",
|
||||
\ "proprietary attribute \"data-"
|
||||
\]
|
||||
|
||||
function! s:ValidateError(text)
|
||||
let valid = 0
|
||||
for i in s:ignore_html_errors
|
||||
if stridx(a:text, i) != -1
|
||||
let valid = 1
|
||||
break
|
||||
endif
|
||||
endfor
|
||||
return valid
|
||||
endfunction
|
||||
|
||||
function! SyntaxCheckers_html_GetLocList()
|
||||
let encopt = s:TidyEncOptByFenc()
|
||||
let makeprg="tidy ".encopt." --new-blocklevel-tags ".shellescape('section, article, aside, hgroup, header, footer, nav, figure, figcaption')." --new-inline-tags ".shellescape('video, audio, source, embed, mark, progress, meter, time, ruby, rt, rp, canvas, command, details, datalist')." --new-empty-tags ".shellescape('wbr, keygen')." -e ".shellescape(expand('%'))." 2>&1"
|
||||
let errorformat='%Wline %l column %c - Warning: %m,%Eline %l column %c - Error: %m,%-G%.%#,%-G%.%#'
|
||||
let loclist = SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat })
|
||||
|
||||
" process loclist since we need to add some info and filter out valid HTML5
|
||||
" from the errors
|
||||
let n = len(loclist) - 1
|
||||
let bufnum = bufnr("")
|
||||
while n >= 0
|
||||
let i = loclist[n]
|
||||
" filter out valid HTML5
|
||||
if s:ValidateError(i['text']) == 1
|
||||
unlet loclist[n]
|
||||
else
|
||||
"the file name isnt in the output so stick in the buf num manually
|
||||
let i['bufnr'] = bufnum
|
||||
endif
|
||||
let n -= 1
|
||||
endwhile
|
||||
|
||||
return loclist
|
||||
endfunction
|
||||
@@ -1,32 +0,0 @@
|
||||
"============================================================================
|
||||
"File: w3.vim
|
||||
"Description: Syntax checking plugin for syntastic.vim
|
||||
"Maintainer: Martin Grenfell <martin.grenfell 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.
|
||||
"
|
||||
"============================================================================
|
||||
function! SyntaxCheckers_html_GetLocList()
|
||||
let makeprg2="curl -s -F output=text -F \"uploaded_file=@".expand('%:p').";type=text/html\" http://validator.w3.org/check \\| sed -n -e '/\<em\>Line\.\*/ \{ N; s/\\n//; N; s/\\n//; /msg/p; \}' -e ''/msg_warn/p'' -e ''/msg_info/p'' \\| sed -e 's/[ ]\\+/ /g' -e 's/\<[\^\>]\*\>//g' -e 's/\^[ ]//g'"
|
||||
let errorformat2='Line %l\, Column %c: %m'
|
||||
let loclist = SyntasticMake({ 'makeprg': makeprg2, 'errorformat': errorformat2 })
|
||||
|
||||
let n = len(loclist) - 1
|
||||
let bufnum = bufnr("")
|
||||
while n >= 0
|
||||
let i = loclist[n]
|
||||
let i['bufnr'] = bufnum
|
||||
|
||||
if i['lnum'] == 0
|
||||
let i['type'] = 'w'
|
||||
else
|
||||
let i['type'] = 'e'
|
||||
endif
|
||||
let n -= 1
|
||||
endwhile
|
||||
|
||||
return loclist
|
||||
endfunction
|
||||
@@ -1,23 +0,0 @@
|
||||
"============================================================================
|
||||
"File: java.vim
|
||||
"Description: Figures out which java syntax checker (if any) to load
|
||||
" from the java directory.
|
||||
"Maintainer: Dmitry Geurkov <d.geurkov 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.
|
||||
"
|
||||
" Use g:syntastic_java_checker option to specify which java syntax checker
|
||||
" should be used (see below for a list of supported checkers).
|
||||
" If g:syntastic_java_checker is not set, just use the first syntax
|
||||
" checker that we find installed.
|
||||
"============================================================================
|
||||
if exists("loaded_java_syntax_checker")
|
||||
finish
|
||||
endif
|
||||
let loaded_java_syntax_checker = 1
|
||||
|
||||
let s:supported_checkers = ["javac", "checkstyle"]
|
||||
call SyntasticLoadChecker(s:supported_checkers, 'java')
|
||||
@@ -1,33 +0,0 @@
|
||||
"============================================================================
|
||||
"File: checkstyle.vim
|
||||
"Description: Syntax checking plugin for syntastic.vim
|
||||
"Maintainer: Dmitry Geurkov <d.geurkov 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.
|
||||
"
|
||||
" Tested with checkstyle 5.5
|
||||
"============================================================================
|
||||
if !exists("g:syntastic_java_checkstyle_classpath")
|
||||
let g:syntastic_java_checkstyle_classpath = 'checkstyle-5.5-all.jar'
|
||||
endif
|
||||
|
||||
if !exists("g:syntastic_java_checkstyle_conf_file")
|
||||
let g:syntastic_java_checkstyle_conf_file = 'sun_checks.xml'
|
||||
endif
|
||||
|
||||
function! SyntaxCheckers_java_GetLocList()
|
||||
|
||||
let makeprg = 'java -cp ' . g:syntastic_java_checkstyle_classpath . ' com.puppycrawl.tools.checkstyle.Main -c '
|
||||
\. g:syntastic_java_checkstyle_conf_file . ' '
|
||||
\. expand ( '%:p:h' ) . '/' . expand ( '%:t' )
|
||||
\. ' 2>&1 '
|
||||
|
||||
" check style format
|
||||
let errorformat = '%f:%l:%c:\ %m,%f:%l:\ %m'
|
||||
|
||||
return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat })
|
||||
|
||||
endfunction
|
||||
@@ -1,161 +0,0 @@
|
||||
"============================================================================
|
||||
"File: javac.vim
|
||||
"Description: Syntax checking plugin for syntastic.vim
|
||||
"Maintainer: Jochen Keil <jochen.keil at gmail dot com>
|
||||
" Dmitry Geurkov <d.geurkov 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.
|
||||
"
|
||||
"============================================================================
|
||||
|
||||
" Global Options
|
||||
if !exists("g:syntastic_java_javac_executable")
|
||||
let g:syntastic_java_javac_executable = 'javac'
|
||||
endif
|
||||
|
||||
if !exists("g:syntastic_java_javac_options")
|
||||
let g:syntastic_java_javac_options = '-Xlint'
|
||||
endif
|
||||
|
||||
if !exists("g:syntastic_java_javac_classpath")
|
||||
let g:syntastic_java_javac_classpath = ''
|
||||
endif
|
||||
|
||||
if !exists("g:syntastic_java_javac_delete_output")
|
||||
let g:syntastic_java_javac_delete_output = 1
|
||||
endif
|
||||
|
||||
if !exists("g:syntastic_java_javac_autoload_maven_classpath")
|
||||
let g:syntastic_java_javac_autoload_maven_classpath = 1
|
||||
endif
|
||||
|
||||
" Internal variables, do not ovveride those
|
||||
if !exists("g:syntastic_java_javac_maven_pom_cwd")
|
||||
let g:syntastic_java_javac_maven_pom_cwd = ''
|
||||
endif
|
||||
|
||||
if !exists("g:syntastic_java_javac_maven_pom_ftime")
|
||||
let g:syntastic_java_javac_maven_pom_ftime = 0
|
||||
endif
|
||||
|
||||
if !exists("g:syntastic_java_javac_maven_pom_classpath")
|
||||
let g:syntastic_java_javac_maven_pom_classpath = ''
|
||||
endif
|
||||
|
||||
function! s:AddToClasspath(classpath,path)
|
||||
if a:path == ''
|
||||
return a:classpath
|
||||
endif
|
||||
if a:classpath != '' && a:path != ''
|
||||
return a:classpath . ":" . a:path
|
||||
else
|
||||
return a:path
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:SaveClasspath()
|
||||
let path = ''
|
||||
let lines = getline(1,line('$'))
|
||||
for l in lines
|
||||
if l != ''
|
||||
let path .= l."\n"
|
||||
endif
|
||||
endfor
|
||||
let g:syntastic_java_javac_classpath = path
|
||||
let &modified = 0
|
||||
endfunction
|
||||
|
||||
function! s:EditClasspath()
|
||||
let command = 'syntastic javac classpath'
|
||||
let winnr = bufwinnr('^' . command . '$')
|
||||
if winnr < 0
|
||||
let pathlist = split(g:syntastic_java_javac_classpath,"\n")
|
||||
execute (len(pathlist)+5) . 'sp ' . fnameescape(command)
|
||||
au BufWriteCmd <buffer> call s:SaveClasspath() | bwipeout
|
||||
setlocal buftype=acwrite bufhidden=wipe nobuflisted noswapfile nowrap number
|
||||
for p in pathlist | call append(line('$')-1,p) | endfor
|
||||
else
|
||||
execute winnr . 'wincmd w'
|
||||
endif
|
||||
endfunction
|
||||
command! SyntasticJavacEditClasspath call s:EditClasspath()
|
||||
|
||||
function! s:GetMavenClasspath()
|
||||
if filereadable('pom.xml')
|
||||
if g:syntastic_java_javac_maven_pom_ftime != getftime('pom.xml') || g:syntastic_java_javac_maven_pom_cwd != getcwd()
|
||||
let mvn_classpath_output = split(system('mvn dependency:build-classpath'),"\n")
|
||||
let class_path_next = 0
|
||||
for line in mvn_classpath_output
|
||||
if class_path_next == 1
|
||||
let mvn_classpath = line
|
||||
break
|
||||
endif
|
||||
if match(line,'Dependencies classpath:') >= 0
|
||||
let class_path_next = 1
|
||||
endif
|
||||
endfor
|
||||
let mvn_classpath = s:AddToClasspath(mvn_classpath,'target/classes')
|
||||
let g:syntastic_java_javac_maven_pom_cwd = getcwd()
|
||||
let g:syntastic_java_javac_maven_pom_ftime = getftime('pom.xml')
|
||||
let g:syntastic_java_javac_maven_pom_classpath = mvn_classpath
|
||||
endif
|
||||
return g:syntastic_java_javac_maven_pom_classpath
|
||||
endif
|
||||
return ''
|
||||
endfunction
|
||||
|
||||
function! SyntaxCheckers_java_GetLocList()
|
||||
|
||||
let javac_opts = g:syntastic_java_javac_options
|
||||
|
||||
if g:syntastic_java_javac_delete_output
|
||||
let output_dir = '/tmp/vim-syntastic'
|
||||
let javac_opts .= ' -d ' .output_dir
|
||||
endif
|
||||
|
||||
let javac_classpath = ''
|
||||
|
||||
" add classpathes to javac_classpath
|
||||
for path in split(g:syntastic_java_javac_classpath,"\n")
|
||||
if path != ''
|
||||
"let ps = glob(path,0,1)
|
||||
let ps = glob(path)
|
||||
if type(ps) == type([])
|
||||
for p in ps
|
||||
if p != '' | let javac_classpath = s:AddToClasspath(javac_classpath,p) | endif
|
||||
endfor
|
||||
else
|
||||
let javac_classpath = s:AddToClasspath(javac_classpath,ps)
|
||||
endif
|
||||
endif
|
||||
endfor
|
||||
|
||||
if g:syntastic_java_javac_autoload_maven_classpath
|
||||
let maven_classpath = s:GetMavenClasspath()
|
||||
let javac_classpath = s:AddToClasspath(javac_classpath,maven_classpath)
|
||||
endif
|
||||
|
||||
if javac_classpath != ''
|
||||
let javac_opts .= ' -cp ' . javac_classpath
|
||||
endif
|
||||
|
||||
let makeprg = g:syntastic_java_javac_executable . ' '. javac_opts . ' '
|
||||
\. expand ( '%:p:h' ) . '/' . expand ( '%:t' )
|
||||
\. ' 2>&1 '
|
||||
|
||||
" unashamedly stolen from *errorformat-javac* (quickfix.txt) and modified to include error types
|
||||
let errorformat = '%E%f:%l:\ error:\ %m,%W%f:%l:\ warning:\ %m,%A%f:%l:\ %m,%+Z%p^,%+C%.%#,%-G%.%#'
|
||||
|
||||
if g:syntastic_java_javac_delete_output
|
||||
call system('mkdir -p ' . output_dir)
|
||||
endif
|
||||
let r = SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat })
|
||||
if g:syntastic_java_javac_delete_output
|
||||
call system('rm -rf ' . output_dir)
|
||||
endif
|
||||
return r
|
||||
|
||||
endfunction
|
||||
@@ -1,23 +0,0 @@
|
||||
"============================================================================
|
||||
"File: javascript.vim
|
||||
"Description: Figures out which javascript syntax checker (if any) to load
|
||||
" from the javascript directory.
|
||||
"Maintainer: Martin Grenfell <martin.grenfell 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.
|
||||
"
|
||||
" Use g:syntastic_javascript_checker option to specify which jslint executable
|
||||
" should be used (see below for a list of supported checkers).
|
||||
" If g:syntastic_javascript_checker is not set, just use the first syntax
|
||||
" checker that we find installed.
|
||||
"============================================================================
|
||||
if exists("loaded_javascript_syntax_checker")
|
||||
finish
|
||||
endif
|
||||
let loaded_javascript_syntax_checker = 1
|
||||
|
||||
let s:supported_checkers = ["gjslint", "jslint", "jsl", "jshint", "closurecompiler"]
|
||||
call SyntasticLoadChecker(s:supported_checkers, 'javascript')
|
||||
@@ -1,43 +0,0 @@
|
||||
"============================================================================
|
||||
"File: closurecompiler.vim
|
||||
"Description: Javascript syntax checker - using Google Closure Compiler
|
||||
"Maintainer: Motohiro Takayama <mootoh 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.
|
||||
"============================================================================
|
||||
"
|
||||
" To enable this plugin, edit the .vimrc like this:
|
||||
"
|
||||
" let g:syntastic_javascript_checker = "closurecompiler"
|
||||
"
|
||||
" and set the path to the Google Closure Compiler:
|
||||
"
|
||||
" let g:syntastic_javascript_closure_compiler_path = '/path/to/google-closure-compiler.jar'
|
||||
"
|
||||
" It takes additional options for Google Closure Compiler with the variable
|
||||
" g:syntastic_javascript_closure_compiler_options.
|
||||
"
|
||||
|
||||
if !exists("g:syntastic_javascript_closure_compiler_options")
|
||||
let g:syntastic_javascript_closure_compiler_options = ""
|
||||
endif
|
||||
|
||||
"bail if the user does not specify the path to closure compiler.
|
||||
if !exists("g:syntastic_javascript_closure_compiler_path")
|
||||
finish
|
||||
endif
|
||||
|
||||
function! SyntaxCheckers_javascript_GetLocList()
|
||||
if exists("g:syntastic_javascript_closure_compiler_file_list")
|
||||
let file_list = join(readfile(g:syntastic_javascript_closure_compiler_file_list), ' ')
|
||||
else
|
||||
let file_list = shellescape(expand('%'))
|
||||
endif
|
||||
|
||||
let makeprg = 'java -jar ' . g:syntastic_javascript_closure_compiler_path . ' ' . g:syntastic_javascript_closure_compiler_options . ' --js ' . file_list
|
||||
let errorformat = '%-GOK,%E%f:%l: ERROR - %m,%Z%p^,%W%f:%l: WARNING - %m,%Z%p^'
|
||||
return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat })
|
||||
endfunction
|
||||
@@ -1,20 +0,0 @@
|
||||
"============================================================================
|
||||
"File: gjslint.vim
|
||||
"Description: Javascript syntax checker - using gjslint
|
||||
"Maintainer: Martin Grenfell <martin.grenfell 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:syntastic_javascript_gjslint_conf")
|
||||
let g:syntastic_javascript_gjslint_conf = ""
|
||||
endif
|
||||
|
||||
function! SyntaxCheckers_javascript_GetLocList()
|
||||
let makeprg = "gjslint " . g:syntastic_javascript_gjslint_conf . " --nosummary --unix_mode --nodebug_indentation --nobeep " . shellescape(expand('%'))
|
||||
let errorformat="%f:%l:(New Error -%\\?\%n) %m,%f:%l:(-%\\?%n) %m,%-G1 files checked, no errors found.,%-G%.%#"
|
||||
return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat })
|
||||
endfunction
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
"============================================================================
|
||||
"File: jshint.vim
|
||||
"Description: Javascript syntax checker - using jshint
|
||||
"Maintainer: Martin Grenfell <martin.grenfell 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:syntastic_javascript_jshint_conf")
|
||||
let g:syntastic_javascript_jshint_conf = ""
|
||||
endif
|
||||
|
||||
function! SyntaxCheckers_javascript_GetLocList()
|
||||
" node-jshint uses .jshintrc as config unless --config arg is present
|
||||
let args = !empty(g:syntastic_javascript_jshint_conf) ? ' --config ' . g:syntastic_javascript_jshint_conf : ''
|
||||
let makeprg = 'jshint ' . shellescape(expand("%")) . args
|
||||
let errorformat = '%ELine %l:%c,%Z\\s%#Reason: %m,%C%.%#,%f: line %l\, col %c\, %m,%-G%.%#'
|
||||
return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat, 'defaults': {'bufnr': bufnr('')} })
|
||||
endfunction
|
||||
@@ -1,28 +0,0 @@
|
||||
"============================================================================
|
||||
"File: jsl.vim
|
||||
"Description: Javascript syntax checker - using jsl
|
||||
"Maintainer: Martin Grenfell <martin.grenfell 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:syntastic_javascript_jsl_conf")
|
||||
let g:syntastic_javascript_jsl_conf = ""
|
||||
endif
|
||||
|
||||
function s:ConfFlag()
|
||||
if !empty(g:syntastic_javascript_jsl_conf)
|
||||
return "-conf " . g:syntastic_javascript_jsl_conf
|
||||
endif
|
||||
|
||||
return ""
|
||||
endfunction
|
||||
|
||||
function! SyntaxCheckers_javascript_GetLocList()
|
||||
let makeprg = "jsl " . s:ConfFlag() . " -nologo -nofilelisting -nosummary -nocontext -process ".shellescape(expand('%'))
|
||||
let errorformat='%W%f(%l): lint warning: %m,%-Z%p^,%W%f(%l): warning: %m,%-Z%p^,%E%f(%l): SyntaxError: %m,%-Z%p^,%-G'
|
||||
return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat })
|
||||
endfunction
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
"============================================================================
|
||||
"File: jslint.vim
|
||||
"Description: Javascript syntax checker - using jslint
|
||||
"Maintainer: Martin Grenfell <martin.grenfell 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.
|
||||
"
|
||||
"Tested with jslint 0.1.4.
|
||||
"============================================================================
|
||||
if !exists("g:syntastic_javascript_jslint_conf")
|
||||
let g:syntastic_javascript_jslint_conf = "--white --undef --nomen --regexp --plusplus --bitwise --newcap --sloppy --vars"
|
||||
endif
|
||||
|
||||
function! SyntaxCheckers_javascript_HighlightTerm(error)
|
||||
let unexpected = matchstr(a:error['text'], 'Expected.*and instead saw \'\zs.*\ze\'')
|
||||
if len(unexpected) < 1 | return '' | end
|
||||
return '\V'.split(unexpected, "'")[1]
|
||||
endfunction
|
||||
|
||||
function! SyntaxCheckers_javascript_GetLocList()
|
||||
let makeprg = "jslint " . g:syntastic_javascript_jslint_conf . " " . shellescape(expand('%'))
|
||||
let errorformat='%E %##%n %m,%-Z%.%#Line %l\, Pos %c,%-G%.%#'
|
||||
return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat, 'defaults': {'bufnr': bufnr("")} })
|
||||
endfunction
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
"============================================================================
|
||||
"File: json.vim
|
||||
"Description: Figures out which json syntax checker (if any) to load
|
||||
" from the json directory.
|
||||
"Maintainer: Miller Medeiros <contact at millermedeiros 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.
|
||||
"
|
||||
" Use g:syntastic_json_checker option to specify which jsonlint executable
|
||||
" should be used (see below for a list of supported checkers).
|
||||
" If g:syntastic_json_checker is not set, just use the first syntax
|
||||
" checker that we find installed.
|
||||
"============================================================================
|
||||
if exists("loaded_json_syntax_checker")
|
||||
finish
|
||||
endif
|
||||
let loaded_json_syntax_checker = 1
|
||||
|
||||
let s:supported_checkers = ["jsonlint", "jsonval"]
|
||||
call SyntasticLoadChecker(s:supported_checkers, 'json')
|
||||
@@ -1,16 +0,0 @@
|
||||
"============================================================================
|
||||
"File: jsonlint.vim
|
||||
"Description: JSON syntax checker - using jsonlint
|
||||
"Maintainer: Miller Medeiros <contact at millermedeiros 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.
|
||||
"============================================================================
|
||||
|
||||
function! SyntaxCheckers_json_GetLocList()
|
||||
let makeprg = 'jsonlint ' . shellescape(expand("%")) . ' --compact'
|
||||
let errorformat = '%ELine %l:%c,%Z\\s%#Reason: %m,%C%.%#,%f: line %l\, col %c\, %m,%-G%.%#'
|
||||
return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat, 'defaults': {'bufnr': bufnr('')} })
|
||||
endfunction
|
||||
@@ -1,17 +0,0 @@
|
||||
"============================================================================
|
||||
"File: jsonval.vim
|
||||
"Description: JSON syntax checker - using jsonval
|
||||
"Maintainer: Miller Medeiros <contact at millermedeiros 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.
|
||||
"============================================================================
|
||||
|
||||
function! SyntaxCheckers_json_GetLocList()
|
||||
" based on https://gist.github.com/1196345
|
||||
let makeprg = 'jsonval '. shellescape(expand('%'))
|
||||
let errorformat = '%E%f:\ %m\ at\ line\ %l,%-G%.%#'
|
||||
return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat, 'defaults': {'bufnr': bufnr('')} })
|
||||
endfunction
|
||||
@@ -1,41 +0,0 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
fs = require 'fs'
|
||||
less = require 'less'
|
||||
args = process.argv.slice(1)
|
||||
options = {}
|
||||
|
||||
args = args.filter (arg) ->
|
||||
match = arg.match(/^-I(.+)$/)
|
||||
if match
|
||||
options.paths.push(match[1]);
|
||||
return false
|
||||
|
||||
match = arg.match(/^--?([a-z][\-0-9a-z]*)(?:=([^\s]+))?$/i)
|
||||
if match
|
||||
arg = match[1]
|
||||
else
|
||||
return arg
|
||||
|
||||
switch arg
|
||||
when 'strict-imports' then options.strictImports = true
|
||||
when 'include-path'
|
||||
options.paths = match[2].split(if os.type().match(/Windows/) then ';' else ':')
|
||||
.map (p) ->
|
||||
if p
|
||||
return path.resolve(process.cwd(), p)
|
||||
when 'O0' then options.optimization = 0
|
||||
when 'O1' then options.optimization = 1
|
||||
when 'O2' then options.optimization = 2
|
||||
|
||||
options.filename = args[1]
|
||||
|
||||
parser = new(less.Parser) options
|
||||
|
||||
fs.readFile(options.filename, 'utf-8', (err,data) ->
|
||||
parser.parse(data, (err, tree) ->
|
||||
if err
|
||||
less.writeError err
|
||||
process.exit(1)
|
||||
)
|
||||
)
|
||||
@@ -1,57 +0,0 @@
|
||||
// Generated by CoffeeScript 1.3.3
|
||||
(function() {
|
||||
var args, fs, less, options, parser;
|
||||
|
||||
fs = require('fs');
|
||||
|
||||
less = require('less');
|
||||
|
||||
args = process.argv.slice(1);
|
||||
|
||||
options = {};
|
||||
|
||||
args = args.filter(function(arg) {
|
||||
var match;
|
||||
match = arg.match(/^-I(.+)$/);
|
||||
if (match) {
|
||||
options.paths.push(match[1]);
|
||||
return false;
|
||||
}
|
||||
match = arg.match(/^--?([a-z][\-0-9a-z]*)(?:=([^\s]+))?$/i);
|
||||
if (match) {
|
||||
arg = match[1];
|
||||
} else {
|
||||
return arg;
|
||||
}
|
||||
switch (arg) {
|
||||
case 'strict-imports':
|
||||
return options.strictImports = true;
|
||||
case 'include-path':
|
||||
return options.paths = match[2].split(os.type().match(/Windows/) ? ';' : ':').map(function(p) {
|
||||
if (p) {
|
||||
return path.resolve(process.cwd(), p);
|
||||
}
|
||||
});
|
||||
case 'O0':
|
||||
return options.optimization = 0;
|
||||
case 'O1':
|
||||
return options.optimization = 1;
|
||||
case 'O2':
|
||||
return options.optimization = 2;
|
||||
}
|
||||
});
|
||||
|
||||
options.filename = args[1];
|
||||
|
||||
parser = new less.Parser(options);
|
||||
|
||||
fs.readFile(options.filename, 'utf-8', function(err, data) {
|
||||
return parser.parse(data, function(err, tree) {
|
||||
if (err) {
|
||||
less.writeError(err);
|
||||
return process.exit(1);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
}).call(this);
|
||||
@@ -1,53 +0,0 @@
|
||||
"============================================================================
|
||||
"File: less.vim
|
||||
"Description: Syntax checking plugin for syntastic.vim
|
||||
"Maintainer: Julien Blanchard <julien at sideburns dot eu>
|
||||
"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.
|
||||
"
|
||||
"============================================================================
|
||||
|
||||
" To send additional options to less use the variable g:syntastic_less_options.
|
||||
" The default is
|
||||
" let g:syntastic_less_options = "--no-color"
|
||||
"
|
||||
" To use less-lint instead of less set the variable
|
||||
" g:syntastic_less_use_less_lint.
|
||||
|
||||
if exists("loaded_less_syntax_checker")
|
||||
finish
|
||||
endif
|
||||
let loaded_less_syntax_checker = 1
|
||||
|
||||
"bail if the user doesnt have the lessc binary installed
|
||||
if !executable("lessc")
|
||||
finish
|
||||
endif
|
||||
|
||||
if !exists("g:syntastic_less_options")
|
||||
let g:syntastic_less_options = "--no-color"
|
||||
endif
|
||||
|
||||
if !exists("g:syntastic_less_use_less_lint")
|
||||
let g:syntastic_less_use_less_lint = 0
|
||||
endif
|
||||
|
||||
if g:syntastic_less_use_less_lint
|
||||
let s:check_file = 'node ' . expand('<sfile>:p:h') . '/less-lint.js'
|
||||
else
|
||||
let s:check_file = 'lessc'
|
||||
end
|
||||
|
||||
function! SyntaxCheckers_less_GetLocList()
|
||||
let makeprg = s:check_file . ' ' . g:syntastic_less_options . ' ' .
|
||||
\ shellescape(expand('%')) . ' ' . syntastic#util#DevNull()
|
||||
let errorformat = '%m in %f:%l:%c'
|
||||
|
||||
return SyntasticMake({ 'makeprg': makeprg,
|
||||
\ 'errorformat': errorformat,
|
||||
\ 'defaults': {'bufnr': bufnr(""), 'text': "Syntax error"} })
|
||||
endfunction
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
"============================================================================
|
||||
"File: lisp.vim
|
||||
"Description: Syntax checking plugin for syntastic.vim
|
||||
"Maintainer: Karl Yngve Lervåg <karl.yngve@lervag.net>
|
||||
"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("loaded_lisp_syntax_checker")
|
||||
finish
|
||||
endif
|
||||
let loaded_lisp_syntax_checker = 1
|
||||
|
||||
" Bail if the user doesnt have clisp installed
|
||||
if !executable("clisp")
|
||||
finish
|
||||
endif
|
||||
|
||||
function! SyntaxCheckers_lisp_GetLocList()
|
||||
let makeprg = 'clisp -c ' . shellescape(expand('%'))
|
||||
let makeprg .= ' -o /tmp/clisp-vim-compiled-file'
|
||||
let efm = '%-G;%.%#,'
|
||||
let efm .= '%W%>WARNING:%.%#line %l : %m,%C %#%m,'
|
||||
let efm .= '%E%>The following functions were %m,%Z %m,'
|
||||
let efm .= '%-G%.%#'
|
||||
return SyntasticMake({ 'makeprg': makeprg, 'errorformat': efm })
|
||||
endfunction
|
||||
@@ -1,55 +0,0 @@
|
||||
"============================================================================
|
||||
"File: lua.vim
|
||||
"Description: Syntax checking plugin for syntastic.vim
|
||||
"Maintainer: Gregor Uhlenheuer <kongo2002 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('loaded_lua_syntax_checker')
|
||||
finish
|
||||
endif
|
||||
let loaded_lua_syntax_checker = 1
|
||||
|
||||
" check if the lua compiler is installed
|
||||
if !executable('luac')
|
||||
finish
|
||||
endif
|
||||
|
||||
function! SyntaxCheckers_lua_GetHighlightRegex(pos)
|
||||
let near = matchstr(a:pos['text'], "near '[^']\\+'")
|
||||
let result = ''
|
||||
if len(near) > 0
|
||||
let near = split(near, "'")[1]
|
||||
if near == '<eof>'
|
||||
let p = getpos('$')
|
||||
let a:pos['lnum'] = p[1]
|
||||
let a:pos['col'] = p[2]
|
||||
let result = '\%'.p[2].'c'
|
||||
else
|
||||
let result = '\V'.near
|
||||
endif
|
||||
let open = matchstr(a:pos['text'], "(to close '[^']\\+' at line [0-9]\\+)")
|
||||
if len(open) > 0
|
||||
let oline = split(open, "'")[1:2]
|
||||
let line = 0+strpart(oline[1], 9)
|
||||
call matchadd('SpellCap', '\%'.line.'l\V'.oline[0])
|
||||
endif
|
||||
endif
|
||||
return result
|
||||
endfunction
|
||||
|
||||
function! SyntaxCheckers_lua_GetLocList()
|
||||
let makeprg = 'luac -p ' . shellescape(expand('%'))
|
||||
let errorformat = 'luac: %#%f:%l: %m'
|
||||
|
||||
return SyntasticMake({ 'makeprg': makeprg,
|
||||
\ 'errorformat': errorformat,
|
||||
\ 'defaults': { 'bufnr': bufnr(''), 'type': 'E' } })
|
||||
|
||||
endfunction
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user