Objective-c 的 Ctags/Cscope 替代品?

发布于 2024-09-04 06:45:50 字数 230 浏览 2 评论 0原文

是否有任何具有 Objective-c 支持的 ctags 和 cscope 替代品?这确实与可可开发有关,所以我似乎不可避免地会使用 Xcode(并且可能应该)。我只是想知道我的 Vim 有哪些选择。

也许有某种类型的插件系统,例如 eclim,但是对于 xcode 来说?

编辑

所以看来除了更新 ctags 以支持 Objective-c 之外,我运气不好。有谁知道 cscope 是否相同?

Are there any alternatives to ctags and cscope with Objective-c support. This does pertain to cocoa development, so inevitably it seems I will be using Xcode (and probably should). I was just wondering what are my Vim options.

Maybe there is some type of plugin system like eclim, but for xcode?

EDIT

So it seems that other than updating ctags to support objective-c, I'm out of luck. Does anyone know if cscope is the same?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(9

月牙弯弯 2024-09-11 06:45:50

在这个问题出现很长一段时间后,用 vim“玩”,我想要 ObjC 支持,尤其是 taglist 插件。我发现了这个问题,然后挖掘了一下,这是一个不太脏的解决方案:

  1. An ObjectiveC parser 已添加到 Exuberant CTags 主干,尚未发布(还?)
  2. 您可以通过自制程序轻松将其安装在 OSX 上:

    $brew install ctags --HEAD

  3. 请注意使用 ctags 时,.m 被视为 Matlab,.h 被视为 C++。要覆盖,请使用:

    $ ctags --langmap=ObjectiveC:.mh

  4. 然后我将类似的内容添加到我的 .vimrc 中以获得标签列表支持:

    let tlist_objc_settings = 'ObjectiveC;P:协议;i:接口;类型(...)'

    从该列表中添加您感兴趣的任何类型:

    ctags --list-kinds=all
    目标C
        i类接口
        I类实现
        p 协议
        m 对象的方法
        c类的方法
        v 全局变量
        F 对象字段
        f 函数
        p 属性
        t 类型别名
        A型结构
        e 枚举
        MA 预处理器宏
    

我希望这会对某人有所帮助!

a long time after this question, "playing" with vim, I wanted ObjC support, especially with taglist plugin. I found that question, then digged a bit, and here is a not so dirty solution:

  1. An ObjectiveC parser has been added to Exuberant CTags trunk, it is not released (yet?)
  2. You can easily install it on OSX via homebrew:

    $ brew install ctags --HEAD

  3. Note that when using ctags, .m is treated as Matlab and .h is treated as C++. To override, use:

    $ ctags --langmap=ObjectiveC:.m.h

  4. Then I added something like this to my .vimrc for taglist support:

    let tlist_objc_settings = 'ObjectiveC;P:protocols;i:interfaces;types(...)'

    add any type interests you from that list:

    ctags --list-kinds=all
    ObjectiveC
        i  class interface
        I  class implementation
        p  Protocol
        m  Object's method
        c  Class' method
        v  Global variable
        F  Object field
        f  A function
        p  A property
        t  A type alias
        s  A type structure
        e  An enumeration
        M  A preprocessor macro
    

I hope that will help someone!

吃→可爱长大的 2024-09-11 06:45:50

