Better kakoune mapping
This commit is contained in:
parent
5d7597be07
commit
844f7d214b
1 changed files with 406 additions and 284 deletions
|
|
@ -1,7 +1,9 @@
|
||||||
{ config, lib, pkgs, ... }:
|
{ config, lib, pkgs, ... }:
|
||||||
let
|
let
|
||||||
strPalette = with pkgs.rice; palette.toRgbShortHex colorPalette;
|
strPalette = with pkgs.rice;
|
||||||
packages = with pkgs; [
|
palette.toRgbShortHex colorPalette;
|
||||||
|
packages = with pkgs;
|
||||||
|
[
|
||||||
(makeDesktopItem
|
(makeDesktopItem
|
||||||
{
|
{
|
||||||
name = "kakoune";
|
name = "kakoune";
|
||||||
|
|
@ -43,7 +45,8 @@ let
|
||||||
rnix-lsp
|
rnix-lsp
|
||||||
]
|
]
|
||||||
) ++ (
|
) ++ (
|
||||||
with python3.pkgs; lib.optionals (pkgs.devEnvironment.enablePython) [
|
with python3.pkgs;
|
||||||
|
lib.optionals (pkgs.devEnvironment.enablePython) [
|
||||||
black
|
black
|
||||||
# pyls-black
|
# pyls-black
|
||||||
pyls-flake8
|
pyls-flake8
|
||||||
|
|
@ -73,7 +76,8 @@ let
|
||||||
aspellDicts.it
|
aspellDicts.it
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
plugins = with pkgs; [
|
plugins = with pkgs;
|
||||||
|
[
|
||||||
kakounePlugins.prelude-kak
|
kakounePlugins.prelude-kak
|
||||||
kakounePlugins.kak-lsp
|
kakounePlugins.kak-lsp
|
||||||
kakounePlugins.auto-pairs-kak
|
kakounePlugins.auto-pairs-kak
|
||||||
|
|
@ -82,9 +86,16 @@ let
|
||||||
];
|
];
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
home.sessionVariables = { EDITOR = "kak"; VISUAL = "kak"; };
|
home.sessionVariables = {
|
||||||
programs.bash.shellAliases = { k = "kak"; };
|
EDITOR = "kak";
|
||||||
programs.zsh.shellAliases = { k = "kak"; };
|
VISUAL = "kak";
|
||||||
|
};
|
||||||
|
programs.bash.shellAliases = {
|
||||||
|
k = "kak";
|
||||||
|
};
|
||||||
|
programs.zsh.shellAliases = {
|
||||||
|
k = "kak";
|
||||||
|
};
|
||||||
home.packages = packages;
|
home.packages = packages;
|
||||||
programs.kakoune = {
|
programs.kakoune = {
|
||||||
enable = true;
|
enable = true;
|
||||||
|
|
@ -110,46 +121,155 @@ in
|
||||||
enable = true;
|
enable = true;
|
||||||
highlightCursor = true;
|
highlightCursor = true;
|
||||||
};
|
};
|
||||||
keyMappings = with pkgs; [
|
keyMappings = with pkgs;
|
||||||
{ mode = "normal"; docstring = "Edit file"; key = "<c-e>"; effect = ":edit<space>"; }
|
[
|
||||||
{ mode = "user"; docstring = "Code actions"; key = "a"; effect = ":lsp-code-actions<ret>"; }
|
{
|
||||||
{ mode = "user"; docstring = "Comment block"; key = "b"; effect = ":comment-block<ret>"; }
|
mode = "normal";
|
||||||
{ mode = "user"; docstring = "Comment line"; key = "l"; effect = ":comment-line<ret>"; }
|
docstring = "Edit file";
|
||||||
{ mode = "user"; docstring = "Copy to clipboard"; key = "y"; effect = "<a-|>${xclip}/bin/xclip -i -selection clipboard<ret>"; }
|
key = "<c-e>";
|
||||||
{ mode = "user"; docstring = "Format code with formatter"; key = "f"; effect = ":format<ret>"; }
|
effect = ":edit<space>";
|
||||||
{ mode = "user"; docstring = "Format code with LSP"; key = "F"; effect = ":lsp-formatting-sync<ret>"; }
|
}
|
||||||
{ mode = "user"; docstring = "Jump to definition"; key = "d"; effect = ":lsp-definition<ret>"; }
|
{
|
||||||
{ mode = "user"; docstring = "Jump to type definition"; key = "t"; effect = ":lsp-type-definition<ret>"; }
|
mode = "user";
|
||||||
{ mode = "user"; docstring = "List project diagnostics"; key = "i"; effect = ":lsp-diagnostics<ret>"; }
|
docstring = "Code actions";
|
||||||
{ mode = "user"; docstring = "Paste from clipboard (after)"; key = "P"; effect = "<a-!>${xclip}/bin/xclip -selection clipboard -o<ret>"; }
|
key = "a";
|
||||||
{ mode = "user"; docstring = "Paste from clipboard (before)"; key = "p"; effect = "!${xclip}/bin/xclip -selection clipboard -o<ret>"; }
|
effect = ":lsp-code-actions<ret>";
|
||||||
{ mode = "user"; docstring = "Show hover info"; key = "q"; effect = ":lsp-hover<ret>"; }
|
}
|
||||||
{ mode = "user"; docstring = "Spellcheck English"; key = "S"; effect = ":spell en<ret>"; }
|
{
|
||||||
{ mode = "user"; docstring = "Spellcheck"; key = "s"; effect = ":spell "; }
|
mode = "user";
|
||||||
{ mode = "normal"; docstring = "Try next snippet placeholder"; key = "<c-n>"; effect = "<a-;>: insert-c-n<ret>"; }
|
docstring = "Comment block";
|
||||||
{ mode = "normal"; docstring = "Search"; key = "/"; effect = "/(?i)"; }
|
key = "b";
|
||||||
{ mode = "normal"; docstring = "Reverse search"; key = "<a-/>"; effect = "<a-/>(?i)"; }
|
effect = ":comment-block<ret>";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
mode = "user";
|
||||||
|
docstring = "Comment line";
|
||||||
|
key = "l";
|
||||||
|
effect = ":comment-line<ret>";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
mode = "user";
|
||||||
|
docstring = "Copy to clipboard";
|
||||||
|
key = "y";
|
||||||
|
effect = "<a-|>${xclip}/bin/xclip -i -selection clipboard<ret>";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
mode = "user";
|
||||||
|
docstring = "Format code with formatter";
|
||||||
|
key = "f";
|
||||||
|
effect = ":format<ret>";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
mode = "user";
|
||||||
|
docstring = "Format code with LSP";
|
||||||
|
key = "F";
|
||||||
|
effect = ":lsp-formatting-sync<ret>";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
mode = "user";
|
||||||
|
docstring = "Jump to definition";
|
||||||
|
key = "d";
|
||||||
|
effect = ":lsp-definition<ret>";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
mode = "user";
|
||||||
|
docstring = "Jump to type definition";
|
||||||
|
key = "t";
|
||||||
|
effect = ":lsp-type-definition<ret>";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
mode = "user";
|
||||||
|
docstring = "List project diagnostics";
|
||||||
|
key = "i";
|
||||||
|
effect = ":lsp-diagnostics<ret>";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
mode = "user";
|
||||||
|
docstring = "Paste from clipboard (after)";
|
||||||
|
key = "P";
|
||||||
|
effect = "<a-!>${xclip}/bin/xclip -selection clipboard -o<ret>";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
mode = "user";
|
||||||
|
docstring = "Paste from clipboard (before)";
|
||||||
|
key = "p";
|
||||||
|
effect = "!${xclip}/bin/xclip -selection clipboard -o<ret>";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
mode = "user";
|
||||||
|
docstring = "Show hover info";
|
||||||
|
key = "q";
|
||||||
|
effect = ":lsp-hover<ret>";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
mode = "user";
|
||||||
|
docstring = "Spellcheck English";
|
||||||
|
key = "S";
|
||||||
|
effect = ":spell en<ret>";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
mode = "user";
|
||||||
|
docstring = "Spellcheck";
|
||||||
|
key = "s";
|
||||||
|
effect = ":spell ";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
mode = "normal";
|
||||||
|
docstring = "Try next snippet placeholder";
|
||||||
|
key = "<c-n>";
|
||||||
|
effect = "<a-;>: insert-c-n<ret>";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
mode = "normal";
|
||||||
|
docstring = "Search";
|
||||||
|
key = "/";
|
||||||
|
effect = "/(?i)";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
mode = "normal";
|
||||||
|
docstring = "Reverse search";
|
||||||
|
key = "<a-/>";
|
||||||
|
effect = "<a-/>(?i)";
|
||||||
|
}
|
||||||
];
|
];
|
||||||
hooks = with pkgs; [
|
hooks = with pkgs;
|
||||||
{ name = "BufCreate"; option = ".*"; commands = "editorconfig-load"; }
|
[
|
||||||
# { name = "ModuleLoaded"; option = "auto-pairs"; commands = "auto-pairs-enable"; }
|
{
|
||||||
{ name = "ModuleLoaded"; option = "powerline"; commands = builtins.concatStringsSep "\n" [ "powerline-enable" ]; }
|
name = "BufCreate";
|
||||||
# { name = "WinSetOption"; option = "filetype=(rust|python|c|cpp|latex|javascript|go|nix)"; commands = builtins.concatStringsSep "\n" [ "lsp-enable-window" ]; }
|
option = ".*";
|
||||||
|
commands = "editorconfig-load";
|
||||||
|
}
|
||||||
|
# {
|
||||||
|
# name = "ModuleLoaded";
|
||||||
|
# option = "auto-pairs";
|
||||||
|
# commands = "auto-pairs-enable";
|
||||||
|
# }
|
||||||
|
{
|
||||||
|
name = "ModuleLoaded";
|
||||||
|
option = "powerline";
|
||||||
|
commands = builtins.concatStringsSep "\n" [ "powerline-enable" ];
|
||||||
|
}
|
||||||
] ++ (
|
] ++ (
|
||||||
lib.optionals (pkgs.devEnvironment.enableLatex) [
|
lib.optionals (pkgs.devEnvironment.enableLatex) [
|
||||||
{ name = "BufSetOption"; option = "filetype=latex"; commands = "set-option buffer formatcmd ${texlive.bin.latexindent}/bin/latexindent"; }
|
{
|
||||||
|
name = "BufSetOption";
|
||||||
|
option = "filetype=latex";
|
||||||
|
commands = "set-option buffer formatcmd ${texlive.bin.latexindent}/bin/latexindent";
|
||||||
|
}
|
||||||
]
|
]
|
||||||
) ++ (
|
) ++ (
|
||||||
lib.optionals (pkgs.devEnvironment.enableData) [
|
lib.optionals (pkgs.devEnvironment.enableData) [
|
||||||
{ name = "BufSetOption"; option = "filetype=(markdown|html|json|yaml|css|scss|less)"; commands = "set-option buffer formatcmd ${nodePackages.prettier}/bin/prettier"; }
|
{
|
||||||
|
name = "BufSetOption";
|
||||||
|
option = "filetype=(markdown|html|json|yaml|css|scss|less)";
|
||||||
|
commands = "set-option buffer formatcmd ${nodePackages.prettier}/bin/prettier";
|
||||||
|
}
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
# TODO add more formatters from https://github.com/mawww/kakoune/wiki/Format
|
# TODO add more formatters from https://github.com/mawww/kakoune/wiki/Format
|
||||||
};
|
};
|
||||||
extraConfig = builtins.concatStringsSep "\n" [
|
extraConfig = builtins.concatStringsSep "\n" [
|
||||||
"# Custom commands"
|
"# Custom commands"
|
||||||
"define-command -docstring 'save and quit' x 'write-all; quit' # Save and quit with 'x'"
|
|
||||||
"add-highlighter global/ regex \\h+$ 0:Error # Highlight trailing spaces"
|
"add-highlighter global/ regex \\h+$ 0:Error # Highlight trailing spaces"
|
||||||
"eval %sh{kak-lsp --kakoune -s $kak_session}"
|
"eval %sh{kak-lsp --kakoune -s $kak_session}"
|
||||||
"lsp-enable"
|
"lsp-enable"
|
||||||
|
|
@ -170,7 +290,8 @@ in
|
||||||
];
|
];
|
||||||
plugins = plugins;
|
plugins = plugins;
|
||||||
};
|
};
|
||||||
xdg.configFile."kak/colors/nord.kak".text = with strPalette; ''
|
xdg.configFile."kak/colors/nord.kak".text = with strPalette;
|
||||||
|
''
|
||||||
set-face global value rgb:${normal.magenta},default
|
set-face global value rgb:${normal.magenta},default
|
||||||
set-face global type rgb:${bright.white},default
|
set-face global type rgb:${bright.white},default
|
||||||
set-face global identifier rgb:${normal.cyan},default
|
set-face global identifier rgb:${normal.cyan},default
|
||||||
|
|
@ -198,7 +319,8 @@ in
|
||||||
set-face global Prompt rgb:${normal.cyan},rgb:${normal.black}
|
set-face global Prompt rgb:${normal.cyan},rgb:${normal.black}
|
||||||
set-face global BufferPadding default,default
|
set-face global BufferPadding default,default
|
||||||
'';
|
'';
|
||||||
xdg.configFile."kak-lsp/kak-lsp.toml".text = with pkgs; builtins.concatStringsSep "\n" (
|
xdg.configFile."kak-lsp/kak-lsp.toml".text = with pkgs;
|
||||||
|
builtins.concatStringsSep "\n" (
|
||||||
[
|
[
|
||||||
''
|
''
|
||||||
snippet_support = false
|
snippet_support = false
|
||||||
|
|
@ -285,7 +407,7 @@ in
|
||||||
settings_section = "texlab"
|
settings_section = "texlab"
|
||||||
[language.latex.settings.texlab]
|
[language.latex.settings.texlab]
|
||||||
# See https://github.com/latex-lsp/texlab/blob/master/src/options.rs
|
# See https://github.com/latex-lsp/texlab/blob/master/src/options.rs
|
||||||
bibtexFormatter = "${texlab}/bin/texlab"
|
# bibtexFormatter = "${texlab}/bin/texlab"
|
||||||
''
|
''
|
||||||
) ++ (
|
) ++ (
|
||||||
lib.optional (pkgs.devEnvironment.enableNix) ''
|
lib.optional (pkgs.devEnvironment.enableNix) ''
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue