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

Do not open tab when current tab is empty #29

Open
fedorenchik opened this issue May 27, 2020 · 1 comment
Open

Do not open tab when current tab is empty #29

fedorenchik opened this issue May 27, 2020 · 1 comment
Labels
enhancement New feature or request

Comments

@fedorenchik
Copy link

In a new vim instance or when new tab is opened, load Flog inside current tab (do not open new tab).

@TamaMcGlinn
Copy link
Contributor

TamaMcGlinn commented Dec 22, 2021

I think this will be more useful if it just checks if the current window is empty; i.e. it has no name and also no contents. That would make it more intuitive to open a split window beside the code and show the flog in that -> <C-W>v followed by opening flog, as well as the desired functionality of being able to open your own new tab and then open flog within that.

I also wanted to point out that this is even useful when you do want a new tab, because you may be looking at a file that is in some other git repo than your main current working dir repo. By opening a new tab first yourself, you force flog to use the current working dir, rather than the last file you were looking at.

You could just add something like this to your vimrc:

function! WindowIsEmpty() abort
  if bufname("%") == ""
    if line('$') > 1
      return 0
    endif
    return len(getline('.')) == 0
  else
    return 0
  endif
endfunction

function! OpenFlog() abort
  if WindowIsEmpty()
    call flog#open(["-open-cmd=edit"])
  else
    execute ':Flog'
  endif
endfunction

" bind to the new OpenFlog instead of `:Flog`
nnoremap <silent> <leader>gll :call OpenFlog()<CR>

@rbong rbong added the enhancement New feature or request label Jan 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants