Skip to content

Conversation

alissonbrunosa
Copy link

Description

I've been using this patched version of the center layout strategy for a while and thought it was worth proposing upstream. It introduces a new layout option, results_height, allowing users to explicitly set the height of the results panel.

In addition, this refactors how window dimensions and positions are calculated, properly centring the entire layout (including preview, results, and prompt), rather than just the prompt + results block.

Type of change

Please delete options that are not relevant.

  • New feature (non-breaking change which adds functionality)

How Has This Been Tested?

I've tested this change with different configurations, such as mirror, prompt_position, height and with the new option results_height

Dropdown theme

pickers = {
    find_files = {
        theme = "dropdown",
    }
}

image

with mirror = true

pickers = {
    find_files = {
        theme = "dropdown",
       layout_config = {
            mirror = true,
       },
    }
}

image

with results_height = 5

pickers = {
    find_files = {
        theme = "dropdown",
       layout_config = {
            results_height = 5,
       },
    }
}

image

with results_height = 5 and mirror = true

pickers = {
    find_files = {
        theme = "dropdown",
       layout_config = {
            results_height = 5,
            mirror = true,
       },
    }
}

image

with prompt_position = 'bottom'

pickers = {
    find_files = {
        theme = "dropdown",
       layout_config = {
            results_height = 5,
            mirror = true,
            prompt_position = 'bottom',
       },
    }
}

image

with height = 40 and results_height = 10

pickers = {
    find_files = {
        theme = "dropdown",
       layout_config = {
            height = 10
            results_height = 10,
       },
    }
}

image

Configuration

  • Neovim version (nvim --version):
NVIM v0.10.4
Build type: RelWithDebInfo
LuaJIT 2.1.1720049189
Run "nvim -V1 -v" for more info
  • Operating system and version: Fedora 41

Checklist:

  • My code follows the style guidelines of this project (stylua)
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation (lua annotations)

Changes:
- Add `results_height` option to configure the number of lines the
  results panel/window should have.

- Replaces calc_size_and_spacing with direct height adjustment based on
  border size and previewer status.

- Refactors layout positioning to more clearly and correctly compute
  topline from the full height of prompt + results + preview.

- Handles preview_cutoff explicitly, disabling the preview when too
  small and reallocating its height to results.

- Adjust dropdown theme. height now sets the overall height intestead of
  just the result + prompt height.
@alissonbrunosa alissonbrunosa changed the title Improve center strategy feat(pickers): improve center strategy by adding results_height option Jun 24, 2025

height = function(_, _, max_lines)
return math.min(max_lines, 15)
return math.min(max_lines, 30)
Copy link
Author

Choose a reason for hiding this comment

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

[ Note 🗒️ ]
Since the height option now sets the overall height and not just the prompt
+ results, we need to make it a bit taller and set the results_height to 15
to replicate the previous layout

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.

1 participant