{"id":13412012,"url":"https://github.com/sontungexpt/sttusline","last_synced_at":"2025-09-04T07:34:35.183Z","repository":{"id":200001314,"uuid":"704295656","full_name":"sontungexpt/sttusline","owner":"sontungexpt","description":"A very lightweight, super fast and lazyloading statusline plugin for Neovim written in lua.","archived":false,"fork":false,"pushed_at":"2024-06-07T08:24:55.000Z","size":446,"stargazers_count":116,"open_issues_count":6,"forks_count":8,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-10-29T23:13:23.274Z","etag":null,"topics":["bar","lua","neovim","nvim","status","statusline"],"latest_commit_sha":null,"homepage":"","language":"Lua","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sontungexpt.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2023-10-13T00:56:59.000Z","updated_at":"2024-10-15T20:59:28.000Z","dependencies_parsed_at":"2023-10-15T06:37:39.008Z","dependency_job_id":"74aceb7e-ae49-4d7c-8635-08a2c94afb79","html_url":"https://github.com/sontungexpt/sttusline","commit_stats":null,"previous_names":["sontungexpt/sttusline"],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sontungexpt%2Fsttusline","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sontungexpt%2Fsttusline/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sontungexpt%2Fsttusline/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sontungexpt%2Fsttusline/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sontungexpt","download_url":"https://codeload.github.com/sontungexpt/sttusline/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224305839,"owners_count":17289446,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bar","lua","neovim","nvim","status","statusline"],"created_at":"2024-07-30T20:01:20.119Z","updated_at":"2024-11-12T16:00:36.862Z","avatar_url":"https://github.com/sontungexpt.png","language":"Lua","funding_links":[],"categories":["Bars and Lines","Lua"],"sub_categories":["Statusline"],"readme":"## Sttusline\n\n## :star2:**IMPORTANT:** As I am currently utilizing the [table_version](https://github.com/sontungexpt/sttusline/tree/table_version) branch, kindly switch to it in order to receive the latest updates regularly.\n\nA very lightweight statusline plugin for neovim written in lua.\n\nThis plugin lazy load all components and only update each component when needed.\n\nBecause this plugin aim to be fast and small as possible. I don't focus on\noverriding default component. I focus on creating your custom component. So\nmaybe you need to know a little bit of lua to create your own component.\n\n- ❓ [Features](#features)\n- 👀 [Installation](#installation)\n- 💻 [Configuration](#configuration)\n- 😆 [Usage](#usage)\n- 😁 [Contributing](#contributing)\n- ✌️ [License](#license)\n\n## A few words to say\n\n🎉 As you can see, this plugin is very small and fast. But maybe it't not perfect\nbecause I'm not a lua expert. So if you have any idea to improve this plugin,\nplease open an issue or pull request. I'm very happy to hear from you.\n\n🍕 The default component is written for my personal use. So maybe you need to\ncreate your own component. I'm very happy to see your component. So if you have\nany idea to create a new component, please open an issue or pull request.\n\n🛠️ At present, I feel that use table to create new component is easy to control\nthan creating by calling get and set function. So I recommend you to use branch\n[table_version](https://github.com/sontungexpt/sttusline/tree/table_version) instead of this branch\n\n## Preview\n\n![preview1](./docs/readme/preview1.png)\n\n\nCopilot loading\n\n[https://github.com/sontungexpt/sttusline/assets/92097639/a6cfc4d1-9d1f-445f-a90a-90f211bb1724](https://github.com/sontungexpt/sttusline/assets/92097639/4582f45d-58e4-469b-a7ad-85f482d3ba57)\n\n\n\n\n\n\n## Features\n\n🎉 Lightweight and super fast.\n\n🛠️ Lazy load all components\n\n🍕 Only update each component when needed, not update all statusline\n\n🔥 Easy to create your component with lua\n\n## Installation\n\n```lua\n    -- lazy\n    {\n        \"sontungexpt/sttusline\",\n        dependencies = {\n            \"nvim-tree/nvim-web-devicons\",\n        },\n        event = { \"BufEnter\" },\n        config = function(_, opts)\n            require(\"sttusline\").setup {\n                -- statusline_color = \"#000000\",\n                statusline_color = \"StatusLine\",\n\n                -- | 1 | 2 | 3\n                -- recommended: 3\n                laststatus = 3,\n                disabled = {\n                    filetypes = {\n                        -- \"NvimTree\",\n                        -- \"lazy\",\n                    },\n                    buftypes = {\n                        -- \"terminal\",\n                    },\n                },\n                components = {\n                    \"mode\",\n                    \"filename\",\n                    \"git-branch\",\n                    \"git-diff\",\n                    \"%=\",\n                    \"diagnostics\",\n                    \"lsps-formatters\",\n                    \"copilot\",\n                    \"indent\",\n                    \"encoding\",\n                    \"pos-cursor\",\n                    \"pos-cursor-progress\",\n                },\n            }\n        end,\n    },\n```\n\n## Usage\n\n**NOTE**: If you want create new component by adding a table to components\nplease use branch [table_version](https://github.com/sontungexpt/sttusline/tree/table_version) instead of this branch\n\n### Create your own component\n\n| **Command**              | **Description**                           |\n| ------------------------ | ----------------------------------------- |\n| `:SttuslineNewComponent` | Create the template to make new component |\n\nor copy the template to your component module\n\n```lua\n-- Change NewComponent to your component name\nlocal NewComponent = require(\"sttusline.component\").new()\n\n-- The component will be update when the event is triggered\n-- To disable default event, set NewComponent.set_event = {}\nNewComponent.set_event {}\n\n-- The component will be update when the user event is triggered\n-- To disable default user_event, set NewComponent.set_user_event = {}\nNewComponent.set_user_event { \"VeryLazy\" }\n\n-- The component will be update every time interval\nNewComponent.set_timing(false)\n\n-- The component will be update when the require(\"sttusline\").setup() is called\nNewComponent.set_lazy(true)\n\n-- The config of the component\n-- After set_config, the config will be available in the component\n-- You can access the config by NewComponent.get_config()\nNewComponent.set_config {}\n\n-- The number of spaces to add before and after the component\nNewComponent.set_padding(1)\n-- or NewComponent.set_padding{ left = 1, right = 1 }\n\n-- The colors of the component. Rely on the return value of the update function, you have 3 ways to set the colors\n-- If the return value is string\n-- NewComponent.set_colors { fg = colors.set_black, bg = colors.set_white }\n-- If the return value is table of string\n-- NewComponent.set_colors { { fg = \"#009900\", bg = \"#ffffff\" }, { fg = \"#000000\", bg = \"#ffffff\" }}\n-- -- so if the return value is { \"string1\", \"string2\" }\n-- -- then the string1 will be highlight with { fg = \"#009900\", bg = \"#ffffff\" }\n-- -- and the string2 will be highlight with { fg = \"#000000\", bg = \"#ffffff\" }\n--\n-- -- if you don't want to add highlight for the string1 now\n-- -- because it will auto update new colors when the returning value in update function is a table that contains the color options,\n-- -- you can add a empty table in the first element\n-- -- {\n--     colors = {\n--         {},\n--         { fg = \"#000000\", bg = \"#ffffff\" }\n--     },\n-- -- }\n--\n-- NOTE: The colors options can be the colors name or the colors options\n-- -- colors = {\n-- --  { fg = \"#009900\", bg = \"#ffffff\" },\n-- --  \"DiagnosticsSignError\",\n-- -- },\n-- -- So if the return value is { \"string1\", \"string2\" }\n-- -- then the string1 will be highlight with { fg = \"#009900\", bg = \"#ffffff\" }\n-- -- and the string2 will be highlight with the colors options of the DiagnosticsSignError highlight\n-- -- Or you can set the fg(bg) follow the colors options of the DiagnosticsSignError highlight\n-- -- {\n-- --  colors = {\n-- --      { fg = \"DiagnosticsSignError\", bg = \"#ffffff\" },\n-- --      \"DiagnosticsSignError\",\n-- --  },\n-- -- }\n\nNewComponent.set_colors {} -- { fg = colors.set_black, bg = colors.set_white }\n\n-- The function will return the value of the component to display on the statusline(required).\n-- Must return a string or a table of string or a table of  { \"string\", { fg = \"color\", bg = \"color\" } }\n-- NewComponent.set_update(function() return { \"string1\", \"string2\" } end)\n-- NewComponent.set_update(function() return { { \"string1\", {fg = \"#000000\", bg =\"#fdfdfd\"} },  \"string3\", \"string4\" } end)\nNewComponent.set_update(function() return \"\" end)\n\n\n-- The function will call when the component is highlight\nNewComponent.set_onhighlight(function() end)\n\n-- The function will return the condition to display the component when the component is update\n-- Must return a boolean\nNewComponent.set_condition(function() return true end)\n\n-- The function will call on the first time component load\nNewComponent.set_onload(function() end)\n\n\nreturn NewComponent\n```\n\nAfter you create your component, you need to add it to `components` option in\n`setup` function\nsuch as:\n\n```lua\n    -- Create new component with name Datetime\n    local Datetime = require(\"sttusline.component\").new()\n\n    Datetime.set_config {\n        style = \"default\",\n    }\n\n    Datetime.set_timing(true)\n\n    Datetime.set_update(function()\n        local style = Datetime.get_config().style\n        local fmt = style\n        if style == \"default\" then\n            fmt = \"%A, %B %d | %H.%M\"\n        elseif style == \"us\" then\n            fmt = \"%m/%d/%Y\"\n        elseif style == \"uk\" then\n            fmt = \"%d/%m/%Y\"\n        elseif style == \"iso\" then\n            fmt = \"%Y-%m-%d\"\n        end\n        return os.date(fmt) .. \"\"\n    end)\n\n    require(\"sttusline\").setup {\n        components = {\n            -- ...\n            -- Add your component\n            Datetime,\n        }\n    }\n```\n\n### Use default component\n\nTo use default component, you need to add it to `components` option in `setup` function\n\nNote: the default component must be a string\n\nWe provide you some default component:\n\n| **Component**         | **Description**                                        |\n| --------------------- | ------------------------------------------------------ |\n| `datetime`            | Show datetime                                          |\n| `mode`                | Show current mode                                      |\n| `filename`            | Show current filename                                  |\n| `git-branch`          | Show git branch                                        |\n| `git-diff`            | Show git diff                                          |\n| `diagnostics`         | Show diagnostics                                       |\n| `lsps-formatters`     | Show lsps, formatters(support for null-ls and conform) |\n| `copilot`             | Show copilot status                                    |\n| `indent`              | Show indent                                            |\n| `encoding`            | Show encoding                                          |\n| `pos-cursor`          | Show position of cursor                                |\n| `pos-cursor-progress` | Show position of cursor with progress                  |\n\n```lua\n    require(\"sttusline\").setup {\n        -- ...\n        components = {\n            -- \"mode\",\n            -- \"filename\",\n            -- \"git-branch\",\n            -- \"git-diff\",\n            -- \"%=\",\n            -- \"diagnostics\",\n            -- \"lsps-formatters\",\n            -- \"copilot\",\n            -- \"indent\",\n            -- \"encoding\",\n            -- \"pos-cursor\",\n            -- \"pos-cursor-progress\",\n        },\n    }\n```\n\n### Add the empty space between components\n\nTo add the empty space between components, you need to add `%=` to `components` option in `setup` function\n\n```lua\n    require(\"sttusline\").setup {\n        components = {\n            -- ... your components\n            \"%=\", -- add the empty space\n            -- ... your components\n        },\n    }\n```\n\n### Override default component\n\nAlthough this plugin is not focus on overriding default component. But you can\ndo it by override the default component by some functions I provide to you. But\nI recommend you to create your own component to reach the best performance.\n\n| **Function**      | Type of args                  | **Description**                                                                                         |\n| ----------------- | ----------------------------- | ------------------------------------------------------------------------------------------------------- |\n| `set_event`       | table or string               | The component will be update when the event is triggered. If you call set_event{} no event will trigger |\n| `set_user_event`  | tableor string                | Same as set_event buf for `User` autocmd                                                                |\n| `set_timing`      | boolean                       | If set_timing(true), component will update after 1 second                                               |\n| `set_lazy`        | boolean                       | Load component on startup(not recommended)                                                              |\n| `set_config`      | table                         | Set config to update component                                                                          |\n| `set_padding`     | number or table               | The number of spaces to add before and after the component                                              |\n| `set_colors`      | table                         | Colors highlight                                                                                        |\n| `set_update`      | function(must return string)  | The function will return the value of the component to display on the statusline                        |\n| `set_condition`   | function(must return boolean) | The function will return the condition to display the component when the component is update            |\n| `set_onhighlight` | function                      | The function will call when the component is set highlight                                              |\n| `set_onload`      | function                      | The function will call on the first time component load                                                 |\n\nSo to override default component you can do\n\n```lua\nlocal mode = require(\"sttusline.components.mode\")\n\nmode.set_config{\n    mode_colors = {\n        [\"STTUSLINE_NORMAL_MODE\"] = { fg = \"#000000\", bg = \"#ffffff\" },\n    },\n}\n\n-- after override default component, you need to add it to components option in setup function\nrequire(\"sttusline\").setup {\n    components = {\n        -- ... your components\n        mode,\n        -- ... your components\n    },\n}\n```\n\nSome config I provide to override default component\n\n- datetime\n\n```lua\n    local datetime = require(\"sttusline.components.datetime\")\n\n    datetime.set_config {\n      style = \"default\",\n    }\n```\n\n- mode\n\n```lua\n    local mode = require(\"sttusline.components.mode\")\n\n    mode.set_config {\n    modes = {\n        [\"n\"] = { \"NORMAL\", \"STTUSLINE_NORMAL_MODE\" },\n        [\"no\"] = { \"NORMAL (no)\", \"STTUSLINE_NORMAL_MODE\" },\n        [\"nov\"] = { \"NORMAL (nov)\", \"STTUSLINE_NORMAL_MODE\" },\n        [\"noV\"] = { \"NORMAL (noV)\", \"STTUSLINE_NORMAL_MODE\" },\n        [\"noCTRL-V\"] = { \"NORMAL\", \"STTUSLINE_NORMAL_MODE\" },\n        [\"niI\"] = { \"NORMAL i\", \"STTUSLINE_NORMAL_MODE\" },\n        [\"niR\"] = { \"NORMAL r\", \"STTUSLINE_NORMAL_MODE\" },\n        [\"niV\"] = { \"NORMAL v\", \"STTUSLINE_NORMAL_MODE\" },\n\n        [\"nt\"] = { \"TERMINAL\", \"STTUSLINE_NTERMINAL_MODE\" },\n        [\"ntT\"] = { \"TERMINAL (ntT)\", \"STTUSLINE_NTERMINAL_MODE\" },\n\n        [\"v\"] = { \"VISUAL\", \"STTUSLINE_VISUAL_MODE\" },\n        [\"vs\"] = { \"V-CHAR (Ctrl O)\", \"STTUSLINE_VISUAL_MODE\" },\n        [\"V\"] = { \"V-LINE\", \"STTUSLINE_VISUAL_MODE\" },\n        [\"Vs\"] = { \"V-LINE\", \"STTUSLINE_VISUAL_MODE\" },\n        [\"\u0016\"] = { \"V-BLOCK\", \"STTUSLINE_VISUAL_MODE\" },\n\n        [\"i\"] = { \"INSERT\", \"STTUSLINE_INSERT_MODE\" },\n        [\"ic\"] = { \"INSERT (completion)\", \"STTUSLINE_INSERT_MODE\" },\n        [\"ix\"] = { \"INSERT completion\", \"STTUSLINE_INSERT_MODE\" },\n\n        [\"t\"] = { \"TERMINAL\", \"STTUSLINE_TERMINAL_MODE\" },\n        [\"!\"] = { \"SHELL\", \"STTUSLINE_TERMINAL_MODE\" },\n\n        [\"R\"] = { \"REPLACE\", \"STTUSLINE_REPLACE_MODE\" },\n        [\"Rc\"] = { \"REPLACE (Rc)\", \"STTUSLINE_REPLACE_MODE\" },\n        [\"Rx\"] = { \"REPLACEa (Rx)\", \"STTUSLINE_REPLACE_MODE\" },\n        [\"Rv\"] = { \"V-REPLACE\", \"STTUSLINE_REPLACE_MODE\" },\n        [\"Rvc\"] = { \"V-REPLACE (Rvc)\", \"STTUSLINE_REPLACE_MODE\" },\n        [\"Rvx\"] = { \"V-REPLACE (Rvx)\", \"STTUSLINE_REPLACE_MODE\" },\n\n        [\"s\"] = { \"SELECT\", \"STTUSLINE_SELECT_MODE\" },\n        [\"S\"] = { \"S-LINE\", \"STTUSLINE_SELECT_MODE\" },\n        [\"\u0013\"] = { \"S-BLOCK\", \"STTUSLINE_SELECT_MODE\" },\n\n        [\"c\"] = { \"COMMAND\", \"STTUSLINE_COMMAND_MODE\" },\n        [\"cv\"] = { \"COMMAND\", \"STTUSLINE_COMMAND_MODE\" },\n        [\"ce\"] = { \"COMMAND\", \"STTUSLINE_COMMAND_MODE\" },\n\n        [\"r\"] = { \"PROMPT\", \"STTUSLINE_CONFIRM_MODE\" },\n        [\"rm\"] = { \"MORE\", \"STTUSLINE_CONFIRM_MODE\" },\n        [\"r?\"] = { \"CONFIRM\", \"STTUSLINE_CONFIRM_MODE\" },\n        [\"x\"] = { \"CONFIRM\", \"STTUSLINE_CONFIRM_MODE\" },\n    },\n    mode_colors = {\n        [\"STTUSLINE_NORMAL_MODE\"] = { fg = colors.blue },\n        [\"STTUSLINE_INSERT_MODE\"] = { fg = colors.green },\n        [\"STTUSLINE_VISUAL_MODE\"] = { fg = colors.purple },\n        [\"STTUSLINE_NTERMINAL_MODE\"] = { fg = colors.gray },\n        [\"STTUSLINE_TERMINAL_MODE\"] = { fg = colors.cyan },\n        [\"STTUSLINE_REPLACE_MODE\"] = { fg = colors.red },\n        [\"STTUSLINE_SELECT_MODE\"] = { fg = colors.magenta },\n        [\"STTUSLINE_COMMAND_MODE\"] = { fg = colors.yellow },\n        [\"STTUSLINE_CONFIRM_MODE\"] = { fg = colors.yellow },\n        },\n    },\n    auto_hide_on_vim_resized = true,\n```\n\n- diagnostics\n\n```lua\n    local diagnostics = require(\"sttusline.components.diagnostics\")\n    diagnostics.set_config {\n        icons = {\n            ERROR = \"\",\n            INFO = \"\",\n            HINT = \"󰌵\",\n            WARN = \"\",\n        },\n        order = { \"ERROR\", \"WARN\", \"INFO\", \"HINT\" },\n    }\n```\n\n- encoding\n\n```lua\nlocal encoding = require(\"sttusline.components.encoding\")\n\nencoding.set_config {\n\t[\"utf-8\"] = \"󰉿\",\n\t[\"utf-16\"] = \"\",\n\t[\"utf-32\"] = \"\",\n\t[\"utf-8mb4\"] = \"\",\n\t[\"utf-16le\"] = \"\",\n\t[\"utf-16be\"] = \"\",\n}\n```\n\n- filename\n\n```lua\n    local filename = require(\"sttusline.components.filename\")\n    filename.set_config {\n        color = { fg = colors.orange },\n    }\n```\n\n- git-branch\n\n```lua\n    local git_branch = require(\"sttusline.components.git-branch\")\n\n    git_branch.set_config {\n        icons =  \"\"\n    }\n```\n\n- git-diff\n\n```lua\n    local git_diff = require(\"sttusline.components.git-diff\")\n\n    git_diff.set_config {\n        icons = {\n            added = \"\",\n            changed = \"\",\n            removed = \"\",\n        },\n        order = { \"added\", \"changed\", \"removed\" },\n    }\n```\n\n- indent\n\n```lua\nlocal indent = require(\"sttusline.components.indent\")\n\nindent.set_colors { fg = colors.cyan }\n```\n\n- lsps-formatters\n\n```lua\nlocal lsps_formatters = require(\"sttusline.components.lsps-formatters\")\n\nlsps_formatters.set_colors { fg = colors.magenta }\n```\n\n- copilot\n\n```lua\nlocal copilot = require(\"sttusline.components.copilot\")\n\ncopilot.set_colors { fg = colors.yellow }\ncopilot.set_config {\n    icons = {\n        normal = \"\",\n        error = \"\",\n        warning = \"\",\n        inprogress = \"\",\n    },\n}\n```\n\n- pos-cursor\n\n```lua\nlocal pos_cursor = require(\"sttusline.components.pos-cursor\")\npos_cursor.set_colors { fg = colors.fg }\n```\n\n- pos-cursor-progress\n\n```lua\nlocal pos_cursor_progress = require(\"sttusline.components.pos-cursor-progress\")\npos_cursor_rogress.set_colors { fg = colors.orange }\n```\n\n## Contributing\n\nPull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsontungexpt%2Fsttusline","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsontungexpt%2Fsttusline","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsontungexpt%2Fsttusline/lists"}