udalov / kotlin-vim

Kotlin plugin for Vim. Featuring: syntax highlighting, basic indentation, Syntastic support
Apache License 2.0
630 stars 52 forks source link

Code completion #6

Open pardom-zz opened 7 years ago

pardom-zz commented 7 years ago

Let's have Kotlin completions!!! πŸ˜„

I've forked this repo to start working on completions, but it would be nice to collaborate on a feature branch here. I've never written a Vim plugin, so I'm using this as a guide: https://github.com/artur-shaik/vim-javacomplete2

They're using an AST parser, which Kotlin provides as an embeddable dependency (I've used it here: https://github.com/notion/kotlin-format). If this doesn't fit into the scope of this repo, I can close this issue and start a new project.

pardom-zz commented 7 years ago

Oh, just noticed you're on the JB team and probably already know everything involved with creating a completions plugin. πŸ˜† Thoughts on the amount of work this might take given the existing tools in https://github.com/JetBrains/kotlin?

udalov commented 7 years ago

Hi, thanks for the feature request. I'm afraid implementing code completion via looking up symbols by kotlin-compiler-embeddable would be too slow for any real world scenario. I think the only way this could be useful is if it's fast enough, and I just don't see any way to make it fast at this point. Maybe some other, mostly heuristic, approach should be taken.

pardom-zz commented 7 years ago

It appears that most of the heavy lifting in javacomplete2 is done with another jar running as a daemon. I could be wrong, but it doesn't look like the parser is used for much.

https://github.com/artur-shaik/vim-javacomplete2/tree/master/libs/javavi/src/main/java/kg/ash/javavi

udalov commented 7 years ago

If that is indeed the case, I suppose you could try and see how fast this would actually be. I think a working prototype wouldn't take much time, however you may need to create a custom build of kotlin-compiler-embeddable if you discover that there's no API to do something, and that would require getting familiar with the Kotlin project itself and how it's built.

smolck commented 5 years ago

@udalov Is this something you do want to see implemented in this project? Considering that KotlinLanguageServer exists, it may not be worth the work (having used said LSP a little bit, it seems to work fine and as intended, although YMMV). May be wrong though, since some people don’t want to deal with installing and setting up an LSP; having things all in one place can be nice.