using vim.log.levels instead of vim.log.lsp_levels

pull/268/head
ray-x 1 year ago
parent 8d96e06d18
commit c000890350

@ -16,7 +16,7 @@ local function call_hierarchy_handler(direction, err, result, ctx, cfg, error_me
assert(next(vim.lsp.get_active_clients()), 'Must have a client running to use lsp_tags')
if err ~= nil then
log('hierarchy error', ctx, 'dir', direction, 'result', result, 'err', err)
vim.notify('ERROR: ' .. error_message, vim.lsp.log_levels.WARN)
vim.notify('ERROR: ' .. error_message, vim.log.levels.WARN)
return
end
-- log(funcs)

@ -76,7 +76,7 @@ local function ctags_gen()
on_exit = function(_, data, _) -- id, data, event
-- log(vim.inspect(data) .. "exit")
if data and data ~= 0 then
return vim.notify(cmd .. ' failed ' .. tostring(data), vim.lsp.log_levels.ERROR)
return vim.notify(cmd .. ' failed ' .. tostring(data), vim.log.levels.ERROR)
else
vim.notify('ctags generated')
end

@ -9,7 +9,7 @@ local TextView = require('guihua.textview')
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)
vim.notify('Defination: ' .. tostring(err) .. vim.inspect(ctx), vim.log.levels.WARN)
return
end
if type(locations) == 'number' then
@ -50,7 +50,7 @@ local function def_preview(timeout_ms)
local result = vim.lsp.buf_request_sync(0, method, params, timeout_ms or 1000)
if result == nil or vim.tbl_isempty(result) then
vim.notify('No result found: ' .. method, vim.lsp.log_levels.WARN)
vim.notify('No result found: ' .. method, vim.log.levels.WARN)
return nil
end
@ -65,7 +65,7 @@ local function def_preview(timeout_ms)
end
if vim.tbl_isempty(data) then
vim.notify('No result found: ' .. method, vim.lsp.log_levels.WARN)
vim.notify('No result found: ' .. method, vim.log.levels.WARN)
return nil
end

@ -259,7 +259,7 @@ local function documentHighlight(bufnr)
vim.lsp.handlers['textDocument/documentHighlight'] = function(err, result, ctx)
local buffer = ctx.bufnr or api.nvim_get_current_buf()
if err then
-- vim.notify('failed to highlight symbol' .. vim.inspect(err), vim.lsp.log_levels.ERROR, vim.lsp.log_levels.ERROR)
-- vim.notify('failed to highlight symbol' .. vim.inspect(err), vim.log.levels.ERROR, vim.log.levels.ERROR)
log('failed to highlight symbol', err)
return
end

@ -85,7 +85,7 @@ 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
vim.notify(string.format('%s %s ', tostring(err), vim.inspect(ctx)), vim.lsp.log_levels.WARN)
vim.notify(string.format('%s %s ', tostring(err), vim.inspect(ctx)), vim.log.levels.WARN)
return
end
M.debug_folds()

