aboutsummaryrefslogtreecommitdiff
path: root/.vimrc
blob: 71954dea043cfb6d4aa52d9c7770409715664e65 (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
" General Config

set nocompatible
set number
set backspace=indent,eol,start
syntax enable
set encoding=utf-8
set fileencodings=ucs=bom,utf-8,utf-16,gbk,big5,gb18030,latin1
set showcmd
set autoread
set mouse=a
filetype on
filetype indent on
filetype plugin on
set modeline
set textwidth=72
set formatoptions+=mB
set formatoptions-=tc
set secure
set exrc
set noerrorbells
set noshowmode

" use for populating filename in quickfix
set errorformat+=%f

" used by nvim and nvim-yarp
let g:python3_host_prog = '/usr/bin/python3'
if has('macunix')
    let g:python3_host_prog = '/usr/local/bin/python3'
endif

" Use python3 first
if has('python3')
elseif has('python')
endif

" GUI

set guioptions-=m
set guioptions-=T
set guioptions-=r
set guioptions+=c
if has('nvim')
    set guifont=Dejavu\ Sans\ Mono:h12
else
    set guifont=DejaVu\ Sans\ Mono\ 12
endif
if has('macunix')
    set guifont=Monaco:h15
endif

set nofoldenable

set hidden

set completeopt=menu,menuone,noinsert,noselect
if !has('nvim')
    set completeopt+=popup
    set completepopup=align:menu,border:off,highlight:WildMenu
endif
set complete=.,w,b,u " Don't use tags and included files as there may be lots of files
set shortmess+=c
set belloff+=ctrlg

" diff
set diffopt+=followwrap,algorithm:patience

" undo
let s:undodir = expand('~/.vim/.undo')
if has('nvim')
    " The undo file of vim and nvim is not compatible
    let s:undodir = expand('~/.vim/.undo/nvim')
endif
if !isdirectory(expand(s:undodir))
    silent! call mkdir(expand(s:undodir, 'p'))
endif
let &undodir=s:undodir
set undofile

" set Vim-specific sequences for RGB colors
let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"
set t_Co=256

if has("termguicolors")
    set termguicolors
endif

" Correct background rendering in some terminal
let &t_ut=''

" Identation

set autoindent
set tabstop=4
set shiftwidth=4
set expandtab
set softtabstop=4

set wrap
"set nowrap
"set wrapmargin=4
set scrolloff=5
"set sidescrolloff=5
" always show statline
set laststatus=2
set ruler

set hlsearch
set incsearch
set ignorecase
set smartcase

" Completion

set path+=**
set wildmenu
set wildignorecase
set wildmode=list:longest,full
set wildignore=*.o,*.obj,*~
set wildignore+=*DS_Store*
set wildignore+=*.gem
set wildignore+=*.png,*.jpg,*.gif
set wildignore+=**/.git/**
set wildignore+=**/node_modules/**

" change default directory
let s:vim_swapfiles_dir = expand('~/.vim/.swp/')
if !isdirectory(s:vim_swapfiles_dir)
    silent! call mkdir(s:vim_swapfiles_dir, 'p')
endif
set directory=~/.vim/.swp//

" tags
set tags=./.tags;,.tags

" mapping
let mapleader=','
let maplocalleader='\'
nnoremap <leader>cd :cd %:p:h<CR> :pwd<CR>
nnoremap <c-g><c-g> <Esc>
cnoremap <C-G> <C-C>

" highlight Pmenu ctermbg=grey

packadd! onedark.vim
silent colorscheme onedark

packadd matchit

if !empty(glob('~/.vim_local'))
    source ~/.vim_local
endif