diff options
author | Adam Stankiewicz <sheerun@sher.pl> | 2021-06-09 21:37:56 +0200 |
---|---|---|
committer | Adam Stankiewicz <sheerun@sher.pl> | 2021-06-09 21:37:56 +0200 |
commit | 4899585281beab51e5dff1d9ae4d3159244a8275 (patch) | |
tree | 1624741b8d1a5366568addbb90b1119587636459 | |
parent | 4f997c5c82d49ce3e2791eb0679e992751bf39a7 (diff) | |
download | vim-polyglot-4899585281beab51e5dff1d9ae4d3159244a8275.tar.gz vim-polyglot-4899585281beab51e5dff1d9ae4d3159244a8275.zip |
Add org mode, close #706
-rw-r--r-- | README.md | 3 | ||||
-rw-r--r-- | autoload/org.vim | 30 | ||||
-rw-r--r-- | autoload/polyglot/init.vim | 4 | ||||
-rw-r--r-- | autoload/polyglot/sleuth.vim | 1 | ||||
-rw-r--r-- | ftplugin/org.vim | 28 | ||||
-rw-r--r-- | ftplugin/outline.vim | 23 | ||||
-rw-r--r-- | packages.yaml | 10 | ||||
-rw-r--r-- | syntax/org.vim | 145 | ||||
-rw-r--r-- | syntax/outline.vim | 43 | ||||
-rw-r--r-- | tests/filetypes.vim | 1 |
10 files changed, 286 insertions, 2 deletions
@@ -7,7 +7,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 120+ times faster** than the <!--Package Count-->606<!--/Package Count--> packages it consists of. +- It **installs and updates 120+ times faster** than the <!--Package Count-->607<!--/Package Count--> packages it consists of. - It is also more secure (scripts loaded for every filetype are generated by vim-polyglot) - Best syntax and indentation support (no other features). Hand-selected language packs. - Automatically detects indentation (includes performance-optimized version of [vim-sleuth](https://github.com/tpope/vim-sleuth), can be disabled) @@ -143,6 +143,7 @@ On top of all language packs from [vim repository](https://github.com/vim/vim/tr - [odin](https://github.com/Tetralux/odin.vim) (Odin syntax highlighting for odin files) - [opencl](https://github.com/petRUShka/vim-opencl) (OpenCL syntax highlighting for cl and opencl files) - [openscad](https://github.com/sirtaj/vim-openscad) (Syntax highlighting for scad files) +- [org](https://github.com/axvr/org.vim) (Syntax highlighting for org files) - [perl](https://github.com/vim-perl/vim-perl) (Perl syntax highlighting for pl, al, cgi, fcgi, perl and 12 more files) - [pest](https://github.com/pest-parser/pest.vim) (Syntax highlighting for pest files) - [pgsql](https://github.com/lifepillar/pgsql.vim) (PLpgSQL syntax highlighting for pgsql files) diff --git a/autoload/org.vim b/autoload/org.vim new file mode 100644 index 00000000..de8282c2 --- /dev/null +++ b/autoload/org.vim @@ -0,0 +1,30 @@ +if polyglot#init#is_disabled(expand('<sfile>:p'), 'org', 'autoload/org.vim') + finish +endif + +" Helper functions for org.vim +" +" Maintainer: Alex Vear <av@axvr.io> +" License: Vim (see `:help license`) +" Location: autoload/org.vim +" Website: https://github.com/axvr/org.vim +" Last Change: 2020-01-04 + +" Fallback chain for options. Buffer local --> Global --> default. +function org#option(name, default) abort + return get(b:, a:name, get(g:, a:name, a:default)) +endfunction + +" Emacs-like fold text. +function org#fold_text() abort + return getline(v:foldstart) . '...' +endfunction + +" Check fold depth of a line. +function org#fold_expr() + let l:depth = match(getline(v:lnum), '\(^\*\+\)\@<=\( .*$\)\@=') + if l:depth > 0 && synIDattr(synID(v:lnum, 1, 1), 'name') =~# '\m^o\(rg\|utline\)Heading' + return ">" . l:depth + endif + return "=" +endfunction diff --git a/autoload/polyglot/init.vim b/autoload/polyglot/init.vim index 781c9e57..7aa94939 100644 --- a/autoload/polyglot/init.vim +++ b/autoload/polyglot/init.vim @@ -169,6 +169,10 @@ let did_load_filetypes = 1 " DO NOT EDIT CODE BELOW, IT IS GENERATED WITH MAKEFILE +if !has_key(g:polyglot_is_disabled, 'org') + au BufNewFile,BufRead *.org setf org +endif + if !has_key(g:polyglot_is_disabled, 'mermaid') au BufNewFile,BufRead *.mermaid,*.mm,*.mmd setf mermaid endif diff --git a/autoload/polyglot/sleuth.vim b/autoload/polyglot/sleuth.vim index 095be910..0785dfbf 100644 --- a/autoload/polyglot/sleuth.vim +++ b/autoload/polyglot/sleuth.vim @@ -388,6 +388,7 @@ let s:globs = { \ 'openscad': '*.scad', \ 'opl': '*.[Oo][Pp][Ll]', \ 'ora': '*.ora', + \ 'org': '*.org', \ 'pamconf': '', \ 'pamenv': 'pam_env.conf,.pam_environment', \ 'papp': '*.papp,*.pxml,*.pxsl', diff --git a/ftplugin/org.vim b/ftplugin/org.vim new file mode 100644 index 00000000..12711088 --- /dev/null +++ b/ftplugin/org.vim @@ -0,0 +1,28 @@ +if polyglot#init#is_disabled(expand('<sfile>:p'), 'org', 'ftplugin/org.vim') + finish +endif + +" Vim filetype plugin for GNU Emacs' Org mode +" +" Maintainer: Alex Vear <av@axvr.io> +" License: Vim (see `:help license`) +" Location: ftplugin/org.vim +" Website: https://github.com/axvr/org.vim +" Last Change: 2020-01-04 +" +" Reference Specification: Org mode manual +" GNU Info: `$ info Org` +" Web: <https://orgmode.org/manual/index.html> + +setlocal commentstring=#%s +setlocal comments=fb:*,fb:-,fb:+,b:#,b:\: +setlocal formatoptions+=ncqlt +let &l:formatlistpat = '^\s*\(\d\+[.)]\|[+-]\)\s\+' + +setlocal foldexpr=org#fold_expr() +setlocal foldmethod=expr + +if org#option('org_clean_folds', 0) + setlocal foldtext=org#fold_text() + setlocal fillchars-=fold:- +endif diff --git a/ftplugin/outline.vim b/ftplugin/outline.vim new file mode 100644 index 00000000..4f0bbd65 --- /dev/null +++ b/ftplugin/outline.vim @@ -0,0 +1,23 @@ +if polyglot#init#is_disabled(expand('<sfile>:p'), 'org', 'ftplugin/outline.vim') + finish +endif + +" Vim filetype plugin for GNU Emacs' Outline mode +" +" Maintainer: Alex Vear <av@axvr.io> +" License: Vim (see `:help license`) +" Location: ftplugin/outline.vim +" Website: https://github.com/axvr/org.vim +" Last Change: 2020-01-04 +" +" Reference Specification: GNU Emacs Manual, section 'Outline Mode' +" GNU Info: `$ info Emacs Outline Mode` +" Web: <https://www.gnu.org/software/emacs/manual/html_node/emacs/Outline-Mode.html> + +setlocal foldexpr=org#fold_expr() +setlocal foldmethod=expr + +if org#option('org_clean_folds', 0) + setlocal foldtext=org#fold_text() + setlocal fillchars-=fold:- +endif diff --git a/packages.yaml b/packages.yaml index e272a2e2..f76f522c 100644 --- a/packages.yaml +++ b/packages.yaml @@ -5612,4 +5612,12 @@ filetypes: - name: mermaid patterns: - pattern: '*.mermaid,*.mm,*.mmd' - description: Mermaid (https://mermaid-js.github.io/)
\ No newline at end of file + description: Mermaid (https://mermaid-js.github.io/) +--- +name: org +remote: axvr/org.vim +filetypes: +- name: org + patterns: + - pattern: '*.org' + description: GNU Emacs' Org mode diff --git a/syntax/org.vim b/syntax/org.vim new file mode 100644 index 00000000..de879a6f --- /dev/null +++ b/syntax/org.vim @@ -0,0 +1,145 @@ +if polyglot#init#is_disabled(expand('<sfile>:p'), 'org', 'syntax/org.vim') + finish +endif + +" Vim syntax file for GNU Emacs' Org mode +" +" Maintainer: Alex Vear <av@axvr.io> +" License: Vim (see `:help license`) +" Location: syntax/org.vim +" Website: https://github.com/axvr/org.vim +" Last Change: 2020-01-05 +" +" Reference Specification: Org mode manual +" GNU Info: `$ info Org` +" Web: <https://orgmode.org/manual/index.html> + +if exists('b:current_syntax') && b:current_syntax !=# 'outline' + finish +endif + +" Enable spell check for non syntax highlighted text +syntax spell toplevel + + +" Bold, underine, italic, etc. +syntax region orgItalic matchgroup=orgItalicDelimiter start="\(^\|[- '"({\]]\)\@<=\/\ze[^ ]" end="^\@!\/\([^\k\/]\|$\)\@=" keepend contains=@Spell +syntax region orgBold matchgroup=orgBoldDelimiter start="\(^\|[- '"({\]]\)\@<=\*\ze[^ ]" end="^\@!\*\([^\k\*]\|$\)\@=" keepend contains=@Spell +syntax region orgUnderline matchgroup=orgUnderlineDelimiter start="\(^\|[- '"({\]]\)\@<=_\ze[^ ]" end="^\@!_\([^\k_]\|$\)\@=" keepend contains=@Spell +syntax region orgStrikethrough matchgroup=orgStrikethroughDelimiter start="\(^\|[ '"({\]]\)\@<=+\ze[^ ]" end="^\@!+\([^\k+]\|$\)\@=" keepend contains=@Spell + +if org#option('org_use_italics', 1) + highlight def orgItalic term=italic cterm=italic gui=italic +else + highlight def orgItalic term=none cterm=none gui=none +endif + +highlight def orgBold term=bold cterm=bold gui=bold +highlight def orgUnderline term=underline cterm=underline gui=underline +highlight def orgStrikethrough term=strikethrough cterm=strikethrough gui=strikethrough +highlight def link orgBoldDelimiter orgBold +highlight def link orgUnderlineDelimiter orgUnderline +highlight def link orgStrikethroughDelimiter orgStrikethrough + + +" Options +syntax match orgOption /^\s*#+\w\+.*$/ keepend +syntax region orgTitle matchgroup=orgOption start="\c^\s*#+TITLE:\s*" end="$" keepend oneline +highlight def link orgBlockDelimiter SpecialComment +highlight def link orgOption SpecialComment +highlight def link orgTitle Title + + +" Code and vervatim text +syntax region orgCode matchgroup=orgCodeDelimiter start="\(^\|[- '"({\]]\)\@<=\~\ze[^ ]" end="^\@!\~\([^\k\~]\|$\)\@=" keepend +syntax region orgVerbatim matchgroup=orgVerbatimDelimiter start="\(^\|[- '"({\]]\)\@<==\ze[^ ]" end="^\@!=\([^\k=]\|$\)\@=" keepend +syntax match orgVerbatim /^\s*: .*$/ keepend +syntax region orgVerbatim matchgroup=orgBlockDelimiter start="\c^\s*#+BEGIN_.*" end="\c^\s*#+END_.*" keepend +syntax region orgCode matchgroup=orgBlockDelimiter start="\c^\s*#+BEGIN_SRC" end="\c^\s*#+END_SRC" keepend +syntax region orgCode matchgroup=orgBlockDelimiter start="\c^\s*#+BEGIN_EXAMPLE" end="\c^\s*#+END_EXAMPLE" keepend + +highlight def link orgVerbatim Identifier +highlight def link orgVerbatimDelimiter orgVerbatim +highlight def link orgCode Statement +highlight def link orgCodeDelimiter orgCode + + +" Comments +syntax match orgComment /^\s*#\s\+.*$/ keepend +syntax region orgComment matchgroup=orgBlockDelimiter start="\c^\s*#+BEGIN_COMMENT" end="\c^\s*#+END_COMMENT" keepend +highlight def link orgComment Comment + + +" Headings +syntax match orgHeading1 /^\s*\*\{1}\s\+.*$/ keepend contains=@Spell,orgTag,orgTodo,orgMath +syntax match orgHeading2 /^\s*\*\{2}\s\+.*$/ keepend contains=@Spell,orgTag,orgTodo,orgMath +syntax match orgHeading3 /^\s*\*\{3}\s\+.*$/ keepend contains=@Spell,orgTag,orgTodo,orgMath +syntax match orgHeading4 /^\s*\*\{4}\s\+.*$/ keepend contains=@Spell,orgTag,orgTodo,orgMath +syntax match orgHeading5 /^\s*\*\{5}\s\+.*$/ keepend contains=@Spell,orgTag,orgTodo,orgMath +syntax match orgHeading6 /^\s*\*\{6,}\s\+.*$/ keepend contains=@Spell,orgTag,orgTodo,orgMath + +syntax cluster orgHeadingGroup contains=orgHeading1,orgHeading2,orgHeading3,orgHeading4,orgHeading5,orgHeading6 + +syntax match orgTag /:\w\{-}:/ contained contains=orgTag +exec 'syntax keyword orgTodo contained ' . join(org#option('org_state_keywords', ['TODO', 'NEXT', 'DONE']), ' ') + +highlight def link orgHeading1 Title +highlight def link orgHeading2 orgHeading1 +highlight def link orgHeading3 orgHeading2 +highlight def link orgHeading4 orgHeading3 +highlight def link orgHeading5 orgHeading4 +highlight def link orgHeading6 orgHeading5 +highlight def link orgTodo Todo +highlight def link orgTag Type + + +" Lists +syntax match orgUnorderedListMarker "^\s*[-+]\s\+" keepend contains=@Spell +syntax match orgOrderedListMarker "^\s*\d\+[.)]\s\+" keepend contains=@Spell +if org#option('org_list_alphabetical_bullets', 0) + syntax match orgOrderedListMarker "^\s*\a[.)]\s\+" keepend contains=@Spell +endif +highlight def link orgUnorderedListMarker Statement +highlight def link orgOrderedListMarker orgUnorderedListMarker + + +" Timestamps +syntax match orgTimestampActive /<\d\{4}-\d\{2}-\d\{2}.\{-}>/ keepend +syntax match orgTimestampInactive /\[\d\{4}-\d\{2}-\d\{2}.\{-}\]/ keepend +highlight def link orgTimestampActive Operator +highlight def link orgTimestampInactive Comment + + +" Hyperlinks +syntax match orgHyperlink /\[\{2}\([^][]\{-1,}\]\[\)\?[^][]\{-1,}\]\{2}/ containedin=ALL contains=orgHyperLeft,orgHyperRight,orgHyperURL +syntax match orgHyperLeft /\[\{2}/ contained conceal +syntax match orgHyperRight /\]\{2}/ contained conceal +syntax match orgHyperURL /[^][]\{-1,}\]\[/ contains=orgHyperCentre contained conceal +syntax match orgHyperCentre /\]\[/ contained conceal + +syntax cluster orgHyperlinkBracketsGroup contains=orgHyperLeft,orgHyperRight,orgHyperCentre +syntax cluster orgHyperlinkGroup contains=orgHyperlink,orgHyperURL,orgHyperlinkBracketsGroup + +highlight def link orgHyperlink Underlined +highlight def link orgHyperURL String +highlight def link orgHyperCentre Comment +highlight def link orgHyperLeft Comment +highlight def link orgHyperRight Comment + + +" TeX +" Ref: https://orgmode.org/manual/LaTeX-fragments.html +if org#option('org_highlight_tex', 1) + syntax include @LATEX syntax/tex.vim + syntax region orgMath start="\\begin\[.*\]{.*}" end="\\end{.*}" keepend contains=@LATEX + syntax region orgMath start="\\begin{.*}" end="\\end{.*}" keepend contains=@LATEX + syntax region orgMath start="\\\[" end="\\\]" keepend contains=@LATEX + syntax region orgMath start="\\(" end="\\)" keepend contains=@LATEX + syntax region orgMath start="\S\@<=\$\|\$\S\@=" end="\S\@<=\$\|\$\S\@=" keepend oneline contains=@LATEX + syntax region orgMath start=/\$\$/ end=/\$\$/ keepend contains=@LATEX + syntax match orgMath /\\\$/ conceal cchar=$ + highlight def link orgMath String +endif + + +let b:current_syntax = 'org' diff --git a/syntax/outline.vim b/syntax/outline.vim new file mode 100644 index 00000000..749bc840 --- /dev/null +++ b/syntax/outline.vim @@ -0,0 +1,43 @@ +if polyglot#init#is_disabled(expand('<sfile>:p'), 'org', 'syntax/outline.vim') + finish +endif + +" Vim syntax file for GNU Emacs' Outline mode +" +" Maintainer: Alex Vear <av@axvr.io> +" License: Vim (see `:help license`) +" Location: syntax/outline.vim +" Website: https://github.com/axvr/org.vim +" Last Change: 2019-09-28 +" +" Reference Specification: GNU Emacs Manual, section 'Outline Mode' +" GNU Info: `$ info Emacs Outline Mode` +" Web: <https://www.gnu.org/software/emacs/manual/html_node/emacs/Outline-Mode.html> + +if exists('b:current_syntax') + finish +endif + +" Enable spell check for non syntax highlighted text +syntax spell toplevel + + +" Headings +syntax match outlineHeading1 /^\s*\*\{1}\s\+.*$/ keepend contains=@Spell +syntax match outlineHeading2 /^\s*\*\{2}\s\+.*$/ keepend contains=@Spell +syntax match outlineHeading3 /^\s*\*\{3}\s\+.*$/ keepend contains=@Spell +syntax match outlineHeading4 /^\s*\*\{4}\s\+.*$/ keepend contains=@Spell +syntax match outlineHeading5 /^\s*\*\{5}\s\+.*$/ keepend contains=@Spell +syntax match outlineHeading6 /^\s*\*\{6,}\s\+.*$/ keepend contains=@Spell + +syntax cluster outlineHeadingGroup contains=outlineHeading1,outlineHeading2,outlineHeading3,outlineHeading4,outlineHeading5,outlineHeading6 + +hi def link outlineHeading1 Title +hi def link outlineHeading2 outlineHeading1 +hi def link outlineHeading3 outlineHeading2 +hi def link outlineHeading4 outlineHeading3 +hi def link outlineHeading5 outlineHeading4 +hi def link outlineHeading6 outlineHeading5 + + +let b:current_syntax = 'outline' diff --git a/tests/filetypes.vim b/tests/filetypes.vim index 091151fb..05582424 100644 --- a/tests/filetypes.vim +++ b/tests/filetypes.vim @@ -653,6 +653,7 @@ call TestFiletype('just') call TestFiletype('nftables') call TestFiletype('openscad') call TestFiletype('mermaid') +call TestFiletype('org') " DO NOT EDIT CODE ABOVE, IT IS GENERATED WITH MAKEFILE |