-
Notifications
You must be signed in to change notification settings - Fork 21
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
Conversation
function! asyncomplete#sources#tmuxcomplete#register(opts) | ||
let l:opts = extend(extend({}, a:opts), { | ||
\ 'name': 'tmuxcomplete', | ||
\ 'whitelist': ['*'], |
There was a problem hiding this comment.
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' |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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]), |
There was a problem hiding this comment.
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.
@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. |
e63902e
to
b735399
Compare
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.
bd918fa
to
5f60dba
Compare
looks good to me. Other users might want some docs on how to change the config values. |
with default options
0912fe7
to
1e2876d
Compare
1e2876d
to
34a877d
Compare
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 |
Looks good. |
Close #76
Edit: You don't need anything to enable it, it gets registered with default options automatically.
@kepbod @prabirshrestha: Do you want to have a look? You should be able to test it like this: