1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-01-23 07:00:04 +08:00

refactor(org): use bundle org plugin

This commit is contained in:
wsdjeg 2022-01-15 22:22:23 +08:00
parent 0f2a73df99
commit 1470aa788a
27 changed files with 12943 additions and 1 deletions

View File

@ -9,7 +9,7 @@
function! SpaceVim#layers#lang#org#plugins() abort
let plugins = []
call add(plugins, ['SpaceVim/org-mode', {'merged' : 0}])
call add(plugins, [g:_spacevim_root_dir . 'bundle/org-mode', {'merged' : 0}])
return plugins
endfunction

1
bundle/org-mode/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
tags

View File

@ -0,0 +1,82 @@
Installation instructions for VimOrganizer v. 0.30, November 2011
=================================================================
1. Install VimOrganizer files as you would any other ftplugin, with downloaded
files going in their respective directories under your .vim (Linux/Mac)
or vimfiles (Windows) directory.
2. Run helptags on the help file in the /doc directory, vimorg.txt,
so help items can be accessed using the Vim help system.
3. Make sure your vimrc has these lines:
-------------------------------------
filetype plugin indent on
[...and then somewhere below that:]
au! BufRead,BufWrite,BufWritePost,BufNewFile *.org
au BufEnter *.org call org#SetOrgFileType()
------------------------------------
If you use VimOrganizer much you will also want to configure variables
and/or functions in your vimrc. A sample vimrc has been included
in the download.
ALSO, you will want to install the plugins listed below. VimOrganizer
will work without them, but some functionality will be unavailable:
4. Make sure you have Calendar.vim installed.
(Calendar.vim comes included in the /plugin/ directory as part of
the Vim runtime in some Vim installs, otherwise available at:
http://www.vim.org/scripts/script.php?script_id=52)
Second, here are two plugins that you will want to download to
take advantage of Org-mode-like narrowing and link features that have been built
into VimOrganizer:
5. Christian Brabandt's NarrowRegion plugin. Find and install it from here:
http://www.vim.org/scripts/script.php?script_id=3075
6. The Utl "Universal Text Linking" plugin. Find and install it from here:
http://www.vim.org/scripts/script.php?script_id=293
If you are running on Windows another plugin will be useful:
7. If you're running on Windows then you may want to get Peter Rodding's
shell.vim plugin. It's not necessary, but if you have installed
it VimOrganizer will use it to ensure that you don't see
the annoying Windows command prompt window pop up when VimOrganizer
calls out to Emacs/Org-mode.
http://www.vim.org/scripts/script.php?script_id=3123
8. FINALLY, install Emacs. Not necessary for basic outlining, agenda
searches, and other basic stuff, but it is necessary to do exports
to html and PDF (which you will definitely want) as well as other
advanced stuff. Don't be afraid, install is simply and configuration
is not hard. Find Emacs here:
http://www.gnu.org/software/emacs/
Vimorg uses a variable, g:org_command_for_emacsclient, to hold the
command that will start the emacsclient on your system. If you are
not on Linux or OSX you will need to set this explicitly in your
vimrc file.
Also, please note that emacsclient works slightly differently on
Windows and Linux/OSX systems. You must manually start
Emacs on Linux/OSX or calls to emacsclient will not work. Please see
:h vimorg-emacs-setup
For Emacs you should also install a hook function in the .emacs file,
which will automatically make minor conversions when you export and/or
open a VimOrganizer .org file in Emacs. You can find the text for that
function in the VimOrganizer help file:
:h vimorg-orgmode-conversion
If you're scared of Emacs, don't worry. You don't ever need to edit
a document using Emacs. The most you will need to do is open up
the .emacs configuration file (in Vim) to make some configuration
changes, and that is required only if you're doing more advanced stuff.
Having said, that, if there are problems it can sometimes be easiest to
open Emacs and diagnose an issue there. Still, you don't ever need
to edit a document in Emacs, just think of Emacs as your "application
server".

View File

@ -0,0 +1,7 @@
# org-mode for SpaceVim
This plugin is a fork of VimOrganizer

View File

@ -0,0 +1,113 @@
* VimOrganizer CheatSheet
** TODO Outline Navigation
:home:work:
abc
TAB cycle visibilty of single headline/subtree
Shift-TAB cycle visibility of entire outline
,1 show level 1 heads only
,2 show up to level 2 headings
...
,,3 show up to level 3 heads for current heading only
,,5 show up to level 5 heads for current heading only
. . .
** Basic Outline Editing
Name your file with a '.org' extension and then just start adding
headings with asterisks to indicate heading level. NOTE: asterisks must
be in the leftmost column and must be separated from heading text by a
space. This document is an example showing headings, subheadings,
and text underneath each.
*** Adding new headlines
**** TODO Enter, shift+Enter
add another headline of same level
<enter> works only in normal mode
**** Ctrl+Enter
add another headline of lower-level
**** DONE Ctrl+Shift+Enter
add another headline of higher-level
** TODO Time Stamps/Date-time prompt
The following commands may be issued anywhere within a headline and will
enter or edit the corresponding date for the headline. One date of
each type may be defined per headline (i.e, 'deadline', 'scheduled',
'closed', and 'regular'. You can enter more dates anywhere you want, but
this editing mechanism is currently restricted to dealing with only these
"primary" dates.
enter DEADLINE date for headline ,dd
enter SCHEDULED date for headline ,ds
enter CLOSED date for headline ,dc
enter regular date TIMESTAMP (i.e., no indicator) for headline
,dt
enter timestamp into text ,dg
The command-line prompt and calendar that appear when you enter a ,d<x>
command operate nearly the same as the date-time prompt in Emacs'
Org-mode. A few options are not yet implemented (e.g., the 'w'eek
options), but most should work just the same. For excellent documentation
on Org-mode's date-time prompt see:
:http://orgmode.org/manual/The-date_002ftime-prompt.html#The-date_002ftime-prompt
** Agenda Dashboard
Type ,ag to bring up the Agenda Dashboard, which allows you to launch
some searches.
** Set Agenda Files
Agenda files are held in a list: g:agenda_files. You can enter values for
g:agenda_files in your vimrc, e.g.,
:let g:agenda_files = ['myfile.org','c:/path/myfile.org']
You can also use Vimscript to assign multiple files at a time to
g:agenda_files. For example, putting the line below in your vimrc would
put all .org files in the org_files directory into g:agenda_files:
:let g:agenda_files = split(glob("~\desktop\org_files\*.org"),"\n")
User Interface for runtime editing of g:agenda_files:
There is a also a bare-bones agenda-editing mechanism that works like this:
(1) Put your .org working directories in list g:agenda_dirs. Mine is in my
vimrc and looks like this:
:let g:agenda_dirs=["c:/users/herbert/documents/my\ dropbox","c:/users/herbert/desktop/org_Files"]
(2) Then to edit your agenda files issue this command
:call EditAgendaFiles()
This will open a new tab and show your current agenda files along with a list
of all org files in your agenda dirs. Simply copy or move lines from the
agenda dirs list to the top and when done press :W (that's a capital 'W').
Order of agenda files is sometimes important, e.g., it is used when ordering
some agenda results.
** Tags
Tags for a file are defined using the SetupTags(<tag-setup-string>) function. There is an
example in the project's vimrc file. General structure of the
tag-setup-string is: (1) tags followed by the single-key access in parens,
(2) curly brackets (i.e., {} ) around sets of tags that are mutually exclusive.
For now you must place the single-key-access parens with character after the
tag, no letter is automatically assigned. The tags set up by SetupTags() are
used in the menu accessed by ,et .
edit tags -- ,et
view items with tag in agenda -- double-click tag,
(Note: The 'RunSearch' searches below can all be entered now
by accessing Agenda Dashboard (,ag) and pressing 'm')
view entries having both tag1 and tag2:
:call RunSearch('+tag1+tag2')
view entries having tag1 but not tag2:
:call RunSearch('+tag1-tag2')
view entries having tag1 or tag2:
:call RunSearch('+tag1|tag2')
view entries having tag1 that are also TODO:
:call RunSearch('+TODO+tag1')
view entries having tag1 that are also DONE:
:call RunSearch('+DONE+tag1')
view entries having tag1 that have any todo:
:call RunSearch('+ANY_TODO+tag1')

180
bundle/org-mode/_vimrc Normal file
View File

@ -0,0 +1,180 @@
" This is an example vimrc that should work for testing purposes.
" Integrate the VimOrganizer specific sections into your own
" vimrc if you wish to use VimOrganizer on a regular basis. . .
"===================================================================
" THE NECESSARY STUFF
" The three lines below are necessary for VimOrganizer to work right
" ==================================================================
let g:ft_ignore_pat = '\.org'
filetype plugin indent on
" and then put these lines in vimrc somewhere after the line above
au! BufRead,BufWrite,BufWritePost,BufNewFile *.org
au BufEnter *.org call org#SetOrgFileType()
" let g:org_capture_file = '~/org_files/mycaptures.org'
command! OrgCapture :call org#CaptureBuffer()
command! OrgCaptureFile :call org#OpenCaptureFile()
syntax on
"==============================================================
" THE UNNECESSARY STUFF
"==============================================================
" Everything below here is a customization. None are needed.
"==============================================================
" The variables below are used to define the default Todo list and
" default Tag list. Both of these can also be defined
" on a document-specific basis by config lines in a file.
" See :h vimorg-todo-metadata and/or :h vimorg-tag-metadata
" 'TODO | DONE' is the default, so not really necessary to define it at all
let g:org_todo_setup='TODO | DONE'
" OR, e.g.,:
"let g:org_todo_setup='TODO NEXT STARTED | DONE CANCELED'
" include a tags setup string if you want:
let g:org_tags_alist='{@home(h) @work(w) @tennisclub(t)} {easy(e) hard(d)} {computer(c) phone(p)}'
"
" g:org_agenda_dirs specify directories that, along with
" their subtrees, are searched for list of .org files when
" accessing EditAgendaFiles(). Specify your own here, otherwise
" default will be for g:org_agenda_dirs to hold single
" directory which is directory of the first .org file opened
" in current Vim instance:
" Below is line I use in my Windows install:
" NOTE: case sensitive even on windows.
let g:org_agenda_select_dirs=["~/desktop/org_files"]
let g:org_agenda_files = split(glob("~/desktop/org_files/org-mod*.org"),"\n")
" ----------------------
" Emacs setup
" ----------------------
" To use Emacs you will need to define the client. On
" Linux/OSX this is typically simple, just:
"let g:org_command_for_emacsclient = 'emacsclient'
"
" On Windows it is more complicated, and probably involves creating
" a 'soft link' to the emacsclient executable (which is 'emacsclientw')
" See :h vimorg-emacs-setup
"let g:org_command_for_emacsclient = 'c:\users\herbert\emacsclientw.exe'
" ----------------------
" Custom Agenda Searches
" ----------------------
" The assignment to g:org_custom_searches below defines searches that a
" a user can then easily access from the Org menu or the Agenda Dashboard.
" (Still need to add help on how to define them, assignment below
" is hopefully illustrative for now. . . . )
let g:org_custom_searches = [
\ { 'name':"Next week's agenda", 'type':'agenda',
\ 'agenda_date':'+1w', 'agenda_duration':'w' }
\, { 'name':"Next week's TODOS", 'type':'agenda',
\ 'agenda_date':'+1w', 'agenda_duration':'w',
\ 'spec':'+UNFINISHED_TODOS' }
\, { 'name':'Home tags', 'type':'heading_list', 'spec':'+HOME' }
\, { 'name':'Home tags', 'type':'sparse_tree', 'spec':'+HOME' }
\ ]
" --------------------------------
" Custom colors
" --------------------------------"
" OrgCustomColors() allows a user to set highlighting for particular items
function! OrgCustomColors()
" Various text item 'highlightings' below
" are the defaults. Uncomment and change a line if you
" want different highlighting for the element.
"
" Below are defaults for any TODOS you define. TODOS that
" come before the | in a definition will use 'NOTDONETODO'
" and those that come after are DONETODO
"hi! DONETODO guifg=green ctermfg=green
"hi! NOTDONETODO guifg=red ctermfg=lightred
" Heading level highlighting is done in pairs, one for the
" heading when unfolded and one for folded. Default is to make
" them the same except for the folded version being bold:
" assign OL1 pair for level 1, OL2 pair for level 2, etc.
"hi! OL1 guifg=somecolor guibg=somecolor
"hi! OL1Folded guifg=somecolor guibg=somecolor gui=bold
" Tags are lines below headings that have :colon:separated:tags:
"hi! Org_Tag guifg=lightgreen ctermfg=blue
" Lines that begin with '#+' in column 0 are config lines
"hi! Org_Config_Line guifg=darkgray ctermfg=magenta
" Drawers are :PROPERTIES: and :LOGBOOK: lines and their associated
" :END: lines
"hi! Org_Drawer guifg=pink ctermfg=magenta
"hi! Org_Drawer_Folded guifg=pink ctermfg=magenta gui=bold cterm=bold
" This applies to value names in :PROPERTIES: blocks
"hi! Org_Property_Value guifg=pink ctermfg=magenta
" Three lines below apply to different kinds of blocks
"hi! Org_Block guifg=#555555 ctermfg=magenta
"hi! Org_Src_Block guifg=#555555 ctermfg=magenta
"hi! Org_Table guifg=#888888 guibg=#333333 ctermfg=magenta
" Dates are date specs between angle brackets (<>) or square brackets ([])
"hi! Org_Date guifg=magenta ctermfg=magenta gui=underline cterm=underline
" Org_Star is used to "hide" initial asterisks in a heading
"hi! Org_Star guifg=#444444 ctermfg=darkgray
"hi! Props guifg=#ffa0a0 ctermfg=gray
" Bold, italics, underline, and code are highlights applied
" to character formatting
"hi! Org_Code guifg=darkgray gui=bold ctermfg=14
"hi! Org_Itals gui=italic guifg=#aaaaaa ctermfg=lightgray
"hi! Org_Bold gui=bold guifg=#aaaaaa ctermfg=lightgray
"hi! Org_Underline gui=underline guifg=#aaaaaa ctermfg=lightgray
"hi! Org_Lnumber guifg=#999999 ctermfg=gray
" These lines apply to links: [[link]], and [[link][link desc]]
"if has("conceal")
" hi! default linkends guifg=blue ctermfg=blue
"endif
"hi! Org_Full_Link guifg=cyan gui=underline ctermfg=lightblue cterm=underline
"hi! Org_Half_Link guifg=cyan gui=underline ctermfg=lightblue cterm=underline
" Applies to the Heading line that can be displayed in column view
"highlight OrgColumnHeadings guibg=#444444 guifg=#aaaaaa gui=underline
" Use g:org_todo_custom_highlights to set up highlighting for individual
" TODO items. Without this all todos that designate an unfinished state
" will be highlighted using NOTDONETODO highlight (see above)
" and all todos that designate a finished state will be highlighted using
" the DONETODO highlight (see above).
let g:org_todo_custom_highlights =
\ { 'NEXT': { 'guifg':'#888888', 'guibg':'#222222',
\ 'ctermfg':'gray', 'ctermbg':'darkgray'},
\ 'WAITING': { 'guifg':'#aa3388',
\ 'ctermfg':'red' } }
endfunction
" Below are two examples of Org-mode "hook" functions
" These present opportunities for end-user customization
" of how VimOrganizer works. For more info see the
" documentation for hooks in Emacs' Org-mode documentation:
" http://orgmode.org/worg/org-configs/org-hooks.php#sec-1_40
"
" These two hooks are currently the only ones enabled in
" the VimOrganizer codebase, but they are easy to add so if
" there's a particular hook you want go ahead and request it
" or look for where these hooks are implemented in
" /ftplugin/org.vim and use them as example for placing your
" own hooks in VimOrganizer:
function! Org_property_changed_functions(line,key, val)
"call confirm("prop changed: ".a:line."--key:".a:key." val:".a:val)
endfunction
function! Org_after_todo_state_change_hook(line,state1, state2)
"call confirm("changed: ".a:line."--key:".a:state1." val:".a:state2)
"call OrgConfirmDrawer("LOGBOOK")
"let str = ": - State: " . org#Pad(a:state2,10) . " from: " . Pad(a:state1,10) .
" \ ' [' . org#Timestamp() . ']'
"call append(line("."), repeat(' ',len(matchstr(getline(line(".")),'^\s*'))) . str)
endfunction

View File

@ -0,0 +1,172 @@
" calutil.vim: some calendar utilities
" Author: Charles E. Campbell, Jr.
" with modifications by Herbert Sitz for VimOrganizer
" Date: Oct 08, 2008
" Version: 3b ASTRO-ONLY
" ---------------------------------------------------------------------
if exists("loaded_calutil")
finish
endif
let g:loaded_calutil= "v3b"
if v:version < 700
echohl WarningMsg
echo "***warning*** this version of calutil needs vim 7.0"
echohl Normal
finish
endif
function! calutil#dayname(date)
return calutil#DayOfWeek(split(a:date,'-')[0],split(a:date,'-')[1],split(a:date,'-')[2],2)
endfunction
function! calutil#dow(date)
return calutil#DayOfWeek(split(a:date,'-')[0],split(a:date,'-')[1],split(a:date,'-')[2],1)
endfunction
function! calutil#jul(date)
return calutil#Cal2Jul(split(a:date,'-')[0],split(a:date,'-')[1],split(a:date,'-')[2])
endfunction
function! calutil#cal(julian)
return calutil#Jul2Cal(a:julian)
endfunction
" ---------------------------------------------------------------------
" DayOfWeek: {{{1
" Usage : call calutil#DayOfWeek(y,m,d,[0|1|2])
" g:CalUtilDayOfWeek: if 0-> integer (default)
" 1-> 3-letter English abbreviation for name of day
" 2-> English name of day
" Returns
" g:CalUtilDayOfWeek
" ---------
" 1 : 0 1 2 3 4 5 6
" 2 : Mon Tue Wed Thu Fri Sat Sun
" 3 : Monday Tuesday Wednesday Thursday Friday Saturday Sunday
fun! calutil#DayOfWeek(y,m,d,...)
if a:0 > 0
let g:CalUtilDayOfWeek= a:1
endif
let z = calutil#Cal2Jul(a:y,a:m,a:d)
if z >= 0
let z= z%7
else
let z= 7 - (-z%7)
endif
if exists("g:CalUtilDayOfWeek")
if g:CalUtilDayOfWeek == 2
let dow0="Mon"
let dow1="Tue"
let dow2="Wed"
let dow3="Thu"
let dow4="Fri"
let dow5="Sat"
let dow6="Sun"
return dow{z}
elseif g:CalUtilDayOfWeek == 3
let dow0="Monday"
let dow1="Tuesday"
let dow2="Wednesday"
let dow3="Thursday"
let dow4="Friday"
let dow5="Saturday"
let dow6="Sunday"
return dow{z}
endif
endif
return z
endfun
" ---------------------------------------------------------------------
" calutil#Cal2Jul: convert a (after 9/14/1752) Gregorian calendar date to Julian day {{{1
" (on,before " ) Julian calendar date to Julian day
" (proleptic)
fun! calutil#Cal2Jul(y,m,d)
let year = a:y
let month= a:m
let day = a:d
" there is no year zero
if year == 0
let year= -1
elseif year < 0
let year= year + 1
endif
let julday= day - 32075 +
\ 1461*(year + 4800 + (month - 14)/12)/4 +
\ 367*(month - 2 - ((month - 14)/12)*12)/12 -
\ 3*((year + 4900 + (month - 14)/12)/100)/4
" 2361221 == Sep 2, 1752, which was followed immediately by
" Sep 14, 1752 (in England). Various countries
" adopted the Gregorian calendar at different times.
if julday <= 2361221
let a = (14-month)/12
let y = year + 4800 - a
let m = month + 12*a - 3
let julday = day + (153*m + 2)/5 + y*365 + y/4 - 32083
endif
return julday
endfun
" ---------------------------------------------------------------------
" calutil#Jul2Cal: convert a Julian day to a date: {{{1
" Default year/month/day
" julday,1 julday,"ymd" year/month/day
" julday,2 julday,"mdy" month/day/year
" julday,3 julday,"dmy" day/month/year
fun! calutil#Jul2Cal(julday,...)
let julday= a:julday
if julday <= 2361221
" Proleptic Julian Calendar:
" 2361210 == Sep 2, 1752, which was followed immediately by Sep 14, 1752
" in England
let c = julday + 32082
let d = (4*c + 3)/1461
let e = c - (1461*d)/4
let m = (5*e + 2)/153
let day = e - (153*m + 2)/5 + 1
let month = m + 3 - 12*(m/10)
let year = d - 4800 + m/10
if year <= 0
" proleptic Julian Calendar: there *is* no year 0!
let year= year - 1
endif
else
" Gregorian calendar
let t1 = julday + 68569
let t2 = 4*t1/146097
let t1 = t1 - (146097*t2 + 3)/4
let yr = 4000*(t1 + 1)/1461001
let t1 = t1 - (1461*yr/4 - 31)
let mo = 80*t1/2447
let day = (t1 - 2447*mo/80)
let t1 = mo/11
let month = (mo + 2 - 12*t1)
let year = (100*(t2 - 49) + yr + t1)
endif
let month = (month<10) ? '0' . month : month
let day = (day < 10) ? '0' . day : day
if a:0 > 0
if a:1 == 1 || a:1 =~ "ymd"
return year."-".month."/".day
elseif a:1 == 2 || a:1 =~ "mdy"
return month."-".day."/".year
elseif a:1 == 3 || a:1 =~ "dmy"
return day."-".month."/".year
else
return year."-".month."/".day
endif
else
return year."-".month."-".day
endif
endfun
" ---------------------------------------------------------------------
" vim: ts=4 fdm=marker

View File

@ -0,0 +1,245 @@
" org.vim - VimOrganizer plugin for Vim
" -------------------------------------------------------------
" Version: 0.30
" Maintainer: Herbert Sitz <hesitz@gmail.com>
" Last Change: 2011 Nov 02
"
" Script: http://www.vim.org/scripts/script.php?script_id=3342
" Github page: http://github.com/hsitz/VimOrganizer
" Copyright: (c) 2010, 2011 by Herbert Sitz
" The VIM LICENSE applies to all files in the
" VimOrganizer plugin.
" (See the Vim copyright except read "VimOrganizer"
" in places where that copyright refers to "Vim".)
" http://vimdoc.sourceforge.net/htmldoc/uganda.html#license
" No warranty, express or implied.
" *** *** Use At-Your-Own-Risk *** ***
if exists("g:org_autoload_funcs")
finish
endif
let g:org_autoload_funcs=1
function! org#SetOrgFileType()
"if expand("%:e") == 'org'
"if exists("g:syntax_on") | syntax off | else | syntax enable | endif
"syntax enable
if &filetype != 'org'
execute "set filetype=org"
" if !exists('g:org_todo_setup')
" let g:org_todo_setup = 'TODO | DONE'
" endif
" if !exists('g:org_tag_setup')
" let g:org_tag_setup = '{home(h) work(w)}'
" endif
"
" call OrgProcessConfigLines()
" exec "syntax match DONETODO '" . b:v.todoDoneMatch . "' containedin=OL1,OL2,OL3,OL4,OL5,OL6"
" exec "syntax match NOTDONETODO '" . b:v.todoNotDoneMatch . "' containedin=OL1,OL2,OL3,OL4,OL5,OL6"
endif
"endif
runtime syntax/org.vim
"syntax enable
"call OrgSetColors()
endfunction
function! org#Pad(s,amt)
return a:s . repeat(' ',a:amt - len(a:s))
endfunction
function! org#Timestamp()
return strftime("%Y-%m-%d %a %H:%M")
endfunction
function! org#redir(command)
let save_a = @a
try
silent! redir @a
silent! exe a:command
redir END
finally
"let res = split(@a,"\n")
let res = @a
" restore register
let @a = save_a
return res
endtry
endfunction
function! org#GetGroupHighlight(group)
" this code was copied and modified from code posted on StackOverflow
" http://stackoverflow.com/questions/1331213/how-to-modify-existing-highlight-group-in-vim
" Redirect the output of the "hi" command into a variable
" and find the highlighting
redir => GroupDetails
try
exe "silent hi " . a:group
catch
" skip error message if no such group exists
endtry
redir END
" Resolve linked groups to find the root highlighting scheme
while GroupDetails =~ "links to"
let index = stridx(GroupDetails, "links to") + len("links to")
let LinkedGroup = strpart(GroupDetails, index + 1)
redir => GroupDetails
exe "silent hi " . LinkedGroup
redir END
endwhile
if GroupDetails ># ''
" Extract the highlighting details (the bit after "xxx")
let MatchGroups = matchlist(GroupDetails, '\<xxx\>\s\+\(.*\)')
let ExistingHighlight = MatchGroups[1] !~? 'cleared' ? MatchGroups[1] : ''
else
" Group does not exist
let ExistingHighlight = ''
endif
return ExistingHighlight
endfunction
function! org#ISODateToYWD(date)
"returns y,w,d which are iso week spec for date
let date = a:date
"let d = 1 + ((calutil#dow(date) + 4) % 7)
let d = 1 + calutil#dow(date)
let jul_nThur = calutil#jul(date) + 4 - d
let y = calutil#cal(jul_nThur)[0:3]
let julJan1 = calutil#jul(date[0:3] . '-01-01')
let w = 1 + ((jul_nThur - julJan1) / 7)
return [y,w,d]
endfunction
function! org#LocateFile(filename)
let filename = a:filename
if bufwinnr(filename) >= 0
silent execute bufwinnr(filename)."wincmd w"
else
if org#redir('tabs') =~ fnamemodify(filename, ':t')
" proceed on assumption that file is open
" if match found in tablist
let this_tab = tabpagenr()
let last_tab = tabpagenr('$')
for i in range(1 , last_tab)
exec i . 'tabn'
if bufwinnr(filename) >= 0
silent execute bufwinnr(filename)."wincmd w"
break
" if file not found then use tab drop to open new file
elseif i == last_tab
execute 'tab drop ' . filename
if (&ft != 'org') && (filename != '__Agenda__')
call org#SetOrgFileType()
endif
endif
tabn
endfor
else
exe 'tabn ' . tabpagenr('$')
execute 'tab drop ' . filename
if (&ft != 'org') && (filename != '__Agenda__')
call org#SetOrgFileType()
endif
endif
endif
if (&fdm != 'expr') && !exists('g:in_agenda_search')
set fdm=expr
set foldlevel=1
endif
endfunction
function! org#SaveLocation()
let file_loc = bufname('%') ==? '__Agenda__' ? '__Agenda__' : expand('%:p')
let g:location = [ file_loc , getpos('.') ]
endfunction
function! org#RestoreLocation()
if expand('%:p') != g:location[0]
call org#LocateFile( g:location[0] )
endif
call setpos( '.', g:location[1] )
endfunction
function! org#OpenCaptureFile()
call org#LocateFile(g:org_capture_file)
endfunction
function! org#CaptureBuffer()
if !exists('g:org_capture_file') || empty(g:org_capture_file)
echo 'Capture is not set up. Please read docs at :h vimorg-capture.'
return
endif
if bufnr('_Org_Capture_') > 0
exec 'bwipeout! ' . bufnr('_Org_Capture_')
endif
sp _Org_Capture_
autocmd BufWriteCmd <buffer> :call <SID>ProcessCapture()
"autocmd BufLeave <buffer> :bwipeout
autocmd BufUnload <buffer> :set nomodified
set nobuflisted
set ft=org
setlocal buftype=acwrite
setlocal noswapfile
command! -buffer W :call <SID>ProcessCapture()
" below is the basic template
" a first level head with date timestamp
normal ggVGd
normal i*
silent exec "normal o:<".org#Timestamp().">"
normal gg
set nomodified
startinsert!
endfunction
function! s:ProcessCapture()
"normal ggVG"xy
let curbufnr = bufnr(g:org_capture_file)
" check if capture file is already open or not
if curbufnr == -1
exe '1,$write >> ' . g:org_capture_file
bw! _Org_Capture_
else
normal ggVG"xy
bw! _Org_Capture_
call org#SaveLocation()
call org#LocateFile(g:org_capture_file)
normal G"xp
silent write
call org#RestoreLocation()
endif
exe 'bwipeout! ' . g:org_capture_file
endfunction
function! s:Pre0(s)
return repeat('0',2 - len(a:s)) . a:s
endfunction
function! org#randomData()
let date = string((2009 + org#util#random(3) - 1)).'-'.s:Pre0(org#util#random(12)).'-'.s:Pre0(org#util#random(28))
let dstring = ''
if org#util#random(3) == 3
let dstring = date. ' ' . calutil#dayname(date)
else
let dstring = date. ' ' . calutil#dayname(date).' '.s:Pre0(org#util#random(23)).':'.s:Pre0((org#util#random(12)-1)*5)
endif
if org#util#random(6) == 6
let dstring .= ' +'.org#util#random(4).['d','w','m'][org#util#random(3)-1]
endif
return '<'.dstring.'>'
"if a:date_type != ''
" call s:SetProp(a:date_type,date)
"else
" silent execute "normal A".date
"endif
endfunction

View File

@ -0,0 +1,52 @@
function! org#buffer#init()
let b:v={}
let b:v.prevlev = 0
let b:v.org_loaded=0
let b:v.lasttext_lev=''
let b:v.dateMatch = '\(\d\d\d\d-\d\d-\d\d\)'
let b:v.headMatch = '^\*\+\s'
let b:v.tableMatch = '^\(\s*|.*|\s*$\|#+TBLFM\)'
let b:v.taglineMatch = '^\s*:\S\+:\s*$'
let b:v.headMatchLevel = '^\(\*\)\{level}\s'
let b:v.propMatch = '^\s*:\s*\(PROPERTIES\)'
let b:v.propvalMatch = '^\s*:\s*\(\S*\)\s*:\s*\(\S.*\)\s*$'
let b:v.drawerMatch = '^\s*:\(PROPERTIES\|LOGBOOK\)'
let b:v.levelstars = 1
let b:v.effort=['0:05','0:10','0:15','0:30','0:45','1:00','1:30','2:00','4:00']
let b:v.tagMatch = '\(:\S*:\)\s*$'
let b:v.mytags = ['buy','home','work','URGENT']
let b:v.foldhi = ''
let b:v.org_inherited_properties = ['COLUMNS']
let b:v.org_inherited_defaults = {'CATEGORY':expand('%:t:r'),'COLUMNS':'%40ITEM %30TAGS'}
let b:v.heading_marks = []
let b:v.heading_marks_dict = {}
let b:v.chosen_agenda_heading = 0
let b:v.prop_all_dict = {}
let b:v.buf_tags_static_spec = ''
let b:v.buffer_category = ''
if !exists('g:org_agenda_default_search_spec')
let g:org_agenda_default_search_spec = 'ANY_TODO'
endif
if exists('g:global_column_defaults')
let b:v.buffer_columns = g:global_column_defaults
else
let b:v.buffer_columns = '%40ITEM %30TAGS'
endif
let b:v.last_dict_time = 0
let b:v.last_idict_time = 0
let b:v.last_idict_type = 0
let b:v.clock_to_logbook = 1
let b:v.messages = []
let b:v.global_cycle_levels_to_show=4
let b:v.src_fold=0
let b:v.foldhilines = []
let b:v.cycle_with_text=1
let b:v.foldcolors=['Normal','SparseSkip','Folded','WarningMsg','WildMenu','DiffAdd','DiffChange','Normal','Normal','Normal','Normal']
let b:v.cols = []
let b:v.basedate = strftime("%Y-%m-%d %a")
let b:v.sparse_list = []
let b:v.fold_list = []
let b:v.suppress_indent=0
let b:v.suppress_list_indent=0
endfunction

View File

@ -0,0 +1,119 @@
function! org#fold#level(line)
if g:org_folds == 0
return 0
endif
if exists('w:sparse_on')
\ && w:sparse_on
\ && (get(s:sparse_lines, a:line) == 1)
if index(b:v.sparse_list, a:line + 1) >= 0
return '<0'
endif
let sparse = index(b:v.sparse_list, a:line)
if sparse >= 0
return '>99'
endif
let sparse = index(b:v.fold_list, a:line)
if sparse >= 0
return '<0'
endif
endif
let [l:text, l:nexttext] = getline(a:line, a:line+1)
if l:text =~ '^\*\+\s'
let b:v.myAbsLevel = s:Ind(a:line)
elseif (b:v.lasttext_lev ># '') && (l:text !~ s:remstring) && (l:nexttext !~ '^\*\+\s') && (b:v.lastline == a:line - 1)
"elseif (b:v.lasttext_lev ># '') && (l:text !~ s:remstring) && (l:nexttext !~ '^\*\+\s\|^\s*:SYNOPSIS:') && (b:v.lastline == a:line - 1)
"if (b:v.lasttext_lev ># '') && (l:text !~ s:remstring) && (l:nexttext !~ '^\*\+\s') && (b:v.lastline == a:line - 1)
let b:v.lastline = a:line
return b:v.lasttext_lev
endif
let l:nextAbsLevel = s:Ind(a:line + 1)
if l:text =~ '^\*\+\s'
" we're on a heading line
let b:v.lasttext_lev = ''
"let b:v.myAbsLevel = s:Ind(a:line)
if l:nexttext =~ b:v.drawerMatch
let b:v.lev = '>' . string(b:v.myAbsLevel + 4)
elseif l:nexttext =~ s:remstring
let b:v.lev = '>' . string(b:v.myAbsLevel + 6)
elseif (l:nexttext !~ b:v.headMatch) && (a:line != line('$'))
let b:v.lev = '>' . string(b:v.myAbsLevel + 3)
elseif l:nextAbsLevel > b:v.myAbsLevel
let b:v.lev = '>' . string(b:v.myAbsLevel)
elseif l:nextAbsLevel < b:v.myAbsLevel
let b:v.lev = '<' . string(l:nextAbsLevel)
else
let b:v.lev = '<' . b:v.myAbsLevel
endif
let b:v.prevlev = b:v.myAbsLevel
else
"we have a text line
if b:v.lastline != a:line - 1 " backup to headline to get bearings
if l:text =~ b:v.drawerMatch
let b:v.prevlev = s:Ind(s:OrgPrevHead_l(a:line))
else
"don't just back up, recalc previous lines
" to set variables correctly
let prevhead = s:OrgPrevHead_l(a:line)
if prevhead == 0
" shortcircuit here, it's blank line prior to any head
return -1
endif
let b:v.prevlev = s:Ind(prevhead)
let i = prevhead
"for item in range(prevhead,a:line-1)
" call OrgFoldLevel(item)
"endfor
endif
"let b:v.prevlev = s:Ind(s:OrgPrevHead_l(a:line))
endif
if l:text =~ b:v.drawerMatch
let b:v.lev = '>' . string(b:v.prevlev + 4)
elseif (l:text =~ s:remstring)
if (getline(a:line - 1) =~ b:v.headMatch) && (l:nexttext =~ s:remstring)
let b:v.lev = string(b:v.prevlev + 5)
elseif (l:nexttext !~ s:remstring) ||
\ (l:nexttext =~ b:v.drawerMatch)
let b:v.lev = '<' . string(b:v.prevlev + 4)
else
let b:v.lev = b:v.prevlev + 4
endif
elseif l:text[0] != '#'
let b:v.lev = (b:v.prevlev + 2)
let b:v.lasttext_lev = b:v.lev
elseif b:v.src_fold
if l:text =~ '^#+begin_src'
let b:v.lev = '>' . (b:v.prevlev + 2)
elseif l:text =~ '^#+end_src'
let b:v.lev = '<' . (b:v.prevlev + 2)
endif
else
let b:v.lev = (b:v.prevlev + 2)
endif
if l:nexttext =~ '^\* '
" this is for perf reasons, closing fold
" back to zero avoids foldlevel calls sometimes
let b:v.lev = '<0'
elseif l:nexttext =~ '^\*\+\s'
let b:v.lev = '<' . string(l:nextAbsLevel)
endif
endif
let b:v.lastline = a:line
return b:v.lev
endfunction
function! s:Ind(line)
" used to get level of a heading (todo : rename this function)
return 2 + (len(matchstr(getline(a:line), '^\**\s')) - 2) / b:v.levelstars
endfunction

View File

@ -0,0 +1,525 @@
" 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
" 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:is_table(line) "{{{
return a:line =~ '^\s*\%(|[^|]\+\)\+|\s*$' || s:is_separator(a:line)
endfunction "}}}
function! s:is_separator(line) "{{{
return a:line =~ '^\s*[|+]\s*--[-|+]\+'
endfunction "}}}
function! s:is_last_column(lnum, cnum) "{{{
return strpart(getline(a:lnum), a:cnum - 1) =~ '^[^|]*|\s*$'
endfunction "}}}
function! s:is_first_column(lnum, cnum) "{{{
let line = strpart(getline(a:lnum), 0, a:cnum - 1)
return line =~ '^\s*|[^|]*$' || line =~ '^\s*$'
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 first_cell = "| |"
let cell = " |"
let row = first_cell
for c in range(a:cols - 1)
let row .= cell
endfor
return row
endfunction "}}}
function! s:create_row_sep(cols) "{{{
let first_cell = "|---+"
let cell = "---+"
let last_cell = "---|"
if a:cols < 2
return "|---|"
endif
let row = first_cell
for c in range(a:cols - 2)
let row .= cell
endfor
let row .= last_cell
return row
endfunction "}}}
function! s:get_values(line) "{{{
return split(a:line, '\s*|\s*', 1)[1:-2]
endfunction "}}}
function! s:col_count(lnum) "{{{
let line = getline(a:lnum)
if !s:is_separator(line)
return len(split(line, '\s*|\s*', 1)[1:-2])
else
return len(split(line, '-+-', 1))
endif
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 = s:get_values(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
if s:is_separator(line)
let sep = '[+|]'
else
let sep = '|'
endif
let curs_pos = col('.')
let mpos = match(line, '|', 0)
let col = -1
while mpos < curs_pos && mpos != -1
let mpos = match(line, sep, 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 = '|'
let cells = s:get_values(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]).'|'
endfor
let idx = len(cells)
while idx < len(a:max_lens)
let new_line .= s:fmt_cell('', a:max_lens[idx]).'|'
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 sep = '|'
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 sep .= s:fmt_cell_sep(a:max_lens[idx]).'+'
endfor
let sep = substitute(sep, '+$', '|', '')
return sep
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 org#tbl#format(line('.'))\<CR>"
if a:goto_first
let cmd .= "\<ESC>0:call search('|', 'c', line('.'))\<CR>la"
else
let cmd .= "0".(col('.')-1)."lT|a"
endif
return cmd
endfunction "}}}
function! s:kbd_goto_next_row() "{{{
let cmd = "\<ESC>jt|T|a"
return cmd
endfunction "}}}
function! s:kbd_goto_prev_row() "{{{
let cmd = "\<ESC>jt|T|a"
return cmd
endfunction "}}}
function! org#tbl#next_col(last)
return s:kbd_goto_next_col(a:last)
endfunction
function! s:kbd_goto_next_col(last) "{{{
if a:last
let seps = s:count_separators_down(line('.'))
if mode() == 'n'
let cmd = seps . "j0:call search('|', 'c', line('.'))\<CR>l"
else
let cmd = "\<ESC>".seps."j0:call search('|', 'c', line('.'))\<CR>la"
endif
else
if mode() == 'n'
let cmd = ":call search('|', 'c', line('.'))\<CR>l"
else
let cmd = "\<ESC>:call search('|', 'c', line('.'))\<CR>la"
endif
endif
return cmd
endfunction "}}}
function! org#tbl#prev_col(first)
return s:kbd_goto_prev_col(a:first)
endfunction
function! s:kbd_goto_prev_col(first) "{{{
if a:first
let seps = s:count_separators_up(line('.'))
let cmd = "\<ESC>".seps."k$:call search('|', 'b', line('.'))\<CR>la"
else
let cmd = "\<ESC>2F|la"
endif
return cmd
endfunction "}}}
"}}}
" Global functions {{{
function! org#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(s:get_values(getline(lnum)))
return s:kbd_create_new_row(cols, 0)
else
return s:kbd_goto_next_row()
endif
endfunction "}}}
function! org#tbl#kbd_tab() "{{{
let lnum = line('.')
if !s:is_table(getline(lnum))
return "\<Tab>"
endif
let last = s:is_last_column(lnum, col('.'))
if last && !s:is_table(getline(lnum+1))
let cols = len(s:get_values(getline(lnum)))
return s:kbd_create_new_row(cols, 1)
endif
return s:kbd_goto_next_col(last)
endfunction "}}}
function! org#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('.'))
if first && !s:is_table(getline(lnum-1))
return ""
endif
return s:kbd_goto_prev_col(first)
endfunction "}}}
function! org#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! org#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! org#tbl#align_or_cmd(cmd) "{{{
if s:is_table(getline('.'))
call org#tbl#format(line('.'))
else
exe 'normal! '.a:cmd
endif
endfunction "}}}
function! org#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! org#tbl#move_column_left() "{{{
if !s:is_table(getline('.'))
return
endif
let cur_col = s:cur_column()
if cur_col == -1
return
endif
if cur_col > 0
call org#tbl#format(line('.'), cur_col-1, cur_col)
call cursor(line('.'), 1)
if !s:is_separator(getline('.'))
call search('\%(|[^|]\+\)\{'.(cur_col-1).'}| .', 'eW')
else
call search('|\%([^+]\++\)\{'.(cur_col-1).'}--', 'eW')
endif
endif
endfunction "}}}
function! org#tbl#move_column_right() "{{{
if !s:is_table(getline('.'))
return
endif
let cur_col = s:cur_column()
if cur_col == -1
return
endif
if cur_col < s:col_count(line('.'))-1
call org#tbl#format(line('.'), cur_col, cur_col+1)
call cursor(line('.'), 1)
if !s:is_separator(getline('.'))
call search('\%(|[^|]\+\)\{'.(cur_col+1).'}| .', 'eW')
else
call search('|\%([^+]\++\)\{'.(cur_col+1).'}--', 'eW')
endif
endif
endfunction "}}}
function! org#tbl#get_rows(lnum) "{{{
return s:get_rows(a:lnum)
endfunction "}}}
"}}}

View File

@ -0,0 +1,7 @@
let s:NUM = SpaceVim#api#import('data#number')
function! org#util#random(range) abort
return s:NUM.random(1, a:range)
endfunction

View File

@ -0,0 +1,10 @@
function! org#windows#init()
let w:v={}
let w:v.total_columns_width = 30
let w:v.columnview = 0
let w:v.org_item_len = 100
let w:v.org_colview_list = []
let w:v.org_current_columns = ''
let w:v.org_column_item_head = ''
let w:sparse_on = 0
endfunction

View File

@ -0,0 +1,185 @@
function! s:AmtDone(lineno) dict
"use list_dict structure to calculate
"amount done for node at lineno
let mysum = 0
let mycount = 0
if (len(self[a:lineno].c) == 0) && ( get(self[a:lineno],'ckbox') )
" just check val for current line
let mysum = get(self[a:lineno],'ckval',0)
let mycount = 1
else
" sum vals for this item's immediate children
for item in self[a:lineno].c
if get(self[item],'ckbox') == 1
let mysum += (get(self[item],'ckval',' ') == 'X')
let mycount += 1
endif
endfor
endif
return [ mysum , mycount ]
endfunction
function! orgcheck#ToggleCheck()
call s:MakeListDict()
let linetext = getline(line('.'))
let curval = matchstr(linetext,' \[\zs.\ze\]')
let has_checkbox = match(linetext, '^\s* [-\+\*] \[.\]') > -1
if curval == 'X'
call s:ClearCheck()
elseif !has_checkbox
" give this list item a checkbox if it has none
let part1 = matchstr(linetext,'^\s* [-\+\*] ')
let part2 = matchstr(linetext,'^\s* [-\+\*] \zs.*')
call setline(line('.'),part1 . '[ ] ' . part2)
" need to redo dict after checkbox added
call s:MakeListDict()
else
call s:SetCheck()
endif
call s:UpdateCheckSummaries()
endfunction
function! orgcheck#UpdateSummaries()
call s:MakeListDict()
call s:UpdateCheckSummaries()
endfunction
function! s:SetCheck()
let save_pos = getpos('.')
exec 's/\[\zs.\ze\]/X/e'
let g:list_dict[line('.')].ckval = 'X'
" also set children, if any
for line in g:list_dict[line('.')].c
exec line
call s:SetCheck()
endfor
call setpos('.', save_pos)
endfunction
function! s:ClearCheck()
let save_pos = getpos('.')
exec 's/\[\zs.\ze\]/ /e'
let g:list_dict[line('.')].ckval = ' '
" also clear children, if any
for line in g:list_dict[line('.')].c
exec line
call s:ClearCheck()
endfor
call setpos('.', save_pos)
endfunction
function! s:UpdateCheckSummaries(...)
" updates summaries (i.e., (x/x)) for list checkbox
" lines from beginning of list to current line
if a:0 > 0 | let lineno = a:1 | endif
let save_pos = getpos('.')
let this_line = line('.')
func! s:CheckCompare(i1, i2)
return a:i2 - a:i1
endfunc
" get reversed list of lines
let list_lines = copy(sort(keys(g:list_dict),"s:CheckCompare"))
if a:0 > 0
call s:UpdateListLine(key)
else
for key in list_lines
call s:UpdateListLine(key)
endfor
endif
call setpos('.',save_pos)
endfunction
function! s:DoHeadingUpdate()
exec 'let lineno =<SNR>' . g:org_sid . '_OrgGetHead()'
if lineno == 0 | return | endif
exec lineno
" delete existing stats, if any
exec 's/ \[\d\+\/\d\+\]\s*$//e'
" now put new stats in
let stats = g:list_dict.AmtDone(0)
let new_summary = ' [' . stats[0] . '\/' . stats[1] . ']'
exec 's/$/' . new_summary . '/'
endfunction
function! s:UpdateListLine(key)
let key = a:key
if str2nr(key) > 0
let parent = get(g:list_dict[key], 'p', 0)
if parent > 0
call s:UpdateListLine(parent)
endif
endif
if key == 'AmtDone' | return | endif
if key == '0'
" put amtdone on heading and return
call s:DoHeadingUpdate()
return
else
exec key
endif
"delete current summary, if any
:s/\s*\[\d\+\/\d\+\]\s*$//e
" and put new summary on
let stats = g:list_dict.AmtDone(key)
let new_summary = ' [' . stats[0] . '\/' . stats[1] . ']'
if match(new_summary,'\/[01]\]') > -1 | return | endif
exec 's/$/' . new_summary . '/'
if stats[0] == 0
exec 's/\[\zs.\ze\]/ /e'
let g:list_dict[key].ckval = ' '
elseif stats[0] == stats[1]
exec 's/\[\zs.\ze\]/X/e'
let g:list_dict[key].ckval = 'X'
else
exec 's/\[\zs.\ze\]/-/e'
let g:list_dict[key].ckval = '-'
endif
endfunction
function! s:MakeListDict()
let save_pos = getpos('.')
let list_dict = {'AmtDone':function('s:AmtDone'), 0:{'c':[], 'indent':0}}
let list_pat = '^\s* [-\+\*] *'
let item_stack = [ 0 ]
let last_indent = 0
?\(^\s*$\|^\*\)?+1
while 1
let lineno = line('.')
let linetext = getline(lineno)
let start_indent = len(matchstr(linetext, list_pat))
let is_list_item = match(linetext, list_pat) > -1
let has_checkbox = match(linetext, '^\s* [-\+\*] \[.\]') > -1
if (linetext =~ '^\s*$')
break
elseif is_list_item
let list_dict[lineno] = { 'ckbox':has_checkbox, 'c':[] }
let this_indent = len(matchstr(linetext, list_pat))
let list_dict[lineno].indent = this_indent
if this_indent < start_indent
break
endif
if has_checkbox && (matchstr(linetext,'^\s* [-\+\*] [\zsX\ze') == 'X')
let list_dict[lineno].ckval = 'X'
endif
if this_indent > last_indent
let list_dict[lineno].p = item_stack[-1]
call add(list_dict[item_stack[-1]].c, lineno)
call add(item_stack, lineno)
elseif this_indent <= last_indent
while list_dict[item_stack[-1]].indent > this_indent
unlet item_stack[-1]
endwhile
let item_stack[-1] = lineno
let list_dict[lineno].p = item_stack[-2]
call add(list_dict[item_stack[-2]].c, lineno)
endif
endif
let last_indent = this_indent
exec lineno + 1
endwhile
let g:list_dict = list_dict
call setpos('.', save_pos)
endfunction

View File

@ -0,0 +1,19 @@
The vim73 patch in this directory does two things:
1. Enables level-dependent fold highlighting in Vim73.
2. Enables separate TODO highlighting in folded headings
in VimOrganizer, so TODO's stand out even when a
heading is folded.
Two versions of the Vim73 patch are included. The _46 version
is for source code downloaded from Vim.org. The _390 version
works for the Mercurial repo version as of Dec. 31, 2011.
The vim72 patch is old and only does (1) above.
If someone is using a version of Windows and wants to avoid
recompiling process you can contact me and I will send you an
executable you should be able to use on your system.
Herbert Sitz
hesitz@gmail.com

View File

@ -0,0 +1,79 @@
=== (+2,-1) src/eval.c ===
@@ -355,6 +355,7 @@
{VV_NAME("operator", VAR_STRING), VV_RO},
{VV_NAME("searchforward", VAR_NUMBER), 0},
{VV_NAME("oldfiles", VAR_LIST), 0},
+ {VV_NAME("foldhighlight", VAR_NUMBER), 0},
};
/* shorthand */
=== (+18,-9) src/screen.c ===
@@ -2179,9 +2179,17 @@
# define RL_MEMSET(p, v, l) for (ri = 0; ri < l; ++ri) \
ScreenAttrs[off + (p) + ri] = v
#endif
+ /*
+ * 4. Compose the folded-line string with 'foldtext', if set.
+ */
+ text = get_foldtext(wp, lnum, lnume, foldinfo, buf);
+
+ txtcol = col; /* remember where text starts */
/* Set all attributes of the 'number' column and the text */
- RL_MEMSET(col, hl_attr(HLF_FL), W_WIDTH(wp) - col);
+ //RL_MEMSET(col, hl_attr(HLF_FL), W_WIDTH(wp) - col);
+ RL_MEMSET(col, hl_attr(get_vim_var_nr(VV_FOLDHIGHLIGHT)), W_WIDTH(wp) - col);
+
#ifdef FEAT_SIGNS
/* If signs are being displayed, add two spaces. */
@@ -2196,10 +2204,11 @@
if (wp->w_p_rl)
/* the line number isn't reversed */
copy_text_attr(off + W_WIDTH(wp) - len - col,
- (char_u *)" ", len, hl_attr(HLF_FL));
+ (char_u *)" ", len, hl_attr(get_vim_var_nr(VV_FOLDHIGHLIGHT)));
+
else
# endif
- copy_text_attr(off + col, (char_u *)" ", len, hl_attr(HLF_FL));
+ copy_text_attr(off + col, (char_u *)" ", len, hl_attr(get_vim_var_nr(VV_FOLDHIGHLIGHT)));
col += len;
}
}
@@ -2222,10 +2231,10 @@
if (wp->w_p_rl)
/* the line number isn't reversed */
copy_text_attr(off + W_WIDTH(wp) - len - col, buf, len,
- hl_attr(HLF_FL));
+ hl_attr(get_vim_var_nr(VV_FOLDHIGHLIGHT)));
else
#endif
- copy_text_attr(off + col, buf, len, hl_attr(HLF_FL));
+ copy_text_attr(off + col, buf, len, hl_attr(get_vim_var_nr(VV_FOLDHIGHLIGHT)));
col += len;
}
}
@@ -2233,9 +2242,9 @@
/*
* 4. Compose the folded-line string with 'foldtext', if set.
*/
- text = get_foldtext(wp, lnum, lnume, foldinfo, buf);
-
- txtcol = col; /* remember where text starts */
+ //text = get_foldtext(wp, lnum, lnume, foldinfo, buf);
+// moved up above to heappen earlier h.s.
+ // txtcol = col; /* remember where text starts */
/*
* 5. move the text to current_ScreenLine. Fill up with "fill_fold".
=== (+3,-2) src/vim.h ===
@@ -1767,7 +1767,8 @@
#define VV_OP 52
#define VV_SEARCHFORWARD 53
#define VV_OLDFILES 54
-#define VV_LEN 55 /* number of v: vars */
+#define VV_FOLDHIGHLIGHT 55
+#define VV_LEN 56 /* number of v: vars */
#ifdef FEAT_CLIPBOARD

View File

@ -0,0 +1,120 @@
Common subdirectories: src/auto and patched_src/auto
diff -u src/eval.c patched_src/eval.c
--- src/eval.c 2012-01-01 16:30:50.421710297 +0100
+++ patched_src/eval.c 2012-01-01 17:12:53.261832394 +0100
@@ -360,6 +360,8 @@
{VV_NAME("searchforward", VAR_NUMBER), 0},
{VV_NAME("oldfiles", VAR_LIST), 0},
{VV_NAME("windowid", VAR_NUMBER), VV_RO},
+ {VV_NAME("foldhighlight", VAR_NUMBER), 0},
+ {VV_NAME("todohighlight", VAR_NUMBER), 0},
};
/* shorthand */
Common subdirectories: src/GvimExt and patched_src/GvimExt
Common subdirectories: src/os_mac_rsrc and patched_src/os_mac_rsrc
Common subdirectories: src/po and patched_src/po
Common subdirectories: src/proto and patched_src/proto
diff -u src/screen.c patched_src/screen.c
--- src/screen.c 2012-01-01 16:41:32.945741392 +0100
+++ patched_src/screen.c 2012-01-01 17:17:33.209845943 +0100
@@ -2214,6 +2214,9 @@
* 4. Compose the text
* 5. Add the text
* 6. set highlighting for the Visual area an other text
+ * NOTE: in patch for VimOrganizer step 4, composing text
+ * is moved up to happen as part of step 2.
+
*/
col = 0;
@@ -2271,11 +2274,16 @@
# define RL_MEMSET(p, v, l) for (ri = 0; ri < l; ++ri) \
ScreenAttrs[off + (p) + ri] = v
#endif
-
- /* Set all attributes of the 'number' or 'relativenumber' column and the
- * text */
- RL_MEMSET(col, hl_attr(HLF_FL), W_WIDTH(wp) - col);
-
+ /*
+ * 4. Compose the folded-line string with 'foldtext', if set.
+ */
+ text = get_foldtext(wp, lnum, lnume, foldinfo, buf);
+
+ txtcol = col; /* remember where text starts */
+
+ /* Set all attributes of the 'number' column and the text */
+ RL_MEMSET(col, syn_id2attr(get_vim_var_nr(VV_FOLDHIGHLIGHT)), W_WIDTH(wp) - col);
+
#ifdef FEAT_SIGNS
/* If signs are being displayed, add two spaces. */
if (draw_signcolumn(wp))
@@ -2289,10 +2297,10 @@
if (wp->w_p_rl)
/* the line number isn't reversed */
copy_text_attr(off + W_WIDTH(wp) - len - col,
- (char_u *)" ", len, hl_attr(HLF_FL));
+ (char_u *)" ", len, hl_attr(HLF_SC));
else
# endif
- copy_text_attr(off + col, (char_u *)" ", len, hl_attr(HLF_FL));
+ copy_text_attr(off + col, (char_u *)" ", len, hl_attr(HLF_SC));
col += len;
}
}
@@ -2324,20 +2332,31 @@
if (wp->w_p_rl)
/* the line number isn't reversed */
copy_text_attr(off + W_WIDTH(wp) - len - col, buf, len,
- hl_attr(HLF_FL));
+ hl_attr(HLF_N));
else
#endif
- copy_text_attr(off + col, buf, len, hl_attr(HLF_FL));
+ copy_text_attr(off + col, buf, len, hl_attr(HLF_N));
col += len;
}
}
+ /* now set attributes for vimorganizer todo word in headline, if any */
+ /* v:todohighlight is set in user's OrgFoldText() function. . . */
+ if (get_vim_var_nr(VV_TODOHIGHLIGHT) > 0 )
+ {
+ int start=0, end;
+
+ while( *(text + start) == ' ' )
+ start++;
+ end = start;
+ while( *(text + end) != ' ' )
+ end++;
+ RL_MEMSET(start+col, syn_id2attr(get_vim_var_nr(VV_TODOHIGHLIGHT)), end - start);
+ }
/*
* 4. Compose the folded-line string with 'foldtext', if set.
*/
- text = get_foldtext(wp, lnum, lnume, foldinfo, buf);
-
- txtcol = col; /* remember where text starts */
+ // moved up above to happen earlier h.s.
/*
* 5. move the text to current_ScreenLine. Fill up with "fill_fold".
Common subdirectories: src/tee and patched_src/tee
Common subdirectories: src/testdir and patched_src/testdir
diff -u src/vim.h patched_src/vim.h
--- src/vim.h 2012-01-01 16:30:51.025710325 +0100
+++ patched_src/vim.h 2012-01-01 17:18:31.933848785 +0100
@@ -1860,7 +1860,9 @@
#define VV_SEARCHFORWARD 53
#define VV_OLDFILES 54
#define VV_WINDOWID 55
-#define VV_LEN 56 /* number of v: vars */
+#define VV_FOLDHIGHLIGHT 56
+#define VV_TODOHIGHLIGHT 57
+#define VV_LEN 58 /* number of v: vars */
#ifdef FEAT_CLIPBOARD
Common subdirectories: src/VisVim and patched_src/VisVim
Common subdirectories: src/xxd and patched_src/xxd