Universal-ctags(https://ctags.io) 可以捕获 Objective-C 的属性。

[jet@localhost objectivec_property.h.d]$ cat input.h 

@interface Person : NSObject {
    @public
        NSString *m_name;
    @private
        int m_age;
}

@property(copy) NSString *personName;
@property(readonly) int personAge;

-(id)initWithAge:(int)age;
@end
[jet@localhost objectivec_property.h.d]$ ../../../ctags -x -o - input.h 
Person           interface     2 input.h          @interface Person : NSObject {
initWithAge:     method       12 input.h          -(id)initWithAge:(int)age;
m_age            field         6 input.h          int m_age;
m_name           field         4 input.h          NSString *m_name;
personAge        property     10 input.h          @property(readonly) int personAge;
personName       property      9 input.h          @property(copy) NSString *personName;

Universal-ctags(https://ctags.io) can capture properties of Objective-C.

[jet@localhost objectivec_property.h.d]$ cat input.h 

@interface Person : NSObject {
    @public
        NSString *m_name;
    @private
        int m_age;
}

@property(copy) NSString *personName;
@property(readonly) int personAge;

-(id)initWithAge:(int)age;
@end
[jet@localhost objectivec_property.h.d]$ ../../../ctags -x -o - input.h 
Person           interface     2 input.h          @interface Person : NSObject {
initWithAge:     method       12 input.h          -(id)initWithAge:(int)age;
m_age            field         6 input.h          int m_age;
m_name           field         4 input.h          NSString *m_name;
personAge        property     10 input.h          @property(readonly) int personAge;
personName       property      9 input.h          @property(copy) NSString *personName;
一杆小烟枪 2024-09-11 06:45:50

AFAIK,ctags 支持您为新语言定义一些规则,我在使用 laszlo(类似于 flex)进行一些开发时就这样做了。您可以阅读 ctags 的联机帮助页以获取更多详细信息,这并不难做到。

我发现有一个支持在cocoa下开发的vim文件类型插件 这里 ,希望对您有帮助。

AFAIK, ctags support you to define some rules for a new language, I did that when I did some development using laszlo(similiar to flex). You can read the manpage of ctags to get more details, that is not hard to do.

I find there is a vim filetype plugin that support development under cocoa here, hope it is helpful for you.

╰◇生如夏花灿烂 2024-09-11 06:45:50

可以选择将 ctags 用于 Objective-C。您可以在 ctags 模式下使用 etags。 etags是前段时间从ctags衍生出来的,在它的源码中会通过定义一定的宏开关来生成ctags兼容的标签。

事实上,Mac OS 中的手册页已经在同一页面中记录了 etag 和 ctag。它指出 ctags 支持 Objective-C。您应该能够使用以下命令生成标记文件:
ctags -l objc *.[mh]

不幸的是,Mac OS 中的 ctags 程序的行为并不像记录的那样,因为 Apple 搞砸了。然而,我成功地使用 Ubuntu Linux 安装了这种 ctags,并且效果很好!您必须在那里安装 emacs22-bin-common 软件包。

所以在 Mac OS 下你所要做的就是自己编译这个包。

  • 例如,从 Debian 服务器下载相应的源代码包(链接)。
  • 解压它并更改为源目录
  • run ./configure
  • configure 返回错误,因为它找不到 lispref
  • 我删除了创建的文件 config.status 中的变量 config_files 中的所有目标,尽管有 lib-src
  • run ./config.status
  • cd lib-src
  • make
  • 将 ctags 例如复制到 /usr/local/bin 并更改权限
    • sudo cp ctags /usr/local/bin
    • chmod a+rx /usr/local/bin/ctags

你就完成了。快乐标记!

There is an option to use ctags for objective-c. You can use etags in ctags mode. etags derived from ctags some time ago, and in its source code ctags compatible tags will be generated by defining a certain macro switch.

In fact the man page in Mac Os already documents etags and ctags in the same page. It states that objective-c is supported in ctags. You should be able to generate a tag file using the following command:
ctags -l objc *.[mh]

Unfortunately the ctags program in Mac OS behaves not as documented since Apple messed it up. I however managed to install this kind of ctags using Ubuntu Linux and it works great!!! There you have to install the emacs22-bin-common package.

So under Mac OS all you have to do is to compile this package for yourself.

  • Download the corresponding source package e.g. from the Debian server (link).
  • exctract it and change to the source directory
  • run ./configure
  • configure returns with an error because it cannot find lispref
  • I deleted all targets in varible config_files in the created file config.status despite the ones with lib-src
  • run ./config.status
  • cd lib-src
  • make
  • Copy ctags e.g. to /usr/local/bin and change permissions
    • sudo cp ctags /usr/local/bin
    • chmod a+rx /usr/local/bin/ctags

You are done. Happy tagging!!!

沉默的熊 2024-09-11 06:45:50

你也可以试试我写的objcscope。

objcsope

You can also try objcscope which is written by me.

objcsope

握住你手 2024-09-11 06:45:50

关于另一个答案:您可以相当轻松地使用 MacPorts 安装 EMACS,它将在 /opt/local/bin 中包含一个 etags 版本,其中编译了 Objective-C 支持。

% sudo port install emacs
% find . -name ‘*.[hm]’ -print0 | xargs −0 /opt/local/bin/etags

然后在 vim 中:

:setlocal tags=TAGS

这对我使用 MacVim 来说效果很好。

Apropos the other answer: you can install EMACS with MacPorts fairly easily and it will include a version of etags at /opt/local/bin that has Objective-C support compiled in.

% sudo port install emacs
% find . -name ‘*.[hm]’ -print0 | xargs −0 /opt/local/bin/etags

And then inside vim:

:setlocal tags=TAGS

This works well for me with MacVim.

度的依靠╰つ 2024-09-11 06:45:50

您可以尝试 Exuberant Ctags 的 Fishman 分支,它支持 Objective C 和 CSS。

You can try Fishman fork of Exuberant Ctags which has Objective C and CSS support.

霓裳挽歌倾城醉 2024-09-11 06:45:50

我发现让 ctags 为 tagbar 生成标签很困难。使用 Objective-C 编辑器的 vim 插件更容易。 XVim 可与 XCode 配合使用。如果你像我一样使用 Appcode,IdeaVim 集成得很好。

尽管您无法使用该插件获得完整的 Vi/Vim 功能。我发现与本机 IDE 命令的混合使用足以弥补这一不足。

I found it difficult getting ctags to generate tags for tagbar. It was easier to use a vim plugin for the Objective-C editor. XVim works with XCode. If you use Appcode like me, IdeaVim is well integrated.

Though you won't get to full Vi/Vim functionality with the plugin. I find mix usage with native IDE commands is enough to compensate.

知足的幸福 2024-09-11 06:45:50

如果我没记错的话:

最新的ctags现在错误地解析了@property关键字,
这可能会导致源代码中 @property 之后的所有单词
代码被解析为属性,导致文件标签混乱。

我必须重新编译 ctags (https://sourceforge.net/p/ctags/code /HEAD/tree/)通过注释 ObjC.c 中的所有属性关键字处理作为解决方法。尽管如此,它只会有助于更好地阅读 Taglist 中的源代码。

它仍然无法跳转(例如到实现
带参数的方法)正确。

我也尝试过这个(https://github.com/mcormier/ctags-ObjC-5.8 .1),但不幸的是这根本无法跳转。

总结: ObjC 似乎没有像 C/C++ 那样可行的 ctag。

If I am not wrong :

Latest ctags by now parsing the @property keyword incorrectly,
which could cause that all the words after @property in the source
code are parsed to be properties, leading to a mess in file tags.

I have to recompile ctags (https://sourceforge.net/p/ctags/code/HEAD/tree/) by commenting all of the property keyword processing in ObjC.c as a workaround. Even though, it only helps to get a little better for reading source code in the Taglist.

It still can't jump (e.g. to the implementation
methods with parameters) correctly.

I also tried this(https://github.com/mcormier/ctags-ObjC-5.8.1), but unfortunately this can't jump at all.

Summary : there seems no ctags for ObjC as workable as for C/C++.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文