{  config, lib, pkgs, ... }:
let
  open-remote-ssh = pkgs.vscode-utils.buildVscodeExtension {
    pname = "open-remote-ssh";
    version = "0.0.49";
    vscodeExtPublisher = "jeanp413";
    vscodeExtName = "open-remote-ssh";
    vscodeExtUniqueId = "jeanp413.open-remote-ssh";
    src = pkgs.fetchurl {
      url = "https://open-vsx.org/api/jeanp413/open-remote-ssh/0.0.49/file/jeanp413.open-remote-ssh-0.0.49.vsix";
      sha256 = "sha256-QfJnAAx+kO2iJ1EzWoO5HLogJKg3RiC3hg1/u2Jm6t4";
      name = "open-remote-ssh.zip";
    };
  };
in
{
  programs.vscode = {
    enable = true;
    package = pkgs.vscodium;
    mutableExtensionsDir = false;
    profiles = {
      default = {
        enableUpdateCheck = false;
        enableExtensionUpdateCheck = false;
        extensions = with pkgs; [
          vscode-extensions.bbenoist.nix
          vscode-extensions.brettm12345.nixfmt-vscode
          vscode-extensions.cweijan.vscode-database-client2
          vscode-extensions.dendron.dendron-markdown-preview-enhanced
          vscode-extensions.jnoortheen.nix-ide
          vscode-extensions.ms-python.debugpy
          vscode-extensions.ms-python.pylint
          vscode-extensions.ms-python.python
          # vscode-extensions.ms-python.vscode-pylance
          vscode-extensions.redhat.vscode-xml
          vscode-extensions.redhat.vscode-yaml
          vscode-extensions.yy0931.vscode-sqlite3-editor

          open-remote-ssh
        ] ++ pkgs.vscode-utils.extensionsFromVscodeMarketplace [
          {
            name = "copilot-mcp";
            publisher = "automatalabs";
            version = "0.0.49";
            sha256 = "sha256-+G2OQl5SCN7bh7MzGdYiRclIZefBE7lWnGg1kNpCvnA=";
          }
          {
            name = "mcp-server-runner";
            publisher = "zebradev";
            version = "0.1.0";
            sha256 = "sha256-StydVt3VzQUSS/pYp76jnIwtZlEj8gWAGzOARs93J+E=";
          }
          {
            name = "claude-dev";
            publisher = "saoudrizwan";
            version = "3.17.9";
            sha256 = "sha256-y3bFtMe5vZrO3DFb31KDvkzjD2jM76wK89mKhgJXC70=";
          }
        ];

        userSettings = {

          "editor" = {
            "defaultFormatter" = "brettm12345.nixfmt-vscode";
            "fontFamily" = "fira-code-nerd, FiraCode Nerd Font, Consolas, 'Courier New', monospace";
            "fontLigatures" = true;
            "renderWhitespace" = "all";
          };

          "explorer" = {
            "confirmDelete" = false;
            "confirmDragAndDrop" = false;
          };
          
          "git" = {
            "confirmSync" = false;
            "enableSmartCommit" = true;
          };

          "github" = {
            "copilot.nextEditSuggestions.enabled" = true;
            "copilot.enable" = {
              "nix" = true;
            };
          };

          "[json]" = {
            "editor.defaultFormatter" = "vscode.json-language-features";
          };

          "nix" = {
            "enableLanguageServer" = true;
            "formatterPath" = "nixpkgs-fmt";
            "serverPath" = "nixd";
            "serverSettings" = {
              "nixd" = {
                "formatting" = {
                  "command" = [ "nixpkgs-fmt" ];
                };
                "options" = {
                  # By default, this entriy will be read from `import <nixpkgs> { }`.
                  # You can write arbitary Nix expressions here, to produce valid "options" declaration result.
                  # Tip: for flake-based configuration, utilize `builtins.getFlake`
                  "nixos" = {
                      "expr" = "(builtins.getFlake \"${config.home.homeDirectory}/nix-config\").nixosConfigurations.<name>.options";
                  };
                  "home-manager" = {
                      "expr" = "(builtins.getFlake \"${config.home.homeDirectory}/nix-config\").homeConfigurations.<name>.options";
                  };
                  # # Tip: use ${workspaceFolder} variable to define path
                  # "nix-darwin" = {
                  #   "expr" = "(builtins.getFlake \"${workspaceFolder}/path/to/flake\").darwinConfigurations.<name>.options"
                  # }
                };
              };
            };
          };

          "[nix]" = {
            "editor" = {
              "defaultFormatter" = "brettm12345.nixfmt-vscode";
              "tabSize" = 2;
            };
          };

          "security.workspace.trust.untrustedFiles" = "open";

          "workbench" = {
            "colorCustomizations" = null;
            "editorAssociations" = {
              "*.db" = "default";
            };
          };
        };
      };
    };
  };
}