" General config {{{ " " Tip: acronyms for overview, use `:h` for a quick lookup. set nocp " Disable vi incompatibility filetype plugin indent on " Filetype recognition set enc=utf8 " Default to UTF-8 encoding set hid " Allow hiding unsaved buffers set tf " Fast tty set ut=300 " 300ms for update time set to tm=200 ttm=5 " Timeouts set shm+=c " ... set ul=500 hi=500 " History and undo set nu rnu scl=number " Line numbers & signs set nowrap set bs=indent,eol,start " Indentation set ai ts=2 sts=2 sw=2 et " Indentation set is ic scs hls " Search set lz " Only essential redraws set nobk nowb noswf " No backups set vi='20,\"101 " Max 100 lines in registers set novb " Bell set cole=0 cocu="" " Conceal set cb=unnamedplus " Clipboard set fcs+=vert:│ " Cleaner split separator (tmux style) set list set lcs=trail:·,tab:→\ ,nbsp:␣ " Whitespace rendering set ar " Autoread set spellsuggest+=5 " Limit spell suggestions set wildignore+=*/node_modules/*,*/tmp/*,*.so,*.swp,*.zip set thesaurus+=~/.vim/thesaurus/mthesaur.txt " File explorer let g:netrw_winsize = 30 let g:netrw_liststyle=3 let g:netrw_banner = 0 " }}} " Folds {{{ " Insert date fu! Today() :put =strftime('%d %b %Y') endfu set foldmethod=marker augroup filetype_vim autocmd! autocmd FileType vim setlocal foldmethod=marker augroup END augroup filetype_python autocmd! autocmd FileType python setlocal foldmethod=indent augroup END augroup filetype_sh autocmd! autocmd FileType sh setlocal foldmethod=marker augroup END " }}} " Mappings {{{ " " Leader keys nn let mapleader = " " let maplocalleader = ";" " Splits & navigation nm s " Split horizontal nm ss :spw| " Split horizontal nm sv :vsw| " Split vertical nn sw w| " Navigate splits nn sh h| " nn sj j| " nn sk k| " nn sl l| " nn sH 8<| " Resize splits nn sJ 8-| " nn sK 8+| " nn sL 8>| " nn s= =| " Equalize splits " Open nn sb :Lex| " File tree nn :noh |" nn t :term| " Open terminal nn o :!xdg-open http://localhost:8080/%:t:r.html & " Remaps ino jj | " Normal now nn | " Hard mode nn | " " nn | " " nn | " " ino | " " ino | " " ino | " " ino | " " " Search nn :noh| " map 'ctrl + /' " Use `the_silver_searcher` to find results (for selection if selection) nn f :Ag vm f y:Ag " " Toggle line numbers nn n :set nu! rnu! " Vim configuration nn ec :vs $MYVIMRC nn so :so % " }}} " Plugins {{{ " " Plug setup {{{ call plug#begin() if !exists('g:vscode') " Coc Plug 'neoclide/coc.nvim', {'branch': 'release'} Plug 'github/copilot.vim' endif " General Plug 'unblevable/quick-scope' Plug 'Shougo/context_filetype.vim' Plug 'tpope/vim-commentary' Plug 'tpope/vim-obsession' Plug 'machakann/vim-sandwich' Plug 'editorconfig/editorconfig-vim' Plug 'honza/vim-snippets' Plug 'chrisbra/unicode.vim' Plug 'ap/vim-css-color' " Fzf Plug 'junegunn/fzf', { 'do': { -> fzf#install() } } Plug 'junegunn/fzf.vim' " JS and TypeScript Plug 'pangloss/vim-javascript', { 'for': ['javascript', 'javascript.jsx'] } Plug 'leafgarland/typescript-vim', { 'for': ['typescript', 'typescript.tsx'] } Plug 'peitalin/vim-jsx-typescript', { 'for': ['typescript.tsx'] } Plug 'evanleck/vim-svelte', {'branch': 'main'} " JSON with comments Plug 'neoclide/jsonc.vim' " LaTeX Plug 'lervag/vimtex' " Wiki Plug 'lervag/wiki.vim' Plug 'hektor/taskwiki' " Markdown Plug 'vim-pandoc/vim-pandoc' Plug 'vim-pandoc/vim-pandoc-syntax' Plug 'ferrine/md-img-paste.vim' " TidalCycles Plug 'supercollider/scvim' Plug 'tidalcycles/vim-tidal' " GLSL Plug 'tikhomirov/vim-glsl' Plug 'timtro/glslView-nvim' " Jupyter notebooks Plug 'goerz/jupytext.vim' " OpenSCAD Plug 'sirtaj/vim-openscad' call plug#end() " }}} " Plugin config {{{ " `.../sandwich` {{{ nmap s xmap s let g:sandwich#recipes = deepcopy(g:sandwich#default_recipes) " }}} " `neoclide/coc.nvim` {{{ let g:coc_global_extensions = [ \'coc-dictionary', \'coc-syntax', \'coc-eslint', \'coc-prettier', \'coc-tsserver', \'coc-html', \'coc-emmet', \'coc-css', \'coc-svg', \'coc-svelte', \'coc-jedi', \'coc-json', \'coc-yaml', \'coc-snippets', \'coc-clangd', \'coc-bibtex', \'coc-git' \] " " Autocomplete " " `coc-snippets` " TODO: is this block even necessary anymore? " " I use `coc-snippets-exand-jump` here as it is more flexible afaics " As stated in the docs: " `coc-snippets-expand` Expand snippet w/ current inserted text " `coc-snippets-expand-jump` Expand snippet or jump to next placeholder of current snippet if possible " Use tab for expansion in every context Don't use it for jumping as " expansions have priority over jumping (which is not always what you want) " " E.g. You don't want to expand `time` to say `12:05` upon ``bing to go " from arguments to body in a function snippet inor \ coc#pum#visible() ? coc#_select_confirm() : \ coc#expandable() ? "\=coc#rpc#request('doKeymap', ['snippets-expand-jump',''])\" : \ "\" " Use and to move through suggestions " Open suggestions if not yet open inor coc#pum#visible() ? coc#pum#next(1) : coc#refresh() " NOTE: As the followning interfered with digraphs, I replaced `coc#refresh` " with `"\u\"` which afaik just does c-k when no completion menu is " shown " ``` " inor coc#pum#visible() ? coc#pum#prev(1) : coc#refresh() " ``` inor coc#pum#visible() ? coc#pum#prev(1) : "\u\" " NOTE: this is cutting text in visual mode, it is replaces `$VISUAL` on next " expansion " " although I mapped it, I have yet to test this feature vmap (coc-snippets-select) ino complete_info()["selected"] != "-1" ? "\" : "\u\" " Show doccumentation fu! s:show_documentation() if (index(['vim','help'], &filetype) >= 0) execute 'h '.expand('') else call CocAction('doHover') endif endfunction nn es :CocCommand snippets.editSnippets " Code action on cursor position nm do (coc-codeaction) " Commands com! -nargs=0 Prettier :CocCommand prettier.formatFile " }}} " `.../copilot` {{{ let g:copilot_node_command = "/home/h/.config/nvm/versions/node/v16.18.0/bin/node" let g:copilot_no_tab_map = v:true imap (copilot-next) imap (copilot-prev) imap