From 7c35e64b445432d9f857b1e581026a244be7d2b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=2E=20Fernando=20S=C3=A1nchez?= Date: Tue, 4 Mar 2014 15:57:06 +0100 Subject: [PATCH] Changes to i3 and vim --- bin/exit_i3.sh | 38 ++++++++++++ i3/config | 19 +++++- vim/ftplugin/tex.vim | 6 +- vimrc | 135 +++++++++++++++++++++++++++++++++---------- 4 files changed, 162 insertions(+), 36 deletions(-) create mode 100755 bin/exit_i3.sh diff --git a/bin/exit_i3.sh b/bin/exit_i3.sh new file mode 100755 index 0000000..c5b8ade --- /dev/null +++ b/bin/exit_i3.sh @@ -0,0 +1,38 @@ +#!/bin/bash +while [ "$select" != "NO" -a "$select" != "YES" ]; do + select=$(echo -e 'NO\nYES' | dmenu -fn "-*-cure-medium-*-*-*-11-*-*-*-*-*-*-*" -nb "#101010" -nf "#5f5f5f" -sb "#191919" -sf "#c72f62" -i -p "Do you really want to exit?"); + [ -z "$select" ] && exit 0 +done +[ "$select" = "NO" ] && exit 0 +i3-msg exit + +##!/bin/sh +#lock() { + #i3lock +#} + +#case "$1" in + #lock) + #lock + #;; + #logout) + #i3-msg exit + #;; + #suspend) + #lock && systemctl suspend + #;; + #hibernate) + #lock && systemctl hibernate + #;; + #reboot) + #systemctl reboot + #;; + #shutdown) + #systemctl poweroff + #;; + #*) + #echo "Usage: $0 {lock|logout|suspend|hibernate|reboot|shutdown}" + #exit 2 +#esac + +#exit 0 diff --git a/i3/config b/i3/config index 87e7a8a..d46847b 100644 --- a/i3/config +++ b/i3/config @@ -114,7 +114,7 @@ bindsym $mod+Shift+minus move scratchpad bindsym $mod+minus scratchpad show # focus the parent container -bindsym $mod+a focus parent +bindsym $mod+u focus parent # focus the child container bindsym $mod+d focus child @@ -150,7 +150,7 @@ bindsym $mod+Shift+C reload # restart i3 inplace (preserves your layout/session, can be used to upgrade i3) bindsym $mod+Shift+R restart # exit i3 (logs you out of your X session) -bindsym $mod+Shift+E exit +bindsym $mod+Shift+E exec exit_i3.sh bindsym $mod+Mod1+s exec gksudo pm-suspend # resize window (you can also use the mouse for that) @@ -238,3 +238,18 @@ exec --no-startup-id syndaemon -i 0.5 -d exec --no-startup-id synapse -s exec xautolock -time 10 -locker 'i3lock -t -c 000000 -i ~/Pictures/Wallpapers/Game\ Over\ Hacker.png' & exec urxvt -e tmux attach + +#set $mode_system System (l) lock, (e) logout, (s) suspend, (h) hibernate, (r) reboot, (Shift+s) shutdown +#mode "$mode_system" { + #bindsym l exec --no-startup-id i3exit lock, mode "default" + #bindsym e exec --no-startup-id i3exit logout, mode "default" + #bindsym s exec --no-startup-id i3exit suspend, mode "default" + #bindsym h exec --no-startup-id i3exit hibernate, mode "default" + #bindsym r exec --no-startup-id i3exit reboot, mode "default" + #bindsym Shift+s exec --no-startup-id i3exit shutdown, mode "default" + +## back to normal: Enter or Escape + #bindsym Return mode "default" + #bindsym Escape mode "default" +#} +#bindsym $mod+Pause mode "$mode_system" diff --git a/vim/ftplugin/tex.vim b/vim/ftplugin/tex.vim index 6e16b32..26ae4cd 100644 --- a/vim/ftplugin/tex.vim +++ b/vim/ftplugin/tex.vim @@ -11,8 +11,10 @@ map ct yyp:s/begin/end/ let g:tex_flavor = "latex" set suffixes+=.log,.aux,.bbl,.blg,.idx,.ilg,.ind,.out,.pdf -let g:LatexBox_latexmk_options="-pvc" -let g:Tex_CompileRule_pdf = 'pdflatex --synctex=1 -interaction=nonstopmode $*' +"let g:LatexBox_latexmk_options="-pvc" +let g:LatexBox_latexmk_async=1 +let g:LatexBox_latexmk_preview_continuously=1 +"let g:Tex_CompileRule_pdf = 'pdflatex --synctex=1 -interaction=nonstopmode $*' let g:LatexBox_output_type="pdf" let g:LatexBox_viewer="evince" let g:LatexBox_Folding=1 diff --git a/vimrc b/vimrc index 02c7040..16bc2a7 100644 --- a/vimrc +++ b/vimrc @@ -14,27 +14,37 @@ Bundle "tpope/vim-repeat" Bundle "tpope/vim-unimpaired" Bundle "tpope/vim-fugitive" Bundle "tpope/vim-surround.git" +Bundle "tpope/vim-abolish.git" Bundle "scrooloose/nerdtree" Bundle "scrooloose/nerdcommenter" Bundle "scrooloose/syntastic" Bundle "ervandew/supertab" Bundle "majutsushi/tagbar" Bundle "MarcWeber/vim-addon-mw-utils" +"" for vim-snippets Bundle "tomtom/tlib_vim" Bundle "honza/vim-snippets" Bundle "garbas/vim-snipmate" -Bundle "SpellCheck" -Bundle "mattn/gist-vim" Bundle "mattn/webapi-vim" -Bundle "kien/ctrlp.vim.git" +Bundle "mattn/gist-vim" Bundle "klen/python-mode" -Bundle "flazz/vim-colorschemes" -Bundle "Lokaltog/vim-distinguished" +Bundle "ivanov/vim-ipython" Bundle "jamessan/vim-gnupg" Bundle "Lokaltog/vim-easymotion" -"Bundle 'chriskempson/base16-vim' -Bundle "fholgado/minibufexpl.vim" -Bundle "nanotech/jellybeans.vim" +Bundle "vim-scripts/YankRing.vim" +Bundle "kien/ctrlp.vim.git" +Bundle "sgur/ctrlp-extensions.vim" +Bundle "sjl/gundo.vim" +Bundle "bling/vim-airline" +Bundle "xolox/vim-misc" +Bundle "xolox/vim-notes" +Bundle "beloglazov/vim-online-thesaurus" +Bundle "vim-scripts/ShowMarks" +Bundle "atweiden/vim-dragvisuals" +Bundle "tomasr/molokai" +Bundle "elzr/vim-json" +Bundle "niklasl/vim-rdf" + filetype plugin indent on " required! @@ -68,7 +78,10 @@ set hlsearch set ruler set wildmenu set autoread -"Better Map Leader + +" faster commands +noremap : +" Better Map Leader let mapleader="," noremap \ , @@ -89,8 +102,10 @@ imap :w "Custom maps noremap n :NERDTreeToggle -noremap t :TagbarToggle -noremap f :CtrlP +noremap t :TagbarOpen fj +noremap f :CtrlPMixed +noremap b :CtrlPBookmarkDir +noremap l :CtrlPLine "Omni set completeopt=longest,menuone @@ -110,6 +125,7 @@ nnoremap :tabnew inoremap :tabpreviousi inoremap :tabnexti "inoremap :tabnew +nnoremap dd :bd " Save sessions @@ -141,28 +157,28 @@ colo solarized set statusline=%t%h%m%r%y%{fugitive#statusline()}\%=[%{strlen(&fenc)?&fenc:'none'},%{&ff}]\ \ %c,%l/%L\ %P set laststatus=2 -function! InsertStatuslineColor(mode) - if a:mode == 'i' - hi statusline guibg=Red ctermbg=Red guifg=White ctermfg=White - elseif a:mode == 'r' - hi statusline guibg=Blue ctermfg=White guifg=White ctermbg=Blue - else - hi statusline ctermbg=Yellow guibg=Yellow ctermfg=Black guifg=Black - endif -endfunction +" Now that I use Airline, there is no need for this :) +"function! InsertStatuslineColor(mode) + "if a:mode == 'i' + "hi statusline guibg=Red ctermbg=Red guifg=White ctermfg=White + "elseif a:mode == 'r' + "hi statusline guibg=Blue ctermfg=White guifg=White ctermbg=Blue + "else + "hi statusline ctermbg=Yellow guibg=Yellow ctermfg=Black guifg=Black + "endif +"endfunction -call InsertStatuslineColor('') +"call InsertStatuslineColor('') +"au InsertEnter * call InsertStatuslineColor(v:insertmode) +"au InsertLeave * call InsertStatuslineColor('') -au InsertEnter * call InsertStatuslineColor(v:insertmode) -au InsertLeave * call InsertStatuslineColor('') +au BufRead,BufNewFile *.md set filetype=markdown "Diff the buffer and the original command DiffOrig let g:diffline = line('.') | vert new | set bt=nofile | r # | 0d_ | diffthis | :exe "norm! ".g:diffline."G" | wincmd p | diffthis | wincmd p nnoremap do :DiffOrig nnoremap dc :q:diffoff:exe "norm! ".g:diffline."G" -let g:ctrlp_cmd = 'CtrlPMRU' - set guifont=DejaVu\ Sans\ Mono set foldmethod=syntax @@ -192,13 +208,6 @@ augroup GnuPGExtra autocmd CursorHold *.\(gpg\|asc\|pgp\) quit augroup END -" RDF Notation 3 Syntax -augroup filetypedetect - au BufNewFile,BufRead *.n3 setfiletype n3 - au BufNewFile,BufRead *.ttl setfiletype n3 -augroup END - - function SetGPGOptions() " Set updatetime to 1 minute. set updatetime=60000 @@ -214,5 +223,67 @@ function SetGPGOptions() set foldopen=insert endfunction +" CtrlP " Do not clear the file cache on exit let g:ctrlp_clear_cache_on_exit = 0 +let g:ctrlp_extensions = [ 'mixed' ] +let g:ctrlp_regexp = 0 +let g:ctrlp_cmd = 'CtrlPMixed' + +" Git things +nmap gs :Gstatus +nmap gd :Gdiff +nmap gl :Glog + +" Gundo magic +nnoremap u :GundoToggle + +" YankRing+Ctrl-P +map y :YRShow +let g:yankring_replace_n_pkey = '' +let g:yankring_replace_n_nkey = '' + + +let g:airline_left_sep='' +let g:airline_right_sep='|' +let g:airline#extensions#tabline#enabled = 1 +let g:airline#extensions#tabline#left_sep = ' ' +let g:airline#extensions#tabline#left_alt_sep = '|' +let g:airline_theme='base16' + +" Notes +:let g:notes_directories = ['~/Dropbox/Notes'] + +" Block move +vmap DVB_Drag('left') +vmap DVB_Drag('right') +vmap DVB_Drag('down') +vmap DVB_Drag('up') +vmap D DVB_Duplicate() + +function! s:get_visual_selection() + " Why is this not a built-in Vim script function?! + let [lnum1, col1] = getpos("'<")[1:2] + let [lnum2, col2] = getpos("'>")[1:2] + let lines = getline(lnum1, lnum2) + let lines[-1] = lines[-1][: col2 - (&selection == 'inclusive' ? 1 : 2)] + let lines[0] = lines[0][col1 - 1:] + return join(lines, "\n") +endfunction + +" Thesaurus +let g:online_thesaurus_map_keys = 0 +nnoremap k :OnlineThesaurusCurrentWord +vnoremap k :Thesaurus =get_visual_selection() + +" Resizing +nnoremap + :exe "resize " . (winheight(0) * 3/2) +nnoremap - :exe "resize " . (winheight(0) * 2/3) +nnoremap + :exe "resize " . (winheight(0) * 3/2) +nnoremap > :exe "vertical resize " . (winwidth(0) * 3/2) +nnoremap < :exe "vertical resize " . (winwidth(0) * 2/3) + +" Clipboard magic +if has('unnamedplus') + set clipboard=unnamed,unnamedplus +endif