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(layout_config) Adds the option to configure additional lines of padding around the anchor of the layout (#2851) #3035

Conversation

Weyaaron
Copy link
Contributor

@Weyaaron Weyaaron commented Apr 8, 2024

Description

This PR adds a new option to layout_config called anchor_padding. When set to a positive integer, it adds
additional lines of padding around the anchor of a layout.

Fixes #2851

Type of change

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

How Has This Been Tested?

  • Test for anchor south and with high padding:
local telescope = require("telescope")

local vertical_config = {
	config = {
		vertical = { width = 0.5 },
		anchor = "S",
		prompt_position = "bottom",
		width = { padding = 0 },
		height = 0.5,
		anchor_padding = 10,
	},
}
telescope.setup({
	pickers = {},
	extensions = {},
	defaults =config,
})

This results in the following layout:
Test_10_Vertical

The result we care about is the ten lines of additional space between the bottom of the screen and the start of the layout.

  • Test for anchor north and with low padding:
local telescope = require("telescope")
local config = {
	layout_config = {
		vertical = { width = 0.5 },
		anchor = "N",
		prompt_position = "bottom",
		width = { padding = 0 },
		height = 0.5,
		anchor_padding = 2,
	},
}
telescope.setup({
	pickers = {},
	extensions = {},
	defaults =config,
})

This results in the following layout:
Test_10_North

The result we care about is the two lines of additional space between the top of the screen and the start of the layout.

Configuration:

  • Neovim version (nvim --version): v0.9.4
  • Operating system and version:
    OS: Manjaro Linux x86_64
    Host: Laptop (12th Gen Intel Core) A4
    Kernel: 6.1.80-1-MANJARO

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)

I am not quite sure what this last point is about, so I left it open.

Open question:

I have not provided additional tests. I have changed the existing tests to mimic the previous behavior by setting anchorpadding to 1 where applicable. Since this is my first contribution, I am unsure about this. Additional feedback is appreciated.

@Weyaaron
Copy link
Contributor Author

Since there is no progress on this, I decided to check the fourth box as well. I think I got this covered. Looking forward to feedback and moving this forward.

@jamestrew
Copy link
Contributor

Sorry for the late response. This looks good to me thanks!

@jamestrew jamestrew merged commit 816dff9 into nvim-telescope:master Jun 27, 2024
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.

layout_strategy=vertical & layout_config.anchor='S' leaves one line
2 participants