feature: ZkGrep / grep through note bodies #127
Replies: 8 comments 8 replies
-
Overall I agree that this would be interesting to have. Unfortunately |
Beta Was this translation helpful? Give feedback.
-
@Joelius300 Is this something you're still looking for? I too would appreciate this functionality, but likely something more like |
Beta Was this translation helpful? Give feedback.
-
Hi! I'm playing with something similar as well. for 2. Overall I don't see much value into for 1. and 3. I think it is already the case if your note has a title? (either an H1 with the title or a about 4. I would say also is implemented if you are using telescope. What I'm looking to see how to implement is to include note aliases as entries on the note picker. Something like:
which will let you open notes by aliases as well, showing the original title just after probably in a different color |
Beta Was this translation helpful? Give feedback.
-
I have an initial pass on this working! Since the operation is very similar to Telescope's
Do you want me to make a pull request for this? |
Beta Was this translation helpful? Give feedback.
-
My attempt is this. It just opens The utils is imported from astronvim ( Without all the comments and prints: ["<leader>zi"] = {
function()
local Terminal = require('toggleterm.terminal').Terminal
local output = 'NO OUTPUT'
local termOptions = {
cmd = "zk list -i -q -P -f json",
hidden = true,
close_on_exit = true,
-- store stdout from process
on_stdout = function(t, job, data, name)
if (data ~= nil) and (data[1] ~= '') then
output = data[1]
end
end,
-- grab path from json output after terminal closes (can then be used to open the file)
on_close = function(t)
local worked, parsed = pcall(vim.json.decode, output)
if worked == false then
utils.notify("COULD NOT PARSE: " .. parsed)
else
utils.notify(parsed[1].absPath)
end
end
}
-- create and open terminal, callbacks are set up
local zkList = Terminal:new(termOptions)
zkList:toggle()
end, desc = "Use `zk list -i`" }, Raw: ["<leader>zi"] = {
function()
local Terminal = require('toggleterm.terminal').Terminal
local output = 'NO OUTPUT'
local termOptions = {
cmd = "zk list -i -q -P -f json",
hidden = true,
close_on_exit = true,
on_stdout = function(t, job, data, name)
-- if #data[1] > 100 and #data[1] < 1500 then
-- utils.notify("very top" .. data[1])
-- end
if (data ~= nil) and (data[1] ~= '') then -- and (data[1].sub(1,2) == "[{") then
output = data[1]
-- utils.notify("just before sub" .. output)
-- if output:sub(1, 1) == '[' then
-- local len = string.len(output .. '')
-- utils.notify((output .. ''):sub(1, 20))
-- utils.notify(string.sub(output .. '', len-20, len))
-- utils.notify("after sub" .. output)
-- end
end
-- vim.cmd('e ' .. response.absPath)
-- utils.notify(response.absPath, vim.log.levels.WARN)
end,
--on_exit = function(t, job, exit_code, name)
--response = vim.json.decode(output)
--print(response)
--print('a' .. response.absPath)
--utils.notify(response.absPath, vim.log.levels.WARN)
--end,
on_close = function(t)
-- utils.notify("on_close")
-- local response = vim.json.decode(output)
-- utils.notify(response.absPath)
-- utils.notify(output:sub(1, 20)) # note that it appeared that sub modifies the string
-- but online it says it doesnt..
-- Current issue is that not the entirety of the output appears to be grabbed, for Named Entities
-- the initial bracket is often missing (1 in like 5 times it was there), others like LU-Zerlegung
-- aren't working at all?? maybe some cache issue but wtf
local worked, parsed = pcall(vim.json.decode, output)
if worked == false then
utils.notify("COULD NOT PARSE: " .. parsed)
else
utils.notify(parsed[1].absPath)
end
-- print(response)
-- print(output)
end
}
local zkList = Terminal:new(termOptions)
zkList:toggle()
end, desc = "Use `zk list -i`" }, |
Beta Was this translation helpful? Give feedback.
-
this is effectively the latest functionality of |
Beta Was this translation helpful? Give feedback.
-
Hey guys, I think my attempt is pretty close to what we're looking for. I'm going to try getting a PR up in the next couple weeks so y'all can test it out. The outstanding issues mentioned previously (I implemented this almost a year ago!) I think may need to be addressed on the zk side, but we can discuss that when we get there |
Beta Was this translation helpful? Give feedback.
-
draft PR is up at #171 |
Beta Was this translation helpful? Give feedback.
-
Thank you for zk-nvim, it's a great extension to zk.
I've been using
:ZkNotes
and live-grep in the zk_root to find but neither are as ergonomic aszk list -i
. Is there a way to emulate this?I would love a
zk list -i
-like picker in nvim thatAFAIK this is all functionality available in
zk list -i
One additional feature that I would love is to be able to write
#ADML
and it automatically filters for the tagADML
.I think this is achievable by using something like telescope.nvim, sending the input to
zk match
in the appropriate format (after debounce), collecting the results, transforming them into something that works for telescope's listing and preview and done.This would allow to prompt with all of the available filtering options.
Unfortunately, I don't know how to do that but I imagine I'm not the first to think of this. Is this a desirable feature for zk-nvim and/or does anyone have any pointer on how to implement this?
Relevant issues: #73 #68
Beta Was this translation helpful? Give feedback.
All reactions