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

Improve import of lightline into tmuxline #11

Closed
scottwillmoore opened this issue Jan 7, 2017 · 5 comments
Closed

Improve import of lightline into tmuxline #11

scottwillmoore opened this issue Jan 7, 2017 · 5 comments

Comments

@scottwillmoore
Copy link

scottwillmoore commented Jan 7, 2017

In order to give some context, the vim plugin tmuxline.vim is used to generate a statusline for tmux based off the current vim statusline. This statusline can be either, the vanilla vim statusline, or from the vim plugins, vim-airline or lightline.vim.

I am currently using lightline.vim with the Nord theme. As you can see below, the generated statusline is quite close, but there are some differences. In one segment, the foreground and background colour are the same.

image

This issue could be manually by exporting the generated statusline and configuring it manually, however this is not an ideal solution.

I managed to track the cause of this issue down to the lightline.vim theme supplied by nord-vim. As seen in the extract below, some of the colours use the identifier "NONE". By replacing all instances of "NONE" with nearest suitable colour (due to the limited terminal colour palate), this fixed the issue. Please note, lines have been omitted in the example below.

" the old nord.vim configuration.
let s:nord0 = ["#2E3440", "NONE"]
let s:nord2 = ["#434C5E", "NONE"]
let s:nord4 = ["#D8DEE9", "NONE"]

" the new nord.vim configuration.
let s:nord0 = ["#2E3440", 0]
let s:nord2 = ["#434C5E", 8]
let s:nord4 = ["#D8DEE9", 7]

This resulted in the fixed statusline, which appears to look as intended.

image

I am not an expert in vim, and I couldn't find much documentation on the "NONE" property, which appears to make the character pseudo transparent (setting the foreground colour to the previous background color, at least this hypothesis appears to hold true).

It would be great if someone with more experience could try and understand the issue better, but until then my fix appears to work so I will continue using that for the moment.

Here are some notable files which helped me identify the issue,

Hope you can help. Thanks!

@arcticicestudio arcticicestudio self-assigned this Jan 9, 2017
@arcticicestudio
Copy link
Contributor

Thanks for your investigation.
The NONE value is indeed used as pseudo transparent color, like the word says: It just sets no color which allows to use the default foreground and background color.

I've tested your solution and it works fine for the dark text elements, but then the lightline in vim seem to break, at least on my system.

ghi-11-scrot-lightline-break

Maybe this is related to my lightline configuration (separator, visible segments etc.) or tmux configurations.
Could you please post your tmux-, vim- and lightline configs so I can see test it?

@scottwillmoore
Copy link
Author

Sorry, I don't currently have a dotfiles repository, so I'll just dump it all below. Sorry!

I try to avoid using separators and complex Unicode characters. Instead I try to keep things simple and use no separators and only employ ASCII characters. This maximises my compatibility with a variety of terminal emulators (also no special fonts, etc).

Also, I use termite as my current terminal emulator, however I doubt that should have much effect.

.vimrc

" name: .vimrc
" author: scott moore

" ______________________________________________________________________________
" plugins

call plug#begin()

" the nord colorscheme.
Plug 'arcticicestudio/nord-vim'

" a lightweight status line replacement.
Plug 'itchyny/lightline.vim'
let g:lightline = {
	\ 'colorscheme': 'nord',
	\  }

" generate tmux status line using vim status line.
Plug 'edkolev/tmuxline.vim', { 'on': ['Tmuxline', 'TmuxlineSimple', 'TmuxlineSnapshot'] }
autocmd! User tmuxline.vim
	\ let g:tmuxline_powerline_separators = 0 |
	\ let g:tmuxline_theme = 'lightline' |
	\ let g:tmuxline_preset = {
		\ 'a':       '#S',
		\ 'b':       '#W',
		\ 'c':       '%R',
		\ 'win':     '#I #W',
		\ 'cwin':    '#I #W',
		\ 'x':       '',
		\ 'y':       '',
		\ 'z':       '',
		\ 'options': { 'status-justify': 'right' }
		\ }

call plug#end()


" ______________________________________________________________________________
" settings

" disable compatibility mode.
set nocompatible

" set better swap and backup directory.
set directory=$HOME/.vim/swap//
set backupdir=$HOME/.vim/backup//

" turn on file type detection.
if has('autocmd')
	filetype plugin indent on
endif

" turn on syntax highlighting.
if has('syntax') && !exists('g:syntax_on')
	syntax enable
