in {
home-manager.sharedModules = [{
programs.helix = enabled {
# Pywal output doesn't have gradients like base16 needs.
# So it's necessary to override a few colours.
inherits = "base16_default";
"comment".fg = if config.theme.is_dark then "#909090" else "#C0C0C0";
# Selections.
} // genAttrs [ "ui.selection" "ui.selection.primary" ] (const {
bg = if config.theme.is_dark then "#707070" else "#E0E0E0";
})
# Cursorline and popups.
// genAttrs [ "ui.cursorline.primary" "ui.cursorline.secondary" "ui.popup" "ui.popup.info" ] (const {
bg = if config.theme.is_dark then "#404040" else "#F0F0F0";
})
# Info.
// genAttrs [ "hint" "info" "diagnostic" "diagnostic.hint" "diagnostic.info" "diagnostic.unnecessary" ] (const {
})
# Warnings.
// genAttrs [ "warning" "diagnostic.warning" "diagnostic.deprecated" ] (const {
fg = if config.theme.is_dark then "#B58900" else "#9D8740"; # Muted yellow.
})
# Errors.
// genAttrs [ "error" "diagnostic.error" ] (const {
fg = if config.theme.is_dark then "#9D0006" else "#8F3F71"; # Muted red/brown.
});
fg = if config.theme.is_dark then "#2B83A6" else "#3A8C9A"; # Muted teal.
themes.base16_custom = {
# Also added overrides for diagnostic colours which don't work well from Pywal.
};
}];
environment.shellAliases = {
nvim = "echo 'no more neovim, use hx'";
nv = "echo 'no more neovim, use hx'";
vim = "echo 'no more vim, use hx'";
v = "echo 'no more vim, use hx'";
h = "hx";
e = "hx"; # editor
};
environment.systemPackages = mkIf config.isDesktop [
# Rust
# rust-analyzer is in modules/common/rust.nix
pkgs.lldb
# Assembler
pkgs.asm-lsp
# TypeScript etc.
pkgs.deno
# Nix
pkgs.nixd
# YAML
pkgs.yaml-language-server
# JSON
pkgs.vscode-json-languageserver
# TOML
pkgs.taplo
# Svelte
pkgs.svelte-language-server
# Markdown
pkgs.mdformat
# Just
pkgs.just-lsp
pkgs.just-formatter
];
# Haskell
pkgs.fourmolu
pkgs.haskell-language-server
# Typos
pkgs.typos-lsp
pkgs.marksman
pkgs.nixfmt-rfc-style
}
settings.theme = if config.theme.color_scheme == "pywal" then "base16_custom" else config.theme.helix;
D = "extend_to_line_end";
});
languages.language = let
denoFmtLanguages = {
astro = "astro"; css = "css";
html = "html"; javascript = "js";
json = "json"; jsonc = "jsonc";
jsx = "jsx"; markdown = "md";
scss = "scss"; svelte = "svelte";
tsx = "tsx"; typescript = "ts";
vue = "vue"; yaml = "yaml";
}
|> mapAttrs (name: extension: {
inherit name;
auto-format = true;
formatter.command = "deno";
formatter.args = [ "fmt" "--use-tabs" "--no-semicolons" "--indent-width" "4" "--unstable-component" "--ext" extension "-" ];
} // optionalAttrs (elem name [ "javascript" "jsx" "typescript" "tsx" ]) {
})
|> attrValues;
in denoFmtLanguages ++ [
{
name = "nix";
auto-format = false;
}
{
name = "toml";
auto-format = true;
formatter.command = "taplo";
formatter.args = [ "fmt" "--option" "align_entries=true" "--option" "column_width=100" "--option" "compact_arrays=false" "--option" "reorder_inline_tables=true" "--option" "reorder_keys=true" "-" ];
}
{
name = "markdown";
}
# I can't get this working right now.
# {
# name = "rust";
# debugger.name = "lldb-dap";
# debugger.transport = "stdio";
# debugger.command = "lldb-dap";
# debugger.templates = [{
# name = "binary";
# request = "launch";
# args.program = "{0}";
# completion = [{
# name = "binary";
# completion = "filename";
# }];
# }];
# }
];
auto-format = true;
language-servers = [ "marksman" "typos" ];
}
{
name = "just";
auto-format = true;
formatter.command = "just-formatter";
language-servers = [ "just-lsp" "typos" ];
language-servers = [ "taplo" "typos" ];
language-servers = [ "nixd" "typos" ];
formatter.command = "nix fmt";
name = "rust";
auto-format = true;
}
{
language-servers = [ { name = "rust-analyzer"; except-features = [ "inlay-hints" ]; } "typos" ];
indent = { tab-width = 3; unit = " "; };
language-servers = [ "deno" "typos" ];
};
};
};
rust-analyzer = {
config = {
cargo.features = "all";
check.command = "clippy";
completion.callable.snippets = "add_parentheses";
};
except-features = [ "inlay-hints" ];
inlayHints.enumMemberValues.enabled = true;
inlayHints.functionLikeReturnTypes.enabled = true;
inlayHints.parameterNames.enabled = "all";
inlayHints.parameterTypes.enabled = true;
inlayHints.propertyDeclarationTypes.enabled = true;
inlayHints.variableTypes.enabled = true;
};
suggest.imports.hosts."https://deno.land" = true;
config.javascript = enabled {
lint = true;
unstable = true;
languages.language-server = mkIf config.isDesktop {
deno = {
command = "deno";
args = [ "lsp" ];
typos.command = "typos-lsp";
settings.keys = merge {
normal."C-y" = ":sh zellij run -n Yazi -c -f -x 10%% -y 10%% --width 80%% --height 80%% -- ${yaziPickerScript} open ...%{buffer_name}";
} <| genAttrs [ "normal" "select" ] (const {
settings.editor = {
completion-timeout = 5;
completion-replace = true;
color-modes = true;
cursorline = true;
file-picker.hidden = false;
idle-timeout = 0;
shell = [ "nu" "--commands" ];
trim-trailing-whitespace = true;
true-color = true;
lsp.display-inlay-hints = true;
inline-diagnostics.cursor-line = "hint";
# Nightly options:
word-completion.trigger-length = 3;
# rainbow-brackets = true;
};
settings.editor.cursor-shape = {
select = "underline";
};
settings.editor.indent-guides = {
character = "▏";
render = true;
};
settings.editor.whitespace = {
characters.tab = "→";
render.tab = "all";
};
insert = "bar";
normal = "block";
bufferline = "multiple";
package = inputs.helix.packages.${pkgs.stdenv.hostPlatform.system}.helix; # `.helix` follows the master branch.
yaziPickerScript = pkgs.writeShellScript "yazi-picker.sh" ''
#!/usr/bin/env bash
'';
if [[ -n "$paths" ]]; then
zellij action toggle-floating-panes
zellij action write 27 # send <Escape> key
zellij action write-chars ":$1 $paths"
zellij action write 13 # send <Enter> key
else
zellij action toggle-floating-panes
fi
paths=$(yazi "$2" --chooser-file=/dev/stdout | while read -r; do printf "%q " "$REPLY"; done)
inherit (lib) enabled const genAttrs mkIf elem mapAttrs optionalAttrs attrValues merge;
{ pkgs, lib, config, inputs, ... }: let