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.12k stars 44 forks source link

Could i get the index of current reference? #197

Closed ShiChenCong closed 3 months ago

ShiChenCong commented 3 months ago

Like this: [4/5]

RRethy commented 3 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)))