Skip to content

Commit

Permalink
[+] custom UI updates
Browse files Browse the repository at this point in the history
  • Loading branch information
Pheon-Dev committed Sep 6, 2023
1 parent 1fb57d0 commit ae54516
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 15 deletions.
14 changes: 11 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,10 @@ require("buffalo").setup({
command = "bd"
}
},
cycle = false, -- cycle through the list
exit_menu = "x", -- similar to 'q' and '<esc>'
borderchars = { "", "", "", "", "", "", "", "" },
general_commands = {
cycle = false, -- cycle through the list
exit_menu = "x", -- similar to 'q' and '<esc>'
},
go_to = {
enabled = true,
go_to_tab = "<leader>%s",
Expand All @@ -158,6 +159,13 @@ require("buffalo").setup({
filter_tabs = "<M-t>",
filter_buffers = "<M-b>",
},
ui = {
width = 60,
height = 10,
row = 2,
col = 2,
borderchars = { "", "", "", "", "", "", "", "" },
}
})
```

Expand Down
14 changes: 11 additions & 3 deletions lua/buffalo/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,10 @@ function M.setup(config)
command = "edit"
}
},
cycle = true,
exit_menu = "q",
borderchars = { "", "", "", "", "", "", "", "" },
general_commands = {
cycle = true,
exit_menu = "q",
},
go_to = {
enabled = true,
go_to_tab = "<leader>%s",
Expand All @@ -114,6 +115,13 @@ function M.setup(config)
filter_tabs = "<M-t>",
filter_buffers = "<M-b>",
},
ui = {
width = 60,
height = 10,
row = 2,
col = 2,
borderchars = { "", "", "", "", "", "", "", "" },
}
}

local complete_config = merge_tables(default_config, config)
Expand Down
20 changes: 11 additions & 9 deletions lua/buffalo/ui.lua
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,19 @@ local map = vim.keymap.set
local function create_window(title)
log.trace("_create_window()")

local width = config.width or 60
local height = config.height or 10
local width = config.ui.width or 60
local height = config.ui.height or 10
local row = config.ui.row or 2
local col = config.ui.col or 2

local borderchars = config.borderchars or { "", "", "", "", "", "", "", "" }
local borderchars = config.ui.borderchars or { "", "", "", "", "", "", "", "" }
local bufnr = vim.api.nvim_create_buf(false, false)

local Buffalo_win_id, win = popup.create(bufnr, {
title = "Buffalo [" .. title .. "]",
highlight = "BuffaloWindow",
line = math.floor(((vim.o.lines - height) / 2) - 1),
col = math.floor((vim.o.columns - width) / 2),
line = math.floor(((vim.o.lines - height) / row) - 1),
col = math.floor((vim.o.columns - width) / col),
minwidth = width,
minheight = height,
borderchars = borderchars,
Expand Down Expand Up @@ -260,7 +262,7 @@ function M.toggle_buf_menu()
vim.api.nvim_buf_set_keymap(
Buffalo_bufh,
"n",
config.exit_menu,
config.general_commands.exit_menu,
"<Cmd>lua require('buffalo.ui').toggle_buf_menu()<CR>",
{ silent = true }
)
Expand Down Expand Up @@ -373,7 +375,7 @@ function M.toggle_tab_menu()
vim.api.nvim_buf_set_keymap(
Buffalo_tabh,
"n",
config.exit_menu,
config.general_commands.exit_menu,
"<Cmd>lua require('buffalo.ui').toggle_tab_menu()<CR>",
{ silent = true }
)
Expand Down Expand Up @@ -573,7 +575,7 @@ function M.nav_buf_next()
end
local next_buf_line = current_buf_line + 1
if next_buf_line > #marks then
if config.cycle then
if config.general_commands.cycle then
M.nav_buf(1)
end
else
Expand All @@ -590,7 +592,7 @@ function M.nav_buf_prev()
end
local prev_buf_line = current_buf_line - 1
if prev_buf_line < 1 then
if config.cycle then
if config.general_commands.cycle then
M.nav_buf(#marks)
end
else
Expand Down

1 comment on commit ae54516

@Pheon-Dev
Copy link
Owner Author

Choose a reason for hiding this comment

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

fixes issue #2

Please sign in to comment.