Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Org-mode language support #2835

Closed
wants to merge 63 commits into from
Closed
Changes from 5 commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
acaa77a
add initial org mode syntax highlighting script, based on markdown.kak
andreyorst Apr 2, 2019
3c9b85b
fix src_blocks, add list highlighting
andreyorst Apr 3, 2019
7cf7dee
case-isensetive src blocks
andreyorst Apr 3, 2019
654ef9c
remove unnedeed slashes
andreyorst Apr 3, 2019
3afb526
update regexes for inline formatting
andreyorst Apr 4, 2019
3eac6b9
Merge remote-tracking branch 'upstream/master' into org-mode
andreyorst Apr 4, 2019
e806a34
use builtin faces for bold, italics, and underline. use add underline…
andreyorst Apr 4, 2019
d26192f
add strikethrough highlighter for org. add strikethrough face to themes
andreyorst Apr 4, 2019
d890516
Merge remote-tracking branch 'upstream/master' into org-mode
andreyorst Apr 10, 2019
f561fdf
add more blocks
andreyorst Apr 10, 2019
ffac001
provide indentation copying rules for lists
andreyorst Apr 11, 2019
51ce3a1
discard list indentation in case no text entered
andreyorst Apr 11, 2019
32bb577
add emacs-lisp
andreyorst Apr 11, 2019
00cff94
fix table being detected mid line
andreyorst Apr 11, 2019
da8bb68
fix wrapping search
andreyorst Apr 11, 2019
fcbc44d
rework highlighters to support singel newlinesd matching
andreyorst Apr 11, 2019
b8f54f0
add highlighting for title and requisites
andreyorst Apr 11, 2019
5bb8ecf
fix end of src block was highlighted along with the code inside it
andreyorst Apr 11, 2019
9a22a53
turn math blocks to region highlighter
andreyorst Apr 11, 2019
848bc25
add math blocks starting with square bracket
andreyorst Apr 11, 2019
9e0642a
add section, subsection, and subsubsection faces
andreyorst Apr 11, 2019
a76a294
use new sections, adjust bold
andreyorst Apr 11, 2019
e9c228c
avoid bold headings
andreyorst Apr 12, 2019
69c23e4
simplify markup regexps
andreyorst Apr 12, 2019
a1721d2
simplify markup regexps
andreyorst Apr 12, 2019
01a88ce
add one level of iteration to sections
andreyorst Apr 12, 2019
bf81bde
merge bold highlighters into one
andreyorst Apr 12, 2019
f1c507c
define inner region for blocks
andreyorst Apr 12, 2019
fbe0bfe
fix links; sort languages
andreyorst Apr 12, 2019
9c35e3f
rebase against master
andreyorst Apr 12, 2019
5e066c7
handle TODO items
andreyorst Apr 13, 2019
43e227a
adjust math blocks
andreyorst Apr 13, 2019
a1adafb
support tags in headings
andreyorst Apr 13, 2019
61f5c0a
fix headings
andreyorst Apr 13, 2019
23f0ec4
add timestamps; adjust markup to specification
andreyorst Apr 13, 2019
8db594d
add timestamps; adjust markup to specification
andreyorst Apr 13, 2019
5018a17
add latex area
andreyorst Apr 13, 2019
86f6708
use match-capture for latex block
andreyorst Apr 13, 2019
19b78f2
export snippets and footnotes
andreyorst Apr 13, 2019
90dc15d
extend links, targets, add cookies
andreyorst Apr 13, 2019
888626c
fix link regex
andreyorst Apr 14, 2019
d74a54d
update commants and docstrings
andreyorst Apr 14, 2019
3fed694
better detection of TODO items on startup
andreyorst Apr 14, 2019
3467e04
better heading highlighting
andreyorst Apr 14, 2019
58fdee0
fix link
andreyorst Apr 14, 2019
9282240
tweak markup to handle three chars correctly
andreyorst Apr 14, 2019
5c4073b
provide reparse command
andreyorst Apr 14, 2019
d5bd2e6
tweak timestamp and link
andreyorst Apr 14, 2019
73ac8a1
Merge remote-tracking branch 'upstream/master' into org-mode
andreyorst Apr 29, 2019
838cc0d
provide orgmode module
andreyorst Apr 29, 2019
8458cb0
create new faces based on existing ones, adjust detection
andreyorst Apr 29, 2019
e10e764
remove section highlighters, as they are now declared by org.kak
andreyorst Apr 29, 2019
75b4bc2
remove underline and strikethrough faces from builtin colorschemes, d…
andreyorst Apr 29, 2019
d60a6f8
remove modifications to themes completely
andreyorst Apr 29, 2019
d9cbdf7
remove modifications to themes completely
andreyorst Apr 29, 2019
3de4874
add heading comments
andreyorst Apr 29, 2019
bae86c7
use whitespace as Comment delimiter
andreyorst Apr 29, 2019
6434ce9
adjust comment face
andreyorst Apr 29, 2019
ceef4e4
Merge remote-tracking branch 'upstream/master' into org-mode
andreyorst Jul 25, 2019
fa784ee
support loading language modules like in #2924
andreyorst Jul 25, 2019
097fbd1
regex simplifications; latex ref
andreyorst Aug 6, 2019
cd4da0f
Merge remote-tracking branch 'upstream/master' into org-mode
andreyorst Apr 4, 2020
45ef1dd
simplify priorities parsing
andreyorst Apr 4, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
78 changes: 78 additions & 0 deletions rc/filetype/org.kak
@@ -0,0 +1,78 @@
# https://orgmode.org/ - your life in plain text
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾

