2020-04-02 15:42:52 +00:00
|
|
|
"""""""""""
|
2020-04-29 15:58:14 +00:00
|
|
|
" PLUGINS "
|
2020-04-02 15:42:52 +00:00
|
|
|
"""""""""""
|
|
|
|
|
|
|
|
" This configuration uses vim-plug (https://github.com/junegunn/vim-plug) as
|
|
|
|
" the plugin manager.
|
|
|
|
" Activate it with ':PlugInstall' for the first time (and when adding new plugins).
|
|
|
|
" And run ':PlugUpgrade' for upgrading the plugins.
|
2020-03-29 12:23:44 +00:00
|
|
|
call plug#begin('~/.config/nvim/plugged')
|
2019-08-09 14:56:06 +00:00
|
|
|
|
2020-04-29 15:58:14 +00:00
|
|
|
" Nord Vim color scheme.
|
|
|
|
Plug 'arcticicestudio/nord-vim'
|
|
|
|
|
2020-04-02 15:42:52 +00:00
|
|
|
" A snippets engine.
|
|
|
|
" One of the must-haves for me.
|
2019-08-09 14:56:06 +00:00
|
|
|
Plug 'sirver/ultisnips'
|
2020-04-02 15:42:52 +00:00
|
|
|
" Setting my private snippets in a consistent home directory and a relative snippets directory for project-specific snippets.
|
|
|
|
let g:UltiSnipsSnippetDirectories = [$HOME . "/.config/nvim/own-snippets", ".snippets"]
|
2019-08-15 03:50:33 +00:00
|
|
|
let g:UltiSnipsExpandTrigger="<tab>"
|
2019-08-19 01:03:51 +00:00
|
|
|
let g:UltiSnipsJumpForwardTrigger="<tab>"
|
|
|
|
let g:UltiSnipsJumpBackwardTrigger="<s-tab>"
|
2019-08-22 12:25:27 +00:00
|
|
|
let g:UltiSnipsEditSplit="context"
|
2019-08-09 14:56:06 +00:00
|
|
|
|
2020-04-02 15:42:52 +00:00
|
|
|
" A completion engine.
|
|
|
|
" I chose this engine since it is linked from UltiSnips.
|
2020-03-29 12:23:44 +00:00
|
|
|
if has('nvim')
|
|
|
|
Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
|
|
|
|
else
|
|
|
|
Plug 'Shougo/deoplete.nvim'
|
|
|
|
Plug 'roxma/nvim-yarp'
|
|
|
|
Plug 'roxma/vim-hug-neovim-rpc'
|
|
|
|
endif
|
|
|
|
let g:deoplete#enable_at_startup = 1
|
|
|
|
|
2020-04-02 15:42:52 +00:00
|
|
|
" Contains various snippets for UltiSnips.
|
2019-08-15 03:50:33 +00:00
|
|
|
Plug 'honza/vim-snippets'
|
2019-08-09 14:56:06 +00:00
|
|
|
|
2020-04-02 15:42:52 +00:00
|
|
|
" Plugin for auto-saving for each change in the buffer (file).
|
2019-08-09 14:56:06 +00:00
|
|
|
Plug '907th/vim-auto-save'
|
2019-08-15 03:50:33 +00:00
|
|
|
let g:auto_save = 1
|
2019-08-09 14:56:06 +00:00
|
|
|
|
2020-04-02 15:42:52 +00:00
|
|
|
" One of the most popular plugins.
|
|
|
|
" Allows to create more substantial status bars.
|
2019-08-09 14:56:06 +00:00
|
|
|
Plug 'vim-airline/vim-airline'
|
|
|
|
let g:airline_powerline_fonts = 1
|
|
|
|
|
|
|
|
if !exists('g:airline_symbols')
|
2019-08-15 03:50:33 +00:00
|
|
|
let g:airline_symbols = {}
|
2019-08-09 14:56:06 +00:00
|
|
|
endif
|
|
|
|
|
2020-04-02 15:42:52 +00:00
|
|
|
" A full LaTeX toolchain plugin for Vim.
|
|
|
|
" Also a must-have for me since writing LaTeX can be a PITA.
|
|
|
|
" Most of the snippets and workflow is inspired from Gilles Castel's posts (at https://castel.dev/).
|
2019-08-09 14:56:06 +00:00
|
|
|
Plug 'lervag/vimtex'
|
|
|
|
let g:tex_flavor='latex'
|
|
|
|
let g:vimtex_view_method='zathura'
|
|
|
|
let g:vimtex_quickfix_mode=0
|
|
|
|
set conceallevel=1
|
|
|
|
let g:tex_conceal='abdmg'
|
2019-08-15 03:50:33 +00:00
|
|
|
let g:vimtex_compiler_latexmk = {
|
|
|
|
\ 'options': [
|
2019-09-21 18:05:16 +00:00
|
|
|
\ '-bibtex',
|
2019-08-15 03:50:33 +00:00
|
|
|
\ '-shell-escape',
|
|
|
|
\ '-verbose',
|
|
|
|
\ '-file-line-error',
|
|
|
|
\ ]
|
|
|
|
\}
|
2019-09-21 18:05:16 +00:00
|
|
|
|
2020-04-02 15:42:52 +00:00
|
|
|
" I use LuaLaTeX for my documents so let me have it as the default, please?
|
2019-09-21 18:05:16 +00:00
|
|
|
let g:vimtex_compiler_latexmk_engines = {
|
|
|
|
\ '_' : '-lualatex',
|
|
|
|
\ 'pdflatex' : '-pdf',
|
|
|
|
\ 'dvipdfex' : '-pdfdvi',
|
|
|
|
\ 'lualatex' : '-lualatex',
|
|
|
|
\ 'xelatex' : '-xelatex',
|
|
|
|
\ 'context (pdftex)' : '-pdf -pdflatex=texexec',
|
|
|
|
\ 'context (luatex)' : '-pdf -pdflatex=context',
|
|
|
|
\ 'context (xetex)' : '-pdf -pdflatex=''texexec --xtx''',
|
|
|
|
\}
|
|
|
|
|
2020-04-02 15:42:52 +00:00
|
|
|
" Enable visuals for addition/deletion of lines in the gutter (side) similar to Visual Studio Code.
|
2019-08-09 14:56:06 +00:00
|
|
|
Plug 'airblade/vim-gitgutter'
|
|
|
|
|
2020-04-02 15:42:52 +00:00
|
|
|
" Plugin for distraction-free writing.
|
|
|
|
Plug 'junegunn/goyo.vim'
|
2019-08-09 14:56:06 +00:00
|
|
|
call plug#end()
|
|
|
|
|
2020-03-29 12:23:44 +00:00
|
|
|
|
2020-04-02 15:42:52 +00:00
|
|
|
|
|
|
|
|
|
|
|
"""""""""""""""""""""""""
|
2020-04-29 15:58:14 +00:00
|
|
|
" EDITOR CONFIGURATIONS "
|
2020-04-02 15:42:52 +00:00
|
|
|
"""""""""""""""""""""""""
|
|
|
|
|
2020-03-29 12:23:44 +00:00
|
|
|
" Setting number lines in the gutter.
|
2019-08-09 14:56:06 +00:00
|
|
|
set number relativenumber
|
2020-04-29 15:58:14 +00:00
|
|
|
highlight CursorLineNr ctermfg=cyan
|
2019-08-09 14:56:06 +00:00
|
|
|
|
2020-03-29 12:23:44 +00:00
|
|
|
" Setting line highlighting based on the position of the cursor.
|
2019-08-15 17:10:42 +00:00
|
|
|
set cursorline
|
|
|
|
|
2020-03-29 12:23:44 +00:00
|
|
|
" Set tab to enter spaces, instead.
|
2019-08-22 12:25:27 +00:00
|
|
|
set expandtab
|
2019-08-15 03:50:33 +00:00
|
|
|
|
2020-03-29 12:23:44 +00:00
|
|
|
" Set entering tab to 4 spaces.
|
2019-09-21 18:05:16 +00:00
|
|
|
set shiftwidth=4 tabstop=4
|
|
|
|
|
2020-04-19 02:57:30 +00:00
|
|
|
" Set list and other listing characters (:h listchars).
|
|
|
|
set list listchars=tab:→\ ,trail:·
|
|
|
|
|
|
|
|
" Enabling spell checker (for your local language, anyway).
|
|
|
|
setlocal spell
|
|
|
|
set spelllang=en_us
|
|
|
|
inoremap <C-l> <c-g>u<Esc>[s1z=`]a<c-g>u
|
|
|
|
|
|
|
|
" Quick escape to default mode.
|
|
|
|
inoremap jk <Esc>
|
|
|
|
|
|
|
|
" Instant Goyo toggle.
|
2020-04-29 15:58:14 +00:00
|
|
|
map <leader>w :Goyo<Enter>
|
|
|
|
|
|
|
|
" Trim all trailing whitespaces.
|
|
|
|
map <leader>s :%s/\s\+$/<Enter>
|
2020-04-19 02:57:30 +00:00
|
|
|
|
|
|
|
" File explorer toggle.
|
|
|
|
" Turns out vim (and nvim) has a native file explorer with :Explore.
|
|
|
|
map <leader>f :Lexplore<Return>:vertical resize 40<Return><C-w><C-w>
|
|
|
|
|
|
|
|
" Changing style of words.
|
2020-04-29 15:58:14 +00:00
|
|
|
highlight clear SpellBad
|
|
|
|
highlight SpellBad ctermfg=red
|
|
|
|
|
|
|
|
highlight clear SpellLocal
|
|
|
|
highlight SpellLocal cterm=underline ctermfg=cyan
|
2020-04-19 02:57:30 +00:00
|
|
|
|
2020-04-29 15:58:14 +00:00
|
|
|
highlight clear SpellCap
|
|
|
|
highlight SpellCap cterm=underline ctermfg=magenta
|
2020-04-19 02:57:30 +00:00
|
|
|
|
2020-04-29 15:58:14 +00:00
|
|
|
highlight clear SpellRare
|
|
|
|
highlight SpellRare ctermfg=white
|
2020-04-19 02:57:30 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
""""""""""
|
|
|
|
" EVENTS "
|
|
|
|
""""""""""
|
|
|
|
|
|
|
|
" Show leading spaces.
|
|
|
|
" SOURCE: https://www.reddit.com/r/vim/comments/5fxsfy/show_leading_spaces/
|
|
|
|
hi Conceal guibg=NONE ctermbg=NONE ctermfg=DarkGrey
|
|
|
|
autocmd BufWinEnter * setl conceallevel=1
|
|
|
|
autocmd BufWinEnter * syn match LeadingSpace /\(^ *\)\@<= / containedin=ALL conceal cchar=·
|
|
|
|
autocmd BufReadPre * setl conceallevel=1
|
|
|
|
autocmd BufReadPre * syn match LeadingSpace /\(^ *\)\@<= / containedin=ALL conceal cchar=·
|
|
|
|
|
2019-09-14 12:58:12 +00:00
|
|
|
" The template list is simply an array composed of vector that represents the
|
2020-03-29 12:23:44 +00:00
|
|
|
" prefix and the suffix of the template file name.
|
2019-08-15 03:50:33 +00:00
|
|
|
let template_list = [
|
|
|
|
\ ["_minted-", ""],
|
|
|
|
\ ["", ".synctex"],
|
|
|
|
\]
|
|
|
|
|
2020-04-02 15:42:52 +00:00
|
|
|
" Additional LaTeX files cleanup.
|
2019-08-15 03:50:33 +00:00
|
|
|
function VimtexAdditionalCleanup(template_list)
|
2019-09-14 12:58:12 +00:00
|
|
|
call vimtex#compiler#clean(1)
|
2019-08-15 03:50:33 +00:00
|
|
|
let file_name = expand("%:t:r")
|
|
|
|
let file_path = expand("%:p:h") . "/"
|
|
|
|
for template in a:template_list
|
|
|
|
let prefix = template[0]
|
|
|
|
let suffix = template[1]
|
|
|
|
let full_template_path = file_path . prefix . file_name . suffix
|
|
|
|
call delete(full_template_path, "rf")
|
|
|
|
endfor
|
|
|
|
endfunction
|
|
|
|
|
2020-03-29 12:23:44 +00:00
|
|
|
" Initiate LaTeX file compilation at the start and auto clean up.
|
2019-08-15 03:50:33 +00:00
|
|
|
augroup vimtex_events
|
|
|
|
au!
|
|
|
|
" auto-clean
|
2019-09-14 12:58:12 +00:00
|
|
|
au User QuitPre call VimtexAdditionalCleanup(template_list)
|
|
|
|
au User VimLeave call VimtexAdditionalCleanup(template_list)
|
2019-08-15 03:50:33 +00:00
|
|
|
au User VimtexEventQuit call vimtex#compiler#clean(1)
|
|
|
|
au User VimtexEventQuit call VimtexAdditionalCleanup(template_list)
|
2019-08-21 12:33:45 +00:00
|
|
|
|
2020-03-29 12:23:44 +00:00
|
|
|
" Auto-compile
|
2019-08-15 03:50:33 +00:00
|
|
|
au User VimtexEventInitPost call vimtex#compiler#compile()
|
|
|
|
augroup END
|