From ff7397b593f0604e24c6686f5bffcf18d7bedf05 Mon Sep 17 00:00:00 2001 From: tawsi-melek <34323926+tawsi-melek@users.github.com> Date: Mon, 5 Aug 2019 22:02:56 +0200 Subject: [PATCH 2/7] nim.kak: Add auto-indent after tuple and object Before: ```nim type MyType = tuple myint: int # This line needs to be indented manually ``` After: ```nim type MyType = tuple myint: int # Lines after 'tuple' are now indented automatically ``` --- rc/filetype/nim.kak | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rc/filetype/nim.kak b/rc/filetype/nim.kak index 1b9283cb..03ff61b5 100644 --- a/rc/filetype/nim.kak +++ b/rc/filetype/nim.kak @@ -110,8 +110,8 @@ def -hidden nim-indent-on-new-line %{ try %{ exec -draft \; K } # cleanup trailing whitespaces from previous line try %{ exec -draft k s \h+$ d } - # indent after line ending with type, import, export, const, let, var, ':' or '=' - try %{ exec -draft k x (:|=|const|let|var|import|export|type)$ j } + # indent after line ending with tuple, object, type, import, export, const, let, var, ':' or '=' + try %{ exec -draft k x (:|=|tuple|object|const|let|var|import|export|type)$ j } } } From 5ca0b9baa3e24404173f8a46733ba33a48d3ec21 Mon Sep 17 00:00:00 2001 From: tawsi-melek <34323926+tawsi-melek@users.github.com> Date: Tue, 6 Aug 2019 00:00:38 +0200 Subject: [PATCH 3/7] Enum too --- rc/filetype/nim.kak | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rc/filetype/nim.kak b/rc/filetype/nim.kak index 03ff61b5..a5dd3e3e 100644 --- a/rc/filetype/nim.kak +++ b/rc/filetype/nim.kak @@ -110,8 +110,8 @@ def -hidden nim-indent-on-new-line %{ try %{ exec -draft \; K } # cleanup trailing whitespaces from previous line try %{ exec -draft k s \h+$ d } - # indent after line ending with tuple, object, type, import, export, const, let, var, ':' or '=' - try %{ exec -draft k x (:|=|tuple|object|const|let|var|import|export|type)$ j } + # indent after line ending with enum, tuple, object, type, import, export, const, let, var, ':' or '=' + try %{ exec -draft k x (:|=|enum|tuple|object|const|let|var|import|export|type)$ j } } } From 93e64b4541a9b9c4fb135c9bce2ec930076365f7 Mon Sep 17 00:00:00 2001 From: tawsi-melek <34323926+tawsi-melek@users.github.com> Date: Thu, 8 Aug 2019 21:17:55 +0200 Subject: [PATCH 4/7] Some more improvements * Fix keywords in comments being highlighted * Highlight Nim's escape sequences for strings * Highlight common comment tags * Add on/off to the highlighted boolean values * Remove redundant regex highlighter for comments * Fix autoindent indenting lines more than it should --- rc/filetype/nim.kak | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/rc/filetype/nim.kak b/rc/filetype/nim.kak index a5dd3e3e..2917c6c5 100644 --- a/rc/filetype/nim.kak +++ b/rc/filetype/nim.kak @@ -37,8 +37,18 @@ add-highlighter shared/nim regions add-highlighter shared/nim/code default-region group add-highlighter shared/nim/triple_string region '([A-Za-z](_?\w)*)?"""' '"""(?!")' fill string add-highlighter shared/nim/raw_string region [A-Za-z](_?[A-Za-z])*" (? s \h+$ d } # indent after line ending with enum, tuple, object, type, import, export, const, let, var, ':' or '=' - try %{ exec -draft k x (:|=|enum|tuple|object|const|let|var|import|export|type)$ j } + try %{ exec -draft k (:|=|enum|tuple|object|const|let|var|import|export|type)$ j } } } From 1c58e5aa90f4afb668b8f624e2713e30ae699d7d Mon Sep 17 00:00:00 2001 From: tawsi-melek <34323926+tawsi-melek@users.github.com> Date: Thu, 8 Aug 2019 22:47:22 +0200 Subject: [PATCH 5/7] Improve single line comments * '#' now gets highlighted as a char literal * Remove highlighting for comment tags and escape sequences --- rc/filetype/nim.kak | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/rc/filetype/nim.kak b/rc/filetype/nim.kak index 2917c6c5..eb47375a 100644 --- a/rc/filetype/nim.kak +++ b/rc/filetype/nim.kak @@ -39,16 +39,11 @@ add-highlighter shared/nim/triple_string region '([A-Za-z](_?\w)*)?"""' '"""(?!" add-highlighter shared/nim/raw_string region [A-Za-z](_?[A-Za-z])*" (? Date: Mon, 12 Aug 2019 16:40:35 +0200 Subject: [PATCH 6/7] Fix some more edge cases * Adapt the char literal highlighter from c-family.kak * Fix line comment adjacent to char literal not being highlighted * Fix single quote terminating a double quote string --- rc/filetype/nim.kak | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/rc/filetype/nim.kak b/rc/filetype/nim.kak index eb47375a..4597a36f 100644 --- a/rc/filetype/nim.kak +++ b/rc/filetype/nim.kak @@ -37,9 +37,9 @@ add-highlighter shared/nim regions add-highlighter shared/nim/code default-region group add-highlighter shared/nim/triple_string region '([A-Za-z](_?\w)*)?"""' '"""(?!")' fill string add-highlighter shared/nim/raw_string region [A-Za-z](_?[A-Za-z])*" (? Date: Mon, 12 Aug 2019 17:17:20 +0200 Subject: [PATCH 7/7] Revert back to previous char literal highlighter as it's more precise --- rc/filetype/nim.kak | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rc/filetype/nim.kak b/rc/filetype/nim.kak index 4597a36f..c73d2b38 100644 --- a/rc/filetype/nim.kak +++ b/rc/filetype/nim.kak @@ -101,7 +101,7 @@ evaluate-commands %sh{ } add-highlighter shared/nim/code/ regex '(,|;|`|\(\.?|\.?\)|\[[.:]?|\.?\]|\{\.?|\.?\})' 0:meta -add-highlighter shared/nim/code/char regex %{\B'(\\x[0-9a-fA-F]{2}|\\"|(\\.)|[^'\\])'\B} 0:value +add-highlighter shared/nim/code/ regex %{'(\\([rcnlftvabe\\"']|0*[12]?\d?\d|x[0-9a-fA-F]{2})|[^'\n])'} 0:value # Commands # ‾‾‾‾‾‾‾‾