RRethy / vim-illuminate

illuminate.vim - (Neo)Vim plugin for automatically highlighting other uses of the word under the cursor using either LSP, Tree-sitter, or regex matching.
2.23k stars 53 forks source link

Could i get the index of current reference? #197

Closed ShiChenCong closed 8 months ago

ShiChenCong commented 8 months ago

Like this: [4/5]

RRethy commented 8 months ago
    local ref = require('illuminate.reference')
    local util = require('illuminate.util')
    local cursor_pos = util.get_cursor_pos(winid)
    local i = ref.bisect_left(ref.buf_get_references(bufnr), cursor_pos)
    print(string.format("[%d/%d]", i, #ref.buf_get_references(bufnr)))