set vicmd=vim
set syscalls
set trash
set history=100
set nofollowlinks
" set fastrun
set sortnumbers
set undolevels=100
set novimhelp
set norunexec
" colorscheme default
set timefmt=%m/%d\ %H:%M
set wildmenu
set wildstyle=popup
set suggestoptions=normal,visual,view,otherpane,keys,marks,registers
set ignorecase
set smartcase
set nohlsearch
set incsearch
set scrolloff=4
if !has('win')
    set slowfs=curlftpfs
endif
set statusline="  Hint: %z%= %A %10u:%-7g %15s %20d  "
mark h ~/
command! df df -h %m 2> /dev/null
command! diff vim -d %f %F
command! zip zip -r %f.zip %f
command! run !! ./%f
command! make !!make %a
command! mkcd :mkdir %a | cd %a
command! vgrep vim "+grep %a"
command! reload :write | restart
" Pdf
filextype *.pdf zathura %c %i &, apvlv %c, xpdf %c
fileviewer *.pdf
        \ vifmimg pdfpreview %px %py %pw %ph %c
        \ %pc
        \ vifmimg clear
        " \ pdftotext -nopgbrk %c -

" PostScript
filextype *.ps,*.eps,*.ps.gz
        \ {View in zathura}
        \ zathura %f,
        \ {View in gv}
        \ gv %c %i &,

" Djvu
filextype *.djvu
        \ {View in zathura}
        \ zathura %f,
        \ {View in apvlv}
        \ apvlv %f,

" Audio
filetype *.wav,*.mp3,*.flac,*.m4a,*.wma,*.ape,*.ac3,*.og[agx],*.spx,*.opus
        \ {View using cmus}
        \ alacritty -e cmus %f &,
       \ {Play using ffplay}
       \ ffplay -nodisp -autoexit %c,
       \ {Play using MPlayer}
       \ mplayer %f,
fileviewer *.mp3 mp3info
fileviewer *.flac soxi

" Video
filextype *.avi,*.mp4,*.wmv,*.dat,*.3gp,*.ogv,*.mkv,*.mpg,*.mpeg,*.vob,
         \*.fl[icv],*.m2v,*.mov,*.webm,*.ts,*.mts,*.m4v,*.r[am],*.qt,*.divx,
         \*.as[fx]
        \ {View using ffplay}
        \ ffplay -fs -autoexit %f,
        \ {View using Dragon}
        \ dragon %f:p,
        \ {View using mplayer}
        \ mplayer %f,
fileviewer *.avi,*.mp4,*.wmv,*.dat,*.3gp,*.ogv,*.mkv,*.mpg,*.mpeg,*.vob,
          \*.fl[icv],*.m2v,*.mov,*.webm,*.ts,*.mts,*.m4v,*.r[am],*.qt,*.divx,
          \*.as[fx]
        \ vifmimg videopreview %px %py %pw %ph %c 
        \ %pc 
        \ vifmimg clear
        " \ ffprobe -pretty %c 2>&1

" Web
filextype *.html,*.htm
        \ {Open with emacs}
        \ emacsclient -c %c &,
        \ {Open with vim}
        \ vim %c &,
        \ {Open with dwb}
        \ dwb %f %i &,
        \ {Open with firefox}
        \ firefox %f &,
        \ {Open with uzbl}
        \ uzbl-browser %f %i &,
filetype *.html,*.htm links, lynx

" Object
filetype *.o nm %f | less

" Man page
filetype *.[1-8] man ./%c
fileviewer *.[1-8] man ./%c | col -b

" Images
filextype *.bmp,*.jpg,*.jpeg,*.png,*.gif,*.xpm
        \ {View in sxiv}
        \ sxiv -ia %f &,
        \ {View in imv}
        \ imv -b 1D2330 -d %d &,
        \ {View in feh}
        \ feh %d &,
        \ {View in cacaview}
        \ cacaview %c &,
fileviewer *.bmp,*.jpg,*.jpeg,*.png,*.xpm
        \ vifmimg draw %px %py %pw %ph %c
        \ %pc
        \ vifmimg clear
fileviewer *.gif
        \ vifmimg gifpreview %px %py %pw %ph %c
        \ %pc
        \ vifmimg clear
        
" OpenRaster
filextype *.ora
        \ {Edit in MyPaint}
        \ mypaint %f,

" Mindmap
filextype *.vym
        \ {Open with VYM}
        \ vym %f &,

" MD5
filetype *.md5
       \ {Check MD5 hash sum}
       \ md5sum -c %f %S,

" SHA1
filetype *.sha1
       \ {Check SHA1 hash sum}
       \ sha1sum -c %f %S,

