Initial commit
This commit is contained in:
15
LICENCE
Normal file
15
LICENCE
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
ISC License
|
||||||
|
|
||||||
|
Copyright (c) 2018, Alex Vear
|
||||||
|
|
||||||
|
Permission to use, copy, modify, and/or distribute this software for any
|
||||||
|
purpose with or without fee is hereby granted, provided that the above
|
||||||
|
copyright notice and this permission notice appear in all copies.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
|
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
|
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
|
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
|
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||||
|
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
|
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
5
README.md
Normal file
5
README.md
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
# Org-mode syntax highlighting for Vim
|
||||||
|
|
||||||
|
TODO: test with other colorthemes
|
||||||
|
TODO: fix italics
|
||||||
|
TODO: fix hyperlinks
|
||||||
7
ftdetect/org.vim
Normal file
7
ftdetect/org.vim
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
" =============================================================
|
||||||
|
" Description: Detect Org-mode files
|
||||||
|
" Author: Alex Vear (axvr)
|
||||||
|
" Licence: ISC (2018)
|
||||||
|
" =============================================================
|
||||||
|
|
||||||
|
autocmd BufRead,BufNewFile *.org setfiletype org
|
||||||
26
ftplugin/org.vim
Normal file
26
ftplugin/org.vim
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
" =============================================================
|
||||||
|
" Description: Configure Org-mode folding
|
||||||
|
" Author: Alex Vear (axvr)
|
||||||
|
" Licence: ISC (2018)
|
||||||
|
" =============================================================
|
||||||
|
|
||||||
|
setlocal conceallevel=2
|
||||||
|
setlocal commentstring=#%s
|
||||||
|
|
||||||
|
function! OrgFold()
|
||||||
|
let l:depth = match(getline(v:lnum), '\(^\*\+\)\@<=\( .*$\)\@=')
|
||||||
|
if l:depth > 0 && synIDattr(synID(v:lnum, 1, 1), 'name') ~=# 'orgHeading'
|
||||||
|
return ">" . l:depth
|
||||||
|
endif
|
||||||
|
return "="
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
setlocal foldexpr=OrgFold()
|
||||||
|
setlocal foldmethod=expr
|
||||||
|
|
||||||
|
" Make folds more readable
|
||||||
|
setlocal foldtext=getline(v:foldstart)
|
||||||
|
setlocal fillchars-=fold:-
|
||||||
|
setlocal fillchars+=fold:\
|
||||||
|
|
||||||
|
" TODO add working links?
|
||||||
90
syntax/org.vim
Normal file
90
syntax/org.vim
Normal file
@@ -0,0 +1,90 @@
|
|||||||
|
" =============================================================
|
||||||
|
" Description: Basic Org-mode syntax highlighting
|
||||||
|
" Author: Alex Vear (axvr)
|
||||||
|
" Licence: ISC (2018)
|
||||||
|
" =============================================================
|
||||||
|
|
||||||
|
if exists("b:current_syntax")
|
||||||
|
finish
|
||||||
|
endif
|
||||||
|
|
||||||
|
" FIXME spell checking does not work on standard lines.
|
||||||
|
|
||||||
|
syntax region orgItalic matchgroup=orgItalicDelimiter start="\S\@<=\/\|\/\S\@=" end="\S\@<=\/\|\/\S\@=" keepend contains=@Spell concealends oneline
|
||||||
|
syntax region orgBold matchgroup=orgBoldDelimiter start="\S\@<=\*\|\*\S\@=" end="\S\@<=\*\|\*\S\@=" keepend contains=@Spell concealends oneline
|
||||||
|
syntax region orgUnderline matchgroup=orgUnderlineDelimiter start="\S\@<=_\|_\S\@=" end="\S\@<=_\|_\S\@=" keepend contains=@Spell concealends oneline
|
||||||
|
syntax region orgStrikethrough start="\S\@<=+\|+\S\@=" end="\S\@<=+\|+\S\@=" keepend contains=@Spell concealends oneline
|
||||||
|
|
||||||
|
syntax match orgOption /^\s*#+\w\+.*$/ keepend
|
||||||
|
syntax region orgTitle matchgroup=orgOption start="^\s*#+TITLE:\s*" end="$" keepend oneline
|
||||||
|
|
||||||
|
syntax region orgCode matchgroup=orgCodeDelimiter start="\S\@<==\|=\S\@=" end="\S\@<==\|=\S\@=" keepend concealends oneline
|
||||||
|
syntax region orgVerbatim matchgroup=orgVerbatimDelimiter start="\S\@<=\~\|\~\S\@=" end="\S\@<=\~\|\~\S\@=" keepend concealends oneline
|
||||||
|
syntax match orgVerbatim /^\s*: .*$/ keepend
|
||||||
|
syntax region orgVerbatim matchgroup=orgBlockDelimiter start="^\s*#+BEGIN_.*" end="^\s*#+END_.*" keepend
|
||||||
|
syntax region orgCode matchgroup=orgBlockDelimiter start="^\s*#+BEGIN_SRC" end="^\s*#+END_SRC" keepend
|
||||||
|
syntax region orgCode matchgroup=orgBlockDelimiter start="^\s*#+BEGIN_EXAMPLE" end="^\s*#+END_EXAMPLE" keepend
|
||||||
|
|
||||||
|
|
||||||
|
" Comments
|
||||||
|
syntax match orgComment /^\s*#\s\+.*$/ keepend
|
||||||
|
syntax region orgComment matchgroup=orgBlockDelimiter start="^\s*#+BEGIN_COMMENT" end="^\s*#+END_COMMENT" keepend
|
||||||
|
highlight def link orgComment Comment
|
||||||
|
|
||||||
|
|
||||||
|
" Headings
|
||||||
|
syntax match orgHeading1 /^\s*\*\{1}\s\+.*$/ keepend contains=@Spell,orgTag,orgTodo
|
||||||
|
syntax match orgHeading2 /^\s*\*\{2}\s\+.*$/ keepend contains=@Spell,orgTag,orgTodo
|
||||||
|
syntax match orgHeading3 /^\s*\*\{3}\s\+.*$/ keepend contains=@Spell,orgTag,orgTodo
|
||||||
|
syntax match orgHeading4 /^\s*\*\{4}\s\+.*$/ keepend contains=@Spell,orgTag,orgTodo
|
||||||
|
syntax match orgHeading5 /^\s*\*\{5}\s\+.*$/ keepend contains=@Spell,orgTag,orgTodo
|
||||||
|
syntax match orgHeading6 /^\s*\*\{6}\s\+.*$/ keepend contains=@Spell,orgTag,orgTodo
|
||||||
|
syntax match orgTag /:\w\{-}:/ contained contains=orgTag
|
||||||
|
syntax keyword orgTodo contained TODO NEXT DONE
|
||||||
|
|
||||||
|
|
||||||
|
" Timestamp
|
||||||
|
syntax match orgTimestamp /<\d\{4}-\d\{2}-\d\{2}.\{-}>/ keepend
|
||||||
|
highlight def link orgTimestamp Operator
|
||||||
|
|
||||||
|
|
||||||
|
" FIXME Hyperlinks
|
||||||
|
" - Highlight a link without formatting
|
||||||
|
" - Fix issues with italics
|
||||||
|
syntax match orgHyperlink "\[\{2}[^][]*\(\]\[[^][]*\)\?\]\{2}" contains=orgHyperlinkBracketsLeft,orgHyperlinkURL,orgHyperlinkBracketsRight containedin=ALL
|
||||||
|
syntax match orgHyperlinkBracketsLeft contained "\[\{2}#\?" conceal
|
||||||
|
syntax match orgHyperlinkURL contained "[^][]*\]\[" conceal
|
||||||
|
syntax match orgHyperlinkBracketsRight contained "\]\{2}" conceal
|
||||||
|
highlight def link orgHyperlink Underlined
|
||||||
|
|
||||||
|
|
||||||
|
" TODO Tables
|
||||||
|
|
||||||
|
|
||||||
|
highlight def orgItalic term=italic cterm=italic gui=italic
|
||||||
|
highlight def orgBold term=bold cterm=bold gui=bold
|
||||||
|
highlight def orgUnderline term=underline cterm=underline gui=underline
|
||||||
|
highlight def link orgItalicDelimiter orgItalic
|
||||||
|
highlight def link orgBoldDelimiter orgBold
|
||||||
|
highlight def link orgUnderlineDelimiter orgUnderline
|
||||||
|
|
||||||
|
highlight def link orgHeading1 htmlH1
|
||||||
|
highlight def link orgHeading2 htmlH2
|
||||||
|
highlight def link orgHeading3 htmlH3
|
||||||
|
highlight def link orgHeading4 htmlH4
|
||||||
|
highlight def link orgHeading5 htmlH5
|
||||||
|
highlight def link orgHeading6 htmlH6
|
||||||
|
highlight def link orgTodo Todo
|
||||||
|
highlight def link orgTag Constant
|
||||||
|
|
||||||
|
highlight def link orgVerbatim Delimiter
|
||||||
|
highlight def link orgVerbatimDelimiter orgVerbatim
|
||||||
|
highlight def link orgCode Statement
|
||||||
|
highlight def link orgCodeDelimiter orgCode
|
||||||
|
|
||||||
|
highlight def link orgBlockDelimiter SpecialComment
|
||||||
|
highlight def link orgOption Constant
|
||||||
|
highlight def link orgTitle Function
|
||||||
|
|
||||||
|
|
||||||
|
let b:current_syntax = 'org'
|
||||||
Reference in New Issue
Block a user