View File

@ -0,0 +1,113 @@
diff -u ./src/eval.c ./patched_src/eval.c
--- ./src/eval.c 2010-08-09 13:12:14.000000000 -0700
+++ ./patched_src/eval.c 2011-08-24 12:45:30.990183200 -0700
@@ -362,6 +362,8 @@
{VV_NAME("operator", VAR_STRING), VV_RO},
{VV_NAME("searchforward", VAR_NUMBER), 0},
{VV_NAME("oldfiles", VAR_LIST), 0},
+ {VV_NAME("foldhighlight", VAR_NUMBER), 0},
+ {VV_NAME("todohighlight", VAR_NUMBER), 0},
};
/* shorthand */
diff -u ./src/screen.c ./patched_src/screen.c
--- ./src/screen.c 2010-08-13 06:21:27.000000000 -0700
+++ ./patched_src/screen.c 2011-10-15 04:01:17.947926300 -0700
@@ -2214,6 +2214,8 @@
* 4. Compose the text
* 5. Add the text
* 6. set highlighting for the Visual area an other text
+ * NOTE: in patch for VimOrganizer step 4, composing text
+ * is moved up to happen as part of step 2.
*/
col = 0;
@@ -2271,10 +2273,16 @@
# define RL_MEMSET(p, v, l) for (ri = 0; ri < l; ++ri) \
ScreenAttrs[off + (p) + ri] = v
#endif
+ /*
+ * 4. Compose the folded-line string with 'foldtext', if set.
+ */
+ text = get_foldtext(wp, lnum, lnume, foldinfo, buf);
+
+ txtcol = col; /* remember where text starts */
+
+ /* Set all attributes of the 'number' column and the text */
+ RL_MEMSET(col, syn_id2attr(get_vim_var_nr(VV_FOLDHIGHLIGHT)), W_WIDTH(wp) - col);
- /* Set all attributes of the 'number' or 'relativenumber' column and the
- * text */
- RL_MEMSET(col, hl_attr(HLF_FL), W_WIDTH(wp) - col);
#ifdef FEAT_SIGNS
/* If signs are being displayed, add two spaces. */
@@ -2289,10 +2297,11 @@
if (wp->w_p_rl)
/* the line number isn't reversed */
copy_text_attr(off + W_WIDTH(wp) - len - col,
- (char_u *)" ", len, hl_attr(HLF_FL));
+ (char_u *)" ", len, hl_attr(HLF_SC));
else
# endif
- copy_text_attr(off + col, (char_u *)" ", len, hl_attr(HLF_FL));
+ copy_text_attr(off + col, (char_u *)" ", len, hl_attr(HLF_SC));
+
col += len;
}
}
@@ -2324,20 +2333,35 @@
if (wp->w_p_rl)
/* the line number isn't reversed */
copy_text_attr(off + W_WIDTH(wp) - len - col, buf, len,
- hl_attr(HLF_FL));
+ hl_attr(HLF_N));
+ //syn_id2attr(get_vim_var_nr(VV_FOLDHIGHLIGHT)));
+
else
#endif
- copy_text_attr(off + col, buf, len, hl_attr(HLF_FL));
+ copy_text_attr(off + col, buf, len, hl_attr(HLF_N));
+ //copy_text_attr(off + col, buf, len, syn_id2attr(get_vim_var_nr(VV_FOLDHIGHLIGHT)));
+
col += len;
}
}
+ /* now set attributes for vimorganizer todo word in headline, if any */
+ /* v:todohighlight is set in user's OrgFoldText() function. . . */
+ if (get_vim_var_nr(VV_TODOHIGHLIGHT) > 0 )
+ {
+ int start=0, end;
+
+ while( *(text + start) == ' ' )
+ start++;
+ end = start;
+ while( *(text + end) != ' ' )
+ end++;
+ RL_MEMSET(start+col, syn_id2attr(get_vim_var_nr(VV_TODOHIGHLIGHT)), end - start);
+ }
/*
* 4. Compose the folded-line string with 'foldtext', if set.
*/
- text = get_foldtext(wp, lnum, lnume, foldinfo, buf);
-
- txtcol = col; /* remember where text starts */
+ // moved up above to happen earlier h.s.
/*
* 5. move the text to current_ScreenLine. Fill up with "fill_fold".
diff -u ./src/vim.h ./patched_src/vim.h
--- ./src/vim.h 2010-07-29 11:46:39.000000000 -0700
+++ ./patched_src/vim.h 2011-08-11 14:22:52.525545700 -0700
@@ -1842,7 +1842,9 @@
#define VV_OP 52
#define VV_SEARCHFORWARD 53
#define VV_OLDFILES 54
-#define VV_LEN 55 /* number of v: vars */
+#define VV_FOLDHIGHLIGHT 55
+#define VV_TODOHIGHLIGHT 56
+#define VV_LEN 57 /* number of v: vars */
#ifdef FEAT_CLIPBOARD

