-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgeorgebrock.vimrc
169 lines (146 loc) · 5.26 KB
/
georgebrock.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
" https://github.com/georgebrock/dotfiles/blob/master/tag-development/vimrc
syntax on
set list " Shows invisible characters
set listchars=tab:▸\ ,eol:¬
set expandtab " Use spaces, not tabs
set tabstop=2 softtabstop=2 shiftwidth=2 " Default tab size
set showcmd " Show the current command in the footer
set ruler " Show line and col numbers in footer
set modeline " Read modelines from files
set laststatus=2 " Show status line (filename, etc.) always in all windows
set number
set relativenumber " Show line numbers
set hlsearch " Highlight the current search term
set incsearch " Incremental searching
set colorcolumn=80
set cursorline " Highlight the line the cursor is on
set wildmode=longest,list
set complete+=kspell " Autocomplete with dictionary words when spell check is on
set splitright
set splitbelow
set nojoinspaces
set wildignore+=*.pyc
filetype plugin on
filetype indent on
augroup georgebrock
autocmd!
autocmd BufNewFile,BufRead *.ru setfiletype ruby
autocmd BufNewFile,BufRead *.css.erb,*.spriter setfiletype css
autocmd BufNewFile,BufRead *.mkd,*.md,*.markdown setfiletype markdown
autocmd BufNewFile,BufRead *.json setfiletype javascript
autocmd BufNewFile,BufRead *.ejs,*.hbs setfiletype html
autocmd BufNewFile,BufRead *.go setfiletype go
autocmd BufNewFile,BufRead *.slim setfiletype slim
autocmd BufNewFile,BufRead *.ex,*.exs set filetype=elixir
autocmd Filetype python setlocal tabstop=4 softtabstop=4 shiftwidth=4
autocmd Filetype make,automake setlocal noexpandtab
autocmd Filetype go setlocal noexpandtab
autocmd Filetype markdown setlocal spell textwidth=80
autocmd Filetype gitcommit,mail setlocal spell textwidth=76 colorcolumn=77
augroup END
map! 3 #
nmap r3 r#
map! - –
noremap 1 :tabnext 1<CR>
noremap 2 :tabnext 2<CR>
noremap 3 :tabnext 3<CR>
noremap 4 :tabnext 4<CR>
noremap 5 :tabnext 5<CR>
noremap 6 :tabnext 6<CR>
noremap 7 :tabnext 7<CR>
noremap 8 :tabnext 8<CR>
noremap 9 :tablast<CR>
noremap <C-j> :ALENext<CR>
noremap <C-k> :ALEPrev<CR>
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'gmarik/vundle'
Plugin 'tpope/vim-rails'
Plugin 'kien/ctrlp.vim'
Plugin 'tpope/vim-endwise'
Plugin 'jnwhiteh/vim-golang'
Plugin 'nono/vim-handlebars'
Plugin 'ConradIrwin/vim-bracketed-paste'
Plugin 'altercation/vim-colors-solarized'
Plugin 'elixir-lang/vim-elixir'
Plugin 'leafgarland/typescript-vim'
Plugin 'tpope/vim-obsession'
Plugin 'dense-analysis/ale'
call vundle#end()
set background=dark
silent! colorscheme solarized
map <leader>g :silent !gitsh<CR>:redraw!<CR>
map <leader>t :call ExecuteInShell("clear; ".TestCmd())<CR>
map <leader>T :call ExecuteInShell("clear; ".TestCmd().":".line("."))<CR>
map <leader>d :call ExecuteInShell("clear; ".DjangoTestCmd())<CR>
map <leader>r :call ExecuteInShell("clear; ".AllTestsCmd())<CR>
map <leader>M :call ExecuteInShell("clear; make")<CR>
map <leader><leader> :call RepeatInShell()<CR>
map <leader>ct :silent !ctags -R .<CR>:redraw!<CR>
map <leader>/ :nohlsearch<CR>
map <leader>m :silent !open -a Marked %<CR>:redraw!<CR>
map <leader>e :e <C-R>=expand("%:p:h") . "/" <CR>
map <leader>b :call ToggleBackground()<CR>
map <leader>2 :setlocal tabstop=2 softtabstop=2 shiftwidth=2<CR>
map <leader>4 :setlocal tabstop=4 softtabstop=4 shiftwidth=4<CR>
xnoremap . :normal .<CR> " . command in visual mode
xnoremap @ :<C-u>call ExecuteMacroOverVisualRange()<CR>
function! ExecuteMacroOverVisualRange()
echo "@".getcmdline()
execute ":'<,'>normal @".nr2char(getchar())
endfunction
command! -nargs=+ Shell :call ExecuteInShell(<q-args>)
command! -nargs=+ Rake :call ExecuteInShell("rake ".<q-args>)
function! ExecuteInShell(cmd)
let t:last_shell_cmd = a:cmd
if (system("tmux list-panes | wc -l | grep -Eo '([0-9]+)'") > 1)
execute(":silent !tmuxsend '
".a:cmd."'")
else
execute(":!".a:cmd)
endif
redraw!
endfunction
function! RepeatInShell()
if (exists("t:last_shell_cmd"))
call ExecuteInShell(t:last_shell_cmd)
else
echo "ExecuteInShell hasn't been called yet, can't repeat it"
endif
endfunction
function! TestCmd()
let l:file = expand("%:.")
if (match(l:file, ".feature$") != -1)
return "cucumber ".l:file
elseif (match(l:file, "_spec.rb$") != -1)
return "rspec ".l:file
elseif (match(l:file, "_test.rb$") != -1)
return "./bin/rails test ".l:file
elseif (match(l:file, ".py$") != -1)
return "nosetests ".l:file
elseif (match(l:file, "_spec.js.coffee$") != -1)
return "teaspoon ".l:file
elseif (match(l:file, ".test.coffee$") != -1)
return "PATH=\"$(npm bin):$PATH\" mocha ".l:file
elseif (match(l:file, ".exs") != -1)
return "mix test ".l:file
endif
endfunction
function! DjangoTestCmd()
let l:file = expand("%:.")
let l:module = substitute(substitute(l:file, "/", ".", "g"), "\.py$", "", "")
return "python manage.py test ".l:module
endfunction
function! AllTestsCmd()
return SpringCmd("spring rake", "rake")
endfunction
function! SpringCmd(spring_version, default_version)
return "$(if [[ -z `which spring` ]]; then echo \"".a:default_version."\"; else echo \"".a:spring_version."\"; fi)"
endfunction
function! ToggleBackground()
if &background == "light"
set background=dark
else
set background=light
endif
endfunction