voldikss / vim-floaterm

:computer: Terminal manager for (neo)vim
MIT License
2.46k stars 79 forks source link

Use haslocaldir() to choose which flavor of cd to use #415

Closed vais closed 10 months ago

vais commented 10 months ago
haslocaldir([{winnr} [, {tabnr}]])          *haslocaldir()*
        The result is a Number:
            1   when the window has set a local directory via |:lcd|
            2   when the tab-page has set a local directory via |:tcd|
            0   otherwise.

        Without arguments use the current window.
        With {winnr} use this window in the current tab page.
        With {winnr} and {tabnr} use the window in the specified tab
        page.
        {winnr} can be the window number or the |window-ID|.
        If {winnr} is -1 it is ignored and only the tabpage is used.
        Return 0 if the arguments are invalid.
        Examples: >
            if haslocaldir() == 1
              " window local directory case
            elseif haslocaldir() == 2
              " tab-local directory case
            else
              " global directory case
            endif

            " current window
            :echo haslocaldir()
            :echo haslocaldir(0)
            :echo haslocaldir(0, 0)
            " window n in current tab page
            :echo haslocaldir(n)
            :echo haslocaldir(n, 0)
            " window n in tab page m
            :echo haslocaldir(n, m)
            " tab page m
            :echo haslocaldir(-1, m)
voldikss commented 10 months ago

Awesome!