Vim: Making Auto-Completion Smarter

后端 未结 7 569
忘了有多久
忘了有多久 2020-12-22 23:49

I use ctags, taglist, etc., to have auto completion in Vim. However, it is very limited compared to Visual Studio intellisense or Eclipse auto-completion. I am wondering whe

相关标签:
7条回答
  • 2020-12-23 00:21

    To make vim trigger a certain behavior when a key is pressed you need to map the key to a function.

    For instance to map the key . to call some type of completion when in INSERT mode you would need to do:

    :inoremap <expr> <buffer> . MyFunction()
    

    and then the function would need to evaluate the context where it was called and present an appropriate answer to the user.

    Edit: This is the basis of how clang complete mentioned by @honk works.

    I'm not sure if you can customize the behavior of omnifunc to meet your needs but on my experience, I never went too far. As @Mikhail said, you would need to keep track of things which in practice means interpreting or even running the code to some extent.

    0 讨论(0)
提交回复
热议问题