From e39dc5f0cb18794a33029ed40d306d24fb7ad0f4 Mon Sep 17 00:00:00 2001 From: xenia Date: Thu, 11 Jan 2024 20:31:59 +0100 Subject: [PATCH] Add patched version of kak-verilog --- home/kak.nix | 7 ++++ kak-verilog/verilog.kak | 79 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 86 insertions(+) create mode 100644 kak-verilog/verilog.kak diff --git a/home/kak.nix b/home/kak.nix index 2722c20d..71b003a7 100644 --- a/home/kak.nix +++ b/home/kak.nix @@ -12,6 +12,12 @@ with pkgs; let meta.homepage = "https://github.com/Delapouite/kakoune-mirror"; }; + kakoune-verilog = kakouneUtils.buildKakounePluginFrom2Nix { + pname = "kakoune-verilog"; + version = "latest"; + src = ../kak-verilog; + }; + ad-hoc-org-mode = kakouneUtils.buildKakounePluginFrom2Nix { pname = "ad-hoc-org-mode"; version = "latest"; @@ -75,6 +81,7 @@ in kakoune-mirror ad-hoc-org-mode + kakoune-verilog kakoune-lsp kak-tree diff --git a/kak-verilog/verilog.kak b/kak-verilog/verilog.kak new file mode 100644 index 00000000..cfc7b117 --- /dev/null +++ b/kak-verilog/verilog.kak @@ -0,0 +1,79 @@ +# Verilog for Kakoune +# stolen and modified from https://github.com/asyncial/kakoune-verilog/blob/master/verilog.kak +# this file is under the gnu license + +# Detection +hook global WinCreate .*\.v %{ + set-option window filetype verilog +} + +# Set up comments +hook global WinSetOption filetype=verilog %{ + set-option window comment_block_begin /* + set-option window comment_block_end */ + set-option window comment_line // +} + +# Highlighting +add-highlighter shared/verilog regions +add-highlighter shared/verilog/code default-region group +add-highlighter shared/verilog/string region '"' (? } + # indent after start structure + try %{ execute-keys -draft k ^ \h * (always|case|casex|casez|else|for|forever|if|repeat|while|begin|config|fork|function|generate|initial|join|macromodule|module|specify|task)\b|(do\h*$|(.*\h+do(\h+\|[^\n]*\|)?\h*$)) j } + try %{ + # previous line is empty, next is not + execute-keys -draft k 2X \A\n\n[^\n]+\n\z + # copy indent of next line + execute-keys -draft j s ^\h+ y k P + } + } +} + +# Initialization + +hook global WinSetOption filetype=verilog %{ + hook window InsertChar \n -group verilog-indent verilog-indent-on-new-line + add-highlighter window/verilog ref verilog + hook -once -always window WinSetOption filetype=(?!verilog).* %{ + remove-hooks window verilog-indent + remove-highlighter window/c + } +}