Skip to content

Commit

Permalink
Support outline.nvim (#54)
Browse files Browse the repository at this point in the history
* feat(plugin): support fork of symbols-outline

The symbols-outline.nvim plugin was archived, and there is a popular
fork that added some nice new features. The fork's filetype is still
"Outline", but the user commands have changed.

ref: https://github.com/hedyhli/outline.nvim

* feat(plugin): separate support for outline.nvim and symbols-outline.nvim

---------

Co-authored-by: Ben Elan <[email protected]>
  • Loading branch information
jedrzejboczar and benelan authored May 11, 2024
1 parent 03a1e1c commit 36a4957
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ require('possession').setup {
nvim_tree = true,
neo_tree = true,
symbols_outline = true,
outline = true,
tabby = true,
dap = true,
dapui = true,
Expand Down
5 changes: 3 additions & 2 deletions doc/possession.txt
Original file line number Diff line number Diff line change
Expand Up @@ -239,9 +239,10 @@ Currently no configuration options beside enabling/disabling are available.
Saves neo-tree windows and restores them when loading the session.

*possession-symbols-outline*
*possession-outline*

Saves symbols-outline.nvim windows and restores when loading session.
NOTE: currently this only works for a single outline due to
Saves symbols-outline.nvim/outline.nvim windows and restores when loading
session. NOTE: currently this only works for a single outline due to
symbols-outline.nvim limitations

*possession-tabby*
Expand Down
1 change: 1 addition & 0 deletions lua/possession/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ local function defaults()
nvim_tree = true,
neo_tree = true,
symbols_outline = true,
outline = true,
tabby = true,
dap = true,
dapui = true,
Expand Down
1 change: 1 addition & 0 deletions lua/possession/plugins/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ local plugins = {
'nvim_tree',
'neo_tree',
'symbols_outline',
'outline',
'tabby',
'neotest',
'dapui',
Expand Down
24 changes: 24 additions & 0 deletions lua/possession/plugins/outline.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
local plugins = require('possession.plugins')
local utils = require('possession.utils')

local function buf_is_plugin(buf)
return vim.api.nvim_buf_get_option(buf, 'filetype') == 'Outline'
end

local find_tab_buf = function(tab)
return utils.find_tab_buf(tab, buf_is_plugin)
end

-- NOTE: currently symbols-outline does not really work on per-tab basis so this does not make sense but in
-- theory symbols-outline could easily work like other file-trees so stick with this implementation for now
return plugins.implement_file_tree_plugin_hooks('symbols-outline', {
has_plugin = 'outline',
buf_is_plugin = buf_is_plugin,
open_in_tab = function(tab)
vim.cmd('OutlineOpen')
-- Need to wait for some async stuff
vim.wait(100, function()
return find_tab_buf(tab) ~= nil
end)
end,
})

0 comments on commit 36a4957

Please sign in to comment.