From: Jean-Marie Gaillourdet <jmg@gaillourdet.net>
To: Bastien <bastien.guerry@wikimedia.fr>
Cc: emacs-orgmode <emacs-orgmode@gnu.org>
Subject: Re: Vim folding/syntax highlighting?
Date: Tue, 18 May 2010 15:03:39 +0200 [thread overview]
Message-ID: <EA275862-B97A-4BAC-B879-177FD07A2D56@gaillourdet.net> (raw)
In-Reply-To: <87vdbaug7b.fsf@bzg.ath.cx>
[-- Attachment #1: Type: text/plain, Size: 1212 bytes --]
Hi,
sorry to answer so late, but I'm way behind my emails.
There is http://www.vim.org/scripts/script.php?script_id=1266 , which emulates folding like outline-mode. I'll attach my locally modified version of it. I've added support for deeper outline structures, drawers, tags, SCHEDULED and DEADLINE. This is just work in progress.
Just put file into ~/.vim/syntax and use :set ft=org or put the following line into ~/.vim/ftdetect/org.vim.
au BufRead,BufNewFile *.org set filetype=org
Additionally, I have a file ~/vim/ftplugin/org.vim which contains:
map <Tab> za
autocmd! BufRead,BufNewFile *.org set filetype=org
This, allows to use tab to open and close folds as in org-mode.
Best regards,
Jean
On 29.04.2010, at 23:00, Bastien wrote:
> Nathan Neff <nathan.neff@gmail.com> writes:
>
>> I'll probably write a syntax file and a folding method if nobody
>> knows of any existing ones.
>
> That would be really great!
>
> --
> Bastien
>
>
> _______________________________________________
> Emacs-orgmode mailing list
> Please use `Reply All' to send replies to the list.
> Emacs-orgmode@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-orgmode
[-- Attachment #2: org.vim --]
[-- Type: application/octet-stream, Size: 11554 bytes --]
"
" Script: syntax/org.vim
"
" Version: 2.1
"
" Description:
"
" This uses folding to mimic outline-mode in Emacs. Set the filetype to
" 'outline' to activate this functinality. Put it in the modeline to
" preserve outlines between edits. For example:
"
" vim:set ft=outline:
"
" Installation:
"
" Place this file in your home directory under ~/.vim/syntax/, or in the
" system location under the syntax/ directory to provide it to all users.
"
" Maintainer: Tye Z. <zdro@yahoo.com>
" modified by Jean-Marie Gaillourdet <jmg@gaillourdet.net>
"
" Customization:
"
" The colors of the outline headers can be changed by linking them to
" whatever you like. For example:
"
" hi! link Outline_1 Statement
"
" History:
"
" Version 2.1: (Jean-Marie Gaillourdet)
"
" - Renamed to org.vim
" - Added rules to match headings up to level 20
" - Added rule to highlight and fold drawers
"
" Version 2.0:
"
" - Rewritten to use syntax-folding instead of a fold expression
" - Eliminated slowness in folds with large amounts of text
"
" Version 1.2:
"
" - Updated regexes for readability, using a number for the '*' count
"
" Version 1.1:
"
" - Initial version
"
"
" Do folding with syntax. This works pretty darn well, and is simpler than a
" complicated foldexpr.
"
" - An outline block starts with a '*' and ends when approaching another '*'
" at the beginning of a line.
"
" - An outline block can contain any outline block of a lower level. So, a
" level 3 can be inside a level 1 without the intermediary level 2.
"
" - A '_' can end a block, allowing one to insert extra space between two
" folds.
"
" ****************************************************************************
" * Syntax Regions for Outline Header *
" ****************************************************************************
" {{{
syn region Outline_1 matchgroup=Outline_1_match
\ start='^\*[^*][^:]*'
\ end='\n\ze\n\?\*[^*]\|^<$'
\ contains=Tags
\ fold keepend
syn region Outline_2 matchgroup=Outline_2_match
\ start='^\*\{2\}[^*][^:]*'
\ end='\n\ze\n\?\*\{1,2\}[^*]\|^<\{2\}$'
\ containedin=Outline_1,Outline_2
\ contains=Tags
\ fold keepend
syn region Outline_3 matchgroup=Outline_3_match
\ start='^\*\{3\}[^*][^:]*'
\ end='\n\ze\n\?\*\{1,3\}[^*]\|^<\{3\}$'
\ containedin=Outline_1,Outline_2,Outline_3
\ contains=Tags
\ fold keepend
syn region Outline_4 matchgroup=Outline_4_match
\ start='^\*\{4\}[^*][^:]*'
\ end='\n\ze\n\?\*\{1,4\}[^*]\|^<\{4\}$'
\ containedin=Outline_1,Outline_2,Outline_3,Outline_4
\ contains=Tags
\ fold keepend
syn region Outline_5 matchgroup=Outline_5_match
\ start='^\*\{5\}[^*][^:]*'
\ end='\n\ze\n\?\*\{1,5\}[^*]\|^<\{5\}$'
\ containedin=Outline_1,Outline_2,Outline_3,Outline_4,Outline_5
\ contains=Tags
\ fold keepend
syn region Outline_6 matchgroup=Outline_6_match
\ start='^\*\{6\}[^*][^:]*'
\ end='\n\ze\n\?\*\{1,6\}[^*]\|^<\{6\}$'
\ containedin=Outline_1,Outline_2,Outline_3,Outline_4,Outline_5,Outline_6
\ contains=Tags
\ fold keepend
syn region Outline_7 matchgroup=Outline_7_match
\ start='^\*\{7\}[^*][^:]*'
\ end='\n\ze\n\?\*\{1,7\}[^*]\|^<\{7\}$'
\ containedin=Outline_1,Outline_2,Outline_3,Outline_4,Outline_5,Outline_6,Outline_7
\ contains=Tags
\ fold keepend
syn region Outline_8 matchgroup=Outline_8_match
\ start='^\*\{8\}[^*][^:]*'
\ end='\n\ze\n\?\*\{1,8\}[^*]\|^<\{8\}$'
\ containedin=Outline_1,Outline_2,Outline_3,Outline_4,Outline_5,Outline_6,Outline_7,Outline_8
\ contains=Tags
\ fold keepend
syn region Outline_9 matchgroup=Outline_9_match
\ start='^\*\{9\}[^*][^:]*'
\ end='\n\ze\n\?\*\{1,9\}[^*]\|^<\{9\}$'
\ containedin=Outline_1,Outline_2,Outline_3,Outline_4,Outline_5,Outline_6,Outline_7,Outline_8,Outline_9
\ contains=Tags
\ fold keepend
syn region Outline_10 matchgroup=Outline_10_match
\ start='^\*\{10\}[^*][^:]*'
\ end='\n\ze\n\?\*\{1,10\}[^*]\|^<\{10\}$'
\ containedin=Outline_1,Outline_2,Outline_3,Outline_4,Outline_5,Outline_6,Outline_7,Outline_8,Outline_9,Outline_10
\ contains=Tags
\ fold keepend
syn region Outline_11 matchgroup=Outline_11_match
\ start='^\*\{11\}[^*][^:]*'
\ end='\n\ze\n\?\*\{1,11\}[^*]\|^<\{11\}$'
\ containedin=Outline_1,Outline_2,Outline_3,Outline_4,Outline_5,Outline_6,Outline_7,Outline_8,Outline_9,Outline_10,Outline_11
\ contains=Tags
\ fold keepend
syn region Outline_12 matchgroup=Outline_12_match
\ start='^\*\{12\}[^*][^:]*'
\ end='\n\ze\n\?\*\{1,12\}[^*]\|^<\{12\}$'
\ containedin=Outline_1,Outline_2,Outline_3,Outline_4,Outline_5,Outline_6,Outline_7,Outline_8,Outline_9,Outline_10,Outline_11,Outline_12
\ contains=Tags
\ fold keepend
syn region Outline_13 matchgroup=Outline_13_match
\ start='^\*\{13\}[^*][^:]*'
\ end='\n\ze\n\?\*\{1,13\}[^*]\|^<\{13\}$'
\ containedin=Outline_1,Outline_2,Outline_3,Outline_4,Outline_5,Outline_6,Outline_7,Outline_8,Outline_9,Outline_10,Outline_11,Outline_12,Outline_13
\ contains=Tags
\ fold keepend
syn region Outline_14 matchgroup=Outline_14_match
\ start='^\*\{14\}[^*][^:]*'
\ end='\n\ze\n\?\*\{1,14\}[^*]\|^<\{14\}$'
\ containedin=Outline_1,Outline_2,Outline_3,Outline_4,Outline_5,Outline_6,Outline_7,Outline_8,Outline_9,Outline_10,Outline_11,Outline_12,Outline_13,Outline_14
\ contains=Tags
\ fold keepend
syn region Outline_15 matchgroup=Outline_15_match
\ start='^\*\{15\}[^*][^:]*'
\ end='\n\ze\n\?\*\{1,15\}[^*]\|^<\{15\}$'
\ containedin=Outline_1,Outline_2,Outline_3,Outline_4,Outline_5,Outline_6,Outline_7,Outline_8,Outline_9,Outline_10,Outline_11,Outline_12,Outline_13,Outline_14,Outline_15
\ contains=Tags
\ fold keepend
syn region Outline_16 matchgroup=Outline_16_match
\ start='^\*\{16\}[^*][^:]*'
\ end='\n\ze\n\?\*\{1,16\}[^*]\|^<\{16\}$'
\ containedin=Outline_1,Outline_2,Outline_3,Outline_4,Outline_5,Outline_6,Outline_7,Outline_8,Outline_9,Outline_10,Outline_11,Outline_12,Outline_13,Outline_14,Outline_15,Outline_16
\ contains=Tags
\ fold keepend
syn region Outline_17 matchgroup=Outline_17_match
\ start='^\*\{17\}[^*][^:]*'
\ end='\n\ze\n\?\*\{1,17\}[^*]\|^<\{17\}$'
\ containedin=Outline_1,Outline_2,Outline_3,Outline_4,Outline_5,Outline_6,Outline_7,Outline_8,Outline_9,Outline_10,Outline_11,Outline_12,Outline_13,Outline_14,Outline_15,Outline_16,Outline_17
\ contains=Tags
\ fold keepend
syn region Outline_18 matchgroup=Outline_18_match
\ start='^\*\{18\}[^*][^:]*'
\ end='\n\ze\n\?\*\{1,18\}[^*]\|^<\{18\}$'
\ containedin=Outline_1,Outline_2,Outline_3,Outline_4,Outline_5,Outline_6,Outline_7,Outline_8,Outline_9,Outline_10,Outline_11,Outline_12,Outline_13,Outline_14,Outline_15,Outline_16,Outline_17,Outline_18
\ contains=Tags
\ fold keepend
syn region Outline_19 matchgroup=Outline_19_match
\ start='^\*\{19\}[^*][^:]*'
\ end='\n\ze\n\?\*\{1,19\}[^*]\|^<\{19\}$'
\ containedin=Outline_1,Outline_2,Outline_3,Outline_4,Outline_5,Outline_6,Outline_7,Outline_8,Outline_9,Outline_10,Outline_11,Outline_12,Outline_13,Outline_14,Outline_15,Outline_16,Outline_17,Outline_18,Outline_19
\ contains=Tags
\ fold keepend
syn region Outline_20 matchgroup=Outline_20_match
\ start='^\*\{20\}[^*][^:]*'
\ end='\n\ze\n\?\*\{1,20\}[^*]\|^<\{20\}$'
\ containedin=Outline_1,Outline_2,Outline_3,Outline_4,Outline_5,Outline_6,Outline_7,Outline_8,Outline_9,Outline_10,Outline_11,Outline_12,Outline_13,Outline_14,Outline_15,Outline_16,Outline_17,Outline_18,Outline_19,Outline_20
\ contains=Tags
\ fold keepend
" }}}
" ****************************************************************************
" * Syntax Regions for Drawer *
" ****************************************************************************
" {{{
syn region DRAWER matchgroup=Drawer_match
\ start='^ *:[^:]*:'
\ end='^ *:END:'
\ containedin=Outline_1,Outline_2,Outline_3,Outline_4,Outline_5,Outline_6,Outline_7,Outline_8,Outline_9,Outline_10,Outline_11,Outline_12,Outline_13,Outline_14,Outline_15,Outline_16,Outline_17,Outline_18,Outline_19,Outline_20
\ fold
" }}}
" ****************************************************************************
" * Syntax for Meta Data *
" ****************************************************************************
" {{{
syn match Configuration '^\#\+.*$'
syn match Tags contained ':[^ ]*:'
" TODO: try to make it match only in a headline
syn match MetaData_Date
\ containedin=Outline_1,Outline_2,Outline_3,Outline_4,Outline_5,Outline_6,Outline_7,Outline_8,Outline_9,Outline_10,Outline_11,Outline_12,Outline_13,Outline_14,Outline_15,Outline_16,Outline_17,Outline_18,Outline_19,Outline_20
\ '\(DEADLINE\|SCHEDULED\):'
syn match ActiveDate
\ containedin=ALL
\ '<[0-9]\{4,4}-[0-9]\{2,2}-[0-9]\{2,2}\s\+\(Mon\|Tue\|Wed\|Thu\|Fri\|Sat\|Sun\)\?>'
syn match InActiveDate
\ containedin=ALL
\ '\[[0-9]\{4,4}-[0-9]\{2,2}-[0-9]\{2,2}\s\+\(Mon\|Tue\|Wed\|Thu\|Fri\|Sat\|Sun\)\?\]'
" }}}
""" Debugging: Hilight the whole block so we can see exactly what is being
""" done.
"hi Outline_1 guibg=gray40
"hi Outline_2 guibg=#330000
"hi Outline_3 guibg=#003300
"hi Outline_4 guibg=#000033
"" Disable
""hi Outline_1 guibg=bg
""hi Outline_2 guibg=bg
""hi Outline_3 guibg=bg
""hi Outline_4 guibg=bg
hi! default link Outline_1_match Comment
hi! default link Outline_2_match Identifier
hi! default link Outline_3_match PreProc
hi! default link Outline_4_match Type
hi! default link Outline_5_match Type
hi! default link Outline_6_match Type
hi! default link Outline_7_match Type
hi! default link Outline_8_match Type
hi! default link Outline_9_match Type
hi! default link Outline_10_match Type
hi! default link Outline_11_match Type
hi! default link Outline_12_match Type
hi! default link Outline_13_match Type
hi! default link Outline_14_match Type
hi! default link Outline_15_match Type
hi! default link Outline_16_match Type
hi! default link Outline_17_match Type
hi! default link Outline_18_match Type
hi! default link Outline_19_match Type
hi! default link Outline_20_match Type
hi! default link Drawer_match Comment
hi! default link Tags Todo
hi! default link Configuration PreProc
hi! default link MetaData_Date Keyword
hi! default link ActiveDate Constant
hi! default link InActiveDate Constant
syn sync fromstart
setlocal foldmethod=syntax
finish
[-- Attachment #3: Type: text/plain, Size: 201 bytes --]
_______________________________________________
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode
next prev parent reply other threads:[~2010-05-18 13:04 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-04-29 18:52 Vim folding/syntax highlighting? Nathan Neff
2010-04-29 21:00 ` Bastien
2010-05-18 13:03 ` Jean-Marie Gaillourdet [this message]
-- strict thread matches above, loose matches on Subject: below --
2010-04-29 21:03 Michael Brand
2010-04-29 22:32 ` Štěpán Němec
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=EA275862-B97A-4BAC-B879-177FD07A2D56@gaillourdet.net \
--to=jmg@gaillourdet.net \
--cc=bastien.guerry@wikimedia.fr \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).