feat: Add follow_cursor and restore_location

New lua API function: follow_cursor (supports opts.focus_outline).
This sets location in outline to match location in code.

New keymap: restore_location (C-g) by default.
This provides the same functionality as follow_cursor.

I've also refactored other lua API functions for consistency of using
`opts.focus_outline`. If opts is not provided, focus_outline is
defaulted to true. To change this behaviour, set it to false.
This commit is contained in:
hedy
2023-11-06 09:20:52 +08:00
parent ceb9a4841d
commit 9e96b54de9
7 changed files with 225 additions and 90 deletions

View File

@@ -83,11 +83,12 @@ local function convert_symbols(result)
end
---@param on_symbols function
function M.request_symbols(on_symbols)
---@param opts table
function M.request_symbols(on_symbols, opts)
vim.fn.call('CocActionAsync', {
'documentSymbols',
function(_, symbols)
on_symbols { [1000000] = { result = convert_symbols(symbols) } }
on_symbols({ [1000000] = { result = convert_symbols(symbols) } }, opts)
end,
})
end