diff --git a/config/autocommands.vim b/config/autocommands.vim new file mode 100644 index 0000000..25b5784 --- /dev/null +++ b/config/autocommands.vim @@ -0,0 +1,24 @@ +"aug LineNumbers + "au! + "au VimEnter,WinEnter,InsertLeave * setlocal relativenumber + "au WinLeave,InsertEnter * setlocal norelativenumber +"aug END + +aug CursorLineColumn + au! + au VimEnter,WinEnter,BufWinEnter * setlocal cursorline cursorcolumn + "au VimEnter,WinEnter,BufWinEnter * setlocal cursorcolumn + "au VimEnter,WinEnter,BufWinEnter * setlocal colorcolumn=80 + au WinLeave * setlocal nocursorline nocursorcolumn colorcolumn=0 +aug END + +aug FastEscape + au! + au InsertEnter * set timeoutlen=0 + au InsertLeave * set timeoutlen=1000 +aug END + +aug ReadonlyFiles + au BufNewFile,BufRead /var/log/* set readonly + au BufNewFile,BufRead /var/log/* set nomodifiable +aug END diff --git a/config/commands.vim b/config/commands.vim new file mode 100644 index 0000000..c79ebc5 --- /dev/null +++ b/config/commands.vim @@ -0,0 +1,4 @@ +command! Wq wq +command! WQ wq +command! Q q +command! W w diff --git a/config/crypto/autocommands.vim b/config/crypto/autocommands.vim new file mode 100644 index 0000000..9e85386 --- /dev/null +++ b/config/crypto/autocommands.vim @@ -0,0 +1 @@ +au BufReadPost * if &key != "" | set noswapfile nowritebackup viminfo= nobackup noshelltemp history=0 secure | endif diff --git a/config/crypto/options.vim b/config/crypto/options.vim new file mode 100644 index 0000000..ef6d060 --- /dev/null +++ b/config/crypto/options.vim @@ -0,0 +1,3 @@ +if v:version >= 704 + set cryptmethod=blowfish +endif diff --git a/config/ctrlp/variables.vim b/config/ctrlp/variables.vim new file mode 100644 index 0000000..e43cd5d --- /dev/null +++ b/config/ctrlp/variables.vim @@ -0,0 +1,5 @@ +let g:ctrlp_cmd = "CtrlPBuffer" +let g:ctrlp_prompt_mappings = { + \ 'ToggleType(1)': ['', '', ''], + \ 'ToggleType(-1)': ['', '', ''], +\ } diff --git a/config/folding.vim b/config/folding.vim new file mode 100644 index 0000000..3c51daf --- /dev/null +++ b/config/folding.vim @@ -0,0 +1,31 @@ +if has("folding") + set foldtext=MyFoldText() + + function! MyFoldText() + " get actual numberwidth of the current document + let nw_add = (len(line('$')) - (&numberwidth - 1)) + if nw_add > 0 + let nw = &numberwidth + nw_add + else + let nw = &numberwidth + endif + + let numfold_w =(nw * &number) + &foldcolumn + let window_w = winwidth(0) - numfold_w + + let foldtxt_start = getline(v:foldstart) + let foldtxt_start_w = len(foldtxt_start) + + let foldtxt_end = "+" . string(foldclosedend(v:foldend) - foldclosed(v:foldstart)) . "  " + let foldtxt_end_w = len(foldtxt_end) + + let foldtxt_mid_w = window_w - (foldtxt_start_w + foldtxt_end_w) + let foldtxt_mid = repeat(" ", foldtxt_mid_w + 2) + + ""let onetab = strpart(" ", 0, &tabstop) + "let foldtext_start = getline(v:foldstart) . " …" + "let foldtext_start = substitute(foldtext_start, "\t", onetab, "g") + + return foldtxt_start . foldtxt_mid . foldtxt_end + endfunction +endif diff --git a/config/gundo/keymaps.vim b/config/gundo/keymaps.vim new file mode 100644 index 0000000..c4c866b --- /dev/null +++ b/config/gundo/keymaps.vim @@ -0,0 +1,3 @@ +nnoremap :GundoToggle +inoremap :GundoToggle +vnoremap :GundoToggle diff --git a/config/gundo/variables.vim b/config/gundo/variables.vim new file mode 100644 index 0000000..5ade36c --- /dev/null +++ b/config/gundo/variables.vim @@ -0,0 +1,3 @@ +let g:gundo_width = 60 +let g:gundo_preview_height = 30 +let g:gundo_right = 1 diff --git a/config/keymaps.vim b/config/keymaps.vim new file mode 100644 index 0000000..925bd1b --- /dev/null +++ b/config/keymaps.vim @@ -0,0 +1,28 @@ +nnoremap +inoremap + +nnoremap :set invlist +inoremap :set invlist +vnoremap :set invlist + +nnoremap Q +nnoremap K +nnoremap Y y$ +nnoremap j gj +nnoremap k gk +vnoremap < >gv + +nnoremap th :tabfirst +nnoremap tj :tabnext +nnoremap tk :tabprev +nnoremap tl :tablast +nnoremap tn :tabnew +nnoremap tq :tabclose + +noremap :noh + +nnoremap vl :setlocal cursorline! +nnoremap vc :setlocal cursorcolumn! +nnoremap ve :setlocal colorcolumn=80 +nnoremap vn :setlocal colorcolumn=0 diff --git a/config/latexsuite/keymaps.vim b/config/latexsuite/keymaps.vim new file mode 100644 index 0000000..b112bb8 --- /dev/null +++ b/config/latexsuite/keymaps.vim @@ -0,0 +1,5 @@ +nnoremap Tex_Help +inoremap Tex_Help +nnoremap IMAP_JumpForward +vnoremap IMAP_JumpForward +"noremap :w :!pdflatex -shell-escape "%" && { pgrep ".*%:p || xdg-open %:p:r.pdf } diff --git a/config/latexsuite/options.vim b/config/latexsuite/options.vim new file mode 100644 index 0000000..c0953c7 --- /dev/null +++ b/config/latexsuite/options.vim @@ -0,0 +1 @@ +set grepprg=grep\ -nH\ $* diff --git a/config/latexsuite/variables.vim b/config/latexsuite/variables.vim new file mode 100644 index 0000000..8e789b4 --- /dev/null +++ b/config/latexsuite/variables.vim @@ -0,0 +1,14 @@ +let g:tex_flavor = "latex" +let g:tex_fold_enabled = 1 + +let g:Imap_UsePlaceHolders = 0 + +let g:Tex_ViewRule_dvi = "" +let g:Tex_ViewRule_ps = "" +let g:Tex_ViewRule_pdf = "" + +let g:Tex_ViewRuleComplete_dvi = "pgrep okular.*$* || xdg-open &" +let g:Tex_ViewRuleComplete_ps = "" +let g:Tex_ViewRuleComplete_pdf = "pgrep okular.*$* || xdg-open &" + +let g:Tex_DefaultTargetFormat = "pdf" diff --git a/config/molokai/colorscheme.vim b/config/molokai/colorscheme.vim new file mode 100644 index 0000000..5709b2e --- /dev/null +++ b/config/molokai/colorscheme.vim @@ -0,0 +1 @@ +colorscheme molokai diff --git a/config/molokai/options.vim b/config/molokai/options.vim new file mode 100644 index 0000000..18a3210 --- /dev/null +++ b/config/molokai/options.vim @@ -0,0 +1 @@ +set background=dark diff --git a/config/molokai/variables.vim b/config/molokai/variables.vim new file mode 100644 index 0000000..f526805 --- /dev/null +++ b/config/molokai/variables.vim @@ -0,0 +1,2 @@ +"let g:molokai_original = 1 +"let g:rehash256 = 1 diff --git a/config/my_vim.vim b/config/my_vim.vim new file mode 100644 index 0000000..3627696 --- /dev/null +++ b/config/my_vim.vim @@ -0,0 +1,193 @@ +function! CheckXDGVars() + if empty($XDG_CONFIG_HOME) + let $vim_config_home=expand("$HOME/.config/vim") + else + let $vim_config_home=expand("$XDG_CONFIG_HOME/vim") + endif + + if empty($XDG_CACHE_HOME) + let $vim_cache_home=expand("$HOME/.local/cache/vim") + else + let $vim_cache_home=expand("$XDG_CACHE_HOME/vim") + endif + + if empty($XDG_DATA_HOME) + let $vim_data_home=expand("$HOME/.local/share/vim") + else + let $vim_data_home=expand("$XDG_DATA_HOME/vim") + endif +endfunction + +function! SetUserRuntimePath(dir) + let $user_rtp=a:dir + let $runtimepath_old=&runtimepath + set runtimepath=$user_rtp,$user_rtp/after,$runtimepath_old +endfunction + +function! SetUserBackupdir(dir) + let &backupdir=a:dir . "/backup" + if !isdirectory(expand(&backupdir)) + call mkdir(expand(&backupdir), "p", 0700) + endif +endfunction + +function! SetUserSwapdir(dir) + let &directory=a:dir . "/swap" + if !isdirectory(expand(&directory)) + call mkdir(expand(&directory), "p", 0700) + endif +endfunction + +function! SetUserViewdir(dir) + if has('mksession') + let &viewdir=a:dir . "/views" + if !isdirectory(expand(&viewdir)) + call mkdir(expand(&viewdir), "p", 0700) + endif + endif +endfunction + +function! SetUserUndodir(dir) + if has('persistent_undo') + let &undodir=a:dir . "/undo" + if !isdirectory(expand(&undodir)) + call mkdir(expand(&undodir), "p", 0700) + endif + endif +endfunction + +function! SetUserViminfo(dir) + if has('viminfo') + if !isdirectory(a:dir) + call mkdir(a:dir, "p", 0700) + endif + set nocompatible + let &viminfo="'1000,<50,s10,n" . a:dir . "/viminfo" + endif +endfunction + +function! SetOptions() + set autoindent + set backspace=indent,eol,start + set complete-=i + set smarttab + set nrformats-=octal + set shiftround + set ttimeout + set ttimeoutlen=100 + set laststatus=2 + set number + set autoread " does it even work? + set fileformats=unix,dos,mac + set display+=lastline + set noerrorbells + set visualbell + set t_vb= + set showmatch + + "################################# + "# Options depending on features # + "################################# + + " allow the cursor to be positioned where no characters are in virtual block mode + if has('virtualedit') + set virtualedit=block + endif + + " split the windows more 'naturally' + if has('windows') + set splitbelow + set splitright + endif + + " enable filetype plugins + if has('autocmd') + filetype plugin indent on + endif + + " enable syntax highlighting + if has('syntax') + syntax enable + endif + + " highlight searches and search while typing + if has('extra_search') + set hlsearch + set incsearch + if maparg('', 'n') ==# '' + nnoremap :nohlsearch + endif + endif + + " show a ruler and show the current command in the bottom right + if has('cmdline_info') + set ruler + set showcmd + endif + + if has('wildmenu') + set wildmenu + endif + + if has('multi_byte') + set encoding=utf-8 + set termencoding=utf-8 + endif + + " enable mouse support + if has('mouse') + set mouse=a + endif + + + "###################################### + "# Options depending on set variables # + "###################################### + + " set scroll offset slightly higher so that the next or previous line can be seen + if !&scrolloff + set scrolloff=1 + endif + + " same as with scroll offset but for horizontal scrolling + if !&sidescrolloff + set sidescrolloff=5 + endif + + " set the history far higher (default 50) + if &history < 1000 + set history=1000 + endif + + " increase the maximal number of tabpages (default 10) + if &tabpagemax < 50 + set tabpagemax=50 + endif + + " set the terminal colors to 256 if not in a VT + if exists($TERM) + if &t_Co == 8 && $TERM !~# '^linux' + set t_Co=256 + endif + endif + + "################# + "# Plugins, etc. # + "################# + + " load the matchit macros + if !exists('g:loaded_matchit') && findfile('plugins/matchit.vim', &rtp) ==# '' + runtime! macros/matchit.vim + endif +endfunction + +if empty($my_vim) + call CheckXDGVars() + call SetUserRuntimePath($vim_config_home) + call SetUserSwapdir($vim_data_home) + call SetUserUndodir($vim_data_home) + call SetUserViewdir($vim_data_home) + call SetUserBackupdir($vim_data_home) + call SetUserViminfo($vim_cache_home) + call SetOptions() +endif " empty($my_vim) diff --git a/config/nerdtree/autocommands.vim b/config/nerdtree/autocommands.vim new file mode 100644 index 0000000..1934365 --- /dev/null +++ b/config/nerdtree/autocommands.vim @@ -0,0 +1 @@ +au bufenter * if (winnr("$") == 1 && exists("b:NERDTreeType") && b:NERDTreeType == "primary") | q | endif diff --git a/config/nerdtree/keymaps.vim b/config/nerdtree/keymaps.vim new file mode 100644 index 0000000..2a55eee --- /dev/null +++ b/config/nerdtree/keymaps.vim @@ -0,0 +1,3 @@ +noremap :NERDTreeToggle +inoremap :NERDTreeToggle +vnoremap :NERDTreeToggle diff --git a/config/options.vim b/config/options.vim new file mode 100644 index 0000000..22a0261 --- /dev/null +++ b/config/options.vim @@ -0,0 +1,36 @@ +set listchars=tab:»\ ,trail:◆,extends:▹,precedes:◃,eol:↲,nbsp:· +set ignorecase +set smartcase +set confirm +set autowrite +set shortmess=aoOtTI +set clipboard=unnamed,unnamedplus,autoselect + +set softtabstop=4 +set shiftwidth=4 +set smartindent +set expandtab + +set wildmode=longest:full,list +set wildignore=.bak,.old,.swp,~ +set autochdir + +if v:version >= 704 + set undofile + set undolevels=1000 +endif + +set report=0 +set updatetime=1500 +set switchbuf=useopen,usetab +set pumheight=10 +set diffopt+=context:3 +set matchtime=2 + +set foldcolumn=0 +set foldlevel=1 +set foldmethod=syntax + +set nowrap + +set t_Co=256 diff --git a/config/powerline/options.vim b/config/powerline/options.vim new file mode 100644 index 0000000..7ff6af1 --- /dev/null +++ b/config/powerline/options.vim @@ -0,0 +1,3 @@ +set laststatus=2 +set noshowmode +"set showtabline=2 diff --git a/config/powerline/variables.vim b/config/powerline/variables.vim new file mode 100644 index 0000000..f485f27 --- /dev/null +++ b/config/powerline/variables.vim @@ -0,0 +1,11 @@ +"if $TERM != "linux" + "if executable("powerline") + "if executable("python3") + "let $PYTHONPATH="/usr/lib/python3.4/site-packages" + "elseif executable("python2") + "let $PYTHONPATH="/usr/lib/python2.7/site-packages" + "endif + "endif +"endif + +"let g:powerline_pycmd = "py3" diff --git a/config/quickrun/variables.vim b/config/quickrun/variables.vim new file mode 100644 index 0000000..6972e79 --- /dev/null +++ b/config/quickrun/variables.vim @@ -0,0 +1 @@ +let g:quickrun_config = {} diff --git a/config/solarized/colorscheme.vim b/config/solarized/colorscheme.vim new file mode 100644 index 0000000..5fcac08 --- /dev/null +++ b/config/solarized/colorscheme.vim @@ -0,0 +1 @@ +"colorscheme solarized diff --git a/config/solarized/options.vim b/config/solarized/options.vim new file mode 100644 index 0000000..2df6879 --- /dev/null +++ b/config/solarized/options.vim @@ -0,0 +1 @@ +"set background=dark diff --git a/config/solarized/variables.vim b/config/solarized/variables.vim new file mode 100644 index 0000000..7bde1ba --- /dev/null +++ b/config/solarized/variables.vim @@ -0,0 +1,2 @@ +let g:solarized_termtrans = 1 +let g:solarized_termcolors = 256 diff --git a/config/sudo/commands.vim b/config/sudo/commands.vim new file mode 100644 index 0000000..567e145 --- /dev/null +++ b/config/sudo/commands.vim @@ -0,0 +1 @@ +command! Sw w !sudo tee % >/dev/null diff --git a/config/syntastic/variables.vim b/config/syntastic/variables.vim new file mode 100644 index 0000000..eaf637e --- /dev/null +++ b/config/syntastic/variables.vim @@ -0,0 +1,12 @@ +let g:syntastic_enable_signs = 1 +let g:syntastic_check_on_open = 1 +let g:syntastic_enable_highlighting = 1 +let g:syntastic_auto_loc_list = 1 + +"let g:syntastic_c_check_header = 1 + +"let g:syntastic_cpp_remove_include_errors = 1 +"let g:syntastic_cpp_check_header = 1 +"let g:syntastic_cpp_auto_refresh_includes = 1 + +let g:syntastic_tex_checkers = ["false"] diff --git a/config/tagbar/keymaps.vim b/config/tagbar/keymaps.vim new file mode 100644 index 0000000..dde9fd2 --- /dev/null +++ b/config/tagbar/keymaps.vim @@ -0,0 +1,3 @@ +nnoremap :TagbarToggle +inoremap :TagbarToggle +vnoremap :TagbarToggle diff --git a/config/tmux/keymaps.vim b/config/tmux/keymaps.vim new file mode 100644 index 0000000..c7651f6 --- /dev/null +++ b/config/tmux/keymaps.vim @@ -0,0 +1,25 @@ +if exists('$TMUX') + function! TmuxOrSplitSwitch(wincmd, tmuxdir) + let previous_winnr = winnr() + silent! execute "wincmd " . a:wincmd + if previous_winnr == winnr() + call system("tmux select-pane -" . a:tmuxdir) + redraw! + endif + endfunction + + let previous_title = substitute(system("tmux display-message -p '#{pane_title}'"), '\n', '', '') + let &t_ti = "\]2;vim\\\" . &t_ti + let &t_te = "\]2;". previous_title . "\\\" . &t_te + + noremap :call TmuxOrSplitSwitch('h', 'L') + noremap :call TmuxOrSplitSwitch('l', 'R') + noremap :call TmuxOrSplitSwitch('k', 'U') + noremap :call TmuxOrSplitSwitch('j', 'D') + noremap :call TmuxOrSplitSwitch('b', 'l') +else + noremap h + noremap j + noremap k + noremap l +endif diff --git a/config/ultisnips/keymaps.vim b/config/ultisnips/keymaps.vim new file mode 100644 index 0000000..971d3ca --- /dev/null +++ b/config/ultisnips/keymaps.vim @@ -0,0 +1 @@ +inoremap diff --git a/config/ultisnips/variables.vim b/config/ultisnips/variables.vim new file mode 100644 index 0000000..bba7725 --- /dev/null +++ b/config/ultisnips/variables.vim @@ -0,0 +1,5 @@ +let g:UltiSnipsUsePythonVersion = 3 +let g:UltiSnipsExpandTrigger = '' +let g:UltiSnipsJumpForwardTrigger = '' +let g:UltiSnipsJumpBackwardTrigger = '' +let g:UltiSnipsSnippetDirectories = ['UltiSnips', 'snippets'] diff --git a/config/variables.vim b/config/variables.vim new file mode 100644 index 0000000..bac596b --- /dev/null +++ b/config/variables.vim @@ -0,0 +1,2 @@ +let g:mapleader = "," +let g:sh_fold_enabled=1 diff --git a/config/ycm/variables.vim b/config/ycm/variables.vim new file mode 100644 index 0000000..ef5ba3c --- /dev/null +++ b/config/ycm/variables.vim @@ -0,0 +1,3 @@ +let g:ycm_global_ycm_extra_conf = $XDG_CONFIG_HOME . "/vim/config/ycm/ycm_extra_conf.py" +let g:ycm_autoclose_preview_window_after_completion = 1 +let g:ycm_register_as_syntastic_checker = 1 diff --git a/config/ycm/ycm_extra_conf.py b/config/ycm/ycm_extra_conf.py new file mode 100644 index 0000000..cd55590 --- /dev/null +++ b/config/ycm/ycm_extra_conf.py @@ -0,0 +1,92 @@ +import os +import ycm_core + +flags = [ '-Wall', '-Werror', '-std=c99' ] + +# 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 +# +# 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 + }