vim-tagbar-ctags-elm


Ⅰ. 插件描述

Support for Elm in Vim Tagbar with Universal Ctags

Ⅱ. 基本信息

创建日期:  2016-11-20
使用用户:  7
Github星:  8
插件作者:  Mark Skipper

Ⅲ. 安装方法

使用Vundle管理器安装

在你的.vimrc下添加:
Plugin 'bitterjug/vim-tagbar-ctags-elm'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall

对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。

使用NeoBundle管理器安装

在你的.vimrc下添加:
NeoBundle 'bitterjug/vim-tagbar-ctags-elm'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall

使用VimPlug管理器安装

在你的.vimrc下添加:
Plug 'bitterjug/vim-tagbar-ctags-elm'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall

使用Pathogen管理器安装

在终端中运行以下命令:
cd ~/.vim/bundle
git clone https://github.com/bitterjug/vim-tagbar-ctags-elm

Ⅳ. 文档说明

# vim-tagbar-ctags-elm

Support for Elm in Vim Tagbar with Universal Ctags (doesn't work with Exuberant Ctags or any earlier stuff)

elm-tagbar-ctags

Features

  • Universal Ctags options for Elm supporting:

    • [ ] modules
    • [x] type definitions
    • [x] type aliases
    • [x] functions
    • [x] nested functions

        **Note**: Uses the [scope tracking](http://docs.ctags.io/en/latest/optlib.html#scope-tracking-in-a-regex-parser) features of Universal Ctags, so won't work with Exuberant Ctags. If you want to use Exuberant Ctags, you need [ctags-elm](https://github.com/kbsymanz/ctags-elm).
      
    • [x] ports
    • [x] imports
  • Vim Tagbar extension showing the checked kinds.

Install

It's a Pathogen-friendly Vim plugin. Install it with a package manager.

Bugs and limitations

  • Only top level function definitions (with no white space before the function name) define scopes for nesting. E.g. in the screen shot above the _ binding is defined in a let expression in one of the cases further down in the updateField function.
  • Doesn't respect block comments (u-ctags doesn't currently support them with regex parsers)
  • The regexps assumes your source is laid out according to elm-format.
  • Does not set the module as a scope, becase it's hard to parse significant whitespace with regular expressions. We don't know when functions end (to pop the scope) so instead we set the scope at the start of each new top-level function. If the module were a containing scope, the first top level function would clear it out.
  • Doesn't distinguish functions by airity. We talked about this; it doesn't seem like a good idea.

Relationship to other projects

This is an experimental project; when it's a bit more mature, and Universal Ctags a bit more common it will probably end up as one or more of the following:

Ctags-elm got me started (thanks Kurt!). It works with Exuberant Ctags, but doesn't support scoped tags.

Elm-vim already provides tagbar support for ctags-elm. In order for this project to live nicely alongside that we overwrite g:tagbar_type_elm. (There might be a more polite way of going about this?)

Thanks to the excellent regular expressions 101 for helping me figure out how to match and capture what I needed. And to the excellent work of Universal Ctags.

添加新评论