234 lines
6.1 KiB
Nix
234 lines
6.1 KiB
Nix
{ pkgs, lib, config, ... }:
|
|
|
|
let
|
|
# Configuration for kakoune plugins
|
|
pluginConfigs = with pkgs.kakounePlugins; [
|
|
{ # FZF for kakoune
|
|
pkg = fzf-kak;
|
|
mappings = [{
|
|
docstring = "FZF mode";
|
|
mode = "user";
|
|
key = "f";
|
|
effect = ":fzf-mode<ret>";
|
|
}];
|
|
hooks = [{ # Change fzf settings before first use
|
|
name = "ModuleLoaded";
|
|
option = "fzf-file";
|
|
commands = ''
|
|
set-option global fzf_file_command "fd"
|
|
set-option global fzf_highlight_command "bat"
|
|
'';
|
|
}];
|
|
}
|
|
|
|
{ # Languange Server Config
|
|
pkg = kak-lsp;
|
|
config = ''
|
|
eval %sh{kak-lsp --kakoune -s $kak_session}
|
|
|
|
hook global WinSetOption filetype=rust %{
|
|
hook window -group rust-inlay-hints BufReload .* rust-analyzer-inlay-hints
|
|
hook window -group rust-inlay-hints NormalIdle .* rust-analyzer-inlay-hints
|
|
hook window -group rust-inlay-hints InsertIdle .* rust-analyzer-inlay-hints
|
|
hook -once -always window WinSetOption filetype=.* %{
|
|
remove-hooks window rust-inlay-hints
|
|
}
|
|
}
|
|
'';
|
|
mappings = [{ # Enter LSP Usermode
|
|
docstring = "LSP mode";
|
|
mode = "user";
|
|
key = "l";
|
|
effect = ":enter-user-mode lsp<ret>";
|
|
}];
|
|
hooks = [{ # Start kak-lsp for specific windows
|
|
name = "WinSetOption";
|
|
commands = "lsp-enable-window";
|
|
option = "filetype=(rust|nix|python|latex|typescript|javascript)";
|
|
}];
|
|
}
|
|
|
|
];
|
|
|
|
additionalMappings = [{ # Switch to last buffer
|
|
docstring = "Previous buffer";
|
|
mode = "user";
|
|
key = ",";
|
|
effect = ":buffer-previous<ret>";
|
|
}];
|
|
|
|
additionalConfig = ''
|
|
add-highlighter global/ number-lines -relative
|
|
add-highlighter global/ wrap -word -indent
|
|
|
|
# Do something about tabs..
|
|
map global insert <tab> ' '
|
|
hook global BufSetOption filetype=nix %{
|
|
map buffer insert <tab> ' '
|
|
}
|
|
'';
|
|
|
|
selectOr = attr: default: map (conf: conf.${attr} or default) pluginConfigs;
|
|
selectList = attr: lib.flatten (selectOr attr [ ]);
|
|
|
|
in {
|
|
|
|
programs.kakoune = {
|
|
enable = true;
|
|
|
|
config = {
|
|
colorScheme = "gruvbox-dark";
|
|
ui.enableMouse = true;
|
|
|
|
hooks = selectList "hooks";
|
|
|
|
keyMappings = (selectList "mappings") ++ additionalMappings;
|
|
};
|
|
|
|
extraConfig = (toString (selectOr "config" "")) + additionalConfig;
|
|
|
|
plugins = map (conf: conf.pkg) pluginConfigs;
|
|
};
|
|
|
|
home.packages = with pkgs; [
|
|
# For Nix
|
|
rnix-lsp
|
|
# For Rust
|
|
rust-analyzer-nightly
|
|
# For Python
|
|
python3.pkgs.python-lsp-server
|
|
# For TypeScript
|
|
nodePackages.typescript
|
|
nodePackages.typescript-language-server
|
|
# For JavaScript
|
|
flow
|
|
];
|
|
|
|
xdg.configFile."kak-lsp/kak-lsp.toml".text = ''
|
|
[language.rust]
|
|
filetypes = ["rust"]
|
|
roots = ["Cargo.toml"]
|
|
command = "${pkgs.rust-analyzer-nightly}/bin/rust-analyzer"
|
|
settings_section = "rust-analyzer"
|
|
|
|
[language.rust.settings.rust-analyzer]
|
|
hoverActions.enable = true # kak-lsp doesn't support this at the moment
|
|
procMacro.enable = true
|
|
cargo.loadOutDirsFromCheck = true
|
|
|
|
[language.nix]
|
|
filetypes = ["nix"]
|
|
roots = ["flake.nix", "shell.nix", ".git", ".hg"]
|
|
command = "${pkgs.rnix-lsp}/bin/rnix-lsp"
|
|
|
|
[language.python]
|
|
filetypes = ["python"]
|
|
roots = ["requirements.txt", "setup.py", ".git", ".hg"]
|
|
command = "${pkgs.python3.pkgs.python-lsp-server}/bin/pylsp"
|
|
settings_section = "pylsp"
|
|
|
|
[language.python.settings.pylsp]
|
|
pylsp.configurationSources = ["flake8"]
|
|
|
|
[language.latex]
|
|
filetypes = ["latex"]
|
|
roots = [".git", ".hg"]
|
|
command = "${pkgs.texlab}/bin/texlab"
|
|
settings_section = "texlab"
|
|
[language.latex.settings.texlab]
|
|
# See https://github.com/latex-lsp/texlab/blob/master/docs/options.md
|
|
#
|
|
# Preview configuration for zathura with SyncTeX search.
|
|
# For other PDF viewers see https://github.com/latex-lsp/texlab/blob/master/docs/previewing.md
|
|
forwardSearch.executable = "${pkgs.zathura}/bin/zathura"
|
|
forwardSearch.args = [
|
|
"%p",
|
|
"--synctex-forward", # Support texlab-forward-search
|
|
"%l:1:%f",
|
|
"--synctex-editor-command", # use Control+Left-Mouse-Button to jump to source.
|
|
"""
|
|
sh -c '
|
|
echo "
|
|
evaluate-commands -client $kak_client %{
|
|
evaluate-commands -try-client %opt{jumpclient} %{
|
|
edit -- %{input} %{line}
|
|
}
|
|
}
|
|
" | kak -p $kak_session
|
|
'
|
|
""",
|
|
]
|
|
|
|
[language.typescript]
|
|
filetypes = ["typescript"]
|
|
roots = ["package.json", "tsconfig.json", ".git", ".hg"]
|
|
command = "${pkgs.nodePackages.typescript-language-server}/bin/typescript-language-server"
|
|
args = [
|
|
"--stdio",
|
|
"--tsserver-path=${pkgs.nodePackages.typescript}/lib/node_modules/typescript/lib"
|
|
]
|
|
|
|
[language.javascript]
|
|
filetypes = ["javascript"]
|
|
roots = [".flowconfig"]
|
|
command = "${pkgs.flow}/bin/flow"
|
|
args = ["lsp"]
|
|
|
|
# Semantic tokens support
|
|
[[semantic_tokens]]
|
|
token = "comment"
|
|
face = "documentation"
|
|
modifiers = ["documentation"]
|
|
|
|
[[semantic_tokens]]
|
|
token = "comment"
|
|
face = "comment"
|
|
|
|
[[semantic_tokens]]
|
|
token = "function"
|
|
face = "function"
|
|
|
|
[[semantic_tokens]]
|
|
token = "keyword"
|
|
face = "keyword"
|
|
|
|
[[semantic_tokens]]
|
|
token = "namespace"
|
|
face = "module"
|
|
|
|
[[semantic_tokens]]
|
|
token = "operator"
|
|
face = "operator"
|
|
|
|
[[semantic_tokens]]
|
|
token = "string"
|
|
face = "string"
|
|
|
|
[[semantic_tokens]]
|
|
token = "type"
|
|
face = "type"
|
|
|
|
[[semantic_tokens]]
|
|
token = "variable"
|
|
face = "default+d"
|
|
modifiers = ["readonly"]
|
|
|
|
[[semantic_tokens]]
|
|
token = "variable"
|
|
face = "default+d"
|
|
modifiers = ["constant"]
|
|
|
|
[[semantic_tokens]]
|
|
token = "variable"
|
|
face = "variable"
|
|
'';
|
|
|
|
systemd.user.sessionVariables = {
|
|
EDITOR = "${pkgs.kakoune}/bin/kak";
|
|
VISUAL = "${pkgs.kitty}/bin/kitty ${pkgs.kakoune}/bin/kak";
|
|
};
|
|
pam.sessionVariables = {
|
|
EDITOR = config.systemd.user.sessionVariables.EDITOR;
|
|
};
|
|
}
|