#
# Visual Studio Code + Dance (kakoune mode) Experiments
#
{ pkgs, deprekages, lib, ... }:
let
  # Simple helper to de-stringify invalid tokens.
	author = name: pkgs.vscode-extensions.${name};

	# Forces a package to be marked as having linux-aarch64 support.
	forceArmLinux = pkg: pkg.overrideAttrs (prev: {
		meta.platforms = prev.meta.platforms ++ [ "aarch64-linux" ];
	});
in
{

	programs.vscode = {
		enable = true;

		#
		# Extensions to include with vscode.
		#
		extensions = with (pkgs.vscode-extensions // deprekages.vscode-extensions); [
			# Requires a qualified name due to the leading '1'.
			(author "1Password").op-vscode

			# appearance
			oderwat.indent-rainbow
			brandonkirbyson.solarized-palenight

			# behavior
			gregoire.dance
			usernamehw.errorlens
			editorconfig.editorconfig

			# general add-ons
			adpyke.codesnap
			ms-toolsai.jupyter
			ms-vscode.hexeditor
			ms-vscode.cmake-tools
			ms-vscode.makefile-tools
			streetsidesoftware.code-spell-checker

			# rust
			fill-labs.dependi
			rust-lang.rust-analyzer
      njpwerner.autodocstring

			# python
			(forceArmLinux ms-python.python)

      # c/c++
      ms-vscode.cpptools

			# misc languages
      golang.go
			graphql.vscode-graphql
			graphql.vscode-graphql-syntax

			# accessibility / talon, for when our neuro condition is wonk
			pokey.talon
			pokey.cursorless
			pokey.parse-tree
			pokey.command-server

		];

		#
		# Keybindings.
		#
		keybindings = [
      {
          key = "shift shift";
          command = "workbench.action.quickOpen";
      }
      {
          key =  "alt alt";
          command = "workbench.action.quickOpen";
      }
      {
          key = "ctrl ctrl";
          command = "workbench.action.showCommands";
      }
    ];

		#
		# VSCode settings; runtime settings are immutable.
		#
		userSettings = {

  		# Theming.
			"workbench.colorTheme" = lib.mkForce "Solarized-Palenight";

			# Default to formatting on save.
			"editor.formatOnSave" = true;

			#
			# Rust
			#
			"rust-analyzer.checkOnSave.command" =  "clippy";

			#
			# Spell Checking
			#
		  "cSpell.userWords" = [
        "serdes"
        "ktemkin"
        "kadkins"
        "deprekated"
        "unpoison"
        "poisonable"
        "hieratika"
      ];

		};

		#
		# For now, let Nix manage everything.
		#
		enableUpdateCheck = false;
		enableExtensionUpdateCheck = false;

		mutableExtensionsDir = false;

	};

}
