configs/init.vim
init.vimRaw
1source ~/vimconfigbase.vim
2
3" Automate plug.vim installation:
4let data_dir = has('nvim') ? stdpath('data') . '/site' : '~/.vim'
5if empty(glob(data_dir . '/autoload/plug.vim'))
6 silent execute '!curl -fLo '.data_dir.'/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim'
7 autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
8endif
9
10call plug#begin(expand('~/.config/nvim/plugged'))
11
12nnoremap <Space> <nop>
13let mapleader = "\<Space>"
14let g:mapleader = "\<Space>"
15let maplocalleader = "\<Space>"
16
17" nerdtree
18Plug 'scrooloose/nerdtree'
19Plug 'jistr/vim-nerdtree-tabs'
20Plug 'scrooloose/nerdcommenter'
21
22" vim-airline
23Plug 'vim-airline/vim-airline'
24Plug 'vim-airline/vim-airline-themes'
25
26" vim-ripgrep
27Plug 'jremmen/vim-ripgrep'
28
29Plug 'airblade/vim-gitgutter'
30Plug 'Raimondi/delimitMate'
31Plug 'majutsushi/tagbar'
32
33" rainbow parentheses
34Plug 'luochen1990/rainbow'
35
36" git
37Plug 'tpope/vim-fugitive'
38" gitlink
39Plug 'mazubieta/gitlink-vim'
40
41" go
42Plug 'fatih/vim-go' " Amazing combination of features.
43Plug 'godoctor/godoctor.vim' " Some refactoring tools
44
45" rust
46Plug 'rust-lang/rust.vim'
47" set hidden
48let g:rustfmt_fail_silently = 0
49let g:rustfmt_autosave = 1
50
51" javascript
52Plug 'jelera/vim-javascript-syntax'
53
54" python (disabled as puts conceallevel=2, which forces markdown
55" previsualization :S)
56" Plug 'davidhalter/jedi-vim'
57" Plug 'raimon49/requirements.txt.vim', {'for': 'requirements'}
58
59" solidity
60Plug 'tomlion/vim-solidity'
61" circom
62Plug 'iden3/vim-circom-syntax'
63" Cairo
64" Plug 'miguelmota/cairo.vim'
65
66" LaTeX support. It needs latexmk & zathura
67Plug 'lervag/vimtex'
68
69
70" deoplete
71Plug 'Shougo/deoplete.nvim'
72let g:deoplete#enable_at_startup = 1
73autocmd CompleteDone * pclose!
74" Plug 'zchee/deoplete-go', {'build': {'unix': 'make'}}
75" " neosnippet with deoplete
76" Plug 'Shougo/neosnippet.vim'
77" Plug 'Shougo/neosnippet-snippets'
78" " Plugin deoplete neosnippet key-mappings.
79" " Note: It must be "imap" and "smap". It uses <Plug> mappings.
80" imap <C-k> <Plug>(neosnippet_expand_or_jump)
81" smap <C-k> <Plug>(neosnippet_expand_or_jump)
82" xmap <C-k> <Plug>(neosnippet_expand_target)
83
84" automatically adjust shiftwidth and expand tab based on current file
85Plug 'tpope/vim-sleuth'
86
87
88" errors
89Plug 'Valloric/ListToggle'
90Plug 'autozimu/LanguageClient-neovim', {
91 \ 'branch': 'next',
92 \ 'do': 'bash install.sh',
93 \ }
94Plug 'neoclide/coc.nvim', {'branch': 'release'}
95" after PlugInstall, install coc-rust-analyzer:
96" :CocInstall coc-rust-analyzer
97" also run (outside vim, in a shell):
98" rustup component add rust-analyzer
99
100" focus mode
101Plug 'junegunn/goyo.vim'
102
103" vimwiki
104Plug 'vimwiki/vimwiki'
105" vim calendar
106Plug 'mattn/calendar-vim'
107
108" colors
109Plug 'tomasr/molokai'
110Plug 'srcery-colors/srcery-vim'
111Plug 'rakr/vim-one'
112Plug 'morhetz/gruvbox'
113
114call plug#end()
115
116let $NVIM_TUI_ENABLE_TRUE_COLOR=1
117set termguicolors
118
119if $COLORTERM == 'gnome-terminal'
120 set term=gnome-256color
121else
122 if $TERM == 'xterm'
123 set term=xterm-256color
124 endif
125endif
126
127set statusline=%F%m%r%h%w%=(%{&ff}/%Y)\ (line\ %l\/%L,\ col\ %c)\
128
129
130" NERDTree
131let NERDTreeShowHidden=1
132autocmd vimenter * NERDTree
133map <C-n> :NERDTreeToggle<CR>
134" NERDCommenter
135let g:NERDSpaceDelims = 1 " Add spaces after comment delimiters by default
136let g:NERDDefaultAlign = 'left' " Align line-wise comment delimiters flush left instead of following code indentation
137let g:NERDCommentEmptyLines = 1 " Allow commenting and inverting empty lines (useful when commenting a region)
138
139
140"" go config
141function! s:build_go_files()
142 let l:file = expand('%')
143 if l:file =~# '^\f\+\.go$'
144 call go#cmd#Build(0)
145 endif
146endfunction
147
148
149let g:go_list_type = "quickfix"
150let g:go_fmt_command = "goimports"
151let g:go_fmt_fail_silently = 1
152let g:go_highlight_types = 1
153let g:go_highlight_fields = 1
154let g:go_highlight_functions = 1
155let g:go_highlight_methods = 1
156let g:go_highlight_operators = 1
157let g:go_highlight_build_constraints = 1
158let g:go_highlight_structs = 1
159let g:go_highlight_generate_tags = 1
160let g:go_highlight_space_tab_error = 0
161let g:go_highlight_array_whitespace_error = 0
162let g:go_highlight_trailing_whitespace_error = 0
163let g:go_highlight_extra_types = 1
164
165
166" vim-airline
167"" let g:airline_theme = 'powerlineish'
168let g:airline_theme='one'
169" let g:airline#extensions#syntastic#enabled = 1
170let g:airline#extensions#branch#enabled = 1
171let g:airline#extensions#tabline#enabled = 1
172let g:airline#extensions#tabline#buffer_nr_show = 1
173let g:airline#extensions#tagbar#enabled = 1
174let g:airline_skip_empty_sections = 1
175
176
177" errors
178"" For go needs gopls installed (comes with vim-go pluggin)
179"" For rust with rust-analyzer needs https://rust-analyzer.github.io/manual.html#rust-analyzer-language-server-binary installed
180"" --> place it at ~.local/bin or ~/bin and make sure that the PATH is defined (eg. in .zshrc: export PATH=$PATH:.local/bin)
181"" [old] for rust with rls needs https://github.com/rust-lang/rls installed
182let g:lt_location_list_toggle_map = '<leader>l'
183let g:lt_quickfix_list_toggle_map = '<leader>s'
184" \ 'rust': ['~/.cargo/bin/rustup', 'run', 'stable', 'rls'],
185let g:LanguageClient_serverCommands = {
186 \ 'go': ['~/go/bin/gopls'],
187 \ 'rust': ['rust-analyzer'],
188 \ }
189let g:LanguageClient_diagnosticsList = "Quickfix"
190let g:LanguageClient_diagnosticsEnable = 1
191
192" language server key bindings
193nnoremap <F6> :call LanguageClient_contextMenu()<CR>
194" Specific mappings of LanguageClient each action separately
195nnoremap <silent> K :call LanguageClient#textDocument_hover()<CR>
196nnoremap <silent> KK :call LanguageClient#textDocument_hover()<CR>
197nnoremap <silent> gd :call LanguageClient#textDocument_definition()<CR>
198nnoremap <silent> <F2> :call LanguageClient#textDocument_rename()<CR>
199
200noremap <silent> <C-c> :cn<CR>
201
202
203" next 3 lines are needed for vimwiki
204set nocompatible
205filetype plugin on
206syntax on
207" vimwiki with markdown
208let g:vimwiki_list = [{'path': '~/vimwiki/',
209 \ 'syntax': 'markdown', 'ext': '.md'}]
210" prevent vimwiki of setting conceallevel=2:
211let g:vimwiki_conceallevel=0
212
213" rainbowparentheses
214let g:rainbow_active = 1
215
216"" circom syntax
217au BufRead,BufNewFile *.circom set filetype=circom
218au BufRead,BufNewFile *.circuit set filetype=go-snark-circuit
219
220"" LaTeX vimtex config:
221" Important: This config needs latexmk & zathura to be installed.
222"
223" This is necessary for VimTeX to load properly. The "indent" is optional.
224" Note that most plugin managers will do this automatically.
225filetype plugin indent on
226" This enables Vim's and neovim's syntax-related features. Without this, some
227" VimTeX features will not work (see ":help vimtex-requirements" for more
228" info).
229syntax enable
230" Viewer options: One may configure the viewer either by specifying a built-in
231" viewer method:
232let g:vimtex_view_method = 'zathura'
233
234"" gitlink
235function! CopyGitLink(...) range
236 redir @+
237 silent echo gitlink#GitLink(get(a:, 1, 0))
238 redir END
239endfunction
240nmap <leader>gl :call CopyGitLink()<CR>
241vmap <leader>gl :call CopyGitLink(1)<CR>
242
243"" sage syntax
244augroup filetypedetect
245 au! BufRead,BufNewFile *.sage,*.spyx,*.pyx setfiletype python
246augroup END
247
248" for file watching
249set backupcopy=yes
250
251" copy&paste from system clipboard
252vnoremap <leader>y "+y
253vnoremap <leader>p "+p
254
255" disable mouse
256set mouse=
257
258" shortcut for theme change
259nnoremap <F9> :colorscheme gruvbox \| set background=dark \| highlight normal ctermbg=0 guibg=#000000 <CR>
260nnoremap <F10> :colorscheme one \| set background=light \| highlight normal guibg=#ffffff<CR>
261
262" colorscheme
263let g:gruvbox_contrast_dark = 'hard'
264let g:gruvbox_contrast_light = 'hard'
265let g:srcery_italic = 1
266
267set colorcolumn=100
268" set textwidth=80
269
270set background=dark
271
272" colorscheme molokai
273colorscheme gruvbox
274set conceallevel=0
275
276highlight normal ctermbg=0 guibg=#000000