-
Notifications
You must be signed in to change notification settings - Fork 0
/
canonrc.vim
202 lines (160 loc) · 4.04 KB
/
canonrc.vim
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
set nocompatible
filetype off
call plug#begin()
Plug 'ctrlpvim/ctrlp.vim'
Plug 'ervandew/supertab'
Plug 'flazz/vim-colorschemes'
Plug 'jremmen/vim-ripgrep'
Plug 'sheerun/vim-polyglot'
Plug 'scrooloose/nerdtree'
Plug 'tpope/vim-commentary'
Plug 'tpope/vim-fugitive'
Plug 'w0rp/ale'
call plug#end()
filetype plugin indent on
runtime ftplugin/man.vim
" Spell checking
set spelllang=en
" Backup files are annoying
set nobackup
set nowritebackup
set noswapfile
" history
set history=700
" Vim recommended
if has('autocmd')
filetype plugin indent on
endif
if has('syntax') && !exists('g:syntax_on')
syntax enable
endif
set synmaxcol=9999
set hidden " Allows you to switch buffers without saving current
set wildmenu
set wildmode=longest:full,full " First tab brings up options, second tab cycles
set encoding=utf8
" Movement
let mapleader = ","
set tm=2000
noremap ,, ,
" treat wrapped lines as different lines
nnoremap j gj
nnoremap k gk
" Set 7 lines to the cursor - when moving vertically using j/k
set so=7
" Always show current position
set ruler
" Playing around with having these off
set number
" set cursorcolumn
" set cursorline
" Remove bell
set visualbell
set t_vb=
" Better searching
set incsearch
set ignorecase
set smartcase
set wrapscan "wraps around end of file
" Redraw screen and clear highlighting
nnoremap <Leader>r :nohl<CR><C-L>
" Don't redraw while executing macros
set lazyredraw
" tabs
set expandtab
set smarttab
" show whitespace
set list
" Show whitespace
if &listchars ==# 'eol:$'
set listchars=tab:>\ ,trail:-,extends:>,precedes:<,nbsp:+
endif
" nowrap
set nowrap
" Show matching bracket
set showmatch
set matchtime=2
set shiftwidth=2
set tabstop=2
" Configure backspace so it acts as it should act
set backspace=eol,start,indent
set whichwrap+=<,>,h,l
" Return to last edit position when opening files
augroup last_edit
autocmd!
autocmd BufReadPost *
\ if line("'\"") > 0 && line("'\"") <= line("$") |
\ exe "normal! g`\"" |
\ endif
augroup END
" previous buffer, next buffer
nnoremap <leader>bp :bp<cr>
nnoremap <leader>bn :bn<cr>
" Close nerdtree after a file is selected
let NERDTreeQuitOnOpen = 1
function! IsNERDTreeOpen()
return exists("t:NERDTreeBufName") && (bufwinnr(t:NERDTreeBufName) != -1)
endfunction
function! ToggleFindNerd()
if IsNERDTreeOpen()
exec ':NERDTreeToggle'
else
exec ':NERDTreeFind'
endif
endfunction
function! Json()
:%!jq --sort-keys .
endfunction
" CtrlP using ripgrep
if executable('rg')
set grepprg=rg\ --color=never
let g:ctrlp_user_command = 'rg %s --files --color=never --glob ""'
let g:ctrlp_use_caching = 0
endif
" If nerd tree is closed, find current file, if open, close it
nmap <silent> <leader>f <ESC>:call ToggleFindNerd()<CR>
nmap <silent> <leader>F <ESC>:NERDTreeToggle<CR>
" set termguicolors
set background=light
colorscheme dim
" set background=light
" highlight VertSplit guifg=#252a33 guibg=#d7dbe2
set statusline=%f\ %h%w%m%r\ %=%(%l,%c%V\ %=\ %P%)
function! ClearWhitespace()
%s/\s\+$//e
endfunction
function! Lambda()
%s/lambda/λ/ge
endfunction
nnoremap <Leader>W :call ClearWhitespace()<CR>
nnoremap <Leader>L :call Lambda()<CR>
nmap <silent> <C-k> <Plug>(ale_previous_wrap)
nmap <silent> <C-j> <Plug>(ale_next_wrap)
nmap <silent> <C-l> :tabn<CR>
nmap <silent> <C-h> :tabp<CR>
" Pane movement/organization
noremap <Leader>h <C-W>h
noremap <Leader>j <C-W>j
noremap <Leader>k <C-W>k
noremap <Leader>l <C-W>l
noremap <Leader>H <C-W>H
noremap <Leader>J <C-W>J
noremap <Leader>K <C-W>K
noremap <Leader>L <C-W>L
" Resize panes
noremap <Leader>a :vertical resize -10<CR>
noremap <Leader>d :vertical resize +10<CR>
noremap <Leader>s :resize -10<CR>
noremap <Leader>w :resize +10<CR>
" Page left and right
nnoremap <C-L> 40zl
nnoremap <C-H> 40zh
" Ale syntax checking
" java
" let g:ale_java_checkstyle_options = '-c ~/.checkstyle.xml'
" rust
let g:ale_rust_cargo_use_check = 1
" Save battery by only running on saving/entering files
let g:ale_lint_on_text_changed = 'never'
" Put fixers in ftplugin, i.e, let b:ale_fixers = ['scalafmt']
nnoremap <leader>o :ALEFix<CR>