refactoring / upgrade
- bookmarks - better mappings - global helpers - autoloading and vim scriptsmain
parent
9895a84cab
commit
8994636c3f
@ -0,0 +1,20 @@
|
|||||||
|
local ok, plenary_reload = pcall(require, "plenary.reload")
|
||||||
|
if not ok then
|
||||||
|
reloader = require
|
||||||
|
else
|
||||||
|
reloader = plenary_reload.reload_module
|
||||||
|
end
|
||||||
|
|
||||||
|
P = function(v)
|
||||||
|
print(vim.inspect(v))
|
||||||
|
return v
|
||||||
|
end
|
||||||
|
|
||||||
|
RELOAD = function(...)
|
||||||
|
return reloader(...)
|
||||||
|
end
|
||||||
|
|
||||||
|
R = function(name)
|
||||||
|
RELOAD(name)
|
||||||
|
return require(name)
|
||||||
|
end
|
@ -1,2 +0,0 @@
|
|||||||
let g:sneak#s_next=1
|
|
||||||
let g:sneak#use_ic_scs=1
|
|
@ -0,0 +1,11 @@
|
|||||||
|
" sneak
|
||||||
|
" let g:sneak#s_next=1
|
||||||
|
" let g:sneak#use_ic_scs=1
|
||||||
|
|
||||||
|
" MattesGroeger/vim-bookmarks
|
||||||
|
let g:bookmark_sign = ''
|
||||||
|
let g:bookmark_annotation_sign = ''
|
||||||
|
let g:bookmark_no_default_key_mappings = 1
|
||||||
|
let g:bookmark_highlight_lines = 0
|
||||||
|
let g:bookmark_auto_save = 1
|
||||||
|
let g:bookmark_auto_save_file = stdpath('data') . '/bookmarks'
|
@ -0,0 +1,71 @@
|
|||||||
|
local fzf = require("fzf-lua")
|
||||||
|
|
||||||
|
local M = {}
|
||||||
|
|
||||||
|
local function fzf_display_bookmarks(bookmarks)
|
||||||
|
P(bookmarks)
|
||||||
|
|
||||||
|
local fzf_exec_opts = {
|
||||||
|
previewer = "builtin",
|
||||||
|
fzf_opts = {
|
||||||
|
['--preview'] = fzf.shell.action(function(items)
|
||||||
|
local contents = {}
|
||||||
|
vim.tbl_map(function (x)
|
||||||
|
table.insert(contents, x)
|
||||||
|
end, items)
|
||||||
|
return contents
|
||||||
|
end)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fzf.fzf_exec(function(fzf_cb)
|
||||||
|
for _, bookmark in ipairs(bookmarks) do
|
||||||
|
-- P(bookmark.text)
|
||||||
|
local entry_text = string.gsub(bookmark.text, "\t", "")
|
||||||
|
entry_text = string.format("%-40s", entry_text)
|
||||||
|
fzf_cb(entry_text)
|
||||||
|
fzf_cb()
|
||||||
|
end
|
||||||
|
end, fzf_exec_opts)
|
||||||
|
end
|
||||||
|
|
||||||
|
local function get_bookmarks(files, opts)
|
||||||
|
opts = opts or {}
|
||||||
|
local bookmarks = {}
|
||||||
|
|
||||||
|
for _,file in ipairs(files) do
|
||||||
|
for _,line in ipairs(vim.fn['bm#all_lines'](file)) do
|
||||||
|
local bookmark = vim.fn['bm#get_bookmark_by_line'](file, line)
|
||||||
|
|
||||||
|
local text = bookmark.annotation ~= "" and "Annotation: " .. bookmark.annotation or bookmark.content
|
||||||
|
if text == "" then
|
||||||
|
text = "(empty line)"
|
||||||
|
end
|
||||||
|
|
||||||
|
local only_annotated = opts.only_annotated or false
|
||||||
|
|
||||||
|
P(only_annotated)
|
||||||
|
if not (only_annotated and bookmark.annotation == "") then
|
||||||
|
table.insert(bookmarks, {
|
||||||
|
filename = file,
|
||||||
|
lnum = tonumber(line),
|
||||||
|
col=1,
|
||||||
|
text = text,
|
||||||
|
sign_idx = bookmark.sign_idx,
|
||||||
|
})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return bookmarks
|
||||||
|
end
|
||||||
|
|
||||||
|
M.all = function(opts)
|
||||||
|
opts = opts or {}
|
||||||
|
local files = vim.fn['bm#all_files']()
|
||||||
|
bookmarks = get_bookmarks(files)
|
||||||
|
fzf_display_bookmarks(bookmarks)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- M.all()
|
||||||
|
-- return M
|
Loading…
Reference in New Issue