-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinit.vim
196 lines (159 loc) · 5.54 KB
/
init.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
function! HTry(function, ...)
if exists('*'.a:function)
return call(a:function, a:000)
else
return ''
endif
endfunction
"optional plugins
"
packadd vim-lsp
packadd copilot.vim
let g:copilot_filetypes = {
\ 'gitcommit': v:true,
\ 'markdown': v:true,
\ 'yaml': v:true,
\ 'ruby': v:true,
\ 'javascript': v:true
\ }
filetype plugin indent on
if executable('standardrb')
au User lsp_setup call lsp#register_server({
\ 'name': 'standardrb',
\ 'cmd': ['standardrb', '--lsp'],
\ 'allowlist': ['ruby'],
\ })
endif
" Settings
set nocompatible
set autoindent
set autoread
set backspace=indent,eol,start
set complete-=i " Searching includes can be slow
set display=lastline " When lines are cropped at the screen bottom, show as much as possible
set incsearch
set laststatus=2 " Always show status line
set listchars=tab:>\ ,trail:-,extends:>,precedes:<,nbsp:+
set list " show trailing whiteshace and tabs
set modelines=5
set scrolloff=1
set sidescrolloff=5
set showcmd
set showmatch
set smarttab
if &statusline == ''
set statusline=[%n]\ %<%.99f\ %h%w%m%r%{HTry('CapsLockStatusline')}%y%{HTry('rails#statusline')}%{HTry('fugitive#statusline')}%#ErrorMsg#%{HTry('SyntasticStatuslineFlag')}%*%=%-16(\ %l,%c-%v\ %)%P
endif
set ttimeoutlen=50 " Make Esc work faster
set wildmenu
set rtp+=/opt/homebrew/opt/fzf
let g:netrw_dirhistmax = 0
" Spacemacs ruined me...
let mapleader="\<Space>"
command! -bar -nargs=* -bang W :write<bang> <args>
command! -bar -range=% Trim :<line1>,<line2>s/\s\+$//e
nnoremap Y y$
nnoremap <CR> :noh<CR><CR>
" Emacs style mappings
inoremap <C-A> <C-O>^
cnoremap <C-A> <Home>
" Enable TAB indent and SHIFT-TAB unindent
vnoremap <silent> <TAB> >gv
vnoremap <silent> <S-TAB> <gv
augroup vimrc
autocmd!
autocmd GuiEnter * set guifont=Hack:h16 guioptions-=T columns=120 lines=70 number
augroup END
function! s:on_lsp_buffer_enabled() abort
setlocal omnifunc=lsp#complete
setlocal signcolumn=yes
if exists('+tagfunc') | setlocal tagfunc=lsp#tagfunc | endif
nmap <buffer> gd <plug>(lsp-definition)
nmap <buffer> gs <plug>(lsp-document-symbol-search)
nmap <buffer> gS <plug>(lsp-workspace-symbol-search)
nmap <buffer> gr <plug>(lsp-references)
nmap <buffer> gi <plug>(lsp-implementation)
nmap <buffer> gt <plug>(lsp-type-definition)
nmap <buffer> <leader>rn <plug>(lsp-rename)
nmap <buffer> [g <plug>(lsp-previous-diagnostic)
nmap <buffer> ]g <plug>(lsp-next-diagnostic)
nmap <buffer> K <plug>(lsp-hover)
let g:lsp_format_sync_timeout = 1000
autocmd! BufWritePre *.rs,*.go, *.rb call execute('LspDocumentFormatSync')
" refer to doc to add more commands
endfunction
augroup lsp_install
au!
" call s:on_lsp_buffer_enabled only for languages that has the server registered.
autocmd User lsp_buffer_enabled call s:on_lsp_buffer_enabled()
augroup END
augroup file_type_settings
autocmd!
autocmd BufRead,BufNewFile *.hamlc setlocal filetype=haml
autocmd FileType go setlocal shiftwidth=4 tabstop=4 expandtab
autocmd FileType handlebars setlocal shiftwidth=2 tabstop=2 expandtab
autocmd FileType asm setlocal shiftwidth=8 tabstop=8 expandtab
autocmd BufNewFile,BufRead *.haml set ft=haml
autocmd FileType javascript setlocal et sw=2 sts=2 isk+=$
autocmd FileType html,xhtml,css,scss setlocal et sw=2 sts=2
autocmd FileType eruby,yaml,ruby setlocal et sw=2 sts=2 omnifunc=rubycomplete#Complete
autocmd FileType cucumber setlocal et sw=2 sts=2
autocmd FileType gitcommit setlocal spell
autocmd FileType ruby setlocal comments=:#\ tw=79
autocmd FileType vim setlocal et sw=2 sts=2 keywordprg=:help
autocmd FileType sql setlocal et sw=2 sts=2
autocmd Syntax css syn sync minlines=50
augroup END
" Rails/Rspec/Ruby
"augroup rails_commands
"autocmd!
"autocmd User Rails nnoremap <buffer> <D-r> :<C-U>Rake<CR>
"autocmd User Rails nnoremap <buffer> <D-R> :<C-U>.Rake<CR>
"augroup END
au FileType rust nmap gd <Plug>(rust-def)
au FileType rust nmap gs <Plug>(rust-def-split)
au FileType rust nmap gx <Plug>(rust-def-vertical)
au FileType rust nmap <leader>gd <Plug>(rust-doc)
let g:racer_experimental_completer = 1
map <Leader>s :Ggrep <C-R><C-W><CR>
let g:rspec_command = "Dispatch spring rspec {spec}"
" Plugin settings / Custom Mappings
" Commenting out with NERDCommenter
nmap \\ <Plug>NERDCommenterInvert
xmap \\ <Plug>NERDCommenterInvert
" split join
let g:splitjoin_ruby_hanging_args=0
let g:splitjoin_ruby_curly_braces=0
map <leader>] :bnext<CR>
map <leader>[ :bprevious<CR>
map <leader>t :FZF<CR>
map <leader>pf :FZF<CR>
map <leader>/ :Ag<CR>
imap dt5 <!DOCTYPE html>
" Open my vimrc like I would open my .spacemacs config
" Like I said, spacemacs ruined me ;)
nnoremap <leader>fed :vsplit $MYVIMRC<cr>
nnoremap <leader>fer :source $MYVIMRC<cr>
nnoremap <leader>feR :source $MYVIMRC<cr>
nnoremap <leader>; :
inoremap ;; <esc>:
noremap ,s :source ~/.vimrc.local
" Colors / UI
if has("termguicolors")
set termguicolors
endif
set number
colorscheme nova
set background=dark
if $TERM == '^\%(screen\|xterm-color\)$' && t_Co == 8
set t_Co=16
endif
if &term =~ '256color'
"disable Background Color Erase (BCE) so that color schemes
"render properly when inside 256-color tmux and GNU screen.
"see also http://snk.tuxfamily.org/log/vim-256color-bce.html
set t_ut=
endif
" I mispell things a lot:
iabbrev fundemental fundamental
iabbrev Fundemental Fundamental