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: config.view.entries.vertical_positioning = 'above'|'below'|'auto' #1701

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

llllvvuu
Copy link

@llllvvuu llllvvuu commented Sep 12, 2023

Also applies to docs_view otherwise the docs will cover the text when it is significantly taller than the completion menu.

For Copilot, 'above' works best with vim.opt.scrolloff = 999.

Fixes: #495
Helped-by: Thanatermesis thanatermesis@gmail.com

@llllvvuu llllvvuu force-pushed the feat/above branch 3 times, most recently from bbed640 to 4f3aa60 Compare September 13, 2023 00:04
@llllvvuu llllvvuu changed the title feat: config.view.entries.vertical_positioning = 'above'|'below' feat: config.view.entries.vertical_positioning = 'above'|'below'|'auto' Oct 8, 2023
@barnacker
Copy link

Best feature ever, I'm running directly off of your branch now... its perfect.

@llllvvuu
Copy link
Author

Thanks! I just fixed it yesterday to fix the docs preview as well

ping @hrsh7th for review

@idelice
Copy link

idelice commented Oct 14, 2023

Thanks! I just fixed it yesterday to fix the docs preview as well

ping @hrsh7th for review

Can we even expect any reviews on this? I mean, we still on v0.0.1 with no releases for a long time and no recent activity

@lcrownover
Copy link

@hrsh7th What's the deal on this? I'd love to have this merged...

I constantly run into overlapping prompts and if this fixes it, I'd be super happy.

@franroa
Copy link

franroa commented Dec 9, 2023

also waiting for this

@valenmarton
Copy link

I also cloned your repo, hope it gets merged soon.

@smitropoulos
Copy link

@hrsh7th can we please get this reviewed?

@Shougo
Copy link

Shougo commented Feb 16, 2024

I think it is useful feature. I heard his thoughts before.

But he don't want to add new features now.
Because new features increases maintenance cost.
He might change his mind though.

He wants to include bug fix only.

@lcrownover
Copy link

This is also a bugfix for a very annoying bug that I constantly run into where the completion window covers up the text if your screen isn't large enough.

@franroa
Copy link

franroa commented Feb 16, 2024

This is also a bugfix for a very annoying bug that I constantly run into where the completion window covers up the text if your screen isn't large enough.

agree

'above' works best with vim.opt.scrolloff = 999.

Fixes: # 495
Helped-by: Thanatermesis <thanatermesis@gmail.com>
@idelice
Copy link

idelice commented Feb 21, 2024

@hrsh7th are you still maintaining this repo or not?

@Shougo
Copy link

Shougo commented Mar 27, 2024

It is still maintaining. The responses are slow though. You can see other issues and PRs.

@michaelbrusegard
Copy link

michaelbrusegard commented Jun 8, 2024

I merged this with main from nvim/cmp so it has the latest changes and can be merged, PR is here: llllvvuu#1.
This was because I wanted multi line ghost text together with the option to put the cmp window above

@xzbdmw
Copy link

xzbdmw commented Jun 9, 2024

Forks who are using copilot now can use copilot-cmp with my pr which add multi-line ghost-text and dynamic window flip capability, I has been using it for 2 month, hope there are few bugs
#1955

@oysandvik94
Copy link

I tested this branch with these settings:

			view = {
				entries = { name = "custom", vertical_positioning = "auto" },
			},

image

The doc menu is supposed to be placed either above or under, right?

@Shougo
Copy link

Shougo commented Aug 22, 2024

The issue of document window position is a different matter.

#1812

@oysandvik94
Copy link

@Shougo My bad!

Comment on lines +178 to 196
local prefers_above = c.view.entries.vertical_positioning == 'above'
local prefers_auto = c.view.entries.vertical_positioning == 'auto'
local cant_fit_at_bottom = vim.o.lines - row - border_offset_row <= math.min(DEFAULT_HEIGHT, height)
local cant_fit_at_top = row - border_offset_row <= math.min(DEFAULT_HEIGHT, height)
local is_in_top_half = math.floor(vim.o.lines * 0.5) > row + border_offset_row
local should_position_above =
cant_fit_at_bottom or
(prefers_above and not cant_fit_at_top) or
(prefers_auto and is_in_top_half)
if should_position_above then
self.bottom_up = true
height = math.min(height, row - 1)
row = row - height - border_offset_row - 1
if row < 0 then
height = height + row
end
else
self.bottom_up = false
end
Copy link

Choose a reason for hiding this comment

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

Would be cool if this code some how took into account the experimental ghost text feature. Not sure if it can be done, but i would like to see auto checking if the ghost text is more than a number of lines that could maybe be configured as well. Could also just be set to 1 line.

Copy link

Choose a reason for hiding this comment

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

I guess you mean #1955

Copy link

Choose a reason for hiding this comment

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

Ye that about covers it :)

Comment on lines 185 to 188
---@field name 'custom'
---@field selection_order 'top_down'|'near_cursor'
---@field vertical_positioning 'auto'|'above'|'below'
---@field follow_cursor boolean
Copy link

Choose a reason for hiding this comment

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

i'm somewhat unsure of what the selection order does, but i imagine it choose if the most relevant entry is shown at the top of the list or nearest the cursor. could be a good place to add a bottom up option as its only become useful now with this new feature for vertical positioning

@Skyppex
Copy link

Skyppex commented Oct 9, 2024

I am also noticing that the floating window is sometimes covering my cursor when switching between different entries in the list.
For info i'm using a solution where copilot appears as a completion in the floating window and i have ghost text turned on so i can see all the different completions and what they will do to my code.

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.

Allow to position the float window above the current line