{"id":25936684,"url":"https://github.com/thomas-hiron/cmp-symfony","last_synced_at":"2026-05-14T07:35:27.784Z","repository":{"id":280158027,"uuid":"941141856","full_name":"thomas-hiron/cmp-symfony","owner":"thomas-hiron","description":"nvim-cmp source for Symfony autocompletions","archived":false,"fork":false,"pushed_at":"2025-04-25T07:35:51.000Z","size":408,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-25T08:39:20.993Z","etag":null,"topics":["neovim","neovim-plugin","neovim-plugin-lua","nvim-cmp"],"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/thomas-hiron.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":"2025-03-01T15:37:26.000Z","updated_at":"2025-04-25T07:35:55.000Z","dependencies_parsed_at":"2025-03-01T17:19:07.869Z","dependency_job_id":null,"html_url":"https://github.com/thomas-hiron/cmp-symfony","commit_stats":null,"previous_names":["thomas-hiron/cmp-symfony"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/thomas-hiron/cmp-symfony","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thomas-hiron%2Fcmp-symfony","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thomas-hiron%2Fcmp-symfony/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thomas-hiron%2Fcmp-symfony/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thomas-hiron%2Fcmp-symfony/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thomas-hiron","download_url":"https://codeload.github.com/thomas-hiron/cmp-symfony/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thomas-hiron%2Fcmp-symfony/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33015538,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-13T13:14:54.681Z","status":"online","status_checked_at":"2026-05-14T02:00:06.663Z","response_time":57,"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":["neovim","neovim-plugin","neovim-plugin-lua","nvim-cmp"],"created_at":"2025-03-04T02:45:16.850Z","updated_at":"2026-05-14T07:35:27.779Z","avatar_url":"https://github.com/thomas-hiron.png","language":"Lua","funding_links":[],"categories":[],"sub_categories":[],"readme":"# cmp-symfony\n\n[nvim-cmp](https://github.com/hrsh7th/nvim-cmp) source for many\nSymfony completions:\n- Behat steps\n- HTML classes\n- Symfony form options\n- Symfony routes\n- Symfony translations\n- Twig constants\n- Twig filters and functions\n- Twig templates\n\n## Required deps\n\n- [fd](https://github.com/sharkdp/fd) for twig templates\n- [jq](https://github.com/jqlang/jq) for form options\n- [nvim-treesitter](https://github.com/nvim-treesitter/nvim-treesitter) for form options (with PHP parser)\n- [ripgrep](https://github.com/BurntSushi/ripgrep) to search for \nbehat steps, constants, filters and functions\n\n## Global setup\n\n```lua\nrequire('cmp').setup({\n  sources = {\n    { name = 'behat' },\n    { name = 'form_options' },\n    { name = 'html_class' },\n    { name = 'symfony_routes' },\n    { name = 'symfony_translations' },\n    { name = 'twig' },\n    { name = 'twig_constants' },\n    { name = 'twig_templates' },\n  },\n})\n```\n\n## Available sources\n\n### 🎓 Behat steps\n\nSteps located in `vendor` and `behat` directories are handled.\n\n![Autocomplete](./docs/behat.png)\n\nSteps are refreshed every 60 seconds.\n\n#### Triggers\n\nThe plugin is activated for `cucumber` filetype.  \nThe trigger characters are `n` and `d`. This covers\n`Given`, `When`, `Then`, `And` keywords.\n\n### 📋 Form options\nForm option completion.\n\n![Autocomplete](./docs/form_options.png)\n\n#### Prerequisite\n\nThe completion is based on a file named `autocomplete_form_type.json`\nat the root of the project. It consists of a JSON array for each\nFormType as key and all available options as values.  \nThis file is obtained iterating over the results of:  \n```bash\nbin/console debug:form --format json # gets all form types\nbin/console debug:form --format json ChoiceType # for each for type\n```\n\nHere is the script I'm using to create this file:  \n\u003cdetails\u003e\n\u003csummary\u003eView script\u003c/summary\u003e\n\n```bash  \n#!/usr/bin/env bash\n\nfunction create_json() {\n    echo \"$1\" | jq -c '{\n        (.\"class\" | split(\"\\\\\") | last): (\n            [\n                .class as $class |\n                (.options.own // [] | map({(.): $class}) | add) as $own |\n                (.options.overridden // {} | to_entries | map({key: .value[], value: .key}) | from_entries) as $overridden |\n                (.options.parent // {} | to_entries | map({key: .value[], value: .key}) | from_entries) as $parent |\n                (.options.extension // {} | to_entries | map({key: .value[], value: .key}) | from_entries) as $extension |\n                $own + $overridden + $parent + $extension\n            ] | add\n        )\n    }'\n}\n\njson=$(docker compose run --rm franken-cli bin/console debug:form --format json)\n\necho \"\" \u003e /tmp/autocomplete_form_type.json\n\nbuiltin_types=$(echo \"$json\" | jq -r \".builtin_form_types[]\")\nservice_types=$(echo \"$json\" | jq -r \".service_form_types[]\")\n\nbuiltin_types_count=$(echo \"$builtin_types\" | wc -l)\nservice_types_count=$(echo \"$service_types\" | wc -l)\n\ncounter=0\necho \"[INFO] Creating builtin types\"\nfor builtin_type in $builtin_types; do\n    counter=$((counter+1))\n    echo \"$counter/$builtin_types_count: $builtin_type\"\n    json=$(docker compose exec franken bin/console debug:form --format json \"$builtin_type\")\n\n    create_json \"$json\" \u003e\u003e /tmp/autocomplete_form_type.json\ndone\n\ncounter=0\necho \"[INFO] Creating service types\"\nfor service_type in $service_types; do\n    counter=$((counter+1))\n    echo \"$counter/$service_types_count: $service_type\"\n    json=$(docker compose exec franken bin/console debug:form --format json \"$service_type\")\n\n    create_json \"$json\" \u003e\u003e /tmp/autocomplete_form_type.json\ndone\n\njq --slurp 'add' /tmp/autocomplete_form_type.json \u003e ./autocomplete_form_type.json\n```\n\u003c/details\u003e\n\nThis is rather hard to maintain, so duplicated FormType are not preserved.\n\n#### Triggers\n\nThe plugin is activated for `php` filetypes.  \nThe trigger character is a single quote, and the current buffer must `extends AbstractType`.  \nThe completion is triggered only on the left side of `=\u003e`.\n\n### 📌 HTML classes\n\nThis plugin autocompletes class tags using a pre-generated json file.  \n\n![Autocomplete](./docs/html_classes.png)\n\n#### Prerequisites\n\nA json file must be generated first. It contains one json object\nper line, with two keys:\n- _class_: the html class to autocomplete\n- _files_: a json array containing all files where this class is\ndefined\n\nHere is an example:\n```json\n{\"class\":\"my-first-class\",\"files\":[\"/path/to/file.css\",\"/path/to/file.min.css\"]}\n{\"class\":\"my-second-class\",\"files\":[\"/path/to/file.css\"]}\n```\n\n#### Generate the json file\n\nThe file is generated with this bash script:  \n\u003cdetails\u003e\n\u003csummary\u003eView script\u003c/summary\u003e\n\n```bash\n#!/usr/bin/env bash\n\ntemp_dir=$(mktemp -d)\n\n# Get all classes in css files, in json format, then use jq to get all matching\n# results and format them: {\"class\":\"my-first-class\",\"file\":\"/path/to/file.css\"}\nrg \"\\.[a-z][a-z0-9-]{3,}\" -tcss --no-filename --json assets | jq -c '. \n                                    | select(.type == \"match\") \n                                    | {class: .data.submatches[].match.text, file: .data.path.text}' \u003e $temp_dir/raw.json\n\n# Sort and uniq input file\ncat $temp_dir/raw.json | sort | uniq \u003e $temp_dir/uniq.json\n\n# Group results by class name and add a files key containing all files\ncat $temp_dir/uniq.json | jq -sc 'map(. + {data: [{class: [.class], file: [.file]}]})\n                                    | group_by(.class)[]\n                                    | .[0] + {files: [.[].data[].file | add]}\n                                    | del (.data, .file)' \u003e $temp_dir/grouped.json\n\n# Remove trailing dot in class name\nsed -i 's/\"\\./\"/' $temp_dir/grouped.json\n\nmv $temp_dir/grouped.json ~/generated_html_classes.json\n```\n\u003c/details\u003e\n\n#### Triggers\n\nThe plugin is activated for `twig` and `html` filetypes.  \nAutocompletion is triggered for double quotes and space\ncharacters.\n\n### 🛣️ Symfony routes\n\nThe source is using `./var/cache/dev/url_generating_routes.php` file.\n\nThis plugin is a very simple implementation, the autocomplete won't work\nif the above file doesn't exist.\n\n![Autocomplete](./docs/symfony_routes.png)\n\nRoutes are refreshed every 30 seconds.\n\n#### Triggers\n\nThe plugin is activated for `php` and `twig` filetypes.  \nThe trigger character is a single quote, and the line must contains\n`route`, `path` or `url`. This covers most of Symfony and twig\nfunctions used to generate URLs:\n- PHP\n  - redirectToRoute\n  - $router-\u003egenerate\n- Twig\n  - path\n  - url\n\n### 🔤 Symfony translations\n\nThe source is using `./var/cache/dev/translations/catalog.fr.SHA1.php` file.\n\nThis plugin the autocomplete won't work if the above file doesn't exist.\n\n![Autocomplete](./docs/symfony_translations.png)\n\nTranslations are refreshed every 60 seconds.\n\n#### Features\n\n- completes translation domains\n- documentation displays full french translation value\n- `-\u003eaddFlash` only displays `flashes_messages` translations\n- `message` attribute only displays `validators` translations\n\n#### Triggers\n\nThe plugin is activated for `php` and `twig` filetypes.  \nThe trigger character is a single quote, and the line must contains\n`trans`, `addflash`, `message:`, `'label' =\u003e` or `'choice_label' =\u003e`. This covers most of Symfony and twig\ntranslation functions:\n- PHP\n  - $translation-\u003etrans\n  - $this-\u003eaddFlash\n  - message attribute for validators\n  - form labels\n- Twig\n  - ''|trans({}, '')\n\n### 🌾 Twig constants\n\nThis plugin autocompletes PHP constants located in src directory for twig.  \n\n![Autocomplete](./docs/twig_constants.png)\n\nOutput is:  \n```twig\nconstant('App\\\\Voter\\\\MyVoter::CAN_EDIT')\n```\n\nConstants are refreshed every 60 seconds.\n\n#### Triggers\n\nThe plugin is activated for `twig` filetype only.  \nThe trigger character is a single quote, and the line must contains `constant` or `enum`.\n\n### 🌾 Twig filters and functions\n\nThis plugin autocompletes twig filters and functions located in \n`src` directory.  \nThe native filters and functions are also available.\n\nFilters:  \n![Autocomplete](./docs/twig_filters.png)\n\nFunctions:  \n![Autocomplete](./docs/twig_functions.png)\n\nFilters and functions are refreshed every 30 seconds.\n\n#### Triggers\n\nThe plugin is activated for `twig` filetype.  \nThere are three trigger characters:\n- pipe triggers filters completion\n- space and open parenthesis trigger functions completion\n\n### 🌾 Twig templates\n\nAutocompletes twig templates located in project directory /templates.  \n\n![Autocomplete](./docs/twig_templates.png)\n\nTemplates are refreshed every 30 seconds.\n\n#### Triggers\n\nThe plugin is activated for `php` and `twig` filetypes.  \nThe trigger character is a single quote, and the line must contains\n`render` or `include`. This covers most of Symfony and twig\nfunctions used to generate URLs:\n- PHP\n  - render\n  - renderView\n- Twig\n  - include\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthomas-hiron%2Fcmp-symfony","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthomas-hiron%2Fcmp-symfony","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthomas-hiron%2Fcmp-symfony/lists"}