-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmarks-config.lua
More file actions
86 lines (78 loc) · 2.94 KB
/
marks-config.lua
File metadata and controls
86 lines (78 loc) · 2.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
local M = {
'MomePP/marks.nvim',
event = { 'BufReadPost', 'BufNewFile' },
}
M.opts = {
-- whether to map keybinds or not. default true
default_mappings = false,
-- which builtin marks to show. default {}
builtin_marks = {},
-- whether movements cycle back to the beginning/end of buffer. default true
cyclic = true,
-- whether the shada file is updated after modifying uppercase marks. default false
force_write_shada = false,
-- sign priorities for each type of mark - builtin marks, uppercase marks, lowercase
-- marks, and bookmarks.
-- can be ither a table with all/none of the keys, or a single number, in which case
-- the priority applies to all marks.
-- default 10.
sign_priority = 15,
-- disables mark tracking for specific filetypes. default {}
excluded_filetypes = {
'toggleterm',
'lspinfo',
'terminal',
'help',
},
-- extra options modified by `MomePP/marks.nvim`
marks_sign = '',
}
M.keys = function()
local marks_keymap = require('config.keymaps').marks
-- NOTE: refresh marks after written buffer
vim.api.nvim_create_autocmd('BufWritePost', {
callback = function() require('marks').refresh(true) end
})
return {
{ marks_keymap.toggle, function() require('marks').toggle() end },
{ marks_keymap.next, function() require('marks').next() end },
{ marks_keymap.prev, function() require('marks').prev() end },
{ marks_keymap.clear, function() require('marks').delete_buf() end },
-- NOTE: use quickfix to show all marks
{
marks_keymap.list,
function()
local gen_items = function(marks_tbl)
local items = {}
for _, mark in ipairs(marks_tbl) do
local path = mark.path
local buf = mark.bufnr
local line = mark.line
local label = mark.mark
items[#items + 1] = {
text = table.concat({ label, path, line }, " "),
label = label,
buf = buf,
file = path,
pos = { mark.lnum, mark.col },
}
end
table.sort(items, function(a, b)
if a.file == b.file then
return a.label < b.label
else
return a.file < b.file
end
end)
return items
end
require('snacks').picker.pick({
source = 'marks.nvim',
format = 'file',
items = gen_items(require('marks').mark_state:get_all_list() or {}),
})
end
},
}
end
return M