Skip to content
This repository has been archived by the owner on Jul 21, 2024. It is now read-only.

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
glepnir committed Oct 23, 2023
1 parent d86a920 commit fb5c15c
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions lua/epo/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ local function completion_request(client, bufnr, trigger_kind, trigger_char)
client.request(ms.textDocument_completion, params, completion_handler, bufnr)
end

local function signature_help(client, bufnr)
local function signature_help(client, bufnr, lnum)
local params = util.make_position_params()
local fwin, fbuf
client.request(ms.textDocument_signatureHelp, params, function(err, result, ctx)
Expand Down Expand Up @@ -219,13 +219,14 @@ local function signature_help(client, bufnr)
end,
})

api.nvim_create_autocmd('InsertLeave', {
api.nvim_create_autocmd({ 'CursorMovedI', 'CursorMoved' }, {
buffer = ctx.bufnr,
group = g,
callback = function()
if api.nvim_win_is_valid(fwin) then
local curline = api.nvim_win_get_cursor(0)[1]
if curline ~= lnum and api.nvim_win_is_valid(fwin) then
api.nvim_win_close(fwin, true)
fwin = nil
api.nvim_del_augroup_by_id(g)
end
end,
})
Expand Down Expand Up @@ -253,11 +254,13 @@ local function complete_ondone(bufnr)
return
end
local completion_item = vim.tbl_get(item, 'user_data', 'nvim', 'lsp', 'completion_item')
if not completion_item then
return
end
local insertText = vim.tbl_get(completion_item, 'insertText')
local insertTextFormat = vim.tbl_get(completion_item, 'insertTextFormat')
if
completion_item
and insertText
insertText
and insertTextFormat == lsp.protocol.InsertTextFormat.Snippet
and vim.snippet
then
Expand All @@ -272,18 +275,16 @@ local function complete_ondone(bufnr)
if not clients or #clients == 0 then
return
end

local line = api.nvim_get_current_line()
local col = vfn.charcol('.')
local char = line:sub(col - 1, col - 1)

if
vim.tbl_contains(
clients[1].server_capabilities.signatureHelpProvider.triggerCharacters,
char
)
then
signature_help(clients[1], args.buf)
signature_help(clients[1], args.buf, api.nvim_win_get_cursor(0)[1])
end
end

Expand Down

0 comments on commit fb5c15c

Please sign in to comment.