-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmyvimrc
More file actions
138 lines (105 loc) · 2.95 KB
/
myvimrc
File metadata and controls
138 lines (105 loc) · 2.95 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
source ~/.vim/vimrc
nnoremap <C-F> :CommandT<cr>
nnoremap <f4> :BufExplorer<cr>
colorscheme monokai
set tabstop=2
set shiftwidth=2
set expandtab
set nobackup
set noswapfile
" better atomic save
autocmd BufWriteCmd * call AtomicSave()
set colorcolumn=100
" highlight line and column under cursor
set cursorline cursorcolumn
set wildignore+=tmp/cache/*
" noremap <Up> <nop>
" noremap <Down> <nop>
" noremap <Left> <nop>
" noremap <Right> <nop>
nnoremap <C-Left> :cp<cr>
nnoremap <C-Right> :cn<cr>
nnoremap <C-Up> :prev<cr>
nnoremap <C-Down> :n<cr>
nnoremap <S-Up> :bprev<cr>
nnoremap <S-Down> :bnext<cr>
" nnoremap ; :
cabbrev gst Gstatus
cabbrev gd Gdiff
set keymap=russian-jcukenwin
set iminsert=0
set imsearch=0
highlight lCursor guifg=Red guibg=NONE
" folding
set foldmethod=expr
set foldexpr=TestFolding(v:lnum)
set foldcolumn=1
set foldlevel=1
set foldnestmax=1
function! IndentLevel(lnum)
let level = indent(a:lnum) / &shiftwidth
if level > 2
return 2
endif
return level
endfunction
function! PrevNonBlankLine(lnum)
let current = a:lnum - 1
while current > 0
if getline(current) =~? '\v\S'
return current
endif
let current -= 1
endwhile
return -2
endfunction
function! NextNonBlankLine(lnum)
let numlines = line('$')
let current = a:lnum + 1
while current <= numlines
if getline(current) =~? '\v\S'
return current
endif
let current += 1
endwhile
return -2
endfunction
function! TestFolding(lnum)
let prev_indent = IndentLevel(PrevNonBlankLine(a:lnum))
let this_indent = IndentLevel(a:lnum)
let next_indent = IndentLevel(NextNonBlankLine(a:lnum))
if getline(a:lnum) =~? '\v^\s*$'
return TestFolding(PrevNonBlankLine(a:lnum))
endif
if prev_indent > this_indent
return prev_indent
elseif next_indent == this_indent
return this_indent
elseif next_indent < this_indent
return this_indent
elseif next_indent > this_indent
return '>' . next_indent
endif
endfunction
function RunTest(text)
let name = substitute(a:text, "['\"]", "", "g")
let name = substitute(name, "[^a-zA-Z0-9]", "_", "g")
let cmd = substitute("echo {name} | time bin/one_test {file}\n", "{name}", name, "")
let cmd = substitute(cmd, "{file}", @%, "")
call Send_to_Tmux(cmd)
endfunction
" running test file, one test, or all suite
noremap <F7> :!time testdrb %<CR>
noremap <F9> $?test ['"][^'"]\+['"] do<CR>:.w !sed "s/^\ \+//" \| sed "s/\ do$//" \| sed "s/['\"]//g" \| sed "s/\ /_/g" \| time bin/one_test %<CR>
noremap <F5> :!time testdrb test/**/*_test.rb<CR>
noremap <F12> :A<CR>
noremap <S-F12> :R<CR>
noremap <F11> :R<CR>
noremap <F5> :call Send_to_Tmux("time bin/tests\n")<CR>
noremap <F7> :call Send_to_Tmux(substitute("time testdrb {file}\n", "{file}", @%, ""))<CR>
noremap <F9> $?test ['"][^'"]\+['"] do<CR>^v/' do<CR>"ry :call RunTest(@r)<CR>
" faster search
set grepprg=ack-grep
" switchers to change how word-wise ops working
noremap _ :set iskeyword-=_ <CR>
noremap + :set iskeyword+=_ <CR>