/
init.vim
executable file
·190 lines (161 loc) · 6.5 KB
/
init.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
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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
" General settings
set nocompatible " be iMproved
filetype off " required!
set relativenumber " display relative line numbers
set number " display line numbers
set hlsearch " highlight search results
set backspace=2 " enable backspace in insert mode
set cursorline " highlight the cursor line
set cursorcolumn " highlight the cursor column
set nobackup " won't save backup file anymore
set noswapfile " won't save swap file anymore
" Encoding settings
set encoding=utf-8 " for Vim execution
set fileencoding=utf-8 " for saving new files
set fileencodings=utf-8 " for opening files
" Programming settings
set expandtab " expand TABs to spaces
set tabstop=4 " the width of a TAB
set shiftwidth=4 " the width of a indent
set softtabstop=4 " the numbers of columns for a TAB
set smarttab " uses shiftwidth instead of tabstop at start of lines
set tabpagemax=100 " change the limit of tabs
set mouse=a " enable mouse mode
set completeopt=longest,menuone,preview
" set clipboard=unnamed " +y to copy text to clipboard
" Theme settings
" let $NVIM_TUI_ENABLE_TRUE_COLOR=1
syntax enable
set background=dark
" Keymap settings
" set <Leader> to <Space>
let mapleader = "\<Space>"
" frequently used commands
nnoremap <Leader>w :w<CR>
nnoremap <Leader>q :qa<CR>
nnoremap <Leader>wq :wq<CR>
" buffer switch
nnoremap <Tab> :bn<CR>
nnoremap <S-Tab> :bp<CR>
" buffer creation and exit
nnoremap <silent> <S-t> :enew<CR>
nnoremap <silent> <S-q> :bw<CR>
" search selected text with //
vnoremap // y/<C-R>"<CR>
" Plugins
call plug#begin('~/.local/share/nvim/plugged')
" Theme
" Plug 'altercation/vim-colors-solarized'
Plug 'morhetz/gruvbox'
" Git
Plug 'tpope/vim-fugitive'
" Status bar
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
set laststatus=2
let g:airline#extensions#tabline#enabled = 1
let g:airline_powerline_fonts = 1
set noshowmode
Plug 'w0rp/ale', { 'for': 'python', 'on': 'ALEToggle' }
let g:ale_linters = {
\ 'python': ['flake8'],
\}
let g:ale_python_flake8_options = "--ignore=E203,E221,E251,E402,E501"
let g:ale_enabled = 0
let g:airline#extensions#ale#enabled = 1
let g:ale_echo_msg_error_str = 'E'
let g:ale_echo_msg_warning_str = 'W'
let g:ale_echo_msg_format = '[%linter%] %s [%severity%]'
let g:ale_open_list = 1
nmap <silent> <leader>e :ALEToggle<CR>: echom "ALE Checking"<CR>
nmap <silent> <C-k> <Plug>(ale_previous_wrap)
nmap <silent> <C-j> <Plug>(ale_next_wrap)
" mako syntax support
Plug 'marksylee/vim-bundle-mako'
" Highlight HTML tags
Plug 'gregsexton/MatchTag'
" Ctrl-P to search file
Plug 'kien/ctrlp.vim'
let g:ctrlp_map = '<Leader>o'
let g:ctrlp_cmd = 'CtrlP'
set wildignore+=*/tmp/*,*.so,*.swp,*.zip
let g:ctrlp_custom_ignore = {
\ 'dir': '\v[\/]\.(git|hg|svn)$',
\ 'file': '\v\.(exe|so|dll|pyc)$',
\ }
let g:ctrlp_user_command = ['.git', 'cd %s && git ls-files . -co --exclude-standard', 'find %s -type f']
" Ag.Vim to search text
Plug 'rking/ag.vim'
" Display tags in a window
Plug 'majutsushi/tagbar', { 'for': 'python' }
let g:tagbar_autofocus = 1
let g:tagbar_silent = 1
let g:tagbar_sort = 0
nnoremap <Leader>t :TagbarToggle<CR>
" Display the indention levels
Plug 'Yggdroot/indentLine'
let g:indentLine_char = '¦'
" let g:indentLine_setConceal = 0
" Easymotion
Plug 'easymotion/vim-easymotion'
" Nerd
Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' }
map <Leader>tt :NERDTreeToggle<CR>
let NERDTreeIgnore=['\.pyc$']
let g:NERDTreeWinSize = 40
" dark powered neo-completion
Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins', 'for': 'python' }
Plug 'zchee/deoplete-jedi', { 'for': 'python' }
" let g:deoplete#enable_smart_case = 1
let g:deoplete#enable_at_startup = 1
" let g:deoplete#sources#jedi#show_docstring = 1
" let g:deoplete#auto_complete_delay = 500
" let g:deoplete#disable_auto_complete = 1
" inoremap <expr><C-n> deoplete#mappings#manual_complete()
inoremap <expr><C-j> pumvisible() ? "\<C-n>" : "\<C-j>"
inoremap <expr><C-k> pumvisible() ? "\<C-p>" : "\<C-k>"
let g:python_host_prog = '/home/marklee/dev/virtualenv/neovim2/bin/python2.7'
let g:python3_host_prog = '/home/marklee/dev/virtualenv/neovim3/bin/python3.6'
" only for go-to-definition
Plug 'davidhalter/jedi-vim', { 'for': 'python' }
let g:jedi#auto_vim_configuration = 0
let g:jedi#use_tabs_not_buffers = 0
let g:jedi#goto_command = '<leader>d'
" let g:jedi#usages_command = '<leader>g'
let g:jedi#documentation_command = "<leader>k"
let g:jedi#completions_enabled = 0
let g:jedi#smart_auto_mappings = 0
call plug#end()
" Remove trailing spaces when saving files
autocmd BufWritePre * :%s/\s\+$//e
" Hand-made snippets
autocmd FileType python
\ nnoremap <Leader>ih i#!/usr/bin/env python<CR># -*- coding: utf-8 -*-<CR>from __future__ import division<CR>from __future__ import print_function<CR>from __future__ import unicode_literals<CR><CR>|
\ nnoremap <Leader>im iif __name__ == '__main__':<CR>
" Copy/Paste Mode for SSH to remote Vim
nnoremap <Leader>c :call ToggleCopyMode()<CR>
function ToggleCopyMode()
" Buffer-local variable
if !exists('b:copy_mode_is_enabled')
let b:copy_mode_is_enabled = 0
endif
if b:copy_mode_is_enabled
echom 'Disable Copy Mode'
set mouse=a
IndentLinesEnable
set number
set relativenumber
let b:copy_mode_is_enabled = 0
else
echom 'Enable Copy Mode'
set mouse=
ALEDisable
IndentLinesDisable
set number!
set relativenumber!
let b:copy_mode_is_enabled = 1
endif
endfunction
" Enable theme
" colorscheme solarized
colorscheme gruvbox