Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: support find tabs. like leaderf buffer #1108

Open
2 of 6 tasks
gulu-star opened this issue Nov 27, 2024 · 1 comment
Open
2 of 6 tasks

Feature: support find tabs. like leaderf buffer #1108

gulu-star opened this issue Nov 27, 2024 · 1 comment

Comments

@gulu-star
Copy link

  • vim or neovim?
    • vim

    • neovim

    • Linux

    • Mac OS X

    • Windows

    • Etc.

  • Configurations related to LeaderF in vimrc:

Describe your question, feature request, or bug.

feature: I hope to be able to directly search and jump to the corresponding tab by its name

Steps to reproduce

Actual behaviour

Expected behaviour

@gulu-star
Copy link
Author

I want to write a extension, but I don't know how to implement preview. I haven't written any plugins before, this was written with the help of GPT

function! leaderf#showtab#source(args) abort "{{{
    let tab_list = []
    let current_tab = tabpagenr()    

    for tabinfo in gettabinfo()
        let tab_num = tabinfo.tabnr
        let buf_name = bufname(tabinfo.windows[0])
        if buf_name == '' 
            let buf_name = '[No Name]'   
        endif
        let tab_name = printf("%d: %s", tab_num, buf_name)
        call add(tab_list, tab_name)
    endfor
    
    return tab_list
endfunction "}}}


function! leaderf#showtab#accept(line, args) abort "{{{
    let match = matchstr(a:line, '^\d\+')
    if match != ''
        let tab_num = str2nr(match)
        if tab_num > 0 && tab_num <= tabpagenr('$')
            execute 'tabnext' tab_num
        else
            echo "Invalid tab number: " . tab_num
        endif
    endif
endfunction "}}}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant