{"id":13412302,"url":"https://github.com/code-biscuits/nvim-biscuits","last_synced_at":"2025-03-14T18:31:13.251Z","repository":{"id":40415919,"uuid":"352421120","full_name":"code-biscuits/nvim-biscuits","owner":"code-biscuits","description":"A neovim port of Assorted Biscuits. Ends up with more supported languages too.","archived":false,"fork":false,"pushed_at":"2024-04-20T22:48:46.000Z","size":1676,"stargazers_count":243,"open_issues_count":5,"forks_count":11,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-07-31T20:50:10.705Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/code-biscuits.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":"2021-03-28T19:35:17.000Z","updated_at":"2024-07-26T06:38:50.000Z","dependencies_parsed_at":"2024-01-03T03:29:43.684Z","dependency_job_id":"f45af52d-a5da-413f-9af8-8c36396e1d85","html_url":"https://github.com/code-biscuits/nvim-biscuits","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/code-biscuits%2Fnvim-biscuits","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/code-biscuits%2Fnvim-biscuits/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/code-biscuits%2Fnvim-biscuits/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/code-biscuits%2Fnvim-biscuits/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/code-biscuits","download_url":"https://codeload.github.com/code-biscuits/nvim-biscuits/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221495290,"owners_count":16832453,"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-07-30T20:01:23.197Z","updated_at":"2024-10-26T04:30:24.534Z","avatar_url":"https://github.com/code-biscuits.png","language":"Lua","readme":"# nvim-biscuits\n\nEvery dev needs something sweet sometimes. Code Biscuits are in-editor annotations usually at the end of a closing tag/bracket/parenthesis/etc. They help you get the context of the end of that AST node so you don't have to navigate to find it.\n\n## Demo\n\nHere you can see the plugin being used on a Go file with `cursor_line_only` turned on.\n\n![Demo of the plugin being used on a Golang file](./assets/demo.gif)\n\n## Installation\n\nIn your nvim config, add the Plug dependencies:\n\nUsing Vim Plug:\n\n```lua\ncall plug#begin()\nPlug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'}\nPlug 'code-biscuits/nvim-biscuits'\ncall plug#end()\n```\n\nUsing Packer:\n\n```lua\nuse {\n  'code-biscuits/nvim-biscuits',\n  requires = {\n    'nvim-treesitter/nvim-treesitter',\n     run = ':TSUpdate'\n  },\n}\n\n```\n\nYou will also need to configure which language parsers you want to have enabled for tree-sitter. \"maintained\" currently will install 40 languages. \"all\" will install even more.\n\n```lua\nlua \u003c\u003cEOF\nrequire'nvim-treesitter.configs'.setup {\n  ensure_installed = \"maintained\",\n  ...\n}\nEOF\n```\n\n## Configuration\n\nBasic configuration is simple:\n\n```lua\nlua require('nvim-biscuits').setup({})\n```\n\nYou can also configure your own global defaults as well as language specific defaults.\n\nThis is just an example config.\n\n```lua\nlua \u003c\u003cEOF\nrequire('nvim-biscuits').setup({\n  default_config = {\n    max_length = 12,\n    min_distance = 5,\n    prefix_string = \" 📎 \"\n  },\n  language_config = {\n    html = {\n      prefix_string = \" 🌐 \"\n    },\n    javascript = {\n      prefix_string = \" ✨ \",\n      max_length = 80\n    },\n    python = {\n      disabled = true\n    }\n  }\n})\nEOF\n```\n\n## Configuration (Custom events)\n\nIf you want to decorate only on specific vim events you can use the `on_events` config option. It is a string that takes in a comma separated list of vim autocmd events ([http://vimdoc.sourceforge.net/htmldoc/autocmd.html#autocmd-events](http://vimdoc.sourceforge.net/htmldoc/autocmd.html#autocmd-events))\n\nThis example only updates the biscuits when leaving insert mode or hold the cursor in one place for long enough.\n\n```lua\nlua \u003c\u003cEOF\nrequire('nvim-biscuits').setup({\n  on_events = { 'InsertLeave', 'CursorHoldI' }\n})\nEOF\n```\n\n## Configuration (Virtual Text Color)\n\nYou can configure the `highlight` group in your init.vim:\n\n```lua\n\n\" global color\nhighlight BiscuitColor ctermfg=cyan\n\n\" language specific color\nhighlight BiscuitColorRust ctermfg=red\n\n```\n\n## Configuration (Disabling Languages)\n\nYou may have tree-sitter set up for some languages in which you don't want nvim-biscuits to show up. Since we just use whatever supported languages tree-sitter has by default, you must disable languages individually.\n\nTo disable nvim-biscuits for any language, simply add `{ mylanguage = {disabled = true} }` to `language_config` field in setup. (where `mylanguage` is the language that you want to disable. eg: `python`, `dart`, etc)\n\n## Configuration (Trim by words)\n\nUsing this settings, you can dictate the max length of a biscuit using whole words rather than just characters. The `max_length` determines how many words will show when this setting is enabled.\n\n```lua\nlua \u003c\u003cEOF\nrequire('nvim-biscuits').setup({\n  max_length = 2,\n  trim_by_words = true,\n})\nEOF\n```\n\n## Configuration (Keybinding to toggle visibility)\n\nYou can show or hide the biscuits by placing a `toggle_keybind` at the root of your config or inside a language config.\n\nWe also expose an optional flag, `show_on_start`, to enable biscuits to show on initial load. This value defaults to `false`;\n\n```lua\nlua \u003c\u003cEOF\nrequire('nvim-biscuits').setup({\n  toggle_keybind = \"\u003cleader\u003ecb\",\n  show_on_start = true -- defaults to false\n})\nEOF\n```\n\nOR\n\n```lua\nlua \u003c\u003cEOF\nrequire('nvim-biscuits').setup({\n  language_config = {\n    rust = {\n      toggle_keybind = \"\u003cleader\u003ecb\"\n    }\n  }\n})\nEOF\n```\n\nIf you prefer to bind manually, the function is exposed as:\n\n```lua\nrequire('nvim-biscuits').toggle_biscuits()\n```\n\n## Configuration (Cursor Line Only)\n\nYou can configure the biscuits to only show on the line that has your cursor. This can be useful if you find that default config makes the text too cluttered\n\n```lua\nlua \u003c\u003cEOF\nrequire('nvim-biscuits').setup({\n  cursor_line_only = true\n})\nEOF\n```\n\n## Configuration (Max File Size)\n\nYou can set a maximum file size to bail out of biscuits if you think they are slowing down your editor. The value can be a string evaluating to a human readable file size or a number in bytes. Values are 1024 based. Supported case-insensitive suffixes: b, kb, kib, mb, mib, gb, gib, tb, tib, pb, pib\n\n```lua\nlua \u003c\u003cEOF\nrequire('nvim-biscuits').setup({\n  max_file_size = '100kb'\n})\nEOF\n```\n\n## Configuration (lazy.nvim support)\n\nIf you are using [lazy.nvim](https://github.com/folke/lazy.nvim), you will have to wire up nvim-biscuits is a specific way.\n\nSince you are using lazy.nvim, it is recommended to not use the internal nvim-biscuits [visibilty toggle](https://github.com/code-biscuits/nvim-biscuits?tab=readme-ov-file#configuration-keybinding-to-toggle-visibility).\n\nWhen setting your `keys` value, you just need to call `BufAttach` inside the callback function:\n\n```lua\nkeys = {\n  {\n    \"\u003cleader\u003ebb\",\n    function()\n      require(\"nvim-biscuits\").BufferAttach()\n    end,\n    mode = \"n\",\n    desc = \"Enable Biscuits\",\n  },\n},\n```\n\nIf you want to lazy load nvim-biscuits but also use the internal visibilty toggle, there are a couple ways of setting things up. If you are letting `show_on_start` default to `false`, you will need to manually toggle the biscuits in the callback function.\n\n```lua\nkeys = {\n  {\n    \"\u003cleader\u003ebb\",\n    function()\n      local nvim_biscuits =\n      require(\"nvim-biscuits\")\n      nvim_biscuits.BufferAttach()\n      nvim_biscuits.toggle_biscuits()\n    end,\n    mode = \"n\",\n    desc = \"Enable Biscuits\",\n  },\n},\n```\n\nA cleaner way of doing it is to set `show_on_start` to true for nvim-biscuits. Then, you do not need to call `toggle_biscuits` in your lazy.nvim callback.\n\n## Supported Languages\n\nWe currently support all the languages supported in tree-sitter. Not all languages have specialized support, though most will probably need some.\n\nAs we make tailored handlers for specific languages we will create a table here to track that.\n\n## Development\n\nWhile doing local dev, it can be nice to use the `utils.console_log` command to write runtime logs to `~/.cache/nvim/nvim-biscuits.log`.\n\nYou can turn this on by passing DEBUG=true as an environment variable when launching Neovim.\n\n## License\n\nCopyright 2021 Chris Griffing\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","funding_links":[],"categories":["Utility","Lua"],"sub_categories":["Cursorline"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcode-biscuits%2Fnvim-biscuits","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcode-biscuits%2Fnvim-biscuits","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcode-biscuits%2Fnvim-biscuits/lists"}