whitequark / sublime-ocp-index

Sublime Text plugin which provides OCaml autocompletion with ocp-index
MIT License
17 stars 1 forks source link

Alt+a is not greedy enough #6

Closed whitequark closed 10 years ago

whitequark commented 10 years ago

For example, it doesn't eat ', which are valid in identifiers.

TheSpyder commented 10 years ago

We probably need to use the identifier regex in a forward search, rather than my quick-fix "sublime expand to word" solution :)

whitequark commented 10 years ago

But how to go backwards?

TheSpyder commented 10 years ago

Searching backwards uses the existing code from completion. If it needs to be more permissive, maybe the query function does need to be split for completion vs type inspection.

whitequark commented 10 years ago

See, goa'uld is a valid identifier. If you position the cursor between l and d, it should work.

TheSpyder commented 10 years ago

goa'uld is also broken for autocompletion (type goa'ul <ctrl+space>). It shows the generic local let binding, not the full completion. We need to adjust the regex to include ' :)

In fact, do we need to include the generic local let bindings at all? The switch to -F and --context should pick those up now...

whitequark commented 10 years ago

Would it pick up bar in let foo _ = let bar = 1 in <cursor> ? If yes, feel free to drop it.

TheSpyder commented 10 years ago

Looks like no. You can test that yourself - the autocomplete shows type "let" for the locally detected variables, and a proper type for the ocp-index ones. I guess context is only really useful for opens :)

whitequark commented 10 years ago

I was just checking -- perhaps you know ocp-index better than I do. :) Then let sniffing probably stays. I really don't like it, it's silly and flawed and doesn't respect lexical scope and doesn't pick up bindings in patterns, but it's still quite useful.

whitequark commented 10 years ago

I've considered using sublime's "scopes" feature to pull out bindings from patterns, but the highlighting file is completely incomprehensible and it doesn't have a specific scope for one variable inside pattern. Rather, it highlights everything that is not a variable inside a pattern in a differing way. :/

TheSpyder commented 10 years ago

I think we're hitting the limits of what can be done without running merlin in the background as vim/emacs do :)

Pretty easy fix in the end, I didn't quite understand what the regex was doing before.

whitequark commented 10 years ago

awesome. There are some plans for merlin, but they're blocked on upstream (cc @def-lkb)