Last active
June 5, 2024 11:48
-
-
Save TheCedarPrince/7b9b51af4c146880f17c39407815b594 to your computer and use it in GitHub Desktop.
My (neo)Vim Configuration File
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" VIM SETTINGS | |
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" TURNS LINE NUMBERING ON | |
set nu | |
" TRIGGER `autoread` WHEN FILES CHANGES ON DISK | |
set autoread | |
autocmd FocusGained,BufEnter,CursorHold,CursorHoldI * if mode() != 'c' | checktime | endif | |
" PLACE THE CURSOR ANYWHERE | |
set virtualedit=all | |
" ENABLES A SYSTEM-WIDE VIMRC | |
set nocompatible | |
" ENSURES DEFVAULT VIM SYNTAX HIGHLIGHTING | |
syntax on | |
" ENABLE MOUSE USE IN ALL MODES | |
set mouse=a | |
" ENABLES SPELLCHECK | |
set spell | |
" ENABLE SAVING OF TAB TITLES FOR SESSIONS | |
set sessionoptions+=tabpages,globals | |
set encoding=utf-8 | |
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" PLUGINS | |
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" ENABLES PLUGINS TO WORK | |
filetype plugin on | |
" LOCATION OF WHERE PLUGINS ARE INSTALLED | |
call plug#begin('~/.vim/addons') | |
" Git gutter for Vim | |
Plug 'airblade/vim-gitgutter' | |
" Preview markdown on your modern browser with synchronised scrolling and flexible configuration. | |
Plug 'iamcco/markdown-preview.nvim', { 'do': { -> mkdp#util#install() } } | |
" Highlight lines in buffer | |
" Plug 'junegunn/limelight.vim' | |
" Distraction free writing | |
Plug 'junegunn/goyo.vim' | |
" Terminal in floating window | |
Plug 'voldikss/vim-floaterm' | |
" Vim test snippets | |
Plug 'SirVer/ultisnips' | |
Plug 'honza/vim-snippets' | |
" Automatic pane resizing | |
" Plug 'camspiers/lens.vim' | |
" Support for Julia | |
Plug 'JuliaEditorSupport/julia-vim' | |
" Formatting Julia Files | |
Plug 'kdheepak/JuliaFormatter.vim' | |
" Formatting of HTML, JS, CSS, JSON, and JSX Files | |
Plug 'maksimr/vim-jsbeautify' | |
" Adding support for LaTeX | |
Plug 'lervag/vimtex' | |
" Live Previewing of LaTeX Documents | |
Plug 'xuhdev/vim-latex-live-preview', { 'for': 'tex' } | |
" Moving through Vim easily | |
Plug 'easymotion/vim-easymotion' | |
" Command line fuzzy finder | |
Plug 'junegunn/fzf', { 'do': './install --bin' } "Checks latest fzf binary | |
Plug 'junegunn/fzf.vim' | |
" The fancy start screen for Vim | |
Plug 'mhinz/vim-startify' | |
" Effective search and listing of queries | |
Plug 'dyng/ctrlsf.vim' | |
" Easy commenting for Vim | |
Plug 'preservim/nerdcommenter' | |
" Support for Todo.txt files | |
Plug 'dbeniamine/todo.txt-vim' | |
" Formatting for SQL scripts | |
Plug 'mattn/vim-sqlfmt' | |
" Gruvbox color theme for Vim | |
Plug 'morhetz/gruvbox' | |
" Window swapping powers | |
Plug 'wesQ3/vim-windowswap' | |
" Editing Jupyter files in Vim | |
Plug 'goerz/jupytext.vim' | |
" BibTeX Handling | |
Plug 'vim-pandoc/vim-pandoc' | |
Plug 'vim-pandoc/vim-pandoc-syntax' "Also used for Markdown formatting | |
" Better Outliner - I cannot stand the TOC from pandoc! | |
Plug 'vim-voom/VOoM' | |
" VIM Table Mode for instant table creation. | |
Plug 'dhruvasagar/vim-table-mode' | |
" Deoplete Completion framework | |
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 | |
" Deoplete word autocompletion | |
Plug 'deathlyfrantic/deoplete-spell' | |
" Tab naming powers | |
Plug 'gcmt/taboo.vim' | |
" Multiple cursors for editing | |
Plug 'mg979/vim-visual-multi' | |
" Adds file type icons to Vim plugins | |
Plug 'ryanoasis/vim-devicons' | |
" Distraction-free writing in Vim | |
Plug 'junegunn/goyo.vim' | |
" Vim session saving | |
Plug 'tpope/vim-obsession' | |
" Rethinking Vim as a tool for writing | |
Plug 'reedes/vim-pencil' | |
" Small scratch space for fleeting notes | |
Plug 'mtth/scratch.vim' | |
" Lean & mean status/tabline for vim that's light as air | |
Plug 'vim-airline/vim-airline' | |
Plug 'vim-airline/vim-airline-themes' "Installs themes for airline | |
call plug#end() | |
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" PLUGIN SETTINGS | |
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
""""""""""""""""""""" | |
"JULIA FORMATTER | |
""""""""""""""""""""" | |
let g:JuliaFormatter_options = { | |
\ 'indent' : 4, | |
\ 'margin' : 92, | |
\ 'always_for_in' : v:false, | |
\ 'whitespace_typedefs' : v:false, | |
\ 'whitespace_ops_in_indices' : v:true, | |
\ } | |
""""""""""""""""""""" | |
" VIM VISUAL MULTI | |
""""""""""""""""""""" | |
let g:VM_maps = {} | |
let g:VM_maps["Add Cursor Down"] = '<C-j>' | |
let g:VM_maps["Add Cursor Up"] = '<C-k>' | |
""""""""""""""""""""" | |
" VIM VISUAL MULTI | |
""""""""""""""""""""" | |
let g:UltiSnipsSnippetDirectories=["UltiSnips", "my_snippets"] | |
""""""""""""""""" | |
"MARKDOWN-PREVIEW | |
""""""""""""""""" | |
" ${name} will be replace with the file name | |
let g:mkdp_page_title = '「${name}」' | |
let g:mkdp_preview_options = { | |
\ 'mkit': {}, | |
\ 'katex': {}, | |
\ 'uml': {}, | |
\ 'maid': {}, | |
\ 'disable_sync_scroll': 0, | |
\ 'sync_scroll_type': 'middle', | |
\ 'hide_yaml_meta': 1, | |
\ 'sequence_diagrams': {}, | |
\ 'flowchart_diagrams': {} | |
\ } | |
let g:mkdp_browser = 'vivaldi' | |
""""""""""""""""""""" | |
" CTRLSF | |
""""""""""""""""""""" | |
let g:ctrlsf_preview_position = 'inside' | |
let g:ctrlsf_position = 'right' | |
let g:ctrlsf_auto_preview = 1 | |
let g:ctrlsf_default_root = 'project+ww' | |
let g:ctrlsf_winsize = '20%' | |
let g:ctrlsf_context = '-C 1' | |
""""""""""""""""""""" | |
" LIMELIGHT | |
""""""""""""""""""""" | |
" autocmd! User GoyoEnter Limelight | |
" autocmd! User GoyoLeave Limelight! | |
""""""""""""""""""""" | |
" GOYO | |
""""""""""""""""""""" | |
let g:goyo_height = 80 | |
let g:goyo_width = 80 | |
""""""""""""""""""""" | |
" AIRLINE | |
""""""""""""""""""""" | |
" Enabling Powerline symbols | |
let g:airline_powerline_fonts = 1 | |
" Allows word counting in the following filetypes | |
let g:airline#extensions#wordcount#filetypes = '\vasciidoc|help|mail|markdown|pandoc|org|rst|tex|text' | |
" Shows all buffers when only one tab open | |
let g:airline#extensions#tabline#enabled = 0 | |
" Removes fileformat | |
let g:airline_section_y = '' | |
" Removes section on whitespace errors, etc. | |
let g:airline_section_warning = '' | |
" Disable SPELL section | |
let g:airline_detect_spell = 0 | |
" Handles file path displays | |
let g:airline#extensions#tabline#formatter = 'unique_tail_improved' | |
" Sets theme for airline | |
let g:airline_theme='gruvbox' | |
"""""""""""""""""""""""""""""" | |
" VIM-JSBEAUTIFY | |
"""""""""""""""""""""""""""""" | |
".vimrc | |
autocmd FileType javascript noremap <buffer> <c-f> :call JsBeautify()<cr> | |
" for json | |
autocmd FileType json noremap <buffer> <c-f> :call JsonBeautify()<cr> | |
" for jsx | |
autocmd FileType jsx noremap <buffer> <c-f> :call JsxBeautify()<cr> | |
" for html | |
autocmd FileType html noremap <buffer> <c-f> :call HtmlBeautify()<cr> | |
" for css or scss | |
autocmd FileType css noremap <buffer> <c-f> :call CSSBeautify()<cr> | |
"""""""""""""""""""""""""""""" | |
" JUPYTEXT | |
"""""""""""""""""""""""""""""" | |
let g:jupytext_filetype_map = { 'py': 'python' } | |
"""""""""""""""""""""""""""""" | |
" VIMPENCIL | |
"""""""""""""""""""""""""""""" | |
" Automatically enable Pencil for files | |
augroup pencil | |
autocmd! | |
autocmd FileType py call pencil#init({'wrap' : 'soft'}) | |
autocmd FileType markdown call pencil#init({'wrap' : 'soft'}) | |
autocmd FileType julia call pencil#init({'wrap' : 'soft'}) | |
autocmd FileType tex call pencil#init({'wrap' : 'soft'}) | |
autocmd FileType ctrlsf call pencil#init({'wrap' : 'soft'}) | |
autocmd FileType voomtree call pencil#init({'wrap' : 'soft'}) | |
augroup END | |
"""""""""""""""""""""""""""""" | |
" GRUVBOX | |
"""""""""""""""""""""""""""""" | |
let g:gruvbox_termcolors=16 | |
let g:gruvbox_contrast_dark = 'medium' | |
colorscheme gruvbox | |
set background=dark " Setting dark mode | |
" Making comments italic | |
highlight Comment cterm=italic | |
"""""""""""""""""""""""""""""" | |
" TODOTXT-VIM | |
"""""""""""""""""""""""""""""" | |
let g:Todo_txt_prefix_creation_date=1 | |
let g:Todo_fold_char='+' | |
let g:TodoTxtForceDoneName='Done.txt' | |
" Autocompletion | |
au filetype todo setlocal omnifunc=todo#Complete | |
au filetype todo imap <buffer> + +<C-X><C-O> | |
au filetype todo imap <buffer> @ @<C-X><C-O> | |
"""""""""""""""""""""""""""""" | |
" VIM-GITGUTTER | |
"""""""""""""""""""""""""""""" | |
set updatetime=250 | |
let g:gitgutter_max_signs = 500 | |
let g:gitgutter_override_sign_column_highlight = 0 | |
highlight clear SignColumn | |
highlight GitGutterAdd ctermfg=2 | |
highlight GitGutterChange ctermfg=3 | |
highlight GitGutterDelete ctermfg=1 | |
highlight GitGutterChangeDelete ctermfg=4 | |
"""""""""""""""""""""""""""""" | |
" TABULAR & VIM-MARKDOWN | |
"""""""""""""""""""""""""""""" | |
let g:vim_markdown_folding_level = 1 | |
"""""""""""""""""""""""""""""" | |
" VIM-PANDOC | |
"""""""""""""""""""""""""""""" | |
let g:pandoc#filetypes#handled = ['pandoc', 'markdown'] | |
let g:pandoc#modules#disabled = ['folding', 'toc'] | |
let g:pandoc#folding#fold_fenced_codeblocks = 1 | |
let g:pandoc#folding#fold_yaml = 1 | |
let g:pandoc#biblio#bibs = ['/home/src/Knowledgebase/Zettelkasten/zettel.bib', '/home/src/Projects/C3T/citations.bib'] | |
let g:pandoc#toc#close_after_navigating = 0 | |
let g:pandoc#toc#position = 'left' | |
let g:pandoc#toc#shift = 0 | |
let g:pandoc#folding#fdc = 0 | |
"""""""""""""""""""""""""""""" | |
" VIM-PANDOC-SYNTAX | |
"""""""""""""""""""""""""""""" | |
let g:pandoc#syntax#conceal#blacklist = ['strikeout', 'list', 'quotes'] | |
"""""""""""""""""""""""""""""" | |
" DEOPLETE | |
"""""""""""""""""""""""""""""" | |
" Turns on Deoplete at start-up of Vim | |
let g:deoplete#enable_at_startup = 1 | |
" Chooses backend for bibtex autocompletion | |
"let g:pandoc#completion#bib#mode = 'citeproc' | |
" Disables autocompletion while writing | |
"call deoplete#custom#option('auto_complete', v:false) | |
" Enables omnicompletion of citation keys | |
call deoplete#custom#var('omni', 'input_patterns', { | |
\ 'pandoc': '@' | |
\}) | |
" Enables deoplete for tex files | |
call deoplete#custom#var('omni', 'input_patterns', { | |
\ 'tex': g:vimtex#re#deoplete | |
\}) | |
"""""""""""""""""""""""""""""" | |
" FZF-VIM | |
"""""""""""""""""""""""""""""" | |
let $FZF_DEFAULT_OPTS='--reverse' | |
let g:fzf_layout = { 'window': { 'width': 0.8, 'height': 0.8 } } | |
let g:fzf_action = { | |
\ 'ctrl-t': 'tab split', | |
\ 'ctrl-x': 'split', | |
\ 'ctrl-v': 'vsplit', | |
\ 'ctrl-o': ':r !echo', | |
\ } | |
"""""""""""""""""""""""""""""" | |
" VIM-TEX | |
"""""""""""""""""""""""""""""" | |
let g:tex_flavor='latexmk' | |
let g:vimtex_view_general_viewer = 'okular' | |
let g:vimtex_view_general_options = '--unique file:@pdf\#src:@line@tex' | |
let g:vimtex_view_general_options_latexmk = '--unique' | |
let g:vimtex_quickfix_mode=0 | |
let g:vimtex_fold_enabled = 1 | |
let g:vimtex_fold_types = { | |
\ 'preamble' : {'enabled' : 1}, | |
\ 'sections' : {'enabled' : 0}, | |
\ 'envs' : { | |
\ 'blacklist' : ['figures'], | |
\ }, | |
\} | |
"""""""""""""""""""""""""""""" | |
" VIM-LATEX-LIVE-PREVIEW | |
"""""""""""""""""""""""""""""" | |
let g:livepreview_previewer = 'zathura' | |
let g:livepreview_use_biber = 1 | |
"""""""""""""""""""""""""""""" | |
" VIM-FLOATERM | |
"""""""""""""""""""""""""""""" | |
let g:floaterm_open_command = 'vsplit' | |
"""""""""""""""""""""""""""""" | |
" LENS | |
"""""""""""""""""""""""""""""" | |
let g:lens#disabled_filetypes = ['nerdtree', 'fzf', 'voomtree'] | |
"""""""""""""""""""""""""""""" | |
" VIM-TABLE-MODE | |
"""""""""""""""""""""""""""""" | |
let g:table_mode_corner = "|" | |
let g:table_mode_align_char = ":" | |
function! s:isAtStartOfLine(mapping) | |
let text_before_cursor = getline('.')[0 : col('.')-1] | |
let mapping_pattern = '\V' . escape(a:mapping, '\') | |
let comment_pattern = '\V' . escape(substitute(&l:commentstring, '%s.*$', '', ''), '\') | |
return (text_before_cursor =~? '^' . ('\v(' . comment_pattern . '\v)?') . '\s*\v' . mapping_pattern . '\v$') | |
endfunction | |
inoreabbrev <expr> <bar><bar> | |
\ <SID>isAtStartOfLine('\|\|') ? | |
\ '<c-o>:TableModeEnable<cr><bar><space><bar><left><left>' : '<bar><bar>' | |
inoreabbrev <expr> __ | |
\ <SID>isAtStartOfLine('__') ? | |
\ '<c-o>:silent! TableModeDisable<cr>' : '__' | |
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" VIM FUNCTIONS | |
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" code/string searching tool for multifile exploration | |
let g:ackprg = 'ag --nogroup --nocolor --column' | |
function! TwiddleCase(str) | |
if a:str ==# toupper(a:str) | |
let result = tolower(a:str) | |
elseif a:str ==# tolower(a:str) | |
let result = substitute(a:str,'\(\<\w\+\>\)', '\u\1', 'g') | |
else | |
let result = toupper(a:str) | |
endif | |
return result | |
endfunction | |
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" KEY REMAPS | |
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" Enables ripgrep for file completion via fzf | |
inoremap <expr> <c-x><c-f> fzf#vim#complete#path('rg --files') | |
" Maps leader to the spacebar | |
map <Space> <Leader> | |
nnoremap <silent> <F9> :FloatermNew --height=0.4 --width=0.98 --wintype=floating --position=bottom --autoclose=2 --title= | |
tnoremap <silent> <F9> <C-\><C-n>:FloatermNew --height=0.4 --width=0.98 --wintype=floating --position=bottom --autoclose=2 --title= | |
nnoremap <silent> <F8> :FloatermPrev<CR> | |
tnoremap <silent> <F8> <C-\><C-n>:FloatermPrev<CR> | |
nnoremap <silent> <F10> :FloatermNext<CR> | |
tnoremap <silent> <F10> <C-\><C-n>:FloatermNext<CR> | |
inoremap <silent> <F11> <C-c>:FloatermToggle<CR> | |
nnoremap <silent> <F11> :FloatermToggle<CR> | |
tnoremap <silent> <F11> <C-\><C-n>:FloatermToggle<CR> | |
tnoremap <silent> <M-o> <C-\><C-n><CR> | |
nnoremap <C-c><C-c> :FloatermSend<CR> | |
vnoremap <C-c><C-c> :FloatermSend<CR> | |
" Maps easymotion jumps for lines | |
map <leader><space>l <Plug>(easymotion-bd-jk) | |
nmap <leader><space>l <Plug>(easymotion-overwin-line) | |
" Maps easymotion jumps for words | |
map <leader><Space>w <Plug>(easymotion-bd-w) | |
nmap <leader><Space>w <Plug>(easymotion-overwin-w) | |
" Maps Ranger | |
nnoremap <silent> <F7> :RnvimrToggle<CR> | |
tnoremap <silent> <F7> <C-\><C-n>:RnvimrToggle<CR> | |
" Automatic formatting for Julia files | |
autocmd FileType julia nnoremap <buffer> <c-f> :JuliaFormatterFormat<cr> | |
" Automatic formatting for SQL files | |
autocmd FileType sql nnoremap <buffer> <c-f> :SQLFmt<cr> | |
" Maps quit | |
noremap <leader>q :q<cr> | |
" Maps quit all | |
noremap <c-q> :qa<cr> | |
" Maps write | |
nnoremap <leader>w :w<cr> | |
" Maps ripgrep file searching function | |
nnoremap <C-g> :Rg<Cr> | |
" Maps display of current buffers | |
nnoremap <C-b> :Buffers<Cr> | |
" Deselects currently highlighted searches | |
nnoremap <Leader><BS> :noh<cr> | |
" Activates Twiddle case to switch between cases of selected text | |
vnoremap ~ y:call setreg('', TwiddleCase(@"), getregtype(''))<CR>gv""Pgv | |
" Mappings for venn | |
vnoremap <leader>g :VBox<CR> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks @JackyYin ! I try to make it as easy as possible to understand because as some point, I will forget how things work. So, I need to make them understandable and well documented such that anyone could understand them!