vimpostor / vim-tpipeline

Embed your vim statusline in tmux
GNU General Public License v3.0
369 stars 11 forks source link

Tmux status-bar emptied when exiting vim #20

Closed mkdior closed 2 years ago

mkdior commented 2 years ago

As the title states, whenever exiting vim, the tmux status-bar is emptied, or retains some of the status-line information from vim. previously it'd remove both status-left and status-right, but now, as can be seen in the video, it just removes status-right and overwrites whatever's in status-left. Now I've read the readme, does this mean I have to disable tpipeline_autoembed and write my own config?

https://user-images.githubusercontent.com/2992995/147392829-4759661e-e86d-41cf-86ae-3ff61d26fadf.mov

vimpostor commented 2 years ago

does this mean I have to disable tpipeline_autoembed and write my own config?

No, the plugin should clear everything by itself automatically. This looks very weird indeed. Does your colorscheme support true color? Can you share your config or give me the output of :hi StatusLine?

previously it'd remove both status-left and status-right

What do you mean with previously? Are you saying that this plugin was working before for you and now has a regression with your config?

mkdior commented 2 years ago

Does your colorscheme support true color?

Hey, thanks for the swift reply. As far as I know my colorscheme does support true color, yes.

Can you share your config or give me the output of :hi StatusLine?

StatusLine xxx term=bold,reverse cterm=bold,reverse ctermfg=245 ctermbg=16 gui=bold,reverse guifg=#8a8a8a guibg=#000000

What do you mean with previously? Are you saying that this plugin was working before for you and now has a regression with your config?

Prior it would, upon leaving vim, completely remove status left and right, now it just adds the weird color-code to status-left, not sure what changed there, but it (my setup, not necessarily the plugin) has never really worked.

What's also super weird, not sure if you know why, but if I start vim in sudo mode, the plugin doesn't activate at all. I'm running vim version 8.2.3800.

vimpostor commented 2 years ago

I can't reproduce this if I switch to that colorscheme with my config. Can you share your vim config or at least give me the output of :set stl?

mkdior commented 2 years ago

I can't reproduce this if I switch to that colorscheme with my config. Can you share your vim config or at least give me the output of :set stl?

Hey, hope all is well, thanks so much for getting back to me.

:set stl

statusline=%{lightline#link()}%#LightlineLeft_active_0#%( %{lightline#mode()} %)%{(&paste)?"|":""}%( %{&paste?"PASTE":""} %)%#LightlineLeft_active_0_1#%#LightlineLeft_active_1#%( %R %)%{(&readonly)&&(1||(&modified||!&modifiable))?"|":
""}%( %t %)%{(&modified||!&modifiable)?"|":""}%( %M %)%#LightlineLeft_active_1_2#%#LightlineMiddle_active#%=%#LightlineRight_active_2_3#%#LightlineRight_active_2#%( %{&ff} %)%{1||1?"|":""}%( %{&fenc!=#""?&fenc:&enc} %)%{1?"|":""}%( %{&f
t!=#""?&ft:"no ft"} %)%#LightlineRight_active_1_2#%#LightlineRight_active_1#%( %3p%% %)%#LightlineRight_active_0_1#%#LightlineRight_active_0#%( %3l:%-2c %)

My config:

call plug#begin('~/.vim/plugged')
Plug 'junegunn/goyo.vim'
Plug 'honza/vim-snippets'
Plug 'neoclide/coc.nvim', {'branch': 'release'}
Plug 'wesQ3/vim-windowswap',
Plug 'fatih/vim-go',
Plug 'itchyny/lightline.vim'
Plug 'vifm/vifm.vim'
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
Plug 'junegunn/fzf.vim'
Plug 'hashivim/vim-terraform'
Plug 'vimpostor/vim-tpipeline'
call plug#end()

" Basic config:
  set nocompatible
  syntax on
  set backspace=indent,eol,start
  let mapleader =" "

