1
0
mirror of https://github.com/gryf/.vim.git synced 2025-12-17 19:40:29 +01:00

Moving from pathogen to NeoBundle

This commit is contained in:
2014-07-27 18:50:47 +02:00
parent a0caebac9a
commit 15369edeee
71 changed files with 83 additions and 21090 deletions

View File

@@ -3,6 +3,7 @@ syntax: glob
*.pyc *.pyc
*.pyo *.pyo
bundle/*
view/* view/*
**/doc/tags **/doc/tags

29
.hgsub
View File

@@ -1,29 +0,0 @@
bundle/git_ack = [git]https://github.com/mileszs/ack.vim.git
bundle/git_calendar = [git]https://github.com/mattn/calendar-vim.git
bundle/git_gundo = [git]https://github.com/sjl/gundo.vim.git
bundle/doc_git_py2stdlib = [git]https://github.com/vim-scripts/Python-2.x-Standard-Library-Reference.git
bundle/ft_git_pyflakes-vim = [git]https://github.com/kevinw/pyflakes-vim.git
bundle/ft_git_pydoc = [git]https://github.com/fs111/pydoc.vim.git
bundle/git_vcscommand = [git]http://repo.or.cz/r/vcscommand.git
bundle/git_tagbar = [git]https://github.com/majutsushi/tagbar.git
bundle/git_surround = [git]https://github.com/tpope/vim-surround.git
#bundle/git_snipmate = [git]https://github.com/msanders/snipmate.vim.git
bundle/git_ultisnips = [git]https://github.com/SirVer/ultisnips.git
bundle/git_repeat = [git]https://github.com/tpope/vim-repeat.git
bundle/git_nerdcommenter = [git]https://github.com/scrooloose/nerdcommenter.git
bundle/git_ctrlp = [git]https://github.com/kien/ctrlp.vim.git
bundle/git_syntastic = [git]https://github.com/scrooloose/syntastic.git
bundle/git_taglisttoo = [git]https://github.com/ervandew/taglisttoo.git
bundle/git_vim-javascript = [git]https://github.com/pangloss/vim-javascript.git
bundle/git_vim-nodejs-complete = [git]https://github.com/myhere/vim-nodejs-complete.git
bundle/git_fugitive = [git]https://github.com/tpope/vim-fugitive.git
bundle/git_markdown = [git]https://github.com/hallison/vim-markdown.git
bundle/git_riv = [git]https://github.com/Rykka/riv.vim.git
bundle/git_zoom = [git]https://github.com/gryf/zoom.vim.git
bundle/git_nerdtree = [git]https://github.com/scrooloose/nerdtree.git
bundle/git_css = [git]https://github.com/skammer/vim-css-color.git
bundle/ft_git_matchtagalways = [git]https://github.com/Valloric/MatchTagAlways.git
bundle/git_vim-snippets = [git]https://github.com/honza/vim-snippets.git
bundle/git_jedi = [git]https://github.com/davidhalter/jedi-vim.git
bundle/git_multiple-cursors = [git]https://github.com/terryma/vim-multiple-cursors.git
bundle/git_html5 = [git]https://github.com/othree/html5.vim.git

View File

@@ -1,28 +0,0 @@
305b08a99a6e3e3c4df6f6936869ba69a6b21fcf bundle/doc_git_py2stdlib
8cf9444704091f4babedd757617f03c390bb0f92 bundle/ft_git_matchtagalways
6adcfcd402d34eacb7e6a1dd85c8757bb71e3618 bundle/ft_git_pydoc
92ab1d390d0dbf0d949aba27c9eb1e4ed0abde0e bundle/ft_git_pyflakes-vim
303bceff1c8ab1145d114083582b1aeac9de7a85 bundle/git_ack
186ae21ab46bb1c2830434160a77cc1352646f77 bundle/git_calendar
417eaf8a20a6208e34ff167f5636b20f8f812ed8 bundle/git_css
b5d3fe66a58a13d2ff8b6391f4387608496a030f bundle/git_ctrlp
188692556a025db6ad4c7324961253469979b348 bundle/git_fugitive
3975ac871565115e3769dc69c06bc88ddc1369af bundle/git_gundo
10dca03366fca80a2b9ec7aed49d2864bcadb8ef bundle/git_html5
c32844dfec93569e9e10228703ea535dc70d8b8b bundle/git_jedi
10073c3a3c363c34681c2e37ae29e9675e2cde90 bundle/git_markdown
35028be1f71953da9f2c28509bf6c5ebd1d31c28 bundle/git_multiple-cursors
0b3d928dce8262dedfc2f83b9aeb59a94e4f0ae4 bundle/git_nerdcommenter
55a8954c48d94c207facb1a0ba109a427b15bcbf bundle/git_nerdtree
2a3c5f8e3c26a57b8eb4cfc4be79615a1c508ef6 bundle/git_repeat
43b1d37479af91cac00d01d4e20b7b7e1b94adfb bundle/git_riv
f85cb4e788356f664d033e8519abdd8e1bc26762 bundle/git_surround
0bef7ef3f608f162eba0daee63acd13b3456efcb bundle/git_syntastic
59c9b7ce1cc70ac2c7bd3c858e80c89f17b42cc9 bundle/git_tagbar
7b84e352ed1e395fc54f5a3f60faf4aef9da9f41 bundle/git_taglisttoo
7b8641e1fd49ca9a048b636d9838b5fea6da9536 bundle/git_ultisnips
c0d27010dd0c96884cfd34c3af621ae009109c69 bundle/git_vcscommand
f8122fd1caca68b2592553e43dad45b3dc445a06 bundle/git_vim-javascript
1e2f98f4366c6dec27fa8df72971fa9fa33e9f07 bundle/git_vim-nodejs-complete
368acf7e2752d6c5914d3f45f938dee6525788a2 bundle/git_vim-snippets
757f513c621a48cf34d5b343ddb405ae731b3e38 bundle/git_zoom

68
.vimrc
View File

@@ -1,7 +1,68 @@
"Basic setup for all files {{{ "Basic setup for all files {{{
call pathogen#infect() "infect path for boundles
set nocompatible "VIM over VI set nocompatible "VIM over VI
" NeoBundle conf {{{
if has('vim_starting')
set runtimepath+=~/.vim/bundle/neobundle.vim/
endif
call neobundle#begin(expand('~/.vim/bundle/'))
NeoBundleFetch 'Shougo/neobundle.vim'
NeoBundle "Finkregh/pythonhelper"
NeoBundle "Rykka/riv.vim"
NeoBundle "SirVer/ultisnips"
NeoBundle "Valloric/MatchTagAlways"
NeoBundle "davidhalter/jedi-vim"
NeoBundle "ervandew/taglisttoo"
NeoBundle "fs111/pydoc.vim"
NeoBundle "gryf/mark"
NeoBundle "gryf/zoom.vim"
NeoBundle "hallison/vim-markdown"
NeoBundle "honza/vim-snippets"
NeoBundle "http://repo.or.cz/r/vcscommand.git"
NeoBundle "https://code.google.com/p/vimwiki/"
NeoBundle "kazuyukitanimura/jsbeautify"
NeoBundle "kevinw/pyflakes-vim"
NeoBundle "kien/ctrlp.vim"
NeoBundle "majutsushi/tagbar"
NeoBundle "mattn/calendar-vim"
NeoBundle "mduan/python.vim"
NeoBundle "mikeage/occur.vim"
NeoBundle "mileszs/ack.vim"
NeoBundle "myhere/vim-nodejs-complete"
NeoBundle "othree/html5.vim"
NeoBundle "pangloss/vim-javascript"
NeoBundle "pcaro90/jpythonfold.vim"
NeoBundle "scrooloose/nerdcommenter"
NeoBundle "scrooloose/nerdtree"
NeoBundle "scrooloose/syntastic"
NeoBundle "sjl/gundo.vim"
NeoBundle "skammer/vim-css-color"
NeoBundle "taylor/ctags.vim"
NeoBundle "terryma/vim-multiple-cursors"
NeoBundle "tpope/vim-fugitive"
NeoBundle "tpope/vim-repeat"
NeoBundle "tpope/vim-surround"
NeoBundle "vim-scripts/LanguageTool"
NeoBundle "vim-scripts/MatchTag"
NeoBundle "vim-scripts/Python-2.x-Standard-Library-Reference"
NeoBundle "vim-scripts/ShowMarks"
NeoBundle "vim-scripts/indentpython"
NeoBundle "vim-scripts/loremipsum"
NeoBundle "vim-scripts/mako.vim"
NeoBundle "vim-scripts/mako.vim--Torborg"
NeoBundle "yegappan/grep"
NeoBundle "zhaocai/DirDiff.vim"
NeoBundle "vim-scripts/JavaScript-Indent"
let g:ctags_statusline=1
let generate_tags=1
call neobundle#end()
" }}}
filetype plugin indent on "turn plugins/indent on filetype plugin indent on "turn plugins/indent on
syntax on "Turn syntax highlighting on syntax on "Turn syntax highlighting on
@@ -209,6 +270,11 @@ let g:riv_fold_level = -1
" formatting tables, doesn't work so good with complex grid tables " formatting tables, doesn't work so good with complex grid tables
let g:riv_auto_format_table = 0 let g:riv_auto_format_table = 0
"}}} "}}}
" Occur {{{
nnoremap <silent> <unique> <Leader>oc :Occur<CR>
nnoremap <silent> <unique> <Leader>om :Moccur<CR>
nnoremap <silent> <unique> <Leader>8 *<C-o>:Moccur<CR>
" }}}
"}}} "}}}
"KEYS: User defined keyboard shortcuts {{{ "KEYS: User defined keyboard shortcuts {{{

View File

@@ -1,29 +0,0 @@
ScriptID SourceID Filename
--------------------------
### plugins
102 16171 DirDiff.vim
311 7645 grep.vim
2727 11120 jsbeautify.vim
2289 8922 loremipsum
3223 1 LanguageTool
2666 18811 Mark
2262 8944 occur.vim
152 3342 showmarks.vim
2226 18232 vimwiki.vim
1334 6377 vst.vim
2321 9055 zoom.vim
### ftplugin
3818 19533 MatchTag
30 9196 python_fn.vim
435 12010 pythonhelper.vim
2527 10034 jpythonfold.vim
### indent
2663 12560 mako.vim
3081 15645 JavaScript indent
# there is also python.vim, which is close to PEP8, but author of
# changes doesn't put it on vim.org scripts. it can be (still) found on
# http://monkey.org/~caz/python.vim
### syntax
790 19619 python.vim
1858 9244 mako.vim
2539 9949 css.vim

View File

@@ -1,230 +0,0 @@
" pathogen.vim - path option manipulation
" Maintainer: Tim Pope <http://tpo.pe/>
" Version: 2.0
" Install in ~/.vim/autoload (or ~\vimfiles\autoload).
"
" For management of individually installed plugins in ~/.vim/bundle (or
" ~\vimfiles\bundle), adding `call pathogen#infect()` to your .vimrc
" prior to `fileype plugin indent on` is the only other setup necessary.
"
" The API is documented inline below. For maximum ease of reading,
" :set foldmethod=marker
if exists("g:loaded_pathogen") || &cp
finish
endif
let g:loaded_pathogen = 1
" Point of entry for basic default usage. Give a directory name to invoke
" pathogen#runtime_append_all_bundles() (defaults to "bundle"), or a full path
" to invoke pathogen#runtime_prepend_subdirectories(). Afterwards,
" pathogen#cycle_filetype() is invoked.
function! pathogen#infect(...) abort " {{{1
let source_path = a:0 ? a:1 : 'bundle'
if source_path =~# '[\\/]'
call pathogen#runtime_prepend_subdirectories(source_path)
else
call pathogen#runtime_append_all_bundles(source_path)
endif
call pathogen#cycle_filetype()
endfunction " }}}1
" Split a path into a list.
function! pathogen#split(path) abort " {{{1
if type(a:path) == type([]) | return a:path | endif
let split = split(a:path,'\\\@<!\%(\\\\\)*\zs,')
return map(split,'substitute(v:val,''\\\([\\,]\)'',''\1'',"g")')
endfunction " }}}1
" Convert a list to a path.
function! pathogen#join(...) abort " {{{1
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 " }}}1
" Convert a list to a path with escaped spaces for 'path', 'tag', etc.
function! pathogen#legacyjoin(...) abort " {{{1
return call('pathogen#join',[1] + a:000)
endfunction " }}}1
" Remove duplicates from a list.
function! pathogen#uniq(list) abort " {{{1
let i = 0
let seen = {}
while i < len(a:list)
if has_key(seen,a:list[i])
call remove(a:list,i)
else
let seen[a:list[i]] = 1
let i += 1
endif
endwhile
return a:list
endfunction " }}}1
" \ on Windows unless shellslash is set, / everywhere else.
function! pathogen#separator() abort " {{{1
return !exists("+shellslash") || &shellslash ? '/' : '\'
endfunction " }}}1
" Convenience wrapper around glob() which returns a list.
function! pathogen#glob(pattern) abort " {{{1
let files = split(glob(a:pattern),"\n")
return map(files,'substitute(v:val,"[".pathogen#separator()."/]$","","")')
endfunction "}}}1
" Like pathogen#glob(), only limit the results to directories.
function! pathogen#glob_directories(pattern) abort " {{{1
return filter(pathogen#glob(a:pattern),'isdirectory(v:val)')
endfunction "}}}1
" Turn filetype detection off and back on again if it was already enabled.
function! pathogen#cycle_filetype() " {{{1
if exists('g:did_load_filetypes')
filetype off
filetype on
endif
endfunction " }}}1
" Checks if a bundle is 'disabled'. A bundle is considered 'disabled' if
" its 'basename()' is included in g:pathogen_disabled[]' or ends in a tilde.
function! pathogen#is_disabled(path) " {{{1
if a:path =~# '\~$'
return 1
elseif !exists("g:pathogen_disabled")
return 0
endif
let sep = pathogen#separator()
return index(g:pathogen_disabled, strpart(a:path, strridx(a:path, sep)+1)) != -1
endfunction "}}}1
" Prepend all subdirectories of path to the rtp, and append all 'after'
" directories in those subdirectories.
function! pathogen#runtime_prepend_subdirectories(path) " {{{1
let sep = pathogen#separator()
let before = filter(pathogen#glob_directories(a:path.sep."*"), '!pathogen#is_disabled(v:val)')
let after = filter(pathogen#glob_directories(a:path.sep."*".sep."after"), '!pathogen#is_disabled(v:val[0:-7])')
let rtp = pathogen#split(&rtp)
let path = expand(a:path)
call filter(rtp,'v:val[0:strlen(path)-1] !=# path')
let &rtp = pathogen#join(pathogen#uniq(before + rtp + after))
return &rtp
endfunction " }}}1
" For each directory in rtp, check for a subdirectory named dir. If it
" exists, add all subdirectories of that subdirectory to the rtp, immediately
" after the original directory. If no argument is given, 'bundle' is used.
" Repeated calls with the same arguments are ignored.
function! pathogen#runtime_append_all_bundles(...) " {{{1
let sep = pathogen#separator()
let name = a:0 ? a:1 : 'bundle'
if "\n".s:done_bundles =~# "\\M\n".name."\n"
return ""
endif
let s:done_bundles .= name . "\n"
let list = []
for dir in pathogen#split(&rtp)
if dir =~# '\<after$'
let list += filter(pathogen#glob_directories(substitute(dir,'after$',name,'').sep.'*[^~]'.sep.'after'), '!pathogen#is_disabled(v:val[0:-7])') + [dir]
else
let list += [dir] + filter(pathogen#glob_directories(dir.sep.name.sep.'*[^~]'), '!pathogen#is_disabled(v:val)')
endif
endfor
let &rtp = pathogen#join(pathogen#uniq(list))
return 1
endfunction
let s:done_bundles = ''
" }}}1
" Invoke :helptags on all non-$VIM doc directories in runtimepath.
function! pathogen#helptags() " {{{1
let sep = pathogen#separator()
for dir in pathogen#split(&rtp)
if (dir.sep)[0 : strlen($VIMRUNTIME)] !=# $VIMRUNTIME.sep && filewritable(dir.'/doc') == 2 && !empty(glob(dir.'/doc/*')) && (!filereadable(dir.'/doc/tags') || filewritable(dir.'/doc/tags'))
helptags `=dir.'/doc'`
endif
endfor
endfunction " }}}1
command! -bar Helptags :call pathogen#helptags()
" Like findfile(), but hardcoded to use the runtimepath.
function! pathogen#rtpfindfile(file,count) "{{{1
let rtp = pathogen#join(1,pathogen#split(&rtp))
return fnamemodify(findfile(a:file,rtp,a:count),':p')
endfunction " }}}1
function! s:find(count,cmd,file,...) " {{{1
let rtp = pathogen#join(1,pathogen#split(&runtimepath))
let file = pathogen#rtpfindfile(a:file,a:count)
if file ==# ''
return "echoerr 'E345: Can''t find file \"".a:file."\" in runtimepath'"
elseif a:0
let path = file[0:-strlen(a:file)-2]
execute a:1.' `=path`'
return a:cmd.' '.fnameescape(a:file)
else
return a:cmd.' '.fnameescape(file)
endif
endfunction " }}}1
function! s:Findcomplete(A,L,P) " {{{1
let sep = pathogen#separator()
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 matches = split(glob(path.sep.pattern),"\n")
call map(matches,'isdirectory(v:val) ? v:val.sep : v:val')
call map(matches,'v:val[strlen(path)+1:-1]')
for match in matches
let found[match] = 1
endfor
endfor
return sort(keys(found))
endfunction " }}}1
command! -bar -bang -count=1 -nargs=1 -complete=customlist,s:Findcomplete Ve :execute s:find(<count>,'edit<bang>',<q-args>)
command! -bar -bang -count=1 -nargs=1 -complete=customlist,s:Findcomplete Vedit :execute s:find(<count>,'edit<bang>',<q-args>)
command! -bar -bang -count=1 -nargs=1 -complete=customlist,s:Findcomplete Vsplit :execute s:find(<count>,'split<bang>',<q-args>)
command! -bar -bang -count=1 -nargs=1 -complete=customlist,s:Findcomplete Vvsplit :execute s:find(<count>,'vsplit<bang>',<q-args>)
command! -bar -bang -count=1 -nargs=1 -complete=customlist,s:Findcomplete Vtabedit :execute s:find(<count>,'tabedit<bang>',<q-args>)
command! -bar -bang -count=1 -nargs=1 -complete=customlist,s:Findcomplete Vpedit :execute s:find(<count>,'pedit<bang>',<q-args>)
command! -bar -bang -count=1 -nargs=1 -complete=customlist,s:Findcomplete Vread :execute s:find(<count>,'read<bang>',<q-args>)
command! -bar -bang -count=1 -nargs=1 -complete=customlist,s:Findcomplete Vopen :execute s:find(<count>,'edit<bang>',<q-args>,'lcd')
" vim:set ft=vim ts=8 sw=2 sts=2:

View File

@@ -1,14 +0,0 @@
" Vim compiler file
" Compiler: Javascript Lint
if exists("current_compiler")
finish
endif
let current_compiler = "jsl"
if exists(":CompilerSet") != 2 " older Vim always used :setlocal
command -nargs=* CompilerSet setlocal <args>
endif
CompilerSet makeprg=jsl\ -nologo\ -nofilelisting\ -nosummary\ -nocontext\ -process\ %
CompilerSet errorformat=%f(%l):\ %m

View File

@@ -1,88 +0,0 @@
#!/usr/bin/env python
"""
This script can be used as a pylint command replacement, especially useful as
a "make" command for VIm
"""
import sys
import re
from cStringIO import StringIO
from optparse import OptionParser
from pylint import lint
from pylint.reporters.text import TextReporter
SYS_STDERR = sys.stderr
DUMMY_STDERR = StringIO()
CONF_MSG = 'No config file found, using default configuration\n'
def parsable_pylint(filename):
"""
Simple wrapper for pylint checker. Provides nice, parseable output.
filename - python fileneame to check
Returns list of dicts of errors, i.e.:
[{'lnum': 5, 'col': 10, 'type': 'C0324',
'text': 'Comma not followed by a space'},
{'lnum': 12, 'type': 'C0111', 'text': 'Missing docstring'},
....
]
"""
# module args
margs = ['-rn', # display only the messages instead of full report
'-iy', # Include message's id in output
filename]
buf = StringIO() # file-like buffer, instead of stdout
reporter = TextReporter(buf)
sys.stderr = DUMMY_STDERR
lint.Run(margs, reporter=reporter, exit=False)
sys.stderr = SYS_STDERR
# see, if we have other errors than 'No config found...' message
DUMMY_STDERR.seek(0)
error_list = DUMMY_STDERR.readlines()
DUMMY_STDERR.truncate(0)
if error_list and CONF_MSG in error_list:
error_list.remove(CONF_MSG)
if error_list:
raise Exception(''.join(error_list))
buf.seek(0)
code_line = {}
error_list = []
carriage_re = re.compile(r'\s*\^+$')
error_re = re.compile(r'^([C,R,W,E,F].+):(\s+)?([0-9]+):?.*:\s(.*)$')
for bufline in buf:
bufline = bufline.rstrip() # remove trailing newline character
if error_re.match(bufline):
if code_line:
error_list.append(code_line)
code_line = {}
(code_line['type'], _unused, code_line['lnum'],
code_line['text']) = error_re.match(bufline).groups()
if carriage_re.match(bufline) and code_line:
code_line['col'] = carriage_re.match(bufline).group().find('^') + 1
return error_list
if __name__ == "__main__":
PARSER = OptionParser("usage: %prog python_file")
(OPTIONS, args) = PARSER.parse_args()
if len(args) == 1:
for line in parsable_pylint(args[0]):
line['short'] = line['type'][0]
line['fname'] = args[0]
out = "%(fname)s: %(short)s: %(lnum)s: %(col)s: %(type)s %(text)s"
if 'col' not in line:
out = "%(fname)s: %(short)s: %(lnum)s: 0: %(type)s %(text)s"
print out % line

View File

@@ -1,12 +0,0 @@
" Vim compiler file for Python
" Compiler: Static code checking tool for Python
" Maintainer: Roman 'gryf' Dobosz
" Last Change: 2010-09-12
" Version: 1.0
if exists("current_compiler")
finish
endif
let current_compiler = "pylint"
CompilerSet makeprg=pylint_parseable.py\ %
CompilerSet efm=%f:\ %t:\ %l:\ %c:\ %m,%f:\ %t:\ %l:\ %m

View File

@@ -1,5 +0,0 @@
Simple pylint compiler for Vim.
Installation:
Place bin/pylint_parseable.py into your path (/usr/local/bin or whenever) and
compiler/pylint.vim under ~/.vim/compiler.

File diff suppressed because it is too large Load Diff

View File

@@ -1,231 +0,0 @@
" Fold routines for python code, version 3.2
" Source: http://www.vim.org/scripts/script.php?script_id=2527
" Last Change: 2009 Feb 25
" Author: Jurjen Bos
" Bug fixes and helpful comments: Grissiom, David Froger, Andrew McNabb
" Principles:
" - a def/class starts a fold
" a line with indent less than the previous def/class ends a fold
" empty lines and comment lines are linked to the previous fold
" comment lines outside a def/class are never folded
" other lines outside a def/class are folded together as a group
" for algorithm, see bottom of script
" - optionally, you can get empty lines between folds, see (***)
" - another option is to ignore non-python files see (**)
" - you can also modify the def/class check,
" allowing for multiline def and class definitions see (*)
" Note for vim 7 users:
" Vim 6 line numbers always take 8 columns, while vim 7 has a numberwidth variable
" you can change the 8 below to &numberwidth if you have vim 7,
" this is only really useful when you plan to use more than 8 columns (i.e. never)
" Note for masochists trying to read this:
" I wanted to keep the functions short, so I replaced occurences of
" if condition
" statement
" by
" if condition | statement
" wherever I found that useful
" (*)
" class definitions are supposed to ontain a colon on the same line.
" function definitions are *not* required to have a colon, to allow for multiline defs.
" I you disagree, use instead of the pattern '^\s*\(class\s.*:\|def\s\)'
" to enforce : for defs: '^\s*\(class\|def\)\s.*:'
" you'll have to do this in two places.
let s:defpat = '^\s*\(@\|class\s.*:\|def\s\)'
" (**) Ignore non-python files
" Commented out because some python files are not recognized by Vim
"if &filetype != 'python'
" finish
"endif
setlocal foldmethod=expr
setlocal foldexpr=GetPythonFold(v:lnum)
setlocal foldtext=PythonFoldText()
function! PythonFoldText()
let fs = v:foldstart
while getline(fs) =~ '^\s*@' | let fs = nextnonblank(fs + 1)
endwhile
let line = getline(fs)
let nnum = nextnonblank(fs + 1)
let nextline = getline(nnum)
"get the document string: next line is ''' or """
if nextline =~ "^\\s\\+[\"']\\{3}\\s*$"
let line = line . " " . matchstr(getline(nextnonblank(nnum + 1)), '^\s*\zs.*\ze$')
"next line starts with qoutes, and has text
elseif nextline =~ "^\\s\\+[\"']\\{1,3}"
let line = line." ".matchstr(nextline, "^\\s\\+[\"']\\{1,3}\\zs.\\{-}\\ze['\"]\\{0,3}$")
elseif nextline =~ '^\s\+pass\s*$'
let line = line . ' pass'
endif
"compute the width of the visible part of the window (see Note above)
let w = winwidth(0) - &foldcolumn - (&number ? 8 : 0)
let size = 1 + v:foldend - v:foldstart
"compute expansion string
let spcs = '................'
while strlen(spcs) < w | let spcs = spcs . spcs
endwhile
"expand tabs (mail me if you have tabstop>10)
let onetab = strpart(' ', 0, &tabstop)
let line = substitute(line, '\t', onetab, 'g')
return strpart(line.spcs, 0, w-strlen(size)-7).'.'.size.' lines'
endfunction
function! GetBlockIndent(lnum)
" Auxiliary function; determines the indent level of the surrounding def/class
" "global" lines are level 0, first def &shiftwidth, and so on
" scan backwards for class/def that is shallower or equal
let ind = 100
let p = a:lnum+1
while indent(p) >= 0
let p = p - 1
" skip empty and comment lines
if getline(p) =~ '^$\|^\s*#' | continue
" zero-level regular line
elseif indent(p) == 0 | return 0
" skip deeper or equal lines
elseif indent(p) >= ind || getline(p) =~ '^$\|^\s*#' | continue
" indent is strictly less at this point: check for def/class
elseif getline(p) =~ s:defpat && getline(p) !~ '^\s*@'
" level is one more than this def/class
return indent(p) + &shiftwidth
endif
" shallower line that is neither class nor def: continue search at new level
let ind = indent(p)
endwhile
"beginning of file
return 0
endfunction
" Clever debug code, use as: call PrintIfCount(n,"Line: ".a:lnum.", value: ".x)
let s:counter=0
function! PrintIfCount(n,t)
"Print text the nth time this function is called
let s:counter = s:counter+1
if s:counter==a:n | echo a:t
endif
endfunction
function! GetPythonFold(lnum)
" Determine folding level in Python source (see "higher foldlevel theory" below)
let line = getline(a:lnum)
let ind = indent(a:lnum)
" Case D***: class and def start a fold
" If previous line is @, it is not the first
if line =~ s:defpat && getline(prevnonblank(a:lnum-1)) !~ '^\s*@'
" let's see if this range of 0 or more @'s end in a class/def
let n = a:lnum
while getline(n) =~ '^\s*@' | let n = nextnonblank(n + 1)
endwhile
" yes, we have a match: this is the first of a real def/class with decorators
if getline(n) =~ s:defpat
return ">".(ind/&shiftwidth+1)
endif
" Case E***: empty lines fold with previous
" (***) change '=' to -1 if you want empty lines/comment out of a fold
elseif line == '' | return '='
endif
" now we need the indent from previous
let p = prevnonblank(a:lnum-1)
while p>0 && getline(p) =~ '^\s*#' | let p = prevnonblank(p-1)
endwhile
let pind = indent(p)
" If previous was definition: count as one level deeper
if getline(p) =~ s:defpat && getline(prevnonblank(a:lnum - 1)) !~ '^\s*@'
let pind = pind + &shiftwidth
" if begin of file: take zero
elseif p==0 | let pind = 0
endif
" Case S*=* and C*=*: indent equal
if ind>0 && ind==pind | return '='
" Case S*>* and C*>*: indent increase
elseif ind>pind | return '='
" All cases with 0 indent
elseif ind==0
" Case C*=0*: separate global code blocks
if pind==0 && line =~ '^#' | return 0
" Case S*<0* and S*=0*: global code
elseif line !~'^#'
" Case S*<0*: new global statement if/while/for/try/with
if 0<pind && line!~'^else\s*:\|^except.*:\|^elif.*:\|^finally\s*:' | return '>1'
" Case S*=0*, after level 0 comment
elseif 0==pind && getline(prevnonblank(a:lnum-1)) =~ '^\s*#' | return '>1'
" Case S*=0*, other, stay 1
else | return '='
endif
endif
" Case C*<0= and C*<0<: compute next indent
let n = nextnonblank(a:lnum+1)
while n>0 && getline(n) =~'^\s*#' | let n = nextnonblank(n+1)
endwhile
" Case C*<0=: split definitions
if indent(n)==0 | return 0
" Case C*<0<: shallow comment
else | return -1
end
endif
" now we really need to compute the actual fold indent
" do the hard computation
let blockindent = GetBlockIndent(a:lnum)
" Case SG<* and CG<*: global code, level 1
if blockindent==0 | return 1
endif
" now we need the indent from next
let n = nextnonblank(a:lnum+1)
while n>0 && getline(n) =~'^\s*#' | let n = nextnonblank(n+1)
endwhile
let nind = indent(n)
" Case CR<= and CR<>
"if line !~ '^\s*#' | call PrintIfCount(4,"Line: ".a:lnum.", blockindent: ".blockindent.", n: ".n.", nind: ".nind.", p: ".p.", pind: ".pind)
endif
if line =~ '^\s*#' && ind>=nind | return -1
" Case CR<<: return next indent
elseif line =~ '^\s*#' | return nind / &shiftwidth
" Case SR<*: return actual indent
else | return blockindent / &shiftwidth
endif
endfunction
" higher foldlevel theory
" There are five kinds of statements: S (code), D (def/class), E (empty), C (comment)
" Note that a decorator statement (beginning with @) counts as definition,
" but that of a sequence of @,@,@,def only the first one counts
" This means that a definiion only counts if not preceded by a decorator
" There are two kinds of folds: R (regular), G (global statements)
" There are five indent situations with respect to the previous non-emtpy non-comment line:
" > (indent), < (dedent), = (same); < and = combine with 0 (indent is zero)
" Note: if the previous line is class/def, its indent is interpreted as one higher
" There are three indent situations with respect to the next (non-E non-C) line:
" > (dedent), < (indent), = (same)
" Situations (in order of the script):
" stat fold prev next
" SDEC RG ><=00 ><=
" D * * * begin fold level if previous is not @: '>'.ind/&sw+1
" E * * * keep with previous: '='
" S * = * stays the same: '='
" C * = * combine with previous: '='
" S * > * stays the same: '='
" C * > * combine with previous: '='
" C * =0 * separate blocks: 0
" S * <0 * becomes new level 1: >1 (except except/else: 1)
" S * =0 * stays 1: '=' (after level 0 comment: '>1')
" C * <0 = split definitions: 0
" C * <0 < shallow comment: -1
" C * <0 > [never occurs]
" S G < * global, not the first: 1
" C G < * indent isn't 0: 1
" C R < = foldlevel as computed for next line: -1
" C R < > foldlevel as computed for next line: -1
" S R < * compute foldlevel the hard way: use function
" C R < < foldlevel as computed for this line: use function

View File

@@ -1,87 +0,0 @@
" Vim plugin for showing matching html tags.
" Maintainer: Greg Sexton <gregsexton@gmail.com>
" Credits: Bram Moolenar and the 'matchparen' plugin from which this draws heavily.
if exists("b:did_ftplugin")
finish
endif
augroup matchhtmlparen
autocmd! CursorMoved,CursorMovedI,WinEnter <buffer> call s:Highlight_Matching_Pair()
augroup END
fu! s:Highlight_Matching_Pair()
" Remove any previous match.
if exists('w:tag_hl_on') && w:tag_hl_on
2match none
let w:tag_hl_on = 0
endif
" Avoid that we remove the popup menu.
" Return when there are no colors (looks like the cursor jumps).
if pumvisible() || (&t_Co < 8 && !has("gui_running"))
return
endif
"get html tag under cursor
let tagname = s:GetCurrentCursorTag()
if tagname == ""|return|endif
if tagname[0] == '/'
let position = s:SearchForMatchingTag(tagname[1:], 0)
else
let position = s:SearchForMatchingTag(tagname, 1)
endif
call s:HighlightTagAtPosition(position)
endfu
fu! s:GetCurrentCursorTag()
"returns the tag under the cursor, includes the '/' if on a closing tag.
let c_col = col('.')
let matched = matchstr(getline('.'), '\(<[^<>]*\%'.c_col.'c.\{-}>\)\|\(\%'.c_col.'c<.\{-}>\)')
if matched == "" || matched =~ '/>$'
return ""
endif
let tagname = matchstr(matched, '<\zs.\{-}\ze[ >]')
return tagname
endfu
fu! s:SearchForMatchingTag(tagname, forwards)
"returns the position of a matching tag or [0 0]
let starttag = '<'.a:tagname.'.\{-}/\@<!>'
let midtag = ''
let endtag = '</'.a:tagname.'.\{-}'.(a:forwards?'':'\zs').'>'
let flags = 'nW'.(a:forwards?'':'b')
" When not in a string or comment ignore matches inside them.
let skip ='synIDattr(synID(line("."), col("."), 0), "name") ' .
\ '=~? "htmlString\\|htmlCommentPart"'
execute 'if' skip '| let skip = 0 | endif'
" Limit the search to lines visible in the window.
let stopline = a:forwards ? line('w$') : line('w0')
let timeout = 300
" The searchpairpos() timeout parameter was added in 7.2
if v:version >= 702
return searchpairpos(starttag, midtag, endtag, flags, skip, stopline, timeout)
else
return searchpairpos(starttag, midtag, endtag, flags, skip, stopline)
endif
endfu
fu! s:HighlightTagAtPosition(position)
if a:position == [0, 0]
return
endif
let [m_lnum, m_col] = a:position
exe '2match MatchParen /\(\%' . m_lnum . 'l\%' . m_col . 'c<\zs.\{-}\ze[ >]\)\|'
\ .'\(\%' . line('.') . 'l\%' . col('.') . 'c<\zs.\{-}\ze[ >]\)\|'
\ .'\(\%' . line('.') . 'l<\zs[^<> ]*\%' . col('.') . 'c.\{-}\ze[ >]\)\|'
\ .'\(\%' . line('.') . 'l<\zs[^<>]\{-}\ze\s[^<>]*\%' . col('.') . 'c.\{-}>\)/'
let w:tag_hl_on = 1
endfu

View File

@@ -1,2 +0,0 @@
runtime! ftplugin/html.vim

View File

@@ -1,447 +0,0 @@
" -*- vim -*-
" FILE: python_fn.vim
" LAST MODIFICATION: 2008-08-28 8:19pm
" (C) Copyright 2001-2005 Mikael Berthe <bmikael@lists.lilotux.net>
" Maintained by Jon Franklin <jvfranklin@gmail.com>
" Version: 1.13
" USAGE:
"
" Save this file to $VIMFILES/ftplugin/python.vim. You can have multiple
" python ftplugins by creating $VIMFILES/ftplugin/python and saving your
" ftplugins in that directory. If saving this to the global ftplugin
" directory, this is the recommended method, since vim ships with an
" ftplugin/python.vim file already.
" You can set the global variable "g:py_select_leading_comments" to 0
" if you don't want to select comments preceding a declaration (these
" are usually the description of the function/class).
" You can set the global variable "g:py_select_trailing_comments" to 0
" if you don't want to select comments at the end of a function/class.
" If these variables are not defined, both leading and trailing comments
" are selected.
" Example: (in your .vimrc) "let g:py_select_leading_comments = 0"
" You may want to take a look at the 'shiftwidth' option for the
" shift commands...
"
" REQUIREMENTS:
" vim (>= 7)
"
" Shortcuts:
" ]t -- Jump to beginning of block
" ]e -- Jump to end of block
" ]v -- Select (Visual Line Mode) block
" ]< -- Shift block to left
" ]> -- Shift block to right
" ]# -- Comment selection
" ]u -- Uncomment selection
" ]c -- Select current/previous class
" ]d -- Select current/previous function
" ]<up> -- Jump to previous line with the same/lower indentation
" ]<down> -- Jump to next line with the same/lower indentation
" Only do this when not done yet for this buffer
if exists("b:loaded_py_ftplugin")
finish
endif
let b:loaded_py_ftplugin = 1
map ]t :PBoB<CR>
vmap ]t :<C-U>PBOB<CR>m'gv``
map ]e :PEoB<CR>
vmap ]e :<C-U>PEoB<CR>m'gv``
map ]v ]tV]e
map ]< ]tV]e<
vmap ]< <
map ]> ]tV]e>
vmap ]> >
map ]# :call PythonCommentSelection()<CR>
vmap ]# :call PythonCommentSelection()<CR>
map ]u :call PythonUncommentSelection()<CR>
vmap ]u :call PythonUncommentSelection()<CR>
" gryf: change mapping for class selection
map ]C :call PythonSelectObject("class")<CR>
map ]d :call PythonSelectObject("function")<CR>
map ]<up> :call PythonNextLine(-1)<CR>
map ]<down> :call PythonNextLine(1)<CR>
" You may prefer use <s-up> and <s-down>... :-)
" jump to previous class
map ]J :call PythonDec("class", -1)<CR>
vmap ]J :call PythonDec("class", -1)<CR>
" jump to next class
map ]j :call PythonDec("class", 1)<CR>
vmap ]j :call PythonDec("class", 1)<CR>
" jump to previous function
map ]F :call PythonDec("function", -1)<CR>
vmap ]F :call PythonDec("function", -1)<CR>
" jump to next function
map ]f :call PythonDec("function", 1)<CR>
vmap ]f :call PythonDec("function", 1)<CR>
" Menu entries
nmenu <silent> &Python.Update\ IM-Python\ Menu
\:call UpdateMenu()<CR>
nmenu &Python.-Sep1- :
nmenu <silent> &Python.Beginning\ of\ Block<Tab>[t
\]t
nmenu <silent> &Python.End\ of\ Block<Tab>]e
\]e
nmenu &Python.-Sep2- :
nmenu <silent> &Python.Shift\ Block\ Left<Tab>]<
\]<
vmenu <silent> &Python.Shift\ Block\ Left<Tab>]<
\]<
nmenu <silent> &Python.Shift\ Block\ Right<Tab>]>
\]>
vmenu <silent> &Python.Shift\ Block\ Right<Tab>]>
\]>
nmenu &Python.-Sep3- :
vmenu <silent> &Python.Comment\ Selection<Tab>]#
\]#
nmenu <silent> &Python.Comment\ Selection<Tab>]#
\]#
vmenu <silent> &Python.Uncomment\ Selection<Tab>]u
\]u
nmenu <silent> &Python.Uncomment\ Selection<Tab>]u
\]u
nmenu &Python.-Sep4- :
nmenu <silent> &Python.Previous\ Class<Tab>]J
\]J
nmenu <silent> &Python.Next\ Class<Tab>]j
\]j
nmenu <silent> &Python.Previous\ Function<Tab>]F
\]F
nmenu <silent> &Python.Next\ Function<Tab>]f
\]f
nmenu &Python.-Sep5- :
nmenu <silent> &Python.Select\ Block<Tab>]v
\]v
nmenu <silent> &Python.Select\ Function<Tab>]d
\]d
nmenu <silent> &Python.Select\ Class<Tab>]c
\]c
nmenu &Python.-Sep6- :
nmenu <silent> &Python.Previous\ Line\ wrt\ indent<Tab>]<up>
\]<up>
nmenu <silent> &Python.Next\ Line\ wrt\ indent<Tab>]<down>
\]<down>
:com! PBoB execute "normal ".PythonBoB(line('.'), -1, 1)."G"
:com! PEoB execute "normal ".PythonBoB(line('.'), 1, 1)."G"
:com! UpdateMenu call UpdateMenu()
" Go to a block boundary (-1: previous, 1: next)
" If force_sel_comments is true, 'g:py_select_trailing_comments' is ignored
function! PythonBoB(line, direction, force_sel_comments)
let ln = a:line
let ind = indent(ln)
let mark = ln
let indent_valid = strlen(getline(ln))
let ln = ln + a:direction
if (a:direction == 1) && (!a:force_sel_comments) &&
\ exists("g:py_select_trailing_comments") &&
\ (!g:py_select_trailing_comments)
let sel_comments = 0
else
let sel_comments = 1
endif
while((ln >= 1) && (ln <= line('$')))
if (sel_comments) || (match(getline(ln), "^\\s*#") == -1)
if (!indent_valid)
let indent_valid = strlen(getline(ln))
let ind = indent(ln)
let mark = ln
else
if (strlen(getline(ln)))
if (indent(ln) < ind)
break
endif
let mark = ln
endif
endif
endif
let ln = ln + a:direction
endwhile
return mark
endfunction
" Go to previous (-1) or next (1) class/function definition
function! PythonDec(obj, direction)
if (a:obj == "class")
let objregexp = "^\\s*class\\s\\+[a-zA-Z0-9_]\\+"
\ . "\\s*\\((\\([a-zA-Z0-9_,. \\t\\n]\\)*)\\)\\=\\s*:"
else
let objregexp = "^\\s*def\\s\\+[a-zA-Z0-9_]\\+\\s*(\\_[^:#]*)\\s*:"
endif
let flag = "W"
if (a:direction == -1)
let flag = flag."b"
endif
let res = search(objregexp, flag)
endfunction
" Comment out selected lines
" commentString is inserted in non-empty lines, and should be aligned with
" the block
function! PythonCommentSelection() range
let commentString = "#"
let cl = a:firstline
let ind = 1000 " I hope nobody use so long lines! :)
" Look for smallest indent
while (cl <= a:lastline)
if strlen(getline(cl))
let cind = indent(cl)
let ind = ((ind < cind) ? ind : cind)
endif
let cl = cl + 1
endwhile
if (ind == 1000)
let ind = 1
else
let ind = ind + 1
endif
let cl = a:firstline
execute ":".cl
" Insert commentString in each non-empty line, in column ind
while (cl <= a:lastline)
if strlen(getline(cl))
execute "normal ".ind."|i".commentString
endif
execute "normal \<Down>"
let cl = cl + 1
endwhile
endfunction
" Uncomment selected lines
function! PythonUncommentSelection() range
" commentString could be different than the one from CommentSelection()
" For example, this could be "# \\="
let commentString = "#"
let cl = a:firstline
while (cl <= a:lastline)
let ul = substitute(getline(cl),
\"\\(\\s*\\)".commentString."\\(.*\\)$", "\\1\\2", "")
call setline(cl, ul)
let cl = cl + 1
endwhile
endfunction
" Select an object ("class"/"function")
function! PythonSelectObject(obj)
" Go to the object declaration
normal $
call PythonDec(a:obj, -1)
let beg = line('.')
if !exists("g:py_select_leading_comments") || (g:py_select_leading_comments)
let decind = indent(beg)
let cl = beg
while (cl>1)
let cl = cl - 1
if (indent(cl) == decind) && (getline(cl)[decind] == "#")
let beg = cl
else
break
endif
endwhile
endif
if (a:obj == "class")
let eod = "\\(^\\s*class\\s\\+[a-zA-Z0-9_]\\+\\s*"
\ . "\\((\\([a-zA-Z0-9_,. \\t\\n]\\)*)\\)\\=\\s*\\)\\@<=:"
else
let eod = "\\(^\\s*def\\s\\+[a-zA-Z0-9_]\\+\\s*(\\_[^:#]*)\\s*\\)\\@<=:"
endif
" Look for the end of the declaration (not always the same line!)
call search(eod, "")
" Is it a one-line definition?
if match(getline('.'), "^\\s*\\(#.*\\)\\=$", col('.')) == -1
let cl = line('.')
execute ":".beg
execute "normal V".cl."G"
else
" Select the whole block
execute "normal \<Down>"
let cl = line('.')
execute ":".beg
execute "normal V".PythonBoB(cl, 1, 0)."G"
endif
endfunction
" Jump to the next line with the same (or lower) indentation
" Useful for moving between "if" and "else", for example.
function! PythonNextLine(direction)
let ln = line('.')
let ind = indent(ln)
let indent_valid = strlen(getline(ln))
let ln = ln + a:direction
while((ln >= 1) && (ln <= line('$')))
if (!indent_valid) && strlen(getline(ln))
break
else
if (strlen(getline(ln)))
if (indent(ln) <= ind)
break
endif
endif
endif
let ln = ln + a:direction
endwhile
execute "normal ".ln."G"
endfunction
function! UpdateMenu()
" delete menu if it already exists, then rebuild it.
" this is necessary in case you've got multiple buffers open
" a future enhancement to this would be to make the menu aware of
" all buffers currently open, and group classes and functions by buffer
if exists("g:menuran")
aunmenu IM-Python
endif
let restore_fe = &foldenable
set nofoldenable
" preserve disposition of window and cursor
let cline=line('.')
let ccol=col('.') - 1
norm H
let hline=line('.')
" create the menu
call MenuBuilder()
" restore disposition of window and cursor
exe "norm ".hline."Gzt"
let dnscroll=cline-hline
exe "norm ".dnscroll."j".ccol."l"
let &foldenable = restore_fe
endfunction
function! MenuBuilder()
norm gg0
let currentclass = -1
let classlist = []
let parentclass = ""
while line(".") < line("$")
" search for a class or function
if match ( getline("."), '^\s*class\s\+[_a-zA-Z].*\|^\s*def\s\+[_a-zA-Z].*' ) != -1
norm ^
let linenum = line('.')
let indentcol = col('.')
norm "nye
let classordef=@n
norm w"nywge
let objname=@n
let parentclass = FindParentClass(classlist, indentcol)
if classordef == "class"
call AddClass(objname, linenum, parentclass)
else " this is a function
call AddFunction(objname, linenum, parentclass)
endif
" We actually created a menu, so lets set the global variable
let g:menuran=1
call RebuildClassList(classlist, [objname, indentcol], classordef)
endif " line matched
norm j
endwhile
endfunction
" classlist contains the list of nested classes we are in.
" in most cases it will be empty or contain a single class
" but where a class is nested within another, it will contain 2 or more
" this function adds or removes classes from the list based on indentation
function! RebuildClassList(classlist, newclass, classordef)
let i = len(a:classlist) - 1
while i > -1
if a:newclass[1] <= a:classlist[i][1]
call remove(a:classlist, i)
endif
let i = i - 1
endwhile
if a:classordef == "class"
call add(a:classlist, a:newclass)
endif
endfunction
" we found a class or function, determine its parent class based on
" indentation and what's contained in classlist
function! FindParentClass(classlist, indentcol)
let i = 0
let parentclass = ""
while i < len(a:classlist)
if a:indentcol <= a:classlist[i][1]
break
else
if len(parentclass) == 0
let parentclass = a:classlist[i][0]
else
let parentclass = parentclass.'\.'.a:classlist[i][0]
endif
endif
let i = i + 1
endwhile
return parentclass
endfunction
" add a class to the menu
function! AddClass(classname, lineno, parentclass)
if len(a:parentclass) > 0
let classstring = a:parentclass.'\.'.a:classname
else
let classstring = a:classname
endif
exe 'menu IM-Python.classes.'.classstring.' :call <SID>JumpToAndUnfold('.a:lineno.')<CR>'
endfunction
" add a function to the menu, grouped by member class
function! AddFunction(functionname, lineno, parentclass)
if len(a:parentclass) > 0
let funcstring = a:parentclass.'.'.a:functionname
else
let funcstring = a:functionname
endif
exe 'menu IM-Python.functions.'.funcstring.' :call <SID>JumpToAndUnfold('.a:lineno.')<CR>'
endfunction
function! s:JumpToAndUnfold(line)
" Go to the right line
execute 'normal '.a:line.'gg'
" Check to see if we are in a fold
let lvl = foldlevel(a:line)
if lvl != 0
" and if so, then expand the fold out, other wise, ignore this part.
execute 'normal 15zo'
endif
endfunction
"" This one will work only on vim 6.2 because of the try/catch expressions.
" function! s:JumpToAndUnfoldWithExceptions(line)
" try
" execute 'normal '.a:line.'gg15zo'
" catch /^Vim\((\a\+)\)\=:E490:/
" " Do nothing, just consume the error
" endtry
"endfunction
" vim:set et sts=2 sw=2:

View File

@@ -1,763 +0,0 @@
" File: pythonhelper.vim
" Author: Michal Vitecek <fuf-at-mageo-dot-cz>
" Version: 0.83
" Last Modified: Jan 4, 2010
"
" Overview
" --------
" Vim script to help moving around in larger Python source files. It displays
" current class, method or function the cursor is placed in on the status
" line for every python file. It's more clever than Yegappan Lakshmanan's
" taglist.vim because it takes into account indetation and comments to
" determine what tag the cursor is placed in.
"
" Requirements
" ------------
" This script needs only VIM compiled with Python interpreter. It doesn't rely
" on exuberant ctags utility. You can determine whether your VIM has Python
" support by issuing command :ver and looking for +python in the list of
" features.
"
" Installation
" ------------
" 1. Make sure your Vim has python feature on (+python). If not, you will need
" to recompile it with --with-pythoninterp option to the configure script
" 2. Copy script pythonhelper.vim to the $HOME/.vim/plugin directory
" 3. Run Vim and open any python file.
"
python << EOS
# import of required modules {{{
import re
import sys
import time
import traceback
import vim
# }}}
# global dictionaries of tags and their line numbers, keys are buffer numbers {{{
TAGS = {}
TAGLINENUMBERS = {}
BUFFERTICKS = {}
# }}}
# class PythonTag() {{{
class PythonTag(object):
# DOC {{{
"""A simple storage class representing a python tag.
"""
# }}}
# STATIC VARIABLES {{{
# possible tag types {{{
TT_CLASS = 0
TT_METHOD = 1
TT_FUNCTION = 2
# }}}
# tag type names {{{
TAG_TYPE_NAME = {
TT_CLASS : "class",
TT_METHOD : "method",
TT_FUNCTION : "function",
}
# }}}
# }}}
# METHODS {{{
def __init__(self, type, name, fullName, lineNumber, indentLevel):
# DOC {{{
"""Initializes instances of PythonTag().
Parameters
type -- tag type
name -- short tag name
fullName -- full tag name (in dotted notation)
lineNumber -- line number on which the tag starts
indentLevel -- indentation level of the tag
"""
# }}}
# CODE {{{
# remember the settings {{{
self.type = type
self.name = name
self.fullName = fullName
self.lineNumber = lineNumber
self.indentLevel = indentLevel
# }}}
# }}}
def __str__(self):
# DOC {{{
"""Returns a string representation of the tag.
"""
# }}}
# CODE {{{
return "%s (%s) [%s, %u, %u]" % (self.name, PythonTag.TAG_TYPE_NAME[self.type],
self.fullName, self.lineNumber, self.indentLevel,)
# }}}
__repr__ = __str__
# }}}
# }}}
# class SimplePythonTagsParser() {{{
class SimplePythonTagsParser(object):
# DOC {{{
"""Provides a simple python tag parser.
"""
# }}}
# STATIC VARIABLES {{{
# how many chars a single tab represents (visually)
TABSIZE = 8
# regexp used to extract indentation and strip comments
COMMENTS_INDENT_RE = re.compile('([ \t]*)([^\n#]*).*')
# regexp used to extract a class name
CLASS_RE = re.compile('class[ \t]+([^(:]+).*')
# regexp used to extract a method or function name
METHOD_RE = re.compile('def[ \t]+([^(]+).*')
# }}}
# METHODS {{{
def __init__(self, source):
# DOC {{{
"""Initializes instances of SimplePythonTagsParser().
Parameters
source -- source for which the tags will be generated. It must
provide callable method readline (i.e. as file objects do).
"""
# }}}
# CODE {{{
# make sure source has readline() method {{{
if ((hasattr(source, 'readline') == 0) or
(callable(source.readline) == 0)):
raise AttributeError("Source must have callable readline method.")
# }}}
# remember what the source is
self.source = source
# }}}
def getTags(self):
# DOC {{{
"""Determines all the tags for the buffer. Returns a tuple in format
(tagLineNumbers, tags,).
"""
# }}}
# CODE {{{
# initialize the resulting list of the tag line numbers and the tag information {{{
tagLineNumbers = []
tags = {}
# }}}
# initalize local auxiliary variables {{{
tagsStack = []
lineNumber = 0
# }}}
# go through all the lines in the source and localize all python tags in it {{{
while 1:
# get next line
line = self.source.readline()
# finish if this is the end of the source {{{
if (line == ''):
break
# }}}
# increase the line number
lineNumber += 1
# extract the line indentation characters and its content {{{
lineMatch = self.COMMENTS_INDENT_RE.match(line)
lineContent = lineMatch.group(2)
# }}}
# handle the class tag {{{
# match for the class tag
tagMatch = self.CLASS_RE.match(lineContent)
# if the class tag has been found, store some information on it {{{
if (tagMatch):
currentTag = self.getPythonTag(tagsStack, lineNumber, lineMatch.group(1),
tagMatch.group(1), self.tagClassTypeDecidingMethod)
tagLineNumbers.append(lineNumber)
tags[lineNumber] = currentTag
# }}}
# }}}
# handle the function/method/none tag {{{
else:
# match for the method/function tag
tagMatch = self.METHOD_RE.match(lineContent)
# if the method/function tag has been found, store some information on it {{{
if (tagMatch):
currentTag = self.getPythonTag(tagsStack, lineNumber, lineMatch.group(1),
tagMatch.group(1), self.tagFunctionTypeDecidingMethod)
tagLineNumbers.append(lineNumber)
tags[lineNumber] = currentTag
# }}}
# }}}
# }}}
# return the tags data for the source
return (tagLineNumbers, tags,)
# }}}
def getParentTag(self, tagsStack):
# DOC {{{
"""Returns the parent/enclosing tag (instance of PythonTag()) from the
specified tag list. If no such parent tag exists, returns None.
Parameters
tagsStack -- list (stack) of currently open PythonTag() instances
"""
# }}}
# CODE {{{
# determine the parent tag {{{
if (len(tagsStack)):
parentTag = tagsStack[-1]
else:
parentTag = None
# }}}
# return the tag
return parentTag
# }}}
def computeIndentationLevel(indentChars):
# DOC {{{
"""Computes the indentation level from the specified string.
Parameters
indentChars -- white space before any other character on line
"""
# }}}
# CODE {{{
# initialize the indentation level
indentLevel = 0
# compute the indentation level (expand tabs) {{{
for char in indentChars:
if (char == '\t'):
indentLevel += SimplePythonTagsParser.TABSIZE
else:
indentLevel += 1
# }}}
# return the computed indentation level
return indentLevel
# }}}
computeIndentationLevel = staticmethod(computeIndentationLevel)
def getPythonTag(self, tagsStack, lineNumber, indentChars, tagName, tagTypeDecidingMethod):
# DOC {{{
"""Returns instance of PythonTag() based on the specified data.
Parameters
tagsStack -- list (stack) of tags currently active. Note: Modified
in this method!
lineNumber -- current line number
indentChars -- characters making up the indentation level of the
current tag
tagName -- short name of the current tag
tagTypeDecidingMethod -- reference to method that is called to
determine the type of the current tag
"""
# }}}
# CODE {{{
# compute the indentation level
indentLevel = self.computeIndentationLevel(indentChars)
# get the parent tag
parentTag = self.getParentTag(tagsStack)
# handle an enclosed tag {{{
while (parentTag):
# if the indent level of the parent tag is greater than of the current tag, use parent tag of the parent tag {{{
if (parentTag.indentLevel >= indentLevel):
del tagsStack[-1]
# }}}
# otherwise we have all information on the current tag and can return it {{{
else:
# create the tag
tag = PythonTag(tagTypeDecidingMethod(parentTag.type), tagName, "%s.%s" % (parentTag.fullName, tagName,), lineNumber, indentLevel)
# break the loop
break
# }}}
# use parent tag of the parent tag
parentTag = self.getParentTag(tagsStack)
# }}}
# handle a top-indent level tag {{{
else:
# create the tag
tag = PythonTag(tagTypeDecidingMethod(None), tagName, tagName, lineNumber, indentLevel)
# }}}
# add the tag to the list of tags
tagsStack.append(tag)
# return the tag
return tag
# }}}
def tagClassTypeDecidingMethod(self, parentTagType):
# DOC {{{
"""Returns tag type of the current tag based on its previous tag (super
tag) for classes.
Parameters
parentTagType -- type of the enclosing/parent tag
"""
# }}}
# CODE {{{
# is always class no matter what
return PythonTag.TT_CLASS
# }}}
def tagFunctionTypeDecidingMethod(self, parentTagType):
# DOC {{{
"""Returns tag type of the current tag based on its previous tag (super
tag) for functions/methods.
Parameters
parentTagType -- type of the enclosing/parent tag
"""
# }}}
# CODE {{{
if (parentTagType == PythonTag.TT_CLASS):
return PythonTag.TT_METHOD
else:
return PythonTag.TT_FUNCTION
# }}}
# }}}
# }}}
# class VimReadlineBuffer() {{{
class VimReadlineBuffer(object):
# DOC {{{
"""A simple wrapper class around vim's buffer that provides readline
method.
"""
# }}}
# METHODS {{{
def __init__(self, vimBuffer):
# DOC {{{
"""Initializes instances of VimReadlineBuffer().
Parameters
vimBuffer -- VIM's buffer
"""
# }}}
# CODE {{{
# remember the settings
self.vimBuffer = vimBuffer
# initialize instance attributes {{{
self.currentLine = -1
self.bufferLines = len(vimBuffer)
# }}}
# }}}
def readline(self):
# DOC {{{
"""Returns next line from the buffer. If all the buffer has been read,
returns empty string.
"""
# }}}
# CODE {{{
# increase the current line counter
self.currentLine += 1
# notify end of file if we reached beyond the last line {{{
if (self.currentLine == self.bufferLines):
return ''
# }}}
# return the line with an added newline (vim stores the lines without it)
return "%s\n" % (self.vimBuffer[self.currentLine],)
# }}}
# }}}
# }}}
def getNearestLineIndex(row, tagLineNumbers):
# DOC {{{
"""Returns the index of line in 'tagLineNumbers' list that is nearest to the
specified cursor row.
Parameters
row -- current cursor row
tagLineNumbers -- list of tags' line numbers (ie. their position)
"""
# }}}
# CODE {{{
# initialize local auxiliary variables {{{
nearestLineNumber = -1
nearestLineIndex = -1
# }}}
# go through all tag line numbers and find the one nearest to the specified row {{{
for lineIndex, lineNumber in enumerate(tagLineNumbers):
# if the current line is nearer the current cursor position, take it {{{
if (nearestLineNumber < lineNumber <= row):
nearestLineNumber = lineNumber
nearestLineIndex = lineIndex
# }}}
# if we've got past the current cursor position, let's end the search {{{
if (lineNumber >= row):
break
# }}}
# }}}
# return index of the line with the nearest tag
return nearestLineIndex
# }}}
def getTags(bufferNumber, changedTick):
# DOC {{{
"""Reads the tags for the specified buffer number. Returns a tuple
(taglinenumber[buffer], tags[buffer],).
Parameters
bufferNumber -- number of the current buffer
changedTick -- ever increasing number used to tell if the buffer has
been modified since the last time
"""
# }}}
# CODE {{{
# define global variables
global TAGLINENUMBERS, TAGS, BUFFERTICKS
# return immediately if there's no need to update the tags {{{
if (BUFFERTICKS.get(bufferNumber, None) == changedTick):
return (TAGLINENUMBERS[bufferNumber], TAGS[bufferNumber],)
# }}}
# get the tags {{{
simpleTagsParser = SimplePythonTagsParser(VimReadlineBuffer(vim.current.buffer))
tagLineNumbers, tags = simpleTagsParser.getTags()
# }}}
# update the global variables {{{
TAGS[bufferNumber] = tags
TAGLINENUMBERS[bufferNumber] = tagLineNumbers
BUFFERTICKS[bufferNumber] = changedTick
# }}}
# return the tuple (tagLineNumbers, tags,)
return (tagLineNumbers, tags,)
# }}}
def findTag(bufferNumber, changedTick):
# DOC {{{
"""Tries to find the best tag for the current cursor position.
Parameters
bufferNumber -- number of the current buffer
changedTick -- ever increasing number used to tell if the buffer has
been modified since the last time
"""
# }}}
# CODE {{{
# try to find the best tag {{{
try:
# get the tags data for the current buffer
tagLineNumbers, tags = getTags(bufferNumber, changedTick)
# link to vim's internal data {{{
currentBuffer = vim.current.buffer
currentWindow = vim.current.window
row, col = currentWindow.cursor
# }}}
# get the index of the nearest line
nearestLineIndex = getNearestLineIndex(row, tagLineNumbers)
# if any line was found, try to find if the tag is appropriate {{{
# (ie. the cursor can be below the last tag but on a code that has nothing
# to do with the tag, because it's indented differently, in such case no
# appropriate tag has been found.)
while (nearestLineIndex > -1):
# get the line number of the nearest tag
nearestLineNumber = tagLineNumbers[nearestLineIndex]
# walk through all the lines in range (nearestTagLine, cursorRow) {{{
for lineNumber in xrange(nearestLineNumber + 1, row):
# get the current line
line = currentBuffer[lineNumber]
# count the indentation of the line, if it's lower than the tag's, the tag is invalid {{{
if (len(line)):
# initialize local auxiliary variables {{{
lineStart = 0
i = 0
# }}}
# compute the indentation of the line {{{
while ((i < len(line)) and (line[i].isspace())):
# move the start of the line code {{{
if (line[i] == '\t'):
lineStart += SimplePythonTagsParser.TABSIZE
else:
lineStart += 1
# }}}
# go to the next character on the line
i += 1
# }}}
# if the line contains only spaces, skip it {{{
if (i == len(line)):
continue
# }}}
# if the next character is a '#' (python comment), skip the line {{{
if (line[i] == '#'):
continue
# }}}
# if the line's indentation starts before or at the nearest tag's one, the tag is invalid {{{
if (lineStart <= tags[nearestLineNumber].indentLevel):
nearestLineIndex -= 1
break
# }}}
# }}}
# }}}
# the tag is appropriate, so use it {{{
else:
break
# }}}
# }}}
# no appropriate tag has been found {{{
else:
nearestLineNumber = -1
# }}}
# describe the cursor position (what tag the cursor is on) {{{
# reset the description
tagDescription = ""
# if an appropriate tag has been found, set the description accordingly {{{
if (nearestLineNumber > -1):
tagInfo = tags[nearestLineNumber]
tagDescription = "[in %s (%s)]" % (tagInfo.fullName, PythonTag.TAG_TYPE_NAME[tagInfo.type],)
# }}}
# }}}
# update the variable for the status line so it get updated with the new description
vim.command("let w:PHStatusLine=\"%s\"" % (tagDescription,))
# }}}
# handle possible exceptions {{{
except Exception:
# bury into the traceback {{{
ec, ei, tb = sys.exc_info()
while (tb != None):
if (tb.tb_next == None):
break
tb = tb.tb_next
# }}}
# spit out the error {{{
print "ERROR: %s %s %s:%u" % (ec.__name__, ei, tb.tb_frame.f_code.co_filename, tb.tb_lineno,)
time.sleep(0.5)
# }}}
# }}}
# }}}
def deleteTags(bufferNumber):
# DOC {{{
"""Removes tags data for the specified buffer number.
Parameters
bufferNumber -- number of the buffer
"""
# }}}
# CODE {{{
# define global variables
global TAGS, TAGLINENUMBERS, BUFFERTICKS
# try to delete the tags for the buffer {{{
try:
del TAGS[bufferNumber]
del TAGLINENUMBERS[bufferNumber]
del BUFFERTICKS[bufferNumber]
except:
pass
# }}}
# }}}
EOS
" VIM functions {{{
function! PHCursorHold()
" only python is supported {{{
if (!exists('b:current_syntax') || (b:current_syntax != 'python'))
let w:PHStatusLine = ''
return
endif
" }}}
" call python function findTag() with the current buffer number and changed ticks
execute 'python findTag(' . expand("<abuf>") . ', ' . b:changedtick . ')'
endfunction
function! PHBufferDelete()
" set PHStatusLine for this window to empty string
let w:PHStatusLine = ""
" call python function deleteTags() with the cur
execute 'python deleteTags(' . expand("<abuf>") . ')'
endfunction
function! TagInStatusLine()
" return value of w:PHStatusLine in case it's set
if (exists("w:PHStatusLine"))
return w:PHStatusLine
" otherwise just return empty string
else
return ""
endif
endfunction
function! PHPreviousClassMethod()
call search('^[ \t]*\(class\|def\)\>', 'bw')
endfunction
function! PHNextClassMethod()
call search('^[ \t]*\(class\|def\)\>', 'w')
endfunction
function! PHPreviousClass()
call search('^[ \t]*class\>', 'bw')
endfunction
function! PHNextClass()
call search('^[ \t]*class\>', 'w')
endfunction
function! PHPreviousMethod()
call search('^[ \t]*def\>', 'bw')
endfunction
function! PHNextMethod()
call search('^[ \t]*def\>', 'w')
endfunction
" }}}
" event binding, vim customizing {{{
" autocommands binding
autocmd CursorHold * call PHCursorHold()
autocmd CursorHoldI * call PHCursorHold()
autocmd BufDelete * silent call PHBufferDelete()
" time that determines after how long time of no activity the CursorHold event
" is fired up
set updatetime=1000
" color of the current tag in the status line (bold cyan on black)
" gryf: i don't like coloring apart from current colorscheme. keep it simple.
"highlight User1 gui=bold guifg=cyan guibg=black
" color of the modified flag in the status line (bold black on red)
" gryf: i don't like coloring apart from current colorscheme. keep it simple.
"highlight User2 gui=bold guifg=black guibg=red
" the status line will be displayed for every window
set laststatus=2
" set the status line to display some useful information
"set stl=%-f%r\ %2*%m%*\ \ \ \ %1*%{TagInStatusLine()}%*%=[%l:%c]\ \ \ \ [buf\ %n]
" gryf: I like my status bar. Don't change it. Just add information.
setlocal statusline=%<%F\ \ \ %{TagInStatusLine()}\ %h%m%r%=%(%l,%c%V%)\ %3p%%
" }}}
" vim:foldmethod=marker

View File

@@ -1,854 +0,0 @@
" File: grep.vim
" Author: Yegappan Lakshmanan (yegappan AT yahoo DOT com)
" Version: 1.9
" Last Modified: September 10, 2007
"
" Overview
" --------
" The grep plugin integrates the grep, fgrep, egrep, and agrep tools with
" Vim and allows you to search for a pattern in one or more files and jump
" to them.
"
" To use this plugin, you need the grep, fgrep, egrep, agrep, find and
" xargs utilities. These tools are present in most of the Unix installations.
" For MS-Windows systems, you can download the GNU grep and find utilities
" from the following sites:
"
" http://gnuwin32.sourceforge.net/packages/grep.htm
" http://gnuwin32.sourceforge.net/packages/findutils.htm
"
" Installation
" ------------
" 1. Copy the grep.vim file to the $HOME/.vim/plugin or $HOME/vimfiles/plugin
" or $VIM/vimfiles/plugin directory.
" Refer to the following Vim help topics for more information about Vim
" plugins:
" :help add-plugin
" :help add-global-plugin
" :help runtimepath
" 2. If the grep executables are not already present in one of the directories
" in the PATH environment variable, then set the Grep_Path and other _Path
" variables to point to the location of the grep utilites in the .vimrc
" file.
" 3. Restart Vim.
" 4. You can now use the ":Grep" and other commands to search for patterns in
" files.
"
" Usage
" -----
" The grep.vim plugin introduces the following Vim commands:
"
" :Grep - Search for the specified pattern in the specified files
" :GrepAdd - Same as ":Grep" but adds the results to the current results
" :Rgrep - Run recursive grep
" :RgrepAdd - Same as ":Rgrep" but adds the results to the current results
" :GrepBuffer - Search for a pattern on all open buffers
" :GrepBufferAdd - Same as ":GrepBuffer" but adds the results to the current
" results
" :Bgrep - Same as :GrepBuffer
" :BgrepAdd - Same as :GrepBufferAdd
" :GrepArgs - Search for a pattern on all the Vim argument
" filenames (:args)
" :GrepArgsAdd - Same as ":GrepArgs" but adds the results to the current
" results
" :Fgrep - Run fgrep
" :FgrepAdd - Same as ":Fgrep" but adds the results to the current
" results
" :Rfgrep - Run recursive fgrep
" :RfgrepAdd - Same as ":Rfgrep" but adds the results to the current
" results
" :Egrep - Run egrep
" :EgrepAdd - Same as ":Egrep" but adds the results to the current
" results
" :Regrep - Run recursive egrep
" :RegrepAdd - Same as ":Regrep" but adds the results to the current
" results
" :Agrep - Run agrep
" :AgrepAdd - Same as ":Agrep" but adds the results to the current
" results
" :Ragrep - Run recursive agrep
" :RagrepAdd - Same as ":Ragrep" but adds the results to the current
" results
"
" The above commands can be invoked like this:
"
" :Grep [<grep_options>] [<search_pattern> [<file_name(s)>]]
" :Rgrep [<grep_options>] [<search_pattern> [<file_name(s)>]]
" :Fgrep [<grep_options>] [<search_pattern> [<file_name(s)>]]
" :Rfgrep [<grep_options>] [<search_pattern> [<file_name(s)>]]
" :Egrep [<grep_options>] [<search_pattern> [<file_name(s)>]]
" :Regrep [<grep_options>] [<search_pattern> [<file_name(s)>]]
" :Agrep [<grep_options>] [<search_pattern> [<file_name(s)>]]
" :Ragrep [<grep_options>] [<search_pattern> [<file_name(s)>]]
"
" :GrepAdd [<grep_options>] [<search_pattern> [<file_name(s)>]]
" :RgrepAdd [<grep_options>] [<search_pattern> [<file_name(s)>]]
" :FgrepAdd [<grep_options>] [<search_pattern> [<file_name(s)>]]
" :RfgrepAdd [<grep_options>] [<search_pattern> [<file_name(s)>]]
" :EgrepAdd [<grep_options>] [<search_pattern> [<file_name(s)>]]
" :RegrepAdd [<grep_options>] [<search_pattern> [<file_name(s)>]]
" :AgrepAdd [<grep_options>] [<search_pattern> [<file_name(s)>]]
" :RagrepAdd [<grep_options>] [<search_pattern> [<file_name(s)>]]
"
" :GrepBuffer [<grep_options>] [<search_pattern>]
" :Bgrep [<grep_options>] [<search_pattern>]
" :GrepArgs [<grep_options>] [<search_pattern>]
"
" :GrepBufferAdd [<grep_options>] [<search_pattern>]
" :BgrepAdd [<grep_options>] [<search_pattern>]
" :GrepArgsAdd [<grep_options>] [<search_pattern>]
"
" In the above commands, all the arguments are optional.
"
" You can specify grep options like -i (ignore case) or -w (search for a word)
" to the above commands. If the <grep_options> are not specified, then the
" default grep options specified by the variable Grep_Default_Options is
" used.
"
" You can specify the grep pattern to search as an argument to the above
" commands. If the <search_pattern> is not specified, then you will be
" prompted to enter a search pattern. By default, the keyword under the cursor
" is displayed for the search pattern prompt. You can accept the default or
" modify it.
"
" The search pattern is automatically enclosed by the character specified in
" the Grep_Shell_Quote_Char variable. You should not enclose the search
" pattern with a shell escape character.
"
" If you want to specify a search pattern with space characters or a
" multi-word pattern, then you should use the Grep command pattern input
" prompt to supply the pattern.
"
" You can specify one or more file names (or file patterns) to the above
" commands. If the <file_names> are not specified, then you will be prompted
" to enter file names. By default, the pattern specified by the
" Grep_Default_Filelist variable is used. To specify the file name(s) as an
" argument to the above commands, you have to specify the search pattern also.
"
" When you enter only the command name, you will be prompted to enter the
" search pattern and the files in which to search for the pattern. By default,
" the keyword under the cursor is displayed for the search pattern prompt.
" Depending on the command, you may prompted for additional parameters like
" the directories to search for the pattern.
"
" You can retrieve previously entered values for the Grep prompts using the up
" and down arrow keys. You can cancel the command by pressing the escape key.
" You can use CTRL-U to erase the default shown for the prompt and CTRL-W to
" erase the previous word in the prompt. For more information about editing
" the prompt, read ':help cmdline-editing' Vim help topic.
"
" After invoking any of the grep commands, you can cancel the command, when
" you are prompted for a search pattern or file names or a directory by
" pressing the <Esc> key. You cannot cancel (or kill) the
" grep/fgrep/egrep/agrep commands after the external command is invoked.
"
" The GrepAdd, RgrepAdd and other *Add commands append the search output to
" the current search output. This is useful if you want to see the search
" results for multiple patterns at the same time. These commands are available
" only in Vim version 7.0 and above.
"
" You can map a key to invoke any of the above commands. For example, the
" following map invokes the :Grep command to search for the keyword under the
" cursor:
"
" nnoremap <silent> <F3> :Grep<CR>
"
" The output of the grep command will be listed in the Vim quickfix window.
" 1. You can select a line in the quickfix window and press <Enter> or double
" click on a match to jump to that line.
" 2. You can use the ":cnext" and ":cprev" commands to the jump to the next or
" previous output line.
" 3. You can use the ":colder" and ":cnewer" commands to go between multiple
" grep quickfix output windows.
" 4. The quickfix window need not be opened always to use the grep output.
" You can close the quickfix window and use the quickfix commands to jump
" to the grep matches. Use the ":copen" command to open the quickfix
" window again.
"
" For more information about other quickfix commands read ":help quickfix"
"
" When using GUI Vim, the Tools->Search menu item with a few sub-menu items is
" created for few variations of the search command.
"
" Configuration
" -------------
" By changing the following variables you can configure the behavior of this
" plugin. Set the following variables in your .vimrc file using the 'let'
" command.
"
" The 'Grep_Path' variable is used to locate the grep utility. By default,
" this is set to grep. You can change this using the let command:
"
" :let Grep_Path = 'd:\tools\grep.exe'
"
" The 'Fgrep_Path' variable is used to locate the fgrep utility. By default,
" this is set to fgrep. You can change this using the let command:
"
" :let Fgrep_Path = 'd:\tools\fgrep.exe'
"
" The 'Egrep_Path' variable is used to locate the egrep utility. By default,
" this is set to egrep. You can change this using the let command:
"
" :let Egrep_Path = 'd:\tools\egrep.exe'
"
" The 'Agrep_Path' variable is used to locate the agrep utility. By default,
" this is set to agrep. You can change this using the let command:
"
" :let Agrep_Path = 'd:\tools\agrep.exe'
"
" The 'Grep_Find_Path' variable is used to locate the find utility. By
" default, this is set to d:\tools\find.exe. You can change this using the let
" command:
"
" :let Grep_Find_Path = 'd:\tools\find.exe'
"
" The 'Grep_Xargs_Path' variable is used to locate the xargs utility. By
" default, this is set to xargs. You can change this using the let
" command:
"
" :let Grep_Xargs_Path = 'd:\tools\xargs.exe'
"
" When running any one of the Grep commands, you will be prompted for the
" files in which to search for the pattern. The 'Grep_Default_Filelist'
" variable is used to specify to default for this prompt. By default, this
" variable is set to '*'. You can specify multiple matching patterns separated
" by spaces. You can change this settings using the let command:
"
" :let Grep_Default_Filelist = '*.[chS]'
" :let Grep_Default_Filelist = '*.c *.cpp *.asm'
"
" The 'Grep_Default_Options' is used to pass default command line options to
" the grep/fgrep/egrep/agrep utilities. By default, this is set to an empty
" string. You can change this using the let command:
"
" :let Grep_Default_Options = '-i'
"
" The 'Grep_Skip_Dirs' variable specifies the list of directories to skip
" while doing recursive searches. By default, this is set to 'RCS CVS SCCS'.
" You can change this using the let command:
"
" :let Grep_Skip_Dirs = 'dir1 dir2 dir3'
"
" The 'Grep_Skip_Files' variable specifies the list of files to skip while
" doing recursive searches. By default, this is set to '*~ *,v s.*'. You can
" change this using the let command:
"
" :let Grep_Skip_Files = '*.bak *~'
"
" By default, when you invoke the Grep commands the quickfix window will be
" opened with the grep output. You can disable opening the quickfix window,
" by setting the 'Grep_OpenQuickfixWindow' variable to zero:
"
" :let Grep_OpenQuickfixWindow = 0
"
" You can manually open the quickfix window using the :cwindow command.
"
" By default, for recursive searches, the 'find' and 'xargs' utilities are
" used. If you don't have the 'xargs' utility or don't want to use the
" 'xargs' utility, " then you can set the 'Grep_Find_Use_Xargs' variable to
" zero. If this is set to zero, then only the 'find' utility is used for
" recursive searches:
"
" :let Grep_Find_Use_Xargs = 0
"
" To handle file names with space characters in them, the xargs utility
" is invoked with the '--null' argument. If the xargs utility in your system
" doesn't accept the '--null' argument, then you can change the
" Grep_Xargs_Options variable. For example, to use the '--print0' xargs
" argument, you can use the following command:
"
" :let Grep_Xargs_Options = '--print0'
"
" The Grep_Cygwin_Find variable should be set to 1, if you are using the find
" utility from the cygwin package. This setting is used to handle the
" difference between the backslash and forward slash path separators.
"
" :let Grep_Cygwin_Find = 1
"
" The 'Grep_Null_Device' variable specifies the name of the null device to
" pass to the grep commands. This is needed to force the grep commands to
" print the name of the file in which a match is found, if only one filename
" is specified. For Unix systems, this is set to /dev/null and for MS-Windows
" systems, this is set to NUL. You can modify this by using the let command:
"
" :let Grep_Null_Device = '/dev/null'
"
" The 'Grep_Shell_Quote_Char' variable specifies the quote character to use
" for protecting patterns from being interpreted by the shell. For Unix
" systems, this is set to "'" and for MS-Window systems, this is set to an
" empty string. You can change this using the let command:
"
" :let Grep_Shell_Quote_Char = "'"
"
" The 'Grep_Shell_Escape_Char' variable specifies the escape character to use
" for protecting special characters from being interpreted by the shell. For
" Unix systems, this is set to '\' and for MS-Window systems, this is set to
" an empty string. You can change this using the let command:
"
" :let Grep_Shell_Escape_Char = "'"
"
" --------------------- Do not modify after this line ---------------------
if exists("loaded_grep")
finish
endif
let loaded_grep = 1
" Line continuation used here
let s:cpo_save = &cpo
set cpo&vim
" Location of the grep utility
if !exists("Grep_Path")
let Grep_Path = 'grep'
endif
" Location of the fgrep utility
if !exists("Fgrep_Path")
let Fgrep_Path = 'fgrep'
endif
" Location of the egrep utility
if !exists("Egrep_Path")
let Egrep_Path = 'egrep'
endif
" Location of the agrep utility
if !exists("Agrep_Path")
let Agrep_Path = 'agrep'
endif
" Location of the find utility
if !exists("Grep_Find_Path")
let Grep_Find_Path = 'find'
endif
" Location of the xargs utility
if !exists("Grep_Xargs_Path")
let Grep_Xargs_Path = 'xargs'
endif
" Open the Grep output window. Set this variable to zero, to not open
" the Grep output window by default. You can open it manually by using
" the :cwindow command.
if !exists("Grep_OpenQuickfixWindow")
let Grep_OpenQuickfixWindow = 1
endif
" Default grep file list
if !exists("Grep_Default_Filelist")
let Grep_Default_Filelist = '*'
endif
" Default grep options
if !exists("Grep_Default_Options")
let Grep_Default_Options = ''
endif
" Use the 'xargs' utility in combination with the 'find' utility. Set this
" to zero to not use the xargs utility.
if !exists("Grep_Find_Use_Xargs")
let Grep_Find_Use_Xargs = 1
endif
" The command-line arguments to supply to the xargs utility
if !exists('Grep_Xargs_Options')
let Grep_Xargs_Options = '--null'
endif
" The find utility is from the cygwin package or some other find utility.
if !exists("Grep_Cygwin_Find")
let Grep_Cygwin_Find = 0
endif
" NULL device name to supply to grep. We need this because, grep will not
" print the name of the file, if only one filename is supplied. We need the
" filename for Vim quickfix processing.
if !exists("Grep_Null_Device")
if has("win32") || has("win16") || has("win95")
let Grep_Null_Device = 'NUL'
else
let Grep_Null_Device = '/dev/null'
endif
endif
" Character to use to quote patterns and filenames before passing to grep.
if !exists("Grep_Shell_Quote_Char")
if has("win32") || has("win16") || has("win95")
let Grep_Shell_Quote_Char = ''
else
let Grep_Shell_Quote_Char = "'"
endif
endif
" Character to use to escape special characters before passing to grep.
if !exists("Grep_Shell_Escape_Char")
if has("win32") || has("win16") || has("win95")
let Grep_Shell_Escape_Char = ''
else
let Grep_Shell_Escape_Char = '\'
endif
endif
" The list of directories to skip while searching for a pattern. Set this
" variable to '', if you don't want to skip directories.
if !exists("Grep_Skip_Dirs")
let Grep_Skip_Dirs = 'RCS CVS SCCS'
endif
" The list of files to skip while searching for a pattern. Set this variable
" to '', if you don't want to skip any files.
if !exists("Grep_Skip_Files")
let Grep_Skip_Files = '*~ *,v s.*'
endif
" RunGrepCmd()
" Run the specified grep command using the supplied pattern
function! s:RunGrepCmd(cmd, pattern, action)
let cmd_output = system(a:cmd)
if cmd_output == ""
echohl WarningMsg |
\ echomsg "Error: Pattern " . a:pattern . " not found" |
\ echohl None
return
endif
let tmpfile = tempname()
let old_verbose = &verbose
set verbose&vim
exe "redir! > " . tmpfile
silent echon '[Search results for pattern: ' . a:pattern . "]\n"
silent echon cmd_output
redir END
let &verbose = old_verbose
let old_efm = &efm
set efm=%f:%\\s%#%l:%m
if v:version >= 700 && a:action == 'add'
execute "silent! caddfile " . tmpfile
else
if exists(":cgetfile")
execute "silent! cgetfile " . tmpfile
else
execute "silent! cfile " . tmpfile
endif
endif
let &efm = old_efm
" Open the grep output window
if g:Grep_OpenQuickfixWindow == 1
" Open the quickfix window below the current window
botright copen
endif
call delete(tmpfile)
endfunction
" RunGrepRecursive()
" Run specified grep command recursively
function! s:RunGrepRecursive(cmd_name, grep_cmd, action, ...)
if a:0 > 0 && (a:1 == "-?" || a:1 == "-h")
echo 'Usage: ' . a:cmd_name . " [<grep_options>] [<search_pattern> " .
\ "[<file_name(s)>]]"
return
endif
let grep_opt = ""
let pattern = ""
let filepattern = ""
let argcnt = 1
while argcnt <= a:0
if a:{argcnt} =~ '^-'
let grep_opt = grep_opt . " " . a:{argcnt}
elseif pattern == ""
let pattern = g:Grep_Shell_Quote_Char . a:{argcnt} .
\ g:Grep_Shell_Quote_Char
else
let filepattern = filepattern . " " . a:{argcnt}
endif
let argcnt= argcnt + 1
endwhile
if grep_opt == ""
let grep_opt = g:Grep_Default_Options
endif
if a:grep_cmd != 'agrep'
" Don't display messages about non-existent files
" Agrep doesn't support the -s option
let grep_opt = grep_opt . " -s"
endif
if a:grep_cmd == 'grep'
let grep_path = g:Grep_Path
let grep_expr_option = '--'
elseif a:grep_cmd == 'fgrep'
let grep_path = g:Fgrep_Path
let grep_expr_option = '-e'
elseif a:grep_cmd == 'egrep'
let grep_path = g:Egrep_Path
let grep_expr_option = '-e'
elseif a:grep_cmd == 'agrep'
let grep_path = g:Agrep_Path
let grep_expr_option = ''
else
return
endif
" No argument supplied. Get the identifier and file list from user
if pattern == ""
let pattern = input("Search for pattern: ", expand("<cword>"))
if pattern == ""
return
endif
let pattern = g:Grep_Shell_Quote_Char . pattern .
\ g:Grep_Shell_Quote_Char
endif
let cwd = getcwd()
if g:Grep_Cygwin_Find == 1
let cwd = substitute(cwd, "\\", "/", "g")
endif
if v:version >= 700
let startdir = input("Start searching from directory: ", cwd, "dir")
else
let startdir = input("Start searching from directory: ", cwd)
endif
if startdir == ""
return
endif
if filepattern == ""
let filepattern = input("Search in files matching pattern: ",
\ g:Grep_Default_Filelist)
if filepattern == ""
return
endif
endif
let txt = filepattern . ' '
let find_file_pattern = ''
while txt != ''
let one_pattern = strpart(txt, 0, stridx(txt, ' '))
if find_file_pattern != ''
let find_file_pattern = find_file_pattern . ' -o'
endif
let find_file_pattern = find_file_pattern . ' -name ' .
\ g:Grep_Shell_Quote_Char . one_pattern . g:Grep_Shell_Quote_Char
let txt = strpart(txt, stridx(txt, ' ') + 1)
endwhile
let find_file_pattern = g:Grep_Shell_Escape_Char . '(' .
\ find_file_pattern . ' ' . g:Grep_Shell_Escape_Char . ')'
let txt = g:Grep_Skip_Dirs
let find_prune = ''
if txt != ''
let txt = txt . ' '
while txt != ''
let one_dir = strpart(txt, 0, stridx(txt, ' '))
if find_prune != ''
let find_prune = find_prune . ' -o'
endif
let find_prune = find_prune . ' -name ' . one_dir
let txt = strpart(txt, stridx(txt, ' ') + 1)
endwhile
let find_prune = '-type d ' . g:Grep_Shell_Escape_Char . '(' .
\ find_prune
let find_prune = find_prune . ' ' . g:Grep_Shell_Escape_Char . ')'
endif
let txt = g:Grep_Skip_Files
let find_skip_files = '-type f'
if txt != ''
let txt = txt . ' '
while txt != ''
let one_file = strpart(txt, 0, stridx(txt, ' '))
let find_skip_files = find_skip_files . ' ! -name ' .
\ g:Grep_Shell_Quote_Char . one_file .
\ g:Grep_Shell_Quote_Char
let txt = strpart(txt, stridx(txt, ' ') + 1)
endwhile
endif
if g:Grep_Find_Use_Xargs == 1
let cmd = g:Grep_Find_Path . " " . startdir
let cmd = cmd . " " . find_prune . " -prune -o"
let cmd = cmd . " " . find_skip_files
let cmd = cmd . " " . find_file_pattern
let cmd = cmd . " -print0 | "
let cmd = cmd . g:Grep_Xargs_Path . ' ' . g:Grep_Xargs_Options
let cmd = cmd . ' ' . grep_path . " " . grep_opt . " -n "
let cmd = cmd . grep_expr_option . " " . pattern
let cmd = cmd . ' ' . g:Grep_Null_Device
else
let cmd = g:Grep_Find_Path . " " . startdir
let cmd = cmd . " " . find_prune . " -prune -o"
let cmd = cmd . " " . find_skip_files
let cmd = cmd . " " . find_file_pattern
let cmd = cmd . " -exec " . grep_path . " " . grep_opt . " -n "
let cmd = cmd . grep_expr_option . " " . pattern
let cmd = cmd . " {} " . g:Grep_Null_Device . ' ' .
\ g:Grep_Shell_Escape_Char . ';'
endif
call s:RunGrepCmd(cmd, pattern, a:action)
endfunction
" RunGrepSpecial()
" Search for a pattern in all the opened buffers or filenames in the
" argument list
function! s:RunGrepSpecial(cmd_name, which, action, ...)
if a:0 > 0 && (a:1 == "-?" || a:1 == "-h")
echo 'Usage: ' . a:cmd_name . " [<grep_options>] [<search_pattern>]"
return
endif
" Search in all the Vim buffers
if a:which == 'buffer'
" Get a list of all the buffer names
let last_bufno = bufnr("$")
let i = 1
let filenames = ""
while i <= last_bufno
if bufexists(i) && buflisted(i)
let filenames = filenames . " " . bufname(i)
endif
let i = i + 1
endwhile
" No buffers
if filenames == ""
return
endif
elseif a:which == 'args'
" Search in all the filenames in the argument list
let arg_cnt = argc()
if arg_cnt == 0
echohl WarningMsg
echomsg "Error: Argument list is empty"
echohl None
return
endif
let i = 0
let filenames = ""
while i < arg_cnt
let filenames = filenames . " " . argv(i)
let i = i + 1
endwhile
" No arguments
if filenames == ""
echohl WarningMsg
echomsg "Error: Argument list is empty"
echohl None
return
endif
endif
let grep_opt = ""
let pattern = ""
" Get the list of optional grep command-line options (if present)
" supplied by the user. All the grep options will be preceded
" by a '-'
let argcnt= 1
while argcnt <= a:0 && a:{argcnt} =~ '^-'
let grep_opt = grep_opt . " " . a:{argcnt}
let argcnt = argcnt + 1
endwhile
" If the user didn't specify the option, then use the defaults
if grep_opt == ""
let grep_opt = g:Grep_Default_Options
endif
" Don't display messages about non-existent files
let grep_opt = grep_opt . " -s"
" The last argument specified by the user is the pattern
if argcnt == a:0
let pattern = a:{argcnt}
else
" No argument supplied. Get the identifier and file list from user
let pattern = input("Search for pattern: ", expand("<cword>"))
if pattern == ""
return
endif
endif
let pattern = g:Grep_Shell_Quote_Char . pattern . g:Grep_Shell_Quote_Char
" Add /dev/null to the list of filenames, so that grep print the
" filename and linenumber when grepping in a single file
let filenames = filenames . " " . g:Grep_Null_Device
let cmd = g:Grep_Path . " " . grep_opt . " -n -- "
let cmd = cmd . pattern . " " . filenames
call s:RunGrepCmd(cmd, pattern, a:action)
endfunction
" RunGrep()
" Run the specified grep command
function! s:RunGrep(cmd_name, grep_cmd, action, ...)
if a:0 > 0 && (a:1 == "-?" || a:1 == "-h")
echo 'Usage: ' . a:cmd_name . " [<grep_options>] [<search_pattern> " .
\ "[<file_name(s)>]]"
return
endif
let grep_opt = ""
let pattern = ""
let filenames = ""
" Parse the arguments
" grep command-line flags are specified using the "-flag" format
" the next argument is assumed to be the pattern
" and the next arguments are assumed to be filenames or file patterns
let argcnt = 1
while argcnt <= a:0
if a:{argcnt} =~ '^-'
let grep_opt = grep_opt . " " . a:{argcnt}
elseif pattern == ""
let pattern = g:Grep_Shell_Quote_Char . a:{argcnt} .
\ g:Grep_Shell_Quote_Char
else
let filenames= filenames . " " . a:{argcnt}
endif
let argcnt = argcnt + 1
endwhile
if grep_opt == ""
let grep_opt = g:Grep_Default_Options
endif
if a:grep_cmd != 'agrep'
" Don't display messages about non-existent files
" Agrep doesn't support the -s option
let grep_opt = grep_opt . " -s"
endif
if a:grep_cmd == 'grep'
let grep_path = g:Grep_Path
let grep_expr_option = '--'
elseif a:grep_cmd == 'fgrep'
let grep_path = g:Fgrep_Path
let grep_expr_option = '-e'
elseif a:grep_cmd == 'egrep'
let grep_path = g:Egrep_Path
let grep_expr_option = '-e'
elseif a:grep_cmd == 'agrep'
let grep_path = g:Agrep_Path
let grep_expr_option = ''
else
return
endif
" Get the identifier and file list from user
if pattern == ""
let pattern = input("Search for pattern: ", expand("<cword>"))
if pattern == ""
return
endif
let pattern = g:Grep_Shell_Quote_Char . pattern .
\ g:Grep_Shell_Quote_Char
endif
if filenames == ""
if v:version >= 700
let filenames = input("Search in files: ", g:Grep_Default_Filelist,
\ "file")
else
let filenames = input("Search in files: ", g:Grep_Default_Filelist)
endif
if filenames == ""
return
endif
endif
" Add /dev/null to the list of filenames, so that grep print the
" filename and linenumber when grepping in a single file
let filenames = filenames . " " . g:Grep_Null_Device
let cmd = grep_path . " " . grep_opt . " -n "
let cmd = cmd . grep_expr_option . " " . pattern
let cmd = cmd . " " . filenames
call s:RunGrepCmd(cmd, pattern, a:action)
endfunction
" Define the set of grep commands
command! -nargs=* -complete=file Grep
\ call s:RunGrep('Grep', 'grep', 'set', <f-args>)
command! -nargs=* -complete=file Rgrep
\ call s:RunGrepRecursive('Rgrep', 'grep', 'set', <f-args>)
command! -nargs=* GrepBuffer
\ call s:RunGrepSpecial('GrepBuffer', 'buffer', 'set', <f-args>)
command! -nargs=* Bgrep
\ call s:RunGrepSpecial('Bgrep', 'buffer', 'set', <f-args>)
command! -nargs=* GrepArgs
\ call s:RunGrepSpecial('GrepArgs', 'args', 'set', <f-args>)
command! -nargs=* -complete=file Fgrep
\ call s:RunGrep('Fgrep', 'fgrep', 'set', <f-args>)
command! -nargs=* -complete=file Rfgrep
\ call s:RunGrepRecursive('Rfgrep', 'fgrep', 'set', <f-args>)
command! -nargs=* -complete=file Egrep
\ call s:RunGrep('Egrep', 'egrep', 'set', <f-args>)
command! -nargs=* -complete=file Regrep
\ call s:RunGrepRecursive('Regrep', 'egrep', 'set', <f-args>)
command! -nargs=* -complete=file Agrep
\ call s:RunGrep('Agrep', 'agrep', 'set', <f-args>)
command! -nargs=* -complete=file Ragrep
\ call s:RunGrepRecursive('Ragrep', 'agrep', 'set', <f-args>)
if v:version >= 700
command! -nargs=* -complete=file GrepAdd
\ call s:RunGrep('GrepAdd', 'grep', 'add', <f-args>)
command! -nargs=* -complete=file RgrepAdd
\ call s:RunGrepRecursive('RgrepAdd', 'grep', 'add', <f-args>)
command! -nargs=* GrepBufferAdd
\ call s:RunGrepSpecial('GrepBufferAdd', 'buffer', 'add', <f-args>)
command! -nargs=* BgrepAdd
\ call s:RunGrepSpecial('BgrepAdd', 'buffer', 'add', <f-args>)
command! -nargs=* GrepArgsAdd
\ call s:RunGrepSpecial('GrepArgsAdd', 'args', 'add', <f-args>)
command! -nargs=* -complete=file FgrepAdd
\ call s:RunGrep('FgrepAdd', 'fgrep', 'add', <f-args>)
command! -nargs=* -complete=file RfgrepAdd
\ call s:RunGrepRecursive('RfgrepAdd', 'fgrep', 'add', <f-args>)
command! -nargs=* -complete=file EgrepAdd
\ call s:RunGrep('EgrepAdd', 'egrep', 'add', <f-args>)
command! -nargs=* -complete=file RegrepAdd
\ call s:RunGrepRecursive('RegrepAdd', 'egrep', 'add', <f-args>)
command! -nargs=* -complete=file AgrepAdd
\ call s:RunGrep('AgrepAdd', 'agrep', 'add', <f-args>)
command! -nargs=* -complete=file RagrepAdd
\ call s:RunGrepRecursive('RagrepAdd', 'agrep', 'add', <f-args>)
endif
" Add the Tools->Search Files menu
if has('gui_running')
anoremenu <silent> Tools.Search.Current\ Directory<Tab>:Grep
\ :Grep<CR>
anoremenu <silent> Tools.Search.Recursively<Tab>:Rgrep
\ :Rgrep<CR>
anoremenu <silent> Tools.Search.Buffer\ List<Tab>:Bgrep
\ :Bgrep<CR>
anoremenu <silent> Tools.Search.Argument\ List<Tab>:GrepArgs
\ :GrepArgs<CR>
endif
" restore 'cpo'
let &cpo = s:cpo_save
unlet s:cpo_save

View File

@@ -1,288 +0,0 @@
" Description: html indenter
" Author: Johannes Zellner <johannes@zellner.org>
" Last Change: Mo, 05 Jun 2006 22:32:41 CEST
" Restoring 'cpo' and 'ic' added by Bram 2006 May 5
" Globals: g:html_indent_tags -- indenting tags
" g:html_indent_strict -- inhibit 'O O' elements
" g:html_indent_strict_table -- inhibit 'O -' elements
" Only load this indent file when no other was loaded.
"if exists("b:did_indent")
"finish
"endif
"let b:did_indent = 1
if exists("g:js_indent")
so g:js_indent
else
ru! indent/javascript.vim
endif
echo "Sourcing html indent"
" [-- local settings (must come before aborting the script) --]
setlocal indentexpr=HtmlIndentGetter(v:lnum)
setlocal indentkeys=o,O,*<Return>,<>>,{,}
if exists('g:html_indent_tags')
unlet g:html_indent_tags
endif
" [-- helper function to assemble tag list --]
fun! <SID>HtmlIndentPush(tag)
if exists('g:html_indent_tags')
let g:html_indent_tags = g:html_indent_tags.'\|'.a:tag
else
let g:html_indent_tags = a:tag
endif
endfun
" [-- <ELEMENT ? - - ...> --]
call <SID>HtmlIndentPush('a')
call <SID>HtmlIndentPush('abbr')
call <SID>HtmlIndentPush('acronym')
call <SID>HtmlIndentPush('address')
call <SID>HtmlIndentPush('b')
call <SID>HtmlIndentPush('bdo')
call <SID>HtmlIndentPush('big')
call <SID>HtmlIndentPush('blockquote')
call <SID>HtmlIndentPush('button')
call <SID>HtmlIndentPush('caption')
call <SID>HtmlIndentPush('center')
call <SID>HtmlIndentPush('cite')
call <SID>HtmlIndentPush('code')
call <SID>HtmlIndentPush('colgroup')
call <SID>HtmlIndentPush('del')
call <SID>HtmlIndentPush('dfn')
call <SID>HtmlIndentPush('dir')
call <SID>HtmlIndentPush('div')
call <SID>HtmlIndentPush('dl')
call <SID>HtmlIndentPush('em')
call <SID>HtmlIndentPush('fieldset')
call <SID>HtmlIndentPush('font')
call <SID>HtmlIndentPush('form')
call <SID>HtmlIndentPush('frameset')
call <SID>HtmlIndentPush('h1')
call <SID>HtmlIndentPush('h2')
call <SID>HtmlIndentPush('h3')
call <SID>HtmlIndentPush('h4')
call <SID>HtmlIndentPush('h5')
call <SID>HtmlIndentPush('h6')
call <SID>HtmlIndentPush('i')
call <SID>HtmlIndentPush('iframe')
call <SID>HtmlIndentPush('ins')
call <SID>HtmlIndentPush('kbd')
call <SID>HtmlIndentPush('label')
call <SID>HtmlIndentPush('legend')
call <SID>HtmlIndentPush('map')
call <SID>HtmlIndentPush('menu')
call <SID>HtmlIndentPush('noframes')
call <SID>HtmlIndentPush('noscript')
call <SID>HtmlIndentPush('object')
call <SID>HtmlIndentPush('ol')
call <SID>HtmlIndentPush('optgroup')
" call <SID>HtmlIndentPush('pre')
call <SID>HtmlIndentPush('q')
call <SID>HtmlIndentPush('s')
call <SID>HtmlIndentPush('samp')
call <SID>HtmlIndentPush('script')
call <SID>HtmlIndentPush('select')
call <SID>HtmlIndentPush('small')
call <SID>HtmlIndentPush('span')
call <SID>HtmlIndentPush('strong')
call <SID>HtmlIndentPush('style')
call <SID>HtmlIndentPush('sub')
call <SID>HtmlIndentPush('sup')
call <SID>HtmlIndentPush('table')
call <SID>HtmlIndentPush('textarea')
call <SID>HtmlIndentPush('title')
call <SID>HtmlIndentPush('tt')
call <SID>HtmlIndentPush('u')
call <SID>HtmlIndentPush('ul')
call <SID>HtmlIndentPush('var')
" html5 tags
call <SID>HtmlIndentPush('article')
call <SID>HtmlIndentPush('aside')
call <SID>HtmlIndentPush('audio')
call <SID>HtmlIndentPush('bdi')
call <SID>HtmlIndentPush('canvas')
call <SID>HtmlIndentPush('command')
call <SID>HtmlIndentPush('datagrid')
call <SID>HtmlIndentPush('datalist')
call <SID>HtmlIndentPush('details')
call <SID>HtmlIndentPush('dialog')
call <SID>HtmlIndentPush('embed')
call <SID>HtmlIndentPush('figcaption')
call <SID>HtmlIndentPush('figure')
call <SID>HtmlIndentPush('footer')
call <SID>HtmlIndentPush('header')
call <SID>HtmlIndentPush('hgroup')
call <SID>HtmlIndentPush('keygen')
call <SID>HtmlIndentPush('mark')
call <SID>HtmlIndentPush('meter')
call <SID>HtmlIndentPush('nav')
call <SID>HtmlIndentPush('output')
call <SID>HtmlIndentPush('progress')
call <SID>HtmlIndentPush('rp')
call <SID>HtmlIndentPush('rt')
call <SID>HtmlIndentPush('ruby')
call <SID>HtmlIndentPush('section')
call <SID>HtmlIndentPush('source')
call <SID>HtmlIndentPush('summary')
call <SID>HtmlIndentPush('time')
call <SID>HtmlIndentPush('track')
call <SID>HtmlIndentPush('video')
call <SID>HtmlIndentPush('wbr')
" [-- <ELEMENT ? O O ...> --]
if !exists('g:html_indent_strict')
call <SID>HtmlIndentPush('body')
call <SID>HtmlIndentPush('head')
call <SID>HtmlIndentPush('html')
call <SID>HtmlIndentPush('tbody')
endif
" [-- <ELEMENT ? O - ...> --]
if !exists('g:html_indent_strict_table')
call <SID>HtmlIndentPush('th')
call <SID>HtmlIndentPush('td')
call <SID>HtmlIndentPush('tr')
call <SID>HtmlIndentPush('tfoot')
call <SID>HtmlIndentPush('thead')
endif
delfun <SID>HtmlIndentPush
let s:cpo_save = &cpo
set cpo-=C
" [-- count indent-increasing tags of line a:lnum --]
fun! <SID>HtmlIndentOpen(lnum, pattern)
let s = substitute('x'.getline(a:lnum),
\ '.\{-}\(\(<\)\('.a:pattern.'\)\>\)', "\1", 'g')
let s = substitute(s, "[^\1].*$", '', '')
return strlen(s)
endfun
" [-- count indent-decreasing tags of line a:lnum --]
fun! <SID>HtmlIndentClose(lnum, pattern)
let s = substitute('x'.getline(a:lnum),
\ '.\{-}\(\(<\)/\('.a:pattern.'\)\>>\)', "\1", 'g')
let s = substitute(s, "[^\1].*$", '', '')
return strlen(s)
endfun
" [-- count indent-increasing '{' of (java|css) line a:lnum --]
fun! <SID>HtmlIndentOpenAlt(lnum)
return strlen(substitute(getline(a:lnum), '[^{]\+', '', 'g'))
endfun
" [-- count indent-decreasing '}' of (java|css) line a:lnum --]
fun! <SID>HtmlIndentCloseAlt(lnum)
return strlen(substitute(getline(a:lnum), '[^}]\+', '', 'g'))
endfun
" [-- return the sum of indents respecting the syntax of a:lnum --]
fun! <SID>HtmlIndentSum(lnum, style)
if a:style == match(getline(a:lnum), '^\s*</')
if a:style == match(getline(a:lnum), '^\s*</\<\('.g:html_indent_tags.'\)\>')
let open = <SID>HtmlIndentOpen(a:lnum, g:html_indent_tags)
let close = <SID>HtmlIndentClose(a:lnum, g:html_indent_tags)
if 0 != open || 0 != close
return open - close
endif
endif
endif
if '' != &syntax &&
\ synIDattr(synID(a:lnum, 1, 1), 'name') =~ '\(css\|java\).*' &&
\ synIDattr(synID(a:lnum, strlen(getline(a:lnum)), 1), 'name')
\ =~ '\(css\|java\).*'
if a:style == match(getline(a:lnum), '^\s*}')
return <SID>HtmlIndentOpenAlt(a:lnum) - <SID>HtmlIndentCloseAlt(a:lnum)
endif
endif
return 0
endfun
fun! HtmlIndentGetter(lnum)
echo "Grabbing html indent for line: " . a:lnum
" Find a non-empty line above the current line.
let lnum = prevnonblank(a:lnum - 1)
" Hit the start of the file, use zero indent.
if lnum == 0
return 0
endif
let restore_ic = &ic
setlocal ic " ignore case
" [-- special handling for <pre>: no indenting --]
if getline(a:lnum) =~ '\c</pre>'
\ || 0 < searchpair('\c<pre>', '', '\c</pre>', 'nWb')
\ || 0 < searchpair('\c<pre>', '', '\c</pre>', 'nW')
" we're in a line with </pre> or inside <pre> ... </pre>
if restore_ic == 0
setlocal noic
endif
return -1
endif
" [-- special handling for <javascript>: use cindent --]
let js = '<script.*type\s*=.*javascript'
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" by Tye Zdrojewski <zdro@yahoo.com>, 05 Jun 2006
" ZDR: This needs to be an AND (we are 'after the start of the pair' AND
" we are 'before the end of the pair'). Otherwise, indentation
" before the start of the script block will be affected; the end of
" the pair will still match if we are before the beginning of the
" pair.
"
if 0 < searchpair(js, '', '</script>', 'nWb')
\ && 0 < searchpair(js, '', '</script>', 'nW')
" we're inside javascript
if getline(lnum) !~ js && getline(a:lnum) !~ '</script>'
if restore_ic == 0
setlocal noic
endif
return GetJsIndent(a:lnum)
endif
endif
if getline(lnum) =~ '\c</pre>'
" line before the current line a:lnum contains
" a closing </pre>. --> search for line before
" starting <pre> to restore the indent.
let preline = prevnonblank(search('\c<pre>', 'bW') - 1)
if preline > 0
if restore_ic == 0
setlocal noic
endif
return indent(preline)
endif
endif
let ind = <SID>HtmlIndentSum(lnum, -1)
let ind = ind + <SID>HtmlIndentSum(a:lnum, 0)
if restore_ic == 0
setlocal noic
endif
return indent(lnum) + (&sw * ind)
endfun
let &cpo = s:cpo_save
unlet s:cpo_save
" [-- EOF <runtime>/indent/html.vim --]

View File

@@ -1,407 +0,0 @@
" Vim indent file Language: JavaScript
" Author: Preston Koprivica (pkopriv2@gmail.com)
" URL:
" Last Change: April 30, 2010
" 0. Standard Stuff
" =================
" Only load one indent script per buffer
if exists('b:did_indent')
finish
endif
let b:did_indent = 1
" Set the global log variable 1 = logging enabled, 0 = logging disabled
if !exists("g:js_indent_log")
let g:js_indent_log = 0
endif
setlocal indentexpr=GetJsIndent(v:lnum)
setlocal indentkeys=
setlocal cindent
setlocal autoindent
" 1. Variables
" ============
" Inline comments (for anchoring other statements)
let s:js_mid_line_comment = '\s*\(\/\*.*\*\/\)*\s*'
let s:js_end_line_comment = s:js_mid_line_comment . '\s*\(//.*\)*'
let s:js_line_comment = s:js_end_line_comment
" Comment/String Syntax Key
let s:syn_comment = '\(Comment\|String\|Regexp\)'
" 2. Aux. Functions
" =================
" = Method: IsInComment
"
" Determines whether the specified position is contained in a comment. "Note:
" This depends on a
function! s:IsInComment(lnum, cnum)
return synIDattr(synID(a:lnum, a:cnum, 1), 'name') =~? s:syn_comment
endfunction
" = Method: IsComment
"
" Determines whether a line is a comment or not.
function! s:IsComment(lnum)
let line = getline(a:lnum)
return s:IsInComment(a:lnum, 1) && s:IsInComment(a:lnum, strlen(line)) "Doesn't absolutely work. Only Probably!
endfunction
" = Method: GetNonCommentLine
"
" Grabs the nearest non-commented line
function! s:GetNonCommentLine(lnum)
let lnum = prevnonblank(a:lnum)
while lnum > 0
if s:IsComment(lnum)
let lnum = prevnonblank(lnum - 1)
else
return lnum
endif
endwhile
return lnum
endfunction
" = Method: SearchForPair
"
" Returns the beginning tag of a given pair starting from the given line.
function! s:SearchForPair(lnum, beg, end)
" Save the cursor position.
let curpos = getpos(".")
" Set the cursor position to the beginning of the line (default
" behavior when using ==)
call cursor(a:lnum, 0)
" Search for the opening tag
let mnum = searchpair(a:beg, '', a:end, 'bW',
\ 'synIDattr(synID(line("."), col("."), 0), "name") =~? s:syn_comment' )
"Restore the cursor position
call cursor(curpos)
" Finally, return the matched line number
return mnum
endfunction
" Object Helpers
" ==============
let s:object_beg = '{[^}]*' . s:js_end_line_comment . '$'
let s:object_end = '^' . s:js_mid_line_comment . '}[;,]\='
function! s:IsObjectBeg(line)
return a:line =~ s:object_beg
endfunction
function! s:IsObjectEnd(line)
return a:line =~ s:object_end
endfunction
function! s:GetObjectBeg(lnum)
return s:SearchForPair(a:lnum, '{', '}')
endfunction
" Array Helpers
" ==============
let s:array_beg = '\[[^\]]*' . s:js_end_line_comment . '$'
let s:array_end = '^' . s:js_mid_line_comment . '[^\[]*\][;,]*' . s:js_end_line_comment . '$'
function! s:IsArrayBeg(line)
return a:line =~ s:array_beg
endfunction
function! s:IsArrayEnd(line)
return a:line =~ s:array_end
endfunction
function! s:GetArrayBeg(lnum)
return s:SearchForPair(a:lnum, '\[', '\]')
endfunction
" MultiLine Declaration/Invocation Helpers
" ========================================
let s:paren_beg = '([^)]*' . s:js_end_line_comment . '$'
let s:paren_end = '^' . s:js_mid_line_comment . '[^(]*)[;,]*'
function! s:IsParenBeg(line)
return a:line =~ s:paren_beg
endfunction
function! s:IsParenEnd(line)
return a:line =~ s:paren_end
endfunction
function! s:GetParenBeg(lnum)
return s:SearchForPair(a:lnum, '(', ')')
endfunction
" Continuation Helpers
" ====================
let s:continuation = '\(+\|\\\)\{1}' . s:js_line_comment . '$'
function! s:IsContinuationLine(line)
return a:line =~ s:continuation
endfunction
function! s:GetContinuationBegin(lnum)
let cur = a:lnum
while s:IsContinuationLine(getline(cur))
let cur -= 1
endwhile
return cur + 1
endfunction
" Switch Helpers
" ==============
let s:switch_beg_next_line = 'switch\s*(.*)\s*' . s:js_mid_line_comment . s:js_end_line_comment . '$'
let s:switch_beg_same_line = 'switch\s*(.*)\s*' . s:js_mid_line_comment . '{\s*' . s:js_line_comment . '$'
let s:switch_mid = '^.*\(case.*\|default\)\s*:\s*'
function! s:IsSwitchBeginNextLine(line)
return a:line =~ s:switch_beg_next_line
endfunction
function! s:IsSwitchBeginSameLine(line)
return a:line =~ s:switch_beg_same_line
endfunction
function! s:IsSwitchMid(line)
return a:line =~ s:switch_mid
endfunction
" Control Helpers
" ===============
let s:cntrl_beg_keys = '\(\(\(if\|for\|with\|while\)\s*(.*)\)\|\(try\|do\)\)\s*'
let s:cntrl_mid_keys = '\(\(\(else\s*if\|catch\)\s*(.*)\)\|\(finally\|else\)\)\s*'
let s:cntrl_beg = s:cntrl_beg_keys . s:js_end_line_comment . '$'
let s:cntrl_mid = s:cntrl_mid_keys . s:js_end_line_comment . '$'
let s:cntrl_end = '\(while\s*(.*)\)\s*;\=\s*' . s:js_end_line_comment . '$'
function! s:IsControlBeg(line)
return a:line =~ s:cntrl_beg
endfunction
function! s:IsControlMid(line)
return a:line =~ s:cntrl_mid
endfunction
function! s:IsControlMidStrict(line)
return a:line =~ s:cntrl_mid
endfunction
function! s:IsControlEnd(line)
return a:line =~ s:cntrl_end
endfunction
" = Method: Log
"
" Logs a message to the stdout.
function! s:Log(msg)
if g:js_indent_log
echo "LOG: " . a:msg
endif
endfunction
" 3. Indenter
" ===========
function! GetJsIndent(lnum)
" Grab the first non-comment line prior to this line
let pnum = s:GetNonCommentLine(a:lnum-1)
" First line, start at indent = 0
if pnum == 0
call s:Log("No, noncomment lines prior to the current line.")
return 0
endif
" Grab the second non-comment line prior to this line
let ppnum = s:GetNonCommentLine(pnum-1)
call s:Log("Line: " . a:lnum)
call s:Log("PLine: " . pnum)
call s:Log("PPLine: " . ppnum)
" Grab the lines themselves.
let line = getline(a:lnum)
let pline = getline(pnum)
let ppline = getline(ppnum)
" Determine the current level of indentation
let ind = indent(pnum)
" Handle: Object Closers (ie })
" =============================
if s:IsObjectEnd(line) && !s:IsComment(a:lnum)
call s:Log("Line matched object end")
let obeg = s:GetObjectBeg(a:lnum)
let oind = indent(obeg)
let oline = getline(obeg)
call s:Log("The object beg was found at: " . obeg)
return oind
endif
if s:IsObjectBeg(pline)
call s:Log("Pline matched object beg")
return ind + &sw
endif
" Handle: Array Closer (ie ])
" ============================
if s:IsArrayEnd(line) && !s:IsComment(a:lnum)
call s:Log("Line matched array end")
let abeg = s:GetArrayBeg(a:lnum)
let aind = indent(abeg)
call s:Log("The array beg was found at: " . abeg)
return aind
endif
if s:IsArrayBeg(pline)
call s:Log("Pline matched array beg")
return ind + &sw
endif
" Handle: Parens
" ==============
if s:IsParenEnd(line) && !s:IsComment(a:lnum)
call s:Log("Line matched paren end")
let abeg = s:GetParenBeg(a:lnum)
let aind = indent(abeg)
call s:Log("The paren beg was found at: " . abeg)
return aind
endif
if s:IsParenBeg(pline)
call s:Log("Pline matched paren beg")
return ind + &sw
endif
" Handle: Continuation Lines.
" ========================================================
if s:IsContinuationLine(pline)
call s:Log('Pline is a continuation line.')
let cbeg = s:GetContinuationBegin(pnum)
let cind = indent(cbeg)
call s:Log('The continuation block begin found at: ' . cbeg)
return cind + &sw
endif
if s:IsContinuationLine(ppline)
call s:Log('PPline was a continuation line but pline wasnt.')
return ind - &sw
endif
" Handle: Switch Control Blocks
" =============================
if s:IsSwitchMid(pline)
call s:Log("PLine matched switch cntrl mid")
if s:IsSwitchMid(line) || s:IsObjectEnd(line)
call s:Log("Line matched a cntrl mid")
return ind
else
call s:Log("Line didnt match a cntrl mid")
return ind + &sw
endif
endif
if s:IsSwitchMid(line)
call s:Log("Line matched switch cntrl mid")
return ind - &sw
endif
" Handle: Single Line Control Blocks
" ==================================
if s:IsControlBeg(pline)
call s:Log("Pline matched control beginning")
if s:IsControlMid(line)
call s:Log("Line matched a control mid")
return ind
elseif line =~ '^\s*{\s*$'
call s:Log("Line matched an object beg")
return ind
else
return ind + &sw
endif
endif
if s:IsControlMid(pline)
call s:Log("Pline matched a control mid")
if s:IsControlMid(line)
call s:Log("Line matched a control mid")
return ind
elseif s:IsObjectBeg(line)
call s:Log("Line matched an object beg")
return ind
else
call s:Log("Line didn't match a control mid or object beg."
return ind + &sw
endif
endif
if s:IsControlMid(line)
call s:Log("Line matched a control mid.")
if s:IsControlEnd(pline) || s:IsObjectEnd(pline)
call s:Log("PLine matched control end")
return ind
else
call s:Log("Pline didn't match object end")
return ind - &sw
endif
endif
if ( s:IsControlBeg(ppline) || s:IsControlMid(ppline) ) &&
\ !s:IsObjectBeg(pline) && !s:IsObjectEnd(pline)
call s:Log("PPLine matched single line control beg or mid")
return ind - &sw
endif
" Handle: No matches
" ==================
"call s:Log("Line didn't match anything. Retaining indent")
return ind
endfunction

View File

@@ -1,399 +0,0 @@
<!-- SAMPLE HTML WITH EMBEDDED JS -->
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>Test</title>
</head>
<body>
<script type="text/javascript" charset="utf-8">
var x = 1 + 1; // 0
// = Case: Arithmetic (2)
var x = 1 + // 0
1; // 1
// = Case: Arithmetic (3)
var x = 1 + // 0
1 + // 1
1; // 1
// = Case: Object (1)
var x = { // 0
// comment // 1
y : y, // 1
z : z // 1
} // 0
// = Case: Object (2)
var x = { // 0
// comment // 1
y : { // 1
z: z, // 2
w: w // 2
}, // 1
t: t // 1
} // 0
// Case: Function (1)
function $blah() { // 0
x; // 1
y; // 1
} // 0
// Case: Function (2)
var $blah = function() { // 0
x; // 1
y; // 1
} // 0
// Case: Function(3)
var x = { // 0
$blah: function() { // 1
y; // 2
} // 1
} // 0
// Case: Function(4)
function $blah( // 0
x, // 1
y, // 1
z ) { // 1
} // 0
// Case: Function (5)
function $blah( // 0
x, // 1
y, // 1
z ) { // 1
x; // 1
} // 0
// = Case: if (1)
if ( x ) { // 0
x; // 1
} // 0
// = Case: if (2)
if(x) // 0
x; // 1
y; // 0
// = Case: if (3)
if(x) // 0
{ // 0
x; // 1
} // 0
// = Case: if (4)
if( x == y && // 0
y == z || // 1
z == w) { // 1
x; // 1
} // 0
// = Case: if (4a)
if( x == y && // 0
y == z || // 1
z == w) // 1
{ // 0
x; // 1
} // 0
// = Case: if (5)
if(x) // 0
// comment // 1
y; // 1
x; // 0
// = Case: if else (1)
if ( x ) { // 0
x; // 1
} else { // 0
y; // 1
} // 0
// = Case: if else (2)
if ( x ) // 0
x; // 1
else // 0
y; // 1
// = Case: if else(3)
if(x) // 0
{ // 0
x; // 1
} // 0
else // 0
{ // 0
y; // 1
} // 0
// = Case: if elseif else (1)
if ( x ) { // 0
x; // 1
} else if ( y ) { // 0
y; // 1
} else { // 0
z; // 1
} // 0
// = Case: if elseif else (2)
if ( x ) // 0
x; // 1
else if ( y ) // 0
y; // 1
else // 0
z; // 1
// = Case: if elseif else (3)
if(x) // 0
{ // 0
x; // 1
} // 0
else if(y) // 0
{ // 0
y; // 1
} // 0
else // 0
{ // 0
z; // 1
} // 0
// = Case: for (1)
for (var i = 0; i < blah.length; i++) { // 0
blah[i]; // 1
}; // 0
// = Case: for (2)
for (var i = 0; i < blah.length; i++) // 0
blah[i]; // 1
x; // 0
// = Case: switch
switch(x) { // 0
case "y": // 0
y; // 1
break; // 1
case "z": // 0
z; // 1
break; // 1
default: // 0
w; // 1
break; // 1
}
// = Case: try (1)
try { // 0
x; // 1
} // 0
// = Case: try (2)
try // 0
x; // 1
y; // 0
// = Case: try (3)
try // 0
{ // 0
x; // 1
} // 0
// = Case: try catch (1)
try { // 0
x; // 1
} catch(e) { // 0
y; // 1
} // 0
// Case: try catch (2)
try // 0
{ // 0
x; // 1
} // 0
catch(e) // 0
{ // 0
y; // 1
} // 0
// Case: try catch (3)
try // 0
x; // 1
catch(e) // 0
y; // 1
// Case: try catch finally (1)
try { // 0
x; // 1
y; // 1
} catch(e) { // 0
x; // 1
y; // 1
} finally { // 0
x; // 1
y; // 1
}
// = Case: try catch finally (2)
try // 0
x; // 1
catch(e) // 0
y; // 1
finally // 0
z; // 1
// = Case: try catch finally (3)
try // 0
// comment // 1
x; // 1
catch(e) // 0
// comment // 1
y; // 1
finally // 1
// comment // 1
z; // 1
// = Case: Anonymous Function (1)
(function(x) { // 0
x; // 1
y; // 1
})(x); // 0
// = Case: Anonymous Function (2)
(function(x) // 0
{ // 0
x; // 1
y; // 1
})(x); // 0
// = Case: Anonymous Function (2)
(function(x) // 0
{ // 1
x; // 1
y; // 1
} // 0
)(x); // 0
// = Case: Anonymous Function (1)
(function(x) { // 0
x; // 1
y; // 1
} // 0
)(x); // 0
// = Case: COMPLEX
(function(window, undefined) { // 0
// = Class: Test // 1
// // 1
// = Description: This is a // 1
// test class. // 1
// // 1
var Test = new Class({ // 1
initialize: function() { // 2
this.test = test; // 3
}, // 2
// = Method: test // 2
// // 2
// = Description: // 2
// // 2
test: function(blah) { // 2
if(blah) { // 3
return "blah"; // 4
} else if(blah === undefined) // 3
return "blahblah"; // 4
else { // 3
// another comment. // 4
return "blahblahblah"; // 4
} // 3
var x = { // 3
y: function() { // 4
for (var i = 0; i < blah.length; i++) { // 5
blah[i]; // 6
}; // 5
} // 4
}; // 3
return new function() { // 3
}; // 3
}, // 2
// = Method: blah // 2
// // 2
// = Description: description // 2
// // 2
blah: function(haha) { // 2
return this.test; // 3
} // 2
}); // 1
})(this); // 0
// Case: SKELETON CODE
(function(window, undefined) {
// = Class: Test
//
// = Description:
//
var Test = new Class({
});
// = Class: Test2
// = Extends: Test
//
// = Description:
//
var Test2 = new Class({
initialize: function() {
},
// = Method: blah
//
// = Description: description
//
contrls: function() {
while(true) {
}
do {
} while(true);
with(x) {
}
if (true) {
} else if(true) {
} else {
}
for (var i = 0; i < blah.length; i++) {
}
switch(true) {
case 'case1': break;
case 'case2': break;
default:
}
try {
} catch (e) {
} finally {
}
}
});
})(this);
</script>
</body>
</html>

View File

@@ -1,353 +0,0 @@
" Vim indent file
" Language: Mako
" Author: Scott Torborg <storborg@mit.edu>
" Version: 0.4
" License: Do What The Fuck You Want To Public License (WTFPL)
"
" ---------------------------------------------------------------------------
"
" DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
" Version 2, December 2004
"
" Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
"
" Everyone is permitted to copy and distribute verbatim or modified
" copies of this license document, and changing it is allowed as long
" as the name is changed.
"
" DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
" TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
"
" 0. You just DO WHAT THE FUCK YOU WANT TO.
"
" ---------------------------------------------------------------------------
"
" This script does more useful indenting for Mako HTML templates. It indents
" inside of control blocks, defs, etc. Note that this indenting style will
" sacrifice readability of the output text for the sake of readability of the
" template.
"
" We'll use HTML indenting globally, python inside <% %> blocks. Inspired by
" the excellent PHP + HTML indentation files such as php.vim by Pim Snel.
"
" Changelog:
" 0.4 - 5 March 2010
" - Added license information
" 0.3 - 15 September 2009
" - Added explicit indenting for ## comments, fixed unindenting count,
" thanks to Mike Lewis (@MikeRLewis) for this
" 0.2 - 15 June 2009
" - Fixed issue where opening and closing mako tags on the same line
" would cause incorrect indenting
" 0.1 - 06 June 2009
" - Initial public release of mako indent file
let sw=2 " default shiftwidth of 2 spaces
if exists("b:did_indent")
finish
endif
let b:did_indent = 1
setlocal nosmartindent
setlocal noautoindent
setlocal nocindent
setlocal nolisp
setlocal indentexpr=GetMakoIndent()
setlocal indentkeys+=*<Return>,<>>,<bs>,end,:
" Only define the function once.
if exists("*GetMakoIndent")
finish
endif
if exists('g:html_indent_tags')
unlet g:html_indent_tags
endif
function IsInsidePythonBlock(startline)
" Loop until we get a line that's either <% or %>
let lnum = a:startline
while getline(lnum) !~ '\(%>\|<%\)$' && lnum > 0
let lnum = lnum - 1
endwhile
" lnum points to the last control. If it's a <% then we're inside an
" embedded python block, otherwise we're not.
return getline(lnum) =~ '<%$'
endfunction
function GetMakoIndent()
" Find a non-empty line above the current line
let lnum = prevnonblank(v:lnum - 1)
" Hit the start of the file, use zero indent.
if lnum == 0
return 0
endif
let line = getline(lnum) " last line
let cline = getline(v:lnum) " current line
let pline = getline(lnum - 1) " previous to last line
let ind = indent(lnum)
if line =~ '^\s*##'
return indent(lnum)
end
let restore_ic=&ic
let &ic=1 " ignore case
let ind = <SID>HtmlIndentSum(lnum, -1)
let ind = <SID>HtmlIndentSum(lnum, -1)
let ind = ind + <SID>HtmlIndentSum(v:lnum, 0)
let &ic=restore_ic
let ind = indent(lnum) + (&sw * ind)
" Indent after %anything: or <%anything NOT ending in />
if line =~ '^\s*%.*:\s*$'
let ind = ind + &sw
endif
" Unindent before %end* or </%anything
if cline =~ '^\s*%\s*end'
let ind = ind - &sw
endif
"
" Unindent before %else, %except, and %elif
if cline =~ '^\s*%\s*else' || cline =~ '^\s*%\s*except' || cline =~ '^\s*%\s*elif'
let ind = ind - &sw
endif
" Indent at the beginning of a python control block
if line =~ '<%$'
let ind = ind + &sw
endif
"
" Unindent at the end of the python block.
if cline =~ '^\s*%>$'
let scanlnum = lnum
" Scan backwards until we find the beginning of this python block.
while getline(scanlnum) !~ '<%$' && scanlnum > 0
let scanlnum = scanlnum - 1
endwhile
let ind = indent(scanlnum)
endif
" If we're inside a python block and the previous line ends in a colon,
" indent.
if IsInsidePythonBlock(lnum - 1)
" Indent after :
if line =~ '\:$'
let ind = ind + &sw
endif
endif
return ind
endfunction
" [-- helper function to assemble tag list --]
fun! <SID>HtmlIndentPush(tag)
if exists('g:html_indent_tags')
let g:html_indent_tags = g:html_indent_tags.'\|'.a:tag
else
let g:html_indent_tags = a:tag
endif
endfun
fun! <SID>MakoIndentPush(tag)
if exists('g:mako_indent_tags')
let g:mako_indent_tags = g:mako_indent_tags.'\|'.a:tag
else
let g:mako_indent_tags = a:tag
endif
endfun
" [-- <ELEMENT ? - - ...> --]
call <SID>HtmlIndentPush('a')
call <SID>HtmlIndentPush('abbr')
call <SID>HtmlIndentPush('acronym')
call <SID>HtmlIndentPush('address')
call <SID>HtmlIndentPush('b')
call <SID>HtmlIndentPush('bdo')
call <SID>HtmlIndentPush('big')
call <SID>HtmlIndentPush('blockquote')
call <SID>HtmlIndentPush('button')
call <SID>HtmlIndentPush('caption')
call <SID>HtmlIndentPush('center')
call <SID>HtmlIndentPush('cite')
call <SID>HtmlIndentPush('code')
call <SID>HtmlIndentPush('colgroup')
call <SID>HtmlIndentPush('del')
call <SID>HtmlIndentPush('dfn')
call <SID>HtmlIndentPush('dir')
call <SID>HtmlIndentPush('div')
call <SID>HtmlIndentPush('dl')
call <SID>HtmlIndentPush('em')
call <SID>HtmlIndentPush('fieldset')
call <SID>HtmlIndentPush('font')
call <SID>HtmlIndentPush('form')
call <SID>HtmlIndentPush('frameset')
call <SID>HtmlIndentPush('h1')
call <SID>HtmlIndentPush('h2')
call <SID>HtmlIndentPush('h3')
call <SID>HtmlIndentPush('h4')
call <SID>HtmlIndentPush('h5')
call <SID>HtmlIndentPush('h6')
call <SID>HtmlIndentPush('i')
call <SID>HtmlIndentPush('iframe')
call <SID>HtmlIndentPush('ins')
call <SID>HtmlIndentPush('kbd')
call <SID>HtmlIndentPush('label')
call <SID>HtmlIndentPush('legend')
call <SID>HtmlIndentPush('map')
call <SID>HtmlIndentPush('menu')
call <SID>HtmlIndentPush('noframes')
call <SID>HtmlIndentPush('noscript')
call <SID>HtmlIndentPush('object')
call <SID>HtmlIndentPush('ol')
call <SID>HtmlIndentPush('optgroup')
call <SID>HtmlIndentPush('pre')
call <SID>HtmlIndentPush('q')
call <SID>HtmlIndentPush('s')
call <SID>HtmlIndentPush('samp')
call <SID>HtmlIndentPush('script')
call <SID>HtmlIndentPush('select')
call <SID>HtmlIndentPush('small')
call <SID>HtmlIndentPush('span')
call <SID>HtmlIndentPush('strong')
call <SID>HtmlIndentPush('style')
call <SID>HtmlIndentPush('sub')
call <SID>HtmlIndentPush('sup')
call <SID>HtmlIndentPush('table')
call <SID>HtmlIndentPush('textarea')
call <SID>HtmlIndentPush('title')
call <SID>HtmlIndentPush('tt')
call <SID>HtmlIndentPush('u')
call <SID>HtmlIndentPush('ul')
call <SID>HtmlIndentPush('var')
" For some reason the default HTML indentation script doesn't consider these
" elements to be worthy of indentation.
call <SID>HtmlIndentPush('p')
call <SID>HtmlIndentPush('dt')
call <SID>HtmlIndentPush('dd')
" [-- <ELEMENT ? O O ...> --]
if !exists('g:html_indent_strict')
call <SID>HtmlIndentPush('body')
call <SID>HtmlIndentPush('head')
call <SID>HtmlIndentPush('html')
call <SID>HtmlIndentPush('tbody')
endif
" [-- <ELEMENT ? O - ...> --]
if !exists('g:html_indent_strict_table')
call <SID>HtmlIndentPush('th')
call <SID>HtmlIndentPush('td')
call <SID>HtmlIndentPush('tr')
call <SID>HtmlIndentPush('tfoot')
call <SID>HtmlIndentPush('thead')
endif
" [-- <Mako Elements> --]
call <SID>MakoIndentPush('%def')
call <SID>MakoIndentPush('%call')
call <SID>MakoIndentPush('%doc')
call <SID>MakoIndentPush('%text')
call <SID>MakoIndentPush('%.\+:.\+')
delfun <SID>HtmlIndentPush
delfun <SID>MakoIndentPush
set cpo-=C
" [-- get number of regex matches in a string --]
fun! <SID>MatchCount(expr, pat)
let mpos = 0
let mcount = 0
let expr = a:expr
while (mpos > -1)
let mend = matchend(expr, a:pat)
if mend > -1
let mcount = mcount + 1
endif
if mend == mpos
let mpos = mpos + 1
else
let mpos = mend
endif
let expr = strpart(expr, mpos)
endwhile
return mcount
endfun
" [-- count indent-increasing tags of line a:lnum --]
fun! <SID>HtmlIndentOpen(lnum)
let s = substitute('x'.getline(a:lnum),
\ '.\{-}\(\(<\)\('.g:html_indent_tags.'\)\>\)', "\1", 'g')
let s = substitute(s, "[^\1].*$", '', '')
return strlen(s)
endfun
" [-- count indent-decreasing tags of line a:lnum --]
fun! <SID>HtmlIndentClose(lnum)
let s = substitute('x'.getline(a:lnum),
\ '.\{-}\(\(<\)/\('.g:html_indent_tags.'\)\>>\)', "\1", 'g')
let s = substitute(s, "[^\1].*$", '', '')
return strlen(s)
endfun
" [-- count indent-increasing mako tags of line a:lnum --]
fun! <SID>MakoIndentOpen(lnum)
let s = substitute('x'.getline(a:lnum),
\ '.\{-}\(\(<\)\('.g:mako_indent_tags.'\)\>\)', "\1", 'g')
let s = substitute(s, "[^\1].*$", '', '')
return strlen(s)
endfun
" [-- count indent-decreasing mako tags of line a:lnum --]
fun! <SID>MakoIndentClose(lnum)
let mcount = <SID>MatchCount(getline(a:lnum), '</\('.g:mako_indent_tags.'\)>')
let mcount = mcount + <SID>MatchCount(getline(a:lnum), '<\('.g:mako_indent_tags.'\)[^>]*/>')
return mcount
endfun
" [-- count indent-increasing '{' of (java|css) line a:lnum --]
fun! <SID>HtmlIndentOpenAlt(lnum)
return strlen(substitute(getline(a:lnum), '[^{]\+', '', 'g'))
endfun
" [-- count indent-decreasing '}' of (java|css) line a:lnum --]
fun! <SID>HtmlIndentCloseAlt(lnum)
return strlen(substitute(getline(a:lnum), '[^}]\+', '', 'g'))
endfun
" [-- return the sum of indents respecting the syntax of a:lnum --]
fun! <SID>HtmlIndentSum(lnum, style)
let open = <SID>HtmlIndentOpen(a:lnum) + <SID>MakoIndentOpen(a:lnum)
let close = <SID>HtmlIndentClose(a:lnum) + <SID>MakoIndentClose(a:lnum)
if a:style == match(getline(a:lnum), '^\s*</')
if a:style == match(getline(a:lnum), '^\s*</\('.g:html_indent_tags.'\|'.g:mako_indent_tags.'\)')
if 0 != open || 0 != close
return open - close
endif
endif
endif
if '' != &syntax &&
\ synIDattr(synID(a:lnum, 1, 1), 'name') =~ '\(css\|java\).*' &&
\ synIDattr(synID(a:lnum, strlen(getline(a:lnum)) - 1, 1), 'name')
\ =~ '\(css\|java\).*'
if a:style == match(getline(a:lnum), '^\s*}')
return <SID>HtmlIndentOpenAlt(a:lnum) - <SID>HtmlIndentCloseAlt(a:lnum)
endif
endif
return 0
endfun
" vim: set ts=4 sw=4:

View File

@@ -1,262 +0,0 @@
" Vim indent file
" Language: Python
" Maintainer: Bram Moolenaar <Bram@vim.org>
" Original Author: David Bustos <bustos@caltech.edu>
" Last Change: 2008 Mar 14
" Changed my Jason Casden to try to prettify the line continuations
" Only load this indent file when no other was loaded.
if exists("b:did_indent")
finish
endif
let b:did_indent = 1
let g:linecont = 0
" Some preliminary settings
setlocal nolisp " Make sure lisp indenting doesn't supersede us
setlocal autoindent " indentexpr isn't much help otherwise
setlocal indentexpr=GetPythonIndent(v:lnum)
setlocal indentkeys+=<:>,=elif,=except
" Only define the function once.
if exists("*GetPythonIndent")
finish
endif
" Come here when loading the script the first time.
let s:maxoff = 50 " maximum number of lines to look backwards for ()
function GetPythonParenContinue(lnum3)
call cursor(a:lnum3,1)
"JMC
let pnum2 = searchpair('(\|{\|\[', '', ')\|}\|\]', 'rnbW',
\ "line('.') < " . (a:lnum3 - s:maxoff) . " ? dummy :"
\ . " synIDattr(synID(line('.'), col('.'), 1), 'name')"
\ . " =~ '\\(Comment\\|String\\)$'")
if pnum2 > 0
let g:linecont = 1
return pnum2
else
return a:lnum3
endif
endfunction
function GetPythonExplicitContinue(lnum2)
let i = 1
let ret_lnum = a:lnum2
while (getline(a:lnum2 - i) =~ '\\\s*$')
let g:linecont = 1
let ret_lnum = a:lnum2 - i
let i = i + 1
endwhile
return ret_lnum
endfunction
function GetPythonIndent(lnum)
" " If this line is explicitly joined: If the previous line was also joined,
"" line it up with that one, otherwise add two 'shiftwidth'
"if getline(a:lnum - 1) =~ '\\$'
"if a:lnum > 1 && getline(a:lnum - 2) =~ '\\\s*$'
"return indent(a:lnum - 1)
"endif
"return indent(a:lnum - 1) + (exists("g:pyindent_continue") ? eval(g:pyindent_continue) : (&sw * 2))
"endif
" If the start of the line is in a string don't change the indent.
if has('syntax_items')
\ && synIDattr(synID(a:lnum, 1, 1), "name") =~ "String$"
return -1
endif
" Search backwards for the previous non-empty line.
let plnum = prevnonblank(v:lnum - 1)
if plnum == 0
" This is the first non-empty line, use zero indent.
return 0
endif
" If the previous line is inside parenthesis, use the indent of the starting
" line.
" Trick: use the non-existing "dummy" variable to break out of the loop when
" going too far back.
call cursor(plnum, 1)
"JMC
" let parlnum = searchpair('(\|{\|\[', '', ')\|}\|\]', 'rnbW',
"\ "line('.') < " . (plnum - s:maxoff) . " ? dummy :"
"\ . " synIDattr(synID(line('.'), col('.'), 1), 'name')"
"\ . " =~ '\\(Comment\\|String\\)$'")
let parlnumcomp = 0
let parlnum = plnum
while (parlnumcomp != parlnum)
let parlnumcomp = parlnum
let parlnum = GetPythonParenContinue(parlnum)
let parlnum = GetPythonExplicitContinue(parlnum)
endwhile
" If this line is explicitly joined: If the previous line was also joined,
" line it up with that one, otherwise add two 'shiftwidth'
if getline(plnum) =~ '\\$'
return indent(parlnum) + (&sw * 2)
else
let plindent = indent(parlnum)
endif
let plnumstart = parlnum
" When inside parenthesis: If at the first line below the parenthesis add
" two 'shiftwidth', otherwise same as previous line.
" i = (a
" + b
" + c)
call cursor(a:lnum, 1)
" JMC, changed to searchpairpos
let [p,parcol] = searchpairpos('(\|{\|\[', '', ')\|}\|\]', 'bW',
\ "line('.') < " . (a:lnum - s:maxoff) . " ? dummy :"
\ . " synIDattr(synID(line('.'), col('.'), 1), 'name')"
\ . " =~ '\\(Comment\\|String\\)$'")
if p > 0
"if p == plnum
" JMC
" let [pp,parcol2] = searchpairpos('(\|{\|\[', '', ')\|}\|\]', 'bW',
"\ "line('.') < " . (a:lnum - s:maxoff) . " ? dummy :"
"\ . " synIDattr(synID(line('.'), col('.'), 1), 'name')"
"\ . " =~ '\\(Comment\\|String\\)$'")
"if pp > 0
"return indent(plnum) + (exists("g:pyindent_nested_paren") ? eval(g:pyindent_nested_paren) : parcol2)
"endif
" JMC, changed to return column position, unless specifically asked
" otherwise
"return indent(plnum) + (exists("g:pyindent_open_paren") ? eval(g:pyindent_open_paren) : (&sw * 2))
return (exists("g:pyindent_open_paren") ? indent(p) + eval(g:pyindent_open_paren) : parcol)
"endif
"if plnumstart == p
"return parcol
"endif
"return plindent
endif
" Get the line and remove a trailing comment.
" Use syntax highlighting attributes when possible.
let pline = getline(plnum)
let pline_len = strlen(pline)
if has('syntax_items')
" If the last character in the line is a comment, do a binary search for
" the start of the comment. synID() is slow, a linear search would take
" too long on a long line.
if synIDattr(synID(plnum, pline_len, 1), "name") =~ "Comment$"
let min = 1
let max = pline_len
while min < max
let col = (min + max) / 2
if synIDattr(synID(plnum, col, 1), "name") =~ "Comment$"
let max = col
else
let min = col + 1
endif
endwhile
let pline = strpart(pline, 0, min - 1)
endif
else
let col = 0
while col < pline_len
if pline[col] == '#'
let pline = strpart(pline, 0, col)
break
endif
let col = col + 1
endwhile
endif
" If the previous line ended with a colon, indent this line
if pline =~ ':\s*$'
" commented because it might not be a good idea:
" only for new lines
" JMC
"if (getline(a:lnum) =~ '^\s*$')
return plindent + &sw
"endif
endif
" If the previous line was a stop-execution statement...
if getline(plnum) =~ '^\s*\(break\|continue\|raise\|return\|pass\)\>'
" See if the user has already dedented
if indent(a:lnum) > indent(plnum) - &sw
" If not, recommend one dedent
return indent(plnum) - &sw
endif
" Otherwise, trust the user
return -1
endif
" If the current line begins with a keyword that lines up with "try"
if getline(a:lnum) =~ '^\s*\(except\|finally\)\>'
let lnum = a:lnum - 1
while lnum >= 1
if getline(lnum) =~ '^\s*\(try\|except\)\>'
let ind = indent(lnum)
if ind >= indent(a:lnum)
return -1 " indent is already less than this
endif
return ind " line up with previous try or except
endif
let lnum = lnum - 1
endwhile
return -1 " no matching "try"!
endif
" If the current line begins with a header keyword, dedent
if getline(a:lnum) =~ '^\s*\(elif\|else\)\>'
" Unless the previous line was a one-liner
if getline(plnumstart) =~ '^\s*\(for\|if\|try\)\>'
return plindent
endif
" Or the user has already dedented
if indent(a:lnum) <= plindent - &sw
return -1
endif
return plindent - &sw
endif
" JMC
" If the previous line is a continuation
" make the next line line up, but only for new lines
"let curline = getline(a:lnum)
if (g:linecont == 1)
if (getline(a:lnum) =~ '^\s*$')
return plindent
endif
endif
" JMC commented
" When after a () construct we probably want to go back to the start line.
" a = (b
" + c)
" here
"if parlnum > 0
"return plindent
"endif
return -1
endfunction
" vim:sw=2

View File

@@ -1,624 +0,0 @@
if &cp || exists("loaded_jsbeautify")
finish
endif
let loaded_jsbeautify = 3
function! s:trim_output()
while len(s:output) > 0 && (s:output[len(s:output)-1] == " " || s:output[len(s:output)-1] == s:indent_string)
call remove(s:output, -1)
endwhile
endfunction
function! s:print_newline(ignore_repeated)
let s:if_line_flag = 0
call s:trim_output()
if len(s:output)==0
return
endif
if s:output[len(s:output)-1] != "\n" || !a:ignore_repeated
call add(s:output, "\n")
endif
let index = 0
while index < s:indent_level
call add(s:output, s:indent_string)
let index += 1
endwhile
endfunction
function! s:print_space()
let last_output = " "
if len(s:output) > 0
let last_output = s:output[len(s:output) - 1]
endif
if last_output != " " && last_output != "\n" && last_output != s:indent_string
call add(s:output, " ")
endif
endfunction
function! s:print_token()
call add(s:output, s:token_text)
endfunctio
function! s:indent()
let s:indent_level += 1
endfunction
function! s:unindent()
if s:indent_level
let s:indent_level -= 1
endif
endfunction
function! s:remove_indent()
if len(s:output)>0 && s:output[len(s:output) -1] == s:indent_string
call remove(s:output, -1)
endif
endfunction
function! s:set_mode(mode)
call add(s:modes, s:current_mode)
let s:current_mode = a:mode
endfunction
function! s:restore_mode()
if s:current_mode == "DO_BLOCK"
let s:do_block_just_closed = 1
else
let s:do_block_just_closed = 0
endif
let s:current_mode = remove(s:modes, -1)
endfunction
function! s:in_array(what, arr)
return index(a:arr, a:what) != -1
endfunction
function! s:get_next_token()
let n_newlines = 0
if s:parser_pos >= len(s:input)
return ["", "TK_EOF"]
endif
let c = s:input[s:parser_pos]
let s:parser_pos += 1
while s:in_array(c, s:whitespace)
if s:parser_pos >= len(s:input)
return ["", "TK_EOF"]
endif
if c == "\n"
let n_newlines += 1
endif
let c = s:input[s:parser_pos]
let s:parser_pos += 1
endwhile
let wanted_newline = 0
if s:opt_preserve_newlines
if n_newlines > 1
for i in [0, 1]
call s:print_newline(i==0)
endfor
endif
let wanted_newline = n_newlines == 1
endif
if s:in_array(c, s:wordchar)
if s:parser_pos < len(s:input)
while s:in_array(s:input[s:parser_pos], s:wordchar)
let c .= s:input[s:parser_pos]
let s:parser_pos += 1
if s:parser_pos == len(s:input)
break
endif
endwhile
endif
"if s:parser_pos != len(s:input) && c =~ /^[0-9]+[Ee]$/ && (s:input[s:parser_pos] == "-" || s:input[s:parser_pos] == "+")
"let sign = s:input[s:parser_pos]
"let s:parser_pos += 1
"let t = get_next_token(s:parser_pos)
"let c .= sign . t[0]
"return [c, "TK_WORD"]
" endif
if c == "in"
return [c, "TK_OPERATOR"]
endif
if wanted_newline && s:last_type != "TK_OPERATOR" && !s:if_line_flag
call s:print_newline(1)
endif
return [c, "TK_WORD"]
endif
if c == "(" || c == "["
return [c, "TK_START_EXPR"]
endif
if c == ")" || c == "]"
return [c, "TK_END_EXPR"]
endif
if c == "{"
return [c, "TK_START_BLOCK"]
endif
if c == "}"
return [c, "TK_END_BLOCK"]
endif
if c == ";"
return [c, "TK_SEMICOLON"]
endif
if c == "/"
let comment = ""
if s:input[s:parser_pos] == "*"
let s:parser_pos += 1
if s:parser_pos < len(s:input)
while !(s:input[s:parser_pos] == "*" && s:parser_pos + 1 < len(s:input) && s:input[s:parser_pos + 1] == "/" && s:parser_pos < len(s:input))
let comment .= s:input[s:parser_pos]
let s:parser_pos += 1
if s:parser_pos >= len(s:input)
break
endif
endwhile
endif
let s:parser_pos += 2
return ['/*' . comment . '*/', 'TK_BLOCK_COMMENT']
endif
" peek for comment // ...
if s:input[s:parser_pos] == "/"
let comment = c
while s:input[s:parser_pos] != "\r" && s:input[s:parser_pos] != "\n"
let comment .= s:input[s:parser_pos]
let s:parser_pos += 1
if s:parser_pos >= len(s:input)
break
endif
endwhile
let s:parser_pos += 1
if wanted_newline
call s:print_newline(1)
endif
return [comment, "TK_COMMENT"]
endif
endif
if c == "'" || c =='"' || (c == "/" && ((s:last_type == "TK_WORD" && s:last_text == "return") || (s:last_type == "TK_START_EXPR" || s:last_type == "TK_START_BLOCK" || s:last_type == "TK_END_BLOCK" || s:last_type == "TK_OPERATOR" || s:last_type == "TK_EOF" || s:last_type == "TK_SEMICOLON")))
let sep = c
let esc = 0
let resulting_string = c
if s:parser_pos < len(s:input)
while esc || s:input[s:parser_pos] != sep
let resulting_string .= s:input[s:parser_pos]
if !esc
let esc = s:input[s:parser_pos] == "\\"
else
let esc = 0
endif
let s:parser_pos += 1
if s:parser_pos >= len(s:input)
return [resulting_string, "TK_STRING"]
endif
endwhile
endif
let s:parser_pos += 1
let resulting_string .= sep
if sep == "/"
while s:parser_pos < len(s:input) && s:in_array(s:input[s:parser_pos], s:wordchar)
let resulting_string .= s:input[s:parser_pos]
let s:parser_pos += 1
endwhile
endif
return [resulting_string, "TK_STRING"]
endif
if c == "#"
let sharp = "#"
if s:parser_pos < len(s:input) && s:in_array(s:input[s:parser_pos], s:digits)
let c = s:input[s:parser_pos]
let sharp .= c
let s:parser_pos += 1
while s:parser_pos < len(s:input) && c != "#" && c !="="
let c = s:input[s:parser_pos]
let sharp .= c
let s:parser_pos += 1
endwhile
if c == "#"
return [sharp, "TK_WORD"]
else
return [sharp, "TK_OPERATOR"]
endif
endif
endif
if c == "<" && s:input[s:parser_pos-1 : s:parser_pos+3] == "<!--"
let s:parser_pos += 3
return ["<!--", "TK_COMMENT"]
endif
if c == "-" && s:input[s:parser_pos-1 : s:parser_pos+2] == "-->"
let s:parser_pos += 2
if wanted_newline
call s:print_newline(1)
endif
return ["-->", "TK_COMMENT"]
endif
if s:in_array(c, s:punct)
while s:parser_pos < len(s:input) && s:in_array(c . s:input[s:parser_pos], s:punct)
let c .= s:input[s:parser_pos]
let s:parser_pos += 1
if s:parser_pos >= len(s:input)
break
endif
endwhile
return [c, "TK_OPERATOR"]
endif
return [c, "TK_UNKNOWN"]
endif
endfunction
function! s:is_js()
" return expand("%:e") == "js"
return &filetype == "javascript"
endfunction
"function! g:Jsbeautify(js_source_text, options)
function! g:Jsbeautify()
if !s:is_js()
echo "Not a JS file."
return
endif
"let a:options = {}
let s:opt_indent_size = 1
let s:opt_indent_char = "\t"
let s:opt_preserve_newlines = 1
let s:opt_indent_level = 0
let s:if_line_flag = 0
"--------------------------------
let s:indent_string = ""
while s:opt_indent_size > 0
let s:indent_string .= s:opt_indent_char
let s:opt_indent_size -= 1
endwhile
let s:indent_level = s:opt_indent_level
let lines = getline(1, "$")
let s:input = join(lines, "\n")
"let s:input = a:js_source_text
let s:last_word = "" "last 'TK_WORD' passed
let s:last_type = "TK_START_EXPR" "last token type
let s:last_text = "" "last token text
let s:output = []
let s:do_block_just_closed = 0
let s:var_line = 0
let s:var_line_tainted = 0
let s:whitespace = ["\n", "\r", "\t", " "]
let s:wordchar = split("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_$", '\zs')
let s:digits = split("0123456789", '\zs')
"<!-- is a special case (ok, it"s a minor hack actually)
let s:punct = split("+ - * / % & ++ -- = += -= *= /= %= == === != !== > < >= <= >> << >>> >>>= >>= <<= && &= | || ! !! , : ? ^ ^= |= ::", " ")
let s:line_starters = split("continue,try,throw,return,var,if,switch,case,default,for,while,break", ",")
let s:current_mode = "BLOCK"
let s:modes = [s:current_mode]
let s:parser_pos = 0
let s:in_case = 0
while 1
let t = s:get_next_token()
let s:token_text = t[0]
let s:token_type = t[1]
if s:token_type == "TK_EOF"
break
endif
try
if s:token_type == "TK_START_EXPR"
let s:var_line = 0
call s:set_mode("EXPRESSION")
if s:last_text == ";"
call s:print_newline(1)
elseif s:last_type == "TK_END_EXPR" || s:last_type == "TK_START_EXPR"
" do nothing on (( and )( and ][ and ]( ..
elseif s:last_type != "TK_WORD" && s:last_type != "TK_OPERATOR"
call s:print_space()
elseif s:in_array(s:last_word, s:line_starters)
call s:print_space()
endif
call s:print_token()
elseif s:token_type == "TK_END_EXPR"
call s:print_token()
call s:restore_mode()
elseif s:token_type == "TK_START_BLOCK"
if s:last_word == "do"
call s:set_mode("DO_BLOCK")
else
call s:set_mode("BLOCK")
endif
if s:last_type != "TK_OPERATOR" && s:last_type != "TK_START_EXPR"
if s:last_type == "TK_START_BLOCK"
call s:print_newline(1)
else
call s:print_space()
endif
endif
call s:print_token()
call s:indent()
elseif s:token_type == "TK_END_BLOCK"
if s:last_type == "TK_START_BLOCK"
call s:remove_indent()
call s:unindent()
else
call s:unindent()
call s:print_newline(1)
endif
call s:print_token()
call s:restore_mode()
elseif s:token_type == "TK_WORD"
if s:do_block_just_closed
" do {} ## while ()
call s:print_space()
call s:print_token()
call s:print_space()
let s:do_block_just_closed = 0
throw "jump out"
endif
if s:token_text == "case" || s:token_text == "default"
if s:last_text == ":"
"switch cases following one another
call s:remove_indent()
else
" case statement starts in the same line where switch
call s:unindent()
call s:print_newline(1)
call s:indent()
endif
call s:print_token()
let s:in_case = 1
throw "jump out"
endif
let s:prefix = "NONE"
if s:last_type == "TK_END_BLOCK"
if !s:in_array(tolower(s:token_text), ["else", "catch", "finally"])
let s:prefix = "NEWLINE"
else
let s:prefix = "SPACE"
call s:print_space()
endif
elseif s:last_type == "TK_SEMICOLON" && (s:current_mode == "BLOCK" || s:current_mode == "DO_BLOCK")
let s:prefix = "NEWLINE"
elseif s:last_type == "TK_SEMICOLON" && s:current_mode == "EXPRESSION"
let s:prefix = "SPACE"
elseif s:last_type == "TK_STRING"
let s:prefix = "NEWLINE"
elseif s:last_type == "TK_WORD"
let s:prefix = "SPACE"
elseif s:last_type == "TK_START_BLOCK"
let s:prefix = "NEWLINE"
elseif s:last_type == "TK_END_EXPR"
call s:print_space()
let s:prefix = "NEWLINE"
endif
if s:last_type != "TK_END_BLOCK" && s:in_array(tolower(s:token_text), ["else", "catch", "finally"])
call s:print_newline(1)
elseif s:in_array(s:token_text, s:line_starters) || s:prefix == "NEWLINE"
if s:last_text == "else"
call s:print_space()
elseif (s:last_type == "TK_START_EXPR" || s:last_text == "=" || s:last_text == ",") && s:token_text == "function"
" no need to force newline on "function":
" DONOTHINT
elseif s:last_type == "TK_WORD" && (s:last_text == "return" || s:last_text == "throw")
" no newline between "return nnn"
call s:print_space()
elseif s:last_type != "TK_END_EXPR"
if (s:last_type != "TK_START_EXPR" || s:token_text != "var") && s:last_text != ":"
" no need to force newline on "var": for (var
" x = 0...)
if s:token_text == "if" && s:last_type == "TK_WORD" && s:last_word == "else"
" no newline for } else if {
call s:print_space()
else
call s:print_newline(1)
endif
endif
else
if s:in_array(s:token_text, s:line_starters) && s:last_text != ")"
call s:print_newline(1)
endif
endif
elseif s:prefix == "SPACE"
call s:print_space()
endif
call s:print_token()
let s:last_word = s:token_text
if s:token_text == "var"
let s:var_line = 1
let s:var_line_tainted = 0
endif
if s:token_text == "if" || s:token_text == "else"
let s:if_line_flag = 1
endif
elseif s:token_type == "TK_SEMICOLON"
call s:print_token()
let s:var_line = 0
elseif s:token_type == "TK_STRING"
if s:last_type == "TK_START_BLOCK" || s:last_type == "TK_END_BLOCK" || s:last_type == "TK_SEMICOLON"
call s:print_newline(1)
elseif s:last_type == "TK_WORD"
call s:print_space()
endif
call s:print_token()
elseif s:token_type == "TK_OPERATOR"
let start_delim = 1
let end_delim = 1
if s:var_line && s:token_text != ","
let s:var_line_tainted = 1
if s:token_text == ":"
let s:var_line = 0
endif
endif
if s:var_line && s:token_text=="," && s:current_mode == "EXPRESSION"
" do not break on comma, for(var a = 1, b = 2)
let s:var_line_tainted = 0
endif
if s:token_text == ":" && s:in_case
call s:print_token()
call s:print_newline(1)
throw "jump out"
endif
if s:token_text == "::"
" no spaces around exotic namespacing syntax operator
call s:print_token()
throw "jump out"
endif
let s:in_case = 0
if s:token_text == ","
if s:var_line
if s:var_line_tainted
call s:print_token()
call s:print_newline(1)
let s:var_line_tainted = 0
else
call s:print_token()
call s:print_space()
endif
elseif s:last_type == "TK_END_BLOCK"
call s:print_token()
call s:print_newline(1)
else
if s:current_mode == "BLOCK"
call s:print_token()
call s:print_newline(1)
else
" EXPR od DO_BLOCK
call s:print_token()
call s:print_space()
endif
endif
throw "jump out"
elseif s:token_text == "--" || s:token_text == "++" " unary operators special case
if s:last_text == ";"
" space for (;; ++i)
let start_delim = 1
let end_delim = 0
else
let start_delim = 0
let end_delim = 0
endif
elseif s:token_text == "!" && s:last_type == "TK_START_EXPR"
" special case handling: if (!a)
let start_delim = 0
let end_delim = 0
elseif s:last_type == "TK_OPERATOR"
let s:start_delim = 0
let s:end_delim = 0
elseif s:last_type == "TK_END_EXPR"
let s:start_delim = 1
let s:end_delim = 1
elseif s:token_text == "."
" decimal digits or object.property
let start_delim = 0
let end_delim = 0
elseif s:token_text == ":"
" zz: xx
" can"t differentiate ternary op, so for now it"s a ? b:
" c;without space before colon
if s:last_text =~ '/^\d+$/'
" a little help for ternary a ? 1 : 0
let start_delim = 1
else
let start_delim = 0
endif
endif
if start_delim
call s:print_space()
endif
call s:print_token()
if end_delim
call s:print_space()
endif
throw "jump out"
elseif s:token_type == "TK_BLOCK_COMMENT"
call s:print_newline(1)
call s:print_token()
call s:print_newline(1)
elseif s:token_type == "TK_COMMENT"
"call s:print_newline(1)
call s:print_space()
call s:print_token()
call s:print_newline(1)
elseif s:token_type == "TK_UNKNOWN"
call s:print_token()
throw "jump out"
endif
catch /.*/
if v:exception != 'jump out'
echo "exception caught: " v:exception
endif
endtry
let s:last_type = s:token_type
let s:last_text = s:token_text
endwhile
let ret = join(s:output, "")
:g/.*/d
let @0 = ret
:put!0
endfunction
nnoremap <silent> <leader>ff :call g:Jsbeautify()<cr>

View File

@@ -1,161 +0,0 @@
" Description: Vim Kick Assembler omnicompletion file
" Language: Assembler, KickAssembler
" Maintainer: Roman 'gryf' Dobosz <gryf_esm@o2.pl>
" LastChange: 2012-08-02
" Version: 0.1
"
" Changelog:
" 0.0 - initial release
if version < 700
finish
endif
let s:mnemonics = split("adc and asl bcc bcs beq bit bmi bne bpl brk bvc bvs clc cld cli clv cmp cpx cpy dec dex dey eor inc inx iny jmp jsr lda ldx ldy lsr nop ora pha php pla plp rol ror rti rts sbc sec sed sei sta stx sty tax tay tsx txa txs tya")
let s:infos = ["ADC Add Memory to Accumulator with Carry\n\n A + M + C -> A, C N Z C I D V\n + + + - - +\n\n addressing assembler opc bytes cyles\n --------------------------------------------\n immidiate ADC #oper 69 2 2\n zeropage ADC oper 65 2 3\n zeropage,X ADC oper,X 75 2 4\n absolute ADC oper 6D 3 4\n absolute,X ADC oper,X 7D 3 4*\n absolute,Y ADC oper,Y 79 3 4*\n (indirect,X) ADC (oper,X) 61 2 6\n (indirect),Y ADC (oper),Y 71 2 5*\n\n * add 1 to cycles if page boundery is crossed\n\n\n Legend to Flags: + .... modified\n - .... not modified\n",
\"AND AND Memory with Accumulator\n\n A AND M -> A N Z C I D V\n + + - - - -\n\n addressing assembler opc bytes cyles\n --------------------------------------------\n immidiate AND #oper 29 2 2\n zeropage AND oper 25 2 3\n zeropage,X AND oper,X 35 2 4\n absolute AND oper 2D 3 4\n absolute,X AND oper,X 3D 3 4*\n absolute,Y AND oper,Y 39 3 4*\n (indirect,X) AND (oper,X) 21 2 6\n (indirect),Y AND (oper),Y 31 2 5*\n\n * add 1 to cycles if page boundery is crossed\n\n\n Legend to Flags: + .... modified\n - .... not modified\n",
\"ASL Shift Left One Bit (Memory or Accumulator)\n\n C <- [76543210] <- 0 N Z C I D V\n + + + - - -\n\n addressing assembler opc bytes cyles\n --------------------------------------------\n accumulator ASL A 0A 1 2\n zeropage ASL oper 06 2 5\n zeropage,X ASL oper,X 16 2 6\n absolute ASL oper 0E 3 6\n absolute,X ASL oper,X 1E 3 7\n\n\n Legend to Flags: + .... modified\n - .... not modified\n",
\"BCC Branch on Carry Clear\n\n branch on C = 0 N Z C I D V\n - - - - - -\n\n addressing assembler opc bytes cyles\n --------------------------------------------\n relative BCC oper 90 2 2**\n\n ** add 1 to cycles if branch occurs on same page\n add 2 to cycles if branch occurs to different page\n\n\n Legend to Flags: - .... not modified\n",
\"BCS Branch on Carry Set\n\n branch on C = 1 N Z C I D V\n - - - - - -\n\n addressing assembler opc bytes cyles\n --------------------------------------------\n relative BCS oper B0 2 2**\n\n ** add 1 to cycles if branch occurs on same page\n add 2 to cycles if branch occurs to different page\n\n\n Legend to Flags: - .... not modified\n",
\"BEQ Branch on Result Zero\n\n branch on Z = 1 N Z C I D V\n - - - - - -\n\n addressing assembler opc bytes cyles\n --------------------------------------------\n relative BEQ oper F0 2 2**\n\n ** add 1 to cycles if branch occurs on same page\n add 2 to cycles if branch occurs to different page\n\n\n Legend to Flags: - .... not modified\n",
\"BIT Test Bits in Memory with Accumulator\n\n bits 7 and 6 of operand are transfered to bit 7 and 6 of SR (N,V);\n the zeroflag is set to the result of operand AND accumulator.\n\n A AND M, M7 -> N, M6 -> V N Z C I D V\n M7 + - - - M6\n\n addressing assembler opc bytes cyles\n --------------------------------------------\n zeropage BIT oper 24 2 3\n absolute BIT oper 2C 3 4\n\n\n Legend to Flags: + .... modified\n - .... not modified\n M6 .... memory bit 6\n M7 .... memory bit 7\n",
\"BMI Branch on Result Minus\n\n branch on N = 1 N Z C I D V\n - - - - - -\n\n addressing assembler opc bytes cyles\n --------------------------------------------\n relative BMI oper 30 2 2**\n\n ** add 1 to cycles if branch occurs on same page\n add 2 to cycles if branch occurs to different page\n\n\n Legend to Flags: - .... not modified\n",
\"BNE Branch on Result not Zero\n\n branch on Z = 0 N Z C I D V\n - - - - - -\n\n addressing assembler opc bytes cyles\n --------------------------------------------\n relative BNE oper D0 2 2**\n\n ** add 1 to cycles if branch occurs on same page\n add 2 to cycles if branch occurs to different page\n\n\n Legend to Flags: - .... not modified\n",
\"BPL Branch on Result Plus\n\n branch on N = 0 N Z C I D V\n - - - - - -\n\n addressing assembler opc bytes cyles\n --------------------------------------------\n relative BPL oper 10 2 2**\n\n ** add 1 to cycles if branch occurs on same page\n add 2 to cycles if branch occurs to different page\n\n\n Legend to Flags: - .... not modified\n",
\"BRK Force Break\n\n interrupt, N Z C I D V\n push PC+2, push SR - - - 1 - -\n\n addressing assembler opc bytes cyles\n --------------------------------------------\n implied BRK 00 1 7\n\n\n Legend to Flags: - .... not modified\n 1 .... set\n",
\"BVC Branch on Overflow Clear\n\n branch on V = 0 N Z C I D V\n - - - - - -\n\n addressing assembler opc bytes cyles\n --------------------------------------------\n relative BVC oper 50 2 2**\n\n ** add 1 to cycles if branch occurs on same page\n add 2 to cycles if branch occurs to different page\n\n\n Legend to Flags: - .... not modified\n",
\"BVS Branch on Overflow Set\n\n branch on V = 1 N Z C I D V\n - - - - - -\n\n addressing assembler opc bytes cyles\n --------------------------------------------\n relative BVC oper 70 2 2**\n\n ** add 1 to cycles if branch occurs on same page\n add 2 to cycles if branch occurs to different page\n\n\n Legend to Flags: - .... not modified\n",
\"CLC Clear Carry Flag\n\n 0 -> C N Z C I D V\n - - 0 - - -\n\n addressing assembler opc bytes cyles\n --------------------------------------------\n implied CLC 18 1 2\n\n\n Legend to Flags: - .... not modified\n 0 .... cleared\n",
\"CLD Clear Decimal Mode\n\n 0 -> D N Z C I D V\n - - - - 0 -\n\n addressing assembler opc bytes cyles\n --------------------------------------------\n implied CLD D8 1 2\n\n\n Legend to Flags: - .... not modified\n 0 .... cleared\n",
\"CLI Clear Interrupt Disable Bit\n\n 0 -> I N Z C I D V\n - - - 0 - -\n\n addressing assembler opc bytes cyles\n --------------------------------------------\n implied CLI 58 1 2\n\n\n Legend to Flags: - .... not modified\n 0 .... cleared\n",
\"CLV Clear Overflow Flag\n\n 0 -> V N Z C I D V\n - - - - - 0\n\n addressing assembler opc bytes cyles\n --------------------------------------------\n implied CLV B8 1 2\n\n\n Legend to Flags: - .... not modified\n 0 .... cleared\n",
\"CMP Compare Memory with Accumulator\n\n A - M N Z C I D V\n + + + - - -\n\n addressing assembler opc bytes cyles\n --------------------------------------------\n immidiate CMP #oper C9 2 2\n zeropage CMP oper C5 2 3\n zeropage,X CMP oper,X D5 2 4\n absolute CMP oper CD 3 4\n absolute,X CMP oper,X DD 3 4*\n absolute,Y CMP oper,Y D9 3 4*\n (indirect,X) CMP (oper,X) C1 2 6\n (indirect),Y CMP (oper),Y D1 2 5*\n\n * add 1 to cycles if page boundery is crossed\n\n\n Legend to Flags: + .... modified\n - .... not modified\n",
\"CPX Compare Memory and Index X\n\n X - M N Z C I D V\n + + + - - -\n\n addressing assembler opc bytes cyles\n --------------------------------------------\n immidiate CPX #oper E0 2 2\n zeropage CPX oper E4 2 3\n absolute CPX oper EC 3 4\n\n\n Legend to Flags: + .... modified\n - .... not modified\n",
\"CPY Compare Memory and Index Y\n\n Y - M N Z C I D V\n + + + - - -\n\n addressing assembler opc bytes cyles\n --------------------------------------------\n immidiate CPY #oper C0 2 2\n zeropage CPY oper C4 2 3\n absolute CPY oper CC 3 4\n\n\n Legend to Flags: + .... modified\n - .... not modified\n",
\"DEC Decrement Memory by One\n\n M - 1 -> M N Z C I D V\n + + - - - -\n\n addressing assembler opc bytes cyles\n --------------------------------------------\n zeropage DEC oper C6 2 5\n zeropage,X DEC oper,X D6 2 6\n absolute DEC oper CE 3 3\n absolute,X DEC oper,X DE 3 7\n\n\n Legend to Flags: + .... modified\n - .... not modified\n",
\"DEX Decrement Index X by One\n\n X - 1 -> X N Z C I D V\n + + - - - -\n\n addressing assembler opc bytes cyles\n --------------------------------------------\n implied DEC CA 1 2\n\n\n Legend to Flags: + .... modified\n - .... not modified\n",
\"DEY Decrement Index Y by One\n\n Y - 1 -> Y N Z C I D V\n + + - - - -\n\n addressing assembler opc bytes cyles\n --------------------------------------------\n implied DEC 88 1 2\n\n\n Legend to Flags: + .... modified\n - .... not modified\n",
\"EOR Exclusive-OR Memory with Accumulator\n\n A EOR M -> A N Z C I D V\n + + - - - -\n\n addressing assembler opc bytes cyles\n --------------------------------------------\n immidiate EOR #oper 49 2 2\n zeropage EOR oper 45 2 3\n zeropage,X EOR oper,X 55 2 4\n absolute EOR oper 4D 3 4\n absolute,X EOR oper,X 5D 3 4*\n absolute,Y EOR oper,Y 59 3 4*\n (indirect,X) EOR (oper,X) 41 2 6\n (indirect),Y EOR (oper),Y 51 2 5*\n\n * add 1 to cycles if page boundery is crossed\n\n\n Legend to Flags: + .... modified\n - .... not modified\n",
\"INC Increment Memory by One\n\n M + 1 -> M N Z C I D V\n + + - - - -\n\n addressing assembler opc bytes cyles\n --------------------------------------------\n zeropage INC oper E6 2 5\n zeropage,X INC oper,X F6 2 6\n absolute INC oper EE 3 6\n absolute,X INC oper,X FE 3 7\n\n\n Legend to Flags: + .... modified\n - .... not modified\n",
\"INX Increment Index X by One\n\n X + 1 -> X N Z C I D V\n + + - - - -\n\n addressing assembler opc bytes cyles\n --------------------------------------------\n implied INX E8 1 2\n\n\n Legend to Flags: + .... modified\n - .... not modified\n",
\"INY Increment Index Y by One\n\n Y + 1 -> Y N Z C I D V\n + + - - - -\n\n addressing assembler opc bytes cyles\n --------------------------------------------\n implied INY C8 1 2\n\n\n Legend to Flags: + .... modified\n - .... not modified\n",
\"JMP Jump to New Location\n\n (PC+1) -> PCL N Z C I D V\n (PC+2) -> PCH - - - - - -\n\n addressing assembler opc bytes cyles\n --------------------------------------------\n absolute JMP oper 4C 3 3\n indirect JMP (oper) 6C 3 5\n\n\n Legend to Flags: - .... not modified\n",
\"JSR Jump to New Location Saving Return Address\n\n push (PC+2), N Z C I D V\n (PC+1) -> PCL - - - - - -\n (PC+2) -> PCH\n\n addressing assembler opc bytes cyles\n --------------------------------------------\n absolute JSR oper 20 3 6\n\n\n Legend to Flags: - .... not modified\n",
\"LDA Load Accumulator with Memory\n\n M -> A N Z C I D V\n + + - - - -\n\n addressing assembler opc bytes cyles\n --------------------------------------------\n immidiate LDA #oper A9 2 2\n zeropage LDA oper A5 2 3\n zeropage,X LDA oper,X B5 2 4\n absolute LDA oper AD 3 4\n absolute,X LDA oper,X BD 3 4*\n absolute,Y LDA oper,Y B9 3 4*\n (indirect,X) LDA (oper,X) A1 2 6\n (indirect),Y LDA (oper),Y B1 2 5*\n\n * add 1 to cycles if page boundery is crossed\n\n\n Legend to Flags: + .... modified\n - .... not modified\n",
\"LDX Load Index X with Memory\n\n M -> X N Z C I D V\n + + - - - -\n\n addressing assembler opc bytes cyles\n --------------------------------------------\n immidiate LDX #oper A2 2 2\n zeropage LDX oper A6 2 3\n zeropage,Y LDX oper,Y B6 2 4\n absolute LDX oper AE 3 4\n absolute,Y LDX oper,Y BE 3 4*\n\n * add 1 to cycles if page boundery is crossed\n\n\n Legend to Flags: + .... modified\n - .... not modified\n",
\"LDY Load Index Y with Memory\n\n M -> Y N Z C I D V\n + + - - - -\n\n addressing assembler opc bytes cyles\n --------------------------------------------\n immidiate LDY #oper A0 2 2\n zeropage LDY oper A4 2 3\n zeropage,X LDY oper,X B4 2 4\n absolute LDY oper AC 3 4\n absolute,X LDY oper,X BC 3 4*\n\n * add 1 to cycles if page boundery is crossed\n\n\n Legend to Flags: + .... modified\n - .... not modified\n",
\"LSR Shift One Bit Right (Memory or Accumulator)\n\n 0 -> [76543210] -> C N Z C I D V\n - + + - - -\n\n addressing assembler opc bytes cyles\n --------------------------------------------\n accumulator LSR A 4A 1 2\n zeropage LSR oper 46 2 5\n zeropage,X LSR oper,X 56 2 6\n absolute LSR oper 4E 3 6\n absolute,X LSR oper,X 5E 3 7\n\n\n Legend to Flags: + .... modified\n - .... not modified\n",
\"NOP No Operation\n\n --- N Z C I D V\n - - - - - -\n\n addressing assembler opc bytes cyles\n --------------------------------------------\n implied NOP EA 1 2\n\n\n Legend to Flags: - .... not modified\n",
\"ORA OR Memory with Accumulator\n\n A OR M -> A N Z C I D V\n + + - - - -\n\n addressing assembler opc bytes cyles\n --------------------------------------------\n immidiate ORA #oper 09 2 2\n zeropage ORA oper 05 2 3\n zeropage,X ORA oper,X 15 2 4\n absolute ORA oper 0D 3 4\n absolute,X ORA oper,X 1D 3 4*\n absolute,Y ORA oper,Y 19 3 4*\n (indirect,X) ORA (oper,X) 01 2 6\n (indirect),Y ORA (oper),Y 11 2 5*\n\n * add 1 to cycles if page boundery is crossed\n\n\n Legend to Flags: + .... modified\n - .... not modified\n",
\"PHA Push Accumulator on Stack\n\n push A N Z C I D V\n - - - - - -\n\n addressing assembler opc bytes cyles\n --------------------------------------------\n implied PHA 48 1 3\n\n\n Legend to Flags: - .... not modified\n",
\"PHP Push Processor Status on Stack\n\n push SR N Z C I D V\n - - - - - -\n\n addressing assembler opc bytes cyles\n --------------------------------------------\n implied PHP 08 1 3\n\n\n Legend to Flags: - .... not modified\n",
\"PLA Pull Accumulator from Stack\n\n pull A N Z C I D V\n + + - - - -\n\n addressing assembler opc bytes cyles\n --------------------------------------------\n implied PLA 68 1 4\n\n\n Legend to Flags: + .... modified\n - .... not modified\n",
\"PLP Pull Processor Status from Stack\n\n pull SR N Z C I D V\n from stack\n\n addressing assembler opc bytes cyles\n --------------------------------------------\n implied PHP 28 1 4\n\n\n Legend to Flags: + .... modified\n - .... not modified\n 1 .... set\n 0 .... cleared\n M6 .... memory bit 6\n M7 .... memory bit 7\n",
\"ROL Rotate One Bit Left (Memory or Accumulator)\n\n C <- [76543210] <- C N Z C I D V\n + + + - - -\n\n addressing assembler opc bytes cyles\n --------------------------------------------\n accumulator ROL A 2A 1 2\n zeropage ROL oper 26 2 5\n zeropage,X ROL oper,X 36 2 6\n absolute ROL oper 2E 3 6\n absolute,X ROL oper,X 3E 3 7\n\n\n Legend to Flags: + .... modified\n - .... not modified\n",
\"ROR Rotate One Bit Right (Memory or Accumulator)\n\n C -> [76543210] -> C N Z C I D V\n + + + - - -\n\n addressing assembler opc bytes cyles\n --------------------------------------------\n accumulator ROR A 6A 1 2\n zeropage ROR oper 66 2 5\n zeropage,X ROR oper,X 76 2 6\n absolute ROR oper 6E 3 6\n absolute,X ROR oper,X 7E 3 7\n\n\n Legend to Flags: + .... modified\n - .... not modified\n",
\"RTI Return from Interrupt\n\n pull SR, pull PC N Z C I D V\n from stack\n\n addressing assembler opc bytes cyles\n --------------------------------------------\n implied RTI 40 1 6\n\n\n Legend to Flags: + .... modified\n - .... not modified\n 1 .... set\n 0 .... cleared\n M6 .... memory bit 6\n M7 .... memory bit 7\n",
\"RTS Return from Subroutine\n\n pull PC, PC+1 -> PC N Z C I D V\n - - - - - -\n\n addressing assembler opc bytes cyles\n --------------------------------------------\n implied RTS 60 1 6\n\n\n Legend to Flags: - .... not modified\n",
\"SBC Subtract Memory from Accumulator with Borrow\n\n A - M - C -> A N Z C I D V\n + + + - - +\n\n addressing assembler opc bytes cyles\n --------------------------------------------\n immidiate SBC #oper E9 2 2\n zeropage SBC oper E5 2 3\n zeropage,X SBC oper,X F5 2 4\n absolute SBC oper ED 3 4\n absolute,X SBC oper,X FD 3 4*\n absolute,Y SBC oper,Y F9 3 4*\n (indirect,X) SBC (oper,X) E1 2 6\n (indirect),Y SBC (oper),Y F1 2 5*\n\n * add 1 to cycles if page boundery is crossed\n\n\n Legend to Flags: + .... modified\n - .... not modified\n",
\"SEC Set Carry Flag\n\n 1 -> C N Z C I D V\n - - 1 - - -\n\n addressing assembler opc bytes cyles\n --------------------------------------------\n implied SEC 38 1 2\n\n\n Legend to Flags: - .... not modified\n 1 .... set\n",
\"SED Set Decimal Flag\n\n 1 -> D N Z C I D V\n - - - - 1 -\n\n addressing assembler opc bytes cyles\n --------------------------------------------\n implied SED F8 1 2\n\n\n Legend to Flags: - .... not modified\n 1 .... set\n",
\"SEI Set Interrupt Disable Status\n\n 1 -> I N Z C I D V\n - - - 1 - -\n\n addressing assembler opc bytes cyles\n --------------------------------------------\n implied SEI 78 1 2\n\n\n Legend to Flags: - .... not modified\n 1 .... set\n",
\"STA Store Accumulator in Memory\n\n A -> M N Z C I D V\n - - - - - -\n\n addressing assembler opc bytes cyles\n --------------------------------------------\n zeropage STA oper 85 2 3\n zeropage,X STA oper,X 95 2 4\n absolute STA oper 8D 3 4\n absolute,X STA oper,X 9D 3 5\n absolute,Y STA oper,Y 99 3 5\n (indirect,X) STA (oper,X) 81 2 6\n (indirect),Y STA (oper),Y 91 2 6\n\n\n Legend to Flags: - .... not modified\n",
\"STX Store Index X in Memory\n\n X -> M N Z C I D V\n - - - - - -\n\n addressing assembler opc bytes cyles\n --------------------------------------------\n zeropage STX oper 86 2 3\n zeropage,Y STX oper,Y 96 2 4\n absolute STX oper 8E 3 4\n\n\n Legend to Flags: - .... not modified\n",
\"STY Sore Index Y in Memory\n\n Y -> M N Z C I D V\n - - - - - -\n\n addressing assembler opc bytes cyles\n --------------------------------------------\n zeropage STY oper 84 2 3\n zeropage,X STY oper,X 94 2 4\n absolute STY oper 8C 3 4\n\n\n Legend to Flags: - .... not modified\n",
\"TAX Transfer Accumulator to Index X\n\n A -> X N Z C I D V\n + + - - - -\n\n addressing assembler opc bytes cyles\n --------------------------------------------\n implied TAX AA 1 2\n\n\n Legend to Flags: + .... modified\n - .... not modified\n",
\"TAY Transfer Accumulator to Index Y\n\n A -> Y N Z C I D V\n + + - - - -\n\n addressing assembler opc bytes cyles\n --------------------------------------------\n implied TAY A8 1 2\n\n\n Legend to Flags: + .... modified\n - .... not modified\n",
\"TSX Transfer Stack Pointer to Index X\n\n SP -> X N Z C I D V\n + + - - - -\n\n addressing assembler opc bytes cyles\n --------------------------------------------\n implied TSX BA 1 2\n\n\n Legend to Flags: + .... modified\n - .... not modified\n",
\"TXA Transfer Index X to Accumulator\n\n X -> A N Z C I D V\n + + - - - -\n\n addressing assembler opc bytes cyles\n --------------------------------------------\n implied TXA 8A 1 2\n\n\n Legend to Flags: + .... modified\n - .... not modified\nTXS Transfer Index X to Stack Register\n\n X -> SP N Z C I D V\n + + - - - -\n\n addressing assembler opc bytes cyles\n --------------------------------------------\n implied TXS 9A 1 2\n\n\n Legend to Flags: + .... modified\n - .... not modified\n",
\"TYA Transfer Index Y to Accumulator\n\n Y -> A N Z C I D V\n + + - - - -\n\n addressing assembler opc bytes cyles\n --------------------------------------------\n implied TYA 98 1 2\n\n\n Legend to Flags: + .... modified\n - .... not modified\n"]
let s:values = [{"word": "adc", "info": "ADC Add Memory to Accumulator with Carry\n\n A + M + C -> A, C N Z C I D V\n + + + - - +\n\n addressing assembler opc bytes cyles\n --------------------------------------------\n immidiate ADC #oper 69 2 2\n zeropage ADC oper 65 2 3\n zeropage,X ADC oper,X 75 2 4\n absolute ADC oper 6D 3 4\n absolute,X ADC oper,X 7D 3 4*\n absolute,Y ADC oper,Y 79 3 4*\n (indirect,X) ADC (oper,X) 61 2 6\n (indirect),Y ADC (oper),Y 71 2 5*\n\n * add 1 to cycles if page boundery is crossed\n\n\n Legend to Flags: + .... modified\n - .... not modified\n"},
\{"word": "and", "info": "AND AND Memory with Accumulator\n\n A AND M -> A N Z C I D V\n + + - - - -\n\n addressing assembler opc bytes cyles\n --------------------------------------------\n immidiate AND #oper 29 2 2\n zeropage AND oper 25 2 3\n zeropage,X AND oper,X 35 2 4\n absolute AND oper 2D 3 4\n absolute,X AND oper,X 3D 3 4*\n absolute,Y AND oper,Y 39 3 4*\n (indirect,X) AND (oper,X) 21 2 6\n (indirect),Y AND (oper),Y 31 2 5*\n\n * add 1 to cycles if page boundery is crossed\n\n\n Legend to Flags: + .... modified\n - .... not modified\n"},
\{"word": "asl", "info": "ASL Shift Left One Bit (Memory or Accumulator)\n\n C <- [76543210] <- 0 N Z C I D V\n + + + - - -\n\n addressing assembler opc bytes cyles\n --------------------------------------------\n accumulator ASL A 0A 1 2\n zeropage ASL oper 06 2 5\n zeropage,X ASL oper,X 16 2 6\n absolute ASL oper 0E 3 6\n absolute,X ASL oper,X 1E 3 7\n\n\n Legend to Flags: + .... modified\n - .... not modified\n"},
\{"word": "bcc", "info": "BCC Branch on Carry Clear\n\n branch on C = 0 N Z C I D V\n - - - - - -\n\n addressing assembler opc bytes cyles\n --------------------------------------------\n relative BCC oper 90 2 2**\n\n ** add 1 to cycles if branch occurs on same page\n add 2 to cycles if branch occurs to different page\n\n\n Legend to Flags: - .... not modified\n"},
\{"word": "bcs", "info": "BCS Branch on Carry Set\n\n branch on C = 1 N Z C I D V\n - - - - - -\n\n addressing assembler opc bytes cyles\n --------------------------------------------\n relative BCS oper B0 2 2**\n\n ** add 1 to cycles if branch occurs on same page\n add 2 to cycles if branch occurs to different page\n\n\n Legend to Flags: - .... not modified\n"},
\{"word": "beq", "info": "BEQ Branch on Result Zero\n\n branch on Z = 1 N Z C I D V\n - - - - - -\n\n addressing assembler opc bytes cyles\n --------------------------------------------\n relative BEQ oper F0 2 2**\n\n ** add 1 to cycles if branch occurs on same page\n add 2 to cycles if branch occurs to different page\n\n\n Legend to Flags: - .... not modified\n"},
\{"word": "bit", "info": "BIT Test Bits in Memory with Accumulator\n\n bits 7 and 6 of operand are transfered to bit 7 and 6 of SR (N,V);\n the zeroflag is set to the result of operand AND accumulator.\n\n A AND M, M7 -> N, M6 -> V N Z C I D V\n M7 + - - - M6\n\n addressing assembler opc bytes cyles\n --------------------------------------------\n zeropage BIT oper 24 2 3\n absolute BIT oper 2C 3 4\n\n\n Legend to Flags: + .... modified\n - .... not modified\n M6 .... memory bit 6\n M7 .... memory bit 7\n"},
\{"word": "bmi", "info": "BMI Branch on Result Minus\n\n branch on N = 1 N Z C I D V\n - - - - - -\n\n addressing assembler opc bytes cyles\n --------------------------------------------\n relative BMI oper 30 2 2**\n\n ** add 1 to cycles if branch occurs on same page\n add 2 to cycles if branch occurs to different page\n\n\n Legend to Flags: - .... not modified\n"},
\{"word": "bne", "info": "BNE Branch on Result not Zero\n\n branch on Z = 0 N Z C I D V\n - - - - - -\n\n addressing assembler opc bytes cyles\n --------------------------------------------\n relative BNE oper D0 2 2**\n\n ** add 1 to cycles if branch occurs on same page\n add 2 to cycles if branch occurs to different page\n\n\n Legend to Flags: - .... not modified\n"},
\{"word": "bpl", "info": "BPL Branch on Result Plus\n\n branch on N = 0 N Z C I D V\n - - - - - -\n\n addressing assembler opc bytes cyles\n --------------------------------------------\n relative BPL oper 10 2 2**\n\n ** add 1 to cycles if branch occurs on same page\n add 2 to cycles if branch occurs to different page\n\n\n Legend to Flags: - .... not modified\n"},
\{"word": "brk", "info": "BRK Force Break\n\n interrupt, N Z C I D V\n push PC+2, push SR - - - 1 - -\n\n addressing assembler opc bytes cyles\n --------------------------------------------\n implied BRK 00 1 7\n\n\n Legend to Flags: - .... not modified\n 1 .... set\n"},
\{"word": "bvc", "info": "BVC Branch on Overflow Clear\n\n branch on V = 0 N Z C I D V\n - - - - - -\n\n addressing assembler opc bytes cyles\n --------------------------------------------\n relative BVC oper 50 2 2**\n\n ** add 1 to cycles if branch occurs on same page\n add 2 to cycles if branch occurs to different page\n\n\n Legend to Flags: - .... not modified\n"},
\{"word": "bvs", "info": "BVS Branch on Overflow Set\n\n branch on V = 1 N Z C I D V\n - - - - - -\n\n addressing assembler opc bytes cyles\n --------------------------------------------\n relative BVC oper 70 2 2**\n\n ** add 1 to cycles if branch occurs on same page\n add 2 to cycles if branch occurs to different page\n\n\n Legend to Flags: - .... not modified\n"},
\{"word": "clc", "info": "CLC Clear Carry Flag\n\n 0 -> C N Z C I D V\n - - 0 - - -\n\n addressing assembler opc bytes cyles\n --------------------------------------------\n implied CLC 18 1 2\n\n\n Legend to Flags: - .... not modified\n 0 .... cleared\n"},
\{"word": "cld", "info": "CLD Clear Decimal Mode\n\n 0 -> D N Z C I D V\n - - - - 0 -\n\n addressing assembler opc bytes cyles\n --------------------------------------------\n implied CLD D8 1 2\n\n\n Legend to Flags: - .... not modified\n 0 .... cleared\n"},
\{"word": "cli", "info": "CLI Clear Interrupt Disable Bit\n\n 0 -> I N Z C I D V\n - - - 0 - -\n\n addressing assembler opc bytes cyles\n --------------------------------------------\n implied CLI 58 1 2\n\n\n Legend to Flags: - .... not modified\n 0 .... cleared\n"},
\{"word": "clv", "info": "CLV Clear Overflow Flag\n\n 0 -> V N Z C I D V\n - - - - - 0\n\n addressing assembler opc bytes cyles\n --------------------------------------------\n implied CLV B8 1 2\n\n\n Legend to Flags: - .... not modified\n 0 .... cleared\n"},
\{"word": "cmp", "info": "CMP Compare Memory with Accumulator\n\n A - M N Z C I D V\n + + + - - -\n\n addressing assembler opc bytes cyles\n --------------------------------------------\n immidiate CMP #oper C9 2 2\n zeropage CMP oper C5 2 3\n zeropage,X CMP oper,X D5 2 4\n absolute CMP oper CD 3 4\n absolute,X CMP oper,X DD 3 4*\n absolute,Y CMP oper,Y D9 3 4*\n (indirect,X) CMP (oper,X) C1 2 6\n (indirect),Y CMP (oper),Y D1 2 5*\n\n * add 1 to cycles if page boundery is crossed\n\n\n Legend to Flags: + .... modified\n - .... not modified\n"},
\{"word": "cpx", "info": "CPX Compare Memory and Index X\n\n X - M N Z C I D V\n + + + - - -\n\n addressing assembler opc bytes cyles\n --------------------------------------------\n immidiate CPX #oper E0 2 2\n zeropage CPX oper E4 2 3\n absolute CPX oper EC 3 4\n\n\n Legend to Flags: + .... modified\n - .... not modified\n"},
\{"word": "cpy", "info": "CPY Compare Memory and Index Y\n\n Y - M N Z C I D V\n + + + - - -\n\n addressing assembler opc bytes cyles\n --------------------------------------------\n immidiate CPY #oper C0 2 2\n zeropage CPY oper C4 2 3\n absolute CPY oper CC 3 4\n\n\n Legend to Flags: + .... modified\n - .... not modified\n"},
\{"word": "dec", "info": "DEC Decrement Memory by One\n\n M - 1 -> M N Z C I D V\n + + - - - -\n\n addressing assembler opc bytes cyles\n --------------------------------------------\n zeropage DEC oper C6 2 5\n zeropage,X DEC oper,X D6 2 6\n absolute DEC oper CE 3 3\n absolute,X DEC oper,X DE 3 7\n\n\n Legend to Flags: + .... modified\n - .... not modified\n"},
\{"word": "dex", "info": "DEX Decrement Index X by One\n\n X - 1 -> X N Z C I D V\n + + - - - -\n\n addressing assembler opc bytes cyles\n --------------------------------------------\n implied DEC CA 1 2\n\n\n Legend to Flags: + .... modified\n - .... not modified\n"},
\{"word": "dey", "info": "DEY Decrement Index Y by One\n\n Y - 1 -> Y N Z C I D V\n + + - - - -\n\n addressing assembler opc bytes cyles\n --------------------------------------------\n implied DEC 88 1 2\n\n\n Legend to Flags: + .... modified\n - .... not modified\n"},
\{"word": "eor", "info": "EOR Exclusive-OR Memory with Accumulator\n\n A EOR M -> A N Z C I D V\n + + - - - -\n\n addressing assembler opc bytes cyles\n --------------------------------------------\n immidiate EOR #oper 49 2 2\n zeropage EOR oper 45 2 3\n zeropage,X EOR oper,X 55 2 4\n absolute EOR oper 4D 3 4\n absolute,X EOR oper,X 5D 3 4*\n absolute,Y EOR oper,Y 59 3 4*\n (indirect,X) EOR (oper,X) 41 2 6\n (indirect),Y EOR (oper),Y 51 2 5*\n\n * add 1 to cycles if page boundery is crossed\n\n\n Legend to Flags: + .... modified\n - .... not modified\n"},
\{"word": "inc", "info": "INC Increment Memory by One\n\n M + 1 -> M N Z C I D V\n + + - - - -\n\n addressing assembler opc bytes cyles\n --------------------------------------------\n zeropage INC oper E6 2 5\n zeropage,X INC oper,X F6 2 6\n absolute INC oper EE 3 6\n absolute,X INC oper,X FE 3 7\n\n\n Legend to Flags: + .... modified\n - .... not modified\n"},
\{"word": "inx", "info": "INX Increment Index X by One\n\n X + 1 -> X N Z C I D V\n + + - - - -\n\n addressing assembler opc bytes cyles\n --------------------------------------------\n implied INX E8 1 2\n\n\n Legend to Flags: + .... modified\n - .... not modified\n"},
\{"word": "iny", "info": "INY Increment Index Y by One\n\n Y + 1 -> Y N Z C I D V\n + + - - - -\n\n addressing assembler opc bytes cyles\n --------------------------------------------\n implied INY C8 1 2\n\n\n Legend to Flags: + .... modified\n - .... not modified\n"},
\{"word": "jmp", "info": "JMP Jump to New Location\n\n (PC+1) -> PCL N Z C I D V\n (PC+2) -> PCH - - - - - -\n\n addressing assembler opc bytes cyles\n --------------------------------------------\n absolute JMP oper 4C 3 3\n indirect JMP (oper) 6C 3 5\n\n\n Legend to Flags: - .... not modified\n"},
\{"word": "jsr", "info": "JSR Jump to New Location Saving Return Address\n\n push (PC+2), N Z C I D V\n (PC+1) -> PCL - - - - - -\n (PC+2) -> PCH\n\n addressing assembler opc bytes cyles\n --------------------------------------------\n absolute JSR oper 20 3 6\n\n\n Legend to Flags: - .... not modified\n"},
\{"word": "lda", "info": "LDA Load Accumulator with Memory\n\n M -> A N Z C I D V\n + + - - - -\n\n addressing assembler opc bytes cyles\n --------------------------------------------\n immidiate LDA #oper A9 2 2\n zeropage LDA oper A5 2 3\n zeropage,X LDA oper,X B5 2 4\n absolute LDA oper AD 3 4\n absolute,X LDA oper,X BD 3 4*\n absolute,Y LDA oper,Y B9 3 4*\n (indirect,X) LDA (oper,X) A1 2 6\n (indirect),Y LDA (oper),Y B1 2 5*\n\n * add 1 to cycles if page boundery is crossed\n\n\n Legend to Flags: + .... modified\n - .... not modified\n"},
\{"word": "ldx", "info": "LDX Load Index X with Memory\n\n M -> X N Z C I D V\n + + - - - -\n\n addressing assembler opc bytes cyles\n --------------------------------------------\n immidiate LDX #oper A2 2 2\n zeropage LDX oper A6 2 3\n zeropage,Y LDX oper,Y B6 2 4\n absolute LDX oper AE 3 4\n absolute,Y LDX oper,Y BE 3 4*\n\n * add 1 to cycles if page boundery is crossed\n\n\n Legend to Flags: + .... modified\n - .... not modified\n"},
\{"word": "ldy", "info": "LDY Load Index Y with Memory\n\n M -> Y N Z C I D V\n + + - - - -\n\n addressing assembler opc bytes cyles\n --------------------------------------------\n immidiate LDY #oper A0 2 2\n zeropage LDY oper A4 2 3\n zeropage,X LDY oper,X B4 2 4\n absolute LDY oper AC 3 4\n absolute,X LDY oper,X BC 3 4*\n\n * add 1 to cycles if page boundery is crossed\n\n\n Legend to Flags: + .... modified\n - .... not modified\n"},
\{"word": "lsr", "info": "LSR Shift One Bit Right (Memory or Accumulator)\n\n 0 -> [76543210] -> C N Z C I D V\n - + + - - -\n\n addressing assembler opc bytes cyles\n --------------------------------------------\n accumulator LSR A 4A 1 2\n zeropage LSR oper 46 2 5\n zeropage,X LSR oper,X 56 2 6\n absolute LSR oper 4E 3 6\n absolute,X LSR oper,X 5E 3 7\n\n\n Legend to Flags: + .... modified\n - .... not modified\n"},
\{"word": "nop", "info": "NOP No Operation\n\n --- N Z C I D V\n - - - - - -\n\n addressing assembler opc bytes cyles\n --------------------------------------------\n implied NOP EA 1 2\n\n\n Legend to Flags: - .... not modified\n"},
\{"word": "ora", "info": "ORA OR Memory with Accumulator\n\n A OR M -> A N Z C I D V\n + + - - - -\n\n addressing assembler opc bytes cyles\n --------------------------------------------\n immidiate ORA #oper 09 2 2\n zeropage ORA oper 05 2 3\n zeropage,X ORA oper,X 15 2 4\n absolute ORA oper 0D 3 4\n absolute,X ORA oper,X 1D 3 4*\n absolute,Y ORA oper,Y 19 3 4*\n (indirect,X) ORA (oper,X) 01 2 6\n (indirect),Y ORA (oper),Y 11 2 5*\n\n * add 1 to cycles if page boundery is crossed\n\n\n Legend to Flags: + .... modified\n - .... not modified\n"},
\{"word": "pha", "info": "PHA Push Accumulator on Stack\n\n push A N Z C I D V\n - - - - - -\n\n addressing assembler opc bytes cyles\n --------------------------------------------\n implied PHA 48 1 3\n\n\n Legend to Flags: - .... not modified\n"},
\{"word": "php", "info": "PHP Push Processor Status on Stack\n\n push SR N Z C I D V\n - - - - - -\n\n addressing assembler opc bytes cyles\n --------------------------------------------\n implied PHP 08 1 3\n\n\n Legend to Flags: - .... not modified\n"},
\{"word": "pla", "info": "PLA Pull Accumulator from Stack\n\n pull A N Z C I D V\n + + - - - -\n\n addressing assembler opc bytes cyles\n --------------------------------------------\n implied PLA 68 1 4\n\n\n Legend to Flags: + .... modified\n - .... not modified\n"},
\{"word": "plp", "info": "PLP Pull Processor Status from Stack\n\n pull SR N Z C I D V\n from stack\n\n addressing assembler opc bytes cyles\n --------------------------------------------\n implied PHP 28 1 4\n\n\n Legend to Flags: + .... modified\n - .... not modified\n 1 .... set\n 0 .... cleared\n M6 .... memory bit 6\n M7 .... memory bit 7\n"},
\{"word": "rol", "info": "ROL Rotate One Bit Left (Memory or Accumulator)\n\n C <- [76543210] <- C N Z C I D V\n + + + - - -\n\n addressing assembler opc bytes cyles\n --------------------------------------------\n accumulator ROL A 2A 1 2\n zeropage ROL oper 26 2 5\n zeropage,X ROL oper,X 36 2 6\n absolute ROL oper 2E 3 6\n absolute,X ROL oper,X 3E 3 7\n\n\n Legend to Flags: + .... modified\n - .... not modified\n"},
\{"word": "ror", "info": "ROR Rotate One Bit Right (Memory or Accumulator)\n\n C -> [76543210] -> C N Z C I D V\n + + + - - -\n\n addressing assembler opc bytes cyles\n --------------------------------------------\n accumulator ROR A 6A 1 2\n zeropage ROR oper 66 2 5\n zeropage,X ROR oper,X 76 2 6\n absolute ROR oper 6E 3 6\n absolute,X ROR oper,X 7E 3 7\n\n\n Legend to Flags: + .... modified\n - .... not modified\n"},
\{"word": "rti", "info": "RTI Return from Interrupt\n\n pull SR, pull PC N Z C I D V\n from stack\n\n addressing assembler opc bytes cyles\n --------------------------------------------\n implied RTI 40 1 6\n\n\n Legend to Flags: + .... modified\n - .... not modified\n 1 .... set\n 0 .... cleared\n M6 .... memory bit 6\n M7 .... memory bit 7\n"},
\{"word": "rts", "info": "RTS Return from Subroutine\n\n pull PC, PC+1 -> PC N Z C I D V\n - - - - - -\n\n addressing assembler opc bytes cyles\n --------------------------------------------\n implied RTS 60 1 6\n\n\n Legend to Flags: - .... not modified\n"},
\{"word": "sbc", "info": "SBC Subtract Memory from Accumulator with Borrow\n\n A - M - C -> A N Z C I D V\n + + + - - +\n\n addressing assembler opc bytes cyles\n --------------------------------------------\n immidiate SBC #oper E9 2 2\n zeropage SBC oper E5 2 3\n zeropage,X SBC oper,X F5 2 4\n absolute SBC oper ED 3 4\n absolute,X SBC oper,X FD 3 4*\n absolute,Y SBC oper,Y F9 3 4*\n (indirect,X) SBC (oper,X) E1 2 6\n (indirect),Y SBC (oper),Y F1 2 5*\n\n * add 1 to cycles if page boundery is crossed\n\n\n Legend to Flags: + .... modified\n - .... not modified\n"},
\{"word": "sec", "info": "SEC Set Carry Flag\n\n 1 -> C N Z C I D V\n - - 1 - - -\n\n addressing assembler opc bytes cyles\n --------------------------------------------\n implied SEC 38 1 2\n\n\n Legend to Flags: - .... not modified\n 1 .... set\n"},
\{"word": "sed", "info": "SED Set Decimal Flag\n\n 1 -> D N Z C I D V\n - - - - 1 -\n\n addressing assembler opc bytes cyles\n --------------------------------------------\n implied SED F8 1 2\n\n\n Legend to Flags: - .... not modified\n 1 .... set\n"},
\{"word": "sei", "info": "SEI Set Interrupt Disable Status\n\n 1 -> I N Z C I D V\n - - - 1 - -\n\n addressing assembler opc bytes cyles\n --------------------------------------------\n implied SEI 78 1 2\n\n\n Legend to Flags: - .... not modified\n 1 .... set\n"},
\{"word": "sta", "info": "STA Store Accumulator in Memory\n\n A -> M N Z C I D V\n - - - - - -\n\n addressing assembler opc bytes cyles\n --------------------------------------------\n zeropage STA oper 85 2 3\n zeropage,X STA oper,X 95 2 4\n absolute STA oper 8D 3 4\n absolute,X STA oper,X 9D 3 5\n absolute,Y STA oper,Y 99 3 5\n (indirect,X) STA (oper,X) 81 2 6\n (indirect),Y STA (oper),Y 91 2 6\n\n\n Legend to Flags: - .... not modified\n"},
\{"word": "stx", "info": "STX Store Index X in Memory\n\n X -> M N Z C I D V\n - - - - - -\n\n addressing assembler opc bytes cyles\n --------------------------------------------\n zeropage STX oper 86 2 3\n zeropage,Y STX oper,Y 96 2 4\n absolute STX oper 8E 3 4\n\n\n Legend to Flags: - .... not modified\n"},
\{"word": "sty", "info": "STY Sore Index Y in Memory\n\n Y -> M N Z C I D V\n - - - - - -\n\n addressing assembler opc bytes cyles\n --------------------------------------------\n zeropage STY oper 84 2 3\n zeropage,X STY oper,X 94 2 4\n absolute STY oper 8C 3 4\n\n\n Legend to Flags: - .... not modified\n"},
\{"word": "tax", "info": "TAX Transfer Accumulator to Index X\n\n A -> X N Z C I D V\n + + - - - -\n\n addressing assembler opc bytes cyles\n --------------------------------------------\n implied TAX AA 1 2\n\n\n Legend to Flags: + .... modified\n - .... not modified\n"},
\{"word": "tay", "info": "TAY Transfer Accumulator to Index Y\n\n A -> Y N Z C I D V\n + + - - - -\n\n addressing assembler opc bytes cyles\n --------------------------------------------\n implied TAY A8 1 2\n\n\n Legend to Flags: + .... modified\n - .... not modified\n"},
\{"word": "tsx", "info": "TSX Transfer Stack Pointer to Index X\n\n SP -> X N Z C I D V\n + + - - - -\n\n addressing assembler opc bytes cyles\n --------------------------------------------\n implied TSX BA 1 2\n\n\n Legend to Flags: + .... modified\n - .... not modified\n"},
\{"word": "txa", "info": "TXA Transfer Index X to Accumulator\n\n X -> A N Z C I D V\n + + - - - -\n\n addressing assembler opc bytes cyles\n --------------------------------------------\n implied TXA 8A 1 2\n\n\n Legend to Flags: + .... modified\n - .... not modified\nTXS Transfer Index X to Stack Register\n\n X -> SP N Z C I D V\n + + - - - -\n\n addressing assembler opc bytes cyles\n --------------------------------------------\n implied TXS 9A 1 2\n\n\n Legend to Flags: + .... modified\n - .... not modified\n"},
\{"word": "txs", "info": "TSX Transfer Stack Pointer to Index X\n\n SP -> X N Z C I D V\n + + - - - -\n\n addressing assembler opc bytes cyles\n --------------------------------------------\n implied TSX BA 1 2\n\n\n Legend to Flags: + .... modified\n - .... not modified\n"},
\{"word": "tya", "info": "TYA Transfer Index Y to Accumulator\n\n Y -> A N Z C I D V\n + + - - - -\n\n addressing assembler opc bytes cyles\n --------------------------------------------\n implied TYA 98 1 2\n\n\n Legend to Flags: + .... modified\n - .... not modified\n"}]
"let s:values = []
"let s:idx = 0
"while s:idx < len(s:mnemonics)
" let s:tmpdict = {}
" let s:tmpdict["word"] = s:mnemonics[s:idx]
" let s:tmpdict["info"] = s:infos[s:idx]
" call add(s:values, s:tmpdict)
"endwhile
function! kickasscomplete#CompleteKick(findstart, base)
if a:findstart == 1
let line = getline('.')
let start = col('.') - 1
while start > 0 && line[start - 1] =~ '\i\|'''
let start -= 1
endwhile
return start
else
return s:values
" let l:pattern = '^' . a:base . '.*$'
" for l:item in s:values
" if l:item =~? l:pattern
" return l:item
" endif
" endfor
endif
endfunction

View File

@@ -1,318 +0,0 @@
*LanguageTool.txt* A grammar checker in Vim for English, French, German, etc.
*LanguageTool*
Author: Dominique Pellé <dominique.pelle@gmail.com>
Last Change: 08 Feb 2013
For Vim version 7.0 and above
============================================================================
1. Overview |languagetool-overview|
2. Screenshots & Demo |languagetool-screenshots|
3. Download |languagetool-download|
4. Installation |languagetool-installation|
5. Configuration |languagetool-configuration|
6. Features |languagetool-features|
7. Bugs |languagetool-bugs|
8. License |languagetool-license|
============================================================================
1. Overview *languagetool-overview*
This plugin integrates LanguageTool into Vim. LanguageTool is an Open Source
style and grammar checker for English, French, German, etc. See
http://www.languagetool.org/languages/ for a complete list of supported
languages.
LanguageTool detects grammar mistakes that a spelling checker cannot detect
such as "it work" instead of "it works". Since version 1.8, LanguageTool
can also detect spelling mistakes using Hunspell dictionaries bundled with
LanguageTool for several languages or using morfologik for other languages.
Vim builtin spelling checker can also of course be used along with
LanguageTool. One advantage of the spelling checker of LanguageTool over
Vim spelling checker, is that it uses the native Hunspell dictionary directly,
so it works even with the latest Hunspell dictionaries containing features
not supported by Vim. For example, the latest French Hunspell dictionaries
from http://www.dicollect.org are not supported by Vim but they work well
with LanguageTool. On the other hand, the Vim native spelling checker is
faster and better integrated with Vim.
See http://www.languagetool.org/ for more information about LanguageTool.
============================================================================
2. Screenshots & Demo *languagetool-screenshots*
If you don't have time to read help files, these screenshots will give you
an idea of what the LanguageTool plugin does:
http://dominique.pelle.free.fr/pic/LanguageToolVimPlugin_en.png
http://dominique.pelle.free.fr/pic/LanguageToolVimPlugin_fr.png
A screencast demo is also available at:
http://shelr.tv/records/4fba8ef99660803e4f00001f
============================================================================
3. Download *languagetool-download*
You can download the latest version of this plugin from:
http://www.vim.org/scripts/script.php?script_id=3223
LanguageTool can be downloaded from:
http://www.languagetool.org/
============================================================================
4. Installation *languagetool-installation*
4.1 Installing the plugin~
Unzip file LanguageTool.zip plugin from in your personal |vimfiles| directory
(~/.vim under Unix or %HOMEPATH%\vimfiles under Windows): >
$ mkdir ~/.vim
$ cd ~/.vim
$ unzip /path-to/LanguageTool.zip
$ vim -c 'helptags ~/.vim/doc'
The zip file contains the following files: >
plugin/LanguageTool.vim
doc/LanguageTool.vim
You have to enable plugins by adding these two lines in your |.vimrc| file: >
set nocompatible
filetype plugin on
4.2 Installing LanguageTool~
To use this plugin, you need to install the Java LanguageTool program. You
can choose to:
* download stand-alone version of LanguageTool (LanguageTool-*.zip) from:
http://www.languagetool.org/ using the orange button labelled
"Download LanguageTool for stand-alone use". The standalone version of
Vim not only does grammar checking but also contains Hunspell dictionaries
for spell checking.
* or download a nightly build LanguageTool-.*-snapshot.zip from
http://www.languagetool.org/download/snapshots/. It contains a more
recent version than the stable version but it is not as well tested.
* or checkout and build the latest LanguageTool from sources in subversion.
4.2.1 Download the stand-alone version of LanguageTool
Download the stand-alone version of LanguageTool (LanguageTool-*.zip)
from http://www.languagetool.org/ and unzip it: >
$ unzip LanguageTool-2.0.zip
This should extract LanguageTool.jar among several other files.
4.2.2 Build LanguageTool from sources in Subversion~
If you prefer to build LanguageTool yourself from sources, you first need
to install the pre-requisite packages. On Ubuntu, you need to install the
following packages: >
$ sudo apt-get install openjdk-7-jdk mvn subversion
Since version 2.1, LanguageTool is built with Maven. Prior to version 2.1,
it was built with ant.
LanguageTool can then be downloaded and built with Maven as follows: >
$ svn co https://languagetool.svn.sourceforge.net/svnroot/languagetool/trunk/languagetool
$ cd languagetool
$ mvn clean package
After the build, the command line version of LanguageTool can be found in: >
./languagetool-standalone/target/LanguageTool-2.1-SNAPSHOT/LanguageTool-2.1-SNAPSHOT/languagetool-commandline.jar
4.3 Configuring the location of LanguageTool.jar~
After installing LanguageTool, you must specify the location of the file
LanguageTool.jar in your $HOME/.vimrc file. Example: >
let g:languagetool_jar='$HOME/languagetool/languagetool-standalone/target/LanguageTool-2.1-SNAPSHOT/LanguageTool-2.1-SNAPSHOT/languagetool-commandline.jar'
Prior to LanguageTool-2.1, the command line version of LanguageTool
was called LanguageTool.jar.
See section |languagetool-configuration| for more optional settings.
============================================================================
5. Configuration *languagetool-configuration*
LanguageTool plugin uses character encoding from the 'fenc' option or from
the 'enc' option if 'fenc' is empty.
Several global variables can be set in your |vimrc| to configure the behavior
of the LanguageTool plugin.
g:languagetool_jar *g:languagetool_jar*
This variable specifies the location of the LanguageTool java grammar
checker program.
Default is: $HOME/languagetool/dist/LanguageTool.jar
g:languagetool_lang
The language code to use for the language tool checker. If undefined,
plugin tries to guess the language of the Vim spelling checker
'spelllang' or v:lang. If neither works, plugin defaults to
English US (en-US). Starting with LanguageTool-1.8, regional variants
of some languages can be specified. For languages with variants
(currently English and German), it is necessary to specify the
variant in order for LanguageTool to signal spelling errors.
In other words, with :set spelllang=en LanguageTool only
signals grammar mistakes whereas with :set spellllang=en_us
LanguageTool signals spelling mistakes and grammar mistakes.
The valid language codes in LanguageTool-2.1 are: >
ast Asturian
be Belarusian
br Breton
ca Catalan
cs Czech
da Danish
de German
de-AT German (Austria)
de-CH German (Switzerland)
de-DE German (Germany)
el Greek
en English
en-AU English (Australia)
en-CA English (Canada)
en-GB English (Great Britain)
en-NZ English (New Zealand)
en-US English (US)
en-ZA English (South Africa)
eo Esperanto
es Spanish
fr French
gl Galician
is Icelandic
it Italian
km Khmer
lt Lithuanian
ml Malayalam
nl Dutch
pl Polish
pt Portuguese
ro Romanian
ru Russian
sk Slovak
sl Slovenian
sv Swedish
tl Tagalog
uk Ukrainian
zh Chinese
g:languagetool_disable_rules *g:languagetool_disable_rules*
This variable specifies checker rules which are disabled. Each disabled
rule must be comma separated.
Default value set by plugin is: WHITESPACE_RULE,EN_QUOTES
g:languagetool_win_height *g:languagetool_win_height*
This variable specifies the height of the scratch window which contains
all grammatical mistakes with some explanations. You can use a negative
value to disable opening the scratch window. You can also make it empty ''
to let Vim pick a default size.
Default is: 14
You can also customize the following syntax highlighting groups: >
LanguageToolGrammarError
LanguageToolSpellingError
LanguageToolCmd
LanguageToolLabel
LanguageToolErrorCount
============================================================================
6. Features *languagetool-features*
The LanguageTool plugin defines 2 commands |:LanguageToolCheck| and
|:LanguageToolClean|.
:LanguageToolCheck *:LanguageToolCheck*
Use the |:LanguageToolCheck| command to check the grammar in the current
buffer. This will highlight errors in the buffer. It will also open a new
scratch window with the list of grammar mistakes with further explanations
for each error. It also populates the location-list for the window.
The |:LanguageToolCheck| command accepts a range. You can for example check
grammar between lines 100 and 200 in buffer with :100,200LanguageToolCheck,
check grammar in the visual selection with :<',>'LanguageToolCheck, etc.
The default range is 1,$ (whole buffer).
:LanguageToolClear *:LanguageToolClear*
Use the |:LanguageToolClear| command to clear highlighting of grammar
mistakes, close the scratch window containing the list of errors, clear
and close the location-list.
The two commands are also available from the menu in gvim: >
Plugin -> LanguageTool -> Check
-> Clear
Using the error scratch window~
Pressing <Enter> on an error in the error scratch buffer will jump to that
error.
Using the Location-list~
The |location-list| is populated when running |:LanguageToolCheck|. So you can
use location-list Vim commands such as |:lopen| to open the location-list
window, |:lne| to jump to the next error, etc.
The error scratch window may seem redundant with the location-list, but the
scratch window is more flexible to present errors in a nice way. If you do
not wish to popup the error scratch window, but use the location-list only,
you can disable it by setting |g:languagetool_win_height| to a negative value.
============================================================================
7. Bugs *languagetool-bugs*
Column number reported by LanguageTool indicating the location of the error
is sometimes incorrect. There is already an opened ticket about this bug:
http://sourceforge.net/tracker/?func=detail&aid=3054895&group_id=110216&atid=655717
The script currently works around it by doing pattern matching with
information context but it's not a perfect workaround: it can cause
spurious highlighting of errors in rare cases. This bug is fixed in
LanguageTool-1.8.
Please report bugs or suggestions to <dominique.pelle@gmail.com>.
Alternatively, you can also discuss improvements to this plugin in Wiki
by clicking on the "Vim wiki" link at the top of the script page:
http://www.vim.org/scripts/script.php?script_id=3223
============================================================================
8. License *languagetool-license*
The VIM LICENSE applies to the LanguageTool.vim plugin (see |copyright|
except use "LanguageTool.vim" instead of "Vim").
LanguageTool is freely available under LGPL.
============================================================================
vim:tw=78:fo=tcq2:isk=!-~,^*,^\|,^\":ts=8:ft=help:norl:

View File

@@ -1,459 +0,0 @@
" LanguageTool: Grammar checker in Vim for English, French, German, etc.
" Maintainer: Dominique Pellé <dominique.pelle@gmail.com>
" Screenshots: http://dominique.pelle.free.fr/pic/LanguageToolVimPlugin_en.png
" http://dominique.pelle.free.fr/pic/LanguageToolVimPlugin_fr.png
" Last Change: 2013/02/08
" Version: 1.25
"
" Long Description: {{{1
"
" This plugin integrates the LanguageTool grammar checker into Vim.
" Current version of LanguageTool can check grammar in many languages:
" ast, be, br, ca, da, de, el, en, eo, es, fr, gl, is, it, km, lt, ml, nl,
" pl, pt, ro, ru, sk, sl, sv, tl, uk, zh. See http://www.languagetool.org/
" for more information about LanguageTool.
"
" The script defines 2 Ex commands:
"
" * Use :LanguageToolCheck to check grammar in current buffer.
" This will check for grammar mistakes in text of current buffer
" and highlight the errors. It also opens a new scratch window with the
" list of grammar errors with further explanations for each error.
" Pressing <Enter> in scratch buffer will jump to that error. The
" location list for the buffer being checked is also populated.
" So you can use location commands such as :lopen to open the location
" list window, :lne to jump to the next error, etc.
"
" * Use :LanguageToolClear to remove highlighting of grammar mistakes,
" close the scratch window containing the list of errors, clear and
" close the location list.
"
" See screenshots of grammar checking in English and French at:
" http://dominique.pelle.free.fr/pic/LanguageToolVimPlugin_en.png
" http://dominique.pelle.free.fr/pic/LanguageToolVimPlugin_fr.png
"
" See also screencast demo at:
" http://shelr.tv/records/4fba8ef99660803e4f00001f
"
" See :help LanguageTool for more details
"
" Install Details: {{{1
"
" Install the plugin with:
"
" $ mkdir ~/.vim
" $ cd ~/.vim
" $ unzip /path-to/LanguageTool.zip
" $ vim -c 'helptags ~/.vim/doc'
"
" You also need to install the Java LanguageTool program in order to use
" this plugin. There are 3 possibilities:
"
" 1/ Download the stand-alone latest version of LanguageTool file
" (LanguageTool-*.zip) from http://www.languagetool.org/ and
" Unzip it. This should extract LanguageTool.jar among several
" other files.
"
" 2/ Or download an unofficial nightly build available at:
" http://www.languagetool.org/download/snapshots/
"
" 3/ Or download the latest LanguageTool from subversion and build
" it. This ensures that you get the latest version. On Ubuntu, you need
" to install the maven, openjdk-7-jdk and subversion packages as a
" prerequisite:
"
" $ sudo apt-get install openjdk-7-jdk maven subversion
"
" LanguageTool can then be downloaded and built as follows:
"
" $ svn co https://languagetool.svn.sourceforge.net/svnroot/languagetool/trunk/languagetool
" $ cd languagetool
" $ mvn package
"
" This should build the command line version of LanguageTool:
"
" ./languagetool-standalone/target/LanguageTool-2.1-SNAPSHOT/LanguageTool-2.1-SNAPSHOT/languagetool-commandline.jar
"
" You then need to set up g:languagetool_jar in your ~/.vimrc with
" the location of this languagetool-commandline.jar file (or
" LanguageTool.jar prior to version 2.1). For example:
"
" let g:languagetool_jar='$HOME/languagetool/languagetool-standalone/target/LanguageTool-2.1-SNAPSHOT/LanguageTool-2.1-SNAPSHOT/languagetool-commandline.jar'
"
" License: {{{1
"
" The VIM LICENSE applies to LanguageTool.vim plugin
" (see ":help copyright" except use "LanguageTool.vim" instead of "Vim").
"
" Plugin set up {{{1
if &cp || exists("g:loaded_languagetool")
finish
endif
let g:loaded_languagetool = "1"
" Guess language from 'a:lang' (either 'spelllang' or 'v:lang')
function s:FindLanguage(lang) "{{{1
" This replaces things like en_gb en-GB as expected by LanguageTool,
" only for languages that support variants in LanguageTool.
let l:language = substitute(substitute(a:lang,
\ '\(\a\{2,3}\)\(_\a\a\)\?.*',
\ '\=tolower(submatch(1)) . toupper(submatch(2))', ''),
\ '_', '-', '')
" All supported languages (with variants) from version LanguageTool-1.8.
let l:supportedLanguages = {
\ 'ast' : 1,
\ 'be' : 1,
\ 'br' : 1,
\ 'ca' : 1,
\ 'cs' : 1,
\ 'da' : 1,
\ 'de' : 1,
\ 'de-AT' : 1,
\ 'de-CH' : 1,
\ 'de-DE' : 1,
\ 'el' : 1,
\ 'en' : 1,
\ 'en-AU' : 1,
\ 'en-CA' : 1,
\ 'en-GB' : 1,
\ 'en-NZ' : 1,
\ 'en-US' : 1,
\ 'en-ZA' : 1,
\ 'eo' : 1,
\ 'es' : 1,
\ 'fr' : 1,
\ 'gl' : 1,
\ 'is' : 1,
\ 'it' : 1,
\ 'km' : 1,
\ 'lt' : 1,
\ 'ml' : 1,
\ 'nl' : 1,
\ 'pl' : 1,
\ 'pt' : 1,
\ 'ro' : 1,
\ 'ru' : 1,
\ 'sk' : 1,
\ 'sl' : 1,
\ 'sv' : 1,
\ 'tl' : 1,
\ 'uk' : 1,
\ 'zh' : 1
\}
if has_key(l:supportedLanguages, l:language)
return l:language
endif
" Removing the region (if any) and trying again.
let l:language = substitute(l:language, '-.*', '', '')
return has_key(l:supportedLanguages, l:language) ? l:language : ''
endfunction
" Return a regular expression used to highlight a grammatical error
" at line a:line in text. The error starts at character a:start in
" context a:context and its length in context is a:len.
function s:LanguageToolHighlightRegex(line, context, start, len) "{{{1
let l:start_idx = byteidx(a:context, a:start)
let l:end_idx = byteidx(a:context, a:start + a:len) - 1
let l:start_ctx_idx = byteidx(a:context, a:start + a:len)
let l:end_ctx_idx = byteidx(a:context, a:start + a:len + 5) - 1
" The substitute allows to match errors which span multiple lines.
" The part after \ze gives a bit of context to avoid spurious
" highlighting when the text of the error is present multiple
" times in the line.
return '\V'
\ . '\%' . a:line . 'l'
\ . substitute(escape(a:context[l:start_idx : l:end_idx], "'\\"), ' ', '\\_\\s', 'g')
\ . '\ze'
\ . substitute(escape(a:context[l:start_ctx_idx : l:end_ctx_idx], "'\\"), ' ', '\\_\\s', 'g')
endfunction
" Unescape XML special characters in a:text.
function s:XmlUnescape(text) "{{{1
" Change XML escape char such as &quot; into "
" Substitution of &amp; must be done last or else something
" like &amp;quot; would get first transformed into &quot;
" and then wrongly transformed into " (correct is &quot;)
let l:escaped = substitute(a:text, '&quot;', '"', 'g')
let l:escaped = substitute(l:escaped, '&apos;', "'", 'g')
let l:escaped = substitute(l:escaped, '&gt;', '>', 'g')
let l:escaped = substitute(l:escaped, '&lt;', '<', 'g')
return substitute(l:escaped, '&amp;', '\&', 'g')
endfunction
" Parse a xml attribute such as: ruleId="FOO" in line a:line.
" where ruleId is the key a:key, and FOO is the returned value corresponding
" to that key.
function s:ParseKeyValue(key, line) "{{{1
return s:XmlUnescape(matchstr(a:line, '\<' . a:key . '="\zs[^"]*\ze"'))
endfunction
" Set up configuration.
" Returns 0 if success, < 0 in case of error.
function s:LanguageToolSetUp() "{{{1
let s:languagetool_disable_rules = exists("g:languagetool_disable_rules")
\ ? g:languagetool_disable_rules
\ : 'WHITESPACE_RULE,EN_QUOTES'
let s:languagetool_win_height = exists("g:languagetool_win_height")
\ ? g:languagetool_win_height
\ : 14
let s:languagetool_encoding = &fenc ? &fenc : &enc
" Setting up language...
if exists("g:languagetool_lang")
let s:languagetool_lang = g:languagetool_lang
else
" Trying to guess language from 'spelllang' or 'v:lang'.
let s:languagetool_lang = s:FindLanguage(&spelllang)
if s:languagetool_lang == ''
let s:languagetool_lang = s:FindLanguage(v:lang)
if s:languagetool_lang == ''
echoerr 'Failed to guess language from spelllang=['
\ . &spelllang . '] or from v:lang=[' . v:lang . ']. '
\ . 'Defauling to English (en-US). '
\ . 'See ":help LanguageTool" regarding setting g:languagetool_lang.'
let s:languagetool_lang = 'en-US'
endif
endif
endif
let s:languagetool_jar = exists("g:languagetool_jar")
\ ? g:languagetool_jar
\ : $HOME . '/languagetool/dist/LanguageTool.jar'
if !filereadable(s:languagetool_jar)
" Hmmm, can't find the jar file. Try again with expand() in case user
" set it up as: let g:languagetool_jar = '$HOME/LanguageTool.jar'
let l:languagetool_jar = expand(s:languagetool_jar)
if !filereadable(expand(l:languagetool_jar))
echomsg "LanguageTool cannot be found at: " . s:languagetool_jar
echomsg "You need to install LanguageTool and/or set up g:languagetool_jar"
return -1
endif
let s:languagetool_jar = l:languagetool_jar
endif
return 0
endfunction
" Jump to a grammar mistake (called when pressing <Enter>
" on a particular error in scratch buffer).
function <sid>JumpToCurrentError() "{{{1
let l:save_cursor = getpos('.')
norm! $
if search('^Error:\s\+', 'beW') > 0
let l:error_idx = expand('<cword>')
let l:error = s:errors[l:error_idx - 1]
let l:line = l:error['fromy']
let l:col = l:error['fromx']
let l:rule = l:error['ruleId']
call setpos('.', l:save_cursor)
exe s:languagetool_text_win . 'wincmd w'
exe 'norm! ' . l:line . 'G0'
" Finding the column is done using pattern matching with information
" in error context.
let l:context = l:error['replacements'][byteidx(l:error['replacements'], l:error['context'])
\ :byteidx(l:error['replacements'], l:error['context'] + l:error['contextoffset']) - 1]
let l:re = s:LanguageToolHighlightRegex(l:error['fromy'], l:error['replacements'],
\ l:error['context'], l:error['contextoffset'])
echon 'Jump to error ' . l:error_idx . '/' . len(s:errors)
\ . ' (' . l:rule . ') ...' . l:context . '... @ '
\ . l:line . 'L ' . l:col . 'C'
call search(l:re)
norm! zz
else
call setpos('.', l:save_cursor)
endif
endfunction
" This function performs grammar checking of text in the current buffer.
" It highlights grammar mistakes in current buffer and opens a scratch
" window with all errors found. It also populates the location-list of
" the window with all errors.
" a:line1 and a:line2 parameters are the first and last line number of
" the range of line to check.
" Returns 0 if success, < 0 in case of error.
function s:LanguageToolCheck(line1, line2) "{{{1
let l:save_cursor = getpos('.')
if s:LanguageToolSetUp() < 0
return -1
endif
call s:LanguageToolClear()
sil %y
botright new
let s:languagetool_error_buffer = bufnr('%')
let s:languagetool_error_win = winnr()
sil put!
" LanguageTool somehow gives incorrect line/column numbers when
" reading from stdin so we need to use a temporary file to get
" correct results.
let l:tmpfilename = tempname()
let l:range = a:line1 . ',' . a:line2
silent exe l:range . 'w!' . l:tmpfilename
let l:languagetool_cmd = 'java'
\ . ' -jar ' . s:languagetool_jar
\ . ' -c ' . s:languagetool_encoding
\ . ' -d ' . s:languagetool_disable_rules
\ . ' -l ' . s:languagetool_lang
\ . ' --api ' . l:tmpfilename
sil exe '%!' . l:languagetool_cmd
call delete(l:tmpfilename)
if v:shell_error
echoerr 'Command [' . l:languagetool_cmd . '] failed with error: '
\ . v:shell_error
call s:LanguageToolClear()
return -1
endif
" Loop on all errors in XML output of LanguageTool and
" collect information about all errors in list s:errors
let s:errors = []
while search('^<error ', 'eW') > 0
let l:l = getline('.')
" The fromx and tox given by LanguageTool are not reliable.
" They are even sometimes negative!
let l:error= {}
for l:k in [ 'fromy', 'fromx', 'tox', 'toy',
\ 'ruleId', 'subId', 'msg', 'replacements',
\ 'context', 'contextoffset', 'errorlength', 'url' ]
let l:error[l:k] = s:ParseKeyValue(l:k, l:l)
endfor
" Make line/column number start at 1 rather than 0.
" Make also line number absolute as in buffer.
let l:error['fromy'] += a:line1
let l:error['fromx'] += 1
let l:error['toy'] += a:line1
let l:error['tox'] += 1
call add(s:errors, l:error)
endwhile
if s:languagetool_win_height >= 0
" Reformat the output of LanguageTool (XML is not human friendly) and
" set up syntax highlighting in the buffer which shows all errors.
sil %d
call append(0, '# ' . l:languagetool_cmd)
set bt=nofile
setlocal nospell
syn clear
syn match LanguageToolCmd '\%1l.*'
syn match LanguageToolLabel '^\(Pos\|Rule\|Context\|Message\|Correction\):'
syn match LanguageToolLabelMoreInfo '^More info:.*' contains=LanguageToolUrl
syn match LanguageToolErrorCount '^Error:\s\+\d\+.\d\+'
syn match LanguageToolUrl '^More info:\s*\zs.*' contained
let l:i = 0
for l:error in s:errors
call append('$', 'Error: '
\ . (l:i + 1) . '/' . len(s:errors)
\ . ' (' . l:error['ruleId'] . ':' . l:error['subId'] . ')'
\ . ' @ ' . l:error['fromy'] . 'L ' . l:error['fromx'] . 'C')
call append('$', 'Message: ' . l:error['msg'])
call append('$', 'Context: ' . l:error['context'])
if l:error['ruleId'] =~ 'HUNSPELL_RULE\|HUNSPELL_NO_SUGGEST_RULE\|MORFOLOGIK_RULE_.*\|GERMAN_SPELLER_RULE'
exe "syn match LanguageToolSpellingError '"
\ . '\%' . line('$') . 'l\%9c'
\ . '.\{' . (4 + l:error['contextoffset']) . '}\zs'
\ . '.\{' . (l:error['errorlength']) . "}'"
else
exe "syn match LanguageToolGrammarError '"
\ . '\%' . line('$') . 'l\%9c'
\ . '.\{' . (4 + l:error['contextoffset']) . '}\zs'
\ . '.\{' . (l:error['errorlength']) . "}'"
endif
if !empty(l:error['replacements'])
call append('$', 'Correction: ' . l:error['replacements'])
endif
if !empty(l:error['url'])
call append('$', 'More info: ' . l:error['url'])
endif
call append('$', '')
let l:i += 1
endfor
exe "norm! z" . s:languagetool_win_height . "\<CR>"
0
map <silent> <buffer> <CR> :call <sid>JumpToCurrentError()<CR>
redraw
echon 'Press <Enter> on error in scratch buffer to jump its location'
exe "norm! \<C-W>\<C-P>"
else
" Negative s:languagetool_win_height -> no scratch window.
bd!
unlet! s:languagetool_error_buffer
endif
let s:languagetool_text_win = winnr()
" Also highlight errors in original buffer and populate location list.
setlocal errorformat=%f:%l:%c:%m
for l:error in s:errors
let l:re = s:LanguageToolHighlightRegex(l:error['fromy'],
\ l:error['context'],
\ l:error['contextoffset'],
\ l:error['errorlength'])
if l:error['ruleId'] =~ 'HUNSPELL_RULE\|HUNSPELL_NO_SUGGEST_RULE\|MORFOLOGIK_RULE_.*\|GERMAN_SPELLER_RULE'
exe "syn match LanguageToolSpellingError '" . l:re . "'"
laddexpr expand('%') . ':'
\ . l:error['fromy'] . ':' . l:error['fromx'] . ':'
\ . l:error['ruleId'] . ' ' . l:error['msg']
else
exe "syn match LanguageToolGrammarError '" . l:re . "'"
laddexpr expand('%') . ':'
\ . l:error['fromy'] . ':' . l:error['fromx'] . ':'
\ . l:error['ruleId'] . ' ' . l:error['msg']
endif
endfor
return 0
endfunction
" This function clears syntax highlighting created by LanguageTool plugin
" and removes the scratch window containing grammar errors.
function s:LanguageToolClear() "{{{1
if exists('s:languagetool_error_buffer')
if bufexists(s:languagetool_error_buffer)
sil! exe "bd! " . s:languagetool_error_buffer
endif
endif
if exists('s:languagetool_text_win')
let l:win = winnr()
exe s:languagetool_text_win . 'wincmd w'
syn clear LanguageToolGrammarError
syn clear LanguageToolSpellingError
lexpr ''
lclose
exe l:win . 'wincmd w'
endif
unlet! s:languagetool_error_buffer
unlet! s:languagetool_error_win
unlet! s:languagetool_text_win
endfunction
hi def link LanguageToolCmd Comment
hi def link LanguageToolLabel Label
hi def link LanguageToolLabelMoreInfo Label
hi def link LanguageToolGrammarError Error
hi def link LanguageToolSpellingError WarningMsg
hi def link LanguageToolErrorCount Title
hi def link LanguageToolUrl Underlined
" Section: Menu items {{{1
if has("gui_running") && has("menu") && &go =~ 'm'
amenu <silent> &Plugin.LanguageTool.Chec&k :LanguageToolCheck<CR>
amenu <silent> &Plugin.LanguageTool.Clea&r :LanguageToolClear<CR>
endif
" Defines commands {{{1
com! -nargs=0 LanguageToolClear :call s:LanguageToolClear()
com! -nargs=0 -range=% LanguageToolCheck :call s:LanguageToolCheck(<line1>,
\ <line2>)
" vim: fdm=marker

View File

@@ -1,127 +0,0 @@
Lorem ipsum dolor sit amet...
Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis splople autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi.
Nam liber tempor cum soluta nobis eleifend option congue nihil imperdiet doming id quod mazim placerat facer possim assum. Typi non habent claritatem insitam; est usus legentis in iis qui facit eorum claritatem. Investigationes demonstraverunt lectores legere me lius quod ii legunt saepius. Claritas est etiam processus dynamicus, qui sequitur mutationem consuetudium lectorum. Mirum est notare quam littera gothica, quam nunc putamus parum claram, anteposuerit litterarum formas humanitatis per seacula quarta decima et quinta decima. Eodem modo typi, qui nunc nobis videntur parum clari, fiant sollemnes in futurum.
Nunc varius risus quis nulla. Vivamus vel magna. Ut rutrum. Aenean dignissim, leo quis faucibus semper, massa est faucibus massa, sit amet pharetra arcu nunc et sem. Aliquam tempor. Nam lobortis sem non urna. Pellentesque et urna sit amet leo accumsan volutpat. Nam molestie lobortis lorem. Quisque eu nulla. Donec id orci in ligula dapibus egestas. Donec sed velit ac lectus mattis sagittis.
In hac habitasse platea dictumst. Maecenas in ligula. Duis tincidunt odio sollicitudin quam. Nullam non mauris. Phasellus lacinia, velit sit amet bibendum euismod, leo diam interdum ligula, eu scelerisque sem purus in tellus.
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. In sit amet nunc id quam porta varius. Ut aliquet facilisis turpis. Etiam pellentesque quam et erat. Praesent suscipit justo.
Cras nec metus pulvinar sem tempor hendrerit. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Nullam in nulla. Mauris elementum. Curabitur tempor, quam ac rutrum placerat, nunc augue ullamcorper est, vitae molestie neque nunc a nunc. Integer justo dolor, consequat id, rutrum auctor, ullamcorper sed, orci. In hac habitasse platea dictumst. Fusce euismod semper orci. Integer venenatis quam non nunc. Vivamus in lorem a nisi aliquet commodo. Suspendisse massa lorem, dignissim at, vehicula et, ornare non, libero. Donec molestie, velit quis dictum scelerisque, est lectus hendrerit lorem, eget dignissim orci nisl sit amet massa. Etiam volutpat lobortis eros. Nunc ac tellus in sapien molestie rhoncus. Pellentesque nisl. Praesent venenatis blandit velit. Fusce rutrum. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Pellentesque vitae erat. Vivamus porttitor cursus lacus. Pellentesque tellus. Nunc aliquam interdum felis. Nulla imperdiet leo. Mauris hendrerit, sem at mollis pharetra, leo sapien pretium elit, a faucibus sapien dolor vel pede. Vestibulum et enim ut nulla sollicitudin adipiscing. Suspendisse malesuada venenatis mauris. Curabitur ornare mollis velit. Sed vitae metus. Morbi posuere mi id odio. Donec elit sem, tempor at, pharetra eu, sodales sit amet, elit.
Curabitur urna tellus, aliquam vitae, ultrices eget, vehicula nec, diam. Integer elementum, felis non faucibus euismod, erat massa dictum eros, eu ornare ligula tortor et mauris. Cras molestie magna in nibh. Aenean et tellus. Fusce adipiscing commodo erat. In eu justo. Nulla dictum, erat sed blandit venenatis, arcu dolor molestie dolor, vitae congue orci risus a nulla. Pellentesque sit amet arcu. In mattis laoreet enim. Pellentesque id augue et arcu blandit tincidunt. Pellentesque elit ante, rhoncus quis, dapibus sit amet, tincidunt eu, nibh. In imperdiet. Nunc lectus neque, commodo eget, porttitor quis, fringilla quis, purus.
Duis sagittis dignissim eros. In sit amet lectus. Fusce lacinia mauris vitae nisl interdum condimentum. Etiam in magna ac nibh ultrices vehicula. Maecenas commodo facilisis lectus. Praesent sed mi. Phasellus ipsum. Donec quis tellus id lectus faucibus molestie. Praesent vel ligula. Nam venenatis neque quis mauris. Proin felis. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Aliquam quam. Nam felis velit, semper nec, aliquam nec, iaculis vel, mi. Nullam et augue vitae nunc tristique vehicula. Suspendisse eget elit. Duis adipiscing dui non quam.
Duis posuere tortor sit amet est iaculis egestas. Ut at magna. Etiam dui nisi, blandit quis, fermentum vitae, auctor vel, sem. Cras et leo. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Proin luctus, odio eu porttitor adipiscing, ante elit tristique tortor, sit amet malesuada tortor nisi sit amet neque. Praesent rhoncus eros non velit. Pellentesque mattis. Sed sit amet ante. Mauris ac nibh eget risus volutpat tempor. Praesent volutpat sollicitudin dui. Sed in tellus id urna viverra commodo. Vestibulum enim felis, interdum non, sollicitudin in, posuere a, sem. Cras nibh.
Sed facilisis ultrices dolor. Vestibulum pretium mauris sed turpis. Phasellus a pede id odio interdum elementum. Nam urna felis, sodales ut, luctus vel, condimentum vitae, est. Vestibulum ut augue. Nunc laoreet sapien quis neque semper dictum. Phasellus rhoncus est id turpis. Vestibulum in elit at odio pellentesque volutpat. Nam nec tortor. Suspendisse porttitor consequat nulla. Morbi suscipit tincidunt nisi. Sed laoreet, mauris et tincidunt facilisis, est nisi pellentesque ligula, sit amet convallis neque dolor at sapien. Aenean viverra justo ac sem.
Pellentesque at dolor non lectus sagittis semper. Donec quis mi. Duis eget pede. Phasellus arcu tellus, ultricies id, consequat id, lobortis nec, diam. Suspendisse sed nunc. Pellentesque id magna. Morbi interdum quam at est. Maecenas eleifend mi in urna. Praesent et lectus ac nibh luctus viverra. In vel dolor sed nibh sollicitudin tincidunt. Ut consequat nisi sit amet nibh. Nunc mi tortor, tristique sit amet, rhoncus porta, malesuada elementum, nisi. Integer vitae enim quis risus aliquet gravida. Curabitur vel lorem vel erat dapibus lobortis. Donec dignissim tellus at arcu. Quisque molestie pulvinar sem.
Nulla magna neque, ullamcorper tempus, luctus eget, malesuada ut, velit. Morbi felis. Praesent in purus at ipsum cursus posuere. Morbi bibendum facilisis eros. Phasellus aliquam sapien in erat. Praesent venenatis diam dignissim dui. Praesent risus erat, iaculis ac, dapibus sed, imperdiet ac, erat. Nullam sed ipsum. Phasellus non dolor. Donec ut elit.
Sed risus.
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Vestibulum sem lacus, commodo vitae, aliquam ut, posuere eget, dui. Praesent massa dui, mattis et, vehicula auctor, iaculis id, diam. Morbi viverra neque sit amet risus. Nunc pellentesque aliquam orci. Proin neque elit, mollis vel, tristique nec, varius consectetuer, lorem. Nam malesuada ornare nunc. Duis turpis turpis, fermentum a, aliquet quis, sodales at, dolor. Duis eget velit eget risus fringilla hendrerit. Nulla facilisi. Mauris turpis pede, aliquet ac, mattis sed, consequat in, massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Etiam egestas posuere metus. Aliquam erat volutpat. Donec non tortor. Vivamus posuere nisi mollis dolor. Quisque porttitor nisi ac elit. Nullam tincidunt ligula vitae nulla.
Vivamus sit amet risus et ipsum viverra malesuada. Duis luctus. Curabitur adipiscing metus et felis. Vestibulum tortor. Pellentesque purus. Donec pharetra, massa quis malesuada auctor, tortor ipsum lobortis ipsum, eget facilisis ante nisi eget lectus. Sed a est. Aliquam nec felis eu sem euismod viverra. Suspendisse felis mi, dictum id, convallis ac, mattis non, nibh. Donec sagittis quam eu mauris. Phasellus et leo at quam dapibus pellentesque. In non lacus. Nullam tristique nunc ut arcu scelerisque aliquam. Nullam viverra magna vitae leo. Vestibulum in lacus sit amet lectus tempus aliquet. Duis cursus nisl ac orci. Donec non nisl. Mauris lacus sapien, congue a, facilisis at, egestas vel, quam. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae.
Phasellus ipsum odio, suscipit nec, fringilla at, vehicula quis, tellus. Phasellus gravida condimentum dui. Aenean imperdiet arcu vitae ipsum. Duis dapibus, nisi non porttitor iaculis, ligula odio sollicitudin mauris, non luctus nunc massa a velit. Fusce ac nisi. Integer volutpat elementum metus. Vivamus luctus ultricies diam. Curabitur euismod. Vivamus quam. Nunc ante. Nulla mi nulla, vehicula nec, ultrices a, tincidunt vel, enim.
Suspendisse potenti. Aenean sed velit. Nunc a urna quis turpis imperdiet sollicitudin. Mauris aliquam mauris ut tortor. Pellentesque tincidunt mattis nibh. In id lectus eu magna vulputate ultrices. Aliquam interdum varius enim. Maecenas at mauris. Sed sed nibh. Nam non turpis. Maecenas fermentum nibh in est. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.
Duis sagittis fermentum nunc. Nullam elementum erat. Quisque dapibus, augue nec dapibus bibendum, velit enim scelerisque sem, accumsan suscipit lectus odio ac justo. Fusce in felis a enim rhoncus placerat. Cras nec eros et mi egestas facilisis. In hendrerit tincidunt neque. Maecenas tellus. Fusce sollicitudin molestie dui. Sed magna orci, accumsan nec, viverra non, pharetra id, dui.
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Nullam placerat mi vitae felis. In porta, quam sit amet sodales elementum, elit dolor aliquam elit, a commodo nisi felis nec nibh. Nulla facilisi. Etiam at tortor. Vivamus quis sapien nec magna scelerisque lobortis.
Curabitur tincidunt viverra justo. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Sed eros ante, mattis ullamcorper, posuere quis, tempor vel, metus. Maecenas cursus cursus lacus. Sed risus magna, aliquam sed, suscipit sit amet, porttitor quis, odio. Suspendisse cursus justo nec urna. Suspendisse potenti. In hac habitasse platea dictumst. Cras quis lacus. Vestibulum rhoncus congue lacus. Vivamus euismod, felis quis commodo viverra, dolor elit dictum ante, et mollis eros augue at est. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Nulla lectus sem, tristique sed, semper in, hendrerit non, sem. Vivamus dignissim massa in ipsum. Morbi fringilla ullamcorper ligula. Nunc turpis. Mauris vitae sapien. Nunc luctus bibendum velit.
Morbi faucibus volutpat sapien. Nam ac mauris at justo adipiscing facilisis. Nunc et velit. Donec auctor, nulla id laoreet volutpat, pede erat feugiat ante, auctor facilisis dui augue non turpis. Suspendisse mattis metus et justo. Aliquam erat volutpat. Suspendisse potenti. Nam hendrerit lorem commodo metus laoreet ullamcorper. Proin vel nunc a felis sollicitudin pretium. Maecenas in metus at mi mollis posuere. Quisque ac quam sed massa adipiscing rutrum. Vestibulum ipsum. Phasellus porta sapien. Maecenas venenatis tellus vel tellus.
Aliquam aliquam dolor at justo. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Morbi pretium purus a magna. Nullam dui tellus, blandit eu, facilisis non, pharetra consectetuer, leo. Maecenas sit amet ante sagittis magna imperdiet pulvinar. Vestibulum a lacus at sapien suscipit tempus. Proin pulvinar velit sed nulla. Curabitur aliquet leo ac massa. Praesent posuere lectus vitae odio. Donec imperdiet urna vel ante. In semper accumsan diam. Vestibulum porta justo. Suspendisse egestas commodo eros.
Suspendisse tincidunt mi vel metus. Vivamus non urna in nisi gravida congue. Aenean semper orci a eros. Praesent dictum. Maecenas pharetra odio ut dui. Pellentesque ut orci. Sed lobortis, velit at laoreet suscipit, quam est sagittis nibh, id varius ipsum quam ac metus. Phasellus est nibh, bibendum non, dictum sed, vehicula in, sem. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Mauris sollicitudin. Duis congue tincidunt orci. Integer blandit neque ut quam. Morbi mollis. Integer lacinia. Praesent blandit elementum sapien. Praesent enim mauris, suscipit a, auctor et, lacinia vitae, nunc. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Praesent lacus diam, auctor quis, venenatis in, hendrerit at, est. Vivamus eget eros. Phasellus congue, sapien ac iaculis feugiat, lacus lacus accumsan lorem, quis volutpat justo turpis ac mauris.
Duis velit magna, scelerisque vitae, varius ut, aliquam vel, justo. Proin ac augue. Nullam auctor lectus vitae arcu. Vestibulum porta justo placerat purus. Ut sem nunc, vestibulum nec, sodales vitae, vehicula eget, ipsum. Sed nec tortor. Aenean malesuada. Nunc convallis, massa eu vestibulum commodo, quam mauris interdum arcu, at pellentesque diam metus ut nulla. Vestibulum eu dolor sit amet lacus varius fermentum. Morbi dolor enim, pulvinar eget, lobortis ac, fringilla ac, turpis. Duis ac erat. Etiam consequat. Integer sed est eu elit pellentesque dapibus. Duis venenatis magna feugiat nisi. Vestibulum et turpis. Maecenas a enim. Suspendisse ultricies ornare justo. Fusce sit amet nisi sed arcu condimentum venenatis. Vivamus dui. Nunc accumsan, quam a fermentum mattis, magna sapien iaculis pede, at porttitor quam odio at est.
Proin eleifend nisi et nibh. Maecenas a lacus. Mauris porta quam non massa molestie scelerisque. Nulla sed ante at lorem suscipit rutrum. Nam quis tellus. Cras elit nisi, ornare a, condimentum vitae, rutrum sit amet, tellus. Maecenas a dolor. Praesent tempor, felis eget gravida blandit, urna lacus faucibus velit, in consectetuer sapien erat nec quam. Integer bibendum odio sit amet neque. Integer imperdiet rhoncus mi. Pellentesque malesuada purus id purus. Quisque viverra porta lectus. Sed lacus leo, feugiat at, consectetuer eu, luctus quis, risus. Suspendisse faucibus orci et nunc. Nullam vehicula fermentum risus. Fusce felis nibh, dignissim vulputate, ultrices quis, lobortis et, arcu. Duis aliquam libero non diam.
Vestibulum placerat tincidunt tortor. Ut vehicula ligula quis lectus. In eget velit. Quisque vel risus. Mauris pede. Nullam ornare sapien sit amet nisl. Cras tortor. Donec tortor lorem, dignissim sit amet, pulvinar eget, mattis eu, metus. Cras vestibulum erat ultrices neque. Praesent rhoncus, dui blandit pellentesque congue, mauris mi ullamcorper odio, eget ultricies nunc felis in augue. Nullam porta nunc. Donec in pede ac mauris mattis eleifend. Cras a libero vel est lacinia dictum. In hac habitasse platea dictumst. Nullam malesuada molestie lorem. Nunc non mauris. Nam accumsan tortor gravida elit. Cras porttitor.
Praesent vel enim sed eros luctus imperdiet. Mauris neque ante, placerat at, mollis vitae, faucibus quis, leo. Ut feugiat. Vivamus urna quam, congue vulputate, convallis non, cursus cursus, risus. Quisque aliquet. Donec vulputate egestas elit. Morbi dictum, sem sit amet aliquam euismod, odio tortor pellentesque odio, ac ultrices enim nibh sed quam. Integer tortor velit, condimentum a, vestibulum eget, sagittis nec, neque. Aenean est urna, bibendum et, imperdiet at, rhoncus in, arcu. In hac habitasse platea dictumst. Vestibulum blandit dignissim dui. Maecenas vitae magna non felis ornare consectetuer. Sed lorem. Nam leo. In eget pede. Donec porta.
Etiam facilisis. Nam suscipit. Ut consectetuer leo vehicula augue. Aliquam cursus. Integer pharetra rhoncus massa. Cras et ligula vel quam tristique commodo. Sed est lectus, mollis quis, lacinia id, sollicitudin nec, eros. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Morbi urna dui, fermentum quis, feugiat imperdiet, imperdiet id, sapien. Phasellus auctor nunc. Vivamus eget augue quis neque vestibulum placerat. Duis placerat. Maecenas accumsan rutrum lacus. Vestibulum lacinia semper nibh. Aenean diam odio, scelerisque at, ullamcorper nec, tincidunt dapibus, quam. Duis vel ante nec tortor porta mollis. Praesent orci. Cras dignissim vulputate metus.
Phasellus eu quam. Quisque interdum cursus purus. In orci. Maecenas vehicula. Sed et mauris. Praesent feugiat viverra lacus. Suspendisse pulvinar lacus ut nunc. Quisque nisi. Suspendisse id risus nec nisi ultrices ornare. Donec eget tellus. Nullam molestie placerat felis. Aenean facilisis. Nunc erat. Integer in tellus. Mauris volutpat, neque vel ornare porttitor, dolor nisi sagittis dolor, sit amet bibendum orci leo blandit lacus.
In id velit sodales arcu iaculis venenatis. Etiam at leo. Vivamus vitae sem. Mauris volutpat congue risus. Curabitur leo. Aenean tempor tortor eget ligula. Aenean vel augue. Vestibulum ac justo. In hac habitasse platea dictumst. Nam dignissim nisi non mauris. Donec et tortor. Morbi felis. Donec aliquet, erat eu ultrices tincidunt, lorem mi sagittis lectus, ut feugiat pede lacus quis sapien. Suspendisse porta, felis a fermentum interdum, dui nisl sodales felis, ut fermentum sapien nibh eu nunc.
Lorem ipsum dolor sit amet. Integer sed magna. Duis nisl nulla, porta ut, molestie sit amet, tincidunt eu, enim. Cras eu mauris. Cras iaculis, nisi vel tempor fringilla, nisl dolor imperdiet dolor, id lobortis ligula nunc sed dolor.
Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Curabitur eu dui vitae nulla tempor consectetuer. Suspendisse ligula dolor, varius nec, vulputate id, luctus sed, lacus. Pellentesque purus urna, porta molestie, mattis non, posuere et, velit. Curabitur diam mauris, dictum vel, lacinia congue, molestie at, nisi. Proin tempus diam ut ligula. Mauris dictum, metus dapibus iaculis sollicitudin, leo ligula cursus sem, eu congue metus ligula sed justo. Suspendisse potenti. Donec sodales elementum turpis. Duis dolor elit, dapibus sed, placerat vitae, auctor sit amet, nunc. Donec nisl quam, hendrerit vitae, porttitor et, imperdiet id, quam. Quisque dolor. Nulla tincidunt, lacus id dapibus ullamcorper, turpis diam fringilla eros, quis aliquet dolor felis at lorem. Pellentesque et lacus. Vestibulum tempor lectus at est. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Sed vitae eros. Nulla pulvinar turpis eget nunc. Sed bibendum pellentesque nunc. Integer tristique, lorem ac faucibus tempor, lorem dolor mollis turpis, a consectetuer nunc justo ac nisl.
Nam vitae purus. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Praesent semper magna. In eu justo. Nunc vitae risus nec sem scelerisque consequat. In hac habitasse platea dictumst. Nam posuere ultricies turpis. Pellentesque a pede. Duis sed tortor. Phasellus egestas porta lectus. Aliquam dignissim consequat diam. Pellentesque pede.
Ut varius tincidunt tellus. Curabitur ornare ipsum. Aenean laoreet posuere orci. Etiam id nisl. Suspendisse volutpat elit molestie orci. Suspendisse vel augue at felis tincidunt sollicitudin. Fusce arcu. Duis a tortor. Duis et odio et leo sollicitudin consequat. Aliquam lobortis. Phasellus condimentum. Ut porttitor bibendum libero. Integer euismod lacinia velit. Donec velit justo, sodales varius, cursus sed, mattis a, arcu.
Maecenas accumsan, sem iaculis egestas gravida, odio nunc aliquet dui, eget cursus diam purus vel augue. Donec eros nisi, imperdiet quis, volutpat ac, sollicitudin sed, arcu. Aenean vel mauris. Mauris tincidunt. Nullam euismod odio at velit. Praesent elit purus, porttitor id, facilisis in, consequat ut, libero. Morbi imperdiet, magna quis ullamcorper malesuada, mi massa pharetra lectus, a pellentesque urna urna id turpis. Nam posuere lectus vitae nibh. Etiam tortor orci, sagittis malesuada, rhoncus quis, hendrerit eget, libero. Quisque commodo nulla at nunc. Mauris consequat, enim vitae venenatis sollicitudin, dolor orci bibendum enim, a sagittis nulla nunc quis elit. Phasellus augue. Nunc suscipit, magna tincidunt lacinia faucibus, lacus tellus ornare purus, a pulvinar lacus orci eget nibh. Maecenas sed nibh non lacus tempor faucibus. In hac habitasse platea dictumst. Vivamus a orci at nulla tristique condimentum. Donec arcu quam, dictum accumsan, convallis accumsan, cursus sit amet, ipsum. In pharetra sagittis nunc.
Donec consequat mi. Quisque vitae dolor. Integer lobortis. Maecenas id nulla. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Sed volutpat felis vitae dui. Vestibulum et est ac ligula dapibus elementum. Nunc suscipit nisl eu felis. Duis nec tortor. Nullam diam libero, semper id, consequat in, consectetuer ut, metus. Phasellus dui purus, vehicula sed, venenatis a, rutrum at, nunc. Pellentesque interdum sapien nec neque.
Vivamus sagittis, sem sit amet porttitor lobortis, turpis sapien consequat orci, sed commodo nulla pede eget sem. Phasellus sollicitudin. Proin orci erat, blandit ut, molestie sed, fringilla non, odio. Nulla porta, tortor non suscipit gravida, velit enim aliquam quam, nec condimentum orci augue vel magna. Nulla facilisi. Donec ipsum enim, congue in, tempus id, pulvinar sagittis, leo. Donec et elit in nunc blandit auctor. Nulla congue urna quis lorem. Nam rhoncus pede sed nunc. Etiam vitae quam. Fusce feugiat pede vel quam. In et augue.
Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
Phasellus mollis dictum nulla. Integer vitae neque vitae eros fringilla rutrum. Vestibulum in pede adipiscing mi dapibus condimentum. Etiam felis risus, condimentum in, malesuada eget, pretium ut, sapien. Suspendisse placerat lectus venenatis lorem. Sed accumsan aliquam enim. Etiam hendrerit, metus eu semper rutrum, nisl elit pharetra purus, non interdum nibh enim eget augue. Sed mauris. Nam varius odio a sapien. Aenean rutrum dictum sapien. Fusce pharetra elementum ligula. Nunc eu mi non augue iaculis facilisis. Morbi interdum. Donec nisi arcu, rhoncus ac, vestibulum ut, pellentesque nec, risus. Maecenas tempus facilisis neque. Nulla mattis odio vitae tortor. Fusce iaculis. Aliquam rhoncus, diam quis tincidunt facilisis, sem quam luctus augue, ut posuere neque sem vitae neque.
Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Nunc faucibus posuere turpis. Sed laoreet, est sed gravida tempor, nibh enim fringilla quam, et dapibus mi enim sit amet risus. Nulla sollicitudin eros sit amet diam. Aliquam ante. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Ut et est. Donec semper nulla in ipsum. Integer elit. In pharetra lorem vel ante.
Sed sed justo. Curabitur consectetuer arcu. Etiam placerat est eget odio. Nulla facilisi. Nulla facilisi. Mauris non neque. Suspendisse et diam. Sed vestibulum malesuada ipsum. Cras id magna. Nunc pharetra velit vitae eros. Vivamus ac risus. Mauris ac pede laoreet felis pharetra ultricies. Proin et neque. Aliquam dignissim placerat felis. Mauris porta ante sagittis purus.
Pellentesque quis leo eget ante tempor cursus. Pellentesque sagittis, diam ut dictum accumsan, magna est viverra erat, vitae imperdiet neque mauris aliquam nisl. Suspendisse blandit quam quis felis. Praesent turpis nunc, vehicula in, bibendum vitae, blandit ac, turpis. Duis rhoncus. Vestibulum metus. Morbi consectetuer felis id tortor. Etiam augue leo, cursus eget, ornare et, ornare sagittis, tellus. Fusce felis tellus, consectetuer nec, consequat at, ornare non, arcu. Maecenas condimentum sodales odio. Sed eu orci.
Nullam adipiscing eros sit amet ante. Vestibulum ante. Sed quis ipsum non ligula dignissim luctus. Integer quis justo id tortor accumsan tempus. Cras vitae magna. Nunc bibendum lacinia tellus. Quisque porttitor ligula et pede. Nam erat nibh, fringilla ac, rutrum sit amet, rhoncus in, ipsum. Mauris rhoncus, lacus eu convallis sagittis, quam magna placerat est, vitae imperdiet mauris arcu ac dui. In ac urna non justo posuere mattis. Suspendisse egestas bibendum nulla. In erat nunc, posuere sed, auctor quis, pulvinar quis, mi. Mauris at est. Phasellus lacinia eros in arcu. Maecenas lobortis, tellus vel gravida tincidunt, elit erat suscipit arcu, in varius erat risus vel magna. Fusce nec ante quis dolor vestibulum bibendum. Pellentesque sit amet urna.
Curabitur eget nisi at lectus placerat gravida. Vivamus nulla. Donec luctus. Sed quis tellus. Quisque lobortis faucibus mi. Aenean vitae risus ut arcu malesuada ornare. Maecenas nec erat. Sed rhoncus, elit laoreet sagittis luctus, nulla leo faucibus lectus, vitae accumsan est diam id felis. Nunc dui pede, vestibulum eu, elementum et, gravida quis, sapien. Donec blandit. Donec sed magna. Curabitur a risus. Nullam nibh libero, sagittis vel, hendrerit accumsan, pulvinar consequat, tellus. Donec varius dictum nisl. Vestibulum suscipit enim ac nulla. Proin tincidunt. Proin sagittis. Curabitur auctor metus non mauris. Nunc condimentum nisl non augue. Donec leo urna, dignissim vitae, porttitor ut, iaculis sit amet, sem.
Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Suspendisse potenti. Quisque augue metus, hendrerit sit amet, commodo vel, scelerisque ut, ante. Praesent euismod euismod risus. Mauris ut metus sit amet mi cursus commodo. Morbi congue mauris ac sapien. Donec justo. Sed congue nunc vel mauris. Pellentesque vehicula orci id libero. In hac habitasse platea dictumst. Nulla sollicitudin, purus id elementum dictum, dolor augue hendrerit ante, vel semper metus enim et dolor. Pellentesque molestie nunc id enim. Etiam mollis tempus neque. Duis tincidunt commodo elit.
Aenean pellentesque purus eu mi. Proin commodo, massa commodo dapibus elementum, libero lacus pulvinar eros, ut tincidunt nisl elit ut velit. Cras rutrum porta purus. Vivamus lorem. Sed turpis enim, faucibus quis, pharetra in, sagittis sed, magna. Curabitur ultricies felis ut libero. Nullam tincidunt enim eu nibh. Nunc eget ipsum in sem facilisis convallis. Proin fermentum risus. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Vestibulum hendrerit malesuada odio. Fusce ut elit ut augue sollicitudin blandit. Phasellus volutpat lorem. Duis non pede et neque luctus tincidunt. Duis interdum tempus elit.
Aenean metus. Vestibulum ac lacus. Vivamus porttitor, massa ut hendrerit bibendum, metus augue aliquet turpis, vitae pellentesque velit est vitae metus. Duis eros enim, fermentum at, sagittis id, lacinia eget, tellus. Nunc consequat pede et nulla. Donec nibh. Pellentesque cursus orci vitae urna. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Pellentesque risus turpis, aliquet ac, accumsan vel, iaculis eget, enim. Pellentesque nibh neque, malesuada id, tempor vel, aliquet ut, eros. In hac habitasse platea dictumst. Integer neque purus, congue sed, mattis sed, vulputate ac, pede. Donec vestibulum purus non tortor. Integer at nunc.
Suspendisse fermentum velit quis sem. Phasellus suscipit nunc in risus. Nulla sed lectus. Morbi sollicitudin, diam ac bibendum scelerisque, enim tortor rhoncus sapien, vel posuere dolor neque in sem. Pellentesque tellus augue, tempus nec, laoreet at, porttitor blandit, leo. Phasellus in odio. Duis lobortis, metus eu laoreet tristique, pede mi congue mi, quis posuere augue nulla a augue. Pellentesque sed est. Mauris cursus urna id lectus. Integer dignissim feugiat eros. Sed tempor volutpat dolor. Vestibulum vel lectus nec mauris semper adipiscing.
Aliquam tincidunt enim sit amet tellus. Sed mauris nulla, semper tincidunt, luctus a, sodales eget, leo. Sed ligula augue, cursus et, posuere non, mollis sit amet, est. Mauris massa. Proin hendrerit massa. Phasellus eu purus. Donec est neque, dignissim a, eleifend vitae, lobortis ut, nibh. Nullam sed lorem. Proin laoreet augue quis eros. Suspendisse vehicula nunc ac nisi.
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Fusce mi. Vivamus enim velit, condimentum sit amet, laoreet quis, fermentum non, ipsum. Etiam quis felis. Curabitur tincidunt, sapien et luctus faucibus, nibh nisi commodo arcu, vitae cursus neque ante sed elit. Sed sit amet erat. Phasellus luctus cursus risus. Phasellus ac felis. Proin nec eros quis ipsum pellentesque congue. Curabitur et diam sed odio accumsan cursus. Pellentesque ultricies. Quisque aliquam. Sed nisi velit, consectetuer eget, dictum ac, molestie a, magna. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Curabitur consequat leo et dui. Aenean ligula mi, dignissim ut, imperdiet tristique, interdum a, dolor.
Vestibulum elit nibh, rhoncus non, euismod sit amet, pretium eu, enim. Nunc commodo ultricies dui. Cras gravida rutrum massa. Donec accumsan mattis turpis. Quisque sem. Quisque elementum sapien iaculis augue. In dui sem, congue sit amet, feugiat quis, lobortis at, eros.
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Proin interdum vehicula purus. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.
Aenean risus dui, volutpat non, posuere vitae, sollicitudin in, urna. Nam eget eros a enim pulvinar rhoncus. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Nulla facilisis massa ut massa. Sed nisi purus, malesuada eu, porta vulputate, suscipit auctor, nunc. Vestibulum convallis, augue eu luctus malesuada, mi ante mattis odio, ac venenatis neque sem vitae nisi. Donec pellentesque purus a lorem. Etiam in massa. Nam ut metus. In rhoncus venenatis tellus. Etiam aliquam. Ut aliquam lectus ut lectus. Nam turpis lacus, tristique sit amet, convallis sollicitudin, commodo a, purus. Nulla vitae eros a diam blandit mollis. Proin luctus feugiat eros. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Duis ultricies urna. Etiam enim urna, pharetra suscipit, varius et, congue quis, odio. Donec lobortis, elit bibendum euismod faucibus, velit nibh egestas libero, vitae pellentesque elit augue ut massa.
Nulla consequat erat at massa. Vivamus id mi. Morbi purus enim, dapibus a, facilisis non, tincidunt at, enim. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Duis imperdiet eleifend arcu. Cras magna ligula, consequat at, tempor non, posuere nec, libero. Vestibulum vel ipsum. Praesent congue justo et nunc. Vestibulum nec felis vitae nisl pharetra sollicitudin. Quisque nec arcu vel tellus tristique vestibulum. Aenean vel lacus. Mauris dolor erat, commodo ut, dapibus vehicula, lobortis sit amet, orci. Aliquam augue. In semper nisi nec libero. Cras magna ipsum, scelerisque et, tempor eget, gravida nec, lacus. Fusce eros nisi, ullamcorper blandit, ultricies eget, elementum eget, pede. Phasellus id risus vitae nisl ullamcorper congue. Proin est.
Sed eleifend odio sed leo. Mauris tortor turpis, dignissim vel, ornare ac, ultricies quis, magna. Phasellus lacinia, augue ac dictum tempor, nisi felis ornare magna, eu vehicula tellus enim eu neque. Fusce est eros, sagittis eget, interdum a, ornare suscipit, massa. Sed vehicula elementum ligula. Aliquam erat volutpat. Donec odio. Quisque nunc. Integer cursus feugiat magna. Fusce ac elit ut elit aliquam suscipit. Duis leo est, interdum nec, varius in, facilisis vitae, odio. Phasellus eget leo at urna adipiscing vulputate. Nam eu erat vel arcu tristique mattis. Nullam placerat lorem non augue. Cras et velit. Morbi sapien nulla, volutpat a, tristique eu, molestie ac, felis.
Suspendisse sit amet tellus non odio porta pellentesque. Nulla facilisi. Integer iaculis condimentum augue. Nullam urna nulla, vestibulum quis, lacinia eget, ullamcorper eu, dui. Quisque dignissim consequat nisl. Pellentesque porta augue in diam. Duis mattis. Aliquam et mi quis turpis pellentesque consequat. Suspendisse nulla erat, lacinia nec, pretium vitae, feugiat ac, quam. Etiam sed tellus vel est ultrices condimentum. Vestibulum euismod. Vivamus blandit. Pellentesque eu urna. Vestibulum consequat sem vitae dui. In dictum feugiat quam. Phasellus placerat. In sem nisl, elementum vitae, venenatis nec, lacinia ac, arcu. Pellentesque gravida egestas mi. Integer rutrum tincidunt libero.
Duis viverra. Nulla diam lectus, tincidunt et, scelerisque vitae, aliquam vitae, justo. Quisque eget erat. Donec aliquet porta magna. Sed nisl. Ut tellus. Suspendisse quis mi eget dolor sagittis tristique. Aenean non pede eget nisl bibendum gravida. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Morbi laoreet. Suspendisse potenti. Donec accumsan porta felis.
Fusce tristique leo quis pede. Cras nibh. Sed eget est vitae tortor mollis ullamcorper. Suspendisse placerat dolor a dui. Vestibulum condimentum dui et elit. Pellentesque porttitor ipsum at ipsum. Nam massa. Duis lorem. Donec porta. Proin ligula. Aenean nunc massa, dapibus quis, imperdiet id, commodo a, lacus. Cras sit amet erat et nulla varius aliquet. Aliquam erat volutpat. Praesent feugiat vehicula pede. Suspendisse pulvinar, orci in sollicitudin venenatis, nibh libero hendrerit sem, eu tempor nisi felis et metus. Etiam gravida sem ut mi. Integer volutpat, enim eu varius gravida, risus urna venenatis lectus, ac ultrices quam nulla eu leo. Duis arcu. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos.
Vivamus lacus libero, aliquam eget, iaculis quis, tristique adipiscing, diam. Vivamus nec massa non justo iaculis pellentesque. Aenean accumsan elit sit amet nibh feugiat semper. Cras tempor ornare purus. Integer id nisi. Phasellus dui velit, ultrices vel, ullamcorper mattis, hendrerit in, erat. Aenean vel quam at eros mattis commodo. Aenean feugiat iaculis justo. Maecenas accumsan justo ut nibh. Donec ac lectus vitae odio lobortis tristique. Donec vestibulum mattis lectus. Donec et lorem.
Cras sit amet mauris. Curabitur a quam. Aliquam neque. Nam nunc nunc, lacinia sed, varius quis, iaculis eget, ante. Nulla dictum justo eu lacus. Phasellus sit amet quam. Nullam sodales. Cras non magna eu est consectetuer faucibus. Donec tempor lobortis turpis. Sed tellus velit, ullamcorper ac, fringilla vitae, sodales nec, purus. Morbi aliquet risus in mi.
Curabitur cursus volutpat neque. Proin posuere mauris ut ipsum. Praesent scelerisque tortor a justo. Quisque consequat libero eu erat. In eros augue, sollicitudin sed, tempus tincidunt, pulvinar a, lectus. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Maecenas interdum purus id risus. Ut ultricies cursus dui. In nec enim at odio aliquam iaculis. Fusce nisl. Pellentesque sagittis. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean placerat tellus. In semper sagittis enim. Aliquam risus neque, pretium in, fermentum vitae, vulputate et, massa. Nulla sed erat vel eros ornare venenatis.
In hac habitasse platea dictumst. Sed nisl nunc, suscipit id, feugiat vel, tristique sit amet, sapien. Phasellus vestibulum. Nam quis justo. Nulla sit amet mauris sed lacus pharetra fringilla. In mollis orci ultrices.
Lorem ipsum dolor sit amet.

View File

@@ -1,157 +0,0 @@
" loremipsum.vim
" @Author: Thomas Link (mailto:micathom AT gmail com?subject=[vim])
" @Website: http://www.vim.org/account/profile.php?user_id=4037
" @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
" @Created: 2008-07-10.
" @Last Change: 2008-07-11.
" @Revision: 0.0.138
if &cp || exists("loaded_loremipsum_autoload")
finish
endif
let loaded_loremipsum_autoload = 1
let s:save_cpo = &cpo
set cpo&vim
" http://www.lorem-ipsum-dolor-sit-amet.com/lorem-ipsum-dolor-sit-amet.html
let s:data = expand('<sfile>:p:h') .'/loremipsum.txt'
function! s:GetWords(nwords, splitrx, join) "{{{3
if exists('b:loremipsum_file')
let file = b:loremipsum_file
else
let file = get(g:loremipsum_files, &spelllang, s:data)
endif
let text = split(join(readfile(file), "\n"), a:splitrx)
let start = (localtime() * -23) % (len(text) - a:nwords)
let start = start < 0 ? -start : start
let out = join(text[start : start + a:nwords], a:join)
let out = substitute(out, '^\s*\zs\S', '\u&', '')
if out !~ '\.\s*$'
let out = substitute(out, '[[:punct:][:space:]]*$', '.', '')
endif
return out
endf
function! s:NoInline(flags) "{{{3
return get(a:flags, 0, 0)
endf
function! s:WrapMarker(marker, text) "{{{3
if len(a:marker) >= 2
let [pre, post; flags] = a:marker
if type(a:text) == 1
if s:NoInline(flags)
return a:text
else
return pre . a:text . post
endif
else
call insert(a:text, pre)
call add(a:text, post)
return a:text
endif
else
return a:text
endif
endf
function! loremipsum#Generate(nwords, template) "{{{3
let out = s:GetWords(a:nwords, '\s\+\zs', '')
let paras = split(out, '\n')
if empty(a:template) || a:template == '*'
let template = get(g:loremipsum_paragraph_template, &filetype, '')
elseif a:template == '_'
let template = ''
else
let template = a:template
endif
if !empty(template)
call map(paras, 'v:val =~ ''\S'' ? printf(template, v:val) : v:val')
end
return paras
endf
function! loremipsum#GenerateInline(nwords) "{{{3
let out = s:GetWords(a:nwords, '[[:space:]\n]\+', ' ')
" let out = substitute(out, '[[:punct:][:space:]]*$', '', '')
" let out = substitute(out, '[.?!]\(\s*.\)', ';\L\1', 'g')
return out
endf
" :display: loremipsum#Insert(?inline=0, ?nwords=100, " ?template='', ?pre='', ?post='')
function! loremipsum#Insert(...) "{{{3
let inline = a:0 >= 1 ? !empty(a:1) : 0
let nwords = a:0 >= 2 ? a:2 : g:loremipsum_words
let template = a:0 >= 3 ? a:3 : ''
if a:0 >= 5
let marker = [a:4, a:5]
elseif a:0 >= 4
if a:4 == '_'
let marker = []
else
echoerr 'Loremipsum: No postfix defined'
endif
else
let marker = get(g:loremipsum_marker, &filetype, [])
endif
" TLogVAR inline, nwords, template
if inline
let t = @t
try
let @t = s:WrapMarker(marker, loremipsum#GenerateInline(nwords))
norm! "tp
finally
let @t = t
endtry
else
let text = s:WrapMarker(marker, loremipsum#Generate(nwords, template))
let lno = line('.')
if getline(lno) !~ '\S'
let lno -= 1
endif
call append(lno, text)
exec 'norm! '. lno .'gggq'. len(text) ."j"
endif
endf
function! loremipsum#Replace(...) "{{{3
let replace = a:0 >= 1 ? a:1 : ''
if a:0 >= 3
let marker = [a:2, a:3]
else
let marker = get(g:loremipsum_marker, &filetype, [])
endif
if len(marker) >= 2
let [pre, post; flags] = marker
let pre = escape(pre, '\/')
let post = escape(post, '\/')
if s:NoInline(flags)
let pre = '\^\s\*'. pre .'\s\*\n'
let post = '\n\s\*'. post .'\s\*\n'
let replace .= "\<c-m>"
endif
let rx = '\V'. pre .'\_.\{-}'. post
let rpl = escape(replace, '\&~/')
let sr = @/
try
" TLogVAR rx, rpl
exec '%s/'. rx .'/'. rpl .'/ge'
finally
let @/ = sr
endtry
else
echoerr 'Loremipsum: No marker for '. &filetype
endif
endf
let &cpo = s:save_cpo
unlet s:save_cpo

View File

@@ -1,97 +0,0 @@
*loremipsum.txt* A dummy text generator
Author: Thomas Link, micathom at gmail com
Insert a dummy text of a certain length. Actually, the text isn't
generated but selected from some text. By default, the following text is
used, which is included in the archive:
http://www.lorem-ipsum-dolor-sit-amet.com/lorem-ipsum-dolor-sit-amet.html
NOTE: The webpage didn't contain any copyright message but there is a
statement that one should copy & paste the text. I thus assume it's ok
to include it in the archive. If not, please let me know.
-----------------------------------------------------------------------
Install~
Edit the vba file and type: >
:so %
See :help vimball for details. If you have difficulties or use vim 7.0,
please make sure, you have the current version of vimball (vimscript
#1502) installed or update your runtime.
========================================================================
Contents~
plugin/loremipsum.vim
g:loremipsum_paragraph_template ... |g:loremipsum_paragraph_template|
g:loremipsum_marker ............... |g:loremipsum_marker|
g:loremipsum_words ................ |g:loremipsum_words|
g:loremipsum_files ................ |g:loremipsum_files|
:Loremipsum ....................... |:Loremipsum|
:Loreplace ........................ |:Loreplace|
autoload/loremipsum.vim
loremipsum#Generate ............... |loremipsum#Generate()|
loremipsum#GenerateInline ......... |loremipsum#GenerateInline()|
loremipsum#Insert ................. |loremipsum#Insert()|
loremipsum#Replace ................ |loremipsum#Replace()|
========================================================================
plugin/loremipsum.vim~
*g:loremipsum_paragraph_template*
g:loremipsum_paragraph_template
A dictionary of filetypes and paragraph templates (as format
strings for |printf()|).
*g:loremipsum_marker*
g:loremipsum_marker (default: {})
A dictionary of filetypes and array containing the prefix and the
postfix for the inserted text:
[prefix, postfix, no_inline?]
*g:loremipsum_words*
g:loremipsum_words (default: 100)
Default length.
*g:loremipsum_files*
g:loremipsum_files (default: {})
*b:loremipsum_file*
If b:loremipsum_file exists, it will be used as source. Otherwise,
g:loremipsum_files[&spelllang] will be checked. As a fallback,
~/vimfiles/autoload/loremipsum.txt will be used.
*:Loremipsum*
:Loremipsum[!] [COUNT] [PARAGRAPH_TEMPLATE] [PREFIX] [POSTFIX]
With [!], insert the text "inline", don't apply paragraph templates.
If the paragraph template is *, use the default template from
|g:loremipsum_paragraph_template| (in case you want to change
PREFIX and POSTFIX). If it is _, use no paragraph template.
If PREFIX is _, don't use markers.
*:Loreplace*
:Loreplace [REPLACEMENT] [PREFIX] [POSTFIX]
Replace loremipsum text with something else. Or simply remove it.
========================================================================
autoload/loremipsum.vim~
*loremipsum#Generate()*
loremipsum#Generate(nwords, template)
*loremipsum#GenerateInline()*
loremipsum#GenerateInline(nwords)
*loremipsum#Insert()*
loremipsum#Insert(?inline=0, ?nwords=100, " ?template='', ?pre='', ?post='')
*loremipsum#Replace()*
loremipsum#Replace(...)
vim:tw=78:fo=tcq2:isk=!-~,^*,^|,^":ts=8:ft=help:norl:

View File

@@ -1,85 +0,0 @@
" loremipsum.vim
" @Author: Thomas Link (micathom AT gmail com?subject=[vim])
" @Website: http://www.vim.org/account/profile.php?user_id=4037
" @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
" @Created: 2008-07-10.
" @Last Change: 2008-07-11.
" @Revision: 66
" GetLatestVimScripts: 2289 0 loremipsum.vim
if &cp || exists("loaded_loremipsum")
finish
endif
let loaded_loremipsum = 2
let s:save_cpo = &cpo
set cpo&vim
if !exists('g:loremipsum_paragraph_template')
" A dictionary of filetypes and paragraph templates (as format
" strings for |printf()|).
" :nodefault:
" :read: let g:loremipsum_paragraph_template = {} "{{{2
let g:loremipsum_paragraph_template = {
\ 'html': '<p>%s</p>',
\ 'php': '<p>%s</p>',
\ }
endif
if !exists('g:loremipsum_marker')
" A dictionary of filetypes and array containing the prefix and the
" postfix for the inserted text:
" [prefix, postfix, no_inline?]
" :read: let g:loremipsum_marker = {} "{{{2
let g:loremipsum_marker = {
\ 'html': ['<!--lorem-->', '<!--/lorem-->', 0],
\ 'php': ['<!--lorem-->', '<!--/lorem-->', 0],
\ 'tex': ['% lorem{{{', '% lorem}}}', 1],
\ 'viki': ['% lorem{{{', '% lorem}}}', 1],
\ }
endif
if !exists('g:loremipsum_words')
" Default length.
let g:loremipsum_words = 100 "{{{2
endif
if !exists('g:loremipsum_files')
" *b:loremipsum_file*
" If b:loremipsum_file exists, it will be used as source. Otherwise,
" g:loremipsum_files[&spelllang] will be checked. As a fallback,
" .../autoload/loremipsum.txt will be used.
let g:loremipsum_files = {} "{{{2
endif
" :display: :Loremipsum[!] [COUNT] [PARAGRAPH_TEMPLATE] [PREFIX POSTFIX]
" With [!], insert the text "inline", don't apply paragraph templates.
" If the PARAGRAPH_TEMPLATE is *, use the default template from
" |g:loremipsum_paragraph_template| (in case you want to change
" PREFIX and POSTFIX). If it is _, use no paragraph template.
" If PREFIX is _, don't use markers.
command! -bang -nargs=* Loremipsum call loremipsum#Insert("<bang>", <f-args>)
" Replace loremipsum text with something else. Or simply remove it.
" :display: :Loreplace [REPLACEMENT] [PREFIX] [POSTFIX]
command! -nargs=* Loreplace call loremipsum#Replace(<f-args>)
let &cpo = s:save_cpo
unlet s:save_cpo
finish
CHANGES:
0.1
- Initial release
0.2
- Loremipsum!: With !, insert inline (single paragraph)
- If the template argument is *, don't apply the default paragraph
template.
- Loreplace: Replace loremipsum text with something else (provided a
marker was defined for the current filetype)
- g:loremipsum_file, b:loremipsum_file

File diff suppressed because it is too large Load Diff

View File

@@ -1,136 +0,0 @@
" mark/palettes.vim: Additional palettes for mark highlighting.
"
" DEPENDENCIES:
"
" Copyright: (C) 2012 Ingo Karkat
" The VIM LICENSE applies to this script; see ':help copyright'.
"
" Maintainer: Ingo Karkat <ingo@karkat.de>
" Contributors: rockybalboa4
"
" Version: 2.7.0
" Changes:
" 04-Jul-2012, Ingo Karkat
" - Add "maximum" palette contributed by rockybalboa4 and move it and the
" "extended" palette to a separate mark/palettes.vim autoload script.
function! mark#palettes#Extended()
return [
\ { 'ctermbg':'Blue', 'ctermfg':'Black', 'guibg':'#A1B7FF', 'guifg':'#001E80' },
\ { 'ctermbg':'Magenta', 'ctermfg':'Black', 'guibg':'#FFA1C6', 'guifg':'#80005D' },
\ { 'ctermbg':'Green', 'ctermfg':'Black', 'guibg':'#ACFFA1', 'guifg':'#0F8000' },
\ { 'ctermbg':'Yellow', 'ctermfg':'Black', 'guibg':'#FFE8A1', 'guifg':'#806000' },
\ { 'ctermbg':'DarkCyan', 'ctermfg':'Black', 'guibg':'#D2A1FF', 'guifg':'#420080' },
\ { 'ctermbg':'Cyan', 'ctermfg':'Black', 'guibg':'#A1FEFF', 'guifg':'#007F80' },
\ { 'ctermbg':'DarkBlue', 'ctermfg':'Black', 'guibg':'#A1DBFF', 'guifg':'#004E80' },
\ { 'ctermbg':'DarkMagenta','ctermfg':'Black', 'guibg':'#A29CCF', 'guifg':'#120080' },
\ { 'ctermbg':'DarkRed', 'ctermfg':'Black', 'guibg':'#F5A1FF', 'guifg':'#720080' },
\ { 'ctermbg':'Brown', 'ctermfg':'Black', 'guibg':'#FFC4A1', 'guifg':'#803000' },
\ { 'ctermbg':'DarkGreen', 'ctermfg':'Black', 'guibg':'#D0FFA1', 'guifg':'#3F8000' },
\ { 'ctermbg':'Red', 'ctermfg':'Black', 'guibg':'#F3FFA1', 'guifg':'#6F8000' },
\ { 'ctermbg':'White', 'ctermfg':'Gray', 'guibg':'#E3E3D2', 'guifg':'#999999' },
\ { 'ctermbg':'LightGray', 'ctermfg':'White', 'guibg':'#D3D3C3', 'guifg':'#666666' },
\ { 'ctermbg':'Gray', 'ctermfg':'Black', 'guibg':'#A3A396', 'guifg':'#222222' },
\ { 'ctermbg':'Black', 'ctermfg':'White', 'guibg':'#53534C', 'guifg':'#DDDDDD' },
\ { 'ctermbg':'Black', 'ctermfg':'Gray', 'guibg':'#131311', 'guifg':'#AAAAAA' },
\ { 'ctermbg':'Blue', 'ctermfg':'White', 'guibg':'#0000FF', 'guifg':'#F0F0FF' },
\ { 'ctermbg':'DarkRed', 'ctermfg':'White', 'guibg':'#FF0000', 'guifg':'#FFFFFF' },
\]
endfunction
function! mark#palettes#Maximum()
let l:palette = [
\ { 'ctermbg':'Cyan', 'ctermfg':'Black', 'guibg':'#8CCBEA', 'guifg':'Black' },
\ { 'ctermbg':'Green', 'ctermfg':'Black', 'guibg':'#A4E57E', 'guifg':'Black' },
\ { 'ctermbg':'Yellow', 'ctermfg':'Black', 'guibg':'#FFDB72', 'guifg':'Black' },
\ { 'ctermbg':'Red', 'ctermfg':'Black', 'guibg':'#FF7272', 'guifg':'Black' },
\ { 'ctermbg':'Magenta', 'ctermfg':'Black', 'guibg':'#FFB3FF', 'guifg':'Black' },
\ { 'ctermbg':'Blue', 'ctermfg':'Black', 'guibg':'#9999FF', 'guifg':'Black' },
\]
if has('gui_running') || &t_Co >= 88
let l:palette += [
\ { 'ctermfg':'White', 'ctermbg':'17', 'guifg':'White', 'guibg':'#00005f' },
\ { 'ctermfg':'White', 'ctermbg':'22', 'guifg':'White', 'guibg':'#005f00' },
\ { 'ctermfg':'White', 'ctermbg':'23', 'guifg':'White', 'guibg':'#005f5f' },
\ { 'ctermfg':'White', 'ctermbg':'27', 'guifg':'White', 'guibg':'#005fff' },
\ { 'ctermfg':'White', 'ctermbg':'29', 'guifg':'White', 'guibg':'#00875f' },
\ { 'ctermfg':'White', 'ctermbg':'34', 'guifg':'White', 'guibg':'#00af00' },
\ { 'ctermfg':'Black', 'ctermbg':'37', 'guifg':'Black', 'guibg':'#00afaf' },
\ { 'ctermfg':'Black', 'ctermbg':'43', 'guifg':'Black', 'guibg':'#00d7af' },
\ { 'ctermfg':'Black', 'ctermbg':'47', 'guifg':'Black', 'guibg':'#00ff5f' },
\ { 'ctermfg':'White', 'ctermbg':'52', 'guifg':'White', 'guibg':'#5f0000' },
\ { 'ctermfg':'White', 'ctermbg':'53', 'guifg':'White', 'guibg':'#5f005f' },
\ { 'ctermfg':'White', 'ctermbg':'58', 'guifg':'White', 'guibg':'#5f5f00' },
\ { 'ctermfg':'White', 'ctermbg':'60', 'guifg':'White', 'guibg':'#5f5f87' },
\ { 'ctermfg':'White', 'ctermbg':'64', 'guifg':'White', 'guibg':'#5f8700' },
\ { 'ctermfg':'White', 'ctermbg':'65', 'guifg':'White', 'guibg':'#5f875f' },
\ { 'ctermfg':'Black', 'ctermbg':'66', 'guifg':'Black', 'guibg':'#5f8787' },
\ { 'ctermfg':'Black', 'ctermbg':'72', 'guifg':'Black', 'guibg':'#5faf87' },
\ { 'ctermfg':'Black', 'ctermbg':'74', 'guifg':'Black', 'guibg':'#5fafd7' },
\ { 'ctermfg':'Black', 'ctermbg':'78', 'guifg':'Black', 'guibg':'#5fd787' },
\ { 'ctermfg':'Black', 'ctermbg':'79', 'guifg':'Black', 'guibg':'#5fd7af' },
\ { 'ctermfg':'Black', 'ctermbg':'85', 'guifg':'Black', 'guibg':'#5fffaf' },
\]
endif
if has('gui_running') || &t_Co >= 256
let l:palette += [
\ { 'ctermfg':'White', 'ctermbg':'90', 'guifg':'White', 'guibg':'#870087' },
\ { 'ctermfg':'White', 'ctermbg':'95', 'guifg':'White', 'guibg':'#875f5f' },
\ { 'ctermfg':'White', 'ctermbg':'96', 'guifg':'White', 'guibg':'#875f87' },
\ { 'ctermfg':'Black', 'ctermbg':'101', 'guifg':'Black', 'guibg':'#87875f' },
\ { 'ctermfg':'Black', 'ctermbg':'107', 'guifg':'Black', 'guibg':'#87af5f' },
\ { 'ctermfg':'Black', 'ctermbg':'114', 'guifg':'Black', 'guibg':'#87d787' },
\ { 'ctermfg':'Black', 'ctermbg':'117', 'guifg':'Black', 'guibg':'#87d7ff' },
\ { 'ctermfg':'Black', 'ctermbg':'118', 'guifg':'Black', 'guibg':'#87ff00' },
\ { 'ctermfg':'Black', 'ctermbg':'122', 'guifg':'Black', 'guibg':'#87ffd7' },
\ { 'ctermfg':'White', 'ctermbg':'130', 'guifg':'White', 'guibg':'#af5f00' },
\ { 'ctermfg':'White', 'ctermbg':'131', 'guifg':'White', 'guibg':'#af5f5f' },
\ { 'ctermfg':'Black', 'ctermbg':'133', 'guifg':'Black', 'guibg':'#af5faf' },
\ { 'ctermfg':'Black', 'ctermbg':'138', 'guifg':'Black', 'guibg':'#af8787' },
\ { 'ctermfg':'Black', 'ctermbg':'142', 'guifg':'Black', 'guibg':'#afaf00' },
\ { 'ctermfg':'Black', 'ctermbg':'152', 'guifg':'Black', 'guibg':'#afd7d7' },
\ { 'ctermfg':'White', 'ctermbg':'160', 'guifg':'White', 'guibg':'#d70000' },
\ { 'ctermfg':'Black', 'ctermbg':'166', 'guifg':'Black', 'guibg':'#d75f00' },
\ { 'ctermfg':'Black', 'ctermbg':'169', 'guifg':'Black', 'guibg':'#d75faf' },
\ { 'ctermfg':'Black', 'ctermbg':'174', 'guifg':'Black', 'guibg':'#d78787' },
\ { 'ctermfg':'Black', 'ctermbg':'175', 'guifg':'Black', 'guibg':'#d787af' },
\ { 'ctermfg':'Black', 'ctermbg':'186', 'guifg':'Black', 'guibg':'#d7d787' },
\ { 'ctermfg':'Black', 'ctermbg':'190', 'guifg':'Black', 'guibg':'#d7ff00' },
\ { 'ctermfg':'White', 'ctermbg':'198', 'guifg':'White', 'guibg':'#ff0087' },
\ { 'ctermfg':'Black', 'ctermbg':'202', 'guifg':'Black', 'guibg':'#ff5f00' },
\ { 'ctermfg':'Black', 'ctermbg':'204', 'guifg':'Black', 'guibg':'#ff5f87' },
\ { 'ctermfg':'Black', 'ctermbg':'209', 'guifg':'Black', 'guibg':'#ff875f' },
\ { 'ctermfg':'Black', 'ctermbg':'212', 'guifg':'Black', 'guibg':'#ff87d7' },
\ { 'ctermfg':'Black', 'ctermbg':'215', 'guifg':'Black', 'guibg':'#ffaf5f' },
\ { 'ctermfg':'Black', 'ctermbg':'220', 'guifg':'Black', 'guibg':'#ffd700' },
\ { 'ctermfg':'Black', 'ctermbg':'224', 'guifg':'Black', 'guibg':'#ffd7d7' },
\ { 'ctermfg':'Black', 'ctermbg':'228', 'guifg':'Black', 'guibg':'#ffff87' },
\]
endif
if has('gui_running')
let l:palette += [
\ { 'guifg':'Black', 'guibg':'#b3dcff' },
\ { 'guifg':'Black', 'guibg':'#99cbd6' },
\ { 'guifg':'Black', 'guibg':'#7afff0' },
\ { 'guifg':'Black', 'guibg':'#a6ffd2' },
\ { 'guifg':'Black', 'guibg':'#a2de9e' },
\ { 'guifg':'Black', 'guibg':'#bcff80' },
\ { 'guifg':'Black', 'guibg':'#e7ff8c' },
\ { 'guifg':'Black', 'guibg':'#f2e19d' },
\ { 'guifg':'Black', 'guibg':'#ffcc73' },
\ { 'guifg':'Black', 'guibg':'#f7af83' },
\ { 'guifg':'Black', 'guibg':'#fcb9b1' },
\ { 'guifg':'Black', 'guibg':'#ff8092' },
\ { 'guifg':'Black', 'guibg':'#ff73bb' },
\ { 'guifg':'Black', 'guibg':'#fc97ef' },
\ { 'guifg':'Black', 'guibg':'#c8a3d9' },
\ { 'guifg':'Black', 'guibg':'#ac98eb' },
\ { 'guifg':'Black', 'guibg':'#6a6feb' },
\ { 'guifg':'Black', 'guibg':'#8caeff' },
\ { 'guifg':'Black', 'guibg':'#70b9fa' },
\]
endif
return l:palette
endfunction
" vim: ts=4 sts=0 sw=4 noet

View File

@@ -1,591 +0,0 @@
*mark.txt* Highlight several words in different colors simultaneously.
MARK by Ingo Karkat
(original version by Yuheng Xie)
*mark.vim*
description |mark-description|
usage |mark-usage|
installation |mark-installation|
configuration |mark-configuration|
integration |mark-integration|
limitations |mark-limitations|
known problems |mark-known-problems|
todo |mark-todo|
history |mark-history|
==============================================================================
DESCRIPTION *mark-description*
This plugin adds mappings and a :Mark command to highlight several words in
different colors simultaneously, similar to the built-in 'hlsearch'
highlighting of search results and the * |star| command. For example, when you
are browsing a big program file, you could highlight multiple identifiers in
parallel. This will make it easier to trace the source code.
This is a continuation of vimscript #1238 by Yuheng Xie, who doesn't maintain
his original version anymore and recommends switching to this fork. This
plugin offers the following advantages over the original:
- Much faster, all colored words can now be highlighted, no more clashes with
syntax highlighting (due to use of matchadd()).
- Many bug fixes.
- Jumps behave like the built-in search, including wrap and error messages.
- Like the built-in commands, jumps take an optional [count] to quickly skip
over some marks.
- Marks can be persisted, and patterns can be added / subtracted from
mark highlight groups.
RELATED WORKS *
- MultipleSearch (vimscript #479) can highlight in a single window and in all
buffers, but still relies on the :syntax highlighting method, which is
slower and less reliable.
- http://vim.wikia.com/wiki/Highlight_multiple_words offers control over the
color used by mapping the 1-9 keys on the numeric keypad, persistence, and
highlights only a single window.
- highlight.vim (vimscript #1599) highlights lines or patterns of interest in
different colors, using mappings that start with CTRL-H and work on cword.
- quickhl.vim (vimscript #3692) can also list the matches with colors and in
addition offers on-the-fly highlighting of the current word (like many IDEs
do).
==============================================================================
USAGE *mark-usage*
HIGHLIGHTING *mark-highlighting*
*<Leader>m* *v_<Leader>m*
<Leader>m Mark the word under the cursor, similar to the |star|
command. The next free highlight group is used.
If already on a mark: Clear the mark, like
|<Leader>n|.
{Visual}<Leader>m Mark or unmark the visual selection.
[N]<Leader>m With [N], mark the word under the cursor with the
named highlight group [N]. When that group is not
empty, the word is added as an alternative match, so
you can highlight multiple words with the same color.
When the word is already contained in the list of
alternatives, it is removed.
When [N] is greater than the number of defined mark
groups, a summary of marks is printed. Active mark
groups are prefixed with "*" (or "M*" when there are
M pattern alternatives), the default next group with
">", the last used search with "/" (like |:Marks|
does). Input the mark group, accept the default with
<CR>, or abort with <Esc> or any other key.
This way, when unsure about which number represents
which color, just use 99<Leader>n and pick the color
interactively!
{Visual}[N]<Leader>m Ditto, based on the visual selection.
*<Leader>r* *v_<Leader>r*
<Leader>r Manually input a regular expression to mark.
{Visual}<Leader>r Ditto, based on the visual selection.
In accordance with the built-in |star| command,
all these mappings use 'ignorecase', but not
'smartcase'.
*<Leader>n*
<Leader>n Clear the mark under the cursor.
If not on a mark: Disable all marks, similar to
|:nohlsearch|.
Note: Marks that span multiple lines are not detected,
so the use of <Leader>n on such a mark will
unintentionally remove all marks! Use
{Visual}<Leader>r or :Mark {pattern} to clear
multi-line marks (or pass [N] if you happen to know
the group number).
[N]<Leader>n Clear the marks represented by highlight group [N].
*:Mark*
:[N]Mark Clear the marks represented by highlight group [N].
:[N]Mark {pattern} Mark or unmark {pattern}. Unless [N] is given, the
next free highlight group is used.
With [N], mark the word under the cursor with the
named highlight group [N]. When that group is not
empty, the word is added as an alternative match, so
you can highlight multiple words with the same color.
When the word is already contained in the list of
alternatives, it is removed.
For implementation reasons, {pattern} cannot use the
'smartcase' setting, only 'ignorecase'.
:Mark Disable all marks, similar to |:nohlsearch|. Marks
will automatically re-enable when a mark is added or
removed, or a search for marks is performed.
*:MarkClear*
:MarkClear Clear all marks. In contrast to disabling marks, the
actual mark information is cleared, the next mark will
use the first highlight group. This cannot be undone.
SEARCHING *mark-searching*
*<Leader>star* *<Leader>#* *<Leader>/* *<Leader>?*
[count]* [count]#
[count]<Leader>* [count]<Leader>#
[count]<Leader>/ [count]<Leader>?
Use these six keys to jump to the [count]'th next /
previous occurrence of a mark.
You could also use Vim's / and ? to search, since the
mark patterns are (optionally, see configuration)
added to the search history, too.
Cursor over mark Cursor not over mark
---------------------------------------------------------------------------
<Leader>* Jump to the next occurrence of Jump to the next occurrence of
current mark, and remember it "last mark".
as "last mark".
<Leader>/ Jump to the next occurrence of Same as left.
ANY mark.
* If <Leader>* is the most recently Do Vim's original * command.
used, do a <Leader>*; otherwise
(<Leader>/ is the most recently
used), do a <Leader>/.
Note: When the cursor is on a mark, the backwards
search does not jump to the beginning of the current
mark (like the built-in search), but to the previous
mark. The entire mark text is treated as one entity.
You can use Vim's |jumplist| to go back to previous
mark matches and the position before a mark search.
MARK PERSISTENCE *mark-persistence*
The marks can be kept and restored across Vim sessions, using the |viminfo|
file. For this to work, the "!" flag must be part of the 'viminfo' setting: >
set viminfo+=! " Save and restore global variables.
< *:MarkLoad*
:MarkLoad Restore the marks from the previous Vim session. All
current marks are discarded.
*:MarkSave*
:MarkSave Save the currently defined marks (or clear the
persisted marks if no marks are currently defined) for
use in a future Vim session.
By default, automatic persistence is enabled (so you don't need to explicitly
|:MarkSave|), but you have to explicitly load the persisted marks in a new Vim
session via |:MarkLoad|, to avoid that you accidentally drag along outdated
highlightings from Vim session to session, and be surprised by the arbitrary
highlight groups and occasional appearance of forgotten marks. If you want
just that though and automatically restore any marks, set |g:mwAutoLoadMarks|.
You can also initialize some marks (even using particular highlight groups) to
static values, e.g. by including this in |vimrc|: >
runtime plugin/mark.vim
silent MarkClear
5Mark foo
6Mark bar
Or you can define custom commands that preset certain marks: >
command -bar MyMarks silent MarkClear | execute '5Mark foo' | execute '6Mark bar'
Or a command that adds to the existing marks and then toggles them: >
command -bar ToggleFooBarMarks execute 'Mark foo' | execute 'Mark bar'
<
MARK INFORMATION *mark-information*
Both |mark-highlighting| and |mark-searching| commands print information about
the mark and search pattern, e.g.
mark-1/\<pattern\> ~
This is especially useful when you want to add or subtract patterns to a mark
highlight group via [N].
*:Marks*
:Marks List all mark highlight groups and the search patterns
defined for them.
The group that will be used for the next |:Mark| or
|<Leader>m| command (with [N]) is shown with a ">".
The last mark used for a search (via |<Leader>*|) is
shown with a "/".
MARK HIGHLIGHTING PALETTES *mark-palette*
The plugin comes with three predefined palettes: original, extended, and
maximum. You can dynamically toggle between them, e.g. when you need more
marks or a different set of colors.
*:MarkPalette*
:MarkPalette {palette} Highlight existing and future marks with the colors
defined in {palette}. If the new palette contains less
mark groups than the current one, the additional marks
are lost.
You can use |:command-completion| for {palette}.
See |g:mwDefaultHighlightingPalette| for how to change the default palette,
and |mark-palette-define| for how to add your own custom palettes.
==============================================================================
INSTALLATION *mark-installation*
This script is packaged as a |vimball|. If you have the "gunzip" decompressor
in your PATH, simply edit the *.vmb.gz package in Vim; otherwise, decompress
the archive first, e.g. using WinZip. Inside Vim, install by sourcing the
vimball or via the |:UseVimball| command. >
vim mark*.vmb.gz
:so %
To uninstall, use the |:RmVimball| command.
DEPENDENCIES *mark-dependencies*
- Requires Vim 7.1 with |matchadd()|, or Vim 7.2 or higher.
==============================================================================
CONFIGURATION *mark-configuration*
For a permanent configuration, put the following commands into your |vimrc|.
*mark-colors* *mark-highlight-colors*
This plugin defines 6 mark groups:
1: Cyan 2:Green 3:Yellow 4:Red 5:Magenta 6:Blue ~
Higher numbers always take precedence and are displayed above lower ones.
*g:mwDefaultHighlightingPalette*
Especially if you use GVIM, you can switch to a richer palette of up to 18
colors: >
let g:mwDefaultHighlightingPalette = 'extended'
Or, if you have both good eyes and display, you can try a palette that defines
27, 58, or even 77 colors, depending on the number of available colors: >
let g:mwDefaultHighlightingPalette = 'maximum'
<
If you like the additional colors, but don't need that many of them, restrict
their number via: >
let g:mwDefaultHighlightingNum = 9
<
*mark-colors-redefine*
If none of the default highlightings suits you, define your own colors in your
vimrc file (or anywhere before this plugin is sourced), in the following form
(where N = 1..): >
highlight MarkWordN ctermbg=Cyan ctermfg=Black guibg=#8CCBEA guifg=Black
You can also use this form to redefine only some of the default highlightings.
If you want to avoid losing the highlightings on |:colorscheme| commands, you
need to re-apply your highlights on the |ColorScheme| event, similar to how
this plugin does. Or you define the palette not via :highlight commands, but
use the plugin's infrastructure: >
let g:mwDefaultHighlightingPalette = [
\ { 'ctermbg':'Cyan', 'ctermfg':'Black', 'guibg':'#8CCBEA', 'guifg':'Black' },
\ ...
\]
< *mark-palette-define*
If you want to switch multiple palettes during runtime, you need to define
them as proper palettes: >
let g:mwPalettes['mypalette'] = [
\ { 'ctermbg':'Cyan', 'ctermfg':'Black', 'guibg':'#8CCBEA', 'guifg':'Black' },
\ ...
\]
let g:mwPalettes['other'] = [ ... ]
let g:mwDefaultHighlightingPalette = 'mypalette'
To add your palette to the existing ones, do this after the default palette
has been defined, e.g. in .vim/after/plugin/mark.vim). Alternatively, you can
also completely redefine all available palettes in .vimrc.
The search type highlighting (in the search message) can be changed via: >
highlight link SearchSpecialSearchType MoreMsg
<
*g:mwHistAdd*
By default, any marked words are also added to the search (/) and input (@)
history; if you don't want that, remove the corresponding symbols from: >
let g:mwHistAdd = '/@'
<
*g:mwAutoLoadMarks*
To enable the automatic restore of marks from a previous Vim session: >
let g:mwAutoLoadMarks = 1
< *g:mwAutoSaveMarks*
To turn off the automatic persistence of marks across Vim sessions: >
let g:mwAutoSaveMarks = 0
You can still explicitly save marks via |:MarkSave|.
*g:mwIgnoreCase*
If you have set 'ignorecase', but want marks to be case-insensitive, you can
override the default behavior of using 'ignorecase' by setting: >
let g:mwIgnoreCase = 0
<
*mark-mappings*
You can use different mappings by mapping to the <Plug>Mark... mappings (use
":map <Plug>Mark" to list them all) before this plugin is sourced.
There are no default mappings for toggling all marks and for the |:MarkClear|
command, but you can define some yourself: >
nmap <Leader>M <Plug>MarkToggle
nmap <Leader>N <Plug>MarkAllClear
<
To remove the default overriding of * and #, use: >
nmap <Plug>IgnoreMarkSearchNext <Plug>MarkSearchNext
nmap <Plug>IgnoreMarkSearchPrev <Plug>MarkSearchPrev
<
If you don't want the * and # mappings remember the last search type and
instead always search for the next occurrence of the current mark, with a
fallback to Vim's original * command, use: >
nmap * <Plug>MarkSearchOrCurNext
nmap # <Plug>MarkSearchOrCurPrev
<
*mark-whitespace-indifferent*
Some people like to create a mark based on the visual selection, like
|v_<Leader>m|, but have whitespace in the selection match any whitespace when
searching (searching for "hello world" will also find "hello<Tab>world" as
well as "hello" at the end of a line, with "world" at the start of the next
line). The Vim Tips Wiki describes such a setup for the built-in search at
http://vim.wikia.com/wiki/Search_for_visually_selected_text
You can achieve the same with the Mark plugin through the following scriptlet: >
function! s:GetVisualSelectionAsLiteralWhitespaceIndifferentPattern()
return substitute(escape(mark#GetVisualSelection(), '\' . '^$.*[~'), '\_s\+', '\\_s\\+', 'g')
endfunction
vnoremap <silent> <Plug>MarkWhitespaceIndifferent :<C-u>if !mark#DoMark(v:count, <SID>GetVisualSelectionAsLiteralWhitespaceIndifferentPattern())<Bar>execute "normal! \<lt>C-\>\<lt>C-n>\<lt>Esc>"<Bar>endif<CR>
Using this, you can assign a new visual mode mapping <Leader>* >
vmap <Leader>* <Plug>MarkWhitespaceIndifferent
or override the default |v_<Leader>m| mapping, in case you always want this
behavior: >
vmap <Plug>IgnoreMarkSet <Plug>MarkSet
vmap <Leader>m <Plug>MarkWhitespaceIndifferent
<
==============================================================================
INTEGRATION *mark-integration*
The following functions offer (read-only) access to the number of marks and
individual patterns:
- mark#GetNum()
- mark#GetPattern([{index}])
==============================================================================
LIMITATIONS *mark-limitations*
- If the 'ignorecase' setting is changed, there will be discrepancies between
the highlighted marks and subsequent jumps to marks.
- If {pattern} in a :Mark command contains atoms that change the semantics of
the entire (|/\c|, |/\C|) or following (|/\v|,|/\V|, |/\M|) regular
expression, there may be discrepancies between the highlighted marks and
subsequent jumps to marks.
KNOWN PROBLEMS *mark-known-problems*
TODO *mark-todo*
IDEAS *mark-ideas*
Taken from an alternative implementation at
http://vim.wikia.com/wiki/Highlight_multiple_words:
- Use keys 1-9 on the numeric keypad to toggle a highlight group number.
==============================================================================
HISTORY *mark-history*
2.7.2 15-Oct-2012
- Issue an error message "No marks defined" instead of moving the cursor by
one character when there are no marks (e.g. initially or after :MarkClear).
- Enable custom integrations via new mark#GetNum() and mark#GetPattern()
functions.
2.7.1 14-Sep-2012
- Enable alternative * / # mappings that do not remember the last search type
through new <Plug>MarkSearchOrCurNext, <Plug>MarkSearchOrCurPrev,
<Plug>MarkSearchOrAnyNext, <Plug>MarkSearchOrAnyPrev mappings. Based on an
inquiry from Kevin Huanpeng Du.
2.7.0 04-Jul-2012
- ENH: Implement :MarkPalette command to switch mark highlighting on-the-fly
during runtime.
- Add "maximum" palette contributed by rockybalboa4.
2.6.5 24-Jun-2012
- Don't define the default <Leader>m and <Leader>r mappings in select mode,
just visual mode. Thanks to rockybalboa4 for pointing this out.
2.6.4 23-Apr-2012
- Allow to override 'ignorecase' setting via g:mwIgnoreCase. Thanks to fanhe
for the idea and sending a patch.
2.6.3 27-Mar-2012
- ENH: Allow choosing of palette and limiting of default mark highlight groups
via g:mwDefaultHighlightingPalette and g:mwDefaultHighlightingNum.
- ENH: Offer an extended color palette in addition to the original 6-color one.
Enable this via :let g:mwDefaultHighlightingPalette = "extended" in your
vimrc.
2.6.2 26-Mar-2012
- ENH: When a [count] exceeding the number of available mark groups is given,
a summary of marks is given and the user is asked to select a mark group.
This allows to interactively choose a color via 99<Leader>m.
If you use the |mark-whitespace-indifferent| mappings, *** PLEASE UPDATE THE
vnoremap <Plug>MarkWhitespaceIndifferent DEFINITION ***
- ENH: Include count of alternative patterns in :Marks list.
- CHG: Use ">" for next mark and "/" for last search in :Marks.
2.6.1 23-Mar-2012
- ENH: Add :Marks command that prints all mark highlight groups and their
search patterns, plus information about the current search mark, next mark
group, and whether marks are disabled.
- ENH: Show which mark group a pattern was set / added / removed / cleared.
- FIX: When the cursor is positioned on the current mark, [N]<Leader>n /
<Plug>MarkClear with [N] appended the pattern for the current mark (again
and again) instead of clearing it. Must not pass current mark pattern when
[N] is given.
- CHG: Show mark group number in same-mark search and rename search types from
"any-mark", "same-mark", and "new-mark" to the shorter "mark-*", "mark-N",
and "mark-N!", respectively.
2.6.0 22-Mar-2012
- ENH: Allow [count] for <Leader>m and :Mark to add / subtract match to / from
highlight group [count], and use [count]<Leader>n to clear only highlight
group [count]. This was also requested by Philipp Marek.
- FIX: :Mark and <Leader>n actually toggled marks back on when they were
already off. Now, they stay off on multiple invocations. Use :call
mark#Toggle() / <Plug>MarkToggle if you want toggling.
2.5.3 02-Mar-2012
- BUG: Version check mistakenly excluded Vim 7.1 versions that do have the
matchadd() function. Thanks to Philipp Marek for sending a patch.
2.5.2 09-Nov-2011
Fixed various problems with wrap-around warnings:
- BUG: With a single match and 'wrapscan' set, a search error was issued.
- FIX: Backwards search with single match leads to wrong error message
instead.
- FIX: Wrong logic for determining l:isWrapped lets wrap-around go undetected.
2.5.1 17-May-2011
- FIX: == comparison in s:DoMark() leads to wrong regexp (\A vs. \a) being
cleared when 'ignorecase' is set. Use case-sensitive comparison ==# instead.
- Refine :MarkLoad messages
- Add whitespace-indifferent visual mark configuration example. Thanks to Greg
Klein for the suggestion.
2.5.0 07-May-2011
- ENH: Add explicit mark persistence via :MarkLoad and :MarkSave commands and
automatic persistence via the g:mwAutoLoadMarks and g:mwAutoSaveMarks
configuration flags. (Request from Mun Johl, 16-Apr-2010)
- Expose toggling of mark display (keeping the mark patterns) via new
<Plug>MarkToggle mapping. Offer :MarkClear command as a replacement for the
old argumentless :Mark command, which now just disables, but not clears all
marks.
2.4.4 18-Apr-2011
- BUG: Include trailing newline character in check for current mark, so that a
mark that matches the entire line (e.g. created by V<Leader>m) can be
cleared via <Leader>n. Thanks to ping for reporting this.
- FIX: On overlapping marks, mark#CurrentMark() returned the lowest, not the
highest visible mark. So on overlapping marks, the one that was not visible
at the cursor position was removed; very confusing! Use reverse iteration
order.
- FIX: To avoid an arbitrary ordering of highlightings when the highlighting
group names roll over, and to avoid order inconsistencies across different
windows and tabs, we assign a different priority based on the highlighting
group.
2.4.3 16-Apr-2011
- Avoid losing the mark highlightings on :syn on or :colorscheme commands.
Thanks to Zhou YiChao for alerting me to this issue and suggesting a fix.
- Made the script more robust when somehow no highlightings have been defined
or when the window-local reckoning of match IDs got lost. I had very
occasionally encountered such script errors in the past.
- Made global housekeeping variables script-local, only g:mwHistAdd is used
for configuration.
2.4.2 14-Jan-2011 (unreleased)
- FIX: Capturing the visual selection could still clobber the blockwise yank
mode of the unnamed register.
2.4.1 13-Jan-2011
- FIX: Using a named register for capturing the visual selection on
{Visual}<Leader>m and {Visual}<Leader>r clobbered the unnamed register. Now
using the unnamed register.
2.4.0 13-Jul-2010
- ENH: The MarkSearch mappings (<Leader>[*#/?]) add the original cursor
position to the jump list, like the built-in [/?*#nN] commands. This allows
to use the regular jump commands for mark matches, like with regular search
matches.
2.3.3 19-Feb-2010
- BUG: Clearing of an accidental zero-width match (e.g. via :Mark \zs) results
in endless loop. Thanks to Andy Wokula for the patch.
2.3.2 17-Nov-2009
- BUG: Creation of literal pattern via '\V' in {Visual}<Leader>m mapping
collided with individual escaping done in <Leader>m mapping so that an
escaped '\*' would be interpreted as a multi item when both modes are used
for marking. Thanks to Andy Wokula for the patch.
2.3.1 06-Jul-2009
- Now working correctly when 'smartcase' is set. All mappings and the :Mark
command use 'ignorecase', but not 'smartcase'.
2.3.0 04-Jul-2009
- All jump commands now take an optional [count], so you can quickly skip over
some marks, as with the built-in */# and n/N commands. For this, the entire
core search algorithm has been rewritten. The script's logic has been
simplified through the use of Vim 7 features like Lists.
- Now also printing a Vim-alike search error message when 'nowrapscan' is set.
2.2.0 02-Jul-2009
- Split off functions into autoload script.
- Initialization of global variables and autocommands is now done lazily on
the first use, not during loading of the plugin. This reduces Vim startup
time and footprint as long as the functionality isn't yet used.
- Split off documentation into separate help file. Now packaging as VimBall.
2.1.0 06-Jun-2009
- Replaced highlighting via :syntax with matchadd() / matchdelete(). This
requires Vim 7.2 / 7.1 with patches. This method is faster, there are no
more clashes with syntax highlighting (:match always has preference), and
the background highlighting does not disappear under 'cursorline'.
- Using winrestcmd() to fix effects of :windo: By entering a window, its
height is potentially increased from 0 to 1.
- Handling multiple tabs by calling s:UpdateScope() on the TabEnter event.
2.0.0 01-Jun-2009
- Now using Vim List for g:mwWord and thus requiring Vim 7. g:mwCycle is now
zero-based, but the syntax groups "MarkWordx" are still one-based.
- Factored :syntax operations out of s:DoMark() and s:UpdateMark() so that
they can all be done in a single :windo.
- Normal mode <Plug>MarkSet now has the same semantics as its visual mode
cousin: If the cursor is on an existing mark, the mark is removed.
Beforehand, one could only remove a visually selected mark via again
selecting it. Now, one simply can invoke the mapping when on such a mark.
1.6.1 31-May-2009
Publication of improved version by Ingo Karkat.
- Now prepending search type ("any-mark", "same-mark", "new-mark") for better
identification.
- Retired the algorithm in s:PrevWord in favor of simply using <cword>, which
makes mark.vim work like the * command. At the end of a line, non-keyword
characters may now be marked; the previous algorithm preferred any preceding
word.
- BF: If 'iskeyword' contains characters that have a special meaning in a
regexp (e.g. [.*]), these are now escaped properly.
- Highlighting can now actually be overridden in the vimrc (anywhere _before_
sourcing this script) by using ':hi def'.
- Added missing setter for re-inclusion guard.
1.5.0 01-Sep-2008
Bug fixes and enhancements by Ingo Karkat.
- Added <Plug>MarkAllClear (without a default mapping), which clears all
marks, even when the cursor is on a mark.
- Added <Plug>... mappings for hard-coded \*, \#, \/, \?, * and #, to allow
re-mapping and disabling. Beforehand, there were some <Plug>... mappings
and hard-coded ones; now, everything can be customized.
- BF: Using :autocmd without <bang> to avoid removing _all_ autocmds for the
BufWinEnter event. (Using a custom :augroup would be even better.)
- BF: Explicitly defining s:current_mark_position; some execution paths left
it undefined, causing errors.
- ENH: Make the match according to the 'ignorecase' setting, like the star
command.
- ENH: The jumps to the next/prev occurrence now print 'search hit BOTTOM,
continuing at TOP" and "Pattern not found:..." messages, like the * and n/N
Vim search commands.
- ENH: Jumps now open folds if the occurrence is inside a closed fold, just
like n/N do.
1.1.8-g 25-Apr-2008
Last version published by Yuheng Xie on vim.org.
1.1.2 22-Mar-2005
Initial version published by Yuheng Xie on vim.org.
==============================================================================
Copyright: (C) 2005-2008 Yuheng Xie
(C) 2008-2012 Ingo Karkat
The VIM LICENSE applies to this script; see |copyright|.
Maintainer: Ingo Karkat <ingo@karkat.de>
==============================================================================
vim:tw=78:ts=8:ft=help:norl:

View File

@@ -1,420 +0,0 @@
" Script Name: mark.vim
" Description: Highlight several words in different colors simultaneously.
"
" Copyright: (C) 2005-2008 Yuheng Xie
" (C) 2008-2012 Ingo Karkat
" The VIM LICENSE applies to this script; see ':help copyright'.
"
" Maintainer: Ingo Karkat <ingo@karkat.de>
" Orig Author: Yuheng Xie <elephant@linux.net.cn>
" Contributors:Luc Hermitte, Ingo Karkat
"
" Dependencies:
" - Requires Vim 7.1 with "matchadd()", or Vim 7.2 or higher.
" - mark.vim autoload script
" - mark/palettes.vim autoload script for additional palettes
"
" Version: 2.7.1
" Changes:
" 13-Sep-2012, Ingo Karkat
" - Enable alternative * / # mappings that do not remember the last search type
" through new <Plug>MarkSearchOrCurNext, <Plug>MarkSearchOrCurPrev,
" <Plug>MarkSearchOrAnyNext, <Plug>MarkSearchOrAnyPrev mappings.
"
" 04-Jul-2012, Ingo Karkat
" - Introduce g:mwPalettes instead of hard-coding them in
" s:DefaultHighlightings(), which got s:DefineHighlightings() extracted and
" the rest renamed to s:GetPalette().
" - Allow overriding of existing mark highlighting via a:isOverride argument to
" s:DefineHighlightings().
" - Add "maximum" palette contributed by rockybalboa4 and move it and the
" "extended" palette to a separate mark/palettes.vim autoload script.
" - ENH: Implement :MarkPalette command to switch mark highlighting on-the-fly
" during runtime.
"
" 24-Jun-2012, Ingo Karkat
" - Don't define the default <Leader>m and <Leader>r mappings in select mode,
" just visual mode. Thanks to rockybalboa4 for pointing this out.
"
" 27-Mar-2012, Ingo Karkat
" - ENH: Allow choosing of palette and limiting of default mark highlight groups
" via g:mwDefaultHighlightingPalette and g:mwDefaultHighlightingNum.
" - ENH: Offer an extended color palette in addition to the original 6-color one.
"
" 23-Mar-2012, Ingo Karkat
" - ENH: Add :Marks command that prints all mark highlight groups and their
" search patterns, plus information about the current search mark, next mark
" group, and whether marks are disabled.
" - FIX: When the cursor is positioned on the current mark, [N]<Leader>n /
" <Plug>MarkClear with [N] appended the pattern for the current mark (again
" and again) instead of clearing it. Must not pass current mark pattern when
" [N] is given.
"
" 22-Mar-2012, Ingo Karkat
" - ENH: Allow [count] for <Leader>m and :Mark to add / subtract match to / from
" highlight group [count], and use [count]<Leader>n to clear only highlight
" group [count]. This was also requested by Philipp Marek.
"
" 02-Mar-2012, Philipp Marek
" - BUG: Version check mistakenly excluded Vim 7.1 versions that do have the
" matchadd() function.
"
" 06-May-2011, Ingo Karkat
" - By default, enable g:mwAutoSaveMarks, so that marks are always persisted,
" but disable g:mwAutoLoadMarks, so that persisted marks have to be explicitly
" loaded, if that is desired. I often wondered why I got unexpected mark
" highlightings in a new Vim session until I realized that I had used marks in
" a previous session and forgot to clear them.
"
" 21-Apr-2011, Ingo Karkat
" - Expose toggling of mark display (keeping the mark patterns) via new
" <Plug>MarkToggle mapping. Offer :MarkClear command as a replacement for the
" old argumentless :Mark command, which now just disables, but not clears all
" marks.
" - Implement lazy-loading of disabled persistent marks via g:mwDoDeferredLoad
" flag passing to autoload/mark.vim.
"
" 19-Apr-2011, Ingo Karkat
" - ENH: Add explicit mark persistence via :MarkLoad and :MarkSave commands and
" automatic persistence via the g:mwAutoLoadMarks and g:mwAutoSaveMarks
" configuration flags.
"
" 15-Apr-2011, Ingo Karkat
" - Avoid losing the mark highlightings on :syn on or :colorscheme commands.
" Thanks to Zhou YiChao for alerting me to this issue and suggesting a fix.
"
" 17-Nov-2009, Ingo Karkat
" - Replaced the (overly) generic mark#GetVisualSelectionEscaped() with
" mark#GetVisualSelectionAsRegexp() and
" mark#GetVisualSelectionAsLiteralPattern().
"
" 04-Jul-2009, Ingo Karkat
" - A [count] before any mapping either caused "No range allowed" error or just
" repeated the :call [count] times, resulting in the current search pattern
" echoed [count] times and a hit-enter prompt. Now suppressing [count] via
" <C-u> and handling it inside the implementation.
" - Now passing isBackward (0/1) instead of optional 'b' flag into functions.
" Also passing empty regexp to mark#MarkRegex() to avoid any optional
" arguments.
"
" 02-Jul-2009, Ingo Karkat
" - Split off functions into autoload script.
" - Removed g:force_reload_mark.
" - Initialization of global variables and autocommands is now done lazily on
" the first use, not during loading of the plugin. This reduces Vim startup
" time and footprint as long as the functionality isn't yet used.
"
" 6-Jun-2009, Ingo Karkat
" 1. Somehow s:WrapMessage() needs a redraw before the :echo to avoid that a
" later Vim redraw clears the wrap message. This happened when there's no
" statusline and thus :echo'ing into the ruler.
" 2. Removed line-continuations and ':set cpo=...'. Upper-cased <SID> and <CR>.
" 3. Added default highlighting for the special search type.
"
" 2-Jun-2009, Ingo Karkat
" 1. Replaced highlighting via :syntax with matchadd() / matchdelete(). This
" requires Vim 7.2 / 7.1 with patches. This method is faster, there are no
" more clashes with syntax highlighting (:match always has preference), and
" the background highlighting does not disappear under 'cursorline'.
" 2. Factored :windo application out into s:MarkScope().
" 3. Using winrestcmd() to fix effects of :windo: By entering a window, its
" height is potentially increased from 0 to 1.
" 4. Handling multiple tabs by calling s:UpdateScope() on the TabEnter event.
"
" 1-Jun-2009, Ingo Karkat
" 1. Now using Vim List for g:mwWord and thus requiring Vim 7. g:mwCycle is now
" zero-based, but the syntax groups "MarkWordx" are still one-based.
" 2. Added missing setter for re-inclusion guard.
" 3. Factored :syntax operations out of s:DoMark() and s:UpdateMark() so that
" they can all be done in a single :windo.
" 4. Normal mode <Plug>MarkSet now has the same semantics as its visual mode
" cousin: If the cursor is on an existing mark, the mark is removed.
" Beforehand, one could only remove a visually selected mark via again
" selecting it. Now, one simply can invoke the mapping when on such a mark.
" 5. Highlighting can now actually be overridden in the vimrc (anywhere
" _before_ sourcing this script) by using ':hi def'.
"
" 31-May-2009, Ingo Karkat
" 1. Refactored s:Search() to optionally take advantage of SearchSpecial.vim
" autoload functionality for echoing of search pattern, wrap and error
" messages.
" 2. Now prepending search type ("any-mark", "same-mark", "new-mark") for
" better identification.
" 3. Retired the algorithm in s:PrevWord in favor of simply using <cword>,
" which makes mark.vim work like the * command. At the end of a line,
" non-keyword characters may now be marked; the previous algorithm prefered
" any preceding word.
" 4. BF: If 'iskeyword' contains characters that have a special meaning in a
" regex (e.g. [.*]), these are now escaped properly.
"
" 01-Sep-2008, Ingo Karkat: bugfixes and enhancements
" 1. Added <Plug>MarkAllClear (without a default mapping), which clears all
" marks, even when the cursor is on a mark.
" 2. Added <Plug>... mappings for hard-coded \*, \#, \/, \?, * and #, to allow
" re-mapping and disabling. Beforehand, there were some <Plug>... mappings
" and hard-coded ones; now, everything can be customized.
" 3. Bugfix: Using :autocmd without <bang> to avoid removing _all_ autocmds for
" the BufWinEnter event. (Using a custom :augroup would be even better.)
" 4. Bugfix: Explicitly defining s:current_mark_position; some execution paths
" left it undefined, causing errors.
" 5. Refactoring: Instead of calling s:InitMarkVariables() at the beginning of
" several functions, just calling it once when sourcing the script.
" 6. Refactoring: Moved multiple 'let lastwinnr = winnr()' to a single one at the
" top of DoMark().
" 7. ENH: Make the match according to the 'ignorecase' setting, like the star
" command.
" 8. The jumps to the next/prev occurrence now print 'search hit BOTTOM,
" continuing at TOP" and "Pattern not found:..." messages, like the * and
" n/N Vim search commands.
" 9. Jumps now open folds if the occurrence is inside a closed fold, just like n/N
" do.
"
" 10th Mar 2006, Yuheng Xie: jump to ANY mark
" (*) added \* \# \/ \? for the ability of jumping to ANY mark, even when the
" cursor is not currently over any mark
"
" 20th Sep 2005, Yuheng Xie: minor modifications
" (*) merged MarkRegexVisual into MarkRegex
" (*) added GetVisualSelectionEscaped for multi-lines visual selection and
" visual selection contains ^, $, etc.
" (*) changed the name ThisMark to CurrentMark
" (*) added SearchCurrentMark and re-used raw map (instead of Vim function) to
" implement * and #
"
" 14th Sep 2005, Luc Hermitte: modifications done on v1.1.4
" (*) anti-reinclusion guards. They do not guard colors definitions in case
" this script must be reloaded after .gvimrc
" (*) Protection against disabled |line-continuation|s.
" (*) Script-local functions
" (*) Default keybindings
" (*) \r for visual mode
" (*) uses <Leader> instead of "\"
" (*) do not mess with global variable g:w
" (*) regex simplified -> double quotes changed into simple quotes.
" (*) strpart(str, idx, 1) -> str[idx]
" (*) command :Mark
" -> e.g. :Mark Mark.\{-}\ze(
" Avoid installing twice or when in unsupported Vim version.
if exists('g:loaded_mark') || (v:version == 701 && ! exists('*matchadd')) || (v:version < 701)
finish
endif
let g:loaded_mark = 1
let s:save_cpo = &cpo
set cpo&vim
"- configuration --------------------------------------------------------------
if ! exists('g:mwHistAdd')
let g:mwHistAdd = '/@'
endif
if ! exists('g:mwAutoLoadMarks')
let g:mwAutoLoadMarks = 0
endif
if ! exists('g:mwAutoSaveMarks')
let g:mwAutoSaveMarks = 1
endif
if ! exists('g:mwDefaultHighlightingNum')
let g:mwDefaultHighlightingNum = -1
endif
if ! exists('g:mwDefaultHighlightingPalette')
let g:mwDefaultHighlightingPalette = 'original'
endif
if ! exists('g:mwPalettes')
let g:mwPalettes = {
\ 'original': [
\ { 'ctermbg':'Cyan', 'ctermfg':'Black', 'guibg':'#8CCBEA', 'guifg':'Black' },
\ { 'ctermbg':'Green', 'ctermfg':'Black', 'guibg':'#A4E57E', 'guifg':'Black' },
\ { 'ctermbg':'Yellow', 'ctermfg':'Black', 'guibg':'#FFDB72', 'guifg':'Black' },
\ { 'ctermbg':'Red', 'ctermfg':'Black', 'guibg':'#FF7272', 'guifg':'Black' },
\ { 'ctermbg':'Magenta', 'ctermfg':'Black', 'guibg':'#FFB3FF', 'guifg':'Black' },
\ { 'ctermbg':'Blue', 'ctermfg':'Black', 'guibg':'#9999FF', 'guifg':'Black' },
\],
\ 'extended': function('mark#palettes#Extended'),
\ 'maximum': function('mark#palettes#Maximum')
\}
endif
"- default highlightings ------------------------------------------------------
function! s:GetPalette()
let l:palette = []
if type(g:mwDefaultHighlightingPalette) == type([])
" There are custom color definitions, not a named built-in palette.
return g:mwDefaultHighlightingPalette
endif
if ! has_key(g:mwPalettes, g:mwDefaultHighlightingPalette)
if ! empty(g:mwDefaultHighlightingPalette)
let v:warningmsg = 'Mark: Unknown value for g:mwDefaultHighlightingPalette: ' . g:mwDefaultHighlightingPalette
echohl WarningMsg
echomsg v:warningmsg
echohl None
endif
return []
endif
if type(g:mwPalettes[g:mwDefaultHighlightingPalette]) == type([])
return g:mwPalettes[g:mwDefaultHighlightingPalette]
elseif type(g:mwPalettes[g:mwDefaultHighlightingPalette]) == type(function('tr'))
return call(g:mwPalettes[g:mwDefaultHighlightingPalette], [])
else
let v:errmsg = printf('Mark: Invalid value type for g:mwPalettes[%s]', g:mwDefaultHighlightingPalette)
echohl ErrorMsg
echomsg v:errmsg
echohl None
return []
endif
endfunction
function! s:DefineHighlightings( palette, isOverride )
let l:command = (a:isOverride ? 'highlight' : 'highlight def')
let l:highlightingNum = (g:mwDefaultHighlightingNum == -1 ? len(a:palette) : g:mwDefaultHighlightingNum)
for i in range(1, l:highlightingNum)
execute l:command 'MarkWord' . i join(map(items(a:palette[i - 1]), 'join(v:val, "=")'))
endfor
return l:highlightingNum
endfunction
call s:DefineHighlightings(s:GetPalette(), 0)
autocmd ColorScheme * call <SID>DefineHighlightings(<SID>GetPalette(), 0)
" Default highlighting for the special search type.
" You can override this by defining / linking the 'SearchSpecialSearchType'
" highlight group before this script is sourced.
highlight def link SearchSpecialSearchType MoreMsg
"- mappings -------------------------------------------------------------------
nnoremap <silent> <Plug>MarkSet :<C-u>if !mark#MarkCurrentWord(v:count)<Bar>execute "normal! \<lt>C-\>\<lt>C-n>\<lt>Esc>"<Bar>endif<CR>
vnoremap <silent> <Plug>MarkSet :<C-u>if !mark#DoMark(v:count, mark#GetVisualSelectionAsLiteralPattern())<Bar>execute "normal! \<lt>C-\>\<lt>C-n>\<lt>Esc>"<Bar>endif<CR>
nnoremap <silent> <Plug>MarkRegex :<C-u>call mark#MarkRegex('')<CR>
vnoremap <silent> <Plug>MarkRegex :<C-u>call mark#MarkRegex(mark#GetVisualSelectionAsRegexp())<CR>
nnoremap <silent> <Plug>MarkClear :<C-u>if !mark#DoMark(v:count, (v:count ? '' : mark#CurrentMark()[0]))<Bar>execute "normal! \<lt>C-\>\<lt>C-n>\<lt>Esc>"<Bar>endif<CR>
nnoremap <silent> <Plug>MarkAllClear :<C-u>call mark#ClearAll()<CR>
nnoremap <silent> <Plug>MarkToggle :<C-u>call mark#Toggle()<CR>
nnoremap <silent> <Plug>MarkSearchCurrentNext :<C-u>call mark#SearchCurrentMark(0)<CR>
nnoremap <silent> <Plug>MarkSearchCurrentPrev :<C-u>call mark#SearchCurrentMark(1)<CR>
nnoremap <silent> <Plug>MarkSearchAnyNext :<C-u>call mark#SearchAnyMark(0)<CR>
nnoremap <silent> <Plug>MarkSearchAnyPrev :<C-u>call mark#SearchAnyMark(1)<CR>
" When typed, [*#nN] open the fold at the search result, but inside a mapping or
" :normal this must be done explicitly via 'zv'.
nnoremap <silent> <Plug>MarkSearchNext :<C-u>if !mark#SearchNext(0)<Bar>execute 'normal! *zv'<Bar>endif<CR>
nnoremap <silent> <Plug>MarkSearchPrev :<C-u>if !mark#SearchNext(1)<Bar>execute 'normal! #zv'<Bar>endif<CR>
nnoremap <silent> <Plug>MarkSearchOrCurNext :<C-u>if !mark#SearchNext(0,'mark#SearchCurrentMark')<Bar>execute 'normal! *zv'<Bar>endif<CR>
nnoremap <silent> <Plug>MarkSearchOrCurPrev :<C-u>if !mark#SearchNext(1,'mark#SearchCurrentMark')<Bar>execute 'normal! #zv'<Bar>endif<CR>
nnoremap <silent> <Plug>MarkSearchOrAnyNext :<C-u>if !mark#SearchNext(0,'mark#SearchAnyMark')<Bar>execute 'normal! *zv'<Bar>endif<CR>
nnoremap <silent> <Plug>MarkSearchOrAnyPrev :<C-u>if !mark#SearchNext(1,'mark#SearchAnyMark')<Bar>execute 'normal! #zv'<Bar>endif<CR>
if !hasmapto('<Plug>MarkSet', 'n')
nmap <unique> <Leader>m <Plug>MarkSet
endif
if !hasmapto('<Plug>MarkSet', 'v')
xmap <unique> <Leader>m <Plug>MarkSet
endif
if !hasmapto('<Plug>MarkRegex', 'n')
nmap <unique> <Leader>r <Plug>MarkRegex
endif
if !hasmapto('<Plug>MarkRegex', 'v')
xmap <unique> <Leader>r <Plug>MarkRegex
endif
if !hasmapto('<Plug>MarkClear', 'n')
nmap <unique> <Leader>n <Plug>MarkClear
endif
" No default mapping for <Plug>MarkAllClear.
" No default mapping for <Plug>MarkToggle.
if !hasmapto('<Plug>MarkSearchCurrentNext', 'n')
nmap <unique> <Leader>* <Plug>MarkSearchCurrentNext
endif
if !hasmapto('<Plug>MarkSearchCurrentPrev', 'n')
nmap <unique> <Leader># <Plug>MarkSearchCurrentPrev
endif
if !hasmapto('<Plug>MarkSearchAnyNext', 'n')
nmap <unique> <Leader>/ <Plug>MarkSearchAnyNext
endif
if !hasmapto('<Plug>MarkSearchAnyPrev', 'n')
nmap <unique> <Leader>? <Plug>MarkSearchAnyPrev
endif
if !hasmapto('<Plug>MarkSearchNext', 'n')
nmap <unique> * <Plug>MarkSearchNext
endif
if !hasmapto('<Plug>MarkSearchPrev', 'n')
nmap <unique> # <Plug>MarkSearchPrev
endif
"- commands -------------------------------------------------------------------
command! -count -nargs=? Mark if !mark#DoMark(<count>, <f-args>) | echoerr printf('Only %d mark highlight groups', mark#GetGroupNum()) | endif
command! -bar MarkClear call mark#ClearAll()
command! -bar Marks call mark#List()
command! -bar MarkLoad call mark#LoadCommand(1)
command! -bar MarkSave call mark#SaveCommand()
function! s:SetPalette( paletteName )
if type(g:mwDefaultHighlightingPalette) == type([])
" Convert the directly defined list to a palette named "default".
let g:mwPalettes['default'] = g:mwDefaultHighlightingPalette
unlet! g:mwDefaultHighlightingPalette " Avoid E706.
endif
let g:mwDefaultHighlightingPalette = a:paletteName
let l:palette = s:GetPalette()
if empty(l:palette)
return
endif
call mark#ReInit(s:DefineHighlightings(l:palette, 1))
call mark#UpdateScope()
endfunction
function! s:MarkPaletteComplete( ArgLead, CmdLine, CursorPos )
return sort(filter(keys(g:mwPalettes), 'v:val =~ ''\V\^'' . escape(a:ArgLead, "\\")'))
endfunction
command! -bar -nargs=1 -complete=customlist,<SID>MarkPaletteComplete MarkPalette call <SID>SetPalette(<q-args>)
"- marks persistence ----------------------------------------------------------
if g:mwAutoLoadMarks
" As the viminfo is only processed after sourcing of the runtime files, the
" persistent global variables are not yet available here. Defer this until Vim
" startup has completed.
function! s:AutoLoadMarks()
if g:mwAutoLoadMarks && exists('g:MARK_MARKS') && g:MARK_MARKS !=# '[]'
if ! exists('g:MARK_ENABLED') || g:MARK_ENABLED
" There are persistent marks and they haven't been disabled; we need to
" show them right now.
call mark#LoadCommand(0)
else
" Though there are persistent marks, they have been disabled. We avoid
" sourcing the autoload script and its invasive autocmds right now;
" maybe the marks are never turned on. We just inform the autoload
" script that it should do this once it is sourced on-demand by a
" mark mapping or command.
let g:mwDoDeferredLoad = 1
endif
endif
endfunction
augroup MarkInitialization
autocmd!
" Note: Avoid triggering the autoload unless there actually are persistent
" marks. For that, we need to check that g:MARK_MARKS doesn't contain the
" empty list representation, and also :execute the :call.
autocmd VimEnter * call <SID>AutoLoadMarks()
augroup END
endif
let &cpo = s:save_cpo
unlet s:save_cpo
" vim: ts=4 sts=0 sw=4 noet

View File

@@ -1,86 +0,0 @@
"=============================================================================
" File: occur.vim
" Author: FURUSAWA, Noriyoshi (noriyosi xxx gmail dot com) xxx=@,dot=.
" Last Change: 2008/7/13
" Version: 0.03
"=============================================================================
if exists('loaded_occur') || &cp
finish
endif
let loaded_occur=1
if v:version < 700
echo "Sorry, occur ONLY runs with Vim 7.0 and greater."
finish
endif
if !exists("g:occur_no_quickfix_map")
let g:occur_no_quickfix_map = 0
endif
" Key bind
nnoremap <silent> <unique> <Leader>oc :Occur<CR>
" gryf: Changed followin mapping due to confilct with showmarks plugin
nnoremap <silent> <unique> <Leader>om :Moccur<CR>
" gryf: Changed followin mapping due to confilct with marks plugin
nnoremap <silent> <unique> <Leader>8 *<C-o>:Moccur<CR>
" Create commands
command! Occur silent call s:SetupAndGo('s:Occur')
command! Moccur silent call s:SetupAndGo('s:Moccur')
command! StarOccur exec "normal! *<C-o>" <Bar> Moccur
function! s:Occur()
let expr = 'caddexpr expand("%") . ":" . line(".") . ":" . getline(".")'
exec 'silent keepjumps g/' . @/ . '/' . expr
endfunction
function! s:Moccur()
" Create the buffer list
redir => command_out
ls
redir END
let buffers = []
for line in split(command_out, '\n')
call add(buffers, split(line, ' ')[0])
endfor
" Search the pattern in all buffers
for buf_number in buffers
exec 'keepjumps buffer ' . buf_number
call s:Occur()
endfor
endfunction
function! s:SetupAndGo(func)
let org_efm = &errorformat
let &errorformat = '%f:%l:%m'
" Clear the results window
cexpr "================= occur result ================="
cclose
" Log the current cursor position
normal! H
" Do Occur
call function(a:func)()
" Open the results window (and restore cursor position)
keepjumps cfirst 1
exec "normal! \<C-o>"
copen
" Map the key sequence on the QuickFix
if !g:occur_no_quickfix_map
nnoremap <buffer> <silent> <Space> <C-w><C-_>
nnoremap <buffer> <silent> x 10<C-w>_<CR>zxzz:copen<CR>
nnoremap <buffer> <silent> <CR> <CR>zxzz:cclose<CR>
nnoremap <buffer> <silent> q :cclose<CR>
endif
let &errorformat = org_efm
endfunction

View File

@@ -1,264 +0,0 @@
*showmarks.txt* Visually show the location of marks
By Anthony Kruize <trandor@labyrinth.net.au>
Michael Geddes <michaelrgeddes@optushome.com.au>
ShowMarks provides a visual representation of |marks| local to a buffer.
Marks are useful for jumping back and forth between interesting points in a
buffer, but can be hard to keep track of without any way to see where you have
placed them.
ShowMarks hopefully makes life easier by placing a |sign| in the
leftmost column of the buffer. The sign indicates the label of the mark and
its location.
ShowMarks is activated by the |CursorHold| |autocommand| which is triggered
every |updatetime| milliseconds. This is set to 4000(4 seconds) by default.
If this is too slow, setting it to a lower value will make it more responsive.
Note: This plugin requires Vim 6.x compiled with the |+signs| feature.
===============================================================================
1. Contents *showmarks* *showmarks-contents*
1. Contents |showmarks-contents|
2. Configuration |showmarks-configuration|
3. Highlighting |showmarks-highlighting|
4. Key mappings |showmarks-mappings|
5. Commands |showmarks-commands|
6. ChangeLog |showmarks-changelog|
Appendix
A. Using marks |marks|
B. Using signs |sign|
C. Defining updatetime |updatetime|
D. Defining a mapleader |mapleader|
E. Defining highlighting |highlight|
===============================================================================
2. Configuration *showmarks-configuration*
ShowMarks can be configured to suit your needs.
The following options can be added to your |vimrc| to change how ShowMarks
behaves:
*'showmarks_enable'*
'showmarks_enable' boolean (default: 1)
global
This option enables or disables ShowMarks on startup. Normally ShowMarks
will be enabled when Vim starts, setting this to 0 will disable ShowMarks
by default.
ShowMarks can be turned back on using the |ShowMarksToggle| command.
*'showmarks_include'*
'showmarks_include' string (default:
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.'`^<>[]{}()\"")
global or local to buffer
This option specifies which marks will be shown and in which order if
placed on the same line. Marks earlier in the list take precedence over
marks later in the list.
This option can also be specified as a buffer option which will override
the global version.
NOTE: When including the " mark, it must be escaped with a \.
For example to only include marks 'abcdefzxABHJio', in that order:
>
let g:showmarks_include="abcdefzxABJio"
<
To override this for a particular buffer with 'ABCDhj.'^':
>
let b:showmarks_include="abcdefzxABJio"
<
*'showmarks_ignore_type'*
'showmarks_ignore_type' string (default: "hq")
global
This option defines which types of buffers should be ignored.
Each type is represented by a letter. This option is not case-sensitive.
Valid buffer types are:
- h : Help
- m : Non-modifiable
- p : Preview
- q : Quickfix
- r : Readonly
For example to ignore help, preview and readonly files:
>
let g:showmarks_ignore_type="hpr"
<
*'showmarks_ignore_name'*
'showmarks_textlower' string (default: ">" )
global
This option defines how the marks a-z will be displayed.
A maximum of two characters can be defined.
To include the mark in the text use a tab(\t) character. A single
character will display as the mark with the character suffixed (same as
"\t<character>"). Specifying two characters will simply display those two
characters.
Some examples:
To display the mark with a > suffixed: >
let g:showmarks_textlower="\t>"
< or >
let g:showmarks_textlower=">"
<
To display the mark with a ( prefixed: >
let g:showmarks_textlower="(\t"
<
To display two > characters: >
let g:showmarks_textlower=">>"
<
*'showmarks_textupper'*
'showmarks_textupper' string (default: ">")
global
This option defines how the marks A-Z will be displayed. It behaves the same
as the |'showmarks_textlower'| option.
*'showmarks_textother'*
'showmarks_textother' string (default: ">")
global
This option defines how all other marks will be displayed. It behaves the
same as the |'showmarks_textlower'| option.
'showmarks_hlline_lower' boolean (default: 0) *'showmarks_hlline_lower'*
global
This option defines whether the entire line a lowercase mark is on will
be highlighted.
'showmarks_hlline_upper' boolean (default: 0) *'showmarks_hlline_upper'*
global
This option defines whether the entire line an uppercase mark is on will
be highlighted.
'showmarks_hlline_other' boolean (default: 0) *'showmarks_hlline_other'*
global
This option defines whether the entire line other marks are on will be
highlighted.
===============================================================================
3. Highlighting *showmarks-highlighting*
Four highlighting groups are used by ShowMarks to define the colours used to
highlight each of the marks.
- ShowMarksHLl : This group is used to highlight all the lowercase marks.
- ShowMarksHLu : This group is used to highlight all the uppercase marks.
- ShowMarksHLo : This group is used to highlight all other marks.
- ShowMarksHLm : This group is used when multiple marks are on the same line.
You can define your own highlighting by overriding these groups in your |vimrc|.
For example: >
highlight ShowMarksHLl guifg=red guibg=green
<
Will set all lowercase marks to be red on green when running in GVim.
See |highlight| for more information.
===============================================================================
4. Mappings *showmarks-mappings*
The following mappings are setup by default:
<Leader>mt - Toggles ShowMarks on and off.
<Leader>mo - Forces ShowMarks on.
<Leader>mh - Clears the mark at the current line.
<Leader>ma - Clears all marks in the current buffer.
<Leader>mm - Places the next available mark on the current line.
(see |mapleader| for how to setup the mapleader variable.)
===============================================================================
5. Commands *showmarks-commands*
*ShowMarksToggle*
:ShowMarksToggle
This command will toggle the display of marks on or off.
:ShowMarksOn *ShowMarksOn*
This command will force the display of marks on.
*ShowMarksClearMark*
:ShowMarksClearMark
This command will clear the mark on the current line.
It doesn't actually remove the mark, it simply moves it to line 1 and
removes the sign.
*ShowMarksClearAll*
:ShowMarksClearAll
This command will clear all marks in the current buffer.
It doesn't actually remove the marks, it simply moves them to line 1 and
removes the signs.
*ShowMarksPlaceMark*
:ShowMarksPlaceMark
This command will place the next available mark on the current line. This
effectively automates mark placement so you don't have to remember which
marks are placed or not. Hidden marks are considered to be available.
NOTE: Only marks a-z are supported by this function.
===============================================================================
6. ChangeLog *showmarks-changelog*
2.2 - 2004-08-17
Fixed highlighting of the A-Z marks when ignorecase is on. (Mike Kelly)
Fixed the delay with ShowMarks triggering when entering a buffer for the
first time. (Mikolaj Machowski)
Added support for highlighting the entire line where a mark is placed.
Now uses HelpExtractor by Charles E. Campbell to install the help file.
2.1 - 2004-03-04
Added ShowMarksOn. It forces ShowMarks to be enabled whether it's on or not.
(Gary Holloway)
Marks now have a definable order of precedence for when mulitple alpha marks
have been placed on the same line. A new highlight group, ShowMarksHLm is
used to identify this situation. (Gary Holloway)
- showmarks_include has changed accordingly.
- ShowMarksHL is now ShowMarksHLl.
ShowMarksPlaceMark now places marks in the order specified by
showmarks_include. (Gary Holloway)
showmarks_include can now be specified per buffer. (Gary Holloway)
2.0 - 2003-08-11
Added ability to ignore buffers by type.
Fixed toggling ShowMarks off when switching buffers.
ShowMarksHideMark and ShowMarksHideAll have been renamed to
ShowMarksClearMark and ShowMarksClearAll.
Marks a-z, A-Z and others now have different highlighting from each other.
Added support for all other marks. (Gary Holloway)
Enhanced customization of how marks are displayed by allowing a prefix to
be specified.(Gary Holloway & Anthony Kruize)
Fixed CursorHold autocmd triggering even when ShowMarks is disabled.
(Charles E. Campbell)
1.5 - 2002-07-16
Added ability to customize how the marks are displayed.
1.4 - 2002-05-29
Added support for placing the next available mark.
(Thanks to Shishir Ramam for the idea)
Added support for hiding all marks.
Marks on line 1 are no longer shown. This stops hidden marks from
reappearing when the file is opened again.
Added a help file.
1.3 - 2002-05-20
Fixed toggling ShowMarks not responding immediately.
Added user commands for toggling/hiding marks.
Added ability to disable ShowMarks by default.
1.2 - 2002-03-06
Added a check that Vim was compiled with +signs support.
Added the ability to define which marks are shown.
Removed debugging code that was accidently left in.
1.1 - 2002-02-05
Added support for the A-Z marks.
Fixed sign staying placed if the line it was on is deleted.
Clear autocommands before making new ones.
1.0 - 2001-11-20
First release.
vim:tw=78:ts=8:ft=help

View File

@@ -1,507 +0,0 @@
" ==============================================================================
" Name: ShowMarks
" Description: Visually displays the location of marks.
" Authors: Anthony Kruize <trandor@labyrinth.net.au>
" Michael Geddes <michaelrgeddes@optushome.com.au>
" Version: 2.2
" Modified: 17 August 2004
" License: Released into the public domain.
" ChangeLog: See :help showmarks-changelog
"
" Usage: Copy this file into the plugins directory so it will be
" automatically sourced.
"
" Default keymappings are:
" <Leader>mt - Toggles ShowMarks on and off.
" <Leader>mo - Turns ShowMarks on, and displays marks.
" <Leader>mh - Clears a mark.
" <Leader>ma - Clears all marks.
" <Leader>mm - Places the next available mark.
"
" Hiding a mark doesn't actually remove it, it simply moves it
" to line 1 and hides it visually.
"
" Configuration: ***********************************************************
" * PLEASE read the included help file(showmarks.txt) for a *
" * more thorough explanation of how to use ShowMarks. *
" ***********************************************************
" The following options can be used to customize the behavior
" of ShowMarks. Simply include them in your vimrc file with
" the desired settings.
"
" showmarks_enable (Default: 1)
" Defines whether ShowMarks is enabled by default.
" Example: let g:showmarks_enable=0
" showmarks_include (Default: "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.'`^<>[]{}()\"")
" Defines all marks, in precedence order (only the highest
" precence will show on lines having more than one mark).
" Can be buffer-specific (set b:showmarks_include)
" showmarks_ignore_type (Default: "hq")
" Defines the buffer types to be ignored.
" Valid types are:
" h - Help p - preview
" q - quickfix r - readonly
" m - non-modifiable
" showmarks_textlower (Default: ">")
" Defines how the mark is to be displayed.
" A maximum of two characters can be displayed. To include
" the mark in the text use a tab(\t) character. A single
" character will display as the mark with the character
" suffixed (same as "\t<character>")
" Examples:
" To display the mark with a > suffixed:
" let g:showmarks_textlower="\t>"
" or
" let g:showmarks_textlower=">"
" To display the mark with a ( prefixed:
" let g:showmarks_textlower="(\t"
" To display two > characters:
" let g:showmarks_textlower=">>"
" showmarks_textupper (Default: ">")
" Same as above but for the marks A-Z.
" Example: let g:showmarks_textupper="**"
" showmarks_textother (Default: ">")
" Same as above but for all other marks.
" Example: let g:showmarks_textother="--"
" showmarks_hlline_lower (Default: 0)
" showmarks_hlline_upper (Default: 0)
" showmarks_hlline_other (Default: 0)
" Defines whether the entire line for a particular mark
" should be highlighted.
" Example: let g:showmarks_hlline_lower=1
"
" Setting Highlighting Colours
" ShowMarks uses the following highlighting groups:
" ShowMarksHLl - For marks a-z
" ShowMarksHLu - For marks A-Z
" ShowMarksHLo - For all other marks
" ShowMarksHLm - For multiple marks on the same line.
" (Highest precendece mark is shown)
"
" By default they are set to a bold blue on light blue.
" Defining a highlight for each of these groups will
" override the default highlighting.
" See the VIM help for more information about highlighting.
" ==============================================================================
" Check if we should continue loading
if exists( "loaded_showmarks" )
finish
endif
let loaded_showmarks = 1
" Bail if Vim isn't compiled with signs support.
if has( "signs" ) == 0
echohl ErrorMsg
echo "ShowMarks requires Vim to have +signs support."
echohl None
finish
endif
" Options: Set up some nice defaults
if !exists('g:showmarks_enable' ) | let g:showmarks_enable = 1 | endif
if !exists('g:showmarks_textlower' ) | let g:showmarks_textlower = ">" | endif
if !exists('g:showmarks_textupper' ) | let g:showmarks_textupper = ">" | endif
if !exists('g:showmarks_textother' ) | let g:showmarks_textother = ">" | endif
if !exists('g:showmarks_ignore_type' ) | let g:showmarks_ignore_type = "hq" | endif
if !exists('g:showmarks_ignore_name' ) | let g:showmarks_ignore_name = "" | endif
if !exists('g:showmarks_hlline_lower') | let g:showmarks_hlline_lower = "0" | endif
if !exists('g:showmarks_hlline_upper') | let g:showmarks_hlline_upper = "0" | endif
if !exists('g:showmarks_hlline_other') | let g:showmarks_hlline_other = "0" | endif
" This is the default, and used in ShowMarksSetup to set up info for any
" possible mark (not just those specified in the possibly user-supplied list
" of marks to show -- it can be changed on-the-fly).
let s:all_marks = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.'`^<>[]{}()\""
" Commands
com! -nargs=0 ShowMarksToggle :call <sid>ShowMarksToggle()
com! -nargs=0 ShowMarksOn :call <sid>ShowMarksOn()
com! -nargs=0 ShowMarksClearMark :call <sid>ShowMarksClearMark()
com! -nargs=0 ShowMarksClearAll :call <sid>ShowMarksClearAll()
com! -nargs=0 ShowMarksPlaceMark :call <sid>ShowMarksPlaceMark()
" Mappings (NOTE: Leave the '|'s immediately following the '<cr>' so the mapping does not contain any trailing spaces!)
if !hasmapto( '<Plug>ShowmarksShowMarksToggle' ) | map <silent> <unique> <leader>mt :ShowMarksToggle<cr>| endif
if !hasmapto( '<Plug>ShowmarksShowMarksOn' ) | map <silent> <unique> <leader>mo :ShowMarksOn<cr>| endif
if !hasmapto( '<Plug>ShowmarksClearMark' ) | map <silent> <unique> <leader>mh :ShowMarksClearMark<cr>| endif
if !hasmapto( '<Plug>ShowmarksClearAll' ) | map <silent> <unique> <leader>ma :ShowMarksClearAll<cr>| endif
if !hasmapto( '<Plug>ShowmarksPlaceMark' ) | map <silent> <unique> <leader>mm :ShowMarksPlaceMark<cr>| endif
noremap <unique> <script> \sm m
noremap <silent> m :exe 'norm \sm'.nr2char(getchar())<bar>call <sid>ShowMarks()<CR>
" AutoCommands: Only if ShowMarks is enabled
if g:showmarks_enable == 1
aug ShowMarks
au!
autocmd CursorHold * call s:ShowMarks()
aug END
endif
" Highlighting: Setup some nice colours to show the mark positions.
hi default ShowMarksHLl ctermfg=darkblue ctermbg=blue cterm=bold guifg=blue guibg=lightblue gui=bold
hi default ShowMarksHLu ctermfg=darkblue ctermbg=blue cterm=bold guifg=blue guibg=lightblue gui=bold
hi default ShowMarksHLo ctermfg=darkblue ctermbg=blue cterm=bold guifg=blue guibg=lightblue gui=bold
hi default ShowMarksHLm ctermfg=darkblue ctermbg=blue cterm=bold guifg=blue guibg=lightblue gui=bold
" Function: IncludeMarks()
" Description: This function returns the list of marks (in priority order) to
" show in this buffer. Each buffer, if not already set, inherits the global
" setting; if the global include marks have not been set; that is set to the
" default value.
fun! s:IncludeMarks()
if exists('b:showmarks_include') && exists('b:showmarks_previous_include') && b:showmarks_include != b:showmarks_previous_include
" The user changed the marks to include; hide all marks; change the
" included mark list, then show all marks. Prevent infinite
" recursion during this switch.
if exists('s:use_previous_include')
" Recursive call from ShowMarksHideAll()
return b:showmarks_previous_include
elseif exists('s:use_new_include')
" Recursive call from ShowMarks()
return b:showmarks_include
else
let s:use_previous_include = 1
call <sid>ShowMarksHideAll()
unlet s:use_previous_include
let s:use_new_include = 1
call <sid>ShowMarks()
unlet s:use_new_include
endif
endif
if !exists('g:showmarks_include')
let g:showmarks_include = s:all_marks
endif
if !exists('b:showmarks_include')
let b:showmarks_include = g:showmarks_include
endif
" Save this include setting so we can detect if it was changed.
let b:showmarks_previous_include = b:showmarks_include
return b:showmarks_include
endf
" Function: NameOfMark()
" Paramaters: mark - Specifies the mark to find the name of.
" Description: Convert marks that cannot be used as part of a variable name to
" something that can be. i.e. We cannot use [ as a variable-name suffix (as
" in 'placed_['; this function will return something like 63, so the variable
" will be something like 'placed_63').
" 10 is added to the mark's index to avoid colliding with the numeric marks
" 0-9 (since a non-word mark could be listed in showmarks_include in the
" first 10 characters if the user overrides the default).
" Returns: The name of the requested mark.
fun! s:NameOfMark(mark)
let name = a:mark
if a:mark =~# '\W'
let name = stridx(s:all_marks, a:mark) + 10
endif
return name
endf
" Function: VerifyText()
" Paramaters: which - Specifies the variable to verify.
" Description: Verify the validity of a showmarks_text{upper,lower,other} setup variable.
" Default to ">" if it is found to be invalid.
fun! s:VerifyText(which)
if strlen(g:showmarks_text{a:which}) == 0 || strlen(g:showmarks_text{a:which}) > 2
echohl ErrorMsg
echo "ShowMarks: text".a:which." must contain only 1 or 2 characters."
echohl None
let g:showmarks_text{a:which}=">"
endif
endf
" Function: ShowMarksSetup()
" Description: This function sets up the sign definitions for each mark.
" It uses the showmarks_textlower, showmarks_textupper and showmarks_textother
" variables to determine how to draw the mark.
fun! s:ShowMarksSetup()
" Make sure the textlower, textupper, and textother options are valid.
call s:VerifyText('lower')
call s:VerifyText('upper')
call s:VerifyText('other')
let n = 0
let s:maxmarks = strlen(s:all_marks)
while n < s:maxmarks
let c = strpart(s:all_marks, n, 1)
let nm = s:NameOfMark(c)
let text = '>'.c
let lhltext = ''
if c =~# '[a-z]'
if strlen(g:showmarks_textlower) == 1
let text=c.g:showmarks_textlower
elseif strlen(g:showmarks_textlower) == 2
let t1 = strpart(g:showmarks_textlower,0,1)
let t2 = strpart(g:showmarks_textlower,1,1)
if t1 == "\t"
let text=c.t2
elseif t2 == "\t"
let text=t1.c
else
let text=g:showmarks_textlower
endif
endif
let s:ShowMarksDLink{nm} = 'ShowMarksHLl'
if g:showmarks_hlline_lower == 1
let lhltext = 'linehl='.s:ShowMarksDLink{nm}.nm
endif
elseif c =~# '[A-Z]'
if strlen(g:showmarks_textupper) == 1
let text=c.g:showmarks_textupper
elseif strlen(g:showmarks_textupper) == 2
let t1 = strpart(g:showmarks_textupper,0,1)
let t2 = strpart(g:showmarks_textupper,1,1)
if t1 == "\t"
let text=c.t2
elseif t2 == "\t"
let text=t1.c
else
let text=g:showmarks_textupper
endif
endif
let s:ShowMarksDLink{nm} = 'ShowMarksHLu'
if g:showmarks_hlline_upper == 1
let lhltext = 'linehl='.s:ShowMarksDLink{nm}.nm
endif
else " Other signs, like ', ., etc.
if strlen(g:showmarks_textother) == 1
let text=c.g:showmarks_textother
elseif strlen(g:showmarks_textother) == 2
let t1 = strpart(g:showmarks_textother,0,1)
let t2 = strpart(g:showmarks_textother,1,1)
if t1 == "\t"
let text=c.t2
elseif t2 == "\t"
let text=t1.c
else
let text=g:showmarks_textother
endif
endif
let s:ShowMarksDLink{nm} = 'ShowMarksHLo'
if g:showmarks_hlline_other == 1
let lhltext = 'linehl='.s:ShowMarksDLink{nm}.nm
endif
endif
" Define the sign with a unique highlight which will be linked when placed.
exe 'sign define ShowMark'.nm.' '.lhltext.' text='.text.' texthl='.s:ShowMarksDLink{nm}.nm
let b:ShowMarksLink{nm} = ''
let n = n + 1
endw
endf
" Set things up
call s:ShowMarksSetup()
" Function: ShowMarksOn
" Description: Enable showmarks, and show them now.
fun! s:ShowMarksOn()
if g:showmarks_enable == 0
call <sid>ShowMarksToggle()
else
call <sid>ShowMarks()
endif
endf
" Function: ShowMarksToggle()
" Description: This function toggles whether marks are displayed or not.
fun! s:ShowMarksToggle()
if g:showmarks_enable == 0
let g:showmarks_enable = 1
call <sid>ShowMarks()
aug ShowMarks
au!
autocmd CursorHold * call s:ShowMarks()
aug END
else
let g:showmarks_enable = 0
call <sid>ShowMarksHideAll()
aug ShowMarks
au!
autocmd BufEnter * call s:ShowMarksHideAll()
aug END
endif
endf
" Function: ShowMarks()
" Description: This function runs through all the marks and displays or
" removes signs as appropriate. It is called on the CursorHold autocommand.
" We use the marked_{ln} variables (containing a timestamp) to track what marks
" we've shown (placed) in this call to ShowMarks; to only actually place the
" first mark on any particular line -- this forces only the first mark
" (according to the order of showmarks_include) to be shown (i.e., letters
" take precedence over marks like paragraph and sentence.)
fun! s:ShowMarks()
if g:showmarks_enable == 0
return
endif
if ((match(g:showmarks_ignore_type, "[Hh]") > -1) && (&buftype == "help" ))
\ || ((match(g:showmarks_ignore_type, "[Qq]") > -1) && (&buftype == "quickfix"))
\ || ((match(g:showmarks_ignore_type, "[Pp]") > -1) && (&pvw == 1 ))
\ || ((match(g:showmarks_ignore_type, "[Rr]") > -1) && (&readonly == 1 ))
\ || ((match(g:showmarks_ignore_type, "[Mm]") > -1) && (&modifiable == 0 ))
return
endif
let n = 0
let s:maxmarks = strlen(s:IncludeMarks())
while n < s:maxmarks
let c = strpart(s:IncludeMarks(), n, 1)
let nm = s:NameOfMark(c)
let id = n + (s:maxmarks * winbufnr(0))
let ln = line("'".c)
if ln == 0 && (exists('b:placed_'.nm) && b:placed_{nm} != ln)
exe 'sign unplace '.id.' buffer='.winbufnr(0)
elseif ln > 1 || c !~ '[a-zA-Z]'
" Have we already placed a mark here in this call to ShowMarks?
if exists('mark_at'.ln)
" Already placed a mark, set the highlight to multiple
if c =~# '[a-zA-Z]' && b:ShowMarksLink{mark_at{ln}} != 'ShowMarksHLm'
let b:ShowMarksLink{mark_at{ln}} = 'ShowMarksHLm'
exe 'hi link '.s:ShowMarksDLink{mark_at{ln}}.mark_at{ln}.' '.b:ShowMarksLink{mark_at{ln}}
endif
else
if !exists('b:ShowMarksLink'.nm) || b:ShowMarksLink{nm} != s:ShowMarksDLink{nm}
let b:ShowMarksLink{nm} = s:ShowMarksDLink{nm}
exe 'hi link '.s:ShowMarksDLink{nm}.nm.' '.b:ShowMarksLink{nm}
endif
let mark_at{ln} = nm
if !exists('b:placed_'.nm) || b:placed_{nm} != ln
exe 'sign unplace '.id.' buffer='.winbufnr(0)
exe 'sign place '.id.' name=ShowMark'.nm.' line='.ln.' buffer='.winbufnr(0)
let b:placed_{nm} = ln
endif
endif
endif
let n = n + 1
endw
endf
" Function: ShowMarksClearMark()
" Description: This function hides the mark at the current line.
" It simply moves the mark to line 1 and removes the sign.
" Only marks a-z and A-Z are supported.
fun! s:ShowMarksClearMark()
let ln = line(".")
let n = 0
let s:maxmarks = strlen(s:IncludeMarks())
while n < s:maxmarks
let c = strpart(s:IncludeMarks(), n, 1)
if c =~# '[a-zA-Z]' && ln == line("'".c)
let nm = s:NameOfMark(c)
let id = n + (s:maxmarks * winbufnr(0))
exe 'sign unplace '.id.' buffer='.winbufnr(0)
exe '1 mark '.c
let b:placed_{nm} = 1
endif
let n = n + 1
endw
endf
" Function: ShowMarksClearAll()
" Description: This function clears all marks in the buffer.
" It simply moves the marks to line 1 and removes the signs.
" Only marks a-z and A-Z are supported.
fun! s:ShowMarksClearAll()
let n = 0
let s:maxmarks = strlen(s:IncludeMarks())
while n < s:maxmarks
let c = strpart(s:IncludeMarks(), n, 1)
if c =~# '[a-zA-Z]'
let nm = s:NameOfMark(c)
let id = n + (s:maxmarks * winbufnr(0))
exe 'sign unplace '.id.' buffer='.winbufnr(0)
exe '1 mark '.c
let b:placed_{nm} = 1
endif
let n = n + 1
endw
endf
" Function: ShowMarksHideAll()
" Description: This function hides all marks in the buffer.
" It simply removes the signs.
fun! s:ShowMarksHideAll()
let n = 0
let s:maxmarks = strlen(s:IncludeMarks())
while n < s:maxmarks
let c = strpart(s:IncludeMarks(), n, 1)
let nm = s:NameOfMark(c)
if exists('b:placed_'.nm)
let id = n + (s:maxmarks * winbufnr(0))
exe 'sign unplace '.id.' buffer='.winbufnr(0)
unlet b:placed_{nm}
endif
let n = n + 1
endw
endf
" Function: ShowMarksPlaceMark()
" Description: This function will place the next unplaced mark (in priority
" order) to the current location. The idea here is to automate the placement
" of marks so the user doesn't have to remember which marks are placed or not.
" Hidden marks are considered to be unplaced.
" Only marks a-z are supported.
fun! s:ShowMarksPlaceMark()
" Find the first, next, and last [a-z] mark in showmarks_include (i.e.
" priority order), so we know where to "wrap".
let first_alpha_mark = -1
let last_alpha_mark = -1
let next_mark = -1
if !exists('b:previous_auto_mark')
let b:previous_auto_mark = -1
endif
" Find the next unused [a-z] mark (in priority order); if they're all
" used, find the next one after the previously auto-assigned mark.
let n = 0
let s:maxmarks = strlen(s:IncludeMarks())
while n < s:maxmarks
let c = strpart(s:IncludeMarks(), n, 1)
if c =~# '[a-z]'
if line("'".c) <= 1
" Found an unused [a-z] mark; we're done.
let next_mark = n
break
endif
if first_alpha_mark < 0
let first_alpha_mark = n
endif
let last_alpha_mark = n
if n > b:previous_auto_mark && next_mark == -1
let next_mark = n
endif
endif
let n = n + 1
endw
if next_mark == -1 && (b:previous_auto_mark == -1 || b:previous_auto_mark == last_alpha_mark)
" Didn't find an unused mark, and haven't placed any auto-chosen marks yet,
" or the previously placed auto-chosen mark was the last alpha mark --
" use the first alpha mark this time.
let next_mark = first_alpha_mark
endif
if (next_mark == -1)
echohl WarningMsg
echo 'No marks in [a-z] included! (No "next mark" to choose from)'
echohl None
return
endif
let c = strpart(s:IncludeMarks(), next_mark, 1)
let b:previous_auto_mark = next_mark
exe 'mark '.c
call <sid>ShowMarks()
endf
" -----------------------------------------------------------------------------
" vim:ts=4:sw=4:noet

View File

@@ -1,67 +0,0 @@
README for fitnesse.vim (Version 0.1) / May 22 2009
* INSTALLATION
* RELEASE NOTES
* CREDITS
fitnesse.vim is a syntax file (and eventually some filetype specific functions)
for editing FitNesse tests using Vim. It was created to make it easier to work
with fitnesse files. It works great in conjunction with "It's All Text" a
plugin for FireFox (found at https://addons.mozilla.org/en-US/firefox/addon/4125).
FitNesse is a collaborative testing tool that uses Wiki markup to create test
scripts as web pages. See http://fitnesse.org for more information.
This release is very Slim centric.
INSTALLATION
------------------------
The files in the Zip file are stored in the same folders they need to be
placed in under the vimfiles folder ( $HOME/.vim/ or %VIM%\vimfils depending
on your OS).
1) Unzip the fitnesse.vim.zip file to the vimfiles folder. Unless you are
customizing the file, you should be OK to overwrite the files.
2) Syntax coloring support must be enabled.
You can do this by adding :syntax enable to your _vimrc or .vimrc file.
3) If you want automatic detection you will need to:
a) Check to see if you have a scripts.vim file already in place. This
file allows post loading checking of files to execute scripts.
b) If you do not have a scripts.vim file in your vimfiles folder, rename
the scripts.vim.add file to scripts.vim.
c) If you do have a scripts.vim file; open the scripts.vim.fitnesse_add
file and copy the text in that file to your scripts.vim file.
RELEASE NOTES
------------------------
Version 0.1:
This release supports the following syntax:
* Numerous keywords in Slim and FitNesse are supported:
scenario, script, Query:, start, check, reject, show, Comment, comment,
!see, !include, !See, null, !define, !include
* Simple collapsible sections (with folding enabled) !** *!, !**> *!
* Table cell delimiter "|"
* Cell contents
* Incomplete cell is error
* !style_(class)
* Strings in Quotes
* Scenario variables @parametername
* Symbols $symbolname
* Simple WikiWord support
CREDITS
------------------------
* Bob Martin for FitNesse and Slim
* Brett Schuchert for Recommending It's All Text

View File

@@ -1,4 +0,0 @@
if getline(1) =~ '^#fitnesse'
setfiletype fitnesse
endif
f

View File

@@ -1,62 +0,0 @@
" fitnesse.vim
" @author: Dan Woodward (dan DOT woodward AT gmail.com)
if version < 600
syntax clear
elseif exists("b:current_syntax")
finish
endif
let b:fitnesseEnabled = 1
syntax sync minlines=2
syn match collapsibleSectionStart /!\*\+.*/
syn match collapsibleSectionEnd /\*\+!.*/
syn match bracesAndBrackets "|\|{\|}\|\[\|\]"
syn match bang /!/
syn match literalText /!-.\{-}-!/
syn match openCell /|[^|]\+\n/hs=s+1
syn region colapsableFold start="!\*\{1,}" end="\*!" fold transparent keepend extend
syn sync fromstart
set foldmethod=syntax
syn region cellContents start=+|+hs=s+1 end=+|+he=e-1 oneline contains=ALL
syn region styledText start=+\[+hs=s+1 end=+\]+he=e-1 oneline contains=ALL
syn region styledText2 start=+{+hs=s+1 end=+}+he=e-1 oneline contains=ALL
syn region styledText3 start=+(+hs=s+1 end=+)+he=e-1 oneline contains=ALL
syn region Comment start=/#/ end=/\n/
syn match String /"[^"]\+"/ contains=Identifier
syn match String /'[^']\+'/ contains=Identifier
syn match symbol /$\w*/
syn match extractVariable /${[^}]*}/
syn match bold /'''.*'''/
syn region heading start=/!\d/ end=/\n/
syn match widget /!\w\+[\[{(]/me=e-1,he=e-1
syn match Keyword /!define /
syn match Keyword /!include /
syn keyword Keyword scenario script Query: start check reject show Comment comment !see !include !See null
syn match scenarioVariable /@\w\+/
syn match wikiWord /\<[A-Z][a-z]\+[A-Za-z]*[A-Z]\+[A-Za-z]*\>/
highlight link collapsibleSectionStart Delimiter
highlight link collapsibleSectionEnd Delimiter
highlight link bracesAndBrackets Delimiter
highlight link cellContents Macro
highlight link bang Delimiter
highlight link styledText Type
highlight link styledText2 Type
highlight link styledText3 Type
highlight link literalText Special
highlight link symbol Identifier
highlight link extractVariable Identifier
highlight link bold Constant
highlight link heading Constant
highlight link scenarioVariable Identifier
highlight link styleMarker Special
highlight link widget Statement
highlight link wikiWord Underlined
highlight link openCell Error
let b:current_syntax = "fitnesse"

File diff suppressed because it is too large Load Diff

View File

@@ -1,11 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<link rel="Stylesheet" type="text/css" href="%root_path%%css%">
<title>%title%</title>
<meta http-equiv="Content-Type" content="text/html; charset=%encoding%">
</head>
<body>
%content%
</body>
</html>

View File

@@ -1,358 +0,0 @@
" vim:tabstop=2:shiftwidth=2:expandtab:foldmethod=marker:textwidth=79
" Vimwiki autoload plugin file
" Desc: Handle diary notes
" Author: Maxim Kim <habamax@gmail.com>
" Home: http://code.google.com/p/vimwiki/
" Load only once {{{
if exists("g:loaded_vimwiki_diary_auto") || &cp
finish
endif
let g:loaded_vimwiki_diary_auto = 1
"}}}
let s:vimwiki_max_scan_for_caption = 5
" Helpers {{{
function! s:prefix_zero(num) "{{{
if a:num < 10
return '0'.a:num
endif
return a:num
endfunction "}}}
function! s:get_date_link(fmt) "{{{
return strftime(a:fmt)
endfunction "}}}
function! s:link_exists(lines, link) "{{{
let link_exists = 0
for line in a:lines
if line =~ escape(a:link, '[]\')
let link_exists = 1
break
endif
endfor
return link_exists
endfunction "}}}
function! s:diary_path(...) "{{{
let idx = a:0 == 0 ? g:vimwiki_current_idx : a:1
return VimwikiGet('path', idx).VimwikiGet('diary_rel_path', idx)
endfunction "}}}
function! s:diary_index(...) "{{{
let idx = a:0 == 0 ? g:vimwiki_current_idx : a:1
return s:diary_path(idx).VimwikiGet('diary_index', idx).VimwikiGet('ext', idx)
endfunction "}}}
function! s:diary_date_link(...) "{{{
let idx = a:0 == 0 ? g:vimwiki_current_idx : a:1
return s:get_date_link(VimwikiGet('diary_link_fmt', idx))
endfunction "}}}
function! s:get_position_links(link) "{{{
let idx = -1
let links = []
if a:link =~ '^\d\{4}-\d\d-\d\d'
let links = keys(s:get_diary_links())
" include 'today' into links
if index(links, s:diary_date_link()) == -1
call add(links, s:diary_date_link())
endif
call sort(links)
let idx = index(links, a:link)
endif
return [idx, links]
endfunction "}}}
fun! s:get_month_name(month) "{{{
return g:vimwiki_diary_months[str2nr(a:month)]
endfun "}}}
" Helpers }}}
" Diary index stuff {{{
fun! s:read_captions(files) "{{{
let result = {}
for fl in a:files
" remove paths and extensions
let fl_key = fnamemodify(fl, ':t:r')
if filereadable(fl)
for line in readfile(fl, '', s:vimwiki_max_scan_for_caption)
if line =~ g:vimwiki_rxHeader && !has_key(result, fl_key)
let result[fl_key] = vimwiki#u#trim(matchstr(line, g:vimwiki_rxHeader))
endif
endfor
endif
if !has_key(result, fl_key)
let result[fl_key] = ''
endif
endfor
return result
endfun "}}}
fun! s:get_diary_links(...) "{{{
let rx = '^\d\{4}-\d\d-\d\d'
let s_files = glob(VimwikiGet('path').VimwikiGet('diary_rel_path').'*'.VimwikiGet('ext'))
let files = split(s_files, '\n')
call filter(files, 'fnamemodify(v:val, ":t") =~ "'.escape(rx, '\').'"')
" remove backup files (.wiki~)
call filter(files, 'v:val !~ ''.*\~$''')
if a:0
call add(files, a:1)
endif
let links_with_captions = s:read_captions(files)
return links_with_captions
endfun "}}}
fun! s:group_links(links) "{{{
let result = {}
let p_year = 0
let p_month = 0
for fl in sort(keys(a:links))
let year = strpart(fl, 0, 4)
let month = strpart(fl, 5, 2)
if p_year != year
let result[year] = {}
let p_month = 0
endif
if p_month != month
let result[year][month] = {}
endif
let result[year][month][fl] = a:links[fl]
let p_year = year
let p_month = month
endfor
return result
endfun "}}}
fun! s:sort(lst) "{{{
if VimwikiGet("diary_sort") == 'desc'
return reverse(sort(a:lst))
else
return sort(a:lst)
endif
endfun "}}}
fun! s:format_diary(...) "{{{
let result = []
call add(result, substitute(g:vimwiki_rxH1_Template, '__Header__', VimwikiGet('diary_header'), ''))
if a:0
let g_files = s:group_links(s:get_diary_links(a:1))
else
let g_files = s:group_links(s:get_diary_links())
endif
" for year in s:rev(sort(keys(g_files)))
for year in s:sort(keys(g_files))
call add(result, '')
call add(result, substitute(g:vimwiki_rxH2_Template, '__Header__', year , ''))
" for month in s:rev(sort(keys(g_files[year])))
for month in s:sort(keys(g_files[year]))
call add(result, '')
call add(result, substitute(g:vimwiki_rxH3_Template, '__Header__', s:get_month_name(month), ''))
" for [fl, cap] in s:rev(sort(items(g_files[year][month])))
for [fl, cap] in s:sort(items(g_files[year][month]))
if empty(cap)
let entry = substitute(g:vimwiki_WikiLinkTemplate1, '__LinkUrl__', fl, '')
let entry = substitute(entry, '__LinkDescription__', cap, '')
call add(result, repeat(' ', &sw).'* '.entry)
else
let entry = substitute(g:vimwiki_WikiLinkTemplate2, '__LinkUrl__', fl, '')
let entry = substitute(entry, '__LinkDescription__', cap, '')
call add(result, repeat(' ', &sw).'* '.entry)
endif
endfor
endfor
endfor
call add(result, '')
return result
endfun "}}}
function! s:delete_diary_section() "{{{
" remove diary section
let old_pos = getpos('.')
let ln_start = -1
let ln_end = -1
call cursor(1, 1)
if search(substitute(g:vimwiki_rxH1_Template, '__Header__', VimwikiGet('diary_header'), ''), 'Wc')
let ln_start = line('.')
if search(g:vimwiki_rxH1, 'W')
let ln_end = line('.') - 1
else
let ln_end = line('$')
endif
endif
if ln_start < 0 || ln_end < 0
call setpos('.', old_pos)
return
endif
if !&readonly
exe ln_start.",".ln_end."delete _"
endif
call setpos('.', old_pos)
endfunction "}}}
function! s:insert_diary_section() "{{{
if !&readonly
let ln = line('.')
call append(ln, s:format_diary())
if ln == 1 && getline(ln) == ''
1,1delete
endif
endif
endfunction "}}}
" Diary index stuff }}}
function! vimwiki#diary#make_note(wnum, ...) "{{{
if a:wnum > len(g:vimwiki_list)
echom "vimwiki: Wiki ".a:wnum." is not registered in g:vimwiki_list!"
return
endif
" TODO: refactor it. base#goto_index uses the same
if a:wnum > 0
let idx = a:wnum - 1
else
let idx = 0
endif
call vimwiki#base#validate_wiki_options(idx)
call vimwiki#base#mkdir(VimwikiGet('path', idx).VimwikiGet('diary_rel_path', idx))
if a:0 && a:1 == 1
let cmd = 'tabedit'
else
let cmd = 'edit'
endif
if a:0>1
let link = 'diary:'.a:2
else
let link = 'diary:'.s:diary_date_link(idx)
endif
call vimwiki#base#open_link(cmd, link, s:diary_index(idx))
call vimwiki#base#setup_buffer_state(idx)
endfunction "}}}
function! vimwiki#diary#goto_diary_index(wnum) "{{{
if a:wnum > len(g:vimwiki_list)
echom "vimwiki: Wiki ".a:wnum." is not registered in g:vimwiki_list!"
return
endif
" TODO: refactor it. base#goto_index uses the same
if a:wnum > 0
let idx = a:wnum - 1
else
let idx = 0
endif
call vimwiki#base#validate_wiki_options(idx)
call vimwiki#base#edit_file('e', s:diary_index(idx))
call vimwiki#base#setup_buffer_state(idx)
endfunction "}}}
function! vimwiki#diary#goto_next_day() "{{{
let link = ''
let [idx, links] = s:get_position_links(expand('%:t:r'))
if idx == (len(links) - 1)
return
endif
if idx != -1 && idx < len(links) - 1
let link = 'diary:'.links[idx+1]
else
" goto today
let link = 'diary:'.s:diary_date_link()
endif
if len(link)
call vimwiki#base#open_link(':e ', link)
endif
endfunction "}}}
function! vimwiki#diary#goto_prev_day() "{{{
let link = ''
let [idx, links] = s:get_position_links(expand('%:t:r'))
if idx == 0
return
endif
if idx > 0
let link = 'diary:'.links[idx-1]
else
" goto today
let link = 'diary:'.s:diary_date_link()
endif
if len(link)
call vimwiki#base#open_link(':e ', link)
endif
endfunction "}}}
function! vimwiki#diary#generate_diary_section() "{{{
let current_file = vimwiki#u#path_norm(expand("%:p"))
let diary_file = vimwiki#u#path_norm(s:diary_index())
if current_file == diary_file
call s:delete_diary_section()
call s:insert_diary_section()
else
echom "vimwiki: You can generate diary links only in a diary index page!"
endif
endfunction "}}}
" Calendar.vim {{{
" Callback function.
function! vimwiki#diary#calendar_action(day, month, year, week, dir) "{{{
let day = s:prefix_zero(a:day)
let month = s:prefix_zero(a:month)
let link = a:year.'-'.month.'-'.day
if winnr('#') == 0
if a:dir == 'V'
vsplit
else
split
endif
else
wincmd p
if !&hidden && &modified
new
endif
endif
" Create diary note for a selected date in default wiki.
call vimwiki#diary#make_note(1, 0, link)
endfunction "}}}
" Sign function.
function vimwiki#diary#calendar_sign(day, month, year) "{{{
let day = s:prefix_zero(a:day)
let month = s:prefix_zero(a:month)
let sfile = VimwikiGet('path').VimwikiGet('diary_rel_path').
\ a:year.'-'.month.'-'.day.VimwikiGet('ext')
return filereadable(expand(sfile))
endfunction "}}}
" Calendar.vim }}}

File diff suppressed because it is too large Load Diff

View File

@@ -1,555 +0,0 @@
" vim:tabstop=2:shiftwidth=2:expandtab:foldmethod=marker:textwidth=79
" Vimwiki autoload plugin file
" Todo lists related stuff here.
" Author: Maxim Kim <habamax@gmail.com>
" Home: http://code.google.com/p/vimwiki/
if exists("g:loaded_vimwiki_list_auto") || &cp
finish
endif
let g:loaded_vimwiki_lst_auto = 1
" Script variables {{{
let s:rx_li_box = '\[.\?\]'
" }}}
" Script functions {{{
" Get unicode string symbol at index
function! s:str_idx(str, idx) "{{{
" Unfortunatly vimscript cannot get symbol at index in unicode string such as
" '✗○◐●✓'
return matchstr(a:str, '\%'.a:idx.'v.')
endfunction "}}}
" Get checkbox regexp
function! s:rx_li_symbol(rate) "{{{
let result = ''
if a:rate == 100
let result = s:str_idx(g:vimwiki_listsyms, 5)
elseif a:rate == 0
let result = s:str_idx(g:vimwiki_listsyms, 1)
elseif a:rate >= 67
let result = s:str_idx(g:vimwiki_listsyms, 4)
elseif a:rate >= 34
let result = s:str_idx(g:vimwiki_listsyms, 3)
else
let result = s:str_idx(g:vimwiki_listsyms, 2)
endif
return '\['.result.'\]'
endfunction "}}}
" Get blank checkbox
function! s:blank_checkbox() "{{{
return '['.s:str_idx(g:vimwiki_listsyms, 1).'] '
endfunction "}}}
" Get regexp of the list item.
function! s:rx_list_item() "{{{
return '\('.g:vimwiki_rxListBullet.'\|'.g:vimwiki_rxListNumber.'\)'
endfunction "}}}
" Get regexp of the list item with checkbox.
function! s:rx_cb_list_item() "{{{
return s:rx_list_item().'\s*\zs\[.\?\]'
endfunction "}}}
" Get level of the list item.
function! s:get_level(lnum) "{{{
if VimwikiGet('syntax') == 'media'
let level = vimwiki#u#count_first_sym(getline(a:lnum))
else
let level = indent(a:lnum)
endif
return level
endfunction "}}}
" Get previous list item.
" Returns: line number or 0.
function! s:prev_list_item(lnum) "{{{
let c_lnum = a:lnum - 1
while c_lnum >= 1
let line = getline(c_lnum)
if line =~ s:rx_list_item()
return c_lnum
endif
if line =~ '^\s*$'
return 0
endif
let c_lnum -= 1
endwhile
return 0
endfunction "}}}
" Get next list item in the list.
" Returns: line number or 0.
function! s:next_list_item(lnum) "{{{
let c_lnum = a:lnum + 1
while c_lnum <= line('$')
let line = getline(c_lnum)
if line =~ s:rx_list_item()
return c_lnum
endif
if line =~ '^\s*$'
return 0
endif
let c_lnum += 1
endwhile
return 0
endfunction "}}}
" Find next list item in the buffer.
" Returns: line number or 0.
function! s:find_next_list_item(lnum) "{{{
let c_lnum = a:lnum + 1
while c_lnum <= line('$')
let line = getline(c_lnum)
if line =~ s:rx_list_item()
return c_lnum
endif
let c_lnum += 1
endwhile
return 0
endfunction "}}}
" Set state of the list item on line number "lnum" to [ ] or [x]
function! s:set_state(lnum, rate) "{{{
let line = getline(a:lnum)
let state = s:rx_li_symbol(a:rate)
let line = substitute(line, s:rx_li_box, state, '')
call setline(a:lnum, line)
endfunction "}}}
" Get state of the list item on line number "lnum"
function! s:get_state(lnum) "{{{
let state = 0
let line = getline(a:lnum)
let opt = matchstr(line, s:rx_cb_list_item())
if opt =~ s:rx_li_symbol(100)
let state = 100
elseif opt =~ s:rx_li_symbol(0)
let state = 0
elseif opt =~ s:rx_li_symbol(25)
let state = 25
elseif opt =~ s:rx_li_symbol(50)
let state = 50
elseif opt =~ s:rx_li_symbol(75)
let state = 75
endif
return state
endfunction "}}}
" Returns 1 if there is checkbox on a list item, 0 otherwise.
function! s:is_cb_list_item(lnum) "{{{
return getline(a:lnum) =~ s:rx_cb_list_item()
endfunction "}}}
" Returns start line number of list item, 0 if it is not a list.
function! s:is_list_item(lnum) "{{{
let c_lnum = a:lnum
while c_lnum >= 1
let line = getline(c_lnum)
if line =~ s:rx_list_item()
return c_lnum
endif
if line =~ '^\s*$'
return 0
endif
if indent(c_lnum) > indent(a:lnum)
return 0
endif
let c_lnum -= 1
endwhile
return 0
endfunction "}}}
" Returns char column of checkbox. Used in parent/child checks.
function! s:get_li_pos(lnum) "{{{
return stridx(getline(a:lnum), '[')
endfunction "}}}
" Returns list of line numbers of parent and all its child items.
function! s:get_child_items(lnum) "{{{
let result = []
let lnum = a:lnum
let p_pos = s:get_level(lnum)
" add parent
call add(result, lnum)
let lnum = s:next_list_item(lnum)
while lnum != 0 && s:is_list_item(lnum) && s:get_level(lnum) > p_pos
call add(result, lnum)
let lnum = s:next_list_item(lnum)
endwhile
return result
endfunction "}}}
" Returns list of line numbers of all items of the same level.
function! s:get_sibling_items(lnum) "{{{
let result = []
let lnum = a:lnum
let ind = s:get_level(lnum)
while lnum != 0 && s:get_level(lnum) >= ind
if s:get_level(lnum) == ind && s:is_cb_list_item(lnum)
call add(result, lnum)
endif
let lnum = s:next_list_item(lnum)
endwhile
let lnum = s:prev_list_item(a:lnum)
while lnum != 0 && s:get_level(lnum) >= ind
if s:get_level(lnum) == ind && s:is_cb_list_item(lnum)
call add(result, lnum)
endif
let lnum = s:prev_list_item(lnum)
endwhile
return result
endfunction "}}}
" Returns line number of the parent of lnum item
function! s:get_parent_item(lnum) "{{{
let lnum = a:lnum
let ind = s:get_level(lnum)
let lnum = s:prev_list_item(lnum)
while lnum != 0 && s:is_list_item(lnum) && s:get_level(lnum) >= ind
let lnum = s:prev_list_item(lnum)
endwhile
if s:is_cb_list_item(lnum)
return lnum
else
return a:lnum
endif
endfunction "}}}
" Creates checkbox in a list item.
function! s:create_cb_list_item(lnum) "{{{
let line = getline(a:lnum)
let m = matchstr(line, s:rx_list_item())
if m != ''
let li_content = substitute(strpart(line, len(m)), '^\s*', '', '')
let line = substitute(m, '\s*$', ' ', '').s:blank_checkbox().li_content
call setline(a:lnum, line)
endif
endfunction "}}}
" Tells if all of the sibling list items are checked or not.
function! s:all_siblings_checked(lnum) "{{{
let result = 0
let cnt = 0
let siblings = s:get_sibling_items(a:lnum)
for lnum in siblings
let cnt += s:get_state(lnum)
endfor
let result = cnt/len(siblings)
return result
endfunction "}}}
" Creates checkbox on a list item if there is no one.
function! s:TLI_create_checkbox(lnum) "{{{
if a:lnum && !s:is_cb_list_item(a:lnum)
if g:vimwiki_auto_checkbox
call s:create_cb_list_item(a:lnum)
endif
return 1
endif
return 0
endfunction "}}}
" Switch state of the child list items.
function! s:TLI_switch_child_state(lnum) "{{{
let current_state = s:get_state(a:lnum)
if current_state == 100
let new_state = 0
else
let new_state = 100
endif
for lnum in s:get_child_items(a:lnum)
call s:set_state(lnum, new_state)
endfor
endfunction "}}}
" Switch state of the parent list items.
function! s:TLI_switch_parent_state(lnum) "{{{
let c_lnum = a:lnum
while s:is_cb_list_item(c_lnum)
let parent_lnum = s:get_parent_item(c_lnum)
if parent_lnum == c_lnum
break
endif
call s:set_state(parent_lnum, s:all_siblings_checked(c_lnum))
let c_lnum = parent_lnum
endwhile
endfunction "}}}
function! s:TLI_toggle(lnum) "{{{
if !s:TLI_create_checkbox(a:lnum)
call s:TLI_switch_child_state(a:lnum)
endif
call s:TLI_switch_parent_state(a:lnum)
endfunction "}}}
" Script functions }}}
" Toggle list item between [ ] and [X]
function! vimwiki#lst#ToggleListItem(line1, line2) "{{{
let line1 = a:line1
let line2 = a:line2
if line1 != line2 && !s:is_list_item(line1)
let line1 = s:find_next_list_item(line1)
endif
let c_lnum = line1
while c_lnum != 0 && c_lnum <= line2
let li_lnum = s:is_list_item(c_lnum)
if li_lnum
let li_level = s:get_level(li_lnum)
if c_lnum == line1
let start_li_level = li_level
endif
if li_level <= start_li_level
call s:TLI_toggle(li_lnum)
let start_li_level = li_level
endif
endif
let c_lnum = s:find_next_list_item(c_lnum)
endwhile
endfunction "}}}
function! vimwiki#lst#kbd_cr() "{{{
" This function is heavily relies on proper 'set comments' option.
let cr = "\<CR>"
if getline('.') =~ s:rx_cb_list_item()
let cr .= s:blank_checkbox()
endif
return cr
endfunction "}}}
function! vimwiki#lst#kbd_oO(cmd) "{{{
" cmd should be 'o' or 'O'
let l:count = v:count1
while l:count > 0
let beg_lnum = foldclosed('.')
let end_lnum = foldclosedend('.')
if end_lnum != -1 && a:cmd ==# 'o'
let lnum = end_lnum
let line = getline(beg_lnum)
else
let line = getline('.')
let lnum = line('.')
endif
let m = matchstr(line, s:rx_list_item())
let res = ''
if line =~ s:rx_cb_list_item()
let res = substitute(m, '\s*$', ' ', '').s:blank_checkbox()
elseif line =~ s:rx_list_item()
let res = substitute(m, '\s*$', ' ', '')
elseif &autoindent || &smartindent
let res = matchstr(line, '^\s*')
endif
if a:cmd ==# 'o'
call append(lnum, res)
call cursor(lnum + 1, col('$'))
else
call append(lnum - 1, res)
call cursor(lnum, col('$'))
endif
let l:count -= 1
endwhile
startinsert!
endfunction "}}}
function! vimwiki#lst#default_symbol() "{{{
" TODO: initialize default symbol from syntax/vimwiki_xxx.vim
if VimwikiGet('syntax') == 'default'
return '-'
else
return '*'
endif
endfunction "}}}
function vimwiki#lst#get_list_margin() "{{{
if VimwikiGet('list_margin') < 0
return &sw
else
return VimwikiGet('list_margin')
endif
endfunction "}}}
function s:get_list_sw() "{{{
if VimwikiGet('syntax') == 'media'
return 1
else
return &sw
endif
endfunction "}}}
function s:get_list_nesting_level(lnum) "{{{
if VimwikiGet('syntax') == 'media'
if getline(a:lnum) !~ s:rx_list_item()
let level = 0
else
let level = vimwiki#u#count_first_sym(getline(a:lnum)) - 1
let level = level < 0 ? 0 : level
endif
else
let level = indent(a:lnum)
endif
return level
endfunction "}}}
function s:get_list_indent(lnum) "{{{
if VimwikiGet('syntax') == 'media'
return indent(a:lnum)
else
return 0
endif
endfunction "}}}
function! s:compose_list_item(n_indent, n_nesting, sym_nest, sym_bullet, li_content, ...) "{{{
if a:0
let sep = a:1
else
let sep = ''
endif
let li_indent = repeat(' ', max([0,a:n_indent])).sep
let li_nesting = repeat(a:sym_nest, max([0,a:n_nesting])).sep
if len(a:sym_bullet) > 0
let li_bullet = a:sym_bullet.' '.sep
else
let li_bullet = ''.sep
endif
return li_indent.li_nesting.li_bullet.a:li_content
endfunction "}}}
function s:compose_cb_bullet(prev_cb_bullet, sym) "{{{
return a:sym.matchstr(a:prev_cb_bullet, '\S*\zs\s\+.*')
endfunction "}}}
function! vimwiki#lst#change_level(...) "{{{
let default_sym = vimwiki#lst#default_symbol()
let cmd = '>>'
let sym = default_sym
" parse argument
if a:0
if a:1 != '<<' && a:1 != '>>'
let cmd = '--'
let sym = a:1
else
let cmd = a:1
endif
endif
" is symbol valid
if sym.' ' !~ s:rx_cb_list_item() && sym.' ' !~ s:rx_list_item()
return
endif
" parsing setup
let lnum = line('.')
let line = getline('.')
let list_margin = vimwiki#lst#get_list_margin()
let list_sw = s:get_list_sw()
let n_nesting = s:get_list_nesting_level(lnum)
let n_indent = s:get_list_indent(lnum)
" remove indent and nesting
let li_bullet_and_content = strpart(line, n_nesting + n_indent)
" list bullet and checkbox
let cb_bullet = matchstr(li_bullet_and_content, s:rx_list_item()).
\ matchstr(li_bullet_and_content, s:rx_cb_list_item())
" XXX: it could be not unicode proof --> if checkboxes are set up with unicode syms
" content
let li_content = strpart(li_bullet_and_content, len(cb_bullet))
" trim
let cb_bullet = vimwiki#u#trim(cb_bullet)
let li_content = vimwiki#u#trim(li_content)
" nesting symbol
if VimwikiGet('syntax') == 'media'
if len(cb_bullet) > 0
let sym_nest = cb_bullet[0]
else
let sym_nest = sym
endif
else
let sym_nest = ' '
endif
if g:vimwiki_debug
echomsg "PARSE: Sw [".list_sw."]"
echomsg s:compose_list_item(n_indent, n_nesting, sym_nest, cb_bullet, li_content, '|')
endif
" change level
if cmd == '--'
let cb_bullet = s:compose_cb_bullet(cb_bullet, sym)
if VimwikiGet('syntax') == 'media'
let sym_nest = sym
endif
elseif cmd == '>>'
if cb_bullet == ''
let cb_bullet = sym
else
let n_nesting = n_nesting + list_sw
endif
elseif cmd == '<<'
let n_nesting = n_nesting - list_sw
if VimwikiGet('syntax') == 'media'
if n_nesting < 0
let cb_bullet = ''
endif
else
if n_nesting < list_margin
let cb_bullet = ''
endif
endif
endif
let n_nesting = max([0, n_nesting])
if g:vimwiki_debug
echomsg "SHIFT:"
echomsg s:compose_list_item(n_indent, n_nesting, sym_nest, cb_bullet, li_content, '|')
endif
" XXX: this is the code that adds the initial indent
let add_nesting = VimwikiGet('syntax') != 'media'
if n_indent + n_nesting*(add_nesting) < list_margin
let n_indent = list_margin - n_nesting*(add_nesting)
endif
if g:vimwiki_debug
echomsg "INDENT:"
echomsg s:compose_list_item(n_indent, n_nesting, sym_nest, cb_bullet, li_content, '|')
endif
let line = s:compose_list_item(n_indent, n_nesting, sym_nest, cb_bullet, li_content)
" replace
call setline(lnum, line)
call cursor(lnum, match(line, '\S') + 1)
endfunction "}}}

View File

@@ -1,302 +0,0 @@
" vim:tabstop=2:shiftwidth=2:expandtab:foldmethod=marker:textwidth=79
" Vimwiki autoload plugin file
" Desc: Link functions for markdown syntax
" Author: Stuart Andrews <stu.andrews@gmail.com> (.. i.e. don't blame Maxim!)
" Home: http://code.google.com/p/vimwiki/
" MISC helper functions {{{
" vimwiki#markdown_base#reset_mkd_refs
function! vimwiki#markdown_base#reset_mkd_refs() "{{{
call VimwikiClear('markdown_refs')
endfunction "}}}
" vimwiki#markdown_base#scan_reflinks
function! vimwiki#markdown_base#scan_reflinks() " {{{
let mkd_refs = {}
" construct list of references using vimgrep
try
execute 'vimgrep #'.g:vimwiki_rxMkdRef.'#j %'
catch /^Vim\%((\a\+)\)\=:E480/ " No Match
"Ignore it, and move on to the next file
endtry
"
for d in getqflist()
let matchline = join(getline(d.lnum, min([d.lnum+1, line('$')])), ' ')
let descr = matchstr(matchline, g:vimwiki_rxMkdRefMatchDescr)
let url = matchstr(matchline, g:vimwiki_rxMkdRefMatchUrl)
if descr != '' && url != ''
let mkd_refs[descr] = url
endif
endfor
call VimwikiSet('markdown_refs', mkd_refs)
return mkd_refs
endfunction "}}}
" vimwiki#markdown_base#get_reflinks
function! vimwiki#markdown_base#get_reflinks() " {{{
let done = 1
try
let mkd_refs = VimwikiGet('markdown_refs')
catch
" work-around hack
let done = 0
" ... the following command does not work inside catch block !?
" > let mkd_refs = vimwiki#markdown_base#scan_reflinks()
endtry
if !done
let mkd_refs = vimwiki#markdown_base#scan_reflinks()
endif
return mkd_refs
endfunction "}}}
" vimwiki#markdown_base#open_reflink
" try markdown reference links
function! vimwiki#markdown_base#open_reflink(link) " {{{
" echom "vimwiki#markdown_base#open_reflink"
let link = a:link
let mkd_refs = vimwiki#markdown_base#get_reflinks()
if has_key(mkd_refs, link)
let url = mkd_refs[link]
call vimwiki#base#system_open_link(url)
return 1
else
return 0
endif
endfunction " }}}
" s:normalize_path
" s:path_html
" vimwiki#base#apply_wiki_options
" vimwiki#base#read_wiki_options
" vimwiki#base#validate_wiki_options
" vimwiki#base#setup_buffer_state
" vimwiki#base#cache_buffer_state
" vimwiki#base#recall_buffer_state
" vimwiki#base#print_wiki_state
" vimwiki#base#mkdir
" vimwiki#base#file_pattern
" vimwiki#base#branched_pattern
" vimwiki#base#subdir
" vimwiki#base#current_subdir
" vimwiki#base#invsubdir
" vimwiki#base#resolve_scheme
" vimwiki#base#system_open_link
" vimwiki#base#open_link
" vimwiki#base#generate_links
" vimwiki#base#goto
" vimwiki#base#backlinks
" vimwiki#base#get_links
" vimwiki#base#edit_file
" vimwiki#base#search_word
" vimwiki#base#matchstr_at_cursor
" vimwiki#base#replacestr_at_cursor
" s:print_wiki_list
" s:update_wiki_link
" s:update_wiki_links_dir
" s:tail_name
" s:update_wiki_links
" s:get_wiki_buffers
" s:open_wiki_buffer
" vimwiki#base#nested_syntax
" }}}
" WIKI link following functions {{{
" vimwiki#base#find_next_link
" vimwiki#base#find_prev_link
" vimwiki#base#follow_link
function! vimwiki#markdown_base#follow_link(split, ...) "{{{ Parse link at cursor and pass
" to VimwikiLinkHandler, or failing that, the default open_link handler
" echom "markdown_base#follow_link"
if 0
" Syntax-specific links
" XXX: @Stuart: do we still need it?
" XXX: @Maxim: most likely! I am still working on a seemless way to
" integrate regexp's without complicating syntax/vimwiki.vim
else
if a:split == "split"
let cmd = ":split "
elseif a:split == "vsplit"
let cmd = ":vsplit "
elseif a:split == "tabnew"
let cmd = ":tabnew "
else
let cmd = ":e "
endif
" try WikiLink
let lnk = matchstr(vimwiki#base#matchstr_at_cursor(g:vimwiki_rxWikiLink),
\ g:vimwiki_rxWikiLinkMatchUrl)
" try WikiIncl
if lnk == ""
let lnk = matchstr(vimwiki#base#matchstr_at_cursor(g:vimwiki_rxWikiIncl),
\ g:vimwiki_rxWikiInclMatchUrl)
endif
" try Weblink
if lnk == ""
let lnk = matchstr(vimwiki#base#matchstr_at_cursor(g:vimwiki_rxWeblink),
\ g:vimwiki_rxWeblinkMatchUrl)
endif
if lnk != ""
if !VimwikiLinkHandler(lnk)
if !vimwiki#markdown_base#open_reflink(lnk)
call vimwiki#base#open_link(cmd, lnk)
endif
endif
return
endif
if a:0 > 0
execute "normal! ".a:1
else
call vimwiki#base#normalize_link(0)
endif
endif
endfunction " }}}
" vimwiki#base#go_back_link
" vimwiki#base#goto_index
" vimwiki#base#delete_link
" vimwiki#base#rename_link
" vimwiki#base#ui_select
" TEXT OBJECTS functions {{{
" vimwiki#base#TO_header
" vimwiki#base#TO_table_cell
" vimwiki#base#TO_table_col
" }}}
" HEADER functions {{{
" vimwiki#base#AddHeaderLevel
" vimwiki#base#RemoveHeaderLevel
"}}}
" LINK functions {{{
" vimwiki#base#apply_template
" s:clean_url
" vimwiki#base#normalize_link_helper
" vimwiki#base#normalize_imagelink_helper
" s:normalize_link_syntax_n
function! s:normalize_link_syntax_n() " {{{
let lnum = line('.')
" try WikiIncl
let lnk = vimwiki#base#matchstr_at_cursor(g:vimwiki_rxWikiIncl)
if !empty(lnk)
" NO-OP !!
if g:vimwiki_debug > 1
echomsg "WikiIncl: ".lnk." Sub: ".lnk
endif
return
endif
" try WikiLink0: replace with WikiLink1
let lnk = vimwiki#base#matchstr_at_cursor(g:vimwiki_rxWikiLink0)
if !empty(lnk)
let sub = vimwiki#base#normalize_link_helper(lnk,
\ g:vimwiki_rxWikiLinkMatchUrl, g:vimwiki_rxWikiLinkMatchDescr,
\ g:vimwiki_WikiLink1Template2)
call vimwiki#base#replacestr_at_cursor(g:vimwiki_rxWikiLink0, sub)
if g:vimwiki_debug > 1
echomsg "WikiLink: ".lnk." Sub: ".sub
endif
return
endif
" try WikiLink1: replace with WikiLink0
let lnk = vimwiki#base#matchstr_at_cursor(g:vimwiki_rxWikiLink1)
if !empty(lnk)
let sub = vimwiki#base#normalize_link_helper(lnk,
\ g:vimwiki_rxWikiLinkMatchUrl, g:vimwiki_rxWikiLinkMatchDescr,
\ g:vimwiki_WikiLinkTemplate2)
call vimwiki#base#replacestr_at_cursor(g:vimwiki_rxWikiLink1, sub)
if g:vimwiki_debug > 1
echomsg "WikiLink: ".lnk." Sub: ".sub
endif
return
endif
" try Weblink
let lnk = vimwiki#base#matchstr_at_cursor(g:vimwiki_rxWeblink)
if !empty(lnk)
let sub = vimwiki#base#normalize_link_helper(lnk,
\ g:vimwiki_rxWeblinkMatchUrl, g:vimwiki_rxWeblinkMatchDescr,
\ g:vimwiki_Weblink1Template)
call vimwiki#base#replacestr_at_cursor(g:vimwiki_rxWeblink, sub)
if g:vimwiki_debug > 1
echomsg "WebLink: ".lnk." Sub: ".sub
endif
return
endif
" try Word (any characters except separators)
" rxWord is less permissive than rxWikiLinkUrl which is used in
" normalize_link_syntax_v
let lnk = vimwiki#base#matchstr_at_cursor(g:vimwiki_rxWord)
if !empty(lnk)
let sub = vimwiki#base#normalize_link_helper(lnk,
\ g:vimwiki_rxWord, '',
\ g:vimwiki_WikiLinkTemplate1)
call vimwiki#base#replacestr_at_cursor('\V'.lnk, sub)
if g:vimwiki_debug > 1
echomsg "Word: ".lnk." Sub: ".sub
endif
return
endif
endfunction " }}}
" s:normalize_link_syntax_v
function! s:normalize_link_syntax_v() " {{{
let lnum = line('.')
let sel_save = &selection
let &selection = "old"
let rv = @"
let rt = getregtype('"')
let done = 0
try
norm! gvy
let visual_selection = @"
let visual_selection = substitute(g:vimwiki_WikiLinkTemplate1, '__LinkUrl__', '\='."'".visual_selection."'", '')
call setreg('"', visual_selection, 'v')
" paste result
norm! `>pgvd
finally
call setreg('"', rv, rt)
let &selection = sel_save
endtry
endfunction " }}}
" vimwiki#base#normalize_link
function! vimwiki#markdown_base#normalize_link(is_visual_mode) "{{{
if 0
" Syntax-specific links
else
if !a:is_visual_mode
call s:normalize_link_syntax_n()
elseif visualmode() ==# 'v' && line("'<") == line("'>")
" action undefined for 'line-wise' or 'multi-line' visual mode selections
call s:normalize_link_syntax_v()
endif
endif
endfunction "}}}
" }}}
" -------------------------------------------------------------------------
" Load syntax-specific Wiki functionality
" -------------------------------------------------------------------------

View File

@@ -1,79 +0,0 @@
body {font-family: Tahoma, Geneva, sans-serif; margin: 1em 2em 1em 2em; font-size: 100%; line-height: 130%;}
h1, h2, h3, h4, h5, h6 {font-family: Trebuchet MS, Helvetica, sans-serif; font-weight: bold; line-height:100%; margin-top: 1.5em; margin-bottom: 0.5em;}
h1 {font-size: 2.6em; color: #000000;}
h2 {font-size: 2.2em; color: #404040;}
h3 {font-size: 1.8em; color: #707070;}
h4 {font-size: 1.4em; color: #909090;}
h5 {font-size: 1.3em; color: #989898;}
h6 {font-size: 1.2em; color: #9c9c9c;}
p, pre, blockquote, table, ul, ol, dl {margin-top: 1em; margin-bottom: 1em;}
ul ul, ul ol, ol ol, ol ul {margin-top: 0.5em; margin-bottom: 0.5em;}
li {margin: 0.3em auto;}
ul {margin-left: 2em; padding-left: 0.5em;}
dt {font-weight: bold;}
img {border: none;}
pre {border-left: 1px solid #ccc; margin-left: 2em; padding-left: 0.5em;}
blockquote {padding: 0.4em; background-color: #f6f5eb;}
th, td {border: 1px solid #ccc; padding: 0.3em;}
th {background-color: #f0f0f0;}
hr {border: none; border-top: 1px solid #ccc; width: 100%;}
del {text-decoration: line-through; color: #777777;}
.toc li {list-style-type: none;}
.todo {font-weight: bold; background-color: #f0ece8; color: #a03020;}
.justleft {text-align: left;}
.justright {text-align: right;}
.justcenter {text-align: center;}
.center {margin-left: auto; margin-right: auto;}
/* classes for items of todo lists */
.done0 {
/* list-style: none; */
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA8AAAAPCAYAAAA71pVKAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAAxQAAAMUBHc26qAAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAAA7SURBVCiR7dMxEgAgCANBI3yVRzF5KxNbW6wsuH7LQ2YKQK1mkswBVERYF5Os3UV3gwd/jF2SkXy66gAZkxS6BniubAAAAABJRU5ErkJggg==);
background-repeat: no-repeat;
background-position: 0 .2em;
margin-left: -2em;
padding-left: 1.5em;
}
.done1 {
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA8AAAAPCAYAAAA71pVKAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAAxQAAAMUBHc26qAAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAABtSURBVCiR1ZO7DYAwDER9BDmTeZQMFXmUbGYpOjrEryA0wOvO8itOslFrJYAug5BMM4BeSkmjsrv3aVTa8p48Xw1JSkSsWVUFwD05IqS1tmYzk5zzae9jnVVVzGyXb8sALjse+euRkEzu/uirFomVIdDGOLjuAAAAAElFTkSuQmCC);
background-repeat: no-repeat;
background-position: 0 .15em;
margin-left: -2em;
padding-left: 1.5em;
}
.done2 {
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA8AAAAPCAYAAAA71pVKAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAAxQAAAMUBHc26qAAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAAB1SURBVCiRzdO5DcAgDAVQGxjAYgTvxlDIu1FTIRYAp8qlFISkSH7l5kk+ZIwxKiI2mIyqWoeILYRgZ7GINDOLjnmF3VqklKCUMgTee2DmM661Qs55iI3Zm/1u5h9sm4ig9z4ERHTFzLyd4G4+nFlVrYg8+qoF/c0kdpeMsmcAAAAASUVORK5CYII=);
background-repeat: no-repeat;
background-position: 0 .15em;
margin-left: -2em;
padding-left: 1.5em;
}
.done3 {
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA8AAAAPCAYAAAA71pVKAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAAxQAAAMUBHc26qAAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAABoSURBVCiR7dOxDcAgDATA/0DtUdiKoZC3YhLkHjkVKF3idJHiztKfvrHZWnOSE8Fx95RJzlprimJVnXktvXeY2S0SEZRSAAAbmxnGGKH2I5T+8VfxPhIReQSuuY3XyYWa3T2p6quvOgGrvSFGlewuUAAAAABJRU5ErkJggg==);
background-repeat: no-repeat;
background-position: 0 .15em;
margin-left: -2em;
padding-left: 1.5em;
}
.done4 {
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABIAAAAQCAYAAAAbBi9cAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAAzgAAAM4BlP6ToAAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAAIISURBVDiNnZQ9SFtRFMd/773kpTaGJoQk1im4VDpWQcTNODhkFBcVTCNCF0NWyeDiIIiCm82QoIMIUkHUxcFBg1SEQoZszSat6cdTn1qNue92CMbEr9Sey+XC/Z/zu+f8h6ukUil3sVg0+M+4cFxk42/jH2wAqqqKSCSiPQdwcHHAnDHH9s/tN1h8V28ETdP+eU8fT9Nt62ancYdIPvJNtsu87bmjrJlrTDVM4RROJs1JrHPrD4Bar7A6cpc54iKOaTdJXCUI2UMVrQZ0Js7YPN18ECKkYNQcJe/OE/4dZsw7VqNXQMvHy3QZXQypQ6ycrtwDjf8aJ+PNEDSCzLpn7+m2pD8ZKHlKarYhy6XjEoCYGcN95qansQeA3fNdki+SaJZGTMQIOoL3W/Z89rxv+tokubNajlvk/vm+LFpF2XnUKZHI0I+QrI7Dw0OZTqdzUkpsM7mZTyfy5OPGyw1tK7AFSvmB/Ks8w8YwbUYbe6/3QEKv0vugfxWPnMLJun+d/kI/WLdizpNjMbAIKrhMF4OuwadBALqqs+RfInwUvuNi+fBd+wjogfogAFVRmffO02q01mZZ0HHdgXIzdz0QQLPezIQygX6llxNKKgOFARYCC49CqhoHIUTlss/Vx2phlYwjw8j1CAlfAiwQiJpiy7o1VHnsG5FISkoJu7Q/2YmmaV+i0ei7v38L2CBguSi5AAAAAElFTkSuQmCC);
background-repeat: no-repeat;
background-position: 0 .15em;
margin-left: -2em;
padding-left: 1.5em;
}
code {
font-family: Monaco,"Courier New","DejaVu Sans Mono","Bitstream Vera Sans Mono",monospace;
-webkit-border-radius: 1px;
-moz-border-radius: 1px;
border-radius: 1px;
-moz-background-clip: padding;
-webkit-background-clip: padding-box;
background-clip: padding-box;
padding: 0px 3px;
display: inline-block;
color: #52595d;
border: 1px solid #ccc;
background-color: #f9f9f9;
}

View File

@@ -1,656 +0,0 @@
" vim:tabstop=2:shiftwidth=2:expandtab:foldmethod=marker:textwidth=79
" Vimwiki autoload plugin file
" Desc: Tables
" | Easily | manageable | text | tables | ! |
" |--------|------------|-------|--------|---------|
" | Have | fun! | Drink | tea | Period. |
"
" Author: Maxim Kim <habamax@gmail.com>
" Home: http://code.google.com/p/vimwiki/
" Load only once {{{
if exists("g:loaded_vimwiki_tbl_auto") || &cp
finish
endif
let g:loaded_vimwiki_tbl_auto = 1
"}}}
let s:textwidth = &tw
let s:rxSep = g:vimwiki_rxTableSep
" Misc functions {{{
function! s:wide_len(str) "{{{
" vim73 has new function that gives correct string width.
if exists("*strdisplaywidth")
return strdisplaywidth(a:str)
endif
" get str display width in vim ver < 7.2
if !g:vimwiki_CJK_length
let ret = strlen(substitute(a:str, '.', 'x', 'g'))
else
let savemodified = &modified
let save_cursor = getpos('.')
exe "norm! o\<esc>"
call setline(line("."), a:str)
let ret = virtcol("$") - 1
d
call setpos('.', save_cursor)
let &modified = savemodified
endif
return ret
endfunction "}}}
function! s:cell_splitter() "{{{
return '\s*'.s:rxSep.'\s*'
endfunction "}}}
function! s:sep_splitter() "{{{
return '-'.s:rxSep.'-'
endfunction "}}}
function! s:is_table(line) "{{{
return s:is_separator(a:line) || (a:line !~ s:rxSep.s:rxSep && a:line =~ '^\s*'.s:rxSep.'.\+'.s:rxSep.'\s*$')
endfunction "}}}
function! s:is_separator(line) "{{{
return a:line =~ '^\s*'.s:rxSep.'\(--\+'.s:rxSep.'\)\+\s*$'
endfunction "}}}
function! s:is_separator_tail(line) "{{{
return a:line =~ '^\{-1}\%(\s*\|-*\)\%('.s:rxSep.'-\+\)\+'.s:rxSep.'\s*$'
endfunction "}}}
function! s:is_last_column(lnum, cnum) "{{{
let line = strpart(getline(a:lnum), a:cnum - 1)
"echomsg "DEBUG is_last_column> ".(line =~ s:rxSep.'\s*$' && line !~ s:rxSep.'.*'.s:rxSep.'\s*$')
return line =~ s:rxSep.'\s*$' && line !~ s:rxSep.'.*'.s:rxSep.'\s*$'
endfunction "}}}
function! s:is_first_column(lnum, cnum) "{{{
let line = strpart(getline(a:lnum), 0, a:cnum - 1)
"echomsg "DEBUG is_first_column> ".(line =~ '^\s*'.s:rxSep && line !~ '^\s*'.s:rxSep.'.*'.s:rxSep)
return line =~ '^\s*$' || (line =~ '^\s*'.s:rxSep && line !~ '^\s*'.s:rxSep.'.*'.s:rxSep)
endfunction "}}}
function! s:count_separators_up(lnum) "{{{
let lnum = a:lnum - 1
while lnum > 1
if !s:is_separator(getline(lnum))
break
endif
let lnum -= 1
endwhile
return (a:lnum-lnum)
endfunction "}}}
function! s:count_separators_down(lnum) "{{{
let lnum = a:lnum + 1
while lnum < line('$')
if !s:is_separator(getline(lnum))
break
endif
let lnum += 1
endwhile
return (lnum-a:lnum)
endfunction "}}}
function! s:create_empty_row(cols) "{{{
let row = s:rxSep
let cell = " ".s:rxSep
for c in range(a:cols)
let row .= cell
endfor
return row
endfunction "}}}
function! s:create_row_sep(cols) "{{{
let row = s:rxSep
let cell = "---".s:rxSep
for c in range(a:cols)
let row .= cell
endfor
return row
endfunction "}}}
function! vimwiki#tbl#get_cells(line) "{{{
let result = []
let cell = ''
let quote = ''
let state = 'NONE'
" 'Simple' FSM
for idx in range(strlen(a:line))
" The only way I know Vim can do Unicode...
let ch = a:line[idx]
if state == 'NONE'
if ch == '|'
let state = 'CELL'
endif
elseif state == 'CELL'
if ch == '[' || ch == '{'
let state = 'BEFORE_QUOTE_START'
let quote = ch
elseif ch == '|'
call add(result, vimwiki#u#trim(cell))
let cell = ""
else
let cell .= ch
endif
elseif state == 'BEFORE_QUOTE_START'
if ch == '[' || ch == '{'
let state = 'QUOTE'
let quote .= ch
else
let state = 'CELL'
let cell .= quote.ch
let quote = ''
endif
elseif state == 'QUOTE'
if ch == ']' || ch == '}'
let state = 'BEFORE_QUOTE_END'
endif
let quote .= ch
elseif state == 'BEFORE_QUOTE_END'
if ch == ']' || ch == '}'
let state = 'CELL'
endif
let cell .= quote.ch
let quote = ''
endif
endfor
if cell.quote != ''
call add(result, vimwiki#u#trim(cell.quote, '|'))
endif
return result
endfunction "}}}
function! s:col_count(lnum) "{{{
return len(vimwiki#tbl#get_cells(getline(a:lnum)))
endfunction "}}}
function! s:get_indent(lnum) "{{{
if !s:is_table(getline(a:lnum))
return
endif
let indent = 0
let lnum = a:lnum - 1
while lnum > 1
let line = getline(lnum)
if !s:is_table(line)
let indent = indent(lnum+1)
break
endif
let lnum -= 1
endwhile
return indent
endfunction " }}}
function! s:get_rows(lnum) "{{{
if !s:is_table(getline(a:lnum))
return
endif
let upper_rows = []
let lower_rows = []
let lnum = a:lnum - 1
while lnum >= 1
let line = getline(lnum)
if s:is_table(line)
call add(upper_rows, [lnum, line])
else
break
endif
let lnum -= 1
endwhile
call reverse(upper_rows)
let lnum = a:lnum
while lnum <= line('$')
let line = getline(lnum)
if s:is_table(line)
call add(lower_rows, [lnum, line])
else
break
endif
let lnum += 1
endwhile
return upper_rows + lower_rows
endfunction "}}}
function! s:get_cell_max_lens(lnum) "{{{
let max_lens = {}
for [lnum, row] in s:get_rows(a:lnum)
if s:is_separator(row)
continue
endif
let cells = vimwiki#tbl#get_cells(row)
for idx in range(len(cells))
let value = cells[idx]
if has_key(max_lens, idx)
let max_lens[idx] = max([s:wide_len(value), max_lens[idx]])
else
let max_lens[idx] = s:wide_len(value)
endif
endfor
endfor
return max_lens
endfunction "}}}
function! s:get_aligned_rows(lnum, col1, col2) "{{{
let max_lens = s:get_cell_max_lens(a:lnum)
let rows = []
for [lnum, row] in s:get_rows(a:lnum)
if s:is_separator(row)
let new_row = s:fmt_sep(max_lens, a:col1, a:col2)
else
let new_row = s:fmt_row(row, max_lens, a:col1, a:col2)
endif
call add(rows, [lnum, new_row])
endfor
return rows
endfunction "}}}
" Number of the current column. Starts from 0.
function! s:cur_column() "{{{
let line = getline('.')
if !s:is_table(line)
return -1
endif
" TODO: do we need conditional: if s:is_separator(line)
let curs_pos = col('.')
let mpos = match(line, s:rxSep, 0)
let col = -1
while mpos < curs_pos && mpos != -1
let mpos = match(line, s:rxSep, mpos+1)
if mpos != -1
let col += 1
endif
endwhile
return col
endfunction "}}}
" }}}
" Format functions {{{
function! s:fmt_cell(cell, max_len) "{{{
let cell = ' '.a:cell.' '
let diff = a:max_len - s:wide_len(a:cell)
if diff == 0 && empty(a:cell)
let diff = 1
endif
let cell .= repeat(' ', diff)
return cell
endfunction "}}}
function! s:fmt_row(line, max_lens, col1, col2) "{{{
let new_line = s:rxSep
let cells = vimwiki#tbl#get_cells(a:line)
for idx in range(len(cells))
if idx == a:col1
let idx = a:col2
elseif idx == a:col2
let idx = a:col1
endif
let value = cells[idx]
let new_line .= s:fmt_cell(value, a:max_lens[idx]).s:rxSep
endfor
let idx = len(cells)
while idx < len(a:max_lens)
let new_line .= s:fmt_cell('', a:max_lens[idx]).s:rxSep
let idx += 1
endwhile
return new_line
endfunction "}}}
function! s:fmt_cell_sep(max_len) "{{{
if a:max_len == 0
return repeat('-', 3)
else
return repeat('-', a:max_len+2)
endif
endfunction "}}}
function! s:fmt_sep(max_lens, col1, col2) "{{{
let new_line = s:rxSep
for idx in range(len(a:max_lens))
if idx == a:col1
let idx = a:col2
elseif idx == a:col2
let idx = a:col1
endif
let new_line .= s:fmt_cell_sep(a:max_lens[idx]).s:rxSep
endfor
return new_line
endfunction "}}}
"}}}
" Keyboard functions "{{{
function! s:kbd_create_new_row(cols, goto_first) "{{{
let cmd = "\<ESC>o".s:create_empty_row(a:cols)
let cmd .= "\<ESC>:call vimwiki#tbl#format(line('.'))\<CR>"
let cmd .= "\<ESC>0"
if a:goto_first
let cmd .= ":call search('\\(".s:rxSep."\\)\\zs', 'c', line('.'))\<CR>"
else
let cmd .= (col('.')-1)."l"
let cmd .= ":call search('\\(".s:rxSep."\\)\\zs', 'bc', line('.'))\<CR>"
endif
let cmd .= "a"
return cmd
endfunction "}}}
function! s:kbd_goto_next_row() "{{{
let cmd = "\<ESC>j"
let cmd .= ":call search('.\\(".s:rxSep."\\)', 'c', line('.'))\<CR>"
let cmd .= ":call search('\\(".s:rxSep."\\)\\zs', 'bc', line('.'))\<CR>"
let cmd .= "a"
return cmd
endfunction "}}}
function! s:kbd_goto_prev_row() "{{{
let cmd = "\<ESC>k"
let cmd .= ":call search('.\\(".s:rxSep."\\)', 'c', line('.'))\<CR>"
let cmd .= ":call search('\\(".s:rxSep."\\)\\zs', 'bc', line('.'))\<CR>"
let cmd .= "a"
return cmd
endfunction "}}}
" Used in s:kbd_goto_next_col
function! vimwiki#tbl#goto_next_col() "{{{
let curcol = virtcol('.')
let lnum = line('.')
let newcol = s:get_indent(lnum)
let max_lens = s:get_cell_max_lens(lnum)
for cell_len in values(max_lens)
if newcol >= curcol-1
break
endif
let newcol += cell_len + 3 " +3 == 2 spaces + 1 separator |<space>...<space>
endfor
let newcol += 2 " +2 == 1 separator + 1 space |<space
call vimwiki#u#cursor(lnum, newcol)
endfunction "}}}
function! s:kbd_goto_next_col(jumpdown) "{{{
let cmd = "\<ESC>"
if a:jumpdown
let seps = s:count_separators_down(line('.'))
let cmd .= seps."j0"
endif
let cmd .= ":call vimwiki#tbl#goto_next_col()\<CR>a"
return cmd
endfunction "}}}
" Used in s:kbd_goto_prev_col
function! vimwiki#tbl#goto_prev_col() "{{{
let curcol = virtcol('.')
let lnum = line('.')
let newcol = s:get_indent(lnum)
let max_lens = s:get_cell_max_lens(lnum)
let prev_cell_len = 0
echom string(max_lens)
for cell_len in values(max_lens)
let delta = cell_len + 3 " +3 == 2 spaces + 1 separator |<space>...<space>
if newcol + delta > curcol-1
let newcol -= (prev_cell_len + 3) " +3 == 2 spaces + 1 separator |<space>...<space>
break
elseif newcol + delta == curcol-1
break
endif
let prev_cell_len = cell_len
let newcol += delta
endfor
let newcol += 2 " +2 == 1 separator + 1 space |<space
call vimwiki#u#cursor(lnum, newcol)
endfunction "}}}
function! s:kbd_goto_prev_col(jumpup) "{{{
let cmd = "\<ESC>"
if a:jumpup
let seps = s:count_separators_up(line('.'))
let cmd .= seps."k"
let cmd .= "$"
endif
let cmd .= ":call vimwiki#tbl#goto_prev_col()\<CR>a"
" let cmd .= ":call search('\\(".s:rxSep."\\)\\zs', 'b', line('.'))\<CR>"
" let cmd .= "a"
"echomsg "DEBUG kbd_goto_prev_col> ".cmd
return cmd
endfunction "}}}
"}}}
" Global functions {{{
function! vimwiki#tbl#kbd_cr() "{{{
let lnum = line('.')
if !s:is_table(getline(lnum))
return "\<CR>"
endif
if s:is_separator(getline(lnum+1)) || !s:is_table(getline(lnum+1))
let cols = len(vimwiki#tbl#get_cells(getline(lnum)))
return s:kbd_create_new_row(cols, 0)
else
return s:kbd_goto_next_row()
endif
endfunction "}}}
function! vimwiki#tbl#kbd_tab() "{{{
let lnum = line('.')
if !s:is_table(getline(lnum))
return "\<Tab>"
endif
let last = s:is_last_column(lnum, col('.'))
let is_sep = s:is_separator_tail(getline(lnum))
"echomsg "DEBUG kbd_tab> last=".last.", is_sep=".is_sep
if (is_sep || last) && !s:is_table(getline(lnum+1))
let cols = len(vimwiki#tbl#get_cells(getline(lnum)))
return s:kbd_create_new_row(cols, 1)
endif
return s:kbd_goto_next_col(is_sep || last)
endfunction "}}}
function! vimwiki#tbl#kbd_shift_tab() "{{{
let lnum = line('.')
if !s:is_table(getline(lnum))
return "\<S-Tab>"
endif
let first = s:is_first_column(lnum, col('.'))
let is_sep = s:is_separator_tail(getline(lnum))
"echomsg "DEBUG kbd_tab> ".first
if (is_sep || first) && !s:is_table(getline(lnum-1))
return ""
endif
return s:kbd_goto_prev_col(is_sep || first)
endfunction "}}}
function! vimwiki#tbl#format(lnum, ...) "{{{
let line = getline(a:lnum)
if !s:is_table(line)
return
endif
if a:0 == 2
let col1 = a:1
let col2 = a:2
else
let col1 = 0
let col2 = 0
endif
let indent = s:get_indent(a:lnum)
for [lnum, row] in s:get_aligned_rows(a:lnum, col1, col2)
let row = repeat(' ', indent).row
call setline(lnum, row)
endfor
let &tw = s:textwidth
endfunction "}}}
function! vimwiki#tbl#create(...) "{{{
if a:0 > 1
let cols = a:1
let rows = a:2
elseif a:0 == 1
let cols = a:1
let rows = 2
elseif a:0 == 0
let cols = 5
let rows = 2
endif
if cols < 1
let cols = 5
endif
if rows < 1
let rows = 2
endif
let lines = []
let row = s:create_empty_row(cols)
call add(lines, row)
if rows > 1
call add(lines, s:create_row_sep(cols))
endif
for r in range(rows - 1)
call add(lines, row)
endfor
call append(line('.'), lines)
endfunction "}}}
function! vimwiki#tbl#align_or_cmd(cmd) "{{{
if s:is_table(getline('.'))
call vimwiki#tbl#format(line('.'))
else
exe 'normal! '.a:cmd
endif
endfunction "}}}
function! vimwiki#tbl#reset_tw(lnum) "{{{
let line = getline(a:lnum)
if !s:is_table(line)
return
endif
let s:textwidth = &tw
let &tw = 0
endfunction "}}}
" TODO: move_column_left and move_column_right are good candidates to be
" refactored.
function! vimwiki#tbl#move_column_left() "{{{
"echomsg "DEBUG move_column_left: "
let line = getline('.')
if !s:is_table(line)
return
endif
let cur_col = s:cur_column()
if cur_col == -1
return
endif
if cur_col > 0
call vimwiki#tbl#format(line('.'), cur_col-1, cur_col)
call cursor(line('.'), 1)
let sep = '\('.s:rxSep.'\).\zs'
let mpos = -1
let col = -1
while col < cur_col-1
let mpos = match(line, sep, mpos+1)
if mpos != -1
let col += 1
else
break
endif
endwhile
endif
endfunction "}}}
function! vimwiki#tbl#move_column_right() "{{{
let line = getline('.')
if !s:is_table(line)
return
endif
let cur_col = s:cur_column()
if cur_col == -1
return
endif
if cur_col < s:col_count(line('.'))-1
call vimwiki#tbl#format(line('.'), cur_col, cur_col+1)
call cursor(line('.'), 1)
let sep = '\('.s:rxSep.'\).\zs'
let mpos = -1
let col = -1
while col < cur_col+1
let mpos = match(line, sep, mpos+1)
if mpos != -1
let col += 1
else
break
endif
endwhile
endif
endfunction "}}}
function! vimwiki#tbl#get_rows(lnum) "{{{
return s:get_rows(a:lnum)
endfunction "}}}
function! vimwiki#tbl#is_table(line) "{{{
return s:is_table(a:line)
endfunction "}}}
function! vimwiki#tbl#is_separator(line) "{{{
return s:is_separator(a:line)
endfunction "}}}
function! vimwiki#tbl#cell_splitter() "{{{
return s:cell_splitter()
endfunction "}}}
function! vimwiki#tbl#sep_splitter() "{{{
return s:sep_splitter()
endfunction "}}}
"}}}

View File

@@ -1,77 +0,0 @@
" vim:tabstop=2:shiftwidth=2:expandtab:foldmethod=marker:textwidth=79
" Vimwiki autoload plugin file
" Utility functions
" Author: Maxim Kim <habamax@gmail.com>
" Home: http://code.google.com/p/vimwiki/
function! vimwiki#u#trim(string, ...) "{{{
let chars = ''
if a:0 > 0
let chars = a:1
endif
let res = substitute(a:string, '^[[:space:]'.chars.']\+', '', '')
let res = substitute(res, '[[:space:]'.chars.']\+$', '', '')
return res
endfunction "}}}
" Builtin cursor doesn't work right with unicode characters.
function! vimwiki#u#cursor(lnum, cnum) "{{{
exe a:lnum
exe 'normal! 0'.a:cnum.'|'
endfunction "}}}
function! vimwiki#u#is_windows() "{{{
return has("win32") || has("win64") || has("win95") || has("win16")
endfunction "}}}
function! vimwiki#u#chomp_slash(str) "{{{
return substitute(a:str, '[/\\]\+$', '', '')
endfunction "}}}
function! vimwiki#u#time(starttime) "{{{
" measure the elapsed time and cut away miliseconds and smaller
return matchstr(reltimestr(reltime(a:starttime)),'\d\+\(\.\d\d\)\=')
endfunction "}}}
function! vimwiki#u#path_norm(path) "{{{
" /-slashes
let path = substitute(a:path, '\', '/', 'g')
" treat multiple consecutive slashes as one path separator
let path = substitute(path, '/\+', '/', 'g')
" ensure that we are not fooled by a symbolic link
return resolve(path)
endfunction "}}}
function! vimwiki#u#is_link_to_dir(link) "{{{
" Check if link is to a directory.
" It should be ended with \ or /.
if a:link =~ '.\+[/\\]$'
return 1
endif
return 0
endfunction " }}}
function! vimwiki#u#count_first_sym(line) "{{{
let first_sym = matchstr(a:line, '\S')
return len(matchstr(a:line, first_sym.'\+'))
endfunction "}}}
" return longest common path prefix of 2 given paths.
" '~/home/usrname/wiki', '~/home/usrname/wiki/shmiki' => '~/home/usrname/wiki'
function! vimwiki#u#path_common_pfx(path1, path2) "{{{
let p1 = split(a:path1, '[/\\]', 1)
let p2 = split(a:path2, '[/\\]', 1)
let idx = 0
let minlen = min([len(p1), len(p2)])
while (idx < minlen) && (p1[idx] ==? p2[idx])
let idx = idx + 1
endwhile
if idx == 0
return ''
else
return join(p1[: idx-1], '/')
endif
endfunction "}}}

File diff suppressed because it is too large Load Diff

View File

@@ -1,475 +0,0 @@
" vim:tabstop=2:shiftwidth=2:expandtab:foldmethod=marker:textwidth=79
" Vimwiki filetype plugin file
" Author: Maxim Kim <habamax@gmail.com>
" Home: http://code.google.com/p/vimwiki/
if exists("b:did_ftplugin")
finish
endif
let b:did_ftplugin = 1 " Don't load another plugin for this buffer
" UNDO list {{{
" Reset the following options to undo this plugin.
let b:undo_ftplugin = "setlocal ".
\ "suffixesadd< isfname< comments< ".
\ "autowriteall< ".
\ "formatoptions< foldtext< ".
\ "foldmethod< foldexpr< commentstring< "
" UNDO }}}
" MISC STUFF {{{
setlocal autowriteall
setlocal commentstring=%%%s
if g:vimwiki_conceallevel && exists("+conceallevel")
let &conceallevel = g:vimwiki_conceallevel
endif
" MISC }}}
" GOTO FILE: gf {{{
execute 'setlocal suffixesadd='.VimwikiGet('ext')
setlocal isfname-=[,]
" gf}}}
" Autocreate list items {{{
" for list items, and list items with checkboxes
setlocal formatoptions+=tnro
setlocal formatoptions-=cq
if VimwikiGet('syntax') == 'default'
setl comments=b:*,b:#,b:-
setl formatlistpat=^\\s*[*#-]\\s*
elseif VimwikiGet('syntax') == 'markdown'
setlocal comments=fb:*,fb:-,fb:+,nb:> commentstring=\ >\ %s
setlocal formatlistpat=^\\s*\\d\\+\\.\\s\\+\\\|^[-*+]\\s\\+j
else
setl comments=n:*,n:#
endif
if !empty(&langmap)
" Valid only if langmap is a comma separated pairs of chars
let l_o = matchstr(&langmap, '\C,\zs.\zeo,')
if l_o
exe 'nnoremap <buffer> '.l_o.' :call vimwiki#lst#kbd_oO("o")<CR>a'
endif
let l_O = matchstr(&langmap, '\C,\zs.\zeO,')
if l_O
exe 'nnoremap <buffer> '.l_O.' :call vimwiki#lst#kbd_oO("O")<CR>a'
endif
endif
" COMMENTS }}}
" FOLDING for headers and list items using expr fold method. {{{
function! VimwikiFoldLevel(lnum) "{{{
let line = getline(a:lnum)
" Header folding...
if line =~ g:vimwiki_rxHeader
let n = vimwiki#u#count_first_sym(line)
return '>'.n
endif
let base_level = s:get_base_level(a:lnum)
" List item folding...
if g:vimwiki_fold_lists
let nnline = getline(a:lnum + 1)
let rx_list_item = '\('.
\ g:vimwiki_rxListBullet.'\|'.g:vimwiki_rxListNumber.
\ '\)'
if line =~ rx_list_item
let [nnum, nline] = s:find_forward(rx_list_item, a:lnum)
let level = s:get_li_level(a:lnum)
let leveln = s:get_li_level(nnum)
let adj = s:get_li_level(s:get_start_list(rx_list_item, a:lnum))
if leveln > level
return ">".(base_level+leveln-adj)
" check if multilined list item
elseif (nnum-a:lnum) > 1
\ && nline =~ rx_list_item && nnline !~ '^\s*$'
return ">".(base_level+level+1-adj)
else
return (base_level+level-adj)
endif
else
" process multilined list items
let [pnum, pline] = s:find_backward(rx_list_item, a:lnum)
if pline =~ rx_list_item
if indent(a:lnum) >= indent(pnum) && line !~ '^\s*$'
let level = s:get_li_level(pnum)
let adj = s:get_li_level(s:get_start_list(rx_list_item, pnum))
return (base_level+level+1-adj)
endif
endif
endif
endif
return base_level
endfunction "}}}
function! s:get_base_level(lnum) "{{{
let lnum = a:lnum - 1
while lnum > 0
if getline(lnum) =~ g:vimwiki_rxHeader
return vimwiki#u#count_first_sym(getline(lnum))
endif
let lnum -= 1
endwhile
return 0
endfunction "}}}
function! s:find_forward(rx_item, lnum) "{{{
let lnum = a:lnum + 1
while lnum <= line('$')
let line = getline(lnum)
if line =~ a:rx_item
\ || line =~ '^\S'
\ || line =~ g:vimwiki_rxHeader
break
endif
let lnum += 1
endwhile
return [lnum, getline(lnum)]
endfunction "}}}
function! s:find_backward(rx_item, lnum) "{{{
let lnum = a:lnum - 1
while lnum > 1
let line = getline(lnum)
if line =~ a:rx_item
\ || line =~ '^\S'
break
endif
let lnum -= 1
endwhile
return [lnum, getline(lnum)]
endfunction "}}}
function! s:get_li_level(lnum) "{{{
if VimwikiGet('syntax') == 'media'
let level = vimwiki#u#count_first_sym(getline(a:lnum))
else
let level = (indent(a:lnum) / &sw)
endif
return level
endfunction "}}}
function! s:get_start_list(rx_item, lnum) "{{{
let lnum = a:lnum
while lnum >= 1
let line = getline(lnum)
if line !~ a:rx_item && line =~ '^\S'
return nextnonblank(lnum + 1)
endif
let lnum -= 1
endwhile
return 0
endfunction "}}}
function! VimwikiFoldText() "{{{
let line = substitute(getline(v:foldstart), '\t',
\ repeat(' ', &tabstop), 'g')
return line.' ['.(v:foldend - v:foldstart).']'
endfunction "}}}
" FOLDING }}}
" COMMANDS {{{
command! -buffer Vimwiki2HTML
\ silent w <bar>
\ let res = vimwiki#html#Wiki2HTML(expand(VimwikiGet('path_html')),
\ expand('%'))
\<bar>
\ if res != '' | echo 'Vimwiki: HTML conversion is done.' | endif
command! -buffer Vimwiki2HTMLBrowse
\ silent w <bar>
\ call vimwiki#base#system_open_link(vimwiki#html#Wiki2HTML(
\ expand(VimwikiGet('path_html')),
\ expand('%')))
command! -buffer VimwikiAll2HTML
\ call vimwiki#html#WikiAll2HTML(expand(VimwikiGet('path_html')))
command! -buffer VimwikiNextLink call vimwiki#base#find_next_link()
command! -buffer VimwikiPrevLink call vimwiki#base#find_prev_link()
command! -buffer VimwikiDeleteLink call vimwiki#base#delete_link()
command! -buffer VimwikiRenameLink call vimwiki#base#rename_link()
command! -buffer VimwikiFollowLink call vimwiki#base#follow_link('nosplit')
command! -buffer VimwikiGoBackLink call vimwiki#base#go_back_link()
command! -buffer VimwikiSplitLink call vimwiki#base#follow_link('split')
command! -buffer VimwikiVSplitLink call vimwiki#base#follow_link('vsplit')
command! -buffer -nargs=? VimwikiNormalizeLink call vimwiki#base#normalize_link(<f-args>)
command! -buffer VimwikiTabnewLink call vimwiki#base#follow_link('tabnew')
command! -buffer -range VimwikiToggleListItem call vimwiki#lst#ToggleListItem(<line1>, <line2>)
command! -buffer VimwikiGenerateLinks call vimwiki#base#generate_links()
command! -buffer -nargs=0 VimwikiBacklinks call vimwiki#base#backlinks()
command! -buffer -nargs=0 VWB call vimwiki#base#backlinks()
exe 'command! -buffer -nargs=* VimwikiSearch lvimgrep <args> '.
\ escape(VimwikiGet('path').'**/*'.VimwikiGet('ext'), ' ')
exe 'command! -buffer -nargs=* VWS lvimgrep <args> '.
\ escape(VimwikiGet('path').'**/*'.VimwikiGet('ext'), ' ')
command! -buffer -nargs=1 VimwikiGoto call vimwiki#base#goto("<args>")
" list commands
command! -buffer -nargs=* VimwikiListChangeLevel call vimwiki#lst#change_level(<f-args>)
" table commands
command! -buffer -nargs=* VimwikiTable call vimwiki#tbl#create(<f-args>)
command! -buffer VimwikiTableAlignQ call vimwiki#tbl#align_or_cmd('gqq')
command! -buffer VimwikiTableAlignW call vimwiki#tbl#align_or_cmd('gww')
command! -buffer VimwikiTableMoveColumnLeft call vimwiki#tbl#move_column_left()
command! -buffer VimwikiTableMoveColumnRight call vimwiki#tbl#move_column_right()
" diary commands
command! -buffer VimwikiDiaryNextDay call vimwiki#diary#goto_next_day()
command! -buffer VimwikiDiaryPrevDay call vimwiki#diary#goto_prev_day()
" COMMANDS }}}
" KEYBINDINGS {{{
if g:vimwiki_use_mouse
nmap <buffer> <S-LeftMouse> <NOP>
nmap <buffer> <C-LeftMouse> <NOP>
nnoremap <silent><buffer> <2-LeftMouse> :call vimwiki#base#follow_link("nosplit", "\<lt>2-LeftMouse>")<CR>
nnoremap <silent><buffer> <S-2-LeftMouse> <LeftMouse>:VimwikiSplitLink<CR>
nnoremap <silent><buffer> <C-2-LeftMouse> <LeftMouse>:VimwikiVSplitLink<CR>
nnoremap <silent><buffer> <RightMouse><LeftMouse> :VimwikiGoBackLink<CR>
endif
if !hasmapto('<Plug>Vimwiki2HTML')
nmap <buffer> <Leader>wh <Plug>Vimwiki2HTML
endif
nnoremap <script><buffer>
\ <Plug>Vimwiki2HTML :Vimwiki2HTML<CR>
if !hasmapto('<Plug>Vimwiki2HTMLBrowse')
nmap <buffer> <Leader>whh <Plug>Vimwiki2HTMLBrowse
endif
nnoremap <script><buffer>
\ <Plug>Vimwiki2HTMLBrowse :Vimwiki2HTMLBrowse<CR>
if !hasmapto('<Plug>VimwikiFollowLink')
nmap <silent><buffer> <CR> <Plug>VimwikiFollowLink
endif
nnoremap <silent><script><buffer>
\ <Plug>VimwikiFollowLink :VimwikiFollowLink<CR>
if !hasmapto('<Plug>VimwikiSplitLink')
nmap <silent><buffer> <S-CR> <Plug>VimwikiSplitLink
endif
nnoremap <silent><script><buffer>
\ <Plug>VimwikiSplitLink :VimwikiSplitLink<CR>
if !hasmapto('<Plug>VimwikiVSplitLink')
nmap <silent><buffer> <C-CR> <Plug>VimwikiVSplitLink
endif
nnoremap <silent><script><buffer>
\ <Plug>VimwikiVSplitLink :VimwikiVSplitLink<CR>
if !hasmapto('<Plug>VimwikiNormalizeLink')
nmap <silent><buffer> + <Plug>VimwikiNormalizeLink
endif
nnoremap <silent><script><buffer>
\ <Plug>VimwikiNormalizeLink :VimwikiNormalizeLink 0<CR>
if !hasmapto('<Plug>VimwikiNormalizeLinkVisual')
vmap <silent><buffer> + <Plug>VimwikiNormalizeLinkVisual
endif
vnoremap <silent><script><buffer>
\ <Plug>VimwikiNormalizeLinkVisual :<C-U>VimwikiNormalizeLink 1<CR>
if !hasmapto('<Plug>VimwikiNormalizeLinkVisualCR')
vmap <silent><buffer> <CR> <Plug>VimwikiNormalizeLinkVisualCR
endif
vnoremap <silent><script><buffer>
\ <Plug>VimwikiNormalizeLinkVisualCR :<C-U>VimwikiNormalizeLink 1<CR>
if !hasmapto('<Plug>VimwikiTabnewLink')
nmap <silent><buffer> <D-CR> <Plug>VimwikiTabnewLink
nmap <silent><buffer> <C-S-CR> <Plug>VimwikiTabnewLink
endif
nnoremap <silent><script><buffer>
\ <Plug>VimwikiTabnewLink :VimwikiTabnewLink<CR>
if !hasmapto('<Plug>VimwikiGoBackLink')
nmap <silent><buffer> <BS> <Plug>VimwikiGoBackLink
endif
nnoremap <silent><script><buffer>
\ <Plug>VimwikiGoBackLink :VimwikiGoBackLink<CR>
if !hasmapto('<Plug>VimwikiNextLink')
nmap <silent><buffer> <TAB> <Plug>VimwikiNextLink
endif
nnoremap <silent><script><buffer>
\ <Plug>VimwikiNextLink :VimwikiNextLink<CR>
if !hasmapto('<Plug>VimwikiPrevLink')
nmap <silent><buffer> <S-TAB> <Plug>VimwikiPrevLink
endif
nnoremap <silent><script><buffer>
\ <Plug>VimwikiPrevLink :VimwikiPrevLink<CR>
if !hasmapto('<Plug>VimwikiDeleteLink')
nmap <silent><buffer> <Leader>wd <Plug>VimwikiDeleteLink
endif
nnoremap <silent><script><buffer>
\ <Plug>VimwikiDeleteLink :VimwikiDeleteLink<CR>
if !hasmapto('<Plug>VimwikiRenameLink')
nmap <silent><buffer> <Leader>wr <Plug>VimwikiRenameLink
endif
nnoremap <silent><script><buffer>
\ <Plug>VimwikiRenameLink :VimwikiRenameLink<CR>
if !hasmapto('<Plug>VimwikiToggleListItem')
nmap <silent><buffer> <C-Space> <Plug>VimwikiToggleListItem
vmap <silent><buffer> <C-Space> <Plug>VimwikiToggleListItem
if has("unix")
nmap <silent><buffer> <C-@> <Plug>VimwikiToggleListItem
endif
endif
nnoremap <silent><script><buffer>
\ <Plug>VimwikiToggleListItem :VimwikiToggleListItem<CR>
if !hasmapto('<Plug>VimwikiDiaryNextDay')
nmap <silent><buffer> <C-Down> <Plug>VimwikiDiaryNextDay
endif
nnoremap <silent><script><buffer>
\ <Plug>VimwikiDiaryNextDay :VimwikiDiaryNextDay<CR>
if !hasmapto('<Plug>VimwikiDiaryPrevDay')
nmap <silent><buffer> <C-Up> <Plug>VimwikiDiaryPrevDay
endif
nnoremap <silent><script><buffer>
\ <Plug>VimwikiDiaryPrevDay :VimwikiDiaryPrevDay<CR>
function! s:CR() "{{{
let res = vimwiki#lst#kbd_cr()
if res == "\<CR>" && g:vimwiki_table_mappings
let res = vimwiki#tbl#kbd_cr()
endif
return res
endfunction "}}}
" List and Table <CR> mapping
inoremap <buffer> <expr> <CR> <SID>CR()
" List mappings
nnoremap <buffer> o :<C-U>call vimwiki#lst#kbd_oO('o')<CR>
nnoremap <buffer> O :<C-U>call vimwiki#lst#kbd_oO('O')<CR>
nnoremap <buffer> gll :VimwikiListChangeLevel <<<CR>
nnoremap <buffer> glm :VimwikiListChangeLevel >><CR>
nnoremap <buffer> gl* :VimwikiListChangeLevel *<CR>
nnoremap <buffer> gl8 :VimwikiListChangeLevel *<CR>
if VimwikiGet('syntax') == 'default'
nnoremap <buffer> gl- :VimwikiListChangeLevel -<CR>
nnoremap <buffer> gl# :VimwikiListChangeLevel #<CR>
nnoremap <buffer> gl3 :VimwikiListChangeLevel #<CR>
elseif VimwikiGet('syntax') == 'markdown'
nnoremap <buffer> gl- :VimwikiListChangeLevel -<CR>
nnoremap <buffer> gl1 :VimwikiListChangeLevel 1.<CR>
elseif VimwikiGet('syntax') == 'media'
nnoremap <buffer> gl# :VimwikiListChangeLevel #<CR>
nnoremap <buffer> gl3 :VimwikiListChangeLevel #<CR>
endif
" Table mappings
if g:vimwiki_table_mappings
inoremap <expr> <buffer> <Tab> vimwiki#tbl#kbd_tab()
inoremap <expr> <buffer> <S-Tab> vimwiki#tbl#kbd_shift_tab()
endif
nnoremap <buffer> gqq :VimwikiTableAlignQ<CR>
nnoremap <buffer> gww :VimwikiTableAlignW<CR>
if !hasmapto('<Plug>VimwikiTableMoveColumnLeft')
nmap <silent><buffer> <A-Left> <Plug>VimwikiTableMoveColumnLeft
endif
nnoremap <silent><script><buffer>
\ <Plug>VimwikiTableMoveColumnLeft :VimwikiTableMoveColumnLeft<CR>
if !hasmapto('<Plug>VimwikiTableMoveColumnRight')
nmap <silent><buffer> <A-Right> <Plug>VimwikiTableMoveColumnRight
endif
nnoremap <silent><script><buffer>
\ <Plug>VimwikiTableMoveColumnRight :VimwikiTableMoveColumnRight<CR>
" Text objects {{{
onoremap <silent><buffer> ah :<C-U>call vimwiki#base#TO_header(0, 0)<CR>
vnoremap <silent><buffer> ah :<C-U>call vimwiki#base#TO_header(0, 1)<CR>
onoremap <silent><buffer> ih :<C-U>call vimwiki#base#TO_header(1, 0)<CR>
vnoremap <silent><buffer> ih :<C-U>call vimwiki#base#TO_header(1, 1)<CR>
onoremap <silent><buffer> a\ :<C-U>call vimwiki#base#TO_table_cell(0, 0)<CR>
vnoremap <silent><buffer> a\ :<C-U>call vimwiki#base#TO_table_cell(0, 1)<CR>
onoremap <silent><buffer> i\ :<C-U>call vimwiki#base#TO_table_cell(1, 0)<CR>
vnoremap <silent><buffer> i\ :<C-U>call vimwiki#base#TO_table_cell(1, 1)<CR>
onoremap <silent><buffer> ac :<C-U>call vimwiki#base#TO_table_col(0, 0)<CR>
vnoremap <silent><buffer> ac :<C-U>call vimwiki#base#TO_table_col(0, 1)<CR>
onoremap <silent><buffer> ic :<C-U>call vimwiki#base#TO_table_col(1, 0)<CR>
vnoremap <silent><buffer> ic :<C-U>call vimwiki#base#TO_table_col(1, 1)<CR>
if !hasmapto('<Plug>VimwikiAddHeaderLevel')
nmap <silent><buffer> = <Plug>VimwikiAddHeaderLevel
endif
nnoremap <silent><buffer> <Plug>VimwikiAddHeaderLevel :
\<C-U>call vimwiki#base#AddHeaderLevel()<CR>
if !hasmapto('<Plug>VimwikiRemoveHeaderLevel')
nmap <silent><buffer> - <Plug>VimwikiRemoveHeaderLevel
endif
nnoremap <silent><buffer> <Plug>VimwikiRemoveHeaderLevel :
\<C-U>call vimwiki#base#RemoveHeaderLevel()<CR>
" }}}
" KEYBINDINGS }}}
" AUTOCOMMANDS {{{
if VimwikiGet('auto_export')
" Automatically generate HTML on page write.
augroup vimwiki
au BufWritePost <buffer>
\ call vimwiki#html#Wiki2HTML(expand(VimwikiGet('path_html')),
\ expand('%'))
augroup END
endif
" AUTOCOMMANDS }}}
" PASTE, CAT URL {{{
" html commands
command! -buffer VimwikiPasteUrl call vimwiki#html#PasteUrl(expand('%:p'))
command! -buffer VimwikiCatUrl call vimwiki#html#CatUrl(expand('%:p'))
" }}}
" DEBUGGING {{{
command! VimwikiPrintWikiState call vimwiki#base#print_wiki_state()
command! VimwikiReadLocalOptions call vimwiki#base#read_wiki_options(1)
" }}}

View File

@@ -1,556 +0,0 @@
" vim:tabstop=2:shiftwidth=2:expandtab:foldmethod=marker:textwidth=79
" Vimwiki plugin file
" Author: Maxim Kim <habamax@gmail.com>
" Home: http://code.google.com/p/vimwiki/
" GetLatestVimScripts: 2226 1 :AutoInstall: vimwiki
if exists("loaded_vimwiki") || &cp
finish
endif
let loaded_vimwiki = 1
let s:old_cpo = &cpo
set cpo&vim
" Logging and performance instrumentation "{{{
let g:VimwikiLog = {}
let g:VimwikiLog.path = 0 " # of calls to VimwikiGet with path or path_html
let g:VimwikiLog.path_html = 0 " # of calls to path_html()
let g:VimwikiLog.normalize_path = 0 " # of calls to normalize_path()
let g:VimwikiLog.subdir = 0 " # of calls to vimwiki#base#subdir()
let g:VimwikiLog.timing = [] " various timing measurements
let g:VimwikiLog.html = [] " html conversion timing
function! VimwikiLog_extend(what,...) "{{{
call extend(g:VimwikiLog[a:what],a:000)
endfunction "}}}
"}}}
" HELPER functions {{{
function! s:default(varname, value) "{{{
if !exists('g:vimwiki_'.a:varname)
let g:vimwiki_{a:varname} = a:value
endif
endfunction "}}}
function! s:find_wiki(path) "{{{
" XXX: find_wiki() does not (yet) take into consideration the ext
let path = vimwiki#u#path_norm(vimwiki#u#chomp_slash(a:path))
let idx = 0
while idx < len(g:vimwiki_list)
let idx_path = expand(VimwikiGet('path', idx))
let idx_path = vimwiki#u#path_norm(vimwiki#u#chomp_slash(idx_path))
if vimwiki#u#path_common_pfx(idx_path, path) == idx_path
return idx
endif
let idx += 1
endwhile
return -1
" an orphan page has been detected
endfunction "}}}
function! s:vimwiki_idx() " {{{
if exists('b:vimwiki_idx')
return b:vimwiki_idx
else
return -1
endif
endfunction " }}}
function! s:setup_buffer_leave() "{{{
if g:vimwiki_debug ==3
echom "Setup_buffer_leave g:curr_idx=".g:vimwiki_current_idx." b:curr_idx=".s:vimwiki_idx().""
endif
if &filetype == 'vimwiki'
" cache global vars of current state XXX: SLOW!?
call vimwiki#base#cache_buffer_state()
endif
if g:vimwiki_debug ==3
echom " Setup_buffer_leave g:curr_idx=".g:vimwiki_current_idx." b:curr_idx=".s:vimwiki_idx().""
endif
" Set up menu
if g:vimwiki_menu != ""
exe 'nmenu disable '.g:vimwiki_menu.'.Table'
endif
endfunction "}}}
function! s:setup_filetype() "{{{
if g:vimwiki_debug ==3
echom "Setup_filetype g:curr_idx=".g:vimwiki_current_idx." b:curr_idx=".s:vimwiki_idx().""
endif
let time0 = reltime() " start the clock "XXX
" Find what wiki current buffer belongs to.
let path = expand('%:p:h')
" XXX: find_wiki() does not (yet) take into consideration the ext
let idx = s:find_wiki(path)
if g:vimwiki_debug ==3
echom " Setup_filetype g:curr_idx=".g:vimwiki_current_idx." find_idx=".idx." b:curr_idx=".s:vimwiki_idx().""
endif
if idx == -1 && g:vimwiki_global_ext == 0
return
endif
"XXX when idx = -1? (an orphan page has been detected)
"TODO: refactor (same code in setup_buffer_enter)
" The buffer's file is not in the path and user *does* want his wiki
" extension(s) to be global -- Add new wiki.
if idx == -1
let ext = '.'.expand('%:e')
" lookup syntax using g:vimwiki_ext2syntax
if has_key(g:vimwiki_ext2syntax, ext)
let syn = g:vimwiki_ext2syntax[ext]
else
let syn = s:vimwiki_defaults.syntax
endif
call add(g:vimwiki_list, {'path': path, 'ext': ext, 'syntax': syn, 'temp': 1})
let idx = len(g:vimwiki_list) - 1
endif
call vimwiki#base#validate_wiki_options(idx)
" initialize and cache global vars of current state
call vimwiki#base#setup_buffer_state(idx)
if g:vimwiki_debug ==3
echom " Setup_filetype g:curr_idx=".g:vimwiki_current_idx." (reset_wiki_state) b:curr_idx=".s:vimwiki_idx().""
endif
unlet! b:vimwiki_fs_rescan
set filetype=vimwiki
if g:vimwiki_debug ==3
echom " Setup_filetype g:curr_idx=".g:vimwiki_current_idx." (set ft=vimwiki) b:curr_idx=".s:vimwiki_idx().""
endif
let time1 = vimwiki#u#time(time0) "XXX
call VimwikiLog_extend('timing',['plugin:setup_filetype:time1',time1])
endfunction "}}}
function! s:setup_buffer_enter() "{{{
if g:vimwiki_debug ==3
echom "Setup_buffer_enter g:curr_idx=".g:vimwiki_current_idx." b:curr_idx=".s:vimwiki_idx().""
endif
let time0 = reltime() " start the clock "XXX
if !vimwiki#base#recall_buffer_state()
" Find what wiki current buffer belongs to.
" If wiki does not exist in g:vimwiki_list -- add new wiki there with
" buffer's path and ext.
" Else set g:vimwiki_current_idx to that wiki index.
let path = expand('%:p:h')
" XXX: find_wiki() does not (yet) take into consideration the ext
let idx = s:find_wiki(path)
if g:vimwiki_debug ==3
echom " Setup_buffer_enter g:curr_idx=".g:vimwiki_current_idx." find_idx=".idx." b:curr_idx=".s:vimwiki_idx().""
endif
" The buffer's file is not in the path and user *does NOT* want his wiki
" extension to be global -- Do not add new wiki.
if idx == -1 && g:vimwiki_global_ext == 0
return
endif
"TODO: refactor (same code in setup_filetype)
" The buffer's file is not in the path and user *does* want his wiki
" extension(s) to be global -- Add new wiki.
if idx == -1
let ext = '.'.expand('%:e')
" lookup syntax using g:vimwiki_ext2syntax
if has_key(g:vimwiki_ext2syntax, ext)
let syn = g:vimwiki_ext2syntax[ext]
else
let syn = s:vimwiki_defaults.syntax
endif
call add(g:vimwiki_list, {'path': path, 'ext': ext, 'syntax': syn, 'temp': 1})
let idx = len(g:vimwiki_list) - 1
endif
call vimwiki#base#validate_wiki_options(idx)
" initialize and cache global vars of current state
call vimwiki#base#setup_buffer_state(idx)
if g:vimwiki_debug ==3
echom " Setup_buffer_enter g:curr_idx=".g:vimwiki_current_idx." (reset_wiki_state) b:curr_idx=".s:vimwiki_idx().""
endif
endif
" If you have
" au GUIEnter * VimwikiIndex
" Then change it to
" au GUIEnter * nested VimwikiIndex
if &filetype == ''
set filetype=vimwiki
if g:vimwiki_debug ==3
echom " Setup_buffer_enter g:curr_idx=".g:vimwiki_current_idx." (set ft vimwiki) b:curr_idx=".s:vimwiki_idx().""
endif
elseif &syntax == 'vimwiki'
" to force a rescan of the filesystem which may have changed
" and update VimwikiLinks syntax group that depends on it;
" b:vimwiki_fs_rescan indicates that setup_filetype() has not been run
if exists("b:vimwiki_fs_rescan") && VimwikiGet('maxhi')
set syntax=vimwiki
if g:vimwiki_debug ==3
echom " Setup_buffer_enter g:curr_idx=".g:vimwiki_current_idx." (set syntax=vimwiki) b:curr_idx=".s:vimwiki_idx().""
endif
endif
let b:vimwiki_fs_rescan = 1
endif
let time1 = vimwiki#u#time(time0) "XXX
" Settings foldmethod, foldexpr and foldtext are local to window. Thus in a
" new tab with the same buffer folding is reset to vim defaults. So we
" insist vimwiki folding here.
if g:vimwiki_folding == 2 && &fdm != 'expr'
" User-defined fold-expression, and fold-text
endif
if g:vimwiki_folding == 1
setlocal fdm=expr
setlocal foldexpr=VimwikiFoldLevel(v:lnum)
setlocal foldtext=VimwikiFoldText()
endif
" And conceal level too.
if g:vimwiki_conceallevel && exists("+conceallevel")
let &conceallevel = g:vimwiki_conceallevel
endif
" Set up menu
if g:vimwiki_menu != ""
exe 'nmenu enable '.g:vimwiki_menu.'.Table'
endif
"let time2 = vimwiki#u#time(time0) "XXX
call VimwikiLog_extend('timing',['plugin:setup_buffer_enter:time1',time1])
endfunction "}}}
function! s:setup_buffer_reenter() "{{{
if g:vimwiki_debug ==3
echom "Setup_buffer_reenter g:curr_idx=".g:vimwiki_current_idx." b:curr_idx=".s:vimwiki_idx().""
endif
if !vimwiki#base#recall_buffer_state()
" Do not repeat work of s:setup_buffer_enter() and s:setup_filetype()
" Once should be enough ...
endif
if g:vimwiki_debug ==3
echom " Setup_buffer_reenter g:curr_idx=".g:vimwiki_current_idx." b:curr_idx=".s:vimwiki_idx().""
endif
endfunction "}}}
function! s:setup_cleared_syntax() "{{{ highlight groups that get cleared
" on colorscheme change because they are not linked to Vim-predefined groups
hi def VimwikiBold term=bold cterm=bold gui=bold
hi def VimwikiItalic term=italic cterm=italic gui=italic
hi def VimwikiBoldItalic term=bold cterm=bold gui=bold,italic
hi def VimwikiUnderline gui=underline
if g:vimwiki_hl_headers == 1
for i in range(1,6)
execute 'hi def VimwikiHeader'.i.' guibg=bg guifg='.g:vimwiki_hcolor_guifg_{&bg}[i-1].' gui=bold ctermfg='.g:vimwiki_hcolor_ctermfg_{&bg}[i-1].' term=bold cterm=bold'
endfor
endif
endfunction "}}}
" OPTION get/set functions {{{
" return complete list of options
function! VimwikiGetOptionNames() "{{{
return keys(s:vimwiki_defaults)
endfunction "}}}
function! VimwikiGetOptions(...) "{{{
let idx = a:0 == 0 ? g:vimwiki_current_idx : a:1
let option_dict = {}
for kk in keys(s:vimwiki_defaults)
let option_dict[kk] = VimwikiGet(kk, idx)
endfor
return option_dict
endfunction "}}}
" Return value of option for current wiki or if second parameter exists for
" wiki with a given index.
" If the option is not found, it is assumed to have been previously cached in a
" buffer local dictionary, that acts as a cache.
" If the option is not found in the buffer local dictionary, an error is thrown
function! VimwikiGet(option, ...) "{{{
let idx = a:0 == 0 ? g:vimwiki_current_idx : a:1
if has_key(g:vimwiki_list[idx], a:option)
let val = g:vimwiki_list[idx][a:option]
elseif has_key(s:vimwiki_defaults, a:option)
let val = s:vimwiki_defaults[a:option]
let g:vimwiki_list[idx][a:option] = val
else
let val = b:vimwiki_list[a:option]
endif
" XXX no call to vimwiki#base here or else the whole autoload/base gets loaded!
return val
endfunction "}}}
" Set option for current wiki or if third parameter exists for
" wiki with a given index.
" If the option is not found or recognized (i.e. does not exist in
" s:vimwiki_defaults), it is saved in a buffer local dictionary, that acts
" as a cache.
" If the option is not found in the buffer local dictionary, an error is thrown
function! VimwikiSet(option, value, ...) "{{{
let idx = a:0 == 0 ? g:vimwiki_current_idx : a:1
if has_key(s:vimwiki_defaults, a:option) ||
\ has_key(g:vimwiki_list[idx], a:option)
let g:vimwiki_list[idx][a:option] = a:value
elseif exists('b:vimwiki_list')
let b:vimwiki_list[a:option] = a:value
else
let b:vimwiki_list = {}
let b:vimwiki_list[a:option] = a:value
endif
endfunction "}}}
" Clear option for current wiki or if third parameter exists for
" wiki with a given index.
" Currently, only works if option was previously saved in the buffer local
" dictionary, that acts as a cache.
function! VimwikiClear(option, ...) "{{{
let idx = a:0 == 0 ? g:vimwiki_current_idx : a:1
if exists('b:vimwiki_list') && has_key(b:vimwiki_list, a:option)
call remove(b:vimwiki_list, a:option)
endif
endfunction "}}}
" }}}
" }}}
" CALLBACK functions "{{{
" User can redefine it.
if !exists("*VimwikiLinkHandler") "{{{
function VimwikiLinkHandler(url)
return 0
endfunction
endif "}}}
if !exists("*VimwikiWikiIncludeHandler") "{{{
function! VimwikiWikiIncludeHandler(value) "{{{
" Return the empty string when unable to process link
return ''
endfunction "}}}
endif "}}}
" CALLBACK }}}
" DEFAULT wiki {{{
let s:vimwiki_defaults = {}
let s:vimwiki_defaults.path = '~/vimwiki/'
let s:vimwiki_defaults.path_html = '' " '' is replaced by derived path.'_html/'
let s:vimwiki_defaults.css_name = 'style.css'
let s:vimwiki_defaults.index = 'index'
let s:vimwiki_defaults.ext = '.wiki'
let s:vimwiki_defaults.maxhi = 0
let s:vimwiki_defaults.syntax = 'default'
let s:vimwiki_defaults.template_path = ''
let s:vimwiki_defaults.template_default = ''
let s:vimwiki_defaults.template_ext = ''
let s:vimwiki_defaults.nested_syntaxes = {}
let s:vimwiki_defaults.auto_export = 0
" is wiki temporary -- was added to g:vimwiki_list by opening arbitrary wiki
" file.
let s:vimwiki_defaults.temp = 0
" diary
let s:vimwiki_defaults.diary_rel_path = 'diary/'
let s:vimwiki_defaults.diary_index = 'diary'
let s:vimwiki_defaults.diary_header = 'Diary'
let s:vimwiki_defaults.diary_sort = 'desc'
" Do not change this! Will wait till vim become more datetime awareable.
let s:vimwiki_defaults.diary_link_fmt = '%Y-%m-%d'
" NEW! in v2.0
" custom_wiki2html
let s:vimwiki_defaults.custom_wiki2html = ''
"
let s:vimwiki_defaults.list_margin = -1
"}}}
" DEFAULT options {{{
call s:default('list', [s:vimwiki_defaults])
call s:default('auto_checkbox', 1)
call s:default('use_mouse', 0)
call s:default('folding', 0)
call s:default('fold_trailing_empty_lines', 0)
call s:default('fold_lists', 0)
call s:default('menu', 'Vimwiki')
call s:default('global_ext', 1)
call s:default('ext2syntax', {'.md': 'markdown'}) " syntax map keyed on extension
call s:default('hl_headers', 0)
call s:default('hl_cb_checked', 0)
call s:default('list_ignore_newline', 1)
call s:default('listsyms', ' .oOX')
call s:default('use_calendar', 1)
call s:default('table_mappings', 1)
call s:default('table_auto_fmt', 1)
call s:default('w32_dir_enc', '')
call s:default('CJK_length', 0)
call s:default('dir_link', '')
call s:default('valid_html_tags', 'b,i,s,u,sub,sup,kbd,br,hr,div,center,strong,em')
call s:default('user_htmls', '')
call s:default('html_header_numbering', 0)
call s:default('html_header_numbering_sym', '')
call s:default('conceallevel', 2)
call s:default('url_mingain', 12)
call s:default('url_maxsave', 15)
call s:default('debug', 0)
call s:default('diary_months',
\ {
\ 1: 'January', 2: 'February', 3: 'March',
\ 4: 'April', 5: 'May', 6: 'June',
\ 7: 'July', 8: 'August', 9: 'September',
\ 10: 'October', 11: 'November', 12: 'December'
\ })
call s:default('current_idx', 0)
" Scheme regexes should be defined even if syntax file is not loaded yet
" cause users should be able to <leader>w<leader>w without opening any
" vimwiki file first
" Scheme regexes {{{
call s:default('schemes', 'wiki\d\+,diary,local')
call s:default('web_schemes1', 'http,https,file,ftp,gopher,telnet,nntp,ldap,'.
\ 'rsync,imap,pop,irc,ircs,cvs,svn,svn+ssh,git,ssh,fish,sftp')
call s:default('web_schemes2', 'mailto,news,xmpp,sip,sips,doi,urn,tel')
let rxSchemes = '\%('.
\ join(split(g:vimwiki_schemes, '\s*,\s*'), '\|').'\|'.
\ join(split(g:vimwiki_web_schemes1, '\s*,\s*'), '\|').'\|'.
\ join(split(g:vimwiki_web_schemes2, '\s*,\s*'), '\|').
\ '\)'
call s:default('rxSchemeUrl', rxSchemes.':.*')
call s:default('rxSchemeUrlMatchScheme', '\zs'.rxSchemes.'\ze:.*')
call s:default('rxSchemeUrlMatchUrl', rxSchemes.':\zs.*\ze')
" scheme regexes }}}
"}}}
" AUTOCOMMANDS for all known wiki extensions {{{
let extensions = vimwiki#base#get_known_extensions()
augroup filetypedetect
" clear FlexWiki's stuff
au! * *.wiki
augroup end
augroup vimwiki
autocmd!
for ext in extensions
exe 'autocmd BufEnter *'.ext.' call s:setup_buffer_reenter()'
exe 'autocmd BufWinEnter *'.ext.' call s:setup_buffer_enter()'
exe 'autocmd BufLeave,BufHidden *'.ext.' call s:setup_buffer_leave()'
exe 'autocmd BufNewFile,BufRead, *'.ext.' call s:setup_filetype()'
exe 'autocmd ColorScheme *'.ext.' call s:setup_cleared_syntax()'
" Format tables when exit from insert mode. Do not use textwidth to
" autowrap tables.
if g:vimwiki_table_auto_fmt
exe 'autocmd InsertLeave *'.ext.' call vimwiki#tbl#format(line("."))'
exe 'autocmd InsertEnter *'.ext.' call vimwiki#tbl#reset_tw(line("."))'
endif
endfor
augroup END
"}}}
" COMMANDS {{{
command! VimwikiUISelect call vimwiki#base#ui_select()
" XXX: why not using <count> instead of v:count1?
" See Issue 324.
command! -count=1 VimwikiIndex
\ call vimwiki#base#goto_index(v:count1)
command! -count=1 VimwikiTabIndex
\ call vimwiki#base#goto_index(v:count1, 1)
command! -count=1 VimwikiDiaryIndex
\ call vimwiki#diary#goto_diary_index(v:count1)
command! -count=1 VimwikiMakeDiaryNote
\ call vimwiki#diary#make_note(v:count1)
command! -count=1 VimwikiTabMakeDiaryNote
\ call vimwiki#diary#make_note(v:count1, 1)
command! VimwikiDiaryGenerateLinks
\ call vimwiki#diary#generate_diary_section()
"}}}
" MAPPINGS {{{
if !hasmapto('<Plug>VimwikiIndex')
nmap <silent><unique> <Leader>ww <Plug>VimwikiIndex
endif
nnoremap <unique><script> <Plug>VimwikiIndex :VimwikiIndex<CR>
if !hasmapto('<Plug>VimwikiTabIndex')
nmap <silent><unique> <Leader>wt <Plug>VimwikiTabIndex
endif
nnoremap <unique><script> <Plug>VimwikiTabIndex :VimwikiTabIndex<CR>
if !hasmapto('<Plug>VimwikiUISelect')
nmap <silent><unique> <Leader>ws <Plug>VimwikiUISelect
endif
nnoremap <unique><script> <Plug>VimwikiUISelect :VimwikiUISelect<CR>
if !hasmapto('<Plug>VimwikiDiaryIndex')
nmap <silent><unique> <Leader>wi <Plug>VimwikiDiaryIndex
endif
nnoremap <unique><script> <Plug>VimwikiDiaryIndex :VimwikiDiaryIndex<CR>
if !hasmapto('<Plug>VimwikiDiaryGenerateLinks')
nmap <silent><unique> <Leader>w<Leader>i <Plug>VimwikiDiaryGenerateLinks
endif
nnoremap <unique><script> <Plug>VimwikiDiaryGenerateLinks :VimwikiDiaryGenerateLinks<CR>
if !hasmapto('<Plug>VimwikiMakeDiaryNote')
nmap <silent><unique> <Leader>w<Leader>w <Plug>VimwikiMakeDiaryNote
endif
nnoremap <unique><script> <Plug>VimwikiMakeDiaryNote :VimwikiMakeDiaryNote<CR>
if !hasmapto('<Plug>VimwikiTabMakeDiaryNote')
nmap <silent><unique> <Leader>w<Leader>t <Plug>VimwikiTabMakeDiaryNote
endif
nnoremap <unique><script> <Plug>VimwikiTabMakeDiaryNote
\ :VimwikiTabMakeDiaryNote<CR>
"}}}
" MENU {{{
function! s:build_menu(topmenu)
let idx = 0
while idx < len(g:vimwiki_list)
let norm_path = fnamemodify(VimwikiGet('path', idx), ':h:t')
let norm_path = escape(norm_path, '\ \.')
execute 'menu '.a:topmenu.'.Open\ index.'.norm_path.
\ ' :call vimwiki#base#goto_index('.(idx + 1).')<CR>'
execute 'menu '.a:topmenu.'.Open/Create\ diary\ note.'.norm_path.
\ ' :call vimwiki#diary#make_note('.(idx + 1).')<CR>'
let idx += 1
endwhile
endfunction
function! s:build_table_menu(topmenu)
exe 'menu '.a:topmenu.'.-Sep- :'
exe 'menu '.a:topmenu.'.Table.Create\ (enter\ cols\ rows) :VimwikiTable '
exe 'nmenu '.a:topmenu.'.Table.Format<tab>gqq gqq'
exe 'nmenu '.a:topmenu.'.Table.Move\ column\ left<tab><A-Left> :VimwikiTableMoveColumnLeft<CR>'
exe 'nmenu '.a:topmenu.'.Table.Move\ column\ right<tab><A-Right> :VimwikiTableMoveColumnRight<CR>'
exe 'nmenu disable '.a:topmenu.'.Table'
endfunction
"XXX make sure anything below does not cause autoload/base to be loaded
if !empty(g:vimwiki_menu)
call s:build_menu(g:vimwiki_menu)
call s:build_table_menu(g:vimwiki_menu)
endif
" }}}
" CALENDAR Hook "{{{
if g:vimwiki_use_calendar
let g:calendar_action = 'vimwiki#diary#calendar_action'
let g:calendar_sign = 'vimwiki#diary#calendar_sign'
endif
"}}}
let &cpo = s:old_cpo

View File

@@ -1,601 +0,0 @@
" vim:tabstop=2:shiftwidth=2:expandtab:foldmethod=marker:textwidth=79
" Vimwiki syntax file
" Author: Maxim Kim <habamax@gmail.com>
" Home: http://code.google.com/p/vimwiki/
" Quit if syntax file is already loaded
if version < 600
syntax clear
elseif exists("b:current_syntax")
finish
endif
"TODO do nothing if ...? (?)
let starttime = reltime() " start the clock
if VimwikiGet('maxhi')
let b:existing_wikifiles = vimwiki#base#get_links('*'.VimwikiGet('ext'))
let b:existing_wikidirs = vimwiki#base#get_links('*/')
endif
let timescans = vimwiki#u#time(starttime) "XXX
"let b:xxx = 1
"TODO ? update wikilink syntax group here if really needed (?) for :e and such
"if VimwikiGet('maxhi')
" ...
"endif
" LINKS: assume this is common to all syntaxes "{{{
" LINKS: WebLinks {{{
" match URL for common protocols;
" see http://en.wikipedia.org/wiki/URI_scheme http://tools.ietf.org/html/rfc3986
let g:vimwiki_rxWebProtocols = ''.
\ '\%('.
\ '\%('.
\ '\%('.join(split(g:vimwiki_web_schemes1, '\s*,\s*'), '\|').'\):'.
\ '\%(//\)'.
\ '\)'.
\ '\|'.
\ '\%('.join(split(g:vimwiki_web_schemes2, '\s*,\s*'), '\|').'\):'.
\ '\)'
"
let g:vimwiki_rxWeblinkUrl = g:vimwiki_rxWebProtocols .
\ '\S\{-1,}'. '\%(([^ \t()]*)\)\='
" }}}
" }}}
" -------------------------------------------------------------------------
" Load concrete Wiki syntax: sets regexes and templates for headers and links
execute 'runtime! syntax/vimwiki_'.VimwikiGet('syntax').'.vim'
" -------------------------------------------------------------------------
let time0 = vimwiki#u#time(starttime) "XXX
" LINKS: setup of larger regexes {{{
" LINKS: setup wikilink regexps {{{
let g:vimwiki_rxWikiLinkPrefix = '[['
let g:vimwiki_rxWikiLinkSuffix = ']]'
let g:vimwiki_rxWikiLinkSeparator = '|'
" [[URL]]
let g:vimwiki_WikiLinkTemplate1 = g:vimwiki_rxWikiLinkPrefix . '__LinkUrl__'.
\ g:vimwiki_rxWikiLinkSuffix
" [[URL|DESCRIPTION]]
let g:vimwiki_WikiLinkTemplate2 = g:vimwiki_rxWikiLinkPrefix . '__LinkUrl__'.
\ g:vimwiki_rxWikiLinkSeparator. '__LinkDescription__'.
\ g:vimwiki_rxWikiLinkSuffix
"
let magic_chars = '.*[]\^$'
let valid_chars = '[^\\]'
let g:vimwiki_rxWikiLinkPrefix = escape(g:vimwiki_rxWikiLinkPrefix, magic_chars)
let g:vimwiki_rxWikiLinkSuffix = escape(g:vimwiki_rxWikiLinkSuffix, magic_chars)
let g:vimwiki_rxWikiLinkSeparator = escape(g:vimwiki_rxWikiLinkSeparator, magic_chars)
let g:vimwiki_rxWikiLinkUrl = valid_chars.'\{-}'
let g:vimwiki_rxWikiLinkDescr = valid_chars.'\{-}'
let g:vimwiki_rxWord = '[^[:blank:]()\\]\+'
"
" [[URL]], or [[URL|DESCRIPTION]]
" a) match [[URL|DESCRIPTION]]
let g:vimwiki_rxWikiLink = g:vimwiki_rxWikiLinkPrefix.
\ g:vimwiki_rxWikiLinkUrl.'\%('.g:vimwiki_rxWikiLinkSeparator.
\ g:vimwiki_rxWikiLinkDescr.'\)\?'.g:vimwiki_rxWikiLinkSuffix
" b) match URL within [[URL|DESCRIPTION]]
let g:vimwiki_rxWikiLinkMatchUrl = g:vimwiki_rxWikiLinkPrefix.
\ '\zs'. g:vimwiki_rxWikiLinkUrl.'\ze\%('. g:vimwiki_rxWikiLinkSeparator.
\ g:vimwiki_rxWikiLinkDescr.'\)\?'.g:vimwiki_rxWikiLinkSuffix
" c) match DESCRIPTION within [[URL|DESCRIPTION]]
let g:vimwiki_rxWikiLinkMatchDescr = g:vimwiki_rxWikiLinkPrefix.
\ g:vimwiki_rxWikiLinkUrl.g:vimwiki_rxWikiLinkSeparator.'\%('.
\ '\zs'. g:vimwiki_rxWikiLinkDescr. '\ze\)\?'. g:vimwiki_rxWikiLinkSuffix
" }}}
" LINKS: Syntax helper {{{
let g:vimwiki_rxWikiLinkPrefix1 = g:vimwiki_rxWikiLinkPrefix.
\ g:vimwiki_rxWikiLinkUrl.g:vimwiki_rxWikiLinkSeparator
let g:vimwiki_rxWikiLinkSuffix1 = g:vimwiki_rxWikiLinkSuffix
" }}}
" LINKS: setup of wikiincl regexps {{{
let g:vimwiki_rxWikiInclPrefix = '{{'
let g:vimwiki_rxWikiInclSuffix = '}}'
let g:vimwiki_rxWikiInclSeparator = '|'
"
" '{{__LinkUrl__}}'
let g:vimwiki_WikiInclTemplate1 = g:vimwiki_rxWikiInclPrefix . '__LinkUrl__'.
\ g:vimwiki_rxWikiInclSuffix
" '{{__LinkUrl____LinkDescription__}}'
let g:vimwiki_WikiInclTemplate2 = g:vimwiki_rxWikiInclPrefix . '__LinkUrl__'.
\ '__LinkDescription__'.
\ g:vimwiki_rxWikiInclSuffix
let g:vimwiki_rxWikiInclPrefix = escape(g:vimwiki_rxWikiInclPrefix, magic_chars)
let g:vimwiki_rxWikiInclSuffix = escape(g:vimwiki_rxWikiInclSuffix, magic_chars)
let g:vimwiki_rxWikiInclSeparator = escape(g:vimwiki_rxWikiInclSeparator, magic_chars)
let g:vimwiki_rxWikiInclUrl = valid_chars.'\{-}'
let g:vimwiki_rxWikiInclArg = valid_chars.'\{-}'
let g:vimwiki_rxWikiInclArgs = '\%('. g:vimwiki_rxWikiInclSeparator. g:vimwiki_rxWikiInclArg. '\)'.'\{-}'
"
"
" *. {{URL}[{...}]} - i.e. {{URL}}, {{URL|ARG1}}, {{URL|ARG1|ARG2}}, etc.
" *a) match {{URL}[{...}]}
let g:vimwiki_rxWikiIncl = g:vimwiki_rxWikiInclPrefix.
\ g:vimwiki_rxWikiInclUrl.
\ g:vimwiki_rxWikiInclArgs. g:vimwiki_rxWikiInclSuffix
" *b) match URL within {{URL}[{...}]}
let g:vimwiki_rxWikiInclMatchUrl = g:vimwiki_rxWikiInclPrefix.
\ '\zs'. g:vimwiki_rxWikiInclUrl. '\ze'.
\ g:vimwiki_rxWikiInclArgs. g:vimwiki_rxWikiInclSuffix
" }}}
" LINKS: Syntax helper {{{
let g:vimwiki_rxWikiInclPrefix1 = g:vimwiki_rxWikiInclPrefix.
\ g:vimwiki_rxWikiInclUrl.g:vimwiki_rxWikiInclSeparator
let g:vimwiki_rxWikiInclSuffix1 = g:vimwiki_rxWikiInclArgs.
\ g:vimwiki_rxWikiInclSuffix
" }}}
" LINKS: Setup weblink regexps {{{
" 0. URL : free-standing links: keep URL UR(L) strip trailing punct: URL; URL) UR(L))
" let g:vimwiki_rxWeblink = '[\["(|]\@<!'. g:vimwiki_rxWeblinkUrl .
" \ '\%([),:;.!?]\=\%([ \t]\|$\)\)\@='
" Maxim:
" Simplify free-standing links: URL starts with non(letter|digit)scheme till
" the whitespace.
" Stuart, could you check it with markdown templated links? [](http://...), as
" the last bracket is the part of URL now?
let g:vimwiki_rxWeblink = '[[:alnum:]]\@<!'. g:vimwiki_rxWeblinkUrl . '\S*'
" 0a) match URL within URL
let g:vimwiki_rxWeblinkMatchUrl = g:vimwiki_rxWeblink
" 0b) match DESCRIPTION within URL
let g:vimwiki_rxWeblinkMatchDescr = ''
" }}}
" LINKS: Setup anylink regexps {{{
let g:vimwiki_rxAnyLink = g:vimwiki_rxWikiLink.'\|'.
\ g:vimwiki_rxWikiIncl.'\|'.g:vimwiki_rxWeblink
" }}}
" }}} end of Links
" LINKS: highlighting is complicated due to "nonexistent" links feature {{{
function! s:add_target_syntax_ON(target, type) " {{{
if g:vimwiki_debug > 1
echom '[vimwiki_debug] syntax target > '.a:target
endif
let prefix0 = 'syntax match '.a:type.' `'
let suffix0 = '` display contains=@NoSpell,VimwikiLinkRest,'.a:type.'Char'
let prefix1 = 'syntax match '.a:type.'T `'
let suffix1 = '` display contained'
execute prefix0. a:target. suffix0
execute prefix1. a:target. suffix1
endfunction "}}}
function! s:add_target_syntax_OFF(target) " {{{
if g:vimwiki_debug > 1
echom '[vimwiki_debug] syntax target > '.a:target
endif
let prefix0 = 'syntax match VimwikiNoExistsLink `'
let suffix0 = '` display contains=@NoSpell,VimwikiLinkRest,VimwikiLinkChar'
let prefix1 = 'syntax match VimwikiNoExistsLinkT `'
let suffix1 = '` display contained'
execute prefix0. a:target. suffix0
execute prefix1. a:target. suffix1
endfunction "}}}
function! s:highlight_existing_links() "{{{
" Wikilink
" Conditional highlighting that depends on the existence of a wiki file or
" directory is only available for *schemeless* wiki links
" Links are set up upon BufEnter (see plugin/...)
let safe_links = vimwiki#base#file_pattern(b:existing_wikifiles)
" Wikilink Dirs set up upon BufEnter (see plugin/...)
let safe_dirs = vimwiki#base#file_pattern(b:existing_wikidirs)
" match [[URL]]
let target = vimwiki#base#apply_template(g:vimwiki_WikiLinkTemplate1,
\ safe_links, g:vimwiki_rxWikiLinkDescr, '')
call s:add_target_syntax_ON(target, 'VimwikiLink')
" match [[URL|DESCRIPTION]]
let target = vimwiki#base#apply_template(g:vimwiki_WikiLinkTemplate2,
\ safe_links, g:vimwiki_rxWikiLinkDescr, '')
call s:add_target_syntax_ON(target, 'VimwikiLink')
" match {{URL}}
let target = vimwiki#base#apply_template(g:vimwiki_WikiInclTemplate1,
\ safe_links, g:vimwiki_rxWikiInclArgs, '')
call s:add_target_syntax_ON(target, 'VimwikiLink')
" match {{URL|...}}
let target = vimwiki#base#apply_template(g:vimwiki_WikiInclTemplate2,
\ safe_links, g:vimwiki_rxWikiInclArgs, '')
call s:add_target_syntax_ON(target, 'VimwikiLink')
" match [[DIRURL]]
let target = vimwiki#base#apply_template(g:vimwiki_WikiLinkTemplate1,
\ safe_dirs, g:vimwiki_rxWikiLinkDescr, '')
call s:add_target_syntax_ON(target, 'VimwikiLink')
" match [[DIRURL|DESCRIPTION]]
let target = vimwiki#base#apply_template(g:vimwiki_WikiLinkTemplate2,
\ safe_dirs, g:vimwiki_rxWikiLinkDescr, '')
call s:add_target_syntax_ON(target, 'VimwikiLink')
endfunction "}}}
" use max highlighting - could be quite slow if there are too many wikifiles
if VimwikiGet('maxhi')
" WikiLink
call s:add_target_syntax_OFF(g:vimwiki_rxWikiLink)
" WikiIncl
call s:add_target_syntax_OFF(g:vimwiki_rxWikiIncl)
" Subsequently, links verified on vimwiki's path are highlighted as existing
let time01 = vimwiki#u#time(starttime) "XXX
call s:highlight_existing_links()
let time02 = vimwiki#u#time(starttime) "XXX
else
let time01 = vimwiki#u#time(starttime) "XXX
" Wikilink
call s:add_target_syntax_ON(g:vimwiki_rxWikiLink, 'VimwikiLink')
" WikiIncl
call s:add_target_syntax_ON(g:vimwiki_rxWikiIncl, 'VimwikiLink')
let time02 = vimwiki#u#time(starttime) "XXX
endif
" Weblink
call s:add_target_syntax_ON(g:vimwiki_rxWeblink, 'VimwikiLink')
" WikiLink
" All remaining schemes are highlighted automatically
let rxSchemes = '\%('.
\ join(split(g:vimwiki_schemes, '\s*,\s*'), '\|').'\|'.
\ join(split(g:vimwiki_web_schemes1, '\s*,\s*'), '\|').
\ '\):'
" a) match [[nonwiki-scheme-URL]]
let target = vimwiki#base#apply_template(g:vimwiki_WikiLinkTemplate1,
\ rxSchemes.g:vimwiki_rxWikiLinkUrl, g:vimwiki_rxWikiLinkDescr, '')
call s:add_target_syntax_ON(target, 'VimwikiLink')
" b) match [[nonwiki-scheme-URL|DESCRIPTION]]
let target = vimwiki#base#apply_template(g:vimwiki_WikiLinkTemplate2,
\ rxSchemes.g:vimwiki_rxWikiLinkUrl, g:vimwiki_rxWikiLinkDescr, '')
call s:add_target_syntax_ON(target, 'VimwikiLink')
" a) match {{nonwiki-scheme-URL}}
let target = vimwiki#base#apply_template(g:vimwiki_WikiInclTemplate1,
\ rxSchemes.g:vimwiki_rxWikiInclUrl, g:vimwiki_rxWikiInclArgs, '')
call s:add_target_syntax_ON(target, 'VimwikiLink')
" b) match {{nonwiki-scheme-URL}[{...}]}
let target = vimwiki#base#apply_template(g:vimwiki_WikiInclTemplate2,
\ rxSchemes.g:vimwiki_rxWikiInclUrl, g:vimwiki_rxWikiInclArgs, '')
call s:add_target_syntax_ON(target, 'VimwikiLink')
" }}}
" generic headers "{{{
if g:vimwiki_symH
"" symmetric
for i in range(1,6)
let g:vimwiki_rxH{i}_Template = repeat(g:vimwiki_rxH, i).' __Header__ '.repeat(g:vimwiki_rxH, i)
let g:vimwiki_rxH{i} = '^\s*'.g:vimwiki_rxH.'\{'.i.'}[^'.g:vimwiki_rxH.'].*[^'.g:vimwiki_rxH.']'.g:vimwiki_rxH.'\{'.i.'}\s*$'
endfor
let g:vimwiki_rxHeader = '^\s*\('.g:vimwiki_rxH.'\{1,6}\)\zs[^'.g:vimwiki_rxH.'].*[^'.g:vimwiki_rxH.']\ze\1\s*$'
else
" asymmetric
for i in range(1,6)
let g:vimwiki_rxH{i}_Template = repeat(g:vimwiki_rxH, i).' __Header__'
let g:vimwiki_rxH{i} = '^\s*'.g:vimwiki_rxH.'\{'.i.'}[^'.g:vimwiki_rxH.'].*$'
endfor
let g:vimwiki_rxHeader = '^\s*\('.g:vimwiki_rxH.'\{1,6}\)\zs[^'.g:vimwiki_rxH.'].*\ze$'
endif
" Header levels, 1-6
for i in range(1,6)
execute 'syntax match VimwikiHeader'.i.' /'.g:vimwiki_rxH{i}.'/ contains=VimwikiTodo,VimwikiHeaderChar,VimwikiNoExistsLink,VimwikiCode,VimwikiLink,@Spell'
endfor
" }}}
" concealed chars " {{{
let cchar = ''
if exists("+conceallevel")
syntax conceal on
let cchar = ' cchar=~ '
endif
syntax spell toplevel
if g:vimwiki_debug > 1
echom 'WikiLink Prefix: '.g:vimwiki_rxWikiLinkPrefix1
echom 'WikiLink Suffix: '.g:vimwiki_rxWikiLinkSuffix1
echom 'WikiIncl Prefix: '.g:vimwiki_rxWikiInclPrefix1
echom 'WikiIncl Suffix: '.g:vimwiki_rxWikiInclSuffix1
endif
" VimwikiLinkChar is for syntax markers (and also URL when a description
" is present) and may be concealed
let options = ' contained transparent contains=NONE'
" conceal wikilinks
execute 'syn match VimwikiLinkChar /'.g:vimwiki_rxWikiLinkPrefix.'/'.options
execute 'syn match VimwikiLinkChar /'.g:vimwiki_rxWikiLinkSuffix.'/'.options
execute 'syn match VimwikiLinkChar /'.g:vimwiki_rxWikiLinkPrefix1.'/'.options
execute 'syn match VimwikiLinkChar /'.g:vimwiki_rxWikiLinkSuffix1.'/'.options
" conceal wikiincls
execute 'syn match VimwikiLinkChar /'.g:vimwiki_rxWikiInclPrefix.'/'.options
execute 'syn match VimwikiLinkChar /'.g:vimwiki_rxWikiInclSuffix.'/'.options
execute 'syn match VimwikiLinkChar /'.g:vimwiki_rxWikiInclPrefix1.'/'.options
execute 'syn match VimwikiLinkChar /'.g:vimwiki_rxWikiInclSuffix1.'/'.options
" A shortener for long URLs: LinkRest (a middle part of the URL) is concealed
execute 'syn match VimwikiLinkRest `\%(///\=[^/ \t]\+/\)\zs\S\{'
\.g:vimwiki_url_mingain.',}\ze\%([/#?]\w\|\S\{'
\.g:vimwiki_url_maxsave.'}\)`'.cchar.options
execute 'syn match VimwikiEqInChar contained /'.g:vimwiki_char_eqin.'/'
execute 'syn match VimwikiBoldChar contained /'.g:vimwiki_char_bold.'/'
execute 'syn match VimwikiItalicChar contained /'.g:vimwiki_char_italic.'/'
execute 'syn match VimwikiBoldItalicChar contained /'.g:vimwiki_char_bolditalic.'/'
execute 'syn match VimwikiItalicBoldChar contained /'.g:vimwiki_char_italicbold.'/'
execute 'syn match VimwikiCodeChar contained /'.g:vimwiki_char_code.'/'
execute 'syn match VimwikiDelTextChar contained /'.g:vimwiki_char_deltext.'/'
execute 'syn match VimwikiSuperScript contained /'.g:vimwiki_char_superscript.'/'
execute 'syn match VimwikiSubScript contained /'.g:vimwiki_char_subscript.'/'
if exists("+conceallevel")
syntax conceal off
endif
" }}}
" non concealed chars " {{{
execute 'syn match VimwikiHeaderChar contained /\%(^\s*'.g:vimwiki_rxH.'\+\)\|\%('.g:vimwiki_rxH.'\+\s*$\)/'
execute 'syn match VimwikiEqInCharT contained /'.g:vimwiki_char_eqin.'/'
execute 'syn match VimwikiBoldCharT contained /'.g:vimwiki_char_bold.'/'
execute 'syn match VimwikiItalicCharT contained /'.g:vimwiki_char_italic.'/'
execute 'syn match VimwikiBoldItalicCharT contained /'.g:vimwiki_char_bolditalic.'/'
execute 'syn match VimwikiItalicBoldCharT contained /'.g:vimwiki_char_italicbold.'/'
execute 'syn match VimwikiCodeCharT contained /'.g:vimwiki_char_code.'/'
execute 'syn match VimwikiDelTextCharT contained /'.g:vimwiki_char_deltext.'/'
execute 'syn match VimwikiSuperScriptT contained /'.g:vimwiki_char_superscript.'/'
execute 'syn match VimwikiSubScriptT contained /'.g:vimwiki_char_subscript.'/'
" Emoticons
"syntax match VimwikiEmoticons /\%((.)\|:[()|$@]\|:-[DOPS()\]|$@]\|;)\|:'(\)/
let g:vimwiki_rxTodo = '\C\%(TODO:\|DONE:\|STARTED:\|FIXME:\|FIXED:\|XXX:\)'
execute 'syntax match VimwikiTodo /'. g:vimwiki_rxTodo .'/'
" }}}
" main syntax groups {{{
" Tables
syntax match VimwikiTableRow /^\s*|.\+|\s*$/
\ transparent contains=VimwikiCellSeparator,
\ VimwikiLinkT,
\ VimwikiNoExistsLinkT,
\ VimwikiEmoticons,
\ VimwikiTodo,
\ VimwikiBoldT,
\ VimwikiItalicT,
\ VimwikiBoldItalicT,
\ VimwikiItalicBoldT,
\ VimwikiDelTextT,
\ VimwikiSuperScriptT,
\ VimwikiSubScriptT,
\ VimwikiCodeT,
\ VimwikiEqInT,
\ @Spell
syntax match VimwikiCellSeparator
\ /\%(|\)\|\%(-\@<=+\-\@=\)\|\%([|+]\@<=-\+\)/ contained
" List items
execute 'syntax match VimwikiList /'.g:vimwiki_rxListBullet.'/'
execute 'syntax match VimwikiList /'.g:vimwiki_rxListNumber.'/'
execute 'syntax match VimwikiList /'.g:vimwiki_rxListDefine.'/'
" List item checkbox
"syntax match VimwikiCheckBox /\[.\?\]/
let g:vimwiki_rxCheckBox = '\s*\[['.g:vimwiki_listsyms.']\?\]\s'
" Todo lists have a checkbox
execute 'syntax match VimwikiListTodo /'.g:vimwiki_rxListBullet.g:vimwiki_rxCheckBox.'/'
execute 'syntax match VimwikiListTodo /'.g:vimwiki_rxListNumber.g:vimwiki_rxCheckBox.'/'
if g:vimwiki_hl_cb_checked
execute 'syntax match VimwikiCheckBoxDone /'.
\ g:vimwiki_rxListBullet.'\s*\['.g:vimwiki_listsyms[4].'\]\s.*$/'.
\ ' contains=VimwikiNoExistsLink,VimwikiLink'
execute 'syntax match VimwikiCheckBoxDone /'.
\ g:vimwiki_rxListNumber.'\s*\['.g:vimwiki_listsyms[4].'\]\s.*$/'.
\ ' contains=VimwikiNoExistsLink,VimwikiLink'
endif
execute 'syntax match VimwikiEqIn /'.g:vimwiki_rxEqIn.'/ contains=VimwikiEqInChar'
execute 'syntax match VimwikiEqInT /'.g:vimwiki_rxEqIn.'/ contained contains=VimwikiEqInCharT'
execute 'syntax match VimwikiBold /'.g:vimwiki_rxBold.'/ contains=VimwikiBoldChar,@Spell'
execute 'syntax match VimwikiBoldT /'.g:vimwiki_rxBold.'/ contained contains=VimwikiBoldCharT,@Spell'
execute 'syntax match VimwikiItalic /'.g:vimwiki_rxItalic.'/ contains=VimwikiItalicChar,@Spell'
execute 'syntax match VimwikiItalicT /'.g:vimwiki_rxItalic.'/ contained contains=VimwikiItalicCharT,@Spell'
execute 'syntax match VimwikiBoldItalic /'.g:vimwiki_rxBoldItalic.'/ contains=VimwikiBoldItalicChar,VimwikiItalicBoldChar,@Spell'
execute 'syntax match VimwikiBoldItalicT /'.g:vimwiki_rxBoldItalic.'/ contained contains=VimwikiBoldItalicChatT,VimwikiItalicBoldCharT,@Spell'
execute 'syntax match VimwikiItalicBold /'.g:vimwiki_rxItalicBold.'/ contains=VimwikiBoldItalicChar,VimwikiItalicBoldChar,@Spell'
execute 'syntax match VimwikiItalicBoldT /'.g:vimwiki_rxItalicBold.'/ contained contains=VimwikiBoldItalicCharT,VimsikiItalicBoldCharT,@Spell'
execute 'syntax match VimwikiDelText /'.g:vimwiki_rxDelText.'/ contains=VimwikiDelTextChar,@Spell'
execute 'syntax match VimwikiDelTextT /'.g:vimwiki_rxDelText.'/ contained contains=VimwikiDelTextChar,@Spell'
execute 'syntax match VimwikiSuperScript /'.g:vimwiki_rxSuperScript.'/ contains=VimwikiSuperScriptChar,@Spell'
execute 'syntax match VimwikiSuperScriptT /'.g:vimwiki_rxSuperScript.'/ contained contains=VimwikiSuperScriptCharT,@Spell'
execute 'syntax match VimwikiSubScript /'.g:vimwiki_rxSubScript.'/ contains=VimwikiSubScriptChar,@Spell'
execute 'syntax match VimwikiSubScriptT /'.g:vimwiki_rxSubScript.'/ contained contains=VimwikiSubScriptCharT,@Spell'
execute 'syntax match VimwikiCode /'.g:vimwiki_rxCode.'/ contains=VimwikiCodeChar'
execute 'syntax match VimwikiCodeT /'.g:vimwiki_rxCode.'/ contained contains=VimwikiCodeCharT'
" <hr> horizontal rule
execute 'syntax match VimwikiHR /'.g:vimwiki_rxHR.'/'
execute 'syntax region VimwikiPre start=/^\s*'.g:vimwiki_rxPreStart.
\ '/ end=/^\s*'.g:vimwiki_rxPreEnd.'\s*$/ contains=@Spell'
execute 'syntax region VimwikiMath start=/^\s*'.g:vimwiki_rxMathStart.
\ '/ end=/^\s*'.g:vimwiki_rxMathEnd.'\s*$/ contains=@Spell'
" placeholders
syntax match VimwikiPlaceholder /^\s*%toc\%(\s.*\)\?$/ contains=VimwikiPlaceholderParam
syntax match VimwikiPlaceholder /^\s*%nohtml\s*$/
syntax match VimwikiPlaceholder /^\s*%title\%(\s.*\)\?$/ contains=VimwikiPlaceholderParam
syntax match VimwikiPlaceholder /^\s*%template\%(\s.*\)\?$/ contains=VimwikiPlaceholderParam
syntax match VimwikiPlaceholderParam /\s.*/ contained
" html tags
if g:vimwiki_valid_html_tags != ''
let html_tags = join(split(g:vimwiki_valid_html_tags, '\s*,\s*'), '\|')
exe 'syntax match VimwikiHTMLtag #\c</\?\%('.html_tags.'\)\%(\s\{-1}\S\{-}\)\{-}\s*/\?>#'
execute 'syntax match VimwikiBold #\c<b>.\{-}</b># contains=VimwikiHTMLTag'
execute 'syntax match VimwikiItalic #\c<i>.\{-}</i># contains=VimwikiHTMLTag'
execute 'syntax match VimwikiUnderline #\c<u>.\{-}</u># contains=VimwikiHTMLTag'
execute 'syntax match VimwikiComment /'.g:vimwiki_rxComment.'/ contains=@Spell'
endif
" }}}
" header groups highlighting "{{{
if g:vimwiki_hl_headers == 0
" Strangely in default colorscheme Title group is not set to bold for cterm...
if !exists("g:colors_name")
hi Title cterm=bold
endif
for i in range(1,6)
execute 'hi def link VimwikiHeader'.i.' Title'
endfor
else
" default colors when headers of different levels are highlighted differently
" not making it yet another option; needed by ColorScheme autocommand
let g:vimwiki_hcolor_guifg_light = ['#aa5858','#507030','#1030a0','#103040','#505050','#636363']
let g:vimwiki_hcolor_ctermfg_light = ['DarkRed','DarkGreen','DarkBlue','Black','Black','Black']
let g:vimwiki_hcolor_guifg_dark = ['#e08090','#80e090','#6090e0','#c0c0f0','#e0e0f0','#f0f0f0']
let g:vimwiki_hcolor_ctermfg_dark = ['Red','Green','Blue','White','White','White']
for i in range(1,6)
execute 'hi def VimwikiHeader'.i.' guibg=bg guifg='.g:vimwiki_hcolor_guifg_{&bg}[i-1].' gui=bold ctermfg='.g:vimwiki_hcolor_ctermfg_{&bg}[i-1].' term=bold cterm=bold'
endfor
endif
"}}}
" syntax group highlighting "{{{
hi def link VimwikiMarkers Normal
hi def link VimwikiEqIn Number
hi def link VimwikiEqInT VimwikiEqIn
hi def VimwikiBold term=bold cterm=bold gui=bold
hi def link VimwikiBoldT VimwikiBold
hi def VimwikiItalic term=italic cterm=italic gui=italic
hi def link VimwikiItalicT VimwikiItalic
hi def VimwikiBoldItalic term=bold cterm=bold gui=bold,italic
hi def link VimwikiItalicBold VimwikiBoldItalic
hi def link VimwikiBoldItalicT VimwikiBoldItalic
hi def link VimwikiItalicBoldT VimwikiBoldItalic
hi def VimwikiUnderline gui=underline
hi def link VimwikiCode PreProc
hi def link VimwikiCodeT VimwikiCode
hi def link VimwikiPre PreProc
hi def link VimwikiPreT VimwikiPre
hi def link VimwikiMath Number
hi def link VimwikiMathT VimwikiMath
hi def link VimwikiNoExistsLink SpellBad
hi def link VimwikiNoExistsLinkT VimwikiNoExistsLink
hi def link VimwikiLink Underlined
hi def link VimwikiLinkT VimwikiLink
hi def link VimwikiList Identifier
hi def link VimwikiListTodo VimwikiList
"hi def link VimwikiCheckBox VimwikiList
hi def link VimwikiCheckBoxDone Comment
hi def link VimwikiEmoticons Character
hi def link VimwikiHR Identifier
hi def link VimwikiDelText Constant
hi def link VimwikiDelTextT VimwikiDelText
hi def link VimwikiSuperScript Number
hi def link VimwikiSuperScriptT VimwikiSuperScript
hi def link VimwikiSubScript Number
hi def link VimwikiSubScriptT VimwikiSubScript
hi def link VimwikiTodo Todo
hi def link VimwikiComment Comment
hi def link VimwikiPlaceholder SpecialKey
hi def link VimwikiPlaceholderParam String
hi def link VimwikiHTMLtag SpecialKey
hi def link VimwikiEqInChar VimwikiMarkers
hi def link VimwikiCellSeparator VimwikiMarkers
hi def link VimwikiBoldChar VimwikiMarkers
hi def link VimwikiItalicChar VimwikiMarkers
hi def link VimwikiBoldItalicChar VimwikiMarkers
hi def link VimwikiItalicBoldChar VimwikiMarkers
hi def link VimwikiDelTextChar VimwikiMarkers
hi def link VimwikiSuperScriptChar VimwikiMarkers
hi def link VimwikiSubScriptChar VimwikiMarkers
hi def link VimwikiCodeChar VimwikiMarkers
hi def link VimwikiHeaderChar VimwikiMarkers
hi def link VimwikiEqInCharT VimwikiMarkers
hi def link VimwikiBoldCharT VimwikiMarkers
hi def link VimwikiItalicCharT VimwikiMarkers
hi def link VimwikiBoldItalicCharT VimwikiMarkers
hi def link VimwikiItalicBoldCharT VimwikiMarkers
hi def link VimwikiDelTextCharT VimwikiMarkers
hi def link VimwikiSuperScriptCharT VimwikiMarkers
hi def link VimwikiSubScriptCharT VimwikiMarkers
hi def link VimwikiCodeCharT VimwikiMarkers
hi def link VimwikiHeaderCharT VimwikiMarkers
hi def link VimwikiLinkCharT VimwikiLinkT
hi def link VimwikiNoExistsLinkCharT VimwikiNoExistsLinkT
"}}}
" -------------------------------------------------------------------------
" Load syntax-specific functionality
execute 'runtime! syntax/vimwiki_'.VimwikiGet('syntax').'_custom.vim'
" -------------------------------------------------------------------------
let b:current_syntax="vimwiki"
" EMBEDDED syntax setup "{{{
let nested = VimwikiGet('nested_syntaxes')
if !empty(nested)
for [hl_syntax, vim_syntax] in items(nested)
call vimwiki#base#nested_syntax(vim_syntax,
\ '^\s*'.g:vimwiki_rxPreStart.'\%(.*[[:blank:][:punct:]]\)\?'.
\ hl_syntax.'\%([[:blank:][:punct:]].*\)\?',
\ '^\s*'.g:vimwiki_rxPreEnd, 'VimwikiPre')
endfor
endif
" LaTeX
call vimwiki#base#nested_syntax('tex',
\ '^\s*'.g:vimwiki_rxMathStart.'\%(.*[[:blank:][:punct:]]\)\?'.
\ '\%([[:blank:][:punct:]].*\)\?',
\ '^\s*'.g:vimwiki_rxMathEnd, 'VimwikiMath')
"}}}
let timeend = vimwiki#u#time(starttime) "XXX
call VimwikiLog_extend('timing',['syntax:scans',timescans],['syntax:regexloaded',time0],['syntax:beforeHLexisting',time01],['syntax:afterHLexisting',time02],['syntax:end',timeend])

View File

@@ -1,89 +0,0 @@
" vim:tabstop=2:shiftwidth=2:expandtab:foldmethod=marker:textwidth=79
" Vimwiki syntax file
" Default syntax
" Author: Maxim Kim <habamax@gmail.com>
" Home: http://code.google.com/p/vimwiki/
" placeholder for math environments
let b:vimwiki_mathEnv = ""
" text: $ equation_inline $
let g:vimwiki_rxEqIn = '\$[^$`]\+\$'
let g:vimwiki_char_eqin = '\$'
" text: *strong*
" let g:vimwiki_rxBold = '\*[^*]\+\*'
let g:vimwiki_rxBold = '\%(^\|\s\|[[:punct:]]\)\@<='.
\'\*'.
\'\%([^*`[:space:]][^*`]*[^*`[:space:]]\|[^*`[:space:]]\)'.
\'\*'.
\'\%([[:punct:]]\|\s\|$\)\@='
let g:vimwiki_char_bold = '*'
" text: _emphasis_
" let g:vimwiki_rxItalic = '_[^_]\+_'
let g:vimwiki_rxItalic = '\%(^\|\s\|[[:punct:]]\)\@<='.
\'_'.
\'\%([^_`[:space:]][^_`]*[^_`[:space:]]\|[^_`[:space:]]\)'.
\'_'.
\'\%([[:punct:]]\|\s\|$\)\@='
let g:vimwiki_char_italic = '_'
" text: *_bold italic_* or _*italic bold*_
let g:vimwiki_rxBoldItalic = '\%(^\|\s\|[[:punct:]]\)\@<='.
\'\*_'.
\'\%([^*_`[:space:]][^*_`]*[^*_`[:space:]]\|[^*_`[:space:]]\)'.
\'_\*'.
\'\%([[:punct:]]\|\s\|$\)\@='
let g:vimwiki_char_bolditalic = '\*_'
let g:vimwiki_rxItalicBold = '\%(^\|\s\|[[:punct:]]\)\@<='.
\'_\*'.
\'\%([^*_`[:space:]][^*_`]*[^*_`[:space:]]\|[^*_`[:space:]]\)'.
\'\*_'.
\'\%([[:punct:]]\|\s\|$\)\@='
let g:vimwiki_char_italicbold = '_\*'
" text: `code`
let g:vimwiki_rxCode = '`[^`]\+`'
let g:vimwiki_char_code = '`'
" text: ~~deleted text~~
let g:vimwiki_rxDelText = '\~\~[^~`]\+\~\~'
let g:vimwiki_char_deltext = '\~\~'
" text: ^superscript^
let g:vimwiki_rxSuperScript = '\^[^^`]\+\^'
let g:vimwiki_char_superscript = '^'
" text: ,,subscript,,
let g:vimwiki_rxSubScript = ',,[^,`]\+,,'
let g:vimwiki_char_subscript = ',,'
" generic headers
let g:vimwiki_rxH = '='
let g:vimwiki_symH = 1
" <hr>, horizontal rule
let g:vimwiki_rxHR = '^-----*$'
" Tables. Each line starts and ends with '|'; each cell is separated by '|'
let g:vimwiki_rxTableSep = '|'
" List items start with optional whitespace(s) then '* ' or '# '
let g:vimwiki_rxListBullet = '^\s*[*-]\s'
let g:vimwiki_rxListNumber = '^\s*#\s'
let g:vimwiki_rxListDefine = '::\(\s\|$\)'
" Preformatted text
let g:vimwiki_rxPreStart = '{{{'
let g:vimwiki_rxPreEnd = '}}}'
" Math block
let g:vimwiki_rxMathStart = '{{\$'
let g:vimwiki_rxMathEnd = '}}\$'
let g:vimwiki_rxComment = '^\s*%%.*$'

View File

@@ -1,89 +0,0 @@
" vim:tabstop=2:shiftwidth=2:expandtab:foldmethod=marker:textwidth=79
" Vimwiki syntax file
" Default syntax
" Author: Maxim Kim <habamax@gmail.com>
" Home: http://code.google.com/p/vimwiki/
" placeholder for math environments
let b:vimwiki_mathEnv = ""
" text: $ equation_inline $
let g:vimwiki_rxEqIn = '\$[^$`]\+\$'
let g:vimwiki_char_eqin = '\$'
" text: *strong*
" let g:vimwiki_rxBold = '\*[^*]\+\*'
let g:vimwiki_rxBold = '\%(^\|\s\|[[:punct:]]\)\@<='.
\'\*'.
\'\%([^*`[:space:]][^*`]*[^*`[:space:]]\|[^*`[:space:]]\)'.
\'\*'.
\'\%([[:punct:]]\|\s\|$\)\@='
let g:vimwiki_char_bold = '*'
" text: _emphasis_
" let g:vimwiki_rxItalic = '_[^_]\+_'
let g:vimwiki_rxItalic = '\%(^\|\s\|[[:punct:]]\)\@<='.
\'_'.
\'\%([^_`[:space:]][^_`]*[^_`[:space:]]\|[^_`[:space:]]\)'.
\'_'.
\'\%([[:punct:]]\|\s\|$\)\@='
let g:vimwiki_char_italic = '_'
" text: *_bold italic_* or _*italic bold*_
let g:vimwiki_rxBoldItalic = '\%(^\|\s\|[[:punct:]]\)\@<='.
\'\*_'.
\'\%([^*_`[:space:]][^*_`]*[^*_`[:space:]]\|[^*_`[:space:]]\)'.
\'_\*'.
\'\%([[:punct:]]\|\s\|$\)\@='
let g:vimwiki_char_bolditalic = '\*_'
let g:vimwiki_rxItalicBold = '\%(^\|\s\|[[:punct:]]\)\@<='.
\'_\*'.
\'\%([^*_`[:space:]][^*_`]*[^*_`[:space:]]\|[^*_`[:space:]]\)'.
\'\*_'.
\'\%([[:punct:]]\|\s\|$\)\@='
let g:vimwiki_char_italicbold = '_\*'
" text: `code`
let g:vimwiki_rxCode = '`[^`]\+`'
let g:vimwiki_char_code = '`'
" text: ~~deleted text~~
let g:vimwiki_rxDelText = '\~\~[^~`]\+\~\~'
let g:vimwiki_char_deltext = '\~\~'
" text: ^superscript^
let g:vimwiki_rxSuperScript = '\^[^^`]\+\^'
let g:vimwiki_char_superscript = '^'
" text: ,,subscript,,
let g:vimwiki_rxSubScript = ',,[^,`]\+,,'
let g:vimwiki_char_subscript = ',,'
" generic headers
let g:vimwiki_rxH = '#'
let g:vimwiki_symH = 0
" <hr>, horizontal rule
let g:vimwiki_rxHR = '^-----*$'
" Tables. Each line starts and ends with '|'; each cell is separated by '|'
let g:vimwiki_rxTableSep = '|'
" List items start with optional whitespace(s) then '* ' or '1. ', '2. ', etc.
let g:vimwiki_rxListBullet = '^\s*[*+-]\s'
let g:vimwiki_rxListNumber = '^\s*[0-9]\+\.\s'
let g:vimwiki_rxListDefine = '::\%(\s\|$\)'
" Preformatted text
let g:vimwiki_rxPreStart = '```'
let g:vimwiki_rxPreEnd = '```'
" Math block
let g:vimwiki_rxMathStart = '\$\$'
let g:vimwiki_rxMathEnd = '\$\$'
let g:vimwiki_rxComment = '^\s*%%.*$'

View File

@@ -1,392 +0,0 @@
" vim:tabstop=2:shiftwidth=2:expandtab:foldmethod=marker:textwidth=79
" Vimwiki syntax file
" Author: Stuart Andrews <stu.andrews@gmail.com>
" Home: http://code.google.com/p/vimwiki/
" LINKS: assume this is common to all syntaxes "{{{
" }}}
" -------------------------------------------------------------------------
" Load concrete Wiki syntax: sets regexes and templates for headers and links
" -------------------------------------------------------------------------
" LINKS: setup of larger regexes {{{
" LINKS: setup wikilink0 regexps {{{
" 0. [[URL]], or [[URL|DESCRIPTION]]
" 0a) match [[URL|DESCRIPTION]]
let g:vimwiki_rxWikiLink0 = g:vimwiki_rxWikiLink
" 0b) match URL within [[URL|DESCRIPTION]]
let g:vimwiki_rxWikiLink0MatchUrl = g:vimwiki_rxWikiLinkMatchUrl
" 0c) match DESCRIPTION within [[URL|DESCRIPTION]]
let g:vimwiki_rxWikiLink0MatchDescr = g:vimwiki_rxWikiLinkMatchDescr
" }}}
" LINKS: setup wikilink1 regexps {{{
" 1. [URL][], or [DESCRIPTION][URL]
let g:vimwiki_rxWikiLink1Prefix = '['
let g:vimwiki_rxWikiLink1Suffix = ']'
let g:vimwiki_rxWikiLink1Separator = ']['
" [URL][]
let g:vimwiki_WikiLink1Template1 = g:vimwiki_rxWikiLink1Prefix . '__LinkUrl__'.
\ g:vimwiki_rxWikiLink1Separator. g:vimwiki_rxWikiLink1Suffix
" [DESCRIPTION][URL]
let g:vimwiki_WikiLink1Template2 = g:vimwiki_rxWikiLink1Prefix . '__LinkDescription__'.
\ g:vimwiki_rxWikiLink1Separator. '__LinkUrl__'.
\ g:vimwiki_rxWikiLink1Suffix
"
let magic_chars = '.*[]\^$'
let valid_chars = '[^\\\[\]]'
let g:vimwiki_rxWikiLink1Prefix = escape(g:vimwiki_rxWikiLink1Prefix, magic_chars)
let g:vimwiki_rxWikiLink1Suffix = escape(g:vimwiki_rxWikiLink1Suffix, magic_chars)
let g:vimwiki_rxWikiLink1Separator = escape(g:vimwiki_rxWikiLink1Separator, magic_chars)
let g:vimwiki_rxWikiLink1Url = valid_chars.'\{-}'
let g:vimwiki_rxWikiLink1Descr = valid_chars.'\{-}'
let g:vimwiki_rxWikiLink1InvalidPrefix = '[\]\[]\@<!'
let g:vimwiki_rxWikiLink1InvalidSuffix = '[\]\[]\@!'
let g:vimwiki_rxWikiLink1Prefix = g:vimwiki_rxWikiLink1InvalidPrefix.
\ g:vimwiki_rxWikiLink1Prefix
let g:vimwiki_rxWikiLink1Suffix = g:vimwiki_rxWikiLink1Suffix.
\ g:vimwiki_rxWikiLink1InvalidSuffix
"
" 1. [URL][], [DESCRIPTION][URL]
" 1a) match [URL][], [DESCRIPTION][URL]
let g:vimwiki_rxWikiLink1 = g:vimwiki_rxWikiLink1Prefix.
\ g:vimwiki_rxWikiLink1Url. g:vimwiki_rxWikiLink1Separator.
\ g:vimwiki_rxWikiLink1Suffix.
\ '\|'. g:vimwiki_rxWikiLink1Prefix.
\ g:vimwiki_rxWikiLink1Descr.g:vimwiki_rxWikiLink1Separator.
\ g:vimwiki_rxWikiLink1Url.g:vimwiki_rxWikiLink1Suffix
" 1b) match URL within [URL][], [DESCRIPTION][URL]
let g:vimwiki_rxWikiLink1MatchUrl = g:vimwiki_rxWikiLink1Prefix.
\ '\zs'. g:vimwiki_rxWikiLink1Url. '\ze'. g:vimwiki_rxWikiLink1Separator.
\ g:vimwiki_rxWikiLink1Suffix.
\ '\|'. g:vimwiki_rxWikiLink1Prefix.
\ g:vimwiki_rxWikiLink1Descr. g:vimwiki_rxWikiLink1Separator.
\ '\zs'. g:vimwiki_rxWikiLink1Url. '\ze'. g:vimwiki_rxWikiLink1Suffix
" 1c) match DESCRIPTION within [DESCRIPTION][URL]
let g:vimwiki_rxWikiLink1MatchDescr = g:vimwiki_rxWikiLink1Prefix.
\ '\zs'. g:vimwiki_rxWikiLink1Descr.'\ze'. g:vimwiki_rxWikiLink1Separator.
\ g:vimwiki_rxWikiLink1Url.g:vimwiki_rxWikiLink1Suffix
" }}}
" LINKS: Syntax helper {{{
let g:vimwiki_rxWikiLink1Prefix1 = g:vimwiki_rxWikiLink1Prefix
let g:vimwiki_rxWikiLink1Suffix1 = g:vimwiki_rxWikiLink1Separator.
\ g:vimwiki_rxWikiLink1Url.g:vimwiki_rxWikiLink1Suffix
" }}}
" *. ANY wikilink {{{
" *a) match ANY wikilink
let g:vimwiki_rxWikiLink = ''.
\ g:vimwiki_rxWikiLink0.'\|'.
\ g:vimwiki_rxWikiLink1
" *b) match URL within ANY wikilink
let g:vimwiki_rxWikiLinkMatchUrl = ''.
\ g:vimwiki_rxWikiLink0MatchUrl.'\|'.
\ g:vimwiki_rxWikiLink1MatchUrl
" *c) match DESCRIPTION within ANY wikilink
let g:vimwiki_rxWikiLinkMatchDescr = ''.
\ g:vimwiki_rxWikiLink0MatchDescr.'\|'.
\ g:vimwiki_rxWikiLink1MatchDescr
" }}}
" LINKS: setup of wikiincl regexps {{{
" }}}
" LINKS: Syntax helper {{{
" }}}
" LINKS: Setup weblink0 regexps {{{
" 0. URL : free-standing links: keep URL UR(L) strip trailing punct: URL; URL) UR(L))
let g:vimwiki_rxWeblink0 = g:vimwiki_rxWeblink
" 0a) match URL within URL
let g:vimwiki_rxWeblinkMatchUrl0 = g:vimwiki_rxWeblinkMatchUrl
" 0b) match DESCRIPTION within URL
let g:vimwiki_rxWeblinkMatchDescr0 = g:vimwiki_rxWeblinkMatchDescr
" }}}
" LINKS: Setup weblink1 regexps {{{
let g:vimwiki_rxWeblink1Prefix = '['
let g:vimwiki_rxWeblink1Suffix = ')'
let g:vimwiki_rxWeblink1Separator = ']('
" [DESCRIPTION](URL)
let g:vimwiki_Weblink1Template = g:vimwiki_rxWeblink1Prefix . '__LinkDescription__'.
\ g:vimwiki_rxWeblink1Separator. '__LinkUrl__'.
\ g:vimwiki_rxWeblink1Suffix
let magic_chars = '.*[]\^$'
let valid_chars = '[^\\]'
let g:vimwiki_rxWeblink1Prefix = escape(g:vimwiki_rxWeblink1Prefix, magic_chars)
let g:vimwiki_rxWeblink1Suffix = escape(g:vimwiki_rxWeblink1Suffix, magic_chars)
let g:vimwiki_rxWeblink1Separator = escape(g:vimwiki_rxWeblink1Separator, magic_chars)
let g:vimwiki_rxWeblink1Url = valid_chars.'\{-}'
let g:vimwiki_rxWeblink1Descr = valid_chars.'\{-}'
"
" " 2012-02-04 TODO not starting with [[ or ][ ? ... prefix = '[\[\]]\@<!\['
" 1. [DESCRIPTION](URL)
" 1a) match [DESCRIPTION](URL)
let g:vimwiki_rxWeblink1 = g:vimwiki_rxWeblink1Prefix.
\ g:vimwiki_rxWeblink1Url.g:vimwiki_rxWeblink1Separator.
\ g:vimwiki_rxWeblink1Descr.g:vimwiki_rxWeblink1Suffix
" 1b) match URL within [DESCRIPTION](URL)
let g:vimwiki_rxWeblink1MatchUrl = g:vimwiki_rxWeblink1Prefix.
\ g:vimwiki_rxWeblink1Descr. g:vimwiki_rxWeblink1Separator.
\ '\zs'.g:vimwiki_rxWeblink1Url.'\ze'. g:vimwiki_rxWeblink1Suffix
" 1c) match DESCRIPTION within [DESCRIPTION](URL)
let g:vimwiki_rxWeblink1MatchDescr = g:vimwiki_rxWeblink1Prefix.
\ '\zs'.g:vimwiki_rxWeblink1Descr.'\ze'. g:vimwiki_rxWeblink1Separator.
\ g:vimwiki_rxWeblink1Url. g:vimwiki_rxWeblink1Suffix
" }}}
" Syntax helper {{{
" TODO: image links too !!
" let g:vimwiki_rxWeblink1Prefix1 = '!\?'. g:vimwiki_rxWeblink1Prefix
let g:vimwiki_rxWeblink1Prefix1 = g:vimwiki_rxWeblink1Prefix
let g:vimwiki_rxWeblink1Suffix1 = g:vimwiki_rxWeblink1Separator.
\ g:vimwiki_rxWeblink1Url.g:vimwiki_rxWeblink1Suffix
" }}}
" *. ANY weblink {{{
" *a) match ANY weblink
let g:vimwiki_rxWeblink = ''.
\ g:vimwiki_rxWeblink1.'\|'.
\ g:vimwiki_rxWeblink0
" *b) match URL within ANY weblink
let g:vimwiki_rxWeblinkMatchUrl = ''.
\ g:vimwiki_rxWeblink1MatchUrl.'\|'.
\ g:vimwiki_rxWeblinkMatchUrl0
" *c) match DESCRIPTION within ANY weblink
let g:vimwiki_rxWeblinkMatchDescr = ''.
\ g:vimwiki_rxWeblink1MatchDescr.'\|'.
\ g:vimwiki_rxWeblinkMatchDescr0
" }}}
" LINKS: Setup anylink regexps {{{
let g:vimwiki_rxAnyLink = g:vimwiki_rxWikiLink.'\|'.
\ g:vimwiki_rxWikiIncl.'\|'.g:vimwiki_rxWeblink
" }}}
" LINKS: setup wikilink1 reference link definitions {{{
let g:vimwiki_rxMkdRef = '\['.g:vimwiki_rxWikiLinkDescr.']:\%(\s\+\|\n\)'.
\ g:vimwiki_rxWeblink0
let g:vimwiki_rxMkdRefMatchDescr = '\[\zs'.g:vimwiki_rxWikiLinkDescr.'\ze]:\%(\s\+\|\n\)'.
\ g:vimwiki_rxWeblink0
let g:vimwiki_rxMkdRefMatchUrl = '\['.g:vimwiki_rxWikiLinkDescr.']:\%(\s\+\|\n\)\zs'.
\ g:vimwiki_rxWeblink0.'\ze'
" }}}
" }}} end of Links
" LINKS: highlighting is complicated due to "nonexistent" links feature {{{
function! s:add_target_syntax_ON(target, type) " {{{
if g:vimwiki_debug > 1
echom '[vimwiki_debug] syntax target > '.a:target
endif
let prefix0 = 'syntax match '.a:type.' `'
let suffix0 = '` display contains=@NoSpell,VimwikiLinkRest,'.a:type.'Char'
let prefix1 = 'syntax match '.a:type.'T `'
let suffix1 = '` display contained'
execute prefix0. a:target. suffix0
execute prefix1. a:target. suffix1
endfunction "}}}
function! s:add_target_syntax_OFF(target, type) " {{{
if g:vimwiki_debug > 1
echom '[vimwiki_debug] syntax target > '.a:target
endif
let prefix0 = 'syntax match VimwikiNoExistsLink `'
let suffix0 = '` display contains=@NoSpell,VimwikiLinkRest,'.a:type.'Char'
let prefix1 = 'syntax match VimwikiNoExistsLinkT `'
let suffix1 = '` display contained'
execute prefix0. a:target. suffix0
execute prefix1. a:target. suffix1
endfunction "}}}
function! s:wrap_wikilink1_rx(target) "{{{
return g:vimwiki_rxWikiLink1InvalidPrefix.a:target.
\ g:vimwiki_rxWikiLink1InvalidSuffix
endfunction "}}}
function! s:existing_mkd_refs() "{{{
call vimwiki#markdown_base#reset_mkd_refs()
return "\n".join(keys(vimwiki#markdown_base#get_reflinks()), "\n")."\n"
endfunction "}}}
function! s:highlight_existing_links() "{{{
" Wikilink1
" Conditional highlighting that depends on the existence of a wiki file or
" directory is only available for *schemeless* wiki links
" Links are set up upon BufEnter (see plugin/...)
let safe_links = vimwiki#base#file_pattern(b:existing_wikifiles)
" Wikilink1 Dirs set up upon BufEnter (see plugin/...)
let safe_dirs = vimwiki#base#file_pattern(b:existing_wikidirs)
" Ref links are cached
let safe_reflinks = vimwiki#base#file_pattern(s:existing_mkd_refs())
" match [URL][]
let target = vimwiki#base#apply_template(g:vimwiki_WikiLink1Template1,
\ safe_links, g:vimwiki_rxWikiLink1Descr, '')
call s:add_target_syntax_ON(s:wrap_wikilink1_rx(target), 'VimwikiWikiLink1')
" match [DESCRIPTION][URL]
let target = vimwiki#base#apply_template(g:vimwiki_WikiLink1Template2,
\ safe_links, g:vimwiki_rxWikiLink1Descr, '')
call s:add_target_syntax_ON(s:wrap_wikilink1_rx(target), 'VimwikiWikiLink1')
" match [DIRURL][]
let target = vimwiki#base#apply_template(g:vimwiki_WikiLink1Template1,
\ safe_dirs, g:vimwiki_rxWikiLink1Descr, '')
call s:add_target_syntax_ON(s:wrap_wikilink1_rx(target), 'VimwikiWikiLink1')
" match [DESCRIPTION][DIRURL]
let target = vimwiki#base#apply_template(g:vimwiki_WikiLink1Template2,
\ safe_dirs, g:vimwiki_rxWikiLink1Descr, '')
call s:add_target_syntax_ON(s:wrap_wikilink1_rx(target), 'VimwikiWikiLink1')
" match [MKDREF][]
let target = vimwiki#base#apply_template(g:vimwiki_WikiLink1Template1,
\ safe_reflinks, g:vimwiki_rxWikiLink1Descr, '')
call s:add_target_syntax_ON(s:wrap_wikilink1_rx(target), 'VimwikiWikiLink1')
" match [DESCRIPTION][MKDREF]
let target = vimwiki#base#apply_template(g:vimwiki_WikiLink1Template2,
\ safe_reflinks, g:vimwiki_rxWikiLink1Descr, '')
call s:add_target_syntax_ON(s:wrap_wikilink1_rx(target), 'VimwikiWikiLink1')
endfunction "}}}
" use max highlighting - could be quite slow if there are too many wikifiles
if VimwikiGet('maxhi')
" WikiLink
call s:add_target_syntax_OFF(g:vimwiki_rxWikiLink1, 'VimwikiWikiLink1')
" Subsequently, links verified on vimwiki's path are highlighted as existing
let time01 = vimwiki#u#time(starttime) "XXX
call s:highlight_existing_links()
let time02 = vimwiki#u#time(starttime) "XXX
else
let time01 = vimwiki#u#time(starttime) "XXX
" Wikilink
call s:add_target_syntax_ON(g:vimwiki_rxWikiLink1, 'VimwikiWikiLink1')
let time02 = vimwiki#u#time(starttime) "XXX
endif
" Weblink
call s:add_target_syntax_ON(g:vimwiki_rxWeblink1, 'VimwikiWeblink1')
" WikiLink
" All remaining schemes are highlighted automatically
let rxSchemes = '\%('.
\ join(split(g:vimwiki_schemes, '\s*,\s*'), '\|').'\|'.
\ join(split(g:vimwiki_web_schemes1, '\s*,\s*'), '\|').
\ '\):'
" a) match [nonwiki-scheme-URL]
let target = vimwiki#base#apply_template(g:vimwiki_WikiLink1Template1,
\ rxSchemes.g:vimwiki_rxWikiLink1Url, g:vimwiki_rxWikiLink1Descr, '')
call s:add_target_syntax_ON(s:wrap_wikilink1_rx(target), 'VimwikiWikiLink1')
" b) match [DESCRIPTION][nonwiki-scheme-URL]
let target = vimwiki#base#apply_template(g:vimwiki_WikiLink1Template2,
\ rxSchemes.g:vimwiki_rxWikiLink1Url, g:vimwiki_rxWikiLink1Descr, '')
call s:add_target_syntax_ON(s:wrap_wikilink1_rx(target), 'VimwikiWikiLink1')
" }}}
" generic headers "{{{
" Header levels, 1-6
for i in range(1,6)
execute 'syntax match VimwikiHeader'.i.' /'.g:vimwiki_rxH{i}.'/ contains=VimwikiTodo,VimwikiHeaderChar,VimwikiNoExistsLink,VimwikiCode,VimwikiLink,VimwikiWeblink1,VimwikiWikiLink1,@Spell'
endfor
" }}}
" concealed chars " {{{
if exists("+conceallevel")
syntax conceal on
endif
syntax spell toplevel
if g:vimwiki_debug > 1
echom 'WikiLink1 Prefix: '.g:vimwiki_rxWikiLink1Prefix1
echom 'WikiLink1 Suffix: '.g:vimwiki_rxWikiLink1Suffix1
echom 'Weblink1 Prefix: '.g:vimwiki_rxWeblink1Prefix1
echom 'Weblink1 Suffix: '.g:vimwiki_rxWeblink1Suffix1
endif
" VimwikiWikiLink1Char is for syntax markers (and also URL when a description
" is present) and may be concealed
let options = ' contained transparent contains=NONE'
" conceal wikilink1
execute 'syn match VimwikiWikiLink1Char /'.g:vimwiki_rxWikiLink1Prefix.'/'.options
execute 'syn match VimwikiWikiLink1Char /'.g:vimwiki_rxWikiLink1Suffix.'/'.options
execute 'syn match VimwikiWikiLink1Char /'.g:vimwiki_rxWikiLink1Prefix1.'/'.options
execute 'syn match VimwikiWikiLink1Char /'.g:vimwiki_rxWikiLink1Suffix1.'/'.options
" conceal weblink1
execute 'syn match VimwikiWeblink1Char "'.g:vimwiki_rxWeblink1Prefix1.'"'.options
execute 'syn match VimwikiWeblink1Char "'.g:vimwiki_rxWeblink1Suffix1.'"'.options
if exists("+conceallevel")
syntax conceal off
endif
" }}}
" non concealed chars " {{{
" }}}
" main syntax groups {{{
" Tables
syntax match VimwikiTableRow /^\s*|.\+|\s*$/
\ transparent contains=VimwikiCellSeparator,
\ VimwikiLinkT,
\ VimwikiWeblink1T,
\ VimwikiWikiLink1T,
\ VimwikiNoExistsLinkT,
\ VimwikiEmoticons,
\ VimwikiTodo,
\ VimwikiBoldT,
\ VimwikiItalicT,
\ VimwikiBoldItalicT,
\ VimwikiItalicBoldT,
\ VimwikiDelTextT,
\ VimwikiSuperScriptT,
\ VimwikiSubScriptT,
\ VimwikiCodeT,
\ VimwikiEqInT,
\ @Spell
" }}}
" header groups highlighting "{{{
"}}}
" syntax group highlighting "{{{
hi def link VimwikiWeblink1 VimwikiLink
hi def link VimwikiWeblink1T VimwikiLink
hi def link VimwikiWikiLink1 VimwikiLink
hi def link VimwikiWikiLink1T VimwikiLink
"}}}
" EMBEDDED syntax setup "{{{
"}}}
"

View File

@@ -1,71 +0,0 @@
" vim:tabstop=2:shiftwidth=2:expandtab:foldmethod=marker:textwidth=79
" Vimwiki syntax file
" MediaWiki syntax
" Author: Maxim Kim <habamax@gmail.com>
" Home: http://code.google.com/p/vimwiki/
" placeholder for math environments
let b:vimwiki_mathEnv = ""
" text: $ equation_inline $
let g:vimwiki_rxEqIn = '\$[^$`]\+\$'
let g:vimwiki_char_eqin = '\$'
" text: '''strong'''
let g:vimwiki_rxBold = "'''[^']\\+'''"
let g:vimwiki_char_bold = "'''"
" text: ''emphasis''
let g:vimwiki_rxItalic = "''[^']\\+''"
let g:vimwiki_char_italic = "''"
" text: '''''strong italic'''''
let g:vimwiki_rxBoldItalic = "'''''[^']\\+'''''"
let g:vimwiki_rxItalicBold = g:vimwiki_rxBoldItalic
let g:vimwiki_char_bolditalic = "'''''"
let g:vimwiki_char_italicbold = g:vimwiki_char_bolditalic
" text: `code`
let g:vimwiki_rxCode = '`[^`]\+`'
let g:vimwiki_char_code = '`'
" text: ~~deleted text~~
let g:vimwiki_rxDelText = '\~\~[^~]\+\~\~'
let g:vimwiki_char_deltext = '\~\~'
" text: ^superscript^
let g:vimwiki_rxSuperScript = '\^[^^]\+\^'
let g:vimwiki_char_superscript = '^'
" text: ,,subscript,,
let g:vimwiki_rxSubScript = ',,[^,]\+,,'
let g:vimwiki_char_subscript = ',,'
" generic headers
let g:vimwiki_rxH = '='
let g:vimwiki_symH = 1
" <hr>, horizontal rule
let g:vimwiki_rxHR = '^-----*$'
" Tables. Each line starts and ends with '|'; each cell is separated by '|'
let g:vimwiki_rxTableSep = '|'
" Bulleted list items start with whitespace(s), then '*'
" highlight only bullets and digits.
let g:vimwiki_rxListBullet = '^\s*\*\+\s\%([^*]*$\)\@='
let g:vimwiki_rxListNumber = '^\s*#\+\s'
let g:vimwiki_rxListDefine = '^\%(;\|:\)\s'
" Preformatted text
let g:vimwiki_rxPreStart = '<pre>'
let g:vimwiki_rxPreEnd = '<\/pre>'
" Math block
let g:vimwiki_rxMathStart = '{{\$'
let g:vimwiki_rxMathEnd = '}}\$'
let g:vimwiki_rxComment = '^\s*%%.*$'

View File

@@ -0,0 +1,9 @@
" Some common settings for all reSt files
setlocal textwidth=80
setlocal makeprg=md2html.py\ \"%\"\ \"%:p:r.html\"
setlocal spell
setlocal smartindent
setlocal autoindent
setlocal formatoptions=tcq "set VIms default
autocmd BufWritePost *.md :silent make

View File

@@ -24,8 +24,6 @@ let g:pyflakes_use_quickfix = 0
autocmd BufWinLeave *.py mkview autocmd BufWinLeave *.py mkview
autocmd BufWinEnter *.py silent loadview autocmd BufWinEnter *.py silent loadview
compiler pylint
finish "end here. all below is just for the record. finish "end here. all below is just for the record.
" Pylint function, which can be optionally mapped to some keys. Currently " Pylint function, which can be optionally mapped to some keys. Currently

View File

@@ -78,6 +78,7 @@ if !exists("b:did_pylint_init")
python << EOF python << EOF
import sys import sys
import re
from StringIO import StringIO from StringIO import StringIO
class VImPylint(object): class VImPylint(object):

View File

@@ -1,348 +0,0 @@
" Vim syntax file
" Language: Assembler, KickAssembler
" Maintainer: Roman 'gryf' Dobosz <gryf_esm@o2.pl>
" Last Change: 2012-07-22
" Version: 1.2
"
" Changelog:
" 1.2 Updated to KickAssembler 3.25 changes
"
" 1.1 Since in assembly languages 'everything is a label' there pretty hard
" to distinguish labels from variables and structures, so I decided to
" remove highlighting labels at all. Instead numbers are highlighted, so that
" labels and defined variables are easily spotted in the code.
"
" 1.0 Initial release
"
" To install this file place it in ~/.vim/syntax (*nix/Mac) or in
" $VIMRUNTIME/syntax on Windows and issue command:
"
" :set filetype=kickass
"
" You can also add to your vimrc file autocommand:
"
" autocmd BufRead *.asm set filetype=kickass
"
" From now on, all files with extension 'asm' will have brand new kickass
" syntax.
"
" Enjoy.
syn clear
" Macro names.
syn case ignore
syn match kickAssMacroCall ":[a-z_][a-z0-9_]*"
syn case match
" 6502 mnemonics
syn keyword kickAssMnemonic brk clc cld cli clv dex dey inx iny nop pha php
syn keyword kickAssMnemonic pla plp sec sed sei tax tay tsx txa txs tya
syn keyword kickAssJump rti rts
syn match kickAssMnemonic "\<adc\(\.\(imm\?\|zp\?x\?\|izp\?[xy]\|a\(bs\)\?[xy]\?\)\)\?\>"
syn match kickAssMnemonic "\<ahx\(\.\(izp\?y\|a\(bs\)\?y\)\)\?\>"
syn match kickAssMnemonic "\<alr\(\.imm\?\)\?\>"
syn match kickAssMnemonic "\<anc\(\.imm\?\)\?\>"
syn match kickAssMnemonic "\<anc2\(\.imm\?\)\?\>"
syn match kickAssMnemonic "\<and\(\.\(imm\?\|zp\?x\?\|izp\?[xy]\|a\(bs\)\?[xy]\?\)\)\?\>"
syn match kickAssMnemonic "\<arr\(\.imm\?\)\?\>"
syn match kickAssMnemonic "\<asl\(\.\(zp\?x\?\|a\(bs\)\?x\?\)\)\?\>"
syn match kickAssMnemonic "\<axs\(\.imm\?\)\?\>"
syn match kickAssJump "\<bcc\(\.r\(el\)\?\)\?\>"
syn match kickAssJump "\<bcs\(\.r\(el\)\?\)\?\>"
syn match kickAssJump "\<beq\(\.r\(el\)\?\)\?\>"
syn match kickAssMnemonic "\<bit\(\.\(zp\?\|a\(bs\)\?\)\)\?\>"
syn match kickAssJump "\<bmi\(\.r\(el\)\?\)\?\>"
syn match kickAssJump "\<bne\(\.r\(el\)\?\)\?\>"
syn match kickAssJump "\<bpl\(\.r\(el\)\?\)\?\>"
syn match kickAssJump "\<bvc\(\.r\(el\)\?\)\?\>"
syn match kickAssJump "\<bvs\(\.r\(el\)\?\)\?\>"
syn match kickAssMnemonic "\<cmp\(\.\(imm\?\|zp\?x\?\|izp\?[xy]\|a\(bs\)\?[xy]\?\)\)\?\>"
syn match kickAssMnemonic "\<cpx\(\.\(imm\?\|zp\?\|a\(bs\)\?\)\)\?\>"
syn match kickAssMnemonic "\<cpy\(\.\(imm\?\|zp\?\|a\(bs\)\?\)\)\?\>"
syn match kickAssMnemonic "\<dcp\(\.\(zp\?\x\?\|izp\?[xy]\|a\(bs\)\?[xy]\?\)\)\?\>"
syn match kickAssMnemonic "\<dec\(\.\(zp\?x\?\|a\(bs\)\?x\?\)\)\?\>"
syn match kickAssMnemonic "\<eor\(\.\(imm\?\|zp\?x\?\|izp\?[xy]\|a\(bs\)\?[xy]\?\)\)\?\>"
syn match kickAssMnemonic "\<inc\(\.\(zp\?x\?\|a\(bs\)\?x\?\)\)\?\>"
syn match kickAssMnemonic "\<isc\(\.\(zp\?\x\?\|izp\?[xy]\|a\(bs\)\?[xy]\?\)\)\?\>"
syn match kickAssJump "\<jmp\(\.\(a\(bs\)\?\|i\(nd\)\?\)\)\?\>"
syn match kickAssJump "\<jsr\(\.a\(bs\)\?\)\?\>"
syn match kickAssMnemonic "\<las\(\.a\(bs\)\?y\)\?\>"
syn match kickAssMnemonic "\<lax\(\.\(imm\?\|zp\?y\?\|izp\?[xy]\|a\(bs\)\?y\?\)\)\?\>"
syn match kickAssMnemonic "\<lda\(\.\(imm\?\|zp\?x\?\|izp\?[xy]\|a\(bs\)\?[xy]\?\)\)\?\>"
syn match kickAssMnemonic "\<ldx\(\.\(imm\?\|zp\?y\?\|a\(bs\)\?y\?\)\)\?\>"
syn match kickAssMnemonic "\<ldy\(\.\(imm\?\|zp\?x\?\|a\(bs\)\?x\?\)\)\?\>"
syn match kickAssMnemonic "\<lsr\(\.\(zp\?x\?\|a\(bs\)\?x\?\)\)\?\>"
syn match kickAssMnemonic "\<ora\(\.\(imm\?\|zp\?x\?\|izp\?[xy]\|a\(bs\)\?[xy]\?\)\)\?\>"
syn match kickAssMnemonic "\<rla\(\.\(zp\?\x\?\|izp\?[xy]\|a\(bs\)\?[xy]\?\)\)\?\>"
syn match kickAssMnemonic "\<rol\(\.\(zp\?x\?\|a\(bs\)\?x\?\)\)\?\>"
syn match kickAssMnemonic "\<ror\(\.\(zp\?x\?\|a\(bs\)\?x\?\)\)\?\>"
syn match kickAssMnemonic "\<rra\(\.\(zp\?\x\?\|izp\?[xy]\|a\(bs\)\?[xy]\?\)\)\?\>"
syn match kickAssMnemonic "\<sax\(\.\(zp\?[xy]\?\|a\(bs\)\?\)\)\?\>"
syn match kickAssMnemonic "\<sbc\(\.\(imm\?\|zp\?x\?\|izp\?[xy]\|a\(bs\)\?[xy]\?\)\)\?\>"
syn match kickAssMnemonic "\<sbc2\(\.imm\?\)\?\>"
syn match kickAssMnemonic "\<shx\(\.a\(bs\)\?y\)\?\>"
syn match kickAssMnemonic "\<shy\(\.a\(bs\)\?x\)\?\>"
syn match kickAssMnemonic "\<slo\(\.\(zp\?\x\?\|izp\?[xy]\|a\(bs\)\?[xy]\?\)\)\?\>"
syn match kickAssMnemonic "\<sre\(\.\(zp\?\x\?\|izp\?[xy]\|a\(bs\)\?[xy]\?\)\)\?\>"
syn match kickAssMnemonic "\<sta\(\.\(zp\?\x\?\|izp\?[xy]\|a\(bs\)\?[xy]\?\)\)\?\>"
syn match kickAssMnemonic "\<stx\(\.\(zp\?y\?\|a\(bs\)\?\)\)\?\>"
syn match kickAssMnemonic "\<sty\(\.\(zp\?x\?\|a\(bs\)\?\)\)\?\>"
syn match kickAssMnemonic "\<tas\(\.a\(bs\)\?y\)\?\>"
syn match kickAssMnemonic "\<xaa\(\.imm\?\)\?\>"
" DTV mnemonics
syn match kickAssJump "\<bra\(\.r\(el\)\?\)\?\>"
syn match kickAssMnemonic "\<sac\(\.imm\?\)\?\>"
syn match kickAssMnemonic "\<sir\(\.imm\?\)\?\>"
" indexes
syn match kickAssIndex ",\s*[xy]"
" Strings/chars
syn region kickAssString start=+"+ skip=+\\"+ end=+"+ contains=@Spell oneline
syn region kickAssString start=+'+ skip=+\\'+ end=+'+ contains=@Spell oneline
" Comments
syn keyword kickAssTodo TODO FIXME XXX TBD NOTE WARNING BUG contained
syn match kickAssLineComment "\/\/.*" contains=@Spell,kickAssTodo
syn region kickAssComment start="/\*" end="\*/" contains=@Spell,kickAssTodo
" Numbers
syn match kickAssDecNumber "\<\d\+\>"
syn match kickAssHexNumber "\$\x\+\>"
syn match kickAssBinNumber "%[01]\+\>"
syn match kickAssImmediate "#\$\x\+\>"
syn match kickAssImmediate "#\d\+\>"
syn match kickAssImmediate "#<\$\x\+\>"
syn match kickAssImmediate "#<\d\+\>"
syn match kickAssImmediate "#>\$\x\+\>"
syn match kickAssImmediate "#>\d\+\>"
" memory and data directives
syn match kickAssDirective /\.\<pc\>/
syn match kickAssDirective /\.\<align\>/
syn match kickAssDirective /\.\<byte\>/
syn match kickAssDirective /\.\<word\>/
syn match kickAssDirective /\.\<dword\>/
syn match kickAssDirective /\.\<text\>/
syn match kickAssDirective /\.\<fill\>/
syn match kickAssDirective /\.\<pseudopc\>/
" modifiers
syn match kickAssDirective /\.\<modify\>/
syn match kickAssDirective /\.\<filemodify\>/
" import directive
syn match kickAssDirective "\.\<importonce\>"
syn match kickAssDirective "\.\<import\>" nextgroup=kickAssImportType skipwhite
syn keyword kickAssImportType source binary c64 text contained
" console output
syn match kickAssDirective "\.\<print\>"
syn match kickAssDirective "\.\<printnow\>"
syn match kickAssDirective "\.\<error\>"
" elements of script language
syn match kickAssDirective "\.\<eval\>"
syn match kickAssDirective "\.\<var\>"
syn match kickAssDirective "\.\<const\>"
syn match kickAssDirective "\.\<enum\>"
syn match kickAssDirective "\.\<label\>"
syn match kickAssDirective "\.\<lock\>"
syn match kickAssDirective "\.\<define\>"
syn match kickAssDirective "\.\<if\>"
syn keyword kickAssDirective else
syn match kickAssDirective "\.\<for\>"
syn match kickAssDirective "\.\<macro\>"
syn match kickAssDirective "\.\<function\>"
syn match kickAssDirective "\.\<return\>"
syn match kickAssDirective "\.\<namespace\>"
syn match kickAssDirective "\.\<filenamespace\>"
" special macros
syn match kickAssMacroCall ":\<BasicUpstart2\?\>"
" PSID files
syn match kickAssFunction "\<LoadSid\>("he=e-1
syn match kickAssAttr "\.\<header\>"hs=s+1
syn match kickAssAttr "\.\<version\>"hs=s+1
syn match kickAssAttr "\.\<location\>"hs=s+1
syn match kickAssAttr "\.\<init\>"hs=s+1
syn match kickAssAttr "\.\<play\>"hs=s+1
syn match kickAssAttr "\.\<size\>"hs=s+1
syn match kickAssAttr "\.\<songs\>"hs=s+1
syn match kickAssAttr "\.\<startSong\>"hs=s+1
syn match kickAssAttr "\.\<name\>"hs=s+1
syn match kickAssAttr "\.\<author\>"hs=s+1
syn match kickAssAttr "\.\<copyright\>"hs=s+1
syn match kickAssAttr "\.\<speed\>"hs=s+1
syn match kickAssAttr "\.\<flags\>"hs=s+1
syn match kickAssAttr "\.\<startpage\>"hs=s+1
syn match kickAssAttr "\.\<pagelength\>"hs=s+1
syn match kickAssMethod "\.\<getData\>("he=e-1,hs=s+1
" string methods and functions
syn match kickAssMethod "\.\<string\>("he=e-1,hs=s+1
syn match kickAssMethod "\.\<size\>("he=e-1,hs=s+1
syn match kickAssMethod "\.\<charAt\>("he=e-1,hs=s+1
syn match kickAssMethod "\.\<substring\>("he=e-1,hs=s+1
syn match kickAssMethod "\.\<asBoolean\>("he=e-1,hs=s+1
syn match kickAssMethod "\.\<asNumber\>("he=e-1,hs=s+1
syn match kickAssFunction "\<toIntString\>("he=e-1
syn match kickAssFunction "\<toBinaryString\>("he=e-1
syn match kickAssFunction "\<toOctalString\>("he=e-1
syn match kickAssFunction "\<toHexString\>("he=e-1
" Math library
syn keyword kickAssConstant PI E
syn match kickAssFunction "\<abs\>("he=e-1
syn match kickAssFunction "\<acos\>("he=e-1
syn match kickAssFunction "\<asin\>("he=e-1
syn match kickAssFunction "\<atan\>("he=e-1
syn match kickAssFunction "\<atan2\>("he=e-1
syn match kickAssFunction "\<cbrt\>("he=e-1
syn match kickAssFunction "\<ceil\>("he=e-1
syn match kickAssFunction "\<cos\>("he=e-1
syn match kickAssFunction "\<cosh\>("he=e-1
syn match kickAssFunction "\<exp\>("he=e-1
syn match kickAssFunction "\<expml\>("he=e-1
syn match kickAssFunction "\<floor\>("he=e-1
syn match kickAssFunction "\<hypot\>("he=e-1
syn match kickAssFunction "\<IEEEremainder\>("he=e-1
syn match kickAssFunction "\<log\>("he=e-1
syn match kickAssFunction "\<log10\>("he=e-1
syn match kickAssFunction "\<log1p\>("he=e-1
syn match kickAssFunction "\<max\>("he=e-1
syn match kickAssFunction "\<min\>("he=e-1
syn match kickAssFunction "\<mod\>("he=e-1
syn match kickAssFunction "\<pow\>("he=e-1
syn match kickAssFunction "\<random\>("he=e-1
syn match kickAssFunction "\<round\>("he=e-1
syn match kickAssFunction "\<signum\>("he=e-1
syn match kickAssFunction "\<sin\>("he=e-1
syn match kickAssFunction "\<sinh\>("he=e-1
syn match kickAssFunction "\<sqrt\>("he=e-1
syn match kickAssFunction "\<tan\>("he=e-1
syn match kickAssFunction "\<tanh\>("he=e-1
syn match kickAssFunction "\<toDegrees\>("he=e-1
syn match kickAssFunction "\<toRadians\>("he=e-1
" List already defined: size
syn match kickAssFunction /\<List\>(/he=e-1
syn match kickAssMethod "\.\<get\>("he=e-1,hs=s+1
syn match kickAssMethod "\.\<set\>("he=e-1,hs=s+1
syn match kickAssMethod "\.\<add\>("he=e-1,hs=s+1
syn match kickAssMethod "\.\<remove\>("he=e-1,hs=s+1
syn match kickAssMethod "\.\<shuffle\>("he=e-1,hs=s+1
syn match kickAssMethod "\.\<reverse\>("he=e-1,hs=s+1
syn match kickAssMethod "\.\<sort\>("he=e-1,hs=s+1
" READY.
" Hash - already defined names: get, remove
syn match kickAssFunction /\<Hashtable\>(/he=e-1
syn match kickAssMethod "\.\<put\>("he=e-1,hs=s+1
syn match kickAssMethod "\.\<keys\>("he=e-1,hs=s+1
syn match kickAssMethod "\.\<containsKey\>("he=e-1,hs=s+1
" Vector/Matrix - already defined: get, set
syn match kickAssFunction "\<Vector\>("he=e-1
syn match kickAssMethod "\.\<getX\>("he=e-1,hs=s+1
syn match kickAssMethod "\.\<getY\>("he=e-1,hs=s+1
syn match kickAssMethod "\.\<getZ\>("he=e-1,hs=s+1
syn match kickAssMethod "\.\<\X\>("he=e-1,hs=s+1
syn match kickAssFunction "\<Matrix\>("he=e-1
syn match kickAssFunction "\<RotationMatrix\>("he=e-1
syn match kickAssFunction "\<ScaleMatrix\>("he=e-1
syn match kickAssFunction "\<PerspectiveMatrix\>("he=e-1
syn match kickAssFunction "\<MoveMatrix\>("he=e-1
" Structures - already defined names: get, set
syn match kickAssDirective "\.\<struct\>"
syn match kickAssMethod "\.\<getStructName\>("he=e-1,hs=s+1
syn match kickAssMethod "\.\<getNoOfFields\>("he=e-1,hs=s+1
syn match kickAssMethod "\.\<getFieldNames\>("he=e-1,hs=s+1
" pseudocommand
syn match kickAssDirective "\.\<pseudocommand\>"
syn match kickAssFunction "\<CmdArgument\>("he=e-1
syn match kickAssFunction "\<getType\>("he=e-1
syn match kickAssFunction "\<getValue\>("he=e-1
syn keyword kickAssConstant AT_ABSOLUTE AT_ABSOLUTEX AT_ABSOLUTEY AT_IMMEDIATE
syn keyword kickAssConstant AT_INDIRECT AT_IZEROPAGEX AT_IZEROPAGEY AT_NONE
" Opcode constants
syn match kickAssFunction "\<asmCommandSize\>("he=e-1
syn keyword kickAssConstant RTS
syn match kickAssConstant "\<[A-Z]\{3}2\?_\(IMM\|I\?ZP[XY]\?\|ABS[XY]\?\|IND\|REL\)\>"
" Constants
syn keyword kickAssColor BLACK WHITE RED CYAN PURPLE GREEN BLUE YELLOW ORANGE
syn keyword kickAssColor BROWN LIGHT_RED DARK_GRAY GRAY LIGHT_GREEN LIGHT_BLUE
syn keyword kickAssColor LIGHT_GRAY DARK_GREY GREY LIGHT_GREY
syn keyword kickAssConstant C64FILE
syn keyword kickAssConstant BD_C64FILE BF_BITMAP_SINGLECOLOR BF_KOALA BF_FLI
" Binary import
syn match kickAssFunction "\<LoadBinary\>("he=e-1
syn match kickAssMethod "\.\<getSize\>("he=e-1,hs=s+1
syn match kickAssFunction "\<LoadBinary\>("he=e-1
" Graphics files
syn match kickAssFunction "\<LoadPicture\>("he=e-1
syn match kickAssAttr "\.\<width\>"hs=s+1
syn match kickAssAttr "\.\<height\>"hs=s+1
syn match kickAssMethod "\.\<getPixel\>("he=e-1,hs=s+1
syn match kickAssMethod "\.\<getSinglecolorByte\>("he=e-1,hs=s+1
syn match kickAssMethod "\.\<getMulticolorByte\>("he=e-1,hs=s+1
syn match kickAssMethod "\.\<getScreenRamSize\>("he=e-1,hs=s+1
syn match kickAssMethod "\.\<getScreenRam\>("he=e-1,hs=s+1
syn match kickAssMethod "\.\<getColorRamSize\>("he=e-1,hs=s+1
syn match kickAssMethod "\.\<getColorRam\>("he=e-1,hs=s+1
syn match kickAssMethod "\.\<getBitmapSize\>("he=e-1,hs=s+1
syn match kickAssMethod "\.\<getBitmap\>("he=e-1,hs=s+1
syn match kickAssMethod "\.\<getBackgroundColor\>("he=e-1,hs=s+1
" User defined files
syn match kickAssFunction "\<createFile\>("he=e-1
syn match kickAssMethod "\.\<writeln\>("he=e-1,hs=s+1
" Testing
syn match kickAssDirective "\.\<kickAssert\>"
syn match kickAssDirective "\.\<kickAsserterror\>"
if !exists("did_kickasm_syntax_inits")
let did_kickasm_syntax_inits = 1
hi def link kickAssDirective Special
hi def link kickAssMnemonic Type
hi def link kickAssIndex None
hi def link kickAssJump Conditional
hi def link kickAssString String
hi def link kickAssString String
hi def link kickAssComment Comment
hi def link kickAssLineComment Comment
hi def link kickAssMacroCall Function
hi def link kickAssTodo Todo
hi def link kickAssImportType Operator
hi def link kickAssFunction Function
hi def link kickAssMethod Function
hi def link kickAssAttr Special
hi def link kickAssColor Constant
hi def link kickAssConstant Constant
hi def link kickAssImmediate Number
hi def link kickAssHexNumber Number
hi def link kickAssBinNumber Number
hi def link kickAssDecNumber Number
endif
let b:current_syntax = "kickasm"

View File

@@ -1,86 +0,0 @@
" Vim syntax file
" Language: Mako
" Maintainer: Armin Ronacher <armin.ronacher@active-4.com>
" URL: http://lucumr.pocoo.org/
" Last Change: 2008 September 12
" Version: 0.6.1
"
" Thanks to Brine Rue <brian@lolapps.com> who noticed a bug in the
" delimiter handling.
"
" Known Limitations
" the <%text> block does not have correct attributes
" For version 5.x: Clear all syntax items
" For version 6.x: Quit when a syntax file was already loaded
if version < 600
syntax clear
elseif exists("b:current_syntax")
finish
endif
if !exists("main_syntax")
let main_syntax = "html"
endif
"Source the html syntax file
ru! syntax/html.vim
unlet b:current_syntax
"Put the python syntax file in @pythonTop
syn include @pythonTop syntax/python.vim
" End keywords
syn keyword makoEnd contained endfor endwhile endif endtry enddef
" Block rules
syn region makoLine matchgroup=makoDelim start=#^\s*%# end=#$# keepend contains=@pythonTop,makoEnd
syn region makoBlock matchgroup=makoDelim start=#<%!\?# end=#%># keepend contains=@pythonTop,makoEnd
" Variables
syn region makoNested start="{" end="}" transparent display contained contains=makoNested,@pythonTop
syn region makoVariable matchgroup=makoDelim start=#\${# end=#}# contains=makoNested,@pythonTop
" Comments
syn region makoComment start="^\s*##" end="$"
syn region makoDocComment matchgroup=makoDelim start="<%doc>" end="</%doc>" keepend
" Literal Blocks
syn region makoText matchgroup=makoDelim start="<%text[^>]*>" end="</%text>"
" Attribute Sublexing
syn match makoAttributeKey containedin=makoTag contained "[a-zA-Z_][a-zA-Z0-9_]*="
syn region makoAttributeValue containedin=makoTag contained start=/"/ skip=/\\"/ end=/"/
syn region makoAttributeValue containedin=MakoTag contained start=/'/ skip=/\\'/ end=/'/
" Tags
syn region makoTag matchgroup=makoDelim start="<%\(def\|call\|page\|include\|namespace\|inherit\)\>" end="/\?>"
syn match makoDelim "</%\(def\|call\|namespace\)>"
" Newline Escapes
syn match makoEscape /\\$/
" Default highlighting links
if version >= 508 || !exists("did_mako_syn_inits")
if version < 508
let did_mako_syn_inits = 1
com -nargs=+ HiLink hi link <args>
else
com -nargs=+ HiLink hi def link <args>
endif
HiLink makoDocComment makoComment
HiLink makoDefEnd makoDelim
HiLink makoAttributeKey Type
HiLink makoAttributeValue String
HiLink makoText Normal
HiLink makoDelim Preproc
HiLink makoEnd Keyword
HiLink makoComment Comment
HiLink makoEscape Special
delc HiLink
endif
let b:current_syntax = "eruby"