From 107242b385556437b43106cca3a582f671c67ec3 Mon Sep 17 00:00:00 2001 From: winston Date: Tue, 19 Dec 2023 17:55:23 +0100 Subject: [PATCH] feat: vscode extension fixes & patching --- home/apps/git.nix | 1 + home/apps/vscode.nix | 138 ++++++++++++++++++++--------- home/apps/vscode/settings.json | 10 ++- home/apps/vscode/snippets/nix.json | 14 +++ 4 files changed, 118 insertions(+), 45 deletions(-) create mode 100644 home/apps/vscode/snippets/nix.json diff --git a/home/apps/git.nix b/home/apps/git.nix index 9fa3455..e77b1fd 100644 --- a/home/apps/git.nix +++ b/home/apps/git.nix @@ -43,6 +43,7 @@ ".gonvim/" ".idea/" "ltex.dictionary*.txt" + "ltex.disabledRules.*.txt" # nix-specific ".direnv/" ".envrc" diff --git a/home/apps/vscode.nix b/home/apps/vscode.nix index e6a010f..2140744 100644 --- a/home/apps/vscode.nix +++ b/home/apps/vscode.nix @@ -9,60 +9,116 @@ settingsJSON = config.lib.file.mkOutOfStoreSymlink "${flakePath}/home/apps/vscode/settings.json"; keybindingsJSON = config.lib.file.mkOutOfStoreSymlink "${flakePath}/home/apps/vscode/keybindings.json"; + snippetsDir = config.lib.file.mkOutOfStoreSymlink "${flakePath}/home/apps/vscode/snippets"; in { programs.vscode = { enable = config.isGraphical; - extensions = with pkgs.vscode-marketplace; [ - pkgs.vscode-extensions.valentjn.vscode-ltex - adrianwilczynski.alpine-js-intellisense - antfu.icons-carbon - astro-build.astro-vscode - bradlc.vscode-tailwindcss - catppuccin.catppuccin-vsc-icons - charliermarsh.ruff - dbaeumer.vscode-eslint - denoland.vscode-deno - dhall.dhall-lang - dhall.vscode-dhall-lsp-server - eamodio.gitlens - editorconfig.editorconfig - esbenp.prettier-vscode - github.copilot - github.vscode-pull-request-github - gitlab.gitlab-workflow - golang.go - graphql.vscode-graphql-syntax - jnoortheen.nix-ide - kamadorueda.alejandra - leonardssh.vscord - lunuan.kubernetes-templates - mads-hartmann.bash-ide-vscode - mikestead.dotenv - mkhl.direnv - mkhl.shfmt - ms-kubernetes-tools.vscode-kubernetes-tools - pkief.material-icon-theme - redhat.vscode-yaml - rust-lang.rust-analyzer - serayuzgur.crates - sumneko.lua - tamasfe.even-better-toml - tomoki1207.pdf - unifiedjs.vscode-mdx - usernamehw.errorlens - vscodevim.vim - webfreak.code-d - ]; + extensions = + (with pkgs.vscode-extensions; [ + # patches + ms-vscode-remote.remote-ssh + sumneko.lua + # needs a pinned release + github.vscode-pull-request-github + # pulling in extra binaries, patched for nix + valentjn.vscode-ltex + ]) + # pinned releases; these install the latest rather than the nightly version + ++ (with pkgs.vscode-marketplace-release; [ + eamodio.gitlens + rust-lang.rust-analyzer + vadimcn.vscode-lldb + ]) + ++ (with pkgs.vscode-marketplace; [ + # some default config patching to make these work without needing devShells all the time. + # other extensions like Go/Rust are only really used with devShells, + # nix & shell are universal enough for me to want them everywhere. + (jnoortheen.nix-ide.overrideAttrs (prev: { + nativeBuildInputs = prev.nativeBuildInputs ++ [pkgs.jq pkgs.moreutils]; + postInstall = '' + cd "$out/$installPrefix" + jq -e ' + .contributes.configuration.properties."nix.formatterPath".default = + "${pkgs.alejandra}/bin/alejandra" | + .contributes.configuration.properties."nix.enableLanguageServer".default = + "true" | + .contributes.configuration.properties."nix.serverPath".default = + "${pkgs.nil}/bin/nil" | + .contributes.configuration.properties."nix.serverSettings".default.nil.formatting.command[0] = + "${pkgs.alejandra}/bin/alejandra" + ' < package.json | sponge package.json + ''; + })) + (mads-hartmann.bash-ide-vscode.overrideAttrs (prev: { + nativeBuildInputs = prev.nativeBuildInputs ++ [pkgs.jq pkgs.moreutils]; + postInstall = '' + cd "$out/$installPrefix" + jq -e ' + .contributes.configuration.properties."bashIde.shellcheckPath".default = + "${pkgs.shellcheck}/bin/shellcheck" + ' < package.json | sponge package.json + ''; + })) + (mkhl.shfmt.overrideAttrs (prev: { + nativeBuildInputs = prev.nativeBuildInputs ++ [pkgs.jq pkgs.moreutils]; + postInstall = '' + cd "$out/$installPrefix" + jq -e ' + .contributes.configuration.properties."shfmt.executablePath".default = + "${pkgs.shfmt}/bin/shfmt" + ' < package.json | sponge package.json + ''; + })) + adrianwilczynski.alpine-js-intellisense + antfu.icons-carbon + arcanis.vscode-zipfs + astro-build.astro-vscode + bradlc.vscode-tailwindcss + catppuccin.catppuccin-vsc-icons + charliermarsh.ruff + dbaeumer.vscode-eslint + denoland.vscode-deno + dhall.dhall-lang + dhall.vscode-dhall-lsp-server + editorconfig.editorconfig + esbenp.prettier-vscode + github.copilot + gitlab.gitlab-workflow + golang.go + graphql.vscode-graphql-syntax + jock.svg + lunuan.kubernetes-templates + mikestead.dotenv + mkhl.direnv + ms-kubernetes-tools.vscode-kubernetes-tools + oscarotero.vento-syntax + pkief.material-icon-theme + redhat.vscode-yaml + serayuzgur.crates + tamasfe.even-better-toml + tomoki1207.pdf + unifiedjs.vscode-mdx + usernamehw.errorlens + vscodevim.vim + ]); mutableExtensionsDir = true; }; home.file = lib.mkIf isDarwin { "Library/Application Support/Code/User/keybindings.json".source = keybindingsJSON; "Library/Application Support/Code/User/settings.json".source = settingsJSON; + "Library/Application Support/Code/User/snippets" = { + source = snippetsDir; + recursive = true; + }; }; xdg.configFile = lib.mkIf isLinux { "Code/User/keybindings.json".source = keybindingsJSON; "Code/User/settings.json".source = settingsJSON; + "Code/User/snippets" = { + source = snippetsDir; + recursive = true; + }; }; xdg.mimeApps.defaultApplications."text/plain" = "code.desktop"; } diff --git a/home/apps/vscode/settings.json b/home/apps/vscode/settings.json index 0a35124..3ecaa64 100644 --- a/home/apps/vscode/settings.json +++ b/home/apps/vscode/settings.json @@ -31,6 +31,7 @@ "extensions.ignoreRecommendations": true, "git.autofetch": true, "git.openRepositoryInParentFolders": "never", + "githubPullRequests.pullBranch": "always", "ltex.additionalRules.enablePickyRules": true, "ltex.additionalRules.motherTongue": "de-AT", "markdown.preview.fontFamily": "IBM Plex Sans, sans-serif", @@ -39,7 +40,8 @@ "typescript.inlayHints.parameterNames.enabled": "all", "update.mode": "none", "vs-kubernetes": { - "vs-kubernetes.crd-code-completion": "enabled" + "vs-kubernetes.crd-code-completion": "enabled", + "vs-kubernetes.minikube-show-information-expiration": "2024-06-09T06:56:22.175Z" }, "window.autoDetectColorScheme": true, "window.commandCenter": false, @@ -79,9 +81,9 @@ "[less]": { "editor.defaultFormatter": "esbenp.prettier-vscode" }, - "nix.enableLanguageServer": true, - "nix.formatterPath": "alejandra", - "nix.serverPath": "nil", + "[nix]": { + "editor.defaultFormatter": "jnoortheen.nix-ide" + }, "[python]": { "editor.defaultFormatter": "charliermarsh.ruff" }, diff --git a/home/apps/vscode/snippets/nix.json b/home/apps/vscode/snippets/nix.json new file mode 100644 index 0000000..b774760 --- /dev/null +++ b/home/apps/vscode/snippets/nix.json @@ -0,0 +1,14 @@ +{ + "mkShell": { + "prefix": "mkshell", + "body": [ + "{pkgs ? import {}}:", + "pkgs.mkShell {", + " buildInputs = with pkgs; [", + " $1", + " ];", + "}" + ], + "description": "Nix development shell" + } +}