1
0
Fork 0
mirror of synced 2024-11-16 14:05:34 -05:00
This commit is contained in:
wangzheng 2018-10-14 21:43:54 +08:00
commit 6d4398077d
2072 changed files with 164054 additions and 0 deletions

10
.gitignore vendored Normal file
View file

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

21
LICENSE Normal file
View file

@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2016 Amir Salihefendic
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.

330
README.md Normal file
View file

@ -0,0 +1,330 @@
![VIM](https://dnp4pehkvoo6n.cloudfront.net/43c5af597bd5c1a64eb1829f011c208f/as/Ultimate%20Vimrc.svg)
# The Ultimate vimrc
Over the last 10 years, I have used and tweaked Vim. This configuration is the ultimate vimrc (or at least my version of it).
There are two versions:
* **The Basic**: If you want something small just copy [basic.vim](https://github.com/amix/vimrc/blob/master/vimrcs/basic.vim) into your ~/.vimrc and you will have a good basic setup
* **The Awesome**: Includes a ton of useful plugins, color schemes, and configurations
I would, of course, recommend using the awesome version.
## How to install the Awesome version?
### Install for your own user only
The awesome version includes a lot of great plugins, configurations and color schemes that make Vim a lot better. To install it simply do following from your terminal:
git clone --depth=1 https://github.com/amix/vimrc.git ~/.vim_runtime
sh ~/.vim_runtime/install_awesome_vimrc.sh
### Install for multiple users
To install for multiple users, the repository needs to be cloned to a location accessible for all the intended users.
git clone --depth=1 https://github.com/amix/vimrc.git /opt/vim_runtime
sh ~/.vim_runtime/install_awesome_parameterized.sh /opt/vim_runtime user0 user1 user2
# to install for all users with home directories
sh ~/.vim_runtime/install_awesome_parameterized.sh /opt/vim_runtime --all
Naturally, `/opt/vim_runtime` can be any directory, as long as all the users specified have read access.
## Fonts
I recommend using [IBM Plex Mono font](https://github.com/IBM/plex) (it's an open-source and awesome font that can make your code beautiful). The Awesome vimrc is already setup to try to use it.
Some other fonts that Awesome will try to use:
* [Hack](http://sourcefoundry.org/hack/)
* [Source Code Pro](https://adobe-fonts.github.io/source-code-pro/)
## How to install the Basic version?
The basic version is just one file and no plugins. Just copy [basic.vim](https://github.com/amix/vimrc/blob/master/vimrcs/basic.vim) and paste it into your vimrc.
The basic version is useful to install on remote servers where you don't need many plugins, and you don't do many edits.
git clone --depth=1 https://github.com/amix/vimrc.git ~/.vim_runtime
sh ~/.vim_runtime/install_basic_vimrc.sh
## How to install on Windows?
Use [gitforwindows](http://gitforwindows.org/) to checkout the repository and run the installation instructions above. No special instructions needed ;-)
## How to install on Linux
If you have vim aliased as `vi` instead of `vim`, make sure to either alias it: `alias vi=vim`. Otherwise, `apt-get install vim`
## How to update to latest version?
Just do a git rebase!
cd ~/.vim_runtime
git pull --rebase
## Some screenshots
Colors when editing a Python file:
![Screenshot 1](https://dnp4pehkvoo6n.cloudfront.net/07583008e4da885801657e8781777844/as/Python%20editing.png)
Opening recently opened files with the [mru.vim](https://github.com/vim-scripts/mru.vim) plugin:
![Screenshot 2](https://dnp4pehkvoo6n.cloudfront.net/1d49a88f9bd5d013c025bb1e1272a7d8/as/MRU%20plugin.png)
[NERD Tree](https://github.com/scrooloose/nerdtree) plugin in a terminal window:
![Screenshot 3](https://dnp4pehkvoo6n.cloudfront.net/ae719203166585d64728f28398f4b1b7/as/Terminal%20usage.png)
Distraction free mode using [goyo.vim](https://github.com/junegunn/goyo.vim) and [vim-zenroom2](https://github.com/amix/vim-zenroom2):
![Screenshot 4](https://dnp4pehkvoo6n.cloudfront.net/f0dcc4c9739148c56cbf8285a910ac41/as/Zen%20mode.png)
## Included Plugins
I recommend reading the docs of these plugins to understand them better. Each plugin provides a much better Vim experience!
* [ack.vim](https://github.com/mileszs/ack.vim): Vim plugin for `the_silver_searcher` (ag) or ack -- a wicked fast grep
* [bufexplorer.zip](https://github.com/vim-scripts/bufexplorer.zip): Quickly and easily switch between buffers. This plugin can be opened with `<leader+o>`
* [ctrlp.vim](https://github.com/ctrlpvim/ctrlp.vim): Fuzzy file, buffer, mru and tag finder. It's mapped to `<Ctrl+F>`
* [goyo.vim](https://github.com/junegunn/goyo.vim) and [vim-zenroom2](https://github.com/amix/vim-zenroom2):
* [lightline.vim](https://github.com/itchyny/lightline.vim): A light and configurable statusline/tabline for Vim
* [NERD Tree](https://github.com/scrooloose/nerdtree): A tree explorer plugin for vim
* [mru.vim](https://github.com/vim-scripts/mru.vim): Plugin to manage Most Recently Used (MRU) files. This plugin can be opened with `<leader+f>`
* [open_file_under_cursor.vim](https://github.com/amix/open_file_under_cursor.vim): Open file under cursor when pressing `gf`
* [pathogen.vim](https://github.com/tpope/vim-pathogen): Manage your vim runtimepath
* [snipmate.vim](https://github.com/garbas/vim-snipmate): snipmate.vim aims to be a concise vim script that implements some of TextMate's snippets features in Vim
* [ale](https://github.com/w0rp/ale): Syntax and lint checking for vim (async)
* [vim-commentary](https://github.com/tpope/vim-commentary): Comment stuff out. Use `gcc` to comment out a line (takes a count), `gc` to comment out the target of a motion. `gcu` uncomments a set of adjacent commented lines.
* [vim-expand-region](https://github.com/terryma/vim-expand-region): Allows you to visually select increasingly larger regions of text using the same key combination
* [vim-fugitive](https://github.com/tpope/vim-fugitive): A Git wrapper so awesome, it should be illegal
* [vim-indent-object](https://github.com/michaeljsmith/vim-indent-object): Defines a new text object representing lines of code at the same indent level. Useful for python/vim scripts
* [vim-multiple-cursors](https://github.com/terryma/vim-multiple-cursors): Sublime Text style multiple selections for Vim, CTRL+N is remapped to CTRL+S (due to YankRing)
* [vim-yankstack](https://github.com/maxbrunsfeld/vim-yankstack): Maintains a history of previous yanks, changes and deletes
* [vim-zenroom2](https://github.com/amix/vim-zenroom2) Remove all clutter and focus only on the essential. Similar to iA Writer or Write Room
## Included color schemes
* [peaksea](https://github.com/vim-scripts/peaksea): The default
* [vim-colors-solarized](https://github.com/altercation/vim-colors-solarized)
* [vim-irblack](https://github.com/wgibbs/vim-irblack)
* [mayansmoke](https://github.com/vim-scripts/mayansmoke)
* [vim-pyte](https://github.com/therubymug/vim-pyte)
## Included modes
* [vim-coffee-script](https://github.com/kchmck/vim-coffee-script)
* [vim-less](https://github.com/groenewege/vim-less)
* [vim-bundle-mako](https://github.com/sophacles/vim-bundle-mako)
* [vim-markdown](https://github.com/tpope/vim-markdown)
* [nginx.vim](https://github.com/vim-scripts/nginx.vim): Highlights configuration files for nginx
* [vim-go](https://github.com/fatih/vim-go)
## How to include your own stuff?
After you have installed the setup, you can create **~/.vim_runtime/my_configs.vim** to fill in any configurations that are important for you. For instance, my **my_configs.vim** looks like this:
~/.vim_runtime (master)> cat my_configs.vim
map <leader>ct :cd ~/Desktop/Todoist/todoist<cr>
map <leader>cw :cd ~/Desktop/Wedoist/wedoist<cr>
You can also install your plugins, for instance, via pathogen you can install [vim-rails](https://github.com/tpope/vim-rails):
cd ~/.vim_runtime
git clone git://github.com/tpope/vim-rails.git my_plugins/vim-rails
## Key Mappings
The [leader](http://learnvimscriptthehardway.stevelosh.com/chapters/06.html#leader) is `,`, so whenever you see `<leader>` it means `,`.
### Plugin related mappings
Open [bufexplorer](https://github.com/vim-scripts/bufexplorer.zip) to see and manage the current buffers (`<leader>o`):
map <leader>o :BufExplorer<cr>
Open [MRU.vim](https://github.com/vim-scripts/mru.vim) to see the recently open files (`<leader>f`):
map <leader>f :MRU<CR>
Open [ctrlp.vim](https://github.com/kien/ctrlp.vim) plugin to quickly find a file or a buffer (`<leader>j` or `<ctrl>f`):
let g:ctrlp_map = '<c-f>'
[NERD Tree](https://github.com/scrooloose/nerdtree) mappings:
map <leader>nn :NERDTreeToggle<cr>
map <leader>nb :NERDTreeFromBookmark
map <leader>nf :NERDTreeFind<cr>
[goyo.vim](https://github.com/junegunn/goyo.vim) and [vim-zenroom2](https://github.com/amix/vim-zenroom2) lets you only focus on one thing at a time. It removes all the distractions and centers the content. It has a special look when editing Markdown, reStructuredText and textfiles. It only has one mapping. (`<leader>z`)
map <leader>z :Goyo<cr>
### Normal mode mappings
Fast saving of a buffer (`<leader>w`):
nmap <leader>w :w!<cr>
Map `<Space>` to `/` (search) and `<Ctrl>+<Space>` to `?` (backwards search):
map <space> /
map <c-space> ?
map <silent> <leader><cr> :noh<cr>
Disable highlights when you press `<leader><cr>`:
map <silent> <leader><cr> :noh<cr>
Smart way to move between windows (`<ctrl>j` etc.):
map <C-j> <C-W>j
map <C-k> <C-W>k
map <C-h> <C-W>h
map <C-l> <C-W>l
Closing of the current buffer(s) (`<leader>bd` and (`<leader>ba`)):
" Close current buffer
map <leader>bd :Bclose<cr>
" Close all buffers
map <leader>ba :1,1000 bd!<cr>
Useful mappings for managing tabs:
map <leader>tn :tabnew<cr>
map <leader>to :tabonly<cr>
map <leader>tc :tabclose<cr>
map <leader>tm :tabmove
" Opens a new tab with the current buffer's path
" Super useful when editing files in the same directory
map <leader>te :tabedit <c-r>=expand("%:p:h")<cr>/
Switch [CWD](http://vim.wikia.com/wiki/Set_working_directory_to_the_current_file) to the directory of the open buffer:
map <leader>cd :cd %:p:h<cr>:pwd<cr>
Open `ack.vim` for fast search:
map <leader>g :Ack
Quickly open a buffer for scripbble:
map <leader>q :e ~/buffer<cr>
Toggle paste mode on and off:
map <leader>pp :setlocal paste!<cr>
### Visual mode mappings
Visual mode pressing `*` or `#` searches for the current selection:
vnoremap <silent> * :call VisualSelection('f')<CR>
vnoremap <silent> # :call VisualSelection('b')<CR>
When you press gv you `Ack.vim` after the selected text:
vnoremap <silent> gv :call VisualSelection('gv', '')<CR>
When you press `<leader>r` you can search and replace the selected text:
vnoremap <silent> <leader>r :call VisualSelection('replace')<CR>
Surround the visual selection in parenthesis/brackets/etc.:
vnoremap $1 <esc>`>a)<esc>`<i(<esc>
vnoremap $2 <esc>`>a]<esc>`<i[<esc>
vnoremap $3 <esc>`>a}<esc>`<i{<esc>
vnoremap $$ <esc>`>a"<esc>`<i"<esc>
vnoremap $q <esc>`>a'<esc>`<i'<esc>
vnoremap $e <esc>`>a"<esc>`<i"<esc>
### Insert mode mappings
Quickly insert parenthesis/brackets/etc.:
inoremap $1 ()<esc>i
inoremap $2 []<esc>i
inoremap $3 {}<esc>i
inoremap $4 {<esc>o}<esc>O
inoremap $q ''<esc>i
inoremap $e ""<esc>i
inoremap $t <><esc>i
Insert the current date and time (useful for timestamps):
iab xdate <c-r>=strftime("%d/%m/%y %H:%M:%S")<cr>
### Command line mappings
$q is super useful when browsing on the command line. It deletes everything until the last slash:
cno $q <C-\>eDeleteTillSlash()<cr>
Bash like keys for the command line:
cnoremap <C-A> <Home>
cnoremap <C-E> <End>
cnoremap <C-K> <C-U>
cnoremap <C-P> <Up>
cnoremap <C-N> <Down>
Write the file as sudo (works only on Unix). Super useful when you open a file and you don't have permissions to save your changes. [Vim tip](http://vim.wikia.com/wiki/Su-write):
:W
### Spell checking
Pressing `<leader>ss` will toggle spell checking:
map <leader>ss :setlocal spell!<cr>
Shortcuts using `<leader>` instead of special characters:
map <leader>sn ]s
map <leader>sp [s
map <leader>sa zg
map <leader>s? z=
### Cope
Query `:help cope` if you are unsure what cope is. It's super useful!
When you search with `Ack.vim`, display your results in cope by doing:
`<leader>cc`
To go to the next search result do:
`<leader>n`
To go to the previous search results do:
`<leader>p`
Cope mappings:
map <leader>cc :botright cope<cr>
map <leader>co ggVGy:tabnew<cr>:set syntax=qf<cr>pgg
map <leader>n :cn<cr>
map <leader>p :cp<cr>
## How to uninstall
Just do following:
* Remove `~/.vim_runtime`
* Remove any lines that reference `.vim_runtime` in your `~/.vimrc`

347
autoload/pathogen.vim Executable file
View file

@ -0,0 +1,347 @@
" pathogen.vim - path option manipulation
" Maintainer: Tim Pope <http://tpo.pe/>
" Version: 2.3
" Install in ~/.vim/autoload (or ~\vimfiles\autoload).
"
" For management of individually installed plugins in ~/.vim/bundle (or
" ~\vimfiles\bundle), adding `execute pathogen#infect()` to the top of your
" .vimrc is the only other setup necessary.
"
" The API is documented inline below.
if exists("g:loaded_pathogen") || &cp
finish
endif
let g:loaded_pathogen = 1
" Point of entry for basic default usage. Give a relative path to invoke
" pathogen#interpose() (defaults to "bundle/{}"), or an absolute path to invoke
" pathogen#surround(). Curly braces are expanded with pathogen#expand():
" "bundle/{}" finds all subdirectories inside "bundle" inside all directories
" in the runtime path.
function! pathogen#infect(...) abort
for path in a:0 ? filter(reverse(copy(a:000)), 'type(v:val) == type("")') : ['bundle/{}']
if path =~# '^\%({\=[$~\\/]\|{\=\w:[\\/]\).*[{}*]'
call pathogen#surround(path)
elseif path =~# '^\%([$~\\/]\|\w:[\\/]\)'
call s:warn('Change pathogen#infect('.string(path).') to pathogen#infect('.string(path.'/{}').')')
call pathogen#surround(path . '/{}')
elseif path =~# '[{}*]'
call pathogen#interpose(path)
else
call s:warn('Change pathogen#infect('.string(path).') to pathogen#infect('.string(path.'/{}').')')
call pathogen#interpose(path . '/{}')
endif
endfor
call pathogen#cycle_filetype()
if pathogen#is_disabled($MYVIMRC)
return 'finish'
endif
return ''
endfunction
" Split a path into a list.
function! pathogen#split(path) abort
if type(a:path) == type([]) | return a:path | endif
if empty(a:path) | return [] | endif
let split = split(a:path,'\\\@<!\%(\\\\\)*\zs,')
return map(split,'substitute(v:val,''\\\([\\,]\)'',''\1'',"g")')
endfunction
" Convert a list to a path.
function! pathogen#join(...) abort
if type(a:1) == type(1) && a:1
let i = 1
let space = ' '
else
let i = 0
let space = ''
endif
let path = ""
while i < a:0
if type(a:000[i]) == type([])
let list = a:000[i]
let j = 0
while j < len(list)
let escaped = substitute(list[j],'[,'.space.']\|\\[\,'.space.']\@=','\\&','g')
let path .= ',' . escaped
let j += 1
endwhile
else
let path .= "," . a:000[i]
endif
let i += 1
endwhile
return substitute(path,'^,','','')
endfunction
" Convert a list to a path with escaped spaces for 'path', 'tag', etc.
function! pathogen#legacyjoin(...) abort
return call('pathogen#join',[1] + a:000)
endfunction
" Turn filetype detection off and back on again if it was already enabled.
function! pathogen#cycle_filetype() abort
if exists('g:did_load_filetypes')
filetype off
filetype on
endif
endfunction
" Check if a bundle is disabled. A bundle is considered disabled if its
" basename or full name is included in the list g:pathogen_disabled.
function! pathogen#is_disabled(path) abort
if a:path =~# '\~$'
return 1
endif
let sep = pathogen#slash()
let blacklist = map(
\ get(g:, 'pathogen_blacklist', get(g:, 'pathogen_disabled', [])) +
\ pathogen#split($VIMBLACKLIST),
\ 'substitute(v:val, "[\\/]$", "", "")')
return index(blacklist, fnamemodify(a:path, ':t')) != -1 || index(blacklist, a:path) != -1
endfunction "}}}1
" Prepend the given directory to the runtime path and append its corresponding
" after directory. Curly braces are expanded with pathogen#expand().
function! pathogen#surround(path) abort
let sep = pathogen#slash()
let rtp = pathogen#split(&rtp)
let path = fnamemodify(a:path, ':p:?[\\/]\=$??')
let before = filter(pathogen#expand(path), '!pathogen#is_disabled(v:val)')
let after = filter(reverse(pathogen#expand(path.sep.'after')), '!pathogen#is_disabled(v:val[0:-7])')
call filter(rtp, 'index(before + after, v:val) == -1')
let &rtp = pathogen#join(before, rtp, after)
return &rtp
endfunction
" For each directory in the runtime path, add a second entry with the given
" argument appended. Curly braces are expanded with pathogen#expand().
function! pathogen#interpose(name) abort
let sep = pathogen#slash()
let name = a:name
if has_key(s:done_bundles, name)
return ""
endif
let s:done_bundles[name] = 1
let list = []
for dir in pathogen#split(&rtp)
if dir =~# '\<after$'
let list += reverse(filter(pathogen#expand(dir[0:-6].name.sep.'after'), '!pathogen#is_disabled(v:val[0:-7])')) + [dir]
else
let list += [dir] + filter(pathogen#expand(dir.sep.name), '!pathogen#is_disabled(v:val)')
endif
endfor
let &rtp = pathogen#join(pathogen#uniq(list))
return 1
endfunction
let s:done_bundles = {}
" Invoke :helptags on all non-$VIM doc directories in runtimepath.
function! pathogen#helptags() abort
let sep = pathogen#slash()
for glob in pathogen#split(&rtp)
for dir in map(split(glob(glob), "\n"), 'v:val.sep."/doc/".sep')
if (dir)[0 : strlen($VIMRUNTIME)] !=# $VIMRUNTIME.sep && filewritable(dir) == 2 && !empty(split(glob(dir.'*.txt'))) && (!filereadable(dir.'tags') || filewritable(dir.'tags'))
silent! execute 'helptags' pathogen#fnameescape(dir)
endif
endfor
endfor
endfunction
command! -bar Helptags :call pathogen#helptags()
" Execute the given command. This is basically a backdoor for --remote-expr.
function! pathogen#execute(...) abort
for command in a:000
execute command
endfor
return ''
endfunction
" Section: Unofficial
function! pathogen#is_absolute(path) abort
return a:path =~# (has('win32') ? '^\%([\\/]\|\w:\)[\\/]\|^[~$]' : '^[/~$]')
endfunction
" Given a string, returns all possible permutations of comma delimited braced
" alternatives of that string. pathogen#expand('/{a,b}/{c,d}') yields
" ['/a/c', '/a/d', '/b/c', '/b/d']. Empty braces are treated as a wildcard
" and globbed. Actual globs are preserved.
function! pathogen#expand(pattern) abort
if a:pattern =~# '{[^{}]\+}'
let [pre, pat, post] = split(substitute(a:pattern, '\(.\{-\}\){\([^{}]\+\)}\(.*\)', "\\1\001\\2\001\\3", ''), "\001", 1)
let found = map(split(pat, ',', 1), 'pre.v:val.post')
let results = []
for pattern in found
call extend(results, pathogen#expand(pattern))
endfor
return results
elseif a:pattern =~# '{}'
let pat = matchstr(a:pattern, '^.*{}[^*]*\%($\|[\\/]\)')
let post = a:pattern[strlen(pat) : -1]
return map(split(glob(substitute(pat, '{}', '*', 'g')), "\n"), 'v:val.post')
else
return [a:pattern]
endif
endfunction
" \ on Windows unless shellslash is set, / everywhere else.
function! pathogen#slash() abort
return !exists("+shellslash") || &shellslash ? '/' : '\'
endfunction
function! pathogen#separator() abort
return pathogen#slash()
endfunction
" Convenience wrapper around glob() which returns a list.
function! pathogen#glob(pattern) abort
let files = split(glob(a:pattern),"\n")
return map(files,'substitute(v:val,"[".pathogen#slash()."/]$","","")')
endfunction "}}}1
" Like pathogen#glob(), only limit the results to directories.
function! pathogen#glob_directories(pattern) abort
return filter(pathogen#glob(a:pattern),'isdirectory(v:val)')
endfunction "}}}1
" Remove duplicates from a list.
function! pathogen#uniq(list) abort
let i = 0
let seen = {}
while i < len(a:list)
if (a:list[i] ==# '' && exists('empty')) || has_key(seen,a:list[i])
call remove(a:list,i)
elseif a:list[i] ==# ''
let i += 1
let empty = 1
else
let seen[a:list[i]] = 1
let i += 1
endif
endwhile
return a:list
endfunction
" Backport of fnameescape().
function! pathogen#fnameescape(string) abort
if exists('*fnameescape')
return fnameescape(a:string)
elseif a:string ==# '-'
return '\-'
else
return substitute(escape(a:string," \t\n*?[{`$\\%#'\"|!<"),'^[+>]','\\&','')
endif
endfunction
" Like findfile(), but hardcoded to use the runtimepath.
function! pathogen#runtime_findfile(file,count) abort "{{{1
let rtp = pathogen#join(1,pathogen#split(&rtp))
let file = findfile(a:file,rtp,a:count)
if file ==# ''
return ''
else
return fnamemodify(file,':p')
endif
endfunction
" Section: Deprecated
function! s:warn(msg) abort
echohl WarningMsg
echomsg a:msg
echohl NONE
endfunction
" Prepend all subdirectories of path to the rtp, and append all 'after'
" directories in those subdirectories. Deprecated.
function! pathogen#runtime_prepend_subdirectories(path) abort
call s:warn('Change pathogen#runtime_prepend_subdirectories('.string(a:path).') to pathogen#infect('.string(a:path.'/{}').')')
return pathogen#surround(a:path . pathogen#slash() . '{}')
endfunction
function! pathogen#incubate(...) abort
let name = a:0 ? a:1 : 'bundle/{}'
call s:warn('Change pathogen#incubate('.(a:0 ? string(a:1) : '').') to pathogen#infect('.string(name).')')
return pathogen#interpose(name)
endfunction
" Deprecated alias for pathogen#interpose().
function! pathogen#runtime_append_all_bundles(...) abort
if a:0
call s:warn('Change pathogen#runtime_append_all_bundles('.string(a:1).') to pathogen#infect('.string(a:1.'/{}').')')
else
call s:warn('Change pathogen#runtime_append_all_bundles() to pathogen#infect()')
endif
return pathogen#interpose(a:0 ? a:1 . '/{}' : 'bundle/{}')
endfunction
if exists(':Vedit')
finish
endif
let s:vopen_warning = 0
function! s:find(count,cmd,file,lcd)
let rtp = pathogen#join(1,pathogen#split(&runtimepath))
let file = pathogen#runtime_findfile(a:file,a:count)
if file ==# ''
return "echoerr 'E345: Can''t find file \"".a:file."\" in runtimepath'"
endif
if !s:vopen_warning
let s:vopen_warning = 1
let warning = '|echohl WarningMsg|echo "Install scriptease.vim to continue using :V'.a:cmd.'"|echohl NONE'
else
let warning = ''
endif
if a:lcd
let path = file[0:-strlen(a:file)-2]
execute 'lcd `=path`'
return a:cmd.' '.pathogen#fnameescape(a:file) . warning
else
return a:cmd.' '.pathogen#fnameescape(file) . warning
endif
endfunction
function! s:Findcomplete(A,L,P)
let sep = pathogen#slash()
let cheats = {
\'a': 'autoload',
\'d': 'doc',
\'f': 'ftplugin',
\'i': 'indent',
\'p': 'plugin',
\'s': 'syntax'}
if a:A =~# '^\w[\\/]' && has_key(cheats,a:A[0])
let request = cheats[a:A[0]].a:A[1:-1]
else
let request = a:A
endif
let pattern = substitute(request,'/\|\'.sep,'*'.sep,'g').'*'
let found = {}
for path in pathogen#split(&runtimepath)
let path = expand(path, ':p')
let matches = split(glob(path.sep.pattern),"\n")
call map(matches,'isdirectory(v:val) ? v:val.sep : v:val')
call map(matches,'expand(v:val, ":p")[strlen(path)+1:-1]')
for match in matches
let found[match] = 1
endfor
endfor
return sort(keys(found))
endfunction
command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Ve :execute s:find(<count>,'edit<bang>',<q-args>,0)
command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Vedit :execute s:find(<count>,'edit<bang>',<q-args>,0)
command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Vopen :execute s:find(<count>,'edit<bang>',<q-args>,1)
command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Vsplit :execute s:find(<count>,'split',<q-args>,<bang>1)
command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Vvsplit :execute s:find(<count>,'vsplit',<q-args>,<bang>1)
command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Vtabedit :execute s:find(<count>,'tabedit',<q-args>,<bang>1)
command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Vpedit :execute s:find(<count>,'pedit',<q-args>,<bang>1)
command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Vread :execute s:find(<count>,'read',<q-args>,<bang>1)
" vim:set et sw=2 foldmethod=expr foldexpr=getline(v\:lnum)=~'^\"\ Section\:'?'>1'\:getline(v\:lnum)=~#'^fu'?'a1'\:getline(v\:lnum)=~#'^endf'?'s1'\:'=':

View file

@ -0,0 +1,41 @@
#!/bin/bash
set -e
echo 'Installing Awesome Vim from '$1
cd $1
VIMRC="set runtimepath+=$1
source $1/vimrcs/basic.vim
source $1/vimrcs/filetypes.vim
source $1/vimrcs/plugins_config.vim
source $1/vimrcs/extended.vim
try
source $1/my_configs.vim
catch
endtry"
if [ $2 == "--all" ]; then
USERS=($(ls -l /home | awk '{if(NR>1)print $9}'))
for user in ${USERS[*]}; do
homepath=$(eval echo "~$user")
IFS=''
echo $VIMRC > ${homepath}/.vimrc
unset IFS
echo "Installed the Ultimate Vim configuration for user $user successfully! Enjoy :-)"
done
echo "Installed the Ultimate Vim configuration successfully! Enjoy :-)"
exit 0
else
SELECTED_USERS=(${@:2})
echo "Selected users: ${SELECTED_USERS[@]}"
for user in ${SELECTED_USERS[@]}; do
homepath=$(eval echo "~$user")
IFS=''
echo $VIMRC > ${homepath}/.vimrc
unset IFS
echo "Installed the Ultimate Vim configuration for user $user successfully! Enjoy :-)"
done
exit 0
fi

18
install_awesome_vimrc.sh Normal file
View file

@ -0,0 +1,18 @@
#!/bin/sh
set -e
cd ~/.vim_runtime
echo 'set runtimepath+=~/.vim_runtime
source ~/.vim_runtime/vimrcs/basic.vim
source ~/.vim_runtime/vimrcs/filetypes.vim
source ~/.vim_runtime/vimrcs/plugins_config.vim
source ~/.vim_runtime/vimrcs/extended.vim
try
source ~/.vim_runtime/my_configs.vim
catch
endtry' > ~/.vimrc
echo "Installed the Ultimate Vim configuration successfully! Enjoy :-)"

6
install_basic_vimrc.sh Normal file
View file

@ -0,0 +1,6 @@
#!/bin/sh
set -e
cd ~/.vim_runtime
cat ~/.vim_runtime/vimrcs/basic.vim > ~/.vimrc
echo "Installed the Basic Vim configuration successfully! Enjoy :-)"

View file

@ -0,0 +1,606 @@
" Vim color file --- psc (peak sea color) "Lite version"
" Maintainer: Pan, Shi Zhu <Go to the following URL for my email>
" URL: http://vim.sourceforge.net/scripts/script.php?script_id=760
" Last Change: 5 Feb 2010
" Version: 3.4
"
" Comments and e-mails are welcomed, thanks.
"
" The peaksea color is simply a colorscheme with the default settings of
" the original ps_color. Lite version means there's no custom settings
" and fancy features such as integration with reloaded.vim
"
" The full version of ps_color.vim will be maintained until Vim 8.
" By then there will be only the lite version: peaksea.vim
"
" Note: Please set the background option in your .vimrc and/or .gvimrc
"
" It is much better *not* to set 'background' option inside
" a colorscheme file. because ":set background" improperly
" may cause colorscheme be sourced twice
"
" Color Scheme Overview:
" :ru syntax/hitest.vim
"
" Relevant Help:
" :h highlight-groups
" :h psc-cterm-color-table
"
" Colors Order:
" #rrggbb
"
hi clear
if exists("syntax_on")
syntax reset
endif
let g:colors_name = "peaksea"
" I don't want to abuse folding, but here folding is used to avoid confusion.
if &background=='light'
" for background=light {{{2
" LIGHT COLOR DEFINE START
hi Normal guifg=#000000 guibg=#e0e0e0 gui=NONE
hi Search guifg=White guibg=DarkRed gui=NONE
hi Visual guifg=NONE guibg=#a6caf0 gui=NONE
hi Cursor guifg=#f0f0f0 guibg=#008000 gui=NONE
" The idea of CursorIM is pretty good, however, the feature is still buggy
" in the current version (Vim 7.0).
" The following line will be kept commented until the bug fixed.
"
" hi CursorIM guifg=#f0f0f0 guibg=#800080
hi Special guifg=#907000 guibg=NONE gui=NONE
hi Comment guifg=#606000 guibg=NONE gui=NONE
hi Number guifg=#907000 guibg=NONE gui=NONE
hi Constant guifg=#007068 guibg=NONE gui=NONE
hi StatusLine guifg=fg guibg=#a6caf0 gui=NONE
hi LineNr guifg=#686868 guibg=NONE gui=NONE
hi Question guifg=fg guibg=#d0d090 gui=NONE
hi PreProc guifg=#009030 guibg=NONE gui=NONE
hi Statement guifg=#2060a8 guibg=NONE gui=NONE
hi Type guifg=#0850a0 guibg=NONE gui=NONE
hi Todo guifg=#800000 guibg=#e0e090 gui=NONE
" NOTE THIS IS IN THE WARM SECTION
hi Error guifg=#c03000 guibg=NONE gui=NONE
hi Identifier guifg=#a030a0 guibg=NONE gui=NONE
hi ModeMsg guifg=fg guibg=#b0b0e0 gui=NONE
hi VisualNOS guifg=fg guibg=#b0b0e0 gui=NONE
hi SpecialKey guifg=#1050a0 guibg=NONE gui=NONE
hi NonText guifg=#002090 guibg=#d0d0d0 gui=NONE
hi Directory guifg=#a030a0 guibg=NONE gui=NONE
hi ErrorMsg guifg=fg guibg=#f0b090 gui=NONE
hi MoreMsg guifg=#489000 guibg=NONE gui=NONE
hi Title guifg=#a030a0 guibg=NONE gui=NONE
hi WarningMsg guifg=#b02000 guibg=NONE gui=NONE
hi WildMenu guifg=fg guibg=#d0d090 gui=NONE
hi Folded guifg=NONE guibg=#b0e0b0 gui=NONE
hi FoldColumn guifg=fg guibg=NONE gui=NONE
hi DiffAdd guifg=NONE guibg=#b0b0e0 gui=NONE
hi DiffChange guifg=NONE guibg=#e0b0e0 gui=NONE
hi DiffDelete guifg=#002090 guibg=#d0d0d0 gui=NONE
hi DiffText guifg=NONE guibg=#c0e080 gui=NONE
hi SignColumn guifg=fg guibg=#90e090 gui=NONE
hi IncSearch guifg=White guibg=DarkRed gui=NONE
hi StatusLineNC guifg=fg guibg=#c0c0c0 gui=NONE
hi VertSplit guifg=fg guibg=#c0c0c0 gui=NONE
hi Underlined guifg=#6a5acd guibg=NONE gui=underline
hi Ignore guifg=bg guibg=NONE
" NOTE THIS IS IN THE WARM SECTION
if v:version >= 700
if has('spell')
hi SpellBad guifg=NONE guibg=NONE guisp=#c03000
hi SpellCap guifg=NONE guibg=NONE guisp=#2060a8
hi SpellRare guifg=NONE guibg=NONE guisp=#a030a0
hi SpellLocal guifg=NONE guibg=NONE guisp=#007068
endif
hi Pmenu guifg=fg guibg=#e0b0e0
hi PmenuSel guifg=#f0f0f0 guibg=#806060 gui=NONE
hi PmenuSbar guifg=fg guibg=#c0c0c0 gui=NONE
hi PmenuThumb guifg=fg guibg=#c0e080 gui=NONE
hi TabLine guifg=fg guibg=#c0c0c0 gui=NONE
hi TabLineFill guifg=fg guibg=#c0c0c0 gui=NONE
hi TabLineSel guifg=fg guibg=NONE gui=NONE
hi CursorColumn guifg=NONE guibg=#f0b090
hi CursorLine guifg=NONE guibg=NONE gui=underline
hi MatchParen guifg=NONE guibg=#c0e080
endif
" LIGHT COLOR DEFINE END
" Vim 7 added stuffs
if v:version >= 700
hi Ignore gui=NONE
" the gui=undercurl guisp could only support in Vim 7
if has('spell')
hi SpellBad gui=undercurl
hi SpellCap gui=undercurl
hi SpellRare gui=undercurl
hi SpellLocal gui=undercurl
endif
hi TabLine gui=underline
hi TabLineFill gui=underline
hi CursorLine gui=underline
endif
" For reversed stuffs, clear the reversed prop and set the bold prop again
hi IncSearch gui=bold
hi StatusLine gui=bold
hi StatusLineNC gui=bold
hi VertSplit gui=bold
hi Visual gui=bold
" Enable the bold property
hi Question gui=bold
hi DiffText gui=bold
hi Statement gui=bold
hi Type gui=bold
hi MoreMsg gui=bold
hi ModeMsg gui=bold
hi NonText gui=bold
hi Title gui=bold
hi DiffDelete gui=bold
hi TabLineSel gui=bold
" gui define for background=light end here
" generally, a dumb terminal is dark, we assume the light terminal has 256
" color support.
if &t_Co==8 || &t_Co==16
set t_Co=256
endif
if &t_Co==256
" 256color light terminal support here
hi Normal ctermfg=16 ctermbg=254 cterm=NONE
" Comment/Uncomment the following line to disable/enable transparency
"hi Normal ctermfg=16 ctermbg=NONE cterm=NONE
hi Search ctermfg=White ctermbg=DarkRed cterm=NONE
hi Visual ctermfg=NONE ctermbg=153 cterm=NONE
hi Cursor ctermfg=255 ctermbg=28 cterm=NONE
" hi CursorIM ctermfg=255 ctermbg=90
hi Special ctermfg=94 ctermbg=NONE cterm=NONE
hi Comment ctermfg=58 ctermbg=NONE cterm=NONE
hi Number ctermfg=94 ctermbg=NONE cterm=NONE
hi Constant ctermfg=23 ctermbg=NONE cterm=NONE
hi StatusLine ctermfg=fg ctermbg=153 cterm=NONE
hi LineNr ctermfg=242 ctermbg=NONE cterm=NONE
hi Question ctermfg=fg ctermbg=186 cterm=NONE
hi PreProc ctermfg=29 ctermbg=NONE cterm=NONE
hi Statement ctermfg=25 ctermbg=NONE cterm=NONE
hi Type ctermfg=25 ctermbg=NONE cterm=NONE
hi Todo ctermfg=88 ctermbg=186 cterm=NONE
" NOTE THIS IS IN THE WARM SECTION
hi Error ctermfg=130 ctermbg=NONE cterm=NONE
hi Identifier ctermfg=133 ctermbg=NONE cterm=NONE
hi ModeMsg ctermfg=fg ctermbg=146 cterm=NONE
hi VisualNOS ctermfg=fg ctermbg=146 cterm=NONE
hi SpecialKey ctermfg=25 ctermbg=NONE cterm=NONE
hi NonText ctermfg=18 ctermbg=252 cterm=NONE
" Comment/Uncomment the following line to disable/enable transparency
"hi NonText ctermfg=18 ctermbg=NONE cterm=NONE
hi Directory ctermfg=133 ctermbg=NONE cterm=NONE
hi ErrorMsg ctermfg=fg ctermbg=216 cterm=NONE
hi MoreMsg ctermfg=64 ctermbg=NONE cterm=NONE
hi Title ctermfg=133 ctermbg=NONE cterm=NONE
hi WarningMsg ctermfg=124 ctermbg=NONE cterm=NONE
hi WildMenu ctermfg=fg ctermbg=186 cterm=NONE
hi Folded ctermfg=NONE ctermbg=151 cterm=NONE
hi FoldColumn ctermfg=fg ctermbg=NONE cterm=NONE
hi DiffAdd ctermfg=NONE ctermbg=146 cterm=NONE
hi DiffChange ctermfg=NONE ctermbg=182 cterm=NONE
hi DiffDelete ctermfg=18 ctermbg=252 cterm=NONE
hi DiffText ctermfg=NONE ctermbg=150 cterm=NONE
hi SignColumn ctermfg=fg ctermbg=114 cterm=NONE
hi IncSearch ctermfg=White ctermbg=DarkRed cterm=NONE
hi StatusLineNC ctermfg=fg ctermbg=250 cterm=NONE
hi VertSplit ctermfg=fg ctermbg=250 cterm=NONE
hi Underlined ctermfg=62 ctermbg=NONE cterm=underline
hi Ignore ctermfg=bg ctermbg=NONE
" NOTE THIS IS IN THE WARM SECTION
if v:version >= 700
if has('spell')
if 0
" ctermsp is not supported in Vim7, we ignore it.
hi SpellBad cterm=undercurl ctermbg=NONE ctermfg=130
hi SpellCap cterm=undercurl ctermbg=NONE ctermfg=25
hi SpellRare cterm=undercurl ctermbg=NONE ctermfg=133
hi SpellLocal cterm=undercurl ctermbg=NONE ctermfg=23
else
hi SpellBad cterm=undercurl ctermbg=NONE ctermfg=NONE
hi SpellCap cterm=undercurl ctermbg=NONE ctermfg=NONE
hi SpellRare cterm=undercurl ctermbg=NONE ctermfg=NONE
hi SpellLocal cterm=undercurl ctermbg=NONE ctermfg=NONE
endif
endif
hi Pmenu ctermfg=fg ctermbg=182
hi PmenuSel ctermfg=255 ctermbg=95 cterm=NONE
hi PmenuSbar ctermfg=fg ctermbg=250 cterm=NONE
hi PmenuThumb ctermfg=fg ctermbg=150 cterm=NONE
hi TabLine ctermfg=fg ctermbg=250 cterm=NONE
hi TabLineFill ctermfg=fg ctermbg=250 cterm=NONE
hi TabLineSel ctermfg=fg ctermbg=NONE cterm=NONE
hi CursorColumn ctermfg=NONE ctermbg=216
hi CursorLine ctermfg=NONE ctermbg=NONE cterm=underline
hi MatchParen ctermfg=NONE ctermbg=150
endif
hi TabLine cterm=underline
hi TabLineFill cterm=underline
hi CursorLine cterm=underline
" For reversed stuffs, clear the reversed prop and set the bold prop again
hi IncSearch cterm=bold
hi StatusLine cterm=bold
hi StatusLineNC cterm=bold
hi VertSplit cterm=bold
hi Visual cterm=bold
hi NonText cterm=bold
hi Question cterm=bold
hi Title cterm=bold
hi DiffDelete cterm=bold
hi DiffText cterm=bold
hi Statement cterm=bold
hi Type cterm=bold
hi MoreMsg cterm=bold
hi ModeMsg cterm=bold
hi TabLineSel cterm=bold
"hi lCursor ctermfg=bg ctermbg=fg cterm=NONE
endif " t_Co==256
" }}}2
elseif &background=='dark'
" for background=dark {{{2
" DARK COLOR DEFINE START
hi Normal guifg=#d0d0d0 guibg=#202020 gui=NONE
hi Comment guifg=#d0d090 guibg=NONE gui=NONE
hi Constant guifg=#80c0e0 guibg=NONE gui=NONE
hi Number guifg=#e0c060 guibg=NONE gui=NONE
hi Identifier guifg=#f0c0f0 guibg=NONE gui=NONE
hi Statement guifg=#c0d8f8 guibg=NONE gui=NONE
hi PreProc guifg=#60f080 guibg=NONE gui=NONE
hi Type guifg=#b0d0f0 guibg=NONE gui=NONE
hi Special guifg=#e0c060 guibg=NONE gui=NONE
hi Error guifg=#f08060 guibg=NONE gui=NONE
hi Todo guifg=#800000 guibg=#d0d090 gui=NONE
hi Search guifg=White guibg=DarkRed gui=NONE
hi Visual guifg=#000000 guibg=#a6caf0 gui=NONE
hi Cursor guifg=#000000 guibg=#00f000 gui=NONE
" NOTE THIS IS IN THE COOL SECTION
" hi CursorIM guifg=#000000 guibg=#f000f0 gui=NONE
hi StatusLine guifg=#000000 guibg=#a6caf0 gui=NONE
hi LineNr guifg=#b0b0b0 guibg=NONE gui=NONE
hi Question guifg=#000000 guibg=#d0d090 gui=NONE
hi ModeMsg guifg=fg guibg=#000080 gui=NONE
hi VisualNOS guifg=fg guibg=#000080 gui=NONE
hi SpecialKey guifg=#b0d0f0 guibg=NONE gui=NONE
hi NonText guifg=#202020 guibg=#202020 gui=NONE
hi Directory guifg=#80c0e0 guibg=NONE gui=NONE
hi ErrorMsg guifg=#d0d090 guibg=#800000 gui=NONE
hi MoreMsg guifg=#c0e080 guibg=NONE gui=NONE
hi Title guifg=#f0c0f0 guibg=NONE gui=NONE
hi WarningMsg guifg=#f08060 guibg=NONE gui=NONE
hi WildMenu guifg=#000000 guibg=#d0d090 gui=NONE
hi Folded guifg=#aaaaaa guibg=#333333 gui=NONE
hi FoldColumn guifg=#202020 guibg=NONE gui=NONE
hi DiffAdd guifg=NONE guibg=#000080 gui=NONE
hi DiffChange guifg=NONE guibg=#800080 gui=NONE
hi DiffDelete guifg=#6080f0 guibg=#202020 gui=NONE
hi DiffText guifg=#000000 guibg=#c0e080 gui=NONE
hi SignColumn guifg=#e0e0e0 guibg=#202020 gui=NONE
hi IncSearch guifg=White guibg=DarkRed gui=NONE
hi StatusLineNC guifg=#000000 guibg=#c0c0c0 gui=NONE
hi VertSplit guifg=#000000 guibg=#c0c0c0 gui=NONE
hi Underlined guifg=#80a0ff guibg=NONE gui=underline
hi Ignore guifg=#000000 guibg=NONE
" NOTE THIS IS IN THE COOL SECTION
if v:version >= 700
if has('spell')
" the guisp= could only support in Vim 7
hi SpellBad guifg=NONE guibg=NONE guisp=#f08060
hi SpellCap guifg=NONE guibg=NONE guisp=#6080f0
hi SpellRare guifg=NONE guibg=NONE guisp=#f0c0f0
hi SpellLocal guifg=NONE guibg=NONE guisp=#c0d8f8
endif
hi Pmenu guifg=#dddddd guibg=#444444 gui=NONE ctermfg=NONE ctermbg=NONE cterm=NONE
hi PmenuSel guifg=#000000 guibg=#ffffff gui=NONE ctermfg=NONE ctermbg=NONE cterm=NONE
hi TabLine guifg=fg guibg=#008000 gui=NONE
hi TabLineFill guifg=fg guibg=#008000 gui=NONE
hi TabLineSel guifg=fg guibg=NONE gui=NONE
hi CursorColumn guifg=NONE guibg=#800000 gui=NONE
hi CursorLine guifg=NONE guibg=NONE gui=underline
hi MatchParen guifg=NONE guibg=#800080
endif
" DARK COLOR DEFINE END
" Vim 7 added stuffs
if v:version >= 700
hi Ignore gui=NONE
" the gui=undercurl could only support in Vim 7
if has('spell')
hi SpellBad gui=undercurl
hi SpellCap gui=undercurl
hi SpellRare gui=undercurl
hi SpellLocal gui=undercurl
endif
hi TabLine gui=underline
hi TabLineFill gui=underline
hi Underlined gui=underline
hi CursorLine gui=underline
endif
" gui define for background=dark end here
if &t_Co==8 || &t_Co==16
" for 8-color and 16-color term
hi Normal ctermfg=LightGrey ctermbg=Black
hi Special ctermfg=Yellow ctermbg=bg
hi Comment ctermfg=DarkYellow ctermbg=bg
hi Constant ctermfg=Blue ctermbg=bg
hi Number ctermfg=Yellow ctermbg=bg
hi LineNr ctermfg=DarkGrey ctermbg=bg
hi PreProc ctermfg=Green ctermbg=bg
hi Statement ctermfg=Cyan ctermbg=bg
hi Type ctermfg=Cyan ctermbg=bg
hi Error ctermfg=Red ctermbg=bg
hi Identifier ctermfg=Magenta ctermbg=bg
hi SpecialKey ctermfg=Cyan ctermbg=bg
hi NonText ctermfg=Blue ctermbg=bg
hi Directory ctermfg=Blue ctermbg=bg
hi MoreMsg ctermfg=Green ctermbg=bg
hi Title ctermfg=Magenta ctermbg=bg
hi WarningMsg ctermfg=Red ctermbg=bg
hi DiffDelete ctermfg=Blue ctermbg=bg
hi Search ctermfg=NONE ctermbg=DarkRed
hi Visual ctermfg=Black ctermbg=DarkCyan
hi Cursor ctermfg=Black ctermbg=Green
hi StatusLine ctermfg=Black ctermbg=DarkCyan
hi Question ctermfg=Black ctermbg=DarkYellow
hi Todo ctermfg=DarkRed ctermbg=DarkYellow
hi Folded ctermfg=DarkGrey ctermbg=DarkGrey
hi FoldColumn ctermfg=DarkGrey ctermbg=NONE
hi ModeMsg ctermfg=Grey ctermbg=DarkBlue
hi VisualNOS ctermfg=Grey ctermbg=DarkBlue
hi ErrorMsg ctermfg=DarkYellow ctermbg=DarkRed
hi WildMenu ctermfg=Black ctermbg=DarkYellow
hi SignColumn ctermfg=White ctermbg=DarkGreen
hi DiffText ctermfg=Black ctermbg=DarkYellow
if v:version >= 700
if has('spell')
hi SpellBad ctermfg=NONE ctermbg=DarkRed
hi SpellCap ctermfg=NONE ctermbg=DarkBlue
hi SpellRare ctermfg=NONE ctermbg=DarkMagenta
hi SpellLocal ctermfg=NONE ctermbg=DarkGreen
endif
hi Pmenu ctermfg=White ctermbg=DarkGrey
hi PmenuSel ctermfg=Black ctermbg=White
hi TabLine ctermfg=fg ctermbg=Black cterm=underline
hi TabLineFill ctermfg=fg ctermbg=Black cterm=underline
hi CursorColumn ctermfg=NONE ctermbg=DarkRed
hi TabLineSel ctermfg=fg ctermbg=bg
hi CursorLine ctermfg=NONE ctermbg=bg cterm=underline
hi MatchParen ctermfg=NONE ctermbg=DarkMagenta
endif
if &t_Co==8
" 8 colour terminal support, this assumes 16 colour is available through
" setting the 'bold' attribute, will get bright foreground colour.
" However, the bright background color is not available for 8-color terms.
"
" You can manually set t_Co=16 in your .vimrc to see if your terminal
" supports 16 colours,
hi DiffText cterm=none
hi Visual cterm=none
hi Cursor cterm=none
hi Comment cterm=none
hi Todo cterm=none
hi StatusLine cterm=none
hi Question cterm=none
hi DiffChange cterm=none
hi ModeMsg cterm=none
hi VisualNOS cterm=none
hi ErrorMsg cterm=none
hi WildMenu cterm=none
hi DiffAdd cterm=none
hi Folded cterm=none
hi DiffDelete cterm=none
hi Normal cterm=none
hi PmenuThumb cterm=none
hi Search cterm=bold
hi Special cterm=bold
hi Constant cterm=bold
hi Number cterm=bold
hi LineNr cterm=bold
hi PreProc cterm=bold
hi Statement cterm=bold
hi Type cterm=bold
hi Error cterm=bold
hi Identifier cterm=bold
hi SpecialKey cterm=bold
hi NonText cterm=bold
hi MoreMsg cterm=bold
hi Title cterm=bold
hi WarningMsg cterm=bold
hi FoldColumn cterm=bold
hi SignColumn cterm=bold
hi Directory cterm=bold
hi DiffDelete cterm=bold
else
" Background > 7 is only available with 16 or more colors
hi WarningMsg cterm=none
hi Search cterm=none
hi Visual cterm=none
hi Cursor cterm=none
hi Special cterm=none
hi Comment cterm=none
hi Constant cterm=none
hi Number cterm=none
hi LineNr cterm=none
hi PreProc cterm=none
hi Todo cterm=none
hi Error cterm=none
hi Identifier cterm=none
hi Folded cterm=none
hi SpecialKey cterm=none
hi Directory cterm=none
hi ErrorMsg cterm=none
hi Normal cterm=none
hi PmenuThumb cterm=none
hi WildMenu cterm=none
hi FoldColumn cterm=none
hi SignColumn cterm=none
hi DiffAdd cterm=none
hi DiffChange cterm=none
hi Question cterm=none
hi StatusLine cterm=none
hi DiffText cterm=none
hi IncSearch cterm=reverse
hi StatusLineNC cterm=reverse
hi VertSplit cterm=reverse
" Well, well, bold font with color 0-7 is not possible.
" So, the Question, StatusLine, DiffText cannot act as expected.
hi Statement cterm=none
hi Type cterm=none
hi MoreMsg cterm=none
hi ModeMsg cterm=none
hi NonText cterm=none
hi Title cterm=none
hi VisualNOS cterm=none
hi DiffDelete cterm=none
hi TabLineSel cterm=none
endif
elseif &t_Co==256
" 256color dark terminal support here
hi Normal ctermfg=252 ctermbg=234 cterm=NONE
" Comment/Uncomment the following line to disable/enable transparency
"hi Normal ctermfg=252 ctermbg=NONE cterm=NONE
hi Comment ctermfg=186 ctermbg=NONE cterm=NONE
hi Constant ctermfg=110 ctermbg=NONE cterm=NONE
hi Number ctermfg=179 ctermbg=NONE cterm=NONE
hi Identifier ctermfg=219 ctermbg=NONE cterm=NONE
hi Statement ctermfg=153 ctermbg=NONE cterm=NONE
hi PreProc ctermfg=84 ctermbg=NONE cterm=NONE
hi Type ctermfg=153 ctermbg=NONE cterm=NONE
hi Special ctermfg=179 ctermbg=NONE cterm=NONE
hi Error ctermfg=209 ctermbg=NONE cterm=NONE
hi Todo ctermfg=88 ctermbg=186 cterm=NONE
hi Search ctermfg=White ctermbg=DarkRed cterm=NONE
hi Visual ctermfg=16 ctermbg=153 cterm=NONE
hi Cursor ctermfg=16 ctermbg=46 cterm=NONE
" NOTE THIS IS IN THE COOL SECTION
" hi CursorIM ctermfg=16 ctermbg=201 cterm=NONE
hi StatusLine ctermfg=16 ctermbg=153 cterm=NONE
hi LineNr ctermfg=249 ctermbg=NONE cterm=NONE
hi Question ctermfg=16 ctermbg=186 cterm=NONE
hi ModeMsg ctermfg=fg ctermbg=18 cterm=NONE
hi VisualNOS ctermfg=fg ctermbg=18 cterm=NONE
hi SpecialKey ctermfg=153 ctermbg=NONE cterm=NONE
hi NonText ctermfg=69 ctermbg=233 cterm=NONE
" Comment/Uncomment the following line to disable/enable transparency
"hi NonText ctermfg=69 ctermbg=NONE cterm=NONE
hi Directory ctermfg=110 ctermbg=NONE cterm=NONE
hi ErrorMsg ctermfg=186 ctermbg=88 cterm=NONE
hi MoreMsg ctermfg=150 ctermbg=NONE cterm=NONE
hi Title ctermfg=219 ctermbg=NONE cterm=NONE
hi WarningMsg ctermfg=209 ctermbg=NONE cterm=NONE
hi WildMenu ctermfg=16 ctermbg=186 cterm=NONE
hi Folded ctermfg=NONE ctermbg=DarkGrey cterm=NONE
hi FoldColumn ctermfg=DarkGrey ctermbg=NONE cterm=NONE
hi DiffAdd ctermfg=NONE ctermbg=18 cterm=NONE
hi DiffChange ctermfg=NONE ctermbg=90 cterm=NONE
hi DiffDelete ctermfg=69 ctermbg=234 cterm=NONE
hi DiffText ctermfg=16 ctermbg=150 cterm=NONE
hi SignColumn ctermfg=254 ctermbg=28 cterm=NONE
hi IncSearch ctermfg=White ctermbg=DarkRed cterm=NONE
hi StatusLineNC ctermfg=16 ctermbg=250 cterm=NONE
hi VertSplit ctermfg=16 ctermbg=250 cterm=NONE
hi Underlined ctermfg=111 ctermbg=NONE cterm=underline
hi Ignore ctermfg=16 ctermbg=NONE
" NOTE THIS IS IN THE COOL SECTION
if v:version >= 700
if has('spell')
" the ctermsp= is not supported in Vim 7 we simply ignored
if 0
hi SpellBad cterm=undercurl ctermbg=NONE ctermfg=209
hi SpellCap cterm=undercurl ctermbg=NONE ctermfg=69
hi SpellRare cterm=undercurl ctermbg=NONE ctermfg=219
hi SpellLocal cterm=undercurl ctermbg=NONE ctermfg=153
else
hi SpellBad cterm=undercurl ctermbg=NONE ctermfg=NONE
hi SpellCap cterm=undercurl ctermbg=NONE ctermfg=NONE
hi SpellRare cterm=undercurl ctermbg=NONE ctermfg=NONE
hi SpellLocal cterm=undercurl ctermbg=NONE ctermfg=NONE
endif
endif
hi Pmenu ctermfg=White ctermbg=DarkGrey
hi PmenuSel ctermfg=Black ctermbg=White cterm=NONE
hi TabLine ctermfg=fg ctermbg=Black cterm=NONE
hi TabLineFill ctermfg=fg ctermbg=Black cterm=NONE
hi TabLineSel ctermfg=fg ctermbg=NONE cterm=NONE
hi CursorColumn ctermfg=NONE ctermbg=88 cterm=NONE
hi CursorLine ctermfg=NONE ctermbg=NONE cterm=underline
hi MatchParen ctermfg=NONE ctermbg=90
hi TabLine cterm=underline
hi TabLineFill cterm=underline
hi Underlined cterm=underline
hi CursorLine cterm=underline
endif
endif " t_Co
" }}}2
endif
" Links:
"
" COLOR LINKS DEFINE START
hi link String Constant
" Character must be different from strings because in many languages
" (especially C, C++) a 'char' variable is scalar while 'string' is pointer,
" mistaken a 'char' for a 'string' will cause disaster!
hi link Character Number
hi link SpecialChar LineNr
hi link Tag Identifier
hi link cCppOut LineNr
" The following are not standard hi links,
" these are used by DrChip
hi link Warning MoreMsg
hi link Notice Constant
" these are used by Calendar
hi link CalToday PreProc
" these are used by TagList
hi link MyTagListTagName IncSearch
hi link MyTagListTagScope Constant
hi TabLineFill guifg=#9098a0 guibg=#111111
hi TabLine guifg=black guibg=#888888
hi TabLineSel guifg=white guibg=#202020 gui=bold
" COLOR LINKS DEFINE END
" vim:et:nosta:sw=2:ts=8:
" vim600:fdm=marker:fdl=1:

View file

@ -0,0 +1,30 @@
function! CustomizedTabLine()
let s = ''
let t = tabpagenr()
let i = 1
while i <= tabpagenr('$')
let buflist = tabpagebuflist(i)
let winnr = tabpagewinnr(i)
let s .= '%' . i . 'T'
let s .= (i == t ? '%1*' : '%2*')
let s .= ' '
let s .= i . ':'
let s .= '%*'
let s .= (i == t ? '%#TabLineSel#' : '%#TabLine#')
let file = bufname(buflist[winnr - 1])
let file = fnamemodify(file, ':p:t')
if file == ''
let file = '[No Name]'
endif
let s .= file
let s .= ' '
let i = i + 1
endwhile
let s .= '%T%#TabLineFill#%='
let s .= (tabpagenr('$') > 1 ? '%999XX' : 'X')
return s
endfunction
" Always show the tablilne
set stal=2
set tabline=%!CustomizedTabLine()

View file

@ -0,0 +1,11 @@
This is a version of Infinite Red's vim theme (http://blog.infinitered.com/entries/show/8) packaged to work with Tim Pope's pathogen plugin (http://www.vim.org/scripts/script.php?script_id=2332).
To use it (assuming you're using pathogen):
- go to your bundle directory (.vim/bundle or .vimbundles) and clone the repo:
git clone git@github.com:wgibbs/vim-irblack.git
- edit your .vimrc and add:
:colorscheme ir_black

View file

@ -0,0 +1,220 @@
" ir_black color scheme
" More at: http://blog.infinitered.com/entries/show/8
" ********************************************************************************
" Standard colors used in all ir_black themes:
" Note, x:x:x are RGB values
"
" normal: #f6f3e8
"
" string: #A8FF60 168:255:96
" string inner (punc, code, etc): #00A0A0 0:160:160
" number: #FF73FD 255:115:253
" comments: #7C7C7C 124:124:124
" keywords: #96CBFE 150:203:254
" operators: white
" class: #FFFFB6 255:255:182
" method declaration name: #FFD2A7 255:210:167
" regular expression: #E9C062 233:192:98
" regexp alternate: #FF8000 255:128:0
" regexp alternate 2: #B18A3D 177:138:61
" variable: #C6C5FE 198:197:254
"
" Misc colors:
" red color (used for whatever): #FF6C60 255:108:96
" light red: #FFB6B0 255:182:176
"
" brown: #E18964 good for special
"
" lightpurpleish: #FFCCFF
"
" Interface colors:
" background color: black
" cursor (where underscore is used): #FFA560 255:165:96
" cursor (where block is used): white
" visual selection: #1D1E2C
" current line: #151515 21:21:21
" search selection: #07281C 7:40:28
" line number: #3D3D3D 61:61:61
" ********************************************************************************
" The following are the preferred 16 colors for your terminal
" Colors Bright Colors
" Black #4E4E4E #7C7C7C
" Red #FF6C60 #FFB6B0
" Green #A8FF60 #CEFFAB
" Yellow #FFFFB6 #FFFFCB
" Blue #96CBFE #FFFFCB
" Magenta #FF73FD #FF9CFE
" Cyan #C6C5FE #DFDFFE
" White #EEEEEE #FFFFFF
" ********************************************************************************
set background=dark
hi clear
if exists("syntax_on")
syntax reset
endif
let colors_name = "ir_black"
"hi Example guifg=NONE guibg=NONE gui=NONE ctermfg=NONE ctermbg=NONE cterm=NONE
" General colors
hi Normal guifg=#f6f3e8 guibg=black gui=NONE ctermfg=NONE ctermbg=NONE cterm=NONE
hi NonText guifg=#070707 guibg=black gui=NONE ctermfg=black ctermbg=NONE cterm=NONE
hi Cursor guifg=black guibg=white gui=NONE ctermfg=black ctermbg=white cterm=reverse
hi LineNr guifg=#3D3D3D guibg=black gui=NONE ctermfg=darkgray ctermbg=NONE cterm=NONE
hi VertSplit guifg=#202020 guibg=#202020 gui=NONE ctermfg=darkgray ctermbg=darkgray cterm=NONE
hi StatusLine guifg=#CCCCCC guibg=#202020 gui=None ctermfg=white ctermbg=darkgray cterm=NONE
hi StatusLineNC guifg=black guibg=#202020 gui=NONE ctermfg=blue ctermbg=darkgray cterm=NONE
hi Folded guifg=#a0a8b0 guibg=#384048 gui=NONE ctermfg=NONE ctermbg=NONE cterm=NONE
hi Title guifg=#f6f3e8 guibg=NONE gui=bold ctermfg=NONE ctermbg=NONE cterm=NONE
hi Visual guifg=NONE guibg=DarkBlue gui=NONE ctermfg=NONE ctermbg=darkgray cterm=NONE
hi SpecialKey guifg=#808080 guibg=#343434 gui=NONE ctermfg=NONE ctermbg=NONE cterm=NONE
hi WildMenu guifg=white guibg=DarkRed gui=NONE ctermfg=white ctermbg=DarkRed cterm=NONE
hi PmenuSbar guifg=black guibg=white gui=NONE ctermfg=black ctermbg=white cterm=NONE
"hi Ignore guifg=gray guibg=black gui=NONE ctermfg=NONE ctermbg=NONE cterm=NONE
hi Error guifg=NONE guibg=red gui=undercurl ctermfg=white ctermbg=red cterm=NONE guisp=#FF6C60 " undercurl color
hi ErrorMsg guifg=white guibg=#FF6C60 gui=BOLD ctermfg=white ctermbg=red cterm=NONE
hi WarningMsg guifg=white guibg=#FF6C60 gui=BOLD ctermfg=white ctermbg=red cterm=NONE
" Message displayed in lower left, such as --INSERT--
hi ModeMsg guifg=black guibg=#C6C5FE gui=BOLD ctermfg=black ctermbg=cyan cterm=BOLD
if version >= 700 " Vim 7.x specific colors
hi CursorLine guifg=NONE guibg=#121212 gui=NONE ctermfg=NONE ctermbg=NONE cterm=BOLD
hi CursorColumn guifg=NONE guibg=#121212 gui=NONE ctermfg=NONE ctermbg=NONE cterm=BOLD
hi MatchParen guifg=#f6f3e8 guibg=#857b6f gui=BOLD ctermfg=white ctermbg=darkgray cterm=NONE
hi Pmenu guifg=#f6f3e8 guibg=#444444 gui=NONE ctermfg=NONE ctermbg=NONE cterm=NONE
hi PmenuSel guifg=#000000 guibg=#cae682 gui=NONE ctermfg=NONE ctermbg=NONE cterm=NONE
hi Search guifg=NONE guibg=NONE gui=NONE ctermfg=NONE ctermbg=NONE cterm=NONE
endif
" Syntax highlighting
hi Comment guifg=#7C7C7C guibg=NONE gui=NONE ctermfg=darkgray ctermbg=NONE cterm=NONE
hi String guifg=#A8FF60 guibg=NONE gui=NONE ctermfg=green ctermbg=NONE cterm=NONE
hi Number guifg=#FF73FD guibg=NONE gui=NONE ctermfg=magenta ctermbg=NONE cterm=NONE
hi Keyword guifg=#96CBFE guibg=NONE gui=NONE ctermfg=blue ctermbg=NONE cterm=NONE
hi PreProc guifg=#96CBFE guibg=NONE gui=NONE ctermfg=blue ctermbg=NONE cterm=NONE
hi Conditional guifg=#6699CC guibg=NONE gui=NONE ctermfg=blue ctermbg=NONE cterm=NONE " if else end
hi Todo guifg=#8f8f8f guibg=NONE gui=NONE ctermfg=red ctermbg=NONE cterm=NONE
hi Constant guifg=#99CC99 guibg=NONE gui=NONE ctermfg=cyan ctermbg=NONE cterm=NONE
hi Identifier guifg=#C6C5FE guibg=NONE gui=NONE ctermfg=cyan ctermbg=NONE cterm=NONE
hi Function guifg=#FFD2A7 guibg=NONE gui=NONE ctermfg=brown ctermbg=NONE cterm=NONE
hi Type guifg=#FFFFB6 guibg=NONE gui=NONE ctermfg=yellow ctermbg=NONE cterm=NONE
hi Statement guifg=#6699CC guibg=NONE gui=NONE ctermfg=lightblue ctermbg=NONE cterm=NONE
hi Special guifg=#E18964 guibg=NONE gui=NONE ctermfg=white ctermbg=NONE cterm=NONE
hi Delimiter guifg=#00A0A0 guibg=NONE gui=NONE ctermfg=cyan ctermbg=NONE cterm=NONE
hi Operator guifg=#6699CC guibg=NONE gui=NONE ctermfg=blue ctermbg=NONE cterm=NONE
hi link Character Constant
hi link Boolean Constant
hi link Float Number
hi link Repeat Statement
hi link Label Statement
hi link Exception Statement
hi link Include PreProc
hi link Define PreProc
hi link Macro PreProc
hi link PreCondit PreProc
hi link StorageClass Type
hi link Structure Type
hi link Typedef Type
hi link Tag Special
hi link SpecialChar Special
hi link SpecialComment Special
hi link Debug Special
" Special for Ruby
hi rubyRegexp guifg=#B18A3D guibg=NONE gui=NONE ctermfg=brown ctermbg=NONE cterm=NONE
hi rubyRegexpDelimiter guifg=#FF8000 guibg=NONE gui=NONE ctermfg=brown ctermbg=NONE cterm=NONE
hi rubyEscape guifg=white guibg=NONE gui=NONE ctermfg=cyan ctermbg=NONE cterm=NONE
hi rubyInterpolationDelimiter guifg=#00A0A0 guibg=NONE gui=NONE ctermfg=blue ctermbg=NONE cterm=NONE
hi rubyControl guifg=#6699CC guibg=NONE gui=NONE ctermfg=blue ctermbg=NONE cterm=NONE "and break, etc
"hi rubyGlobalVariable guifg=#FFCCFF guibg=NONE gui=NONE ctermfg=lightblue ctermbg=NONE cterm=NONE "yield
hi rubyStringDelimiter guifg=#336633 guibg=NONE gui=NONE ctermfg=lightgreen ctermbg=NONE cterm=NONE
"rubyInclude
"rubySharpBang
"rubyAccess
"rubyPredefinedVariable
"rubyBoolean
"rubyClassVariable
"rubyBeginEnd
"rubyRepeatModifier
"hi link rubyArrayDelimiter Special " [ , , ]
"rubyCurlyBlock { , , }
hi link rubyClass Keyword
hi link rubyModule Keyword
hi link rubyKeyword Keyword
hi link rubyOperator Operator
hi link rubyIdentifier Identifier
hi link rubyInstanceVariable Identifier
hi link rubyGlobalVariable Identifier
hi link rubyClassVariable Identifier
hi link rubyConstant Type
" Special for Java
" hi link javaClassDecl Type
hi link javaScopeDecl Identifier
hi link javaCommentTitle javaDocSeeTag
hi link javaDocTags javaDocSeeTag
hi link javaDocParam javaDocSeeTag
hi link javaDocSeeTagParam javaDocSeeTag
hi javaDocSeeTag guifg=#CCCCCC guibg=NONE gui=NONE ctermfg=darkgray ctermbg=NONE cterm=NONE
hi javaDocSeeTag guifg=#CCCCCC guibg=NONE gui=NONE ctermfg=darkgray ctermbg=NONE cterm=NONE
"hi javaClassDecl guifg=#CCFFCC guibg=NONE gui=NONE ctermfg=white ctermbg=NONE cterm=NONE
" Special for XML
hi link xmlTag Keyword
hi link xmlTagName Conditional
hi link xmlEndTag Identifier
" Special for HTML
hi link htmlTag Keyword
hi link htmlTagName Conditional
hi link htmlEndTag Identifier
" Special for Javascript
hi link javaScriptNumber Number
" Special for Python
"hi link pythonEscape Keyword
" Special for CSharp
hi link csXmlTag Keyword
" Amix customizations
" Tab line
hi TabLineFill guifg=#000000 guibg=#000000 gui=NONE
hi TabLine guifg=black guibg=#888888 gui=NONE
hi TabLineSel guifg=white guibg=#000000 gui=bold
" Search higlights
hi Search guifg=White guibg=DarkRed gui=NONE

View file

View file

@ -0,0 +1,38 @@
vim-peepopen
=============
A plugin for the Vim text editor. PeepOpen provides fuzzy search of filenames and paths in a programming project.
Installation
------------
Get the PeepOpen.app and open it at least once to approve the Mac OS X security dialog.
Standard:
Copy `peepopen.vim` to your `~/.vim/plugin` directory.
With Tim Pope's [Pathogen](http://github.com/tpope/vim-pathogen):
Copy the entire `vim-peepopen` plugin directory to your `~/.vim/bundle` directory.
Usage
-----
`<Leader>p` opens the current project directory with the PeepOpen application.
Use the [vim-rooter](https://github.com/airblade/vim-rooter) plugin for automatic assignment of the current working directory for projects stored in Git.
(Leader is mapped to '\' by default)
### Options
Automatically quit PeepOpen when Vim exits.
`let p:peepopen_quit = 1`
Credits
-------
- Initial Vim Plugin by [Andrew Stewart](http://www.airbladesoftware.com/).
- Some plugin boilerplate from [Rein Henrichs](http://reinh.com/).

View file

@ -0,0 +1,57 @@
" plugin/peepopen.vim
" Author: Geoffrey Grosenbach <boss@topfunky.com>
" License: MIT License
" Install this file as plugin/peepopen.vim.
" If you prefer Command-T, use this snippet in your .gvimrc:
" if has("gui_macvim")
" macmenu &File.New\ Tab key=<nop>
" map <D-t> <Plug>PeepOpen
" end
" ============================================================================
" Exit quickly when:
" - this plugin was already loaded (or disabled)
" - when 'compatible' is set
if &cp || exists("g:peepopen_loaded") && g:peepopen_loaded
finish
endif
let g:peepopen_loaded = 1
let s:save_cpo = &cpo
set cpo&vim
if !exists('g:peepopen_quit')
let g:peepopen_quit = 0
endif
function s:LaunchPeepOpenViaVim()
silent exe "!open -a PeepOpen " . shellescape(getcwd())
redraw!
endfunction
function s:QuitPeepOpenViaVim()
silent exe '!ps ax | grep PeepOpen | grep -v grep | awk "{ print $1 }" | xargs kill -QUIT'
endfunction
command! PeepOpen :call <SID>LaunchPeepOpenViaVim()
command! PeepQuit :call <SID>QuitPeepOpenViaVim()
if has('autocmd') && exists('g:peepopen_quit') && g:peepopen_quit
au VimLeave * :call <SID>QuitPeepOpenViaVim()
endif
noremap <unique> <script> <Plug>PeepOpen <SID>Launch
noremap <SID>Launch :call <SID>LaunchPeepOpenViaVim()<CR>
if !hasmapto('<Plug>PeepOpen')
map! <unique> <silent> <Leader>p <Plug>PeepOpen
endif
let &cpo = s:save_cpo
unlet s:save_cpo
" vim:set sw=2 sts=2:

1
sources_non_forked/ack.vim/.gitignore vendored Normal file
View file

@ -0,0 +1 @@
tags

View file

@ -0,0 +1,89 @@
ack.vim is distributed under the same license terms as Vim itself, which you
can find in full with `:help license` within Vim, or copied in full herein.
Copyright (c) 2007-2015 Antoine Imbert <antoine.imbert+ackvim@gmail.com>
and contributors.
Maintainers may be contacted via GitHub Issues at:
https://github.com/mileszs/ack.vim/issues
VIM LICENSE
I) There are no restrictions on distributing unmodified copies of Vim except
that they must include this license text. You can also distribute
unmodified parts of Vim, likewise unrestricted except that they must
include this license text. You are also allowed to include executables
that you made from the unmodified Vim sources, plus your own usage
examples and Vim scripts.
II) It is allowed to distribute a modified (or extended) version of Vim,
including executables and/or source code, when the following four
conditions are met:
1) This license text must be included unmodified.
2) The modified Vim must be distributed in one of the following five ways:
a) If you make changes to Vim yourself, you must clearly describe in
the distribution how to contact you. When the maintainer asks you
(in any way) for a copy of the modified Vim you distributed, you
must make your changes, including source code, available to the
maintainer without fee. The maintainer reserves the right to
include your changes in the official version of Vim. What the
maintainer will do with your changes and under what license they
will be distributed is negotiable. If there has been no negotiation
then this license, or a later version, also applies to your changes.
The current maintainer is Bram Moolenaar <Bram@vim.org>. If this
changes it will be announced in appropriate places (most likely
vim.sf.net, www.vim.org and/or comp.editors). When it is completely
impossible to contact the maintainer, the obligation to send him
your changes ceases. Once the maintainer has confirmed that he has
received your changes they will not have to be sent again.
b) If you have received a modified Vim that was distributed as
mentioned under a) you are allowed to further distribute it
unmodified, as mentioned at I). If you make additional changes the
text under a) applies to those changes.
c) Provide all the changes, including source code, with every copy of
the modified Vim you distribute. This may be done in the form of a
context diff. You can choose what license to use for new code you
add. The changes and their license must not restrict others from
making their own changes to the official version of Vim.
d) When you have a modified Vim which includes changes as mentioned
under c), you can distribute it without the source code for the
changes if the following three conditions are met:
- The license that applies to the changes permits you to distribute
the changes to the Vim maintainer without fee or restriction, and
permits the Vim maintainer to include the changes in the official
version of Vim without fee or restriction.
- You keep the changes for at least three years after last
distributing the corresponding modified Vim. When the maintainer
or someone who you distributed the modified Vim to asks you (in
any way) for the changes within this period, you must make them
available to him.
- You clearly describe in the distribution how to contact you. This
contact information must remain valid for at least three years
after last distributing the corresponding modified Vim, or as long
as possible.
e) When the GNU General Public License (GPL) applies to the changes,
you can distribute the modified Vim under the GNU GPL version 2 or
any later version.
3) A message must be added, at least in the output of the ":version"
command and in the intro screen, such that the user of the modified Vim
is able to see that it was modified. When distributing as mentioned
under 2)e) adding the message is only required for as far as this does
not conflict with the license used for the changes.
4) The contact information as required under 2)a) and 2)d) must not be
removed or changed, except that the person himself can make
corrections.
III) If you distribute a modified version of Vim, you are encouraged to use
the Vim license for your changes and make them available to the
maintainer, including the source code. The preferred way to do this is
by e-mail or by uploading the files to a server and e-mailing the URL.
If the number of changes is small (e.g., a modified Makefile) e-mailing a
context diff will do. The e-mail address to be used is
<maintainer@vim.org>
IV) It is not allowed to remove this license from the distribution of the Vim
sources, parts of it or from a modified version. You may use this
license for previous Vim releases instead of the license that they came
with, at your option.

View file

@ -0,0 +1,163 @@
# ack.vim
Run your favorite search tool from Vim, with an enhanced results list.
This plugin was designed as a Vim frontend for the programmer's search tool
[ack]. ack can be used as a replacement for 99% of the uses of `grep`. The
plugin allows you to search with ack from within Vim and shows the results in a
split window.
But here's a little secret for the Vim-seasoned: it's just a light wrapper for
Vim's [grepprg] and the [quickfix] window for match results. This makes it easy
to integrate with your own Vim configuration and use existing knowledge of core
features. It also means the plugin is flexible to use with other search tools.
[grepprg]: http://vimdoc.sourceforge.net/htmldoc/options.html#'grepprg'
[quickfix]: http://vimdoc.sourceforge.net/htmldoc/quickfix.html#quickfix
## Installation
### ack
You will need ack (>= 2.0), of course. To install it follow the
[manual](http://beyondgrep.com/install/).
### The Plugin
It is recommended to use one of the popular plugin managers for Vim. There are
many and you probably already have a preferred one, but a few examples for your
copy-and-paste convenience:
#### Pathogen
$ git clone https://github.com/mileszs/ack.vim.git ~/.vim/bundle/ack.vim
#### Vundle
```vim
Plugin 'mileszs/ack.vim'
```
#### NeoBundle
```vim
NeoBundle 'mileszs/ack.vim'
```
#### Manual (not recommended)
[Download][releases] the plugin and extract it in `~/.vim/` (or
`%PROGRAMFILES%/Vim/vimfiles` on Windows).
## Usage
:Ack [options] {pattern} [{directories}]
Search recursively in `{directories}` (which defaults to the current directory)
for the `{pattern}`.
Files containing the search term will be listed in the quickfix 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.
Just like where you use `:grep`, `:grepadd`, `:lgrep`, and :`lgrepadd`, you can
use `:Ack`, `:AckAdd`, `:LAck`, and `:LAckAdd` respectively. (See `:help Ack`
after installing, or [`doc/ack.txt`][doc] in the repo, for more information.)
For more ack help see [ack documentation](http://beyondgrep.com/documentation/).
[doc]: https://github.com/mileszs/ack.vim/blob/master/doc/ack.txt
### Keyboard Shortcuts
The quickfix results window is augmented with these convenience mappings:
? a quick summary of these keys, repeat to close
o to open (same as Enter)
O to open and close the quickfix window
go to preview file, open but maintain focus on ack.vim results
t to open in new tab
T to open in new tab without moving to it
h to open in horizontal split
H to open in horizontal split, keeping focus on the results
v to open in vertical split
gv to open in vertical split, keeping focus on the results
q to close the quickfix window
### Gotchas
To search for a pattern that contains whitespace, you need to enclose the
pattern in single quotes. For example: `:Ack 'foo bar'` to search for
'foo bar'.
Some characters have special meaning, and need to be escaped in your search
pattern. For instance, `#`. You need to escape it with `:Ack '\\\#define
foo'` to search for '#define foo'. See [issue #5].
[issue #5]: https://github.com/mileszs/ack.vim/issues/5
## Possibly FAQ
#### Can I use `ag` ([The Silver Searcher]) with this?
Absolutely, and probably other tools if their output is similar or you can
write a pattern match for it--just set `g:ackprg`. If you like, you can fall
back to Ack in case you use your vimrc on a system without Ag available:
```vim
if executable('ag')
let g:ackprg = 'ag --vimgrep'
endif
```
Since Ack is quite portable you might check a copy of it into your dotfiles
repository in `~/bin` so you'll nearly always have it available.
#### What's the difference from ag.vim?
Well... not a lot really.
Present maintainer, yours truly, [kind of wishes they never forked][sadface],
contributes to both, and wouldn't mind seeing them merged again. ag.vim got a
nice code clean-up (which ack.vim is now hopefully getting), and ack.vim picked
up a few features that haven't made their way to ag.vim, like `:AckWindow`,
optional background search execution with [vim-dispatch], and auto-previewing.
#### I don't want to jump to the first result automatically. ####
Use `:Ack!`, with bang. If you want this behavior most of the time, you might
like an abbreviation or mapping in your personal config, something like these:
```vim
cnoreabbrev Ack Ack!
nnoremap <Leader>a :Ack!<Space>
```
Most of the `:[L]Ack*` commands support this. Note that this behavior follows
the convention of Vim's built-in `:grep` and `:make` commands.
[The Silver Searcher]: https://github.com/ggreer/the_silver_searcher
[sadface]: https://github.com/mileszs/ack.vim/commit/d97090fb502d40229e6976dfec0e06636ba227d5#commitcomment-5771145
## Changelog
Please see [the GitHub releases page][releases].
## Credits
This plugin is derived from Antoine Imbert's blog post [ack and Vim
Integration][] (in particular, the function in the update to the post). [Miles
Sterrett][mileszs] packaged it up as a plugin and documented it in Vim's help
format, and since then [many contributors][contributors] have submitted
enhancements and fixes.
And of course, where would we be without [ack]. And, you know, Vim.
[ack and Vim Integration]: http://blog.ant0ine.com/typepad/2007/03/ack-and-vim-integration.html
[mileszs]: https://github.com/mileszs
[contributors]: https://github.com/mileszs/ack.vim/graphs/contributors
[ack]: http://beyondgrep.com/
[vim-dispatch]: https://github.com/tpope/vim-dispatch
[releases]: https://github.com/mileszs/ack.vim/releases

View file

@ -0,0 +1,246 @@
if exists('g:autoloaded_ack') || &cp
finish
endif
if exists('g:ack_use_dispatch')
if g:ack_use_dispatch && !exists(':Dispatch')
call s:Warn('Dispatch not loaded! Falling back to g:ack_use_dispatch = 0.')
let g:ack_use_dispatch = 0
endif
else
let g:ack_use_dispatch = 0
endif
"-----------------------------------------------------------------------------
" Public API
"-----------------------------------------------------------------------------
function! ack#Ack(cmd, args) "{{{
call s:Init(a:cmd)
redraw
" Local values that we'll temporarily set as options when searching
let l:grepprg = g:ackprg
let l:grepformat = '%f:%l:%c:%m,%f:%l:%m' " Include column number
" Strip some options that are meaningless for path search and set match
" format accordingly.
if s:SearchingFilepaths()
let l:grepprg = substitute(l:grepprg, '-H\|--column', '', 'g')
let l:grepformat = '%f'
endif
" Check user policy for blank searches
if empty(a:args)
if !g:ack_use_cword_for_empty_search
echo "No regular expression found."
return
endif
endif
" If no pattern is provided, search for the word under the cursor
let l:grepargs = empty(a:args) ? expand("<cword>") : a:args . join(a:000, ' ')
"Bypass search if cursor is on blank string
if l:grepargs == ""
echo "No regular expression found."
return
endif
" NOTE: we escape special chars, but not everything using shellescape to
" allow for passing arguments etc
let l:escaped_args = escape(l:grepargs, '|#%')
echo "Searching ..."
if g:ack_use_dispatch
call s:SearchWithDispatch(l:grepprg, l:escaped_args, l:grepformat)
else
call s:SearchWithGrep(a:cmd, l:grepprg, l:escaped_args, l:grepformat)
endif
" Dispatch has no callback mechanism currently, we just have to display the
" list window early and wait for it to populate :-/
call ack#ShowResults()
call s:Highlight(l:grepargs)
endfunction "}}}
function! ack#AckFromSearch(cmd, args) "{{{
let search = getreg('/')
" translate vim regular expression to perl regular expression.
let search = substitute(search, '\(\\<\|\\>\)', '\\b', 'g')
call ack#Ack(a:cmd, '"' . search . '" ' . a:args)
endfunction "}}}
function! ack#AckHelp(cmd, args) "{{{
let args = a:args . ' ' . s:GetDocLocations()
call ack#Ack(a:cmd, args)
endfunction "}}}
function! ack#AckWindow(cmd, args) "{{{
let files = tabpagebuflist()
" remove duplicated filenames (files appearing in more than one window)
let files = filter(copy(sort(files)), 'index(files,v:val,v:key+1)==-1')
call map(files, "bufname(v:val)")
" remove unnamed buffers as quickfix (empty strings before shellescape)
call filter(files, 'v:val != ""')
" expand to full path (avoid problems with cd/lcd in au QuickFixCmdPre)
let files = map(files, "shellescape(fnamemodify(v:val, ':p'))")
let args = a:args . ' ' . join(files)
call ack#Ack(a:cmd, args)
endfunction "}}}
function! ack#ShowResults() "{{{
let l:handler = s:UsingLocList() ? g:ack_lhandler : g:ack_qhandler
execute l:handler
call s:ApplyMappings()
redraw!
endfunction "}}}
"-----------------------------------------------------------------------------
" Private API
"-----------------------------------------------------------------------------
function! s:ApplyMappings() "{{{
if !s:UsingListMappings() || &filetype != 'qf'
return
endif
let l:wintype = s:UsingLocList() ? 'l' : 'c'
let l:closemap = ':' . l:wintype . 'close<CR>'
let g:ack_mappings.q = l:closemap
nnoremap <buffer> <silent> ? :call <SID>QuickHelp()<CR>
if g:ack_autoclose
" We just map the 'go' and 'gv' mappings to close on autoclose, wtf?
for key_map in items(g:ack_mappings)
execute printf("nnoremap <buffer> <silent> %s %s", get(key_map, 0), get(key_map, 1) . l:closemap)
endfor
execute "nnoremap <buffer> <silent> <CR> <CR>" . l:closemap
else
for key_map in items(g:ack_mappings)
execute printf("nnoremap <buffer> <silent> %s %s", get(key_map, 0), get(key_map, 1))
endfor
endif
if exists("g:ackpreview") " if auto preview in on, remap j and k keys
nnoremap <buffer> <silent> j j<CR><C-W><C-P>
nnoremap <buffer> <silent> k k<CR><C-W><C-P>
nmap <buffer> <silent> <Down> j
nmap <buffer> <silent> <Up> k
endif
endfunction "}}}
function! s:GetDocLocations() "{{{
let dp = ''
for p in split(&rtp, ',')
let p = p . '/doc/'
if isdirectory(p)
let dp = p . '*.txt ' . dp
endif
endfor
return dp
endfunction "}}}
function! s:Highlight(args) "{{{
if !g:ackhighlight
return
endif
let @/ = matchstr(a:args, "\\v(-)\@<!(\<)\@<=\\w+|['\"]\\zs.{-}\\ze['\"]")
call feedkeys(":let &hlsearch=1 \| echo \<CR>", "n")
endfunction "}}}
" Initialize state for an :Ack* or :LAck* search
function! s:Init(cmd) "{{{
let s:searching_filepaths = (a:cmd =~# '-g$') ? 1 : 0
let s:using_loclist = (a:cmd =~# '^l') ? 1 : 0
if g:ack_use_dispatch && s:using_loclist
call s:Warn('Dispatch does not support location lists! Proceeding with quickfix...')
let s:using_loclist = 0
endif
endfunction "}}}
function! s:QuickHelp() "{{{
execute 'edit' globpath(&rtp, 'doc/ack_quick_help.txt')
silent normal gg
setlocal buftype=nofile bufhidden=hide nobuflisted
setlocal nomodifiable noswapfile
setlocal filetype=help
setlocal nonumber norelativenumber nowrap
setlocal foldmethod=diff foldlevel=20
nnoremap <buffer> <silent> ? :q!<CR>:call ack#ShowResults()<CR>
endfunction "}}}
function! s:SearchWithDispatch(grepprg, grepargs, grepformat) "{{{
let l:makeprg_bak = &l:makeprg
let l:errorformat_bak = &l:errorformat
" We don't execute a :grep command for Dispatch, so add -g here instead
if s:SearchingFilepaths()
let l:grepprg = a:grepprg . ' -g'
else
let l:grepprg = a:grepprg
endif
try
let &l:makeprg = l:grepprg . ' ' . a:grepargs
let &l:errorformat = a:grepformat
Make
finally
let &l:makeprg = l:makeprg_bak
let &l:errorformat = l:errorformat_bak
endtry
endfunction "}}}
function! s:SearchWithGrep(grepcmd, grepprg, grepargs, grepformat) "{{{
let l:grepprg_bak = &l:grepprg
let l:grepformat_bak = &grepformat
try
let &l:grepprg = a:grepprg
let &grepformat = a:grepformat
silent execute a:grepcmd a:grepargs
finally
let &l:grepprg = l:grepprg_bak
let &grepformat = l:grepformat_bak
endtry
endfunction "}}}
" Are we finding matching files, not lines? (the -g option -- :AckFile)
function! s:SearchingFilepaths() "{{{
return get(s:, 'searching_filepaths', 0)
endfunction "}}}
" Predicate for whether mappings are enabled for list type of current search.
function! s:UsingListMappings() "{{{
if s:UsingLocList()
return g:ack_apply_lmappings
else
return g:ack_apply_qmappings
endif
endfunction "}}}
" Were we invoked with a :LAck command?
function! s:UsingLocList() "{{{
return get(s:, 'using_loclist', 0)
endfunction "}}}
function! s:Warn(msg) "{{{
echohl WarningMsg | echomsg 'Ack: ' . a:msg | echohl None
endf "}}}
let g:autoloaded_ack = 1
" vim:set et sw=2 ts=2 tw=78 fdm=marker

View file

@ -0,0 +1,315 @@
*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|)
This plugin is only available if 'compatible' is not set.
{Vi does not have any of this}
==============================================================================
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. If [!] is not given the first
occurrence is jumped to.
:AckAdd [options] {pattern} [{directory}] *:AckAdd*
Just like |:Ack|, but instead of making a new list, the matches are
appended to the current |quickfix| list.
:AckFromSearch [{directory}] *:AckFromSearch*
Just like |:Ack| but the pattern is from previous search.
:LAck [options] {pattern} [{directory}] *:LAck*
Just like |:Ack| but instead of the |quickfix| list, matches are placed in
the current |location-list|.
:LAckAdd [options] {pattern} [{directory}] *:LAckAdd*
Just like |:AckAdd| but instead of the |quickfix| list, matches are added
to the current |location-list|
:AckFile [options] {pattern} [{directory}] *:AckFile*
Search recursively in {directory} (which defaults to the current
directory) for filenames matching the {pattern}. Behaves just like the
|:grep| command, but will open the |Quickfix| window for you.
:AckHelp[!] [options] {pattern} *:AckHelp*
Search vim documentation files for the {pattern}. Behaves just like the
|:Ack| command, but searches only vim documentation .txt files
:LAckHelp [options] {pattern} *:LAckHelp*
Just like |:AckHelp| but instead of the |quickfix| list, matches are placed
in the current |location-list|.
:AckWindow[!] [options] {pattern} *:AckWindow*
Search all buffers visible in the screen (current tab page only) files for
the {pattern}.
:LAckWindow [options] {pattern} *:LAckWindow*
Just like |:AckWindow| but instead of the |quickfix| list, matches are
placed in the current |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.
Note that if you are using Dispatch.vim with |g:ack_use_dispatch|, location
lists are not supported, because Dispatch does not support them at this time.
`:LAck` versions of commands above will give a warning and proceed to use the
quickfix list instead.
See http://beyondgrep.com/ for more information on searching with ack.
==============================================================================
CONFIGURATION *ack-configuration*
*g:ackprg*
g:ackprg
Default for ubuntu: "ack-grep"
Default for other systems: "ack"
Use this option to specify the search command and its default arguments.
Example:
>
let g:ackprg = "ag --vimgrep"
<
*g:ack_default_options*
g:ack_default_options
Default: " -s -H --nocolor --nogroup --column"
Use this option to specify the default arguments given to `ack`. This is only
used if |g:ackprg| has not been customized from the default--if you are using
a custom search program instead of Ack, set your preferred options in
|g:ackprg|.
NOTE: This option may be deprecated in the future. ~
Example:
>
let g:ack_default_options =
\ " -s -H --nocolor --nogroup --column --smart-case --follow"
<
*g:ack_apply_qmappings*
g:ack_apply_qmappings
Default: 1
This option enables mappings on the |quickfix| window.
*g:ack_apply_lmappings*
g:ack_apply_lmappings
Default: 1
This option enables mappings on |location-list| windows.
*g:ack_mappings*
g:ack_mappings
Default: {
\ "t": "<C-W><CR><C-W>T",
\ "T": "<C-W><CR><C-W>TgT<C-W>j",
\ "o": "<CR>",
\ "O": "<CR><C-W><C-W>:ccl<CR>",
\ "go": "<CR><C-W>j",
\ "h": "<C-W><CR><C-W>K",
\ "H": "<C-W><CR><C-W>K<C-W>b",
\ "v": "<C-W><CR><C-W>H<C-W>b<C-W>J<C-W>t",
\ "gv": "<C-W><CR><C-W>H<C-W>b<C-W>J" }
This option list all maps create on quickfix/Location list window.
Example, if you want to open the result in the middle of the screen:
>
let g:ack_mappings = { "o": "<CR>zz" }
<
*g:ack_qhandler*
g:ack_qhandler
Default: "botright copen"
Command to open the quickview window.
If you want to open a quickview window with 30 lines you can do:
>
let g:ack_qhandler = "botright copen 30"
<
*g:ack_lhandler*
g:ack_lhandler
Default: "botright lopen"
Command to open the Location list window.
If you want to open a Location list window with 30 lines you can do:
>
let g:ack_lhandler = "botright lopen 30"
<
*g:ackhighlight*
g:ackhighlight
Default: 0
Use this option to highlight the searched term.
Example:
>
let g:ackhighlight = 1
<
*g:ack_autoclose*
g:ack_autoclose
Default: 0
Use this option to specify whether to close the quickfix window after
using any of the shortcuts.
Example:
>
let g:ack_autoclose = 1
<
*g:ack_autofold_results*
g:ack_autofold_results
Default: 0
Use this option to fold the results in quickfix by file name. Only the current
fold will be open by default and while you press 'j' and 'k' to move between the
results if you hit other fold the last one will be closed and the current will
be open.
Example:
>
let g:ack_autofold_results = 1
<
*g:ackpreview*
g:ackpreview
Default: 0
Use this option to automagically open the file with 'j' or 'k'.
Example:
>
let g:ackpreview = 1
<
*g:ack_use_dispatch*
g:ack_use_dispatch
Default: 0
Use this option to use vim-dispatch to run searches in the background, with a
variety of execution backends for different systems.
Due to limitations in Dispatch at this time, location lists are unsupported
and result windows will appear before results are ready. Still, these may be
acceptable tradeoffs for very large projects where searches are slow.
Example:
>
let g:ack_use_dispatch = 1
<
*g:ack_use_cword_for_empty_search*
g:ack_use_cword_for_empty_search
Default: 1
Use this option to enable blank searches to run against the word under the
cursor. When this option is not set, blank searches will only output an error
message.
Example:
>
let g:ack_use_cword_for_empty_search = 0
<
==============================================================================
MAPPINGS *ack-mappings*
The following keyboard shortcuts are available in the |quickfix| and
|location-list| windows:
? display a quick summary of these mappings.
o open file (same as Enter).
O open file and close the quickfix window.
go preview file (open but maintain focus on ack.vim results).
t open in a new tab.
T open in new tab without moving to it.
h open in horizontal split.
H open in horizontal split, keeping focus on the results.
v open in vertical split.
gv open in vertical split, keeping focus on the results.
q close the quickfix window.
To adjust these, see |g:ack_mappings|.
==============================================================================
Ignoring files *ack-ignore*
If you're using this plugin with ag, The Silver Searcher, bear in mind that:
- It ignores file patterns from your .gitignore and .hgignore.
- If there are other files in your source repository you don't wish to
search, you can add their patterns to an .agignore file.
==============================================================================
ISSUES AND FAQ *ack-issues-and-faq*
I don't want to jump to the first result automatically.~
Use `:Ack!`, with bang. If you want this behavior most of the time, you
might like an abbreviation or mapping in your personal config, something
like these:
>
cnoreabbrev Ack Ack!
nnoremap <Leader>a :Ack!<Space>
<
Most of the `:[L]Ack*` commands support this. Note that this behavior
follows the convention of Vim's built-in |:grep| and |:make| commands.
I use NERDTree and opening ack.vim results in a vertical split displacing it.~
You are probably using NERDTree with its default alignment at the left
side of the window. Set these custom mappings in your vimrc to work around
this:
>
let g:ack_mappings = {
\ 'v': '<C-W><CR><C-W>L<C-W>p<C-W>J<C-W>p',
\ 'gv': '<C-W><CR><C-W>L<C-W>p<C-W>J' }
<
This solution will be improved in the future.
Results show a mix of relative and absolute paths, making them hard to read.~
This is a quirk of Vim that can happen with plain |:vimgrep| too. You can
try this in your vimrc to work around it:
>
autocmd BufAdd * exe "cd" fnameescape(getcwd())
<
but for some users this may be disruptive to their Vim workflow. For more
details, see:
http://vi.stackexchange.com/a/4816/7174
https://github.com/mileszs/ack.vim/issues/143
vim:set et sw=4 ts=4 tw=78:

View file

@ -0,0 +1,15 @@
==== ack.vim quick help ===============
*?:* a quick summary of these keys, repeat to close
*o:* to open (same as Enter)
*O:* to open and close the quickfix window
*go:* to preview file, open but maintain focus on ack.vim results
*t:* to open in new tab
*T:* to open in new tab without moving to it
*h:* to open in horizontal split
*H:* to open in horizontal split, keeping focus on the results
*v:* to open in vertical split
*gv:* to open in vertical split, keeping focus on the results
*q:* to close the quickfix window
========================================

View file

@ -0,0 +1,9 @@
if exists("g:ack_autofold_results") && g:ack_autofold_results
setlocal foldlevel=0
setlocal foldmethod=expr
setlocal foldexpr=matchstr(getline(v:lnum),'^[^\|]\\+')==#matchstr(getline(v:lnum+1),'^[^\|]\\+')?1:'<1'
setlocal foldenable
setlocal foldclose=all
setlocal foldopen=all
nnoremap <buffer> j jzz
endif

View file

@ -0,0 +1,83 @@
if exists('g:loaded_ack') || &cp
finish
endif
if !exists("g:ack_default_options")
let g:ack_default_options = " -s -H --nopager --nocolor --nogroup --column"
endif
" Location of the ack utility
if !exists("g:ackprg")
if executable('ack-grep')
let g:ackprg = "ack-grep"
elseif executable('ack')
let g:ackprg = "ack"
else
finish
endif
let g:ackprg .= g:ack_default_options
endif
if !exists("g:ack_apply_qmappings")
let g:ack_apply_qmappings = !exists("g:ack_qhandler")
endif
if !exists("g:ack_apply_lmappings")
let g:ack_apply_lmappings = !exists("g:ack_lhandler")
endif
let s:ack_mappings = {
\ "t": "<C-W><CR><C-W>T",
\ "T": "<C-W><CR><C-W>TgT<C-W>j",
\ "o": "<CR>",
\ "O": "<CR><C-W>p<C-W>c",
\ "go": "<CR><C-W>p",
\ "h": "<C-W><CR><C-W>K",
\ "H": "<C-W><CR><C-W>K<C-W>b",
\ "v": "<C-W><CR><C-W>H<C-W>b<C-W>J<C-W>t",
\ "gv": "<C-W><CR><C-W>H<C-W>b<C-W>J" }
if exists("g:ack_mappings")
let g:ack_mappings = extend(s:ack_mappings, g:ack_mappings)
else
let g:ack_mappings = s:ack_mappings
endif
if !exists("g:ack_qhandler")
let g:ack_qhandler = "botright copen"
endif
if !exists("g:ack_lhandler")
let g:ack_lhandler = "botright lopen"
endif
if !exists("g:ackhighlight")
let g:ackhighlight = 0
endif
if !exists("g:ack_autoclose")
let g:ack_autoclose = 0
endif
if !exists("g:ack_autofold_results")
let g:ack_autofold_results = 0
endif
if !exists("g:ack_use_cword_for_empty_search")
let g:ack_use_cword_for_empty_search = 1
endif
command! -bang -nargs=* -complete=file Ack call ack#Ack('grep<bang>', <q-args>)
command! -bang -nargs=* -complete=file AckAdd call ack#Ack('grepadd<bang>', <q-args>)
command! -bang -nargs=* -complete=file AckFromSearch call ack#AckFromSearch('grep<bang>', <q-args>)
command! -bang -nargs=* -complete=file LAck call ack#Ack('lgrep<bang>', <q-args>)
command! -bang -nargs=* -complete=file LAckAdd call ack#Ack('lgrepadd<bang>', <q-args>)
command! -bang -nargs=* -complete=file AckFile call ack#Ack('grep<bang> -g', <q-args>)
command! -bang -nargs=* -complete=help AckHelp call ack#AckHelp('grep<bang>', <q-args>)
command! -bang -nargs=* -complete=help LAckHelp call ack#AckHelp('lgrep<bang>', <q-args>)
command! -bang -nargs=* AckWindow call ack#AckWindow('grep<bang>', <q-args>)
command! -bang -nargs=* LAckWindow call ack#AckWindow('lgrep<bang>', <q-args>)
let g:loaded_ack = 1
" vim:set et sw=2 ts=2 tw=78 fdm=marker

View file

@ -0,0 +1,22 @@
Copyright (c) 2016-2018, w0rp <devw0rp@gmail.com>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

View file

@ -0,0 +1,49 @@
" Author: Bjorn Neergaard <bjorn@neersighted.com>
" Description: ansible-lint for ansible-yaml files
function! ale_linters#ansible#ansible_lint#Handle(buffer, lines) abort
for l:line in a:lines[:10]
if match(l:line, '^Traceback') >= 0
return [{
\ 'lnum': 1,
\ 'text': 'An exception was thrown. See :ALEDetail',
\ 'detail': join(a:lines, "\n"),
\}]
endif
endfor
" Matches patterns line the following:
"
" test.yml:35: [EANSIBLE0002] Trailing whitespace
let l:pattern = '\v^([a-zA-Z]?:?[^:]+):(\d+):?(\d+)?: \[?([[:alnum:]]+)\]? (.*)$'
let l:output = []
for l:match in ale#util#GetMatches(a:lines, l:pattern)
let l:code = l:match[4]
if l:code is# 'EANSIBLE0002'
\&& !ale#Var(a:buffer, 'warn_about_trailing_whitespace')
" Skip warnings for trailing whitespace if the option is off.
continue
endif
if ale#path#IsBufferPath(a:buffer, l:match[1])
call add(l:output, {
\ 'lnum': l:match[2] + 0,
\ 'col': l:match[3] + 0,
\ 'text': l:match[5],
\ 'code': l:code,
\ 'type': l:code[:0] is# 'E' ? 'E' : 'W',
\})
endif
endfor
return l:output
endfunction
call ale#linter#Define('ansible', {
\ 'name': 'ansible',
\ 'executable': 'ansible',
\ 'command': 'ansible-lint -p %t',
\ 'callback': 'ale_linters#ansible#ansible_lint#Handle',
\})

View file

@ -0,0 +1,38 @@
" Author: nametake https://nametake.github.io
" Description: apiblueprint parser
function! ale_linters#apiblueprint#drafter#HandleErrors(buffer, lines) abort
" Matches patterns line the following:
"
" warning: (3) unable to parse response signature, expected 'response [<HTTP status code>] [(<media type>)]'; line 4, column 3k - line 4, column 22
" warning: (10) message-body asset is expected to be a pre-formatted code block, separate it by a newline and indent every of its line by 12 spaces or 3 tabs; line 30, column 5 - line 30, column 9; line 31, column 9 - line 31, column 14; line 32, column 9 - line 32, column 14
let l:pattern = '\(^.*\): (\d\+) \(.\{-\}\); line \(\d\+\), column \(\d\+\) - line \d\+, column \d\+\(.*; line \d\+, column \d\+ - line \(\d\+\), column \(\d\+\)\)\{-\}$'
let l:output = []
for l:match in ale#util#GetMatches(a:lines[2:], l:pattern)
let l:item = {
\ 'type': l:match[1] is# 'warning' ? 'W' : 'E',
\ 'text': l:match[2],
\ 'lnum': l:match[3] + 0,
\ 'col': l:match[4] + 0,
\}
if l:match[5] isnot# ''
let l:item.end_lnum = l:match[6] + 0
let l:item.end_col = l:match[7] + 0
endif
call add(l:output, l:item)
endfor
return l:output
endfunction
call ale#linter#Define('apiblueprint', {
\ 'name': 'drafter',
\ 'output_stream': 'stderr',
\ 'executable': 'drafter',
\ 'command': 'drafter --use-line-num --validate',
\ 'callback': 'ale_linters#apiblueprint#drafter#HandleErrors',
\})

View file

@ -0,0 +1,11 @@
" Author: Johannes Wienke <languitar@semipol.de>
" Description: alex for asciidoc files
call ale#linter#Define('help', {
\ 'name': 'alex',
\ 'executable': 'alex',
\ 'command': 'alex %s -t',
\ 'output_stream': 'stderr',
\ 'callback': 'ale#handlers#alex#Handle',
\ 'lint_file': 1,
\})

View file

@ -0,0 +1,9 @@
" Author: Daniel M. Capella https://github.com/polyzen
" Description: proselint for AsciiDoc files
call ale#linter#Define('asciidoc', {
\ 'name': 'proselint',
\ 'executable': 'proselint',
\ 'command': 'proselint %t',
\ 'callback': 'ale#handlers#unix#HandleAsWarning',
\})

View file

@ -0,0 +1,9 @@
" Author: rhysd https://rhysd.github.io
" Description: Redpen, a proofreading tool (http://redpen.cc)
call ale#linter#Define('asciidoc', {
\ 'name': 'redpen',
\ 'executable': 'redpen',
\ 'command': 'redpen -f asciidoc -r json %t',
\ 'callback': 'ale#handlers#redpen#HandleRedpenOutput',
\})

View file

@ -0,0 +1,4 @@
" Author: Sumner Evans <sumner.evans98@gmail.com>
" Description: write-good for AsciiDoc files
call ale#handlers#writegood#DefineLinter('asciidoc')

View file

@ -0,0 +1,34 @@
" Author: Lucas Kolstad <lkolstad@uw.edu>
" Description: gcc linter for asm files
call ale#Set('asm_gcc_executable', 'gcc')
call ale#Set('asm_gcc_options', '-Wall')
function! ale_linters#asm#gcc#GetCommand(buffer) abort
return '%e -x assembler -fsyntax-only '
\ . '-iquote ' . ale#Escape(fnamemodify(bufname(a:buffer), ':p:h'))
\ . ' ' . ale#Var(a:buffer, 'asm_gcc_options') . ' -'
endfunction
function! ale_linters#asm#gcc#Handle(buffer, lines) abort
let l:pattern = '^.\+:\(\d\+\): \([^:]\+\): \(.\+\)$'
let l:output = []
for l:match in ale#util#GetMatches(a:lines, l:pattern)
call add(l:output, {
\ 'lnum': l:match[1] + 0,
\ 'type': l:match[2] =~? 'error' ? 'E' : 'W',
\ 'text': l:match[3],
\})
endfor
return l:output
endfunction
call ale#linter#Define('asm', {
\ 'name': 'gcc',
\ 'output_stream': 'stderr',
\ 'executable_callback': ale#VarFunc('asm_gcc_executable'),
\ 'command_callback': 'ale_linters#asm#gcc#GetCommand',
\ 'callback': 'ale_linters#asm#gcc#Handle',
\})

View file

@ -0,0 +1,22 @@
" Author: kmarc <korondi.mark@gmail.com>
" Description: This file adds support for using GNU awk with sripts.
call ale#Set('awk_gawk_executable', 'gawk')
call ale#Set('awk_gawk_options', '')
function! ale_linters#awk#gawk#GetCommand(buffer) abort
" note the --source 'BEGIN ...' is to prevent
" gawk from attempting to execute the body of the script
" it is linting.
return '%e --source ' . ale#Escape('BEGIN { exit } END { exit 1 }')
\ . ale#Pad(ale#Var(a:buffer, 'awk_gawk_options'))
\ . ' -f %t --lint /dev/null'
endfunction
call ale#linter#Define('awk', {
\ 'name': 'gawk',
\ 'executable_callback': ale#VarFunc('awk_gawk_executable'),
\ 'command_callback': 'ale_linters#awk#gawk#GetCommand',
\ 'callback': 'ale#handlers#gawk#HandleGawkFormat',
\ 'output_stream': 'both'
\})

View file

@ -0,0 +1,14 @@
" Author: Ye Jingchen <ye.jingchen@gmail.com>, Ben Falconer <ben@falconers.me.uk>, jtalowell <jtalowell@protonmail.com>
" Description: A language server for C
call ale#Set('c_ccls_executable', 'ccls')
call ale#Set('c_ccls_init_options', {})
call ale#linter#Define('c', {
\ 'name': 'ccls',
\ 'lsp': 'stdio',
\ 'executable_callback': ale#VarFunc('c_ccls_executable'),
\ 'command': '%e',
\ 'project_root_callback': 'ale#handlers#ccls#GetProjectRoot',
\ 'initialization_options_callback':ale#VarFunc('c_ccls_init_options'),
\})

View file

@ -0,0 +1,27 @@
" Author: Masahiro H https://github.com/mshr-h
" Description: clang linter for c files
call ale#Set('c_clang_executable', 'clang')
call ale#Set('c_clang_options', '-std=c11 -Wall')
function! ale_linters#c#clang#GetCommand(buffer, output) abort
let l:cflags = ale#c#GetCFlags(a:buffer, a:output)
" -iquote with the directory the file is in makes #include work for
" headers in the same directory.
return '%e -S -x c -fsyntax-only'
\ . ' -iquote ' . ale#Escape(fnamemodify(bufname(a:buffer), ':p:h'))
\ . ale#Pad(l:cflags)
\ . ale#Pad(ale#Var(a:buffer, 'c_clang_options')) . ' -'
endfunction
call ale#linter#Define('c', {
\ 'name': 'clang',
\ 'output_stream': 'stderr',
\ 'executable_callback': ale#VarFunc('c_clang_executable'),
\ 'command_chain': [
\ {'callback': 'ale#c#GetMakeCommand', 'output_stream': 'stdout'},
\ {'callback': 'ale_linters#c#clang#GetCommand'}
\ ],
\ 'callback': 'ale#handlers#gcc#HandleGCCFormatWithIncludes',
\})

View file

@ -0,0 +1,23 @@
" Author: Andrey Melentyev <andrey.melentyev@protonmail.com>
" Description: Clangd language server
call ale#Set('c_clangd_executable', 'clangd')
call ale#Set('c_clangd_options', '')
function! ale_linters#c#clangd#GetProjectRoot(buffer) abort
let l:project_root = ale#path#FindNearestFile(a:buffer, 'compile_commands.json')
return !empty(l:project_root) ? fnamemodify(l:project_root, ':h') : ''
endfunction
function! ale_linters#c#clangd#GetCommand(buffer) abort
return '%e' . ale#Pad(ale#Var(a:buffer, 'c_clangd_options'))
endfunction
call ale#linter#Define('c', {
\ 'name': 'clangd',
\ 'lsp': 'stdio',
\ 'executable_callback': ale#VarFunc('c_clangd_executable'),
\ 'command_callback': 'ale_linters#c#clangd#GetCommand',
\ 'project_root_callback': 'ale_linters#c#clangd#GetProjectRoot',
\})

View file

@ -0,0 +1,42 @@
" Author: vdeurzen <tim@kompiler.org>, w0rp <devw0rp@gmail.com>,
" gagbo <gagbobada@gmail.com>, Andrej Radovic <r.andrej@gmail.com>
" Description: clang-tidy linter for c files
call ale#Set('c_clangtidy_executable', 'clang-tidy')
" Set this option to check the checks clang-tidy will apply.
" The number of checks that can be applied to C files is limited in contrast to
" C++
"
" Consult the check list in clang-tidy's documentation:
" http://clang.llvm.org/extra/clang-tidy/checks/list.html
call ale#Set('c_clangtidy_checks', ['*'])
" Set this option to manually set some options for clang-tidy.
" This will disable compile_commands.json detection.
call ale#Set('c_clangtidy_options', '')
call ale#Set('c_build_dir', '')
function! ale_linters#c#clangtidy#GetCommand(buffer) abort
let l:checks = join(ale#Var(a:buffer, 'c_clangtidy_checks'), ',')
let l:build_dir = ale#c#GetBuildDirectory(a:buffer)
" Get the extra options if we couldn't find a build directory.
let l:options = empty(l:build_dir)
\ ? ale#Var(a:buffer, 'c_clangtidy_options')
\ : ''
return '%e'
\ . (!empty(l:checks) ? ' -checks=' . ale#Escape(l:checks) : '')
\ . ' %s'
\ . (!empty(l:build_dir) ? ' -p ' . ale#Escape(l:build_dir) : '')
\ . (!empty(l:options) ? ' -- ' . l:options : '')
endfunction
call ale#linter#Define('c', {
\ 'name': 'clangtidy',
\ 'output_stream': 'stdout',
\ 'executable_callback': ale#VarFunc('c_clangtidy_executable'),
\ 'command_callback': 'ale_linters#c#clangtidy#GetCommand',
\ 'callback': 'ale#handlers#gcc#HandleGCCFormat',
\ 'lint_file': 1,
\})

View file

@ -0,0 +1,34 @@
" Author: Bart Libert <bart.libert@gmail.com>
" Description: cppcheck linter for c files
call ale#Set('c_cppcheck_executable', 'cppcheck')
call ale#Set('c_cppcheck_options', '--enable=style')
function! ale_linters#c#cppcheck#GetCommand(buffer) abort
" Search upwards from the file for compile_commands.json.
"
" If we find it, we'll `cd` to where the compile_commands.json file is,
" then use the file to set up import paths, etc.
let l:compile_commmands_path = ale#path#FindNearestFile(a:buffer, 'compile_commands.json')
let l:cd_command = !empty(l:compile_commmands_path)
\ ? ale#path#CdString(fnamemodify(l:compile_commmands_path, ':h'))
\ : ''
let l:compile_commands_option = !empty(l:compile_commmands_path)
\ ? '--project=compile_commands.json '
\ : ''
return l:cd_command
\ . '%e -q --language=c '
\ . l:compile_commands_option
\ . ale#Var(a:buffer, 'c_cppcheck_options')
\ . ' %t'
endfunction
call ale#linter#Define('c', {
\ 'name': 'cppcheck',
\ 'output_stream': 'both',
\ 'executable_callback': ale#VarFunc('c_cppcheck_executable'),
\ 'command_callback': 'ale_linters#c#cppcheck#GetCommand',
\ 'callback': 'ale#handlers#cppcheck#HandleCppCheckFormat',
\})

View file

@ -0,0 +1,28 @@
" Author: Ben Falconer <ben@falconers.me.uk>, jtalowell <jtalowell@protonmail.com>
" Description: A language server for C
call ale#Set('c_cquery_executable', 'cquery')
call ale#Set('c_cquery_cache_directory', expand('~/.cache/cquery'))
function! ale_linters#c#cquery#GetProjectRoot(buffer) abort
let l:project_root = ale#path#FindNearestFile(a:buffer, 'compile_commands.json')
if empty(l:project_root)
let l:project_root = ale#path#FindNearestFile(a:buffer, '.cquery')
endif
return !empty(l:project_root) ? fnamemodify(l:project_root, ':h') : ''
endfunction
function! ale_linters#c#cquery#GetInitializationOptions(buffer) abort
return {'cacheDirectory': ale#Var(a:buffer, 'c_cquery_cache_directory')}
endfunction
call ale#linter#Define('c', {
\ 'name': 'cquery',
\ 'lsp': 'stdio',
\ 'executable_callback': ale#VarFunc('c_cquery_executable'),
\ 'command': '%e',
\ 'project_root_callback': 'ale_linters#c#cquery#GetProjectRoot',
\ 'initialization_options_callback': 'ale_linters#c#cquery#GetInitializationOptions',
\})

View file

@ -0,0 +1,25 @@
" Author: Christian Gibbons <cgibbons@gmu.edu>
" Description: flawfinder linter for c files
call ale#Set('c_flawfinder_executable', 'flawfinder')
call ale#Set('c_flawfinder_options', '')
call ale#Set('c_flawfinder_minlevel', 1)
call ale#Set('c_flawfinder_error_severity', 6)
function! ale_linters#c#flawfinder#GetCommand(buffer) abort
" Set the minimum vulnerability level for flawfinder to bother with
let l:minlevel = ' --minlevel=' . ale#Var(a:buffer, 'c_flawfinder_minlevel')
return '%e -CDQS'
\ . ale#Pad(ale#Var(a:buffer, 'c_flawfinder_options'))
\ . l:minlevel
\ . ' %t'
endfunction
call ale#linter#Define('c', {
\ 'name': 'flawfinder',
\ 'output_stream': 'stdout',
\ 'executable_callback': ale#VarFunc('c_flawfinder_executable'),
\ 'command_callback': 'ale_linters#c#flawfinder#GetCommand',
\ 'callback': 'ale#handlers#flawfinder#HandleFlawfinderFormat',
\})

View file

@ -0,0 +1,27 @@
" Author: w0rp <devw0rp@gmail.com>
" Description: gcc linter for c files
call ale#Set('c_gcc_executable', 'gcc')
call ale#Set('c_gcc_options', '-std=c11 -Wall')
function! ale_linters#c#gcc#GetCommand(buffer, output) abort
let l:cflags = ale#c#GetCFlags(a:buffer, a:output)
" -iquote with the directory the file is in makes #include work for
" headers in the same directory.
return '%e -S -x c -fsyntax-only'
\ . ' -iquote ' . ale#Escape(fnamemodify(bufname(a:buffer), ':p:h'))
\ . ale#Pad(l:cflags)
\ . ale#Pad(ale#Var(a:buffer, 'c_gcc_options')) . ' -'
endfunction
call ale#linter#Define('c', {
\ 'name': 'gcc',
\ 'output_stream': 'stderr',
\ 'executable_callback': ale#VarFunc('c_gcc_executable'),
\ 'command_chain': [
\ {'callback': 'ale#c#GetMakeCommand', 'output_stream': 'stdout'},
\ {'callback': 'ale_linters#c#gcc#GetCommand'}
\ ],
\ 'callback': 'ale#handlers#gcc#HandleGCCFormatWithIncludes',
\})

View file

@ -0,0 +1,41 @@
" Author: Edward Larkey <edwlarkey@mac.com>
" Author: Jose Junior <jose.junior@gmail.com>
" Author: w0rp <devw0rp@gmail.com>
" Description: This file adds the foodcritic linter for Chef files.
call ale#Set('chef_foodcritic_executable', 'foodcritic')
call ale#Set('chef_foodcritic_options', '')
function! ale_linters#chef#foodcritic#GetCommand(buffer) abort
let l:options = ale#Var(a:buffer, 'chef_foodcritic_options')
return '%e' . ale#Pad(escape(l:options, '~')) . ' %s'
endfunction
function! ale_linters#chef#foodcritic#Handle(buffer, lines) abort
" Matches patterns line the following:
"
" FC002: Avoid string interpolation where not required: httpd.rb:13
let l:pattern = '\v([^:]+): (.+): ([a-zA-Z]?:?[^:]+):(\d+)$'
let l:output = []
for l:match in ale#util#GetMatches(a:lines, l:pattern)
call add(l:output, {
\ 'code': l:match[1],
\ 'text': l:match[2],
\ 'filename': l:match[3],
\ 'lnum': l:match[4] + 0,
\ 'type': 'W',
\})
endfor
return l:output
endfunction
call ale#linter#Define('chef', {
\ 'name': 'foodcritic',
\ 'executable_callback': ale#VarFunc('chef_foodcritic_executable'),
\ 'command_callback': 'ale_linters#chef#foodcritic#GetCommand',
\ 'callback': 'ale_linters#chef#foodcritic#Handle',
\ 'lint_file': 1,
\})

View file

@ -0,0 +1,34 @@
" Author: Nic West <nicwest@mailbox.org>
" Description: linter for clojure using joker https://github.com/candid82/joker
function! ale_linters#clojure#joker#HandleJokerFormat(buffer, lines) abort
" output format
" <filename>:<line>:<column>: <issue type>: <message>
let l:pattern = '\v^[a-zA-Z]?:?[^:]+:(\d+):(\d+):? ((Read error|Parse error|Parse warning|Exception): ?(.+))$'
let l:output = []
for l:match in ale#util#GetMatches(a:lines, l:pattern)
let l:type = 'E'
if l:match[4] is? 'Parse warning'
let l:type = 'W'
endif
call add(l:output, {
\ 'lnum': l:match[1] + 0,
\ 'col': l:match[2] + 0,
\ 'text': l:match[3],
\ 'type': l:type,
\})
endfor
return l:output
endfunction
call ale#linter#Define('clojure', {
\ 'name': 'joker',
\ 'output_stream': 'stderr',
\ 'executable': 'joker',
\ 'command': 'joker --working-dir %s --lint %t',
\ 'callback': 'ale_linters#clojure#joker#HandleJokerFormat',
\})

View file

@ -0,0 +1,35 @@
" Author: Yasuhiro Kiyota <yasuhiroki.duck@gmail.com>
" Description: Support cfn-python-lint for AWS Cloudformation template file
function! ale_linters#cloudformation#cfn_python_lint#Handle(buffer, lines) abort
" Matches patterns line the following:
"
" sample.template.yaml:96:7:96:15:E3012:Property Resources/Sample/Properties/FromPort should be of type Integer
let l:pattern = '\v^(.*):(\d+):(\d+):(\d+):(\d+):([[:alnum:]]+):(.*)$'
let l:output = []
for l:match in ale#util#GetMatches(a:lines, l:pattern)
let l:code = l:match[6]
if ale#path#IsBufferPath(a:buffer, l:match[1])
call add(l:output, {
\ 'lnum': l:match[2],
\ 'col': l:match[3],
\ 'end_lnum': l:match[4],
\ 'end_col': l:match[5],
\ 'code': l:code,
\ 'type': l:code[:0] is# 'E' ? 'E' : 'W',
\ 'text': l:match[7]
\})
endif
endfor
return l:output
endfunction
call ale#linter#Define('cloudformation', {
\ 'name': 'cloudformation',
\ 'executable': 'cfn-lint',
\ 'command': 'cfn-lint --template %t --format parseable',
\ 'callback': 'ale_linters#cloudformation#cfn_python_lint#Handle',
\})

View file

@ -0,0 +1,24 @@
" Author: Kenneth Benzie <k.benzie83@gmail.com>
" Description: cmakelint for cmake files
let g:ale_cmake_cmakelint_executable =
\ get(g:, 'ale_cmake_cmakelint_executable', 'cmakelint')
let g:ale_cmake_cmakelint_options =
\ get(g:, 'ale_cmake_cmakelint_options', '')
function! ale_linters#cmake#cmakelint#Executable(buffer) abort
return ale#Var(a:buffer, 'cmake_cmakelint_executable')
endfunction
function! ale_linters#cmake#cmakelint#Command(buffer) abort
return ale_linters#cmake#cmakelint#Executable(a:buffer)
\ . ' ' . ale#Var(a:buffer, 'cmake_cmakelint_options') . ' %t'
endfunction
call ale#linter#Define('cmake', {
\ 'name': 'cmakelint',
\ 'executable_callback': 'ale_linters#cmake#cmakelint#Executable',
\ 'command_callback': 'ale_linters#cmake#cmakelint#Command',
\ 'callback': 'ale#handlers#unix#HandleAsWarning',
\})

View file

@ -0,0 +1,23 @@
" Author: KabbAmine - https://github.com/KabbAmine
" Description: Coffee for checking coffee files
function! ale_linters#coffee#coffee#GetExecutable(buffer) abort
return ale#path#ResolveLocalPath(
\ a:buffer,
\ 'node_modules/.bin/coffee',
\ 'coffee'
\)
endfunction
function! ale_linters#coffee#coffee#GetCommand(buffer) abort
return ale_linters#coffee#coffee#GetExecutable(a:buffer)
\ . ' -cp -s'
endfunction
call ale#linter#Define('coffee', {
\ 'name': 'coffee',
\ 'executable_callback': 'ale_linters#coffee#coffee#GetExecutable',
\ 'command_callback': 'ale_linters#coffee#coffee#GetCommand',
\ 'output_stream': 'stderr',
\ 'callback': 'ale#handlers#gcc#HandleGCCFormat',
\})

View file

@ -0,0 +1,43 @@
" Author: Prashanth Chandra https://github.com/prashcr
" Description: coffeelint linter for coffeescript files
function! ale_linters#coffee#coffeelint#GetExecutable(buffer) abort
return ale#path#ResolveLocalPath(
\ a:buffer,
\ 'node_modules/.bin/coffeelint',
\ 'coffeelint'
\)
endfunction
function! ale_linters#coffee#coffeelint#GetCommand(buffer) abort
return ale_linters#coffee#coffeelint#GetExecutable(a:buffer)
\ . ' --stdin --reporter csv'
endfunction
function! ale_linters#coffee#coffeelint#Handle(buffer, lines) abort
" Matches patterns like the following:
"
" path,lineNumber,lineNumberEnd,level,message
" stdin,14,,error,Throwing strings is forbidden
"
" Note that we currently ignore lineNumberEnd for multiline errors
let l:pattern = 'stdin,\(\d\+\),\(\d*\),\(.\{-1,}\),\(.\+\)'
let l:output = []
for l:match in ale#util#GetMatches(a:lines, l:pattern)
call add(l:output, {
\ 'lnum': str2nr(l:match[1]),
\ 'type': l:match[3] is# 'error' ? 'E' : 'W',
\ 'text': l:match[4],
\})
endfor
return l:output
endfunction
call ale#linter#Define('coffee', {
\ 'name': 'coffeelint',
\ 'executable_callback': 'ale_linters#coffee#coffeelint#GetExecutable',
\ 'command_callback': 'ale_linters#coffee#coffeelint#GetCommand',
\ 'callback': 'ale_linters#coffee#coffeelint#Handle',
\})

View file

@ -0,0 +1,14 @@
" Author: Ye Jingchen <ye.jingchen@gmail.com>, Ben Falconer <ben@falconers.me.uk>, jtalowell <jtalowell@protonmail.com>
" Description: A language server for C++
call ale#Set('cpp_ccls_executable', 'ccls')
call ale#Set('cpp_ccls_init_options', {})
call ale#linter#Define('cpp', {
\ 'name': 'ccls',
\ 'lsp': 'stdio',
\ 'executable_callback': ale#VarFunc('cpp_ccls_executable'),
\ 'command': '%e',
\ 'project_root_callback': 'ale#handlers#ccls#GetProjectRoot',
\ 'initialization_options_callback': ale#VarFunc('cpp_ccls_init_options'),
\})

View file

@ -0,0 +1,27 @@
" Author: Tomota Nakamura <https://github.com/tomotanakamura>
" Description: clang linter for cpp files
call ale#Set('cpp_clang_executable', 'clang++')
call ale#Set('cpp_clang_options', '-std=c++14 -Wall')
function! ale_linters#cpp#clang#GetCommand(buffer, output) abort
let l:cflags = ale#c#GetCFlags(a:buffer, a:output)
" -iquote with the directory the file is in makes #include work for
" headers in the same directory.
return '%e -S -x c++ -fsyntax-only'
\ . ' -iquote ' . ale#Escape(fnamemodify(bufname(a:buffer), ':p:h'))
\ . ale#Pad(l:cflags)
\ . ale#Pad(ale#Var(a:buffer, 'cpp_clang_options')) . ' -'
endfunction
call ale#linter#Define('cpp', {
\ 'name': 'clang',
\ 'output_stream': 'stderr',
\ 'executable_callback': ale#VarFunc('cpp_clang_executable'),
\ 'command_chain': [
\ {'callback': 'ale#c#GetMakeCommand', 'output_stream': 'stdout'},
\ {'callback': 'ale_linters#cpp#clang#GetCommand'},
\ ],
\ 'callback': 'ale#handlers#gcc#HandleGCCFormatWithIncludes',
\})

View file

@ -0,0 +1,34 @@
" Author: gagbo <gagbobada@gmail.com>
" Description: clang-check linter for cpp files
call ale#Set('cpp_clangcheck_executable', 'clang-check')
call ale#Set('cpp_clangcheck_options', '')
call ale#Set('c_build_dir', '')
function! ale_linters#cpp#clangcheck#GetCommand(buffer) abort
let l:user_options = ale#Var(a:buffer, 'cpp_clangcheck_options')
" Try to find compilation database to link automatically
let l:build_dir = ale#Var(a:buffer, 'c_build_dir')
if empty(l:build_dir)
let l:build_dir = ale#path#Dirname(ale#c#FindCompileCommands(a:buffer))
endif
" The extra arguments in the command are used to prevent .plist files from
" being generated. These are only added if no build directory can be
" detected.
return '%e -analyze %s'
\ . (empty(l:build_dir) ? ' -extra-arg -Xclang -extra-arg -analyzer-output=text' : '')
\ . ale#Pad(l:user_options)
\ . (!empty(l:build_dir) ? ' -p ' . ale#Escape(l:build_dir) : '')
endfunction
call ale#linter#Define('cpp', {
\ 'name': 'clangcheck',
\ 'output_stream': 'stderr',
\ 'executable_callback': ale#VarFunc('cpp_clangcheck_executable'),
\ 'command_callback': 'ale_linters#cpp#clangcheck#GetCommand',
\ 'callback': 'ale#handlers#gcc#HandleGCCFormat',
\ 'lint_file': 1,
\})

View file

@ -0,0 +1,23 @@
" Author: Andrey Melentyev <andrey.melentyev@protonmail.com>
" Description: Clangd language server
call ale#Set('cpp_clangd_executable', 'clangd')
call ale#Set('cpp_clangd_options', '')
function! ale_linters#cpp#clangd#GetProjectRoot(buffer) abort
let l:project_root = ale#path#FindNearestFile(a:buffer, 'compile_commands.json')
return !empty(l:project_root) ? fnamemodify(l:project_root, ':h') : ''
endfunction
function! ale_linters#cpp#clangd#GetCommand(buffer) abort
return '%e' . ale#Pad(ale#Var(a:buffer, 'cpp_clangd_options'))
endfunction
call ale#linter#Define('cpp', {
\ 'name': 'clangd',
\ 'lsp': 'stdio',
\ 'executable_callback': ale#VarFunc('cpp_clangd_executable'),
\ 'command_callback': 'ale_linters#cpp#clangd#GetCommand',
\ 'project_root_callback': 'ale_linters#cpp#clangd#GetProjectRoot',
\})

View file

@ -0,0 +1,36 @@
" Author: vdeurzen <tim@kompiler.org>, w0rp <devw0rp@gmail.com>,
" gagbo <gagbobada@gmail.com>
" Description: clang-tidy linter for cpp files
call ale#Set('cpp_clangtidy_executable', 'clang-tidy')
" Set this option to check the checks clang-tidy will apply.
call ale#Set('cpp_clangtidy_checks', ['*'])
" Set this option to manually set some options for clang-tidy.
" This will disable compile_commands.json detection.
call ale#Set('cpp_clangtidy_options', '')
call ale#Set('c_build_dir', '')
function! ale_linters#cpp#clangtidy#GetCommand(buffer) abort
let l:checks = join(ale#Var(a:buffer, 'cpp_clangtidy_checks'), ',')
let l:build_dir = ale#c#GetBuildDirectory(a:buffer)
" Get the extra options if we couldn't find a build directory.
let l:options = empty(l:build_dir)
\ ? ale#Var(a:buffer, 'cpp_clangtidy_options')
\ : ''
return '%e'
\ . (!empty(l:checks) ? ' -checks=' . ale#Escape(l:checks) : '')
\ . ' %s'
\ . (!empty(l:build_dir) ? ' -p ' . ale#Escape(l:build_dir) : '')
\ . (!empty(l:options) ? ' -- ' . l:options : '')
endfunction
call ale#linter#Define('cpp', {
\ 'name': 'clangtidy',
\ 'output_stream': 'stdout',
\ 'executable_callback': ale#VarFunc('cpp_clangtidy_executable'),
\ 'command_callback': 'ale_linters#cpp#clangtidy#GetCommand',
\ 'callback': 'ale#handlers#gcc#HandleGCCFormat',
\ 'lint_file': 1,
\})

View file

@ -0,0 +1,32 @@
" Description: clazy linter for cpp files (clang-based and Qt-oriented)
call ale#Set('cpp_clazy_executable', 'clazy-standalone')
" Set this option to check the checks clazy will apply.
call ale#Set('cpp_clazy_checks', ['level1'])
" Set this option to manually set some options for clazy.
" This will disable compile_commands.json detection.
call ale#Set('cpp_clazy_options', '')
call ale#Set('c_build_dir', '')
function! ale_linters#cpp#clazy#GetCommand(buffer) abort
let l:checks = join(ale#Var(a:buffer, 'cpp_clazy_checks'), ',')
let l:build_dir = ale#c#GetBuildDirectory(a:buffer)
" Get the extra options if we couldn't find a build directory.
let l:options = ale#Var(a:buffer, 'cpp_clazy_options')
return '%e'
\ . (!empty(l:checks) ? ' -checks=' . ale#Escape(l:checks) : '')
\ . (!empty(l:build_dir) ? ' -p ' . ale#Escape(l:build_dir) : '')
\ . (!empty(l:options) ? ' ' . l:options : '')
\ . ' %s'
endfunction
call ale#linter#Define('cpp', {
\ 'name': 'clazy',
\ 'output_stream': 'stderr',
\ 'executable_callback': ale#VarFunc('cpp_clazy_executable'),
\ 'command_callback': 'ale_linters#cpp#clazy#GetCommand',
\ 'callback': 'ale#handlers#gcc#HandleGCCFormat',
\ 'lint_file': 1,
\})

View file

@ -0,0 +1,34 @@
" Author: Bart Libert <bart.libert@gmail.com>
" Description: cppcheck linter for cpp files
call ale#Set('cpp_cppcheck_executable', 'cppcheck')
call ale#Set('cpp_cppcheck_options', '--enable=style')
function! ale_linters#cpp#cppcheck#GetCommand(buffer) abort
" Search upwards from the file for compile_commands.json.
"
" If we find it, we'll `cd` to where the compile_commands.json file is,
" then use the file to set up import paths, etc.
let l:compile_commmands_path = ale#path#FindNearestFile(a:buffer, 'compile_commands.json')
let l:cd_command = !empty(l:compile_commmands_path)
\ ? ale#path#CdString(fnamemodify(l:compile_commmands_path, ':h'))
\ : ''
let l:compile_commands_option = !empty(l:compile_commmands_path)
\ ? '--project=compile_commands.json '
\ : ''
return l:cd_command
\ . '%e -q --language=c++ '
\ . l:compile_commands_option
\ . ale#Var(a:buffer, 'cpp_cppcheck_options')
\ . ' %t'
endfunction
call ale#linter#Define('cpp', {
\ 'name': 'cppcheck',
\ 'output_stream': 'both',
\ 'executable_callback': ale#VarFunc('cpp_cppcheck_executable'),
\ 'command_callback': 'ale_linters#cpp#cppcheck#GetCommand',
\ 'callback': 'ale#handlers#cppcheck#HandleCppCheckFormat',
\})

View file

@ -0,0 +1,20 @@
" Author: Dawid Kurek https://github.com/dawikur
" Description: cpplint for cpp files
call ale#Set('cpp_cpplint_executable', 'cpplint')
call ale#Set('cpp_cpplint_options', '')
function! ale_linters#cpp#cpplint#GetCommand(buffer) abort
let l:options = ale#Var(a:buffer, 'cpp_cpplint_options')
return '%e' . ale#Pad(l:options) . ' %s'
endfunction
call ale#linter#Define('cpp', {
\ 'name': 'cpplint',
\ 'output_stream': 'stderr',
\ 'executable_callback': ale#VarFunc('cpp_cpplint_executable'),
\ 'command_callback': 'ale_linters#cpp#cpplint#GetCommand',
\ 'callback': 'ale#handlers#cpplint#HandleCppLintFormat',
\ 'lint_file': 1,
\})

View file

@ -0,0 +1,28 @@
" Author: Ben Falconer <ben@falconers.me.uk>
" Description: A language server for C++
call ale#Set('cpp_cquery_executable', 'cquery')
call ale#Set('cpp_cquery_cache_directory', expand('~/.cache/cquery'))
function! ale_linters#cpp#cquery#GetProjectRoot(buffer) abort
let l:project_root = ale#path#FindNearestFile(a:buffer, 'compile_commands.json')
if empty(l:project_root)
let l:project_root = ale#path#FindNearestFile(a:buffer, '.cquery')
endif
return !empty(l:project_root) ? fnamemodify(l:project_root, ':h') : ''
endfunction
function! ale_linters#cpp#cquery#GetInitializationOptions(buffer) abort
return {'cacheDirectory': ale#Var(a:buffer, 'cpp_cquery_cache_directory')}
endfunction
call ale#linter#Define('cpp', {
\ 'name': 'cquery',
\ 'lsp': 'stdio',
\ 'executable_callback': ale#VarFunc('cpp_cquery_executable'),
\ 'command': '%e',
\ 'project_root_callback': 'ale_linters#cpp#cquery#GetProjectRoot',
\ 'initialization_options_callback': 'ale_linters#cpp#cquery#GetInitializationOptions',
\})

View file

@ -0,0 +1,25 @@
" Author: Christian Gibbons <cgibbons@gmu.edu>
" Description: flawfinder linter for c++ files
call ale#Set('cpp_flawfinder_executable', 'flawfinder')
call ale#Set('cpp_flawfinder_options', '')
call ale#Set('cpp_flawfinder_minlevel', 1)
call ale#Set('c_flawfinder_error_severity', 6)
function! ale_linters#cpp#flawfinder#GetCommand(buffer) abort
" Set the minimum vulnerability level for flawfinder to bother with
let l:minlevel = ' --minlevel=' . ale#Var(a:buffer, 'cpp_flawfinder_minlevel')
return '%e -CDQS'
\ . ale#Var(a:buffer, 'cpp_flawfinder_options')
\ . l:minlevel
\ . ' %t'
endfunction
call ale#linter#Define('cpp', {
\ 'name': 'flawfinder',
\ 'output_stream': 'stdout',
\ 'executable_callback': ale#VarFunc('cpp_flawfinder_executable'),
\ 'command_callback': 'ale_linters#cpp#flawfinder#GetCommand',
\ 'callback': 'ale#handlers#flawfinder#HandleFlawfinderFormat',
\})

