mirror of
https://github.com/mawww/kakoune.git
synced 2024-12-18 08:51:46 +03:00
Merge support for some additional languages from alexherbo2
* alexherbo2/lisp-rc * alexherbo2/clojure-rc * alexherbo2/haskell-rc * alexherbo2/scala-rc * alexherbo2/markdown-rc * alexherbo2/css-rc * alexherbo2/html-rc
This commit is contained in:
commit
de8b0f3b41
82
rc/cabal.kak
Normal file
82
rc/cabal.kak
Normal file
@ -0,0 +1,82 @@
|
||||
# http://haskell.org/cabal
|
||||
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
|
||||
|
||||
# Detection
|
||||
# ‾‾‾‾‾‾‾‾‾
|
||||
|
||||
hook global BufSetOption mimetype=text/x-cabal %{
|
||||
set buffer filetype cabal
|
||||
}
|
||||
|
||||
hook global BufCreate .*[.](cabal) %{
|
||||
set buffer filetype cabal
|
||||
}
|
||||
|
||||
# Highlighters
|
||||
# ‾‾‾‾‾‾‾‾‾‾‾‾
|
||||
|
||||
addhl -group / regions -default code cabal \
|
||||
comment (--) $ '' \
|
||||
comment \{- -\} \{-
|
||||
|
||||
addhl -group /cabal/comment fill comment
|
||||
|
||||
addhl -group /cabal/code regex \<(true|false)\>|(([<>]?=?)?\d+(\.\d+)+) 0:value
|
||||
addhl -group /cabal/code regex \<(if|else)\> 0:keyword
|
||||
addhl -group /cabal/code regex ^\h*([A-Za-z][A-Za-z0-9_-]*)\h*: 1:identifier
|
||||
|
||||
# Commands
|
||||
# ‾‾‾‾‾‾‾‾
|
||||
|
||||
def -hidden _cabal_filter_around_selections %{
|
||||
eval -draft -itersel %{
|
||||
exec <a-x>
|
||||
# remove trailing white spaces
|
||||
try %{ exec -draft s \h+$ <ret> d }
|
||||
}
|
||||
}
|
||||
|
||||
def -hidden _cabal_indent_on_new_line %[
|
||||
eval -draft -itersel %[
|
||||
# preserve previous line indent
|
||||
try %[ exec -draft <space> K <a-&> ]
|
||||
# filter previous line
|
||||
try %[ exec -draft k : _cabal_filter_around_selections <ret> ]
|
||||
# copy '#' comment prefix and following white spaces
|
||||
try %[ exec -draft k x s ^\h*\K#\h* <ret> y j p ]
|
||||
# indent after lines ending with { or :
|
||||
try %[ exec -draft <space> k x <a-k> [:{]$ <ret> j <a-gt> ]
|
||||
]
|
||||
]
|
||||
|
||||
def -hidden _cabal_indent_on_opening_curly_brace %[
|
||||
eval -draft -itersel %[
|
||||
# align indent with opening paren when { is entered on a new line after the closing paren
|
||||
try %[ exec -draft h <a-F> ) M <a-k> \`\(.*\)\h*\n\h*\{\' <ret> s \`|.\' <ret> 1<a-&> ]
|
||||
]
|
||||
]
|
||||
|
||||
def -hidden _cabal_indent_on_closing_curly_brace %[
|
||||
eval -draft -itersel %[
|
||||
# align to opening curly brace when alone on a line
|
||||
try %[ exec -draft <a-h> <a-k> ^\h+\}$ <ret> h m s \`|.\'<ret> 1<a-&> ]
|
||||
]
|
||||
]
|
||||
|
||||
# Initialization
|
||||
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾
|
||||
|
||||
hook global WinSetOption filetype=cabal %[
|
||||
addhl ref cabal
|
||||
|
||||
hook window InsertEnd .* -group cabal-hooks _cabal_filter_around_selections
|
||||
hook window InsertChar \n -group cabal-indent _cabal_indent_on_new_line
|
||||
hook window InsertChar \{ -group cabal-indent _cabal_indent_on_opening_curly_brace
|
||||
hook window InsertChar \} -group cabal-indent _cabal_indent_on_closing_curly_brace
|
||||
]
|
||||
|
||||
hook global WinSetOption filetype=(?!cabal).* %{
|
||||
rmhl cabal
|
||||
rmhooks window cabal-indent
|
||||
rmhooks window cabal-hooks
|
||||
}
|
46
rc/clojure.kak
Normal file
46
rc/clojure.kak
Normal file
@ -0,0 +1,46 @@
|
||||
# http://clojure.org
|
||||
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
|
||||
|
||||
# require lisp.kak
|
||||
|
||||
# Detection
|
||||
# ‾‾‾‾‾‾‾‾‾
|
||||
|
||||
hook global BufSetOption mimetype=text/x-clojure %{
|
||||
set buffer filetype clojure
|
||||
}
|
||||
|
||||
hook global BufCreate .*[.](clj) %{
|
||||
set buffer filetype clojure
|
||||
}
|
||||
|
||||
# Highlighters
|
||||
# ‾‾‾‾‾‾‾‾‾‾‾‾
|
||||
|
||||
addhl -group / group clojure
|
||||
|
||||
addhl -group /clojure ref lisp
|
||||
|
||||
addhl -group /clojure regex \<(clojure.core/['/\w]+)\> 0:keyword
|
||||
|
||||
# Commands
|
||||
# ‾‾‾‾‾‾‾‾
|
||||
|
||||
def -hidden _clojure_filter_around_selections _lisp_filter_around_selections
|
||||
def -hidden _clojure_indent_on_new_line _lisp_indent_on_new_line
|
||||
|
||||
# Initialization
|
||||
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾
|
||||
|
||||
hook global WinSetOption filetype=clojure %[
|
||||
addhl ref clojure
|
||||
|
||||
hook window InsertEnd .* -group clojure-hooks _clojure_filter_around_selections
|
||||
hook window InsertChar \n -group clojure-indent _clojure_indent_on_new_line
|
||||
]
|
||||
|
||||
hook global WinSetOption filetype=(?!clojure).* %{
|
||||
rmhl clojure
|
||||
rmhooks window clojure-indent
|
||||
rmhooks window clojure-hooks
|
||||
}
|
84
rc/css.kak
Normal file
84
rc/css.kak
Normal file
@ -0,0 +1,84 @@
|
||||
# http://w3.org/Style/CSS
|
||||
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
|
||||
|
||||
# Detection
|
||||
# ‾‾‾‾‾‾‾‾‾
|
||||
|
||||
hook global BufSetOption mimetype=text/x-css %{
|
||||
set buffer filetype css
|
||||
}
|
||||
|
||||
hook global BufCreate .*[.](css) %{
|
||||
set buffer filetype css
|
||||
}
|
||||
|
||||
# Highlighters
|
||||
# ‾‾‾‾‾‾‾‾‾‾‾‾
|
||||
|
||||
addhl -group / regions -default selector css \
|
||||
declaration [{] [}] '' \
|
||||
comment /[*] [*]/ ''
|
||||
|
||||
addhl -group /css/comment fill comment
|
||||
|
||||
addhl -group /css/declaration regions content \
|
||||
string '"' (?<!\\)(\\\\)*" '' \
|
||||
string "'" "'" ''
|
||||
|
||||
addhl -group /css/declaration/content/string fill string
|
||||
|
||||
addhl -group /css/declaration regex (#[0-9A-Fa-f]+)|((\d*\.)?\d+(em|px)) 0:value
|
||||
addhl -group /css/declaration regex ([A-Za-z][A-Za-z0-9_-]*)\h*: 1:keyword
|
||||
addhl -group /css/declaration regex :(before|after) 0:attribute
|
||||
addhl -group /css/declaration regex !important 0:keyword
|
||||
|
||||
# element#id element.class
|
||||
# universal selector
|
||||
addhl -group /css/selector regex [A-Za-z][A-Za-z0-9_-]* 0:keyword
|
||||
addhl -group /css/selector regex [*]|[#.][A-Za-z][A-Za-z0-9_-]* 0:identifier
|
||||
|
||||
# Commands
|
||||
# ‾‾‾‾‾‾‾‾
|
||||
|
||||
def -hidden _css_filter_around_selections %{
|
||||
eval -draft -itersel %{
|
||||
exec <a-x>
|
||||
# remove trailing white spaces
|
||||
try %{ exec -draft s \h+$ <ret> d }
|
||||
}
|
||||
}
|
||||
|
||||
def -hidden _css_indent_on_new_line %[
|
||||
eval -draft -itersel %[
|
||||
# preserve previous line indent
|
||||
try %[ exec -draft <space> K <a-&> ]
|
||||
# filter previous line
|
||||
try %[ exec -draft k : _css_filter_around_selections <ret> ]
|
||||
# indent after lines ending with with {
|
||||
try %[ exec -draft k x <a-k> \{$ <ret> j <a-gt> ]
|
||||
]
|
||||
]
|
||||
|
||||
def -hidden _css_indent_on_closing_curly_brace %[
|
||||
eval -draft -itersel %[
|
||||
# align to opening curly brace when alone on a line
|
||||
try %[ exec -draft <a-h> <a-k> ^\h+\}$ <ret> m s \`|.\' <ret> 1<a-&> ]
|
||||
]
|
||||
]
|
||||
|
||||
# Initialization
|
||||
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾
|
||||
|
||||
hook global WinSetOption filetype=css %[
|
||||
addhl ref css
|
||||
|
||||
hook window InsertEnd .* -group css-hooks _css_filter_around_selections
|
||||
hook window InsertChar \n -group css-indent _css_indent_on_new_line
|
||||
hook window InsertChar \} -group css-indent _css_indent_on_closing_curly_brace
|
||||
]
|
||||
|
||||
hook global WinSetOption filetype=(?!css).* %{
|
||||
rmhl css
|
||||
rmhooks window css-indent
|
||||
rmhooks window css-hooks
|
||||
}
|
75
rc/haskell.kak
Normal file
75
rc/haskell.kak
Normal file
@ -0,0 +1,75 @@
|
||||
# http://haskell.org
|
||||
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
|
||||
|
||||
# Detection
|
||||
# ‾‾‾‾‾‾‾‾‾
|
||||
|
||||
hook global BufSetOption mimetype=text/x-haskell %{
|
||||
set buffer filetype haskell
|
||||
}
|
||||
|
||||
hook global BufCreate .*[.](hs) %{
|
||||
set buffer filetype haskell
|
||||
}
|
||||
|
||||
# Highlighters
|
||||
# ‾‾‾‾‾‾‾‾‾‾‾‾
|
||||
|
||||
addhl -group / regions -default code haskell \
|
||||
string '"' (?<!\\)(\\\\)*" '' \
|
||||
comment (--) $ '' \
|
||||
comment \{- -\} \{- \
|
||||
macro ^\h*?\K# (?<!\\)\n ''
|
||||
|
||||
addhl -group /haskell/string fill string
|
||||
addhl -group /haskell/comment fill comment
|
||||
addhl -group /haskell/macro fill meta
|
||||
|
||||
addhl -group /haskell/code regex \<(import)\> 0:meta
|
||||
addhl -group /haskell/code regex \<(True|False)\> 0:value
|
||||
addhl -group /haskell/code regex \<(as|case|class|data|default|deriving|do|else|hiding|if|in|infix|infixl|infixr|instance|let|module|newtype|of|qualified|then|type|where)\> 0:keyword
|
||||
addhl -group /haskell/code regex \<(Int|Integer|Char|Bool|Float|Double|IO|Void|Addr|Array|String)\> 0:type
|
||||
|
||||
# Commands
|
||||
# ‾‾‾‾‾‾‾‾
|
||||
|
||||
# http://en.wikibooks.org/wiki/Haskell/Indentation
|
||||
|
||||
def -hidden _haskell_filter_around_selections %{
|
||||
eval -draft -itersel %{
|
||||
exec <a-x>
|
||||
# remove trailing white spaces
|
||||
try %{ exec -draft s \h+$ <ret> d }
|
||||
}
|
||||
}
|
||||
|
||||
def -hidden _haskell_indent_on_new_line %{
|
||||
eval -draft -itersel %{
|
||||
# preserve previous line indent
|
||||
try %{ exec -draft <space> K <a-&> }
|
||||
# align to first clause
|
||||
try %{ exec -draft <space> k x X s ^\h*(if|then|else)?\h*(([\w']+\h+)+=)?\h*(case\h+[\w']+\h+of|do|let|where)\h+\K.* <ret> s \`|.\' <ret> & }
|
||||
# filter previous line
|
||||
try %{ exec -draft k : _haskell_filter_around_selections <ret> }
|
||||
# copy -- comments prefix and following white spaces
|
||||
try %{ exec -draft k x s ^\h*\K--\h* <ret> y j p }
|
||||
# indent after lines beginning with condition or ending with expression or =(
|
||||
try %{ exec -draft <space> k x <a-k> ^\h*(if)|(case\h+[\w']+\h+of|do|let|where|[=(])$ <ret> j <a-gt> }
|
||||
}
|
||||
}
|
||||
|
||||
# Initialization
|
||||
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾
|
||||
|
||||
hook global WinSetOption filetype=haskell %{
|
||||
addhl ref haskell
|
||||
|
||||
hook window InsertEnd .* -group haskell-hooks _haskell_filter_around_selections
|
||||
hook window InsertChar \n -group haskell-indent _haskell_indent_on_new_line
|
||||
}
|
||||
|
||||
hook global WinSetOption filetype=(?!haskell).* %{
|
||||
rmhl haskell
|
||||
rmhooks window haskell-indent
|
||||
rmhooks window haskell-hooks
|
||||
}
|
81
rc/html.kak
Normal file
81
rc/html.kak
Normal file
@ -0,0 +1,81 @@
|
||||
# http://w3.org/html
|
||||
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
|
||||
|
||||
# Detection
|
||||
# ‾‾‾‾‾‾‾‾‾
|
||||
|
||||
hook global BufSetOption mimetype=text/x-html %{
|
||||
set buffer filetype html
|
||||
}
|
||||
|
||||
hook global BufCreate .*[.](html) %{
|
||||
set buffer filetype html
|
||||
}
|
||||
|
||||
# Highlighters
|
||||
# ‾‾‾‾‾‾‾‾‾‾‾‾
|
||||
|
||||
addhl -group / regions html \
|
||||
comment <!-- --> '' \
|
||||
tag < > '' \
|
||||
style <style\>.*?>\K (?=</style>) '' \
|
||||
script <script\>.*?>\K (?=</script>) ''
|
||||
|
||||
addhl -group /html/comment fill comment
|
||||
|
||||
addhl -group /html/style ref css
|
||||
addhl -group /html/script ref javascript
|
||||
|
||||
addhl -group /html/tag regex </?(\w+) 1:keyword
|
||||
|
||||
addhl -group /html/tag regions content \
|
||||
string '"' (?<!\\)(\\\\)*" '' \
|
||||
string "'" "'" ''
|
||||
|
||||
addhl -group /html/tag/content/string fill string
|
||||
|
||||
# Commands
|
||||
# ‾‾‾‾‾‾‾‾
|
||||
|
||||
def -hidden _html_filter_around_selections %{
|
||||
eval -draft -itersel %{
|
||||
exec <a-x>
|
||||
# remove trailing white spaces
|
||||
try %{ exec -draft s \h+$ <ret> d }
|
||||
}
|
||||
}
|
||||
|
||||
def -hidden _html_indent_on_char %{
|
||||
eval -draft -itersel %{
|
||||
# align closing tag to opening when alone on a line
|
||||
try %{ exec -draft <space> <a-h> s ^\h+</(\w+)>$ <ret> <a-\;> <a-?> <lt><c-r>1 <ret> s \`|.\' <ret> <a-r> 1<a-&> }
|
||||
}
|
||||
}
|
||||
|
||||
def -hidden _html_indent_on_new_line %{
|
||||
eval -draft -itersel %{
|
||||
# preserve previous line indent
|
||||
try %{ exec -draft <space> K <a-&> }
|
||||
# filter previous line
|
||||
try %{ exec -draft k : _html_filter_around_selections <ret> }
|
||||
# indent after lines ending with opening tag
|
||||
try %{ exec -draft k x <a-k> <[^/][^>]+>$ <ret> j <a-gt> }
|
||||
}
|
||||
}
|
||||
|
||||
# Initialization
|
||||
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾
|
||||
|
||||
hook global WinSetOption filetype=html %{
|
||||
addhl ref html
|
||||
|
||||
hook window InsertEnd .* -group html-hooks _html_filter_around_selections
|
||||
hook window InsertChar .* -group html-indent _html_indent_on_char
|
||||
hook window InsertChar \n -group html-indent _html_indent_on_new_line
|
||||
}
|
||||
|
||||
hook global WinSetOption filetype=(?!html).* %{
|
||||
rmhl html
|
||||
rmhooks window html-indent
|
||||
rmhooks window html-hooks
|
||||
}
|
64
rc/lisp.kak
Normal file
64
rc/lisp.kak
Normal file
@ -0,0 +1,64 @@
|
||||
# http://common-lisp.net
|
||||
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
|
||||
|
||||
# Detection
|
||||
# ‾‾‾‾‾‾‾‾‾
|
||||
|
||||
hook global BufSetOption mimetype=text/x-lisp %{
|
||||
set buffer filetype lisp
|
||||
}
|
||||
|
||||
hook global BufCreate .*[.](lisp) %{
|
||||
set buffer filetype lisp
|
||||
}
|
||||
|
||||
# Highlighters
|
||||
# ‾‾‾‾‾‾‾‾‾‾‾‾
|
||||
|
||||
addhl -group / regions -default code lisp \
|
||||
string '"' (?<!\\)(\\\\)*" '' \
|
||||
comment ';' '$' ''
|
||||
|
||||
addhl -group /lisp/string fill string
|
||||
addhl -group /lisp/comment fill comment
|
||||
|
||||
addhl -group /lisp/code regex \<(nil|true|false)\> 0:value
|
||||
addhl -group /lisp/code regex (((\Q***\E)|(///)|(\Q+++\E)){1,3})|(1[+-])|(<|>|<=|=|>=|) 0:operator
|
||||
addhl -group /lisp/code regex \<(([':]\w+)|([*]\H+[*]))\> 0:identifier
|
||||
addhl -group /lisp/code regex \<(def[a-z]+|if|do|let|lambda|catch|and|assert|while|def|do|fn|finally|let|loop|new|quote|recur|set!|throw|try|var|case|if-let|if-not|when|when-first|when-let|when-not|(cond(->|->>)?))\> 0:keyword
|
||||
|
||||
# Commands
|
||||
# ‾‾‾‾‾‾‾‾
|
||||
|
||||
def -hidden _lisp_filter_around_selections %{
|
||||
eval -draft -itersel %{
|
||||
exec <a-x>
|
||||
# remove trailing white spaces
|
||||
try %{ exec -draft s \h+$ <ret> d }
|
||||
}
|
||||
}
|
||||
|
||||
def -hidden _lisp_indent_on_new_line %{
|
||||
eval -draft -itersel %{
|
||||
# preserve previous line indent
|
||||
try %{ exec -draft <space> K <a-&> }
|
||||
# indent when matches opening paren
|
||||
try %{ exec -draft [( <a-k> \`\([^\n]+\n[^\n]*\n?\' <ret> <a-\;> \; <a-gt> }
|
||||
}
|
||||
}
|
||||
|
||||
# Initialization
|
||||
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾
|
||||
|
||||
hook global WinSetOption filetype=lisp %{
|
||||
addhl ref lisp
|
||||
|
||||
hook window InsertEnd .* -group lisp-hooks _lisp_filter_around_selections
|
||||
hook window InsertChar \n -group lisp-indent _lisp_indent_on_new_line
|
||||
}
|
||||
|
||||
hook global WinSetOption filetype=(?!lisp).* %{
|
||||
rmhl lisp
|
||||
rmhooks window lisp-indent
|
||||
rmhooks window lisp-hooks
|
||||
}
|
84
rc/markdown.kak
Normal file
84
rc/markdown.kak
Normal file
@ -0,0 +1,84 @@
|
||||
# http://daringfireball.net/projects/markdown
|
||||
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
|
||||
|
||||
# Detection
|
||||
# ‾‾‾‾‾‾‾‾‾
|
||||
|
||||
hook global BufSetOption mimetype=text/x-markdown %{
|
||||
set buffer filetype markdown
|
||||
}
|
||||
|
||||
hook global BufCreate .*[.](markdown|md) %{
|
||||
set buffer filetype markdown
|
||||
}
|
||||
|
||||
# Highlighters
|
||||
# ‾‾‾‾‾‾‾‾‾‾‾‾
|
||||
|
||||
addhl -group / regions -default content markdown \
|
||||
sh ```sh ``` '' \
|
||||
fish ```fish ``` '' \
|
||||
ruby ```ruby ``` '' \
|
||||
code ``` ``` '' \
|
||||
code `` `` '' \
|
||||
code ` ` ''
|
||||
|
||||
addhl -group /markdown/code fill meta
|
||||
|
||||
addhl -group /markdown/sh ref sh
|
||||
addhl -group /markdown/fish ref fish
|
||||
addhl -group /markdown/ruby ref ruby
|
||||
|
||||
# Setext-style header
|
||||
addhl -group /markdown/content regex (\A|\n\n)[^\n]+\n={2,}\h*\n\h*$ 0:blue
|
||||
addhl -group /markdown/content regex (\A|\n\n)[^\n]+\n-{2,}\h*\n\h*$ 0:cyan
|
||||
|
||||
# Atx-style header
|
||||
addhl -group /markdown/content regex ^(#+)(\h+)([^\n]+) 1:red
|
||||
|
||||
addhl -group /markdown/content regex ^\h+([-\*])\h+[^\n]*(\n\h+[^-\*]\S+[^\n]*)*$ 0:yellow 1:cyan
|
||||
addhl -group /markdown/content regex ^([-=~]+)\n[^\n\h].*?\n\1$ 0:magenta
|
||||
addhl -group /markdown/content regex (?<!\w)\+[^\n]+?\+(?!\w) 0:green
|
||||
addhl -group /markdown/content regex (?<!\w)_[^\n]+?_(?!\w) 0:yellow
|
||||
addhl -group /markdown/content regex (?<!\w)\*[^\n]+?\*(?!\w) 0:red
|
||||
addhl -group /markdown/content regex <[a-z]+://.*?> 0:cyan
|
||||
addhl -group /markdown/content regex ^\h*(>\h*)+ 0:comment
|
||||
addhl -group /markdown/content regex \H\K\h\h$ 0:PrimarySelection
|
||||
|
||||
# Commands
|
||||
# ‾‾‾‾‾‾‾‾
|
||||
|
||||
def -hidden _markdown_filter_around_selections %{
|
||||
eval -draft -itersel %{
|
||||
exec <a-x>
|
||||
# remove trailing white spaces
|
||||
try %{ exec -draft s \h+$ <ret> d }
|
||||
}
|
||||
}
|
||||
|
||||
def -hidden _markdown_indent_on_new_line %{
|
||||
eval -draft -itersel %{
|
||||
# preserve previous line indent
|
||||
try %{ exec -draft <space> K <a-&> }
|
||||
# filter previous line
|
||||
try %{ exec -draft k : _markdown_filter_around_selections <ret> }
|
||||
# copy block quote(s), list item prefix and following white spaces
|
||||
try %{ exec -draft k x s ^\h*\K((>\h*)|[*+-])+\h* <ret> y j p }
|
||||
}
|
||||
}
|
||||
|
||||
# Initialization
|
||||
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾
|
||||
|
||||
hook global WinSetOption filetype=markdown %{
|
||||
addhl ref markdown
|
||||
|
||||
hook window InsertEnd .* -group markdown-hooks _markdown_filter_around_selections
|
||||
hook window InsertChar \n -group markdown-indent _markdown_indent_on_new_line
|
||||
}
|
||||
|
||||
hook global WinSetOption filetype=(?!markdown).* %{
|
||||
rmhl markdown
|
||||
rmhooks window markdown-indent
|
||||
rmhooks window markdown-hooks
|
||||
}
|
84
rc/scala.kak
Normal file
84
rc/scala.kak
Normal file
@ -0,0 +1,84 @@
|
||||
# http://scala-lang.org
|
||||
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
|
||||
|
||||
# Detection
|
||||
# ‾‾‾‾‾‾‾‾‾
|
||||
|
||||
hook global BufSetOption mimetype=text/x-scala %{
|
||||
set buffer filetype scala
|
||||
}
|
||||
|
||||
hook global BufCreate .*[.](scala) %{
|
||||
set buffer filetype scala
|
||||
}
|
||||
|
||||
# Highlighters
|
||||
# ‾‾‾‾‾‾‾‾‾‾‾‾
|
||||
|
||||
addhl -group / regions -default code scala \
|
||||
string '"' (?<!\\)(\\\\)*" '' \
|
||||
literal ` ` '' \
|
||||
comment // $ '' \
|
||||
comment /[*] [*]/ /[*]
|
||||
|
||||
addhl -group /scala/string fill string
|
||||
addhl -group /scala/literal fill identifier
|
||||
addhl -group /scala/comment fill comment
|
||||
|
||||
# Keywords are collected at
|
||||
# http://tutorialspoint.com/scala/scala_basic_syntax.htm
|
||||
|
||||
addhl -group /scala/code regex \<(import|package)\> 0:meta
|
||||
addhl -group /scala/code regex \<(this|true|false|null)\> 0:value
|
||||
addhl -group /scala/code regex \<(become|case|catch|class|def|do|else|extends|final|finally|for|forSome|goto|if|initialize|macro|match|new|object|onTransition|return|startWith|stay|throw|trait|try|unbecome|using|val|var|when|while|with|yield)\> 0:keyword
|
||||
addhl -group /scala/code regex \<(abstract|final|implicit|implicitly|lazy|override|private|protected|require|sealed|super)\> 0:attribute
|
||||
addhl -group /scala/code regex \<(⇒|=>|<:|:>|=:=|::|&&|\|\|)\> 0:operator
|
||||
addhl -group /scala/code regex "'[_A-Za-z0-9$]+" 0:identifier
|
||||
|
||||
# Commands
|
||||
# ‾‾‾‾‾‾‾‾
|
||||
|
||||
def -hidden _scala_filter_around_selections %{
|
||||
eval -draft -itersel %{
|
||||
exec <a-x>
|
||||
# remove trailing white spaces
|
||||
try %{ exec -draft s \h+$ <ret> d }
|
||||
}
|
||||
}
|
||||
|
||||
def -hidden _scala_indent_on_new_line %[
|
||||
eval -draft -itersel %[
|
||||
# preserve previous line indent
|
||||
try %[ exec -draft <space> K <a-&> ]
|
||||
# filter previous line
|
||||
try %[ exec -draft k : _scala_filter_around_selections <ret> ]
|
||||
# copy // comments prefix and following white spaces
|
||||
try %[ exec -draft k x s ^\h*\K#\h* <ret> y j p ]
|
||||
# indent after lines ending with {
|
||||
try %[ exec -draft k x <a-k> \{$ <ret> j <a-gt> ]
|
||||
]
|
||||
]
|
||||
|
||||
def -hidden _scala_indent_on_closing_curly_brace %[
|
||||
eval -draft -itersel %[
|
||||
# align to opening curly brace when alone on a line
|
||||
try %[ exec -draft <a-h> <a-k> ^\h+\}$ <ret> m s \`|.\' <ret> 1<a-&> ]
|
||||
]
|
||||
]
|
||||
|
||||
# Initialization
|
||||
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾
|
||||
|
||||
hook global WinSetOption filetype=scala %[
|
||||
addhl ref scala
|
||||
|
||||
hook window InsertEnd .* -group scala-hooks _scala_filter_around_selections
|
||||
hook window InsertChar \n -group scala-indent _scala_indent_on_new_line
|
||||
hook window InsertChar \} -group scala-indent _scala_indent_on_closing_curly_brace
|
||||
]
|
||||
|
||||
hook global WinSetOption filetype=(?!scala).* %{
|
||||
rmhl scala
|
||||
rmhooks window scala-indent
|
||||
rmhooks window scala-hooks
|
||||
}
|
Loading…
Reference in New Issue
Block a user