-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinit.vim
More file actions
250 lines (193 loc) · 6.91 KB
/
Copy pathinit.vim
File metadata and controls
250 lines (193 loc) · 6.91 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
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
" Neovim config.
" basics {{{1
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set number
set ignorecase
set smartcase
set linebreak " don't break lines in the middle of a word
set scrolloff=5 " keep some lines below and above the cursor
set undolevels=100000
set textwidth=88
set autoindent " new line like previous line
set nosmartindent
set foldmethod=marker " automatically close marked folds in files
set hidden " required by LustyJuggler
" set exrc " allow project-local config files (see :trust)
" default indentation (may be overriden by filetype-specific settings)
set expandtab
set shiftwidth=4
set tabstop=4
set softtabstop=4
" Y copies till the end of the line (can't have comment after the line, since
" white space is significant -- it makes the cursor move).
noremap Y y$
" plugin settings
let NERDSpaceDelims=1 " comment with '# ' instead of just '#'
" neovim stuff
set mouse=
colorscheme vim
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" }}}
" filetype-specific settings {{{1
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
filetype plugin on
filetype indent off
function! SetTwoSpaceMode()
setlocal softtabstop=2
setlocal tabstop=2
setlocal shiftwidth=2
endfunction
" Python
au FileType python set formatoptions+=cro
" Makefile
au FileType make set noexpandtab
" CSS
au FileType css call SetTwoSpaceMode()
" HTML
" au FileType html set textwidth=0
au FileType html call SetTwoSpaceMode()
" au FileType htmldjango set textwidth=0
au FileType htmldjango call SetTwoSpaceMode()
" JavaScript
au FileType javascript call SetTwoSpaceMode()
" Java (google style doc says 2 spaces)
au FileType java call SetTwoSpaceMode()
" Scala
au FileType scala call SetTwoSpaceMode()
" Markdown
au BufRead,BufNewFile *.md set filetype=markdown
let g:instant_markdown_autostart = 0
let g:instant_markdown_slow = 1
" Arduino
au BufNewFile,BufRead *.pde set syntax=arduino
" Error buffer
au BufReadPost quickfix setlocal nonumber
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" }}}
" shortcuts {{{1
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
map <F9> :w<CR>:make<CR>
map gf :e **/<cfile><cr> " allow opening files with incomplete paths
" (e.g. open bla/bla/a/b when a/b is under cursor)
" Can still save if I forget sudo.
cmap w!! %!sudo tee > /dev/null %
" Old stuff; not sure I still need any of this:
"
" set pastetoggle=<F6> " toggle paste mode
"
" Alt+o / Alt+O to make a new line without entering insert mode.
" Mapping <M-o> and <M-O> doesn't do squat, because terminals insert weird
" characters when you press those keys.
" Linux (FIXME: this makes the arrow keys insert lines...)
" noremap o o<Esc>
" noremap O O<Esc>
" Move line up / down. Especially useful for git rebase -i.
noremap <C-j> :m +1<CR>
noremap <C-k> :m -2<CR>
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" }}}
" abbreviations {{{1
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Pressing <Tab> or <Space> or <Enter> after one of these will
" still insert the tab / space / newline after the abbreviation.
" (:help abbrev and search for "non-id" for some fun restrictions)
" shebangs
iabbrev bash# #!/bin/bash
iabbrev py# #!/usr/bin/env python
" Python misc
iabbrev pyma if __name__ == "__main__":
iabbrev py* print "*" * 78 # XXX
iabbrev ipdb; import ipdb; ipdb.set_trace() # XXX
iabbrev pinit def __init__(self):
" Python imports
iabbrev inpy import numpy as np
iabbrev iplt import matplotlib.pyplot as plt
iabbrev iimg import matplotlib.image as mpimg
iabbrev ictr from collections import Counter
iabbrev idd from collections import defaultdict
iabbrev idt import datetime
iabbrev intup from collections import namedtuple
" Python nose
iabbrev nae nose.tools.assert_equal
iabbrev naae nose.tools.assert_almost_equals
iabbrev nat nose.tools.assert_true
iabbrev naf nose.tools.assert_false
iabbrev nai nose.tools.assert_in
" Java misc
iabbrev pln System.out.println
" TODO port this macro to do include-guard boilerplate.
" :call setreg('i', 'bywI#ifndef o#define po#endif // pkko')
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" }}}
" arpeggio mappings {{{1
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Force plugin to load now, instead of after ~/.vimrc is finished processing.
:packloadall
call arpeggio#load()
" very common operations {{{2
Arpeggio inoremap jk <Esc>
Arpeggio noremap jf :w<CR>
Arpeggio noremap we :noh<CR>
Arpeggio noremap sf :set filetype=
" Note: Can't put indented comments after the line,
" since the spaces cause the cursor to move!
" Note: On OSX, use * instead of +.
" Copy entire file to system clipboard:
Arpeggio noremap gy :%y+<CR>
" Copy selection to system clipboard:
Arpeggio vnoremap gy "+y
" Comment lines:
Arpeggio noremap co :call nerdcommenter#Comment(0, "AlignLeft")<CR>
" Uncomment lines:
Arpeggio noremap cu :call nerdcommenter#Comment(0, "Uncomment")<CR>
" ruff (TODO: set up proper LSP, see https://docs.astral.sh/ruff/editors/setup/#neovim)
Arpeggio noremap fo :!ruff check --fix && ruff format<CR>
"}}}
" windows and buffers {{{2
Arpeggio noremap wj <C-w>j
Arpeggio noremap wk <C-w>k
Arpeggio noremap wl <C-w>l
Arpeggio noremap wh <C-w>h
Arpeggio noremap WJ <C-w>J
Arpeggio noremap WK <C-w>K
Arpeggio noremap WL <C-w>L
Arpeggio noremap WH <C-w>H
Arpeggio noremap ws <C-w>s
Arpeggio noremap wv <C-w>v
Arpeggio noremap wq <C-w>q
" TODO: CommandTCommand also seems useful
" TODO: CommandTLine also seems useful
" TODO: not sure if CommandTBuffer or CommandTJump is better for me
" Arpeggio noremap gj :CommandTBuffer<CR>
Arpeggio noremap gj :CommandTJump<CR>
" ripgrep variant respects gitignore etc; regular variant includes all files
Arpeggio noremap gh :CommandTRipgrep<CR>
Arpeggio noremap GH :CommandT<CR>
Arpeggio noremap gt :NERDTreeToggle<CR>
" Arpeggio noremap gj :LustyJuggler<CR>
" Arpeggio noremap gp :LustyJugglePrevious<CR>
Arpeggio noremap gp :b#<CR>
"}}}
" TODO clean up {{{2
" Arpeggio noremap ei :Gstatus<CR>
" Arpeggio noremap uw viwu
" Arpeggio noremap UW viwU
"}}}
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"}}}
" leader commands {{{1
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Most of these also have arpeggio shortcuts.
" noremap <Leader>j :LustyJuggler<CR>
" <Leader>t opens :CommandT
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" }}}
" account-specific stuff not stored in git {{{1
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
if filereadable(glob("~/.vim_private"))
source ~/.vim_private
endif
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" }}}