mirror of
https://github.com/ryanccn/flake.git
synced 2025-12-06 08:10:43 +01:00
refactor: flake-parts
This commit is contained in:
parent
872c6be493
commit
42a1293f6d
63 changed files with 1118 additions and 875 deletions
232
users/ryan/apps/vscode.nix
Normal file
232
users/ryan/apps/vscode.nix
Normal file
|
|
@ -0,0 +1,232 @@
|
|||
# SPDX-FileCopyrightText: 2025 Ryan Cao <hello@ryanccn.dev>
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
{
|
||||
pkgs,
|
||||
lib,
|
||||
config,
|
||||
# self,
|
||||
...
|
||||
}:
|
||||
let
|
||||
extensions = [
|
||||
"astro-build.astro-vscode"
|
||||
"bierner.lit-html"
|
||||
"bmalehorn.vscode-fish"
|
||||
"bradlc.vscode-tailwindcss"
|
||||
"catppuccin.catppuccin-vsc"
|
||||
"catppuccin.catppuccin-vsc-icons"
|
||||
"charliermarsh.ruff"
|
||||
"dbaeumer.vscode-eslint"
|
||||
"denoland.vscode-deno"
|
||||
"dotjoshjohnson.xml"
|
||||
"dprint.dprint"
|
||||
"editorconfig.editorconfig"
|
||||
"esbenp.prettier-vscode"
|
||||
"github.vscode-github-actions"
|
||||
"graphql.vscode-graphql"
|
||||
"graphql.vscode-graphql-syntax"
|
||||
"golang.go"
|
||||
"griimick.vhs"
|
||||
"jnoortheen.nix-ide"
|
||||
"ms-python.isort"
|
||||
"ms-python.vscode-pylance"
|
||||
"ms-python.python"
|
||||
"myriad-dreamin.tinymist"
|
||||
"naumovs.color-highlight"
|
||||
"prisma.prisma"
|
||||
"ronnidc.nunjucks"
|
||||
"rust-lang.rust-analyzer"
|
||||
"skellock.just"
|
||||
"svelte.svelte-vscode"
|
||||
"tamasfe.even-better-toml"
|
||||
"timonwong.shellcheck"
|
||||
"unifiedjs.vscode-mdx"
|
||||
"usernamehw.errorlens"
|
||||
"vue.volar"
|
||||
"yoavbls.pretty-ts-errors"
|
||||
];
|
||||
|
||||
defaultFormatters = {
|
||||
"[python]" = "charliermarsh.ruff";
|
||||
"[cpp]" = "xaver.clang-format";
|
||||
"[toml]" = "tamasfe.even-better-toml";
|
||||
"[svelte]" = "svelte.svelte-vscode";
|
||||
"[go][go.mod][go.sum]" = "golang.go";
|
||||
"[xml]" = "DotJoshJohnson.xml";
|
||||
"[fish]" = "bmalehorn.vscode-fish";
|
||||
"[just]" = "skellock.just";
|
||||
"[astro]" = "astro-build.astro-vscode";
|
||||
"[rust]" = "rust-lang.rust-analyzer";
|
||||
"[nix]" = "jnoortheen.nix-ide";
|
||||
"[typst]" = "myriad-dreamin.tinymist";
|
||||
};
|
||||
in
|
||||
{
|
||||
programs.vscode = {
|
||||
enable = true;
|
||||
package = pkgs.writeShellApplication {
|
||||
name = "vscode-1.98.2";
|
||||
text = "";
|
||||
derivationArgs = {
|
||||
pname = "vscode";
|
||||
version = "1.98.2";
|
||||
};
|
||||
};
|
||||
|
||||
profiles.default.extensions = [ ];
|
||||
mutableExtensionsDir = true;
|
||||
|
||||
profiles.default.userSettings = builtins.foldl' lib.recursiveUpdate { } [
|
||||
{
|
||||
"workbench.colorTheme" = "Catppuccin Frappé";
|
||||
"workbench.iconTheme" = "catppuccin-frappe";
|
||||
"workbench.sideBar.location" = "left";
|
||||
"workbench.activityBar.location" = "top";
|
||||
|
||||
"editor.semanticHighlighting.enabled" = true;
|
||||
"terminal.integrated.minimumContrastRatio" = 1;
|
||||
"terminal.integrated.drawBoldTextInBrightColors" = false;
|
||||
"window.titleBarStyle" = "custom";
|
||||
|
||||
"catppuccin.accentColor" = config.catppuccin.accent;
|
||||
"catppuccin.workbenchMode" = "flat";
|
||||
"catppuccin.customUIColors" = {
|
||||
"all" = {
|
||||
"statusBarItem.remoteBackground" = "accent";
|
||||
"activityBar.activeBorder" = "accent";
|
||||
"activityBarTop.activeBorder" = "accent";
|
||||
};
|
||||
};
|
||||
|
||||
"git.autofetch" = true;
|
||||
"git.confirmSync" = false;
|
||||
"git.inputValidation" = false;
|
||||
"git.suggestSmartCommit" = false;
|
||||
"git.blame.editorDecoration.enabled" = true;
|
||||
|
||||
"diffEditor.renderSideBySide" = false;
|
||||
"diffEditor.ignoreTrimWhitespace" = false;
|
||||
|
||||
"editor.fontFamily" = ''"IBM Plex Mono", "Symbols Nerd Font", monospace'';
|
||||
"editor.fontLigatures" = true;
|
||||
"editor.fontSize" = 16;
|
||||
"editor.lineHeight" = 1.5;
|
||||
# "editor.cursorBlinking" = "phase";
|
||||
# "editor.cursorSmoothCaretAnimation" = "on";
|
||||
# "editor.minimap.renderCharacters" = false;
|
||||
"workbench.editor.highlightModifiedTabs" = true;
|
||||
"workbench.editor.empty.hint" = "hidden";
|
||||
"chat.commandCenter.enabled" = false;
|
||||
|
||||
"editor.inlineSuggest.enabled" = true;
|
||||
"editor.tabSize" = 2;
|
||||
"editor.insertSpaces" = true;
|
||||
"editor.formatOnSave" = true;
|
||||
|
||||
"terminal.integrated.fontFamily" = ''"IBM Plex Mono", "Symbols Nerd Font Mono", monospace'';
|
||||
"terminal.integrated.fontSize" = 14;
|
||||
"terminal.integrated.lineHeight" = 1.5;
|
||||
"terminal.integrated.cursorBlinking" = true;
|
||||
"terminal.integrated.defaultProfile.osx" = "fish";
|
||||
"terminal.integrated.inheritEnv" = false;
|
||||
"terminal.integrated.enablePersistentSessions" = false;
|
||||
"terminal.integrated.shellIntegration.enabled" = false;
|
||||
|
||||
"editor.defaultFormatter" = "esbenp.prettier-vscode";
|
||||
|
||||
"javascript.preferGoToSourceDefinition" = true;
|
||||
"typescript.preferGoToSourceDefinition" = true;
|
||||
"typescript.enablePromptUseWorkspaceTsdk" = true;
|
||||
|
||||
"eslint.useFlatConfig" = true;
|
||||
|
||||
"shellcheck.ignorePatterns".".envrc" = true;
|
||||
"tailwindCSS.includeLanguages" = {
|
||||
"typescript" = "javascript";
|
||||
"typescriptreact" = "javascript";
|
||||
"vue-html" = "html";
|
||||
};
|
||||
|
||||
"telemetry.telemetryLevel" = "off";
|
||||
"workbench.enableExperiments" = false;
|
||||
"workbench.settings.enableNaturalLanguageSearch" = false;
|
||||
"extensions.ignoreRecommendations" = true;
|
||||
"editor.accessibilitySupport" = "off";
|
||||
|
||||
"[python]"."editor.tabSize" = 4;
|
||||
"[rust]"."editor.tabSize" = 4;
|
||||
|
||||
"[mdx]"."editor.wordWrap" = "on";
|
||||
|
||||
"rust-analyzer.server.path" = "rust-analyzer";
|
||||
"rust-analyzer.check.command" = "clippy";
|
||||
"rust-analyzer.showUnlinkedFileNotification" = false;
|
||||
|
||||
"files.associations" = {
|
||||
"*.mcmeta" = "json";
|
||||
"*.plist" = "xml";
|
||||
".dockerignore" = "ignore";
|
||||
".dev.vars" = "properties";
|
||||
".env.example" = "properties";
|
||||
"*.sarif" = "json";
|
||||
".tokeignore" = "ignore";
|
||||
"flake.lock" = "json";
|
||||
};
|
||||
|
||||
"svelte.enable-ts-plugin" = true;
|
||||
|
||||
"color-highlight.matchRgbWithNoFunction" = true;
|
||||
"color-highlight.matchHslWithNoFunction" = true;
|
||||
"color-highlight.markRuler" = false;
|
||||
"color-highlight.markerType" = "underline";
|
||||
|
||||
"nix.enableLanguageServer" = true;
|
||||
"nix.serverPath" = lib.getExe pkgs.nil;
|
||||
"nix.serverSettings" = {
|
||||
"nil" = {
|
||||
formatting.command = [ (lib.getExe pkgs.nixfmt-rfc-style) ];
|
||||
# nixpkgs.expr = "import (builtins.getFlake \"${self}\").inputs.nixpkgs { }";
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
(lib.concatMapAttrs (lang: formatter: {
|
||||
${lang}."editor.defaultFormatter" = formatter;
|
||||
}) defaultFormatters)
|
||||
];
|
||||
};
|
||||
|
||||
home.activation = {
|
||||
vscodeExtensions = lib.hm.dag.entryAfter [ "writeBoundary" ] ''
|
||||
code_bin="/usr/local/bin/code"
|
||||
|
||||
if ! command -v "$code_bin" &> /dev/null; then
|
||||
echo "code CLI is not available"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
declare -A currentExtensions
|
||||
for extension in $("$code_bin" --list-extensions); do
|
||||
currentExtensions["$extension"]=1;
|
||||
done
|
||||
|
||||
${builtins.concatStringsSep "\n" (
|
||||
builtins.map (ext: ''
|
||||
if [[ -z "''${currentExtensions[${ext}]+unset}" ]]; then
|
||||
echo "installing ${ext}"
|
||||
$DRY_RUN_CMD "$code_bin" --install-extension ${ext} &> /dev/null
|
||||
fi
|
||||
unset 'currentExtensions[${ext}]'
|
||||
'') extensions
|
||||
)}
|
||||
|
||||
for ext in "''${!currentExtensions[@]}"; do
|
||||
echo "uninstalling $ext"
|
||||
$DRY_RUN_CMD "$code_bin" --uninstall-extension $ext &> /dev/null
|
||||
unset 'currentExtensions[$ext]'
|
||||
done
|
||||
'';
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue