diff --git a/flake.lock b/flake.lock index bc99849..6977747 100644 --- a/flake.lock +++ b/flake.lock @@ -90,11 +90,11 @@ ] }, "locked": { - "lastModified": 1696043447, - "narHash": "sha256-VbJ1dY5pVH2fX1bS+cT2+4+BYEk4lMHRP0+udu9G6tk=", + "lastModified": 1696360011, + "narHash": "sha256-HpPv27qMuPou4acXcZ8Klm7Zt0Elv9dgDvSJaomWb9Y=", "owner": "lnl7", "repo": "nix-darwin", - "rev": "792c2e01347cb1b2e7ec84a1ef73453ca86537d8", + "rev": "8b6ea26d5d2e8359d06278364f41fbc4b903b28a", "type": "github" }, "original": { @@ -111,11 +111,11 @@ ] }, "locked": { - "lastModified": 1695864092, - "narHash": "sha256-Hu1SkFPqO7ND95AOzBkZE2jGXSYhfZ965C03O72Kbu8=", + "lastModified": 1696468923, + "narHash": "sha256-qSM7NKgf8LcZ5hjKHZ8ANFI8+LQivvAypbhJHBJmYFM=", "owner": "nix-community", "repo": "disko", - "rev": "19b62324663b6b9859caf7f335d232cf4f1f6a32", + "rev": "cde886a1c97ef2399b4f91409db045785020291f", "type": "github" }, "original": { @@ -131,11 +131,11 @@ ] }, "locked": { - "lastModified": 1696034364, - "narHash": "sha256-7giewUYqKhhfhKRxe2EPHCpSM0oMLuByW4RTRZl6Jfc=", + "lastModified": 1696639203, + "narHash": "sha256-T11ve6QN+9rD58q5CU10pOZavfOSl44S6q19H0W73l8=", "owner": "bandithedoge", "repo": "nixpkgs-firefox-darwin", - "rev": "b1e4d451a15c34d45bfefb05137a20469399a2df", + "rev": "6c9812285de872caff762633928370fe9f30365d", "type": "github" }, "original": { @@ -237,11 +237,11 @@ ] }, "locked": { - "lastModified": 1696063111, - "narHash": "sha256-F2IJEbyH3xG0eqyAYn9JoV+niqNz+xb4HICYNkkviNI=", + "lastModified": 1696737557, + "narHash": "sha256-YD/pjDjj/BNmisEvRdM/vspkCU3xyyeGVAUWhvVSi5Y=", "owner": "nix-community", "repo": "home-manager", - "rev": "ae896c810f501bf0c3a2fd7fc2de094dd0addf01", + "rev": "3c1d8758ac3f55ab96dcaf4d271c39da4b6e836d", "type": "github" }, "original": { @@ -369,11 +369,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1695830400, - "narHash": "sha256-gToZXQVr0G/1WriO83olnqrLSHF2Jb8BPcmCt497ro0=", + "lastModified": 1696604326, + "narHash": "sha256-YXUNI0kLEcI5g8lqGMb0nh67fY9f2YoJsILafh6zlMo=", "owner": "nixos", "repo": "nixpkgs", - "rev": "8a86b98f0ba1c405358f1b71ff8b5e1d317f5db2", + "rev": "87828a0e03d1418e848d3dd3f3014a632e4a4f64", "type": "github" }, "original": { @@ -385,11 +385,11 @@ }, "nixpkgs_2": { "locked": { - "lastModified": 1695825837, - "narHash": "sha256-4Ne11kNRnQsmSJCRSSNkFRSnHC4Y5gPDBIQGjjPfJiU=", + "lastModified": 1696039360, + "narHash": "sha256-g7nIUV4uq1TOVeVIDEZLb005suTWCUjSY0zYOlSBsyE=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "5cfafa12d57374f48bcc36fda3274ada276cf69e", + "rev": "32dcb45f66c0487e92db8303a798ebc548cadedc", "type": "github" }, "original": { @@ -417,11 +417,11 @@ }, "nur": { "locked": { - "lastModified": 1696080597, - "narHash": "sha256-fhf7+NT/xMwPZ/sRT30lnI04AHgf7tLPU4ClMux1nWA=", + "lastModified": 1696772745, + "narHash": "sha256-9cXNUJwpHLOTPqlpUF33oFJHzrscb9oi/YKS2QiiTtQ=", "owner": "nix-community", "repo": "nur", - "rev": "8783c360abc69f58d46a2929534ddd91eb41f3c6", + "rev": "09a721cf6869671ec2258da3c377436e3498eead", "type": "github" }, "original": { @@ -450,11 +450,11 @@ "nvim-tree-lua-src": { "flake": false, "locked": { - "lastModified": 1695716495, - "narHash": "sha256-Fkchn7UuIHPmVFFrx1kzsE2lviJrAFAe9tHu73HnS/w=", + "lastModified": 1696725658, + "narHash": "sha256-8/JxdIY4v4kf24wLA8b2LE1HUD4gYpVEGJrZq7da7Nw=", "owner": "kyazdani42", "repo": "nvim-tree.lua", - "rev": "934469b9b6df369e198fb3016969e56393b0dc07", + "rev": "53b0bcaadaffb505acff230578b56a86ec1ab38a", "type": "github" }, "original": { @@ -466,11 +466,11 @@ "nvim-treesitter-src": { "flake": false, "locked": { - "lastModified": 1696061053, - "narHash": "sha256-KR+VMYTVM2qsLPx412gySAKiGObhs+awbDJhWX72/wY=", + "lastModified": 1696754715, + "narHash": "sha256-UkZVEkhPONkW0J3i46uhNB0BMHE3LxVO8lSyBxUk05w=", "owner": "nvim-treesitter", "repo": "nvim-treesitter", - "rev": "dd4e2dbc002dfce109d621e8bdcd9d89438b0a32", + "rev": "a102053352bd958d84a3e1be3de0203d2af92984", "type": "github" }, "original": { @@ -655,11 +655,11 @@ "tree-sitter-bash": { "flake": false, "locked": { - "lastModified": 1695263734, - "narHash": "sha256-dJUJGrpBWBLjcqiqxCnJ/MENwa2+uxAmQD71aYloxsw=", + "lastModified": 1696293236, + "narHash": "sha256-4ikQGyi8VZQpR5U0RzBkfzvEsSu9PcDOABnyHW/1Ugc=", "owner": "tree-sitter", "repo": "tree-sitter-bash", - "rev": "fd4e40dab883d6456da4d847de8321aee9c80805", + "rev": "1479a4030f1a399c253aee02097576d4af46f23a", "type": "github" }, "original": { @@ -790,11 +790,11 @@ "nixpkgs": "nixpkgs_2" }, "locked": { - "lastModified": 1696053802, - "narHash": "sha256-8TTbJbtGDz1MstExrVQe56eXZpovvZv6G6L6q/4NOKg=", + "lastModified": 1696239710, + "narHash": "sha256-Ps7zIKYGT7TEi9JrG1fV9cdUY5X6hmaidUcTaEDxPO4=", "owner": "nix-community", "repo": "NixOS-WSL", - "rev": "cadde47d123d1a534c272b04a7582f1d11474c48", + "rev": "337edef90c8abe35b42e95aecf510a063dad02dd", "type": "github" }, "original": { diff --git a/modules/common/neovim/config/lsp.nix b/modules/common/neovim/config/lsp.nix index 553f25d..215c923 100644 --- a/modules/common/neovim/config/lsp.nix +++ b/modules/common/neovim/config/lsp.nix @@ -1,76 +1,94 @@ -{ pkgs, dsl, ... }: { +{ pkgs, lib, config, dsl, ... }: { - plugins = [ - pkgs.vimPlugins.nvim-lspconfig - pkgs.vimPlugins.lsp-colors-nvim - pkgs.vimPlugins.null-ls-nvim - ]; + # Terraform optional because non-free + options.useTerraform = lib.mkEnableOption "Whether to enable Terraform LSP"; - use.lspconfig.lua_ls.setup = dsl.callWith { - settings = { Lua = { diagnostics = { globals = [ "vim" "hs" ]; }; }; }; - capabilities = dsl.rawLua "require('cmp_nvim_lsp').default_capabilities()"; - cmd = [ "${pkgs.lua-language-server}/bin/lua-language-server" ]; - }; + config = - use.lspconfig.nil_ls.setup = dsl.callWith { - cmd = [ "${pkgs.nil}/bin/nil" ]; - capabilities = dsl.rawLua "require('cmp_nvim_lsp').default_capabilities()"; - }; + let - use.lspconfig.pyright.setup = dsl.callWith { - cmd = [ "${pkgs.pyright}/bin/pyright-langserver" "--stdio" ]; - }; + terraformFormat = if config.useTerraform then '' + require("null-ls").builtins.formatting.terraform_fmt.with({ + command = "${pkgs.terraform}/bin/terraform", + extra_filetypes = { "hcl" }, + }), + '' else + ""; - use.lspconfig.terraformls.setup = - dsl.callWith { cmd = [ "${pkgs.terraform-ls}/bin/terraform-ls" "serve" ]; }; + in { + plugins = [ + pkgs.vimPlugins.nvim-lspconfig + pkgs.vimPlugins.lsp-colors-nvim + pkgs.vimPlugins.null-ls-nvim + ]; - vim.api.nvim_create_augroup = dsl.callWith [ "LspFormatting" { } ]; + use.lspconfig.lua_ls.setup = dsl.callWith { + settings = { Lua = { diagnostics = { globals = [ "vim" "hs" ]; }; }; }; + capabilities = + dsl.rawLua "require('cmp_nvim_lsp').default_capabilities()"; + cmd = [ "${pkgs.lua-language-server}/bin/lua-language-server" ]; + }; - lua = '' - ${builtins.readFile ./lsp.lua} + use.lspconfig.nil_ls.setup = dsl.callWith { + cmd = [ "${pkgs.nil}/bin/nil" ]; + capabilities = + dsl.rawLua "require('cmp_nvim_lsp').default_capabilities()"; + }; - -- Prevent infinite log size (change this when debugging) - vim.lsp.set_log_level("off") + use.lspconfig.pyright.setup = dsl.callWith { + cmd = [ "${pkgs.pyright}/bin/pyright-langserver" "--stdio" ]; + }; - require("null-ls").setup({ - sources = { - require("null-ls").builtins.formatting.stylua.with({ command = "${pkgs.stylua}/bin/stylua" }), - require("null-ls").builtins.formatting.black.with({ command = "${pkgs.black}/bin/black" }), - require("null-ls").builtins.diagnostics.ruff.with({ command = "${pkgs.ruff}/bin/ruff" }), - require("null-ls").builtins.formatting.fish_indent.with({ command = "${pkgs.fish}/bin/fish_indent" }), - require("null-ls").builtins.formatting.nixfmt.with({ command = "${pkgs.nixfmt}/bin/nixfmt" }), - require("null-ls").builtins.formatting.rustfmt.with({ command = "${pkgs.rustfmt}/bin/rustfmt" }), - require("null-ls").builtins.diagnostics.shellcheck.with({ command = "${pkgs.shellcheck}/bin/shellcheck" }), - require("null-ls").builtins.formatting.shfmt.with({ - command = "${pkgs.shfmt}/bin/shfmt", - extra_args = { "-i", "4", "-ci" }, - }), - require("null-ls").builtins.formatting.terraform_fmt.with({ - command = "${pkgs.terraform}/bin/terraform", - extra_filetypes = { "hcl" }, - }), - }, + use.lspconfig.terraformls.setup = dsl.callWith { + cmd = [ "${pkgs.terraform-ls}/bin/terraform-ls" "serve" ]; + }; - on_attach = function(client, bufnr) - if client.supports_method("textDocument/formatting") then - -- Auto-format on save - vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr }) - vim.api.nvim_create_autocmd("BufWritePre", { - group = augroup, - buffer = bufnr, - callback = function() - vim.lsp.buf.format({ bufnr = bufnr }) - end, - }) - -- Use internal formatting for bindings like gq. - vim.api.nvim_create_autocmd("LspAttach", { - callback = function(args) - vim.bo[args.buf].formatexpr = nil - end, - }) - end - end, - }) - ''; + vim.api.nvim_create_augroup = dsl.callWith [ "LspFormatting" { } ]; + + lua = '' + ${builtins.readFile ./lsp.lua} + + -- Prevent infinite log size (change this when debugging) + vim.lsp.set_log_level("off") + + require("null-ls").setup({ + sources = { + require("null-ls").builtins.formatting.stylua.with({ command = "${pkgs.stylua}/bin/stylua" }), + require("null-ls").builtins.formatting.black.with({ command = "${pkgs.black}/bin/black" }), + require("null-ls").builtins.diagnostics.ruff.with({ command = "${pkgs.ruff}/bin/ruff" }), + require("null-ls").builtins.formatting.fish_indent.with({ command = "${pkgs.fish}/bin/fish_indent" }), + require("null-ls").builtins.formatting.nixfmt.with({ command = "${pkgs.nixfmt}/bin/nixfmt" }), + require("null-ls").builtins.formatting.rustfmt.with({ command = "${pkgs.rustfmt}/bin/rustfmt" }), + require("null-ls").builtins.diagnostics.shellcheck.with({ command = "${pkgs.shellcheck}/bin/shellcheck" }), + require("null-ls").builtins.formatting.shfmt.with({ + command = "${pkgs.shfmt}/bin/shfmt", + extra_args = { "-i", "4", "-ci" }, + }), + ${terraformFormat} + }, + + on_attach = function(client, bufnr) + if client.supports_method("textDocument/formatting") then + -- Auto-format on save + vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr }) + vim.api.nvim_create_autocmd("BufWritePre", { + group = augroup, + buffer = bufnr, + callback = function() + vim.lsp.buf.format({ bufnr = bufnr }) + end, + }) + -- Use internal formatting for bindings like gq. + vim.api.nvim_create_autocmd("LspAttach", { + callback = function(args) + vim.bo[args.buf].formatexpr = nil + end, + }) + end + end, + }) + ''; + + }; } diff --git a/modules/common/neovim/config/tree.nix b/modules/common/neovim/config/tree.nix index 4a625d1..53e413b 100644 --- a/modules/common/neovim/config/tree.nix +++ b/modules/common/neovim/config/tree.nix @@ -63,7 +63,6 @@ ''; view = { # Set look and feel width = 30; - hide_root_folder = false; side = "left"; number = false; relativenumber = false; diff --git a/modules/common/neovim/default.nix b/modules/common/neovim/default.nix index e04f1d6..0dfa703 100644 --- a/modules/common/neovim/default.nix +++ b/modules/common/neovim/default.nix @@ -5,6 +5,7 @@ let neovim = import ./package { inherit pkgs; colors = config.theme.colors; + useTerraform = config.terraform.enable; }; in { diff --git a/modules/common/neovim/package/default.nix b/modules/common/neovim/package/default.nix index ae7f2d8..2fc5864 100644 --- a/modules/common/neovim/package/default.nix +++ b/modules/common/neovim/package/default.nix @@ -26,13 +26,13 @@ # ] ++ extraConfig; # } -{ pkgs, colors, ... }: +{ pkgs, colors, useTerraform ? false, ... }: # Comes from nix2vim overlay: # https://github.com/gytis-ivaskevicius/nix2vim/blob/master/lib/neovim-builder.nix pkgs.neovimBuilder { package = pkgs.neovim-unwrapped; - inherit colors; + inherit colors useTerraform; imports = [ ../config/align.nix ../config/bufferline.nix diff --git a/modules/common/programming/terraform.nix b/modules/common/programming/terraform.nix index 9a5f3e1..e156a34 100644 --- a/modules/common/programming/terraform.nix +++ b/modules/common/programming/terraform.nix @@ -3,6 +3,7 @@ options.terraform.enable = lib.mkEnableOption "Terraform tools."; config = lib.mkIf config.terraform.enable { + unfreePackages = [ "terraform" ]; home-manager.users.${config.user} = { programs.fish.shellAbbrs = {