-
Notifications
You must be signed in to change notification settings - Fork 61
Zk grep 2 (inheriting #171) #232
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
base: main
Are you sure you want to change the base?
Conversation
if the 'grep' argument is provided, the ui is called directly. the api is not called with the ui as a callback (as would normally be the case) because in this case the ui has to call the api on each input change
run grep picker if 'grep' is given, otherwise run the other one
picker uses asynchronous calls to "zk list -m <search_term>" to live filter notes based on a search term implemented based on Telescope's live_grep does not include ability to jump to line since "zk list" does not give this info
grep option insertion, instead of overwrite
Merged @shfattig's ZkGrep command to main/HEAD. And enhanced it with `rg` command for jumping to the matched line.
|
ChangeLog:
Now using:
To customize these highlights, you can add something like this to your config: vim.api.nvim_create_autocmd('ColorScheme', {
callback = function()
vim.api.nvim_set_hl(0, 'TelescopeResultsIdentifier', { fg = '#E0B449', bold = true })
vim.api.nvim_set_hl(0, 'TelescopeResultsLineNr', { fg = '#999999' })
vim.api.nvim_set_hl(0, 'TelescopeResultsNormal', { fg = '#CCCCCC' })
end,
}) |
|
This is awesome, thanks for the work. I really want to get grep functionality in here. I'm sad that #171 stalled out. Using zk's All that being said, I have to prioritise bug fixes much more highly at the moment as until the start of July I need to finish my masters thesis, while working part time on the side. So just focusing on bug fixes of existing functionality keeps my other commitments manageable, while keeping the ship afloat here. But I am totally in to get this merged, and will look at it when I can, but latest in July. |
|
Thank you for replying even though you're so busy. Yes, Of course, please prioritize bug fixes — I’d be happy if you could take a look when you have some spare time. In the meantime, I might continue adding commits here with further improvements. Concerns (for future reference):Currently, ZkGrep is integrated into |
- Add attach_mappings to pickers. - Remove unneccesory `zk.api.list` - Follow original function style. (Add args, external entry_maker & sorter.) - Modify `ui.edit()` to move the cursor, if `entry` has lnum & col - Brush up the code Or, adding new function like `ui.edit_move()` is better & safer?
…f zk.get_options()
…ine options Since some users may have already customized bufferline's buf.name.formatter, I decided to stop forcing it into zk-nvim's options to avoid conflicts.
|
And now I'm looking into integrating |
|
Now I replaced It's quite faster than (Ready to be merged) |
1f620b4 to
1ee1bb0
Compare
|
I've merged |
The count is because |
Got it -- there's an option to hide the count! |
|
Thanks for reviewing ! Additionally, I created PR in Though it took quite a while, it's pretty close to completion, too. Anyway, please get some rest first @tjex ! |
|
@WhyNotHugo Would you be able to give the code of this pr a look? Need your lua / nvim plugin competencies on this, it's a pretty big addition and would be great to get it right. Also as it's a long standing requested feature. |
|
I've only had a glance at a high level for now. Do we need to use I'm not very familiar with Folks who prefer require("snacks").setup({
picker = {
ui_select = true,
},
})Personally, I use require("fzf-lua").register_ui_select()I'm sure there are other implementations out there too. |
|
@WhyNotHugo Thanks a lot for your review and comment! The main goals of this PR are:
Why ripgrep?
I completely agree that ideally we should rely on Because of that limitation, jumping directly to the match location wasn’t possible — the cursor always moved to the file top. To work around this, I temporarily used ripgrep. This makes it possible to get lnum/col and jump precisely to the right spot. (Of course, once Dependency
require("zk").setup({
-- Can be "telescope", "fzf", "fzf_lua", "minipick", "snacks_picker",
-- or select" (`vim.ui.select`).
picker = "select",
...
}With this setup, And this PR just reuses this contrivance as well as So, actually it's not a strict dependency but a optional choice for users, I think. Addtionally, currently this grep feature contains only I'm not familiar with No extra setup or codings
In the grep results, displaying With this PR, users can achieve that with no extra setup or coding. I really like the philosophy behind zk, and I made this change to zk-nvim hoping that more people can use it easily and comfortably. |
|
I’ve merged the latest upstream main into this branch due to conflicts and avoiding deviation. |
|
Yep, thats the correct process. And main is also correct (on zk, we have a dev branch which is the default for merges, but zk-nvim is still just main). I know this is taking ages to get this merged. Sorry for it and thanks for your patience. @WhyNotHugo Do you think you'd have any time coming up to reassess now that riodelphino replied to your questions? I agree it would be great to use zk's match, but without line / location jumping, its not great. So it is good that we could switch out ripgrep for zk match (I haven't varified how much of a rewrite that would take though). |

Initially, I added this sample code to implement the
:ZkGrepcommand.Then I merged the changes from #171 into the latest
mainbranch, and extended it based on the above example.Features:
rgcommand, instead ofzk list --format=oneline -mcommand. (to getlnumandcol)TODO:
Now
score -> idx.Sorting by
score -> title(filename) -> lnum -> color modifying scoring directly is ideal.snacks_picker's sorting is difficult to understand, so I give up for now.
This may helps (Japanese)
Thanks to @shfattig for providing a great foundation and roadmap for integrating grep into
zk-nvimpickers.