autoload/handlers.vim | 72 +++++++++++++++++++++++++++--------------------------- autoload/lspserver.vim | 18 +++++++++--------- autoload/outline.vim | 4 ++-- autoload/symbol.vim | 4 ++-- autoload/textedit.vim | 4 ++-- plugin/lsp.vim | 8 ++++---- test/run_tests.sh | 11 ++++++++--- diff --git a/autoload/handlers.vim b/autoload/handlers.vim index ca789e13297da93de75f76d8966d351e9f074a2b..ce0b20c62a6099e4e50574c183482e370901d7de 100644 --- a/autoload/handlers.vim +++ b/autoload/handlers.vim @@ -673,28 +673,28 @@ # Process various reply messages from the LSP server export def ProcessReply(lspserver: dict, req: dict, reply: dict): void var lsp_reply_handlers: dict = { - 'initialize': function('s:ProcessInitializeReply'), - 'textDocument/definition': function('s:ProcessDefDeclReply'), - 'textDocument/declaration': function('s:ProcessDefDeclReply'), - 'textDocument/typeDefinition': function('s:ProcessDefDeclReply'), - 'textDocument/implementation': function('s:ProcessDefDeclReply'), - 'textDocument/signatureHelp': function('s:ProcessSignaturehelpReply'), - 'textDocument/completion': function('s:ProcessCompletionReply'), - 'textDocument/hover': function('s:ProcessHoverReply'), - 'textDocument/references': function('s:ProcessReferencesReply'), - 'textDocument/documentHighlight': function('s:ProcessDocHighlightReply'), - 'textDocument/documentSymbol': function('s:ProcessDocSymbolReply'), - 'textDocument/formatting': function('s:ProcessFormatReply'), - 'textDocument/rangeFormatting': function('s:ProcessFormatReply'), - 'textDocument/rename': function('s:ProcessRenameReply'), - 'textDocument/codeAction': function('s:ProcessCodeActionReply'), - 'textDocument/selectionRange': function('s:ProcessSelectionRangeReply'), - 'textDocument/foldingRange': function('s:ProcessFoldingRangeReply'), - 'workspace/executeCommand': function('s:ProcessWorkspaceExecuteReply'), - 'workspace/symbol': function('s:ProcessWorkspaceSymbolReply'), - 'textDocument/prepareCallHierarchy': function('s:ProcessPrepareCallHierarchy'), - 'callHierarchy/incomingCalls': function('s:ProcessIncomingCalls'), - 'callHierarchy/outgoingCalls': function('s:ProcessOutgoingCalls') + 'initialize': function('ProcessInitializeReply'), + 'textDocument/definition': function('ProcessDefDeclReply'), + 'textDocument/declaration': function('ProcessDefDeclReply'), + 'textDocument/typeDefinition': function('ProcessDefDeclReply'), + 'textDocument/implementation': function('ProcessDefDeclReply'), + 'textDocument/signatureHelp': function('ProcessSignaturehelpReply'), + 'textDocument/completion': function('ProcessCompletionReply'), + 'textDocument/hover': function('ProcessHoverReply'), + 'textDocument/references': function('ProcessReferencesReply'), + 'textDocument/documentHighlight': function('ProcessDocHighlightReply'), + 'textDocument/documentSymbol': function('ProcessDocSymbolReply'), + 'textDocument/formatting': function('ProcessFormatReply'), + 'textDocument/rangeFormatting': function('ProcessFormatReply'), + 'textDocument/rename': function('ProcessRenameReply'), + 'textDocument/codeAction': function('ProcessCodeActionReply'), + 'textDocument/selectionRange': function('ProcessSelectionRangeReply'), + 'textDocument/foldingRange': function('ProcessFoldingRangeReply'), + 'workspace/executeCommand': function('ProcessWorkspaceExecuteReply'), + 'workspace/symbol': function('ProcessWorkspaceSymbolReply'), + 'textDocument/prepareCallHierarchy': function('ProcessPrepareCallHierarchy'), + 'callHierarchy/incomingCalls': function('ProcessIncomingCalls'), + 'callHierarchy/outgoingCalls': function('ProcessOutgoingCalls') } if lsp_reply_handlers->has_key(req.method) @@ -757,14 +757,14 @@ # process notification messages from the LSP server export def ProcessNotif(lspserver: dict, reply: dict): void var lsp_notif_handlers: dict = { - 'window/showMessage': function('s:ProcessShowMsgNotif'), - 'window/logMessage': function('s:ProcessLogMsgNotif'), - 'textDocument/publishDiagnostics': function('s:ProcessDiagNotif'), - '$/progress': function('s:ProcessUnsupportedNotif'), - 'telemetry/event': function('s:ProcessUnsupportedNotif'), + 'window/showMessage': function('ProcessShowMsgNotif'), + 'window/logMessage': function('ProcessLogMsgNotif'), + 'textDocument/publishDiagnostics': function('ProcessDiagNotif'), + '$/progress': function('ProcessUnsupportedNotif'), + 'telemetry/event': function('ProcessUnsupportedNotif'), # Java language server sends the 'language/status' notification which is # not in the LSP specification - 'language/status': function('s:IgnoreNotif') + 'language/status': function('IgnoreNotif') } if lsp_notif_handlers->has_key(reply.method) @@ -799,14 +799,14 @@ # process a request message from the server export def ProcessRequest(lspserver: dict, request: dict) var lspRequestHandlers: dict = { - 'workspace/applyEdit': function('s:ProcessApplyEditReq'), - 'window/workDoneProgress/create': function('s:ProcessUnsupportedReq'), - 'client/registerCapability': function('s:ProcessUnsupportedReq'), - 'client/unregisterCapability': function('s:ProcessUnsupportedReq'), - 'workspace/workspaceFolders': function('s:ProcessUnsupportedReq'), - 'workspace/configuration': function('s:ProcessUnsupportedReq'), - 'workspace/codeLens/refresh': function('s:ProcessUnsupportedReq'), - 'workspace/semanticTokens/refresh': function('s:ProcessUnsupportedReq') + 'workspace/applyEdit': function('ProcessApplyEditReq'), + 'window/workDoneProgress/create': function('ProcessUnsupportedReq'), + 'client/registerCapability': function('ProcessUnsupportedReq'), + 'client/unregisterCapability': function('ProcessUnsupportedReq'), + 'workspace/workspaceFolders': function('ProcessUnsupportedReq'), + 'workspace/configuration': function('ProcessUnsupportedReq'), + 'workspace/codeLens/refresh': function('ProcessUnsupportedReq'), + 'workspace/semanticTokens/refresh': function('ProcessUnsupportedReq') } if lspRequestHandlers->has_key(request.method) diff --git a/autoload/lspserver.vim b/autoload/lspserver.vim index 397ff5590f6a93441dba34714438cca4e9b6d7ad..6d9f1e895be5d6ec04fd15c808ab5470eab14c00 100644 --- a/autoload/lspserver.vim +++ b/autoload/lspserver.vim @@ -454,7 +454,7 @@ lspserver.peekSymbol = peek var req = lspserver.createRequest('textDocument/definition') # interface DefinitionParams # interface TextDocumentPositionParams - req.params->extend(s:GetLspTextDocPosition()) + req.params->extend(GetLspTextDocPosition()) lspserver.sendMessage(req) lspserver.waitForReponse(req) @@ -478,7 +478,7 @@ var req = lspserver.createRequest('textDocument/declaration') # interface DeclarationParams # interface TextDocumentPositionParams - req.params->extend(s:GetLspTextDocPosition()) + req.params->extend(GetLspTextDocPosition()) lspserver.sendMessage(req) @@ -503,7 +503,7 @@ var req = lspserver.createRequest('textDocument/typeDefinition') # interface TypeDefinitionParams # interface TextDocumentPositionParams - req.params->extend(s:GetLspTextDocPosition()) + req.params->extend(GetLspTextDocPosition()) lspserver.sendMessage(req) @@ -528,7 +528,7 @@ var req = lspserver.createRequest('textDocument/implementation') # interface ImplementationParams # interface TextDocumentPositionParams - req.params->extend(s:GetLspTextDocPosition()) + req.params->extend(GetLspTextDocPosition()) lspserver.sendMessage(req) @@ -548,7 +548,7 @@ var req = lspserver.createRequest('textDocument/signatureHelp') # interface SignatureHelpParams # interface TextDocumentPositionParams - req.params->extend(s:GetLspTextDocPosition()) + req.params->extend(GetLspTextDocPosition()) lspserver.sendMessage(req) @@ -587,7 +587,7 @@ var req = lspserver.createRequest('textDocument/hover') # interface HoverParams # interface TextDocumentPositionParams - req.params->extend(s:GetLspTextDocPosition()) + req.params->extend(GetLspTextDocPosition()) lspserver.sendMessage(req) if exists('g:LSPTest') && g:LSPTest # When running LSP tests, make this a synchronous call @@ -608,7 +608,7 @@ var req = lspserver.createRequest('textDocument/references') # interface ReferenceParams # interface TextDocumentPositionParams - req.params->extend(s:GetLspTextDocPosition()) + req.params->extend(GetLspTextDocPosition()) req.params->extend({context: {includeDeclaration: true}}) lspserver.peekSymbol = peek @@ -632,7 +632,7 @@ var req = lspserver.createRequest('textDocument/documentHighlight') # interface DocumentHighlightParams # interface TextDocumentPositionParams - req.params->extend(s:GetLspTextDocPosition()) + req.params->extend(GetLspTextDocPosition()) lspserver.sendMessage(req) if exists('g:LSPTest') && g:LSPTest # When running LSP tests, make this a synchronous call @@ -729,7 +729,7 @@ var req = lspserver.createRequest('textDocument/prepareCallHierarchy') # interface CallHierarchyPrepareParams # interface TextDocumentPositionParams - req.params->extend(s:GetLspTextDocPosition()) + req.params->extend(GetLspTextDocPosition()) lspserver.sendMessage(req) enddef diff --git a/autoload/outline.vim b/autoload/outline.vim index af549f929007b7cfbdb76c9d398d87ce3c94793d..d66c676c0ea5e506faecde274e1dd228046bef45 100644 --- a/autoload/outline.vim +++ b/autoload/outline.vim @@ -99,7 +99,7 @@ lnumMap->add({name: s.name, lnum: s.range.start.line + 1, col: start_col}) s.outlineLine = lnumMap->len() if s->has_key('children') && !s.children->empty() - s:AddSymbolText(bnr, s.children, prefix, text, lnumMap, true) + AddSymbolText(bnr, s.children, prefix, text, lnumMap, true) endif endfor endfor @@ -259,7 +259,7 @@ :setlocal foldlevel=4 :setlocal foldmethod=indent setline(1, ['# File Outline']) :nnoremap q :quit - :nnoremap :call outlineJumpToSymbol() + :nnoremap :call OutlineJumpToSymbol() :setlocal nomodifiable # highlight all the symbol types diff --git a/autoload/symbol.vim b/autoload/symbol.vim index 8e9cacf3abd93d5645d10a534d2ed28e72cd32a5..9f9644583d61abc6f5ebe6db588433e1e27f54e7 100644 --- a/autoload/symbol.vim +++ b/autoload/symbol.vim @@ -150,8 +150,8 @@ maxwidth: 60, mapping: false, fixed: 1, close: "button", - filter: function('s:filterSymbols', [lspserver]), - callback: function('s:jumpToWorkspaceSymbol') + filter: function('s:FilterSymbols', [lspserver]), + callback: function('s:JumpToWorkspaceSymbol') } lspserver.workspaceSymbolPopup = popup_menu([], popupAttr) lspserver.workspaceSymbolQuery = query diff --git a/autoload/textedit.vim b/autoload/textedit.vim index 9da069a78d4e05067b2e3f863768a571157f85a6..b57addcabe863ec568eb2bc2fa919eec330d39d9 100644 --- a/autoload/textedit.vim +++ b/autoload/textedit.vim @@ -153,7 +153,7 @@ endfor # Reverse sort the edit operations by descending line and column numbers so # that they can be applied without interfering with each other. - updated_edits->sort('s:Edit_sort_func') + updated_edits->sort('Edit_sort_func') var lines: list = bnr->getbufline(start_line + 1, finish_line + 1) var fix_eol: bool = bnr->getbufvar('&fixeol') @@ -218,7 +218,7 @@ for change in workspaceEdit.documentChanges if change->has_key('kind') util.ErrMsg('Error: Unsupported change in workspace edit [' .. change.kind .. ']') else - s:ApplyTextDocumentEdit(change) + ApplyTextDocumentEdit(change) endif endfor return diff --git a/plugin/lsp.vim b/plugin/lsp.vim index a9b51d5032230fc8cf6a2d24773ebd6c25040bab..83b98d7a7d92b2318bb38b88f61ab808993c1bb9 100644 --- a/plugin/lsp.vim +++ b/plugin/lsp.vim @@ -227,8 +227,8 @@ # This takes some time. # autocmd VimLeavePre * call TstopAllServers() # LSP commands -command! -nargs=0 -bar LspShowServers call s:TshowServers() -command! -nargs=0 -bar LspShowServerCapabilities call s:TshowServerCapabilities() +command! -nargs=0 -bar LspShowServers call TshowServers() +command! -nargs=0 -bar LspShowServerCapabilities call TshowServerCapabilities() command! -nargs=1 -bar LspSetTrace call TsetTraceServer() command! -nargs=0 -bar LspGotoDefinition call TgotoDefinition(v:false) command! -nargs=0 -bar LspGotoDeclaration call TgotoDeclaration(v:false) @@ -246,8 +246,8 @@ command! -nargs=0 -bar LspDiagNext call TjumpToDiag('next') command! -nargs=0 -bar LspDiagPrev call TjumpToDiag('prev') command! -nargs=0 -bar LspDiagHighlightEnable call TdiagHighlightEnable() command! -nargs=0 -bar LspDiagHighlightDisable call TdiagHighlightDisable() -command! -nargs=0 -bar LspShowReferences call s:TshowReferences(v:false) -command! -nargs=0 -bar LspPeekReferences call s:TshowReferences(v:true) +command! -nargs=0 -bar LspShowReferences call TshowReferences(v:false) +command! -nargs=0 -bar LspPeekReferences call TshowReferences(v:true) command! -nargs=0 -bar LspHighlight call LspDocHighlight() command! -nargs=0 -bar LspHighlightClear call LspDocHighlightClear() command! -nargs=0 -bar LspOutline call Toutline() diff --git a/test/run_tests.sh b/test/run_tests.sh index 4285d6f423100e39b5a2bfe41851178a45442c93..811604424ff131b04dd1ebf3aa668bb3df846774 100755 --- a/test/run_tests.sh +++ b/test/run_tests.sh @@ -2,15 +2,20 @@ #!/bin/bash # Script to run the unit-tests for the LSP Vim plugin -#VIMPRG=${VIMPRG:=/usr/bin/vim} -export VIMRUNTIME=/home/yega/Documents/vim/cmdexpand/vim/runtime -VIMPRG=/home/yega/Documents/vim/cmdexpand/vim/src/vim +VIMPRG=${VIMPRG:=/usr/bin/vim} VIM_CMD="$VIMPRG -u NONE -U NONE -i NONE --noplugin -N --not-a-term" $VIM_CMD -S unit_tests.vim echo "LSP unit test results:" echo + +if [ ! -f results.txt ] +then + echo "ERROR: Test results file 'results.txt' is not found" + exit 1 +fi + cat results.txt echo