From 59189d88dbebc19cde3d1472f4e83b572107a1ed Mon Sep 17 00:00:00 2001 From: Youwen Wu Date: Mon, 2 Sep 2024 18:28:53 -0700 Subject: [PATCH] chore: switch to nixfmt-rfc-style --- config/default.nix | 9 ++++-- config/keymaps.nix | 20 ++++++++++--- config/plugins/cmp.nix | 28 +++++++++++++----- config/plugins/default.nix | 12 +++++++- config/plugins/formatters.nix | 31 +++++++++---------- config/plugins/lsps.nix | 3 +- config/plugins/mini.nix | 16 +++++----- config/plugins/qol.nix | 3 +- flake.nix | 56 +++++++++++++++++++---------------- 9 files changed, 113 insertions(+), 65 deletions(-) diff --git a/config/default.nix b/config/default.nix index 76dd2bd..05ef4c9 100644 --- a/config/default.nix +++ b/config/default.nix @@ -1,5 +1,10 @@ -{pkgs, ...}: { - imports = [./plugins ./keymaps.nix ./init.nix]; +{ pkgs, ... }: +{ + imports = [ + ./plugins + ./keymaps.nix + ./init.nix + ]; viAlias = true; vimAlias = true; withNodeJs = true; diff --git a/config/keymaps.nix b/config/keymaps.nix index 44fcae1..3e43b35 100644 --- a/config/keymaps.nix +++ b/config/keymaps.nix @@ -278,22 +278,34 @@ { action = "(YankyPutAfter)"; key = "p"; - mode = ["n" "x"]; + mode = [ + "n" + "x" + ]; } { action = "(YankyPutBefore)"; key = "P"; - mode = ["n" "x"]; + mode = [ + "n" + "x" + ]; } { action = "(YankyGPutAfter)"; key = "gp"; - mode = ["n" "x"]; + mode = [ + "n" + "x" + ]; } { action = "(YankyGPutBefore)"; key = "gP"; - mode = ["n" "x"]; + mode = [ + "n" + "x" + ]; } { action = ":Telescope yank_history"; diff --git a/config/plugins/cmp.nix b/config/plugins/cmp.nix index 4ccbde1..2da6741 100644 --- a/config/plugins/cmp.nix +++ b/config/plugins/cmp.nix @@ -5,17 +5,27 @@ enable = true; settings = { autoEnableSources = true; - experimental = {ghost_text = true;}; + experimental = { + ghost_text = true; + }; performance = { debounce = 60; fetchingTimeout = 200; maxViewEntries = 30; }; - snippet = {expand = "luasnip";}; - formatting = {fields = ["kind" "abbr" "menu"];}; + snippet = { + expand = "luasnip"; + }; + formatting = { + fields = [ + "kind" + "abbr" + "menu" + ]; + }; sources = [ - {name = "nvim_lsp";} - {name = "emoji";} + { name = "nvim_lsp"; } + { name = "emoji"; } { name = "buffer"; # text within current buffer option.get_bufnrs.__raw = "vim.api.nvim_list_bufs"; @@ -33,8 +43,12 @@ ]; window = { - completion = {border = "solid";}; - documentation = {border = "solid";}; + completion = { + border = "solid"; + }; + documentation = { + border = "solid"; + }; }; mapping = { diff --git a/config/plugins/default.nix b/config/plugins/default.nix index 7af3312..19d51a9 100644 --- a/config/plugins/default.nix +++ b/config/plugins/default.nix @@ -1,3 +1,13 @@ { - imports = [./lsps.nix ./setup.nix ./formatters.nix ./cmp.nix ./qol.nix ./mini.nix ./misc.nix ./navigation.nix ./treesitter.nix]; + imports = [ + ./lsps.nix + ./setup.nix + ./formatters.nix + ./cmp.nix + ./qol.nix + ./mini.nix + ./misc.nix + ./navigation.nix + ./treesitter.nix + ]; } diff --git a/config/plugins/formatters.nix b/config/plugins/formatters.nix index 2ea6c7e..7f6e129 100644 --- a/config/plugins/formatters.nix +++ b/config/plugins/formatters.nix @@ -1,5 +1,6 @@ # Code formatters -{pkgs, ...}: { +{ pkgs, ... }: +{ extraPackages = with pkgs; [ # TS/JS, Markdown, TOML, JSON, etc nodePackages.prettier @@ -31,21 +32,21 @@ lspFallback = true; }; formatters_by_ft = { - lua = ["stylua"]; - python = ["black"]; - nix = ["nixfmt"]; - svelte = ["prettier"]; - rust = ["rustfmt"]; - haskell = ["fourmolu"]; - toml = ["prettier"]; - json = ["prettier"]; - markdown = ["prettier"]; - yaml = ["prettier"]; - html = ["prettier"]; - javascript = ["prettier"]; - typescript = ["prettier"]; + lua = [ "stylua" ]; + python = [ "black" ]; + nix = [ "nixfmt" ]; + svelte = [ "prettier" ]; + rust = [ "rustfmt" ]; + haskell = [ "fourmolu" ]; + toml = [ "prettier" ]; + json = [ "prettier" ]; + markdown = [ "prettier" ]; + yaml = [ "prettier" ]; + html = [ "prettier" ]; + javascript = [ "prettier" ]; + typescript = [ "prettier" ]; # "*" = ["codespell"]; - "_" = ["trim_whitespace"]; + "_" = [ "trim_whitespace" ]; }; }; }; diff --git a/config/plugins/lsps.nix b/config/plugins/lsps.nix index 569e8bf..f766cc5 100644 --- a/config/plugins/lsps.nix +++ b/config/plugins/lsps.nix @@ -1,5 +1,6 @@ # LSP setup -{pkgs, ...}: { +{ pkgs, ... }: +{ extraPackages = with pkgs; [ rust-analyzer lua-language-server diff --git a/config/plugins/mini.nix b/config/plugins/mini.nix index 81c9425..3a07d44 100644 --- a/config/plugins/mini.nix +++ b/config/plugins/mini.nix @@ -3,14 +3,14 @@ plugins.mini = { enable = true; modules = { - surround = {}; - ai = {}; - hipatterns = {}; - notify = {}; - tabline = {}; - trailspace = {}; - cursorword = {}; - bracketed = {}; + surround = { }; + ai = { }; + hipatterns = { }; + notify = { }; + tabline = { }; + trailspace = { }; + cursorword = { }; + bracketed = { }; }; }; } diff --git a/config/plugins/qol.nix b/config/plugins/qol.nix index 102988d..8f96f35 100644 --- a/config/plugins/qol.nix +++ b/config/plugins/qol.nix @@ -1,5 +1,6 @@ # Quality of life plugins -{pkgs, ...}: { +{ pkgs, ... }: +{ extraPackages = with pkgs; [ ripgrep yazi diff --git a/flake.nix b/flake.nix index 5fbdcb1..7824e40 100644 --- a/flake.nix +++ b/flake.nix @@ -8,12 +8,13 @@ flake-parts.url = "github:hercules-ci/flake-parts"; }; - outputs = { - nixvim, - flake-parts, - ... - } @ inputs: - flake-parts.lib.mkFlake {inherit inputs;} { + outputs = + { + nixvim, + flake-parts, + ... + }@inputs: + flake-parts.lib.mkFlake { inherit inputs; } { systems = [ "x86_64-linux" "aarch64-linux" @@ -21,27 +22,30 @@ "aarch64-darwin" ]; - perSystem = { - pkgs, - system, - ... - }: let - nixvimLib = nixvim.lib.${system}; - nixvim' = nixvim.legacyPackages.${system}; - nixvimModule = { - inherit pkgs; - module = import ./config; - }; - nvim = nixvim'.makeNixvimWithModule nixvimModule; - in { - formatter = pkgs.alejandra; - checks = { - default = nixvimLib.check.mkTestDerivationFromNixvimModule nixvimModule; - }; + perSystem = + { + pkgs, + system, + ... + }: + let + nixvimLib = nixvim.lib.${system}; + nixvim' = nixvim.legacyPackages.${system}; + nixvimModule = { + inherit pkgs; + module = import ./config; + }; + nvim = nixvim'.makeNixvimWithModule nixvimModule; + in + { + formatter = pkgs.nixfmt-rfc-style; + checks = { + default = nixvimLib.check.mkTestDerivationFromNixvimModule nixvimModule; + }; - packages = { - default = nvim; + packages = { + default = nvim; + }; }; - }; }; }