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
98" focus mode
99Plug 'junegunn/goyo.vim'
100
101" vimwiki
102Plug 'vimwiki/vimwiki'
103" vim calendar
104Plug 'mattn/calendar-vim'
105
106" colors
107Plug 'tomasr/molokai'
108Plug 'srcery-colors/srcery-vim'
109Plug 'rakr/vim-one'
110Plug 'morhetz/gruvbox'
111
112call plug#end()
113
114let $NVIM_TUI_ENABLE_TRUE_COLOR=1
115set termguicolors
116
117if $COLORTERM == 'gnome-terminal'
118 set term=gnome-256color
119else
120 if $TERM == 'xterm'
121 set term=xterm-256color
122 endif
123endif
124
125set statusline=%F%m%r%h%w%=(%{&ff}/%Y)\ (line\ %l\/%L,\ col\ %c)\
126
127
128" NERDTree
129let NERDTreeShowHidden=1
130autocmd vimenter * NERDTree
131map <C-n> :NERDTreeToggle<CR>
132" NERDCommenter
133let g:NERDSpaceDelims = 1 " Add spaces after comment delimiters by default
134let g:NERDDefaultAlign = 'left' " Align line-wise comment delimiters flush left instead of following code indentation
135let g:NERDCommentEmptyLines = 1 " Allow commenting and inverting empty lines (useful when commenting a region)
136
137
138"" go config
139function! s:build_go_files()
140 let l:file = expand('%')
141 if l:file =~# '^\f\+\.go$'
142 call go#cmd#Build(0)
143 endif
144endfunction
145
146
147let g:go_list_type = "quickfix"
148let g:go_fmt_command = "goimports"
149let g:go_fmt_fail_silently = 1
150let g:go_highlight_types = 1
151let g:go_highlight_fields = 1
152let g:go_highlight_functions = 1
153let g:go_highlight_methods = 1
154let g:go_highlight_operators = 1
155let g:go_highlight_build_constraints = 1
156let g:go_highlight_structs = 1
157let g:go_highlight_generate_tags = 1
158let g:go_highlight_space_tab_error = 0
159let g:go_highlight_array_whitespace_error = 0
160let g:go_highlight_trailing_whitespace_error = 0
161let g:go_highlight_extra_types = 1
162
163
164" vim-airline
165"" let g:airline_theme = 'powerlineish'
166let g:airline_theme='one'
167" let g:airline#extensions#syntastic#enabled = 1
168let g:airline#extensions#branch#enabled = 1
169let g:airline#extensions#tabline#enabled = 1
170let g:airline#extensions#tabline#buffer_nr_show = 1
171let g:airline#extensions#tagbar#enabled = 1
172let g:airline_skip_empty_sections = 1
173
174
175" errors
176"" For go needs gopls installed (comes with vim-go pluggin)
177"" For rust with rust-analyzer needs https://rust-analyzer.github.io/manual.html#rust-analyzer-language-server-binary installed
178"" --> place it at ~.local/bin or ~/bin and make sure that the PATH is defined (eg. in .zshrc: export PATH=$PATH:.local/bin)
179"" [old] for rust with rls needs https://github.com/rust-lang/rls installed
180let g:lt_location_list_toggle_map = '<leader>l'
181let g:lt_quickfix_list_toggle_map = '<leader>s'
182" \ 'rust': ['~/.cargo/bin/rustup', 'run', 'stable', 'rls'],
183let g:LanguageClient_serverCommands = {
184 \ 'go': ['~/go/bin/gopls'],
185 \ 'rust': ['rust-analyzer'],
186 \ }
187let g:LanguageClient_diagnosticsList = "Quickfix"
188let g:LanguageClient_diagnosticsEnable = 1
189
190" language server key bindings
191nnoremap <F6> :call LanguageClient_contextMenu()<CR>
192" Specific mappings of LanguageClient each action separately
193nnoremap <silent> K :call LanguageClient#textDocument_hover()<CR>
194nnoremap <silent> KK :call LanguageClient#textDocument_hover()<CR>
195nnoremap <silent> gd :call LanguageClient#textDocument_definition()<CR>
196nnoremap <silent> <F2> :call LanguageClient#textDocument_rename()<CR>
197
198noremap <silent> <C-c> :cn<CR>
199
200
201" next 3 lines are needed for vimwiki
202set nocompatible
203filetype plugin on
204syntax on
205" vimwiki with markdown
206let g:vimwiki_list = [{'path': '~/vimwiki/',
207 \ 'syntax': 'markdown', 'ext': '.md'}]
208" prevent vimwiki of setting conceallevel=2:
209let g:vimwiki_conceallevel=0
210
211" rainbowparentheses
212let g:rainbow_active = 1
213
214"" circom syntax
215au BufRead,BufNewFile *.circom set filetype=circom
216au BufRead,BufNewFile *.circuit set filetype=go-snark-circuit
217
218"" LaTeX vimtex config:
219" Important: This config needs latexmk & zathura to be installed.
220"
221" This is necessary for VimTeX to load properly. The "indent" is optional.
222" Note that most plugin managers will do this automatically.
223filetype plugin indent on
224" This enables Vim's and neovim's syntax-related features. Without this, some
225" VimTeX features will not work (see ":help vimtex-requirements" for more
226" info).
227syntax enable
228" Viewer options: One may configure the viewer either by specifying a built-in
229" viewer method:
230let g:vimtex_view_method = 'zathura'
231
232"" gitlink
233function! CopyGitLink(...) range
234 redir @+
235 silent echo gitlink#GitLink(get(a:, 1, 0))
236 redir END
237endfunction
238nmap <leader>gl :call CopyGitLink()<CR>
239vmap <leader>gl :call CopyGitLink(1)<CR>
240
241"" sage syntax
242augroup filetypedetect
243 au! BufRead,BufNewFile *.sage,*.spyx,*.pyx setfiletype python
244augroup END
245
246" for file watching
247set backupcopy=yes
248
249" copy&paste from system clipboard
250vnoremap <leader>y "+y
251vnoremap <leader>p "+p
252
253" shortcut for theme change
254nnoremap <F9> :colorscheme gruvbox \| set background=dark \| highlight normal ctermbg=0 guibg=#000000 <CR>
255nnoremap <F10> :colorscheme one \| set background=light \| highlight normal guibg=#ffffff<CR>
256
257" colorscheme
258let g:gruvbox_contrast_dark = 'hard'
259let g:gruvbox_contrast_light = 'hard'
260let g:srcery_italic = 1
261
262set colorcolumn=100
263" set textwidth=80
264
265set background=dark
266
267" colorscheme molokai
268colorscheme gruvbox
269set conceallevel=0
270
271highlight normal ctermbg=0 guibg=#000000