From e490a10620d8b9540ae97a824210adac7ba3c3e4 Mon Sep 17 00:00:00 2001 From: Vincent Siliakus Date: Fri, 5 May 2017 17:59:36 +0200 Subject: [PATCH 1/3] Vincent Siliakus Copyright Waiver I dedicate any and all copyright interest in this software to the public domain. I make this dedication for the benefit of the public at large and to the detriment of my heirs and successors. I intend this dedication to be an overt act of relinquishment in perpetuity of all present and future rights to this software under copyright law. From 848de57f20bfb920774dee8d2fe24df1bdae3536 Mon Sep 17 00:00:00 2001 From: Vincent Siliakus Date: Fri, 5 May 2017 18:01:07 +0200 Subject: [PATCH 2/3] Add Elixir highlighter --- rc/extra/elixir.kak | 85 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 rc/extra/elixir.kak diff --git a/rc/extra/elixir.kak b/rc/extra/elixir.kak new file mode 100644 index 000000000..3da43265b --- /dev/null +++ b/rc/extra/elixir.kak @@ -0,0 +1,85 @@ +# http://elixir-lang.org +# ---------------------- + +# Detection +# ‾‾‾‾‾‾‾‾‾ + +hook global BufCreate .*[.](ex|exs) %{ + set buffer filetype elixir +} + +# Faces +# ----- + +face ElixirAtom yellow +face ElixirUnderscore white+d +face ElixirAttribute green+d +face ElixirSpecialKeyword blue+b +face ElixirEnv red+b +face ElixirOperator rgb:a8a8a8 +face ElixirInterpolation rgb:00d7ff + +# Highlighters +# ‾‾‾‾‾‾‾‾‾‾‾‾ + +add-highlighter -group / regions -default code elixir \ + double_string '"' (?|<-|<<|>>|=>) 0:ElixirOperator +add-highlighter -group /elixir/code regex \b(require|alias|use|import)\b 0:ElixirSpecialKeyword +add-highlighter -group /elixir/code regex \b(__MODULE__|__DIR__|__ENV__|__CALLER__)\b 0:ElixirEnv +add-highlighter -group /elixir/code regex \b(def|defp|defmacro|defmacrop|defstruct|defmodule|defimpl|defprotocol|defoverridable)\b 0:keyword +add-highlighter -group /elixir/code regex \b(fn|do|end|case|if|else|unless|var!|for|cond|quote|unquote|receive|with|raise|reraise|try|catch)\b 0:keyword +add-highlighter -group /elixir/code regex '@[\w_]+\b' 0:ElixirAttribute +add-highlighter -group /elixir/code regex '\b\d+[\d_]*\b' 0:value + +# Commands +# ‾‾‾‾‾‾‾‾ + +def -hidden elixir-filter-around-selections %{ + # remove trailing white spaces + try %{ exec -draft -itersel s \h+$ d } +} + +def -hidden elixir-indent-on-new-line %{ + eval -draft -itersel %{ + # copy -- comments prefix and following white spaces + try %{ exec -draft k s ^\h*\K--\h* y gh j P } + # preserve previous line indent + try %{ exec -draft \; K } + # indent after line ending with: + # try %{ exec -draft k x (do|else|->)$ & } + # filter previous line + try %{ exec -draft k : elixir-filter-around-selections } + # indent after lines ending with do or -> + try %{ exec -draft \\; k x ^.+(do|->)$ j } + } +} + +# Initialization +# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ + +hook -group elixir-highlight global WinSetOption filetype=elixir %{ add-highlighter ref elixir } + +hook global WinSetOption filetype=elixir %{ + hook window InsertEnd .* -group elixir-hooks elixir-filter-around-selections + hook window InsertChar \n -group elixir-indent elixir-indent-on-new-line +} + +hook -group elixir-highlight global WinSetOption filetype=(?!elixir).* %{ remove-highlighter elixir } + From 812af8c886bc854bcdfc0553ffd320c0fbfe8267 Mon Sep 17 00:00:00 2001 From: Vincent Siliakus Date: Thu, 11 May 2017 18:40:07 +0200 Subject: [PATCH 3/3] Use only default faces --- rc/extra/elixir.kak | 31 +++++++++++-------------------- 1 file changed, 11 insertions(+), 20 deletions(-) diff --git a/rc/extra/elixir.kak b/rc/extra/elixir.kak index 3da43265b..a6a747e85 100644 --- a/rc/extra/elixir.kak +++ b/rc/extra/elixir.kak @@ -8,16 +8,6 @@ hook global BufCreate .*[.](ex|exs) %{ set buffer filetype elixir } -# Faces -# ----- - -face ElixirAtom yellow -face ElixirUnderscore white+d -face ElixirAttribute green+d -face ElixirSpecialKeyword blue+b -face ElixirEnv red+b -face ElixirOperator rgb:a8a8a8 -face ElixirInterpolation rgb:00d7ff # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ @@ -31,21 +21,22 @@ add-highlighter -group / regions -default code elixir \ add-highlighter -group /elixir/comment fill comment add-highlighter -group /elixir/double_string fill string add-highlighter -group /elixir/double_string regions regions interpolation \Q#{ \} \{ -add-highlighter -group /elixir/double_string/regions/interpolation fill ElixirInterpolation +add-highlighter -group /elixir/double_string/regions/interpolation fill builtin add-highlighter -group /elixir/single_string fill string -add-highlighter -group /elixir/code regex ':[\w_]+\b' 0:ElixirAtom -add-highlighter -group /elixir/code regex '[\w_]+:' 0:ElixirAtom +add-highlighter -group /elixir/code regex ':[\w_]+\b' 0:type +add-highlighter -group /elixir/code regex '[\w_]+:' 0:type add-highlighter -group /elixir/code regex '[A-Z][\w_]+\b' 0:module add-highlighter -group /elixir/code regex '(:[\w_]+)(\.)' 1:module -add-highlighter -group /elixir/code regex '\b_\b' 0:ElixirUnderscore -add-highlighter -group /elixir/code regex '\b_[\w_]+\b' 0:ElixirUnderscore +add-highlighter -group /elixir/code regex '\b_\b' 0:default +add-highlighter -group /elixir/code regex '\b_[\w_]+\b' 0:default +add-highlighter -group /elixir/code regex '~[a-zA-Z]\(.*\)' 0:string add-highlighter -group /elixir/code regex \b(true|false|nil)\b 0:value -add-highlighter -group /elixir/code regex (->|<-|<<|>>|=>) 0:ElixirOperator -add-highlighter -group /elixir/code regex \b(require|alias|use|import)\b 0:ElixirSpecialKeyword -add-highlighter -group /elixir/code regex \b(__MODULE__|__DIR__|__ENV__|__CALLER__)\b 0:ElixirEnv +add-highlighter -group /elixir/code regex (->|<-|<<|>>|=>) 0:builtin +add-highlighter -group /elixir/code regex \b(require|alias|use|import)\b 0:keyword +add-highlighter -group /elixir/code regex \b(__MODULE__|__DIR__|__ENV__|__CALLER__)\b 0:value add-highlighter -group /elixir/code regex \b(def|defp|defmacro|defmacrop|defstruct|defmodule|defimpl|defprotocol|defoverridable)\b 0:keyword -add-highlighter -group /elixir/code regex \b(fn|do|end|case|if|else|unless|var!|for|cond|quote|unquote|receive|with|raise|reraise|try|catch)\b 0:keyword -add-highlighter -group /elixir/code regex '@[\w_]+\b' 0:ElixirAttribute +add-highlighter -group /elixir/code regex \b(fn|do|end|when|case|if|else|unless|var!|for|cond|quote|unquote|receive|with|raise|reraise|try|catch)\b 0:keyword +add-highlighter -group /elixir/code regex '@[\w_]+\b' 0:attribute add-highlighter -group /elixir/code regex '\b\d+[\d_]*\b' 0:value # Commands