Skip to content

Commit

Permalink
Version 4.0
Browse files Browse the repository at this point in the history
New markup modes: asciidoc, org, cwiki. Viki mode now ignores special regions.
New Tree mapping: "R" selects corresponding range in the source buffer.
  • Loading branch information
vim-voom authored and vim-scripts committed Nov 7, 2011
1 parent 8cc336a commit 77883ae
Show file tree
Hide file tree
Showing 29 changed files with 2,118 additions and 267 deletions.
9 changes: 6 additions & 3 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,19 @@ Screenshots and an animation: http://vim-voom.github.com/

VOoM was originally written to work with start fold markers with level numbers, that is {{{1, {{{2, {{{3, etc. This is the most versatile outline markup -- it is suitable for organizing all kinds of files, including source code, and it allows features not possible with other markups. (See :help fold-marker. Markers are specified by option 'foldmarker'. End fold markers with levels, }}}3, }}}2, etc. are not supported.)

VOoM currently can handle a variety of other markup formats that have headlines and support an outline structure. (Headlines are also called headings, headers, section headers, titles.) The following markup modes are available:
VOoM currently can handle several other markup formats that have headlines and support an outline structure. (Headlines are also called headings, headers, section headers, titles.) The following markup modes are available:
wiki -- MediaWiki, headlines are surrounded by '='
vimwiki -- vimwiki plugin (vimscript #2226)
viki -- Viki/Deplate plugin (vimscript #861), Emacs Org-mode
viki -- Viki/Deplate plugin (vimscript #861)
org -- Emacs Org-mode
rest -- reStructuredText section titles
markdown -- Markdown, both header styles
txt2tags -- txt2tags titles and numbered titles
txt2tags -- txt2tags titles and numbered titles
asciidoc -- AsciiDoc document and section titles, both styles
html -- HTML heading tags, single line only
thevimoutliner -- The Vim Outliner plugin (vimscript #517)
vimoutliner -- VimOutliner plugin (vimscript #3515)
cwiki -- vimscript #2176
python -- Python code browser, blocks between 'class' and 'def' are also nodes

FEATURES:
Expand Down
642 changes: 518 additions & 124 deletions doc/voom.txt

Large diffs are not rendered by default.

98 changes: 74 additions & 24 deletions plugin/voom.vim
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
" voom.vim
" Last Modified: 2011-03-19
" VOoM (Vim Outliner of Markers) -- two-pane outliner and related utilities
" plugin for Python-enabled Vim version 7.x
" Version: 4.0b5
" Last Modified: 2011-11-03
" VOoM -- Vim two-pane outliner, plugin for Python-enabled Vim version 7.x
" Version: 4.0
" Website: http://www.vim.org/scripts/script.php?script_id=2657
" Author: Vlad Irnov (vlad DOT irnov AT gmail DOT com)
" License: This program is free software. It comes without any warranty,
Expand Down Expand Up @@ -36,7 +35,7 @@

"---Quickload---------------------------------{{{1
if !exists('s:voom_did_quickload')
let s:voom_did_quickload = 'v4.0b5'
let s:voom_did_quickload = 'v4.0'
com! -complete=custom,Voom_Complete -nargs=? Voom call Voom_Init(<q-args>)
com! Voomhelp call Voom_Help()
com! Voomlog call Voom_LogInit()
Expand Down Expand Up @@ -215,7 +214,7 @@ endfunc

func! Voom_Complete(A,L,P) "{{{2
" Argument completion for command :Voom.
return "wiki\nvimwiki\nviki\nrest\nmarkdown\ntxt2tags\nhtml\npython\nthevimoutliner\nvimoutliner"
return "wiki\nvimwiki\nviki\norg\nrest\nmarkdown\ntxt2tags\nasciidoc\nhtml\npython\nthevimoutliner\nvimoutliner"
endfunc


Expand Down Expand Up @@ -887,29 +886,33 @@ func! Voom_TreeSyntax(body) "{{{2
syn match Title /\%1l.*/

let FT = getbufvar(a:body, "&ft")
if FT==#'python'
syn match Statement /^.\{-}|\zs\%(def\s\|class\s\)/
syn match Define /^.\{-}|\zs@/
syn match Comment /^.\{-}|\zs#.*/ contains=Todo
if FT==#'text'
" organizer nodes: /headline/
syn match Comment '^[^|]\+|\zs[/#].*' contains=Todo
syn keyword Todo TODO XXX FIXME
elseif FT==#'python'
syn match Statement /^[^|]\+|\zs\%(def\s\|class\s\)/
syn match Define /^[^|]\+|\zs@/
syn match Comment /^[^|]\+|\zs#.*/ contains=Todo
syn keyword Todo contained TODO XXX FIXME
elseif FT==#'vim'
syn match Statement /^.\{-}|\zs\%(fu\%[nction]\>\|def\s\|class\s\)/
syn match Comment /^.\{-}|\zs\%("\|#\).*/ contains=Todo
syn match Statement /^[^|]\+|\zs\%(fu\%[nction]\>\|def\s\|class\s\)/
syn match Comment /^[^|]\+|\zs\%("\|#\).*/ contains=Todo
syn keyword Todo contained TODO XXX FIXME
elseif FT==#'html' || FT==#'xml'
syn match Comment /^.\{-}|\zs<!.*/ contains=Todo
syn match Comment /^[^|]\+|\zs<!.*/ contains=Todo
syn keyword Todo contained TODO XXX FIXME
else
""" organizer nodes: /headline/
"syn match Directory @^.\{-}|\zs/.*@ contains=Todo
""" line comment chars: " # // /* % <!--
"syn match Comment @^.\{-}|\zs\%("\|#\|//\|/\*\|%\|<!--\).*@ contains=Todo
"syn match Directory @^[^|]\+|\zs/.*@ contains=Todo
""" line comment chars: " # // /* % ; <!--
"syn match Comment @^[^|]\+|\zs\%("\|#\|//\|/\*\|%\|<!--\).*@ contains=Todo
""" line comment chars with / (organizer nodes) instead of // and /*
syn match Comment '^.\{-}|\zs["#/%].*' contains=Todo
syn match Comment '^[^|]\+|\zs["#/%;].*' contains=Todo
syn keyword Todo TODO XXX FIXME
endif

syn match WarningMsg /^.\{-}|\zs!\+/
syn match WarningMsg /^[^|]\+|\zs!\+/

""" selected node hi, useless with folding
"syn match Pmenu /^=.\{-}|\zs.*/
Expand Down Expand Up @@ -1082,6 +1085,10 @@ vnoremap <buffer><silent> <LocalLeader>M :<C-u>call Voom_OopMark('unmark', 'v'
" mark node as selected node
nnoremap <buffer><silent> <LocalLeader>= :<C-u>call Voom_OopMarkStartup()<CR>
" select Body region
nnoremap <buffer><silent> R :<C-u>call Voom_OopSelectBodyRegion('n')<CR>
vnoremap <buffer><silent> R :<C-u>call Voom_OopSelectBodyRegion('v')<CR>
""" }}}

""" save/Restore Tree folding {{{
Expand Down Expand Up @@ -1116,7 +1123,7 @@ nnoremap <buffer><silent> <LocalLeader>e :<C-u>call Voom_Exec('')<CR>
" Can't use Ctrl: <C-i> is Tab; <C-u>, <C-d> are page up/down.
" Use <LocalLeader> instead of Ctrl.
"
" Still up for grabs: R <C-x> <C-j> <C-k> <C-p> <C-n> [ ] { }
" Still up for grabs: q <C-x> <C-j> <C-k> <C-p> <C-n> [ ] { }
endfunc


Expand Down Expand Up @@ -1579,14 +1586,48 @@ endfunc

"---Outline Operations---{{{2

func! Voom_OopSelectBodyRegion(mode) "{{{3
" Move to Body and select region corresponding to node(s) in the Tree.
let tree = bufnr('')
let body = s:voom_trees[tree]
if Voom_BufLoaded(body) < 0 | return | endif
if Voom_BufEditable(body) < 0 | return | endif
let ln = line('.')
let ln_status = Voom_FoldStatus(ln)
" current line must not be hidden in a fold
if ln_status=='hidden'
call Voom_ErrorMsg("VOoM: current line is hidden in fold")
return
endif
" normal mode: use current line
if a:mode=='n'
let [ln1, ln2] = [ln, ln]
" visual mode: use range
elseif a:mode=='v'
let [ln1, ln2] = [line("'<"), line("'>")]
endif

if Voom_ToBody(body) < 0 | return | endif
if Voom_BodyCheckTicks(body) < 0 | return | endif
" compute bln1 and bln2
python voom.voom_OopSelectBodyRegion()
" this happens when ln2==1 and the first headline is top of buffer
if l:bln2==0 | return | endif
exe 'normal! '.bln1.'Gzv'.bln2.'GzvV'.bln1.'G'
if line('w$') < bln2
normal! zt
endif
endfunc


func! Voom_OopEdit() "{{{3
" Edit headline text: move into Body, put cursor on headline.
let tree = bufnr('')
let body = s:voom_trees[tree]
if Voom_BufLoaded(body) < 0 | return | endif
if Voom_BufEditable(body) < 0 | return | endif
let lnum = line('.')
if lnum==1 | return | endif
if Voom_BufEditable(body) < 0 | return | endif

python vim.command("let l:bLnr=%s" %voom.VOOMS[int(vim.eval('l:body'))].bnodes[int(vim.eval('l:lnum'))-1])

Expand Down Expand Up @@ -1624,9 +1665,17 @@ func! Voom_OopInsert(as_child) "{{{3
endif

let lz_ = &lz | set lz
if Voom_ToBody(body) < 0 | let &lz=lz_ | return | endif
if Voom_BodyCheckTicks(body) < 0 | let &lz=lz_ | return | endif
call Voom_OopFromBody(body,tree,-1,1)
if v:version > 703 || v:version==703 && has('patch105')
if s:voom_bodies[body].tick_ != getbufvar(body,'changedtick')
if Voom_ToBody(body) < 0 | let &lz=lz_ | return | endif
if Voom_BodyCheckTicks(body) < 0 | let &lz=lz_ | return | endif
call Voom_OopFromBody(body,tree,-1,1)
endif
else
if Voom_ToBody(body) < 0 | let &lz=lz_ | return | endif
if Voom_BodyCheckTicks(body) < 0 | let &lz=lz_ | return | endif
call Voom_OopFromBody(body,tree,-1,1)
endif

setl ma
if a:as_child=='as_child'
Expand Down Expand Up @@ -1693,7 +1742,7 @@ func! Voom_OopMark(op, mode) "{{{3
let tree = bufnr('')
let body = s:voom_trees[tree]
if s:voom_bodies[body].mmode
call Voom_ErrorMsg('VOoM: marked nodes are not available in in this markup mode')
call Voom_ErrorMsg('VOoM: marked nodes are not available in this markup mode')
return
endif
if Voom_BufLoaded(body) < 0 | return | endif
Expand Down Expand Up @@ -2581,6 +2630,7 @@ func! Voom_LogSyntax() "{{{2

" VOoM messages
syn match Error /^ERROR: .*/
syn match Error /^EXCEPTION: .*/
syn match PreProc /^---end of Python script---/
syn match PreProc /^---end of Vim script---/

Expand Down
29 changes: 24 additions & 5 deletions plugin/voom/voom.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
# voom.py
# Last Modified: 2011-03-15
# VOoM (Vim Outliner of Markers) -- two-pane outliner and related utilities
# plugin for Python-enabled Vim version 7.x
# Version: 4.0b5
# Last Modified: 2011-11-03
# VOoM -- Vim two-pane outliner, plugin for Python-enabled Vim version 7.x
# Version: 4.0
# Website: http://www.vim.org/scripts/script.php?script_id=2657
# Author: Vlad Irnov (vlad DOT irnov AT gmail DOT com)
# License: This program is free software. It comes without any warranty,
Expand Down Expand Up @@ -617,7 +616,7 @@ def intersectDicts(dictsAND, dictsNOT): #{{{2
#---Outline Operations------------------------{{{1
# voom_Oop... functions are called from Voom_Oop... Vim functions.
# They use local Vim vars set by the caller and can create and change Vim vars.
# They set lines in Tree and Body via vim.buffer objects.
# Most of them set lines in Tree and Body via vim.buffer objects.
# Default l:blnShow is -1.
# Returning before setting l:blnShow means no changes were made.

Expand Down Expand Up @@ -664,6 +663,10 @@ def setClipboard(s): #{{{2
s = s.replace("'", "''")
vim.command("let @+='%s'" %s)

# TODO: failed once, empty clipboard after copy/delete >5MB outline, could
# not reproduce, probably stale system, perhaps a check for clipboard size
# is needed


def voom_OopVerify(): #{{{2
body, tree = int(vim.eval('a:body')), int(vim.eval('a:tree'))
Expand Down Expand Up @@ -713,6 +716,22 @@ def voom_OopSelEnd(): #{{{2
return z


def voom_OopSelectBodyRegion(): # {{{2
body, tree = int(vim.eval('l:body')), int(vim.eval('l:tree'))
ln1, ln2 = int(vim.eval('l:ln1')), int(vim.eval('l:ln2'))
VO = VOOMS[body]
assert VO.tree == tree
bnodes = VO.bnodes

vim.command("let l:bln1=%s" %(bnodes[ln1-1]))
if ln2==1 and len(bnodes)>1 and bnodes[1]==1:
pass
if ln2 < len(bnodes):
vim.command("let l:bln2=%s" %(bnodes[ln2]-1))
else:
vim.command("let l:bln2=line('$')")


def voom_OopInsert(as_child=False): #{{{2
body, tree = int(vim.eval('l:body')), int(vim.eval('l:tree'))
ln, ln_status = int(vim.eval('l:ln')), vim.eval('l:ln_status')
Expand Down
Loading

0 comments on commit 77883ae

Please sign in to comment.