caio.co/de/vim-runtime


Map :ALEDetail to <leader>D 💬 by Caio 4 years ago (log)
`rustc` and `clippy` often give good advice on diagnostics, so I've
been reaching to `:ALEDetail` very often over the past few months

Blob 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
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
set nocompatible
filetype off
let mapleader=','

" {{{ Plug
call plug#begin('~/.vim/plugged')

Plug 'arcticicestudio/nord-vim'
Plug 'rust-lang/rust.vim'
Plug 'tpope/vim-commentary'
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-git'
Plug 'tpope/vim-markdown'
Plug 'tpope/vim-repeat'
Plug 'tpope/vim-surround'
Plug 'cohama/lexima.vim'

let g:indentLine_char_list = ['|', '¦', '┆', '┊']
Plug 'Yggdroot/indentLine'

let g:ale_sign_error = 'E'
let g:ale_sign_warning = 'W'
let g:ale_set_highlights = 1
let g:ale_lint_on_enter = 0
Plug 'dense-analysis/ale'

nmap <silent> [c <Plug>(ale_previous_wrap)
nmap <silent> ]c <Plug>(ale_next_wrap)
nmap <silent> [C <Plug>(ale_previous_wrap_error)
nmap <silent> ]C <Plug>(ale_next_wrap_error)
nmap <silent> <leader>D :ALEDetail<CR>

if executable("node")
    Plug 'neoclide/coc.nvim', {'branch': 'release'}
    let g:coc_start_at_startup = 0

    function! s:show_documentation()
        if (index(['vim','help'], &filetype) >= 0)
            execute 'h '.expand('<cword>')
        else
            call CocAction('doHover')
        endif
    endfunction

    function! s:start_coc()
        set updatetime=300

        nmap <silent> gd <Plug>(coc-definition)
        nmap <silent> gr <Plug>(coc-references)

        nmap <leader>rn <Plug>(coc-rename)
        nmap <leader>ac <Plug>(coc-codeaction)

        nnoremap <silent><leader>t :<C-u>CocList -I symbols<cr>
        nnoremap <silent><leader>d :<C-u>CocList diagnostics<cr>
        nnoremap <silent> K :call <SID>show_documentation()<CR>

        " Highlight symbol under cursor on CursorHold
        autocmd CursorHold * silent call CocActionAsync('highlight')

        call coc#rpc#start_server()
    endfunction

    command! -nargs=0 IDE :call s:start_coc()
endif

set ttimeoutlen=50
let g:airline_left_sep=''
let g:airline_right_sep=''
let g:airline_detect_modified=1
let g:airline_detect_paste=1
let g:airline_inactive_collapse=1
let g:airline#extensions#whitespace#enabled = 1
let g:airline#extensions#whitespace#symbol = 'WS'
let g:airline#extensions#whitespace#show_message = 0
let g:airline#extensions#branch#enabled = 0
let g:airline_theme='nord'
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'

Plug 'fatih/vim-go', { 'for': 'go' }
let g:go_highlight_functions = 1
let g:go_highlight_methods = 1
let g:go_highlight_structs = 1
let g:go_highlight_operators = 1
let g:go_highlight_build_constraints = 1
let g:go_fmt_command = "goimports"

function! s:relative_gfiles()
    let gitdir = FugitiveGitDir()
    if len(gitdir)
        let gitdir = substitute(gitdir, "/.git", "", "")
        let curdir = getcwd()

        if curdir == gitdir
            execute ":GFiles"
        else
            let relative_dir = substitute(curdir, gitdir . "/", "", "")
            execute ":GFiles -- " . relative_dir
        endif
    else
        :Files
    endif
endfunction

" GFilesRelative:
" * Outside of a git repo: `:Files`
" * In the root of a git repo: `:Gfiles`
" * In a subtree of a git repo: `:Gfiles -- subtree`
command! -nargs=0 GFilesRelative :call s:relative_gfiles()


let g:fzf_buffers_jump = 1
let g:fzf_preview_window = ''
imap <c-x><c-f> <plug>(fzf-complete-path)
nmap <silent><leader>f :GFilesRelative<CR>
nmap <silent><leader>F :GFiles<CR>
nmap <silent><leader>b :Buffers<CR>
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --bin' }
Plug 'junegunn/fzf.vim'


Plug 'vim-scripts/YankRing.vim'
nmap <leader>p :YRShow<CR>
let g:yankring_history_file='.yankring_history'

