-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvimrc.local
More file actions
194 lines (157 loc) · 6.85 KB
/
vimrc.local
File metadata and controls
194 lines (157 loc) · 6.85 KB
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
191
192
193
194
" Turn on support for 256-color terminals
let &t_Co=256
" i want mapleader to be space, not comma. let mapleader=','
filetype plugin on
" =================== General Config ======================
set relativenumber " relative line numbers
set tags=./tags; " Set tag file search order (for ctags)
set undofile " undo files even after writing and closing (saved in a *~ file)
set smartindent " enable smart indenting of files
set hlsearch " highlight our search results
set timeoutlen=500 " lower leader key timout to get rid of slight lag
set autowrite " Write the old file out when switching between files.
set autoread " reload files changed outside of vim
" ============ Settings for Core Packages ================
" create a netrw hide list
let g:netrw_list_hide= '.*\.swp$,.*\.pyc,.*\.~un$'
" get rid of netrw banner
" let g:netrw_banner = 0
" ================== Color Theme =========================
"Use 24-bit (true-color) mode in Vim/Neovim when outside tmux.
"If you're using tmux version 2.2 or later, you can remove the outermost $TMUX check and use tmux's 24-bit color support
"(see < http://sunaku.github.io/tmux-24bit-color.html#usage > for more information.)
if (empty($TMUX))
if (has("nvim"))
"For Neovim 0.1.3 and 0.1.4 < https://github.com/neovim/neovim/pull/2198 >
let $NVIM_TUI_ENABLE_TRUE_COLOR=1
endif
"For Neovim > 0.1.5 and Vim > patch 7.4.1799 < https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162 >
"Based on Vim patch 7.4.1770 (`guicolors` option) < https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd >
" < https://github.com/neovim/neovim/wiki/Following-HEAD#20160511 >
if (has("termguicolors"))
set termguicolors
endif
endif
syntax on
colorscheme onedark
" other color schemes
" colorscheme Tomorrow-Night-Eighties " theme
" colorscheme gotham256
" colorscheme OceanicNext
let g:onedark_terminal_italics = 1 " enable italics in vim
let g:airline_theme='onedark' " vim airline theme for onedark
" ================== Key Remappings =====================
:imap kk <Esc>
" make regexs work the way they do in other langs, and not like literal
nnoremap / /\v
vnoremap / /\v
nnoremap ? ?\v
vnoremap ? ?\v
augroup vimrcEx
" Clear all autocmds in the group
autocmd!
" Jump to last cursor position unless it's invalid or in an event handler
autocmd BufReadPost *
\ if line("'\"") > 0 && line("'\"") <= line("$") |
\ exe "normal g`\"" |
\ endif
augroup END
" Toggle character at the end of the line
function! ToggleEndChar(charToMatch)
s/\v(.)$/\=submatch(1)==a:charToMatch ? '' : submatch(1).a:charToMatch
endfunction
nnoremap ;; :call ToggleEndChar(';')<CR>
augroup JavaScriptCmds
" remove autocommands previously set in javascript group
autocmd!
" run file in node, buffer so only in js (current buffer)
autocmd Filetype javascript nnoremap <buffer> <leader>r :!node %<cr>
" create a comment for javascript with leader c only good for current buffer
autocmd Filetype javascript nnoremap <buffer> <leader>c I//<esc>
autocmd Filetype javascript setlocal tabstop=2 shiftwidth=2 softtabstop=2 expandtab
augroup END
" use jsx syntax in .js files
autocmd Filetype javascript let g:jsx_ext_required = 0
" vim-easymotion mappings
let g:EasyMotion_do_mapping = 0 " Disable default mappings
" Bi-directional find motion
" Jump to anywhere you want with minimal keystrokes, with just one key binding.
" We comment out single char and choose double char below
" `s{char}{label}`
" nmap s <Plug>(easymotion-s)
" or
" `s{char}{char}{label}`
" Need one more keystroke, but on average, it may be more comfortable.
nmap s <Plug>(easymotion-s2)
" Turn on case insensitive feature
let g:EasyMotion_smartcase = 1
" JK motions: Line motions
map <Leader>j <Plug>(easymotion-j)
map <Leader>k <Plug>(easymotion-k)
map <Leader>l <Plug>(easymotion-lineforward)
map <Leader>h <Plug>(easymotion-linebackward)
map <Leader>w <Plug>(easymotion-w)
map <Leader>f <Plug>(easymotion-f)
" Map leader s to save
map <Leader>s :w<CR>
" enable vim to paste properly with leader-p
" turn paste on, open new line, from * (system clipboard register) paste, then
" turn paste off, carriage return - note that the `]` after the * says to
" start pasting at the current level of indentation
map <Leader>p :set paste<CR>o<esc>"*]p:set nopaste<cr>
" Tabular mappings for alignment using a= in normal or visual mode to align equals signs
nmap <Leader>a= :Tab/=<CR>
vmap <Leader>a= :Tab/=<CR>
nmap <Leader>a: :Tab/:\zs<CR>
vmap <Leader>a: :Tab/:\zs<CR>
" Movement in insert mode
inoremap <C-h> <C-o>h
inoremap <C-l> <C-o>a
inoremap <C-j> <C-o>j
inoremap <C-k> <C-o>k
" =========== FILE TREES + FILE FINDING TOOLS ==========
" nerdtree: open automatically when vim starts up
" autocmd vimenter * NERDTree
" open nerdtree on vim startup even when no files are specified
" i.e. so you can start with `vim` and not `vim .`
" autocmd StdinReadPre * let s:std_in=1
" autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif
" close vim automatically if the only window left open is a NERDTree window
" autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
" open NERDTree with CTRL + n
map <C-n> :NERDTreeToggle<CR>
" map <C-p> to fzf :GFiles command - fuzzy file finding that obeys .gitignore
" export FZF_DEFAULT_COMMAND='ag --hidden -U --ignore .git -g""'
" create a custom GitFiles command `MyGF` that excludes standard git excludes
command! MyGF call fzf#run(fzf#wrap({'source': 'git ls-files --exclude-standard --cached --others'}))
" nnoremap <c-p> :GFiles<cr>
nnoremap <c-p> :MyGF<cr>
" Open GFiles on vim open except when opened from git (for git commits)
" :autocmd vimenter * if &filetype !=# 'gitcommit' | GFiles | endif
augroup PythonCmds
" assume python is using invoke and run invoke test with leader t to
" run tests from python files
autocmd Filetype python nnoremap <buffer> <leader>t :!invoke test<cr>
augroup END
" force Markdown for *.md files
" see vim-markdown for why: https://github.com/tpope/vim-markdown
autocmd BufNewFile,BufReadPost *.md set filetype=markdown
" use vim-flavored markdown for github-flavored markdown by default
augroup markdown
au!
au BufNewFile,BufRead *.md,*.markdown setlocal filetype=ghmarkdown
augroup END
" add syntastic linting to status line and set eslint as javascript lint checker
" set statusline+=%#warningmsg#
" set statusline+=%{SyntasticStatuslineFlag()}
" set statusline+=%*
" let g:syntastic_always_populate_loc_list = 1
" let g:syntastic_auto_loc_list = 1
" let g:syntastic_check_on_open = 1
" let g:syntastic_check_on_wq = 0
" let g:syntastic_javascript_checkers = ['eslint']
" let g:syntastic_javascript_eslint_exe='[ -f $(npm bin)/eslint ] && $(npm bin)/eslint || eslint'
let g:ale_fixers = {
\ '*': ['remove_trailing_lines', 'trim_whitespace'],
\ 'javascript': ['eslint'],
\}