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

completor#do('complete') returns 0 #236

Closed
habamax opened this issue Nov 26, 2018 · 4 comments
Closed

completor#do('complete') returns 0 #236

habamax opened this issue Nov 26, 2018 · 4 comments

Comments

@habamax
Copy link

habamax commented Nov 26, 2018

Looks like after the latest update of the plugin I can no longer call completor#do('complete') to call completion. Now it returns 0 as a text.

How can I manually call completor completion now? (I use it with tab together with ultisnips and it worked for me well)

completor-issue

@habamax
Copy link
Author

habamax commented Nov 26, 2018

And just in case, setup that worked for me (tab to trigger snippet or jump to next placeholder or open completion menu or complete next):

" UltiSnips and Completor {{{
if has('python') || has('python3')
	let g:UltiSnipsExpandTrigger = '<tab>'
	let g:UltiSnipsJumpForwardTrigger = '<tab>'

	packadd ultisnips

	" Completor and ultisnips to reuse TAB key
	fun! Tab_Or_Complete() "{{{
		call UltiSnips#ExpandSnippet()
		if g:ulti_expand_res == 0
			if pumvisible()
				return "\<C-n>"
			else
				call UltiSnips#JumpForwards()
				if g:ulti_jump_forwards_res == 0
					" If completor is not open and we are in the middle of typing a word then
					" `tab` opens completor menu.
					let inp_str = strpart( getline('.'), col('.')-3, 2 )
					if col('.')>1 && (inp_str =~ '^\w$' || inp_str =~ '\%(->\)\|\%(.\w\)\|\%(\w\.\)\|\%(./\)')
						return "\<C-R>=completor#do('complete')\<CR>"
					else
						return "\<TAB>"
					endif
				endif
			endif
		endif
		return ""
	endf "}}}

	au InsertEnter * exec "inoremap <silent> " . g:UltiSnipsExpandTrigger . " <C-R>=Tab_Or_Complete()<cr>"

	" should be together if auto trigger is off
	let g:completor_complete_options = "menuone,preview"
	let g:completor_min_chars = 1
	let g:completor_auto_trigger = 0

	packadd completor.vim

endif

@habamax
Copy link
Author

habamax commented Nov 26, 2018

Looks like you have changed it to use timers...

I am not sure if the following is a proper way to fix my issue but:

function! completor#do(action) range
  if exists('s:timer') && !empty(timer_info(s:timer))
    call timer_stop(s:timer)
  endif
  let meta = {'range': [a:firstline, a:lastline]}
  let status = completor#action#current_status()
  let s:timer = timer_start(g:completor_completion_delay, {t->s:do_action('complete', meta, status)})
  return ''
endfunction

I have just added return '' to the function.

PS

By the way, now your new version of the function do not propagate action parameter to s:do_action function as it was in previous versions. If this is intended behavior, param from completor#do(action) could be removed, probably?

@maralla
Copy link
Owner

maralla commented Nov 26, 2018

Thanks for reporting! This is a bug. And the commit f5bddd6 fixed it.

@habamax
Copy link
Author

habamax commented Nov 26, 2018

Thx! Looks like it is fixed for me!

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

No branches or pull requests

2 participants