let g:RenamerSupportColonWToRename=1
let g:RenamerWildIgnoreSetting=''
Plug 'qpkorr/vim-renamer'

" Zen mode
Plug 'junegunn/goyo.vim'
let g:goyo_width = "55%"
nmap <silent><leader>z :Goyo<CR>

call plug#end()
" }}}

" {{{ Settings
filetype plugin indent on
syntax enable
scriptencoding utf-8

set mouse-=a
set nowrap
set shortmess=at
set showcmd
set showmatch
"set matchpairs+=<:>
set hlsearch
set incsearch
set ignorecase
set smartcase
set gdefault
set showfulltag
set suffixes+=.in,.a
set hidden
set scrolloff=3
set shiftwidth=4
set textwidth=79
set formatoptions=qrn1
set tabstop=8
set smarttab
set expandtab
set softtabstop=4
set autoindent
set nonumber
set viminfo='1000,f1,<500,:1000,/1000,h
set history=500
set backspace=indent,eol,start
set backup
set backupdir=./.backup,/tmp,.
set directory=.,./.backup,/tmp
set nolazyredraw
set noswapfile
set title
set noerrorbells
set novisualbell
set completeopt=menu,menuone,noinsert,noselect,preview
" reducing noise
set more
set cmdheight=1
set tags=tags;/
" reload file if not modified by this editor instance
set autoread
set fillchars=vert:┃
set showbreak=↪
set virtualedit+=block
set shiftround
set laststatus=2

set foldmethod=marker
set foldlevelstart=0

set undofile
set undodir=/tmp,.,~/
autocmd BufWritePre /tmp/* setlocal noundofile

" List trailing chars
set list
set listchars=tab:▸\ ,trail:·,precedes:…,extends:…,nbsp:‗

set wildmenu
set wildmode=list:longest
set wildignore+=.hg,.git,.svn
set wildignore+=*.aux,*.out,*.toc
set wildignore+=*.jpg,*.bmp,*.gif,*.png,*.jpeg
set wildignore+=*.o,*.obj,*.exe,*.dll,*.manifest
set wildignore+=*.spl
set wildignore+=*.sw?
set wildignore+=*.DS_Store
set wildignore+=*.luac
set wildignore+=*.pyc
set wildignore+=*.class,*.jar

" Appearance
set background=dark
set cursorline
colorscheme nord

" Don't reset the column when paging
set nostartofline
" }}}


" {{{ Mappings
inoremap <F1> <ESC>
nnoremap <F1> <ESC>
vnoremap <F1> <ESC>
inoremap jj <ESC>
nmap <silent><leader>m :bp<CR>
nmap <silent><leader>n :bn<CR>
nnoremap <silent><leader><Space> :nohlsearch<CR>
nnoremap <Space> za
vnoremap <Space> za
nnoremap ' `
nnoremap ` '

" Re-select block after (de)indent
vnoremap < <gv
vnoremap > >gv

" Spell shortcuts
nmap <leader>se :setlocal spell! spelllang=en<CR>
nmap <leader>sp :setlocal spell! spelllang=pt_br<CR>

" Better navigation when 'wrap' is on
nmap k gk
nmap <Up> gk
nmap j gj
nmap <Down> gj

" Write with sudo using w!!
cmap w!! w !sudo tee % &>/dev/null

" fish is not posix
if $SHELL =~ 'bin/fish'
    set shell=/usr/bin/bash
endif

" Better/Faster window handling
nnoremap <C-h> <C-w>h
nnoremap <C-j> <C-w>j
nnoremap <C-k> <C-w>k
nnoremap <C-l> <C-w>l
" }}}

let g:netrw_sizestyle="h"
let g:netrw_banner=0
let g:netrw_list_style=3
let g:netrw_list_hide = '\(^\|\s\s\)\zs\.\S\+'

" Matchit plugin
runtime macros/matchit.vim

" Close the preview window automatically
autocmd CursorMovedI * if pumvisible() == 0|pclose|endif
autocmd InsertLeave * if pumvisible() == 0|pclose|endif

" Move to last cursor position
au BufReadPost * if line("'\"") > 0|if line("'\"") <= line("$")|exe("norm '\"")|else|exe "norm $"|endif|endif

" Source local (unversioned) configuration file
if filereadable(expand("~/.vimrc.local"))
  source ~/.vimrc.local
endif

" vim: set ts=4 sw=4 tw=79: