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

Customizable window width #7

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ require('command-completion').setup {
-- see `:help nvim_open_win()` for available options (e.g. 'single', 'double', etc.)
max_col_num = 5, -- Maximum number of columns to display in the completion window
min_col_width = 20, -- Minimum width of completion window columns
window_width = vim.o.columns, -- Width of the window (defaults to full width)
use_matchfuzzy = true, -- Whether or not to use `matchfuzzy()` (see `:help matchfuzzy()`)
-- to order completion results
highlight_selection = true, -- Whether or not to highlight the currently
Expand Down
5 changes: 3 additions & 2 deletions lua/command-completion.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ local user_opts = {
border = nil,
max_col_num = 5,
min_col_width = 20,
window_width = vim.o.columns,
use_matchfuzzy = true,
highlight_selection = true,
highlight_directories = true,
Expand All @@ -40,7 +41,7 @@ local directory_hl_nsid = n.create_namespace('__ccs_hls_namespace_directory___')
local function calc_col_width()
local col_width
for i = 1, user_opts.max_col_num do
local test_width = math.floor(vim.o.columns / i)
local test_width = math.floor(user_opts.window_width / i)
if test_width <= user_opts.min_col_width then
return col_width
else
Expand All @@ -60,7 +61,7 @@ local function open_and_setup_win(height)
relative = 'editor',
border = user_opts.border,
style = 'minimal',
width = vim.o.columns,
width = user_opts.window_width,
height = height,
row = vim.o.lines - 2,
col = 0,
Expand Down