" Search settings
  set ignorecase
  set smartcase
  set incsearch  " Incremental search
  set hlsearch   " Highlight search
  set showmatch  " Show matching braces

" Tabs
  set autoindent
  set smartindent
  set tabstop=2
  set softtabstop=2
  set shiftwidth=2

" Language
  map <leader>s :setlocal spell! spelllang=en_us<CR>

" General coms
  com! FormatJSON %!python -m json.tool

" Goyo settings:
  map <leader>g :Goyo <CR>

" General QOL mappings:
  map <leader>m i<++><Esc>A
  map <leader><leader> <Esc>/<++><Enter>"_c4l
  map <leader>vv :sp<space>~/.vimrc<CR>
  map <leader>aa :sp<space>~/.config/aliasrc<CR>
  map <leader>[ :tabp<CR>
  map <leader>] :tabn<CR>
  map <leader>rg :Rg<CR>

" Autmatic FT setting
  autocmd BufEnter * if &filetype == "" | setlocal ft=sh | endif

" LaTeX QOL mappings:
  autocmd FileType tex nmap <buffer> <C-p> :w<CR>:!xelatex -output-directory=../artifacts %<CR><CR>

" :Loremipsum[!] [WORDCOUNT] [PARAGRAPH_TEMPLATE] [PREFIX POSTFIX]
" makeindex test.nlo -s nomencl.ist -o test.nls >> Building Nomenclature list
  set wmh=0
  nmap <silent> <A-w> :wincmd k<CR>
  nmap <silent> <A-s> :wincmd j<CR>
  nmap <silent> <A-a> :wincmd h<CR>
  nmap <silent> <A-d> :wincmd l<CR>

  nnoremap <A-j> :m .+1<CR>==
  nnoremap <A-k> :m .-2<CR>==
  inoremap <A-j> <Esc>:m .+1<CR>==gi
  inoremap <A-k> <Esc>:m .-2<CR>==gi
  vnoremap <A-j> :m '>+1<CR>gv=gv
  vnoremap <A-k> :m '<-2<CR>gv=gv

" Move .swp files to their own directory
  set dir=~/.config/vim/swaps

" Set clipboard to +mode, which allows us to yank to systemCC
  set clipboard=unnamed

" Colorscheme
" colorscheme preto
  colorscheme 256_noir

" Change highlighting of cursor line when entering/leaving Insert Mode
" <++>
  set cursorline
  highlight CursorLine cterm=NONE ctermfg=NONE ctermbg=233 guifg=NONE guibg=#121212
  autocmd InsertEnter * highlight CursorLine cterm=NONE ctermfg=NONE ctermbg=234 guifg=NONE guibg=#1c1c1c
  autocmd InsertLeave * highlight CursorLine cterm=NONE ctermfg=NONE ctermbg=233 guifg=NONE guibg=#121212

  " Map split navigation to just CTRL h/j/k/l
  nnoremap <C-j> <C-W><C-J>
  nnoremap <C-k> <C-W><C-K>
  nnoremap <C-l> <C-W><C-L>
  nnoremap <C-h> <C-W><C-H> 

  " Save all our folds
  augroup AutoSaveGroup
  autocmd!
  " view files are about 500 bytes
  " bufleave but not bufwinleave captures closing 2nd tab
  " nested is needed by bufwrite* (if triggered via other autocmd)
  " BufHidden for compatibility with `set hidden`
  autocmd BufWinLeave,BufLeave,BufWritePost,BufHidden,QuitPre ?* nested silent! mkview!
  autocmd BufWinEnter ?* silent! loadview
  augroup end

  set viewoptions=folds,cursor
  set sessionoptions=folds

  " Coc settings
  " Having longer updatetime (default is 4000 ms = 4 s) leads to noticeable
  " delays and poor user experience.
  set updatetime=300

  " Always show the signcolumn, otherwise it would shift the text each time
  " diagnostics appear/become resolved.
  if has("patch-8.1.1564")
  " Recently vim can merge signcolumn and number column into one
    set signcolumn=number
  else
    set signcolumn=yes
  endif

  " Use tab for trigger completion with characters ahead and navigate.
  " NOTE: Use command ':verbose imap <tab>' to make sure tab is not mapped by
  " other plugin before putting this into your config.
  inoremap <silent><expr> <TAB>
    \ pumvisible() ? "\<C-n>" :
    \ <SID>check_back_space() ? "\<TAB>" :
    \ coc#refresh()
  inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>"

  function! s:check_back_space() abort
    let col = col('.') - 1
    return !col || getline('.')[col - 1]  =~# '\s'
  endfunction

  augroup mygroup
    autocmd!
    " Setup formatexpr specified filetype(s).
    autocmd FileType typescript,json setl formatexpr=CocAction('formatSelected')
    " Update signature help on jump placeholder.
    autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp')
  augroup end

