From 7e437b700a4e500eca3ac50bbaf06482be73ffba Mon Sep 17 00:00:00 2001 From: starlightaria Date: Thu, 23 Apr 2026 01:26:44 -0700 Subject: [PATCH 1/2] Added option in config to set local window opts of Bufferlist window --- README.md | 12 ++++++++++++ lua/bufferlist.lua | 5 +++++ 2 files changed, 17 insertions(+) diff --git a/README.md b/README.md index 4c8e5b8..fd43e52 100644 --- a/README.md +++ b/README.md @@ -106,6 +106,7 @@ Bufferlist comes with the following defaults: line = "▎", modified = "󰝥", }, + win_opts = {}, -- set local vim opts of BufferList window top_prompt = true, -- set this to false if you want the prompt to be at the bottom of the window instead of on top of it. show_path = false, -- show the relative paths the first time BufferList window is opened } @@ -178,6 +179,17 @@ press `keymap.toggle_path` to toggle the relative path to each buffer from the n #### Show relative path set `show_path` to `true` to show the relative path the first time you open the BufferList window after it has been loaded. +### Adding custom window opts +You can add custom local opts for BufferList window via `win_opts` option. `win_opts` takes a table of `key = value` items. You can see a list of available options by running `:help option-summary`, any option marked as local can be set. + +This example shows how to set window opts to highlight the cursor line of BufferList window: +```lua +win_opts = { + cursorline = true, + cursorlineopts = "line", +}, +``` + ### Adding custom keymaps You can add custom keymaps for BufferList window via `win_keymaps` option, and keymaps for buffers via `bufs_keymaps` option #### For BufferList window diff --git a/lua/bufferlist.lua b/lua/bufferlist.lua index 52d16ed..524c026 100644 --- a/lua/bufferlist.lua +++ b/lua/bufferlist.lua @@ -35,6 +35,7 @@ local default_opts = { prompt = "", save_prompt = "󰆓 ", }, + win_opts = {}, top_prompt = true, show_path = false, } @@ -422,6 +423,10 @@ local function list_buffers() fn.setcursorcharpos(1, 6) + for key, value in pairs(default_opts.win_opts) do + vim.wo[win][key] = value + end + km.set("n", default_opts.keymap.close_bufferlist, function() cmd("bwipeout") end, km_opts(scratch_buf, "exit")) From 97fb5b1cf0b92f636cbd6b79c8221dc9a186021f Mon Sep 17 00:00:00 2001 From: starlightaria Date: Thu, 23 Apr 2026 01:29:31 -0700 Subject: [PATCH 2/2] Added option to start cursor on current buffer line --- README.md | 1 + lua/bufferlist.lua | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index fd43e52..b2561e3 100644 --- a/README.md +++ b/README.md @@ -107,6 +107,7 @@ Bufferlist comes with the following defaults: modified = "󰝥", }, win_opts = {}, -- set local vim opts of BufferList window + start_cursor_on_buf_line = true, -- set this to true if you want the cursor to start on the line of the currently opened buffer top_prompt = true, -- set this to false if you want the prompt to be at the bottom of the window instead of on top of it. show_path = false, -- show the relative paths the first time BufferList window is opened } diff --git a/lua/bufferlist.lua b/lua/bufferlist.lua index 524c026..9caae50 100644 --- a/lua/bufferlist.lua +++ b/lua/bufferlist.lua @@ -36,6 +36,7 @@ local default_opts = { save_prompt = "󰆓 ", }, win_opts = {}, + start_cursor_on_buf_line = true, top_prompt = true, show_path = false, } @@ -259,8 +260,10 @@ local function list_buffers() local modified_byteidx = fn.byteidx(default_opts.icons.modified, 1) local function refresh() + local store_cursor_line = unpack(api.nvim_win_get_cursor(0)) cmd("bwipeout") list_buffers() + fn.setcursorcharpos(store_cursor_line, 6) end for i = 1, #b do @@ -421,7 +424,11 @@ local function list_buffers() vim.wo[win].number = true bo[scratch_buf].modifiable = false - fn.setcursorcharpos(1, 6) + if default_opts.start_cursor_on_buf_line then + fn.setcursorcharpos(tostring(current_buf_line or 1), 6) + else + fn.setcursorcharpos(1, 6) + end for key, value in pairs(default_opts.win_opts) do vim.wo[win][key] = value