You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何为Geany编辑器添加/扩展已知符号(函数名等)实现自动补全?

Extending Geany's PHP Autocompletion for Frameworks/CMS

Absolutely—Geany has you covered for expanding autocompletion to include your framework, CMS, or custom app core functions. You’ve got two reliable methods to make this happen: manual function header setup and automatic directory scanning with ctags. Let’s dive into each:

1. Manual Addition of Custom Function Tags

If you only need to add a handful of frequently used functions, manual editing works great. Here’s how:

  • First, locate Geany’s PHP tags file (or create a custom one to keep edits separate):
    • On Linux: ~/.config/geany/filedefs/php.tags
    • On Windows: %APPDATA%\Geany\filedefs\php.tags
    • Alternatively, make a new file like my_custom_tags.tags to avoid messing with default files (cleaner for Geany updates!).
  • Follow Geany’s tag format for PHP functions: each line follows function_name return_type (parameter_list)
    Example entries for a CMS:
    get_post    WP_Post    (int $id, bool $output = OBJECT)
    the_title    void    (string $before = '', string $after = '', bool $echo = true)
    
  • Load the tags file in Geany: Go to Edit > Preferences > Files > Tags, click Add, select your tags file, and check "Auto-reload tags files" so changes take effect automatically.

2. Automatic Scanning with Ctags (Best for Full Frameworks/CMS)

Manual entry isn’t feasible for large codebases—this is where ctags (built into Geany) comes in. It scans your entire framework directory and generates a tags file automatically:

  • Open your terminal and navigate to your framework/CMS core directory (e.g., WordPress wp-includes or Laravel app/vendor).
  • Run this ctags command to generate PHP-specific tags for functions, classes, and methods:
    ctags -R --languages=PHP --php-kinds=+f+c+m
    
    Breakdown:
    • -R: Recursively scan all subdirectories
    • --languages=PHP: Only process PHP files
    • --php-kinds=+f+c+m: Include functions (f), classes (c), and methods (m)—adjust this if you only want specific types (e.g., remove +c if you don’t need class autocompletion).
  • Rename the generated tags file to something descriptive (e.g., laravel.tags or wordpress.tags) and add it to Geany’s tags list using the same steps as above.
  • Pro tip: Whenever your framework/CMS updates, re-run the ctags command to refresh the tags file—Geany will auto-reload it if you enabled that setting.

Quick Extra Tips

  • For project-specific setups: Go to Edit > Preferences > Editor > Completion and add your framework’s core directories to "Extra Include Paths"—this helps Geany’s symbol lookup work faster.
  • If you work with multiple frameworks, create separate tags files for each so you can enable/disable them based on your current project.

Hope these methods give you the seamless autocompletion you need for your PHP framework/CMS projects! 🚀

内容的提问来源于stack exchange,提问作者jave.web

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.20 10:32:28