diff options
| -rw-r--r-- | home/.vim/plugin/buftabline.vim | 195 | ||||
| -rw-r--r-- | home/.vim/plugin/buftabs.vim | 247 | ||||
| -rw-r--r-- | home/.vim/vimrc | 67 | ||||
| -rw-r--r-- | home/.zprofile | 13 | ||||
| -rw-r--r-- | home/.zshrc | 12 |
5 files changed, 295 insertions, 239 deletions
diff --git a/home/.vim/plugin/buftabline.vim b/home/.vim/plugin/buftabline.vim deleted file mode 100644 index 091a5f7..0000000 --- a/home/.vim/plugin/buftabline.vim +++ /dev/null @@ -1,195 +0,0 @@ -" Vim global plugin for rendering the buffer list in the tabline -" Licence: The MIT License (MIT) -" Commit: $Format:%H$ -" {{{ Copyright (c) 2015 Aristotle Pagaltzis <pagaltzis@gmx.de> -" -" Permission is hereby granted, free of charge, to any person obtaining a copy -" of this software and associated documentation files (the "Software"), to deal -" in the Software without restriction, including without limitation the rights -" to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -" copies of the Software, and to permit persons to whom the Software is -" furnished to do so, subject to the following conditions: -" -" The above copyright notice and this permission notice shall be included in -" all copies or substantial portions of the Software. -" -" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -" IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -" FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -" AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -" LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -" OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -" THE SOFTWARE. -" }}} - -if v:version < 700 - echoerr printf('Vim 7 is required for buftabline (this is only %d.%d)',v:version/100,v:version%100) - finish -endif - -scriptencoding utf-8 - -hi default link BufTabLineCurrent TabLineSel -hi default link BufTabLineActive PmenuSel -hi default link BufTabLineHidden TabLine -hi default link BufTabLineFill TabLineFill - -let g:buftabline_numbers = get(g:, 'buftabline_numbers', 0) -let g:buftabline_indicators = get(g:, 'buftabline_indicators', 0) -let g:buftabline_separators = get(g:, 'buftabline_separators', 0) -let g:buftabline_show = get(g:, 'buftabline_show', 2) -let g:buftabline_plug_max = get(g:, 'buftabline_plug_max', 10) - -function! buftabline#user_buffers() " help buffers are always unlisted, but quickfix buffers are not - return filter(range(1,bufnr('$')),'buflisted(v:val) && "quickfix" !=? getbufvar(v:val, "&buftype")') -endfunction - -let s:dirsep = fnamemodify(getcwd(),':p')[-1:] -let s:centerbuf = winbufnr(0) -function! buftabline#render() - let show_num = g:buftabline_numbers == 1 - let show_ord = g:buftabline_numbers == 2 - let show_mod = g:buftabline_indicators - let lpad = g:buftabline_separators ? nr2char(0x23B8) : ' ' - - let bufnums = buftabline#user_buffers() - let centerbuf = s:centerbuf " prevent tabline jumping around when non-user buffer current (e.g. help) - - " pick up data on all the buffers - let tabs = [] - let path_tabs = [] - let tabs_per_tail = {} - let currentbuf = winbufnr(0) - let screen_num = 0 - for bufnum in bufnums - let screen_num = show_num ? bufnum : show_ord ? screen_num + 1 : '' - let tab = { 'num': bufnum } - let tab.hilite = currentbuf == bufnum ? 'Current' : bufwinnr(bufnum) > 0 ? 'Active' : 'Hidden' - if currentbuf == bufnum | let [centerbuf, s:centerbuf] = [bufnum, bufnum] | endif - let bufpath = bufname(bufnum) - if strlen(bufpath) - let tab.path = fnamemodify(bufpath, ':p:~:.') - let tab.sep = strridx(tab.path, s:dirsep, strlen(tab.path) - 2) " keep trailing dirsep - let tab.label = tab.path[tab.sep + 1:] - let pre = ( show_mod && getbufvar(bufnum, '&mod') ? '+' : '' ) . screen_num - let tab.pre = strlen(pre) ? pre . ' ' : '' - let tabs_per_tail[tab.label] = get(tabs_per_tail, tab.label, 0) + 1 - let path_tabs += [tab] - elseif -1 < index(['nofile','acwrite'], getbufvar(bufnum, '&buftype')) " scratch buffer - let tab.label = ( show_mod ? '!' . screen_num : screen_num ? screen_num . ' !' : '!' ) - else " unnamed file - let tab.label = ( show_mod && getbufvar(bufnum, '&mod') ? '+' : '' ) - \ . ( screen_num ? screen_num : '*' ) - endif - let tabs += [tab] - endfor - - " disambiguate same-basename files by adding trailing path segments - while len(filter(tabs_per_tail, 'v:val > 1')) - let [ambiguous, tabs_per_tail] = [tabs_per_tail, {}] - for tab in path_tabs - if -1 < tab.sep && has_key(ambiguous, tab.label) - let tab.sep = strridx(tab.path, s:dirsep, tab.sep - 1) - let tab.label = tab.path[tab.sep + 1:] - endif - let tabs_per_tail[tab.label] = get(tabs_per_tail, tab.label, 0) + 1 - endfor - endwhile - - " now keep the current buffer center-screen as much as possible: - - " 1. setup - let lft = { 'lasttab': 0, 'cut': '.', 'indicator': '<', 'width': 0, 'half': &columns / 2 } - let rgt = { 'lasttab': -1, 'cut': '.$', 'indicator': '>', 'width': 0, 'half': &columns - lft.half } - - " 2. sum the string lengths for the left and right halves - let currentside = lft - for tab in tabs - let tab.label = lpad . get(tab, 'pre', '') . tab.label . ' ' - let tab.width = strwidth(strtrans(tab.label)) - if centerbuf == tab.num - let halfwidth = tab.width / 2 - let lft.width += halfwidth - let rgt.width += tab.width - halfwidth - let currentside = rgt - continue - endif - let currentside.width += tab.width - endfor - if currentside is lft " centered buffer not seen? - " then blame any overflow on the right side, to protect the left - let [lft.width, rgt.width] = [0, lft.width] - endif - - " 3. toss away tabs and pieces until all fits: - if ( lft.width + rgt.width ) > &columns - let oversized - \ = lft.width < lft.half ? [ [ rgt, &columns - lft.width ] ] - \ : rgt.width < rgt.half ? [ [ lft, &columns - rgt.width ] ] - \ : [ [ lft, lft.half ], [ rgt, rgt.half ] ] - for [side, budget] in oversized - let delta = side.width - budget - " toss entire tabs to close the distance - while delta >= tabs[side.lasttab].width - let delta -= remove(tabs, side.lasttab).width - endwhile - " then snip at the last one to make it fit - let endtab = tabs[side.lasttab] - while delta > ( endtab.width - strwidth(strtrans(endtab.label)) ) - let endtab.label = substitute(endtab.label, side.cut, '', '') - endwhile - let endtab.label = substitute(endtab.label, side.cut, side.indicator, '') - endfor - endif - - if len(tabs) | let tabs[0].label = substitute(tabs[0].label, lpad, ' ', '') | endif - - let swallowclicks = '%'.(1 + tabpagenr('$')).'X' - return swallowclicks . join(map(tabs,'printf("%%#BufTabLine%s#%s",v:val.hilite,strtrans(v:val.label))'),'') . '%#BufTabLineFill#' -endfunction - -function! buftabline#update(zombie) - set tabline= - if tabpagenr('$') > 1 | set guioptions+=e showtabline=2 | return | endif - set guioptions-=e - if 0 == g:buftabline_show - set showtabline=1 - return - elseif 1 == g:buftabline_show - " account for BufDelete triggering before buffer is actually deleted - let bufnums = filter(buftabline#user_buffers(), 'v:val != a:zombie') - let &g:showtabline = 1 + ( len(bufnums) > 1 ) - elseif 2 == g:buftabline_show - set showtabline=2 - endif - set tabline=%!buftabline#render() -endfunction - -augroup BufTabLine -autocmd! -autocmd VimEnter * call buftabline#update(0) -autocmd TabEnter * call buftabline#update(0) -autocmd BufAdd * call buftabline#update(0) -autocmd BufDelete * call buftabline#update(str2nr(expand('<abuf>'))) -augroup END - -for s:n in range(1, g:buftabline_plug_max) + ( g:buftabline_plug_max > 0 ? [-1] : [] ) - let s:b = s:n == -1 ? -1 : s:n - 1 - execute printf("noremap <silent> <Plug>BufTabLine.Go(%d) :<C-U>exe 'b'.get(buftabline#user_buffers(),%d,'')<cr>", s:n, s:b) -endfor -unlet! s:n s:b - -if v:version < 703 - function s:transpile() - let [ savelist, &list ] = [ &list, 0 ] - redir => src - silent function buftabline#render - redir END - let &list = savelist - let src = substitute(src, '\n\zs[0-9 ]*', '', 'g') - let src = substitute(src, 'strwidth(strtrans(\([^)]\+\)))', 'strlen(substitute(\1, ''\p\|\(.\)'', ''x\1'', ''g''))', 'g') - return src - endfunction - exe "delfunction buftabline#render\n" . s:transpile() - delfunction s:transpile -endif diff --git a/home/.vim/plugin/buftabs.vim b/home/.vim/plugin/buftabs.vim new file mode 100644 index 0000000..ec9e6c6 --- /dev/null +++ b/home/.vim/plugin/buftabs.vim @@ -0,0 +1,247 @@ +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" buftabs (C) 2006 Ico Doornekamp +" +" This program is free software; you can redistribute it and/or modify it +" under the terms of the GNU General Public License as published by the Free +" Software Foundation; either version 2 of the License, or (at your option) +" any later version. +" +" This program is distributed in the hope that it will be useful, but WITHOUT +" ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +" FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +" more details. +" +" Introduction +" ------------ +" +" This is a simple script that shows a tabs-like list of buffers in the bottom +" of the window. The biggest advantage of this script over various others is +" that it does not take any lines away from your terminal, leaving more space +" for the document you're editing. The tabs are only visible when you need +" them - when you are switchin between buffers. +" +" Usage +" ----- +" +" This script draws buffer tabs on vim startup, when a new buffer is created +" and when switching between buffers. +" +" It might be handy to create a few maps for easy switching of buffers in your +" .vimrc file. For example, using F1 and F2 keys: +" +" noremap <f1> :bprev<CR> +" noremap <f2> :bnext<CR> +" +" or using control-left and control-right keys: +" +" :noremap <C-left> :bprev<CR> +" :noremap <C-right> :bnext<CR> +" +" +" The following extra configuration variables are availabe: +" +" * g:buftabs_only_basename +" +" Define this variable to make buftabs only print the filename of each buffer, +" omitting the preceding directory name. Add to your .vimrc: +" +" :let g:buftabs_only_basename=1 +" +" +" * g:buftabs_in_statusline +" +" Define this variable to make the plugin show the buftabs in the statusline +" instead of the command line. It is a good idea to configure vim to show +" the statusline as well when only one window is open. Add to your .vimrc: +" +" set laststatus=2 +" :let g:buftabs_in_statusline=1 +" +" +" * g:buftabs_active_highlight_group +" +" The name of a highlight group (:help highligh-groups) which is used to +" show the name of the current active buffer. If this variable is not +" defined, no highlighting is used. (Highlighting is only functional when +" g:buftabs_in_statusline is enabled) +" +" :let g:buftabs_active_highlight_group="Visual" +" +" +" Bugs +" ---- +" +" Vim's 'set hidden' option is known to break this plugin - for some reason +" vim will overwrite the buftabs when this option is enabled. +" +" +" Changelog +" --------- +" +" 0.1 2006-09-22 Initial version +" +" 0.2 2006-09-22 Better handling when the list of buffers is longer then the +" window width. +" +" 0.3 2006-09-27 Some cleanups, set 'hidden' mode by default +" +" 0.4 2007-02-26 Don't draw buftabs until VimEnter event to avoid clutter at +" startup in some circumstances +" +" 0.5 2007-02-26 Added option for showing only filenames without directories +" in tabs +" +" 0.6 2007-03-04 'only_basename' changed to a global variable. Removed +" functions and add event handlers instead. 'hidden' mode +" broke some things, so is disabled now. Fixed documentation +" +" 0.7 2007-03-07 Added configuration option to show tabs in statusline +" instead of cmdline +" +" 0.8 2007-04-02 Update buftabs when leaving insertmode +" +" 0.9 2007-08-22 Now compatible with older Vim versions < 7.0 +" +" 0.10 2008-01-26 Added GPL license +" +" 0.11 2008-02-29 Added optional syntax highlighting to active buffer name +" +" 0.12 2009-03-18 Fixed support for split windows +" +" 0.13 2009-05-07 Store and reuse right-aligned part of original statusline +" +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" + +" +" Called on VimEnter event +" + +let s:buftabs_enabled = 0 +let s:original_statusline = matchstr(&statusline, "%=.*") + +function! Buftabs_enable() + let s:buftabs_enabled = 1 +endfunction + + +" +" Draw the buftabs +" + +function! Buftabs_show() + + let l:i = 1 + let l:list = '' + let l:start = 0 + let l:end = 0 + if ! exists("s:from") + let s:from = 0 + endif + + if s:buftabs_enabled != 1 + return + endif + + " Walk the list of buffers + + while(l:i <= bufnr('$')) + + " Only show buffers in the list, and omit help screens + + if buflisted(l:i) && getbufvar(l:i, "&modifiable") + + " Get the name of the current buffer, and escape characters that might + " mess up the statusline + + if exists("g:buftabs_only_basename") + let l:name = fnamemodify(bufname(l:i), ":t") + else + let l:name = bufname(l:i) + endif + let l:name = substitute(l:name, "%", "%%", "g") + + " Append the current buffer number and name to the list. If the buffer + " is the active buffer, enclose it in some magick characters which will + " be replaced by markers later. If it is modified, it is appended with + " an exclaimation mark + + if winbufnr(winnr()) == l:i + let l:start = strlen(l:list) + let l:list = l:list . "\x01" + else + let l:list = l:list . ' ' + endif + + let l:list = l:list . l:i . "-" + let l:list = l:list . l:name + + if getbufvar(l:i, "&modified") == 1 + let l:list = l:list . "!" + endif + + if winbufnr(winnr()) == l:i + let l:list = l:list . "\x02" + let l:end = strlen(l:list) + else + let l:list = l:list . ' ' + endif + end + + let l:i = l:i + 1 + endwhile + + " If the resulting list is too long to fit on the screen, chop + " out the appropriate part + + let l:width = winwidth(0) - 12 + + if(l:start < s:from) + let s:from = l:start - 1 + endif + if l:end > s:from + l:width + let s:from = l:end - l:width + endif + + let l:list = strpart(l:list, s:from, l:width) + + " Replace the magic characters by visible markers for highlighting the + " current buffer. The markers can be simple characters like square brackets, + " but can also be special codes with highlight groups + + let l:buftabs_marker_start = "[" + let l:buftabs_marker_end = "]" + if exists("g:buftabs_active_highlight_group") + if exists("g:buftabs_in_statusline") + let l:buftabs_marker_start = "%#" . g:buftabs_active_highlight_group . "#" . l:buftabs_marker_start + let l:buftabs_marker_end = l:buftabs_marker_end . "%##" + end + end + + let l:list = substitute(l:list, "\x01", l:buftabs_marker_start, 'g') + let l:list = substitute(l:list, "\x02", l:buftabs_marker_end, 'g') + + " Show the list. The buftabs_in_statusline variable determines of the list + " is displayed in the command line (volatile) or in the statusline + " (persistent) + + if exists("g:buftabs_in_statusline") + let &l:statusline = l:list . s:original_statusline + else + redraw + echon l:list + end + +endfunction + + +" Hook to events to show buftabs at startup, when creating and when switching +" buffers + +autocmd VimEnter * call Buftabs_enable() +autocmd VimEnter,BufNew,BufEnter,BufWritePost * call Buftabs_show() +if version >= 700 + autocmd InsertLeave,VimResized * call Buftabs_show() +end + +" vi: ts=2 sw=2 + diff --git a/home/.vim/vimrc b/home/.vim/vimrc index d358bbf..b8ab4b4 100644 --- a/home/.vim/vimrc +++ b/home/.vim/vimrc @@ -3,13 +3,12 @@ set nocompatible let mapleader = "," cmap w!! w !sudo tee % >/dev/null<CR>:e!<CR><CR> -" ca w!! w !sudo tee > /dev/null "%" nmap <silent> <F1> <Plug>DiffChangesPatchToggle " F2: - nmap <silent> <F3> :NERDTreeToggle<CR> " F4: - -" F5: switchbuf +" F5: - nmap <silent> <F6> :foldclose<CR> nmap <silent> <F7> :foldopen<CR> " F8: ctags @@ -28,8 +27,6 @@ set binary let g:tex_fold_enabled=1 filetype plugin indent on -"filetype plugin on -"filetype indent on " Automatisch einruecken (Ausrichtung an voriger Zeile) " (STRG-T rueckt um 1 Stufe ein, STRG-D rueckt um 1 Stufe aus) @@ -92,8 +89,8 @@ set incsearch set noerrorbells set novisualbell -" Ausfuehrung von Skripten erlauben (Sicherheit) -set modeline +" Keine Ausfuehrung von Skripten erlauben (Sicherheit) +set nomodeline " KEINE Backupdateien erzeugen (Dateiname + ~ dahinter) set nobackup @@ -130,6 +127,33 @@ colorscheme molokai_black set showtabline=2 set laststatus=2 +function! CountListedBuffers() + let cnt = 0 + for nr in range(1,bufnr("$")) +" if buflisted(nr) && ! empty(bufname(nr)) || getbufvar(nr, '&buftype') ==# 'help' + if buflisted(nr) || getbufvar(nr, '&buftype') ==# 'help' + let cnt += 1 + endif + endfor + return cnt +endfunction + +function! QuitIfLastBuffer() + if CountListedBuffers() == 1 + :q + endif +endfunction + +function! CloseOrQuitIfLastBuffer() + if CountListedBuffers() == 1 + :q + else + :bd + endif +endfunction + +"autocmd BufDelete * :call QuitIfLastBuffer() + "set switchbuf=usetab,newtab "nnoremap <F5> :sbnext<CR> "nnoremap <S-F5> :sbprevious<CR> @@ -137,7 +161,8 @@ set laststatus=2 nmap t :edit<Space> nmap s :w<CR> nmap w :w<CR> -nmap q :bd<CR> +"nmap q :bd<CR> +nmap q :call CloseOrQuitIfLastBuffer()<CR> :nnoremap <S-Tab> :bprevious<cr> ":nnoremap <C-Y> :tabprevious<cr> @@ -154,24 +179,6 @@ nmap q :bd<CR> :inoremap <C-x> :wincmd w<cr> :vnoremap <C-x> :wincmd w<cr> -function! CountListedBuffers() - let cnt = 0 - for nr in range(1,bufnr("$")) - if buflisted(nr) && ! empty(bufname(nr)) || getbufvar(nr, '&buftype') ==# 'help' - let cnt += 1 - endif - endfor - return cnt -endfunction - -function! QuitIfLastBuffer() - if CountListedBuffers() == 1 - :q - endif -endfunction - -autocmd BufDelete * :call QuitIfLastBuffer() - "allow backspacing over everything in insert mode set bs=2 " keep 50 lines of command line history @@ -286,7 +293,7 @@ function! GitStatus() endfunction nnoremap <Leader>gd :call GitDiff()<CR> -nnoremap <Leader>gt :call GitStatus()<CR> +nnoremap <Leader>gs :call GitStatus()<CR> "------------------------------------------------------------------------------- "" TIMESTAMPS @@ -319,14 +326,6 @@ let g:Powerline_symbols = 'fancy' let g:Powerline_cache_enabled = 0 set guifont=Noto\ Mono\ Emoji\ for\ Powerline\ Regular\ 10 -let g:EclimHome = '/usr/share/vim/vimfiles/eclim' -let g:EclimEclipseHome = '/usr/share/eclipse' - -let g:miniBufExplMapWindowNavVim = 1 -let g:miniBufExplMapWindowNavArrows = 1 -let g:miniBufExplMapCTabSwitchBufs = 1 -let g:miniBufExplModSelTarget = 1 - let Tlist_Ctags_Cmd='/usr/bin/ctags' map T :TaskList<CR> diff --git a/home/.zprofile b/home/.zprofile index f192a91..b004820 100644 --- a/home/.zprofile +++ b/home/.zprofile @@ -1,12 +1,15 @@ main_node() { [[ "$HOSTNAME" == "anduin" ]] } -export XDG_CURRENT_DESKTOP=Hyprland -export XDG_SESSION_DESKTOP=Hyprland +#export XDG_CURRENT_DESKTOP=Hyprland +#export XDG_SESSION_DESKTOP=Hyprland +export XDG_CURRENT_DESKTOP=sway +export XDG_SESSION_DESKTOP=sway + export GNOME_KEYRING_CONTROL=/run/user/1000/keyring -export GTK_IM_MODULE=ibus -export XMODIFIERS=@im=ibus -export QT_IM_MODULE=ibus +#export GTK_IM_MODULE=ibus +#export XMODIFIERS=@im=ibus +#export QT_IM_MODULE=ibus export LANG='en_US.utf8' if main_node; then diff --git a/home/.zshrc b/home/.zshrc index 91f24cb..4878ea2 100644 --- a/home/.zshrc +++ b/home/.zshrc @@ -182,7 +182,7 @@ if main_node; then export BROWSER="firefox" export BATTERY=1 - export XDG_CURRENT_DESKTOP=kde + #export XDG_CURRENT_DESKTOP=kde export CVS_RSH="ssh" export GPG_TTY=$(tty) @@ -207,8 +207,10 @@ if main_node; then alias gnuplot="gnuplot -persist" #alias padoff='/usr/bin/xinput disable "SynPS/2 Synaptics TouchPad"' #alias padon='/usr/bin/xinput enable "SynPS/2 Synaptics TouchPad"' - alias padoff='/usr/bin/hyprctl keyword "device[synps/2-synaptics-touchpad]:enabled" false' - alias padon='/usr/bin/hyprctl keyword "device[synps/2-synaptics-touchpad]:enabled" true' + alias padoff='swaymsg input 2:7:SynPS/2_Synaptics_TouchPad events disabled' + alias padon='swaymsg input 2:7:SynPS/2_Synaptics_TouchPad events enabled' + #alias padoff='/usr/bin/hyprctl keyword "device[synps/2-synaptics-touchpad]:enabled" false' + #alias padon='/usr/bin/hyprctl keyword "device[synps/2-synaptics-touchpad]:enabled" true' alias snownews="snownews -u" alias biew="TERM=vt100 biew" alias urxvt="urxvt256c" @@ -259,7 +261,7 @@ if main_node; then } schauglasl () { - curl -s "https://icinga2.kom.tuwien.ac.at/schauglasl/routes?address=$1&context=tunet&best=1" | html2text --pad-tables | less -E + curl -s "https://icinga2.kom.tuwien.ac.at/schauglasl/routes?addresses=$1&context=tunet&best=1" | html2text --pad-tables | less -E } cable () { @@ -275,7 +277,7 @@ if main_node; then vlan () { vlan=`echo ${1} | sed 's/^0*//'` - curl -s https://cantonica.kom.tuwien.ac.at/neu/vlaniflist/ -X POST -d "vlan=${vlan}" | sed 's/|/¦/g' | html2text --pad-tables --body-width 0 | grep -v Startseite + curl -H "Accept: application/json" -s "https://netdata.it.tuwien.ac.at/api.php?call=vlans¶m=ports¶m2=${vlan}" | sed 's/|/¦/g' | jq '.[] | .cable + " → " + .switch_name + "¦" + .interface' } yaml_validate () { |
