{"id":21917167,"url":"https://github.com/oxy2dev/foldtext.nvim","last_synced_at":"2025-05-09T00:06:49.647Z","repository":{"id":248248811,"uuid":"828181498","full_name":"OXY2DEV/foldtext.nvim","owner":"OXY2DEV","description":"Dynamic \u0026 stylized foldtext for Neovim","archived":false,"fork":false,"pushed_at":"2025-05-07T16:34:16.000Z","size":761,"stargazers_count":86,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-05-09T00:06:37.353Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Lua","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/OXY2DEV.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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,"publiccode":null,"codemeta":null}},"created_at":"2024-07-13T11:07:07.000Z","updated_at":"2025-05-08T23:59:27.000Z","dependencies_parsed_at":"2024-07-13T12:35:46.014Z","dependency_job_id":"6843c489-4a63-4d4a-ad5a-706ccc6b1f3a","html_url":"https://github.com/OXY2DEV/foldtext.nvim","commit_stats":null,"previous_names":["oxy2dev/foldtext.nvim"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OXY2DEV%2Ffoldtext.nvim","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OXY2DEV%2Ffoldtext.nvim/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OXY2DEV%2Ffoldtext.nvim/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OXY2DEV%2Ffoldtext.nvim/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/OXY2DEV","download_url":"https://codeload.github.com/OXY2DEV/foldtext.nvim/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253166518,"owners_count":21864476,"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":[],"created_at":"2024-11-28T19:28:26.292Z","updated_at":"2025-05-09T00:06:49.596Z","avatar_url":"https://github.com/OXY2DEV.png","language":"Lua","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 📂 Foldtext.nvim\n\n\u003e[!NOTE]\n\u003e If you are coming from `v1`, you should see the [migration](#-migration) section.\n\u003e\n\u003e Also, You can always tag the plugin's version to `v1.0.0` from your package manager until you are ready to migrate.\n\n\n![demo_1](https://raw.githubusercontent.com/OXY2DEV/foldtext.nvim/refs/heads/images/images/foldtext.nvim-1.png)\n\n![demo_2](https://raw.githubusercontent.com/OXY2DEV/foldtext.nvim/refs/heads/images/images/foldtext.nvim-2.png)\n\n\n*Fancy* foldtext for `Neovim`.\n\n## ✨ Features\n\n- Fast, ~1ms load time.\n- Ability to use separate foldtext **per window**.\n- Foldtext parts to make things easier with ability to toggle them on-demand.\n- Automatically updates the used foldtext on `OptionSet`(only for `filetype`, `buftype`, `foldmethod` \u0026 `foldexpr`).\n\n## 📦 Installation\n\n`Foldtext.nvim` can be installed via your favourite package managers.\n\n### 💤 Lazy.nvim\n\nFor `lazy.lua`/`plugins.lua` users.\n\n```lua\n{\n    \"OXY2DEV/foldtext.nvim\",\n    lazy = false\n}\n```\n\nFor `plugins/foldtext.lua` users.\n\n```lua\nreturn {\n    \"OXY2DEV/foldtext.nvim\",\n    lazy = false\n}\n```\n\n### 🦠 Mini.deps\n\n```lua\nlocal MiniDeps = require(\"mini.deps\");\n\nMiniDeps.add({\n    source = \"OXY2DEV/foldtext.nvim\"\n});\n```\n\n### 🌒 Rocks.nvim\n\nYou can install the plugin via `rocks.nvim` with the following command.\n\n```vim\n:Rocks install foldtext.nvim\n```\n\n## 🔩 Configuration\n\nThe plugin can be configured via the `setup()` command. The configuration table has the following structure,\n\n\u003e[!TIP]\n\u003e You can check out the [example styles](https://github.com/OXY2DEV/foldtext.nvim/blob/main/lua/foldtext/examples.lua) file to see how different parts are used.\n\n```lua\nrequire(\"foldtext\").setup({\n    -- Ignore buffers with these buftypes.\n    ignore_buftypes = {},\n    -- Ignore buffers with these filetypes.\n    ignore_filetypes = {},\n    -- Ignore buffers/windows if the result\n    -- is false.\n    condition = function ()\n        return true;\n    end,\n\n    styles = {\n        default = {\n            { kind = \"bufline\" }\n        },\n\n        -- Custom foldtext.\n        custom_a = {\n            -- Only on these filetypes.\n            filetypes = {},\n            -- Only on these buftypes.\n            buftypes = {},\n\n            -- Only if this condition is\n            -- true.\n            condition = function (win)\n                return vim.wo[win].foldmethod == \"manual\";\n            end,\n\n            -- Parts to create the foldtext.\n            parts = {\n                { kind = \"fold_size\" }\n            }\n        }\n    }\n});\n```\n\nYou can find the default configuration table [here](https://github.com/OXY2DEV/foldtext.nvim/blob/main/lua/foldtext.lua#L8). A few custom foldtext are provided as examples. These are,\n\n- `default`, Used for **conventional-commit** style messages(falls back to showing range if no description is found) in foldtext. See [here](https://github.com/OXY2DEV/foldtext.nvim/blob/dev/lua/foldtext.lua#L13).\n- `ts_expr`, Used when tree-sitter expressions are used for folding. See [here](https://github.com/OXY2DEV/foldtext.nvim/blob/dev/lua/foldtext.lua#L44).\n\n------\n\nDescription about each option is given below,\n\n### ignore_buftypes\n\n- Type: `string[]`\n- Default: `{ \"nofile\" }`\n\nBuffer types to ignore.\n\n\u003e[!NOTE]\n\u003e `nofile` buffers may use folds for various things, so we ignore them.\n\n### ignore_filetypes\n\n- Type: `string[]`\n\nFile types to ignore.\n\n### condition\n\n- Type: `fun(buffer: integer, window: integer): boolean`\n\nFunction to determine if a window should be attached to. Used for defining additional conditions.\n\n### styles\n\n- Type: `foldtext.styles`\n\nStyles for different foldtexts.\n\n#### default\n\n- Type: `foldtext_part[]`\n\nParts for the default foldtext. See [parts](#-parts) for more info.\n\n#### custom_a\n\n- Type: `foldtext.custom_style`\n\nCustom style for the foldtext. Here it's named `custom_a`.\n\n##### filetypes\n\n- Type: `string[]`\n\nFile types where this style should be enabled.\n\n##### buftypes\n\n- Type: `string[]`\n\nBuffer types where this style should be enabled.\n\n##### condition\n\n- Type: `fun(buffer: integer, window: integer): boolean`\n\nAddition conditions for this style.\n\n##### parts\n\n- Type: `foldtext_part[]`\n\nParts for this foldtext. See [parts](#-parts) for more info.\n\n### 🔄 Migration\n\nThese are the option name changes for `v2.0.0`.\n\n```diff\nexample.lua\n {\n-    ft_ignore = {},\n+    ignore_filetypes = {},\n\n-    bt_ignore = {},\n+    ignore_buftypes = {},\n\n-    default = {},\n-    custom = {},\n+    styles = {\n+        default = {},\n+        a = {}\n+    }\n }\n```\n\nParts have also been changed. These are,\n\n#### Deprecated: raw\n\nHas been deprecated in favor of `section`.\n\n```diff\nraw.lua\n {\n-    type = \"raw\",\n+    kind = \"section\",\n\n     condition = function ()\n         return true;\n     end\n\n-    text = \"abcd\",\n-    hl = \"Comment\"\n+    output = {\n+       { \"abcd\", \"Comment\" },\n+    }\n }\n```\n\n#### Deprecated: fold_size\n\nHas new options \u0026 option name changes,\n\n```diff\nfold_size.lua\n {\n+    condition = function ()\n+        return true;\n+    end\n\n-    type = \"fold_size\",\n+    kind = \"fold_size\",\n \n     hl = \"Special\",\n \n+    padding_left = nil,\n+    padding_left_hl = nil,\n\n+    padding_right = nil,\n+    padding_right_hl = nil,\n\n+    icon = nil,\n+    icon_hl = nil,\n }\n```\n\n#### Deprecated: indent\n\nHas new option \u0026 option name change,\n\n```diff\nindent.lua\n {\n+    condition = function ()\n+        return true;\n+    end\n\n-    type = \"indent\",\n+    kind = \"indent\",\n \n     hl = \"Comment\"\n }\n```\n\n#### Deprecated: custom\n\nHas been removed in favor of `section`,\n\n```diff\ncustom.lua\n {\n+    condition = function ()\n+        return true;\n+    end\n\n-    type = \"custom\",\n+    kind = \"section\",\n \n-    handler = function (window, buffer)\n-        return {\n-            { \"text\" }\n-        };\n-    end\n+    output = function (buffer, window)\n+        return {\n+            { \"text\" }\n+        };\n+    end\n }\n```\n\n## 🧩 Parts\n\nSome built-in parts are provided in the plugin. These are,\n\n### bufline\n\nShows the buffer line with tree-sitter syntax highlighting. Has the following options,\n\n```lua\n{\n    kind = \"bufline\",\n    -- Optional condition for this\n    -- part.\n    condition = function ()\n        return true;\n    end\n\n    -- Delimiter between the start/end line.\n    delimiter = \"...\",\n    -- Highlight group for `delimiter`.\n    hl = \"@comment\"\n}\n```\n\n### description\n\nConventional commit styled fold description. Has the following options,\n\n```lua\n{\n    kind = \"description\",\n    -- Optional condition for this\n    -- part.\n    condition = function ()\n        return true;\n    end\n\n    -- Pattern to detect the foldtext from the start line.\n    -- Here I am using, \"feat: Keymaps\" \u0026 \"fix, Something's not right here\"\n    pattern = '[\\'\"](.+)[\\'\"]',\n    styles = {\n        default = {\n            hl = \"@comment\",\n            icon = \"💭 \",\n            icon_hl = nil\n        },\n\n        -- Style for `doc`(case-insensitive).\n        -- Options are merged with `default`\n        -- before being used.\n        doc = {\n            -- hl, icon_hl are inherited from\n            -- `default`.\n            icon = \"📚 \",\n        }\n    }\n}\n```\n\n### section\n\nA section of the foldtext. Has the following options,\n\n```lua\n{\n    kind = \"section\",\n    -- Optional condition for this\n    -- part.\n    condition = function ()\n        return true;\n    end\n\n    -- Text to show for this section. Has\n    -- the same structure as virtual text.\n    -- [ text, highlight_group ][]\n    output = {\n        { \"Hello, Neovim!\", \"Comment\" }\n    },\n    -- Can also be a function!\n    output = function (buffer, window)\n        return {\n            { \"Buf: \" .. buffer },\n            { \"Win: \" .. window },\n        };\n    end\n}\n```\n\n### fold_size\n\nShows the fold size. Has the following option,\n\n```lua\n{\n    kind = \"fold_size\",\n    -- Optional condition for this\n    -- part.\n    condition = function ()\n        return true;\n    end\n\n    -- Highlight group for the entire\n    -- part.\n    hl = \"@comment\",\n\n    icon = \"←→ \",\n    icon_hl = nil,\n\n    padding_left = \" \",\n    padding_left_hl = nil,\n\n    padding_right = \" \",\n    padding_right_hl = nil,\n}\n```\n\n### indent\n\nAdds the fold's starting line's indentation. Has the following options,\n\n```lua\n{\n    kind = \"indent\",\n    -- Optional condition for this\n    -- part.\n    condition = function ()\n        return true;\n    end\n\n    hl = nil\n}\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foxy2dev%2Ffoldtext.nvim","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foxy2dev%2Ffoldtext.nvim","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foxy2dev%2Ffoldtext.nvim/lists"}