" SHA256
filetype *.sha256
       \ {Check SHA256 hash sum}
       \ sha256sum -c %f %S,

" SHA512
filetype *.sha512
       \ {Check SHA512 hash sum}
       \ sha512sum -c %f %S,

" GPG signature
filetype *.asc
       \ {Check signature}
       \ !!gpg --verify %c,

" Torrent
filetype *.torrent ktorrent %f &
fileviewer *.torrent dumptorrent -v %c

" FuseZipMount
filetype *.zip,*.jar,*.war,*.ear,*.oxt,*.apkg
       \ {Mount with fuse-zip}
       \ FUSE_MOUNT|fuse-zip %SOURCE_FILE %DESTINATION_DIR,
       \ {View contents}
       \ zip -sf %c | less,
       \ {Extract here}
       \ tar -xf %c,
fileviewer *.zip,*.jar,*.war,*.ear,*.oxt zip -sf %c

" ArchiveMount
filetype *.tar,*.tar.bz2,*.tbz2,*.tgz,*.tar.gz,*.tar.xz,*.txz
       \ {Mount with archivemount}
       \ FUSE_MOUNT|archivemount %SOURCE_FILE %DESTINATION_DIR,
fileviewer *.tgz,*.tar.gz tar -tzf %c
fileviewer *.tar.bz2,*.tbz2 tar -tjf %c
fileviewer *.tar.txz,*.txz xz --list %c
fileviewer *.tar tar -tf %c

" Rar2FsMount and rar archives
filetype *.rar
       \ {Mount with rar2fs}
       \ FUSE_MOUNT|rar2fs %SOURCE_FILE %DESTINATION_DIR,
fileviewer *.rar unrar v %c

" IsoMount
filetype *.iso
       \ {Mount with fuseiso}
       \ FUSE_MOUNT|fuseiso %SOURCE_FILE %DESTINATION_DIR,

" SshMount
filetype *.ssh
       \ {Mount with sshfs}
       \ FUSE_MOUNT2|sshfs %PARAM %DESTINATION_DIR %FOREGROUND,

" FtpMount
filetype *.ftp
       \ {Mount with curlftpfs}
       \ FUSE_MOUNT2|curlftpfs -o ftp_port=-,,disable_eprt %PARAM %DESTINATION_DIR %FOREGROUND,

" Fuse7z and 7z archives
filetype *.7z
       \ {Mount with fuse-7z}
       \ FUSE_MOUNT|fuse-7z %SOURCE_FILE %DESTINATION_DIR,
fileviewer *.7z 7z l %c

" Office files
filextype *.odt,*.doc,*.docx,*.xls,*.xlsx,*.odp,*.pptx libreoffice %f &
fileviewer *.doc catdoc %c
fileviewer *.docx docx2txt.pl %f -

" TuDu files
filetype *.tudu tudu -f %c

" Qt projects
filextype *.pro qtcreator %f &

" Directories
filextype */
        \ {View in thunar}
        \ Thunar %f &,

" file types
set classify=' :dir:/, :exe:, :reg:, :link:'
" various file names
set classify+=' ::../::, ::*.sh::, ::*.[hc]pp::, ::*.[hc]::, ::/^copying|license$/::, ::.git/,,*.git/::, ::*.epub,,*.fb2,,*.djvu::, ::*.pdf::, ::*.htm,,*.html,,**.[sx]html,,*.xml::'
" archives
set classify+=' ::*.7z,,*.ace,,*.arj,,*.bz2,,*.cpio,,*.deb,,*.dz,,*.gz,,*.jar,,*.lzh,,*.lzma,,*.rar,,*.rpm,,*.rz,,*.tar,,*.taz,,*.tb2,,*.tbz,,*.tbz2,,*.tgz,,*.tlz,,*.trz,,*.txz,,*.tz,,*.tz2,,*.xz,,*.z,,*.zip,,*.zoo::'
" images
set classify+=' ::*.bmp,,*.gif,,*.jpeg,,*.jpg,,*.ico,,*.png,,*.ppm,,*.svg,,*.svgz,,*.tga,,*.tif,,*.tiff,,*.xbm,,*.xcf,,*.xpm,,*.xspf,,*.xwd::'
" audio
set classify+=' ::*.aac,,*.anx,,*.asf,,*.au,,*.axa,,*.flac,,*.m2a,,*.m4a,,*.mid,,*.midi,,*.mp3,,*.mpc,,*.oga,,*.ogg,,*.ogx,,*.ra,,*.ram,,*.rm,,*.spx,,*.wav,,*.wma,,*.ac3::'
" media
set classify+=' ::*.avi,,*.ts,,*.axv,,*.divx,,*.m2v,,*.m4p,,*.m4v,,.mka,,*.mkv,,*.mov,,*.mp4,,*.flv,,*.mp4v,,*.mpeg,,*.mpg,,*.nuv,,*.ogv,,*.pbm,,*.pgm,,*.qt,,*.vob,,*.wmv,,*.xvid::'
" office files
set classify+=' ::*.doc,,*.docx::, ::*.xls,,*.xls[mx]::, ::*.pptx,,*.ppt::'

