]> Sergey Matveev's repositories - vim-lsp.git/commitdiff
Bump up the minimum required Vim version to 9.0 and cleanup the code
authorYegappan Lakshmanan <yegappan@yahoo.com>
Fri, 30 Sep 2022 01:55:10 +0000 (18:55 -0700)
committerYegappan Lakshmanan <yegappan@yahoo.com>
Fri, 30 Sep 2022 01:55:10 +0000 (18:55 -0700)
17 files changed:
.github/workflows/unitests.yml
README.md
autoload/lsp/callhierarchy.vim
autoload/lsp/codeaction.vim
autoload/lsp/diag.vim
autoload/lsp/handlers.vim
autoload/lsp/lsp.vim
autoload/lsp/lspserver.vim
autoload/lsp/outline.vim
autoload/lsp/selection.vim
autoload/lsp/signature.vim
autoload/lsp/symbol.vim
autoload/lsp/textedit.vim
autoload/lsp/util.vim
doc/lsp.txt
plugin/lsp.vim
test/unit_tests.vim

index 71c04dd51150e7f8799a51a1ed3608ec8d00fba9..1009b0a2a11f0b6e99ac0d689d886dfedc8ac5d6 100644 (file)
@@ -12,7 +12,7 @@ jobs:
         uses: rhysd/action-setup-vim@v1
         id: vim
         with:
-          version: nightly
+          version: v9.0.0000
       - name: Checkout LSP Code
         uses: actions/checkout@v2
       - name: Run Tests
index ce5bf9bae562aec98a0cc050be57253e49457a5b..7fa2bc886235a699063ce86e01fb75e5969afde1 100644 (file)
--- a/README.md
+++ b/README.md
@@ -1,6 +1,6 @@
 ![unit-tests](https://github.com/yegappan/mru/workflows/unit-tests/badge.svg?branch=master)
 
-Language Server Protocol (LSP) plugin for Vim9. You need Vim version 8.2.2342 or above to use this plugin.
+Language Server Protocol (LSP) plugin for Vim9. You need Vim version 9.0 or above to use this plugin.
 
 ## Installation
 
index 1cd76b65e0a248049e14bbd815316f4da82ab700..75508e2abeb3a48e4e30a9eb631053116b0e29cd 100644 (file)
@@ -2,22 +2,7 @@ vim9script
 
 # Functions for dealing with call hierarchy (incoming/outgoing calls)
 
-var util = {}
-if has('patch-8.2.4019')
-  import './util.vim' as util_import
-
-  util.WarnMsg = util_import.WarnMsg
-  util.LspUriToFile = util_import.LspUriToFile
-  util.GetLineByteFromPos = util_import.GetLineByteFromPos
-else
-  import {WarnMsg,
-         LspUriToFile,
-         GetLineByteFromPos} from './util.vim'
-
-  util.WarnMsg = WarnMsg
-  util.LspUriToFile = LspUriToFile
-  util.GetLineByteFromPos = GetLineByteFromPos
-endif
+import './util.vim'
 
 def CreateLoclistWithCalls(calls: list<dict<any>>, incoming: bool)
   var qflist: list<dict<any>> = []
@@ -51,15 +36,15 @@ def CreateLoclistWithCalls(calls: list<dict<any>>, incoming: bool)
         qflist->add({filename: fname,
                        lnum: r.start.line + 1,
                        col: util.GetLineByteFromPos(bnr, r.start) + 1,
-                       text: name .. ': ' .. text})
+                       text: $'{name}: {text}'})
       endfor
     else
       var pos: dict<any> = item.to.range.start
       var text: string = bnr->getbufline(pos.line + 1)[0]->trim("\t ", 1)
       qflist->add({filename: fname,
-                       lnum: item.to.range.start.line + 1,
-                       col: util.GetLineByteFromPos(bnr, pos) + 1,
-                       text: name .. ': ' .. text})
+                       lnum: item.to.range.start.line + 1,
+                       col: util.GetLineByteFromPos(bnr, pos) + 1,
+                       text: $'{name}: {text}'})
     endif
   endfor
   var save_winid = win_getid()
index e7e838f2c2b8ed83cf0889aff1dfcd0d36840aa5..6306834a4d986a5254059121aa934f46d572f6af 100644 (file)
@@ -2,22 +2,8 @@ vim9script
 
 # Functions related to handling LSP code actions to fix diagnostics.
 
-var util = {}
-var textedit = {}
-
-if has('patch-8.2.4019')
-  import './util.vim' as util_import
-  import './textedit.vim' as textedit_import
-
-  util.WarnMsg = util_import.WarnMsg
-  textedit.ApplyWorkspaceEdit = textedit_import.ApplyWorkspaceEdit
-else
-  import WarnMsg from './util.vim'
-  import ApplyWorkspaceEdit from './textedit.vim'
-
-  util.WarnMsg = WarnMsg
-  textedit.ApplyWorkspaceEdit = ApplyWorkspaceEdit
-endif
+import './util.vim'
+import './textedit.vim'
 
 export def ApplyCodeAction(lspserver: dict<any>, actions: list<dict<any>>): void
   if actions->empty()
index d4d128429f1c8350e9b3b5ea3600a4d9e2c3b7b0..e7696e4c28c63611d83afd724621c09e8c2299d7 100644 (file)
@@ -2,28 +2,8 @@ vim9script
 
 # Functions related to handling LSP diagnostics.
 
-var opt = {}
-var util = {}
-
-if has('patch-8.2.4019')
-  import './lspoptions.vim' as opt_import
-  import './util.vim' as util_import
-
-  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,
-       LspUriToFile,
-       GetLineByteFromPos} from './util.vim'
-
-  opt.lspOptions = lspOptions
-  util.WarnMsg = WarnMsg
-  util.LspUriToFile = LspUriToFile
-  util.GetLineByteFromPos = GetLineByteFromPos
-endif
+import './lspoptions.vim' as opt
+import './util.vim'
 
 # Remove the diagnostics stored for buffer 'bnr'
 export def DiagRemoveFile(lspserver: dict<any>, bnr: number)
