diff --git a/config/default.nix b/config/default.nix index 23e898e..4b7800a 100644 --- a/config/default.nix +++ b/config/default.nix @@ -25,6 +25,7 @@ ./plugins/ui/lualine.nix # LSP and formatting + ./plugins/lsp/conform.nix ./plugins/lsp/lsp.nix # Git diff --git a/config/plugins/lsp/conform.nix b/config/plugins/lsp/conform.nix new file mode 100644 index 0000000..90b1dd0 --- /dev/null +++ b/config/plugins/lsp/conform.nix @@ -0,0 +1,26 @@ +{pkgs, ...}: + +{ + plugins.conform-nvim = { + enable = true; + + # Run the formatter on file save. + formatOnSave = { + lspFallback = true; + timeoutMs = 500; + }; + # Receive notificaton when a formatter errors. + notifyOnError = true; + + # Map of filetype to formatters. + formattersByFt = { + c = ["clang-format"]; + nix = ["alejandra"]; + }; + }; + + # Install our formatters. + extraPackages = with pkgs; [ + alejandra + ]; +}