2019-03-21 19:38:55 +01:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
cfg = config.programs.kakoune;
|
|
|
|
|
|
|
|
hook = types.submodule {
|
|
|
|
options = {
|
|
|
|
name = mkOption {
|
|
|
|
type = types.enum [
|
2020-02-02 00:39:17 +01:00
|
|
|
"NormalIdle"
|
|
|
|
"NormalKey"
|
|
|
|
"InsertIdle"
|
|
|
|
"InsertKey"
|
|
|
|
"InsertChar"
|
|
|
|
"InsertDelete"
|
|
|
|
"InsertMove"
|
|
|
|
"WinCreate"
|
|
|
|
"WinClose"
|
|
|
|
"WinResize"
|
|
|
|
"WinDisplay"
|
|
|
|
"WinSetOption"
|
|
|
|
"BufSetOption"
|
|
|
|
"BufNewFile"
|
|
|
|
"BufOpenFile"
|
|
|
|
"BufCreate"
|
|
|
|
"BufWritePre"
|
|
|
|
"BufWritePost"
|
|
|
|
"BufReload"
|
|
|
|
"BufClose"
|
|
|
|
"BufOpenFifo"
|
|
|
|
"BufReadFifo"
|
|
|
|
"BufCloseFifo"
|
|
|
|
"RuntimeError"
|
|
|
|
"ModeChange"
|
|
|
|
"PromptIdle"
|
|
|
|
"GlobalSetOption"
|
|
|
|
"KakBegin"
|
|
|
|
"KakEnd"
|
|
|
|
"FocusIn"
|
|
|
|
"FocusOut"
|
|
|
|
"RawKey"
|
|
|
|
"InsertCompletionShow"
|
|
|
|
"InsertCompletionHide"
|
2020-04-22 23:18:23 +02:00
|
|
|
"ModuleLoaded"
|
2022-12-29 13:42:24 +01:00
|
|
|
"ClientCreate"
|
|
|
|
"ClientClose"
|
|
|
|
"RegisterModified"
|
|
|
|
"User"
|
2019-03-21 19:38:55 +01:00
|
|
|
];
|
|
|
|
example = "SetOption";
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2019-03-21 19:38:55 +01:00
|
|
|
The name of the hook. For a description, see
|
2023-07-01 01:30:13 +02:00
|
|
|
<https://github.com/mawww/kakoune/blob/master/doc/pages/hooks.asciidoc#default-hooks>.
|
2019-03-21 19:38:55 +01:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
once = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2019-03-21 19:38:55 +01:00
|
|
|
Remove the hook after running it once.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
group = mkOption {
|
|
|
|
type = types.nullOr types.str;
|
|
|
|
default = null;
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2019-03-21 19:38:55 +01:00
|
|
|
Add the hook to the named group.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
option = mkOption {
|
|
|
|
type = types.nullOr types.str;
|
|
|
|
default = null;
|
|
|
|
example = "filetype=latex";
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2019-03-21 19:38:55 +01:00
|
|
|
Additional option to pass to the hook.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
commands = mkOption {
|
|
|
|
type = types.lines;
|
|
|
|
default = "";
|
|
|
|
example = "set-option window indentwidth 2";
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2019-03-21 19:38:55 +01:00
|
|
|
Commands to run when the hook is activated.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
keyMapping = types.submodule {
|
|
|
|
options = {
|
|
|
|
mode = mkOption {
|
2020-07-03 22:43:18 +02:00
|
|
|
type = types.str;
|
2019-03-21 19:38:55 +01:00
|
|
|
example = "user";
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2019-03-21 19:38:55 +01:00
|
|
|
The mode in which the mapping takes effect.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
docstring = mkOption {
|
|
|
|
type = types.nullOr types.str;
|
|
|
|
default = null;
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2019-03-21 19:38:55 +01:00
|
|
|
Optional documentation text to display in info boxes.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
key = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
example = "<a-x>";
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2019-03-21 19:38:55 +01:00
|
|
|
The key to be mapped. See
|
2023-07-01 01:30:13 +02:00
|
|
|
<https://github.com/mawww/kakoune/blob/master/doc/pages/mapping.asciidoc#mappable-keys>
|
2019-03-21 19:38:55 +01:00
|
|
|
for possible values.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
effect = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
example = ":wq<ret>";
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2019-03-21 19:38:55 +01:00
|
|
|
The sequence of keys to be mapped.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
configModule = types.submodule {
|
|
|
|
options = {
|
|
|
|
colorScheme = mkOption {
|
|
|
|
type = types.nullOr types.str;
|
|
|
|
default = null;
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2019-03-21 19:38:55 +01:00
|
|
|
Set the color scheme. To see available schemes, enter
|
2023-07-01 01:30:13 +02:00
|
|
|
{command}`colorscheme` at the kakoune prompt.
|
2019-03-21 19:38:55 +01:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
tabStop = mkOption {
|
|
|
|
type = types.nullOr types.ints.unsigned;
|
|
|
|
default = null;
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2019-03-21 19:38:55 +01:00
|
|
|
The width of a tab in spaces. The kakoune default is
|
2023-07-01 01:30:13 +02:00
|
|
|
`6`.
|
2019-03-21 19:38:55 +01:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
indentWidth = mkOption {
|
|
|
|
type = types.nullOr types.ints.unsigned;
|
|
|
|
default = null;
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2019-03-21 19:38:55 +01:00
|
|
|
The width of an indentation in spaces.
|
2023-07-01 01:30:13 +02:00
|
|
|
The kakoune default is `4`.
|
|
|
|
If `0`, a tab will be used instead.
|
2019-03-21 19:38:55 +01:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
incrementalSearch = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = true;
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2019-03-21 19:38:55 +01:00
|
|
|
Execute a search as it is being typed.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
alignWithTabs = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2019-03-21 19:38:55 +01:00
|
|
|
Use tabs for the align command.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
autoInfo = mkOption {
|
2020-02-02 00:39:17 +01:00
|
|
|
type = types.nullOr
|
|
|
|
(types.listOf (types.enum [ "command" "onkey" "normal" ]));
|
2019-03-21 19:38:55 +01:00
|
|
|
default = null;
|
|
|
|
example = [ "command" "normal" ];
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2019-03-21 19:38:55 +01:00
|
|
|
Contexts in which to display automatic information box.
|
2023-07-01 01:30:13 +02:00
|
|
|
The kakoune default is `[ "command" "onkey" ]`.
|
2019-03-21 19:38:55 +01:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
autoComplete = mkOption {
|
2020-02-02 00:39:17 +01:00
|
|
|
type = types.nullOr (types.listOf (types.enum [ "insert" "prompt" ]));
|
2019-03-21 19:38:55 +01:00
|
|
|
default = null;
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2019-03-21 19:38:55 +01:00
|
|
|
Modes in which to display possible completions.
|
2023-07-01 01:30:13 +02:00
|
|
|
The kakoune default is `[ "insert" "prompt" ]`.
|
2019-03-21 19:38:55 +01:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
autoReload = mkOption {
|
|
|
|
type = types.nullOr (types.enum [ "yes" "no" "ask" ]);
|
|
|
|
default = null;
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2019-03-21 19:38:55 +01:00
|
|
|
Reload buffers when an external modification is detected.
|
2023-07-01 01:30:13 +02:00
|
|
|
The kakoune default is `"ask"`.
|
2019-03-21 19:38:55 +01:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
scrollOff = mkOption {
|
|
|
|
type = types.nullOr (types.submodule {
|
|
|
|
options = {
|
|
|
|
lines = mkOption {
|
|
|
|
type = types.ints.unsigned;
|
|
|
|
default = 0;
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2019-03-21 19:38:55 +01:00
|
|
|
The number of lines to keep visible around the cursor.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
columns = mkOption {
|
|
|
|
type = types.ints.unsigned;
|
|
|
|
default = 0;
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2019-03-21 19:38:55 +01:00
|
|
|
The number of columns to keep visible around the cursor.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
});
|
|
|
|
default = null;
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2019-03-21 19:38:55 +01:00
|
|
|
How many lines and columns to keep visible around the cursor.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
ui = mkOption {
|
|
|
|
type = types.nullOr (types.submodule {
|
|
|
|
options = {
|
|
|
|
setTitle = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2019-03-21 19:38:55 +01:00
|
|
|
Change the title of the terminal emulator.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
statusLine = mkOption {
|
|
|
|
type = types.enum [ "top" "bottom" ];
|
|
|
|
default = "bottom";
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2019-03-21 19:38:55 +01:00
|
|
|
Where to display the status line.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
assistant = mkOption {
|
|
|
|
type = types.enum [ "clippy" "cat" "dilbert" "none" ];
|
|
|
|
default = "clippy";
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2019-03-21 19:38:55 +01:00
|
|
|
The assistant displayed in info boxes.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
enableMouse = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2019-03-21 19:38:55 +01:00
|
|
|
Whether to enable mouse support.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
changeColors = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = true;
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2019-03-21 19:38:55 +01:00
|
|
|
Change color palette.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
wheelDownButton = mkOption {
|
|
|
|
type = types.nullOr types.str;
|
|
|
|
default = null;
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2019-03-21 19:38:55 +01:00
|
|
|
Button to send for wheel down events.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
wheelUpButton = mkOption {
|
|
|
|
type = types.nullOr types.str;
|
|
|
|
default = null;
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2019-03-21 19:38:55 +01:00
|
|
|
Button to send for wheel up events.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
shiftFunctionKeys = mkOption {
|
|
|
|
type = types.nullOr types.ints.unsigned;
|
|
|
|
default = null;
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2019-03-21 19:38:55 +01:00
|
|
|
Amount by which shifted function keys are offset. That
|
|
|
|
is, if the terminal sends F13 for Shift-F1, this
|
2023-07-01 01:30:13 +02:00
|
|
|
should be `12`.
|
2019-03-21 19:38:55 +01:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
useBuiltinKeyParser = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2019-03-21 19:38:55 +01:00
|
|
|
Bypass ncurses key parser and use an internal one.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
});
|
|
|
|
default = null;
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2019-03-21 19:38:55 +01:00
|
|
|
Settings for the ncurses interface.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
showMatching = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2019-03-21 19:38:55 +01:00
|
|
|
Highlight the matching char of the character under the
|
2023-07-01 01:30:13 +02:00
|
|
|
selections' cursor using the `MatchingChar`
|
2019-03-21 19:38:55 +01:00
|
|
|
face.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
wrapLines = mkOption {
|
|
|
|
type = types.nullOr (types.submodule {
|
|
|
|
options = {
|
2023-07-02 01:45:18 +02:00
|
|
|
enable = mkEnableOption "the wrap lines highlighter";
|
2019-03-21 19:38:55 +01:00
|
|
|
|
|
|
|
word = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2019-03-21 19:38:55 +01:00
|
|
|
Wrap at word boundaries instead of codepoint boundaries.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
indent = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2019-03-21 19:38:55 +01:00
|
|
|
Preserve line indentation when wrapping.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
maxWidth = mkOption {
|
|
|
|
type = types.nullOr types.ints.unsigned;
|
|
|
|
default = null;
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2019-03-21 19:38:55 +01:00
|
|
|
Wrap text at maxWidth, even if the window is wider.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
marker = mkOption {
|
|
|
|
type = types.nullOr types.str;
|
|
|
|
default = null;
|
|
|
|
example = "⏎";
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2019-03-21 19:38:55 +01:00
|
|
|
Prefix wrapped lines with marker text.
|
2023-07-01 01:30:13 +02:00
|
|
|
If not `null`,
|
2019-03-21 19:38:55 +01:00
|
|
|
the marker text will be displayed in the indentation if possible.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
});
|
|
|
|
default = null;
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2019-03-21 19:38:55 +01:00
|
|
|
Settings for the wrap lines highlighter.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
numberLines = mkOption {
|
|
|
|
type = types.nullOr (types.submodule {
|
|
|
|
options = {
|
2023-07-02 01:45:18 +02:00
|
|
|
enable = mkEnableOption "the number lines highlighter";
|
2019-03-21 19:38:55 +01:00
|
|
|
|
|
|
|
relative = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2019-03-21 19:38:55 +01:00
|
|
|
Show line numbers relative to the main cursor line.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
highlightCursor = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2019-03-21 19:38:55 +01:00
|
|
|
Highlight the cursor line with a separate face.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
separator = mkOption {
|
|
|
|
type = types.nullOr types.str;
|
|
|
|
default = null;
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2019-03-21 19:38:55 +01:00
|
|
|
String that separates the line number column from the
|
|
|
|
buffer contents. The kakoune default is
|
2023-07-01 01:30:13 +02:00
|
|
|
`"|"`.
|
2019-03-21 19:38:55 +01:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
});
|
|
|
|
default = null;
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2019-03-21 19:38:55 +01:00
|
|
|
Settings for the number lines highlighter.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
showWhitespace = mkOption {
|
|
|
|
type = types.nullOr (types.submodule {
|
|
|
|
options = {
|
2023-07-02 01:45:18 +02:00
|
|
|
enable = mkEnableOption "the show whitespace highlighter";
|
2019-03-21 19:38:55 +01:00
|
|
|
|
|
|
|
lineFeed = mkOption {
|
|
|
|
type = types.nullOr types.str;
|
|
|
|
default = null;
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2019-03-21 19:38:55 +01:00
|
|
|
The character to display for line feeds.
|
2023-07-01 01:30:13 +02:00
|
|
|
The kakoune default is `"¬"`.
|
2019-03-21 19:38:55 +01:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
space = mkOption {
|
|
|
|
type = types.nullOr types.str;
|
|
|
|
default = null;
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2019-03-21 19:38:55 +01:00
|
|
|
The character to display for spaces.
|
2023-07-01 01:30:13 +02:00
|
|
|
The kakoune default is `"·"`.
|
2019-03-21 19:38:55 +01:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
nonBreakingSpace = mkOption {
|
|
|
|
type = types.nullOr types.str;
|
|
|
|
default = null;
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2019-03-21 19:38:55 +01:00
|
|
|
The character to display for non-breaking spaces.
|
2023-07-01 01:30:13 +02:00
|
|
|
The kakoune default is `"⍽"`.
|
2019-03-21 19:38:55 +01:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
tab = mkOption {
|
|
|
|
type = types.nullOr types.str;
|
|
|
|
default = null;
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2019-03-21 19:38:55 +01:00
|
|
|
The character to display for tabs.
|
2023-07-01 01:30:13 +02:00
|
|
|
The kakoune default is `"→"`.
|
2019-03-21 19:38:55 +01:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
tabStop = mkOption {
|
|
|
|
type = types.nullOr types.str;
|
|
|
|
default = null;
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2019-03-21 19:38:55 +01:00
|
|
|
The character to append to tabs to reach the width of a tabstop.
|
2023-07-01 01:30:13 +02:00
|
|
|
The kakoune default is `" "`.
|
2019-03-21 19:38:55 +01:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
});
|
|
|
|
default = null;
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2019-03-21 19:38:55 +01:00
|
|
|
Settings for the show whitespaces highlighter.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
keyMappings = mkOption {
|
|
|
|
type = types.listOf keyMapping;
|
2020-02-02 00:39:17 +01:00
|
|
|
default = [ ];
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2019-03-21 19:38:55 +01:00
|
|
|
User-defined key mappings. For documentation, see
|
2023-07-01 01:30:13 +02:00
|
|
|
<https://github.com/mawww/kakoune/blob/master/doc/pages/mapping.asciidoc>.
|
2019-03-21 19:38:55 +01:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
hooks = mkOption {
|
|
|
|
type = types.listOf hook;
|
2020-02-02 00:39:17 +01:00
|
|
|
default = [ ];
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2019-03-21 19:38:55 +01:00
|
|
|
Global hooks. For documentation, see
|
2023-07-01 01:30:13 +02:00
|
|
|
<https://github.com/mawww/kakoune/blob/master/doc/pages/hooks.asciidoc>.
|
2019-03-21 19:38:55 +01:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2022-11-27 01:49:15 +01:00
|
|
|
kakouneWithPlugins =
|
|
|
|
pkgs.wrapKakoune cfg.package { configure = { plugins = cfg.plugins; }; };
|
2020-06-24 11:35:17 +02:00
|
|
|
|
2020-02-02 00:39:17 +01:00
|
|
|
configFile = let
|
|
|
|
wrapOptions = with cfg.config.wrapLines;
|
|
|
|
concatStrings [
|
2019-03-21 19:38:55 +01:00
|
|
|
"${optionalString word " -word"}"
|
|
|
|
"${optionalString indent " -indent"}"
|
|
|
|
"${optionalString (marker != null) " -marker ${marker}"}"
|
|
|
|
"${optionalString (maxWidth != null) " -width ${toString maxWidth}"}"
|
|
|
|
];
|
|
|
|
|
2020-02-02 00:39:17 +01:00
|
|
|
numberLinesOptions = with cfg.config.numberLines;
|
|
|
|
concatStrings [
|
2019-03-21 19:38:55 +01:00
|
|
|
"${optionalString relative " -relative "}"
|
|
|
|
"${optionalString highlightCursor " -hlcursor"}"
|
|
|
|
"${optionalString (separator != null) " -separator ${separator}"}"
|
|
|
|
];
|
|
|
|
|
2020-04-16 13:36:21 +02:00
|
|
|
showWhitespaceOptions = with cfg.config.showWhitespace;
|
2020-06-24 19:30:16 +02:00
|
|
|
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}")
|
2020-04-16 13:36:21 +02:00
|
|
|
];
|
|
|
|
|
2020-02-02 00:39:17 +01:00
|
|
|
uiOptions = with cfg.config.ui;
|
|
|
|
concatStringsSep " " [
|
2022-01-17 01:39:41 +01:00
|
|
|
"terminal_set_title=${if setTitle then "true" else "false"}"
|
|
|
|
"terminal_status_on_top=${
|
2020-02-02 00:39:17 +01:00
|
|
|
if (statusLine == "top") then "true" else "false"
|
|
|
|
}"
|
2022-01-17 01:39:41 +01:00
|
|
|
"terminal_assistant=${assistant}"
|
|
|
|
"terminal_enable_mouse=${if enableMouse then "true" else "false"}"
|
|
|
|
"terminal_change_colors=${if changeColors then "true" else "false"}"
|
2019-03-21 19:38:55 +01:00
|
|
|
"${optionalString (wheelDownButton != null)
|
2022-01-17 01:39:41 +01:00
|
|
|
"terminal_wheel_down_button=${wheelDownButton}"}"
|
2019-03-21 19:38:55 +01:00
|
|
|
"${optionalString (wheelUpButton != null)
|
2022-01-17 01:39:41 +01:00
|
|
|
"terminal_wheel_up_button=${wheelUpButton}"}"
|
2019-03-21 19:38:55 +01:00
|
|
|
"${optionalString (shiftFunctionKeys != null)
|
2022-01-17 01:39:41 +01:00
|
|
|
"terminal_shift_function_key=${toString shiftFunctionKeys}"}"
|
|
|
|
"terminal_builtin_key_parser=${
|
2020-02-02 00:39:17 +01:00
|
|
|
if useBuiltinKeyParser then "true" else "false"
|
|
|
|
}"
|
2019-03-21 19:38:55 +01:00
|
|
|
];
|
|
|
|
|
2020-07-03 22:43:18 +02:00
|
|
|
userModeString = mode:
|
|
|
|
optionalString (!builtins.elem mode [
|
|
|
|
"insert"
|
|
|
|
"normal"
|
|
|
|
"prompt"
|
|
|
|
"menu"
|
|
|
|
"user"
|
|
|
|
"goto"
|
|
|
|
"view"
|
|
|
|
"object"
|
|
|
|
]) "try %{declare-user-mode ${mode}}";
|
|
|
|
|
|
|
|
userModeStrings = map userModeString
|
|
|
|
(lists.unique (map (km: km.mode) cfg.config.keyMappings));
|
|
|
|
|
2020-02-02 00:39:17 +01:00
|
|
|
keyMappingString = km:
|
|
|
|
concatStringsSep " " [
|
2019-03-21 19:38:55 +01:00
|
|
|
"map global"
|
|
|
|
"${km.mode} ${km.key} '${km.effect}'"
|
2020-02-02 00:39:17 +01:00
|
|
|
"${optionalString (km.docstring != null)
|
|
|
|
"-docstring '${km.docstring}'"}"
|
2019-03-21 19:38:55 +01:00
|
|
|
];
|
|
|
|
|
2020-02-02 00:39:17 +01:00
|
|
|
hookString = h:
|
|
|
|
concatStringsSep " " [
|
|
|
|
"hook"
|
2021-02-22 22:21:36 +01:00
|
|
|
"${optionalString (h.group != null) "-group ${h.group}"}"
|
2020-02-02 00:39:17 +01:00
|
|
|
"${optionalString (h.once) "-once"}"
|
|
|
|
"global"
|
|
|
|
"${h.name}"
|
|
|
|
"${optionalString (h.option != null) h.option}"
|
2019-03-21 19:38:55 +01:00
|
|
|
"%{ ${h.commands} }"
|
|
|
|
];
|
|
|
|
|
2020-02-02 00:39:17 +01:00
|
|
|
cfgStr = with cfg.config;
|
|
|
|
concatStringsSep "\n" ([ "# Generated by home-manager" ]
|
2019-03-21 19:38:55 +01:00
|
|
|
++ optional (colorScheme != null) "colorscheme ${colorScheme}"
|
2020-02-02 00:39:17 +01:00
|
|
|
++ optional (tabStop != null)
|
|
|
|
"set-option global tabstop ${toString tabStop}"
|
|
|
|
++ optional (indentWidth != null)
|
|
|
|
"set-option global indentwidth ${toString indentWidth}"
|
2019-03-21 19:38:55 +01:00
|
|
|
++ optional (!incrementalSearch) "set-option global incsearch false"
|
|
|
|
++ optional (alignWithTabs) "set-option global aligntab true"
|
2020-02-02 00:39:17 +01:00
|
|
|
++ optional (autoInfo != null)
|
|
|
|
"set-option global autoinfo ${concatStringsSep "|" autoInfo}"
|
|
|
|
++ optional (autoComplete != null)
|
|
|
|
"set-option global autocomplete ${concatStringsSep "|" autoComplete}"
|
|
|
|
++ optional (autoReload != null)
|
2020-03-29 06:52:28 +02:00
|
|
|
"set-option global autoreload ${autoReload}"
|
2020-02-02 00:39:17 +01:00
|
|
|
++ optional (wrapLines != null && wrapLines.enable)
|
|
|
|
"add-highlighter global/ wrap${wrapOptions}"
|
2019-03-21 19:38:55 +01:00
|
|
|
++ optional (numberLines != null && numberLines.enable)
|
2020-02-02 00:39:17 +01:00
|
|
|
"add-highlighter global/ number-lines${numberLinesOptions}"
|
2019-03-21 19:38:55 +01:00
|
|
|
++ optional showMatching "add-highlighter global/ show-matching"
|
2020-04-16 13:36:21 +02:00
|
|
|
++ optional (showWhitespace != null && showWhitespace.enable)
|
|
|
|
"add-highlighter global/ show-whitespaces${showWhitespaceOptions}"
|
2019-03-21 19:38:55 +01:00
|
|
|
++ optional (scrollOff != null)
|
2020-02-02 00:39:17 +01:00
|
|
|
"set-option global scrolloff ${toString scrollOff.lines},${
|
|
|
|
toString scrollOff.columns
|
|
|
|
}"
|
2019-03-21 19:38:55 +01:00
|
|
|
|
|
|
|
++ [ "# UI options" ]
|
|
|
|
++ optional (ui != null) "set-option global ui_options ${uiOptions}"
|
|
|
|
|
2020-07-03 22:43:18 +02:00
|
|
|
++ [ "# User modes" ] ++ userModeStrings ++ [ "# Key mappings" ]
|
|
|
|
++ map keyMappingString keyMappings
|
2019-03-21 19:38:55 +01:00
|
|
|
|
2020-02-02 00:39:17 +01:00
|
|
|
++ [ "# Hooks" ] ++ map hookString hooks);
|
|
|
|
in pkgs.writeText "kakrc"
|
|
|
|
(optionalString (cfg.config != null) cfgStr + "\n" + cfg.extraConfig);
|
2019-03-21 19:38:55 +01:00
|
|
|
|
2020-02-02 00:39:17 +01:00
|
|
|
in {
|
2019-03-21 19:38:55 +01:00
|
|
|
options = {
|
|
|
|
programs.kakoune = {
|
2023-07-02 01:45:18 +02:00
|
|
|
enable = mkEnableOption "the kakoune text editor";
|
2019-03-21 19:38:55 +01:00
|
|
|
|
2023-07-02 01:45:18 +02:00
|
|
|
package = mkPackageOption pkgs "kakoune-unwrapped" { };
|
2022-11-27 01:49:15 +01:00
|
|
|
|
2019-03-21 19:38:55 +01:00
|
|
|
config = mkOption {
|
|
|
|
type = types.nullOr configModule;
|
2020-02-02 00:39:17 +01:00
|
|
|
default = { };
|
2023-07-02 01:45:18 +02:00
|
|
|
description = "kakoune configuration options.";
|
2019-03-21 19:38:55 +01:00
|
|
|
};
|
|
|
|
|
2023-06-26 17:23:35 +02:00
|
|
|
defaultEditor = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2023-07-01 01:30:13 +02:00
|
|
|
Whether to configure {command}`kak` as the default
|
|
|
|
editor using the {env}`EDITOR` environment variable.
|
2023-06-26 17:23:35 +02:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2019-03-21 19:38:55 +01:00
|
|
|
extraConfig = mkOption {
|
|
|
|
type = types.lines;
|
|
|
|
default = "";
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2019-03-21 19:38:55 +01:00
|
|
|
Extra configuration lines to add to
|
2023-07-01 01:30:13 +02:00
|
|
|
{file}`$XDG_CONFIG_HOME/kak/kakrc`.
|
2019-03-21 19:38:55 +01:00
|
|
|
'';
|
|
|
|
};
|
2020-06-24 11:35:17 +02:00
|
|
|
|
|
|
|
plugins = mkOption {
|
|
|
|
type = with types; listOf package;
|
|
|
|
default = [ ];
|
2021-10-09 11:14:08 +02:00
|
|
|
example = literalExpression "[ pkgs.kakounePlugins.kak-fzf ]";
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2020-06-24 11:35:17 +02:00
|
|
|
List of kakoune plugins to install. To get a list of
|
|
|
|
supported plugins run:
|
2023-07-01 01:30:13 +02:00
|
|
|
{command}`nix-env -f '<nixpkgs>' -qaP -A kakounePlugins`.
|
2020-06-24 11:35:17 +02:00
|
|
|
'';
|
|
|
|
};
|
2019-03-21 19:38:55 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
2020-06-24 11:35:17 +02:00
|
|
|
home.packages = [ kakouneWithPlugins ];
|
2023-06-26 17:23:35 +02:00
|
|
|
home.sessionVariables = mkIf cfg.defaultEditor { EDITOR = "kak"; };
|
2019-03-21 19:38:55 +01:00
|
|
|
xdg.configFile."kak/kakrc".source = configFile;
|
|
|
|
};
|
|
|
|
}
|