View file

@ -0,0 +1,28 @@
" Author: geam <mdelage@student.42.fr>
" Description: gcc linter for cpp files
"
call ale#Set('cpp_gcc_executable', 'gcc')
call ale#Set('cpp_gcc_options', '-std=c++14 -Wall')
function! ale_linters#cpp#gcc#GetCommand(buffer, output) abort
let l:cflags = ale#c#GetCFlags(a:buffer, a:output)
" -iquote with the directory the file is in makes #include work for
" headers in the same directory.
return '%e -S -x c++ -fsyntax-only'
\ . ' -iquote ' . ale#Escape(fnamemodify(bufname(a:buffer), ':p:h'))
\ . ale#Pad(l:cflags)
\ . ale#Pad(ale#Var(a:buffer, 'cpp_gcc_options')) . ' -'
endfunction
call ale#linter#Define('cpp', {
\ 'name': 'gcc',
\ 'aliases': ['g++'],
\ 'output_stream': 'stderr',
\ 'executable_callback': ale#VarFunc('cpp_gcc_executable'),
\ 'command_chain': [
\ {'callback': 'ale#c#GetMakeCommand', 'output_stream': 'stdout'},
\ {'callback': 'ale_linters#cpp#gcc#GetCommand'},
\ ],
\ 'callback': 'ale#handlers#gcc#HandleGCCFormatWithIncludes',
\})

