fix: adjust more to make it backward compatible for 0.11-
This commit is contained in:
@@ -208,7 +208,7 @@ end
|
||||
---@param bufnr integer
|
||||
---@return boolean include
|
||||
function M.should_include_symbol(kind, bufnr)
|
||||
local ft = vim.api.nvim_buf_get_option(bufnr, 'ft')
|
||||
local ft = vim.api.nvim_get_option_value('ft', { buf = bufnr })
|
||||
-- There can only be one kind in markdown and norg as of now
|
||||
if ft == 'markdown' or ft == 'norg' or kind == nil then
|
||||
return true
|
||||
@@ -232,7 +232,7 @@ function M.should_include_symbol(kind, bufnr)
|
||||
return filter_table[kind] ~= false
|
||||
end
|
||||
|
||||
---@param client lsp.client|number
|
||||
---@param client vim.lsp.Client|number
|
||||
function M.is_client_blacklisted(client)
|
||||
if not client then
|
||||
return false
|
||||
|
||||
@@ -68,7 +68,19 @@ function Float:open(lines, hl, title, indent)
|
||||
if hl then
|
||||
self.ns = vim.api.nvim_create_namespace('OutlineHelp')
|
||||
for _, h in ipairs(hl) do
|
||||
if _G._outline_nvim_has[11] then
|
||||
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 })
|
||||
else
|
||||
---@diagnostic disable-next-line:deprecated
|
||||
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
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -29,7 +29,14 @@ function M.hovers(bufnr, nodes)
|
||||
for line, node in ipairs(nodes) do
|
||||
if node.hovered then
|
||||
-- stylua: ignore start
|
||||
if _G._outline_nvim_has[11] then
|
||||
vim.hl.range(bufnr, M.ns.hover, 'OutlineCurrent', { line - 1, node.prefix_length }, { line - 1, -1 })
|
||||
else
|
||||
---@diagnostic disable-next-line:deprecated
|
||||
vim.api.nvim_buf_add_highlight(
|
||||
bufnr, M.ns.hover, 'OutlineCurrent', line - 1, node.prefix_length, -1
|
||||
)
|
||||
end
|
||||
-- stylua: ignore end
|
||||
end
|
||||
end
|
||||
@@ -41,7 +48,14 @@ end
|
||||
function M.items(bufnr, hl_list)
|
||||
for _, h in ipairs(hl_list) do
|
||||
-- stylua: ignore start
|
||||
if _G._outline_nvim_has[11] then
|
||||
vim.hl.range(bufnr, M.ns.items, h.name, { h.line - 1, h.from }, { h.line - 1, h.to })
|
||||
else
|
||||
---@diagnostic disable-next-line:deprecated
|
||||
vim.api.nvim_buf_add_highlight(
|
||||
bufnr, M.ns.items, h.name, h.line - 1, h.from, h.to
|
||||
)
|
||||
end
|
||||
-- stylua: ignore end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -351,6 +351,7 @@ function M.setup(opts)
|
||||
[8] = minor >= 8,
|
||||
[9] = minor >= 9,
|
||||
[10] = minor >= 10,
|
||||
[11] = minor >= 11,
|
||||
}
|
||||
|
||||
cfg.setup(opts)
|
||||
|
||||
@@ -18,7 +18,7 @@ function M.get_status(info)
|
||||
return { 'client: ' .. info.client.name }
|
||||
end
|
||||
|
||||
---@param client lsp.client
|
||||
---@param client vim.lsp.Client
|
||||
---@param capability string
|
||||
---@return boolean
|
||||
local function _check_client(client, capability)
|
||||
@@ -30,7 +30,7 @@ end
|
||||
|
||||
---@param bufnr integer
|
||||
---@param capability string
|
||||
---@return lsp.client?
|
||||
---@return vim.lsp.Client?
|
||||
local function get_appropriate_client(bufnr, capability)
|
||||
local clients, use_client
|
||||
|
||||
@@ -98,14 +98,22 @@ 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 method = 'textDocument/documentSymbol'
|
||||
local callback = function(err, response)
|
||||
if err or not response then
|
||||
on_symbols(response, opts)
|
||||
else
|
||||
response = postprocess_symbols(response)
|
||||
on_symbols(response, opts)
|
||||
end
|
||||
end, 0)
|
||||
end
|
||||
local bufnr = 0
|
||||
local status
|
||||
if _G._outline_nvim_has[11] then
|
||||
status = info.client:request(method, params, callback, bufnr)
|
||||
else
|
||||
status = info.client.request(method, params, callback, bufnr)
|
||||
end
|
||||
if not status then
|
||||
on_symbols(nil, opts)
|
||||
end
|
||||
@@ -135,7 +143,7 @@ end
|
||||
|
||||
---@see rename_symbol
|
||||
---@param sidebar outline.Sidebar
|
||||
---@param client lsp.client
|
||||
---@param client vim.lsp.Client
|
||||
---@param node outline.FlatSymbol
|
||||
---@return boolean success
|
||||
local function legacy_rename(sidebar, client, node)
|
||||
@@ -151,8 +159,13 @@ local function legacy_rename(sidebar, client, node)
|
||||
bufnr = sidebar.code.buf,
|
||||
newName = new_name,
|
||||
}
|
||||
local status, err =
|
||||
client:request_sync('textDocument/rename', params, request_timeout, sidebar.code.buf)
|
||||
local status, err
|
||||
if _G._outline_nvim_has[11] then
|
||||
status, err = client:request_sync('textDocument/rename', params, request_timeout, sidebar.code.buf)
|
||||
else
|
||||
---@diagnostic disable-next-line
|
||||
status, err = client.request_sync('textDocument/rename', params, request_timeout, sidebar.code.buf)
|
||||
end
|
||||
if status == nil or status.err or err or status.result == nil then
|
||||
return false
|
||||
end
|
||||
@@ -211,7 +224,12 @@ function M.show_hover(sidebar)
|
||||
bufnr = sidebar.code.buf,
|
||||
}
|
||||
|
||||
local status, err = client:request_sync('textDocument/hover', params, request_timeout)
|
||||
local status, err
|
||||
if _G._outline_nvim_has[11] then
|
||||
status, err = client:request_sync('textDocument/hover', params, request_timeout)
|
||||
else
|
||||
status, err = client.request_sync('textDocument/hover', params, request_timeout)
|
||||
end
|
||||
if status == nil or status.err or err or not status.result or not status.result.contents then
|
||||
return false
|
||||
end
|
||||
|
||||
@@ -38,7 +38,14 @@ function M.flash_highlight(winnr, lnum, durationMs, hl_group)
|
||||
durationMs = 400
|
||||
end
|
||||
local bufnr = vim.api.nvim_win_get_buf(winnr)
|
||||
local ns = vim.api.nvim_buf_add_highlight(bufnr, 0, hl_group, lnum - 1, 0, -1)
|
||||
local ns
|
||||
if _G._outline_nvim_has[11] then
|
||||
ns = vim.api.nvim_create_namespace("_outline_nvim_flash")
|
||||
vim.hl.range(bufnr, ns, hl_group, { lnum-1, 0 }, { lnum-1, -1 })
|
||||
else
|
||||
---@diagnostic disable-next-line:deprecated
|
||||
ns = vim.api.nvim_buf_add_highlight(bufnr, 0, hl_group, lnum - 1, 0, -1)
|
||||
end
|
||||
local remove_highlight = function()
|
||||
pcall(vim.api.nvim_buf_clear_namespace, bufnr, ns, 0, -1)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user