util.GetLineByteFromPos = GetLineByteFromPos
endif
-def s:CreateLoclistWithCalls(calls: list<dict<any>>, incoming: bool)
+def CreateLoclistWithCalls(calls: list<dict<any>>, incoming: bool)
var qflist: list<dict<any>> = []
for item in calls
endif
enddef
-def s:DiagSevToSignName(severity: number): string
+def DiagSevToSignName(severity: number): string
var typeMap: list<string> = ['LspDiagError', 'LspDiagWarning',
'LspDiagInfo', 'LspDiagHint']
if severity > 4
enddef
# Map the LSP DiagnosticSeverity to a quickfix type character
-def s:DiagSevToQfType(severity: number): string
+def DiagSevToQfType(severity: number): string
var typeMap: list<string> = ['E', 'W', 'I', 'N']
if severity > 4
enddef
# sort the diaganostics messages for a buffer by line number
-def s:GetSortedDiagLines(lspsrv: dict<any>, bnr: number): list<number>
+def GetSortedDiagLines(lspsrv: dict<any>, bnr: number): list<number>
# create a list of line numbers from the diag map keys
var lnums: list<number> =
lspsrv.diagsMap[bnr]->keys()->mapnew((_, v) => v->str2nr())
# process the 'initialize' method reply from the LSP server
# Result: InitializeResult
-def s:ProcessInitializeReply(lspserver: dict<any>, req: dict<any>, reply: dict<any>): void
+def ProcessInitializeReply(lspserver: dict<any>, req: dict<any>, reply: dict<any>): void
if reply.result->len() <= 0
return
endif
# 'textDocument/typeDefinition' and 'textDocument/implementation' replies from
# the LSP server
# Result: Location | Location[] | LocationLink[] | null
-def s:ProcessDefDeclReply(lspserver: dict<any>, req: dict<any>, reply: dict<any>): void
+def ProcessDefDeclReply(lspserver: dict<any>, req: dict<any>, reply: dict<any>): void
var location: dict<any>
if reply.result->type() == v:t_list
if !reply.result->empty()
# process the 'textDocument/signatureHelp' reply from the LSP server
# Result: SignatureHelp | null
-def s:ProcessSignaturehelpReply(lspserver: dict<any>, req: dict<any>, reply: dict<any>): void
+def ProcessSignaturehelpReply(lspserver: dict<any>, req: dict<any>, reply: dict<any>): void
signature.SignatureDisplay(lspserver, reply.result)
enddef
# process the 'textDocument/completion' reply from the LSP server
# Result: CompletionItem[] | CompletionList | null
-def s:ProcessCompletionReply(lspserver: dict<any>, req: dict<any>, reply: dict<any>): void
+def ProcessCompletionReply(lspserver: dict<any>, req: dict<any>, reply: dict<any>): void
if reply.result->empty()
return
endif
# process the 'textDocument/hover' reply from the LSP server
# Result: Hover | null
-def s:ProcessHoverReply(lspserver: dict<any>, req: dict<any>, reply: dict<any>): void
+def ProcessHoverReply(lspserver: dict<any>, req: dict<any>, reply: dict<any>): void
if reply.result->empty()
return
endif
# process the 'textDocument/references' reply from the LSP server
# Result: Location[] | null
-def s:ProcessReferencesReply(lspserver: dict<any>, req: dict<any>, reply: dict<any>): void
+def ProcessReferencesReply(lspserver: dict<any>, req: dict<any>, reply: dict<any>): void
symbol.ShowReferences(lspserver, reply.result)
enddef
# process the 'textDocument/documentHighlight' reply from the LSP server
# Result: DocumentHighlight[] | null
-def s:ProcessDocHighlightReply(lspserver: dict<any>, req: dict<any>, reply: dict<any>): void
+def ProcessDocHighlightReply(lspserver: dict<any>, req: dict<any>, reply: dict<any>): void
if reply.result->empty()
return
endif
enddef
# process SymbolInformation[]
-def s:ProcessSymbolInfoTable(symbolInfoTable: list<dict<any>>,
+def ProcessSymbolInfoTable(symbolInfoTable: list<dict<any>>,
symbolTypeTable: dict<list<dict<any>>>,
symbolLineTable: list<dict<any>>)
var fname: string
enddef
# process DocumentSymbol[]
-def s:ProcessDocSymbolTable(docSymbolTable: list<dict<any>>,
+def ProcessDocSymbolTable(docSymbolTable: list<dict<any>>,
symbolTypeTable: dict<list<dict<any>>>,
symbolLineTable: list<dict<any>>)
var symbolType: string
# process the 'textDocument/documentSymbol' reply from the LSP server
# Open a symbols window and display the symbols as a tree
# Result: DocumentSymbol[] | SymbolInformation[] | null
-def s:ProcessDocSymbolReply(lspserver: dict<any>, req: dict<any>, reply: dict<any>): void
+def ProcessDocSymbolReply(lspserver: dict<any>, req: dict<any>, reply: dict<any>): void
var fname: string
var symbolTypeTable: dict<list<dict<any>>> = {}
var symbolLineTable: list<dict<any>> = []
# process the 'textDocument/formatting' reply from the LSP server
# Result: TextEdit[] | null
-def s:ProcessFormatReply(lspserver: dict<any>, req: dict<any>, reply: dict<any>)
+def ProcessFormatReply(lspserver: dict<any>, req: dict<any>, reply: dict<any>)
if reply.result->empty()
# nothing to format
return
# Reply: 'textDocument/rename'
# Result: Range | { range: Range, placeholder: string }
# | { defaultBehavior: boolean } | null
-def s:ProcessRenameReply(lspserver: dict<any>, req: dict<any>, reply: dict<any>)
+def ProcessRenameReply(lspserver: dict<any>, req: dict<any>, reply: dict<any>)
if reply.result->empty()
# nothing to rename
return
# process the 'textDocument/codeAction' reply from the LSP server
# Result: (Command | CodeAction)[] | null
-def s:ProcessCodeActionReply(lspserver: dict<any>, req: dict<any>, reply: dict<any>)
+def ProcessCodeActionReply(lspserver: dict<any>, req: dict<any>, reply: dict<any>)
codeaction.ApplyCodeAction(lspserver, reply.result)
enddef
# Reply: 'textDocument/selectionRange'
# Result: SelectionRange[] | null
-def s:ProcessSelectionRangeReply(lspserver: dict<any>, req: dict<any>, reply: dict<any>)
+def ProcessSelectionRangeReply(lspserver: dict<any>, req: dict<any>, reply: dict<any>)
selection.SelectionStart(lspserver, reply.result)
enddef
# Reply: 'textDocument/foldingRange'
# Result: FoldingRange[] | null
-def s:ProcessFoldingRangeReply(lspserver: dict<any>, req: dict<any>, reply: dict<any>)
+def ProcessFoldingRangeReply(lspserver: dict<any>, req: dict<any>, reply: dict<any>)
if reply.result->empty()
return
endif
# process the 'workspace/executeCommand' reply from the LSP server
# Result: any | null
-def s:ProcessWorkspaceExecuteReply(lspserver: dict<any>, req: dict<any>, reply: dict<any>)
+def ProcessWorkspaceExecuteReply(lspserver: dict<any>, req: dict<any>, reply: dict<any>)
if reply.result->empty()
return
endif
# Convert a file name <filename> (<dirname>) format.
# Make sure the popup does't occupy the entire screen by reducing the width.
-def s:MakeMenuName(popupWidth: number, fname: string): string
+def MakeMenuName(popupWidth: number, fname: string): string
var filename: string = fname->fnamemodify(':t')
var flen: number = filename->len()
var dirname: string = fname->fnamemodify(':h')
# process the 'workspace/symbol' reply from the LSP server
# Result: SymbolInformation[] | null
-def s:ProcessWorkspaceSymbolReply(lspserver: dict<any>, req: dict<any>, reply: dict<any>)
+def ProcessWorkspaceSymbolReply(lspserver: dict<any>, req: dict<any>, reply: dict<any>)
var symbols: list<dict<any>> = []
var symbolType: string
var fileName: string
# process the 'textDocument/prepareCallHierarchy' reply from the LSP server
# Result: CallHierarchyItem[] | null
-def s:ProcessPrepareCallHierarchy(lspserver: dict<any>, req: dict<any>, reply: dict<any>)
+def ProcessPrepareCallHierarchy(lspserver: dict<any>, req: dict<any>, reply: dict<any>)
if reply.result->empty()
if lspserver.callHierarchyType == 'incoming'
util.WarnMsg('No incoming calls')
# process the 'callHierarchy/incomingCalls' reply from the LSP server
# Result: CallHierarchyIncomingCall[] | null
-def s:ProcessIncomingCalls(lspserver: dict<any>, req: dict<any>, reply: dict<any>)
+def ProcessIncomingCalls(lspserver: dict<any>, req: dict<any>, reply: dict<any>)
callhier.IncomingCalls(reply.result)
enddef
# process the 'callHierarchy/outgoingCalls' reply from the LSP server
# Result: CallHierarchyOutgoingCall[] | null
-def s:ProcessOutgoingCalls(lspserver: dict<any>, req: dict<any>, reply: dict<any>)
+def ProcessOutgoingCalls(lspserver: dict<any>, req: dict<any>, reply: dict<any>)
callhier.OutgoingCalls(reply.result)
enddef
# process a diagnostic notification message from the LSP server
# Notification: textDocument/publishDiagnostics
# Param: PublishDiagnosticsParams
-def s:ProcessDiagNotif(lspserver: dict<any>, reply: dict<any>): void
+def ProcessDiagNotif(lspserver: dict<any>, reply: dict<any>): void
diag.DiagNotification(lspserver, reply.params.uri, reply.params.diagnostics)
enddef
# process a show notification message from the LSP server
# Notification: window/showMessage
# Param: ShowMessageParams
-def s:ProcessShowMsgNotif(lspserver: dict<any>, reply: dict<any>)
+def ProcessShowMsgNotif(lspserver: dict<any>, reply: dict<any>)
var msgType: list<string> = ['', 'Error: ', 'Warning: ', 'Info: ', 'Log: ']
if reply.params.type == 4
# ignore log messages from the LSP server (too chatty)
# process a log notification message from the LSP server
# Notification: window/logMessage
# Param: LogMessageParams
-def s:ProcessLogMsgNotif(lspserver: dict<any>, reply: dict<any>)
+def ProcessLogMsgNotif(lspserver: dict<any>, reply: dict<any>)
var msgType: list<string> = ['', 'Error: ', 'Warning: ', 'Info: ', 'Log: ']
var mtype: string = 'Log: '
if reply.params.type > 0 && reply.params.type < 5
enddef
# process unsupported notification messages
-def s:ProcessUnsupportedNotif(lspserver: dict<any>, reply: dict<any>)
+def ProcessUnsupportedNotif(lspserver: dict<any>, reply: dict<any>)
util.ErrMsg('Error: Unsupported notification message received from the LSP server (' .. lspserver.path .. '), message = ' .. reply->string())
enddef
# ignore unsupported notification message
-def s:IgnoreNotif(lspserver: dict<any>, reply: dict<any>)
+def IgnoreNotif(lspserver: dict<any>, reply: dict<any>)
enddef
# process notification messages from the LSP server
# process the workspace/applyEdit LSP server request
# Request: "workspace/applyEdit"
# Param: ApplyWorkspaceEditParams
-def s:ProcessApplyEditReq(lspserver: dict<any>, request: dict<any>)
+def ProcessApplyEditReq(lspserver: dict<any>, request: dict<any>)
# interface ApplyWorkspaceEditParams
if !request->has_key('params')
return
lspserver.sendResponse(request, {applied: true}, {})
enddef
-def s:ProcessUnsupportedReq(lspserver: dict<any>, request: dict<any>)
+def ProcessUnsupportedReq(lspserver: dict<any>, request: dict<any>)
util.ErrMsg('Error: Unsupported request message received from the LSP server (' .. lspserver.path .. '), message = ' .. request->string())
enddef
var lspInitializedOnce = false
-def s:LspInitOnce()
+def LspInitOnce()
# Signs used for LSP diagnostics
sign_define([{name: 'LspDiagError', text: 'E ', texthl: 'ErrorMsg',
linehl: 'MatchParen'},
# Returns the LSP server for the a specific filetype. Returns an empty dict if
# the server is not found.
-def s:LspGetServer(ftype: string): dict<any>
+def LspGetServer(ftype: string): dict<any>
return ftypeServerMap->get(ftype, {})
enddef
# Returns the LSP server for the current buffer if it is running and is ready.
# Returns an empty dict if the server is not found or is not ready.
-def s:CurbufGetServerChecked(): dict<any>
+def CurbufGetServerChecked(): dict<any>
var fname: string = @%
if fname == ''
return {}
enddef
# Add a LSP server for a filetype
-def s:LspAddServer(ftype: string, lspsrv: dict<any>)
+def LspAddServer(ftype: string, lspsrv: dict<any>)
ftypeServerMap->extend({[ftype]: lspsrv})
enddef
# Returns true if omni-completion is enabled for filetype 'ftype'.
# Otherwise, returns false.
-def s:LspOmniComplEnabled(ftype: string): bool
+def LspOmniComplEnabled(ftype: string): bool
return ftypeOmniCtrlMap->get(ftype, v:false)
enddef
# Enables or disables omni-completion for filetype 'fype'
-def s:LspOmniComplSet(ftype: string, enabled: bool)
+def LspOmniComplSet(ftype: string, enabled: bool)
ftypeOmniCtrlMap->extend({[ftype]: enabled})
enddef
enddef
# buffer change notification listener
-def s:Bufchange_listener(bnr: number, start: number, end: number, added: number, changes: list<dict<number>>)
+def Bufchange_listener(bnr: number, start: number, end: number, added: number, changes: list<dict<number>>)
var lspserver: dict<any> = buf.CurbufGetServer()
if lspserver->empty() || !lspserver.running
return
enddef
# A buffer is saved. Send the "textDocument/didSave" LSP notification
-def s:LspSavedFile()
+def LspSavedFile()
var bnr: number = expand('<abuf>')->str2nr()
var lspserver: dict<any> = buf.BufLspServerGet(bnr)
if lspserver->empty() || !lspserver.running
endif
# LSP server standard output handler
-def s:Output_cb(lspserver: dict<any>, chan: channel, msg: string): void
+def Output_cb(lspserver: dict<any>, chan: channel, msg: string): void
util.TraceLog(false, msg)
lspserver.data = lspserver.data .. msg
lspserver.processMessages()
enddef
# LSP server error output handler
-def s:Error_cb(lspserver: dict<any>, chan: channel, emsg: string,): void
+def Error_cb(lspserver: dict<any>, chan: channel, emsg: string,): void
util.TraceLog(true, emsg)
enddef
# LSP server exit callback
-def s:Exit_cb(lspserver: dict<any>, job: job, status: number): void
+def Exit_cb(lspserver: dict<any>, job: job, status: number): void
util.WarnMsg("LSP server exited with status " .. status)
lspserver.job = v:null
lspserver.running = false
enddef
# Start a LSP server
-def s:StartServer(lspserver: dict<any>): number
+def StartServer(lspserver: dict<any>): number
if lspserver.running
util.WarnMsg("LSP server for is already running")
return 0
# Request: 'initialize'
# Param: InitializeParams
-def s:InitServer(lspserver: dict<any>)
+def InitServer(lspserver: dict<any>)
var req = lspserver.createRequest('initialize')
# client capabilities (ClientCapabilities)
# Send a "initialized" LSP notification
# Params: InitializedParams
-def s:SendInitializedNotif(lspserver: dict<any>)
+def SendInitializedNotif(lspserver: dict<any>)
var notif: dict<any> = lspserver.createNotification('initialized')
lspserver.sendMessage(notif)
enddef
# Request: shutdown
# Param: void
-def s:ShutdownServer(lspserver: dict<any>): void
+def ShutdownServer(lspserver: dict<any>): void
var req = lspserver.createRequest('shutdown')
lspserver.sendMessage(req)
enddef
# Send a 'exit' notification to the LSP server
# Params: void
-def s:ExitServer(lspserver: dict<any>): void
+def ExitServer(lspserver: dict<any>): void
var notif: dict<any> = lspserver.createNotification('exit')
lspserver.sendMessage(notif)
enddef
# Stop a LSP server
-def s:StopServer(lspserver: dict<any>): number
+def StopServer(lspserver: dict<any>): number
if !lspserver.running
util.WarnMsg("LSP server is not running")
return 0
enddef
# set the LSP server trace level using $/setTrace notification
-def s:SetTrace(lspserver: dict<any>, traceVal: string)
+def SetTrace(lspserver: dict<any>, traceVal: string)
var notif: dict<any> = lspserver.createNotification('$/setTrace')
notif.params->extend({value: traceVal})
lspserver.sendMessage(notif)
enddef
# Return the next id for a LSP server request message
-def s:NextReqID(lspserver: dict<any>): number
+def NextReqID(lspserver: dict<any>): number
var id = lspserver.nextID
lspserver.nextID = id + 1
return id
enddef
# create a LSP server request message
-def s:CreateRequest(lspserver: dict<any>, method: string): dict<any>
+def CreateRequest(lspserver: dict<any>, method: string): dict<any>
var req = {}
req.jsonrpc = '2.0'
req.id = lspserver.nextReqID()
enddef
# create a LSP server response message
-def s:CreateResponse(lspserver: dict<any>, req_id: number): dict<any>
+def CreateResponse(lspserver: dict<any>, req_id: number): dict<any>
var resp = {}
resp.jsonrpc = '2.0'
resp.id = req_id
enddef
# create a LSP server notification message
-def s:CreateNotification(lspserver: dict<any>, notif: string): dict<any>
+def CreateNotification(lspserver: dict<any>, notif: string): dict<any>
var req = {}
req.jsonrpc = '2.0'
req.method = notif
enddef
# send a response message to the server
-def s:SendResponse(lspserver: dict<any>, request: dict<any>, result: dict<any>, error: dict<any>)
+def SendResponse(lspserver: dict<any>, request: dict<any>, result: dict<any>, error: dict<any>)
var resp: dict<any> = lspserver.createResponse(request.id)
if result->type() != v:t_none
resp->extend({result: result})
enddef
# Send a request message to LSP server
-def s:SendMessage(lspserver: dict<any>, content: dict<any>): void
+def SendMessage(lspserver: dict<any>, content: dict<any>): void
var payload_js: string = content->json_encode()
var msg = "Content-Length: " .. payload_js->len() .. "\r\n\r\n"
var ch = lspserver.job->job_getchannel()
# Wait for a response message from the LSP server for the request "req"
# Waits for a maximum of 5 seconds
-def s:WaitForReponse(lspserver: dict<any>, req: dict<any>)
+def WaitForReponse(lspserver: dict<any>, req: dict<any>)
var maxCount: number = 2500
var key: string = req.id->string()
# Send a LSP "textDocument/didOpen" notification
# Params: DidOpenTextDocumentParams
-def s:TextdocDidOpen(lspserver: dict<any>, bnr: number, ftype: string): void
+def TextdocDidOpen(lspserver: dict<any>, bnr: number, ftype: string): void
var notif: dict<any> = lspserver.createNotification('textDocument/didOpen')
# interface DidOpenTextDocumentParams
enddef
# Send a LSP "textDocument/didClose" notification
-def s:TextdocDidClose(lspserver: dict<any>, bnr: number): void
+def TextdocDidClose(lspserver: dict<any>, bnr: number): void
var notif: dict<any> = lspserver.createNotification('textDocument/didClose')
# interface DidCloseTextDocumentParams
# Send a LSP "textDocument/didChange" notification
# Params: DidChangeTextDocumentParams
-def s:TextdocDidChange(lspserver: dict<any>, bnr: number, start: number,
+def TextdocDidChange(lspserver: dict<any>, bnr: number, start: number,
end: number, added: number,
changes: list<dict<number>>): void
var notif: dict<any> = lspserver.createNotification('textDocument/didChange')
# LSP line and column numbers start from zero, whereas Vim line and column
# numbers start from one. The LSP column number is the character index in the
# line and not the byte index in the line.
-def s:GetLspPosition(): dict<number>
+def GetLspPosition(): dict<number>
var lnum: number = line('.') - 1
var col: number = charcol('.') - 1
return {line: lnum, character: col}
# Return the current file name and current cursor position as a LSP
# TextDocumentPositionParams structure
-def s:GetLspTextDocPosition(): dict<dict<any>>
+def GetLspTextDocPosition(): dict<dict<any>>
# interface TextDocumentIdentifier
# interface Position
return {textDocument: {uri: util.LspFileToUri(@%)},
# Get a list of completion items.
# Request: "textDocument/completion"
# Param: CompletionParams
-def s:GetCompletion(lspserver: dict<any>, triggerKind_arg: number): void
+def GetCompletion(lspserver: dict<any>, triggerKind_arg: number): void
# Check whether LSP server supports completion
if !lspserver.caps->has_key('completionProvider')
util.ErrMsg("Error: LSP server does not support completion")
# Request: "textDocument/definition"
# Param: DefinitionParams
-def s:GotoDefinition(lspserver: dict<any>, peek: bool)
+def GotoDefinition(lspserver: dict<any>, peek: bool)
# Check whether LSP server supports jumping to a definition
if !lspserver.caps->has_key('definitionProvider')
|| !lspserver.caps.definitionProvider
# Request: "textDocument/declaration"
# Param: DeclarationParams
-def s:GotoDeclaration(lspserver: dict<any>, peek: bool): void
+def GotoDeclaration(lspserver: dict<any>, peek: bool): void
# Check whether LSP server supports jumping to a declaration
if !lspserver.caps->has_key('declarationProvider')
|| !lspserver.caps.declarationProvider
# Request: "textDocument/typeDefinition"
# Param: TypeDefinitionParams
-def s:GotoTypeDef(lspserver: dict<any>, peek: bool): void
+def GotoTypeDef(lspserver: dict<any>, peek: bool): void
# Check whether LSP server supports jumping to a type definition
if !lspserver.caps->has_key('typeDefinitionProvider')
|| !lspserver.caps.typeDefinitionProvider
# Request: "textDocument/implementation"
# Param: ImplementationParams
-def s:GotoImplementation(lspserver: dict<any>, peek: bool): void
+def GotoImplementation(lspserver: dict<any>, peek: bool): void
# Check whether LSP server supports jumping to a implementation
if !lspserver.caps->has_key('implementationProvider')
|| !lspserver.caps.implementationProvider
# get symbol signature help.
# Request: "textDocument/signatureHelp"
# Param: SignatureHelpParams
-def s:ShowSignature(lspserver: dict<any>): void
+def ShowSignature(lspserver: dict<any>): void
# Check whether LSP server supports signature help
if !lspserver.caps->has_key('signatureHelpProvider')
util.ErrMsg("Error: LSP server does not support signature help")
endif
enddef
-def s:DidSaveFile(lspserver: dict<any>, bnr: number): void
+def DidSaveFile(lspserver: dict<any>, bnr: number): void
# Check whether the LSP server supports the didSave notification
if !lspserver.caps->has_key('textDocumentSync')
|| lspserver.caps.textDocumentSync->type() == v:t_number
# get the hover information
# Request: "textDocument/hover"
# Param: HoverParams
-def s:Hover(lspserver: dict<any>): void
+def Hover(lspserver: dict<any>): void
# Check whether LSP server supports getting hover information
if !lspserver.caps->has_key('hoverProvider')
|| !lspserver.caps.hoverProvider
# Request: "textDocument/references"
# Param: ReferenceParams
-def s:ShowReferences(lspserver: dict<any>, peek: bool): void
+def ShowReferences(lspserver: dict<any>, peek: bool): void
# Check whether LSP server supports getting reference information
if !lspserver.caps->has_key('referencesProvider')
|| !lspserver.caps.referencesProvider
# Request: "textDocument/documentHighlight"
# Param: DocumentHighlightParams
-def s:DocHighlight(lspserver: dict<any>): void
+def DocHighlight(lspserver: dict<any>): void
# Check whether LSP server supports getting highlight information
if !lspserver.caps->has_key('documentHighlightProvider')
|| !lspserver.caps.documentHighlightProvider
# Request: "textDocument/documentSymbol"
# Param: DocumentSymbolParams
-def s:GetDocSymbols(lspserver: dict<any>, fname: string): void
+def GetDocSymbols(lspserver: dict<any>, fname: string): void
# Check whether LSP server supports getting document symbol information
if !lspserver.caps->has_key('documentSymbolProvider')
|| !lspserver.caps.documentSymbolProvider
# or
# Request: "textDocument/rangeFormatting"
# Param: DocumentRangeFormattingParams
-def s:TextDocFormat(lspserver: dict<any>, fname: string, rangeFormat: bool,
+def TextDocFormat(lspserver: dict<any>, fname: string, rangeFormat: bool,
start_lnum: number, end_lnum: number)
# Check whether LSP server supports formatting documents
if !lspserver.caps->has_key('documentFormattingProvider')
# Request: "textDocument/prepareCallHierarchy"
# Param: CallHierarchyPrepareParams
-def s:PrepareCallHierarchy(lspserver: dict<any>, fname: string)
+def PrepareCallHierarchy(lspserver: dict<any>, fname: string)
# Check whether LSP server supports call hierarchy
if !lspserver.caps->has_key('callHierarchyProvider')
|| !lspserver.caps.callHierarchyProvider
# Request: "callHierarchy/incomingCalls"
# Param: CallHierarchyItem
-def s:IncomingCalls(lspserver: dict<any>, hierItem: dict<any>)
+def IncomingCalls(lspserver: dict<any>, hierItem: dict<any>)
# Check whether LSP server supports call hierarchy
if !lspserver.caps->has_key('callHierarchyProvider')
|| !lspserver.caps.callHierarchyProvider
# Request: "callHierarchy/outgoingCalls"
# Param: CallHierarchyItem
-def s:OutgoingCalls(lspserver: dict<any>, hierItem: dict<any>)
+def OutgoingCalls(lspserver: dict<any>, hierItem: dict<any>)
# Check whether LSP server supports call hierarchy
if !lspserver.caps->has_key('callHierarchyProvider')
|| !lspserver.caps.callHierarchyProvider
# Request: "textDocument/rename"
# Param: RenameParams
-def s:RenameSymbol(lspserver: dict<any>, newName: string)
+def RenameSymbol(lspserver: dict<any>, newName: string)
# Check whether LSP server supports rename operation
if !lspserver.caps->has_key('renameProvider')
|| !lspserver.caps.renameProvider
# Request: "textDocument/codeAction"
# Param: CodeActionParams
-def s:CodeAction(lspserver: dict<any>, fname_arg: string)
+def CodeAction(lspserver: dict<any>, fname_arg: string)
# Check whether LSP server supports code action operation
if !lspserver.caps->has_key('codeActionProvider')
|| !lspserver.caps.codeActionProvider
# List project-wide symbols matching query string
# Request: "workspace/symbol"
# Param: WorkspaceSymbolParams
-def s:WorkspaceQuerySymbols(lspserver: dict<any>, query: string): bool
+def WorkspaceQuerySymbols(lspserver: dict<any>, query: string): bool
# Check whether the LSP server supports listing workspace symbols
if !lspserver.caps->has_key('workspaceSymbolProvider')
|| !lspserver.caps.workspaceSymbolProvider
# Add a workspace folder to the LSP server.
# Request: "workspace/didChangeWorkspaceFolders"
# Param: DidChangeWorkspaceFoldersParams
-def s:AddWorkspaceFolder(lspserver: dict<any>, dirName: string): void
+def AddWorkspaceFolder(lspserver: dict<any>, dirName: string): void
if !lspserver.caps->has_key('workspace')
|| !lspserver.caps.workspace->has_key('workspaceFolders')
|| !lspserver.caps.workspace.workspaceFolders->has_key('supported')
# Remove a workspace folder from the LSP server.
# Request: "workspace/didChangeWorkspaceFolders"
# Param: DidChangeWorkspaceFoldersParams
-def s:RemoveWorkspaceFolder(lspserver: dict<any>, dirName: string): void
+def RemoveWorkspaceFolder(lspserver: dict<any>, dirName: string): void
if !lspserver.caps->has_key('workspace')
|| !lspserver.caps.workspace->has_key('workspaceFolders')
|| !lspserver.caps.workspace.workspaceFolders->has_key('supported')
# select the text around the current cursor location
# Request: "textDocument/selectionRange"
# Param: SelectionRangeParams
-def s:SelectionRange(lspserver: dict<any>, fname: string)
+def SelectionRange(lspserver: dict<any>, fname: string)
# Check whether LSP server supports selection ranges
if !lspserver.caps->has_key('selectionRangeProvider')
|| !lspserver.caps.selectionRangeProvider
enddef
# Expand the previous selection or start a new one
-def s:SelectionExpand(lspserver: dict<any>)
+def SelectionExpand(lspserver: dict<any>)
# Check whether LSP server supports selection ranges
if !lspserver.caps->has_key('selectionRangeProvider')
|| !lspserver.caps.selectionRangeProvider
enddef
# Shrink the previous selection or start a new one
-def s:SelectionShrink(lspserver: dict<any>)
+def SelectionShrink(lspserver: dict<any>)
# Check whether LSP server supports selection ranges
if !lspserver.caps->has_key('selectionRangeProvider')
|| !lspserver.caps.selectionRangeProvider
# fold the entire document
# Request: "textDocument/foldingRange"
# Param: FoldingRangeParams
-def s:FoldRange(lspserver: dict<any>, fname: string)
+def FoldRange(lspserver: dict<any>, fname: string)
# Check whether LSP server supports fold ranges
if !lspserver.caps->has_key('foldingRangeProvider')
|| !lspserver.caps.foldingRangeProvider
# Request the LSP server to execute a command
# Request: workspace/executeCommand
# Params: ExecuteCommandParams
-def s:ExecuteCommand(lspserver: dict<any>, cmd: dict<any>)
+def ExecuteCommand(lspserver: dict<any>, cmd: dict<any>)
var req = lspserver.createRequest('workspace/executeCommand')
req.params->extend(cmd)
lspserver.sendMessage(req)
# Display the LSP server capabilities (received during the initialization
# stage).
-def s:ShowCapabilities(lspserver: dict<any>)
+def ShowCapabilities(lspserver: dict<any>)
echo "Capabilities of '" .. lspserver.path .. "' LSP server:"
for k in lspserver.caps->keys()->sort()
echo k .. ": " .. lspserver.caps[k]->string()
endif
# jump to a symbol selected in the outline window
-def s:OutlineJumpToSymbol()
+def OutlineJumpToSymbol()
var lnum: number = line('.') - 1
if w:lspSymbols.lnumTable[lnum]->empty()
return
return skipRefresh
enddef
-def s:AddSymbolText(bnr: number,
+def AddSymbolText(bnr: number,
symbolTypeTable: dict<list<dict<any>>>,
pfx: string,
text: list<string>,
skipRefresh = false
enddef
-def s:OutlineHighlightCurrentSymbol()
+def OutlineHighlightCurrentSymbol()
var fname: string = expand('%')->fnamemodify(':p')
if fname == '' || &filetype == ''
return
enddef
# when the outline window is closed, do the cleanup
-def s:OutlineCleanup()
+def OutlineCleanup()
# Remove the outline autocommands
:silent! autocmd! LSPOutline
endif
# Visually (character-wise) select the text in a range
-def s:SelectText(bnr: number, range: dict<dict<number>>)
+def SelectText(bnr: number, range: dict<dict<number>>)
var start_col: number = util.GetLineByteFromPos(bnr, range.start) + 1
var end_col: number = util.GetLineByteFromPos(bnr, range.end)
enddef
# Locate the range in the LSP reply at a specified level
-def s:GetSelRangeAtLevel(selRange: dict<any>, level: number): dict<any>
+def GetSelRangeAtLevel(selRange: dict<any>, level: number): dict<any>
var r: dict<any> = selRange
var idx: number = 0
# Returns true if the current visual selection matches a range in the
# selection reply from LSP.
-def s:SelectionFromLSP(range: dict<any>, startpos: list<number>, endpos: list<number>): bool
+def SelectionFromLSP(range: dict<any>, startpos: list<number>, endpos: list<number>): bool
return startpos[1] == range.start.line + 1
&& endpos[1] == range.end.line + 1
&& startpos[2] == range.start.character + 1
endif
# close the signature popup window
-def s:CloseSignaturePopup(lspserver: dict<any>)
+def CloseSignaturePopup(lspserver: dict<any>)
lspserver.signaturePopup->popup_close()
lspserver.signaturePopup = -1
enddef
-def s:CloseCurBufSignaturePopup()
+def CloseCurBufSignaturePopup()
var lspserver: dict<any> = buf.CurbufGetServer()
if lspserver->empty()
return
endif
# Handle keys pressed when the workspace symbol popup menu is displayed
-def s:FilterSymbols(lspserver: dict<any>, popupID: number, key: string): bool
+def FilterSymbols(lspserver: dict<any>, popupID: number, key: string): bool
var key_handled: bool = false
var update_popup: bool = false
var query: string = lspserver.workspaceSymbolQuery
enddef
# Jump to the location of a symbol selected in the popup menu
-def s:JumpToWorkspaceSymbol(popupID: number, result: number): void
+def JumpToWorkspaceSymbol(popupID: number, result: number): void
# clear the message displayed at the command-line
echo ''
# numbers.
# 'a': {'A': [lnum, col], 'B': [lnum, col]}
# 'b': {'A': [lnum, col], 'B': [lnum, col]}
-def s:Edit_sort_func(a: dict<any>, b: dict<any>): number
+def Edit_sort_func(a: dict<any>, b: dict<any>): number
# line number
if a.A[0] != b.A[0]
return b.A[0] - a.A[0]
# 'new_lines' A list of strings to replace the original
#
# returns the modified 'lines'
-def s:Set_lines(lines: list<string>, A: list<number>, B: list<number>,
+def Set_lines(lines: list<string>, A: list<number>, B: list<number>,
new_lines: list<string>): list<string>
var i_0: number = A[0]
enddef
# interface TextDocumentEdit
-def s:ApplyTextDocumentEdit(textDocEdit: dict<any>)
+def ApplyTextDocumentEdit(textDocEdit: dict<any>)
var bnr: number = bufnr(util.LspUriToFile(textDocEdit.textDocument.uri))
if bnr == -1
util.ErrMsg('Error: Text Document edit, buffer ' .. textDocEdit.textDocument.uri .. ' is not found')
lspf.showDiagnostics = ShowDiagnostics
lspf.showCurrentDiag = LspShowCurrentDiag
lspf.jumpToDiag = JumpToDiag
- lspf.jumpToDiag = JumpToDiag
- lspf.jumpToDiag = JumpToDiag
lspf.diagHighlightEnable = DiagHighlightEnable
lspf.diagHighlightDisable = DiagHighlightDisable
lspf.showReferences = ShowReferences