View file

@ -0,0 +1,31 @@
" Author: Jordan Andree <https://github.com/jordanandree>, David Alexander <opensource@thelonelyghost.com>
" Description: This file adds support for checking Crystal with crystal build
function! ale_linters#crystal#crystal#Handle(buffer, lines) abort
let l:output = []
for l:error in ale#util#FuzzyJSONDecode(a:lines, [])
call add(l:output, {
\ 'lnum': l:error.line + 0,
\ 'col': l:error.column + 0,
\ 'text': l:error.message,
\})
endfor
return l:output
endfunction
function! ale_linters#crystal#crystal#GetCommand(buffer) abort
return 'crystal build -f json --no-codegen --no-color -o '
\ . ale#Escape(g:ale#util#nul_file)
\ . ' %s'
endfunction
call ale#linter#Define('crystal', {
\ 'name': 'crystal',
\ 'executable': 'crystal',
\ 'output_stream': 'both',
\ 'lint_file': 1,
\ 'command_callback': 'ale_linters#crystal#crystal#GetCommand',
\ 'callback': 'ale_linters#crystal#crystal#Handle',
\})

View file

@ -0,0 +1,37 @@
let g:ale_cs_mcs_options = get(g:, 'ale_cs_mcs_options', '')
function! ale_linters#cs#mcs#GetCommand(buffer) abort
let l:options = ale#Var(a:buffer, 'cs_mcs_options')
return 'mcs -unsafe --parse'
\ . (!empty(l:options) ? ' ' . l:options : '')
\ . ' %t'
endfunction
function! ale_linters#cs#mcs#Handle(buffer, lines) abort
" Look for lines like the following.
"
" Tests.cs(12,29): error CSXXXX: ; expected
let l:pattern = '^\v(.+\.cs)\((\d+),(\d+)\)\: ([^ ]+) ([^ ]+): (.+)$'
let l:output = []
for l:match in ale#util#GetMatches(a:lines, l:pattern)
call add(l:output, {
\ 'lnum': l:match[2] + 0,
\ 'col': l:match[3] + 0,
\ 'type': l:match[4] is# 'error' ? 'E' : 'W',
\ 'code': l:match[5],
\ 'text': l:match[6],
\})
endfor
return l:output
endfunction
call ale#linter#Define('cs',{
\ 'name': 'mcs',
\ 'output_stream': 'stderr',
\ 'executable': 'mcs',
\ 'command_callback': 'ale_linters#cs#mcs#GetCommand',
\ 'callback': 'ale_linters#cs#mcs#Handle',
\})

