-
-
Notifications
You must be signed in to change notification settings - Fork 15
/
general.vim
141 lines (132 loc) · 3.58 KB
/
general.vim
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
" general.vim
"
" Maintained by Claud D. Park <posquit0.bj@gmail.com>
" https://www.posquit0.com/
" Make Vim more useful
set nocompatible
" Use path '~/.vim' even on non-unix machine
set runtimepath+=~/.vim
" Enhance command-line completion
set wildmenu
" Ignore when expanding wildcards
set wildignore=*.swp,*.swo,*.class
" Number of things to remember in history
set history=256
" Use the OS clipboard by default (on versions compiled with `+clipboard`)
set clipboard=unnamed
" Optimize for fast terminal connections
set ttyfast
" Walk directory tree upto $HOME looking for tags
set tags=./tags;$HOME
" Don’t add empty newlines at the end of files
" set binary
" set noendofline
" Add empty newlines at the end of files
set endofline
" Automatically change window's cwd to file's dir
set autochdir
" Set path to viminfo
if !has('nvim')
set viminfo='100,n$HOME/.viminfo
endif
" Set default shell to execute functions
set shell=sh
"" Modeline
" Respect modeline in files
set modeline
set modelines=4
"" Python
" Figure out the system Python for Neovim.
if exists("$VIRTUAL_ENV")
let g:python3_host_prog=substitute(system('which -a python3 | head -n2 | tail -n1'), '\n', '', 'g')
else
let g:python3_host_prog=substitute(system('which python3'), '\n', '', 'g')
endif
""" Auto Commands {{{
if has('autocmd')
" Auto reload vimrc
" augroup reload_vimrc
" autocmd!
" autocmd BufWritePost $MYVIMRC,*.vim
" \ source $MYVIMRC |
" \ echo 'Reloaded VIM Configurations'
" augroup END
" Restore cursor position when opening file
augroup restore_cursor
autocmd!
autocmd BufReadPost *
\ if line("'\"") > 1 && line("'\"") <= line("$") |
\ exe "normal! g`\"" |
\ endif
augroup END
endif
""" }}}
""" Folding {{{
" Turn on folding
set foldenable
" Make folding indent sensitive
set foldmethod=indent
" Don't autofold anything
set foldlevel=99
" Don't open folds when search into them
set foldopen-=search
" Don't open folds when undo stuff
set foldopen-=undo
""" }}}
""" Backup & Swap {{{
" No fucking backup & swap files
set noswapfile
set nobackup
" Centralize backups, swapfiles and undo history
" set backupdir=~/.vim/backups
" set directory=~/.vim/swaps
" Maintain undo history between sessions
set undofile
" Set maximum number of changes that can be undone
set undolevels=100
" Change directory to save undo history
if has('persistent_undo') && !has('nvim')
set undodir=~/.vim/cache
if !isdirectory(&undodir)
" Create directory
call mkdir(&undodir, 'p')
endif
endif
" Don’t create backups when editing files in certain directories
set backupskip=/tmp/*
""" }}}
""" Encoding {{{
set encoding=utf-8
set fileencodings=utf-8,euc-kr
""" }}}
""" Formatting {{{
" Set the default tabstop
set tabstop=2
set softtabstop=2
" Set the default shift width for indents
set shiftwidth=2
" Make tabs into spaces (set by tabstop)
set expandtab
" Smarter tab levels
set smarttab
" Copy indent from current line when starting a new line
set autoindent
" Do smart autoindenting when starting a new line
set smartindent
""" }}}
""" Grep {{{
if executable('rg')
" Use rg(ripgrep)
set grepprg=rg\ --no-heading\ --vimgrep
elseif executable('pt')
" Use pt(The Platinum Searcher)
set grepprg=pt\ --nocolor\ --nogroup\ --column
elseif executable('ag')
" Use ag(The Silver Searcher)
set grepprg=ag\ --vimgrep
elseif executable('ack')
set grepprg=ack\ -H\ --nocolor\ --nogroup
endif
" Set foramt for vimgrep
set grepformat=%f:%l:%c:%m
""" }}}