| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034 |
- " wreed vimrc
- " vim:foldmethod=marker:foldlevel=0:
- let g:python3_host_prog = expand('$HOME') . '/.pyenv/versions/nvim/bin/python3'
- "{{{ ***** PLUGINS INSTALLATION ***** "
- " ##### vim-plug #####
- set nocompatible
- call plug#begin('~/.vim/bundle')
- " **** Major Functionality Plugins
- Plug 'nvim-lua/plenary.nvim'
- Plug 'AckslD/swenv.nvim'
- " coc.nvim - code completion
- Plug 'neoclide/coc.nvim', {'branch': 'release'}
- Plug 'clangd/coc-clangd'
- " Linters
- Plug 'mfussenegger/nvim-lint'
- " tree-sitter - syntax parsing
- Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'}
- " Snippet completion
- Plug 'SirVer/ultisnips' ", { 'on': []}
- " Dependency for vim-snippets
- Plug 'tomtom/tlib_vim'
- " A library of snippets that work with Utilsnip
- Plug 'honza/vim-snippets'
- " Asynchonous building and launching of programs
- Plug 'tpope/vim-dispatch'
- Plug '5long/pytest-vim-compiler'
- " Run tests
- " Plug 'janko-m/vim-test'
- " Amazing plugin that makes a lot of things obsolete...
- "Plug 'Shougo/unite.vim'
- "Plug 'Shougo/denite.nvim'
- "Plug 'Shougo/neomru.vim'
- "Plug 'Shougo/neoyank.vim'
- " Plug 'Shougo/unite-outline'
- " Diff directories quickly and powerfully
- Plug 'will133/vim-dirdiff'
- " Diff individual sections of code
- Plug 'AndrewRadev/linediff.vim'
- " Show differences with style
- Plug 'mhinz/vim-signify'
- " Better diffs (optionaly)
- Plug 'chrisbra/vim-diff-enhanced'
- " Gives a graphical view of vim's undo tree (replaced by neovim-compatible
- " fork)
- "Plugin 'sjl/gundo.vim'
- Plug 'simnalamburt/vim-mundo'
- " Plug 'mbbill/undotree'
- " Git integration
- Plug 'tpope/vim-fugitive'
- Plug 'tpope/vim-rhubarb'
- " Easy alignment
- Plug 'junegunn/vim-easy-align'
- " command line fuzzy finder
- Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
- Plug 'junegunn/fzf.vim'
- " **** Basic editing and functionality
- " Matching things in insert mode
- Plug 'Raimondi/delimitMate'
- " Comments
- " Way more lightweight comment plugin
- Plug 'tpope/vim-commentary'
- " Makes motions way better. lets you jump anywhere on the screen
- " Plug 'Lokaltog/vim-easymotion'
- Plug 'justinmk/vim-sneak'
- " ability to surround text objects with things like quotes or parens
- Plug 'tpope/vim-surround'
- " Better text objects
- Plug 'wellle/targets.vim'
- " Heuristically set indent settings
- Plug 'tpope/vim-sleuth'
- " Better ways to deal with extra whitespace
- Plug 'ntpeters/vim-better-whitespace'
- " **** Language-specific plugins
- " switch between header files easily
- Plug 'vim-scripts/a.vim'
- " pretty JSON stuff
- Plug 'elzr/vim-json'
- " coding in GO
- Plug 'fatih/vim-go', { 'do': ':GoInstallBinaries' }
- " Markdown viewing
- " Plug 'suan/vim-instant-markdown', {'for': 'markdown'}
- " Plug 'iamcco/markdown-preview.nvim', { 'do': { -> mkdp#util#install() }, 'for': ['markdown', 'vim-plug']}
- " Behave integration
- Plug 'avanzzzi/behave.vim', {'for': 'cucumber'}
- Plug 'gisraptor/vim-lilypond-integrator', {'frozen': 1, 'for': ['lilypond']}
- Plug 'hashivim/vim-terraform'
- Plug 'andrewstuart/vim-kubernetes'
- " **** UX enhancements
- " Make vim priiiiity
- Plug 'bling/vim-airline'
- Plug 'vim-airline/vim-airline-themes'
- " Make Tmux pretty
- Plug 'edkolev/tmuxline.vim'
- " Shows file browser. (replaces netrw and :Explore)
- Plug 'scrooloose/nerdtree', { 'on': ['NERDTreeToggle', 'NERDTreeFind']}
- " show tabs up on top prettily
- Plug 'mkitt/tabline.vim'
- " shows an outline of all Tags in a file
- Plug 'majutsushi/tagbar'
- " Fancy start screen
- Plug 'mhinz/vim-startify'
- " **** SYNTAX Files
- " Plug 'linkinpark342/xonsh-vim'
- Plug 'stephpy/vim-yaml'
- Plug 'solarnz/thrift.vim'
- Plug 'martinda/Jenkinsfile-vim-syntax'
- Plug 'mustache/vim-mustache-handlebars'
- " **** COLORSCHEMES
- "COLORSCHEMES
- Plug 'vim-scripts/devbox-dark-256'
- " end installed plugins
- call plug#end()
- " }}}
- "{{{ ***** PLUGIN SETTINGS ***** "
- " {{{##### Vim-Sneak #####
- let g:sneak#label = 1
- nmap s <Plug>Sneak_s
- xmap s <Plug>Sneak_s
- omap s <Plug>Sneak_s
- nmap S <Plug>Sneak_S
- xmap S <Plug>Sneak_S
- omap S <Plug>Sneak_S
- " 1-character enhanced 'f'
- nmap f <Plug>Sneak_f
- nmap F <Plug>Sneak_F
- xmap f <Plug>Sneak_f
- xmap F <Plug>Sneak_F
- omap f <Plug>Sneak_f
- omap F <Plug>Sneak_F
- " 1-character enhanced 't'
- nmap t <Plug>Sneak_t
- nmap T <Plug>Sneak_T
- xmap t <Plug>Sneak_t
- xmap T <Plug>Sneak_T
- omap t <Plug>Sneak_t
- omap T <Plug>Sneak_T
- " this seems weird, but it's to maintain motor memory with EasyMotion
- nmap <Leader>w <Plug>(SneakStreak)
- nmap <Leader>W <Plug>(SneakStreakBackward)
- "}}}
- " {{{##### Tagbar #####
- let g:tagbar_autofocus = 1
- let g:tagbar_left = 1
- let g:tagbar_zoomwidth = 0
- let g:tagbar_show_linenumbers = -1
- let g:tagbar_foldlevel = 0
- let g:tagbar_autoshowtag = 1
- let g:tagbar_sort = 0
- " open Tagbar automatically when viewing a supported file/files
- "autocmd VimEnter * nested :call tagbar#autoopen(1)
- " open Tagbar automatically when entering a buffer of supported file/files
- "autocmd BufEnter * nested :call tagbar#autoopen(0)
- " Toggle Tagbar
- nnoremap <leader>tt :TagbarToggle<CR>
- "}}}
- " {{{##### Airline #####
- let g:airline_powerline_fonts=1
- " only if YCM is enabled
- " autocmd User YouCompleteMe let g:airline#extensions#ycm#enabled = 1 | AirlineRefresh
- let g:airline#extensions#tabline#enabled = 1
- let g:airline#extentions#tabline#show_splits = 1
- let g:airline#extensions#tabline#show_tab_nr = 1
- let g:airline#extensions#tabline#tab_nr_type = 2
- let g:airline#extensions#tabline#show_close_button =1
- let g:airline#extensions#ycm#enabled = 1
- let g:airline#extensions#tagbar#flags = 'f'
- let g:airline#extensions#tagbar#enabled = 1
- let g:airline#extensions#whitespace#enabled = 1
- let g:airline#extensions#tmuxline#enabled = 1
- let g:airline#extensions#tabline#buffer_idx_mode = 1
- nmap <silent> <leader>1 <Plug>AirlineSelectTab1
- nmap <silent> <leader>2 <Plug>AirlineSelectTab2
- nmap <silent> <leader>3 <Plug>AirlineSelectTab3
- nmap <silent> <leader>4 <Plug>AirlineSelectTab4
- nmap <silent> <leader>5 <Plug>AirlineSelectTab5
- nmap <silent> <leader>6 <Plug>AirlineSelectTab6
- nmap <silent> <leader>7 <Plug>AirlineSelectTab7
- nmap <silent> <leader>8 <Plug>AirlineSelectTab8
- nmap <silent> <leader>9 <Plug>AirlineSelectTab9
- " }}}
- " {{{##### NERDTree #####
- let g:NERDTreeHijackNetrw = 1
- let g:NERDTreeDirArrows = 1
- let g:NERDTreeWinPos = "right"
- let g:NERDTreeMouseMode = 2
- let g:NERDTreeShowLineNumbers = 1
- let g:NERDTreeIgnore=['\~$', '\.vim$', '\.d$', '\.sw.$']
- nnoremap <leader>nt :NERDTreeToggle<CR>
- nnoremap <leader>nf :NERDTreeFind<CR>
- " }}}
- " {{{##### UltiSnips #####
- let g:UltiSnipsEditSplit = "vertical"
- let g:UltiSnipsExpandTrigger = "<C-Space>"
- let g:UltiSnipsJumpForwardTrigger="<TAB>"
- let g:UltiSnipsJumpBackwardTrigger="<S-TAB>"
- let g:UltiSnipsSnippetsDir="~/.vim/UltiSnips"
- " }}}
- " {{{##### Linters #####
- lua require('lint').linters_by_ft = { python = {'mypy'} }
- command! -nargs=* Lint lua require('lint').try_lint(<f-args>)
- au BufWritePost,BufRead * Lint
- " }}}
- " {{{ ##### FZF #####
- command! -nargs=* -complete=dir Cd call fzf#run(fzf#wrap(
- \ {'source': 'find '.(empty([<f-args>]) ? '.' : expand(<f-args>)).' -type d',
- \ 'sink': 'cd'}))
- function! Bufs()
- redir => list
- silent ls
- redir END
- return split(list, "\n")
- endfunction
- command! BufferDelete call fzf#run(fzf#wrap({
- \ 'source': Bufs(),
- \ 'sink*': { lines -> execute('bwipeout '.join(map(lines, {_, line -> split(line)[0]}))) },
- \ 'options': '--multi --bind ctrl-a:select-all+accept --prompt BufDelete'
- \ }))
- " \ 'options': '+m -x --tiebreak=index --header-lines=1 --ansi -d \t -n "2,1..2" --prompt BufDelete>'
- nnoremap <leader>cd :Cd<CR>
- nnoremap <leader><leader>cd :Cd ~<CR>
- nnoremap <leader>e :Files<CR>
- nnoremap <leader><leader>e :Files ~<CR>
- nnoremap <leader>be :Buffers<CR>
- nnoremap <leader>bd :BufferDelete<CR>
- nnoremap <leader>/ :BLines<CR>
- nnoremap <leader>gst :GFiles!?<CR>
- " }}}
- " {{{##### JSON.vim #####
- augroup json_autocmd
- autocmd!
- autocmd FileType json set autoindent
- autocmd FileType json set formatoptions=cq2
- autocmd FileType json set foldmethod=indent
- augroup END
- autocmd filetype crontab setlocal nobackup nowritebackup
- " }}}
- " {{{##### DirDiff #####
- let g:DirDiffExcludes = ".*.*.swp,*.d"
- " }}}
- " {{{##### Mundo #####
- nnoremap <leader>u :MundoToggle<CR>
- let g:mundo_playback_delay = 300
- let g:mundo_preview_bottom = 1
- " }}}
- " {{{##### EasyAlign #####
- vmap <Enter> <Plug>(LiveEasyAlign)
- let g:easy_align_delimiters = {
- \ '\': {
- \ 'pattern': '\\' },
- \ '/': {
- \ 'pattern': '//\+\|/\*\|\*/',
- \ 'delimiter_align': 'l',
- \ 'ignore_groups': ['!Comment'] },
- \ }
- " }}}
- " {{{##### DelimitMate #####
- let delimitMate_expand_space = 1
- let delimitMate_expand_cr = 1
- imap <c-l> <Plug>delimitMateS-Tab
- " }}}
- " {{{##### Startify #####
- let g:startify_lists = [
- \ { 'type': 'dir', 'header': [ 'MRU '. getcwd()] },
- \ { 'type': 'files', 'header': [ 'MRU'] },
- \ { 'type': 'sessions', 'header': [ 'Sessions'] },
- \ { 'type': 'bookmarks', 'header': [ 'Bookmarks'] },
- \ { 'type': 'commands', 'header': [ 'Commands'] },
- \ ]
- " let g:startify_bookmarks = [ {'v': '~/.vim/vimrc'} ]
- let g:startify_commands = [
- \ {'rc': 'EditVimrc'},
- \ {'crc': 'EditCustomVimrc'},
- \ {'p': 'PlugUpdate'}]
- let g:startify_session_delete_buffers = 1
- if has('nvim')
- let g:startify_custom_header =
- \ map(split(system('toilet Nvim -t -W -F border'), '\n'), '" ". v:val') + ['','']
- " \ map(split(system('cowsay -f dragon Welcome to VIM | sed "s/ *$//"'), '\n'), '" ". v:val') + ['','']
- " \ map(split(system('fortune | cowsay'), '\n'), '" ". v:val') + ['','']
- else
- let g:startify_custom_header =
- \ map(split(system('toilet Vim -t -W -F border'), '\n'), '" ". v:val') + ['','']
- endif
- " }}}
- " {{{##### Signify #####
- let g:signify_vcs_list = ['git']
- omap ih <plug>(signify-motion-inner-pending)
- xmap ih <plug>(signify-motion-inner-visual)
- omap ah <plug>(signify-motion-outer-pending)
- xmap ah <plug>(signify-motion-outer-visual)
- " }}}
- " {{{ ##### vim-colorscheme switcher #####
- let g:colorscheme_switcher_define_mappings = 0
- let g:colorscheme_switcher_exclude = []
- nnoremap <silent> <F9> :NextColorScheme<CR>
- nnoremap <silent> <S-F9> :PrevColorScheme<CR>
- nnoremap <silent> <leader><F9> :RandomColorScheme<CR>
- " }}}
- " {{{ ##### vim-fugitive #####
- augroup rebase_tools
- autocmd!
- autocmd FileType gitrebase nnoremap <buffer> <leader>] :Gedit <c-r><c-w><CR>
- autocmd FileType gitrebase nnoremap <buffer> <leader>p :Pick <CR>j
- autocmd FileType gitrebase nnoremap <buffer> <leader>r :Reword <CR>j
- autocmd FileType gitrebase nnoremap <buffer> <leader>e :Edit <CR>j
- autocmd FileType gitrebase nnoremap <buffer> <leader>sq :Squash <CR>j
- autocmd FileType gitrebase nnoremap <buffer> <leader>f :Fixup <CR>j
- augroup END
- command! Jenkins execute 'Gcommit -a --fixup=HEAD' | Gpush
- " }}}
- " {{{ ##### vim-go #####
- let g:go_def_mapping_enabled = 0
- let g:go_fmt_experimental = 1 " retains folds on save (For some reason) https://github.com/fatih/vim-go/issues/502
- augroup vimgosettings
- " autocmd FileType go nmap <leader>] :GoDef<CR>
- au FileType go nmap <F4> <Plug>(go-test)
- au FileType go nmap <leader><F4> <Plug>(go-lint)
- au FileType go nmap <F3> <Plug>(go-build)
- au FileType go nmap <leader><F3> <Plug>(go-install)
- au FileType go nmap <F2> <Plug>(go-imports)
- au FileType go nmap <leader>ie <Plug>(go-iferr)
- augroup END
- " }}}
- " {{{ ##### coc.nvim #####
- " Having longer updatetime (default is 4000 ms = 4s) leads to noticeable
- " delays and poor user experience
- set updatetime=300
- " Always show the signcolumn, otherwise it would shift the text each time
- " diagnostics appear/become resolved
- set signcolumn=yes
- " Use tab for trigger completion with characters ahead and navigate
- " NOTE: There's always complete item selected by default, you may want to enable
- " no select by `"suggest.noselect": true` in your configuration file
- " NOTE: Use command ':verbose imap <tab>' to make sure tab is not mapped by
- " other plugin before putting this into your config
- inoremap <silent><expr> <TAB>
- \ coc#pum#visible() ? coc#pum#next(1) :
- \ CheckBackspace() ? "\<Tab>" :
- \ coc#refresh()
- inoremap <expr><S-TAB> coc#pum#visible() ? coc#pum#prev(1) : "\<C-h>"
- " Make <CR> to accept selected completion item or notify coc.nvim to format
- " <C-g>u breaks current undo, please make your own choice
- inoremap <silent><expr> <CR> coc#pum#visible() ? coc#pum#confirm()
- \: "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>"
- function! CheckBackspace() abort
- let col = col('.') - 1
- return !col || getline('.')[col - 1] =~# '\s'
- endfunction
- " Use <c-space> to trigger completion
- if has('nvim')
- inoremap <silent><expr> <c-space> coc#refresh()
- else
- inoremap <silent><expr> <c-@> coc#refresh()
- endif
- " Use `[g` and `]g` to navigate diagnostics
- " Use `:CocDiagnostics` to get all diagnostics of current buffer in location list
- nmap <silent> [g <Plug>(coc-diagnostic-prev)
- nmap <silent> ]g <Plug>(coc-diagnostic-next)
- " GoTo code navigation
- nmap <silent> gd <Plug>(coc-definition)
- nmap <silent> gy <Plug>(coc-type-definition)
- nmap <silent> gi <Plug>(coc-implementation)
- nmap <silent> gr <Plug>(coc-references)
- " Use K to show documentation in preview window
- nnoremap <silent> K :call <SID>show_documentation()<CR>
- " let g:coc_node_path = '/snap/bin/node'
- function! s:show_documentation()
- if (index(['vim','help'], &filetype) >= 0)
- execute 'h '.expand('<cword>')
- else
- call CocAction('doHover')
- endif
- endfunction
- " Highlight the symbol and its references when holding the cursor
- autocmd CursorHold * silent call CocActionAsync('highlight')
- " Symbol renaming
- nmap <leader>rn <Plug>(coc-rename)
- " Formatting selected code
- xmap <leader>f <Plug>(coc-format-selected)
- nmap <leader>f <Plug>(coc-format-selected)
- augroup mygroup
- autocmd!
- " Setup formatexpr specified filetype(s)
- autocmd FileType typescript,json setl formatexpr=CocAction('formatSelected')
- " Update signature help on jump placeholder
- autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp')
- augroup end
- " Applying code actions to the selected code block
- " Example: `<leader>aap` for current paragraph
- xmap <leader>a <Plug>(coc-codeaction-selected)
- nmap <leader>a <Plug>(coc-codeaction-selected)
- " Remap keys for applying code actions at the cursor position
- nmap <leader>ac <Plug>(coc-codeaction-cursor)
- " Remap keys for apply code actions affect whole buffer
- nmap <leader>as <Plug>(coc-codeaction-source)
- " Apply the most preferred quickfix action to fix diagnostic on the current line
- nmap <leader>qf <Plug>(coc-fix-current)
- " Remap keys for applying refactor code actions
- nmap <silent> <leader>re <Plug>(coc-codeaction-refactor)
- xmap <silent> <leader>r <Plug>(coc-codeaction-refactor-selected)
- nmap <silent> <leader>r <Plug>(coc-codeaction-refactor-selected)
- " Run the Code Lens action on the current line
- nmap <leader>cl <Plug>(coc-codelens-action)
- " Map function and class text objects
- " NOTE: Requires 'textDocument.documentSymbol' support from the language server
- xmap if <Plug>(coc-funcobj-i)
- omap if <Plug>(coc-funcobj-i)
- xmap af <Plug>(coc-funcobj-a)
- omap af <Plug>(coc-funcobj-a)
- xmap ic <Plug>(coc-classobj-i)
- omap ic <Plug>(coc-classobj-i)
- xmap ac <Plug>(coc-classobj-a)
- omap ac <Plug>(coc-classobj-a)
- " Use CTRL-S for selections ranges
- " Requires 'textDocument/selectionRange' support of language server
- nmap <silent> <C-s> <Plug>(coc-range-select)
- xmap <silent> <C-s> <Plug>(coc-range-select)
- " Add `:Format` command to format current buffer
- command! -nargs=0 Format :call CocActionAsync('format')
- " Add `:Fold` command to fold current buffer
- command! -nargs=? Fold :call CocAction('fold', <f-args>)
- " Add `:OR` command for organize imports of the current buffer
- command! -nargs=0 OR :call CocActionAsync('runCommand', 'editor.action.organizeImport')
- " Add (Neo)Vim's native statusline support
- " NOTE: Please see `:h coc-status` for integrations with external plugins that
- " provide custom statusline: lightline.vim, vim-airline
- set statusline^=%{coc#status()}%{get(b:,'coc_current_function','')}
- " Mappings for CoCList
- " Show all diagnostics
- nnoremap <silent><nowait> <space>a :<C-u>CocList diagnostics<cr>
- " Manage extensions
- nnoremap <silent><nowait> <space>e :<C-u>CocList extensions<cr>
- " Show commands
- nnoremap <silent><nowait> <space>c :<C-u>CocList commands<cr>
- " Find symbol of current document
- nnoremap <silent><nowait> <space>o :<C-u>CocList outline<cr>
- " Search workspace symbols
- nnoremap <silent><nowait> <space>s :<C-u>CocList -I symbols<cr>
- " Do default action for next item
- nnoremap <silent><nowait> <space>j :<C-u>CocNext<CR>
- " Do default action for previous item
- nnoremap <silent><nowait> <space>k :<C-u>CocPrev<CR>
- " Resume latest coc list
- nnoremap <silent><nowait> <space>p :<C-u>CocListResume<CR>
- " }}}
- " {{{ ##### instant-markdown-viewer #####
- " let g:instant_markdown_python = 1
- let g:instant_markdown_autostart = 0
- " }}}
- " {{{ ##### markdown-preview #####
- let g:mkdp_preview_options = {
- \'maid': {
- \ "maxTextSize": 99999999,
- \},
- \}
- " }}}
- " {{{ ##### Tree-sitter #####
- " lua << EOF
- " require'nvim-treesitter.configs'.setup {
- " -- A list of parser names, or "all" (the listed parsers MUST always be installed)
- " ensure_installed = { "vim", "vimdoc", "query", "markdown", "markdown_inline", "go", "python" },
- " -- Install parsers synchronously (only applied to `ensure_installed`)
- " sync_install = false,
- " -- Automatically install missing parsers when entering buffer
- " -- Recommendation: set to false if you don't have `tree-sitter` CLI installed locally
- " auto_install = false,
- " -- List of parsers to ignore installing (or "all")
- " -- ignore_install = { "javascript" },
- " ---- If you need to change the installation directory of the parsers (see -> Advanced Setup)
- " -- parser_install_dir = "/some/path/to/store/parsers", -- Remember to run vim.opt.runtimepath:append("/some/path/to/store/parsers")!
- " highlight = {
- " enable = true,
- " -- NOTE: these are the names of the parsers and not the filetype. (for example if you want to
- " -- disable highlighting for the `tex` filetype, you need to include `latex` in this list as this is
- " -- the name of the parser)
- " -- list of language that will be disabled
- " -- disable = { "c", "rust" },
- " -- Or use a function for more flexibility, e.g. to disable slow treesitter highlight for large files
- " -- disable = function(lang, buf)
- " -- local max_filesize = 100 * 1024 -- 100 KB
- " -- local ok, stats = pcall(vim.loop.fs_stat, vim.api.nvim_buf_get_name(buf))
- " -- if ok and stats and stats.size > max_filesize then
- " -- return true
- " -- end
- " -- end,
- " -- Setting this to true will run `:h syntax` and tree-sitter at the same time.
- " -- Set this to `true` if you depend on 'syntax' being enabled (like for indentation).
- " -- Using this option may slow down your editor, and you may see some duplicate highlights.
- " -- Instead of true it can also be a list of languages
- " additional_vim_regex_highlighting = false,
- " },
- " }
- " EOF
- " }}}
- " }}}
- "{{{ ***** VIM FEATURES ***** "
- " allow project-specific .vimrc files
- if has('nvim')
- set shada+=f10
- endif
- set exrc
- set secure
- " allow the use of a modeline
- set modeline
- " automatically read a file if it changes outside of vim
- set autoread
- " hide buffers by default instead of unloading them
- set hidden
- " turn ruler on
- set ruler
- " set incremental search
- set hlsearch
- set incsearch
- if has('nvim')
- set inccommand=split
- endif
- " set status line always on
- if exists("g:gui_oni")
- set noshowmode
- set noruler
- set laststatus=0
- set noshowcmd
- else
- set laststatus=2
- endif
- set shortmess+=c
- " turn vim's mode printing off. Airline takes care of this
- set noshowmode
- " shorten the pause after leaving insert mode
- set ttimeoutlen=50
- " set mouse always on. I like the mouse sometimes
- set mouse=a
- " 256 stuff
- " disable BackgroundColorErase (BCE) inside of 256-color tmux sessions
- if &term =~ '256color'
- set t_ut=
- endif
- " OR... do this shit instead
- if &term =~ '^screen'
- " tmux will send xterm-style keys when xterm-keys is on
- execute "set <xUp>=\e[1;*A"
- execute "set <xDown>=\e[1;*B"
- execute "set <xRight>=\e[1;*C"
- execute "set <xLeft>=\e[1;*D"
- endif
- " set utf8
- if !has('nvim')
- " set encoding=utf-8
- endif
- " set fileencoding=utf-8
- " New Splits default to right, or below
- set splitbelow
- set splitright
- set diffopt+=vertical
- "turn omnicomplete on
- set omnifunc=syntaxcomplete#Complete
- " enable persistant undo history
- set undofile
- set undodir=~/.vim/undodir
- " format options
- set expandtab
- " set shiftwidth=4
- " set softtabstop=4
- set tabstop=4
- set autoindent
- set nosmartindent
- set cindent
- set cino=l1,t0,(0
- set breakindent
- set showbreak=↳
- set breakindentopt=min:20
- " TOhtml settings
- let g:html_ignore_conceal=1
- let g:html_dynamic_folds=1
- " folding options
- set foldlevelstart=99
- set foldmethod=syntax
- augroup folding_settings
- autocmd FileType python,xonsh,yaml,thrift set foldmethod=indent
- augroup END
- " set filetype options
- au BufNewFile,BufRead *.xsh set filetype=python
- au BufNewFile,BufRead Dockerfile* set filetype=dockerfile
- " md options
- augroup md_settings
- autocmd FileType markdown set textwidth=80
- autocmd FileType markdown set nocindent
- autocmd FileType markdown set spell
- augroup END
- set wildmode=longest:full
- " switch ' and `
- noremap ' `
- noremap ` '
- noremap Y y$
- noremap <leader>y "*y
- noremap <leader>p "*p
- " In nvim, open keyword/help in new terminal,
- " as nvim doesn't currently allow terminal scrollback.
- function! KeywordNvim(searchTerm)
- if &keywordprg == ':Man'
- exe ':Man ' . a:searchTerm
- else
- let l:man = &keywordprg
- vsplit | enew
- exe 'terminal ' . l:man a:searchTerm
- normal i
- endif
- endfunction
- function! KeywordNvimVisual()
- let l:saved_reg = @"
- execute "normal! vgvy"
- call KeywordNvim(@")
- let @" = l:saved_reg
- endfunction
- " if has("nvim")
- " nnoremap K :call KeywordNvim(expand("<cword>"))<CR>
- " vnoremap K <Esc>:call KeywordNvimVisual()<CR>
- " endif
- let g:clipboard = {
- \ 'name': 'My xsel',
- \ 'copy': {
- \ '+': 'xsel -i',
- \ '*': 'xsel -ib',
- \ },
- \ 'paste': {
- \ '+': 'xsel -i',
- \ '*': 'xsel -ib',
- \ },
- \ 'cache_enabled': 1,
- \ }
- " comment strings
- augroup comment_strings
- autocmd FileType python set commentstring=#\ %s
- augroup END
- " }}}
- "{{{ ***** VISUALS ***** "
- set number
- set relativenumber
- set expandtab
- set shiftwidth=2
- set softtabstop=2
- set autoindent
- set nosmartindent
- set foldmethod=indent
- set background=dark
- syntax on
- augroup numbertoggle
- autocmd!
- autocmd BufEnter,FocusGained,InsertLeave,WinEnter,CmdlineLeave * if &nu | set rnu | endif
- autocmd BufLeave,FocusLost,InsertEnter,WinLeave,CmdlineEnter * if &nu | set nornu | redraw | endif
- augroup END
- autocmd BufWinEnter * if line2byte(line("$") + 1) > 10000000 | syntax clear | endif
- colorscheme devbox-dark-256
- set termguicolors&
- set showcmd
- "}}}
- "{{{ ***** KEY MAPPINGS ***** "
- " make <C-A> work the same in tmux and not
- nnoremap <C-C> <C-A>
- " easier buffer navigation
- " nnoremap bn :bn<CR>
- " nnoremap bp :bp<CR>
- " make backspace work
- set backspace=eol,start,indent
- set whichwrap+=<,>,h,l
- set whichwrap+=<,>,h,l
- " nnoremap <silent> <F5> :so ~/.vim/vimrc<CR>:LvimrcReload<CR>
- nnoremap <silent> <F5> :so ~/.vim/vimrc<CR>
- nnoremap <silent> <F6> :redraw!<CR>
- " set pastetoggle=<F7>
- nmap <F8> :mks!<CR>
- " treat wrapped lines as multiple lines when navigating
- map j gj
- map k gk
- " Scroll the window more intuitively
- nnoremap <M-j> <C-e>
- nnoremap <M-k> <C-y>
- nnoremap <M-h> 10zh
- nnoremap <M-l> 10zl
- nnoremap j <C-e>
- nnoremap k <C-y>
- nnoremap h 10zh
- nnoremap l 10zl
- vnoremap <M-j> <C-e>
- vnoremap <M-k> <C-y>
- vnoremap <M-h> 10zh
- vnoremap <M-l> 10zl
- vnoremap j <C-e>
- vnoremap k <C-y>
- vnoremap h 10zh
- vnoremap l 10zl
- " Open a new line and exit insert mode, staying on the same line
- nnoremap <leader>o o<ESC>
- nnoremap <leader>O O<ESC>
- " Clean a line and exit insert mode
- nnoremap <leader>c cc<ESC>
- " Exit insert mode and put ';' at the end of the line
- " inoremap ;<Esc> <Esc>A;<Esc>
- " Open tag in new tab
- nnoremap <M-]> <C-W><C-]><C-W>T
- " Toggle TODOs as done or not
- nnoremap <silent> <leader>x :s/\[ \]TODO/[X]TODO/<CR>:nohl<CR>
- nnoremap <silent> <leader><space> :s/\[X\]TODO/[ ]TODO/<CR>:nohl<CR>
- " copy 'filename:linenumber' to @f register. useful for adding links to
- " places in files in comments
- nnoremap <silent> <leader>gf :let @f=@% . ':' . line('.')<CR>:echo @f<CR>
- " WINDOW ORGANISATION
- " Smart way to move between windows
- map <C-j> <C-W>j
- map <C-k> <C-W>k
- map <C-h> <C-W>h
- map <C-l> <C-W>l
- map <C-Up> <C-W>k
- map <C-Down> <C-W>j
- map <C-Left> <C-W>h
- map <C-Right> <C-W>l
- " easy resize windows
- nnoremap <S-Up> <C-W>+
- nnoremap <S-Down> <C-W>-
- nnoremap <S-Left> 3<C-W><
- nnoremap <S-Right> 3<C-W>>
- " easy move windows
- nnoremap <C-S-Up> <C-W><S-K>
- nnoremap <C-S-Down> <C-W><S-J>
- nnoremap <C-S-Left> <C-W><S-H>
- nnoremap <C-S-Right> <C-W><S-L>
- " close annoying windows easily
- nnoremap cq :cclose<CR>
- nnoremap cqq :lclose<CR>
- nnoremap cp :pclose<CR>
- " Call CopyMode
- vnoremap <C-c> :call CopyMode()<CR><CR>
- " Visual mode pressing * or # searches for the current selection
- " Super useful! From an idea by Michael Naumann
- vnoremap <silent> * :call VisualSelection('f')<CR>
- vnoremap <silent> # :call VisualSelection('b')<CR>
- " Default building/running options
- let g:run_command = 'echo No run command defined'
- nnoremap <leader>` :execute "Start " . g:run_command<CR>
- nnoremap <F3> :Make %<CR>
- autocmd FileType lilypond setlocal makeprg=lilypond
- augroup python_build
- autocmd FileType python compiler pylint
- autocmd FileType python nnoremap <F3> :Make %<CR>
- autocmd FileType python nnoremap <S-F3> :Make .<CR>
- autocmd FileType python nnoremap <F4> :Dispatch mypy %<CR>
- autocmd FileType python nnoremap <S-F4> :Dispatch mypy .<CR>
- augroup END
- " Quickly edit a macro
- nnoremap <leader>@ :<c-u><c-r><c-r>='let @'. v:register .' = '. string(getreg(v:register))<cr><c-f><left>
- " Quickly edit the Q macro
- nnoremap <leader>q :<c-u><c-r><c-r>='let @q = '. string(getreg('q'))<cr><c-f><left>
- " go back and delete last buffer (dangerous if the going back doesn't bring
- " you to another buffer
- nnoremap <M-C-O> <C-^>:bd! #<CR>
- " toggle number
- nnoremap <silent> -- :set number!<CR>
- " toggle cursorcolumn
- nnoremap <silent> scc :set cursorcolumn!<CR>
- " insert command at line
- inoremap <C-r>! <C-\><C-O>:let @r=system("")<left><left>
- " terminal escape
- " tnoremap <Esc><Esc> <C-\><C-N>
- " enter selects menu entry (<CR> is already remaped by delimitMate, so
- " hardcode what it does to mimic behavior)
- imap <expr> <CR> pumvisible() ? "\<C-Y>" : "<Plug>delimitMateCR"
- " base64 decode selected text
- :vnoremap <leader>64 d:let @@ = system('base64 --decode', @")<cr><esc>o<esc>p
- " }}}
- "{{{ ***** COMMANDS ***** "
- " Terminal commands
- command! -nargs=0 VTerm vsplit term://bash
- command! -nargs=0 STerm split term://bash
- command! -nargs=0 VPyTerm vsplit term://python3
- command! -nargs=0 SPyTerm split term://python3
- " make todo list
- " command! -nargs=* -complete=file Todos execute "Unite -keep-focus -auto-resize -no-quit -buffer-name=Todos vimgrep:%:TODO(" . expand("$USER") . ")"
- " Edit ~/.vim/vimrc in a new tab
- command! -nargs=0 EditVimrc tabedit ~/.vim/vimrc
- " Swap two lines
- command! -nargs=1 -range Swap call Swap(<f-args>)
- function! Swap(s1, s2, d1, d2)
- let cursor = line(".")
- echo "swap <" . a:s1 . "," . a:s2 . "> and <" . a:d1 . "," . a:d2 . ">"
- if a:s1 <= a:d1
- let l:source1 = a:s1
- let l:source2 = a:s2
- let l:dest1 = a:d1
- let l:dest2 = a:d2
- else
- let l:dest1 = a:s1
- let l:dest2 = a:s2
- let l:source1 = a:d1
- let l:source2 = a:d2
- endif
- let l:offset = l:source2 - l:source1
- execute l:source1 .",". lsource2 . "move " . l:dest2
- execute l:dest1 . "," . l:dest2 . "move " . l:source2
- execute l:source1 . ",". l:source2 . "normal =="
- execute l:dest1 . ",". l:dest2 . "normal =="
- execute "normal " . cursor . "G"
- endfunction
- function! CopyMode() range
- execute a:firstline . "," . a:lastline . "yank c"
- tabnew
- setlocal nonumber
- setlocal norelativenumber
- setlocal showbreak=
- map <buffer> <silent> <C-V> :bd!<CR>
- normal [p
- endfunction
- " Diff original file (from help)
- command! DiffOrig vert new | set bt=nofile | r ++edit # | 0d_
- \ | diffthis | wincmd p | diffthis
- " from https://amix.dk/vim/vimrc.html
- function! VisualSelection(direction) range
- let l:saved_reg = @"
- execute "normal! vgvy"
- let l:pattern = escape(@", '\\/.*$^~[]')
- let l:pattern = substitute(l:pattern, "\n", "", "")
- let l:pattern = '\<'.l:pattern.'\>'
- if a:direction == 'b'
- execute "normal ?" . l:pattern . "^M"
- " elseif a:direction == 'gv'
- " call CmdLine("vimgrep " . '/'. l:pattern . '/' . ' **/*.')
- " elseif a:direction == 'replace'
- " call CmdLine("%s" . '/'. l:pattern . '/')
- elseif a:direction == 'f'
- " execute "normal /" . l:pattern . "^M"
- execute "normal /" . l:pattern
- endif
- let @/ = l:pattern
- let @" = l:saved_reg
- endfunction
- " }}}
- "{{{ ***** MACHINE SPECIFIC CONFIG ***** "
- command! -nargs=0 EditCustomVimrc tabedit ~/.vimrc_custom
- if filereadable($HOME . "/.vimrc_custom")
- source ~/.vimrc_custom
- endif
- "}}}
- lua << EOF
- require('swenv').setup({
- -- Should return a list of tables with a `name` and a `path` entry each.
- -- Gets the argument `venvs_path` set below.
- -- By default just lists the entries in `venvs_path`.
- get_venvs = function(venvs_path)
- return require('swenv.api').get_venvs(venvs_path)
- end,
- -- Path passed to `get_venvs`.
- venvs_path = vim.fn.expand('~/.pyenv/versions'),
- -- Something to do after setting an environment, for example call vim.cmd.LspRestart
- post_set_venv = function()
- vim.cmd.CocRestart()
- end,
- })
- EOF
- lua require('swenv.api').auto_venv()
|