View file

@ -0,0 +1,81 @@
call ale#Set('cs_mcsc_options', '')
call ale#Set('cs_mcsc_source', '')
call ale#Set('cs_mcsc_assembly_path', [])
call ale#Set('cs_mcsc_assemblies', [])
function! s:GetWorkingDirectory(buffer) abort
let l:working_directory = ale#Var(a:buffer, 'cs_mcsc_source')
if !empty(l:working_directory)
return l:working_directory
endif
return expand('#' . a:buffer . ':p:h')
endfunction
function! ale_linters#cs#mcsc#GetCommand(buffer) abort
" Pass assembly paths via the -lib: parameter.
let l:path_list = ale#Var(a:buffer, 'cs_mcsc_assembly_path')
let l:lib_option = !empty(l:path_list)
\ ? '-lib:' . join(map(copy(l:path_list), 'ale#Escape(v:val)'), ',')
\ : ''
" Pass paths to DLL files via the -r: parameter.
let l:assembly_list = ale#Var(a:buffer, 'cs_mcsc_assemblies')
let l:r_option = !empty(l:assembly_list)
\ ? '-r:' . join(map(copy(l:assembly_list), 'ale#Escape(v:val)'), ',')
\ : ''
" register temporary module target file with ale
" register temporary module target file with ALE.
let l:out = ale#engine#CreateFile(a:buffer)
" The code is compiled as a module and the output is redirected to a
" temporary file.
return ale#path#CdString(s:GetWorkingDirectory(a:buffer))
\ . 'mcs -unsafe'
\ . ale#Pad(ale#Var(a:buffer, 'cs_mcsc_options'))
\ . ale#Pad(l:lib_option)
\ . ale#Pad(l:r_option)
\ . ' -out:' . l:out
\ . ' -t:module'
\ . ' -recurse:' . ale#Escape('*.cs')
endfunction
function! ale_linters#cs#mcsc#Handle(buffer, lines) abort
" Look for lines like the following.
"
" Tests.cs(12,29): error CSXXXX: ; expected
"
" NOTE: pattern also captures file name as linter compiles all
" files within the source tree rooted at the specified source
" path and not just the file loaded in the buffer
let l:pattern = '^\v(.+\.cs)\((\d+),(\d+)\)\: ([^ ]+) ([^ ]+): (.+)$'
let l:output = []
let l:dir = s:GetWorkingDirectory(a:buffer)
for l:match in ale#util#GetMatches(a:lines, l:pattern)
call add(l:output, {
\ 'filename': ale#path#GetAbsPath(l:dir, l:match[1]),
\ 'lnum': l:match[2] + 0,
\ 'col': l:match[3] + 0,
\ 'type': l:match[4] is# 'error' ? 'E' : 'W',
\ 'code': l:match[5],
\ 'text': l:match[6],
\})
endfor
return l:output
endfunction
call ale#linter#Define('cs',{
\ 'name': 'mcsc',
\ 'output_stream': 'stderr',
\ 'executable': 'mcs',
\ 'command_callback': 'ale_linters#cs#mcsc#GetCommand',
\ 'callback': 'ale_linters#cs#mcsc#Handle',
\ 'lint_file': 1
\})