View File

@ -0,0 +1,108 @@
diff -u src-orig\eval.c src-changed\eval.c
--- src-orig\eval.c Fri Jul 05 09:23:42 2013
+++ src-changed\eval.c Tue Oct 29 13:58:08 2013
@@ -358,6 +358,8 @@
{VV_NAME("searchforward", VAR_NUMBER), 0},
{VV_NAME("oldfiles", VAR_LIST), 0},
{VV_NAME("windowid", VAR_NUMBER), VV_RO},
+ {VV_NAME("foldhighlight", VAR_NUMBER), 0},
+ {VV_NAME("todohighlight", VAR_NUMBER), 0},
};
/* shorthand */
diff -u src-orig\screen.c src-changed\screen.c
--- src-orig\screen.c Sat Jul 13 03:23:00 2013
+++ src-changed\screen.c Tue Oct 29 13:52:39 2013
@@ -2374,6 +2374,9 @@
* 4. Compose the text
* 5. Add the text
* 6. set highlighting for the Visual area an other text
+ * NOTE: in patch for VimOrganizer step 4, composing text
+ * is moved up to happen as part of step 2.
+
*/
col = 0;
@@ -2432,9 +2435,15 @@
ScreenAttrs[off + (p) + ri] = v
#endif
- /* Set all attributes of the 'number' or 'relativenumber' column and the
- * text */
- RL_MEMSET(col, hl_attr(HLF_FL), W_WIDTH(wp) - col);
+ /*
+ * 4. Compose the folded-line string with 'foldtext', if set.
+ */
+ text = get_foldtext(wp, lnum, lnume, foldinfo, buf);
+
+ txtcol = col; /* remember where text starts */
+
+ /* Set all attributes of the 'number' column and the text */
+ RL_MEMSET(col, syn_id2attr(get_vim_var_nr(VV_FOLDHIGHLIGHT)), W_WIDTH(wp) - col);
#ifdef FEAT_SIGNS
/* If signs are being displayed, add two spaces. */
@@ -2449,10 +2458,10 @@
if (wp->w_p_rl)
/* the line number isn't reversed */
copy_text_attr(off + W_WIDTH(wp) - len - col,
- (char_u *)" ", len, hl_attr(HLF_FL));
+ (char_u *)" ", len, hl_attr(HLF_SC));
else
# endif
- copy_text_attr(off + col, (char_u *)" ", len, hl_attr(HLF_FL));
+ copy_text_attr(off + col, (char_u *)" ", len, hl_attr(HLF_SC));
col += len;
}
}
@@ -2494,20 +2503,31 @@
if (wp->w_p_rl)
/* the line number isn't reversed */
copy_text_attr(off + W_WIDTH(wp) - len - col, buf, len,
- hl_attr(HLF_FL));
+ hl_attr(HLF_N));
else
#endif
- copy_text_attr(off + col, buf, len, hl_attr(HLF_FL));
+ copy_text_attr(off + col, buf, len, hl_attr(HLF_N));
col += len;
}
}
+ /* now set attributes for vimorganizer todo word in headline, if any */
+ /* v:todohighlight is set in user's OrgFoldText() function. . . */
+ if (get_vim_var_nr(VV_TODOHIGHLIGHT) > 0 )
+ {
+ int start=0, end;
+
+ while( *(text + start) == ' ' )
+ start++;
+ end = start;
+ while( *(text + end) != ' ' )
+ end++;
+ RL_MEMSET(start+col, syn_id2attr(get_vim_var_nr(VV_TODOHIGHLIGHT)), end - start);
+ }
/*
* 4. Compose the folded-line string with 'foldtext', if set.
*/
- text = get_foldtext(wp, lnum, lnume, foldinfo, buf);
-
- txtcol = col; /* remember where text starts */
+ // moved up above to happen earlier h.s.
/*
* 5. move the text to current_ScreenLine. Fill up with "fill_fold".
diff -u src-orig\vim.h src-changed\vim.h
--- src-orig\vim.h Fri Aug 02 07:02:27 2013
+++ src-changed\vim.h Tue Oct 29 13:59:29 2013
@@ -1866,7 +1866,9 @@
#define VV_SEARCHFORWARD 53
#define VV_OLDFILES 54
#define VV_WINDOWID 55
-#define VV_LEN 56 /* number of v: vars */
+#define VV_FOLDHIGHLIGHT 56
+#define VV_TODOHIGHLIGHT 57
+#define VV_LEN 58 /* number of v: vars */
#ifdef FEAT_CLIPBOARD

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,75 @@
" org.vim - VimOrganizer plugin for Vim
" -------------------------------------------------------------
" Version: 0.30
" Maintainer: Herbert Sitz <hesitz@gmail.com>
" Last Change: 2011 Nov 02
"
" Script: http://www.vim.org/scripts/script.php?script_id=3342
" Github page: http://github.com/hsitz/VimOrganizer
" Copyright: (c) 2010, 2011 by Herbert Sitz
" The VIM LICENSE applies to all files in the
" VimOrganizer plugin.
" (See the Vim copyright except read "VimOrganizer"
" in places where that copyright refers to "Vim".)
" http://vimdoc.sourceforge.net/htmldoc/uganda.html#license
" No warranty, express or implied.
" *** *** Use At-Your-Own-Risk *** ***
let mysid='<SNR>' . g:org_sid . '_'
nnoremap <silent> <buffer> <localleader>ag :call OrgAgendaDashboard()<cr>
nnoremap <silent> <buffer> <localleader>et :call OrgTagsEdit()<cr>
nnoremap <silent> <buffer> <localleader>ci :call OrgClockIn()<cr>
nnoremap <silent> <buffer> <localleader>co :call OrgClockOut()<cr>
nnoremap <silent> <buffer> <localleader>d :call OrgDateDashboard()<cr>
nnoremap <silent> <buffer> <localleader>t :call OrgTodoDashboard()<cr>
nnoremap <silent> <buffer> <localleader>a :call DoRefile(['_archive'],[line('.')])<cr>
"nnoremap <silent> <buffer> <localleader><tab> :call {mysid}ToFromAgenda()<cr>
nnoremap <silent> <buffer> <localleader><tab> :call {mysid}ToFromAgenda()<cr>
"nnoremap <silent> <buffer> q :sign unplace * | quit<cr>
nnoremap <silent> <buffer> q :call OrgQuitAgenda()<cr>
nmap <buffer> <silent> <s-CR> :call {mysid}AgendaReplaceTodo()<CR>
nmap <silent> <buffer> <c-CR> :MyAgendaToBuf<CR>
nmap <silent> <buffer> <CR> :AgendaMoveToBuf<CR>
nmap <silent> <buffer> ,r :call OrgRunCustom({'redo_num': line('.'), 'type':'tags-todo', 'spec': g:org_search_spec})<CR>
nmap <silent> <buffer> >> :call OrgAgendaDateInc('++1d')<CR>
nmap <silent> <buffer> << :call OrgAgendaDateInc('--1d')<CR>
nmap <silent> <buffer> <localleader>t :call OrgTodoDashboard()<CR>
nmap <silent> <buffer> <s-right> :silent call {mysid}AgendaReplaceTodo()<CR>
nmap <silent> <buffer> <s-left> :silent call {mysid}AgendaReplaceTodo('todo-bkwd')<CR>
nmap <silent> <buffer> <space> :call {mysid}ToggleHeadingMark(line('.'))<CR>
nmap <silent> <buffer> <c-space> :call {mysid}DeleteHeadingMarks()<CR>
nmap <silent> <buffer> ,R :call OrgRefileDashboard()<CR>
nmap <silent> <buffer> <tab> :call {mysid}OrgAgendaTab()<CR>
"if a:search_type ==? 'agenda_todo'
" nmap <buffer> r :call OrgRunSearch(g:org_search_spec,'agenda_todo')<cr>
"endif
" lines below are from date searches
nmap <silent> <buffer> v. :call OrgRunCustom({'redo_num': line('.'), 'type':'agenda', 'agenda_date': strftime("%Y-%m-%d"), 'agenda_duration':'d', 'spec': g:org_search_spec})<CR>
nmap <silent> <buffer> vd :call OrgRunCustom({'redo_num': line('.'), 'type':'agenda', 'agenda_date': g:agenda_startdate, 'agenda_duration':'d', 'spec': g:org_search_spec})<CR>
nmap <silent> <buffer> vw :call OrgRunCustom({'redo_num': line('.'), 'type':'agenda', 'agenda_date': g:agenda_startdate, 'agenda_duration':'w', 'spec': g:org_search_spec})<CR>
nmap <silent> <buffer> vm :call OrgRunCustom({'redo_num': line('.'), 'type':'agenda', 'agenda_date': g:agenda_startdate, 'agenda_duration':'m', 'spec': g:org_search_spec})<CR>
nmap <silent> <buffer> vy :call OrgRunCustom({'redo_num': line('.'), 'type':'agenda', 'agenda_date': g:agenda_startdate, 'agenda_duration':'y', 'spec': g:org_search_spec})<CR>
nmap <silent> <buffer> f :<C-U>call OrgAgendaMove('forward',v:count1)<cr>
nmap <silent> <buffer> b :<C-U>call OrgAgendaMove('backward',v:count1)<cr>
nmap <buffer> <silent> <tab> :call {mysid}OrgAgendaTab()<CR>
"nmap <silent> <buffer> <s-CR> :call OrgAgendaGetText(1)<CR>
nmap <silent> <buffer> r :call OrgRefreshCalendarAgenda()<CR>
function! OrgQuitAgenda()
sign unplace *
bw
call clearmatches()
let b:v.chosen_agenda_heading = 0
if bufnr('ColHeadBuffer') > -1
"main window has column headings window that
"is now showing a blank buffer line, push back up . . .
resize 100
endif
"quit
endfunction

