" Personal vimrc config file. " Last Changed: 2019-01-27 " Author: Federico Igne <> " License: This file is placed in the public domain. " {{{1 GENERAL SETTINGS " Don't open Vim in vi-compatibility mode. " Note: this is implicit when a user .vimrc file is detected. " set nocompatible " Set encoding to utf8. if has('multi_byte') set encoding=utf8 endif " Enable modeline capabilities set modeline " Set file format to `unix' (set newline encoding to ). set fileformat=unix " May use `dos' file format if is detected as newline " encoding. set fileformats=unix,dos " Automatically update a file whenever it is detected to have been " changed outside of Vim. " NOTE: you need something like " https://github.com/tmux-plugins/vim-tmux-focus-events " in order for autoread to work in terminal Vim. set autoread " Automatically save changes when switching buffers (and some other " commands). Use `autowriteall` if you want the hardcore version. set autowrite " A buffer becomes hidden when it is abandoned. set hidden " Do not redraw the screen while executing macros or other (not explicitly " typed) commands. This speeds up the iteration of macros and avoids " screen flickering/lag. set lazyredraw " If in `&updatetime` milliseconds nothing is typed the swap file will " be written to disk. Also used for the `CursorHold` autocommand event. set updatetime=2000 " Reduce the time Vim will try to recognize commands consisting of " a sequence of keys. In particular `timeoutlen` is the timeout for " mappings, `ttimeoutlen` is the timeout for key codes (like ). set timeoutlen=2000 ttimeoutlen=100 " Remove beep or visual effect on errors. set noerrorbells set novisualbell t_vb= " {{{1 COLORS/INTERFACE " Cursor shape: " * set cursor to a steady block in normal mode; " * set cursor to a blinking underline in insert mode. " Possible values: " 0 -> blinking block. " 1 -> blinking block (default). " 2 -> steady block. " 3 -> blinking underline. " 4 -> steady underline. " 5 -> blinking bar (xterm). " 6 -> steady bar (xterm). let &t_EI = "\[2 q" let &t_SI = "\[3 q" " Resets cursor to terminal default augroup stCursor autocmd! autocmd VimLeave * silent !echo -ne "\e[6 q" augroup END " Leave n lines above/below cursor when scrolling. " If set to a very large value the cursor line will always be in the " middle of the window (except at the start or end of the file). set scrolloff=999 " Leave n chars on the left/right of the cursor when scrolling. " If set to a very large value the cursor will always be in the " middle of the window (except when close to the beginning of the line). set sidescrolloff=20 " Remove numbers. `Hybrid' number mode (show relative numbers with " current line on cursor position) can be toggles with `in` set nonumber norelativenumber " Show typed command on the right side of the status bar. if has('cmdline_info') set showcmd endif " Do not show current mode in status bar. Basically remove the " "-- INSERT --" status string, which is redundant when using a " statusline plugin. set noshowmode " Use true colors or fall back to 256 colors. if has('termguicolors') " Use 'guifg' and 'guibg' attributes in the terminal (true color). set termguicolors " Necessary escape codes " https://www.reddit.com/r/vim/comments/5416d0/true_colors_in_vim_under_tmux/ let &t_8f = "\[38;2;%lu;%lu;%lum" let &t_8b = "\[48;2;%lu;%lu;%lum" else set t_Co=256 endif " Any modification to the highlights groups needs to be done here, " before setting the colorsheme. This is because most colorschemes clear " the highlight groups before setting them... this includes groups like " User1-9. Setting this hook, it's possible to set custom colors " everytime a colorscheme is reloaded. function! CustomColors() "" Italics comments " NOTE: that the terminal must support italics for this option to work highlight Comment cterm=italic "" Statusline highlight clear StatusLine highlight clear StatusLineNC highlight clear StatusLineTerm highlight clear StatusLineTermNC highlight StatusLine ctermfg=248 ctermbg=239 guifg=#bdae93 guibg=#504945 highlight StatusLineNC ctermbg=237 ctermfg=246 guibg=#3c3836 guifg=#a89984 highlight StatusLineTerm ctermfg=248 ctermbg=239 guifg=#bdae93 guibg=#504945 highlight StatusLineTermNC ctermfg=08 ctermbg=237 guifg=#665c54 guibg=#3c3836 highlight User1 cterm=bold gui=bold ctermfg=248 ctermbg=239 guifg=#bdae93 guibg=#504945 highlight User2 cterm=italic gui=italic ctermfg=248 ctermbg=239 guifg=#bdae93 guibg=#504945 highlight User3 cterm=bold gui=bold ctermfg=237 ctermbg=248 guifg=#3c3836 guibg=#bdae93 " Search matches " highlight clear IncSearch " highlight IncSearch ctermfg=00 ctermbg=03 guifg=#282828 guibg=#fabd2f " highlight Search cterm=underline ctermbg=00 ctermfg=03 guibg=#282828 guifg=#fabd2f " Guides " highlight ColorColumn ctermbg=237 guibg=#3c3836 highlight LineNr cterm=NONE ctermbg=237 gui=NONE guibg=#3c3836 " Visual highlight clear Visual highlight Visual ctermbg=239 guibg=#504945 " Errors " Default highlight for errors is `reverse`d which looks terrible. highlight clear Error highlight clear ErrorMsg highlight Error cterm=bold term=bold ctermbg=00 ctermfg=01 guibg=#282828 guifg=#fb4934 highlight link Errormsg Error " LSP signs and highlights. highlight LspErrorText cterm=bold gui=bold ctermbg=237 ctermfg=01 guibg=#3c3836 guifg=#cc241d highlight link LspErrorHighlight Error highlight LspWarningText cterm=bold gui=bold ctermbg=237 ctermfg=03 guibg=#3c3836 guifg=#d79921 highlight LspWarningHighlight cterm=bold gui=bold ctermbg=00 ctermfg=03 guibg=#282828 guifg=#d79921 highlight LspInformationText cterm=bold gui=bold ctermbg=237 ctermfg=08 guibg=#3c3836 guifg=#928374 highlight LspInformationHighlight cterm=bold gui=bold ctermbg=00 ctermfg=07 guibg=#282828 guifg=#a89984 highlight link LspHintText LspInformationText highlight link LspHintHighlight LspInformationHighlight " Spelling highlight clear SpellBad highlight clear SpellCap highlight clear SpellLocal highlight clear SpellRare highlight SpellBad cterm=underline gui=underline ctermbg=00 ctermfg=01 guibg=#282828 guifg=#cc241d highlight SpellCap cterm=underline gui=underline ctermbg=00 ctermfg=03 guibg=#282828 guifg=#d79921 highlight SpellLocal cterm=underline gui=underline ctermbg=00 ctermfg=04 guibg=#282828 guifg=#458588 highlight link SpellRare SpellLocal endfunction augroup CustomColors autocmd! autocmd ColorScheme * call CustomColors() augroup END " Also you need to teach Vim the terminal escape sequences for " italics (insert '^[' with in Insert mode) set t_ZH= set t_ZR= " Set colorscheme to gruvbox dark set background=dark colorscheme gruvbox " Display whitespaces with some flavour set list " Remove eol default symbol set listchars= " Highlight eol (maybe consider moving this on specific filetypes that " use soft wrapping, to avoid too much noise) set listchars+=eol:¬ " Make tabs a bit more visible set listchars+=tab:├─ " Highlight trailing spaces set listchars+=trail:· " Last/first character when the current line is longer that the window " width set listchars+=extends:»,precedes:« " {{{1 STATUSLINES if has('statusline') " Always show the statusline. set laststatus=2 " Custom mode flags. let g:modeFlag={ \ 'n' : 'N', \ 'no' : 'N·Operator Pending', \ 'v' : 'V', \ 'V' : 'V·Line', \ '' : 'V·Block', \ 's' : 'S', \ 'S' : 'S·Line', \ '' : 'S·Block', \ 'i' : 'I', \ 'ic' : 'I·Compl', \ 'ix' : 'I·XCompl', \ 'R' : 'R', \ 'Rc' : 'R·Compl', \ 'Rv' : 'R·Virtual', \ 'Rx' : 'R·XCompl', \ 'c' : 'C', \ 'cv' : 'E·Vim ', \ 'ce' : 'E', \ 'r' : 'Prompt', \ 'rm' : 'More', \ 'r?' : 'Confirm', \ '!' : 'Shell', \ 't' : 'T' \} " Custom flag by name (overrides the mode flag). let g:nameFlag={ \ '[Grammarous]' : 'Grammar' \} " Custom filetype flags (overrides the mode flag). let g:filetypeFlag={ \ 'help' : 'Help', \ 'qf' : 'QFix', \ 'netrw' : 'Netrw', \ 'fugitive' : 'Gstatus', \ 'tagbar' : 'TagBar', \ 'gitcommit' : 'Gcommit' \} " Special flags (overrides previous flags). " Currently support: " 'preview': displayed for a preview window. let g:specialFlag={ \ 'preview' : 'Preview' \} " Some elements will be hidden if the window width falls below " `g:fullstatusline` (namely relative path, git statistics, some " file flags). let g:fullstatusline=81 " Resets statusline set statusline= " Overrides hl-User3 if buffer is modified set statusline+=%{dyamon#statusline#setcolor()} " Mode flag. set statusline+=%3*\ %{dyamon#statusline#modeflag()}\ " Start truncate from here set statusline+=%< " Relative filename. set statusline+=%*\ %{dyamon#statusline#fileprefix()}%1*%t " Left/right separator set statusline+=%= " Git info (if Fugitive and GitGutter are available) set statusline+=\ %*%{dyamon#statusline#gitinfo()} " Zettel info (if relevant) set statusline+=%{zettel#status()} set statusline+=[ " Various flags and metadata. In order: " * modified/modifiable flag set statusline+=%M " * readonly flag set statusline+=%R " * session flag set statusline+=%{dyamon#statusline#session()} " * filetype set statusline+=%{dyamon#statusline#filetype()} " * file encoding set statusline+=%{dyamon#statusline#fileenc()} set statusline+=]\ " / set statusline+=%3*\ %3l/%L " / set statusline+=:%2c/%2{len(getline('.'))} " set statusline+=\ [%P] " language server indicator set statusline+=%{dyamon#statusline#lsp()} endif set tabline=%!dyamon#statusline#tabline() " {{{1 SEARCH/COMPLETION " Set highlighting for search results. Also search results are " dynamically highlighted. if has('extra_search') set hlsearch incsearch endif " Case-insensitive when searching; case-sensitive only if search string " includes a capital letter. set ignorecase set smartcase " Don't echo search wrap messages. set shortmess+=s " Basically enables a fuzzy-finder in command mode. Completion via " in command mode search in the whole subtree of the pwd. set path+=** if has("wildmenu") " Turn on wildmenu (a nice multi-option menu). set wildmenu " Hitting will first complete the longest common prefix; hit " again for a complete list of possible completions (cicle through " them with ). set wildmode=longest:full,full " File patterns ignored during completion. set wildignore+=*.o,*~ " Java/Scala compilation files set wildignore+=*.class endif " Options for Insert mode completion: " + menuone: display popup menu when there is only one match; " + longest only insert the longest common text of the matches; " + preview: show extra information about the currently selected " completion in the preview window. set completeopt=longest,menuone,preview " {{{1 SPELL CHECKING if has("syntax") " Use double method to compute suggestions (takes into account both " syntax errors and words with a similar sound - useful if English " is not your first language). set spellsuggest=double,15 set spelllang=en_gb endif " {{{1 WINDOWS if has('windows') " When using `:[v]split' (or any command including it) the buffer is " opened below/right. set splitbelow splitright endif " {{{1 EDITING " Turn off soft wrap set nowrap " Set hard wrap to 72 columns. Control what is affected by this option " with `formatoptions`. set textwidth=72 " DEFAULT: formatoptions=tcq " t Auto-wrap text using textwidth " c Auto-wrap comments using textwidth, insert the current comment " leader automatically. " q Allow formatting of comments with "gq". " j Where it makes sense, remove a comment leader when joining " lines. " l Long lines are not broken in insert mode: When a line was longer " than 'textwidth' when the insert command started, Vim does not " automatically format it. set formatoptions+=jl " Here is assumed most of the time I'm editing code so I want auto-wrap " turned on for comments but not for code. If editing prose, use a " ftplugin with `setlocal formatoptions+=t` set formatoptions-=t " Do not insert two spaces after a `.`, `?` and `!` with a join command set nojoinspaces " Turn tabs into spaces but still keep some advantages of tabs set expandtab smarttab " Set number of spaces a tab counts for, and the number of spaces used " per (auto)indent step set tabstop=4 set shiftwidth=0 " fallback to `tabstop` " Maintain indentation from previous line. Also activate some smart " C-like auto-indenting features. For more advanced indentation use " `indentexpr`. set autoindent if has("smartindent") set smartindent endif " Show matching bracket (briefly jumping for 0.n seconds) set showmatch matchtime=2 " Add new matching bracket <,>. " Required by mortimer.vim plugin set matchpairs+=<:> " Allow backspacing over in insert mode (eol), start of insert " (start), autoindentation (indent). set bs=start,eol,indent " Removes and from the default `whichwrap` list, preventing " them from moving to the next/previous line when on the first/last " character of a line. " Motivation: " * : is the leader key; " * : why would you use backspace? set whichwrap= " Fold related options. if has('folding') " Default folding method is explicit with markers {{{,}}}. set foldmethod=marker " Override default `foldtext` with something like: " »··[42ℓ]··TITLE··················································· set fillchars+=fold:· set foldtext=CustomFoldText() function! PadNumber(n, pad_to) abort let l:padding = '' let l:pad_to = a:pad_to while (l:pad_to > 0) if (a:n < pow(10,l:pad_to)) let l:padding .= ' ' endif let l:pad_to -= 1 endwhile return l:padding . a:n endfunction function! CustomFoldText() abort let l:middot='··' let l:start='»' let l:italicsl='ℓ' let l:lines='[' . PadNumber(v:foldend - v:foldstart + 1, 2) . l:italicsl . ']' let l:prefix=substitute(&commentstring,'%s',' ','') let l:first=substitute(substitute(substitute(getline(v:foldstart), '\v *', '', ''),'{{{\d','','g'),l:prefix,'','') let l:dashes=substitute(v:folddashes, '-', l:middot, 'g') return l:start . l:middot . l:lines . l:dashes . l:middot . l:first endfunction endif if has('virtualedit') " Allow visual-block selection to exceed text boundaries set virtualedit=block endif " {{{1 POLLUTION " Backup files (defaults: 'backup' off, 'writebackup' on if available) if $USER ==# 'root' " This is done to avoid backups for files that might contain " sensible information. set nobackup nowritebackup elseif has('writebackup') " Backup file is created *while* writing a file, and deleted " afterwards. This gives you a backup when something goes wrong " during a write operation. set nobackup writebackup else " Keep a backup for each file. set backup endif " Have a look at the help for an explanation on the definition of " `backupdir` and `directory` set backupdir=~/.local/share/vim/backup//,. " Swap files ('swapfile' on) if $USER ==# 'root' " This is done to avoid swap files that might contain sensible " information. set noswapfile else " Create swapfiles for any buffer (default). set swapfile endif set directory=~/.local/share/vim/swap//,. " Undo files ('undofile' off) if has('persistent_undo') && $USER !=# 'root' " Persist undo tree in a file and restore it when reading a file. " Avoiding this for `root` user to prevent sensible information to " appear in undo files. set undodir=~/.local/share/vim/undo//,. set undofile endif if has('viminfo') if $USER ==# 'root' " `viminfo` is reset for `root` user to avoid storing sensible " information. set viminfo= else " Save marks for at most 100 files (include {jump,change}list). set viminfo='100 " Don't save search history set viminfo+=/0 " Save 100 lines of command history set viminfo+=:100 " Save at most 500 lines per register. set viminfo+=<200 " Don't save anything about the input-line history set viminfo+=@0 " Save file marks (A-Z and 0-9). set viminfo+=f1 " Do not highlight last search pattern when loading the viminfo " file. set viminfo+=h if isdirectory($HOME . '/.local/share/vim') set viminfofile=~/.local/share/vim/viminfo else set viminfofile=~/.viminfo endif endif endif " Session files " Stored in $VIM_SESSIONS=~/.local/share/vim/sessions " NOTE: these options are provided here just in case TPope's " `vim-obsession` plugin is not available (`-=` is idempotent anyway) if has('mksession') " Don't save global options and mappings in session files (`vimrc` " file is sourced anyway right?) set sessionoptions-=options " Don't save empty windows set sessionoptions-=blank " Create tab-specific sessions set sessionoptions-=tabpages endif " {{{1 AUTOCMDS augroup focus autocmd! " Focused window has guides and a statusbar autocmd BufEnter,FocusGained,VimEnter,WinEnter,BufWinEnter * call dyamon#guides#on() autocmd BufEnter,FocusGained,VimEnter,WinEnter,BufWinEnter * call dyamon#statusline#focus() " Unfocused windows do not have guides and the statusbar is blurred autocmd WinLeave,FocusLost * call dyamon#guides#off() autocmd WinLeave,FocusLost * call dyamon#statusline#blur() " Exceptions " TODO here 0/1 as true/false are all messed up! autocmd Filetype help let b:guides=1 autocmd Filetype netrw let b:guides=1 autocmd Filetype qf let b:guides=1 autocmd Filetype gitcommit let b:guides=1 autocmd Filetype tagbar let b:guides=1 autocmd Filetype tagbar let b:disable_statusline=1 augroup END augroup filetypes autocmd! autocmd BufRead,BufNewFile *.tex set filetype=tex autocmd BufRead,BufNewFile *.ms set filetype=groff autocmd BufRead,BufNewFile *.man set filetype=groff augroup END augroup mutt autocmd! autocmd BufRead,BufNewFile $TMPDIR/mutt* :Goyo 75% augroup END " {{{1 PLUGINS " List of installed plugins, along with their custom configuration. " " Plugins are managed via Git Submodules; have a look at this for more " details: " " https://gist.github.com/manasthakur/d4dc9a610884c60d944a4dd97f0b3560 " " Add a new submodule/plugin: " " git submodule add --name " " Update all submodules/plugins: " " git submodule foreach git pull origin master " " NOTE: remember to generate help tags for the newly installed plugins. " The easiest way is using: " " :helptags ALL " " also bound to `hg` (Help tags Generate) " {{{2 FZF " https://github.com/junegunn/fzf.vim " {{{2 GOYO " https://github.com/junegunn/goyo.vim ~/.vim/bundle/goyo.vim " Fixed height to 80% fo the window. let g:goyo_height="80%" " Custom autocmds to hide the statusline, interact with Tmux, and change " some colors. augroup GoyoOptions autocmd! autocmd User GoyoEnter nested call dyamon#goyo#enter() autocmd User GoyoLeave nested call dyamon#goyo#leave() augroup END " {{{2 MATCHIT " Matching extends the capabilities of `%`. It's an optional plugin " shipped with Vim. " {{{2 NETRW " Hides dotfiles by default when opening the file explorer. " NB: toggle dotfiles visibility with `gh'. " NB: when editing a dotfile this option is disabled by default. let g:netrw_list_hide = '\(^\|\s\s\)\zs\.\S\+' " Display filesystem tree-style let g:netrw_liststyle=3 " Turn off netrw banner. let g:netrw_banner=0 " Directory to store bookmark and history file. let g:netrw_home="~/.local/share/vim" " Show preview window in a vertical split. "let g:netrw_preview=1 " Customize behaviour of preview window. " NB: help page is wrong when it comes to define all combinations; the " correct config is " g:netrw_preview g:netrw_alto result " 1 0 :botright " 1 1 :topleft "let g:netrw_alto=0 "let g:netrw_altv=1 " {{{2 TERMDEBUG " Force debug windows on vertical split let g:termdebug_wide = 1 " {{{2 TAGBAR " https://github.com/majutsushi/tagbar " Open tagbar on the left let g:tagbar_left = 1 " Default width of the tagbar window let g:tagbar_width = 40 " When zooming (`x`) use the width of the longest currently visible tag. let g:tagbar_zoomwidth = 0 " Move to the Tagbar window when opened and close it when jumping to a " tag (implies `g:tagbar_autofocus` set) let g:tagbar_autoclose = 1 " Sort by position in the source file. let g:tagbar_sort = 0 " Use a case-insensitive comparison when sorting tags let g:tagbar_case_insensitive = 1 " Folds with a level higher than this number will be closed. let g:tagbar_foldlevel = 2 " Custom icons for tagbar folds let g:tagbar_iconchars = ['▸', ' '] " Location of the preview window (below the current window) let g:tagbar_previewwin_pos = "belowright" " Custom statusbar let g:tagbar_status_func = 'dyamon#statusline#tagbar' " {{{3 Additional language support " {{{4 HASKELL " Requires: Hasktags let g:tagbar_type_haskell = { \ 'ctagsbin' : 'hasktags', \ 'ctagsargs' : '-x -c -o-', \ 'kinds' : [ \ 'm:modules:0:1', \ 'd:data: 0:1', \ 'd_gadt: data gadt:0:1', \ 't:type names:0:1', \ 'nt:new types:0:1', \ 'c:classes:0:1', \ 'cons:constructors:1:1', \ 'c_gadt:constructor gadt:1:1', \ 'c_a:constructor accessors:1:1', \ 'ft:function types:1:1', \ 'fi:function implementations:0:1', \ 'o:others:0:1' \ ], \ 'sro' : '.', \ 'kind2scope' : { \ 'm' : 'module', \ 'c' : 'class', \ 'd' : 'data', \ 't' : 'type' \ }, \ 'scope2kind' : { \ 'module' : 'm', \ 'class' : 'c', \ 'data' : 'd', \ 'type' : 't' \ } \ } " {{{4 SCALA " https://github.com/majutsushi/tagbar/wiki#scala " {{{4 MARKDOWN " https://github.com/majutsushi/tagbar/wiki#markdown " {{{4 BIB " https://github.com/majutsushi/tagbar/wiki#bib " {{{2 UNODTREE " https://github.com/mbbill/undotree " Set the undotree window layout. " " +------------------+----------+ " | | | " | | | " | | undotree | " | | | " | | | " +------------------+----------+ " | | " | diff | " | | " +-----------------------------+ " let g:undotree_WindowLayout=4 " Set the undotree window width. let g:undotree_SplitWidth = 25 " Set the diff window height. let g:undotree_DiffpanelHeight = 30 " Undotree window will get focus after being opened. let g:undotree_SetFocusWhenToggle = 1 " Set the tree node shape. let g:undotree_TreeNodeShape = '×' " Use short (relative) timestamps. let g:undotree_ShortIndicators = 1 " {{{2 VIM-BBYE " https://github.com/moll/vim-bbye " {{{2 VIM-COMMENTARY " https://github.com/tpope/vim-commentary " {{{2 VIM-FUGITIVE " https://github.com/tpope/vim-fugitive " {{{2 VIM-GITGUTTER " https://github.com/airblade/vim-gitgutter " Plugin on at startup (toggle with `gg`). let g:gitgutter_enabled = 0 " No ANSI escape or color codes on `grep` invocation. let g:gitgutter_grep = 'grep --color=never' " Custom signs. let g:gitgutter_sign_added = '▐' let g:gitgutter_sign_modified = '▐' let g:gitgutter_sign_removed = '▐' let g:gitgutter_sign_modified_removed = '▐' let g:gitgutter_sign_removed_first_line = '▐' " Disable default mappings. let g:gitgutter_map_keys = 0 " {{{2 VIM-OBSESSION " https://github.com/tpope/vim-obsession " {{{2 VIM-RACKET " https://github.com/wlangstroth/vim-racket " {{{2 VIM-REPEAT " https://github.com/tpope/vim-repeat " {{{2 VIM-SLIME " https://github.com/jpalardy/vim-slime " Set TMux as default target let g:slime_target = "tmux" " Set default TMux pane target let g:slime_default_config = {"socket_name": "default", "target_pane": "{bottom-right}"} " Set bridge file between VIM and TMux let g:slime_paste_file = tempname() " Disable default mappings let g:slime_no_mappings = 1 " {{{2 VIM-SURROUND " https://github.com/tpope/vim-surround " {{{2 VIM-TMUX-FOCUS-EVENT " https://github.com/tmux-plugins/vim-tmux-focus-events " {{{2 VIM-TMUX-NAVIGATOR " https://github.com/christoomey/vim-tmux-navigator " Disable tmux navigator when zooming the Vim pane let g:tmux_navigator_disable_when_zoomed = 1 " {{{2 VIM-VINEGAR " https://github.com/tpope/vim-vinegar " {{{2 VIM-TABLE-MODE " https://github.com/dhruvasagar/vim-table-mode " Define the table corner character let g:table_mode_corner = '+' " Define the character to be used for the extreme corners of the table border. > let g:table_mode_corner_corner = '+' " Define the table header border fill character let g:table_mode_fillchar = '-' " Define the table mode mapping prefix that will be prefixed for all other " table mode mappings let g:table_mode_map_prefix = 't' " Define the mapping for toggling the table mode: > let g:table_mode_toggle_map = 'm' " Disable mappings "let g:table_mode_disable_mappings = 1 " Disable mappings for tableize "let g:table_mode_disable_tableize_mappings = 1 " Disable table mode syntax definitions "let g:table_mode_syntax = 0 " Set the mapping to move up a cell vertically let g:table_mode_motion_up_map = '{t' " Set the mapping to move down a cell vertically let g:table_mode_motion_down_map = '}t' " Set the mapping to move to the left cell. > let g:table_mode_motion_left_map = '[t' " Set the mapping to move to the right cell. > let g:table_mode_motion_right_map = ']t' " {{{2 VIM-LSP " https://github.com/prabirshrestha/vim-lsp " Display diagnostics as a floating window let g:lsp_diagnostics_float_cursor = 1 " Disable floating preview of documentation in completion menu (it " ignores the `preview` option in `completeopt`. let g:lsp_documentation_float = 0 " Align text on top when peeking on window let g:lsp_peek_alignment = "top" " Give priority to other gutters (e.g., GitGutter) let g:lsp_signs_priority = 9 " Set custom diagnostic signs let g:lsp_signs_error = {'text': '>>'} let g:lsp_signs_warning = {'text': '>>'} let g:lsp_signs_information = {'text': '>>'} let g:lsp_signs_hit = {'text': '>>'} " Closes the preview/floating window on second tap let g:lsp_preview_doubletap = [function('lsp#ui#vim#output#closepreview')] " Log file (uncomment when debugging) "let g:lsp_log_file = expand('$TMPDIR/vim-lsp.log') " Rust Language Server registration " if executable('rls') " autocmd User lsp_setup call lsp#register_server({ " \ 'name': 'rls', " \ 'cmd': {server_info->['rls']}, " \ 'workspace_config': {'rust': {'clippy_preference': 'on'}}, " \ 'allowlist': ['rust'], " \ }) " endif " Scala Meta Language Server registration " Take a look here " " https://scalameta.org/metals/docs/editors/vim.html#using-an-alternative-lsp-client " " for details on how to install MetaLS " " Import build with the following command: " " :call lsp#send_request('metals', { 'method': 'workspace/executeCommand', 'params': { 'command': 'build-import' }}) " " Formatting on save needs some additional configuration. MetaLS uses " `scalafmt` to format code. Have a look here " " https://scalameta.org/metals/docs/editors/new-editor.html#textdocumentformatting " " for details of what MetaLS does when receiving a " `textDocument/formatting` message. " " To configure it manually you need to create a `.scalafmt.conf` file " (in the project root by default, but customizable with the " `metals.scalafmtConfigPath` option) and with the following content: " " ``` " version="" " ``` " with being the ScalaFMT to use for the project (latest " version can be found at https://github.com/scalameta/scalafmt). " if executable('metals-vim') au User lsp_setup call lsp#register_server({ \ 'name': 'metals', \ 'cmd': {server_info->['metals-vim']}, \ 'initialization_options': { 'rootPatterns': 'build.sbt' }, \ 'allowlist': [ 'scala', 'sbt' ], \ }) endif function! s:on_lsp_buffer_enabled() abort " Enable autocompletion (Omnifunc vs asyncomplete.vim "setlocal omnifunc=lsp#complete "let b:asyncomplete_enable = 1 " Enable docs on preview window. For more details look at " https://github.com/prabirshrestha/asyncomplete.vim#preview-window setlocal completeopt=menuone,noinsert,noselect,preview " Show gutters only when needed setlocal signcolumn=number " Integrate tag functionality with vim-lsp if exists('+tagfunc') | setlocal tagfunc=lsp#tagfunc | endif " Mappings nmap nc (lsp-next-diagnostic) nmap pc (lsp-previous-diagnostic) nmap gd (lsp-definition) nmap gD (lsp-peek-definition) nmap gr (lsp-references) nmap K (lsp-hover) "nmap gi (lsp-implementation) "nmap gt (lsp-type-definition) "nmap rn (lsp-rename) "nmap [g (lsp-previous-diagnostic) "nmap ]g (lsp-next-diagnostic) " Format buffer on save "augroup lsp_enabled_common " autocmd! autocmd BufWritePre silent LspDocumentFormatSync "augroup END "command LspMetalsBuildImport call lsp#send_request('metals', { 'method': 'workspace/executeCommand', 'params': { 'command': 'build-import' }}) endfunction augroup lsp_install autocmd! " Call `s:on_lsp_buffer_enabled()` only for languages that has the " server registered. autocmd User lsp_buffer_enabled call s:on_lsp_buffer_enabled() augroup END " {{{2 ASYNCOMPLETE.VIM " https://github.com/prabirshrestha/asyncomplete.vim " Disable asynccomplete by default (re-enabled when using LSP) "let g:asyncomplete_enable_for_all = 0 " Do not override `completeopt` let g:asyncomplete_auto_completeopt = 0 " Add some delay on completion popup let g:asyncomplete_popup_delay = 500 " Log file (uncomment when debugging) "let g:asyncomplete_log_file = expand('$TMPDIR/vim-asyncomplete.log') " {{{2 ASYNCOMPLETE-LSP.VIM " https://github.com/prabirshrestha/asyncomplete-lsp.vim " {{{2 VIM-GRAMMAROUS " https://github.com/rhysd/vim-grammarous " Manually downloaded Language Tools from " https://languagetool.org/download/LanguageTool-stable.zip let g:grammarous#jar_dir = expand('$HOME/programs/LanguageTool-5.3') " Seems to slow things down a lot and give more false positive in TeX let g:grammarous#use_vim_spelllang = 0 " Don't perform spell check (toggled by hooks instead) let g:grammarous#enable_spell_check = 0 " Change colorscheme and toggle Vim spellcheck functionality. let g:grammarous#hooks = #{on_check: 'dyamon#spell#on', on_reset: 'dyamon#spell#off'} " {{{2 TO TRY " Vim: statically built version of Vim. " https://github.com/fr0xk/vim " FastFold: some fixes for fold updates. " https://github.com/Konfekt/FastFold " Vimtex: full-featured Latex support for Vim (also integrates with " Zathura). Not compatible with Polyglot (which includes " LaTeX-Box). " https://github.com/lervag/vimtex " " Consider not using a plugin at all: " + Compilation via `:make` with " set makeprg=latexmk\ -pdf\ ... " + Zathura automatically updates its view; " + Clean up all regeneratable files on Vim closing: " autocmd VimLeave *.tex !latexmk -c " + `g/\v\\(chapter|(sub)?section)/#:` map this to see the document " structure and quickly jump to through the document; " + you can borrow some mappings/folding/completion/error parsing " configurations from Vimtex. " MuComplete: omnicomplete wrapper (might be a good alternative to " full-featured autocompletion engines) " https://github.com/lifepillar/vim-mucomplete " Wordy: writing checker (not grammar checker). " https://github.com/reedes/vim-wordy " Polyglot: mega-pack of syntax/indent/autoload/compiler/ftplugin for " various languages. " https://github.com/sheerun/vim-polyglot " Pencil: might provide a better soft wrap feature than vanilla? " https://github.com/reedes/vim-pencil " Remark: write presentations in markdown and use JavaScript to display " them on your browser (supports presentation mode). Can be used " offline. " https://www.reddit.com/r/vim/comments/9bw6cp/turn_markdown_into_selfcontained_html_slideshows/ " https://github.com/gnab/remark " https://github.com/idbrii/vim-remarkjs " https://en.wikipedia.org/wiki/Takahashi_method " Qfx: quickfix gutter " https://gitlab.com/hauleth/qfx.vim " Boxdraw: draw boxes in visual mode (quite advanced). " https://github.com/gyim/vim-boxdraw " Cool: enable `hlsearch` when searching, disable it when you are not. " https://github.com/romainl/vim-cool/blob/master/plugin/cool.vim " Dadbod: use Vim as a DBMS IDE " https://github.com/tpope/vim-dadbod " https://medium.com/@sammerry/vim-mysql-442b26dd013c " MatchUp: drop-in replacement end extention for matchit.vim " https://github.com/andymass/vim-matchup/ " HighlightedYank: briefly highlight the highlighted text on " TextYankPost. Note that NeoVim has not a Lua function that does the " same [here](https://github.com/neovim/neovim/pull/12279), so maybe it " is worth waiting for Vim to implement it too. " https://github.com/machakann/vim-highlightedyank " VimQF: is a growing collection of settings, commands and mappings put " together to make working with the location list/window and the " quickfix list/window smoother. " https://github.com/romainl/vim-qf " {{{3 ALIGNING " Tabular: Easily align text. " https://github.com/godlygeek/tabular " EasyAlign: Easily align text (action bound to `ga`) " https://github.com/junegunn/vim-easy-align " {{{3 TEXTOBJS " IndentObject: a text-object based on the indentation level. " https://github.com/michaeljsmith/vim-indent-object " TextobjFunction: a text-object for {C,Java,VimScript} functions. Can " be extended to include other languages. " https://github.com/kana/vim-textobj-function " Targets: collection of (immersive) text-objects " https://github.com/wellle/targets.vim " TextobjUser: declarative way of defining text-objects " https://github.com/kana/vim-textobj-user " {{{1 DEBUG " Automatically create .gitignore based on given keywords " https://www.toptal.com/developers/gitignore/api/linux,vim,rust command! -nargs=1 GetGitignore execute "!curl https://www.toptal.com/developers/gitignore/api/linux,macos,vim,visualstudiocode," . . " > .gitignore" let g:rust_fold = 1 let g:rustfmt_command = 'rustfmt' " {{{1 PLUGIN/RUNTIMEPATH MANAGER " Source `.local.vim` file in the current working directory. Create this " file if you want to have some project-specific vim configuration. silent! source .local.vim " Plugins code will be evaluated. " If you want something to be evaluated after this point use the `after` " folder. See `:scriptnames` for a list of all scripts, in evaluation " order. Launch Vim with `vim --startuptime vim.log` for profiling info. if &loadplugins if has('packages') " If Vim8 plugin/runtimepath manager is active. packadd vim-openscad packadd zettel.vim packadd! gruvbox packadd! fzf.vim packadd! goyo.vim packadd! matchit packadd! mortimer.vim packadd! tagbar packadd! undotree packadd! vim-bbye packadd! vim-commentary packadd! vim-fugitive packadd! vim-gitgutter packadd! vim-obsession packadd! vim-racket packadd! vim-repeat packadd! vim-slime packadd! vim-surround packadd! vim-tmux-focus-events packadd! vim-tmux-navigator packadd! vim-vinegar packadd! vim-lsp packadd! vimprobably packadd! asyncomplete.vim packadd! asyncomplete-lsp.vim else " Fall back to TPope's Pathogen plugin manager. source $HOME/.vim/pack/bundle/opt/vim-pathogen/autoload/pathogen.vim call pathogen#infect('pack/bundle/opt/{}') endif endif " Must come *after* the `:packadd!` calls above otherwise the contents of " package "ftdetect" directories won't be evaluated. " Activate filetype support, and allow filetype specific plugin and " indent files. filetype plugin indent on " Enable syntax highlight by default. syntax enable " {{{1 END " Ignore anything after this point finish