lint all codes

neovim_0.6^2
ray-x 2 years ago
parent 32ddd66dd2
commit 3f49769abc

@ -118,7 +118,6 @@ vim.cmd("command! -nargs=0 LspToggleFmt lua require'navigator.lspclient.mapping'
vim.cmd("command! -nargs=0 LspKeymaps lua require'navigator.lspclient.mapping'.get_keymaps_help()<CR>")
M.deprecated = function(cfg)
local warn = require('navigator.util').warn
if cfg.code_action_prompt then
warn('code_action_prompt moved to lsp.code_action')
end

@ -51,7 +51,7 @@ end
local call_hierarchy_handler_from = partial(call_hierarchy_handler, 'from')
local call_hierarchy_handler_to = partial(call_hierarchy_handler, 'to')
local function incoming_calls_handler(bang, err, result, ctx, cfg)
local function incoming_calls_handler(_, err, result, ctx, cfg)
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')
@ -61,7 +61,7 @@ local function incoming_calls_handler(bang, err, result, ctx, cfg)
gui.new_list_view({ items = results, ft = ft or 'cpp', api = '' })
end
-- err, method, result, client_id, bufnr
local function outgoing_calls_handler(bang, err, result, ctx, cfg)
local function outgoing_calls_handler(_, err, result, ctx, cfg)
local results = call_hierarchy_handler_to(err, result, ctx, cfg, 'Outgoing calls not found')
local ft = vim.api.nvim_buf_get_option(ctx.bufnr or 0, 'ft')

@ -2,7 +2,7 @@ local util = require('navigator.util')
local log = util.log
local trace = util.trace
local code_action = {}
local gui = require('navigator.gui')
-- local gui = require('navigator.gui')
local config = require('navigator').config_values()
local api = vim.api

@ -8,7 +8,6 @@ local trace = require('navigator.util').trace
local lsphelper = require('navigator.lspwrapper')
local api = vim.api
local gui = require('navigator.gui')
local M = {}
local config = require('navigator').config_values()

@ -85,6 +85,9 @@ local function def_preview(timeout_ms)
local ts = require('navigator.treesitter')
local root = parsers.get_parser(bufnr)
log(range)
if ts == nil then
return
end
local def_node = ts.get_node_at_pos({ range['start'].line, range['start'].character }, root)
local sr, _, er, _ = ts.get_node_scope(def_node)
@ -105,7 +108,7 @@ local function def_preview(timeout_ms)
end
local width = 40
local maxwidth = math.floor(vim.fn.winwidth(0) * 4 / 5)
for key, value in pairs(definition) do
for _, value in pairs(definition) do
-- log(key, value, width)
width = math.max(width, #value + 4)
width = math.min(maxwidth, width)
@ -143,7 +146,7 @@ local def = 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)
vim.lsp.for_each_buffer_client(bufnr, function(client, _, _bufnr)
-- if client.resolved_capabilities.goto_definition then
if client.server_capabilities.definitionProvider then
client.request('textDocument/definition', ref_params, definition_hdlr, _bufnr)

@ -306,10 +306,10 @@ local diag_hdlr = function(err, result, ctx, config)
end
end
local diag_hdlr_async = function()
local debounce = require('navigator.debounce').debounce_trailing
return debounce(100, diag_hdlr)
end
-- local diag_hdlr_async = function()
-- local debounce = require('navigator.debounce').debounce_trailing
-- return debounce(100, diag_hdlr)
-- end
local M = {}
@ -368,6 +368,9 @@ M.show_buf_diagnostics = function()
api = _NgConfigValues.icons.diagnostic_file .. _NgConfigValues.icons.diagnostic_head .. ' Diagnostic ',
enable_preview_edit = true,
})
if listview == nil then
return log("nil listview")
end
trace('new buffer', listview.bufnr)
if listview.bufnr then
vim.api.nvim_buf_add_highlight(listview.bufnr, -1, 'Title', 0, 0, -1)

