Neovim plugin improving access to clipboard history (mirror)
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix: fixed error in clipboard.lua and fixed formatting for ci

ptdewey 31526205 f34afe83

+24 -12
+2 -3
lua/yankbank/clipboard.lua
··· 13 13 -- avoid adding empty strings 14 14 -- TODO: could block adding single characters here 15 15 if text == "" or text == " " or text == "\n" then 16 - -- if text == "" and text == " " and text == "\n" then -- NOTE: which is correct between and/or here? 17 16 return 18 17 end 19 18 ··· 58 57 if #yank_text <= 1 then 59 58 return 60 59 end 61 - M.add_yank(yanks, reg_types, yank_text, reg_type, opts.max_entries) 60 + M.add_yank(yanks, reg_types, yank_text, reg_type, opts) 62 61 end 63 62 end, 64 63 }) ··· 79 78 return 80 79 end 81 80 82 - M.add_yank(yanks, reg_types, yank_text, reg_type, opts.max_entries) 81 + M.add_yank(yanks, reg_types, yank_text, reg_type, opts) 83 82 end, 84 83 }) 85 84 end
+10 -3
lua/yankbank/data.lua
··· 35 35 for j, line in ipairs(yank_lines) do 36 36 if j == 1 then 37 37 -- Format the line number with uniform spacing 38 - local lineNumber = string.format("%" .. max_digits .. "d: ", yank_num) 38 + local lineNumber = 39 + string.format("%" .. max_digits .. "d: ", yank_num) 39 40 line = line:sub(leading_space_length + 1) 40 41 table.insert(display_lines, lineNumber .. line) 41 42 else 42 43 -- Remove the same amount of leading whitespace as on the first line 43 44 line = line:sub(leading_space_length + 1) 44 45 -- Use spaces equal to the line number's reserved space to align subsequent lines 45 - table.insert(display_lines, string.rep(" ", max_digits + 2) .. line) 46 + table.insert( 47 + display_lines, 48 + string.rep(" ", max_digits + 2) .. line 49 + ) 46 50 end 47 51 table.insert(line_yank_map, i) 48 52 end ··· 50 54 if i < #yanks then 51 55 -- Add a visual separator between yanks, aligned with the yank content 52 56 if sep ~= "" then 53 - table.insert(display_lines, string.rep(" ", max_digits + 2) .. sep) 57 + table.insert( 58 + display_lines, 59 + string.rep(" ", max_digits + 2) .. sep 60 + ) 54 61 end 55 62 table.insert(line_yank_map, false) 56 63 end
+4 -3
lua/yankbank/init.lua
··· 22 22 keymaps = {}, 23 23 } 24 24 25 - local plugin_path = debug.getinfo(1).source:sub(2):match("(.*/).*/.*/") or "./" 25 + -- local plugin_path = debug.getinfo(1).source:sub(2):match("(.*/).*/.*/") or "./" 26 26 27 27 --- wrapper function for main plugin functionality 28 28 ---@param opts table ··· 32 32 opts = opts or default_opts 33 33 34 34 -- initialize buffer and populate bank 35 - local bufnr, display_lines, line_yank_map = menu.create_and_fill_buffer(yanks, reg_types, opts) 35 + local bufnr, display_lines, line_yank_map = 36 + menu.create_and_fill_buffer(yanks, reg_types, opts) 36 37 37 38 -- handle empty bank case 38 39 if not bufnr or not display_lines or not line_yank_map then ··· 45 46 end 46 47 47 48 -- plugin setup 48 - ---@param opts table? 49 + ---@param opts table 49 50 function M.setup(opts) 50 51 -- merge opts with default options table 51 52 -- opts = vim.tbl_deep_extend("force", default_opts, opts or {})
+8 -3
lua/yankbank/menu.lua
··· 60 60 -- define buffer window width and height based on number of columns 61 61 -- FIX: long enough entries will cause window to go below end of screen 62 62 -- FIX: wrapping long lines will cause entries below to not show in menu (requires scrolling to see) 63 - local width = math.min(max_width, vim.api.nvim_get_option_value("columns", {}) - 4) 63 + local width = 64 + math.min(max_width, vim.api.nvim_get_option_value("columns", {}) - 4) 64 65 local height = math.min( 65 66 display_lines and #display_lines or 1, 66 67 vim.api.nvim_get_option_value("lines", {}) - 10 ··· 71 72 relative = "editor", 72 73 width = width, 73 74 height = height, 74 - col = math.floor((vim.api.nvim_get_option_value("columns", {}) - width) / 2), 75 - row = math.floor((vim.api.nvim_get_option_value("lines", {}) - height) / 2), 75 + col = math.floor( 76 + (vim.api.nvim_get_option_value("columns", {}) - width) / 2 77 + ), 78 + row = math.floor( 79 + (vim.api.nvim_get_option_value("lines", {}) - height) / 2 80 + ), 76 81 border = "rounded", 77 82 style = "minimal", 78 83 })