{"id":19737115,"url":"https://github.com/arnaud-lb/vim-php-namespace","last_synced_at":"2025-04-09T09:11:08.050Z","repository":{"id":1424744,"uuid":"1560851","full_name":"arnaud-lb/vim-php-namespace","owner":"arnaud-lb","description":"PHP namespace support for VIM. Types \"use\" statements for you","archived":false,"fork":false,"pushed_at":"2022-04-27T20:24:49.000Z","size":68,"stargazers_count":256,"open_issues_count":10,"forks_count":28,"subscribers_count":11,"default_branch":"master","last_synced_at":"2025-04-02T02:40:42.909Z","etag":null,"topics":["namespace","php","vim","vim-php","vim-plugin"],"latest_commit_sha":null,"homepage":"","language":"Vim script","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"composer/getcomposer.org","license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/arnaud-lb.png","metadata":{"files":{"readme":"README.markdown","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2011-04-02T21:08:08.000Z","updated_at":"2025-02-27T08:00:14.000Z","dependencies_parsed_at":"2022-08-16T13:20:13.382Z","dependency_job_id":null,"html_url":"https://github.com/arnaud-lb/vim-php-namespace","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/arnaud-lb%2Fvim-php-namespace","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arnaud-lb%2Fvim-php-namespace/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arnaud-lb%2Fvim-php-namespace/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arnaud-lb%2Fvim-php-namespace/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/arnaud-lb","download_url":"https://codeload.github.com/arnaud-lb/vim-php-namespace/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248008630,"owners_count":21032556,"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":["namespace","php","vim","vim-php","vim-plugin"],"created_at":"2024-11-12T01:09:45.029Z","updated_at":"2025-04-09T09:11:08.026Z","avatar_url":"https://github.com/arnaud-lb.png","language":"Vim script","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Goal\n\n[vim-php-namespace](https://github.com/arnaud-lb/vim-php-namespace) is a vim plugin for inserting \"use\" statements automatically.\n\n## Features\n\n### Import classes, functions, traits, or enums (add use statements)\n\nImports the symbol under the cursor by adding the corresponding `use` statement.\n\nTo use this feature, add the following mappings in `~/.vimrc`:\n\n    function! IPhpInsertUse()\n        call PhpInsertUse()\n        call feedkeys('a',  'n')\n    endfunction\n    autocmd FileType php inoremap \u003cLeader\u003eu \u003cEsc\u003e:call IPhpInsertUse()\u003cCR\u003e\n    autocmd FileType php noremap \u003cLeader\u003eu :call PhpInsertUse()\u003cCR\u003e\n\n\nThen, typing `\\u` in normal or insert mode will import the symbol under the cursor.\n\n``` php\n\u003c?php\nnew Response\u003c-- cursor here or on the name; hit \\u now to insert the use statement\n```\n\n### Make symbol fully qualified\n\nExpands the symbol under the cursor to its fully qualified name.\n\nTo use this feature, add the following mappings  in `~/.vimrc`:\n\n    function! IPhpExpandClass()\n        call PhpExpandClass()\n        call feedkeys('a', 'n')\n    endfunction\n    autocmd FileType php inoremap \u003cLeader\u003ee \u003cEsc\u003e:call IPhpExpandClass()\u003cCR\u003e\n    autocmd FileType php noremap \u003cLeader\u003ee :call PhpExpandClass()\u003cCR\u003e\n\nThen, typing `\\e` in normal or insert mode will expand the symbol to its fully qualified name.\n\n``` php\n\u003c?php\n$this-\u003egetMock('RouterInterface\u003c-- cursor here or on the name; type \\e now to expand the class name'\n```\n\n### Sort existing use statements alphabetically\n\nTo use this feature, add the following mappings  in `~/.vimrc`:\n\n    autocmd FileType php inoremap \u003cLeader\u003es \u003cEsc\u003e:call PhpSortUse()\u003cCR\u003e\n    autocmd FileType php noremap \u003cLeader\u003es :call PhpSortUse()\u003cCR\u003e\n\nThen, hitting `\\s` in normal or insert mode will sort use statements.\n\nIt is also possible to sort statements automatically after a PhpInsertUse()\nby defining the following variable:\n\n    let g:php_namespace_sort_after_insert = 1\n\n## Installation:\n\n### Using [pathogen](https://github.com/tpope/vim-pathogen)\n\n``` sh\ngit clone git://github.com/arnaud-lb/vim-php-namespace.git ~/.vim/bundle/vim-php-namespace\n```\n\n### Using [vim-plug](https://github.com/junegunn/vim-plug)\n\nAdd to vimrc:\n\n``` vim\nPlug 'arnaud-lb/vim-php-namespace'\n```\n\nRun command in vim:\n\n``` vim\n:PlugInstall\n```\n\n### Using [vundle](https://github.com/gmarik/vundle)\n\nAdd to vimrc:\n\n``` vim\nBundle 'arnaud-lb/vim-php-namespace'\n```\n\nRun command in vim:\n\n``` vim\n:BundleInstall\n```\n\n### Manual installation\n\nDownload and copy `plugin/phpns.vim` to `~/.vim/plugin/`\n\n## Post installation\n\n### Generate a tag file\n\nThe plugin makes use of tag files. If you don't already use a tag file you may create one with the following command; after having installed the `ctags` package:\n\n    ctags -R --PHP-kinds=cfi\n\n#### Traits\n\n[universal-ctags] supports traits natively (with `--php-kinds=cfit`).\n\nIf you can't use universal-ctags, the `--regex-php` argument allows to extract traits:\n\n    ctags -R --PHP-kinds=cfi --regex-php=\"/^[ \\t]*trait[ \\t]+([a-z0_9_]+)/\\1/t,traits/i\"\n\nYou can also create a `~/.ctags` file with the following contents:\n\n    --regex-php=/^[ \\t]*trait[ \\t]+([a-z0_9_]+)/\\1/t,traits/i\n\nNote that using `--regex-php=` is 10x slower than using universal-ctags.\n\n#### Enums\n\nThe `--regex-php` argument can be used to extract enums:\n\n    ctags -R --PHP-kinds=cfi --regex-php=\"/^[ \\t]*enum[ \\t]+([a-z0_9_]+)/\\1/e,enum/i\"\n\nYou can also create a `~/.ctags` file with the following contents:\n\n    --regex-php=/^[ \\t]*enum[ \\t]+([a-z0_9_]+)/\\1/e,enum/i\n\n#### Automatically updating tags\n\nThe [AutoTags](http://www.vim.org/scripts/script.php?script_id=1343) plugin can update the tags file every time a file is created or modified under vim.\n\nTo keep updates fast, AutoTags won't operate if the tags file exceeds 7MB. To avoid exceeding this limit on projects with many dependencies, use a separate tags file for dependencies:\n\n    # dependencies tags file (index only the vendor directory, and save tags in ./tags.vendors)\n    ctags -R --PHP-kinds=cfi -f tags.vendors vendor\n\n    # project tags file (index only src, and save tags in ./tags; AutoTags will update this one)\n    ctags -R --PHP-kinds=cfi src\n\nDo not forget to load both files in vim:\n\n    \" ~/.vimrc\n    set tags+=tags,tags.vendors\n\n### Key mappings\n\nSee [Features](#features) section for adding key mappings.\n\nThe `\u003cLeader\u003e` key usually is `\\`.\n\n## Credits:\n\n * Arnaud Le Blanc\n * [Contributors](https://github.com/arnaud-lb/vim-php-namespace/graphs/contributors)\n\nThis was originally based on a similar script for java packages found at http://vim.wikia.com/wiki/Add_Java_import_statements_automatically (in comments).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farnaud-lb%2Fvim-php-namespace","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Farnaud-lb%2Fvim-php-namespace","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farnaud-lb%2Fvim-php-namespace/lists"}