diff --git a/README.md b/README.md index 8e1bd48..517246c 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ A collection of language packs for Vim. > One to rule them all, one to find them, one to bring them all and in the darkness bind them. - It **won't affect your startup time**, as scripts are loaded only on demand\*. -- It **installs and updates 100+ times faster** than the 115 packages it consists of. +- It **installs and updates 100+ times faster** than the 116 packages it consists of. - Solid syntax and indentation support (other features skipped). Only the best language packs. - All unnecessary files are ignored (like enormous documentation from php support). - No support for esoteric languages, only most popular ones (modern too, like `slim`). @@ -110,6 +110,7 @@ If you need full functionality of any plugin, please use it directly with your p - [ocaml](https://github.com/jrk/vim-ocaml) (syntax, indent, ftplugin) - [octave](https://github.com/vim-scripts/octave.vim--) (syntax) - [opencl](https://github.com/petRUShka/vim-opencl) (syntax, indent, ftplugin) +- [org](https://github.com/jceb/vim-orgmode) (syntax, indent, ftplugin) - [perl](https://github.com/vim-perl/vim-perl) (syntax, indent, ftplugin) - [pgsql](https://github.com/exu/pgsql.vim) (syntax) - [php](https://github.com/StanAngeloff/php.vim) (syntax) diff --git a/build b/build index cadba1f..ace4120 100755 --- a/build +++ b/build @@ -219,6 +219,7 @@ PACKS=" ocaml:jrk/vim-ocaml octave:vim-scripts/octave.vim-- opencl:petRUShka/vim-opencl + org:jceb/vim-orgmode perl:vim-perl/vim-perl pgsql:exu/pgsql.vim php:StanAngeloff/php.vim diff --git a/ftdetect/polyglot.vim b/ftdetect/polyglot.vim index f19344d..a63014d 100644 --- a/ftdetect/polyglot.vim +++ b/ftdetect/polyglot.vim @@ -688,6 +688,14 @@ au! BufRead,BufNewFile *.cl set filetype=opencl augroup end endif +if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'org') == -1 + augroup filetypedetect + " org, from org.vim in jceb/vim-orgmode +autocmd BufNewFile,BufRead *.org setfiletype org +"autocmd BufNewFile,BufReadPost org:todo* setfiletype orgtodo + augroup end +endif + if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'perl') == -1 augroup filetypedetect " perl, from mason-in-html.vim in vim-perl/vim-perl diff --git a/ftplugin/org.vim b/ftplugin/org.vim new file mode 100644 index 0000000..6c7bd87 --- /dev/null +++ b/ftplugin/org.vim @@ -0,0 +1,173 @@ +if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'org') == -1 + +" org.vim -- Text outlining and task management for Vim based on Emacs' Org-Mode +" @Author : Jan Christoph Ebersbach (jceb@e-jc.de) +" @License : AGPL3 (see http://www.gnu.org/licenses/agpl.txt) +" @Created : 2010-10-03 +" @Last Modified: Tue 13. Sep 2011 20:52:57 +0200 CEST +" @Revision : 0.4 +" vi: ft=vim:tw=80:sw=4:ts=4:fdm=marker + +if v:version > 702 + if has('python3') + let s:py_version = 'python3 ' + let s:py_env = 'python3 << EOF' + elseif has('python') + let s:py_version = 'python ' + let s:py_env = 'python << EOF' + else + echoerr "Unable to start orgmode. Orgmode depends on Vim >= 7.3 with Python support complied in." + finish + endif +else + echoerr "Unable to start orgmode. Orgmode depends on Vim >= 7.3 with Python support complied in." + finish +endif + +" Init buffer for file {{{1 +if ! exists('b:did_ftplugin') + " default emacs settings + setlocal comments=fb:*,b:#,fb:- + setlocal commentstring=#\ %s + setlocal conceallevel=2 concealcursor=nc + " original emacs settings are: setlocal tabstop=6 shiftwidth=6, but because + " of checkbox indentation the following settings are used: + setlocal tabstop=6 shiftwidth=6 + if exists('g:org_tag_column') + exe 'setlocal textwidth='.g:org_tag_column + else + setlocal textwidth=77 + endif + + " expand tab for counting level of checkbox + setlocal expandtab + + " enable % for angle brackets < > + setlocal matchpairs+=<:> + + " register keybindings if they don't have been registered before + if exists("g:loaded_org") + exe s:py_version . 'ORGMODE.register_keybindings()' + endif +endif + +" Load orgmode just once {{{1 +if &cp || exists("g:loaded_org") + finish +endif +let g:loaded_org = 1 + +" Default org plugins that will be loaded (in the given order) {{{2 +if ! exists('g:org_plugins') && ! exists('b:org_plugins') + let g:org_plugins = ['ShowHide', '|', 'Navigator', 'EditStructure', 'EditCheckbox', '|', 'Hyperlinks', '|', 'Todo', 'TagsProperties', 'Date', 'Agenda', 'Misc', '|', 'Export'] +endif + +" Default org plugin settings {{{2 +" What does this do? +if ! exists('g:org_syntax_highlight_leading_stars') && ! exists('b:org_syntax_highlight_leading_stars') + let g:org_syntax_highlight_leading_stars = 1 +endif + +" setting to conceal aggresively +if ! exists('g:org_aggressive_conceal') && ! exists('b:org_aggressive_conceal') + let g:org_aggressive_conceal = 0 +endif + +" Defined in separate plugins +" Adding Behavior preference: +" 1: go into insert-mode when new heading/checkbox/plainlist added +" 0: retain original mode when new heading/checkbox/plainlist added +if ! exists('g:org_prefer_insert_mode') && ! exists('b:org_prefer_insert_mode') + let g:org_prefer_insert_mode = 1 +endif + +" Menu and document handling {{{1 +function! OrgRegisterMenu() + exe s:py_version . 'ORGMODE.register_menu()' +endfunction + +function! OrgUnregisterMenu() + exe s:py_version . 'ORGMODE.unregister_menu()' +endfunction + +function! OrgDeleteUnusedDocument(bufnr) + exe s:py_env +b = int(vim.eval('a:bufnr')) +if b in ORGMODE._documents: + del ORGMODE._documents[b] +EOF +endfunction + +" show and hide Org menu depending on the filetype +augroup orgmode + au BufEnter * :if &filetype == "org" | call OrgRegisterMenu() | endif + au BufLeave * :if &filetype == "org" | call OrgUnregisterMenu() | endif + au BufDelete * :call OrgDeleteUnusedDocument(expand('')) +augroup END + +" Start orgmode {{{1 +" Expand our path +exec s:py_env +import vim, os, sys + +for p in vim.eval("&runtimepath").split(','): + dname = os.path.join(p, "ftplugin") + if os.path.exists(os.path.join(dname, "orgmode")): + if dname not in sys.path: + sys.path.append(dname) + break + +from orgmode._vim import ORGMODE, insert_at_cursor, get_user_input, date_to_str +ORGMODE.start() + +from Date import Date +import datetime +EOF + +" 3rd Party Plugin Integration {{{1 +" * Repeat {{{2 +try + call repeat#set() +catch +endtry + +" * Tagbar {{{2 +let g:tagbar_type_org = { + \ 'ctagstype' : 'org', + \ 'kinds' : [ + \ 's:sections', + \ 'h:hyperlinks', + \ ], + \ 'sort' : 0, + \ 'deffile' : expand(':p:h') . '/org.cnf' + \ } + +" * Taglist {{{2 +if exists('g:Tlist_Ctags_Cmd') + " Pass parameters to taglist + let g:tlist_org_settings = 'org;s:section;h:hyperlinks' + let g:Tlist_Ctags_Cmd .= ' --options=' . expand(':p:h') . '/org.cnf ' +endif + +" * Calendar.vim {{{2 +fun CalendarAction(day, month, year, week, dir) + let g:org_timestamp = printf("%04d-%02d-%02d Fri", a:year, a:month, a:day) + let datetime_date = printf("datetime.date(%d, %d, %d)", a:year, a:month, a:day) + exe s:py_version . "selected_date = " . datetime_date + " get_user_input + let msg = printf("Inserting %s | Modify date", g:org_timestamp) + exe s:py_version . "modifier = get_user_input('" . msg . "')" + " change date according to user input + exe s:py_version . "newdate = Date._modify_time(selected_date, modifier)" + exe s:py_version . "newdate = date_to_str(newdate)" + " close Calendar + exe "q" + " goto previous window + exe "wincmd p" + exe s:py_version . "timestamp = '" . g:org_timestamp_template . "' % newdate" + exe s:py_version . "insert_at_cursor(timestamp)" + " restore calendar_action + let g:calendar_action = g:org_calendar_action_backup +endf + +endif diff --git a/indent/org.vim b/indent/org.vim new file mode 100644 index 0000000..9eacb3a --- /dev/null +++ b/indent/org.vim @@ -0,0 +1,137 @@ +if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'org') == -1 + +" Delete the next line to avoid the special indention of items +if !exists("g:org_indent") + let g:org_indent = 0 +endif + +setlocal foldtext=GetOrgFoldtext() +setlocal fillchars-=fold:- +setlocal fillchars+=fold:\ +setlocal foldexpr=GetOrgFolding() +setlocal foldmethod=expr +setlocal indentexpr=GetOrgIndent() +setlocal nolisp +setlocal nosmartindent +setlocal autoindent + +if has('python3') + let s:py_env = 'python3 << EOF' +else + let s:py_env = 'python << EOF' +endif + +function! GetOrgIndent() + if g:org_indent == 0 + return -1 + endif + +exe s:py_env +from orgmode._vim import indent_orgmode +indent_orgmode() +EOF + + if exists('b:indent_level') + let l:tmp = b:indent_level + unlet b:indent_level + return l:tmp + else + return -1 + endif +endfunction + +function! GetOrgFolding() + let l:mode = mode() + if l:mode == 'i' + " the cache size is limited to 3, because vim queries the current and + " both surrounding lines when the user is typing in insert mode. The + " cache is shared between GetOrgFolding and GetOrgFoldtext + if ! exists('b:org_folding_cache') + let b:org_folding_cache = {} + endif + + if has_key(b:org_folding_cache, v:lnum) + if match(b:org_folding_cache[v:lnum], '^>') == 0 && + \ match(getline(v:lnum), '^\*\+\s') != 0 + " when the user pastes text or presses enter, it happens that + " the cache starts to confuse vim's folding abilities + " these entries can safely be removed + unlet b:org_folding_cache[v:lnum] + + " the fold text cache is probably also damaged, delete it as + " well + unlet! b:org_foldtext_cache + else + return b:org_folding_cache[v:lnum] + endif + endif + + exe s:py_env +from orgmode._vim import fold_orgmode +fold_orgmode(allow_dirty=True) +EOF + else + + exe s:py_env +from orgmode._vim import fold_orgmode +fold_orgmode() +EOF + endif + + if exists('b:fold_expr') + let l:tmp = b:fold_expr + unlet b:fold_expr + if l:mode == 'i' + if ! has_key(b:org_folding_cache, v:lnum) + if len(b:org_folding_cache) > 3 + let b:org_folding_cache = {} + endif + let b:org_folding_cache[v:lnum] = l:tmp + endif + endif + return l:tmp + else + return -1 + endif +endfunction + +function! SetOrgFoldtext(text) + let b:foldtext = a:text +endfunction + +function! GetOrgFoldtext() + let l:mode = mode() + if l:mode == 'i' + " add a separate cache for fold text + if ! exists('b:org_foldtext_cache') || + \ ! has_key(b:org_foldtext_cache, 'timestamp') || + \ b:org_foldtext_cache['timestamp'] > (localtime() + 10) + let b:org_foldtext_cache = {'timestamp': localtime()} + endif + + if has_key(b:org_foldtext_cache, v:foldstart) + return b:org_foldtext_cache[v:foldstart] + endif + exe s:py_env +from orgmode._vim import fold_text +fold_text(allow_dirty=True) +EOF + else + unlet! b:org_foldtext_cache + exec s:py_env +from orgmode._vim import fold_text +fold_text() +EOF + endif + + if exists('b:foldtext') + let l:tmp = b:foldtext + unlet b:foldtext + if l:mode == 'i' + let b:org_foldtext_cache[v:foldstart] = l:tmp + endif + return l:tmp + endif +endfunction + +endif diff --git a/syntax/org.vim b/syntax/org.vim new file mode 100644 index 0000000..148e280 --- /dev/null +++ b/syntax/org.vim @@ -0,0 +1,387 @@ +if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'org') == -1 + +" Support org authoring markup as closely as possible +" (we're adding two markdown-like variants for =code= and blockquotes) +" ----------------------------------------------------------------------------- +" +" Do we use aggresive conceal? +if exists("b:org_aggressive_conceal") + let s:conceal_aggressively=b:org_aggressive_conceal +elseif exists("g:org_aggressive_conceal") + let s:conceal_aggressively=g:org_aggressive_conceal +else + let s:conceal_aggressively=0 +endif + +" Inline markup {{{1 +" *bold*, /italic/, _underline_, +strike-through+, =code=, ~verbatim~ +" Note: +" - /italic/ is rendered as reverse in most terms (works fine in gVim, though) +" - +strike-through+ doesn't work on Vim / gVim +" - the non-standard `code' markup is also supported +" - =code= and ~verbatim~ are also supported as block-level markup, see below. +" Ref: http://orgmode.org/manual/Emphasis-and-monospace.html +"syntax match org_bold /\*[^ ]*\*/ + +" FIXME: Always make org_bold syntax define before org_heading syntax +" to make sure that org_heading syntax got higher priority(help :syn-priority) than org_bold. +" If there is any other good solution, please help fix it. +" \\\\*sinuate* +if (s:conceal_aggressively == 1) + syntax region org_bold matchgroup=org_border_bold start="[^ \\]\zs\*\|\(\(^\|[^\\]\)\zs\(\\\\\)\+\)\zs\*\|\(^\|[^\\]\)\@<=\*\S\@=" end="[^ \\]\zs\*\|\(\(^\|[^\\]\)\zs\(\\\\\)\+\)\zs\*\|[^\\]\zs\*\S\@=" concealends oneline + syntax region org_italic matchgroup=org_border_ital start="[^ \\]\zs\/\|\(\(^\|[^\\]\)\zs\(\\\\\)\+\)\zs\/\|\(^\|[^\\]\)\@<=\/\S\@=" end="[^ \\]\zs\/\|\(\(^\|[^\\]\)\zs\(\\\\\)\+\)\zs\/\|[^\\]\zs\/\S\@=" concealends oneline + syntax region org_underline matchgroup=org_border_undl start="[^ \\]\zs_\|\(\(^\|[^\\]\)\zs\(\\\\\)\+\)\zs_\|\(^\|[^\\]\)\@<=_\S\@=" end="[^ \\]\zs_\|\(\(^\|[^\\]\)\zs\(\\\\\)\+\)\zs_\|[^\\]\zs_\S\@=" concealends oneline + syntax region org_code matchgroup=org_border_code start="[^ \\]\zs=\|\(\(^\|[^\\]\)\zs\(\\\\\)\+\)\zs=\|\(^\|[^\\]\)\@<==\S\@=" end="[^ \\]\zs=\|\(\(^\|[^\\]\)\zs\(\\\\\)\+\)\zs=\|[^\\]\zs=\S\@=" concealends oneline + syntax region org_code matchgroup=org_border_code start="[^ \\]\zs`\|\(\(^\|[^\\]\)\zs\(\\\\\)\+\)\zs`\|\(^\|[^\\]\)\@<=`\S\@=" end="[^ \\]\zs'\|\(\(^\|[^\\]\)\zs\(\\\\\)\+\)\zs'\|[^\\]\zs'\S\@=" concealends oneline + syntax region org_verbatim matchgroup=org_border_verb start="[^ \\]\zs\~\|\(\(^\|[^\\]\)\zs\(\\\\\)\+\)\zs\~\|\(^\|[^\\]\)\@<=\~\S\@=" end="[^ \\]\zs\~\|\(\(^\|[^\\]\)\zs\(\\\\\)\+\)\zs\~\|[^\\]\zs\~\S\@=" concealends oneline +else + syntax region org_bold start="\S\zs\*\|\*\S\@=" end="\S\zs\*\|\*\S\@=" keepend oneline + syntax region org_italic start="\S\zs\/\|\/\S\@=" end="\S\zs\/\|\/\S\@=" keepend oneline + syntax region org_underline start="\S\zs_\|_\S\@=" end="\S\zs_\|_\S\@=" keepend oneline + syntax region org_code start="\S\zs=\|=\S\@=" end="\S\zs=\|=\S\@=" keepend oneline + syntax region org_code start="\S\zs`\|`\S\@=" end="\S\zs'\|'\S\@=" keepend oneline + syntax region org_verbatim start="\S\zs\~\|\~\S\@=" end="\S\zs\~\|\~\S\@=" keepend oneline +endif + +hi def org_bold term=bold cterm=bold gui=bold +hi def org_italic term=italic cterm=italic gui=italic +hi def org_underline term=underline cterm=underline gui=underline + +if (s:conceal_aggressively == 1) + hi link org_border_bold org_bold + hi link org_border_ital org_italic + hi link org_border_undl org_underline +endif + +" Headings: {{{1 +" Load Settings: {{{2 +if !exists('g:org_heading_highlight_colors') + let g:org_heading_highlight_colors = ['Title', 'Constant', 'Identifier', 'Statement', 'PreProc', 'Type', 'Special'] +endif + +if !exists('g:org_heading_highlight_levels') + let g:org_heading_highlight_levels = len(g:org_heading_highlight_colors) +endif + +if !exists('g:org_heading_shade_leading_stars') + let g:org_heading_shade_leading_stars = 1 +endif + +" Enable Syntax HL: {{{2 +unlet! s:i s:j s:contains +let s:i = 1 +let s:j = len(g:org_heading_highlight_colors) +let s:contains = ' contains=org_timestamp,org_timestamp_inactive,org_subtask_percent,org_subtask_number,org_subtask_percent_100,org_subtask_number_all,org_list_checkbox,org_bold,org_italic,org_underline,org_code,org_verbatim' +if g:org_heading_shade_leading_stars == 1 + let s:contains = s:contains . ',org_shade_stars' + syntax match org_shade_stars /^\*\{2,\}/me=e-1 contained + hi def link org_shade_stars Ignore +else + hi clear org_shade_stars +endif + +while s:i <= g:org_heading_highlight_levels + exec 'syntax match org_heading' . s:i . ' /^\*\{' . s:i . '\}\s.*/' . s:contains + exec 'hi def link org_heading' . s:i . ' ' . g:org_heading_highlight_colors[(s:i - 1) % s:j] + let s:i += 1 +endwhile +unlet! s:i s:j s:contains + +" Todo Keywords: {{{1 +" Load Settings: {{{2 +if !exists('g:org_todo_keywords') + let g:org_todo_keywords = ['TODO', '|', 'DONE'] +endif + +if !exists('g:org_todo_keyword_faces') + let g:org_todo_keyword_faces = [] +endif + +" Enable Syntax HL: {{{2 +let s:todo_headings = '' +let s:i = 1 +while s:i <= g:org_heading_highlight_levels + if s:todo_headings == '' + let s:todo_headings = 'containedin=org_heading' . s:i + else + let s:todo_headings = s:todo_headings . ',org_heading' . s:i + endif + let s:i += 1 +endwhile +unlet! s:i + +if !exists('g:loaded_org_syntax') + let g:loaded_org_syntax = 1 + + function! OrgExtendHighlightingGroup(base_group, new_group, settings) + let l:base_hi = '' + redir => l:base_hi + silent execute 'highlight ' . a:base_group + redir END + let l:group_hi = substitute(split(l:base_hi, '\n')[0], '^' . a:base_group . '\s\+xxx', '', '') + execute 'highlight ' . a:new_group . l:group_hi . ' ' . a:settings + endfunction + + function! OrgInterpretFaces(faces) + let l:res_faces = '' + if type(a:faces) == 3 + let l:style = [] + for l:f in a:faces + let l:_f = [l:f] + if type(l:f) == 3 + let l:_f = l:f + endif + for l:g in l:_f + if type(l:g) == 1 && l:g =~ '^:' + if l:g !~ '[\t ]' + continue + endif + let l:k_v = split(l:g) + if l:k_v[0] == ':foreground' + let l:gui_color = '' + let l:found_gui_color = 0 + for l:color in split(l:k_v[1], ',') + if l:color =~ '^#' + let l:found_gui_color = 1 + let l:res_faces = l:res_faces . ' guifg=' . l:color + elseif l:color != '' + let l:gui_color = l:color + let l:res_faces = l:res_faces . ' ctermfg=' . l:color + endif + endfor + if ! l:found_gui_color && l:gui_color != '' + let l:res_faces = l:res_faces . ' guifg=' . l:gui_color + endif + elseif l:k_v[0] == ':background' + let l:gui_color = '' + let l:found_gui_color = 0 + for l:color in split(l:k_v[1], ',') + if l:color =~ '^#' + let l:found_gui_color = 1 + let l:res_faces = l:res_faces . ' guibg=' . l:color + elseif l:color != '' + let l:gui_color = l:color + let l:res_faces = l:res_faces . ' ctermbg=' . l:color + endif + endfor + if ! l:found_gui_color && l:gui_color != '' + let l:res_faces = l:res_faces . ' guibg=' . l:gui_color + endif + elseif l:k_v[0] == ':weight' || l:k_v[0] == ':slant' || l:k_v[0] == ':decoration' + if index(l:style, l:k_v[1]) == -1 + call add(l:style, l:k_v[1]) + endif + endif + elseif type(l:g) == 1 + " TODO emacs interprets the color and automatically determines + " whether it should be set as foreground or background color + let l:res_faces = l:res_faces . ' ctermfg=' . l:k_v[1] . ' guifg=' . l:k_v[1] + endif + endfor + endfor + let l:s = '' + for l:i in l:style + if l:s == '' + let l:s = l:i + else + let l:s = l:s . ','. l:i + endif + endfor + if l:s != '' + let l:res_faces = l:res_faces . ' term=' . l:s . ' cterm=' . l:s . ' gui=' . l:s + endif + elseif type(a:faces) == 1 + " TODO emacs interprets the color and automatically determines + " whether it should be set as foreground or background color + let l:res_faces = l:res_faces . ' ctermfg=' . a:faces . ' guifg=' . a:faces + endif + return l:res_faces + endfunction + + function! s:ReadTodoKeywords(keywords, todo_headings) + let l:default_group = 'Todo' + for l:i in a:keywords + if type(l:i) == 3 + call s:ReadTodoKeywords(l:i, a:todo_headings) + continue + endif + if l:i == '|' + let l:default_group = 'Question' + continue + endif + " strip access key + let l:_i = substitute(l:i, "\(.*$", "", "") + + let l:group = l:default_group + for l:j in g:org_todo_keyword_faces + if l:j[0] == l:_i + let l:group = 'org_todo_keyword_face_' . l:_i + call OrgExtendHighlightingGroup(l:default_group, l:group, OrgInterpretFaces(l:j[1])) + break + endif + endfor + silent! exec 'syntax match org_todo_keyword_' . l:_i . ' /\*\{1,\}\s\{1,\}\zs' . l:_i .'\(\s\|$\)/ ' . a:todo_headings + silent! exec 'hi def link org_todo_keyword_' . l:_i . ' ' . l:group + endfor + endfunction +endif + +call s:ReadTodoKeywords(g:org_todo_keywords, s:todo_headings) +unlet! s:todo_headings + +" Timestamps: {{{1 +"<2003-09-16 Tue> +"<2003-09-16 Sáb> +syn match org_timestamp /\(<\d\d\d\d-\d\d-\d\d \k\k\k>\)/ +"<2003-09-16 Tue 12:00> +syn match org_timestamp /\(<\d\d\d\d-\d\d-\d\d \k\k\k \d\d:\d\d>\)/ +"<2003-09-16 Tue 12:00-12:30> +syn match org_timestamp /\(<\d\d\d\d-\d\d-\d\d \k\k\k \d\d:\d\d-\d\d:\d\d>\)/ + +"<2003-09-16 Tue>--<2003-09-16 Tue> +syn match org_timestamp /\(<\d\d\d\d-\d\d-\d\d \k\k\k>--<\d\d\d\d-\d\d-\d\d \k\k\k>\)/ +"<2003-09-16 Tue 12:00>--<2003-09-16 Tue 12:00> +syn match org_timestamp /\(<\d\d\d\d-\d\d-\d\d \k\k\k \d\d:\d\d>--<\d\d\d\d-\d\d-\d\d \k\k\k \d\d:\d\d>\)/ + +syn match org_timestamp /\(<%%(diary-float.\+>\)/ + +"[2003-09-16 Tue] +syn match org_timestamp_inactive /\(\[\d\d\d\d-\d\d-\d\d \k\k\k\]\)/ +"[2003-09-16 Tue 12:00] +syn match org_timestamp_inactive /\(\[\d\d\d\d-\d\d-\d\d \k\k\k \d\d:\d\d\]\)/ + +"[2003-09-16 Tue]--[2003-09-16 Tue] +syn match org_timestamp_inactive /\(\[\d\d\d\d-\d\d-\d\d \k\k\k\]--\[\d\d\d\d-\d\d-\d\d \k\k\k\]\)/ +"[2003-09-16 Tue 12:00]--[2003-09-16 Tue 12:00] +syn match org_timestamp_inactive /\(\[\d\d\d\d-\d\d-\d\d \k\k\k \d\d:\d\d\]--\[\d\d\d\d-\d\d-\d\d \k\k\k \d\d:\d\d\]\)/ + +syn match org_timestamp_inactive /\(\[%%(diary-float.\+\]\)/ + +hi def link org_timestamp PreProc +hi def link org_timestamp_inactive Comment + +" Deadline And Schedule: {{{1 +syn match org_deadline_scheduled /^\s*\(DEADLINE\|SCHEDULED\):/ +hi def link org_deadline_scheduled PreProc + +" Tables: {{{1 +syn match org_table /^\s*|.*/ contains=org_timestamp,org_timestamp_inactive,hyperlink,org_table_separator,org_table_horizontal_line +syn match org_table_separator /\(^\s*|[-+]\+|\?\||\)/ contained +hi def link org_table_separator Type + +" Hyperlinks: {{{1 +syntax match hyperlink "\[\{2}[^][]*\(\]\[[^][]*\)\?\]\{2}" contains=hyperlinkBracketsLeft,hyperlinkURL,hyperlinkBracketsRight containedin=ALL +if (s:conceal_aggressively == 1) + syntax match hyperlinkBracketsLeft contained "\[\{2}#\?" conceal +else + syntax match hyperlinkBracketsLeft contained "\[\{2}" conceal +endif +syntax match hyperlinkURL contained "[^][]*\]\[" conceal +syntax match hyperlinkBracketsRight contained "\]\{2}" conceal +hi def link hyperlink Underlined + +" Comments: {{{1 +syntax match org_comment /^#.*/ +hi def link org_comment Comment + +" Bullet Lists: {{{1 +" Ordered Lists: +" 1. list item +" 1) list item +" a. list item +" a) list item +syn match org_list_ordered "^\s*\(\a\|\d\+\)[.)]\(\s\|$\)" nextgroup=org_list_item +hi def link org_list_ordered Identifier + +" Unordered Lists: +" - list item +" * list item +" + list item +" + and - don't need a whitespace prefix +syn match org_list_unordered "^\(\s*[-+]\|\s\+\*\)\(\s\|$\)" nextgroup=org_list_item +hi def link org_list_unordered Identifier + +" Definition Lists: +" - Term :: expl. +" 1) Term :: expl. +syntax match org_list_def /.*\s\+::/ contained +hi def link org_list_def PreProc + +syntax match org_list_item /.*$/ contained contains=org_subtask_percent,org_subtask_number,org_subtask_percent_100,org_subtask_number_all,org_list_checkbox,org_bold,org_italic,org_underline,org_code,org_verbatim,org_timestamp,org_timestamp_inactive,org_list_def +syntax match org_list_checkbox /\[[ X-]]/ contained +hi def link org_list_bullet Identifier +hi def link org_list_checkbox PreProc + +" Block Delimiters: {{{1 +syntax case ignore +syntax match org_block_delimiter /^#+BEGIN_.*/ +syntax match org_block_delimiter /^#+END_.*/ +syntax match org_key_identifier /^#+[^ ]*:/ +syntax match org_title /^#+TITLE:.*/ contains=org_key_identifier +hi def link org_block_delimiter Comment +hi def link org_key_identifier Comment +hi def link org_title Title + +" Block Markup: {{{1 +" we consider all BEGIN/END sections as 'verbatim' blocks (inc. 'quote', 'verse', 'center') +" except 'example' and 'src' which are treated as 'code' blocks. +" Note: the non-standard '>' prefix is supported for quotation lines. +" Note: the '^:.*" rule must be defined before the ':PROPERTIES:' one below. +" TODO: http://vim.wikia.com/wiki/Different_syntax_highlighting_within_regions_of_a_file +syntax match org_verbatim /^\s*>.*/ +syntax match org_code /^\s*:.*/ + +syntax region org_verbatim start="^\s*#+BEGIN_.*" end="^\s*#+END_.*" keepend contains=org_block_delimiter +syntax region org_code start="^\s*#+BEGIN_SRC" end="^\s*#+END_SRC" keepend contains=org_block_delimiter +syntax region org_code start="^\s*#+BEGIN_EXAMPLE" end="^\s*#+END_EXAMPLE" keepend contains=org_block_delimiter + +hi def link org_code String +hi def link org_verbatim String + +if (s:conceal_aggressively==1) + hi link org_border_code org_code + hi link org_border_verb org_verbatim +endif + +" Properties: {{{1 +syn region Error matchgroup=org_properties_delimiter start=/^\s*:PROPERTIES:\s*$/ end=/^\s*:END:\s*$/ contains=org_property keepend +syn match org_property /^\s*:[^\t :]\+:\s\+[^\t ]/ contained contains=org_property_value +syn match org_property_value /:\s\zs.*/ contained +hi def link org_properties_delimiter PreProc +hi def link org_property Statement +hi def link org_property_value Constant +" Break down subtasks +syntax match org_subtask_number /\[\d*\/\d*]/ contained +syntax match org_subtask_percent /\[\d*%\]/ contained +syntax match org_subtask_number_all /\[\(\d\+\)\/\1\]/ contained +syntax match org_subtask_percent_100 /\[100%\]/ contained + +hi def link org_subtask_number String +hi def link org_subtask_percent String +hi def link org_subtask_percent_100 Identifier +hi def link org_subtask_number_all Identifier + +" Plugin SyntaxRange: {{{1 +" This only works if you have SyntaxRange installed: +" https://github.com/vim-scripts/SyntaxRange + +" BEGIN_SRC +if exists('g:loaded_SyntaxRange') + call SyntaxRange#Include('#+BEGIN_SRC vim', '#+END_SRC', 'vim', 'comment') + call SyntaxRange#Include('#+BEGIN_SRC python', '#+END_SRC', 'python', 'comment') + call SyntaxRange#Include('#+BEGIN_SRC c', '#+END_SRC', 'c', 'comment') + " cpp must be below c, otherwise you get c syntax hl for cpp files + call SyntaxRange#Include('#+BEGIN_SRC cpp', '#+END_SRC', 'cpp', 'comment') + call SyntaxRange#Include('#+BEGIN_SRC ruby', '#+END_SRC', 'ruby', 'comment') + " call SyntaxRange#Include('#+BEGIN_SRC lua', '#+END_SRC', 'lua', 'comment') + " call SyntaxRange#Include('#+BEGIN_SRC lisp', '#+END_SRC', 'lisp', 'comment') + + " LaTeX + call SyntaxRange#Include('\\begin[.*]{.*}', '\\end{.*}', 'tex') + call SyntaxRange#Include('\\begin{.*}', '\\end{.*}', 'tex') + call SyntaxRange#Include('\\\[', '\\\]', 'tex') +endif + +" vi: ft=vim:tw=80:sw=4:ts=4:fdm=marker + +endif diff --git a/syntax/orgagenda.vim b/syntax/orgagenda.vim new file mode 100644 index 0000000..1f094eb --- /dev/null +++ b/syntax/orgagenda.vim @@ -0,0 +1,83 @@ +if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'org') == -1 + +" TODO do we really need a separate syntax file for the agenda? +" - Most of the stuff here is also in syntax.org +" - DRY! + +syn match org_todo_key /\[\zs[^]]*\ze\]/ +hi def link org_todo_key Identifier + +let s:todo_headings = '' +let s:i = 1 +while s:i <= g:org_heading_highlight_levels + if s:todo_headings == '' + let s:todo_headings = 'containedin=org_heading' . s:i + else + let s:todo_headings = s:todo_headings . ',org_heading' . s:i + endif + let s:i += 1 +endwhile +unlet! s:i + +if !exists('g:loaded_orgagenda_syntax') + let g:loaded_orgagenda_syntax = 1 + function! s:ReadTodoKeywords(keywords, todo_headings) + let l:default_group = 'Todo' + for l:i in a:keywords + if type(l:i) == 3 + call s:ReadTodoKeywords(l:i, a:todo_headings) + continue + endif + if l:i == '|' + let l:default_group = 'Question' + continue + endif + " strip access key + let l:_i = substitute(l:i, "\(.*$", "", "") + + let l:group = l:default_group + for l:j in g:org_todo_keyword_faces + if l:j[0] == l:_i + let l:group = 'orgtodo_todo_keyword_face_' . l:_i + call OrgExtendHighlightingGroup(l:default_group, l:group, OrgInterpretFaces(l:j[1])) + break + endif + endfor + silent! exec 'syntax match orgtodo_todo_keyword_' . l:_i . ' /' . l:_i .'/ ' . a:todo_headings + silent! exec 'hi def link orgtodo_todo_keyword_' . l:_i . ' ' . l:group + endfor + endfunction +endif + +call s:ReadTodoKeywords(g:org_todo_keywords, s:todo_headings) +unlet! s:todo_headings + +" Timestamps +"<2003-09-16 Tue> +syn match org_timestamp /\(<\d\d\d\d-\d\d-\d\d \k\k\k>\)/ +"<2003-09-16 Tue 12:00> +syn match org_timestamp /\(<\d\d\d\d-\d\d-\d\d \k\k\k \d\d:\d\d>\)/ +"<2003-09-16 Tue 12:00-12:30> +syn match org_timestamp /\(<\d\d\d\d-\d\d-\d\d \k\k\k \d\d:\d\d-\d\d:\d\d>\)/ +"<2003-09-16 Tue>--<2003-09-16 Tue> +syn match org_timestamp /\(<\d\d\d\d-\d\d-\d\d \k\k\k>--<\d\d\d\d-\d\d-\d\d \k\k\k>\)/ +"<2003-09-16 Tue 12:00>--<2003-09-16 Tue 12:00> +syn match org_timestamp /\(<\d\d\d\d-\d\d-\d\d \k\k\k \d\d:\d\d>--<\d\d\d\d-\d\d-\d\d \k\k\k \d\d:\d\d>\)/ +syn match org_timestamp /\(<%%(diary-float.\+>\)/ +hi def link org_timestamp PreProc + +" special words +syn match today /TODAY$/ +hi def link today PreProc + +syn match week_agenda /^Week Agenda:$/ +hi def link week_agenda PreProc + +" Hyperlinks +syntax match hyperlink "\[\{2}[^][]*\(\]\[[^][]*\)\?\]\{2}" contains=hyperlinkBracketsLeft,hyperlinkURL,hyperlinkBracketsRight containedin=ALL +syntax match hyperlinkBracketsLeft contained "\[\{2}" conceal +syntax match hyperlinkURL contained "[^][]*\]\[" conceal +syntax match hyperlinkBracketsRight contained "\]\{2}" conceal +hi def link hyperlink Underlined + +endif diff --git a/syntax/orgtodo.vim b/syntax/orgtodo.vim new file mode 100644 index 0000000..f2d7a68 --- /dev/null +++ b/syntax/orgtodo.vim @@ -0,0 +1,51 @@ +if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'org') == -1 + +syn match org_todo_key /\[\zs[^]]*\ze\]/ +hi def link org_todo_key Identifier + +let s:todo_headings = '' +let s:i = 1 +while s:i <= g:org_heading_highlight_levels + if s:todo_headings == '' + let s:todo_headings = 'containedin=org_heading' . s:i + else + let s:todo_headings = s:todo_headings . ',org_heading' . s:i + endif + let s:i += 1 +endwhile +unlet! s:i + +if !exists('g:loaded_orgtodo_syntax') + let g:loaded_orgtodo_syntax = 1 + function! s:ReadTodoKeywords(keywords, todo_headings) + let l:default_group = 'Todo' + for l:i in a:keywords + if type(l:i) == 3 + call s:ReadTodoKeywords(l:i, a:todo_headings) + continue + endif + if l:i == '|' + let l:default_group = 'Question' + continue + endif + " strip access key + let l:_i = substitute(l:i, "\(.*$", "", "") + + let l:group = l:default_group + for l:j in g:org_todo_keyword_faces + if l:j[0] == l:_i + let l:group = 'orgtodo_todo_keyword_face_' . l:_i + call OrgExtendHighlightingGroup(l:default_group, l:group, OrgInterpretFaces(l:j[1])) + break + endif + endfor + silent! exec 'syntax match orgtodo_todo_keyword_' . l:_i . ' /' . l:_i .'/ ' . a:todo_headings + silent! exec 'hi def link orgtodo_todo_keyword_' . l:_i . ' ' . l:group + endfor + endfunction +endif + +call s:ReadTodoKeywords(g:org_todo_keywords, s:todo_headings) +unlet! s:todo_headings + +endif