-
Notifications
You must be signed in to change notification settings - Fork 0
/
.vimrc
executable file
·155 lines (122 loc) · 4.14 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
" Minimalist VIm configuration
" Author: Ben Johnson
" Created March 2019
" Updated December 2019
" ~~~ Plugin setup ~~~
" Plugins directory:
call plug#begin('~/.vim/plugged')
" Fuzzy file finder
Plug 'junegunn/fzf'
Plug 'junegunn/fzf.vim'
" Find-in-folder
Plug 'mileszs/ack.vim'
" Language server protocol/lint tool
Plug 'w0rp/ale'
" Better status line
Plug 'itchyny/lightline.vim'
" Show simple git diff info in side gutter
Plug 'airblade/vim-gitgutter'
" Syntax highlighting for all languages!
" Especially awesome, as it only loads in relevant configuration to open
" file(s)
Plug 'sheerun/vim-polyglot'
" Color theme
Plug 'crusoexia/vim-monokai'
" Simple .git blame
Plug 'zivyangll/git-blame.vim'
" File system explorer
Plug 'preservim/nerdtree'
Plug 'rust-lang/rust.vim'
" Autocompletion
if has('nvim')
Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
else
Plug 'Shougo/deoplete.nvim'
Plug 'roxma/nvim-yarp'
Plug 'roxma/vim-hug-neovim-rpc'
endif
" Use deoplete for auto-complete.
let g:deoplete#enable_at_startup = 1
" Initialize plugin system
call plug#end()
" ~~~ End plugin setup
" Rust formatting preferences:
let g:rustfmt_autosave = 1
let g:rustfmt_emit_files = 1
let g:rustfmt_fail_silently = 0
" Show line numbers by default!
:set number
" Key binding for the .git blame plugin (\s)
nnoremap <Leader>s :<C-u>call gitblame#echo()<CR>
" Syntax highlighting for flow.js! (disabled by default)
let g:javascript_plugin_flow = 1
" Allegedly, TypeScript doesn't play nice with the old regex engine
" Set it to automatically choose an engine
:set re=0
" Asynchronous Lint Engine (ALE)
" Limit linters used for JavaScript.
let g:ale_linters = {
\ 'javascript': ['eslint'],
\ 'rust': ['analyzer'],
\ 'typescript': ['tsserver']
\}
highlight clear ALEErrorSign " otherwise uses error bg color (typically red)
highlight clear ALEWarningSign " otherwise uses error bg color (typically red)
let g:ale_sign_error = 'X' " could use emoji
let g:ale_sign_warning = '?' " could use emoji
let g:ale_statusline_format = ['X %d', '? %d', '']
" %linter% is the name of the linter that provided the message
" %s is the error or warning message
let g:ale_echo_msg_format = '%linter% says %s'
" Map keys to navigate between lines with errors and warnings.
nnoremap <leader>an :ALENextWrap<cr>
nnoremap <leader>ap :ALEPreviousWrap<cr>
" Get type under cursor
nnoremap <leader>ag :ALEGoToDefinition<cr>
" Use ripgrep as default search engine for Ack.vim
let g:ackprg = 'rg --vimgrep --no-heading'
" Bind ack-vim to ctrl+f, don't auto-open results (! modifier)
nmap <C-f> :Ack!<space>
" Use ripgrep as default search engine for fzf!
" --files: List files that would be searched but do not search
" --no-ignore: Do not respect .gitignore, etc...
" --hidden: Search hidden files and folders
" --follow: Follow symlinks
" --glob: Additional conditions for search (in this case ignore everything in the .git/ folder)
let $FZF_DEFAULT_COMMAND='rg --files --hidden --follow --glob "!.git/*"'
" Use ctrl+p to open fzf (not the default :Files command)
nnoremap <silent> <C-p> :FZF -m<cr>
" Font stuff:
set guifont=Fira\ Code\ Retina:h12
" Monokai theme
syntax on
colorscheme monokai
set termguicolors
" Tab key -> 2 spaces
set tabstop=4 softtabstop=0 expandtab shiftwidth=2 smarttab
" git-gutter: faster git updates (default is 4000ms)
set updatetime=200
" prevent vim from wrapping words
set nowrap
" For some reason this is necessary for lightline to render?
set laststatus=2
" Show relative file path of open file in lightline!
let g:lightline = {
\ 'component_function': {
\ 'filename': 'LightLineFilename'
\ }
\ }
function! LightLineFilename()
return expand('%')
endfunction
" NERDTree: File system explorer!
" Start NERDTree when Vim is started without file arguments.
autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter * if argc() == 0 && !exists('s:std_in') | NERDTree | endif
" Show hidden files
let NERDTreeShowHidden=1
" Un-comment this section if you'd like to use OCAML and have things set up
" locally
" Support for OCAML's Merlin tooling
" let g:opamshare = substitute(system('opam var share'),'\n$','','''')
" execute "set rtp+=" . g:opamshare . "/merlin/vim"