-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.vimrc
159 lines (135 loc) · 5.15 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
" https://github.com/junegunn/vim-plug
if empty(glob('$HOME/.vim/autoload/plug.vim'))
silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif
function! Cond(cond, ...)
let opts = get(a:000, 0, {})
return a:cond ? opts : extend(opts, { 'on': [], 'for': [] })
endfunction
call plug#begin()
Plug 'romainl/vim-cool'
Plug 'tpope/vim-surround'
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'davidhalter/jedi-vim'
Plug 'ervandew/supertab'
Plug 'tomtom/tcomment_vim'
Plug 'romainl/flattened' " For colorscheme
Plug 'christoomey/vim-sort-motion'
Plug 'psf/black', Cond(has('pip'))
Plug 'neoclide/coc.nvim', {'branch': 'release'}
call plug#end()
" exec python
noremap <F5> <ESC>:w<CR>:silent execute "!python %"<CR><CR>
set clipboard=unnamed
nnoremap <buffer> <F9> :w<CR>:exec '!python' shellescape(@%, 1)<cr>
" Abbreviations
abbr flaot float
abbr funciton function
abbr teh the
abbr tempalte template
abbr fitler filter
abbr cosnt const
abbr attribtue attribute
abbr attribuet attribute
filetype plugin indent on
set tabstop=2 " number of visual spaces per TAB
set softtabstop=2 " number of spaces in tab when editing
set shiftwidth=2 " when indenting with '>', use 4 spaces width
set expandtab " tabs are spaces https://dougblack.io/words/a-good-vimrc.html
set smarttab
set backspace=indent,eol,start
" colorscheme solarized
let g:airline_solarized_bg='dark'
let g:airline_theme='solarized'
" code completion SuperTab config
let g:SuperTabDefaultCompletionType = "context"
" instead of <c-p> as completion, which is backwards
" let g:SuperTabContextDefaultCompletionType = "<c-n>"
let g:SuperTabLongestEnhanced = 1
let g:SuperTabDefaultCompletionType = ""
" let g:SuperTabContextDefaultCompletionType = "<c-x><c-o>"
silent! colorscheme flattened_dark
" Line number column on the left
" Taken from https://jeffkreeftmeijer.com/vim-number/
set number relativenumber
augroup numbertoggle
autocmd!
autocmd BufEnter,FocusGained,InsertLeave * set relativenumber
autocmd BufLeave,FocusLost,InsertEnter * set norelativenumber
augroup END
" UI Config
set number " show line numbers
set showcmd " show command in bottom bar
set cursorline
set wildmenu " visual autocomplete for command menu
set showmatch " highlight matching [{()}]
" Color the column number 121 differently
let &colorcolumn=121
" To jump back to where you last were when editing the file
if has("autocmd")
au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$")
\| exe "normal! g'\"" | endif
endif
" Searching
set incsearch " search as characters are entered
set hlsearch " highlight matches
" Use <C-L> to clear the highlighting of :set hlsearch.
if maparg('<C-L>', 'n') ==# ''
nnoremap <silent> <C-L> :nohlsearch<C-R>=has('diff')?'<Bar>diffupdate':''<CR><CR><C-L>
endif
" Motion
" From https://blog.petrzemek.net/2016/04/06/things-about-vim-i-wish-i-knew-earlier/
" move vertically by visual line https://stackoverflow.com/questions/20975928/moving-the-cursor-through-long-soft-wrapped-lines-in-vim/21000307#21000307
noremap <silent> <expr> j (v:count == 0 ? 'gj' : 'j')
noremap <silent> <expr> k (v:count == 0 ? 'gk' : 'k')
" highlight last inserted text
nnoremap gV `[v`]
"
" Stay in visual mode when indenting. You will never have to run gv after
" performing an indentation.
vnoremap < <gv
vnoremap > >gv
" Make Y yank everything from the cursor to the end of the line. This makes Y
" act more like C or D because by default, Y yanks the current line (i.e. the
" same as yy).
noremap Y y$
" In command mode (i.e. after pressing ':'), expand %% to the path of the current
" buffer. This allows you to easily open files from the same directory as the
" currently opened file.
cnoremap <expr> %% getcmdtype() == ':' ? expand('%:h').'/' : '%%'
" Allows you to easily replace the current word and all its occurrences.
nnoremap <Leader>rc :%s/\<<C-r><C-w>\>/
vnoremap <Leader>rc y:%s/<C-r>"/
" Allows you to easily change the current word and all occurrences to something
" else. The difference between this and the previous mapping is that the mapping
" below pre-fills the current word for you to change.
nnoremap <Leader>cc :%s/\<<C-r><C-w>\>/<C-r><C-w>
vnoremap <Leader>cc y:%s/<C-r>"/<C-r>"
" Make Ctrl-e jump to the end of the current line in the insert mode. This is
" handy when you are in the middle of a line and would like to go to its end
" without switching to the normal mode.
inoremap <C-e> <C-o>$
" jk is escape
inoremap jk <esc>
" Map ; to : to avoid pressing shift to enter command mode
map ; :
let mapleader=","
map ,t :tabnew <CR>
" Airline configuration
let g:airline_powerline_fonts=1
let g:airline#extensions#tabline#enabled=1
" Sensible vim
" Allow color schemes to do bright colors without forcing bold.
if &t_Co == 8 && $TERM !~# '^linux\|^Eterm'
set t_Co=16
endif
" Black autosave
" let g:black_virtualenv=$PYENV_ROOT."/versions/neovim"
let g:black_virtualenv=$PYENV_ROOT.'/versions/neovim/bin/black'
" augroup black_on_save
" autocmd!
" autocmd BufWritePre *.py Black
" augroup end