if has('win32') let g:session_dir = $HOME .'\Desktop\workspace\programmimg\Vim\nvim-sessions' " specific to my PC, but who cares? else let g:session_dir = '~/.vim/sessions' " sessions dir endif exec 'nnoremap ss :NERDTreeClose:mks! ' . g:session_dir . '/*' " save session to file exec 'nnoremap sr :so ' . g:session_dir. '/*' " load session from file exec 'nnoremap sd :!del ' . g:session_dir. '/*' " delete session let g:auto_save = 0 augroup ft_openscad " auto save on scad files by default so live preview will work au! au FileType openscad let b:auto_save = 1 augroup END "augroup toml " TODO: get real toml highlighting (COC?) " au! " autocmd FileType BufNewFile,BufRead *.toml set syntax=javascript "augroup END " au BufRead,BufNewFile *.toml setfiletype javascript silent nmap s ^C " replace current line nmap gd (coc-definition) nmap gy (coc-type-definition) nmap gi (coc-implementation) nmap gr (coc-references) " jump to various " use space or \ exec 'nmap ' exec 'vmap ' nnoremap w :w " end paste at bottom of selection vnoremap p p`] nnoremap p p`] nmap r (coc-rename) "vmap r (coc-refactor) " refactor xmap f (coc-format-selected) nmap f (coc-format-selected) " formt nnoremap K :call show_documentation() function! s:show_documentation() if (index(['vim','help'], &filetype) >= 0) execute 'h '.expand('') elseif (coc#rpc#ready()) call CocActionAsync('doHover') else execute '!' . &keywordprg . " " . expand('') endif endfunction " show docs on K nnoremap l :call DmenuFzf() function! DmenuFzf() " heavily inspired by https://leafo.net/posts/using_dmenu_to_open_quickly.html let name= system("git ls-files | dmenu -i -l 32 -p edit | tr -d '\n'") if empty(name) return endif execute "edit " . name endfunction if has('nvim-0.4.0') || has('patch-8.2.0750') nnoremap coc#float#has_scroll() ? coc#float#scroll(1) : "\" nnoremap coc#float#has_scroll() ? coc#float#scroll(0) : "\" inoremap coc#float#has_scroll() ? "\=coc#float#scroll(1)\" : "\" inoremap coc#float#has_scroll() ? "\=coc#float#scroll(0)\" : "\" vnoremap coc#float#has_scroll() ? coc#float#scroll(1) : "\" vnoremap coc#float#has_scroll() ? coc#float#scroll(0) : "\" endif " CoC sub-pane scroll silent nnoremap h silent nnoremap j silent nnoremap k silent nnoremap l " split nav silent nnoremap < silent nnoremap - silent nnoremap + silent nnoremap > " split resize silent nnoremap e :ToggleTerm " fancy ls silent nnoremap n :NERDTreeToggle " fancy ls silent nnoremap t :UndotreeToggle let g:goyo_width = '75%' silent nnoremap g :Goyo " focus editor silent nnoremap b :w:!pandoc %:t --pdf-engine=xelatex -o %:t:r.html " make pdf from current file silent nnoremap p :set invpaste " disable autoformatting so pasted code looks right silent nnoremap c :set rnu! " relative line number toggle on c " keep cursor from skipping wrapped lines silent nnoremap j gj silent nnoremap k gk " skip wrapped lines with g silent nnoremap gj j silent nnoremap gk k " remap alt+jk to scroll TODO " nnoremap silent vmap a (coc-codeaction-selected) " silent nmap a (coc-codeaction-line) silent nmap a (coc-codeaction-cursor) " coc.vim spellcheck and refactoring silent tnoremap " easy escape terminal (at the expense of using vi in a subterm) " set nobackup nowritebackup " don't save those pesky ~vim files everywhere set backupdir=~/.vim/backup " save backup files outside of current dir TODO: make this cross-platform set directory=~/.vim/swap " probably unnecessary, not opening 8gig files. set undodir=~/.vim/undo " save undo over restart set undofile autocmd Filetype json syntax match Comment +\/\/.\+$+ " highlight comments in json set number " show line numbers " it isn't 2020 anymore :( "set pyx=2 " set python version? set breakindent " pretty indent set formatoptions+="lb" " linebreak between words set lbr " break lines instead of scrolling set nocompatible " denite wanted it filetype plugin on " denite wanted it syntax on " denite wanted it set termguicolors " make colors prettier set updatetime=100 " backup every 100 ms set showbreak=\ \ \ \ \ \ \ \ " indent wrapped lines set mouse=a " enable using mouse (and scroll wheel) set gdefault " find and replace globally by default set virtualedit=block " allow visual block selection out of buffer set shiftwidth=4 " make indentation less pronounced set expandtab set tabstop=4 set scrolloff=2 " margin on bottom set autoread " read files changed in other editors set clipboard+=unnamedplus " system clipboard let first_run = 0 if has('win32') " Installs Vim-Plug TODO: fix this, it currently works on 0% of platforms if empty(glob($HOME . '\AppData\Local\nvim\autoload')) exec 'silent !curl -fLo ' . $HOME . '\AppData\Local\nvim\autoload\plug.vim --create-dirs ' \ 'https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim' autocmd VimEnter * PlugInstall --sync | source $MYVIMRC endif else let autoload_plug_path = stdpath('config') . '/autoload/plug.vim' if !filereadable(autoload_plug_path) silent exe '!curl -fL --create-dirs -o ' . autoload_plug_path . \ ' https://raw.github.com/junegunn/vim-plug/master/plug.vim' execute 'source ' . fnameescape(autoload_plug_path) let first_run = 1 endif unlet autoload_plug_path endif call plug#begin('~/.vim/plugged') " plugins Plug 'dracula/vim', {'as': 'dracula'} " blue colorscheme Plug 'junegunn/goyo.vim' " focus Plug 'preservim/nerdtree' " fancy ls Plug 'airblade/vim-gitgutter' " auto git diff Plug 'neoclide/coc.nvim', {'branch': 'release'} " autocomplete Plug 'Shougo/denite.nvim', {'do' : ':UpdateRemotePlugins'} " file finding TODO: learn how to use or uninstall Plug 'vimwiki/vimwiki' " hyperlinks in vim TODO: start using this or uninstall Plug 'jackguo380/vim-lsp-cxx-highlight' " c, c++, c# highlighting Plug 'tpope/vim-surround' " plugin for surrounding (html good) TODO: use this or uninstall Plug 'tpope/vim-repeat' " plugin to make plugins work with . Plug 'tpope/vim-fugitive' " git plugin Plug 'tpope/vim-unimpaired' " url encoder, among others TODO: use this or uninstall Plug 'sirtaj/vim-openscad' " openSCAD highlighting Plug '907th/vim-auto-save' " autosave (activate with \as) Plug 'gustavo-hms/garbo', {'as' : 'garbage'} " colorscheme for light backgrounds Plug 'gcmt/taboo.vim' " set tab names Plug 'Shirk/vim-gas' " asm highlighting Plug 'NLKNguyen/papercolor-theme' " another theme Plug '4513ECHO/vim-colors-hatsunemiku' " another theme Plug 'fenetikm/falcon' Plug 'jacoborus/tender.vim' Plug 'sonph/onehalf', {'rtp': 'vim/'} Plug 'tomasiser/vim-code-dark' Plug 'savq/melange' Plug 'arcticicestudio/nord-vim' Plug 'sickill/vim-monokai' Plug 'AhmedAbdulrahman/aylin.vim' Plug 'gosukiwi/vim-atom-dark' Plug 'fcpg/vim-farout' "Plug 'pgdouyoun/vim-yin-yang' "Plug 'FranzyExists/aquarium-vim' Plug 'DingDean/wgsl.vim', {'branch': 'main'} Plug 'foxbunny/vim-amber' Plug 'SirVer/ultisnips' Plug 'tribela/vim-transparent' Plug 'mbbill/undotree' " Plug 'danth/pathfinder.vim' " training Plug 'yuttie/comfortable-motion.vim' Plug 'nvim-lua/plenary.nvim' Plug 'saecki/crates.nvim', { 'tag': 'v0.3.0' } " Plug 'andweeb/presence.nvim' " discord Plug 'akinsho/toggleterm.nvim', {'tag' : '*'} Plug 'mg979/vim-visual-multi', {'branch': 'master'} Plug 'mfussenegger/nvim-dap' Plug 'rcarriga/nvim-dap-ui' Plug 'jdhao/better-escape.vim' Plug 'tikhomirov/vim-glsl' call plug#end() lua require("toggleterm").setup() lua require('crates').setup() " default let g:transparent_groups = ['Normal', 'Comment', 'Constant', 'Special', 'Identifier', \ 'Statement', 'PreProc', 'Type', 'Underlined', 'Todo', 'String', \ 'Function', 'Conditional', 'Repeat', 'Operator', 'Structure', \ 'LineNr', 'NonText', 'SignColumn', 'CursorLineNr', 'EndOfBuffer'] " coc.nvim let g:transparent_groups += ['NormalFloat', 'CocFloating'] if first_run PlugInstall --sync " install plugins CocInstall coc-json coc-css coc-html coc-eslint coc-tsserver coc-pyright coc-stylelint coc-tslint coc-vimlsp coc-java coc-word coc-dictionary coc-spell-checker coc-toml coc-rust-analyzer coc-lua " install autocomplete plugins silent execute "!mkdir -p " . g:session_dir silent execute "!mkdir -p " . &l:backupdir silent execute "!mkdir -p " . &l:directory silent execute "!mkdir -p " . &l:undodir endif unlet first_run color falcon " colorscheme autocmd FileType denite call s:denite_my_settings() " denite config TODO figure out how to use this function! s:denite_my_settings() abort nnoremap \ denite#do_map('do_action') nnoremap d \ denite#do_map('do_action', 'delete') nnoremap p \ denite#do_map('do_action', 'preview') nnoremap q \ denite#do_map('quit') nnoremap i \ denite#do_map('open_filter_buffer') nnoremap \ denite#do_map('toggle_select').'j' endfunction if empty(argv()) " custom nvim home screen set buftype=nofile " disable undo warnings file startup " set name if has("win32") exec 'read !dir ' . g:session_dir . '\*.vim /B /O-d /tw' " read sessions from new to old else exec 'read !ls -t ' g:session_dir endif " get sessions normal! ggiClose " normal oExit " normal oJournal " normal oWiki normal oMenu normal 0gg " add close option nnoremap :call Opensession() " set mapping to select endif function! Opensession() " open session under cursor, or run homepage command if getline(".") == "Close" " clear buffer, for example to write something silent normal uu silent nun " unmap enter (disable this function from running again) bd echo "" elseif getline(".") == " Exit" " quit nvim silent normal uu exit elseif getline(".") == " Wiki" " open vimwiki silent normal uu\ww elseif getline(".") == " NTree" " open nerdtree silent normal uu bd " the thing on the following line not existing probably cost me several " hours over the years cleaning up random empty files with one-word " names silent nun NERDTreeToggle elseif getline(".") == "" echo "" elseif getline(".") == "Menu" normal oExit normal oNTree normal oWiki normal oEv3 normal o normal V4k> normal 2GA (Open) normal 0 elseif getline(".") == "Menu (Open)" " normal jV3jdk silent normal u echo "" else let g:selected_line = getline(".") " get line under cursor silent normal uu " clear buffer exec 'silent !touch ' . g:session_dir. '/' . g:selected_line exec 'so ' . g:session_dir. '/' . g:selected_line " open session under cursor nun " unmap enter (disable this function from running again) endif endfunction