" Vimball Archiver by Charles E. Campbell, Jr., Ph.D. UseVimball finish syntax\vimwiki.vim [[[1 127 " Vimwiki syntax file " Author: Maxim Kim " Home: http://code.google.com/p/vimwiki/ " vim:tw=79: " Quit if syntax file is already loaded if version < 600 syntax clear elseif exists("b:current_syntax") finish endif "" use max highlighting - could be quite slow if there are too many wikifiles if VimwikiGet('maxhi') " Every WikiWord is nonexistent if g:vimwiki_camel_case execute 'syntax match wikiNoExistsWord /\%(^\|[^!]\)\zs'.g:vimwiki_word1.'/' endif execute 'syntax match wikiNoExistsWord /'.g:vimwiki_word2.'/' execute 'syntax match wikiNoExistsWord /'.g:vimwiki_word3.'/' " till we find them in vimwiki's path call vimwiki#WikiHighlightWords() else " A WikiWord (unqualifiedWikiName) execute 'syntax match wikiWord /\%(^\|[^!]\)\zs\<'.g:vimwiki_word1.'\>/' " A [[bracketed wiki word]] execute 'syntax match wikiWord /'.g:vimwiki_word2.'/' endif execute 'syntax match wikiLink `'.g:vimwiki_rxWeblink.'`' " Emoticons: must come after the Textilisms, as later rules take precedence " over earlier ones. This match is an approximation for the ~70 distinct syntax match wikiEmoticons /\%((.)\|:[()|$@]\|:-[DOPS()\]|$@]\|;)\|:'(\)/ let g:vimwiki_rxTodo = '\C\%(TODO:\|DONE:\|FIXME:\|FIXED:\|XXX:\)' execute 'syntax match wikiTodo /'. g:vimwiki_rxTodo .'/' " Load concrete Wiki syntax execute 'runtime! syntax/vimwiki_'.VimwikiGet('syntax').'.vim' " Tables execute 'syntax match wikiTable /'.g:vimwiki_rxTable.'/' execute 'syntax match wikiBold /'.g:vimwiki_rxBold.'/' execute 'syntax match wikiItalic /'.g:vimwiki_rxItalic.'/' execute 'syntax match wikiBoldItalic /'.g:vimwiki_rxBoldItalic.'/' execute 'syntax match wikiItalicBold /'.g:vimwiki_rxItalicBold.'/' execute 'syntax match wikiDelText /'.g:vimwiki_rxDelText.'/' execute 'syntax match wikiSuperScript /'.g:vimwiki_rxSuperScript.'/' execute 'syntax match wikiSubScript /'.g:vimwiki_rxSubScript.'/' execute 'syntax match wikiCode /'.g:vimwiki_rxCode.'/' "
horizontal rule execute 'syntax match wikiHR /'.g:vimwiki_rxHR.'/' " List items execute 'syntax match wikiList /'.g:vimwiki_rxListBullet.'/' execute 'syntax match wikiList /'.g:vimwiki_rxListNumber.'/' execute 'syntax match wikiList /'.g:vimwiki_rxListDefine.'/' execute 'syntax region wikiPre start=/'.g:vimwiki_rxPreStart. \ '/ end=/'.g:vimwiki_rxPreEnd.'/ contains=wikiComment' " List item checkbox syntax match wikiCheckBox /\[.\?\]/ if g:vimwiki_hl_cb_checked execute 'syntax match wikiCheckBoxDone /'.g:vimwiki_rxListBullet.'\s*\[x\].*$/' execute 'syntax match wikiCheckBoxDone /'.g:vimwiki_rxListNumber.'\s*\[x\].*$/' endif syntax region wikiComment start='' if !vimwiki#hl_exists("wikiHeader1") execute 'syntax match wikiHeader /'.g:vimwiki_rxHeader.'/' else " Header levels, 1-6 execute 'syntax match wikiHeader1 /'.g:vimwiki_rxH1.'/' execute 'syntax match wikiHeader2 /'.g:vimwiki_rxH2.'/' execute 'syntax match wikiHeader3 /'.g:vimwiki_rxH3.'/' execute 'syntax match wikiHeader4 /'.g:vimwiki_rxH4.'/' execute 'syntax match wikiHeader5 /'.g:vimwiki_rxH5.'/' execute 'syntax match wikiHeader6 /'.g:vimwiki_rxH6.'/' endif if !vimwiki#hl_exists("wikiHeader1") hi def link wikiHeader Title else hi def link wikiHeader1 Title hi def link wikiHeader2 Title hi def link wikiHeader3 Title hi def link wikiHeader4 Title hi def link wikiHeader5 Title hi def link wikiHeader6 Title endif hi def wikiBold term=bold cterm=bold gui=bold hi def wikiItalic term=italic cterm=italic gui=italic hi def wikiBoldItalic term=bold cterm=bold gui=bold,italic hi def link wikiItalicBold wikiBoldItalic hi def link wikiCode PreProc hi def link wikiWord Underlined hi def link wikiNoExistsWord Error hi def link wikiPre PreProc hi def link wikiLink Underlined hi def link wikiList Statement " hi def link wikiList Identifier hi def link wikiCheckBox wikiList hi def link wikiCheckBoxDone Comment hi def link wikiTable PreProc hi def link wikiEmoticons Character hi def link wikiDelText Constant hi def link wikiSuperScript Number hi def link wikiSubScript Number hi def link wikiTodo Todo hi def link wikiComment Comment let b:current_syntax="vimwiki" syntax\vimwiki_default.vim [[[1 76 " Vimwiki syntax file " Default syntax " Author: Maxim Kim " Home: http://code.google.com/p/vimwiki/ " vim:tw=78: " text: *strong* " let g:vimwiki_rxBold = '\*[^*]\+\*' let g:vimwiki_rxBold = '\%(^\|\s\|[[:punct:]]\)\@<='. \'\*'. \'\([^*`[:space:]][^*`]*[^*`[:space:]]\|[^*`]\)'. \'\*'. \'\%([[:punct:]]\|\s\|$\)\@=' " text: _emphasis_ " let g:vimwiki_rxItalic = '_[^_]\+_' let g:vimwiki_rxItalic = '\%(^\|\s\|[[:punct:]]\)\@<='. \'_'. \'\([^_`[:space:]][^_`]*[^_`[:space:]]\|[^_`]\)'. \'_'. \'\%([[:punct:]]\|\s\|$\)\@=' " text: *_bold italic_* or _*italic bold*_ let g:vimwiki_rxBoldItalic = '\%(^\|\s\|[[:punct:]]\)\@<='. \'\*_'. \'\([^*_`[:space:]][^*_`]*[^*_`[:space:]]\|[^*_`]\)'. \'_\*'. \'\%([[:punct:]]\|\s\|$\)\@=' let g:vimwiki_rxItalicBold = '\%(^\|\s\|[[:punct:]]\)\@<='. \'_\*'. \'\([^*_`[:space:]][^*_`]*[^*_`[:space:]]\|[^*_`]\)'. \'\*_'. \'\%([[:punct:]]\|\s\|$\)\@=' " text: `code` let g:vimwiki_rxCode = '`[^`]\+`' " text: ~~deleted text~~ let g:vimwiki_rxDelText = '\~\~[^~`]\+\~\~' " text: ^superscript^ let g:vimwiki_rxSuperScript = '\^[^^`]\+\^' " text: ,,subscript,, let g:vimwiki_rxSubScript = ',,[^,`]\+,,' " Header levels, 1-6 let g:vimwiki_rxH1 = '^\s*=\{1}[^=]\+.*[^=]\+=\{1}\s*$' let g:vimwiki_rxH2 = '^\s*=\{2}[^=]\+.*[^=]\+=\{2}\s*$' let g:vimwiki_rxH3 = '^\s*=\{3}[^=]\+.*[^=]\+=\{3}\s*$' let g:vimwiki_rxH4 = '^\s*=\{4}[^=]\+.*[^=]\+=\{4}\s*$' let g:vimwiki_rxH5 = '^\s*=\{5}[^=]\+.*[^=]\+=\{5}\s*$' let g:vimwiki_rxH6 = '^\s*=\{6}[^=]\+.*[^=]\+=\{6}\s*$' let g:vimwiki_rxHeader = '\%('.g:vimwiki_rxH1.'\)\|'. \ '\%('.g:vimwiki_rxH2.'\)\|'. \ '\%('.g:vimwiki_rxH3.'\)\|'. \ '\%('.g:vimwiki_rxH4.'\)\|'. \ '\%('.g:vimwiki_rxH5.'\)\|'. \ '\%('.g:vimwiki_rxH6.'\)' "
, horizontal rule let g:vimwiki_rxHR = '^----.*$' " Tables. Each line starts and ends with '||'; each cell is separated by '||' let g:vimwiki_rxTable = '||' " List items start with whitespace(s) then '*' or '#' let g:vimwiki_rxListBullet = '^\s\+\*' let g:vimwiki_rxListNumber = '^\s\+#' let g:vimwiki_rxListDefine = '::\(\s\|$\)' " Preformatted text let g:vimwiki_rxPreStart = '{{{' let g:vimwiki_rxPreEnd = '}}}' syntax\vimwiki_media.vim [[[1 58 " Vimwiki syntax file " MediaWiki syntax " Author: Maxim Kim " Home: http://code.google.com/p/vimwiki/ " vim:tw=78: " text: '''strong''' let g:vimwiki_rxBold = "'''[^']\\+'''" " text: ''emphasis'' let g:vimwiki_rxItalic = "''[^']\\+''" " text: '''''strong italic''''' let g:vimwiki_rxBoldItalic = "'''''[^']\\+'''''" let g:vimwiki_rxItalicBold = g:vimwiki_rxBoldItalic " text: `code` let g:vimwiki_rxCode = '`[^`]\+`' " text: ~~deleted text~~ let g:vimwiki_rxDelText = '\~\~[^~]\+\~\~' " text: ^superscript^ let g:vimwiki_rxSuperScript = '\^[^^]\+\^' " text: ,,subscript,, let g:vimwiki_rxSubScript = ',,[^,]\+,,' " Header levels, 1-6 let g:vimwiki_rxH1 = '^\s*=\{1}[^=]\+.*[^=]\+=\{1}\s*$' let g:vimwiki_rxH2 = '^\s*=\{2}[^=]\+.*[^=]\+=\{2}\s*$' let g:vimwiki_rxH3 = '^\s*=\{3}[^=]\+.*[^=]\+=\{3}\s*$' let g:vimwiki_rxH4 = '^\s*=\{4}[^=]\+.*[^=]\+=\{4}\s*$' let g:vimwiki_rxH5 = '^\s*=\{5}[^=]\+.*[^=]\+=\{5}\s*$' let g:vimwiki_rxH6 = '^\s*=\{6}[^=]\+.*[^=]\+=\{6}\s*$' let g:vimwiki_rxHeader = '\%('.g:vimwiki_rxH1.'\)\|'. \ '\%('.g:vimwiki_rxH2.'\)\|'. \ '\%('.g:vimwiki_rxH3.'\)\|'. \ '\%('.g:vimwiki_rxH4.'\)\|'. \ '\%('.g:vimwiki_rxH5.'\)\|'. \ '\%('.g:vimwiki_rxH6.'\)' "
, horizontal rule let g:vimwiki_rxHR = '^----.*$' " Tables. Each line starts and ends with '||'; each cell is separated by '||' let g:vimwiki_rxTable = '||' " Bulleted list items start with whitespace(s), then '*' " highlight only bullets and digits. let g:vimwiki_rxListBullet = '^\s*\*\+\([^*]*$\)\@=' let g:vimwiki_rxListNumber = '^\s*#\+' let g:vimwiki_rxListDefine = '^\%(;\|:\)\s' " Preformatted text let g:vimwiki_rxPreStart = '
'
let g:vimwiki_rxPreEnd = '<\/pre>'
ftplugin\vimwiki.vim	[[[1
277
" Vimwiki filetype plugin file
" Author: Maxim Kim 
" 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 wrap< linebreak< ".
      \ "suffixesadd< isfname< comments< ".
      \ "autowriteall< ".
      \ "formatoptions< foldtext< ".
      \ "foldmethod< foldexpr< commentstring< "
" UNDO }}}

" MISC STUFF {{{

setlocal wrap
setlocal linebreak
setlocal autowriteall
setlocal commentstring=
" MISC }}}

" GOTO FILE: gf {{{
execute 'setlocal suffixesadd='.VimwikiGet('ext')
setlocal isfname-=[,]
" gf}}}

" COMMENTS: autocreate list items {{{
" for list items, and list items with checkboxes
if VimwikiGet('syntax') == 'default'
  setl comments=b:\ *\ [\ ],b:\ *[\ ],b:\ *\ [],b:\ *[],b:\ *\ [x],b:\ *[x]
  setl comments+=b:\ #\ [\ ],b:\ #[\ ],b:\ #\ [],b:\ #[],b:\ #\ [x],b:\ #[x]
  setl comments+=b:\ *,b:\ #
  setl formatlistpat=^\\s\\+[*#]\\s*
else
  setl comments=n:*\ [\ ],n:*[\ ],n:*\ [],n:*[],n:*\ [x],n:*[x]
  setl comments+=n:#\ [\ ],n:#[\ ],n:#\ [],n:#[],n:#\ [x],n:#[x]
  setl comments+=n:*,n:#
endif
setlocal formatoptions=tnro
" COMMENTS }}}

" FOLDING for headers and list items using expr fold method. {{{
if g:vimwiki_folding == 1
  setlocal fdm=expr
endif
setlocal foldexpr=VimwikiFoldLevel(v:lnum)

function! VimwikiFoldLevel(lnum) "{{{
  let line = getline(a:lnum)

  " Header folding...
  if line =~ g:vimwiki_rxHeader
    let n = vimwiki#count_first_sym(line)
    return '>' . n
  endif

  if g:vimwiki_fold_empty_lines == 0
    let nnline = getline(nextnonblank(a:lnum + 1))
    if nnline =~ g:vimwiki_rxHeader
      let n = vimwiki#count_first_sym(nnline)
      return '<' . n
    endif
  endif

  " List item folding...
  if g:vimwiki_fold_lists
    let rx_list_item = '\('.
          \ g:vimwiki_rxListBullet.'\|'.g:vimwiki_rxListNumber.
          \ '\)'

    if line =~ rx_list_item
      let [nnum, nline] = s:find_next_item(rx_list_item, a:lnum)
      if nline =~ rx_list_item
        let level = s:get_li_level(a:lnum, nnum)
        if !(level < 0 && (nnum - a:lnum) > 1)
          return s:fold_marker(level)
        endif
      elseif nnum - a:lnum == 1
        " last single-lined list item in a list
        let level = s:get_li_level_last(a:lnum)
        return s:fold_marker(level)
      endif
    else
      let [pnum, pline] = s:find_prev_item(rx_list_item, a:lnum)
      if pline =~ rx_list_item
        if getline(a:lnum + 1) =~ rx_list_item
          let level = s:get_li_level(pnum, a:lnum + 1)
          if level < 0
            return s:fold_marker(level)
          endif
        endif

        let [nnum, nline] = s:find_next_item(rx_list_item, pnum)
        if nline !~ rx_list_item && nnum-a:lnum == 1
          " last multi-lined list item in a list
          let level = s:get_li_level_last(pnum)
          return s:fold_marker(level)
        endif

      endif
    endif

  endif

  return '='
endfunction "}}}

function! s:fold_marker(level) "{{{
  if a:level > 0
    return "a".a:level
  elseif a:level < 0
    return "s".abs(a:level)
  else
    return "="
  endif
endfunction "}}}

function! s:find_next_item(rx_item, lnum) "{{{
  let lnum = a:lnum + 1

  while lnum <= line('$')
    if getline(lnum) =~ a:rx_item
          \ || getline(lnum) =~ '^\S'
          \ || indent(lnum) <= indent(a:lnum)
      break
    endif
    let lnum += 1
  endwhile

  return [lnum, getline(lnum)]
endfunction "}}}

function! s:find_prev_item(rx_item, lnum) "{{{
  let lnum = a:lnum - 1

  while lnum > 1
    if getline(lnum) =~ a:rx_item
          \ || getline(lnum) =~ '^\S'
      break
    endif
    let lnum -= 1
  endwhile

  return [lnum, getline(lnum)]
endfunction "}}}

function! s:get_li_level(lnum, nnum) "{{{
  if VimwikiGet('syntax') == 'media'
    let level = vimwiki#count_first_sym(getline(a:nnum)) -
          \ vimwiki#count_first_sym(getline(a:lnum))
  else
    let level = ((indent(a:nnum) - indent(a:lnum)) / &sw)
  endif
  return level
endfunction "}}}

function! s:get_li_level_last(lnum) "{{{
  if VimwikiGet('syntax') == 'media'
    return -(vimwiki#count_first_sym(getline(a:lnum)) - 1)
  else
    return -(indent(a:lnum) / &sw - 1)
  endif
endfunction "}}}

setlocal foldtext=VimwikiFoldText()
function! VimwikiFoldText() "{{{
  let line = getline(v:foldstart)
  return line.' ['.(v:foldend - v:foldstart).'] '
endfunction "}}}

" FOLDING }}}

" COMMANDS {{{
command! -buffer Vimwiki2HTML
      \ call vimwiki_html#Wiki2HTML(expand(VimwikiGet('path_html')),
      \                             expand('%'))
command! -buffer VimwikiAll2HTML
      \ call vimwiki_html#WikiAll2HTML(expand(VimwikiGet('path_html')))

command! -buffer VimwikiNextWord call vimwiki#WikiNextWord()
command! -buffer VimwikiPrevWord call vimwiki#WikiPrevWord()
command! -buffer VimwikiDeleteWord call vimwiki#WikiDeleteWord()
command! -buffer VimwikiRenameWord call vimwiki#WikiRenameWord()
command! -buffer VimwikiFollowWord call vimwiki#WikiFollowWord('nosplit')
command! -buffer VimwikiGoBackWord call vimwiki#WikiGoBackWord()
command! -buffer VimwikiSplitWord call vimwiki#WikiFollowWord('split')
command! -buffer VimwikiVSplitWord call vimwiki#WikiFollowWord('vsplit')

command! -buffer VimwikiToggleListItem call vimwiki_lst#ToggleListItem()
" COMMANDS }}}

" KEYBINDINGS {{{
if g:vimwiki_use_mouse
  nmap   
  nmap   
  noremap  <2-LeftMouse> :VimwikiFollowWord
  noremap   :VimwikiSplitWord
  noremap   :VimwikiVSplitWord
  noremap   :VimwikiGoBackWord
endif

if !hasmapto('VimwikiFollowWord')
  nmap   VimwikiFollowWord
endif
noremap