diff --git a/README.md b/README.md index 9dc7a89..7412919 100644 --- a/README.md +++ b/README.md @@ -28,6 +28,7 @@ The default configuration performs editing without settings for any particular l - Go `nix run github:fred-drake/neovim#golang` - Python `nix run github:fred-drake/neovim#python` - Javascript `nix run github:fred-drake/neovim#javascript` +- Infrastructure as Code `nix run github:fred-drake/neovim#ia ### Install Multiple Configurations @@ -65,8 +66,8 @@ And add it to your home-manager imports: | YAML | yamlfmt | yamllint, yamlls | | default | | CSS | prettier | | | default | | HTML | prettier | | | default | -| Javascript | prettier | | | default | -| Typescript | prettier | | | default | +| Javascript | prettier | | | javascript | +| Typescript | prettier | | | javascript | | JSON | prettier | jsonls | | default | | Markdown | prettier | marksman | | default | | Ruby | rubyfmt | | | default | @@ -77,3 +78,8 @@ And add it to your home-manager imports: | Python | black, isort | flake8, jedi, pylint, rope, mccabe | dap-python | python | | Rust | rustfmt | clippy | lldb | rust | | Node | prettier | tsserver | vscode-js-debug | javascript | +| Ansible | yamlfmt | ansiblels | | iac | +| Terraform | tofu_fmt | terraformls | | iac | +| Nginx | | nginx-language-server | | iac | +| Helm | | helm-ls | | iac | +| Dockerfile | | dockerls | | iac | diff --git a/config/iac/default.nix b/config/iac/default.nix new file mode 100644 index 0000000..3d7eebc --- /dev/null +++ b/config/iac/default.nix @@ -0,0 +1,16 @@ +let + # Read all files in the current directory + files = builtins.readDir ./.; + + # Filter out default.nix and non-.nix files + nixFiles = builtins.filter + (name: name != "default.nix" && builtins.match ".*\\.nix" name != null) + (builtins.attrNames files); + + # Create a list of import statements + imports = map (name: ./. + "/${name}") nixFiles; +in { + # Import all configuration modules automatically + imports = imports; +} + diff --git a/config/iac/language.nix b/config/iac/language.nix new file mode 100644 index 0000000..5037fde --- /dev/null +++ b/config/iac/language.nix @@ -0,0 +1,33 @@ +{pkgs, ...}: { + plugins = { + conform-nvim = { + enable = true; + settings = { + formatters_by_ft = { + terraform = ["tofu_fmt"]; + tf = ["tofu_fmt"]; + }; + }; + }; + lsp.servers = { + ansiblels.enable = true; + dockerls.enable = true; + helm-ls.enable = true; + nginx-language-server.enable = true; + terraformls.enable = true; + }; + }; + + extraPlugins = [ + # Set ansible.yaml files + (pkgs.vimUtils.buildVimPlugin { + name = "nvim-ansible"; + src = pkgs.fetchFromGitHub { + owner = "mfussenegger"; + repo = "nvim-ansible"; + rev = "9c3b4a771b8c8d7b4f2171466464d978cb3846f7"; + hash = "sha256-N1yOL77WpP66A2zrKxi7IOO5uRzAaeGa0Y/yWaIFiws="; + }; + }) + ]; +} diff --git a/flake.nix b/flake.nix index 46da18f..a457ce7 100644 --- a/flake.nix +++ b/flake.nix @@ -89,6 +89,17 @@ }; extraSpecialArgs = {}; }; + iacNixvimModule = { + inherit pkgs; + module = {pkgs, ...}: { + imports = [ + ./config + ./config/iac + ]; + extraPackages = with pkgs; [sops ansible-lint]; + }; + extraSpecialArgs = {}; + }; pkgs = import inputs.nixpkgs { inherit system overlays; config.allowUnfree = true; @@ -99,6 +110,7 @@ goNvim = nixvim'.makeNixvimWithModule goNixvimModule; pythonNvim = nixvim'.makeNixvimWithModule pythonNixvimModule; javascriptNvim = nixvim'.makeNixvimWithModule javascriptNixvimModule; + iacNvim = nixvim'.makeNixvimWithModule iacNixvimModule; in { checks = { # Run `nix flake check .` to verify that your config is not broken @@ -117,6 +129,8 @@ python = pythonNvim; # Lets you run `nix run .#javascript` to start nixvim with JS/TS configuration javascript = javascriptNvim; + # Lets you run `nix run .#javascript` to start nixvim with IaC configuration + iac = iacNvim; }; }; };