endif

" attempt to set colorscheme, and suppress error messages.
silent! colorscheme nord

" enable the use of mouse for all modes.
if has('mouse')
	set mouse=a
endif

" show search pattern matches while typing, only if it's possible to timeout.
if has('reltime')
	set incsearch
endif

" indent to same level as previous line.
set autoindent
"
" allow backspacing over everything in insert mode.
set backspace=indent,eol,start

" disable incrementing of octal numbers to create better decimal experience.
set nrformats-=octal

" keep 200 lines of command history.
set history=200

" set timeout for keycodes, and wait up to 100ms.
set ttimeout
set ttimeoutlen=100

" show as much as possible of truncated lines.
set display+=lastline

" set the minimal number of lines to show around the cursor.
set scrolloff=3
set sidescrolloff=3

" always show a status line.
set laststatus=2

" display command completion matches in the status line.
set wildmenu

" ignore completion matches which matches these patterns.
set wildignore+=*/.git/*,*/.hg/*,*/.svn/*,*/.DS_Store

" characters to show hidden characters when in list mode.
set listchars=tab:>\ ,trail:-,nbsp:+,extends:>,precedes:<

" new splits are placed below or to the right of the current buffer.
set splitright
set splitbelow

" show line numbers.
set number

" highlight the line that the cursor is on.
set cursorline

" allow lines longer than the window to wrap.
set wrap

" set window title to match bash title.
" TODO: mirror bash title
set notitle
set titlestring=%t

" highlight these keywords in comments.
autocmd Syntax * call matchadd('Todo',  '\W\zs\(NOTE\|INFO\|IDEA\|TODO\|CHANGED\)')
autocmd Syntax * call matchadd('Debug', '\W\zs\(FIXME\|XXX\|BUG\|HACK\)')


" ______________________________________________________________________________
" bindings

" disable the use of arrow keys.
noremap <up> <nop>
noremap <down> <nop>
noremap <left> <nop>
noremap <right> <nop>

" make the command buffer easier to access.
noremap ; :

" reselect selection after indent command.
vnoremap < <gv
vnoremap > >gv

" use easier key combination to exit insert mode.
" inoremap fd <ESC>

" allow easier split navigation.
noremap <C-j> <C-w>j
noremap <C-k> <C-w>k
noremap <C-l> <C-w>l
noremap <C-h> <C-w>h

" move through wrapped lines, instead of actual lines.
noremap j gj
noremap k gk

.tmux.conf

# name: .tmux.conf
# author: scott moore

# TODO: configure tmux
# TODO: explain, add bindings
# TODO: increase visibility of active pane
# TODO: enter tmux on bash start
# TODO: set bash, terminal title

# ______________________________________________________________________________
# settings

# load theme configuration.
source ~/.tmux.theme

# set terminal with support for 256 colors.
set -g default-terminal 'tmux-256color'

# allow tmux to capture and pass through mouse events.
set -g mouse on

# allow tmux to set window titles.
set -g set-titles on
set -g set-titles-string '#T'

# use vi-style key bindings when interacting with tmux.
set -g mode-keys vi
set -g status-keys vi

# set the amount of seconds between status bar refreshes.
set -g status-interval 10

# the time in milliseconds tmux waits after an escape sequence for other sequences.
# TODO: explain vim conflict
set -g escape-time 0

# set the maximum number of lines of window history.
set -g history-limit 10000

# highlight windows with activity in the status line.
set -g monitor-activity on

# set a sensible base index for new windows and panes.
set -g base-index 1
set -g pane-base-index 1

# when a window is closed, the other windows are renumbered in numerical order.
set -g renumber-windows on


# ______________________________________________________________________________
# bindings

# reload tmux configuration.
bind r source-file ~/.tmux.conf \; display 'Reloaded!'

# create vi-style pane navigation.
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R

bind -n M-h select-pane -L
bind -n M-j select-pane -D
bind -n M-k select-pane -U
bind -n M-l select-pane -R

# create vi-style pane resising.
bind H resize-pane -L
bind J resize-pane -D
bind K resize-pane -U
bind L resize-pane -R

bind -n M-H resize-pane -L
bind -n M-J resize-pane -D
bind -n M-K resize-pane -U
bind -n M-L resize-pane -R

# easily switch window.
bind -n M-p previous-window
bind -n M-n next-window

