diff --git a/modules/programs/kakoune.nix b/modules/programs/kakoune.nix index d2fd8eb1..3c234915 100644 --- a/modules/programs/kakoune.nix +++ b/modules/programs/kakoune.nix @@ -506,12 +506,22 @@ let ]; showWhitespaceOptions = with cfg.config.showWhitespace; - concatStrings [ - (optionalString (tab != null) " -tab ${tab}") - (optionalString (tabStop != null) " -tabpad ${tabStop}") - (optionalString (space != null) " -spc ${space}") - (optionalString (nonBreakingSpace != null) " -nbsp ${nonBreakingSpace}") - (optionalString (lineFeed != null) " -lf ${lineFeed}") + let + quoteSep = sep: + if sep == "'" then + ''"'"'' + else if lib.strings.stringLength sep == 1 then + "'${sep}'" + else + sep; # backwards compat, in case sep == "' '", etc. + + in concatStrings [ + (optionalString (tab != null) " -tab ${quoteSep tab}") + (optionalString (tabStop != null) " -tabpad ${quoteSep tabStop}") + (optionalString (space != null) " -spc ${quoteSep space}") + (optionalString (nonBreakingSpace != null) + " -nbsp ${quoteSep nonBreakingSpace}") + (optionalString (lineFeed != null) " -lf ${quoteSep lineFeed}") ]; uiOptions = with cfg.config.ui; diff --git a/tests/modules/programs/kakoune/default.nix b/tests/modules/programs/kakoune/default.nix index 9d88abf4..9f906a94 100644 --- a/tests/modules/programs/kakoune/default.nix +++ b/tests/modules/programs/kakoune/default.nix @@ -1 +1,5 @@ -{ kakoune-whitespace-highlighter = ./whitespace-highlighter.nix; } +{ + kakoune-whitespace-highlighter = ./whitespace-highlighter.nix; + kakoune-whitespace-highlighter-corner-cases = + ./whitespace-highlighter-corner-cases.nix; +} diff --git a/tests/modules/programs/kakoune/whitespace-highlighter-corner-cases.nix b/tests/modules/programs/kakoune/whitespace-highlighter-corner-cases.nix new file mode 100644 index 00000000..142aaac8 --- /dev/null +++ b/tests/modules/programs/kakoune/whitespace-highlighter-corner-cases.nix @@ -0,0 +1,25 @@ +{ config, lib, pkgs, ... }: + +with lib; + +{ + config = { + programs.kakoune = { + enable = true; + config.showWhitespace = { + enable = true; + lineFeed = ''"''; + space = " "; + nonBreakingSpace = "' '"; # backwards compat + tab = "'"; + # tabStop = + }; + }; + + nmt.script = '' + assertFileExists home-files/.config/kak/kakrc + assertFileContains home-files/.config/kak/kakrc \ + "add-highlighter global/ show-whitespaces -tab \"'\" -spc ' ' -nbsp ' ' -lf '\"'" + ''; + }; +} diff --git a/tests/modules/programs/kakoune/whitespace-highlighter.nix b/tests/modules/programs/kakoune/whitespace-highlighter.nix index edeb6b52..514c26a1 100644 --- a/tests/modules/programs/kakoune/whitespace-highlighter.nix +++ b/tests/modules/programs/kakoune/whitespace-highlighter.nix @@ -19,7 +19,7 @@ with lib; nmt.script = '' assertFileExists home-files/.config/kak/kakrc assertFileContains home-files/.config/kak/kakrc \ - "add-highlighter global/ show-whitespaces -tab 4 -tabpad 5 -spc 2 -nbsp 3 -lf 1" + "add-highlighter global/ show-whitespaces -tab '4' -tabpad '5' -spc '2' -nbsp '3' -lf '1'" ''; }; }