mirror of
https://github.com/nix-community/home-manager
synced 2024-11-30 08:30:41 +00:00
kakoune: escape showWhitespace separators
We were passing the separators for the `show-whitespaces` highlighter verbatim. This was problematic in case one wanted to use, spaces, quotes or `%` as separators since the resulting kakoune configuration would be invalid. According to kakoune's docs, the separator has to be one character long, so we can use a simple rule for escaping them. It is possible that people has been working this around by passing, e.g. `"' '"` as separator in order to get a space (i.e., escaped explicitly by the user), so we just let longer strings be used verbatim. PR #1357
This commit is contained in:
parent
861690ff29
commit
d1f4d1514d
4 changed files with 47 additions and 8 deletions
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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 = <default>
|
||||
};
|
||||
};
|
||||
|
||||
nmt.script = ''
|
||||
assertFileExists home-files/.config/kak/kakrc
|
||||
assertFileContains home-files/.config/kak/kakrc \
|
||||
"add-highlighter global/ show-whitespaces -tab \"'\" -spc ' ' -nbsp ' ' -lf '\"'"
|
||||
'';
|
||||
};
|
||||
}
|
|
@ -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'"
|
||||
'';
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue