style: Switch to Alejandra formatting

This commit is contained in:
punkfairie 2024-11-25 17:47:14 -08:00
parent 63a19ff3f9
commit 27ba9da6f3
Signed by: punkfairie
GPG key ID: A509E8F77FB9D696
5 changed files with 169 additions and 147 deletions

View file

@ -1,8 +1,7 @@
{
description = "MarleyVim";
outputs =
inputs:
outputs = inputs:
inputs.snowfall-lib.mkFlake {
inherit inputs;
@ -16,7 +15,7 @@
alias.packages.default = "neovim";
overlays = with inputs; [ nixvim.overlays.default ];
overlays = [inputs.nixvim.overlays.default];
outputs-builder = channels: {
formatter = channels.nixpkgs.nixfmt-rfc-style;

View file

@ -1,6 +1,6 @@
{ lib, ... }:
let
inherit (lib)
{lib, ...}: let
inherit
(lib)
map
mapAttrsToList
toUpper
@ -8,8 +8,7 @@ let
mapCartesianProduct
toLower
;
in
{
in {
globals = {
mapleader = " ";
maplocalleader = "\\";
@ -17,7 +16,8 @@ in
keymaps =
# Disable Arrow Key Movement - - - - - - - - - - - - - - - - - - - - - - - -
(map
(
map
(d: {
mode = [
"i"
@ -33,9 +33,9 @@ in
"<Right>"
]
)
# Better Up/Down - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
++ (mapAttrsToList
++ (
mapAttrsToList
(d: k: {
mode = [
"n"
@ -54,16 +54,17 @@ in
Up = "k";
}
)
# Resize Windows - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
++ (mapAttrsToList
++ (
mapAttrsToList
(
k: d:
let
s = if (d == "Increase") then "+" else "-";
in
{
mode = [ "n" ];
k: d: let
s =
if (d == "Increase")
then "+"
else "-";
in {
mode = ["n"];
key = "<C-${k}>";
action = "<cmd>resize ${s}4<cr>";
options = {
@ -78,17 +79,15 @@ in
Right = "Increase";
}
)
# Buffers - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
++ (mapAttrsToList
++ (
mapAttrsToList
(
k: d:
let
k: d: let
# previous -> Prev
prettyDir = (toUpper (substring 0 1 d)) + (substring 1 3 d);
in
{
mode = [ "n" ];
in {
mode = ["n"];
key = k;
action = "<cmd>b${d}<cr>";
options = {
@ -103,10 +102,9 @@ in
"]b" = "next";
}
)
++ [
{
mode = [ "n" ];
mode = ["n"];
key = "<leader>bD";
action = "<cmd>bd<cr>";
options = {
@ -114,7 +112,6 @@ in
};
}
]
# Clear Search/Diff Update/Redraw - - - - - - - - - - - - - - - - - - - - -
++ [
{
@ -130,7 +127,7 @@ in
}
{
mode = [ "n" ];
mode = ["n"];
key = "<leader>ur";
action = "<cmd>nohlsearch<bar>diffupdate<bar>normal! <C-l><cr>";
options = {
@ -138,18 +135,28 @@ in
};
}
]
# Better n & N - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
++ (mapCartesianProduct
++ (
mapCartesianProduct
(
{ m, d }:
let
nn = if (d == "Next") then "Nn" else "nN";
zv = if (m == "n") then ".'zv'" else "";
in
{
mode = [ m ];
key = if (d == "Next") then "n" else "N";
m,
d,
}: let
nn =
if (d == "Next")
then "Nn"
else "nN";
zv =
if (m == "n")
then ".'zv'"
else "";
in {
mode = [m];
key =
if (d == "Next")
then "n"
else "N";
action = "'${nn}'[v:searchforward]${zv}";
options = {
desc = "${d} Search Result";
@ -169,11 +176,11 @@ in
];
}
)
# Undo Break-Points - - - - - - - - - - - - - - - - - - - - - - - - - - - -
++ (map
++ (
map
(c: {
mode = [ "i" ];
mode = ["i"];
key = c;
action = "${c}<c-g>u";
})
@ -183,12 +190,11 @@ in
";"
]
)
# Search Docs (keywordprog) - - - - - - - - - - - - - - - - - - - - - - - -
# https://til.codeinthehole.com/posts/about-how-to-use-keywordprg-effectively/
++ [
{
mode = [ "n" ];
mode = ["n"];
key = "<leader>K";
action = "<cmd>norm! K<cr>";
options = {
@ -196,11 +202,11 @@ in
};
}
]
# Better Indenting - - - - - - - - - - - - - - - - - - - - - - - - - - - -
++ (map
++ (
map
(c: {
mode = [ "v" ];
mode = ["v"];
key = c;
action = "${c}gv";
})
@ -209,11 +215,11 @@ in
">"
]
)
# Commenting - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
++ (mapAttrsToList
++ (
mapAttrsToList
(k: d: {
mode = [ "n" ];
mode = ["n"];
key = "gc${k}";
action = "${k}<esc>Vcx<esc><cmd>normal gcc<cr>fxa<bs>";
options = {
@ -225,11 +231,10 @@ in
O = "Above";
}
)
# New File - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
++ [
{
mode = [ "n" ];
mode = ["n"];
key = "<leader>fn";
action = "<cmd>enew<cr>";
options = {
@ -237,11 +242,10 @@ in
};
}
]
# Locations/Quickfixes - - - - - - - - - - - - - - - - - - - - - - - - - - -
++ [
{
mode = [ "n" ];
mode = ["n"];
key = "<leader>xl";
action = "<cmd>lopen<cr>";
options = {
@ -250,7 +254,7 @@ in
}
{
mode = [ "n" ];
mode = ["n"];
key = "<leader>xq";
action = "<cmd>copen<cr>";
options = {
@ -258,15 +262,13 @@ in
};
}
]
++ (mapAttrsToList
++ (
mapAttrsToList
(
k: d:
let
k: d: let
cmd = substring 0 4 (toLower d);
in
{
mode = [ "n" ];
in {
mode = ["n"];
key = "${k}q";
action = "<cmd>c${cmd}<cr>";
options = {
@ -279,24 +281,26 @@ in
"]" = "Next";
}
)
# Diagnostics - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
++ [
{
mode = [ "n" ];
mode = ["n"];
key = "<leader>cd";
action.__raw = # lua
action.__raw =
# lua
"function() vim.diagnostic.open_float() end";
options = {
desc = "Line Diagnostics";
};
}
]
++ (mapCartesianProduct
++ (
mapCartesianProduct
(
{ dir, key }:
let
{
dir,
key,
}: let
sevs = {
d = {
key = "nil";
@ -314,11 +318,15 @@ in
cmd = toLower dir;
sev = sevs."${key}".key;
in
{
mode = [ "n" ];
key = "${if (dir == "Next") then "]" else "["}${key}";
action.__raw = # lua
in {
mode = ["n"];
key = "${
if (dir == "Next")
then "]"
else "["
}${key}";
action.__raw =
# lua
"function() vim.diagnostic.goto_${cmd}({ severity = ${sev} }) end";
options = {
desc = "${dir} ${sevs."${key}".desc}";
@ -337,11 +345,10 @@ in
];
}
)
# Quit - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
++ [
{
mode = [ "n" ];
mode = ["n"];
key = "<leader>qq";
action = "<cmd>qa<cr>";
options = {
@ -349,24 +356,23 @@ in
};
}
]
# Inspect - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
++ [
{
mode = [ "n" ];
mode = ["n"];
key = "<leader>ui";
action.__raw = # lua
action.__raw =
# lua
"vim.show_pos";
options = {
desc = "Inspect Position";
};
}
]
# Window Management - - - - - - - - - - - - - - - - - - - - - - - - - - - -
++ [
{
mode = [ "n" ];
mode = ["n"];
key = "<leader>w";
action = "<C-w>";
options = {
@ -376,7 +382,7 @@ in
}
{
mode = [ "n" ];
mode = ["n"];
key = "<leader>-";
action = "<C-w>s";
options = {
@ -386,7 +392,7 @@ in
}
{
mode = [ "n" ];
mode = ["n"];
key = "<leader>|";
action = "<C-w>v";
options = {
@ -396,7 +402,7 @@ in
}
{
mode = [ "n" ];
mode = ["n"];
key = "<leader>wd";
action = "<C-w>c";
options = {
@ -404,17 +410,19 @@ in
remap = true;
};
}
]
# Tab Management - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
++ (mapAttrsToList
++ (
mapAttrsToList
(k: a: {
mode = [ "n" ];
mode = ["n"];
key = "<leader><tab>${k}";
action = "<cmd>tab${toLower a}<cr>";
options = {
desc = if (a == "Only") then "Close Other Tabs" else "${a} Tab";
desc =
if (a == "Only")
then "Close Other Tabs"
else "${a} Tab";
};
})
{

View file

@ -1,6 +1,9 @@
{ pkgs, helpers, ... }:
{
extraPackages = [ pkgs.ripgrep ];
pkgs,
helpers,
...
}: {
extraPackages = [pkgs.ripgrep];
opts = {
# Relative line numbers.
@ -44,8 +47,8 @@
# Completion.
completeopt = [
"menu"
"menuone"
"menu"
"menuone"
"noselect"
"noinsert"
];
@ -92,7 +95,9 @@
# Only set clipboard if not in SSH, to make sure the OSC 52
# integration works automatically.
clipboard = helpers.mkRaw # lua
clipboard =
helpers.mkRaw # lua
''
vim.env.SSH_TTY and "" or "unnamedplus"
'';
@ -128,19 +133,20 @@
sidescrolloff = 8;
# Languages to use for spelling suggestions.
spelllang = [ "en" ];
spelllang = ["en"];
# Allow cursor to move where there is no text in visual block mode.
virtualedit = "block";
# Command mode completion mode.
wildmode = [ "longest:full" "full" ];
wildmode = ["longest:full" "full"];
# Min window width when splitting.
winminwidth = 5;
};
extraConfigLua = # lua
extraConfigLua =
# lua
''
-- Disable messages.
vim.opt.shortmess:append({ W = true, I = true, c = true, C = true })

View file

@ -1,6 +1,5 @@
{ pkgs, ... }:
{
extraPackages = [ pkgs.lazygit ];
{pkgs, ...}: {
extraPackages = [pkgs.lazygit];
plugins.snacks = {
enable = true;
@ -16,9 +15,10 @@
keymaps = [
{
mode = [ "n" ];
mode = ["n"];
key = "<leader>un";
action.__raw = # lua
action.__raw =
# lua
"function() Snacks.notifier.hide() end";
options = {
desc = "Dismiss All Notifications";
@ -26,9 +26,10 @@
}
{
mode = [ "n" ];
mode = ["n"];
key = "<leader>bd";
action.__raw = # lua
action.__raw =
# lua
"function() Snacks.bufdelete() end";
options = {
desc = "Delete Buffer";
@ -36,9 +37,10 @@
}
{
mode = [ "n" ];
mode = ["n"];
key = "<leader>bo";
action.__raw = # lua
action.__raw =
# lua
"function() Snacks.bufdelete.other() end";
options = {
desc = "Delete Other Buffers";
@ -47,9 +49,10 @@
# LazyGit - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
{
mode = [ "n" ];
mode = ["n"];
key = "<leader>gg";
action.__raw = # lua
action.__raw =
# lua
"function() Snacks.lazygit() end";
options = {
desc = "Lazygit";
@ -57,9 +60,10 @@
}
{
mode = [ "n" ];
mode = ["n"];
key = "<leader>gf";
action.__raw = # lua
action.__raw =
# lua
"function() Snacks.lazygit.log_file() end";
options = {
desc = "Lazygit Current File History";
@ -67,9 +71,10 @@
}
{
mode = [ "n" ];
mode = ["n"];
key = "<leader>gl";
action.__raw = # lua
action.__raw =
# lua
"function() Snacks.lazygit.log() end";
options = {
desc = "Lazygit Log";
@ -78,9 +83,10 @@
# Git - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
{
mode = [ "n" ];
mode = ["n"];
key = "<leader>gb";
action.__raw = # lua
action.__raw =
# lua
"function() Snacks.git.blame_line() end";
options = {
desc = "Gib Blame Line";
@ -93,7 +99,8 @@
"x"
];
key = "<leader>gB";
action.__raw = # lua
action.__raw =
# lua
"function() Snacks.gitbrowse() end";
options = {
desc = "Git Browse";
@ -102,7 +109,8 @@
];
# Toggles - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
extraConfigLua = # lua
extraConfigLua =
# lua
''
---@param buf? number
function format_enabled(buf)

View file

@ -1,36 +1,35 @@
{ lib
, pkgs
, inputs
, neovim-settings ? { }
, neovim-config ? { }
, ...
}:
let
{
lib,
pkgs,
inputs,
neovim-settings ? {},
neovim-config ? {},
...
}: let
raw-modules = lib.snowfall.fs.get-default-nix-files-recursive (
lib.snowfall.fs.get-file "/modules/nixvim"
);
wrapped-modules = builtins.map
wrapped-modules =
builtins.map
(
raw-module:
args@{ ... }:
let
raw-module: args: let
module = import raw-module;
result =
if builtins.isFunction module then
if builtins.isFunction module
then
module
(
args
// {
# NOTE: nixvim doesn't allow for these to be customized so we must work around the
# module system here...
inherit lib pkgs;
}
)
else
module;
(
args
// {
# NOTE: nixvim doesn't allow for these to be customized so we must work around the
# module system here...
inherit lib pkgs;
}
)
else module;
in
result // { _file = raw-module; }
result // {_file = raw-module;}
)
raw-modules;
@ -54,12 +53,14 @@ let
};
neovim = raw-neovim.overrideAttrs (attrs: {
meta = attrs.meta // {
# NOTE: The default platforms specified aren't actually all
# supported by nixvim. Instead, only support the ones that can build with
# the module system.
platforms = builtins.attrNames inputs.nixvim.legacyPackages;
};
meta =
attrs.meta
// {
# NOTE: The default platforms specified aren't actually all
# supported by nixvim. Instead, only support the ones that can build with
# the module system.
platforms = builtins.attrNames inputs.nixvim.legacyPackages;
};
});
in
neovim
neovim