forked from pelme/pelmerc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vimrc
176 lines (141 loc) · 6.57 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
call plug#begin('~/.vim/plugins')
Plug 'tpope/vim-surround' " life-changer
Plug 'tpope/vim-commentary' " comment code with gc
Plug 'tpope/vim-repeat' " make it possible to use . (repeat command) for plugins
if !exists('g:vscode')
Plug 'rakr/vim-one'
Plug 'vim-airline/vim-airline' " nicer status line
Plug 'vim-airline/vim-airline-themes'
Plug 'pangloss/vim-javascript', { 'for': 'javascript' }
Plug 'HerringtonDarkholme/yats.vim'
Plug 'ctrlpvim/ctrlp.vim' " find files with fuzzymatching
Plug 'SirVer/ultisnips' " snippet manager
Plug 'honza/vim-snippets' " snippets
Plug 'neomake/neomake' " linting with flake8, eslint
Plug 'tpope/vim-fugitive' " git integration
Plug 'ervandew/supertab' " make tab provivde autocomplete
Plug 'dyng/ctrlsf.vim'
Plug 'airblade/vim-gitgutter' " mark added/changed/removed
Plug 'davidhalter/jedi-vim' " python autocompletion
Plug 'hynek/vim-python-pep8-indent' " sane python indentation
Plug 'saltstack/salt-vim' " salt state file support
Plug 'dag/vim-fish' " fish syntax
Plug 'ryanoasis/vim-devicons' " nice icons. requires installing nerd font.
" must be loaded late to be used by ctrlp etc
Plug 'robbles/logstash.vim'
Plug 'vim-python/python-syntax'
Plug '~/code/vim-testfile'
endif
call plug#end()
if !exists('g:vscode')
" basics
syntax on
set hidden " allow hidden buffers
set number " show line numbers
set title " show title in console title bar
set wildignore+=*.o,*.obj,*.bak,*.exe,*.pyc,*.png,*.jpg,*.gif,*.rdb,*.DS_Store,*.egg-info/**,*.db
set wildignore+=**/_build/**,**/external/**,**/CACHE/**,**/node_modules/**,**/bower_components/**
set wildignore+=**/build/**,**/assets/**,*.tar.gz,*.tar.bz2,**/venv/**,**/venv-*/**,**/.tox/**
set colorcolumn=100 " show a vertical line at 100 characters
set ignorecase " case insensitive search
set nobackup " do not keep a backup file
set modeline " allow modeline
set shiftwidth=4 " autoindent to 4 spaces (=,<,>) by default
set expandtab " insert spaces when pressing tab
set tabstop=4 " numbers of spaces of tab character
set noswapfile " make vim work with watchdog
set nowritebackup " avoid backup file
set cursorline " highlight the current line
if has("autocmd")
" Restore cursor position
au BufReadPost * if line("'\"") > 0|if line("'\"") <= line("$")|exe("norm '\"")|else|exe "norm $"|endif|endif
au BufRead,BufNewFile *.md set filetype=markdown
au BufRead,BufNewFile *.txt set filetype=markdown
au BufRead,BufNewFile *.es6 set filetype=javascript
au BufRead,BufNewFile *.html.dj set filetype=htmldjango
au BufRead,BufNewFile *.html.ng set filetype=html
" http://vim.wikia.com/wiki/Update_the_diff_view_automatically
autocmd BufWritePost * if &diff == 1 | diffupdate | endif
autocmd! BufWritePost * Neomake " invoke neomake on save
endif
" shortcuts
let mapleader = ","
nmap <leader>w :w<cr>
nmap <leader>x :x<cr>
nmap <silent> <leader>/ :nohlsearch<cr> " clear search highlight
" search/replace current word
nnoremap <leader>s :%s/\<<C-r><C-w>\>//g<Left><Left>
nnoremap S diw"0P " 'stamp' the word under the cursor
map <leader>e :e ~/.vimrc<cr> " edit my .vimrc file
let g:jedi#use_tabs_not_buffers = 0
let g:jedi#use_splits_not_buffers = "bottom"
let g:jedi#goto_assignments_command = ""
let g:jedi#goto_definitions_command = ""
let g:jedi#usages_command = ""
nnoremap <leader>f :CtrlSF<space>
noremap <leader>a :call jedi#goto_assignments()<cr>
noremap <leader>d :call jedi#goto_definitions()<cr>
noremap <leader>u :call jedi#usages()<cr>
nnoremap <leader>g :Gstatus<cr>
nnoremap <leader>c :Gcommit<cr>
" yank to system clipboard
vmap <leader>y "*y
nmap <leader>y "*y
nmap <leader>t :CtrlP<cr>
nmap <leader>b :CtrlPBuffer<cr>
imap jj <C-c>
nnoremap <leader>d :bp<bar>sp<bar>bn<bar>bd<CR>
nnoremap <leader><leader> :b#<cr> " switch to last buffer
nnoremap <C-Left> :vertical resize -1<cr> " ctrl+arrow keys to resize splits
nnoremap <C-Down> :resize +1<cr>
nnoremap <C-Up> :resize -1<cr>
nnoremap <C-Right> :vertical resize +1<cr>
nnoremap <leader>v :vertical size 105<cr>
set splitright " open vertical splits to the right
nmap <silent> <C-h> :wincmd h<CR>
nmap <silent> <C-j> :wincmd j<CR>
nmap <silent> <C-k> :wincmd k<CR>
nmap <silent> <C-l> :wincmd l<CR>
if has('nvim')
nmap <BS> <C-W>h " Workaround https://github.com/neovim/neovim/issues/2048
endif
" make it possible to easily create new files in the same directories as
" existing files by typing %%
cabbr <expr> %% expand('%:p:h')
" GUI/MacVim specific
set guifont=Source\ Code\ Pro:h14
set guioptions-=T " remove scrollbars and toolbars
set guioptions-=L " ...
set guioptions-=r " ...
set vb " disable annoying audible bell in macvim
" theming and colors
if (has("termguicolors"))
set termguicolors " enable lots of colors
endif
set background=dark
let g:oceanic_next_terminal_italic = 1 " enable italics, disabled by default
let g:oceanic_next_terminal_bold = 1 " enable bold, disabled by default
colorscheme one
let $NVIM_TUI_ENABLE_CURSOR_SHAPE=1 " non-block cursor in insert mode
let g:WebDevIconsUnicodeDecorateFileNodesExtensionSymbols = {} " needed
let g:WebDevIconsUnicodeDecorateFileNodesExtensionSymbols['es6'] = '' " pretty icon for .es6 files
" highlight trailing whitespace
highlight ExtraWhitespace ctermbg=red guibg=red
match ExtraWhitespace /\s\+$/
autocmd BufWinEnter * match ExtraWhitespace /\s\+$/
autocmd InsertEnter * match ExtraWhitespace /\s\+\%#\@<!$/
autocmd InsertLeave * match ExtraWhitespace /\s\+$/
autocmd BufWinLeave * call clearmatches()
" create virtualenv with:
" $ new -p (which python3.5) neovim3
" $ pip install neovim
" $ new -p (which python2.7) neovim2
" $ pip install neovim
let g:python_host_prog=$HOME . '/.virtualenvs/neovim2/bin/python'
let g:python3_host_prog=$HOME . '/.virtualenvs/neovim3/bin/python'
let g:python_highlight_all = 1
" Stolen from https://github.com/blueyed/dotfiles/blob/12ff8d2572e5333ef4a11c0c56f630e8d0e4d13f/vimrc
command! -range=% -nargs=* Isort :<line1>,<line2>! isort --lines 79 <args> -
vmap <leader>i :Isort<cr>
nmap <leader>i :Isort<cr>
endif