Skip to content
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
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,22 @@ actions = {
}
```

### Custom Display Names
```lua
local butils = require("bento.utils")

-- Change from ~/home/yak/file.lua -> ~/h/y/file.lua
-- by default this is displayed as file.lua
butils.get_display_names = function(paths)
local display_names = {}
for _, p in ipairs(paths) do
display_names[p] = vim.fn.pathshorten(vim.fn.fnamemodify(p, ":~:."), 1)
end
return display_names
end
require("bento").setup(opts)
```

## Acknowledgments & inspiration

- [buffer-sticks.nvim](https://github.com/ahkohd/buffer-sticks.nvim) by [`ahkohd`](https://github.com/ahkohd): this plugin inspired some of the ideas implemented in `bento` (e.g., the dashed menu). You should also check out this plugin, it's very good and it pursues solutions to many of the same problems.
Expand Down
19 changes: 18 additions & 1 deletion lua/bento/ui.lua
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,10 @@ local function update_marks()
local a_val = bento.get_ordering_value(a.buf_id)
local b_val = bento.get_ordering_value(b.buf_id)

if ordering_metric == "filename" or ordering_metric == "directory" then
if
ordering_metric == "filename"
or ordering_metric == "directory"
then
-- String comparison: ascending alphabetical
if a_val == b_val then
return a.buf_id < b.buf_id
Expand Down Expand Up @@ -476,11 +479,25 @@ local function calculate_position(height, width)

local row, col

if position:match("^middle") then
row = math.floor((ui.height - height) / 2)
col = math.floor((ui.width - width) / 2)
return row + offset_x, col + offset_y
end

-- Vertical positioning
if position:match("^top") then
row = 0
if position:match("middle$") then
col = math.floor((ui.width - width) / 2)
return row + offset_x, col + offset_y
end
elseif position:match("^bottom") then
row = ui.height - height
if position:match("middle$") then
col = math.floor((ui.width - width) / 2)
return row + offset_x, col + offset_y
end
else
row = math.floor((ui.height - height) / 2)
end
Expand Down