set vifminfo=dhistory,savedirs,chistory,state,tui,shistory,
    \phistory,fhistory,dirstack,registers,bookmarks,bmarks
nnoremap sx :!sxiv -t %d & <cr>
nnoremap gp :!gimp %f & <cr>
nnoremap s :shell<cr>
nnoremap S :sort<cr>
nnoremap w :view<cr>
vnoremap w :view<cr>gv
nnoremap gb :file &<cr>l
nnoremap yd :!echo %d | xclip %i<cr>
nnoremap yf :!echo %c:p | xclip %i<cr>
nnoremap I cw<c-a>
nnoremap cc cw<c-u>
nnoremap A cw
nnoremap ,t :!xterm &<cr>
nnoremap ,c :write | edit $MYVIFMRC | restart<cr>
nnoremap ,C :!gvim --remote-tab-silent $MYVIFMRC &<cr>
nnoremap ,w :set wrap!<cr>
nnoremap <f3> :!less %f<cr>
nnoremap <f4> :edit<cr>
nnoremap <f5> :copy<cr>
nnoremap <f6> :move<cr>
nnoremap <f7> :mkdir<space>
nnoremap <f8> :delete<cr>
" let $PATH = $HOME.'/bin/fuse:'.$PATH
" nnoremap <left> <nop>
" let $VIFM_SERVER_NAME = v:servername

" Colors
highlight clear
highlight Win cterm=none ctermfg=default ctermbg=default
highlight Directory cterm=bold ctermfg=magenta ctermbg=default
highlight Link cterm=bold ctermfg=default ctermbg=default
highlight BrokenLink cterm=bold ctermfg=red ctermbg=default
highlight Socket cterm=bold ctermfg=magenta ctermbg=default
highlight Device cterm=bold ctermfg=red ctermbg=default
highlight Fifo cterm=bold ctermfg=cyan ctermbg=default
highlight Executable cterm=bold ctermfg=green ctermbg=default
highlight Selected cterm=bold ctermfg=magenta ctermbg=default
highlight CurrLine cterm=bold,reverse ctermfg=4 ctermbg=black
highlight TopLine cterm=none ctermfg=147 ctermbg=8
highlight TopLineSel cterm=bold ctermfg=white ctermbg=default
highlight StatusLine cterm=bold ctermfg=white ctermbg=8
highlight WildMenu cterm=underline,reverse ctermfg=white ctermbg=black
highlight CmdLine cterm=none ctermfg=green ctermbg=black
highlight ErrorMsg cterm=none ctermfg=red ctermbg=black
highlight Border cterm=none ctermfg=black ctermbg=8
highlight JobLine cterm=bold,reverse ctermfg=black ctermbg=white
highlight SuggestBox cterm=bold ctermfg=default ctermbg=default
highlight CmpMismatch cterm=bold ctermfg=white ctermbg=red
highlight AuxWin cterm=bold,underline,reverse,standout,italic ctermfg=default ctermbg=default
highlight TabLine cterm=none ctermfg=white ctermbg=black
highlight TabLineSel cterm=bold,reverse ctermfg=default ctermbg=default
highlight User1 cterm=bold,underline,reverse,standout,italic ctermfg=default ctermbg=default
highlight User2 cterm=bold,underline,reverse,standout,italic ctermfg=default ctermbg=default
highlight User3 cterm=bold,underline,reverse,standout,italic ctermfg=default ctermbg=default
highlight User4 cterm=bold,underline,reverse,standout,italic ctermfg=default ctermbg=default
highlight User5 cterm=bold,underline,reverse,standout,italic ctermfg=default ctermbg=default
highlight User6 cterm=bold,underline,reverse,standout,italic ctermfg=default ctermbg=default
highlight User7 cterm=bold,underline,reverse,standout,italic ctermfg=default ctermbg=default
highlight User8 cterm=bold,underline,reverse,standout,italic ctermfg=default ctermbg=default
highlight User9 cterm=bold,underline,reverse,standout,italic ctermfg=default ctermbg=default
