Skip to content

Commit d78fb3b

Browse files
authored
feat: max_height for completion window (#2202)
1 parent 106c4bc commit d78fb3b

4 files changed

Lines changed: 10 additions & 1 deletion

File tree

doc/cmp.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -787,6 +787,13 @@ window.completion.scrollbar~
787787
`boolean`
788788
Whether the scrollbar should be enabled if there are more items that fit
789789

790+
*cmp-config.window.completion.max_height*
791+
window.completion.max_height~
792+
`number | nil`
793+
The completion window's max height, can be set to 0 to use all available
794+
space. To use `vim.o.pumheight` set this to `nil`.
795+
See |'pumheight'|.
796+
790797
*cmp-config.window.documentation.max_width*
791798
window.documentation.max_width~
792799
`number`

lua/cmp/config/window.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ window.bordered = function(opts)
1010
col_offset = opts.col_offset or 0,
1111
side_padding = opts.side_padding or 1,
1212
scrollbar = opts.scrollbar == nil and true or opts.scrollbar,
13+
max_height = opts.max_height or nil,
1314
}
1415
end
1516

lua/cmp/types/cmp.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ cmp.ItemField = {
131131
---@field public col_offset? integer|nil
132132
---@field public side_padding? integer|nil
133133
---@field public scrollbar? boolean|true
134+
---@field public max_height? integer|nil
134135

135136
---@class cmp.DocumentationWindowOptions: cmp.WindowOptions
136137
---@field public max_height? integer|nil

lua/cmp/view/custom_entries_view.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ custom_entries_view.open = function(self, offset, entries)
174174
width = width + self.column_width.kind + (self.column_width.menu > 0 and 1 or 0)
175175
width = width + self.column_width.menu + 1
176176

177-
local height = vim.api.nvim_get_option_value('pumheight', {})
177+
local height = completion.max_height or vim.api.nvim_get_option_value('pumheight', {})
178178
height = height ~= 0 and height or #self.entries
179179
height = math.min(height, #self.entries)
180180

0 commit comments

Comments
 (0)