~theothornhill/dotfiles

dotfiles/vim/vimrc -rw-r--r-- 6.5 KiB
57165df0Theodor Thornhill Create eglot-x.el 6 months ago
                                                                                
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
filetype plugin indent on
syntax on

if empty(glob('~/.vim/autoload/plug.vim'))
  silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
        \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
  autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif 

call plug#begin('~/.vim/bundle')
Plug 'jiangmiao/auto-pairs'
Plug 'guns/vim-sexp'
Plug 'tpope/vim-sexp-mappings-for-regular-people'
Plug 'tpope/vim-commentary'
Plug 'tpope/vim-repeat'
Plug 'tpope/vim-surround'
Plug 'morhetz/gruvbox'
Plug 'tpope/vim-markdown'
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
Plug 'junegunn/fzf.vim'
Plug 'joshdick/onedark.vim'
Plug 'vlime/vlime', {'rtp': 'vim/'}
" Plug 'kovisoft/slimv'
Plug 'neoclide/coc.nvim', { 'branch': 'release' }
Plug 'andys8/vim-elm-syntax'
Plug 'christoomey/vim-tmux-navigator'
call plug#end()

let g:markdown_fenced_languages = ['css', 'js=javascript']
" let g:slimv_swank_cmd = '! tmux new-window -d -n REPL-SBCL "sbcl --load ~/.vim/bundle/slimv/slime/start-swank.lisp"'

set termguicolors
set background=dark
colorscheme gruvbox
highlight Comment cterm=italic

set number
set relativenumber
set hidden
set nobackup
set nowritebackup
set nowrap linebreak
set shortmess+=c
set signcolumn=yes
set showcmd showmode showfulltag
set encoding=utf-8 fileencoding=utf-8
set backspace=indent,eol,start
set updatetime=300
set wildmenu
set wildmode=longest:full,full
set clipboard^=unnamed,unnamedplus
set incsearch nohlsearch
set expandtab softtabstop=4 shiftwidth=2
set textwidth=90
set laststatus=2
set fillchars+=vert:│
set completeopt=noinsert,menuone,preview
set noswapfile
autocmd CompleteDone * pclose
let g:netrw_banner=0
let g:netrw_winsize=15
let mapleader = " "
let maplocalleader = " "
inoremap fd <esc>
inoremap <c-e> <c-o>A
inoremap <c-f> <c-o>a
xnoremap fd <esc>

nnoremap <leader>f :Files<cr>
nnoremap <leader>b :Buffers<cr>
nnoremap <leader>r :Rg<cr>
nnoremap <leader>n :bn<cr>
nnoremap <leader>p :bp<cr>
nnoremap <leader>d :bd<cr>
nnoremap <leader>t :term<cr><c-w><c-r>
nnoremap ' `
nnoremap <leader>s !sbcl --load ~/.vim/bundle/vlime/lisp/start-vlime.lisp

nnoremap <c-h> <c-w><c-h>
nnoremap <c-j> <c-w><c-j>
nnoremap <c-k> <c-w><c-k>
nnoremap <c-l> <c-w><c-l>
tnoremap <c-h> <c-w><c-h>
tnoremap <c-j> <c-w><c-j>
tnoremap <c-k> <c-w><c-k>
tnoremap <c-l> <c-w><c-l>


let g:UltiSnipsExpandTrigger="<tab>"
let g:UltiSnipsJumpForwardTrigger="<tab>"
let g:UltiSnipsJumpBackwardTrigger="<s-tab>"

let g:AutoPairsShortcutFastWrap=''

inoremap wq <esc>ZZ
inoremap <c-l> <c-o>zz

augroup git_commit_insert_mode
  autocmd!
  autocmd FileType gitcommit startinsert
augroup END

if executable('rg')
  let &grepprg = "rg --vimgrep"
endif

