-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit.vim
206 lines (168 loc) · 5.57 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
197
198
199
200
201
202
203
204
205
206
" Use spaces instead of tabs
set expandtab
set shiftwidth=4
" Autoread files when they change outside of vim
set autoread
autocmd BufEnter,FocusGained * checktime
" Change colorscheme
set termguicolors
set background=light
autocmd vimenter * ++nested colorscheme solarized8_flat
" Allow setting syntax and stuff in modeline
set modeline
" Set wrap on and end at full words
set wrap
set linebreak
" Don't abandon buffers when they are unloaded
set hidden
" Make TAB completion in command mode like a shell
set wildmode=list:longest
" Ignore case on / searches, but not on * searches
set ignorecase
set smartcase
" Don't highlight matches when searching
set nohlsearch
" Set the terminal title
set title
" Scroll before cursor hits very bottom to maintain more context
set scrolloff=3
" Scroll the viewport faster
nnoremap <C-e> 3<C-e>
nnoremap <C-y> 3<C-y>
" Less interruptive prompts
set shortmess=atI
" autocomplete behavior
set completeopt=menu,longest,preview
set omnifunc=syntaxcomplete#Complete
imap <buffer> <C-Space> <C-x><C-o>
imap <buffer> <C-@> <C-Space>
set wildignore+=*.pyc "ignore pyc files
set grepprg=rg\ --vimgrep\ --smart-case
" vim-plug
call plug#begin()
Plug 'https://github.com/tpope/vim-sensible.git'
Plug 'https://github.com/tpope/vim-vinegar.git'
Plug 'https://github.com/lifepillar/vim-solarized8.git', { 'branch': 'neovim' }
Plug 'https://github.com/junegunn/fzf.vim.git'
Plug 'https://github.com/neoclide/coc.nvim.git', { 'branch': 'release' }
Plug 'https://github.com/nvim-treesitter/nvim-treesitter.git', {'do': ':TSUpdate'}
Plug 'https://github.com/Olical/conjure.git'
Plug 'https://github.com/eraserhd/parinfer-rust.git', {'do': 'cargo build --release'}
Plug 'https://github.com/4e554c4c/darkman.nvim.git', {'do': 'go build -o bin/darkman.nvim'}
call plug#end()
" leaders
let mapleader = ","
let maplocalleader = ","
" FZF settings
source /usr/share/doc/fzf/examples/fzf.vim
nnoremap <C-w>; :Buffers<CR>
nnoremap <C-w><C-;> :Buffers<CR>
nnoremap <C-w>' :Files<CR>
nnoremap <C-w><C-'> :Files<CR>
tnoremap <C-w>; <C-\><C-N>:Buffers<CR>
tnoremap <C-w><C-;> <C-\><C-N>:Buffers<CR>
tnoremap <C-w>' <C-\><C-N>:Files<CR>
tnoremap <C-w><C-'> <C-\><C-N>:Files<CR>
let g:fzf_action = {
\'ctrl-o': 'split',
\'ctrl-v': 'vsplit' }
" Terminal settings
tnoremap <C-w>: <C-\><C-N>:
nnoremap <C-w>: :
tnoremap <C-w> <C-\><C-N><C-w>
tnoremap <expr> <C-w><C-r> '<C-\><C-N>"'.nr2char(getchar()).'pi'
autocmd TermOpen * setlocal hidden
autocmd TermOpen * setlocal modifiable
autocmd TermOpen * setlocal modified
autocmd TermOpen * startinsert
" Due to https://github.com/neovim/neovim/issues/3681, can't change cursor
" shape in term. Change the color so we at least can tell if we are in
" insert or normal mode within a terminal buffer.
highlight TermCursor guifg=#dc322f
" netrw
let g:netrw_list_hide = '\(^\|\s\s\)\zs\.\S\+' " ignore dotfiles by default
let g:netrw_localrmdir = 'rm -r'
" coc.nvim
let g:coc_global_extensions = [
\'coc-clojure',
\'coc-css',
\'coc-eslint',
\'coc-json',
\'coc-pyright',
\'coc-tsserver',
\'@yaegassy/coc-marksman',
\]
autocmd FileType
\ clojure,css,javascript,typescript,json,python,markdown
\ setl formatexpr=CocAction('formatSelected')
set tagfunc=CocTagFunc
xmap if <Plug>(coc-funcobj-i)
omap if <Plug>(coc-funcobj-i)
xmap af <Plug>(coc-funcobj-a)
omap af <Plug>(coc-funcobj-a)
inoremap <silent><expr> <C-n> coc#pum#visible() ? coc#pum#next(1) : coc#refresh()
nnoremap <silent><nowait><expr> <C-f> coc#float#has_scroll() ? coc#float#scroll(1) : "\<C-f>"
nnoremap <silent><nowait><expr> <C-b> coc#float#has_scroll() ? coc#float#scroll(0) : "\<C-b>"
inoremap <silent><nowait><expr> <C-f> coc#float#has_scroll() ? "\<c-r>=coc#float#scroll(1)\<cr>" : "\<Right>"
inoremap <silent><nowait><expr> <C-b> coc#float#has_scroll() ? "\<c-r>=coc#float#scroll(0)\<cr>" : "\<Left>"
vnoremap <silent><nowait><expr> <C-f> coc#float#has_scroll() ? coc#float#scroll(1) : "\<C-f>"
vnoremap <silent><nowait><expr> <C-b> coc#float#has_scroll() ? coc#float#scroll(0) : "\<C-b>"
nnoremap <silent> <leader>d :CocDiagnostics<CR>
nnoremap <silent> ]d <Plug>(coc-diagnostic-next)
nnoremap <silent> [d <Plug>(coc-diagnostic-prev)
nnoremap <silent> <leader>rn <Plug>(coc-rename)
nnoremap <silent> <leader>rf <Plug>(coc-references)
nnoremap <silent> K :call ShowDocumentation()<CR>
function! ShowDocumentation()
if CocAction('hasProvider', 'hover')
call CocActionAsync('definitionHover')
else
call feedkeys('K', 'in')
endif
endfunction
nnoremap <silent><nowait> gO :call ToggleOutline()<CR>
function! ToggleOutline() abort
let winid = coc#window#find('cocViewId', 'OUTLINE')
if winid != -1
call coc#window#close(winid)
endif
if winid == -1
if CocAction('hasProvider', 'documentSymbol')
call CocActionAsync('showOutline')
else
call feedkeys('gO', 'in')
endif
endif
endfunction
autocmd BufWritePre *.py call CocAction('runCommand', 'pyright.organizeimports')
" nvim-treesitter
lua << EOF
require"nvim-treesitter.configs".setup {
sync_install = false,
auto_install = true,
highlight = {
enable = true,
additional_vim_regex_highlighting = false,
},
indent = {
enable = true
},
}
EOF
set foldmethod=expr
set foldexpr=v:lua.vim.treesitter.foldexpr()
set foldlevelstart=2
autocmd FileType * highlight! link @variable Normal
" conjure
let g:conjure#mapping#def_word = v:false
let g:conjure#mapping#doc_word = v:false
let g:conjure#completion#omnifunc = v:false
let g:conjure#highlight#enabled = v:true
" darkman.nvim
lua << EOF
require"darkman".setup {
change_background = true
}
EOF
" Autogenerate documentation tags
silent! helptags ALL