setcursorcharpos(symTbl[result - 1].pos.line + 1,
util.GetCharIdxWithoutCompChar(bufnr(),
symTbl[result - 1].pos) + 1)
+ :normal! zv
catch
# ignore exceptions
endtry
var w: number = &columns
var fnamelen = float2nr(w * 0.4)
+ var curlnum = line('.')
+ var symIdx = 1
+ var curSymIdx = 1
var menuItems: list<string> = []
for loc in locations
var [uri, range] = util.LspLocationParse(loc)
var lnum = range.start.line + 1
var text: string = bnr->getbufline(lnum)->get(0, '')
menuItems->add($'{lnum}: {text}')
+
+ if lnum == curlnum
+ curSymIdx = symIdx
+ endif
+ symIdx += 1
endfor
var popupAttrs = {
callback: function(LocPopupCallback, [lspserver, locations])
}
lspserver.peekSymbolPopup = popup_menu(menuItems, popupAttrs)
+ # Select the current symbol in the menu
+ var cmds =<< trim eval END
+ [{curSymIdx}, 1]->cursor()
+ END
+ win_execute(lspserver.peekSymbolPopup, cmds, 'silent!')
UpdatePeekFilePopup(lspserver, locations)
enddef
# Jump to the selected symbol location
var r = symTblFiltered[result - 1].selectionRange
+ if r->empty()
+ # SymbolInformation doesn't have the selectionRange field
+ r = symTblFiltered[result - 1].range
+ endif
setcursorcharpos(r.start.line + 1,
- util.GetCharIdxWithoutCompChar(bufnr(), r.start) + 1)
+ util.GetCharIdxWithoutCompChar(bufnr(), r.start) + 1)
+ :normal! zv
endif
symInputPopup->popup_close()
prop_remove({type: 'LspSymbolNameProp', all: true})
assert_match('XshowRefs', filePopupAttrs.title)
assert_equal('Symbol References', refPopupAttrs.title)
assert_equal(10, line('.', ids[0]))
+ assert_equal(1, line('.', ids[1]))
assert_equal(3, line('$', ids[1]))
feedkeys("jj\<CR>", 'xt')
assert_equal(12, line('.'))
assert_equal([], popup_list())
popup_clear()
+ # LspShowReferences should start with the current symbol
+ cursor(12, 6)
+ :LspPeekReferences
+ sleep 50m
+ ids = popup_list()
+ assert_equal(2, ids->len())
+ assert_equal(12, line('.', ids[0]))
+ assert_equal(3, line('.', ids[1]))
+ feedkeys("\<CR>", 'xt')
+ popup_clear()
+
bw!
# empty file