replace print to notify, add workspace gui

neovim_0.6
ray-x 2 years ago
parent 85d907ffaf
commit c528b58bb9

@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title></title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="css/style.css" rel="stylesheet">
</head>
<body>
</body>
</html>

@ -16,7 +16,7 @@ local function call_hierarchy_handler(direction, err, result, ctx, cfg, error_me
assert(#vim.lsp.buf_get_clients() > 0, "Must have a client running to use lsp_tags")
if err ~= nil then
log("hierarchy error", ctx, "dir", direction, "result", result, "err", err)
print("ERROR: " .. error_message)
vim.notify("ERROR: " .. error_message, vim.lsp.log_levels.WARN)
return
end
-- local funcs = vim.lsp.util.locations_to_items(result)

@ -8,7 +8,7 @@ local TextView = require("guihua.textview")
local definition_hdlr = util.mk_handler(function(err, locations, ctx, _)
-- log(locations)
if err ~= nil then
print(err, ctx)
vim.notify(err, ctx, vim.lsp.log_levels.WARN)
return
end
if type(locations) == "number" then
@ -16,7 +16,7 @@ local definition_hdlr = util.mk_handler(function(err, locations, ctx, _)
log("unable to handle request")
end
if locations == nil or vim.tbl_isempty(locations) then
print "Definition not found"
vim.notify "Definition not found"
return
end
if vim.tbl_islist(locations) then
@ -43,7 +43,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
print("No result found: " .. method)
vim.notify("No result found: " .. method, vim.lsp.log_levels.WARN)
return nil
end
@ -58,7 +58,7 @@ local function def_preview(timeout_ms)
end
if vim.tbl_isempty(data) then
print("No result found: " .. method)
vim.notify("No result found: " .. method, vim.lsp.log_levels.WARN)
return nil
end

@ -427,7 +427,7 @@ end
-- TODO: update the marker
if _NgConfigValues.diagnostic_scrollbar_sign then
print("config deprecated, set lsp.diagnostic_scrollbar_sign instead")
vim.notify("config deprecated, set lsp.diagnostic_scrollbar_sign instead", vim.lsp.log_levels.WARN)
end
if _NgConfigValues.lsp.diagnostic_scrollbar_sign then

@ -233,7 +233,7 @@ local function documentHighlight()
vim.lsp.handlers['textDocument/documentHighlight'] = mk_handler(function(err, result, ctx)
local bufnr = ctx.bufnr or api.nvim_get_current_buf()
if err then
print(err)
vim.notify(err, vim.lsp.log_levels.ERROR)
return
end
if not result or not result[1] or not result[1]['range'] then

@ -93,7 +93,7 @@ M.fold_handler = mk_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
print(err, ctx.method, ctx.client_id)
vim.notify(err, ctx.method, ctx.client_id, vim.lsp.log_levels.WARN)
return
end
M.debug_folds()

@ -32,7 +32,7 @@ vim.opt.viewoptions:remove("options")
function M.setup_fold()
if not parsers.has_parser() then
print("treesitter folding not enabled for current file")
vim.notify("treesitter folding not enabled for current file", vim.lsp.log_levels.WARN)
return
end
log("setup treesitter folding")

@ -11,14 +11,14 @@ local cwd = vim.loop.cwd()
local M = {}
local function call_hierarchy_handler(direction, err, result, ctx, cfg, error_message)
if not result then
print("No call hierarchy items found")
vim.notify ("No call hierarchy items found", vim.lsp.log_levels.WARN)
return
end
trace('call_hierarchy', result)
assert(#vim.lsp.buf_get_clients() > 0, "Must have a client running to use lsp_tags")
if err ~= nil then
log("dir", direction, "result", result, "err", err, ctx)
print("ERROR: " .. error_message)
vim.notify("ERROR: " .. error_message, vim.lsp.log_levels.WARN)
return
end

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

@ -18,7 +18,7 @@ local has_lsp, lspconfig = pcall(require, 'lspconfig')
if not has_lsp then
return {
setup = function()
print('loading lsp config failed LSP may not working correctly')
vim.notify('loading lsp config failed LSP may not working correctly', vim.lsp.log_levels.WARN)
end,
}
end
@ -457,14 +457,14 @@ local function lsp_startup(ft, retry, user_lsp_opts)
local default_config = {}
log(lspclient)
if lspconfig[lspclient] == nil then
print('lspclient', lspclient, 'no longer support by lspconfig, please submit an issue')
vim.notify('lspclient', lspclient, 'no longer support by lspconfig, please submit an issue', vim.lsp.log_levels.WARN)
goto continue
end
if lspconfig[lspclient].document_config and lspconfig[lspclient].document_config.default_config then
default_config = lspconfig[lspclient].document_config.default_config
else
print('missing document config for client: ', lspclient)
vim.notify('missing document config for client: ', lspclient, vim.lsp.log_levels.WARN)
goto continue
end
@ -525,7 +525,7 @@ local function lsp_startup(ft, retry, user_lsp_opts)
end
cfg.on_init = function(client)
if client and client.config and client.config.settings then
client.notify('workspace/didChangeConfiguration', { settings = client.config.settings })
client.notify('workspace/didChangeConfiguration', { settings = client.config.settings }, vim.lsp.log_levels.WARN)
end
end
end

@ -45,7 +45,7 @@ local key_maps = {
{ key = '<Space>wr', func = 'remove_workspace_folder()' },
{ key = '<Space>ff', func = 'formatting()', mode = 'n' },
{ key = '<Space>ff', func = 'range_formatting()', mode = 'v' },
{ key = '<Space>wl', func = 'print(vim.inspect(vim.lsp.buf.list_workspace_folders()))' },
{ key = '<Space>wl', func = 'vim.notify(vim.inspect(vim.lsp.buf.list_workspace_folders()))' },
{ key = '<Space>la', mode = 'n', func = "require('navigator.codelens').run_action()" },
}
@ -221,12 +221,12 @@ M.toggle_lspformat = function(on)
end
if _NgConfigValues.lsp.format_on_save then
if on == nil then
print('format on save true')
vim.notify('format on save true', vim.lsp.log_levels.INFO)
end
vim.cmd([[set eventignore-=BufWritePre]])
else
if on == nil then
print('format on save false')
vim.notify('format on save false', vim.lsp.log_levels.INFO)
end
vim.cmd([[set eventignore+=BufWritePre]])
end

@ -314,7 +314,7 @@ end
function M.locations_to_items(locations, max_items)
max_items = max_items or 100000 --
if not locations or vim.tbl_isempty(locations) then
print('list not avalible')
vim.notify('list not avalible', vim.lsp.log_levels.WARN)
return
end
local width = 4
@ -420,7 +420,7 @@ end
function M.symbol_to_items(locations)
if not locations or vim.tbl_isempty(locations) then
print('list not avalible')
vim.notify('list not avalible', vim.lsp.log_levels.WARN)
return
end

@ -20,18 +20,18 @@ local ref_view = function(err, locations, ctx, cfg)
-- log("num", num)
-- log("bfnr", bufnr)
if err ~= nil then
print('lsp ref callback error', err, ctx, vim.inspect(locations))
vim.notify('lsp ref callback error', err, ctx, vim.inspect(locations), vim.lsp.log_levels.WARN)
log('ref callback error, lsp may not ready', err, ctx, vim.inspect(locations))
return
end
if type(locations) ~= 'table' then
log(locations)
log('ctx', ctx)
print('incorrect setup', locations)
vim.notify('incorrect setup', locations, vim.lsp.log_levels.WARN)
return
end
if locations == nil or vim.tbl_isempty(locations) then
print('References not found')
vim.notify('References not found', vim.lsp.log_levels.WARN)
return
end
@ -58,7 +58,7 @@ local ref_view = function(err, locations, ctx, cfg)
local listview = gui.new_list_view(opts)
if listview == nil then
print('failed to create preview windows')
vim.notify('failed to create preview windows', vim.lsp.log_levels.WARN)
return
end
-- trace("update items", listview.ctrl.class)

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

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

@ -30,7 +30,7 @@ local symbols_to_items = lsphelper.symbols_to_items
-- if #lines > 0 then
-- gui.new_list_view({data = lines})
-- else
-- print("symbols not found")
-- vim.notify("symbols not found")
-- end
-- end
@ -77,12 +77,12 @@ end
M.document_symbol_handler = mk_handler(function(err, result, ctx)
if err then
print('failed to get document symbol', ctx)
vim.notify('failed to get document symbol', ctx, vim.lsp.log_levels.WARN)
end
local bufnr = ctx.bufnr or 0
if not result or vim.tbl_isempty(result) then
print('symbol not found for buf', ctx)
vim.notify('symbol not found for buf', ctx, vim.lsp.log_levels.WARN)
return
end
-- log(result)
@ -134,10 +134,10 @@ end)
M.workspace_symbol_handler = mk_handler(function(err, result, ctx, cfg)
if err then
print('failed to get workspace symbol', ctx)
vim.notify('failed to get workspace symbol', ctx, vim.lsp.log_levels.WARN)
end
if not result or vim.tbl_isempty(result) then
print('symbol not found for buf', ctx)
vim.notify('symbol not found for buf', ctx, vim.lsp.log_levels.WARN)
return
end
log(result[1])
@ -161,7 +161,7 @@ M.workspace_symbol_handler = mk_handler(function(err, result, ctx, cfg)
-- gui.new_list_view({items = items, prompt = true, ft = ft, rowdata = true, api = " "})
-- if locations == nil or vim.tbl_isempty(locations) then
-- print "References not found"
-- vim.notify "References not found"
-- return
-- end
-- local items = locations_to_items(locations)

@ -292,11 +292,11 @@ local function get_all_nodes(bufnr, filter, summary)
trace(bufnr, filter, summary)
if not bufnr then
print("get_all_node invalide bufnr")
vim.notify("get_all_node invalide bufnr", vim.lsp.log_levels.WARN)
end
summary = summary or false
if not parsers.has_parser() then
print("ts not loaded")
vim.notify("ts not loaded", vim.lsp.log_levels.WARN)
end
local path_sep = require"navigator.util".path_sep()

@ -211,7 +211,7 @@ function M.getArgs(inputstr)
end
function M.p(t)
print(vim.inspect(t))
vim.notify(vim.inspect(t), vim.log.levels.INFO)
end
function M.printError(msg)

@ -0,0 +1,49 @@
-- https://github.com/lukas-reineke/dotfiles/blob/master/vim/lua/lsp/rename.lua
local M = {}
local util = require('navigator.util')
-- local rename_prompt = 'Rename -> '
M.add_workspace_folder = function()
util.log(vim.ui.input)
local input = require('guihua.floating').input
input({ prompt = 'Workspace To Add: ', default = vim.fn.expand('%:p:h') }, function(inputs)
util.log(inputs)
vim.lsp.buf.add_workspace_folder(inputs)
end)
end
M.remove_workspace_folder = function()
local select = require('guihua.gui').select
local folders = vim.lsp.buf.list_workspace_folders()
if #folders > 1 then
select(folders, { prompt = 'select workspace to delete' }, function(workspace)
util.log(workspace)
vim.lsp.buf.remove_workspace_folder(workspace)
end)
end
end
M.workspace_symbol = function()
local input = vim.ui.input
vim.ui.input = require('guihua.floating').input
vim.lsp.buf.workspace_symbol()
vim.defer_fn(function()
vim.ui.input = input
end, 1000)
end
M.list_workspace_folders = function()
local folders = vim.lsp.buf.list_workspace_folders()
if #folders > 0 then
return require('navigator.gui').new_list_view({
items = folders,
border = 'single',
rawdata = true,
on_move = function(...) end,
})
end
end
return M
Loading…
Cancel
Save