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