summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSyndamia <kamen@syndamia.com>2023-02-25 11:21:06 +0200
committerSyndamia <kamen@syndamia.com>2023-02-25 11:21:06 +0200
commitcf7ba097e63d46d770af317c645caf1e8fae49d7 (patch)
tree4da6c2e42a78f4016e32c84b1a694597ac348e88
parent9e8621385d27b8d060e471e1cf3b81aa1033cc7f (diff)
downloaddotfiles-cf7ba097e63d46d770af317c645caf1e8fae49d7.tar
dotfiles-cf7ba097e63d46d770af317c645caf1e8fae49d7.tar.gz
dotfiles-cf7ba097e63d46d770af317c645caf1e8fae49d7.zip
[.vim/mp/tl] Added tabline miniplugin, completely replacing lightline
-rw-r--r--.vim/miniplugins/tabline.vim85
-rw-r--r--.vim/startup/pluginsettings.vim96
2 files changed, 85 insertions, 96 deletions
diff --git a/.vim/miniplugins/tabline.vim b/.vim/miniplugins/tabline.vim
new file mode 100644
index 0000000..63d927a
--- /dev/null
+++ b/.vim/miniplugins/tabline.vim
@@ -0,0 +1,85 @@
+let tabcap = ''
+let tabmiddlecap = ''
+
+set tabline=%!TablineGenerator()
+
+" Tab data/helper functions {{{
+ function! TabFilename(n)
+ let buflist = tabpagebuflist(a:n)
+ let winnr = tabpagewinnr(a:n)
+ let _ = (expand('#'..buflist[winnr - 1]..':t') !=# '') ? expand('#'..buflist[winnr - 1]..':t') : '[No Name]'
+
+ " Limit the width of tabs, so they don't go out of the screen
+ let tabNameLengthMax = &columns/(((tabpagenr('$') > 0) ? tabpagenr('$') : 0) + 5)
+
+ return WebDevIconsGetFileTypeSymbol(_) .. ' ' .. _[0:tabNameLengthMax]
+ endfunction
+
+ function! TabReadonly(n)
+ let winnr = tabpagewinnr(a:n)
+ return gettabwinvar(a:n, winnr, '&readonly') ? ' ' : ''
+ endfunction
+
+ function! TabModified(n)
+ let winnr = tabpagewinnr(a:n)
+ return gettabwinvar(a:n, winnr, '&modified') ? ' ' : (gettabwinvar(a:n, winnr, '&modifiable') ? '' : ' ')
+ endfunction
+" }}}
+
+" Colors {{{
+ hi TLTab ctermfg=252 ctermbg=242
+ hi TLTabSel ctermfg=252 ctermbg=235
+ hi TLRest ctermfg=248 ctermbg=238
+
+ let s:hi_tltab = hlget('TLTab')[0]
+ let s:hi_tltabsel = hlget('TLTabSel')[0]
+ let s:hi_tlrest = hlget('TLRest')[0]
+ call hlset([#{name: 'TLTabSelLC', ctermfg: s:hi_tltab['ctermbg'], ctermbg: s:hi_tltabsel['ctermbg'] },
+ \ #{name: 'TLTabSelRC', ctermfg: s:hi_tltabsel['ctermbg'], ctermbg: s:hi_tltab['ctermbg'] },
+ \ #{name: 'TLTabSelRCF', ctermfg: s:hi_tltabsel['ctermbg'], ctermbg: s:hi_tlrest['ctermbg'] },
+ \ #{name: 'TLTabRCF', ctermfg: s:hi_tltab['ctermbg'], ctermbg: s:hi_tlrest['ctermbg'] }])
+" }}}
+
+function! TablineGenerator()
+ let s = ''
+
+ " For each tab i
+ for i in range(1, tabpagenr('$'))
+ " Sets the tab page number, so that mouse clicks work
+ let s ..= '%' .. i .. 'T'
+
+ let innerText = '%{TabFilename(' .. i .. ')}%{TabReadonly(' .. i .. ')}%{TabModified(' .. i .. ')} '
+
+ " If tab is the selected one
+ if i == tabpagenr()
+ " If tab isn't the left most
+ if i > 1
+ let s ..= '%#TLTabSelLC#%{tabcap}'
+ endif
+
+ let s ..= '%#TLTabSel# ' .. l:innerText
+
+ " If tab is the last one, right cap bg color has to be different
+ let s ..= (i == tabpagenr('$') ? '%#TLTabSelRCF#' : '%#TLTabSelRC#') .. '%{tabcap}'
+
+ else
+ let s ..= '%#TLTab#'
+ " If tab isn't to the right of selected and isn't the left most
+ if (i-1 != tabpagenr()) && (i > 1)
+ let s ..= '%{tabmiddlecap}'
+ endif
+
+ let s ..= ' ' .. l:innerText
+
+ " Last tab has to have a tabcap
+ if i == tabpagenr('$')
+ let s ..= '%#TLTabRCF#%{tabcap}'
+ endif
+ endif
+ endfor
+
+ " After last tab, fill with TLRest
+ let s ..= '%#TLRest#%T'
+
+ return s
+endfunction
diff --git a/.vim/startup/pluginsettings.vim b/.vim/startup/pluginsettings.vim
index 633cfe7..3b8e87e 100644
--- a/.vim/startup/pluginsettings.vim
+++ b/.vim/startup/pluginsettings.vim
@@ -34,102 +34,6 @@
let g:SuperTabDefaultCompletionType = "context"
" }}}
-" Lightline {{{
- " Settings {{{
-
- if !has('gui_running')
- set t_Co=256
- endif
-
- let g:lightline = {
- \ 'enable': {
- \ 'statusline': 1,
- \ 'tabline': 1
- \ },
- \ 'colorscheme': 'wombat',
- \ 'active': {
- \ 'left': [ [ 'mode', 'paste' ],
- \ [ 'gitbranch', 'filename', 'charvaluehex', 'readonly', 'modified' ] ],
- \ 'right': [ [ 'lineinfo' ],
- \ [ 'fileencoding', 'filetype'] ]
- \ },
- \ 'component': {
- \ 'charvaluehex': '0x%B',
- \ },
- \ 'component_function': {
- \ 'gitbranch': 'LightlineFugitive',
- \ 'readonly': 'LightlineReadonly',
- \ 'modified': 'LightlineModified',
- \ 'filetype': 'LightlineFileType'
- \ },
- \ 'tabline': {
- \ 'right': [[]]
- \ },
- \ 'tab': {
- \ 'active': [ 'iconFilename','iconReadonly', 'iconModified' ],
- \ 'inactive': [ 'iconFilename', 'iconReadonly', 'iconModified' ]
- \ },
- \ 'tab_component_function': {
- \ 'iconFilename': 'LightlineTabFilename',
- \ 'iconReadonly': 'LightlineTabReadonly',
- \ 'iconModified': 'LightlineTabModified'
- \ },
- \ 'separator': { 'left': '', 'right': '' },
- \ 'subseparator': { 'left': '', 'right': '' },
- \ 'tabline_separator': { 'left': '', 'right': '' },
- \ 'tabline_subseparator': { 'left': '' }
- \ }
- " }}}
-
- " Function overrides {{{
- " Most of the following functions are just modification of source:
- " Examples from doc file - https://github.com/itchyny/lightline.vim/blob/53176a0b75d6389d775d7bce0d494e58fc654f38/doc/lightline.txt#L583
- " Tab source code - https://github.com/itchyny/lightline.vim/blob/master/autoload/lightline/tab.vim
-
- function! LightlineFugitive()
- if exists('*FugitiveHead')
- let branch = FugitiveHead()
- return branch !=# '' ? ' '.branch : ''
- endif
- return ''
- endfunction
-
- function! LightlineReadonly()
- return &ft !~? 'help\|vimfiler' && &readonly ? '' : ''
- endfunction
-
- function! LightlineModified()
- return &ft =~ 'help\|vimfiler' ? '' : &modified ? '' : &modifiable ? '' : ''
- endfunction
-
- function! LightlineFileType()
- return strlen(&filetype) ? WebDevIconsGetFileTypeSymbol() . ' ' . &filetype : ''
- endfunction
-
- " Adds the file type icon in tabs and limit their width
- function! LightlineTabFilename(n) abort
- let buflist = tabpagebuflist(a:n)
- let winnr = tabpagewinnr(a:n)
- let _ = (expand('#'.buflist[winnr - 1].':t') !=# '' ? expand('#'.buflist[winnr - 1].':t') : '[No Name]')
-
- " Limit the width of tabs, so they don't go out of the screen
- let tabNameLengthMax = &columns/((tabpagenr('$') > 0 ? tabpagenr('$') : 0) + 5)
-
- return WebDevIconsGetFileTypeSymbol(_) . ' ' . _[0:tabNameLengthMax]
- endfunction
-
- function! LightlineTabReadonly(n) abort
- let winnr = tabpagewinnr(a:n)
- return gettabwinvar(a:n, winnr, '&readonly') ? '' : ''
- endfunction
-
- function! LightlineTabModified(n) abort
- let winnr = tabpagewinnr(a:n)
- return gettabwinvar(a:n, winnr, '&modified') ? '' : gettabwinvar(a:n, winnr, '&modifiable') ? '' : ''
- endfunction
- " }}}
-" }}}
-
" ALE {{{
map <F2> <ESC>:ALERename<CR>
map gd <ESC>:ALEGoToDefinition<CR>