diff options
-rw-r--r-- | dotfiles/vim/lua/vim-dev.lua | 32 | ||||
-rw-r--r-- | usecases/desktop/development.nix | 229 |
2 files changed, 152 insertions, 109 deletions
diff --git a/dotfiles/vim/lua/vim-dev.lua b/dotfiles/vim/lua/vim-dev.lua index e1c38db..c8bcba7 100644 --- a/dotfiles/vim/lua/vim-dev.lua +++ b/dotfiles/vim/lua/vim-dev.lua | |||
@@ -31,7 +31,7 @@ local function on_attach(client, bufnr) | |||
31 | -- Capability specific | 31 | -- Capability specific |
32 | 32 | ||
33 | if client.server_capabilities.documentFormattingProvider then | 33 | if client.server_capabilities.documentFormattingProvider then |
34 | vim.keymap.set("n", "<leader>sf", vim.lsp.buf.formatting, desc(opts, "Format buffer")) | 34 | vim.keymap.set("n", "<leader>sf", vim.lsp.buf.format, desc(opts, "Format buffer")) |
35 | end | 35 | end |
36 | 36 | ||
37 | -- Rust specific | 37 | -- Rust specific |
@@ -75,21 +75,31 @@ require("refactoring").setup {} | |||
75 | 75 | ||
76 | -- Null LSP | 76 | -- Null LSP |
77 | 77 | ||
78 | require("null-ls").setup({ | 78 | local null_ls = require("null-ls") |
79 | |||
80 | null_ls.setup({ | ||
79 | sources = { | 81 | sources = { |
80 | require("null-ls").builtins.code_actions.gitrebase, | 82 | null_ls.builtins.code_actions.gitrebase, |
81 | require("null-ls").builtins.code_actions.gitsigns, | 83 | null_ls.builtins.code_actions.gitsigns, |
82 | require("null-ls").builtins.code_actions.refactoring.with { | 84 | null_ls.builtins.code_actions.refactoring.with { |
83 | filetypes = { "typescript", "javascript", "lua", "c", "cpp", "go", "python", "java", "php", "ruby" }, | 85 | filetypes = { "typescript", "javascript", "lua", "c", "cpp", "go", "python", "java", "php", "ruby" }, |
84 | }, | 86 | }, |
85 | require("null-ls").builtins.code_actions.shellcheck, | 87 | null_ls.builtins.code_actions.shellcheck, |
86 | require("null-ls").builtins.code_actions.statix, | 88 | null_ls.builtins.code_actions.statix, |
87 | require("null-ls").builtins.diagnostics.deadnix, | 89 | |
88 | require("null-ls").builtins.diagnostics.shellcheck, | 90 | null_ls.builtins.diagnostics.deadnix, |
89 | require("null-ls").builtins.diagnostics.statix, | 91 | null_ls.builtins.diagnostics.ruff, |
90 | require("null-ls").builtins.diagnostics.vale.with { | 92 | null_ls.builtins.diagnostics.shellcheck, |
93 | null_ls.builtins.diagnostics.statix, | ||
94 | null_ls.builtins.diagnostics.vale.with { | ||
91 | filetypes = { "markdown", "pandoc", "tex", "asciidoc" }, | 95 | filetypes = { "markdown", "pandoc", "tex", "asciidoc" }, |
92 | }, | 96 | }, |
97 | |||
98 | null_ls.builtins.formatting.alejandra, | ||
99 | null_ls.builtins.formatting.black, | ||
100 | null_ls.builtins.formatting.isort, | ||
101 | null_ls.builtins.formatting.shfmt, | ||
102 | null_ls.builtins.formatting.taplo, | ||
93 | }, | 103 | }, |
94 | on_attach = on_attach, | 104 | on_attach = on_attach, |
95 | }) | 105 | }) |
diff --git a/usecases/desktop/development.nix b/usecases/desktop/development.nix index d15afec..bc936b8 100644 --- a/usecases/desktop/development.nix +++ b/usecases/desktop/development.nix | |||
@@ -1,9 +1,11 @@ | |||
1 | inputs: | 1 | inputs: { |
2 | 2 | config, | |
3 | { config, lib, pkgs, ... }: | 3 | lib, |
4 | 4 | pkgs, | |
5 | let | 5 | ... |
6 | inherit (pkgs.unstable) | 6 | }: let |
7 | inherit | ||
8 | (pkgs.unstable) | ||
7 | clang | 9 | clang |
8 | clang-tools | 10 | clang-tools |
9 | elixir_ls | 11 | elixir_ls |
@@ -11,67 +13,82 @@ let | |||
11 | marksman | 13 | marksman |
12 | rust-analyzer-unwrapped | 14 | rust-analyzer-unwrapped |
13 | lua-language-server | 15 | lua-language-server |
14 | 16 | vimPlugins | |
15 | vimPlugins; | 17 | ; |
16 | 18 | ||
17 | inherit (pkgs.unstable.python3Packages) python-lsp-server; | 19 | pylsp = with pkgs.unstable.python3Packages; |
18 | 20 | python-lsp-server.overrideAttrs (old: { | |
19 | luaFormat = inputs.self.lib.generators.lua { }; | 21 | propagatedBuildInputs = |
20 | 22 | old.propagatedBuildInputs | |
21 | in | 23 | ++ python-lsp-server.passthru.optional-dependencies.all; |
22 | { | 24 | }); |
25 | |||
26 | luaFormat = inputs.self.lib.generators.lua {}; | ||
27 | in { | ||
23 | imports = [ | 28 | imports = [ |
24 | (import ./development/latex.nix inputs) | 29 | (import ./development/latex.nix inputs) |
25 | ]; | 30 | ]; |
26 | 31 | ||
27 | options = with lib; with luaFormat.lib; { | 32 | options = with lib; |
33 | with luaFormat.lib; { | ||
28 | vim.lsp = mkOption { | 34 | vim.lsp = mkOption { |
29 | description = '' | 35 | description = '' |
30 | Configure Neovim to use these LSP servers; | 36 | Configure Neovim to use these LSP servers; |
31 | ''; | 37 | ''; |
32 | type = with types; attrsOf (submodule { | 38 | type = with types; |
33 | freeformType = luaFormat.type; | 39 | attrsOf (submodule { |
34 | 40 | freeformType = luaFormat.type; | |
35 | options = { | 41 | |
36 | capabilities = mkOption { | 42 | options = { |
37 | default = mkRaw "capabilities"; | 43 | capabilities = mkOption { |
38 | }; | 44 | default = mkRaw "capabilities"; |
39 | cmd = mkOption { | 45 | }; |
40 | type = with types; listOf str; | 46 | cmd = mkOption { |
41 | }; | 47 | type = with types; listOf str; |
42 | on_attach = mkOption { | 48 | }; |
43 | default = mkRaw "on_attach"; | 49 | on_attach = mkOption { |
50 | default = mkRaw "on_attach"; | ||
51 | }; | ||
44 | }; | 52 | }; |
45 | }; | 53 | }); |
46 | }); | 54 | default = {}; |
47 | default = { }; | ||
48 | }; | 55 | }; |
49 | }; | 56 | }; |
50 | 57 | ||
51 | config = { | 58 | config = { |
52 | # TODO: add cargo-info | 59 | # TODO: add cargo-info |
53 | users.extraUsers.minijackson.packages = with pkgs.unstable; [ | 60 | users.extraUsers.minijackson.packages = with pkgs.unstable; |
54 | bintools | 61 | [ |
55 | bacon | 62 | bintools |
56 | clang | 63 | bacon |
57 | clang-tools | 64 | clang |
58 | diffoscopeMinimal | 65 | clang-tools |
59 | elixir | 66 | diffoscopeMinimal |
60 | gcc | 67 | elixir |
61 | gdb | 68 | gcc |
62 | graphviz | 69 | gdb |
63 | man-pages | 70 | graphviz |
64 | python3Packages.ipython | 71 | man-pages |
65 | rr | 72 | python3Packages.ipython |
66 | rustup | 73 | rr |
67 | watchexec | 74 | rustup |
68 | 75 | watchexec | |
69 | # Python | 76 | |
70 | black | 77 | shfmt |
71 | python3Packages.isort | 78 | taplo |
72 | python3Packages.mypy | 79 | |
73 | python3Packages.tox | 80 | # Python |
74 | ]; | 81 | black |
82 | python3Packages.isort | ||
83 | python3Packages.mypy | ||
84 | python3Packages.tox | ||
85 | # TODO: how to install into pylsp's python env? | ||
86 | # python-lsp-black | ||
87 | # pyls-isort | ||
88 | # pylsp-mypy | ||
89 | |||
90 | ruff | ||
91 | ]; | ||
75 | 92 | ||
76 | vim = { | 93 | vim = { |
77 | extraPlugins = with vimPlugins; [ | 94 | extraPlugins = with vimPlugins; [ |
@@ -91,28 +108,45 @@ in | |||
91 | }; | 108 | }; |
92 | 109 | ||
93 | lsp = { | 110 | lsp = { |
94 | elixirls.cmd = [ "${elixir_ls}/bin/elixir-ls" ]; | 111 | elixirls.cmd = ["${elixir_ls}/bin/elixir-ls"]; |
95 | hls.cmd = [ "${haskell-language-server}/bin/haskell-language-server" "--lsp" ]; | 112 | hls.cmd = ["${haskell-language-server}/bin/haskell-language-server" "--lsp"]; |
96 | lua_ls = { | 113 | lua_ls = { |
97 | cmd = [ "${lua-language-server}/bin/lua-language-server" ]; | 114 | cmd = ["${lua-language-server}/bin/lua-language-server"]; |
98 | settings.Lua.completion.callSnippet = "Replace"; | 115 | settings.Lua = { |
116 | completion.callSnippet = "Replace"; | ||
117 | telemetry.enable = false; | ||
118 | }; | ||
119 | }; | ||
120 | marksman.cmd = ["${marksman}/bin/marksman"]; | ||
121 | pylsp = { | ||
122 | cmd = ["${pylsp}/bin/pylsp"]; | ||
123 | settings.pylsp.plugins = { | ||
124 | autopep8.enabled = false; | ||
125 | flake8.ignore = ["E501"]; | ||
126 | pycodestyle.ignore = ["E501"]; | ||
127 | yapf.enabled = false; | ||
128 | |||
129 | # See TODO above | ||
130 | #black.enabled = true; | ||
131 | #isort.enabled = true; | ||
132 | #mypy.enabled = true; | ||
133 | }; | ||
99 | }; | 134 | }; |
100 | marksman.cmd = [ "${marksman}/bin/marksman" ]; | ||
101 | pylsp.cmd = [ "${python-lsp-server}/bin/pylsp" ]; | ||
102 | }; | 135 | }; |
103 | 136 | ||
104 | luaConfig = with lib; let | 137 | luaConfig = with lib; let |
105 | toLua = luaFormat.generate; | 138 | toLua = luaFormat.generate; |
106 | lspconfigFor = name: settings: "lspconfig['${name}'].setup ${toLua settings}"; | 139 | lspconfigFor = name: settings: "lspconfig['${name}'].setup ${toLua settings}"; |
107 | lspconfig = concatStringsSep | 140 | lspconfig = |
141 | concatStringsSep | ||
108 | "\n" | 142 | "\n" |
109 | (mapAttrsToList lspconfigFor config.vim.lsp); | 143 | (mapAttrsToList lspconfigFor config.vim.lsp); |
110 | in | 144 | in |
111 | mkMerge [ | 145 | mkMerge [ |
112 | "require('vim-dev')" | 146 | "require('vim-dev')" |
113 | "local lspconfig = require('lspconfig')" | 147 | "local lspconfig = require('lspconfig')" |
114 | lspconfig | 148 | lspconfig |
115 | ]; | 149 | ]; |
116 | }; | 150 | }; |
117 | 151 | ||
118 | programs.zsh.interactiveShellInit = '' | 152 | programs.zsh.interactiveShellInit = '' |
@@ -128,47 +162,46 @@ in | |||
128 | "kernel.perf_event_paranoid" = 1; | 162 | "kernel.perf_event_paranoid" = 1; |
129 | }; | 163 | }; |
130 | 164 | ||
131 | home-manager.users.minijackson = { config, ... }: | 165 | home-manager.users.minijackson = {config, ...}: { |
132 | { | 166 | home.file.".clang-format".source = |
133 | home.file.".clang-format".source = (pkgs.formats.yaml { }).generate | 167 | (pkgs.formats.yaml {}).generate |
134 | "clang-format.yml" | 168 | "clang-format.yml" |
135 | { | 169 | { |
136 | BasedOnStyle = "Mozilla"; | 170 | BasedOnStyle = "Mozilla"; |
137 | ColumnLimit = 100; | 171 | ColumnLimit = 100; |
138 | TabWidth = 4; | 172 | TabWidth = 4; |
139 | IndentWidth = 4; | 173 | IndentWidth = 4; |
140 | UseTab = "ForIndentation"; | 174 | UseTab = "ForIndentation"; |
141 | 175 | ||
142 | AlignAfterOpenBracket = "AlwaysBreak"; | 176 | AlignAfterOpenBracket = "AlwaysBreak"; |
143 | AccessModifierOffset = -4; | 177 | AccessModifierOffset = -4; |
144 | AlwaysBreakAfterDefinitionReturnType = "None"; | 178 | AlwaysBreakAfterDefinitionReturnType = "None"; |
145 | AlwaysBreakAfterReturnType = "None"; | 179 | AlwaysBreakAfterReturnType = "None"; |
146 | AlwaysBreakTemplateDeclarations = true; | 180 | AlwaysBreakTemplateDeclarations = true; |
147 | BinPackArguments = false; | 181 | BinPackArguments = false; |
148 | BinPackParameters = false; | 182 | BinPackParameters = false; |
149 | BreakConstructorInitializers = "BeforeComma"; | 183 | BreakConstructorInitializers = "BeforeComma"; |
150 | Cpp11BracedListStyle = true; | 184 | Cpp11BracedListStyle = true; |
151 | DerivePointerAlignment = false; | 185 | DerivePointerAlignment = false; |
152 | NamespaceIndentation = "Inner"; | 186 | NamespaceIndentation = "Inner"; |
153 | PenaltyBreakBeforeFirstCallParameter = 2; | 187 | PenaltyBreakBeforeFirstCallParameter = 2; |
154 | PointerAlignment = "Left"; | 188 | PointerAlignment = "Left"; |
155 | Standard = "Latest"; | 189 | Standard = "Latest"; |
156 | }; | 190 | }; |
157 | 191 | ||
158 | programs.direnv = { | 192 | programs.direnv = { |
159 | enable = true; | 193 | enable = true; |
160 | enableBashIntegration = true; | 194 | enableBashIntegration = true; |
161 | enableZshIntegration = true; | 195 | enableZshIntegration = true; |
162 | 196 | ||
163 | nix-direnv.enable = true; | 197 | nix-direnv.enable = true; |
164 | }; | ||
165 | }; | 198 | }; |
199 | }; | ||
166 | 200 | ||
167 | nixpkgs.overlays = [ | 201 | nixpkgs.overlays = [ |
168 | (self: super: { | 202 | (self: super: { |
169 | inherit (self.unstable) nix-direnv direnv; | 203 | inherit (self.unstable) nix-direnv direnv; |
170 | }) | 204 | }) |
171 | ]; | 205 | ]; |
172 | |||
173 | }; | 206 | }; |
174 | } | 207 | } |