bind -n M-1 select-window -t 1
bind -n M-2 select-window -t 2
bind -n M-3 select-window -t 3
bind -n M-4 select-window -t 4
bind -n M-5 select-window -t 5
bind -n M-6 select-window -t 6
bind -n M-7 select-window -t 7
bind -n M-8 select-window -t 8
bind -n M-9 select-window -t 9

.tmux.theme

# This tmux statusbar config was created by tmuxline.vim
# on Sun, 08 Jan 2017

set -g status-bg "colour8"
set -g message-command-fg "colour7"
set -g status-justify "right"
set -g status-left-length "100"
set -g status "on"
set -g pane-active-border-fg "colour6"
set -g message-bg "colour0"
set -g status-right-length "100"
set -g status-right-attr "none"
set -g message-fg "colour7"
set -g message-command-bg "colour0"
set -g status-attr "none"
set -gq status-utf8 "on"
set -g pane-border-fg "colour0"
set -g status-left-attr "none"
setw -g window-status-fg "colour7"
setw -g window-status-attr "none"
setw -g window-status-activity-bg "colour8"
setw -g window-status-activity-attr "none"
setw -g window-status-activity-fg "colour6"
setw -g window-status-separator ""
setw -g window-status-bg "colour8"
set -g status-left "#[fg=colour0,bg=colour6] #S #[fg=colour6,bg=colour0,nobold,nounderscore,noitalics]#[fg=colour7,bg=colour0] #W #[fg=colour0,bg=colour8,nobold,nounderscore,noitalics]#[fg=colour7,bg=colour8] %R #[fg=colour8,bg=colour8,nobold,nounderscore,noitalics]"
set -g status-right "#[fg=colour8,bg=colour8,nobold,nounderscore,noitalics]#[fg=colour0,bg=colour8,nobold,nounderscore,noitalics]#[fg=colour0,bg=colour0,nobold,nounderscore,noitalics]"
setw -g window-status-format "#[fg=colour8,bg=colour8,nobold,nounderscore,noitalics]#[default] #I #W #[fg=colour8,bg=colour8,nobold,nounderscore,noitalics]"
setw -g window-status-current-format "#[fg=colour0,bg=colour8,nobold,nounderscore,noitalics]#[fg=colour7,bg=colour0] #I #W #[fg=colour8,bg=colour0,nobold,nounderscore,noitalics]"

@arcticicestudio arcticicestudio changed the title Fix import of lightline into tmuxline Improve import of lightline into tmuxline Jan 14, 2017
@arcticicestudio
Copy link
Contributor

I've tested some scenarios and I came to the conclusion that it may break the theme when the nord0, nord2 and nord4 variables are changed, so I decided to fix this problem by using nord5 for lightline texts. This makes sure that texts are always colored bright and you can't really see a difference between the nord4 and nord5 color when only used for texts. The difference is only visible when you compare it for larger areas for example in a UI.

Some preview screenshots with the change applied:

@scottwillmoore test configurations

With unicode separators

Without specified configurations (tmuxline.vim autodetect)

The change can be tested by checking out the improvement/ghi-#11-improve-import-of-lightline-into-tmuxline branch .

@scottwillmoore
Copy link
Author

Awesome, seems like a great solution, and works on my end. Thanks!

@arcticicestudio
Copy link
Contributor

🚢 Shipped in release version 🏷 0.3.0.
If your're using vim-plug you can update to the latest version by running :PlugUpdate 😄

@arcticicestudio arcticicestudio added this to the 0.3.0 milestone Jul 10, 2017
@arcticicestudio arcticicestudio removed their assignment Sep 23, 2017
arcticicestudio added a commit that referenced this issue Jun 24, 2018
The "Nord airline.vim" (1) UI plugin theme now includes better support
for the "tmuxline.vim" (2) plugin. Previously text shown in the main
segment of the tmuxline, generated via the `:Tmuxline airline` command,
caused a `bad colour: NONE` error or has been colorized using `nord0`
which resulted in unreadable text due to a `nord3` background.

This has been fixed by using `nord5` as foreground color. See GH-11 (3)
which has been used as implementation reference that fixed the same
incompatibility for the "lightline.vim" (4) plugin.

References:

  (1) https://github.com/arcticicestudio/nord-vim/blob/develop/autoload/airline/themes/nord.vim
  (2) https://github.com/edkolev/tmuxline.vim
  (3) #11
  (4) https://github.com/itchyny/lightline.vim

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

No branches or pull requests

3 participants