View file

@ -0,0 +1,18 @@
" Author: w0rp <devw0rp@gmail.com>
" Description: This file adds support for checking CSS code with csslint.
function! ale_linters#css#csslint#GetCommand(buffer) abort
let l:csslintrc = ale#path#FindNearestFile(a:buffer, '.csslintrc')
let l:config_option = !empty(l:csslintrc)
\ ? '--config=' . ale#Escape(l:csslintrc)
\ : ''
return 'csslint --format=compact ' . l:config_option . ' %t'
endfunction
call ale#linter#Define('css', {
\ 'name': 'csslint',
\ 'executable': 'csslint',
\ 'command_callback': 'ale_linters#css#csslint#GetCommand',
\ 'callback': 'ale#handlers#css#HandleCSSLintFormat',
\})

View file

@ -0,0 +1,19 @@
" Author: diartyz <diartyz@gmail.com>
call ale#Set('css_stylelint_executable', 'stylelint')
call ale#Set('css_stylelint_options', '')
call ale#Set('css_stylelint_use_global', get(g:, 'ale_use_global_executables', 0))
function! ale_linters#css#stylelint#GetCommand(buffer) abort
return '%e ' . ale#Pad(ale#Var(a:buffer, 'css_stylelint_options'))
\ . ' --stdin-filename %s'
endfunction
call ale#linter#Define('css', {
\ 'name': 'stylelint',
\ 'executable_callback': ale#node#FindExecutableFunc('css_stylelint', [
\ 'node_modules/.bin/stylelint',
\ ]),
\ 'command_callback': 'ale_linters#css#stylelint#GetCommand',
\ 'callback': 'ale#handlers#css#HandleStyleLintFormat',
\})

