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, ... }:
|
||||
let
|
||||
strPalette = with pkgs.rice; palette.toRgbShortHex colorPalette;
|
||||
packages = with pkgs; [
|
||||
strPalette = with pkgs.rice;
|
||||
palette.toRgbShortHex colorPalette;
|
||||
packages = with pkgs;
|
||||
[
|
||||
(makeDesktopItem
|
||||
{
|
||||
name = "kakoune";
|
||||
|
|
@ -43,7 +45,8 @@ let
|
|||
rnix-lsp
|
||||
]
|
||||
) ++ (
|
||||
with python3.pkgs; lib.optionals (pkgs.devEnvironment.enablePython) [
|
||||
with python3.pkgs;
|
||||
lib.optionals (pkgs.devEnvironment.enablePython) [
|
||||
black
|
||||
# pyls-black
|
||||
pyls-flake8
|
||||
|
|
@ -73,7 +76,8 @@ let
|
|||
aspellDicts.it
|
||||
]
|
||||
);
|
||||
plugins = with pkgs; [
|
||||
plugins = with pkgs;
|
||||
[
|
||||
kakounePlugins.prelude-kak
|
||||
kakounePlugins.kak-lsp
|
||||
kakounePlugins.auto-pairs-kak
|
||||
|
|
@ -82,9 +86,16 @@ let
|
|||
];
|
||||
in
|
||||
{
|
||||
home.sessionVariables = { EDITOR = "kak"; VISUAL = "kak"; };
|
||||
programs.bash.shellAliases = { k = "kak"; };
|
||||
programs.zsh.shellAliases = { k = "kak"; };
|
||||
home.sessionVariables = {
|
||||
EDITOR = "kak";
|
||||
VISUAL = "kak";
|
||||
};
|
||||
programs.bash.shellAliases = {
|
||||
k = "kak";
|
||||
};
|
||||
programs.zsh.shellAliases = {
|
||||
k = "kak";
|
||||
};
|
||||
home.packages = packages;
|
||||
programs.kakoune = {
|
||||
enable = true;
|
||||
|
|
@ -110,46 +121,155 @@ in
|
|||
enable = true;
|
||||
highlightCursor = true;
|
||||
};
|
||||
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 = "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)"; }
|
||||
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 = "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; [
|
||||
{ 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 = "WinSetOption"; option = "filetype=(rust|python|c|cpp|latex|javascript|go|nix)"; commands = builtins.concatStringsSep "\n" [ "lsp-enable-window" ]; }
|
||||
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" ];
|
||||
}
|
||||
] ++ (
|
||||
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) [
|
||||
{ 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
|
||||
};
|
||||
extraConfig = builtins.concatStringsSep "\n" [
|
||||
"# 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"
|
||||
"eval %sh{kak-lsp --kakoune -s $kak_session}"
|
||||
"lsp-enable"
|
||||
|
|
@ -170,7 +290,8 @@ in
|
|||
];
|
||||
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 type rgb:${bright.white},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 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
|
||||
|
|
@ -285,7 +407,7 @@ in
|
|||
settings_section = "texlab"
|
||||
[language.latex.settings.texlab]
|
||||
# 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) ''
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue