home/nvim: switch to nixvim

This commit is contained in:
chayleaf 2024-10-09 23:57:20 +07:00
parent 21ab05153f
commit 6f9d877667
Signed by: chayleaf
GPG key ID: 78171AD46227E68E
3 changed files with 382 additions and 104 deletions

View file

@ -165,6 +165,27 @@
"type": "github" "type": "github"
} }
}, },
"devshell": {
"inputs": {
"nixpkgs": [
"nixvim",
"nixpkgs"
]
},
"locked": {
"lastModified": 1728330715,
"narHash": "sha256-xRJ2nPOXb//u1jaBnDP56M7v5ldavjbtR6lfGqSvcKg=",
"owner": "numtide",
"repo": "devshell",
"rev": "dd6b80932022cea34a019e2bb32f6fa9e494dfef",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "devshell",
"type": "github"
}
},
"disko": { "disko": {
"inputs": { "inputs": {
"nixpkgs": [ "nixpkgs": [
@ -264,6 +285,20 @@
"type": "github" "type": "github"
} }
}, },
"flake-compat_5": {
"locked": {
"lastModified": 1696426674,
"narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=",
"rev": "0f9255e01c2351cc7d116c072cb317785dd33b33",
"revCount": 57,
"type": "tarball",
"url": "https://api.flakehub.com/f/pinned/edolstra/flake-compat/1.0.1/018afb31-abd1-7bff-a5e4-cff7e18efb7a/source.tar.gz"
},
"original": {
"type": "tarball",
"url": "https://flakehub.com/f/edolstra/flake-compat/1.tar.gz"
}
},
"flake-parts": { "flake-parts": {
"inputs": { "inputs": {
"nixpkgs-lib": [ "nixpkgs-lib": [
@ -303,10 +338,49 @@
"type": "github" "type": "github"
} }
}, },
"flake-parts_3": {
"inputs": {
"nixpkgs-lib": [
"nixvim",
"nixpkgs"
]
},
"locked": {
"lastModified": 1727826117,
"narHash": "sha256-K5ZLCyfO/Zj9mPFldf3iwS6oZStJcU4tSpiXTMYaaL0=",
"owner": "hercules-ci",
"repo": "flake-parts",
"rev": "3d04084d54bedc3d6b8b736c70ef449225c361b1",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "flake-parts",
"type": "github"
}
},
"flake-utils": { "flake-utils": {
"inputs": { "inputs": {
"systems": "systems_2" "systems": "systems_2"
}, },
"locked": {
"lastModified": 1726560853,
"narHash": "sha256-X6rJYSESBVr3hBoH0WbKE5KvhPU5bloyZ2L4K60/fPQ=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "c1dfcf08411b08f6b8615f7d8971a2bfa81d5e8a",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"flake-utils_2": {
"inputs": {
"systems": "systems_3"
},
"locked": { "locked": {
"lastModified": 1710146030, "lastModified": 1710146030,
"narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=",
@ -321,6 +395,58 @@
"type": "github" "type": "github"
} }
}, },
"git-hooks": {
"inputs": {
"flake-compat": [
"nixvim",
"flake-compat"
],
"gitignore": "gitignore",
"nixpkgs": [
"nixvim",
"nixpkgs"
],
"nixpkgs-stable": [
"nixvim",
"nixpkgs"
]
},
"locked": {
"lastModified": 1728092656,
"narHash": "sha256-eMeCTJZ5xBeQ0f9Os7K8DThNVSo9gy4umZLDfF5q6OM=",
"owner": "cachix",
"repo": "git-hooks.nix",
"rev": "1211305a5b237771e13fcca0c51e60ad47326a9a",
"type": "github"
},
"original": {
"owner": "cachix",
"repo": "git-hooks.nix",
"type": "github"
}
},
"gitignore": {
"inputs": {
"nixpkgs": [
"nixvim",
"git-hooks",
"nixpkgs"
]
},
"locked": {
"lastModified": 1709087332,
"narHash": "sha256-HG2cCnktfHsKV0s4XW83gU3F57gaTljL9KNSuG6bnQs=",
"owner": "hercules-ci",
"repo": "gitignore.nix",
"rev": "637db329424fd7e46cf4185293b9cc8c88c95394",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "gitignore.nix",
"type": "github"
}
},
"home-manager": { "home-manager": {
"inputs": { "inputs": {
"nixpkgs": [ "nixpkgs": [
@ -341,6 +467,27 @@
"type": "github" "type": "github"
} }
}, },
"home-manager_2": {
"inputs": {
"nixpkgs": [
"nixvim",
"nixpkgs"
]
},
"locked": {
"lastModified": 1728337164,
"narHash": "sha256-VdRTjJFyq4Q9U7Z/UoC2Q5jK8vSo6E86lHc2OanXtvc=",
"owner": "nix-community",
"repo": "home-manager",
"rev": "038630363e7de57c36c417fd2f5d7c14773403e4",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "home-manager",
"type": "github"
}
},
"impermanence": { "impermanence": {
"locked": { "locked": {
"lastModified": 1719091691, "lastModified": 1719091691,
@ -427,6 +574,27 @@
"type": "github" "type": "github"
} }
}, },
"nix-darwin_2": {
"inputs": {
"nixpkgs": [
"nixvim",
"nixpkgs"
]
},
"locked": {
"lastModified": 1728385805,
"narHash": "sha256-mUd38b0vhB7yzgAjNOaFz7VY9xIVzlbn3P2wjGBcVV0=",
"owner": "lnl7",
"repo": "nix-darwin",
"rev": "48b50b3b137be5cfb9f4d006835ce7c3fe558ccc",
"type": "github"
},
"original": {
"owner": "lnl7",
"repo": "nix-darwin",
"type": "github"
}
},
"nix-gaming": { "nix-gaming": {
"inputs": { "inputs": {
"flake-parts": "flake-parts_2", "flake-parts": "flake-parts_2",
@ -649,6 +817,48 @@
"type": "github" "type": "github"
} }
}, },
"nixpkgs_4": {
"locked": {
"lastModified": 1728241625,
"narHash": "sha256-yumd4fBc/hi8a9QgA9IT8vlQuLZ2oqhkJXHPKxH/tRw=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "c31898adf5a8ed202ce5bea9f347b1c6871f32d1",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixvim": {
"inputs": {
"devshell": "devshell",
"flake-compat": "flake-compat_5",
"flake-parts": "flake-parts_3",
"git-hooks": "git-hooks",
"home-manager": "home-manager_2",
"nix-darwin": "nix-darwin_2",
"nixpkgs": "nixpkgs_4",
"nuschtosSearch": "nuschtosSearch",
"treefmt-nix": "treefmt-nix_2"
},
"locked": {
"lastModified": 1728485062,
"narHash": "sha256-+2e9hAM2GVDF3gywdQI/OA7s4f0Z9rvFuiVxePI41QM=",
"owner": "nix-community",
"repo": "nixvim",
"rev": "61ec39764fbe1e4f21cf801ea7b9209d527c8135",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "nixvim",
"type": "github"
}
},
"notlua": { "notlua": {
"inputs": { "inputs": {
"nixpkgs": [ "nixpkgs": [
@ -725,9 +935,31 @@
"type": "github" "type": "github"
} }
}, },
"osu-wine": { "nuschtosSearch": {
"inputs": { "inputs": {
"flake-utils": "flake-utils", "flake-utils": "flake-utils",
"nixpkgs": [
"nixvim",
"nixpkgs"
]
},
"locked": {
"lastModified": 1728423244,
"narHash": "sha256-+YwNsyIFj3dXyLVQd1ry4pCNmtOpbceKUrkNS8wp9Ho=",
"owner": "NuschtOS",
"repo": "search",
"rev": "f276cc3b391493ba3a8b30170776860f9520b7fa",
"type": "github"
},
"original": {
"owner": "NuschtOS",
"repo": "search",
"type": "github"
}
},
"osu-wine": {
"inputs": {
"flake-utils": "flake-utils_2",
"nixpkgs": [ "nixpkgs": [
"nixpkgs" "nixpkgs"
] ]
@ -761,6 +993,7 @@
"nixos-router": "nixos-router", "nixos-router": "nixos-router",
"nixpkgs": "nixpkgs_3", "nixpkgs": "nixpkgs_3",
"nixpkgs-kernel": "nixpkgs-kernel", "nixpkgs-kernel": "nixpkgs-kernel",
"nixvim": "nixvim",
"notlua": "notlua", "notlua": "notlua",
"notnft": "notnft", "notnft": "notnft",
"nur": "nur", "nur": "nur",
@ -865,6 +1098,21 @@
"type": "github" "type": "github"
} }
}, },
"systems_3": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
},
"treefmt-nix": { "treefmt-nix": {
"inputs": { "inputs": {
"nixpkgs": [ "nixpkgs": [
@ -886,6 +1134,27 @@
"type": "github" "type": "github"
} }
}, },
"treefmt-nix_2": {
"inputs": {
"nixpkgs": [
"nixvim",
"nixpkgs"
]
},
"locked": {
"lastModified": 1727984844,
"narHash": "sha256-xpRqITAoD8rHlXQafYZOLvUXCF6cnZkPfoq67ThN0Hc=",
"owner": "numtide",
"repo": "treefmt-nix",
"rev": "4446c7a6fc0775df028c5a3f6727945ba8400e64",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "treefmt-nix",
"type": "github"
}
},
"umu": { "umu": {
"inputs": { "inputs": {
"nixpkgs": [ "nixpkgs": [

View file

@ -5,6 +5,7 @@
nix-community-infra.url = "github:nix-community/infra"; nix-community-infra.url = "github:nix-community/infra";
nixpkgs-kernel.url = "github:NixOS/nixpkgs/a58bc8ad779655e790115244571758e8de055e3d"; nixpkgs-kernel.url = "github:NixOS/nixpkgs/a58bc8ad779655e790115244571758e8de055e3d";
nixpkgs.url = "github:chayleaf/nixpkgs/ci"; nixpkgs.url = "github:chayleaf/nixpkgs/ci";
nixvim.url = "github:nix-community/nixvim";
nixos-hardware.url = "github:NixOS/nixos-hardware"; nixos-hardware.url = "github:NixOS/nixos-hardware";
nix-index-database = { nix-index-database = {
url = "github:nix-community/nix-index-database"; url = "github:nix-community/nix-index-database";
@ -160,6 +161,7 @@
nixmsi = rec { nixmsi = rec {
system = "x86_64-linux"; system = "x86_64-linux";
modules = [ ./system/devices/msi-delta-15-workstation.nix ]; modules = [ ./system/devices/msi-delta-15-workstation.nix ];
home.common.modules = [ inputs.nixvim.homeManagerModules.default ];
home.common.extraSpecialArgs = { home.common.extraSpecialArgs = {
notlua = inputs.notlua.lib.${system}; notlua = inputs.notlua.lib.${system};
}; };
@ -168,6 +170,7 @@
phone = rec { phone = rec {
system = "aarch64-linux"; system = "aarch64-linux";
modules = [ ./system/devices/oneplus-6-phone.nix ]; modules = [ ./system/devices/oneplus-6-phone.nix ];
home.common.modules = [ inputs.nixvim.homeManagerModules.default ];
home.common.extraSpecialArgs = { home.common.extraSpecialArgs = {
notlua = inputs.notlua.lib.${system}; notlua = inputs.notlua.lib.${system};
}; };

View file

@ -13,8 +13,11 @@
*/ */
# welcome to my cursed DSL # welcome to my cursed DSL
programs.neovim = let programs.nixvim = let
notlua-nvim = notlua.neovim { inherit (config.programs.neovim) plugins extraLuaPackages; }; notlua-nvim = notlua.neovim {
plugins = config.programs.nixvim.extraPlugins;
inherit (config.programs.nixvim) extraLuaPackages;
};
inherit (notlua.keywords) inherit (notlua.keywords)
AND APPLY CALL DEFUN ELSE EQ GE IDX IF AND APPLY CALL DEFUN ELSE EQ GE IDX IF
LE LET LETREC MERGE OR PROP RETURN SET; LE LET LETREC MERGE OR PROP RETURN SET;
@ -68,100 +71,8 @@
which-key = REQ "which-key"; which-key = REQ "which-key";
luasnip = REQ "luasnip"; luasnip = REQ "luasnip";
in {
enable = true;
defaultEditor = true;
package = pkgs.neovim-unwrapped;
extraPackages = with pkgs; [
rust-analyzer
nodePackages_latest.bash-language-server shellcheck
nodePackages_latest.typescript-language-server
# nodePackages_latest.svelte-language-server
clang-tools_latest
nodePackages_latest.vscode-langservers-extracted
nil
marksman
nixfmt-rfc-style
taplo
ripgrep
(python3.withPackages (p: with p; [
python-lsp-server
python-lsp-black
pylsp-mypy
python-lsp-server.optional-dependencies.pyflakes
python-lsp-server.optional-dependencies.mccabe
python-lsp-server.optional-dependencies.pycodestyle
]))
];
# extraPython3Packages = pyPkgs: with pyPkgs; [
# ];
viAlias = true;
vimAlias = true;
vimdiffAlias = true;
extraLuaConfig = compile "main" [ plugins = let ps = pkgs.vimPlugins; in [
(kmSetNs {
"<C-X>" = {
rhs = DEFUN (vim.fn.system [ "chmod" "+x" (vim.fn.expand "%") ]);
desc = "chmod +x %";
};
})
(SET (vimg "vimsyn_embed") "l")
(LET (vim.api.nvim_create_augroup "nvimrc" { clear = true; }) (group:
lib.mapAttrsToList (k: v: vim.api.nvim_create_autocmd k { inherit group; callback = v; }) {
BufReadPre = DEFUN (SET vim.o.foldmethod "syntax");
BufEnter = { buf, ... }:
LET (vim.filetype.match { inherit buf; }) (filetype: [
(IF (APPLY OR (map (EQ filetype) [ "gitcommit" "markdown" "mail" ])) (
LET vim.o.colorcolumn (old_colorcolumn: [
(SET vim.o.colorcolumn "73")
(vim.api.nvim_create_autocmd "BufLeave" {
buffer = buf;
callback = DEFUN [
(SET vim.o.colorcolumn old_colorcolumn)
# return true = delete autocommand
(RETURN true)
];
})
])
))
(IF (APPLY OR (map (EQ filetype) [ "markdown" "mail" ])) (
(SET (IDX vim.bo buf).textwidth 72)
))
]);
BufWinEnter = { buf, ... }:
LET (vim.filetype.match { inherit buf; }) (filetype: [
(CALL (PROP vim.cmd "folddoc") "foldopen!")
(IF (EQ filetype "gitcommit") (
vim.cmd {
cmd = "normal"; bang = true;
args = [ "gg" ];
}
) ELSE (LET
(IDX (vim.api.nvim_buf_get_mark buf "\"") 1)
(vim.api.nvim_buf_line_count buf)
(pos: cnt:
IF (AND (GE pos 1) (LE pos cnt))
(vim.cmd {
cmd = "normal"; bang = true;
args = [ "g`\"" ];
})
/*ELIF*/ (GE pos 1)
(vim.cmd {
cmd = "normal"; bang = true;
args = [ "g$" ];
})
ELSE
(vim.cmd {
cmd = "normal"; bang = true;
args = [ "gg" ];
})
)))
]);
}
))
];
plugins = let ps = pkgs.vimPlugins; in map (x: if x?config && x?plugin then { type = "lua"; } // x else x) [
ps.vim-svelte ps.vim-svelte
# vim-nix isn't necessary for syntax highlighting, but it improves overall editing experience # vim-nix isn't necessary for syntax highlighting, but it improves overall editing experience
ps.vim-nix ps.vim-nix
@ -175,7 +86,7 @@
sha256 = "sha256-X2IgIjO5NNq7vJdl09hBY1TFqHlsfF1xfllKr4osILI="; sha256 = "sha256-X2IgIjO5NNq7vJdl09hBY1TFqHlsfF1xfllKr4osILI=";
}; };
}; };
config = compile "vscode_nvim" [ config = [
((REQ "vscode").setup { ((REQ "vscode").setup {
transparent = true; transparent = true;
color_overrides = { color_overrides = {
@ -199,9 +110,9 @@
}) })
]; } ]; }
{ plugin = ps.nvim-web-devicons; { plugin = ps.nvim-web-devicons;
config = compile "nvim_web_devicons" ((REQ "nvim-web-devicons").setup { }); } config = ((REQ "nvim-web-devicons").setup { }); }
{ plugin = ps.nvim-tree-lua; { plugin = ps.nvim-tree-lua;
config = compile "nvim_tree_lua" (LET (REQ "nvim-tree") (REQ "nvim-tree.api") (nvim-tree: nvim-tree-api: [ config = (LET (REQ "nvim-tree") (REQ "nvim-tree.api") (nvim-tree: nvim-tree-api: [
(SET (vimg "loaded_netrw") 1) (SET (vimg "loaded_netrw") 1)
(SET (vimg "loaded_netrwPlugin") 1) (SET (vimg "loaded_netrwPlugin") 1)
(SET vim.o.termguicolors true) (SET vim.o.termguicolors true)
@ -227,7 +138,7 @@
[ "" name ] [ "" name ]
[ "" name ] [ "" name ]
]); ]);
in compile "nvim_cmp" (LET (REQ "cmp") (REQ "lspkind") (cmp: lspkind: in (LET (REQ "cmp") (REQ "lspkind") (cmp: lspkind:
# call is required because cmp.setup is a table # call is required because cmp.setup is a table
cmp.setup { cmp.setup {
snippet = { snippet = {
@ -293,7 +204,7 @@
ps.cmp_luasnip ps.cmp_luasnip
ps.cmp-nvim-lsp ps.cmp-nvim-lsp
{ plugin = ps.nvim-autopairs; { plugin = ps.nvim-autopairs;
config = compile "nvim_autopairs" (LET config = (LET
(REQ "cmp") (REQ "nvim-autopairs.completion.cmp") (REQ "nvim-autopairs") (REQ "cmp") (REQ "nvim-autopairs.completion.cmp") (REQ "nvim-autopairs")
(cmp: cmp-autopairs: nvim-autopairs: (cmp: cmp-autopairs: nvim-autopairs:
[ [
@ -303,7 +214,7 @@
(cmp.event.on cmp.event "confirm_done" (cmp-autopairs.on_confirm_done { })) (cmp.event.on cmp.event "confirm_done" (cmp-autopairs.on_confirm_done { }))
])); } ])); }
{ plugin = ps.comment-nvim; { plugin = ps.comment-nvim;
config = compile "comment_nvim" [ config = [
((REQ "Comment").setup { }) ((REQ "Comment").setup { })
(kmSetNs { (kmSetNs {
"<space>/" = { "<space>/" = {
@ -320,7 +231,7 @@
}) })
]; } ]; }
{ plugin = ps.nvim-lspconfig; { plugin = ps.nvim-lspconfig;
config = compile "nvim_lspconfig" ( config = (
let lsp = name: builtins.seq let lsp = name: builtins.seq
# ensure an lsp exists (otherwise lspconfig will still create an empty config for some reason) # ensure an lsp exists (otherwise lspconfig will still create an empty config for some reason)
(REQ "lspconfig.server_configurations.${name}") (REQ "lspconfig.server_configurations.${name}")
@ -464,11 +375,106 @@
)) # END )) # END
]); } ]); }
{ plugin = ps.which-key-nvim; { plugin = ps.which-key-nvim;
config = compile "which_key_nvim" [ config = [
(SET vim.o.timeout true) (SET vim.o.timeout true)
(SET vim.o.timeoutlen 500) (SET vim.o.timeoutlen 500)
(which-key.setup { }) (which-key.setup { })
]; } ]; }
]; ];
in {
enable = true;
defaultEditor = true;
package = pkgs.neovim-unwrapped;
extraPackages = with pkgs; [
rust-analyzer
nodePackages_latest.bash-language-server shellcheck
nodePackages_latest.typescript-language-server
# nodePackages_latest.svelte-language-server
clang-tools_latest
nodePackages_latest.vscode-langservers-extracted
nil
marksman
nixfmt-rfc-style
taplo
ripgrep
(python3.withPackages (p: with p; [
python-lsp-server
python-lsp-black
pylsp-mypy
python-lsp-server.optional-dependencies.pyflakes
python-lsp-server.optional-dependencies.mccabe
python-lsp-server.optional-dependencies.pycodestyle
]))
];
# extraPython3Packages = pyPkgs: with pyPkgs; [
# ];
viAlias = true;
vimAlias = true;
vimdiffAlias = true;
extraConfigLua = compile "main" (
builtins.concatLists (map (x: if x?plugin then lib.toList x.config else [ ]) plugins) ++ [
(kmSetNs {
"<C-X>" = {
rhs = DEFUN (vim.fn.system [ "chmod" "+x" (vim.fn.expand "%") ]);
desc = "chmod +x %";
};
})
(SET (vimg "vimsyn_embed") "l")
(LET (vim.api.nvim_create_augroup "nvimrc" { clear = true; }) (group:
lib.mapAttrsToList (k: v: vim.api.nvim_create_autocmd k { inherit group; callback = v; }) {
BufReadPre = DEFUN (SET vim.o.foldmethod "syntax");
BufEnter = { buf, ... }:
LET (vim.filetype.match { inherit buf; }) (filetype: [
(IF (APPLY OR (map (EQ filetype) [ "gitcommit" "markdown" "mail" ])) (
LET vim.o.colorcolumn (old_colorcolumn: [
(SET vim.o.colorcolumn "73")
(vim.api.nvim_create_autocmd "BufLeave" {
buffer = buf;
callback = DEFUN [
(SET vim.o.colorcolumn old_colorcolumn)
# return true = delete autocommand
(RETURN true)
];
})
])
))
(IF (APPLY OR (map (EQ filetype) [ "markdown" "mail" ])) (
(SET (IDX vim.bo buf).textwidth 72)
))
]);
BufWinEnter = { buf, ... }:
LET (vim.filetype.match { inherit buf; }) (filetype: [
(CALL (PROP vim.cmd "folddoc") "foldopen!")
(IF (EQ filetype "gitcommit") (
vim.cmd {
cmd = "normal"; bang = true;
args = [ "gg" ];
}
) ELSE (LET
(IDX (vim.api.nvim_buf_get_mark buf "\"") 1)
(vim.api.nvim_buf_line_count buf)
(pos: cnt:
IF (AND (GE pos 1) (LE pos cnt))
(vim.cmd {
cmd = "normal"; bang = true;
args = [ "g`\"" ];
})
/*ELIF*/ (GE pos 1)
(vim.cmd {
cmd = "normal"; bang = true;
args = [ "g$" ];
})
ELSE
(vim.cmd {
cmd = "normal"; bang = true;
args = [ "gg" ];
})
)))
]);
}
))
]);
extraPlugins = map (x: x.plugin or x) plugins;
}; };
} }