Merge vim.loop changes (replacing vim.fn.getcwd)

neovim_0.6
ray-x 3 years ago
parent 0dc5851d1c
commit 26012cf9c1

@ -54,6 +54,8 @@ included for LSP clients.
all features(handler) provided by LSP from commonly used search reference, to less commonly used search for interface
implementation.
- Luv async job
- Edit your code in preview window
- Async request with lsp.buf_request for reference search

@ -3,7 +3,7 @@ local util = require "navigator.util"
local log = util.log
local partial = util.partial
local lsphelper = require "navigator.lspwrapper"
local cwd = vim.fn.getcwd(0)
local cwd = vim.loop.cwd()
local path_sep = require"navigator.util".path_sep()
local path_cur = require"navigator.util".path_cur()

@ -106,7 +106,7 @@ local diag_hdlr = mk_handler(function(err, result, ctx, config)
log(err, config)
return
end
local cwd = vim.fn.getcwd(0)
local cwd = vim.loop.cwd()
local ft = vim.bo.filetype
if diagnostic_list[ft] == nil then
diagnostic_list[vim.bo.filetype] = {}

@ -90,6 +90,7 @@ function M._preview_location(opts) -- location, width, pos_x, pos_y
end
function M.preview_uri(opts) -- uri, width, line, col, offset_x, offset_y
-- local handle = vim.loop.new_async(vim.schedule_wrap(function()
local line_beg = opts.lnum - 1
if line_beg >= _NgConfigValues.preview_lines_before then
line_beg = line_beg - _NgConfigValues.preview_lines_before
@ -104,6 +105,9 @@ function M.preview_uri(opts) -- uri, width, line, col, offset_x, offset_y
trace("uri", opts.uri, opts.lnum, opts.location.range.start.line, opts.location.range['end'].line)
return M._preview_location(opts)
-- handle:close()
-- end))
-- handle:send()
end
function M.new_list_view(opts)

@ -6,7 +6,7 @@ local lsphelper = require "navigator.lspwrapper"
local path_sep = require"navigator.util".path_sep()
local path_cur = require"navigator.util".path_cur()
local cwd = vim.fn.getcwd(0)
local cwd = vim.loop.cwd()
local M = {}
local function call_hierarchy_handler(direction, err, result, ctx, cfg, error_message)

@ -10,7 +10,7 @@ local log = require"navigator.util".log
local lerr = require"navigator.util".error
local trace = require"navigator.util".trace
local symbol_kind = require"navigator.lspclient.lspkind".symbol_kind
local cwd = vim.fn.getcwd(0)
local cwd = vim.loop.cwd()
local is_win = vim.loop.os_uname().sysname:find("Windows")

@ -6,14 +6,14 @@ local gui = require "navigator.gui"
local lsp = require "navigator.lspwrapper"
local trace = require"navigator.util".trace
-- local partial = util.partial
-- local cwd = vim.fn.getcwd(0)
-- local cwd = vim.loop.cwd()
-- local lsphelper = require "navigator.lspwrapper"
local locations_to_items = lsphelper.locations_to_items
local ref_hdlr = mk_handler(function(err, locations, ctx, cfg)
local ref_view = function(err, locations, ctx, cfg)
local opts = {}
trace("arg1", err, ctx, locations)
log(api)
log(ctx.api)
trace(locations)
-- log("num", num)
-- log("bfnr", bufnr)
@ -49,8 +49,18 @@ local ref_hdlr = mk_handler(function(err, locations, ctx, cfg)
enable_preview_edit = true
})
return listview, items, width
end)
end
local M = {}
local ref_hdlr = mk_handler(function(err, locations, ctx, cfg)
trace(err, locations, ctx, cfg)
M.async_hdlr = vim.loop.new_async(vim.schedule_wrap(function()
ref_view(err, locations, ctx, cfg)
M.async_hdlr:close()
end))
M.async_hdlr:send()
end)
local async_reference_request = function()
local ref_params = vim.lsp.util.make_position_params()
ref_params.context = {includeDeclaration = true}
@ -58,4 +68,4 @@ local async_reference_request = function()
lsp.call_async("textDocument/definition", ref_params, ref_hdlr) -- return asyncresult, canceller
end
return {reference_handler = ref_hdlr, show_reference = async_reference_request}
return {reference_handler = ref_hdlr, show_reference = async_reference_request, ref_view = ref_view}

@ -4,7 +4,7 @@ local mk_handler = util.mk_handler
local log = util.log
local partial = util.partial
local lsphelper = require "navigator.lspwrapper"
local cwd = vim.fn.getcwd(0)
local cwd = vim.loop.cwd()
local M = {}
--- navigator signature

@ -144,7 +144,7 @@ M.document_symbol_handler = mk_handler(function(err, result, ctx)
-- for i, item in pairs(action.items) do
-- data[i] = item.text
-- if filename ~= item.filename then
-- local cwd = vim.fn.getcwd(0) .. "/"
-- local cwd = vim.loop.cwd() .. "/"
-- local add = util.get_relative_path(cwd, item.filename)
-- data[i] = data[i] .. " - " .. add
-- end
@ -193,7 +193,7 @@ M.workspace_symbol_handler = mk_handler(function(err, result, ctx, cfg)
-- for i, item in pairs(action.items) do
-- data[i] = item.text
-- if filename ~= item.filename then
-- local cwd = vim.fn.getcwd(0) .. "/"
-- local cwd = vim.loop.cwd() .. "/"
-- local add = util.get_relative_path(cwd, item.filename)
-- data[i] = data[i] .. " - " .. add
-- end

@ -18,7 +18,7 @@ local api = vim.api
local util = require "navigator.util"
local M = {}
local cwd = vim.fn.getcwd(0)
local cwd = vim.loop.cwd()
local log = require"navigator.util".log
local lerr = require"navigator.util".error
local trace = require"navigator.util".trace

@ -50,7 +50,7 @@ describe("should run lsp reference", function()
vim.fn.setpos(".", {bufn, 15, 4, 0}) -- width
vim.bo.filetype = "go"
vim.lsp.buf.references()
-- vim.lsp.buf.references()
eq(1, 1)
end)
it("reference handler should return items", function()
@ -63,7 +63,7 @@ describe("should run lsp reference", function()
print(path)
local cmd = " silent exe 'e " .. path .. "'"
vim.cmd(cmd)
vim.cmd([[cd %:p:h]])
-- vim.cmd([[cd %:p:h]])
local bufn = vim.fn.bufnr("")
vim.fn.setpos(".", {bufn, 15, 4, 0}) -- width
@ -125,7 +125,7 @@ describe("should run lsp reference", function()
local win, items, width
if nvim_6 then
win, items, width = require('navigator.reference').reference_handler(nil, result, {
win, items, width = require('navigator.reference').ref_view(nil, result, {
method = 'textDocument/references',
bufnr = 1,
client_id = 1

Loading…
Cancel
Save