Start refactor of kakoune config

This commit is contained in:
Riley Apeldoorn 2022-05-15 23:32:21 +02:00
parent fc7ff7f450
commit 8af394d0bd
4 changed files with 164 additions and 3 deletions

21
modules/kak/colors.nix Normal file
View file

@ -0,0 +1,21 @@
{ theme, lib, pkgs }:
pkgs.writeTextFile (rec {
name = "colors.kak";
destination = "/share/kak/colors/${name}";
text = with theme; ''
face global comment rgb:525252
face global value rgb:${blue.normal}
face global string rgb:${green.normal}
face global keyword rgb:${cyan.normal}
face global operator rgb:${cyan.normal}
face global function rgb:${cyan.normal}
face global builtin rgb:${orange.normal}
face global module rgb:${yellow.normal}
face global meta rgb:${green.bright}
face global type rgb:${blue.bright}
'';
})

View file

@ -136,12 +136,18 @@ let kakrc = pkgs.writeTextFile (rec {
in with lib; { in with lib; {
options.riley = { options.editor = {
kak.enable = (mkEnableOption "kakoune editor") // { default = true; }; kak.enable = (mkEnableOption "kakoune editor") // { default = true; };
kak.ide = mkEnableOption "kakoune with ide plugins";
kak.ide = (mkEnableOption "kakoune with ide plugins") // { default = false; };
kak.rust = mkEnableOption "Rust support in Kakoune";
kak.haskell = mkEnableOption "Haskell support in Kakoune";
}; };
config = mkIf (config.riley.kak.enable || config.riley.kak.ide) { config = mkIf (config.editor.kak.enable || config.editor.kak.ide) {
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [
(pkgs.kakoune.override { (pkgs.kakoune.override {

62
modules/kak/kakoune.nix Normal file
View file

@ -0,0 +1,62 @@
# Preconfigured kakoune editor.
{
# Feature flags
typescript ? false,
haskell ? false,
python ? false,
rust ? false,
nix ? true,
# Allow extra plugins to be defined
# outside of the package
extraPlugins ? [],
# Color theme
theme,
# Build context
pkgs,
lib
}:
let kakrc = (import ./kakrc.nix {
inherit typescript
haskell
python
rust
nix
theme
pkgs
lib;
});
colors = (import ./colors.nix {
inherit theme
pkgs
lib;
});
kak-lsp = (import ./kak-lsp.nix {
inherit typescript
haskell
python
rust
nix
pkgs
lib;
});
in (pkgs.kakoune.override {
plugins = [
# Configuration
kak-lsp
colors
kakrc
# Plugins
crosshairs
] ++ extraPlugins;
})

72
modules/kak/kakrc.nix Normal file
View file

@ -0,0 +1,72 @@
# Defines the kakrc.
{
# Feature flags
typescript ? false,
haskell ? false,
python ? false,
rust ? false,
nix ? true,
# Color theme
theme,
# Build tools
pkgs,
lib,
}:
# If any of the language features are enabled, enable the
# extra language server-related keybinds and options.
let ide = typescript || haskell || python || rust || nix;
# Generic keybinds
keybinds = ''
'';
# IDE mode enables the language server protocol client
# and adds keybinds for lsp-hover and lsp-code-actions.
# If `rust` is enabled, lsp-semantic-tokens is also used.
ide-config = (lib.optionalString ide ''
'');
# Sometimes work requires me to touch the frontend. Ew
typescript-config = (lib.optionalString typescript ''
'');
# Haskell development
haskell-config = (lib.optionalString haskell ''
'');
# Python-related config
python-config = (lib.optionalString python ''
'');
# Rust development
rust-config = (lib.optionalString rust ''
'');
# Nix hacking-related configuration
nix-config = (lib.optionalString nix ''
'');
in pkgs.writeTextFile (rec {
name = "kakrc.kak";
destination = "/share/kak/autoload/${name}";
text = with theme; ''
'' ++ keybinds
++ typescript-config
++ haskell-config
++ python-config
++ rust-config
++ nix-config;
})