View file

@ -0,0 +1,46 @@
" Author: Eddie Lebow https://github.com/elebow
" Description: Cucumber, a BDD test tool
function! ale_linters#cucumber#cucumber#GetCommand(buffer) abort
let l:features_dir = ale#path#FindNearestDirectory(a:buffer, 'features')
if !empty(l:features_dir)
let l:features_arg = '-r ' . ale#Escape(l:features_dir)
else
let l:features_arg = ''
endif
return 'cucumber --dry-run --quiet --strict --format=json '
\ . l:features_arg . ' %t'
endfunction
function! ale_linters#cucumber#cucumber#Handle(buffer, lines) abort
try
let l:json = ale#util#FuzzyJSONDecode(a:lines, {})[0]
catch
return []
endtry
let l:output = []
for l:element in get(l:json, 'elements', [])
for l:step in l:element['steps']
if l:step['result']['status'] is# 'undefined'
call add(l:output, {
\ 'lnum': l:step['line'],
\ 'code': 'E',
\ 'text': 'Undefined step'
\})
endif
endfor
endfor
return l:output
endfunction
call ale#linter#Define('cucumber', {
\ 'name': 'cucumber',
\ 'executable': 'cucumber',
\ 'command_callback': 'ale_linters#cucumber#cucumber#GetCommand',
\ 'callback': 'ale_linters#cucumber#cucumber#Handle'
\})

View file

@ -0,0 +1,49 @@
" Author: blahgeek <i@blahgeek.com>
" Description: NVCC linter for cuda files
call ale#Set('cuda_nvcc_executable', 'nvcc')
call ale#Set('cuda_nvcc_options', '-std=c++11')
function! ale_linters#cuda#nvcc#GetCommand(buffer) abort
" Unused: use ale#util#nul_file
" let l:output_file = ale#util#Tempname() . '.ii'
" call ale#engine#ManageFile(a:buffer, l:output_file)
return '%e -cuda'
\ . ale#Pad(ale#c#IncludeOptions(ale#c#FindLocalHeaderPaths(a:buffer)))
\ . ale#Pad(ale#Var(a:buffer, 'cuda_nvcc_options'))
\ . ' %s -o ' . g:ale#util#nul_file
endfunction
function! ale_linters#cuda#nvcc#HandleNVCCFormat(buffer, lines) abort
" Look for lines like the following.
"
" test.cu(8): error: argument of type "void *" is incompatible with parameter of type "int *"
let l:pattern = '\v^([^:\(\)]+):?\(?(\d+)\)?:(\d+)?:?\s*\w*\s*(error|warning): (.+)$'
let l:output = []
for l:match in ale#util#GetMatches(a:lines, l:pattern)
let l:item = {
\ 'lnum': str2nr(l:match[2]),
\ 'type': l:match[4] =~# 'error' ? 'E' : 'W',
\ 'text': l:match[5],
\ 'filename': fnamemodify(l:match[1], ':p'),
\}
if !empty(l:match[3])
let l:item.col = str2nr(l:match[3])
endif
call add(l:output, l:item)
endfor
return l:output
endfunction
call ale#linter#Define('cuda', {
\ 'name': 'nvcc',
\ 'output_stream': 'stderr',
\ 'executable_callback': ale#VarFunc('cuda_nvcc_executable'),
\ 'command_callback': 'ale_linters#cuda#nvcc#GetCommand',
\ 'callback': 'ale_linters#cuda#nvcc#HandleNVCCFormat',
\ 'lint_file': 1,
\})

View file

@ -0,0 +1,79 @@
" Author: w0rp <devw0rp@gmail.com>
" Description: "dmd for D files"
function! s:FindDUBConfig(buffer) abort
" Find a DUB configuration file in ancestor paths.
" The most DUB-specific names will be tried first.
for l:possible_filename in ['dub.sdl', 'dub.json', 'package.json']
let l:dub_file = ale#path#FindNearestFile(a:buffer, l:possible_filename)
if !empty(l:dub_file)
return l:dub_file
endif
endfor
return ''
endfunction
function! ale_linters#d#dmd#DUBCommand(buffer) abort
" If we can't run dub, then skip this command.
if !executable('dub')
" Returning an empty string skips to the DMD command.
return ''
endif
let l:dub_file = s:FindDUBConfig(a:buffer)
if empty(l:dub_file)
return ''
endif
" To support older dub versions, we just change the directory to
" the directory where we found the dub config, and then run `dub describe`
" from that directory.
return 'cd ' . ale#Escape(fnamemodify(l:dub_file, ':h'))
\ . ' && dub describe --import-paths'
endfunction
function! ale_linters#d#dmd#DMDCommand(buffer, dub_output) abort
let l:import_list = []
" Build a list of import paths generated from DUB, if available.
for l:line in a:dub_output
if !empty(l:line)
" The arguments must be '-Ifilename', not '-I filename'
call add(l:import_list, '-I' . ale#Escape(l:line))
endif
endfor
return 'dmd '. join(l:import_list) . ' -o- -wi -vcolumns -c %t'
endfunction
function! ale_linters#d#dmd#Handle(buffer, lines) abort
" Matches patterns lines like the following:
" /tmp/tmp.qclsa7qLP7/file.d(1): Error: function declaration without return type. (Note that constructors are always named 'this')
" /tmp/tmp.G1L5xIizvB.d(8,8): Error: module weak_reference is in file 'dstruct/weak_reference.d' which cannot be read
let l:pattern = '^[^(]\+(\([0-9]\+\)\,\?\([0-9]*\)): \([^:]\+\): \(.\+\)'
let l:output = []
for l:match in ale#util#GetMatches(a:lines, l:pattern)
call add(l:output, {
\ 'lnum': l:match[1],
\ 'col': l:match[2],
\ 'type': l:match[3] is# 'Warning' ? 'W' : 'E',
\ 'text': l:match[4],
\})
endfor
return l:output
endfunction
call ale#linter#Define('d', {
\ 'name': 'dmd',
\ 'executable': 'dmd',
\ 'command_chain': [
\ {'callback': 'ale_linters#d#dmd#DUBCommand', 'output_stream': 'stdout'},
\ {'callback': 'ale_linters#d#dmd#DMDCommand', 'output_stream': 'stderr'},
\ ],
\ 'callback': 'ale_linters#d#dmd#Handle',
\})

View file

@ -0,0 +1,26 @@
" Author: Taylor Blau <me@ttaylorr.com>
function! ale_linters#dafny#dafny#Handle(buffer, lines) abort
let l:pattern = '\v(.*)\((\d+),(\d+)\): (.*): (.*)'
let l:output = []
for l:match in ale#util#GetMatches(a:lines, l:pattern)
call add(l:output, {
\ 'bufnr': a:buffer,
\ 'col': l:match[3] + 0,
\ 'lnum': l:match[2] + 0,
\ 'text': l:match[5],
\ 'type': l:match[4] =~# '^Error' ? 'E' : 'W'
\ })
endfor
return l:output
endfunction
call ale#linter#Define('dafny', {
\ 'name': 'dafny',
\ 'executable': 'dafny',
\ 'command': 'dafny %s /compile:0',
\ 'callback': 'ale_linters#dafny#dafny#Handle',
\ 'lint_file': 1,
\ })

View file

