fix: set tagstack when we jump with lsp in telescope (#1887)

Co-authored-by: Simon Hauser <Simon-Hauser@outlook.de>
This commit is contained in:
dagle
2022-05-18 19:59:12 +02:00
committed by GitHub
parent 01fc5a9274
commit 3cc44f8f05
4 changed files with 16 additions and 3 deletions

View File

@@ -133,14 +133,21 @@ action_set.edit = function(prompt_bufnr, command)
local picker = action_state.get_current_picker(prompt_bufnr) local picker = action_state.get_current_picker(prompt_bufnr)
require("telescope.actions").close(prompt_bufnr) require("telescope.actions").close(prompt_bufnr)
local win_id = picker.get_selection_window(picker, entry) local win_id = picker.get_selection_window(picker, entry)
if win_id ~= 0 and a.nvim_get_current_win() ~= win_id then
vim.api.nvim_set_current_win(win_id)
end
if picker.push_cursor_on_edit then if picker.push_cursor_on_edit then
vim.cmd "normal! m'" vim.cmd "normal! m'"
end end
if picker.push_tagstack_on_edit then
local from = { vim.fn.bufnr "%", vim.fn.line ".", vim.fn.col ".", 0 }
local items = { { tagname = vim.fn.expand "<cword>", from = from } }
vim.fn.settagstack(vim.fn.win_getid(), { items = items }, "t")
end
if win_id ~= 0 and a.nvim_get_current_win() ~= win_id then
vim.api.nvim_set_current_win(win_id)
end
if entry_bufnr then if entry_bufnr then
if not vim.api.nvim_buf_get_option(entry_bufnr, "buflisted") then if not vim.api.nvim_buf_get_option(entry_bufnr, "buflisted") then
vim.api.nvim_buf_set_option(entry_bufnr, "buflisted", true) vim.api.nvim_buf_set_option(entry_bufnr, "buflisted", true)

View File

@@ -1042,6 +1042,7 @@ internal.marks = function(opts)
previewer = conf.grep_previewer(opts), previewer = conf.grep_previewer(opts),
sorter = conf.generic_sorter(opts), sorter = conf.generic_sorter(opts),
push_cursor_on_edit = true, push_cursor_on_edit = true,
push_tagstack_on_edit = true,
}):find() }):find()
end end

View File

@@ -47,6 +47,7 @@ lsp.references = function(opts)
previewer = conf.qflist_previewer(opts), previewer = conf.qflist_previewer(opts),
sorter = conf.generic_sorter(opts), sorter = conf.generic_sorter(opts),
push_cursor_on_edit = true, push_cursor_on_edit = true,
push_tagstack_on_edit = true,
}):find() }):find()
end) end)
end end
@@ -93,6 +94,8 @@ local function list_or_jump(action, title, opts)
}, },
previewer = conf.qflist_previewer(opts), previewer = conf.qflist_previewer(opts),
sorter = conf.generic_sorter(opts), sorter = conf.generic_sorter(opts),
push_cursor_on_edit = true,
push_tagstack_on_edit = true,
}):find() }):find()
end end
end) end)
@@ -154,6 +157,7 @@ lsp.document_symbols = function(opts)
sorter = conf.generic_sorter(opts), sorter = conf.generic_sorter(opts),
}, },
push_cursor_on_edit = true, push_cursor_on_edit = true,
push_tagstack_on_edit = true,
}):find() }):find()
end) end)
end end

View File

@@ -117,6 +117,7 @@ function Picker:new(opts)
selection_strategy = get_default(opts.selection_strategy, config.values.selection_strategy), selection_strategy = get_default(opts.selection_strategy, config.values.selection_strategy),
push_cursor_on_edit = get_default(opts.push_cursor_on_edit, false), push_cursor_on_edit = get_default(opts.push_cursor_on_edit, false),
push_tagstack_on_edit = get_default(opts.push_tagstack_on_edit, false),
layout_strategy = layout_strategy, layout_strategy = layout_strategy,
layout_config = config.smarter_depth_2_extend(opts.layout_config or {}, config.values.layout_config or {}), layout_config = config.smarter_depth_2_extend(opts.layout_config or {}, config.values.layout_config or {}),