219 lines
6.4 KiB
Nix
219 lines
6.4 KiB
Nix
{
|
|
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;
|
|
};
|
|
};
|
|
};
|
|
};
|
|
};
|
|
}
|