@ -0,0 +1,36 @@
" Author: w0rp <devw0rp@gmail.com>
" Description: Check Dart files with dartanalyzer
call ale#Set('dart_dartanalyzer_executable', 'dartanalyzer')
function! ale_linters#dart#dartanalyzer#GetCommand(buffer) abort
let l:path = ale#path#FindNearestFile(a:buffer, '.packages')
return '%e'
\ . (!empty(l:path) ? ' --packages ' . ale#Escape(l:path) : '')
\ . ' %s'
endfunction
function! ale_linters#dart#dartanalyzer#Handle(buffer, lines) abort
let l:pattern = '\v^ ([a-z]+) . (.+) at (.+):(\d+):(\d+) . (.+)$'
let l:output = []
for l:match in ale#util#GetMatches(a:lines, l:pattern)
call add(l:output, {
\ 'type': l:match[1] is# 'error' ? 'E' : 'W',
\ 'text': l:match[6] . ': ' . l:match[2],
\ 'lnum': str2nr(l:match[4]),
\ 'col': str2nr(l:match[5]),
\})
endfor
return l:output
endfunction
call ale#linter#Define('dart', {
\ 'name': 'dartanalyzer',
\ 'executable_callback': ale#VarFunc('dart_dartanalyzer_executable'),
\ 'command_callback': 'ale_linters#dart#dartanalyzer#GetCommand',
\ 'callback': 'ale_linters#dart#dartanalyzer#Handle',
\ 'lint_file': 1,
\})

View file

@ -0,0 +1,20 @@
" Author: aurieh <me@aurieh.me>
" Description: A language server for dart
call ale#Set('dart_language_server_executable', 'dart_language_server')
function! ale_linters#dart#language_server#GetProjectRoot(buffer) abort
" Note: pub only looks for pubspec.yaml, there's no point in adding
" support for pubspec.yml
let l:pubspec = ale#path#FindNearestFile(a:buffer, 'pubspec.yaml')
return !empty(l:pubspec) ? fnamemodify(l:pubspec, ':h:h') : ''
endfunction
call ale#linter#Define('dart', {
\ 'name': 'language_server',
\ 'lsp': 'stdio',
\ 'executable_callback': ale#VarFunc('dart_language_server_executable'),
\ 'command': '%e',
\ 'project_root_callback': 'ale_linters#dart#language_server#GetProjectRoot',
\})

View file

@ -0,0 +1,99 @@
" Author: hauleth - https://github.com/hauleth
" always, yes, never
call ale#Set('dockerfile_hadolint_use_docker', 'never')
call ale#Set('dockerfile_hadolint_docker_image', 'hadolint/hadolint')
function! ale_linters#dockerfile#hadolint#Handle(buffer, lines) abort
" Matches patterns line the following:
"
" /dev/stdin:19 DL3001 Pipe chain should start with a raw value.
" /dev/stdin:19:3 unexpected thing
let l:pattern = '\v^/dev/stdin:(\d+):?(\d+)? ((DL|SC)(\d+) )?(.+)$'
let l:output = []
for l:match in ale#util#GetMatches(a:lines, l:pattern)
let l:lnum = 0
let l:colnum = 0
if l:match[1] isnot# ''
let l:lnum = l:match[1] + 0
endif
if l:match[2] isnot# ''
let l:colnum = l:match[2] + 0
endif
let l:type = 'W'
let l:text = l:match[6]
let l:detail = l:match[6]
let l:domain = 'https://github.com/hadolint/hadolint/wiki/'
if l:match[4] is# 'SC'
let l:domain = 'https://github.com/koalaman/shellcheck/wiki/'
endif
if l:match[5] isnot# ''
let l:code = l:match[4] . l:match[5]
let l:link = ' ( ' . l:domain . l:code . ' )'
let l:detail = l:code . l:link . "\n\n" . l:detail
else
let l:type = 'E'
endif
call add(l:output, {
\ 'lnum': l:lnum,
\ 'col': l:colnum,
\ 'type': l:type,
\ 'text': l:text,
\ 'detail': l:detail
\})
endfor
return l:output
endfunction
" This is a little different than the typical 'executable' callback. We want
" to afford the user the chance to say always use docker, never use docker,
" and use docker if the hadolint executable is not present on the system.
"
" In the case of neither docker nor hadolint executables being present, it
" really doesn't matter which we return -- either will have the effect of
" 'nope, can't use this linter!'.
function! ale_linters#dockerfile#hadolint#GetExecutable(buffer) abort
let l:use_docker = ale#Var(a:buffer, 'dockerfile_hadolint_use_docker')
" check for mandatory directives
if l:use_docker is# 'never'
return 'hadolint'
elseif l:use_docker is# 'always'
return 'docker'
endif
" if we reach here, we want to use 'hadolint' if present...
if executable('hadolint')
return 'hadolint'
endif
"... and 'docker' as a fallback.
return 'docker'
endfunction
function! ale_linters#dockerfile#hadolint#GetCommand(buffer) abort
let l:command = ale_linters#dockerfile#hadolint#GetExecutable(a:buffer)
if l:command is# 'docker'
return 'docker run --rm -i ' . ale#Var(a:buffer, 'dockerfile_hadolint_docker_image')
endif
return 'hadolint -'
endfunction
call ale#linter#Define('dockerfile', {
\ 'name': 'hadolint',
\ 'executable_callback': 'ale_linters#dockerfile#hadolint#GetExecutable',
\ 'command_callback': 'ale_linters#dockerfile#hadolint#GetCommand',
\ 'callback': 'ale_linters#dockerfile#hadolint#Handle',
\})

View file

@ -0,0 +1,37 @@
" Author: hauleth - https://github.com/hauleth
function! ale_linters#elixir#credo#Handle(buffer, lines) abort
" Matches patterns line the following:
"
" lib/filename.ex:19:7: F: Pipe chain should start with a raw value.
let l:pattern = '\v:(\d+):?(\d+)?: (.): (.+)$'
let l:output = []
for l:match in ale#util#GetMatches(a:lines, l:pattern)
let l:type = l:match[3]
let l:text = l:match[4]
if l:type is# 'C'
let l:type = 'E'
elseif l:type is# 'R'
let l:type = 'W'
endif
call add(l:output, {
\ 'bufnr': a:buffer,
\ 'lnum': l:match[1] + 0,
\ 'col': l:match[2] + 0,
\ 'type': l:type,
\ 'text': l:text,
\})
endfor
return l:output
endfunction
call ale#linter#Define('elixir', {
\ 'name': 'credo',
\ 'executable': 'mix',
\ 'command': 'mix help credo && mix credo suggest --format=flycheck --read-from-stdin %s',
\ 'callback': 'ale_linters#elixir#credo#Handle',
\})

View file

@ -0,0 +1,34 @@
" Author: Fran C. - https://github.com/franciscoj
" Description: Add dialyzer support for elixir through dialyxir
" https://github.com/jeremyjh/dialyxir
function! ale_linters#elixir#dialyxir#Handle(buffer, lines) abort
" Matches patterns line the following:
"
" lib/filename.ex:19: Function fname/1 has no local return
let l:pattern = '\v(.+):(\d+): (.+)$'
let l:output = []
let l:type = 'W'
for l:match in ale#util#GetMatches(a:lines, l:pattern)
if bufname(a:buffer) == l:match[1]
call add(l:output, {
\ 'bufnr': a:buffer,
\ 'lnum': l:match[2] + 0,
\ 'col': 0,
\ 'type': l:type,
\ 'text': l:match[3],
\})
endif
endfor
return l:output
endfunction
call ale#linter#Define('elixir', {
\ 'name': 'dialyxir',
\ 'executable': 'mix',
\ 'command': 'mix help dialyzer && mix dialyzer',
\ 'callback': 'ale_linters#elixir#dialyxir#Handle',
\})

View file

@ -0,0 +1,38 @@
" Author: archseer - https://github.com/archSeer
function! ale_linters#elixir#dogma#Handle(buffer, lines) abort
" Matches patterns line the following:
"
" lib/filename.ex:19:7: F: Pipe chain should start with a raw value.
let l:pattern = '\v:(\d+):?(\d+)?: (.): (.+)$'
let l:output = []
for l:match in ale#util#GetMatches(a:lines, l:pattern)
let l:type = l:match[3]
let l:text = l:match[4]
if l:type is# 'C'
let l:type = 'E'
elseif l:type is# 'R'
let l:type = 'W'
endif
call add(l:output, {
\ 'bufnr': a:buffer,
\ 'lnum': l:match[1] + 0,
\ 'col': l:match[2] + 0,
\ 'type': l:type,
\ 'text': l:text,
\})
endfor
return l:output
endfunction
call ale#linter#Define('elixir', {
\ 'name': 'dogma',
\ 'executable': 'mix',
\ 'command': 'mix help dogma && mix dogma %s --format=flycheck',
\ 'lint_file': 1,
\ 'callback': 'ale_linters#elixir#dogma#Handle',
\})

View file

@ -0,0 +1,62 @@
" Author: evnu - https://github.com/evnu
" Author: colbydehart - https://github.com/colbydehart
" Description: Mix compile checking for Elixir files
function! ale_linters#elixir#mix#Handle(buffer, lines) abort
" Matches patterns like the following:
"
" Error format
" ** (CompileError) apps/sim/lib/sim/server.ex:87: undefined function update_in/4
"
" TODO: Warning format
" warning: variable "foobar" does not exist and is being expanded to "foobar()", please use parentheses to remove the ambiguity or change the variable name
let l:pattern = '\v\(([^\)]+Error)\) ([^:]+):([^:]+): (.+)$'
let l:output = []
for l:match in ale#util#GetMatches(a:lines, l:pattern)
let l:type = 'E'
let l:text = l:match[4]
call add(l:output, {
\ 'bufnr': a:buffer,
\ 'lnum': l:match[3] + 0,
\ 'col': 0,
\ 'type': l:type,
\ 'text': l:text,
\})
endfor
return l:output
endfunction
function! ale_linters#elixir#mix#FindProjectRoot(buffer) abort
let l:mix_file = ale#path#FindNearestFile(a:buffer, 'mix.exs')
if !empty(l:mix_file)
return fnamemodify(l:mix_file, ':p:h')
endif
return '.'
endfunction
function! ale_linters#elixir#mix#GetCommand(buffer) abort
let l:project_root = ale_linters#elixir#mix#FindProjectRoot(a:buffer)
let l:temp_dir = ale#engine#CreateDirectory(a:buffer)
let l:mix_build_path = has('win32')
\ ? 'set MIX_BUILD_PATH=' . ale#Escape(l:temp_dir) . ' &&'
\ : 'MIX_BUILD_PATH=' . ale#Escape(l:temp_dir)
return ale#path#CdString(l:project_root)
\ . l:mix_build_path
\ . ' mix compile %s'
endfunction
call ale#linter#Define('elixir', {
\ 'name': 'mix',
\ 'executable': 'mix',
\ 'command_callback': 'ale_linters#elixir#mix#GetCommand',
\ 'callback': 'ale_linters#elixir#mix#Handle',
\ 'lint_file': 1,
\})

View file

@ -0,0 +1,172 @@
" Author: buffalocoder - https://github.com/buffalocoder, soywod - https://github.com/soywod, hecrj - https://github.com/hecrj
" Description: Elm linting in Ale. Closely follows the Syntastic checker in https://github.com/ElmCast/elm-vim.
call ale#Set('elm_make_executable', 'elm')
call ale#Set('elm_make_use_global', get(g:, 'ale_use_global_executables', 0))
function! ale_linters#elm#make#Handle(buffer, lines) abort
let l:output = []
let l:unparsed_lines = []
for l:line in a:lines
if l:line[0] is# '{'
" Elm 0.19
call ale_linters#elm#make#HandleElm019Line(l:line, l:output)
elseif l:line[0] is# '['
" Elm 0.18
call ale_linters#elm#make#HandleElm018Line(l:line, l:output)
elseif l:line isnot# 'Successfully generated /dev/null'
call add(l:unparsed_lines, l:line)
endif
endfor
if len(l:unparsed_lines) > 0
call add(l:output, {
\ 'lnum': 1,
\ 'type': 'E',
\ 'text': l:unparsed_lines[0],
\ 'detail': join(l:unparsed_lines, "\n")
\})
endif
return l:output
endfunction
function! ale_linters#elm#make#HandleElm019Line(line, output) abort
let l:report = json_decode(a:line)
if l:report.type is? 'error'
" General problem
let l:details = ale_linters#elm#make#ParseMessage(l:report.message)
if empty(l:report.path)
let l:report.path = 'Elm'
endif
if ale_linters#elm#make#FileIsBuffer(l:report.path)
call add(a:output, {
\ 'lnum': 1,
\ 'type': 'E',
\ 'text': l:details,
\})
else
call add(a:output, {
\ 'lnum': 1,
\ 'type': 'E',
\ 'text': l:report.path .' - '. l:details,
\ 'detail': l:report.path ." ----------\n\n". l:details,
\})
endif
else
" Compilation errors
for l:error in l:report.errors
let l:file_is_buffer = ale_linters#elm#make#FileIsBuffer(l:error.path)
for l:problem in l:error.problems
let l:details = ale_linters#elm#make#ParseMessage(l:problem.message)
if l:file_is_buffer
" Buffer module has problems
call add(a:output, {
\ 'lnum': l:problem.region.start.line,
\ 'col': l:problem.region.start.column,
\ 'end_lnum': l:problem.region.end.line,
\ 'end_col': l:problem.region.end.column,
\ 'type': 'E',
\ 'text': l:details,
\})
else
" Imported module has problems
let l:location = l:error.path .':'. l:problem.region.start.line
call add(a:output, {
\ 'lnum': 1,
\ 'type': 'E',
\ 'text': l:location .' - '. l:details,
\ 'detail': l:location ." ----------\n\n". l:details,
\})
endif
endfor
endfor
endif
endfunction
function! ale_linters#elm#make#HandleElm018Line(line, output) abort
let l:errors = json_decode(a:line)
for l:error in l:errors
let l:file_is_buffer = ale_linters#elm#make#FileIsBuffer(l:error.file)
if l:file_is_buffer
" Current buffer has problems
call add(a:output, {
\ 'lnum': l:error.region.start.line,
\ 'col': l:error.region.start.column,
\ 'end_lnum': l:error.region.end.line,
\ 'end_col': l:error.region.end.column,
\ 'type': (l:error.type is? 'error') ? 'E' : 'W',
\ 'text': l:error.overview,
\ 'detail': l:error.overview . "\n\n" . l:error.details
\})
elseif l:error.type is? 'error'
" Imported module has errors
let l:location = l:error.file .':'. l:error.region.start.line
call add(a:output, {
\ 'lnum': 1,
\ 'type': 'E',
\ 'text': l:location .' - '. l:error.overview,
\ 'detail': l:location ." ----------\n\n". l:error.overview . "\n\n" . l:error.details
\})
endif
endfor
endfunction
function! ale_linters#elm#make#FileIsBuffer(path) abort
return ale#path#IsTempName(a:path)
endfunction
function! ale_linters#elm#make#ParseMessage(message) abort
return join(map(copy(a:message), 'ale_linters#elm#make#ParseMessageItem(v:val)'), '')
endfunction
function! ale_linters#elm#make#ParseMessageItem(item) abort
if type(a:item) is v:t_string
return a:item
else
return a:item.string
endif
endfunction
" Return the command to execute the linter in the projects directory.
" If it doesn't, then this will fail when imports are needed.
function! ale_linters#elm#make#GetCommand(buffer) abort
let l:elm_json = ale#path#FindNearestFile(a:buffer, 'elm.json')
if empty(l:elm_json)
" Fallback to Elm 0.18
let l:elm_json = ale#path#FindNearestFile(a:buffer, 'elm-package.json')
endif
if empty(l:elm_json)
let l:dir_set_cmd = ''
else
let l:root_dir = fnamemodify(l:elm_json, ':p:h')
let l:dir_set_cmd = 'cd ' . ale#Escape(l:root_dir) . ' && '
endif
" The elm compiler, at the time of this writing, uses '/dev/null' as
" a sort of flag to tell the compiler not to generate an output file,
" which is why this is hard coded here.
" Source: https://github.com/elm-lang/elm-compiler/blob/19d5a769b30ec0b2fc4475985abb4cd94cd1d6c3/builder/src/Generate/Output.hs#L253
return l:dir_set_cmd . '%e make --report=json --output=/dev/null %t'
endfunction
call ale#linter#Define('elm', {
\ 'name': 'make',
\ 'executable_callback': ale#node#FindExecutableFunc('elm_make', [
\ 'node_modules/.bin/elm',
\ ]),
\ 'output_stream': 'both',
\ 'command_callback': 'ale_linters#elm#make#GetCommand',
\ 'callback': 'ale_linters#elm#make#Handle'
\})

View file

@ -0,0 +1,96 @@
" Author: Magnus Ottenklinger - https://github.com/evnu
let g:ale_erlang_erlc_options = get(g:, 'ale_erlang_erlc_options', '')
function! ale_linters#erlang#erlc#GetCommand(buffer) abort
let l:output_file = ale#util#Tempname()
call ale#engine#ManageFile(a:buffer, l:output_file)
return 'erlc -o ' . ale#Escape(l:output_file)
\ . ' ' . ale#Var(a:buffer, 'erlang_erlc_options')
\ . ' %t'
endfunction
function! ale_linters#erlang#erlc#Handle(buffer, lines) abort
" Matches patterns like the following:
"
" error.erl:4: variable 'B' is unbound
" error.erl:3: Warning: function main/0 is unused
" error.erl:4: Warning: variable 'A' is unused
let l:pattern = '\v^([a-zA-Z]?:?[^:]+):(\d+): (Warning: )?(.+)$'
" parse_transforms are a special case. The error message does not indicate a location:
" error.erl: undefined parse transform 'some_parse_transform'
let l:pattern_parse_transform = '\v(undefined parse transform .*)$'
let l:output = []
let l:pattern_no_module_definition = '\v(no module definition)$'
let l:pattern_unused = '\v(.* is unused)$'
let l:is_hrl = fnamemodify(bufname(a:buffer), ':e') is# 'hrl'
for l:line in a:lines
let l:match = matchlist(l:line, l:pattern)
" Determine if the output indicates an error. We distinguish between two cases:
"
" 1) normal errors match l:pattern
" 2) parse_transform errors match l:pattern_parse_transform
"
" If none of the patterns above match, the line can be ignored
if len(l:match) == 0 " not a 'normal' warning or error
let l:match_parse_transform = matchlist(l:line, l:pattern_parse_transform)
if len(l:match_parse_transform) == 0 " also not a parse_transform error
continue
endif
call add(l:output, {
\ 'bufnr': a:buffer,
\ 'lnum': 0,
\ 'col': 0,
\ 'type': 'E',
\ 'text': l:match_parse_transform[0],
\})
continue
endif
let l:line = l:match[2]
let l:warning_or_text = l:match[3]
let l:text = l:match[4]
" If this file is a header .hrl, ignore the following expected messages:
" - 'no module definition'
" - 'X is unused'
if l:is_hrl && (
\ match(l:text, l:pattern_no_module_definition) != -1
\ || match(l:text, l:pattern_unused) != -1
\)
continue
endif
if !empty(l:warning_or_text)
let l:type = 'W'
else
let l:type = 'E'
endif
call add(l:output, {
\ 'bufnr': a:buffer,
\ 'lnum': l:line,
\ 'col': 0,
\ 'type': l:type,
\ 'text': l:text,
\})
endfor
return l:output
endfunction
call ale#linter#Define('erlang', {
\ 'name': 'erlc',
\ 'executable': 'erlc',
\ 'command_callback': 'ale_linters#erlang#erlc#GetCommand',
\ 'callback': 'ale_linters#erlang#erlc#Handle',
\})

View file

@ -0,0 +1,35 @@
" Author: Dmitri Vereshchagin <dmitri.vereshchagin@gmail.com>
" Description: SyntaxErl linter for Erlang files
call ale#Set('erlang_syntaxerl_executable', 'syntaxerl')
function! ale_linters#erlang#syntaxerl#GetCommand(buffer, output) abort
let l:use_b_option = match(a:output, '\C\V-b, --base\>') > -1
return '%e' . (l:use_b_option ? ' -b %s %t' : ' %t')
endfunction
function! ale_linters#erlang#syntaxerl#Handle(buffer, lines) abort
let l:pattern = '\v\C:(\d+):( warning:)? (.+)'
let l:loclist = []
for l:match in ale#util#GetMatches(a:lines, l:pattern)
call add(l:loclist, {
\ 'lnum': l:match[1] + 0,
\ 'text': l:match[3],
\ 'type': empty(l:match[2]) ? 'E' : 'W',
\})
endfor
return l:loclist
endfunction
call ale#linter#Define('erlang', {
\ 'name': 'syntaxerl',
\ 'executable_callback': ale#VarFunc('erlang_syntaxerl_executable'),
\ 'command_chain': [
\ {'callback': {-> '%e -h'}},
\ {'callback': 'ale_linters#erlang#syntaxerl#GetCommand'},
\ ],
\ 'callback': 'ale_linters#erlang#syntaxerl#Handle',
\})

View file

@ -0,0 +1,25 @@
" Author: Matthias Guenther - https://wikimatze.de, Eddie Lebow https://github.com/elebow
" Description: ERB from the Ruby standard library, for eruby/erb files
function! ale_linters#eruby#erb#GetCommand(buffer) abort
let l:rails_root = ale#ruby#FindRailsRoot(a:buffer)
if empty(l:rails_root)
return 'erb -P -T - -x %t | ruby -c'
endif
" Rails-flavored eRuby does not comply with the standard as understood by
" ERB, so we'll have to do some substitution. This does not reduce the
" effectiveness of the linter—the translated code is still evaluated.
return 'ruby -r erb -e ' . ale#Escape('puts ERB.new($stdin.read.gsub(%{<%=},%{<%}), nil, %{-}).src') . '< %t | ruby -c'
endfunction
call ale#linter#Define('eruby', {
\ 'name': 'erb',
\ 'aliases': ['erubylint'],
\ 'executable': 'erb',
\ 'output_stream': 'stderr',
\ 'command_callback': 'ale_linters#eruby#erb#GetCommand',
\ 'callback': 'ale#handlers#ruby#HandleSyntaxErrors',
\})

View file

@ -0,0 +1,35 @@
" Author: Eddie Lebow https://github.com/elebow
" Description: eruby checker using `erubi`
function! ale_linters#eruby#erubi#CheckErubi(buffer) abort
return 'ruby -r erubi/capture_end -e ' . ale#Escape('""')
endfunction
function! ale_linters#eruby#erubi#GetCommand(buffer, check_erubi_output) abort
let l:rails_root = ale#ruby#FindRailsRoot(a:buffer)
if (!empty(a:check_erubi_output))
" The empty command in CheckErubi returns nothing if erubi runs and
" emits an error if erubi is not present
return ''
endif
if empty(l:rails_root)
return 'ruby -r erubi/capture_end -e ' . ale#Escape('puts Erubi::CaptureEndEngine.new($stdin.read).src') . '< %t | ruby -c'
endif
" Rails-flavored eRuby does not comply with the standard as understood by
" Erubi, so we'll have to do some substitution. This does not reduce the
" effectiveness of the linter---the translated code is still evaluated.
return 'ruby -r erubi/capture_end -e ' . ale#Escape('puts Erubi::CaptureEndEngine.new($stdin.read.gsub(%{<%=},%{<%}), nil, %{-}).src') . '< %t | ruby -c'
endfunction
call ale#linter#Define('eruby', {
\ 'name': 'erubi',
\ 'executable': 'ruby',
\ 'command_chain': [
\ {'callback': 'ale_linters#eruby#erubi#CheckErubi'},
\ {'callback': 'ale_linters#eruby#erubi#GetCommand', 'output_stream': 'stderr'},
\ ],
\ 'callback': 'ale#handlers#ruby#HandleSyntaxErrors',
\})

View file

@ -0,0 +1,23 @@
" Author: Jake Zimmerman <jake@zimmerman.io>, Eddie Lebow https://github.com/elebow
" Description: eruby checker using `erubis`, instead of `erb`
function! ale_linters#eruby#erubis#GetCommand(buffer) abort
let l:rails_root = ale#ruby#FindRailsRoot(a:buffer)
if empty(l:rails_root)
return 'erubis -x %t | ruby -c'
endif
" Rails-flavored eRuby does not comply with the standard as understood by
" Erubis, so we'll have to do some substitution. This does not reduce the
" effectiveness of the linter - the translated code is still evaluated.
return 'ruby -r erubis -e ' . ale#Escape('puts Erubis::Eruby.new($stdin.read.gsub(%{<%=},%{<%})).src') . '< %t | ruby -c'
endfunction
call ale#linter#Define('eruby', {
\ 'name': 'erubis',
\ 'executable': 'erubis',
\ 'output_stream': 'stderr',
\ 'command_callback': 'ale_linters#eruby#erubis#GetCommand',
\ 'callback': 'ale#handlers#ruby#HandleSyntaxErrors',
\})

View file

@ -0,0 +1,67 @@
" Author: Niraj Thapaliya - https://github.com/nthapaliya
" Description: Lints fish files using fish -n
function! ale_linters#fish#fish#Handle(buffer, lines) abort
" Matches patterns such as:
"
" home/.config/fish/functions/foo.fish (line 1): Missing end to balance this function definition
" function foo
" ^
"
" OR, patterns such as:
"
" Unsupported use of '||'. In fish, please use 'COMMAND; or COMMAND'.
" /tmp/vLz620o/258/test.fish (line 2): if set -q SSH_CLIENT || set -q SSH_TTY
" ^
"
" fish -n can return errors in either format.
let l:pattern = '^\(.* (line \(\d\+\)): \)\(.*\)$'
let l:column_pattern = '^ *\^'
let l:output = []
let l:column_offset = 0
let l:last_line_with_message = ''
for l:line in a:lines
" Look for error lines first.
let l:match = matchlist(l:line, l:pattern)
if !empty(l:match)
if !empty(l:last_line_with_message)
let l:text = l:last_line_with_message
else
let l:text = l:match[3]
endif
let l:column_offset = len(l:match[1])
let l:last_line_with_message = ''
call add(l:output, {
\ 'col': 0,
\ 'lnum': str2nr(l:match[2]),
\ 'text': l:text,
\})
else
" Look for column markers like ' ^' second.
" The column index will be set according to how long the line is.
let l:column_match = matchstr(l:line, l:column_pattern)
if !empty(l:column_match) && !empty(l:output)
let l:output[-1].col = len(l:column_match) - l:column_offset
let l:last_line_with_message = ''
else
let l:last_line_with_message = l:line
let l:column_offset = 0
endif
endif
endfor
return l:output
endfunction
call ale#linter#Define('fish', {
\ 'name': 'fish',
\ 'output_stream': 'stderr',
\ 'executable': 'fish',
\ 'command': 'fish -n %t',
\ 'callback': 'ale_linters#fish#fish#Handle',
\})