@ -46,7 +46,7 @@ local function call_hierarchy_result_procesor(direction, err, result, ctx, confi
trace(direction, err, ctx, config)
trace(result)
if not result then
vim.notify('No call hierarchy items found', vim.lsp.log_levels.WARN)
vim.notify('No call hierarchy items found', vim.log.levels.WARN)
return
end
-- trace('call_hierarchy', result)
@ -55,7 +55,7 @@ local function call_hierarchy_result_procesor(direction, err, result, ctx, confi
assert(next(vim.lsp.get_active_clients({buffer = bufnr})), 'Must have a client running to use call hierarchy')
if err ~= nil then
log('dir', direction, 'result', result, 'err', err, ctx)
vim.notify('ERROR: ' .. err, vim.lsp.log_levels.WARN)
vim.notify('ERROR: ' .. err, vim.log.levels.WARN)
return
end

@ -9,7 +9,7 @@ local log = util.log
-- dataformat should be same as reference
local function location_handler(err, locations, ctx, _, msg)
if err ~= nil then
vim.notify('ERROR: ' .. tostring(err) .. ' ' .. msg, vim.lsp.log_levels.WARN)
vim.notify('ERROR: ' .. tostring(err) .. ' ' .. msg, vim.log.levels.WARN)
return
end
return locations_to_items(locations, ctx)

@ -18,7 +18,7 @@ local has_lsp, lspconfig = pcall(require, 'lspconfig')
if not has_lsp then
return {
setup = function()
vim.notify('loading lsp config failed LSP may not working correctly', vim.lsp.log_levels.WARN)
vim.notify('loading lsp config failed LSP may not working correctly', vim.log.levels.WARN)
end,
}
end
@ -256,7 +256,7 @@ local function lsp_startup(ft, retry, user_lsp_opts)
if lspconfig[lspclient] == nil then
vim.notify(
'lspclient' .. vim.inspect(lspclient) .. 'no longer support by lspconfig, please submit an issue',
vim.lsp.log_levels.WARN
vim.log.levels.WARN
)
log('lspclient', lspclient, 'not supported')
goto continue
@ -265,7 +265,7 @@ local function lsp_startup(ft, retry, user_lsp_opts)
if lspconfig[lspclient].document_config and lspconfig[lspclient].document_config.default_config then
default_config = lspconfig[lspclient].document_config.default_config
else
vim.notify('missing document config for client: ' .. vim.inspect(lspclient), vim.lsp.log_levels.WARN)
vim.notify('missing document config for client: ' .. vim.inspect(lspclient), vim.log.levels.WARN)
goto continue
end
@ -349,7 +349,7 @@ local function lsp_startup(ft, retry, user_lsp_opts)
client.notify(
'workspace/didChangeConfiguration',
{ settings = client.config.settings },
vim.lsp.log_levels.WARN
vim.log.levels.WARN
)
end
end
@ -417,7 +417,7 @@ local function lsp_startup(ft, retry, user_lsp_opts)
if vfn.executable(cfg.cmd[1]) == 0 then
log('lsp server not installed in path ' .. lspclient .. vim.inspect(cfg.cmd), vim.lsp.log_levels.WARN)
log('lsp server not installed in path ' .. lspclient .. vim.inspect(cfg.cmd), vim.log.levels.WARN)
end
if _NG_Loaded[lspclient] then

@ -6,7 +6,7 @@ M.defaults = function()
if not has_lsp then
return {
setup = function()
vim.notify('loading lsp config failed LSP may not working correctly', vim.lsp.log_levels.WARN)
vim.notify('loading lsp config failed LSP may not working correctly', vim.log.levels.WARN)
end,
}
end

@ -389,12 +389,12 @@ M.toggle_lspformat = function(on)
end
if _NgConfigValues.lsp.format_on_save then
if on == nil then
vim.notify('format on save true', vim.lsp.log_levels.INFO)
vim.notify('format on save true', vim.log.levels.INFO)
end
vim.cmd([[set eventignore-=BufWritePre]])
else
if on == nil then
vim.notify('format on save false', vim.lsp.log_levels.INFO)
vim.notify('format on save false', vim.log.levels.INFO)
end
vim.cmd([[set eventignore+=BufWritePre]])
end
@ -404,7 +404,7 @@ function M.setup(attach_opts)
if not attach_opts or not attach_opts.client then
vim.notify(
'please call require"navigator.mapping".setup({bufnr=bufnr, client=client}) inside on_attach(client,bufnr)',
vim.lsp.log_levels.WARN
vim.log.levels.WARN
)
end
attach_opts = attach_opts or { bufnr = 0, client = {}, cap = {} }

@ -330,7 +330,7 @@ function M.locations_to_items(locations, ctx)
local client_id = ctx.client_id or 1
local enc = util.encoding(client_id)
if not locations or vim.tbl_isempty(locations) then
vim.notify('list not avalible', vim.lsp.log_levels.WARN)
vim.notify('list not avalible', vim.log.levels.WARN)
return
end
local width = 4
@ -453,7 +453,7 @@ end
function M.symbol_to_items(locations)
if not locations or vim.tbl_isempty(locations) then
vim.notify('list not avalible', vim.lsp.log_levels.WARN)
vim.notify('list not avalible', vim.log.levels.WARN)
return
end

@ -33,7 +33,7 @@ local ref_view = function(err, locations, ctx, cfg)
log(logctx, 'result size', 'def', #ctx.results.definitions, 'ref', #ctx.results.references)
end
if definitions.error and references.error then
vim.notify('lsp ref callback error' .. vim.inspect(ctx.result), vim.lsp.log_levels.WARN)
vim.notify('lsp ref callback error' .. vim.inspect(ctx.result), vim.log.levels.WARN)
end
locations = {}
if definitions and definitions.result then
@ -58,7 +58,7 @@ local ref_view = function(err, locations, ctx, cfg)
if err ~= nil then
vim.notify(
'lsp ref callback error' .. vim.inspect(err) .. vim.inspect(ctx) .. vim.inspect(locations),
vim.lsp.log_levels.WARN
vim.log.levels.WARN
)
log('ref callback error, lsp may not ready', err, ctx, vim.inspect(locations))
return
@ -66,11 +66,11 @@ local ref_view = function(err, locations, ctx, cfg)
if type(locations) ~= 'table' then
log(locations)
log('ctx', ctx)
vim.notify('incorrect setup' .. vim.inspect(locations), vim.lsp.log_levels.WARN)
vim.notify('incorrect setup' .. vim.inspect(locations), vim.log.levels.WARN)
return
end
if locations == nil or vim.tbl_isempty(locations) then
vim.notify('References not found', vim.lsp.log_levels.INFO)
vim.notify('References not found', vim.log.levels.INFO)
return
end
@ -100,7 +100,7 @@ local ref_view = function(err, locations, ctx, cfg)
listview = gui.new_list_view(opts)
if listview == nil then
vim.notify('failed to create preview windows', vim.lsp.log_levels.INFO)
vim.notify('failed to create preview windows', vim.log.levels.INFO)
return
end
end

@ -124,22 +124,26 @@ local function cache_lines(result)
end
local function fetch_lsp_references(bufnr, lsp_params, callback)
require('navigator.reference').fetch_lsp_references(bufnr, lsp_params, function(err, result, ctx, cfg)
if err then
log('[nav-rename] Error while finding references: ' .. err.message, ctx, cfg)
return
end
if not result or vim.tbl_isempty(result) then
log('[nav-rename] Nothing to rename', result)
return
end
state.total = #result
state.cached_lines = cache_lines(result)
state.should_fetch_references = false
if callback then
callback()
require('navigator.reference').fetch_lsp_references(
bufnr,
lsp_params,
function(err, result, ctx, cfg)
if err then
log('[nav-rename] Error while finding references: ' .. err.message, ctx, cfg)
return
end
if not result or vim.tbl_isempty(result) then
log('[nav-rename] Nothing to rename', result)
return
end
state.total = #result
state.cached_lines = cache_lines(result)
state.should_fetch_references = false
if callback then
callback()
end
end
end)
)
end
-- a function from smjonas/inc-rename.nvim
@ -208,7 +212,14 @@ local function incremental_rename_preview(opts, preview_ns, preview_buf)
api.nvim_buf_set_lines(bufnr or opts.bufnr, line_nr, line_nr + 1, false, { updated_line })
for _, hl_pos in ipairs(highlight_positions) do
api.nvim_buf_add_highlight(bufnr or opts.bufnr, preview_ns, M.hl_group, line_nr, hl_pos.start_col, hl_pos.end_col)
api.nvim_buf_add_highlight(
bufnr or opts.bufnr,
preview_ns,
M.hl_group,
line_nr,
hl_pos.start_col,
hl_pos.end_col
)
end
end
@ -229,12 +240,12 @@ local function perform_lsp_rename(new_name, params)
vim.lsp.buf_request(0, 'textDocument/rename', params, function(err, result, ctx, _)
if err and err.message then
vim.notify('[nav-rename] Error while renaming: ' .. err.message, vim.lsp.log_levels.ERROR)
vim.notify('[nav-rename] Error while renaming: ' .. err.message, vim.log.levels.ERROR)
return
end
if not result or vim.tbl_isempty(result) then
set_error('[nav-rename] Nothing renamed', vim.lsp.log_levels.WARN)
set_error('[nav-rename] Nothing renamed', vim.log.levels.WARN)
return
end
@ -270,7 +281,10 @@ end
local function inc_rename_execute(opts)
if vim.v.errmsg ~= '' then
log('[nav-rename] An error occurred in the preview function.' .. vim.v.errmsg, vim.lsp.log_levels.ERROR)
log(
'[nav-rename] An error occurred in the preview function.' .. vim.v.errmsg,
vim.log.levels.ERROR
)
elseif state.err then
log(state.err.msg, state.err.level)
end
@ -428,7 +442,8 @@ function M.rename_inplace(new_name, options)
---@private
local function rename(name)
params.newName = name
local handler = client.handlers['textDocument/rename'] or vim.lsp.handlers['textDocument/rename']
local handler = client.handlers['textDocument/rename']
or vim.lsp.handlers['textDocument/rename']
client.request('textDocument/rename', params, function(...)
handler(...)
try_use_client(next(clients, idx))
@ -442,7 +457,8 @@ function M.rename_inplace(new_name, options)
if next(clients, idx) then
try_use_client(next(clients, idx))
else
local msg = err and ('Error on prepareRename: ' .. (err.message or '')) or 'Nothing to rename'
local msg = err and ('Error on prepareRename: ' .. (err.message or ''))
or 'Nothing to rename'
vim.notify(msg, vim.log.levels.INFO)
end
return
@ -514,7 +530,10 @@ function M.rename_inplace(new_name, options)
vim.cmd('noautocmd startinsert')
end, bufnr)
else
assert(client.supports_method('textDocument/rename'), 'Client must support textDocument/rename')
assert(
client.supports_method('textDocument/rename'),
'Client must support textDocument/rename'
)
if new_name then
rename(new_name)
return

@ -53,7 +53,7 @@ end
function M.prepare_for_render(items, opts)
opts = opts or {}
if items == nil or #items < 1 then
vim.notify('no item found or empty fields', vim.lsp.log_levels.INFO)
vim.notify('no item found or empty fields', vim.log.levels.INFO)
return
end
local item = clone(items[1])

@ -46,7 +46,7 @@ local signature_handler = function(err, result, ctx, config)
log("config nil")
end
if err then
vim.notify("signature help error: ".. vim.inspect(err) .. vim.inspect(result), ctx, config, vim.lsp.log_levels.WARN)
vim.notify("signature help error: ".. vim.inspect(err) .. vim.inspect(result), ctx, config, vim.log.levels.WARN)
end
config = config or {}
if config.border == nil then

@ -43,7 +43,7 @@ M.document_symbol_handler = function(err, result, ctx)
if error ~= 'timeout' then
vim.notify(
'failed to get document symbol' .. vim.inspect(ctx) .. err,
vim.lsp.log_levels.WARN
vim.log.levels.WARN
)
else
log('request timeout')
@ -59,7 +59,7 @@ M.document_symbol_handler = function(err, result, ctx)
if not result or vim.tbl_isempty(result) then
vim.notify(
'symbol ' .. query .. ' not found for buf ' .. vim.inspect(ctx),
vim.lsp.log_levels.WARN
vim.log.levels.WARN
)
return
end
@ -134,7 +134,7 @@ end
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)
vim.notify('failed to get workspace symbol' .. vim.inspect(ctx), vim.log.levels.WARN)
end
local query = ' '
if ctx.params and ctx.params.query then
@ -144,7 +144,7 @@ M.workspace_symbol_handler = function(err, result, ctx, cfg)
log('symbol not found', ctx)
vim.notify(
'symbol' .. query .. 'not found for buf ' .. tostring(ctx.bufnr),
vim.lsp.log_levels.WARN
vim.log.levels.WARN
)
return
end

@ -461,13 +461,13 @@ local function get_all_nodes(bufnr, filter, summary)
trace(bufnr, filter, summary)
if not bufnr then
vim.notify('get_all_node invalid bufnr', vim.lsp.log_levels.WARN)
vim.notify('get_all_node invalid bufnr', vim.log.levels.WARN)
end
summary = summary or false
local ft = vim.api.nvim_buf_get_option(bufnr, 'filetype')
if not parsers.has_parser() then
if not require('navigator.lspclient.clients').ft_disabled(ft) then
-- vim.notify('ts not loaded ' .. ft, vim.lsp.log_levels.Debug)
-- vim.notify('ts not loaded ' .. ft, vim.log.levels.Debug)
log('ts not loaded ' .. ft)
end
return {}

@ -470,15 +470,15 @@ end
-- alternatively: use vim.notify("namespace does not exist or is anonymous", vim.log.levels.ERROR)
function M.warn(msg)
vim.notify('WRN: ' .. msg, vim.lsp.log_levels.WARN)
vim.notify('WRN: ' .. msg, vim.log.levels.WARN)
end
function M.error(msg)
vim.notify('ERR: ' .. msg, vim.lsp.log_levels.EROR)
vim.notify('ERR: ' .. msg, vim.log.levels.EROR)
end
function M.info(msg)
vim.notify('INF: ' .. msg, vim.lsp.log_levels.INFO)
vim.notify('INF: ' .. msg, vim.log.levels.INFO)
end
function M.dedup(locations)

Loading…
Cancel
Save