diff options
| author | triethyl <triethylammonium@pm.me> | 2026-03-29 17:22:23 -0400 |
|---|---|---|
| committer | triethyl <triethylammonium@pm.me> | 2026-03-29 17:22:23 -0400 |
| commit | 716798a809d70ef31b2738544b34b793b7cc5c00 (patch) | |
| tree | 4be588faf094de1e4f43db7d88494098c5964294 /README.md | |
| parent | b70989225fd73fa796a1e26bcf2e3358cb802586 (diff) | |
added license and readme files
Diffstat (limited to 'README.md')
| -rw-r--r-- | README.md | 139 |
1 files changed, 139 insertions, 0 deletions
@@ -0,0 +1,139 @@ +# Lineage.nvim + +Lineage is an incredibly simple lua statusline for neovim. It was written in ~330 LOC and is designed to be easy for people to modify and extend with their own components. + +> [!CAUTION] +> This is my first Neovim plugin. The code is likely not as good as it could be and I probably missed several best practices. + +## Installation + +I use nix to manage my neovim plugins so I'm not sure how installing plugins works using package managers. I'll update this with instructions later if I have time. + +## Example Configurations + +The default layout is my daily driver, which is fairly unusual as far as statuslines go. Since I use the winbar to hold per-buffer information like the file name and diagnostics, I put things like the current working directory and the tab count in my statusline. + +### Icons Enabled + +To use the default layout with nerd-font icons enabled (must have a nerd font): + +```lua +require("lineage.nvim").setup { + use_icons = true +} +``` + +### Regular Configuration + +A totally regular configuration: + +> [!WARNING] +> The git branch and status components require the mini.git and mini.diff plugins, respectively. + +```lua +local lineage = require("lineage.nvim") +local comp = lineage.components +lineage.setup { + use_icons = true, + components = function() + return { + comp.mode({before = " "}), -- Gap before the first component + comp.git_branch(), + comp.filename({shorten_percentage = 70}), -- Shorten if takes up more than 70% of the line (only works with filename and cwd). + + "%=", -- Variable length spacer + + comp.location() + } + end +} +``` + +### Default Configuration + +You probably don't want to use this one. + +```lua +local lineage = require("lineage.nvim") +local comp = lineage.components +lineage.setup { + use_icons = false, + gaps = " ", + components = function() + return { + comp.mode({before = " "}), + comp.git_branch(), + comp.cwd(), + + "%=", + + comp.session_name(), + comp.markdown_word_count(), + comp.tab_counter(), + -- Neovide breaks progress component so add a spacer after location if neovide is present. + comp.location({after = vim.g.neovide and " " or ""}), + comp.progress({after = ""}), + } + end +} +``` + +## Do it Yourself + +Because of how simple this plugin is, it's very easy to write your own components or customize existing ones. All the utilities that were used to create the default components are exposed in the module. + +### Simple Custom Component + +Here is a full configuration with a custom markdown word counter component. + +```lua +local lineage = require("lineage.nvim") + +-- Custom component function. It just needs to return a string. +local custom_markdown_word_count = function(args) + -- Check for extra arguments + args = args or {} + + -- Get text to insert before and after the component (unnecessary but sometimes useful) + local before = args.before or "" + local after = args.after or "" + + -- Return an empty string if we're not focused on a markdown file + if vim.bo.filetype ~= "markdown" then + return "" + end + + -- Get the word count of the current file or the current visual selection, if there is one. + local word_count = vim.fn.wordcount().visual_words or vim.fn.wordcount().words + + -- Set the nerd fonts icon if icons are enabled or just ascii text if they're not + local icon = lineage.use_icons and " " or "words: " + + -- Construct the string to be added to the line. + return before..icon..word_count..after +end + +local comp = lineage.components +lineage.setup { + use_icons = true, + components = function() + return { + comp.mode({before = " "}), + comp.git_branch(), + comp.filename(), + + "%=", -- Variable length spacer + + comp.location() + } + end +} +``` + +### Colors + +Because this plugin was designed to be as simple as possible, it does not have its own themes. Instead, all colors are pulled from existing highlights, meaning that any neovim theme will work. To see how this works, you can look at the code for the mode component. + +### Shortening + +Certain components like cwd and filename will shorten themselves if they take up a certain percentage of the statusline. They take an option (similar to before and after) that defines what this percentage is. To see how this works, you can look at the code for the cwd and filename components. |