View File

@ -0,0 +1,216 @@
" org.vim - VimOrganizer plugin for Vim
" -------------------------------------------------------------
" Version: 0.30
" Maintainer: Herbert Sitz <hesitz@gmail.com>
" Last Change: 2011 Nov 02
"
" Script: http://www.vim.org/scripts/script.php?script_id=3342
" Github page: http://github.com/hsitz/VimOrganizer
" Copyright: (c) 2010, 2011 by Herbert Sitz
" The VIM LICENSE applies to all files in the
" VimOrganizer plugin.
" (See the Vim copyright except read "VimOrganizer"
" in places where that copyright refers to "Vim".)
" http://vimdoc.sourceforge.net/htmldoc/uganda.html#license
" No warranty, express or implied.
" *** *** Use At-Your-Own-Risk *** ***
"
"Section Mappings and Endstuff
" below block of 10 or 15 maps are ones collected
" from body of doc that weren't getting assigned for docs
" oepened after initial org filetype doc
let mysid = '<SNR>' . g:org_sid . '_'
nnoremap <silent> <buffer> <tab> :call OrgCycle()<cr>
nnoremap <silent> <buffer> <s-tab> :call OrgGlobalCycle()<cr>
nnoremap <silent> <buffer> <localleader>ci :call OrgClockIn(line("."))<cr>
nnoremap <silent> <buffer> <localleader>co :call OrgClockOut()<cr>
"cnoremap <space> <C-\>e(<SID>OrgDateEdit())<CR>
" dl is for the date on the current line
noremap <buffer> <localleader>x :call OrgExportDashboard()<cr>
noremap <buffer> <localleader>d :call OrgDateDashboard()<cr>
noremap <buffer> <localleader>b :call OrgTableDashboard()<cr>
"for char in split('fnbptd12345','\zs')
" exec 'noremap <silent> <buffer> <localleader>t' . char . ' :call OrgTodoDashboard("' . char . '")<cr>'
"endfor
"for char in split('dsctg','\zs')
" exec 'noremap <silent> <buffer> <localleader>d' . char . ' :call OrgDateDashboard("' . char . '")<cr>'
"endfor
"for char in split('hlt12345','\zs')
" exec 'noremap <silent> <buffer> <localleader>m' . char . ' :call OrgColumnsDashboard("' . char . '")<cr>'
"endfor
"noremap <silent> <buffer> <localleader>dg :call OrgGenericDateEdit()<cr>
"noremap <silent> <buffer> <localleader>dt :call OrgDateEdit('TIMESTAMP')<cr>
"noremap <silent> <buffer> <localleader>dd :call OrgDateEdit('DEADLINE')<cr>
"noremap <silent> <buffer> <localleader>dc :call OrgDateEdit('CLOSED')<cr>
"noremap <silent> <buffer> <localleader>ds :call OrgDateEdit('SCHEDULED')<cr>
noremap <silent> <buffer> <localleader>a* :call OrgRunAgenda(strftime("%Y-%m-%d"),'w,'')<cr>
noremap <silent> <buffer> <localleader>aa :call OrgRunAgenda(strftime("%Y-%m-%d"),'w,'+ANY_TODO')<cr>
noremap <silent> <buffer> <localleader>at :call OrgRunAgenda(strftime("%Y-%m-%d"),'w,'+UNFINISHED_TODOS')<cr>
noremap <silent> <buffer> <localleader>ad :call OrgRunAgenda(strftime("%Y-%m-%d"),'w,'+FINISHED_TODOS')<cr>
noremap <silent> <buffer> <localleader>ag :call OrgAgendaDashboard()<cr>
noremap <silent> <buffer> <localleader>af :call OrgAgendaFilesDashboard()<cr>
noremap <silent> <buffer> <localleader>ac :call OrgCustomSearchMenu()<cr>
"command! -nargs=0 Agenda :call OrgAgendaDashboard()
nnoremap <silent> <buffer> <s-up> :call OrgDateInc(1)<CR>
nnoremap <silent> <buffer> <s-down> :call OrgDateInc(-1)<CR>
nnoremap <silent> <buffer> <2-LeftMouse> :call OrgMouseDate()<CR>
nnoremap <localleader>pl :call s:MyPopup()<cr>
"map <silent> <localleader>b :call ShowBottomCal()<cr>
nnoremap <silent> <buffer> <localleader>et :call OrgTagsEdit()<cr>
" clear search matching
nnoremap <silent> <buffer> <localleader>cs :let @/=''<cr>
noremap <buffer> <localleader>r :call OrgRefileDashboard()<cr>
noremap <buffer> <localleader>g :call {mysid}OrgGatherDashboard()<cr>
"noremap <silent> <buffer> <localleader>rh :call OrgRefile(line('.'))<cr>
"noremap <silent> <buffer> <localleader>rj :call OrgJumpToRefilePoint()<cr>
"noremap <silent> <buffer> <localleader>rx :call OrgJumpToRefilePointPersistent()<cr>
"noremap <silent> <buffer> <localleader>rs :call OrgSetRefilePoint()<cr>
"noremap <silent> <buffer> <localleader>rp :call OrgRefileToPermPoint(line('.'))<cr>
noremap <silent> <buffer> <localleader><localleader>cx :silent call orgcheck#ToggleCheck()<cr>
noremap <silent> <buffer> <localleader>v :silent call OrgEval()<cr>
noremap <buffer> <C-K> <C-]>
noremap <buffer> <C-N> <C-T>
noremap <silent> <buffer> <localleader>0 :call OrgExpandWithoutText(99999)<CR>
noremap <silent> <buffer> <localleader>9 :call OrgExpandWithoutText(9)<CR>
noremap <silent> <buffer> <localleader>8 :call OrgExpandWithoutText(8)<CR>
noremap <silent> <buffer> <localleader>7 :call OrgExpandWithoutText(7)<CR>
noremap <silent> <buffer> <localleader>6 :call OrgExpandWithoutText(6)<CR>
noremap <silent> <buffer> <localleader>5 :call OrgExpandWithoutText(5)<CR>
noremap <silent> <buffer> <localleader>4 :call OrgExpandWithoutText(4)<CR>
noremap <silent> <buffer> <localleader>3 :call OrgExpandWithoutText(3)<CR>
noremap <silent> <buffer> <localleader>2 :call OrgExpandWithoutText(2)<CR>
noremap <silent> <buffer> <localleader>1 :call OrgExpandWithoutText(1)<CR>
"noremap <silent> <buffer> <localleader><space> :call OrgExpandWithoutText(1)<CR>
"noremap <silent> <buffer> <localleader>/ :let @/='exec call OrgExpandWithoutText(1)<CR>
"noremap <silent> <buffer> <localleader>/ :let @a='/^\*\{1,' . &foldlevel . '\} .*'|call LevSearch()<cr>
nnoremap <buffer> <expr> <localleader>/ '/^\*\{1,' . &foldlevel . '\} .*'
nnoremap <buffer> <expr> <localleader>? '?^\*\{1,' . &foldlevel . '\} .*'
" set reasonable max limit of 12 for '0' command below, because it iterates
" each for each level, just assume 12 is max. . .
noremap <silent> <buffer> <localleader>,0 :call OrgShowSubs(12,0)<CR>
noremap <silent> <buffer> <localleader>,9 :call OrgShowSubs(9,0)<CR>
noremap <silent> <buffer> <localleader>,8 :call OrgShowSubs(8,0)<CR>
noremap <silent> <buffer> <localleader>,7 :call OrgShowSubs(7,0)<CR>
noremap <silent> <buffer> <localleader>,6 :call OrgShowSubs(6,0)<CR>
noremap <silent> <buffer> <localleader>,5 :call OrgShowSubs(5,0)<CR>
noremap <silent> <buffer> <localleader>,4 :call OrgShowSubs(4,0)<CR>
noremap <silent> <buffer> <localleader>,3 :call OrgShowSubs(3,0)<CR>
noremap <silent> <buffer> <localleader>,2 :call OrgShowSubs(2,0)<CR>
noremap <silent> <buffer> <localleader>,1 :call OrgShowSubs(1,0)<CR>
noremap <silent> <buffer> <localleader>,; :call OrgShowSubs(1,0)<CR>
"nnoremap <silent> <buffer> <localleader>no :call NarrowOutline(line('.'))<cr>
"nnoremap <silent> <buffer> <localleader>ns :call NarrowOutline(line('.'))<cr>
"nnoremap <silent> <buffer> <localleader>nc :call NarrowCodeBlock(line('.'))<cr>
nnoremap <silent> <buffer> <localleader>na :call NarrowCodeBlock(line('.'))<cr>
nnoremap <silent> <buffer> <localleader>m :call OrgColumnsDashboard()<cr>
" ----------------------------------------
" table commands
au InsertEnter *.org :call org#tbl#reset_tw(line("."))
au InsertLeave *.org :call org#tbl#format(line("."))
command! -buffer -nargs=* OrgTable call org#tbl#create(<f-args>)
"nnoremap <silent> <buffer> <localleader>bc :call org#tbl#create()<cr>
command! -buffer OrgTableAlignQ call org#tbl#align_or_cmd('gqq')
command! -buffer OrgTableAlignW call org#tbl#align_or_cmd('gww')
command! -buffer OrgTableMoveColumnLeft call org#tbl#move_column_left()
"nnoremap <silent> <buffer> <localleader>bl :call org#tbl#move_column_left()<cr>
command! -buffer OrgTableMoveColumnRight call org#tbl#move_column_right()
"nnoremap <silent> <buffer> <localleader>br :call org#tbl#move_column_right()<cr>
" table function mappings
inoremap <buffer> <expr> <CR> org#tbl#kbd_cr()
inoremap <expr> <buffer> <Tab> org#tbl#kbd_tab()
inoremap <expr> <buffer> <S-Tab> org#tbl#kbd_shift_tab()
nnoremap <buffer> gqq :OrgTableAlignQ<CR>
nnoremap <buffer> gww :OrgTableAlignW<CR>
"nnoremap <silent><buffer> <A-Left> <Plug>OrgTableMoveColumnLeft
nnoremap <silent><script><buffer>
\ <Plug>OrgTableMoveColumnLeft :OrgTableMoveColumnLeft<CR>
"nnoremap <silent><buffer> <A-Right> <Plug>OrgTableMoveColumnRight
nnoremap <silent><script><buffer>
\ <Plug>OrgTableMoveColumnRight :OrgTableMoveColumnRight<CR>
" -------------------------------------
imap <silent> <buffer> <s-c-CR> <c-r>=OrgNewHead('levelup',1)<CR>
imap <silent> <buffer> <c-CR> <c-r>=OrgNewHead('leveldown',1)<CR>
imap <silent> <buffer> <s-CR> <c-r>=OrgNewHead('same',1)<CR>
nnoremap <silent> <buffer> <s-c-CR> :call OrgNewHead('levelup')<CR>
nnoremap <silent> <buffer> <c-CR> :call OrgNewHead('leveldown')<CR>
nnoremap <silent> <buffer> <CR> :call OrgEnterFunc()<CR>
nnoremap <silent> <buffer> <c-left> :call OrgShowLess(line("."))<CR>
nnoremap <silent> <buffer> <c-right> :call OrgShowMore(line("."))<CR>
nnoremap <silent> <buffer> <c-a-left> :call OrgMoveLevel(line("."),'left')<CR>
nnoremap <silent> <buffer> <c-a-right> :call OrgMoveLevel(line("."),'right')<CR>
nnoremap <silent> <buffer> <c-a-up> :<C-U>call OrgMoveLevel(line("."),'up',v:count1)<CR>
nnoremap <silent> <buffer> <c-a-down> :<C-U>call OrgMoveLevel(line("."),'down',v:count1)<CR>
nnoremap <silent> <buffer> <a-end> :call OrgNavigateLevels("end")<CR>
nnoremap <silent> <buffer> <a-home> :call OrgNavigateLevels("home")<CR>
nnoremap <silent> <buffer> <a-up> :call OrgNavigateLevels("up")<CR>
nnoremap <silent> <buffer> <a-down> :call OrgNavigateLevels("down")<CR>
nnoremap <silent> <buffer> <a-left> :call OrgNavigateLevels("left")<CR>
nnoremap <silent> <buffer> <a-right> :call OrgNavigateLevels("right")<CR>
nnoremap <silent> <buffer> <localleader>le :call EditLink()<cr>
nnoremap <silent> <buffer> <localleader>lf :call FollowLink(OrgGetLink())<cr>
nnoremap <silent> <buffer> <localleader>ln :/]]<cr>
nnoremap <silent> <buffer> <localleader>lp :?]]<cr>
nnoremap <silent> <buffer> <localleader>lc :set conceallevel=3\|set concealcursor=nc<cr>
nnoremap <silent> <buffer> <localleader>la :set conceallevel=3\|set concealcursor=c<cr>
nnoremap <silent> <buffer> <localleader>lx :set conceallevel=0<cr>
"nnoremap <silent> <buffer> <localleader>,e :call OrgSingleHeadingText("expand")<CR>
"nnoremap <silent> <buffer> <localleader>,E :call OrgBodyTextOperation(1,line("$"),"expand")<CR>
"nnoremap <silent> <buffer> <localleader>,C :call OrgBodyTextOperation(1,line("$"),"collapse")<CR>
"nnoremap <silent> <buffer> <localleader>,c :call OrgSingleHeadingText("collapse")<CR>
nnoremap <silent> <buffer> zc :call OrgDoSingleFold(line("."))<CR>
nnoremap <silent> <buffer> <localleader><tab> :call {mysid}ToFromAgenda()<cr>
function! OrgIndent()
if getline(line('.')) =~ b:v.headMatch
call OrgMoveLevel(line("."),'right')
else
normal! >>
endif
endfunction
function! OrgReverseIndent()
if getline(line('.')) =~ b:v.headMatch
call OrgMoveLevel(line("."),'left')
else
normal! <<
endif
endfunction
function! OrgNaviMap(keys)
let keys = a:keys
let dir_dict = {'gj':'down', 'gk':'up', 'gh':'left','gl':'right'}
"if getline(line('.')) =~ b:v.headMatch
call OrgNavigateLevels(dir_dict[keys])
"else
" exe 'normal! ' . keys
"endif
endfunction
" below are alternate mappings for terminals, which
" don't support some of the above key combinations
"nnoremap <silent> <buffer> ,<tab> :call OrgGlobalCycle()<cr>
nnoremap <silent> <buffer> gk :call OrgNaviMap("gk")<CR>
nnoremap <silent> <buffer> gj :call OrgNaviMap("gj")<CR>
nnoremap <silent> <buffer> gh :call OrgNaviMap("gh")<CR>
nnoremap <silent> <buffer> gl :call OrgNaviMap("gl")<CR>
nnoremap <silent> <buffer> <localleader>zu :call OrgNavigateLevels("up")<CR>
nnoremap <silent> <buffer> <localleader>zd :call OrgNavigateLevels("down")<CR>
nnoremap <silent> <buffer> <localleader>zl :call OrgNavigateLevels("left")<CR>
nnoremap <silent> <buffer> <localleader>zr :call OrgNavigateLevels("right")<CR>
nnoremap <silent> <buffer> >> :call OrgIndent()<CR>
nnoremap <silent> <buffer> << :call OrgReverseIndent()<CR>
nnoremap <silent> <buffer> <localleader>zL :call OrgMoveLevel(line("."),'left')<CR>
nnoremap <silent> <buffer> <localleader>zR :call OrgMoveLevel(line("."),'right')<CR>
nnoremap <silent> <buffer> <, :<c-u>call OrgMoveLevel(line("."),'up',v:count1)<CR>
nnoremap <silent> <buffer> >. :<c-u>call OrgMoveLevel(line("."),'down',v:count1)<CR>
nnoremap <silent> <buffer> <localleader>k :<c-u>call OrgMoveLevel(line("."),'up',v:count1)<CR>
nnoremap <silent> <buffer> <localleader>j :<c-u>call OrgMoveLevel(line("."),'down',v:count1)<CR>
nnoremap <silent> <buffer> <localleader>np :call OrgNewHead('levelup')<CR>
nnoremap <silent> <buffer> <localleader>ns :call OrgNewHead('leveldown')<CR>

