enddef
# Go to a definition using "textDocument/definition" LSP request
-export def GotoDefinition(peek: bool, cmdmods: string)
+export def GotoDefinition(peek: bool, cmdmods: string, count: number)
var lspserver: dict<any> = buf.CurbufGetServerChecked('definition')
if lspserver->empty()
return
endif
- lspserver.gotoDefinition(peek, cmdmods)
+ lspserver.gotoDefinition(peek, cmdmods, count)
enddef
# Go to a declaration using "textDocument/declaration" LSP request
-export def GotoDeclaration(peek: bool, cmdmods: string)
+export def GotoDeclaration(peek: bool, cmdmods: string, count: number)
var lspserver: dict<any> = buf.CurbufGetServerChecked('declaration')
if lspserver->empty()
return
endif
- lspserver.gotoDeclaration(peek, cmdmods)
+ lspserver.gotoDeclaration(peek, cmdmods, count)
enddef
# Go to a type definition using "textDocument/typeDefinition" LSP request
-export def GotoTypedef(peek: bool, cmdmods: string)
+export def GotoTypedef(peek: bool, cmdmods: string, count: number)
var lspserver: dict<any> = buf.CurbufGetServerChecked('typeDefinition')
if lspserver->empty()
return
endif
- lspserver.gotoTypeDef(peek, cmdmods)
+ lspserver.gotoTypeDef(peek, cmdmods, count)
enddef
# Go to a implementation using "textDocument/implementation" LSP request
-export def GotoImplementation(peek: bool, cmdmods: string)
+export def GotoImplementation(peek: bool, cmdmods: string, count: number)
var lspserver: dict<any> = buf.CurbufGetServerChecked('implementation')
if lspserver->empty()
return
endif
- lspserver.gotoImplementation(peek, cmdmods)
+ lspserver.gotoImplementation(peek, cmdmods, count)
enddef
# Switch source header using "textDocument/switchSourceHeader" LSP request
#
# Result: Location | Location[] | LocationLink[] | null
def GotoSymbolLoc(lspserver: dict<any>, msg: string, peekSymbol: bool,
- cmdmods: string)
+ cmdmods: string, count: number)
var reply = lspserver.rpc(msg, GetLspTextDocPosition(true), false)
if reply->empty() || reply.result->empty()
var emsg: string
var location: dict<any>
if reply.result->type() == v:t_list
- # When there are multiple symbol locations, display the locations in a
- # location list.
- if reply.result->len() > 1
- var title: string = ''
- if msg ==# 'textDocument/declaration'
- title = 'Declarations'
- elseif msg ==# 'textDocument/typeDefinition'
- title = 'Type Definitions'
- elseif msg ==# 'textDocument/implementation'
- title = 'Implementations'
- else
- title = 'Definitions'
+ if count == 0
+ # When there are multiple symbol locations, and a specific one isn't
+ # requested with 'count', display the locations in a location list.
+ if reply.result->len() > 1
+ var title: string = ''
+ if msg ==# 'textDocument/declaration'
+ title = 'Declarations'
+ elseif msg ==# 'textDocument/typeDefinition'
+ title = 'Type Definitions'
+ elseif msg ==# 'textDocument/implementation'
+ title = 'Implementations'
+ else
+ title = 'Definitions'
+ endif
+
+ symbol.ShowLocations(lspserver, reply.result, peekSymbol, title)
+ return
endif
-
- symbol.ShowLocations(lspserver, reply.result, peekSymbol, title)
- return
endif
- # Only one location
- location = reply.result[0]
+ # Select the location requsted in 'count'
+ var idx = count - 1
+ if idx >= reply.result->len()
+ idx = reply.result->len() - 1
+ endif
+ location = reply.result[idx]
else
location = reply.result
endif
# Request: "textDocument/definition"
# Param: DefinitionParams
-def GotoDefinition(lspserver: dict<any>, peek: bool, cmdmods: string)
+def GotoDefinition(lspserver: dict<any>, peek: bool, cmdmods: string, count: number)
# Check whether LSP server supports jumping to a definition
if !lspserver.isDefinitionProvider
util.ErrMsg('Jumping to a symbol definition is not supported')
# interface DefinitionParams
# interface TextDocumentPositionParams
- GotoSymbolLoc(lspserver, 'textDocument/definition', peek, cmdmods)
+ GotoSymbolLoc(lspserver, 'textDocument/definition', peek, cmdmods, count)
enddef
# Request: "textDocument/declaration"
# Param: DeclarationParams
-def GotoDeclaration(lspserver: dict<any>, peek: bool, cmdmods: string)
+def GotoDeclaration(lspserver: dict<any>, peek: bool, cmdmods: string, count: number)
# Check whether LSP server supports jumping to a declaration
if !lspserver.isDeclarationProvider
util.ErrMsg('Jumping to a symbol declaration is not supported')
# interface DeclarationParams
# interface TextDocumentPositionParams
- GotoSymbolLoc(lspserver, 'textDocument/declaration', peek, cmdmods)
+ GotoSymbolLoc(lspserver, 'textDocument/declaration', peek, cmdmods, count)
enddef
# Request: "textDocument/typeDefinition"
# Param: TypeDefinitionParams
-def GotoTypeDef(lspserver: dict<any>, peek: bool, cmdmods: string)
+def GotoTypeDef(lspserver: dict<any>, peek: bool, cmdmods: string, count: number)
# Check whether LSP server supports jumping to a type definition
if !lspserver.isTypeDefinitionProvider
util.ErrMsg('Jumping to a symbol type definition is not supported')
# interface TypeDefinitionParams
# interface TextDocumentPositionParams
- GotoSymbolLoc(lspserver, 'textDocument/typeDefinition', peek, cmdmods)
+ GotoSymbolLoc(lspserver, 'textDocument/typeDefinition', peek, cmdmods, count)
enddef
# Request: "textDocument/implementation"
# Param: ImplementationParams
-def GotoImplementation(lspserver: dict<any>, peek: bool, cmdmods: string)
+def GotoImplementation(lspserver: dict<any>, peek: bool, cmdmods: string, count: number)
# Check whether LSP server supports jumping to a implementation
if !lspserver.isImplementationProvider
util.ErrMsg('Jumping to a symbol implementation is not supported')
# interface ImplementationParams
# interface TextDocumentPositionParams
- GotoSymbolLoc(lspserver, 'textDocument/implementation', peek, cmdmods)
+ GotoSymbolLoc(lspserver, 'textDocument/implementation', peek, cmdmods, count)
enddef
# Request: "textDocument/switchSourceHeader"
file using the language server.
*:LspGotoDeclaration*
-:LspGotoDeclaration Jumps to the declaration of the symbol under the
+:[count]LspGotoDeclaration
+ Jumps to the declaration of the symbol under the
cursor. The behavior of this command is similar to the
|:LspGotoDefinition| command.
*:LspGotoDefinition*
-:LspGotoDefinition Jumps to the definition of the symbol under the
- cursor.
+:[count]LspGotoDefinition
+ Jumps to the [count] definition of the symbol under the
+ cursor. If there are multiple matches and [count] isn't
+ specified, then a location list will be created with the
+ list of locations.
- If there are multiple matches, then a location list will
- be created with the list of locations.
-
- If there is only one location then the following will
- apply:
+ If there is only one location, or [count] is provided
+ then the following will apply:
If the file is already present in a window, then jumps
to that window. Otherwise, opens the file in a new
nnoremap <buffer> <C-W>gd <Cmd>topleft LspGotoDefinition<CR>
<
*:LspGotoImpl*
-:LspGotoImpl Jumps to the implementation of the symbol under the
+:[count]LspGotoImpl Jumps to the implementation of the symbol under the
cursor. The behavior of this command is similar to the
|:LspGotoDefinition| command. Note that not all the
language servers support this feature.
nnoremap <buffer> gi <Cmd>LspGotoImpl<CR>
<
*:LspGotoTypeDef*
-:LspGotoTypeDef Jumps to the type definition of the symbol under the
+:[count]LspGotoTypeDef Jumps to the type definition of the symbol under the
cursor. The behavior of this command is similar to the
|:LspGotoDefinition| command. Note that not all the
language servers support this feature.
:vert aboveleft 50LspOutline
<
*:LspPeekDeclaration*
-:LspPeekDeclaration Displays the line where the symbol under the
+:[count]LspPeekDeclaration
+ Displays the line where the symbol under the
cursor is declared in a popup window. The
behavior of this command is similar to the
|:LspPeekDefinition| command.
*:LspPeekDefinition*
-:LspPeekDefinition Displays the line where the symbol under the cursor is
+:[count]LspPeekDefinition
+ Displays the line where the symbol under the cursor is
defined in a popup window. The symbol is highlighted
in the popup window. Moving the cursor or pressing
<Esc> will close the popup window.
+ When more than one symbol is found all of them will be
+ shown. The corresponding file for the symbol is
+ displayed in another popup window. As the selection in
+ the symbol popup menu changes, the file in the popup is
+ updated.
+ When [count] is provided only the [count] symbol will be
+ shown.
*:LspPeekImpl*
-:LspPeekImpl Displays the implementation of the symbol under the
+:[count]LspPeekImpl Displays the implementation of the symbol under the
cursor in a popup window. The behavior of this
command is similar to the |:LspPeekDefinition|
command. Note that not all the language servers
the file in the popup is updated.
*:LspPeekTypeDef*
-:LspPeekTypeDef Displays the line where the type of the symbol under
+:[count]LspPeekTypeDef Displays the line where the type of the symbol under
the cursor is defined in a popup window. The
behavior of this command is similar to the
|:LspPeekDefinition| command. Note that not all the
command! -nargs=0 -bar LspDiagHere lsp.JumpToDiag('here')
command! -nargs=0 -bar LspFold lsp.FoldDocument()
command! -nargs=0 -bar -range=% LspFormat lsp.TextDocFormat(<range>, <line1>, <line2>)
-command! -nargs=0 -bar LspGotoDeclaration lsp.GotoDeclaration(v:false, <q-mods>)
-command! -nargs=0 -bar LspGotoDefinition lsp.GotoDefinition(v:false, <q-mods>)
-command! -nargs=0 -bar LspGotoImpl lsp.GotoImplementation(v:false, <q-mods>)
-command! -nargs=0 -bar LspGotoTypeDef lsp.GotoTypedef(v:false, <q-mods>)
+command! -nargs=0 -bar -count LspGotoDeclaration lsp.GotoDeclaration(v:false, <q-mods>, <count>)
+command! -nargs=0 -bar -count LspGotoDefinition lsp.GotoDefinition(v:false, <q-mods>, <count>)
+command! -nargs=0 -bar -count LspGotoImpl lsp.GotoImplementation(v:false, <q-mods>, <count>)
+command! -nargs=0 -bar -count LspGotoTypeDef lsp.GotoTypedef(v:false, <q-mods>, <count>)
command! -nargs=0 -bar LspHighlight call LspDocHighlight(<q-mods>)
command! -nargs=0 -bar LspHighlightClear call LspDocHighlightClear()
command! -nargs=0 -bar LspHover lsp.Hover(<q-mods>)
command! -nargs=0 -bar LspIncomingCalls lsp.IncomingCalls()
command! -nargs=0 -bar LspOutgoingCalls lsp.OutgoingCalls()
command! -nargs=0 -bar -count LspOutline lsp.Outline(<q-mods>, <count>)
-command! -nargs=0 -bar LspPeekDeclaration lsp.GotoDeclaration(v:true, <q-mods>)
-command! -nargs=0 -bar LspPeekDefinition lsp.GotoDefinition(v:true, <q-mods>)
-command! -nargs=0 -bar LspPeekImpl lsp.GotoImplementation(v:true, <q-mods>)
+command! -nargs=0 -bar -count LspPeekDeclaration lsp.GotoDeclaration(v:true, <q-mods>, <count>)
+command! -nargs=0 -bar -count LspPeekDefinition lsp.GotoDefinition(v:true, <q-mods>, <count>)
+command! -nargs=0 -bar -count LspPeekImpl lsp.GotoImplementation(v:true, <q-mods>, <count>)
command! -nargs=0 -bar LspPeekReferences lsp.ShowReferences(v:true)
-command! -nargs=0 -bar LspPeekTypeDef lsp.GotoTypedef(v:true, <q-mods>)
+command! -nargs=0 -bar -count LspPeekTypeDef lsp.GotoTypedef(v:true, <q-mods>, <count>)
command! -nargs=? -bar LspRename lsp.Rename(<q-args>)
command! -nargs=0 -bar LspSelectionExpand lsp.SelectionExpand()
command! -nargs=0 -bar LspSelectionShrink lsp.SelectionShrink()