diff options
| author | Vito Graffagnino <vito@graffagnino.xyz> | 2020-09-19 16:40:47 +0100 |
|---|---|---|
| committer | Vito Graffagnino <vito@graffagnino.xyz> | 2020-09-19 16:40:47 +0100 |
| commit | ec3c4a0b2d4993324acd6bc00545836ac00759ce (patch) | |
| tree | 947852b39b2408b3e27d6087d79648db02cca37f | |
| parent | 0ffc4b3712f71e4d88f700d4aef9ac7443bc6a36 (diff) | |
| -rwxr-xr-x | .vimrc | 999 | ||||
| -rwxr-xr-x | urlportal.sh | 245 |
2 files changed, 1244 insertions, 0 deletions
@@ -0,0 +1,999 @@ +" ================================= +" Vimrc +" ================================= +" +" Plugin setup --- via Pathogen ----- {{{ +" set nocompatible +" filetype off +" execute pathogen#infect() +" execute pathogen#helptags() +" }}} +" +" ================================= +" +" Plugin setup --- via vundle ----- {{{ +" +if has('vim') + set nocompatible +endif +filetype off +" +" set the runtime path to include Vundle and initialize +" +set rtp+=$HOME/.vim/bundle/Vundle.vim +" +call vundle#begin() +" +" let Vundle manage Vundle, required +" +Plugin 'VundleVim/Vundle.vim' +Plugin 'alfredodeza/pytest.vim' +Plugin 'altercation/vim-colors-solarized' +Plugin 'benmills/vimux' +Plugin 'cburroughs/pep8.py' +Plugin 'chriskempson/tomorrow-theme' +Plugin 'christoomey/vim-tmux-navigator' +Plugin 'davidhalter/jedi-vim' +Plugin 'dbeniamine/vim-mail' +Plugin 'ervandew/screen' +Plugin 'ervandew/supertab' +Plugin 'flazz/vim-colorschemes' " Colourschemes +Plugin 'honza/vim-snippets' +Plugin 'jistr/vim-nerdtree-tabs' +Plugin 'jnurmine/Zenburn' +Plugin 'julienr/vim-cellmode' +Plugin 'junegunn/goyo.vim' +Plugin 'junegunn/fzf.vim' +Plugin 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' } +Plugin 'junegunn/limelight.vim' +Plugin 'junegunn/seoul256.vim' +Plugin 'KabbAmine/zeavim.vim' +Plugin 'kien/ctrlp.vim' " Fast transitions on project files +Plugin 'klen/python-mode' " Python mode (docs, refactor, lints...) +Plugin 'majutsushi/tagbar' " Class/module browser +Plugin 'mileszs/ack.vim' +Plugin 'mitsuhiko/vim-jinja' +Plugin 'mitsuhiko/vim-python-combined' +Plugin 'mitsuhiko/vim-sparkup' " Sparkup(XML/jinja/htlm-django/etc.) support +Plugin 'nelstrom/vim-markdown-preview' +Plugin 'nvie/vim-flake8' +Plugin 'pangloss/vim-javascript' +Plugin 'rkulla/pydiction' +Plugin 'Rykka/riv.vim' " ReStructuredText plugin +Plugin 'scrooloose/nerdtree' " Project and file navigation +Plugin 'scrooloose/nerdcommenter' " Comment stuff out +Plugin 'scrooloose/syntastic' " Syntax checking plugin for Vim +Plugin 'SirVer/ultisnips' +Plugin 'sjl/tslime2.vim' +Plugin 'suan/vim-instant-markdown' +Plugin 'terryma/vim-multiple-cursors' +Plugin 'tmhedberg/SimpylFold' +Plugin 'tpope/timl' +Plugin 'tpope/vim-fugitive' +Plugin 'tpope/vim-git' +Plugin 'tpope/vim-markdown' +Plugin 'tpope/vim-obsession' +Plugin 'tpope/vim-surround' +Plugin 'Valloric/YouCompleteMe' " Autocomplete plugin +Plugin 'vim-airline/vim-airline' +Plugin 'vim-airline/vim-airline-themes' +Plugin 'vim-latex/vim-latex' +Plugin 'vim-scripts/indentpython.vim' +Plugin 'vim-scripts/pydoc.vim' +Plugin 'vim-scripts/taglist.vim' +Plugin 'vim-scripts/vim-R-plugin' +Plugin 'vimwiki/vimwiki' +Plugin 'wincent/command-t' +Plugin 'xuhdev/vim-latex-live-preview' +" +" All Plugins must be added before the following line +" +call vundle#end() " required +" +filetype plugin indent on " required +" +filetype on +" +" To ignore plugin indent changes, instead use: filetype plugin on +" +" Brief help +" +" :PluginList - lists configured plugins +" :PluginInstall - installs plugins; append `!` to update or just :PluginUpdate +" :PluginSearch foo - searches for foo; append `!` to refresh local cache +" :PluginClean - confirms removal of unused plugins; append `!` to auto-approve removal +" +" see :h vundle for more details or wiki for FAQ +" Put your non-Plugin stuff after this line +" +" }}} +" +" ================================= +" +" GUI Settings ---------------------- {{{ +" +" " GVIM- (here instead of .gvimrc) + if has('gui_running') + set lines=40 + colorscheme zenburn + + if has("gui_gtk2") + set guifont=Inconsolata\ 15 + elseif has("gui_macvim") + set guifont=Inconsolata-dz:h14 + endif + + set guicursor=n-v-c:block-Cursor + else + set background=dark + set t_Co=256 + "let g:gruvbox_italic=1 + "colorscheme wombat256i + colorscheme gruvbox + + endif +" +" +" }}} +" +" ================================= +" +" General Settings ------ {{{ +" +syntax on + +let mapleader="," +let maplocalleader=",," + +set autoindent "set autoindenting for programming +set autoread +set autowrite +set columns=100 +set cursorline " shows line under the cursor's line +set dictionary+=/usr/share/dict/words +set directory=.,$TEMP: +set encoding=utf-8 +set directory=.,$TEMP: +set encoding=utf-8 +set foldlevel=0 "0=all folds closed; 99=all folds open +set foldmethod=marker +set hidden +set history=1000 +set hlsearch "set highligh searching +set incsearch "set incremental searching +set lines=40 +set nobackup +set nowritebackup +set number +set omnifunc=syntaxcomplete#Complete +set shiftwidth=4 +set showmatch +set showmode +set title +set t_RV= "surpress terminal version query from vim +set visualbell +set wildmenu +set wildmode=longest,list,full + +nnoremap <silent> OA <UP> +nnoremap <silent> OB <DOWN> +nnoremap <silent> OC <RIGHT> +nnoremap <silent> OD <LEFT> +inoremap <silent> OA <UP> +inoremap <silent> OB <DOWN> +inoremap <silent> OC <RIGHT> +inoremap <silent> OD <LEFT> + +" }}} +" +" ================================= +" +" General Key Bindings ----- {{{ +" + +noremap § :norm i#<CR> +noremap <C-F11> :NERDTreeToggle <CR> +nnoremap <leader>n :NERDTreeToggle <CR> + +noremap <C-M> :make %<CR> +noremap <C-F5> :setlocal spell! spelllang = en_gb<CR> + +noremap <C-\> :tab split <CR>exec("tag ".expand("<cword>"))<CR> +noremap <A-]> :vsp <CR>exec("tag ".expand("<cword>"))<CR> + +nnoremap <leader>a :Ag<CR> + +"noremap <C-F3> <ESC>:set guifont=*<CR> +"nnoremap <leader>f :set guifont=Monospace\ 12<CR> +"nnoremap <leader>F :set guifont=Monospace\ 15<CR> +nnoremap <leader>[ :tabprevious<CR> +nnoremap <leader>] :tabnext<CR> + +" clears highlighted search results +nnoremap <Esc> :nohlsearch <CR><Esc> + +"cd to current working directory +nnoremap <leader>cwd :cd %:p:h<CR>:pwd<CR> + +" edit vimrc file +nnoremap <leader>v :edit $MYVIMRC<CR> +" +"If you forget to sudo before calling vim use the following to be +"able to write the file. +cnoremap w!! %!sudo tee > /dev/null % + +"open with @locate or find command +"tutorial video: https://www.youtube.com/watch?v=X0KP15O006M +noremap <leader>o :exec '!xdg-open ' . shellescape(getline('.')) <CR><CR> +noremap <leader>mp :exec '!mpv ' . shellescape(getreg('0')) <CR><CR> +noremap <leader>yp :exec '!mplayer $(youtube-dl -g ' . shellescape(getline('.')) . ')' <CR><CR> + +"See docstrings for folded code +let g:SimpylFold_docstring_preview=1 + +"Toggle relative numbering, and set to absolute on loss of focus or insert +"mode + +set rnu +function! ToggleNumbersOn() + set nonumber! + set norelativenumber! +endfunction +function! ToggleAbsoluteOn() + set nu! + set rnu +endfunction +function! ToggleRelativeOn() + set rnu! + set nu +endfunction +autocmd FocusGained * call ToggleRelativeOn() +autocmd FocusLost * call ToggleRelativeOn() +autocmd InsertLeave * call ToggleRelativeOn() +autocmd InsertEnter * call ToggleRelativeOn() +nmap <Leader>l :call ToggleNumbersOn()<CR> + +""" SYSTEM CLIPBOARD COPY AND PASTE SUPPORT """ +set pastetoggle=<F2> "F2 before pasting to preserve indentation +"copy/paste to/from clipboard +vnoremap <C-c> "*y +map <silent><Leader>p :set paste<CR>o<Esc>"*]p:set nopaste<CR>" +map <silent><Leader><S-p> :set paste<CR>O<Esc>"*]p:set nopaste<CR>" + +" Copy and paste from x11 clipboard +" http://vim.wikia.com/wiki/GNU/Linux_clipboard_copy/paste_with_xclip +vmap <Leader>xyy :!xclip -f -sel clip<CR> +map <Leader>xpp mz:-lr !xclip -o -sel clip<CR>`z + +vmap <Leader>xtt :!tmux set-buffer<CR> + +" +" ================================= +" +" Ranger File Browser in Vim ----- {{{ +" http://www.everythingcli.org/use-ranger-as-a-file-explorer-in-vim/ +function! g:RangerExplorer() + exec "silent !ranger --choosefile=/tmp/vim_ranger_current_file " . expand("%:p:h") + if filereadable('/tmp/vim_ranger_current_file') + exec 'edit ' . system('cat /tmp/vim_ranger_current_file') + call system('rm /tmp/vim_ranger_current_file') + endif + redraw! +endfunction +noremap <Leader>re :call g:RangerExplorer()<CR> +" }}} +" +" +" ================================= + +" +"Manage multiple windows +"nnoremap <leader>W :call g:VGGToggleWindowFixedWidth()<CR> +"nnoremap <leader>H :call g:VGGToggleWindowFixedHeight()<CR> +nnoremap <leader>W :call g:VGGAutoWindowResize()<CR> +" }}} +" +" ================================= +" +" Eclim Settings ------ {{{ +" +" ================================= +" + +" Status line setting +"let g:EclimProjectStatusLine = 'eclim(p=${name}, n=${natures})' +"let g:EclimProjectTreeAutoOpen=1 +"let g:EclimLocateFileNonProjectScope = 'ag' + +" +" }}} +" +" ================================= +" +" Status Line ----- {{{ +" +function! Local_AirlineThemePatcher(palette) + " Trick to ensure 'Normal' highlight group exists + if !hlexists('Normal') + highlight Normal ctermbg=0 + endif +endfunction + +let g:airline_theme='luna' + +if !exists('g:airline_symbols') + let g:airline_symbols = {} +endif + +let g:powerline_pycmd='py3' +let g:airline_powerline_fonts = 1 +let g:airline_left_sep = '' +let g:airline_left_alt_sep = '' +let g:airline_right_sep = '' +let g:airline_right_alt_sep = '' +let g:airline_symbols.branch = '' +let g:airline_symbols.readonly = '' +let g:airline_symbols.linenr = '' +"let g:airline#extensions#tabline#enabled = 1 +"let g:airline#extensions#whitespace#enabled = 0 + +set timeoutlen=300 ttimeoutlen=0 +set laststatus=2 "Always display status line +set statusline=%F "Full path to the file +set statusline+=\ -\ "Separator +set statusline+=%-4{fugitive#statusline()} "If using git, show + "branch being used + "in status line. +"set statusline+=%= "Switch to the right side +"set statusline+=%l "Current line +"set statusline+=/ " Separator +"set statusline+=%L "Total lines +"set statusline+=%-4{ObsessionStatus('R','P')} "Indicate when Obsession is + "active or paused + +" +" }}} +" +" ================================= +" +" Vimscript file settings ------------ {{{ +" +augroup filetype_vim + autocmd! + autocmd FileType vim setlocal foldmethod=marker + " Source the vimrc file after saving it + if has("autocmd") + autocmd! bufwritepost $MYVIMRC nested :source $MYVIMRC + endif + function! g:VGGToggleWindowFixedWidth() + :set winfixwidth! + if &l:winfixwidth + echo "Fixed Window Width ON" + else + echo "Fixed Window Width OFF" + endif + endfunction + function! g:VGGToggleWindowFixedHeight() + :set winfixheight! + if &l:winfixheight + echo "Fixed Window Height ON" + else + echo "Fixed Window Height OFF" + endif + endfunction + function! g:VGGAutoWindowResize() + if winwidth == 100 || winheight == 40 + set nowinfixwidth nowinfixheight + set noequalalways eadirection=both + set winminwidth=1 winminheight=1 + set winwidth=9999 winheight=999 + set helpheight=999 cmdwinheight=999 previewheight=999 + echo "Window Defaults ON" + else + set nowinfixwidth nowinfixheight + set equalalways eadirection=both + set winminwidth=1 winminheight=0 + set winwidth=100 winheight=40 + set helpheight=20 cmdwinheight=7 previewheight=12 + echo "Window Defaults OFF" + endif + endfunction +augroup END +" +" }}} +" +" ================================= +" +" Javascript file settings ------------ {{{ +" +augroup filetype_js + autocmd! + autocmd FileType javascript setlocal foldmethod=marker omnifunc=javascriptcomplete#CompleteJS +augroup END +" +" }}} +" +" ================================= +" +" Taglist Settings ---- {{{ +" +" Taglist variables +" +set tags+=./tags;/ +set tags+=$HOME/Computing/Sandbox/tags +" +"can verify taglist is correct via +": set verbose tags?" command + +" +" Display function name in status bar: +" +let g:ctags_statusline=1 +" +" Automatically start script +" +let generate_tags=1 +" +" Displays taglist results in a vertical window: +" +let Tlist_Use_Horiz_Window=0 +" +" Shorter commands to toggle Taglist display +" +nnoremap TT :TlistToggle<CR> +nnoremap <C-S-F11> :TlistToggle<CR> +noremap <C-S-F12> :call g:VGGCTagsGenerate()<CR> + +function! g:VGGCTagsGenerate() + :!ctags -R --c++-kinds=+pl --fields=+iaS --extra=+q . + :!ctags -R --c-kinds=+pl --fields=+iaS --extra=+q . + :!ctags -R --Fortran-kinds=+iL --fields=+iaS --extra=+q . + :!ctags -R --Python-kinds=+cfimv --fields=+iaS --extra=+q . + :!ctags -R --Vim-kinds=+acfmv --fields=+iaS --extra=+q . + echo "cTags generated..." +endfunction +" +" Various Taglist diplay config: +" +let Tlist_Use_Left_Window=1 +let Tlist_Compact_Format=1 +let Tlist_Exit_OnlyWindow=1 +let Tlist_GainFocus_On_ToggleOpen=1 +let Tlist_File_Fold_Auto_Close=1 +let Tlist_WinWidth=20 + +" +" }}} +" +" ================================= +" +"Tagbar Settings ---- {{{ +" +"Toggle Tagbar window +let g:tagbar_width=22 +let g:tagbar_zoomwidth=0 +nnoremap <C-S-F7> :TagbarToggle<CR> +"autocmd BufEnter *.py :call tagbar#autoopen(0) +"autocmd BufWinLeave *.py :TagbarClose +" +" }}} +" +" +" ================================= +" +"NERDTree Settings ---- {{{ +" +let NERDTreeIgnore=['\.pyc$', '\.pyo$', '__pycache__$'] " Ignore files in NERDTree +let NERDTreeWinSize=40 +"autocmd VimEnter * if !argc() | NERDTree | endif " Load NERDTree only if vim is run without arguments +" }}} +" +" ================================= +" +" Binary File Settings ---- {{{ +" +" Hex read +nmap <Leader>hr :%!xxd<CR> :set filetype=xxd<CR> +" Hex write +nmap <Leader>hw :%!xxd -r<CR> :set binary<CR> :set filetype=xxd<CR> +" +" }}} +" +" ================================= +" +" Limelight Settings ---- {{{ +" +" 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 +" +" }}} +" +" ================================= +" +" Goyo Settings ---- {{{ +" +function! s:goyo_enter() + silent !tmux set status off + silent !tmux list-panes -F '\#F' | grep -q Z || tmux resize-pane -Z + set noshowmode + set noshowcmd + set scrolloff=999 + Limelight +endfunction + +function! s:goyo_leave() + silent !tmux set status on + silent !tmux list-panes -F '\#F' | grep -q Z && tmux + resize-pane -Z + set showmode + set showcmd + set scrolloff=5 + Limelight! +endfunction + +autocmd! User GoyoEnter nested call <SID>goyo_enter() +autocmd! User GoyoLeave nested call <SID>goyo_leave() + +nmap <Leader>go :Goyo<CR> +" +" }}} +" +" ================================= +" +"Some Python settings:------------------- {{{ + +augroup filetype_py + " Clears the group each time vimrc is sourced + " to prevent multiple definitions of the same autocmd + " + autocmd! + " + autocmd FileType python set omnifunc=pythoncomplete#Complete + autocmd BufRead *.py set smartindent cinwords=if,elif,else,for,while,try,except,finally,def,class + autocmd BufRead, BufNewFile *.py + \ set tabstop=4 + \ set softtabstop=4 + \ set shiftwidth=4 + \ set textwidth=79 + \ set expandtab + \ set autoindent + \ set fileformat=unix + + " + " This will allow you to check the syntax of your entire file + " by typing :make. You can the get a list of errors with :clist + " and move between the errors with :cn and :cp. + " + autocmd BufRead *.py set makeprg=python\ -c\ \"import\ py_compile,sys;\ sys.stderr=sys.stdout;\ py_compile.compile(r'%')\" + autocmd Bufwrite *.(py) : call Pyflakes() + autocmd BufRead *.py set efm=%C\ %.%#,%A\ \ File\ \"%f\"\\,\ line\ %l%.%#,%Z%[%^\ ]%\\@=%m + + " Execute pydoc on the current word in the file being edited + autocmd FileType python noremap <buffer> K : execute "!xterm -e 'pydoc " . expand("<cword>") . "'"<CR> + " Execute file being edited with <Command> + e: + noremap <buffer> <C-e> :w\|!/usr/bin/env python % <CR> + +let g:pydiction_location="~/.vim/bundle/pydiction/complete-dict" +let g:pyflakes_use_quickfix=0 +let g:pep8_map="<leader>8" +" +" For full syntax highlighting: +" +let python_highlight_all=1 +syntax on + +" python executables for different plugins +let g:pymode_python='python' +let g:syntastic_python_python_exec='python' + +" rope +let g:pymode_rope=0 +let g:pymode_rope_completion=0 +let g:pymode_rope_complete_on_dot=0 +let g:pymode_rope_auto_project=0 +let g:pymode_rope_enable_autoimport=0 +let g:pymode_rope_autoimport_generate=0 +let g:pymode_rope_guess_project=0 + +" documentation +let g:pymode_doc=0 +let g:pymode_doc_bind='K' + +" lints +let g:pymode_lint=0 + + +" breakpoints +let g:pymode_breakpoint=1 +let g:pymode_breakpoint_key='<LocalLeader>b' + +" syntax highlight +let g:pymode_syntax=1 +let g:pymode_syntax_slow_sync=1 +let g:pymode_syntax_all=1 +let g:pymode_syntax_print_as_function=g:pymode_syntax_all +let g:pymode_syntax_highlight_async_await=g:pymode_syntax_all +let g:pymode_syntax_highlight_equal_operator=g:pymode_syntax_all +let g:pymode_syntax_highlight_stars_operator=g:pymode_syntax_all +let g:pymode_syntax_highlight_self=g:pymode_syntax_all +let g:pymode_syntax_indent_errors=g:pymode_syntax_all +let g:pymode_syntax_string_formatting=g:pymode_syntax_all +let g:pymode_syntax_space_errors=g:pymode_syntax_all +let g:pymode_syntax_string_format=g:pymode_syntax_all +let g:pymode_syntax_string_templates=g:pymode_syntax_all +let g:pymode_syntax_doctests=g:pymode_syntax_all +let g:pymode_syntax_builtin_objs=g:pymode_syntax_all +let g:pymode_syntax_builtin_types=g:pymode_syntax_all +let g:pymode_syntax_highlight_exceptions=g:pymode_syntax_all +let g:pymode_syntax_docstrings=g:pymode_syntax_all + + +" code folding +let g:pymode_folding=0 + +" pep8 indents +let g:pymode_indent=1 + +" code running +let g:pymode_run=1 +let g:pymode_run_bind='<F5>' + +" syntastic +let g:syntastic_always_populate_loc_list=1 +let g:syntastic_auto_loc_list=1 +let g:syntastic_enable_signs=1 +let g:syntastic_check_on_wq=0 +let g:syntastic_aggregate_errors=1 +let g:syntastic_loc_list_height=5 +let g:syntastic_error_symbol='X' +let g:syntastic_style_error_symbol='X' +let g:syntastic_warning_symbol='x' +let g:syntastic_style_warning_symbol='x' +let g:syntastic_python_checkers=['flake8', 'pydocstyle', 'python'] + +" +" jedi-vim settings +" + +let g:jedi#goto_command = "<LocalLeader>d" +let g:jedi#use_splits_not_buffers = "right" +let g:jedi#goto_assignments_command = "<LocalLeader>G" +let g:jedi#goto_definitions_command = "<LocalLeader>GG" +let g:jedi#documentation_command = "K" +let g:jedi#usages_command = "<LocalLeader>n" +let g:jedi#completions_command = "<C-Space>" +let g:jedi#rename_command = "<LocalLeader>R" +let g:jedi#show_call_signatures = 2 +" +" +" screen stuff +" +let g:ScreenImpl = "Tmux" +let g:ScreenShellTmuxInitArgs = '-2' +let g:ScreenShellSendPrefix = '' +let g:ScreenShellSendSufix = '' +let g:ScreenIPython3 = 1 + + +" Open an IPython3 shell (! for vertical split). +autocmd FileType python map <LocalLeader>p :IPython!<CR> + +" Close whichever shell is running. +autocmd FileType python map <LocalLeader>q :ScreenQuit<CR> + +" Send Commands +" Send current line to python and move to next line. +autocmd FileType python map <LocalLeader>r V:ScreenSend<CR>0j +" Send selection to python and move to next line. +autocmd FileType python map <LocalLeader>v :ScreenSend<CR>`>}0j + +" Send a <CR> to ipython. +autocmd FileType python map <LocalLeader>cr :call g:ScreenShellSend("\r")<CR> + +" Clear the screen. +autocmd FileType python map <LocalLeader>L :call g:ScreenShellSend('!clear')<CR> +" +" Using tslime2 to send python code to ipython +" press vip to select current paragraph then press <C-c><C-c> and this sends +" the code to ipython. This also works sending current line and any selected text +" +" cellmode +" +let g:cellmode_use_tmux=1 +let g:cellmode_tmux_windowname='' +let g:cellmode_tmux_panenumber=2 +" +" Vimux +" +" +""## +""print("Hello, this is vim-cellmode in action") +""## +""import numpy as np +""b=np.zeros(50,50) +""print(b) +""## +""import pylab as pl +""pl.plot(0,1) +""## + + +function! VimuxSlime() + call VimuxSendText(@v) + call VimuxSendKeys("Enter") +endfunction + +"If text is selected save it in the v buffer and send that buffer to tmux +vmap <LocalLeader>k "vy :call VimuxSlime()<CR> + +"Select current paragraph and send that it to tmux +"nmap <LocalLeader>x vip<LocalLeader>vs<CR> +nmap <LocalLeader>x vip<LocalLeader>v<CR> + +" Execute py tests +" +nnoremap <silent><leader>ptf <Esc>:Pytest file<CR> +nnoremap <silent><leader>ptc <Esc>:Pytest class<CR> +nnoremap <silent><leader>ptm <Esc>:Pytest method<CR> +" +" Cycle through test errors +" +nnoremap <silent><leader>ptn <Esc>:Pytest next<CR> +nnoremap <silent><leader>ptp <Esc>:Pytest previous<CR> +nnoremap <silent><leader>pte <Esc>:Pytest error<CR> + +augroup END + +" +" }}} +" +" ================================= +" +" Latex Settings ----- {{{ +" +augroup filetype_tex + autocmd! + autocmd FileType tex setlocal iskeyword+=: +" IMPORTANT: grep will sometimes skip displaying the file name if you +" search in a singe file. This will confuse Latex-Suite. Set your grep +" program to always generate a file-name. + + set grepprg=grep\ -nH\ $* + +" OPTIONAL: Starting with Vim 7, the filetype of empty .tex files +" defaults to 'plaintex' instead of 'tex', which results in vim-latex +" not being loaded. The following changes the default filetype back +" to 'tex': + + let g:tex_flavor='latex' +" +"To use live preview we set the viewer. + + let g:livepreview_previewer = 'mupdf' + +augroup END +" +" }}} +" +" ================================= +" +" Man Pages Settings ----- {{{ +" +" Set up the reading of manpages from within vim (use :Man whatever) + +au BufNewFile,BufRead *.js, *.html, *.css + \ set tabstop=2 + \ set softtabstop=2 + \ set shiftwidth=2 + +" +" }}} +" +" ================================= +" +" Ag Settings ----- {{{ +" +" ag.vim is a plugin for vim which allows you to search over files using the +" silver searcher (ag). +" +" Usage +" +" :Ag [options] pattern [directory] +" +" The :Ag command provides several features to make running ag easier: +" +" :Ag supports command completion of: +" +" - patterns from search history: hit <tab> when starting +" to run :Ag and you can choose from a list of 10 of your most +" recent searches. A common use case while editing code could be to +" hit * on a function name to search for occurrences in the current +" file, then to run :Ag <tab> to search for the function across all +" files. +" - ag options: If you type - and then hit <tab>, you can +" scroll through all the ag.vim supported ag options. +" - file/directory name to search in: Once you've +" supplied a search pattern, the next argument to +" :Ag is an optional directory or file to search in +" and you can make use of <tab> completion to choose +" that file or directory. +" ag.vim also registers itself as a backend for eclim's :LocateFile functionality. You +" can even set ag as the default for non-eclim projects by adding the following to your vimrc: +" +" let g:EclimLocateFileNonProjectScope = 'ag' + + let g:AgSmartCase=1 +" +" }}} +" ================================= +" +" Vim Wiki Settings ----- {{{ +" +" vimwiki - Personal wiki for vim +" https://github.com/vikiwiki/vimwik + +" vimwiki with markdown support + +filetype plugin on +syntax on +let g:vimwiki_list = [{'path': '$HOME/vimwiki', + \ 'syntax': 'markdown', + \ 'ext': '.md'}] + +" help-page -> :h vimwiki-syntax + +"vim-instant-markdown - Instant markdown previews from vim +" https://github.com/suan/vim-instant-markdown + +let g:instant_markdown_autostart = 0 " disable autostart +noremap <LocalLeader>md :InstantMarkdownPreview<CR> + +" +" }}} +" ================================= +" +" urlview ----- {{{ +" +" Use urlview to choose and open a url + + :noremap <leader>u :w<Home>silent <End> !urlview<CR> + +" +" }}} +" +" ================================= +" +" FZF Settings ----- {{{ +" +function! FzfOmniOmniFiles() + let is_git = system('git status') + if v:shell_error + :Files + else + :GitFiles + endif +endfunction +nnoremap <C-P> : call FzfOmniOmniFiles()<CR> + +let g:fzf_files_options = + \ '--preview "(coderay {} || cat {}) 2> /dev/null | head - '.&lines.'"' + +" +" }}} +" +" ================================= +" +" SuperTab settings ------- {{{ +" +inoremap <expr> <Esc> pumvisible() ? "\<C-e>" : "\<Esc>" +inoremap <expr> <CR> pumvisible() ? "\<C-y>" : "\<CR>" +inoremap <expr> <Down> pumvisible() ? "\<C-n>" : "\<Down>" +inoremap <expr> <Up> pumvisible() ? "\<C-p>" : "\<Up>" +inoremap <expr> <PageDown> pumvisible() ? "\<PageDown>\<C-p>\<C-n>" : "\<PageDown>" +inoremap <expr> <PageUp> pumvisible() ? "\<PageUp>\<C-p>\<C-n>" : "\<PageUp>" + +"let g:SuperTabDefaultCompletionType="context" +let g:SuperTabDefaultCompletionType="<C-n>" + +" +" Automatically open and close the popup menu / preview window +" + +au CursorMovedI,InsertLeave * if pumvisible() == 0|silent! pclose|endif +set completeopt=menuone,menu,longest,preview + +" +" }}} +" +" ================================= +" +" UltiSnips Settings ----- {{{ +" +" snippets plugin +" https://github.com/SirVer/ultisnips + +let g:UltiSnipsExpandTrigger="<Tab>" +let g:UltiSnipsJumpForwardTrigger="<Tab>" +let g:UltiSnipsJumpBackwardTrigger="<S-Tab>" +let g:UltiSnipsListSnippets="<C-Tab>" +let g:UltiSnipsUsePythonVersion = 3 + +" If you want :UltiSnipsEdit to split your window. +let g:UltiSnipsEditSplit="horiizontal" + +let g:UltiSnipsSnippetsDir=$HOME."/.vim/UltiSnips" +let g:UltiSnipsSnippetDirectories=[$HOME.'/.vim/', $HOME.'/.vim/bundle/vim-snippets/UltiSnips'] +"let g:UltiSnipsSnippetDirectories=[$HOME.'/.vim/'] +" +" }}} +" +" ================================= +" +" YouCompleteMe Settings ----- {{{ +" +" Code Completion Engine +" https://github.com/Valloric/YouCompleteMe. + +let g:ycm_confirm_extra_conf=0 "load ycm conf by default +let g:ycm_global_ycm_extra_conf="~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp/ycm/.ycm_extra_conf.py" +let g:ycm_complete_in_comments=1 "turn on completion in comments +let g:ycm_collect_identifiers_from_tags_file=1 "turn on tag completion +let g:ycm_min_num_of_chars_for_completion=1 "start completion from first character +let g:ycm_cache_omnifunc=0 "dont cache completion items +let g:ycm_seed_identifiers_with_syntax=1 "complete syntax keywords +let g:ycm_autoclose_preview_window_after_completion=1 + +" Make YCM compatible with Ultisnips (using supertab) +let g:ycm_key_list_select_completion=['<C-n>', '<Down>'] "Dont use tab completion to cycle - leave this for UltiSnips +let g:ycm_key_list_previous_completion=['<C-p>', '<Up'] +noremap <Leader>g :YcmCompleter GoToDefinitionElseDeclaration<CR> +" +" }}} +" +" ================================= +" +" Command-t Settings ----- {{{ +" +" +"Command-T is a Vim plug-in that provides an extremely fast 'fuzzy' mechanism for: +" +" - Opening files and buffers +" - Jumping to tags and help +" - Running commands, or previous searches and commands +" +"with a minimal number of keystrokes. +" +" https://github.com/wincent/command-t + +let g:CommandTMaxFiles=999999 +let g:CommandTSuppressMaxFilesWarning=1 + +" +" }}} +" +" ================================= +" +runtime ftplugin/man.vim +" +" ================================= diff --git a/urlportal.sh b/urlportal.sh new file mode 100755 index 0000000..60f358c --- /dev/null +++ b/urlportal.sh @@ -0,0 +1,245 @@ +#!/bin/bash +# _ _ _ _ +# __ _ ___ | |_| |__ | | ___| |_ _ _ +# / _` |/ _ \| __| '_ \| |/ _ \ __| | | | +#| (_| | (_) | |_| |_) | | __/ |_| |_| | +# \__, |\___/ \__|_.__/|_|\___|\__|\__,_| +# |___/ +# https://www.youtube.com/user/gotbletu +# https://twitter.com/gotbletu +# https://github.com/gotbletu +# gotbleu@gmail.com + +# _ _ _ +# _ _ _ __| |_ __ ___ _ __| |_ __ _| | +# | | | | '__| | '_ \ / _ \| '__| __/ _` | | +# | |_| | | | | |_) | (_) | | | || (_| | | +# \__,_|_| |_| .__/ \___/|_| \__\__,_|_| +# |_| +# DESC: custom way to handle url (similar idea to xdg-open, mailcap) +# works with just about all programs (e.g w3m, rtv, newsboat, urlview ...etc) +# DEMO: https://www.youtube.com/watch?v=2jyfrmBYzVQ +# install: lynx youtube-dl task-spooler newsboat rtv w3m mpv urlview tmux feh plowshare streamlink curl coreutils + + +# newsboat: +# vim ~/.newsboat/config +# browser ~/.scripts/urlportal.sh + +# rtv: +# vim ~/.bashrc +# export RTV_BROWSER=~/.scripts/urlportal.sh + +# w3m: +# vim ~/.w3m/keymap +# open url under cursor (default: Esc+Shift+M); e.g 2+Esc+Shift+M +# keymap e EXTERN_LINK ~/.scripts/urlportal.sh + +# urlview: +# vim ~/.urlview +# COMMAND ~/.scripts/urlportal.sh + +# references: +# cirrusuk http://arza.us/paste/piper +# obosob https://github.com/michael-lazar/rtv/issues/78#issuecomment-125507472 +# budlabs - mpv queue https://www.youtube.com/watch?v=-vbr3-mHoRs +# https://github.com/budlabs/youtube/blob/master/letslinux/032-queue-files-in-mpv/openvideo +# ji99 - mpv queue script https://www.reddit.com/r/commandline/comments/920p5d/bash_script_for_queueing_youtube_links_in_mpv/ + + +BROWSERCLI="w3m" +BROWSER="qutebrowser" +# DEFAULT="xdg-open" +# DEFAULT="chromium --incognito" +# DEFAULT="w3m" +DEFAULT="$BROWSERCLI" +## long videos like youtube +VIDEO_QUEUE="tsp mpv --ontop --no-border --force-window --autofit=500x280 --geometry=-15-53" +VIDEO_DL="mpsyt dlurl" +## short videos/animated gif clips +VIDEO_CLIP="mpv --loop --quiet --ontop --no-border --force-window --autofit=900x600 --geometry=-15+60" +IMAGEGUI="feh -. -x -B black -g 900x600-15+60" +IMAGECLI="w3m -o display_image=1 -o imgdisplay=w3mimgdisplay" +LIVEFEED="tsp streamlink" +DDL_PATH=~/Downloads/plowshare +DDL_QUEUE_FAST=~/.config/plowshare/queuefast.txt + + +# enable case-insensitive matching +shopt -s nocasematch + +url="$1" +case "$url" in + *gfycat.com/*|*streamable.com/*) + nohup $VIDEO_CLIP "${url/.gifv/.webm}" > /dev/null 2>&1 & + ;; + *v.redd.it/*|*video.twimg.com/*|*dailymotion.com*) + nohup $VIDEO_CLIP "$url" > /dev/null 2>&1 & + ;; + *youtube.com/watch*|*youtu.be/*|*clips.twitch.tv/*) + $VIDEO_DL "$url" + ;; + *twitch.tv/*) + $LIVEFEED "$url" + ;; + *pornhub.com/*|*xvideos.com/*) + # $VIDEO_QUEUE "$url" + nohup $VIDEO_CLIP "$url" > /dev/null 2>&1 & + ;; + *reddit.com/r/*) + tmux new-window -n rtv && tmux send-keys "rtv -l $url && tmux kill-pane" 'Enter' + ;; + *glodls.to/*|*eogli.org/*|*limetorrents.io/*|*limetorrents.cc/*|*pornoshara.tv/item*|*rustorrents.net/details*|*xxx-tracker.com/*) + tmux new-window -n browse && tmux send-keys "$BROWSERCLI '$url' && tmux kill-pane" 'Enter' + ;; + *thepiratebay.org/*|*torrentdownloads.me/*|*yourbittorrent2.com/*|*torlock2.com/*|*bt-scene.cc/*|*rarbg.to/*|*ettorrent.xyz/*) + tmux new-window -n browse && tmux send-keys "$BROWSERCLI '$url' && tmux kill-pane" 'Enter' + ;; + *1337x.to/*|*eztv.ag/*|*extratorrent.ag/*|*yts.am/*) + tmux new-window -n browse && tmux send-keys "$BROWSERCLI '$url' && tmux kill-pane" 'Enter' + ;; + *22pixx.xyz/ia-i/*) + cleanurl="$(printf $url | sed 's/ia-i/i/g' | sed 's/\.html//g')" + tmux new-window -n pixcli && tmux send-keys "$IMAGECLI '$cleanurl' && tmux kill-pane" 'Enter' + ;; + *freebunker.com/*) + cleanurl="$(printf $url | sed 's@img\/@tn\/i@')" + tmux new-window -n pixcli && tmux send-keys "$IMAGECLI '$cleanurl' && tmux kill-pane" 'Enter' + ;; + *imagerar.com/t/*) + cleanurl="$(printf $url | sed 's@/t@/u@')" + tmux new-window -n pixcli && tmux send-keys "$IMAGECLI '$cleanurl' && tmux kill-pane" 'Enter' + ;; + *imagerar.com/imgy-u/*) + cleanurl="$(printf $url | sed 's/imgy-u/u/g' | sed 's/.html//g')" + tmux new-window -n pixcli && tmux send-keys "$IMAGECLI '$cleanurl' && tmux kill-pane" 'Enter' + ;; + *imageshtorm.com/upload/small/*|*hotimage.uk/upload/small/*|*hdmoza.com//upload/small/*|*nikapic.ru/upload/small/*|*imagedecode.com/upload/small/*|*trans.firm.in//upload/small/*) + # nohup $IMAGEGUI "$(printf $url | sed 's/small/big/')" > /dev/null 2>&1 & + cleanurl="$(printf $url | sed 's/small/big/')" + tmux new-window -n pixcli && tmux send-keys "$IMAGECLI '$cleanurl' && tmux kill-pane" 'Enter' + ;; + *imageshtorm.com/img*) + # nohup $IMAGEGUI "$(printf $url | sed 's/small/big/')" > /dev/null 2>&1 & + cleanurl="$(curl -s "$url" | grep onclick | grep -oP '<a href=\047\K[^\047]+')" + tmux new-window -n pixcli && tmux send-keys "$IMAGECLI '$cleanurl' && tmux kill-pane" 'Enter' + ;; + *freescreens.ru/allimage/*|*imgclick.ru/allimage/*|*money-pic.ru/allimage/*) + cleanurl="$(printf $url | sed 's/-thumb//')" + tmux new-window -n pixcli && tmux send-keys "$IMAGECLI '$cleanurl' && tmux kill-pane" 'Enter' + ;; + *freescreens.ru/*) + cleanurl="$(printf "$url/1/" | sed 's/freescreens.ru/picpic.online/')" + tmux new-window -n pixcli && tmux send-keys "$IMAGECLI '$cleanurl' && tmux kill-pane" 'Enter' + ;; + *pixcloud.ru/view*) + cleanurl="$(curl -s "$url" | grep -oP '<img id="photo" src="\K[^"]+')" + tmux new-window -n pixcli && tmux send-keys "$IMAGECLI '$cleanurl' && tmux kill-pane" 'Enter' + ;; + *money-pic.ru/*) + cleanurl="$(curl -s "$url/1/" | grep allimage | grep -oP '<img src="\K[^"]+')" + tmux new-window -n pixcli && tmux send-keys "$IMAGECLI '$cleanurl' && tmux kill-pane" 'Enter' + ;; + *imagecurl.com/viewer.php?file=*) + cleanurl="$(printf $url | sed 's@https://@https://cdn.@' | sed 's@/viewer.php?file=@/images/@')" + tmux new-window -n pixcli && tmux send-keys "$IMAGECLI '$cleanurl' && tmux kill-pane" 'Enter' + ;; + *img2share.com/*|*imgpeak.com/*|*damimage.com/img*|*imagedecode.com/img*|*picfuture.com/*|*imageteam.org/*|*imgsalem.com/*|*dimtus.com/img*|*imgstudio.org/img*|*imagehub.pro/img*|*trans.firm.in//img*|*pic.hotimg.site/img*) + # cleanurl="$(curl -s "$url" | grep -oP '<img class=\047centred\047 src=\047\K[^\047]+')" + cleanurl="$(curl -s "$url" | grep centred | grep -oP 'src=\047\K[^\047]+')" + tmux new-window -n pixcli && tmux send-keys "$IMAGECLI '$cleanurl' && tmux kill-pane" 'Enter' + ;; + *imgadult.com/img*|*imgdrive.net/*) + cleanurl="$(curl -s "$url" | grep -oP '<meta property="og:image" content="\K[^"]+' | sed 's/small/big/')" + tmux new-window -n pixcli && tmux send-keys "$IMAGECLI '$cleanurl' && tmux kill-pane" 'Enter' + ;; + *xxximagetpb.org/*|*img-central.com/*|*imgdone.com/image/*|*i.nmfiles.com/image/*|*i.imghost.top/image/*|*mstimg.com/image/*|*imagebam.com/image/*|*imgflip.com/i/*) + cleanurl="$(lynx -source "$url" | grep -oP '<meta property="og:image" content="\K[^"]+')" + tmux new-window -n pixcli && tmux send-keys "$IMAGECLI '$cleanurl' && tmux kill-pane" 'Enter' + ;; + *wallpaperspic.pw/*|*pornweb.xyz/*) + cleanurl="$(curl -s "$url" | grep imagebam | grep -oP '<p><img src="\K[^"]+')" + tmux new-window -n pixcli && tmux send-keys "$IMAGECLI '$cleanurl' && tmux kill-pane" 'Enter' + ;; + */imagetwist.com/*) + cleanurl="$(curl -s "$url" | grep -oP '<p style="display: block; text-align:center;"><img src="\K[^"]+')" + tmux new-window -n pixcli && tmux send-keys "$IMAGECLI '$cleanurl' && tmux kill-pane" 'Enter' + ;; + *imgtornado.com/img*|*placeimg.net/img*|*http://imgjazz.com/img*|*picmoza.com//img*|*xxxwebdlxxx.org/img*) + cleanurl="$(curl --data "imgContinue=Continue to image ..." --location "$url" | grep centred | grep -oP 'src=\047\K[^\047]+')" + tmux new-window -n pixcli && tmux send-keys "$IMAGECLI '$cleanurl' && tmux kill-pane" 'Enter' + ;; + *hotimage.uk/img*) + cleanurl="$(curl --data "imgContinue=Continue to image ..." --location "$(printf $url | sed 's@http://@https://www.@')" | grep centred | grep -oP 'src=\047\K[^\047]+')" + tmux new-window -n pixcli && tmux send-keys "$IMAGECLI '$cleanurl' && tmux kill-pane" 'Enter' + ;; + *i.imgur.com/*.gifv|*i.imgur.com/*.mp4|*i.imgur.com/*.webm|*i.imgur.com/*.gif) + nohup $VIDEO_CLIP "$url" > /dev/null 2>&1 & + ;; + *i.imgur.com/*| *imgur.com/*.*) + # nohup $IMAGEGUI "$url" > /dev/null 2>&1 & + tmux new-window -n pixcli && tmux send-keys "$IMAGECLI '$url' && tmux kill-pane" 'Enter' + ;; + *imgur.com/*) + # tmux split-window && tmux send-keys "lynx -source "$url" | grep post-image-container | grep -oP '<div id=\"\K[^\"]+' | while read line; do echo https://i.imgur.com/"\$line".png; done | urlview && tmux kill-pane" 'Enter' + multiurlextract="(lynx -source "$url" | grep post-image-container | grep -oP '<div id=\"\K[^\"]+' | while read line; do echo https://i.imgur.com/"\$line".png; done | urlview)" + tmux split-window && tmux send-keys "$multiurlextract && tmux kill-pane" 'Enter' + ;; + mailto:*) + tmux split-window -fv && tmux send-keys "mutt -- '$url' && tmux kill-pane" 'Enter' + ;; + *.pls|*.m3u) + tmux split-window -fv -p 20 && tmux send-keys "mpv '$url' && exit" 'Enter' + ;; + magnet:*|*.torrent) + transmission-remote --add "$url" + ;; + *.jpg|*.jpeg|*.png|*:large) + tmux new-window -n pixcli && tmux send-keys "$IMAGECLI '$url' && tmux kill-pane" 'Enter' + # nohup $IMAGEGUI "$url" > /dev/null 2>&1 & + ;; + *.pdf|*.ps) + zathura "$url" + ;; + *.gif) + nohup $VIDEO_CLIP "${url/.gifv/.webm}" > /dev/null 2>&1 & + ;; + *zippyshare.com/*|*mediafire.com/file/*|*sendspace.com/file/*) + if pgrep -f $DDL_QUEUE_FAST > /dev/null + then + echo "$url" >> $DDL_QUEUE_FAST + else + echo "$url" >> $DDL_QUEUE_FAST + cat $DDL_QUEUE_FAST | awk '!x[$0]++' | sponge $DDL_QUEUE_FAST + tmux split-window -fv -p 20 && tmux send-keys "until [[ \$(cat $DDL_QUEUE_FAST | grep -v '#' | wc -l) -eq 0 ]]; do mkdir -p $DDL_PATH && cd $DDL_PATH && plowdown -m $DDL_QUEUE_FAST -o $DDL_PATH ; done" 'Enter' + fi + ;; + *.mp4|*.mkv|*.avi|*.wmv|*.m4v|*.mpg|*.mpeg|*.flv|*.ogm|*.ogv|*.gifv) + $VIDEO_QUEUE "$url" + ;; + *.mp3|*.m4a|*.wav|*.ogg|*.oga|*.flac) + # create queue fifo files if it does not exist + if [[ ! -p /tmp/mpvinput ]]; then + mkfifo /tmp/mpvinput + fi + + # check if process mpv exist (e.g mpv --input-file=/tmp/mpvinput filename.mp3) + if pgrep -f mpvinput > /dev/null + then + # if mpv is already running then append new url/files to queue + # echo loadfile \"${url/'/\\'}\" append-play > /tmp/mpvinput + echo loadfile \"$url\" append-play > /tmp/mpvinput + # nohup $VIDEO_CLIP "${url/.gifv/.webm}" > /dev/null 2>&1 & + else + # if mpv is not running then start it (initial startup) + # mpv --no-video --input-file=/tmp/mpvinput "$1" + tmux split-window -fv -p 20 && tmux send-keys "mpv --no-video --input-file=/tmp/mpvinput \"$url\" && exit" 'Enter' + fi + # Note: use "<" or ">" hotkeys to skip between songs/audio queue list on mpv + ;; + http*|https*|*|*.html) + # $DEFAULT "$url" + tmux new-window -n browse && tmux send-keys "$DEFAULT '$url' && tmux kill-pane" 'Enter' + ;; +esac + |
