add (home options): all my editors configuration options

This commit is contained in:
Kirill Samoylenkov 2025-09-30 00:29:50 +05:00
parent fbb1bd2530
commit 453e0b68eb
3 changed files with 422 additions and 0 deletions

View file

@ -0,0 +1,17 @@
{
lib,
config,
...
}:
let
cfg = config.home.editors;
in
{
options.home.editors = {
enable = lib.mkOption {
type = lib.types.bool;
default = false;
description = "Text, media & audio editors configurations.";
};
};
}

View file

@ -0,0 +1,186 @@
{
lib,
pkgs,
inputs,
config,
...
}:
let
cfg = config.home.editors;
in
{
options.home.editors.helix = {
enable = lib.mkOption {
type = lib.types.bool;
default = false;
description = "Helix - text editor.";
};
defaultEditor = lib.mkOption {
type = lib.types.bool;
default = false;
description = "Make Helix default editor.";
};
systemArch = lib.mkOption {
type = lib.types.str;
default = pkgs.system;
description = "System arch for Helix flake package.";
};
keys = lib.mkOption {
type = lib.types.attrs;
default = { };
description = "Hot keys in Helix editor.";
};
nix.enable = lib.mkOption {
type = lib.types.bool;
default = false;
description = "Nix lang support in Helix.";
};
python.enable = lib.mkOption {
type = lib.types.bool;
default = false;
description = "Python lang support in Helix.";
};
rust.enable = lib.mkOption {
type = lib.types.bool;
default = false;
description = "Rust lang support in Helix.";
};
json.enable = lib.mkOption {
type = lib.types.bool;
default = false;
description = "JSON support in Helix.";
};
};
config = lib.mkIf cfg.enable {
programs.helix = lib.mkIf cfg.helix.enable {
enable = true;
defaultEditor = cfg.helix.defaultEditor;
package = inputs.helix.packages.${cfg.helix.systemArch}.helix;
settings.editor = {
auto-format = true;
idle-timeout = 200;
mouse = false;
scrolloff = 8;
middle-click-paste = false;
true-color = true;
line-number = "relative";
rulers = [ 90 ];
cursorline = true;
cursor-shape = {
normal = "block";
insert = "bar";
select = "underline";
};
soft-wrap = {
enable = true;
wrap-indicator = "";
wrap-at-text-width = true;
};
lsp = {
enable = true;
display-messages = true;
snippets = true;
display-inlay-hints = true;
};
file-picker = {
hidden = false;
git-ignore = false;
git-global = true;
};
};
settings.keys = cfg.helix.keys;
ignores = [
".git/"
]
++ lib.optionals cfg.helix.python.enable [
"__pycache__/"
".ruff_cache/"
".venv/"
]
++ lib.optionals cfg.helix.rust.enable [
"target/"
];
languages.language =
lib.optional cfg.helix.nix.enable {
name = "nix";
file-types = [ "nix" ];
auto-format = true;
indent = {
tab-width = 2;
unit = " ";
};
formatter.command = "${pkgs.nixfmt-rfc-style}/bin/nixfmt";
language-servers = [ "nixd" ];
}
++ lib.optional cfg.helix.rust.enable {
name = "rust";
file-types = [ "rs" ];
auto-format = true;
indent = {
tab-width = 4;
unit = " ";
};
formatter.command = "${pkgs.rustfmt}/bin/rustfmt";
language-servers = [ "rust-analyzer" ];
}
++ lib.optional cfg.helix.python.enable {
name = "python";
file-types = [ "py" ];
auto-format = true;
indent = {
tab-width = 4;
unit = " ";
};
language-servers = [ "ruff" ];
formatter = {
command = "${pkgs.black}/bin/black";
args = [
"--quiet"
"--line-length=90"
"-"
];
};
}
++ lib.optional cfg.helix.json.enable {
name = "json";
auto-format = true;
language-servers = [ "vscode-json" ];
formatter.command = "${pkgs.vscode-langservers-extracted}/bin/vscode-json-language-server";
};
languages.language-server = {
nixd = lib.mkIf cfg.helix.nix.enable {
command = "${pkgs.nixd}/bin/nixd";
};
rust-analyzer = lib.mkIf cfg.helix.rust.enable {
command = "${pkgs.rust-analyzer}/bin/rust-analyzer";
};
ruff = lib.mkIf cfg.helix.python.enable {
command = "${pkgs.ruff}/bin/ruff";
args = [ "server" ];
config.settings = {
lineLength = 89;
logLevel = "debug";
};
};
vscode-json = lib.mkIf cfg.helix.json.enable {
command = "${pkgs.vscode-langservers-extracted}/bin/vscode-json-language-server";
};
};
};
};
}

View file

