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

76 Add support for asyncomplete #77

Merged
merged 13 commits into from
Nov 28, 2017
Merged

76 Add support for asyncomplete #77

merged 13 commits into from
Nov 28, 2017

Conversation

wellle
Copy link
Owner

@wellle wellle commented Nov 24, 2017

Close #76

Edit: You don't need anything to enable it, it gets registered with default options automatically.

To enable it add this to your vimrc:

let g:tmuxcomplete#asyncomplete_source_options = {}

@kepbod @prabirshrestha: Do you want to have a look? You should be able to test it like this:

Plug 'wellle/tmux-complete.vim', { 'branch': '76-asyncomplete' }

function! asyncomplete#sources#tmuxcomplete#register(opts)
let l:opts = extend(extend({}, a:opts), {
\ 'name': 'tmuxcomplete',
\ 'whitelist': ['*'],

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

based on the order seems like whitelist can't be modified by the user.

if a:event ==? 'stdout'
let a:opt['buffer'] .= join(a:data)

elseif a:event ==? 'exit'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would check the exit code instead of assuming it always succeeds. When a:event is 'exit', a:data is the exit code.

function! asyncomplete#sources#tmuxcomplete#completor(opt, ctx)
" taken from asyncomplete-buffer
let l:kw = matchstr(a:ctx['typed'], '\w\+$')
let a:opt['kwlen'] = len(l:kw)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should treat a:opt and a:ctx as immutable . You can create your own dict instead

let a:opt['buffer'] = ''

let l:jobid = async#job#start(l:cmd, {
\ 'on_stdout': function('s:handler', [a:opt, a:ctx]),

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since you are passing your options. you could add a:ctx as part of the option.

@wellle
Copy link
Owner Author

wellle commented Nov 25, 2017

@prabirshrestha: Thank you for the review! I think I addressed all your points and added some more improvements to the integration. Please have another look.

To enable it add this to your vimrc:
let g:tmuxcomplete#asyncomplete_source_options = {}
Use own params instead, including ctx
And other options by preferring the injected opts over default values.
Check exit code of command, reset copletion on error
Split async callback functions
Show incomplete candidates as they come in
Add commented out debug logs
Cache mapped candidates
Show incomplete results sligthly different than complete ones
Returns lines with leading non word characters removed. Possible to
complete both lines and words in one run.

Add undocumented -n flag to disable result sorting to be better
streamable.
'splitmode', 'filter_prefix', 'show_incomplete', 'sort_candidates'

See code comment below for details.
@prabirshrestha
Copy link

looks good to me. Other users might want some docs on how to change the config values.

@wellle wellle force-pushed the 76-asyncomplete branch 3 times, most recently from 0912fe7 to 1e2876d Compare November 28, 2017 21:52
@wellle wellle changed the title WIP Add support for asyncomplete 76 Add support for asyncomplete Nov 28, 2017
@wellle
Copy link
Owner Author

wellle commented Nov 28, 2017

Great! I added some documentation and made another change to actually register the source automatically (it's already guarded by your user autocommand) with default options.

Do you want to have a final look here? After that I'll merge and add the asyncomplete topic. 😉

@prabirshrestha
Copy link

Looks good.

@wellle wellle merged commit 3412f3a into master Nov 28, 2017
@wellle wellle deleted the 76-asyncomplete branch November 28, 2017 22:42
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.

None yet

2 participants