Created
March 13, 2020 15:23
-
-
Save davidbegin/befece03b96064a2142e828a6acd4ba9 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
" Color name (:help cterm-colors) or ANSI code | |
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 'tpope/vim-surround' | |
Plug 'scrooloose/nerdtree' | |
Plug 'junegunn/goyo.vim' | |
Plug 'junegunn/limelight.vim' | |
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } } | |
Plug 'PotatoesMaster/i3-vim-syntax' | |
Plug 'jreybert/vimagit' | |
Plug 'bling/vim-airline' | |
Plug 'tpope/vim-commentary' | |
Plug 'neoclide/coc.nvim', {'branch': 'release'} | |
Plug 'godlygeek/tabular' | |
Plug 'mattn/gist-vim' | |
Plug 'mattn/webapi-vim' | |
" Plug 'lokikl/vim-ctrlp-ag' | |
Plug 'gabesoft/vim-ags' | |
Plug 'ctrlpvim/ctrlp.vim' | |
Plug 'vimwiki/vimwiki' | |
" Plug 'lukesmithxyz/vimling' | |
" Plug 'kovetskiy/sxhkd-vim' | |
call plug#end() | |
" Run xrdb whenever Xdefaults or Xresources are updated. | |
autocmd BufWritePost *Xresources,*Xdefaults !xrdb % | |
" =========== Begin Settings =========== | |
" Lets us yank in vim and then paste to other programs | |
set clipboard+=unnamedplus | |
set foldmethod=indent | |
" 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>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>rc :source ~/.config/nvim/init.vim<cr> | |
noremap <leader>rc :so ~/.config/nvim/init.vim<cr> | |
noremap ,p :w!\|!python3 -m pytest -s %:p<cr> | |
" noremap ,p :w!\|!python3 -m pytest --capture=sys %:p<cr> | |
noremap ,f :w!\|!python3 -m pytest %:p -m focus<cr> | |
noremap ,t :w!\|!python %:p<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> | |
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) | |
" stupac62: l: is local scope to the function. s: is script scope g: is global | |
" | |
" How do you run two commands in a row | |
" How do you use the paste buffer in a remapping | |
:vnoremap <leader>gg :Gist<cr>; beginbot @+<cr> | |
"the highlighted section | |
"call the gist command | |
"use the paste buffer and beginbot command | |
:vnoremap <leader>co :<c-u>call <SID>GistAndPost(visualmode())<cr> | |
function! s:GistAndPost(type) | |
if a:type ==# 'V' | |
execute "normal! `<v`>y" | |
endif | |
" We Need Labcoats | |
" echom @@ | |
" let l:uri=system("gist -P") | |
" let s:path = resolve(expand('<sfile>:p')) | |
let s:path = expand('%') | |
echom s:path | |
let s:uri=system('gist ' . s:path . ' ' ) | |
" echom s:path | |
" echo s:path | |
" let s:chat=system('beginbot testing') | |
" let s:chat=system('beginbot ' . s:path . ' ') | |
" echom @+ | |
" let s:uri=<Plug>Gist | |
" let s:msg=getline('.') | |
" let @+ = s:msg | |
" let s:output = system("ls") | |
" let s:print = system('echo ' . s:output . ' ') | |
" let s:print = system('echo hello') | |
" let s:chat=system('cat ~/.config/TWITCH_CHAT_COMMANDS | dmenu -l 30 | xargs beginbot') | |
endfunction | |
:nnoremap <leader>tu :call <SID>PostChatByUser()<cr> | |
function! s:PostChatByUser() | |
let s:viewer = input('Viewer: ') | |
let s:chat=system('beginchat -a | grep -i ' . s:viewer . ' | tail -5 ') | |
let @+ = s:chat | |
endfunction | |
:nnoremap <leader>tr :call <SID>PostChat()<cr> | |
: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: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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment