fix: Handle toggling logic outside the handler
* This way we can close the window while being focused in it. Before, the window was not closed because the handler wasn't called because no lsp was attached
This commit is contained in:
@@ -343,7 +343,6 @@ local function handler(_, _, result)
|
|||||||
if result == nil then return end
|
if result == nil then return end
|
||||||
D.state.code_win = vim.api.nvim_get_current_win()
|
D.state.code_win = vim.api.nvim_get_current_win()
|
||||||
|
|
||||||
if D.state.outline_buf == nil then
|
|
||||||
setup_buffer()
|
setup_buffer()
|
||||||
D.state.outline_items = parse(result)
|
D.state.outline_items = parse(result)
|
||||||
D.state.flattened_outline_items = flatten(parse(result))
|
D.state.flattened_outline_items = flatten(parse(result))
|
||||||
@@ -355,13 +354,15 @@ local function handler(_, _, result)
|
|||||||
D.state.outline_win)
|
D.state.outline_win)
|
||||||
write_details(D.state.outline_buf, details)
|
write_details(D.state.outline_buf, details)
|
||||||
setup_highlights()
|
setup_highlights()
|
||||||
else
|
|
||||||
vim.api.nvim_win_close(D.state.outline_win, true)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function D.toggle_outline()
|
function D.toggle_outline()
|
||||||
vim.lsp.buf_request(0, "textDocument/documentSymbol", getParams(), handler)
|
if D.state.outline_buf == nil then
|
||||||
|
vim.lsp.buf_request(0, "textDocument/documentSymbol", getParams(),
|
||||||
|
handler)
|
||||||
|
else
|
||||||
|
vim.api.nvim_win_close(D.state.outline_win, true)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function D.setup(opts)
|
function D.setup(opts)
|
||||||
|
|||||||
Reference in New Issue
Block a user