自动完成在Vim中 [英] Autocompletion in Vim

查看:136
本文介绍了自动完成在Vim中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在概括地说,我在寻找一个工作自动完成对Vim编辑器功能。我 的Vim能完全取代Linux下的IDE前认为,虽然这是肯定是真的,它缺少一个重要特点:自动完成

In a nutshell, I'm searching for a working autocompletion feature for the Vim editor. I've argued before that Vim completely replaces an IDE under Linux and while that's certainly true, it lacks one important feature: autocompletion.

我知道<大骨节病>控制 + <大骨节病> N 旺盛Ctags的整合,< A HREF =htt​​p://vim-taglist.sourceforge.net/>标记列表, cppcomplete OmniCppComplete 。唉,这些都不适合我的说明工作自动完成:

I know about Ctrl+N, Exuberant Ctags integration, Taglist, cppcomplete and OmniCppComplete. Alas, none of these fits my description of "working autocompletion:"


  • <大骨节病>控制 + <大骨节病> N 作品很好(只),如果你已经福尔戈如何拼写,而。哦。

  • Ctags的为您提供了雏形,但有很多弊端。

  • 标记列表只是Ctags的包装,因此,继承其大部分缺点(尽管它非常适用的清单的声明)。

  • cppcomplete 只是如许不工作,我想不出我做错了什么,或者如果它的工作正常和限制是由设计。

  • OmniCppComplete 似乎有同样的问题cppcomplete,即自动完成不能正常工作。此外,标记再次文件需要手动更新。

  • Ctrl+N works nicely (only) if you've forgotton how to spell class, or while. Oh well.
  • Ctags gives you the rudiments but has a lot of drawbacks.
  • Taglist is just a Ctags wrapper and as such, inherits most of its drawbacks (although it works well for listing declarations).
  • cppcomplete simply doesn't work as promised, and I can't figure out what I did wrong, or if it's "working" correctly and the limitations are by design.
  • OmniCppComplete seems to have the same problems as cppcomplete, i.e. auto-completion doesn't work properly. Additionally, the tags file once again needs to be updated manually.

我知道的事实,甚至没有现代化的,成熟的集成开发环境提供了良好的C ++ code完成。这就是为什么我已经接受Vim的在这方面缺乏直到现在。但我认为,code完成的基本水平并不过分的要求,并在生产性用途所需的事实。所以我在寻找的东西,至少可以做到以下的事情。

I'm aware of the fact that not even modern, full-blown IDEs offer good C++ code completion. That's why I've accepted Vim's lack in this area until now. But I think a fundamental level of code completion isn't too much to ask, and is in fact required for productive usage. So I'm searching for something that can accomplish at least the following things.


  • 语法意识。 cppcomplete许诺(但不提供对我来说),以下正确的,范围感知自动完成:

  • Syntax awareness. cppcomplete promises (but doesn't deliver for me), correct, scope-aware auto-completion of the following:

variableName.abc
variableName->abc
typeName::abc

真的,别的是完全无用的。

And really, anything else is completely useless.

可配置即可。我需要指定(容易)所在的源文件,因此那里的脚本得到它的自动完成信息。其实,我有我的目录一个Makefile,指定所需的包含路径。 Eclipse可以跨preT的信息在其中发现,为什么不Vim的脚本呢?

Configurability. I need to specify (easily) where the source files are, and hence where the script gets its auto-completion information from. In fact, I've got a Makefile in my directory which specifies the required include paths. Eclipse can interpret the information found therein, why not a Vim script as well?

截至到现代化程度即可。当我改变的东西在我的文件,我想自动完成,以反映这一点。我做的的要手动触发的ctags (或相媲美的东西)。此外,变化应的增量的,即当我改变只是一个文件,它是完全的接受的为的ctags 重新-parse整个目录树(可能是巨大的)。

Up-to-dateness. As soon as I change something in my file, I want the auto-completion to reflect this. I do not want to manually trigger ctags (or something comparable). Also, changes should be incremental, i.e. when I've changed just one file it's completely unacceptable for ctags to re-parse the whole directory tree (which may be huge).

难道我忘了什么吗?随时更新。

Did I forget anything? Feel free to update.

我舒服了不少配置和/或修补,但我不想编程从头一个解决方案,我不擅长调试Vim脚本。

I'm comfortable with quite a lot of configuration and/or tinkering but I don't want to program a solution from scratch, and I'm not good at debugging Vim scripts.

最后一点,我真的像Java和C#类似的东西,但我想这是太多的希望:的ctags 只能通过解析code文件和Java和C#有需要进行索引巨大,precompiled框架。不幸的是,开发.NET没有一个IDE 更是一个比PITA C ++的。

A final note, I'd really like something similar for Java and C# but I guess that's too much to hope for: ctags only parses code files and both Java and C# have huge, precompiled frameworks that would need to be indexed. Unfortunately, developing .NET without an IDE is even more of a PITA than C++.

推荐答案

尝试 YouCompleteMe 。它采用锵通过libclang接口,提供语义的C / C ++ / Objective-C的完成。这很像clang_complete,但大大快和模糊匹配。

Try YouCompleteMe. It uses Clang through the libclang interface, offering semantic C/C++/Objective-C completion. It's much like clang_complete, but substantially faster and with fuzzy-matching.

在除了上述,YCM还提供语义完成了C#,Python和围棋,打字稿等,还规定了它不具有语义支持语言非语义,基于标识符的完成。

In addition to the above, YCM also provides semantic completion for C#, Python, Go, TypeScript etc. It also provides non-semantic, identifier-based completion for languages for which it doesn't have semantic support.

这篇关于自动完成在Vim中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