From: Yegappan Lakshmanan Date: Thu, 3 Feb 2022 17:07:39 +0000 (-0800) Subject: Use global functions instead of funcref variables for LspOptionsSet() and LspServerTr... X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=165d5585375df014e6f7ffd2ef5703dedbaaa9a0;p=vim-lsp.git Use global functions instead of funcref variables for LspOptionsSet() and LspServerTraceEnable(). Rename LspCalledBy() to LspIncomingCalls() and LspCalling() to LspOutgoingCalls() --- diff --git a/README.md b/README.md index 29bbb17..08631d5 100644 --- a/README.md +++ b/README.md @@ -99,8 +99,8 @@ Command|Description :LspOutline|Show the list of symbols defined in the current file in a separate window. :LspFormat|Format the current file using the LSP server. :{range}LspFormat|Format the specified range of lines. -:LspCalledBy|Display the list of symbols called by the current symbol. -:LspCalling|Display the list of symbols calling the current symbol. +:LspIncomingCalls|Display the list of symbols calling the current symbol. +:LspOutgoingCalls|Display the list of symbols called by the current symbol. :LspRename|Rename the current symbol :LspCodeAction|Apply the code action supplied by the LSP server to the diagnostic in the current line. :LspSymbolSearch|Perform a workspace wide search for a symbol diff --git a/autoload/handlers.vim b/autoload/handlers.vim index 43cf265..85a067b 100644 --- a/autoload/handlers.vim +++ b/autoload/handlers.vim @@ -705,9 +705,9 @@ def s:processPrepareCallHierarchy(lspserver: dict, req: dict, reply: d endif if lspserver.callHierarchyType == 'incoming' - LspGetIncomingCalls(reply.result[choice - 1]) + g:LspGetIncomingCalls(reply.result[choice - 1]) else - LspGetOutgoingCalls(reply.result[choice - 1]) + g:LspGetOutgoingCalls(reply.result[choice - 1]) endif enddef diff --git a/autoload/lspoptions.vim b/autoload/lspoptions.vim index b8ac3f2..b5bc6ce 100644 --- a/autoload/lspoptions.vim +++ b/autoload/lspoptions.vim @@ -1,7 +1,7 @@ vim9script # LSP plugin options -# User can override these by calling the LspOptionsSet() function. +# User can override these by calling the OptionsSet() function. export var lspOptions: dict = { # In insert mode, complete the current symbol automatically # Otherwise, use omni-completion @@ -35,7 +35,7 @@ export var lspOptions: dict = { } # set LSP options from user provided options -export def LspOptionsSet(opts: dict) +export def OptionsSet(opts: dict) for key in opts->keys() lspOptions[key] = opts[key] endfor diff --git a/doc/lsp.txt b/doc/lsp.txt index 8bbce82..63e6e99 100644 --- a/doc/lsp.txt +++ b/doc/lsp.txt @@ -107,10 +107,10 @@ The following commands are provided: in a separate window. :LspFormat Format the current file using the LSP server. :{range}LspFormat Format the specified range of lines. -:LspCalledBy Display the list of symbols called by the current - symbol in a new location list. -:LspCalling Display the list of symbols calling the current symbol +:LspIncomingCalls Display the list of symbols calling the current symbol in a new location list. +:LspOutgoingCalls Display the list of symbols called by the current + symbol in a new location list. :LspRename Rename the current symbol :LspCodeAction Apply the code action supplied by the LSP server to the diagnostic in the current line. @@ -383,14 +383,14 @@ diagnostic messages, you can add the following line to your .vimrc file: :{range}LspFormat Format the specified range of lines in the current file using the LSP server. - *:LspCalledBy* -:LspCalledBy Creates a new location list with the location of - the list of symbols called by the current symbol. - - *:LspCalling* -:LspCalling Creates a new location list with the location of the + *:LspIncomingCalls* +:LspIncomingCalls Creates a new location list with the location of the list of symbols calling the current symbol. + *:LspOutoingCalls* +:LspOutoingCalls Creates a new location list with the location of + the list of symbols called by the current symbol. + *:LspRename* :LspRename Rename the current symbol. You will be prompted to enter the new name for the symbol. You can press diff --git a/plugin/lsp.vim b/plugin/lsp.vim index c358d49..c9ef725 100644 --- a/plugin/lsp.vim +++ b/plugin/lsp.vim @@ -12,7 +12,7 @@ if has('patch-8.2.4257') import '../autoload/lspoptions.vim' as lspoptions import '../autoload/lsp.vim' - opt.LspOptionsSet = lspoptions.LspOptionsSet + opt.LspOptionsSet = lspoptions.OptionsSet opt.lspOptions = lspoptions.lspOptions lspf.enableServerTrace = lsp.EnableServerTrace lspf.addServer = lsp.AddServer @@ -57,7 +57,7 @@ elseif has('patch-8.2.4019') import '../autoload/lspoptions.vim' as opt_import import '../autoload/lsp.vim' as lsp_import - opt.LspOptionsSet = opt_import.LspOptionsSet + opt.LspOptionsSet = opt_import.OptionsSet opt.lspOptions = opt_import.lspOptions lspf.enableServerTrace = lsp_import.EnableServerTrace lspf.addServer = lsp_import.AddServer @@ -99,7 +99,7 @@ elseif has('patch-8.2.4019') lspf.addWorkspaceFolder = lsp_import.AddWorkspaceFolder lspf.removeWorkspaceFolder = lsp_import.RemoveWorkspaceFolder else - import {lspOptions, LspOptionsSet} from '../autoload/lspoptions.vim' + import {lspOptions, OptionsSet} from '../autoload/lspoptions.vim' import {EnableServerTrace, AddServer, ServerReady, @@ -133,7 +133,7 @@ else AddWorkspaceFolder, RemoveWorkspaceFolder} from '../autoload/lsp.vim' - opt.LspOptionsSet = LspOptionsSet + opt.LspOptionsSet = OptionsSet opt.lspOptions = lspOptions lspf.enableServerTrace = EnableServerTrace lspf.addServer = AddServer @@ -176,8 +176,13 @@ else lspf.removeWorkspaceFolder = RemoveWorkspaceFolder endif -g:LspOptionsSet = s:opt.LspOptionsSet -g:LspServerTraceEnable = s:lspf.enableServerTrace +def g:LspOptionsSet(opts: dict) + opt.LspOptionsSet(opts) +enddef + +def g:LspServerTraceEnable() + lspf.enableServerTrace() +enddef def g:LspAddServer(serverList: list>) lspf.addServer(serverList) @@ -258,8 +263,8 @@ 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(, , ) -command! -nargs=0 -bar LspCalledBy call TincomingCalls() -command! -nargs=0 -bar LspCalling call ToutgoingCalls() +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() @@ -283,8 +288,8 @@ if has('gui_running') anoremenu L&sp.Outline :LspOutline anoremenu L&sp.Symbol\ Search :LspSymbolSearch - anoremenu L&sp.CalledBy :LspCalledBy - anoremenu L&sp.Calling :LspCalling + anoremenu L&sp.Outgoing\ Calls :LspOutgoingCalls + anoremenu L&sp.Incoming\ Calls :LspIncomingCalls anoremenu L&sp.Rename :LspRename anoremenu L&sp.Code\ Action :LspCodeAction