@ -0,0 +1,219 @@
{
lib,
pkgs,
config,
...
}:
let
cfg = config.home.editors;
in
{
options.home.editors.vscodium = {
enable = lib.mkOption {
type = lib.types.bool;
default = false;
description = "VSCodium - code editor.";
};
terminalShell = lib.mkOption {
type = lib.types.str;
default = "bash";
description = "VSCodium terminal shell.";
};
zoomLevel = lib.mkOption {
type = lib.types.int;
default = 0;
description = "VSCodium window zoom level.";
};
additionalExtensions = lib.mkOption {
type = lib.types.listOf lib.types.package;
default = [ ];
description = "VSCodium additional extension packages";
};
minimalUI.enable = lib.mkOption {
type = lib.types.bool;
default = false;
description = "VSCodium minimal UI configuration.";
};
keys = lib.mkOption {
type = lib.types.listOf lib.types.attrs;
default = [ ];
description = "Hot keys in VSCodium.";
};
nix.enable = lib.mkOption {
type = lib.types.bool;
default = false;
description = "Nix lang support in VSCodium.";
};
python.enable = lib.mkOption {
type = lib.types.bool;
default = false;
description = "Python lang support in VSCodium.";
};
rust.enable = lib.mkOption {
type = lib.types.bool;
default = false;
description = "Rust lang support in VSCodium.";
};
toml.enable = lib.mkOption {
type = lib.types.bool;
default = false;
description = "TOML support in VSCodium.";
};
markdown.enable = lib.mkOption {
type = lib.types.bool;
default = false;
description = "Markdown support in VSCodium.";
};
};
config = lib.mkIf cfg.enable {
programs.vscode = lib.mkIf cfg.vscodium.enable {
enable = true;
package = pkgs.vscodium;
mutableExtensionsDir = false;
profiles.default = {
enableUpdateCheck = false;
enableExtensionUpdateCheck = false;
extensions =
cfg.vscodium.additionalExtensions
++ lib.optionals cfg.vscodium.nix.enable [
pkgs.vscode-marketplace.bbenoist.nix
pkgs.vscode-marketplace.jnoortheen.nix-ide
pkgs.vscode-marketplace.kamadorueda.alejandra
pkgs.vscode-marketplace.brettm12345.nixfmt-vscode
pkgs.vscode-marketplace.arrterian.nix-env-selector
pkgs.vscode-marketplace.jeff-hykin.better-nix-syntax
]
++ lib.optionals cfg.vscodium.python.enable [
pkgs.vscode-marketplace.ms-python.python
pkgs.vscode-marketplace.njpwerner.autodocstring
pkgs.vscode-marketplace.ms-python.black-formatter
]
++ lib.optionals cfg.vscodium.rust.enable [
pkgs.vscode-marketplace.rust-lang.rust-analyzer
]
++ lib.optionals cfg.vscodium.toml.enable [
pkgs.vscode-marketplace.be5invis.toml
]
++ lib.optionals cfg.vscodium.markdown.enable [
pkgs.vscode-marketplace.mervin.markdown-formatter
];
keybindings = cfg.vscodium.keys;
userSettings = {
terminal.integrated.defaultProfile.linux = cfg.vscodium.terminalShell;
window = {
zoomLevel = cfg.vscodium.zoomLevel;
titleBarStyle = "custom";
};
"[nix]" = lib.mkIf cfg.vscodium.nix.enable {
editor = {
formatOnSave = true;
formatOnPaste = false;
formatOnType = false;
rulers = [ 90 ];
defaultFormatter = "brettm12345.nixfmt-vscode";
};
};
nixfmt = lib.mkIf cfg.vscodium.nix.enable {
path = "${pkgs.nixfmt-rfc-style}/bin/nixfmt";
};
"[python]" = lib.mkIf cfg.vscodium.python.enable {
editor = {
formatOnSave = true;
formatOnPaste = true;
formatOnType = false;
rulers = [ 70 ];
defaultFormatter = "ms-python.black-formatter";
codeActionsOnSave = {
source.organizeImports = true;
};
};
};
black-formatter = lib.mkIf cfg.vscodium.python.enable {
args = [
"--line-length=70"
];
};
files = lib.mkIf cfg.vscodium.python.enable {
exclude = {
"**/.venv" = true;
"**/__pycache__" = true;
};
autoSave = "off";
};
"[rust]" = lib.mkIf cfg.vscodium.rust.enable {
editor = {
formatOnSave = true;
formatOnPaste = true;
formatOnType = false;
rulers = [ 90 ];
defaultFormatter = "rust-lang.rust-analyzer";
};
};
"[markdown]" = lib.mkIf cfg.vscodium.markdown.enable {
formatOnSave = true;
formatOnPaste = true;
formatOnType = false;
editor.renderWhitespace = "all";
editor.quickSuggestions = {
other = true;
comments = true;
strings = true;
};
editor.tabCompletion = "on";
editor.snippetSuggestions = "top";
editor.acceptSuggestionOnEnter = "on";
editor.defaultFormatter = "mervin.markdown-formatter";
};
explorer = lib.mkIf cfg.vscodium.minimalUI.enable {
confirmDelete = false;
confirmDragAndDrop = false;
confirmPasteNative = false;
};
workbench = lib.mkIf cfg.vscodium.minimalUI.enable {
startupEditor = "none";
sideBar.location = "right";
activityBar.location = "hidden";
layoutControl.enabled = false;
navigationControl.enabled = false;
editor.showTabs = "single";
editor.showIcons = false;
editor.labelFormat = "medium";
editor.rulers = [ 100 ];
};
editor = lib.mkIf cfg.vscodium.minimalUI.enable {
minimap.enabled = false;
unicodeHighlight.allowedLocales = {
ru = true;
};
};
chat = lib.mkIf cfg.vscodium.minimalUI.enable {
commandCenter.enabled = false;
};
breadcrumbs = lib.mkIf cfg.vscodium.minimalUI.enable {
enabled = false;
};
};
};
};
};
}