# Detection
# ‾‾‾‾‾‾‾‾‾

hook global BufCreate .*[.]org %{
set-option buffer filetype org
}

# Highlighters
# ‾‾‾‾‾‾‾‾‾‾‾‾

add-highlighter shared/org regions
add-highlighter shared/org/inline default-region regions
add-highlighter shared/org/inline/text default-region group

evaluate-commands %sh{
languages="
c cabal clojure coffee cpp css cucumber d diff dockerfile fish gas go
haml haskell html ini java javascript json julia kak kickstart latex
lisp emacs-lisp scheme lua makefile org moon objc perl pug python ragel ruby rust
sass scala scss sh swift toml tupfile typescript yaml sql
"
for lang in ${languages}; do
printf "%s\n" "add-highlighter shared/org/${lang} region '#\+(?i)BEGIN_SRC(?I)\h+${lang}\b' '#\+(?i)END_SRC' regions"
printf "%s\n" "add-highlighter shared/org/${lang}/ default-region fill meta"
case ${lang} in
kak) ref="kakrc" ;;
emacs-lisp) ref="lisp" ;;
*) ref="${lang}" ;;
esac
printf "%s\n" "add-highlighter shared/org/${lang}/inner region \A#\+(?i)BEGIN_SRC(?I)[^\n]*\K '(?=#\+(?i)END_SRC)' ref ${ref}"
done
}

# Comment
add-highlighter shared/org/comment region (^|\h)\K#[^+] $ fill comment
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe a regex would be clearer here, e.g.

regex (^|\h)(#[^\n]+) 1:comment


# No-language SRC block
add-highlighter shared/org/src_block region ^(\h*)(?i)#\+BEGIN_SRC(\h+|\n) ^(\h*)(?i)#\+END_SRC\h*$ fill meta

# Example block
add-highlighter shared/org/example_block region ^(\h*)(?i)#\+BEGIN_EXAMPLE(\h+|\n) ^(\h*)(?i)#\+END_EXAMPLE\h*$ fill mono

# Small example block
add-highlighter shared/org/inline/text/example regex ^(\h*)[:]\h+[^\n]* 0:mono

# Unordered list items start with `-', `+', or `*'
add-highlighter shared/org/inline/text/unordered-lists regex ^(?:\h*)([-+])\h+ 1:bullet
# But `*' list must be indented with at least single space, if not it is treated as a heading
add-highlighter shared/org/inline/text/star-list regex ^(?:\h+)([*])\h+ 1:bullet

# Ordered list items start with a numeral followed by either a period or a right parenthesis, such as `1.' or `1)'
add-highlighter shared/org/inline/text/ordered-lists regex ^(?:\h*)(\d+[.)])\h+ 1:bullet

# Headings
add-highlighter shared/org/inline/text/heading regex "^[*]+\h+[^\n]+" 0:header
add-highlighter shared/org/inline/text/italic regex "\s([/][^\s/].*?[^\s/]*?[/])\W" 1:default,default+i
add-highlighter shared/org/inline/text/verbatim regex "\s([=][^\s=].*?[^\s=]*?[=])\W" 1:meta
andreyorst marked this conversation as resolved.
Show resolved Hide resolved
add-highlighter shared/org/inline/text/code regex "\s([~][^\s~].*?[^\s~]*?[~])\W" 1:mono
add-highlighter shared/org/inline/text/math regex "\s([$][^\s].*?[^\s]*?[$])\W" 1:mono
add-highlighter shared/org/inline/text/underlined regex "\s([_][^\s_].*?[^\s_]*?[_])\W" 1:default,default+u
add-highlighter shared/org/inline/text/bold regex "\s([*][^\s*].*?[^\s*]*?[*])\W" 1:default,default+b
andreyorst marked this conversation as resolved.
Show resolved Hide resolved
add-highlighter shared/org/inline/text/link regex "\[[^\n]+\]\]" 0:link
add-highlighter shared/org/inline/text/option regex "(?i)#\+[a-z]\w*\b" 0:meta

# Strikethrough highlighter is disabled because Kakoune doesn't support strikethrough attribute
# add-highlighter shared/org/inline/text/strikethrough regex "\W*\+[^\s][^\n+]+[^\s]\+\W" 0:default,default+s
andreyorst marked this conversation as resolved.
Show resolved Hide resolved

# Initialization
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾

hook -group org-highlight global WinSetOption filetype=org %{
add-highlighter window/org ref org
hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/org }
}