Document border option and publicize has_code_win

This commit is contained in:
hedy
2023-11-02 17:31:37 +08:00
parent 4358ce8e9b
commit 841825b747
4 changed files with 14 additions and 5 deletions

View File

@@ -292,6 +292,11 @@ local opts = {
-- If you disable this you can still open hover_symbol using your keymap -- If you disable this you can still open hover_symbol using your keymap
-- below. -- below.
open_hover_on_preview = true, open_hover_on_preview = true,
-- Border option for floating preview window.
-- Options include: single/double/rounded/solid/shadow or an array of border
-- characters.
-- See :help nvim_open_win() and search for "border" option.
border = 'single',
-- Behaviour changed in this fork: -- Behaviour changed in this fork:
-- Auto close the outline window if goto_location is triggered and not for -- Auto close the outline window if goto_location is triggered and not for
-- focus_location -- focus_location
@@ -325,7 +330,9 @@ local opts = {
keymaps = { keymaps = {
show_help = '?', show_help = '?',
close = {"<Esc>", "q"}, close = {"<Esc>", "q"},
-- Jump to symbol under cursor -- Jump to symbol under cursor.
-- It can auto close the outline window when triggered, see
-- 'auto_close' option above.
goto_location = "<Cr>", goto_location = "<Cr>",
-- Jump to symbol under cursor but keep focus on outline window -- Jump to symbol under cursor but keep focus on outline window
focus_location = "o", focus_location = "o",

View File

@@ -375,13 +375,13 @@ function M.focus_outline()
end end
function M.focus_code() function M.focus_code()
if M.state.code_win then if require('symbols-outline.preview').has_code_win() then
vim.fn.win_gotoid(M.state.code_win) vim.fn.win_gotoid(M.state.code_win)
end end
end end
function M.focus_toggle() function M.focus_toggle()
if M.view:is_open() and M.state.code_win then if M.view:is_open() and require('symbols-outline.preview').has_code_win() then
local winid = vim.fn.win_getid() local winid = vim.fn.win_getid()
if winid == M.state.code_win then if winid == M.state.code_win then
vim.fn.win_gotoid(M.view.winnr) vim.fn.win_gotoid(M.view.winnr)

View File

@@ -3,12 +3,12 @@ local vim = vim
local M = {} local M = {}
M.defaults = { M.defaults = {
position = 'right',
width = 25,
highlight_hovered_item = true, highlight_hovered_item = true,
show_guides = true, show_guides = true,
position = 'right',
border = 'single', border = 'single',
relative_width = true, relative_width = true,
width = 25,
auto_close = false, auto_close = false,
auto_preview = false, auto_preview = false,
open_hover_on_preview = true, open_hover_on_preview = true,

View File

@@ -24,6 +24,8 @@ local function has_code_win()
return isBufValid return isBufValid
end end
M.has_code_win = has_code_win
local function get_offset() local function get_offset()
local outline_winnr = so.view.winnr local outline_winnr = so.view.winnr
local width = 53 local width = 53