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" Lean
52Plug 'Julian/lean.nvim'
53" let g:lean_config = {'mappings' = v:true}
54let g:lean_config = {
55 \ 'mappings': v:true,
56 \ }
57
58
59" javascript
60Plug 'jelera/vim-javascript-syntax'
61
62" python (disabled as puts conceallevel=2, which forces markdown
63" previsualization :S)
64" Plug 'davidhalter/jedi-vim'
65" Plug 'raimon49/requirements.txt.vim', {'for': 'requirements'}
66
67" solidity
68Plug 'tomlion/vim-solidity'
69" circom
70Plug 'iden3/vim-circom-syntax'
71" Cairo
72" Plug 'miguelmota/cairo.vim'
73
74" LaTeX support. It needs latexmk & zathura
75Plug 'lervag/vimtex'
76
77" Coq/Rocq
78Plug 'whonore/Coqtail'
79
80" completion and native LSP support. v1 while v2 is unstable
81Plug 'saghen/blink.cmp', { 'tag': 'v1.*' }
82Plug 'neovim/nvim-lspconfig'
83
84" automatically adjust shiftwidth and expand tab based on current file
85Plug 'tpope/vim-sleuth'
86
87
88" errors
89Plug 'Valloric/ListToggle'
90
91" focus mode
92Plug 'junegunn/goyo.vim'
93Plug 'szw/vim-maximizer' " use `CTRL+w; m` to maximize panel
94
95" vimwiki
96Plug 'vimwiki/vimwiki'
97" vim calendar
98Plug 'mattn/calendar-vim'
99
100" colors
101Plug 'tomasr/molokai'
102Plug 'srcery-colors/srcery-vim'
103Plug 'rakr/vim-one'
104Plug 'morhetz/gruvbox'
105Plug 'noahfrederick/vim-hemisu'
106Plug 'JaySandhu/xcode-vim'
107
108call plug#end()
109
110lua << EOF
111require('blink.cmp').setup({
112 keymap = { preset = 'default' },
113 completion = { documentation = { auto_show = true } },
114 sources = { default = { 'lsp', 'path', 'snippets', 'buffer' } },
115 fuzzy = { implementation = 'prefer_rust_with_warning' },
116})
117
118-- nvim-lspconfig supplies these server definitions to Neovim's native LSP.
119local capabilities = require('blink.cmp').get_lsp_capabilities()
120vim.lsp.config('gopls', { capabilities = capabilities })
121vim.lsp.config('rust_analyzer', { capabilities = capabilities })
122vim.lsp.enable({ 'gopls', 'rust_analyzer' })
123
124vim.keymap.set('n', '<F6>', vim.lsp.buf.code_action)
125vim.keymap.set('n', 'K', vim.lsp.buf.hover)
126vim.keymap.set('n', 'KK', vim.lsp.buf.hover)
127vim.keymap.set('n', 'gd', vim.lsp.buf.definition)
128vim.keymap.set('n', '<F2>', vim.lsp.buf.rename)
129EOF
130
131let $NVIM_TUI_ENABLE_TRUE_COLOR=1
132set termguicolors
133
134if $COLORTERM == 'gnome-terminal'
135 set term=gnome-256color
136else
137 if $TERM == 'xterm'
138 set term=xterm-256color
139 endif
140endif
141
142set statusline=%F%m%r%h%w%=(%{&ff}/%Y)\ (line\ %l\/%L,\ col\ %c)\
143
144
145" NERDTree
146let NERDTreeShowHidden=1
147autocmd vimenter * NERDTree
148map <C-n> :NERDTreeToggle<CR>
149" NERDCommenter
150let g:NERDSpaceDelims = 1 " Add spaces after comment delimiters by default
151let g:NERDDefaultAlign = 'left' " Align line-wise comment delimiters flush left instead of following code indentation
152let g:NERDCommentEmptyLines = 1 " Allow commenting and inverting empty lines (useful when commenting a region)
153
154
155"" go config
156function! s:build_go_files()
157 let l:file = expand('%')
158 if l:file =~# '^\f\+\.go$'
159 call go#cmd#Build(0)
160 endif
161endfunction
162
163
164let g:go_list_type = "quickfix"
165let g:go_fmt_command = "goimports"
166let g:go_fmt_fail_silently = 1
167let g:go_highlight_types = 1
168let g:go_highlight_fields = 1
169let g:go_highlight_functions = 1
170let g:go_highlight_methods = 1
171let g:go_highlight_operators = 1
172let g:go_highlight_build_constraints = 1
173let g:go_highlight_structs = 1
174let g:go_highlight_generate_tags = 1
175let g:go_highlight_space_tab_error = 0
176let g:go_highlight_array_whitespace_error = 0
177let g:go_highlight_trailing_whitespace_error = 0
178let g:go_highlight_extra_types = 1
179
180
181" vim-airline
182"" let g:airline_theme = 'powerlineish'
183let g:airline_theme='one'
184" let g:airline#extensions#syntastic#enabled = 1
185let g:airline#extensions#branch#enabled = 1
186let g:airline#extensions#tabline#enabled = 1
187let g:airline#extensions#tabline#buffer_nr_show = 1
188let g:airline#extensions#tagbar#enabled = 1
189let g:airline_skip_empty_sections = 1
190
191
192" errors
193"" native LSP requires gopls and rust-analyzer to be available on PATH.
194let g:lt_location_list_toggle_map = '<leader>l'
195let g:lt_quickfix_list_toggle_map = '<leader>s'
196
197noremap <silent> <C-c> :cn<CR>
198
199
200" next 3 lines are needed for vimwiki
201set nocompatible
202filetype plugin on
203syntax on
204" vimwiki with markdown
205let g:vimwiki_list = [{'path': '~/vimwiki/',
206 \ 'syntax': 'markdown', 'ext': '.md'}]
207" prevent vimwiki of setting conceallevel=2:
208let g:vimwiki_conceallevel=0
209
210" rainbowparentheses
211let g:rainbow_active = 1
212
213"" circom syntax
214au BufRead,BufNewFile *.circom set filetype=circom
215au BufRead,BufNewFile *.circuit set filetype=go-snark-circuit
216
217"" LaTeX vimtex config:
218" Important: This config needs latexmk & zathura to be installed.
219"
220" This is necessary for VimTeX to load properly. The "indent" is optional.
221" Note that most plugin managers will do this automatically.
222filetype plugin indent on
223" This enables Vim's and neovim's syntax-related features. Without this, some
224" VimTeX features will not work (see ":help vimtex-requirements" for more
225" info).
226syntax enable
227" Viewer options: One may configure the viewer either by specifying a built-in
228" viewer method:
229let g:vimtex_view_method = 'zathura'
230
231"" gitlink
232function! CopyGitLink(...) range
233 redir @+
234 silent echo gitlink#GitLink(get(a:, 1, 0))
235 redir END
236endfunction
237nmap <leader>gl :call CopyGitLink()<CR>
238vmap <leader>gl :call CopyGitLink(1)<CR>
239
240"" sage syntax
241augroup filetypedetect
242 au! BufRead,BufNewFile *.sage,*.spyx,*.pyx setfiletype python
243augroup END
244
245"" wat (wasm) syntax
246autocmd BufNewFile,BufReadPost *.wat setlocal filetype=wast
247
248" maximize current split or return to previous
249noremap <C-w>m :MaximizerToggle<CR>
250
251" for file watching
252set backupcopy=yes
253
254" copy&paste from system clipboard
255vnoremap <leader>y "+y
256vnoremap <leader>p "+p
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=80
268set textwidth=80
269
270set background=dark
271
272" colorscheme molokai
273colorscheme gruvbox
274set conceallevel=0
275
276highlight normal ctermbg=0 guibg=#000000
277