maralla / completor.vim

Async completion framework made ease.
MIT License
1.27k stars 63 forks source link

TernJS "complete_strings" built-in plugin doesn't interact well #238

Closed shea-parkes closed 5 years ago

shea-parkes commented 5 years ago

First of all, this is a great plugin, thanks for a simple, sane async-completion library.

It inspired me to even setup TernJS for javascript. It works quite well for basic semantic completion.

I tried to turn on Tern's first-party "complete_strings" plugin: https://github.com/ternjs/tern/blob/master/plugin/complete_strings.js

However, there seems to be a couple glitches when trying to use that tern plugin with completor.vim:

First, it oddly seems to only trigger on two characters. If I type a third character it all falls back to completor.vim's "ID" completions.

Second, the suggestions from the "complete_strings" plugin come back quoted, so they double the quotes when they land in vim.

I perfectly understand if you have no interest in supporting this tern plugin, but I thought I'd at least post this issue in case there was an easy answer, or if others come later and wonder the same thing.

Thanks again for a great plugin!

maralla commented 5 years ago

I added support for this plugin in commit 5987cfc1485b6dc4cccef2b1e538078b90a9acd1. Please try it out. You should disable auto pair vim plugins like https://github.com/jiangmiao/auto-pairs in case there has an unwanted closing quote.

shea-parkes commented 5 years ago

Thank you very much sir. I'll try it out soon and let you know how it works.

shea-parkes commented 5 years ago

It's definitely working better. The trigger seems to be working very consistently.

You were correct that it doesn't interact well with auto-pair plugins. I'll have to research how to make that work since I find those more valuable than this specific tern plugin.

It also is opinionated in that it flops over to double quotes, even though I prefer single quotes. That's likely also a deal breaker.

I might try and see if I can decipher the regex enough to just strip the quotes out of the suggested completion options. I understand why tern is offering them, but I don't think they're needed here.

Thanks again!

shea-parkes commented 5 years ago

So I did leave this on for the last week or so. I did uncover a pretty big problem that I believe https://github.com/maralla/completor.vim/commit/5987cfc1485b6dc4cccef2b1e538078b90a9acd1 introduced.

Running the version from that commit, the following happens:

var foo = "this is a string" + d3.ma| <- cursor at bar (at end) var foo = max| <- result of completing max (from d3.max)

It completes back to the start of the string on the line, wiping out far more than it should.

I imagine this is related to the new value for ident in https://github.com/maralla/completor.vim/commit/5987cfc1485b6dc4cccef2b1e538078b90a9acd1 , but I am running quite a few additional plugins, so it could be me. I'll try to dig into it some more soon, but in the meantime you might want to revert that commit.

Thanks again.

maralla commented 5 years ago

I think this is fixed by #245.