configuration/common/components/editor.user.nix
2023-05-17 11:40:54 -07:00

293 lines
12 KiB
Nix
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

{ lib, pkgs, ... }:
let
palette = import ../resources/palette.nix;
monospace = {
"editor.fontFamily" = "'Iosevka Custom Mono'";
"editor.wrappingStrategy" = "simple";
};
prettier = {
"editor.defaultFormatter" = "esbenp.prettier-vscode";
};
in
{
programs.vscode = {
enable = true;
package = pkgs.vscodium;
keybindings = [
{ key = "ctrl+j"; command = "-workbench.action.togglePanel"; }
{ key = "ctrl+j"; command = "editor.action.joinLines"; }
{ key = "shift+alt+m"; command = "editor.emmet.action.wrapWithAbbreviation"; }
{ key = "shift+alt+down"; command = "-editor.action.insertCursorBelow"; }
{ key = "shift+alt+down"; command = "editor.action.copyLinesDownAction"; }
{ key = "shift+alt+up"; command = "-editor.action.insertCursorAbove"; }
{ key = "shift+alt+up"; command = "editor.action.copyLinesUpAction"; }
{ key = "ctrl+k i"; command = "editor.action.formatChanges"; }
{ when = "isInDiffEditor"; key = "ctrl+s"; command = "git.stageSelectedRanges"; }
];
userSettings = {
# Dependencies
"hadolint.hadolintPath" = "${pkgs.hadolint}/bin/hadolint";
"nix.formatterPath" = "${pkgs.nixpkgs-fmt}/bin/nixpkgs-fmt";
"prettier.prettierPath" = "${pkgs.nodePackages.prettier}/lib/node_modules/prettier";
"python.formatting.blackPath" = "${pkgs.black}/bin/black";
"qalc.path" = "${pkgs.libqalculate}/bin/qalc";
"ruby.rubocop.executePath" = "${pkgs.rubocop}/bin/";
"ruff.path" = [ "${pkgs.ruff}/bin/ruff" ];
"shellcheck.executablePath" = "${pkgs.shellcheck}/bin/shellcheck";
"stylelint.stylelintPath" = "${pkgs.nodePackages.stylelint}/lib/node_modules/stylelint";
# Application
"breadcrumbs.enabled" = false;
"editor.acceptSuggestionOnCommitCharacter" = false;
"editor.acceptSuggestionOnEnter" = "off";
"editor.copyWithSyntaxHighlighting" = false;
"editor.cursorSurroundingLines" = 10;
"editor.dragAndDrop" = false;
"editor.fontFamily" = "'Iosevka Custom Proportional'";
"editor.fontLigatures" = true;
"editor.fontSize" = 15;
"editor.glyphMargin" = false;
"editor.inlayHints.enabled" = "off";
"editor.linkedEditing" = true;
"editor.minimap.enabled" = false;
"editor.multiCursorModifier" = "ctrlCmd";
"editor.suggest.localityBonus" = true;
"editor.unfoldOnClickAfterEndOfLine" = true;
"editor.wrappingStrategy" = "advanced";
"explorer.confirmDelete" = false;
"markdown.preview.linkify" = false;
"markdown-checkboxes.enable" = false;
"security.workspace.trust.banner" = "never";
"terminal.integrated.fontFamily" = "'Iosevka Custom Term'";
"update.mode" = "none";
"window.customMenuBarAltFocus" = false;
"window.enableMenuBarMnemonics" = false;
"window.titleBarStyle" = "custom";
"window.titleSeparator" = " · ";
"workbench.activityBar.visible" = false;
"workbench.colorTheme" = "Monokai";
"workbench.editor.closeEmptyGroups" = false;
"workbench.editor.tabCloseButton" = "off";
"workbench.editor.untitled.hint" = "hidden";
"workbench.enableExperiments" = false;
"workbench.iconTheme" = "material-icon-theme";
"workbench.sideBar.location" = "right";
"workbench.startupEditor" = "none";
"workbench.tips.enabled" = false;
# Formatting
"editor.tabSize" = 2;
"files.insertFinalNewline" = true;
"html.format.extraLiners" = "";
"html.format.indentInnerHtml" = true;
# Version control
"diffEditor.ignoreTrimWhitespace" = false;
"git.alwaysShowStagedChangesResourceGroup" = true;
"git.enableStatusBarSync" = false;
"git.showActionButton" = false;
"git.suggestSmartCommit" = false;
# Colors
"workbench.colorCustomizations" = {
# "activitybarbadge.background" = "#ff7042";
# "editor.selectionhighlightbackground" = "#54320a";
# "editorsuggestwidget.highlightforeground" = "#ff7042";
# "list.activeselectionforeground" = "#ff7042";
# "list.highlightforeground" = "#ff7042";
# "list.inactiveselectionforeground" = "#ff7042";
# "pickergroup.foreground" = "#ff7042";
# "progressbar.background" = "#ff7042";
# "scrollbarslider.activebackground" = "#ff704250";
# "tab.activeborder" = "#ff7042";
# "tab.inactivebackground" = "#1e1f1c";
# "textlink.foreground" = "#ff7042";
"terminal.foreground" = palette.white;
"terminal.background" = palette.black;
"terminal.ansiblack" = palette.dark-gray;
"terminal.ansired" = palette.red;
"terminal.ansigreen" = palette.green;
"terminal.ansiyellow" = palette.yellow;
"terminal.ansiblue" = palette.blue;
"terminal.ansimagenta" = palette.orange;
"terminal.ansicyan" = palette.purple;
"terminal.ansiwhite" = palette.white;
"terminal.ansibrightblack" = palette.gray;
"terminal.ansibrightred" = palette.red;
"terminal.ansibrightgreen" = palette.green;
"terminal.ansibrightyellow" = palette.yellow;
"terminal.ansibrightblue" = palette.blue;
"terminal.ansibrightmagenta" = palette.orange;
"terminal.ansibrightcyan" = palette.purple;
"terminal.ansibrightwhite" = palette.white;
"tab.inactiveBackground" = palette.black;
"editorGroupHeader.tabsBackground" = palette.black;
"editorGutter.addedBackground" = palette.purple;
"editorGutter.deletedBackground" = palette.purple;
"editorGutter.modifiedBackground" = palette.purple;
"editorOverviewRuler.addedForeground" = palette.purple;
"editorOverviewRuler.deletedForeground" = palette.purple;
"editorOverviewRuler.modifiedForeground" = palette.purple;
"gitDecoration.modifiedResourceForeground" = palette.purple;
"gitDecoration.untrackedResourceForeground" = palette.dark-purple;
"editorMarkerNavigationWarning.background" = palette.orange;
"editorOverviewRuler.warningForeground" = palette.orange;
"editorWarning.foreground" = palette.orange;
"list.warningForeground" = palette.orange;
"sideBar.border" = "#00000000";
"statusBar.border" = "#00000000";
"titleBar.border" = "#00000000";
"editor.findMatchHighlightBackground" = "#00000000";
"editor.findMatchHighlightBorder" = "#aaaaaa";
"editor.selectionHighlightBackground" = "#464646";
"editorError.foreground" = palette.dark-red;
"editorMarkerNavigationError.background" = palette.dark-red;
"editorOverviewRuler.errorForeground" = palette.dark-red;
"gitDecoration.conflictingResourceForeground" = palette.dark-red;
"inputValidation.errorBackground" = palette.dark-red;
"list.errorForeground" = palette.dark-red;
"list.invalidItemForeground" = palette.dark-red;
};
"editor.tokenColorCustomizations" = {
textMateRules = [
{ scope = "constant.numeric"; settings = { foreground = palette.yellow; }; }
{ scope = "constant.other.caps"; settings = { foreground = palette.light-gray; }; }
{ scope = "entity.name.function.macro"; settings = { foreground = palette.blue; }; }
{ scope = "entity.name.namespace"; settings = { foreground = palette.purple; }; }
{ scope = "entity.name.type.lifetime"; settings = { foreground = palette.orange; fontStyle = "italic"; }; }
{ scope = "entity.name.type.numeric"; settings = { foreground = palette.purple; fontStyle = ""; }; }
{ scope = "entity.name.type.primitive"; settings = { foreground = palette.purple; fontStyle = ""; }; }
{ scope = "entity.name.type"; settings = { foreground = palette.purple; fontStyle = "underline"; }; }
{ scope = "keyword.operator.access.dot"; settings = { foreground = palette.light-gray; }; }
{ scope = "keyword.operator.attribute"; settings = { foreground = palette.blue; }; }
{ scope = "keyword.operator.borrow"; settings = { foreground = palette.orange; }; }
{ scope = "keyword.operator.namespace"; settings = { foreground = palette.light-gray; }; }
{ scope = "meta.attribute"; settings = { foreground = palette.blue; }; }
{ scope = "meta.interpolation"; settings = { foreground = palette.light-gray; }; }
{ scope = "punctuation.brackets.angle.rust, keyword.operator.namespace.rust"; settings = { foreground = palette.purple; }; }
{ scope = "punctuation.definition.interpolation"; settings = { foreground = palette.red; }; }
{ scope = "punctuation.definition.lifetime"; settings = { foreground = palette.orange; fontStyle = "italic"; }; }
{ scope = "storage.type"; settings = { foreground = palette.red; fontStyle = ""; }; }
{ scope = "storage.modifier"; settings = { foreground = palette.orange; }; }
{ scope = "variable.language.self, variable.language.super"; settings = { foreground = palette.purple; fontStyle = "italic"; }; }
];
};
# Language-specific
"emmet.includeLanguages" = { postcss = "css"; };
"files.associations" =
(builtins.listToAttrs (map (n: lib.nameValuePair "*.log.${toString n}" "log") (lib.range 1 10))) // {
".ansible-lint" = "yaml";
".htmlnanorc" = "json";
".mapcss" = "css";
".parcelrc" = "jsonc";
".postcssrc" = "json";
"*.bu" = "yaml";
};
"python.formatting.provider" = "black";
"rust-analyzer.checkOnSave.command" = "clippy";
"[css]" = prettier;
"[diff]" = monospace;
"[git-commit]" = monospace // { "editor.rulers" = [ 50 72 ]; "rewrap.wrappingColumn" = 72; };
"[html]" = prettier;
"[javascript]" = prettier;
"[json]" = prettier;
"[jsonc]" = prettier;
"[markdown]" = monospace // { "editor.tabSize" = 4; };
"[plaintext]" = monospace;
"[postcss]" = prettier;
"[ruby]" = monospace;
"[typescript]" = prettier;
"[typescriptreact]" = prettier;
"[yaml]" = monospace;
# Highlights
"editor.unicodeHighlight.allowedCharacters" = {
"" = true;
"×" = true;
};
"highlight.decorations" = { rangeBehavior = 1; };
"highlight.regexFlags" = "g";
"highlight.regexes" = {
"(TODO)" = {
decorations = [{
color = palette.red;
fontStyle = "italic";
fontWeight = "bold";
overviewRulerColor = palette.red;
}];
};
"(\\t)" = {
decorations = [{
after = {
contentText = "";
backgroundColor = "${palette.white}22";
margin = "0 1px 0 -3px";
width = "2px";
};
}];
};
"([\\u00a0\\u00ad\\u115f\\u2000-\\u200e\\u202f\\u205f\\u2060-\\u2061\\u2800\\u3000\\u3164\\ufeff\\uffa0])" = {
decorations = [{
backgroundColor = "${palette.purple}66";
border = "1px solid ${palette.purple}";
}];
};
"([^\\s|#/]|[^/]/)( {2,})([^\\s|])" = {
decorations = [{ }
{
backgroundColor = "${palette.black}88";
overviewRulerColor = "${palette.black}88";
}
{ }];
};
};
# Environment
"files.exclude" = {
"**/.bundle" = true;
"**/.cache" = true;
"**/.direnv" = true;
"**/.parcel-cache" = true;
"**/.ruff_cache" = true;
"**/.Trash-*" = true;
"**/.vagrant" = true;
"**/.vscode" = true;
"**/__pycache__" = true;
"**/node_modules" = true;
};
"rust-client.disableRustup" = true;
"shellcheck.disableVersionCheck" = true;
# Icons
"material-icon-theme.files.associations" = {
"*.🡕" = "Http";
".envrc" = "Tune";
};
"material-icon-theme.folders.associations" = {
"[post]" = "Docs";
"benches" = "Benchmark";
"browser-extension" = "Plugin";
"endpoints" = "Routes";
"entrypoints" = "Routes";
"hosts" = "Server";
"local" = "Environment";
"migration" = "Database";
"site" = "Public";
};
};
};
home.sessionVariables = rec {
EDITOR = "${pkgs.vscodium}/bin/codium --wait";
VISUAL = EDITOR;
};
programs.zsh.shellAliases.code = "codium";
programs.git.extraConfig."mergetool \"code\"".cmd = "${pkgs.vscodium}/bin/codium --wait --merge $REMOTE $LOCAL $BASE $MERGED";
}