-
Notifications
You must be signed in to change notification settings - Fork 0
/
.vimrc
187 lines (167 loc) · 5.78 KB
/
.vimrc
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
set encoding=utf-8
" Leaders
let mapleader=" "
let maplocalleader=","
filetype plugin indent on " Enabling filetype support indenting
syntax enable " Turn on syntax highlighting
set nostartofline " keep cursor in the same column when moving
set backspace=indent,eol,start " Backspacing over everything in insert mode
set nomodeline " As a security precaution
set autowrite " Automatically :write before running commands
set smartindent
set autoindent
set smartcase " Only uppercase words with uppercase search term
set incsearch " Do incremental searching
set hlsearch " Continue to highlight searched phrases
set history=200 " keep lines of command line history
set ruler " Show the cursor position all the time
set showcmd " Display incomplete commands
set undofile " Automatically saves undo history to an undo file
set undodir=~/.cache/vim/
if !isdirectory(expand(&undodir))
call mkdir(expand(&undodir), "p")
endif
" Enable spell check
set spell
set spelllang=en,fr
set spellsuggest=10
"set complete+=kspell
"set expandtab
"set tabstop=2 " Maximum columns of whitespace a TAB can take up
"set shiftwidth=2 " Levels of indentation
"set softtabstop=2
"set smarttab
"set clipboard^=unnamed
"set shiftround
set nojoinspaces " Use one space, not two, after punctuation
set scrolloff=10 " Show a few lines of context around the cursor
set mouse= " Mouse disabled, set 'a' to enable in all modes
set ttymouse= " Mouse disabled, set 'a' to enable in all modes
set matchpairs+=<:> " Highlight matching pairs of brackets using '%'
" Store info from no more than 50 files at a time, 9999 lines of text,
" 100kb of data. Useful for copying large amounts of data between files.
set viminfo='50,<9999,s100
"" Display options
colorscheme habamax
if filereadable(expand("~/.vim/colors/solarized.vim"))
set background=light
colorscheme solarized
endif
set laststatus=2 " Always display the status line
set cursorline " Show a visual lien under the cursor's current line
set showmatch " Show matching brackets
set number
set relativenumber
set numberwidth=5
set textwidth=80 " Make it obvious where 80 characters is
set colorcolumn=+1
set list listchars=tab:»·,trail:·,nbsp:· " Display extra white space
"set termguicolors
" Open new split panes to right and bottom
set splitbelow
set splitright
"" Don't wrap text
"set nowrap
"set formatoptions=ronjp
"set formatoptions=tcqrn1
" When the type of shell script is /bin/sh, assume a POSIX-compatible
" shell for syntax highlighting purposes.
"let g:is_posix = 1
"" Keybinding
nnoremap <leader>r :source ~/.vimrc<CR>
" Open explorer
nnoremap <leader>f :Lex<CR>
nnoremap <leader>s :find
nnoremap <leader>w :w<CR>
nnoremap <leader>n :call SwitchBg()<CR>
nnoremap <leader>l :call CycleLineNumbers()<CR>
" Display/hide different types of white spaces
noremap <Leader><Tab><Tab> :set invlist<CR>
" Switch between the last two files
"nnoremap <Leader><Leader> <C-^>
" Opening a terminal window
nnoremap <c-t> :ter<CR>
" Closing the terminal window
tnoremap <c-t> exit<CR>
tnoremap <Esc> <C-\><C-n>
nnoremap <silent><ESC><ESC> :nohlsearch<CR>
" Use Q for formatting. Except for Select mode. Revert with ':unmap Q'
map Q gq
sunmap Q
" Quicker window movement
nnoremap <C-j> <C-w>j
nnoremap <C-k> <C-w>k
nnoremap <C-h> <C-w>h
nnoremap <C-l> <C-w>l
:nmap <Up> <Nop>
:nmap <Down> <Nop>
" Map the <Space> key to toggle a selected fold opened/closed.
"nnoremap <silent> <Space> @=(foldlevel('.')?'za':"\<Space>")<CR>
"vnoremap <Space> zf
"" File Browsing settings
set path+=**
set wildmenu " display completion matches in a status line
set wildmode=list:longest,full " How to complete matched strings
set wildignore=*.docx,*.jpg,*.png,*.gif,*.pdf,*.pyc,*.exe,*.flv,*.img,*.xlsx
set completeopt=menu,menuone,noinsert,preview
let g:netrw_banner=0
let g:netrw_liststyle=3
let g:netrw_showhide=1
let g:netrw_winsize=20
" add yaml settings
autocmd FileType yaml,yml setlocal ts=2 sts=2 sw=2 expandtab indentkeys-=0# indentkeys-=<:>
"" Set status line display
"set statusline=%F%m%r%h%w\ [FORMAT=%{&ff}]\ [TYPE=%Y]\ [POS=%l,%v][%p%%]\ [BUFFER=%n]\ %{strftime('%c')}
set statusline=
set statusline+=%#PmenuSel#
set statusline+=%{StatuslineGit()}
set statusline+=%#LineNr#
set statusline+=\ %f
set statusline+=%m\
set statusline+=%=
set statusline+=%#CursorColumn#
set statusline+=\ %y
set statusline+=\ %{&fileencoding?&fileencoding:&encoding}
set statusline+=\[%{&fileformat}\]
set statusline+=\ %p%%
set statusline+=\ %l:%c
set statusline+=\
function! GitBranch()
return system("git rev-parse --abbrev-ref HEAD 2>/dev/null | tr -d '\n'")
endfunction
function! StatuslineGit()
let l:branchname = GitBranch()
return strlen(l:branchname) > 0?' '.l:branchname.' ':''
endfunction
function SwitchBg()
if (&background == "light")
set background=dark
else
set background=light
endif
endfun
" Toggle/cycle line number modes
function! CycleLineNumbers()
if (&number == 1 && &relativenumber == 0)
set relativenumber
else
if (&relativenumber == 1 && &number == 1)
set norelativenumber
set nonumber
else
set number
set norelativenumber
endif
endif
endfunc
" Vim jump to the last position when reopening a file
autocmd BufReadPost *
\ if line("'\"") >= 1 && line("'\"") <= line("$") && &ft !~# 'commit'
\ | exe "normal! g`\""
\ | endif
" See the difference between the current buffer and the
" Revert with: ":delcommand DiffOrig".
if !exists(":DiffOrig")
command DiffOrig vert new | set bt=nofile | r ++edit # | 0d_ | diffthis
\ | wincmd p | diffthis
endif