From 04b4abb5ba369ba42f2fc2d2b23179ccd8b8be02 Mon Sep 17 00:00:00 2001 From: Julian Doherty Date: Sat, 27 Aug 2022 11:48:28 +1000 Subject: [PATCH 1/3] add wrap config option, default to false Default to not wrapping long function names etc that are too big for the window. If wrap=true is set, use some sane linebreak/breakindent/showbreak options to wrap with an indent at the current indent level of the UI tree, instead of just wrapping back to the far left side of the window. --- README.md | 2 ++ lua/symbols-outline/config.lua | 1 + lua/symbols-outline/view.lua | 8 ++++++++ 3 files changed, 11 insertions(+) diff --git a/README.md b/README.md index 14cad04..10cbcaa 100644 --- a/README.md +++ b/README.md @@ -46,6 +46,7 @@ local opts = { autofold_depth = nil, auto_unfold_hover = true, fold_markers = { '', '' }, + wrap = false, keymaps = { -- These keymaps can be a string or a table for multiple keys close = {"", "q"}, goto_location = "", @@ -114,6 +115,7 @@ local opts = { | autofold_depth | Depth past which nodes will be folded by default | int | nil | | auto_unfold_hover | Automatically unfold hovered symbol | boolean | true | | fold_markers | Markers to denote foldable symbol's status | table (array) | { '', '' } | +| wrap | Whether to wrap long lines, or let them flow off the window | boolean | false | ## Commands diff --git a/lua/symbols-outline/config.lua b/lua/symbols-outline/config.lua index e5ed735..a3fa596 100644 --- a/lua/symbols-outline/config.lua +++ b/lua/symbols-outline/config.lua @@ -19,6 +19,7 @@ M.defaults = { autofold_depth = nil, auto_unfold_hover = true, fold_markers = { '', '' }, + wrap = true, keymaps = { -- These keymaps can be a string or a table for multiple keys close = { '', 'q' }, goto_location = '', diff --git a/lua/symbols-outline/view.lua b/lua/symbols-outline/view.lua index 0202ac6..dc78e0c 100644 --- a/lua/symbols-outline/view.lua +++ b/lua/symbols-outline/view.lua @@ -27,6 +27,14 @@ function View:setup_view() vim.api.nvim_win_set_option(self.winnr, 'relativenumber', false) vim.api.nvim_win_set_option(self.winnr, 'winfixwidth', true) vim.api.nvim_win_set_option(self.winnr, 'list', false) + vim.api.nvim_win_set_option(self.winnr, 'wrap', config.options.wrap) + vim.api.nvim_win_set_option(self.winnr, 'linebreak', true) -- only has effect when wrap=true + vim.api.nvim_win_set_option(self.winnr, 'breakindent', true) -- only has effect when wrap=true + -- Would be nice to use ui.markers.vertical as part of showbreak to keep + -- continuity of the tree UI, but there's currently no way to style the + -- color, apart from globally overriding hl-NonText, which will potentially + -- mess with other theme/user settings. So just use empty spaces for now. + vim.api.nvim_win_set_option(self.winnr, 'showbreak', ' ') -- only has effect when wrap=true. -- buffer stuff vim.api.nvim_buf_set_name(self.bufnr, 'OUTLINE') vim.api.nvim_buf_set_option(self.bufnr, 'filetype', 'Outline') From a6d40cd63c4be2823d59c833318c88d3f3ec901c Mon Sep 17 00:00:00 2001 From: Julian Doherty Date: Sat, 27 Aug 2022 11:53:20 +1000 Subject: [PATCH 2/3] fix formatting --- README.md | 2 +- lua/symbols-outline/view.lua | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 10cbcaa..5fdd369 100644 --- a/README.md +++ b/README.md @@ -114,7 +114,7 @@ local opts = { | symbol_blacklist | Which symbols to ignore ([possible values](./lua/symbols-outline/symbols.lua)) | table (array) | {} | | autofold_depth | Depth past which nodes will be folded by default | int | nil | | auto_unfold_hover | Automatically unfold hovered symbol | boolean | true | -| fold_markers | Markers to denote foldable symbol's status | table (array) | { '', '' } | +| fold_markers | Markers to denote foldable symbol's status | table (array) | { '', '' } | | wrap | Whether to wrap long lines, or let them flow off the window | boolean | false | ## Commands diff --git a/lua/symbols-outline/view.lua b/lua/symbols-outline/view.lua index dc78e0c..3ffd0f6 100644 --- a/lua/symbols-outline/view.lua +++ b/lua/symbols-outline/view.lua @@ -57,9 +57,9 @@ end function View:is_open() return self.winnr - and self.bufnr - and vim.api.nvim_buf_is_valid(self.bufnr) - and vim.api.nvim_win_is_valid(self.winnr) + and self.bufnr + and vim.api.nvim_buf_is_valid(self.bufnr) + and vim.api.nvim_win_is_valid(self.winnr) end return View From 0d8d2e8c73f7b743d83a84d1e7b1e35272f9d4e6 Mon Sep 17 00:00:00 2001 From: Julian Doherty Date: Sat, 27 Aug 2022 15:10:19 +1000 Subject: [PATCH 3/3] default wrap to false --- lua/symbols-outline/config.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/symbols-outline/config.lua b/lua/symbols-outline/config.lua index a3fa596..a7cbe5a 100644 --- a/lua/symbols-outline/config.lua +++ b/lua/symbols-outline/config.lua @@ -19,7 +19,7 @@ M.defaults = { autofold_depth = nil, auto_unfold_hover = true, fold_markers = { '', '' }, - wrap = true, + wrap = false, keymaps = { -- These keymaps can be a string or a table for multiple keys close = { '', 'q' }, goto_location = '',