" Make <CR> auto-select the first completion item and notify coc.nvim to
" format on enter, <cr> could be remapped by other vim plugin
  inoremap <silent><expr> <cr> pumvisible() ? coc#_select_confirm()
    \: "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>"

" Go settings
  let g:go_highlight_structs = 1 
  let g:go_highlight_methods = 1
  let g:go_highlight_functions = 1
  let g:go_highlight_operators = 1
  let g:go_highlight_build_constraints = 1
  let g:go_fmt_command = "gofmt"

" Go hotfixes
" @- To prevent fold magic
  let g:go_fmt_experimental = 1

" Lightline
  set noshowmode
  set laststatus=2
  let g:lightline = {
      \ 'colorscheme': 'hamza',
      \ }

" Vifm
  map <Leader>vv :Vifm<CR>
  map <Leader>vs :VsplitVifm<CR>
  map <Leader>hs :SplitVifm<CR>
  map <Leader>dv :DiffVifm<CR>
  map <Leader>tv :TabVifm<CR>

" Tab settings
  set tabpagemax=30
  map <Leader>tl :tabm -1<CR>
  map <Leader>tr :tabm +1<CR>

" Terraform settings
  let g:terraform_align=1
  let g:terraform_fmt_on_save=1

" Fix auto-indentation for YAML files
  augroup yaml_fix
    autocmd!
    autocmd FileType yaml setlocal ts=2 sts=2 sw=2 expandtab indentkeys-=0# indentkeys-=<:>
  augroup END

" Vifm settings
  let g:vifm_replace_netrw_cmd = "Vifm"
  let g:vifm_embed_split = 1

" Disable netrw in favor of vifm
  let g:loaded_netrw = 1 
  let g:loaded_netrwPlugin = 1
vimpostor commented 2 years ago

I still can't reproduce, even with your config. What terminal emulator are you using and what's your tmux config?

mkdior commented 2 years ago

I still can't reproduce, even with your config. What terminal emulator are you using and what's your tmux config?

Weird, yeah, my bad, maybe I should've also listed my terminal emulator lmao, it's Iterm2(3.4.12)

tmux.conf

# Using -r with the bind command allows us to state that we wish our command to be repeatable. The
# defined key can then be pressed multiple times within the repeat-limit.

# Plugins
set -g @plugin 'tmux-plugins/tmux-cpu'
set -g @plugin 'tmux-plugins/tmux-battery'

# Activate VI-mode
set -g mode-keys vi
# Change our prefix key from C-b to C-a
set -g prefix C-a
unbind C-b

set -g default-terminal "xterm-256color"

# Setting the delay between prefix and command
set -s escape-time 1

# Change default window index from 0 to 1
set -g base-index 1

# Bind <prefix>r to source our tmux.conf
bind r source-file ~/.tmux.conf \; display 'Sourced latest tmux.conf'

# Ensure we can send tmux prefix through to other apps
# Activate prefix x2 to send through
bind C-a send-prefix

