diff options
Diffstat (limited to 'modules/common/vscode.nix')
-rw-r--r-- | modules/common/vscode.nix | 167 |
1 files changed, 167 insertions, 0 deletions
diff --git a/modules/common/vscode.nix b/modules/common/vscode.nix new file mode 100644 index 0000000..6671973 --- /dev/null +++ b/modules/common/vscode.nix @@ -0,0 +1,167 @@ +{ + config, + lib, + pkgs, + ... +}: +with lib; let + cfg = config.nixfiles.modules.vscode; +in { + options.nixfiles.modules.vscode = { + enable = mkEnableOption "VSCode"; + + package = with pkgs; + mkOption { + type = types.enum [vscodium vscode vscode-fhs]; + default = vscodium; + description = "Which package to use as a VSCode implementation."; + }; + + vim.enable = mkOption { + type = types.bool; + default = true; + description = "Whether to enable Vim emulation."; + }; + }; + + config = mkIf cfg.enable { + hm.programs.vscode = with config.nixfiles; + with modules; + with profiles; { + enable = true; + + inherit (cfg) package; + + extensions = with pkgs; + with vscode-extensions; + [ + editorconfig.editorconfig + file-icons.file-icons + gitlab.gitlab-workflow + ms-kubernetes-tools.vscode-kubernetes-tools + redhat.vscode-xml + redhat.vscode-yaml + streetsidesoftware.code-spell-checker + ] + ++ optional cfg.vim.enable vscodevim.vim; + + userSettings = let + font = config.fontScheme.monospaceFont; + fontFamily = font.family; + fontSize = font.size; + in { + editor = + { + inherit fontFamily fontSize; + inlayHints = {inherit fontFamily fontSize;}; + codeLens = false; + cursorStyle = "block"; + detectIndentation = true; + minimap.enabled = false; + renderWhitespace = "trailing"; + rulers = [80 120]; + smoothScrolling = false; + tabCompletion = "on"; + } + // (let + surround = 10; + in { + cursorSurroundingLines = surround; + scrollBeyondLastColumn = surround; + }); + + keyboard.dispatch = "keyCode"; + + diffEditor.codeLens = false; + + files = { + autoSave = "off"; + enableTrash = false; + }; + + workbench = { + activityBar.visible = false; + editor.highlightModifiedTabs = true; + enableExperiments = false; + settings.enableNaturalLanguageSearch = false; + startupEditor = "none"; + tips.enabled = false; + tree.indent = 4; + welcomePage = { + walkthroughs.openOnInstall = false; + preferReducedMotion = true; + }; + }; + + debug.console = {inherit fontFamily fontSize;}; + + scm = { + inputFontFamily = fontFamily; + inputFontSize = fontSize; + }; + + extensions = { + autoCheckUpdates = false; + autoUpdate = false; + ignoreRecommendations = true; + }; + + terminal = { + external.linuxExec = + if alacritty.enable + then "${pkgs.alacritty}/bin/alacritty" + else "${pkgs.xterm}/bin/xterm}"; + + integrated = { + inherit fontFamily fontSize; + enableBell = true; + }; + }; + + update = { + mode = "none"; + showReleaseNotes = false; + }; + + telemetry = { + enableCrashReporter = false; + enableTelemetry = false; + }; + + security.workspace.trust.enabled = false; + + git.allowForcePush = true; + + vim = let + applyInputMethod = { + "ibus" = let + bin = "${pkgs.ibus}/bin/ibus"; + in { + enable = true; + defaultIM = "xkb:us::eng"; + obtainIMCmd = "${bin} engine"; + switchIMCmd = "${bin} engine {im}"; + }; + "fcitx" = let + bin = "${pkgs.fcitx}/bin/fcitx-remote"; + in { + enable = true; + defaultIM = "1"; + obtainIMCmd = bin; + switchIMCmd = "${bin} -t {im}"; + }; + }; + in + mkIf cfg.vim.enable rec { + easymotion = true; + easymotionMarkerFontFamily = fontFamily; + easymotionMarkerFontSize = fontSize; + + leader = " "; + + useSystemClipboard = true; + }; + }; + }; + }; +} |