about summary refs log tree commit diff
path: root/modules/vscode.nix
blob: 393b32f93dcabbadb96eb9f585451f38b2010b17 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
{
  config,
  inputs,
  lib,
  pkgs,
  ...
}:
with lib;
let
  cfg = config.nixfiles.modules.vscode;
in
{
  options.nixfiles.modules.vscode = {
    enable = mkEnableOption "VSCode";

    package =
      with pkgs;
      mkOption {
        type = types.enum [
          vscodium
          vscode
          vscode-fhs
        ];
        default = vscodium;
        description = "Which package to use as a VSCode implementation.";
      };

    vim.enable = mkOption {
      type = types.bool;
      default = true;
      description = "Whether to enable Vim emulation.";
    };
  };

  config = mkIf cfg.enable {
    hm = {
      stylix.targets.vscode.enable = false;

      programs.vscode =
        with config.nixfiles;
        with modules;
        with profiles;
        {
          enable = true;

          inherit (cfg) package;

          extensions =
            with pkgs.open-vsx;
            [
              editorconfig.editorconfig
              efoerster.texlab
              github.vscode-pull-request-github
              gitlab.gitlab-workflow
              golang.go
              # graphql.vscode-graphql
              graphql.vscode-graphql-execution
              graphql.vscode-graphql-syntax
              hashicorp.hcl
              hashicorp.terraform
              haskell.haskell
              jnoortheen.nix-ide
              kahole.magit
              mads-hartmann.bash-ide-vscode
              mkhl.direnv
              ms-kubernetes-tools.vscode-kubernetes-tools
              ms-python.python
              redhat.ansible
              redhat.vscode-xml
              redhat.vscode-yaml
              rust-lang.rust
              signageos.signageos-vscode-sops
              skellock.just
              streetsidesoftware.code-spell-checker
              streetsidesoftware.code-spell-checker-russian
              streetsidesoftware.code-spell-checker-scientific-terms
              tamasfe.even-better-toml
              # task.vscode-task
              # vscode-org-mode.org-mode
            ]
            ++ optional cfg.vim.enable vscodevim.vim;

          userSettings = {
            editor = {
              codeLens = false;
              cursorStyle = "block";
              detectIndentation = true;
              minimap.enabled = false;
              renderWhitespace = "trailing";
              rulers = [
                80
                120
              ];
              smoothScrolling = false;
              tabCompletion = "on";
              cursorSurroundingLines = 10;
              scrollBeyondLastColumn = 10;
            };

            keyboard.dispatch = "keyCode";

            diffEditor.codeLens = false;

            files = {
              autoSave = "off";
              enableTrash = false;
            };

            workbench = {
              activityBar.location = "hidden";
              colorTheme = "Default Light Modern";
              editor.highlightModifiedTabs = true;
              enableExperiments = false;
              settings.enableNaturalLanguageSearch = false;
              startupEditor = "none";
              tips.enabled = false;
              tree.indent = 4;
              welcomePage = {
                walkthroughs.openOnInstall = false;
                preferReducedMotion = true;
              };
            };

            extensions = {
              autoCheckUpdates = false;
              autoUpdate = false;
              ignoreRecommendations = true;
            };

            terminal.integrated = {
              enableBell = true;
            };

            update = {
              mode = "none";
              showReleaseNotes = false;
            };

            telemetry = {
              enableCrashReporter = false;
              enableTelemetry = false;
            };

            security.workspace.trust.enabled = false;

            # Extensions.

            ansible = {
              ansible = {
                useFullyQualifiedCollectionNames = true;
                reuseTerminal = true;
              };
              validation.lint.path = getExe' pkgs.ansible-lint "ansible-lint";
            };

            bashIde.shellcheckPath = getExe' pkgs.shellcheck "shellcheck";

            cSpell.language = "en-GB,en,ru";

            direnv = {
              restart.automatic = true;
            };

            magit = {
              forge-enabled = true;
              git-path = getExe config.hm.programs.git.package;
            };

            git.openRepositoryInParentFolders = "always";

            github = {
              branchProtection = true;
              gitProtocol = "ssh";
            };

            terraform = {
              languageServer.path = getExe' pkgs.terraform-ls "terraform-ls";
              languageServer.terraform.path = getExe pkgs.opentofu;
            };

            haskell = {
              formattingProvider = "ormolu";
              serverExecutablePath = getExe' pkgs.haskell-language-server "haskell-language-server";
            };

            nix = {
              enableLanguageServer = true;
              serverPath = getExe pkgs.nil;
            };

            python = with pkgs.python311Packages; {
              experiments.optOutFrom = [ "All" ];
              pipenvPath = getExe' pkgs.pipenv "pipenv";
              poetryPath = getExe' pkgs.poetry "poetry";
              formatting = {
                provider = "black";
                autopep8Path = getExe' autopep8 "autopep8";
                blackPath = getExe' black "black";
                yapfPath = getExe' yapf "yapf";
              };
              linting = {
                enabled = true;
                banditPath = getExe' bandit "bandit";
                flake8Path = getExe' flake8 "flake8";
                mypyPath = getExe' mypy "mypy";
                pycodestylePath = getExe' pycodestyle "pycodestyle";
                pydocstylePath = getExe' pydocstyle "pydocstyle";
                pylamaPath = getExe' pylama "pylama";
                pylintPath = getExe' pylint "pylint";
              };
              testing = {
                pytestPath = getExe' pytest "pytest";
              };
            };

            rust-client = {
              disableRustup = true;
              rustupPath = getExe' pkgs.rustup "rustup";
              rustfmt_path = getExe pkgs.rustfmt;
            };

            vim = mkIf cfg.vim.enable {
              easymotion = true;

              leader = " ";

              useSystemClipboard = true;
            };

            redhat.telemetry.enabled = false;
          };
        };
    };

    nixpkgs.overlays = [ inputs.vscode-extensions.overlays.default ];
  };
}

Consider giving Nix/NixOS a try! <3