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