View File

@ -0,0 +1,262 @@
" org.vim - VimOrganizer plugin for Vim
" -------------------------------------------------------------
" Version: 0.30
" Maintainer: Herbert Sitz <hesitz@gmail.com>
" Last Change: 2011 Nov 02
"
" Script: http://www.vim.org/scripts/script.php?script_id=3342
" Github page: http://github.com/hsitz/VimOrganizer
" Copyright: (c) 2010, 2011 by Herbert Sitz
" The VIM LICENSE applies to all files in the
" VimOrganizer plugin.
" (See the Vim copyright except read "VimOrganizer"
" in places where that copyright refers to "Vim".)
" http://vimdoc.sourceforge.net/htmldoc/uganda.html#license
" No warranty, express or implied.
" *** *** Use At-Your-Own-Risk *** ***
" set indent of text lines beyond heading's left column
" 0 -- have text lines flush with their heading's left col
if !exists("g:org_indent_from_head")
let g:org_indent_from_head = 0
endif
if exists("b:did_indent") | finish
endif
let b:did_indent = 1
setlocal indentexpr=GetOrgIndent()
setlocal nolisp
setlocal nosmartindent
setlocal autoindent
"setlocal indentkeys+=},=\\item,=\\bibitem
" Only define the function once
"if exists("GetOrgIndent") | finish
"endif
function! GetOrgIndent(...)
" Find a non-blank line above the current line.
"let lnum = prevnonblank(v:lnum - 1)
let lnum = PrevNonBlank(v:lnum - 1)
" At the start of the file use zero indent.
if lnum == 0 | return 0
endif
let curline = getline(v:lnum) " current line
"let lminusone = getline(v:lnum-1)
"if b:v.last_lnum > 0) && (curline !~ '^\s*$')
" let lnum = b:v.last_lnum
" let b:v.last_lnum = 0
" endif
let ind = indent(lnum)
if b:v.suppress_list_indent == 1
let prevline = getline(lnum) " previous line
else
let prevline = getline(prevnonblank(v:lnum-1))
endif
if (curline =~ '^\s*$') && (b:v.suppress_list_indent == 1)
let b:v.suppress_list_indent = 0
let b:v.org_list_offset=0
endif
if (curline =~ '^\*\+ ')
let ind = 0
" below lines are failsafes, hopefully redundant
let b:v.suppress_list_indent=0
let b:v.suppress_indent=0
elseif curline =~ '#+begin_'
let b:v.suppress_indent=1
let ind = 0
elseif curline =~ '#+end_'
let b:v.suppress_indent=0
let ind = 0
elseif curline =~ '^#+'
let ind = 0
"elseif (curline =~ '^\s*$') && (b:v.suppress_list_indent == 1)
" \ && (len(synstack(v:lnum-1,1))>0)
" \ && (synIDattr(synstack(v:lnum-1,1)[0],'name') == 'orgList')
" let b:v.suppress_list_indent = 0
elseif b:v.suppress_indent == 1
return indent(curline)
elseif b:v.suppress_list_indent == 1
return len(matchstr(curline,'^\s*')) + b:v.org_list_offset
elseif (curline =~ '^\s*\(\d\+[.):]\|[-+] \)')
let before_ind = len(matchstr(curline,'^\s*'))
"let ind= ind
let b:v.org_list_offset = ind - before_ind
let b:v.suppress_list_indent = 1
elseif (curline =~'^\s*\d\+[).:]\s\+\S') || (curline =~'^\s*[-+\*]\s\+\S')
" if len(curline)>0
let ind = indent(curline)
" endif
elseif prevline =~ '^\*\+ '
let ind = len(matchstr(prevline,'^\*\+ ')) + g:org_indent_from_head
elseif prevline =~ '^\s*\d\+[).\]:]\s\+\S'
let ind = ind + len(matchstr(prevline,'^\s*\zs\d\+[).\]:]\s\+\ze\S'))
elseif prevline =~ '^\s*[-+\*]\s\+\S'
let ind = ind + len(matchstr(prevline,'^\s*\zs[-+\*]\s\+\ze\S'))
elseif (len(synstack(v:lnum,1))>0) && (synIDattr(synstack(v:lnum,1)[0],'name') == 'orgList')
let ind = len(matchstr(getline(v:lnum-1),'^\s*'))
endif
return ind
endfunction
function! PrevNonBlank(line)
let line = prevnonblank(a:line)
if (len(synstack(line,1))>0) && (synIDattr(synstack(line,1)[0],'name') == 'orgLisp')
execute line + 1
let line = search('^#+begin_src','nb')-1
elseif (len(synstack(line-1,1))>0) && (synIDattr(synstack(line-1,1)[0],'name') == 'orgList')
execute line - 1
let line = search('^\s*$','nb')-1
endif
return prevnonblank(line)
endfunction
function! GetTestIndent2(lnum)
" Find a non-blank line above the current line.
"let lnum = prevnonblank(a:lnum - 1)
let lnum = PrevNonBlank(a:lnum - 1)
" At the start of the file use zero indent.
if lnum == 0 | return 0
endif
let curline = getline(a:lnum) " current line
"let lminusone = getline(a:lnum-1)
"if b:v.last_lnum > 0) && (curline !~ '^\s*$')
" let lnum = b:v.last_lnum
" let b:v.last_lnum = 0
" endif
let ind = indent(lnum)
if b:v.suppress_list_indent == 1
let prevline = getline(lnum) " previous line
else
let prevline = getline(prevnonblank(a:lnum-1))
endif
if (curline =~ '^\s*$') && (b:v.suppress_list_indent == 1)
let b:v.suppress_list_indent = 0
let b:v.org_list_offset=0
endif
if (curline =~ '^\*\+ ')
let ind = 0
" below lines are failsafes, hopefully redundant
let b:v.suppress_list_indent=0
let b:v.suppress_indent=0
elseif curline =~ '#+begin_'
let b:v.suppress_indent=1
let ind = 0
elseif curline =~ '#+end_'
let b:v.suppress_indent=0
let ind = 0
"elseif (curline =~ '^\s*$') && (b:v.suppress_list_indent == 1)
" \ && (len(synstack(a:lnum-1,1))>0)
" \ && (synIDattr(synstack(a:lnum-1,1)[0],'name') == 'orgList')
" let b:v.suppress_list_indent = 0
elseif b:v.suppress_indent == 1
return indent(curline)
elseif b:v.suppress_list_indent == 1
return len(matchstr(curline,'^\s*')) + b:v.org_list_offset
elseif (curline =~ '^\s*\(\d\+[.):]\|[-+] \)')
let before_ind = len(matchstr(curline,'^\s*'))
"let ind= ind
let b:v.org_list_offset = ind - before_ind
let b:v.suppress_list_indent = 1
elseif (curline =~'^\s*\d\+[).:]\s\+\S') || (curline =~'^\s*[-+\*]\s\+\S')
" if len(curline)>0
let ind = indent(curline)
" endif
elseif prevline =~ '^\*\+ '
let ind = len(matchstr(prevline,'^\*\+ ')) + g:org_indent_from_head
elseif prevline =~ '^\s*\d\+[).\]:]\s\+\S'
let ind = ind + len(matchstr(prevline,'^\s*\zs\d\+[).\]:]\s\+\ze\S'))
elseif prevline =~ '^\s*[-+\*]\s\+\S'
let ind = ind + len(matchstr(prevline,'^\s*\zs[-+\*]\s\+\ze\S'))
elseif (len(synstack(a:lnum,1))>0) && (synIDattr(synstack(a:lnum,1)[0],'name') == 'orgList')
let ind = len(matchstr(getline(a:lnum-1),'^\s*'))
endif
return ind
endfunction
function! GetTestIndent(lnum)
" Find a non-blank line above the current line.
"let lnum = prevnonblank(a:lnum - 1)
let lnum = PrevNonBlank(a:lnum - 1)
" At the start of the file use zero indent.
if lnum == 0 | return 0
endif
let curline = getline(a:lnum) " current line
"let lminusone = getline(a:lnum-1)
"if b:v.last_lnum > 0) && (curline !~ '^\s*$')
" let lnum = b:v.last_lnum
" let b:v.last_lnum = 0
" endif
let ind = indent(lnum)
if b:v.suppress_list_indent == 1
let prevline = getline(lnum) " previous line
else
let prevline = getline(prevnonblank(v:lnum-1))
endif
if (curline =~ '^\s*$') && (b:v.suppress_list_indent == 1)
let b:v.suppress_list_indent = 0
let b:v.org_list_offset=0
endif
if (curline =~ '^\*\+ ')
let ind = 0
" below lines are failsafes, hopefully redundant
let b:v.suppress_list_indent=0
let b:v.suppress_indent=0
elseif curline =~ '#+begin_'
let b:v.suppress_indent=1
let ind = 0
elseif curline =~ '#+end_'
let b:v.suppress_indent=0
let ind = 0
"elseif (curline =~ '^\s*$') && (b:v.suppress_list_indent == 1)
" \ && (len(synstack(a:lnum-1,1))>0)
" \ && (synIDattr(synstack(a:lnum-1,1)[0],'name') == 'orgList')
" let b:v.suppress_list_indent = 0
elseif b:v.suppress_indent == 1
return indent(curline)
elseif b:v.suppress_list_indent == 1
return len(matchstr(curline,'^\s*')) + b:v.org_list_offset
elseif (curline =~ '^\s*\(\d\+[.):]\|[-+] \)')
let before_ind = len(matchstr(curline,'^\s*'))
"let ind= ind
let b:v.org_list_offset = ind - before_ind
let b:v.suppress_list_indent = 1
elseif (curline =~'^\s*\d\+[).:]\s\+\S') || (curline =~'^\s*[-+\*]\s\+\S')
" if len(curline)>0
let ind = indent(curline)
" endif
elseif prevline =~ '^\*\+ '
let ind = len(matchstr(prevline,'^\*\+ ')) + g:org_indent_from_head
elseif prevline =~ '^\s*\d\+[).\]:]\s\+\S'
let ind = ind + len(matchstr(prevline,'^\s*\zs\d\+[).\]:]\s\+\ze\S'))
elseif prevline =~ '^\s*[-+\*]\s\+\S'
let ind = ind + len(matchstr(prevline,'^\s*\zs[-+\*]\s\+\ze\S'))
endif
return ind
endfunction

