/
local.vim
273 lines (224 loc) · 6.57 KB
/
local.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
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
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
call plug#begin('~/.vim/plugged')
" Search and navigation
Plug 'mileszs/ack.vim'
Plug 'ctrlpvim/ctrlp.vim'
Plug 'scrooloose/nerdtree'
Plug 'mattesgroeger/vim-bookmarks'
" Utility
Plug 'tpope/vim-surround'
Plug 'tpope/vim-speeddating'
Plug 'tpope/vim-endwise'
Plug 'mattn/calendar-vim'
" Org and documentation
Plug 'jceb/vim-orgmode'
Plug 'vimwiki/vimwiki'
" Git
Plug 'tpope/vim-fugitive'
Plug 'tommcdo/vim-fugitive-blame-ext'
" Statusline
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
" Colors
Plug 'altercation/vim-colors-solarized'
Plug 'arcticicestudio/nord-vim'
Plug 'jnurmine/Zenburn'
Plug 'morhetz/gruvbox'
Plug 'tjammer/blayu.vim'
Plug 'vim-scripts/autumnleaf_modified.vim'
Plug 'vim-scripts/summerfruit256.vim'
Plug 'chrisbra/Colorizer'
" Language server integration and error checking
Plug 'autozimu/LanguageClient-neovim', {
\ 'branch': 'next',
\ 'do': 'bash install.sh',
\ }
Plug 'dense-analysis/ale'
" Ctags
Plug 'majutsushi/tagbar'
" Go
Plug 'fatih/vim-go'
" Python
Plug 'vim-python/python-syntax'
" Ocaml and ReasonML
Plug 'reasonml-editor/vim-reason-plus'
" Rust
Plug 'rust-lang/rust.vim'
" Zig
Plug 'ziglang/zig.vim'
" JS/TS/JSX etc.
Plug 'leafgarland/typescript-vim'
Plug 'peitalin/vim-jsx-typescript'
" Lisp/Clojure/Racket etc.
Plug 'tpope/vim-fireplace'
Plug 'vim-scripts/paredit.vim'
Plug 'venantius/vim-cljfmt'
Plug 'bakpakin/janet.vim'
" Completion
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
Plug 'deoplete-plugins/deoplete-go'
call plug#end()
" Background color fix for kitty terminal emu
let &t_ut=''
set swapfile directory=~/.vim/tmp
set undofile undodir=~/.vim/tmp
set backup backupdir=~/.vim/tmp
filetype on
filetype plugin on
set nocompatible
set number
set hidden
set autowrite
set updatetime=500
set expandtab
set autoindent
set smartindent
set hlsearch
set laststatus=2
set ignorecase
set smartcase
set backspace=indent,eol,start
set list
set listchars=tab:»\ ,extends:❯,precedes:❮,trail:.,nbsp:.
set ts=2 sw=2 sts=2 expandtab
" Colors
set termguicolors
if hostname() == "saraswati"
set background=light
colorscheme gruvbox
else
set background=dark
colorscheme zenburn
endif
" GUI vim
if has("gui_running")
set go-=T
set go-=m
set go-=r
set go-=R
set go-=l
set go-=L
set go+=c
set visualbell t_vb=
set guifont=Source\ Code\ Pro\ 11
endif
" Neovim
if has("nvim")
:tnoremap <Esc> <C-\><C-n>
endif
if has("autocmd")
" General
au FocusGained,BufEnter * :checktime
au FileType javascriptreact set filetype=javascript.jsx
au FileType typescriptreact set filetype=typescript.tsx
set autoread
endif
" Ack configuration
if executable('ag')
let g:ackprg = 'ag --vimgrep'
endif
" Ale configuration
let g:ale_fix_on_save = 1
" LanguageClient configuration
let g:LanguageClient_autoStart = 1
let g:LanguageClient_serverCommands = {
\ 'c': ['clangd'],
\ 'cpp': ['clangd'],
\ 'python': ['pyls'],
\ 'rust': ['rustup', 'run', 'stable', 'rls'],
\ 'ocaml': ['ocaml-language-server', '--stdio'],
\ 'reason': ['ocaml-language-server', '--stdio'],
\ 'javascript': ['typescript-language-server', '--stdio'],
\ 'javascript.jsx': ['typescript-language-server', '--stdio'],
\ 'typescript': ['typescript-language-server', '--stdio'],
\ 'typescript.tsx': ['typescript-language-server', '--stdio'],
\ }
function SetLSPShortcuts()
nnoremap gd :call LanguageClient#textDocument_definition()<CR>
nnoremap <leader>lr :call LanguageClient#textDocument_rename()<CR>
nnoremap <leader>lf :call LanguageClient#textDocument_formatting()<CR>
nnoremap <leader>lt :call LanguageClient#textDocument_typeDefinition()<CR>
nnoremap <leader>lx :call LanguageClient#textDocument_references()<CR>
nnoremap <leader>la :call LanguageClient_workspace_applyEdit()<CR>
nnoremap <leader>lc :call LanguageClient#textDocument_completion()<CR>
nnoremap <leader>lh :call LanguageClient#textDocument_hover()<CR>
nnoremap <leader>ls :call LanguageClient_textDocument_documentSymbol()<CR>
nnoremap <leader>lm :call LanguageClient_contextMenu()<CR>
endfunction()
augroup LSP
autocmd!
autocmd FileType typescript,javascript,typescript.tsx,javascript.jsx,rust,c,cpp,python,ocaml call SetLSPShortcuts()
augroup END
" Deoplete completion configuration
let g:deoplete#enable_at_startup = 1
call deoplete#custom#option('sources', {
\ '_': ['LanguageClient'],
\})
" Fuzzy search configuration
let g:ctrlp_extensions = ['line', 'dir']
let g:ctrlp_custom_ignore = { 'dir': '\v[\/](node_modules|\.git|target|dist)$' }
let g:ctrlp_mruf_relative = 1
set wildignore+=*/.git/*,*/.hg/*,*/.svn/*,*/node_modules/*
" Vim-bookmarks configuration
let g:bookmark_save_per_working_dir = 1
let g:bookmark_auto_save = 1
" Airline configuration
let g:airline_theme='zenburn'
let g:airline_inactive_collapse=1
let g:airline_symbols_ascii = 1
let g:airline_extensions = ['branch', 'languageclient', 'ctrlp']
" Show file name only instead of full path.
let g:airline_section_c = '%<%t%m%#__accent_red#%{airline#util#wrap(airline#parts#readonly(),0)}%#__restore__#'
" Hide file encoding/format section.
let g:airline_section_y = ''
" Show only column number in the rightmost regularly visible section.
let g:airline_section_z = '%3v'
let g:airline_mode_map = {
\ '__' : '-',
\ 'c' : 'C',
\ 'i' : 'I',
\ 'ic' : 'I',
\ 'ix' : 'I',
\ 'n' : 'N',
\ 'multi' : 'M',
\ 'ni' : 'N',
\ 'no' : 'N',
\ 'R' : 'R',
\ 'Rv' : 'R',
\ 's' : 'S',
\ 'S' : 'S',
\ '' : 'S',
\ 't' : 'T',
\ 'v' : 'V',
\ 'V' : 'V',
\ '' : 'V',
\ }
" Leader bindings
let mapleader = ";"
let maplocalleader = "\\"
nmap <leader>n :bn<cr>
nmap <leader>p :bp<cr>
nmap <leader>w :w<cr>
nmap <leader>d :bd<cr>
nmap <leader>b :CtrlPBuffer<cr>
nmap <leader>s :CtrlPMixed<cr>
nmap <leader>to :NERDTree<cr>
nmap <leader>tc :NERDTreeClose<cr>
nmap <leader>q :qa<cr>
nmap <leader>co :copen<cr>
nmap <leader>o :lopen<cr>
nmap <leader>m :marks<cr>
nmap <leader>a :Ack<Space>
nmap <leader>T :silent! lvimgrep /TODO\\|FIXME/ %<cr>:lopen<cr>
nmap <leader>tt :TagbarToggle<CR>
" Clear sign column (if signs left over by e.g. rls + LanguageClient).
nmap <leader>cl :sign unplace *<cr>
" Show syntax highlighting groups for the element under cursor
map <F10> :echo "hi<" . synIDattr(synID(line("."),col("."),1),"name") . '> trans<'
\ . synIDattr(synID(line("."),col("."),0),"name") . "> lo<"
\ . synIDattr(synIDtrans(synID(line("."),col("."),1)),"name") . ">"<CR>