@ -205,10 +205,10 @@ local function cmd_nohl()
end
end
_G.nav_doc_hl = function()
local 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)
vim.lsp.for_each_buffer_client(bufnr, function(client, _, _)
if client.server_capabilities.documentHighlightProvider == true then
client.request('textDocument/documentHighlight', ref_params, handle_document_highlight, bufnr)
end
@ -220,7 +220,7 @@ local function documentHighlight()
[[
augroup lsp_document_highlight
autocmd! * <buffer>
autocmd CursorHold,CursorHoldI <buffer> lua nav_doc_hl()
autocmd CursorHold,CursorHoldI <buffer> lua require('navigator.dochighlight').nav_doc_hl()
autocmd CursorMoved <buffer> lua vim.lsp.buf.clear_references()
augroup END
]],
@ -258,5 +258,6 @@ return {
handle_document_highlight = handle_document_highlight,
hi_symbol = hi_symbol,
nohl = nohl,
nav_doc_hl = nav_doc_hl,
cmd_nohl = cmd_nohl,
}

@ -87,7 +87,7 @@ function M.debug_folds()
end
end
M.fold_handler = function(err, result, ctx, config)
M.fold_handler = function(err, result, ctx, _)
-- params: err, method, result, client_id, bufnr
-- XXX: handle err?
if err or result == nil or #result == 0 then

@ -17,14 +17,14 @@ function M.on_attach()
-- M.update_folds()
end
function _G.custom_fold_text()
function Custom_fold_text()
local line = vim.fn.getline(vim.v.foldstart)
local line_count = vim.v.foldend - vim.v.foldstart + 1
-- log("" .. line .. " // " .. line_count .. " lines")
return '' .. line .. ': ' .. line_count .. ' lines'
end
vim.opt.foldtext = _G.custom_fold_text()
vim.opt.foldtext = Custom_fold_text()
vim.opt.fillchars = { eob = '-', fold = ' ' }

@ -1,7 +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
return {
format_hdl = function(err, result, ctx, cfg) -- FIXME: bufnr is nil
format_hdl = function(err, result, ctx, _) -- FIXME: bufnr is nil
if err ~= nil or result == nil then
return
end

@ -8,7 +8,7 @@ local api = vim.api
local active_list_view -- only one listview at a time
function M.new_list_view(opts)
log(opts)
-- log(opts)
local config = require('navigator').config_values()
if active_list_view ~= nil then
@ -36,6 +36,9 @@ function M.new_list_view(opts)
opts.data = require('navigator.render').prepare_for_render(items, opts)
end
opts.border = _NgConfigValues.border or 'shadow'
if vim.fn.hlID('TelescopePromptBorder') > 0 then
opts.border_hl = 'TelescopePromptBorder'
end
if not items or vim.tbl_isempty(items) then
log('empty data return')
return
@ -48,7 +51,7 @@ function M.new_list_view(opts)
opts.external = _NgConfigValues.external
opts.preview_lines_before = 3
trace(opts)
log(opts)
active_list_view = require('guihua.gui').new_list_view(opts)
return active_list_view
end

@ -9,7 +9,7 @@ local path_sep = require('navigator.util').path_sep()
local path_cur = require('navigator.util').path_cur()
local cwd = vim.loop.cwd()
local M = {}
local function call_hierarchy_handler(direction, err, result, ctx, cfg, error_message)
local function call_hierarchy_handler(direction, err, result, ctx, _, error_message)
if not result then
vim.notify('No call hierarchy items found', vim.lsp.log_levels.WARN)
return
@ -33,11 +33,11 @@ local function call_hierarchy_handler(direction, err, result, ctx, cfg, error_me
kind = require('navigator.lspclient.lspkind').symbol_kind(call_hierarchy_item.kind) .. ' '
end
-- for _, range in pairs(call_hierarchy_call.fromRanges) do
range = call_hierarchy_item.range or call_hierarchy_item.selectionRange
local range = call_hierarchy_item.range or call_hierarchy_item.selectionRange
local filename = assert(vim.uri_to_fname(call_hierarchy_item.uri))
local display_filename = filename:gsub(cwd .. path_sep, path_cur, 1)
call_hierarchy_item.detail = call_hierarchy_item.detail or ''
call_hierarchy_item.detail = call_hierarchy_item.detail:gsub('\n', '')
call_hierarchy_item.detail = string.gsub(call_hierarchy_item.detail, '\n', '')
trace(range, call_hierarchy_item)
local disp_item = {
@ -59,7 +59,8 @@ end
local call_hierarchy_handler_from = partial(call_hierarchy_handler, 'from')
local call_hierarchy_handler_to = partial(call_hierarchy_handler, 'to')
local function incoming_calls_handler(bang, err, result, ctx, cfg)
-- local function incoming_calls_handler(bang, err, result, ctx, cfg)
local function incoming_calls_handler(_, err, result, ctx, cfg)
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')
local results = call_hierarchy_handler_from(err, result, ctx, cfg, 'Incoming calls not found')
@ -68,7 +69,7 @@ local function incoming_calls_handler(bang, err, result, ctx, cfg)
gui.new_list_view({ items = results, ft = ft, api = '' })
end
local function outgoing_calls_handler(bang, err, result, ctx, cfg)
local function outgoing_calls_handler(_, err, result, ctx, cfg)
local results = call_hierarchy_handler_to(err, result, ctx, cfg, 'Outgoing calls not found')
local ft = vim.api.nvim_buf_get_option(ctx.bufnr, 'ft')

@ -2,12 +2,12 @@ local util = require('navigator.util')
local lsphelper = require('navigator.lspwrapper')
local gui = require('navigator.gui')
local M = {}
local location = require('guihua.location')
-- local location = require('guihua.location')
local partial = util.partial
local locations_to_items = lsphelper.locations_to_items
local log = util.log
-- dataformat should be same as reference
local function location_handler(err, locations, ctx, cfg, msg)
local function location_handler(err, locations, ctx, _, msg)
if err ~= nil then
vim.notify('ERROR: ' .. tostring(err) .. ' ' .. msg, vim.lsp.log_levels.WARN)
return
@ -15,7 +15,7 @@ local function location_handler(err, locations, ctx, cfg, msg)
return locations_to_items(locations, ctx)
end
local function implementation_handler(bang, err, result, ctx, cfg)
local function implementation_handler(_, err, result, ctx, cfg)
local results = location_handler(err, result, ctx, cfg, 'Implementation not found')
local ft = vim.api.nvim_buf_get_option(ctx.bufnr, 'ft')
gui.new_list_view({ items = results, ft = ft, api = 'Implementation' })

@ -51,7 +51,7 @@ return {
local lazy_plugins = {}
lazy_plugins[plugin_name] = path
loader = require('packer').loader
for plugin, url in pairs(lazy_plugins) do
for plugin, _ in pairs(lazy_plugins) do
if packer_plugins[plugin] and packer_plugins[plugin].loaded == false then
-- log("loading ", plugin)
pcall(loader, plugin)

@ -1,14 +1,12 @@
-- todo allow config passed in
local util = require('navigator.util')
local log = util.log
local trace = util.trace
local uv = vim.loop
local empty = util.empty
local warn = util.warn
local ng_util = require('navigator.util')
local log = ng_util.log
local trace = ng_util.trace
local empty = ng_util.empty
local warn = ng_util.warn
_NG_Loaded = {}
_LoadedFiletypes = {}
local loader = nil
packer_plugins = packer_plugins or nil -- suppress warnings
-- packer only
@ -203,7 +201,7 @@ local setups = {
},
sqls = {
filetypes = { 'sql' },
on_attach = function(client, bufnr)
on_attach = function(client, _)
client.server_capabilities.executeCommandProvider = client.server_capabilities.documentFormattingProvider or true
highlight.diagnositc_config_sign()
require('sqls').setup({ picker = 'telescope' }) -- or default
@ -369,7 +367,6 @@ local ng_default_cfg = {
flags = { allow_incremental_sync = true, debounce_text_changes = 1000 },
}
local configs = {}
-- check and load based on file type
local function load_cfg(ft, client, cfg, loaded)
@ -444,7 +441,6 @@ end
local function update_capabilities()
trace(vim.o.ft, 'lsp startup')
local loaded = {}
local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities.textDocument.completion.completionItem.snippetSupport = true
capabilities.textDocument.completion.completionItem.preselectSupport = true
@ -481,7 +477,7 @@ local function lsp_startup(ft, retry, user_lsp_opts)
if lspclient.name then
lspclient = lspclient.name
else
warn('incorrect set for lspclient', vim.inspect(lspclient))
warn('incorrect set for lspclient'.. vim.inspect(lspclient))
goto continue
end
end
@ -546,9 +542,9 @@ local function lsp_startup(ft, retry, user_lsp_opts)
if user_lsp_opts[lspclient] ~= nil then
-- log(lsp_opts[lspclient], cfg)
cfg = vim.tbl_deep_extend('force', cfg, user_lsp_opts[lspclient])
if config.combined_attach == nil then
setup_fmt(client, enable_fmt)
end
-- if config.combined_attach == nil then
-- setup_fmt(client, enable_fmt)
-- end
if config.combined_attach == 'mine' then
if config.on_attach == nil then
error('on attach not provided')
@ -652,7 +648,7 @@ local function lsp_startup(ft, retry, user_lsp_opts)
end, 1000)
log('null-ls loading')
_NG_Loaded['null-ls'] = true
configs['null-ls'] = cfg
setups['null-ls'] = cfg
end
end
@ -671,7 +667,7 @@ local function lsp_startup(ft, retry, user_lsp_opts)
lspconfig.efm.setup(cfg)
log('efm loading')
_NG_Loaded['efm'] = true
configs['efm'] = cfg
setups['efm'] = cfg
end
end

@ -1,6 +1,6 @@
local lsp = require("vim.lsp")
M = {}
local M = {}
local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities.textDocument.completion.completionItem.snippetSupport = true

@ -1,6 +1,6 @@
local M = {}
local log = require('navigator.util').log
-- local log = require('navigator.util').log
local api = vim.api
-- lsp sign          ﮻         ﯭ        ﳀ  

@ -1,78 +1,135 @@
local kind_symbols = {
Text = "",
Method = "ƒ",
Function = "",
Constructor = "",
Field = "",
Variable = "",
Class = "",
Interface = "",
Module = "",
Property = "",
Unit = "",
Value = "",
Enum = "",
Keyword = "",
Snippet = "",
Color = "",
File = "",
Reference = "",
Folder = "",
EnumMember = "",
Constant = "",
Struct = "",
Event = "",
Operator = "",
TypeParameter = "",
Default = ""
Text = '',
Method = 'ƒ',
Function = '',
Constructor = '',
Field = '',
Variable = '',
Class = '',
Interface = '',
Module = '',
Property = '',
Unit = '',
Value = '',
Enum = '',
Keyword = '',
Snippet = '',
Color = '',
File = '',
Reference = '',
Folder = '',
EnumMember = '',
Constant = '',
Struct = '',
Event = '',
Operator = '',
TypeParameter = '',
Default = '',
}
local CompletionItemKind = {
"", "𝔉 ", "", "", "", "", "", "", "", "", "", "", "𝕰 ", "",
"", "", "", "", "", "", "", "", "", "", "", ""
'',
'𝔉 ',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'𝕰 ',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
}
-- A symbol kind.
local SymbolKind = {
File = 1,
Module = 2,
Namespace = 3,
Package = 4,
Class = 5,
Method = 6,
Property = 7,
Field = 8,
Constructor = 9,
Enum = 10,
Interface = 11,
Function = 12,
Variable = 13,
Constant = 14,
String = 15,
Number = 16,
Boolean = 17,
Array = 18,
Object = 19,
Key = 20,
Null = 21,
EnumMember = 22,
Struct = 23,
Event = 24,
Operator = 25,
TypeParameter = 26
}
-- local SymbolKind = {
-- File = 1,
-- Module = 2,
-- Namespace = 3,
-- Package = 4,
-- Class = 5,
-- Method = 6,
-- Property = 7,
-- Field = 8,
-- Constructor = 9,
-- Enum = 10,
-- Interface = 11,
-- Function = 12,
-- Variable = 13,
-- Constant = 14,
-- String = 15,
-- Number = 16,
-- Boolean = 17,
-- Array = 18,
-- Object = 19,
-- Key = 20,
-- Null = 21,
-- EnumMember = 22,
-- Struct = 23,
-- Event = 24,
-- Operator = 25,
-- TypeParameter = 26
-- }
local SymbolItemKind = {
"", "", "", "", "", "ƒ ", "", "", "", "𝕰 ", "", "", "", "", "",
"", "", "", "", "", "", "", "", "", "", "", ""
'',
'',
'',
'',
'',
'ƒ ',
'',
'',
'',
'𝕰 ',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
}
local lspkind = {}
function lspkind.comp_kind(kind) return CompletionItemKind[kind] or "" end
function lspkind.comp_kind(kind)
return CompletionItemKind[kind] or ''
end
function lspkind.symbol_kind(kind) return SymbolItemKind[kind] or "" end
function lspkind.symbol_kind(kind)
return SymbolItemKind[kind] or ''
end
function lspkind.cmp_kind(kind) return kind_symbols[kind] or "" end
function lspkind.cmp_kind(kind)
return kind_symbols[kind] or ''
end
function lspkind.init() require('vim.lsp.protocol').CompletionItemKind = CompletionItemKind end
function lspkind.init()
require('vim.lsp.protocol').CompletionItemKind = CompletionItemKind
end
return lspkind

@ -148,14 +148,14 @@ local function set_mapping(user_opts)
local fmtkey, rfmtkey
for _, value in pairs(key_maps) do
local f = '<Cmd>lua vim.lsp.buf.' .. value.func .. '<CR>'
if string.find(value.func, 'require') then
if string.find(value.func, 'require') or string.find(value.func, 'vim.') then
f = '<Cmd>lua ' .. value.func .. '<CR>'
elseif string.find(value.func, 'diagnostic') then
local diagnostic = '<Cmd>lua vim.'
diagnostic = '<Cmd>lua vim.'
f = diagnostic .. value.func .. '<CR>'
elseif string.find(value.func, 'vim.') then
f = '<Cmd>lua ' .. value.func .. '<CR>'
-- elseif string.find(value.func, 'vim.') then
-- f = '<Cmd>lua ' .. value.func .. '<string.find(value.func, 'vim.')CR>'
end
local k = value.key
local m = value.mode or 'n'
@ -196,7 +196,7 @@ local function set_mapping(user_opts)
log('enable format ', doc_fmt, range_fmt, _NgConfigValues.lsp.format_on_save)
end
local function autocmd(user_opts)
local function autocmd()
vim.api.nvim_exec(
[[
aug NavigatorDocHlAu
@ -257,7 +257,7 @@ function M.setup(user_opts)
user_opts = user_opts or _NgConfigValues
set_mapping(user_opts)
autocmd(user_opts)
autocmd()
set_event_handler(user_opts)
local client = user_opts.client or {}
@ -301,7 +301,11 @@ function M.setup(user_opts)
})
end
vim.lsp.handlers['textDocument/hover'] = vim.lsp.with(vim.lsp.handlers.hover, { border = single })
local border_style = single
if _NgConfigValues.border == 'double' then
border_style = double
end
vim.lsp.handlers['textDocument/hover'] = vim.lsp.with(vim.lsp.handlers.hover, { border = border_style })
if cap.documentFormattingProvider then
log('formatting enabled setup hdl')
vim.lsp.handlers['textDocument/formatting'] = require('navigator.formatting').format_hdl

@ -294,21 +294,21 @@ local function slice_locations(locations, max_items)
return first_part, second_part
end
local function test_locations()
local locations = {
{ uri = '1', range = { start = { line = 1 } } },
{ uri = '2', range = { start = { line = 2 } } },
{ uri = '2', range = { start = { line = 3 } } },
{ uri = '1', range = { start = { line = 3 } } },
{ uri = '1', range = { start = { line = 4 } } },
{ uri = '3', range = { start = { line = 4 } } },
{ uri = '3', range = { start = { line = 4 } } },
}
local second_part
order_locations(locations)
local locations, second_part = slice_locations(locations, 3)
log(locations, second_part)
end
-- local function test_locations()
-- local locations = {
-- { uri = '1', range = { start = { line = 1 } } },
-- { uri = '2', range = { start = { line = 2 } } },
-- { uri = '2', range = { start = { line = 3 } } },
-- { uri = '1', range = { start = { line = 3 } } },
-- { uri = '1', range = { start = { line = 4 } } },
-- { uri = '3', range = { start = { line = 4 } } },
-- { uri = '3', range = { start = { line = 4 } } },
-- }
-- local second_part
-- order_locations(locations)
-- local locations, second_part = slice_locations(locations, 3)
-- log(locations, second_part)
-- end
function M.locations_to_items(locations, ctx)
ctx = ctx or {}
@ -462,7 +462,7 @@ end
function M.request(method, hdlr) -- e.g textDocument/reference
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)
vim.lsp.for_each_buffer_client(bufnr, function(client, _, _)
client.request(method, ref_params, hdlr, bufnr)
end)
end

@ -4,7 +4,6 @@ local lsphelper = require('navigator.lspwrapper')
local gui = require('navigator.gui')
local lsp = require('navigator.lspwrapper')
local trace = require('navigator.util').trace
ListViewCtrl = ListViewCtrl or require('guihua.listviewctrl').ListViewCtrl
-- local partial = util.partial
-- local cwd = vim.loop.cwd()
-- local lsphelper = require "navigator.lspwrapper"
@ -41,7 +40,7 @@ local ref_view = function(err, locations, ctx, cfg)
if references and references.result and #references.result > 0 then
local refs = references.result
for _, value in pairs(locations) do
vrange = value.range or { start = { line = 0 }, ['end'] = { line = 0 } }
local vrange = value.range or { start = { line = 0 }, ['end'] = { line = 0 } }
for i = 1, #refs, 1 do
local rg = refs[i].range or {}
log(value, refs[i])
@ -204,7 +203,7 @@ local ref = 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)
vim.lsp.for_each_buffer_client(bufnr, function(client, _, _)
if client.server_capabilities.referencesProvider then
client.request('textDocument/references', ref_params, ref_hdlr, bufnr)
end
@ -212,12 +211,9 @@ local ref = function()
end
return {
reference_handler = ref_hdlr,
reference = ref_req,
ref_view = ref_view,
async_ref = async_ref,
all_ref = ref,
}

@ -68,16 +68,16 @@ function M.prepare_for_render(items, opts)
local ext = extension(fn)
icon = devicons.get_icon(fn, ext) or icon
end
local call_by_presented = false
-- local call_by_presented = false
local width = 100
opts.width = opts.width or width
local win_width = opts.width -- buf
for i = 1, #items do
if items[i].call_by and #items[i].call_by > 0 then
call_by_presented = true
end
end
-- for i = 1, #items do
-- if items[i].call_by and #items[i].call_by > 0 then
-- call_by_presented = true
-- end
-- end
-- log(items[1])
for i = 1, #items do

@ -1,10 +1,5 @@
local gui = require "navigator.gui"
local util = require "navigator.util"
local log = util.log
local partial = util.partial
local lsphelper = require "navigator.lspwrapper"
local cwd = vim.loop.cwd()
local M = {}
--- navigator signature
local match_parameter = function(result)

@ -3,8 +3,6 @@ local M = {}
local log = require('navigator.util').log
local trace = require('navigator.util').trace
local lsphelper = require('navigator.lspwrapper')
local locations_to_items = lsphelper.locations_to_items
local clone = require('guihua.util').clone
local symbol_kind = require('navigator.lspclient.lspkind').symbol_kind
local symbols_to_items = lsphelper.symbols_to_items
@ -12,7 +10,7 @@ function M.workspace_symbols(query)
query = query or pcall(vim.fn.input, '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)
vim.lsp.for_each_buffer_client(bufnr, function(client, _, _bufnr)
-- if client.resolved_capabilities.workspace_symbol then
if client.server_capabilities.workspaceSymbolProvider then
client.request('workspace/symbol', params, M.workspace_symbol_handler, _bufnr)
@ -34,7 +32,7 @@ function M.document_symbols(opts)
local params = vim.lsp.util.make_position_params()
params.context = { includeDeclaration = true }
params.query = opts.prompt or ''
vim.lsp.for_each_buffer_client(bufnr, function(client, client_id, _bufnr)
vim.lsp.for_each_buffer_client(bufnr, function(client, _, _bufnr)
-- if client.resolved_capabilities.document_symbol then
if client.server_capabilities.documentSymbolProvider then
client.request('textDocument/documentSymbol', params, M.document_symbol_handler, _bufnr)

@ -149,9 +149,7 @@ local function prepare_node(node, kind)
end
local function get_scope(type, source)
local sbl, sbc, sel, sec = source:range()
local current = source
local result = current
local next = ts_utils.get_next_node(source)
local parent = current:parent()
trace(source:type(), source:range(), parent)
@ -169,7 +167,7 @@ local function get_scope(type, source)
-- for C++
local n = source
for i = 1, 4, 1 do
for _ = 1, 4, 1 do
if n == nil or n:parent() == nil then
break
end
@ -195,7 +193,7 @@ local function get_scope(type, source)
-- M.fun1 = function() end
-- lets work up and see next node, lua
local n = source
for i = 1, 4, 1 do
for _ = 1, 4, 1 do
if n == nil or n:parent() == nil then
break
end
@ -303,7 +301,7 @@ local function get_all_nodes(bufnr, filter, summary)
local all_nodes = {}
-- Support completion-nvim customized label map
local customized_labels = vim.g.completion_customize_lsp_label or {}
-- local customized_labels = vim.g.completion_customize_lsp_label or {}
-- Force some types to act like they are parents
-- instead of neighbors of the next nodes.

@ -114,7 +114,13 @@ end
function M.get_relative_path(base_path, my_path)
local base_data = getDir(base_path)
if base_data == nil then
return
end
local my_data = getDir(my_path)
if my_data == nil then
return
end
local base_len = #base_data
local my_len = #my_data
@ -163,10 +169,18 @@ if _NgConfigValues.debug then
M.error = M._log.error
else
M._log = {}
M.log = function() end
M.info = function() end
M.trace = function() end
M.error = function() end
M.log = function(...)
return { ... }
end
M.info = function(...)
return { ... }
end
M.trace = function(...)
return { ... }
end
M.error = function(...)
return { ... }
end
end
function M.fmt(...)
@ -261,7 +275,7 @@ function M.split2(s, sep)
sep = sep or ' '
local pattern = string.format('([^%s]+)', sep)
string.gsub(s, pattern, function(c)
_ = string.gsub(s, pattern, function(c)
fields[#fields + 1] = c
end)
@ -293,13 +307,13 @@ end
M.open_file_at = guihua.open_file_at
function M.exists(var)
for k, _ in pairs(_G) do
if k == var then
return true
end
end
end
-- function M.exists(var)
-- for k, _ in pairs(_G) do
-- if k == var then
-- return true
-- end
-- end
-- end
local exclude_ft = { 'scrollbar', 'help', 'NvimTree' }
function M.exclude(fname)

@ -38,7 +38,7 @@ M.list_workspace_folders = function()
items = folders,
border = 'single',
rawdata = true,
on_move = function(...)
on_move = function()
end
})
end

Loading…
Cancel
Save