From: Yegappan Lakshmanan Date: Thu, 10 Feb 2022 04:50:03 +0000 (-0800) Subject: Remove s: prefix from script-local functions X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=d4408926a56d8ac7ef508190158858ce1d416dda;p=vim-lsp.git Remove s: prefix from script-local functions --- diff --git a/autoload/callhierarchy.vim b/autoload/callhierarchy.vim index 9ccc71a..aaa5c40 100644 --- a/autoload/callhierarchy.vim +++ b/autoload/callhierarchy.vim @@ -19,7 +19,7 @@ else util.GetLineByteFromPos = GetLineByteFromPos endif -def s:CreateLoclistWithCalls(calls: list>, incoming: bool) +def CreateLoclistWithCalls(calls: list>, incoming: bool) var qflist: list> = [] for item in calls diff --git a/autoload/diag.vim b/autoload/diag.vim index 9780cd9..7310d43 100644 --- a/autoload/diag.vim +++ b/autoload/diag.vim @@ -32,7 +32,7 @@ export def DiagRemoveFile(lspserver: dict, bnr: number) endif enddef -def s:DiagSevToSignName(severity: number): string +def DiagSevToSignName(severity: number): string var typeMap: list = ['LspDiagError', 'LspDiagWarning', 'LspDiagInfo', 'LspDiagHint'] if severity > 4 @@ -140,7 +140,7 @@ export def DiagsGetErrorCount(lspserver: dict): dict enddef # Map the LSP DiagnosticSeverity to a quickfix type character -def s:DiagSevToQfType(severity: number): string +def DiagSevToQfType(severity: number): string var typeMap: list = ['E', 'W', 'I', 'N'] if severity > 4 @@ -221,7 +221,7 @@ export def GetDiagByLine(lspserver: dict, bnr: number, lnum: number): dict< enddef # sort the diaganostics messages for a buffer by line number -def s:GetSortedDiagLines(lspsrv: dict, bnr: number): list +def GetSortedDiagLines(lspsrv: dict, bnr: number): list # create a list of line numbers from the diag map keys var lnums: list = lspsrv.diagsMap[bnr]->keys()->mapnew((_, v) => v->str2nr()) diff --git a/autoload/handlers.vim b/autoload/handlers.vim index f073f31..e635016 100644 --- a/autoload/handlers.vim +++ b/autoload/handlers.vim @@ -83,7 +83,7 @@ endif # process the 'initialize' method reply from the LSP server # Result: InitializeResult -def s:ProcessInitializeReply(lspserver: dict, req: dict, reply: dict): void +def ProcessInitializeReply(lspserver: dict, req: dict, reply: dict): void if reply.result->len() <= 0 return endif @@ -126,7 +126,7 @@ enddef # 'textDocument/typeDefinition' and 'textDocument/implementation' replies from # the LSP server # Result: Location | Location[] | LocationLink[] | null -def s:ProcessDefDeclReply(lspserver: dict, req: dict, reply: dict): void +def ProcessDefDeclReply(lspserver: dict, req: dict, reply: dict): void var location: dict if reply.result->type() == v:t_list if !reply.result->empty() @@ -143,7 +143,7 @@ enddef # process the 'textDocument/signatureHelp' reply from the LSP server # Result: SignatureHelp | null -def s:ProcessSignaturehelpReply(lspserver: dict, req: dict, reply: dict): void +def ProcessSignaturehelpReply(lspserver: dict, req: dict, reply: dict): void signature.SignatureDisplay(lspserver, reply.result) enddef @@ -184,7 +184,7 @@ enddef # process the 'textDocument/completion' reply from the LSP server # Result: CompletionItem[] | CompletionList | null -def s:ProcessCompletionReply(lspserver: dict, req: dict, reply: dict): void +def ProcessCompletionReply(lspserver: dict, req: dict, reply: dict): void if reply.result->empty() return endif @@ -274,7 +274,7 @@ enddef # process the 'textDocument/hover' reply from the LSP server # Result: Hover | null -def s:ProcessHoverReply(lspserver: dict, req: dict, reply: dict): void +def ProcessHoverReply(lspserver: dict, req: dict, reply: dict): void if reply.result->empty() return endif @@ -337,13 +337,13 @@ enddef # process the 'textDocument/references' reply from the LSP server # Result: Location[] | null -def s:ProcessReferencesReply(lspserver: dict, req: dict, reply: dict): void +def ProcessReferencesReply(lspserver: dict, req: dict, reply: dict): void symbol.ShowReferences(lspserver, reply.result) enddef # process the 'textDocument/documentHighlight' reply from the LSP server # Result: DocumentHighlight[] | null -def s:ProcessDocHighlightReply(lspserver: dict, req: dict, reply: dict): void +def ProcessDocHighlightReply(lspserver: dict, req: dict, reply: dict): void if reply.result->empty() return endif @@ -387,7 +387,7 @@ def LspSymbolKindToName(symkind: number): string enddef # process SymbolInformation[] -def s:ProcessSymbolInfoTable(symbolInfoTable: list>, +def ProcessSymbolInfoTable(symbolInfoTable: list>, symbolTypeTable: dict>>, symbolLineTable: list>) var fname: string @@ -417,7 +417,7 @@ def s:ProcessSymbolInfoTable(symbolInfoTable: list>, enddef # process DocumentSymbol[] -def s:ProcessDocSymbolTable(docSymbolTable: list>, +def ProcessDocSymbolTable(docSymbolTable: list>, symbolTypeTable: dict>>, symbolLineTable: list>) var symbolType: string @@ -451,7 +451,7 @@ enddef # 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, req: dict, reply: dict): void +def ProcessDocSymbolReply(lspserver: dict, req: dict, reply: dict): void var fname: string var symbolTypeTable: dict>> = {} var symbolLineTable: list> = [] @@ -481,7 +481,7 @@ enddef # process the 'textDocument/formatting' reply from the LSP server # Result: TextEdit[] | null -def s:ProcessFormatReply(lspserver: dict, req: dict, reply: dict) +def ProcessFormatReply(lspserver: dict, req: dict, reply: dict) if reply.result->empty() # nothing to format return @@ -506,7 +506,7 @@ enddef # Reply: 'textDocument/rename' # Result: Range | { range: Range, placeholder: string } # | { defaultBehavior: boolean } | null -def s:ProcessRenameReply(lspserver: dict, req: dict, reply: dict) +def ProcessRenameReply(lspserver: dict, req: dict, reply: dict) if reply.result->empty() # nothing to rename return @@ -518,19 +518,19 @@ enddef # process the 'textDocument/codeAction' reply from the LSP server # Result: (Command | CodeAction)[] | null -def s:ProcessCodeActionReply(lspserver: dict, req: dict, reply: dict) +def ProcessCodeActionReply(lspserver: dict, req: dict, reply: dict) codeaction.ApplyCodeAction(lspserver, reply.result) enddef # Reply: 'textDocument/selectionRange' # Result: SelectionRange[] | null -def s:ProcessSelectionRangeReply(lspserver: dict, req: dict, reply: dict) +def ProcessSelectionRangeReply(lspserver: dict, req: dict, reply: dict) selection.SelectionStart(lspserver, reply.result) enddef # Reply: 'textDocument/foldingRange' # Result: FoldingRange[] | null -def s:ProcessFoldingRangeReply(lspserver: dict, req: dict, reply: dict) +def ProcessFoldingRangeReply(lspserver: dict, req: dict, reply: dict) if reply.result->empty() return endif @@ -556,7 +556,7 @@ enddef # process the 'workspace/executeCommand' reply from the LSP server # Result: any | null -def s:ProcessWorkspaceExecuteReply(lspserver: dict, req: dict, reply: dict) +def ProcessWorkspaceExecuteReply(lspserver: dict, req: dict, reply: dict) if reply.result->empty() return endif @@ -566,7 +566,7 @@ enddef # Convert a file name () 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') @@ -587,7 +587,7 @@ enddef # process the 'workspace/symbol' reply from the LSP server # Result: SymbolInformation[] | null -def s:ProcessWorkspaceSymbolReply(lspserver: dict, req: dict, reply: dict) +def ProcessWorkspaceSymbolReply(lspserver: dict, req: dict, reply: dict) var symbols: list> = [] var symbolType: string var fileName: string @@ -628,7 +628,7 @@ enddef # process the 'textDocument/prepareCallHierarchy' reply from the LSP server # Result: CallHierarchyItem[] | null -def s:ProcessPrepareCallHierarchy(lspserver: dict, req: dict, reply: dict) +def ProcessPrepareCallHierarchy(lspserver: dict, req: dict, reply: dict) if reply.result->empty() if lspserver.callHierarchyType == 'incoming' util.WarnMsg('No incoming calls') @@ -659,13 +659,13 @@ enddef # process the 'callHierarchy/incomingCalls' reply from the LSP server # Result: CallHierarchyIncomingCall[] | null -def s:ProcessIncomingCalls(lspserver: dict, req: dict, reply: dict) +def ProcessIncomingCalls(lspserver: dict, req: dict, reply: dict) callhier.IncomingCalls(reply.result) enddef # process the 'callHierarchy/outgoingCalls' reply from the LSP server # Result: CallHierarchyOutgoingCall[] | null -def s:ProcessOutgoingCalls(lspserver: dict, req: dict, reply: dict) +def ProcessOutgoingCalls(lspserver: dict, req: dict, reply: dict) callhier.OutgoingCalls(reply.result) enddef @@ -707,14 +707,14 @@ enddef # process a diagnostic notification message from the LSP server # Notification: textDocument/publishDiagnostics # Param: PublishDiagnosticsParams -def s:ProcessDiagNotif(lspserver: dict, reply: dict): void +def ProcessDiagNotif(lspserver: dict, reply: dict): 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, reply: dict) +def ProcessShowMsgNotif(lspserver: dict, reply: dict) var msgType: list = ['', 'Error: ', 'Warning: ', 'Info: ', 'Log: '] if reply.params.type == 4 # ignore log messages from the LSP server (too chatty) @@ -734,7 +734,7 @@ enddef # process a log notification message from the LSP server # Notification: window/logMessage # Param: LogMessageParams -def s:ProcessLogMsgNotif(lspserver: dict, reply: dict) +def ProcessLogMsgNotif(lspserver: dict, reply: dict) var msgType: list = ['', 'Error: ', 'Warning: ', 'Info: ', 'Log: '] var mtype: string = 'Log: ' if reply.params.type > 0 && reply.params.type < 5 @@ -745,12 +745,12 @@ def s:ProcessLogMsgNotif(lspserver: dict, reply: dict) enddef # process unsupported notification messages -def s:ProcessUnsupportedNotif(lspserver: dict, reply: dict) +def ProcessUnsupportedNotif(lspserver: dict, reply: dict) 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, reply: dict) +def IgnoreNotif(lspserver: dict, reply: dict) enddef # process notification messages from the LSP server @@ -777,7 +777,7 @@ enddef # process the workspace/applyEdit LSP server request # Request: "workspace/applyEdit" # Param: ApplyWorkspaceEditParams -def s:ProcessApplyEditReq(lspserver: dict, request: dict) +def ProcessApplyEditReq(lspserver: dict, request: dict) # interface ApplyWorkspaceEditParams if !request->has_key('params') return @@ -791,7 +791,7 @@ def s:ProcessApplyEditReq(lspserver: dict, request: dict) lspserver.sendResponse(request, {applied: true}, {}) enddef -def s:ProcessUnsupportedReq(lspserver: dict, request: dict) +def ProcessUnsupportedReq(lspserver: dict, request: dict) util.ErrMsg('Error: Unsupported request message received from the LSP server (' .. lspserver.path .. '), message = ' .. request->string()) enddef diff --git a/autoload/lsp.vim b/autoload/lsp.vim index 324c048..e190d45 100644 --- a/autoload/lsp.vim +++ b/autoload/lsp.vim @@ -121,7 +121,7 @@ var ftypeOmniCtrlMap: dict = {} var lspInitializedOnce = false -def s:LspInitOnce() +def LspInitOnce() # Signs used for LSP diagnostics sign_define([{name: 'LspDiagError', text: 'E ', texthl: 'ErrorMsg', linehl: 'MatchParen'}, @@ -141,13 +141,13 @@ enddef # 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 +def LspGetServer(ftype: string): dict 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 +def CurbufGetServerChecked(): dict var fname: string = @% if fname == '' return {} @@ -171,18 +171,18 @@ def s:CurbufGetServerChecked(): dict enddef # Add a LSP server for a filetype -def s:LspAddServer(ftype: string, lspsrv: dict) +def LspAddServer(ftype: string, lspsrv: dict) 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 @@ -260,7 +260,7 @@ def g:LspShowSignature(): string enddef # buffer change notification listener -def s:Bufchange_listener(bnr: number, start: number, end: number, added: number, changes: list>) +def Bufchange_listener(bnr: number, start: number, end: number, added: number, changes: list>) var lspserver: dict = buf.CurbufGetServer() if lspserver->empty() || !lspserver.running return @@ -270,7 +270,7 @@ def s:Bufchange_listener(bnr: number, start: number, end: number, added: number, enddef # A buffer is saved. Send the "textDocument/didSave" LSP notification -def s:LspSavedFile() +def LspSavedFile() var bnr: number = expand('')->str2nr() var lspserver: dict = buf.BufLspServerGet(bnr) if lspserver->empty() || !lspserver.running diff --git a/autoload/lspserver.vim b/autoload/lspserver.vim index 74a693f..1be8746 100644 --- a/autoload/lspserver.vim +++ b/autoload/lspserver.vim @@ -56,19 +56,19 @@ else endif # LSP server standard output handler -def s:Output_cb(lspserver: dict, chan: channel, msg: string): void +def Output_cb(lspserver: dict, 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, chan: channel, emsg: string,): void +def Error_cb(lspserver: dict, chan: channel, emsg: string,): void util.TraceLog(true, emsg) enddef # LSP server exit callback -def s:Exit_cb(lspserver: dict, job: job, status: number): void +def Exit_cb(lspserver: dict, job: job, status: number): void util.WarnMsg("LSP server exited with status " .. status) lspserver.job = v:null lspserver.running = false @@ -77,7 +77,7 @@ def s:Exit_cb(lspserver: dict, job: job, status: number): void enddef # Start a LSP server -def s:StartServer(lspserver: dict): number +def StartServer(lspserver: dict): number if lspserver.running util.WarnMsg("LSP server for is already running") return 0 @@ -122,7 +122,7 @@ enddef # Request: 'initialize' # Param: InitializeParams -def s:InitServer(lspserver: dict) +def InitServer(lspserver: dict) var req = lspserver.createRequest('initialize') # client capabilities (ClientCapabilities) @@ -175,27 +175,27 @@ enddef # Send a "initialized" LSP notification # Params: InitializedParams -def s:SendInitializedNotif(lspserver: dict) +def SendInitializedNotif(lspserver: dict) var notif: dict = lspserver.createNotification('initialized') lspserver.sendMessage(notif) enddef # Request: shutdown # Param: void -def s:ShutdownServer(lspserver: dict): void +def ShutdownServer(lspserver: dict): 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): void +def ExitServer(lspserver: dict): void var notif: dict = lspserver.createNotification('exit') lspserver.sendMessage(notif) enddef # Stop a LSP server -def s:StopServer(lspserver: dict): number +def StopServer(lspserver: dict): number if !lspserver.running util.WarnMsg("LSP server is not running") return 0 @@ -217,21 +217,21 @@ def s:StopServer(lspserver: dict): number enddef # set the LSP server trace level using $/setTrace notification -def s:SetTrace(lspserver: dict, traceVal: string) +def SetTrace(lspserver: dict, traceVal: string) var notif: dict = 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): number +def NextReqID(lspserver: dict): number var id = lspserver.nextID lspserver.nextID = id + 1 return id enddef # create a LSP server request message -def s:CreateRequest(lspserver: dict, method: string): dict +def CreateRequest(lspserver: dict, method: string): dict var req = {} req.jsonrpc = '2.0' req.id = lspserver.nextReqID() @@ -245,7 +245,7 @@ def s:CreateRequest(lspserver: dict, method: string): dict enddef # create a LSP server response message -def s:CreateResponse(lspserver: dict, req_id: number): dict +def CreateResponse(lspserver: dict, req_id: number): dict var resp = {} resp.jsonrpc = '2.0' resp.id = req_id @@ -254,7 +254,7 @@ def s:CreateResponse(lspserver: dict, req_id: number): dict enddef # create a LSP server notification message -def s:CreateNotification(lspserver: dict, notif: string): dict +def CreateNotification(lspserver: dict, notif: string): dict var req = {} req.jsonrpc = '2.0' req.method = notif @@ -264,7 +264,7 @@ def s:CreateNotification(lspserver: dict, notif: string): dict enddef # send a response message to the server -def s:SendResponse(lspserver: dict, request: dict, result: dict, error: dict) +def SendResponse(lspserver: dict, request: dict, result: dict, error: dict) var resp: dict = lspserver.createResponse(request.id) if result->type() != v:t_none resp->extend({result: result}) @@ -275,7 +275,7 @@ def s:SendResponse(lspserver: dict, request: dict, result: dict, enddef # Send a request message to LSP server -def s:SendMessage(lspserver: dict, content: dict): void +def SendMessage(lspserver: dict, content: dict): 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() @@ -289,7 +289,7 @@ enddef # 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, req: dict) +def WaitForReponse(lspserver: dict, req: dict) var maxCount: number = 2500 var key: string = req.id->string() @@ -301,7 +301,7 @@ enddef # Send a LSP "textDocument/didOpen" notification # Params: DidOpenTextDocumentParams -def s:TextdocDidOpen(lspserver: dict, bnr: number, ftype: string): void +def TextdocDidOpen(lspserver: dict, bnr: number, ftype: string): void var notif: dict = lspserver.createNotification('textDocument/didOpen') # interface DidOpenTextDocumentParams @@ -317,7 +317,7 @@ def s:TextdocDidOpen(lspserver: dict, bnr: number, ftype: string): void enddef # Send a LSP "textDocument/didClose" notification -def s:TextdocDidClose(lspserver: dict, bnr: number): void +def TextdocDidClose(lspserver: dict, bnr: number): void var notif: dict = lspserver.createNotification('textDocument/didClose') # interface DidCloseTextDocumentParams @@ -331,7 +331,7 @@ enddef # Send a LSP "textDocument/didChange" notification # Params: DidChangeTextDocumentParams -def s:TextdocDidChange(lspserver: dict, bnr: number, start: number, +def TextdocDidChange(lspserver: dict, bnr: number, start: number, end: number, added: number, changes: list>): void var notif: dict = lspserver.createNotification('textDocument/didChange') @@ -392,7 +392,7 @@ enddef # 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 +def GetLspPosition(): dict var lnum: number = line('.') - 1 var col: number = charcol('.') - 1 return {line: lnum, character: col} @@ -400,7 +400,7 @@ enddef # Return the current file name and current cursor position as a LSP # TextDocumentPositionParams structure -def s:GetLspTextDocPosition(): dict> +def GetLspTextDocPosition(): dict> # interface TextDocumentIdentifier # interface Position return {textDocument: {uri: util.LspFileToUri(@%)}, @@ -410,7 +410,7 @@ enddef # Get a list of completion items. # Request: "textDocument/completion" # Param: CompletionParams -def s:GetCompletion(lspserver: dict, triggerKind_arg: number): void +def GetCompletion(lspserver: dict, 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") @@ -439,7 +439,7 @@ enddef # Request: "textDocument/definition" # Param: DefinitionParams -def s:GotoDefinition(lspserver: dict, peek: bool) +def GotoDefinition(lspserver: dict, peek: bool) # Check whether LSP server supports jumping to a definition if !lspserver.caps->has_key('definitionProvider') || !lspserver.caps.definitionProvider @@ -462,7 +462,7 @@ enddef # Request: "textDocument/declaration" # Param: DeclarationParams -def s:GotoDeclaration(lspserver: dict, peek: bool): void +def GotoDeclaration(lspserver: dict, peek: bool): void # Check whether LSP server supports jumping to a declaration if !lspserver.caps->has_key('declarationProvider') || !lspserver.caps.declarationProvider @@ -487,7 +487,7 @@ enddef # Request: "textDocument/typeDefinition" # Param: TypeDefinitionParams -def s:GotoTypeDef(lspserver: dict, peek: bool): void +def GotoTypeDef(lspserver: dict, peek: bool): void # Check whether LSP server supports jumping to a type definition if !lspserver.caps->has_key('typeDefinitionProvider') || !lspserver.caps.typeDefinitionProvider @@ -512,7 +512,7 @@ enddef # Request: "textDocument/implementation" # Param: ImplementationParams -def s:GotoImplementation(lspserver: dict, peek: bool): void +def GotoImplementation(lspserver: dict, peek: bool): void # Check whether LSP server supports jumping to a implementation if !lspserver.caps->has_key('implementationProvider') || !lspserver.caps.implementationProvider @@ -538,7 +538,7 @@ enddef # get symbol signature help. # Request: "textDocument/signatureHelp" # Param: SignatureHelpParams -def s:ShowSignature(lspserver: dict): void +def ShowSignature(lspserver: dict): void # Check whether LSP server supports signature help if !lspserver.caps->has_key('signatureHelpProvider') util.ErrMsg("Error: LSP server does not support signature help") @@ -558,7 +558,7 @@ def s:ShowSignature(lspserver: dict): void endif enddef -def s:DidSaveFile(lspserver: dict, bnr: number): void +def DidSaveFile(lspserver: dict, 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 @@ -577,7 +577,7 @@ enddef # get the hover information # Request: "textDocument/hover" # Param: HoverParams -def s:Hover(lspserver: dict): void +def Hover(lspserver: dict): void # Check whether LSP server supports getting hover information if !lspserver.caps->has_key('hoverProvider') || !lspserver.caps.hoverProvider @@ -597,7 +597,7 @@ enddef # Request: "textDocument/references" # Param: ReferenceParams -def s:ShowReferences(lspserver: dict, peek: bool): void +def ShowReferences(lspserver: dict, peek: bool): void # Check whether LSP server supports getting reference information if !lspserver.caps->has_key('referencesProvider') || !lspserver.caps.referencesProvider @@ -621,7 +621,7 @@ enddef # Request: "textDocument/documentHighlight" # Param: DocumentHighlightParams -def s:DocHighlight(lspserver: dict): void +def DocHighlight(lspserver: dict): void # Check whether LSP server supports getting highlight information if !lspserver.caps->has_key('documentHighlightProvider') || !lspserver.caps.documentHighlightProvider @@ -642,7 +642,7 @@ enddef # Request: "textDocument/documentSymbol" # Param: DocumentSymbolParams -def s:GetDocSymbols(lspserver: dict, fname: string): void +def GetDocSymbols(lspserver: dict, fname: string): void # Check whether LSP server supports getting document symbol information if !lspserver.caps->has_key('documentSymbolProvider') || !lspserver.caps.documentSymbolProvider @@ -666,7 +666,7 @@ enddef # or # Request: "textDocument/rangeFormatting" # Param: DocumentRangeFormattingParams -def s:TextDocFormat(lspserver: dict, fname: string, rangeFormat: bool, +def TextDocFormat(lspserver: dict, fname: string, rangeFormat: bool, start_lnum: number, end_lnum: number) # Check whether LSP server supports formatting documents if !lspserver.caps->has_key('documentFormattingProvider') @@ -717,7 +717,7 @@ enddef # Request: "textDocument/prepareCallHierarchy" # Param: CallHierarchyPrepareParams -def s:PrepareCallHierarchy(lspserver: dict, fname: string) +def PrepareCallHierarchy(lspserver: dict, fname: string) # Check whether LSP server supports call hierarchy if !lspserver.caps->has_key('callHierarchyProvider') || !lspserver.caps.callHierarchyProvider @@ -735,7 +735,7 @@ enddef # Request: "callHierarchy/incomingCalls" # Param: CallHierarchyItem -def s:IncomingCalls(lspserver: dict, hierItem: dict) +def IncomingCalls(lspserver: dict, hierItem: dict) # Check whether LSP server supports call hierarchy if !lspserver.caps->has_key('callHierarchyProvider') || !lspserver.caps.callHierarchyProvider @@ -757,7 +757,7 @@ enddef # Request: "callHierarchy/outgoingCalls" # Param: CallHierarchyItem -def s:OutgoingCalls(lspserver: dict, hierItem: dict) +def OutgoingCalls(lspserver: dict, hierItem: dict) # Check whether LSP server supports call hierarchy if !lspserver.caps->has_key('callHierarchyProvider') || !lspserver.caps.callHierarchyProvider @@ -779,7 +779,7 @@ enddef # Request: "textDocument/rename" # Param: RenameParams -def s:RenameSymbol(lspserver: dict, newName: string) +def RenameSymbol(lspserver: dict, newName: string) # Check whether LSP server supports rename operation if !lspserver.caps->has_key('renameProvider') || !lspserver.caps.renameProvider @@ -801,7 +801,7 @@ enddef # Request: "textDocument/codeAction" # Param: CodeActionParams -def s:CodeAction(lspserver: dict, fname_arg: string) +def CodeAction(lspserver: dict, fname_arg: string) # Check whether LSP server supports code action operation if !lspserver.caps->has_key('codeActionProvider') || !lspserver.caps.codeActionProvider @@ -836,7 +836,7 @@ enddef # List project-wide symbols matching query string # Request: "workspace/symbol" # Param: WorkspaceSymbolParams -def s:WorkspaceQuerySymbols(lspserver: dict, query: string): bool +def WorkspaceQuerySymbols(lspserver: dict, query: string): bool # Check whether the LSP server supports listing workspace symbols if !lspserver.caps->has_key('workspaceSymbolProvider') || !lspserver.caps.workspaceSymbolProvider @@ -854,7 +854,7 @@ enddef # Add a workspace folder to the LSP server. # Request: "workspace/didChangeWorkspaceFolders" # Param: DidChangeWorkspaceFoldersParams -def s:AddWorkspaceFolder(lspserver: dict, dirName: string): void +def AddWorkspaceFolder(lspserver: dict, dirName: string): void if !lspserver.caps->has_key('workspace') || !lspserver.caps.workspace->has_key('workspaceFolders') || !lspserver.caps.workspace.workspaceFolders->has_key('supported') @@ -880,7 +880,7 @@ enddef # Remove a workspace folder from the LSP server. # Request: "workspace/didChangeWorkspaceFolders" # Param: DidChangeWorkspaceFoldersParams -def s:RemoveWorkspaceFolder(lspserver: dict, dirName: string): void +def RemoveWorkspaceFolder(lspserver: dict, dirName: string): void if !lspserver.caps->has_key('workspace') || !lspserver.caps.workspace->has_key('workspaceFolders') || !lspserver.caps.workspace.workspaceFolders->has_key('supported') @@ -907,7 +907,7 @@ enddef # select the text around the current cursor location # Request: "textDocument/selectionRange" # Param: SelectionRangeParams -def s:SelectionRange(lspserver: dict, fname: string) +def SelectionRange(lspserver: dict, fname: string) # Check whether LSP server supports selection ranges if !lspserver.caps->has_key('selectionRangeProvider') || !lspserver.caps.selectionRangeProvider @@ -928,7 +928,7 @@ def s:SelectionRange(lspserver: dict, fname: string) enddef # Expand the previous selection or start a new one -def s:SelectionExpand(lspserver: dict) +def SelectionExpand(lspserver: dict) # Check whether LSP server supports selection ranges if !lspserver.caps->has_key('selectionRangeProvider') || !lspserver.caps.selectionRangeProvider @@ -940,7 +940,7 @@ def s:SelectionExpand(lspserver: dict) enddef # Shrink the previous selection or start a new one -def s:SelectionShrink(lspserver: dict) +def SelectionShrink(lspserver: dict) # Check whether LSP server supports selection ranges if !lspserver.caps->has_key('selectionRangeProvider') || !lspserver.caps.selectionRangeProvider @@ -954,7 +954,7 @@ enddef # fold the entire document # Request: "textDocument/foldingRange" # Param: FoldingRangeParams -def s:FoldRange(lspserver: dict, fname: string) +def FoldRange(lspserver: dict, fname: string) # Check whether LSP server supports fold ranges if !lspserver.caps->has_key('foldingRangeProvider') || !lspserver.caps.foldingRangeProvider @@ -976,7 +976,7 @@ enddef # Request the LSP server to execute a command # Request: workspace/executeCommand # Params: ExecuteCommandParams -def s:ExecuteCommand(lspserver: dict, cmd: dict) +def ExecuteCommand(lspserver: dict, cmd: dict) var req = lspserver.createRequest('workspace/executeCommand') req.params->extend(cmd) lspserver.sendMessage(req) @@ -988,7 +988,7 @@ enddef # Display the LSP server capabilities (received during the initialization # stage). -def s:ShowCapabilities(lspserver: dict) +def ShowCapabilities(lspserver: dict) echo "Capabilities of '" .. lspserver.path .. "' LSP server:" for k in lspserver.caps->keys()->sort() echo k .. ": " .. lspserver.caps[k]->string() diff --git a/autoload/outline.vim b/autoload/outline.vim index 25e41ed..bef0ae3 100644 --- a/autoload/outline.vim +++ b/autoload/outline.vim @@ -16,7 +16,7 @@ else 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 @@ -70,7 +70,7 @@ export def SkipOutlineRefresh(): bool return skipRefresh enddef -def s:AddSymbolText(bnr: number, +def AddSymbolText(bnr: number, symbolTypeTable: dict>>, pfx: string, text: list, @@ -156,7 +156,7 @@ export def UpdateOutlineWindow(fname: string, skipRefresh = false enddef -def s:OutlineHighlightCurrentSymbol() +def OutlineHighlightCurrentSymbol() var fname: string = expand('%')->fnamemodify(':p') if fname == '' || &filetype == '' return @@ -224,7 +224,7 @@ def s:OutlineHighlightCurrentSymbol() enddef # when the outline window is closed, do the cleanup -def s:OutlineCleanup() +def OutlineCleanup() # Remove the outline autocommands :silent! autocmd! LSPOutline diff --git a/autoload/selection.vim b/autoload/selection.vim index 49c2dde..7b73340 100644 --- a/autoload/selection.vim +++ b/autoload/selection.vim @@ -14,7 +14,7 @@ else endif # Visually (character-wise) select the text in a range -def s:SelectText(bnr: number, range: dict>) +def SelectText(bnr: number, range: dict>) var start_col: number = util.GetLineByteFromPos(bnr, range.start) + 1 var end_col: number = util.GetLineByteFromPos(bnr, range.end) @@ -39,7 +39,7 @@ export def SelectionStart(lspserver: dict, sel: list>) enddef # Locate the range in the LSP reply at a specified level -def s:GetSelRangeAtLevel(selRange: dict, level: number): dict +def GetSelRangeAtLevel(selRange: dict, level: number): dict var r: dict = selRange var idx: number = 0 @@ -56,7 +56,7 @@ enddef # Returns true if the current visual selection matches a range in the # selection reply from LSP. -def s:SelectionFromLSP(range: dict, startpos: list, endpos: list): bool +def SelectionFromLSP(range: dict, startpos: list, endpos: list): bool return startpos[1] == range.start.line + 1 && endpos[1] == range.end.line + 1 && startpos[2] == range.start.character + 1 diff --git a/autoload/signature.vim b/autoload/signature.vim index 19ff04d..64d2d77 100644 --- a/autoload/signature.vim +++ b/autoload/signature.vim @@ -25,12 +25,12 @@ else endif # close the signature popup window -def s:CloseSignaturePopup(lspserver: dict) +def CloseSignaturePopup(lspserver: dict) lspserver.signaturePopup->popup_close() lspserver.signaturePopup = -1 enddef -def s:CloseCurBufSignaturePopup() +def CloseCurBufSignaturePopup() var lspserver: dict = buf.CurbufGetServer() if lspserver->empty() return diff --git a/autoload/symbol.vim b/autoload/symbol.vim index 6b09430..8e9cacf 100644 --- a/autoload/symbol.vim +++ b/autoload/symbol.vim @@ -33,7 +33,7 @@ else endif # Handle keys pressed when the workspace symbol popup menu is displayed -def s:FilterSymbols(lspserver: dict, popupID: number, key: string): bool +def FilterSymbols(lspserver: dict, popupID: number, key: string): bool var key_handled: bool = false var update_popup: bool = false var query: string = lspserver.workspaceSymbolQuery @@ -94,7 +94,7 @@ def s:FilterSymbols(lspserver: dict, popupID: number, key: string): bool 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 '' diff --git a/autoload/textedit.vim b/autoload/textedit.vim index 77a09f6..f9afaa2 100644 --- a/autoload/textedit.vim +++ b/autoload/textedit.vim @@ -26,7 +26,7 @@ endif # numbers. # 'a': {'A': [lnum, col], 'B': [lnum, col]} # 'b': {'A': [lnum, col], 'B': [lnum, col]} -def s:Edit_sort_func(a: dict, b: dict): number +def Edit_sort_func(a: dict, b: dict): number # line number if a.A[0] != b.A[0] return b.A[0] - a.A[0] @@ -49,7 +49,7 @@ enddef # 'new_lines' A list of strings to replace the original # # returns the modified 'lines' -def s:Set_lines(lines: list, A: list, B: list, +def Set_lines(lines: list, A: list, B: list, new_lines: list): list var i_0: number = A[0] @@ -202,7 +202,7 @@ export def ApplyTextEdits(bnr: number, text_edits: list>): void enddef # interface TextDocumentEdit -def s:ApplyTextDocumentEdit(textDocEdit: dict) +def ApplyTextDocumentEdit(textDocEdit: dict) 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') diff --git a/plugin/lsp.vim b/plugin/lsp.vim index fa06c73..84b9ff1 100644 --- a/plugin/lsp.vim +++ b/plugin/lsp.vim @@ -144,8 +144,6 @@ else lspf.showDiagnostics = ShowDiagnostics lspf.showCurrentDiag = LspShowCurrentDiag lspf.jumpToDiag = JumpToDiag - lspf.jumpToDiag = JumpToDiag - lspf.jumpToDiag = JumpToDiag lspf.diagHighlightEnable = DiagHighlightEnable lspf.diagHighlightDisable = DiagHighlightDisable lspf.showReferences = ShowReferences