feat(pickers): initial_mode = 'select'#2092
feat(pickers): initial_mode = 'select'#2092fdschmidt93 wants to merge 1 commit intonvim-telescope:masterfrom
Conversation
|
ahh awesome! i just tried this out though, and i'm still seeing the same exact CPU pegging issue i described here when using EDIT: to clarify, this happens in |
|
I cannot reproduce this issue. Seems to work just as other initial modes for these two pickers for me. |
|
@fdschmidt93 So once this gets merged, how would one get the content from the visual selection to actually show up (asking for #1766)? In the example here the content is static and I assume defined with |
You have a function that extracts the visual selection for you (lots on stackoverflow and there is an upstream neovim PR waiting for an owner) and pass that to Not part (and 100% won't be) of this PR. It's agreed |
|
@fdschmidt93 Thanks for the tips. Found a snippet here. I've managed to get it working with the code below and your PR: function vim.getVisualSelection()
vim.cmd('noau normal! "vy"')
local text = vim.fn.getreg('v')
vim.fn.setreg('v', {})
text = string.gsub(text, "\n", "")
if #text > 0 then
return text
else
return ''
end
end
function live_grep()
text = vim.getVisualSelection()
require("telescope.builtin").live_grep({
initial_mode = "select",
default_text = text})
end
vim.keymap.set({'n','v'} , '<Leader>r', live_grep)In the screencast below I'm visually selecting "Gaze" and pressing |
|
@fdschmidt93 |
|
Patience? I'm waiting for Conni's feedback as to whether he'd agree that we should have this in this capacity and then I guess I'd write docs. I already pinged him in the OP, so he'll consider it when he can/wants to make time for it. |
| -- n: A<ESC> makes sure cursor is at always at end of prompt w/o default_text | ||
| keys = mode ~= "n" and "<ESC>A<ESC>" or "A<ESC>" | ||
| elseif self.initial_mode == "select" then | ||
| keys = mode ~= "n" and [[<ESC>^v$<C-g>]] or [[<ESC>^v$<C-g>]] |
There was a problem hiding this comment.
Is it github or is the lhs and rhs of this "if" the same?
There was a problem hiding this comment.
Ah thanks, threw this together in 10mins with a beer when I realized I had two PRs to reply to after 1.5 months 😅 mode switching worked as intended, but I'll check switching from normal to select mode once more to make sure.
|
Sorry for the late response. I am really swamped lately with everything 😆 We can do this, the gif looks like fun and there is some demand for it. I also think it doesn't break normal and insert mode. So if you finish the docs, feel free to merge. Totally unrelated, we should talk about backporting, future development, (retrospective for 0.1.0) ... |
Ok cool :) will do.
Sure, I'm relatively flexible timewise after my deadline now, just ping me on Discord whenever you're free. |
|
@fdschmidt93 Working codeNot working codeIssue manifestationPressing After killing nvim from a different terminal I saw something which looks like an error message: |
93390d3 to
14579aa
Compare
|
Try again, I fixed something that might have caused this. Please next time point out your error rather than pasting unformatted code and provide more context (your initial mode etc). E: I amended the original commit, make sure you properly update. |
|
Tried, still occurring.
The case when there is something visually selected before pressing
Sure, hope the above gives more context. Anyways, do suggest, will gladly adapt if it makes it simpler on your end. |
Sorry, I wasn't clear, I just meant having to visually parse unhighlighted and unformatted code myself. Either embed it with syntax highlighting (```lua at beginning of code block) or describe it properly. I think I've understood the problem: can you confirm that the crashes only happen if there is no visual selection, that is the text you return is @rkoval that might also be your problem -- crashes/getting stuck I can reproduce with something like -- no default_text
require "telescope.builtin".find_files { initial_mode = "select" }Though there is no use case for |
I gave it another test and made a screencast.
|
|
heyo! i'm wondering if this branch can be rebased/merged up from master to potentially retest the hanging/crashing issue we were seeing? i'm wondering if related code that touched these codepaths were modified and this hanging issue is no longer a problem. i know it's a long shot, but just wanting to make some traction on this feature given that i miss it! |
|
Apologies, I won't see this through at the very least anytime soon and quite likely at all. My foreseeable efforts into contributing new features will be focused on |



Description
Minimal solution of what's needed to implement what's needed for #1939 (
initial_mode = "select") to get a feel. Looks like it works as expected to move in between pickers etc. without much hassle.Not 100% sure whether default to insert mode mappings is a sane default but I think it works reasonably well.
Would close #1766 as everything needed would be provided then I suppose.
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list relevant details about your configuration
Snippet:
Checklist:
TODO
cc @rkoval if you wouldn't mind stress testing this branch :)