Retab kak config
This commit is contained in:
parent
f398775552
commit
11e08fc437
3 changed files with 157 additions and 167 deletions
|
@ -3,50 +3,50 @@
|
|||
with pkgs.kakouneUtils;
|
||||
|
||||
let cfg = config.riley.kak;
|
||||
theme = config.riley.theme;
|
||||
kak-crosshairs = buildKakounePlugin (rec {
|
||||
name = "kak-crosshairs";
|
||||
src = (pkgs.fetchFromGitHub {
|
||||
owner = "insipx";
|
||||
repo = name;
|
||||
rev = "7edba13c535ce1bc67356b1c9461f5d261949d29";
|
||||
sha256 = "sha256-VOn9GGHludJasEwcCv6t1Q3/63w9139MCEkdRDnTw6E";
|
||||
});
|
||||
});
|
||||
theme = config.riley.theme;
|
||||
kak-crosshairs = buildKakounePlugin (rec {
|
||||
name = "kak-crosshairs";
|
||||
src = (pkgs.fetchFromGitHub {
|
||||
owner = "insipx";
|
||||
repo = name;
|
||||
rev = "7edba13c535ce1bc67356b1c9461f5d261949d29";
|
||||
sha256 = "sha256-VOn9GGHludJasEwcCv6t1Q3/63w9139MCEkdRDnTw6E";
|
||||
});
|
||||
});
|
||||
in
|
||||
|
||||
with lib; {
|
||||
|
||||
options.riley = {
|
||||
options.riley.kak = {
|
||||
|
||||
kak.enable = (mkEnableOption "kakoune editor") // { default = true; };
|
||||
enable = (mkEnableOption "kakoune editor") // { default = true; };
|
||||
|
||||
kak.rust = mkEnableOption "Rust support in Kakoune";
|
||||
kak.ts = mkEnableOption "TypeScript support in Kakoune";
|
||||
kak.haskell = mkEnableOption "Haskell support in Kakoune";
|
||||
kak.python = mkEnableOption "Python 3.9 support in Kakoune";
|
||||
kak.nix = (mkEnableOption "Nix support in Kakoune") // { default = true; };
|
||||
rust = mkEnableOption "Rust support in Kakoune";
|
||||
ts = mkEnableOption "TypeScript support in Kakoune";
|
||||
haskell = mkEnableOption "Haskell support in Kakoune";
|
||||
python = mkEnableOption "Python 3.9 support in Kakoune";
|
||||
nix = (mkEnableOption "Nix support in Kakoune") // { default = true; };
|
||||
|
||||
};
|
||||
|
||||
config = mkIf (cfg.enable) {
|
||||
|
||||
environment.systemPackages = [
|
||||
(import ./kakoune.nix {
|
||||
environment.systemPackages = [
|
||||
(import ./kakoune.nix {
|
||||
|
||||
typescript = cfg.ts;
|
||||
haskell = cfg.haskell;
|
||||
python = cfg.python;
|
||||
rust = cfg.rust;
|
||||
nix = cfg.nix;
|
||||
typescript = cfg.ts;
|
||||
haskell = cfg.haskell;
|
||||
python = cfg.python;
|
||||
rust = cfg.rust;
|
||||
nix = cfg.nix;
|
||||
|
||||
inherit kak-crosshairs;
|
||||
inherit kak-crosshairs;
|
||||
|
||||
inherit pkgs lib theme;
|
||||
inherit pkgs lib theme;
|
||||
|
||||
})
|
||||
];
|
||||
|
||||
})
|
||||
];
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -15,97 +15,100 @@ with lib;
|
|||
with pkgs;
|
||||
|
||||
let semantic-tokens =
|
||||
let mk = (name: value: ''
|
||||
[[semantic_tokens]]
|
||||
token = "${name}"
|
||||
face = "${value}"
|
||||
''); in concatStringsSep "\n" (mapAttrsToList mk {
|
||||
"enumMember" = "variant";
|
||||
"enum" = "enum";
|
||||
"union" = "union";
|
||||
"struct" = "struct";
|
||||
"typeAlias" = "alias";
|
||||
"builtinType" = "primitive";
|
||||
"trait" = "trait";
|
||||
"interface" = "trait";
|
||||
"method" = "method";
|
||||
"function" = "function";
|
||||
"namespace" = "module";
|
||||
"boolean" = "literal";
|
||||
"character" = "literal";
|
||||
"number" = "literal";
|
||||
"string" = "string";
|
||||
"keyword" = "keyword";
|
||||
"documentation" = "comment";
|
||||
"comment" = "comment";
|
||||
"escapeSequence" = "format";
|
||||
"formatSpecifier" = "format";
|
||||
"operator" = "operator";
|
||||
"arithmetic" = "operator";
|
||||
"bitwise" = "operator";
|
||||
"comparison" = "operator";
|
||||
"logical" = "operator";
|
||||
"macro" = "macro";
|
||||
"lifetime" = "lifetime";
|
||||
"variable" = "variable";
|
||||
"attribute" = "attribute";
|
||||
"punctuation" = "punctuation";
|
||||
});
|
||||
let mk = (name: value: ''
|
||||
[[semantic_tokens]]
|
||||
token = "${name}"
|
||||
face = "${value}"
|
||||
''); in concatStringsSep "\n" (mapAttrsToList mk {
|
||||
"enumMember" = "variant";
|
||||
"enum" = "enum";
|
||||
"union" = "union";
|
||||
"struct" = "struct";
|
||||
"typeAlias" = "alias";
|
||||
"builtinType" = "primitive";
|
||||
"trait" = "trait";
|
||||
"interface" = "trait";
|
||||
"method" = "method";
|
||||
"function" = "function";
|
||||
"namespace" = "module";
|
||||
"boolean" = "literal";
|
||||
"character" = "literal";
|
||||
"number" = "literal";
|
||||
"string" = "string";
|
||||
"keyword" = "keyword";
|
||||
"documentation" = "comment";
|
||||
"comment" = "comment";
|
||||
"escapeSequence" = "format";
|
||||
"formatSpecifier" = "format";
|
||||
"operator" = "operator";
|
||||
"arithmetic" = "operator";
|
||||
"bitwise" = "operator";
|
||||
"comparison" = "operator";
|
||||
"logical" = "operator";
|
||||
"macro" = "macro";
|
||||
"lifetime" = "lifetime";
|
||||
"variable" = "variable";
|
||||
"attribute" = "attribute";
|
||||
"punctuation" = "punctuation";
|
||||
});
|
||||
|
||||
kak-lsp-config-text = concatStringsSep "\n" (
|
||||
kak-lsp-config-text = concatStringsSep "\n" (
|
||||
(optional (rust || haskell) semantic-tokens)
|
||||
++ (optional rust ''
|
||||
[language.rust]
|
||||
filetypes = [ "rust" ]
|
||||
roots = [ "Cargo.toml" ]
|
||||
command = "rust-analyzer"
|
||||
[language.rust.settings.rust-analyzer]
|
||||
semanticTokens = true
|
||||
diagnostics.enabled = [ "unresolved-proc-macro" ]
|
||||
cargo.loadOutDirsFromCheck = true
|
||||
procMacro.enable = false
|
||||
'')
|
||||
++ (optional nix ''
|
||||
[language.rust]
|
||||
filetypes = [ "rust" ]
|
||||
roots = [ "Cargo.toml" ]
|
||||
command = "rust-analyzer"
|
||||
[language.rust.settings.rust-analyzer]
|
||||
semanticTokens = true
|
||||
diagnostics.enabled = [ "unresolved-proc-macro" ]
|
||||
cargo.loadOutDirsFromCheck = true
|
||||
procMacro.enable = false
|
||||
'')
|
||||
++ (optional nix ''
|
||||
[language.nix]
|
||||
filetypes = [ "nix" ]
|
||||
roots = [ "flake.nix", "shell.nix", ".git", ".hg" ]
|
||||
command = "rnix-lsp"
|
||||
'')
|
||||
++ (optional haskell ''
|
||||
'')
|
||||
++ (optional haskell ''
|
||||
[language.haskell]
|
||||
filetypes = [ "haskell" ]
|
||||
roots = [ "Setup.hs", "stack.yaml", "*.cabal" ]
|
||||
command = "haskell-language-server-wrapper"
|
||||
args = [ "--lsp" ]
|
||||
'')
|
||||
++ (optional python ''
|
||||
'')
|
||||
++ (optional python ''
|
||||
[language.python]
|
||||
filetypes = [ "python" ]
|
||||
roots = [ "setup.py", ".git", ".hg" ]
|
||||
command = "pylsp"
|
||||
'')
|
||||
++ (optional typescript ''
|
||||
'')
|
||||
++ (optional typescript ''
|
||||
[language.typescript]
|
||||
filetypes = ["typescript", "javascript"]
|
||||
roots = ["package.json"]
|
||||
command = "rslint-lsp"
|
||||
''));
|
||||
''));
|
||||
|
||||
kak-lsp-config = (pkgs.writeTextFile (rec {
|
||||
name = "kak-lsp.toml";
|
||||
destination = "/share/kak-lsp/${name}";
|
||||
text = kak-lsp-config-text;
|
||||
}));
|
||||
kak-lsp-config = (pkgs.writeTextFile (rec {
|
||||
name = "kak-lsp.toml";
|
||||
destination = "/share/kak-lsp/${name}";
|
||||
text = kak-lsp-config-text;
|
||||
}));
|
||||
|
||||
in (symlinkJoin {
|
||||
|
||||
paths = with kakounePlugins; [
|
||||
|
||||
# The language server client
|
||||
kak-lsp
|
||||
|
||||
# Overwrite kak-lsp.toml
|
||||
kak-lsp-config
|
||||
name = "kak-lsp-${kak-lsp.version}";
|
||||
nativeBuildInputs = [ makeWrapper ];
|
||||
|
||||
paths = with kakounePlugins; [
|
||||
|
||||
# The language server client
|
||||
kak-lsp
|
||||
|
||||
# Overwrite kak-lsp.toml
|
||||
kak-lsp-config
|
||||
|
||||
] ++ (optional nix rnix-lsp)
|
||||
++ (optional typescript rslint)
|
||||
|
@ -113,9 +116,8 @@ in (symlinkJoin {
|
|||
++ (optional python python39Packages.python-lsp-server)
|
||||
++ (optional rust rust-analyzer);
|
||||
|
||||
name = "kak-lsp-${kak-lsp.version}";
|
||||
nativeBuildInputs = [ makeWrapper ];
|
||||
postBuild = ''
|
||||
wrapProgram $out/bin/kak-lsp --add-flags "--config $out/share/kak-lsp/kak-lsp.toml"
|
||||
'';
|
||||
postBuild = ''
|
||||
wrapProgram $out/bin/kak-lsp --add-flags "--config $out/share/kak-lsp/kak-lsp.toml"
|
||||
'';
|
||||
|
||||
})
|
||||
|
|
|
@ -18,57 +18,49 @@
|
|||
|
||||
|
||||
let keybinds = ''
|
||||
map global insert <a-tab> <esc>:buffer-next<ret>
|
||||
map global normal <a-tab> :buffer-next<ret>
|
||||
map global insert <a-tab> <esc>:buffer-next<ret>
|
||||
map global normal <a-tab> :buffer-next<ret>
|
||||
'';
|
||||
|
||||
# Initialization code for IDE mode needed for every supported
|
||||
# language, and inlay diagnostics.
|
||||
# Initialization code for IDE mode needed for every supported
|
||||
# language, and inlay diagnostics.
|
||||
ide-init = ''
|
||||
eval %sh{ kak-lsp --kakoune -s $kak_session }
|
||||
eval %sh{ kak-lsp --kakoune -s $kak_session }
|
||||
lsp-enable-window
|
||||
|
||||
lsp-inlay-diagnostics-enable window
|
||||
|
||||
hook window ModeChange .*:.*:insert %{
|
||||
remove-highlighter window/lsp_diagnostics
|
||||
}
|
||||
|
||||
hook window ModeChange .*:insert:normal %{
|
||||
lsp-inlay-diagnostics-enable window
|
||||
}
|
||||
lsp-inlay-diagnostics-enable window
|
||||
|
||||
hook window ModeChange .*:.*:insert %{ remove-highlighter window/lsp_diagnostics }
|
||||
hook window ModeChange .*:insert:normal %{ lsp-inlay-diagnostics-enable window }
|
||||
'';
|
||||
|
||||
# Implies `ide-init`. Adds code actions and hover.
|
||||
# Implies `ide-init`. Adds code actions and hover.
|
||||
ide-core = ''
|
||||
|
||||
${ide-init}
|
||||
${ide-init}
|
||||
|
||||
map buffer normal <tab> ': lsp-code-actions<ret>'
|
||||
map buffer normal <ret> ': lsp-hover<ret>'
|
||||
|
||||
'';
|
||||
|
||||
# Implies `ide-core`, which implies `ide-init`.
|
||||
ide-full = ''
|
||||
# Implies `ide-core`, which implies `ide-init`.
|
||||
ide-full = ''
|
||||
|
||||
${ide-core}
|
||||
${ide-core}
|
||||
|
||||
hook window -group semtok BufReload .* lsp-semantic-tokens
|
||||
hook window -group semtok NormalIdle .* lsp-semantic-tokens
|
||||
hook window -group semtok InsertIdle .* lsp-semantic-tokens
|
||||
|
||||
hook -once -always window WinSetOption filetype=.* %{
|
||||
remove-hooks window semtok
|
||||
}
|
||||
hook window -group semtok BufReload .* lsp-semantic-tokens
|
||||
hook window -group semtok NormalIdle .* lsp-semantic-tokens
|
||||
hook window -group semtok InsertIdle .* lsp-semantic-tokens
|
||||
|
||||
hook -once -always window WinSetOption filetype=.* %{ remove-hooks window semtok }
|
||||
|
||||
map global normal <a-down> ': lsp-next-function<ret>'
|
||||
map global normal <a-up> ': lsp-previous-function<ret>'
|
||||
map global normal <a-left> ': lsp-previous-location *goto*<ret>'
|
||||
map global normal <a-right> ': lsp-next-location *goto*<ret>'
|
||||
|
||||
''; in
|
||||
''; in
|
||||
|
||||
|
||||
# Nix hacking-related configuration. Nix has a very weak language
|
||||
|
@ -81,7 +73,7 @@ let nix-config = (lib.optionalString nix ''
|
|||
|
||||
# Sometimes work requires me to touch the frontend. Ew. `ide-core`
|
||||
# suffices here.
|
||||
typescript-config = (lib.optionalString typescript ''
|
||||
typescript-config = (lib.optionalString typescript ''
|
||||
hook global WinSetOption filetype=(javascript|typescript) %{
|
||||
${ide-core}
|
||||
}
|
||||
|
@ -90,24 +82,24 @@ let nix-config = (lib.optionalString nix ''
|
|||
# Python-related config. Python does not support more features than
|
||||
# those in `ide-core`.
|
||||
python-config = (lib.optionalString python ''
|
||||
hook global WinSetOption filetype=python %{
|
||||
hook global WinSetOption filetype=python %{
|
||||
|
||||
${ide-core}
|
||||
${ide-core}
|
||||
|
||||
face window keyword rgb:${theme.green.bright}
|
||||
face window meta keyword
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
'');
|
||||
|
||||
# Haskell development. Haskell has a language server with
|
||||
# the features in `ide-full`.
|
||||
haskell-config = (lib.optionalString haskell ''
|
||||
hook global WinSetOption filetype=haskell %{
|
||||
hook global WinSetOption filetype=haskell %{
|
||||
|
||||
${ide-full}
|
||||
|
||||
set-option buffer tabstop 2
|
||||
${ide-full}
|
||||
|
||||
set-option buffer tabstop 2
|
||||
|
||||
face global variable rgb:${theme.purple.normal}
|
||||
face global attribute keyword
|
||||
|
@ -116,52 +108,50 @@ let nix-config = (lib.optionalString nix ''
|
|||
face global value string
|
||||
face global meta rgb:${theme.pink.normal}
|
||||
|
||||
}
|
||||
}
|
||||
'');
|
||||
|
||||
# Rust development. Rust's language servers all support the
|
||||
# `ide-full` features.
|
||||
rust-config = (lib.optionalString rust ''
|
||||
hook global WinSetOption filetype=rust %{
|
||||
hook global WinSetOption filetype=rust %{
|
||||
|
||||
${ide-full}
|
||||
${ide-full}
|
||||
|
||||
hook global -group yeet ModuleLoaded rust %{
|
||||
hook global -group yeet ModuleLoaded rust %{
|
||||
|
||||
# Override the Rust highlighting with semantic
|
||||
# tokens supplied by the LSP client
|
||||
remove-hooks global rust-highlight
|
||||
remove-highlighter shared/rust
|
||||
# Override the Rust highlighting with semantic
|
||||
# tokens supplied by the LSP client
|
||||
remove-hooks global rust-highlight
|
||||
remove-highlighter shared/rust
|
||||
|
||||
# Request tokens
|
||||
lsp-semantic-tokens
|
||||
|
||||
# Self-destruct this hook (it should only run once)
|
||||
remove-hooks global yeet
|
||||
# Request tokens
|
||||
lsp-semantic-tokens
|
||||
|
||||
}
|
||||
# Self-destruct this hook (it should only run once)
|
||||
remove-hooks global yeet
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
'');
|
||||
|
||||
in pkgs.writeTextFile (rec {
|
||||
name = "kakrc.kak";
|
||||
name = "kakrc.kak";
|
||||
destination = "/share/kak/autoload/${name}";
|
||||
text = ''
|
||||
colorscheme colors;
|
||||
set global tabstop 4
|
||||
|
||||
colorscheme colors;
|
||||
|
||||
add-highlighter global/ number-lines -separator ' │ ' -hlcursor
|
||||
add-highlighter global/ number-lines -separator ' │ ' -hlcursor
|
||||
|
||||
set global tabstop 4
|
||||
face global InlayHint rgb:828282
|
||||
face global InlayDiagnosticWarning rgb:a39e31+f
|
||||
face global InlayDiagnosticError rgb:ad494f+f
|
||||
face global InlayDiagnosticHint rgb:4d965a+f
|
||||
face global InlayDiagnosticInfo rgb:4d965a+f
|
||||
|
||||
face global InlayHint rgb:828282
|
||||
face global InlayDiagnosticWarning rgb:a39e31+f
|
||||
face global InlayDiagnosticError rgb:ad494f+f
|
||||
face global InlayDiagnosticHint rgb:4d965a+f
|
||||
face global InlayDiagnosticInfo rgb:4d965a+f
|
||||
|
||||
${keybinds}
|
||||
${keybinds}
|
||||
|
||||
${typescript-config}
|
||||
${haskell-config}
|
||||
|
@ -169,8 +159,6 @@ in pkgs.writeTextFile (rec {
|
|||
${rust-config}
|
||||
${nix-config}
|
||||
|
||||
hook global KakBegin .* %{
|
||||
cursorline
|
||||
}
|
||||
hook global KakBegin .* %{ cursorline }
|
||||
'';
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue