This repository has been archived on 2024-05-17. You can view files and clone it, but cannot push or open issues or pull requests.
neovim/flake.nix

315 lines
8 KiB
Nix

{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
flake-utils.url = "github:numtide/flake-utils";
nix2lua.url = "git+https://git.pleshevski.ru/mynix/nix2lua";
# Plenary (required by crates-nvim)
plenary-nvim = {
url = "github:nvim-lua/plenary.nvim";
flake = false;
};
# config
# https://github.com/gpanders/editorconfig.nvim
editorconfig-nvim = {
url = "github:gpanders/editorconfig.nvim";
flake = false;
};
# explorer
# https://github.com/kyazdani42/nvim-tree.lua
nvim-tree-lua = {
url = "github:kyazdani42/nvim-tree.lua";
flake = false;
};
# https://github.com/nvim-telescope/telescope.nvim
telescope-nvim = {
url = "github:nvim-telescope/telescope.nvim";
flake = false;
};
# https://github.com/nvim-telescope/telescope-live-grep-args.nvim
telescope-live-grep-args-nvim = {
url = "github:nvim-telescope/telescope-live-grep-args.nvim";
flake = false;
};
# formatter
# https://github.com/sbdchd/neoformat
neoformat = {
url = "github:sbdchd/neoformat";
flake = false;
};
# git
# https://github.com/lewis6991/gitsigns.nvim
gitsigns-nvim = {
url = "github:lewis6991/gitsigns.nvim";
flake = false;
};
# lsp
# https://github.com/neovim/nvim-lspconfig
nvim-lspconfig = {
url = "github:neovim/nvim-lspconfig";
flake = false;
};
# https://github.com/tamago324/nlsp-settings.nvim
nlsp-settings-nvim = {
url = "github:tamago324/nlsp-settings.nvim";
flake = false;
};
# https://github.com/glepnir/lspsaga.nvim
lspsaga-nvim = {
url = "github:glepnir/lspsaga.nvim?rev=f33bc99d0ed3ed691a58b3339decf4e1933c3f9e";
flake = false;
};
# https://github.com/L3MON4D3/LuaSnip
luasnip = {
url = "github:L3MON4D3/LuaSnip";
flake = false;
};
# https://github.com/hrsh7th/nvim-cmp
nvim-cmp = {
url = "github:hrsh7th/nvim-cmp";
flake = false;
};
# https://github.com/hrsh7th/cmp-nvim-lsp
cmp-nvim-lsp = {
url = "github:hrsh7th/cmp-nvim-lsp";
flake = false;
};
# https://github.com/saadparwaiz1/cmp_luasnip
cmp-luasnip = {
url = "github:saadparwaiz1/cmp_luasnip";
flake = false;
};
# theme
# https://github.com/nanozuki/tabby.nvim
tabby-nvim = {
url = "github:nanozuki/tabby.nvim";
flake = false;
};
# https://github.com/nvim-lualine/lualine.nvim
lualine-nvim = {
url = "github:nvim-lualine/lualine.nvim";
flake = false;
};
# https://github.com/arkav/lualine-lsp-progress
lualine-lsp-progress = {
url = "github:/arkav/lualine-lsp-progress";
flake = false;
};
# https://github.com/kyazdani42/nvim-web-devicons
nvim-web-devicons = {
url = "github:kyazdani42/nvim-web-devicons";
flake = false;
};
# https://github.com/catppuccin/nvim
theme = {
url = "github:catppuccin/nvim";
flake = false;
};
# ux
# https://github.com/phaazon/hop.nvim
hop-nvim = {
url = "github:phaazon/hop.nvim";
flake = false;
};
# https://github.com/nvim-orgmode/orgmode
nvim-orgmode = {
url = "github:nvim-orgmode/orgmode?rev=fc9bb0f5823d01e4008e4b86663772d4148aa9ce";
flake = false;
};
# https://github.com/akinsho/org-bullets.nvim
org-bullets-nvim = {
url = "github:akinsho/org-bullets.nvim";
flake = false;
};
};
outputs = inputs @ { self, nixpkgs, flake-utils, nix2lua, ... }:
let
inputPlugins = [
"plenary-nvim"
# config
"editorconfig-nvim"
# explorer
"nvim-tree-lua"
"telescope-nvim"
"telescope-live-grep-args-nvim"
# formatter
"neoformat"
# git
"gitsigns-nvim"
# lsp
"nvim-lspconfig"
"nlsp-settings-nvim"
"lspsaga-nvim"
"luasnip"
"nvim-cmp"
"cmp-nvim-lsp"
"cmp-luasnip"
# theme
"tabby-nvim"
"lualine-nvim"
"lualine-lsp-progress"
"nvim-web-devicons"
"theme"
# ux
"hop-nvim"
"nvim-orgmode"
"org-bullets-nvim"
];
mkNvimPlugins = { lib, vimUtils, vimPlugins, ... }:
let
inherit (builtins) getAttr attrNames pathExists readDir;
inherit (lib) listToAttrs nameValuePair;
buildPlugin = name: vimUtils.buildVimPluginFrom2Nix {
name = name;
src = getAttr name inputs;
patches = lib.optional
(pathExists ./patches/${name})
(map
(fn: ./patches/${name}/${fn})
(attrNames (readDir ./patches/${name}))
);
};
buildPluginValuePair = n: nameValuePair n (buildPlugin n);
neovimPlugins = (listToAttrs (map buildPluginValuePair inputPlugins)) // {
inherit (vimPlugins) nvim-treesitter;
};
in
{
inherit neovimPlugins;
inherit nix2lua;
};
mkNeovim = pkgs: pkgs.callPackage ./neovim.nix (mkNvimPlugins pkgs);
in
{
overlays = {
default = final: prev: {
myneovim = mkNeovim prev;
};
};
} //
flake-utils.lib.eachDefaultSystem (system:
let
inherit (builtins) mapAttrs;
pkgs = import nixpkgs { inherit system; };
minimalNeovim = mkNeovim pkgs;
recommendedNeovim = (minimalNeovim.override {
enableDevIcons = true;
enableTabby = true;
plugins = with minimalNeovim.nix2lua; {
nvimTree.settings = {
renderer = {
group_empty = true;
full_name = true;
};
};
lualine.settings = {
options.ignore_focus = [ "NvimTree" ];
sections = {
lualine_a = [
[ "filename" (mkNamedField "path" 1) ]
];
lualine_b = [ "branch" "diff" "diagnostics" ];
lualine_c = [ "lsp_progress" ];
lualine_x = [ "filesize" "filetype" ];
lualine_y = [ "progress" ];
lualine_z = [ "location" "mode" ];
};
};
};
});
fullNeovim = recommendedNeovim.override {
plugins = recommendedNeovim.plugins // (with minimalNeovim.nix2lua; {
lspSaga.settings = {
border_style = "rounded";
symbol_in_winbar.enable = false;
code_action_lightbulb.enable = false;
code_action_keys = { quit = "<Esc>"; };
definition_action_keys = { quit = "<Esc>"; };
rename_action_quit = "<C-c>";
};
lspConfig = {
servers = {
nil_ls = { };
tsserver = { };
eslint = { };
denols = {
root_dir = mkLuaRaw "root_pattern(\"deno.json\", \"deno.jsonc\")";
};
rust_analyzer = {
settings.rust-analyzer = {
"server.path" = "rust-analyzer";
"updates.prompt" = false;
"updates.checkOnStartup" = false;
"checkOnSave.enable" = true;
"checkOnSave.command" = "clippy";
"cargo.autoreload" = true;
};
};
};
};
});
};
packages = {
default = recommendedNeovim;
recommended = recommendedNeovim;
full = fullNeovim;
minimal = minimalNeovim;
};
mkApp = drv: {
type = "app";
program = "${drv}/bin/nvim";
};
in
{
inherit packages;
apps = mapAttrs (name: mkApp) packages;
devShells.default = pkgs.mkShell {
packages = [
pkgs.stylua # lua formatter
];
};
});
}