update resolved_capacities -> server_capacities (#185)

* update resolved_capacities

* format renaming

* remove comments

* remove mk_handler. update documentFormator

* bumpup test image to ubuntu 22.04

* add logs when neovim is lower than 0.8
pull/188/head
rayx 2 years ago committed by GitHub
parent 5131b30ad7
commit a73fb38ef9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -10,15 +10,15 @@ jobs:
fail-fast: false
matrix:
include:
- os: ubuntu-20.04
- os: ubuntu-22.04
url: https://github.com/neovim/neovim/releases/download/nightly/nvim-linux64.tar.gz
manager: sudo snap
packages: go
- os: ubuntu-20.04
- os: ubuntu-22.04
url: https://github.com/neovim/neovim/releases/download/v0.7.0/nvim-linux64.tar.gz
manager: sudo snap
packages: go
- os: ubuntu-20.04
- os: ubuntu-22.04
url: https://github.com/neovim/neovim/releases/download/v0.6.1/nvim-linux64.tar.gz
manager: sudo snap
packages: go
@ -26,7 +26,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: "^1.17.2" # The Go version to download (if necessary) and use.
go-version: "^1.18.1" # The Go version to download (if necessary) and use.
- run: date +%F > todays-date
- name: Restore cache for today's nightly.
uses: actions/cache@v2

@ -4,8 +4,6 @@
local codelens = require('vim.lsp.codelens')
local log = require('navigator.util').log
local mk_handler = require('navigator.util').mk_handler
local nvim_0_6_1 = require('navigator.util').nvim_0_6_1
local trace = require('navigator.util').trace
local lsphelper = require('navigator.lspwrapper')
@ -49,7 +47,7 @@ local function _update_sign(line)
end
end
local codelens_hdlr = mk_handler(function(err, result, ctx, cfg)
local codelens_hdlr = function(err, result, ctx, cfg)
trace(ctx, result)
M.codelens_ctx = ctx
if err or result == nil then
@ -62,7 +60,7 @@ local codelens_hdlr = mk_handler(function(err, result, ctx, cfg)
for _, v in pairs(result) do
_update_sign(v.range.start.line)
end
end)
end
function M.setup()
vim.cmd('highlight! link LspCodeLens LspDiagnosticsHint')
@ -75,18 +73,13 @@ function M.setup()
vim.cmd("autocmd BufEnter,CursorHold,InsertLeave <buffer> lua require('navigator.codelens').refresh()")
vim.cmd('augroup end')
local on_codelens = vim.lsp.handlers['textDocument/codeLens']
vim.lsp.handlers['textDocument/codeLens'] = mk_handler(function(err, result, ctx, cfg)
vim.lsp.handlers['textDocument/codeLens'] = function(err, result, ctx, cfg)
-- trace(err, result, ctx.client_id, ctx.bufnr, cfg or {})
cfg = cfg or {}
ctx = ctx or { bufnr = vim.api.nvim_get_current_buf() }
if nvim_0_6_1() then
on_codelens(err, result, ctx, cfg)
codelens_hdlr(err, result, ctx, cfg)
else
on_codelens(err, ctx.method, result, ctx.client_id, ctx.bufnr)
codelens_hdlr(err, nil, result, ctx.client_id or 0, ctx.bufnr or 0)
end
end)
on_codelens(err, result, ctx, cfg)
codelens_hdlr(err, result, ctx, cfg)
end
end
M.lsp_clients = {}
@ -96,7 +89,7 @@ function M.refresh()
log('Must have a client running to use lsp code action')
return
end
if not lsphelper.check_capabilities('code_lens') then
if not lsphelper.check_capabilities('codeLensProvider') then
return
end
vim.lsp.codelens.refresh()

@ -5,7 +5,7 @@ local gui = require('navigator.gui')
local log = util.log
local TextView = require('guihua.textview')
-- callback for lsp definition, implementation and declaration handler
local definition_hdlr = util.mk_handler(function(err, locations, ctx, _)
local definition_hdlr = function(err, locations, ctx, _)
-- log(locations)
if err ~= nil then
vim.notify('Defination: ' .. tostring(err) .. vim.inspect(ctx), vim.lsp.log_levels.WARN)
@ -31,7 +31,7 @@ local definition_hdlr = util.mk_handler(function(err, locations, ctx, _)
else
vim.lsp.util.jump_to_location(locations, oe)
end
end)
end
local function get_symbol()
local currentWord = vim.fn.expand('<cword>')
@ -144,7 +144,8 @@ local def = function()
local ref_params = vim.lsp.util.make_position_params()
vim.lsp.for_each_buffer_client(bufnr, function(client, client_id, _bufnr)
if client.resolved_capabilities.goto_definition then
-- if client.resolved_capabilities.goto_definition then
if client.server_capabilities.definitionProvider then
client.request('textDocument/definition', ref_params, definition_hdlr, _bufnr)
end
end)

@ -9,7 +9,6 @@ local trace = require('guihua.log').trace
-- trace = log
local error = util.error
local path_sep = require('navigator.util').path_sep()
local mk_handler = require('navigator.util').mk_handler
local path_cur = require('navigator.util').path_cur()
local empty = util.empty
@ -194,7 +193,7 @@ local update_err_marker_async = function()
return debounce(400, error_marker)
end
local diag_hdlr = mk_handler(function(err, result, ctx, config)
local diag_hdlr = function(err, result, ctx, config)
require('navigator.lspclient.highlight').diagnositc_config_sign()
config = config or diagnostic_cfg
if err ~= nil then
@ -305,7 +304,7 @@ local diag_hdlr = mk_handler(function(err, result, ctx, config)
vim.api.nvim_buf_clear_namespace(0, _NG_VT_DIAG_NS, 0, -1)
_NG_VT_DIAG_NS = nil
end
end)
end
local diag_hdlr_async = function()
local debounce = require('navigator.debounce').debounce_trailing

@ -1,7 +1,6 @@
local util = require('navigator.util')
local log = util.log
local trace = util.trace
local mk_handler = util.mk_handler
local api = vim.api
local references = {}
_NG_hi_list = {}
@ -139,7 +138,7 @@ local function before(r1, r2)
return false
end
local handle_document_highlight = mk_handler(function(_, result, ctx)
local handle_document_highlight = function(_, result, ctx)
trace(result, ctx)
if not ctx.bufnr then
log('ducment highlight error', result, ctx)
@ -157,7 +156,7 @@ local handle_document_highlight = mk_handler(function(_, result, ctx)
references[ctx.bufnr] = result
local client_id = ctx.client_id
vim.lsp.util.buf_highlight_references(ctx.bufnr, result, util.encoding(client_id))
end)
end
-- modify from vim-illuminate
local function goto_adjent_reference(opt)
trace(opt)
@ -210,7 +209,7 @@ _G.nav_doc_hl = function()
local bufnr = vim.api.nvim_get_current_buf()
local ref_params = vim.lsp.util.make_position_params()
vim.lsp.for_each_buffer_client(bufnr, function(client, client_id, bufnr)
if client.resolved_capabilities.document_highlight then
if client.server_capabilities.documentHighlightProvider then
client.request('textDocument/documentHighlight', ref_params, handle_document_highlight, bufnr)
end
end)
@ -227,7 +226,7 @@ local function documentHighlight()
]],
false
)
vim.lsp.handlers['textDocument/documentHighlight'] = mk_handler(function(err, result, ctx)
vim.lsp.handlers['textDocument/documentHighlight'] = function(err, result, ctx)
local bufnr = ctx.bufnr or api.nvim_get_current_buf()
if err then
vim.notify(err, vim.lsp.log_levels.ERROR)
@ -250,7 +249,7 @@ local function documentHighlight()
end)
references[bufnr] = result
add_locs(bufnr, result)
end)
end
end
return {

@ -1,5 +1,4 @@
local log = require('navigator.util').log
local mk_handler = require('navigator.util').mk_handler
local lsp = vim.lsp
local api = vim.api
@ -88,7 +87,7 @@ function M.debug_folds()
end
end
M.fold_handler = mk_handler(function(err, result, ctx, config)
M.fold_handler = function(err, result, ctx, config)
-- params: err, method, result, client_id, bufnr
-- XXX: handle err?
if err or result == nil or #result == 0 then
@ -112,7 +111,7 @@ M.fold_handler = mk_handler(function(err, result, ctx, config)
api.nvim_win_set_option(current_window, 'foldmethod', 'expr')
api.nvim_win_set_option(current_window, 'foldexpr', 'foldlsp#foldexpr()')
end
end)
end
function M.adjust_foldstart(line_no)
return line_no + 1

@ -1,8 +1,7 @@
-- https://github.com/wention/dotfiles/blob/master/.config/nvim/lua/config/lsp.lua
-- https://github.com/lukas-reineke/dotfiles/blob/master/vim/lua/lsp/handlers.lua
local mk_handler = require('navigator.util').mk_handler
return {
format_hdl = mk_handler(function(err, result, ctx, cfg) -- FIXME: bufnr is nil
format_hdl = function(err, result, ctx, cfg) -- FIXME: bufnr is nil
if err ~= nil or result == nil then
return
end
@ -31,5 +30,5 @@ return {
-- end
end
end, 100)
end),
end,
}

@ -79,7 +79,7 @@ end
function M.incoming_calls(bang, opts)
local bufnr = vim.api.nvim_get_current_buf()
assert(next(vim.lsp.buf_get_clients(bufnr)), 'Must have a client running to use lsp hierarchy')
if not lsphelper.check_capabilities('call_hierarchy') then
if not lsphelper.check_capabilities('callHierarchyProvider') then
return
end
@ -90,7 +90,7 @@ end
function M.outgoing_calls(bang, opts)
local bufnr = vim.api.nvim_get_current_buf()
assert(next(vim.lsp.buf_get_clients(bufnr)), 'Must have a client running to use lsp_tags')
if not lsphelper.check_capabilities('call_hierarchy') then
if not lsphelper.check_capabilities('callHierarchyProvider') then
return
end

@ -1,5 +1,4 @@
local util = require('navigator.util')
local mk_handler = util.mk_handler
local lsphelper = require('navigator.lspwrapper')
local gui = require('navigator.gui')
local M = {}
@ -23,7 +22,7 @@ local function implementation_handler(bang, err, result, ctx, cfg)
end
function M.implementation(bang, opts)
if not lsphelper.check_capabilities('implementation') then
if not lsphelper.check_capabilities('implementationProvider') then
return
end

@ -34,7 +34,7 @@ M.on_attach = function(client, bufnr)
bufnr = bufnr,
})
if client.resolved_capabilities.document_highlight then
if client.server_capabilities.documentHighlightProvider then
require('navigator.dochighlight').documentHighlight()
end
@ -60,8 +60,8 @@ M.on_attach = function(client, bufnr)
end
if _NgConfigValues.lsp.code_action.enable then
if client.resolved_capabilities.code_action then
log('code action enabled for client', client.resolved_capabilities.code_action)
if client.server_capabilities.codeActionProvider then
log('code action enabled for client', client.server_capabilities.codeActionProvider)
vim.cmd([[autocmd CursorHold,CursorHoldI <buffer> lua require'navigator.codeAction'.code_action_prompt()]])
end
end

@ -185,7 +185,8 @@ local setups = {
},
filetypes = { 'c', 'cpp', 'objc', 'objcpp' },
on_attach = function(client, bufnr)
client.resolved_capabilities.document_formatting = true
client.server_capabilities.documentFormattingProvider = client.server_capabilities.documentFormattingProvider
or true
on_attach(client, bufnr)
end,
},
@ -208,7 +209,7 @@ local setups = {
sqls = {
filetypes = { 'sql' },
on_attach = function(client, bufnr)
client.resolved_capabilities.execute_command = true
client.server_capabilities.executeCommandProvider = client.server_capabilities.documentFormattingProvider or true
highlight.diagnositc_config_sign()
require('sqls').setup({ picker = 'telescope' }) -- or default
end,
@ -379,12 +380,6 @@ local configs = {}
-- check and load based on file type
local function load_cfg(ft, client, cfg, loaded)
-- if _NG_LSPCfgSetup ~= true then
-- log(lspconfig_setup)
-- lspconfig_setup(cfg)
-- _NG_LSPCfgSetup = true
-- end
log(ft, client, loaded)
trace(cfg)
if lspconfig[client] == nil then
@ -437,8 +432,25 @@ local function load_cfg(ft, client, cfg, loaded)
-- need to verify the lsp server is up
end
local function setup_fmt(client, enabled)
if not require('navigator.util').nvim_0_8() then
if enabled == false then
client.resolved_capabilities.document_formatting = enabled
else
client.resolved_capabilities.document_formatting = client.resolved_capabilities.document_formatting or enabled
end
end
if enabled == false then
client.server_capabilities.documentFormattingProvider = false
else
client.server_capabilities.documentFormattingProvider = client.server_capabilities.documentFormattingProvider
or enabled
end
end
local function update_capabilities()
trace(ft, 'lsp startup')
trace(vim.o.ft, 'lsp startup')
local loaded = {}
local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities.textDocument.completion.completionItem.snippetSupport = true
@ -526,6 +538,7 @@ local function lsp_startup(ft, retry, user_lsp_opts)
-- filetype disabled
if not vim.tbl_contains(cfg.filetypes or {}, ft) then
trace('ft', ft, 'disabled for', lspclient)
goto continue
end
@ -544,10 +557,7 @@ local function lsp_startup(ft, retry, user_lsp_opts)
-- log(lsp_opts[lspclient], cfg)
cfg = vim.tbl_deep_extend('force', cfg, user_lsp_opts[lspclient])
if config.combined_attach == nil then
cfg.on_attach = function(client, bufnr)
on_attach(client, bufnr)
client.resolved_capabilities.document_formatting = enable_fmt
end
setup_fmt(client, enable_fmt)
end
if config.combined_attach == 'mine' then
if config.on_attach == nil then
@ -555,7 +565,8 @@ local function lsp_startup(ft, retry, user_lsp_opts)
end
cfg.on_attach = function(client, bufnr)
config.on_attach(client, bufnr)
client.resolved_capabilities.document_formatting = enable_fmt
setup_fmt(client, enable_fmt)
require('navigator.lspclient.mapping').setup({
client = client,
bufnr = bufnr,
@ -567,7 +578,7 @@ local function lsp_startup(ft, retry, user_lsp_opts)
cfg.on_attach = function(client, bufnr)
on_attach(client, bufnr)
config.on_attach(client, bufnr)
client.resolved_capabilities.document_formatting = enable_fmt
setup_fmt(client, enable_fmt)
require('navigator.lspclient.mapping').setup({
client = client,
bufnr = bufnr,
@ -577,7 +588,8 @@ local function lsp_startup(ft, retry, user_lsp_opts)
end
if config.combined_attach == 'both' then
cfg.on_attach = function(client, bufnr)
client.resolved_capabilities.document_formatting = enable_fmt
setup_fmt(client, enable_fmt)
if config.on_attach and type(config.on_attach) == 'function' then
config.on_attach(client, bufnr)
end
@ -605,7 +617,8 @@ local function lsp_startup(ft, retry, user_lsp_opts)
else
cfg.on_attach = function(client, bufnr)
on_attach(client, bufnr)
client.resolved_capabilities.document_formatting = enable_fmt
setup_fmt(client, enable_fmt)
end
end

@ -9,6 +9,10 @@ local event_hdlrs = {
{ ev = 'CursorMoved', func = 'clear_references()' },
}
if vim.lsp.buf.format == nil then
vim.lsp.buf.format = vim.lsp.buf.formatting
end
if vim.diagnostic == nil then
util.error('Please update nvim to 0.6.1+')
end
@ -51,7 +55,7 @@ local key_maps = {
{ key = '<Leader>k', func = "require('navigator.dochighlight').hi_symbol()" },
{ key = '<Space>wa', func = "require('navigator.workspace').add_workspace_folder()" },
{ key = '<Space>wr', func = "require('navigator.workspace').remove_workspace_folder()" },
{ key = '<Space>ff', func = 'formatting()', mode = 'n' },
{ key = '<Space>ff', func = 'format({async = true})', mode = 'n' },
{ key = '<Space>ff', func = 'range_formatting()', mode = 'v' },
{ key = '<Space>wl', func = "require('navigator.workspace').list_workspace_folders()" },
{ key = '<Space>la', mode = 'n', func = "require('navigator.codelens').run_action()" },
@ -71,23 +75,23 @@ local check_cap = function(opts)
local fmt, rfmt, ccls
local cap = opts.cap
if cap == nil then
if opts.client and opts.client.resolved_capabilities then
cap = opts.client.resolved_capabilities
if opts.client and opts.client.server_capabilities then
cap = opts.client.server_capabilities
end
end
if cap and cap.document_formatting then
if cap and cap.documentFormattingProvider then
fmt = true
end
if cap and cap.document_range_formatting then
if cap and cap.documentRangeFormattingProvider then
rfmt = true
end
for _, value in pairs(vim.lsp.buf_get_clients(0)) do
trace(value)
if value ~= nil and value.resolved_capabilities == nil then
if value.resolved_capabilities.document_formatting then
if value ~= nil and value.server_capabilities == nil then
if value.server_capabilities.documentFormattingProvider then
fmt = true
end
if value.resolved_capabilities.document_range_formatting then
if value.server_capabilities.documentRangeFormattingProvider then
rfmt = true
end
@ -157,7 +161,7 @@ local function set_mapping(user_opts)
local m = value.mode or 'n'
if string.find(value.func, 'range_formatting') then
rfmtkey = value.key
elseif string.find(value.func, 'formatting') then
elseif string.find(value.func, 'format') then
fmtkey = value.key
end
log('binding', k, f)
@ -174,7 +178,7 @@ local function set_mapping(user_opts)
vim.cmd([[
aug NavigatorAuFormat
au!
autocmd BufWritePre <buffer> lua vim.lsp.buf.formatting()
autocmd BufWritePre <buffer> lua vim.lsp.buf.format({async = true})
aug END
]])
elseif fmtkey then
@ -257,11 +261,11 @@ function M.setup(user_opts)
set_event_handler(user_opts)
local client = user_opts.client or {}
local cap = client.resolved_capabilities or vim.lsp.protocol.make_client_capabilities()
local cap = client.server_capabilities or vim.lsp.protocol.make_client_capabilities()
log('lsp cap:', cap)
if cap.call_hierarchy or cap.callHierarchy then
if cap.call_hierarchy or cap.callHierarchyProvider then
vim.lsp.handlers['callHierarchy/incomingCalls'] = require('navigator.hierarchy').incoming_calls_handler
vim.lsp.handlers['callHierarchy/outgoingCalls'] = require('navigator.hierarchy').outgoing_calls_handler
end
@ -270,7 +274,7 @@ function M.setup(user_opts)
-- vim.lsp.handlers["textDocument/codeAction"] = require"navigator.codeAction".code_action_handler
vim.lsp.handlers['textDocument/definition'] = require('navigator.definition').definition_handler
if cap.declaration then
if cap.declarationProvider then
vim.lsp.handlers['textDocument/declaration'] = require('navigator.definition').declaration_handler
end
@ -298,7 +302,7 @@ function M.setup(user_opts)
end
vim.lsp.handlers['textDocument/hover'] = vim.lsp.with(vim.lsp.handlers.hover, { border = single })
if cap.document_formatting then
if cap.documentFormattingProvider then
log('formatting enabled setup hdl')
vim.lsp.handlers['textDocument/formatting'] = require('navigator.formatting').format_hdl
end

@ -1,7 +1,6 @@
local M = {}
local util = require('navigator.util')
local nvim_0_6_1 = util.nvim_0_6_1()
local gutil = require('guihua.util')
local lsp = require('vim.lsp')
@ -122,7 +121,8 @@ function M.check_capabilities(feature, client_id)
local supported_client = false
for _, client in pairs(clients) do
supported_client = client.resolved_capabilities[feature]
-- supported_client = client.resolved_capabilities[feature]
supported_client = client.server_capabilities[feature]
if supported_client then
break
end
@ -145,11 +145,7 @@ function M.call_sync(method, params, opts, handler)
opts = opts or {}
local results_lsp, err = lsp.buf_request_sync(0, method, params, opts.timeout or vim.g.navtator_timeout or 1000)
if nvim_0_6_1 then
handler(err, extract_result(results_lsp), { method = method }, nil)
else
handler(err, method, extract_result(results_lsp), nil, nil)
end
handler(err, extract_result(results_lsp), { method = method }, nil)
end
function M.call_async(method, params, handler)

@ -1,5 +1,4 @@
local util = require('navigator.util')
local mk_handler = util.mk_handler
local log = util.log
local lsphelper = require('navigator.lspwrapper')
local gui = require('navigator.gui')
@ -135,7 +134,7 @@ local ref_view = function(err, locations, ctx, cfg)
return listview, items, width
end
local ref_hdlr = mk_handler(function(err, locations, ctx, cfg)
local ref_hdlr = function(err, locations, ctx, cfg)
_NgConfigValues.closer = nil
trace(err, locations, ctx, cfg)
M.async_hdlr = vim.loop.new_async(vim.schedule_wrap(function()
@ -145,7 +144,7 @@ local ref_hdlr = mk_handler(function(err, locations, ctx, cfg)
end
end))
M.async_hdlr:send()
end)
end
local async_ref = function()
local ref_params = vim.lsp.util.make_position_params()
@ -206,7 +205,7 @@ local ref = function()
local ref_params = vim.lsp.util.make_position_params()
vim.lsp.for_each_buffer_client(bufnr, function(client, client_id, bufnr)
if client.resolved_capabilities.find_references then
if client.server_capabilities.referencesProvider then
client.request('textDocument/references', ref_params, ref_hdlr, bufnr)
end
end)

@ -1,6 +1,5 @@
local gui = require "navigator.gui"
local util = require "navigator.util"
local mk_handler = util.mk_handler
local log = util.log
local partial = util.partial
local lsphelper = require "navigator.lspwrapper"
@ -47,7 +46,7 @@ local match_parameter = function(result)
end
end
local signature_handler = mk_handler(function(err, result, ctx, config)
local signature_handler = function(err, result, ctx, config)
if config == nil then
log("config nil")
end
@ -71,5 +70,5 @@ local signature_handler = mk_handler(function(err, result, ctx, config)
local syntax = vim.lsp.util.try_trim_markdown_code_blocks(lines)
config.focus_id = ctx.bufnr .. "lsp_signature"
vim.lsp.util.open_floating_preview(lines, syntax, config)
end)
end
return {signature_handler = signature_handler}

@ -2,7 +2,6 @@ local gui = require('navigator.gui')
local M = {}
local log = require('navigator.util').log
local trace = require('navigator.util').trace
local mk_handler = require('navigator.util').mk_handler
local lsphelper = require('navigator.lspwrapper')
local locations_to_items = lsphelper.locations_to_items
local clone = require('guihua.util').clone
@ -14,7 +13,8 @@ function M.workspace_symbols(query)
local bufnr = vim.api.nvim_get_current_buf()
local params = { query = query }
vim.lsp.for_each_buffer_client(bufnr, function(client, client_id, _bufnr)
if client.resolved_capabilities.workspace_symbol then
-- if client.resolved_capabilities.workspace_symbol then
if client.server_capabilities.workspaceSymbolProvider then
client.request('workspace/symbol', params, M.workspace_symbol_handler, _bufnr)
end
end)
@ -35,13 +35,14 @@ function M.document_symbols(opts)
params.context = { includeDeclaration = true }
params.query = opts.prompt or ''
vim.lsp.for_each_buffer_client(bufnr, function(client, client_id, _bufnr)
if client.resolved_capabilities.document_symbol then
-- if client.resolved_capabilities.document_symbol then
if client.server_capabilities.documentSymbolProvider then
client.request('textDocument/documentSymbol', params, M.document_symbol_handler, _bufnr)
end
end)
end
M.document_symbol_handler = mk_handler(function(err, result, ctx)
M.document_symbol_handler = function(err, result, ctx)
if err then
vim.notify('failed to get document symbol' .. vim.inspect(ctx), vim.lsp.log_levels.WARN)
end
@ -99,9 +100,9 @@ M.document_symbol_handler = mk_handler(function(err, result, ctx)
local ft = vim.api.nvim_buf_get_option(bufnr, 'ft')
gui.new_list_view({ items = locations, prompt = true, rawdata = true, ft = ft, api = '' })
end)
end
M.workspace_symbol_handler = mk_handler(function(err, result, ctx, cfg)
M.workspace_symbol_handler = function(err, result, ctx, cfg)
trace(err, result, ctx, cfg)
if err then
vim.notify('failed to get workspace symbol' .. vim.inspect(ctx), vim.lsp.log_levels.WARN)
@ -121,6 +122,6 @@ M.workspace_symbol_handler = mk_handler(function(err, result, ctx, cfg)
local ft = vim.api.nvim_buf_get_option(ctx.bufnr, 'ft')
gui.new_list_view({ items = items, prompt = true, ft = ft, rowdata = true, api = '' })
end)
end
return M

@ -5,6 +5,7 @@ local M = { log_path = vim.lsp.get_log_path() }
-- local is_windows = uv.os_uname().version:match("Windows")
local guihua = require('guihua.util')
local nvim_0_6_1
local nvim_0_8
M.path_sep = function()
local is_win = vim.loop.os_uname().sysname:find('Windows')
@ -354,11 +355,20 @@ function M.nvim_0_6_1()
return nvim_0_6_1
end
function M.nvim_0_8()
if nvim_0_8 ~= nil then
return nvim_0_8
end
nvim_0_8 = vim.fn.has('nvim-0.8') == 1
if nvim_0_8 == false then
M.log('Please use navigator 0.4 version for neovim version < 0.8')
end
return nvim_0_8
end
function M.mk_handler(fn)
return function(...)
if M.nvim_0_6_1() then
return fn(...)
end
return fn(...)
end
end
@ -392,7 +402,7 @@ function M.encoding(client)
return 'utf-8'
end
if type(oe) == 'table' then
oe = oe[1] or 'utf-8'
return oe[1]
end
return oe
end

Loading…
Cancel
Save