telescope-repo.nvim
telescope-repo.nvim copied to clipboard
Start results cursor at the top instead of the bottom?
This is more of a question than an actual issue with the code, hope that this is okay.
Currently, when invoking :Telescope repo list
from the command line, you output similar to this:
Current
I couldn't help but notice that the cursor/highlighted element is near the bottom. Personally, I'd like it to be just under the search bar. An example of this is the find_files
picker within Telescope itself as shown below:
find_files picker
I had a look through the documentation but I sadly couldn't find anyway to configure this. Is this behaviour configurable in any way?
Hi, thanks for opening this issue. I think there is a telescope setting for that, Iāll look into it later today.
The following should work @sgoudham :
:Telescope repo list layout_strategy=center
This is covered in more details in this part of Telescopeās documentation: :h telescope.layout.vertical()
.
Please let me know if that does not enable you to do what you want.
Hi, no sorry, that isn't what I was thinking. In the original issue, you can see that the find_files picker shows results right underneath the search bar.
find_files picker
whereas, telescope repo is configured like the following:
Telescope repo list
Is there anyway to configure Telescope repo list to act the same as the find files picker? @cljoly
Ah, ok, so you would want to apply this setting only to the second prompt? Or to both prompt?
The latter should be easier to implement. @sgoudham
Apologies, I think I've explained this poorly @cljoly
I was just wondering if the telescope-repo picker could be configured to show the search results right underneath the search bar as this is the default behaviour for the base telescope pickers. (e.g. find_files)
The first screenshot I posted in https://github.com/cljoly/telescope-repo.nvim/issues/44#issuecomment-1207449914 is the desired behaviour whereas the second screenshot is the current behaviour of telescope-repo.
@sgoudham no worries. So if I get it right, you would like to see the default behavior for Telescope find_files
to be preserved, right?
Iām not sure what causes it not to be preserved, Iāve checked quickly in the code of telescope-repo, I donāt think we try to set the layout.
#45 might help with your use case, as you will be able to set the same layout for both prompt (if I got you correctly, you would prefer if you did not have to set any parameter and if the default behavior of find_files
was just picked up, but IĀ donāt know how to do that yet).
To clarify further, I mean the way the search results appear. The overall layout of the picker is fine (e.g center) @cljoly
Invoking the command Telescope repo list layout_strategy=center
does not change how the search results are ordered, so I'm unsure if changes in #45 will make any difference.
Oh right, your issue is with the ordering of the result and the fact that it āfocusesā with the very bottom of the screen when you would want the top result to be focused.
Invoking the command
Telescope repo list layout_strategy=center
does not change how the search results are ordered, so I'm unsure if changes in #45 will make any difference.
Yeah, it wonāt help. #45 is still probably a more correct behavior (the second prompt will be configurable, which it is not currently).
But yeah, I donāt know how to fix your issue.
Yes! sorry it took so long to clarify that. It feels like doing a google search and having to look at the bottom of the screen instead of looking at the top...
It looks like telescope-repo is the odd one out with the way the search results are populated, so it may be worth looking at telescope-project
or even any of the default pickers? Could it be the way you're populating the search results in the code?
Yes! sorry it took so long to clarify that
Thatās alright, perhaps I was slow to understand on that one.
It feels like doing a google search and having to look at the bottom of the screen instead of looking at the top...
Totally
It looks like telescope-repo is the odd one out with the way the search results are populated, so it may be worth looking at
telescope-project
or even any of the default pickers? Could it be the way you're populating the search results in the code?
Well, the funny thing is: for me, find_files
starts from the bottom too:
so it may be worth looking at telescope-project or even any of the default pickers?
Yes. Thatās also why Iām trying to get my find_files
to behave like yours.
Could it be the way you're populating the search results in the code?
Well, on the second prompt, Iām not populating anything, I just call the picker with a few options that shouldā¢ļø be unrelated, like the current file. But maybe they are not š¤·š¼ .
Iāll try to look more into this issue next weekend, but honestly, I donāt know when or even if Iāll have a fix.
In the meantime, could you please paste the part of your config pertaining to Telescope?
I guess this is more preference than anything, to me it just makes logical sense since your eyes naturally stay around the search bar.
Here's my full config at the minute @cljoly
require("telescope").setup {
pickers = {
find_files = {
hidden = true,
theme = 'dropdown'
},
live_grep = {
theme = 'dropdown'
},
lsp_references = {
theme = 'dropdown'
},
diagnostics = {
theme = 'dropdown'
},
current_buffer_fuzzy_find = {
theme = 'dropdown'
}
},
defaults = {
layout_strategy = 'center',
layout_config = {
center = {
anchor = 'S'
}
},
file_ignore_patterns = {
".git/"
},
mappings = {
n = {
["<A-j>"] = require("telescope.actions").preview_scrolling_down,
["<A-k>"] = require("telescope.actions").preview_scrolling_up
}
}
},
extensions = {
['ui-select'] = {
require("telescope.themes").get_dropdown()
},
repo = {
theme = "dropdown",
list = {
search_dirs = {
"~/personal/",
"~/.config/",
[[~/.local/share/nvim/]]
}
}
},
project = {
theme = 'dropdown'
},
file_browser = {
theme = "ivy",
hijack_netrw = true
}
}
}
I second this, I was able to move the prompt to the top via layout_config = { prompt_position = "top" }
but couldn't find a setting to make the result top-bottom instead of bottom-top. I keep hitting ctrl+j instead of ctrl+k while trying to cycle through the results (maybe muscle memory coming from LeaderF but it still is more "natural" to me)
Actually, I took another look and I used the config you shared @sgoudham.
For me, this:
Telescope repo list theme=dropdown
gives the expected result, pretty much regardless of the rest of the config.
And so for you @sirfz, looking into telescope source code, I would guess that you need to use:
Telescope repo list sorting_strategy=ascending
as the sorting strategy appears to be the relevant bit of the them. Please let me know if that works for you.
I'll look for a way to make this configurable in the call to telescope.setup{ā¦}
.
Ok, so there is currently no way to statically configure this in the call to telescope.setup{ā¦}
.
I could make
repo = {
theme = "dropdown",
list = {
search_dirs = {
"~/personal/",
"~/.config/",
[[~/.local/share/nvim/]]
}
}
},
work. However I'm a bit concerned with compatibility with the rest of the telescope ecosystem (we might have key collisions and we do launch two selectors, one with the repositories and then the file selector in that repository).
Hi @cljoly thanks for taking the time to respond! This is actually a general Telescope problem and not related to telescope-repo (I just noticed I posted here, probably after lots of googling and frustration). I'll try to check if there's already an issue about it there
Found what I wanted here:
in case it helps anyone:
local telescope = require('telescope')
telescope.setup {
defaults = {
sorting_strategy = "ascending", -- display results top->bottom
layout_config = {
prompt_position = "top" -- search bar at the top
}
}
}
@sirfz no worries. Thanks for finding this general setting, it's probably the best course of action here.
@sgoudham I'll close this issue, feel free to reopen it or comment if your problem is not fully solved.