From 1b27caf3ba0f2ef4e5351684b121c11410cbb7aa Mon Sep 17 00:00:00 2001 From: Rutherther Date: Fri, 22 Sep 2023 21:38:56 +0200 Subject: [PATCH] feat: add vscodium with extensions --- flake.lock | 86 ++++++++- flake.nix | 5 + hosts/default.nix | 6 +- modules/editors/home.nix | 1 + modules/editors/vscode/home.nix | 315 ++++++++++++++++++++++++++++++++ 5 files changed, 403 insertions(+), 10 deletions(-) create mode 100644 modules/editors/vscode/home.nix diff --git a/flake.lock b/flake.lock index c74855c..44bcaba 100644 --- a/flake.lock +++ b/flake.lock @@ -1,6 +1,40 @@ { "nodes": { + "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1673956053, + "narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1681202837, + "narHash": "sha256-H+Rh19JDwRtpVPAWp64F+rlEtxUWBAQW28eAi3SRSzg=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "cfacdce06f30d2b68473a46042957675eebb3401", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_2": { "locked": { "lastModified": 1659877975, "narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=", @@ -36,13 +70,35 @@ "type": "github" } }, - "nixgl": { + "nix-vscode-extensions": { "inputs": { + "flake-compat": "flake-compat", "flake-utils": "flake-utils", "nixpkgs": [ "nixpkgs" ] }, + "locked": { + "lastModified": 1695345913, + "narHash": "sha256-TkCmI8cLQ02HW9jW2HEquQZ1u1ljeOlEFMU+9PS2tLg=", + "owner": "nix-community", + "repo": "nix-vscode-extensions", + "rev": "8f30a4bcd475bff9f23097e4450754ec068523b2", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nix-vscode-extensions", + "type": "github" + } + }, + "nixgl": { + "inputs": { + "flake-utils": "flake-utils_2", + "nixpkgs": [ + "nixpkgs" + ] + }, "locked": { "lastModified": 1685908677, "narHash": "sha256-E4zUPEUFyVWjVm45zICaHRpfGepfkE9Z2OECV9HXfA4=", @@ -59,11 +115,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1694937365, - "narHash": "sha256-iHZSGrb9gVpZRR4B2ishUN/1LRKWtSHZNO37C8z1SmA=", + "lastModified": 1695272228, + "narHash": "sha256-4uw2OdJPVyjdB+xcDst9SecrNIpxKXJ2usN3M5HVa7o=", "owner": "nixos", "repo": "nixpkgs", - "rev": "5d017a8822e0907fb96f7700a319f9fe2434de02", + "rev": "55ac2a9d2024f15c56adf20da505b29659911da8", "type": "github" }, "original": { @@ -91,11 +147,11 @@ }, "nur": { "locked": { - "lastModified": 1695379524, - "narHash": "sha256-lXG7i/7BHa3hLBHV+KsXGrOEna+zYBJ09wnGa7SlRG8=", + "lastModified": 1695404986, + "narHash": "sha256-ivcXoAQNdEd7L5LpemOLt9n+Xs1PIGCbVxctYeaeN6c=", "owner": "nix-community", "repo": "NUR", - "rev": "580b8e4860d3ef435f7f2c0d25cbbafdb8a831cb", + "rev": "1415b45ba5cbe4367b733743f41afc81e08f0aa7", "type": "github" }, "original": { @@ -107,11 +163,27 @@ "root": { "inputs": { "home-manager": "home-manager", + "nix-vscode-extensions": "nix-vscode-extensions", "nixgl": "nixgl", "nixpkgs": "nixpkgs", "nixpkgs-unstable": "nixpkgs-unstable", "nur": "nur" } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } } }, "root": "root", diff --git a/flake.nix b/flake.nix index 500f641..7e1091b 100644 --- a/flake.nix +++ b/flake.nix @@ -27,6 +27,11 @@ url = "github:guibou/nixGL"; inputs.nixpkgs.follows = "nixpkgs"; }; + + nix-vscode-extensions = { + url = "github:nix-community/nix-vscode-extensions"; + inputs.nixpkgs.follows = "nixpkgs"; + }; }; outputs = inputs @ { self, nixpkgs, nixpkgs-unstable, home-manager, nur, nixgl, ... }: # Function that tells my flake which to use and what do what to do with the dependencies. diff --git a/hosts/default.nix b/hosts/default.nix index 52f6423..5ed6d53 100644 --- a/hosts/default.nix +++ b/hosts/default.nix @@ -46,7 +46,7 @@ in home-manager.useGlobalPkgs = true; home-manager.useUserPackages = true; home-manager.extraSpecialArgs = { - inherit unstable user location; + inherit inputs unstable user location; host = { hostName = "laptop"; mainMonitor = "eDP-1"; @@ -77,7 +77,7 @@ in home-manager.useGlobalPkgs = true; home-manager.useUserPackages = true; home-manager.extraSpecialArgs = { - inherit unstable user location; + inherit inputs unstable user location; host = { hostName = "vm"; mainMonitor = "Virtual-1"; @@ -110,7 +110,7 @@ in home-manager.useGlobalPkgs = true; home-manager.useUserPackages = true; home-manager.extraSpecialArgs = { - inherit unstable user location; + inherit inputs unstable user location; host = { hostName = "desktop"; #For Xorg iGPU | Hyprland iGPU mainMonitor = "HDMI-A-1"; #HDMIA3 | HDMI-A-3 diff --git a/modules/editors/home.nix b/modules/editors/home.nix index 2d2eb5c..ba26b7a 100644 --- a/modules/editors/home.nix +++ b/modules/editors/home.nix @@ -13,6 +13,7 @@ [ ./emacs/home.nix ./nvim/home.nix + ./vscode/home.nix ] # Comment out emacs if you are not using native doom emacs. (import from host configuration.nix) diff --git a/modules/editors/vscode/home.nix b/modules/editors/vscode/home.nix new file mode 100644 index 0000000..94e9dba --- /dev/null +++ b/modules/editors/vscode/home.nix @@ -0,0 +1,315 @@ +{ inputs, config, lib, pkgs, system, ... }: + +let + extensions = inputs.nix-vscode-extensions.extensions.x86_64-linux; +in { + programs.vscode = { + enable = true; + enableExtensionUpdateCheck = true; + enableUpdateCheck = true; + package = pkgs.vscodium.fhsWithPackages (ps: with ps; [ git ]); + + extensions = (with extensions.open-vsx; [ + vspacecode.vspacecode # Spacemacs like menu on space + vspacecode.whichkey # dependency of vspacecode + vscodevim.vim # vim keybindings + kahole.magit # emacs magit-mode like git client + jacobdufault.fuzzy-search # Fuzzy search + bodil.file-browser # File browser + + usernamehw.errorlens # See error better + nonspicyburrito.hoverlens # See hover better + + yzhang.markdown-all-in-one # Write markdown + + ]) ++ (with extensions.vscode-marketplace; [ + arrterian.nix-env-selector # Nix environment + ]); + + keybindings = [ + # VSpaceCode + { + key = "space"; + command = "vspacecode.space"; + when = + "activeEditorGroupEmpty && focusedView == '' && !whichkeyActive && !inputFocus"; + } + { + key = "space"; + command = "vspacecode.space"; + when = "sideBarFocus && !inputFocus && !whichkeyActive"; + } + { + key = "ctrl+space"; + command = "vspacecode.space"; + when = "!whichkeyActive"; + } + # Vim + { + key = "tab"; + command = "extension.vim_tab"; + when = + "editorTextFocus && vim.active && !inDebugRepl && vim.mode != 'Insert' && editorLangId != 'magit'"; + } + { + key = "tab"; + command = "-extension.vim_tab"; + when = + "editorTextFocus && vim.active && !inDebugRepl && vim.mode != 'Insert'"; + } + # Magit + { + key = "p"; + command = "magit.pushing"; + when = "editorTextFocus && editorLangId == 'magit'"; + } + { + key = "x"; + command = "magit.discard-at-point"; + when = + "editorTextFocus && editorLangId == 'magit' && vim.mode =~ /^(?!SearchInProgressMode|CommandlineInProgress).*$/"; + } + { + key = "k"; + command = "-magit.discard-at-point"; + } + { + key = "-"; + command = "magit.reverse-at-point"; + when = + "editorTextFocus && editorLangId == 'magit' && vim.mode =~ /^(?!SearchInProgressMode|CommandlineInProgress).*$/"; + } + { + key = "v"; + command = "-magit.reverse-at-point"; + } + { + key = "shift+-"; + command = "magit.reverting"; + when = + "editorTextFocus && editorLangId == 'magit' && vim.mode =~ /^(?!SearchInProgressMode|CommandlineInProgress).*$/"; + } + { + key = "shift+v"; + command = "-magit.reverting"; + } + { + key = "shift+o"; + command = "magit.resetting"; + when = + "editorTextFocus && editorLangId == 'magit' && vim.mode =~ /^(?!SearchInProgressMode|CommandlineInProgress).*$/"; + } + { + key = "shift+x"; + command = "-magit.resetting"; + } + { + key = "x"; + command = "-magit.reset-mixed"; + } + { + key = "ctrl+u x"; + command = "-magit.reset-hard"; + } + { + key = "y"; + command = "-magit.show-refs"; + } + { + key = "y"; + command = "vspacecode.showMagitRefMenu"; + when = + "editorTextFocus && editorLangId == 'magit' && vim.mode == 'Normal'"; + } + + # Support vim-like keybindings in lists, quick view etc. + { + key = "ctrl+j"; + command = "workbench.action.quickOpenSelectNext"; + when = "inQuickOpen"; + } + { + key = "ctrl+k"; + command = "workbench.action.quickOpenSelectPrevious"; + when = "inQuickOpen"; + } + { + key = "ctrl+j"; + command = "selectNextSuggestion"; + when = + "suggestWidgetMultipleSuggestions && suggestWidgetVisible && textInputFocus"; + } + { + key = "ctrl+k"; + command = "selectPrevSuggestion"; + when = + "suggestWidgetMultipleSuggestions && suggestWidgetVisible && textInputFocus"; + } + { + key = "ctrl+l"; + command = "acceptSelectedSuggestion"; + when = + "suggestWidgetMultipleSuggestions && suggestWidgetVisible && textInputFocus"; + } + { + key = "ctrl+j"; + command = "showNextParameterHint"; + when = + "editorFocus && parameterHintsMultipleSignatures && parameterHintsVisible"; + } + { + key = "ctrl+k"; + command = "showPrevParameterHint"; + when = + "editorFocus && parameterHintsMultipleSignatures && parameterHintsVisible"; + } + { + key = "ctrl+j"; + command = "selectNextCodeAction"; + when = "codeActionMenuVisible"; + } + { + key = "ctrl+k"; + command = "selectPrevCodeAction"; + when = "codeActionMenuVisible"; + } + { + key = "ctrl+l"; + command = "acceptSelectedCodeAction"; + when = "codeActionMenuVisible"; + } + { + key = "ctrl+h"; + command = "file-browser.stepOut"; + when = "inFileBrowser"; + } + { + key = "ctrl+l"; + command = "file-browser.stepIn"; + when = "inFileBrowser"; + } + { + key = "ctrl+h"; + command = "workbench.action.navigateLeft"; + when = + "!inQuickOpen && !suggestWidgetVisible && !parameterHintsVisible && !isInDiffEditor"; + } + { + key = "ctrl+j"; + command = "workbench.action.navigateDown"; + when = + "!codeActionMenuVisible && !inQuickOpen && !suggestWidgetVisible && !parameterHintsVisible"; + } + { + key = "ctrl+k"; + command = "workbench.action.navigateUp"; + when = + "!codeActionMenuVisible && !inQuickOpen && !suggestWidgetVisible && !parameterHintsVisible"; + } + { + key = "ctrl+l"; + command = "workbench.action.navigateRight"; + when = + "!codeActionMenuVisible && !inQuickOpen && !suggestWidgetVisible && !parameterHintsVisible && !isInDiffEditor"; + } + { + key = "ctrl+h"; + command = "workbench.action.compareEditor.focusSecondarySide"; + when = "isInDiffEditor && !isInDiffLeftEditor"; + } + { + key = "ctrl+h"; + command = "workbench.action.navigateLeft"; + when = "isInDiffEditor && isInDiffLeftEditor"; + } + { + key = "ctrl+l"; + command = "workbench.action.compareEditor.focusPrimarySide"; + when = "isInDiffEditor && isInDiffLeftEditor"; + } + { + key = "ctrl+l"; + command = "workbench.action.navigateRight"; + when = "isInDiffEditor && !isInDiffLeftEditor"; + } + { + key = "ctrl+h"; + command = "list.collapse"; + when = "listFocus && !inputFocus"; + } + { + key = "ctrl+l"; + command = "list.expand"; + when = "listFocus && !inputFocus"; + } + { + key = "ctrl+j"; + command = "list.focusDown"; + when = "listFocus && !inputFocus"; + } + { + key = "ctrl+k"; + command = "list.focusUp"; + when = "listFocus && !inputFocus"; + } + ]; + + userSettings = { + "workbench.colorTheme" = "Default Dark Modern"; + # Editor + "editor.lineNumbers" = "relative"; + "search.mode" = "newEditor"; + "editor.wordSeparators" = ''`~!@#$%^&*()-=+[{]}\|; ='",.<>/?_''; + "workbench.activityBar.visible" = false; + "workbench.editor.showTabs" = false; + "terminal.integrated.commandsToSkipShell" = + [ "language-julia.interrupt" "vspacecode.space" ]; + + # Magit + "magit.display-buffer-function" = "same-column"; + "magit.quick-switch-enabled" = true; + + # Vim + "vim.easymotion" = "true"; + "vim.sneak" = true; + "vim.smartRelativeLine" = true; + "vim.sneakReplacesF" = true; + "vim.targets.enable" = true; + "vim.useSystemClipboard" = true; + + # VSpaceCode + "vim.normalModeKeyBindingsNonRecursive" = [ + { + "before" = [ "" ]; + "commands" = [ "vspacecode.space" ]; + } + { + "before" = [ "," ]; + "commands" = [ + "vspacecode.space" + { + "command" = "whichkey.triggerKey"; + "args" = "m"; + } + ]; + } + ]; + "vim.visualModeKeyBindingsNonRecursive" = [ + { + "before" = [ "" ]; + "commands" = [ "vspacecode.space" ]; + } + { + "before" = [ "," ]; + "commands" = [ + "vspacecode.space" + { + "command" = "whichkey.triggerKey"; + "args" = "m"; + } + ]; + } + ]; + }; + }; +} -- 2.48.1