# Split commands remap (|=vertical&&-=horizontal)
bind | split-window -h
bind - split-window -v

# Move between panes using hjkl
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R

# Resize panes
bind -r H resize-pane -L 5
bind -r J resize-pane -D 5
bind -r K resize-pane -U 5
bind -r L resize-pane -R 5

# Quick window selection
bind -r C-h select-window -t :-
bind -r C-l select-window -t :+

bind-key -T copy-mode-vi 'v' send -X begin-selection
bind-key -T copy-mode-vi 'y' send -X copy-selection-and-cancel

# Turn off mouse support
set -g mouse off

# Begin colors
###############
GIT_BR='#[fg=colour225,bold]#(cd #{pane_current_path}; git rev-parse --abbrev-ref HEAD 2>/dev/null)#[default]'

TMUX_BG_COLOUR='colour232'

TMUX_PANE_FORMAT='[#I#F]#W#[default]'
TMUX_PANE_C_COLOUR='colour255'
TMUX_PANE_L_COLOUR='colour255'
TMUX_PANE_COLOUR='colour240'

set-window-option -g status-fg colour255
set-window-option -g status-bg "$TMUX_BG_COLOUR"
set-window-option -g status-left "#[bg=colour225]#{?client_prefix,#[fg=colour232]#[bold],}#[bg=colour255,fg=colour232] #S #[fg=colour232,reverse] "
set-window-option -g status-left-length 60
set-window-option -g status-right "b-#{battery_percentage}#[default] c-#{cpu_percentage}#[default] "$GIT_BR" #[fg=colour231,bold] %a #[bold]%H:%M:%S "
set-window-option -g status-right-length 80
set-window-option -g window-status-current-format "$TMUX_PANE_FORMAT$TLS"
set-window-option -g window-status-format "$TMUX_PANE_FORMAT$TLS"

# Set active split's border-color to magenta
set -g pane-active-border-style bg=default,fg=magenta

###############
# End colors

# Change status-interval to 1 second
set -g status-interval 1

# Tmux/plugins
run '~/.tmux/plugins/tpm/tpm'
vimpostor commented 2 years ago

Weird, I wonder where that [fg=255,bg=16] NORMAL comes from. If I use your tmux config, it clears the left and right part properly.

BTW if you don't want it to clear the left and right part, but return to your previous left and right part, you need to disable autoembed and configure it like so (specifically in the case of your config):

vimrc:

let g:tpipeline_autoembed = 0

tmux.conf:

set-window-option -g status-left "#(cat #{socket_path}-\#{session_id}-vimbridge)#[bg=colour225]#{?client_prefix,#[fg=colour232]#[bold],}#[bg=colour255,fg=colour232] #S #[fg=colour232,reverse] "
set-window-option -g status-right "#(cat #{socket_path}-\#{session_id}-vimbridge-R)b-#{battery_percentage}#[default] c-#{cpu_percentage}#[default] "$GIT_BR" #[fg=colour231,bold] %a #[bold]%H:%M:%S "

That being said, there is a feature planned in the future to restore the tmux statusline automatically with autoembed, so that you don't need to do this manually.

Can you test if the problem persists if you make these changes to your config to disable autoembedding?

vimpostor commented 2 years ago

I also fixed a race condition in the latest commit fcddc77, hopefully the statusline is properly cleared now.

mkdior commented 2 years ago

I also fixed a race condition in the latest commit fcddc77, hopefully the statusline is properly cleared now.

mvp, I appreciate the effort. I'll try this out later tonight, I'll report back tomorrow!

vimpostor commented 2 years ago

Hi there is no need to manually embed the statusline anymore. You can now just use let g:tpipeline_restore = 1 with autoembed and everything will work out of the box.

If you still have an issue with this, feel free to reopen the issue.

The above feature is not enabled by default right now, but it will become enabled by default soon, once I have implemented another edge case.