docs: Add script to convert symbols-outline setup opts
This commit is contained in:
25
README.md
25
README.md
@@ -1,25 +1,28 @@
|
|||||||
<!-- panvimdoc-ignore-start -->
|
<!-- panvimdoc-ignore-start -->
|
||||||
|
|
||||||
**A note on fork status**
|
# Fork status
|
||||||
|
|
||||||
This is a fork of the original symbols-outline.nvim which fixes a lot of bugs
|
This is a fork of the original symbols-outline.nvim which fixed a lot of bugs
|
||||||
from the original repo, and also adds many more features ([see #12 on
|
from the original repo, and also added many more features.
|
||||||
github](https://github.com/hedyhli/outline.nvim/issues/12)).
|
|
||||||
|
You can see all the changes from the original plugin before v1.0.0 in [#12 on
|
||||||
|
github](https://github.com/hedyhli/outline.nvim/issues/12).
|
||||||
|
|
||||||
It started out as a personal fork which I maintain for my personal use-cases,
|
It started out as a personal fork which I maintain for my personal use-cases,
|
||||||
soon more and more features found their way in and I started introducing
|
soon more and more features found their way in and I started introducing
|
||||||
significant changes. However, due to simrat's status with the original plugin,
|
significant changes.
|
||||||
I eventually decided to rename and detach the fork, starting to work on this
|
|
||||||
as a new plugin.
|
|
||||||
|
|
||||||
You can see all the changes from the original plugin before fork detach in [#12
|
However, due to simrat's status with the original plugin, I eventually decided
|
||||||
on github](https://github.com/hedyhli/outline.nvim/issues/12).
|
to rename and detach the fork, starting to work on this as a new plugin.
|
||||||
|
|
||||||
|
## Migrating from symbols-outline.nvim
|
||||||
|
|
||||||
|
If you have existing setup opts for symbols-outline.nvim, you can convert it to
|
||||||
|
be usable for outline.nvim using this script: [scripts/convert-symbols-outline-opts.lua](scripts/convert-symbols-outline-opts.lua).
|
||||||
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
<!-- panvimdoc-ignore-start -->
|
|
||||||
|
|
||||||
# outline.nvim
|
# outline.nvim
|
||||||
|
|
||||||
**A sidebar with a tree-like outline of symbols from your code, powered by LSP.**
|
**A sidebar with a tree-like outline of symbols from your code, powered by LSP.**
|
||||||
|
|||||||
125
scripts/convert-symbols-outline-opts.lua
Normal file
125
scripts/convert-symbols-outline-opts.lua
Normal file
@@ -0,0 +1,125 @@
|
|||||||
|
-- This script converts your existing setup opts from symbols-outline.nvim to
|
||||||
|
-- the new format for outline.nvim.
|
||||||
|
--
|
||||||
|
-- You do not need this if your old symbols-outline.nvim config was empty.
|
||||||
|
--
|
||||||
|
-- 1. Save this file somewhere temporary and open this file in nvim.
|
||||||
|
-- 2. Paste your old symbols-outline setup opts in the 'opts' table,
|
||||||
|
-- 3. Put your cursor on the line of 'your_new_opts' table.
|
||||||
|
-- 4. Keeping your cursor there, run ':luafile %'
|
||||||
|
-- 5. You can then '$yi{' to yank it in register 0
|
||||||
|
--
|
||||||
|
-- Read about all the new features and improvements on:
|
||||||
|
-- https://github.com/hedyhli/outline.nvim/issues/12
|
||||||
|
--
|
||||||
|
-- If you encounter any problems, please open an issue.
|
||||||
|
--
|
||||||
|
-- Thanks for using outline.nvim!
|
||||||
|
|
||||||
|
local opts = {
|
||||||
|
--- Example:
|
||||||
|
-- show_guides = false,
|
||||||
|
-- fold_markers = {'>', 'v'},
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
---@diagnostic disable-next-line
|
||||||
|
local your_new_opts = --[[put the cursor on this line]] {
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
----- BEGIN SCRIPT --------------------------------------------------
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
local newopts = {}
|
||||||
|
|
||||||
|
if opts.symbols or opts.symbol_blacklist then
|
||||||
|
newopts.symbols = {
|
||||||
|
icons = opts.symbols,
|
||||||
|
blacklist = opts.symbol_blacklist,
|
||||||
|
}
|
||||||
|
opts.symbols = nil
|
||||||
|
opts.symbol_blacklist = nil
|
||||||
|
end
|
||||||
|
|
||||||
|
if opts.lsp_blacklist then
|
||||||
|
newopts.provider = {
|
||||||
|
lsp = {
|
||||||
|
blacklist_clients = opts.lsp_blacklist
|
||||||
|
}
|
||||||
|
}
|
||||||
|
opts.lsp_blacklist = nil
|
||||||
|
end
|
||||||
|
|
||||||
|
if opts.fold_markers or opts.autofold_depth ~= nil or opts.auto_unfold_hover ~= nil then
|
||||||
|
newopts.symbol_folding = {
|
||||||
|
autofold_depth = opts.autofold_depth,
|
||||||
|
auto_unfold_hover = opts.auto_unfold_hover,
|
||||||
|
markers = opts.fold_markers,
|
||||||
|
}
|
||||||
|
opts.autofold_depth = nil
|
||||||
|
opts.auto_unfold_hover = nil
|
||||||
|
opts.fold_markers = nil
|
||||||
|
end
|
||||||
|
|
||||||
|
if opts and next(opts) ~= nil then
|
||||||
|
newopts.preview_window = {}
|
||||||
|
newopts.outline_window = {}
|
||||||
|
newopts.outline_items = {}
|
||||||
|
|
||||||
|
for _, v in ipairs({'auto_preview', 'border'}) do
|
||||||
|
newopts.preview_window[v] = opts[v]
|
||||||
|
opts[v] = nil
|
||||||
|
end
|
||||||
|
if newopts.preview_window.auto_preview == true then
|
||||||
|
newopts.preview_window.open_hover_on_preview = true
|
||||||
|
end
|
||||||
|
|
||||||
|
if opts.preview_bg_highlight then
|
||||||
|
newopts.preview_window.winhl = 'Normal:'..opts.preview_bg_highlight
|
||||||
|
opts.preview_bg_highlight = nil
|
||||||
|
end
|
||||||
|
|
||||||
|
for _, v in ipairs({'show_symbol_details', 'highlight_hovered_item'}) do
|
||||||
|
newopts.outline_items[v] = opts[v]
|
||||||
|
opts[v] = nil
|
||||||
|
end
|
||||||
|
|
||||||
|
for _, v in ipairs({
|
||||||
|
'width', 'relative_width', 'position', 'border', 'wrap', 'auto_close',
|
||||||
|
'show_numbers', 'show_relative_numbers', 'show_cursorline',
|
||||||
|
}) do
|
||||||
|
newopts.outline_window[v] = opts[v]
|
||||||
|
opts[v] = nil
|
||||||
|
end
|
||||||
|
|
||||||
|
if type(opts.show_guides) == 'boolean' then
|
||||||
|
newopts.guides = {}
|
||||||
|
newopts.guides.enabled = opts.show_guides
|
||||||
|
end
|
||||||
|
opts.show_guides = nil
|
||||||
|
|
||||||
|
if opts.keymaps ~= nil then
|
||||||
|
newopts.keymaps = opts.keymaps
|
||||||
|
newopts.keymaps.peek_location = opts.keymaps.focus_location
|
||||||
|
newopts.keymaps.focus_location = nil
|
||||||
|
opts.keymaps = nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
for _, v in ipairs({'outline_items', 'outline_window', 'preview_window'}) do
|
||||||
|
if newopts[v] and next(newopts[v]) == nil then
|
||||||
|
newopts[v] = nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local all = vim.inspect(newopts)
|
||||||
|
local lines = vim.split(all, '\n', {plain = true, trimempty = true})
|
||||||
|
table.remove(lines, 1) table.remove(lines, #lines)
|
||||||
|
local curline = vim.api.nvim_win_get_cursor(0)[1]
|
||||||
|
vim.api.nvim_buf_set_lines(0, curline, curline, true, lines)
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
----- END SCRIPT ----------------------------------------------------
|
||||||
|
---------------------------------------------------------------------
|
||||||
Reference in New Issue
Block a user