From 36a4957f74d72324292348278922127c52e14bce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C4=99drzej=20Boczar?= Date: Sat, 11 May 2024 22:07:20 +0200 Subject: [PATCH] Support outline.nvim (#54) * 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 --- README.md | 1 + doc/possession.txt | 5 +++-- lua/possession/config.lua | 1 + lua/possession/plugins/init.lua | 1 + lua/possession/plugins/outline.lua | 24 ++++++++++++++++++++++++ 5 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 lua/possession/plugins/outline.lua diff --git a/README.md b/README.md index 084e574..e70f332 100644 --- a/README.md +++ b/README.md @@ -111,6 +111,7 @@ require('possession').setup { nvim_tree = true, neo_tree = true, symbols_outline = true, + outline = true, tabby = true, dap = true, dapui = true, diff --git a/doc/possession.txt b/doc/possession.txt index e66ec22..5954032 100644 --- a/doc/possession.txt +++ b/doc/possession.txt @@ -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* diff --git a/lua/possession/config.lua b/lua/possession/config.lua index 695dada..c6fd2b6 100644 --- a/lua/possession/config.lua +++ b/lua/possession/config.lua @@ -58,6 +58,7 @@ local function defaults() nvim_tree = true, neo_tree = true, symbols_outline = true, + outline = true, tabby = true, dap = true, dapui = true, diff --git a/lua/possession/plugins/init.lua b/lua/possession/plugins/init.lua index 355c14b..ca87a10 100644 --- a/lua/possession/plugins/init.lua +++ b/lua/possession/plugins/init.lua @@ -9,6 +9,7 @@ local plugins = { 'nvim_tree', 'neo_tree', 'symbols_outline', + 'outline', 'tabby', 'neotest', 'dapui', diff --git a/lua/possession/plugins/outline.lua b/lua/possession/plugins/outline.lua new file mode 100644 index 0000000..69a5b6d --- /dev/null +++ b/lua/possession/plugins/outline.lua @@ -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, +})