From 3e91896dbbc7df47e5ae424b6218c2752817d367 Mon Sep 17 00:00:00 2001 From: c0dev0id Date: Sun, 15 Oct 2023 21:29:44 +0200 Subject: [PATCH] Update 2023-10-15 21:29 OpenBSD/amd64-x13 --- .bin/_config | 12 +- .bin/documents-import | 2 + .config/luakit/rc.lua | 16 +- .exrc | 23 +- .local/share/luakit/styles/reddit.css | 40 + .mutt/scripts/call-browser.sh | 2 +- .vim/.netrwhist | 8 +- .../bundle/vim-fugitive/CONTRIBUTING.markdown | 24 - .vim/bundle/vim-fugitive/README.markdown | 137 - .../bundle/vim-fugitive/autoload/fugitive.vim | 8227 ----------------- .vim/bundle/vim-fugitive/doc/fugitive.txt | 730 -- .vim/bundle/vim-fugitive/doc/tags | 153 - .../bundle/vim-fugitive/ftdetect/fugitive.vim | 1 - .../vim-fugitive/ftplugin/fugitiveblame.vim | 6 - .vim/bundle/vim-fugitive/plugin/fugitive.vim | 754 -- .vim/bundle/vim-fugitive/syntax/fugitive.vim | 57 - .../vim-fugitive/syntax/fugitiveblame.vim | 7 - .vim/bundle/vim-nerdtree-fugitive | 1 - .vim/bundle/vim-nerdtree/.vintrc.yaml | 5 - .vim/bundle/vim-nerdtree/CHANGELOG.md | 307 - .vim/bundle/vim-nerdtree/LICENCE | 13 - .vim/bundle/vim-nerdtree/README.markdown | 227 - .vim/bundle/vim-nerdtree/_config.yml | 1 - .../bundle/vim-nerdtree/autoload/nerdtree.vim | 249 - .../autoload/nerdtree/ui_glue.vim | 732 -- .vim/bundle/vim-nerdtree/doc/NERDTree.txt | 1534 --- .vim/bundle/vim-nerdtree/doc/tags | 143 - .../vim-nerdtree/lib/nerdtree/bookmark.vim | 365 - .../vim-nerdtree/lib/nerdtree/creator.vim | 402 - .../vim-nerdtree/lib/nerdtree/event.vim | 13 - .../vim-nerdtree/lib/nerdtree/flag_set.vim | 58 - .../vim-nerdtree/lib/nerdtree/key_map.vim | 164 - .../lib/nerdtree/menu_controller.vim | 211 - .../vim-nerdtree/lib/nerdtree/menu_item.vim | 118 - .../vim-nerdtree/lib/nerdtree/nerdtree.vim | 209 - .../vim-nerdtree/lib/nerdtree/notifier.vim | 35 - .../vim-nerdtree/lib/nerdtree/opener.vim | 326 - .../bundle/vim-nerdtree/lib/nerdtree/path.vim | 852 -- .../lib/nerdtree/tree_dir_node.vim | 706 -- .../lib/nerdtree/tree_file_node.vim | 349 - .vim/bundle/vim-nerdtree/lib/nerdtree/ui.vim | 532 -- .../nerdtree_plugin/exec_menuitem.vim | 40 - .../vim-nerdtree/nerdtree_plugin/fs_menu.vim | 484 - .../vim-nerdtree/nerdtree_plugin/vcs.vim | 47 - .vim/bundle/vim-nerdtree/plugin/NERD_tree.vim | 234 - .vim/bundle/vim-nerdtree/screenshot.png | Bin 87896 -> 0 bytes .vim/bundle/vim-nerdtree/syntax/nerdtree.vim | 97 - .vim/vimrc | 16 +- 48 files changed, 84 insertions(+), 18585 deletions(-) create mode 100644 .local/share/luakit/styles/reddit.css delete mode 100644 .vim/bundle/vim-fugitive/CONTRIBUTING.markdown delete mode 100644 .vim/bundle/vim-fugitive/README.markdown delete mode 100644 .vim/bundle/vim-fugitive/autoload/fugitive.vim delete mode 100644 .vim/bundle/vim-fugitive/doc/fugitive.txt delete mode 100644 .vim/bundle/vim-fugitive/doc/tags delete mode 100644 .vim/bundle/vim-fugitive/ftdetect/fugitive.vim delete mode 100644 .vim/bundle/vim-fugitive/ftplugin/fugitiveblame.vim delete mode 100644 .vim/bundle/vim-fugitive/plugin/fugitive.vim delete mode 100644 .vim/bundle/vim-fugitive/syntax/fugitive.vim delete mode 100644 .vim/bundle/vim-fugitive/syntax/fugitiveblame.vim delete mode 160000 .vim/bundle/vim-nerdtree-fugitive delete mode 100644 .vim/bundle/vim-nerdtree/.vintrc.yaml delete mode 100644 .vim/bundle/vim-nerdtree/CHANGELOG.md delete mode 100644 .vim/bundle/vim-nerdtree/LICENCE delete mode 100644 .vim/bundle/vim-nerdtree/README.markdown delete mode 100644 .vim/bundle/vim-nerdtree/_config.yml delete mode 100644 .vim/bundle/vim-nerdtree/autoload/nerdtree.vim delete mode 100644 .vim/bundle/vim-nerdtree/autoload/nerdtree/ui_glue.vim delete mode 100644 .vim/bundle/vim-nerdtree/doc/NERDTree.txt delete mode 100644 .vim/bundle/vim-nerdtree/doc/tags delete mode 100644 .vim/bundle/vim-nerdtree/lib/nerdtree/bookmark.vim delete mode 100644 .vim/bundle/vim-nerdtree/lib/nerdtree/creator.vim delete mode 100644 .vim/bundle/vim-nerdtree/lib/nerdtree/event.vim delete mode 100644 .vim/bundle/vim-nerdtree/lib/nerdtree/flag_set.vim delete mode 100644 .vim/bundle/vim-nerdtree/lib/nerdtree/key_map.vim delete mode 100644 .vim/bundle/vim-nerdtree/lib/nerdtree/menu_controller.vim delete mode 100644 .vim/bundle/vim-nerdtree/lib/nerdtree/menu_item.vim delete mode 100644 .vim/bundle/vim-nerdtree/lib/nerdtree/nerdtree.vim delete mode 100644 .vim/bundle/vim-nerdtree/lib/nerdtree/notifier.vim delete mode 100644 .vim/bundle/vim-nerdtree/lib/nerdtree/opener.vim delete mode 100644 .vim/bundle/vim-nerdtree/lib/nerdtree/path.vim delete mode 100644 .vim/bundle/vim-nerdtree/lib/nerdtree/tree_dir_node.vim delete mode 100644 .vim/bundle/vim-nerdtree/lib/nerdtree/tree_file_node.vim delete mode 100644 .vim/bundle/vim-nerdtree/lib/nerdtree/ui.vim delete mode 100644 .vim/bundle/vim-nerdtree/nerdtree_plugin/exec_menuitem.vim delete mode 100644 .vim/bundle/vim-nerdtree/nerdtree_plugin/fs_menu.vim delete mode 100644 .vim/bundle/vim-nerdtree/nerdtree_plugin/vcs.vim delete mode 100644 .vim/bundle/vim-nerdtree/plugin/NERD_tree.vim delete mode 100644 .vim/bundle/vim-nerdtree/screenshot.png delete mode 100644 .vim/bundle/vim-nerdtree/syntax/nerdtree.vim diff --git a/.bin/_config b/.bin/_config index 7b0c208..d5f0031 100644 --- a/.bin/_config +++ b/.bin/_config @@ -4,10 +4,10 @@ # # FONTS # -DFONT="-xos4-terminus-medium-r-normal--18-200-72-72-c-100-iso10646-1" -SFONT="-xos4-terminus-medium-r-normal--18-200-72-72-c-100-iso10646-1" -BFONT="-xos4-terminus-medium-r-normal--13-200-72-72-c-100-iso10646-1" -HFONT="-xos4-terminus-medium-r-normal--26-200-72-72-c-100-iso10646-1" +DFONT="-misc-spleen-medium-r-normal--16-160-72-72-c-80-iso10646-1" +SFONT="-uw-ttyp0-medium-r-normal--16-150-75-75-c-80-iso10646-1" +BFONT="-misc-spleen-medium-r-normal--24-240-72-72-c-120-iso10646-1" +HFONT="-misc-spleen-medium-r-normal--32-320-72-72-c-160-iso10646-1" # # TERMINALS @@ -21,10 +21,10 @@ HTERM="st -f ${HFONT}" # # NOTION ORANGE -DMENUOPTS="-fn '$DFONT' -nb #121212 -nf #707070 -sf #FFA600 -sb #121212 -l 10 -i -f" +# DMENUOPTS="-fn '$DFONT' -nb #121212 -nf #707070 -sf #FFA600 -sb #121212 -l 10 -i -f" # SPECTRWM GREY -# DMENUOPTS="-fn $DFONT -nb #181818 -nf #999999 -sf #CCCCCC -sb #181818 -i -f" +DMENUOPTS="-fn $DFONT -nb #181818 -nf #999999 -sf #CCCCCC -sb #181818 -i -f" DMENU_CMD="dmenu $DMENUOPTS" DMENURUN_CMD="dmenu_run $DMENUOPTS" diff --git a/.bin/documents-import b/.bin/documents-import index 2b1b7c5..23c1305 100755 --- a/.bin/documents-import +++ b/.bin/documents-import @@ -1,6 +1,8 @@ #/bin/sh -xe . ${HOME}/.bin/_config +pkg_add tesseract tesseract-deu ocrmypdf + mkdir -p ${PIMDIR}/documents/_incoming mv -f /tank/scanner/*.pdf ${PIMDIR}/documents/_incoming/ ${HOME}/.bin/documents-update diff --git a/.config/luakit/rc.lua b/.config/luakit/rc.lua index 1a7f81b..4349acc 100644 --- a/.config/luakit/rc.lua +++ b/.config/luakit/rc.lua @@ -60,7 +60,7 @@ local settings_chrome = require "settings_chrome" settings.window.home_page = "luakit://newtab" settings.window.scroll_step = 20 settings.window.zoom_step = 0.2 -settings.webview.zoom_level = 100 +settings.webview.zoom_level = 150 settings.window.close_with_last_tab = true -- search engines @@ -79,7 +79,7 @@ local adblock = require "adblock" local adblock_chrome = require "adblock_chrome" -- Enable Developer Tools ---- local webinspector = require "webinspector" +local webinspector = require "webinspector" -- Add uzbl-like form filling -- local formfiller = require "formfiller" @@ -221,10 +221,14 @@ follow.pattern_maker = follow.pattern_styles.match_label local webview = require "webview" webview.add_signal('init', function (view) view:add_signal('navigation-request', function(v, uri) - -- if v.uri:match('https://www.reddit.com') then - -- v.uri = v.uri:gsub('%www.reddit.com', 'old.reddit.com') - -- return true - -- end + if v.uri:match('https://www.reddit.com') then + v.uri = v.uri:gsub('%www.reddit.com', 'old.reddit.com') + return true + end + if v.uri:match('https://new.reddit.com') then + v.uri = v.uri:gsub('%new.reddit.com', 'old.reddit.com') + return true + end -- if v.uri:match('https://old.reddit.com') then -- v.uri = v.uri:gsub('%old.reddit.com', 'libreddit.kylrth.com') -- return true diff --git a/.exrc b/.exrc index 4d42c65..584ea67 100644 --- a/.exrc +++ b/.exrc @@ -2,11 +2,11 @@ set showmode set showmatch set ruler -" set verbose -" set leftright +set verbose +set leftright set noflash -" set windowname -set number +set windowname +set nonumber " indentation set shiftwidth=4 @@ -16,24 +16,23 @@ set expandtab " search set tags=tags -" set iclower -" set searchincr +set iclower +set searchincr set wrapscan -" set noerrorbell -" set extended +set noerrorbell +set extended set noedcompatible -" set nomodeline " regular expressions -" set extended +set extended " other -" set nolock +set nolock set path=. set cedit= " Don't be smart with indent levels -" map I 0i +map I 0i " Format paragraph map gq !)par -w72qie diff --git a/.local/share/luakit/styles/reddit.css b/.local/share/luakit/styles/reddit.css new file mode 100644 index 0000000..c6ae3ea --- /dev/null +++ b/.local/share/luakit/styles/reddit.css @@ -0,0 +1,40 @@ +@-moz-document domain(old.reddit.com) { + * { + background-color: #181818 !important; + color: #CCC !important; + border-color: #555 !important; + border-width: 0px !important; + } + .premium-banner-outer, .premium-banner { + display: none !important; + } + #header-img.default-header, .side { + display: none !important; + } + .link.promotedlink.promoted, .link.promotedlink.external { + display: none !important; + } + .footer-parent { + display: none !important; + } + input, textarea, button { + background-color: #282828 !important; + } + a { + font-style: oblique !important; + } + .expando-button, .thumbnail, .rank, .midcol { + display: none !important; + } + .top-matter, .top-matter > *, .top-matter > * > *, .top-matter > * > * > *, .top-matter > * > * > * > * { + background-color: #222 !important; + } + .linkflairlabel, .linkflairlabel > * { + background-color: #999 !important; + color: #121212 !important; + } + .entry { + border-left: 5px solid darkred !important; + padding-left: 5px !important; + } +} diff --git a/.mutt/scripts/call-browser.sh b/.mutt/scripts/call-browser.sh index 42bce3c..808be0d 100755 --- a/.mutt/scripts/call-browser.sh +++ b/.mutt/scripts/call-browser.sh @@ -1,3 +1,3 @@ #/bin/sh -e cp -f "$1" /tmp/mutt.html -2>/dev/null 1>&2 chrome file:///tmp/mutt.html & +2>/dev/null 1>&2 $BROWSER file:///tmp/mutt.html & diff --git a/.vim/.netrwhist b/.vim/.netrwhist index 21f7159..35ea382 100644 --- a/.vim/.netrwhist +++ b/.vim/.netrwhist @@ -1,5 +1,8 @@ let g:netrw_dirhistmax =10 -let g:netrw_dirhistcnt =2 +let g:netrw_dirhistcnt =5 +let g:netrw_dirhist_5='/home/sdk/webc' +let g:netrw_dirhist_4='/home/sdk' +let g:netrw_dirhist_3='/home/sdk/webc' let g:netrw_dirhist_2='/home/sdk/.cache/mutt' let g:netrw_dirhist_1='/home/dpb/usr/ports/games/devilutionx' let g:netrw_dirhist_0='/usr/local/share/doc/crispy-strife' @@ -7,6 +10,3 @@ let g:netrw_dirhist_9='/usr/local/share/doc/crispy-hexen' let g:netrw_dirhist_8='/usr/local/share/doc/crispy-heretic' let g:netrw_dirhist_7='/usr/local/share/doc/crispy-doom' let g:netrw_dirhist_6='/home/sdk' -let g:netrw_dirhist_5='/home/sdk/.config' -let g:netrw_dirhist_4='/home/sdk/satzung' -let g:netrw_dirhist_3='/usr/xenocara/lib/libva' diff --git a/.vim/bundle/vim-fugitive/CONTRIBUTING.markdown b/.vim/bundle/vim-fugitive/CONTRIBUTING.markdown deleted file mode 100644 index 843bbe6..0000000 --- a/.vim/bundle/vim-fugitive/CONTRIBUTING.markdown +++ /dev/null @@ -1,24 +0,0 @@ -Before reporting a bug, you should try stripping down your Vim configuration -and removing other plugins. The sad truth about VimScript is that it is -fraught with incompatibilities waiting to happen. I'm happy to work around -them where I can, but it's up to you to isolate the conflict. - -Fugitive is particularly prone to regressions due to Git version issues, -platform issues, and interactions with other plugins. I end up bisecting a -lot more than other projects, and thus I'm especially meticulous here about -maintaining a clean, readable, history. Squash and force push any requested -changes to a pull request. And if your [commit message -sucks](https://commit.style), I'm not going to accept it. Period. - -If your contribution involves adding a configuration option, you are going to -need a very compelling justification for it. Options add a maintenance -burden, support burden, and documentation bloat, and oftentimes can be -achieved much more simply with a custom map or autocommand. If your option -controls an underlying Git command, ask yourself why Git itself does not offer -such configuration. - -Beyond that, don't be shy about asking before patching. What takes you hours -might take me minutes simply because I have both domain knowledge and a -perverse knowledge of VimScript so vast that many would consider it a symptom -of mental illness. On the flip side, some ideas I'll reject no matter how -good the implementation is. "Send a patch" is an edge case answer in my book. diff --git a/.vim/bundle/vim-fugitive/README.markdown b/.vim/bundle/vim-fugitive/README.markdown deleted file mode 100644 index 3dc4e6c..0000000 --- a/.vim/bundle/vim-fugitive/README.markdown +++ /dev/null @@ -1,137 +0,0 @@ -# fugitive.vim - -Fugitive is the premier Vim plugin for Git. Or maybe it's the premier Git -plugin for Vim? Either way, it's "so awesome, it should be illegal". That's -why it's called Fugitive. - -The crown jewel of Fugitive is `:Git` (or just `:G`), which calls any -arbitrary Git command. If you know how to use Git at the command line, you -know how to use `:Git`. It's vaguely akin to `:!git` but with numerous -improvements: - -* The default behavior is to directly echo the command's output. Quiet - commands like `:Git add` avoid the dreaded "Press ENTER or type command to - continue" prompt. -* `:Git commit`, `:Git rebase -i`, and other commands that invoke an editor do - their editing in the current Vim instance. -* `:Git diff`, `:Git log`, and other verbose, paginated commands have their - output loaded into a temporary buffer. Force this behavior for any command - with `:Git --paginate` or `:Git -p`. -* `:Git blame` uses a temporary buffer with maps for additional triage. Press - enter on a line to view the commit where the line changed, or `g?` to see - other available maps. Omit the filename argument and the currently edited - file will be blamed in a vertical, scroll-bound split. -* `:Git mergetool` and `:Git difftool` load their changesets into the quickfix - list. -* Called with no arguments, `:Git` opens a summary window with dirty files and - unpushed and unpulled commits. Press `g?` to bring up a list of maps for - numerous operations including diffing, staging, committing, rebasing, and - stashing. (This is the successor to the old `:Gstatus`.) -* This command (along with all other commands) always uses the current - buffer's repository, so you don't need to worry about the current working - directory. - -Additional commands are provided for higher level operations: - -* View any blob, tree, commit, or tag in the repository with `:Gedit` (and - `:Gsplit`, etc.). For example, `:Gedit HEAD~3:%` loads the current file as - it existed 3 commits ago. -* `:Gdiffsplit` (or `:Gvdiffsplit`) brings up the staged version of the file - side by side with the working tree version. Use Vim's diff handling - capabilities to apply changes to the staged version, and write that buffer - to stage the changes. You can also give an arbitrary `:Gedit` argument to - diff against older versions of the file. -* `:Gread` is a variant of `git checkout -- filename` that operates on the - buffer rather than the file itself. This means you can use `u` to undo it - and you never get any warnings about the file changing outside Vim. -* `:Gwrite` writes to both the work tree and index versions of a file, making - it like `git add` when called from a work tree file and like `git checkout` - when called from the index or a blob in history. -* `:Ggrep` is `:grep` for `git grep`. `:Glgrep` is `:lgrep` for the same. -* `:GMove` does a `git mv` on the current file and changes the buffer name to - match. `:GRename` does the same with a destination filename relative to the - current file's directory. -* `:GDelete` does a `git rm` on the current file and simultaneously deletes - the buffer. `:GRemove` does the same but leaves the (now empty) buffer - open. -* `:GBrowse` to open the current file on the web front-end of your favorite - hosting provider, with optional line range (try it in visual mode). Plugins - are available for popular providers such as [GitHub][rhubarb.vim], - [GitLab][fugitive-gitlab.vim], [Bitbucket][fubitive.vim], - [Gitee][fugitive-gitee.vim], [Pagure][pagure], - [Phabricator][vim-phabricator], [Azure DevOps][fugitive-azure-devops.vim], - and [sourcehut][srht.vim]. - -[rhubarb.vim]: https://github.com/tpope/vim-rhubarb -[fugitive-gitlab.vim]: https://github.com/shumphrey/fugitive-gitlab.vim -[fubitive.vim]: https://github.com/tommcdo/vim-fubitive -[fugitive-gitee.vim]: https://github.com/linuxsuren/fugitive-gitee.vim -[pagure]: https://github.com/FrostyX/vim-fugitive-pagure -[vim-phabricator]: https://github.com/jparise/vim-phabricator -[fugitive-azure-devops.vim]: https://github.com/cedarbaum/fugitive-azure-devops.vim -[srht.vim]: https://git.sr.ht/~willdurand/srht.vim - -Add `%{FugitiveStatusline()}` to `'statusline'` to get an indicator -with the current branch in your statusline. - -For more information, see `:help fugitive`. - -## Screencasts - -* [A complement to command line git](http://vimcasts.org/e/31) -* [Working with the git index](http://vimcasts.org/e/32) -* [Resolving merge conflicts with vimdiff](http://vimcasts.org/e/33) -* [Browsing the git object database](http://vimcasts.org/e/34) -* [Exploring the history of a git repository](http://vimcasts.org/e/35) - -## Installation - -Install using your favorite package manager, or use Vim's built-in package -support: - - mkdir -p ~/.vim/pack/tpope/start - cd ~/.vim/pack/tpope/start - git clone https://tpope.io/vim/fugitive.git - vim -u NONE -c "helptags fugitive/doc" -c q - -## FAQ - -> What happened to the dispatch.vim backed asynchronous `:Gpush` and -> `:Gfetch`? - -This behavior was divisive, confusing, and complicated inputting passwords, so -it was removed. Use `:Git! push` to use Fugitive's own asynchronous -execution, or retroactively make `:Git push` asynchronous by pressing -`CTRL-D`. - -> Why am I getting `core.worktree is required when using an external Git dir`? - -Git generally sets `core.worktree` for you automatically when necessary, but -if you're doing something weird, or using a third-party tool that does -something weird, you may need to set it manually: - - git config core.worktree "$PWD" - -This may be necessary even when simple `git` commands seem to work fine -without it. - -> So I have a symlink and... - -Stop. Just stop. If Git won't deal with your symlink, then Fugitive won't -either. Consider using a [plugin that resolves -symlinks](https://github.com/aymericbeaumet/symlink.vim), or even better, -using fewer symlinks. - -## Self-Promotion - -Like fugitive.vim? Follow the repository on -[GitHub](https://github.com/tpope/vim-fugitive) and vote for it on -[vim.org](http://www.vim.org/scripts/script.php?script_id=2975). And if -you're feeling especially charitable, follow [tpope](http://tpo.pe/) on -[Twitter](http://twitter.com/tpope) and -[GitHub](https://github.com/tpope). - -## License - -Copyright (c) Tim Pope. Distributed under the same terms as Vim itself. -See `:help license`. diff --git a/.vim/bundle/vim-fugitive/autoload/fugitive.vim b/.vim/bundle/vim-fugitive/autoload/fugitive.vim deleted file mode 100644 index 6e5095f..0000000 --- a/.vim/bundle/vim-fugitive/autoload/fugitive.vim +++ /dev/null @@ -1,8227 +0,0 @@ -" Location: autoload/fugitive.vim -" Maintainer: Tim Pope - -" The functions contained within this file are for internal use only. For the -" official API, see the commented functions in plugin/fugitive.vim. - -if exists('g:autoloaded_fugitive') - finish -endif -let g:autoloaded_fugitive = 1 - -" Section: Utility - -function! s:function(name) abort - return function(substitute(a:name,'^s:',matchstr(expand(''), '.*\zs\d\+_'),'')) -endfunction - -function! s:sub(str,pat,rep) abort - return substitute(a:str,'\v\C'.a:pat,a:rep,'') -endfunction - -function! s:gsub(str,pat,rep) abort - return substitute(a:str,'\v\C'.a:pat,a:rep,'g') -endfunction - -function! s:Uniq(list) abort - let i = 0 - let seen = {} - while i < len(a:list) - let str = string(a:list[i]) - if has_key(seen, str) - call remove(a:list, i) - else - let seen[str] = 1 - let i += 1 - endif - endwhile - return a:list -endfunction - -function! s:JoinChomp(list) abort - if empty(a:list[-1]) - return join(a:list[0:-2], "\n") - else - return join(a:list, "\n") - endif -endfunction - -function! s:winshell() abort - return has('win32') && &shellcmdflag !~# '^-' -endfunction - -function! s:WinShellEsc(arg) abort - if type(a:arg) == type([]) - return join(map(copy(a:arg), 's:WinShellEsc(v:val)')) - elseif a:arg =~# '^[A-Za-z0-9_/:.-]\+$' - return a:arg - else - return '"' . s:gsub(s:gsub(a:arg, '"', '""'), '\%', '"%"') . '"' - endif -endfunction - -function! s:shellesc(arg) abort - if type(a:arg) == type([]) - return join(map(copy(a:arg), 's:shellesc(v:val)')) - elseif a:arg =~# '^[A-Za-z0-9_/:.-]\+$' - return a:arg - elseif s:winshell() - return '"' . s:gsub(s:gsub(a:arg, '"', '""'), '\%', '"%"') . '"' - else - return shellescape(a:arg) - endif -endfunction - -function! s:fnameescape(file) abort - if type(a:file) == type([]) - return join(map(copy(a:file), 's:fnameescape(v:val)')) - else - return fnameescape(a:file) - endif -endfunction - -function! fugitive#UrlDecode(str) abort - return substitute(a:str, '%\(\x\x\)', '\=iconv(nr2char("0x".submatch(1)), "utf-8", "latin1")', 'g') -endfunction - -function! s:UrlEncode(str) abort - return substitute(a:str, '[%#?&;+=\<> [:cntrl:]]', '\=printf("%%%02X", char2nr(submatch(0)))', 'g') -endfunction - -function! s:PathUrlEncode(str) abort - return substitute(a:str, '[%#?[:cntrl:]]', '\=printf("%%%02X", char2nr(submatch(0)))', 'g') -endfunction - -function! s:PathJoin(prefix, str) abort - if a:prefix =~# '://' - return a:prefix . s:PathUrlEncode(a:str) - else - return a:prefix . a:str - endif -endfunction - -function! s:throw(string) abort - throw 'fugitive: '.a:string -endfunction - -function! s:VersionCheck() abort - if v:version < 704 - return 'return ' . string('echoerr "fugitive: Vim 7.4 or newer required"') - elseif empty(fugitive#GitVersion()) - let exe = get(s:GitCmd(), 0, '') - if len(exe) && !executable(exe) - return 'return ' . string('echoerr "fugitive: cannot find ' . string(exe) . ' in PATH"') - endif - return 'return ' . string('echoerr "fugitive: cannot execute Git"') - elseif !fugitive#GitVersion(1, 8, 5) - return 'return ' . string('echoerr "fugitive: Git 1.8.5 or newer required"') - else - return '' - endif -endfunction - -let s:worktree_error = "core.worktree is required when using an external Git dir" -function! s:DirCheck(...) abort - let vcheck = s:VersionCheck() - if !empty(vcheck) - return vcheck - endif - let dir = call('FugitiveGitDir', a:000) - if !empty(dir) && FugitiveWorkTree(dir, 1) is# 0 - return 'return ' . string('echoerr "fugitive: ' . s:worktree_error . '"') - elseif !empty(dir) - return '' - elseif empty(bufname('')) - return 'return ' . string('echoerr "fugitive: working directory does not belong to a Git repository"') - else - return 'return ' . string('echoerr "fugitive: file does not belong to a Git repository"') - endif -endfunction - -function! s:Mods(mods, ...) abort - let mods = substitute(a:mods, '\C', '', '') - let mods = mods =~# '\S$' ? mods . ' ' : mods - if a:0 && mods !~# '\<\%(aboveleft\|belowright\|leftabove\|rightbelow\|topleft\|botright\|tab\)\>' - let default = a:1 - if default ==# 'SpanOrigin' - if s:OriginBufnr() > 0 && (mods =~# '\' ? &winfixheight : &winfixwidth) - let default = 'Edge' - else - let default = '' - endif - endif - if default ==# 'Edge' - if mods =~# '\' ? &splitright : &splitbelow - let mods = 'botright ' . mods - else - let mods = 'topleft ' . mods - endif - else - let mods = default . ' ' . mods - endif - endif - return substitute(mods, '\s\+', ' ', 'g') -endfunction - -if exists('+shellslash') - - let s:dir_commit_file = '\c^fugitive://\%(/[^/]\@=\)\=\([^?#]\{-1,\}\)//\%(\(\x\{40,\}\|[0-3]\)\(/[^?#]*\)\=\)\=$' - - function! s:Slash(path) abort - return tr(a:path, '\', '/') - endfunction - - function! s:VimSlash(path) abort - return tr(a:path, '\/', &shellslash ? '//' : '\\') - endfunction - -else - - let s:dir_commit_file = '\c^fugitive://\([^?#]\{-\}\)//\%(\(\x\{40,\}\|[0-3]\)\(/[^?#]*\)\=\)\=$' - - function! s:Slash(path) abort - return a:path - endfunction - - function! s:VimSlash(path) abort - return a:path - endfunction - -endif - -function! s:AbsoluteVimPath(...) abort - if a:0 && type(a:1) == type('') - let path = a:1 - else - let path = bufname(a:0 && a:1 > 0 ? a:1 : '') - if getbufvar(a:0 && a:1 > 0 ? a:1 : '', '&buftype') !~# '^\%(nowrite\|acwrite\)\=$' - return path - endif - endif - if s:Slash(path) =~# '^/\|^\a\+:' - return path - else - return getcwd() . matchstr(getcwd(), '[\\/]') . path - endif -endfunction - -function! s:Resolve(path) abort - let path = resolve(a:path) - if has('win32') - let path = s:VimSlash(fnamemodify(fnamemodify(path, ':h'), ':p') . fnamemodify(path, ':t')) - endif - return path -endfunction - -function! s:FileIgnoreCase(for_completion) abort - return (exists('+fileignorecase') && &fileignorecase) - \ || (a:for_completion && exists('+wildignorecase') && &wildignorecase) -endfunction - -function! s:cpath(path, ...) abort - if s:FileIgnoreCase(0) - let path = s:VimSlash(tolower(a:path)) - else - let path = s:VimSlash(a:path) - endif - return a:0 ? path ==# s:cpath(a:1) : path -endfunction - -let s:quote_chars = { - \ "\007": 'a', "\010": 'b', "\011": 't', "\012": 'n', "\013": 'v', "\014": 'f', "\015": 'r', - \ '"': '"', '\': '\'} - -let s:unquote_chars = { - \ 'a': "\007", 'b': "\010", 't': "\011", 'n': "\012", 'v': "\013", 'f': "\014", 'r': "\015", - \ '"': '"', '\': '\'} - -function! s:Quote(string) abort - let string = substitute(a:string, "[\001-\037\"\\\177]", '\="\\" . get(s:quote_chars, submatch(0), printf("%03o", char2nr(submatch(0))))', 'g') - if string !=# a:string - return '"' . string . '"' - else - return string - endif -endfunction - -function! fugitive#Unquote(string) abort - let string = substitute(a:string, "\t*$", '', '') - if string =~# '^".*"$' - return substitute(string[1:-2], '\\\(\o\o\o\|.\)', '\=get(s:unquote_chars, submatch(1), iconv(nr2char("0" . submatch(1)), "utf-8", "latin1"))', 'g') - else - return string - endif -endfunction - -let s:executables = {} - -function! s:executable(binary) abort - if !has_key(s:executables, a:binary) - let s:executables[a:binary] = executable(a:binary) - endif - return s:executables[a:binary] -endfunction - -if !exists('s:temp_scripts') - let s:temp_scripts = {} -endif -function! s:TempScript(...) abort - let body = join(a:000, "\n") - if !has_key(s:temp_scripts, body) - let s:temp_scripts[body] = tempname() . '.sh' - endif - let temp = s:temp_scripts[body] - if !filereadable(temp) - call writefile(['#!/bin/sh'] + a:000, temp) - endif - return FugitiveGitPath(temp) -endfunction - -function! s:DoAutocmd(...) abort - return join(map(copy(a:000), "'doautocmd ' . v:val"), '|') -endfunction - -function! s:Map(mode, lhs, rhs, ...) abort - let maps = [] - let flags = a:0 && type(a:1) == type('') ? a:1 : '' - let defer = flags =~# '' - let flags = substitute(flags, '', '', '') . (a:rhs =~# '' ? '' : '