From f2e01d7e513067ddb57c75f6e38cdcf434946cf8 Mon Sep 17 00:00:00 2001 From: Max Christian Pohle Date: Mon, 22 Oct 2018 00:02:58 +0200 Subject: Major refactoring for version 2.0 vim-plug has been removed and replaced with Vims internal bundle mechanism. But I already noticed, that there is also GLVM now and started trying that as well. --- .gitmodules | 57 ++ GetLatest/GetLatestVimScripts.dat | 10 + bashrc | 30 - compton.conf | 64 -- default-font.conf | 61 -- gtk-3.0.css | 117 --- gvim-buffer.desktop | 10 - gvim.desktop | 10 - gvimrc | 29 + init.vim | 36 +- list-commands.vim | 6 + nvim.desktop | 10 - plugin/AlignMapsPlugin.vim | 253 +++++ plugin/AlignPlugin.vim | 41 + plugin/cecutil.vim | 482 +++++++++ plugin/cscope.vim | 57 ++ plugin/jedi.vim | 15 + plugin/max-change-icon.vim | 11 + plugin/max-find-bash.vim | 9 + plugin/max-fix-colorschemes.vim | 49 + plugin/max-function-menu.vim | 173 ++++ plugin/max-highlight-word-under-cursor.vim | 18 + plugin/max-set-window-title.vim | 21 + plugin/max-splash.vim | 23 + plugin/nerdtree.vim | 25 + plugin/netrw.vim | 16 + plugin/signify.vim | 35 + plugin/snippets.vim | 12 + plugin/statusline.vim | 125 +++ plugin/tagbar.vim | 10 + plugin/terminal.vim | 19 + vim.desktop | 13 - vimpagerrc | 12 +- vimrc | 50 +- vimrc-common | 355 +++++++ vimrc-full | 1255 ------------------------ vimrc-minimal-statusline | 30 + xdg-additions/applications/gvim-buffer.desktop | 10 + xdg-additions/applications/gvim.desktop | 10 + xdg-additions/applications/nvim.desktop | 10 + xdg-additions/applications/vim.desktop | 13 + xdg-additions/bashrc | 30 + xdg-additions/default-font.conf | 61 ++ xdg-additions/gtk-3.0.css | 117 +++ ycm_extra_mini-conf.py | 138 +++ 45 files changed, 2360 insertions(+), 1578 deletions(-) create mode 100644 GetLatest/GetLatestVimScripts.dat delete mode 100644 bashrc delete mode 100644 compton.conf delete mode 100644 default-font.conf delete mode 100644 gtk-3.0.css delete mode 100644 gvim-buffer.desktop delete mode 100644 gvim.desktop create mode 100644 gvimrc mode change 120000 => 100644 init.vim create mode 100644 list-commands.vim delete mode 100644 nvim.desktop create mode 100644 plugin/AlignMapsPlugin.vim create mode 100644 plugin/AlignPlugin.vim create mode 100644 plugin/cecutil.vim create mode 100644 plugin/cscope.vim create mode 100644 plugin/jedi.vim create mode 100644 plugin/max-change-icon.vim create mode 100644 plugin/max-find-bash.vim create mode 100644 plugin/max-fix-colorschemes.vim create mode 100644 plugin/max-function-menu.vim create mode 100644 plugin/max-highlight-word-under-cursor.vim create mode 100644 plugin/max-set-window-title.vim create mode 100644 plugin/max-splash.vim create mode 100644 plugin/nerdtree.vim create mode 100644 plugin/netrw.vim create mode 100644 plugin/signify.vim create mode 100644 plugin/snippets.vim create mode 100644 plugin/statusline.vim create mode 100644 plugin/tagbar.vim create mode 100644 plugin/terminal.vim delete mode 100644 vim.desktop mode change 120000 => 100644 vimrc create mode 100644 vimrc-common delete mode 100644 vimrc-full create mode 100644 vimrc-minimal-statusline create mode 100644 xdg-additions/applications/gvim-buffer.desktop create mode 100644 xdg-additions/applications/gvim.desktop create mode 100644 xdg-additions/applications/nvim.desktop create mode 100644 xdg-additions/applications/vim.desktop create mode 100644 xdg-additions/bashrc create mode 100644 xdg-additions/default-font.conf create mode 100644 xdg-additions/gtk-3.0.css create mode 100644 ycm_extra_mini-conf.py diff --git a/.gitmodules b/.gitmodules index 605d959..a24b441 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,60 @@ [submodule "autoload"] path = autoload url = https://github.com/junegunn/vim-plug +[submodule "plugin/YouCompleteMe"] + path = pack/vim/opt/YouCompleteMe + url = https://github.com/Valloric/YouCompleteMe.git +[submodule "plugin/vim-remote-menu"] + path = pack/_all/start/vim-remote-menu + url = https://github.com/coderonline/vim-remote-menu.git +[submodule "plugin/base16-vim"] + path = pack/_all/start/base16-vim + url = https://github.com/chriskempson/base16-vim.git +[submodule "plugin/papercolor-theme"] + path = pack/_all/start/papercolor-theme + url = https://github.com/NLKNguyen/papercolor-theme.git +[submodule "plugin/vim-signify"] + path = pack/_all/opt/vim-signify + url = https://github.com/mhinz/vim-signify.git +[submodule "plugin/vim-fugitive"] + path = pack/_all/start/vim-fugitive + url = https://github.com/tpope/vim-fugitive.git +[submodule "plugin/tabular"] + path = pack/_all/start/tabular + url = https://github.com/godlygeek/tabular.git +[submodule "plugin/tagbar"] + path = pack/_all/opt/tagbar + url = https://github.com/majutsushi/tagbar.git +[submodule "plugin/vim-surround"] + path = pack/_all/start/vim-surround + url = https://github.com/tpope/vim-surround.git +[submodule "plugin/nerdtree"] + path = pack/_all/opt/nerdtree + url = https://github.com/scrooloose/nerdtree.git +[submodule "plugin/ultisnips"] + path = pack/_all/opt/ultisnips + url = https://github.com/SirVer/ultisnips.git +[submodule "plugin/vim-snippets"] + path = pack/_all/opt/vim-snippets + url = https://github.com/honza/vim-snippets.git +[submodule "plugin-neovim/deoplete.nvim"] + path = pack/neovim/start/deoplete.nvim + url = https://github.com/Shougo/deoplete.nvim.git +[submodule "plugin-neovim/echodoc.vim"] + path = pack/neovim/start/echodoc.vim + url = https://github.com/Shougo/echodoc.vim.git +[submodule "plugin-neovim/LanguageClient-neovim"] + path = pack/neovim/start/LanguageClient-neovim + url = https://github.com/autozimu/LanguageClient-neovim.git +[submodule "plugin-neovim/ale"] + path = pack/neovim/start/ale + url = https://github.com/w0rp/ale.git +[submodule "plugin-vim/syntastic"] + path = pack/vim/opt/syntastic + url = https://github.com/vim-syntastic/syntastic.git +[submodule "plugin/jedi-vim"] + path = pack/_all/opt/jedi-vim + url = https://github.com/davidhalter/jedi-vim.git +[submodule "plugin/vim-operator-user"] + path = pack/_all/start/vim-operator-user + url = https://github.com/kana/vim-operator-user.git diff --git a/GetLatest/GetLatestVimScripts.dat b/GetLatest/GetLatestVimScripts.dat new file mode 100644 index 0000000..aff0816 --- /dev/null +++ b/GetLatest/GetLatestVimScripts.dat @@ -0,0 +1,10 @@ +ScriptID SourceID Filename +-------------------------- +294 19633 :AutoInstall: Align.vim +120 9388 Decho.vim +40 21108 DrawIt.tar.gz +451 9231 EasyAccents.vim +195 6351 engspchk.vim +642 15781 GetLatestVimScripts.vim +489 16670 Manpageview.vim +1066 7618 :AutoInstall: cecutil.vim diff --git a/bashrc b/bashrc deleted file mode 100644 index 24c51a0..0000000 --- a/bashrc +++ /dev/null @@ -1,30 +0,0 @@ - -# gvim () { /bin/gvim $(if [[ "$#" > 0 && `/bin/gvim --serverlist | wc -l` ]]; then echo --remote; fi) $@; } -# vim () { /bin/vim $(if [[ "$#" > 0 && `/bin/vim --serverlist | wc -l` ]]; then echo --remote; fi) $@; } - -# man() -# { -# /bin/gvim \ -# $(if [[ `/bin/gvim --serverlist | wc -l` > 0 ]]; then echo --remote-send; fi) \ -# ":enew<CR>:0read !groffer --pager='cat' --tty $1 <bar> col -bx<CR> :set filetype=man buftype=nowrite readonly<CR>gg"; -# } - -# export MANPAGER='vim -c":set noswapfile|%!col -b" -c":file man|:setlocal filetype=man buftype=nowrite readonly nonumber nolist signcolumn=no" -' -export MANPAGER="vim -M +MANPAGER -" - -# man() { /bin/vim ":enew<CR>:0read !groffer --pager='cat' --tty $1 <bar> col -bx<CR> :set filetype=man buftype=nowrite readonly<CR>gg" -; } -# alias git='git -c color.ui=false' -# export GIT_DIFF_OPTS="--no-color" - - - -git config --global --replace-all color.pager 0 -git config --global --replace-all core.pager 'vim -c":set noswapfile filetype=git buftype=nowrite readonly nolist nonumber signcolumn=no|:file git" -' -# export GIT_PAGER='' - -# alias git="TERM=dumb git" - -# export EDITOR="gvim()" -# export PAGER="tee /tmp/output.txt /dev/stdout | /bin/vim -" - -# --remote-expr ":%!col -b" -c":set buftype=nowrite filetype=man readonly" -'A diff --git a/compton.conf b/compton.conf deleted file mode 100644 index 1d3025d..0000000 --- a/compton.conf +++ /dev/null @@ -1,64 +0,0 @@ -backend = "xrender"; -#backend = "glx"; -paint-on-overlay = true; -glx-no-stencil = true; -# glx-no-rebind-pixmap = true; # does not work! definitelly! -# vsync = "opengl-swc"; -vsync = "drm"; -# vsync-use-glfinish = true - -# These are important. The first one enables the opengl backend. The last one is the vsync method. Depending on the driver you might need to use a different method. -# The other options are smaller performance tweaks that work well in most cases. -# You can find the rest of the options here: https://github.com/chjj/compton/wiki/perf-guide, and here: https://github.com/chjj/compton/wiki/vsync-guide - - -# Shadow -#shadow = true; # Enabled client-side shadows on windows. -shadow = false; # Enabled client-side shadows on windows. -#no-dock-shadow = true; # Avoid drawing shadows on dock/panel windows. -#no-dnd-shadow = true; # Don't draw shadows on DND windows. -# clear-shadow = true; # Zero the part of the shadow's mask behind the window (experimental). -shadow-radius = 7; # The blur radius for shadows. (default 12) -shadow-offset-x = -7; # The left offset for shadows. (default -15) -shadow-offset-y = -7; # The top offset for shadows. (default -15) -shadow-exclude = [ - "! name~=''", - "n:e:Notification", - "n:e:Plank", - "n:e:Docky", - "g:e:Synapse", - "g:e:Kupfer", - "g:e:Conky", - "n:w:*Firefox*", - "n:w:*Chrome*", - "n:w:*Chromium*", - "class_g ?= 'Notify-osd'", - "class_g ?= 'Cairo-dock'", - "class_g ?= 'Xfce4-notifyd'", - "class_g ?= 'Xfce4-power-manager'", - "x = 0 && y = 0 && override_redirect = true" -]; - -# The shadow exclude options are helpful if you have shadows enabled. Due to the way compton draws its shadows, certain applications will have visual glitches -# (most applications are fine, only apps that do weird things with xshapes or argb are affected). -# This list includes all the affected apps I found in my testing. The "! name~=''" part excludes shadows on any "Unknown" windows, this prevents a visual glitch with the XFWM alt tab switcher. - -# Fading -# fading = true; # Fade windows during opacity changes. -fade-delta = 8; # The time between steps in a fade in milliseconds. (default 10). -fade-in-step = 0.03; # Opacity change between steps while fading in. (default 0.028). -fade-out-step = 0.03; # Opacity change between steps while fading out. (default 0.03). -#no-fading-openclose = true; # Fade windows in/out when opening/closing - -detect-client-opacity = true; # This prevents opacity being ignored for some apps. For example without this enabled my xfce4-notifyd is 100% opacity no matter what. - -# Window type settings -wintypes: -{ - tooltip = { fade = true; shadow = true; }; -}; - -#opacity-rule = ["90:class_g = 'URxvt'", "90:class_g = ''" ]; - - -opacity-rule = ["90:class_g = 'xfce4-terminal'", "95:class_g = 'Xfce4-terminal'", "90:class_g = 'termite'", "90:class_g = 'i3bar'", "90:class_g = 'i3-frame'", "90:class_g = 'Gnome-terminal'", "90:class_g = 'gnome-terminal-server'" ]; diff --git a/default-font.conf b/default-font.conf deleted file mode 100644 index b1de279..0000000 --- a/default-font.conf +++ /dev/null @@ -1,61 +0,0 @@ -<?xml version="1.0"?> -<!-- this is a configuration file for fontconfig and should be copied or linked to ~/.config/fontconfig/conf.d/ --> -<!DOCTYPE fontconfig SYSTEM "fonts.dtd"> -<fontconfig> - <match> - <edit mode="prepend" name="family"><string>NotoSans-Regular</string></edit> - </match> - <match target="pattern"> - <test qual="any" name="family"><string>serif</string></test> - <edit name="family" mode="assign" binding="same"><string>Noto Serif</string></edit> - </match> - <match target="pattern"> - <test qual="any" name="family"><string>sans-serif</string></test> - <edit name="family" mode="assign" binding="same"><string>Noto Sans Mono Bold</string></edit> - </match> - <match target="pattern"> - <test name="family" qual="any"> - <string>monospace</string> - </test> - <edit binding="strong" mode="assign" name="family"> - <string>SauceCodePro Nerd Font Mono</string> - </edit> - <edit binding="strong" mode="assign" name="weight"> - <int>100</int> - </edit> - <edit binding="strong" mode="assign" name="style"> - <string>dz</string> - </edit> - <edit binding="strong" mode="assign" name="pixelsize"> - <double>14</double> - </edit> - </match> -</fontconfig> - -<!-- - family: "Anonymous Pro for Powerline"(s) - family: "Consolas for Powerline"(s) "Consolas for Powerline FixedD"(s) - family: "DejaVu Sans Mono for Powerline"(s) - family: "Droid Sans Mono for Powerline"(s) - family: "Inconsolata for Powerline"(s) - family: "Inconsolata-dz for Powerline"(s) - family: "Liberation Mono for Powerline"(s) - family: "Menlo for Powerline"(s) - family: "Meslo LG L DZ for Powerline"(s) - family: "Meslo LG L for Powerline"(s) - family: "Meslo LG M DZ for Powerline"(s) - family: "Meslo LG M for Powerline"(s) - family: "Meslo LG S DZ for Powerline"(s) - family: "Meslo LG S for Powerline"(s) - family: "PowerlineSymbols"(s) - family: "Source Code Pro for Powerline"(s) - family: "Source Code Pro for Powerline"(s) "Source Code Pro Black"(s) - family: "Source Code Pro for Powerline"(s) "Source Code Pro ExtraLight"(s) - family: "Source Code Pro for Powerline"(s) "Source Code Pro Light"(s) - family: "Source Code Pro for Powerline"(s) "Source Code Pro Medium"(s) - family: "Source Code Pro for Powerline"(s) "Source Code Pro Semibold"(s) - family: "Terminus for Powerline"(s) - family: "Ubuntu Mono derivative Powerline"(s) - family: "xos4 Terminess Powerline"(s) - family: "xos4 Terminus for Powerline"(s) ---> diff --git a/gtk-3.0.css b/gtk-3.0.css deleted file mode 100644 index f347a83..0000000 --- a/gtk-3.0.css +++ /dev/null @@ -1,117 +0,0 @@ -/* -#vim-menubar, -#vim-menubar #menu, -#vim-toolbar, -#vim-gui-drawarea, -#vim-main-window { - color:#6060af; - color: #4e4e4e; - font-family: "Hasklug Nerd Font Mono", "Source Code Pro for Powerline", "Source Code Pro", "Roboto"; - font-weight:bold; - font-size:8pt; - border:0; - outline:0; -} - -* { - border-width:0px; - outline-width:0px; - padding:0; - margin:0; -} - -#vim-menubar -{ - padding-left:1em; - border-bottom:2px solid #ffffff; -} - -#vim-menubar>* -{ - padding-right:1em; - padding-top:.25em; - padding-bottom:.25em; -} - -#vim-menubar>*, -#vim-main-window { - background-color:#ffffff; - color: #4e4e4e; -} - -menu menuitem:backdrop, menu menuitem:backdrop:hover -{ - border:0px; -} -*/ - -window#vim-main-window > box -{ - background:#fff; - border:2px solid #fff; -} - -/* within window > box ... */ -menubar#vim-menubar { - font-family: "monospace", "Hasklug Nerd Font Mono", "Source Code Pro for Powerline", "Source Code Pro", "Roboto"; - font-weight:bold; - font-size:8pt; - background: #fff; - /* background: linear-gradient(180deg, white 85%, black); */ -} - -menubar#vim-menubar menuitem { - background:transparent; -} - -menubar#vim-menubar > menuitem { - padding:.25em; -} - -menubar#vim-menubar menuitem box { - padding:.1em .25em; -} - -menubar#vim-menubar menuitem window -{ - margin-top:1em; -} - -/* opened menu (after being clicked) */ -menubar#vim-menubar menuitem window menu { - padding:1px; - background:linear-gradient(90deg, #ccc, #fff); - -} - -menubar#vim-menubar menuitem window menu menuitem { - padding:0em; - margin:0px; -} - -menubar#vim-menubar menuitem window menu menuitem box { - background:rgba(255,255,255,.5); - padding:.25em; - padding-left:1em; - -} - -menubar#vim-menubar menuitem window menu separator { - margin:0; - background:#fff; - border-top:1px dotted #666; -} - - -menubar#vim-menubar menuitem:hover { - box-shadow:none; - background:rgba(0,0,0,.2); - color:#000; -} - - - -/* -toolbar button { -notebook tab { -*/ diff --git a/gvim-buffer.desktop b/gvim-buffer.desktop deleted file mode 100644 index 5cd2cbf..0000000 --- a/gvim-buffer.desktop +++ /dev/null @@ -1,10 +0,0 @@ -[Desktop Entry] -Type=Application -Name=Gnome Vi IMproved Buffer -Icon=gvim -Comment=Open file in an existing instance of vi and in a new tab -MimeType=text/english;text/plain;text/x-makefile;text/x-c++hdr;text/x-c++src;text/x-chdr;text/x-csrc;text/x-java;text/x-moc;text/x-pascal;text/x-tcl;text/x-tex;application/x-shellscript;text/x-c;text/x-c++; -Exec=gvim -f -N --remote-silent %F -Terminal=false -X-XClassHintResName=VIM -Categories=Utility;TextEditor; diff --git a/gvim.desktop b/gvim.desktop deleted file mode 100644 index 37c6e58..0000000 --- a/gvim.desktop +++ /dev/null @@ -1,10 +0,0 @@ -[Desktop Entry] -Name=Vi IMproved Tab -Comment=Open file in an existing instance of vi and in a new tab -MimeType=text/english;text/plain;text/x-makefile;text/x-c++hdr;text/x-c++src;text/x-chdr;text/x-csrc;text/x-java;text/x-moc;text/x-pascal;text/x-tcl;text/x-tex;application/x-shellscript;text/x-c;text/x-c++; -Exec=gvim f -N --remote-tab %F -Icon=gvim -Type=Application -Terminal=false -X-XClassHintResName=VIM -Categories=Utility;TextEditor; diff --git a/gvimrc b/gvimrc new file mode 100644 index 0000000..b4f2d70 --- /dev/null +++ b/gvimrc @@ -0,0 +1,29 @@ +" ====================================================================================================================== +" GUI_DEFAULTS: +" We want to have a minimal UI +" ====================================================================================================================== + +if has("gui_running") + set guicursor=a:block-blinkon100 + set browsedir=buffer + set toolbar+=text + set guiheadroom=0 + set guioptions+=eig + set guioptions-=T | " toolbar + set guioptions+=c | " use console dialogues instead of popups + set guioptions+=a | " auto select: copy&paste using middle click + set guioptions+=m | " remove menu + set guioptions-=e | " do not display tabs + set guioptions-=L | " do not show left scrollbar + set guioptions-=r | " do not show right scrollbar + set winaltkeys=menu | " behave like other windows: ALT-key can be used to open the menu (and cannot be :remaped) + " set selectmode=mouse,key,cmd | " enters vim's select mode when pressing shift-left or shift-END + " set keymodel=startsel,stopsel | " makes shift-left, shift-right available for selecting text + + " its possible to define alternative fonts (order matters), but we will + " use the systems default font and cofigure that if necessary + set guifont=Monospace\ 10 + + " like in the terminal: use Ctrl-shift-v for paste in vim's command editor + cnoremap <c-s-v> <c-r>* +endif diff --git a/init.vim b/init.vim deleted file mode 120000 index c9a3c9c..0000000 --- a/init.vim +++ /dev/null @@ -1 +0,0 @@ -vimrc \ No newline at end of file diff --git a/init.vim b/init.vim new file mode 100644 index 0000000..67bdf65 --- /dev/null +++ b/init.vim @@ -0,0 +1,35 @@ +exec ':source '.fnamemodify($MYVIMRC,':h').'/vimrc-common' + +set packpath+=pack/neovim + +"======================================================================================================================= +augroup DEOPLETE + inoremap <silent><expr> <C-Space> deoplete#mappings#manual_complete() + + let g:deoplete#enable_at_startup = 1 + let g:echodoc#enable_at_startup = 1 + let g:LanguageClient_serverCommands = { + \ 'cpp': ['clangd'], + \ 'c': ['clangd'] + \ } + + packadd deoplete.nvim + packadd LanguageClient-neovim + packadd echodoc.vim +augroup END + +"======================================================================================================================= +augroup ALE + let g:ale_set_highlights = 0 + + let g:ale_sign_error = '' + let g:ale_sign_style_error = '' + let g:ale_sign_info = '' + let g:ale_sign_warning = '' + + highlight! link ALEWarningSign FoldColumn + + packadd ale +augroup END + + diff --git a/list-commands.vim b/list-commands.vim new file mode 100644 index 0000000..0dd4bca --- /dev/null +++ b/list-commands.vim @@ -0,0 +1,6 @@ + + + +for s in sort(getcompletion('', 'function')) + echo getcompletion(s, 'function') +endfor diff --git a/nvim.desktop b/nvim.desktop deleted file mode 100644 index 21f0090..0000000 --- a/nvim.desktop +++ /dev/null @@ -1,10 +0,0 @@ -[Desktop Entry] -Version=1.0 -Type=Application -Name=Vim -Comment= -Exec=xfce4-terminal --icon /usr/share/icons/HighContrast/256x256/apps/vim.png -T 'nvim' -e '/bin/bash -i -c "env TERM=gnome-256color screen nvr ."' --fullscreen -Icon=/usr/share/icons/HighContrast/256x256/apps/vim.png -Path= -Terminal=false -StartupNotify=false diff --git a/plugin/AlignMapsPlugin.vim b/plugin/AlignMapsPlugin.vim new file mode 100644 index 0000000..7296f7f --- /dev/null +++ b/plugin/AlignMapsPlugin.vim @@ -0,0 +1,253 @@ +" AlignMapsPlugin: Alignment maps based upon <Align.vim> and <AlignMaps.vim> +" Maintainer: Dr. Charles E. Campbell. <NdrOchipS@PcampbellAfamily.Mbiz> +" Date: Jan 07, 2013 +" +" NOTE: the code herein needs vim 7.0 or later +" Copyright: Copyright (C) 1999-2012 Charles E. Campbell {{{1 +" Permission is hereby granted to use and distribute this code, +" with or without modifications, provided that this copyright +" notice is copied with it. Like anything else that's free, +" AlignMaps.vim is provided *as is* and comes with no warranty +" of any kind, either expressed or implied. By using this +" plugin, you agree that in no event will the copyright +" holder be liable for any damages resulting from the use +" of this software. +" Romans 1:20 For the invisible things of Him since the creation of the {{{1 +" world are clearly seen, being perceived through the things that are +" made, even His everlasting power and divinity; that they may be +" without excuse. + +" --------------------------------------------------------------------- +" Usage: {{{1 +" Use 'a to mark beginning of to-be-aligned region, Alternative: use V +" move cursor to end of region, and execute map. (linewise visual mode) to +" The maps also set up marks 'y and 'z, and retain mark region, execute same +" 'a at the beginning of region. map. Uses 'a, 'y, and 'z. +" +" The start/end wrappers save and restore marks 'y and 'z. +" +" Although the comments indicate the maps use a leading backslash, +" actually they use <Leader> (:he mapleader), so the user can +" specify that the maps start how he or she prefers. +" +" Note: these maps all use <Align.vim>. +" +" Load Once: {{{1 +if &cp || exists("g:loaded_AlignMapsPlugin") + finish +endif +let s:keepcpo = &cpo +let g:loaded_AlignMapsPlugin = "v43" +set cpo&vim + +" ===================================================================== +" Public Interface: {{{1 +com! AlignMapsClean :call AlignMaps#AlignMapsClean() + +" ===================================================================== +" Maps: {{{1 + +" --------------------------------------------------------------------- +" WS: wrapper start map (internal) {{{2 +" Produces a blank line above and below, marks with 'y and 'z +if !hasmapto('<Plug>WrapperStart') + map <unique> <SID>WS <Plug>AlignMapsWrapperStart +endif +nnoremap <silent> <script> <Plug>AlignMapsWrapperStart :set lz<CR>:call AlignMaps#WrapperStart(0)<CR> +vnoremap <silent> <script> <Plug>AlignMapsWrapperStart :<c-u>set lz<CR>:call AlignMaps#WrapperStart(1)<CR> + +" --------------------------------------------------------------------- +" WE: wrapper end (internal) {{{2 +" Removes guard lines, restores marks y and z, and restores search pattern +if !hasmapto('<Plug>WrapperEnd') + nmap <unique> <SID>WE <Plug>AlignMapsWrapperEnd +endif +nnoremap <silent> <script> <Plug>AlignMapsWrapperEnd :call AlignMaps#WrapperEnd()<CR>:set nolz<CR> + +" --------------------------------------------------------------------- +" Complex C-code alignment maps: {{{2 +if !hasmapto('<Plug>AM_a?') |call AlignMaps#MakeMap("a?")|endif +if !hasmapto('<Plug>AM_a,') |call AlignMaps#MakeMap("a,")|endif +if !hasmapto('<Plug>AM_a<') |call AlignMaps#MakeMap("a<")|endif +if !hasmapto('<Plug>AM_a=') |call AlignMaps#MakeMap("a=")|endif +if !hasmapto('<Plug>AM_a(') |call AlignMaps#MakeMap("a(")|endif +if !hasmapto('<Plug>AM_abox') |call AlignMaps#MakeMap("abox")|endif +if !hasmapto('<Plug>AM_acom') |call AlignMaps#MakeMap("acom")|endif +if !hasmapto('<Plug>AM_adcom')|call AlignMaps#MakeMap("adcom")|endif +if !hasmapto('<Plug>AM_aocom')|call AlignMaps#MakeMap("aocom")|endif +if !hasmapto('<Plug>AM_ascom')|call AlignMaps#MakeMap("ascom")|endif +if !hasmapto('<Plug>AM_adec') |call AlignMaps#MakeMap("adec")|endif +if !hasmapto('<Plug>AM_adef') |call AlignMaps#MakeMap("adef")|endif +if !hasmapto('<Plug>AM_afnc') |call AlignMaps#MakeMap("afnc")|endif +if !hasmapto('<Plug>AM_afnc') |call AlignMaps#MakeMap("afnc")|endif + +" --------------------------------------------------------------------- +" Number alignment maps: {{{2 +if !hasmapto('<Plug>AM_aunum')|call AlignMaps#MakeMap("aunum")|endif +if !hasmapto('<Plug>AM_aenum')|call AlignMaps#MakeMap("aenum")|endif +if exists("g:alignmaps_euronumber") && !exists("g:alignmaps_usanumber") + if !hasmapto('<Plug>AM_anum')|call AlignMaps#MakeMap("anum")|endif +else + if !hasmapto('<Plug>AM_anum')|call AlignMaps#MakeMap("anum")|endif +endif + +" --------------------------------------------------------------------- +" Plug maps: (the real thing) {{{2 +nnoremap <silent> <script> <Plug>AM_a? <SID>WS:AlignCtrl mIp1P1lC ? : : : : <CR>:'a,.Align<CR>:'a,'z-1s/\(\s\+\)? /?\1/e<CR><SID>WE +nnoremap <silent> <script> <Plug>AM_a, <SID>WS:'y,'zs/\(\S\)\s\+/\1 /ge<CR>'yjma'zk:call AlignMaps#CharJoiner(",")<cr>:silent 'y,'zg/,/call AlignMaps#FixMultiDec()<CR>'z:exe "norm \<Plug>AM_adec"<cr><SID>WE +nnoremap <silent> <script> <Plug>AM_a< <SID>WS:AlignCtrl mIp1P1=l << >><CR>:'a,.Align<CR><SID>WE +nnoremap <silent> <script> <Plug>AM_a( <SID>WS:AlignCtrl mIp0P1=l<CR>:'a,.Align [(,]<CR>:sil 'y+1,'z-1s/\(\s\+\),/,\1/ge<CR><SID>WE +nnoremap <silent> <script> <Plug>AM_a= <SID>WS:AlignCtrl mIp1P1=l<CR>:AlignCtrl g :=<CR>:'a,'zAlign :\==<CR><SID>WE +nnoremap <silent> <script> <Plug>AM_abox <SID>WS:let g:alignmaps_iws=substitute(getline("'a"),'^\(\s*\).*$','\1','e')<CR>:'a,'z-1s/^\s\+//e<CR>:'a,'z-1s/^.*$/@&@/<CR>:AlignCtrl m=p01P0w @<CR>:'a,.Align<CR>:'a,'z-1s/@/ * /<CR>:'a,'z-1s/@$/*/<CR>'aYP:s/./*/g<CR>0r/'zkYp:s/./*/g<CR>0r A/<Esc>:exe "'a-1,'z-1s/^/".g:alignmaps_iws."/e"<CR><SID>WE +nnoremap <silent> <script> <Plug>AM_acom <SID>WS:'a,.s/\/[*/]\/\=/@&@/e<CR>:'a,.s/\*\//@&/e<CR>:'y,'zs/^\( *\) @/\1@/e<CR>'zk:call AlignMaps#StdAlign(2)<CR>:'y,'zs/^\(\s*\) @/\1/e<CR>:'y,'zs/ @//eg<CR><SID>WE +nnoremap <silent> <script> <Plug>AM_adcom <SID>WS:'a,.v/^\s*\/[/*]/s/\/[*/]\*\=/@&@/e<CR>:'a,.v/^\s*\/[/*]/s/\*\//@&/e<CR>:'y,'zv/^\s*\/[/*]/s/^\( *\) @/\1@/e<CR>'zk:call AlignMaps#StdAlign(3)<cr>:'y,'zv/^\s*\/[/*]/s/^\(\s*\) @/\1/e<CR>:'y,'zs/ @//eg<CR><SID>WE +nnoremap <silent> <script> <Plug>AM_aocom <SID>WS:AlignPush<CR>:AlignCtrl g /[*/]<CR>:exe "norm \<Plug>AM_acom"<cr>:AlignPop<CR><SID>WE +nnoremap <silent> <script> <Plug>AM_ascom <SID>WS:'a,.s/\/[*/]/@&@/e<CR>:'a,.s/\*\//@&/e<CR>:silent! 'a,.g/^\s*@\/[*/]/s/@//ge<CR>:AlignCtrl v ^\s*\/[*/]<CR>:AlignCtrl g \/[*/]<CR>'zk:call AlignMaps#StdAlign(2)<cr>:'y,'zs/^\(\s*\) @/\1/e<CR>:'y,'zs/ @//eg<CR><SID>WE +nnoremap <silent> <script> <Plug>AM_adec <SID>WS:'a,'zs/\([^ \t/(]\)\([*&]\)/\1 \2/e<CR>:'y,'zv/^\//s/\([^ \t]\)\s\+/\1 /ge<CR>:'y,'zv/^\s*[*/]/s/\([^/][*&]\)\s\+/\1/ge<CR>:'y,'zv/^\s*[*/]/s/^\(\s*\%([a-zA-Z_][a-zA-Z_0-9<>:]*\s\+\%([a-zA-Z_*(&]\)\@=\)\+\)\([*(&]*\)\s*\([a-zA-Z0-9_()<>:]\+\)\s*\(\(\[.\{-}]\)*\)\s*\(=\)\=\s*\(.\{-}\)\=\s*;/\1@\2#@\3\4@\6@\7;@/e<CR>:'y,'zv/^\s*[*/]/s/\*\/\s*$/@*\//e<CR>:'y,'zv/^\s*[*/]/s/^\s\+\*/@@@@@* /e<CR>:'y,'zv/^\s*[*/]/s/^@@@@@\*\(.*[^*/]\)$/&@*/e<CR>'yjma'zk:AlignCtrl v ^\s*[*/#]<CR>:call AlignMaps#StdAlign(1)<cr>:'y,'zv/^\s*[*/]/s/@ //ge<CR>:'y,'zv/^\s*[*/]/s/\(\s*\);/;\1/e<CR>:'y,'zv/^#/s/# //e<CR>:'y,'zv/^\s\+[*/#]/s/\([^/*]\)\(\*\+\)\( \+\)/\1\3\2/e<CR>:'y,'zv/^\s\+[*/#]/s/\((\+\)\( \+\)\*/\2\1*/e<CR>:'y,'zv/^\s\+[*/#]/s/^\(\s\+\) \*/\1*/e<CR>:'y,'zv/^\s\+[*/#]/s/[ \t@]*$//e<CR>:'y,'zs/^[*]/ */e<CR><SID>WE +nnoremap <silent> <script> <Plug>AM_adef <SID>WS:AlignPush<CR>:AlignCtrl v ^\s*\(\/\*\<bar>\/\/\)<CR>:'a,.v/^\s*\(\/\*\<bar>\/\/\)/s/^\(\s*\)#\(\s\)*define\s*\(\I[a-zA-Z_0-9(),]*\)\s*\(.\{-}\)\($\<Bar>\/\*\)/#\1\2define @\3@\4@\5/e<CR>:'a,.v/^\s*\(\/\*\<bar>\/\/\)/s/\($\<Bar>\*\/\)/@&/e<CR>'zk:call AlignMaps#StdAlign(1)<cr>'yjma'zk:'a,.v/^\s*\(\/\*\<bar>\/\/\)/s/ @//g<CR><SID>WE +nnoremap <silent> <script> <Plug>AM_afnc :<c-u>set lz<CR>:silent call AlignMaps#Afnc()<CR>:set nolz<CR> +nnoremap <silent> <script> <Plug>AM_aunum <SID>WS:'a,'zs/\([-+]\=\d\+\)\([eE][-+]\d\+\)\=/\1#\2/ge<CR>:'a,'zs/\([.eE][-+]\=\d\+\)#/\1/ge<CR>:'a,'zs/#\././ge<CR>:'a,'zs/[-+]\=\%(\d\+\%([.#]\d*\)\=\<bar>[.#]\d\+\)\%([eE][-+]\=\d\+\)\=/@&@/ge<CR>:AlignCtrl Imp0P0r<CR>:'a,'zAlign [@#.]<CR>:'a,'zs/\([.#]\)\(\s\+\)\(\d*\%([eE][-+]\=\d\+\)\=\)@/\1\3\2@/ge<CR>:'a,'zs/@//<CR>:'a,'zs/[#@]/ /ge<CR><SID>WE +nnoremap <silent> <script> <Plug>AM_aenum <SID>WS:'a,'zs/\([-+]\=\d\+\)\([eE][-+]\d\+\)\=/\1#\2/ge<CR>:'a,'zs/\([,eE][-+]\=\d\+\)#/\1/ge<CR>:'a,'zs/#,/,/ge<CR>:'a,'zs/[-+]\=\%(\d\+\%([,#]\d*\)\=\<bar>[,#]\d\+\)\%([eE][-+]\=\d\+\)\=/@&@/ge<CR>:AlignCtrl Imp0P0r<CR>:'a,'zAlign [@#,]<CR>:'a,'zs/\([,#]\)\(\s\+\)\(\d*\%([eE][-+]\=\d\+\)\=\)@/\1\3\2@/ge<CR>:'a,'zs/@//<CR>:'a,'zs/[#@]/ /ge<CR><SID>WE +" --------------------------------------------------------------------- +" html table alignment {{{2 +if !hasmapto('<Plug>AM_Htd')|map <unique> <Leader>Htd <Plug>AM_Htd|endif +map <silent> <script> <Plug>AM_Htd <SID>WS:'y,'zs%<[tT][rR]><[tT][dD][^>]\{-}>\<Bar></[tT][dD]><[tT][dD][^>]\{-}>\<Bar></[tT][dD]></[tT][rR]>%@&@%g<CR>'yjma'zk:AlignCtrl m=Ilp1P0 @<CR>:'a,.Align<CR>:'y,'zs/ @/@/<CR>:'y,'zs/@ <[tT][rR]>/<[tT][rR]>/ge<CR>:'y,'zs/@//ge<CR><SID>WE + +" --------------------------------------------------------------------- +" character-based right-justified alignment maps {{{2 +if !hasmapto('<Plug>AM_T|')|call AlignMaps#MakeMap("T|")|endif +if !hasmapto('<Plug>AM_T#') |call AlignMaps#MakeMap("T#")|endif +if !hasmapto('<Plug>AM_T,') |call AlignMaps#MakeMap("T,")|endif +if !hasmapto('<Plug>AM_Ts,') |call AlignMaps#MakeMap("Ts,")|endif +if !hasmapto('<Plug>AM_T:') |call AlignMaps#MakeMap("T:")|endif +if !hasmapto('<Plug>AM_T;') |call AlignMaps#MakeMap("T;")|endif +if !hasmapto('<Plug>AM_T<') |call AlignMaps#MakeMap("T<")|endif +if !hasmapto('<Plug>AM_T=') |call AlignMaps#MakeMap("T=")|endif +if !hasmapto('<Plug>AM_T?') |call AlignMaps#MakeMap("T?")|endif +if !hasmapto('<Plug>AM_T@') |call AlignMaps#MakeMap("T@")|endif +if !hasmapto('<Plug>AM_TW@') |call AlignMaps#MakeMap("TW@")|endif +if !hasmapto('<Plug>AM_Tab') |call AlignMaps#MakeMap("Tab")|endif +if !hasmapto('<Plug>AM_Tsp') |call AlignMaps#MakeMap("Tsp")|endif +if !hasmapto('<Plug>AM_T~') |call AlignMaps#MakeMap("T~")|endif + +nnoremap <silent> <script> <Plug>AM_T| <SID>WS:AlignCtrl mIp0P0=r <Bar><CR>:'a,.Align<CR><SID>WE +nnoremap <silent> <script> <Plug>AM_T# <SID>WS:AlignCtrl mIp0P0=r #<CR>:'a,.Align<CR><SID>WE +nnoremap <silent> <script> <Plug>AM_T, <SID>WS:AlignCtrl mIp0P1=r ,<CR>:'a,.Align<CR><SID>WE +nnoremap <silent> <script> <Plug>AM_Ts, <SID>WS:AlignCtrl mIp0P1=r ,<CR>:'a,.Align<CR>:'a,.s/\(\s*\),/,\1/ge<CR><SID>WE +nnoremap <silent> <script> <Plug>AM_T: <SID>WS:AlignCtrl mIp1P1=r :<CR>:'a,.Align<CR><SID>WE +nnoremap <silent> <script> <Plug>AM_T; <SID>WS:AlignCtrl mIp0P0=r ;<CR>:'a,.Align<CR><SID>WE +nnoremap <silent> <script> <Plug>AM_T< <SID>WS:AlignCtrl mIp0P0=r <<CR>:'a,.Align<CR><SID>WE +nnoremap <silent> <script> <Plug>AM_T= <SID>WS:'a,'z-1s/\s\+\([*/+\-%<Bar>&\~^]\==\)/ \1/e<CR>:'a,'z-1s@ \+\([*/+\-%<Bar>&\~^]\)=@\1=@ge<CR>:'a,'z-1s/; */;@/e<CR>:'a,'z-1s/==/\="\<Char-0x0f>\<Char-0x0f>"/ge<CR>:'a,'z-1s/!=/\x="!\<Char-0x0f>"/ge<CR>:AlignCtrl mIp1P1=r = @<CR>:AlignCtrl g =<CR>:'a,'z-1Align<CR>:'a,'z-1s/; *@/;/e<CR>:'a,'z-1s/; *$/;/e<CR>:'a,'z-1s@\([*/+\-%<Bar>&\~^]\)\( \+\)=@\2\1=@ge<CR>:'a,'z-1s/\( \+\);/;\1/ge<CR>:'a,'z-1s/\xff/=/ge<CR><SID>WE:exe "norm <Plug>acom" +nnoremap <silent> <script> <Plug>AM_T? <SID>WS:AlignCtrl mIp0P0=r ?<CR>:'a,.Align<CR>:'y,'zs/ \( *\);/;\1/ge<CR><SID>WE +nnoremap <silent> <script> <Plug>AM_T@ <SID>WS:AlignCtrl mIp0P0=r @<CR>:'a,.Align<CR><SID>WE +nnoremap <silent> <script> <Plug>AM_TW@ <SID>WS:AlignCtrl mWp0P0=r @<CR>:'a,.Align<CR><SID>WE +nnoremap <silent> <script> <Plug>AM_Tab <SID>WS:'a,.s/^\(\t*\)\(.*\)/\=submatch(1).escape(substitute(submatch(2),'\t','@','g'),'\')/<CR>:AlignCtrl mI=r @<CR>:'a,.Align<CR>:'y+1,'z-1s/@/ /g<CR><SID>WE +nnoremap <silent> <script> <Plug>AM_Tsp <SID>WS:'a,.s/^\(\s*\)\(.*\)/\=submatch(1).escape(substitute(submatch(2),'\s\+','@','g'),'\')/<CR>:AlignCtrl mI=r @<CR>:'a,.Align<CR>:'y+1,'z-1s/@/ /g<CR><SID>WE +nnoremap <silent> <script> <Plug>AM_T~ <SID>WS:AlignCtrl mIp0P0=r ~<CR>:'a,.Align<CR>:'y,'zs/ \( *\);/;\1/ge<CR><SID>WE + +" --------------------------------------------------------------------- +" character-based left-justified alignment maps {{{2 +if !hasmapto('<Plug>AM_t|','n') |call AlignMaps#MakeMap("t|")|endif +if !hasmapto('<Plug>AM_t#','n') |call AlignMaps#MakeMap("t#")|endif +if !hasmapto('<Plug>AM_t,','n') |call AlignMaps#MakeMap("t,")|endif +if !hasmapto('<Plug>AM_t:','n') |call AlignMaps#MakeMap("t:")|endif +if !hasmapto('<Plug>AM_t;','n') |call AlignMaps#MakeMap("t;")|endif +if !hasmapto('<Plug>AM_t<','n') |call AlignMaps#MakeMap("t<")|endif +if !hasmapto('<Plug>AM_t=','n') |call AlignMaps#MakeMap("t=")|endif +if !hasmapto('<Plug>AM_ts,','n') |call AlignMaps#MakeMap("ts,")|endif +if !hasmapto('<Plug>AM_ts:','n') |call AlignMaps#MakeMap("ts:")|endif +if !hasmapto('<Plug>AM_ts;','n') |call AlignMaps#MakeMap("ts;")|endif +if !hasmapto('<Plug>AM_ts<','n') |call AlignMaps#MakeMap("ts<")|endif +if !hasmapto('<Plug>AM_ts=','n') |call AlignMaps#MakeMap("ts=")|endif +if !hasmapto('<Plug>AM_w=','n') |call AlignMaps#MakeMap("w=")|endif +if !hasmapto('<Plug>AM_t?','n') |call AlignMaps#MakeMap("t?")|endif +if !hasmapto('<Plug>AM_t~','n') |call AlignMaps#MakeMap("t~")|endif +if !hasmapto('<Plug>AM_t@','n') |call AlignMaps#MakeMap("t@")|endif +if !hasmapto('<Plug>AM_tW@','n') |call AlignMaps#MakeMap("tW@")|endif +if !hasmapto('<Plug>AM_m=','n') |call AlignMaps#MakeMap("m=")|endif +if !hasmapto('<Plug>AM_tab','n') |call AlignMaps#MakeMap("tab")|endif +if !hasmapto('<Plug>AM_tml','n') |call AlignMaps#MakeMap("tml")|endif +if !hasmapto('<Plug>AM_tsp','n') |call AlignMaps#MakeMap("tsp")|endif +if !hasmapto('<Plug>AM_tsq','n') |call AlignMaps#MakeMap("tsq")|endif +if !hasmapto('<Plug>AM_tt','n') |call AlignMaps#MakeMap("tt")|endif +if !hasmapto('<Plug>AM_tab','n') |call AlignMaps#MakeMap("tab")|endif + +" <Plug> normal mode mappings +nnoremap <silent> <script> <Plug>AM_t| <SID>WS:AlignCtrl mIp0P0=l <Bar><CR>:'a,.Align<CR><SID>WE +nnoremap <silent> <script> <Plug>AM_t# <SID>WS:AlignCtrl mIp0P0=l #<CR>:'a,.Align<CR><SID>WE +nnoremap <silent> <script> <Plug>AM_t, <SID>WS:AlignCtrl mIp0P1=l ,<CR>:'a,.Align<CR><SID>WE +nnoremap <silent> <script> <Plug>AM_t: <SID>WS:AlignCtrl mIp1P1=l :<CR>:'a,.Align<CR><SID>WE +nnoremap <silent> <script> <Plug>AM_t; <SID>WS:AlignCtrl mIp0P1=l ;<CR>:'a,.Align<CR>:sil 'y,'zs/\( *\);/;\1/ge<CR><SID>WE +nnoremap <silent> <script> <Plug>AM_t< <SID>WS:AlignCtrl mIp0P0=l <<CR>:'a,.Align<CR><SID>WE +nnoremap <silent> <script> <Plug>AM_t= <SID>WS:call AlignMaps#Equals()<CR><SID>WE +nnoremap <silent> <script> <Plug>AM_ts, <SID>WS:AlignCtrl mIp0P1=l #\zs<CR>:'a,.Align<CR><SID>WE +nnoremap <silent> <script> <Plug>AM_ts, <SID>WS:AlignCtrl mIp0P1=l ,\zs<CR>:'a,.Align<CR><SID>WE +nnoremap <silent> <script> <Plug>AM_ts: <SID>WS:AlignCtrl mIp1P1=l :\zs<CR>:'a,.Align<CR><SID>WE +nnoremap <silent> <script> <Plug>AM_ts; <SID>WS:AlignCtrl mIp1P1=l ;\zs<CR>:'a,.Align<CR><SID>WE +nnoremap <silent> <script> <Plug>AM_ts< <SID>WS:AlignCtrl mIp1P1=l <\zs<CR>:'a,.Align<CR><SID>WE +nnoremap <silent> <script> <Plug>AM_ts= <SID>WS:AlignCtrl mIp1P1=l =\zs<CR>:'a,.Align<CR><SID>WE +nnoremap <silent> <script> <Plug>AM_w= <SID>WS:'a,'zg/=/s/\s\+\([*/+\-%<Bar>&\~^]\==\)/ \1/e<CR>:'a,'zg/=/s@ \+\([*/+\-%<Bar>&\~^]\)=@\1=@ge<CR>:'a,'zg/=/s/==/\="\<Char-0x0f>\<Char-0x0f>"/ge<CR>:'a,'zg/=/s/!=/\="!\<Char-0x0f>"/ge<CR>'zk:AlignCtrl mWp1P1=l =<CR>:AlignCtrl g =<CR>:'a,'z-1g/=/Align<CR>:'a,'z-1g/=/s@\([*/+\-%<Bar>&\~^!=]\)\( \+\)=@\2\1=@ge<CR>:'a,'z-1g/=/s/\( \+\);/;\1/ge<CR>:'a,'z-1v/^\s*\/[*/]/s/\/[*/]/@&@/e<CR>:'a,'z-1v/^\s*\/[*/]/s/\*\//@&/e<CR>'zk:call AlignMaps#StdAlign(1)<cr>:'y,'zs/^\(\s*\) @/\1/e<CR>:'a,'z-1g/=/s/\xff/=/ge<CR>:'y,'zg/=/s/ @//eg<CR><SID>WE +nnoremap <silent> <script> <Plug>AM_t? <SID>WS:AlignCtrl mIp0P0=l ?<CR>:'a,.Align<CR>:.,'zs/ \( *\);/;\1/ge<CR><SID>WE +nnoremap <silent> <script> <Plug>AM_t~ <SID>WS:AlignCtrl mIp0P0=l ~<CR>:'a,.Align<CR>:'y,'zs/ \( *\);/;\1/ge<CR><SID>WE +nnoremap <silent> <script> <Plug>AM_t@ <SID>WS:call AlignMaps#StdAlign(1)<cr><SID>WE +nnoremap <silent> <script> <Plug>AM_tW@ <SID>WS:call AlignMaps#StdAlign(2)<cr><SID>WE +nnoremap <silent> <script> <Plug>AM_m= <SID>WS:'a,'zs/\s\+\([*/+\-%<Bar>&\~^]\==\)/ \1/e<CR>:'a,'zs@ \+\([*/+\-%<Bar>&\~^]\)=@\1=@ge<CR>:'a,'zs/==/\="\<Char-0x0f>\<Char-0x0f>"/ge<CR>:'a,'zs/!=/\="!\<Char-0x0f>"/ge<CR>'zk:AlignCtrl mIp1P1=l =<CR>:AlignCtrl g =<CR>:'a,'z-1Align<CR>:'a,'z-1s@\([*/+\-%<Bar>&\~^!=]\)\( \+\)=@\2\1=@ge<CR>:'a,'z-1s/\( \+\);/;\1/ge<CR>:'a,'z-s/%\ze[^=]/ @%@ /e<CR>'zk:call AlignMaps#StdAlign(1)<cr>:'y,'zs/^\(\s*\) @/\1/e<CR>:'a,'z-1s/\xff/=/ge<CR>:'y,'zs/ @//eg<CR><SID>WE +nnoremap <silent> <script> <Plug>AM_tab <SID>WS:'a,.s/^\(\t*\)\(.*\)$/\=submatch(1).escape(substitute(submatch(2),'\t',"\<Char-0x0f>",'g'),'\')/<CR>:if &ts == 1<bar>exe "AlignCtrl mI=lp0P0 \<Char-0x0f>"<bar>else<bar>exe "AlignCtrl mI=l"<bar>endif<CR>:'a,.Align <Char-0x0f><CR>:exe "'y+1,'z-1s/\<Char-0x0f>/".((&ts == 1)? '\t' : ' ')."/g"<CR><SID>WE +nnoremap <silent> <script> <Plug>AM_tml <SID>WS:AlignCtrl mWp1P0=l \\\@<!\\\s*$<CR>:'a,.Align<CR><SID>WE +nnoremap <silent> <script> <Plug>AM_tsp <SID>WS:keepj 'a,.s/^\(\s*\)\(.*\)/\=submatch(1).escape(substitute(submatch(2),'\s\+','@','g'),'\')/<CR>:AlignCtrl mI=lp0P0 @<CR>:'a,.Align<CR>:keepj 'y+1,'z-1s/@/ /g<CR><SID>WE +nnoremap <silent> <script> <Plug>AM_tsq <SID>WS:'a,.AlignReplaceQuotedSpaces<CR>:keepj 'a,.s/^\(\s*\)\(.*\)/\=submatch(1).substitute(submatch(2),'\s\+','@','g')/<CR>:AlignCtrl mIp0P0=l @<CR>:'a,.Align<CR>:keepj 'y+1,'z-1s/[%@]/ /g<CR><SID>WE +nnoremap <silent> <script> <Plug>AM_tt <SID>WS:AlignCtrl mIp1P1=l \\\@<!& \\\\<CR>:'a,.Align<CR><SID>WE + +" ===================================================================== +" Menu Support: {{{1 +" ma ..move.. use menu +" v V or ctrl-v ..move.. use menu +if has("menu") && has("gui_running") && &go =~# 'm' && !exists("s:firstmenu") + let s:firstmenu= 1 + if !exists("g:DrChipTopLvlMenu") + let g:DrChipTopLvlMenu= "DrChip." + endif + if g:DrChipTopLvlMenu != "" + let s:mapleader = exists("g:mapleader")? g:mapleader : '\' + let s:emapleader= escape(s:mapleader,'\ ') + exe 'menu '.g:DrChipTopLvlMenu.'AlignMaps.<<\ and\ >><tab>'.s:emapleader.'a< '.s:mapleader.'a<' + exe 'menu '.g:DrChipTopLvlMenu.'AlignMaps.Assignment\ =<tab>'.s:emapleader.'t= '.s:mapleader.'t=' + exe 'menu '.g:DrChipTopLvlMenu.'AlignMaps.Assignment\ :=<tab>'.s:emapleader.'a= '.s:mapleader.'a=' + exe 'menu '.g:DrChipTopLvlMenu.'AlignMaps.Backslashes<tab>'.s:emapleader.'tml '.s:mapleader.'tml' + exe 'menu '.g:DrChipTopLvlMenu.'AlignMaps.Breakup\ Comma\ Declarations<tab>'.s:emapleader.'a, '.s:mapleader.'a,' + exe 'menu '.g:DrChipTopLvlMenu.'AlignMaps.C\ Comment\ Box<tab>'.s:emapleader.'abox '.s:mapleader.'abox' + exe 'menu '.g:DrChipTopLvlMenu.'AlignMaps.Commas<tab>'.s:emapleader.'t, '.s:mapleader.'t,' + exe 'menu '.g:DrChipTopLvlMenu.'AlignMaps.Commas<tab>'.s:emapleader.'ts, '.s:mapleader.'ts,' + exe 'menu '.g:DrChipTopLvlMenu.'AlignMaps.Commas\ With\ Strings<tab>'.s:emapleader.'tsq '.s:mapleader.'tsq' + exe 'menu '.g:DrChipTopLvlMenu.'AlignMaps.Comments<tab>'.s:emapleader.'acom '.s:mapleader.'acom' + exe 'menu '.g:DrChipTopLvlMenu.'AlignMaps.Comments\ Only<tab>'.s:emapleader.'aocom '.s:mapleader.'aocom' + exe 'menu '.g:DrChipTopLvlMenu.'AlignMaps.Declaration\ Comments<tab>'.s:emapleader.'adcom '.s:mapleader.'adcom' + exe 'menu '.g:DrChipTopLvlMenu.'AlignMaps.Declarations<tab>'.s:emapleader.'adec '.s:mapleader.'adec' + exe 'menu '.g:DrChipTopLvlMenu.'AlignMaps.Definitions<tab>'.s:emapleader.'adef '.s:mapleader.'adef' + exe 'menu '.g:DrChipTopLvlMenu.'AlignMaps.Function\ Header<tab>'.s:emapleader.'afnc '.s:mapleader.'afnc' + exe 'menu '.g:DrChipTopLvlMenu.'AlignMaps.Html\ Tables<tab>'.s:emapleader.'Htd '.s:mapleader.'Htd' + exe 'menu '.g:DrChipTopLvlMenu.'AlignMaps.(\.\.\.)?\.\.\.\ :\ \.\.\.<tab>'.s:emapleader.'a? '.s:mapleader.'a?' + exe 'menu '.g:DrChipTopLvlMenu.'AlignMaps.Numbers<tab>'.s:emapleader.'anum '.s:mapleader.'anum' + exe 'menu '.g:DrChipTopLvlMenu.'AlignMaps.Numbers\ (American-Style)<tab>'.s:emapleader.'aunum <Leader>aunum '.s:mapleader.'aunum <Leader>aunum' + exe 'menu '.g:DrChipTopLvlMenu.'AlignMaps.Numbers\ (Euro-Style)<tab>'.s:emapleader.'aenum '.s:mapleader.'aenum' + exe 'menu '.g:DrChipTopLvlMenu.'AlignMaps.Spaces\ (Left\ Justified)<tab>'.s:emapleader.'tsp '.s:mapleader.'tsp' + exe 'menu '.g:DrChipTopLvlMenu.'AlignMaps.Spaces\ (Right\ Justified)<tab>'.s:emapleader.'Tsp '.s:mapleader.'Tsp' + exe 'menu '.g:DrChipTopLvlMenu.'AlignMaps.Statements\ With\ Percent\ Style\ Comments<tab>'.s:emapleader.'m= '.s:mapleader.'m=' + exe 'menu '.g:DrChipTopLvlMenu.'AlignMaps.Symbol\ <<tab>'.s:emapleader.'t< '.s:mapleader.'t<' + exe 'menu '.g:DrChipTopLvlMenu.'AlignMaps.Symbol\ \|<tab>'.s:emapleader.'t\| '.s:mapleader.'t|' + exe 'menu '.g:DrChipTopLvlMenu.'AlignMaps.Symbol\ @<tab>'.s:emapleader.'t@ '.s:mapleader.'t@' + exe 'menu '.g:DrChipTopLvlMenu.'AlignMaps.Symbol\ #<tab>'.s:emapleader.'t# '.s:mapleader.'t#' + exe 'menu '.g:DrChipTopLvlMenu.'AlignMaps.Tabs<tab>'.s:emapleader.'tab '.s:mapleader.'tab' + unlet s:mapleader + unlet s:emapleader + endif +endif + +" ===================================================================== +" Restore: {{{1 +let &cpo= s:keepcpo +unlet s:keepcpo + +" ============================================================================== +" Modelines: {{{1 +" vim: ts=4 nowrap fdm=marker diff --git a/plugin/AlignPlugin.vim b/plugin/AlignPlugin.vim new file mode 100644 index 0000000..50c53d6 --- /dev/null +++ b/plugin/AlignPlugin.vim @@ -0,0 +1,41 @@ +" AlignPlugin: tool to align multiple fields based on one or more separators +" Author: Charles E. Campbell +" Date: Nov 02, 2008 +" GetLatestVimScripts: 294 1 :AutoInstall: Align.vim +" GetLatestVimScripts: 1066 1 :AutoInstall: cecutil.vim +" Copyright: Copyright (C) 1999-2012 Charles E. Campbell {{{1 +" Permission is hereby granted to use and distribute this code, +" with or without modifications, provided that this copyright +" notice is copied with it. Like anything else that's free, +" Align.vim is provided *as is* and comes with no warranty +" of any kind, either expressed or implied. By using this +" plugin, you agree that in no event will the copyright +" holder be liable for any damages resulting from the use +" of this software. +" +" Romans 1:16,17a : For I am not ashamed of the gospel of Christ, for it is {{{1 +" the power of God for salvation for everyone who believes; for the Jew first, +" and also for the Greek. For in it is revealed God's righteousness from +" faith to faith. +" --------------------------------------------------------------------- +" Load Once: {{{1 +if &cp || exists("g:loaded_AlignPlugin") + finish +endif +let g:loaded_AlignPlugin = "v37" +let s:keepcpo = &cpo +set cpo&vim + +" --------------------------------------------------------------------- +" Public Interface: {{{1 +com! -bang -range -nargs=* Align <line1>,<line2>call Align#Align(<bang>0,<q-args>) +com! -range -nargs=0 AlignReplaceQuotedSpaces <line1>,<line2>call Align#AlignReplaceQuotedSpaces() +com! -nargs=* AlignCtrl call Align#AlignCtrl(<q-args>) +com! -nargs=0 AlignPush call Align#AlignPush() +com! -nargs=0 AlignPop call Align#AlignPop() + +" --------------------------------------------------------------------- +" Restore: {{{1 +let &cpo= s:keepcpo +unlet s:keepcpo +" vim: ts=4 fdm=marker diff --git a/plugin/cecutil.vim b/plugin/cecutil.vim new file mode 100644 index 0000000..506b7bf --- /dev/null +++ b/plugin/cecutil.vim @@ -0,0 +1,482 @@ +" cecutil.vim : save/restore window position +" save/restore mark position +" save/restore selected user maps +" Author: Charles E. Campbell, Jr. +" Version: 17 +" Date: Sep 04, 2007 +" +" Saving Restoring Destroying Marks: {{{1 +" call SaveMark(markname) let savemark= SaveMark(markname) +" call RestoreMark(markname) call RestoreMark(savemark) +" call DestroyMark(markname) +" commands: SM RM DM +" +" Saving Restoring Destroying Window Position: {{{1 +" call SaveWinPosn() let winposn= SaveWinPosn() +" call RestoreWinPosn() call RestoreWinPosn(winposn) +" \swp : save current window/buffer's position +" \rwp : restore current window/buffer's previous position +" commands: SWP RWP +" +" Saving And Restoring User Maps: {{{1 +" call SaveUserMaps(mapmode,maplead,mapchx,suffix) +" call RestoreUserMaps(suffix) +" +" GetLatestVimScripts: 1066 1 :AutoInstall: cecutil.vim +" +" You believe that God is one. You do well. The demons also {{{1 +" believe, and shudder. But do you want to know, vain man, that +" faith apart from works is dead? (James 2:19,20 WEB) + +" Load Once: {{{1 +if &cp || exists("g:loaded_cecutil") + finish +endif +let g:loaded_cecutil = "v17" +let s:keepcpo = &cpo +set cpo&vim +"DechoVarOn + +" ----------------------- +" Public Interface: {{{1 +" ----------------------- + +" Map Interface: {{{2 +if !hasmapto('<Plug>SaveWinPosn') + map <unique> <Leader>swp <Plug>SaveWinPosn +endif +if !hasmapto('<Plug>RestoreWinPosn') + map <unique> <Leader>rwp <Plug>RestoreWinPosn +endif +nmap <silent> <Plug>SaveWinPosn :call SaveWinPosn()<CR> +nmap <silent> <Plug>RestoreWinPosn :call RestoreWinPosn()<CR> + +" Command Interface: {{{2 +com! -bar -nargs=0 SWP call SaveWinPosn() +com! -bar -nargs=0 RWP call RestoreWinPosn() +com! -bar -nargs=1 SM call SaveMark(<q-args>) +com! -bar -nargs=1 RM call RestoreMark(<q-args>) +com! -bar -nargs=1 DM call DestroyMark(<q-args>) + +if v:version < 630 + let s:modifier= "sil " +else + let s:modifier= "sil keepj " +endif + +" --------------------------------------------------------------------- +" SaveWinPosn: {{{1 +" let winposn= SaveWinPosn() will save window position in winposn variable +" call SaveWinPosn() will save window position in b:cecutil_winposn{b:cecutil_iwinposn} +" let winposn= SaveWinPosn(0) will *only* save window position in winposn variable (no stacking done) +fun! SaveWinPosn(...) +" call Dfunc("SaveWinPosn() a:0=".a:0) + if line(".") == 1 && getline(1) == "" +" call Dfunc("SaveWinPosn : empty buffer") + return "" + endif + let so_keep = &so + let siso_keep = &siso + let ss_keep = &ss + set so=0 siso=0 ss=0 + + let swline = line(".") + let swcol = col(".") + let swwline = winline() - 1 + let swwcol = virtcol(".") - wincol() + let savedposn = "call GoWinbufnr(".winbufnr(0).")|silent ".swline + let savedposn = savedposn."|".s:modifier."norm! 0z\<cr>" + if swwline > 0 + let savedposn= savedposn.":".s:modifier."norm! ".swwline."\<c-y>\<cr>" + endif + if swwcol > 0 + let savedposn= savedposn.":".s:modifier."norm! 0".swwcol."zl\<cr>" + endif + let savedposn = savedposn.":".s:modifier."call cursor(".swline.",".swcol.")\<cr>" + + " save window position in + " b:cecutil_winposn_{iwinposn} (stack) + " only when SaveWinPosn() is used + if a:0 == 0 + if !exists("b:cecutil_iwinposn") + let b:cecutil_iwinposn= 1 + else + let b:cecutil_iwinposn= b:cecutil_iwinposn + 1 + endif +" call Decho("saving posn to SWP stack") + let b:cecutil_winposn{b:cecutil_iwinposn}= savedposn + endif + + let &so = so_keep + let &siso = siso_keep + let &ss = ss_keep + +" if exists("b:cecutil_iwinposn") " Decho +" call Decho("b:cecutil_winpos{".b:cecutil_iwinposn."}[".b:cecutil_winposn{b:cecutil_iwinposn}."]") +" else " Decho +" call Decho("b:cecutil_iwinposn doesn't exist") +" endif " Decho +" call Dret("SaveWinPosn [".savedposn."]") + return savedposn +endfun + +" --------------------------------------------------------------------- +" RestoreWinPosn: {{{1 +fun! RestoreWinPosn(...) +" call Dfunc("RestoreWinPosn() a:0=".a:0) +" call Decho("getline(1)<".getline(1).">") +" call Decho("line(.)=".line(".")) + if line(".") == 1 && getline(1) == "" +" call Dfunc("RestoreWinPosn : empty buffer") + return "" + endif + let so_keep = &so + let siso_keep = &siso + let ss_keep = &ss + set so=0 siso=0 ss=0 + + if a:0 == 0 || a:1 == "" + " use saved window position in b:cecutil_winposn{b:cecutil_iwinposn} if it exists + if exists("b:cecutil_iwinposn") && exists("b:cecutil_winposn{b:cecutil_iwinposn}") +" call Decho("using stack b:cecutil_winposn{".b:cecutil_iwinposn."}<".b:cecutil_winposn{b:cecutil_iwinposn}.">") + try + exe "silent! ".b:cecutil_winposn{b:cecutil_iwinposn} + catch /^Vim\%((\a\+)\)\=:E749/ + " ignore empty buffer error messages + endtry + " normally drop top-of-stack by one + " but while new top-of-stack doesn't exist + " drop top-of-stack index by one again + if b:cecutil_iwinposn >= 1 + unlet b:cecutil_winposn{b:cecutil_iwinposn} + let b:cecutil_iwinposn= b:cecutil_iwinposn - 1 + while b:cecutil_iwinposn >= 1 && !exists("b:cecutil_winposn{b:cecutil_iwinposn}") + let b:cecutil_iwinposn= b:cecutil_iwinposn - 1 + endwhile + if b:cecutil_iwinposn < 1 + unlet b:cecutil_iwinposn + endif + endif + else + echohl WarningMsg + echomsg "***warning*** need to SaveWinPosn first!" + echohl None + endif + + else " handle input argument +" call Decho("using input a:1<".a:1.">") + " use window position passed to this function + exe "silent ".a:1 + " remove a:1 pattern from b:cecutil_winposn{b:cecutil_iwinposn} stack + if exists("b:cecutil_iwinposn") + let jwinposn= b:cecutil_iwinposn + while jwinposn >= 1 " search for a:1 in iwinposn..1 + if exists("b:cecutil_winposn{jwinposn}") " if it exists + if a:1 == b:cecutil_winposn{jwinposn} " and the pattern matches + unlet b:cecutil_winposn{jwinposn} " unlet it + if jwinposn == b:cecutil_iwinposn " if at top-of-stack + let b:cecutil_iwinposn= b:cecutil_iwinposn - 1 " drop stacktop by one + endif + endif + endif + let jwinposn= jwinposn - 1 + endwhile + endif + endif + + " seems to be something odd: vertical motions after RWP + " cause jump to first column. Following fixes that + if wincol() > 1 + silent norm! hl + elseif virtcol(".") < virtcol("$") + silent norm! lh + endif + + let &so = so_keep + let &siso = siso_keep + let &ss = ss_keep + +" call Dret("RestoreWinPosn") +endfun + +" --------------------------------------------------------------------- +" GoWinbufnr: go to window holding given buffer (by number) {{{1 +" Prefers current window; if its buffer number doesn't match, +" then will try from topleft to bottom right +fun! GoWinbufnr(bufnum) +" call Dfunc("GoWinbufnr(".a:bufnum.")") + if winbufnr(0) == a:bufnum +" call Dret("GoWinbufnr : winbufnr(0)==a:bufnum") + return + endif + winc t + let first=1 + while winbufnr(0) != a:bufnum && (first || winnr() != 1) + winc w + let first= 0 + endwhile +" call Dret("GoWinbufnr") +endfun + +" --------------------------------------------------------------------- +" SaveMark: sets up a string saving a mark position. {{{1 +" For example, SaveMark("a") +" Also sets up a global variable, g:savemark_{markname} +fun! SaveMark(markname) +" call Dfunc("SaveMark(markname<".a:markname.">)") + let markname= a:markname + if strpart(markname,0,1) !~ '\a' + let markname= strpart(markname,1,1) + endif +" call Decho("markname=".markname) + + let lzkeep = &lz + set lz + + if 1 <= line("'".markname) && line("'".markname) <= line("$") + let winposn = SaveWinPosn(0) + exe s:modifier."norm! `".markname + let savemark = SaveWinPosn(0) + let g:savemark_{markname} = savemark + let savemark = markname.savemark + call RestoreWinPosn(winposn) + else + let g:savemark_{markname} = "" + let savemark = "" + endif + + let &lz= lzkeep + +" call Dret("SaveMark : savemark<".savemark.">") + return savemark +endfun + +" --------------------------------------------------------------------- +" RestoreMark: {{{1 +" call RestoreMark("a") -or- call RestoreMark(savemark) +fun! RestoreMark(markname) +" call Dfunc("RestoreMark(markname<".a:markname.">)") + + if strlen(a:markname) <= 0 +" call Dret("RestoreMark : no such mark") + return + endif + let markname= strpart(a:markname,0,1) + if markname !~ '\a' + " handles 'a -> a styles + let markname= strpart(a:markname,1,1) + endif +" call Decho("markname=".markname." strlen(a:markname)=".strlen(a:markname)) + + let lzkeep = &lz + set lz + let winposn = SaveWinPosn(0) + + if strlen(a:markname) <= 2 + if exists("g:savemark_{markname}") && strlen(g:savemark_{markname}) != 0 + " use global variable g:savemark_{markname} +" call Decho("use savemark list") + call RestoreWinPosn(g:savemark_{markname}) + exe "norm! m".markname + endif + else + " markname is a savemark command (string) +" call Decho("use savemark command") + let markcmd= strpart(a:markname,1) + call RestoreWinPosn(markcmd) + exe "norm! m".markname + endif + + call RestoreWinPosn(winposn) + let &lz = lzkeep + +" call Dret("RestoreMark") +endfun + +" --------------------------------------------------------------------- +" DestroyMark: {{{1 +" call DestroyMark("a") -- destroys mark +fun! DestroyMark(markname) +" call Dfunc("DestroyMark(markname<".a:markname.">)") + + " save options and set to standard values + let reportkeep= &report + let lzkeep = &lz + set lz report=10000 + + let markname= strpart(a:markname,0,1) + if markname !~ '\a' + " handles 'a -> a styles + let markname= strpart(a:markname,1,1) + endif +" call Decho("markname=".markname) + + let curmod = &mod + let winposn = SaveWinPosn(0) + 1 + let lineone = getline(".") + exe "k".markname + d + put! =lineone + let &mod = curmod + call RestoreWinPosn(winposn) + + " restore options to user settings + let &report = reportkeep + let &lz = lzkeep + +" call Dret("DestroyMark") +endfun + +" --------------------------------------------------------------------- +" QArgSplitter: to avoid \ processing by <f-args>, <q-args> is needed. {{{1 +" However, <q-args> doesn't split at all, so this one returns a list +" with splits at all whitespace (only!), plus a leading length-of-list. +" The resulting list: qarglist[0] corresponds to a:0 +" qarglist[i] corresponds to a:{i} +fun! QArgSplitter(qarg) +" call Dfunc("QArgSplitter(qarg<".a:qarg.">)") + let qarglist = split(a:qarg) + let qarglistlen = len(qarglist) + let qarglist = insert(qarglist,qarglistlen) +" call Dret("QArgSplitter ".string(qarglist)) + return qarglist +endfun + +" --------------------------------------------------------------------- +" ListWinPosn: +"fun! ListWinPosn() " Decho +" if !exists("b:cecutil_iwinposn") || b:cecutil_iwinposn == 0 " Decho +" call Decho("nothing on SWP stack") " Decho +" else " Decho +" let jwinposn= b:cecutil_iwinposn " Decho +" while jwinposn >= 1 " Decho +" if exists("b:cecutil_winposn{jwinposn}") " Decho +" call Decho("winposn{".jwinposn."}<".b:cecutil_winposn{jwinposn}.">") " Decho +" else " Decho +" call Decho("winposn{".jwinposn."} -- doesn't exist") " Decho +" endif " Decho +" let jwinposn= jwinposn - 1 " Decho +" endwhile " Decho +" endif " Decho +"endfun " Decho +"com! -nargs=0 LWP call ListWinPosn() " Decho + +" --------------------------------------------------------------------- +" SaveUserMaps: this function sets up a script-variable (s:restoremap) {{{1 +" which can be used to restore user maps later with +" call RestoreUserMaps() +" +" mapmode - see :help maparg for its list +" ex. "n" = Normal +" If the first letter is u, then unmapping will be done +" ex. "un" = Normal + unmapping +" maplead - see mapchx +" mapchx - "<something>" handled as a single map item. +" ex. "<left>" +" - "string" a string of single letters which are actually +" multiple two-letter maps (using the maplead: +" maplead . each_character_in_string) +" ex. maplead="\" and mapchx="abc" saves user mappings for +" \a, \b, and \c +" Of course, if maplead is "", then for mapchx="abc", +" mappings for a, b, and c are saved. +" - :something handled as a single map item, w/o the ":" +" ex. mapchx= ":abc" will save a mapping for "abc" +" suffix - a string unique to your plugin +" ex. suffix= "DrawIt" +fun! SaveUserMaps(mapmode,maplead,mapchx,suffix) +" call Dfunc("SaveUserMaps(mapmode<".a:mapmode."> maplead<".a:maplead."> mapchx<".a:mapchx."> suffix<".a:suffix.">)") + + if !exists("s:restoremap_{a:suffix}") + " initialize restoremap_suffix to null string + let s:restoremap_{a:suffix}= "" + endif + + " set up dounmap: if 1, then save and unmap (a:mapmode leads with a "u") + " if 0, save only + if a:mapmode =~ '^u' + let dounmap= 1 + let mapmode= strpart(a:mapmode,1) + else + let dounmap= 0 + let mapmode= a:mapmode + endif + + " save single map :...something... + if strpart(a:mapchx,0,1) == ':' + let amap= strpart(a:mapchx,1) + if amap == "|" || amap == "\<c-v>" + let amap= "\<c-v>".amap + endif + let amap = a:maplead.amap + let s:restoremap_{a:suffix} = s:restoremap_{a:suffix}."|:silent! ".mapmode."unmap ".amap + if maparg(amap,mapmode) != "" + let maprhs = substitute(maparg(amap,mapmode),'|','<bar>','ge') + let s:restoremap_{a:suffix} = s:restoremap_{a:suffix}."|:".mapmode."map ".amap." ".maprhs + endif + if dounmap + exe "silent! ".mapmode."unmap ".amap + endif + + " save single map <something> + elseif strpart(a:mapchx,0,1) == '<' + let amap = a:mapchx + if amap == "|" || amap == "\<c-v>" + let amap= "\<c-v>".amap + endif + let s:restoremap_{a:suffix} = s:restoremap_{a:suffix}."|silent! ".mapmode."unmap ".amap + if maparg(a:mapchx,mapmode) != "" + let maprhs = substitute(maparg(amap,mapmode),'|','<bar>','ge') + let s:restoremap_{a:suffix} = s:restoremap_{a:suffix}."|".mapmode."map ".amap." ".maprhs + endif + if dounmap + exe "silent! ".mapmode."unmap ".amap + endif + + " save multiple maps + else + let i= 1 + while i <= strlen(a:mapchx) + let amap= a:maplead.strpart(a:mapchx,i-1,1) + if amap == "|" || amap == "\<c-v>" + let amap= "\<c-v>".amap + endif + let s:restoremap_{a:suffix} = s:restoremap_{a:suffix}."|silent! ".mapmode."unmap ".amap + if maparg(amap,mapmode) != "" + let maprhs = substitute(maparg(amap,mapmode),'|','<bar>','ge') + let s:restoremap_{a:suffix} = s:restoremap_{a:suffix}."|".mapmode."map ".amap." ".maprhs + endif + if dounmap + exe "silent! ".mapmode."unmap ".amap + endif + let i= i + 1 + endwhile + endif +" call Dret("SaveUserMaps : restoremap_".a:suffix.": ".s:restoremap_{a:suffix}) +endfun + +" --------------------------------------------------------------------- +" RestoreUserMaps: {{{1 +" Used to restore user maps saved by SaveUserMaps() +fun! RestoreUserMaps(suffix) +" call Dfunc("RestoreUserMaps(suffix<".a:suffix.">)") + if exists("s:restoremap_{a:suffix}") + let s:restoremap_{a:suffix}= substitute(s:restoremap_{a:suffix},'|\s*$','','e') + if s:restoremap_{a:suffix} != "" +" call Decho("exe ".s:restoremap_{a:suffix}) + exe "silent! ".s:restoremap_{a:suffix} + endif + unlet s:restoremap_{a:suffix} + endif +" call Dret("RestoreUserMaps") +endfun + +" --------------------------------------------------------------------- +" Restore: {{{1 +let &cpo= s:keepcpo +unlet s:keepcpo + +" --------------------------------------------------------------------- +" Modelines: {{{1 +" vim: ts=4 fdm=marker diff --git a/plugin/cscope.vim b/plugin/cscope.vim new file mode 100644 index 0000000..b9ca444 --- /dev/null +++ b/plugin/cscope.vim @@ -0,0 +1,57 @@ +"======================================================================================================================= +" CSCOPE: http://vim.wikia.com/wiki/Cscope +"======================================================================================================================= + +augroup MAX_CSCOPE + if has('cscope') " compiled with cscope support? + set cscopetag " CTRL-] uses cscope first, then ctags + set cscopeverbose + + if has('quickfix') + set cscopequickfix=s+,c+,d+,i+,t+,e+ + endif + + if has('menu') + 1001menu &Cscope.find.c\ symbol + \<tab>s + \ :cscope find s <cword><:cR> + 1001menu &Cscope.find.definition + \<tab>g + \ :cscope find g <cword><:cR> + 1001menu &Cscope.find.functions\ called\ by\ this + \<tab>d + \ :cscope find d <cword><:cR> + 1001menu &Cscope.find.functions\ calling\ this + \<tab>c + \ :cscope find c <cword><:cR> + 1001menu &Cscope.find.text\ string + \<tab>t + \ :cscope find t <cword><:cR> + 1001menu &Cscope.find.egrep\ pattern + \<tab>e + \ :cscope find e <cword><:cR> + 1001menu &Cscope.find.this\ file + \<tab>f + \ :cscope find f <cword><:cR> + 1001menu &Cscope.find.files\ including\ this\ file + \<tab>i + \ :cscope find i <cword><:cR> + 1001menu &Cscope.find.places\ where\ this\ symbol\ is\ assigned\ a\ value + \<tab>a + \ :cscope find a <cword><:cR> + 1001menu &Cscope.-Sep1- + \ : + 1001menu &Cscope.create\ and\ add\ database + \ :cscope kill -1<CR>:execute '!find -type f -regex ".*\.\(c\\|h\\|cpp\\|cxx\\|hh\\|hpp\\|hxx\)$" <bar> cscope -i- -b -q -v'<CR>:cscope add .<CR> + 1001menu &Cscope.-Sep2- + \ : + 1001menu &Cscope.add\ \. + \ :cscope add .<CR> + 1001menu &Cscope.show + \ :cscope show<CR> + 1001menu &Cscope.reset + \ :cscope reset<CR> + endif + endif +augroup END " MAX_CSCOPE + diff --git a/plugin/jedi.vim b/plugin/jedi.vim new file mode 100644 index 0000000..dca8838 --- /dev/null +++ b/plugin/jedi.vim @@ -0,0 +1,15 @@ +" JEDI: ============================================================================================================== +augroup JEDI + if has("python") || has('python3') + let g:jedi#completions_enabled = 0 " we do not need completions, because we have YouCompleteMe + let g:jedi#show_call_signatures = 1 " which sadly does not support signatures like jedi + let g:jedi#show_call_signatures_delay = 0 + let g:jedi#auto_vim_configure = 0 + let g:pymode_rope = 0 " https://github.com/davidhalter/jedi-vim/issues/163 + " autocmd FileType python jedi.preload_module('os', 'sys', 'math') + " let g:pymode_options_max_line_length = 120 + " let g:syntastic_python_flake8_args='--ignore=F821,E302,E501,E241,E301' + + packadd jedi-vim + endif " has("python") +augroup END diff --git a/plugin/max-change-icon.vim b/plugin/max-change-icon.vim new file mode 100644 index 0000000..f544a5e --- /dev/null +++ b/plugin/max-change-icon.vim @@ -0,0 +1,11 @@ + + + +augroup ChangeIcon + "if filereadable("/usr/bin/xseticon") + "if filereadable("~/.vim/nvim.png") + " autocmd VimEnter * silent :execute "!xseticon -id $WINDOWID ~/.vim/nvim.png" + " autocmd VimLeave * silent :execute "!xseticon -id $WINDOWID /usr/share/icons/gnome/32x32/apps/xfce-terminal.png" + "endif + "endif +augroup END diff --git a/plugin/max-find-bash.vim b/plugin/max-find-bash.vim new file mode 100644 index 0000000..a5e243b --- /dev/null +++ b/plugin/max-find-bash.vim @@ -0,0 +1,9 @@ +"======================================================================================================================= +" SHELL: +" Many scripts rely on bash. We help to find the bash binary +"======================================================================================================================= +if filereadable("/bin/bash") + set shell=/bin/bash +elseif filereadable("/usr/local/bin/bash") + set shell=/usr/local/bin/bash +endif diff --git a/plugin/max-fix-colorschemes.vim b/plugin/max-fix-colorschemes.vim new file mode 100644 index 0000000..ac2af76 --- /dev/null +++ b/plugin/max-fix-colorschemes.vim @@ -0,0 +1,49 @@ +"======================================================================================================================= +" COLOR SCHEME: +"======================================================================================================================= +function! ExtendColorTheme() + highlight! Bold cterm=bold gui=bold + highlight! Italic cterm=italic gui=italic + highlight! Underline cterm=underline gui=underline + highlight! BoldUnderline cterm=bold,underline gui=bold,underline + highlight! BoldItalic cterm=bold,Italic gui=Bold,Italic + highlight! Todo cterm=bold gui=bold guibg=#ffffaa guifg=#000000 + highlight! Error ctermbg=NONE guibg=NONE + highlight! SpellBad cterm=NONE gui=undercurl guibg=NONE guifg=red + + + highlight! link SpecialKey NonText | " makes tab stop (see listchars) less disturbing + highlight! link EndOfBuffer Ignore + highlight! link WildMenu Search + highlight! link Convention Error + highlight! link VertSplit NonText + + highlight! link Folded LineNr + highlight! link SignColumn LineNr + highlight! link FoldColumn LineNr + + highlight! link PmenuSbar Pmenu + highlight! PmenuThumb cterm=inverse + highlight! MoreMsg cterm=inverse + + +endfunction +autocmd ColorScheme * call ExtendColorTheme() + + +if filereadable(expand("~/.vimrc_background")) && filereadable(expand("~/.config/base16-shell/colortest")) + let g:base16_shell_path = "~/.config/base16-shell/scripts" + let base16colorspace = 256 + set background=dark + source ~/.vimrc_background +else + let g:PaperColor_Theme_Options = { + \ 'theme': { + \ 'default': { + \ 'transparent_background': 0 + \ } + \ } + \ } + set background=light + colorscheme PaperColor +endif diff --git a/plugin/max-function-menu.vim b/plugin/max-function-menu.vim new file mode 100644 index 0000000..6c7308a --- /dev/null +++ b/plugin/max-function-menu.vim @@ -0,0 +1,173 @@ +augroup MAX_FUNCTION_MENU + if has('menu') + source $VIMRUNTIME/menu.vim + set wildmenu + set cpo-=< + set wcm=<C-Z> + + 01menu &Functions.toggle\ file\ browser + \<Tab><leader><leader> + \ <leader><leader> + 01menu &Functions.-Sep0- : + + 01menu &Functions.help + \<Tab><F1> + \ <F1> + 01menu &Functions.bp:\ previous\ buffer + \<Tab><F2> + \ <F2> + 01menu &Functions.bn:\ next\ buffer + \<Tab><F3> + \ <F3> + 01menu &Functions.^wc\:\ close\ window + \<Tab><F4> + \ <F4> + 01menu &Functions.-Sep1- : + + 01menu &Functions.make + \<Tab><F5> + \ <F5> + 01menu &Functions.clear\ matches,\ update\ viewport + \<Tab><F6> + \ <F6> + 01menu &Functions.copen\:\ show\ quickfix\ list + \<Tab><F7> + \ <F7> + 01menu &Functions.lopen\:\ show\ location\ list + \<Tab><F8> + \ <F8> + 01menu &Functions.-Sep2- : + + 01menu &Functions.toggle\ tagbar + \<Tab><F9> + \ <F9> + + if has("gui_running") == 0 + " in the gui F10 already triggers the menu, not in a terminal vim, so upgrade that... + map <F10> :emenu <C-Z> + endif + 01menu &Functions.activate\ menu\ (:emenu) + \<Tab><F10> + \ <F10> + + 01menu &Functions.undef11 + \<Tab><F11> + \ <F11> + 01menu &Functions.undef12 + \<Tab><F12> + \ <F12> + 01menu &Functions.-Sep2- : + + + 09menu &Directory.print\ current\ directory + \<Tab>:pwd + \ :pwd<CR> + + 09menu &Directory.-Sep- : + + 09menu &Directory.Change\ to\ GIT\ root + \<Tab>:Gcd + \ :Gcd<CR>:pwd<CR> + + 09menu &Directory.Change\ to\ current\ buffers\ directory\ (global) + \<tab>:cd\ %:p:h + \ :cd %:h<CR>:pwd<CR> + + 09menu &Directory.Change\ to\ current\ buffers\ directory\ (local\ window)<tab>:lcd\ %:p:h + \ :lcd %:p:h<CR>:pwd<CR> + + menu &Git.&Display\ uncommited\ files\ in\ location\ list + \ :call setloclist(0, map(systemlist("git diff --name-only --pretty=''"), {_, p->{'filename': fnamemodify(p, ':.')}}))<CR>:lopen<CR> + menu &Git.&Display\ recently\ changed\ files\ in\ quickfix\ list + \ :call setqflist([], 'r', {'title': 'Recently changed in GIT', 'items':map(systemlist("git show --name-only --pretty=''"), {_, p->{'filename': fnamemodify(p, ':.')}}) })<CR>:copen<CR> + menu &Git.&Display\ last\ changes + \ :let g:signify_vcs_cmds={'git': 'git diff --no-color --no-ext-diff -U0 HEAD^ -- %f'}<CR>:SignifyRefresh<CR> + menu &Git.&Display\ unmerged\ files\ in\ location\ list + \ :call setloclist(0, map(systemlist("git diff --name-only --diff-filter=U \| uniq"), {_, p->{'filename': fnamemodify(p, ':.')}}))<CR>:lopen<CR> + menu &Git.&Display\ significance\ of\ changes + \ :!git diff --stat HEAD~1..HEAD + menu &Git.&Display\ Changed\ files\ compared\ to\ master + \ :!git diff --name-status ..master + + menu &Match.Clear\ All\ Matches + \<Tab><F6> + \ :call clearmatches()<CR> + + menu &Match.-Sep- : + + menu &Match.&dispensable\ white\ spaces + \ :call matchadd("Convention", '\s\+$', 0)<CR> + + menu &Match.&long\ lines\ (exeeding\ textwidth) + \ :call matchadd("Convention", '\%>'.&textwidth.'v.', 0)<CR> + + menu &Match.Highlight\ current\ file\ name + \ :call matchadd("Search", escape(expand('%:t'), '.'))<CR> + + " :execute ':match SpellBad /'.escape(expand('%:t'), '.').'/'<CR> + + menu &Window.-Sep- : + + + menu &Window.Scratch + \ :Scratch<CR> + + + menu &Find.file\ under\ the\ cursor + \<Tab>gf + \ gf + + menu &Find.Open\ search\ results\ in\ location\ list + \<Tab>:gf + \ :execute ':vimgrep /'.escape(getreg('/'), '.').'/g %'<CR> + \ :copen<CR> + + menu &Changes.list + \<Tab>:changes + \ :changes<CR> + menu &Changes.-Sep- : + menu &Changes.previous + \<Tab>g; + \ g; + menu &Changes.next + \<Tab>g, + \ g, + menu &List.location.signs\ to\ list + \<Tab>CMD + \ :execute ":call setloclist(0, map(get(getbufinfo('%')[0], 'signs'), {_, p->extend(p, {'bufnr':buffer_number('.'), 'text':get(p, 'name')})}))"<CR> + menu &List.location.list\ to\ signs + \<Tab>CMD + \ :call execute(extend(['sign define LocationListEntry text=L', 'sign unplace *'], map(getloclist('%'), {key, val->'sign place '.(key+100).' name=LocationListEntry line='.val['lnum'].' buffer='.buffer_number('%')})))<CR> + menu &Jump.list + \<Tab>:jumps + \ :jumps<CR> + menu &Jump.-Sep1- : + menu &Jump.previous\ position + \<Tab>CTRL-O + \ <C-O> + menu &Jump.next\ position + \<Tab>CTRL-I + \ <C-I> + menu &Jump.-Sep2- : + menu &Jump.clear\ list + \<Tab>:clearjumps + \ :clearjumps + + 1000menu &Tag.list + \<Tab>:tags + \ :tags<CR> + 1000menu &Tag.selection\ list + \<Tab>:ts + \ :ts<CR> + + 1000menu &Tag.-Sep1- : + + 1000menu &Tag.stack.jump\ older + \<Tab><C-T> + \ :po + 1000menu &Tag.stack.jump\ + \<Tab>:ta + \ :ta + endif +augroup END " MAX_FUNCTION_MENU + diff --git a/plugin/max-highlight-word-under-cursor.vim b/plugin/max-highlight-word-under-cursor.vim new file mode 100644 index 0000000..d557b40 --- /dev/null +++ b/plugin/max-highlight-word-under-cursor.vim @@ -0,0 +1,18 @@ +"======================================================================================================================= +" HIGHLIGHT_WORD_UNDER_CURSOR: +"======================================================================================================================= + +let w:m1 = 0 +function! HighlightWordUnderCursor() + if(exists('w:m1') && w:m1 > 0) + silent! call matchdelete(w:m1) + let w:m1 = 0 + endif + let l:currentword = escape(expand('<cword>'), '.') + if(strlen(l:currentword) > 0) + let w:m1=100 + silent! call matchadd('BoldUnderline', '\<'.l:currentword.'\>', -1, w:m1) + endif +endfunction + +autocmd CursorHold,CursorHoldI * call HighlightWordUnderCursor() diff --git a/plugin/max-set-window-title.vim b/plugin/max-set-window-title.vim new file mode 100644 index 0000000..1a84ac3 --- /dev/null +++ b/plugin/max-set-window-title.vim @@ -0,0 +1,21 @@ + + +augroup SET_WINDOW_TITLE + set title + set titlelen=40 + + " set window title for screen(3) + " if &term == "screen" || &term == "xterm" + if &term == "screen" + set t_ts=k + set t_fs=\ + endif + + " autocmd BufEnter * let &titlestring = hostname() . "[vim(" . expand("%:t") . ")]" + " autocmd CursorHold * let &titlestring = "%t %y ".$USER."@".hostname().":%{expand("%:~:.:h")}" + " Fix terminal title ================================================================================================= + " autocmd VimEnter * let &t_EI .= "\<Esc>[0 q" + " autocmd VimEnter * let &t_SI = "\<Esc>]12;green\x7" + autocmd VimLeave * silent !echo -ne "\033]112\007" +augroup END + diff --git a/plugin/max-splash.vim b/plugin/max-splash.vim new file mode 100644 index 0000000..5282679 --- /dev/null +++ b/plugin/max-splash.vim @@ -0,0 +1,23 @@ +"======================================================================================================================= +" MAX_SPLASH: +" Shows recently used files from the current directory in a location list +"======================================================================================================================= + +" moved after VimEnter of statusline, so that it does not get overwritten any +" more +if empty(argv()) + + " autocmd VimEnter * call setloclist(0, filter(map(copy(v:oldfiles), {_, p->{'filename': expand(get(split(p, "'"), 0))}}), { val -> echo val})) + + " from the list of recent files: make absolute paths, filter out files not + " contained in cwd and finally filter out directories and non-files... + autocmd StdinReadPre * let s:std_in=1 + autocmd VimEnter * if !exists("s:std_in") | call setloclist(0, [], 'r', + \ { + \ 'title':'Recently used files in directory: '.getcwd(), + \ 'items':map(filter(filter( + \ map(copy(v:oldfiles), + \ {_, p->expand(p)}), 'v:val =~ "'.getcwd().'/"'), 'filereadable(v:val)'), + \ {_, p->{'filename': fnamemodify(p, ':.')}}) + \ }) | lopen | only | setfiletype qf +endif diff --git a/plugin/nerdtree.vim b/plugin/nerdtree.vim new file mode 100644 index 0000000..b9665fb --- /dev/null +++ b/plugin/nerdtree.vim @@ -0,0 +1,25 @@ +augroup NERDTREE + " NERDTree: replaces NetRW, as long as it has so many bugs + let NERDTreeIgnore = ['\.aux$', '\.o$'] + let NERDTreeCascadeSingleChildDir = 0 | " I don't get how one can use <m> to create files in that included directory + let NERDTreeChDirMode = 0 + let NERDTreeHiddenFirst = 1 + let NERDTreeMinimalUI = 1 + let NERDTreeShowBookmarks = 1 | " show bookmarks by default (when opening for the first time) + let NERDTreeWinSize = 40 + let NERDTreeQuitOnOpen = 1 + + " depending on if NERDTree has the focus: + nnoremap <expr> + \ <leader><leader> + \ bufwinnr("%")==g:NERDTree.GetWinNum() ? ':NERDTreeClose<CR>' : ':NERDTreeFind<CR>' + nnoremap <expr> + \ <F2> + \ bufwinnr("%")==g:NERDTree.GetWinNum() ? '<C-W><C-W>' : ':N<CR>' + + nnoremap <expr> + \ <F3> + \ bufwinnr("%")==g:NERDTree.GetWinNum() ? '<C-W><C-W>' : ':n<CR>' + + packadd nerdtree +augroup END diff --git a/plugin/netrw.vim b/plugin/netrw.vim new file mode 100644 index 0000000..d9029cc --- /dev/null +++ b/plugin/netrw.vim @@ -0,0 +1,16 @@ +augroup NETRW + " Deprecated with this configuration, but still useful when deactivating some Plugins + " NETRW: obsolete with NERDTree + let g:netrw_alto = 0 | " open files on the right + let g:netrw_altv = 1 | " open files on the right + let g:netrw_banner = 0 | " display help messages? + let g:netrw_browse_split = 4 | " 4=open in previous window + let g:netrw_fastbrowse = 2 | " manually refresh direcory list (avoids display errors) + let g:netrw_hide = 1 | " show not-hidden files only + let g:netrw_keepdir = 0 + let g:netrw_list_hide = '^\..*' | " Explore mode: hide files starting with dot + let g:netrw_liststyle = 3 | " 3=tree + let g:netrw_preview = 0 | " + let g:netrw_winsize = 20 | " window size in percent + let s:treedepthstring = "│ " +augroup END diff --git a/plugin/signify.vim b/plugin/signify.vim new file mode 100644 index 0000000..2ab41fe --- /dev/null +++ b/plugin/signify.vim @@ -0,0 +1,35 @@ +augroup SIGNIFY + " displays file changes in sign column + + let @l = ":let g:signify_vcs_cmds={'git': 'git diff --no-color --no-ext-diff -U0 HEAD^ -- %f'}|:SignifyRefresh" + + " use signify only with git (improves speed when loading buffers, see :h signify) + let g:signify_vcs_list = [ 'git' ] + + let g:signify_cursorhold_insert = 0 + let g:signify_cursorhold_normal = 0 + let g:signify_update_on_bufenter = 0 + let g:signify_update_on_focusgained = 0 + let g:signify_sign_show_count = 0 + + if has("multi_byte") && (&enc == 'utf-8' || &enc == 'utf-16' || &enc == 'ucs-4') + let g:signify_sign_add = '➕' + let g:signify_sign_delete = '➖' + let g:signify_sign_delete_first_line = '➖' + let g:signify_sign_change = '❇️' + let g:signify_sign_changedelete = '❇️' + endif + + function! SignifyColorScheme() + highlight! SignifySignAdd ctermbg=NONE + highlight! link SignifySignAdd SignColumn + highlight! link SignifySignChange SignColumn + highlight! link SignifySignDelete SignColumn + highlight! link SignifySignChangeDelete SignColumn + highlight! link SignifySignDeleteFirstLine SignColumn + endfunction + + packadd vim-signify + + autocmd VimEnter,ColorScheme * call SignifyColorScheme() +augroup END diff --git a/plugin/snippets.vim b/plugin/snippets.vim new file mode 100644 index 0000000..dcf265b --- /dev/null +++ b/plugin/snippets.vim @@ -0,0 +1,12 @@ + +augroup ULTISNIPS + if has("python") || has('python3') + let g:UltiSnipsExpandTrigger = '<Tab>'| " expands the snippet, be careful not to use <tab> elsewhere (ycm uses it by default, but it has been deactivated by g:ycm_key_list_select_completion) + let g:UltiSnipsJumpForwardTrigger = '<Tab>'| + let g:UltiSnipsJumpBackwardTrigger = '<S-Tab>'| + + packadd vim-snippets + packadd ultisnips + endif +augroup END + diff --git a/plugin/statusline.vim b/plugin/statusline.vim new file mode 100644 index 0000000..98fc4a9 --- /dev/null +++ b/plugin/statusline.vim @@ -0,0 +1,125 @@ +augroup MAX_FANCYLINE + set noshowmode | " mode will be shown twice, in lightline and below, so we want to deactivate one + set laststatus=2 | " required by AirLine and Lightline, without status line does not appear until a window split + + let g:status_sym_start = '' + let g:status_sym_end = '' + let g:status_sym_sep_start = '' + let g:status_sym_sep_end = '' + let g:symbol_branch = '' + + if &term == "linux" + let g:symbol_branch = '' + + let g:group_active = "StatusLineTerm" + let g:group_inactive = "StatusLineTermNC" + let g:group_tabline = "StatusLineTerm" + else + let g:group_active = "StatusLine" + let g:group_inactive = "StatusLineNC" + let g:group_tabline = "TabLine" + endif + + " this function reverts foreground color and background color of a given + " highlight group and returns the name of a newly created _invert group + function! CreateInvertGroup(highlight_group) + if(synIDattr(hlID(a:highlight_group), "reverse")==1) + let w:color=synIDattr(hlID(a:highlight_group), "fg#") + else + let w:color=synIDattr(hlID(a:highlight_group), "bg#") + endif + + let l:retval=a:highlight_group.'_invert' + if(exists('w:color') && w:color == '') + let w:color = 'NONE' + endif + silent! exec 'highlight '.retval.' gui=NONE guifg='.w:color.' cterm=NONE ctermfg='.w:color + return l:retval + endfunction + + function! UpdateStatus(highlight_group) + let l:invert_group = CreateInvertGroup(a:highlight_group) + let l:mode = get({ + \ 'n' : 'normal', + \ 'i' : 'insert', + \ 'R' : 'replace', + \ 'v' : 'visual', + \ "V" : 'visual line', + \ "\<C-V>" : 'visual block', + \ 'c' : 'command', + \ 's' : 'select', + \ 'S' : 'select line', + \ "\<C-s>" : 'select block', + \ 't' : 'terminal' + \ }, mode(), mode()) + return '' + \ ."%#StatusLineHighlight#" + \ ."%#".a:highlight_group."#" + \ ."%(%w%h%q%)".' '.l:mode.' '.g:status_sym_sep_start.' ' + \ ."%{(argc()>0\ ?\ argidx()+1.':'.argc().' '.g:status_sym_sep_start.' '\ :\ '')}" + \ ."%{winbufnr(0).' '.g:status_sym_sep_start}" + \ ."%{(&readonly\ ?\ '\ \ 🔒'\ :\ '')}" + \ ."%{(&modified\ ?\ '\ \ '.nr2char(0xF0C7).'\ '\ :\ '')\ }" + \ ."%{(haslocaldir() ?\ fnamemodify(getcwd(),\ ':.').' '.nr2char(0xe0b1)\ \:\ '')}\ " + \ ."%{(&buftype\ ==\ \"terminal\"\ ?\ has('nvim')?b:term_title:expand(&titlestring)\ :\ substitute(expand('%:p'),\ '^'.getcwd(-1).'/*',\ '',\ ''))\ }" + \ ."%1(%)" + \ ."%#".l:invert_group."#" + \ .g:status_sym_end + \ .'' + \ ."%=" + \ .'' + \ ."%#".l:invert_group."#" + \ .g:status_sym_start + \ ."%#".a:highlight_group."#" + \ ."%1(%)" + \ ."%{(&filetype\ !=\ ''\ ?\ &filetype\ :\ &buftype)}" + \ ."%(\ %{g:status_sym_sep_end}\ %)" + \ ."%{(&spell\ ?\ &spelllang.' '.g:status_sym_sep_end\ :\ '')}" + \ ."%{(&fileencoding\ !=\ ''\ ?\ &fileencoding.' '.g:status_sym_sep_end.' '\ :\ '')}" + \ ."%{(&fileformat\ !=\ ''\ ?\ ' '.&fileformat.' '\ :\ '')}" + \ .g:status_sym_sep_end.' ' + \ ."%4l:%-3c" + \ .g:status_sym_sep_end.' ' + \ ."%-3p%%" + endfunction + + function! UpdateTabline(highlight_group) + let l:invert_group = CreateInvertGroup(a:highlight_group) + return '' + \ ."%#".a:highlight_group."#" + \ ."%3( \ %)\ " + \ ."%{getcwd(-1)}\ " + \ .g:status_sym_sep_start.' ' + \ ."%(\ ".g:symbol_branch."\ %{fugitive#head()}\ %)" + \ ."%#".l:invert_group."#" + \ .g:status_sym_end + \ .'' + \ ."%=" + \ .'' + \ ."%#".l:invert_group."#" + \ .g:status_sym_start + \ ."%#".a:highlight_group."#" + \ ."%3(\ %)" + \ ."%(%{v:servername}\ %{v:this_session}%)" + \ .g:status_sym_sep_end.' ' + \ ."%(\ \ %{tabpagenr()}/%{tabpagenr('$')}\ %)" + \ ."%##" + \ ."" " end + endfunction + + function! ApplyColorScheme() + " set termguicolors | " When on, uses highlight-guifg and highlight-guibg attributes in the terminal (=24bit color) incompatible with nvim + " set t_ut= + " set up statusline, global and current window individually + set statusline=%!UpdateStatus(g:group_inactive) + setlocal statusline=%!UpdateStatus(g:group_active) + " set up the tabline (match colors) + set tabline=%!UpdateTabline(g:group_tabline) + endfunction + " apply colors from the loaded colorscheme... + " when changing the colorscheme also apply new colors to the statusbar... + autocmd VimEnter,ColorScheme * call ApplyColorScheme() + + autocmd WinEnter * setlocal statusline=%!UpdateStatus(g:group_active) + autocmd WinLeave * setlocal statusline< +augroup END " MAX_FANCYLINE diff --git a/plugin/tagbar.vim b/plugin/tagbar.vim new file mode 100644 index 0000000..2758f20 --- /dev/null +++ b/plugin/tagbar.vim @@ -0,0 +1,10 @@ +augroup TAGBAR + let g:tagbar_autoclose = 0 + let g:tagbar_autofocus = 1 + let g:tagbar_autoshowtag = 0 + let g:tagbar_compact = 1 + let g:tagbar_indent = 0 + let g:tagbar_foldlevel = 99 + + packadd tagbar +augroup END diff --git a/plugin/terminal.vim b/plugin/terminal.vim new file mode 100644 index 0000000..c8f02fd --- /dev/null +++ b/plugin/terminal.vim @@ -0,0 +1,19 @@ +augroup TERMINAL + " Vim 8 has a terminal command... + if has('terminal') + " use default ESC key to leave insert mode in the internal terminal emulator + tnoremap <Esc> <C-W>N + " make terminal windows hidden by default (copied from :help terminal) + autocmd BufWinEnter * if &buftype == 'terminal' | setlocal bufhidden=hide | endif + endif + + " NEOVIM_incompatible: + if has('nvim') " Neovim? + autocmd TermOpen term://* set nobuflisted + " use default ESC key to leave insert mode in the internal terminal emulator + tnoremap <Esc> <C-\><C-n> + + menu &UI.&Open\ in\ Serversession + \ :execute ':!nvr --servername /tmp/nvimsocket --remote % +'.line('.')<CR>:stopinsert<CR>:set readonly<CR> + endif +augroup END diff --git a/vim.desktop b/vim.desktop deleted file mode 100644 index f8efe76..0000000 --- a/vim.desktop +++ /dev/null @@ -1,13 +0,0 @@ -[Desktop Entry] -X-Desktop-File-Install-Version=0.23 -Type=Application -Name=Vi IMproved->buffer2 -Icon=gvim -Comment=Open file in an existing instance of vi and in a new tab -MimeType=text/english;text/plain;text/x-makefile;text/x-c++hdr;text/x-c++src;text/x-chdr;text/x-csrc;text/x-java;text/x-moc;text/x-pascal;text/x-tcl;text/x-tex;application/x-shellscript;text/x-c;text/x-c++; -X-XClassHintResName=VIM -Categories=Application;Utility;TextEditor; -# Exec=vim --servername VIM --remote-silent %F -Exec=xfce4-terminal -e "bash -c '~/.bashrc ; vim --servername VIM --remote-silent %F'" -Terminal=true -StartupNotify=true diff --git a/vimpagerrc b/vimpagerrc index 9516d3c..89cdb4f 100644 --- a/vimpagerrc +++ b/vimpagerrc @@ -1,10 +1,10 @@ -let g:vimpager = {} -let g:less = {} -let g:less.enabled = 0 -let g:less.number = 1 -let g:less.hlsearch = 0 +let g:vimpager = {} +let g:less = {} +let g:less.enabled = 0 +let g:less.number = 1 +let g:less.hlsearch = 0 let g:vimpager.ansiesc = 0 -let g:less.enabled = 0 +let g:less.enabled = 0 set noswapfile set viminfo+=% | " restore buffer list diff --git a/vimrc b/vimrc deleted file mode 120000 index 9a5cefb..0000000 --- a/vimrc +++ /dev/null @@ -1 +0,0 @@ -vimrc-full \ No newline at end of file diff --git a/vimrc b/vimrc new file mode 100644 index 0000000..1b9f20b --- /dev/null +++ b/vimrc @@ -0,0 +1,49 @@ +exec ':source '.fnamemodify($MYVIMRC,':h').'/vimrc-common' + +set packpath+=pack/vim + + +set ttymouse=xterm2 +set ttyscroll=100 | " improves speed for terminal vim, incompatible with nvim +set ttyfast | " improves speed for terminal vim (incompatible with nvim) +set nottybuiltin | " use external termcaps +set restorescreen | " restores the console after exiting vim (intentionally not in nvim) + +autocmd VimLeave * call system("echo -n $'" . escape(getreg(), "'") . "' | xsel -ib") + + +" scripts from the default vim installation, which do not get loaded by default, but are useful. +if filereadable($VIMRUNTIME.'/macros/editexisting.vim') + packadd! editexisting +endif + +" load default plugin 'matchit' to allow % to jump between tags +if filereadable($VIMRUNTIME.'/macros/matchit.vim') + packadd! matchit +endif + +"======================================================================================================================= +augroup YOUCOMPLETEME + let g:ycm_error_symbol = '✖' " insert this as an error symbol in the gutter bar/sign column + let g:ycm_warning_symbol = '➔' " insert this as a warning symbol in the gutter bar/sign coloumn + + let g:ycm_autoclose_preview_window_after_insertion = 0 + let g:ycm_auto_trigger = 1 + let g:ycm_collect_identifiers_from_tags_files = 1 " Let YCM read tags from Ctags file + let g:ycm_confirm_extra_conf = 0 " security is overrated ;) + let g:ycm_always_populate_location_list = 0 " we can manually run :YcmDiags to do that + + let g:ycm_key_list_previous_completion = ['Up'] + let g:ycm_key_list_select_completion = ['Down'] + + let g:ycm_semantic_triggers = + \ { + \ 'c': [ 're!\w{2}' ] + \ } " per language configurations + + + packadd YouCompleteMe +augroup END + + + diff --git a/vimrc-common b/vimrc-common new file mode 100644 index 0000000..00c7996 --- /dev/null +++ b/vimrc-common @@ -0,0 +1,355 @@ +"======================================================================================================================= +" GENERAL: +" It is likely, that you will want to overwrite these settings with a +" project-local .vimrc file (activated with exrc setting) +"======================================================================================================================= + +set exrc | " enable exrc, a specific .exrc per project, which can contain usual .vimrc commands +set modeline | " set variables specific to a file, like indentation by adding a comment +set textwidth=0 | " better done with modeline or local exrc and not here +set ts=4 sts=4 sw=4 expandtab | " better done with a modeline or local exrc +set virtualedit=all | " virtual edit should be default behaviour, because I don't see any reason against +set nonumber norelativenumber | " do not show numbers by default, because that causes a performance loss, instead activate them on a file type basis +set ignorecase smartcase | " search with ignore case by default, but use case sensitive search when one capital char is contained and highlight while typing (even though its slower) +set hlsearch incsearch | " highlight pattern while entering it (performance wise this isn't that good) +set cindent cinoptions+=(0 | " indent at parentheses + +set path+=** | " allow recursive searches for files +let &path = &path.",/usr/lib/modules/".substitute(system('uname -r'), "\n", "", "")."/build/include" + +filetype on +filetype plugin on +filetype indent on + +syntax on | " enable syntax highlighting +syntax sync minlines=60 | " how many preceding lines will be parsed? (has performance impact) + +"======================================================================================================================= +" SPELL_CHECKING: +"======================================================================================================================= +let g:spellfile_URL='http://ftp.vim.org/vim/runtime/spell' +" add local user default spell file as primary source for words +let &spellfile=fnamemodify($MYVIMRC, ":p:h")."/spell/spellfile-user.UTF-8.add" + +set nospell | " disable spell checker by default +set spelllang=en,de | " languages for the spell checker +set spellsuggest=10 | " how many words will z= suggest? +set thesaurus+=~/.vim/thesaurus/php.txt + + +"======================================================================================================================= +" UNDO: +" Persistent undo behaviour, also keeps undo history between starts +"======================================================================================================================= +if has('persistent_undo') + if isdirectory('/dev/shm') + set undodir=/dev/shm/ | " save undo file in memory. That is volatile, but fast and we have GIT for longer lasting undoes + set directory=/dev/shm/ | " swap file directory to RAM + set swapfile + elseif isdirectory('/tmp/') + set undodir=/tmp/ + endif + set undofile | " preserve undo history when closing and reopening buffers (see :help undo-persistence) +endif + + +"======================================================================================================================= +" MULTI_BYTE: +"======================================================================================================================= +if has("multi_byte") + scriptencoding utf-8 | " tell vim that we are using UTF-8 here + set encoding=utf-8 | " we need default UTF-8 encoding to use cool chars as line break and so on (see below) + set termencoding=utf-8 | " we just assume that this is supported. + + set fillchars= | " initialize empty fillchars + set listchars= | " initialize empty listchars + + if &term == "linux" + set fillchars+=vert:\│ | " cool vertical split char + else + set fillchars+=vert:\║ | " cool vertical split char + endif + + set fillchars+=fold:\ | " + set fillchars+=diff:\ | " a white space gets used here + + set listchars+=extends:» | " symbols used when using :set list (which displays non-printable chars) + set listchars+=precedes:« | " symbols used when using :set list (which displays non-printable chars) + + set listchars+=tab:▏\ | " + set listchars+=trail:· | " symbols used when using :set list (which displays non-printable chars) + " set listchars+=eol:↲ | " symbols used when using :set list (which displays non-printable chars) + " set listchars+=space:· | " symbols used when using :set list (which displays non-printable chars) + set showbreak+=› | " symbol used in the beginning of a wrapped line + + " automatically enter list mode when going in insert mode (makes above syntax command temporarily ineffective) + set nolist + + autocmd InsertEnter * set list + autocmd InsertLeave * set list& + + + autocmd InsertEnter * set colorcolumn=80,120 + autocmd InsertLeave * set colorcolumn& + + + " set fillchars+=stlnc:\― | " +end + +" ====================================================================================================================== +" SETTINGS: +" ====================================================================================================================== +set breakindent | " Every wrapped line will continue visually indented +set clipboard=unnamedplus | " makes copy and paste work (autoselectplus might work as well) +set concealcursor=nc | " limits the display of concealed text to normal and command mode +set conceallevel=2 | " replace escaped chars by their UTF-8 representation (useful for LaTeX) +set confirm | " asks 'do you want to save?' +set cpoptions+=P | " makes :w filename set the current buffer to filename +set hidden | " allows switching buffers even if the current buffer contains changes (displays +) +set linebreak | " wrap long lines at char 'breakat', not inside words +set mousemodel=popup | " only in gvim: right click opens a pop-up-menu +set mouse=n | " allow mouse in normal mode only, so one can use the terminals c&p feature in insert mode +set noautochdir | " When on, Vim will change the current working directory +set nostartofline | " when scrolling: do not move the cursor to column 1 +set nowrap | " but do not (by default) wrap long lines around +set nrformats+=alpha | " allows CTRL-A & CTRL-X to increment and decrement letters, not just numbers + +if has('nvim') " Neovim? + set inccommand=nosplit | " preview substitute and such things in real time +endif + +set pumheight=8 | " Determines the maximum number of items to show in the pop-up menu for +set scrolljump=5 | " how many lines get scrolled into view when cursor reaches the screens edge +set scrolloff=0 | " keeps cursor centered +set shiftround | " indent/un-indent snaps to multiple of shiftwidths +set writedelay=0 + +" display and performance +set lazyredraw | " disables redraw during macro execution (improves performance) +set cmdheight=2 | " sets the command line's height +set signcolumn=auto | " auto=auto hide, yes=always, no=never show the column with error indicators +set nocursorcolumn | " turn visual cursor column off (improves performance) +set updatetime=80 | " updates the screen more often +set redrawtime=1500 | " Timeout in milliseconds for redrawing the screen (switches syntax off when ssh too slow) / CTRL+L to retry +set notimeout | " improves performance but is known to cause problems on slow terminals +set ttimeout ttimeoutlen=150 | " set Esc key timeout in ms- +set showcmd | " essential: show keys of combined commands in the lower right corner (BUT SLOW, makes cursor flickering) +set showtabline=2 | " 0: never, 1: only if there are at least two tabs, 2:always +set shortmess+=I | " don't give the intro message when starting Vim |:intro|. +set wildmenu | " use a menu in the command line +set wildmode=longest:full | " do not preselect any entry and show all possible + +" code completion +" set dictionary=/usr/share/dict/cracklib-small +" set complete+=k " make default completer <C-N> respect the dictionary +set complete-=u " scan current and included files +set complete+=i " scan current and included files +set complete+=d " scan current and included files for defined name or macro +set complete+=d | " scan current and included files for defined name or macro +set complete+=i | " scan current and included files for completions +set completeopt+=noinsert | " Do not insert any text for a match until the user selects one +set completeopt+=noselect | " Do not select a completion from the menu, let the user do that +set tagcase=match | " tagcase match, because we mostly use ^] to jump around and that variant respects the upper/lower case [followscs, followic, match, ignore] +set tags+=../tags + +" code folding... +set nofoldenable | " disable folding, because we have zi to toggle foldenable :) +set foldclose=all | " automatically fold, when the cursor leaves the folded area +set foldcolumn=2 | " I think I don't need this second indicator +" set numberwidth=5 +" set foldmethod=syntax | " foldlevel: syntax, indent, manual / foldmethod=syntax makes Vim incredible slow +set foldnestmax=1 | " top level folding only +set foldopen=block,hor,search | " when do we unfold? +set foldtext=printf('%*s%.*S',indent(v:foldstart),'',&textwidth-indent(v:foldstart),substitute(substitute(join(getline(v:foldstart,v:foldend),'\ '),'[[:space:]]\\+','\ ','g'),'^[[:space:]*]','','g')) + +" works ... +" set foldexpr=match(synIDattr(synID(v:lnum,indent(v:lnum)+1,0),'name'),'Comment')>-1 +set foldexpr=!empty(filter(synstack(v:lnum,indent(v:lnum)+1),{_,val->match(synIDattr(val,'name'),'Comment')>-1})) + + +" vim window behaviour +set splitbelow | " open new windows below the current one (i find that more intuitive) +set splitright | " this also works for me and makes better use of the scren space I think +set winminwidth=0 | " (and all other windows, so TODO: watch out) +set winwidth=30 | " keep NERDTreeWindow at least this size + + +" vim session handling and restore behaviour +set viminfo+=% | " restore buffer list +set sessionoptions= +set sessionoptions+=buffers +set sessionoptions+=curdir +set sessionoptions+=folds +set sessionoptions+=resize +set sessionoptions+=slash +set sessionoptions+=tabpages +set sessionoptions+=unix +set sessionoptions+=winpos +set sessionoptions+=winsize + +" set nocindent smartindent | " use smart indent rather then cindent +set noautoindent +set nosmartindent + +set noshiftround | " indent/un-indent sna=ps to multiple of shiftwidths +set noequalalways | " do not evenly size windows when opening new or closing old +set nocursorline | " turn visual cursor line off (improves performance) + +"======================================================================================================================= +if has("autocmd") + " use the shada/viminfo file to return the cursor to where it was... + autocmd BufReadPost * call setpos(".", getpos("'\"")) + autocmd BufWinEnter * if &previewwindow | setlocal nonumber nolist signcolumn=no filetype=c nobuflisted | endif + autocmd TextYankPost * echo '> text yanked to '. + \ (get(v:event,'regname') == '' + \ ? 'default register' + \ : 'register '.get(v:event,'regname')) + + + autocmd InsertLeave * silent! call matchadd('Convention', ' \+$', -1, 101, { 'conceal': '⟶' }) + autocmd InsertEnter * silent! call matchdelete(101) + + + "==================================================================================================================== + augroup FILETYPES + " indent within <script> and <style> (default is a zero indent) + let g:html_indent_script1 = "inc" + let g:html_indent_style1 = "inc" + + let g:loaded_ruby_provider = 1 " disable ruby support + let g:loaded_python_provider = 1 " disable python 3 + + let g:LatexBox_latexmk_preview_continuously = 1 + let g:LatexBox_viewer = "evince" + + autocmd FileType python setlocal keywordprg=pydoc + autocmd FileType vim setlocal keywordprg=:help |. + autocmd FileType conf setlocal isfname-== + autocmd FileType c,cpp setlocal equalprg=clang-format + autocmd FileType c,cpp setlocal breakat-=- + autocmd FileType c,cpp setlocal keywordprg=man\ 3 + autocmd FileType c,cpp map <buffer> = :pyf /usr/share/clang/clang-format.py<CR> + autocmd Filetype css command! CSSsort :g/{/+1;/}/-1 sort + autocmd Filetype html,markdown,xml iabbrev </ </<C-X><C-O> + + autocmd Filetype html,htmldjango,xml + \ :nnoremap + \ <M-Down> + \ :call search('^ *<', 'e')<CR>:nohlsearch<CR>| + \ :nnoremap + \ <M-Up> + \ :call search('^ *<', 'eb')<CR>:nohlsearch<CR>| + \ :nnoremap + \ <leader>= + \ vat:'<,'>!tidy -xml --wrap 0 --sort-attributes alpha 2>/dev/null<CR>vat= + + if filereadable("/usr/bin/vendor_perl/ack") + autocmd FileType c,cpp set grepprg=/usr/bin/vendor_perl/ack\ --type=cc\ --nogroup\ --column\ $* + autocmd FileType c,cpp set grepformat=%f:%l:%c:%m + endif + augroup END +endif + +" ====================================================================================================================== +augroup CUSTOM_COMMANDS + command! Vimls + \ call setloclist(0, map(getbufinfo({'buflisted':1}), + \ "{'bufnr': v:val.bufnr, + \ 'lnum': v:val.lnum, + \ 'text': '='.printf('%*s, % 3d: %s [%s]', winwidth(0) / 2, '', v:val.bufnr, v:val.name, getbufvar(v:val.bufnr, '&buftype')), + \ 'pattern': 'not loaded'} + \ ")) + command! Ctoggle + \ if(get(getqflist({'winid':1}), 'winid') == win_getid())|cclose|else|botright copen|endif + command! Ltoggle + \ if(get(getloclist(0, {'winid':1}), 'winid') == win_getid())|lclose|else|lopen|endif + command! BuffersToArg :exec ':args '.join(map(range(0, bufnr('$')), 'fnameescape(fnamemodify(bufname(v:val), ":."))')) + command! BufToArg :argadd %:. + command! Gbranch call setqflist([], 'r', {'title':'Git branch selector','items':map(systemlist("git branch"), {_, p->{'filename':'branch','module': fnamemodify(p, ':.')}})}) + " the following command opens a preview-window and shows the declaration of + " the function under the cursor. It also highlights the word to make it easier + " to spot within a great file + command! Helpme au! CursorHold * nested let @/=expand('<cword>')|exe "silent! psearch ".expand("<cword>") + command! FindInAllBuffers cex [] | bufdo vimgrepadd //g % | cw +augroup END + +"======================================================================================================================= +augroup KEYBOARD_MAPPING + " map CTRL-PageUp/Down to next/previous buffer + " and Shift-PageUp/Down to next/previous arglist file + nnoremap <C-PageUp> :bn<CR> + nnoremap <C-PageDown> :bp<CR> + nnoremap <S-PageUp> :N<CR> + nnoremap <S-PageDown> :n<CR> + + + nnoremap <F4> :wincmd c<CR> + + nnoremap <F5> :make!<CR> + nnoremap <F6> :silent syntax sync fromstart<CR>:nohlsearch<CR>:silent match<CR>:silent 2match<CR>:silent 3match<CR> + nnoremap <F7> :Ltoggle<CR> + nnoremap <F8> :Ctoggle<CR> + + nnoremap <F9> :TagbarToggle<CR> + nnoremap <F12> :Vimls<CR>:Ltoggle<CR> + + " close current buffer with <leader>q... + nnoremap <leader>q :bp<bar>sp<bar>bn<bar>bd<CR>. + nnoremap <leader>r :syntax sync fromstart + + nnoremap <silent> <A-Up> :wincmd k<CR> + nnoremap <silent> <A-Down> :wincmd j<CR> + nnoremap <silent> <A-Left> :wincmd h<CR> + nnoremap <silent> <A-Right> :wincmd l<CR> + + + inoremap <C-S> <C-O>:w<CR> + + " exec current line as a command, insert output of command (from: https://youtu.be/MquaityA1SM?t=35m45s) + nnoremap <leader>Q !!$SHELL<CR> + " google the word under the cursor + nnoremap <leader>G :execute ":!xdg-open https://google.de/search?q=".expand("<cword>") + " display highlight group under the cursor + nnoremap <leader>h :echo map(synstack(line('.'), col('.')), 'synIDattr(v:val, "name")')<CR> + + + " ====================================================================================================================== + " SHORTCUTS: custom shortcuts + " inoremap <C-Space> <C-x><C-o> + " inoremap <C-@> <C-Space> + + " Bind CTRL+Backspace to vim's version (CTRL+W) in " <CR> insert mode (only works with gvim) + inoremap + \ <C-Backspace> + \ <C-W> + + " INDENTATION: allows un-indenting a selected block and keeps selection + vnoremap < <gv + vnoremap > >gv + + " make shift-home select to the beginning of the line + nnoremap <s-home> v^ + nnoremap <s-end> v$ + + nnoremap <s-down> vj + vnoremap <s-down> j + nnoremap <s-up> vk + vnoremap <s-up> k + + + + " INSERT_MODE_MAPPINGS: + " default copy&paste insert key binding (just in insert mode, so it doesn't conflict + " with visual block mode)- would have been nice, but collides with c-w for digraphs + " inoremap <C-V> <C-R>+ + + " NEOVIM_SPECIFIC: + if has('nvim') " only neovim... + " shortcut \t opens a terminal in a horizontal split + nnoremap <leader>t :new +terminal<CR> + endif +augroup END + +"======================================================================================================================= +" v modeline, do not chnage v +" vim: noai:ts=2:sw=2:sts=2 iskeyword+=\:,\<,\>,\-,\& number diff --git a/vimrc-full b/vimrc-full deleted file mode 100644 index 7512908..0000000 --- a/vimrc-full +++ /dev/null @@ -1,1255 +0,0 @@ -" vim: noai:ts=2:sw=2:sts=2 iskeyword+=\:,\<,\>,\-,\& number - -"======================================================================================================================= -" GENERAL: -"======================================================================================================================= -set exrc | " enable exrc, a specific .exrc per project, which can contain usual .vimrc commands -set textwidth=0 | " better done with modeline or local exrc and not here -set ts=4 sts=4 sw=4 expandtab | " better done with a modeline or local exrc -set virtualedit=all | " virtual edit should be default behaviour, because I don't see any reason against -set nonumber norelativenumber | " do not show numbers by default, because that causes a performance loss, instead activate them on a file type basis -set ignorecase smartcase hlsearch | " search with ignore case by default, but use case sensitive search when one capital char is contained and highlight while typing (even though its slower) -set cindent cinoptions+=(0 | " indent at parentheses - - -set path+=** | " allow recursive searches for files -let &path = &path.",/usr/lib/modules/".substitute(system('uname -r'), "\n", "", "")."/build/include" - -"======================================================================================================================= -" SHELL -"======================================================================================================================= -if filereadable("/bin/bash") - set shell=/bin/bash | " many scripts rely on bash, but its path varies why it is commented out here -elseif filereadable("/usr/local/bin/bash") - set shell=/usr/local/bin/bash -endif - -"======================================================================================================================= -" Persistent undo -"======================================================================================================================= -if has('persistent_undo') - if isdirectory('/dev/shm') - set undodir=/dev/shm/ | " save undo file in memory. That is volatile, but fast and we have GIT for longer lasting undoes - set directory=/dev/shm/ | " swap file directory to RAM - set swapfile - elseif isdirectory('/tmp/') - set undodir=/tmp/ - endif - set undofile | " preserve undo history when closing and reopening buffers (see :help undo-persistence) -endif - -"======================================================================================================================= -" multi byte -"======================================================================================================================= -if has("multi_byte") - scriptencoding utf-8 | " tell vim that we are using UTF-8 here - set encoding=utf-8 | " we need default UTF-8 encoding to use cool chars as line break and so on (see below) - let &termencoding=&encoding | " once we use special chars we assume everybody uses a terminal supporting those - - set fillchars= | " initialize empty fillchars - set listchars= | " initialize empty listchars - - if &term == "linux" - set fillchars+=vert:\│ | " cool vertical split char - else - set fillchars+=vert:\║ | " cool vertical split char - endif - - set fillchars+=fold:\ | " - set fillchars+=diff:\ | " a white space gets used here - - set listchars+=extends:» | " symbols used when using :set list (which displays non-printable chars) - set listchars+=precedes:« | " symbols used when using :set list (which displays non-printable chars) - - set listchars+=tab:▏\ | " - set listchars+=trail:· | " symbols used when using :set list (which displays non-printable chars) - " set listchars+=eol:↲ | " symbols used when using :set list (which displays non-printable chars) - " set listchars+=space:· | " symbols used when using :set list (which displays non-printable chars) - set showbreak+=› | " symbol used in the beginning of a wrapped line - - " automatically enter list mode when going in insert mode (makes above syntax command temporarily ineffective) - set nolist - autocmd InsertEnter * set list - autocmd InsertLeave * set nolist -" set fillchars+=stlnc:\― | " -end - - -"======================================================================================================================= -" SPELL_CHECKING -"======================================================================================================================= -let g:spellfile_URL='http://ftp.vim.org/vim/runtime/spell' -" add local user default spell file as primary source for words -let &spellfile=fnamemodify($MYVIMRC, ":p:h")."/spell/spellfile-user.UTF-8.add" - -set nospell | " disable spell checker by default -set spelllang=en,de | " languages for the spell checker -set spellsuggest=10 | " how many words will z= suggest? -set thesaurus+=~/.vim/thesaurus/php.txt - -"======================================================================================================================= -" cscope -"======================================================================================================================= -" http://vim.wikia.com/wiki/Cscope -if has('cscope') " compiled with cscope support? - set cscopetag " CTRL-] uses cscope first, then ctags - set cscopeverbose - - if has('quickfix') - set cscopequickfix=s+,c+,d+,i+,t+,e+ - endif - - if has('menu') - 1001menu &Cscope.find.c\ symbol - \<tab>s - \ :cscope find s <cword><:cR> - 1001menu &Cscope.find.definition - \<tab>g - \ :cscope find g <cword><:cR> - 1001menu &Cscope.find.functions\ called\ by\ this - \<tab>d - \ :cscope find d <cword><:cR> - 1001menu &Cscope.find.functions\ calling\ this - \<tab>c - \ :cscope find c <cword><:cR> - 1001menu &Cscope.find.text\ string - \<tab>t - \ :cscope find t <cword><:cR> - 1001menu &Cscope.find.egrep\ pattern - \<tab>e - \ :cscope find e <cword><:cR> - 1001menu &Cscope.find.this\ file - \<tab>f - \ :cscope find f <cword><:cR> - 1001menu &Cscope.find.files\ including\ this\ file - \<tab>i - \ :cscope find i <cword><:cR> - 1001menu &Cscope.find.places\ where\ this\ symbol\ is\ assigned\ a\ value - \<tab>a - \ :cscope find a <cword><:cR> - 1001menu &Cscope.-Sep1- - \ : - 1001menu &Cscope.create\ and\ add\ database - \ :cscope kill -1<CR>:execute '!find -type f -regex ".*\.\(c\\|h\\|cpp\\|cxx\\|hh\\|hpp\\|hxx\)$" <bar> cscope -i- -b -q -v'<CR>:cscope add .<CR> - 1001menu &Cscope.-Sep2- - \ : - 1001menu &Cscope.add\ \. - \ :cscope add .<CR> - 1001menu &Cscope.show - \ :cscope show<CR> - 1001menu &Cscope.reset - \ :cscope reset<CR> - endif -endif - -" ====================================================================================================================== -" GUI_VERSION -" ====================================================================================================================== -if has("gui_running") - set guicursor=a:block-blinkon100 - set browsedir=buffer - set toolbar+=text - set guiheadroom=0 - set guioptions+=eig - set guioptions-=T | " toolbar - set guioptions+=c | " use console dialogues instead of popups - set guioptions+=a | " auto select: copy&paste using middle click - set guioptions+=m | " remove menu - set guioptions-=e | " do not display tabs - set guioptions-=L | " do not show left scrollbar - set guioptions-=r | " do not show right scrollbar - set winaltkeys=menu | " behave like other windows: ALT-key can be used to open the menu (and cannot be :remaped) -" set selectmode=mouse,key,cmd | " enters vim's select mode when pressing shift-left or shift-END -" set keymodel=startsel,stopsel | " makes shift-left, shift-right available for selecting text - - - " its possible to define alternative fonts (order matters) - set guifont=Monospace\ 10 - set guifont+=Noto\ Sans\ Mono\ Bold - set guifont+=Noto\ Sans\ Mono\ Bold - set guifont+=Hasklug\ Nerd\ Font\ Mono\ Semi-Bold\ 10 - set guifont+=Hasklig\ Semi-Bold\ 10 - set guifont+=Bitstream\ Vera\ Sans\ Mono\ 10 - set guifont+=FuraMono\ Nerd\ Font\ Mono\ Medium\ 11 - set guifont+=Source\ Code\ Pro\ for\ Powerline\ SemiBold\ 10 - set guifont+=LiterationMono\ Nerd\ Font\ Mono\ 10 - set guifont+=RobotoMono\ Nerd\ Font\ Medium\ 10 - set guifont+=Source\ Code\ Pro\ Semi-Bold\ 10 - set guifont+=Dejavu\ Sans\ Mono\ for\ Powerline\ Semibold - set guifont+=Droid\ Sans\ Mono\ for\ Powerline\ 10 - set guifont+=Meslo\ LG\ M\ for\ Powerline\ 10 - - " like in the terminal: use Ctrl-shift-v for paste in vim's command editor - cnoremap <c-s-v> <c-r>* -endif - -" ====================================================================================================================== -" SETTINGS: -" ====================================================================================================================== -set breakindent | " Every wrapped line will continue visually indented -set clipboard=unnamedplus | " makes copy and paste work (autoselectplus might work as well) -set concealcursor=nc | " limits the display of concealed text to normal and command mode -set conceallevel=2 | " replace escaped chars by their UTF-8 representation (useful for LaTeX) -set confirm | " asks 'do you want to save?' -set cpoptions+=P | " makes :w filename set the current buffer to filename -set hidden | " allows switching buffers even if the current buffer contains changes (displays +) -set linebreak | " wrap long lines at char 'breakat', not inside words -set mousemodel=popup | " only in gvim: right click opens a pop-up-menu -set mouse=n | " allow mouse in normal mode only, so one can use the terminals c&p feature in insert mode -set noautochdir | " When on, Vim will change the current working directory -set nostartofline | " when scrolling: do not move the cursor to column 1 -set nowrap | " but do not (by default) wrap long lines around -set nrformats+=alpha | " allows CTRL-A & CTRL-X to increment and decrement letters, not just numbers -set incsearch | " highlight pattern while entering it (performance wise this isn't that good) - -if has('nvim') " Neovim? -set inccommand=nosplit | " preview substitute and such things in real time -endif - -set pumheight=8 | " Determines the maximum number of items to show in the pop-up menu for -set scrolljump=5 | " how many lines get scrolled into view when cursor reaches the screens edge -set scrolloff=0 | " keeps cursor centered -set shiftround | " indent/un-indent snaps to multiple of shiftwidths -set writedelay=0 - -" display and performance -set lazyredraw | " disables redraw during macro execution (improves performance) -set cmdheight=2 | " sets the command line's height -set signcolumn=yes | " auto=auto hide, yes=always, no=never show the column with error indicators -set nocursorcolumn | " turn visual cursor column off (improves performance) -set updatetime=80 | " updates the screen more often -set redrawtime=1500 | " Timeout in milliseconds for redrawing the screen (switches syntax off when ssh too slow) / CTRL+L to retry -set notimeout | " improves performance but is known to cause problems on slow terminals -set ttimeout ttimeoutlen=150 | " set Esc key timeout in ms- -set showcmd | " essential: show keys of combined commands in the lower right corner (BUT SLOW, makes cursor flickering) -set showtabline=2 | " 0: never, 1: only if there are at least two tabs, 2:always -set shortmess+=I | " don't give the intro message when starting Vim |:intro|. -set wildmenu | " use a menu in the command line -set wildmode=longest:full | " do not preselect any entry and show all possible - -" code completion -" set dictionary=/usr/share/dict/cracklib-small -" set complete+=k " make default completer <C-N> respect the dictionary -set complete-=u " scan current and included files -set complete+=i " scan current and included files -set complete+=d " scan current and included files for defined name or macro -set complete+=d | " scan current and included files for defined name or macro -set complete+=i | " scan current and included files for completions -set completeopt+=noinsert | " Do not insert any text for a match until the user selects one -set completeopt+=noselect | " Do not select a completion from the menu, let the user do that -set tagcase=match | " tagcase match, because we mostly use ^] to jump around and that variant respects the upper/lower case [followscs, followic, match, ignore] -set tags+=../tags - -" code folding... -set nofoldenable | " disable folding, because we have zi to toggle foldenable :) -set foldclose=all | " automatically fold, when the cursor leaves the folded area -set foldcolumn=2 | " I think I don't need this second indicator -" set numberwidth=5 -" set foldmethod=syntax | " foldlevel: syntax, indent, manual / foldmethod=syntax makes Vim incredible slow -set foldnestmax=1 | " top level folding only -set foldopen=block,hor,search | " when do we unfold? -" set foldtext=Foldtext() | " -" set foldtext=v:folddashes.substitute(getline(v:foldstart),'\\v^/[/*]\','','g') -" set foldtext='⊞\ '.substitute(getline(v:foldstart),'^[\ '.printf(&cms,'').']*','','').'↵'.getline(v:foldstart+1).'↵'.getline(v:foldstart+2) -" set foldtext=repeat('',indent(v:foldstart)).substitute(substitute(substitute(join(getline(v:foldstart,v:foldend)),'\\s\\s\\+\\\|\[\*\/\]','\ ','g'),'\^\\s\\+','','g'),\ '\\s\\s\\+',\ '\ ',\ 'g') -set foldtext=printf('%*s%.*S',indent(v:foldstart),'',&textwidth-indent(v:foldstart),substitute(substitute(join(getline(v:foldstart,v:foldend),'\ '),'[[:space:]]\\+','\ ','g'),'^[[:space:]*]','','g')) - -" works ... -" set foldexpr=match(synIDattr(synID(v:lnum,indent(v:lnum)+1,0),'name'),'Comment')>-1 -set foldexpr=!empty(filter(synstack(v:lnum,indent(v:lnum)+1),{_,val->match(synIDattr(val,'name'),'Comment')>-1})) - -" set foldtext=printf('%*s%.'.eval(&textwidth-indent(v:foldstart)).'S',indent(v:foldstart),'',substitute(substitute(substitute(join(getline(v:foldstart,v:foldend)),'\\s\\s\\+\\\|\[\*\/\]','\ ','g'),'\^\\s\\+','','g'),\ '\\s\\s\\+',\ '\ ',\ 'g')) - -" vim window behaviour -set splitbelow | " open new windows below the current one (i find that more intuitive) -set splitright | " this also works for me and makes better use of the scren space I think -set winminwidth=0 | " (and all other windows, so TODO: watch out) -set winwidth=30 | " keep NERDTreeWindow at least this size - - -" vim session handling and restore behaviour -set viminfo+=% | " restore buffer list -set sessionoptions= -set sessionoptions+=buffers -set sessionoptions+=curdir -set sessionoptions+=folds -set sessionoptions+=resize -set sessionoptions+=slash -set sessionoptions+=tabpages -set sessionoptions+=unix -set sessionoptions+=winpos -set sessionoptions+=winsize - - -" set nocindent smartindent | " use smart indent rather then cindent -set noautoindent -set nosmartindent - -set noshiftround | " indent/un-indent sna=ps to multiple of shiftwidths -set noequalalways | " do not evenly size windows when opening new or closing old -set nocursorline | " turn visual cursor line off (improves performance) -"======================================================================================================================= - -" Vim 8 has a terminal command... -if has('terminal') - " use default ESC key to leave insert mode in the internal terminal emulator - tnoremap <Esc> <C-W>N - " make terminal windows hidden by default (copied from :help terminal) - autocmd BufWinEnter * if &buftype == 'terminal' | setlocal bufhidden=hide | endif -endif - - -" NEOVIM_incompatible: -" -if has('nvim') " Neovim? - autocmd TermOpen term://* set nobuflisted - " use default ESC key to leave insert mode in the internal terminal emulator - tnoremap <Esc> <C-\><C-n> -" set shada+=n~/.vim/shada | " shada file to use -" - menu &UI.&Open\ in\ Serversession - \ :execute ':!nvr --servername /tmp/nvimsocket --remote % +'.line('.')<CR>:stopinsert<CR>:set readonly<CR> - -else " default Vim? - autocmd VimLeave * call system("echo -n $'" . escape(getreg(), "'") . "' | xsel -ib") - - set ttymouse=xterm2 - set ttyscroll=100 | " improves speed for terminal vim, incompatible with nvim - set ttyfast | " improves speed for terminal vim (incompatible with nvim) - set nottybuiltin | " use external termcaps - set restorescreen | " restores the console after exiting vim (intentionally not in nvim) - " - let g:loaded_ruby_provider = 1 " disable ruby support - let g:loaded_python_provider = 1 " disable python 3 - - if version >= 702 " clean up (see: http://vim.wikia.com/wiki/VimTip396) - autocmd BufWinLeave * call clearmatches() - endif - - - " scripts from the default vim installation, which do not get loaded by default, but are useful. - if filereadable($VIMRUNTIME.'/macros/editexisting.vim') - packadd! editexisting - endif - - " load default plugin 'matchit' to allow % to jump between tags - if filereadable($VIMRUNTIME.'/macros/matchit.vim') - packadd! matchit - endif - -endif - - -if has("autocmd") - set modeline | " set variables specific to a file, like indentation by adding a comment - " set default completion function in case YouCompleteMe cannot help - " set omnifunc=syntaxcomplete#Complete - - augroup set_window_title " { - " autocmd BufEnter * let &titlestring = hostname() . "[vim(" . expand("%:t") . ")]" - autocmd CursorHold * let &titlestring = "%t %y ".$USER."@".hostname().":%{expand(\"%:~:.:h\")}" - set title - " autocmd CursorHold * let &titlestring = "Vim (".airline#extensions#tagbar#currenttag().")" - - " set window title for screen(3) - if &term == "screen" - set t_ts=k - set t_fs=\ - endif - if &term == "screen" || &term == "xterm" - set titlelen=40 - set title - endif - augroup END - - augroup ChangeIcon - "if filereadable("/usr/bin/xseticon") - "if filereadable("~/.vim/nvim.png") - " autocmd VimEnter * silent :execute "!xseticon -id $WINDOWID ~/.vim/nvim.png" - " autocmd VimLeave * silent :execute "!xseticon -id $WINDOWID /usr/share/icons/gnome/32x32/apps/xfce-terminal.png" - "endif - "endif - augroup END - - " Fix terminal title ================================================================================================= - " autocmd VimEnter * let &t_EI .= "\<Esc>[0 q" - " autocmd VimEnter * let &t_SI = "\<Esc>]12;green\x7" - autocmd VimLeave * silent !echo -ne "\033]112\007" - - " highlight word under the cursor ==================================================================================== - let w:m1 = 0 - function! HighlightWordUnderCursor() - if(exists('w:m1') && w:m1 > 0) - silent! call matchdelete(w:m1) - let w:m1 = 0 - endif - let l:currentword = escape(expand('<cword>'), '.') - if(strlen(l:currentword) > 0) - let w:m1=100 - silent! call matchadd('BoldUnderline', '\<'.l:currentword.'\>', -1, w:m1) - endif - endfunction - autocmd! CursorHold,CursorHoldI * call HighlightWordUnderCursor() - - " hitting K over a keyword shows a help in a buffer. - " Here we define the commands used to look those keywords up - " as per file type... - augroup filetype_specific - autocmd FileType python setlocal keywordprg=pydoc - autocmd FileType vim setlocal keywordprg=:help |. - autocmd FileType c,cpp setlocal equalprg=clang-format - autocmd FileType c,cpp setlocal breakat-=- - - if filereadable("/usr/bin/vendor_perl/ack") - autocmd FileType c,cpp set grepprg=/usr/bin/vendor_perl/ack\ --type=cc\ --nogroup\ --column\ $* - autocmd FileType c,cpp set grepformat=%f:%l:%c:%m - endif - - autocmd BufWinEnter * if &previewwindow | setlocal nonumber nolist signcolumn=no filetype=c nobuflisted | endif - - - " autocmd FileType c,cpp setlocal iskeyword-=_ - - " the following helps to make file=/etc/something work with gf, but disallows filenames with an equal sign in them - autocmd FileType conf setlocal isfname-== - - - autocmd Filetype css command! CSSsort :g/{/+1;/}/-1 sort - - " keyboard mapping for xml alike languages - " Alt-Up : Move cursor up one tag - " Alt-Down: Move cursor down one tag - " leader-=: tidies currently selected tag and subtags and sorts attributes by name (alphabetically) - autocmd Filetype html,markdown,xml iabbrev </ </<C-X><C-O> - autocmd Filetype html,htmldjango,xml - \ :nnoremap - \ <M-Down> - \ :call search('^ *<', 'e')<CR>:nohlsearch<CR>| - \ :nnoremap - \ <M-Up> - \ :call search('^ *<', 'eb')<CR>:nohlsearch<CR>| - \ :nnoremap - \ <leader>= - \ vat:'<,'>!tidy -xml --wrap 0 --sort-attributes alpha 2>/dev/null<CR>vat= - augroup END - - " autocmd BufNewFile set nobuflisted - " use the shada/viminfo file to return the cursor to where it was... - autocmd BufReadPost * call setpos(".", getpos("'\"")) - - augroup CurrentFileName - " highlight the current files name inside the document... - let @g = ":exe ':match SpellBad /'.escape(expand('%:t'), '.').'/'" - " put the current files name after the cursor... - let @f = ":exe ':normal a'.expand('%:t')" - - " grep all buffers for a given string and return result in a quickfix window - let @q = ":cex [] | bufdo vimgrepadd /foo/g % | cw" - - let @l = ":let g:signify_vcs_cmds={'git': 'git diff --no-color --no-ext-diff -U0 HEAD^ -- %f'}|:SignifyRefresh" - - if has('menu') - source $VIMRUNTIME/menu.vim - set wildmenu - set cpo-=< - set wcm=<C-Z> - - 01menu &Functions.toggle\ file\ browser - \<Tab><leader><leader> - \ <leader><leader> - 01menu &Functions.-Sep0- : - - 01menu &Functions.help - \<Tab><F1> - \ <F1> - 01menu &Functions.bp:\ previous\ buffer - \<Tab><F2> - \ <F2> - 01menu &Functions.bn:\ next\ buffer - \<Tab><F3> - \ <F3> - 01menu &Functions.^wc\:\ close\ window - \<Tab><F4> - \ <F4> - 01menu &Functions.-Sep1- : - - 01menu &Functions.make - \<Tab><F5> - \ <F5> - 01menu &Functions.clear\ matches,\ update\ viewport - \<Tab><F6> - \ <F6> - 01menu &Functions.copen\:\ show\ quickfix\ list - \<Tab><F7> - \ <F7> - 01menu &Functions.lopen\:\ show\ location\ list - \<Tab><F8> - \ <F8> - 01menu &Functions.-Sep2- : - - 01menu &Functions.toggle\ tagbar - \<Tab><F9> - \ <F9> - - if has("gui_running") == 0 - " in the gui F10 already triggers the menu, not in a terminal vim, so upgrade that... - map <F10> :emenu <C-Z> - endif - 01menu &Functions.activate\ menu\ (:emenu) - \<Tab><F10> - \ <F10> - - 01menu &Functions.undef11 - \<Tab><F11> - \ <F11> - 01menu &Functions.undef12 - \<Tab><F12> - \ <F12> - 01menu &Functions.-Sep2- : - - - 09menu &Directory.print\ current\ directory - \<Tab>:pwd - \ :pwd<CR> - - 09menu &Directory.-Sep- : - - 09menu &Directory.Change\ to\ GIT\ root - \<Tab>:Gcd - \ :Gcd<CR>:pwd<CR> - - 09menu &Directory.Change\ to\ current\ buffers\ directory\ (global) - \<tab>:cd\ %:p:h - \ :cd %:h<CR>:pwd<CR> - - 09menu &Directory.Change\ to\ current\ buffers\ directory\ (local\ window)<tab>:lcd\ %:p:h - \ :lcd %:p:h<CR>:pwd<CR> - - menu &Git.&Display\ uncommited\ files\ in\ location\ list - \ :call setloclist(0, map(systemlist("git diff --name-only --pretty=''"), {_, p->{'filename': fnamemodify(p, ':.')}}))<CR>:lopen<CR> - menu &Git.&Display\ recently\ changed\ files\ in\ quickfix\ list - \ :call setqflist([], 'r', {'title': 'Recently changed in GIT', 'items':map(systemlist("git show --name-only --pretty=''"), {_, p->{'filename': fnamemodify(p, ':.')}}) })<CR>:copen<CR> - menu &Git.&Display\ last\ changes - \ :let g:signify_vcs_cmds={'git': 'git diff --no-color --no-ext-diff -U0 HEAD^ -- %f'}<CR>:SignifyRefresh<CR> - menu &Git.&Display\ unmerged\ files\ in\ location\ list - \ :call setloclist(0, map(systemlist("git diff --name-only --diff-filter=U \| uniq"), {_, p->{'filename': fnamemodify(p, ':.')}}))<CR>:lopen<CR> - menu &Git.&Display\ significance\ of\ changes - \ :!git diff --stat HEAD~1..HEAD - menu &Git.&Display\ Changed\ files\ compared\ to\ master - \ :!git diff --name-status ..master - - menu &Match.Clear\ All\ Matches - \<Tab><F6> - \ :call clearmatches()<CR> - - menu &Match.-Sep- : - - menu &Match.&dispensable\ white\ spaces - \ :call matchadd("Convention", '\s\+$', 0)<CR> - - menu &Match.&long\ lines\ (exeeding\ textwidth) - \ :call matchadd("Convention", '\%>'.&textwidth.'v.', 0)<CR> - - menu &Match.Highlight\ current\ file\ name - \ :call matchadd("Search", escape(expand('%:t'), '.'))<CR> - - " :execute ':match SpellBad /'.escape(expand('%:t'), '.').'/'<CR> - - menu &Window.-Sep- : - - - menu &Window.Scratch - \ :Scratch<CR> - - - menu &Find.file\ under\ the\ cursor - \<Tab>gf - \ gf - - menu &Find.Open\ search\ results\ in\ location\ list - \<Tab>:gf - \ :execute ':vimgrep /'.escape(getreg('/'), '.').'/g %'<CR> - \ :copen<CR> - - menu &Changes.list - \<Tab>:changes - \ :changes<CR> - menu &Changes.-Sep- : - menu &Changes.previous - \<Tab>g; - \ g; - menu &Changes.next - \<Tab>g, - \ g, - menu &List.location.signs\ to\ list - \<Tab>CMD - \ :execute ":call setloclist(0, map(get(getbufinfo('%')[0], 'signs'), {_, p->extend(p, {'bufnr':buffer_number('.'), 'text':get(p, 'name')})}))"<CR> - menu &List.location.list\ to\ signs - \<Tab>CMD - \ :call execute(extend(['sign define LocationListEntry text=L', 'sign unplace *'], map(getloclist('%'), {key, val->'sign place '.(key+100).' name=LocationListEntry line='.val['lnum'].' buffer='.buffer_number('%')})))<CR> - menu &Jump.list - \<Tab>:jumps - \ :jumps<CR> - menu &Jump.-Sep1- : - menu &Jump.previous\ position - \<Tab>CTRL-O - \ <C-O> - menu &Jump.next\ position - \<Tab>CTRL-I - \ <C-I> - menu &Jump.-Sep2- : - menu &Jump.clear\ list - \<Tab>:clearjumps - \ :clearjumps - - 1000menu &Tag.list - \<Tab>:tags - \ :tags<CR> - 1000menu &Tag.selection\ list - \<Tab>:ts - \ :ts<CR> - - 1000menu &Tag.-Sep1- : - - 1000menu &Tag.stack.jump\ older - \<Tab><C-T> - \ :po - 1000menu &Tag.stack.jump\ - \<Tab>:ta - \ :ta - endif - - " autocmd BufEnter * @f - augroup END - - " autocmd VimEnter * set nobuflisted -endif - - -" ====================================================================================================================== -" SHORTCUTS: custom shortcuts -" inoremap <C-Space> <C-x><C-o> -" inoremap <C-@> <C-Space> - -" Bind CTRL+Backspace to vim's version (CTRL+W) in " <CR> insert mode (only works with gvim) -inoremap - \ <C-Backspace> - \ <C-W> - -" INDENTATION: allows un-indenting a selected block and keeps selection -vnoremap < <gv -vnoremap > >gv - -" make shift-home select to the beginning of the line -nnoremap <s-home> v^ -nnoremap <s-end> v$ - -nnoremap <s-down> vj -vnoremap <s-down> j -nnoremap <s-up> vk -vnoremap <s-up> k - - -" close current buffer with <leader>q... -nnoremap <leader>q :bp<bar>sp<bar>bn<bar>bd<CR>. -" google the word under the cursor -nnoremap <leader>G :execute ":!xdg-open https://google.de/search?q=".expand("<cword>") - -nnoremap <silent> <F5> :make!<CR> -nnoremap <silent> <F6> :silent syntax sync fromstart<CR>:nohlsearch<CR>:silent match<CR>:silent 2match<CR>:silent 3match<CR> -nnoremap <leader>r :syntax sync fromstart - -nnoremap <silent> <A-Up> :wincmd k<CR> -nnoremap <silent> <A-Down> :wincmd j<CR> -nnoremap <silent> <A-Left> :wincmd h<CR> -nnoremap <silent> <A-Right> :wincmd l<CR> - -" INSERT_MODE_MAPPINGS: -" default copy&paste insert key binding (just in insert mode, so it doesn't conflict -" with visual block mode)- would have been nice, but collides with c-w for digraphs -" inoremap <C-V> <C-R>+ -" -inoremap <C-S> <C-O>:w<CR> - -" NEOVIM_SPECIFIC: -if has('nvim') " only neovim... - " shortcut \t opens a terminal in a horizontal split - nnoremap <leader>t :new +terminal<CR> -endif - - - -" ====================================================================================================================== -" START: LOADING PLUGINS -" ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓ -call plug#begin() -" Colorschemes: -Plug 'coderonline/vim-remote-menu' -" Plug 'bbchung/clighter8' -" Plug 'octol/vim-cpp-enhanced-highlight' -" Plug 'vim-scripts/TagHighlight' -" if ! exists('g:TagHighlightSettings') -" let g:TagHighlightSettings = {} -" endif -" let g:TagHighlightSettings['TagFileName'] = 'tags' -" let g:TagHighlightSettings['CtagsExecutable'] = 'ctags' - -Plug 'chriskempson/base16-vim' | " not just one high quality color scheme (all named base16-*) -Plug 'NLKNguyen/papercolor-theme' | " the one I like the most - -Plug 'mhinz/vim-signify' | " uses the sign column to indicate added, modified and removed lines -Plug 'tpope/vim-fugitive' | " the most complete GIT integration plugin -Plug 'godlygeek/tabular' | " align code on a sign, like :Tab/= -Plug 'tpope/vim-surround' | " plugin makes cs"' inside a line replace " with ' -let g:signify_vcs_list = [ 'git' ] | " use signify only with git (improves speed when loading buffers, see :h signify) -let g:signify_cursorhold_insert = 0 -let g:signify_cursorhold_normal = 0 -let g:signify_update_on_bufenter = 0 -let g:signify_update_on_focusgained = 0 -let g:signify_sign_show_count = 0 - -let g:signify_sign_add = '➕' -let g:signify_sign_delete = '➖' -let g:signify_sign_delete_first_line = '➖' -let g:signify_sign_change = '❗' -let g:signify_sign_changedelete = g:signify_sign_change - - -" NERDTree: replaces NetRW, as long as it has so many bugs -Plug 'scrooloose/nerdtree' | " -let NERDTreeIgnore = ['\.aux$', '\.o$'] -let NERDTreeCascadeSingleChildDir = 0 | " I don't get how one can use <m> to create files in that included directory -let NERDTreeChDirMode = 0 -let NERDTreeHiddenFirst = 1 -let NERDTreeMinimalUI = 1 -let NERDTreeShowBookmarks = 1 | " show bookmarks by default (when opening for the first time) -let NERDTreeWinSize = 40 -let NERDTreeQuitOnOpen = 1 - -" depending on if NERDTree has the focus: -nnoremap <expr> - \ <leader><leader> - \ bufwinnr("%")==g:NERDTree.GetWinNum() ? ':NERDTreeClose<CR>' : ':NERDTreeFind<CR>' -nnoremap <expr> - \ <F2> - \ bufwinnr("%")==g:NERDTree.GetWinNum() ? '<C-W><C-W>' : ':N<CR>' - -nnoremap <expr> - \ <F3> - \ bufwinnr("%")==g:NERDTree.GetWinNum() ? '<C-W><C-W>' : ':n<CR>' - -nnoremap <F4> - \ :wincmd c<CR> -" close NERDTree if it is the last remaining window (taken from the official documentation) -" autocmd bufenter * -" \ if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif -" -" map CTRL-PageUp/Down to next/previous buffer -" and Shift-PageUp/Down to next/previous arglist file -nnoremap <C-PageUp> :bn<CR> -nnoremap <C-PageDown> :bp<CR> -nnoremap <S-PageUp> :N<CR> -nnoremap <S-PageDown> :n<CR> - -" indent within <script> and <style> (default is a zero indent) -let g:html_indent_script1 = "inc" -let g:html_indent_style1 = "inc" - -Plug 'majutsushi/tagbar' " superseeds taglist-plus, which isn't maintained any more -let g:tagbar_autoclose = 0 -let g:tagbar_autofocus = 1 -let g:tagbar_autoshowtag = 0 -let g:tagbar_compact = 1 -let g:tagbar_indent = 0 -let g:tagbar_foldlevel = 99 - -nnoremap <F9> :TagbarToggle<CR>| " bind TagBar to hotkey F9 - -" Autocompleter: ===================================== -if has("python") || has('python3') - - " ULTISNIPS: code snippet ============================================================================================ - Plug 'honza/vim-snippets' " dependency of ultisnips (see below) - Plug 'SirVer/ultisnips' " replaces loremipsum (and many more) - " let g:UltiSnipsExpandTrigger = '<Tab>'| " expands the snippet, be careful not to use <tab> elsewhere (ycm uses it by default, but it has been deactivated by g:ycm_key_list_select_completion) - let g:UltiSnipsExpandTrigger = '<Tab>'| " expands the snippet, be careful not to use <tab> elsewhere (ycm uses it by default, but it has been deactivated by g:ycm_key_list_select_completion) - - let g:UltiSnipsJumpForwardTrigger = '<Tab>'| - let g:UltiSnipsJumpBackwardTrigger = '<S-Tab>'| - "d let g:UltiSnipsJumpForwardTrigger = '<PageDown>' - " let g:UltiSnipsJumpBackwardTrigger = '<PageUp>' - "let g:UltiSnipsExpandTrigger = '<C-j>'| " Trigger configuration. Do not use <tab> if you use https://github.com/Valloric/YouCompleteMe. - "let g:UltiSnipsJumpForwardTrigger = '<C-j>'| " \ - "let g:UltiSnipsJumpBackwardTrigger = '<C-k>'| " \ - "let g:UltiSnipsListSnippets = '<C-`>'| " YouCompleteMe includes those, so this isn't necessary - "let g:UltiSnipsListSnippets = '<leader><leader>'| " YouCompleteMe includes those, so this isn't necessary - """ Ultisnips - " let g:UltiSnipsExpandTrigger="<c-tab>" - " let g:UltiSnipsListSnippets="<c-s-tab>" - - if has('nvim') - Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' } - " Use deoplete. - let g:deoplete#enable_at_startup = 1 - inoremap <silent><expr> <C-Space> deoplete#mappings#manual_complete() - - Plug 'Shougo/echodoc.vim' - let g:echodoc#enable_at_startup = 1 - - " Plug 'Rip-Rip/clang_complete' - " Plug 'tweekmonster/deoplete-clang2' - " Plug 'zchee/deoplete-clang' - " let g:deoplete#sources#clang#libclang_path = "/usr/lib/libclang.so" - " let g:deoplete#sources#clang#clang_header = "/usr/lib/clang/6.0.0" - " let g:deoplete#sources#clang#std#cpp = 'c++1z' - " let g:deoplete#sources#clang#clang_complete_database = "/home/max/src" - " Plug 'Shougo/neoinclude.vim' " makes vim slow - unfortunatelly - - " Plug 'Shougo/deoplete-clangx' " mentioned in Q&A of deoplete - Plug 'autozimu/LanguageClient-neovim', { - \ 'branch': 'next', - \ 'do': 'bash install.sh', - \ } - - let g:LanguageClient_serverCommands = { - \ 'cpp': ['clangd'], - \ 'c': ['clangd'] - \ } - " Plug 'roxma/nvim-completion-manager' unmaintained python version - else - " YouCompleteMe: ===================================================================================================== - " Plug 'Valloric/MatchTagAlways' " highlights the closing tag/brace/... - Plug 'Valloric/YouCompleteMe', { - \ 'do' : 'python install.py --clang-completer --system-libclang --quiet', - \ } - let g:ycm_error_symbol = '✖' " insert this as an error symbol in the gutter bar/sign column - let g:ycm_warning_symbol = '➔' " insert this as a warning symbol in the gutter bar/sign coloumn - - let g:ycm_autoclose_preview_window_after_insertion = 0 - let g:ycm_auto_trigger = 1 - let g:ycm_collect_identifiers_from_tags_files = 1 " Let YCM read tags from Ctags file - let g:ycm_confirm_extra_conf = 0 " security is overrated ;) - let g:ycm_always_populate_location_list = 0 " we can manually run :YcmDiags to do that - - let g:ycm_key_list_previous_completion = ['Up'] - let g:ycm_key_list_select_completion = ['Down'] - - let g:ycm_semantic_triggers = { - \ 'c': [ 're!\w{2}' ] - \ } - - " Plug 'vim-scripts/dbext.vim' " dependency to allow db related completions - " let g:ycm_server_python_interpreter = 'python3' - " let g:ycm_python_binary_path = '/usr/bin/python3' " the python interpreter of choice (for code checking) - " let g:ycm_add_preview_to_completeopt = 1 " reuse existing preview window - " let g:ycm_seed_identifiers_with_syntax = 1 " Completion for programming language's keyword - " let g:ycm_complete_in_comments = 1 " Completion in comments - " let g:ycm_complete_in_strings = 1 " Completion in string - " let g:ycm_min_num_of_chars_for_completion = 6 " we normally avoid identifier based completion, it just helps with long words. Use semantic completions with <C-Space> instead (terrible idea, html snippets not working!) - " let g:ycm_min_num_identifier_candidate_chars = 4 - " let g:ycm_max_num_identifier_candidates = 10 - " let g:ycm_max_num_candidates = 50 - " let g:ycm_use_ultisnips_completer = 1 " Default 1, just ensure - " let g:ycm_key_list_select_completion = ['<Down>'] - " let g:ycm_key_list_previous_completion = ['<Up>'] - " let g:ycm_global_ycm_extra_conf = '.ycm_extra_conf.py' - " let g:ycm_semantic_triggers = { 'c': [ 're!.' ] } - " let g:ycm_disable_for_files_larger_than_kb = 16384 " we have faaast computers, don't we? - " let g:ycm_show_diagnostics_ui = 0 - " " disable <tab>-key for YCM so that it can be used with ultisnips - " let g:ycm_key_list_select_completion=[] - " let g:ycm_key_list_previous_completion=[] - endif - - - " SYNTASTIC: ========================================================================================================= - if has('nvim') - Plug 'w0rp/ale' - let g:ale_set_highlights = 0 - highlight! link ALEWarningSign FoldColumn - let g:ale_sign_error = '' - let g:ale_sign_style_error = '' - let g:ale_sign_info = '' - let g:ale_sign_warning = '' - else - Plug 'scrooloose/syntastic' - " set statusline+=%#warningmsg# - " set statusline+=%{SyntasticStatuslineFlag()} - let g:LatexBox_latexmk_preview_continuously = 1 - let g:LatexBox_viewer = "evince" - let g:syntastic_always_populate_loc_list = 1 - let g:syntastic_auto_loc_list = 0 - let g:syntastic_check_on_open = 1 - let g:syntastic_check_on_wq = 0 - " let g:syntastic_quiet_messages = {"type":"style"} - " - " E221: multiple spaces before Operator - let g:syntastic_python_flake8_args = '--max-complexity=10 --max-line-length=120 --exclude venv --doctests --exit-zero --ignore=E221' - " filter ( = do not display) style/formatting errors and warnings - let g:syntastic_error_symbol = '✖' - let g:syntastic_style_error_symbol = '✗' - let g:syntastic_warning_symbol = '➔' - let g:syntastic_style_warning_symbol = '≈' - endif - - " JEDI: ============================================================================================================== - Plug 'davidhalter/jedi-vim' " jedi gets used to display python function signatures - let g:jedi#completions_enabled = 0 " we do not need completions, because we have YouCompleteMe - let g:jedi#show_call_signatures = 1 " which sadly does not support signatures like jedi - let g:jedi#show_call_signatures_delay = 0 - let g:jedi#auto_vim_configure = 0 - let g:pymode_rope = 0 " https://github.com/davidhalter/jedi-vim/issues/163 - " autocmd FileType python jedi.preload_module('os', 'sys', 'math') - " let g:pymode_options_max_line_length = 120 - " let g:syntastic_python_flake8_args='--ignore=F821,E302,E501,E241,E301' - -endif " has("python") - -"======================================================================================================================= -" TESTING: | " plugins which I am currently trying... -"======================================================================================================================= -" Plug 'rhysd/vim-clang-format' | unnecessary, because we can just :pyf /usr/share/clang/clang-format.py -Plug 'kana/vim-operator-user' " dependency, which allows overriding the = operator for indentation - -" TODO: check if this is unrequired, when set equalprog is set to that py file -autocmd FileType c,cpp,objc map <buffer> = :pyf /usr/share/clang/clang-format.py<CR> - -" let g:clang_format#detect_style_file = 1 -" autocmd FileType c,cpp,objc map <buffer> = <Plug>(operator-clang-format) - -" Plug 'tpope/vim-characterize' | " normal mode: make ga show character names of Unicode chars (ga shows hex and dec values) -" Plug 'rkitover/vimpager' -" found this command instead (use as PAGER): -" man -P 'nvim -R -u NORC -c":%!col -b" -c":set buftype=nowrite filetype=man" -' ls - -command BuffersToArg :exec ':args '.join(map(range(0, bufnr('$')), 'fnameescape(fnamemodify(bufname(v:val), ":."))')) -command BufToArg :argadd %:. -command Gbranch call setqflist([], 'r', {'title':'Git branch selector','items':map(systemlist("git branch"), {_, p->{'filename':'branch','module': fnamemodify(p, ':.')}})}) - -" the following command opens a preview-window and shows the declaration of -" the function under the cursor. It also highlights the word to make it easier -" to spot within a great file -command Helpme au! CursorHold * nested let @/=expand('<cword>')|exe "silent! psearch ".expand("<cword>") - -"======================================================================================================================= -call plug#end() | " all plugins are getting loaded on this line, don't remove! - -" ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑ -" END: LOADING PLUGINS -" ====================================================================================================================== - -" Deprecated with this configuration, but still useful when deactivating some Plugins -" NETRW: obsolete with NERDTree -let g:netrw_alto = 0 | " open files on the right -let g:netrw_altv = 1 | " open files on the right -let g:netrw_banner = 0 | " display help messages? -let g:netrw_browse_split = 4 | " 4=open in previous window -let g:netrw_fastbrowse = 2 | " manually refresh direcory list (avoids display errors) -let g:netrw_hide = 1 | " show not-hidden files only -let g:netrw_keepdir = 0 -let g:netrw_list_hide = '^\..*' | " Explore mode: hide files starting with dot -let g:netrw_liststyle = 3 | " 3=tree -let g:netrw_preview = 0 | " -let g:netrw_winsize = 20 | " window size in percent - -" ====================================================================================================================== -" COLORSCHEME: -" ====================================================================================================================== - -function! ExtendColorTheme() - filetype on - filetype plugin on - filetype indent on - - syntax on | " enable syntax highlighting - syntax sync minlines=60 | " how many preceding lines will be parsed? (has performance impact) - - highlight! SignifySignAdd ctermbg=NONE - highlight! Bold cterm=bold gui=bold - highlight! Italic cterm=italic gui=italic - highlight! Underline cterm=underline gui=underline - highlight! BoldUnderline cterm=bold,underline gui=bold,underline - highlight! BoldItalic cterm=bold,Italic gui=Bold,Italic - highlight! Todo cterm=bold gui=bold guibg=#ffffaa guifg=#000000 - highlight! Error ctermbg=NONE guibg=NONE - highlight! SpellBad cterm=NONE gui=undercurl guibg=NONE guifg=red - - - highlight! link SpecialKey NonText | " makes tab stop (see listchars) less disturbing - highlight! link EndOfBuffer Ignore - highlight! link WildMenu Search - highlight! link Convention Error - highlight! link YcmErrorSign SpellBad - highlight! link YcmWarningSign Spellbad - highlight! link SignifySignAdd SignColumn - highlight! link SignifySignChange SignColumn - highlight! link SignifySignDelete SignColumn - highlight! link SignifySignChangeDelete SignColumn - highlight! link SignifySignDeleteFirstLine SignColumn - highlight! link VertSplit NonText - highlight! link LineNr Comment - highlight! link Folded LineNr - highlight! link SignColumn Comment - highlight! link FoldColumn Comment - highlight! link PmenuSbar Pmenu - highlight! PmenuThumb cterm=inverse - highlight! MoreMsg cterm=inverse - - autocmd InsertEnter * silent! call matchdelete(101) - autocmd InsertLeave * silent! call matchadd('Convention', ' \+$', -1, 101, { 'conceal': '⟶' }) - - autocmd InsertEnter * set colorcolumn=80,120 - autocmd InsertLeave * set colorcolumn& - - " execute 'highlight! StatusLine' - " \ .' guibg=NONE' - " \ .' guifg='.g:status_bg - " \ .' gui=inverse' - " let g:status_fg=synIDattr(hlID('Cursor'), 'fg#') - " let g:status_bg=synIDattr(hlID('Cursor'), 'bg#') - " let g:status_sel=synIDattr(hlID('Text'), 'fg#') - " let g:status_sel='#ffffff' - " " execute 'highlight! User1 gui=NONE' - " execute 'highlight! User1 guibg='.g:status_sel - " execute 'highlight! User1 guifg='.g:status_fg - " execute 'highlight! User2 gui=NONE' - " execute 'highlight! User2 guibg='.g:status_sel - " execute 'highlight! User2 guifg=NONE' - " use the default terminal background color as background (allows transparency) - " highlight! Normal guibg=NONE ctermbg=NONE - " highlight! NonText guibg=NONE guifg=black ctermbg=NONE ctermfg=black - " makes the ~ (tilde) indicator invisible, which usually marks the EOF - " highlight! CursorLineNr cterm=inverse | " ctermbg=black ctermfg=NONE - " highlight! Pmenu ctermbg=LightYellow ctermfg=DarkGrey - " highlight! PmenuSel ctermbg=blue ctermfg=LightYellow cterm=bold - " highlight! Folded ctermbg=NONE - " highlight! Cursor guibg=#729fcf ctermbg=yellow - " highlight! SpellBad ctermbg=none - " highlight! SpecialKey ctermfg=19 - " highlight! WhiteSpace ctermfg=19 - " highlight! link TabLine LineNr - " highlight! TabLineSel ctermbg=blue ctermfg=black - " highlight! link TabLineFill LineNr - " highlight! Search ctermbg=LightYellow ctermfg=12 guibg=#fefd86 guifg=#222222 - " generic, which should exist but don't - " autocmd InsertLeave * call matchadd('Conceal', ' \+$', -1, 101, { 'conceal': '⟶' }) - " Show trailing whitepace and spaces before a tab as part of the syntax highlighting - " autocmd BufEnter,InsertLeave * syntax match Convention /\s\+$\| \+\ze\t/ containedin=ALL - " autocmd Syntax * syntax match Convention /\s\+$\| \+\ze\t/ containedin=ALL - " autocmd BufEnter,BufWritePost * syntax match Convention /\s\+$\| \+\ze\t/ containedin=ALL - " autocmd InsertEnter * syntax clear Convention - " autocmd BufEnter,InsertLeave * execute ':syntax match Convention /\%>'.&textwidth.'v./ containedin=ALL' - " set colorcolumn= | " not used, because we have a :match directive for textwidth -" if argc() == 0 - " rv - " autocmd VimEnter * split +bro\ ol - " endif -endfunction -autocmd! ColorScheme * call ExtendColorTheme() - - - -" ====================================================================================================================== -" CONVENIENCE: -" ====================================================================================================================== -command Vimls - \ call setloclist(0, map(getbufinfo({'buflisted':1}), - \ "{'bufnr': v:val.bufnr, - \ 'lnum': v:val.lnum, - \ 'text': '='.printf('%*s, % 3d: %s [%s]', winwidth(0) / 2, '', v:val.bufnr, v:val.name, getbufvar(v:val.bufnr, '&buftype')), - \ 'pattern': 'not loaded'} - \ ")) - -command Ctoggle - \ if(get(getqflist({'winid':1}), 'winid') == win_getid())|cclose|else|botright copen|endif -command Ltoggle - \ if(get(getloclist(0, {'winid':1}), 'winid') == win_getid())|lclose|else|lopen|endif - - - -" nnoremap <silent> <ESC> :lclose<CR> " brings vim into REPLACE mode (R) -nnoremap <silent> <F7> :Ltoggle<CR> -nnoremap <silent> <F8> :Ctoggle<CR> -nnoremap <silent> <F12> :Vimls<CR>:Ltoggle<CR> - -" exec current line as a command, insert output of command (from: https://youtu.be/MquaityA1SM?t=35m45s) -nnoremap Q !!$SHELL<CR> - - -" ====================================================================================================================== -" TESTING: -" ====================================================================================================================== -autocmd TextYankPost * echo '> text yanked to '.( - \ get(v:event,'regname') == '' - \ ? 'default register' - \ : 'register '.get(v:event,'regname')) - -autocmd VimEnter,WinEnter * exec ':set scrolljump='.winheight(0)/2 - -" display highlight group under the cursor -map <leader>h :echo map(synstack(line('.'), col('.')), 'synIDattr(v:val, "name")')<CR> - -if filereadable(expand("~/.vimrc_background")) && filereadable(expand("~/.config/base16-shell/colortest")) - let g:base16_shell_path="~/.config/base16-shell/scripts" - let base16colorspace=256 - " let syntax_cmd="skip" " vim internal, use base16 and no default colors - set background=dark - source ~/.vimrc_background -else - let g:PaperColor_Theme_Options = { - \ 'theme': { - \ 'default': { - \ 'transparent_background': 0 - \ } - \ } - \ } - set background=light - colorscheme PaperColor -endif - - -augroup status - set noshowmode | " mode will be shown twice, in lightline and below, so we want to deactivate one - set laststatus=2 | " required by AirLine and Lightline, without status line does not appear until a window split - - let g:status_sym_start = '' - let g:status_sym_end = '' - let g:status_sym_sep_start = '' - let g:status_sym_sep_end = '' - let g:symbol_branch = '' - - if &term == "linux" - let g:symbol_branch = '' - - let g:group_active = "StatusLineTerm" - let g:group_inactive = "StatusLineTermNC" - let g:group_tabline = "StatusLineTerm" - else - let g:group_active = "StatusLine" - let g:group_inactive = "StatusLineNC" - let g:group_tabline = "TabLine" - endif - - " this function reverts foreground color and background color of a given - " highlight group and returns the name of a newly created _invert group - function! CreateInvertGroup(highlight_group) - if(synIDattr(hlID(a:highlight_group), "reverse")==1) - let w:color=synIDattr(hlID(a:highlight_group), "fg#") - else - let w:color=synIDattr(hlID(a:highlight_group), "bg#") - endif - - let l:retval=a:highlight_group.'_invert' - if(exists('w:color') && w:color == '') - let w:color = 'NONE' - endif - silent! exec 'highlight '.retval.' gui=NONE guifg='.w:color.' cterm=NONE ctermfg='.w:color - return l:retval - endfunction - - function! UpdateStatus(highlight_group) - let l:invert_group = CreateInvertGroup(a:highlight_group) - let l:mode = get({ - \ 'n' : 'normal', - \ 'i' : 'insert', - \ 'R' : 'replace', - \ 'v' : 'visual', - \ "V" : 'visual line', - \ "\<C-V>" : 'visual block', - \ 'c' : 'command', - \ 's' : 'select', - \ 'S' : 'select line', - \ "\<C-s>" : 'select block', - \ 't' : 'terminal' - \ }, mode(), mode()) - return '' - \ ."%#StatusLineHighlight#" - \ ."%#".a:highlight_group."#" - \ ."%(%w%h%q%)".' '.l:mode.' '.g:status_sym_sep_start.' ' - \ ."%{(argc()>0\ ?\ argidx()+1.':'.argc().' '.g:status_sym_sep_start.' '\ :\ '')}" - \ ."%{winbufnr(0).' '.g:status_sym_sep_start}" - \ ."%{(&readonly\ ?\ '\ \ 🔒'\ :\ '')}" - \ ."%{(&modified\ ?\ '\ \ '.nr2char(0xF0C7).'\ '\ :\ '')\ }" - \ ."%{(haslocaldir() ?\ fnamemodify(getcwd(),\ ':.').' '.nr2char(0xe0b1)\ \:\ '')}\ " - \ ."%{(&buftype\ ==\ \"terminal\"\ ?\ has('nvim')?b:term_title:expand(&titlestring)\ :\ substitute(expand('%:p'),\ '^'.getcwd(-1).'/*',\ '',\ ''))\ }" - \ ."%1(%)" - \ ."%#".l:invert_group."#" - \ .g:status_sym_end - \ .'' - \ ."%=" - \ .'' - \ ."%#".l:invert_group."#" - \ .g:status_sym_start - \ ."%#".a:highlight_group."#" - \ ."%1(%)" - \ ."%{(&filetype\ !=\ ''\ ?\ &filetype\ :\ &buftype)}" - \ ."%(\ %{g:status_sym_sep_end}\ %)" - \ ."%{(&spell\ ?\ &spelllang.' '.g:status_sym_sep_end\ :\ '')}" - \ ."%{(&fileencoding\ !=\ ''\ ?\ &fileencoding.' '.g:status_sym_sep_end.' '\ :\ '')}" - \ ."%{(&fileformat\ !=\ ''\ ?\ ' '.&fileformat.' '\ :\ '')}" - \ .g:status_sym_sep_end.' ' - \ ."%4l:%-3c" - \ .g:status_sym_sep_end.' ' - \ ."%-3p%%" - endfunction - - function! UpdateTabline(highlight_group) - let l:invert_group = CreateInvertGroup(a:highlight_group) - return '' - \ ."%#".a:highlight_group."#" - \ ."%3( \ %)\ " - \ ."%{getcwd(-1)}\ " - \ .g:status_sym_sep_start.' ' - \ ."%(\ ".g:symbol_branch."\ %{fugitive#head()}\ %)" - \ ."%#".l:invert_group."#" - \ .g:status_sym_end - \ .'' - \ ."%=" - \ .'' - \ ."%#".l:invert_group."#" - \ .g:status_sym_start - \ ."%#".a:highlight_group."#" - \ ."%3(\ %)" - \ ."%(%{v:servername}\ %{v:this_session}%)" - \ .g:status_sym_sep_end.' ' - \ ."%(\ \ %{tabpagenr()}/%{tabpagenr('$')}\ %)" - \ ."%##" - \ ."" " end - endfunction - - function! ApplyColorScheme() - " set termguicolors | " When on, uses highlight-guifg and highlight-guibg attributes in the terminal (=24bit color) incompatible with nvim - " set t_ut= - " set up statusline, global and current window individually - set statusline=%!UpdateStatus(g:group_inactive) - setlocal statusline=%!UpdateStatus(g:group_active) - " set up the tabline (match colors) - set tabline=%!UpdateTabline(g:group_tabline) - endfunction - " apply colors from the loaded colorscheme... - " when changing the colorscheme also apply new colors to the statusbar... - autocmd VimEnter,ColorScheme * call ApplyColorScheme() - - autocmd WinEnter * setlocal statusline=%!UpdateStatus(g:group_active) - autocmd WinLeave * setlocal statusline< -augroup END " status - -" moved after VimEnter of statusline, so that it does not get overwritten any -" more -if empty(argv()) - - " autocmd VimEnter * call setloclist(0, filter(map(copy(v:oldfiles), {_, p->{'filename': expand(get(split(p, "'"), 0))}}), { val -> echo val})) - - " from the list of recent files: make absolute paths, filter out files not - " contained in cwd and finally filter out directories and non-files... - autocmd StdinReadPre * let s:std_in=1 - autocmd VimEnter * if !exists("s:std_in") | call setloclist(0, [], 'r', - \ { - \ 'title':'Recently used files in directory: '.getcwd(), - \ 'items':map(filter(filter( - \ map(copy(v:oldfiles), - \ {_, p->expand(p)}), 'v:val =~ "'.getcwd().'/"'), 'filereadable(v:val)'), - \ {_, p->{'filename': fnamemodify(p, ':.')}}) - \ }) | lopen | only | setfiletype qf -endif - diff --git a/vimrc-minimal-statusline b/vimrc-minimal-statusline new file mode 100644 index 0000000..8a8656e --- /dev/null +++ b/vimrc-minimal-statusline @@ -0,0 +1,30 @@ +set nocompatible + + +filetype plugin indent on + +set omnifunc=syntaxcomplete#Complete + +syntax on + + +set ts=2 sw=2 expandtab + +set ignorecase smartcase + +set hidden + +let g:status_fg="#ffffff" +let g:status_bg="#000000" +let g:status_sel='#ffff00' + +execute 'highlight! StatusLine' + \ .' guibg='.g:status_sel + \ .' guifg=NONE' + +execute 'highlight! User1 guibg='.g:status_bg +execute 'highlight! User1 guifg='.g:status_fg + +execute 'highlight! User2 guibg='.g:status_sel +execute 'highlight! User2 guifg='.g:status_bg +colorscheme coderonline diff --git a/xdg-additions/applications/gvim-buffer.desktop b/xdg-additions/applications/gvim-buffer.desktop new file mode 100644 index 0000000..5cd2cbf --- /dev/null +++ b/xdg-additions/applications/gvim-buffer.desktop @@ -0,0 +1,10 @@ +[Desktop Entry] +Type=Application +Name=Gnome Vi IMproved Buffer +Icon=gvim +Comment=Open file in an existing instance of vi and in a new tab +MimeType=text/english;text/plain;text/x-makefile;text/x-c++hdr;text/x-c++src;text/x-chdr;text/x-csrc;text/x-java;text/x-moc;text/x-pascal;text/x-tcl;text/x-tex;application/x-shellscript;text/x-c;text/x-c++; +Exec=gvim -f -N --remote-silent %F +Terminal=false +X-XClassHintResName=VIM +Categories=Utility;TextEditor; diff --git a/xdg-additions/applications/gvim.desktop b/xdg-additions/applications/gvim.desktop new file mode 100644 index 0000000..37c6e58 --- /dev/null +++ b/xdg-additions/applications/gvim.desktop @@ -0,0 +1,10 @@ +[Desktop Entry] +Name=Vi IMproved Tab +Comment=Open file in an existing instance of vi and in a new tab +MimeType=text/english;text/plain;text/x-makefile;text/x-c++hdr;text/x-c++src;text/x-chdr;text/x-csrc;text/x-java;text/x-moc;text/x-pascal;text/x-tcl;text/x-tex;application/x-shellscript;text/x-c;text/x-c++; +Exec=gvim f -N --remote-tab %F +Icon=gvim +Type=Application +Terminal=false +X-XClassHintResName=VIM +Categories=Utility;TextEditor; diff --git a/xdg-additions/applications/nvim.desktop b/xdg-additions/applications/nvim.desktop new file mode 100644 index 0000000..21f0090 --- /dev/null +++ b/xdg-additions/applications/nvim.desktop @@ -0,0 +1,10 @@ +[Desktop Entry] +Version=1.0 +Type=Application +Name=Vim +Comment= +Exec=xfce4-terminal --icon /usr/share/icons/HighContrast/256x256/apps/vim.png -T 'nvim' -e '/bin/bash -i -c "env TERM=gnome-256color screen nvr ."' --fullscreen +Icon=/usr/share/icons/HighContrast/256x256/apps/vim.png +Path= +Terminal=false +StartupNotify=false diff --git a/xdg-additions/applications/vim.desktop b/xdg-additions/applications/vim.desktop new file mode 100644 index 0000000..f8efe76 --- /dev/null +++ b/xdg-additions/applications/vim.desktop @@ -0,0 +1,13 @@ +[Desktop Entry] +X-Desktop-File-Install-Version=0.23 +Type=Application +Name=Vi IMproved->buffer2 +Icon=gvim +Comment=Open file in an existing instance of vi and in a new tab +MimeType=text/english;text/plain;text/x-makefile;text/x-c++hdr;text/x-c++src;text/x-chdr;text/x-csrc;text/x-java;text/x-moc;text/x-pascal;text/x-tcl;text/x-tex;application/x-shellscript;text/x-c;text/x-c++; +X-XClassHintResName=VIM +Categories=Application;Utility;TextEditor; +# Exec=vim --servername VIM --remote-silent %F +Exec=xfce4-terminal -e "bash -c '~/.bashrc ; vim --servername VIM --remote-silent %F'" +Terminal=true +StartupNotify=true diff --git a/xdg-additions/bashrc b/xdg-additions/bashrc new file mode 100644 index 0000000..24c51a0 --- /dev/null +++ b/xdg-additions/bashrc @@ -0,0 +1,30 @@ + +# gvim () { /bin/gvim $(if [[ "$#" > 0 && `/bin/gvim --serverlist | wc -l` ]]; then echo --remote; fi) $@; } +# vim () { /bin/vim $(if [[ "$#" > 0 && `/bin/vim --serverlist | wc -l` ]]; then echo --remote; fi) $@; } + +# man() +# { +# /bin/gvim \ +# $(if [[ `/bin/gvim --serverlist | wc -l` > 0 ]]; then echo --remote-send; fi) \ +# ":enew<CR>:0read !groffer --pager='cat' --tty $1 <bar> col -bx<CR> :set filetype=man buftype=nowrite readonly<CR>gg"; +# } + +# export MANPAGER='vim -c":set noswapfile|%!col -b" -c":file man|:setlocal filetype=man buftype=nowrite readonly nonumber nolist signcolumn=no" -' +export MANPAGER="vim -M +MANPAGER -" + +# man() { /bin/vim ":enew<CR>:0read !groffer --pager='cat' --tty $1 <bar> col -bx<CR> :set filetype=man buftype=nowrite readonly<CR>gg" -; } +# alias git='git -c color.ui=false' +# export GIT_DIFF_OPTS="--no-color" + + + +git config --global --replace-all color.pager 0 +git config --global --replace-all core.pager 'vim -c":set noswapfile filetype=git buftype=nowrite readonly nolist nonumber signcolumn=no|:file git" -' +# export GIT_PAGER='' + +# alias git="TERM=dumb git" + +# export EDITOR="gvim()" +# export PAGER="tee /tmp/output.txt /dev/stdout | /bin/vim -" + +# --remote-expr ":%!col -b" -c":set buftype=nowrite filetype=man readonly" -'A diff --git a/xdg-additions/default-font.conf b/xdg-additions/default-font.conf new file mode 100644 index 0000000..b1de279 --- /dev/null +++ b/xdg-additions/default-font.conf @@ -0,0 +1,61 @@ +<?xml version="1.0"?> +<!-- this is a configuration file for fontconfig and should be copied or linked to ~/.config/fontconfig/conf.d/ --> +<!DOCTYPE fontconfig SYSTEM "fonts.dtd"> +<fontconfig> + <match> + <edit mode="prepend" name="family"><string>NotoSans-Regular</string></edit> + </match> + <match target="pattern"> + <test qual="any" name="family"><string>serif</string></test> + <edit name="family" mode="assign" binding="same"><string>Noto Serif</string></edit> + </match> + <match target="pattern"> + <test qual="any" name="family"><string>sans-serif</string></test> + <edit name="family" mode="assign" binding="same"><string>Noto Sans Mono Bold</string></edit> + </match> + <match target="pattern"> + <test name="family" qual="any"> + <string>monospace</string> + </test> + <edit binding="strong" mode="assign" name="family"> + <string>SauceCodePro Nerd Font Mono</string> + </edit> + <edit binding="strong" mode="assign" name="weight"> + <int>100</int> + </edit> + <edit binding="strong" mode="assign" name="style"> + <string>dz</string> + </edit> + <edit binding="strong" mode="assign" name="pixelsize"> + <double>14</double> + </edit> + </match> +</fontconfig> + +<!-- + family: "Anonymous Pro for Powerline"(s) + family: "Consolas for Powerline"(s) "Consolas for Powerline FixedD"(s) + family: "DejaVu Sans Mono for Powerline"(s) + family: "Droid Sans Mono for Powerline"(s) + family: "Inconsolata for Powerline"(s) + family: "Inconsolata-dz for Powerline"(s) + family: "Liberation Mono for Powerline"(s) + family: "Menlo for Powerline"(s) + family: "Meslo LG L DZ for Powerline"(s) + family: "Meslo LG L for Powerline"(s) + family: "Meslo LG M DZ for Powerline"(s) + family: "Meslo LG M for Powerline"(s) + family: "Meslo LG S DZ for Powerline"(s) + family: "Meslo LG S for Powerline"(s) + family: "PowerlineSymbols"(s) + family: "Source Code Pro for Powerline"(s) + family: "Source Code Pro for Powerline"(s) "Source Code Pro Black"(s) + family: "Source Code Pro for Powerline"(s) "Source Code Pro ExtraLight"(s) + family: "Source Code Pro for Powerline"(s) "Source Code Pro Light"(s) + family: "Source Code Pro for Powerline"(s) "Source Code Pro Medium"(s) + family: "Source Code Pro for Powerline"(s) "Source Code Pro Semibold"(s) + family: "Terminus for Powerline"(s) + family: "Ubuntu Mono derivative Powerline"(s) + family: "xos4 Terminess Powerline"(s) + family: "xos4 Terminus for Powerline"(s) +--> diff --git a/xdg-additions/gtk-3.0.css b/xdg-additions/gtk-3.0.css new file mode 100644 index 0000000..f347a83 --- /dev/null +++ b/xdg-additions/gtk-3.0.css @@ -0,0 +1,117 @@ +/* +#vim-menubar, +#vim-menubar #menu, +#vim-toolbar, +#vim-gui-drawarea, +#vim-main-window { + color:#6060af; + color: #4e4e4e; + font-family: "Hasklug Nerd Font Mono", "Source Code Pro for Powerline", "Source Code Pro", "Roboto"; + font-weight:bold; + font-size:8pt; + border:0; + outline:0; +} + +* { + border-width:0px; + outline-width:0px; + padding:0; + margin:0; +} + +#vim-menubar +{ + padding-left:1em; + border-bottom:2px solid #ffffff; +} + +#vim-menubar>* +{ + padding-right:1em; + padding-top:.25em; + padding-bottom:.25em; +} + +#vim-menubar>*, +#vim-main-window { + background-color:#ffffff; + color: #4e4e4e; +} + +menu menuitem:backdrop, menu menuitem:backdrop:hover +{ + border:0px; +} +*/ + +window#vim-main-window > box +{ + background:#fff; + border:2px solid #fff; +} + +/* within window > box ... */ +menubar#vim-menubar { + font-family: "monospace", "Hasklug Nerd Font Mono", "Source Code Pro for Powerline", "Source Code Pro", "Roboto"; + font-weight:bold; + font-size:8pt; + background: #fff; + /* background: linear-gradient(180deg, white 85%, black); */ +} + +menubar#vim-menubar menuitem { + background:transparent; +} + +menubar#vim-menubar > menuitem { + padding:.25em; +} + +menubar#vim-menubar menuitem box { + padding:.1em .25em; +} + +menubar#vim-menubar menuitem window +{ + margin-top:1em; +} + +/* opened menu (after being clicked) */ +menubar#vim-menubar menuitem window menu { + padding:1px; + background:linear-gradient(90deg, #ccc, #fff); + +} + +menubar#vim-menubar menuitem window menu menuitem { + padding:0em; + margin:0px; +} + +menubar#vim-menubar menuitem window menu menuitem box { + background:rgba(255,255,255,.5); + padding:.25em; + padding-left:1em; + +} + +menubar#vim-menubar menuitem window menu separator { + margin:0; + background:#fff; + border-top:1px dotted #666; +} + + +menubar#vim-menubar menuitem:hover { + box-shadow:none; + background:rgba(0,0,0,.2); + color:#000; +} + + + +/* +toolbar button { +notebook tab { +*/ diff --git a/ycm_extra_mini-conf.py b/ycm_extra_mini-conf.py new file mode 100644 index 0000000..0583c73 --- /dev/null +++ b/ycm_extra_mini-conf.py @@ -0,0 +1,138 @@ +# Generated by YCM Generator at 2017-02-03 00:22:04.774052 + +# This file is NOT licensed under the GPLv3, which is the license for the rest +# of YouCompleteMe. +# +# Here's the license text for this file: +# +# This is free and unencumbered software released into the public domain. +# +# Anyone is free to copy, modify, publish, use, compile, sell, or +# distribute this software, either in source code form or as a compiled +# binary, for any purpose, commercial or non-commercial, and by any +# means. +# +# In jurisdictions that recognize copyright laws, the author or authors +# of this software dedicate any and all copyright interest in the +# software to the public domain. We make this dedication for the benefit +# of the public at large and to the detriment of our heirs and +# successors. We intend this dedication to be an overt act of +# relinquishment in perpetuity of all present and future rights to this +# software under copyright law. +# +# 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 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. +# +# For more information, please refer to <http://unlicense.org/> + +import os +import ycm_core + +flags = [ + '-x', + 'c', + '-Wall', +] + + +# Set this to the absolute path to the folder (NOT the file!) containing the +# compile_commands.json file to use that instead of 'flags'. See here for +# more details: http://clang.llvm.org/docs/JSONCompilationDatabase.html +# +# You can get CMake to generate this file for you by adding: +# set( CMAKE_EXPORT_COMPILE_COMMANDS 1 ) +# to your CMakeLists.txt file. +# +# Most projects will NOT need to set this to anything; you can just change the +# 'flags' list of compilation flags. Notice that YCM itself uses that approach. +compilation_database_folder = '' + +if os.path.exists( compilation_database_folder ): + database = ycm_core.CompilationDatabase( compilation_database_folder ) +else: + database = None + +SOURCE_EXTENSIONS = [ '.cpp', '.cxx', '.cc', '.c', '.m', '.mm' ] + +def DirectoryOfThisScript(): + return os.path.dirname( os.path.abspath( __file__ ) ) + + +def MakeRelativePathsInFlagsAbsolute( flags, working_directory ): + if not working_directory: + return list( flags ) + new_flags = [] + make_next_absolute = False + path_flags = [ '-isystem', '-I', '-iquote', '--sysroot=' ] + for flag in flags: + new_flag = flag + + if make_next_absolute: + make_next_absolute = False + if not flag.startswith( '/' ): + new_flag = os.path.join( working_directory, flag ) + + for path_flag in path_flags: + if flag == path_flag: + make_next_absolute = True + break + + if flag.startswith( path_flag ): + path = flag[ len( path_flag ): ] + new_flag = path_flag + os.path.join( working_directory, path ) + break + + if new_flag: + new_flags.append( new_flag ) + return new_flags + + +def IsHeaderFile( filename ): + extension = os.path.splitext( filename )[ 1 ] + return extension in [ '.h', '.hxx', '.hpp', '.hh' ] + + +def GetCompilationInfoForFile( filename ): + # The compilation_commands.json file generated by CMake does not have entries + # for header files. So we do our best by asking the db for flags for a + # corresponding source file, if any. If one exists, the flags for that file + # should be good enough. + if IsHeaderFile( filename ): + basename = os.path.splitext( filename )[ 0 ] + for extension in SOURCE_EXTENSIONS: + replacement_file = basename + extension + if os.path.exists( replacement_file ): + compilation_info = database.GetCompilationInfoForFile( + replacement_file ) + if compilation_info.compiler_flags_: + return compilation_info + return None + return database.GetCompilationInfoForFile( filename ) + + +def FlagsForFile( filename, **kwargs ): + if database: + # Bear in mind that compilation_info.compiler_flags_ does NOT return a + # python list, but a "list-like" StringVec object + compilation_info = GetCompilationInfoForFile( filename ) + if not compilation_info: + return None + + final_flags = MakeRelativePathsInFlagsAbsolute( + compilation_info.compiler_flags_, + compilation_info.compiler_working_dir_ ) + + else: + relative_to = DirectoryOfThisScript() + final_flags = MakeRelativePathsInFlagsAbsolute( flags, relative_to ) + + return { + 'flags': final_flags, + 'do_cache': True + } + -- cgit v1.2.3