added `marks`

main
bhagwan 3 years ago
parent faad0474d4
commit cea8e27991

@ -170,6 +170,7 @@ nnoremap <c-P> <cmd>lua require('fzf-lua').files()<CR>
|`commands`|neovim commands|
|`command_history`|command history|
|`search_history`|search history|
|`marks`|:marks|
|`registers`|:registers|
|`keymaps`|key mappings|
|`spell_suggest`|spelling suggestions|
@ -423,15 +424,16 @@ EOF
+ [x] ~~LSP (refs, symbols, etc)~~ (2021-07-20)
+ [x] ~~git commits~~ (2021-08-05)
+ [x] ~~git branches~~ (2021-08-05)
+ [x] nvim builtin:
+ [x] nvim built-in:
* [x] ~~commands~~ (2021-08-14)
* [x] ~~command history~~ (2021-08-14)
* [x] ~~search history~~ (2021-08-14)
* [x] ~~registers~~ (2021-08-14)
* [x] ~~keymaps~~ (2021-08-14)
* [x] ~~spelling suggestions~~ (2021-08-14)
+ [ ] marks
* [x] ~~marks~~ (2021-08-14)
+ [ ] tags
- [ ] Improve previewer for `buffers`, `marks`
- [ ] Built-in previewer with treesitter support
- [ ] Add built-in plugin documentation
- [ ] Complete the Wiki

@ -148,6 +148,16 @@ M.search = function(selected)
utils.feed_keys_termcodes(string.format("/%s<CR>", query))
end
M.goto_mark = function(selected)
if not selected then return end
local mark = selected[1]
if #selected>1 then mark = selected[2] end
mark = mark:match("[^ ]+")
vim.cmd("stopinsert")
vim.cmd("normal! '" .. mark)
-- vim.fn.feedkeys(string.format("'%s", mark))
end
M.spell_apply = function(selected)
if not selected then return end
local word = selected[1]

@ -316,6 +316,12 @@ M.globals.builtin = {
},
}
M.globals.nvim = {
marks = {
prompt = 'Marks> ',
actions = {
["default"] = actions.goto_mark,
},
},
commands = {
prompt = 'Commands> ',
actions = {

@ -68,6 +68,7 @@ M.help_tags = require'fzf-lua.providers.helptags'.helptags
M.man_pages = require'fzf-lua.providers.manpages'.manpages
M.colorschemes = require'fzf-lua.providers.colorschemes'.colorschemes
M.marks = require'fzf-lua.providers.nvim'.marks
M.keymaps = require'fzf-lua.providers.nvim'.keymaps
M.registers = require'fzf-lua.providers.nvim'.registers
M.commands = require'fzf-lua.providers.nvim'.commands

@ -84,6 +84,53 @@ M.search_history = function(opts)
history(opts, "search")
end
M.marks = function(opts)
opts = config.normalize_opts(opts, config.globals.nvim.marks)
coroutine.wrap(function ()
local marks = vim.fn.execute("marks")
marks = vim.split(marks, "\n")
local prev_act = action(function (args, fzf_lines, _)
local mark = args[1]:match("[^ ]+")
local bufnr, lnum, _, _ = unpack(vim.fn.getpos("'"..mark))
if vim.api.nvim_buf_is_loaded(bufnr) then
return vim.api.nvim_buf_get_lines(bufnr, lnum, fzf_lines+lnum, false)
else
local name = vim.fn.expand(args[1]:match(".* (.*)"))
if vim.fn.filereadable(name) ~= 0 then
return vim.fn.readfile(name, "", fzf_lines)
end
return "UNLOADED: " .. name
end
end)
local entries = {}
for i = #marks, 3, -1 do
local mark, line, col, text = marks[i]:match("(.)%s+(%d+)%s+(%d+)%s+(.*)")
table.insert(entries, string.format("%-15s %-15s %-15s %s",
utils.ansi_codes.yellow(mark),
utils.ansi_codes.blue(line),
utils.ansi_codes.green(col),
text))
end
table.sort(entries, function(a, b) return a<b end)
opts.nomulti = true
opts.preview = prev_act
-- opts.preview_window = 'hidden:down:0'
local selected = core.fzf(opts, entries,
core.build_fzf_cli(opts),
config.winopts(opts))
if not selected then return end
actions.act(opts.actions, selected)
end)()
end
M.registers = function(opts)
opts = config.normalize_opts(opts, config.globals.nvim.registers)

Loading…
Cancel
Save