plugin/theme: setup optional tabline plugin

This commit is contained in:
Dmitriy Pleshevskiy 2022-09-17 15:59:06 +03:00
parent f0ebb7f846
commit a686e4b253
Signed by: pleshevskiy
GPG key ID: 1B59187B161C0215
5 changed files with 26 additions and 14 deletions

View file

@ -3,18 +3,21 @@
let let
lib = import ./lib.nix; lib = import ./lib.nix;
callPlugins = list: builtins.map (p: import p vimPlugins) list; pluginParams = vimPlugins // { inherit lib; };
callPlugin = op: if builtins.isFunction op then op pluginParams else import op pluginParams;
callPlugins = list: builtins.map callPlugin list;
plugins = callPlugins [ plugins = callPlugins [
./plugins/syntax ./plugins/syntax
./plugins/explorer ./plugins/explorer
./plugins/theme (import ./plugins/theme { enableTabline = false; })
./plugins/lsp ./plugins/lsp
./plugins/formatter ./plugins/formatter
]; ];
basicConfigs = map builtins.readFile [ ./config/basic.lua ]; basicConfigs = builtins.map builtins.readFile [ ./config/basic.lua ];
pluginConfigs = lib.extractAttrs "luaConfig" plugins; pluginConfigs = builtins.catAttrs "luaConfig" plugins;
allConfigs = basicConfigs ++ pluginConfigs; allConfigs = basicConfigs ++ pluginConfigs;
in in
wrapNeovim neovim-unwrapped { wrapNeovim neovim-unwrapped {
@ -25,6 +28,6 @@ wrapNeovim neovim-unwrapped {
configure = { configure = {
customRC = lib.mkLuaRc allConfigs; customRC = lib.mkLuaRc allConfigs;
packages.myVimPackages = { start = lib.extractAttrs "plugins" plugins; }; packages.myVimPackages = { start = builtins.catAttrs "plugins" plugins; };
}; };
} }

14
lib.nix
View file

@ -19,13 +19,17 @@ rec {
in in
foldr concat "" list; foldr concat "" list;
extractAttrs = attr: list: ############################################################################
# Configs
optional = cond: val:
let let
getAttr' = builtins.getAttr attr; def =
hasAttr' = builtins.hasAttr attr; if builtins.isList val then [ ]
filteredList = builtins.filter hasAttr' list; else if builtins.isString val then ""
else null;
in in
builtins.map getAttr' filteredList; if cond then val else def;
############################################################################# #############################################################################
# Lua # Lua

View file

@ -7,5 +7,5 @@ vim.g.loaded_netrwPlugin = 1
-- empty setup using defaults -- empty setup using defaults
require("nvim-tree").setup() require("nvim-tree").setup()
vim.keymap.set("n", "<leader>nt", ":NvimTreeFocus<CR>") vim.keymap.set("n", "<leader>nt", ":NvimTreeToggle<CR>")
vim.keymap.set("n", "<leader>nf", ":NvimTreeFindFile<CR>") vim.keymap.set("n", "<leader>nf", ":NvimTreeFindFile<CR>")

View file

@ -1,13 +1,16 @@
{ catppuccin-nvim, lualine-nvim, lualine-lsp-progress, ... }: { enableTabline ? false }:
{ lib, catppuccin-nvim, lualine-nvim, lualine-lsp-progress, tabline-nvim, ... }:
{ {
luaConfig = (builtins.readFile ./catppuccin-nvim.lua) luaConfig = (builtins.readFile ./catppuccin-nvim.lua)
+ (builtins.readFile ./lualine.lua); + (builtins.readFile ./lualine.lua)
+ (lib.optional enableTabline (builtins.readFile ./tabline.lua));
plugins = [ plugins = [
catppuccin-nvim catppuccin-nvim
lualine-nvim lualine-nvim
lualine-lsp-progress lualine-lsp-progress
]; ] ++ (lib.optional enableTabline [ tabline-nvim ]);
} }

View file

@ -0,0 +1,2 @@
-- See: https://github.com/kdheepak/tabline.nvim
require("tabline").setup({})