function Coc_settings()
  " Coc relevant config
  "
  " Always show the signcolumn, otherwise it would shift the text each time
  " diagnostics appear/become resolved.
  if has("patch-8.1.1564")
    " Recently vim can merge signcolumn and number column into one
    set signcolumn=number
  else
    set signcolumn=yes
  endif

  inoremap <silent><expr> <TAB>
        \ pumvisible() ? "\<C-n>" :
        \ <SID>check_back_space() ? "\<TAB>" :
        \ coc#refresh()

  inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>"

  function! s:check_back_space() abort
    let col = col('.') - 1
    return !col || getline('.')[col - 1]  =~# '\s'
  endfunction

  " Use <c-space> to trigger completion.
  inoremap <silent><expr> <c-space> coc#refresh()

  if has('patch8.1.1068')
    " Use `complete_info` if your (Neo)Vim version supports it.
    inoremap <expr> <cr> complete_info()["selected"] != "-1" ?  "\<C-y>" : "\<C-g>u\<CR>"
  else
    imap <expr> <cr> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>"
  endif

  " Use `[g` and `]g` to navigate diagnostics
  nmap <silent> [g <Plug>(coc-diagnostic-prev)
  nmap <silent> ]g <Plug>(coc-diagnostic-next)

  " GoTo code navigation.
  nmap <silent> gd <Plug>(coc-definition)
  nmap <silent> gy <Plug>(coc-type-definition)
  nmap <silent> gi <Plug>(coc-implementation)
  nmap <silent> gr <Plug>(coc-references)

  " Use K to show documentation in preview window.
  nnoremap <silent> K :call <SID>show_documentation()<CR>

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

  " Highlight the symbol and its references when holding the cursor.
  autocmd CursorHold * silent call CocActionAsync('highlight')

  " Symbol renaming.
  nmap <leader>rn <Plug>(coc-rename)

  " Formatting selected code.
  " xmap <leader>f  <Plug>(coc-format-selected)
  " nmap <leader>f  <Plug>(coc-format-selected)

  augroup mygroup
    autocmd!
    " Setup formatexpr specified filetype(s).
    autocmd FileType typescript,json setl formatexpr=CocAction('formatSelected')
    " Update signature help on jump placeholder.
    autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp')
  augroup end

  " Applying codeAction to the selected region.
  " Example: `<leader>aap` for current paragraph
  xmap <leader>a <Plug>(coc-codeaction-selected)
  nmap <leader>a <Plug>(coc-codeaction-selected)

  " Remap keys for applying codeAction to the current line.
  nmap <leader>ac <Plug>(coc-codeaction)
  " Apply AutoFix to problem on the current line.
  nmap <leader>qf <Plug>(coc-fix-current)

  " Introduce function text object
  " NOTE: Requires 'textDocument.documentSymbol' support from the language server.
  xmap if <Plug>(coc-funcobj-i)
  xmap af <Plug>(coc-funcobj-a)
  omap if <Plug>(coc-funcobj-i)
  omap af <Plug>(coc-funcobj-a)

  " Add `:Format` command to format current buffer.
  command! -nargs=0 Format :call CocAction('format')

  " Add `:Fold` command to fold current buffer.
  command! -nargs=? Fold :call CocAction('fold', <f-args>)

  " Add `:OR` command for organize imports of the current buffer.
  command! -nargs=0 OR   :call CocAction('runCommand', 'editor.action.organizeImport')

  nnoremap <silent> <space>a :<C-u>CocList diagnostics<cr>
  " Manage extensions.
  nnoremap <silent> <space>e :<C-u>CocList extensions<cr>
  " Show commands.
  nnoremap <silent> <space>c :<C-u>CocList commands<cr>
  " Find symbol of current document.
  nnoremap <silent> <space>o :<C-u>CocList outline<cr>
  " Search workspace symbols.
  nnoremap <silent> <space>s :<C-u>CocList -I symbols<cr>
  " Do default action for next item.
  nnoremap <silent> <space>j :<C-u>CocNext<CR>
  " Do default action for previous item.
  nnoremap <silent> <space>k :<C-u>CocPrev<CR>
  " Resume latest coc list.
  nnoremap <silent> <space>p :<C-u>CocListResume<CR>
endfunction