feat: Add show_status

This commit is contained in:
hedy
2023-11-01 21:09:06 +08:00
parent d78d94218a
commit c19b3bd571
3 changed files with 31 additions and 3 deletions

View File

@@ -61,6 +61,9 @@ focus changed), and not for `focus_location` (simrat39/symbols-outline.nvim#119)
- The preview window is positioned to be vertically center-aligned (rather - The preview window is positioned to be vertically center-aligned (rather
than fixed to the top). This is planned to be configurable. than fixed to the top). This is planned to be configurable.
- Feat: Added function and command to show provider and outline window status,
somewhat like `:LspInfo`.
Fixes: Fixes:
- Fix symbol preview (simrat39/symbols-outline.nvim#176) - Fix symbol preview (simrat39/symbols-outline.nvim#176)
@@ -419,6 +422,10 @@ local opts = {
Focus on source window Focus on source window
- **:SymbolsOutlineStatus**
Display current provider and outline window status in the messages area.
### Lua API ### Lua API
@@ -441,11 +448,11 @@ require'symbols-outline'
- **close_outline()** - **close_outline()**
Close the outline window Close the outline window.
- **focus_toggle()** - **focus_toggle()**
Toggle cursor focus between code and outline window Toggle cursor focus between code and outline window.
- **focus_outline()** - **focus_outline()**
@@ -457,7 +464,11 @@ require'symbols-outline'
- **is_open()** - **is_open()**
Return whether the outline window is open Return whether the outline window is open.
- **show_status()**
Display current provider and outline window status in the messages area.
## Default keymaps ## Default keymaps
@@ -488,3 +499,4 @@ require'symbols-outline'
| Pmenu | Highlight of the preview popup windows | | Pmenu | Highlight of the preview popup windows |
| SymbolsOutlineConnector | Highlight of the table connectors | | SymbolsOutlineConnector | Highlight of the table connectors |
| Comment | Highlight of the info virtual text | | Comment | Highlight of the info virtual text |

View File

@@ -61,6 +61,7 @@ local function setup_commands()
cmd('FocusOutline', M.focus_outline, { nargs = 0 }) cmd('FocusOutline', M.focus_outline, { nargs = 0 })
cmd('FocusCode', M.focus_code, { nargs = 0 }) cmd('FocusCode', M.focus_code, { nargs = 0 })
cmd('Focus', M.focus_toggle, { nargs = 0 }) cmd('Focus', M.focus_toggle, { nargs = 0 })
cmd('Status', M.show_status, { nargs = 0 })
end end
------------------------- -------------------------
@@ -394,6 +395,20 @@ function M.is_open()
return M.view:is_open() return M.view:is_open()
end end
function M.show_status()
if providers.has_provider() and _G._symbols_outline_current_provider then
print("Current provider:")
print(_G._symbols_outline_current_provider.name)
if M.view:is_open() then
print("Outline window is open")
else
print("Outline window is not open")
end
else
print("No providers")
end
end
function M.setup(opts) function M.setup(opts)
config.setup(opts) config.setup(opts)
ui.setup_highlights() ui.setup_highlights()

View File

@@ -26,6 +26,7 @@ function M.request_symbols(on_symbols)
local provider = require(value) local provider = require(value)
if provider.should_use_provider(0) then if provider.should_use_provider(0) then
_G._symbols_outline_current_provider = provider _G._symbols_outline_current_provider = provider
_G._symbols_outline_current_provider.name = value
provider.request_symbols(on_symbols) provider.request_symbols(on_symbols)
break break
end end