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

Configure Feed

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

fmt(fixed styling and ci)

ptdewey 7ff58a21 2eb48aac

+14 -7
-1
.github/workflows/ci.yaml
··· 1 1 name: YankBank CI 2 2 3 3 on: 4 - push: 5 4 pull_request: 6 5 7 6 jobs:
+4 -1
lua/yankbank/persistence.lua
··· 15 15 elseif opts.method == "file" then 16 16 -- TODO: 17 17 require("persistence.file").setup_persistence( 18 - yanks, opts.persist_file, opts.max_entries) 18 + yanks, 19 + opts.persist_file, 20 + opts.max_entries 21 + ) 19 22 elseif opts.method == "sqlite" then 20 23 -- TODO: 21 24 print("sqlite persistence not yet implemented.")
+10 -5
lua/yankbank/persistence/file.lua
··· 9 9 ---@return boolean 10 10 local function file_exists(file) 11 11 local f = io.open(file, "rb") 12 - if f then f:close() end 12 + if f then 13 + f:close() 14 + end 13 15 return f ~= nil 14 16 end 15 17 ··· 17 19 ---@param file string: file path 18 20 ---@return table 19 21 local function read_lines(file) 20 - if not file_exists(file) then return {} end 22 + if not file_exists(file) then 23 + return {} 24 + end 21 25 local lines = {} 22 26 for line in io.lines(file) do 23 - lines[#lines+1] = line 27 + lines[#lines + 1] = line 24 28 end 25 29 return lines 26 30 end ··· 43 47 ---@param line string: line from file being checked 44 48 ---@return table|nil 45 49 local function check_for_entry(line) 46 - local i, l, ft, rt = string.match(line, "<YANKBANK_ENTRY:(%d+),(%d+),(%a+),(%a+)>") 50 + local i, l, ft, rt = 51 + string.match(line, "<YANKBANK_ENTRY:(%d+),(%d+),(%a+),(%a+)>") 47 52 if i then 48 53 return { 49 54 index = tonumber(i), ··· 134 139 print(M.setup_persistence(yanks, "test.txt", 10)) 135 140 yanks = {} 136 141 print(M.setup_persistence(yanks, "test1.txt", 10)) 137 - 142 + print(n_entries) 138 143 139 144 return M