Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Completion context #214

Merged
merged 1 commit into from May 17, 2015
Merged

Completion context #214

merged 1 commit into from May 17, 2015

Conversation

Deraen
Copy link
Contributor

@Deraen Deraen commented May 17, 2015

Fixes #212

This is still work in progress but I opened this for comments and help.

My current strategy is to first yank from start of toplevel form to cursor and then from cursor to end of the form. Problem is that the latter yank is not working.

@Deraen
Copy link
Contributor Author

Deraen commented May 17, 2015

I got this working by yanking the whole toplevel form in one operation and then using strpart to select start and end parts. To find the cursor position I calculate number of characters in yanked text from start of the form to cursor pos.

screenshot

@tpope
Copy link
Owner

tpope commented May 17, 2015

You're saving 'selection' and 'clipboard' but best I can tell aren't changing them to safe values. If you can manage it, I would rather avoid that dance entirely and use getline(). I think this logic would work.

@Deraen
Copy link
Contributor Author

Deraen commented May 17, 2015

Thanks, that works.

Other comments before I start cleaning this?

@tpope
Copy link
Owner

tpope commented May 17, 2015

I haven't fully digested the logic but looks good to me. I would favor pulling s:pos_inside_selection inline.

If complete operation is given context property containing the
current toplevel form Compliment library can give better completion
results in some contexts:

- Local vars for let and defn
- Resources in classpath for io/resource calls
- Vars in specific ns for :require :refer
- Better Java class name completion for :import

The context string should contain symbol __prefix__ in place of the word
being completed. To achieve this location of cursor inside the toplevel
form is calculated so that the placeholder symbol can be placed in the
proper place.
@Deraen Deraen changed the title NOT READY: Completion context Completion context May 17, 2015
@Deraen
Copy link
Contributor Author

Deraen commented May 17, 2015

Okay should be cleared now.

tpope added a commit that referenced this pull request May 17, 2015
@tpope tpope merged commit 89aee9c into tpope:master May 17, 2015
@tpope
Copy link
Owner

tpope commented May 17, 2015

Thanks for figuring this out; I'm excited to try it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support for completion context
2 participants