add cursor location to jumplist (closes issue #147)

main
bhagwan 3 years ago
parent a11f5eb9d4
commit 59d8f6eed5

@ -53,6 +53,8 @@ M.vimcmd_file = function(vimcmd, selected, opts)
vim.cmd(vimcmd .. " " .. vim.fn.fnameescape(entry.path))
end
if entry.line > 1 or entry.col > 1 then
-- add current location to jumplist
vim.cmd("normal! m`")
vim.api.nvim_win_set_cursor(0, {tonumber(entry.line), tonumber(entry.col)-1})
vim.cmd("norm! zz")
end

@ -241,13 +241,13 @@ M.buffer_lines = function(opts)
-- ignore bufnr when searching
-- disable multi-select
opts.nomulti = true
opts.fzf_opts["--no-multi"] = ''
opts.fzf_opts["--preview-window"] = 'hidden:right:0'
opts.fzf_opts["--delimiter"] = vim.fn.shellescape(']')
opts.fzf_opts["--nth"] = '2,-1'
if opts.search and #opts.search>0 then
opts.fzf_opts['--query'] = vim.fn.shellescape(opts.search)
opts.fzf_opts['--query'] = vim.fn.shellescape(opts.search)
end
local selected = core.fzf(opts, items)
@ -258,7 +258,12 @@ M.buffer_lines = function(opts)
actions.act(opts.actions, selected, opts)
if line then vim.api.nvim_win_set_cursor(0, {line, 0}) end
if line then
-- add current location to jumplist
vim.cmd("normal! m`")
vim.api.nvim_win_set_cursor(0, {line, 0})
vim.cmd("norm! zz")
end
end)()
end
@ -316,7 +321,7 @@ M.tabs = function(opts)
end
end
opts.nomulti = true
opts.fzf_opts["--no-multi"] = ''
opts.fzf_opts["--preview-window"] = 'hidden:right:0'
opts.fzf_opts["--delimiter"] = vim.fn.shellescape('[\\)]')
opts.fzf_opts["---with-nth"] = '2'

@ -87,7 +87,7 @@ end
M.branches = function(opts)
opts = config.normalize_opts(opts, config.globals.git.branches)
if not opts then return end
opts.nomulti = true
opts.fzf_opts["--no-multi"] = ''
opts._preview = path.git_cwd(opts.preview, opts.cwd)
opts.preview = fzf_helpers.choices_to_shell_cmd_previewer(function(items)
local branch = items[1]:gsub("%*", "") -- remove the * from current branch

@ -342,8 +342,8 @@ M.code_actions = function(opts)
end
end)
opts.nomulti = true
opts.previewer = false
opts.fzf_opts["--no-multi"] = ''
opts.fzf_opts["--preview-window"] = 'right:0'
opts.fzf_opts["--delimiter"] = vim.fn.shellescape(':')
opts = set_lsp_fzf_fn(opts)

Loading…
Cancel
Save