205 lines
5.9 KiB
Nix
205 lines
5.9 KiB
Nix
{
|
|
lib,
|
|
pkgs,
|
|
config,
|
|
...
|
|
}:
|
|
let
|
|
inherit (lib)
|
|
mkIf
|
|
mkOption
|
|
optionals
|
|
mkEnableOption
|
|
;
|
|
inherit (lib.types)
|
|
str
|
|
int
|
|
attrs
|
|
listOf
|
|
package
|
|
;
|
|
|
|
cfg = config.home.editors;
|
|
in
|
|
{
|
|
options.home.editors.vscodium = {
|
|
enable = mkEnableOption "VSCodium - code editor.";
|
|
terminalShell = mkOption {
|
|
type = str;
|
|
default = "bash";
|
|
description = "VSCodium terminal shell.";
|
|
};
|
|
zoomLevel = mkOption {
|
|
type = int;
|
|
default = 0;
|
|
description = "VSCodium window zoom level.";
|
|
};
|
|
additionalExtensions = mkOption {
|
|
type = listOf package;
|
|
default = [ ];
|
|
description = "VSCodium additional extension packages";
|
|
};
|
|
minimalUI.enable = mkEnableOption "VSCodium minimal UI configuration.";
|
|
keys = mkOption {
|
|
type = listOf attrs;
|
|
default = [ ];
|
|
description = "Hot keys in VSCodium.";
|
|
};
|
|
nix.enable = mkEnableOption "Nix lang support in VSCodium.";
|
|
python.enable = mkEnableOption "Python lang support in VSCodium.";
|
|
rust.enable = mkEnableOption "Rust lang support in VSCodium.";
|
|
toml.enable = mkEnableOption "TOML support in VSCodium.";
|
|
markdown.enable = mkEnableOption "Markdown support in VSCodium.";
|
|
};
|
|
|
|
config = mkIf cfg.enable {
|
|
programs.vscode = mkIf cfg.vscodium.enable {
|
|
enable = true;
|
|
package = pkgs.vscodium;
|
|
mutableExtensionsDir = false;
|
|
profiles.default = {
|
|
enableUpdateCheck = false;
|
|
enableExtensionUpdateCheck = false;
|
|
extensions =
|
|
cfg.vscodium.additionalExtensions
|
|
++ 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
|
|
]
|
|
++ optionals cfg.vscodium.python.enable [
|
|
pkgs.vscode-marketplace.ms-python.python
|
|
pkgs.vscode-marketplace.njpwerner.autodocstring
|
|
pkgs.vscode-marketplace.ms-python.black-formatter
|
|
]
|
|
++ optionals cfg.vscodium.rust.enable [
|
|
pkgs.vscode-marketplace.rust-lang.rust-analyzer
|
|
]
|
|
++ optionals cfg.vscodium.toml.enable [
|
|
pkgs.vscode-marketplace.be5invis.toml
|
|
]
|
|
++ 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]" = mkIf cfg.vscodium.nix.enable {
|
|
editor = {
|
|
formatOnSave = true;
|
|
formatOnPaste = false;
|
|
formatOnType = false;
|
|
rulers = [ 90 ];
|
|
defaultFormatter = "brettm12345.nixfmt-vscode";
|
|
};
|
|
};
|
|
nixfmt = mkIf cfg.vscodium.nix.enable {
|
|
path = "${pkgs.nixfmt-rfc-style}/bin/nixfmt";
|
|
};
|
|
|
|
"[python]" = 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 = mkIf cfg.vscodium.python.enable {
|
|
args = [
|
|
"--line-length=70"
|
|
];
|
|
};
|
|
files = mkIf cfg.vscodium.python.enable {
|
|
exclude = {
|
|
"**/.venv" = true;
|
|
"**/__pycache__" = true;
|
|
};
|
|
autoSave = "off";
|
|
};
|
|
|
|
"[rust]" = mkIf cfg.vscodium.rust.enable {
|
|
editor = {
|
|
formatOnSave = true;
|
|
formatOnPaste = true;
|
|
formatOnType = false;
|
|
|
|
rulers = [ 90 ];
|
|
|
|
defaultFormatter = "rust-lang.rust-analyzer";
|
|
};
|
|
};
|
|
|
|
"[markdown]" = 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 = mkIf cfg.vscodium.minimalUI.enable {
|
|
confirmDelete = false;
|
|
confirmDragAndDrop = false;
|
|
confirmPasteNative = false;
|
|
};
|
|
|
|
workbench = 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 = mkIf cfg.vscodium.minimalUI.enable {
|
|
minimap.enabled = false;
|
|
unicodeHighlight.allowedLocales = {
|
|
ru = true;
|
|
};
|
|
};
|
|
chat = mkIf cfg.vscodium.minimalUI.enable {
|
|
commandCenter.enabled = false;
|
|
};
|
|
|
|
breadcrumbs = mkIf cfg.vscodium.minimalUI.enable {
|
|
enabled = false;
|
|
};
|
|
};
|
|
};
|
|
};
|
|
};
|
|
}
|