From: Yegappan Lakshmanan Date: Tue, 11 Jan 2022 15:20:13 +0000 (-0800) Subject: Not able to use one exported function from another exported function in an autoloaded... X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=85417435fafc78c09d5a445690afe87210b3b7d7;p=vim-lsp.git Not able to use one exported function from another exported function in an autoloaded script --- diff --git a/autoload/diag.vim b/autoload/diag.vim index d870422..687c486 100644 --- a/autoload/diag.vim +++ b/autoload/diag.vim @@ -10,6 +10,7 @@ if has('patch-8.2.4019') opt.lspOptions = opt_import.lspOptions util.WarnMsg = util_import.WarnMsg util.GetLineByteFromPos = util_import.GetLineByteFromPos + util.LspUriToFile = util_import.LspUriToFile else import lspOptions from './lspoptions.vim' import {WarnMsg, @@ -40,7 +41,7 @@ enddef # New LSP diagnostic messages received from the server for a file. # Update the signs placed in the buffer for this file -export def UpdateDiags(lspserver: dict, bnr: number) +def ProcessNewDiags(lspserver: dict, bnr: number) if !opt.lspOptions.autoHighlightDiags return endif @@ -74,6 +75,14 @@ export def UpdateDiags(lspserver: dict, bnr: number) signs->sign_placelist() enddef +# FIXME: Remove this function once the Vim bug (calling one exported function +# from another exported function in an autoload script is not working) is +# fixed. Replace the calls to this function directly with calls to +# ProcessNewDiags(). +export def UpdateDiags(lspserver: dict, bnr: number) + ProcessNewDiags(lspserver, bnr) +enddef + # process a diagnostic notification message from the LSP server # Notification: textDocument/publishDiagnostics # Param: PublishDiagnosticsParams @@ -101,7 +110,7 @@ export def DiagNotification(lspserver: dict, uri: string, diags: listextend({['' .. bnr]: diag_by_lnum}) - UpdateDiags(lspserver, bnr) + ProcessNewDiags(lspserver, bnr) enddef # get the count of error in the current buffer diff --git a/autoload/util.vim b/autoload/util.vim index bed2f38..e815e22 100644 --- a/autoload/util.vim +++ b/autoload/util.vim @@ -70,7 +70,7 @@ export def LspUriToFile(uri: string): string enddef # Convert a Vim filename to an LSP URI (file://) -export def LspFileToUri(fname: string): string +def ConvertFilenameToUri(fname: string): string var uri: string = fnamemodify(fname, ':p') var on_windows: bool = false @@ -95,9 +95,17 @@ export def LspFileToUri(fname: string): string return uri enddef +# FIXME: Remove this function once the Vim bug (calling one exported function +# from another exported function in an autoload script is not working) is +# fixed. Replace the calls to this function directly with calls to +# ConvertFilenameToUri(). +export def LspFileToUri(fname: string): string + return ConvertFilenameToUri(fname) +enddef + # Convert a Vim buffer number to an LSP URI (file://) export def LspBufnrToUri(bnr: number): string - return LspFileToUri(bnr->bufname()) + return ConvertFilenameToUri(bnr->bufname()) enddef # Returns the byte number of the specified LSP position in buffer 'bnr'.