130
bundle/org-mode/intro.txt Normal file
View File

@ -0,0 +1,130 @@
VimOrganizer version 0.30, November 2, 2011. Requires Vim version that
is compiled with support for folding and tabs. Conceal will
be taken advantage of if working with Vim73 supporting conceal.
(Also, I STRONGLY suggest that you apply a patch to Vim so that
folded headings can have level-dependent highlighting,
patch for Vim73 is in contrib directory of the download. If you're on
Windows contact me and I should be able to provide you with an
executable. If I hadn't been able to make Vim do this I would have
bitten the bullet and moved to Emacs, as much as I hate editing in Emacs.)
VimOrganizer is a Vim filetype plugin that attempts to clone Emacs' Org-mode.
It is currently (November 2011) in an alpha-stage, both in terms of (1) the
breadth and depth of Org-mode features it clones and (2) the stability of its
operation. It is nevertheless very usable.
Some of the ADDITIONS AND IMPROVEMENTS since previous (December 2010) version:
-- Adjusts to any colorscheme
-- Org menu in gvim.
-- "Dashboards" to assist with Date entry, Columns, Tables,
Agenda searches, and exporting.
-- VimOrganizer help file to install in Vim.
-- Better compatibility with Org-mode files. Open, edit, and save same
files in Org-mode and/or VimOrganizer with (some) of the functionality and
configuration-specific options of Org-mode supported in VimOrganizer.
-- Support for Org-mode style links (as well as use of 'Conceal' in Vim73
to hide link brackets and
descriptions)
-- Easy to use Org-like column mode, including column headings,
inherited columns, support for Org column blocks, and ability to
specify a list of custom column specs to apply in any buffer.
-- Org-like narrowing of code blocks and subtrees
-- Support for Org-like specifications of TODOS, tags, dates,
including support for Org-compatible config lines in a file.
-- Support for Org-like CATEGORIES, both in specification and in
their inherited behavior.
-- Search specification in Agenda searches is now nearly identical
to specification of searches in Org-mode.
-- User can specify list of commonly used custom agenda searches.
-- Clockin, clockout, and (when a running Emacs server is available,
clocktable block creation and updates.
-- Org-like "refiling"
-- Easy creation and editing of tables, as well as (when a running Emacs
server is available) manipulation and evaluation of tables, including
all spreadsheet functionality in Org-mode.
-- "Live" block evaluation (when a running Emacs server is available)
-- Support for nearly all the export types and export options
available in Org-mode (when running Emacs server is available)
-- Call out to an Emacs server to do "tangling" (literate programming).
-- Many bug fixes and small improvements
Org-mode, and thus VimOrganizer, is a text-editor plugin/application that can
be used for (1) keeping notes, (2) maintaining TODO lists, (3) planning
projects, and/or (4) authoring and publishing documents, including support for
literate programming and "reproducible research". Like Org-mode, VimOrganizer
does this by implementing a flexible plain-text system with a lightly
structured document format. Org-mode has been in constant development for
seven or eight years, and continues to be developed. Work on VimOrganizer is
likewise ongoing, but VimOrganizer is at present a smaller and less ambitious
project than Org-mode.
File formats and basic workflows for VimOrganizer and Org-mode are very
similar (files auto-convert as part of loading process) and VimOrganizer
actually calls out to an Emacs' Org-mode server to
implement important features, e.g., exporting to pdf format for printing.
Thus, to make full use of VimOrganizer you will want to have an Emacs'
server running alongside. In most cases this requires little knowledge of
Emacs other than how to start it up and add a few lines to the '.emacs' file,
Emacs' counterpart to Vim's '.vimrc'. (You can even edit the .emacs file in
Vim.) VimOrganizer is focused on leveraging Org-mode by accessing it via
an Emacs server, and re-implementing in Vim only what is necessary and makes
sense.
VimOrganizer also lets Vim users access Org-babel, a subproject of
Org-mode that allows execution of source-code blocks in org-format
documents. Uses for Org-babel range from writing technical research papers to
simply using a VimOrganizer document as a "language-scratchpad". Over
twenty languages are supported, including C, R, Lisp, Python, Perl, Ruby,
and others. VimOrganizer calls out to a running Emacs server for Org-babel
processing; functionality and speed are essentially the same as
when editing with Org-mode in Emacs.
VimOrganizer has a first draft of a Vim help file, but the best first step in
learning about VimOrganizer is to learn about Emacs' Org-mode. VimOrganizer
uses the same basic concepts but implements them within the context of Vim
(and with a reduced feature set). Org-mode's main documentation and
support newsgroup are found here:
Org-mode Main Manual: http://orgmode.org/manual/index.html
Org-mode Compact Guide: http://orgmode.org/guide/index.html
Org-mode support: http://news.gmane.org/gmane.emacs.orgmode
Org-babel information: http://orgmode.org/worg/org-contrib/babel/
VimOrganizer help can be found here:
https://github.com/hsitz/VimOrganizer/blob/master/doc/vimorg.txt
==========================
INSTALLATION INSTRUCTIONS
===========================
https://github.com/hsitz/VimOrganizer/blob/master/INSTALL.txt
QUESTIONS, COMMENTS, SUGGESTIONS
================================
Questions, comments, and suggestions regarding VimOrganizer are always
appreciated. The preferred place for those is in the VimOrganizer newsgroup
here:
http://groups.google.com/group/vimorganizer/topics
VimOrganizer project files are maintained at github and the version
there may be more recent than the files at vim.org:
https://github.com/hsitz/VimOrganizer
----------------------------------------------------------------
NOTE: some code from other Vim plugins has been incorporated into the
VimOrganizer script files. Do NOT download these plugins to use them
with VimOrganizer; since VimOrganizer does not call out to them in any way:
1. Charles Campbell's great calendar utilities
2. Table editing routines from Maxim Kim's excellent vimwiki plugin.
These are really quite nice (seem to be inspired by Org-mode's
own table-editing stuff) and deserve to be offered as a separate
plugin of their own, not dependent on any larger project. (If
VimOrganizer is not quite the sort of plugin you're looking for then
vimwiki may be.)
----------------------------------------------------------------
VimOrganizer page at vim.org:
http://www.vim.org/scripts/script.php?script_id=3342

View File

@ -0,0 +1,34 @@
if !exists('g:org_custom_column_options')
let g:org_custom_column_options = ['%ITEM %15DEADLINE %35TAGS', '%ITEM %35TAGS']
endif
if !exists('g:org_command_for_emacsclient') && (has('unix') || has('macunix'))
let g:org_command_for_emacsclient = 'emacsclient'
endif
if !exists('g:org_custom_colors')
let g:org_custom_colors=[]
endif
if !exists('g:org_tags_persistent_alist')
let g:org_tags_persistent_alist = ''
endif
if !exists('g:org_save_when_searched')
let g:org_save_when_searched = 0
endif
if !exists('g:org_capture_file')
let g:org_capture_file = ''
endif
if !exists('g:org_sort_with_todo_words')
let g:org_sort_with_todo_words=1
endif
if !exists('g:org_tags_alist')
let g:org_tags_alist = ''
endif
if !exists('g:org_agenda_include_clocktable')
let g:org_agenda_include_clocktable = 0
endif
if !exists('g:org_confirm_babel_evaluate')
let g:org_confirm_babel_evaluate = 0
endif
if !exists('g:org_agenda_window_position')
let g:org_agenda_window_position = 'bottom'
endif

View File

@ -0,0 +1,105 @@
" org.vim - VimOrganizer plugin for Vim
" -------------------------------------------------------------
" Version: 0.30
" Maintainer: Herbert Sitz <hesitz@gmail.com>
" Last Change: 2011 Nov 02
"
" Script: http://www.vim.org/scripts/script.php?script_id=3342
" Github page: http://github.com/hsitz/VimOrganizer
" Copyright: (c) 2010, 2011 by Herbert Sitz
" The VIM LICENSE applies to all files in the
" VimOrganizer plugin.
" (See the Vim copyright except read "VimOrganizer"
" in places where that copyright refers to "Vim".)
" http://vimdoc.sourceforge.net/htmldoc/uganda.html#license
" No warranty, express or implied.
" *** *** Use At-Your-Own-Risk *** ***
" THIS FUNC is only for variable stars per level, currently
" not exposed to users
function! s:SynStars(perlevel)
let b:levelstars = a:perlevel
exe 'syntax match OL1 +^\(*\)\{1}\s.*+ contains=stars'
exe 'syntax match OL2 +^\(*\)\{'.( 1 + 1*a:perlevel).'}\s.*+ contains=stars'
exe 'syntax match OL3 +^\(*\)\{'.(1 + 2*a:perlevel).'}\s.*+ contains=stars'
exe 'syntax match OL4 +^\(*\)\{'.(1 + 3*a:perlevel).'}\s.*+ contains=stars'
exe 'syntax match OL5 +^\(*\)\{'.(1 + 4*a:perlevel).'}\s.*+ contains=stars'
exe 'syntax match OL6 +^\(*\)\{'.(1 + 5*a:perlevel).'}\s.*+ contains=stars'
exe 'syntax match OL7 +^\(*\)\{'.(1 + 6*a:perlevel).'}\s.*+ contains=stars'
exe 'syntax match OL8 +^\(*\)\{'.(1 + 7*a:perlevel).'}\s.*+ contains=stars'
exe 'syntax match OL9 +^\(*\)\{'.(1 + 8*a:perlevel).'}\s.*+ contains=stars'
endfunction
command! ChangeSyn call <SID>SynStars(b:levelstars)
syntax match Org_Property_Value +^\s*:\S*:\ze.*+
syntax match Org_Tag +\s*:\S*:$+
syntax match Org_Drawer +^\s*:\(PROPERTIES\|LOGBOOK\|END\):\ze.*+
syntax match Org_Date +[<[]\d\d\d\d-\d\d-\d\d.\{-1,}[\]>]+
syntax match Org_Star +\*\+\*+me=e-1 containedin=OL1,OL2,OL3,OL4,OL5,OL6
syntax match Org_Table +^\s*|.\+|\s*$+ contains=Org_Full_Link,Org_Half_Link
"syntax match NEXT '\* \zsNEXT' containedin=OL1,OL2,OL3,OL4,OL5,OL6
"syntax match CANCELED '\* \zsCANCELED' containedin=OL1,OL2,OL3,OL4,OL5,OL6
"syntax match STARTED '\* \zsSTARTED' containedin=OL1,OL2,OL3,OL4,OL5,OL6
"syntax match TODO '^\*\+ \zsTODO' containedin=OL1,OL2,OL3,OL4,OL5,OL6
"syntax match DONE '\* \zsDONE' containedin=OL1,OL2,OL3,OL4,OL5,OL6
syntax match Org_Config_Line '^#+.*' containedin=Org_Block,Org_Src_Block
syntax region Org_Block start='\c^#+begin.*$' end='\c^#+end.*' keepend contains=Org_Config_Line,Org_Table
syntax region Org_Src_Block start='\c^#+begin_src.*$' end='\c^#+end.*' keepend contains=Org_Config_Line
exec "syntax match DONETODO '" . b:v.todoDoneMatch[1:] . "' containedin=OL1,OL2,OL3,OL4,OL5,OL6"
exec "syntax match NOTDONETODO '" . b:v.todoNotDoneMatch[1:] . "' containedin=OL1,OL2,OL3,OL4,OL5,OL6"
syntax match OL1 +^\(*\)\{1}\s.*+
syntax match OL2 +^\(*\)\{2}\s.*+
syntax match OL3 +^\(*\)\{3}\s.*+
syntax match OL4 +^\(*\)\{4}\s.*+
syntax match OL5 +^\(*\)\{5}\s.*+
syntax match OL6 +^\(*\)\{6}\s.*+
syntax match OL7 +^\(*\)\{7}\s.*+
syntax match OL8 +^\(*\)\{8}\s.*+
syntax match OL9 +^\(*\)\{9}\s.*+
" character highlights
syn match Org_Code '=\S.\{-}\S='
syn match Org_Itals '\(\_^\|\W\)/\zs\S[^/]\{-}\S\ze/\_W'
syn match Org_Bold '\(\_^\|\W\)\*\zs\S[^*]\{-}\S\ze\*\_W'
syn match Org_Underline '\(\_^\|\W\)_\zs\S[^_]\{-}\S\ze_\_W'
syn match Org_Lnumber '^\t*\(\d\.\)*\s\s' contained
if has("conceal")
syn region Org_Half_Link concealends matchgroup=linkends start='\[\[' end=']]' contains=FullLink
syn region Org_Full_Link concealends matchgroup=linkends start='\[\[\(.\{-1,}\)]\[' end=']]'
endif
"exec "syntax match DONETODO '" . b:v.todoDoneMatch . "' containedin=OL1,OL2,OL3,OL4,OL5,OL6"
"exec "syntax match NOTDONETODO '" . b:v.todoNotDoneMatch . "' containedin=OL1,OL2,OL3,OL4,OL5,OL6"
" ***********************************************
" section below is example for having subregions
" of code in an .org file that use syntax highlighting
" for the language in the code block itself
" not regular Org syntax highlighting.
" See Emacs' Org documentation for some details:
" http://orgmode.org/manual/Working-With-Source-Code.html#Working-With-Source-Code
" Notice that much of the functionality of
" source code blocks is for when they are exported or 'tangled'.
" VimOrganizer calls out to an Emacs server for exports (and,
" -- soon to come -- for tangling) so the functionality described
" in the Emacs Org-mode docs already exists for VimOrganizer.
"
" The example below is for Lisp, other languages could be added
" using same priciple. In addition to using context-sensitive
" syntax highlighting for code blocks, VimOrganizer will
" eventually use context-sensitive language indent-rules. . .
" ************************************************"
"let b:current_syntax=''
"unlet b:current_syntax
"syntax include @Lispcode $VIMRUNTIME/syntax/lisp.vim
"syntax region orgLisp start='^#+begin_src/semacs-lisp' end='^#+end_src$' contains=@Lispcode
"let b:current_syntax = 'combined'
"hi orgLisp gui=bold
" vim600: set foldmethod=marker foldlevel=0: