From 32ea697d10e51909d0ff5c332d25c3781e49ed53 Mon Sep 17 00:00:00 2001 From: Yegappan Lakshmanan Date: Sat, 11 Mar 2023 15:47:30 -0800 Subject: [PATCH] Use string interpolation and single quoted strings --- autoload/lsp/codeaction.vim | 13 ++++- autoload/lsp/completion.vim | 2 +- autoload/lsp/diag.vim | 6 +-- autoload/lsp/handlers.vim | 4 +- autoload/lsp/lsp.vim | 10 ++-- autoload/lsp/lspserver.vim | 52 +++++++++---------- autoload/lsp/markdown.vim | 94 +++++++++++++++++----------------- autoload/lsp/selection.vim | 4 +- autoload/lsp/symbol.vim | 2 +- autoload/lsp/textedit.vim | 24 ++++----- autoload/lsp/typehierarchy.vim | 2 +- 11 files changed, 112 insertions(+), 101 deletions(-) diff --git a/autoload/lsp/codeaction.vim b/autoload/lsp/codeaction.vim index 8199494..0855767 100644 --- a/autoload/lsp/codeaction.vim +++ b/autoload/lsp/codeaction.vim @@ -21,6 +21,7 @@ def DoCommand(lspserver: dict, cmd: dict) endif enddef +# Apply the code action selected by the user. export def HandleCodeAction(lspserver: dict, selAction: dict) # textDocument/codeAction can return either Command[] or CodeAction[]. # If it is a CodeAction, it can have either an edit, a command or both. @@ -43,6 +44,16 @@ export def HandleCodeAction(lspserver: dict, selAction: dict) endif enddef +# Process the list of code actions returned by the LSP server, ask the user to +# choose one action from the list and then apply it. +# If "query" is a number, then apply the corresponding action in the list. +# If "query" is a regular expression starting with "/", then apply the action +# matching the search string in the list. +# If "query" is a regular string, then apply the action matching the string. +# If "query" is an empty string, then if the "usePopupInCodeAction" option is +# configured by the user, then display the list of items in a popup menu. +# Otherwise display the items in an input list and prompt the user to select +# an action. export def ApplyCodeAction(lspserver: dict, actionlist: list>, query: string): void var actions = actionlist @@ -106,7 +117,7 @@ export def ApplyCodeAction(lspserver: dict, actionlist: list>, qu }, }) else - choice = inputlist(["Code action:"] + text) + choice = inputlist(['Code action:'] + text) endif if choice < 1 || choice > text->len() diff --git a/autoload/lsp/completion.vim b/autoload/lsp/completion.vim index 5c6554e..841ec0f 100644 --- a/autoload/lsp/completion.vim +++ b/autoload/lsp/completion.vim @@ -142,7 +142,7 @@ export def CompletionReply(lspserver: dict, cItems: any) endif if completeItems->len() == 1 - && getline('.')->matchstr(completeItems[0].word .. '\>') != '' + && getline('.')->matchstr($'{completeItems[0].word}\>') != '' # only one complete match. No need to show the completion popup return endif diff --git a/autoload/lsp/diag.vim b/autoload/lsp/diag.vim index 84a41c4..4382c4a 100644 --- a/autoload/lsp/diag.vim +++ b/autoload/lsp/diag.vim @@ -257,14 +257,14 @@ export def ShowCurrentDiagInStatusLine(lspserver: dict) if !diag->empty() # 15 is a enough length not to cause line break var max_width = &columns - 15 - var code = "" + var code = '' if diag->has_key('code') code = $'[{diag.code}] ' endif - var msgNoLineBreak = code .. substitute(substitute(diag.message, "\n", " ", ""), "\\n", " ", "") + var msgNoLineBreak = code .. substitute(substitute(diag.message, "\n", ' ', ''), "\\n", ' ', '') echo msgNoLineBreak[ : max_width] else - echo "" + echo '' endif enddef diff --git a/autoload/lsp/handlers.vim b/autoload/lsp/handlers.vim index 70d56c8..16290d4 100644 --- a/autoload/lsp/handlers.vim +++ b/autoload/lsp/handlers.vim @@ -214,9 +214,9 @@ export def ProcessMessages(lspserver: dict): 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 ..= $', data = {msg.error.data->string()}' endif util.ErrMsg($'Error(LSP): request {req.method} failed ({emsg})') endif diff --git a/autoload/lsp/lsp.vim b/autoload/lsp/lsp.vim index 990a94e..827b7bc 100644 --- a/autoload/lsp/lsp.vim +++ b/autoload/lsp/lsp.vim @@ -81,7 +81,7 @@ enddef # Show information about all the LSP servers export def ShowServers() for [ftype, lspserver] in ftypeServerMap->items() - var msg = ftype .. " " + var msg = $'{ftype} ' if lspserver.running msg ..= 'running' else @@ -299,7 +299,7 @@ export def AddFile(bnr: number): void endif # Skip remote files - if util.LspUriRemote(bnr->bufname()->fnamemodify(":p")) + if util.LspUriRemote(bnr->bufname()->fnamemodify(':p')) return endif @@ -730,7 +730,7 @@ export def SymbolSearch(queryArg: string) var query: string = queryArg if query == '' - query = input("Lookup symbol: ", expand('')) + query = input('Lookup symbol: ', expand('')) if query == '' return endif @@ -759,7 +759,7 @@ export def AddWorkspaceFolder(dirArg: string) var dirName: string = dirArg if dirName == '' - dirName = input("Add Workspace Folder: ", getcwd(), 'dir') + dirName = input('Add Workspace Folder: ', getcwd(), 'dir') if dirName == '' return endif @@ -782,7 +782,7 @@ export def RemoveWorkspaceFolder(dirArg: string) var dirName: string = dirArg if dirName == '' - dirName = input("Remove Workspace Folder: ", getcwd(), 'dir') + dirName = input('Remove Workspace Folder: ', getcwd(), 'dir') if dirName == '' return endif diff --git a/autoload/lsp/lspserver.vim b/autoload/lsp/lspserver.vim index 0f6385b..7d9fc77 100644 --- a/autoload/lsp/lspserver.vim +++ b/autoload/lsp/lspserver.vim @@ -481,7 +481,7 @@ enddef # Stop a LSP server def StopServer(lspserver: dict): number if !lspserver.running - util.WarnMsg("LSP server is not running") + util.WarnMsg('LSP server is not running') return 0 endif @@ -563,7 +563,7 @@ def SendResponse(lspserver: dict, request: dict, result: any, error: d && (request.id->trim() =~ '[^[:digit:]]\+' || request.id->trim() == '')) || (request.id->type() != v:t_string && request.id->type() != v:t_number) - util.ErrMsg("Error: request.id of response to LSP server is not a correct number") + util.ErrMsg('Error: request.id of response to LSP server is not a correct number') return endif var resp: dict = lspserver.createResponse( @@ -625,9 +625,9 @@ def Rpc(lspserver: dict, method: string, params: any): dict if reply->has_key('error') # request failed var emsg: string = reply.error.message - emsg ..= ', code = ' .. reply.error.code + emsg ..= $', code = {reply.error.code}' if reply.error->has_key('data') - emsg ..= ', data = ' .. reply.error.data->string() + emsg ..= $', data = {reply.error.data->string()}' endif util.ErrMsg($'Error(LSP): request {method} failed ({emsg})') endif @@ -813,7 +813,7 @@ enddef def GetCompletion(lspserver: dict, triggerKind_arg: number, triggerChar: string): void # Check whether LSP server supports completion if !lspserver.isCompletionProvider - util.ErrMsg("Error: LSP server does not support completion") + util.ErrMsg('Error: LSP server does not support completion') return endif @@ -838,7 +838,7 @@ enddef def ResolveCompletion(lspserver: dict, item: dict): void # Check whether LSP server supports completion item resolve if !lspserver.isCompletionResolveProvider - util.ErrMsg("Error: LSP server does not support completion item resolve") + util.ErrMsg('Error: LSP server does not support completion item resolve') return endif @@ -903,7 +903,7 @@ enddef def GotoDefinition(lspserver: dict, peek: bool, cmdmods: string) # Check whether LSP server supports jumping to a definition if !lspserver.isDefinitionProvider - util.ErrMsg("Error: Jumping to a symbol definition is not supported") + util.ErrMsg('Error: Jumping to a symbol definition is not supported') return endif @@ -917,7 +917,7 @@ enddef def GotoDeclaration(lspserver: dict, peek: bool, cmdmods: string) # Check whether LSP server supports jumping to a declaration if !lspserver.isDeclarationProvider - util.ErrMsg("Error: Jumping to a symbol declaration is not supported") + util.ErrMsg('Error: Jumping to a symbol declaration is not supported') return endif @@ -931,7 +931,7 @@ enddef def GotoTypeDef(lspserver: dict, peek: bool, cmdmods: string) # Check whether LSP server supports jumping to a type definition if !lspserver.isTypeDefinitionProvider - util.ErrMsg("Error: Jumping to a symbol type definition is not supported") + util.ErrMsg('Error: Jumping to a symbol type definition is not supported') return endif @@ -945,7 +945,7 @@ enddef def GotoImplementation(lspserver: dict, peek: bool, cmdmods: string) # Check whether LSP server supports jumping to a implementation if !lspserver.isImplementationProvider - util.ErrMsg("Error: Jumping to a symbol implementation is not supported") + util.ErrMsg('Error: Jumping to a symbol implementation is not supported') return endif @@ -983,7 +983,7 @@ enddef def ShowSignature(lspserver: dict): void # Check whether LSP server supports signature help if !lspserver.isSignatureHelpProvider - util.ErrMsg("Error: LSP server does not support signature help") + util.ErrMsg('Error: LSP server does not support signature help') return endif @@ -1031,7 +1031,7 @@ enddef def ShowReferences(lspserver: dict, peek: bool): void # Check whether LSP server supports getting reference information if !lspserver.isReferencesProvider - util.ErrMsg("Error: LSP server does not support showing references") + util.ErrMsg('Error: LSP server does not support showing references') return endif @@ -1089,7 +1089,7 @@ enddef def DocHighlight(lspserver: dict): void # Check whether LSP server supports getting highlight information if !lspserver.isDocumentHighlightProvider - util.ErrMsg("Error: LSP server does not support document highlight") + util.ErrMsg('Error: LSP server does not support document highlight') return endif @@ -1105,7 +1105,7 @@ enddef def GetDocSymbols(lspserver: dict, fname: string): void # Check whether LSP server supports getting document symbol information if !lspserver.isDocumentSymbolProvider - util.ErrMsg("Error: LSP server does not support getting list of symbols") + util.ErrMsg('Error: LSP server does not support getting list of symbols') return endif @@ -1125,7 +1125,7 @@ def TextDocFormat(lspserver: dict, fname: string, rangeFormat: bool, start_lnum: number, end_lnum: number) # Check whether LSP server supports formatting documents if !lspserver.isDocumentFormattingProvider - util.ErrMsg("Error: LSP server does not support formatting documents") + util.ErrMsg('Error: LSP server does not support formatting documents') return endif @@ -1207,7 +1207,7 @@ enddef def IncomingCalls(lspserver: dict, fname: string) # Check whether LSP server supports call hierarchy if !lspserver.isCallHierarchyProvider - util.ErrMsg("Error: LSP server does not support call hierarchy") + util.ErrMsg('Error: LSP server does not support call hierarchy') return endif @@ -1230,7 +1230,7 @@ enddef def OutgoingCalls(lspserver: dict, fname: string) # Check whether LSP server supports call hierarchy if !lspserver.isCallHierarchyProvider - util.ErrMsg("Error: LSP server does not support call hierarchy") + util.ErrMsg('Error: LSP server does not support call hierarchy') return endif @@ -1254,7 +1254,7 @@ enddef def InlayHintsShow(lspserver: dict) # Check whether LSP server supports type hierarchy if !lspserver.isInlayHintProvider && !lspserver.isClangdInlayHintsProvider - util.ErrMsg("Error: LSP server does not support inlay hint") + util.ErrMsg('Error: LSP server does not support inlay hint') return endif @@ -1285,7 +1285,7 @@ enddef def TypeHiearchy(lspserver: dict, direction: number) # Check whether LSP server supports type hierarchy if !lspserver.isTypeHierarchyProvider - util.ErrMsg("Error: LSP server does not support type hierarchy") + util.ErrMsg('Error: LSP server does not support type hierarchy') return endif @@ -1310,7 +1310,7 @@ enddef def RenameSymbol(lspserver: dict, newName: string) # Check whether LSP server supports rename operation if !lspserver.isRenameProvider - util.ErrMsg("Error: LSP server does not support rename operation") + util.ErrMsg('Error: LSP server does not support rename operation') return endif @@ -1338,7 +1338,7 @@ def CodeAction(lspserver: dict, fname_arg: string, line1: number, line2: number, query: string) # Check whether LSP server supports code action operation if !lspserver.isCodeActionProvider - util.ErrMsg("Error: LSP server does not support code action operation") + util.ErrMsg('Error: LSP server does not support code action operation') return endif @@ -1377,7 +1377,7 @@ enddef def WorkspaceQuerySymbols(lspserver: dict, query: string) # Check whether the LSP server supports listing workspace symbols if !lspserver.isWorkspaceSymbolProvider - util.ErrMsg("Error: LSP server does not support listing workspace symbols") + util.ErrMsg('Error: LSP server does not support listing workspace symbols') return endif @@ -1446,7 +1446,7 @@ enddef def SelectionRange(lspserver: dict, fname: string) # Check whether LSP server supports selection ranges if !lspserver.isSelectionRangeProvider - util.ErrMsg("Error: LSP server does not support selection ranges") + util.ErrMsg('Error: LSP server does not support selection ranges') return endif @@ -1472,7 +1472,7 @@ enddef def SelectionExpand(lspserver: dict) # Check whether LSP server supports selection ranges if !lspserver.isSelectionRangeProvider - util.ErrMsg("Error: LSP server does not support selection ranges") + util.ErrMsg('Error: LSP server does not support selection ranges') return endif @@ -1483,7 +1483,7 @@ enddef def SelectionShrink(lspserver: dict) # Check whether LSP server supports selection ranges if !lspserver.isSelectionRangeProvider - util.ErrMsg("Error: LSP server does not support selection ranges") + util.ErrMsg('Error: LSP server does not support selection ranges') return endif @@ -1496,7 +1496,7 @@ enddef def FoldRange(lspserver: dict, fname: string) # Check whether LSP server supports fold ranges if !lspserver.isFoldingRangeProvider - util.ErrMsg("Error: LSP server does not support folding") + util.ErrMsg('Error: LSP server does not support folding') return endif diff --git a/autoload/lsp/markdown.vim b/autoload/lsp/markdown.vim index 0c8f7d1..7c0ca0f 100644 --- a/autoload/lsp/markdown.vim +++ b/autoload/lsp/markdown.vim @@ -194,7 +194,7 @@ enddef def GetNextInlineBlock(text: string, blocks: list, rel_pos: number): dict var result = { - text: "", + text: '', props: [] } var cur = blocks->remove(0) @@ -227,7 +227,7 @@ enddef def ParseInlines(text: string, rel_pos: number = 0): dict var formatted = { - text: "", + text: '', props: [] } var code_spans = GetCodeSpans(text) @@ -341,13 +341,13 @@ enddef def CreateContainerBlock(match: list, start_lnum: number): dict if match[0][0] == '>' return { - type: "quote_block", + type: 'quote_block', lnum: start_lnum, indent: 0 } else return { - type: "list_item", + type: 'list_item', lnum: start_lnum, marker: $' {match[0]->matchstr("\\S\\+")} ', indent: match[2] @@ -357,7 +357,7 @@ enddef # new open leaf block def CreateLeafBlock(block_type: string, line: string, ...opt: list): dict - if block_type == "fenced_code" + if block_type == 'fenced_code' var token = line->matchlist(code_fence) return { type: block_type, @@ -365,23 +365,23 @@ def CreateLeafBlock(block_type: string, line: string, ...opt: list): dictmatchstr(code_indent)] } - elseif block_type == "paragraph" + elseif block_type == 'paragraph' return { type: block_type, text: [line->matchstr(paragraph)] } - elseif block_type == "heading" + elseif block_type == 'heading' return { type: block_type, level: opt[0], text: line } - elseif block_type == "table" + elseif block_type == 'table' return { type: block_type, header: line, @@ -393,11 +393,11 @@ def CreateLeafBlock(block_type: string, line: string, ...opt: list): dict>, blocks: list>, start: number = 0): void if start >= blocks->len() return endif var line: dict = { - text: "", + text: '', props: [] } if !document.content->empty() && NeedBlankLine(last_block, blocks[0].type) - document.content->add({text: "", props: []}) + document.content->add({text: '', props: []}) endif last_block = blocks[0].type for i in start->range() - if blocks[i]->has_key("marker") + if blocks[i]->has_key('marker') if blocks[i].marker =~ '\S' line.props->add(GetMarkerProp('list_item', line.text->len() + 1, @@ -435,7 +435,7 @@ def CloseBlocks(document: dict>, blocks: list>, start: numbe endfor for block in blocks->remove(start, -1) if block.type =~ 'quote_block\|list_item' - if block->has_key("marker") + if block->has_key('marker') if block.marker =~ '\S' line.props->add(GetMarkerProp('list_item', line.text->len() + 1, @@ -449,7 +449,7 @@ def CloseBlocks(document: dict>, blocks: list>, start: numbe else # leaf block if block.type =~ '_code' - if block.type == "indented_code" + if block.type == 'indented_code' while !block.text->empty() && block.text[0] !~ '\S' block.text->remove(0) endwhile @@ -479,7 +479,7 @@ def CloseBlocks(document: dict>, blocks: list>, start: numbe indent->len() + max_len + 1)) endif endif - elseif block.type == "heading" + elseif block.type == 'heading' line.props->add(GetMarkerProp('heading', line.text->len() + 1, block.text->len(), @@ -488,7 +488,7 @@ def CloseBlocks(document: dict>, blocks: list>, start: numbe line.text ..= format.text line.props += line.props document.content->add(line) - elseif block.type == "table" + elseif block.type == 'table' var indent = line.text var head = block.header->split('\\\@1remove(0) @@ -504,7 +504,7 @@ def CloseBlocks(document: dict>, blocks: list>, start: numbe line.props->add(GetMarkerProp('table_header', line.text->len() + 2, format.text->len())) - line.text ..= "|" .. format.text + line.text ..= $'|{format.text}' line.props += format.props endfor document.content->add(line) @@ -530,13 +530,13 @@ def CloseBlocks(document: dict>, blocks: list>, start: numbe data.props->add(GetMarkerProp('table_sep', data.text->len() + 1, 1)) - data.text ..= "|" .. format.text + data.text ..= $'|{format.text}' data.props += format.props endfor document.content->add(data) endfor - elseif block.type == "paragraph" - var format = ParseInlines(block.text->join(" "), line.text->len()) + elseif block.type == 'paragraph' + var format = ParseInlines(block.text->join(' '), line.text->len()) line.text ..= format.text line.props += format.props document.content->add(line) @@ -555,19 +555,19 @@ export def ParseMarkdown(data: list, width: number = 80): dict # for each open block check if current line continue it while cur < open_blocks->len() - if open_blocks[cur].type == "quote_block" + if open_blocks[cur].type == 'quote_block' var marker = line->matchstrpos(block_quote) if marker[1] == -1 break endif line = line[marker[2] :] - elseif open_blocks[cur].type == "list_item" + elseif open_blocks[cur].type == 'list_item' var marker = line->matchstrpos($'^ \{{{open_blocks[cur].indent}}}') if marker[1] == -1 break endif line = line[marker[2] :] - elseif open_blocks[cur].type == "fenced_code" + elseif open_blocks[cur].type == 'fenced_code' if line =~ $'^ \{{,3}}{open_blocks[cur].fence}{open_blocks[cur].fence[0]}* *$' CloseBlocks(document, open_blocks, cur) else @@ -575,19 +575,19 @@ export def ParseMarkdown(data: list, width: number = 80): dict endif cur = -1 break - elseif open_blocks[cur].type == "indented_code" + elseif open_blocks[cur].type == 'indented_code' var marker = line->matchstrpos(code_indent) if marker[1] >= 0 open_blocks[cur].text->add(marker[0]) cur = -1 endif break - elseif open_blocks[cur].type == "paragraph" + elseif open_blocks[cur].type == 'paragraph' if line =~ setext_heading var marker = line->matchstrpos(setext_heading) open_blocks->add(CreateLeafBlock( - "heading", - open_blocks->remove(cur).text->join(" "), + 'heading', + open_blocks->remove(cur).text->join(' '), setext_heading_level[marker[0]])) CloseBlocks(document, open_blocks, cur) cur = -1 @@ -595,9 +595,9 @@ export def ParseMarkdown(data: list, width: number = 80): dict # may be a table var marker = line->matchstr(table_delimiter) if !marker->empty() - if open_blocks[cur].text[0]->split('\\\@1len() == marker->split("|")->len() + if open_blocks[cur].text[0]->split('\\\@1len() == marker->split('|')->len() open_blocks->add(CreateLeafBlock( - "table", + 'table', open_blocks->remove(cur).text[0], marker)) cur = -1 @@ -617,12 +617,12 @@ export def ParseMarkdown(data: list, width: number = 80): dict # a themaic break close all previous blocks if line =~ thematic_break CloseBlocks(document, open_blocks) - if &g:encoding == "utf-8" + if &g:encoding == 'utf-8' document.content->add({text: "\u2500"->repeat(width)}) else - document.content->add({text: "-"->repeat(width)}) + document.content->add({text: '-'->repeat(width)}) endif - last_block = "hr" + last_block = 'hr' continue endif @@ -643,45 +643,45 @@ export def ParseMarkdown(data: list, width: number = 80): dict # check for leaf block if line =~ code_fence CloseBlocks(document, open_blocks, cur) - open_blocks->add(CreateLeafBlock("fenced_code", line)) + open_blocks->add(CreateLeafBlock('fenced_code', line)) elseif line =~ blank_line if open_blocks->empty() continue endif - if open_blocks[-1].type == "paragraph" + if open_blocks[-1].type == 'paragraph' CloseBlocks(document, open_blocks, min([cur, open_blocks->len() - 1])) - elseif open_blocks[-1].type == "table" + elseif open_blocks[-1].type == 'table' CloseBlocks(document, open_blocks, open_blocks->len() - 1) elseif open_blocks[-1].type =~ '_code' open_blocks[-1].text->add(line) endif elseif line =~ code_indent if open_blocks->empty() - open_blocks->add(CreateLeafBlock("indented_code", line)) + open_blocks->add(CreateLeafBlock('indented_code', line)) elseif open_blocks[-1].type =~ '_code' open_blocks[-1].text->add(line->matchstr(code_indent)) - elseif open_blocks[-1].type == "paragraph" + elseif open_blocks[-1].type == 'paragraph' open_blocks[-1].text->add(line->matchstr(paragraph)) else CloseBlocks(document, open_blocks, cur) - open_blocks->add(CreateLeafBlock("indented_code", line)) + open_blocks->add(CreateLeafBlock('indented_code', line)) endif elseif line =~ atx_heading CloseBlocks(document, open_blocks, cur) var token = line->matchlist(atx_heading) - open_blocks->add(CreateLeafBlock("heading", token[2], token[1]->len())) + open_blocks->add(CreateLeafBlock('heading', token[2], token[1]->len())) CloseBlocks(document, open_blocks, cur) elseif !open_blocks->empty() - if open_blocks[-1].type == "table" + if open_blocks[-1].type == 'table' open_blocks[-1].text->add(line) - elseif open_blocks[-1].type == "paragraph" + elseif open_blocks[-1].type == 'paragraph' open_blocks[-1].text->add(line->matchstr(paragraph)) else CloseBlocks(document, open_blocks, cur) - open_blocks->add(CreateLeafBlock("paragraph", line)) + open_blocks->add(CreateLeafBlock('paragraph', line)) endif else - open_blocks->add(CreateLeafBlock("paragraph", line)) + open_blocks->add(CreateLeafBlock('paragraph', line)) endif endfor diff --git a/autoload/lsp/selection.vim b/autoload/lsp/selection.vim index 8ee1a9b..51467f1 100644 --- a/autoload/lsp/selection.vim +++ b/autoload/lsp/selection.vim @@ -66,8 +66,8 @@ export def SelectionModify(lspserver: dict, expand: bool) # reply for this buffer is available. Modify the current selection. var selRange: dict = lspserver.selection.selRange - var startpos: list = getcharpos("v") - var endpos: list = getcharpos(".") + var startpos: list = getcharpos('v') + var endpos: list = getcharpos('.') var idx: number = lspserver.selection.index # Locate the range in the LSP reply for the current selection diff --git a/autoload/lsp/symbol.vim b/autoload/lsp/symbol.vim index 6bddbff..89e498f 100644 --- a/autoload/lsp/symbol.vim +++ b/autoload/lsp/symbol.vim @@ -138,7 +138,7 @@ def ShowSymbolMenu(lspserver: dict, query: string) maxwidth: 60, mapping: false, fixed: 1, - close: "button", + close: 'button', filter: function(FilterSymbols, [lspserver]), callback: JumpToWorkspaceSymbol } diff --git a/autoload/lsp/textedit.vim b/autoload/lsp/textedit.vim index 061e8f9..257ec53 100644 --- a/autoload/lsp/textedit.vim +++ b/autoload/lsp/textedit.vim @@ -43,9 +43,9 @@ def Set_lines(lines: list, A: list, B: list, #util.WarnMsg("set_lines: Invalid range, A = " .. A->string() # .. ", B = " .. B->string() .. ", numlines = " .. numlines # .. ", new lines = " .. new_lines->string()) - var msg = "set_lines: Invalid range, A = " .. A->string() - msg ..= ", B = " .. B->string() .. ", numlines = " .. numlines - msg ..= ", new lines = " .. new_lines->string() + var msg = $"set_lines: Invalid range, A = {A->string()}" + msg ..= $", B = {B->string()}, numlines = {numlines}" + msg ..= $", new lines = {new_lines->string()}" util.WarnMsg(msg) return lines endif @@ -59,7 +59,7 @@ def Set_lines(lines: list, A: list, B: list, var new_lines_len: number = new_lines->len() - #echomsg 'i_0 = ' .. i_0 .. ', i_n = ' .. i_n .. ', new_lines = ' .. string(new_lines) + #echomsg $"i_0 = {i_0}, i_n = {i_n}, new_lines = {string(new_lines)}" var n: number = i_n - i_0 + 1 if n != new_lines_len if n > new_lines_len @@ -71,26 +71,26 @@ def Set_lines(lines: list, A: list, B: list, lines->extend(repeat([''], new_lines_len - n), i_0) endif endif - #echomsg "lines(1) = " .. string(lines) + #echomsg $"lines(1) = {string(lines)}" # replace the previous lines with the new lines for i in new_lines_len->range() lines[i_0 + i] = new_lines[i] endfor - #echomsg "lines(2) = " .. string(lines) + #echomsg $"lines(2) = {string(lines)}" # append the suffix (if any) to the last line if suffix != '' var i = i_0 + new_lines_len - 1 lines[i] = lines[i] .. suffix endif - #echomsg "lines(3) = " .. string(lines) + #echomsg $"lines(3) = {string(lines)}" # prepend the prefix (if any) to the first line if prefix != '' lines[i_0] = prefix .. lines[i_0] endif - #echomsg "lines(4) = " .. string(lines) + #echomsg $"lines(4) = {string(lines)}" return lines enddef @@ -142,7 +142,7 @@ export def ApplyTextEdits(bnr: number, text_edits: list>): void lines->add('') endif - #echomsg 'lines(1) = ' .. string(lines) + #echomsg $'lines(1) = {string(lines)}' #echomsg updated_edits for e in updated_edits @@ -151,15 +151,15 @@ export def ApplyTextEdits(bnr: number, text_edits: list>): void lines = Set_lines(lines, A, B, e.lines) endfor - #echomsg 'lines(2) = ' .. string(lines) + #echomsg $'lines(2) = {string(lines)}' # If the last line is empty and we need to set EOL, then remove it. if set_eol && lines[-1]->len() == 0 lines->remove(-1) endif - #echomsg 'ApplyTextEdits: start_line = ' .. start_line .. ', finish_line = ' .. finish_line - #echomsg 'lines = ' .. string(lines) + #echomsg $'ApplyTextEdits: start_line = {start_line}, finish_line = {finish_line}' + #echomsg $'lines = {string(lines)}' # Delete all the lines that need to be modified bnr->deletebufline(start_line + 1, finish_line + 1) diff --git a/autoload/lsp/typehierarchy.vim b/autoload/lsp/typehierarchy.vim index 510a446..d4048e6 100644 --- a/autoload/lsp/typehierarchy.vim +++ b/autoload/lsp/typehierarchy.vim @@ -50,7 +50,7 @@ def TypeTreeGenerate(super: bool, typeHier: dict, pfx_arg: string, items = super ? typeHier.parents : typeHier.children for item in items - TypeTreeGenerate(super, item, pfx_arg .. '| ', typeTree, typeUriMap) + TypeTreeGenerate(super, item, $'{pfx_arg}| ', typeTree, typeUriMap) endfor enddef -- 2.48.1