-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvimrc
257 lines (223 loc) · 6.93 KB
/
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
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
248
249
250
251
252
253
254
255
256
257
set nocompatible
syntax on
filetype plugin indent on
colors zenburn
let hostname = substitute(system("hostname"), "\n", "", "")
set backupdir=~/.vim-tmp,~/.tmp,~/tmp,/var/tmp,/tmp
set directory=~/.vim-tmp,~/.tmp,~/tmp,/var/tmp,/tmp
set nobackup
set noswapfile
set ruler
set rulerformat=%=%h%m%r%w\ %(%c%V%),%l/%L\ %P
set autoindent
set autoread
set backspace=indent,eol,start
" set clipboard=unamedplus,unnamed,autoselect
set expandtab
set fileformat=unix
set fileformats=unix,dos
set formatoptions-=t
set hidden
set history=1000
set hlsearch
set incsearch
set ignorecase smartcase
set laststatus=2
set modeline
set modelines=3
set nofixendofline
set noruler
set nowb
set number
" set relativenumber
set scrolloff=3
set shiftwidth=2
set showcmd
set showmode
set smartcase
set smartindent
set smarttab
set softtabstop=2
set t_ti= t_te=
set tabstop=2
set title
set ttyfast
set tw=79
set visualbell
set wildmenu
set wildmode=list:longest
augroup spellcheck
autocmd!
autocmd FileType markdown,org,text setlocal spell spelllang=en_gb
augroup END
nmap <silent> <leader>s :set nolist!<CR>
exe "set rtp+=" . $BREW_PREFIX . "/opt/fzf"
nnoremap ' `
nnoremap ` '
nnoremap <C-e> 3<C-e>
nnoremap <C-y> 3<C-y>
let mapleader = ","
let maplocalleader="\<space>"
inoremap jj <ESC>
nnoremap <Leader>d :Git diff<CR>
nnoremap <Leader>D :Gdiffsplit<CR>
nnoremap <Leader>p :r !pbpaste<CR>
nnoremap <Leader>g :Rg<CR>
nnoremap <Leader>S :StripWhitespace<CR>
nnoremap <Leader>v :vsp<CR>
nnoremap <Leader>w :w<CR>
nnoremap <Leader>m :Snippets<CR>
"Unset "last search pattern" register by hitting return.
nnoremap <CR> :noh<CR><CR>
" Copy to system clipboard
vmap <Leader>y "+y
vmap <Leader>d "+d
nmap <Leader>p "+p
nmap <Leader>P "+P
vmap <Leader>p "+p
vmap <Leader>P "+P
vnoremap <silent> y y`]
vnoremap <silent> p p`]
nnoremap <silent> p p`]
" Reformat JSON block
" :%!python -m json.tool
runtime macros/matchit.vim
set t_Co=256
set background=dark
set statusline=[%n]\ %<%F\ \ \ %m%r%h%w%y[%{strlen(&fenc)?&fenc:'none'},%{&ff}]\
set statusline+=\ \ %=\ line:%l/%L\ col:%c\ \ \ %p%%\ \ \ %{strftime(\"%H:%M\ \")}
" Highlight lines breaking column 80 on a per-line basis.
highlight ColorColumn ctermfg=208 ctermbg=Black
function! MarkMargin (on)
if exists('b:MarkMargin')
try
call matchdelete(b:MarkMargin)
catch /./
endtry
unlet b:MarkMargin
endif
if a:on
let b:MarkMargin = matchadd('ColorColumn', '\%81v\s*\S', 100)
endif
endfunction
augroup MarkMargin
autocmd!
autocmd BufEnter * :call MarkMargin(1)
autocmd BufEnter *.vp* :call MarkMargin(0)
augroup END
" File navigation
nnoremap ; :Buffers<CR>
nnoremap <Leader>h :Files<CR>
nnoremap <Leader>j :GFiles<CR>
nnoremap <Leader>f :GFiles?<CR>
nnoremap <Leader>b :Buffers<CR>
nnoremap <Leader>L :noh<CR>
" let s:project = system('git rev-parse --show-toplevel')
" let s:todo = "TODO.org"
" let s:path = s:project . "/" . s:todo
nnoremap <Leader>t :e ./TODO.org<CR>
" Formatting
let g:rustfmt_autosave = 1
let g:splitjoin_python_brackets_on_separate_lines = 1
autocmd FileType nix setlocal commentstring=#\ %s
autocmd FileType yaml setlocal ts=2 sts=2 sw=2 expandtab
autocmd FileType markdown setlocal ts=2 sts=2 sw=2 expandtab
autocmd FileType vue syntax sync fromstart
autocmd FileType vue setlocal commentstring=//\ %s
" ALE
let g:ale_lint_on_enter = 1
let g:ale_lint_on_save = 1
let g:ale_lint_on_text_changed = 'never'
let g:ale_fix_on_save = 1
let g:ale_virtualenv_dir_names = ['venv', '.venv']
let g:ale_virtualtext_cursor = 0
let g:ale_linter_aliases = {
\ 'svelte': ['javascript', 'typescript'],
\ 'vue': ['javascript', 'typescript']
\}
let g:ale_linters = {
\ 'javascript': ['eslint'],
\ 'typescript': ['eslint', 'tsserver'],
\ 'python': ['mypy', 'ruff'],
\ 'rust': ['analyzer', 'cargo', 'cspell', 'rls'],
\ 'terraform': ['terraform', 'tflint'],
\}
let g:ale_fixers = {
\ '*': ['remove_trailing_lines', 'trim_whitespace'],
\ 'javascript': ['prettier', 'eslint'],
\ 'typescript': ['prettier', 'eslint'],
\ 'vue': ['prettier', 'eslint'],
\ 'python': ['isort', 'ruff', 'ruff_format'],
\ 'rust': ['rustfmt'],
\ 'svelte': ['prettier', 'eslint'],
\ 'terraform': ['terraform'],
\}
" TODO: This is all far from ideal but does the job for now.
let mypy_config = trim(system('gfind ~+ -maxdepth 2 -type f -name pyproject.toml'))
let g:ale_python_mypy_options = '--config=' . mypy_config
let g:ale_rust_rls_toolchain = 'nightly'
let rustfmt_config = trim(system('gfind ~+ -maxdepth 2 -type f -name rustfmt.toml'))
let g:ale_rust_rustfmt_options = '--edition 2018 --config-path=' . rustfmt_config
let stubs = trim(system('gfind ~+ -maxdepth 2 -type d -name stubs ! -path "*venv*"'))
let $MYPYPATH=stubs
nnoremap <Leader>l :ALEFix<CR>
" Hardtime
let g:hardtime_default_on = 1
" Org
let g:org_indent = 0
autocmd FileType org setlocal shiftwidth=2 tabstop=2
" Mu-complete
set belloff+=ctrlg
set completeopt+=menuone
set completeopt+=noselect
set shortmess+=c
let g:mucomplete#completion_delay = 1
" Cursor shapes per mode.
if empty($TMUX)
let &t_SI = "\<Esc>]50;CursorShape=1\x7"
let &t_EI = "\<Esc>]50;CursorShape=0\x7"
let &t_SR = "\<Esc>]50;CursorShape=2\x7"
else
let &t_SI = "\e[5 q"
let &t_SR = "\e[4 q"
let &t_EI = "\e[1 q"
endif
" SuperCollider
" ,b -> Start server.
" ,o -> Run line of code.
" ,i -> Run block of code.
" ,k -> Kill the server completely.
" ,. -> Hard stop.
" K -> Open help file.
" ^] -> Jump to tagfile.
let g:scTerminalBuffer="on"
let g:scSplitDirection="v"
let g:scSplitSize = '50%'
au BufEnter,BufWinEnter,BufNewFile,BufRead *.sc,*.scd set filetype=supercollider
au Filetype supercollider packadd scvim
au Filetype supercollider nnoremap <leader>b :call SClangStart()<CR>
au Filetype supercollider inoremap <leader>b :call SClangStart()<CR>
au Filetype supercollider vnoremap <leader>b :call SClangStart()<CR>
au Filetype supercollider nnoremap <leader>o :call SClang_line()<CR>
au Filetype supercollider inoremap <leader>o :call SClang_line()<CR>
au Filetype supercollider vnoremap <leader>o :call SClang_line()<CR>
au Filetype supercollider nnoremap <leader>i :call SClang_block()<CR>
au Filetype supercollider inoremap <leader>i :call SClang_block()<CR>
au Filetype supercollider vnoremap <leader>i :call SClang_block()<CR>
au Filetype supercollider nnoremap <leader>. :call SClangHardstop()<CR>
au Filetype supercollider inoremap <leader>. :call SClangHardstop()<CR>
au Filetype supercollider vnoremap <leader>. :call SClangHardstop()<CR>
au Filetype supercollider nnoremap <leader>k :call SClangKill()<CR>
au Filetype supercollider inoremap <leader>k :call SClangKill()<CR>
au Filetype supercollider vnoremap <leader>k :call SClangKill()<CR>
" Ultisnips
let g:UltiSnipsExpandTrigger = '<c-j>'
" let g:UltiSnipsJumpForwardTrigger = '<c-b>'
" let g:UltiSnipsJumpBackwardTrigger = '<c-z
" UTL
let g:utl_cfg_hdl_scm_http_system = "silent !firefox %u &"
" UUID
function InsertUUID()
r !uuidgen | sed "s/.*/&/" | tr "[A-Z]" "[a-z]"
endfunction
nnoremap <Leader>u :call InsertUUID()<CR>