fix: migrating to 0.11
fix: migrating to 0.11 fix: migrating to 0.11 fix: migrating to 0.11
This commit is contained in:
@@ -19,7 +19,7 @@ function Float:open(lines, hl, title, indent)
|
||||
indent = indent or 0
|
||||
|
||||
self.bufnr = vim.api.nvim_create_buf(false, true)
|
||||
vim.api.nvim_buf_set_option(self.bufnr, 'bufhidden', 'delete')
|
||||
vim.api.nvim_set_option_value('bufhidden', 'delete', { buf = self.bufnr })
|
||||
|
||||
local maxwidth = 0
|
||||
for _, l in ipairs(lines) do
|
||||
@@ -60,22 +60,15 @@ function Float:open(lines, hl, title, indent)
|
||||
end
|
||||
end
|
||||
|
||||
vim.api.nvim_win_set_option(self.winnr, 'winfixwidth', true)
|
||||
vim.api.nvim_set_option_value('winfixwidth', true, { win = self.winnr })
|
||||
vim.api.nvim_buf_set_lines(self.bufnr, 0, -1, false, lines)
|
||||
vim.api.nvim_buf_set_option(self.bufnr, 'modifiable', false)
|
||||
vim.api.nvim_buf_set_option(self.bufnr, 'ft', 'OutlineHelp')
|
||||
vim.api.nvim_set_option_value('modifiable', false, { buf = self.bufnr })
|
||||
vim.api.nvim_set_option_value('ft', 'OutlineHelp', { buf = self.bufnr })
|
||||
|
||||
if hl then
|
||||
self.ns = vim.api.nvim_create_namespace('OutlineHelp')
|
||||
for _, h in ipairs(hl) do
|
||||
vim.api.nvim_buf_add_highlight(
|
||||
self.bufnr,
|
||||
self.ns,
|
||||
h.name,
|
||||
h.line,
|
||||
h.from + indent,
|
||||
(h.to ~= -1 and h.to + indent) or -1
|
||||
)
|
||||
vim.hl.range(self.bufnr, self.ns, h.name, { h.line, h.from + indent }, { h.line, (h.to ~= -1 and h.to + indent) or -1 })
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -29,9 +29,7 @@ function M.hovers(bufnr, nodes)
|
||||
for line, node in ipairs(nodes) do
|
||||
if node.hovered then
|
||||
-- stylua: ignore start
|
||||
vim.api.nvim_buf_add_highlight(
|
||||
bufnr, M.ns.hover, 'OutlineCurrent', line - 1, node.prefix_length, -1
|
||||
)
|
||||
vim.hl.range(bufnr, M.ns.hover, 'OutlineCurrent', { line - 1, node.prefix_length }, { line - 1, -1 })
|
||||
-- stylua: ignore end
|
||||
end
|
||||
end
|
||||
@@ -43,9 +41,7 @@ end
|
||||
function M.items(bufnr, hl_list)
|
||||
for _, h in ipairs(hl_list) do
|
||||
-- stylua: ignore start
|
||||
vim.api.nvim_buf_add_highlight(
|
||||
bufnr, M.ns.items, h.name, h.line - 1, h.from, h.to
|
||||
)
|
||||
vim.hl.range(bufnr, M.ns.items, h.name, { h.line - 1, h.from }, { h.line - 1, h.to })
|
||||
-- stylua: ignore end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -278,7 +278,7 @@ function M.show_status()
|
||||
}
|
||||
|
||||
if buf and vim.api.nvim_buf_is_valid(buf) then
|
||||
ctx.ft = vim.api.nvim_buf_get_option(buf, 'ft')
|
||||
ctx.ft = vim.api.nvim_get_option_value('ft', { buf = buf })
|
||||
ctx.filter = cfg.o.symbols.user_config_filter[ctx.ft]
|
||||
-- 'else' is handled in help.lua
|
||||
end
|
||||
|
||||
@@ -151,12 +151,12 @@ end
|
||||
|
||||
---Set buf & win options, and setup highlight
|
||||
function Preview:setup()
|
||||
vim.api.nvim_win_set_option(self.win, 'winhl', self.conf.winhl)
|
||||
vim.api.nvim_win_set_option(self.win, 'winblend', self.conf.winblend)
|
||||
vim.api.nvim_set_option_value('winhl', self.conf.winhl, { win = self.win })
|
||||
vim.api.nvim_set_option_value('winblend', self.conf.winblend, { win = self.win })
|
||||
|
||||
local code_buf = self.s.code.buf
|
||||
local ft = vim.api.nvim_buf_get_option(code_buf, 'filetype')
|
||||
vim.api.nvim_buf_set_option(self.buf, 'syntax', ft)
|
||||
local ft = vim.api.nvim_get_option_value('filetype', { buf = code_buf })
|
||||
vim.api.nvim_set_option_value('syntax', ft, { buf = self.buf })
|
||||
|
||||
local ts_highlight_fn = vim.treesitter.start
|
||||
if not _G._outline_nvim_has[8] then
|
||||
@@ -167,9 +167,9 @@ function Preview:setup()
|
||||
end
|
||||
pcall(ts_highlight_fn, self.buf, ft)
|
||||
|
||||
vim.api.nvim_buf_set_option(self.buf, 'bufhidden', 'delete')
|
||||
vim.api.nvim_buf_set_option(self.buf, 'modifiable', false)
|
||||
vim.api.nvim_win_set_option(self.win, 'cursorline', true)
|
||||
vim.api.nvim_set_option_value('bufhidden', 'delete', { buf = self.buf })
|
||||
vim.api.nvim_set_option_value('modifiable', false, { buf = self.buf })
|
||||
vim.api.nvim_set_option_value('cursorline', true, { win = self.win })
|
||||
end
|
||||
|
||||
function Preview:update()
|
||||
@@ -180,9 +180,9 @@ function Preview:update()
|
||||
local lines = vim.api.nvim_buf_get_lines(self.s.code.buf, 0, -1, false)
|
||||
|
||||
if self.buf ~= nil then
|
||||
vim.api.nvim_buf_set_option(self.buf, 'modifiable', true)
|
||||
vim.api.nvim_set_option_value('modifiable', true, { buf = self.buf })
|
||||
vim.api.nvim_buf_set_lines(self.buf, 0, -1, false, lines)
|
||||
vim.api.nvim_buf_set_option(self.buf, 'modifiable', false)
|
||||
vim.api.nvim_set_option_value('modifiable', false, { buf = self.buf })
|
||||
vim.api.nvim_win_set_cursor(self.win, { node.line + 1, node.character })
|
||||
end
|
||||
end
|
||||
@@ -221,7 +221,7 @@ end
|
||||
---Creates new preview window and sets the content. Calls setup and set_lines.
|
||||
function LivePreview:create()
|
||||
self.codewin = self.s.code.win
|
||||
self.initial_cursorline = vim.api.nvim_win_get_option(self.s.code.win, 'cursorline')
|
||||
self.initial_cursorline = vim.api.nvim_get_option_value('cursorline', { win = self.s.code.win })
|
||||
self.outline_height = vim.api.nvim_win_get_height(self.s.view.win)
|
||||
self.width = cfg.get_preview_width(self.conf)
|
||||
self.height = cfg.get_preview_height(self.conf, self.outline_height)
|
||||
@@ -256,9 +256,9 @@ end
|
||||
|
||||
---Set buf & win options, and autocmds
|
||||
function LivePreview:setup()
|
||||
vim.api.nvim_win_set_option(self.win, 'winhl', self.conf.winhl)
|
||||
vim.api.nvim_win_set_option(self.win, 'winblend', self.conf.winblend)
|
||||
vim.api.nvim_win_set_option(self.win, 'cursorline', true)
|
||||
vim.api.nvim_set_option_value('winhl', self.conf.winhl, { win = self.win })
|
||||
vim.api.nvim_set_option_value('winblend', self.conf.winblend, { win = self.win })
|
||||
vim.api.nvim_set_option_value('cursorline', true, { win = self.win })
|
||||
|
||||
vim.api.nvim_create_autocmd('WinClosed', {
|
||||
pattern = tostring(self.win),
|
||||
@@ -273,7 +273,7 @@ function LivePreview:setup()
|
||||
once = true,
|
||||
callback = function()
|
||||
-- This doesn't work at all?
|
||||
vim.api.nvim_win_set_option(self.win, 'cursorline', self.initial_cursorline)
|
||||
vim.api.nvim_set_option_value('cursorline', self.initial_cursorline, { win = self.win })
|
||||
end,
|
||||
})
|
||||
end
|
||||
@@ -286,7 +286,7 @@ end
|
||||
function LivePreview:focus()
|
||||
vim.api.nvim_set_current_win(self.win)
|
||||
-- Remove this when the autocmd for WinEnter works above
|
||||
vim.api.nvim_win_set_option(self.win, 'cursorline', self.initial_cursorline)
|
||||
vim.api.nvim_set_option_value('cursorline', self.initial_cursorline, { win = self.win })
|
||||
end
|
||||
|
||||
---Create, focus, or update preview
|
||||
|
||||
@@ -38,6 +38,7 @@ local function get_appropriate_client(bufnr, capability)
|
||||
if _G._outline_nvim_has[10] then
|
||||
clients = l.get_clients({ bufnr = bufnr })
|
||||
else
|
||||
---@diagnostic disable-next-line: deprecated
|
||||
clients = l.get_active_clients({ bufnr = bufnr })
|
||||
end
|
||||
for _, client in ipairs(clients) do
|
||||
@@ -97,7 +98,7 @@ function M.request_symbols(on_symbols, opts, info)
|
||||
textDocument = l.util.make_text_document_params(),
|
||||
}
|
||||
-- XXX: Is bufnr=0 ok here?
|
||||
local status = info.client.request('textDocument/documentSymbol', params, function(err, response)
|
||||
local status = info.client:request('textDocument/documentSymbol', params, function(err, response)
|
||||
if err or not response then
|
||||
on_symbols(response, opts)
|
||||
else
|
||||
@@ -151,7 +152,7 @@ local function legacy_rename(sidebar, client, node)
|
||||
newName = new_name,
|
||||
}
|
||||
local status, err =
|
||||
client.request_sync('textDocument/rename', params, request_timeout, sidebar.code.buf)
|
||||
client:request_sync('textDocument/rename', params, request_timeout, sidebar.code.buf)
|
||||
if status == nil or status.err or err or status.result == nil then
|
||||
return false
|
||||
end
|
||||
@@ -210,7 +211,7 @@ function M.show_hover(sidebar)
|
||||
bufnr = sidebar.code.buf,
|
||||
}
|
||||
|
||||
local status, err = client.request_sync('textDocument/hover', params, request_timeout)
|
||||
local status, err = client:request_sync('textDocument/hover', params, request_timeout)
|
||||
if status == nil or status.err or err or not status.result or not status.result.contents then
|
||||
return false
|
||||
end
|
||||
@@ -226,7 +227,7 @@ function M.show_hover(sidebar)
|
||||
border = cfg.o.preview_window.border,
|
||||
width = code_width,
|
||||
})
|
||||
vim.api.nvim_win_set_option(winnr, 'winhighlight', cfg.o.preview_window.winhl)
|
||||
vim.api.nvim_set_option_value('winhighlight', cfg.o.preview_window.winhl, { win = winnr })
|
||||
return true
|
||||
end
|
||||
|
||||
|
||||
@@ -249,7 +249,7 @@ function Sidebar:update_cursor_style()
|
||||
local hide_cursor = type(cl) ~= 'string'
|
||||
|
||||
if cl == 'focus_in_outline' or cl == 'focus_in_code' then
|
||||
vim.api.nvim_win_set_option(0, 'cursorline', cl == 'focus_in_outline')
|
||||
vim.api.nvim_set_option_value('cursorline', cl == 'focus_in_outline', { win = 0 })
|
||||
hide_cursor = cl == 'focus_in_outline'
|
||||
end
|
||||
|
||||
@@ -265,7 +265,7 @@ function Sidebar:reset_cursor_style()
|
||||
local cl = cfg.o.outline_window.show_cursorline
|
||||
|
||||
if cl == 'focus_in_outline' or cl == 'focus_in_code' then
|
||||
vim.api.nvim_win_set_option(0, 'cursorline', cl ~= 'focus_in_outline')
|
||||
vim.api.nvim_set_option_value('cursorline', cl ~= 'focus_in_outline', { win = 0 })
|
||||
end
|
||||
-- vim.opt doesn't seem to provide a way to remove last item, like a pop()
|
||||
-- vim.o.guicursor = vim.o.guicursor:gsub(",n.-:.-$", "")
|
||||
@@ -344,8 +344,8 @@ function Sidebar:__refresh()
|
||||
if focused_outline or not self.view:is_open() then
|
||||
return
|
||||
end
|
||||
local ft = vim.api.nvim_buf_get_option(buf, 'ft')
|
||||
local listed = vim.api.nvim_buf_get_option(buf, 'buflisted')
|
||||
local ft = vim.api.nvim_get_option_value("ft", { buf = buf })
|
||||
local listed = vim.api.nvim_get_option_value("ft", { buf = buf })
|
||||
if ft == 'OutlineHelp' or not (listed or ft == 'help') then
|
||||
return
|
||||
end
|
||||
|
||||
@@ -7,13 +7,14 @@ function M.is_buf_attached_to_lsp(bufnr)
|
||||
if _G._outline_nvim_has[10] then
|
||||
clients = vim.lsp.get_clients({ bufnr = bufnr or 0 })
|
||||
else
|
||||
---@diagnostic disable-next-line: deprecated
|
||||
clients = vim.lsp.get_active_clients({ bufnr = bufnr or 0 })
|
||||
end
|
||||
return clients ~= nil and #clients > 0
|
||||
end
|
||||
|
||||
function M.is_buf_markdown(bufnr)
|
||||
return vim.api.nvim_buf_get_option(bufnr, 'ft') == 'markdown'
|
||||
return vim.api.nvim_get_option_value('ft', { buf = bufnr }) == 'markdown'
|
||||
end
|
||||
|
||||
--- Merge all client token lists in an LSP response
|
||||
|
||||
@@ -19,10 +19,10 @@ function View:setup_view(split_command)
|
||||
self.buf = vim.api.nvim_create_buf(false, true)
|
||||
|
||||
-- set filetype
|
||||
vim.api.nvim_buf_set_option(self.buf, 'filetype', 'Outline')
|
||||
vim.api.nvim_set_option_value('filetype', 'Outline', { buf = self.buf })
|
||||
|
||||
-- delete buffer when window is closed / buffer is hidden
|
||||
vim.api.nvim_buf_set_option(self.buf, 'bufhidden', 'delete')
|
||||
vim.api.nvim_set_option_value('bufhidden', 'delete', { buf = self.buf })
|
||||
|
||||
-- create a split
|
||||
vim.cmd(split_command)
|
||||
@@ -38,38 +38,38 @@ function View:setup_view(split_command)
|
||||
end
|
||||
|
||||
-- window stuff
|
||||
vim.api.nvim_win_set_option(self.win, 'spell', false)
|
||||
vim.api.nvim_win_set_option(self.win, 'signcolumn', 'no')
|
||||
vim.api.nvim_win_set_option(self.win, 'foldcolumn', '0')
|
||||
vim.api.nvim_win_set_option(self.win, 'number', false)
|
||||
vim.api.nvim_win_set_option(self.win, 'relativenumber', false)
|
||||
vim.api.nvim_win_set_option(self.win, 'winfixwidth', true)
|
||||
vim.api.nvim_win_set_option(self.win, 'list', false)
|
||||
vim.api.nvim_win_set_option(self.win, 'wrap', cfg.o.outline_window.wrap)
|
||||
vim.api.nvim_win_set_option(self.win, 'winhl', cfg.o.outline_window.winhl)
|
||||
vim.api.nvim_win_set_option(self.win, 'linebreak', true) -- only has effect when wrap=true
|
||||
vim.api.nvim_win_set_option(self.win, 'breakindent', true) -- only has effect when wrap=true
|
||||
vim.api.nvim_set_option_value('spell', false, { win = self.win })
|
||||
vim.api.nvim_set_option_value('signcolumn', 'no', { win = self.win })
|
||||
vim.api.nvim_set_option_value('foldcolumn', '0', { win = self.win })
|
||||
vim.api.nvim_set_option_value('number', false, { win = self.win })
|
||||
vim.api.nvim_set_option_value('relativenumber', false, { win = self.win })
|
||||
vim.api.nvim_set_option_value('winfixwidth', true, { win = self.win })
|
||||
vim.api.nvim_set_option_value('list', false, { win = self.win })
|
||||
vim.api.nvim_set_option_value('wrap', cfg.o.outline_window.wrap, { win = self.win })
|
||||
vim.api.nvim_set_option_value('winhl', cfg.o.outline_window.winhl, { win = self.win })
|
||||
vim.api.nvim_set_option_value('linebreak', true, { win = self.win }) -- only has effect when wrap=true
|
||||
vim.api.nvim_set_option_value('breakindent', true, { win = self.win }) -- only has effect when wrap=true
|
||||
-- Would be nice to use guides.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.win, 'showbreak', ' ') -- only has effect when wrap=true.
|
||||
vim.api.nvim_set_option_value('showbreak', ' ', { win = self.win }) -- only has effect when wrap=true.
|
||||
-- buffer stuff
|
||||
local tab = vim.api.nvim_get_current_tabpage()
|
||||
vim.api.nvim_buf_set_name(self.buf, 'OUTLINE_' .. tostring(tab))
|
||||
vim.api.nvim_buf_set_option(self.buf, 'modifiable', false)
|
||||
vim.api.nvim_set_option_value('modifiable', false, { buf = self.buf })
|
||||
|
||||
if cfg.o.outline_window.show_numbers or cfg.o.outline_window.show_relative_numbers then
|
||||
vim.api.nvim_win_set_option(self.win, 'nu', true)
|
||||
vim.api.nvim_set_option_value('nu', true, { win = self.win })
|
||||
end
|
||||
|
||||
if cfg.o.outline_window.show_relative_numbers then
|
||||
vim.api.nvim_win_set_option(self.win, 'rnu', true)
|
||||
vim.api.nvim_set_option_value('rnu', true, { win = self.win })
|
||||
end
|
||||
|
||||
local cl = cfg.o.outline_window.show_cursorline
|
||||
if cl == true or cl == 'focus_in_outline' then
|
||||
vim.api.nvim_win_set_option(self.win, 'cursorline', true)
|
||||
vim.api.nvim_set_option_value('cursorline', true, { win = self.win })
|
||||
end
|
||||
end
|
||||
|
||||
@@ -100,9 +100,9 @@ end
|
||||
---@param lines string[]
|
||||
function View:rewrite_lines(lines)
|
||||
if self.buf and vim.api.nvim_buf_is_valid(self.buf) then
|
||||
vim.api.nvim_buf_set_option(self.buf, 'modifiable', true)
|
||||
vim.api.nvim_set_option_value('modifiable', true, { buf = self.buf })
|
||||
vim.api.nvim_buf_set_lines(self.buf, 0, -1, false, lines)
|
||||
vim.api.nvim_buf_set_option(self.buf, 'modifiable', false)
|
||||
vim.api.nvim_set_option_value('modifiable', false, { buf = self.buf })
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user