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