-
Notifications
You must be signed in to change notification settings - Fork 0
/
.vimrc
100 lines (89 loc) · 3.96 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
" Colors -------------------------------------
syntax on " syntax highlighting
" Whitespace ---------------------------------
set tabstop=4 " 4 spaces per tab
set shiftwidth=4 " 4 spaces per indent level
set softtabstop=4 " 4 spaces per backspace
set expandtab " tabs, please
set smartindent " indent things for me
set shiftround " indenting when at column 3 will go to column 4, not 7
set autoindent " indent at the same level of the previous line
set pastetoggle=<F12> " pastetoggle (sane indentation on pastes)
set ruler " show the line/column breakdown in the bottom right
set list
set listchars=""
set listchars=tab:>.,trail:.,extends:#,nbsp:.
set listchars+=trail:.
set listchars+=extends:>
set listchars+=precedes:<
autocmd FileType yaml setlocal ts=2 sts=2 sw=2 expandtab
autocmd FileType c,cpp,java,php,js,python,twig,xml,yml autocmd BufWritePre <buffer> :call setline(1,map(getline(1,"$"),'substitute(v:val,"\\s\\+$","","")'))
autocmd BufNewFile,BufRead *.ts set syntax=javascript
" UI Layout ----------------------------------
set number " Line numbers on
set encoding=utf-8 " UTF-8, please
set background=dark " Assume a dark background
set backspace=indent,eol,start " backspace for dummys
filetype indent on " Automatically detect file types.
set colorcolumn=120 " Marker at column 120
set cursorline " highlight current line
set lazyredraw " redraw only when we need to.
set showmatch " highlight matching [{()}]
" Searching ----------------------------------
" turn off search highlight
nnoremap <leader><space> :nohlsearch<CR>
set showmatch " show matching brackets/parenthesis
set incsearch " find as you type search
set hlsearch " highlight search terms
set ignorecase " case insensitive search
set smartcase " case sensitive when uc present
" Tabline ------------------------------------
set showtabline=2
highlight TabLine term=NONE cterm=NONE ctermfg=black ctermbg=gray
highlight TabLineSel term=NONE cterm=NONE ctermfg=yellow ctermbg=black
highlight TabLineFill term=NONE cterm=NONE ctermfg=black ctermbg=gray
" Backups ------------------------------------
set noswapfile
set nobackup
set nowb
silent !mkdir ~/.vim/backups > /dev/null 2>&1
set undodir=~/.vim/backups
set undofile
" Completion ---------------------------------
" scan the current buffer, other windows, and included files
set complete=.,w,i
" highlight auto complete popup selected item with a better bg color
highlight PmenuSel ctermbg=3 ctermfg=0
set completeopt=longest,menuone
" let Enter accept completion like Ctrl+y, but only when the popup is visible
inoremap <expr> <CR> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>"
" Custom Functions ---------------------------
cnoremap sudow w !sudo tee % >/dev/null
function! InitializeDirectories()
let separator = "."
let parent = $HOME
let prefix = '.vim'
let dir_list = {
\ 'backup': 'backupdir',
\ 'views': 'viewdir',
\ 'swap': 'directory' }
for [dirname, settingname] in items(dir_list)
let directory = parent . '/' . prefix . dirname . "/"
if exists("*mkdir")
if !isdirectory(directory)
call mkdir(directory)
endif
endif
if !isdirectory(directory)
echo "Warning: Unable to create backup directory: " . directory
echo "Try: mkdir -p " . directory
else
let directory = substitute(directory, " ", "\\\\ ", "")
exec "set " . settingname . "=" . directory
endif
endfor
endfunction
call InitializeDirectories()
" Ale Plugin Options -------------------------
let g:ale_sign_error = '✘'
let g:ale_sign_warning = '⚠'