Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

statusline/feline: init #521

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,12 @@
flake = false;
};

plugin-feline-nvim = {
url = "github:freddiehaddad/feline.nvim";
flake = false;
};

# Completion
plugin-nvim-cmp = {
url = "github:hrsh7th/nvim-cmp";
flake = false;
Expand Down
1 change: 1 addition & 0 deletions modules/plugins/statusline/default.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
imports = [
./feline
./lualine
];
}
21 changes: 21 additions & 0 deletions modules/plugins/statusline/feline/config.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
config,
lib,
...
}: let
inherit (lib.modules) mkIf;

cfg = config.vim.statusline.feline-nvim;
in {
config = mkIf cfg.enable {
vim = {
lazy.plugins.feline-nvim = {
event = "UIEnter";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
event = "UIEnter";
event = "DeferredUIEnter";

This is debatable, but if the goal is to start accepting user input as soon as possible, then DeferredUIEnter should be used

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a benefit to taking user input as soon as possible?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean yeah? You wouldn't want a 10s startup time would you


package = "feline-nvim";
setupModule = "feline";
inherit (cfg) setupOpts;
};
};
};
}
6 changes: 6 additions & 0 deletions modules/plugins/statusline/feline/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
imports = [
./config.nix
./feline.nix
];
}
143 changes: 143 additions & 0 deletions modules/plugins/statusline/feline/feline.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
{
config,
lib,
...
}: let
inherit (builtins) elem;
inherit (lib.options) mkOption mkEnableOption literalExpression;
inherit (lib.types) str listOf attrs attrsOf anything either submodule;
inherit (lib.lists) optional;
inherit (lib.generators) mkLuaInline;
inherit (lib.nvim.types) mkPluginSetupOption;

conditionalRenderers = {
options = {
filetypes = mkOption {
type = listOf str;
default = [
"^NvimTree$"
"^neo-tree$"
"^startify$"
"^fugitive$"
"^fugitiveblame$"
"^qf$"
"^help$"
];

description = "Filetypes in which to force render inactive statusline";
};

buftypes = mkOption {
type = listOf str;
default = ["^terminal$"];
description = "Buffer types in which to force render inactive statusline";
};

bufnames = mkOption {
type = listOf str;
default = [];
description = "Buffer names in which to force render inactive statusline";
};
};
};
in {
options.vim.statusline.feline-nvim = {
enable = mkEnableOption "minimal, stylish and customizable statusline, statuscolumn, and winbar [feline.nvim]";
setupOpts = mkPluginSetupOption "feline-nvim" {
custom_providers = mkOption {
type = attrsOf anything;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be of type luaInline

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

custom_providers takes a table, in which case we should be able to get a listOf luaInline. No?

Copy link
Collaborator

@diniamo diniamo Jan 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Men go read the docs, you have to be able to refer to the custom providers somehow. It's a set of functions (which is what I meant to say in my original comment, but it ended up beibg ambiguous)

default = {};
example = literalExpression ''
{
window_number = mkLuaInline ''''
function()
return tostring(vim.api.nvim_win_get_number(0))
end
'''';
}
'';

description = "User-defined feline provider functions";
};

theme = mkOption {
type = either str (attrsOf str);
default = {};
example = {
fg = "#fff";
bg = "#111";
};
description = ''
Either a string containing the color theme name or an attribute set of
strings, containing the colors.

The theme’s `fg` and `bg` values also represent the default foreground
and background colors, respectively.
'';
};

separators = mkOption {
type = attrsOf str;
default = {};
example = {vertical_bar = "┃";};
description = ''
A table containing custom Feline separator prests.

:::{.warning}
This option is not type-checked! Before setting this option, please take
a look at {command}`:help feline-separator-preset` for a list of
available separator presets.
:::
'';
};

force_inactive = mkOption {
default = {};
type = attrsOf (submodule conditionalRenderers);
description = ''
A table that determines which buffers should always have the inactive
statusline, even when they are active.
'';
};

disable = mkOption {
default = {};
type = attrsOf (submodule conditionalRenderers);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't make sense, the defaults above only apply to force_active. Nothing should be disabled by default.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We cannot omit the default here. That's why it has one, and also conditionalRenderers submodule provides upstream defaults.

Copy link
Collaborator

@diniamo diniamo Jan 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It literally does not, nothing is disabled by default (in the upstream detaults, which is what I meant by apply)

description = ''
A table that determines which buffers should always have the statusline
disabled, even when they are active.
'';
};

vi_mode_colors = mkOption {
type = attrsOf str;
default = {};
description = ''
Attribute set containing colors associated with specific Vi modes.

It can later be used to get the color associated with the current Vim
mode using `require('feline.providers.vi_mode').get_mode_color()`.

See `:help feline-vi-mode` for more details on vi mode.
'';
};

# TODO:

# - add examples for each one of those components. The option types are necessary, but confusing.
components = {
active = mkOption {
type = listOf (listOf (attrsOf anything));
default = [];
description = "List of components to display for buffers feline will render as 'active'";
};

inactive = mkOption {
type = listOf (listOf (attrsOf anything));
default = [];
description = "List of components to display for buffers feline will render as 'inactive'";
};
};
};
};
}
Loading