{ config, inputs, 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.open-vsx; [ editorconfig.editorconfig efoerster.texlab github.vscode-pull-request-github gitlab.gitlab-workflow golang.go graphql.vscode-graphql hashicorp.hcl hashicorp.terraform haskell.haskell jnoortheen.nix-ide kahole.magit mads-hartmann.bash-ide-vscode mkhl.direnv ms-kubernetes-tools.vscode-kubernetes-tools ms-python.python redhat.ansible redhat.vscode-xml redhat.vscode-yaml rust-lang.rust streetsidesoftware.code-spell-checker streetsidesoftware.code-spell-checker-british-english streetsidesoftware.code-spell-checker-russian streetsidesoftware.code-spell-checker-scientific-terms tamasfe.even-better-toml vscode-org-mode.org-mode ziglang.vscode-zig ] ++ 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.integrated = { inherit fontFamily fontSize; enableBell = true; }; update = { mode = "none"; showReleaseNotes = false; }; telemetry = { enableCrashReporter = false; enableTelemetry = false; }; security.workspace.trust.enabled = false; # Extensions. ansible = { ansible = { useFullyQualifiedCollectionNames = true; reuseTerminal = true; }; validation.lint.path = "${pkgs.ansible-lint}/bin/ansible-lint"; }; bashIde.shellcheckPath = "${pkgs.shellcheck}/bin/shellcheck"; cSpell.language = "en-GB,ru"; magit = { forge-enabled = true; git-path = "${config.hm.programs.git.package}/bin/git"; }; github = { branchProtection = true; gitProtocol = "ssh"; }; terraform = { languageServer.path = "${pkgs.terraform-ls}/bin/terraform-ls"; languageServer.terraform.path = "${pkgs.terraform}/bin/terraform"; }; haskell = { formattingProvider = "ormolu"; serverExecutablePath = "${pkgs.haskell-language-server}/bin/haskell-language-server"; }; nix = { enableLanguageServer = true; serverPath = "${pkgs.rnix-lsp}/bin/rnix-lsp"; }; python = with pkgs.python311Packages; { experiments.optOutFrom = ["All"]; pipenvPath = "${pkgs.pipenv}/bin/pipenv"; poetryPath = "${pkgs.poetry}/bin/poetry"; formatting = { provider = "black"; autopep8Path = "${autopep8}/bin/autopep8"; blackPath = "${black}/bin/black"; yapfPath = "${yapf}/bin/yapf"; }; linting = { enabled = true; banditPath = "${bandit}/bin/bandit"; flake8Path = "${flake8}/bin/flake8"; mypyPath = "${mypy}/bin/mypy"; pycodestylePath = "${pycodestyle}/bin/pycodestyle"; pydocstylePath = "${pydocstyle}/bin/pydocstyle"; pylamaPath = "${pylama}/bin/pylama"; pylintPath = "${pylint}/bin/pylint"; }; testing = { pytestPath = "${pytest}/bin/pytest"; }; }; rust-client = { disableRustup = true; rustupPath = "${pkgs.rustup}/bin/rustup"; rlsPath = "${pkgs.rustup}/bin/rls"; rustfmt_path = "${pkgs.rustfmt}/bin/rustfmt"; }; vim = mkIf cfg.vim.enable rec { easymotion = true; easymotionMarkerFontFamily = fontFamily; easymotionMarkerFontSize = fontSize; leader = " "; useSystemClipboard = true; }; zig.zls = { checkForUpdate = false; path = "${pkgs.zls}/bin/zls"; }; redhat.telemetry.enabled = false; }; }; nixpkgs.overlays = [inputs.nix-vscode-extensions.overlays.default]; }; }