@@ -115,7 +95,7 @@ export def DiagNotification(lspserver: dict<any>, uri: string, diags: list<dict<
     diag_by_lnum[lnum] = d
   endfor
 
-  lspserver.diagsMap->extend({['' .. bnr]: diag_by_lnum})
+  lspserver.diagsMap->extend({[$'{bnr}']: diag_by_lnum})
   ProcessNewDiags(lspserver, bnr)
 enddef
 
@@ -204,7 +184,7 @@ enddef
 # in a location list
 export def ShowAllDiags(lspserver: dict<any>): void
   if !DiagsUpdateLocList(lspserver, bufnr())
-    util.WarnMsg('No diagnostic messages found for ' .. @%)
+    util.WarnMsg($'No diagnostic messages found for {@%}')
     return
   endif
 
@@ -233,7 +213,7 @@ export def ShowCurrentDiagInStatusLine(lspserver: dict<any>)
     var max_width = &columns - 15
     var code = ""
     if has_key(diag, 'code')
-      code = "[" .. diag.code .. "] "
+      code = $'[{diag.code}] '
     endif
     var msgNoLineBreak = code .. substitute(substitute(diag.message, "\n", " ", ""), "\\n", " ", "")
     echo msgNoLineBreak[ : max_width]
@@ -268,7 +248,7 @@ export def LspDiagsJump(lspserver: dict<any>, which: string): void
   var bnr: number = bufnr()
 
   if !lspserver.diagsMap->has_key(bnr) || lspserver.diagsMap[bnr]->empty()
-    util.WarnMsg('No diagnostic messages found for ' .. fname)
+    util.WarnMsg($'No diagnostic messages found for {fname}')
     return
   endif
 
index ec37783477e38da893e088bcb5628865d35b434e..50dac81769438a8b991b55c3b058bb77ea2830fa 100644 (file)
@@ -4,82 +4,16 @@ vim9script
 # Refer to https://microsoft.github.io/language-server-protocol/specification
 # for the Language Server Protocol (LSP) specificaiton.
 
-var opt = {}
-var util = {}
-var diag = {}
-var outline = {}
-var textedit = {}
-var symbol = {}
-var codeaction = {}
-var callhier = {}
-var selection = {}
-var signature = {}
-
-if has('patch-8.2.4019')
-  import './lspoptions.vim' as opt_import
-  import './util.vim' as util_import
-  import './diag.vim' as diag_import
-  import './outline.vim' as outline_import
-  import './textedit.vim' as textedit_import
-  import './symbol.vim' as symbol_import
-  import './codeaction.vim' as codeaction_import
-  import './callhierarchy.vim' as callhierarchy_import
-  import './selection.vim' as selection_import
-  import './signature.vim' as signature_import
-
-  opt.lspOptions = opt_import.lspOptions
-  util.WarnMsg = util_import.WarnMsg
-  util.ErrMsg = util_import.ErrMsg
-  util.TraceLog = util_import.TraceLog
-  util.LspUriToFile = util_import.LspUriToFile
-  util.GetLineByteFromPos = util_import.GetLineByteFromPos
-  diag.DiagNotification = diag_import.DiagNotification
-  outline.UpdateOutlineWindow = outline_import.UpdateOutlineWindow
-  textedit.ApplyTextEdits = textedit_import.ApplyTextEdits
-  textedit.ApplyWorkspaceEdit = textedit_import.ApplyWorkspaceEdit
-  symbol.ShowReferences = symbol_import.ShowReferences
-  symbol.GotoSymbol = symbol_import.GotoSymbol
-  codeaction.ApplyCodeAction = codeaction_import.ApplyCodeAction
-  callhier.IncomingCalls = callhierarchy_import.IncomingCalls
-  callhier.OutgoingCalls = callhierarchy_import.OutgoingCalls
-  selection.SelectionStart = selection_import.SelectionStart
-  signature.SignatureInit = signature_import.SignatureInit
-  signature.SignatureDisplay = signature_import.SignatureDisplay
-else
-  import lspOptions from './lspoptions.vim'
-  import {WarnMsg,
-       ErrMsg,
-       TraceLog,
-       LspUriToFile,
-       GetLineByteFromPos} from './util.vim'
-  import DiagNotification from './diag.vim'
-  import UpdateOutlineWindow from './outline.vim'
-  import {ApplyTextEdits, ApplyWorkspaceEdit} from './textedit.vim'
-  import {ShowReferences, GotoSymbol} from './symbol.vim'
-  import ApplyCodeAction from './codeaction.vim'
-  import {IncomingCalls, OutgoingCalls} from './callhierarchy.vim'
-  import {SelectionStart} from './selection.vim'
-  import {SignatureInit, SignatureDisplay} from './signature.vim'
-
-  opt.lspOptions = lspOptions
-  util.WarnMsg = WarnMsg
-  util.ErrMsg = ErrMsg
-  util.TraceLog = TraceLog
-  util.LspUriToFile = LspUriToFile
-  util.GetLineByteFromPos = GetLineByteFromPos
-  diag.DiagNotification = DiagNotification
-  outline.UpdateOutlineWindow = UpdateOutlineWindow
-  textedit.ApplyTextEdits = ApplyTextEdits
-  textedit.ApplyWorkspaceEdit = ApplyWorkspaceEdit
-  symbol.ShowReferences = ShowReferences
-  symbol.GotoSymbol = GotoSymbol
-  codeaction.ApplyCodeAction = ApplyCodeAction
-  callhier.IncomingCalls = IncomingCalls
-  callhier.OutgoingCalls = OutgoingCalls
-  selection.SelectionStart = SelectionStart
-  signature.SignatureInit = SignatureInit
-  signature.SignatureDisplay = SignatureDisplay
-endif
+import './lspoptions.vim' as opt
+import './util.vim'
+import './diag.vim'
+import './outline.vim'
+import './textedit.vim'
+import './symbol.vim'
+import './codeaction.vim'
+import './callhierarchy.vim' as callhier
+import './selection.vim'
+import './signature.vim'
 
 # process the 'initialize' method reply from the LSP server
 # Result: InitializeResult
@@ -156,9 +90,9 @@ def ProcessSwitchHeaderReply(lspserver: dict<any>, req: dict<any>, reply: dict<a
   if (&modified && !&hidden) || &buftype != ''
     # if the current buffer has unsaved changes and 'hidden' is not set,
     # or if the current buffer is a special buffer, then ask to save changes
-    exe 'confirm edit ' .. fname
+    exe $'confirm edit {fname}'
   else
-    exe 'edit  ' .. fname
+    exe $'edit {fname}'
   endif
 enddef
 
@@ -316,14 +250,14 @@ def ProcessHoverReply(lspserver: dict<any>, req: dict<any>, reply: dict<any>): v
         hoverText = reply.result.contents.value->split("\n")
         hoverKind = 'markdown'
       else
-        util.ErrMsg('Error: Unsupported hover contents type (' .. reply.result.contents.kind .. ')')
+        util.ErrMsg($'Error: Unsupported hover contents type ({reply.result.contents.kind})')
         return
       endif
     elseif reply.result.contents->has_key('value')
       # MarkedString
       hoverText = reply.result.contents.value->split("\n")
     else
-      util.ErrMsg('Error: Unsupported hover contents (' .. reply.result.contents .. ')')
+      util.ErrMsg($'Error: Unsupported hover contents ({reply.result.contents})')
       return
     endif
   elseif reply.result.contents->type() == v:t_list
@@ -341,7 +275,7 @@ def ProcessHoverReply(lspserver: dict<any>, req: dict<any>, reply: dict<any>): v
     endif
     hoverText->extend(reply.result.contents->split("\n"))
   else
-    util.ErrMsg('Error: Unsupported hover contents (' .. reply.result.contents .. ')')
+    util.ErrMsg($'Error: Unsupported hover contents ({reply.result.contents})')
     return
   endif
   if opt.lspOptions.hoverInPreview
@@ -349,7 +283,7 @@ def ProcessHoverReply(lspserver: dict<any>, req: dict<any>, reply: dict<any>): v
     wincmd P
     setlocal buftype=nofile
     setlocal bufhidden=delete
-    exe 'setlocal ft=' .. hoverKind
+    exe $'setlocal ft={hoverKind}'
     deletebufline(bufnr(), 1, '$')
     append(0, hoverText)
     cursor(1, 1)
@@ -432,7 +366,7 @@ def ProcessSymbolInfoTable(symbolInfoTable: list<dict<any>>,
     name = symbol.name
     if symbol->has_key('containerName')
       if symbol.containerName != ''
-       name ..= ' [' .. symbol.containerName .. ']'
+       name ..= $' [{symbol.containerName}]'
       endif
     endif
     r = symbol.location.range
@@ -583,7 +517,7 @@ def ProcessFoldingRangeReply(lspserver: dict<any>, req: dict<any>, reply: dict<a
     if end_lnum < foldRange.startLine + 2
       end_lnum = foldRange.startLine + 2
     endif
-    exe ':' .. (foldRange.startLine + 2) .. ',' .. end_lnum .. 'fold'
+    exe $':{foldRange.startLine + 2}, {end_lnum}fold'
     # Open all the folds, otherwise the subsequently created folds are not
     # correct.
     :silent! foldopen!
@@ -620,7 +554,7 @@ def MakeMenuName(popupWidth: number, fname: string): string
   endif
   var str: string = filename
   if dirname != '.'
-    str ..= ' (' .. dirname .. '/)'
+    str ..= $' ({dirname}/)'
   endif
   return str
 enddef
@@ -650,9 +584,9 @@ def ProcessWorkspaceSymbolReply(lspserver: dict<any>, req: dict<any>, reply: dic
 
     symName = symbol.name
     if symbol->has_key('containerName') && symbol.containerName != ''
-      symName = symbol.containerName .. '::' .. symName
+      symName = $'{symbol.containerName}::{symName}'
     endif
-    symName ..= ' [' .. LspSymbolKindToName(symbol.kind) .. ']'
+    symName ..= $' [{LspSymbolKindToName(symbol.kind)}]'
     symName ..= ' ' .. MakeMenuName(
                lspserver.workspaceSymbolPopup->popup_getpos().core_width,
                fileName)
@@ -750,7 +684,7 @@ export def ProcessReply(lspserver: dict<any>, req: dict<any>, reply: dict<any>):
   if lsp_reply_handlers->has_key(req.method)
     lsp_reply_handlers[req.method](lspserver, req, reply)
   else
-    util.ErrMsg("Error: Unsupported reply received from LSP server: " .. reply->string() .. " for request: " .. req->string())
+    util.ErrMsg($'Error: Unsupported reply received from LSP server: {reply->string()} for request: {req->string()}')
   endif
 enddef
 
@@ -778,7 +712,7 @@ def ProcessShowMsgNotif(lspserver: dict<any>, reply: dict<any>)
     mtype = msgType[reply.params.type]
   endif
 
-  :echomsg 'Lsp ' .. mtype .. reply.params.message
+  :echomsg $'Lsp {mtype} {reply.params.message}'
 enddef
 
 # process a log notification message from the LSP server
@@ -791,12 +725,12 @@ def ProcessLogMsgNotif(lspserver: dict<any>, reply: dict<any>)
     mtype = msgType[reply.params.type]
   endif
 
-  util.TraceLog(false, '[' .. mtype .. ']: ' .. reply.params.message)
+  util.TraceLog(false, $'[{mtype}]: {reply.params.message}')
 enddef
 
 # process unsupported notification messages
 def ProcessUnsupportedNotif(lspserver: dict<any>, reply: dict<any>)
-  util.ErrMsg('Error: Unsupported notification message received from the LSP server (' .. lspserver.path .. '), message = ' .. reply->string())
+  util.ErrMsg($'Error: Unsupported notification message received from the LSP server ({lspserver.path}), message = {reply->string()}')
 enddef
 
 # per-filetype private map inside to record if ntf once or not
@@ -830,7 +764,7 @@ export def ProcessNotif(lspserver: dict<any>, reply: dict<any>): void
   if lsp_notif_handlers->has_key(reply.method)
     lsp_notif_handlers[reply.method](lspserver, reply)
   else
-    util.ErrMsg('Error: Unsupported notification received from LSP server ' .. reply->string())
+    util.ErrMsg($'Error: Unsupported notification received from LSP server {reply->string()}')
   endif
 enddef
 
@@ -844,7 +778,7 @@ def ProcessApplyEditReq(lspserver: dict<any>, request: dict<any>)
   endif
   var workspaceEditParams: dict<any> = request.params
   if workspaceEditParams->has_key('label')
-    :echomsg "Workspace edit" .. workspaceEditParams.label
+    :echomsg $'Workspace edit {workspaceEditParams.label}'
   endif
   textedit.ApplyWorkspaceEdit(workspaceEditParams.edit)
   # TODO: Need to return the proper result of the edit operation
@@ -873,7 +807,7 @@ def ProcessClientUnregisterCap(lspserver: dict<any>, request: dict<any>)
 enddef
 
 def ProcessUnsupportedReq(lspserver: dict<any>, request: dict<any>)
-  util.ErrMsg('Error: Unsupported request message received from the LSP server (' .. lspserver.path .. '), message = ' .. request->string())
+  util.ErrMsg($'Error: Unsupported request message received from the LSP server ({lspserver.path}), message = {request->string()}')
 enddef
 
 # process a request message from the server
@@ -893,7 +827,7 @@ export def ProcessRequest(lspserver: dict<any>, request: dict<any>)
   if lspRequestHandlers->has_key(request.method)
     lspRequestHandlers[request.method](lspserver, request)
   else
-    util.ErrMsg('Error: Unsupported request message received from the LSP server (' .. lspserver.path .. '), message = ' .. request->string())
+    util.ErrMsg($'Error: Unsupported request message received from the LSP server ({lspserver.path}), message = {request->string()}')
   endif
 enddef
 
@@ -944,7 +878,7 @@ export def ProcessMessages(lspserver: dict<any>): void
     try
       msg = content->json_decode()
     catch
-      util.ErrMsg("Error(LSP): Malformed content (" .. content .. ")")
+      util.ErrMsg($'Error(LSP): Malformed content ({content})')
       lspserver.data = lspserver.data[idx + len :]
       continue
     endtry
@@ -961,12 +895,11 @@ export def ProcessMessages(lspserver: dict<any>): void
        else
          # request failed
          var emsg: string = msg.error.message
-         emsg ..= ', code = ' .. msg.error.code
+         emsg ..= $', code = {msg.error.code}'
          if msg.error->has_key('data')
-           emsg = emsg .. ', data = ' .. msg.error.data->string()
+           emsg = $'{emsg}, data = {msg.error.data->string()}'
          endif
-         util.ErrMsg("Error(LSP): request " .. req.method .. " failed ("
-                                                       .. emsg .. ")")
+         util.ErrMsg($'Error(LSP): request {req.method} failed ({emsg})')
        endif
       endif
     elseif msg->has_key('id') && msg->has_key('method')
@@ -976,7 +909,7 @@ export def ProcessMessages(lspserver: dict<any>): void
       # notification message from the server
       lspserver.processNotif(msg)
     else
-      util.ErrMsg("Error(LSP): Unsupported message (" .. msg->string() .. ")")
+      util.ErrMsg($'Error(LSP): Unsupported message ({msg->string()})')
     endif
 
     lspserver.data = lspserver.data[idx + len :]
index e2398cd80ea9fbdb74a4b668d3dbe4379dc339b9..662f32d43277c144379ee389226864dbf6e3ddb9 100644 (file)
@@ -2,113 +2,19 @@ vim9script
 
 # Vim9 LSP client
 
-# Needs Vim 8.2.2342 and higher
-if v:version < 802 || !has('patch-8.2.2342')
+# Needs Vim 9.0 and higher
+if v:version < 900
   finish
 endif
 
-var opt = {}
-var lserver = {}
-var util = {}
-var diag = {}
-var symbol = {}
-var outline = {}
-var signature = {}
-var buf = {}
-
-if has('patch-8.2.4019')
-  import './lspoptions.vim' as opt_import
-  import './lspserver.vim' as server_import
-  import './util.vim' as util_import
-  import './buffer.vim' as buf_import
-  import './diag.vim' as diag_import
-  import './symbol.vim' as symbol_import
-  import './outline.vim' as outline_import
-  import './signature.vim' as signature_import
-
-  opt.lspOptions = opt_import.lspOptions
-  lserver.NewLspServer = server_import.NewLspServer
-  util.WarnMsg = util_import.WarnMsg
-  util.ErrMsg = util_import.ErrMsg
-  util.ServerTrace = util_import.ServerTrace
-  util.ClearTraceLogs = util_import.ClearTraceLogs
-  util.GetLineByteFromPos = util_import.GetLineByteFromPos
-  util.PushCursorToTagStack = util_import.PushCursorToTagStack
-  util.LspUriRemote = util_import.LspUriRemote
-  buf.BufLspServerSet = buf_import.BufLspServerSet
-  buf.BufLspServerRemove = buf_import.BufLspServerRemove
-  buf.BufHasLspServer = buf_import.BufHasLspServer
-  buf.BufLspServerGet = buf_import.BufLspServerGet
-  buf.CurbufGetServer = buf_import.CurbufGetServer
-  diag.UpdateDiags = diag_import.UpdateDiags
-  diag.DiagsGetErrorCount = diag_import.DiagsGetErrorCount
-  diag.ShowAllDiags = diag_import.ShowAllDiags
-  diag.ShowCurrentDiag = diag_import.ShowCurrentDiag
-  diag.ShowCurrentDiagInStatusLine = diag_import.ShowCurrentDiagInStatusLine
-  diag.LspDiagsJump = diag_import.LspDiagsJump
-  diag.DiagRemoveFile = diag_import.DiagRemoveFile
-  diag.DiagsHighlightEnable = diag_import.DiagsHighlightEnable
-  diag.DiagsHighlightDisable = diag_import.DiagsHighlightDisable
-  symbol.ShowSymbolMenu = symbol_import.ShowSymbolMenu
-  outline.OpenOutlineWindow = outline_import.OpenOutlineWindow
-  outline.SkipOutlineRefresh = outline_import.SkipOutlineRefresh
-  signature.SignatureInit = signature_import.SignatureInit
-else
-  import {lspOptions} from './lspoptions.vim'
-  import NewLspServer from './lspserver.vim'
-  import {WarnMsg,
-        ErrMsg,
-        ServerTrace,
-        ClearTraceLogs,
-        GetLineByteFromPos,
-        PushCursorToTagStack,
-       LspUriRemote} from './util.vim'
-  import {BufLspServerSet,
-         BufLspServerRemove,
-         BufHasLspServer,
-         BufLspServerGet,
-         CurbufGetServer} from './buffer.vim'
-  import {DiagRemoveFile,
-       UpdateDiags,
-       DiagsGetErrorCount,
-       ShowAllDiags,
-       ShowCurrentDiag,
-       ShowCurrentDiagInStatusLine,
-       LspDiagsJump,
-       DiagsHighlightEnable,
-       DiagsHighlightDisable} from './diag.vim'
-  import ShowSymbolMenu from './symbol.vim'
-  import {OpenOutlineWindow, SkipOutlineRefresh} from './outline.vim'
-  import {SignatureInit} from './signature.vim'
-
-  opt.lspOptions = lspOptions
-  lserver.NewLspServer = NewLspServer
-  util.WarnMsg = WarnMsg
-  util.ErrMsg = ErrMsg
-  util.ServerTrace = ServerTrace
-  util.ClearTraceLogs = ClearTraceLogs
-  util.GetLineByteFromPos = GetLineByteFromPos
-  util.PushCursorToTagStack = PushCursorToTagStack
-  util.LspUriRemote = LspUriRemote
-  buf.BufLspServerSet = BufLspServerSet
-  buf.BufLspServerRemove = BufLspServerRemove
-  buf.BufHasLspServer = BufHasLspServer
-  buf.BufLspServerGet = BufLspServerGet
-  buf.CurbufGetServer = CurbufGetServer
-  diag.DiagRemoveFile = DiagRemoveFile
-  diag.UpdateDiags = UpdateDiags
-  diag.DiagsGetErrorCount = DiagsGetErrorCount
-  diag.ShowAllDiags = ShowAllDiags
-  diag.ShowCurrentDiag = ShowCurrentDiag
-  diag.ShowCurrentDiagInStatusLine = ShowCurrentDiagInStatusLine
-  diag.LspDiagsJump = LspDiagsJump
-  diag.DiagsHighlightEnable = DiagsHighlightEnable
-  diag.DiagsHighlightDisable = DiagsHighlightDisable
-  symbol.ShowSymbolMenu = ShowSymbolMenu
-  outline.OpenOutlineWindow = OpenOutlineWindow
-  outline.SkipOutlineRefresh = SkipOutlineRefresh
-  signature.SignatureInit = SignatureInit
-endif
+import './lspoptions.vim' as opt
+import './lspserver.vim' as lserver
+import './util.vim'
+import './buffer.vim' as buf
+import './diag.vim'
+import './symbol.vim'
+import './outline.vim'
+import './signature.vim'
 
 # LSP server information
 var lspServers: list<dict<any>> = []
@@ -155,15 +61,15 @@ def CurbufGetServerChecked(): dict<any>
 
   var lspserver: dict<any> = buf.CurbufGetServer()
   if lspserver->empty()
-    util.ErrMsg('Error: LSP server for "' .. fname .. '" is not found')
+    util.ErrMsg($'Error: LSP server for "{fname}" is not found')
     return {}
   endif
   if !lspserver.running
-    util.ErrMsg('Error: LSP server for "' .. fname .. '" is not running')
+    util.ErrMsg($'Error: LSP server for "{fname}" is not running')
     return {}
   endif
   if !lspserver.ready
-    util.ErrMsg('Error: LSP server for "' .. fname .. '" is not ready')
+    util.ErrMsg($'Error: LSP server for "{fname}" is not ready')
     return {}
   endif
 
@@ -200,7 +106,7 @@ export def ShowServers()
     else
       msg ..= 'not running'
     endif
-    msg ..= '    ' .. lspserver.path
+    msg ..= $'    {lspserver.path}'
     :echomsg msg
   endfor
 enddef
@@ -387,22 +293,21 @@ export def AddFile(bnr: number): void
   # Set buffer local autocmds
   augroup LSPBufferAutocmds
     # file saved notification handler
-    exe 'autocmd BufWritePost <buffer=' .. bnr .. '> call LspSavedFile()'
+    exe $'autocmd BufWritePost <buffer={bnr}> call LspSavedFile()'
 
     if opt.lspOptions.autoComplete
       # Trigger 24x7 insert mode completion when text is changed
-      exe 'autocmd TextChangedI <buffer=' .. bnr .. '> call LspComplete()'
+      exe $'autocmd TextChangedI <buffer={bnr}> call LspComplete()'
     endif
 
     # Update the diagnostics when insert mode is stopped
-    exe 'autocmd InsertLeave <buffer=' .. bnr .. '> call LspLeftInsertMode()'
+    exe $'autocmd InsertLeave <buffer={bnr}> call LspLeftInsertMode()'
 
     if opt.lspOptions.autoHighlight &&
                        lspserver.caps->has_key('documentHighlightProvider')
                        && lspserver.caps.documentHighlightProvider
       # Highlight all the occurrences of the current keyword
-      exe 'autocmd CursorMoved <buffer=' .. bnr .. '> '
-                 .. 'call LspDocHighlightClear() | call LspDocHighlight()'
+      exe $'autocmd CursorMoved <buffer={bnr}> call LspDocHighlightClear() | call LspDocHighlight()'
     endif
   augroup END
 
@@ -454,7 +359,7 @@ export def RestartServer()
   endfor
 
   # Start the server again
-  lspserver.startServer(true)
+  lspserver.startServer()
 
   # Add all the buffers with the same file type as the current buffer
   for binfo in getbufinfo({bufloaded: 1})
@@ -478,14 +383,14 @@ export def AddServer(serverList: list<dict<any>>)
 
     if !executable(server.path)
       if !opt.lspOptions.ignoreMissingServer
-        util.ErrMsg('Error: LSP server ' .. server.path .. ' is not found')
+        util.ErrMsg($'Error: LSP server {server.path} is not found')
       endif
       return
     endif
     var args: list<string> = []
     if server->has_key('args')
       if server.args->type() != v:t_list
-        util.ErrMsg('Error: Arguments for LSP server ' .. server.args .. ' is not a List')
+        util.ErrMsg($'Error: Arguments for LSP server {server.args} is not a List')
         return
       endif
       args = server.args
@@ -496,14 +401,14 @@ export def AddServer(serverList: list<dict<any>>)
     var initializationOptions: dict<any> = {}
     if server->has_key('initializationOptions')
       if server.initializationOptions->type() != v:t_dict
-        util.ErrMsg('Error: initializationOptions for LSP server ' .. server.initializationOptions .. ' is not a Dictionary')
+        util.ErrMsg($'Error: initializationOptions for LSP server {server.initializationOptions} is not a Dictionary')
         return
       endif
       initializationOptions = server.initializationOptions
     endif
 
     if server.omnicompl->type() != v:t_bool
-      util.ErrMsg('Error: Setting of omnicompl ' .. server.omnicompl .. ' is not a Boolean')
+      util.ErrMsg($'Error: Setting of omnicompl {server.omnicompl} is not a Boolean')
       return
     endif
 
@@ -525,8 +430,7 @@ export def AddServer(serverList: list<dict<any>>)
         LspOmniComplSet(ftype, server.omnicompl)
       endfor
     else
-      util.ErrMsg('Error: Unsupported file type information "' ..
-               server.filetype->string() .. '" in LSP server registration')
+      util.ErrMsg($'Error: Unsupported file type information "{server.filetype->string()}" in LSP server registration')
       continue
     endif
   endfor
@@ -551,7 +455,7 @@ enddef
 # Params: SetTraceParams
 export def SetTraceServer(traceVal: string)
   if ['off', 'message', 'verbose']->index(traceVal) == -1
-    util.ErrMsg("Error: Unsupported LSP server trace value " .. traceVal)
+    util.ErrMsg($'Error: Unsupported LSP server trace value {traceVal}')
     return
   endif
 
@@ -843,7 +747,7 @@ export def Rename()
   endif
 
   var sym: string = expand('<cword>')
-  var newName: string = input("Rename symbol '" .. sym .. "' to: ", sym)
+  var newName: string = input($"Rename symbol '{sym}' to: ", sym)
   if newName == ''
     return
   endif
@@ -894,7 +798,7 @@ export def ListWorkspaceFolders()
     return
   endif
 
-  echomsg 'Workspace Folders: ' .. lspserver.workspaceFolders->string()
+  echomsg $'Workspace Folders: {lspserver.workspaceFolders->string()}'
 enddef
 
 # Add a workspace folder. Default is to use the current folder.
@@ -913,7 +817,7 @@ export def AddWorkspaceFolder(dirArg: string)
   endif
   :redraw!
   if !dirName->isdirectory()
-    util.ErrMsg('Error: ' .. dirName .. ' is not a directory')
+    util.ErrMsg($'Error: {dirName} is not a directory')
     return
   endif
 
@@ -936,7 +840,7 @@ export def RemoveWorkspaceFolder(dirArg: string)
   endif
   :redraw!
   if !dirName->isdirectory()
-    util.ErrMsg('Error: ' .. dirName .. ' is not a directory')
+    util.ErrMsg($'Error: {dirName} is not a directory')
     return
   endif
 
index 13436af1405fd3c0057155d7638aaa59bb4ad933..5d32d867c4cd505e6f6994e1c8f095d3713f0562 100644 (file)
@@ -4,56 +4,10 @@ vim9script
 # Refer to https://microsoft.github.io/language-server-protocol/specification
 # for the Language Server Protocol (LSP) specificaiton.
 
-var handlers = {}
-var diag = {}
-var util = {}
-var selection = {}
-
-if has('patch-8.2.4019')
-  import './handlers.vim' as handlers_import
-  import './util.vim' as util_import
-  import './diag.vim' as diag_import
-  import './selection.vim' as selection_import
-
-  handlers.ProcessReply = handlers_import.ProcessReply
-  handlers.ProcessNotif = handlers_import.ProcessNotif
-  handlers.ProcessRequest = handlers_import.ProcessRequest
-  handlers.ProcessMessages = handlers_import.ProcessMessages
-  util.WarnMsg = util_import.WarnMsg
-  util.ErrMsg = util_import.ErrMsg
-  util.TraceLog = util_import.TraceLog
-  util.LspBufnrToUri = util_import.LspBufnrToUri
-  util.LspFileToUri = util_import.LspFileToUri
-  util.PushCursorToTagStack = util_import.PushCursorToTagStack
-  diag.GetDiagByLine = diag_import.GetDiagByLine
-  selection.SelectionModify = selection_import.SelectionModify
-else
-  import {ProcessReply,
-       ProcessNotif,
-       ProcessRequest,
-       ProcessMessages} from './handlers.vim'
-  import {GetDiagByLine} from './diag.vim'
-  import {WarnMsg,
-       ErrMsg,
-       TraceLog,
-       LspBufnrToUri,
-       LspFileToUri,
-       PushCursorToTagStack} from './util.vim'
-  import {SelectionModify} from './selection.vim'
-
-  handlers.ProcessReply = ProcessReply
-  handlers.ProcessNotif = ProcessNotif
-  handlers.ProcessRequest = ProcessRequest
-  handlers.ProcessMessages = ProcessMessages
-  util.WarnMsg = WarnMsg
-  util.ErrMsg = ErrMsg
-  util.TraceLog = TraceLog
-  util.LspBufnrToUri = LspBufnrToUri
-  util.LspFileToUri = LspFileToUri
-  util.PushCursorToTagStack = PushCursorToTagStack
-  diag.GetDiagByLine = GetDiagByLine
-  selection.SelectionModify = SelectionModify
-endif
+import './handlers.vim'
+import './util.vim'
+import './diag.vim'
+import './selection.vim'
 
 # LSP server standard output handler
 def Output_cb(lspserver: dict<any>, chan: channel, msg: string): void
@@ -69,7 +23,7 @@ enddef
 
 # LSP server exit callback
 def Exit_cb(lspserver: dict<any>, job: job, status: number): void
-  util.WarnMsg("LSP server exited with status " .. status)
+  util.WarnMsg($'LSP server exited with status {status}')
   lspserver.running = false
   lspserver.ready = false
   lspserver.requests = {}
@@ -79,7 +33,7 @@ enddef
 #
 def StartServer(lspserver: dict<any>): number
   if lspserver.running
-    util.WarnMsg("LSP server for is already running")
+    util.WarnMsg('LSP server for is already running')
     return 0
   endif
 
@@ -105,7 +59,7 @@ def StartServer(lspserver: dict<any>): number
 
   var job = job_start(cmd, opts)
   if job->job_status() == 'fail'
-    util.ErrMsg("Error: Failed to start LSP server " .. lspserver.path)
+    util.ErrMsg($'Error: Failed to start LSP server {lspserver.path}')
     return 1
   endif
 
@@ -298,7 +252,7 @@ enddef
 # Send a request message to LSP server
 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 msg = $"Content-Length: {payload_js->len()}\r\n\r\n"
   var ch = lspserver.job->job_getchannel()
   if ch_status(ch) != 'open'
     # LSP server has exited
@@ -888,7 +842,7 @@ def AddWorkspaceFolder(lspserver: dict<any>, dirName: string): void
   endif
 
   if lspserver.workspaceFolders->index(dirName) != -1
-    util.ErrMsg('Error: ' .. dirName .. ' is already part of this workspace')
+    util.ErrMsg($'Error: {dirName} is already part of this workspace')
     return
   endif
 
@@ -915,7 +869,7 @@ def RemoveWorkspaceFolder(lspserver: dict<any>, dirName: string): void
 
   var idx: number = lspserver.workspaceFolders->index(dirName)
   if idx == -1
-    util.ErrMsg('Error: ' .. dirName .. ' is not currently part of this workspace')
+    util.ErrMsg($'Error: {dirName} is not currently part of this workspace')
     return
   endif
 
@@ -1013,9 +967,9 @@ enddef
 # Display the LSP server capabilities (received during the initialization
 # stage).
 def ShowCapabilities(lspserver: dict<any>)
-  echo "Capabilities of '" .. lspserver.path .. "' LSP server:"
+  echo $"Capabilities of '{lspserver.path}' LSP server:"
   for k in lspserver.caps->keys()->sort()
-    echo k .. ": " .. lspserver.caps[k]->string()
+    echo $'{k}: {lspserver.caps[k]->string()}'
   endfor
 enddef
 
index d66c676c0ea5e506faecde274e1dd228046bef45..5be07bb62ee3d3ee15c79888839657de3d275167 100644 (file)
@@ -1,19 +1,7 @@
 vim9script
 
-var util = {}
-var opt = {}
-if has('patch-8.2.4019')
-  import './util.vim' as util_import
-  import './lspoptions.vim' as opt_import
-  util.GetLineByteFromPos = util_import.GetLineByteFromPos
-  opt.lspOptions = opt_import.lspOptions
-else
-  import GetLineByteFromPos from './util.vim'
-  import lspOptions from './lspoptions.vim'
-
-  util.GetLineByteFromPos = GetLineByteFromPos
-  opt.lspOptions = lspOptions
-endif
+import './util.vim'
+import './lspoptions.vim' as opt
 
 # jump to a symbol selected in the outline window
 def OutlineJumpToSymbol()
@@ -54,7 +42,7 @@ def OutlineJumpToSymbol()
       win_execute(symWinid, 'vertical resize 20')
     endif
 
-    exe 'edit ' .. fname
+    exe $'edit {fname}'
   else
     wid->win_gotoid()
   endif
@@ -131,8 +119,7 @@ export def UpdateOutlineWindow(fname: string,
   :setlocal modifiable
   :silent! :%d _
   setline(1, ['# LSP Outline View',
-               '# ' .. fname->fnamemodify(':t') .. ' ('
-                               .. fname->fnamemodify(':h') .. ')'])
+               $'# {fname->fnamemodify(":t")} ({fname->fnamemodify(":h")})'])
 
   # First two lines in the buffer display comment information
   var lnumMap: list<dict<any>> = [{}, {}]
@@ -217,8 +204,7 @@ def OutlineHighlightCurrentSymbol()
   var wininfo = wid->getwininfo()
   if symbolTable[mid].outlineLine < wininfo[0].topline
                        || symbolTable[mid].outlineLine > wininfo[0].botline
-    var cmd: string = 'call cursor(' ..
-                       symbolTable[mid].outlineLine .. ', 1) | normal z.'
+    var cmd: string = $'call cursor({symbolTable[mid].outlineLine}, 1) | normal z.'
     win_execute(wid, cmd)
   endif
 enddef
@@ -241,9 +227,9 @@ export def OpenOutlineWindow()
   var prevWinID: number = win_getid()
 
   if opt.lspOptions.outlineOnRight
-    execute ':botright :' .. opt.lspOptions.outlineWinSize .. 'vnew LSP-Outline'
+    execute $':botright :{opt.lspOptions.outlineWinSize}vnew LSP-Outline'
   else
-    execute ':topleft :' .. opt.lspOptions.outlineWinSize .. 'vnew LSP-Outline'
+    execute $':topleft :{opt.lspOptions.outlineWinSize}vnew LSP-Outline'
   endif
   :setlocal modifiable
   :setlocal noreadonly
index 222b385087d02fab323a2ad0e6cc919410c72b5d..0996c0ea6de1832b877264f3152e755f6e497f78 100644 (file)
@@ -2,16 +2,7 @@ vim9script
 
 # Functions related to handling LSP range selection.
 
-var util = {}
-if has('patch-8.2.4019')
-  import './util.vim' as util_import
-
-  util.GetLineByteFromPos = util_import.GetLineByteFromPos
-else
-  import {GetLineByteFromPos} from './util.vim'
-
-  util.GetLineByteFromPos = GetLineByteFromPos
-endif
+import './util.vim'
 
 # Visually (character-wise) select the text in a range
 def SelectText(bnr: number, range: dict<dict<number>>)
index c78b0c30476c5726d63a361bd9e6fe2b22c4ad78..60887ff648d6dc380999846cf97624f15a133b85 100644 (file)
@@ -2,27 +2,9 @@ vim9script
 
 # Functions related to handling LSP symbol signature help.
 
-var opt = {}
-var util = {}
-var buf = {}
-
-if has('patch-8.2.4019')
-  import './lspoptions.vim' as opt_import
-  import './util.vim' as util_import
-  import './buffer.vim' as buf_import
-
-  opt.lspOptions = opt_import.lspOptions
-  util.WarnMsg = util_import.WarnMsg
-  buf.CurbufGetServer = buf_import.CurbufGetServer
-else
-  import lspOptions from './lspoptions.vim'
-  import {WarnMsg} from './util.vim'
-  import {CurbufGetServer} from './buffer.vim'
-
-  opt.lspOptions = lspOptions
-  util.WarnMsg = WarnMsg
-  buf.CurbufGetServer = CurbufGetServer
-endif
+import './lspoptions.vim' as opt
+import './util.vim'
+import './buffer.vim' as buf
 
 # close the signature popup window
 def CloseSignaturePopup(lspserver: dict<any>)
@@ -49,8 +31,7 @@ export def SignatureInit(lspserver: dict<any>)
 
   # map characters that trigger signature help
   for ch in lspserver.caps.signatureHelpProvider.triggerCharacters
-    exe 'inoremap <buffer> <silent> ' .. ch .. ' ' .. ch
-                                       .. "<C-R>=LspShowSignature()<CR>"
+    exe $"inoremap <buffer> <silent> {ch} {ch}<C-R>=LspShowSignature()<CR>"
   endfor
   # close the signature popup when leaving insert mode
   autocmd InsertLeave <buffer> call CloseCurBufSignaturePopup()
index f61d65065eed38f00a9cb45e6eddf8340e4192d4..765714a25602e637d1894d7e544b0bd46a92482e 100644 (file)
@@ -6,31 +6,8 @@ vim9script
 #   - jump to a symbol definition, declaration, type definition or
 #     implementation
 
-var opt = {}
-var util = {}
-
-if has('patch-8.2.4019')
-  import './lspoptions.vim' as opt_import
-  import './util.vim' as util_import
-
-  opt.lspOptions = opt_import.lspOptions
-  util.PushCursorToTagStack = util_import.PushCursorToTagStack
-  util.WarnMsg = util_import.WarnMsg
-  util.LspUriToFile = util_import.LspUriToFile
-  util.GetLineByteFromPos = util_import.GetLineByteFromPos
-else
-  import lspOptions from './lspoptions.vim'
-  import {WarnMsg,
-       LspUriToFile,
-       GetLineByteFromPos,
-       PushCursorToTagStack} from './util.vim'
-
-  opt.lspOptions = lspOptions
-  util.WarnMsg = WarnMsg
-  util.LspUriToFile = LspUriToFile
-  util.GetLineByteFromPos = GetLineByteFromPos
-  util.PushCursorToTagStack = PushCursorToTagStack
-endif
+import './lspoptions.vim' as opt
+import './util.vim'
 
 # Handle keys pressed when the workspace symbol popup menu is displayed
 def FilterSymbols(lspserver: dict<any>, popupID: number, key: string): bool
@@ -80,7 +57,7 @@ def FilterSymbols(lspserver: dict<any>, popupID: number, key: string): bool
     else
       []->setwinvar(popupID, 'LspSymbolTable')
     endif
-    echo 'Symbol: ' .. query
+    echo $'Symbol: {query}'
   endif
 
   # Update the workspace symbol query string
@@ -119,9 +96,9 @@ def JumpToWorkspaceSymbol(popupID: number, result: number): void
       if &modified || &buftype != ''
        # the current buffer is modified or is not a normal buffer, then open
        # the file in a new window
-       exe "split " .. symTbl[result - 1].file
+       exe $'split {symTbl[result - 1].file}'
       else
-       exe "confirm edit " .. symTbl[result - 1].file
+       exe $'confirm edit {symTbl[result - 1].file}'
       endif
     else
       winList[0]->win_gotoid()
@@ -158,7 +135,7 @@ export def ShowSymbolMenu(lspserver: dict<any>, query: string)
   prop_type_add('lspworkspacesymbol',
                        {bufnr: lspserver.workspaceSymbolPopup->winbufnr(),
                         highlight: 'Title'})
-  echo 'Symbol: ' .. query
+  echo $'Symbol: {query}'
 enddef
 
 # Display or peek symbol references in a location list
@@ -199,9 +176,9 @@ export def ShowReferences(lspserver: dict<any>, refs: list<dict<any>>)
     # When peeking the references, open the location list in a vertically
     # split window to the right and make the location list window 30% of the
     # source window width
-    mods = 'belowright vert :' .. (winwidth(0) * 30) / 100
+    mods = $'belowright vert :{(winwidth(0) * 30) / 100}'
   endif
-  exe mods .. 'lopen'
+  exe $'{mods} lopen'
   if !opt.lspOptions.keepFocusInReferences
     save_winid->win_gotoid()
   endif
@@ -240,7 +217,7 @@ export def GotoSymbol(lspserver: dict<any>, location: dict<any>, type: string)
   if lspserver.peekSymbol
     # open the definition/declaration in the preview window and highlight the
     # matching symbol
-    exe 'pedit ' .. fname
+    exe $'pedit {fname}'
     var cur_wid = win_getid()
     wincmd P
     var pvwbuf = bufnr()
@@ -268,18 +245,18 @@ export def GotoSymbol(lspserver: dict<any>, location: dict<any>, type: string)
        # and 'hidden' is not set or if the current buffer is a special
        # buffer, then open the buffer in a new window.
         if (&modified && !&hidden) || &buftype != ''
-          exe 'sbuffer ' .. bnr
+          exe $'sbuffer {bnr}'
         else
-          exe 'buf ' .. bnr
+          exe $'buf {bnr}'
         endif
       else
         if (&modified && !&hidden) || &buftype != ''
          # if the current buffer has unsaved changes and 'hidden' is not set,
          # or if the current buffer is a special buffer, then open the file
          # in a new window
-          exe 'split ' .. fname
+          exe $'split {fname}'
         else
-          exe 'edit  ' .. fname
+          exe $'edit {fname}'
         endif
       endif
     endif
index b57addcabe863ec568eb2bc2fa919eec330d39d9..7fb2037681381eee1995c433f71fffdcb7e1c44b 100644 (file)
@@ -1,26 +1,6 @@
 vim9script
 
-var util = {}
-
-if has('patch-8.2.4019')
-  import './util.vim' as util_import
-
-  util.WarnMsg = util_import.WarnMsg
-  util.ErrMsg = util_import.ErrMsg
-  util.LspUriToFile = util_import.LspUriToFile
-  util.GetLineByteFromPos = util_import.GetLineByteFromPos
-else
-  import {WarnMsg,
-       ErrMsg,
-       TraceLog,
-       LspUriToFile,
-       GetLineByteFromPos} from './util.vim'
-
-  util.WarnMsg = WarnMsg
-  util.ErrMsg = ErrMsg
-  util.LspUriToFile = LspUriToFile
-  util.GetLineByteFromPos = GetLineByteFromPos
-endif
+import './util.vim'
 
 # sort the list of edit operations in the descending order of line and column
 # numbers.
@@ -205,7 +185,7 @@ enddef
 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')
+    util.ErrMsg($'Error: Text Document edit, buffer {textDocEdit.textDocument.uri} is not found')
     return
   endif
   ApplyTextEdits(bnr, textDocEdit.edits)
@@ -216,7 +196,7 @@ export def ApplyWorkspaceEdit(workspaceEdit: dict<any>)
   if workspaceEdit->has_key('documentChanges')
     for change in workspaceEdit.documentChanges
       if change->has_key('kind')
-       util.ErrMsg('Error: Unsupported change in workspace edit [' .. change.kind .. ']')
+       util.ErrMsg($'Error: Unsupported change in workspace edit [{change.kind}]')
       else
        ApplyTextDocumentEdit(change)
       endif
index fe478ed294fe6ec20ef83e51c978b51fc62ec87f..65d15d493b841c10243352aabd33c897b26953e2 100644 (file)
@@ -35,9 +35,9 @@ export def TraceLog(stderr: bool, msg: string)
     return
   endif
   if stderr
-    writefile(split(msg, "\n"), lsp_log_dir .. 'lsp_server.err', 'a')
+    writefile(split(msg, "\n"), $'{lsp_log_dir}lsp_server.err', 'a')
   else
-    writefile(split(msg, "\n"), lsp_log_dir .. 'lsp_server.out', 'a')
+    writefile(split(msg, "\n"), $'{lsp_log_dir}lsp_server.out', 'a')
   endif
 enddef
 
@@ -46,8 +46,8 @@ export def ClearTraceLogs()
   if !lsp_server_trace
     return
   endif
-  writefile([], lsp_log_dir .. 'lsp_server.out')
-  writefile([], lsp_log_dir .. 'lsp_server.err')
+  writefile([], $'{lsp_log_dir}lsp_server.out')
+  writefile([], $'{lsp_log_dir}lsp_server.err')
 enddef
 
 # Convert a LSP file URI (file://<absolute_path>) to a Vim file name
@@ -93,9 +93,9 @@ def ConvertFilenameToUri(fname: string): string
                        '\=printf("%%%02x", char2nr(submatch(1)))', 'g')
 
   if on_windows
-    uri = 'file:///' .. uri
+    uri = $'file:///{uri}'
   else
-    uri = 'file://' .. uri
+    uri = $'file://{uri}'
   endif
 
   return uri
index 2678fe1a057b7fedd0da4ac4f2075985a95be404..99cb875941f6293215f184741fb60f149ac10228 100644 (file)
@@ -1,8 +1,8 @@
 *lsp.txt*      Language Server Protocol (LSP) Plugin for Vim9
 
 Author: Yegappan Lakshmanan  (yegappan AT yahoo DOT com)
-For Vim version 8.2.2342 and above
-Last change: Sep 27, 2022
+For Vim version 9.0 and above
+Last change: Sep 29, 2022
 
 ==============================================================================
                                                *lsp-license*
@@ -35,7 +35,7 @@ Refer to the following pages for more information about LSP:
     https://microsoft.github.io/language-server-protocol/
     https://langserver.org/
 
-This plugin needs Vim version 8.2.2342 and after. You will need a language
+This plugin needs Vim version 9.0 and after. You will need a language
 specific server in your system to use this plugin. Refer to the above pages
 for a list of available language servers for the various programming
 languages.
index dd3f79e432d7dd2d89db3c41b9317f368f7ad3e7..5b54be1a8333355576f0cb25f209afad95b1312e 100644 (file)
 vim9script
 
-# LSP plugin for vim9
+# Language Server Protocol (LSP) plugin for vim
 
-if !has('patch-8.2.2342')
+# Needs Vim version 9.0 and above
+if v:version < 900
   finish
 endif
 
-# The following is needed to support both Vim 8.2.3741 (shipped with Ubuntu
-# 21.10) and the latest Vim. The Vim9 script syntax for import changed between
-# these two versions. Once offical Vim9 is out, the following can be
-# simplified.
-var opt = {}
-var lspf = {}
-if has('patch-8.2.4257')
-  import '../autoload/lsp/lspoptions.vim' as lspoptions
-  import '../autoload/lsp/lsp.vim'
-
-  opt.LspOptionsSet = lspoptions.OptionsSet
-  opt.lspOptions = lspoptions.lspOptions
-  lspf.enableServerTrace = lsp.EnableServerTrace
-  lspf.addServer = lsp.AddServer
-  lspf.restartServer = lsp.RestartServer
-  lspf.LspServerReady = lsp.ServerReady
-  lspf.addFile = lsp.AddFile
-  lspf.removeFile = lsp.RemoveFile
-  lspf.showCurrentDiagInStatusLine = lsp.LspShowCurrentDiagInStatusLine
-  lspf.showServers = lsp.ShowServers
-  lspf.showServerCapabilities = lsp.ShowServerCapabilities
-  lspf.setTraceServer = lsp.SetTraceServer
-  lspf.gotoDefinition = lsp.GotoDefinition
-  lspf.gotoDeclaration = lsp.GotoDeclaration
-  lspf.gotoTypedef = lsp.GotoTypedef
-  lspf.gotoImplementation = lsp.GotoImplementation
-  lspf.showDiagnostics = lsp.ShowDiagnostics
-  lspf.showCurrentDiag = lsp.LspShowCurrentDiag
-  lspf.jumpToDiag = lsp.JumpToDiag
-  lspf.diagHighlightEnable = lsp.DiagHighlightEnable
-  lspf.diagHighlightDisable = lsp.DiagHighlightDisable
-  lspf.showReferences = lsp.ShowReferences
-  lspf.outline = lsp.Outline
-  lspf.textDocFormat = lsp.TextDocFormat
-  lspf.incomingCalls = lsp.IncomingCalls
-  lspf.outgoingCalls = lsp.OutgoingCalls
-  lspf.rename = lsp.Rename
-  lspf.codeAction = lsp.CodeAction
-  lspf.symbolSearch = lsp.SymbolSearch
-  lspf.hover = lsp.Hover
-  lspf.selectionExpand = lsp.SelectionExpand
-  lspf.selectionShrink = lsp.SelectionShrink
-  lspf.switchSourceHeader = lsp.SwitchSourceHeader
-  lspf.foldDocument = lsp.FoldDocument
-  lspf.listWorkspaceFolders = lsp.ListWorkspaceFolders
-  lspf.addWorkspaceFolder = lsp.AddWorkspaceFolder
-  lspf.removeWorkspaceFolder = lsp.RemoveWorkspaceFolder
-elseif has('patch-8.2.4019')
-  import '../autoload/lsp/lspoptions.vim' as opt_import
-  import '../autoload/lsp/lsp.vim' as lsp_import
-
-  opt.LspOptionsSet = opt_import.OptionsSet
-  opt.lspOptions = opt_import.lspOptions
-  lspf.enableServerTrace = lsp_import.EnableServerTrace
-  lspf.addServer = lsp_import.AddServer
-  lspf.restartServer = lsp_import.RestartServer
-  lspf.LspServerReady = lsp_import.ServerReady
-  lspf.addFile = lsp_import.AddFile
-  lspf.removeFile = lsp_import.RemoveFile
-  lspf.showCurrentDiagInStatusLine = lsp_import.LspShowCurrentDiagInStatusLine
-  lspf.showServers = lsp_import.ShowServers
-  lspf.showServerCapabilities = lsp_import.ShowServerCapabilities
-  lspf.setTraceServer = lsp_import.SetTraceServer
-  lspf.gotoDefinition = lsp_import.GotoDefinition
-  lspf.gotoDeclaration = lsp_import.GotoDeclaration
-  lspf.gotoTypedef = lsp_import.GotoTypedef
-  lspf.gotoImplementation = lsp_import.GotoImplementation
-  lspf.showDiagnostics = lsp_import.ShowDiagnostics
-  lspf.showCurrentDiag = lsp_import.LspShowCurrentDiag
-  lspf.jumpToDiag = lsp_import.JumpToDiag
-  lspf.diagHighlightEnable = lsp_import.DiagHighlightEnable
-  lspf.diagHighlightDisable = lsp_import.DiagHighlightDisable
-  lspf.showReferences = lsp_import.ShowReferences
-  lspf.outline = lsp_import.Outline
-  lspf.textDocFormat = lsp_import.TextDocFormat
-  lspf.incomingCalls = lsp_import.IncomingCalls
-  lspf.outgoingCalls = lsp_import.OutgoingCalls
-  lspf.rename = lsp_import.Rename
-  lspf.codeAction = lsp_import.CodeAction
-  lspf.symbolSearch = lsp_import.SymbolSearch
-  lspf.hover = lsp_import.Hover
-  lspf.selectionExpand = lsp_import.SelectionExpand
-  lspf.selectionShrink = lsp_import.SelectionShrink
-  lspf.switchSourceHeader = lsp_import.SwitchSourceHeader
-  lspf.foldDocument = lsp_import.FoldDocument
-  lspf.listWorkspaceFolders = lsp_import.ListWorkspaceFolders
-  lspf.addWorkspaceFolder = lsp_import.AddWorkspaceFolder
-  lspf.removeWorkspaceFolder = lsp_import.RemoveWorkspaceFolder
-else
-  import {lspOptions, OptionsSet} from '../autoload/lsp/lspoptions.vim'
-  import {EnableServerTrace,
-         AddServer,
-         RestartServer,
-         ServerReady,
-         AddFile,
-         RemoveFile,
-         LspShowCurrentDiagInStatusLine,
-         ShowServers,
-         ShowServerCapabilities,
-         SetTraceServer,
-         GotoDefinition,
-         GotoDeclaration,
-         GotoTypedef,
-         GotoImplementation,
-         ShowDiagnostics,
-         LspShowCurrentDiag,
-         JumpToDiag,
-         DiagHighlightEnable,
-         DiagHighlightDisable,
-         ShowReferences,
-         Outline,
-         TextDocFormat,
-         IncomingCalls,
-         OutgoingCalls,
-         Rename,
-         CodeAction,
-         SymbolSearch,
-         Hover,
-         SelectionExpand,
-         SelectionShrink,
-         SwitchSourceHeader,
-         FoldDocument,
-         ListWorkspaceFolders,
-         AddWorkspaceFolder,
-         RemoveWorkspaceFolder} from '../autoload/lsp/lsp.vim'
-
-  opt.LspOptionsSet = OptionsSet
-  opt.lspOptions = lspOptions
-  lspf.enableServerTrace = EnableServerTrace
-  lspf.addServer = AddServer
-  lspf.restartServer = RestartServer
-  lspf.LspServerReady = ServerReady
-  lspf.addFile = AddFile
-  lspf.removeFile = RemoveFile
-  lspf.showCurrentDiagInStatusLine = LspShowCurrentDiagInStatusLine
-  lspf.showServers = ShowServers
-  lspf.showServerCapabilities = ShowServerCapabilities
-  lspf.setTraceServer = SetTraceServer
-  lspf.gotoDefinition = GotoDefinition
-  lspf.gotoDeclaration = GotoDeclaration
-  lspf.gotoTypedef = GotoTypedef
-  lspf.gotoImplementation = GotoImplementation
-  lspf.gotoDefinition = GotoDefinition
-  lspf.gotoDeclaration = GotoDeclaration
-  lspf.gotoTypedef = GotoTypedef
-  lspf.gotoImplementation = GotoImplementation
-  lspf.showDiagnostics = ShowDiagnostics
-  lspf.showCurrentDiag = LspShowCurrentDiag
-  lspf.jumpToDiag = JumpToDiag
-  lspf.diagHighlightEnable = DiagHighlightEnable
-  lspf.diagHighlightDisable = DiagHighlightDisable
-  lspf.showReferences = ShowReferences
-  lspf.showReferences = ShowReferences
-  lspf.outline = Outline
-  lspf.textDocFormat = TextDocFormat
-  lspf.incomingCalls = IncomingCalls
-  lspf.outgoingCalls = OutgoingCalls
-  lspf.rename = Rename
-  lspf.codeAction = CodeAction
-  lspf.symbolSearch = SymbolSearch
-  lspf.hover = Hover
-  lspf.selectionExpand = SelectionExpand
-  lspf.selectionShrink = SelectionShrink
-  lspf.switchSourceHeader = SwitchSourceHeader
-  lspf.foldDocument = FoldDocument
-  lspf.listWorkspaceFolders = ListWorkspaceFolders
-  lspf.addWorkspaceFolder = AddWorkspaceFolder
-  lspf.removeWorkspaceFolder = RemoveWorkspaceFolder
-endif
+import autoload '../autoload/lsp/lspoptions.vim'
+import autoload '../autoload/lsp/lsp.vim'
 
 def g:LspOptionsSet(opts: dict<any>)
-  opt.LspOptionsSet(opts)
+  lspoptions.OptionsSet(opts)
 enddef
 
 def g:LspServerTraceEnable()
-  lspf.enableServerTrace()
+  lsp.EnableServerTrace()
 enddef
 
 def g:LspAddServer(serverList: list<dict<any>>)
-  lspf.addServer(serverList)
+  lsp.AddServer(serverList)
 enddef
 
 def g:LspServerReady(): bool
-  return lspf.LspServerReady()
+  return lsp.ServerReady()
 enddef
 
-var TshowServers = lspf.showServers
-var TshowServerCapabilities = lspf.showServerCapabilities
-var TrestartServer = lspf.restartServer
-var TsetTraceServer = lspf.setTraceServer
-var TaddFile = lspf.addFile
-var TremoveFile = lspf.removeFile
-var TshowCurrentDiagInStatusLine = lspf.showCurrentDiagInStatusLine
-var TgotoDefinition = lspf.gotoDefinition
-var TgotoDeclaration = lspf.gotoDeclaration
-var TgotoTypedef = lspf.gotoTypedef
-var TgotoImplementation = lspf.gotoImplementation
-var TshowDiagnostics = lspf.showDiagnostics
-var TshowCurrentDiag = lspf.showCurrentDiag
-var TjumpToDiag = lspf.jumpToDiag
-var TdiagHighlightEnable = lspf.diagHighlightEnable
-var TdiagHighlightDisable = lspf.diagHighlightDisable
-var TshowReferences = lspf.showReferences
-var Toutline = lspf.outline
-var TtextDocFormat = lspf.textDocFormat
-var TincomingCalls = lspf.incomingCalls
-var ToutgoingCalls = lspf.outgoingCalls
-var Trename = lspf.rename
-var TcodeAction = lspf.codeAction
-var TsymbolSearch = lspf.symbolSearch
-var Thover = lspf.hover
-var TselectionExpand = lspf.selectionExpand
-var TselectionShrink = lspf.selectionShrink
-var TswitchSourceHeader = lspf.switchSourceHeader
-var TfoldDocument = lspf.foldDocument
-var TlistWorkspaceFolders = lspf.listWorkspaceFolders
-var TaddWorkspaceFolder = lspf.addWorkspaceFolder
-var TremoveWorkspaceFolder = lspf.removeWorkspaceFolder
-
 augroup LSPAutoCmds
   au!
-  autocmd BufNewFile,BufReadPost * TaddFile(expand('<abuf>')->str2nr())
+  autocmd BufNewFile,BufReadPost * lsp.AddFile(expand('<abuf>')->str2nr())
   # Note that when BufWipeOut is invoked, the current buffer may be different
   # from the buffer getting wiped out.
-  autocmd BufWipeOut * TremoveFile(expand('<abuf>')->str2nr())
-  if opt.lspOptions.showDiagOnStatusLine
-    autocmd CursorMoved * TshowCurrentDiagInStatusLine()
+  autocmd BufWipeOut * lsp.RemoveFile(expand('<abuf>')->str2nr())
+  if lspoptions.lspOptions.showDiagOnStatusLine
+    autocmd CursorMoved * lsp.LspShowCurrentDiagInStatusLine()
   endif
 augroup END
 
 # TODO: Is it needed to shutdown all the LSP servers when exiting Vim?
 # This takes some time.
-# autocmd VimLeavePre * call TstopAllServers()
+# autocmd VimLeavePre * call lsp.StopAllServers()
 
 # LSP commands
-command! -nargs=0 -bar LspShowServers call TshowServers()
-command! -nargs=0 -bar LspShowServerCapabilities call TshowServerCapabilities()
-command! -nargs=0 -bar LspServerRestart call TrestartServer()
-command! -nargs=1 -bar LspSetTrace call TsetTraceServer(<q-args>)
-command! -nargs=0 -bar LspGotoDefinition call TgotoDefinition(v:false)
-command! -nargs=0 -bar LspGotoDeclaration call TgotoDeclaration(v:false)
-command! -nargs=0 -bar LspGotoTypeDef call TgotoTypedef(v:false)
-command! -nargs=0 -bar LspGotoImpl call TgotoImplementation(v:false)
-command! -nargs=0 -bar LspPeekDefinition call TgotoDefinition(v:true)
-command! -nargs=0 -bar LspPeekDeclaration call TgotoDeclaration(v:true)
-command! -nargs=0 -bar LspPeekTypeDef call TgotoTypedef(v:true)
-command! -nargs=0 -bar LspPeekImpl call TgotoImplementation(v:true)
+command! -nargs=0 -bar LspShowServers lsp.ShowServers()
+command! -nargs=0 -bar LspShowServerCapabilities lsp.ShowServerCapabilities()
+command! -nargs=0 -bar LspServerRestart lsp.RestartServer()
+command! -nargs=1 -bar LspSetTrace lsp.SetTraceServer(<q-args>)
+command! -nargs=0 -bar LspGotoDefinition lsp.GotoDefinition(v:false)
+command! -nargs=0 -bar LspGotoDeclaration lsp.GotoDeclaration(v:false)
+command! -nargs=0 -bar LspGotoTypeDef lsp.GotoTypedef(v:false)
+command! -nargs=0 -bar LspGotoImpl lsp.GotoImplementation(v:false)
+command! -nargs=0 -bar LspPeekDefinition lsp.GotoDefinition(v:true)
+command! -nargs=0 -bar LspPeekDeclaration lsp.GotoDeclaration(v:true)
+command! -nargs=0 -bar LspPeekTypeDef lsp.GotoTypedef(v:true)
+command! -nargs=0 -bar LspPeekImpl lsp.GotoImplementation(v:true)
 command! -nargs=0 -bar LspShowSignature call LspShowSignature()
-command! -nargs=0 -bar LspDiagShow call TshowDiagnostics()
-command! -nargs=0 -bar LspDiagCurrent call TshowCurrentDiag()
-command! -nargs=0 -bar LspDiagFirst call TjumpToDiag('first')
-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 TshowReferences(v:false)
-command! -nargs=0 -bar LspPeekReferences call TshowReferences(v:true)
+command! -nargs=0 -bar LspDiagShow lsp.ShowDiagnostics()
+command! -nargs=0 -bar LspDiagCurrent lsp.LspShowCurrentDiag()
+command! -nargs=0 -bar LspDiagFirst lsp.JumpToDiag('first')
+command! -nargs=0 -bar LspDiagNext lsp.JumpToDiag('next')
+command! -nargs=0 -bar LspDiagPrev lsp.JumpToDiag('prev')
+command! -nargs=0 -bar LspDiagHighlightEnable lsp.DiagHighlightEnable()
+command! -nargs=0 -bar LspDiagHighlightDisable lsp.DiagHighlightDisable()
+command! -nargs=0 -bar LspShowReferences lsp.ShowReferences(v:false)
+command! -nargs=0 -bar LspPeekReferences lsp.ShowReferences(v:true)
 # Clangd specifc extension to switch from one C/C++ source file to a
 # corresponding header file
-command! -nargs=0 -bar LspSwitchSourceHeader call TswitchSourceHeader()
+command! -nargs=0 -bar LspSwitchSourceHeader lsp.SwitchSourceHeader()
 command! -nargs=0 -bar LspHighlight call LspDocHighlight()
 command! -nargs=0 -bar LspHighlightClear call LspDocHighlightClear()
-command! -nargs=0 -bar LspOutline call Toutline()
-command! -nargs=0 -bar -range=% LspFormat call TtextDocFormat(<range>, <line1>, <line2>)
-command! -nargs=0 -bar LspOutgoingCalls call ToutgoingCalls()
-command! -nargs=0 -bar LspIncomingCalls call TincomingCalls()
-command! -nargs=0 -bar LspRename call Trename()
-command! -nargs=0 -bar LspCodeAction call TcodeAction()
-command! -nargs=? -bar LspSymbolSearch call TsymbolSearch(<q-args>)
-command! -nargs=0 -bar LspHover call Thover()
-command! -nargs=0 -bar LspSelectionExpand call TselectionExpand()
-command! -nargs=0 -bar LspSelectionShrink call TselectionShrink()
-command! -nargs=0 -bar LspFold call TfoldDocument()
-command! -nargs=0 -bar LspWorkspaceListFolders call TlistWorkspaceFolders()
-command! -nargs=1 -bar -complete=dir LspWorkspaceAddFolder call TaddWorkspaceFolder(<q-args>)
-command! -nargs=1 -bar -complete=dir LspWorkspaceRemoveFolder call TremoveWorkspaceFolder(<q-args>)
+command! -nargs=0 -bar LspOutline lsp.Outline()
+command! -nargs=0 -bar -range=% LspFormat lsp.TextDocFormat(<range>, <line1>, <line2>)
+command! -nargs=0 -bar LspOutgoingCalls lsp.OutgoingCalls()
+command! -nargs=0 -bar LspIncomingCalls lsp.IncomingCalls()
+command! -nargs=0 -bar LspRename lsp.Rename()
+command! -nargs=0 -bar LspCodeAction lsp.CodeAction()
+command! -nargs=? -bar LspSymbolSearch lsp.SymbolSearch(<q-args>)
+command! -nargs=0 -bar LspHover lsp.Hover()
+command! -nargs=0 -bar LspSelectionExpand lsp.SelectionExpand()
+command! -nargs=0 -bar LspSelectionShrink lsp.SelectionShrink()
+command! -nargs=0 -bar LspFold lsp.FoldDocument()
+command! -nargs=0 -bar LspWorkspaceListFolders lsp.ListWorkspaceFolders()
+command! -nargs=1 -bar -complete=dir LspWorkspaceAddFolder lsp.AddWorkspaceFolder(<q-args>)
+command! -nargs=1 -bar -complete=dir LspWorkspaceRemoveFolder lsp.RemoveWorkspaceFolder(<q-args>)
 
 # Add the GUI menu entries
 if has('gui_running')
index 62d9fc54fa05739959d6839d144c36db1055fe7f..cf5fb7735ec0383885ab2b3b336b178360a6c5e4 100644 (file)
@@ -585,19 +585,13 @@ def Test_LspHighlight()
   :LspHighlight
   var expected: dict<any>
   expected = {id: 0, col: 13, end: 1, type: 'LspTextRef', length: 3, start: 1}
-  if has('patch-8.2.3233')
-    expected.type_bufnr = 0
-  endif
+  expected.type_bufnr = 0
   assert_equal([expected], prop_list(1))
   expected = {id: 0, col: 11, end: 1, type: 'LspReadRef', length: 3, start: 1}
-  if has('patch-8.2.3233')
-    expected.type_bufnr = 0
-  endif
+  expected.type_bufnr = 0
   assert_equal([expected], prop_list(3))
   expected = {id: 0, col: 3, end: 1, type: 'LspWriteRef', length: 3, start: 1}
-  if has('patch-8.2.3233')
-    expected.type_bufnr = 0
-  endif
+  expected.type_bufnr = 0
   assert_equal([expected], prop_list(4))
   :LspHighlightClear
   assert_equal([], prop_list(1))
@@ -660,9 +654,7 @@ def Test_LspShowSignature()
   assert_equal(['MyFunc(int a, int b) -> int'], getbufline(bnr, 1, '$'))
   var expected: dict<any>
   expected = {id: 0, col: 8, end: 1, type: 'signature', length: 5, start: 1}
-  if has('patch-8.2.3233')
-    expected.type_bufnr = bnr
-  endif
+  expected.type_bufnr = bnr
   assert_equal([expected], prop_list(1, {bufnr: bnr}))
   popup_close(p[0])
 
@@ -674,9 +666,7 @@ def Test_LspShowSignature()
   assert_equal(1, p->len())
   assert_equal(['MyFunc(int a, int b) -> int'], getbufline(bnr, 1, '$'))
   expected = {id: 0, col: 15, end: 1, type: 'signature', length: 5, start: 1}
-  if has('patch-8.2.3233')
-    expected.type_bufnr = bnr
-  endif
+  expected.type_bufnr = bnr
   assert_equal([expected], prop_list(1, {bufnr: bnr}))
   popup_close(p[0])
   :%bw!