{"id":23280943,"url":"https://github.com/claby2/genfmt.vim","last_synced_at":"2025-08-10T07:06:05.151Z","repository":{"id":112527083,"uuid":"300930805","full_name":"claby2/genfmt.vim","owner":"claby2","description":"🧼 Generic code formatting utility","archived":false,"fork":false,"pushed_at":"2021-04-06T11:07:35.000Z","size":10,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-06T13:39:55.095Z","etag":null,"topics":["formatter","vim","vim-plugin"],"latest_commit_sha":null,"homepage":"","language":"Vim script","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/claby2.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,"publiccode":null,"codemeta":null}},"created_at":"2020-10-03T16:53:51.000Z","updated_at":"2021-04-06T11:07:38.000Z","dependencies_parsed_at":"2023-03-14T20:15:46.627Z","dependency_job_id":null,"html_url":"https://github.com/claby2/genfmt.vim","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/claby2/genfmt.vim","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/claby2%2Fgenfmt.vim","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/claby2%2Fgenfmt.vim/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/claby2%2Fgenfmt.vim/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/claby2%2Fgenfmt.vim/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/claby2","download_url":"https://codeload.github.com/claby2/genfmt.vim/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/claby2%2Fgenfmt.vim/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269688329,"owners_count":24459442,"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","status":"online","status_checked_at":"2025-08-10T02:00:08.965Z","response_time":71,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["formatter","vim","vim-plugin"],"created_at":"2024-12-19T23:39:41.750Z","updated_at":"2025-08-10T07:06:05.103Z","avatar_url":"https://github.com/claby2.png","language":"Vim script","funding_links":[],"categories":[],"sub_categories":[],"readme":"# genfmt.vim\n\nGeneric code formatting utility. \nThis vim plugin utilizes user-defined external tools to format code.\n\n## Getting Started\n\n### Installation\n\nIt is recommended that you use a plugin manager to install.\n\nThis example uses vim-plug.\n\n#### [vim-plug](https://github.com/junegunn/vim-plug)\n\n```vim\ncall plug#begin()\nPlug 'claby2/genfmt.vim'\ncall plug#end()\n```\n\n## Usage\n\n-   `:GenfmtFormat`\n    -   Format the current buffer\n\n### Defining Formatters\n\n`genfmt.vim` works by running an external tool and replacing the current buffer with its standard output.\nExternal tools must be defined and correlated with a corresponding filetype (`\u0026filetype`).\n\nExample configuration:\n\n```vim\nlet g:genfmt_formatters = {\n            \\ 'python': \"yapf\",\n            \\ 'cpp': \"clang-format --style=\\\"{BasedOnStyle: Google, IndentWidth: 4}\\\"\",\n            \\ }\n```\n\nIn this example, if the formatter is run in a python file, it would run [`yapf`](https://github.com/google/yapf).\nLikewise, the formatter would run [`clang-format`](https://clang.llvm.org/docs/ClangFormat.html) with the given style argument in a cpp file. \n\n### Custom Vim Function\n\nDefining a custom vim function that returns the formatter command used allows for additional control if you wish to do so.\nFor example, specifying the name of the file may influence the output of some formatters.\n\nExample:\n\n```vim\nfunction! ClangFormat()\n    return \"clang-format --assume-filename=\".expand('%:t').\" -style=file\"\nendfunction\n\nlet g:genfmt_formatters = {\n            \\ 'cpp': \"ClangFormat()\",\n            \\ }\n```\n\nThe `ClangFormat()` function returns a command with an argument (`assume-filename`) specifying the name of the file that will be formatted.\n\nWhen defining the formatter under `genfmt_formatters`, it is important to pass the name of the function with `()` at the end of the string.\n\n### Fallback Formatters\n\nIn the case where no formatter is found for the filetype, `genfmt.vim` can format the code by indenting, retabbing, and removing trailing whitespace.\nTo enable this, set the following variable to 1 (default value is 0).\n\n```vim\nlet g:genfmt_enable_fallback = 1\n```\n\nAdditionally, you can define custom commands to run as a fallback.\nThe following represents the default commands.\n\n```vim\nlet g:genfmt_fallback = [\"%s/\\\\s\\\\+$//e\", \"retab\", \"normal! gg=G\"]\n```\n\nWhen the fallback formatter is called, the commands in `g:genfmt_fallback` will be silently executed.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fclaby2%2Fgenfmt.vim","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fclaby2%2Fgenfmt.vim","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fclaby2%2Fgenfmt.vim/lists"}