add floating windows edit option

pull/15/head
ray-x 3 years ago
parent 53f384ba46
commit 807f41975e

@ -99,7 +99,11 @@ M.show_diagnostic = function()
end
-- log(display_items)
if #display_items > 0 then
gui.new_list_view({items = display_items, api = "🚑🐛 Diagnostic "})
gui.new_list_view({
items = display_items,
api = "🚑🐛 Diagnostic ",
enable_preview_edit = true
})
end
end
end

@ -9,8 +9,8 @@ local api = vim.api
local top_center = require"guihua.location".top_center
function M._preview_location(opts) -- location, width, pos_x, pos_y
local uri = opts.location.uri
if opts.uri == nil then
local uri = opts.uri
if uri == nil then
log("invalid/nil uri ")
return
end
@ -54,7 +54,7 @@ function M._preview_location(opts) -- location, width, pos_x, pos_y
range = opts.range,
display_range = display_range,
uri = uri,
allow_edit = true
allow_edit = opts.enable_edit
}
-- win_opts.items = contents
win_opts.hl_line = opts.lnum - display_range.start.line
@ -62,6 +62,7 @@ function M._preview_location(opts) -- location, width, pos_x, pos_y
win_opts.hl_line = 1
end
trace(opts.lnum, opts.range.start.line, win_opts.hl_line)
log(win_opts)
local w = TextView:new({
loc = "offset_center",
rect = {
@ -78,8 +79,10 @@ function M._preview_location(opts) -- location, width, pos_x, pos_y
syntax = win_opts.syntax,
enter = win_opts.enter or false,
range = win_opts.range,
border = opts.border,
display_range = win_opts.display_range,
hl_line = win_opts.hl_line
hl_line = win_opts.hl_line,
allow_edit = win_opts.allow_edit
})
return w
end
@ -184,6 +187,7 @@ function M.new_list_view(opts)
ft = opts.ft or 'guihua',
-- data = display_data,
data = data,
border = border,
on_confirm = opts.on_confirm or function(pos)
if pos == 0 then
pos = 1
@ -217,7 +221,8 @@ function M.new_list_view(opts)
range = l.range,
offset_x = 0,
offset_y = offset_y,
border = border
border = border,
enable_edit = opts.enable_preview_edit or false
})
end
})

@ -16,15 +16,19 @@ local function location_handler(err, _, locations, _, bufnr, error_message)
end
local function implementation_handler(bang, err, method, result, client_id, bufnr)
local results = location_handler(err, method, result, client_id, bufnr, "Implementation not found")
local results =
location_handler(err, method, result, client_id, bufnr, "Implementation not found")
local ft = vim.api.nvim_buf_get_option(bufnr, "ft")
gui.new_list_view({items = results, ft = ft, api = 'Implementation'})
end
function M.implementation(bang, opts)
if not lsphelper.check_capabilities("implementation") then return end
if not lsphelper.check_capabilities("implementation") then
return
end
local params = vim.lsp.util.make_position_params()
log("impel params", params)
util.call_sync("textDocument/implementation", params, opts, partial(implementation_handler, bang))
end

@ -16,6 +16,16 @@ local key_maps = {
{key = "gr", func = "references()"}, {mode = "i", key = "<M-k>", func = "signature_help()"},
{key = "gs", func = "signature_help()"}, {key = "g0", func = "document_symbol()"},
{key = "gW", func = "workspace_symbol()"}, {key = "<c-]>", func = "definition()"},
{key = "gs", func = "signature_help()"}, {key = "g0", func = "document_symbol()"},
{key = "gW", func = "workspace_symbol()"}, {key = "<c-]>", func = "definition()"},
{key = "gD", func = "declaration({ popup_opts = { border = 'single' }})"},
{key = "gp", func = "require('navigator.definition').definition_preview()"},
{key = "gT", func = "require('navigator.treesitter').buf_ts()"},
{key = "GT", func = "require('navigator.treesitter').bufs_ts()"},
{key = "gs", func = "signature_help()"}, {key = "g0", func = "document_symbol()"},
{key = "gW", func = "workspace_symbol()"}, {key = "<c-]>", func = "definition()"},
{key = "gs", func = "signature_help()"}, {key = "g0", func = "document_symbol()"},
{key = "gW", func = "workspace_symbol()"}, {key = "<c-]>", func = "definition()"},
{key = "gD", func = "declaration({ popup_opts = { border = 'single' }})"},
{key = "gp", func = "require('navigator.definition').definition_preview()"},
{key = "gT", func = "require('navigator.treesitter').buf_ts()"},

@ -1,4 +1,18 @@
parameter
{
position = {
character = 6,
line = 13
},
textDocument = {
uri = "file:///Users/ray.xu/lsp_test/go/interface.go"
}
}
--[[ -- incomming/outgoing
dir from result { {
from = {
detail = "command-line-arguments • interface.go",

@ -40,7 +40,13 @@ local function ref_hdlr(err, api, locations, num, bufnr)
local wwidth = vim.api.nvim_get_option("columns")
width = math.min(width + 30, 120, math.floor(wwidth * 0.8))
gui.new_list_view({items = items, ft = ft, width = width, api = "Reference"})
gui.new_list_view({
items = items,
ft = ft,
width = width,
api = "Reference",
enable_preview_edit = true
})
end
local async_reference_request = function()

Loading…
Cancel
Save