{"id":24206195,"url":"https://github.com/shimman-dev/laundry.nvim","last_synced_at":"2025-03-03T13:42:14.360Z","repository":{"id":264021152,"uuid":"882859022","full_name":"shimman-dev/laundry.nvim","owner":"shimman-dev","description":"👔 folding our imports in tidy little piles 🧺","archived":false,"fork":false,"pushed_at":"2025-02-13T22:52:53.000Z","size":21,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-02-13T23:33:14.939Z","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/shimman-dev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","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-11-03T23:35:07.000Z","updated_at":"2025-02-13T22:52:56.000Z","dependencies_parsed_at":"2024-11-21T15:44:54.365Z","dependency_job_id":null,"html_url":"https://github.com/shimman-dev/laundry.nvim","commit_stats":null,"previous_names":["shimman-dev/laundry.nvim"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shimman-dev%2Flaundry.nvim","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shimman-dev%2Flaundry.nvim/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shimman-dev%2Flaundry.nvim/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shimman-dev%2Flaundry.nvim/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shimman-dev","download_url":"https://codeload.github.com/shimman-dev/laundry.nvim/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241676956,"owners_count":20001601,"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":"2025-01-14T00:19:29.373Z","updated_at":"2025-03-03T13:42:14.353Z","avatar_url":"https://github.com/shimman-dev.png","language":"Lua","funding_links":[],"categories":[],"sub_categories":[],"readme":"# laundry.nvim 🧺\n\nWhen you need to fold a lengthy stack of imports in your preferred language. 👔\n\n![pinny doing laundry](./assets/pinny-laundry-nvim.png)\n\n## Requirements\n\n[passed on my first audition](https://www.youtube.com/watch?v=8coWvoSgrOs#t=1m29s)\n\n- [Neovim \u003e= 0.9.0](https://neovim.io/)\n- [nvim-treesitter](https://github.com/nvim-treesitter/nvim-treesitter)\n\n## Features\n\n- Automatically folds import statements in your code\n- Language-specific fold configurations\n- Currently supports TypeScript, JavaScript, and Go (wow three whole languages? Visit the\n[CONTRIBUTING.md](./CONTRIBUTING.md) to learn how to add additional languages)\n- Configurable minimum fold thresholds\n\n## Installation\n\n\u003cdetails\u003e\n\u003csummary\u003elazy.nvim\u003c/summary\u003e\n\n```lua\n{\n    \"shimman-dev/laundry.nvim\",\n\tpriority = 1000,\n    requires = { 'nvim-treesitter/nvim-treesitter' },\n\tevent = { \"BufReadPost\", \"BufNewFile\" },\n    dependencies = {\n        \"nvim-treesitter/nvim-treesitter\",\n    },\n\t---@module 'laundry'\n\t---@type LaundryConfig\n    opts = {\n        auto_fold = true, -- default value is false, need to opt-in for plugin\n    }\n}\n```\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003epacker.nvim\u003c/summary\u003e\n\n```lua\nuse {\n    'shimman-dev/laundry.nvim',\n    requires = { 'nvim-treesitter/nvim-treesitter' },\n    config = function()\n        require('laundry').setup({\n            auto_fold = true, -- default value is false, need to opt-in for plugin\n        })\n    end\n}\n```\n\u003c/details\u003e\n\n## Commands\n\n- `:LaundryFold` - Manually fold import statements in the current buffer,\nrespects `min_fold_lines`\n- `:LaundryForceFold` - Manually fold import statements in the current buffer,\nignores `min_fold_lines`\n\n## Notes\n\n- If `min_fold_lines` is not set in either the global config or language-specific config, no folding will occur\n- Language-specific settings take precedence over global settings unless overridden by user configuration\n\n## Configuration\n\nEverything but the kitchen sink options (lazy.nvim):\n\n```lua\n{\n    \"shimman-dev/laundry.nvim\",\n    dependencies = {\n        \"nvim-treesitter/nvim-treesitter\",\n    },\n    opts = {\n\t\t-- NOTE: not initially set to true, must opt-in the plugin\n        -- Whether to automatically fold imports when opening files\n        auto_fold = false,\n\n        -- Global minimum number of import lines before folding\n        -- If not set, will use language-specific settings\n        -- min_fold_lines = 25,\n\n        -- Filetypes that will be folded (if `auto_fold` is true)\n        enabled_filetypes = {\n            \"typescript\",\n            \"typescriptreact\",\n            \"javascript\",\n            \"javascriptreact\",\n            \"go\",\n        },\n\n        -- Language-specific configurations\n        languages = {\n            -- Override settings for TypeScript\n            typescript = {\n                min_fold_lines = 10,  -- Only fold if there are \u003e=10 lines of imports\n            },\n        },\n    }\n}\n```\n\n### Adding Support for Additional Languages\n\nExample showing how to add Python support:\n\n```lua\nrequire('laundry').setup({\n    auto_fold = true,\n    enabled_filetypes = { \"python\" },  -- Enable for Python\n    languages = {\n        python = {\n            -- Patterns determine which files this config applies to\n            file_patterns = { \"*.py\" },\n\n            -- These are the TreeSitter node types that represent imports\n            -- For Python they are:\n            -- - import_statement: for \"import foo\"\n            -- - import_from_statement: for \"from foo import bar\"\n            import_node_types = { \n                \"import_statement\",\n                \"import_from_statement\"\n            },\n\n            -- Most languages don't need aliases, but some like\n            -- TypeScript/JavaScript might have multiple file extensions\n            aliases = {},\n\n            -- Only fold when there are \u003e=10 import lines\n            min_fold_lines = 10,\n        }\n    }\n})\n```\n\nTo find the correct `TreeSitter` node types for other languages:\n1. Open a file of your target language\n2. Place your cursor on an import statement\n3. Run `:InspectTree` to see the syntax tree\n4. Look for the node type that encompasses the import statement\n\n\u003cdetails\u003e\n\u003csummary\u003eExamples of Different Configurations\u003c/summary\u003e\n\n1. Minimal setup (uses defaults):\n```lua\nrequire('laundry').setup()\n```\n\n1. Opt-in auto-folding:\n```lua\nrequire('laundry').setup({\n    auto_fold = true,\n})\n```\n\n2. Auto-fold with custom threshold:\n```lua\nrequire('laundry').setup({\n    auto_fold = true,\n    min_fold_lines = 3,\n})\n```\n\n3. Language-specific thresholds:\n```lua\nrequire('laundry').setup({\n    auto_fold = true,\n    languages = {\n        typescript = { min_fold_lines = 10 },\n        javascript = { min_fold_lines = 8 },\n        python = { min_fold_lines = 5 },\n    }\n})\n```\n\n4. Manual folding only (no auto-fold):\n```lua\nrequire('laundry').setup({\n    auto_fold = false, -- Fold when using :LaundryForceFold\n})\n```\n\u003c/details\u003e\n\n## Current Language Support\n\n\u003cdetails\u003e\n\u003csummary\u003eLanguage Support Matrix\u003c/summary\u003e\n\n- [Go](https://go.dev/)\n- [Typescript](https://www.typescriptlang.org/)\n\u003c/details\u003e\n\n## Todo\n\n- [x] whimmsy up the `README.md`\n- [x] create an art icon\n- [x] create a `CONTRIBUTING.md`\n- [ ] create a benchmark tests (folding 1k, 10k, 100k, 1000k imports)\n- [ ] create a basic unit test suite\n- [ ] in a future neovim release: [folding can be handled via the LSP](https://github.com/neovim/neovim/pull/31311) will need to account for this change. Will need to handle `LSP` and `treesitter` options.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshimman-dev%2Flaundry.nvim","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshimman-dev%2Flaundry.nvim","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshimman-dev%2Flaundry.nvim/lists"}