View file

@ -0,0 +1,72 @@
" Author: w0rp <devw0rp@gmail.com>
" Description: gcc for Fortran files
" This option can be set to 0 to use -ffixed-form
call ale#Set('fortran_gcc_use_free_form', 1)
call ale#Set('fortran_gcc_executable', 'gcc')
" Set this option to change the GCC options for warnings for Fortran.
call ale#Set('fortran_gcc_options', '-Wall')
function! ale_linters#fortran#gcc#Handle(buffer, lines) abort
" We have to match a starting line and a later ending line together,
" like so.
"
" :21.34:
" Error: Expected comma in I/O list at (1)
let l:line_marker_pattern = ':\(\d\+\)[.:]\=\(\d\+\)\=:\=$'
let l:message_pattern = '^\(Error\|Warning\): \(.\+\)$'
let l:looking_for_message = 0
let l:last_loclist_obj = {}
let l:output = []
for l:line in a:lines
if l:looking_for_message
let l:match = matchlist(l:line, l:message_pattern)
else
let l:match = matchlist(l:line, l:line_marker_pattern)
endif
if len(l:match) == 0
continue
endif
if l:looking_for_message
let l:looking_for_message = 0
" Now we have the text, we can set it and add the error.
let l:last_loclist_obj.text = l:match[2]
let l:last_loclist_obj.type = l:match[1] is# 'Warning' ? 'W' : 'E'
call add(l:output, l:last_loclist_obj)
else
let l:last_loclist_obj = {
\ 'bufnr': a:buffer,
\ 'lnum': l:match[1] + 0,
\ 'col': l:match[2] + 0,
\}
" Start looking for the message and error type.
let l:looking_for_message = 1
endif
endfor
return l:output
endfunction
function! ale_linters#fortran#gcc#GetCommand(buffer) abort
let l:layout_option = ale#Var(a:buffer, 'fortran_gcc_use_free_form')
\ ? '-ffree-form'
\ : '-ffixed-form'
return '%e -S -x f95 -fsyntax-only ' . l:layout_option
\ . ale#Pad(ale#Var(a:buffer, 'fortran_gcc_options'))
\ . ' -'
endfunction
call ale#linter#Define('fortran', {
\ 'name': 'gcc',
\ 'output_stream': 'stderr',
\ 'executable_callback': ale#VarFunc('fortran_gcc_executable'),
\ 'command_callback': 'ale_linters#fortran#gcc#GetCommand',
\ 'callback': 'ale_linters#fortran#gcc#Handle',
\})

View file

@ -0,0 +1,19 @@
" Author: unpairedbracket ben.spiers22@gmail.com
" Description: A language server for fortran
call ale#Set('fortran_language_server_executable', 'fortls')
call ale#Set('fortran_language_server_use_global', get(g:, 'ale_use_global_executables', 0))
function! ale_linters#fortran#language_server#GetProjectRoot(buffer) abort
let l:fortls_file = ale#path#FindNearestFile(a:buffer, '.fortls')
return !empty(l:fortls_file) ? fnamemodify(l:fortls_file, ':h') : ''
endfunction
call ale#linter#Define('fortran', {
\ 'name': 'language_server',
\ 'lsp': 'stdio',
\ 'executable_callback': ale#VarFunc('fortran_language_server_executable'),
\ 'command': '%e',
\ 'project_root_callback': 'ale_linters#fortran#language_server#GetProjectRoot',
\})

View file

@ -0,0 +1,9 @@
" Author: Jansen Mitchell https://github.com/JansenMitchell
" Description: proselint for Fountain files
call ale#linter#Define('fountain', {
\ 'name': 'proselint',
\ 'executable': 'proselint',
\ 'command': 'proselint %t',
\ 'callback': 'ale#handlers#unix#HandleAsWarning',
\})

View file

@ -0,0 +1,33 @@
" Author: RyanSquared <vandor2012@gmail.com>
" Description: `fusion-lint` linter for FusionScript files
call ale#Set('fuse_fusionlint_executable', 'fusion-lint')
call ale#Set('fuse_fusionlint_options', '')
function! ale_linters#fuse#fusionlint#GetCommand(buffer) abort
return '%e' . ale#Pad(ale#Var(a:buffer, 'fuse_fusionlint_options'))
\ . ' --filename %s -i'
endfunction
function! ale_linters#fuse#fusionlint#Handle(buffer, lines) abort
let l:pattern = '^.*:\(\d\+\):\(\d\+\): (\([WE]\)\d\+) \(.\+\)$'
let l:output = []
for l:match in ale#util#GetMatches(a:lines, l:pattern)
call add(l:output, {
\ 'lnum': l:match[1] + 0,
\ 'col': l:match[2] + 0,
\ 'text': l:match[4],
\ 'type': l:match[3],
\})
endfor
return l:output
endfunction
call ale#linter#Define('fuse', {
\ 'name': 'fusionlint',
\ 'executable_callback': ale#VarFunc('fuse_fusionlint_executable'),
\ 'command_callback': 'ale_linters#fuse#fusionlint#GetCommand',
\ 'callback': 'ale_linters#fuse#fusionlint#Handle',
\})

View file

@ -0,0 +1,51 @@
" Author: Nick Yamane <nick.diego@gmail.com>
" Description: gitlint for git commit message files
call ale#Set('gitcommit_gitlint_executable', 'gitlint')
call ale#Set('gitcommit_gitlint_options', '')
call ale#Set('gitcommit_gitlint_use_global', get(g:, 'ale_use_global_executables', 0))
function! ale_linters#gitcommit#gitlint#GetExecutable(buffer) abort
return ale#python#FindExecutable(a:buffer, 'gitcommit_gitlint', ['gitlint'])
endfunction
function! ale_linters#gitcommit#gitlint#GetCommand(buffer) abort
let l:options = ale#Var(a:buffer, 'gitcommit_gitlint_options')
return '%e' . ale#Pad(l:options) . ' lint'
endfunction
function! ale_linters#gitcommit#gitlint#Handle(buffer, lines) abort
" Matches patterns line the following:
let l:pattern = '\v^(\d+): (\w+) (.*)$'
let l:output = []
for l:match in ale#util#GetMatches(a:lines, l:pattern)
let l:code = l:match[2]
if !ale#Var(a:buffer, 'warn_about_trailing_whitespace')
if l:code is# 'T2' || l:code is# 'B2'
continue
endif
endif
let l:item = {
\ 'lnum': l:match[1] + 0,
\ 'text': l:match[3],
\ 'code': l:code,
\ 'type': 'E',
\}
call add(l:output, l:item)
endfor
return l:output
endfunction
call ale#linter#Define('gitcommit', {
\ 'name': 'gitlint',
\ 'output_stream': 'stderr',
\ 'executable_callback': 'ale_linters#gitcommit#gitlint#GetExecutable',
\ 'command_callback': 'ale_linters#gitcommit#gitlint#GetCommand',
\ 'callback': 'ale_linters#gitcommit#gitlint#Handle',
\})

View file

@ -0,0 +1,40 @@
" Author: Sven-Hendrik Haase <svenstaro@gmail.com>
" Description: glslang-based linter for glsl files
"
" TODO: Once https://github.com/KhronosGroup/glslang/pull/1047 is accepted,
" we can use stdin.
call ale#Set('glsl_glslang_executable', 'glslangValidator')
call ale#Set('glsl_glslang_options', '')
function! ale_linters#glsl#glslang#GetCommand(buffer) abort
return '%e'
\ . ale#Pad(ale#Var(a:buffer, 'glsl_glslang_options'))
\ . ' -C %t'
endfunction
function! ale_linters#glsl#glslang#Handle(buffer, lines) abort
" Matches patterns like the following:
"
" ERROR: 0:5: 'foo' : undeclared identifier
let l:pattern = '^\(.\+\): \(\d\+\):\(\d\+\): \(.\+\)'
let l:output = []
for l:match in ale#util#GetMatches(a:lines, l:pattern)
call add(l:output, {
\ 'lnum': str2nr(l:match[3]),
\ 'col': str2nr(l:match[2]),
\ 'text': l:match[4],
\ 'type': l:match[1] is# 'ERROR' ? 'E' : 'W',
\})
endfor
return l:output
endfunction
call ale#linter#Define('glsl', {
\ 'name': 'glslang',
\ 'executable_callback': ale#VarFunc('glsl_glslang_executable'),
\ 'command_callback': 'ale_linters#glsl#glslang#GetCommand',
\ 'callback': 'ale_linters#glsl#glslang#Handle',
\})

View file

@ -0,0 +1,30 @@
" Author: Sven-Hendrik Haase <svenstaro@gmail.com>
" Description: A language server for glsl
call ale#Set('glsl_glslls_executable', 'glslls')
call ale#Set('glsl_glslls_logfile', '')
function! ale_linters#glsl#glslls#GetCommand(buffer) abort
let l:logfile = ale#Var(a:buffer, 'glsl_glslls_logfile')
let l:logfile_args = ''
if l:logfile isnot# ''
let l:logfile_args = ' --verbose -l ' . l:logfile
endif
return '%e' . l:logfile_args . ' --stdin'
endfunction
function! ale_linters#glsl#glslls#GetProjectRoot(buffer) abort
let l:project_root = ale#c#FindProjectRoot(a:buffer)
return !empty(l:project_root) ? fnamemodify(l:project_root, ':h:h') : ''
endfunction
call ale#linter#Define('glsl', {
\ 'name': 'glslls',
\ 'lsp': 'stdio',
\ 'executable_callback': ale#VarFunc('glsl_glslls_executable'),
\ 'command_callback': 'ale_linters#glsl#glslls#GetCommand',
\ 'project_root_callback': 'ale_linters#glsl#glslls#GetProjectRoot',
\})

View file

@ -0,0 +1,56 @@
" Author: Joshua Rubin <joshua@rubixconsulting.com>, Ben Reedy <https://github.com/breed808>,
" Jeff Willette <jrwillette88@gmail.com>
" Description: go build for Go files
" inspired by work from dzhou121 <dzhou121@gmail.com>
call ale#Set('go_go_executable', 'go')
call ale#Set('go_gobuild_options', '')
function! ale_linters#go#gobuild#GetCommand(buffer) abort
let l:options = ale#Var(a:buffer, 'go_gobuild_options')
" Run go test in local directory with relative path
return ale#path#BufferCdString(a:buffer)
\ . ale#Var(a:buffer, 'go_go_executable') . ' test'
\ . (!empty(l:options) ? ' ' . l:options : '')
\ . ' -c -o /dev/null ./'
endfunction
function! ale_linters#go#gobuild#GetMatches(lines) abort
" Matches patterns like the following:
"
" file.go:27: missing argument for Printf("%s"): format reads arg 2, have only 1 args
" file.go:53:10: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary)
" file.go:5:2: expected declaration, found 'STRING' "log"
" go test returns relative paths so use tail of filename as part of pattern matcher
let l:pattern = '\v^([a-zA-Z]?:?[^:]+):(\d+):?(\d+)?:? (.+)$'
return ale#util#GetMatches(a:lines, l:pattern)
endfunction
function! ale_linters#go#gobuild#Handler(buffer, lines) abort
let l:dir = expand('#' . a:buffer . ':p:h')
let l:output = []
for l:match in ale_linters#go#gobuild#GetMatches(a:lines)
call add(l:output, {
\ 'filename': ale#path#GetAbsPath(l:dir, l:match[1]),
\ 'lnum': l:match[2] + 0,
\ 'col': l:match[3] + 0,
\ 'text': l:match[4],
\ 'type': 'E',
\})
endfor
return l:output
endfunction
call ale#linter#Define('go', {
\ 'name': 'gobuild',
\ 'aliases': ['go build'],
\ 'executable_callback': ale#VarFunc('go_go_executable'),
\ 'command_callback': 'ale_linters#go#gobuild#GetCommand',
\ 'output_stream': 'stderr',
\ 'callback': 'ale_linters#go#gobuild#Handler',
\ 'lint_file': 1,
\})

View file

@ -0,0 +1,10 @@
" Author: neersighted <bjorn@neersighted.com>
" Description: gofmt for Go files
call ale#linter#Define('go', {
\ 'name': 'gofmt',
\ 'output_stream': 'stderr',
\ 'executable': 'gofmt',
\ 'command': 'gofmt -e %t',
\ 'callback': 'ale#handlers#unix#HandleAsError',
\})

View file

@ -0,0 +1,56 @@
" Author: Sascha Grunert <mail@saschagrunert.de>
" Description: Adds support of golangci-lint
call ale#Set('go_golangci_lint_options', '--enable-all')
call ale#Set('go_golangci_lint_executable', 'golangci-lint')
call ale#Set('go_golangci_lint_package', 0)
function! ale_linters#go#golangci_lint#GetCommand(buffer) abort
let l:filename = expand('#' . a:buffer . ':t')
let l:options = ale#Var(a:buffer, 'go_golangci_lint_options')
let l:lint_package = ale#Var(a:buffer, 'go_golangci_lint_package')
if l:lint_package
return ale#path#BufferCdString(a:buffer)
\ . '%e run '
\ . l:options
endif
return ale#path#BufferCdString(a:buffer)
\ . '%e run '
\ . ale#Escape(l:filename)
\ . ' ' . l:options
endfunction
function! ale_linters#go#golangci_lint#GetMatches(lines) abort
let l:pattern = '\v^([a-zA-Z]?:?[^:]+):(\d+):?(\d+)?:?:?:?\s\*?(.+)$'
return ale#util#GetMatches(a:lines, l:pattern)
endfunction
function! ale_linters#go#golangci_lint#Handler(buffer, lines) abort
let l:dir = expand('#' . a:buffer . ':p:h')
let l:output = []
for l:match in ale_linters#go#golangci_lint#GetMatches(a:lines)
" l:match[1] will already be an absolute path, output from
" golangci_lint
call add(l:output, {
\ 'filename': ale#path#GetAbsPath(l:dir, l:match[1]),
\ 'lnum': l:match[2] + 0,
\ 'col': l:match[3] + 0,
\ 'type': 'E',
\ 'text': l:match[4],
\})
endfor
return l:output
endfunction
call ale#linter#Define('go', {
\ 'name': 'golangci-lint',
\ 'executable_callback': ale#VarFunc('go_golangci_lint_executable'),
\ 'command_callback': 'ale_linters#go#golangci_lint#GetCommand',
\ 'callback': 'ale_linters#go#golangci_lint#Handler',
\ 'lint_file': 1,
\})

View file

@ -0,0 +1,10 @@
" Author: neersighted <bjorn@neersighted.com>
" Description: golint for Go files
call ale#linter#Define('go', {
\ 'name': 'golint',
\ 'output_stream': 'both',
\ 'executable': 'golint',
\ 'command': 'golint %t',
\ 'callback': 'ale#handlers#unix#HandleAsWarning',
\})

View file

@ -0,0 +1,57 @@
" Author: Ben Reedy <https://github.com/breed808>, Jeff Willette <jrwillette88@gmail.com>
" Description: Adds support for the gometalinter suite for Go files
call ale#Set('go_gometalinter_options', '')
call ale#Set('go_gometalinter_executable', 'gometalinter')
call ale#Set('go_gometalinter_lint_package', 0)
function! ale_linters#go#gometalinter#GetCommand(buffer) abort
let l:filename = expand('#' . a:buffer . ':t')
let l:options = ale#Var(a:buffer, 'go_gometalinter_options')
let l:lint_package = ale#Var(a:buffer, 'go_gometalinter_lint_package')
" BufferCdString is used so that we can be sure the paths output from gometalinter can
" be calculated to absolute paths in the Handler
if l:lint_package
return ale#path#BufferCdString(a:buffer)
\ . '%e'
\ . (!empty(l:options) ? ' ' . l:options : '') . ' .'
endif
return ale#path#BufferCdString(a:buffer)
\ . '%e'
\ . ' --include=' . ale#Escape(ale#util#EscapePCRE(l:filename))
\ . (!empty(l:options) ? ' ' . l:options : '') . ' .'
endfunction
function! ale_linters#go#gometalinter#GetMatches(lines) abort
let l:pattern = '\v^([a-zA-Z]?:?[^:]+):(\d+):?(\d+)?:?:?(warning|error):?\s\*?(.+)$'
return ale#util#GetMatches(a:lines, l:pattern)
endfunction
function! ale_linters#go#gometalinter#Handler(buffer, lines) abort
let l:dir = expand('#' . a:buffer . ':p:h')
let l:output = []
for l:match in ale_linters#go#gometalinter#GetMatches(a:lines)
" l:match[1] will already be an absolute path, output from gometalinter
call add(l:output, {
\ 'filename': ale#path#GetAbsPath(l:dir, l:match[1]),
\ 'lnum': l:match[2] + 0,
\ 'col': l:match[3] + 0,
\ 'type': tolower(l:match[4]) is# 'warning' ? 'W' : 'E',
\ 'text': l:match[5],
\})
endfor
return l:output
endfunction
call ale#linter#Define('go', {
\ 'name': 'gometalinter',
\ 'executable_callback': ale#VarFunc('go_gometalinter_executable'),
\ 'command_callback': 'ale_linters#go#gometalinter#GetCommand',
\ 'callback': 'ale_linters#go#gometalinter#Handler',
\ 'lint_file': 1,
\})

View file

@ -0,0 +1,15 @@
" Author: Ben Reedy <https://github.com/breed808>
" Description: gosimple for Go files
function! ale_linters#go#gosimple#GetCommand(buffer) abort
return ale#path#BufferCdString(a:buffer) . ' gosimple .'
endfunction
call ale#linter#Define('go', {
\ 'name': 'gosimple',
\ 'executable': 'gosimple',
\ 'command_callback': 'ale_linters#go#gosimple#GetCommand',
\ 'callback': 'ale#handlers#go#Handler',
\ 'output_stream': 'both',
\ 'lint_file': 1,
\})

View file

@ -0,0 +1,19 @@
" Author: Jelte Fennema <github-public@jeltef.nl>
" Description: gotype for Go files
function! ale_linters#go#gotype#GetCommand(buffer) abort
if expand('#' . a:buffer . ':p') =~# '_test\.go$'
return ''
endif
return ale#path#BufferCdString(a:buffer) . ' gotype .'
endfunction
call ale#linter#Define('go', {
\ 'name': 'gotype',
\ 'output_stream': 'stderr',
\ 'executable': 'gotype',
\ 'command_callback': 'ale_linters#go#gotype#GetCommand',
\ 'callback': 'ale#handlers#go#Handler',
\ 'lint_file': 1,
\})

View file

@ -0,0 +1,27 @@
" Author: neersighted <bjorn@neersighted.com>
" Description: go vet for Go files
"
" Author: John Eikenberry <jae@zhar.net>
" Description: updated to work with go1.10
call ale#Set('go_go_executable', 'go')
call ale#Set('go_govet_options', '')
function! ale_linters#go#govet#GetCommand(buffer) abort
let l:options = ale#Var(a:buffer, 'go_govet_options')
return ale#path#BufferCdString(a:buffer) . ' '
\ . ale#Var(a:buffer, 'go_go_executable') . ' vet '
\ . (!empty(l:options) ? ' ' . l:options : '')
\ . ' .'
endfunction
call ale#linter#Define('go', {
\ 'name': 'govet',
\ 'aliases': ['go vet'],
\ 'output_stream': 'stderr',
\ 'executable_callback': ale#VarFunc('go_go_executable'),
\ 'command_callback': 'ale_linters#go#govet#GetCommand',
\ 'callback': 'ale#handlers#go#Handler',
\ 'lint_file': 1,
\})

View file

@ -0,0 +1,28 @@
" Author: Horacio Sanson <https://github.com/hsanson>
" Description: Support for go-langserver https://github.com/sourcegraph/go-langserver
call ale#Set('go_langserver_executable', 'go-langserver')
call ale#Set('go_langserver_options', '')
function! ale_linters#go#langserver#GetCommand(buffer) abort
let l:executable = [ale#Escape(ale#Var(a:buffer, 'go_langserver_executable'))]
let l:options = ale#Var(a:buffer, 'go_langserver_options')
let l:options = substitute(l:options, '-gocodecompletion', '', 'g')
let l:options = filter(split(l:options, ' '), 'empty(v:val) != 1')
if(ale#Var(a:buffer, 'completion_enabled') == 1)
call add(l:options, '-gocodecompletion')
endif
let l:options = uniq(sort(l:options))
return join(extend(l:executable, l:options), ' ')
endfunction
call ale#linter#Define('go', {
\ 'name': 'golangserver',
\ 'lsp': 'stdio',
\ 'executable_callback': ale#VarFunc('go_langserver_executable'),
\ 'command_callback': 'ale_linters#go#langserver#GetCommand',
\ 'project_root_callback': 'ale#go#FindProjectRoot',
\})

View file

@ -0,0 +1,33 @@
" Author: Ben Reedy <https://github.com/breed808>
" Description: staticcheck for Go files
call ale#Set('go_staticcheck_options', '')
call ale#Set('go_staticcheck_lint_package', 0)
function! ale_linters#go#staticcheck#GetCommand(buffer) abort
let l:filename = expand('#' . a:buffer . ':t')
let l:options = ale#Var(a:buffer, 'go_staticcheck_options')
let l:lint_package = ale#Var(a:buffer, 'go_staticcheck_lint_package')
" BufferCdString is used so that we can be sure the paths output from
" staticcheck can be calculated to absolute paths in the Handler
if l:lint_package
return ale#path#BufferCdString(a:buffer)
\ . 'staticcheck'
\ . (!empty(l:options) ? ' ' . l:options : '') . ' .'
endif
return ale#path#BufferCdString(a:buffer)
\ . 'staticcheck'
\ . (!empty(l:options) ? ' ' . l:options : '')
\ . ' ' . ale#Escape(l:filename)
endfunction
call ale#linter#Define('go', {
\ 'name': 'staticcheck',
\ 'executable': 'staticcheck',
\ 'command_callback': 'ale_linters#go#staticcheck#GetCommand',
\ 'callback': 'ale#handlers#go#Handler',
\ 'output_stream': 'both',
\ 'lint_file': 1,
\})

View file

@ -0,0 +1,9 @@
" Author: Benjie Gillam <code@benjiegillam.com>
" Description: eslint for GraphQL files
call ale#linter#Define('graphql', {
\ 'name': 'eslint',
\ 'executable_callback': 'ale#handlers#eslint#GetExecutable',
\ 'command_callback': 'ale#handlers#eslint#GetCommand',
\ 'callback': 'ale#handlers#eslint#Handle',
\})

View file

@ -0,0 +1,9 @@
" Author: Michiel Westerbeek <happylinks@gmail.com>
" Description: Linter for GraphQL Schemas
call ale#linter#Define('graphql', {
\ 'name': 'gqlint',
\ 'executable': 'gqlint',
\ 'command': 'gqlint --reporter=simple %t',
\ 'callback': 'ale#handlers#unix#HandleAsWarning',
\})

View file

@ -0,0 +1,22 @@
" Author: Fred Emmott <fe@fb.com>
" Description: Hack support via `hack lsp`
call ale#Set('hack_hack_executable', 'hh_client')
function! ale_linters#hack#hack#GetProjectRoot(buffer) abort
let l:hhconfig = ale#path#FindNearestFile(a:buffer, '.hhconfig')
return !empty(l:hhconfig) ? fnamemodify(l:hhconfig, ':h') : ''
endfunction
function! ale_linters#hack#hack#GetExecutable(buffer) abort
return ale#Var(a:buffer, 'hack_hack_executable')
endfunction
call ale#linter#Define('hack', {
\ 'name': 'hack',
\ 'lsp': 'stdio',
\ 'executable_callback': 'ale_linters#hack#hack#GetExecutable',
\ 'command': '%e lsp --from vim-ale',
\ 'project_root_callback': 'ale_linters#hack#hack#GetProjectRoot',
\})

View file

@ -0,0 +1,40 @@
" Author: Fred Emmott <fe@fb.com>
" Description: Hack support via `hhast lsp`
call ale#Set('hack_hhast_executable', 'vendor/bin/hhast-lint')
function! ale_linters#hack#hhast#GetProjectRoot(buffer) abort
" Find the hack root, then figure out if it's also an HHAST root.
" Don't try to use lint configurations from vendor/foo/bar/hhast-lint.json
let l:hhconfig = ale#path#FindNearestFile(a:buffer, '.hhconfig')
if empty(l:hhconfig)
return ''
endif
let l:root = fnamemodify(l:hhconfig, ':h')
let l:hhast_config = findfile('hhast-lint.json', l:root)
return !empty(l:hhast_config) ? l:root : ''
endfunction
function! ale_linters#hack#hhast#GetExecutable(buffer) abort
let l:root = ale_linters#hack#hhast#GetProjectRoot(a:buffer)
let l:relative = ale#Var(a:buffer, 'hack_hhast_executable')
let l:absolute = findfile(l:relative, l:root)
return !empty(l:absolute) ? l:absolute : ''
endfunction
function! ale_linters#hack#hhast#GetInitializationOptions(buffer) abort
return {'lintMode': 'open-files'}
endfunction
call ale#linter#Define('hack', {
\ 'name': 'hhast',
\ 'lsp': 'stdio',
\ 'executable_callback': 'ale_linters#hack#hhast#GetExecutable',
\ 'command': '%e --mode lsp --from vim-ale',
\ 'project_root_callback': 'ale_linters#hack#hhast#GetProjectRoot',
\ 'initialization_options_callback': 'ale_linters#hack#hhast#GetInitializationOptions',
\})

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