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

fix: Support omnifunc's alternative return type (dict) #10

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

wookayin
Copy link

@wookayin wookayin commented Aug 29, 2023

As per :help complete-functions, a complete function may return a list
or a dictionary { words = <list>, refresh = 'always' }. This was not
previously recognized, silently resulting in "no completion results".

An example of such omnifunc is vim.treesitter.query.omnifunc().

In order to return more information than the matching words, return a Dict
that contains the List.  The Dict can have these items:
	words		The List of matching words (mandatory).
	refresh		A string to control re-invocation of the function
			(optional).
			The only value currently recognized is "always", the
			effect is that the function is called whenever the
			leading text is changed.
Other items are ignored.

Note: workaround for vim.treesitter.query.omnifunc by monkey-patching until this gets merged:

-- Workaround /~https://github.com/hrsh7th/cmp-omni/pull/10
vim.treesitter.query.omnifunc = function(...)
  local ret = require('vim.treesitter._query_linter').omnifunc(...)
  return type(ret) == "table" and ret.words or ret
end

As per :help complete-functions, a complete function may return a list
or a dictionary { words = <list>, refresh = 'always' }. This was not
previously recognized, silently resulting in "no completion reuslts".

An example of such omnifunc is `vim.treesitter.query.omnifunc()`.
@wookayin
Copy link
Author

Note: #4 also includes this kind of fix /cc @hrsh7th @akh2008

@wookayin
Copy link
Author

/cc @hrsh7th Bumping this up.

@wookayin
Copy link
Author

@hrsh7th Bumping this up again.

@wookayin
Copy link
Author

@hrsh7th

@ribru17
Copy link

ribru17 commented May 24, 2024

@hrsh7th Please merge 🥲

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.

2 participants