From 569e75799d7015b15631c80cee1feec561f29df7 Mon Sep 17 00:00:00 2001 From: Raphael Date: Fri, 18 Sep 2020 21:37:53 +0800 Subject: lsp: remove popup No signature available. (#12915) * lsp: remove popup No signature available. If no signatures. we shouldn't popup No signature available ..It will make noise when use ` api.nvim_command("autocmd CompleteDone lua vim.lsp.buf.signature_help()")` * fix ci test failed remove whitespace * print message when no signature help * Add comment --- runtime/lua/vim/lsp/callbacks.lua | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/runtime/lua/vim/lsp/callbacks.lua b/runtime/lua/vim/lsp/callbacks.lua index 0ee03e6a2f..4e7a8333a0 100644 --- a/runtime/lua/vim/lsp/callbacks.lua +++ b/runtime/lua/vim/lsp/callbacks.lua @@ -229,16 +229,19 @@ M['textDocument/implementation'] = location_callback --@see https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_signatureHelp M['textDocument/signatureHelp'] = function(_, method, result) + -- When use `autocmd CompleteDone lua vim.lsp.buf.signature_help()` to call signatureHelp callback + -- If the completion item doesn't have signatures It will make noise. Change to use `print` that can use `` to ignore + if not (result and result.signatures and result.signatures[1]) then + print('No signature help available') + return + end + local lines = util.convert_signature_help_to_markdown_lines(result) + lines = util.trim_empty_lines(lines) + if vim.tbl_isempty(lines) then + print('No signature help available') + return + end util.focusable_preview(method, function() - if not (result and result.signatures and result.signatures[1]) then - return { 'No signature available' } - end - -- TODO show popup when signatures is empty? - local lines = util.convert_signature_help_to_markdown_lines(result) - lines = util.trim_empty_lines(lines) - if vim.tbl_isempty(lines) then - return { 'No signature available' } - end return lines, util.try_trim_markdown_code_blocks(lines) end) end -- cgit