Skip to content
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

feat: more prompt position strategies #1280

Merged

Conversation

l-kershaw
Copy link
Contributor

@l-kershaw l-kershaw commented Sep 22, 2021

This PR adds the prompt_position option for the following layout stratgies:

  • vertical
  • bottom_pane
  • center

vertical was noted as being "planned" in the code
bottom_pane was requested in this comment


EDIT: I have now also added some more flexibility to the get_dropdown and get_ivy themes if the user customises the prompt_position

@Conni2461
Copy link
Member

Conni2461 commented Sep 26, 2021

Just setting

    layout_strategy = 'bottom_pane',
    layout_config = {
      bottom_pane = {
        prompt_position = "top" | "bottom",
      }
    }

looks a little bit of (no idea if this is intended and if the intention is to fix it with changing borderchars for prompt, like what theme does)
image
image

FWIW plenary is up to date

Otherwise LGTM thanks :)

@l-kershaw
Copy link
Contributor Author

I agree that it looks a bit weird without adjusting borderchars
I think this design was a conscious choice by whoever made the top version, to then match the style of ivy for the theme.
I tried to match the general aesthetic for the bottom version

@l-kershaw
Copy link
Contributor Author

I've added some flexibility to the get_dropdown theme, so it will adjust based on prompt_position. Picture below:
image

I've also added some flexibility to the get_ivy theme. Picture below:
image

@Conni2461 is this more what you were looking for with the prompt_position="bottom" for the bottom_pane layout?

@l-kershaw l-kershaw force-pushed the feat/more_prompt_position_strategies branch from 3b5589d to e208f50 Compare September 30, 2021 13:56
@l-kershaw
Copy link
Contributor Author

@fdschmidt93 I've rebased this PR as requested, and the fixes from #1293 still seem to work well.

If you could test this PR and let me know your thoughts, that would be great 🙂

Copy link
Member

@Conni2461 Conni2461 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM thanks :)

(just running layout_config bottom_pane without ivy layout still looks kinda weird, at least for me, but i dont think anyone is doing it. We can fix it if someone reports an issue for that)

@Conni2461 Conni2461 merged commit be600b5 into nvim-telescope:master Oct 4, 2021
@l-kershaw l-kershaw deleted the feat/more_prompt_position_strategies branch October 9, 2021 19:14
@pickfire
Copy link

pickfire commented Nov 9, 2021

get_ivy seemed to fill the whole screen. How should I configure the height?

@l-kershaw
Copy link
Contributor Author

@pickfire It depends on how you are using the telescope API.


If you are using the viml command line api, e.g.:

:Telescope find_files theme=get_ivy

then you could add layout_config to change the height by doing:

:Telescope find_files theme=get_ivy layout_config={height=10}

If you are using the lua api, e.g.:

require("telescope.builtin").find_files(require("telescope.themes").get_ivy())

then you can add layout_config to change the height by doing:

require("telescope.builtin").find_files(require("telescope.themes").get_ivy({layout_config={height=10}}))

If you want to create your own theme based on get_ivy then you can do the following in lua

require("telescope.themes").get_custom = function(opts)
  opts = vim.tbl_deep_extend("force",{layout_config={height=10}},opts)
  return require("telescope.themes").get_ivy(opts)
end

and then you can use you custom theme like:

:Telescope find_files theme=get_custom

or

require("telescope.builtin").find_files(require("telescope.themes").get_custom())

@pickfire
Copy link

pickfire commented Nov 11, 2021

Wow, this thing is nested multiple layers deep, no wonder I couldn't find it in the docs. I was using get_ivy lua but setting the whole telescope defaults for it, ended up just using the original one, I wish the ivy defaults don't cover the whole screen at least if the terminal is small (80x24). Thanks a lot for sharing the answer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants