brandon1024/cortado.vim

feature: import classes under cursor from tag files

Closed this issue · 1 comments

Most of the plugins I've seen for adding imports aren't great. They either require a fair bit of project-specific configuration, or shell out to python for help.

Instead of that, let's implement this by leveraging tag files. universal-ctags is pretty powerful and works quite well with Java source files. It correctly picks out the names of classes and sets the kind field accordingly. We can use the taglist() builtin to find class names.

The tricky part is getting the full package path. Although we could probably get it from the filename field, this won't work in all cases. I think a better bet is to try and lookup the package statement in the file and build the package path ourselves. This will be quite difficult with nested classes, so we might have to leave that to a later date.

We might want to rename the plugin after this is implemented.

Implemented!