Created
April 23, 2020 14:36
-
-
Save davidbegin/0bcbd9632349ee472a40aedbaeaebbf8 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
let g:vimwiki_list = [{'path': '/home/begin/vimwiki/', | |
\ 'syntax': 'markdown', 'ext': '.wiki'}] | |
let g:limelight_conceal_ctermfg = 'gray' | |
let g:limelight_conceal_ctermfg = 240 | |
if ! filereadable(expand('~/.config/nvim/autoload/plug.vim')) | |
echo "Downloading junegunn/vim-plug to manage plugins..." | |
silent !mkdir -p ~/.config/nvim/autoload/ | |
silent !curl "https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim" > ~/.config/nvim/autoload/plug.vim | |
autocmd VimEnter * PlugInstall | |
endif | |
call plug#begin('~/.config/nvim/plugged') | |
Plug 'hashivim/vim-terraform' | |
Plug 'tpope/vim-fugitive' | |
Plug 'junegunn/goyo.vim' | |
Plug 'junegunn/limelight.vim' | |
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } } | |
Plug 'PotatoesMaster/i3-vim-syntax' | |
Plug 'jreybert/vimagit' | |
Plug 'ripxorip/aerojump.nvim', { 'do': ':UpdateRemotePlugins' } | |
Plug 'tpope/vim-commentary' | |
Plug 'neoclide/coc.nvim', {'branch': 'release'} | |
Plug 'godlygeek/tabular' | |
Plug 'mattn/gist-vim' | |
Plug 'mattn/webapi-vim' | |
Plug 'gabesoft/vim-ags' | |
Plug 'ctrlpvim/ctrlp.vim' | |
Plug 'vimwiki/vimwiki' | |
Plug 'frazrepo/vim-rainbow' | |
Plug 'dylanaraps/wal.vim' | |
Plug 'bronson/vim-trailing-whitespace' | |
Plug 'scrooloose/nerdtree' | |
" Plug 'bling/vim-airline' | |
" Plug 'lokikl/vim-ctrlp-ag' | |
" Plug 'lukesmithxyz/vimling' | |
" Plug 'kovetskiy/sxhkd-vim' | |
call plug#end() | |
" Run xrdb whenever Xdefaults or Xresources are updated. | |
autocmd BufWritePost *Xresources,*Xdefaults !xrdb % | |
let g:rainbow_active = 1 | |
" =========== Begin Settings =========== | |
" Lets us yank in vim and then paste to other programs | |
set clipboard+=unnamedplus | |
" set foldmethod=indent | |
" set foldlevel=99 | |
set nofoldenable | |
let g:python3_host_prog = '/usr/bin/python3' | |
" open folds when opening a file | |
autocmd FileType * exe "normal zR" | |
set spell spelllang=en_us | |
" --------- Markdown Header functionality -------- | |
:nnoremap <leader>h1 :call <SID>MdTitle('=')<cr> | |
:nnoremap <leader>h2 :call <SID>MdTitle('-')<cr> | |
function! s:MdTitle(sign) | |
let cnt=strwidth(getline('.')) | |
execute "normal! o" repeat(a:sign,cnt) | |
execute "normal! 0xj" | |
endfunction | |
" Disable Arrow keys in Escape mode | |
map <up> <nop> | |
map <down> <nop> | |
map <left> <nop> | |
map <right> <nop> | |
" Disable Arrow keys in Insert mode | |
imap <up> <nop> | |
imap <down> <nop> | |
imap <left> <nop> | |
imap <right> <nop> | |
" set number | |
" set relativenumber | |
set tabstop=2 | |
set softtabstop=0 expandtab | |
set shiftwidth=2 | |
set hlsearch | |
noremap <leader>ll <cr>i# =============================================================================<cr> | |
noremap <leader>` <cr>i```<cr>```<Esc>O | |
noremap <leader>hh <cr>i===<cr> | |
noremap <leader>s 1z= | |
nmap <S-Enter> O<Esc> | |
nmap <CR> o<Esc> | |
noremap <leader>e :edit %:h<cr> | |
noremap <leader>gg :Goyo<cr> | |
noremap <leader>pp :set paste<cr> | |
noremap <leader>pk :set nopaste<cr> | |
noremap <leader>bb <cr>ibreakpoint()<cr> | |
noremap <leader>fo <cr>[email protected]<cr><Esc> | |
noremap <leader>jq :%!python -m json.tool<cr> | |
noremap <leader>rc :source ~/.config/nvim/init.vim<cr> | |
nnoremap <C-J> <C-W><C-J> | |
nnoremap <C-K> <C-W><C-K> | |
nnoremap <C-L> <C-W><C-L> | |
nnoremap <C-H> <C-W><C-H> | |
noremap ,, <esc>:w!<cr> | |
noremap <leader>ag :Ags | |
noremap <leader>tt :Tabularize/ | |
noremap ff :resize 100 <cr> <bar> :vertical resize 220<cr> | |
noremap fm <C-w>= | |
noremap <leader>ff :FixWhitespace<cr> | |
iab teh the | |
iab wikipedia Wikipedia | |
nnoremap <leader>wl :call WhitelistUser()<CR> | |
nnoremap <leader>bl :call BlacklistUser()<CR> | |
function! WhitelistUser() | |
let s:user = expand("<cword>") | |
let s:result=system('~/code/chat_thief/scripts/whitelist_user ' . s:user) | |
echo s:result | |
endfunction | |
function! BlacklistUser() | |
let s:user = expand("<cword>") | |
let s:result=system('~/code/chat_thief/scripts/blacklist_user ' . s:user) | |
echo s:result | |
endfunction | |
" function and shortcut to add "import <word under cursor" to the top of the | |
" file | |
function! AddImport() | |
let module = expand("<cword>") | |
call append(0, "import " . module) | |
endfunction | |
nnoremap <silent> <leader>im :call AddImport()<CR> | |
noremap ,p :w!\|!python3 %<cr> | |
noremap ,t :w!\|!make t<cr> | |
noremap ,f :w!\|!make f<cr> | |
" Color name (:help cterm-colors) or ANSI code | |
" | |
set noshowmode | |
" use <tab> for trigger completion and navigate to the next complete item | |
function! s:check_back_space() abort | |
let col = col('.') - 1 | |
return !col || getline('.')[col - 1] =~ '\s' | |
endfunction | |
inoremap <silent><expr> <Tab> | |
\ pumvisible() ? "\<C-n>" : | |
\ <SID>check_back_space() ? "\<Tab>" : | |
\ coc#refresh() | |
autocmd BufWritePost .vimrc source % | |
set background=dark | |
" set t_8f=^[[38;2;%lu;%lu;%lum " set foreground color | |
" set t_8b=^[[48;2;%lu;%lu;%lum " set background color | |
" colorscheme Tomorrow-Night-Eighties | |
set t_Co=256 " Enable 256 colors | |
set termguicolors " Enable GUI colors for the terminal to get truecolor | |
" colorscheme wal | |
" Limelight Configuration | |
" Color name (:help cterm-colors) or ANSI code | |
let g:limelight_conceal_ctermfg = 'gray' | |
let g:limelight_conceal_ctermfg = 240 | |
" Color name (:help gui-colors) or RGB color | |
let g:limelight_conceal_guifg = 'DarkGray' | |
let g:limelight_conceal_guifg = '#777777' | |
" Default: 0.5 | |
" let g:limelight_default_coefficient = 0.7 | |
" Number of preceding/following paragraphs to include (default: 0) | |
" let g:limelight_paragraph_span = 1 | |
" Beginning/end of paragraph | |
" When there's no empty line between the paragraphs | |
" and each paragraph starts with indentation | |
" let g:limelight_bop = '^\s' | |
" let g:limelight_eop = '\ze\n^\s' | |
" Highlighting priority (default: 10) | |
" Set it to -1 not to overrule hlsearch | |
let g:limelight_priority = -1 | |
autocmd! User GoyoEnter Limelight | |
autocmd! User GoyoLeave Limelight! | |
" Applying codeAction to the selected region. | |
" Example: `<leader>aap` for current paragraph | |
xmap <leader>a <Plug>(coc-codeaction-selected) | |
nmap <leader>a <Plug>(coc-codeaction-selected) | |
" Remap keys for applying codeAction to the current line. | |
nmap <leader>ac <Plug>(coc-codeaction) | |
" Apply AutoFix to problem on the current line. | |
nmap <leader>qf <Plug>(coc-fix-current) | |
" nnoremap <buffer> H :w!\|!pydoc3 <cword><CR> | |
" pydoc3 pathlib | nvim pathlib -c "set buftype=nofile" | |
" nnoremap <buffer> H :w!\|!pydoc3 <cword><CR> | |
" nnoremap <buffer> H :w!\|!pydoc3 <cword><CR> | |
" nnoremap <buffer> H :w!\|!pydoc3 <cword> > <cword>.doc<CR>; nvim <cword>.doc<CR> | |
" noremap <buffer> H :w!\|!pydoc3 <cword> | vim - -c "set buftype=nofile"<CR> | |
" What is the :<C-u>execute for? | |
" nnoremap <buffer> H :<C-u>execute "!pydoc3 " . expand("<cword>")<CR> | |
" nnoremap <buffer> H :call <SID>OpenPyDocs()<CR> | |
" function! s:OpenPyDocs() | |
" " let s:viewer = input('Viewer: ') | |
" " let s:chat=system('echo ' . keyword) | |
" " let s:chat=system('pydoc3 pathlib | nvim - -c "set buftype=nofile"') | |
" let s:chat=system('pydoc3 pathlib') | |
" endfunction | |
" How do you use the paste buffer in a remapping | |
" :vnoremap <leader>gg :Gist<cr>; beginbot @+<cr> | |
:vmap <leader>gi :call <SID>GistAndPost(mode())<cr> | |
:nmap <leader>gi :call <SID>GistAndPost(mode())<cr> | |
function! s:GistAndPost(type) | |
if a:type ==# 'V' | |
let l:lines = getline("'<", "'>") | |
else | |
let l:lines = getline('^', '$') | |
endif | |
let l:uri = system('gist', l:lines) | |
let s:chat=system('beginbot ' . l:uri . ' ') | |
endfunction | |
:nnoremap <leader>ts :call <SID>PostChatByUser()<cr> | |
function! s:PostChatByUser() | |
let s:viewer = input('SearcSearchh: ') | |
let s:chat=system('beginchat -a | grep -i ' . s:viewer . ' | tail -5 ') | |
let @+ = s:chat | |
endfunction | |
function! s:LastTwitchMsg() | |
let s:chat=system('beginchat -c 2') | |
let @+ = s:chat | |
execute "normal! p" | |
endfunction | |
:nnoremap <leader>tl :call <SID>LastTwitchMsg()<cr> | |
:nnoremap <leader>rr :call <SID>DecryptTheChat()<cr> | |
:nnoremap <leader>tr :call <SID>PostChat()<cr> | |
:nnoremap <leader>ob :call <SID>ObsSceneCommands()<cr> | |
function! s:ObsSceneCommands() | |
let s:chat=system('echo "codin\ncubin\nbrb\nstart" | dmenu -l 29 | xargs scene') | |
endfunction | |
:nnoremap <leader>oa :call <SID>ObsSourceCommands()<cr> | |
function! s:ObsSourceCommands() | |
let s:chat=system('echo "idk\nwyp\nha\nclap\nahh" | dmenu -l 30 | xargs so') | |
endfunction | |
" Turn them all off | |
:nnoremap <leader>os :!nomeme<cr> | |
" endfunction | |
:nnoremap <leader>m :call <SID>Emojis()<cr> | |
function! s:Emojis() | |
let s:emoji=system('cat ~/.local/share/larbs/emoji | dmenu -l 30 ') | |
let @+ = s:emoji | |
execute "normal! pld$" | |
endfunction | |
" :noremap <leader>tu | |
:nnoremap <leader>te :call <SID>TwitchCommands()<cr> | |
function! s:TwitchCommands() | |
let s:chat=system('cat ~/.config/TWITCH_CHAT_COMMANDS | dmenu -l 30 | xargs beginbot') | |
endfunction | |
function! s:DecryptTheChat() | |
let s:chat=system('beginchat -c 1') | |
let @+ = s:chat | |
execute "normal! p" | |
endfunction | |
:nnoremap <leader>pd :call <SID>PyDocSearch()<cr> | |
function! s:PyDocSearch() | |
let s:search = input("Python Doc Keyword: ") | |
" pydoc3 -k <keyword> | |
" Search for a keyword in the synopsis lines of all available modules. | |
let s:module=system('pydoc3 -k string | dmenu -l 30') | |
let @+ = s:module | |
endfunction | |
function! s:PostChat() | |
let s:chat=system('beginchat') | |
let @+ = s:chat | |
endfunction | |
:nnoremap <leader>tw :call <SID>SendToTwitch()<cr> | |
:vnoremap <leader>tw :call <SID>SendToTwitch()<cr> | |
function! s:SendToTwitch() | |
let s:msg=getline('.') | |
" Escape "'s or we won't be able to send lines with " | |
let s:msg=substitute(s:msg, '"', '\\\"', '') | |
let s:regexForUrl='[a-z]*:\/\/[^ >,;)]*' | |
let s:uri=matchstr(s:msg, s:regexForUrl) | |
if len(s:uri)>0 | |
let s:twitch_call=system('beginbot " ' . s:uri. '"') | |
else | |
let s:twitch_call=system('beginbot " ' . s:msg . '"') | |
endif | |
endfunction | |
" in normal, remap, but not recursively | |
:nnoremap <leader>ll :call <SID>MdLink()<cr> | |
" Get title of youtube link | |
function! s:YoutubeTitle(ytUrl) | |
" what is . and the a: ???? | |
let l:ytTitle=system('youtube-dl -e "' . a:ytUrl . '"') | |
return l:ytTitle | |
endfunction | |
function! s:CurlTitle(url) | |
let s:rawTitle=system('curl -s ' . a:url . ' | grep "<title>"') | |
if len(s:rawTitle)>0 | |
let s:title=substitute(substitute(s:rawTitle, '<title>', '', ''), '</title>', '', '') | |
else | |
let s:title='' | |
endif | |
return s:title | |
endfunction | |
function s:MdCreateLink(title, url, posStart, posEnd) | |
let l:curPos=getcurpos()[1:] | |
" set cursor to end of url to add ")" | |
call cursor(l:curPos[0], a:posEnd) | |
execute "normal! a)" | |
" set cursor to start of url | |
call cursor(l:curPos[0], a:posStart) | |
execute "normal! i[" . a:title . "](\<esc>" | |
endfunction | |
" Create Markdown link getting title from url | |
function! s:MdLink() | |
" Should reach cannonicial regex for URLs | |
let s:regexForUrl='[a-z]*:\/\/[^ >,;)]*' | |
" matchstr is part vimscript? | |
" getline means grab the whole line | |
let s:uri=matchstr(getline('.'), s:regexForUrl) | |
let s:posStart=match(getline('.'), s:regexForUrl) + 1 | |
let s:posEnd=matchend(getline('.'), s:regexForUrl) | |
if len(matchstr(s:uri, 'youtube\.com'))>0 | |
let s:title=s:YoutubeTitle(s:uri) | |
elseif len(matchstr(s:uri, 'youtu.be'))>0 | |
let s:title=s:YoutubeTitle(s:uri) | |
else | |
let s:title=s:CurlTitle(s:uri) | |
endif | |
let s:cleanTitle=substitute(s:title, '\n\+$', '', '') | |
call s:MdCreateLink(s:cleanTitle, s:uri, s:posStart, s:posEnd) | |
endfunction | |
set wrap | |
set linebreak | |
set nolist | |
set textwidth=80 | |
" set rtp+=~/.fzf | |
vnoremap <c-f> :CtrlPag<cr> | |
vnoremap <c-f> :CtrlPagVisual<cr> | |
nnoremap <leader>ca :CtrlPagLocate | |
nnoremap <leader>cp :CtrlPagPrevious<cr> | |
let g:ctrlp_ag_ignores = '--ignore .git | |
\ --ignore "deps/*" | |
\ --ignore "_build/*" | |
\ --ignore "node_modules/*"' | |
" By default ag will search from PWD | |
" But you may enable one of below line to use an arbitrary directory or, | |
" Using the magic word 'current-file-dir' to use current file base directory | |
" let g:ctrlp_ag_search_base = 'current-file-dir' | |
" let g:ctrlp_ag_search_base = 'app/controllers' " both relative and absolute path supported | |
" https://vim.fandom.com/wiki/Quickly_adding_and_deleting_empty_lines#:~:text= | |
" Ctrl-j/k deletes blank line below/above, and Alt-j/k inserts. | |
" nnoremap <silent><C-j> m`:silent +g/\m^\s*$/d<CR>``:noh<CR> | |
" nnoremap <silent><C-k> m`:silent -g/\m^\s*$/d<CR>``:noh<CR> | |
" nnoremap <silent><C-J> :set paste<CR>m`o<Esc>``:set nopaste<CR> | |
" nnoremap <silent><C-K> :set paste<CR>m`O<Esc>``:set nopaste<CR> | |
" function! RunPytest() | |
" :exe "!tmux send -t 1 ' python3 -m pytest' Enter" | |
" :exe "!tmux send -t 0 Enter k" | |
" endfunction | |
" autocmd BufWritePost *.py :call RunPytest() | |
" ================ | |
" ===== COC ====== | |
" ================ | |
" TextEdit might fail if hidden is not set. | |
set hidden | |
" Some servers have issues with backup files, see #649. | |
set nobackup | |
set nowritebackup | |
" Give more space for displaying messages. | |
set cmdheight=2 | |
" Having longer updatetime (default is 4000 ms = 4 s) leads to noticeable | |
" delays and poor user experience. | |
set updatetime=300 | |
" Don't pass messages to |ins-completion-menu|. | |
set shortmess+=c | |
" 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: 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> | |
\ pumvisible() ? "\<C-n>" : | |
\ <SID>check_back_space() ? "\<TAB>" : | |
\ coc#refresh() | |
inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>" | |
function! s:check_back_space() abort | |
let col = col('.') - 1 | |
return !col || getline('.')[col - 1] =~# '\s' | |
endfunction | |
" Use <c-space> to trigger completion. | |
inoremap <silent><expr> <c-space> coc#refresh() | |
" Use <cr> to confirm completion, `<C-g>u` means break undo chain at current | |
" position. Coc only does snippet and additional edit on confirm. | |
if has('patch8.1.1068') | |
" Use `complete_info` if your (Neo)Vim version supports it. | |
inoremap <expr> <cr> complete_info()["selected"] != "-1" ? "\<C-y>" : "\<C-g>u\<CR>" | |
else | |
imap <expr> <cr> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>" | |
endif | |
" Use `[g` and `]g` to navigate diagnostics | |
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> | |
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 codeAction to the selected region. | |
" Example: `<leader>aap` for current paragraph | |
xmap <leader>a <Plug>(coc-codeaction-selected) | |
nmap <leader>a <Plug>(coc-codeaction-selected) | |
" Remap keys for applying codeAction to the current line. | |
nmap <leader>ac <Plug>(coc-codeaction) | |
" Apply AutoFix to problem on the current line. | |
nmap <leader>qf <Plug>(coc-fix-current) | |
" Introduce function text object | |
" NOTE: Requires 'textDocument.documentSymbol' support from the language server. | |
xmap if <Plug>(coc-funcobj-i) | |
xmap af <Plug>(coc-funcobj-a) | |
omap if <Plug>(coc-funcobj-i) | |
omap af <Plug>(coc-funcobj-a) | |
" Use <TAB> for selections ranges. | |
" NOTE: Requires 'textDocument/selectionRange' support from the language server. | |
" coc-tsserver, coc-python are the examples of servers that support it. | |
nmap <silent> <TAB> <Plug>(coc-range-select) | |
xmap <silent> <TAB> <Plug>(coc-range-select) | |
" Add `:Format` command to format current buffer. | |
command! -nargs=0 Format :call CocAction('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 CocAction('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 using CoCList: | |
" Show all diagnostics. | |
nnoremap <silent> <space>a :<C-u>CocList diagnostics<cr> | |
" Manage extensions. | |
nnoremap <silent> <space>e :<C-u>CocList extensions<cr> | |
" Show commands. | |
nnoremap <silent> <space>c :<C-u>CocList commands<cr> | |
" Find symbol of current document. | |
nnoremap <silent> <space>o :<C-u>CocList outline<cr> | |
" Search workspace symbols. | |
nnoremap <silent> <space>s :<C-u>CocList -I symbols<cr> | |
" Do default action for next item. | |
nnoremap <silent> <space>j :<C-u>CocNext<CR> | |
" Do default action for previous item. | |
nnoremap <silent> <space>k :<C-u>CocPrev<CR> | |
" Resume latest coc list. | |
nnoremap <silent> <space>p :<C-u>CocListResume<CR> | |
nnoremap <leader>nj :!nojam<cr> | |
" Create mappings (with leader) | |
nmap <Leader>as <Plug>(AerojumpSpace) | |
nmap <Leader>ab <Plug>(AerojumpBolt) | |
nmap <Leader>aa <Plug>(AerojumpFromCursorBolt) | |
nmap <Leader>ad <Plug>(AerojumpDefault) " Boring mode |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment