diff --git a/rc/filetype/R.kak b/rc/filetype/r.kak similarity index 76% rename from rc/filetype/R.kak rename to rc/filetype/r.kak index 5f7100eb..b5b6f6b5 100644 --- a/rc/filetype/R.kak +++ b/rc/filetype/r.kak @@ -5,23 +5,23 @@ # ‾‾‾‾‾‾‾‾‾ hook global BufCreate (.*/)?(\.Rprofile|.*\.[rR]) %{ - set-option buffer filetype R + set-option buffer filetype r } # Highlighters & Completion # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ -add-highlighter shared/R regions -add-highlighter shared/R/code default-region group -add-highlighter shared/R/double_string region '"' (?])>|<=|>=|==|!=|!|&{1,2}|\|{1,2}|~|\?) 0:operator +add-highlighter shared/r/code/ regex (?<=[\w\s\d'"_)])(\$|@|\^|-|\+|%[^%]+%|\*|/|<(?![<-])|(?])>|<=|>=|==|!=|!|&{1,2}|\|{1,2}|~|\?) 0:operator # Commands # ‾‾‾‾‾‾‾‾ -define-command -hidden R-trim-indent %{ +define-command -hidden r-trim-indent %{ # remove the line if it's empty when leaving the insert mode try %{ execute-keys -draft 1s^(\h+)$ d } } -define-command -hidden R-indent-on-newline %< evaluate-commands -draft -itersel %< +define-command -hidden r-indent-on-newline %< evaluate-commands -draft -itersel %< execute-keys \; try %< # if previous line closed a paren (possibly followed by words and a comment), @@ -91,12 +91,12 @@ define-command -hidden R-indent-on-newline %< evaluate-commands -draft -itersel > > > > -define-command -hidden R-indent-on-opening-curly-brace %[ +define-command -hidden r-indent-on-opening-curly-brace %[ # align indent with opening paren when { is entered on a new line after the closing paren try %[ execute-keys -draft -itersel h)M \A\(.*\)\h*\n\h*\{\z 1 ] ] -define-command -hidden R-indent-on-closing-curly-brace %[ +define-command -hidden r-indent-on-closing-curly-brace %[ # align to opening curly brace when alone on a line try %[ # in case open curly brace follows a closing paren, align indent with opening paren @@ -107,7 +107,7 @@ define-command -hidden R-indent-on-closing-curly-brace %[ ] catch %[] ] -define-command -hidden R-insert-on-newline %[ evaluate-commands -itersel -draft %[ +define-command -hidden r-insert-on-newline %[ evaluate-commands -itersel -draft %[ execute-keys \; try %[ evaluate-commands -draft -save-regs '/"' %[ @@ -127,17 +127,17 @@ define-command -hidden R-insert-on-newline %[ evaluate-commands -itersel -draft # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ -hook -group R-highlight global WinSetOption filetype=R %{ - add-highlighter window/R ref R - hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/R } +hook -group r-highlight global WinSetOption filetype=r %{ + add-highlighter window/r ref r + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/r } } -hook global WinSetOption filetype=R %~ - hook window ModeChange insert:.* R-trim-indent - hook window InsertChar \n R-insert-on-newline - hook window InsertChar \n R-indent-on-newline - hook window InsertChar \{ R-indent-on-opening-curly-brace - hook window InsertChar \} R-indent-on-closing-curly-brace +hook global WinSetOption filetype=r %~ + hook window ModeChange insert:.* r-trim-indent + hook window InsertChar \n r-insert-on-newline + hook window InsertChar \n r-indent-on-newline + hook window InsertChar \{ r-indent-on-opening-curly-brace + hook window InsertChar \} r-indent-on-closing-curly-brace - hook -once -always window WinSetOption filetype=.* %{ remove-hooks window R-.+ } + hook -once -always window WinSetOption filetype=.* %{ remove-hooks window r-.+ } ~