tpope / vim-fireplace

fireplace.vim: Clojure REPL support
https://www.vim.org/scripts/script.php?script_id=4978
1.75k stars 139 forks source link

Completion context #214

Closed Deraen closed 9 years ago

Deraen commented 9 years ago

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 commented 9 years ago

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 commented 9 years ago

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 commented 9 years ago

Thanks, that works.

Other comments before I start cleaning this?

tpope commented 9 years ago

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

Deraen commented 9 years ago

Okay should be cleared now.

tpope commented 9 years ago

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