Open psiska opened 3 years ago
entry_maker
gets called for each line. So for example for fd
we call entry_maker with each file, which will generate a table with value, display, ordinal etc ... I am not sure how this should work if we first split the contents in the entry_maker
because we kinda only can return one item. If i recall correctly we can't return a table of table/items but i need to recheck :)
For the vimL is not allowed in tight lua callback. You can fix that issue if you basically reimplement a json_decode
in lua. So you can look at https://github.com/rxi/json.lua e.g. and just ship that file. Its MIT so it shouldn't be a problem.
You could also do something like this which could be way eaiser (similar to some of the git ones and symbols:
hoogle
with utils.get_os_command_output
vim.fn.json_decode
finders.new_table
with table of decoded lines as resultsI think that should generally work but will block, depending how long hoogle
needs to complete that query (i have no idea about that :laughing:)
Okay you can't use finders.new_job
because it will process each item/on_stdout line on its own. It was originally designed for ripgrep where each line is a new item. See https://github.com/nvim-telescope/telescope.nvim/blob/3a7fa41857394cd2d90d00891413c12fada039c3/lua/telescope/finders.lua#L63-L73
So you would need to write a new finder similar to JobFinder that allows you to process multiple lines or that JobFinder does the decoding and query entry_maker for each decoded item. I think something like this should be possible.
Feel free to ask more question is something isn't clear either here or in our telescope gitter room :)
Thanks for great pointers and assistance.
This was exactly what I was looking for. And sorry for spamming the issue tracker, I haven't noticed the gitter channel. If I hit problem again I will ask there.
Hello, I have prepared PR which provides utility to achieve the goal in this issue (create multiple results from single line).
How can I help to have PR-681 merged?
There is one linting failure - not from my change. What is expected here? Ignore it since it is not related to PR or fix it?
I am trying to create plugin for querying local hoogle database (haskell hoogle). Source can be found at https://github.com/psiska/telescope-hoogle.nvim
Overview:
I've hit several obstacles. 1) entry_maker is supposed to create 1 entry for one line. However I get all entries in one line 2) I cannot decode json via vim.fn.json_decode in entry_maker since I receive E5560 error (cannot use vim function in callback)
Help needed: since I am new to lua and neovim, how should I solve point 2 ?
Solution: