···1313 -- avoid adding empty strings
1414 -- TODO: could block adding single characters here
1515 if text == "" or text == " " or text == "\n" then
1616- -- if text == "" and text == " " and text == "\n" then -- NOTE: which is correct between and/or here?
1716 return
1817 end
1918···5857 if #yank_text <= 1 then
5958 return
6059 end
6161- M.add_yank(yanks, reg_types, yank_text, reg_type, opts.max_entries)
6060+ M.add_yank(yanks, reg_types, yank_text, reg_type, opts)
6261 end
6362 end,
6463 })
···7978 return
8079 end
81808282- M.add_yank(yanks, reg_types, yank_text, reg_type, opts.max_entries)
8181+ M.add_yank(yanks, reg_types, yank_text, reg_type, opts)
8382 end,
8483 })
8584 end
+10-3
lua/yankbank/data.lua
···3535 for j, line in ipairs(yank_lines) do
3636 if j == 1 then
3737 -- Format the line number with uniform spacing
3838- local lineNumber = string.format("%" .. max_digits .. "d: ", yank_num)
3838+ local lineNumber =
3939+ string.format("%" .. max_digits .. "d: ", yank_num)
3940 line = line:sub(leading_space_length + 1)
4041 table.insert(display_lines, lineNumber .. line)
4142 else
4243 -- Remove the same amount of leading whitespace as on the first line
4344 line = line:sub(leading_space_length + 1)
4445 -- Use spaces equal to the line number's reserved space to align subsequent lines
4545- table.insert(display_lines, string.rep(" ", max_digits + 2) .. line)
4646+ table.insert(
4747+ display_lines,
4848+ string.rep(" ", max_digits + 2) .. line
4949+ )
4650 end
4751 table.insert(line_yank_map, i)
4852 end
···5054 if i < #yanks then
5155 -- Add a visual separator between yanks, aligned with the yank content
5256 if sep ~= "" then
5353- table.insert(display_lines, string.rep(" ", max_digits + 2) .. sep)
5757+ table.insert(
5858+ display_lines,
5959+ string.rep(" ", max_digits + 2) .. sep
6060+ )
5461 end
5562 table.insert(line_yank_map, false)
5663 end
+4-3
lua/yankbank/init.lua
···2222 keymaps = {},
2323}
24242525-local plugin_path = debug.getinfo(1).source:sub(2):match("(.*/).*/.*/") or "./"
2525+-- local plugin_path = debug.getinfo(1).source:sub(2):match("(.*/).*/.*/") or "./"
26262727--- wrapper function for main plugin functionality
2828---@param opts table
···3232 opts = opts or default_opts
33333434 -- initialize buffer and populate bank
3535- local bufnr, display_lines, line_yank_map = menu.create_and_fill_buffer(yanks, reg_types, opts)
3535+ local bufnr, display_lines, line_yank_map =
3636+ menu.create_and_fill_buffer(yanks, reg_types, opts)
36373738 -- handle empty bank case
3839 if not bufnr or not display_lines or not line_yank_map then
···4546end
46474748-- plugin setup
4848----@param opts table?
4949+---@param opts table
4950function M.setup(opts)
5051 -- merge opts with default options table
5152 -- opts = vim.tbl_deep_extend("force", default_opts, opts or {})
+8-3
lua/yankbank/menu.lua
···6060 -- define buffer window width and height based on number of columns
6161 -- FIX: long enough entries will cause window to go below end of screen
6262 -- FIX: wrapping long lines will cause entries below to not show in menu (requires scrolling to see)
6363- local width = math.min(max_width, vim.api.nvim_get_option_value("columns", {}) - 4)
6363+ local width =
6464+ math.min(max_width, vim.api.nvim_get_option_value("columns", {}) - 4)
6465 local height = math.min(
6566 display_lines and #display_lines or 1,
6667 vim.api.nvim_get_option_value("lines", {}) - 10
···7172 relative = "editor",
7273 width = width,
7374 height = height,
7474- col = math.floor((vim.api.nvim_get_option_value("columns", {}) - width) / 2),
7575- row = math.floor((vim.api.nvim_get_option_value("lines", {}) - height) / 2),
7575+ col = math.floor(
7676+ (vim.api.nvim_get_option_value("columns", {}) - width) / 2
7777+ ),
7878+ row = math.floor(
7979+ (vim.api.nvim_get_option_value("lines", {}) - height) / 2
8080+ ),
7681 border = "rounded",
7782 style = "minimal",
7883 })