From fd7aa6768a6c341edc1fe768c13899a3d92d8b1d Mon Sep 17 00:00:00 2001 From: Michael Lingelbach Date: Tue, 27 Oct 2020 19:39:24 -0700 Subject: lsp: Fix case where active_signature == vim.NIL (#13114) --- runtime/lua/vim/lsp/util.lua | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'runtime/lua/vim/lsp/util.lua') diff --git a/runtime/lua/vim/lsp/util.lua b/runtime/lua/vim/lsp/util.lua index b5f171a985..775932c7fd 100644 --- a/runtime/lua/vim/lsp/util.lua +++ b/runtime/lua/vim/lsp/util.lua @@ -492,7 +492,10 @@ function M.convert_signature_help_to_markdown_lines(signature_help) --=== 0`. Whenever possible implementors should make an active decision about --the active signature and shouldn't rely on a default value. local contents = {} - local active_signature = signature_help.activeSignature or 0 + local active_signature = signature_help.activeSignature + if active_signature == vim.NIL or active_signature == nil then + active_signature = 0 + end -- If the activeSignature is not inside the valid range, then clip it. if active_signature >= #signature_help.signatures then active_signature = 0 -- cgit From dc14b1468afeb53c9ca0a734a2035cc54b5e1d94 Mon Sep 17 00:00:00 2001 From: TJ DeVries Date: Mon, 2 Nov 2020 08:50:44 -0500 Subject: lsp: remove vim.NIL from processing (#13174) * lsp: remove vim.NIL from processing * lsp: remove instances of vim.NIL --- runtime/lua/vim/lsp/util.lua | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'runtime/lua/vim/lsp/util.lua') diff --git a/runtime/lua/vim/lsp/util.lua b/runtime/lua/vim/lsp/util.lua index 775932c7fd..9ed19b938d 100644 --- a/runtime/lua/vim/lsp/util.lua +++ b/runtime/lua/vim/lsp/util.lua @@ -214,13 +214,16 @@ end function M.apply_text_document_edit(text_document_edit) local text_document = text_document_edit.textDocument local bufnr = vim.uri_to_bufnr(text_document.uri) - if text_document.version then - -- `VersionedTextDocumentIdentifier`s version may be null https://microsoft.github.io/language-server-protocol/specification#versionedTextDocumentIdentifier - if text_document.version ~= vim.NIL and M.buf_versions[bufnr] ~= nil and M.buf_versions[bufnr] > text_document.version then - print("Buffer ", text_document.uri, " newer than edits.") - return - end + + -- `VersionedTextDocumentIdentifier`s version may be null + -- https://microsoft.github.io/language-server-protocol/specification#versionedTextDocumentIdentifier + if text_document.version + and M.buf_versions[bufnr] + and M.buf_versions[bufnr] > text_document.version then + print("Buffer ", text_document.uri, " newer than edits.") + return end + M.apply_text_edits(text_document_edit.edits, bufnr) end @@ -492,10 +495,7 @@ function M.convert_signature_help_to_markdown_lines(signature_help) --=== 0`. Whenever possible implementors should make an active decision about --the active signature and shouldn't rely on a default value. local contents = {} - local active_signature = signature_help.activeSignature - if active_signature == vim.NIL or active_signature == nil then - active_signature = 0 - end + local active_signature = signature_help.activeSignature or 0 -- If the activeSignature is not inside the valid range, then clip it. if active_signature >= #signature_help.signatures then active_signature = 0 @@ -535,7 +535,7 @@ function M.convert_signature_help_to_markdown_lines(signature_help) } --]=] -- TODO highlight parameter - if parameter.documentation and parameter.documentation ~= vim.NIL then + if parameter.documentation then M.convert_input_to_markdown_lines(parameter.documentation, contents) end end -- cgit