From e703f3a7ffee32fc2c7bd7cf1129846d3411fe56 Mon Sep 17 00:00:00 2001 From: Mel Date: Tue, 14 Jan 2025 22:13:14 +0100 Subject: Fully configure VSCode Signed-off-by: Mel --- configs/vscode/keybindings.nix | 42 ++++++++++++++++ configs/vscode/settings.nix | 109 +++++++++++++++++++++++++++++++++++++++++ modules/code.nix | 61 ----------------------- modules/common.nix | 1 - modules/home/code.nix | 72 +++++++++++++++++++++++++++ modules/home/common.nix | 4 ++ 6 files changed, 227 insertions(+), 62 deletions(-) create mode 100644 configs/vscode/keybindings.nix create mode 100644 configs/vscode/settings.nix delete mode 100644 modules/code.nix create mode 100644 modules/home/code.nix diff --git a/configs/vscode/keybindings.nix b/configs/vscode/keybindings.nix new file mode 100644 index 0000000..fcb6e4d --- /dev/null +++ b/configs/vscode/keybindings.nix @@ -0,0 +1,42 @@ +{ ... }: + +[ + # toggle the left panels nicely. + { + key = "ctrl+b"; + command = "workbench.action.toggleSidebarVisibility"; + } + { + key = "alt+b"; + command = "workbench.action.toggleActivityBarVisibility"; + } + # quickly switch left panel view by order. + { + key = "ctrl+alt+1"; + command = "workbench.view.explorer"; + } + { + key = "ctrl+alt+2"; + command = "workbench.view.search"; + } + { + key = "ctrl+alt+3"; + command = "workbench.view.scm"; + } + { + key = "ctrl+alt+4"; + command = "workbench.view.debug"; + } + { + key = "ctrl+alt+5"; + command = "workbench.view.extension.test"; + } + { + key = "ctrl+alt+6"; + command = "workbench.view.extensions"; + } + { + key = "ctrl+alt+7"; + command = "workbench.view.extension.bookmarks"; + } +] diff --git a/configs/vscode/settings.nix b/configs/vscode/settings.nix new file mode 100644 index 0000000..4e2fba1 --- /dev/null +++ b/configs/vscode/settings.nix @@ -0,0 +1,109 @@ +{ pkgs, lib, ... }: + +let + inherit (lib) getExe; + + # https://github.com/Sertion/vscode-gitblame?tab=readme-ov-file#message-tokens + blameMessageFormat = "\${author.name}; \${time.ago} * \${commit.summary}"; +in +{ + # appearance + "workbench.iconTheme" = "catppuccin-mocha"; + "workbench.colorTheme" = "Catppuccin Mocha"; + "workbench.productIconTheme" = "fluent-icons"; + "workbench.layoutControl.enabled" = false; + "workbench.activityBar.location" = "hidden"; + "window.menuBarVisibility" = "toggle"; + "window.commandCenter" = false; + "window.dialogStyle" = "custom"; + "window.titleBarStyle" = "custom"; + "window.title" = " "; + "vscode-pets.position" = "explorer"; + "vscode-pets.petSize" = "medium"; + + # editor appearance and behavior + "editor.fontSize" = 16; + "editor.fontFamily" = "Berkeley Mono"; + "editor.cursorStyle" = "block"; + "editor.formatOnSave" = true; + "editor.formatOnSaveMode" = "modificationsIfAvailable"; + "editor.cursorBlinking" = "smooth"; + "editor.cursorSmoothCaretAnimation" = "on"; + "editor.minimap.autohide" = true; + "files.autoSave" = "afterDelay"; + + # git configuration + "git.autofetch" = "all"; + "git.enableCommitSigning" = true; + "github.gitProtocol" = "ssh"; + + "gitblame.inlineMessageEnabled" = true; + "gitblame.ignoreWhitespace" = true; + "gitblame.inlineMessageNoCommit" = ""; + "gitblame.inlineMessageFormat" = blameMessageFormat; + "gitblame.statusBarMessageFormat" = blameMessageFormat; + "gitblame.delayBlame" = 1000; + + # language configuration + "nix.enableLanguageServer" = true; + "nix.serverPath" = getExe pkgs.nil; + "nix.formatterPath" = getExe pkgs.nixfmt-rfc-style; + + "mesonbuild.buildFolder" = "build"; + "mesonbuild.formatting.enabled" = true; + "mesonbuild.linter.muon.enabled" = true; + "mesonbuild.downloadLanguageServer" = false; + "mesonbuild.languageServerPath" = getExe pkgs.mesonlsp; + "mesonbuild.mesonPath" = getExe pkgs.meson; + "mesonbuild.muomPath" = getExe pkgs.muon; + + "rust-analyzer.server.path" = getExe pkgs.rust-analyzer; + + "go.formatFlags" = [ "-s" ]; + "go.alternateTools" = with pkgs; { + go = getExe go; + gopls = getExe gopls; + dlv = getExe delve; + }; + + # vscode+vim configuration + "vim.useSystemClipboard" = true; + "vim.easymotion" = true; + "vim.hlsearch" = true; + "vim.gdefault" = true; + "vim.sneak" = true; + "vim.sneakReplacesF" = true; + "vim.vimrc.enable" = true; + "vim.vimrc.path" = ./../.vimrc; + "extensions.experimental.affinity" = { + "vscodevim.vim" = 1; + }; + "vim.useCtrlKeys" = true; + "vim.handleKeys" = { + "" = false; # command palette + "" = false; # new file + "" = false; # toggle sidebar + "" = false; # key with a million uses + "" = false; # select all text + }; + "vim.normalModeKeyBindings" = [ + # add binds to manage bookmarks (from the bookmarks extension) + { + before = [ + "" + "m" + ]; + commands = [ "bookmarks.toggle" ]; + } + { + before = [ + "" + "b" + ]; + commands = [ "bookmarks.list" ]; + } + ]; + + # some other extension behavior + "direnv.restart.automatic" = true; +} diff --git a/modules/code.nix b/modules/code.nix deleted file mode 100644 index 506e0bd..0000000 --- a/modules/code.nix +++ /dev/null @@ -1,61 +0,0 @@ -{ pkgs, unstablePkgs, ... }: - -let - extensions = with unstablePkgs.vscode-extensions; [ - # Microsoft vendor extensions - ms-vscode.hexeditor - ms-vscode-remote.remote-containers - ms-vscode-remote.remote-ssh - ms-azuretools.vscode-docker - github.codespaces - - # Usability - vscodevim.vim - waderyan.gitblame - mkhl.direnv - alefragnani.bookmarks - - # Language support - ms-vscode.makefile-tools - ms-vscode.cpptools-extension-pack - mesonbuild.mesonbuild - ms-python.python - ms-python.debugpy - charliermarsh.ruff - golang.go - jnoortheen.nix-ide - rust-lang.rust-analyzer - haskell.haskell - justusadam.language-haskell - elixir-lsp.vscode-elixir-ls - - # Pretty :3 - aaron-bond.better-comments - catppuccin.catppuccin-vsc-icons - catppuccin.catppuccin-vsc - jdinhlife.gruvbox - ]; - - externalExtensions = with pkgs.open-vsx; [ - # Small extensions that aren't included in nixpkgs - geequlim.godot-tools - miguelsolorio.fluent-icons - tonybaloney.vscode-pets - ]; - - newVendorExtensions = with pkgs.vscode-marketplace; [ - # Quick editing and viewing of ad-hoc repos and pull request - ms-vscode.remote-repositories - github.remotehub - ]; - - code = - with unstablePkgs; - vscode-with-extensions.override { - vscode = vscodium; - vscodeExtensions = extensions ++ externalExtensions ++ newVendorExtensions; - }; -in -{ - environment.systemPackages = [ code ]; -} diff --git a/modules/common.nix b/modules/common.nix index 00fc46a..dbc4efc 100644 --- a/modules/common.nix +++ b/modules/common.nix @@ -5,7 +5,6 @@ ./nix.nix ./user.nix ./locale.nix - ./code.nix ./vim.nix ./tmux.nix ./gnome.nix diff --git a/modules/home/code.nix b/modules/home/code.nix new file mode 100644 index 0000000..053d550 --- /dev/null +++ b/modules/home/code.nix @@ -0,0 +1,72 @@ +{ + pkgs, + unstablePkgs, + lib, + ... +}: + +let + settings = import ./../../configs/vscode/settings.nix { inherit pkgs lib; }; + keybindings = import ./../../configs/vscode/keybindings.nix { }; + + extensions = with unstablePkgs.vscode-extensions; [ + # Microsoft vendor extensions + ms-vscode.hexeditor + ms-vscode-remote.remote-containers + ms-vscode-remote.remote-ssh + ms-azuretools.vscode-docker + github.codespaces + + # Usability + vscodevim.vim + waderyan.gitblame + mkhl.direnv + alefragnani.bookmarks + + # Language support + ms-vscode.makefile-tools + ms-vscode.cpptools-extension-pack + mesonbuild.mesonbuild + ms-python.python + ms-python.debugpy + charliermarsh.ruff + golang.go + jnoortheen.nix-ide + rust-lang.rust-analyzer + haskell.haskell + justusadam.language-haskell + elixir-lsp.vscode-elixir-ls + + # Pretty :3 + aaron-bond.better-comments + catppuccin.catppuccin-vsc-icons + catppuccin.catppuccin-vsc + jdinhlife.gruvbox + ]; + + externalExtensions = with pkgs.open-vsx; [ + # Small extensions that aren't included in nixpkgs + geequlim.godot-tools + miguelsolorio.fluent-icons + tonybaloney.vscode-pets + ]; + + newVendorExtensions = with pkgs.vscode-marketplace; [ + # Quick editing and viewing of ad-hoc repos and pull request + ms-vscode.remote-repositories + github.remotehub + ]; +in +{ + programs.vscode = { + enable = true; + enableUpdateCheck = false; + enableExtensionUpdateCheck = false; + mutableExtensionsDir = false; + package = unstablePkgs.vscodium; + + extensions = extensions ++ externalExtensions ++ newVendorExtensions; + keybindings = keybindings; + userSettings = settings; + }; +} diff --git a/modules/home/common.nix b/modules/home/common.nix index 99900e6..7e10560 100644 --- a/modules/home/common.nix +++ b/modules/home/common.nix @@ -1,6 +1,10 @@ { ... }: { + imports = [ + ./code.nix + ]; + programs = { git = { enable = true; -- cgit 1.4.1