summaryrefslogtreecommitdiff
path: root/vim/vimrc
blob: 2fbebf268d9d76429f2b0442f5c8e9a5ae9a24e1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
""  Required by Vundle

set nocompatible
filetype off
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()

""  Plugins
Plugin 'gmarik/vundle'
Plugin 'LaTeX-Box-Team/latex-box'
Plugin 'fugitive.vim'
Plugin 'gregsexton/gitv'
Plugin 'UltiSnips'
Plugin 'kien/ctrlp.vim'
Plugin 'tpope/vim-surround'
Plugin 'scrooloose/nerdtree'
Plugin 'tommcdo/vim-exchange'
Plugin 'unimpaired.vim'
Plugin 'Tabular'
Plugin 'tComment'
Plugin 'Gundo'
Plugin 'altercation/vim-colors-solarized'
Plugin 'honza/vim-snippets'

filetype plugin indent on
syntax on

""  Configuration  

"  Leader maps
let mapleader = "\\"
let maplocalleader = "-"
nmap <Space> <Leader>

"  UltiSnips
let g:UltiSnipsExpandTrigger="<tab>"
let g:UltiSnipsJumpForwardTrigger="<tab>"
let g:UltiSnipsJumpBackwardTrigger="<s-tab>"
let g:UltiSnipsListSnippets="<c-l>"
let g:UltiSnipsEditSplit="horizontal"
let g:UltiSnipsSnippetsDir="~/.vim/mySnippets"
let g:UltiSnipsSnippetDirectories=['UltiSnips', 'mySnippets']
let g:ctrlp_open_new_file = 't'
noremap <c-h> :UltiSnipsEdit<Return>

"  Latex-Box
let g:tex_flavor='latex'
let g:tex_conceal= 'adgm'
let g:LatexBox_Folding=0
let g:LatexBox_viewer='zathura'
let g:LatexBox_latexmk_preview_continuously=1
let g:LatexBox_quickfix=2
function! SynctexShow()
    let synctex = glob("*.synctex.gz")
    if strlen(synctex) == 0
        echom "no synctex file found"
    else
        let pdffile = substitute(synctex,"synctex.gz","pdf","")
        let execline = printf(":!zathura --synctex-forward %d:%d:%s %s", line('.'), col('.'), shellescape(bufname("%")), shellescape(pdffile))
        exec execline
    end
endfunction

"  Gundo
nnoremap <F5> :GundoToggle<cr>

"  Nerdtree
nnoremap <F3> :NERDTreeToggle<cr>
let NERDTreeIgnore=['\.pdf$', '\~$','\.toc$',
            \ '\.fls$','\.bbl$','\.blg$',
            \ '\.out$', '\.log$','\.aux$','\.sty$',
            \ '\.fdb_latexmk$', '\.synctex.gz$','\.latexmain$']

"  CTRL-P

let g:ctrlp_map = '<c-p>'
let g:ctrlp_by_filename = 1
let g:ctrlp_working_path_mode = ''
let g:ctrlp_show_hidden = 1

""  Options  

"  Tabs and indent
set smartindent
set nosmarttab
set expandtab
set tabstop=4
set softtabstop=4
set shiftwidth=4
set autoindent

"  Folds
set foldcolumn=0
set foldenable
set foldmethod=expr
set foldlevel=0

"  Search
set hlsearch
set incsearch

"  Back up files
set noswapfile
set nowritebackup
set undofile
set undodir=/home/urbain/.vim/vimundo/

"  Layout window
set nonumber
set ruler
set showcmd
set listchars=tab:▸\ ,eol:¬,trail:-
set fillchars=fold:\ ,vert:\ ,
set showbreak=...
set colorcolumn=0
set scrolloff=0
if has('gui_running')
    set t_Co=256
else
    set t_Co=256
endif
set guitablabel=%N\ %t\ %M
set showcmd

"  Layout text
set nowrap
set linebreak
set textwidth=0
set conceallevel=2
set guifont=Monaco\ 11
set lazyredraw
highlight diffAdded guifg=#00bf00
highlight diffRemoved guifg=#bf0000

"  Case and spell
set nospell
set smartcase
set ignorecase

"  General
set noautochdir
set wildmenu
set cpoptions+=I
set encoding=utf-8

""  Colorscheme
function! UpdateColorscheme()
    try | colorscheme solarized | catch | endtry
    if strftime("%H") >= 8 && strftime("%H") < 20
        set background=light
    else
        set background=dark
    endif

    hi Cursor guifg=white guibg=blue
    hi iCursor guifg=black guibg=green
    hi! link conceal normal
    hi! link folded comment
endfunction
autocmd! BufNewFile,BufRead,BufWrite * :call UpdateColorscheme()

""  Custom mappings

" General
nnoremap <Leader>te :tabedit 
nnoremap <Leader>tn :tabnew<cr>
nnoremap <Leader>to :tabonly<cr>
nnoremap <Leader>w :w<cr>
nnoremap <Leader>q :q!<cr>
nnoremap <Leader>h :set hlsearch!<cr>
nnoremap <Leader>n :set relativenumber!<cr>
nnoremap <Leader>sv :source ~/.vim/vimrc<cr>
nnoremap <Leader>sc :source %<cr>

"  Other maps
nnoremap <Return> o<Esc>
nnoremap <s-Return> O<Esc>
nnoremap J mzJ`z
nnoremap Y y$

" nnoremap - za
nnoremap <c-y> 3<c-y>
nnoremap <c-e> 3<c-e>

nnoremap j gj
nnoremap k gk
nnoremap $ g$
nnoremap ^ g^
nnoremap gj j
nnoremap gk k
nnoremap g$ $
nnoremap g^ ^

vnoremap j gj
vnoremap k gk
vnoremap $ g$
vnoremap ^ g^
vnoremap gj j
vnoremap gk k
vnoremap g$ $
vnoremap g^ ^

""  Latex  
let g:tex_fast=""

""  Autocommands
augroup autorelead_vimrc
    au!
    au BufWritePost ~/.vim/vimrc source ~/.vim/vimrc
augroup END