aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmytro Meleshko <dmytro.meleshko@gmail.com>2021-12-04 23:14:38 +0200
committerGitHub <noreply@github.com>2021-12-04 22:14:38 +0100
commit222ef0c00d97aa2d5e17ca6b14aea037155595ee (patch)
treef1f02fa5220ff02f10d7e8d2a2b346c1fdfb10ba
parent8dcf45c824b421b0b8723a09435ea40e2626b771 (diff)
downloadrneovim-222ef0c00d97aa2d5e17ca6b14aea037155595ee.tar.gz
rneovim-222ef0c00d97aa2d5e17ca6b14aea037155595ee.tar.bz2
rneovim-222ef0c00d97aa2d5e17ca6b14aea037155595ee.zip
feat(lsp,diagnostic): open folds in jump-related functions (#16520)
-rw-r--r--runtime/lua/vim/diagnostic.lua11
-rw-r--r--runtime/lua/vim/lsp/util.lua2
2 files changed, 9 insertions, 4 deletions
diff --git a/runtime/lua/vim/diagnostic.lua b/runtime/lua/vim/diagnostic.lua
index a903f25b58..708ee1727a 100644
--- a/runtime/lua/vim/diagnostic.lua
+++ b/runtime/lua/vim/diagnostic.lua
@@ -508,10 +508,13 @@ local function diagnostic_move_pos(opts, pos)
return
end
- -- Save position in the window's jumplist
- vim.api.nvim_win_call(win_id, function() vim.cmd("normal! m'") end)
-
- vim.api.nvim_win_set_cursor(win_id, {pos[1] + 1, pos[2]})
+ vim.api.nvim_win_call(win_id, function()
+ -- Save position in the window's jumplist
+ vim.cmd("normal! m'")
+ vim.api.nvim_win_set_cursor(win_id, {pos[1] + 1, pos[2]})
+ -- Open folds under the cursor
+ vim.cmd("normal! zv")
+ end)
if float then
local float_opts = type(float) == "table" and float or {}
diff --git a/runtime/lua/vim/lsp/util.lua b/runtime/lua/vim/lsp/util.lua
index fad2b962b5..059e66c53a 100644
--- a/runtime/lua/vim/lsp/util.lua
+++ b/runtime/lua/vim/lsp/util.lua
@@ -965,6 +965,8 @@ function M.jump_to_location(location)
local row = range.start.line
local col = get_line_byte_from_position(0, range.start)
api.nvim_win_set_cursor(0, {row + 1, col})
+ -- Open folds under the cursor
+ vim.cmd("normal! zv")
return true
end