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