From b67551a67411a998f096ff469c837bb565939a42 Mon Sep 17 00:00:00 2001 From: "Harish.K" Date: Sun, 14 Jun 2020 06:03:42 +0530 Subject: [PATCH] Adding a skel for plasma workspace --- skel/.bashrc | 17 + skel/.config/alacritty/alacritty.yml | 1 + skel/.config/kglobalshortcutsrc | 285 ++ skel/.config/khotkeysrc | 940 +++++ skel/.config/kwinrc | 32 + skel/.config/nvim/autoload/plug.vim | 2458 +++++++++++++ skel/.config/nvim/colors/molokai.vim | 211 ++ skel/.config/nvim/init.vim | 462 +++ .../plugged/fzf.vim/.github/ISSUE_TEMPLATE.md | 24 + skel/.config/nvim/plugged/fzf.vim/.gitignore | 1 + skel/.config/nvim/plugged/fzf.vim/README.md | 413 +++ .../nvim/plugged/fzf.vim/autoload/fzf/vim.vim | 1346 +++++++ .../fzf.vim/autoload/fzf/vim/complete.vim | 163 + .../nvim/plugged/fzf.vim/bin/preview.rb | 3 + .../nvim/plugged/fzf.vim/bin/preview.sh | 69 + skel/.config/nvim/plugged/fzf.vim/bin/tags.pl | 15 + .../nvim/plugged/fzf.vim/doc/fzf-vim.txt | 470 +++ .../nvim/plugged/fzf.vim/plugin/fzf.vim | 157 + skel/.config/nvim/plugged/fzf/BUILD.md | 51 + skel/.config/nvim/plugged/fzf/CHANGELOG.md | 870 +++++ skel/.config/nvim/plugged/fzf/LICENSE | 21 + skel/.config/nvim/plugged/fzf/README-VIM.md | 435 +++ skel/.config/nvim/plugged/fzf/README.md | 655 ++++ skel/.config/nvim/plugged/fzf/bin/fzf-tmux | 236 ++ skel/.config/nvim/plugged/fzf/doc/fzf.txt | 447 +++ skel/.config/nvim/plugged/fzf/doc/tags | 21 + .../nvim/plugged/fzf/man/man1/fzf-tmux.1 | 68 + skel/.config/nvim/plugged/fzf/man/man1/fzf.1 | 791 ++++ skel/.config/nvim/plugged/fzf/plugin/fzf.vim | 949 +++++ .../nvim/plugged/fzf/shell/completion.bash | 372 ++ .../nvim/plugged/fzf/shell/completion.zsh | 329 ++ .../nvim/plugged/fzf/shell/key-bindings.bash | 96 + .../nvim/plugged/fzf/shell/key-bindings.fish | 161 + .../nvim/plugged/fzf/shell/key-bindings.zsh | 121 + .../ftplugin/javascript/settings.vim | 1 + .../plugged/harish2704-vim/plugin/utils.vim | 74 + .../plugged/nerdcommenter/.github/FUNDING.yml | 1 + .../nerdcommenter/.github/workflows/vint.yml | 17 + .../nvim/plugged/nerdcommenter/.gitignore | 4 + .../nvim/plugged/nerdcommenter/README.md | 159 + .../nvim/plugged/nerdcommenter/Rakefile | 76 + .../nerdcommenter/doc/NERD_commenter.txt | 1191 ++++++ .../nerdcommenter/plugin/NERD_commenter.vim | 3212 +++++++++++++++++ skel/.config/nvim/plugged/sparkup/.gitignore | 18 + skel/.config/nvim/plugged/sparkup/Makefile | 48 + skel/.config/nvim/plugged/sparkup/README.md | 175 + .../Commands/Sparkup expand.tmCommand | 35 + .../Sparkup.tmbundle/Support/sparkup.py | 1 + .../TextMate/Sparkup.tmbundle/info.plist | 14 + .../nvim/plugged/sparkup/ftdetect/hsb.vim | 1 + .../nvim/plugged/sparkup/mit-license.txt | 22 + .../nvim/plugged/sparkup/sparkup-unittest.py | 184 + skel/.config/nvim/plugged/sparkup/sparkup.py | 1171 ++++++ .../nvim/plugged/sparkup/vim/README.txt | 69 + .../sparkup/vim/ftplugin/html/sparkup.py | 1 + .../sparkup/vim/ftplugin/html/sparkup.vim | 129 + .../plugged/sparkup/vim/ftplugin/htmldjango | 1 + .../nvim/plugged/sparkup/vim/ftplugin/smarty | 1 + .../nvim/plugged/sparkup/vim/ftplugin/xml | 1 + skel/.config/nvim/plugged/tlib_vim/.gitignore | 13 + .../.config/nvim/plugged/tlib_vim/CHANGES.TXT | 909 +++++ .../.config/nvim/plugged/tlib_vim/LICENSE.TXT | 674 ++++ skel/.config/nvim/plugged/tlib_vim/README | 32 + .../nvim/plugged/tlib_vim/addon-info.json | 9 + .../autoload/tinykeymap/map/para_move.vim | 12 + .../nvim/plugged/tlib_vim/autoload/tlib.vim | 8 + .../tlib_vim/autoload/tlib/Filter_cnf.vim | 152 + .../tlib_vim/autoload/tlib/Filter_cnfd.vim | 53 + .../tlib_vim/autoload/tlib/Filter_fuzzy.vim | 83 + .../tlib_vim/autoload/tlib/Filter_glob.vim | 68 + .../plugged/tlib_vim/autoload/tlib/Object.vim | 154 + .../plugged/tlib_vim/autoload/tlib/Test.vim | 19 + .../tlib_vim/autoload/tlib/TestChild.vim | 19 + .../plugged/tlib_vim/autoload/tlib/World.vim | 1396 +++++++ .../plugged/tlib_vim/autoload/tlib/agent.vim | 716 ++++ .../plugged/tlib_vim/autoload/tlib/arg.vim | 342 ++ .../plugged/tlib_vim/autoload/tlib/assert.vim | 44 + .../tlib_vim/autoload/tlib/autocmdgroup.vim | 14 + .../tlib_vim/autoload/tlib/balloon.vim | 73 + .../tlib_vim/autoload/tlib/bitwise.vim | 141 + .../plugged/tlib_vim/autoload/tlib/buffer.vim | 401 ++ .../plugged/tlib_vim/autoload/tlib/cache.vim | 464 +++ .../plugged/tlib_vim/autoload/tlib/char.vim | 59 + .../plugged/tlib_vim/autoload/tlib/cmd.vim | 117 + .../tlib_vim/autoload/tlib/comments.vim | 26 + .../plugged/tlib_vim/autoload/tlib/date.vim | 195 + .../tlib_vim/autoload/tlib/dictionary.vim | 45 + .../plugged/tlib_vim/autoload/tlib/dir.vim | 93 + .../plugged/tlib_vim/autoload/tlib/eval.vim | 72 + .../plugged/tlib_vim/autoload/tlib/file.vim | 356 ++ .../plugged/tlib_vim/autoload/tlib/fixes.vim | 14 + .../plugged/tlib_vim/autoload/tlib/grep.vim | 38 + .../plugged/tlib_vim/autoload/tlib/hash.vim | 145 + .../plugged/tlib_vim/autoload/tlib/hook.vim | 25 + .../plugged/tlib_vim/autoload/tlib/input.vim | 1270 +++++++ .../plugged/tlib_vim/autoload/tlib/list.vim | 194 + .../tlib_vim/autoload/tlib/loclist.vim | 13 + .../plugged/tlib_vim/autoload/tlib/map.vim | 23 + .../plugged/tlib_vim/autoload/tlib/normal.vim | 34 + .../plugged/tlib_vim/autoload/tlib/notify.vim | 113 + .../plugged/tlib_vim/autoload/tlib/number.vim | 29 + .../tlib_vim/autoload/tlib/paragraph.vim | 97 + .../tlib_vim/autoload/tlib/persistent.vim | 54 + .../tlib_vim/autoload/tlib/progressbar.vim | 95 + .../plugged/tlib_vim/autoload/tlib/qfl.vim | 317 ++ .../plugged/tlib_vim/autoload/tlib/rx.vim | 54 + .../tlib_vim/autoload/tlib/scratch.vim | 136 + .../tlib_vim/autoload/tlib/selection.vim | 40 + .../plugged/tlib_vim/autoload/tlib/signs.vim | 103 + .../plugged/tlib_vim/autoload/tlib/string.vim | 208 ++ .../plugged/tlib_vim/autoload/tlib/syntax.vim | 38 + .../plugged/tlib_vim/autoload/tlib/sys.vim | 218 ++ .../plugged/tlib_vim/autoload/tlib/tab.vim | 49 + .../plugged/tlib_vim/autoload/tlib/tag.vim | 133 + .../tlib_vim/autoload/tlib/textobjects.vim | 45 + .../plugged/tlib_vim/autoload/tlib/time.vim | 84 + .../plugged/tlib_vim/autoload/tlib/trace.vim | 198 + .../plugged/tlib_vim/autoload/tlib/type.vim | 142 + .../plugged/tlib_vim/autoload/tlib/url.vim | 52 + .../plugged/tlib_vim/autoload/tlib/var.vim | 90 + .../plugged/tlib_vim/autoload/tlib/vcs.vim | 230 ++ .../plugged/tlib_vim/autoload/tlib/vim.vim | 152 + .../plugged/tlib_vim/autoload/tlib/win.vim | 197 + skel/.config/nvim/plugged/tlib_vim/doc/tags | 223 ++ .../nvim/plugged/tlib_vim/doc/tlib.txt | 1610 +++++++++ .../nvim/plugged/tlib_vim/etc/tpl_tlib.txt | 30 + .../nvim/plugged/tlib_vim/macros/tlib.vim | 38 + .../nvim/plugged/tlib_vim/plugin/02tlib.vim | 126 + .../samples/tlib/input/tlib_input_list.vim | 50 + .../tlib_vim/scripts/create_crc_table.rb | 67 + .../nvim/plugged/tlib_vim/spec/tlib/arg.vim | 66 + .../nvim/plugged/tlib_vim/spec/tlib/date.vim | 61 + .../plugged/tlib_vim/spec/tlib/dictionary.vim | 28 + .../nvim/plugged/tlib_vim/spec/tlib/eval.vim | 27 + .../nvim/plugged/tlib_vim/spec/tlib/file.vim | 59 + .../nvim/plugged/tlib_vim/spec/tlib/hash.vim | 58 + .../nvim/plugged/tlib_vim/spec/tlib/input.vim | 127 + .../nvim/plugged/tlib_vim/spec/tlib/list.vim | 67 + .../nvim/plugged/tlib_vim/spec/tlib/rx.vim | 27 + .../plugged/tlib_vim/spec/tlib/string.vim | 29 + .../nvim/plugged/tlib_vim/spec/tlib/url.vim | 23 + .../nvim/plugged/tlib_vim/spec/tlib/var.vim | 37 + .../plugged/vim-addon-mw-utils/.gitignore | 1 + .../vim-addon-mw-utils/autoload/buf_utils.vim | 24 + .../autoload/cached_file_contents.vim | 104 + .../autoload/env_reload.vim | 12 + .../vim-addon-mw-utils/autoload/funcref.vim | 95 + .../vim-addon-mw-utils/autoload/glob.vim | 27 + .../autoload/glob_linux.vim | 43 + .../vim-addon-mw-utils/autoload/tiny_cmd.vim | 19 + .../autoload/tovl/scratch_buffer.vim | 103 + .../autoload/tovl/ui/filter_list.vim | 473 +++ .../doc/cached_file_contents.txt | 7 + .../vim-addon-mw-utils/doc/funcref.txt | 35 + .../vim-addon-mw-utils/doc/tiny_cmd.txt | 18 + .../vim-addon-mw-utils-addon-info.txt | 9 + .../nvim/plugged/vim-snipmate/.gitignore | 3 + .../nvim/plugged/vim-snipmate/Contributors.md | 52 + .../nvim/plugged/vim-snipmate/README.md | 187 + .../nvim/plugged/vim-snipmate/addon-info.json | 12 + .../vim-snipmate/after/plugin/snipMate.vim | 46 + .../vim-snipmate/autoload/snipMate.vim | 648 ++++ .../autoload/snipMate_python_demo.vim | 47 + .../autoload/snipmate/jumping.vim | 228 ++ .../vim-snipmate/autoload/snipmate/legacy.vim | 139 + .../vim-snipmate/autoload/snipmate/parse.vim | 323 ++ .../vim-snipmate/autoload/snipmate/util.vim | 30 + .../plugged/vim-snipmate/doc/SnipMate.txt | 704 ++++ .../ftplugin/html_snip_helper.vim | 10 + .../vim-snipmate/ftplugin/snippets.vim | 20 + .../plugged/vim-snipmate/indent/snippets.vim | 32 + .../plugged/vim-snipmate/plugin/snipMate.vim | 136 + .../plugged/vim-snipmate/syntax/snippet.vim | 11 + .../plugged/vim-snipmate/syntax/snippets.vim | 23 + .../nvim/plugged/vim-snipmate/t/jumping.vim | 175 + .../nvim/plugged/vim-snipmate/t/parser.vim | 152 + .../nvim/plugged/vim-snipmate/t/tests.sh | 20 + .../.config/nvim/plugged/vim-snippets/AUTHORS | 45 + .../.config/nvim/plugged/vim-snippets/LICENSE | 20 + .../nvim/plugged/vim-snippets/README.md | 216 ++ .../plugged/vim-snippets/UltiSnips/README | 21 + .../vim-snippets/UltiSnips/all.snippets | 112 + .../vim-snippets/UltiSnips/bindzone.snippets | 27 + .../plugged/vim-snippets/UltiSnips/c.snippets | 117 + .../vim-snippets/UltiSnips/coffee.snippets | 98 + .../UltiSnips/coffee_jasmine.snippets | 163 + .../vim-snippets/UltiSnips/cpp.snippets | 50 + .../vim-snippets/UltiSnips/css.snippets | 405 +++ .../plugged/vim-snippets/UltiSnips/d.snippets | 583 +++ .../vim-snippets/UltiSnips/django.snippets | 236 ++ .../vim-snippets/UltiSnips/elixir.snippets | 168 + .../vim-snippets/UltiSnips/erlang.snippets | 98 + .../vim-snippets/UltiSnips/eruby.snippets | 287 ++ .../vim-snippets/UltiSnips/go.snippets | 107 + .../vim-snippets/UltiSnips/haskell.snippets | 61 + .../vim-snippets/UltiSnips/help.snippets | 30 + .../vim-snippets/UltiSnips/html.snippets | 297 ++ .../UltiSnips/html_minimal.snippets | 31 + .../UltiSnips/htmldjango.snippets | 1 + .../vim-snippets/UltiSnips/java.snippets | 212 ++ .../UltiSnips/javascript.snippets | 72 + .../UltiSnips/javascript_ember.snippets | 88 + .../UltiSnips/javascript_jasmine.snippets | 168 + .../vim-snippets/UltiSnips/jinja2.snippets | 209 ++ .../vim-snippets/UltiSnips/json.snippets | 19 + .../vim-snippets/UltiSnips/lua.snippets | 37 + .../vim-snippets/UltiSnips/mako.snippets | 90 + .../vim-snippets/UltiSnips/markdown.snippets | 44 + .../vim-snippets/UltiSnips/objc.snippets | 270 ++ .../vim-snippets/UltiSnips/ocaml.snippets | 167 + .../vim-snippets/UltiSnips/perl.snippets | 127 + .../vim-snippets/UltiSnips/php.snippets | 108 + .../UltiSnips/php/phpunit.snippets | 30 + .../UltiSnips/php/symfony2.snippets | 237 ++ .../vim-snippets/UltiSnips/puppet.snippets | 78 + .../vim-snippets/UltiSnips/python.snippets | 468 +++ .../vim-snippets/UltiSnips/rails.snippets | 906 +++++ .../vim-snippets/UltiSnips/rst.snippets | 314 ++ .../vim-snippets/UltiSnips/ruby.snippets | 566 +++ .../vim-snippets/UltiSnips/sh.snippets | 88 + .../vim-snippets/UltiSnips/snippets.snippets | 23 + .../vim-snippets/UltiSnips/tcl.snippets | 50 + .../vim-snippets/UltiSnips/tex.snippets | 124 + .../vim-snippets/UltiSnips/texmath.snippets | 54 + .../vim-snippets/UltiSnips/vim.snippets | 58 + .../vim-snippets/UltiSnips/xhtml.snippets | 0 .../vim-snippets/UltiSnips/xml.snippets | 9 + .../vim-snippets/UltiSnips/zsh.snippets | 11 + .../nvim/plugged/vim-snippets/addon-info.json | 9 + .../vim-snippets/autoload/vim_snippets.vim | 27 + .../plugged/vim-snippets/snippets/_.snippets | 241 ++ .../snippets/actionscript.snippets | 157 + .../vim-snippets/snippets/apache.snippets | 35 + .../vim-snippets/snippets/autoit.snippets | 66 + .../vim-snippets/snippets/bootstrap2.snippets | 840 +++++ .../vim-snippets/snippets/bootstrap3.snippets | 63 + .../plugged/vim-snippets/snippets/c.snippets | 237 ++ .../vim-snippets/snippets/chef.snippets | 204 ++ .../vim-snippets/snippets/clojure.snippets | 90 + .../vim-snippets/snippets/cmake.snippets | 58 + .../vim-snippets/snippets/coffee.snippets | 95 + .../vim-snippets/snippets/cpp.snippets | 131 + .../plugged/vim-snippets/snippets/cs.snippets | 374 ++ .../vim-snippets/snippets/css.snippets | 967 +++++ .../vim-snippets/snippets/dart.snippets | 82 + .../vim-snippets/snippets/diff.snippets | 11 + .../vim-snippets/snippets/django.snippets | 108 + .../vim-snippets/snippets/dosini.snippets | 12 + .../vim-snippets/snippets/ect.snippets | 37 + .../vim-snippets/snippets/elixir.snippets | 127 + .../vim-snippets/snippets/erlang.snippets | 353 ++ .../vim-snippets/snippets/eruby.snippets | 127 + .../vim-snippets/snippets/falcon.snippets | 71 + .../plugged/vim-snippets/snippets/go.snippets | 232 ++ .../vim-snippets/snippets/haml.snippets | 37 + .../vim-snippets/snippets/haskell.snippets | 82 + .../vim-snippets/snippets/html.snippets | 832 +++++ .../snippets/html_minimal.snippets | 72 + .../vim-snippets/snippets/htmldjango.snippets | 141 + .../snippets/htmltornado.snippets | 55 + .../vim-snippets/snippets/java.snippets | 240 ++ .../snippets/javascript-jquery.snippets | 589 +++ .../snippets/javascript.d3.snippets | 30 + .../vim-snippets/snippets/javascript.snippets | 221 ++ .../snippets/javascript_jquery.snippets | 589 +++ .../vim-snippets/snippets/jsp.snippets | 99 + .../vim-snippets/snippets/ledger.snippets | 5 + .../plugged/vim-snippets/snippets/ls.snippets | 108 + .../vim-snippets/snippets/lua.snippets | 21 + .../vim-snippets/snippets/make.snippets | 4 + .../vim-snippets/snippets/mako.snippets | 54 + .../vim-snippets/snippets/markdown.snippets | 87 + .../vim-snippets/snippets/objc.snippets | 247 ++ .../vim-snippets/snippets/openfoam.snippets | 53 + .../vim-snippets/snippets/perl.snippets | 351 ++ .../vim-snippets/snippets/php.snippets | 569 +++ .../vim-snippets/snippets/plsql.snippets | 109 + .../plugged/vim-snippets/snippets/po.snippets | 5 + .../vim-snippets/snippets/processing.snippets | 705 ++++ .../vim-snippets/snippets/progress.snippets | 58 + .../vim-snippets/snippets/puppet.snippets | 244 ++ .../vim-snippets/snippets/python.snippets | 202 ++ .../plugged/vim-snippets/snippets/r.snippets | 121 + .../vim-snippets/snippets/rst.snippets | 69 + .../vim-snippets/snippets/ruby.snippets | 1087 ++++++ .../vim-snippets/snippets/scala.snippets | 353 ++ .../plugged/vim-snippets/snippets/sh.snippets | 92 + .../vim-snippets/snippets/snippets.snippets | 9 + .../vim-snippets/snippets/sql.snippets | 26 + .../vim-snippets/snippets/tcl.snippets | 96 + .../vim-snippets/snippets/tex.snippets | 258 ++ .../vim-snippets/snippets/textile.snippets | 30 + .../vim-snippets/snippets/vim.snippets | 51 + .../vim-snippets/snippets/xslt.snippets | 97 + .../vim-snippets/snippets/yii-chtml.snippets | 248 ++ .../vim-snippets/snippets/yii.snippets | 300 ++ .../vim-snippets/snippets/zsh.snippets | 62 + .../plugged/vim-surround/.github/FUNDING.yml | 2 + .../nvim/plugged/vim-surround/.gitignore | 1 + .../nvim/plugged/vim-surround/README.markdown | 91 + .../plugged/vim-surround/doc/surround.txt | 217 ++ .../plugged/vim-surround/plugin/surround.vim | 619 ++++ .../plasma-org.kde.plasma.desktop-appletsrc | 233 ++ skel/.local/Apps/adminer-standalone/README.md | 22 + .../.local/Apps/adminer-standalone/adminer.sh | 10 + .../Apps/adminer-standalone/binaries.lst | 1 + .../.local/Apps/adminer-standalone/install.sh | 27 + .../www/.github/FUNDING.yml | 2 + .../Apps/adminer-standalone/www/.travis.yml | 7 + .../www/adminer/call.inc.php | 88 + .../www/adminer/create.inc.php | 223 ++ .../www/adminer/database.inc.php | 80 + .../adminer-standalone/www/adminer/db.inc.php | 237 ++ .../www/adminer/designs.php | 14 + .../www/adminer/download.inc.php | 10 + .../www/adminer/drivers/clickhouse.inc.php | 392 ++ .../www/adminer/drivers/elastic.inc.php | 465 +++ .../www/adminer/drivers/firebird.inc.php | 320 ++ .../www/adminer/drivers/mongo.inc.php | 732 ++++ .../www/adminer/drivers/mssql.inc.php | 673 ++++ .../www/adminer/drivers/mysql.inc.php | 1144 ++++++ .../www/adminer/drivers/oracle.inc.php | 433 +++ .../www/adminer/drivers/pgsql.inc.php | 872 +++++ .../www/adminer/drivers/simpledb.inc.php | 484 +++ .../www/adminer/drivers/sqlite.inc.php | 803 +++++ .../www/adminer/dump.inc.php | 224 ++ .../www/adminer/edit.inc.php | 117 + .../www/adminer/event.inc.php | 52 + .../www/adminer/file.inc.php | 26 + .../www/adminer/foreign.inc.php | 107 + .../www/adminer/include/adminer.inc.php | 1058 ++++++ .../www/adminer/include/auth.inc.php | 209 ++ .../www/adminer/include/bootstrap.inc.php | 102 + .../www/adminer/include/connect.inc.php | 102 + .../www/adminer/include/coverage.inc.php | 18 + .../www/adminer/include/design.inc.php | 195 + .../www/adminer/include/driver.inc.php | 168 + .../www/adminer/include/editing.inc.php | 579 +++ .../www/adminer/include/functions.inc.php | 1498 ++++++++ .../www/adminer/include/lang.inc.php | 127 + .../www/adminer/include/pdo.inc.php | 99 + .../www/adminer/include/tmpfile.inc.php | 22 + .../www/adminer/include/version.inc.php | 2 + .../www/adminer/include/xxtea.inc.php | 107 + .../adminer-standalone/www/adminer/index.php | 79 + .../www/adminer/indexes.inc.php | 146 + .../www/adminer/lang/ar.inc.php | 267 ++ .../www/adminer/lang/bg.inc.php | 336 ++ .../www/adminer/lang/bn.inc.php | 267 ++ .../www/adminer/lang/bs.inc.php | 321 ++ .../www/adminer/lang/ca.inc.php | 268 ++ .../www/adminer/lang/cs.inc.php | 349 ++ .../www/adminer/lang/da.inc.php | 282 ++ .../www/adminer/lang/de.inc.php | 289 ++ .../www/adminer/lang/el.inc.php | 336 ++ .../www/adminer/lang/en.inc.php | 15 + .../www/adminer/lang/es.inc.php | 268 ++ .../www/adminer/lang/et.inc.php | 268 ++ .../www/adminer/lang/fa.inc.php | 334 ++ .../www/adminer/lang/fi.inc.php | 336 ++ .../www/adminer/lang/fr.inc.php | 291 ++ .../www/adminer/lang/gl.inc.php | 291 ++ .../www/adminer/lang/he.inc.php | 293 ++ .../www/adminer/lang/hu.inc.php | 267 ++ .../www/adminer/lang/id.inc.php | 316 ++ .../www/adminer/lang/it.inc.php | 268 ++ .../www/adminer/lang/ja.inc.php | 277 ++ .../www/adminer/lang/ka.inc.php | 303 ++ .../www/adminer/lang/ko.inc.php | 267 ++ .../www/adminer/lang/lt.inc.php | 312 ++ .../www/adminer/lang/ms.inc.php | 340 ++ .../www/adminer/lang/nl.inc.php | 268 ++ .../www/adminer/lang/no.inc.php | 282 ++ .../www/adminer/lang/pl.inc.php | 340 ++ .../www/adminer/lang/pt-br.inc.php | 263 ++ .../www/adminer/lang/pt.inc.php | 263 ++ .../www/adminer/lang/ro.inc.php | 268 ++ .../www/adminer/lang/ru.inc.php | 292 ++ .../www/adminer/lang/sk.inc.php | 268 ++ .../www/adminer/lang/sl.inc.php | 307 ++ .../www/adminer/lang/sr.inc.php | 319 ++ .../www/adminer/lang/sv.inc.php | 349 ++ .../www/adminer/lang/ta.inc.php | 267 ++ .../www/adminer/lang/th.inc.php | 268 ++ .../www/adminer/lang/tr.inc.php | 343 ++ .../www/adminer/lang/uk.inc.php | 316 ++ .../www/adminer/lang/vi.inc.php | 328 ++ .../www/adminer/lang/xx.inc.php | 349 ++ .../www/adminer/lang/zh-tw.inc.php | 349 ++ .../www/adminer/lang/zh.inc.php | 349 ++ .../adminer-standalone/www/adminer/plugin.php | 44 + .../www/adminer/privileges.inc.php | 29 + .../www/adminer/procedure.inc.php | 57 + .../www/adminer/processlist.inc.php | 59 + .../www/adminer/schema.inc.php | 110 + .../www/adminer/scheme.inc.php | 38 + .../www/adminer/script.inc.php | 45 + .../www/adminer/select.inc.php | 589 +++ .../www/adminer/sequence.inc.php | 35 + .../www/adminer/sql.inc.php | 268 ++ .../adminer-standalone/www/adminer/sqlite.php | 11 + .../www/adminer/static/arrow.gif | Bin 0 -> 56 bytes .../www/adminer/static/cross.gif | Bin 0 -> 82 bytes .../www/adminer/static/default.css | 109 + .../www/adminer/static/down.gif | Bin 0 -> 79 bytes .../www/adminer/static/editing.js | 759 ++++ .../www/adminer/static/favicon.ico | Bin 0 -> 318 bytes .../www/adminer/static/functions.js | 912 +++++ .../www/adminer/static/plus.gif | Bin 0 -> 80 bytes .../www/adminer/static/up.gif | Bin 0 -> 79 bytes .../www/adminer/table.inc.php | 67 + .../www/adminer/trigger.inc.php | 49 + .../www/adminer/type.inc.php | 33 + .../www/adminer/user.inc.php | 189 + .../www/adminer/variables.inc.php | 16 + .../www/adminer/view.inc.php | 58 + .../Apps/adminer-standalone/www/changes.txt | 870 +++++ .../Apps/adminer-standalone/www/compile.php | 440 +++ .../Apps/adminer-standalone/www/composer.json | 31 + .../Apps/adminer-standalone/www/coverage.php | 82 + .../www/designs/brade/adminer.css | 62 + .../www/designs/bueltge/adminer.css | 428 +++ .../www/designs/cvicebni-ubor/adminer.css | 272 ++ .../www/designs/esterka/adminer.css | 261 ++ .../www/designs/flat/adminer.css | 108 + .../www/designs/galkaev/adminer.css | 990 +++++ .../www/designs/haeckel/adminer.css | 520 +++ .../www/designs/hever/adminer.css | 71 + .../www/designs/jukin/adminer.css | 29 + .../www/designs/kahi/adminer.css | 290 ++ .../www/designs/konya/adminer.css | 129 + .../www/designs/lucas-sandery/adminer.css | 699 ++++ .../www/designs/mancave-hever/adminer.css | 202 ++ .../www/designs/mancave/adminer.css | 1214 +++++++ .../www/designs/mvt/adminer.css | 818 +++++ .../www/designs/nette/adminer.css | 570 +++ .../www/designs/ng9/adminer.css | 259 ++ .../www/designs/nicu/adminer.css | 562 +++ .../www/designs/pappu687/adminer.css | 378 ++ .../www/designs/paranoiq/adminer.css | 290 ++ .../www/designs/pepa-linha/adminer.css | 664 ++++ .../www/designs/pilot/adminer.css | 127 + .../www/designs/pokorny/adminer.css | 294 ++ .../www/designs/price/adminer.css | 75 + .../adminer-standalone/www/designs/readme.txt | 1 + .../www/designs/rmsoft/adminer.css | 36 + .../www/designs/rmsoft_blue/adminer.css | 36 + .../adminer-standalone/www/editor/db.inc.php | 33 + .../adminer-standalone/www/editor/example.php | 52 + .../www/editor/include/adminer.inc.php | 658 ++++ .../www/editor/include/connect.inc.php | 2 + .../www/editor/include/editing.inc.php | 53 + .../adminer-standalone/www/editor/index.php | 30 + .../www/editor/script.inc.php | 16 + .../www/editor/static/editing.js | 62 + .../www/externals/JsShrink/jsShrink.php | 49 + .../www/externals/jush/jush.css | 33 + .../www/externals/jush/modules/jush-cnf.js | 19 + .../www/externals/jush/modules/jush-css.js | 50 + .../www/externals/jush/modules/jush-htm.js | 97 + .../www/externals/jush/modules/jush-http.js | 12 + .../www/externals/jush/modules/jush-js.js | 43 + .../www/externals/jush/modules/jush-mssql.js | 12 + .../www/externals/jush/modules/jush-oracle.js | 8 + .../www/externals/jush/modules/jush-pgsql.js | 20 + .../www/externals/jush/modules/jush-php.js | 109 + .../externals/jush/modules/jush-simpledb.js | 7 + .../www/externals/jush/modules/jush-sql.js | 47 + .../www/externals/jush/modules/jush-sqlite.js | 24 + .../externals/jush/modules/jush-textarea.js | 211 ++ .../www/externals/jush/modules/jush-txt.js | 1 + .../www/externals/jush/modules/jush.js | 501 +++ .../Apps/adminer-standalone/www/index.php | 1 + .../Apps/adminer-standalone/www/lang.php | 62 + .../www/plugins/database-hide.php | 29 + .../www/plugins/designs.php | 43 + .../www/plugins/dump-alter.php | 155 + .../www/plugins/dump-bz2.php | 41 + .../www/plugins/dump-date.php | 16 + .../www/plugins/dump-json.php | 62 + .../www/plugins/dump-php.php | 51 + .../www/plugins/dump-xml.php | 56 + .../www/plugins/dump-zip.php | 45 + .../www/plugins/edit-calendar.php | 56 + .../www/plugins/edit-foreign.php | 43 + .../www/plugins/edit-textarea.php | 17 + .../www/plugins/email-table.php | 60 + .../www/plugins/enum-option.php | 40 + .../www/plugins/enum-types.php | 50 + ...-sqlite-connection-without-credentials.php | 6 + .../www/plugins/file-upload.php | 53 + .../www/plugins/foreign-system.php | 56 + .../adminer-standalone/www/plugins/frames.php | 28 + .../www/plugins/json-column.php | 48 + .../www/plugins/login-ip.php | 42 + .../www/plugins/login-otp.php | 55 + .../www/plugins/login-password-less.php | 31 + .../www/plugins/login-servers.php | 42 + .../www/plugins/login-ssl.php | 24 + .../www/plugins/login-table.php | 34 + .../www/plugins/master-slave.php | 43 + .../adminer-standalone/www/plugins/plugin.php | 403 +++ .../www/plugins/pretty-json-column.php | 40 + .../adminer-standalone/www/plugins/readme.txt | 2 + .../www/plugins/slugify.php | 51 + .../www/plugins/sql-log.php | 41 + .../www/plugins/struct-comments.php | 14 + .../www/plugins/table-indexes-structure.php | 33 + .../www/plugins/table-structure.php | 33 + .../www/plugins/tables-filter.php | 69 + .../www/plugins/tinymce.php | 77 + .../www/plugins/translation.php | 55 + .../www/plugins/version-noverify.php | 16 + .../www/plugins/wymeditor.php | 66 + .../Apps/adminer-standalone/www/readme.txt | 20 + .../adminer-standalone/www/tests/katalon.html | 1608 +++++++++ .../Apps/adminer-standalone/www/todo.txt | 55 + skel/.local/Apps/installer-scripts/README.md | 46 + .../installer-scripts/bin/installer-script.sh | 64 + .../Apps/installer-scripts/binaries.lst | 1 + .../Apps/installer-scripts/gen-installer.sh | 8 + .../Apps/installer-scripts/installer.sh | 65 + .../installer-scripts/lib/installer_common | 48 + .../Apps/installer-scripts/packages/_generic | 50 + .../Apps/installer-scripts/packages/ffmpeg | 14 + .../Apps/installer-scripts/packages/iojs | 14 + .../Apps/installer-scripts/packages/nodejs | 16 + .../Apps/installer-scripts/packages/self | 14 + skel/.local/bin/adminer.sh | 1 + skel/.local/bin/installer-script.sh | 1 + skel/.local/bin/nv | 3 + 531 files changed, 105507 insertions(+) create mode 100644 skel/.bashrc create mode 120000 skel/.config/alacritty/alacritty.yml create mode 100644 skel/.config/kglobalshortcutsrc create mode 100644 skel/.config/khotkeysrc create mode 100644 skel/.config/kwinrc create mode 100644 skel/.config/nvim/autoload/plug.vim create mode 100644 skel/.config/nvim/colors/molokai.vim create mode 100644 skel/.config/nvim/init.vim create mode 100644 skel/.config/nvim/plugged/fzf.vim/.github/ISSUE_TEMPLATE.md create mode 100644 skel/.config/nvim/plugged/fzf.vim/.gitignore create mode 100644 skel/.config/nvim/plugged/fzf.vim/README.md create mode 100644 skel/.config/nvim/plugged/fzf.vim/autoload/fzf/vim.vim create mode 100644 skel/.config/nvim/plugged/fzf.vim/autoload/fzf/vim/complete.vim create mode 100755 skel/.config/nvim/plugged/fzf.vim/bin/preview.rb create mode 100755 skel/.config/nvim/plugged/fzf.vim/bin/preview.sh create mode 100755 skel/.config/nvim/plugged/fzf.vim/bin/tags.pl create mode 100644 skel/.config/nvim/plugged/fzf.vim/doc/fzf-vim.txt create mode 100644 skel/.config/nvim/plugged/fzf.vim/plugin/fzf.vim create mode 100644 skel/.config/nvim/plugged/fzf/BUILD.md create mode 100644 skel/.config/nvim/plugged/fzf/CHANGELOG.md create mode 100644 skel/.config/nvim/plugged/fzf/LICENSE create mode 100644 skel/.config/nvim/plugged/fzf/README-VIM.md create mode 100644 skel/.config/nvim/plugged/fzf/README.md create mode 100755 skel/.config/nvim/plugged/fzf/bin/fzf-tmux create mode 100644 skel/.config/nvim/plugged/fzf/doc/fzf.txt create mode 100644 skel/.config/nvim/plugged/fzf/doc/tags create mode 100644 skel/.config/nvim/plugged/fzf/man/man1/fzf-tmux.1 create mode 100644 skel/.config/nvim/plugged/fzf/man/man1/fzf.1 create mode 100644 skel/.config/nvim/plugged/fzf/plugin/fzf.vim create mode 100644 skel/.config/nvim/plugged/fzf/shell/completion.bash create mode 100644 skel/.config/nvim/plugged/fzf/shell/completion.zsh create mode 100644 skel/.config/nvim/plugged/fzf/shell/key-bindings.bash create mode 100644 skel/.config/nvim/plugged/fzf/shell/key-bindings.fish create mode 100755 skel/.config/nvim/plugged/fzf/shell/key-bindings.zsh create mode 100644 skel/.config/nvim/plugged/harish2704-vim/ftplugin/javascript/settings.vim create mode 100644 skel/.config/nvim/plugged/harish2704-vim/plugin/utils.vim create mode 100644 skel/.config/nvim/plugged/nerdcommenter/.github/FUNDING.yml create mode 100644 skel/.config/nvim/plugged/nerdcommenter/.github/workflows/vint.yml create mode 100644 skel/.config/nvim/plugged/nerdcommenter/.gitignore create mode 100644 skel/.config/nvim/plugged/nerdcommenter/README.md create mode 100644 skel/.config/nvim/plugged/nerdcommenter/Rakefile create mode 100644 skel/.config/nvim/plugged/nerdcommenter/doc/NERD_commenter.txt create mode 100644 skel/.config/nvim/plugged/nerdcommenter/plugin/NERD_commenter.vim create mode 100644 skel/.config/nvim/plugged/sparkup/.gitignore create mode 100644 skel/.config/nvim/plugged/sparkup/Makefile create mode 100644 skel/.config/nvim/plugged/sparkup/README.md create mode 100644 skel/.config/nvim/plugged/sparkup/TextMate/Sparkup.tmbundle/Commands/Sparkup expand.tmCommand create mode 120000 skel/.config/nvim/plugged/sparkup/TextMate/Sparkup.tmbundle/Support/sparkup.py create mode 100644 skel/.config/nvim/plugged/sparkup/TextMate/Sparkup.tmbundle/info.plist create mode 100644 skel/.config/nvim/plugged/sparkup/ftdetect/hsb.vim create mode 100644 skel/.config/nvim/plugged/sparkup/mit-license.txt create mode 100755 skel/.config/nvim/plugged/sparkup/sparkup-unittest.py create mode 100755 skel/.config/nvim/plugged/sparkup/sparkup.py create mode 100644 skel/.config/nvim/plugged/sparkup/vim/README.txt create mode 120000 skel/.config/nvim/plugged/sparkup/vim/ftplugin/html/sparkup.py create mode 100644 skel/.config/nvim/plugged/sparkup/vim/ftplugin/html/sparkup.vim create mode 120000 skel/.config/nvim/plugged/sparkup/vim/ftplugin/htmldjango create mode 120000 skel/.config/nvim/plugged/sparkup/vim/ftplugin/smarty create mode 120000 skel/.config/nvim/plugged/sparkup/vim/ftplugin/xml create mode 100644 skel/.config/nvim/plugged/tlib_vim/.gitignore create mode 100644 skel/.config/nvim/plugged/tlib_vim/CHANGES.TXT create mode 100644 skel/.config/nvim/plugged/tlib_vim/LICENSE.TXT create mode 100644 skel/.config/nvim/plugged/tlib_vim/README create mode 100644 skel/.config/nvim/plugged/tlib_vim/addon-info.json create mode 100644 skel/.config/nvim/plugged/tlib_vim/autoload/tinykeymap/map/para_move.vim create mode 100644 skel/.config/nvim/plugged/tlib_vim/autoload/tlib.vim create mode 100644 skel/.config/nvim/plugged/tlib_vim/autoload/tlib/Filter_cnf.vim create mode 100644 skel/.config/nvim/plugged/tlib_vim/autoload/tlib/Filter_cnfd.vim create mode 100644 skel/.config/nvim/plugged/tlib_vim/autoload/tlib/Filter_fuzzy.vim create mode 100644 skel/.config/nvim/plugged/tlib_vim/autoload/tlib/Filter_glob.vim create mode 100644 skel/.config/nvim/plugged/tlib_vim/autoload/tlib/Object.vim create mode 100644 skel/.config/nvim/plugged/tlib_vim/autoload/tlib/Test.vim create mode 100644 skel/.config/nvim/plugged/tlib_vim/autoload/tlib/TestChild.vim create mode 100644 skel/.config/nvim/plugged/tlib_vim/autoload/tlib/World.vim create mode 100644 skel/.config/nvim/plugged/tlib_vim/autoload/tlib/agent.vim create mode 100644 skel/.config/nvim/plugged/tlib_vim/autoload/tlib/arg.vim create mode 100644 skel/.config/nvim/plugged/tlib_vim/autoload/tlib/assert.vim create mode 100644 skel/.config/nvim/plugged/tlib_vim/autoload/tlib/autocmdgroup.vim create mode 100644 skel/.config/nvim/plugged/tlib_vim/autoload/tlib/balloon.vim create mode 100644 skel/.config/nvim/plugged/tlib_vim/autoload/tlib/bitwise.vim create mode 100644 skel/.config/nvim/plugged/tlib_vim/autoload/tlib/buffer.vim create mode 100644 skel/.config/nvim/plugged/tlib_vim/autoload/tlib/cache.vim create mode 100644 skel/.config/nvim/plugged/tlib_vim/autoload/tlib/char.vim create mode 100644 skel/.config/nvim/plugged/tlib_vim/autoload/tlib/cmd.vim create mode 100644 skel/.config/nvim/plugged/tlib_vim/autoload/tlib/comments.vim create mode 100644 skel/.config/nvim/plugged/tlib_vim/autoload/tlib/date.vim create mode 100644 skel/.config/nvim/plugged/tlib_vim/autoload/tlib/dictionary.vim create mode 100644 skel/.config/nvim/plugged/tlib_vim/autoload/tlib/dir.vim create mode 100644 skel/.config/nvim/plugged/tlib_vim/autoload/tlib/eval.vim create mode 100644 skel/.config/nvim/plugged/tlib_vim/autoload/tlib/file.vim create mode 100644 skel/.config/nvim/plugged/tlib_vim/autoload/tlib/fixes.vim create mode 100644 skel/.config/nvim/plugged/tlib_vim/autoload/tlib/grep.vim create mode 100644 skel/.config/nvim/plugged/tlib_vim/autoload/tlib/hash.vim create mode 100644 skel/.config/nvim/plugged/tlib_vim/autoload/tlib/hook.vim create mode 100644 skel/.config/nvim/plugged/tlib_vim/autoload/tlib/input.vim create mode 100644 skel/.config/nvim/plugged/tlib_vim/autoload/tlib/list.vim create mode 100644 skel/.config/nvim/plugged/tlib_vim/autoload/tlib/loclist.vim create mode 100644 skel/.config/nvim/plugged/tlib_vim/autoload/tlib/map.vim create mode 100644 skel/.config/nvim/plugged/tlib_vim/autoload/tlib/normal.vim create mode 100644 skel/.config/nvim/plugged/tlib_vim/autoload/tlib/notify.vim create mode 100644 skel/.config/nvim/plugged/tlib_vim/autoload/tlib/number.vim create mode 100644 skel/.config/nvim/plugged/tlib_vim/autoload/tlib/paragraph.vim create mode 100644 skel/.config/nvim/plugged/tlib_vim/autoload/tlib/persistent.vim create mode 100644 skel/.config/nvim/plugged/tlib_vim/autoload/tlib/progressbar.vim create mode 100644 skel/.config/nvim/plugged/tlib_vim/autoload/tlib/qfl.vim create mode 100644 skel/.config/nvim/plugged/tlib_vim/autoload/tlib/rx.vim create mode 100644 skel/.config/nvim/plugged/tlib_vim/autoload/tlib/scratch.vim create mode 100644 skel/.config/nvim/plugged/tlib_vim/autoload/tlib/selection.vim create mode 100644 skel/.config/nvim/plugged/tlib_vim/autoload/tlib/signs.vim create mode 100644 skel/.config/nvim/plugged/tlib_vim/autoload/tlib/string.vim create mode 100644 skel/.config/nvim/plugged/tlib_vim/autoload/tlib/syntax.vim create mode 100644 skel/.config/nvim/plugged/tlib_vim/autoload/tlib/sys.vim create mode 100644 skel/.config/nvim/plugged/tlib_vim/autoload/tlib/tab.vim create mode 100644 skel/.config/nvim/plugged/tlib_vim/autoload/tlib/tag.vim create mode 100644 skel/.config/nvim/plugged/tlib_vim/autoload/tlib/textobjects.vim create mode 100644 skel/.config/nvim/plugged/tlib_vim/autoload/tlib/time.vim create mode 100644 skel/.config/nvim/plugged/tlib_vim/autoload/tlib/trace.vim create mode 100644 skel/.config/nvim/plugged/tlib_vim/autoload/tlib/type.vim create mode 100644 skel/.config/nvim/plugged/tlib_vim/autoload/tlib/url.vim create mode 100644 skel/.config/nvim/plugged/tlib_vim/autoload/tlib/var.vim create mode 100644 skel/.config/nvim/plugged/tlib_vim/autoload/tlib/vcs.vim create mode 100644 skel/.config/nvim/plugged/tlib_vim/autoload/tlib/vim.vim create mode 100644 skel/.config/nvim/plugged/tlib_vim/autoload/tlib/win.vim create mode 100644 skel/.config/nvim/plugged/tlib_vim/doc/tags create mode 100644 skel/.config/nvim/plugged/tlib_vim/doc/tlib.txt create mode 100644 skel/.config/nvim/plugged/tlib_vim/etc/tpl_tlib.txt create mode 100644 skel/.config/nvim/plugged/tlib_vim/macros/tlib.vim create mode 100644 skel/.config/nvim/plugged/tlib_vim/plugin/02tlib.vim create mode 100644 skel/.config/nvim/plugged/tlib_vim/samples/tlib/input/tlib_input_list.vim create mode 100644 skel/.config/nvim/plugged/tlib_vim/scripts/create_crc_table.rb create mode 100644 skel/.config/nvim/plugged/tlib_vim/spec/tlib/arg.vim create mode 100644 skel/.config/nvim/plugged/tlib_vim/spec/tlib/date.vim create mode 100644 skel/.config/nvim/plugged/tlib_vim/spec/tlib/dictionary.vim create mode 100644 skel/.config/nvim/plugged/tlib_vim/spec/tlib/eval.vim create mode 100644 skel/.config/nvim/plugged/tlib_vim/spec/tlib/file.vim create mode 100644 skel/.config/nvim/plugged/tlib_vim/spec/tlib/hash.vim create mode 100644 skel/.config/nvim/plugged/tlib_vim/spec/tlib/input.vim create mode 100644 skel/.config/nvim/plugged/tlib_vim/spec/tlib/list.vim create mode 100644 skel/.config/nvim/plugged/tlib_vim/spec/tlib/rx.vim create mode 100644 skel/.config/nvim/plugged/tlib_vim/spec/tlib/string.vim create mode 100644 skel/.config/nvim/plugged/tlib_vim/spec/tlib/url.vim create mode 100644 skel/.config/nvim/plugged/tlib_vim/spec/tlib/var.vim create mode 100644 skel/.config/nvim/plugged/vim-addon-mw-utils/.gitignore create mode 100644 skel/.config/nvim/plugged/vim-addon-mw-utils/autoload/buf_utils.vim create mode 100644 skel/.config/nvim/plugged/vim-addon-mw-utils/autoload/cached_file_contents.vim create mode 100644 skel/.config/nvim/plugged/vim-addon-mw-utils/autoload/env_reload.vim create mode 100644 skel/.config/nvim/plugged/vim-addon-mw-utils/autoload/funcref.vim create mode 100644 skel/.config/nvim/plugged/vim-addon-mw-utils/autoload/glob.vim create mode 100644 skel/.config/nvim/plugged/vim-addon-mw-utils/autoload/glob_linux.vim create mode 100644 skel/.config/nvim/plugged/vim-addon-mw-utils/autoload/tiny_cmd.vim create mode 100644 skel/.config/nvim/plugged/vim-addon-mw-utils/autoload/tovl/scratch_buffer.vim create mode 100644 skel/.config/nvim/plugged/vim-addon-mw-utils/autoload/tovl/ui/filter_list.vim create mode 100644 skel/.config/nvim/plugged/vim-addon-mw-utils/doc/cached_file_contents.txt create mode 100644 skel/.config/nvim/plugged/vim-addon-mw-utils/doc/funcref.txt create mode 100644 skel/.config/nvim/plugged/vim-addon-mw-utils/doc/tiny_cmd.txt create mode 100644 skel/.config/nvim/plugged/vim-addon-mw-utils/vim-addon-mw-utils-addon-info.txt create mode 100644 skel/.config/nvim/plugged/vim-snipmate/.gitignore create mode 100644 skel/.config/nvim/plugged/vim-snipmate/Contributors.md create mode 100644 skel/.config/nvim/plugged/vim-snipmate/README.md create mode 100644 skel/.config/nvim/plugged/vim-snipmate/addon-info.json create mode 100644 skel/.config/nvim/plugged/vim-snipmate/after/plugin/snipMate.vim create mode 100644 skel/.config/nvim/plugged/vim-snipmate/autoload/snipMate.vim create mode 100644 skel/.config/nvim/plugged/vim-snipmate/autoload/snipMate_python_demo.vim create mode 100644 skel/.config/nvim/plugged/vim-snipmate/autoload/snipmate/jumping.vim create mode 100644 skel/.config/nvim/plugged/vim-snipmate/autoload/snipmate/legacy.vim create mode 100644 skel/.config/nvim/plugged/vim-snipmate/autoload/snipmate/parse.vim create mode 100644 skel/.config/nvim/plugged/vim-snipmate/autoload/snipmate/util.vim create mode 100644 skel/.config/nvim/plugged/vim-snipmate/doc/SnipMate.txt create mode 100644 skel/.config/nvim/plugged/vim-snipmate/ftplugin/html_snip_helper.vim create mode 100644 skel/.config/nvim/plugged/vim-snipmate/ftplugin/snippets.vim create mode 100644 skel/.config/nvim/plugged/vim-snipmate/indent/snippets.vim create mode 100644 skel/.config/nvim/plugged/vim-snipmate/plugin/snipMate.vim create mode 100644 skel/.config/nvim/plugged/vim-snipmate/syntax/snippet.vim create mode 100644 skel/.config/nvim/plugged/vim-snipmate/syntax/snippets.vim create mode 100644 skel/.config/nvim/plugged/vim-snipmate/t/jumping.vim create mode 100644 skel/.config/nvim/plugged/vim-snipmate/t/parser.vim create mode 100755 skel/.config/nvim/plugged/vim-snipmate/t/tests.sh create mode 100644 skel/.config/nvim/plugged/vim-snippets/AUTHORS create mode 100644 skel/.config/nvim/plugged/vim-snippets/LICENSE create mode 100644 skel/.config/nvim/plugged/vim-snippets/README.md create mode 100644 skel/.config/nvim/plugged/vim-snippets/UltiSnips/README create mode 100644 skel/.config/nvim/plugged/vim-snippets/UltiSnips/all.snippets create mode 100644 skel/.config/nvim/plugged/vim-snippets/UltiSnips/bindzone.snippets create mode 100644 skel/.config/nvim/plugged/vim-snippets/UltiSnips/c.snippets create mode 100644 skel/.config/nvim/plugged/vim-snippets/UltiSnips/coffee.snippets create mode 100644 skel/.config/nvim/plugged/vim-snippets/UltiSnips/coffee_jasmine.snippets create mode 100644 skel/.config/nvim/plugged/vim-snippets/UltiSnips/cpp.snippets create mode 100644 skel/.config/nvim/plugged/vim-snippets/UltiSnips/css.snippets create mode 100644 skel/.config/nvim/plugged/vim-snippets/UltiSnips/d.snippets create mode 100644 skel/.config/nvim/plugged/vim-snippets/UltiSnips/django.snippets create mode 100644 skel/.config/nvim/plugged/vim-snippets/UltiSnips/elixir.snippets create mode 100644 skel/.config/nvim/plugged/vim-snippets/UltiSnips/erlang.snippets create mode 100644 skel/.config/nvim/plugged/vim-snippets/UltiSnips/eruby.snippets create mode 100644 skel/.config/nvim/plugged/vim-snippets/UltiSnips/go.snippets create mode 100644 skel/.config/nvim/plugged/vim-snippets/UltiSnips/haskell.snippets create mode 100644 skel/.config/nvim/plugged/vim-snippets/UltiSnips/help.snippets create mode 100644 skel/.config/nvim/plugged/vim-snippets/UltiSnips/html.snippets create mode 100644 skel/.config/nvim/plugged/vim-snippets/UltiSnips/html_minimal.snippets create mode 100644 skel/.config/nvim/plugged/vim-snippets/UltiSnips/htmldjango.snippets create mode 100644 skel/.config/nvim/plugged/vim-snippets/UltiSnips/java.snippets create mode 100644 skel/.config/nvim/plugged/vim-snippets/UltiSnips/javascript.snippets create mode 100644 skel/.config/nvim/plugged/vim-snippets/UltiSnips/javascript_ember.snippets create mode 100644 skel/.config/nvim/plugged/vim-snippets/UltiSnips/javascript_jasmine.snippets create mode 100644 skel/.config/nvim/plugged/vim-snippets/UltiSnips/jinja2.snippets create mode 100644 skel/.config/nvim/plugged/vim-snippets/UltiSnips/json.snippets create mode 100644 skel/.config/nvim/plugged/vim-snippets/UltiSnips/lua.snippets create mode 100644 skel/.config/nvim/plugged/vim-snippets/UltiSnips/mako.snippets create mode 100644 skel/.config/nvim/plugged/vim-snippets/UltiSnips/markdown.snippets create mode 100644 skel/.config/nvim/plugged/vim-snippets/UltiSnips/objc.snippets create mode 100644 skel/.config/nvim/plugged/vim-snippets/UltiSnips/ocaml.snippets create mode 100644 skel/.config/nvim/plugged/vim-snippets/UltiSnips/perl.snippets create mode 100644 skel/.config/nvim/plugged/vim-snippets/UltiSnips/php.snippets create mode 100644 skel/.config/nvim/plugged/vim-snippets/UltiSnips/php/phpunit.snippets create mode 100644 skel/.config/nvim/plugged/vim-snippets/UltiSnips/php/symfony2.snippets create mode 100644 skel/.config/nvim/plugged/vim-snippets/UltiSnips/puppet.snippets create mode 100644 skel/.config/nvim/plugged/vim-snippets/UltiSnips/python.snippets create mode 100644 skel/.config/nvim/plugged/vim-snippets/UltiSnips/rails.snippets create mode 100644 skel/.config/nvim/plugged/vim-snippets/UltiSnips/rst.snippets create mode 100644 skel/.config/nvim/plugged/vim-snippets/UltiSnips/ruby.snippets create mode 100644 skel/.config/nvim/plugged/vim-snippets/UltiSnips/sh.snippets create mode 100644 skel/.config/nvim/plugged/vim-snippets/UltiSnips/snippets.snippets create mode 100644 skel/.config/nvim/plugged/vim-snippets/UltiSnips/tcl.snippets create mode 100644 skel/.config/nvim/plugged/vim-snippets/UltiSnips/tex.snippets create mode 100644 skel/.config/nvim/plugged/vim-snippets/UltiSnips/texmath.snippets create mode 100644 skel/.config/nvim/plugged/vim-snippets/UltiSnips/vim.snippets create mode 100644 skel/.config/nvim/plugged/vim-snippets/UltiSnips/xhtml.snippets create mode 100644 skel/.config/nvim/plugged/vim-snippets/UltiSnips/xml.snippets create mode 100644 skel/.config/nvim/plugged/vim-snippets/UltiSnips/zsh.snippets create mode 100644 skel/.config/nvim/plugged/vim-snippets/addon-info.json create mode 100644 skel/.config/nvim/plugged/vim-snippets/autoload/vim_snippets.vim create mode 100644 skel/.config/nvim/plugged/vim-snippets/snippets/_.snippets create mode 100644 skel/.config/nvim/plugged/vim-snippets/snippets/actionscript.snippets create mode 100644 skel/.config/nvim/plugged/vim-snippets/snippets/apache.snippets create mode 100644 skel/.config/nvim/plugged/vim-snippets/snippets/autoit.snippets create mode 100644 skel/.config/nvim/plugged/vim-snippets/snippets/bootstrap2.snippets create mode 100644 skel/.config/nvim/plugged/vim-snippets/snippets/bootstrap3.snippets create mode 100644 skel/.config/nvim/plugged/vim-snippets/snippets/c.snippets create mode 100644 skel/.config/nvim/plugged/vim-snippets/snippets/chef.snippets create mode 100644 skel/.config/nvim/plugged/vim-snippets/snippets/clojure.snippets create mode 100644 skel/.config/nvim/plugged/vim-snippets/snippets/cmake.snippets create mode 100644 skel/.config/nvim/plugged/vim-snippets/snippets/coffee.snippets create mode 100644 skel/.config/nvim/plugged/vim-snippets/snippets/cpp.snippets create mode 100644 skel/.config/nvim/plugged/vim-snippets/snippets/cs.snippets create mode 100644 skel/.config/nvim/plugged/vim-snippets/snippets/css.snippets create mode 100644 skel/.config/nvim/plugged/vim-snippets/snippets/dart.snippets create mode 100644 skel/.config/nvim/plugged/vim-snippets/snippets/diff.snippets create mode 100644 skel/.config/nvim/plugged/vim-snippets/snippets/django.snippets create mode 100644 skel/.config/nvim/plugged/vim-snippets/snippets/dosini.snippets create mode 100644 skel/.config/nvim/plugged/vim-snippets/snippets/ect.snippets create mode 100644 skel/.config/nvim/plugged/vim-snippets/snippets/elixir.snippets create mode 100644 skel/.config/nvim/plugged/vim-snippets/snippets/erlang.snippets create mode 100644 skel/.config/nvim/plugged/vim-snippets/snippets/eruby.snippets create mode 100644 skel/.config/nvim/plugged/vim-snippets/snippets/falcon.snippets create mode 100644 skel/.config/nvim/plugged/vim-snippets/snippets/go.snippets create mode 100644 skel/.config/nvim/plugged/vim-snippets/snippets/haml.snippets create mode 100644 skel/.config/nvim/plugged/vim-snippets/snippets/haskell.snippets create mode 100644 skel/.config/nvim/plugged/vim-snippets/snippets/html.snippets create mode 100644 skel/.config/nvim/plugged/vim-snippets/snippets/html_minimal.snippets create mode 100644 skel/.config/nvim/plugged/vim-snippets/snippets/htmldjango.snippets create mode 100644 skel/.config/nvim/plugged/vim-snippets/snippets/htmltornado.snippets create mode 100644 skel/.config/nvim/plugged/vim-snippets/snippets/java.snippets create mode 100644 skel/.config/nvim/plugged/vim-snippets/snippets/javascript-jquery.snippets create mode 100644 skel/.config/nvim/plugged/vim-snippets/snippets/javascript.d3.snippets create mode 100644 skel/.config/nvim/plugged/vim-snippets/snippets/javascript.snippets create mode 100755 skel/.config/nvim/plugged/vim-snippets/snippets/javascript_jquery.snippets create mode 100644 skel/.config/nvim/plugged/vim-snippets/snippets/jsp.snippets create mode 100644 skel/.config/nvim/plugged/vim-snippets/snippets/ledger.snippets create mode 100644 skel/.config/nvim/plugged/vim-snippets/snippets/ls.snippets create mode 100644 skel/.config/nvim/plugged/vim-snippets/snippets/lua.snippets create mode 100644 skel/.config/nvim/plugged/vim-snippets/snippets/make.snippets create mode 100644 skel/.config/nvim/plugged/vim-snippets/snippets/mako.snippets create mode 100644 skel/.config/nvim/plugged/vim-snippets/snippets/markdown.snippets create mode 100644 skel/.config/nvim/plugged/vim-snippets/snippets/objc.snippets create mode 100644 skel/.config/nvim/plugged/vim-snippets/snippets/openfoam.snippets create mode 100644 skel/.config/nvim/plugged/vim-snippets/snippets/perl.snippets create mode 100644 skel/.config/nvim/plugged/vim-snippets/snippets/php.snippets create mode 100644 skel/.config/nvim/plugged/vim-snippets/snippets/plsql.snippets create mode 100644 skel/.config/nvim/plugged/vim-snippets/snippets/po.snippets create mode 100755 skel/.config/nvim/plugged/vim-snippets/snippets/processing.snippets create mode 100644 skel/.config/nvim/plugged/vim-snippets/snippets/progress.snippets create mode 100644 skel/.config/nvim/plugged/vim-snippets/snippets/puppet.snippets create mode 100644 skel/.config/nvim/plugged/vim-snippets/snippets/python.snippets create mode 100644 skel/.config/nvim/plugged/vim-snippets/snippets/r.snippets create mode 100644 skel/.config/nvim/plugged/vim-snippets/snippets/rst.snippets create mode 100644 skel/.config/nvim/plugged/vim-snippets/snippets/ruby.snippets create mode 100644 skel/.config/nvim/plugged/vim-snippets/snippets/scala.snippets create mode 100644 skel/.config/nvim/plugged/vim-snippets/snippets/sh.snippets create mode 100644 skel/.config/nvim/plugged/vim-snippets/snippets/snippets.snippets create mode 100644 skel/.config/nvim/plugged/vim-snippets/snippets/sql.snippets create mode 100644 skel/.config/nvim/plugged/vim-snippets/snippets/tcl.snippets create mode 100644 skel/.config/nvim/plugged/vim-snippets/snippets/tex.snippets create mode 100644 skel/.config/nvim/plugged/vim-snippets/snippets/textile.snippets create mode 100644 skel/.config/nvim/plugged/vim-snippets/snippets/vim.snippets create mode 100644 skel/.config/nvim/plugged/vim-snippets/snippets/xslt.snippets create mode 100644 skel/.config/nvim/plugged/vim-snippets/snippets/yii-chtml.snippets create mode 100644 skel/.config/nvim/plugged/vim-snippets/snippets/yii.snippets create mode 100644 skel/.config/nvim/plugged/vim-snippets/snippets/zsh.snippets create mode 100644 skel/.config/nvim/plugged/vim-surround/.github/FUNDING.yml create mode 100644 skel/.config/nvim/plugged/vim-surround/.gitignore create mode 100644 skel/.config/nvim/plugged/vim-surround/README.markdown create mode 100644 skel/.config/nvim/plugged/vim-surround/doc/surround.txt create mode 100644 skel/.config/nvim/plugged/vim-surround/plugin/surround.vim create mode 100644 skel/.config/plasma-org.kde.plasma.desktop-appletsrc create mode 100644 skel/.local/Apps/adminer-standalone/README.md create mode 100755 skel/.local/Apps/adminer-standalone/adminer.sh create mode 100644 skel/.local/Apps/adminer-standalone/binaries.lst create mode 100755 skel/.local/Apps/adminer-standalone/install.sh create mode 100644 skel/.local/Apps/adminer-standalone/www/.github/FUNDING.yml create mode 100644 skel/.local/Apps/adminer-standalone/www/.travis.yml create mode 100644 skel/.local/Apps/adminer-standalone/www/adminer/call.inc.php create mode 100644 skel/.local/Apps/adminer-standalone/www/adminer/create.inc.php create mode 100644 skel/.local/Apps/adminer-standalone/www/adminer/database.inc.php create mode 100644 skel/.local/Apps/adminer-standalone/www/adminer/db.inc.php create mode 100644 skel/.local/Apps/adminer-standalone/www/adminer/designs.php create mode 100644 skel/.local/Apps/adminer-standalone/www/adminer/download.inc.php create mode 100644 skel/.local/Apps/adminer-standalone/www/adminer/drivers/clickhouse.inc.php create mode 100644 skel/.local/Apps/adminer-standalone/www/adminer/drivers/elastic.inc.php create mode 100644 skel/.local/Apps/adminer-standalone/www/adminer/drivers/firebird.inc.php create mode 100644 skel/.local/Apps/adminer-standalone/www/adminer/drivers/mongo.inc.php create mode 100644 skel/.local/Apps/adminer-standalone/www/adminer/drivers/mssql.inc.php create mode 100644 skel/.local/Apps/adminer-standalone/www/adminer/drivers/mysql.inc.php create mode 100644 skel/.local/Apps/adminer-standalone/www/adminer/drivers/oracle.inc.php create mode 100644 skel/.local/Apps/adminer-standalone/www/adminer/drivers/pgsql.inc.php create mode 100644 skel/.local/Apps/adminer-standalone/www/adminer/drivers/simpledb.inc.php create mode 100644 skel/.local/Apps/adminer-standalone/www/adminer/drivers/sqlite.inc.php create mode 100644 skel/.local/Apps/adminer-standalone/www/adminer/dump.inc.php create mode 100644 skel/.local/Apps/adminer-standalone/www/adminer/edit.inc.php create mode 100644 skel/.local/Apps/adminer-standalone/www/adminer/event.inc.php create mode 100644 skel/.local/Apps/adminer-standalone/www/adminer/file.inc.php create mode 100644 skel/.local/Apps/adminer-standalone/www/adminer/foreign.inc.php create mode 100644 skel/.local/Apps/adminer-standalone/www/adminer/include/adminer.inc.php create mode 100644 skel/.local/Apps/adminer-standalone/www/adminer/include/auth.inc.php create mode 100644 skel/.local/Apps/adminer-standalone/www/adminer/include/bootstrap.inc.php create mode 100644 skel/.local/Apps/adminer-standalone/www/adminer/include/connect.inc.php create mode 100644 skel/.local/Apps/adminer-standalone/www/adminer/include/coverage.inc.php create mode 100644 skel/.local/Apps/adminer-standalone/www/adminer/include/design.inc.php create mode 100644 skel/.local/Apps/adminer-standalone/www/adminer/include/driver.inc.php create mode 100644 skel/.local/Apps/adminer-standalone/www/adminer/include/editing.inc.php create mode 100644 skel/.local/Apps/adminer-standalone/www/adminer/include/functions.inc.php create mode 100644 skel/.local/Apps/adminer-standalone/www/adminer/include/lang.inc.php create mode 100644 skel/.local/Apps/adminer-standalone/www/adminer/include/pdo.inc.php create mode 100644 skel/.local/Apps/adminer-standalone/www/adminer/include/tmpfile.inc.php create mode 100644 skel/.local/Apps/adminer-standalone/www/adminer/include/version.inc.php create mode 100644 skel/.local/Apps/adminer-standalone/www/adminer/include/xxtea.inc.php create mode 100644 skel/.local/Apps/adminer-standalone/www/adminer/index.php create mode 100644 skel/.local/Apps/adminer-standalone/www/adminer/indexes.inc.php create mode 100644 skel/.local/Apps/adminer-standalone/www/adminer/lang/ar.inc.php create mode 100644 skel/.local/Apps/adminer-standalone/www/adminer/lang/bg.inc.php create mode 100644 skel/.local/Apps/adminer-standalone/www/adminer/lang/bn.inc.php create mode 100644 skel/.local/Apps/adminer-standalone/www/adminer/lang/bs.inc.php create mode 100644 skel/.local/Apps/adminer-standalone/www/adminer/lang/ca.inc.php create mode 100644 skel/.local/Apps/adminer-standalone/www/adminer/lang/cs.inc.php create mode 100644 skel/.local/Apps/adminer-standalone/www/adminer/lang/da.inc.php create mode 100644 skel/.local/Apps/adminer-standalone/www/adminer/lang/de.inc.php create mode 100644 skel/.local/Apps/adminer-standalone/www/adminer/lang/el.inc.php create mode 100644 skel/.local/Apps/adminer-standalone/www/adminer/lang/en.inc.php create mode 100644 skel/.local/Apps/adminer-standalone/www/adminer/lang/es.inc.php create mode 100644 skel/.local/Apps/adminer-standalone/www/adminer/lang/et.inc.php create mode 100644 skel/.local/Apps/adminer-standalone/www/adminer/lang/fa.inc.php create mode 100644 skel/.local/Apps/adminer-standalone/www/adminer/lang/fi.inc.php create mode 100644 skel/.local/Apps/adminer-standalone/www/adminer/lang/fr.inc.php create mode 100644 skel/.local/Apps/adminer-standalone/www/adminer/lang/gl.inc.php create mode 100644 skel/.local/Apps/adminer-standalone/www/adminer/lang/he.inc.php create mode 100644 skel/.local/Apps/adminer-standalone/www/adminer/lang/hu.inc.php create mode 100644 skel/.local/Apps/adminer-standalone/www/adminer/lang/id.inc.php create mode 100644 skel/.local/Apps/adminer-standalone/www/adminer/lang/it.inc.php create mode 100644 skel/.local/Apps/adminer-standalone/www/adminer/lang/ja.inc.php create mode 100644 skel/.local/Apps/adminer-standalone/www/adminer/lang/ka.inc.php create mode 100644 skel/.local/Apps/adminer-standalone/www/adminer/lang/ko.inc.php create mode 100644 skel/.local/Apps/adminer-standalone/www/adminer/lang/lt.inc.php create mode 100644 skel/.local/Apps/adminer-standalone/www/adminer/lang/ms.inc.php create mode 100644 skel/.local/Apps/adminer-standalone/www/adminer/lang/nl.inc.php create mode 100644 skel/.local/Apps/adminer-standalone/www/adminer/lang/no.inc.php create mode 100644 skel/.local/Apps/adminer-standalone/www/adminer/lang/pl.inc.php create mode 100644 skel/.local/Apps/adminer-standalone/www/adminer/lang/pt-br.inc.php create mode 100644 skel/.local/Apps/adminer-standalone/www/adminer/lang/pt.inc.php create mode 100644 skel/.local/Apps/adminer-standalone/www/adminer/lang/ro.inc.php create mode 100644 skel/.local/Apps/adminer-standalone/www/adminer/lang/ru.inc.php create mode 100644 skel/.local/Apps/adminer-standalone/www/adminer/lang/sk.inc.php create mode 100644 skel/.local/Apps/adminer-standalone/www/adminer/lang/sl.inc.php create mode 100644 skel/.local/Apps/adminer-standalone/www/adminer/lang/sr.inc.php create mode 100644 skel/.local/Apps/adminer-standalone/www/adminer/lang/sv.inc.php create mode 100644 skel/.local/Apps/adminer-standalone/www/adminer/lang/ta.inc.php create mode 100644 skel/.local/Apps/adminer-standalone/www/adminer/lang/th.inc.php create mode 100644 skel/.local/Apps/adminer-standalone/www/adminer/lang/tr.inc.php create mode 100644 skel/.local/Apps/adminer-standalone/www/adminer/lang/uk.inc.php create mode 100644 skel/.local/Apps/adminer-standalone/www/adminer/lang/vi.inc.php create mode 100644 skel/.local/Apps/adminer-standalone/www/adminer/lang/xx.inc.php create mode 100644 skel/.local/Apps/adminer-standalone/www/adminer/lang/zh-tw.inc.php create mode 100644 skel/.local/Apps/adminer-standalone/www/adminer/lang/zh.inc.php create mode 100644 skel/.local/Apps/adminer-standalone/www/adminer/plugin.php create mode 100644 skel/.local/Apps/adminer-standalone/www/adminer/privileges.inc.php create mode 100644 skel/.local/Apps/adminer-standalone/www/adminer/procedure.inc.php create mode 100644 skel/.local/Apps/adminer-standalone/www/adminer/processlist.inc.php create mode 100644 skel/.local/Apps/adminer-standalone/www/adminer/schema.inc.php create mode 100644 skel/.local/Apps/adminer-standalone/www/adminer/scheme.inc.php create mode 100644 skel/.local/Apps/adminer-standalone/www/adminer/script.inc.php create mode 100644 skel/.local/Apps/adminer-standalone/www/adminer/select.inc.php create mode 100644 skel/.local/Apps/adminer-standalone/www/adminer/sequence.inc.php create mode 100644 skel/.local/Apps/adminer-standalone/www/adminer/sql.inc.php create mode 100644 skel/.local/Apps/adminer-standalone/www/adminer/sqlite.php create mode 100644 skel/.local/Apps/adminer-standalone/www/adminer/static/arrow.gif create mode 100644 skel/.local/Apps/adminer-standalone/www/adminer/static/cross.gif create mode 100644 skel/.local/Apps/adminer-standalone/www/adminer/static/default.css create mode 100644 skel/.local/Apps/adminer-standalone/www/adminer/static/down.gif create mode 100644 skel/.local/Apps/adminer-standalone/www/adminer/static/editing.js create mode 100644 skel/.local/Apps/adminer-standalone/www/adminer/static/favicon.ico create mode 100644 skel/.local/Apps/adminer-standalone/www/adminer/static/functions.js create mode 100644 skel/.local/Apps/adminer-standalone/www/adminer/static/plus.gif create mode 100644 skel/.local/Apps/adminer-standalone/www/adminer/static/up.gif create mode 100644 skel/.local/Apps/adminer-standalone/www/adminer/table.inc.php create mode 100644 skel/.local/Apps/adminer-standalone/www/adminer/trigger.inc.php create mode 100644 skel/.local/Apps/adminer-standalone/www/adminer/type.inc.php create mode 100644 skel/.local/Apps/adminer-standalone/www/adminer/user.inc.php create mode 100644 skel/.local/Apps/adminer-standalone/www/adminer/variables.inc.php create mode 100644 skel/.local/Apps/adminer-standalone/www/adminer/view.inc.php create mode 100644 skel/.local/Apps/adminer-standalone/www/changes.txt create mode 100755 skel/.local/Apps/adminer-standalone/www/compile.php create mode 100644 skel/.local/Apps/adminer-standalone/www/composer.json create mode 100644 skel/.local/Apps/adminer-standalone/www/coverage.php create mode 100644 skel/.local/Apps/adminer-standalone/www/designs/brade/adminer.css create mode 100644 skel/.local/Apps/adminer-standalone/www/designs/bueltge/adminer.css create mode 100644 skel/.local/Apps/adminer-standalone/www/designs/cvicebni-ubor/adminer.css create mode 100644 skel/.local/Apps/adminer-standalone/www/designs/esterka/adminer.css create mode 100755 skel/.local/Apps/adminer-standalone/www/designs/flat/adminer.css create mode 100644 skel/.local/Apps/adminer-standalone/www/designs/galkaev/adminer.css create mode 100644 skel/.local/Apps/adminer-standalone/www/designs/haeckel/adminer.css create mode 100644 skel/.local/Apps/adminer-standalone/www/designs/hever/adminer.css create mode 100644 skel/.local/Apps/adminer-standalone/www/designs/jukin/adminer.css create mode 100644 skel/.local/Apps/adminer-standalone/www/designs/kahi/adminer.css create mode 100644 skel/.local/Apps/adminer-standalone/www/designs/konya/adminer.css create mode 100644 skel/.local/Apps/adminer-standalone/www/designs/lucas-sandery/adminer.css create mode 100644 skel/.local/Apps/adminer-standalone/www/designs/mancave-hever/adminer.css create mode 100644 skel/.local/Apps/adminer-standalone/www/designs/mancave/adminer.css create mode 100644 skel/.local/Apps/adminer-standalone/www/designs/mvt/adminer.css create mode 100644 skel/.local/Apps/adminer-standalone/www/designs/nette/adminer.css create mode 100644 skel/.local/Apps/adminer-standalone/www/designs/ng9/adminer.css create mode 100644 skel/.local/Apps/adminer-standalone/www/designs/nicu/adminer.css create mode 100644 skel/.local/Apps/adminer-standalone/www/designs/pappu687/adminer.css create mode 100644 skel/.local/Apps/adminer-standalone/www/designs/paranoiq/adminer.css create mode 100644 skel/.local/Apps/adminer-standalone/www/designs/pepa-linha/adminer.css create mode 100644 skel/.local/Apps/adminer-standalone/www/designs/pilot/adminer.css create mode 100644 skel/.local/Apps/adminer-standalone/www/designs/pokorny/adminer.css create mode 100644 skel/.local/Apps/adminer-standalone/www/designs/price/adminer.css create mode 100644 skel/.local/Apps/adminer-standalone/www/designs/readme.txt create mode 100644 skel/.local/Apps/adminer-standalone/www/designs/rmsoft/adminer.css create mode 100644 skel/.local/Apps/adminer-standalone/www/designs/rmsoft_blue/adminer.css create mode 100644 skel/.local/Apps/adminer-standalone/www/editor/db.inc.php create mode 100644 skel/.local/Apps/adminer-standalone/www/editor/example.php create mode 100644 skel/.local/Apps/adminer-standalone/www/editor/include/adminer.inc.php create mode 100644 skel/.local/Apps/adminer-standalone/www/editor/include/connect.inc.php create mode 100644 skel/.local/Apps/adminer-standalone/www/editor/include/editing.inc.php create mode 100644 skel/.local/Apps/adminer-standalone/www/editor/index.php create mode 100644 skel/.local/Apps/adminer-standalone/www/editor/script.inc.php create mode 100644 skel/.local/Apps/adminer-standalone/www/editor/static/editing.js create mode 100644 skel/.local/Apps/adminer-standalone/www/externals/JsShrink/jsShrink.php create mode 100644 skel/.local/Apps/adminer-standalone/www/externals/jush/jush.css create mode 100644 skel/.local/Apps/adminer-standalone/www/externals/jush/modules/jush-cnf.js create mode 100644 skel/.local/Apps/adminer-standalone/www/externals/jush/modules/jush-css.js create mode 100644 skel/.local/Apps/adminer-standalone/www/externals/jush/modules/jush-htm.js create mode 100644 skel/.local/Apps/adminer-standalone/www/externals/jush/modules/jush-http.js create mode 100644 skel/.local/Apps/adminer-standalone/www/externals/jush/modules/jush-js.js create mode 100644 skel/.local/Apps/adminer-standalone/www/externals/jush/modules/jush-mssql.js create mode 100644 skel/.local/Apps/adminer-standalone/www/externals/jush/modules/jush-oracle.js create mode 100644 skel/.local/Apps/adminer-standalone/www/externals/jush/modules/jush-pgsql.js create mode 100644 skel/.local/Apps/adminer-standalone/www/externals/jush/modules/jush-php.js create mode 100644 skel/.local/Apps/adminer-standalone/www/externals/jush/modules/jush-simpledb.js create mode 100644 skel/.local/Apps/adminer-standalone/www/externals/jush/modules/jush-sql.js create mode 100644 skel/.local/Apps/adminer-standalone/www/externals/jush/modules/jush-sqlite.js create mode 100644 skel/.local/Apps/adminer-standalone/www/externals/jush/modules/jush-textarea.js create mode 100644 skel/.local/Apps/adminer-standalone/www/externals/jush/modules/jush-txt.js create mode 100644 skel/.local/Apps/adminer-standalone/www/externals/jush/modules/jush.js create mode 100644 skel/.local/Apps/adminer-standalone/www/index.php create mode 100755 skel/.local/Apps/adminer-standalone/www/lang.php create mode 100644 skel/.local/Apps/adminer-standalone/www/plugins/database-hide.php create mode 100644 skel/.local/Apps/adminer-standalone/www/plugins/designs.php create mode 100644 skel/.local/Apps/adminer-standalone/www/plugins/dump-alter.php create mode 100644 skel/.local/Apps/adminer-standalone/www/plugins/dump-bz2.php create mode 100644 skel/.local/Apps/adminer-standalone/www/plugins/dump-date.php create mode 100644 skel/.local/Apps/adminer-standalone/www/plugins/dump-json.php create mode 100644 skel/.local/Apps/adminer-standalone/www/plugins/dump-php.php create mode 100644 skel/.local/Apps/adminer-standalone/www/plugins/dump-xml.php create mode 100644 skel/.local/Apps/adminer-standalone/www/plugins/dump-zip.php create mode 100644 skel/.local/Apps/adminer-standalone/www/plugins/edit-calendar.php create mode 100644 skel/.local/Apps/adminer-standalone/www/plugins/edit-foreign.php create mode 100644 skel/.local/Apps/adminer-standalone/www/plugins/edit-textarea.php create mode 100644 skel/.local/Apps/adminer-standalone/www/plugins/email-table.php create mode 100644 skel/.local/Apps/adminer-standalone/www/plugins/enum-option.php create mode 100644 skel/.local/Apps/adminer-standalone/www/plugins/enum-types.php create mode 100644 skel/.local/Apps/adminer-standalone/www/plugins/fc-sqlite-connection-without-credentials.php create mode 100644 skel/.local/Apps/adminer-standalone/www/plugins/file-upload.php create mode 100644 skel/.local/Apps/adminer-standalone/www/plugins/foreign-system.php create mode 100644 skel/.local/Apps/adminer-standalone/www/plugins/frames.php create mode 100644 skel/.local/Apps/adminer-standalone/www/plugins/json-column.php create mode 100644 skel/.local/Apps/adminer-standalone/www/plugins/login-ip.php create mode 100644 skel/.local/Apps/adminer-standalone/www/plugins/login-otp.php create mode 100644 skel/.local/Apps/adminer-standalone/www/plugins/login-password-less.php create mode 100644 skel/.local/Apps/adminer-standalone/www/plugins/login-servers.php create mode 100644 skel/.local/Apps/adminer-standalone/www/plugins/login-ssl.php create mode 100644 skel/.local/Apps/adminer-standalone/www/plugins/login-table.php create mode 100644 skel/.local/Apps/adminer-standalone/www/plugins/master-slave.php create mode 100644 skel/.local/Apps/adminer-standalone/www/plugins/plugin.php create mode 100644 skel/.local/Apps/adminer-standalone/www/plugins/pretty-json-column.php create mode 100644 skel/.local/Apps/adminer-standalone/www/plugins/readme.txt create mode 100644 skel/.local/Apps/adminer-standalone/www/plugins/slugify.php create mode 100644 skel/.local/Apps/adminer-standalone/www/plugins/sql-log.php create mode 100644 skel/.local/Apps/adminer-standalone/www/plugins/struct-comments.php create mode 100644 skel/.local/Apps/adminer-standalone/www/plugins/table-indexes-structure.php create mode 100644 skel/.local/Apps/adminer-standalone/www/plugins/table-structure.php create mode 100644 skel/.local/Apps/adminer-standalone/www/plugins/tables-filter.php create mode 100644 skel/.local/Apps/adminer-standalone/www/plugins/tinymce.php create mode 100644 skel/.local/Apps/adminer-standalone/www/plugins/translation.php create mode 100644 skel/.local/Apps/adminer-standalone/www/plugins/version-noverify.php create mode 100644 skel/.local/Apps/adminer-standalone/www/plugins/wymeditor.php create mode 100644 skel/.local/Apps/adminer-standalone/www/readme.txt create mode 100644 skel/.local/Apps/adminer-standalone/www/tests/katalon.html create mode 100644 skel/.local/Apps/adminer-standalone/www/todo.txt create mode 100644 skel/.local/Apps/installer-scripts/README.md create mode 100755 skel/.local/Apps/installer-scripts/bin/installer-script.sh create mode 100644 skel/.local/Apps/installer-scripts/binaries.lst create mode 100755 skel/.local/Apps/installer-scripts/gen-installer.sh create mode 100755 skel/.local/Apps/installer-scripts/installer.sh create mode 100644 skel/.local/Apps/installer-scripts/lib/installer_common create mode 100644 skel/.local/Apps/installer-scripts/packages/_generic create mode 100755 skel/.local/Apps/installer-scripts/packages/ffmpeg create mode 100755 skel/.local/Apps/installer-scripts/packages/iojs create mode 100755 skel/.local/Apps/installer-scripts/packages/nodejs create mode 100755 skel/.local/Apps/installer-scripts/packages/self create mode 120000 skel/.local/bin/adminer.sh create mode 120000 skel/.local/bin/installer-script.sh create mode 100755 skel/.local/bin/nv diff --git a/skel/.bashrc b/skel/.bashrc new file mode 100644 index 0000000..8841db4 --- /dev/null +++ b/skel/.bashrc @@ -0,0 +1,17 @@ +# Sample .bashrc for SUSE Linux +# Copyright (c) SUSE Software Solutions Germany GmbH + +# There are 3 different types of shells in bash: the login shell, normal shell +# and interactive shell. Login shells read ~/.profile and interactive shells +# read ~/.bashrc; in our setup, /etc/profile sources ~/.bashrc - thus all +# settings made here will also take effect in a login shell. +# +# NOTE: It is recommended to make language settings in ~/.profile rather than +# here, since multilingual X sessions would not work properly if LANG is over- +# ridden in every subshell. + +test -s ~/.alias && . ~/.alias || true + +PS1='${debian_chroot:+($debian_chroot)}\[\033[01;33m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ ' +export PATH="$HOME/.local/bin:$PATH" +export PATH="$HOME/node_modules/.bin:$PATH" diff --git a/skel/.config/alacritty/alacritty.yml b/skel/.config/alacritty/alacritty.yml new file mode 120000 index 0000000..bdb0a03 --- /dev/null +++ b/skel/.config/alacritty/alacritty.yml @@ -0,0 +1 @@ +../../../home/.config/alacritty/alacritty.yml \ No newline at end of file diff --git a/skel/.config/kglobalshortcutsrc b/skel/.config/kglobalshortcutsrc new file mode 100644 index 0000000..5390af9 --- /dev/null +++ b/skel/.config/kglobalshortcutsrc @@ -0,0 +1,285 @@ +[ActivityManager] +_k_friendly_name=Activity Manager +switch-to-activity-13992ea8-857b-45ec-9ffa-cb3873fc076f=none,none,Switch to activity "Default" +switch-to-activity-1de2555c-8dce-4b05-9048-0576a7cc6b7a=none,none,Switch to activity "Default" +switch-to-activity-bc57e82d-c204-4427-bde4-83de8bd4d0d6=none,none,Switch to activity "Default" + +[KDE Keyboard Layout Switcher] +Switch keyboard layout to English (US)=none,none,Switch keyboard layout to English (US) +Switch to Next Keyboard Layout=Ctrl+Alt+K,Ctrl+Alt+K,Switch to Next Keyboard Layout +_k_friendly_name=System Settings + +[kaccess] +Toggle Screen Reader On and Off=Meta+Alt+S,Meta+Alt+S,Toggle Screen Reader On and Off +_k_friendly_name=Accessibility + +[kcm_touchpad] +Disable Touchpad=Touchpad Off,Touchpad Off,Disable Touchpad +Enable Touchpad=Touchpad On,Touchpad On,Enable Touchpad +Toggle Touchpad=Touchpad Toggle,Touchpad Toggle,Toggle Touchpad +_k_friendly_name=System Settings + +[kded5] +Show System Activity=Ctrl+Esc,Ctrl+Esc,Show System Activity +_k_friendly_name=KDE Daemon +display=Display\tMeta+P,Display\tMeta+P,Switch Display + +[khotkeys] +_k_friendly_name=System Settings +{9fe79beb-041f-4099-a70f-68aef7e73b83}=Ctrl+Alt+T,none,Launch Konsole +{d03619b6-9b3c-48cc-9d9c-a2aadb485550}=,none,Search + +[kmix] +_k_friendly_name=Audio Volume +decrease_microphone_volume=Microphone Volume Down,Microphone Volume Down,Decrease Microphone Volume +decrease_volume=Volume Down,Volume Down,Decrease Volume +increase_microphone_volume=Microphone Volume Up,Microphone Volume Up,Increase Microphone Volume +increase_volume=Volume Up,Volume Up,Increase Volume +mic_mute=Microphone Mute,Microphone Mute,Mute Microphone +mute=Volume Mute,Volume Mute,Mute + +[krunner.desktop] +RunClipboard=Alt+Shift+F2,Alt+Shift+F2,Run command on clipboard contents +_k_friendly_name=KRunner +_launch=Ctrl+Space\tAlt+F2\tSearch,none,KRunner + +[ksmserver] +Halt Without Confirmation=Ctrl+Alt+Shift+PgDown,none,Halt Without Confirmation +Lock Session=Ctrl+Alt+L\tScreensaver,Meta+L\tCtrl+Alt+L\tScreensaver,Lock Session +Log Out=Ctrl+Alt+Del,none,Log Out +Log Out Without Confirmation=Ctrl+Alt+Shift+Del,none,Log Out Without Confirmation +Reboot Without Confirmation=Ctrl+Alt+Shift+PgUp,none,Reboot Without Confirmation +_k_friendly_name=ksmserver + +[kwin] +Activate Window Demanding Attention=Ctrl+Alt+A,Ctrl+Alt+A,Activate Window Demanding Attention +ClearLastMouseMark=Meta+Shift+F12,Meta+Shift+F12,Clear Last Mouse Mark +ClearMouseMarks=Meta+Shift+F11,Meta+Shift+F11,Clear All Mouse Marks +Decrease Opacity=none,none,Decrease Opacity of Active Window by 5 % +Expose=Ctrl+F9,Ctrl+F9,Toggle Present Windows (Current desktop) +ExposeAll=Ctrl+F10\tLaunch (C),Ctrl+F10\tLaunch (C),Toggle Present Windows (All desktops) +ExposeClass=Ctrl+F7,Ctrl+F7,Toggle Present Windows (Window class) +Increase Opacity=none,none,Increase Opacity of Active Window by 5 % +Invert Screen Colors=none,none,Invert Screen Colors +Kill Window=Ctrl+Alt+Esc,Ctrl+Alt+Esc,Kill Window +MoveMouseToCenter=Meta+F6,Meta+F6,Move Mouse to Center +MoveMouseToFocus=Meta+F5,Meta+F5,Move Mouse to Focus +MoveZoomDown=none,none,Move Zoomed Area Downwards +MoveZoomLeft=none,none,Move Zoomed Area to Left +MoveZoomRight=none,none,Move Zoomed Area to Right +MoveZoomUp=none,none,Move Zoomed Area Upwards +Remove Window From Group=none,none,Remove Window From Group +Setup Window Shortcut=none,none,Setup Window Shortcut +Show Desktop=none,Meta+D,Show Desktop +ShowDesktopGrid=Ctrl+F8,Ctrl+F8,Show Desktop Grid +Suspend Compositing=Alt+Shift+F12,Alt+Shift+F12,Suspend Compositing +Switch One Desktop Down=Ctrl+Alt+Down,Meta+Ctrl+Down,Switch One Desktop Down +Switch One Desktop Up=Ctrl+Alt+Up,Meta+Ctrl+Up,Switch One Desktop Up +Switch One Desktop to the Left=Ctrl+Alt+Left,Meta+Ctrl+Left,Switch One Desktop to the Left +Switch One Desktop to the Right=Ctrl+Alt+Right,Meta+Ctrl+Right,Switch One Desktop to the Right +Switch Window Down=Meta+Alt+Down,Meta+Alt+Down,Switch to Window Below +Switch Window Left=Meta+Alt+Left,Meta+Alt+Left,Switch to Window to the Left +Switch Window Right=Meta+Alt+Right,Meta+Alt+Right,Switch to Window to the Right +Switch Window Up=Meta+Alt+Up,Meta+Alt+Up,Switch to Window Above +Switch to Desktop 1=Ctrl+F1,Ctrl+F1,Switch to Desktop 1 +Switch to Desktop 10=none,none,Switch to Desktop 10 +Switch to Desktop 11=none,none,Switch to Desktop 11 +Switch to Desktop 12=none,none,Switch to Desktop 12 +Switch to Desktop 13=none,none,Switch to Desktop 13 +Switch to Desktop 14=none,none,Switch to Desktop 14 +Switch to Desktop 15=none,none,Switch to Desktop 15 +Switch to Desktop 16=none,none,Switch to Desktop 16 +Switch to Desktop 17=none,none,Switch to Desktop 17 +Switch to Desktop 18=none,none,Switch to Desktop 18 +Switch to Desktop 19=none,none,Switch to Desktop 19 +Switch to Desktop 2=Ctrl+F2,Ctrl+F2,Switch to Desktop 2 +Switch to Desktop 20=none,none,Switch to Desktop 20 +Switch to Desktop 3=Ctrl+F3,Ctrl+F3,Switch to Desktop 3 +Switch to Desktop 4=Ctrl+F4,Ctrl+F4,Switch to Desktop 4 +Switch to Desktop 5=none,none,Switch to Desktop 5 +Switch to Desktop 6=none,none,Switch to Desktop 6 +Switch to Desktop 7=none,none,Switch to Desktop 7 +Switch to Desktop 8=none,none,Switch to Desktop 8 +Switch to Desktop 9=none,none,Switch to Desktop 9 +Switch to Next Desktop=none,none,Switch to Next Desktop +Switch to Next Screen=none,none,Switch to Next Screen +Switch to Previous Desktop=none,none,Switch to Previous Desktop +Switch to Previous Screen=none,none,Switch to Previous Screen +Switch to Screen 0=none,none,Switch to Screen 0 +Switch to Screen 1=none,none,Switch to Screen 1 +Switch to Screen 2=none,none,Switch to Screen 2 +Switch to Screen 3=none,none,Switch to Screen 3 +Switch to Screen 4=none,none,Switch to Screen 4 +Switch to Screen 5=none,none,Switch to Screen 5 +Switch to Screen 6=none,none,Switch to Screen 6 +Switch to Screen 7=none,none,Switch to Screen 7 +Toggle Night Color=none,none,Toggle Night Color +Toggle Window Raise/Lower=none,none,Toggle Window Raise/Lower +ToggleMouseClick=Meta+*,Meta+*,Toggle Mouse Click Effect +Walk Through Desktop List=none,none,Walk Through Desktop List +Walk Through Desktop List (Reverse)=none,none,Walk Through Desktop List (Reverse) +Walk Through Desktops=none,none,Walk Through Desktops +Walk Through Desktops (Reverse)=none,none,Walk Through Desktops (Reverse) +Walk Through Window Tabs=none,none,Walk Through Window Tabs +Walk Through Window Tabs (Reverse)=none,none,Walk Through Window Tabs (Reverse) +Walk Through Windows=Alt+Tab,Alt+Tab,Walk Through Windows +Walk Through Windows (Reverse)=Alt+Shift+Backtab,Alt+Shift+Backtab,Walk Through Windows (Reverse) +Walk Through Windows Alternative=none,none,Walk Through Windows Alternative +Walk Through Windows Alternative (Reverse)=none,none,Walk Through Windows Alternative (Reverse) +Walk Through Windows of Current Application=Alt+`,Alt+`,Walk Through Windows of Current Application +Walk Through Windows of Current Application (Reverse)=Alt+~,Alt+~,Walk Through Windows of Current Application (Reverse) +Walk Through Windows of Current Application Alternative=none,none,Walk Through Windows of Current Application Alternative +Walk Through Windows of Current Application Alternative (Reverse)=none,none,Walk Through Windows of Current Application Alternative (Reverse) +Window Above Other Windows=none,none,Keep Window Above Others +Window Below Other Windows=none,none,Keep Window Below Others +Window Close=Alt+F4,Alt+F4,Close Window +Window Fullscreen=none,none,Make Window Fullscreen +Window Grow Horizontal=none,none,Pack Grow Window Horizontally +Window Grow Vertical=none,none,Pack Grow Window Vertically +Window Lower=none,none,Lower Window +Window Maximize=Meta+PgUp,Meta+PgUp,Maximize Window +Window Maximize Horizontal=none,none,Maximize Window Horizontally +Window Maximize Vertical=none,none,Maximize Window Vertically +Window Minimize=Meta+PgDown,Meta+PgDown,Minimize Window +Window Move=none,none,Move Window +Window No Border=none,none,Hide Window Border +Window On All Desktops=none,none,Keep Window on All Desktops +Window One Desktop Down=Ctrl+Alt+Shift+Down,none,Window One Desktop Down +Window One Desktop Up=Ctrl+Alt+Shift+Up,none,Window One Desktop Up +Window One Desktop to the Left=Ctrl+Alt+Shift+Left,none,Window One Desktop to the Left +Window One Desktop to the Right=Ctrl+Alt+Shift+Right,none,Window One Desktop to the Right +Window Operations Menu=Alt+F3,Alt+F3,Window Operations Menu +Window Pack Down=none,none,Pack Window Down +Window Pack Left=none,none,Pack Window to the Left +Window Pack Right=none,none,Pack Window to the Right +Window Pack Up=none,none,Pack Window Up +Window Quick Tile Bottom=Meta+Down,Meta+Down,Quick Tile Window to the Bottom +Window Quick Tile Bottom Left=none,none,Quick Tile Window to the Bottom Left +Window Quick Tile Bottom Right=none,none,Quick Tile Window to the Bottom Right +Window Quick Tile Left=Meta+Left,Meta+Left,Quick Tile Window to the Left +Window Quick Tile Right=Meta+Right,Meta+Right,Quick Tile Window to the Right +Window Quick Tile Top=Meta+Up,Meta+Up,Quick Tile Window to the Top +Window Quick Tile Top Left=none,none,Quick Tile Window to the Top Left +Window Quick Tile Top Right=none,none,Quick Tile Window to the Top Right +Window Raise=none,none,Raise Window +Window Resize=none,none,Resize Window +Window Shade=none,none,Shade Window +Window Shrink Horizontal=none,none,Pack Shrink Window Horizontally +Window Shrink Vertical=none,none,Pack Shrink Window Vertically +Window to Desktop 1=none,none,Window to Desktop 1 +Window to Desktop 10=none,none,Window to Desktop 10 +Window to Desktop 11=none,none,Window to Desktop 11 +Window to Desktop 12=none,none,Window to Desktop 12 +Window to Desktop 13=none,none,Window to Desktop 13 +Window to Desktop 14=none,none,Window to Desktop 14 +Window to Desktop 15=none,none,Window to Desktop 15 +Window to Desktop 16=none,none,Window to Desktop 16 +Window to Desktop 17=none,none,Window to Desktop 17 +Window to Desktop 18=none,none,Window to Desktop 18 +Window to Desktop 19=none,none,Window to Desktop 19 +Window to Desktop 2=none,none,Window to Desktop 2 +Window to Desktop 20=none,none,Window to Desktop 20 +Window to Desktop 3=none,none,Window to Desktop 3 +Window to Desktop 4=none,none,Window to Desktop 4 +Window to Desktop 5=none,none,Window to Desktop 5 +Window to Desktop 6=none,none,Window to Desktop 6 +Window to Desktop 7=none,none,Window to Desktop 7 +Window to Desktop 8=none,none,Window to Desktop 8 +Window to Desktop 9=none,none,Window to Desktop 9 +Window to Next Desktop=none,none,Window to Next Desktop +Window to Next Screen=Meta+Ctrl+Shift+Right,none,Window to Next Screen +Window to Previous Desktop=none,none,Window to Previous Desktop +Window to Previous Screen=Meta+Ctrl+Shift+Left,none,Window to Previous Screen +Window to Screen 0=none,none,Window to Screen 0 +Window to Screen 1=none,none,Window to Screen 1 +Window to Screen 2=none,none,Window to Screen 2 +Window to Screen 3=none,none,Window to Screen 3 +Window to Screen 4=none,none,Window to Screen 4 +Window to Screen 5=none,none,Window to Screen 5 +Window to Screen 6=none,none,Window to Screen 6 +Window to Screen 7=none,none,Window to Screen 7 +_k_friendly_name=KWin +view_actual_size=,Meta+0,Actual Size +view_zoom_in=Meta+=,Meta+=,Zoom In +view_zoom_out=Meta+-,Meta+-,Zoom Out + +[mediacontrol] +_k_friendly_name=Media Controller +mediavolumedown=none,none,Media volume down +mediavolumeup=none,none,Media volume up +nextmedia=Media Next,Media Next,Media playback next +playpausemedia=Media Play,Media Play,Play/Pause media playback +previousmedia=Media Previous,Media Previous,Media playback previous +stopmedia=Media Stop,Media Stop,Stop media playback + +[org.gnome.Terminal.desktop] +_k_friendly_name=Launch Terminal +_launch=none,none,Launch Terminal +new-window=none,none,New Window +preferences=,none,Preferences + +[org.kde.dolphin.desktop] +_k_friendly_name=Dolphin +_launch=Meta+E,Meta+E,Dolphin + +[org.kde.spectacle.desktop] +ActiveWindowScreenShot=Meta+Print,Meta+Print,Capture Active Window +CurrentMonitorScreenShot=,none,Capture Current Monitor +FullScreenScreenShot=Shift+Print,Shift+Print,Capture Entire Desktop +RectangularRegionScreenShot=Meta+Shift+Print,Meta+Shift+Print,Capture Rectangular Region +_k_friendly_name=Spectacle +_launch=Print,Print,Launch Spectacle + +[org_kde_powerdevil] +Decrease Keyboard Brightness=Keyboard Brightness Down,Keyboard Brightness Down,Decrease Keyboard Brightness +Decrease Screen Brightness=Monitor Brightness Down,Monitor Brightness Down,Decrease Screen Brightness +Hibernate=Hibernate,Hibernate,Hibernate +Increase Keyboard Brightness=Keyboard Brightness Up,Keyboard Brightness Up,Increase Keyboard Brightness +Increase Screen Brightness=Monitor Brightness Up,Monitor Brightness Up,Increase Screen Brightness +PowerOff=Power Off,Power Off,Power Off +Sleep=Sleep,Sleep,Suspend +Toggle Keyboard Backlight=Keyboard Light On/Off,Keyboard Light On/Off,Toggle Keyboard Backlight +Turn Off Screen=none,none,Turn Off Screen +_k_friendly_name=Power Management + +[plasmashell] +_k_friendly_name=Plasma +activate task manager entry 1=Meta+1,Meta+1,Activate Task Manager Entry 1 +activate task manager entry 10=Meta+0,Meta+0,Activate Task Manager Entry 10 +activate task manager entry 2=Meta+2,Meta+2,Activate Task Manager Entry 2 +activate task manager entry 3=Meta+3,Meta+3,Activate Task Manager Entry 3 +activate task manager entry 4=Meta+4,Meta+4,Activate Task Manager Entry 4 +activate task manager entry 5=Meta+5,Meta+5,Activate Task Manager Entry 5 +activate task manager entry 6=Meta+6,Meta+6,Activate Task Manager Entry 6 +activate task manager entry 7=Meta+7,Meta+7,Activate Task Manager Entry 7 +activate task manager entry 8=Meta+8,Meta+8,Activate Task Manager Entry 8 +activate task manager entry 9=Meta+9,Meta+9,Activate Task Manager Entry 9 +activate widget 24=none,none,Activate Application Launcher Widget +activate widget 3=Alt+F1,none,Activate Application Launcher Widget +clear-history=none,none,Clear Clipboard History +clipboard_action=Ctrl+Alt+X,Ctrl+Alt+X,Enable Clipboard Actions +cycleNextAction=none,none,Next History Item +cyclePrevAction=none,none,Previous History Item +edit_clipboard=none,none,Edit Contents... +manage activities=Meta+Q,Meta+Q,Activities... +next activity=Meta+Tab,none,Walk through activities +previous activity=Meta+Shift+Tab,none,Walk through activities (Reverse) +repeat_action=Ctrl+Alt+R,Ctrl+Alt+R,Manually Invoke Action on Current Clipboard +show dashboard=Ctrl+F12,Ctrl+F12,Show Desktop +show-barcode=none,none,Show Barcode... +show-on-mouse-pos=none,none,Open Klipper at Mouse Position +stop current activity=Meta+S,Meta+S,Stop Current Activity +switch to next activity=none,none,Switch to Next Activity +switch to previous activity=none,none,Switch to Previous Activity +toggle do not disturb=none,none,Toggle do not disturb + +[wacomtablet] +Map to fullscreen=Meta+Ctrl+F,Meta+Ctrl+F,Map to fullscreen +Map to screen 1=Meta+Ctrl+1,Meta+Ctrl+1,Map to screen 1 +Map to screen 2=Meta+Ctrl+2,Meta+Ctrl+2,Map to screen 2 +Next Profile=Meta+Ctrl+N,Meta+Ctrl+N,Next profile +Previous Profile=Meta+Ctrl+P,Meta+Ctrl+P,Previous Profile +Toggle screen map selection=Meta+Ctrl+M,Meta+Ctrl+M,Toggle between all screens +Toggle stylus mode=Meta+Ctrl+S,Meta+Ctrl+S,Toggle the Stylus Tool Relative/Absolute +Toggle touch tool=Meta+Ctrl+T,Meta+Ctrl+T,Enable/Disable the Touch Tool +_k_friendly_name=Wacom Tablet diff --git a/skel/.config/khotkeysrc b/skel/.config/khotkeysrc new file mode 100644 index 0000000..e28f874 --- /dev/null +++ b/skel/.config/khotkeysrc @@ -0,0 +1,940 @@ +[$Version] +update_info=spectacle_shortcuts.upd:spectacle-migrate-shortcuts + +[Data] +DataCount=3 + +[Data_1] +Comment=KMenuEdit Global Shortcuts +DataCount=2 +Enabled=true +Name=KMenuEdit +SystemGroup=1 +Type=ACTION_DATA_GROUP + +[Data_1Conditions] +Comment= +ConditionsCount=0 + +[Data_1_1] +Comment=Comment +Enabled=true +Name=Search +Type=SIMPLE_ACTION_DATA + +[Data_1_1Actions] +ActionsCount=1 + +[Data_1_1Actions0] +CommandURL=http://google.com +Type=COMMAND_URL + +[Data_1_1Conditions] +Comment= +ConditionsCount=0 + +[Data_1_1Triggers] +Comment=Simple_action +TriggersCount=1 + +[Data_1_1Triggers0] +Key= +Type=SHORTCUT +Uuid={d03619b6-9b3c-48cc-9d9c-a2aadb485550} + +[Data_1_2] +Comment=Global keyboard shortcut to launch Konsole +Enabled=true +Name=Launch Konsole +Type=MENUENTRY_SHORTCUT_ACTION_DATA + +[Data_1_2Actions] +ActionsCount=1 + +[Data_1_2Actions0] +CommandURL=org.kde.konsole.desktop +Type=MENUENTRY + +[Data_1_2Conditions] +Comment= +ConditionsCount=0 + +[Data_1_2Triggers] +Comment=Simple_action +TriggersCount=1 + +[Data_1_2Triggers0] +Key=Ctrl+Alt+T +Type=SHORTCUT +Uuid={9fe79beb-041f-4099-a70f-68aef7e73b83} + +[Data_2] +Comment=Basic Konqueror gestures. +DataCount=14 +Enabled=true +ImportId=konqueror_gestures_kde321 +Name=Konqueror Gestures +SystemGroup=0 +Type=ACTION_DATA_GROUP + +[Data_2Conditions] +Comment=Konqueror window +ConditionsCount=1 + +[Data_2Conditions0] +Type=ACTIVE_WINDOW + +[Data_2Conditions0Window] +Comment=Konqueror +WindowsCount=1 + +[Data_2Conditions0Window0] +Class=^konqueror\s +ClassType=3 +Comment=Konqueror +Role=konqueror-mainwindow#1 +RoleType=0 +Title=file:/ - Konqueror +TitleType=0 +Type=SIMPLE +WindowTypes=1 + +[Data_2_1] +Comment=Press, move left, release. +Enabled=true +Name=Back +Type=SIMPLE_ACTION_DATA + +[Data_2_10] +Comment=Opera-style: Press, move up, release.\nNOTE: Conflicts with 'New Tab', and as such is disabled by default. +Enabled=false +Name=Stop Loading +Type=SIMPLE_ACTION_DATA + +[Data_2_10Actions] +ActionsCount=1 + +[Data_2_10Actions0] +DestinationWindow=2 +Input=Escape\n +Type=KEYBOARD_INPUT + +[Data_2_10Conditions] +Comment= +ConditionsCount=0 + +[Data_2_10Triggers] +Comment=Gesture_triggers +TriggersCount=1 + +[Data_2_10Triggers0] +GesturePointData=0,0.125,-0.5,0.5,1,0.125,0.125,-0.5,0.5,0.875,0.25,0.125,-0.5,0.5,0.75,0.375,0.125,-0.5,0.5,0.625,0.5,0.125,-0.5,0.5,0.5,0.625,0.125,-0.5,0.5,0.375,0.75,0.125,-0.5,0.5,0.25,0.875,0.125,-0.5,0.5,0.125,1,0,0,0.5,0 +Type=GESTURE + +[Data_2_11] +Comment=Going up in URL/directory structure.\nMozilla-style: Press, move up, move left, move up, release. +Enabled=true +Name=Up +Type=SIMPLE_ACTION_DATA + +[Data_2_11Actions] +ActionsCount=1 + +[Data_2_11Actions0] +DestinationWindow=2 +Input=Alt+Up +Type=KEYBOARD_INPUT + +[Data_2_11Conditions] +Comment= +ConditionsCount=0 + +[Data_2_11Triggers] +Comment=Gesture_triggers +TriggersCount=1 + +[Data_2_11Triggers0] +GesturePointData=0,0.0625,-0.5,1,1,0.0625,0.0625,-0.5,1,0.875,0.125,0.0625,-0.5,1,0.75,0.1875,0.0625,-0.5,1,0.625,0.25,0.0625,1,1,0.5,0.3125,0.0625,1,0.875,0.5,0.375,0.0625,1,0.75,0.5,0.4375,0.0625,1,0.625,0.5,0.5,0.0625,1,0.5,0.5,0.5625,0.0625,1,0.375,0.5,0.625,0.0625,1,0.25,0.5,0.6875,0.0625,1,0.125,0.5,0.75,0.0625,-0.5,0,0.5,0.8125,0.0625,-0.5,0,0.375,0.875,0.0625,-0.5,0,0.25,0.9375,0.0625,-0.5,0,0.125,1,0,0,0,0 +Type=GESTURE + +[Data_2_12] +Comment=Going up in URL/directory structure.\nOpera-style: Press, move up, move left, move up, release.\nNOTE: Conflicts with "Activate Previous Tab", and as such is disabled by default. +Enabled=false +Name=Up #2 +Type=SIMPLE_ACTION_DATA + +[Data_2_12Actions] +ActionsCount=1 + +[Data_2_12Actions0] +DestinationWindow=2 +Input=Alt+Up\n +Type=KEYBOARD_INPUT + +[Data_2_12Conditions] +Comment= +ConditionsCount=0 + +[Data_2_12Triggers] +Comment=Gesture_triggers +TriggersCount=1 + +[Data_2_12Triggers0] +GesturePointData=0,0.0625,-0.5,1,1,0.0625,0.0625,-0.5,1,0.875,0.125,0.0625,-0.5,1,0.75,0.1875,0.0625,-0.5,1,0.625,0.25,0.0625,-0.5,1,0.5,0.3125,0.0625,-0.5,1,0.375,0.375,0.0625,-0.5,1,0.25,0.4375,0.0625,-0.5,1,0.125,0.5,0.0625,1,1,0,0.5625,0.0625,1,0.875,0,0.625,0.0625,1,0.75,0,0.6875,0.0625,1,0.625,0,0.75,0.0625,1,0.5,0,0.8125,0.0625,1,0.375,0,0.875,0.0625,1,0.25,0,0.9375,0.0625,1,0.125,0,1,0,0,0,0 +Type=GESTURE + +[Data_2_13] +Comment=Press, move up, move right, release. +Enabled=true +Name=Activate Next Tab +Type=SIMPLE_ACTION_DATA + +[Data_2_13Actions] +ActionsCount=1 + +[Data_2_13Actions0] +DestinationWindow=2 +Input=Ctrl+.\n +Type=KEYBOARD_INPUT + +[Data_2_13Conditions] +Comment= +ConditionsCount=0 + +[Data_2_13Triggers] +Comment=Gesture_triggers +TriggersCount=1 + +[Data_2_13Triggers0] +GesturePointData=0,0.0625,-0.5,0,1,0.0625,0.0625,-0.5,0,0.875,0.125,0.0625,-0.5,0,0.75,0.1875,0.0625,-0.5,0,0.625,0.25,0.0625,-0.5,0,0.5,0.3125,0.0625,-0.5,0,0.375,0.375,0.0625,-0.5,0,0.25,0.4375,0.0625,-0.5,0,0.125,0.5,0.0625,0,0,0,0.5625,0.0625,0,0.125,0,0.625,0.0625,0,0.25,0,0.6875,0.0625,0,0.375,0,0.75,0.0625,0,0.5,0,0.8125,0.0625,0,0.625,0,0.875,0.0625,0,0.75,0,0.9375,0.0625,0,0.875,0,1,0,0,1,0 +Type=GESTURE + +[Data_2_14] +Comment=Press, move up, move left, release. +Enabled=true +Name=Activate Previous Tab +Type=SIMPLE_ACTION_DATA + +[Data_2_14Actions] +ActionsCount=1 + +[Data_2_14Actions0] +DestinationWindow=2 +Input=Ctrl+, +Type=KEYBOARD_INPUT + +[Data_2_14Conditions] +Comment= +ConditionsCount=0 + +[Data_2_14Triggers] +Comment=Gesture_triggers +TriggersCount=1 + +[Data_2_14Triggers0] +GesturePointData=0,0.0625,-0.5,1,1,0.0625,0.0625,-0.5,1,0.875,0.125,0.0625,-0.5,1,0.75,0.1875,0.0625,-0.5,1,0.625,0.25,0.0625,-0.5,1,0.5,0.3125,0.0625,-0.5,1,0.375,0.375,0.0625,-0.5,1,0.25,0.4375,0.0625,-0.5,1,0.125,0.5,0.0625,1,1,0,0.5625,0.0625,1,0.875,0,0.625,0.0625,1,0.75,0,0.6875,0.0625,1,0.625,0,0.75,0.0625,1,0.5,0,0.8125,0.0625,1,0.375,0,0.875,0.0625,1,0.25,0,0.9375,0.0625,1,0.125,0,1,0,0,0,0 +Type=GESTURE + +[Data_2_1Actions] +ActionsCount=1 + +[Data_2_1Actions0] +DestinationWindow=2 +Input=Alt+Left +Type=KEYBOARD_INPUT + +[Data_2_1Conditions] +Comment= +ConditionsCount=0 + +[Data_2_1Triggers] +Comment=Gesture_triggers +TriggersCount=1 + +[Data_2_1Triggers0] +GesturePointData=0,0.125,1,1,0.5,0.125,0.125,1,0.875,0.5,0.25,0.125,1,0.75,0.5,0.375,0.125,1,0.625,0.5,0.5,0.125,1,0.5,0.5,0.625,0.125,1,0.375,0.5,0.75,0.125,1,0.25,0.5,0.875,0.125,1,0.125,0.5,1,0,0,0,0.5 +Type=GESTURE + +[Data_2_2] +Comment=Press, move down, move up, move down, release. +Enabled=true +Name=Duplicate Tab +Type=SIMPLE_ACTION_DATA + +[Data_2_2Actions] +ActionsCount=1 + +[Data_2_2Actions0] +DestinationWindow=2 +Input=Ctrl+Shift+D\n +Type=KEYBOARD_INPUT + +[Data_2_2Conditions] +Comment= +ConditionsCount=0 + +[Data_2_2Triggers] +Comment=Gesture_triggers +TriggersCount=1 + +[Data_2_2Triggers0] +GesturePointData=0,0.0416667,0.5,0.5,0,0.0416667,0.0416667,0.5,0.5,0.125,0.0833333,0.0416667,0.5,0.5,0.25,0.125,0.0416667,0.5,0.5,0.375,0.166667,0.0416667,0.5,0.5,0.5,0.208333,0.0416667,0.5,0.5,0.625,0.25,0.0416667,0.5,0.5,0.75,0.291667,0.0416667,0.5,0.5,0.875,0.333333,0.0416667,-0.5,0.5,1,0.375,0.0416667,-0.5,0.5,0.875,0.416667,0.0416667,-0.5,0.5,0.75,0.458333,0.0416667,-0.5,0.5,0.625,0.5,0.0416667,-0.5,0.5,0.5,0.541667,0.0416667,-0.5,0.5,0.375,0.583333,0.0416667,-0.5,0.5,0.25,0.625,0.0416667,-0.5,0.5,0.125,0.666667,0.0416667,0.5,0.5,0,0.708333,0.0416667,0.5,0.5,0.125,0.75,0.0416667,0.5,0.5,0.25,0.791667,0.0416667,0.5,0.5,0.375,0.833333,0.0416667,0.5,0.5,0.5,0.875,0.0416667,0.5,0.5,0.625,0.916667,0.0416667,0.5,0.5,0.75,0.958333,0.0416667,0.5,0.5,0.875,1,0,0,0.5,1 +Type=GESTURE + +[Data_2_3] +Comment=Press, move down, move up, release. +Enabled=true +Name=Duplicate Window +Type=SIMPLE_ACTION_DATA + +[Data_2_3Actions] +ActionsCount=1 + +[Data_2_3Actions0] +DestinationWindow=2 +Input=Ctrl+D\n +Type=KEYBOARD_INPUT + +[Data_2_3Conditions] +Comment= +ConditionsCount=0 + +[Data_2_3Triggers] +Comment=Gesture_triggers +TriggersCount=1 + +[Data_2_3Triggers0] +GesturePointData=0,0.0625,0.5,0.5,0,0.0625,0.0625,0.5,0.5,0.125,0.125,0.0625,0.5,0.5,0.25,0.1875,0.0625,0.5,0.5,0.375,0.25,0.0625,0.5,0.5,0.5,0.3125,0.0625,0.5,0.5,0.625,0.375,0.0625,0.5,0.5,0.75,0.4375,0.0625,0.5,0.5,0.875,0.5,0.0625,-0.5,0.5,1,0.5625,0.0625,-0.5,0.5,0.875,0.625,0.0625,-0.5,0.5,0.75,0.6875,0.0625,-0.5,0.5,0.625,0.75,0.0625,-0.5,0.5,0.5,0.8125,0.0625,-0.5,0.5,0.375,0.875,0.0625,-0.5,0.5,0.25,0.9375,0.0625,-0.5,0.5,0.125,1,0,0,0.5,0 +Type=GESTURE + +[Data_2_4] +Comment=Press, move right, release. +Enabled=true +Name=Forward +Type=SIMPLE_ACTION_DATA + +[Data_2_4Actions] +ActionsCount=1 + +[Data_2_4Actions0] +DestinationWindow=2 +Input=Alt+Right +Type=KEYBOARD_INPUT + +[Data_2_4Conditions] +Comment= +ConditionsCount=0 + +[Data_2_4Triggers] +Comment=Gesture_triggers +TriggersCount=1 + +[Data_2_4Triggers0] +GesturePointData=0,0.125,0,0,0.5,0.125,0.125,0,0.125,0.5,0.25,0.125,0,0.25,0.5,0.375,0.125,0,0.375,0.5,0.5,0.125,0,0.5,0.5,0.625,0.125,0,0.625,0.5,0.75,0.125,0,0.75,0.5,0.875,0.125,0,0.875,0.5,1,0,0,1,0.5 +Type=GESTURE + +[Data_2_5] +Comment=Press, move down, move half up, move right, move down, release.\n(Drawing a lowercase 'h'.) +Enabled=true +Name=Home +Type=SIMPLE_ACTION_DATA + +[Data_2_5Actions] +ActionsCount=1 + +[Data_2_5Actions0] +DestinationWindow=2 +Input=Alt+Home\n +Type=KEYBOARD_INPUT + +[Data_2_5Conditions] +Comment= +ConditionsCount=0 + +[Data_2_5Triggers] +Comment=Gesture_triggers +TriggersCount=2 + +[Data_2_5Triggers0] +GesturePointData=0,0.0461748,0.5,0,0,0.0461748,0.0461748,0.5,0,0.125,0.0923495,0.0461748,0.5,0,0.25,0.138524,0.0461748,0.5,0,0.375,0.184699,0.0461748,0.5,0,0.5,0.230874,0.0461748,0.5,0,0.625,0.277049,0.0461748,0.5,0,0.75,0.323223,0.0461748,0.5,0,0.875,0.369398,0.065301,-0.25,0,1,0.434699,0.065301,-0.25,0.125,0.875,0.5,0.065301,-0.25,0.25,0.75,0.565301,0.065301,-0.25,0.375,0.625,0.630602,0.0461748,0,0.5,0.5,0.676777,0.0461748,0,0.625,0.5,0.722951,0.0461748,0,0.75,0.5,0.769126,0.0461748,0,0.875,0.5,0.815301,0.0461748,0.5,1,0.5,0.861476,0.0461748,0.5,1,0.625,0.90765,0.0461748,0.5,1,0.75,0.953825,0.0461748,0.5,1,0.875,1,0,0,1,1 +Type=GESTURE + +[Data_2_5Triggers1] +GesturePointData=0,0.0416667,0.5,0,0,0.0416667,0.0416667,0.5,0,0.125,0.0833333,0.0416667,0.5,0,0.25,0.125,0.0416667,0.5,0,0.375,0.166667,0.0416667,0.5,0,0.5,0.208333,0.0416667,0.5,0,0.625,0.25,0.0416667,0.5,0,0.75,0.291667,0.0416667,0.5,0,0.875,0.333333,0.0416667,-0.5,0,1,0.375,0.0416667,-0.5,0,0.875,0.416667,0.0416667,-0.5,0,0.75,0.458333,0.0416667,-0.5,0,0.625,0.5,0.0416667,0,0,0.5,0.541667,0.0416667,0,0.125,0.5,0.583333,0.0416667,0,0.25,0.5,0.625,0.0416667,0,0.375,0.5,0.666667,0.0416667,0,0.5,0.5,0.708333,0.0416667,0,0.625,0.5,0.75,0.0416667,0,0.75,0.5,0.791667,0.0416667,0,0.875,0.5,0.833333,0.0416667,0.5,1,0.5,0.875,0.0416667,0.5,1,0.625,0.916667,0.0416667,0.5,1,0.75,0.958333,0.0416667,0.5,1,0.875,1,0,0,1,1 +Type=GESTURE + +[Data_2_6] +Comment=Press, move right, move down, move right, release.\nMozilla-style: Press, move down, move right, release. +Enabled=true +Name=Close Tab +Type=SIMPLE_ACTION_DATA + +[Data_2_6Actions] +ActionsCount=1 + +[Data_2_6Actions0] +DestinationWindow=2 +Input=Ctrl+W\n +Type=KEYBOARD_INPUT + +[Data_2_6Conditions] +Comment= +ConditionsCount=0 + +[Data_2_6Triggers] +Comment=Gesture_triggers +TriggersCount=2 + +[Data_2_6Triggers0] +GesturePointData=0,0.0625,0,0,0,0.0625,0.0625,0,0.125,0,0.125,0.0625,0,0.25,0,0.1875,0.0625,0,0.375,0,0.25,0.0625,0.5,0.5,0,0.3125,0.0625,0.5,0.5,0.125,0.375,0.0625,0.5,0.5,0.25,0.4375,0.0625,0.5,0.5,0.375,0.5,0.0625,0.5,0.5,0.5,0.5625,0.0625,0.5,0.5,0.625,0.625,0.0625,0.5,0.5,0.75,0.6875,0.0625,0.5,0.5,0.875,0.75,0.0625,0,0.5,1,0.8125,0.0625,0,0.625,1,0.875,0.0625,0,0.75,1,0.9375,0.0625,0,0.875,1,1,0,0,1,1 +Type=GESTURE + +[Data_2_6Triggers1] +GesturePointData=0,0.0625,0.5,0,0,0.0625,0.0625,0.5,0,0.125,0.125,0.0625,0.5,0,0.25,0.1875,0.0625,0.5,0,0.375,0.25,0.0625,0.5,0,0.5,0.3125,0.0625,0.5,0,0.625,0.375,0.0625,0.5,0,0.75,0.4375,0.0625,0.5,0,0.875,0.5,0.0625,0,0,1,0.5625,0.0625,0,0.125,1,0.625,0.0625,0,0.25,1,0.6875,0.0625,0,0.375,1,0.75,0.0625,0,0.5,1,0.8125,0.0625,0,0.625,1,0.875,0.0625,0,0.75,1,0.9375,0.0625,0,0.875,1,1,0,0,1,1 +Type=GESTURE + +[Data_2_7] +Comment=Press, move up, release.\nConflicts with Opera-style 'Up #2', which is disabled by default. +Enabled=true +Name=New Tab +Type=SIMPLE_ACTION_DATA + +[Data_2_7Actions] +ActionsCount=1 + +[Data_2_7Actions0] +DestinationWindow=2 +Input=Ctrl+Shift+N +Type=KEYBOARD_INPUT + +[Data_2_7Conditions] +Comment= +ConditionsCount=0 + +[Data_2_7Triggers] +Comment=Gesture_triggers +TriggersCount=1 + +[Data_2_7Triggers0] +GesturePointData=0,0.125,-0.5,0.5,1,0.125,0.125,-0.5,0.5,0.875,0.25,0.125,-0.5,0.5,0.75,0.375,0.125,-0.5,0.5,0.625,0.5,0.125,-0.5,0.5,0.5,0.625,0.125,-0.5,0.5,0.375,0.75,0.125,-0.5,0.5,0.25,0.875,0.125,-0.5,0.5,0.125,1,0,0,0.5,0 +Type=GESTURE + +[Data_2_8] +Comment=Press, move down, release. +Enabled=true +Name=New Window +Type=SIMPLE_ACTION_DATA + +[Data_2_8Actions] +ActionsCount=1 + +[Data_2_8Actions0] +DestinationWindow=2 +Input=Ctrl+N\n +Type=KEYBOARD_INPUT + +[Data_2_8Conditions] +Comment= +ConditionsCount=0 + +[Data_2_8Triggers] +Comment=Gesture_triggers +TriggersCount=1 + +[Data_2_8Triggers0] +GesturePointData=0,0.125,0.5,0.5,0,0.125,0.125,0.5,0.5,0.125,0.25,0.125,0.5,0.5,0.25,0.375,0.125,0.5,0.5,0.375,0.5,0.125,0.5,0.5,0.5,0.625,0.125,0.5,0.5,0.625,0.75,0.125,0.5,0.5,0.75,0.875,0.125,0.5,0.5,0.875,1,0,0,0.5,1 +Type=GESTURE + +[Data_2_9] +Comment=Press, move up, move down, release. +Enabled=true +Name=Reload +Type=SIMPLE_ACTION_DATA + +[Data_2_9Actions] +ActionsCount=1 + +[Data_2_9Actions0] +DestinationWindow=2 +Input=F5 +Type=KEYBOARD_INPUT + +[Data_2_9Conditions] +Comment= +ConditionsCount=0 + +[Data_2_9Triggers] +Comment=Gesture_triggers +TriggersCount=1 + +[Data_2_9Triggers0] +GesturePointData=0,0.0625,-0.5,0.5,1,0.0625,0.0625,-0.5,0.5,0.875,0.125,0.0625,-0.5,0.5,0.75,0.1875,0.0625,-0.5,0.5,0.625,0.25,0.0625,-0.5,0.5,0.5,0.3125,0.0625,-0.5,0.5,0.375,0.375,0.0625,-0.5,0.5,0.25,0.4375,0.0625,-0.5,0.5,0.125,0.5,0.0625,0.5,0.5,0,0.5625,0.0625,0.5,0.5,0.125,0.625,0.0625,0.5,0.5,0.25,0.6875,0.0625,0.5,0.5,0.375,0.75,0.0625,0.5,0.5,0.5,0.8125,0.0625,0.5,0.5,0.625,0.875,0.0625,0.5,0.5,0.75,0.9375,0.0625,0.5,0.5,0.875,1,0,0,0.5,1 +Type=GESTURE + +[Data_3] +Comment=This group contains various examples demonstrating most of the features of KHotkeys. (Note that this group and all its actions are disabled by default.) +DataCount=8 +Enabled=false +ImportId=kde32b1 +Name=Examples +SystemGroup=0 +Type=ACTION_DATA_GROUP + +[Data_3Conditions] +Comment= +ConditionsCount=0 + +[Data_3_1] +Comment=After pressing Ctrl+Alt+I, the KSIRC window will be activated, if it exists. Simple. +Enabled=false +Name=Activate KSIRC Window +Type=SIMPLE_ACTION_DATA + +[Data_3_1Actions] +ActionsCount=1 + +[Data_3_1Actions0] +Type=ACTIVATE_WINDOW + +[Data_3_1Actions0Window] +Comment=KSIRC window +WindowsCount=1 + +[Data_3_1Actions0Window0] +Class=ksirc +ClassType=1 +Comment=KSIRC +Role= +RoleType=0 +Title= +TitleType=0 +Type=SIMPLE +WindowTypes=33 + +[Data_3_1Conditions] +Comment= +ConditionsCount=0 + +[Data_3_1Triggers] +Comment=Simple_action +TriggersCount=1 + +[Data_3_1Triggers0] +Key=Ctrl+Alt+I +Type=SHORTCUT +Uuid={74d24aca-9c40-4db2-a9bd-fd217ed24f72} + +[Data_3_2] +Comment=After pressing Alt+Ctrl+H the input of 'Hello' will be simulated, as if you typed it. This is especially useful if you have call to frequently type a word (for instance, 'unsigned'). Every keypress in the input is separated by a colon ':'. Note that the keypresses literally mean keypresses, so you have to write what you would press on the keyboard. In the table below, the left column shows the input and the right column shows what to type.\n\n"enter" (i.e. new line) Enter or Return\na (i.e. small a) A\nA (i.e. capital a) Shift+A\n: (colon) Shift+;\n' ' (space) Space +Enabled=false +Name=Type 'Hello' +Type=SIMPLE_ACTION_DATA + +[Data_3_2Actions] +ActionsCount=1 + +[Data_3_2Actions0] +DestinationWindow=2 +Input=Shift+H:E:L:L:O\n +Type=KEYBOARD_INPUT + +[Data_3_2Conditions] +Comment= +ConditionsCount=0 + +[Data_3_2Triggers] +Comment=Simple_action +TriggersCount=1 + +[Data_3_2Triggers0] +Key=Ctrl+Alt+H +Type=SHORTCUT +Uuid={2df1c985-861f-4fef-b3de-6bbd3789bc6c} + +[Data_3_3] +Comment=This action runs Konsole, after pressing Ctrl+Alt+T. +Enabled=false +Name=Run Konsole +Type=SIMPLE_ACTION_DATA + +[Data_3_3Actions] +ActionsCount=1 + +[Data_3_3Actions0] +CommandURL=konsole +Type=COMMAND_URL + +[Data_3_3Conditions] +Comment= +ConditionsCount=0 + +[Data_3_3Triggers] +Comment=Simple_action +TriggersCount=1 + +[Data_3_3Triggers0] +Key=Ctrl+Alt+T +Type=SHORTCUT +Uuid={4f8b1e07-a5cb-4b2a-8e00-30445db61529} + +[Data_3_4] +Comment=Read the comment on the "Type 'Hello'" action first.\n\nQt Designer uses Ctrl+F4 for closing windows. In KDE, however, Ctrl+F4 is the shortcut for going to virtual desktop 4, so this shortcut does not work in Qt Designer. Further, Qt Designer does not use KDE's standard Ctrl+W for closing the window.\n\nThis problem can be solved by remapping Ctrl+W to Ctrl+F4 when the active window is Qt Designer. When Qt Designer is active, every time Ctrl+W is pressed, Ctrl+F4 will be sent to Qt Designer instead. In other applications, the effect of Ctrl+W is unchanged.\n\nWe now need to specify three things: A new shortcut trigger on 'Ctrl+W', a new keyboard input action sending Ctrl+F4, and a new condition that the active window is Qt Designer.\nQt Designer seems to always have title 'Qt Designer by Trolltech', so the condition will check for the active window having that title. +Enabled=false +Name=Remap Ctrl+W to Ctrl+F4 in Qt Designer +Type=GENERIC_ACTION_DATA + +[Data_3_4Actions] +ActionsCount=1 + +[Data_3_4Actions0] +DestinationWindow=2 +Input=Ctrl+F4 +Type=KEYBOARD_INPUT + +[Data_3_4Conditions] +Comment= +ConditionsCount=1 + +[Data_3_4Conditions0] +Type=ACTIVE_WINDOW + +[Data_3_4Conditions0Window] +Comment=Qt Designer +WindowsCount=1 + +[Data_3_4Conditions0Window0] +Class= +ClassType=0 +Comment= +Role= +RoleType=0 +Title=Qt Designer by Trolltech +TitleType=2 +Type=SIMPLE +WindowTypes=33 + +[Data_3_4Triggers] +Comment= +TriggersCount=1 + +[Data_3_4Triggers0] +Key=Ctrl+W +Type=SHORTCUT +Uuid={af214550-9c9d-4a2b-8300-2d6cabd1ae3e} + +[Data_3_5] +Comment=By pressing Alt+Ctrl+W a D-Bus call will be performed that will show the minicli. You can use any kind of D-Bus call, just like using the command line 'qdbus' tool. +Enabled=false +Name=Perform D-Bus call 'qdbus org.kde.krunner /App display' +Type=SIMPLE_ACTION_DATA + +[Data_3_5Actions] +ActionsCount=1 + +[Data_3_5Actions0] +Arguments= +Call=popupExecuteCommand +RemoteApp=org.kde.krunner +RemoteObj=/App +Type=DBUS + +[Data_3_5Conditions] +Comment= +ConditionsCount=0 + +[Data_3_5Triggers] +Comment=Simple_action +TriggersCount=1 + +[Data_3_5Triggers0] +Key=Ctrl+Alt+W +Type=SHORTCUT +Uuid={0bfc762d-96a2-426c-96da-7be42c5c1b60} + +[Data_3_6] +Comment=Read the comment on the "Type 'Hello'" action first.\n\nJust like the "Type 'Hello'" action, this one simulates keyboard input, specifically, after pressing Ctrl+Alt+B, it sends B to XMMS (B in XMMS jumps to the next song). The 'Send to specific window' checkbox is checked and a window with its class containing 'XMMS_Player' is specified; this will make the input always be sent to this window. This way, you can control XMMS even if, for instance, it is on a different virtual desktop.\n\n(Run 'xprop' and click on the XMMS window and search for WM_CLASS to see 'XMMS_Player'). +Enabled=false +Name=Next in XMMS +Type=SIMPLE_ACTION_DATA + +[Data_3_6Actions] +ActionsCount=1 + +[Data_3_6Actions0] +DestinationWindow=1 +Input=B +Type=KEYBOARD_INPUT + +[Data_3_6Actions0DestinationWindow] +Comment=XMMS window +WindowsCount=1 + +[Data_3_6Actions0DestinationWindow0] +Class=XMMS_Player +ClassType=1 +Comment=XMMS Player window +Role= +RoleType=0 +Title= +TitleType=0 +Type=SIMPLE +WindowTypes=33 + +[Data_3_6Conditions] +Comment= +ConditionsCount=0 + +[Data_3_6Triggers] +Comment=Simple_action +TriggersCount=1 + +[Data_3_6Triggers0] +Key=Ctrl+Alt+B +Type=SHORTCUT +Uuid={645d7bf7-3899-4bc3-9bf0-83843171267c} + +[Data_3_7] +Comment=Konqueror in KDE3.1 has tabs, and now you can also have gestures.\n\nJust press the middle mouse button and start drawing one of the gestures, and after you are finished, release the mouse button. If you only need to paste the selection, it still works, just click the middle mouse button. (You can change the mouse button to use in the global settings).\n\nRight now, there are the following gestures available:\nmove right and back left - Forward (Alt+Right)\nmove left and back right - Back (Alt+Left)\nmove up and back down - Up (Alt+Up)\ncircle counterclockwise - Reload (F5)\n\nThe gesture shapes can be entered by performing them in the configuration dialog. You can also look at your numeric pad to help you: gestures are recognized like a 3x3 grid of fields, numbered 1 to 9.\n\nNote that you must perform exactly the gesture to trigger the action. Because of this, it is possible to enter more gestures for the action. You should try to avoid complicated gestures where you change the direction of mouse movement more than once. For instance, 45654 or 74123 are simple to perform, but 1236987 may be already quite difficult.\n\nThe conditions for all gestures are defined in this group. All these gestures are active only if the active window is Konqueror (class contains 'konqueror'). +DataCount=4 +Enabled=false +Name=Konqi Gestures +SystemGroup=0 +Type=ACTION_DATA_GROUP + +[Data_3_7Conditions] +Comment=Konqueror window +ConditionsCount=1 + +[Data_3_7Conditions0] +Type=ACTIVE_WINDOW + +[Data_3_7Conditions0Window] +Comment=Konqueror +WindowsCount=1 + +[Data_3_7Conditions0Window0] +Class=konqueror +ClassType=1 +Comment=Konqueror +Role= +RoleType=0 +Title= +TitleType=0 +Type=SIMPLE +WindowTypes=33 + +[Data_3_7_1] +Comment= +Enabled=false +Name=Back +Type=SIMPLE_ACTION_DATA + +[Data_3_7_1Actions] +ActionsCount=1 + +[Data_3_7_1Actions0] +DestinationWindow=2 +Input=Alt+Left +Type=KEYBOARD_INPUT + +[Data_3_7_1Conditions] +Comment= +ConditionsCount=0 + +[Data_3_7_1Triggers] +Comment=Gesture_triggers +TriggersCount=3 + +[Data_3_7_1Triggers0] +GesturePointData=0,0.0625,1,1,0.5,0.0625,0.0625,1,0.875,0.5,0.125,0.0625,1,0.75,0.5,0.1875,0.0625,1,0.625,0.5,0.25,0.0625,1,0.5,0.5,0.3125,0.0625,1,0.375,0.5,0.375,0.0625,1,0.25,0.5,0.4375,0.0625,1,0.125,0.5,0.5,0.0625,0,0,0.5,0.5625,0.0625,0,0.125,0.5,0.625,0.0625,0,0.25,0.5,0.6875,0.0625,0,0.375,0.5,0.75,0.0625,0,0.5,0.5,0.8125,0.0625,0,0.625,0.5,0.875,0.0625,0,0.75,0.5,0.9375,0.0625,0,0.875,0.5,1,0,0,1,0.5 +Type=GESTURE + +[Data_3_7_1Triggers1] +GesturePointData=0,0.0833333,1,0.5,0.5,0.0833333,0.0833333,1,0.375,0.5,0.166667,0.0833333,1,0.25,0.5,0.25,0.0833333,1,0.125,0.5,0.333333,0.0833333,0,0,0.5,0.416667,0.0833333,0,0.125,0.5,0.5,0.0833333,0,0.25,0.5,0.583333,0.0833333,0,0.375,0.5,0.666667,0.0833333,0,0.5,0.5,0.75,0.0833333,0,0.625,0.5,0.833333,0.0833333,0,0.75,0.5,0.916667,0.0833333,0,0.875,0.5,1,0,0,1,0.5 +Type=GESTURE + +[Data_3_7_1Triggers2] +GesturePointData=0,0.0833333,1,1,0.5,0.0833333,0.0833333,1,0.875,0.5,0.166667,0.0833333,1,0.75,0.5,0.25,0.0833333,1,0.625,0.5,0.333333,0.0833333,1,0.5,0.5,0.416667,0.0833333,1,0.375,0.5,0.5,0.0833333,1,0.25,0.5,0.583333,0.0833333,1,0.125,0.5,0.666667,0.0833333,0,0,0.5,0.75,0.0833333,0,0.125,0.5,0.833333,0.0833333,0,0.25,0.5,0.916667,0.0833333,0,0.375,0.5,1,0,0,0.5,0.5 +Type=GESTURE + +[Data_3_7_2] +Comment= +Enabled=false +Name=Forward +Type=SIMPLE_ACTION_DATA + +[Data_3_7_2Actions] +ActionsCount=1 + +[Data_3_7_2Actions0] +DestinationWindow=2 +Input=Alt+Right +Type=KEYBOARD_INPUT + +[Data_3_7_2Conditions] +Comment= +ConditionsCount=0 + +[Data_3_7_2Triggers] +Comment=Gesture_triggers +TriggersCount=3 + +[Data_3_7_2Triggers0] +GesturePointData=0,0.0625,0,0,0.5,0.0625,0.0625,0,0.125,0.5,0.125,0.0625,0,0.25,0.5,0.1875,0.0625,0,0.375,0.5,0.25,0.0625,0,0.5,0.5,0.3125,0.0625,0,0.625,0.5,0.375,0.0625,0,0.75,0.5,0.4375,0.0625,0,0.875,0.5,0.5,0.0625,1,1,0.5,0.5625,0.0625,1,0.875,0.5,0.625,0.0625,1,0.75,0.5,0.6875,0.0625,1,0.625,0.5,0.75,0.0625,1,0.5,0.5,0.8125,0.0625,1,0.375,0.5,0.875,0.0625,1,0.25,0.5,0.9375,0.0625,1,0.125,0.5,1,0,0,0,0.5 +Type=GESTURE + +[Data_3_7_2Triggers1] +GesturePointData=0,0.0833333,0,0.5,0.5,0.0833333,0.0833333,0,0.625,0.5,0.166667,0.0833333,0,0.75,0.5,0.25,0.0833333,0,0.875,0.5,0.333333,0.0833333,1,1,0.5,0.416667,0.0833333,1,0.875,0.5,0.5,0.0833333,1,0.75,0.5,0.583333,0.0833333,1,0.625,0.5,0.666667,0.0833333,1,0.5,0.5,0.75,0.0833333,1,0.375,0.5,0.833333,0.0833333,1,0.25,0.5,0.916667,0.0833333,1,0.125,0.5,1,0,0,0,0.5 +Type=GESTURE + +[Data_3_7_2Triggers2] +GesturePointData=0,0.0833333,0,0,0.5,0.0833333,0.0833333,0,0.125,0.5,0.166667,0.0833333,0,0.25,0.5,0.25,0.0833333,0,0.375,0.5,0.333333,0.0833333,0,0.5,0.5,0.416667,0.0833333,0,0.625,0.5,0.5,0.0833333,0,0.75,0.5,0.583333,0.0833333,0,0.875,0.5,0.666667,0.0833333,1,1,0.5,0.75,0.0833333,1,0.875,0.5,0.833333,0.0833333,1,0.75,0.5,0.916667,0.0833333,1,0.625,0.5,1,0,0,0.5,0.5 +Type=GESTURE + +[Data_3_7_3] +Comment= +Enabled=false +Name=Up +Type=SIMPLE_ACTION_DATA + +[Data_3_7_3Actions] +ActionsCount=1 + +[Data_3_7_3Actions0] +DestinationWindow=2 +Input=Alt+Up +Type=KEYBOARD_INPUT + +[Data_3_7_3Conditions] +Comment= +ConditionsCount=0 + +[Data_3_7_3Triggers] +Comment=Gesture_triggers +TriggersCount=3 + +[Data_3_7_3Triggers0] +GesturePointData=0,0.0625,-0.5,0.5,1,0.0625,0.0625,-0.5,0.5,0.875,0.125,0.0625,-0.5,0.5,0.75,0.1875,0.0625,-0.5,0.5,0.625,0.25,0.0625,-0.5,0.5,0.5,0.3125,0.0625,-0.5,0.5,0.375,0.375,0.0625,-0.5,0.5,0.25,0.4375,0.0625,-0.5,0.5,0.125,0.5,0.0625,0.5,0.5,0,0.5625,0.0625,0.5,0.5,0.125,0.625,0.0625,0.5,0.5,0.25,0.6875,0.0625,0.5,0.5,0.375,0.75,0.0625,0.5,0.5,0.5,0.8125,0.0625,0.5,0.5,0.625,0.875,0.0625,0.5,0.5,0.75,0.9375,0.0625,0.5,0.5,0.875,1,0,0,0.5,1 +Type=GESTURE + +[Data_3_7_3Triggers1] +GesturePointData=0,0.0833333,-0.5,0.5,1,0.0833333,0.0833333,-0.5,0.5,0.875,0.166667,0.0833333,-0.5,0.5,0.75,0.25,0.0833333,-0.5,0.5,0.625,0.333333,0.0833333,-0.5,0.5,0.5,0.416667,0.0833333,-0.5,0.5,0.375,0.5,0.0833333,-0.5,0.5,0.25,0.583333,0.0833333,-0.5,0.5,0.125,0.666667,0.0833333,0.5,0.5,0,0.75,0.0833333,0.5,0.5,0.125,0.833333,0.0833333,0.5,0.5,0.25,0.916667,0.0833333,0.5,0.5,0.375,1,0,0,0.5,0.5 +Type=GESTURE + +[Data_3_7_3Triggers2] +GesturePointData=0,0.0833333,-0.5,0.5,0.5,0.0833333,0.0833333,-0.5,0.5,0.375,0.166667,0.0833333,-0.5,0.5,0.25,0.25,0.0833333,-0.5,0.5,0.125,0.333333,0.0833333,0.5,0.5,0,0.416667,0.0833333,0.5,0.5,0.125,0.5,0.0833333,0.5,0.5,0.25,0.583333,0.0833333,0.5,0.5,0.375,0.666667,0.0833333,0.5,0.5,0.5,0.75,0.0833333,0.5,0.5,0.625,0.833333,0.0833333,0.5,0.5,0.75,0.916667,0.0833333,0.5,0.5,0.875,1,0,0,0.5,1 +Type=GESTURE + +[Data_3_7_4] +Comment= +Enabled=false +Name=Reload +Type=SIMPLE_ACTION_DATA + +[Data_3_7_4Actions] +ActionsCount=1 + +[Data_3_7_4Actions0] +DestinationWindow=2 +Input=F5 +Type=KEYBOARD_INPUT + +[Data_3_7_4Conditions] +Comment= +ConditionsCount=0 + +[Data_3_7_4Triggers] +Comment=Gesture_triggers +TriggersCount=3 + +[Data_3_7_4Triggers0] +GesturePointData=0,0.03125,0,0,1,0.03125,0.03125,0,0.125,1,0.0625,0.03125,0,0.25,1,0.09375,0.03125,0,0.375,1,0.125,0.03125,0,0.5,1,0.15625,0.03125,0,0.625,1,0.1875,0.03125,0,0.75,1,0.21875,0.03125,0,0.875,1,0.25,0.03125,-0.5,1,1,0.28125,0.03125,-0.5,1,0.875,0.3125,0.03125,-0.5,1,0.75,0.34375,0.03125,-0.5,1,0.625,0.375,0.03125,-0.5,1,0.5,0.40625,0.03125,-0.5,1,0.375,0.4375,0.03125,-0.5,1,0.25,0.46875,0.03125,-0.5,1,0.125,0.5,0.03125,1,1,0,0.53125,0.03125,1,0.875,0,0.5625,0.03125,1,0.75,0,0.59375,0.03125,1,0.625,0,0.625,0.03125,1,0.5,0,0.65625,0.03125,1,0.375,0,0.6875,0.03125,1,0.25,0,0.71875,0.03125,1,0.125,0,0.75,0.03125,0.5,0,0,0.78125,0.03125,0.5,0,0.125,0.8125,0.03125,0.5,0,0.25,0.84375,0.03125,0.5,0,0.375,0.875,0.03125,0.5,0,0.5,0.90625,0.03125,0.5,0,0.625,0.9375,0.03125,0.5,0,0.75,0.96875,0.03125,0.5,0,0.875,1,0,0,0,1 +Type=GESTURE + +[Data_3_7_4Triggers1] +GesturePointData=0,0.0277778,0,0,1,0.0277778,0.0277778,0,0.125,1,0.0555556,0.0277778,0,0.25,1,0.0833333,0.0277778,0,0.375,1,0.111111,0.0277778,0,0.5,1,0.138889,0.0277778,0,0.625,1,0.166667,0.0277778,0,0.75,1,0.194444,0.0277778,0,0.875,1,0.222222,0.0277778,-0.5,1,1,0.25,0.0277778,-0.5,1,0.875,0.277778,0.0277778,-0.5,1,0.75,0.305556,0.0277778,-0.5,1,0.625,0.333333,0.0277778,-0.5,1,0.5,0.361111,0.0277778,-0.5,1,0.375,0.388889,0.0277778,-0.5,1,0.25,0.416667,0.0277778,-0.5,1,0.125,0.444444,0.0277778,1,1,0,0.472222,0.0277778,1,0.875,0,0.5,0.0277778,1,0.75,0,0.527778,0.0277778,1,0.625,0,0.555556,0.0277778,1,0.5,0,0.583333,0.0277778,1,0.375,0,0.611111,0.0277778,1,0.25,0,0.638889,0.0277778,1,0.125,0,0.666667,0.0277778,0.5,0,0,0.694444,0.0277778,0.5,0,0.125,0.722222,0.0277778,0.5,0,0.25,0.75,0.0277778,0.5,0,0.375,0.777778,0.0277778,0.5,0,0.5,0.805556,0.0277778,0.5,0,0.625,0.833333,0.0277778,0.5,0,0.75,0.861111,0.0277778,0.5,0,0.875,0.888889,0.0277778,0,0,1,0.916667,0.0277778,0,0.125,1,0.944444,0.0277778,0,0.25,1,0.972222,0.0277778,0,0.375,1,1,0,0,0.5,1 +Type=GESTURE + +[Data_3_7_4Triggers2] +GesturePointData=0,0.0277778,0.5,0,0.5,0.0277778,0.0277778,0.5,0,0.625,0.0555556,0.0277778,0.5,0,0.75,0.0833333,0.0277778,0.5,0,0.875,0.111111,0.0277778,0,0,1,0.138889,0.0277778,0,0.125,1,0.166667,0.0277778,0,0.25,1,0.194444,0.0277778,0,0.375,1,0.222222,0.0277778,0,0.5,1,0.25,0.0277778,0,0.625,1,0.277778,0.0277778,0,0.75,1,0.305556,0.0277778,0,0.875,1,0.333333,0.0277778,-0.5,1,1,0.361111,0.0277778,-0.5,1,0.875,0.388889,0.0277778,-0.5,1,0.75,0.416667,0.0277778,-0.5,1,0.625,0.444444,0.0277778,-0.5,1,0.5,0.472222,0.0277778,-0.5,1,0.375,0.5,0.0277778,-0.5,1,0.25,0.527778,0.0277778,-0.5,1,0.125,0.555556,0.0277778,1,1,0,0.583333,0.0277778,1,0.875,0,0.611111,0.0277778,1,0.75,0,0.638889,0.0277778,1,0.625,0,0.666667,0.0277778,1,0.5,0,0.694444,0.0277778,1,0.375,0,0.722222,0.0277778,1,0.25,0,0.75,0.0277778,1,0.125,0,0.777778,0.0277778,0.5,0,0,0.805556,0.0277778,0.5,0,0.125,0.833333,0.0277778,0.5,0,0.25,0.861111,0.0277778,0.5,0,0.375,0.888889,0.0277778,0.5,0,0.5,0.916667,0.0277778,0.5,0,0.625,0.944444,0.0277778,0.5,0,0.75,0.972222,0.0277778,0.5,0,0.875,1,0,0,0,1 +Type=GESTURE + +[Data_3_8] +Comment=After pressing Win+E (Tux+E) a WWW browser will be launched, and it will open http://www.kde.org . You may run all kind of commands you can run in minicli (Alt+F2). +Enabled=false +Name=Go to KDE Website +Type=SIMPLE_ACTION_DATA + +[Data_3_8Actions] +ActionsCount=1 + +[Data_3_8Actions0] +CommandURL=http://www.kde.org +Type=COMMAND_URL + +[Data_3_8Conditions] +Comment= +ConditionsCount=0 + +[Data_3_8Triggers] +Comment=Simple_action +TriggersCount=1 + +[Data_3_8Triggers0] +Key=Meta+E +Type=SHORTCUT +Uuid={b9dcc100-c750-47e4-9f9c-352d472fca4d} + +[Directories] +dir_pixmap[$d] + +[General] +BrowserApplication[$d] +desktopFont[$d] +fixed[$d] +font[$d] +menuFont[$d] +shadeSortColumn[$d] +smallestReadableFont[$d] +taskbarFont[$d] +toolBarFont[$d] + +[Gestures] +Disabled=true +MouseButton=2 +Timeout=300 + +[GesturesExclude] +Comment= +WindowsCount=0 + +[Icons] +Theme[$d] + +[KDE] +ChangeCursor[$d] +LookAndFeelPackage[$d] +contrast[$d] + +[KDE URL Restrictions] +rule_1[$d] +rule_count[$d] + +[KFileDialog Settings] +Breadcrumb Navigation[$d] + +[Main] +AlreadyImported=defaults,konqueror_gestures_kde321,konsole,kde32b1 +Disabled=false +Version=2 + +[Paths] +Trash[$d] + +[PreviewSettings] +camera[$d] +file[$d] +fonts[$d] + +[Voice] +Shortcut= diff --git a/skel/.config/kwinrc b/skel/.config/kwinrc new file mode 100644 index 0000000..28f8d17 --- /dev/null +++ b/skel/.config/kwinrc @@ -0,0 +1,32 @@ +[$Version] +update_info=kwin.upd:replace-scalein-with-scale,kwin.upd:port-minimizeanimation-effect-to-js,kwin.upd:port-scale-effect-to-js,kwin.upd:port-dimscreen-effect-to-js,kwin.upd:auto-bordersize,kwin.upd:animation-speed + +[Compositing] +AnimationSpeed[$d] +OpenGLIsUnsafe=false + +[Desktops] +Id_1=d58fdeb5-859b-4cd3-bc75-78fba32a1fdc +Id_2=74d95bb3-64ef-4888-870e-794c9d3fedbe +Id_3=c00d3871-eebb-4fd7-82a8-a08754d136d7 +Id_4=eda439a5-741e-47d7-afa9-009db7e7966a +Id_5=f085ada0-c63c-4ee4-9412-0e58f1288979 +Id_6=e1fa5d19-9784-49de-8465-13d17b41e576 +Id_7=531bc9e0-d704-4186-b246-ae56cf2586e5 +Id_8=55bead01-e31a-4b86-9039-82ae1999bc13 +Id_9=7da55073-b089-4b5b-978a-0665f03656b4 +Name_3=New Desktop +Name_4=New Desktop +Name_5=New Desktop +Name_6=New Desktop +Name_7=New Desktop +Name_8=New Desktop +Name_9=New Desktop +Number=9 +Rows=3 + +[Plugins] +desktopchangeosdEnabled=true + +[Windows] +RollOverDesktops=false diff --git a/skel/.config/nvim/autoload/plug.vim b/skel/.config/nvim/autoload/plug.vim new file mode 100644 index 0000000..e0dc78f --- /dev/null +++ b/skel/.config/nvim/autoload/plug.vim @@ -0,0 +1,2458 @@ +" vim-plug: Vim plugin manager +" ============================ +" +" Download plug.vim and put it in ~/.vim/autoload +" +" curl -fLo ~/.vim/autoload/plug.vim --create-dirs \ +" https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim +" +" Edit your .vimrc +" +" call plug#begin('~/.vim/plugged') +" +" " Make sure you use single quotes +" +" " Shorthand notation; fetches https://github.com/junegunn/vim-easy-align +" Plug 'junegunn/vim-easy-align' +" +" " Any valid git URL is allowed +" Plug 'https://github.com/junegunn/vim-github-dashboard.git' +" +" " Multiple Plug commands can be written in a single line using | separators +" Plug 'SirVer/ultisnips' | Plug 'honza/vim-snippets' +" +" " On-demand loading +" Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' } +" Plug 'tpope/vim-fireplace', { 'for': 'clojure' } +" +" " Using a non-master branch +" Plug 'rdnetto/YCM-Generator', { 'branch': 'stable' } +" +" " Using a tagged release; wildcard allowed (requires git 1.9.2 or above) +" Plug 'fatih/vim-go', { 'tag': '*' } +" +" " Plugin options +" Plug 'nsf/gocode', { 'tag': 'v.20150303', 'rtp': 'vim' } +" +" " Plugin outside ~/.vim/plugged with post-update hook +" Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' } +" +" " Unmanaged plugin (manually installed and updated) +" Plug '~/my-prototype-plugin' +" +" " Initialize plugin system +" call plug#end() +" +" Then reload .vimrc and :PlugInstall to install plugins. +" +" Plug options: +" +"| Option | Description | +"| ----------------------- | ------------------------------------------------ | +"| `branch`/`tag`/`commit` | Branch/tag/commit of the repository to use | +"| `rtp` | Subdirectory that contains Vim plugin | +"| `dir` | Custom directory for the plugin | +"| `as` | Use different name for the plugin | +"| `do` | Post-update hook (string or funcref) | +"| `on` | On-demand loading: Commands or ``-mappings | +"| `for` | On-demand loading: File types | +"| `frozen` | Do not update unless explicitly specified | +" +" More information: https://github.com/junegunn/vim-plug +" +" +" Copyright (c) 2017 Junegunn Choi +" +" MIT License +" +" Permission is hereby granted, free of charge, to any person obtaining +" a copy of this software and associated documentation files (the +" "Software"), to deal in the Software without restriction, including +" without limitation the rights to use, copy, modify, merge, publish, +" distribute, sublicense, and/or sell copies of the Software, and to +" permit persons to whom the Software is furnished to do so, subject to +" the following conditions: +" +" The above copyright notice and this permission notice shall be +" included in all copies or substantial portions of the Software. +" +" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +" EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +" NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +" LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +" OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +" WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +if exists('g:loaded_plug') + finish +endif +let g:loaded_plug = 1 + +let s:cpo_save = &cpo +set cpo&vim + +let s:plug_src = 'https://github.com/junegunn/vim-plug.git' +let s:plug_tab = get(s:, 'plug_tab', -1) +let s:plug_buf = get(s:, 'plug_buf', -1) +let s:mac_gui = has('gui_macvim') && has('gui_running') +let s:is_win = has('win32') || has('win64') +let s:nvim = has('nvim-0.2') || (has('nvim') && exists('*jobwait') && !s:is_win) +let s:vim8 = has('patch-8.0.0039') && exists('*job_start') +let s:me = resolve(expand(':p')) +let s:base_spec = { 'branch': 'master', 'frozen': 0 } +let s:TYPE = { +\ 'string': type(''), +\ 'list': type([]), +\ 'dict': type({}), +\ 'funcref': type(function('call')) +\ } +let s:loaded = get(s:, 'loaded', {}) +let s:triggers = get(s:, 'triggers', {}) + +function! plug#begin(...) + if a:0 > 0 + let s:plug_home_org = a:1 + let home = s:path(fnamemodify(expand(a:1), ':p')) + elseif exists('g:plug_home') + let home = s:path(g:plug_home) + elseif !empty(&rtp) + let home = s:path(split(&rtp, ',')[0]) . '/plugged' + else + return s:err('Unable to determine plug home. Try calling plug#begin() with a path argument.') + endif + if fnamemodify(home, ':t') ==# 'plugin' && fnamemodify(home, ':h') ==# s:first_rtp + return s:err('Invalid plug home. '.home.' is a standard Vim runtime path and is not allowed.') + endif + + let g:plug_home = home + let g:plugs = {} + let g:plugs_order = [] + let s:triggers = {} + + call s:define_commands() + return 1 +endfunction + +function! s:define_commands() + command! -nargs=+ -bar Plug call plug#() + if !executable('git') + return s:err('`git` executable not found. Most commands will not be available. To suppress this message, prepend `silent!` to `call plug#begin(...)`.') + endif + command! -nargs=* -bar -bang -complete=customlist,s:names PlugInstall call s:install(0, []) + command! -nargs=* -bar -bang -complete=customlist,s:names PlugUpdate call s:update(0, []) + command! -nargs=0 -bar -bang PlugClean call s:clean(0) + command! -nargs=0 -bar PlugUpgrade if s:upgrade() | execute 'source' s:esc(s:me) | endif + command! -nargs=0 -bar PlugStatus call s:status() + command! -nargs=0 -bar PlugDiff call s:diff() + command! -nargs=? -bar -bang -complete=file PlugSnapshot call s:snapshot(0, ) +endfunction + +function! s:to_a(v) + return type(a:v) == s:TYPE.list ? a:v : [a:v] +endfunction + +function! s:to_s(v) + return type(a:v) == s:TYPE.string ? a:v : join(a:v, "\n") . "\n" +endfunction + +function! s:glob(from, pattern) + return s:lines(globpath(a:from, a:pattern)) +endfunction + +function! s:source(from, ...) + let found = 0 + for pattern in a:000 + for vim in s:glob(a:from, pattern) + execute 'source' s:esc(vim) + let found = 1 + endfor + endfor + return found +endfunction + +function! s:assoc(dict, key, val) + let a:dict[a:key] = add(get(a:dict, a:key, []), a:val) +endfunction + +function! s:ask(message, ...) + call inputsave() + echohl WarningMsg + let answer = input(a:message.(a:0 ? ' (y/N/a) ' : ' (y/N) ')) + echohl None + call inputrestore() + echo "\r" + return (a:0 && answer =~? '^a') ? 2 : (answer =~? '^y') ? 1 : 0 +endfunction + +function! s:ask_no_interrupt(...) + try + return call('s:ask', a:000) + catch + return 0 + endtry +endfunction + +function! plug#end() + if !exists('g:plugs') + return s:err('Call plug#begin() first') + endif + + if exists('#PlugLOD') + augroup PlugLOD + autocmd! + augroup END + augroup! PlugLOD + endif + let lod = { 'ft': {}, 'map': {}, 'cmd': {} } + + if exists('g:did_load_filetypes') + filetype off + endif + for name in g:plugs_order + if !has_key(g:plugs, name) + continue + endif + let plug = g:plugs[name] + if get(s:loaded, name, 0) || !has_key(plug, 'on') && !has_key(plug, 'for') + let s:loaded[name] = 1 + continue + endif + + if has_key(plug, 'on') + let s:triggers[name] = { 'map': [], 'cmd': [] } + for cmd in s:to_a(plug.on) + if cmd =~? '^.\+' + if empty(mapcheck(cmd)) && empty(mapcheck(cmd, 'i')) + call s:assoc(lod.map, cmd, name) + endif + call add(s:triggers[name].map, cmd) + elseif cmd =~# '^[A-Z]' + let cmd = substitute(cmd, '!*$', '', '') + if exists(':'.cmd) != 2 + call s:assoc(lod.cmd, cmd, name) + endif + call add(s:triggers[name].cmd, cmd) + else + call s:err('Invalid `on` option: '.cmd. + \ '. Should start with an uppercase letter or ``.') + endif + endfor + endif + + if has_key(plug, 'for') + let types = s:to_a(plug.for) + if !empty(types) + augroup filetypedetect + call s:source(s:rtp(plug), 'ftdetect/**/*.vim', 'after/ftdetect/**/*.vim') + augroup END + endif + for type in types + call s:assoc(lod.ft, type, name) + endfor + endif + endfor + + for [cmd, names] in items(lod.cmd) + execute printf( + \ 'command! -nargs=* -range -bang -complete=file %s call s:lod_cmd(%s, "", , , , %s)', + \ cmd, string(cmd), string(names)) + endfor + + for [map, names] in items(lod.map) + for [mode, map_prefix, key_prefix] in + \ [['i', '', ''], ['n', '', ''], ['v', '', 'gv'], ['o', '', '']] + execute printf( + \ '%snoremap %s %s:call lod_map(%s, %s, %s, "%s")', + \ mode, map, map_prefix, string(map), string(names), mode != 'i', key_prefix) + endfor + endfor + + for [ft, names] in items(lod.ft) + augroup PlugLOD + execute printf('autocmd FileType %s call lod_ft(%s, %s)', + \ ft, string(ft), string(names)) + augroup END + endfor + + call s:reorg_rtp() + filetype plugin indent on + if has('vim_starting') + if has('syntax') && !exists('g:syntax_on') + syntax enable + end + else + call s:reload_plugins() + endif +endfunction + +function! s:loaded_names() + return filter(copy(g:plugs_order), 'get(s:loaded, v:val, 0)') +endfunction + +function! s:load_plugin(spec) + call s:source(s:rtp(a:spec), 'plugin/**/*.vim', 'after/plugin/**/*.vim') +endfunction + +function! s:reload_plugins() + for name in s:loaded_names() + call s:load_plugin(g:plugs[name]) + endfor +endfunction + +function! s:trim(str) + return substitute(a:str, '[\/]\+$', '', '') +endfunction + +function! s:version_requirement(val, min) + for idx in range(0, len(a:min) - 1) + let v = get(a:val, idx, 0) + if v < a:min[idx] | return 0 + elseif v > a:min[idx] | return 1 + endif + endfor + return 1 +endfunction + +function! s:git_version_requirement(...) + if !exists('s:git_version') + let s:git_version = map(split(split(s:system('git --version'))[2], '\.'), 'str2nr(v:val)') + endif + return s:version_requirement(s:git_version, a:000) +endfunction + +function! s:progress_opt(base) + return a:base && !s:is_win && + \ s:git_version_requirement(1, 7, 1) ? '--progress' : '' +endfunction + +if s:is_win + function! s:rtp(spec) + return s:path(a:spec.dir . get(a:spec, 'rtp', '')) + endfunction + + function! s:path(path) + return s:trim(substitute(a:path, '/', '\', 'g')) + endfunction + + function! s:dirpath(path) + return s:path(a:path) . '\' + endfunction + + function! s:is_local_plug(repo) + return a:repo =~? '^[a-z]:\|^[%~]' + endfunction +else + function! s:rtp(spec) + return s:dirpath(a:spec.dir . get(a:spec, 'rtp', '')) + endfunction + + function! s:path(path) + return s:trim(a:path) + endfunction + + function! s:dirpath(path) + return substitute(a:path, '[/\\]*$', '/', '') + endfunction + + function! s:is_local_plug(repo) + return a:repo[0] =~ '[/$~]' + endfunction +endif + +function! s:err(msg) + echohl ErrorMsg + echom '[vim-plug] '.a:msg + echohl None +endfunction + +function! s:warn(cmd, msg) + echohl WarningMsg + execute a:cmd 'a:msg' + echohl None +endfunction + +function! s:esc(path) + return escape(a:path, ' ') +endfunction + +function! s:escrtp(path) + return escape(a:path, ' ,') +endfunction + +function! s:remove_rtp() + for name in s:loaded_names() + let rtp = s:rtp(g:plugs[name]) + execute 'set rtp-='.s:escrtp(rtp) + let after = globpath(rtp, 'after') + if isdirectory(after) + execute 'set rtp-='.s:escrtp(after) + endif + endfor +endfunction + +function! s:reorg_rtp() + if !empty(s:first_rtp) + execute 'set rtp-='.s:first_rtp + execute 'set rtp-='.s:last_rtp + endif + + " &rtp is modified from outside + if exists('s:prtp') && s:prtp !=# &rtp + call s:remove_rtp() + unlet! s:middle + endif + + let s:middle = get(s:, 'middle', &rtp) + let rtps = map(s:loaded_names(), 's:rtp(g:plugs[v:val])') + let afters = filter(map(copy(rtps), 'globpath(v:val, "after")'), '!empty(v:val)') + let rtp = join(map(rtps, 'escape(v:val, ",")'), ',') + \ . ','.s:middle.',' + \ . join(map(afters, 'escape(v:val, ",")'), ',') + let &rtp = substitute(substitute(rtp, ',,*', ',', 'g'), '^,\|,$', '', 'g') + let s:prtp = &rtp + + if !empty(s:first_rtp) + execute 'set rtp^='.s:first_rtp + execute 'set rtp+='.s:last_rtp + endif +endfunction + +function! s:doautocmd(...) + if exists('#'.join(a:000, '#')) + execute 'doautocmd' ((v:version > 703 || has('patch442')) ? '' : '') join(a:000) + endif +endfunction + +function! s:dobufread(names) + for name in a:names + let path = s:rtp(g:plugs[name]).'/**' + for dir in ['ftdetect', 'ftplugin'] + if len(finddir(dir, path)) + if exists('#BufRead') + doautocmd BufRead + endif + return + endif + endfor + endfor +endfunction + +function! plug#load(...) + if a:0 == 0 + return s:err('Argument missing: plugin name(s) required') + endif + if !exists('g:plugs') + return s:err('plug#begin was not called') + endif + let names = a:0 == 1 && type(a:1) == s:TYPE.list ? a:1 : a:000 + let unknowns = filter(copy(names), '!has_key(g:plugs, v:val)') + if !empty(unknowns) + let s = len(unknowns) > 1 ? 's' : '' + return s:err(printf('Unknown plugin%s: %s', s, join(unknowns, ', '))) + end + let unloaded = filter(copy(names), '!get(s:loaded, v:val, 0)') + if !empty(unloaded) + for name in unloaded + call s:lod([name], ['ftdetect', 'after/ftdetect', 'plugin', 'after/plugin']) + endfor + call s:dobufread(unloaded) + return 1 + end + return 0 +endfunction + +function! s:remove_triggers(name) + if !has_key(s:triggers, a:name) + return + endif + for cmd in s:triggers[a:name].cmd + execute 'silent! delc' cmd + endfor + for map in s:triggers[a:name].map + execute 'silent! unmap' map + execute 'silent! iunmap' map + endfor + call remove(s:triggers, a:name) +endfunction + +function! s:lod(names, types, ...) + for name in a:names + call s:remove_triggers(name) + let s:loaded[name] = 1 + endfor + call s:reorg_rtp() + + for name in a:names + let rtp = s:rtp(g:plugs[name]) + for dir in a:types + call s:source(rtp, dir.'/**/*.vim') + endfor + if a:0 + if !s:source(rtp, a:1) && !empty(s:glob(rtp, a:2)) + execute 'runtime' a:1 + endif + call s:source(rtp, a:2) + endif + call s:doautocmd('User', name) + endfor +endfunction + +function! s:lod_ft(pat, names) + let syn = 'syntax/'.a:pat.'.vim' + call s:lod(a:names, ['plugin', 'after/plugin'], syn, 'after/'.syn) + execute 'autocmd! PlugLOD FileType' a:pat + call s:doautocmd('filetypeplugin', 'FileType') + call s:doautocmd('filetypeindent', 'FileType') +endfunction + +function! s:lod_cmd(cmd, bang, l1, l2, args, names) + call s:lod(a:names, ['ftdetect', 'after/ftdetect', 'plugin', 'after/plugin']) + call s:dobufread(a:names) + execute printf('%s%s%s %s', (a:l1 == a:l2 ? '' : (a:l1.','.a:l2)), a:cmd, a:bang, a:args) +endfunction + +function! s:lod_map(map, names, with_prefix, prefix) + call s:lod(a:names, ['ftdetect', 'after/ftdetect', 'plugin', 'after/plugin']) + call s:dobufread(a:names) + let extra = '' + while 1 + let c = getchar(0) + if c == 0 + break + endif + let extra .= nr2char(c) + endwhile + + if a:with_prefix + let prefix = v:count ? v:count : '' + let prefix .= '"'.v:register.a:prefix + if mode(1) == 'no' + if v:operator == 'c' + let prefix = "\" . prefix + endif + let prefix .= v:operator + endif + call feedkeys(prefix, 'n') + endif + call feedkeys(substitute(a:map, '^', "\", '') . extra) +endfunction + +function! plug#(repo, ...) + if a:0 > 1 + return s:err('Invalid number of arguments (1..2)') + endif + + try + let repo = s:trim(a:repo) + let opts = a:0 == 1 ? s:parse_options(a:1) : s:base_spec + let name = get(opts, 'as', fnamemodify(repo, ':t:s?\.git$??')) + let spec = extend(s:infer_properties(name, repo), opts) + if !has_key(g:plugs, name) + call add(g:plugs_order, name) + endif + let g:plugs[name] = spec + let s:loaded[name] = get(s:loaded, name, 0) + catch + return s:err(v:exception) + endtry +endfunction + +function! s:parse_options(arg) + let opts = copy(s:base_spec) + let type = type(a:arg) + if type == s:TYPE.string + let opts.tag = a:arg + elseif type == s:TYPE.dict + call extend(opts, a:arg) + if has_key(opts, 'dir') + let opts.dir = s:dirpath(expand(opts.dir)) + endif + else + throw 'Invalid argument type (expected: string or dictionary)' + endif + return opts +endfunction + +function! s:infer_properties(name, repo) + let repo = a:repo + if s:is_local_plug(repo) + return { 'dir': s:dirpath(expand(repo)) } + else + if repo =~ ':' + let uri = repo + else + if repo !~ '/' + throw printf('Invalid argument: %s (implicit `vim-scripts'' expansion is deprecated)', repo) + endif + let fmt = get(g:, 'plug_url_format', 'https://git::@github.com/%s.git') + let uri = printf(fmt, repo) + endif + return { 'dir': s:dirpath(g:plug_home.'/'.a:name), 'uri': uri } + endif +endfunction + +function! s:install(force, names) + call s:update_impl(0, a:force, a:names) +endfunction + +function! s:update(force, names) + call s:update_impl(1, a:force, a:names) +endfunction + +function! plug#helptags() + if !exists('g:plugs') + return s:err('plug#begin was not called') + endif + for spec in values(g:plugs) + let docd = join([spec.dir, 'doc'], '/') + if isdirectory(docd) + silent! execute 'helptags' s:esc(docd) + endif + endfor + return 1 +endfunction + +function! s:syntax() + syntax clear + syntax region plug1 start=/\%1l/ end=/\%2l/ contains=plugNumber + syntax region plug2 start=/\%2l/ end=/\%3l/ contains=plugBracket,plugX + syn match plugNumber /[0-9]\+[0-9.]*/ contained + syn match plugBracket /[[\]]/ contained + syn match plugX /x/ contained + syn match plugDash /^-/ + syn match plugPlus /^+/ + syn match plugStar /^*/ + syn match plugMessage /\(^- \)\@<=.*/ + syn match plugName /\(^- \)\@<=[^ ]*:/ + syn match plugSha /\%(: \)\@<=[0-9a-f]\{4,}$/ + syn match plugTag /(tag: [^)]\+)/ + syn match plugInstall /\(^+ \)\@<=[^:]*/ + syn match plugUpdate /\(^* \)\@<=[^:]*/ + syn match plugCommit /^ \X*[0-9a-f]\{7,9} .*/ contains=plugRelDate,plugEdge,plugTag + syn match plugEdge /^ \X\+$/ + syn match plugEdge /^ \X*/ contained nextgroup=plugSha + syn match plugSha /[0-9a-f]\{7,9}/ contained + syn match plugRelDate /([^)]*)$/ contained + syn match plugNotLoaded /(not loaded)$/ + syn match plugError /^x.*/ + syn region plugDeleted start=/^\~ .*/ end=/^\ze\S/ + syn match plugH2 /^.*:\n-\+$/ + syn keyword Function PlugInstall PlugStatus PlugUpdate PlugClean + hi def link plug1 Title + hi def link plug2 Repeat + hi def link plugH2 Type + hi def link plugX Exception + hi def link plugBracket Structure + hi def link plugNumber Number + + hi def link plugDash Special + hi def link plugPlus Constant + hi def link plugStar Boolean + + hi def link plugMessage Function + hi def link plugName Label + hi def link plugInstall Function + hi def link plugUpdate Type + + hi def link plugError Error + hi def link plugDeleted Ignore + hi def link plugRelDate Comment + hi def link plugEdge PreProc + hi def link plugSha Identifier + hi def link plugTag Constant + + hi def link plugNotLoaded Comment +endfunction + +function! s:lpad(str, len) + return a:str . repeat(' ', a:len - len(a:str)) +endfunction + +function! s:lines(msg) + return split(a:msg, "[\r\n]") +endfunction + +function! s:lastline(msg) + return get(s:lines(a:msg), -1, '') +endfunction + +function! s:new_window() + execute get(g:, 'plug_window', 'vertical topleft new') +endfunction + +function! s:plug_window_exists() + let buflist = tabpagebuflist(s:plug_tab) + return !empty(buflist) && index(buflist, s:plug_buf) >= 0 +endfunction + +function! s:switch_in() + if !s:plug_window_exists() + return 0 + endif + + if winbufnr(0) != s:plug_buf + let s:pos = [tabpagenr(), winnr(), winsaveview()] + execute 'normal!' s:plug_tab.'gt' + let winnr = bufwinnr(s:plug_buf) + execute winnr.'wincmd w' + call add(s:pos, winsaveview()) + else + let s:pos = [winsaveview()] + endif + + setlocal modifiable + return 1 +endfunction + +function! s:switch_out(...) + call winrestview(s:pos[-1]) + setlocal nomodifiable + if a:0 > 0 + execute a:1 + endif + + if len(s:pos) > 1 + execute 'normal!' s:pos[0].'gt' + execute s:pos[1] 'wincmd w' + call winrestview(s:pos[2]) + endif +endfunction + +function! s:finish_bindings() + nnoremap R :call retry() + nnoremap D :PlugDiff + nnoremap S :PlugStatus + nnoremap U :call status_update() + xnoremap U :call status_update() + nnoremap ]] :silent! call section('') + nnoremap [[ :silent! call section('b') +endfunction + +function! s:prepare(...) + if empty(getcwd()) + throw 'Invalid current working directory. Cannot proceed.' + endif + + for evar in ['$GIT_DIR', '$GIT_WORK_TREE'] + if exists(evar) + throw evar.' detected. Cannot proceed.' + endif + endfor + + call s:job_abort() + if s:switch_in() + if b:plug_preview == 1 + pc + endif + enew + else + call s:new_window() + endif + + nnoremap q :if b:plug_preview==1pcendifbd + if a:0 == 0 + call s:finish_bindings() + endif + let b:plug_preview = -1 + let s:plug_tab = tabpagenr() + let s:plug_buf = winbufnr(0) + call s:assign_name() + + for k in ['', 'L', 'o', 'X', 'd', 'dd'] + execute 'silent! unmap ' k + endfor + setlocal buftype=nofile bufhidden=wipe nobuflisted nolist noswapfile nowrap cursorline modifiable nospell + setf vim-plug + if exists('g:syntax_on') + call s:syntax() + endif +endfunction + +function! s:assign_name() + " Assign buffer name + let prefix = '[Plugins]' + let name = prefix + let idx = 2 + while bufexists(name) + let name = printf('%s (%s)', prefix, idx) + let idx = idx + 1 + endwhile + silent! execute 'f' fnameescape(name) +endfunction + +function! s:chsh(swap) + let prev = [&shell, &shellredir] + if !s:is_win && a:swap + set shell=sh shellredir=>%s\ 2>&1 + endif + return prev +endfunction + +function! s:bang(cmd, ...) + try + let [sh, shrd] = s:chsh(a:0) + " FIXME: Escaping is incomplete. We could use shellescape with eval, + " but it won't work on Windows. + let cmd = a:0 ? s:with_cd(a:cmd, a:1) : a:cmd + let g:_plug_bang = '!'.escape(cmd, '#!%') + execute "normal! :execute g:_plug_bang\\" + finally + unlet g:_plug_bang + let [&shell, &shellredir] = [sh, shrd] + endtry + return v:shell_error ? 'Exit status: ' . v:shell_error : '' +endfunction + +function! s:regress_bar() + let bar = substitute(getline(2)[1:-2], '.*\zs=', 'x', '') + call s:progress_bar(2, bar, len(bar)) +endfunction + +function! s:is_updated(dir) + return !empty(s:system_chomp('git log --pretty=format:"%h" "HEAD...HEAD@{1}"', a:dir)) +endfunction + +function! s:do(pull, force, todo) + for [name, spec] in items(a:todo) + if !isdirectory(spec.dir) + continue + endif + let installed = has_key(s:update.new, name) + let updated = installed ? 0 : + \ (a:pull && index(s:update.errors, name) < 0 && s:is_updated(spec.dir)) + if a:force || installed || updated + execute 'cd' s:esc(spec.dir) + call append(3, '- Post-update hook for '. name .' ... ') + let error = '' + let type = type(spec.do) + if type == s:TYPE.string + if spec.do[0] == ':' + if !get(s:loaded, name, 0) + let s:loaded[name] = 1 + call s:reorg_rtp() + endif + call s:load_plugin(spec) + try + execute spec.do[1:] + catch + let error = v:exception + endtry + if !s:plug_window_exists() + cd - + throw 'Warning: vim-plug was terminated by the post-update hook of '.name + endif + else + let error = s:bang(spec.do) + endif + elseif type == s:TYPE.funcref + try + let status = installed ? 'installed' : (updated ? 'updated' : 'unchanged') + call spec.do({ 'name': name, 'status': status, 'force': a:force }) + catch + let error = v:exception + endtry + else + let error = 'Invalid hook type' + endif + call s:switch_in() + call setline(4, empty(error) ? (getline(4) . 'OK') + \ : ('x' . getline(4)[1:] . error)) + if !empty(error) + call add(s:update.errors, name) + call s:regress_bar() + endif + cd - + endif + endfor +endfunction + +function! s:hash_match(a, b) + return stridx(a:a, a:b) == 0 || stridx(a:b, a:a) == 0 +endfunction + +function! s:checkout(spec) + let sha = a:spec.commit + let output = s:system('git rev-parse HEAD', a:spec.dir) + if !v:shell_error && !s:hash_match(sha, s:lines(output)[0]) + let output = s:system( + \ 'git fetch --depth 999999 && git checkout '.s:esc(sha).' --', a:spec.dir) + endif + return output +endfunction + +function! s:finish(pull) + let new_frozen = len(filter(keys(s:update.new), 'g:plugs[v:val].frozen')) + if new_frozen + let s = new_frozen > 1 ? 's' : '' + call append(3, printf('- Installed %d frozen plugin%s', new_frozen, s)) + endif + call append(3, '- Finishing ... ') | 4 + redraw + call plug#helptags() + call plug#end() + call setline(4, getline(4) . 'Done!') + redraw + let msgs = [] + if !empty(s:update.errors) + call add(msgs, "Press 'R' to retry.") + endif + if a:pull && len(s:update.new) < len(filter(getline(5, '$'), + \ "v:val =~ '^- ' && stridx(v:val, 'Already up-to-date') < 0")) + call add(msgs, "Press 'D' to see the updated changes.") + endif + echo join(msgs, ' ') + call s:finish_bindings() +endfunction + +function! s:retry() + if empty(s:update.errors) + return + endif + echo + call s:update_impl(s:update.pull, s:update.force, + \ extend(copy(s:update.errors), [s:update.threads])) +endfunction + +function! s:is_managed(name) + return has_key(g:plugs[a:name], 'uri') +endfunction + +function! s:names(...) + return sort(filter(keys(g:plugs), 'stridx(v:val, a:1) == 0 && s:is_managed(v:val)')) +endfunction + +function! s:check_ruby() + silent! ruby require 'thread'; VIM::command("let g:plug_ruby = '#{RUBY_VERSION}'") + if !exists('g:plug_ruby') + redraw! + return s:warn('echom', 'Warning: Ruby interface is broken') + endif + let ruby_version = split(g:plug_ruby, '\.') + unlet g:plug_ruby + return s:version_requirement(ruby_version, [1, 8, 7]) +endfunction + +function! s:update_impl(pull, force, args) abort + let sync = index(a:args, '--sync') >= 0 || has('vim_starting') + let args = filter(copy(a:args), 'v:val != "--sync"') + let threads = (len(args) > 0 && args[-1] =~ '^[1-9][0-9]*$') ? + \ remove(args, -1) : get(g:, 'plug_threads', 16) + + let managed = filter(copy(g:plugs), 's:is_managed(v:key)') + let todo = empty(args) ? filter(managed, '!v:val.frozen || !isdirectory(v:val.dir)') : + \ filter(managed, 'index(args, v:key) >= 0') + + if empty(todo) + return s:warn('echo', 'No plugin to '. (a:pull ? 'update' : 'install')) + endif + + if !s:is_win && s:git_version_requirement(2, 3) + let s:git_terminal_prompt = exists('$GIT_TERMINAL_PROMPT') ? $GIT_TERMINAL_PROMPT : '' + let $GIT_TERMINAL_PROMPT = 0 + for plug in values(todo) + let plug.uri = substitute(plug.uri, + \ '^https://git::@github\.com', 'https://github.com', '') + endfor + endif + + if !isdirectory(g:plug_home) + try + call mkdir(g:plug_home, 'p') + catch + return s:err(printf('Invalid plug directory: %s. '. + \ 'Try to call plug#begin with a valid directory', g:plug_home)) + endtry + endif + + if has('nvim') && !exists('*jobwait') && threads > 1 + call s:warn('echom', '[vim-plug] Update Neovim for parallel installer') + endif + + let use_job = s:nvim || s:vim8 + let python = (has('python') || has('python3')) && !use_job + let ruby = has('ruby') && !use_job && (v:version >= 703 || v:version == 702 && has('patch374')) && !(s:is_win && has('gui_running')) && threads > 1 && s:check_ruby() + + let s:update = { + \ 'start': reltime(), + \ 'all': todo, + \ 'todo': copy(todo), + \ 'errors': [], + \ 'pull': a:pull, + \ 'force': a:force, + \ 'new': {}, + \ 'threads': (python || ruby || use_job) ? min([len(todo), threads]) : 1, + \ 'bar': '', + \ 'fin': 0 + \ } + + call s:prepare(1) + call append(0, ['', '']) + normal! 2G + silent! redraw + + let s:clone_opt = get(g:, 'plug_shallow', 1) ? + \ '--depth 1' . (s:git_version_requirement(1, 7, 10) ? ' --no-single-branch' : '') : '' + + if has('win32unix') + let s:clone_opt .= ' -c core.eol=lf -c core.autocrlf=input' + endif + + " Python version requirement (>= 2.7) + if python && !has('python3') && !ruby && !use_job && s:update.threads > 1 + redir => pyv + silent python import platform; print platform.python_version() + redir END + let python = s:version_requirement( + \ map(split(split(pyv)[0], '\.'), 'str2nr(v:val)'), [2, 6]) + endif + + if (python || ruby) && s:update.threads > 1 + try + let imd = &imd + if s:mac_gui + set noimd + endif + if ruby + call s:update_ruby() + else + call s:update_python() + endif + catch + let lines = getline(4, '$') + let printed = {} + silent! 4,$d _ + for line in lines + let name = s:extract_name(line, '.', '') + if empty(name) || !has_key(printed, name) + call append('$', line) + if !empty(name) + let printed[name] = 1 + if line[0] == 'x' && index(s:update.errors, name) < 0 + call add(s:update.errors, name) + end + endif + endif + endfor + finally + let &imd = imd + call s:update_finish() + endtry + else + call s:update_vim() + while use_job && sync + sleep 100m + if s:update.fin + break + endif + endwhile + endif +endfunction + +function! s:log4(name, msg) + call setline(4, printf('- %s (%s)', a:msg, a:name)) + redraw +endfunction + +function! s:update_finish() + if exists('s:git_terminal_prompt') + let $GIT_TERMINAL_PROMPT = s:git_terminal_prompt + endif + if s:switch_in() + call append(3, '- Updating ...') | 4 + for [name, spec] in items(filter(copy(s:update.all), 'index(s:update.errors, v:key) < 0 && (s:update.force || s:update.pull || has_key(s:update.new, v:key))')) + let [pos, _] = s:logpos(name) + if !pos + continue + endif + if has_key(spec, 'commit') + call s:log4(name, 'Checking out '.spec.commit) + let out = s:checkout(spec) + elseif has_key(spec, 'tag') + let tag = spec.tag + if tag =~ '\*' + let tags = s:lines(s:system('git tag --list '.s:shellesc(tag).' --sort -version:refname 2>&1', spec.dir)) + if !v:shell_error && !empty(tags) + let tag = tags[0] + call s:log4(name, printf('Latest tag for %s -> %s', spec.tag, tag)) + call append(3, '') + endif + endif + call s:log4(name, 'Checking out '.tag) + let out = s:system('git checkout -q '.s:esc(tag).' -- 2>&1', spec.dir) + else + let branch = s:esc(get(spec, 'branch', 'master')) + call s:log4(name, 'Merging origin/'.branch) + let out = s:system('git checkout -q '.branch.' -- 2>&1' + \. (has_key(s:update.new, name) ? '' : ('&& git merge --ff-only origin/'.branch.' 2>&1')), spec.dir) + endif + if !v:shell_error && filereadable(spec.dir.'/.gitmodules') && + \ (s:update.force || has_key(s:update.new, name) || s:is_updated(spec.dir)) + call s:log4(name, 'Updating submodules. This may take a while.') + let out .= s:bang('git submodule update --init --recursive 2>&1', spec.dir) + endif + let msg = s:format_message(v:shell_error ? 'x': '-', name, out) + if v:shell_error + call add(s:update.errors, name) + call s:regress_bar() + silent execute pos 'd _' + call append(4, msg) | 4 + elseif !empty(out) + call setline(pos, msg[0]) + endif + redraw + endfor + silent 4 d _ + try + call s:do(s:update.pull, s:update.force, filter(copy(s:update.all), 'index(s:update.errors, v:key) < 0 && has_key(v:val, "do")')) + catch + call s:warn('echom', v:exception) + call s:warn('echo', '') + return + endtry + call s:finish(s:update.pull) + call setline(1, 'Updated. Elapsed time: ' . split(reltimestr(reltime(s:update.start)))[0] . ' sec.') + call s:switch_out('normal! gg') + endif +endfunction + +function! s:job_abort() + if (!s:nvim && !s:vim8) || !exists('s:jobs') + return + endif + + for [name, j] in items(s:jobs) + if s:nvim + silent! call jobstop(j.jobid) + elseif s:vim8 + silent! call job_stop(j.jobid) + endif + if j.new + call s:system('rm -rf ' . s:shellesc(g:plugs[name].dir)) + endif + endfor + let s:jobs = {} +endfunction + +function! s:last_non_empty_line(lines) + let len = len(a:lines) + for idx in range(len) + let line = a:lines[len-idx-1] + if !empty(line) + return line + endif + endfor + return '' +endfunction + +function! s:job_out_cb(self, data) abort + let self = a:self + let data = remove(self.lines, -1) . a:data + let lines = map(split(data, "\n", 1), 'split(v:val, "\r", 1)[-1]') + call extend(self.lines, lines) + " To reduce the number of buffer updates + let self.tick = get(self, 'tick', -1) + 1 + if !self.running || self.tick % len(s:jobs) == 0 + let bullet = self.running ? (self.new ? '+' : '*') : (self.error ? 'x' : '-') + let result = self.error ? join(self.lines, "\n") : s:last_non_empty_line(self.lines) + call s:log(bullet, self.name, result) + endif +endfunction + +function! s:job_exit_cb(self, data) abort + let a:self.running = 0 + let a:self.error = a:data != 0 + call s:reap(a:self.name) + call s:tick() +endfunction + +function! s:job_cb(fn, job, ch, data) + if !s:plug_window_exists() " plug window closed + return s:job_abort() + endif + call call(a:fn, [a:job, a:data]) +endfunction + +function! s:nvim_cb(job_id, data, event) dict abort + return a:event == 'stdout' ? + \ s:job_cb('s:job_out_cb', self, 0, join(a:data, "\n")) : + \ s:job_cb('s:job_exit_cb', self, 0, a:data) +endfunction + +function! s:spawn(name, cmd, opts) + let job = { 'name': a:name, 'running': 1, 'error': 0, 'lines': [''], + \ 'new': get(a:opts, 'new', 0) } + let s:jobs[a:name] = job + let argv = add(s:is_win ? ['cmd', '/c'] : ['sh', '-c'], + \ has_key(a:opts, 'dir') ? s:with_cd(a:cmd, a:opts.dir) : a:cmd) + + if s:nvim + call extend(job, { + \ 'on_stdout': function('s:nvim_cb'), + \ 'on_exit': function('s:nvim_cb'), + \ }) + let jid = jobstart(argv, job) + if jid > 0 + let job.jobid = jid + else + let job.running = 0 + let job.error = 1 + let job.lines = [jid < 0 ? argv[0].' is not executable' : + \ 'Invalid arguments (or job table is full)'] + endif + elseif s:vim8 + let jid = job_start(s:is_win ? join(argv, ' ') : argv, { + \ 'out_cb': function('s:job_cb', ['s:job_out_cb', job]), + \ 'exit_cb': function('s:job_cb', ['s:job_exit_cb', job]), + \ 'out_mode': 'raw' + \}) + if job_status(jid) == 'run' + let job.jobid = jid + else + let job.running = 0 + let job.error = 1 + let job.lines = ['Failed to start job'] + endif + else + let params = has_key(a:opts, 'dir') ? [a:cmd, a:opts.dir] : [a:cmd] + let job.lines = s:lines(call('s:system', params)) + let job.error = v:shell_error != 0 + let job.running = 0 + endif +endfunction + +function! s:reap(name) + let job = s:jobs[a:name] + if job.error + call add(s:update.errors, a:name) + elseif get(job, 'new', 0) + let s:update.new[a:name] = 1 + endif + let s:update.bar .= job.error ? 'x' : '=' + + let bullet = job.error ? 'x' : '-' + let result = job.error ? join(job.lines, "\n") : s:last_non_empty_line(job.lines) + call s:log(bullet, a:name, empty(result) ? 'OK' : result) + call s:bar() + + call remove(s:jobs, a:name) +endfunction + +function! s:bar() + if s:switch_in() + let total = len(s:update.all) + call setline(1, (s:update.pull ? 'Updating' : 'Installing'). + \ ' plugins ('.len(s:update.bar).'/'.total.')') + call s:progress_bar(2, s:update.bar, total) + call s:switch_out() + endif +endfunction + +function! s:logpos(name) + for i in range(4, line('$')) + if getline(i) =~# '^[-+x*] '.a:name.':' + for j in range(i + 1, line('$')) + if getline(j) !~ '^ ' + return [i, j - 1] + endif + endfor + return [i, i] + endif + endfor + return [0, 0] +endfunction + +function! s:log(bullet, name, lines) + if s:switch_in() + let [b, e] = s:logpos(a:name) + if b > 0 + silent execute printf('%d,%d d _', b, e) + if b > winheight('.') + let b = 4 + endif + else + let b = 4 + endif + " FIXME For some reason, nomodifiable is set after :d in vim8 + setlocal modifiable + call append(b - 1, s:format_message(a:bullet, a:name, a:lines)) + call s:switch_out() + endif +endfunction + +function! s:update_vim() + let s:jobs = {} + + call s:bar() + call s:tick() +endfunction + +function! s:tick() + let pull = s:update.pull + let prog = s:progress_opt(s:nvim || s:vim8) +while 1 " Without TCO, Vim stack is bound to explode + if empty(s:update.todo) + if empty(s:jobs) && !s:update.fin + call s:update_finish() + let s:update.fin = 1 + endif + return + endif + + let name = keys(s:update.todo)[0] + let spec = remove(s:update.todo, name) + let new = !isdirectory(spec.dir) + + call s:log(new ? '+' : '*', name, pull ? 'Updating ...' : 'Installing ...') + redraw + + let has_tag = has_key(spec, 'tag') + if !new + let [error, _] = s:git_validate(spec, 0) + if empty(error) + if pull + let fetch_opt = (has_tag && !empty(globpath(spec.dir, '.git/shallow'))) ? '--depth 99999999' : '' + call s:spawn(name, printf('git fetch %s %s 2>&1', fetch_opt, prog), { 'dir': spec.dir }) + else + let s:jobs[name] = { 'running': 0, 'lines': ['Already installed'], 'error': 0 } + endif + else + let s:jobs[name] = { 'running': 0, 'lines': s:lines(error), 'error': 1 } + endif + else + call s:spawn(name, + \ printf('git clone %s %s %s %s 2>&1', + \ has_tag ? '' : s:clone_opt, + \ prog, + \ s:shellesc(spec.uri), + \ s:shellesc(s:trim(spec.dir))), { 'new': 1 }) + endif + + if !s:jobs[name].running + call s:reap(name) + endif + if len(s:jobs) >= s:update.threads + break + endif +endwhile +endfunction + +function! s:update_python() +let py_exe = has('python') ? 'python' : 'python3' +execute py_exe "<< EOF" +import datetime +import functools +import os +try: + import queue +except ImportError: + import Queue as queue +import random +import re +import shutil +import signal +import subprocess +import tempfile +import threading as thr +import time +import traceback +import vim + +G_NVIM = vim.eval("has('nvim')") == '1' +G_PULL = vim.eval('s:update.pull') == '1' +G_RETRIES = int(vim.eval('get(g:, "plug_retries", 2)')) + 1 +G_TIMEOUT = int(vim.eval('get(g:, "plug_timeout", 60)')) +G_CLONE_OPT = vim.eval('s:clone_opt') +G_PROGRESS = vim.eval('s:progress_opt(1)') +G_LOG_PROB = 1.0 / int(vim.eval('s:update.threads')) +G_STOP = thr.Event() +G_IS_WIN = vim.eval('s:is_win') == '1' + +class PlugError(Exception): + def __init__(self, msg): + self.msg = msg +class CmdTimedOut(PlugError): + pass +class CmdFailed(PlugError): + pass +class InvalidURI(PlugError): + pass +class Action(object): + INSTALL, UPDATE, ERROR, DONE = ['+', '*', 'x', '-'] + +class Buffer(object): + def __init__(self, lock, num_plugs, is_pull): + self.bar = '' + self.event = 'Updating' if is_pull else 'Installing' + self.lock = lock + self.maxy = int(vim.eval('winheight(".")')) + self.num_plugs = num_plugs + + def __where(self, name): + """ Find first line with name in current buffer. Return line num. """ + found, lnum = False, 0 + matcher = re.compile('^[-+x*] {0}:'.format(name)) + for line in vim.current.buffer: + if matcher.search(line) is not None: + found = True + break + lnum += 1 + + if not found: + lnum = -1 + return lnum + + def header(self): + curbuf = vim.current.buffer + curbuf[0] = self.event + ' plugins ({0}/{1})'.format(len(self.bar), self.num_plugs) + + num_spaces = self.num_plugs - len(self.bar) + curbuf[1] = '[{0}{1}]'.format(self.bar, num_spaces * ' ') + + with self.lock: + vim.command('normal! 2G') + vim.command('redraw') + + def write(self, action, name, lines): + first, rest = lines[0], lines[1:] + msg = ['{0} {1}{2}{3}'.format(action, name, ': ' if first else '', first)] + msg.extend([' ' + line for line in rest]) + + try: + if action == Action.ERROR: + self.bar += 'x' + vim.command("call add(s:update.errors, '{0}')".format(name)) + elif action == Action.DONE: + self.bar += '=' + + curbuf = vim.current.buffer + lnum = self.__where(name) + if lnum != -1: # Found matching line num + del curbuf[lnum] + if lnum > self.maxy and action in set([Action.INSTALL, Action.UPDATE]): + lnum = 3 + else: + lnum = 3 + curbuf.append(msg, lnum) + + self.header() + except vim.error: + pass + +class Command(object): + CD = 'cd /d' if G_IS_WIN else 'cd' + + def __init__(self, cmd, cmd_dir=None, timeout=60, cb=None, clean=None): + self.cmd = cmd + if cmd_dir: + self.cmd = '{0} {1} && {2}'.format(Command.CD, cmd_dir, self.cmd) + self.timeout = timeout + self.callback = cb if cb else (lambda msg: None) + self.clean = clean if clean else (lambda: None) + self.proc = None + + @property + def alive(self): + """ Returns true only if command still running. """ + return self.proc and self.proc.poll() is None + + def execute(self, ntries=3): + """ Execute the command with ntries if CmdTimedOut. + Returns the output of the command if no Exception. + """ + attempt, finished, limit = 0, False, self.timeout + + while not finished: + try: + attempt += 1 + result = self.try_command() + finished = True + return result + except CmdTimedOut: + if attempt != ntries: + self.notify_retry() + self.timeout += limit + else: + raise + + def notify_retry(self): + """ Retry required for command, notify user. """ + for count in range(3, 0, -1): + if G_STOP.is_set(): + raise KeyboardInterrupt + msg = 'Timeout. Will retry in {0} second{1} ...'.format( + count, 's' if count != 1 else '') + self.callback([msg]) + time.sleep(1) + self.callback(['Retrying ...']) + + def try_command(self): + """ Execute a cmd & poll for callback. Returns list of output. + Raises CmdFailed -> return code for Popen isn't 0 + Raises CmdTimedOut -> command exceeded timeout without new output + """ + first_line = True + + try: + tfile = tempfile.NamedTemporaryFile(mode='w+b') + preexec_fn = not G_IS_WIN and os.setsid or None + self.proc = subprocess.Popen(self.cmd, stdout=tfile, + stderr=subprocess.STDOUT, + stdin=subprocess.PIPE, shell=True, + preexec_fn=preexec_fn) + thrd = thr.Thread(target=(lambda proc: proc.wait()), args=(self.proc,)) + thrd.start() + + thread_not_started = True + while thread_not_started: + try: + thrd.join(0.1) + thread_not_started = False + except RuntimeError: + pass + + while self.alive: + if G_STOP.is_set(): + raise KeyboardInterrupt + + if first_line or random.random() < G_LOG_PROB: + first_line = False + line = '' if G_IS_WIN else nonblock_read(tfile.name) + if line: + self.callback([line]) + + time_diff = time.time() - os.path.getmtime(tfile.name) + if time_diff > self.timeout: + raise CmdTimedOut(['Timeout!']) + + thrd.join(0.5) + + tfile.seek(0) + result = [line.decode('utf-8', 'replace').rstrip() for line in tfile] + + if self.proc.returncode != 0: + raise CmdFailed([''] + result) + + return result + except: + self.terminate() + raise + + def terminate(self): + """ Terminate process and cleanup. """ + if self.alive: + if G_IS_WIN: + os.kill(self.proc.pid, signal.SIGINT) + else: + os.killpg(self.proc.pid, signal.SIGTERM) + self.clean() + +class Plugin(object): + def __init__(self, name, args, buf_q, lock): + self.name = name + self.args = args + self.buf_q = buf_q + self.lock = lock + self.tag = args.get('tag', 0) + + def manage(self): + try: + if os.path.exists(self.args['dir']): + self.update() + else: + self.install() + with self.lock: + thread_vim_command("let s:update.new['{0}'] = 1".format(self.name)) + except PlugError as exc: + self.write(Action.ERROR, self.name, exc.msg) + except KeyboardInterrupt: + G_STOP.set() + self.write(Action.ERROR, self.name, ['Interrupted!']) + except: + # Any exception except those above print stack trace + msg = 'Trace:\n{0}'.format(traceback.format_exc().rstrip()) + self.write(Action.ERROR, self.name, msg.split('\n')) + raise + + def install(self): + target = self.args['dir'] + if target[-1] == '\\': + target = target[0:-1] + + def clean(target): + def _clean(): + try: + shutil.rmtree(target) + except OSError: + pass + return _clean + + self.write(Action.INSTALL, self.name, ['Installing ...']) + callback = functools.partial(self.write, Action.INSTALL, self.name) + cmd = 'git clone {0} {1} {2} {3} 2>&1'.format( + '' if self.tag else G_CLONE_OPT, G_PROGRESS, self.args['uri'], + esc(target)) + com = Command(cmd, None, G_TIMEOUT, callback, clean(target)) + result = com.execute(G_RETRIES) + self.write(Action.DONE, self.name, result[-1:]) + + def repo_uri(self): + cmd = 'git rev-parse --abbrev-ref HEAD 2>&1 && git config -f .git/config remote.origin.url' + command = Command(cmd, self.args['dir'], G_TIMEOUT,) + result = command.execute(G_RETRIES) + return result[-1] + + def update(self): + actual_uri = self.repo_uri() + expect_uri = self.args['uri'] + regex = re.compile(r'^(?:\w+://)?(?:[^@/]*@)?([^:/]*(?::[0-9]*)?)[:/](.*?)(?:\.git)?/?$') + ma = regex.match(actual_uri) + mb = regex.match(expect_uri) + if ma is None or mb is None or ma.groups() != mb.groups(): + msg = ['', + 'Invalid URI: {0}'.format(actual_uri), + 'Expected {0}'.format(expect_uri), + 'PlugClean required.'] + raise InvalidURI(msg) + + if G_PULL: + self.write(Action.UPDATE, self.name, ['Updating ...']) + callback = functools.partial(self.write, Action.UPDATE, self.name) + fetch_opt = '--depth 99999999' if self.tag and os.path.isfile(os.path.join(self.args['dir'], '.git/shallow')) else '' + cmd = 'git fetch {0} {1} 2>&1'.format(fetch_opt, G_PROGRESS) + com = Command(cmd, self.args['dir'], G_TIMEOUT, callback) + result = com.execute(G_RETRIES) + self.write(Action.DONE, self.name, result[-1:]) + else: + self.write(Action.DONE, self.name, ['Already installed']) + + def write(self, action, name, msg): + self.buf_q.put((action, name, msg)) + +class PlugThread(thr.Thread): + def __init__(self, tname, args): + super(PlugThread, self).__init__() + self.tname = tname + self.args = args + + def run(self): + thr.current_thread().name = self.tname + buf_q, work_q, lock = self.args + + try: + while not G_STOP.is_set(): + name, args = work_q.get_nowait() + plug = Plugin(name, args, buf_q, lock) + plug.manage() + work_q.task_done() + except queue.Empty: + pass + +class RefreshThread(thr.Thread): + def __init__(self, lock): + super(RefreshThread, self).__init__() + self.lock = lock + self.running = True + + def run(self): + while self.running: + with self.lock: + thread_vim_command('noautocmd normal! a') + time.sleep(0.33) + + def stop(self): + self.running = False + +if G_NVIM: + def thread_vim_command(cmd): + vim.session.threadsafe_call(lambda: vim.command(cmd)) +else: + def thread_vim_command(cmd): + vim.command(cmd) + +def esc(name): + return '"' + name.replace('"', '\"') + '"' + +def nonblock_read(fname): + """ Read a file with nonblock flag. Return the last line. """ + fread = os.open(fname, os.O_RDONLY | os.O_NONBLOCK) + buf = os.read(fread, 100000).decode('utf-8', 'replace') + os.close(fread) + + line = buf.rstrip('\r\n') + left = max(line.rfind('\r'), line.rfind('\n')) + if left != -1: + left += 1 + line = line[left:] + + return line + +def main(): + thr.current_thread().name = 'main' + nthreads = int(vim.eval('s:update.threads')) + plugs = vim.eval('s:update.todo') + mac_gui = vim.eval('s:mac_gui') == '1' + + lock = thr.Lock() + buf = Buffer(lock, len(plugs), G_PULL) + buf_q, work_q = queue.Queue(), queue.Queue() + for work in plugs.items(): + work_q.put(work) + + start_cnt = thr.active_count() + for num in range(nthreads): + tname = 'PlugT-{0:02}'.format(num) + thread = PlugThread(tname, (buf_q, work_q, lock)) + thread.start() + if mac_gui: + rthread = RefreshThread(lock) + rthread.start() + + while not buf_q.empty() or thr.active_count() != start_cnt: + try: + action, name, msg = buf_q.get(True, 0.25) + buf.write(action, name, ['OK'] if not msg else msg) + buf_q.task_done() + except queue.Empty: + pass + except KeyboardInterrupt: + G_STOP.set() + + if mac_gui: + rthread.stop() + rthread.join() + +main() +EOF +endfunction + +function! s:update_ruby() + ruby << EOF + module PlugStream + SEP = ["\r", "\n", nil] + def get_line + buffer = '' + loop do + char = readchar rescue return + if SEP.include? char.chr + buffer << $/ + break + else + buffer << char + end + end + buffer + end + end unless defined?(PlugStream) + + def esc arg + %["#{arg.gsub('"', '\"')}"] + end + + def killall pid + pids = [pid] + if /mswin|mingw|bccwin/ =~ RUBY_PLATFORM + pids.each { |pid| Process.kill 'INT', pid.to_i rescue nil } + else + unless `which pgrep 2> /dev/null`.empty? + children = pids + until children.empty? + children = children.map { |pid| + `pgrep -P #{pid}`.lines.map { |l| l.chomp } + }.flatten + pids += children + end + end + pids.each { |pid| Process.kill 'TERM', pid.to_i rescue nil } + end + end + + def compare_git_uri a, b + regex = %r{^(?:\w+://)?(?:[^@/]*@)?([^:/]*(?::[0-9]*)?)[:/](.*?)(?:\.git)?/?$} + regex.match(a).to_a.drop(1) == regex.match(b).to_a.drop(1) + end + + require 'thread' + require 'fileutils' + require 'timeout' + running = true + iswin = VIM::evaluate('s:is_win').to_i == 1 + pull = VIM::evaluate('s:update.pull').to_i == 1 + base = VIM::evaluate('g:plug_home') + all = VIM::evaluate('s:update.todo') + limit = VIM::evaluate('get(g:, "plug_timeout", 60)') + tries = VIM::evaluate('get(g:, "plug_retries", 2)') + 1 + nthr = VIM::evaluate('s:update.threads').to_i + maxy = VIM::evaluate('winheight(".")').to_i + vim7 = VIM::evaluate('v:version').to_i <= 703 && RUBY_PLATFORM =~ /darwin/ + cd = iswin ? 'cd /d' : 'cd' + tot = VIM::evaluate('len(s:update.todo)') || 0 + bar = '' + skip = 'Already installed' + mtx = Mutex.new + take1 = proc { mtx.synchronize { running && all.shift } } + logh = proc { + cnt = bar.length + $curbuf[1] = "#{pull ? 'Updating' : 'Installing'} plugins (#{cnt}/#{tot})" + $curbuf[2] = '[' + bar.ljust(tot) + ']' + VIM::command('normal! 2G') + VIM::command('redraw') + } + where = proc { |name| (1..($curbuf.length)).find { |l| $curbuf[l] =~ /^[-+x*] #{name}:/ } } + log = proc { |name, result, type| + mtx.synchronize do + ing = ![true, false].include?(type) + bar += type ? '=' : 'x' unless ing + b = case type + when :install then '+' when :update then '*' + when true, nil then '-' else + VIM::command("call add(s:update.errors, '#{name}')") + 'x' + end + result = + if type || type.nil? + ["#{b} #{name}: #{result.lines.to_a.last || 'OK'}"] + elsif result =~ /^Interrupted|^Timeout/ + ["#{b} #{name}: #{result}"] + else + ["#{b} #{name}"] + result.lines.map { |l| " " << l } + end + if lnum = where.call(name) + $curbuf.delete lnum + lnum = 4 if ing && lnum > maxy + end + result.each_with_index do |line, offset| + $curbuf.append((lnum || 4) - 1 + offset, line.gsub(/\e\[./, '').chomp) + end + logh.call + end + } + bt = proc { |cmd, name, type, cleanup| + tried = timeout = 0 + begin + tried += 1 + timeout += limit + fd = nil + data = '' + if iswin + Timeout::timeout(timeout) do + tmp = VIM::evaluate('tempname()') + system("(#{cmd}) > #{tmp}") + data = File.read(tmp).chomp + File.unlink tmp rescue nil + end + else + fd = IO.popen(cmd).extend(PlugStream) + first_line = true + log_prob = 1.0 / nthr + while line = Timeout::timeout(timeout) { fd.get_line } + data << line + log.call name, line.chomp, type if name && (first_line || rand < log_prob) + first_line = false + end + fd.close + end + [$? == 0, data.chomp] + rescue Timeout::Error, Interrupt => e + if fd && !fd.closed? + killall fd.pid + fd.close + end + cleanup.call if cleanup + if e.is_a?(Timeout::Error) && tried < tries + 3.downto(1) do |countdown| + s = countdown > 1 ? 's' : '' + log.call name, "Timeout. Will retry in #{countdown} second#{s} ...", type + sleep 1 + end + log.call name, 'Retrying ...', type + retry + end + [false, e.is_a?(Interrupt) ? "Interrupted!" : "Timeout!"] + end + } + main = Thread.current + threads = [] + watcher = Thread.new { + if vim7 + while VIM::evaluate('getchar(1)') + sleep 0.1 + end + else + require 'io/console' # >= Ruby 1.9 + nil until IO.console.getch == 3.chr + end + mtx.synchronize do + running = false + threads.each { |t| t.raise Interrupt } unless vim7 + end + threads.each { |t| t.join rescue nil } + main.kill + } + refresh = Thread.new { + while true + mtx.synchronize do + break unless running + VIM::command('noautocmd normal! a') + end + sleep 0.2 + end + } if VIM::evaluate('s:mac_gui') == 1 + + clone_opt = VIM::evaluate('s:clone_opt') + progress = VIM::evaluate('s:progress_opt(1)') + nthr.times do + mtx.synchronize do + threads << Thread.new { + while pair = take1.call + name = pair.first + dir, uri, tag = pair.last.values_at *%w[dir uri tag] + exists = File.directory? dir + ok, result = + if exists + chdir = "#{cd} #{iswin ? dir : esc(dir)}" + ret, data = bt.call "#{chdir} && git rev-parse --abbrev-ref HEAD 2>&1 && git config -f .git/config remote.origin.url", nil, nil, nil + current_uri = data.lines.to_a.last + if !ret + if data =~ /^Interrupted|^Timeout/ + [false, data] + else + [false, [data.chomp, "PlugClean required."].join($/)] + end + elsif !compare_git_uri(current_uri, uri) + [false, ["Invalid URI: #{current_uri}", + "Expected: #{uri}", + "PlugClean required."].join($/)] + else + if pull + log.call name, 'Updating ...', :update + fetch_opt = (tag && File.exist?(File.join(dir, '.git/shallow'))) ? '--depth 99999999' : '' + bt.call "#{chdir} && git fetch #{fetch_opt} #{progress} 2>&1", name, :update, nil + else + [true, skip] + end + end + else + d = esc dir.sub(%r{[\\/]+$}, '') + log.call name, 'Installing ...', :install + bt.call "git clone #{clone_opt unless tag} #{progress} #{uri} #{d} 2>&1", name, :install, proc { + FileUtils.rm_rf dir + } + end + mtx.synchronize { VIM::command("let s:update.new['#{name}'] = 1") } if !exists && ok + log.call name, result, ok + end + } if running + end + end + threads.each { |t| t.join rescue nil } + logh.call + refresh.kill if refresh + watcher.kill +EOF +endfunction + +function! s:shellesc(arg) + return '"'.escape(a:arg, '"').'"' +endfunction + +function! s:glob_dir(path) + return map(filter(s:glob(a:path, '**'), 'isdirectory(v:val)'), 's:dirpath(v:val)') +endfunction + +function! s:progress_bar(line, bar, total) + call setline(a:line, '[' . s:lpad(a:bar, a:total) . ']') +endfunction + +function! s:compare_git_uri(a, b) + " See `git help clone' + " https:// [user@] github.com[:port] / junegunn/vim-plug [.git] + " [git@] github.com[:port] : junegunn/vim-plug [.git] + " file:// / junegunn/vim-plug [/] + " / junegunn/vim-plug [/] + let pat = '^\%(\w\+://\)\='.'\%([^@/]*@\)\='.'\([^:/]*\%(:[0-9]*\)\=\)'.'[:/]'.'\(.\{-}\)'.'\%(\.git\)\=/\?$' + let ma = matchlist(a:a, pat) + let mb = matchlist(a:b, pat) + return ma[1:2] ==# mb[1:2] +endfunction + +function! s:format_message(bullet, name, message) + if a:bullet != 'x' + return [printf('%s %s: %s', a:bullet, a:name, s:lastline(a:message))] + else + let lines = map(s:lines(a:message), '" ".v:val') + return extend([printf('x %s:', a:name)], lines) + endif +endfunction + +function! s:with_cd(cmd, dir) + return printf('cd%s %s && %s', s:is_win ? ' /d' : '', s:shellesc(a:dir), a:cmd) +endfunction + +function! s:system(cmd, ...) + try + let [sh, shrd] = s:chsh(1) + let cmd = a:0 > 0 ? s:with_cd(a:cmd, a:1) : a:cmd + return system(s:is_win ? '('.cmd.')' : cmd) + finally + let [&shell, &shellredir] = [sh, shrd] + endtry +endfunction + +function! s:system_chomp(...) + let ret = call('s:system', a:000) + return v:shell_error ? '' : substitute(ret, '\n$', '', '') +endfunction + +function! s:git_validate(spec, check_branch) + let err = '' + if isdirectory(a:spec.dir) + let result = s:lines(s:system('git rev-parse --abbrev-ref HEAD 2>&1 && git config -f .git/config remote.origin.url', a:spec.dir)) + let remote = result[-1] + if v:shell_error + let err = join([remote, 'PlugClean required.'], "\n") + elseif !s:compare_git_uri(remote, a:spec.uri) + let err = join(['Invalid URI: '.remote, + \ 'Expected: '.a:spec.uri, + \ 'PlugClean required.'], "\n") + elseif a:check_branch && has_key(a:spec, 'commit') + let result = s:lines(s:system('git rev-parse HEAD 2>&1', a:spec.dir)) + let sha = result[-1] + if v:shell_error + let err = join(add(result, 'PlugClean required.'), "\n") + elseif !s:hash_match(sha, a:spec.commit) + let err = join([printf('Invalid HEAD (expected: %s, actual: %s)', + \ a:spec.commit[:6], sha[:6]), + \ 'PlugUpdate required.'], "\n") + endif + elseif a:check_branch + let branch = result[0] + " Check tag + if has_key(a:spec, 'tag') + let tag = s:system_chomp('git describe --exact-match --tags HEAD 2>&1', a:spec.dir) + if a:spec.tag !=# tag && a:spec.tag !~ '\*' + let err = printf('Invalid tag: %s (expected: %s). Try PlugUpdate.', + \ (empty(tag) ? 'N/A' : tag), a:spec.tag) + endif + " Check branch + elseif a:spec.branch !=# branch + let err = printf('Invalid branch: %s (expected: %s). Try PlugUpdate.', + \ branch, a:spec.branch) + endif + if empty(err) + let [ahead, behind] = split(s:lastline(s:system(printf( + \ 'git rev-list --count --left-right HEAD...origin/%s', + \ a:spec.branch), a:spec.dir)), '\t') + if !v:shell_error && ahead + if behind + " Only mention PlugClean if diverged, otherwise it's likely to be + " pushable (and probably not that messed up). + let err = printf( + \ "Diverged from origin/%s (%d commit(s) ahead and %d commit(s) behind!\n" + \ .'Backup local changes and run PlugClean and PlugUpdate to reinstall it.', a:spec.branch, ahead, behind) + else + let err = printf("Ahead of origin/%s by %d commit(s).\n" + \ .'Cannot update until local changes are pushed.', + \ a:spec.branch, ahead) + endif + endif + endif + endif + else + let err = 'Not found' + endif + return [err, err =~# 'PlugClean'] +endfunction + +function! s:rm_rf(dir) + if isdirectory(a:dir) + call s:system((s:is_win ? 'rmdir /S /Q ' : 'rm -rf ') . s:shellesc(a:dir)) + endif +endfunction + +function! s:clean(force) + call s:prepare() + call append(0, 'Searching for invalid plugins in '.g:plug_home) + call append(1, '') + + " List of valid directories + let dirs = [] + let errs = {} + let [cnt, total] = [0, len(g:plugs)] + for [name, spec] in items(g:plugs) + if !s:is_managed(name) + call add(dirs, spec.dir) + else + let [err, clean] = s:git_validate(spec, 1) + if clean + let errs[spec.dir] = s:lines(err)[0] + else + call add(dirs, spec.dir) + endif + endif + let cnt += 1 + call s:progress_bar(2, repeat('=', cnt), total) + normal! 2G + redraw + endfor + + let allowed = {} + for dir in dirs + let allowed[s:dirpath(fnamemodify(dir, ':h:h'))] = 1 + let allowed[dir] = 1 + for child in s:glob_dir(dir) + let allowed[child] = 1 + endfor + endfor + + let todo = [] + let found = sort(s:glob_dir(g:plug_home)) + while !empty(found) + let f = remove(found, 0) + if !has_key(allowed, f) && isdirectory(f) + call add(todo, f) + call append(line('$'), '- ' . f) + if has_key(errs, f) + call append(line('$'), ' ' . errs[f]) + endif + let found = filter(found, 'stridx(v:val, f) != 0') + end + endwhile + + 4 + redraw + if empty(todo) + call append(line('$'), 'Already clean.') + else + let s:clean_count = 0 + call append(3, ['Directories to delete:', '']) + redraw! + if a:force || s:ask_no_interrupt('Delete all directories?') + call s:delete([6, line('$')], 1) + else + call setline(4, 'Cancelled.') + nnoremap d :set opfunc=delete_opg@ + nmap dd d_ + xnoremap d :call delete_op(visualmode(), 1) + echo 'Delete the lines (d{motion}) to delete the corresponding directories' + endif + endif + 4 + setlocal nomodifiable +endfunction + +function! s:delete_op(type, ...) + call s:delete(a:0 ? [line("'<"), line("'>")] : [line("'["), line("']")], 0) +endfunction + +function! s:delete(range, force) + let [l1, l2] = a:range + let force = a:force + while l1 <= l2 + let line = getline(l1) + if line =~ '^- ' && isdirectory(line[2:]) + execute l1 + redraw! + let answer = force ? 1 : s:ask('Delete '.line[2:].'?', 1) + let force = force || answer > 1 + if answer + call s:rm_rf(line[2:]) + setlocal modifiable + call setline(l1, '~'.line[1:]) + let s:clean_count += 1 + call setline(4, printf('Removed %d directories.', s:clean_count)) + setlocal nomodifiable + endif + endif + let l1 += 1 + endwhile +endfunction + +function! s:upgrade() + echo 'Downloading the latest version of vim-plug' + redraw + let tmp = tempname() + let new = tmp . '/plug.vim' + + try + let out = s:system(printf('git clone --depth 1 %s %s', s:plug_src, tmp)) + if v:shell_error + return s:err('Error upgrading vim-plug: '. out) + endif + + if readfile(s:me) ==# readfile(new) + echo 'vim-plug is already up-to-date' + return 0 + else + call rename(s:me, s:me . '.old') + call rename(new, s:me) + unlet g:loaded_plug + echo 'vim-plug has been upgraded' + return 1 + endif + finally + silent! call s:rm_rf(tmp) + endtry +endfunction + +function! s:upgrade_specs() + for spec in values(g:plugs) + let spec.frozen = get(spec, 'frozen', 0) + endfor +endfunction + +function! s:status() + call s:prepare() + call append(0, 'Checking plugins') + call append(1, '') + + let ecnt = 0 + let unloaded = 0 + let [cnt, total] = [0, len(g:plugs)] + for [name, spec] in items(g:plugs) + if has_key(spec, 'uri') + if isdirectory(spec.dir) + let [err, _] = s:git_validate(spec, 1) + let [valid, msg] = [empty(err), empty(err) ? 'OK' : err] + else + let [valid, msg] = [0, 'Not found. Try PlugInstall.'] + endif + else + if isdirectory(spec.dir) + let [valid, msg] = [1, 'OK'] + else + let [valid, msg] = [0, 'Not found.'] + endif + endif + let cnt += 1 + let ecnt += !valid + " `s:loaded` entry can be missing if PlugUpgraded + if valid && get(s:loaded, name, -1) == 0 + let unloaded = 1 + let msg .= ' (not loaded)' + endif + call s:progress_bar(2, repeat('=', cnt), total) + call append(3, s:format_message(valid ? '-' : 'x', name, msg)) + normal! 2G + redraw + endfor + call setline(1, 'Finished. '.ecnt.' error(s).') + normal! gg + setlocal nomodifiable + if unloaded + echo "Press 'L' on each line to load plugin, or 'U' to update" + nnoremap L :call status_load(line('.')) + xnoremap L :call status_load(line('.')) + end +endfunction + +function! s:extract_name(str, prefix, suffix) + return matchstr(a:str, '^'.a:prefix.' \zs[^:]\+\ze:.*'.a:suffix.'$') +endfunction + +function! s:status_load(lnum) + let line = getline(a:lnum) + let name = s:extract_name(line, '-', '(not loaded)') + if !empty(name) + call plug#load(name) + setlocal modifiable + call setline(a:lnum, substitute(line, ' (not loaded)$', '', '')) + setlocal nomodifiable + endif +endfunction + +function! s:status_update() range + let lines = getline(a:firstline, a:lastline) + let names = filter(map(lines, 's:extract_name(v:val, "[x-]", "")'), '!empty(v:val)') + if !empty(names) + echo + execute 'PlugUpdate' join(names) + endif +endfunction + +function! s:is_preview_window_open() + silent! wincmd P + if &previewwindow + wincmd p + return 1 + endif +endfunction + +function! s:find_name(lnum) + for lnum in reverse(range(1, a:lnum)) + let line = getline(lnum) + if empty(line) + return '' + endif + let name = s:extract_name(line, '-', '') + if !empty(name) + return name + endif + endfor + return '' +endfunction + +function! s:preview_commit() + if b:plug_preview < 0 + let b:plug_preview = !s:is_preview_window_open() + endif + + let sha = matchstr(getline('.'), '^ \X*\zs[0-9a-f]\{7,9}') + if empty(sha) + return + endif + + let name = s:find_name(line('.')) + if empty(name) || !has_key(g:plugs, name) || !isdirectory(g:plugs[name].dir) + return + endif + + if exists('g:plug_pwindow') && !s:is_preview_window_open() + execute g:plug_pwindow + execute 'e' sha + else + execute 'pedit' sha + wincmd P + endif + setlocal previewwindow filetype=git buftype=nofile nobuflisted modifiable + try + let [sh, shrd] = s:chsh(1) + execute 'silent %!cd' s:shellesc(g:plugs[name].dir) '&& git show --no-color --pretty=medium' sha + finally + let [&shell, &shellredir] = [sh, shrd] + endtry + setlocal nomodifiable + nnoremap q :q + wincmd p +endfunction + +function! s:section(flags) + call search('\(^[x-] \)\@<=[^:]\+:', a:flags) +endfunction + +function! s:format_git_log(line) + let indent = ' ' + let tokens = split(a:line, nr2char(1)) + if len(tokens) != 5 + return indent.substitute(a:line, '\s*$', '', '') + endif + let [graph, sha, refs, subject, date] = tokens + let tag = matchstr(refs, 'tag: [^,)]\+') + let tag = empty(tag) ? ' ' : ' ('.tag.') ' + return printf('%s%s%s%s%s (%s)', indent, graph, sha, tag, subject, date) +endfunction + +function! s:append_ul(lnum, text) + call append(a:lnum, ['', a:text, repeat('-', len(a:text))]) +endfunction + +function! s:diff() + call s:prepare() + call append(0, ['Collecting changes ...', '']) + let cnts = [0, 0] + let bar = '' + let total = filter(copy(g:plugs), 's:is_managed(v:key) && isdirectory(v:val.dir)') + call s:progress_bar(2, bar, len(total)) + for origin in [1, 0] + let plugs = reverse(sort(items(filter(copy(total), (origin ? '' : '!').'(has_key(v:val, "commit") || has_key(v:val, "tag"))')))) + if empty(plugs) + continue + endif + call s:append_ul(2, origin ? 'Pending updates:' : 'Last update:') + for [k, v] in plugs + let range = origin ? '..origin/'.v.branch : 'HEAD@{1}..' + let diff = s:system_chomp('git log --graph --color=never --pretty=format:"%x01%h%x01%d%x01%s%x01%cr" '.s:shellesc(range), v.dir) + if !empty(diff) + let ref = has_key(v, 'tag') ? (' (tag: '.v.tag.')') : has_key(v, 'commit') ? (' '.v.commit) : '' + call append(5, extend(['', '- '.k.':'.ref], map(s:lines(diff), 's:format_git_log(v:val)'))) + let cnts[origin] += 1 + endif + let bar .= '=' + call s:progress_bar(2, bar, len(total)) + normal! 2G + redraw + endfor + if !cnts[origin] + call append(5, ['', 'N/A']) + endif + endfor + call setline(1, printf('%d plugin(s) updated.', cnts[0]) + \ . (cnts[1] ? printf(' %d plugin(s) have pending updates.', cnts[1]) : '')) + + if cnts[0] || cnts[1] + nnoremap :silent! call preview_commit() + nnoremap o :silent! call preview_commit() + endif + if cnts[0] + nnoremap X :call revert() + echo "Press 'X' on each block to revert the update" + endif + normal! gg + setlocal nomodifiable +endfunction + +function! s:revert() + if search('^Pending updates', 'bnW') + return + endif + + let name = s:find_name(line('.')) + if empty(name) || !has_key(g:plugs, name) || + \ input(printf('Revert the update of %s? (y/N) ', name)) !~? '^y' + return + endif + + call s:system('git reset --hard HEAD@{1} && git checkout '.s:esc(g:plugs[name].branch).' --', g:plugs[name].dir) + setlocal modifiable + normal! "_dap + setlocal nomodifiable + echo 'Reverted' +endfunction + +function! s:snapshot(force, ...) abort + call s:prepare() + setf vim + call append(0, ['" Generated by vim-plug', + \ '" '.strftime("%c"), + \ '" :source this file in vim to restore the snapshot', + \ '" or execute: vim -S snapshot.vim', + \ '', '', 'PlugUpdate!']) + 1 + let anchor = line('$') - 3 + let names = sort(keys(filter(copy(g:plugs), + \'has_key(v:val, "uri") && !has_key(v:val, "commit") && isdirectory(v:val.dir)'))) + for name in reverse(names) + let sha = s:system_chomp('git rev-parse --short HEAD', g:plugs[name].dir) + if !empty(sha) + call append(anchor, printf("silent! let g:plugs['%s'].commit = '%s'", name, sha)) + redraw + endif + endfor + + if a:0 > 0 + let fn = expand(a:1) + if filereadable(fn) && !(a:force || s:ask(a:1.' already exists. Overwrite?')) + return + endif + call writefile(getline(1, '$'), fn) + echo 'Saved as '.a:1 + silent execute 'e' s:esc(fn) + setf vim + endif +endfunction + +function! s:split_rtp() + return split(&rtp, '\\\@ +" +" Note: Based on the monokai theme for textmate +" by Wimer Hazenberg and its darker variant +" by Hamish Stuart Macpherson +" + +hi clear + +set background=dark +if version > 580 + " no guarantees for version 5.8 and below, but this makes it stop + " complaining + hi clear + if exists("syntax_on") + syntax reset + endif +endif +let g:colors_name="molokai" + +if exists("g:molokai_original") + let s:molokai_original = g:molokai_original +else + let s:molokai_original = 0 +endif + + +hi Boolean guifg=#AE81FF +hi Character guifg=#E6DB74 +hi Number guifg=#AE81FF +hi String guifg=#E6DB74 +hi Conditional guifg=#F92672 gui=bold +hi Constant guifg=#AE81FF gui=bold +hi Cursor guifg=#000000 guibg=#F8F8F0 +hi Debug guifg=#BCA3A3 gui=bold +hi Define guifg=#66D9EF +hi Delimiter guifg=#8F8F8F +hi DiffAdd guibg=#13354A +hi DiffChange guifg=#89807D guibg=#4C4745 +hi DiffDelete guifg=#960050 guibg=#1E0010 +hi DiffText guibg=#4C4745 gui=italic,bold + +hi Directory guifg=#A6E22E gui=bold +hi Error guifg=#960050 guibg=#1E0010 +hi ErrorMsg guifg=#F92672 guibg=#232526 gui=bold +hi Exception guifg=#A6E22E gui=bold +hi Float guifg=#AE81FF +hi FoldColumn guifg=#465457 guibg=#000000 +hi Folded guifg=#465457 guibg=#000000 +hi Function guifg=#A6E22E +hi Identifier guifg=#FD971F +hi Ignore guifg=#808080 guibg=bg +hi IncSearch guifg=#C4BE89 guibg=#000000 + +hi Keyword guifg=#F92672 gui=bold +hi Label guifg=#E6DB74 gui=none +hi Macro guifg=#C4BE89 gui=italic +hi SpecialKey guifg=#66D9EF gui=italic + +hi MatchParen guifg=#000000 guibg=#FD971F gui=bold +hi ModeMsg guifg=#E6DB74 +hi MoreMsg guifg=#E6DB74 +hi Operator guifg=#F92672 + +" complete menu +hi Pmenu guifg=#66D9EF guibg=#000000 +hi PmenuSel guibg=#808080 +hi PmenuSbar guibg=#080808 +hi PmenuThumb guifg=#66D9EF + +hi PreCondit guifg=#A6E22E gui=bold +hi PreProc guifg=#A6E22E +hi Question guifg=#66D9EF +hi Repeat guifg=#F92672 gui=bold +hi Search guifg=#FFFFFF guibg=#455354 +" marks column +hi SignColumn guifg=#A6E22E guibg=#232526 +hi SpecialChar guifg=#F92672 gui=bold +hi SpecialComment guifg=#465457 gui=bold +hi Special guifg=#66D9EF guibg=bg gui=italic +hi SpecialKey guifg=#888A85 gui=italic +if has("spell") + hi SpellBad guisp=#FF0000 gui=undercurl + hi SpellCap guisp=#7070F0 gui=undercurl + hi SpellLocal guisp=#70F0F0 gui=undercurl + hi SpellRare guisp=#FFFFFF gui=undercurl +endif +hi Statement guifg=#F92672 gui=bold +hi StatusLine guifg=#455354 guibg=fg +hi StatusLineNC guifg=#808080 guibg=#080808 +hi StorageClass guifg=#FD971F gui=italic +hi Structure guifg=#66D9EF +hi Tag guifg=#F92672 gui=italic +hi Title guifg=#ef5939 +hi Todo guifg=#FFFFFF guibg=bg gui=bold + +hi Typedef guifg=#66D9EF +hi Type guifg=#66D9EF gui=none +hi Underlined guifg=#808080 gui=underline + +hi VertSplit guifg=#808080 guibg=#080808 gui=bold +hi VisualNOS guibg=#403D3D +hi Visual guibg=#403D3D +hi WarningMsg guifg=#FFFFFF guibg=#333333 gui=bold +hi WildMenu guifg=#66D9EF guibg=#000000 + +if s:molokai_original == 1 + hi Normal guifg=#F8F8F2 guibg=#272822 + hi Comment guifg=#75715E + hi CursorLine guibg=#3E3D32 + hi CursorColumn guibg=#3E3D32 + hi LineNr guifg=#BCBCBC guibg=#3B3A32 + hi NonText guifg=#BCBCBC guibg=#3B3A32 +else + hi Normal guifg=#F8F8F2 guibg=#1B1D1E + hi Comment guifg=#465457 + hi CursorLine guibg=#293739 + hi CursorColumn guibg=#293739 + hi LineNr guifg=#BCBCBC guibg=#232526 + hi NonText guifg=#BCBCBC guibg=#232526 +end + +" +" Support for 256-color terminal +" +if &t_Co > 255 + hi Boolean ctermfg=135 + hi Character ctermfg=144 + hi Number ctermfg=135 + hi String ctermfg=144 + hi Conditional ctermfg=161 cterm=bold + hi Constant ctermfg=135 cterm=bold + hi Cursor ctermfg=16 ctermbg=253 + hi Debug ctermfg=225 cterm=bold + hi Define ctermfg=81 + hi Delimiter ctermfg=241 + + hi DiffAdd ctermbg=24 + hi DiffChange ctermfg=181 ctermbg=239 + hi DiffDelete ctermfg=162 ctermbg=53 + hi DiffText ctermbg=102 cterm=bold + + hi Directory ctermfg=118 cterm=bold + hi Error ctermfg=219 ctermbg=89 + hi ErrorMsg ctermfg=199 ctermbg=16 cterm=bold + hi Exception ctermfg=118 cterm=bold + hi Float ctermfg=135 + hi FoldColumn ctermfg=67 ctermbg=16 + hi Folded ctermfg=67 ctermbg=16 + hi Function ctermfg=118 + hi Identifier ctermfg=208 + hi Ignore ctermfg=244 ctermbg=232 + hi IncSearch ctermfg=193 ctermbg=16 + + hi Keyword ctermfg=161 cterm=bold + hi Label ctermfg=229 cterm=none + hi Macro ctermfg=193 + hi SpecialKey ctermfg=81 + + hi MatchParen ctermfg=16 ctermbg=208 cterm=bold + hi ModeMsg ctermfg=229 + hi MoreMsg ctermfg=229 + hi Operator ctermfg=161 + + " complete menu + hi Pmenu ctermfg=81 ctermbg=16 + hi PmenuSel ctermbg=244 + hi PmenuSbar ctermbg=232 + hi PmenuThumb ctermfg=81 + + hi PreCondit ctermfg=118 cterm=bold + hi PreProc ctermfg=118 + hi Question ctermfg=81 + hi Repeat ctermfg=161 cterm=bold + hi Search ctermfg=253 ctermbg=66 + + " marks column + hi SignColumn ctermfg=118 ctermbg=235 + hi SpecialChar ctermfg=161 cterm=bold + hi SpecialComment ctermfg=245 cterm=bold + hi Special ctermfg=81 ctermbg=232 + hi SpecialKey ctermfg=245 + + hi Statement ctermfg=161 cterm=bold + hi StatusLine ctermfg=238 ctermbg=253 + hi StatusLineNC ctermfg=244 ctermbg=232 + hi StorageClass ctermfg=208 + hi Structure ctermfg=81 + hi Tag ctermfg=161 + hi Title ctermfg=166 + hi Todo ctermfg=231 ctermbg=232 cterm=bold + + hi Typedef ctermfg=81 + hi Type ctermfg=81 cterm=none + hi Underlined ctermfg=244 cterm=underline + + hi VertSplit ctermfg=244 ctermbg=232 cterm=bold + hi VisualNOS ctermbg=238 + hi Visual ctermbg=235 + hi WarningMsg ctermfg=231 ctermbg=238 cterm=bold + hi WildMenu ctermfg=81 ctermbg=16 + + hi Normal ctermfg=252 ctermbg=233 + hi Comment ctermfg=59 + hi CursorLine ctermbg=234 cterm=none + hi CursorColumn ctermbg=234 + hi LineNr ctermfg=250 ctermbg=234 + hi NonText ctermfg=250 ctermbg=234 +end diff --git a/skel/.config/nvim/init.vim b/skel/.config/nvim/init.vim new file mode 100644 index 0000000..1d4b5a6 --- /dev/null +++ b/skel/.config/nvim/init.vim @@ -0,0 +1,462 @@ +" This file is inspired by spf13's vimrc + +" My settings {{{ +filetype on " required! +filetype plugin indent on " Automatically detect file types. + +" set selection=exclusive " Do not inlcude char under cursor while doing visual selection +set autoindent " Indent at the same level of the previous line +set backspace=indent,eol,start " Backspace for dummies +set clipboard=unnamedplus +set cursorline " Highlight current line +set expandtab " Tabs are spaces, not tabs +set foldlevel=99 +set foldmethod=indent +set hidden " Allow buffer switching without saving +set history=1000 " Store a ton of history (default is 20) +set hlsearch " Highlight search terms +set ignorecase " Case insensitive search +set linespace=0 " No extra spaces between rows +set list +set listchars=tab:›\ ,trail:•,extends:#,nbsp:. " Highlight problematic whitespace +set mouse=a +set nocompatible " be iMproved +set noincsearch +set noswapfile +set nu " Line numbers on +set path=., +set scrolljump=1 " Lines to scroll when cursor leaves screen +set scrolloff=0 " Minimum lines to keep above and below cursor +set shiftwidth=0 " Use indents of 4 spaces +set showmatch " Show matching brackets/parenthesis +set showmode " Display the current mode +set smartcase " Case sensitive when uc present +set softtabstop=0 " Let backspace delete indent +set spell " Spell checking on +set tabstop=2 " An indentation every four columns +set title +set whichwrap=b,s,h,l,<,>,[,] " Backspace and cursor keys wrap too +set wildmenu " Show list instead of just completing +set wildmode=list:longest,full " Command completion, list matches, then longest common part, then all. +set winminheight=0 " Windows can be 0 line high +set wrap +syntax on + +let javaScript_fold=0 " JavaScript +let perl_fold=1 " Perl +let r_syntax_folding=1 " R +let ruby_fold=1 " Ruby +let sh_fold_enabled=1 " sh +let vimsyn_folding='af' " Vim script +let $FZF_DEFAULT_COMMAND='ag -g ""' + +au BufEnter *.js.ejs set ft=javascript.ejs +au BufEnter *.sshconf set ft=sshconfig + +" Disable python linting +autocmd VimEnter *.py SyntasticToggleMode + + + +" Syntax based folding found be slow. In most of the cases, we will do indenting according to syntax. +autocmd FileType java set foldmethod=indent +autocmd FileType html set foldmethod=indent +autocmd FileType javascript set foldmethod=indent +autocmd FileType xml set foldmethod=indent + +" % key will be mapped by MatchTag plugin to match HTML tags. +" It is not need on php file +autocmd FileType php unmap % + +" }}} + + +" for formating {{{ +" set nowrap " Wrap long lines + +" for JavaScript {{{ +" if we press 'gf' under require('abc/xyz'), then also sarch for ./abs/xyz.js +autocmd FileType javascript set includeexpr='./'.v:fname +autocmd FileType typescript set includeexpr='./'.v:fname +" }}} + +" for java {{{ +autocmd BufRead *.java set include=^#\s*import +autocmd BufRead *.java set includeexpr=substitute(v:fname,'\\.','/','g') +autocmd BufRead *.java set suffixesadd=.java,.xml +autocmd BufRead *.ect set suffixesadd=.ect ft=html.ect + +" For vue js +" autocmd BufRead,BufNewFile *.vue setlocal filetype=html.vue + +" For Nunjucks templates +autocmd BufRead *.njk set ft=jinja + +autocmd BufEnter *.gradle set ft=groovy +" }}} + + + +" * Commenting support for jinja tempaltes +" * Typedoc compatible Sexycomment support for typescript ( '/**' instead of '/*'' ) +" * jsdoc3 compatible Sexycomment support for javascript ( '/**' instead of '/*'' ) + +let g:NERDSpaceDelims=1 +au BufEnter *.ts let b:NERDSexyComMarker='* ' +au BufEnter *.js let b:NERDSexyComMarker='* ' +au BufEnter *.jsx let b:NERDSexyComMarker='* ' +let g:NERDCustomDelimiters = { + \ 'jinja': { 'left': '{# ', 'right': ' #}', 'leftAlt': '{# ', 'rightAlt': ' #}' }, + \ 'typescript': { 'left': '//', 'leftAlt': '/**', 'rightAlt': '*/' }, + \ 'javascript': { 'left': '//', 'leftAlt': '/**', 'rightAlt': '*/' }, +\ } +" }}} + +" Session List {{{ +set sessionoptions=blank,buffers,curdir,tabpages,winsize,resize,winpos +" }}} + + +" for JavaScript syntax checking {{{ +let g:syntastic_always_populate_loc_list = 1 +let g:syntastic_javascript_checkers = ['eslint'] +" }}} + + + +" set lazyredraw +let g:sparkupNextMapping = '' + + + + +" Ctrl-p will open fuzzy file search using fzf plugin. These are the shortcuts available in fzf window +let g:fzf_action = { + \ 'ctrl-t': 'tab split', + \ 'ctrl-x': 'split', + \ 'ctrl-v': 'vsplit' } + + +let nvim_conf_root = expand(':p:h') . '/' + +" Enable jsdoc comments Highlight for javascript +let g:javascript_plugin_jsdoc = 1 + +let g:MacroManagerDir = g:nvim_conf_root . 'macros' +call plug#begin( ) +Plug 'tomtom/tlib_vim' " Dependency of Snipmate plugin +Plug 'MarcWeber/vim-addon-mw-utils' " Dependency of Snipmate plugin +Plug 'garbas/vim-snipmate' " Snippet management +" Plug 'tpope/vim-fugitive' " For Git repo management. +" Plug 'brooth/far.vim' " Interactive Fine & replace on multiple files +" Plug 'Lokaltog/vim-easymotion' " Quick cursor movement to any where in the screen +Plug 'rstacruz/sparkup' " HTML zen-coding helper +" Plug 'git://github.com/maxbrunsfeld/vim-yankstack.git' " Clipboard histroy management. +" Plug 'vim-scripts/DoxygenToolkit.vim' " Quickly create Doxygent style comments +" Plug 'scrooloose/syntastic' " Syntax checking pluin +" Plug 'rust-lang/rust.vim', { 'for': 'rust'} +Plug 'preservim/nerdcommenter' " Code commenting uncommenting +" Plug 'Yggdroot/indentLine' +" Plug 'vim-scripts/sessionman.vim' " Session manager. Manage projects +" Plug 'godlygeek/tabular' " Tabularize Text +" Plug 'majutsushi/tagbar' +Plug 'tpope/vim-surround' " quickly Insert/remove/change quote/brackes any vim selection. +" function! DoRemote(arg) +" UpdateRemotePlugins +" endfunction +" Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' } "Autocompletion +" Plug 'Shougo/vimproc.vim' +" Plug 'pangloss/vim-javascript' +" Plug 'mxw/vim-jsx' , { 'for': [ 'javascript.jsx'] } +" Plug 'leafOfTree/vim-vue-plugin' , { 'for': ['vue']} +" Plug 'mhartington/nvim-typescript' , { 'for': ['javascript.ts'] } +" Plug 'spf13/vim-autoclose' " Autoclose brackets/quotes etc +" Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeFind' } "File tree +Plug 'harish2704/harish2704-vim' +" Plug 'kchmck/vim-coffee-script', { 'for': 'coffee' } +" Plug 'digitaltoad/vim-jade', { 'for': 'jade' } +" Plug 'AndrewRadev/vim-eco', { 'for': [ 'ect', 'eco' ] } +" Plug 'mustache/vim-mustache-handlebars', { 'for': 'handlebars' } +" Plug 'chrisbra/NrrwRgn' " Edit a portion file as different buffer +" Plug 'briancollins/vim-jst', { 'for': 'jst' } +" Plug 'vim-scripts/matchit.zip' +Plug 'harish2704/vim-snippets' +" Plug 'tomasr/molokai' +Plug 'junegunn/fzf' +Plug 'junegunn/fzf.vim' +" Plug 'Glench/Vim-Jinja2-Syntax' +" Plug 'tyru/open-browser.vim' +" Plug 'Valloric/MatchTagAlways' +" Plug 'bogado/file-line' +" Plug 'dohsimpson/vim-macroeditor' +" Plug 'low-ghost/vim-macro-manager' +" Plug 'tikhomirov/vim-glsl' +" Plug 'HerringtonDarkholme/yats.vim' +" Plug 'iamcco/markdown-preview.nvim', { 'do': 'cd app & yarn install' } +" Plug 'ollykel/v-vim' +" Plug 'sjl/gundo.vim' +" Plug 'evanleck/vim-svelte', { 'for': 'svelte' } +call plug#end() + +" Source support_function.vim to support vim-snippets. +if filereadable(expand( g:nvim_conf_root ."bundle/vim-snippets/snippets/support_functions.vim")) + source g:nvim_conf_root . 'bundle/vim-snippets/snippets/support_functions.vim' +endif + + + + +" Ctrl-p opens fuzzy file search +nmap :Files + +" Ctrl-b opens current buffers list +nmap :Buffers + +colorscheme molokai + +" Neovim specific settings + +" Switch tabs using Alt-1..9 +map ± 1gt +map ² 2gt +map ³ 3gt +map ´ 4gt +map µ 5gt +map ¶ 6gt +map · 7gt +map ¸ 8gt + + +" Ctrl-l -> Go to end of line +imap + +" Replace grep with silver-searcher +" silver-searcher or 'ag' command is much faster than grep command. So use ag command instead of grep command for 'vimgrep' +set grepprg=ag\ --nogroup\ --nocolor +" set grepprg=grep\ -n\ $*\ /dev/null + +" Ctrl-Enter on normal mode -> Jump to definition using Tern +" autocmd BufEnter *.js nmap :TernDefSplit + +" Ctrl-/ on normal mode -> Grep word under cursor ( Recursive ) +nmap  :Gr +nmap :Gr + + +" Open the version of current file using fugitive, where is the string in clipboard. +" Eg: copy sha id of git commit to clip board. then press '\go' which open old +" version of current file in vsplit using fugitive +nmap go :Gvsplit +:% + +" Open error list. By default, Syntax checking plugin ( syntastic ) will emit errors to vim's error list +nmap co :copen +nmap cc :cclose +nmap lo :lopen +nmap lc :lclose +" When opening any items in location list, Try current window, othertabs, then new tab +set switchbuf=useopen,usetab,newtab + +" Ctrl-Shift-T -> Open new tab +nmap :tabedit + +" Ctrl-S to save file {{{ +nmap :w +vmap gv +imap +" }}} + +" Alt-q Delete current buffer ( Close file ) +nmap :bd + + +" '\\es' or 'es' Open vimrc in a new tab +execute( 'nmap es :tabedit '. g:nvim_conf_root .'init.vim ' ) + +" '\\en' 'en' Open current file's snippets file in a new tab +nmap en :execute 'OpenSnippets' + + +" for moving tab {{{ +" Ctrl-Shift + Page-Up/Down to rearrange tab +nmap :execute 'tabmove ' . (tabpagenr()-2 ) +nmap :execute 'tabmove ' . ( tabpagenr()+1 ) +nmap :execute 'tabmove ' . (tabpagenr()-2 ) +nmap :execute 'tabmove ' . ( tabpagenr()+1 ) + + + +" Ctrl-Shift + j/k to move current window in to nearby tab {{{ +nmap :execute 'Mt' . (tabpagenr() -1) +nmap :execute 'Mt' . (tabpagenr() +1) +nmap :execute 'Mt' . (tabpagenr() -1) +nmap :execute 'Mt' . (tabpagenr() +1) +" }}} + + " \tr Reset shiftwidth to default value 2 +nmap tr :set tabstop=2 + " \tt Toggle tab and spaces +nmap tt :let &expandtab=!&expandtab + " \tj Incraese additional two spaces width for tab +nmap tj :let &tabstop=&tabstop-2\|echo 'tabstop=' &tabstop + " \tj Decreases two spaces width for tab +nmap tk :let &tabstop=&tabstop+2\|echo 'tabstop=' &tabstop +" }}} + +" Session handling {{{ +" List saved sessions +nmap sl :SessionList +" Save and close current session +nmap sc :SessionClose +" }}} + +" Ctrl-Enter in insert mode will append ';' to the line and insert a new line +imap A; + +" Ctrl-Enter in normal mode will jump to tag definition using cscope +" nmap :vert scs f g +" Ctrl-? in normal mode will jump to tag references using cscope +" nmap :vert scs f t + +" Alt + Arrows to Moving cursor to different windows {{{ +nmap k +nmap j +nmap l +nmap h +" }}} + +" For terminal mod {{{ +tmap +tmap +tmap k +tmap j +tmap l +tmap h +" }}} + +" For Terminal mode Alt + [1-8] to Switch tabs {{{ +tmap 1gt +tmap 2gt +tmap 3gt +tmap 4gt +tmap 5gt +tmap 6gt +tmap 7gt +tmap 8gt +" }}} + +" For terminal mod {{{ +tmap +tmap +" }}} + +"for easy quote/unquote {{{ +" \\ + a[add] / d[delete] + q[single quote] / Q [Double quote] +" \\dQ remove double quote +nmap dQ ds" +" \\dQ add double quote +nmap aQ ysiw" +" \\dQ remove single quote +nmap dq ds' +" \\dQ remove double quote +nmap aq ysiw' +" In insert mode, will quote current word +imap maysiw"`aa +" In insert mode, will quote current word with double quotes +imap maysiw'`ai +" }}} + + +" format JSON {{{ +nmap jt :%!python -m json.tool:set filetype=json +" }}} + +" Alt + [1-8] to Switch tabs {{{ +map 1gt +map 2gt +map 3gt +map 4gt +map 5gt +map 6gt +map 7gt +map 8gt +" }}} + + +" NerdTree {{{ +nmap ac ToggleAutoCloseMappings +map :NERDTreeToggle:NERDTreeMirror +map e :NERDTreeFind +nmap nt :NERDTreeFind +" }}} + +" For Open a terminal in current directory +nmap t :!gnome-terminal +" Open git-gui in current pwd +nmap g :!git gui & + +" -> Reload current file +nmap :e! + +" force Close buffer +nmap :bd! + +" Select a word and press Ctrl-h to replace all its occurance, even if the word is having special chars +vmap "fy:%s#f# +" Copy current word to 'f' register, search for that word +vmap "fy/f + +" set guicursor=n-c:block,i-ci-ve:ver40,r-cr-v:hor20,o:hor50,a:blinkwait700-blinkoff400-blinkon250-Cursor/lCursor,sm:block-blinkwait175-blinkoff150-blinkon175 +set termguicolors + +command! -register CopyMatches call CopyMatches() + +command! -register -range=% Unretab ,call Unretab() +" My custom commands {{{ + +imap ; +imap , +imap +" Grep for a word and open the result in errorlist +command! -nargs=+ Gr :silent execute 'grep! -nr "" | copen' +" Raw version of Gr command. +command! -nargs=* Grc grep -nr + +" Add file header to current buffer. Depends on https://github.com/harish2704/file-header +command! Header :execute '0r!file-header %' + +" Open Terminal in split window +command! Termw :execute '!konsole -e bash-session &' +command! Term :execute 'sp | term' + +" Cd to current file's directory +command! Cwd :execute 'cd %:p:h' + +" Cd to current file's directory, but limit to current tab +command! Tcd :execute ':tcd %:p:h' + +" Reload current buffer +command! Reload :execute "bufdo execute 'checktime . bufnr('%')'" + +" Delete current file and close buffer +command! Rm :execute '!rm %' | bd + +" Copy current file path to unnamedplus register +command! CopyFilename :let @+=@% + +" Open vscode in on current line +command! Code :execute "!code ./ -g %:". ( line('.')+1 ) +" }}} + + + + +function! CopyMatches(reg) + let hits = [] + %s//\=len(add(hits, submatch(0))) ? submatch(0) : ''/gne + let reg = empty(a:reg) ? '+' : a:reg + execute 'let @'.reg.' = join(hits, "\n") . "\n"' +endfunction + +function! Unretab() range + execute a:firstline . "," . a:lastline . 's/ \{1,' . &tabstop . '}/\t/g' +endfunction diff --git a/skel/.config/nvim/plugged/fzf.vim/.github/ISSUE_TEMPLATE.md b/skel/.config/nvim/plugged/fzf.vim/.github/ISSUE_TEMPLATE.md new file mode 100644 index 0000000..a62ef9e --- /dev/null +++ b/skel/.config/nvim/plugged/fzf.vim/.github/ISSUE_TEMPLATE.md @@ -0,0 +1,24 @@ + + + + +- [ ] I have read through https://github.com/junegunn/fzf.vim/blob/master/README.md +- [ ] I have read through https://github.com/junegunn/fzf/blob/master/README-VIM.md +- [ ] I have read through the manual page of fzf (`man fzf`) +- [ ] I have searched through the existing issues + + + diff --git a/skel/.config/nvim/plugged/fzf.vim/.gitignore b/skel/.config/nvim/plugged/fzf.vim/.gitignore new file mode 100644 index 0000000..926ccaa --- /dev/null +++ b/skel/.config/nvim/plugged/fzf.vim/.gitignore @@ -0,0 +1 @@ +doc/tags diff --git a/skel/.config/nvim/plugged/fzf.vim/README.md b/skel/.config/nvim/plugged/fzf.vim/README.md new file mode 100644 index 0000000..1fe93f3 --- /dev/null +++ b/skel/.config/nvim/plugged/fzf.vim/README.md @@ -0,0 +1,413 @@ +fzf :heart: vim +=============== + +Things you can do with [fzf][fzf] and Vim. + +Rationale +--------- + +[fzf][fzf] in itself is not a Vim plugin, and the official repository only +provides the [basic wrapper function][run] for Vim and it's up to the users to +write their own Vim commands with it. However, I've learned that many users of +fzf are not familiar with Vimscript and are looking for the "default" +implementation of the features they can find in the alternative Vim plugins. + +This repository is a bundle of fzf-based commands and mappings extracted from +my [.vimrc][vimrc] to address such needs. They are *not* designed to be +flexible or configurable, and there's no guarantee of backward-compatibility. + +Why you should use fzf on Vim +----------------------------- + +Because you can and you love fzf. + +fzf runs asynchronously and can be orders of magnitude faster than similar Vim +plugins. However, the benefit may not be noticeable if the size of the input +is small, which is the case for many of the commands provided here. +Nevertheless I wrote them anyway since it's really easy to implement custom +selector with fzf. + +Installation +------------ + +fzf.vim depends on the basic Vim plugin of [the main fzf +repository][fzf-main], which means you need to **set up both "fzf" and +"fzf.vim" on Vim**. To learn more about fzf/Vim integration, see +[README-VIM][README-VIM]. + +[fzf-main]: https://github.com/junegunn/fzf +[README-VIM]: https://github.com/junegunn/fzf/blob/master/README-VIM.md + +### Using [vim-plug](https://github.com/junegunn/vim-plug) + +```vim +Plug 'junegunn/fzf', { 'do': { -> fzf#install() } } +Plug 'junegunn/fzf.vim' +``` + +`fzf#install()` makes sure that you have the latest binary, but it's optional, +so you can omit it if you use a plugin manager that doesn't support hooks. + +Commands +-------- + +| Command | List | +| --- | --- | +| `:Files [PATH]` | Files (runs `$FZF_DEFAULT_COMMAND` if defined) | +| `:GFiles [OPTS]` | Git files (`git ls-files`) | +| `:GFiles?` | Git files (`git status`) | +| `:Buffers` | Open buffers | +| `:Colors` | Color schemes | +| `:Ag [PATTERN]` | [ag][ag] search result (`ALT-A` to select all, `ALT-D` to deselect all) | +| `:Rg [PATTERN]` | [rg][rg] search result (`ALT-A` to select all, `ALT-D` to deselect all) | +| `:Lines [QUERY]` | Lines in loaded buffers | +| `:BLines [QUERY]` | Lines in the current buffer | +| `:Tags [QUERY]` | Tags in the project (`ctags -R`) | +| `:BTags [QUERY]` | Tags in the current buffer | +| `:Marks` | Marks | +| `:Windows` | Windows | +| `:Locate PATTERN` | `locate` command output | +| `:History` | `v:oldfiles` and open buffers | +| `:History:` | Command history | +| `:History/` | Search history | +| `:Snippets` | Snippets ([UltiSnips][us]) | +| `:Commits` | Git commits (requires [fugitive.vim][f]) | +| `:BCommits` | Git commits for the current buffer | +| `:Commands` | Commands | +| `:Maps` | Normal mode mappings | +| `:Helptags` | Help tags [1](#helptags) | +| `:Filetypes` | File types + +- Most commands support `CTRL-T` / `CTRL-X` / `CTRL-V` key + bindings to open in a new tab, a new split, or in a new vertical split +- Bang-versions of the commands (e.g. `Ag!`) will open fzf in fullscreen +- You can set `g:fzf_command_prefix` to give the same prefix to the commands + - e.g. `let g:fzf_command_prefix = 'Fzf'` and you have `FzfFiles`, etc. + +(1: `Helptags` will shadow the command of the same name +from [pathogen][pat]. But its functionality is still available via `call +pathogen#helptags()`. [↩](#a1)) + +[pat]: https://github.com/tpope/vim-pathogen +[f]: https://github.com/tpope/vim-fugitive + +Customization +------------- + +### Global options + +Every command in fzf.vim internally calls `fzf#wrap` function of the main +repository which supports a set of global option variables. So please read +through [README-VIM][README-VIM] to learn more about them. + +#### Preview window + +If the width of the screen is wider than 120 columns, some commands will show +the preview window on the right. You can customize the behavior with +`g:fzf_preview_window`. Here are some examples: + +```vim +" Empty value to disable preview window altogether +let g:fzf_preview_window = '' + +" Always enable preview window on the right with 60% width +let g:fzf_preview_window = 'right:60%' +``` + +### Command-local options + +A few commands in fzf.vim can be customized with global option variables shown +below. + +```vim +" [Buffers] Jump to the existing window if possible +let g:fzf_buffers_jump = 1 + +" [[B]Commits] Customize the options used by 'git log': +let g:fzf_commits_log_options = '--graph --color=always --format="%C(auto)%h%d %s %C(black)%C(bold)%cr"' + +" [Tags] Command to generate tags file +let g:fzf_tags_command = 'ctags -R' + +" [Commands] --expect expression for directly executing the command +let g:fzf_commands_expect = 'alt-enter,ctrl-x' +``` + +### Advanced customization + +#### Vim functions + +Each command in fzf.vim is backed by a Vim function. You can override +a command or define a variation of it by calling its corresponding function. + +| Command | Vim function | +| --- | --- | +| `Files` | `fzf#vim#files(dir, [spec dict], [fullscreen bool])` | +| `GFiles` | `fzf#vim#gitfiles(git_options, [spec dict], [fullscreen bool])` | +| `GFiles?` | `fzf#vim#gitfiles('?', [spec dict], [fullscreen bool])` | +| `Buffers` | `fzf#vim#buffers([spec dict], [fullscreen bool])` | +| `Colors` | `fzf#vim#colors([spec dict], [fullscreen bool])` | +| `Rg` | `fzf#vim#grep(command, [has_column bool], [spec dict], [fullscreen bool])` | +| ... | ... | + +(We can see that the last two optional arguments of each function are +identical. They are directly passed to `fzf#wrap` function. If you haven't +read [README-VIM][README-VIM] already, please read it before proceeding.) + +#### Example: Customizing `Files` command + +This is the default definition of `Files` command: + +```vim +command! -bang -nargs=? -complete=dir Files call fzf#vim#files(, 0) +``` + +Let's say you want to a variation of it called `ProjectFiles` that only +searches inside `~/projects` directory. Then you can do it like this: + +```vim +command! -bang ProjectFiles call fzf#vim#files('~/projects', 0) +``` + +Or, if you want to override the command with different fzf options, just pass +a custom spec to the function. + +```vim +command! -bang -nargs=? -complete=dir Files + \ call fzf#vim#files(, {'options': ['--layout=reverse', '--info=inline']}, 0) +``` + +Want a preview window? + +```vim +command! -bang -nargs=? -complete=dir Files + \ call fzf#vim#files(, {'options': ['--layout=reverse', '--info=inline', '--preview', 'cat {}']}, 0) +``` + +It kind of works, but you probably want a nicer previewer program than `cat`. +fzf.vim ships [a versatile preview script](bin/preview.sh) you can readily +use. It internally executes [bat](https://github.com/sharkdp/bat) for syntax +highlighting, so make sure to install it. + +```vim +command! -bang -nargs=? -complete=dir Files + \ call fzf#vim#files(, {'options': ['--layout=reverse', '--info=inline', '--preview', '~/.vim/plugged/fzf.vim/bin/preview.sh {}']}, 0) +``` + +However, it's not ideal to hard-code the path to the script which can be +different in different circumstances. So in order to make it easier to set up +the previewer, fzf.vim provides `fzf#vim#with_preview` helper function. +Similarly to `fzf#wrap`, it takes a spec dictionary and returns a copy of it +with additional preview options. + +```vim +command! -bang -nargs=? -complete=dir Files + \ call fzf#vim#files(, fzf#vim#with_preview({'options': ['--layout=reverse', '--info=inline']}), 0) +``` + +You can just omit the spec argument if you only want the previewer. + +```vim +command! -bang -nargs=? -complete=dir Files + \ call fzf#vim#files(, fzf#vim#with_preview(), 0) +``` + +#### Example: `git grep` wrapper + +The following example implements `GGrep` command that works similarly to +predefined `Ag` or `Rg` using `fzf#vim#grep`. + +- The second argument to `fzf#vim#grep` is 0 (false), because `git grep` does + not print column numbers. +- We set the base directory to git root by setting `dir` attribute in spec + dictionary. +- [The preview script](bin/preview.sh) supports `grep` format + (`FILE_PATH:LINE_NO:...`), so we can just wrap the spec with + `fzf#vim#with_preview` as before to enable previewer. + +```vim +command! -bang -nargs=* GGrep + \ call fzf#vim#grep( + \ 'git grep --line-number -- '.shellescape(), 0, + \ fzf#vim#with_preview({'dir': systemlist('git rev-parse --show-toplevel')[0]}), 0) +``` + +#### Example: `Rg` command with preview window + +You can see the definition of `Rg` command with `:command Rg`. With the +information, you can redefine it with the preview window enabled. In this +case, we're only interested in setting up the preview window, so we will omit +the spec argument to `fzf#vim#preview`. + +```vim +command! -bang -nargs=* Rg + \ call fzf#vim#grep( + \ 'rg --column --line-number --no-heading --color=always --smart-case -- '.shellescape(), 1, + \ fzf#vim#with_preview(), 0) +``` + +#### Example: Advanced ripgrep integration + +In the default implementation of `Rg`, ripgrep process starts only once with +the initial query (e.g. `:Rg foo`) and fzf filters the output of the process. + +This is okay in most cases because fzf is quite performant even with millions +of lines, but we can make fzf completely delegate its search responsibliity to +ripgrep process by making it restart ripgrep whenever the query string is +updated. In this scenario, fzf becomes a simple selector interface rather than +a "fuzzy finder". + +- We will name the new command all-uppercase `RG` so we can still access the + default version. +- `--bind 'change:reload:rg ... {q}'` will make fzf restart ripgrep process + whenever the query string, denoted by `{q}`, is changed. +- With `--phony` option, fzf will no longer perform search. The query string + you type on fzf prompt is only used for restarting ripgrep process. +- Also note that we enabled previewer with `fzf#vim#with_preview`. + +```vim +function! RipgrepFzf(query, fullscreen) + let command_fmt = 'rg --column --line-number --no-heading --color=always --smart-case -- %s || true' + let initial_command = printf(command_fmt, shellescape(a:query)) + let reload_command = printf(command_fmt, '{q}') + let spec = {'options': ['--phony', '--query', a:query, '--bind', 'change:reload:'.reload_command]} + call fzf#vim#grep(initial_command, 1, fzf#vim#with_preview(spec), a:fullscreen) +endfunction + +command! -nargs=* -bang RG call RipgrepFzf(, 0) +``` + +Mappings +-------- + +| Mapping | Description | +| --- | --- | +| `(fzf-maps-n)` | Normal mode mappings | +| `(fzf-maps-i)` | Insert mode mappings | +| `(fzf-maps-x)` | Visual mode mappings | +| `(fzf-maps-o)` | Operator-pending mappings | +| `(fzf-complete-word)` | `cat /usr/share/dict/words` | +| `(fzf-complete-path)` | Path completion using `find` (file + dir) | +| `(fzf-complete-file)` | File completion using `find` | +| `(fzf-complete-line)` | Line completion (all open buffers) | +| `(fzf-complete-buffer-line)` | Line completion (current buffer only) | + +```vim +" Mapping selecting mappings +nmap (fzf-maps-n) +xmap (fzf-maps-x) +omap (fzf-maps-o) + +" Insert mode completion +imap (fzf-complete-word) +imap (fzf-complete-path) +imap (fzf-complete-line) +``` + +Completion functions +-------------------- + +| Function | Description | +| --- | --- | +| `fzf#vim#complete#path(command, [spec])` | Path completion | +| `fzf#vim#complete#word([spec])` | Word completion | +| `fzf#vim#complete#line([spec])` | Line completion (all open buffers) | +| `fzf#vim#complete#buffer_line([spec])` | Line completion (current buffer only) | + +```vim +" Path completion with custom source command +inoremap fzf#vim#complete#path('fd') +inoremap fzf#vim#complete#path('rg --files') + +" Word completion with custom spec with popup layout option +inoremap fzf#vim#complete#word({'window': { 'width': 0.2, 'height': 0.9, 'xoffset': 1 }}) +``` + +Custom completion +----------------- + +`fzf#vim#complete` is a helper function for creating custom fuzzy completion +using fzf. If the first parameter is a command string or a Vim list, it will +be used as the source. + +```vim +" Replace the default dictionary completion with fzf-based fuzzy completion +inoremap fzf#vim#complete('cat /usr/share/dict/words') +``` + +For advanced uses, you can pass an options dictionary to the function. The set +of options is pretty much identical to that for `fzf#run` only with the +following exceptions: + +- `reducer` (funcref) + - Reducer transforms the output lines of fzf into a single string value +- `prefix` (string or funcref; default: `\k*$`) + - Regular expression pattern to extract the completion prefix + - Or a function to extract completion prefix +- Both `source` and `options` can be given as funcrefs that take the + completion prefix as the argument and return the final value +- `sink` or `sink*` are ignored + +```vim +" Global line completion (not just open buffers. ripgrep required.) +inoremap fzf#vim#complete(fzf#wrap({ + \ 'prefix': '^.*$', + \ 'source': 'rg -n ^ --color always', + \ 'options': '--ansi --delimiter : --nth 3..', + \ 'reducer': { lines -> join(split(lines[0], ':\zs')[2:], '') }})) +``` + +### Reducer example + +```vim +function! s:make_sentence(lines) + return substitute(join(a:lines), '^.', '\=toupper(submatch(0))', '').'.' +endfunction + +inoremap fzf#vim#complete({ + \ 'source': 'cat /usr/share/dict/words', + \ 'reducer': function('make_sentence'), + \ 'options': '--multi --reverse --margin 15%,0', + \ 'left': 20}) +``` + +Status line of terminal buffer +------------------------------ + +When fzf starts in a terminal buffer (see [fzf/README-VIM.md][termbuf]), you +may want to customize the statusline of the containing buffer. + +[termbuf]: https://github.com/junegunn/fzf/blob/master/README-VIM.md#fzf-inside-terminal-buffer + +### Hide statusline + +```vim +autocmd! FileType fzf set laststatus=0 noshowmode noruler + \| autocmd BufLeave set laststatus=2 showmode ruler +``` + +### Custom statusline + +```vim +function! s:fzf_statusline() + " Override statusline as you like + highlight fzf1 ctermfg=161 ctermbg=251 + highlight fzf2 ctermfg=23 ctermbg=251 + highlight fzf3 ctermfg=237 ctermbg=251 + setlocal statusline=%#fzf1#\ >\ %#fzf2#fz%#fzf3#f +endfunction + +autocmd! User FzfStatusLine call fzf_statusline() +``` + +License +------- + +MIT + +[fzf]: https://github.com/junegunn/fzf +[run]: https://github.com/junegunn/fzf/blob/master/README-VIM.md#fzfrun +[vimrc]: https://github.com/junegunn/dotfiles/blob/master/vimrc +[ag]: https://github.com/ggreer/the_silver_searcher +[rg]: https://github.com/BurntSushi/ripgrep +[us]: https://github.com/SirVer/ultisnips diff --git a/skel/.config/nvim/plugged/fzf.vim/autoload/fzf/vim.vim b/skel/.config/nvim/plugged/fzf.vim/autoload/fzf/vim.vim new file mode 100644 index 0000000..8587783 --- /dev/null +++ b/skel/.config/nvim/plugged/fzf.vim/autoload/fzf/vim.vim @@ -0,0 +1,1346 @@ +" Copyright (c) 2017 Junegunn Choi +" +" MIT License +" +" Permission is hereby granted, free of charge, to any person obtaining +" a copy of this software and associated documentation files (the +" "Software"), to deal in the Software without restriction, including +" without limitation the rights to use, copy, modify, merge, publish, +" distribute, sublicense, and/or sell copies of the Software, and to +" permit persons to whom the Software is furnished to do so, subject to +" the following conditions: +" +" The above copyright notice and this permission notice shall be +" included in all copies or substantial portions of the Software. +" +" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +" EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +" NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +" LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +" OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +" WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +let s:cpo_save = &cpo +set cpo&vim + +" ------------------------------------------------------------------ +" Common +" ------------------------------------------------------------------ + +let s:is_win = has('win32') || has('win64') +let s:layout_keys = ['window', 'up', 'down', 'left', 'right'] +let s:bin_dir = expand(':h:h:h').'/bin/' +let s:bin = { +\ 'preview': s:bin_dir.'preview.sh', +\ 'tags': s:bin_dir.'tags.pl' } +let s:TYPE = {'dict': type({}), 'funcref': type(function('call')), 'string': type(''), 'list': type([])} +if s:is_win + if has('nvim') + let s:bin.preview = split(system('for %A in ("'.s:bin.preview.'") do @echo %~sA'), "\n")[0] + else + let s:bin.preview = fnamemodify(s:bin.preview, ':8') + endif + let s:bin.preview = 'bash '.escape(s:bin.preview, '\') +endif + +let s:wide = 120 + +function! s:extend_opts(dict, eopts, prepend) + if empty(a:eopts) + return + endif + if has_key(a:dict, 'options') + if type(a:dict.options) == s:TYPE.list && type(a:eopts) == s:TYPE.list + if a:prepend + let a:dict.options = extend(copy(a:eopts), a:dict.options) + else + call extend(a:dict.options, a:eopts) + endif + else + let all_opts = a:prepend ? [a:eopts, a:dict.options] : [a:dict.options, a:eopts] + let a:dict.options = join(map(all_opts, 'type(v:val) == s:TYPE.list ? join(map(copy(v:val), "fzf#shellescape(v:val)")) : v:val')) + endif + else + let a:dict.options = a:eopts + endif +endfunction + +function! s:merge_opts(dict, eopts) + return s:extend_opts(a:dict, a:eopts, 0) +endfunction + +function! s:prepend_opts(dict, eopts) + return s:extend_opts(a:dict, a:eopts, 1) +endfunction + +" [[options to wrap], [preview window expression], [toggle-preview keys...]] +function! fzf#vim#with_preview(...) + " Default options + let options = {} + let window = '' + + let args = copy(a:000) + + " Options to wrap + if len(args) && type(args[0]) == s:TYPE.dict + let options = copy(args[0]) + call remove(args, 0) + endif + + " Placeholder expression (TODO/TBD: undocumented) + let placeholder = get(options, 'placeholder', '{}') + + " Preview window + if len(args) && type(args[0]) == s:TYPE.string + if args[0] !~# '^\(up\|down\|left\|right\)' + throw 'invalid preview window: '.args[0] + endif + let window = args[0] + call remove(args, 0) + endif + + let preview = [] + if len(window) + let preview += ['--preview-window', window] + endif + let preview += ['--preview', (s:is_win ? s:bin.preview : fzf#shellescape(s:bin.preview)).' '.placeholder] + + if len(args) + call extend(preview, ['--bind', join(map(args, 'v:val.":toggle-preview"'), ',')]) + endif + call s:merge_opts(options, preview) + return options +endfunction + +function! s:remove_layout(opts) + for key in s:layout_keys + if has_key(a:opts, key) + call remove(a:opts, key) + endif + endfor + return a:opts +endfunction + +function! s:reverse_list(opts) + let tokens = map(split($FZF_DEFAULT_OPTS, '[^a-z-]'), 'substitute(v:val, "^--", "", "")') + if index(tokens, 'reverse') < 0 + return extend(['--layout=reverse-list'], a:opts) + endif + return a:opts +endfunction + +function! s:wrap(name, opts, bang) + " fzf#wrap does not append --expect if sink or sink* is found + let opts = copy(a:opts) + let options = '' + if has_key(opts, 'options') + let options = type(opts.options) == s:TYPE.list ? join(opts.options) : opts.options + endif + if options !~ '--expect' && has_key(opts, 'sink*') + let Sink = remove(opts, 'sink*') + let wrapped = fzf#wrap(a:name, opts, a:bang) + let wrapped['sink*'] = Sink + else + let wrapped = fzf#wrap(a:name, opts, a:bang) + endif + return wrapped +endfunction + +function! s:strip(str) + return substitute(a:str, '^\s*\|\s*$', '', 'g') +endfunction + +function! s:chomp(str) + return substitute(a:str, '\n*$', '', 'g') +endfunction + +function! s:escape(path) + let path = fnameescape(a:path) + return s:is_win ? escape(path, '$') : path +endfunction + +if v:version >= 704 + function! s:function(name) + return function(a:name) + endfunction +else + function! s:function(name) + " By Ingo Karkat + return function(substitute(a:name, '^s:', matchstr(expand(''), '\d\+_\zefunction$'), '')) + endfunction +endif + +function! s:get_color(attr, ...) + let gui = has('termguicolors') && &termguicolors + let fam = gui ? 'gui' : 'cterm' + let pat = gui ? '^#[a-f0-9]\+' : '^[0-9]\+$' + for group in a:000 + let code = synIDattr(synIDtrans(hlID(group)), a:attr, fam) + if code =~? pat + return code + endif + endfor + return '' +endfunction + +let s:ansi = {'black': 30, 'red': 31, 'green': 32, 'yellow': 33, 'blue': 34, 'magenta': 35, 'cyan': 36} + +function! s:csi(color, fg) + let prefix = a:fg ? '38;' : '48;' + if a:color[0] == '#' + return prefix.'2;'.join(map([a:color[1:2], a:color[3:4], a:color[5:6]], 'str2nr(v:val, 16)'), ';') + endif + return prefix.'5;'.a:color +endfunction + +function! s:ansi(str, group, default, ...) + let fg = s:get_color('fg', a:group) + let bg = s:get_color('bg', a:group) + let color = (empty(fg) ? s:ansi[a:default] : s:csi(fg, 1)) . + \ (empty(bg) ? '' : ';'.s:csi(bg, 0)) + return printf("\x1b[%s%sm%s\x1b[m", color, a:0 ? ';1' : '', a:str) +endfunction + +for s:color_name in keys(s:ansi) + execute "function! s:".s:color_name."(str, ...)\n" + \ " return s:ansi(a:str, get(a:, 1, ''), '".s:color_name."')\n" + \ "endfunction" +endfor + +function! s:buflisted() + return filter(range(1, bufnr('$')), 'buflisted(v:val) && getbufvar(v:val, "&filetype") != "qf"') +endfunction + +function! s:fzf(name, opts, extra) + let [extra, bang] = [{}, 0] + if len(a:extra) <= 1 + let first = get(a:extra, 0, 0) + if type(first) == s:TYPE.dict + let extra = first + else + let bang = first + endif + elseif len(a:extra) == 2 + let [extra, bang] = a:extra + else + throw 'invalid number of arguments' + endif + + let eopts = has_key(extra, 'options') ? remove(extra, 'options') : '' + let merged = extend(copy(a:opts), extra) + call s:merge_opts(merged, eopts) + return fzf#run(s:wrap(a:name, merged, bang)) +endfunction + +let s:default_action = { + \ 'ctrl-t': 'tab split', + \ 'ctrl-x': 'split', + \ 'ctrl-v': 'vsplit' } + +function! s:action_for(key, ...) + let default = a:0 ? a:1 : '' + let Cmd = get(get(g:, 'fzf_action', s:default_action), a:key, default) + return type(Cmd) == s:TYPE.string ? Cmd : default +endfunction + +function! s:open(cmd, target) + if stridx('edit', a:cmd) == 0 && fnamemodify(a:target, ':p') ==# expand('%:p') + return + endif + execute a:cmd s:escape(a:target) +endfunction + +function! s:align_lists(lists) + let maxes = {} + for list in a:lists + let i = 0 + while i < len(list) + let maxes[i] = max([get(maxes, i, 0), len(list[i])]) + let i += 1 + endwhile + endfor + for list in a:lists + call map(list, "printf('%-'.maxes[v:key].'s', v:val)") + endfor + return a:lists +endfunction + +function! s:warn(message) + echohl WarningMsg + echom a:message + echohl None + return 0 +endfunction + +function! s:fill_quickfix(list, ...) + if len(a:list) > 1 + call setqflist(a:list) + copen + wincmd p + if a:0 + execute a:1 + endif + endif +endfunction + +function! fzf#vim#_uniq(list) + let visited = {} + let ret = [] + for l in a:list + if !empty(l) && !has_key(visited, l) + call add(ret, l) + let visited[l] = 1 + endif + endfor + return ret +endfunction + +" ------------------------------------------------------------------ +" Files +" ------------------------------------------------------------------ +function! s:shortpath() + let short = fnamemodify(getcwd(), ':~:.') + if !has('win32unix') + let short = pathshorten(short) + endif + let slash = (s:is_win && !&shellslash) ? '\' : '/' + return empty(short) ? '~'.slash : short . (short =~ escape(slash, '\').'$' ? '' : slash) +endfunction + +function! fzf#vim#files(dir, ...) + let args = {} + if !empty(a:dir) + if !isdirectory(expand(a:dir)) + return s:warn('Invalid directory') + endif + let slash = (s:is_win && !&shellslash) ? '\\' : '/' + let dir = substitute(a:dir, '[/\\]*$', slash, '') + let args.dir = dir + else + let dir = s:shortpath() + endif + + let args.options = ['-m', '--prompt', strwidth(dir) < &columns / 2 - 20 ? dir : '> '] + call s:merge_opts(args, get(g:, 'fzf_files_options', [])) + return s:fzf('files', args, a:000) +endfunction + +" ------------------------------------------------------------------ +" Lines +" ------------------------------------------------------------------ +function! s:line_handler(lines) + if len(a:lines) < 2 + return + endif + normal! m' + let cmd = s:action_for(a:lines[0]) + if !empty(cmd) && stridx('edit', cmd) < 0 + execute 'silent' cmd + endif + + let keys = split(a:lines[1], '\t') + execute 'buffer' keys[0] + execute keys[2] + normal! ^zvzz +endfunction + +function! fzf#vim#_lines(all) + let cur = [] + let rest = [] + let buf = bufnr('') + let longest_name = 0 + let display_bufnames = &columns > s:wide + if display_bufnames + let bufnames = {} + for b in s:buflisted() + let bufnames[b] = pathshorten(fnamemodify(bufname(b), ":~:.")) + let longest_name = max([longest_name, len(bufnames[b])]) + endfor + endif + let len_bufnames = min([15, longest_name]) + for b in s:buflisted() + let lines = getbufline(b, 1, "$") + if empty(lines) + let path = fnamemodify(bufname(b), ':p') + let lines = filereadable(path) ? readfile(path) : [] + endif + if display_bufnames + let bufname = bufnames[b] + if len(bufname) > len_bufnames + 1 + let bufname = '…' . bufname[-len_bufnames+1:] + endif + let bufname = printf(s:green("%".len_bufnames."s", "Directory"), bufname) + else + let bufname = '' + endif + let linefmt = s:blue("%2d\t", "TabLine")."%s".s:yellow("\t%4d ", "LineNr")."\t%s" + call extend(b == buf ? cur : rest, + \ filter( + \ map(lines, + \ '(!a:all && empty(v:val)) ? "" : printf(linefmt, b, bufname, v:key + 1, v:val)'), + \ 'a:all || !empty(v:val)')) + endfor + return [display_bufnames, extend(cur, rest)] +endfunction + +function! fzf#vim#lines(...) + let [display_bufnames, lines] = fzf#vim#_lines(1) + let nth = display_bufnames ? 3 : 2 + let [query, args] = (a:0 && type(a:1) == type('')) ? + \ [a:1, a:000[1:]] : ['', a:000] + return s:fzf('lines', { + \ 'source': lines, + \ 'sink*': s:function('s:line_handler'), + \ 'options': s:reverse_list(['+m', '--tiebreak=index', '--prompt', 'Lines> ', '--ansi', '--extended', '--nth='.nth.'..', '--tabstop=1', '--query', query]) + \}, args) +endfunction + +" ------------------------------------------------------------------ +" BLines +" ------------------------------------------------------------------ +function! s:buffer_line_handler(lines) + if len(a:lines) < 2 + return + endif + let qfl = [] + for line in a:lines[1:] + let chunks = split(line, "\t", 1) + let ln = chunks[0] + let ltxt = join(chunks[1:], "\t") + call add(qfl, {'filename': expand('%'), 'lnum': str2nr(ln), 'text': ltxt}) + endfor + call s:fill_quickfix(qfl, 'cfirst') + normal! m' + let cmd = s:action_for(a:lines[0]) + if !empty(cmd) + execute 'silent' cmd + endif + + execute split(a:lines[1], '\t')[0] + normal! ^zvzz +endfunction + +function! s:buffer_lines(query) + let linefmt = s:yellow(" %4d ", "LineNr")."\t%s" + let fmtexpr = 'printf(linefmt, v:key + 1, v:val)' + let lines = getline(1, '$') + if empty(a:query) + return map(lines, fmtexpr) + end + return filter(map(lines, 'v:val =~ a:query ? '.fmtexpr.' : ""'), 'len(v:val)') +endfunction + +function! fzf#vim#buffer_lines(...) + let [query, args] = (a:0 && type(a:1) == type('')) ? + \ [a:1, a:000[1:]] : ['', a:000] + return s:fzf('blines', { + \ 'source': s:buffer_lines(query), + \ 'sink*': s:function('s:buffer_line_handler'), + \ 'options': s:reverse_list(['+m', '--tiebreak=index', '--multi', '--prompt', 'BLines> ', '--ansi', '--extended', '--nth=2..', '--tabstop=1']) + \}, args) +endfunction + +" ------------------------------------------------------------------ +" Colors +" ------------------------------------------------------------------ +function! fzf#vim#colors(...) + let colors = split(globpath(&rtp, "colors/*.vim"), "\n") + if has('packages') + let colors += split(globpath(&packpath, "pack/*/opt/*/colors/*.vim"), "\n") + endif + return s:fzf('colors', { + \ 'source': fzf#vim#_uniq(map(colors, "substitute(fnamemodify(v:val, ':t'), '\\..\\{-}$', '', '')")), + \ 'sink': 'colo', + \ 'options': '+m --prompt="Colors> "' + \}, a:000) +endfunction + +" ------------------------------------------------------------------ +" Locate +" ------------------------------------------------------------------ +function! fzf#vim#locate(query, ...) + return s:fzf('locate', { + \ 'source': 'locate '.a:query, + \ 'options': '-m --prompt "Locate> "' + \}, a:000) +endfunction + +" ------------------------------------------------------------------ +" History[:/] +" ------------------------------------------------------------------ +function! fzf#vim#_recent_files() + return fzf#vim#_uniq(map( + \ filter([expand('%')], 'len(v:val)') + \ + filter(map(s:buflisted_sorted(), 'bufname(v:val)'), 'len(v:val)') + \ + filter(copy(v:oldfiles), "filereadable(fnamemodify(v:val, ':p'))"), + \ 'fnamemodify(v:val, ":~:.")')) +endfunction + +function! s:history_source(type) + let max = histnr(a:type) + let fmt = ' %'.len(string(max)).'d ' + let list = filter(map(range(1, max), 'histget(a:type, - v:val)'), '!empty(v:val)') + return extend([' :: Press '.s:magenta('CTRL-E', 'Special').' to edit'], + \ map(list, 's:yellow(printf(fmt, len(list) - v:key), "Number")." ".v:val')) +endfunction + +nnoremap (-fzf-vim-do) :execute g:__fzf_command +nnoremap (-fzf-/) / +nnoremap (-fzf-:) : + +function! s:history_sink(type, lines) + if len(a:lines) < 2 + return + endif + + let prefix = "\(-fzf-".a:type.')' + let key = a:lines[0] + let item = matchstr(a:lines[1], ' *[0-9]\+ *\zs.*') + if key == 'ctrl-e' + call histadd(a:type, item) + redraw + call feedkeys(a:type."\", 'n') + else + if a:type == ':' + call histadd(a:type, item) + endif + let g:__fzf_command = "normal ".prefix.item."\" + call feedkeys("\(-fzf-vim-do)") + endif +endfunction + +function! s:cmd_history_sink(lines) + call s:history_sink(':', a:lines) +endfunction + +function! fzf#vim#command_history(...) + return s:fzf('history-command', { + \ 'source': s:history_source(':'), + \ 'sink*': s:function('s:cmd_history_sink'), + \ 'options': '+m --ansi --prompt="Hist:> " --header-lines=1 --expect=ctrl-e --tiebreak=index'}, a:000) +endfunction + +function! s:search_history_sink(lines) + call s:history_sink('/', a:lines) +endfunction + +function! fzf#vim#search_history(...) + return s:fzf('history-search', { + \ 'source': s:history_source('/'), + \ 'sink*': s:function('s:search_history_sink'), + \ 'options': '+m --ansi --prompt="Hist/> " --header-lines=1 --expect=ctrl-e --tiebreak=index'}, a:000) +endfunction + +function! fzf#vim#history(...) + return s:fzf('history-files', { + \ 'source': fzf#vim#_recent_files(), + \ 'options': ['-m', '--header-lines', !empty(expand('%')), '--prompt', 'Hist> '] + \}, a:000) +endfunction + +" ------------------------------------------------------------------ +" GFiles[?] +" ------------------------------------------------------------------ + +function! s:get_git_root() + let root = split(system('git rev-parse --show-toplevel'), '\n')[0] + return v:shell_error ? '' : root +endfunction + +function! fzf#vim#gitfiles(args, ...) + let root = s:get_git_root() + if empty(root) + return s:warn('Not in git repo') + endif + if a:args != '?' + return s:fzf('gfiles', { + \ 'source': 'git ls-files '.a:args.(s:is_win ? '' : ' | uniq'), + \ 'dir': root, + \ 'options': '-m --prompt "GitFiles> "' + \}, a:000) + endif + + " Here be dragons! + " We're trying to access the common sink function that fzf#wrap injects to + " the options dictionary. + let wrapped = fzf#wrap({ + \ 'source': 'git -c color.status=always status --short --untracked-files=all', + \ 'dir': root, + \ 'options': ['--ansi', '--multi', '--nth', '2..,..', '--tiebreak=index', '--prompt', 'GitFiles?> ', '--preview', 'sh -c "(git diff --color=always -- {-1} | sed 1,4d; cat {-1}) | head -500"'] + \}) + call s:remove_layout(wrapped) + let wrapped.common_sink = remove(wrapped, 'sink*') + function! wrapped.newsink(lines) + let lines = extend(a:lines[0:0], map(a:lines[1:], 'substitute(v:val[3:], ".* -> ", "", "")')) + return self.common_sink(lines) + endfunction + let wrapped['sink*'] = remove(wrapped, 'newsink') + return s:fzf('gfiles-diff', wrapped, a:000) +endfunction + +" ------------------------------------------------------------------ +" Buffers +" ------------------------------------------------------------------ +function! s:find_open_window(b) + let [tcur, tcnt] = [tabpagenr() - 1, tabpagenr('$')] + for toff in range(0, tabpagenr('$') - 1) + let t = (tcur + toff) % tcnt + 1 + let buffers = tabpagebuflist(t) + for w in range(1, len(buffers)) + let b = buffers[w - 1] + if b == a:b + return [t, w] + endif + endfor + endfor + return [0, 0] +endfunction + +function! s:jump(t, w) + execute a:t.'tabnext' + execute a:w.'wincmd w' +endfunction + +function! s:bufopen(lines) + if len(a:lines) < 2 + return + endif + let b = matchstr(a:lines[1], '\[\zs[0-9]*\ze\]') + if empty(a:lines[0]) && get(g:, 'fzf_buffers_jump') + let [t, w] = s:find_open_window(b) + if t + call s:jump(t, w) + return + endif + endif + let cmd = s:action_for(a:lines[0]) + if !empty(cmd) + execute 'silent' cmd + endif + execute 'buffer' b +endfunction + +function! s:format_buffer(b) + let name = bufname(a:b) + let line = exists('*getbufinfo') ? getbufinfo(a:b)[0]['lnum'] : 0 + let name = empty(name) ? '[No Name]' : fnamemodify(name, ":p:~:.") + let flag = a:b == bufnr('') ? s:blue('%', 'Conditional') : + \ (a:b == bufnr('#') ? s:magenta('#', 'Special') : ' ') + let modified = getbufvar(a:b, '&modified') ? s:red(' [+]', 'Exception') : '' + let readonly = getbufvar(a:b, '&modifiable') ? '' : s:green(' [RO]', 'Constant') + let extra = join(filter([modified, readonly], '!empty(v:val)'), '') + let target = line == 0 ? name : name.':'.line + return s:strip(printf("%s\t[%s] %s\t%s\t%s", target, s:yellow(a:b, 'Number'), flag, name, extra)) +endfunction + +function! s:sort_buffers(...) + let [b1, b2] = map(copy(a:000), 'get(g:fzf#vim#buffers, v:val, v:val)') + " Using minus between a float and a number in a sort function causes an error + return b1 < b2 ? 1 : -1 +endfunction + +function! s:buflisted_sorted() + return sort(s:buflisted(), 's:sort_buffers') +endfunction + +function! fzf#vim#buffers(...) + let [query, args] = (a:0 && type(a:1) == type('')) ? + \ [a:1, a:000[1:]] : ['', a:000] + return s:fzf('buffers', { + \ 'source': map(s:buflisted_sorted(), 's:format_buffer(v:val)'), + \ 'sink*': s:function('s:bufopen'), + \ 'options': ['+m', '-x', '--tiebreak=index', '--header-lines=1', '--ansi', '-d', '\t', '--with-nth', '2..', '-n', '2,1..2', '--prompt', 'Buf> ', '--query', query] + \}, args) +endfunction + +" ------------------------------------------------------------------ +" Ag / Rg +" ------------------------------------------------------------------ +function! s:ag_to_qf(line, has_column) + let parts = split(a:line, '[^:]\zs:\ze[^:]') + let text = join(parts[(a:has_column ? 3 : 2):], ':') + let dict = {'filename': &acd ? fnamemodify(parts[0], ':p') : parts[0], 'lnum': parts[1], 'text': text} + if a:has_column + let dict.col = parts[2] + endif + return dict +endfunction + +function! s:ag_handler(lines, has_column) + if len(a:lines) < 2 + return + endif + + let cmd = s:action_for(a:lines[0], 'e') + let list = map(filter(a:lines[1:], 'len(v:val)'), 's:ag_to_qf(v:val, a:has_column)') + if empty(list) + return + endif + + let first = list[0] + try + call s:open(cmd, first.filename) + execute first.lnum + if a:has_column + execute 'normal!' first.col.'|' + endif + normal! zz + catch + endtry + + call s:fill_quickfix(list) +endfunction + +" query, [[ag options], options] +function! fzf#vim#ag(query, ...) + if type(a:query) != s:TYPE.string + return s:warn('Invalid query argument') + endif + let query = empty(a:query) ? '^(?=.)' : a:query + let args = copy(a:000) + let ag_opts = len(args) > 1 && type(args[0]) == s:TYPE.string ? remove(args, 0) : '' + let command = ag_opts . ' -- ' . fzf#shellescape(query) + return call('fzf#vim#ag_raw', insert(args, command, 0)) +endfunction + +" ag command suffix, [options] +function! fzf#vim#ag_raw(command_suffix, ...) + if !executable('ag') + return s:warn('ag is not found') + endif + return call('fzf#vim#grep', extend(['ag --nogroup --column --color '.a:command_suffix, 1], a:000)) +endfunction + +" command (string), has_column (0/1), [options (dict)], [fullscreen (0/1)] +function! fzf#vim#grep(grep_command, has_column, ...) + let words = [] + for word in split(a:grep_command) + if word !~# '^[a-z]' + break + endif + call add(words, word) + endfor + let words = empty(words) ? ['grep'] : words + let name = join(words, '-') + let capname = join(map(words, 'toupper(v:val[0]).v:val[1:]'), '') + let opts = { + \ 'column': a:has_column, + \ 'options': ['--ansi', '--prompt', capname.'> ', + \ '--multi', '--bind', 'alt-a:select-all,alt-d:deselect-all', + \ '--color', 'hl:4,hl+:12'] + \} + function! opts.sink(lines) + return s:ag_handler(a:lines, self.column) + endfunction + let opts['sink*'] = remove(opts, 'sink') + try + let prev_default_command = $FZF_DEFAULT_COMMAND + let $FZF_DEFAULT_COMMAND = a:grep_command + return s:fzf(name, opts, a:000) + finally + let $FZF_DEFAULT_COMMAND = prev_default_command + endtry +endfunction + +" ------------------------------------------------------------------ +" BTags +" ------------------------------------------------------------------ +function! s:btags_source(tag_cmds) + if !filereadable(expand('%')) + throw 'Save the file first' + endif + + for cmd in a:tag_cmds + let lines = split(system(cmd), "\n") + if !v:shell_error && len(lines) + break + endif + endfor + if v:shell_error + throw get(lines, 0, 'Failed to extract tags') + elseif empty(lines) + throw 'No tags found' + endif + return map(s:align_lists(map(lines, 'split(v:val, "\t")')), 'join(v:val, "\t")') +endfunction + +function! s:btags_sink(lines) + if len(a:lines) < 2 + return + endif + normal! m' + let cmd = s:action_for(a:lines[0]) + if !empty(cmd) + execute 'silent' cmd '%' + endif + let qfl = [] + for line in a:lines[1:] + execute split(line, "\t")[2] + call add(qfl, {'filename': expand('%'), 'lnum': line('.'), 'text': getline('.')}) + endfor + call s:fill_quickfix(qfl, 'cfirst') + normal! zz +endfunction + +" query, [[tag commands], options] +function! fzf#vim#buffer_tags(query, ...) + let args = copy(a:000) + let escaped = fzf#shellescape(expand('%')) + let null = s:is_win ? 'nul' : '/dev/null' + let sort = has('unix') && !has('win32unix') && executable('sort') ? '| sort -s -k 5' : '' + let tag_cmds = (len(args) > 1 && type(args[0]) != type({})) ? remove(args, 0) : [ + \ printf('ctags -f - --sort=yes --excmd=number --language-force=%s %s 2> %s %s', &filetype, escaped, null, sort), + \ printf('ctags -f - --sort=yes --excmd=number %s 2> %s %s', escaped, null, sort)] + if type(tag_cmds) != type([]) + let tag_cmds = [tag_cmds] + endif + try + return s:fzf('btags', { + \ 'source': s:btags_source(tag_cmds), + \ 'sink*': s:function('s:btags_sink'), + \ 'options': s:reverse_list(['-m', '-d', '\t', '--with-nth', '1,4..', '-n', '1', '--prompt', 'BTags> ', '--query', a:query])}, args) + catch + return s:warn(v:exception) + endtry +endfunction + +" ------------------------------------------------------------------ +" Tags +" ------------------------------------------------------------------ +function! s:tags_sink(lines) + if len(a:lines) < 2 + return + endif + normal! m' + let qfl = [] + let cmd = s:action_for(a:lines[0], 'e') + try + let [magic, &magic, wrapscan, &wrapscan, acd, &acd] = [&magic, 0, &wrapscan, 1, &acd, 0] + for line in a:lines[1:] + try + let parts = split(line, '\t\zs') + let excmd = matchstr(join(parts[2:-2], '')[:-2], '^.\{-}\ze;\?"\t') + let base = fnamemodify(parts[-1], ':h') + let relpath = parts[1][:-2] + let abspath = relpath =~ (s:is_win ? '^[A-Z]:\' : '^/') ? relpath : join([base, relpath], '/') + call s:open(cmd, expand(abspath, 1)) + silent execute excmd + call add(qfl, {'filename': expand('%'), 'lnum': line('.'), 'text': getline('.')}) + catch /^Vim:Interrupt$/ + break + catch + call s:warn(v:exception) + endtry + endfor + finally + let [&magic, &wrapscan, &acd] = [magic, wrapscan, acd] + endtry + call s:fill_quickfix(qfl, 'clast') + normal! zz +endfunction + +function! fzf#vim#tags(query, ...) + if !executable('perl') + return s:warn('Tags command requires perl') + endif + if empty(tagfiles()) + call inputsave() + echohl WarningMsg + let gen = input('tags not found. Generate? (y/N) ') + echohl None + call inputrestore() + redraw + if gen =~? '^y' + call s:warn('Preparing tags') + call system(get(g:, 'fzf_tags_command', 'ctags -R'.(s:is_win ? ' --output-format=e-ctags' : ''))) + if empty(tagfiles()) + return s:warn('Failed to create tags') + endif + else + return s:warn('No tags found') + endif + endif + + let tagfiles = tagfiles() + let v2_limit = 1024 * 1024 * 200 + for tagfile in tagfiles + let v2_limit -= getfsize(tagfile) + if v2_limit < 0 + break + endif + endfor + let opts = v2_limit < 0 ? ['--algo=v1'] : [] + + return s:fzf('tags', { + \ 'source': 'perl '.fzf#shellescape(s:bin.tags).' '.join(map(tagfiles, 'fzf#shellescape(fnamemodify(v:val, ":p"))')), + \ 'sink*': s:function('s:tags_sink'), + \ 'options': extend(opts, ['--nth', '1..2', '-m', '--tiebreak=begin', '--prompt', 'Tags> ', '--query', a:query])}, a:000) +endfunction + +" ------------------------------------------------------------------ +" Snippets (UltiSnips) +" ------------------------------------------------------------------ +function! s:inject_snippet(line) + let snip = split(a:line, "\t")[0] + execute 'normal! a'.s:strip(snip)."\=UltiSnips#ExpandSnippet()\" +endfunction + +function! fzf#vim#snippets(...) + if !exists(':UltiSnipsEdit') + return s:warn('UltiSnips not found') + endif + let list = UltiSnips#SnippetsInCurrentScope() + if empty(list) + return s:warn('No snippets available here') + endif + let aligned = sort(s:align_lists(items(list))) + let colored = map(aligned, 's:yellow(v:val[0])."\t".v:val[1]') + return s:fzf('snippets', { + \ 'source': colored, + \ 'options': '--ansi --tiebreak=index +m -n 1 -d "\t"', + \ 'sink': s:function('s:inject_snippet')}, a:000) +endfunction + +" ------------------------------------------------------------------ +" Commands +" ------------------------------------------------------------------ +let s:nbs = nr2char(0x2007) + +function! s:format_cmd(line) + return substitute(a:line, '\C \([A-Z]\S*\) ', + \ '\=s:nbs.s:yellow(submatch(1), "Function").s:nbs', '') +endfunction + +function! s:command_sink(lines) + if len(a:lines) < 2 + return + endif + let cmd = matchstr(a:lines[1], s:nbs.'\zs\S*\ze'.s:nbs) + if empty(a:lines[0]) + call feedkeys(':'.cmd.(a:lines[1][0] == '!' ? '' : ' '), 'n') + else + execute cmd + endif +endfunction + +let s:fmt_excmd = ' '.s:blue('%-38s', 'Statement').'%s' + +function! s:format_excmd(ex) + let match = matchlist(a:ex, '^|:\(\S\+\)|\s*\S*\(.*\)') + return printf(s:fmt_excmd, s:nbs.match[1].s:nbs, s:strip(match[2])) +endfunction + +function! s:excmds() + let help = globpath($VIMRUNTIME, 'doc/index.txt') + if empty(help) + return [] + endif + + let commands = [] + let command = '' + for line in readfile(help) + if line =~ '^|:[^|]' + if !empty(command) + call add(commands, s:format_excmd(command)) + endif + let command = line + elseif line =~ '^\s\+\S' && !empty(command) + let command .= substitute(line, '^\s*', ' ', '') + elseif !empty(commands) && line =~ '^\s*$' + break + endif + endfor + if !empty(command) + call add(commands, s:format_excmd(command)) + endif + return commands +endfunction + +function! fzf#vim#commands(...) + redir => cout + silent command + redir END + let list = split(cout, "\n") + return s:fzf('commands', { + \ 'source': extend(extend(list[0:0], map(list[1:], 's:format_cmd(v:val)')), s:excmds()), + \ 'sink*': s:function('s:command_sink'), + \ 'options': '--ansi --expect '.get(g:, 'fzf_commands_expect', 'ctrl-x'). + \ ' --tiebreak=index --header-lines 1 -x --prompt "Commands> " -n2,3,2..3 -d'.s:nbs}, a:000) +endfunction + +" ------------------------------------------------------------------ +" Marks +" ------------------------------------------------------------------ +function! s:format_mark(line) + return substitute(a:line, '\S', '\=s:yellow(submatch(0), "Number")', '') +endfunction + +function! s:mark_sink(lines) + if len(a:lines) < 2 + return + endif + let cmd = s:action_for(a:lines[0]) + if !empty(cmd) + execute 'silent' cmd + endif + execute 'normal! `'.matchstr(a:lines[1], '\S').'zz' +endfunction + +function! fzf#vim#marks(...) + redir => cout + silent marks + redir END + let list = split(cout, "\n") + return s:fzf('marks', { + \ 'source': extend(list[0:0], map(list[1:], 's:format_mark(v:val)')), + \ 'sink*': s:function('s:mark_sink'), + \ 'options': '+m -x --ansi --tiebreak=index --header-lines 1 --tiebreak=begin --prompt "Marks> "'}, a:000) +endfunction + +" ------------------------------------------------------------------ +" Help tags +" ------------------------------------------------------------------ +function! s:helptag_sink(line) + let [tag, file, path] = split(a:line, "\t")[0:2] + let rtp = fnamemodify(path, ':p:h:h') + if stridx(&rtp, rtp) < 0 + execute 'set rtp+='.s:escape(rtp) + endif + execute 'help' tag +endfunction + +function! fzf#vim#helptags(...) + if !executable('grep') || !executable('perl') + return s:warn('Helptags command requires grep and perl') + endif + let sorted = sort(split(globpath(&runtimepath, 'doc/tags', 1), '\n')) + let tags = exists('*uniq') ? uniq(sorted) : fzf#vim#_uniq(sorted) + + if exists('s:helptags_script') + silent! call delete(s:helptags_script) + endif + let s:helptags_script = tempname() + call writefile(['/('.(s:is_win ? '^[A-Z]:\/.*?[^:]' : '.*?').'):(.*?)\t(.*?)\t/; printf(qq('.s:green('%-40s', 'Label').'\t%s\t%s\n), $2, $3, $1)'], s:helptags_script) + return s:fzf('helptags', { + \ 'source': 'grep -H ".*" '.join(map(tags, 'fzf#shellescape(v:val)')). + \ ' | perl -n '.fzf#shellescape(s:helptags_script).' | sort', + \ 'sink': s:function('s:helptag_sink'), + \ 'options': ['--ansi', '+m', '--tiebreak=begin', '--with-nth', '..-2']}, a:000) +endfunction + +" ------------------------------------------------------------------ +" File types +" ------------------------------------------------------------------ +function! fzf#vim#filetypes(...) + return s:fzf('filetypes', { + \ 'source': fzf#vim#_uniq(sort(map(split(globpath(&rtp, 'syntax/*.vim'), '\n'), + \ 'fnamemodify(v:val, ":t:r")'))), + \ 'sink': 'setf', + \ 'options': '+m --prompt="File types> "' + \}, a:000) +endfunction + +" ------------------------------------------------------------------ +" Windows +" ------------------------------------------------------------------ +function! s:format_win(tab, win, buf) + let modified = getbufvar(a:buf, '&modified') + let name = bufname(a:buf) + let name = empty(name) ? '[No Name]' : name + let active = tabpagewinnr(a:tab) == a:win + return (active? s:blue('> ', 'Operator') : ' ') . name . (modified? s:red(' [+]', 'Exception') : '') +endfunction + +function! s:windows_sink(line) + let list = matchlist(a:line, '^ *\([0-9]\+\) *\([0-9]\+\)') + call s:jump(list[1], list[2]) +endfunction + +function! fzf#vim#windows(...) + let lines = [] + for t in range(1, tabpagenr('$')) + let buffers = tabpagebuflist(t) + for w in range(1, len(buffers)) + call add(lines, + \ printf('%s %s %s', + \ s:yellow(printf('%3d', t), 'Number'), + \ s:cyan(printf('%3d', w), 'String'), + \ s:format_win(t, w, buffers[w-1]))) + endfor + endfor + return s:fzf('windows', { + \ 'source': extend(['Tab Win Name'], lines), + \ 'sink': s:function('s:windows_sink'), + \ 'options': '+m --ansi --tiebreak=begin --header-lines=1'}, a:000) +endfunction + +" ------------------------------------------------------------------ +" Commits / BCommits +" ------------------------------------------------------------------ +function! s:yank_to_register(data) + let @" = a:data + silent! let @* = a:data + silent! let @+ = a:data +endfunction + +function! s:commits_sink(lines) + if len(a:lines) < 2 + return + endif + + let pat = '[0-9a-f]\{7,9}' + + if a:lines[0] == 'ctrl-y' + let hashes = join(filter(map(a:lines[1:], 'matchstr(v:val, pat)'), 'len(v:val)')) + return s:yank_to_register(hashes) + end + + let diff = a:lines[0] == 'ctrl-d' + let cmd = s:action_for(a:lines[0], 'e') + let buf = bufnr('') + for idx in range(1, len(a:lines) - 1) + let sha = matchstr(a:lines[idx], pat) + if !empty(sha) + if diff + if idx > 1 + execute 'tab sb' buf + endif + execute 'Gdiff' sha + else + " Since fugitive buffers are unlisted, we can't keep using 'e' + let c = (cmd == 'e' && idx > 1) ? 'tab split' : cmd + execute c FugitiveFind(sha) + endif + endif + endfor +endfunction + +function! s:commits(buffer_local, args) + let s:git_root = s:get_git_root() + if empty(s:git_root) + return s:warn('Not in git repository') + endif + + let source = 'git log '.get(g:, 'fzf_commits_log_options', '--color=always '.fzf#shellescape('--format=%C(auto)%h%d %s %C(green)%cr')) + let current = expand('%') + let managed = 0 + if !empty(current) + call system('git show '.fzf#shellescape(current).' 2> '.(s:is_win ? 'nul' : '/dev/null')) + let managed = !v:shell_error + endif + + if a:buffer_local + if !managed + return s:warn('The current buffer is not in the working tree') + endif + let source .= ' --follow '.fzf#shellescape(current) + else + let source .= ' --graph' + endif + + let command = a:buffer_local ? 'BCommits' : 'Commits' + let expect_keys = join(keys(get(g:, 'fzf_action', s:default_action)), ',') + let options = { + \ 'source': source, + \ 'sink*': s:function('s:commits_sink'), + \ 'options': s:reverse_list(['--ansi', '--multi', '--tiebreak=index', + \ '--inline-info', '--prompt', command.'> ', '--bind=ctrl-s:toggle-sort', + \ '--header', ':: Press '.s:magenta('CTRL-S', 'Special').' to toggle sort, '.s:magenta('CTRL-Y', 'Special').' to yank commit hashes', + \ '--expect=ctrl-y,'.expect_keys]) + \ } + + if a:buffer_local + let options.options[-2] .= ', '.s:magenta('CTRL-D', 'Special').' to diff' + let options.options[-1] .= ',ctrl-d' + endif + + if !s:is_win && &columns > s:wide + call extend(options.options, + \ ['--preview', 'echo {} | grep -o "[a-f0-9]\{7,\}" | head -1 | xargs git show --format=format: --color=always | head -200']) + endif + + return s:fzf(a:buffer_local ? 'bcommits' : 'commits', options, a:args) +endfunction + +function! fzf#vim#commits(...) + return s:commits(0, a:000) +endfunction + +function! fzf#vim#buffer_commits(...) + return s:commits(1, a:000) +endfunction + +" ------------------------------------------------------------------ +" fzf#vim#maps(mode, opts[with count and op]) +" ------------------------------------------------------------------ +function! s:align_pairs(list) + let maxlen = 0 + let pairs = [] + for elem in a:list + let match = matchlist(elem, '^\(\S*\)\s*\(.*\)$') + let [_, k, v] = match[0:2] + let maxlen = max([maxlen, len(k)]) + call add(pairs, [k, substitute(v, '^\*\?[@ ]\?', '', '')]) + endfor + let maxlen = min([maxlen, 35]) + return map(pairs, "printf('%-'.maxlen.'s', v:val[0]).' '.v:val[1]") +endfunction + +function! s:highlight_keys(str) + return substitute( + \ substitute(a:str, '<[^ >]\+>', s:yellow('\0', 'Special'), 'g'), + \ '', s:blue('', 'SpecialKey'), 'g') +endfunction + +function! s:key_sink(line) + let key = matchstr(a:line, '^\S*') + redraw + call feedkeys(s:map_gv.s:map_cnt.s:map_reg, 'n') + call feedkeys(s:map_op. + \ substitute(key, '<[^ >]\+>', '\=eval("\"\\".submatch(0)."\"")', 'g')) +endfunction + +function! fzf#vim#maps(mode, ...) + let s:map_gv = a:mode == 'x' ? 'gv' : '' + let s:map_cnt = v:count == 0 ? '' : v:count + let s:map_reg = empty(v:register) ? '' : ('"'.v:register) + let s:map_op = a:mode == 'o' ? v:operator : '' + + redir => cout + silent execute 'verbose' a:mode.'map' + redir END + let list = [] + let curr = '' + for line in split(cout, "\n") + if line =~ "^\t" + let src = "\t".substitute(matchstr(line, '/\zs[^/\\]*\ze$'), ' [^ ]* ', ':', '') + call add(list, printf('%s %s', curr, s:green(src, 'Comment'))) + let curr = '' + else + let curr = line[3:] + endif + endfor + if !empty(curr) + call add(list, curr) + endif + let aligned = s:align_pairs(list) + let sorted = sort(aligned) + let colored = map(sorted, 's:highlight_keys(v:val)') + let pcolor = a:mode == 'x' ? 9 : a:mode == 'o' ? 10 : 12 + return s:fzf('maps', { + \ 'source': colored, + \ 'sink': s:function('s:key_sink'), + \ 'options': '--prompt "Maps ('.a:mode.')> " --ansi --no-hscroll --nth 1,.. --color prompt:'.pcolor}, a:000) +endfunction + +" ---------------------------------------------------------------------------- +" fzf#vim#complete - completion helper +" ---------------------------------------------------------------------------- +inoremap (-fzf-complete-trigger) :call complete_trigger() + +function! s:pluck(dict, key, default) + return has_key(a:dict, a:key) ? remove(a:dict, a:key) : a:default +endfunction + +function! s:complete_trigger() + let opts = copy(s:opts) + call s:prepend_opts(opts, ['+m', '-q', s:query]) + let opts['sink*'] = s:function('s:complete_insert') + let s:reducer = s:pluck(opts, 'reducer', s:function('s:first_line')) + call fzf#run(opts) +endfunction + +" The default reducer +function! s:first_line(lines) + return a:lines[0] +endfunction + +function! s:complete_insert(lines) + if empty(a:lines) + return + endif + + let chars = strchars(s:query) + if chars == 0 | let del = '' + elseif chars == 1 | let del = '"_x' + else | let del = (chars - 1).'"_dvh' + endif + + let data = call(s:reducer, [a:lines]) + let ve = &ve + set ve= + execute 'normal!' ((s:eol || empty(chars)) ? '' : 'h').del.(s:eol ? 'a': 'i').data + let &ve = ve + if mode() =~ 't' + call feedkeys('a', 'n') + else + execute "normal! \la" + endif +endfunction + +function! s:eval(dict, key, arg) + if has_key(a:dict, a:key) && type(a:dict[a:key]) == s:TYPE.funcref + let ret = copy(a:dict) + let ret[a:key] = call(a:dict[a:key], [a:arg]) + return ret + endif + return a:dict +endfunction + +function! fzf#vim#complete(...) + if a:0 == 0 + let s:opts = fzf#wrap() + elseif type(a:1) == s:TYPE.dict + let s:opts = copy(a:1) + elseif type(a:1) == s:TYPE.string + let s:opts = extend({'source': a:1}, get(a:000, 1, fzf#wrap())) + else + echoerr 'Invalid argument: '.string(a:000) + return '' + endif + for s in ['sink', 'sink*'] + if has_key(s:opts, s) + call remove(s:opts, s) + endif + endfor + + let eol = col('$') + let ve = &ve + set ve=all + let s:eol = col('.') == eol + let &ve = ve + + let Prefix = s:pluck(s:opts, 'prefix', '\k*$') + if col('.') == 1 + let s:query = '' + else + let full_prefix = getline('.')[0 : col('.')-2] + if type(Prefix) == s:TYPE.funcref + let s:query = call(Prefix, [full_prefix]) + else + let s:query = matchstr(full_prefix, Prefix) + endif + endif + let s:opts = s:eval(s:opts, 'source', s:query) + let s:opts = s:eval(s:opts, 'options', s:query) + let s:opts = s:eval(s:opts, 'extra_options', s:query) + if has_key(s:opts, 'extra_options') + call s:merge_opts(s:opts, remove(s:opts, 'extra_options')) + endif + if has_key(s:opts, 'options') + if type(s:opts.options) == s:TYPE.list + call add(s:opts.options, '--no-expect') + else + let s:opts.options .= ' --no-expect' + endif + endif + + call feedkeys("\(-fzf-complete-trigger)") + return '' +endfunction + +" ------------------------------------------------------------------ +let &cpo = s:cpo_save +unlet s:cpo_save + diff --git a/skel/.config/nvim/plugged/fzf.vim/autoload/fzf/vim/complete.vim b/skel/.config/nvim/plugged/fzf.vim/autoload/fzf/vim/complete.vim new file mode 100644 index 0000000..03c9b3b --- /dev/null +++ b/skel/.config/nvim/plugged/fzf.vim/autoload/fzf/vim/complete.vim @@ -0,0 +1,163 @@ +" Copyright (c) 2015 Junegunn Choi +" +" MIT License +" +" Permission is hereby granted, free of charge, to any person obtaining +" a copy of this software and associated documentation files (the +" "Software"), to deal in the Software without restriction, including +" without limitation the rights to use, copy, modify, merge, publish, +" distribute, sublicense, and/or sell copies of the Software, and to +" permit persons to whom the Software is furnished to do so, subject to +" the following conditions: +" +" The above copyright notice and this permission notice shall be +" included in all copies or substantial portions of the Software. +" +" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +" EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +" NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +" LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +" OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +" WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +let s:cpo_save = &cpo +set cpo&vim +let s:is_win = has('win32') || has('win64') + +function! s:extend(base, extra) + let base = copy(a:base) + if has_key(a:extra, 'options') + let extra = copy(a:extra) + let extra.extra_options = remove(extra, 'options') + return extend(base, extra) + endif + return extend(base, a:extra) +endfunction + +if v:version >= 704 + function! s:function(name) + return function(a:name) + endfunction +else + function! s:function(name) + " By Ingo Karkat + return function(substitute(a:name, '^s:', matchstr(expand(''), '\d\+_\zefunction$'), '')) + endfunction +endif + +function! fzf#vim#complete#word(...) + return fzf#vim#complete(s:extend({ + \ 'source': 'cat /usr/share/dict/words'}, + \ get(a:000, 0, fzf#wrap()))) +endfunction + +" ---------------------------------------------------------------------------- +" (fzf-complete-path) +" (fzf-complete-file) +" (fzf-complete-file-ag) +" ---------------------------------------------------------------------------- +function! s:file_split_prefix(prefix) + let expanded = expand(a:prefix) + let slash = (s:is_win && !&shellslash) ? '\\' : '/' + return isdirectory(expanded) ? + \ [expanded, + \ substitute(a:prefix, '[/\\]*$', slash, ''), + \ ''] : + \ [fnamemodify(expanded, ':h'), + \ substitute(fnamemodify(a:prefix, ':h'), '[/\\]*$', slash, ''), + \ fnamemodify(expanded, ':t')] +endfunction + +function! s:file_source(prefix) + let [dir, head, tail] = s:file_split_prefix(a:prefix) + return printf( + \ "cd %s && ".s:file_cmd." | sed %s", + \ fzf#shellescape(dir), fzf#shellescape('s:^:'.(empty(a:prefix) || a:prefix == tail ? '' : head).':')) +endfunction + +function! s:file_options(prefix) + let [_, head, tail] = s:file_split_prefix(a:prefix) + return ['--prompt', head, '--query', tail] +endfunction + +function! s:fname_prefix(str) + let isf = &isfname + let white = [] + let black = [] + if isf =~ ',,,' + call add(white, ',') + let isf = substitute(isf, ',,,', ',', 'g') + endif + if isf =~ ',^,,' + call add(black, ',') + let isf = substitute(isf, ',^,,', ',', 'g') + endif + + for token in split(isf, ',') + let target = white + if token[0] == '^' + let target = black + let token = token[1:] + endif + + let ends = matchlist(token, '\(.\+\)-\(.\+\)') + if empty(ends) + call add(target, token) + else + let ends = map(ends[1:2], "len(v:val) == 1 ? char2nr(v:val) : str2nr(v:val)") + for i in range(ends[0], ends[1]) + call add(target, nr2char(i)) + endfor + endif + endfor + + let prefix = a:str + for offset in range(1, len(a:str)) + let char = a:str[len(a:str) - offset] + if (char =~ '\w' || index(white, char) >= 0) && index(black, char) < 0 + continue + endif + let prefix = strpart(a:str, len(a:str) - offset + 1) + break + endfor + + return prefix +endfunction + +function! fzf#vim#complete#path(command, ...) + let s:file_cmd = a:command + return fzf#vim#complete(s:extend({ + \ 'prefix': s:function('s:fname_prefix'), + \ 'source': s:function('s:file_source'), + \ 'options': s:function('s:file_options')}, get(a:000, 0, fzf#wrap()))) +endfunction + +" ---------------------------------------------------------------------------- +" (fzf-complete-line) +" (fzf-complete-buffer-line) +" ---------------------------------------------------------------------------- +function! s:reduce_line(lines) + return join(split(a:lines[0], '\t\zs')[3:], '') +endfunction + + +function! fzf#vim#complete#line(...) + let [display_bufnames, lines] = fzf#vim#_lines(0) + let nth = display_bufnames ? 4 : 3 + return fzf#vim#complete(s:extend({ + \ 'prefix': '^.*$', + \ 'source': lines, + \ 'options': '--tiebreak=index --ansi --nth '.nth.'.. --tabstop=1', + \ 'reducer': s:function('s:reduce_line')}, get(a:000, 0, fzf#wrap()))) +endfunction + +function! fzf#vim#complete#buffer_line(...) + return fzf#vim#complete(s:extend({ + \ 'prefix': '^.*$', + \ 'source': fzf#vim#_uniq(getline(1, '$'))}, get(a:000, 0, fzf#wrap()))) +endfunction + +let &cpo = s:cpo_save +unlet s:cpo_save + diff --git a/skel/.config/nvim/plugged/fzf.vim/bin/preview.rb b/skel/.config/nvim/plugged/fzf.vim/bin/preview.rb new file mode 100755 index 0000000..4532421 --- /dev/null +++ b/skel/.config/nvim/plugged/fzf.vim/bin/preview.rb @@ -0,0 +1,3 @@ +#!/usr/bin/env ruby + +puts 'preview.rb is deprecated. Use preview.sh instead.' diff --git a/skel/.config/nvim/plugged/fzf.vim/bin/preview.sh b/skel/.config/nvim/plugged/fzf.vim/bin/preview.sh new file mode 100755 index 0000000..f9c8db1 --- /dev/null +++ b/skel/.config/nvim/plugged/fzf.vim/bin/preview.sh @@ -0,0 +1,69 @@ +#!/usr/bin/env bash + +REVERSE="\x1b[7m" +RESET="\x1b[m" + +if [ -z "$1" ]; then + echo "usage: $0 FILENAME[:LINENO][:IGNORED]" + exit 1 +fi + +IFS=':' read -r -a INPUT <<< "$1" +FILE=${INPUT[0]} +CENTER=${INPUT[1]} + +if [[ $1 =~ ^[A-Z]:\\ ]]; then + FILE=$FILE:${INPUT[1]} + CENTER=${INPUT[2]} +fi + +if [[ -n "$CENTER" && ! "$CENTER" =~ ^[0-9] ]]; then + exit 1 +fi +CENTER=${CENTER/[^0-9]*/} + +FILE="${FILE/#\~\//$HOME/}" +if [ ! -r "$FILE" ]; then + echo "File not found ${FILE}" + exit 1 +fi + +MIME=$(file --dereference --mime "$FILE") +if [[ "$MIME" =~ binary ]]; then + echo "$MIME" + exit 0 +fi + +if [ -z "$CENTER" ]; then + CENTER=0 +fi + +if [ -n "$FZF_PREVIEW_LINES" ]; then + LINES=$FZF_PREVIEW_LINES +else + if [ -r /dev/tty ]; then + LINES=$(stty size < /dev/tty | awk '{print $1}') + else + LINES=40 + fi +fi + +FIRST=$(($CENTER-$LINES/3)) +FIRST=$(($FIRST < 1 ? 1 : $FIRST)) +LAST=$((${FIRST}+${LINES}-1)) + +if [ -z "$FZF_PREVIEW_COMMAND" ] && command -v bat > /dev/null; then + bat --style="${BAT_STYLE:-numbers}" --color=always --pager=never \ + --line-range=$FIRST:$LAST --highlight-line=$CENTER "$FILE" + exit $? +fi + +DEFAULT_COMMAND="highlight -O ansi -l {} || coderay {} || rougify {} || cat {}" +CMD=${FZF_PREVIEW_COMMAND:-$DEFAULT_COMMAND} +CMD=${CMD//{\}/$(printf %q "$FILE")} + +eval "$CMD" 2> /dev/null | awk "NR >= $FIRST && NR <= $LAST { \ + if (NR == $CENTER) \ + { gsub(/\x1b[[0-9;]*m/, \"&$REVERSE\"); printf(\"$REVERSE%s\n$RESET\", \$0); } \ + else printf(\"$RESET%s\n\", \$0); \ + }" diff --git a/skel/.config/nvim/plugged/fzf.vim/bin/tags.pl b/skel/.config/nvim/plugged/fzf.vim/bin/tags.pl new file mode 100755 index 0000000..4208c16 --- /dev/null +++ b/skel/.config/nvim/plugged/fzf.vim/bin/tags.pl @@ -0,0 +1,15 @@ +#!/usr/bin/env perl + +use strict; + +foreach my $file (@ARGV) { + open my $lines, $file; + while (<$lines>) { + unless (/^\!/) { + s/^[^\t]*/sprintf("%-24s", $&)/e; + s/$/\t$file/; + print; + } + } + close $lines; +} diff --git a/skel/.config/nvim/plugged/fzf.vim/doc/fzf-vim.txt b/skel/.config/nvim/plugged/fzf.vim/doc/fzf-vim.txt new file mode 100644 index 0000000..6b53a37 --- /dev/null +++ b/skel/.config/nvim/plugged/fzf.vim/doc/fzf-vim.txt @@ -0,0 +1,470 @@ +fzf-vim.txt fzf-vim Last change: May 3 2020 +FZF-VIM - TABLE OF CONTENTS *fzf-vim* *fzf-vim-toc* +============================================================================== + + fzf :heart: vim + Rationale + Why you should use fzf on Vim + Installation + Using vim-plug + Commands + Customization + Global options + Preview window + Command-local options + Advanced customization + Vim functions + Example: Customizing Files command + Example: git grep wrapper + Example: Rg command with preview window + Example: Advanced ripgrep integration + Mappings + Completion functions + Custom completion + Reducer example + Status line of terminal buffer + Hide statusline + Custom statusline + License + +FZF :HEART: VIM *fzf-vim-fzfheart-vim* +============================================================================== + +Things you can do with {fzf}{1} and Vim. + + {1} https://github.com/junegunn/fzf + + +RATIONALE *fzf-vim-rationale* +============================================================================== + +{fzf}{1} in itself is not a Vim plugin, and the official repository only +provides the {basic wrapper function}{2} for Vim and it's up to the users to +write their own Vim commands with it. However, I've learned that many users of +fzf are not familiar with Vimscript and are looking for the "default" +implementation of the features they can find in the alternative Vim plugins. + +This repository is a bundle of fzf-based commands and mappings extracted from +my {.vimrc}{3} to address such needs. They are not designed to be flexible or +configurable, and there's no guarantee of backward-compatibility. + + {1} https://github.com/junegunn/fzf + {2} https://github.com/junegunn/fzf/blob/master/README-VIM.md#fzfrun + {3} https://github.com/junegunn/dotfiles/blob/master/vimrc + + +WHY YOU SHOULD USE FZF ON VIM *fzf-vim-why-you-should-use-fzf-on-vim* +============================================================================== + +Because you can and you love fzf. + +fzf runs asynchronously and can be orders of magnitude faster than similar Vim +plugins. However, the benefit may not be noticeable if the size of the input +is small, which is the case for many of the commands provided here. +Nevertheless I wrote them anyway since it's really easy to implement custom +selector with fzf. + + +INSTALLATION *fzf-vim-installation* +============================================================================== + +fzf.vim depends on the basic Vim plugin of {the main fzf repository}{1}, which +means you need to set up both "fzf" and "fzf.vim" on Vim. To learn more about +fzf/Vim integration, see {README-VIM}{4}. + + {1} https://github.com/junegunn/fzf + {4} https://github.com/junegunn/fzf/blob/master/README-VIM.md + + +< Using vim-plug >____________________________________________________________~ + *fzf-vim-using-vim-plug* +> + Plug 'junegunn/fzf', { 'do': { -> fzf#install() } } + Plug 'junegunn/fzf.vim' +< +`fzf#install()` makes sure that you have the latest binary, but it's optional, +so you can omit it if you use a plugin manager that doesn't support hooks. + + +COMMANDS *fzf-vim-commands* +============================================================================== + + *:Files* *:GFiles* *:Buffers* *:Colors* *:Ag* *:Rg* *:Lines* *:BLines* *:Tags* *:BTags* *:Marks* + *:Windows* *:Locate* *:History* *:Snippets* *:Commits* *:BCommits* *:Commands* *:Maps* + *:Helptags* *:Filetypes* + + ------------------+----------------------------------------------------------------------- + Command | List ~ + ------------------+----------------------------------------------------------------------- + `:Files [PATH]` | Files (runs `$FZF_DEFAULT_COMMAND` if defined) + `:GFiles [OPTS]` | Git files ( `git ls-files` ) + `:GFiles?` | Git files ( `git status` ) + `:Buffers` | Open buffers + `:Colors` | Color schemes + `:Ag [PATTERN]` | {ag}{5} search result ( `ALT-A` to select all, `ALT-D` to deselect all) + `:Rg [PATTERN]` | {rg}{6} search result ( `ALT-A` to select all, `ALT-D` to deselect all) + `:Lines [QUERY]` | Lines in loaded buffers + `:BLines [QUERY]` | Lines in the current buffer + `:Tags [QUERY]` | Tags in the project ( `ctags -R` ) + `:BTags [QUERY]` | Tags in the current buffer + `:Marks` | Marks + `:Windows` | Windows + `:Locate PATTERN` | `locate` command output + `:History` | `v:oldfiles` and open buffers + `:History:` | Command history + `:History/` | Search history + `:Snippets` | Snippets ({UltiSnips}{7}) + `:Commits` | Git commits (requires {fugitive.vim}{8}) + `:BCommits` | Git commits for the current buffer + `:Commands` | Commands + `:Maps` | Normal mode mappings + `:Helptags` | Help tags [1] + `:Filetypes` | File types + ------------------+----------------------------------------------------------------------- + + *g:fzf_command_prefix* + + - Most commands support CTRL-T / CTRL-X / CTRL-V key bindings to open in a new + tab, a new split, or in a new vertical split + - Bang-versions of the commands (e.g. `Ag!`) will open fzf in fullscreen + - You can set `g:fzf_command_prefix` to give the same prefix to the commands + - e.g. `let g:fzf_command_prefix = 'Fzf'` and you have `FzfFiles`, etc. + +(1: `Helptags` will shadow the command of the same name from {pathogen}{9}. +But its functionality is still available via `call pathogen#helptags()`.) + + {5} https://github.com/ggreer/the_silver_searcher + {6} https://github.com/BurntSushi/ripgrep + {7} https://github.com/SirVer/ultisnips + {8} https://github.com/tpope/vim-fugitive + {9} https://github.com/tpope/vim-pathogen + + +CUSTOMIZATION *fzf-vim-customization* +============================================================================== + + +< Global options >____________________________________________________________~ + *fzf-vim-global-options* + +Every command in fzf.vim internally calls `fzf#wrap` function of the main +repository which supports a set of global option variables. So please read +through {README-VIM}{4} to learn more about them. + + {4} https://github.com/junegunn/fzf/blob/master/README-VIM.md + + +Preview window~ + *fzf-vim-preview-window* + + *g:fzf_preview_window* + +If the width of the screen is wider than 120 columns, some commands will show +the preview window on the right. You can customize the behavior with +`g:fzf_preview_window`. Here are some examples: +> + " Empty value to disable preview window altogether + let g:fzf_preview_window = '' + + " Always enable preview window on the right with 60% width + let g:fzf_preview_window = 'right:60%' +< + +< Command-local options >_____________________________________________________~ + *fzf-vim-command-local-options* + +A few commands in fzf.vim can be customized with global option variables shown +below. + + *g:fzf_buffers_jump* *g:fzf_commits_log_options* *g:fzf_tags_command* + *g:fzf_commands_expect* +> + " [Buffers] Jump to the existing window if possible + let g:fzf_buffers_jump = 1 + + " [[B]Commits] Customize the options used by 'git log': + let g:fzf_commits_log_options = '--graph --color=always --format="%C(auto)%h%d %s %C(black)%C(bold)%cr"' + + " [Tags] Command to generate tags file + let g:fzf_tags_command = 'ctags -R' + + " [Commands] --expect expression for directly executing the command + let g:fzf_commands_expect = 'alt-enter,ctrl-x' +< + +< Advanced customization >____________________________________________________~ + *fzf-vim-advanced-customization* + + +Vim functions~ + *fzf-vim-vim-functions* + +Each command in fzf.vim is backed by a Vim function. You can override a +command or define a variation of it by calling its corresponding function. + + ----------+--------------------------------------------------------------------------- + Command | Vim function ~ + ----------+--------------------------------------------------------------------------- + `Files` | `fzf#vim#files(dir, [spec dict], [fullscreen bool])` + `GFiles` | `fzf#vim#gitfiles(git_options, [spec dict], [fullscreen bool])` + `GFiles?` | `fzf#vim#gitfiles('?', [spec dict], [fullscreen bool])` + `Buffers` | `fzf#vim#buffers([spec dict], [fullscreen bool])` + `Colors` | `fzf#vim#colors([spec dict], [fullscreen bool])` + `Rg` | `fzf#vim#grep(command, [has_column bool], [spec dict], [fullscreen bool])` + ... | ... + ----------+--------------------------------------------------------------------------- + +(We can see that the last two optional arguments of each function are +identical. They are directly passed to `fzf#wrap` function. If you haven't +read {README-VIM}{4} already, please read it before proceeding.) + + {4} https://github.com/junegunn/fzf/blob/master/README-VIM.md + + +Example: Customizing Files command~ + *fzf-vim-example-customizing-files-command* + +This is the default definition of `Files` command: +> + command! -bang -nargs=? -complete=dir Files call fzf#vim#files(, 0) +< +Let's say you want to a variation of it called `ProjectFiles` that only +searches inside `~/projects` directory. Then you can do it like this: +> + command! -bang ProjectFiles call fzf#vim#files('~/projects', 0) +< +Or, if you want to override the command with different fzf options, just pass +a custom spec to the function. +> + command! -bang -nargs=? -complete=dir Files + \ call fzf#vim#files(, {'options': ['--layout=reverse', '--info=inline']}, 0) +< +Want a preview window? +> + command! -bang -nargs=? -complete=dir Files + \ call fzf#vim#files(, {'options': ['--layout=reverse', '--info=inline', '--preview', 'cat {}']}, 0) +< +It kind of works, but you probably want a nicer previewer program than `cat`. +fzf.vim ships {a versatile preview script}{10} you can readily use. It +internally executes {bat}{11} for syntax highlighting, so make sure to install +it. +> + command! -bang -nargs=? -complete=dir Files + \ call fzf#vim#files(, {'options': ['--layout=reverse', '--info=inline', '--preview', '~/.vim/plugged/fzf.vim/bin/preview.sh {}']}, 0) +< +However, it's not ideal to hard-code the path to the script which can be +different in different circumstances. So in order to make it easier to set up +the previewer, fzf.vim provides `fzf#vim#with_preview` helper function. +Similarly to `fzf#wrap`, it takes a spec dictionary and returns a copy of it +with additional preview options. +> + command! -bang -nargs=? -complete=dir Files + \ call fzf#vim#files(, fzf#vim#with_preview({'options': ['--layout=reverse', '--info=inline']}), 0) +< +You can just omit the spec argument if you only want the previewer. +> + command! -bang -nargs=? -complete=dir Files + \ call fzf#vim#files(, fzf#vim#with_preview(), 0) +< + {10} bin/preview.sh + {11} https://github.com/sharkdp/bat + + +Example: git grep wrapper~ + *fzf-vim-example-git-grep-wrapper* + +The following example implements `GGrep` command that works similarly to +predefined `Ag` or `Rg` using `fzf#vim#grep`. + + - The second argument to `fzf#vim#grep` is 0 (false), because `git grep` does + not print column numbers. + - We set the base directory to git root by setting `dir` attribute in spec + dictionary. + - {The preview script}{10} supports `grep` format (`FILE_PATH:LINE_NO:...`), so + we can just wrap the spec with `fzf#vim#with_preview` as before to enable + previewer. +> + command! -bang -nargs=* GGrep + \ call fzf#vim#grep( + \ 'git grep --line-number -- '.shellescape(), 0, + \ fzf#vim#with_preview({'dir': systemlist('git rev-parse --show-toplevel')[0]}), 0) +< + {10} bin/preview.sh + + +Example: Rg command with preview window~ + *fzf-vim-example-rg-command-with-preview-window* + +You can see the definition of `Rg` command with `:command Rg`. With the +information, you can redefine it with the preview window enabled. In this +case, we're only interested in setting up the preview window, so we will omit +the spec argument to `fzf#vim#preview`. +> + command! -bang -nargs=* Rg + \ call fzf#vim#grep( + \ 'rg --column --line-number --no-heading --color=always --smart-case -- '.shellescape(), 1, + \ fzf#vim#with_preview(), 0) +< + +Example: Advanced ripgrep integration~ + *fzf-vim-example-advanced-ripgrep-integration* + +In the default implementation of `Rg`, ripgrep process starts only once with +the initial query (e.g. `:Rg foo`) and fzf filters the output of the process. + +This is okay in most cases because fzf is quite performant even with millions +of lines, but we can make fzf completely delegate its search responsibliity to +ripgrep process by making it restart ripgrep whenever the query string is +updated. In this scenario, fzf becomes a simple selector interface rather than +a "fuzzy finder". + + - We will name the new command all-uppercase `RG` so we can still access the + default version. + - `--bind 'change:reload:rg ... {q}'` will make fzf restart ripgrep process + whenever the query string, denoted by `{q}`, is changed. + - With `--phony` option, fzf will no longer perform search. The query string you + type on fzf prompt is only used for restarting ripgrep process. + - Also note that we enabled previewer with `fzf#vim#with_preview`. +> + function! RipgrepFzf(query, fullscreen) + let command_fmt = 'rg --column --line-number --no-heading --color=always --smart-case -- %s || true' + let initial_command = printf(command_fmt, shellescape(a:query)) + let reload_command = printf(command_fmt, '{q}') + let spec = {'options': ['--phony', '--query', a:query, '--bind', 'change:reload:'.reload_command]} + call fzf#vim#grep(initial_command, 1, fzf#vim#with_preview(spec), a:fullscreen) + endfunction + + command! -nargs=* -bang RG call RipgrepFzf(, 0) +< + +MAPPINGS *fzf-vim-mappings* +============================================================================== + + ---------------------------------+------------------------------------------ + Mapping | Description ~ + ---------------------------------+------------------------------------------ + (fzf-maps-n) | Normal mode mappings + (fzf-maps-i) | Insert mode mappings + (fzf-maps-x) | Visual mode mappings + (fzf-maps-o) | Operator-pending mappings + (fzf-complete-word) | `cat /usr/share/dict/words` + (fzf-complete-path) | Path completion using `find` (file + dir) + (fzf-complete-file) | File completion using `find` + (fzf-complete-line) | Line completion (all open buffers) + (fzf-complete-buffer-line) | Line completion (current buffer only) + ---------------------------------+------------------------------------------ +> + " Mapping selecting mappings + nmap (fzf-maps-n) + xmap (fzf-maps-x) + omap (fzf-maps-o) + + " Insert mode completion + imap (fzf-complete-word) + imap (fzf-complete-path) + imap (fzf-complete-line) +< + +COMPLETION FUNCTIONS *fzf-vim-completion-functions* +============================================================================== + + -----------------------------------------+-------------------------------------- + Function | Description ~ + -----------------------------------------+-------------------------------------- + `fzf#vim#complete#path(command, [spec])` | Path completion + `fzf#vim#complete#word([spec])` | Word completion + `fzf#vim#complete#line([spec])` | Line completion (all open buffers) + `fzf#vim#complete#buffer_line([spec])` | Line completion (current buffer only) + -----------------------------------------+-------------------------------------- +> + " Path completion with custom source command + inoremap fzf#vim#complete#path('fd') + inoremap fzf#vim#complete#path('rg --files') + + " Word completion with custom spec with popup layout option + inoremap fzf#vim#complete#word({'window': { 'width': 0.2, 'height': 0.9, 'xoffset': 1 }}) +< + +CUSTOM COMPLETION *fzf-vim-custom-completion* +============================================================================== + +`fzf#vim#complete` is a helper function for creating custom fuzzy completion +using fzf. If the first parameter is a command string or a Vim list, it will +be used as the source. +> + " Replace the default dictionary completion with fzf-based fuzzy completion + inoremap fzf#vim#complete('cat /usr/share/dict/words') +< +For advanced uses, you can pass an options dictionary to the function. The set +of options is pretty much identical to that for `fzf#run` only with the +following exceptions: + + - `reducer` (funcref) + - Reducer transforms the output lines of fzf into a single string value + - `prefix` (string or funcref; default: `\k*$`) + - Regular expression pattern to extract the completion prefix + - Or a function to extract completion prefix + - Both `source` and `options` can be given as funcrefs that take the completion + prefix as the argument and return the final value + - `sink` or `sink*` are ignored +> + " Global line completion (not just open buffers. ripgrep required.) + inoremap fzf#vim#complete(fzf#wrap({ + \ 'prefix': '^.*$', + \ 'source': 'rg -n ^ --color always', + \ 'options': '--ansi --delimiter : --nth 3..', + \ 'reducer': { lines -> join(split(lines[0], ':\zs')[2:], '') }})) +< + +< Reducer example >___________________________________________________________~ + *fzf-vim-reducer-example* +> + function! s:make_sentence(lines) + return substitute(join(a:lines), '^.', '\=toupper(submatch(0))', '').'.' + endfunction + + inoremap fzf#vim#complete({ + \ 'source': 'cat /usr/share/dict/words', + \ 'reducer': function('make_sentence'), + \ 'options': '--multi --reverse --margin 15%,0', + \ 'left': 20}) +< + +STATUS LINE OF TERMINAL BUFFER *fzf-vim-status-line-of-terminal-buffer* +============================================================================== + +When fzf starts in a terminal buffer (see {fzf/README-VIM.md}{12}), you may +want to customize the statusline of the containing buffer. + +{12} https://github.com/junegunn/fzf/blob/master/README-VIM.md#fzf-inside-terminal-buffer + + +< Hide statusline >___________________________________________________________~ + *fzf-vim-hide-statusline* +> + autocmd! FileType fzf set laststatus=0 noshowmode noruler + \| autocmd BufLeave set laststatus=2 showmode ruler +< + +< Custom statusline >_________________________________________________________~ + *fzf-vim-custom-statusline* +> + function! s:fzf_statusline() + " Override statusline as you like + highlight fzf1 ctermfg=161 ctermbg=251 + highlight fzf2 ctermfg=23 ctermbg=251 + highlight fzf3 ctermfg=237 ctermbg=251 + setlocal statusline=%#fzf1#\ >\ %#fzf2#fz%#fzf3#f + endfunction + + autocmd! User FzfStatusLine call fzf_statusline() +< + +LICENSE *fzf-vim-license* +============================================================================== + +MIT + + +============================================================================== +vim:tw=78:sw=2:ts=2:ft=help:norl:nowrap: diff --git a/skel/.config/nvim/plugged/fzf.vim/plugin/fzf.vim b/skel/.config/nvim/plugged/fzf.vim/plugin/fzf.vim new file mode 100644 index 0000000..d039ed4 --- /dev/null +++ b/skel/.config/nvim/plugged/fzf.vim/plugin/fzf.vim @@ -0,0 +1,157 @@ +" Copyright (c) 2015 Junegunn Choi +" +" MIT License +" +" Permission is hereby granted, free of charge, to any person obtaining +" a copy of this software and associated documentation files (the +" "Software"), to deal in the Software without restriction, including +" without limitation the rights to use, copy, modify, merge, publish, +" distribute, sublicense, and/or sell copies of the Software, and to +" permit persons to whom the Software is furnished to do so, subject to +" the following conditions: +" +" The above copyright notice and this permission notice shall be +" included in all copies or substantial portions of the Software. +" +" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +" EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +" NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +" LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +" OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +" WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +let s:cpo_save = &cpo +set cpo&vim +let s:is_win = has('win32') || has('win64') + +function! s:defs(commands) + let prefix = get(g:, 'fzf_command_prefix', '') + if prefix =~# '^[^A-Z]' + echoerr 'g:fzf_command_prefix must start with an uppercase letter' + return + endif + for command in a:commands + let name = ':'.prefix.matchstr(command, '\C[A-Z]\S\+') + if 2 != exists(name) + execute substitute(command, '\ze\C[A-Z]', prefix, '') + endif + endfor +endfunction + +function! s:p(bang, ...) + let preview_window = get(g:, 'fzf_preview_window', a:bang && &columns >= 80 || &columns >= 120 ? 'right': '') + if len(preview_window) + return call('fzf#vim#with_preview', add(copy(a:000), preview_window)) + endif + return {} +endfunction + +call s:defs([ +\'command! -bang -nargs=? -complete=dir Files call fzf#vim#files(, s:p(0), 0)', +\'command! -bang -nargs=? GitFiles call fzf#vim#gitfiles(, == "?" ? {} : s:p(0), 0)', +\'command! -bang -nargs=? GFiles call fzf#vim#gitfiles(, == "?" ? {} : s:p(0), 0)', +\'command! -bar -bang -nargs=? -complete=buffer Buffers call fzf#vim#buffers(, s:p(0, { "placeholder": "{1}", "options": ["-d", "\t"] }), 0)', +\'command! -bang -nargs=* Lines call fzf#vim#lines(, 0)', +\'command! -bang -nargs=* BLines call fzf#vim#buffer_lines(, 0)', +\'command! -bar -bang Colors call fzf#vim#colors(0)', +\'command! -bang -nargs=+ -complete=dir Locate call fzf#vim#locate(, s:p(0), 0)', +\'command! -bang -nargs=* Ag call fzf#vim#ag(, s:p(0), 0)', +\'command! -bang -nargs=* Rg call fzf#vim#grep("rg --column --line-number --no-heading --color=always --smart-case -- ".shellescape(), 1, s:p(0), 0)', +\'command! -bang -nargs=* Tags call fzf#vim#tags(, 0)', +\'command! -bang -nargs=* BTags call fzf#vim#buffer_tags(, s:p(0, { "placeholder": "{2}:{3}", "options": ["-d", "\t"] }), 0)', +\'command! -bar -bang Snippets call fzf#vim#snippets(0)', +\'command! -bar -bang Commands call fzf#vim#commands(0)', +\'command! -bar -bang Marks call fzf#vim#marks(0)', +\'command! -bar -bang Helptags call fzf#vim#helptags(0)', +\'command! -bar -bang Windows call fzf#vim#windows(0)', +\'command! -bar -bang Commits call fzf#vim#commits(0)', +\'command! -bar -bang BCommits call fzf#vim#buffer_commits(0)', +\'command! -bar -bang Maps call fzf#vim#maps("n", 0)', +\'command! -bar -bang Filetypes call fzf#vim#filetypes(0)', +\'command! -bang -nargs=* History call s:history(, s:p(0), 0)']) + +function! s:history(arg, extra, bang) + let bang = a:bang || a:arg[len(a:arg)-1] == '!' + if a:arg[0] == ':' + call fzf#vim#command_history(bang) + elseif a:arg[0] == '/' + call fzf#vim#search_history(bang) + else + call fzf#vim#history(a:extra, bang) + endif +endfunction + +function! fzf#complete(...) + return call('fzf#vim#complete', a:000) +endfunction + +if (has('nvim') || has('terminal') && has('patch-8.0.995')) && (get(g:, 'fzf_statusline', 1) || get(g:, 'fzf_nvim_statusline', 1)) + function! s:fzf_restore_colors() + if exists('#User#FzfStatusLine') + doautocmd User FzfStatusLine + else + if $TERM !~ "256color" + highlight default fzf1 ctermfg=1 ctermbg=8 guifg=#E12672 guibg=#565656 + highlight default fzf2 ctermfg=2 ctermbg=8 guifg=#BCDDBD guibg=#565656 + highlight default fzf3 ctermfg=7 ctermbg=8 guifg=#D9D9D9 guibg=#565656 + else + highlight default fzf1 ctermfg=161 ctermbg=238 guifg=#E12672 guibg=#565656 + highlight default fzf2 ctermfg=151 ctermbg=238 guifg=#BCDDBD guibg=#565656 + highlight default fzf3 ctermfg=252 ctermbg=238 guifg=#D9D9D9 guibg=#565656 + endif + setlocal statusline=%#fzf1#\ >\ %#fzf2#fz%#fzf3#f + endif + endfunction + + function! s:fzf_vim_term() + if get(w:, 'airline_active', 0) + let w:airline_disabled = 1 + autocmd BufWinLeave let w:airline_disabled = 0 + endif + autocmd WinEnter,ColorScheme call s:fzf_restore_colors() + + setlocal nospell + call s:fzf_restore_colors() + endfunction + + augroup _fzf_statusline + autocmd! + autocmd FileType fzf call s:fzf_vim_term() + augroup END +endif + +if !exists('g:fzf#vim#buffers') + let g:fzf#vim#buffers = {} +endif + +augroup fzf_buffers + autocmd! + if exists('*reltimefloat') + autocmd BufWinEnter,WinEnter * let g:fzf#vim#buffers[bufnr('')] = reltimefloat(reltime()) + else + autocmd BufWinEnter,WinEnter * let g:fzf#vim#buffers[bufnr('')] = localtime() + endif + autocmd BufDelete * silent! call remove(g:fzf#vim#buffers, expand('')) +augroup END + +inoremap (fzf-complete-word) fzf#vim#complete#word() +if s:is_win + inoremap (fzf-complete-path) fzf#vim#complete#path('dir /s/b') + inoremap (fzf-complete-file) fzf#vim#complete#path('dir /s/b/a:-d') +else + inoremap (fzf-complete-path) fzf#vim#complete#path("find . -path '*/\.*' -prune -o -print \| sed '1d;s:^..::'") + inoremap (fzf-complete-file) fzf#vim#complete#path("find . -path '*/\.*' -prune -o -type f -print -o -type l -print \| sed 's:^..::'") +endif +inoremap (fzf-complete-file-ag) fzf#vim#complete#path('ag -l -g ""') +inoremap (fzf-complete-line) fzf#vim#complete#line() +inoremap (fzf-complete-buffer-line) fzf#vim#complete#buffer_line() + +nnoremap (fzf-maps-n) :call fzf#vim#maps('n', 0) +inoremap (fzf-maps-i) :call fzf#vim#maps('i', 0) +xnoremap (fzf-maps-x) :call fzf#vim#maps('x', 0) +onoremap (fzf-maps-o) :call fzf#vim#maps('o', 0) + +let &cpo = s:cpo_save +unlet s:cpo_save + diff --git a/skel/.config/nvim/plugged/fzf/BUILD.md b/skel/.config/nvim/plugged/fzf/BUILD.md new file mode 100644 index 0000000..f6a4f26 --- /dev/null +++ b/skel/.config/nvim/plugged/fzf/BUILD.md @@ -0,0 +1,51 @@ +Building fzf +============ + +Build instructions +------------------ + +### Prerequisites + +- Go 1.11 or above + +### Using Makefile + +```sh +# Build fzf binary for your platform in target +make + +# Build fzf binary and copy it to bin directory +make install + +# Build 32-bit and 64-bit executables and tarballs in target +make release + +# Make release archives for all supported platforms in target +make release-all +``` + +### Using `go get` + +Alternatively, you can build fzf directly with `go get` command without +manually cloning the repository. + +```sh +go get -u github.com/junegunn/fzf +``` + +Third-party libraries used +-------------------------- + +- [mattn/go-runewidth](https://github.com/mattn/go-runewidth) + - Licensed under [MIT](http://mattn.mit-license.org) +- [mattn/go-shellwords](https://github.com/mattn/go-shellwords) + - Licensed under [MIT](http://mattn.mit-license.org) +- [mattn/go-isatty](https://github.com/mattn/go-isatty) + - Licensed under [MIT](http://mattn.mit-license.org) +- [tcell](https://github.com/gdamore/tcell) + - Licensed under [Apache License 2.0](https://github.com/gdamore/tcell/blob/master/LICENSE) + +License +------- + +[MIT](LICENSE) diff --git a/skel/.config/nvim/plugged/fzf/CHANGELOG.md b/skel/.config/nvim/plugged/fzf/CHANGELOG.md new file mode 100644 index 0000000..f465c6c --- /dev/null +++ b/skel/.config/nvim/plugged/fzf/CHANGELOG.md @@ -0,0 +1,870 @@ +CHANGELOG +========= + +0.21.1 +------ +- Shell extension + - CTRL-R will remove duplicate commands +- fzf-tmux + - Supports tmux popup window (require tmux 3.2 or above) + - ```sh + # 50% width and height + fzf-tmux -p + + # 80% width and height + fzf-tmux -p 80% + + # 80% width and 40% height + fzf-tmux -p 80%,40% + fzf-tmux -w 80% -h 40% + + # Window position + fzf-tmux -w 80% -h 40% -x 0 -y 0 + fzf-tmux -w 80% -h 40% -y 1000 + + # Write ordinary fzf options after -- + fzf-tmux -p -- --reverse --info=inline --margin 2,4 --border + ``` + - On macOS, you can build the latest tmux from the source with + `brew install tmux --HEAD` +- Bug fixes + - Fixed Windows file traversal not to include directories + - Fixed ANSI colors with `--keep-right` + - Fixed _fzf_complete for zsh +- Built with Go 1.14.1 + +0.21.0 +------ +- `--height` option is now available on Windows as well (@kelleyma49) +- Added `--pointer` and `--marker` options +- Added `--keep-right` option that keeps the right end of the line visible + when it's too long +- Style changes + - `--border` will now print border with rounded corners around the + finder instead of printing horizontal lines above and below it. + The previous style is available via `--border=horizontal` + - Unicode spinner +- More keys and actions for `--bind` +- Added PowerShell script for downloading Windows binary +- Vim plugin: Built-in floating windows support + ```vim + let g:fzf_layout = { 'window': { 'width': 0.9, 'height': 0.6 } } + ``` +- bash: Various improvements in key bindings (CTRL-T, CTRL-R, ALT-C) + - CTRL-R will start with the current command-line as the initial query + - CTRL-R properly supports multi-line commands +- Fuzzy completion API changed + ```sh + # Previous: fzf arguments given as a single string argument + # - This style is still supported, but it's deprecated + _fzf_complete "--multi --reverse --prompt=\"doge> \"" "$@" < <( + echo foo + ) + + # New API: multiple fzf arguments before "--" + # - Easier to write multiple options + _fzf_complete --multi --reverse --prompt="doge> " -- "$@" < <( + echo foo + ) + ``` +- Bug fixes and improvements + +0.20.0 +------ +- Customizable preview window color (`preview-fg` and `preview-bg` for `--color`) + ```sh + fzf --preview 'cat {}' \ + --color 'fg:#bbccdd,fg+:#ddeeff,bg:#334455,preview-bg:#223344,border:#778899' \ + --border --height 20 --layout reverse --info inline + ``` +- Removed the immediate flicking of the screen on `reload` action. + ```sh + : | fzf --bind 'change:reload:seq {q}' --phony + ``` +- Added `clear-query` and `clear-selection` actions for `--bind` +- It is now possible to split a composite bind action over multiple `--bind` + expressions by prefixing the later ones with `+`. + ```sh + fzf --bind 'ctrl-a:up+up' + + # Can be now written as + fzf --bind 'ctrl-a:up' --bind 'ctrl-a:+up' + + # This is useful when you need to write special execute/reload form (i.e. `execute:...`) + # to avoid parse errors and add more actions to the same key + fzf --multi --bind 'ctrl-l:select-all+execute:less {+f}' --bind 'ctrl-l:+deselect-all' + ``` +- Fixed parse error of `--bind` expression where concatenated execute/reload + action contains `+` character. + ```sh + fzf --multi --bind 'ctrl-l:select-all+execute(less {+f})+deselect-all' + ``` +- Fixed bugs of reload action + - Not triggered when there's no match even when the command doesn't have + any placeholder expressions + - Screen not properly cleared when `--header-lines` not filled on reload + +0.19.0 +------ + +- Added `--phony` option which completely disables search functionality. + Useful when you want to use fzf only as a selector interface. See below. +- Added "reload" action for dynamically updating the input list without + restarting fzf. See https://github.com/junegunn/fzf/issues/1750 to learn + more about it. + ```sh + # Using fzf as the selector interface for ripgrep + RG_PREFIX="rg --column --line-number --no-heading --color=always --smart-case " + INITIAL_QUERY="foo" + FZF_DEFAULT_COMMAND="$RG_PREFIX '$INITIAL_QUERY' || true" \ + fzf --bind "change:reload:$RG_PREFIX {q} || true" \ + --ansi --phony --query "$INITIAL_QUERY" + ``` +- `--multi` now takes an optional integer argument which indicates the maximum + number of items that can be selected + ```sh + seq 100 | fzf --multi 3 --reverse --height 50% + ``` +- If a placeholder expression for `--preview` and `execute` action (and the + new `reload` action) contains `f` flag, it is replaced to the + path of a temporary file that holds the evaluated list. This is useful + when you multi-select a large number of items and the length of the + evaluated string may exceed [`ARG_MAX`][argmax]. + ```sh + # Press CTRL-A to select 100K items and see the sum of all the numbers + seq 100000 | fzf --multi --bind ctrl-a:select-all \ + --preview "awk '{sum+=\$1} END {print sum}' {+f}" + ``` +- `deselect-all` no longer deselects unmatched items. It is now consistent + with `select-all` and `toggle-all` in that it only affects matched items. +- Due to the limitation of bash, fuzzy completion is enabled by default for + a fixed set of commands. A helper function for easily setting up fuzzy + completion for any command is now provided. + ```sh + # usage: _fzf_setup_completion path|dir COMMANDS... + _fzf_setup_completion path git kubectl + ``` +- Info line style can be changed by `--info=STYLE` + - `--info=default` + - `--info=inline` (same as old `--inline-info`) + - `--info=hidden` +- Preview window border can be disabled by adding `noborder` to + `--preview-window`. +- When you transform the input with `--with-nth`, the trailing white spaces + are removed. +- `ctrl-\`, `ctrl-]`, `ctrl-^`, and `ctrl-/` can now be used with `--bind` +- See https://github.com/junegunn/fzf/milestone/15?closed=1 for more details + +[argmax]: https://unix.stackexchange.com/questions/120642/what-defines-the-maximum-size-for-a-command-single-argument + +0.18.0 +------ + +- Added placeholder expression for zero-based item index: `{n}` and `{+n}` + - `fzf --preview 'echo {n}: {}'` +- Added color option for the gutter: `--color gutter:-1` +- Added `--no-unicode` option for drawing borders in non-Unicode, ASCII + characters +- `FZF_PREVIEW_LINES` and `FZF_PREVIEW_COLUMNS` are exported to preview process + - fzf still overrides `LINES` and `COLUMNS` as before, but they may be + reset by the default shell. +- Bug fixes and improvements + - See https://github.com/junegunn/fzf/milestone/14?closed=1 +- Built with Go 1.12.1 + +0.17.5 +------ + +- Bug fixes and improvements + - See https://github.com/junegunn/fzf/milestone/13?closed=1 +- Search query longer than the screen width is allowed (up to 300 chars) +- Built with Go 1.11.1 + +0.17.4 +------ + +- Added `--layout` option with a new layout called `reverse-list`. + - `--layout=reverse` is a synonym for `--reverse` + - `--layout=default` is a synonym for `--no-reverse` +- Preview window will be updated even when there is no match for the query + if any of the placeholder expressions (e.g. `{q}`, `{+}`) evaluates to + a non-empty string. +- More keys for binding: `shift-{up,down}`, `alt-{up,down,left,right}` +- fzf can now start even when `/dev/tty` is not available by making an + educated guess. +- Updated the default command for Windows. +- Fixes and improvements on bash/zsh completion +- install and uninstall scripts now supports generating files under + `XDG_CONFIG_HOME` on `--xdg` flag. + +See https://github.com/junegunn/fzf/milestone/12?closed=1 for the full list of +changes. + +0.17.3 +------ +- `$LINES` and `$COLUMNS` are exported to preview command so that the command + knows the exact size of the preview window. +- Better error messages when the default command or `$FZF_DEFAULT_COMMAND` + fails. +- Reverted #1061 to avoid having duplicate entries in the list when find + command detected a file system loop (#1120). The default command now + requires that find supports `-fstype` option. +- fzf now distinguishes mouse left click and right click (#1130) + - Right click is now bound to `toggle` action by default + - `--bind` understands `left-click` and `right-click` +- Added `replace-query` action (#1137) + - Replaces query string with the current selection +- Added `accept-non-empty` action (#1162) + - Same as accept, except that it prevents fzf from exiting without any + selection + +0.17.1 +------ + +- Fixed custom background color of preview window (#1046) +- Fixed background color issues of Windows binary +- Fixed Windows binary to execute command using cmd.exe with no parsing and + escaping (#1072) +- Added support for `window` layout on Vim 8 using Vim 8 terminal (#1055) + +0.17.0-2 +-------- + +A maintenance release for auxiliary scripts. fzf binaries are not updated. + +- Experimental support for the builtin terminal of Vim 8 + - fzf can now run inside GVim +- Updated Vim plugin to better handle `&shell` issue on fish +- Fixed a bug of fzf-tmux where invalid output is generated +- Fixed fzf-tmux to work even when `tput` does not work + +0.17.0 +------ +- Performance optimization +- One can match literal spaces in extended-search mode with a space prepended + by a backslash. +- `--expect` is now additive and can be specified multiple times. + +0.16.11 +------- +- Performance optimization +- Fixed missing preview update + +0.16.10 +------- +- Fixed invalid handling of ANSI colors in preview window +- Further improved `--ansi` performance + +0.16.9 +------ +- Memory and performance optimization + - Around 20% performance improvement for general use cases + - Up to 5x faster processing of `--ansi` + - Up to 50% reduction of memory usage +- Bug fixes and usability improvements + - Fixed handling of bracketed paste mode + - [ERROR] on info line when the default command failed + - More efficient rendering of preview window + - `--no-clear` updated for repetitive relaunching scenarios + +0.16.8 +------ +- New `change` event and `top` action for `--bind` + - `fzf --bind change:top` + - Move cursor to the top result whenever the query string is changed + - `fzf --bind 'ctrl-w:unix-word-rubout+top,ctrl-u:unix-line-discard+top'` + - `top` combined with `unix-word-rubout` and `unix-line-discard` +- Fixed inconsistent tiebreak scores when `--nth` is used +- Proper display of tab characters in `--prompt` +- Fixed not to `--cycle` on page-up/page-down to prevent overshoot +- Git revision in `--version` output +- Basic support for Cygwin environment +- Many fixes in Vim plugin on Windows/Cygwin (thanks to @janlazo) + +0.16.7 +------ +- Added support for `ctrl-alt-[a-z]` key chords +- CTRL-Z (SIGSTOP) now works with fzf +- fzf will export `$FZF_PREVIEW_WINDOW` so that the scripts can use it +- Bug fixes and improvements in Vim plugin and shell extensions + +0.16.6 +------ +- Minor bug fixes and improvements +- Added `--no-clear` option for scripting purposes + +0.16.5 +------ +- Minor bug fixes +- Added `toggle-preview-wrap` action +- Built with Go 1.8 + +0.16.4 +------ +- Added `--border` option to draw border above and below the finder +- Bug fixes and improvements + +0.16.3 +------ +- Fixed a bug where fzf incorrectly display the lines when straddling tab + characters are trimmed +- Placeholder expression used in `--preview` and `execute` action can + optionally take `+` flag to be used with multiple selections + - e.g. `git log --oneline | fzf --multi --preview 'git show {+1}'` +- Added `execute-silent` action for executing a command silently without + switching to the alternate screen. This is useful when the process is + short-lived and you're not interested in its output. + - e.g. `fzf --bind 'ctrl-y:execute!(echo -n {} | pbcopy)'` +- `ctrl-space` is allowed in `--bind` + +0.16.2 +------ +- Dropped ncurses dependency +- Binaries for freebsd, openbsd, arm5, arm6, arm7, and arm8 +- Official 24-bit color support +- Added support for composite actions in `--bind`. Multiple actions can be + chained using `+` separator. + - e.g. `fzf --bind 'ctrl-y:execute(echo -n {} | pbcopy)+abort'` +- `--preview-window` with size 0 is allowed. This is used to make fzf execute + preview command in the background without displaying the result. +- Minor bug fixes and improvements + +0.16.1 +------ +- Fixed `--height` option to properly fill the window with the background + color +- Added `half-page-up` and `half-page-down` actions +- Added `-L` flag to the default find command + +0.16.0 +------ +- *Added `--height HEIGHT[%]` option* + - fzf can now display finder without occupying the full screen +- Preview window will truncate long lines by default. Line wrap can be enabled + by `:wrap` flag in `--preview-window`. +- Latin script letters will be normalized before matching so that it's easier + to match against accented letters. e.g. `sodanco` can match `Só Danço Samba`. + - Normalization can be disabled via `--literal` +- Added `--filepath-word` to make word-wise movements/actions (`alt-b`, + `alt-f`, `alt-bs`, `alt-d`) respect path separators + +0.15.9 +------ +- Fixed rendering glitches introduced in 0.15.8 +- The default escape delay is reduced to 50ms and is configurable via + `$ESCDELAY` +- Scroll indicator at the top-right corner of the preview window is always + displayed when there's overflow +- Can now be built with ncurses 6 or tcell to support extra features + - *ncurses 6* + - Supports more than 256 color pairs + - Supports italics + - *tcell* + - 24-bit color support + - See https://github.com/junegunn/fzf/blob/master/BUILD.md + +0.15.8 +------ +- Updated ANSI processor to handle more VT-100 escape sequences +- Added `--no-bold` (and `--bold`) option +- Improved escape sequence processing for WSL +- Added support for `alt-[0-9]`, `f11`, and `f12` for `--bind` and `--expect` + +0.15.7 +------ +- Fixed panic when color is disabled and header lines contain ANSI colors + +0.15.6 +------ +- Windows binaries! (@kelleyma49) +- Fixed the bug where header lines are cleared when preview window is toggled +- Fixed not to display ^N and ^O on screen +- Fixed cursor keys (or any key sequence that starts with ESC) on WSL by + making fzf wait for additional keystrokes after ESC for up to 100ms + +0.15.5 +------ +- Setting foreground color will no longer set background color to black + - e.g. `fzf --color fg:153` +- `--tiebreak=end` will consider relative position instead of absolute distance +- Updated `fzf#wrap` function to respect `g:fzf_colors` + +0.15.4 +------ +- Added support for range expression in preview and execute action + - e.g. `ls -l | fzf --preview="echo user={3} when={-4..-2}; cat {-1}" --header-lines=1` + - `{q}` will be replaced to the single-quoted string of the current query +- Fixed to properly handle unicode whitespace characters +- Display scroll indicator in preview window +- Inverse search term will use exact matcher by default + - This is a breaking change, but I believe it makes much more sense. It is + almost impossible to predict which entries will be filtered out due to + a fuzzy inverse term. You can still perform inverse-fuzzy-match by + prepending `!'` to the term. + +0.15.3 +------ +- Added support for more ANSI attributes: dim, underline, blink, and reverse +- Fixed race condition in `toggle-preview` + +0.15.2 +------ +- Preview window is now scrollable + - With mouse scroll or with bindable actions + - `preview-up` + - `preview-down` + - `preview-page-up` + - `preview-page-down` +- Updated ANSI processor to support high intensity colors and ignore + some VT100-related escape sequences + +0.15.1 +------ +- Fixed panic when the pattern occurs after 2^15-th column +- Fixed rendering delay when displaying extremely long lines + +0.15.0 +------ +- Improved fuzzy search algorithm + - Added `--algo=[v1|v2]` option so one can still choose the old algorithm + which values the search performance over the quality of the result +- Advanced scoring criteria +- `--read0` to read input delimited by ASCII NUL character +- `--print0` to print output delimited by ASCII NUL character + +0.13.5 +------ +- Memory and performance optimization + - Up to 2x performance with half the amount of memory + +0.13.4 +------ +- Performance optimization + - Memory footprint for ascii string is reduced by 60% + - 15 to 20% improvement of query performance + - Up to 45% better performance of `--nth` with non-regex delimiters +- Fixed invalid handling of `hidden` property of `--preview-window` + +0.13.3 +------ +- Fixed duplicate rendering of the last line in preview window + +0.13.2 +------ +- Fixed race condition where preview window is not properly cleared + +0.13.1 +------ +- Fixed UI issue with large `--preview` output with many ANSI codes + +0.13.0 +------ +- Added preview feature + - `--preview CMD` + - `--preview-window POS[:SIZE][:hidden]` +- `{}` in execute action is now replaced to the single-quoted (instead of + double-quoted) string of the current line +- Fixed to ignore control characters for bracketed paste mode + +0.12.2 +------ + +- 256-color capability detection does not require `256` in `$TERM` +- Added `print-query` action +- More named keys for binding; F1 ~ F10, + ALT-/, ALT-space, and ALT-enter +- Added `jump` and `jump-accept` actions that implement [EasyMotion][em]-like + movement + ![][jump] + +[em]: https://github.com/easymotion/vim-easymotion +[jump]: https://cloud.githubusercontent.com/assets/700826/15367574/b3999dc4-1d64-11e6-85da-28ceeb1a9bc2.png + +0.12.1 +------ + +- Ranking algorithm introduced in 0.12.0 is now universally applied +- Fixed invalid cache reference in exact mode +- Fixes and improvements in Vim plugin and shell extensions + +0.12.0 +------ + +- Enhanced ranking algorithm +- Minor bug fixes + +0.11.4 +------ + +- Added `--hscroll-off=COL` option (default: 10) (#513) +- Some fixes in Vim plugin and shell extensions + +0.11.3 +------ + +- Graceful exit on SIGTERM (#482) +- `$SHELL` instead of `sh` for `execute` action and `$FZF_DEFAULT_COMMAND` (#481) +- Changes in fuzzy completion API + - [`_fzf_compgen_{path,dir}`](https://github.com/junegunn/fzf/commit/9617647) + - [`_fzf_complete_COMMAND_post`](https://github.com/junegunn/fzf/commit/8206746) + for post-processing + +0.11.2 +------ + +- `--tiebreak` now accepts comma-separated list of sort criteria + - Each criterion should appear only once in the list + - `index` is only allowed at the end of the list + - `index` is implicitly appended to the list when not specified + - Default is `length` (or equivalently `length,index`) +- `begin` criterion will ignore leading whitespaces when calculating the index +- Added `toggle-in` and `toggle-out` actions + - Switch direction depending on `--reverse`-ness + - `export FZF_DEFAULT_OPTS="--bind tab:toggle-out,shift-tab:toggle-in"` +- Reduced the initial delay when `--tac` is not given + - fzf defers the initial rendering of the screen up to 100ms if the input + stream is ongoing to prevent unnecessary redraw during the initial + phase. However, 100ms delay is quite noticeable and might give the + impression that fzf is not snappy enough. This commit reduces the + maximum delay down to 20ms when `--tac` is not specified, in which case + the input list quickly fills the entire screen. + +0.11.1 +------ + +- Added `--tabstop=SPACES` option + +0.11.0 +------ + +- Added OR operator for extended-search mode +- Added `--execute-multi` action +- Fixed incorrect cursor position when unicode wide characters are used in + `--prompt` +- Fixes and improvements in shell extensions + +0.10.9 +------ + +- Extended-search mode is now enabled by default + - `--extended-exact` is deprecated and instead we have `--exact` for + orthogonally controlling "exactness" of search +- Fixed not to display non-printable characters +- Added `double-click` for `--bind` option +- More robust handling of SIGWINCH + +0.10.8 +------ + +- Fixed panic when trying to set colors after colors are disabled (#370) + +0.10.7 +------ + +- Fixed unserialized interrupt handling during execute action which often + caused invalid memory access and crash +- Changed `--tiebreak=length` (default) to use trimmed length when `--nth` is + used + +0.10.6 +------ + +- Replaced `--header-file` with `--header` option +- `--header` and `--header-lines` can be used together +- Changed exit status + - 0: Okay + - 1: No match + - 2: Error + - 130: Interrupted +- 64-bit linux binary is statically-linked with ncurses to avoid + compatibility issues. + +0.10.5 +------ + +- `'`-prefix to unquote the term in `--extended-exact` mode +- Backward scan when `--tiebreak=end` is set + +0.10.4 +------ + +- Fixed to remove ANSI code from output when `--with-nth` is set + +0.10.3 +------ + +- Fixed slow performance of `--with-nth` when used with `--delimiter` + - Regular expression engine of Golang as of now is very slow, so the fixed + version will treat the given delimiter pattern as a plain string instead + of a regular expression unless it contains special characters and is + a valid regular expression. + - Simpler regular expression for delimiter for better performance + +0.10.2 +------ + +### Fixes and improvements + +- Improvement in perceived response time of queries + - Eager, efficient rune array conversion +- Graceful exit when failed to initialize ncurses (invalid $TERM) +- Improved ranking algorithm when `--nth` option is set +- Changed the default command not to fail when there are files whose names + start with dash + +0.10.1 +------ + +### New features + +- Added `--margin` option +- Added options for sticky header + - `--header-file` + - `--header-lines` +- Added `cancel` action which clears the input or closes the finder when the + input is already empty + - e.g. `export FZF_DEFAULT_OPTS="--bind esc:cancel"` +- Added `delete-char/eof` action to differentiate `CTRL-D` and `DEL` + +### Minor improvements/fixes + +- Fixed to allow binding colon and comma keys +- Fixed ANSI processor to handle color regions spanning multiple lines + +0.10.0 +------ + +### New features + +- More actions for `--bind` + - `select-all` + - `deselect-all` + - `toggle-all` + - `ignore` +- `execute(...)` action for running arbitrary command without leaving fzf + - `fzf --bind "ctrl-m:execute(less {})"` + - `fzf --bind "ctrl-t:execute(tmux new-window -d 'vim {}')"` + - If the command contains parentheses, use any of the follows alternative + notations to avoid parse errors + - `execute[...]` + - `execute~...~` + - `execute!...!` + - `execute@...@` + - `execute#...#` + - `execute$...$` + - `execute%...%` + - `execute^...^` + - `execute&...&` + - `execute*...*` + - `execute;...;` + - `execute/.../` + - `execute|...|` + - `execute:...` + - This is the special form that frees you from parse errors as it + does not expect the closing character + - The catch is that it should be the last one in the + comma-separated list +- Added support for optional search history + - `--history HISTORY_FILE` + - When used, `CTRL-N` and `CTRL-P` are automatically remapped to + `next-history` and `previous-history` + - `--history-size MAX_ENTRIES` (default: 1000) +- Cyclic scrolling can be enabled with `--cycle` +- Fixed the bug where the spinner was not spinning on idle input stream + - e.g. `sleep 100 | fzf` + +### Minor improvements/fixes + +- Added synonyms for key names that can be specified for `--bind`, + `--toggle-sort`, and `--expect` +- Fixed the color of multi-select marker on the current line +- Fixed to allow `^pattern$` in extended-search mode + + +0.9.13 +------ + +### New features + +- Color customization with the extended `--color` option + +### Bug fixes + +- Fixed premature termination of Reader in the presence of a long line which + is longer than 64KB + +0.9.12 +------ + +### New features + +- Added `--bind` option for custom key bindings + +### Bug fixes + +- Fixed to update "inline-info" immediately after terminal resize +- Fixed ANSI code offset calculation + +0.9.11 +------ + +### New features + +- Added `--inline-info` option for saving screen estate (#202) + - Useful inside Neovim + - e.g. `let $FZF_DEFAULT_OPTS = $FZF_DEFAULT_OPTS.' --inline-info'` + +### Bug fixes + +- Invalid mutation of input on case conversion (#209) +- Smart-case for each term in extended-search mode (#208) +- Fixed double-click result when scroll offset is positive + +0.9.10 +------ + +### Improvements + +- Performance optimization +- Less aggressive memoization to limit memory usage + +### New features + +- Added color scheme for light background: `--color=light` + +0.9.9 +----- + +### New features + +- Added `--tiebreak` option (#191) +- Added `--no-hscroll` option (#193) +- Visual indication of `--toggle-sort` (#194) + +0.9.8 +----- + +### Bug fixes + +- Fixed Unicode case handling (#186) +- Fixed to terminate on RuneError (#185) + +0.9.7 +----- + +### New features + +- Added `--toggle-sort` option (#173) + - `--toggle-sort=ctrl-r` is applied to `CTRL-R` shell extension + +### Bug fixes + +- Fixed to print empty line if `--expect` is set and fzf is completed by + `--select-1` or `--exit-0` (#172) +- Fixed to allow comma character as an argument to `--expect` option + +0.9.6 +----- + +### New features + +#### Added `--expect` option (#163) + +If you provide a comma-separated list of keys with `--expect` option, fzf will +allow you to select the match and complete the finder when any of the keys is +pressed. Additionally, fzf will print the name of the key pressed as the first +line of the output so that your script can decide what to do next based on the +information. + +```sh +fzf --expect=ctrl-v,ctrl-t,alt-s,f1,f2,~,@ +``` + +The updated vim plugin uses this option to implement +[ctrlp](https://github.com/kien/ctrlp.vim)-compatible key bindings. + +### Bug fixes + +- Fixed to ignore ANSI escape code `\e[K` (#162) + +0.9.5 +----- + +### New features + +#### Added `--ansi` option (#150) + +If you give `--ansi` option to fzf, fzf will interpret ANSI color codes from +the input, display the item with the ANSI colors (true colors are not +supported), and strips the codes from the output. This option is off by +default as it entails some overhead. + +### Improvements + +#### Reduced initial memory footprint (#151) + +By removing unnecessary copy of pointers, fzf will use significantly smaller +amount of memory when it's started. The difference is hugely noticeable when +the input is extremely large. (e.g. `locate / | fzf`) + +### Bug fixes + +- Fixed panic on `--no-sort --filter ''` (#149) + +0.9.4 +----- + +### New features + +#### Added `--tac` option to reverse the order of the input. + +One might argue that this option is unnecessary since we can already put `tac` +or `tail -r` in the command pipeline to achieve the same result. However, the +advantage of `--tac` is that it does not block until the input is complete. + +### *Backward incompatible changes* + +#### Changed behavior on `--no-sort` + +`--no-sort` option will no longer reverse the display order within finder. You +may want to use the new `--tac` option with `--no-sort`. + +``` +history | fzf +s --tac +``` + +### Improvements + +#### `--filter` will not block when sort is disabled + +When fzf works in filtering mode (`--filter`) and sort is disabled +(`--no-sort`), there's no need to block until input is complete. The new +version of fzf will print the matches on-the-fly when the following condition +is met: + + --filter TERM --no-sort [--no-tac --no-sync] + +or simply: + + -f TERM +s + +This change removes unnecessary delay in the use cases like the following: + + fzf -f xxx +s | head -5 + +However, in this case, fzf processes the lines sequentially, so it cannot +utilize multiple cores, and fzf will run slightly slower than the previous +mode of execution where filtering is done in parallel after the entire input +is loaded. If the user is concerned about this performance problem, one can +add `--sync` option to re-enable buffering. + +0.9.3 +----- + +### New features +- Added `--sync` option for multi-staged filtering + +### Improvements +- `--select-1` and `--exit-0` will start finder immediately when the condition + cannot be met + diff --git a/skel/.config/nvim/plugged/fzf/LICENSE b/skel/.config/nvim/plugged/fzf/LICENSE new file mode 100644 index 0000000..c64372a --- /dev/null +++ b/skel/.config/nvim/plugged/fzf/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2013-2020 Junegunn Choi + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/skel/.config/nvim/plugged/fzf/README-VIM.md b/skel/.config/nvim/plugged/fzf/README-VIM.md new file mode 100644 index 0000000..be5bdbf --- /dev/null +++ b/skel/.config/nvim/plugged/fzf/README-VIM.md @@ -0,0 +1,435 @@ +FZF Vim integration +=================== + +Installation +------------ + +Once you have fzf installed, you can enable it inside Vim simply by adding the +directory to `&runtimepath` in your Vim configuration file. The path may +differ depending on the package manager. + +```vim +" If installed using Homebrew +set rtp+=/usr/local/opt/fzf + +" If installed using git +set rtp+=~/.fzf +``` + +If you use [vim-plug](https://github.com/junegunn/vim-plug), the same can be +written as: + +```vim +" If installed using Homebrew +Plug '/usr/local/opt/fzf' + +" If installed using git +Plug '~/.fzf' +``` + +But if you want the latest Vim plugin file from GitHub rather than the one +included in the package, write: + +```vim +Plug 'junegunn/fzf' +``` + +The Vim plugin will pick up fzf binary available on the system. If fzf is not +found on `$PATH`, it will ask you if it should download the latest binary for +you. + +To make sure that you have the latest version of the binary, set up +post-update hook like so: + +```vim +Plug 'junegunn/fzf', { 'do': { -> fzf#install() } } +``` + +Summary +------- + +The Vim plugin of fzf provides two core functions, and `:FZF` command which is +the basic file selector command built on top of them. + +1. **`fzf#run([spec dict])`** + - Starts fzf inside Vim with the given spec + - `:call fzf#run({'source': 'ls'})` +2. **`fzf#wrap([spec dict]) -> (dict)`** + - Takes a spec for `fzf#run` and returns an extended version of it with + additional options for addressing global preferences (`g:fzf_xxx`) + - `:echo fzf#wrap({'source': 'ls'})` + - We usually *wrap* a spec with `fzf#wrap` before passing it to `fzf#run` + - `:call fzf#run(fzf#wrap({'source': 'ls'}))` +3. **`:FZF [fzf_options string] [path string]`** + - Basic fuzzy file selector + - A reference implementation for those who don't want to write VimScript + to implement custom commands + - If you're looking for more such commands, check out [fzf.vim](https://github.com/junegunn/fzf.vim) project. + +The most important of all is `fzf#run`, but it would be easier to understand +the whole if we start off with `:FZF` command. + +`:FZF[!]` +--------- + +```vim +" Look for files under current directory +:FZF + +" Look for files under your home directory +:FZF ~ + +" With fzf command-line options +:FZF --reverse --info=inline /tmp + +" Bang version starts fzf in fullscreen mode +:FZF! +``` + +Similarly to [ctrlp.vim](https://github.com/kien/ctrlp.vim), use enter key, +`CTRL-T`, `CTRL-X` or `CTRL-V` to open selected files in the current window, +in new tabs, in horizontal splits, or in vertical splits respectively. + +Note that the environment variables `FZF_DEFAULT_COMMAND` and +`FZF_DEFAULT_OPTS` also apply here. + +### Configuration + +- `g:fzf_action` + - Customizable extra key bindings for opening selected files in different ways +- `g:fzf_layout` + - Determines the size and position of fzf window +- `g:fzf_colors` + - Customizes fzf colors to match the current color scheme +- `g:fzf_history_dir` + - Enables history feature + +#### Examples + +```vim +" This is the default extra key bindings +let g:fzf_action = { + \ 'ctrl-t': 'tab split', + \ 'ctrl-x': 'split', + \ 'ctrl-v': 'vsplit' } + +" An action can be a reference to a function that processes selected lines +function! s:build_quickfix_list(lines) + call setqflist(map(copy(a:lines), '{ "filename": v:val }')) + copen + cc +endfunction + +let g:fzf_action = { + \ 'ctrl-q': function('s:build_quickfix_list'), + \ 'ctrl-t': 'tab split', + \ 'ctrl-x': 'split', + \ 'ctrl-v': 'vsplit' } + +" Default fzf layout +" - down / up / left / right +let g:fzf_layout = { 'down': '~40%' } + +" You can set up fzf window using a Vim command (Neovim or latest Vim 8 required) +let g:fzf_layout = { 'window': 'enew' } +let g:fzf_layout = { 'window': '-tabnew' } +let g:fzf_layout = { 'window': '10new' } + +" Customize fzf colors to match your color scheme +" - fzf#wrap translates this to a set of `--color` options +let g:fzf_colors = +\ { 'fg': ['fg', 'Normal'], + \ 'bg': ['bg', 'Normal'], + \ 'hl': ['fg', 'Comment'], + \ 'fg+': ['fg', 'CursorLine', 'CursorColumn', 'Normal'], + \ 'bg+': ['bg', 'CursorLine', 'CursorColumn'], + \ 'hl+': ['fg', 'Statement'], + \ 'info': ['fg', 'PreProc'], + \ 'border': ['fg', 'Ignore'], + \ 'prompt': ['fg', 'Conditional'], + \ 'pointer': ['fg', 'Exception'], + \ 'marker': ['fg', 'Keyword'], + \ 'spinner': ['fg', 'Label'], + \ 'header': ['fg', 'Comment'] } + +" Enable per-command history +" - History files will be stored in the specified directory +" - When set, CTRL-N and CTRL-P will be bound to 'next-history' and +" 'previous-history' instead of 'down' and 'up'. +let g:fzf_history_dir = '~/.local/share/fzf-history' +``` + +##### Explanation of `g:fzf_colors` + +`g:fzf_colors` is a dictionary mapping fzf elements to a color specification +list: + + element: [ component, group1 [, group2, ...] ] + +- `element` is an fzf element to apply a color to: + + | Element | Description | + | --- | --- | + | `fg` / `bg` / `hl` | Item (foreground / background / highlight) | + | `fg+` / `bg+` / `hl+` | Current item (foreground / background / highlight) | + | `hl` / `hl+` | Highlighted substrings (normal / current) | + | `gutter` | Background of the gutter on the left | + | `pointer` | Pointer to the current line (`>`) | + | `marker` | Multi-select marker (`>`) | + | `border` | Border around the window (`--border` and `--preview`) | + | `header` | Header (`--header` or `--header-lines`) | + | `info` | Info line (match counters) | + | `spinner` | Streaming input indicator | + | `prompt` | Prompt before query (`> `) | + +- `component` specifies the component (`fg` / `bg`) from which to extract the + color when considering each of the following highlight groups + +- `group1 [, group2, ...]` is a list of highlight groups that are searched (in + order) for a matching color definition + +For example, consider the following specification: + +```vim + 'prompt': ['fg', 'Conditional', 'Comment'], +``` + +This means we color the **prompt** +- using the `fg` attribute of the `Conditional` if it exists, +- otherwise use the `fg` attribute of the `Comment` highlight group if it exists, +- otherwise fall back to the default color settings for the **prompt**. + +You can examine the color option generated according the setting by printing +the result of `fzf#wrap()` function like so: + +```vim +:echo fzf#wrap() +``` + +`fzf#run` +--------- + +`fzf#run()` function is the core of Vim integration. It takes a single +dictionary argument, *a spec*, and starts fzf process accordingly. At the very +least, specify `sink` option to tell what it should do with the selected +entry. + +```vim +call fzf#run({'sink': 'e'}) +``` + +We haven't specified the `source`, so this is equivalent to starting fzf on +command line without standard input pipe; fzf will use find command (or +`$FZF_DEFAULT_COMMAND` if defined) to list the files under the current +directory. When you select one, it will open it with the sink, `:e` command. +If you want to open it in a new tab, you can pass `:tabedit` command instead +as the sink. + +```vim +call fzf#run({'sink': 'tabedit'}) +``` + +Instead of using the default find command, you can use any shell command as +the source. The following example will list the files managed by git. It's +equivalent to running `git ls-files | fzf` on shell. + +```vim +call fzf#run({'source': 'git ls-files', 'sink': 'e'}) +``` + +fzf options can be specified as `options` entry in spec dictionary. + +```vim +call fzf#run({'sink': 'tabedit', 'options': '--multi --reverse'}) +``` + +You can also pass a layout option if you don't want fzf window to take up the +entire screen. + +```vim +" up / down / left / right / window are allowed +call fzf#run({'source': 'git ls-files', 'sink': 'e', 'left': '40%'}) +call fzf#run({'source': 'git ls-files', 'sink': 'e', 'window': '30vnew'}) +``` + +`source` doesn't have to be an external shell command, you can pass a Vim +array as the source. In the next example, we pass the names of color +schemes as the source to implement a color scheme selector. + +```vim +call fzf#run({'source': map(split(globpath(&rtp, 'colors/*.vim')), + \ 'fnamemodify(v:val, ":t:r")'), + \ 'sink': 'colo', 'left': '25%'}) +``` + +The following table summarizes the available options. + +| Option name | Type | Description | +| -------------------------- | ------------- | ---------------------------------------------------------------- | +| `source` | string | External command to generate input to fzf (e.g. `find .`) | +| `source` | list | Vim list as input to fzf | +| `sink` | string | Vim command to handle the selected item (e.g. `e`, `tabe`) | +| `sink` | funcref | Reference to function to process each selected item | +| `sink*` | funcref | Similar to `sink`, but takes the list of output lines at once | +| `options` | string/list | Options to fzf | +| `dir` | string | Working directory | +| `up`/`down`/`left`/`right` | number/string | (Layout) Window position and size (e.g. `20`, `50%`) | +| `tmux` | string | (Layout) fzf-tmux options (e.g. `-p90%,60%`) | +| `window` (Vim 8 / Neovim) | string | (Layout) Command to open fzf window (e.g. `vertical aboveleft 30new`) | +| `window` (Vim 8 / Neovim) | dict | (Layout) Popup window settings (e.g. `{'width': 0.9, 'height': 0.6}`) | + +`options` entry can be either a string or a list. For simple cases, string +should suffice, but prefer to use list type to avoid escaping issues. + +```vim +call fzf#run({'options': '--reverse --prompt "C:\\Program Files\\"'}) +call fzf#run({'options': ['--reverse', '--prompt', 'C:\Program Files\']}) +``` + +When `window` entry is a dictionary, fzf will start in a popup window. The +following options are allowed: + +- Required: + - `width` [float range [0 ~ 1]] + - `height` [float range [0 ~ 1]] +- Optional: + - `yoffset` [float default 0.5 range [0 ~ 1]] + - `xoffset` [float default 0.5 range [0 ~ 1]] + - `highlight` [string default `'Comment'`]: Highlight group for border + - `border` [string default `rounded`]: Border style + - `rounded` / `sharp` / `horizontal` / `vertical` / `top` / `bottom` / `left` / `right` + +`fzf#wrap` +---------- + +We have seen that several aspects of `:FZF` command can be configured with +a set of global option variables; different ways to open files +(`g:fzf_action`), window position and size (`g:fzf_layout`), color palette +(`g:fzf_colors`), etc. + +So how can we make our custom `fzf#run` calls also respect those variables? +Simply by *"wrapping"* the spec dictionary with `fzf#wrap` before passing it +to `fzf#run`. + +- **`fzf#wrap([name string], [spec dict], [fullscreen bool]) -> (dict)`** + - All arguments are optional. Usually we only need to pass a spec dictionary. + - `name` is for managing history files. It is ignored if + `g:fzf_history_dir` is not defined. + - `fullscreen` can be either `0` or `1` (default: 0). + +`fzf#wrap` takes a spec and returns an extended version of it (also +a dictionary) with additional options for addressing global preferences. You +can examine the return value of it like so: + +```vim +echo fzf#wrap({'source': 'ls'}) +``` + +After we *"wrap"* our spec, we pass it to `fzf#run`. + +```vim +call fzf#run(fzf#wrap({'source': 'ls'})) +``` + +Now it supports `CTRL-T`, `CTRL-V`, and `CTRL-X` key bindings and it opens fzf +window according to `g:fzf_layout` setting. + +To make it easier to use, let's define `LS` command. + +```vim +command! LS call fzf#run(fzf#wrap({'source': 'ls'})) +``` + +Type `:LS` and see how it works. + +We would like to make `:LS!` (bang version) open fzf in fullscreen, just like +`:FZF!`. Add `-bang` to command definition, and use `` value to set +the last `fullscreen` argument of `fzf#wrap` (see `:help `). + +```vim +" On :LS!, evaluates to '!', and '!0' becomes 1 +command! -bang LS call fzf#run(fzf#wrap({'source': 'ls'}, 0)) +``` + +Our `:LS` command will be much more useful if we can pass a directory argument +to it, so that something like `:LS /tmp` is possible. + +```vim +command! -bang -complete=dir -nargs=* LS + \ call fzf#run(fzf#wrap({'source': 'ls', 'dir': }, 0)) +``` + +Lastly, if you have enabled `g:fzf_history_dir`, you might want to assign +a unique name to our command and pass it as the first argument to `fzf#wrap`. + +```vim +" The query history for this command will be stored as 'ls' inside g:fzf_history_dir. +" The name is ignored if g:fzf_history_dir is not defined. +command! -bang -complete=dir -nargs=* LS + \ call fzf#run(fzf#wrap('ls', {'source': 'ls', 'dir': }, 0)) +``` + +Tips +---- + +### fzf inside terminal buffer + +The latest versions of Vim and Neovim include builtin terminal emulator +(`:terminal`) and fzf will start in a terminal buffer in the following cases: + +- On Neovim +- On GVim +- On Terminal Vim with a non-default layout + - `call fzf#run({'left': '30%'})` or `let g:fzf_layout = {'left': '30%'}` + +#### Starting fzf in a popup window + +```vim +" Required: +" - width [float range [0 ~ 1]] +" - height [float range [0 ~ 1]] +" +" Optional: +" - xoffset [float default 0.5 range [0 ~ 1]] +" - yoffset [float default 0.5 range [0 ~ 1]] +" - highlight [string default 'Comment']: Highlight group for border +" - border [string default 'rounded']: Border style +" - 'rounded' / 'sharp' / 'horizontal' / 'vertical' / 'top' / 'bottom' / 'left' / 'right' +let g:fzf_layout = { 'window': { 'width': 0.9, 'height': 0.6 } } +``` + +Alternatively, you can make fzf open in a tmux popup window (requires tmux 3.2 +or above) by putting fzf-tmux options in `tmux` key. + +```vim +" See `man fzf-tmux` for available options +if exists('$TMUX') + let g:fzf_layout = { 'tmux': '-p90%,60%' } +else + let g:fzf_layout = { 'window': { 'width': 0.9, 'height': 0.6 } } +endif +``` + +#### Hide statusline + +When fzf starts in a terminal buffer, the file type of the buffer is set to +`fzf`. So you can set up `FileType fzf` autocmd to customize the settings of +the window. + +For example, if you use the default layout (`{'down': '~40%'}`) on Neovim, you +might want to temporarily disable the statusline for a cleaner look. + +```vim +if has('nvim') && !exists('g:fzf_layout') + autocmd! FileType fzf + autocmd FileType fzf set laststatus=0 noshowmode noruler + \| autocmd BufLeave set laststatus=2 showmode ruler +endif +``` + +[License](LICENSE) +------------------ + +The MIT License (MIT) + +Copyright (c) 2013-2020 Junegunn Choi diff --git a/skel/.config/nvim/plugged/fzf/README.md b/skel/.config/nvim/plugged/fzf/README.md new file mode 100644 index 0000000..4e368b0 --- /dev/null +++ b/skel/.config/nvim/plugged/fzf/README.md @@ -0,0 +1,655 @@ +fzf - a command-line fuzzy finder [![travis-ci](https://travis-ci.org/junegunn/fzf.svg?branch=master)](https://travis-ci.org/junegunn/fzf) +=== + +fzf is a general-purpose command-line fuzzy finder. + + + +It's an interactive Unix filter for command-line that can be used with any +list; files, command history, processes, hostnames, bookmarks, git commits, +etc. + +Pros +---- + +- Portable, no dependencies +- Blazingly fast +- The most comprehensive feature set +- Flexible layout +- Batteries included + - Vim/Neovim plugin, key bindings and fuzzy auto-completion + +Table of Contents +----------------- + + * [Installation](#installation) + * [Using Homebrew or Linuxbrew](#using-homebrew-or-linuxbrew) + * [Using git](#using-git) + * [Using Linux package managers](#using-linux-package-managers) + * [Windows](#windows) + * [As Vim plugin](#as-vim-plugin) + * [Upgrading fzf](#upgrading-fzf) + * [Building fzf](#building-fzf) + * [Usage](#usage) + * [Using the finder](#using-the-finder) + * [Layout](#layout) + * [Search syntax](#search-syntax) + * [Environment variables](#environment-variables) + * [Options](#options) + * [Demo](#demo) + * [Examples](#examples) + * [fzf-tmux script](#fzf-tmux-script) + * [Key bindings for command line](#key-bindings-for-command-line) + * [Fuzzy completion for bash and zsh](#fuzzy-completion-for-bash-and-zsh) + * [Files and directories](#files-and-directories) + * [Process IDs](#process-ids) + * [Host names](#host-names) + * [Environment variables / Aliases](#environment-variables--aliases) + * [Settings](#settings) + * [Supported commands](#supported-commands) + * [Custom fuzzy completion](#custom-fuzzy-completion) + * [Vim plugin](#vim-plugin) + * [Advanced topics](#advanced-topics) + * [Performance](#performance) + * [Executing external programs](#executing-external-programs) + * [Preview window](#preview-window) + * [Tips](#tips) + * [Respecting .gitignore](#respecting-gitignore) + * [Fish shell](#fish-shell) + * [Related projects](#related-projects) + * [License](#license) + +Installation +------------ + +fzf project consists of the following components: + +- `fzf` executable +- `fzf-tmux` script for launching fzf in a tmux pane +- Shell extensions + - Key bindings (`CTRL-T`, `CTRL-R`, and `ALT-C`) (bash, zsh, fish) + - Fuzzy auto-completion (bash, zsh) +- Vim/Neovim plugin + +You can [download fzf executable][bin] alone if you don't need the extra +stuff. + +[bin]: https://github.com/junegunn/fzf-bin/releases + +### Using Homebrew or Linuxbrew + +You can use [Homebrew](http://brew.sh/) or [Linuxbrew](http://linuxbrew.sh/) +to install fzf. + +```sh +brew install fzf + +# To install useful key bindings and fuzzy completion: +$(brew --prefix)/opt/fzf/install +``` + +fzf is also available [via MacPorts][portfile]: `sudo port install fzf` + +[portfile]: https://github.com/macports/macports-ports/blob/master/sysutils/fzf/Portfile + +### Using git + +Alternatively, you can "git clone" this repository to any directory and run +[install](https://github.com/junegunn/fzf/blob/master/install) script. + +```sh +git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf +~/.fzf/install +``` + +### Using Linux package managers + +| Package Manager | Linux Distribution | Command | +| --- | --- | --- | +| APK | Alpine Linux | `sudo apk add fzf` | +| APT | Debian 9+/Ubuntu 19.10+ | `sudo apt-get install fzf` | +| Conda | | `conda install -c conda-forge fzf` | +| DNF | Fedora | `sudo dnf install fzf` | +| Nix | NixOS | `nix-env -iA nixpkgs.fzf` | +| Pacman | Arch Linux | `sudo pacman -S fzf` | +| pkg | FreeBSD | `pkg install fzf` | +| pkg_add | OpenBSD | `pkg_add fzf` | +| Zypper | openSUSE | `sudo zypper install fzf` | + +Shell extensions (key bindings and fuzzy auto-completion) and Vim/Neovim +plugin may or may not be enabled by default depending on the package manager. +Refer to the package documentation for more information. + +### Windows + +Pre-built binaries for Windows can be downloaded [here][bin]. fzf is also +available via [Chocolatey][choco] and [Scoop][scoop]: + +| Package manager | Command | +| --- | --- | +| Chocolatey | `choco install fzf` | +| Scoop | `scoop install fzf` | + +[choco]: https://chocolatey.org/packages/fzf +[scoop]: https://github.com/ScoopInstaller/Main/blob/master/bucket/fzf.json + +Known issues and limitations on Windows can be found on [the wiki +page][windows-wiki]. + +[windows-wiki]: https://github.com/junegunn/fzf/wiki/Windows + +### As Vim plugin + +If you use +[vim-plug](https://github.com/junegunn/vim-plug), add this line to your Vim +configuration file: + +```vim +Plug 'junegunn/fzf', { 'do': { -> fzf#install() } } +``` + +`fzf#install()` makes sure that you have the latest binary, but it's optional, +so you can omit it if you use a plugin manager that doesn't support hooks. + +For more installation options, see [README-VIM.md](README-VIM.md). + +Upgrading fzf +------------- + +fzf is being actively developed and you might want to upgrade it once in a +while. Please follow the instruction below depending on the installation +method used. + +- git: `cd ~/.fzf && git pull && ./install` +- brew: `brew update; brew reinstall fzf` +- macports: `sudo port upgrade fzf` +- chocolatey: `choco upgrade fzf` +- vim-plug: `:PlugUpdate fzf` + +Building fzf +------------ + +See [BUILD.md](BUILD.md). + +Usage +----- + +fzf will launch interactive finder, read the list from STDIN, and write the +selected item to STDOUT. + +```sh +find * -type f | fzf > selected +``` + +Without STDIN pipe, fzf will use find command to fetch the list of +files excluding hidden ones. (You can override the default command with +`FZF_DEFAULT_COMMAND`) + +```sh +vim $(fzf) +``` + +#### Using the finder + +- `CTRL-J` / `CTRL-K` (or `CTRL-N` / `CTRL-P`) to move cursor up and down +- `Enter` key to select the item, `CTRL-C` / `CTRL-G` / `ESC` to exit +- On multi-select mode (`-m`), `TAB` and `Shift-TAB` to mark multiple items +- Emacs style key bindings +- Mouse: scroll, click, double-click; shift-click and shift-scroll on + multi-select mode + +#### Layout + +fzf by default starts in fullscreen mode, but you can make it start below the +cursor with `--height` option. + +```sh +vim $(fzf --height 40%) +``` + +Also check out `--reverse` and `--layout` options if you prefer +"top-down" layout instead of the default "bottom-up" layout. + +```sh +vim $(fzf --height 40% --reverse) +``` + +You can add these options to `$FZF_DEFAULT_OPTS` so that they're applied by +default. For example, + +```sh +export FZF_DEFAULT_OPTS='--height 40% --layout=reverse --border' +``` + +#### Search syntax + +Unless otherwise specified, fzf starts in "extended-search mode" where you can +type in multiple search terms delimited by spaces. e.g. `^music .mp3$ sbtrkt +!fire` + +| Token | Match type | Description | +| --------- | -------------------------- | ------------------------------------ | +| `sbtrkt` | fuzzy-match | Items that match `sbtrkt` | +| `'wild` | exact-match (quoted) | Items that include `wild` | +| `^music` | prefix-exact-match | Items that start with `music` | +| `.mp3$` | suffix-exact-match | Items that end with `.mp3` | +| `!fire` | inverse-exact-match | Items that do not include `fire` | +| `!^music` | inverse-prefix-exact-match | Items that do not start with `music` | +| `!.mp3$` | inverse-suffix-exact-match | Items that do not end with `.mp3` | + +If you don't prefer fuzzy matching and do not wish to "quote" every word, +start fzf with `-e` or `--exact` option. Note that when `--exact` is set, +`'`-prefix "unquotes" the term. + +A single bar character term acts as an OR operator. For example, the following +query matches entries that start with `core` and end with either `go`, `rb`, +or `py`. + +``` +^core go$ | rb$ | py$ +``` + +#### Environment variables + +- `FZF_DEFAULT_COMMAND` + - Default command to use when input is tty + - e.g. `export FZF_DEFAULT_COMMAND='fd --type f'` +- `FZF_DEFAULT_OPTS` + - Default options + - e.g. `export FZF_DEFAULT_OPTS="--layout=reverse --inline-info"` + +#### Options + +See the man page (`man fzf`) for the full list of options. + +#### Demo +If you learn by watching videos, check out this screencast by [@samoshkin](https://github.com/samoshkin) to explore `fzf` features. + + + + + +Examples +-------- + +Many useful examples can be found on [the wiki +page](https://github.com/junegunn/fzf/wiki/examples). Feel free to add your +own as well. + +`fzf-tmux` script +----------------- + +[fzf-tmux](bin/fzf-tmux) is a bash script that opens fzf in a tmux pane. + +```sh +# usage: fzf-tmux [LAYOUT OPTIONS] [--] [FZF OPTIONS] + +# See available options +fzf-tmux --help + +# select git branches in horizontal split below (15 lines) +git branch | fzf-tmux -d 15 + +# select multiple words in vertical split on the left (20% of screen width) +cat /usr/share/dict/words | fzf-tmux -l 20% --multi --reverse +``` + +It will still work even when you're not on tmux, silently ignoring `-[pudlr]` +options, so you can invariably use `fzf-tmux` in your scripts. + +Alternatively, you can use `--height HEIGHT[%]` option not to start fzf in +fullscreen mode. + +```sh +fzf --height 40% +``` + +Key bindings for command-line +----------------------------- + +The install script will setup the following key bindings for bash, zsh, and +fish. + +- `CTRL-T` - Paste the selected files and directories onto the command-line + - Set `FZF_CTRL_T_COMMAND` to override the default command + - Set `FZF_CTRL_T_OPTS` to pass additional options +- `CTRL-R` - Paste the selected command from history onto the command-line + - If you want to see the commands in chronological order, press `CTRL-R` + again which toggles sorting by relevance + - Set `FZF_CTRL_R_OPTS` to pass additional options +- `ALT-C` - cd into the selected directory + - Set `FZF_ALT_C_COMMAND` to override the default command + - Set `FZF_ALT_C_OPTS` to pass additional options + +If you're on a tmux session, you can start fzf in a tmux split pane or in +a tmux popup window by setting `FZF_TMUX_OPTS` (e.g. `-d 40%`). +See `fzf-tmux --help` for available options. + +More tips can be found on [the wiki page](https://github.com/junegunn/fzf/wiki/Configuring-shell-key-bindings). + +Fuzzy completion for bash and zsh +--------------------------------- + +#### Files and directories + +Fuzzy completion for files and directories can be triggered if the word before +the cursor ends with the trigger sequence which is by default `**`. + +- `COMMAND [DIRECTORY/][FUZZY_PATTERN]**` + +```sh +# Files under current directory +# - You can select multiple items with TAB key +vim ** + +# Files under parent directory +vim ../** + +# Files under parent directory that match `fzf` +vim ../fzf** + +# Files under your home directory +vim ~/** + + +# Directories under current directory (single-selection) +cd ** + +# Directories under ~/github that match `fzf` +cd ~/github/fzf** +``` + +#### Process IDs + +Fuzzy completion for PIDs is provided for kill command. In this case, +there is no trigger sequence, just press tab key after kill command. + +```sh +# Can select multiple processes with or keys +kill -9 +``` + +#### Host names + +For ssh and telnet commands, fuzzy completion for host names is provided. The +names are extracted from /etc/hosts and ~/.ssh/config. + +```sh +ssh ** +telnet ** +``` + +#### Environment variables / Aliases + +```sh +unset ** +export ** +unalias ** +``` + +#### Settings + +```sh +# Use ~~ as the trigger sequence instead of the default ** +export FZF_COMPLETION_TRIGGER='~~' + +# Options to fzf command +export FZF_COMPLETION_OPTS='+c -x' + +# Use fd (https://github.com/sharkdp/fd) instead of the default find +# command for listing path candidates. +# - The first argument to the function ($1) is the base path to start traversal +# - See the source code (completion.{bash,zsh}) for the details. +_fzf_compgen_path() { + fd --hidden --follow --exclude ".git" . "$1" +} + +# Use fd to generate the list for directory completion +_fzf_compgen_dir() { + fd --type d --hidden --follow --exclude ".git" . "$1" +} + +# (EXPERIMENTAL) Advanced customization of fzf options via _fzf_comprun function +# - The first argument to the function is the name of the command. +# - You should make sure to pass the rest of the arguments to fzf. +_fzf_comprun() { + local command=$1 + shift + + case "$command" in + cd) fzf "$@" --preview 'tree -C {} | head -200' ;; + export|unset) fzf "$@" --preview "eval 'echo \$'{}" ;; + ssh) fzf "$@" --preview 'dig {}' ;; + *) fzf "$@" ;; + esac +} +``` + +#### Supported commands + +On bash, fuzzy completion is enabled only for a predefined set of commands +(`complete | grep _fzf` to see the list). But you can enable it for other +commands as well by using `_fzf_setup_completion` helper function. + +```sh +# usage: _fzf_setup_completion path|dir|var|alias|host COMMANDS... +_fzf_setup_completion path ag git kubectl +_fzf_setup_completion dir tree +``` + +#### Custom fuzzy completion + +_**(Custom completion API is experimental and subject to change)**_ + +For a command named _"COMMAND"_, define `_fzf_complete_COMMAND` function using +`_fzf_complete` helper. + +```sh +# Custom fuzzy completion for "doge" command +# e.g. doge ** +_fzf_complete_doge() { + _fzf_complete --multi --reverse --prompt="doge> " -- "$@" < <( + echo very + echo wow + echo such + echo doge + ) +} +``` + +- The arguments before `--` are the options to fzf. +- After `--`, simply pass the original completion arguments unchanged (`"$@"`). +- Then write a set of commands that generates the completion candidates and + feed its output to the function using process substitution (`< <(...)`). + +zsh will automatically pick up the function using the naming convention but in +bash you have to manually associate the function with the command using +`complete` command. + +```sh +[ -n "$BASH" ] && complete -F _fzf_complete_doge -o default -o bashdefault doge +``` + +If you need to post-process the output from fzf, define +`_fzf_complete_COMMAND_post` as follows. + +```sh +_fzf_complete_foo() { + _fzf_complete --multi --reverse --header-lines=3 -- "$@" < <( + ls -al + ) +} + +_fzf_complete_foo_post() { + awk '{print $NF}' +} + +[ -n "$BASH" ] && complete -F _fzf_complete_foo -o default -o bashdefault foo +``` + +Vim plugin +---------- + +See [README-VIM.md](README-VIM.md). + +Advanced topics +--------------- + +### Performance + +fzf is fast and is [getting even faster][perf]. Performance should not be +a problem in most use cases. However, you might want to be aware of the +options that affect the performance. + +- `--ansi` tells fzf to extract and parse ANSI color codes in the input and it + makes the initial scanning slower. So it's not recommended that you add it + to your `$FZF_DEFAULT_OPTS`. +- `--nth` makes fzf slower as fzf has to tokenize each line. +- `--with-nth` makes fzf slower as fzf has to tokenize and reassemble each + line. +- If you absolutely need better performance, you can consider using + `--algo=v1` (the default being `v2`) to make fzf use a faster greedy + algorithm. However, this algorithm is not guaranteed to find the optimal + ordering of the matches and is not recommended. + +[perf]: https://junegunn.kr/images/fzf-0.17.0.png + +### Executing external programs + +You can set up key bindings for starting external processes without leaving +fzf (`execute`, `execute-silent`). + +```bash +# Press F1 to open the file with less without leaving fzf +# Press CTRL-Y to copy the line to clipboard and aborts fzf (requires pbcopy) +fzf --bind 'f1:execute(less -f {}),ctrl-y:execute-silent(echo {} | pbcopy)+abort' +``` + +See *KEY BINDINGS* section of the man page for details. + +### Preview window + +When `--preview` option is set, fzf automatically starts an external process with +the current line as the argument and shows the result in the split window. Your +`$SHELL` is used to execute the command with `$SHELL -c COMMAND`. + +```bash +# {} is replaced to the single-quoted string of the focused line +fzf --preview 'cat {}' +``` + +Since the preview window is updated only after the process is complete, it's +important that the command finishes quickly. + +```bash +# Use head instead of cat so that the command doesn't take too long to finish +fzf --preview 'head -100 {}' +``` + +Preview window supports ANSI colors, so you can use any program that +syntax-highlights the content of a file. + +- Bat: https://github.com/sharkdp/bat +- Highlight: http://www.andre-simon.de/doku/highlight/en/highlight.php + +```bash +fzf --preview 'bat --style=numbers --color=always {} | head -500' +``` + +You can customize the size, position, and border of the preview window using +`--preview-window` option, and the foreground and background color of it with +`--color` option. For example, + +```bash +fzf --height 40% --layout reverse --info inline --border \ + --preview 'file {}' --preview-window down:1:noborder \ + --color 'fg:#bbccdd,fg+:#ddeeff,bg:#334455,preview-bg:#223344,border:#778899' +``` + +See the man page (`man fzf`) for the full list of options. + +For more advanced examples, see [Key bindings for git with fzf][fzf-git] +([code](https://gist.github.com/junegunn/8b572b8d4b5eddd8b85e5f4d40f17236)). + +[fzf-git]: https://junegunn.kr/2016/07/fzf-git/ + +---- + +Since fzf is a general-purpose text filter rather than a file finder, **it is +not a good idea to add `--preview` option to your `$FZF_DEFAULT_OPTS`**. + +```sh +# ********************* +# ** DO NOT DO THIS! ** +# ********************* +export FZF_DEFAULT_OPTS='--preview "bat --style=numbers --color=always {} | head -500"' + +# bat doesn't work with any input other than the list of files +ps -ef | fzf +seq 100 | fzf +history | fzf +``` + +Tips +---- + +#### Respecting `.gitignore` + +You can use [fd](https://github.com/sharkdp/fd), +[ripgrep](https://github.com/BurntSushi/ripgrep), or [the silver +searcher](https://github.com/ggreer/the_silver_searcher) instead of the +default find command to traverse the file system while respecting +`.gitignore`. + +```sh +# Feed the output of fd into fzf +fd --type f | fzf + +# Setting fd as the default source for fzf +export FZF_DEFAULT_COMMAND='fd --type f' + +# Now fzf (w/o pipe) will use fd instead of find +fzf + +# To apply the command to CTRL-T as well +export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND" +``` + +If you want the command to follow symbolic links, and don't want it to exclude +hidden files, use the following command: + +```sh +export FZF_DEFAULT_COMMAND='fd --type f --hidden --follow --exclude .git' +``` + +#### Fish shell + +`CTRL-T` key binding of fish, unlike those of bash and zsh, will use the last +token on the command-line as the root directory for the recursive search. For +instance, hitting `CTRL-T` at the end of the following command-line + +```sh +ls /var/ +``` + +will list all files and directories under `/var/`. + +When using a custom `FZF_CTRL_T_COMMAND`, use the unexpanded `$dir` variable to +make use of this feature. `$dir` defaults to `.` when the last token is not a +valid directory. Example: + +```sh +set -g FZF_CTRL_T_COMMAND "command find -L \$dir -type f 2> /dev/null | sed '1d; s#^\./##'" +``` + +Related projects +---------------- + +https://github.com/junegunn/fzf/wiki/Related-projects + +[License](LICENSE) +------------------ + +The MIT License (MIT) + +Copyright (c) 2013-2020 Junegunn Choi diff --git a/skel/.config/nvim/plugged/fzf/bin/fzf-tmux b/skel/.config/nvim/plugged/fzf/bin/fzf-tmux new file mode 100755 index 0000000..4b3e497 --- /dev/null +++ b/skel/.config/nvim/plugged/fzf/bin/fzf-tmux @@ -0,0 +1,236 @@ +#!/usr/bin/env bash +# fzf-tmux: starts fzf in a tmux pane +# usage: fzf-tmux [LAYOUT OPTIONS] [--] [FZF OPTIONS] + +fail() { + >&2 echo "$1" + exit 2 +} + +fzf="$(command -v fzf 2> /dev/null)" || fzf="$(dirname "$0")/fzf" +[[ -x "$fzf" ]] || fail 'fzf executable not found' + +tmux_args=() +args=() +opt="" +skip="" +swap="" +close="" +term="" +[[ -n "$LINES" ]] && lines=$LINES || lines=$(tput lines) || lines=$(tmux display-message -p "#{pane_height}") +[[ -n "$COLUMNS" ]] && columns=$COLUMNS || columns=$(tput cols) || columns=$(tmux display-message -p "#{pane_width}") + +help() { + >&2 echo 'usage: fzf-tmux [LAYOUT OPTIONS] [--] [FZF OPTIONS] + + LAYOUT OPTIONS: + (default layout: -d 50%) + + Popup window (requires tmux 3.2 or above): + -p [WIDTH[%][,HEIGHT[%]]] (default: 50%) + -w WIDTH[%] + -h HEIGHT[%] + -x COL + -y ROW + + Split pane: + -u [HEIGHT[%]] Split above (up) + -d [HEIGHT[%]] Split below (down) + -l [WIDTH[%]] Split left + -r [WIDTH[%]] Split right +' + exit +} + +while [[ $# -gt 0 ]]; do + arg="$1" + shift + [[ -z "$skip" ]] && case "$arg" in + -) + term=1 + ;; + --help) + help + ;; + --version) + echo "fzf-tmux (with fzf $("$fzf" --version))" + exit + ;; + -p*|-w*|-h*|-x*|-y*|-d*|-u*|-r*|-l*) + if [[ "$arg" =~ ^-[pwhxy] ]]; then + [[ "$opt" =~ "-K -E" ]] || opt="-K -E" + elif [[ "$arg" =~ ^.[lr] ]]; then + opt="-h" + if [[ "$arg" =~ ^.l ]]; then + opt="$opt -d" + swap="; swap-pane -D ; select-pane -L" + close="; tmux swap-pane -D" + fi + else + opt="" + if [[ "$arg" =~ ^.u ]]; then + opt="$opt -d" + swap="; swap-pane -D ; select-pane -U" + close="; tmux swap-pane -D" + fi + fi + if [[ ${#arg} -gt 2 ]]; then + size="${arg:2}" + else + if [[ "$1" =~ ^[0-9%,]+$ ]] || [[ "$1" =~ ^[A-Z]$ ]]; then + size="$1" + shift + else + continue + fi + fi + + if [[ "$arg" =~ ^-p ]]; then + if [[ -n "$size" ]]; then + w=${size%%,*} + h=${size##*,} + opt="$opt -w$w -h$h" + fi + elif [[ "$arg" =~ ^-[whxy] ]]; then + opt="$opt ${arg:0:2}$size" + elif [[ "$size" =~ %$ ]]; then + size=${size:0:((${#size}-1))} + if [[ -n "$swap" ]]; then + opt="$opt -p $(( 100 - size ))" + else + opt="$opt -p $size" + fi + else + if [[ -n "$swap" ]]; then + if [[ "$arg" =~ ^.l ]]; then + max=$columns + else + max=$lines + fi + size=$(( max - size )) + [[ $size -lt 0 ]] && size=0 + opt="$opt -l $size" + else + opt="$opt -l $size" + fi + fi + ;; + --) + # "--" can be used to separate fzf-tmux options from fzf options to + # avoid conflicts + skip=1 + tmux_args=("${args[@]}") + args=() + continue + ;; + *) + args+=("$arg") + ;; + esac + [[ -n "$skip" ]] && args+=("$arg") +done + +if [[ -z "$TMUX" ]]; then + "$fzf" "${args[@]}" + exit $? +fi + +# --height option is not allowed +args=("--no-height" "${args[@]}") + +# Handle zoomed tmux pane by moving it to a temp window +if tmux list-panes -F '#F' | grep -q Z; then + zoomed=1 + original_window=$(tmux display-message -p "#{window_id}") + tmp_window=$(tmux new-window -d -P -F "#{window_id}" "bash -c 'while :; do for c in \\| / - '\\;' do sleep 0.2; printf \"\\r\$c fzf-tmux is running\\r\"; done; done'") + tmux swap-pane -t $tmp_window \; select-window -t $tmp_window +fi + +set -e + +# Clean up named pipes on exit +id=$RANDOM +argsf="${TMPDIR:-/tmp}/fzf-args-$id" +fifo1="${TMPDIR:-/tmp}/fzf-fifo1-$id" +fifo2="${TMPDIR:-/tmp}/fzf-fifo2-$id" +fifo3="${TMPDIR:-/tmp}/fzf-fifo3-$id" +cleanup() { + \rm -f $argsf $fifo1 $fifo2 $fifo3 + + # Restore tmux window options + if [[ "${#tmux_win_opts[@]}" -gt 0 ]]; then + eval "tmux ${tmux_win_opts[@]}" + fi + + # Remove temp window if we were zoomed + if [[ -n "$zoomed" ]]; then + tmux display-message -p "#{window_id}" > /dev/null + tmux swap-pane -t $original_window \; \ + select-window -t $original_window \; \ + kill-window -t $tmp_window \; \ + resize-pane -Z + fi + + if [ $# -gt 0 ]; then + trap - EXIT + exit 130 + fi +} +trap 'cleanup 1' SIGUSR1 +trap 'cleanup' EXIT + +envs="env TERM=$TERM " +[[ "$opt" =~ "-K -E" ]] && FZF_DEFAULT_OPTS="--margin 0,1 $FZF_DEFAULT_OPTS" +[[ -n "$FZF_DEFAULT_OPTS" ]] && envs="$envs FZF_DEFAULT_OPTS=$(printf %q "$FZF_DEFAULT_OPTS")" +[[ -n "$FZF_DEFAULT_COMMAND" ]] && envs="$envs FZF_DEFAULT_COMMAND=$(printf %q "$FZF_DEFAULT_COMMAND")" + +mkfifo -m o+w $fifo2 +mkfifo -m o+w $fifo3 + +# Build arguments to fzf +opts="" +for arg in "${args[@]}"; do + arg="${arg//\\/\\\\}" + arg="${arg//\"/\\\"}" + arg="${arg//\`/\\\`}" + arg="${arg//$/\\$}" + opts="$opts \"$arg\"" +done + +pppid=$$ +echo -n "trap 'kill -SIGUSR1 -$pppid' EXIT SIGINT SIGTERM;" > $argsf +close="; trap - EXIT SIGINT SIGTERM $close" + +tmux_win_opts=( $(tmux show-window-options remain-on-exit \; show-window-options synchronize-panes | sed '/ off/d; s/^/set-window-option /; s/$/ \\;/') ) + +if [[ "$opt" =~ "-K -E" ]]; then + cat $fifo2 & + if [[ -n "$term" ]] || [[ -t 0 ]]; then + cat <<< "\"$fzf\" $opts > $fifo2; out=\$? $close; exit \$out" >> $argsf + TMUX=$(echo $TMUX | cut -d , -f 1,2) tmux popup -d "$PWD" "${tmux_args[@]}" $opt -R "$envs bash $argsf" > /dev/null 2>&1 + else + mkfifo $fifo1 + cat <<< "\"$fzf\" $opts < $fifo1 > $fifo2; out=\$? $close; exit \$out" >> $argsf + cat <&0 > $fifo1 & + TMUX=$(echo $TMUX | cut -d , -f 1,2) tmux popup -d "$PWD" "${tmux_args[@]}" $opt -R "$envs bash $argsf" > /dev/null 2>&1 + fi + exit $? +fi + +if [[ -n "$term" ]] || [[ -t 0 ]]; then + cat <<< "\"$fzf\" $opts > $fifo2; echo \$? > $fifo3 $close" >> $argsf + TMUX=$(echo $TMUX | cut -d , -f 1,2) tmux set-window-option synchronize-panes off \;\ + set-window-option remain-on-exit off \;\ + split-window $opt "${tmux_args[@]}" "$envs bash -c 'cd $(printf %q "$PWD"); exec -a fzf bash $argsf'" $swap \ + > /dev/null 2>&1 || { "$fzf" "${args[@]}"; exit $?; } +else + mkfifo $fifo1 + cat <<< "\"$fzf\" $opts < $fifo1 > $fifo2; echo \$? > $fifo3 $close" >> $argsf + TMUX=$(echo $TMUX | cut -d , -f 1,2) tmux set-window-option synchronize-panes off \;\ + set-window-option remain-on-exit off \;\ + split-window $opt "${tmux_args[@]}" "$envs bash -c 'exec -a fzf bash $argsf'" $swap \ + > /dev/null 2>&1 || { "$fzf" "${args[@]}"; exit $?; } + cat <&0 > $fifo1 & +fi +cat $fifo2 +exit "$(cat $fifo3)" diff --git a/skel/.config/nvim/plugged/fzf/doc/fzf.txt b/skel/.config/nvim/plugged/fzf/doc/fzf.txt new file mode 100644 index 0000000..a6deda6 --- /dev/null +++ b/skel/.config/nvim/plugged/fzf/doc/fzf.txt @@ -0,0 +1,447 @@ +fzf.txt fzf Last change: April 4 2020 +FZF - TABLE OF CONTENTS *fzf* *fzf-toc* +============================================================================== + + FZF Vim integration + Installation + Summary + :FZF[!] + Configuration + Examples + Explanation of g:fzf_colors + fzf#run + fzf#wrap + Tips + fzf inside terminal buffer + Starting fzf in a popup window + Hide statusline + License + +FZF VIM INTEGRATION *fzf-vim-integration* +============================================================================== + + +INSTALLATION *fzf-installation* +============================================================================== + +Once you have fzf installed, you can enable it inside Vim simply by adding the +directory to 'runtimepath' in your Vim configuration file. The path may differ +depending on the package manager. +> + " If installed using Homebrew + set rtp+=/usr/local/opt/fzf + + " If installed using git + set rtp+=~/.fzf +< +If you use {vim-plug}{1}, the same can be written as: +> + " If installed using Homebrew + Plug '/usr/local/opt/fzf' + + " If installed using git + Plug '~/.fzf' +< +But if you want the latest Vim plugin file from GitHub rather than the one +included in the package, write: +> + Plug 'junegunn/fzf' +< +The Vim plugin will pick up fzf binary available on the system. If fzf is not +found on `$PATH`, it will ask you if it should download the latest binary for +you. + +To make sure that you have the latest version of the binary, set up +post-update hook like so: + + *fzf#install* +> + Plug 'junegunn/fzf', { 'do': { -> fzf#install() } } +< + {1} https://github.com/junegunn/vim-plug + + +SUMMARY *fzf-summary* +============================================================================== + +The Vim plugin of fzf provides two core functions, and `:FZF` command which is +the basic file selector command built on top of them. + + 1. `fzf#run([spec dict])` + - Starts fzf inside Vim with the given spec + - `:call fzf#run({'source': 'ls'})` + 2. `fzf#wrap([spec dict]) -> (dict)` + - Takes a spec for `fzf#run` and returns an extended version of it with + additional options for addressing global preferences (`g:fzf_xxx`) + - `:echo fzf#wrap({'source': 'ls'})` + - We usually wrap a spec with `fzf#wrap` before passing it to `fzf#run` + - `:call fzf#run(fzf#wrap({'source': 'ls'}))` + 3. `:FZF [fzf_options string] [path string]` + - Basic fuzzy file selector + - A reference implementation for those who don't want to write VimScript to + implement custom commands + - If you're looking for more such commands, check out {fzf.vim}{2} project. + +The most important of all is `fzf#run`, but it would be easier to understand +the whole if we start off with `:FZF` command. + + {2} https://github.com/junegunn/fzf.vim + + +:FZF[!] +============================================================================== + + *:FZF* +> + " Look for files under current directory + :FZF + + " Look for files under your home directory + :FZF ~ + + " With fzf command-line options + :FZF --reverse --info=inline /tmp + + " Bang version starts fzf in fullscreen mode + :FZF! +< +Similarly to {ctrlp.vim}{2}, use enter key, CTRL-T, CTRL-X or CTRL-V to open +selected files in the current window, in new tabs, in horizontal splits, or in +vertical splits respectively. + +Note that the environment variables `FZF_DEFAULT_COMMAND` and +`FZF_DEFAULT_OPTS` also apply here. + + {2} https://github.com/kien/ctrlp.vim + + +< Configuration >_____________________________________________________________~ + *fzf-configuration* + + *g:fzf_action* *g:fzf_layout* *g:fzf_colors* *g:fzf_history_dir* + + - `g:fzf_action` + - Customizable extra key bindings for opening selected files in different + ways + - `g:fzf_layout` + - Determines the size and position of fzf window + - `g:fzf_colors` + - Customizes fzf colors to match the current color scheme + - `g:fzf_history_dir` + - Enables history feature + + +Examples~ + *fzf-examples* +> + " This is the default extra key bindings + let g:fzf_action = { + \ 'ctrl-t': 'tab split', + \ 'ctrl-x': 'split', + \ 'ctrl-v': 'vsplit' } + + " An action can be a reference to a function that processes selected lines + function! s:build_quickfix_list(lines) + call setqflist(map(copy(a:lines), '{ "filename": v:val }')) + copen + cc + endfunction + + let g:fzf_action = { + \ 'ctrl-q': function('s:build_quickfix_list'), + \ 'ctrl-t': 'tab split', + \ 'ctrl-x': 'split', + \ 'ctrl-v': 'vsplit' } + + " Default fzf layout + " - down / up / left / right + let g:fzf_layout = { 'down': '~40%' } + + " You can set up fzf window using a Vim command (Neovim or latest Vim 8 required) + let g:fzf_layout = { 'window': 'enew' } + let g:fzf_layout = { 'window': '-tabnew' } + let g:fzf_layout = { 'window': '10new' } + + " Customize fzf colors to match your color scheme + " - fzf#wrap translates this to a set of `--color` options + let g:fzf_colors = + \ { 'fg': ['fg', 'Normal'], + \ 'bg': ['bg', 'Normal'], + \ 'hl': ['fg', 'Comment'], + \ 'fg+': ['fg', 'CursorLine', 'CursorColumn', 'Normal'], + \ 'bg+': ['bg', 'CursorLine', 'CursorColumn'], + \ 'hl+': ['fg', 'Statement'], + \ 'info': ['fg', 'PreProc'], + \ 'border': ['fg', 'Ignore'], + \ 'prompt': ['fg', 'Conditional'], + \ 'pointer': ['fg', 'Exception'], + \ 'marker': ['fg', 'Keyword'], + \ 'spinner': ['fg', 'Label'], + \ 'header': ['fg', 'Comment'] } + + " Enable per-command history + " - History files will be stored in the specified directory + " - When set, CTRL-N and CTRL-P will be bound to 'next-history' and + " 'previous-history' instead of 'down' and 'up'. + let g:fzf_history_dir = '~/.local/share/fzf-history' +< + +Explanation of g:fzf_colors~ + *fzf-explanation-of-gfzfcolors* + +`g:fzf_colors` is a dictionary mapping fzf elements to a color specification +list: +> + element: [ component, group1 [, group2, ...] ] +< + - `element` is an fzf element to apply a color to: + + ----------------------+------------------------------------------------------ + Element | Description ~ + ----------------------+------------------------------------------------------ + `fg` / `bg` / `hl` | Item (foreground / background / highlight) + `fg+` / `bg+` / `hl+` | Current item (foreground / background / highlight) + `hl` / `hl+` | Highlighted substrings (normal / current) + `gutter` | Background of the gutter on the left + `pointer` | Pointer to the current line ( `>` ) + `marker` | Multi-select marker ( `>` ) + `border` | Border around the window ( `--border` and `--preview` ) + `header` | Header ( `--header` or `--header-lines` ) + `info` | Info line (match counters) + `spinner` | Streaming input indicator + `prompt` | Prompt before query ( `> ` ) + ----------------------+------------------------------------------------------ + - `component` specifies the component (`fg` / `bg`) from which to extract the + color when considering each of the following highlight groups + - `group1 [, group2, ...]` is a list of highlight groups that are searched (in + order) for a matching color definition + +For example, consider the following specification: +> + 'prompt': ['fg', 'Conditional', 'Comment'], +< +This means we color the prompt - using the `fg` attribute of the `Conditional` +if it exists, - otherwise use the `fg` attribute of the `Comment` highlight +group if it exists, - otherwise fall back to the default color settings for +the prompt. + +You can examine the color option generated according the setting by printing +the result of `fzf#wrap()` function like so: +> + :echo fzf#wrap() +< + +FZF#RUN +============================================================================== + + *fzf#run* + +`fzf#run()` function is the core of Vim integration. It takes a single +dictionary argument, a spec, and starts fzf process accordingly. At the very +least, specify `sink` option to tell what it should do with the selected +entry. +> + call fzf#run({'sink': 'e'}) +< +We haven't specified the `source`, so this is equivalent to starting fzf on +command line without standard input pipe; fzf will use find command (or +`$FZF_DEFAULT_COMMAND` if defined) to list the files under the current +directory. When you select one, it will open it with the sink, `:e` command. +If you want to open it in a new tab, you can pass `:tabedit` command instead +as the sink. +> + call fzf#run({'sink': 'tabedit'}) +< +Instead of using the default find command, you can use any shell command as +the source. The following example will list the files managed by git. It's +equivalent to running `git ls-files | fzf` on shell. +> + call fzf#run({'source': 'git ls-files', 'sink': 'e'}) +< +fzf options can be specified as `options` entry in spec dictionary. +> + call fzf#run({'sink': 'tabedit', 'options': '--multi --reverse'}) +< +You can also pass a layout option if you don't want fzf window to take up the +entire screen. +> + " up / down / left / right / window are allowed + call fzf#run({'source': 'git ls-files', 'sink': 'e', 'left': '40%'}) + call fzf#run({'source': 'git ls-files', 'sink': 'e', 'window': '30vnew'}) +< +`source` doesn't have to be an external shell command, you can pass a Vim +array as the source. In the next example, we pass the names of color schemes +as the source to implement a color scheme selector. +> + call fzf#run({'source': map(split(globpath(&rtp, 'colors/*.vim')), + \ 'fnamemodify(v:val, ":t:r")'), + \ 'sink': 'colo', 'left': '25%'}) +< +The following table summarizes the available options. + + ---------------------------+---------------+---------------------------------------------------------------------- + Option name | Type | Description ~ + ---------------------------+---------------+---------------------------------------------------------------------- + `source` | string | External command to generate input to fzf (e.g. `find .` ) + `source` | list | Vim list as input to fzf + `sink` | string | Vim command to handle the selected item (e.g. `e` , `tabe` ) + `sink` | funcref | Reference to function to process each selected item + `sink*` | funcref | Similar to `sink` , but takes the list of output lines at once + `options` | string/list | Options to fzf + `dir` | string | Working directory + `up` / `down` / `left` / `right` | number/string | (Layout) Window position and size (e.g. `20` , `50%` ) + `tmux` | string | (Layout) fzf-tmux options (e.g. `-p90%,60%` ) + `window` (Vim 8 / Neovim) | string | (Layout) Command to open fzf window (e.g. `vertical aboveleft 30new` ) + `window` (Vim 8 / Neovim) | dict | (Layout) Popup window settings (e.g. `{'width': 0.9, 'height': 0.6}` ) + ---------------------------+---------------+---------------------------------------------------------------------- + +`options` entry can be either a string or a list. For simple cases, string +should suffice, but prefer to use list type to avoid escaping issues. +> + call fzf#run({'options': '--reverse --prompt "C:\\Program Files\\"'}) + call fzf#run({'options': ['--reverse', '--prompt', 'C:\Program Files\']}) +< +When `window` entry is a dictionary, fzf will start in a popup window. The +following options are allowed: + + - Required: + - `width` [float range [0 ~ 1]] + - `height` [float range [0 ~ 1]] + - Optional: + - `yoffset` [float default 0.5 range [0 ~ 1]] + - `xoffset` [float default 0.5 range [0 ~ 1]] + - `highlight` [string default `'Comment'`]: Highlight group for border + - `border` [string default `rounded`]: Border style + - `rounded` / `sharp` / `horizontal` / `vertical` / `top` / `bottom` / `left` / `right` + + +FZF#WRAP +============================================================================== + + *fzf#wrap* + +We have seen that several aspects of `:FZF` command can be configured with a +set of global option variables; different ways to open files (`g:fzf_action`), +window position and size (`g:fzf_layout`), color palette (`g:fzf_colors`), +etc. + +So how can we make our custom `fzf#run` calls also respect those variables? +Simply by "wrapping" the spec dictionary with `fzf#wrap` before passing it to +`fzf#run`. + + - `fzf#wrap([name string], [spec dict], [fullscreen bool]) -> (dict)` + - All arguments are optional. Usually we only need to pass a spec + dictionary. + - `name` is for managing history files. It is ignored if `g:fzf_history_dir` + is not defined. + - `fullscreen` can be either `0` or `1` (default: 0). + +`fzf#wrap` takes a spec and returns an extended version of it (also a +dictionary) with additional options for addressing global preferences. You can +examine the return value of it like so: +> + echo fzf#wrap({'source': 'ls'}) +< +After we "wrap" our spec, we pass it to `fzf#run`. +> + call fzf#run(fzf#wrap({'source': 'ls'})) +< +Now it supports CTRL-T, CTRL-V, and CTRL-X key bindings and it opens fzf +window according to `g:fzf_layout` setting. + +To make it easier to use, let's define `LS` command. +> + command! LS call fzf#run(fzf#wrap({'source': 'ls'})) +< +Type `:LS` and see how it works. + +We would like to make `:LS!` (bang version) open fzf in fullscreen, just like +`:FZF!`. Add `-bang` to command definition, and use value to set the +last `fullscreen` argument of `fzf#wrap` (see :help ). +> + " On :LS!, evaluates to '!', and '!0' becomes 1 + command! -bang LS call fzf#run(fzf#wrap({'source': 'ls'}, 0)) +< +Our `:LS` command will be much more useful if we can pass a directory argument +to it, so that something like `:LS /tmp` is possible. +> + command! -bang -complete=dir -nargs=* LS + \ call fzf#run(fzf#wrap({'source': 'ls', 'dir': }, 0)) +< +Lastly, if you have enabled `g:fzf_history_dir`, you might want to assign a +unique name to our command and pass it as the first argument to `fzf#wrap`. +> + " The query history for this command will be stored as 'ls' inside g:fzf_history_dir. + " The name is ignored if g:fzf_history_dir is not defined. + command! -bang -complete=dir -nargs=* LS + \ call fzf#run(fzf#wrap('ls', {'source': 'ls', 'dir': }, 0)) +< + +TIPS *fzf-tips* +============================================================================== + + +< fzf inside terminal buffer >________________________________________________~ + *fzf-inside-terminal-buffer* + +The latest versions of Vim and Neovim include builtin terminal emulator +(`:terminal`) and fzf will start in a terminal buffer in the following cases: + + - On Neovim + - On GVim + - On Terminal Vim with a non-default layout + - `call fzf#run({'left': '30%'})` or `let g:fzf_layout = {'left': '30%'}` + + +Starting fzf in a popup window~ + *fzf-starting-fzf-in-a-popup-window* +> + " Required: + " - width [float range [0 ~ 1]] + " - height [float range [0 ~ 1]] + " + " Optional: + " - xoffset [float default 0.5 range [0 ~ 1]] + " - yoffset [float default 0.5 range [0 ~ 1]] + " - highlight [string default 'Comment']: Highlight group for border + " - border [string default 'rounded']: Border style + " - 'rounded' / 'sharp' / 'horizontal' / 'vertical' / 'top' / 'bottom' / 'left' / 'right' + let g:fzf_layout = { 'window': { 'width': 0.9, 'height': 0.6 } } +< +Alternatively, you can make fzf open in a tmux popup window (requires tmux 3.2 +or above) by putting fzf-tmux options in `tmux` key. +> + " See `man fzf-tmux` for available options + if exists('$TMUX') + let g:fzf_layout = { 'tmux': '-p90%,60%' } + else + let g:fzf_layout = { 'window': { 'width': 0.9, 'height': 0.6 } } + endif +< + +Hide statusline~ + *fzf-hide-statusline* + +When fzf starts in a terminal buffer, the file type of the buffer is set to +`fzf`. So you can set up `FileType fzf` autocmd to customize the settings of +the window. + +For example, if you use the default layout (`{'down': '~40%'}`) on Neovim, you +might want to temporarily disable the statusline for a cleaner look. +> + if has('nvim') && !exists('g:fzf_layout') + autocmd! FileType fzf + autocmd FileType fzf set laststatus=0 noshowmode noruler + \| autocmd BufLeave set laststatus=2 showmode ruler + endif +< + +LICENSE *fzf-license* +============================================================================== + +The MIT License (MIT) + +Copyright (c) 2013-2020 Junegunn Choi + +============================================================================== +vim:tw=78:sw=2:ts=2:ft=help:norl:nowrap: diff --git a/skel/.config/nvim/plugged/fzf/doc/tags b/skel/.config/nvim/plugged/fzf/doc/tags new file mode 100644 index 0000000..004b13d --- /dev/null +++ b/skel/.config/nvim/plugged/fzf/doc/tags @@ -0,0 +1,21 @@ +:FZF fzf.txt /*:FZF* +fzf fzf.txt /*fzf* +fzf#install fzf.txt /*fzf#install* +fzf#run fzf.txt /*fzf#run* +fzf#wrap fzf.txt /*fzf#wrap* +fzf-configuration fzf.txt /*fzf-configuration* +fzf-examples fzf.txt /*fzf-examples* +fzf-explanation-of-gfzfcolors fzf.txt /*fzf-explanation-of-gfzfcolors* +fzf-hide-statusline fzf.txt /*fzf-hide-statusline* +fzf-inside-terminal-buffer fzf.txt /*fzf-inside-terminal-buffer* +fzf-installation fzf.txt /*fzf-installation* +fzf-license fzf.txt /*fzf-license* +fzf-starting-fzf-in-a-popup-window fzf.txt /*fzf-starting-fzf-in-a-popup-window* +fzf-summary fzf.txt /*fzf-summary* +fzf-tips fzf.txt /*fzf-tips* +fzf-toc fzf.txt /*fzf-toc* +fzf-vim-integration fzf.txt /*fzf-vim-integration* +g:fzf_action fzf.txt /*g:fzf_action* +g:fzf_colors fzf.txt /*g:fzf_colors* +g:fzf_history_dir fzf.txt /*g:fzf_history_dir* +g:fzf_layout fzf.txt /*g:fzf_layout* diff --git a/skel/.config/nvim/plugged/fzf/man/man1/fzf-tmux.1 b/skel/.config/nvim/plugged/fzf/man/man1/fzf-tmux.1 new file mode 100644 index 0000000..525b895 --- /dev/null +++ b/skel/.config/nvim/plugged/fzf/man/man1/fzf-tmux.1 @@ -0,0 +1,68 @@ +.ig +The MIT License (MIT) + +Copyright (c) 2013-2020 Junegunn Choi + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +.. +.TH fzf-tmux 1 "Apr 2020" "fzf 0.21.1" "fzf-tmux - open fzf in tmux split pane" + +.SH NAME +fzf-tmux - open fzf in tmux split pane + +.SH SYNOPSIS +.B fzf-tmux [LAYOUT OPTIONS] [--] [FZF OPTIONS] + +.SH DESCRIPTION +fzf-tmux is a wrapper script for fzf that opens fzf in a tmux split pane or in +a tmux popup window. It is designed to work just like fzf except that it does +not take up the whole screen. You can safely use fzf-tmux instead of fzf in +your scripts as the extra options will be silently ignored if you're not on +tmux. + +.SH LAYOUT OPTIONS + +(default layout: \fB-d 50%\fR) + +.SS Popup window +(requires tmux 3.2 or above) +.TP +.B "-p [WIDTH[%][,HEIGHT[%]]]" +.TP +.B "-w WIDTH[%]" +.TP +.B "-h WIDTH[%]" +.TP +.B "-x COL" +.TP +.B "-y ROW" + +.SS Split pane +.TP +.B "-u [height[%]]" +Split above (up) +.TP +.B "-d [height[%]]" +Split below (down) +.TP +.B "-l [width[%]]" +Split left +.TP +.B "-r [width[%]]" +Split right diff --git a/skel/.config/nvim/plugged/fzf/man/man1/fzf.1 b/skel/.config/nvim/plugged/fzf/man/man1/fzf.1 new file mode 100644 index 0000000..3adf7f1 --- /dev/null +++ b/skel/.config/nvim/plugged/fzf/man/man1/fzf.1 @@ -0,0 +1,791 @@ +.ig +The MIT License (MIT) + +Copyright (c) 2013-2020 Junegunn Choi + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +.. +.TH fzf 1 "Apr 2020" "fzf 0.21.1" "fzf - a command-line fuzzy finder" + +.SH NAME +fzf - a command-line fuzzy finder + +.SH SYNOPSIS +fzf [options] + +.SH DESCRIPTION +fzf is a general-purpose command-line fuzzy finder. + +.SH OPTIONS +.SS Search mode +.TP +.B "-x, --extended" +Extended-search mode. Since 0.10.9, this is enabled by default. You can disable +it with \fB+x\fR or \fB--no-extended\fR. +.TP +.B "-e, --exact" +Enable exact-match +.TP +.B "-i" +Case-insensitive match (default: smart-case match) +.TP +.B "+i" +Case-sensitive match +.TP +.B "--literal" +Do not normalize latin script letters for matching. +.TP +.BI "--algo=" TYPE +Fuzzy matching algorithm (default: v2) + +.br +.BR v2 " Optimal scoring algorithm (quality)" +.br +.BR v1 " Faster but not guaranteed to find the optimal result (performance)" +.br + +.TP +.BI "-n, --nth=" "N[,..]" +Comma-separated list of field index expressions for limiting search scope. +See \fBFIELD INDEX EXPRESSION\fR for the details. +.TP +.BI "--with-nth=" "N[,..]" +Transform the presentation of each line using field index expressions +.TP +.BI "-d, --delimiter=" "STR" +Field delimiter regex for \fB--nth\fR and \fB--with-nth\fR (default: AWK-style) +.TP +.BI "--phony" +Do not perform search. With this option, fzf becomes a simple selector +interface rather than a "fuzzy finder". +.SS Search result +.TP +.B "+s, --no-sort" +Do not sort the result +.TP +.B "--tac" +Reverse the order of the input + +.RS +e.g. + \fBhistory | fzf --tac --no-sort\fR +.RE +.TP +.BI "--tiebreak=" "CRI[,..]" +Comma-separated list of sort criteria to apply when the scores are tied. +.br + +.br +.BR length " Prefers line with shorter length" +.br +.BR begin " Prefers line with matched substring closer to the beginning" +.br +.BR end " Prefers line with matched substring closer to the end" +.br +.BR index " Prefers line that appeared earlier in the input stream" +.br + +.br +- Each criterion should appear only once in the list +.br +- \fBindex\fR is only allowed at the end of the list +.br +- \fBindex\fR is implicitly appended to the list when not specified +.br +- Default is \fBlength\fR (or equivalently \fBlength\fR,index) +.br +- If \fBend\fR is found in the list, fzf will scan each line backwards +.SS Interface +.TP +.B "-m, --multi" +Enable multi-select with tab/shift-tab. It optionally takes an integer argument +which denotes the maximum number of items that can be selected. +.TP +.B "+m, --no-multi" +Disable multi-select +.TP +.B "--no-mouse" +Disable mouse +.TP +.BI "--bind=" "KEYBINDS" +Comma-separated list of custom key bindings. See \fBKEY/EVENT BINDINGS\fR for +the details. +.TP +.B "--cycle" +Enable cyclic scroll +.TP +.B "--keep-right" +Keep the right end of the line visible when it's too long. Effective only when +the query string is empty. +.TP +.B "--no-hscroll" +Disable horizontal scroll +.TP +.BI "--hscroll-off=" "COL" +Number of screen columns to keep to the right of the highlighted substring +(default: 10). Setting it to a large value will cause the text to be positioned +on the center of the screen. +.TP +.B "--filepath-word" +Make word-wise movements and actions respect path separators. The following +actions are affected: + +\fBbackward-kill-word\fR +.br +\fBbackward-word\fR +.br +\fBforward-word\fR +.br +\fBkill-word\fR +.TP +.BI "--jump-labels=" "CHARS" +Label characters for \fBjump\fR and \fBjump-accept\fR +.SS Layout +.TP +.BI "--height=" "HEIGHT[%]" +Display fzf window below the cursor with the given height instead of using +the full screen. +.TP +.BI "--min-height=" "HEIGHT" +Minimum height when \fB--height\fR is given in percent (default: 10). +Ignored when \fB--height\fR is not specified. +.TP +.BI "--layout=" "LAYOUT" +Choose the layout (default: default) + +.br +.BR default " Display from the bottom of the screen" +.br +.BR reverse " Display from the top of the screen" +.br +.BR reverse-list " Display from the top of the screen, prompt at the bottom" +.br + +.TP +.B "--reverse" +A synonym for \fB--layout=reverse\fB + +.TP +.BI "--border" [=STYLE] +Draw border around the finder + +.br +.BR rounded " Border with rounded corners (default)" +.br +.BR sharp " Border with sharp corners" +.br +.BR horizontal " Horizontal lines above and below the finder" +.br + +.TP +.B "--no-unicode" +Use ASCII characters instead of Unicode box drawing characters to draw border + +.TP +.BI "--margin=" MARGIN +Comma-separated expression for margins around the finder. +.br + +.br +.RS +.BR TRBL " Same margin for top, right, bottom, and left" +.br +.BR TB,RL " Vertical, horizontal margin" +.br +.BR T,RL,B " Top, horizontal, bottom margin" +.br +.BR T,R,B,L " Top, right, bottom, left margin" +.br + +.br +Each part can be given in absolute number or in percentage relative to the +terminal size with \fB%\fR suffix. +.br + +.br +e.g. + \fBfzf --margin 10% + fzf --margin 1,5%\fR +.RE +.TP +.BI "--info=" "STYLE" +Determines the display style of finder info. + +.br +.BR default " Display on the next line to the prompt" +.br +.BR inline " Display on the same line" +.br +.BR hidden " Do not display finder info" +.br + +.TP +.B "--no-info" +A synonym for \fB--info=hidden\fB + +.TP +.BI "--prompt=" "STR" +Input prompt (default: '> ') +.TP +.BI "--pointer=" "STR" +Pointer to the current line (default: '>') +.TP +.BI "--marker=" "STR" +Multi-select marker (default: '>') +.TP +.BI "--header=" "STR" +The given string will be printed as the sticky header. The lines are displayed +in the given order from top to bottom regardless of \fB--layout\fR option, and +are not affected by \fB--with-nth\fR. ANSI color codes are processed even when +\fB--ansi\fR is not set. +.TP +.BI "--header-lines=" "N" +The first N lines of the input are treated as the sticky header. When +\fB--with-nth\fR is set, the lines are transformed just like the other +lines that follow. +.SS Display +.TP +.B "--ansi" +Enable processing of ANSI color codes +.TP +.BI "--tabstop=" SPACES +Number of spaces for a tab character (default: 8) +.TP +.BI "--color=" "[BASE_SCHEME][,COLOR:ANSI]" +Color configuration. The name of the base color scheme is followed by custom +color mappings. Ansi color code of -1 denotes terminal default +foreground/background color. You can also specify 24-bit color in \fB#rrggbb\fR +format. + +.RS +.B BASE SCHEME: + (default: dark on 256-color terminal, otherwise 16) + + \fBdark \fRColor scheme for dark 256-color terminal + \fBlight \fRColor scheme for light 256-color terminal + \fB16 \fRColor scheme for 16-color terminal + \fBbw \fRNo colors (equivalent to \fB--no-color\fR) + +.B COLOR: + \fBfg \fRText + \fBbg \fRBackground + \fBpreview-fg \fRPreview window text + \fBpreview-bg \fRPreview window background + \fBhl \fRHighlighted substrings + \fBfg+ \fRText (current line) + \fBbg+ \fRBackground (current line) + \fBgutter \fRGutter on the left (defaults to \fBbg+\fR) + \fBhl+ \fRHighlighted substrings (current line) + \fBinfo \fRInfo line (match counters) + \fBborder \fRBorder around the window (\fB--border\fR and \fB--preview\fR) + \fBprompt \fRPrompt + \fBpointer \fRPointer to the current line + \fBmarker \fRMulti-select marker + \fBspinner \fRStreaming input indicator + \fBheader \fRHeader + +.B EXAMPLES: + + \fB# Seoul256 theme with 8-bit colors + # (https://github.com/junegunn/seoul256.vim) + fzf --color='bg:237,bg+:236,info:143,border:240,spinner:108' \\ + --color='hl:65,fg:252,header:65,fg+:252' \\ + --color='pointer:161,marker:168,prompt:110,hl+:108' + + # Seoul256 theme with 24-bit colors + fzf --color='bg:#4B4B4B,bg+:#3F3F3F,info:#BDBB72,border:#6B6B6B,spinner:#98BC99' \\ + --color='hl:#719872,fg:#D9D9D9,header:#719872,fg+:#D9D9D9' \\ + --color='pointer:#E12672,marker:#E17899,prompt:#98BEDE,hl+:#98BC99'\fR +.RE +.TP +.B "--no-bold" +Do not use bold text +.TP +.B "--black" +Use black background +.SS History +.TP +.BI "--history=" "HISTORY_FILE" +Load search history from the specified file and update the file on completion. +When enabled, \fBCTRL-N\fR and \fBCTRL-P\fR are automatically remapped to +\fBnext-history\fR and \fBprevious-history\fR. +.TP +.BI "--history-size=" "N" +Maximum number of entries in the history file (default: 1000). The file is +automatically truncated when the number of the lines exceeds the value. +.SS Preview +.TP +.BI "--preview=" "COMMAND" +Execute the given command for the current line and display the result on the +preview window. \fB{}\fR in the command is the placeholder that is replaced to +the single-quoted string of the current line. To transform the replacement +string, specify field index expressions between the braces (See \fBFIELD INDEX +EXPRESSION\fR for the details). + +.RS +e.g. + \fBfzf --preview='head -$LINES {}' + ls -l | fzf --preview="echo user={3} when={-4..-2}; cat {-1}" --header-lines=1\fR + +fzf exports \fB$FZF_PREVIEW_LINES\fR and \fB$FZF_PREVIEW_COLUMNS\fR so that +they represent the exact size of the preview window. (It also overrides +\fB$LINES\fR and \fB$COLUMNS\fR with the same values but they can be reset +by the default shell, so prefer to refer to the ones with \fBFZF_PREVIEW_\fR +prefix.) + +A placeholder expression starting with \fB+\fR flag will be replaced to the +space-separated list of the selected lines (or the current line if no selection +was made) individually quoted. + +e.g. + \fBfzf --multi --preview='head -10 {+}' + git log --oneline | fzf --multi --preview 'git show {+1}'\fR + +When using a field index expression, leading and trailing whitespace is stripped +from the replacement string. To preserve the whitespace, use the \fBs\fR flag. + +Also, \fB{q}\fR is replaced to the current query string, and \fB{n}\fR is +replaced to zero-based ordinal index of the line. Use \fB{+n}\fR if you want +all index numbers when multiple lines are selected. + +A placeholder expression with \fBf\fR flag is replaced to the path of +a temporary file that holds the evaluated list. This is useful when you +multi-select a large number of items and the length of the evaluated string may +exceed \fBARG_MAX\fR. + +e.g. + \fB# Press CTRL-A to select 100K items and see the sum of all the numbers. + # This won't work properly without 'f' flag due to ARG_MAX limit. + seq 100000 | fzf --multi --bind ctrl-a:select-all \\ + --preview "awk '{sum+=\$1} END {print sum}' {+f}"\fR + +Note that you can escape a placeholder pattern by prepending a backslash. + +Preview window will be updated even when there is no match for the current +query if any of the placeholder expressions evaluates to a non-empty string. +.RE +.TP +.BI "--preview-window=" "[POSITION][:SIZE[%]][:noborder][:wrap][:hidden]" +Determines the layout of the preview window. If the argument contains +\fB:hidden\fR, the preview window will be hidden by default until +\fBtoggle-preview\fR action is triggered. Long lines are truncated by default. +Line wrap can be enabled with \fB:wrap\fR flag. + +If size is given as 0, preview window will not be visible, but fzf will still +execute the command in the background. + +.RS +.B POSITION: (default: right) + \fBup + \fBdown + \fBleft + \fBright +.RE + +.RS +e.g. + \fBfzf --preview="head {}" --preview-window=up:30% + fzf --preview="file {}" --preview-window=down:1\fR +.RE +.SS Scripting +.TP +.BI "-q, --query=" "STR" +Start the finder with the given query +.TP +.B "-1, --select-1" +Automatically select the only match +.TP +.B "-0, --exit-0" +Exit immediately when there's no match +.TP +.BI "-f, --filter=" "STR" +Filter mode. Do not start interactive finder. When used with \fB--no-sort\fR, +fzf becomes a fuzzy-version of grep. +.TP +.B "--print-query" +Print query as the first line +.TP +.BI "--expect=" "KEY[,..]" +Comma-separated list of keys that can be used to complete fzf in addition to +the default enter key. When this option is set, fzf will print the name of the +key pressed as the first line of its output (or as the second line if +\fB--print-query\fR is also used). The line will be empty if fzf is completed +with the default enter key. If \fB--expect\fR option is specified multiple +times, fzf will expect the union of the keys. \fB--no-expect\fR will clear the +list. + +.RS +e.g. + \fBfzf --expect=ctrl-v,ctrl-t,alt-s --expect=f1,f2,~,@\fR +.RE +.TP +.B "--read0" +Read input delimited by ASCII NUL characters instead of newline characters +.TP +.B "--print0" +Print output delimited by ASCII NUL characters instead of newline characters +.TP +.B "--no-clear" +Do not clear finder interface on exit. If fzf was started in full screen mode, +it will not switch back to the original screen, so you'll have to manually run +\fBtput rmcup\fR to return. This option can be used to avoid flickering of the +screen when your application needs to start fzf multiple times in order. +.TP +.B "--sync" +Synchronous search for multi-staged filtering. If specified, fzf will launch +ncurses finder only after the input stream is complete. + +.RS +e.g. \fBfzf --multi | fzf --sync\fR +.RE +.TP +.B "--version" +Display version information and exit + +.TP +Note that most options have the opposite versions with \fB--no-\fR prefix. + +.SH ENVIRONMENT VARIABLES +.TP +.B FZF_DEFAULT_COMMAND +Default command to use when input is tty. On *nix systems, fzf runs the command +with \fBsh -c\fR, so make sure that it's POSIX-compliant. +.TP +.B FZF_DEFAULT_OPTS +Default options. e.g. \fBexport FZF_DEFAULT_OPTS="--extended --cycle"\fR + +.SH EXIT STATUS +.BR 0 " Normal exit" +.br +.BR 1 " No match" +.br +.BR 2 " Error" +.br +.BR 130 " Interrupted with \fBCTRL-C\fR or \fBESC\fR" + +.SH FIELD INDEX EXPRESSION + +A field index expression can be a non-zero integer or a range expression +([BEGIN]..[END]). \fB--nth\fR and \fB--with-nth\fR take a comma-separated list +of field index expressions. + +.SS Examples +.BR 1 " The 1st field" +.br +.BR 2 " The 2nd field" +.br +.BR -1 " The last field" +.br +.BR -2 " The 2nd to last field" +.br +.BR 3..5 " From the 3rd field to the 5th field" +.br +.BR 2.. " From the 2nd field to the last field" +.br +.BR ..-3 " From the 1st field to the 3rd to the last field" +.br +.BR .. " All the fields" +.br + +.SH EXTENDED SEARCH MODE + +Unless specified otherwise, fzf will start in "extended-search mode". In this +mode, you can specify multiple patterns delimited by spaces, such as: \fB'wild +^music .mp3$ sbtrkt !rmx\fR + +You can prepend a backslash to a space (\fB\\ \fR) to match a literal space +character. + +.SS Exact-match (quoted) +A term that is prefixed by a single-quote character (\fB'\fR) is interpreted as +an "exact-match" (or "non-fuzzy") term. fzf will search for the exact +occurrences of the string. + +.SS Anchored-match +A term can be prefixed by \fB^\fR, or suffixed by \fB$\fR to become an +anchored-match term. Then fzf will search for the lines that start with or end +with the given string. An anchored-match term is also an exact-match term. + +.SS Negation +If a term is prefixed by \fB!\fR, fzf will exclude the lines that satisfy the +term from the result. In this case, fzf performs exact match by default. + +.SS Exact-match by default +If you don't prefer fuzzy matching and do not wish to "quote" (prefixing with +\fB'\fR) every word, start fzf with \fB-e\fR or \fB--exact\fR option. Note that +when \fB--exact\fR is set, \fB'\fR-prefix "unquotes" the term. + +.SS OR operator +A single bar character term acts as an OR operator. For example, the following +query matches entries that start with \fBcore\fR and end with either \fBgo\fR, +\fBrb\fR, or \fBpy\fR. + +e.g. \fB^core go$ | rb$ | py$\fR + +.SH KEY/EVENT BINDINGS +\fB--bind\fR option allows you to bind \fBa key\fR or \fBan event\fR to one or +more \fBactions\fR. You can use it to customize key bindings or implement +dynamic behaviors. + +\fB--bind\fR takes a comma-separated list of binding expressions. Each binding +expression is \fBKEY:ACTION\fR or \fBEVENT:ACTION\fR. + +e.g. + \fBfzf --bind=ctrl-j:accept,ctrl-k:kill-line\fR + +.SS AVAILABLE KEYS: (SYNONYMS) +\fIctrl-[a-z]\fR +.br +\fIctrl-space\fR +.br +\fIctrl-\\\fR +.br +\fIctrl-]\fR +.br +\fIctrl-^\fR (\fIctrl-6\fR) +.br +\fIctrl-/\fR (\fIctrl-_\fR) +.br +\fIctrl-alt-[a-z]\fR +.br +\fIalt-[a-z]\fR +.br +\fIalt-[0-9]\fR +.br +\fIf[1-12]\fR +.br +\fIenter\fR (\fIreturn\fR \fIctrl-m\fR) +.br +\fIspace\fR +.br +\fIbspace\fR (\fIbs\fR) +.br +\fIalt-up\fR +.br +\fIalt-down\fR +.br +\fIalt-left\fR +.br +\fIalt-right\fR +.br +\fIalt-enter\fR +.br +\fIalt-space\fR +.br +\fIalt-bspace\fR (\fIalt-bs\fR) +.br +\fIalt-/\fR +.br +\fItab\fR +.br +\fIbtab\fR (\fIshift-tab\fR) +.br +\fIesc\fR +.br +\fIdel\fR +.br +\fIup\fR +.br +\fIdown\fR +.br +\fIleft\fR +.br +\fIright\fR +.br +\fIhome\fR +.br +\fIend\fR +.br +\fIinsert\fR +.br +\fIpgup\fR (\fIpage-up\fR) +.br +\fIpgdn\fR (\fIpage-down\fR) +.br +\fIshift-up\fR +.br +\fIshift-down\fR +.br +\fIshift-left\fR +.br +\fIshift-right\fR +.br +\fIleft-click\fR +.br +\fIright-click\fR +.br +\fIdouble-click\fR +.br +or any single character + +.SS AVAILABLE EVENTS: +\fIchange\fR (triggered whenever the query string is changed) +.br + + e.g. + \fB# Moves cursor to the top (or bottom depending on --layout) whenever the query is changed + fzf --bind change:top\fR + +.SS AVAILABLE ACTIONS: +A key or an event can be bound to one or more of the following actions. + + \fBACTION: DEFAULT BINDINGS (NOTES): + \fBabort\fR \fIctrl-c ctrl-g ctrl-q esc\fR + \fBaccept\fR \fIenter double-click\fR + \fBaccept-non-empty\fR (same as \fBaccept\fR except that it prevents fzf from exiting without selection) + \fBbackward-char\fR \fIctrl-b left\fR + \fBbackward-delete-char\fR \fIctrl-h bspace\fR + \fBbackward-delete-char/eof\fR (same as \fBbackward-delete-char\fR except aborts fzf if query is empty) + \fBbackward-kill-word\fR \fIalt-bs\fR + \fBbackward-word\fR \fIalt-b shift-left\fR + \fBbeginning-of-line\fR \fIctrl-a home\fR + \fBcancel\fR (clear query string if not empty, abort fzf otherwise) + \fBclear-screen\fR \fIctrl-l\fR + \fBclear-selection\fR (clear multi-selection) + \fBclear-query\fR (clear query string) + \fBdelete-char\fR \fIdel\fR + \fBdelete-char/eof\fR \fIctrl-d\fR (same as \fBdelete-char\fR except aborts fzf if query is empty) + \fBdeselect-all\fR (deselect all matches) + \fBdown\fR \fIctrl-j ctrl-n down\fR + \fBend-of-line\fR \fIctrl-e end\fR + \fBexecute(...)\fR (see below for the details) + \fBexecute-silent(...)\fR (see below for the details) + \fRexecute-multi(...)\fR (deprecated in favor of \fB{+}\fR expression) + \fBforward-char\fR \fIctrl-f right\fR + \fBforward-word\fR \fIalt-f shift-right\fR + \fBignore\fR + \fBjump\fR (EasyMotion-like 2-keystroke movement) + \fBjump-accept\fR (jump and accept) + \fBkill-line\fR + \fBkill-word\fR \fIalt-d\fR + \fBnext-history\fR (\fIctrl-n\fR on \fB--history\fR) + \fBpage-down\fR \fIpgdn\fR + \fBpage-up\fR \fIpgup\fR + \fBhalf-page-down\fR + \fBhalf-page-up\fR + \fBpreview-down\fR \fIshift-down\fR + \fBpreview-up\fR \fIshift-up\fR + \fBpreview-page-down\fR + \fBpreview-page-up\fR + \fBprevious-history\fR (\fIctrl-p\fR on \fB--history\fR) + \fBprint-query\fR (print query and exit) + \fBreload(...)\fR (see below for the details) + \fBreplace-query\fR (replace query string with the current selection) + \fBselect-all\fR (select all matches) + \fBtoggle\fR (\fIright-click\fR) + \fBtoggle-all\fR (toggle all matches) + \fBtoggle+down\fR \fIctrl-i (tab)\fR + \fBtoggle-in\fR (\fB--layout=reverse*\fR ? \fBtoggle+up\fR : \fBtoggle+down\fR) + \fBtoggle-out\fR (\fB--layout=reverse*\fR ? \fBtoggle+down\fR : \fBtoggle+up\fR) + \fBtoggle-preview\fR + \fBtoggle-preview-wrap\fR + \fBtoggle-sort\fR + \fBtoggle+up\fR \fIbtab (shift-tab)\fR + \fBtop\fR (move to the top result) + \fBunix-line-discard\fR \fIctrl-u\fR + \fBunix-word-rubout\fR \fIctrl-w\fR + \fBup\fR \fIctrl-k ctrl-p up\fR + \fByank\fR \fIctrl-y\fR + +.SS ACTION COMPOSITION + +Multiple actions can be chained using \fB+\fR separator. + +e.g. + \fBfzf --bind 'ctrl-a:select-all+accept'\fR + +.SS COMMAND EXECUTION + +With \fBexecute(...)\fR action, you can execute arbitrary commands without +leaving fzf. For example, you can turn fzf into a simple file browser by +binding \fBenter\fR key to \fBless\fR command like follows. + + \fBfzf --bind "enter:execute(less {})"\fR + +You can use the same placeholder expressions as in \fB--preview\fR. + +If the command contains parentheses, fzf may fail to parse the expression. In +that case, you can use any of the following alternative notations to avoid +parse errors. + + \fBexecute[...]\fR + \fBexecute~...~\fR + \fBexecute!...!\fR + \fBexecute@...@\fR + \fBexecute#...#\fR + \fBexecute$...$\fR + \fBexecute%...%\fR + \fBexecute^...^\fR + \fBexecute&...&\fR + \fBexecute*...*\fR + \fBexecute;...;\fR + \fBexecute/.../\fR + \fBexecute|...|\fR + \fBexecute:...\fR +.RS +The last one is the special form that frees you from parse errors as it does +not expect the closing character. The catch is that it should be the last one +in the comma-separated list of key-action pairs. +.RE + +fzf switches to the alternate screen when executing a command. However, if the +command is expected to complete quickly, and you are not interested in its +output, you might want to use \fBexecute-silent\fR instead, which silently +executes the command without the switching. Note that fzf will not be +responsive until the command is complete. For asynchronous execution, start +your command as a background process (i.e. appending \fB&\fR). + +.SS RELOAD INPUT + +\fBreload(...)\fR action is used to dynamically update the input list +without restarting fzf. It takes the same command template with placeholder +expressions as \fBexecute(...)\fR. + +See \fIhttps://github.com/junegunn/fzf/issues/1750\fR for more info. + +e.g. + \fB# Update the list of processes by pressing CTRL-R + ps -ef | fzf --bind 'ctrl-r:reload(ps -ef)' --header 'Press CTRL-R to reload' \\ + --header-lines=1 --layout=reverse + + # Integration with ripgrep + RG_PREFIX="rg --column --line-number --no-heading --color=always --smart-case " + INITIAL_QUERY="foobar" + FZF_DEFAULT_COMMAND="$RG_PREFIX '$INITIAL_QUERY'" \\ + fzf --bind "change:reload:$RG_PREFIX {q} || true" \\ + --ansi --phony --query "$INITIAL_QUERY"\fR + +.SH AUTHOR +Junegunn Choi (\fIjunegunn.c@gmail.com\fR) + +.SH SEE ALSO +.B Project homepage: +.RS +.I https://github.com/junegunn/fzf +.RE +.br + +.br +.B Extra Vim plugin: +.RS +.I https://github.com/junegunn/fzf.vim +.RE + +.SH LICENSE +MIT diff --git a/skel/.config/nvim/plugged/fzf/plugin/fzf.vim b/skel/.config/nvim/plugged/fzf/plugin/fzf.vim new file mode 100644 index 0000000..06ef99a --- /dev/null +++ b/skel/.config/nvim/plugged/fzf/plugin/fzf.vim @@ -0,0 +1,949 @@ +" Copyright (c) 2017 Junegunn Choi +" +" MIT License +" +" Permission is hereby granted, free of charge, to any person obtaining +" a copy of this software and associated documentation files (the +" "Software"), to deal in the Software without restriction, including +" without limitation the rights to use, copy, modify, merge, publish, +" distribute, sublicense, and/or sell copies of the Software, and to +" permit persons to whom the Software is furnished to do so, subject to +" the following conditions: +" +" The above copyright notice and this permission notice shall be +" included in all copies or substantial portions of the Software. +" +" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +" EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +" NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +" LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +" OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +" WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +if exists('g:loaded_fzf') + finish +endif +let g:loaded_fzf = 1 + +let s:is_win = has('win32') || has('win64') +if s:is_win && &shellslash + set noshellslash + let s:base_dir = expand(':h:h') + set shellslash +else + let s:base_dir = expand(':h:h') +endif +if s:is_win + let s:term_marker = '&::FZF' + + function! s:fzf_call(fn, ...) + let shellslash = &shellslash + try + set noshellslash + return call(a:fn, a:000) + finally + let &shellslash = shellslash + endtry + endfunction + + " Use utf-8 for fzf.vim commands + " Return array of shell commands for cmd.exe + function! s:enc_to_cp(str) + if !has('iconv') + return a:str + endif + if !exists('s:codepage') + let s:codepage = libcallnr('kernel32.dll', 'GetACP', 0) + endif + return iconv(a:str, &encoding, 'cp'.s:codepage) + endfunction + function! s:wrap_cmds(cmds) + return map([ + \ '@echo off', + \ 'setlocal enabledelayedexpansion'] + \ + (has('gui_running') ? ['set TERM= > nul'] : []) + \ + (type(a:cmds) == type([]) ? a:cmds : [a:cmds]) + \ + ['endlocal'], + \ 'enc_to_cp(v:val."\r")') + endfunction +else + let s:term_marker = ";#FZF" + + function! s:fzf_call(fn, ...) + return call(a:fn, a:000) + endfunction + + function! s:wrap_cmds(cmds) + return a:cmds + endfunction + + function! s:enc_to_cp(str) + return a:str + endfunction +endif + +function! s:shellesc_cmd(arg) + let escaped = substitute(a:arg, '[&|<>()@^]', '^&', 'g') + let escaped = substitute(escaped, '%', '%%', 'g') + let escaped = substitute(escaped, '"', '\\^&', 'g') + let escaped = substitute(escaped, '\(\\\+\)\(\\^\)', '\1\1\2', 'g') + return '^"'.substitute(escaped, '\(\\\+\)$', '\1\1', '').'^"' +endfunction + +function! fzf#shellescape(arg, ...) + let shell = get(a:000, 0, s:is_win ? 'cmd.exe' : 'sh') + if shell =~# 'cmd.exe$' + return s:shellesc_cmd(a:arg) + endif + return s:fzf_call('shellescape', a:arg) +endfunction + +function! s:fzf_getcwd() + return s:fzf_call('getcwd') +endfunction + +function! s:fzf_fnamemodify(fname, mods) + return s:fzf_call('fnamemodify', a:fname, a:mods) +endfunction + +function! s:fzf_expand(fmt) + return s:fzf_call('expand', a:fmt, 1) +endfunction + +function! s:fzf_tempname() + return s:fzf_call('tempname') +endfunction + +let s:default_layout = { 'down': '~40%' } +let s:layout_keys = ['window', 'tmux', 'up', 'down', 'left', 'right'] +let s:fzf_go = s:base_dir.'/bin/fzf' +let s:fzf_tmux = s:base_dir.'/bin/fzf-tmux' + +let s:cpo_save = &cpo +set cpo&vim + +function! fzf#install() + if s:is_win && !has('win32unix') + let script = s:base_dir.'/install.ps1' + if !filereadable(script) + throw script.' not found' + endif + let script = 'powershell -ExecutionPolicy Bypass -file ' . script + else + let script = s:base_dir.'/install' + if !executable(script) + throw script.' not found' + endif + let script .= ' --bin' + endif + + call s:warn('Running fzf installer ...') + call system(script) + if v:shell_error + throw 'Failed to download fzf: '.script + endif +endfunction + +function! s:fzf_exec() + if !exists('s:exec') + if executable(s:fzf_go) + let s:exec = s:fzf_go + elseif executable('fzf') + let s:exec = 'fzf' + elseif input('fzf executable not found. Download binary? (y/n) ') =~? '^y' + redraw + call fzf#install() + return s:fzf_exec() + else + redraw + throw 'fzf executable not found' + endif + endif + return fzf#shellescape(s:exec) +endfunction + +function! s:tmux_enabled() + if has('gui_running') || !exists('$TMUX') + return 0 + endif + + if exists('s:tmux') + return s:tmux + endif + + let s:tmux = 0 + if !executable(s:fzf_tmux) + if executable('fzf-tmux') + let s:fzf_tmux = 'fzf-tmux' + else + return 0 + endif + endif + + let output = system('tmux -V') + let s:tmux = !v:shell_error && output >= 'tmux 1.7' + return s:tmux +endfunction + +function! s:escape(path) + let path = fnameescape(a:path) + return s:is_win ? escape(path, '$') : path +endfunction + +function! s:error(msg) + echohl ErrorMsg + echom a:msg + echohl None +endfunction + +function! s:warn(msg) + echohl WarningMsg + echom a:msg + echohl None +endfunction + +function! s:has_any(dict, keys) + for key in a:keys + if has_key(a:dict, key) + return 1 + endif + endfor + return 0 +endfunction + +function! s:open(cmd, target) + if stridx('edit', a:cmd) == 0 && s:fzf_fnamemodify(a:target, ':p') ==# s:fzf_expand('%:p') + return + endif + execute a:cmd s:escape(a:target) +endfunction + +function! s:common_sink(action, lines) abort + if len(a:lines) < 2 + return + endif + let key = remove(a:lines, 0) + let Cmd = get(a:action, key, 'e') + if type(Cmd) == type(function('call')) + return Cmd(a:lines) + endif + if len(a:lines) > 1 + augroup fzf_swap + autocmd SwapExists * let v:swapchoice='o' + \| call s:warn('fzf: E325: swap file exists: '.s:fzf_expand('')) + augroup END + endif + try + let empty = empty(s:fzf_expand('%')) && line('$') == 1 && empty(getline(1)) && !&modified + let autochdir = &autochdir + set noautochdir + for item in a:lines + if empty + execute 'e' s:escape(item) + let empty = 0 + else + call s:open(Cmd, item) + endif + if !has('patch-8.0.0177') && !has('nvim-0.2') && exists('#BufEnter') + \ && isdirectory(item) + doautocmd BufEnter + endif + endfor + catch /^Vim:Interrupt$/ + finally + let &autochdir = autochdir + silent! autocmd! fzf_swap + endtry +endfunction + +function! s:get_color(attr, ...) + let gui = !s:is_win && !has('win32unix') && has('termguicolors') && &termguicolors + let fam = gui ? 'gui' : 'cterm' + let pat = gui ? '^#[a-f0-9]\+' : '^[0-9]\+$' + for group in a:000 + let code = synIDattr(synIDtrans(hlID(group)), a:attr, fam) + if code =~? pat + return code + endif + endfor + return '' +endfunction + +function! s:defaults() + let rules = copy(get(g:, 'fzf_colors', {})) + let colors = join(map(items(filter(map(rules, 'call("s:get_color", v:val)'), '!empty(v:val)')), 'join(v:val, ":")'), ',') + return empty(colors) ? '' : fzf#shellescape('--color='.colors) +endfunction + +function! s:validate_layout(layout) + for key in keys(a:layout) + if index(s:layout_keys, key) < 0 + throw printf('Invalid entry in g:fzf_layout: %s (allowed: %s)%s', + \ key, join(s:layout_keys, ', '), key == 'options' ? '. Use $FZF_DEFAULT_OPTS.' : '') + endif + endfor + return a:layout +endfunction + +function! s:evaluate_opts(options) + return type(a:options) == type([]) ? + \ join(map(copy(a:options), 'fzf#shellescape(v:val)')) : a:options +endfunction + +" [name string,] [opts dict,] [fullscreen boolean] +function! fzf#wrap(...) + let args = ['', {}, 0] + let expects = map(copy(args), 'type(v:val)') + let tidx = 0 + for arg in copy(a:000) + let tidx = index(expects, type(arg), tidx) + if tidx < 0 + throw 'Invalid arguments (expected: [name string] [opts dict] [fullscreen boolean])' + endif + let args[tidx] = arg + let tidx += 1 + unlet arg + endfor + let [name, opts, bang] = args + + if len(name) + let opts.name = name + end + + " Layout: g:fzf_layout (and deprecated g:fzf_height) + if bang + for key in s:layout_keys + if has_key(opts, key) + call remove(opts, key) + endif + endfor + elseif !s:has_any(opts, s:layout_keys) + if !exists('g:fzf_layout') && exists('g:fzf_height') + let opts.down = g:fzf_height + else + let opts = extend(opts, s:validate_layout(get(g:, 'fzf_layout', s:default_layout))) + endif + endif + + " Colors: g:fzf_colors + let opts.options = s:defaults() .' '. s:evaluate_opts(get(opts, 'options', '')) + + " History: g:fzf_history_dir + if len(name) && len(get(g:, 'fzf_history_dir', '')) + let dir = s:fzf_expand(g:fzf_history_dir) + if !isdirectory(dir) + call mkdir(dir, 'p') + endif + let history = fzf#shellescape(dir.'/'.name) + let opts.options = join(['--history', history, opts.options]) + endif + + " Action: g:fzf_action + if !s:has_any(opts, ['sink', 'sink*']) + let opts._action = get(g:, 'fzf_action', s:default_action) + let opts.options .= ' --expect='.join(keys(opts._action), ',') + function! opts.sink(lines) abort + return s:common_sink(self._action, a:lines) + endfunction + let opts['sink*'] = remove(opts, 'sink') + endif + + return opts +endfunction + +function! s:use_sh() + let [shell, shellslash, shellcmdflag, shellxquote] = [&shell, &shellslash, &shellcmdflag, &shellxquote] + if s:is_win + set shell=cmd.exe + set noshellslash + let &shellcmdflag = has('nvim') ? '/s /c' : '/c' + let &shellxquote = has('nvim') ? '"' : '(' + else + set shell=sh + endif + return [shell, shellslash, shellcmdflag, shellxquote] +endfunction + +function! fzf#run(...) abort +try + let [shell, shellslash, shellcmdflag, shellxquote] = s:use_sh() + + let dict = exists('a:1') ? copy(a:1) : {} + let temps = { 'result': s:fzf_tempname() } + let optstr = s:evaluate_opts(get(dict, 'options', '')) + try + let fzf_exec = s:fzf_exec() + catch + throw v:exception + endtry + + if !has_key(dict, 'dir') + let dict.dir = s:fzf_getcwd() + endif + if has('win32unix') && has_key(dict, 'dir') + let dict.dir = fnamemodify(dict.dir, ':p') + endif + + if has_key(dict, 'source') + let source = dict.source + let type = type(source) + if type == 1 + let prefix = '( '.source.' )|' + elseif type == 3 + let temps.input = s:fzf_tempname() + call writefile(map(source, 'enc_to_cp(v:val)'), temps.input) + let prefix = (s:is_win ? 'type ' : 'cat ').fzf#shellescape(temps.input).'|' + else + throw 'Invalid source type' + endif + else + let prefix = '' + endif + + let prefer_tmux = get(g:, 'fzf_prefer_tmux', 0) || has_key(dict, 'tmux') + let use_height = has_key(dict, 'down') && !has('gui_running') && + \ !(has('nvim') || s:is_win || has('win32unix') || s:present(dict, 'up', 'left', 'right', 'window')) && + \ executable('tput') && filereadable('/dev/tty') + let has_vim8_term = has('terminal') && has('patch-8.0.995') + let has_nvim_term = has('nvim-0.2.1') || has('nvim') && !s:is_win + let use_term = has_nvim_term || + \ has_vim8_term && !has('win32unix') && (has('gui_running') || s:is_win || !use_height && s:present(dict, 'down', 'up', 'left', 'right', 'window')) + let use_tmux = (has_key(dict, 'tmux') || (!use_height && !use_term || prefer_tmux) && !has('win32unix') && s:splittable(dict)) && s:tmux_enabled() + if prefer_tmux && use_tmux + let use_height = 0 + let use_term = 0 + endif + if use_height + let height = s:calc_size(&lines, dict.down, dict) + let optstr .= ' --height='.height + elseif use_term + let optstr .= ' --no-height' + endif + let command = prefix.(use_tmux ? s:fzf_tmux(dict) : fzf_exec).' '.optstr.' > '.temps.result + + if use_term + return s:execute_term(dict, command, temps) + endif + + let lines = use_tmux ? s:execute_tmux(dict, command, temps) + \ : s:execute(dict, command, use_height, temps) + call s:callback(dict, lines) + return lines +finally + let [&shell, &shellslash, &shellcmdflag, &shellxquote] = [shell, shellslash, shellcmdflag, shellxquote] +endtry +endfunction + +function! s:present(dict, ...) + for key in a:000 + if !empty(get(a:dict, key, '')) + return 1 + endif + endfor + return 0 +endfunction + +function! s:fzf_tmux(dict) + let size = get(a:dict, 'tmux', '') + if empty(size) + for o in ['up', 'down', 'left', 'right'] + if s:present(a:dict, o) + let spec = a:dict[o] + if (o == 'up' || o == 'down') && spec[0] == '~' + let size = '-'.o[0].s:calc_size(&lines, spec, a:dict) + else + " Legacy boolean option + let size = '-'.o[0].(spec == 1 ? '' : substitute(spec, '^\~', '', '')) + endif + break + endif + endfor + endif + return printf('LINES=%d COLUMNS=%d %s %s %s --', + \ &lines, &columns, fzf#shellescape(s:fzf_tmux), size, (has_key(a:dict, 'source') ? '' : '-')) +endfunction + +function! s:splittable(dict) + return s:present(a:dict, 'up', 'down') && &lines > 15 || + \ s:present(a:dict, 'left', 'right') && &columns > 40 +endfunction + +function! s:pushd(dict) + if s:present(a:dict, 'dir') + let cwd = s:fzf_getcwd() + let w:fzf_pushd = { + \ 'command': haslocaldir() ? 'lcd' : (exists(':tcd') && haslocaldir(-1) ? 'tcd' : 'cd'), + \ 'origin': cwd, + \ 'bufname': bufname('') + \ } + execute 'lcd' s:escape(a:dict.dir) + let cwd = s:fzf_getcwd() + let w:fzf_pushd.dir = cwd + let a:dict.pushd = w:fzf_pushd + return cwd + endif + return '' +endfunction + +augroup fzf_popd + autocmd! + autocmd WinEnter * call s:dopopd() +augroup END + +function! s:dopopd() + if !exists('w:fzf_pushd') + return + endif + + " FIXME: We temporarily change the working directory to 'dir' entry + " of options dictionary (set to the current working directory if not given) + " before running fzf. + " + " e.g. call fzf#run({'dir': '/tmp', 'source': 'ls', 'sink': 'e'}) + " + " After processing the sink function, we have to restore the current working + " directory. But doing so may not be desirable if the function changed the + " working directory on purpose. + " + " So how can we tell if we should do it or not? A simple heuristic we use + " here is that we change directory only if the current working directory + " matches 'dir' entry. However, it is possible that the sink function did + " change the directory to 'dir'. In that case, the user will have an + " unexpected result. + if s:fzf_getcwd() ==# w:fzf_pushd.dir && (!&autochdir || w:fzf_pushd.bufname ==# bufname('')) + execute w:fzf_pushd.command s:escape(w:fzf_pushd.origin) + endif + unlet w:fzf_pushd +endfunction + +function! s:xterm_launcher() + let fmt = 'xterm -T "[fzf]" -bg "%s" -fg "%s" -geometry %dx%d+%d+%d -e bash -ic %%s' + if has('gui_macvim') + let fmt .= '&& osascript -e "tell application \"MacVim\" to activate"' + endif + return printf(fmt, + \ escape(synIDattr(hlID("Normal"), "bg"), '#'), escape(synIDattr(hlID("Normal"), "fg"), '#'), + \ &columns, &lines/2, getwinposx(), getwinposy()) +endfunction +unlet! s:launcher +if s:is_win || has('win32unix') + let s:launcher = '%s' +else + let s:launcher = function('s:xterm_launcher') +endif + +function! s:exit_handler(code, command, ...) + if a:code == 130 + return 0 + elseif has('nvim') && a:code == 129 + " When deleting the terminal buffer while fzf is still running, + " Nvim sends SIGHUP. + return 0 + elseif a:code > 1 + call s:error('Error running ' . a:command) + if !empty(a:000) + sleep + endif + return 0 + endif + return 1 +endfunction + +function! s:execute(dict, command, use_height, temps) abort + call s:pushd(a:dict) + if has('unix') && !a:use_height + silent! !clear 2> /dev/null + endif + let escaped = (a:use_height || s:is_win) ? a:command : escape(substitute(a:command, '\n', '\\n', 'g'), '%#!') + if has('gui_running') + let Launcher = get(a:dict, 'launcher', get(g:, 'Fzf_launcher', get(g:, 'fzf_launcher', s:launcher))) + let fmt = type(Launcher) == 2 ? call(Launcher, []) : Launcher + if has('unix') + let escaped = "'".substitute(escaped, "'", "'\"'\"'", 'g')."'" + endif + let command = printf(fmt, escaped) + else + let command = escaped + endif + if s:is_win + let batchfile = s:fzf_tempname().'.bat' + call writefile(s:wrap_cmds(command), batchfile) + let command = batchfile + let a:temps.batchfile = batchfile + if has('nvim') + let fzf = {} + let fzf.dict = a:dict + let fzf.temps = a:temps + function! fzf.on_exit(job_id, exit_status, event) dict + call s:pushd(self.dict) + let lines = s:collect(self.temps) + call s:callback(self.dict, lines) + endfunction + let cmd = 'start /wait cmd /c '.command + call jobstart(cmd, fzf) + return [] + endif + elseif has('win32unix') && $TERM !=# 'cygwin' + let shellscript = s:fzf_tempname() + call writefile([command], shellscript) + let command = 'cmd.exe /C '.fzf#shellescape('set "TERM=" & start /WAIT sh -c '.shellscript) + let a:temps.shellscript = shellscript + endif + if a:use_height + let stdin = has_key(a:dict, 'source') ? '' : '< /dev/tty' + call system(printf('tput cup %d > /dev/tty; tput cnorm > /dev/tty; %s %s 2> /dev/tty', &lines, command, stdin)) + else + execute 'silent !'.command + endif + let exit_status = v:shell_error + redraw! + return s:exit_handler(exit_status, command) ? s:collect(a:temps) : [] +endfunction + +function! s:execute_tmux(dict, command, temps) abort + let command = a:command + let cwd = s:pushd(a:dict) + if len(cwd) + " -c '#{pane_current_path}' is only available on tmux 1.9 or above + let command = join(['cd', fzf#shellescape(cwd), '&&', command]) + endif + + call system(command) + let exit_status = v:shell_error + redraw! + return s:exit_handler(exit_status, command) ? s:collect(a:temps) : [] +endfunction + +function! s:calc_size(max, val, dict) + let val = substitute(a:val, '^\~', '', '') + if val =~ '%$' + let size = a:max * str2nr(val[:-2]) / 100 + else + let size = min([a:max, str2nr(val)]) + endif + + let srcsz = -1 + if type(get(a:dict, 'source', 0)) == type([]) + let srcsz = len(a:dict.source) + endif + + let opts = $FZF_DEFAULT_OPTS.' '.s:evaluate_opts(get(a:dict, 'options', '')) + let margin = match(opts, '--inline-info\|--info[^-]\{-}inline') > match(opts, '--no-inline-info\|--info[^-]\{-}\(default\|hidden\)') ? 1 : 2 + let margin += stridx(opts, '--border') > stridx(opts, '--no-border') ? 2 : 0 + if stridx(opts, '--header') > stridx(opts, '--no-header') + let margin += len(split(opts, "\n")) + endif + return srcsz >= 0 ? min([srcsz + margin, size]) : size +endfunction + +function! s:getpos() + return {'tab': tabpagenr(), 'win': winnr(), 'winid': win_getid(), 'cnt': winnr('$'), 'tcnt': tabpagenr('$')} +endfunction + +function! s:split(dict) + let directions = { + \ 'up': ['topleft', 'resize', &lines], + \ 'down': ['botright', 'resize', &lines], + \ 'left': ['vertical topleft', 'vertical resize', &columns], + \ 'right': ['vertical botright', 'vertical resize', &columns] } + let ppos = s:getpos() + let is_popup = 0 + try + if s:present(a:dict, 'window') + if type(a:dict.window) == type({}) + if !has('nvim') && !has('patch-8.2.191') + throw 'Vim 8.2.191 or later is required for pop-up window' + end + call s:popup(a:dict.window) + let is_popup = 1 + else + execute 'keepalt' a:dict.window + endif + elseif !s:splittable(a:dict) + execute (tabpagenr()-1).'tabnew' + else + for [dir, triple] in items(directions) + let val = get(a:dict, dir, '') + if !empty(val) + let [cmd, resz, max] = triple + if (dir == 'up' || dir == 'down') && val[0] == '~' + let sz = s:calc_size(max, val, a:dict) + else + let sz = s:calc_size(max, val, {}) + endif + execute cmd sz.'new' + execute resz sz + return [ppos, {}, is_popup] + endif + endfor + endif + return [ppos, is_popup ? {} : { '&l:wfw': &l:wfw, '&l:wfh': &l:wfh }, is_popup] + finally + if !is_popup + setlocal winfixwidth winfixheight + endif + endtry +endfunction + +function! s:execute_term(dict, command, temps) abort + let winrest = winrestcmd() + let pbuf = bufnr('') + let [ppos, winopts, is_popup] = s:split(a:dict) + call s:use_sh() + let b:fzf = a:dict + let fzf = { 'buf': bufnr(''), 'pbuf': pbuf, 'ppos': ppos, 'dict': a:dict, 'temps': a:temps, + \ 'winopts': winopts, 'winrest': winrest, 'lines': &lines, + \ 'columns': &columns, 'command': a:command } + function! fzf.switch_back(inplace) + if a:inplace && bufnr('') == self.buf + if bufexists(self.pbuf) + execute 'keepalt b' self.pbuf + endif + " No other listed buffer + if bufnr('') == self.buf + enew + endif + endif + endfunction + function! fzf.on_exit(id, code, ...) + if s:getpos() == self.ppos " {'window': 'enew'} + for [opt, val] in items(self.winopts) + execute 'let' opt '=' val + endfor + call self.switch_back(1) + else + if bufnr('') == self.buf + " We use close instead of bd! since Vim does not close the split when + " there's no other listed buffer (nvim +'set nobuflisted') + close + endif + silent! execute 'tabnext' self.ppos.tab + silent! execute self.ppos.win.'wincmd w' + endif + + if bufexists(self.buf) + execute 'bd!' self.buf + endif + + if &lines == self.lines && &columns == self.columns && s:getpos() == self.ppos + execute self.winrest + endif + + if !s:exit_handler(a:code, self.command, 1) + return + endif + + call s:pushd(self.dict) + let lines = s:collect(self.temps) + call s:callback(self.dict, lines) + call self.switch_back(s:getpos() == self.ppos) + endfunction + + try + call s:pushd(a:dict) + if s:is_win + let fzf.temps.batchfile = s:fzf_tempname().'.bat' + call writefile(s:wrap_cmds(a:command), fzf.temps.batchfile) + let command = fzf.temps.batchfile + else + let command = a:command + endif + let command .= s:term_marker + if has('nvim') + call termopen(command, fzf) + else + let term_opts = {'exit_cb': function(fzf.on_exit)} + if is_popup + let term_opts.hidden = 1 + else + let term_opts.curwin = 1 + endif + let fzf.buf = term_start([&shell, &shellcmdflag, command], term_opts) + if is_popup && exists('#TerminalWinOpen') + doautocmd TerminalWinOpen + endif + if !has('patch-8.0.1261') && !s:is_win + call term_wait(fzf.buf, 20) + endif + endif + finally + call s:dopopd() + endtry + setlocal nospell bufhidden=wipe nobuflisted nonumber + setf fzf + startinsert + return [] +endfunction + +function! s:collect(temps) abort + try + return filereadable(a:temps.result) ? readfile(a:temps.result) : [] + finally + for tf in values(a:temps) + silent! call delete(tf) + endfor + endtry +endfunction + +function! s:callback(dict, lines) abort + let popd = has_key(a:dict, 'pushd') + if popd + let w:fzf_pushd = a:dict.pushd + endif + + try + if has_key(a:dict, 'sink') + for line in a:lines + if type(a:dict.sink) == 2 + call a:dict.sink(line) + else + execute a:dict.sink s:escape(line) + endif + endfor + endif + if has_key(a:dict, 'sink*') + call a:dict['sink*'](a:lines) + endif + catch + if stridx(v:exception, ':E325:') < 0 + echoerr v:exception + endif + endtry + + " We may have opened a new window or tab + if popd + let w:fzf_pushd = a:dict.pushd + call s:dopopd() + endif +endfunction + +if has('nvim') + function s:create_popup(hl, opts) abort + let buf = nvim_create_buf(v:false, v:true) + let opts = extend({'relative': 'editor', 'style': 'minimal'}, a:opts) + let border = has_key(opts, 'border') ? remove(opts, 'border') : [] + let win = nvim_open_win(buf, v:true, opts) + call setwinvar(win, '&winhighlight', 'NormalFloat:'..a:hl) + call setwinvar(win, '&colorcolumn', '') + if !empty(border) + call nvim_buf_set_lines(buf, 0, -1, v:true, border) + endif + return buf + endfunction +else + function! s:create_popup(hl, opts) abort + let is_frame = has_key(a:opts, 'border') + let s:popup_create = {buf -> popup_create(buf, #{ + \ line: a:opts.row, + \ col: a:opts.col, + \ minwidth: a:opts.width, + \ minheight: a:opts.height, + \ zindex: 50 - is_frame, + \ })} + if is_frame + let id = s:popup_create('') + call setwinvar(id, '&wincolor', a:hl) + call setbufline(winbufnr(id), 1, a:opts.border) + execute 'autocmd BufWipeout * ++once call popup_close('..id..')' + return winbufnr(id) + else + autocmd TerminalOpen * ++once call s:popup_create(str2nr(expand(''))) + endif + endfunction +endif + +function! s:popup(opts) abort + " Support ambiwidth == 'double' + let ambidouble = &ambiwidth == 'double' ? 2 : 1 + + " Size and position + let width = min([max([0, float2nr(&columns * a:opts.width)]), &columns]) + let width += width % ambidouble + let height = min([max([0, float2nr(&lines * a:opts.height)]), &lines - has('nvim')]) + let row = float2nr(get(a:opts, 'yoffset', 0.5) * (&lines - height)) + let col = float2nr(get(a:opts, 'xoffset', 0.5) * (&columns - width)) + + " Managing the differences + let row = min([max([0, row]), &lines - has('nvim') - height]) + let col = min([max([0, col]), &columns - width]) + let row += !has('nvim') + let col += !has('nvim') + + " Border style + let style = tolower(get(a:opts, 'border', 'rounded')) + if !has_key(a:opts, 'border') && !get(a:opts, 'rounded', 1) + let style = 'sharp' + endif + + if style =~ 'vertical\|left\|right' + let mid = style == 'vertical' ? '│' .. repeat(' ', width - 2 * ambidouble) .. '│' : + \ style == 'left' ? '│' .. repeat(' ', width - 1 * ambidouble) + \ : repeat(' ', width - 1 * ambidouble) .. '│' + let border = repeat([mid], height) + let shift = { 'row': 0, 'col': style == 'right' ? 0 : 2, 'width': style == 'vertical' ? -4 : -2, 'height': 0 } + elseif style =~ 'horizontal\|top\|bottom' + let hor = repeat('─', width / ambidouble) + let mid = repeat(' ', width) + let border = style == 'horizontal' ? [hor] + repeat([mid], height - 2) + [hor] : + \ style == 'top' ? [hor] + repeat([mid], height - 1) + \ : repeat([mid], height - 1) + [hor] + let shift = { 'row': style == 'bottom' ? 0 : 1, 'col': 0, 'width': 0, 'height': style == 'horizontal' ? -2 : -1 } + else + let edges = style == 'sharp' ? ['┌', '┐', '└', '┘'] : ['╭', '╮', '╰', '╯'] + let bar = repeat('─', width / ambidouble - 2) + let top = edges[0] .. bar .. edges[1] + let mid = '│' .. repeat(' ', width - 2 * ambidouble) .. '│' + let bot = edges[2] .. bar .. edges[3] + let border = [top] + repeat([mid], height - 2) + [bot] + let shift = { 'row': 1, 'col': 2, 'width': -4, 'height': -2 } + endif + + let highlight = get(a:opts, 'highlight', 'Comment') + let frame = s:create_popup(highlight, { + \ 'row': row, 'col': col, 'width': width, 'height': height, 'border': border + \ }) + call s:create_popup('Normal', { + \ 'row': row + shift.row, 'col': col + shift.col, 'width': width + shift.width, 'height': height + shift.height + \ }) + if has('nvim') + execute 'autocmd BufWipeout bwipeout '..frame + endif +endfunction + +let s:default_action = { + \ 'ctrl-t': 'tab split', + \ 'ctrl-x': 'split', + \ 'ctrl-v': 'vsplit' } + +function! s:shortpath() + let short = fnamemodify(getcwd(), ':~:.') + if !has('win32unix') + let short = pathshorten(short) + endif + let slash = (s:is_win && !&shellslash) ? '\' : '/' + return empty(short) ? '~'.slash : short . (short =~ escape(slash, '\').'$' ? '' : slash) +endfunction + +function! s:cmd(bang, ...) abort + let args = copy(a:000) + let opts = { 'options': ['--multi'] } + if len(args) && isdirectory(expand(args[-1])) + let opts.dir = substitute(substitute(remove(args, -1), '\\\(["'']\)', '\1', 'g'), '[/\\]*$', '/', '') + if s:is_win && !&shellslash + let opts.dir = substitute(opts.dir, '/', '\\', 'g') + endif + let prompt = opts.dir + else + let prompt = s:shortpath() + endif + let prompt = strwidth(prompt) < &columns - 20 ? prompt : '> ' + call extend(opts.options, ['--prompt', prompt]) + call extend(opts.options, args) + call fzf#run(fzf#wrap('FZF', opts, a:bang)) +endfunction + +command! -nargs=* -complete=dir -bang FZF call s:cmd(0, ) + +let &cpo = s:cpo_save +unlet s:cpo_save diff --git a/skel/.config/nvim/plugged/fzf/shell/completion.bash b/skel/.config/nvim/plugged/fzf/shell/completion.bash new file mode 100644 index 0000000..3f6161d --- /dev/null +++ b/skel/.config/nvim/plugged/fzf/shell/completion.bash @@ -0,0 +1,372 @@ +# ____ ____ +# / __/___ / __/ +# / /_/_ / / /_ +# / __/ / /_/ __/ +# /_/ /___/_/ completion.bash +# +# - $FZF_TMUX (default: 0) +# - $FZF_TMUX_OPTS (default: empty) +# - $FZF_COMPLETION_TRIGGER (default: '**') +# - $FZF_COMPLETION_OPTS (default: empty) + +if [[ $- =~ i ]]; then + +# To use custom commands instead of find, override _fzf_compgen_{path,dir} +if ! declare -f _fzf_compgen_path > /dev/null; then + _fzf_compgen_path() { + echo "$1" + command find -L "$1" \ + -name .git -prune -o -name .hg -prune -o -name .svn -prune -o \( -type d -o -type f -o -type l \) \ + -a -not -path "$1" -print 2> /dev/null | sed 's@^\./@@' + } +fi + +if ! declare -f _fzf_compgen_dir > /dev/null; then + _fzf_compgen_dir() { + command find -L "$1" \ + -name .git -prune -o -name .hg -prune -o -name .svn -prune -o -type d \ + -a -not -path "$1" -print 2> /dev/null | sed 's@^\./@@' + } +fi + +########################################################### + +# To redraw line after fzf closes (printf '\e[5n') +bind '"\e[0n": redraw-current-line' + +__fzf_comprun() { + if [ "$(type -t _fzf_comprun 2>&1)" = function ]; then + _fzf_comprun "$@" + elif [ -n "$TMUX_PANE" ] && { [ "${FZF_TMUX:-0}" != 0 ] || [ -n "$FZF_TMUX_OPTS" ]; }; then + shift + fzf-tmux ${FZF_TMUX_OPTS:--d${FZF_TMUX_HEIGHT:-40%}} -- "$@" + else + shift + fzf "$@" + fi +} + +__fzf_orig_completion_filter() { + sed 's/^\(.*-F\) *\([^ ]*\).* \([^ ]*\)$/export _fzf_orig_completion_\3="\1 %s \3 #\2"; [[ "\1" = *" -o nospace "* ]] \&\& [[ ! "$__fzf_nospace_commands" = *" \3 "* ]] \&\& __fzf_nospace_commands="$__fzf_nospace_commands \3 ";/' | + awk -F= '{OFS = FS} {gsub(/[^A-Za-z0-9_= ;]/, "_", $1);}1' +} + +_fzf_opts_completion() { + local cur prev opts + COMPREPLY=() + cur="${COMP_WORDS[COMP_CWORD]}" + prev="${COMP_WORDS[COMP_CWORD-1]}" + opts=" + -x --extended + -e --exact + --algo + -i +i + -n --nth + --with-nth + -d --delimiter + +s --no-sort + --tac + --tiebreak + -m --multi + --no-mouse + --bind + --cycle + --no-hscroll + --jump-labels + --height + --literal + --reverse + --margin + --inline-info + --prompt + --pointer + --marker + --header + --header-lines + --ansi + --tabstop + --color + --no-bold + --history + --history-size + --preview + --preview-window + -q --query + -1 --select-1 + -0 --exit-0 + -f --filter + --print-query + --expect + --sync" + + case "${prev}" in + --tiebreak) + COMPREPLY=( $(compgen -W "length begin end index" -- "$cur") ) + return 0 + ;; + --color) + COMPREPLY=( $(compgen -W "dark light 16 bw" -- "$cur") ) + return 0 + ;; + --history) + COMPREPLY=() + return 0 + ;; + esac + + if [[ "$cur" =~ ^-|\+ ]]; then + COMPREPLY=( $(compgen -W "${opts}" -- "$cur") ) + return 0 + fi + + return 0 +} + +_fzf_handle_dynamic_completion() { + local cmd orig_var orig ret orig_cmd orig_complete + cmd="$1" + shift + orig_cmd="$1" + orig_var="_fzf_orig_completion_$cmd" + orig="${!orig_var##*#}" + if [ -n "$orig" ] && type "$orig" > /dev/null 2>&1; then + $orig "$@" + elif [ -n "$_fzf_completion_loader" ]; then + orig_complete=$(complete -p "$orig_cmd" 2> /dev/null) + _completion_loader "$@" + ret=$? + # _completion_loader may not have updated completion for the command + if [ "$(complete -p "$orig_cmd" 2> /dev/null)" != "$orig_complete" ]; then + eval "$(complete | command grep " -F.* $orig_cmd$" | __fzf_orig_completion_filter)" + if [[ "$__fzf_nospace_commands" = *" $orig_cmd "* ]]; then + eval "${orig_complete/ -F / -o nospace -F }" + else + eval "$orig_complete" + fi + fi + return $ret + fi +} + +__fzf_generic_path_completion() { + local cur base dir leftover matches trigger cmd + cmd="${COMP_WORDS[0]//[^A-Za-z0-9_=]/_}" + COMPREPLY=() + trigger=${FZF_COMPLETION_TRIGGER-'**'} + cur="${COMP_WORDS[COMP_CWORD]}" + if [[ "$cur" == *"$trigger" ]]; then + base=${cur:0:${#cur}-${#trigger}} + eval "base=$base" + + [[ $base = *"/"* ]] && dir="$base" + while true; do + if [ -z "$dir" ] || [ -d "$dir" ]; then + leftover=${base/#"$dir"} + leftover=${leftover/#\/} + [ -z "$dir" ] && dir='.' + [ "$dir" != "/" ] && dir="${dir/%\//}" + matches=$(eval "$1 $(printf %q "$dir")" | FZF_DEFAULT_OPTS="--height ${FZF_TMUX_HEIGHT:-40%} --reverse $FZF_DEFAULT_OPTS $FZF_COMPLETION_OPTS $2" __fzf_comprun "$4" -q "$leftover" | while read -r item; do + printf "%q$3 " "$item" + done) + matches=${matches% } + [[ -z "$3" ]] && [[ "$__fzf_nospace_commands" = *" ${COMP_WORDS[0]} "* ]] && matches="$matches " + if [ -n "$matches" ]; then + COMPREPLY=( "$matches" ) + else + COMPREPLY=( "$cur" ) + fi + printf '\e[5n' + return 0 + fi + dir=$(dirname "$dir") + [[ "$dir" =~ /$ ]] || dir="$dir"/ + done + else + shift + shift + shift + _fzf_handle_dynamic_completion "$cmd" "$@" + fi +} + +_fzf_complete() { + # Split arguments around -- + local args rest str_arg i sep + args=("$@") + sep= + for i in "${!args[@]}"; do + if [[ "${args[$i]}" = -- ]]; then + sep=$i + break + fi + done + if [[ -n "$sep" ]]; then + str_arg= + rest=("${args[@]:$((sep + 1)):${#args[@]}}") + args=("${args[@]:0:$sep}") + else + str_arg=$1 + args=() + shift + rest=("$@") + fi + + local cur selected trigger cmd post + post="$(caller 0 | awk '{print $2}')_post" + type -t "$post" > /dev/null 2>&1 || post=cat + + cmd="${COMP_WORDS[0]//[^A-Za-z0-9_=]/_}" + trigger=${FZF_COMPLETION_TRIGGER-'**'} + cur="${COMP_WORDS[COMP_CWORD]}" + if [[ "$cur" == *"$trigger" ]]; then + cur=${cur:0:${#cur}-${#trigger}} + + selected=$(FZF_DEFAULT_OPTS="--height ${FZF_TMUX_HEIGHT:-40%} --reverse $FZF_DEFAULT_OPTS $FZF_COMPLETION_OPTS $str_arg" __fzf_comprun "${rest[0]}" "${args[@]}" -q "$cur" | $post | tr '\n' ' ') + selected=${selected% } # Strip trailing space not to repeat "-o nospace" + if [ -n "$selected" ]; then + COMPREPLY=("$selected") + else + COMPREPLY=("$cur") + fi + printf '\e[5n' + return 0 + else + _fzf_handle_dynamic_completion "$cmd" "${rest[@]}" + fi +} + +_fzf_path_completion() { + __fzf_generic_path_completion _fzf_compgen_path "-m" "" "$@" +} + +# Deprecated. No file only completion. +_fzf_file_completion() { + _fzf_path_completion "$@" +} + +_fzf_dir_completion() { + __fzf_generic_path_completion _fzf_compgen_dir "" "/" "$@" +} + +_fzf_complete_kill() { + local trigger=${FZF_COMPLETION_TRIGGER-'**'} + local cur="${COMP_WORDS[COMP_CWORD]}" + if [[ -z "$cur" ]]; then + COMP_WORDS[$COMP_CWORD]=$trigger + elif [[ "$cur" != *"$trigger" ]]; then + return 1 + fi + + _fzf_proc_completion "$@" +} + +_fzf_proc_completion() { + _fzf_complete -m --preview 'echo {}' --preview-window down:3:wrap --min-height 15 -- "$@" < <( + command ps -ef | sed 1d + ) +} + +_fzf_proc_completion_post() { + awk '{print $2}' +} + +_fzf_host_completion() { + _fzf_complete +m -- "$@" < <( + cat <(cat ~/.ssh/config ~/.ssh/config.d/* /etc/ssh/ssh_config 2> /dev/null | command grep -i '^\s*host\(name\)\? ' | awk '{for (i = 2; i <= NF; i++) print $1 " " $i}' | command grep -v '[*?]') \ + <(command grep -oE '^[[a-z0-9.,:-]+' ~/.ssh/known_hosts | tr ',' '\n' | tr -d '[' | awk '{ print $1 " " $1 }') \ + <(command grep -v '^\s*\(#\|$\)' /etc/hosts | command grep -Fv '0.0.0.0') | + awk '{if (length($2) > 0) {print $2}}' | sort -u + ) +} + +_fzf_var_completion() { + _fzf_complete -m -- "$@" < <( + declare -xp | sed 's/=.*//' | sed 's/.* //' + ) +} + +_fzf_alias_completion() { + _fzf_complete -m -- "$@" < <( + alias | sed 's/=.*//' | sed 's/.* //' + ) +} + +# fzf options +complete -o default -F _fzf_opts_completion fzf + +d_cmds="${FZF_COMPLETION_DIR_COMMANDS:-cd pushd rmdir}" +a_cmds=" + awk cat diff diff3 + emacs emacsclient ex file ftp g++ gcc gvim head hg java + javac ld less more mvim nvim patch perl python ruby + sed sftp sort source tail tee uniq vi view vim wc xdg-open + basename bunzip2 bzip2 chmod chown curl cp dirname du + find git grep gunzip gzip hg jar + ln ls mv open rm rsync scp + svn tar unzip zip" + +# Preserve existing completion +eval "$(complete | + sed -E '/-F/!d; / _fzf/d; '"/ ($(echo $d_cmds $a_cmds | sed 's/ /|/g; s/+/\\+/g'))$/"'!d' | + __fzf_orig_completion_filter)" + +if type _completion_loader > /dev/null 2>&1; then + _fzf_completion_loader=1 +fi + +__fzf_defc() { + local cmd func opts orig_var orig def + cmd="$1" + func="$2" + opts="$3" + orig_var="_fzf_orig_completion_${cmd//[^A-Za-z0-9_]/_}" + orig="${!orig_var}" + if [ -n "$orig" ]; then + printf -v def "$orig" "$func" + eval "$def" + else + complete -F "$func" $opts "$cmd" + fi +} + +# Anything +for cmd in $a_cmds; do + __fzf_defc "$cmd" _fzf_path_completion "-o default -o bashdefault" +done + +# Directory +for cmd in $d_cmds; do + __fzf_defc "$cmd" _fzf_dir_completion "-o nospace -o dirnames" +done + +# Kill completion (supports empty completion trigger) +complete -F _fzf_complete_kill -o default -o bashdefault kill + +unset cmd d_cmds a_cmds + +_fzf_setup_completion() { + local kind fn cmd + kind=$1 + fn=_fzf_${1}_completion + if [[ $# -lt 2 ]] || ! type -t "$fn" > /dev/null; then + echo "usage: ${FUNCNAME[0]} path|dir|var|alias|host|proc COMMANDS..." + return 1 + fi + shift + eval "$(complete -p "$@" 2> /dev/null | grep -v "$fn" | __fzf_orig_completion_filter)" + for cmd in "$@"; do + case "$kind" in + dir) __fzf_defc "$cmd" "$fn" "-o nospace -o dirnames" ;; + var) __fzf_defc "$cmd" "$fn" "-o default -o nospace -v" ;; + alias) __fzf_defc "$cmd" "$fn" "-a" ;; + *) __fzf_defc "$cmd" "$fn" "-o default -o bashdefault" ;; + esac + done +} + +# Environment variables / Aliases / Hosts +_fzf_setup_completion 'var' export unset +_fzf_setup_completion 'alias' unalias +_fzf_setup_completion 'host' ssh telnet + +fi diff --git a/skel/.config/nvim/plugged/fzf/shell/completion.zsh b/skel/.config/nvim/plugged/fzf/shell/completion.zsh new file mode 100644 index 0000000..2096ad4 --- /dev/null +++ b/skel/.config/nvim/plugged/fzf/shell/completion.zsh @@ -0,0 +1,329 @@ +# ____ ____ +# / __/___ / __/ +# / /_/_ / / /_ +# / __/ / /_/ __/ +# /_/ /___/_/ completion.zsh +# +# - $FZF_TMUX (default: 0) +# - $FZF_TMUX_OPTS (default: '-d 40%') +# - $FZF_COMPLETION_TRIGGER (default: '**') +# - $FZF_COMPLETION_OPTS (default: empty) + +# Both branches of the following `if` do the same thing -- define +# __fzf_completion_options such that `eval $__fzf_completion_options` sets +# all options to the same values they currently have. We'll do just that at +# the bottom of the file after changing options to what we prefer. +# +# IMPORTANT: Until we get to the `emulate` line, all words that *can* be quoted +# *must* be quoted in order to prevent alias expansion. In addition, code must +# be written in a way works with any set of zsh options. This is very tricky, so +# careful when you change it. +# +# Start by loading the builtin zsh/parameter module. It provides `options` +# associative array that stores current shell options. +if 'zmodload' 'zsh/parameter' 2>'/dev/null' && (( ${+options} )); then + # This is the fast branch and it gets taken on virtually all Zsh installations. + # + # ${(kv)options[@]} expands to array of keys (option names) and values ("on" + # or "off"). The subsequent expansion# with (j: :) flag joins all elements + # together separated by spaces. __fzf_completion_options ends up with a value + # like this: "options=(shwordsplit off aliases on ...)". + __fzf_completion_options="options=(${(j: :)${(kv)options[@]}})" +else + # This branch is much slower because it forks to get the names of all + # zsh options. It's possible to eliminate this fork but it's not worth the + # trouble because this branch gets taken only on very ancient or broken + # zsh installations. + () { + # That `()` above defines an anonymous function. This is essentially a scope + # for local parameters. We use it to avoid polluting global scope. + 'local' '__fzf_opt' + __fzf_completion_options="setopt" + # `set -o` prints one line for every zsh option. Each line contains option + # name, some spaces, and then either "on" or "off". We just want option names. + # Expansion with (@f) flag splits a string into lines. The outer expansion + # removes spaces and everything that follow them on every line. __fzf_opt + # ends up iterating over option names: shwordsplit, aliases, etc. + for __fzf_opt in "${(@)${(@f)$(set -o)}%% *}"; do + if [[ -o "$__fzf_opt" ]]; then + # Option $__fzf_opt is currently on, so remember to set it back on. + __fzf_completion_options+=" -o $__fzf_opt" + else + # Option $__fzf_opt is currently off, so remember to set it back off. + __fzf_completion_options+=" +o $__fzf_opt" + fi + done + # The value of __fzf_completion_options here looks like this: + # "setopt +o shwordsplit -o aliases ..." + } +fi + +# Enable the default zsh options (those marked with in `man zshoptions`) +# but without `aliases`. Aliases in functions are expanded when functions are +# defined, so if we disable aliases here, we'll be sure to have no pesky +# aliases in any of our functions. This way we won't need prefix every +# command with `command` or to quote every word to defend against global +# aliases. Note that `aliases` is not the only option that's important to +# control. There are several others that could wreck havoc if they are set +# to values we don't expect. With the following `emulate` command we +# sidestep this issue entirely. +'emulate' 'zsh' '-o' 'no_aliases' + +# This brace is the start of try-always block. The `always` part is like +# `finally` in lesser languages. We use it to *always* restore user options. +{ + +# Bail out if not interactive shell. +[[ -o interactive ]] || return 0 + +# To use custom commands instead of find, override _fzf_compgen_{path,dir} +if ! declare -f _fzf_compgen_path > /dev/null; then + _fzf_compgen_path() { + echo "$1" + command find -L "$1" \ + -name .git -prune -o -name .hg -prune -o -name .svn -prune -o \( -type d -o -type f -o -type l \) \ + -a -not -path "$1" -print 2> /dev/null | sed 's@^\./@@' + } +fi + +if ! declare -f _fzf_compgen_dir > /dev/null; then + _fzf_compgen_dir() { + command find -L "$1" \ + -name .git -prune -o -name .hg -prune -o -name .svn -prune -o -type d \ + -a -not -path "$1" -print 2> /dev/null | sed 's@^\./@@' + } +fi + +########################################################### + +__fzf_comprun() { + if [[ "$(type _fzf_comprun 2>&1)" =~ function ]]; then + _fzf_comprun "$@" + elif [ -n "$TMUX_PANE" ] && { [ "${FZF_TMUX:-0}" != 0 ] || [ -n "$FZF_TMUX_OPTS" ]; }; then + shift + if [ -n "$FZF_TMUX_OPTS" ]; then + fzf-tmux ${(Q)${(Z+n+)FZF_TMUX_OPTS}} -- "$@" + else + fzf-tmux -d ${FZF_TMUX_HEIGHT:-40%} -- "$@" + fi + else + shift + fzf "$@" + fi +} + +# Extract the name of the command. e.g. foo=1 bar baz** +__fzf_extract_command() { + local token tokens + tokens=(${(z)1}) + for token in $tokens; do + token=${(Q)token} + if [[ "$token" =~ [[:alnum:]] && ! "$token" =~ "=" ]]; then + echo "$token" + return + fi + done + echo "${tokens[1]}" +} + +__fzf_generic_path_completion() { + local base lbuf cmd compgen fzf_opts suffix tail dir leftover matches + base=$1 + lbuf=$2 + cmd=$(__fzf_extract_command "$lbuf") + compgen=$3 + fzf_opts=$4 + suffix=$5 + tail=$6 + + setopt localoptions nonomatch + eval "base=$base" + [[ $base = *"/"* ]] && dir="$base" + while [ 1 ]; do + if [[ -z "$dir" || -d ${dir} ]]; then + leftover=${base/#"$dir"} + leftover=${leftover/#\/} + [ -z "$dir" ] && dir='.' + [ "$dir" != "/" ] && dir="${dir/%\//}" + matches=$(eval "$compgen $(printf %q "$dir")" | FZF_DEFAULT_OPTS="--height ${FZF_TMUX_HEIGHT:-40%} --reverse $FZF_DEFAULT_OPTS $FZF_COMPLETION_OPTS" __fzf_comprun "$cmd" ${(Q)${(Z+n+)fzf_opts}} -q "$leftover" | while read item; do + echo -n "${(q)item}$suffix " + done) + matches=${matches% } + if [ -n "$matches" ]; then + LBUFFER="$lbuf$matches$tail" + fi + zle reset-prompt + break + fi + dir=$(dirname "$dir") + dir=${dir%/}/ + done +} + +_fzf_path_completion() { + __fzf_generic_path_completion "$1" "$2" _fzf_compgen_path \ + "-m" "" " " +} + +_fzf_dir_completion() { + __fzf_generic_path_completion "$1" "$2" _fzf_compgen_dir \ + "" "/" "" +} + +_fzf_feed_fifo() ( + command rm -f "$1" + mkfifo "$1" + cat <&0 > "$1" & +) + +_fzf_complete() { + setopt localoptions ksh_arrays + # Split arguments around -- + local args rest str_arg i sep + args=("$@") + sep= + for i in {0..${#args[@]}}; do + if [[ "${args[$i]}" = -- ]]; then + sep=$i + break + fi + done + if [[ -n "$sep" ]]; then + str_arg= + rest=("${args[@]:$((sep + 1)):${#args[@]}}") + args=("${args[@]:0:$sep}") + else + str_arg=$1 + args=() + shift + rest=("$@") + fi + + local fifo lbuf cmd matches post + fifo="${TMPDIR:-/tmp}/fzf-complete-fifo-$$" + lbuf=${rest[0]} + cmd=$(__fzf_extract_command "$lbuf") + post="${funcstack[1]}_post" + type $post > /dev/null 2>&1 || post=cat + + _fzf_feed_fifo "$fifo" + matches=$(FZF_DEFAULT_OPTS="--height ${FZF_TMUX_HEIGHT:-40%} --reverse $FZF_DEFAULT_OPTS $FZF_COMPLETION_OPTS $str_arg" __fzf_comprun "$cmd" "${args[@]}" -q "${(Q)prefix}" < "$fifo" | $post | tr '\n' ' ') + if [ -n "$matches" ]; then + LBUFFER="$lbuf$matches" + fi + zle reset-prompt + command rm -f "$fifo" +} + +_fzf_complete_telnet() { + _fzf_complete +m -- "$@" < <( + command grep -v '^\s*\(#\|$\)' /etc/hosts | command grep -Fv '0.0.0.0' | + awk '{if (length($2) > 0) {print $2}}' | sort -u + ) +} + +_fzf_complete_ssh() { + _fzf_complete +m -- "$@" < <( + setopt localoptions nonomatch + command cat <(cat ~/.ssh/config ~/.ssh/config.d/* /etc/ssh/ssh_config 2> /dev/null | command grep -i '^\s*host\(name\)\? ' | awk '{for (i = 2; i <= NF; i++) print $1 " " $i}' | command grep -v '[*?]') \ + <(command grep -oE '^[[a-z0-9.,:-]+' ~/.ssh/known_hosts | tr ',' '\n' | tr -d '[' | awk '{ print $1 " " $1 }') \ + <(command grep -v '^\s*\(#\|$\)' /etc/hosts | command grep -Fv '0.0.0.0') | + awk '{if (length($2) > 0) {print $2}}' | sort -u + ) +} + +_fzf_complete_export() { + _fzf_complete -m -- "$@" < <( + declare -xp | sed 's/=.*//' | sed 's/.* //' + ) +} + +_fzf_complete_unset() { + _fzf_complete -m -- "$@" < <( + declare -xp | sed 's/=.*//' | sed 's/.* //' + ) +} + +_fzf_complete_unalias() { + _fzf_complete +m -- "$@" < <( + alias | sed 's/=.*//' + ) +} + +_fzf_complete_kill() { + _fzf_complete -m --preview 'echo {}' --preview-window down:3:wrap --min-height 15 -- "$@" < <( + command ps -ef | sed 1d + ) +} + +_fzf_complete_kill_post() { + awk '{print $2}' +} + +fzf-completion() { + local tokens cmd prefix trigger tail matches lbuf d_cmds + setopt localoptions noshwordsplit noksh_arrays noposixbuiltins + + # http://zsh.sourceforge.net/FAQ/zshfaq03.html + # http://zsh.sourceforge.net/Doc/Release/Expansion.html#Parameter-Expansion-Flags + tokens=(${(z)LBUFFER}) + if [ ${#tokens} -lt 1 ]; then + zle ${fzf_default_completion:-expand-or-complete} + return + fi + + cmd=$(__fzf_extract_command "$LBUFFER") + + # Explicitly allow for empty trigger. + trigger=${FZF_COMPLETION_TRIGGER-'**'} + [ -z "$trigger" -a ${LBUFFER[-1]} = ' ' ] && tokens+=("") + + # When the trigger starts with ';', it becomes a separate token + if [[ ${LBUFFER} = *"${tokens[-2]}${tokens[-1]}" ]]; then + tokens[-2]="${tokens[-2]}${tokens[-1]}" + tokens=(${tokens[0,-2]}) + fi + + lbuf=$LBUFFER + tail=${LBUFFER:$(( ${#LBUFFER} - ${#trigger} ))} + # Kill completion (do not require trigger sequence) + if [ "$cmd" = kill -a ${LBUFFER[-1]} = ' ' ]; then + tail=$trigger + tokens+=$trigger + lbuf="$lbuf$trigger" + fi + + # Trigger sequence given + if [ ${#tokens} -gt 1 -a "$tail" = "$trigger" ]; then + d_cmds=(${=FZF_COMPLETION_DIR_COMMANDS:-cd pushd rmdir}) + + [ -z "$trigger" ] && prefix=${tokens[-1]} || prefix=${tokens[-1]:0:-${#trigger}} + [ -n "${tokens[-1]}" ] && lbuf=${lbuf:0:-${#tokens[-1]}} + + if eval "type _fzf_complete_${cmd} > /dev/null"; then + prefix="$prefix" eval _fzf_complete_${cmd} ${(q)lbuf} + elif [ ${d_cmds[(i)$cmd]} -le ${#d_cmds} ]; then + _fzf_dir_completion "$prefix" "$lbuf" + else + _fzf_path_completion "$prefix" "$lbuf" + fi + # Fall back to default completion + else + zle ${fzf_default_completion:-expand-or-complete} + fi +} + +[ -z "$fzf_default_completion" ] && { + binding=$(bindkey '^I') + [[ $binding =~ 'undefined-key' ]] || fzf_default_completion=$binding[(s: :w)2] + unset binding +} + +zle -N fzf-completion +bindkey '^I' fzf-completion + +} always { + # Restore the original options. + eval $__fzf_completion_options + 'unset' '__fzf_completion_options' +} diff --git a/skel/.config/nvim/plugged/fzf/shell/key-bindings.bash b/skel/.config/nvim/plugged/fzf/shell/key-bindings.bash new file mode 100644 index 0000000..e157b07 --- /dev/null +++ b/skel/.config/nvim/plugged/fzf/shell/key-bindings.bash @@ -0,0 +1,96 @@ +# ____ ____ +# / __/___ / __/ +# / /_/_ / / /_ +# / __/ / /_/ __/ +# /_/ /___/_/ key-bindings.bash +# +# - $FZF_TMUX_OPTS +# - $FZF_CTRL_T_COMMAND +# - $FZF_CTRL_T_OPTS +# - $FZF_CTRL_R_OPTS +# - $FZF_ALT_C_COMMAND +# - $FZF_ALT_C_OPTS + +# Key bindings +# ------------ +__fzf_select__() { + local cmd="${FZF_CTRL_T_COMMAND:-"command find -L . -mindepth 1 \\( -path '*/\\.*' -o -fstype 'sysfs' -o -fstype 'devfs' -o -fstype 'devtmpfs' -o -fstype 'proc' \\) -prune \ + -o -type f -print \ + -o -type d -print \ + -o -type l -print 2> /dev/null | cut -b3-"}" + eval "$cmd" | FZF_DEFAULT_OPTS="--height ${FZF_TMUX_HEIGHT:-40%} --reverse $FZF_DEFAULT_OPTS $FZF_CTRL_T_OPTS" $(__fzfcmd) -m "$@" | while read -r item; do + printf '%q ' "$item" + done + echo +} + +if [[ $- =~ i ]]; then + +__fzfcmd() { + [ -n "$TMUX_PANE" ] && { [ "${FZF_TMUX:-0}" != 0 ] || [ -n "$FZF_TMUX_OPTS" ]; } && + echo "fzf-tmux ${FZF_TMUX_OPTS:--d${FZF_TMUX_HEIGHT:-40%}} -- " || echo "fzf" +} + +fzf-file-widget() { + local selected="$(__fzf_select__)" + READLINE_LINE="${READLINE_LINE:0:$READLINE_POINT}$selected${READLINE_LINE:$READLINE_POINT}" + READLINE_POINT=$(( READLINE_POINT + ${#selected} )) +} + +__fzf_cd__() { + local cmd dir + cmd="${FZF_ALT_C_COMMAND:-"command find -L . -mindepth 1 \\( -path '*/\\.*' -o -fstype 'sysfs' -o -fstype 'devfs' -o -fstype 'devtmpfs' -o -fstype 'proc' \\) -prune \ + -o -type d -print 2> /dev/null | cut -b3-"}" + dir=$(eval "$cmd" | FZF_DEFAULT_OPTS="--height ${FZF_TMUX_HEIGHT:-40%} --reverse $FZF_DEFAULT_OPTS $FZF_ALT_C_OPTS" $(__fzfcmd) +m) && printf 'cd %q' "$dir" +} + +__fzf_history__() { + local output + output=$( + builtin fc -lnr -2147483648 | + last_hist=$(HISTTIMEFORMAT='' builtin history 1) perl -n -l0 -e 'BEGIN { getc; $/ = "\n\t"; $HISTCMD = $ENV{last_hist} + 1 } s/^[ *]//; print $HISTCMD - $. . "\t$_" if !$seen{$_}++' | + FZF_DEFAULT_OPTS="--height ${FZF_TMUX_HEIGHT:-40%} $FZF_DEFAULT_OPTS -n2..,.. --tiebreak=index --bind=ctrl-r:toggle-sort $FZF_CTRL_R_OPTS +m --read0" $(__fzfcmd) --query "$READLINE_LINE" + ) || return + READLINE_LINE=${output#*$'\t'} + if [ -z "$READLINE_POINT" ]; then + echo "$READLINE_LINE" + else + READLINE_POINT=0x7fffffff + fi +} + +# Required to refresh the prompt after fzf +bind -m emacs-standard '"\er": redraw-current-line' + +bind -m vi-command '"\C-z": emacs-editing-mode' +bind -m vi-insert '"\C-z": emacs-editing-mode' +bind -m emacs-standard '"\C-z": vi-editing-mode' + +if [ "${BASH_VERSINFO[0]}" -lt 4 ]; then + # CTRL-T - Paste the selected file path into the command line + bind -m emacs-standard '"\C-t": " \C-b\C-k \C-u`__fzf_select__`\e\C-e\er\C-a\C-y\C-h\C-e\e \C-y\ey\C-x\C-x\C-f"' + bind -m vi-command '"\C-t": "\C-z\C-t\C-z"' + bind -m vi-insert '"\C-t": "\C-z\C-t\C-z"' + + # CTRL-R - Paste the selected command from history into the command line + bind -m emacs-standard '"\C-r": "\C-e \C-u\C-y\ey\C-u"$(__fzf_history__)"\e\C-e\er"' + bind -m vi-command '"\C-r": "\C-z\C-r\C-z"' + bind -m vi-insert '"\C-r": "\C-z\C-r\C-z"' +else + # CTRL-T - Paste the selected file path into the command line + bind -m emacs-standard -x '"\C-t": fzf-file-widget' + bind -m vi-command -x '"\C-t": fzf-file-widget' + bind -m vi-insert -x '"\C-t": fzf-file-widget' + + # CTRL-R - Paste the selected command from history into the command line + bind -m emacs-standard -x '"\C-r": __fzf_history__' + bind -m vi-command -x '"\C-r": __fzf_history__' + bind -m vi-insert -x '"\C-r": __fzf_history__' +fi + +# ALT-C - cd into the selected directory +bind -m emacs-standard '"\ec": " \C-b\C-k \C-u`__fzf_cd__`\e\C-e\er\C-m\C-y\C-h\e \C-y\ey\C-x\C-x\C-d"' +bind -m vi-command '"\ec": "\C-z\ec\C-z"' +bind -m vi-insert '"\ec": "\C-z\ec\C-z"' + +fi diff --git a/skel/.config/nvim/plugged/fzf/shell/key-bindings.fish b/skel/.config/nvim/plugged/fzf/shell/key-bindings.fish new file mode 100644 index 0000000..73a0733 --- /dev/null +++ b/skel/.config/nvim/plugged/fzf/shell/key-bindings.fish @@ -0,0 +1,161 @@ +# ____ ____ +# / __/___ / __/ +# / /_/_ / / /_ +# / __/ / /_/ __/ +# /_/ /___/_/ key-bindings.fish +# +# - $FZF_TMUX_OPTS +# - $FZF_CTRL_T_COMMAND +# - $FZF_CTRL_T_OPTS +# - $FZF_CTRL_R_OPTS +# - $FZF_ALT_C_COMMAND +# - $FZF_ALT_C_OPTS + +# Key bindings +# ------------ +function fzf_key_bindings + + # Store current token in $dir as root for the 'find' command + function fzf-file-widget -d "List files and folders" + set -l commandline (__fzf_parse_commandline) + set -l dir $commandline[1] + set -l fzf_query $commandline[2] + + # "-path \$dir'*/\\.*'" matches hidden files/folders inside $dir but not + # $dir itself, even if hidden. + test -n "$FZF_CTRL_T_COMMAND"; or set -l FZF_CTRL_T_COMMAND " + command find -L \$dir -mindepth 1 \\( -path \$dir'*/\\.*' -o -fstype 'sysfs' -o -fstype 'devfs' -o -fstype 'devtmpfs' \\) -prune \ + -o -type f -print \ + -o -type d -print \ + -o -type l -print 2> /dev/null | sed 's@^\./@@'" + + test -n "$FZF_TMUX_HEIGHT"; or set FZF_TMUX_HEIGHT 40% + begin + set -lx FZF_DEFAULT_OPTS "--height $FZF_TMUX_HEIGHT --reverse $FZF_DEFAULT_OPTS $FZF_CTRL_T_OPTS" + eval "$FZF_CTRL_T_COMMAND | "(__fzfcmd)' -m --query "'$fzf_query'"' | while read -l r; set result $result $r; end + end + if [ -z "$result" ] + commandline -f repaint + return + else + # Remove last token from commandline. + commandline -t "" + end + for i in $result + commandline -it -- (string escape $i) + commandline -it -- ' ' + end + commandline -f repaint + end + + function fzf-history-widget -d "Show command history" + test -n "$FZF_TMUX_HEIGHT"; or set FZF_TMUX_HEIGHT 40% + begin + set -lx FZF_DEFAULT_OPTS "--height $FZF_TMUX_HEIGHT $FZF_DEFAULT_OPTS --tiebreak=index --bind=ctrl-r:toggle-sort $FZF_CTRL_R_OPTS +m" + + set -l FISH_MAJOR (echo $version | cut -f1 -d.) + set -l FISH_MINOR (echo $version | cut -f2 -d.) + + # history's -z flag is needed for multi-line support. + # history's -z flag was added in fish 2.4.0, so don't use it for versions + # before 2.4.0. + if [ "$FISH_MAJOR" -gt 2 -o \( "$FISH_MAJOR" -eq 2 -a "$FISH_MINOR" -ge 4 \) ]; + history -z | eval (__fzfcmd) --read0 --print0 -q '(commandline)' | read -lz result + and commandline -- $result + else + history | eval (__fzfcmd) -q '(commandline)' | read -l result + and commandline -- $result + end + end + commandline -f repaint + end + + function fzf-cd-widget -d "Change directory" + set -l commandline (__fzf_parse_commandline) + set -l dir $commandline[1] + set -l fzf_query $commandline[2] + + test -n "$FZF_ALT_C_COMMAND"; or set -l FZF_ALT_C_COMMAND " + command find -L \$dir -mindepth 1 \\( -path \$dir'*/\\.*' -o -fstype 'sysfs' -o -fstype 'devfs' -o -fstype 'devtmpfs' \\) -prune \ + -o -type d -print 2> /dev/null | sed 's@^\./@@'" + test -n "$FZF_TMUX_HEIGHT"; or set FZF_TMUX_HEIGHT 40% + begin + set -lx FZF_DEFAULT_OPTS "--height $FZF_TMUX_HEIGHT --reverse $FZF_DEFAULT_OPTS $FZF_ALT_C_OPTS" + eval "$FZF_ALT_C_COMMAND | "(__fzfcmd)' +m --query "'$fzf_query'"' | read -l result + + if [ -n "$result" ] + cd $result + + # Remove last token from commandline. + commandline -t "" + end + end + + commandline -f repaint + end + + function __fzfcmd + test -n "$FZF_TMUX"; or set FZF_TMUX 0 + test -n "$FZF_TMUX_HEIGHT"; or set FZF_TMUX_HEIGHT 40% + if [ -n "$FZF_TMUX_OPTS" ] + echo "fzf-tmux $FZF_TMUX_OPTS -- " + else if [ $FZF_TMUX -eq 1 ] + echo "fzf-tmux -d$FZF_TMUX_HEIGHT -- " + else + echo "fzf" + end + end + + bind \ct fzf-file-widget + bind \cr fzf-history-widget + bind \ec fzf-cd-widget + + if bind -M insert > /dev/null 2>&1 + bind -M insert \ct fzf-file-widget + bind -M insert \cr fzf-history-widget + bind -M insert \ec fzf-cd-widget + end + + function __fzf_parse_commandline -d 'Parse the current command line token and return split of existing filepath and rest of token' + # eval is used to do shell expansion on paths + set -l commandline (eval "printf '%s' "(commandline -t)) + + if [ -z $commandline ] + # Default to current directory with no --query + set dir '.' + set fzf_query '' + else + set dir (__fzf_get_dir $commandline) + + if [ "$dir" = "." -a (string sub -l 1 $commandline) != '.' ] + # if $dir is "." but commandline is not a relative path, this means no file path found + set fzf_query $commandline + else + # Also remove trailing slash after dir, to "split" input properly + set fzf_query (string replace -r "^$dir/?" '' "$commandline") + end + end + + echo $dir + echo $fzf_query + end + + function __fzf_get_dir -d 'Find the longest existing filepath from input string' + set dir $argv + + # Strip all trailing slashes. Ignore if $dir is root dir (/) + if [ (string length $dir) -gt 1 ] + set dir (string replace -r '/*$' '' $dir) + end + + # Iteratively check if dir exists and strip tail end of path + while [ ! -d "$dir" ] + # If path is absolute, this can keep going until ends up at / + # If path is relative, this can keep going until entire input is consumed, dirname returns "." + set dir (dirname "$dir") + end + + echo $dir + end + +end diff --git a/skel/.config/nvim/plugged/fzf/shell/key-bindings.zsh b/skel/.config/nvim/plugged/fzf/shell/key-bindings.zsh new file mode 100755 index 0000000..74ce9b7 --- /dev/null +++ b/skel/.config/nvim/plugged/fzf/shell/key-bindings.zsh @@ -0,0 +1,121 @@ +# ____ ____ +# / __/___ / __/ +# / /_/_ / / /_ +# / __/ / /_/ __/ +# /_/ /___/_/ key-bindings.zsh +# +# - $FZF_TMUX_OPTS +# - $FZF_CTRL_T_COMMAND +# - $FZF_CTRL_T_OPTS +# - $FZF_CTRL_R_OPTS +# - $FZF_ALT_C_COMMAND +# - $FZF_ALT_C_OPTS + +# Key bindings +# ------------ + +# The code at the top and the bottom of this file is the same as in completion.zsh. +# Refer to that file for explanation. +if 'zmodload' 'zsh/parameter' 2>'/dev/null' && (( ${+options} )); then + __fzf_key_bindings_options="options=(${(j: :)${(kv)options[@]}})" +else + () { + __fzf_key_bindings_options="setopt" + 'local' '__fzf_opt' + for __fzf_opt in "${(@)${(@f)$(set -o)}%% *}"; do + if [[ -o "$__fzf_opt" ]]; then + __fzf_key_bindings_options+=" -o $__fzf_opt" + else + __fzf_key_bindings_options+=" +o $__fzf_opt" + fi + done + } +fi + +'emulate' 'zsh' '-o' 'no_aliases' + +{ + +[[ -o interactive ]] || return 0 + +# CTRL-T - Paste the selected file path(s) into the command line +__fsel() { + local cmd="${FZF_CTRL_T_COMMAND:-"command find -L . -mindepth 1 \\( -path '*/\\.*' -o -fstype 'sysfs' -o -fstype 'devfs' -o -fstype 'devtmpfs' -o -fstype 'proc' \\) -prune \ + -o -type f -print \ + -o -type d -print \ + -o -type l -print 2> /dev/null | cut -b3-"}" + setopt localoptions pipefail no_aliases 2> /dev/null + eval "$cmd" | FZF_DEFAULT_OPTS="--height ${FZF_TMUX_HEIGHT:-40%} --reverse $FZF_DEFAULT_OPTS $FZF_CTRL_T_OPTS" $(__fzfcmd) -m "$@" | while read item; do + echo -n "${(q)item} " + done + local ret=$? + echo + return $ret +} + +__fzfcmd() { + [ -n "$TMUX_PANE" ] && { [ "${FZF_TMUX:-0}" != 0 ] || [ -n "$FZF_TMUX_OPTS" ]; } && + echo "fzf-tmux ${FZF_TMUX_OPTS:--d${FZF_TMUX_HEIGHT:-40%}} -- " || echo "fzf" +} + +fzf-file-widget() { + LBUFFER="${LBUFFER}$(__fsel)" + local ret=$? + zle reset-prompt + return $ret +} +zle -N fzf-file-widget +bindkey '^T' fzf-file-widget + +# Ensure precmds are run after cd +fzf-redraw-prompt() { + local precmd + for precmd in $precmd_functions; do + $precmd + done + zle reset-prompt +} +zle -N fzf-redraw-prompt + +# ALT-C - cd into the selected directory +fzf-cd-widget() { + local cmd="${FZF_ALT_C_COMMAND:-"command find -L . -mindepth 1 \\( -path '*/\\.*' -o -fstype 'sysfs' -o -fstype 'devfs' -o -fstype 'devtmpfs' -o -fstype 'proc' \\) -prune \ + -o -type d -print 2> /dev/null | cut -b3-"}" + setopt localoptions pipefail no_aliases 2> /dev/null + local dir="$(eval "$cmd" | FZF_DEFAULT_OPTS="--height ${FZF_TMUX_HEIGHT:-40%} --reverse $FZF_DEFAULT_OPTS $FZF_ALT_C_OPTS" $(__fzfcmd) +m)" + if [[ -z "$dir" ]]; then + zle redisplay + return 0 + fi + cd "$dir" + unset dir # ensure this doesn't end up appearing in prompt expansion + local ret=$? + zle fzf-redraw-prompt + return $ret +} +zle -N fzf-cd-widget +bindkey '\ec' fzf-cd-widget + +# CTRL-R - Paste the selected command from history into the command line +fzf-history-widget() { + local selected num + setopt localoptions noglobsubst noposixbuiltins pipefail no_aliases 2> /dev/null + selected=( $(fc -rl 1 | perl -ne 'print if !$seen{(/^\s*[0-9]+\s+(.*)/, $1)}++' | + FZF_DEFAULT_OPTS="--height ${FZF_TMUX_HEIGHT:-40%} $FZF_DEFAULT_OPTS -n2..,.. --tiebreak=index --bind=ctrl-r:toggle-sort $FZF_CTRL_R_OPTS --query=${(qqq)LBUFFER} +m" $(__fzfcmd)) ) + local ret=$? + if [ -n "$selected" ]; then + num=$selected[1] + if [ -n "$num" ]; then + zle vi-fetch-history -n $num + fi + fi + zle reset-prompt + return $ret +} +zle -N fzf-history-widget +bindkey '^R' fzf-history-widget + +} always { + eval $__fzf_key_bindings_options + 'unset' '__fzf_key_bindings_options' +} diff --git a/skel/.config/nvim/plugged/harish2704-vim/ftplugin/javascript/settings.vim b/skel/.config/nvim/plugged/harish2704-vim/ftplugin/javascript/settings.vim new file mode 100644 index 0000000..afcac6f --- /dev/null +++ b/skel/.config/nvim/plugged/harish2704-vim/ftplugin/javascript/settings.vim @@ -0,0 +1 @@ +set suffixesadd=.js,.html diff --git a/skel/.config/nvim/plugged/harish2704-vim/plugin/utils.vim b/skel/.config/nvim/plugged/harish2704-vim/plugin/utils.vim new file mode 100644 index 0000000..562ba73 --- /dev/null +++ b/skel/.config/nvim/plugged/harish2704-vim/plugin/utils.vim @@ -0,0 +1,74 @@ +let s:bundlePath = resolve( expand(':p:h' ) . '/../../' ) + +" Popout current split window to a new tab by saving curor position +fun! OpenInNewTab(fname, ... ) + " let l:cWinPos = winnr() + let l:totalWins = winnr('$') + let l:tabOffset = 0 + let l:currentTabNo = tabpagenr() + if l:totalWins == 1 + let l:tabOffset=1 + end + if exists('a:1') + if a:1 < l:currentTabNo + let l:tabOffset = 0 + endif + let l:targetTabNo = ( a:1-l:tabOffset ) + echo l:targetTabNo + if l:targetTabNo < 1 + return + endif + + let save_cursor = getcurpos() + execute 'close' + execute 'tabn'.( l:targetTabNo) + execute 'vs '.a:fname + call setpos('.', save_cursor) + else + execute 'tabedit ' . a:fname + end +endfunction + +" Open current window in n'th tab after current tab +fun! OpenInNewTabI( ... ) + if exists('a:1') + let l:targetTab = a:1 + else + let l:targetTab = input('Enter tabNo: ') + endif + call OpenInNewTab( @%, l:targetTab ) +endfunction + +fun! SpList( files, ... ) + let l:prefix = '' + let l:suffix = '' + if exists('a:1') + let l:prefix = a:1 + endif + if exists('a:2') + let l:suffix = a:2 + endif + + execute 'e ' . l:prefix . a:files[0] . l:suffix + call remove( a:files, 0 ) + for file in a:files + execute 'sp ' . l:prefix . file . l:suffix + endfor +endfunction + +fun! OpenSnippets() + let l:ftypes = split( &filetype , '\.') + + let l:prefix = s:bundlePath .'/vim-snippets/snippets/' + + let l:suffix = '.snippets' + execute 'tabnew' + call SpList( l:ftypes, l:prefix, l:suffix ) +endfunction + +" Open current window in new tab +nmap t :call OpenInNewTab(@%) +" Move current window to n'th tab +command! -nargs=? Mt call OpenInNewTabI() +" Open all snippet files for current filetype +command! OpenSnippets call OpenSnippets() diff --git a/skel/.config/nvim/plugged/nerdcommenter/.github/FUNDING.yml b/skel/.config/nvim/plugged/nerdcommenter/.github/FUNDING.yml new file mode 100644 index 0000000..dc20bd4 --- /dev/null +++ b/skel/.config/nvim/plugged/nerdcommenter/.github/FUNDING.yml @@ -0,0 +1 @@ +github: [alerque, scrooloose] diff --git a/skel/.config/nvim/plugged/nerdcommenter/.github/workflows/vint.yml b/skel/.config/nvim/plugged/nerdcommenter/.github/workflows/vint.yml new file mode 100644 index 0000000..d686760 --- /dev/null +++ b/skel/.config/nvim/plugged/nerdcommenter/.github/workflows/vint.yml @@ -0,0 +1,17 @@ +name: Vint +on: [push, pull_request] +jobs: + vint: + strategy: + fail-fast: false + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@master + - name: Run vint with reviewdog + uses: reviewdog/action-vint@v1.0.1 + with: + github_token: ${{ secrets.github_token }} + reporter: github-pr-review + + diff --git a/skel/.config/nvim/plugged/nerdcommenter/.gitignore b/skel/.config/nvim/plugged/nerdcommenter/.gitignore new file mode 100644 index 0000000..fcfaaec --- /dev/null +++ b/skel/.config/nvim/plugged/nerdcommenter/.gitignore @@ -0,0 +1,4 @@ +*~ +*.swp +tags +DEBUG diff --git a/skel/.config/nvim/plugged/nerdcommenter/README.md b/skel/.config/nvim/plugged/nerdcommenter/README.md new file mode 100644 index 0000000..dec0bb7 --- /dev/null +++ b/skel/.config/nvim/plugged/nerdcommenter/README.md @@ -0,0 +1,159 @@ +# NERD Commenter [![Vint](https://github.com/preservim/nerdcommenter/workflows/Vint/badge.svg)](https://github.com/preservim/nerdcommenter/actions?workflow=Vint) + +Comment functions so powerful—no comment necessary. + +## Installation + +### Via Plugin Manager (Recommended) + +#### [Vim-Plug](https://github.com/junegunn/vim-plug) + +1. Add `Plug 'preservim/nerdcommenter'` to your vimrc file. +2. Reload your vimrc or restart +3. Run `:PlugInstall` + +#### [Vundle](https://github.com/VundleVim/Vundle.vim) or similar + +1. Add `Plugin 'preservim/nerdcommenter'` to your vimrc file. +2. Reload your vimrc or restart +3. Run `:BundleInstall` + +#### [NeoBundle](https://github.com/Shougo/neobundle.vim) + +1. Add `NeoBundle 'preservim/nerdcommenter'` to your vimrc file. +2. Reload your vimrc or restart +3. Run `:NeoUpdate` + +#### [Pathogen](https://github.com/tpope/vim-pathogen) + +```sh +cd ~/.vim/bundle +git clone https://github.com/preservim/nerdcommenter.git +``` + +### Manual Installation + +#### Unix + +(For Neovim, change `~/.vim/` to `~/.config/nvim/`.) + +```sh +curl -fLo ~/.vim/plugin/NERD_Commenter.vim --create-dirs \ + https://raw.githubusercontent.com/preservim/nerdcommenter/master/plugin/NERD_commenter.vim +curl -fLo ~/.vim/doc/NERD_Commenter.txt --create-dirs \ + https://raw.githubusercontent.com/preservim/nerdcommenter/master/doc/NERD_commenter.txt +``` + +#### Windows (PowerShell) + +```powershell +md ~\vimfiles\plugin +md ~\vimfiles\doc +$pluguri = 'https://raw.githubusercontent.com/preservim/nerdcommenter/master/plugin/NERD_commenter.vim' +$docsuri = 'https://raw.githubusercontent.com/preservim/nerdcommenter/master/doc/NERD_commenter.txt' +(New-Object Net.WebClient).DownloadFile($pluguri, $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath("~\vimfiles\plugin\NERD_commenter.vim")) +(New-Object Net.WebClient).DownloadFile($docsuri, $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath("~\vimfiles\doc\NERD_commenter.txt")) +``` + +### Post Installation + +Make sure that you have filetype plugins enabled, as the plugin makes use of **|commentstring|** where possible (which is usually set in a filetype plugin). See **|filetype-plugin-on|** for details, but the short version is make sure this line appears in your vimrc: + +```sh +filetype plugin on +``` + +## Usage + +### Documentation + +Please see the vim help system for full documentation of all options: `:help nerdcommenter` + +### Settings + +Several settings can be added to your vimrc to change the default behavior. Some examples: + +```vim +" Add spaces after comment delimiters by default +let g:NERDSpaceDelims = 1 + +" Use compact syntax for prettified multi-line comments +let g:NERDCompactSexyComs = 1 + +" Align line-wise comment delimiters flush left instead of following code indentation +let g:NERDDefaultAlign = 'left' + +" Set a language to use its alternate delimiters by default +let g:NERDAltDelims_java = 1 + +" Add your own custom formats or override the defaults +let g:NERDCustomDelimiters = { 'c': { 'left': '/**','right': '*/' } } + +" Allow commenting and inverting empty lines (useful when commenting a region) +let g:NERDCommentEmptyLines = 1 + +" Enable trimming of trailing whitespace when uncommenting +let g:NERDTrimTrailingWhitespace = 1 + +" Enable NERDCommenterToggle to check all selected lines is commented or not +let g:NERDToggleCheckAllLines = 1 +``` + +### Default mappings + +The following key mappings are provided by default (there is also a menu provided that contains menu items corresponding to all the below mappings): + +Most of the following mappings are for normal/visual mode only. The **|NERDCommenterInsert|** mapping is for insert mode only. + + * `[count]cc` **|NERDCommenterComment|** + + Comment out the current line or text selected in visual mode. + + * `[count]cn` **|NERDCommenterNested|** + + Same as cc but forces nesting. + + * `[count]c` **|NERDCommenterToggle|** + + Toggles the comment state of the selected line(s). If the topmost selected line is commented, all selected lines are uncommented and vice versa. + + * `[count]cm` **|NERDCommenterMinimal|** + + Comments the given lines using only one set of multipart delimiters. + + * `[count]ci` **|NERDCommenterInvert|** + + Toggles the comment state of the selected line(s) individually. + + * `[count]cs` **|NERDCommenterSexy|** + + Comments out the selected lines with a pretty block formatted layout. + + * `[count]cy` **|NERDCommenterYank|** + + Same as cc except that the commented line(s) are yanked first. + + * `c$` **|NERDCommenterToEOL|** + + Comments the current line from the cursor to the end of line. + + * `cA` **|NERDCommenterAppend|** + + Adds comment delimiters to the end of line and goes into insert mode between them. + + * **|NERDCommenterInsert|** + + Adds comment delimiters at the current cursor position and inserts between. Disabled by default. + + * `ca` **|NERDCommenterAltDelims|** + + Switches to the alternative set of delimiters. + + * `[count]cl` **|NERDCommenterAlignLeft** + `[count]cb` **|NERDCommenterAlignBoth** + + Same as **|NERDCommenterComment|** except that the delimiters are aligned down the left side (`cl`) or both sides (`cb`). + + * `[count]cu` **|NERDCommenterUncomment|** + + Uncomments the selected line(s). diff --git a/skel/.config/nvim/plugged/nerdcommenter/Rakefile b/skel/.config/nvim/plugged/nerdcommenter/Rakefile new file mode 100644 index 0000000..c7bf9e6 --- /dev/null +++ b/skel/.config/nvim/plugged/nerdcommenter/Rakefile @@ -0,0 +1,76 @@ +# written by travis jeffery +# contributions by scrooloose + +require 'rake' +require 'find' +require 'pathname' + +IGNORE = [/\.gitignore$/, /Rakefile$/] + +files = `git ls-files`.split("\n") +files.reject! { |f| IGNORE.any? { |re| f.match(re) } } + +desc 'Zip up the project files' +task :zip do + zip_name = File.basename(File.dirname(__FILE__)) + zip_name.gsub!(/ /, '_') + zip_name = "#{zip_name}.zip" + + if File.exist?(zip_name) + abort("Zip file #{zip_name} already exists. Remove it first.") + end + + puts "Creating zip file: #{zip_name}" + system("zip #{zip_name} #{files.join(" ")}") +end + +desc 'Install plugin and documentation' +task :install do + vimfiles = if ENV['VIMFILES'] + ENV['VIMFILES'] + elsif RUBY_PLATFORM =~ /(win|w)32$/ + File.expand_path("~/vimfiles") + else + File.expand_path("~/.vim") + end + files.each do |file| + target_file = File.join(vimfiles, file) + FileUtils.mkdir_p File.dirname(target_file) + FileUtils.cp file, target_file + + puts "Installed #{file} to #{target_file}" + end + +end + +desc 'Pulls from origin' +task :pull do + puts "Updating local repo..." + system("cd " << Dir.new(File.dirname(__FILE__)).path << " && git pull") +end + +desc 'Calls pull task and then install task' +task :update => ['pull', 'install'] do + puts "Update of vim script complete." +end + +desc 'Uninstall plugin and documentation' +task :uninstall do + vimfiles = if ENV['VIMFILES'] + ENV['VIMFILES'] + elsif RUBY_PLATFORM =~ /(win|w)32$/ + File.expand_path("~/vimfiles") + else + File.expand_path("~/.vim") + end + files.each do |file| + target_file = File.join(vimfiles, file) + FileUtils.rm target_file + + puts "Uninstalled #{target_file}" + end + +end + +task :default => ['update'] + diff --git a/skel/.config/nvim/plugged/nerdcommenter/doc/NERD_commenter.txt b/skel/.config/nvim/plugged/nerdcommenter/doc/NERD_commenter.txt new file mode 100644 index 0000000..995c31c --- /dev/null +++ b/skel/.config/nvim/plugged/nerdcommenter/doc/NERD_commenter.txt @@ -0,0 +1,1191 @@ +*NERD_commenter.txt* Plugin for commenting code + + + NERD COMMENTER REFERENCE MANUAL~ + + + + + +============================================================================== +CONTENTS *NERDCommenterContents* + + 1.Intro...................................|NERDCommenter| + 1.1 Leader............................|NERDCommenterLeader| + 2.Installation............................|NERDCommenterInstallation| + 3.Functionality provided..................|NERDCommenterFunctionality| + 3.1 Functionality Summary.............|NERDCommenterFunctionalitySummary| + 3.2 Functionality Details.............|NERDCommenterFunctionalityDetails| + 3.2.1 Comment map.................|NERDCommenterComment| + 3.2.2 Nested comment map..........|NERDCommenterNested| + 3.2.3 Toggle comment map..........|NERDCommenterToggle| + 3.2.4 Minimal comment map.........|NERDCommenterMinimal| + 3.2.5 Invert comment map..........|NERDCommenterInvert| + 3.2.6 Sexy comment map............|NERDCommenterSexy| + 3.2.7 Yank comment map............|NERDCommenterYank| + 3.2.8 Comment to EOL map..........|NERDCommenterToEOL| + 3.2.9 Append com to line map......|NERDCommenterAppend| + 3.2.10 Insert comment map.........|NERDCommenterInsert| + 3.2.11 Use alternate delims map...|NERDCommenterAltDelims| + 3.2.12 Comment aligned maps.......|NERDCommenterAlignLeft| + |NERDCommenterAlignBoth| + 3.2.13 Uncomment line map.........|NERDCommenterUncomment| + 3.3 Sexy Comments.....................|NERDCommenterSexyComments| + 3.4 The NERDComment function..........|NERDCommenterNERDComment| + 3.5 The Hooks.........................|NERDCommenterHooks| + 4.Options.................................|NERDCommenterOptions| + 4.1 Options summary...................|NERDCommenterOptionsSummary| + 4.2 Options details...................|NERDCommenterOptionsDetails| + 4.3 Default delimiter Options.........|NERDCommenterDefaultDelims| + 5. Customising key mappings...............|NERDCommenterMappings| + 6. Interfaces.............................|NERDCommenterInterfaces| + 7. Issues with the script.................|NERDCommenterIssues| + 7.1 Delimiter detection heuristics....|NERDCommenterHeuristics| + 7.2 Nesting issues....................|NERDCommenterNesting| + 8.About.. ............................|NERDCommenterAbout| + 9.Changelog...............................|NERDCommenterChangelog| + 10.Credits................................|NERDCommenterCredits| + 11.License................................|NERDCommenterLicense| + +============================================================================== +1. Intro *NERDCommenter* + +The NERD commenter provides many different commenting operations and styles +which are invoked via key mappings and a menu. These operations are available +for most filetypes. + +There are also options that allow to tweak the commenting engine to your +taste. + +------------------------------------------------------------------------------ +1.1 Leader key *NERDCommenterLeader* + +Most NERD commenter commands are executed using the || key. In Vim +this is a key dedicated for user-specific customizations. It effectively +creates a namespace so that custom commands don't interfere with Vim's +built-in shortcuts. + +The leader key can be mapped to whatever the user likes (see :help mapleader). +In the definition of custom commands || is the placeholder for the +leader key. To see the current mapping for || type :echo mapleader. +If it reports an undefined variable it means the leader key is set to the +default of '\'. + +============================================================================== +2. Installation *NERDCommenterInstallation* + +The NERD Commenter requires Vim 7 or higher. + +Extract the plugin files in your ~/.vim (*nix) or ~/vimfiles (Windows). You +should have 2 files: > + plugin/NERD_commenter.vim + doc/NERD_commenter.txt +< +Next, to finish installing the help file run: > + :helptags ~/.vim/doc +< +See |add-local-help| for more details. + +Make sure that you have filetype plugins enabled, as the script makes use of +|'commentstring'| where possible (which is usually set in a filetype plugin). +See |filetype-plugin-on| for details, but basically, stick this in your vimrc > + filetype plugin on +< + +============================================================================== +3. Functionality provided *NERDCommenterFunctionality* + +------------------------------------------------------------------------------ +3.1 Functionality summary *NERDCommenterFunctionalitySummary* + +The following key mappings are provided by default (there is also a menu +with items corresponding to all the mappings below): + +[count]||cc |NERDCommenterComment| +Comment out the current line or text selected in visual mode. + + +[count]||cn |NERDCommenterNested| +Same as ||cc but forces nesting. + + +[count]||c |NERDCommenterToggle| +Toggles the comment state of the selected line(s). If the topmost selected +line is commented, all selected lines are uncommented and vice versa. + + +[count]||cm |NERDCommenterMinimal| +Comments the given lines using only one set of multipart delimiters. + + +[count]||ci |NERDCommenterInvert| +Toggles the comment state of the selected line(s) individually. + + +[count]||cs |NERDCommenterSexy| +Comments out the selected lines ``sexily'' + + +[count]||cy |NERDCommenterYank| +Same as ||cc except that the commented line(s) are yanked first. + + +||c$ |NERDCommenterToEOL| +Comments the current line from the cursor to the end of line. + + +||cA |NERDCommenterAppend| +Adds comment delimiters to the end of line and goes into insert mode between +them. + + +|NERDCommenterInsert| +Adds comment delimiters at the current cursor position and inserts between. +Disabled by default. + + +||ca |NERDCommenterAltDelims| +Switches to the alternative set of delimiters. + + +[count]||cl |NERDCommenterAlignLeft| +[count]||cb |NERDCommenterAlignBoth| +Same as |NERDCommenterComment| except that the delimiters are aligned down the +left side (||cl) or both sides (||cb). + + +[count]||cu |NERDCommenterUncomment| +Uncomments the selected line(s). + + +With the optional repeat.vim plugin (vimscript #2136), the mappings can also +be repeated via |.| + +------------------------------------------------------------------------------ +3.2 Functionality details *NERDCommenterFunctionalityDetails* + +------------------------------------------------------------------------------ +3.2.1 Comment map *NERDCommenterComment* + +Default mapping: [count]||cc +Mapped to: NERDCommenterComment +Applicable modes: normal visual visual-line visual-block. + + +Comments out the current line. If multiple lines are selected in visual-line +mode, they are all commented out. If some text is selected in visual or +visual-block mode then the script will try to comment out the exact text that +is selected using multi-part delimiters if they are available. + +If a [count] is given in normal mode, the mapping works as though that many +lines were selected in visual-line mode. + +------------------------------------------------------------------------------ +3.2.2 Nested comment map *NERDCommenterNested* + +Default mapping: [count]||cn +Mapped to: NERDCommenterNested +Applicable modes: normal visual visual-line visual-block. + +Performs nested commenting. Works the same as ||cc except that if a line +is already commented then it will be commented again. + +If |'NERDUsePlaceHolders'| is set then the previous comment delimiters will +be replaced by place-holder delimiters if needed. Otherwise the nested +comment will only be added if the current commenting delimiters have no right +delimiter (to avoid syntax errors) + +If a [count] is given in normal mode, the mapping works as though that many +lines were selected in visual-line mode. + +Related options: +|'NERDDefaultNesting'| + +------------------------------------------------------------------------------ +3.2.3 Toggle comment map *NERDCommenterToggle* + +Default mapping: [count]||c +Mapped to: NERDCommenterToggle +Applicable modes: normal visual-line. + +Toggles commenting of the lines selected. The behaviour of this mapping +depends on whether the first line selected is commented or not. If so, all +selected lines are uncommented and vice versa. + +With this mapping, a line is only considered to be commented if it starts with +a left delimiter. + +If a [count] is given in normal mode, the mapping works as though that many +lines were selected in visual-line mode. + +------------------------------------------------------------------------------ +3.2.4 Minimal comment map *NERDCommenterMinimal* + +Default mapping: [count]||cm +Mapped to: NERDCommenterMinimal +Applicable modes: normal visual-line. + +Comments the selected lines using one set of multipart delimiters if possible. + +For example: if you are programming in c and you select 5 lines and press +||cm then a '/*' will be placed at the start of the top line and a '*/' +will be placed at the end of the last line. + +Sets of multipart comment delimiters that are between the top and bottom +selected lines are replaced with place holders (see |'NERDLPlace'|) if +|'NERDUsePlaceHolders'| is set for the current filetype. If it is not, then +the comment will be aborted if place holders are required to prevent illegal +syntax. + +If a [count] is given in normal mode, the mapping works as though that many +lines were selected in visual-line mode. + +------------------------------------------------------------------------------ +3.2.5 Invert comment map *NERDCommenterInvert* + +Default mapping: ||ci +Mapped to: NERDCommenterInvert +Applicable modes: normal visual-line. + +Inverts the commented state of each selected line. If the selected line is +commented then it is uncommented and vice versa. Each line is examined and +commented/uncommented individually. + +With this mapping, a line is only considered to be commented if it starts with +a left delimiter. + +If a [count] is given in normal mode, the mapping works as though that many +lines were selected in visual-line mode. + +------------------------------------------------------------------------------ +3.2.6 Sexy comment map *NERDCommenterSexy* + +Default mapping: [count]||cs +Mapped to: NERDCommenterSexy +Applicable modes: normal, visual-line. + +Comments the selected line(s) ``sexily''. See |NERDCommenterSexyComments| for +a description of what sexy comments are. Can only be done on filetypes for +which there is at least one set of multipart comment delimiters specified. + +Sexy comments cannot be nested and lines inside a sexy comment cannot be +commented again. + +If a [count] is given in normal mode, the mapping works as though that many +lines were selected in visual-line mode. + +Related options: +|'NERDCompactSexyComs'| + +------------------------------------------------------------------------------ +3.2.7 Yank comment map *NERDCommenterYank* + +Default mapping: [count]||cy +Mapped to: NERDCommenterYank +Applicable modes: normal visual visual-line visual-block. + +Same as ||cc except that it yanks the line(s) that are commented first. + +------------------------------------------------------------------------------ +3.2.8 Comment to EOL map *NERDCommenterToEOL* + +Default mapping: ||c$ +Mapped to: NERDCommenterToEOL +Applicable modes: normal. + +Comments the current line from the current cursor position up to the end of +the line. + +------------------------------------------------------------------------------ +3.2.9 Append com to line map *NERDCommenterAppend* + +Default mapping: ||cA +Mapped to: NERDCommenterAppend +Applicable modes: normal. + +Appends comment delimiters to the end of the current line and goes +to insert mode between the new delimiters. + +------------------------------------------------------------------------------ +3.2.10 Insert comment map *NERDCommenterInsert* + +Default mapping: disabled by default. +Map it to: NERDCommenterInsert +Applicable modes: insert. + +Adds comment delimiters at the current cursor position and inserts +between them. + +NOTE: prior to version 2.1.17 this was mapped to . To restore this +mapping add > + imap NERDCommenterInsert +< +to your vimrc. + +------------------------------------------------------------------------------ +3.2.11 Use alternate delims map *NERDCommenterAltDelims* + +Default mapping: ||ca +Mapped to: NERDCommenterAltDelims +Applicable modes: normal. + +Changes to the alternative commenting style if one is available. For example, +if the user is editing a c++ file using // comments and they hit ||ca +then they will be switched over to /**/ comments. + +See also |NERDCommenterDefaultDelims| + +------------------------------------------------------------------------------ +3.2.12 Comment aligned maps *NERDCommenterAlignLeft* + *NERDCommenterAlignBoth* + +Default mappings: [count]||cl [count]||cb +Mapped to: NERDCommenterAlignLeft + NERDCommenterAlignBoth +Applicable modes: normal visual-line. + +Same as ||cc except that the comment delimiters are aligned on the left +side or both sides respectively. These comments are always nested if the +line(s) are already commented. + +If a [count] is given in normal mode, the mapping works as though that many +lines were selected in visual-line mode. + +------------------------------------------------------------------------------ +3.2.13 Uncomment line map *NERDCommenterUncomment* + +Default mapping: [count]||cu +Mapped to: NERDCommenterUncomment +Applicable modes: normal visual visual-line visual-block. + +Uncomments the current line. If multiple lines are selected in +visual mode then they are all uncommented. + +When uncommenting, if the line contains multiple sets of delimiters then the +``outermost'' pair of delimiters will be removed. + +The script uses a set of heuristics to distinguish ``real'' delimiters from +``fake'' ones when uncommenting. See |NERDCommenterIssues| for details. + +If a [count] is given in normal mode, the mapping works as though that many +lines were selected in visual-line mode. + +Related options: +|'NERDRemoveAltComs'| +|'NERDRemoveExtraSpaces'| + +------------------------------------------------------------------------------ +3.3 Sexy Comments *NERDCommenterSexyComments* +These are comments that use one set of multipart comment delimiters as well as +one other marker symbol. For example: > + /* + * This is a c style sexy comment + * So there! + */ + + /* This is a c style sexy comment + * So there! + * But this one is ``compact'' style */ +< +Here the multipart delimiters are /* and */ and the marker is *. + +------------------------------------------------------------------------------ +3.4 The NERDComment function *NERDCommenterNERDComment* + +All of the NERD commenter mappings and menu items invoke a single function +which delegates the commenting work to other functions. This function is +public and has the prototype: > + function! NERDComment(mode, type) +< +The arguments to this function are simple: + - mode: a character indicating the mode in which the comment is requested: + 'n' for Normal mode, 'x' for Visual mode + - type: is used to specify what type of commenting operation is to be + performed, and it can be one of the following: "sexy", "invert", + "minimal", "toggle", "alignLeft", "alignBoth", "comment", "nested", + "toEOL", "append", "insert", "uncomment", "yank" + +For example, if you typed > + :call NERDComment(1, 'sexy') +< +then the script would do a sexy comment on the last visual selection. + +------------------------------------------------------------------------------ +3.5 The hooks *NERDCommenterHooks* +|fu! NERDCommenter_before()| Before NERDComment/SwitchToAlternativeDelimiters +|fu! NERDCommenter_after()| After NERDComment/SwitchToAlternativeDelimiters + +For example, in order to handle different language blocks embedded in the same +file such as |vim-vue|, you can change the filetype, comment something and +change the filetype back: > + let g:ft = '' + fu! NERDCommenter_before() + if &ft == 'vue' + let g:ft = 'vue' + let stack = synstack(line('.'), col('.')) + if len(stack) > 0 + let syn = synIDattr((stack)[0], 'name') + if len(syn) > 0 + let syn = tolower(syn) + exe 'setf '.syn + endif + endif + endif + endfu + fu! NERDCommenter_after() + if g:ft == 'vue' + setf vue + let g:ft = '' + endif + endfu +< + +============================================================================== +4. Options *NERDCommenterOptions* + +------------------------------------------------------------------------------ +4.1 Options summary *NERDCommenterOptionsSummary* + +|'loaded_nerd_comments'| Turns off the script. + +|'NERDAllowAnyVisualDelims'| Allows multipart alternative delimiters + to be used when commenting in + visual/visual-block mode. + +|'NERDBlockComIgnoreEmpty'| Forces right delimiters to be placed + when doing visual-block comments. + +|'NERDCommentEmptyLines'| Specifies if empty lines should be + commented (useful with regions). + +|'NERDCommentWholeLinesInVMode'| Changes behaviour of visual comments. + +|'NERDCreateDefaultMappings'| Turn the default mappings on/off. + +|'NERDCustomDelimiters'| Add or override delimiters for any + filetypes. + +|'NERDDefaultNesting'| Tells the script to use nested comments + by default. + +|'NERDMenuMode'| Specifies how the NERD commenter menu + will appear (if at all). + +|'NERDLPlace'| Specifies what to use as the left + delimiter placeholder when nesting + comments. + +|'NERDUsePlaceHolders'| Specifies which filetypes may use + placeholders when nesting comments. + +|'NERDRemoveAltComs'| Tells the script whether to remove + alternative comment delimiters when + uncommenting. + +|'NERDRemoveExtraSpaces'| Tells the script to always remove the + extra spaces when uncommenting + (regardless of whether NERDSpaceDelims + is set). + +|'NERDRPlace'| Specifies what to use as the right + delimiter placeholder when nesting + comments. + +|'NERDSpaceDelims'| Specifies whether to add extra spaces + around delimiters when commenting, and + whether to remove them when + uncommenting. + +|'NERDTrimTrailingWhitespace'| Specifies if trailing whitespace + should be deleted when uncommenting. + +|'NERDCompactSexyComs'| Specifies whether to use the compact + style sexy comments. + +|'NERDDefaultAlign'| Specifies the default alignment to use, + one of 'none', 'left', 'start', or + 'both'. + +|'NERDToggleCheckAllLines'| Enable NERDCommenterToggle to check + all selected lines is commented or not. + +------------------------------------------------------------------------------ +4.3 Options details *NERDCommenterOptionsDetails* + +To enable any of the below options you should put the given line in your +~/.vimrc + + *'loaded_nerd_comments'* +If this script is driving you insane you can turn it off by setting this +option > + let loaded_nerd_comments=1 +< +------------------------------------------------------------------------------ + *'NERDAllowAnyVisualDelims'* +Values: 0 or 1. +Default: 1. + +If set to 1 then, when doing a visual or visual-block comment (but not a +visual-line comment), the script will choose the right delimiters to use for +the comment. This means either using the current delimiters if they are +multipart or using the alternative delimiters if THEY are multipart. For +example if we are editing the following java code: > + float foo = 1221; + float bar = 324; + System.out.println(foo * bar); +< +If we are using // comments and select the "foo" and "bar" in visual-block +mode, as shown left below (where '|'s are used to represent the visual-block +boundary), and comment it then the script will use the alternative delimiters +as shown on the right: > + + float |foo| = 1221; float /*foo*/ = 1221; + float |bar| = 324; float /*bar*/ = 324; + System.out.println(foo * bar); System.out.println(foo * bar); +< +------------------------------------------------------------------------------ + *'NERDBlockComIgnoreEmpty'* +Values: 0 or 1. +Default: 1. + +This option affects visual-block mode commenting. If this option is turned +on, lines that begin outside the right boundary of the selection block will be +ignored. + +For example, if you are commenting this chunk of c code in visual-block mode +(where the '|'s are used to represent the visual-block boundary) > + #include + #include + #include + |int| main(){ + | | printf("SUCK THIS\n"); + | | while(1){ + | | fork(); + | | } + |} | +< +If NERDBlockComIgnoreEmpty=0 then this code will become: > + #include + #include + #include + /*int*/ main(){ + /* */ printf("SUCK THIS\n"); + /* */ while(1){ + /* */ fork(); + /* */ } + /*} */ +< +Otherwise, the code block would become: > + #include + #include + #include + /*int*/ main(){ + printf("SUCK THIS\n"); + while(1){ + fork(); + } + /*} */ +< +------------------------------------------------------------------------------ + *'NERDCommentEmptyLines'* +Values: 0 or 1. +Default: 0. + +This option affects commenting of empty lines. If this option is turned on, +then empty lines will be commented as well. Useful when commenting regions of +code. + +------------------------------------------------------------------------------ + *'NERDCommentWholeLinesInVMode'* +Values: 0, 1 or 2. +Default: 0. + +By default the script tries to comment out exactly what is selected in visual +mode (v). For example if you select and comment the following c code (using | +to represent the visual boundary): > + in|t foo = 3; + int bar =| 9; + int baz = foo + bar; +< +This will result in: > + in/*t foo = 3;*/ + /*int bar =*/ 9; + int baz = foo + bar; +< +But some people prefer it if the whole lines are commented like: > + /*int foo = 3;*/ + /*int bar = 9;*/ + int baz = foo + bar; +< +If you prefer the second option then stick this line in your vimrc: > + let NERDCommentWholeLinesInVMode=1 +< + +If the filetype you are editing only has no multipart delimiters (for example +a shell script) and you hadn't set this option then the above would become > + in#t foo = 3; + #int bar = 9; +< +(where # is the comment delimiter) as this is the closest the script can +come to commenting out exactly what was selected. If you prefer for whole +lines to be commented out when there is no multipart delimiters but the EXACT +text that was selected to be commented out if there IS multipart delimiters +then stick the following line in your vimrc: > + let NERDCommentWholeLinesInVMode=2 +< + +Note that this option does not affect the behaviour of commenting in +|visual-block| mode. + +------------------------------------------------------------------------------ + *'NERDCreateDefaultMappings'* +Values: 0 or 1. +Default: 1. + +If set to 0, none of the default mappings will be created. + +See also |NERDCommenterMappings|. + +------------------------------------------------------------------------------ + *'NERDCustomDelimiters'* +Values: A map (format specified below). +Default: {} + +Use this option if you have new filetypes you want the script to handle, or if +you want to override the default delimiters of a filetype. + +Example: > + let g:NERDCustomDelimiters = { + \ 'ruby': { 'left': '#', 'leftAlt': 'FOO', 'rightAlt': 'BAR' }, + \ 'grondle': { 'left': '{{', 'right': '}}' } + \ } +< + +Here we override the delimiter settings for ruby and add FOO/BAR as alternative +delimiters. We also add {{ and }} as delimiters for a new filetype called +'grondle'. + +------------------------------------------------------------------------------ + *'NERDRemoveAltComs'* +Values: 0 or 1. +Default: 1. + +When uncommenting a line (for a filetype with an alternative commenting style) +this option tells the script whether to look for, and remove, comment +delimiters of the alternative style. + +For example, if you are editing a c++ file using // style comments and you go +||cu on this line: > + /* This is a c++ comment baby! */ +< +It will not be uncommented if the NERDRemoveAltComs is set to 0. + +------------------------------------------------------------------------------ + *'NERDRemoveExtraSpaces'* +Values: 0 or 1. +Default: 0. + +By default, the NERD commenter will remove spaces around comment delimiters if +either: +1. |'NERDSpaceDelims'| is set to 1. +2. NERDRemoveExtraSpaces is set to 1. + +This means that if we have the following lines in a c code file: > + /* int foo = 5; */ + /* int bar = 10; */ + int baz = foo + bar +< +If either of the above conditions hold then if these lines are uncommented +they will become: > + int foo = 5; + int bar = 10; + int baz = foo + bar +< +Otherwise they would become: > + int foo = 5; + int bar = 10; + int baz = foo + bar +< + +Note: When using 'start' as the default alignment, the enabling of +NERDRemoveExtraSpaces will still result in the removal of a space after the +delimiter. This can be undesirable since aligning the delimiters at the very +start of the line (index 0) will usually result in spaces between the comment +delimiters and the text which probably shouldn't be removed. So when using +'start' as the default alignment, take care to also disable +NERDRemoveExtraSpaces. + +------------------------------------------------------------------------------ + *'NERDLPlace'* + *'NERDRPlace'* +Values: arbitrary string. +Default: + NERDLPlace: "[>" + NERDRPlace: "<]" + +These options are used to control the strings used as place-holder delimiters. +Place holder delimiters are used when performing nested commenting when the +filetype supports commenting styles with both left and right delimiters. +To set these options use lines like: > + let NERDLPlace="FOO" + let NERDRPlace="BAR" +< +Following the above example, if we have line of c code: > + /* int horse */ +< +and we comment it with ||cn it will be changed to: > + /*FOO int horse BAR*/ +< +When we uncomment this line it will go back to what it was. + +------------------------------------------------------------------------------ + *'NERDMenuMode'* +Values: 0, 1, 2, 3. +Default: 3 + +This option can take 4 values: + "0": Turns the menu off. + "1": Turns the 'comment' menu on with no menu shortcut. + "2": Turns the 'comment' menu on with -c as the shortcut. + "3": Turns the 'Plugin -> comment' menu on with -c as the shortcut. + +------------------------------------------------------------------------------ + *'NERDUsePlaceHolders'* +Values: 0 or 1. +Default 1. + +This option is used to specify whether place-holder delimiters should be used +when creating a nested comment. + +------------------------------------------------------------------------------ + *'NERDSpaceDelims'* +Values: 0 or 1. +Default 0. + +Some people prefer a space after the left delimiter and before the right +delimiter like this: > + /* int foo=2; */ +< +as opposed to this: > + /*int foo=2;*/ +< +If you want spaces to be added then set NERDSpaceDelims to 1 in your vimrc. + +See also |'NERDRemoveExtraSpaces'|. + +------------------------------------------------------------------------------ + *'NERDTrimTrailingWhitespace'* +Values: 0 or 1. +Default 0. + +When uncommenting an empty line some whitespace may be left as a result of +alignment padding. With this option enabled any trailing whitespace will be +deleted when uncommenting a line. + +------------------------------------------------------------------------------ + *'NERDDefaultAlign'* +Values: 'none', 'left', 'start', 'both' +Default 'none'. + +Specifies the default alignment to use when inserting comments. + +Note: When using 'start' as the default alignment be sure to disable +NERDRemoveExtraSpaces. See the note at the bottom of |NERDRemoveExtraSpaces| +for more details. + +------------------------------------------------------------------------------ + *'NERDCompactSexyComs'* +Values: 0 or 1. +Default 0. + +Some people may want their sexy comments to be like this: > + /* Hi There! + * This is a sexy comment + * in c */ +< +As opposed to like this: > + /* + * Hi There! + * This is a sexy comment + * in c + */ +< +If this option is set to 1 then the top style will be used. + +------------------------------------------------------------------------------ + *'NERDDefaultNesting'* +Values: 0 or 1. +Default 1. + +When this option is set to 1, comments are nested automatically. That is, if +you hit ||cc on a line that is already commented it will be commented +again. + +------------------------------------------------------------------------------ + *'NERDToggleCheckAllLines'* +Values: 0 or 1. +Default 0. + +When this option is set to 1, NERDCommenterToggle will check all selected line, +if there have oneline not be commented, then comment all lines. + +------------------------------------------------------------------------------ + *'NERDDisableTabsInBlockComm'* +Values: 0 or 1. +Default 0. + +When this option is set to 1, NERDDisableTabsInBlockComm will not add +whitespaces align the start location of the ending comment symbol with the +end location of the starting comment symbol. For example, in Fortran, the new +style will be as the following: > + close (inpt,iostat=ierr,iomsg=error_message) + call io_error(pname,input_fname,2,__LINE__,__FILE__,ierr,error_message) +< +to > + !===BEGIN===! + ! close (inpt,iostat=ierr,iomsg=error_message) + ! call io_error(pname,input_fname,2,__LINE__,__FILE__,ierr,error_message) + !===END===! +< +for the block comment style if customized comment symbols are set up in vimrc +file by the following line > + let g:NERDCustomDelimiters = { + \ 'fortran':{'left':'!','leftAlt':'!===BEGIN===!','rightAlt':'!===END===!'} + \ } +< + +------------------------------------------------------------------------------ +3.3 Default delimiter customisation *NERDCommenterDefaultDelims* + +If you want the NERD commenter to use the alternative delimiters for a +specific filetype by default then put a line of this form into your vimrc: > + let g:NERDAltDelims_ = 1 +< +Example: java uses // style comments by default, but you want it to default to +/* */ style comments instead. You would put this line in your vimrc: > + let g:NERDAltDelims_java = 1 +< + +See |NERDCommenterAltDelims| for switching commenting styles at runtime. + +============================================================================== +5. Key mapping customisation *NERDCommenterMappings* + +To change a mapping just map another key combo to the internal mapping. +For example, to remap the |NERDCommenterComment| mapping to ",omg" you would put +this line in your vimrc: > + map ,omg NERDCommenterComment +< +This will stop the corresponding default mappings from being created. + +See the help for the mapping in question to see which mapping to +map to. + +See also |'NERDCreateDefaultMappings'|. + +============================================================================== +6. Interfaces *NERDCommenterInterfaces* + +NERDCommentIsLineCommented({lineNo}) *NERDCommentIsLineCommented()* + Check if the line is a comment + Note this function checks if the line is **completely** a comment + Args: + {lineNo}: the line number of the line to check + Return: Number, 1 if the line is a comment, 0 else + + +NERDComment({mode}, {type}) *NERDComment()* + This function is a Wrapper for the main commenting functions + + Args: + {mode}: character indicating the mode in which the comment + is requested: + 'n' for Normal mode, 'x' for Visual mode + {type}: the type of commenting requested. Can be 'Sexy', + 'Invert', 'Minimal', 'Toggle', 'AlignLeft', + 'AlignBoth', 'Comment', 'Nested', 'ToEOL', 'Append', + 'Insert', 'Uncomment', 'Yank' + + +NERDCommentIsCharCommented({line}, {col}) *NERDCommentIsCharCommented()* + Check if the character at [{line}, {col}] is inside a comment + Note the Comment delimeter it self is considered as part of the + comment + + Args: + {line} the line number of the character + {col} the column number of the character + Return: Number, 1 if the character is inside a comment, 0 else + + +============================================================================== +7. Issues with the script *NERDCommenterIssues* + + +------------------------------------------------------------------------------ +7.1 Delimiter detection heuristics *NERDCommenterHeuristics* + +Heuristics are used to distinguish the real comment delimiters + +Because we have comment mappings that place delimiters in the middle of lines, +removing comment delimiters is a bit tricky. This is because if comment +delimiters appear in a line doesn't mean they really ARE delimiters. For +example, Java uses // comments but the line > + System.out.println("//"); +< +clearly contains no real comment delimiters. + +To distinguish between ``real'' comment delimiters and ``fake'' ones we use a +set of heuristics. For example, one such heuristic states that any comment +delimiter that has an odd number of non-escaped " characters both preceding +and following it on the line is not a comment because it is probably part of a +string. These heuristics, while usually pretty accurate, will not work for all +cases. + +------------------------------------------------------------------------------ +7.2 Nesting issues *NERDCommenterNesting* + +If we have some line of code like this: > + /*int foo */ = /*5 + 9;*/ +< +This will not be uncommented legally. The NERD commenter will remove the +"outer most" delimiters so the line will become: > + int foo */ = /*5 + 9; +< +which almost certainly will not be what you want. Nested sets of comments will +uncomment fine though. E.g.: > + /*int/* foo =*/ 5 + 9;*/ +< +will become: > + int/* foo =*/ 5 + 9; +< +(Note that in the above examples I have deliberately not used place holders +for simplicity) + +============================================================================== +8. About *NERDCommenterAbout* + +The author of the NERD commenter is Martyzillatron --- the half robot, half +dinosaur bastard son of Megatron and Godzilla. He enjoys destroying +metropolises and eating tourist buses. + +Drop him a line at martin_grenfell at msn.com. He would love to hear from you. +It's a lonely life being the worlds premier terror machine. How would you feel +if your face looked like a toaster and a t-rex put together? :( + +The latest stable versions can be found at + http://www.vim.org/scripts/script.php?script_id=1218 + +The latest dev versions are on github + http://github.com/preservim/nerdcommenter + +============================================================================== +9. Changelog *NERDCommenterChangelog* + +2.3.0 + - remove all filetypes which have a &commentstring in the standard vim + runtime for vim > 7.0 unless the script stores an alternate set of + delimiters + - make the script complain if the user doesn't have filetype plugins enabled + - use || instead of comma to start the default mappings + - fix a couple of bugs with sexy comments - thanks to Tim Smart + - lots of refactoring + +2.2.2 + - remove the NERDShutup option and the message is suppresses, this makes + the plugin silently rely on &commentstring for unknown filetypes. + - add support for dhcpd, limits, ntp, resolv, rgb, sysctl, udevconf and + udevrules. Thanks to Thilo Six. + - match filetypes case insensitively + - add support for mp (metapost), thanks to Andrey Skvortsov. + - add support for htmlcheetah, thanks to Simon Hengel. + - add support for javacc, thanks to Matt Tolton. + - make <%# %> the default delims for eruby, thanks to tpope. + - add support for javascript.jquery, thanks to Ivan Devat. + - add support for cucumber and pdf. Fix sass and railslog delims, + thanks to tpope + +2.2.1 + - add support for newlisp and clojure, thanks to Matthew Lee Hinman. + - fix automake comments, thanks to Elias Pipping + - make haml comments default to -# with / as the alternative delimiter, + thanks to tpope + - add support for actionscript and processing thanks to Edwin Benavides + - add support for ps1 (powershell), thanks to Jason Mills + - add support for hostsaccess, thanks to Thomas Rowe + - add support for CVScommit + - add support for asciidoc, git and gitrebase. Thanks to Simon Ruderich. + - use # for gitcommit comments, thanks to Simon Ruderich. + - add support for mako and genshi, thanks to Keitheis. + - add support for conkyrc, thanks to David + - add support for SVNannotate, thanks to Miguel Jaque Barbero. + - add support for sieve, thanks to Stefan Walk + - add support for objj, thanks to Adam Thorsen. + +2.2.0 + - rewrote the mappings system to be more "standard". + - removed all the mapping options. Now, mappings to mappings are + used + - see :help NERDComMappings, and :help NERDCreateDefaultMappings for + more info + - remove "prepend comments" and "right aligned comments". + - add support for applescript, calbire, man, SVNcommit, potwiki, txt2tags and SVNinfo. + Thanks to nicothakis, timberke, sgronblo, mntnoe, Bernhard Grotz, John + O'Shea, François and Giacomo Mariani respectively. + - bugfix for haskell delimiters. Thanks to mntnoe. +2.1.18 + - add support for llvm. Thanks to nicothakis. + - add support for xquery. Thanks to Phillip Kovalev. +2.1.17 + - fixed haskell delimiters (hackily). Thanks to Elias Pipping. + - add support for mailcap. Thanks to Pascal Brueckner. + - add support for stata. Thanks to Jerónimo Carballo. + - applied a patch from ewfalor to fix an error in the help file with the + NERDMapleader doc + - disable the insert mode ctrl-c mapping by default, see :help + NERDCommenterInsert if you wish to restore it + +============================================================================== +10. Credits *NERDCommenterCredits* + +Thanks to the follow people for suggestions and patches: + +Nick Brettell +Matthew Hawkins +Mathieu Clabaut +Greg Searle +Nguyen +Litchi +Jorge Scandaliaris +Shufeng Zheng +Martin Stubenschrott +Markus Erlmann +Brent Rice +Richard Willis +Igor Prischepoff +Harry +David Bourgeois +Eike Von Seggern +Torsten Blix +Alexander Bosecke +Stefano Zacchiroli +Norick Chen +Joseph Barker +Gary Church +Tim Carey-Smith +Markus Klinik +Anders +Seth Mason +James Hales +Heptite +Cheng Fang +Yongwei Wu +David Miani +Jeremy Hinegardner +Marco +Ingo Karkat +Zhang Shuhan +tpope +Ben Schmidt +David Fishburn +Erik Falor +JaGoTerr +Elias Pipping +mntnoe +Mark S. +James P. Harvey + + +Thanks to the following people for sending me new filetypes to support: + +The hackers The filetypes~ +Sam R verilog +Jonathan Derque context, plaintext and mail +Vigil fetchmail +Michael Brunner kconfig +Antono Vasiljev netdict +Melissa Reid omlet +Ilia N Ternovich quickfix +John O'Shea RTF, SVNcommitlog and vcscommit, SVNCommit +Anders occam +Mark Woodward csv +fREW gentoo-package-mask, + gentoo-package-keywords, + gentoo-package-use, and vo_base +Alexey verilog_systemverilog, systemverilog +Lizendir fstab +Michael Böhler autoit, autohotkey and docbk +Aaron Small cmake +Ramiro htmldjango and django +Stefano Zacchiroli debcontrol, debchangelog, mkd +Alex Tarkovsky ebuild and eclass +Jorge Rodrigues gams +Rainer Müller Objective C +Jason Mills Groovy, ps1 +Normandie Azucena vera +Florian Apolloner ldif +David Fishburn lookupfile +Niels Aan de Brugh rst +Don Hatlestad ahk +Christophe Benz Desktop and xsd +Eyolf Østrem lilypond, bbx and lytex +Ingo Karkat dosbatch +Nicolas Weber markdown, objcpp +tinoucas gentoo-conf-d +Greg Weber D, haml +Bruce Sherrod velocity +timberke cobol, calibre +Aaron Schaefer factor +Mr X asterisk, mplayerconf +Kuchma Michael plsql +Brett Warneke spectre +Pipp lhaskell +Renald Buter scala +Vladimir Lomov asymptote +Marco mrxvtrc, aap +nicothakis SVNAnnotate, CVSAnnotate, SVKAnnotate, + SVNdiff, gitAnnotate, gitdiff, dtrace + llvm, applescript +Chen Xing Wikipedia +Jacobo Diaz dakota, patran +Li Jin gentoo-env-d, gentoo-init-d, + gentoo-make-conf, grub, modconf, sudoers +SpookeyPeanut rib +Greg Jandl pyrex/cython +Christophe Benz services, gitcommit +A Pontus vimperator +Stromnov slice, bzr +Martin Kustermann pamconf +Indriði Einarsson mason +Chris map +Krzysztof A. Adamski group +Pascal Brueckner mailcap +Jerónimo Carballo stata +Phillip Kovalev xquery +Bernhard Grotz potwiki +sgronblo man +François txt2tags +Giacomo Mariani SVNinfo +Matthew Lee Hinman newlisp, clojure +Elias Pipping automake +Edwin Benavides actionscript, processing +Thomas Rowe hostsaccess +Simon Ruderich asciidoc, git, gitcommit, gitrebase +Keitheis mako, genshi +David conkyrc +Miguel Jaque Barbero SVNannotate +Stefan Walk sieve +Adam Thorsen objj +Thilo Six dhcpd, limits, ntp, resolv, rgb, sysctl, + udevconf, udevrules +Andrey Skvortsov mp +Simon Hengel htmlcheetah +Matt Tolton javacc +Ivan Devat javascript.jquery +tpope cucumber,pdf +Lyude Paul piglit shader_test +============================================================================== +11. License *NERDCommenterLicense* + +The NERD commenter is released under the wtfpl. +See http://sam.zoy.org/wtfpl/COPYING. diff --git a/skel/.config/nvim/plugged/nerdcommenter/plugin/NERD_commenter.vim b/skel/.config/nvim/plugged/nerdcommenter/plugin/NERD_commenter.vim new file mode 100644 index 0000000..21f0a3b --- /dev/null +++ b/skel/.config/nvim/plugged/nerdcommenter/plugin/NERD_commenter.vim @@ -0,0 +1,3212 @@ +" ============================================================================ +" File: NERD_commenter.vim +" Description: vim global plugin that provides easy code commenting +" Author: Martin Grenfell +" Maintainer: Caleb Maclennan +" Version: 2.5.1 +" Last Change: Tue Nov 7 10:45:53 +03 2017 +" License: This program is free software. It comes without any warranty, +" to the extent permitted by applicable law. You can redistribute +" it and/or modify it under the terms of the Do What The Fuck You +" Want To Public License, Version 2, as published by Sam Hocevar. +" See http://sam.zoy.org/wtfpl/COPYING for more details. +" +" ============================================================================ + +" Section: script init stuff {{{1 +if exists('loaded_nerd_comments') + finish +endif +if v:version < 700 + echoerr "NERDCommenter: this plugin requires vim >= 7. DOWNLOAD IT! You'll thank me later!" + finish +endif +let loaded_nerd_comments = 1 + +" Function: s:InitVariable() function {{{2 +" This function is used to initialise a given variable to a given value. The +" variable is only initialised if it does not exist prior +" +" Args: +" -var: the name of the var to be initialised +" -value: the value to initialise var to +" +" Returns: +" 1 if the var is set, 0 otherwise +function s:InitVariable(var, value) + if !exists(a:var) + execute 'let ' . a:var . ' = ' . "'" . a:value . "'" + return 1 + endif + return 0 +endfunction + +" Section: space string init{{{2 +" When putting spaces after the left delimiter and before the right we use +" s:spaceStr for the space char. This way we can make it add anything after +" the left and before the right by modifying this variable +let s:spaceStr = ' ' +let s:lenSpaceStr = strlen(s:spaceStr) + +" Section: variable initialization {{{2 +call s:InitVariable('g:NERDAllowAnyVisualDelims', 1) +call s:InitVariable('g:NERDBlockComIgnoreEmpty', 0) +call s:InitVariable('g:NERDCommentWholeLinesInVMode', 0) +call s:InitVariable('g:NERDCommentEmptyLines', 0) +call s:InitVariable('g:NERDCompactSexyComs', 0) +call s:InitVariable('g:NERDCreateDefaultMappings', 1) +call s:InitVariable('g:NERDDefaultNesting', 1) +call s:InitVariable('g:NERDMenuMode', 3) +call s:InitVariable('g:NERDLPlace', '[>') +call s:InitVariable('g:NERDUsePlaceHolders', 1) +call s:InitVariable('g:NERDRemoveAltComs', 1) +call s:InitVariable('g:NERDRemoveExtraSpaces', 0) +call s:InitVariable('g:NERDRPlace', '<]') +call s:InitVariable('g:NERDSpaceDelims', 0) +call s:InitVariable('g:NERDDefaultAlign', 'none') +call s:InitVariable('g:NERDTrimTrailingWhitespace', 0) +call s:InitVariable('g:NERDToggleCheckAllLines', 0) +call s:InitVariable('g:NERDDisableTabsInBlockComm', 0) + +let s:NERDFileNameEscape="[]#*$%'\" ?`!&();<>\\" + +let s:delimiterMap = { + \ 'aap': { 'left': '#' }, + \ 'abc': { 'left': '%' }, + \ 'acedb': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, + \ 'actionscript': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, + \ 'ada': { 'left': '--', 'leftAlt': '-- ' }, + \ 'ahdl': { 'left': '--' }, + \ 'ahk': { 'left': ';', 'leftAlt': '/*', 'rightAlt': '*/' }, + \ 'amiga': { 'left': ';' }, + \ 'aml': { 'left': '/*' }, + \ 'ampl': { 'left': '#' }, + \ 'ansible': { 'left': '#' }, + \ 'apache': { 'left': '#' }, + \ 'apachestyle': { 'left': '#' }, + \ 'apdl': { 'left': '!' }, + \ 'applescript': { 'left': '--', 'leftAlt': '(*', 'rightAlt': '*)' }, + \ 'armasm': { 'left': ';' }, + \ 'asciidoc': { 'left': '//' }, + \ 'asm': { 'left': ';', 'leftAlt': '#' }, + \ 'asm68k': { 'left': ';' }, + \ 'asn': { 'left': '--' }, + \ 'asp': { 'left': '%', 'leftAlt': '%*', 'rightAlt': '*%' }, + \ 'aspvbs': { 'left': '''', 'leftAlt': '' }, + \ 'asterisk': { 'left': ';' }, + \ 'asy': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, + \ 'atlas': { 'left': 'C', 'right': '$' }, + \ 'augeas': { 'left': '(*', 'right': '*)' }, + \ 'autohotkey': { 'left': ';', 'leftAlt': '/*', 'rightAlt': '*/' }, + \ 'autoit': { 'left': ';' }, + \ 'ave': { 'left': "'" }, + \ 'awk': { 'left': '#' }, + \ 'basic': { 'left': "'", 'leftAlt': 'REM ' }, + \ 'bbx': { 'left': '%' }, + \ 'bc': { 'left': '#' }, + \ 'bib': { 'left': '//' }, + \ 'bindzone': { 'left': ';' }, + \ 'blade': { 'left': '{{--', 'right': '--}}' }, + \ 'bst': { 'left': '%' }, + \ 'btm': { 'left': '::' }, + \ 'c': { 'left': '/*', 'right': '*/', 'leftAlt': '//' }, + \ 'cabal': { 'left': '--' }, + \ 'calibre': { 'left': '//' }, + \ 'caos': { 'left': '*' }, + \ 'catalog': { 'left': '--', 'right': '--' }, + \ 'cf': { 'left': '' }, + \ 'cfg': { 'left': '#' }, + \ 'cg': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, + \ 'ch': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, + \ 'cl': { 'left': '#' }, + \ 'clean': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, + \ 'clipper': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, + \ 'clojure': { 'left': ';' }, + \ 'cmake': { 'left': '#' }, + \ 'cocci': { 'left': '//' }, + \ 'coffee': { 'left': '#', 'leftAlt': '###', 'rightAlt': '###' }, + \ 'conkyrc': { 'left': '#' }, + \ 'context': { 'left': '%', 'leftAlt': '--' }, + \ 'coq': { 'left': '(*', 'right': '*)' }, + \ 'cpp': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, + \ 'crontab': { 'left': '#' }, + \ 'cs': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, + \ 'csp': { 'left': '--' }, + \ 'cterm': { 'left': '*' }, + \ 'cucumber': { 'left': '#' }, + \ 'cuda': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, + \ 'cvs': { 'left': 'CVS:' }, + \ 'cython': { 'left': '# ', 'leftAlt': '#' }, + \ 'd': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, + \ 'dakota': { 'left': '#' }, + \ 'dcl': { 'left': '$!' }, + \ 'debcontrol': { 'left': '#' }, + \ 'debsources': { 'left': '#' }, + \ 'def': { 'left': ';' }, + \ 'desktop': { 'left': '#' }, + \ 'dhcpd': { 'left': '#' }, + \ 'diff': { 'left': '#' }, + \ 'django': { 'left': '{% comment %}', 'right': '{% endcomment %}', 'leftAlt': '{#', 'rightAlt': '#}' }, + \ 'dns': { 'left': ';' }, + \ 'docbk': { 'left': '' }, + \ 'dockerfile': { 'left': '#' }, + \ 'dosbatch': { 'left': 'REM ', 'leftAlt': '::' }, + \ 'dosini': { 'left': ';' }, + \ 'dot': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, + \ 'dracula': { 'left': ';' }, + \ 'dsl': { 'left': ';' }, + \ 'dtml': { 'left': '', 'right': '' }, + \ 'dylan': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, + \ 'ebuild': { 'left': '#' }, + \ 'ecd': { 'left': '#' }, + \ 'eclass': { 'left': '#' }, + \ 'eiffel': { 'left': '--' }, + \ 'elf': { 'left': "'" }, + \ 'elixir': { 'left': '#' }, + \ 'elm': { 'left': '--', 'leftAlt': '{--', 'rightAlt': '--}' }, + \ 'elmfilt': { 'left': '#' }, + \ 'ember-script': { 'left': '#' }, + \ 'emblem': { 'left': '/' }, + \ 'erlang': { 'left': '%', 'leftAlt': '%%' }, + \ 'eruby': { 'left': '<%#', 'right': '%>', 'leftAlt': '' }, + \ 'esmtprc': { 'left': '#' }, + \ 'expect': { 'left': '#' }, + \ 'exports': { 'left': '#' }, + \ 'factor': { 'left': '! ', 'leftAlt': '!# ' }, + \ 'fancy': { 'left': '#' }, + \ 'faust': { 'left': '//' }, + \ 'fgl': { 'left': '#' }, + \ 'fluent': { 'left': '#', 'leftAlt': '##' }, + \ 'focexec': { 'left': '-*' }, + \ 'form': { 'left': '*' }, + \ 'fortran': { 'left': '!' }, + \ 'foxpro': { 'left': '*' }, + \ 'fsharp': { 'left': '(*', 'right': '*)', 'leftAlt': '//' }, + \ 'fstab': { 'left': '#' }, + \ 'fvwm': { 'left': '#' }, + \ 'fx': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, + \ 'gams': { 'left': '*' }, + \ 'gdb': { 'left': '#' }, + \ 'gdmo': { 'left': '--' }, + \ 'gdscript3': { 'left': '# ', 'leftAlt': '#' }, + \ 'geek': { 'left': 'GEEK_COMMENT:' }, + \ 'genshi': { 'left': '', 'leftAlt': '{#', 'rightAlt': '#}' }, + \ 'gentoo-conf-d': { 'left': '#' }, + \ 'gentoo-env-d': { 'left': '#' }, + \ 'gentoo-init-d': { 'left': '#' }, + \ 'gentoo-make-conf': { 'left': '#' }, + \ 'gentoo-package-keywords': { 'left': '#' }, + \ 'gentoo-package-mask': { 'left': '#' }, + \ 'gentoo-package-use': { 'left': '#' }, + \ 'gitcommit': { 'left': '#' }, + \ 'gitconfig': { 'left': ';' }, + \ 'gitignore': { 'left': '#' }, + \ 'gitrebase': { 'left': '#' }, + \ 'glsl': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, + \ 'gnuplot': { 'left': '#' }, + \ 'go': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, + \ 'groff': { 'left': '\#' }, + \ 'groovy': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, + \ 'gsp': { 'left': '<%--', 'right': '--%>', 'leftAlt': '' }, + \ 'gtkrc': { 'left': '#' }, + \ 'h': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, + \ 'haml': { 'left': '-#', 'leftAlt': '/' }, + \ 'handlebars': { 'left': '{{!-- ', 'right': ' --}}' }, + \ 'haskell': { 'left': '--', 'nested': 0, 'leftAlt': '{-', 'rightAlt': '-}', 'nestedAlt': 1 }, + \ 'haxe': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, + \ 'hb': { 'left': '#' }, + \ 'hbs': { 'left': '{{!-- ', 'right': ' --}}' }, + \ 'hercules': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, + \ 'hive': { 'left': '-- ' }, + \ 'hog': { 'left': '#' }, + \ 'hostsaccess': { 'left': '#' }, + \ 'htmlcheetah': { 'left': '##' }, + \ 'htmldjango': { 'left': '{% comment %}', 'right': '{% endcomment %}', 'leftAlt': '{#', 'rightAlt': '#}' }, + \ 'htmlos': { 'left': '#', 'right': '/#' }, + \ 'hxml': { 'left': '#' }, + \ 'hyphy': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, + \ 'ia64': { 'left': '#' }, + \ 'icon': { 'left': '#' }, + \ 'idl': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, + \ 'idlang': { 'left': ';' }, + \ 'idris': { 'leftAlt': '--', 'left': '{-', 'right': '-}' }, + \ 'incar': { 'left': '!' }, + \ 'inform': { 'left': '!' }, + \ 'inittab': { 'left': '#' }, + \ 'ishd': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, + \ 'iss': { 'left': ';' }, + \ 'ist': { 'left': '%' }, + \ 'jade': { 'left': '//-', 'leftAlt': '//' }, + \ 'java': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, + \ 'javacc': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, + \ 'javascript': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, + \ 'javascriptreact': { 'left': '//', 'leftAlt': '{/*', 'rightAlt': '*/}' }, + \ 'javascript.jquery': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, + \ 'jess': { 'left': ';' }, + \ 'jgraph': { 'left': '(*', 'right': '*)' }, + \ 'jinja': { 'left': '{#', 'right': '#}', 'leftAlt': '' }, + \ 'jproperties': { 'left': '#' }, + \ 'jsp': { 'left': '<%--', 'right': '--%>' }, + \ 'julia': { 'left': '# ', 'leftAlt': '#=', 'rightAlt': '=#' }, + \ 'kivy': { 'left': '#' }, + \ 'kix': { 'left': ';' }, + \ 'kscript': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, + \ 'lace': { 'left': '--' }, + \ 'laravel': { 'left': '{{--', 'right': '--}}' }, + \ 'ldif': { 'left': '#' }, + \ 'ledger': { 'left': '#', 'leftAlt': ';' }, + \ 'less': { 'left': '/*', 'right': '*/' }, + \ 'lhaskell': { 'left': '>{-', 'right': '-}', 'leftAlt': '>-- ' }, + \ 'lilo': { 'left': '#' }, + \ 'lilypond': { 'left': '%' }, + \ 'liquid': { 'left': '{% comment %}', 'right': '{% endcomment %}' }, + \ 'lisp': { 'left': ';', 'nested': 1, 'leftAlt': '#|', 'rightAlt': '|#', 'nestedAlt': 1 }, + \ 'llvm': { 'left': ';' }, + \ 'lotos': { 'left': '(*', 'right': '*)' }, + \ 'lout': { 'left': '#' }, + \ 'lpc': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, + \ 'lprolog': { 'left': '%' }, + \ 'lscript': { 'left': "'" }, + \ 'lss': { 'left': '#' }, + \ 'lua': { 'left': '--', 'leftAlt': '--[[', 'rightAlt': ']]' }, + \ 'lynx': { 'left': '#' }, + \ 'lytex': { 'left': '%' }, + \ 'm4': { 'left': 'dnl ' }, + \ 'mail': { 'left': '> ' }, + \ 'mako': { 'left': '##' }, + \ 'man': { 'left': '."' }, + \ 'mandoc': { 'left': '.\\"' }, + \ 'map': { 'left': '%' }, + \ 'maple': { 'left': '#' }, + \ 'markdown': { 'left': '' }, + \ 'masm': { 'left': ';' }, + \ 'mason': { 'left': '<% #', 'right': '%>' }, + \ 'master': { 'left': '$' }, + \ 'matlab': { 'left': '%', 'leftAlt': '%{', 'rightAlt': '%}' }, + \ 'mel': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, + \ 'meson': { 'left': '#' }, + \ 'mib': { 'left': '--' }, + \ 'minizinc': { 'left': '% ', 'leftAlt': '/*', 'rightAlt': '*/' }, + \ 'mips': { 'left': '#' }, + \ 'mirah': {'left': '#' }, + \ 'mkd': { 'left': '' }, + \ 'mma': { 'left': '(*', 'right': '*)' }, + \ 'model': { 'left': '$', 'right': '$' }, + \ 'modula2': { 'left': '(*', 'right': '*)' }, + \ 'modula3': { 'left': '(*', 'right': '*)' }, + \ 'molpro': { 'left': '!' }, + \ 'monk': { 'left': ';' }, + \ 'mush': { 'left': '#' }, + \ 'mustache': { 'left': '{{!', 'right': '}}' }, + \ 'nagios': { 'left': ';' }, + \ 'named': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, + \ 'nasm': { 'left': ';' }, + \ 'nastran': { 'left': '$' }, + \ 'natural': { 'left': '/*' }, + \ 'ncf': { 'left': ';' }, + \ 'newlisp': { 'left': ';' }, + \ 'nginx': { 'left': '#' }, + \ 'nimrod': { 'left': '#' }, + \ 'nroff': { 'left': '\"' }, + \ 'nsis': { 'left': '#' }, + \ 'ntp': { 'left': '#' }, + \ 'objc': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, + \ 'objcpp': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, + \ 'objj': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, + \ 'ocaml': { 'left': '(*', 'right': '*)', 'nested': 1 }, + \ 'occam': { 'left': '--' }, + \ 'octave': { 'left': '%', 'leftAlt': '#' }, + \ 'omlet': { 'left': '(*', 'right': '*)' }, + \ 'omnimark': { 'left': ';' }, + \ 'ooc': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, + \ 'openroad': { 'left': '//' }, + \ 'opl': { 'left': 'REM' }, + \ 'ora': { 'left': '#' }, + \ 'ox': { 'left': '//' }, + \ 'paludis-use-conf': { 'left': '#' }, + \ 'pandoc': { 'left': '' }, + \ 'pascal': { 'left': '{', 'right': '}', 'leftAlt': '(*', 'rightAlt': '*)' }, + \ 'patran': { 'left': '$', 'leftAlt': '/*', 'rightAlt': '*/' }, + \ 'pcap': { 'left': '#' }, + \ 'pccts': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, + \ 'pdf': { 'left': '%' }, + \ 'perl': { 'left': '#' }, + \ 'pfmain': { 'left': '//' }, + \ 'php': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, + \ 'pic': { 'left': ';' }, + \ 'pike': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, + \ 'pilrc': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, + \ 'pine': { 'left': '#' }, + \ 'plm': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, + \ 'plsql': { 'left': '-- ', 'leftAlt': '/*', 'rightAlt': '*/' }, + \ 'po': { 'left': '#' }, + \ 'poscar': { 'left': '!' }, + \ 'postscr': { 'left': '%' }, + \ 'pov': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, + \ 'povini': { 'left': ';' }, + \ 'ppd': { 'left': '%' }, + \ 'ppwiz': { 'left': ';;' }, + \ 'praat': { 'left': '#' }, + \ 'privoxy': { 'left': '#' }, + \ 'processing': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, + \ 'prolog': { 'left': '%', 'leftAlt': '/*', 'rightAlt': '*/' }, + \ 'proto': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, + \ 'ps1': { 'left': '#' }, + \ 'psf': { 'left': '#' }, + \ 'ptcap': { 'left': '#' }, + \ 'pug': { 'left': '//-', 'leftAlt': '//' }, + \ 'puppet': { 'left': '#' }, + \ 'pyrex': { 'left': '# ', 'leftAlt': '#' }, + \ 'python': { 'left': '# ', 'leftAlt': '#' }, + \ 'r': { 'left': '#', 'leftAlt': '#''' }, + \ 'racket': { 'left': ';', 'nested': 1, 'leftAlt': '#|', 'rightAlt': '|#', 'nestedAlt': 1 }, + \ 'radiance': { 'left': '#' }, + \ 'ratpoison': { 'left': '#' }, + \ 'rc': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, + \ 'rebol': { 'left': ';' }, + \ 'registry': { 'left': ';' }, + \ 'remind': { 'left': '#' }, + \ 'renpy': { 'left': '# ' }, + \ 'resolv': { 'left': '#' }, + \ 'rgb': { 'left': '!' }, + \ 'rib': { 'left': '#' }, + \ 'rmd': { 'left': '', 'leftalt': '#' }, + \ 'robot': { 'left': '#' }, + \ 'robots': { 'left': '#' }, + \ 'rspec': { 'left': '#' }, + \ 'ruby': { 'left': '#' }, + \ 'rust': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, + \ 'sa': { 'left': '--' }, + \ 'samba': { 'left': ';', 'leftAlt': '#' }, + \ 'sass': { 'left': '//', 'leftAlt': '/*' }, + \ 'sather': { 'left': '--' }, + \ 'scala': { 'left': '//', 'nested': 1, 'leftAlt': '/*', 'rightAlt': '*/', 'nestedAlt': 1 }, + \ 'scheme': { 'left': ';', 'nested': 1, 'leftAlt': '#|', 'rightAlt': '|#', 'nestedAlt': 1 }, + \ 'scilab': { 'left': '//' }, + \ 'scilla': { 'left': '(*', 'right': '*)', 'nested': 1 }, + \ 'scons': { 'left': '#' }, + \ 'scsh': { 'left': ';' }, + \ 'scss': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, + \ 'sdc': { 'left': '#' }, + \ 'sed': { 'left': '#' }, + \ 'sentinel': { 'left': '#', 'leftAlt': '/*', 'rightAlt': '*/' }, + \ 'sgmldecl': { 'left': '--', 'right': '--' }, + \ 'sgmllnx': { 'left': '' }, + \ 'sh': { 'left': '#' }, + \ 'shader_test': { 'left': '#' }, + \ 'sicad': { 'left': '*' }, + \ 'sile': { 'left': '%' }, + \ 'simula': { 'left': '%', 'leftAlt': '--' }, + \ 'sinda': { 'left': '$' }, + \ 'skill': { 'left': ';' }, + \ 'slang': { 'left': '%' }, + \ 'slice': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, + \ 'slim': { 'left': '/', 'leftAlt': '/!' }, + \ 'slrnrc': { 'left': '%' }, + \ 'sls': { 'left': '#' }, + \ 'sm': { 'left': '#' }, + \ 'smarty': { 'left': '{*', 'right': '*}' }, + \ 'smil': { 'left': '' }, + \ 'smith': { 'left': ';' }, + \ 'sml': { 'left': '(*', 'right': '*)', 'nested': 1 }, + \ 'snakemake': { 'left': '#' }, + \ 'snippets': { 'left': '#' }, + \ 'snnsnet': { 'left': '#' }, + \ 'snnspat': { 'left': '#' }, + \ 'snnsres': { 'left': '#' }, + \ 'snobol4': { 'left': '*' }, + \ 'spec': { 'left': '#' }, + \ 'specman': { 'left': '//' }, + \ 'spectre': { 'left': '//', 'leftAlt': '*' }, + \ 'spice': { 'left': '$' }, + \ 'spin': { 'left': '''', 'leftAlt': '{', 'rightAlt': '}' }, + \ 'sql': { 'left': '-- ', 'leftAlt': '/*', 'rightAlt': '*/' }, + \ 'sqlforms': { 'left': '-- ' }, + \ 'sqlj': { 'left': '-- ' }, + \ 'sqr': { 'left': '!' }, + \ 'squid': { 'left': '#' }, + \ 'ss': { 'left': ';', 'leftAlt': '#|', 'rightAlt': '|#' }, + \ 'sshconfig': { 'left': '#' }, + \ 'sshdconfig': { 'left': '#' }, + \ 'st': { 'left': '"' }, + \ 'stan': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, + \ 'stp': { 'left': '/*', 'right': '*/', 'leftAlt': '//' }, + \ 'supercollider': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, + \ 'swift': { 'left': '/*', 'right': '*/', 'leftAlt': '//' }, + \ 'systemverilog': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, + \ 'tads': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, + \ 'tags': { 'left': ';' }, + \ 'tak': { 'left': '$' }, + \ 'tasm': { 'left': ';' }, + \ 'tcl': { 'left': '#' }, + \ 'teak': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, + \ 'terraform': { 'left': '#', 'leftAlt': '/*', 'rightAlt': '*/' }, + \ 'tex': { 'left': '%' }, + \ 'texinfo': { 'left': '@c ' }, + \ 'texmf': { 'left': '%' }, + \ 'tf': { 'left': '#' }, + \ 'tidy': { 'left': '#' }, + \ 'tli': { 'left': '#' }, + \ 'tmux': { 'left': '#' }, + \ 'toml': { 'left': '#' }, + \ 'trasys': { 'left': '$' }, + \ 'troff': { 'left': '.\\"' }, + \ 'tsalt': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, + \ 'tsscl': { 'left': '#' }, + \ 'tssgm': { 'left': "comment = '", 'right': "'" }, + \ 'ttl': { 'left': '#' }, + \ 'tup': { 'left': '#' }, + \ 'twig': { 'left': '{#', 'right': '#}' }, + \ 'txt2tags': { 'left': '%' }, + \ 'typescript': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, + \ 'typescriptreact': { 'left': '//', 'leftAlt': '{/*', 'rightAlt': '*/}' }, + \ 'uc': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, + \ 'uil': { 'left': '!' }, + \ 'upstart': { 'left': '#' }, + \ 'vala': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, + \ 'vasp': { 'left': '!' }, + \ 'vb': { 'left': "'" }, + \ 'velocity': { 'left': '##', 'right': '', 'leftAlt': '#*', 'rightAlt': '*#' }, + \ 'vera': { 'left': '/*', 'right': '*/', 'leftAlt': '//' }, + \ 'verilog': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, + \ 'verilog_systemverilog': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, + \ 'vgrindefs': { 'left': '#' }, + \ 'vhdl': { 'left': '--' }, + \ 'vimperator': { 'left': '"' }, + \ 'virata': { 'left': '%' }, + \ 'vrml': { 'left': '#' }, + \ 'vsejcl': { 'left': '/*' }, + \ 'webmacro': { 'left': '##' }, + \ 'wget': { 'left': '#' }, + \ 'wikipedia': { 'left': '' }, + \ 'winbatch': { 'left': ';' }, + \ 'wml': { 'left': '#' }, + \ 'wvdial': { 'left': ';' }, + \ 'xdefaults': { 'left': '!' }, + \ 'xkb': { 'left': '//' }, + \ 'xmath': { 'left': '#' }, + \ 'xpm2': { 'left': '!' }, + \ 'xquery': { 'left': '(:', 'right': ':)' }, + \ 'yaml': { 'left': '#' }, + \ 'z8a': { 'left': ';' } + \ } + +let g:NERDDelimiterMap = s:delimiterMap + +if exists('g:NERDCustomDelimiters') + call extend(s:delimiterMap, g:NERDCustomDelimiters) +endif + +" Section: Comment mapping functions, autocommands and commands {{{1 +" ============================================================================ +" Section: Comment enabler autocommands {{{2 +" ============================================================================ + +augroup NERDCommenter + + "if the user enters a buffer or reads a buffer then we gotta set up + "the comment delimiters for that new filetype + autocmd BufEnter,BufRead * :call s:SetUpForNewFiletype(&filetype, 0) + + "if the filetype of a buffer changes, force the script to reset the + "delimiters for the buffer + autocmd Filetype * :call s:SetUpForNewFiletype(&filetype, 1) +augroup END + + +" Function: s:SetUpForNewFiletype(filetype) function {{{2 +" This function is responsible for setting up buffer scoped variables for the +" given filetype. +" +" Args: +" -filetype: the filetype to set delimiters for +" -forceReset: 1 if the delimiters should be reset if they have already be +" set for this buffer. +" +function s:SetUpForNewFiletype(filetype, forceReset) + let filetype = a:filetype + + "for compound filetypes, if we don't know how to handle the full filetype + "then break it down and use the first part that we know how to handle + if filetype =~# '\.' && !has_key(s:delimiterMap, filetype) + let filetypes = split(a:filetype, '\.') + for i in filetypes + if has_key(s:delimiterMap, i) + let filetype = i + break + endif + endfor + endif + + let b:NERDSexyComMarker = '' + + if has_key(s:delimiterMap, filetype) + let b:NERDCommenterDelims = s:delimiterMap[filetype] + for i in ['left', 'leftAlt', 'right', 'rightAlt'] + if !has_key(b:NERDCommenterDelims, i) + let b:NERDCommenterDelims[i] = '' + endif + endfor + for i in ['nested', 'nestedAlt'] + if !has_key(b:NERDCommenterDelims, i) + let b:NERDCommenterDelims[i] = 0 + endif + endfor + " if g:NERD__alt_style is defined, use the alternate style + let b:NERDCommenterFirstInit = getbufvar(1,'NERDCommenterFirstInit') + if exists('g:NERDAltDelims_'.filetype) && eval('g:NERDAltDelims_'.filetype) && !b:NERDCommenterFirstInit + call s:SwitchToAlternativeDelimiters(0) + let b:NERDCommenterFirstInit = 1 + endif + else + let b:NERDCommenterDelims = s:CreateDelimMapFromCms() + endif + +endfunction + +function s:CreateDelimMapFromCms() + if &filetype ==# '' && exists('g:NERDDefaultDelims') + let delims = g:NERDDefaultDelims + for i in ['left', 'leftAlt', 'right', 'rightAlt'] + if !has_key(delims, i) + let delims[i] = '' + endif + endfor + return delims + endif + return { + \ 'left': substitute(&commentstring, '\([^ \t]*\)\s*%s.*', '\1', ''), + \ 'right': substitute(&commentstring, '.*%s\s*\(.*\)', '\1', 'g'), + \ 'nested': 0, + \ 'leftAlt': '', + \ 'rightAlt': '', + \ 'nestedAlt': 0} +endfunction + +" Function: s:SwitchToAlternativeDelimiters(printMsgs) function {{{2 +" This function is used to swap the delimiters that are being used to the +" alternative delimiters for that filetype. For example, if a c++ file is +" being edited and // comments are being used, after this function is called +" /**/ comments will be used. +" +" Args: +" -printMsgs: if this is 1 then a message is echoed to the user telling them +" if this function changed the delimiters or not +function s:SwitchToAlternativeDelimiters(printMsgs) + if exists('*NERDCommenter_before') + exe 'call NERDCommenter_before()' + endif + "if both of the alternative delimiters are empty then there is no + "alternative comment style so bail out + if b:NERDCommenterDelims['leftAlt'] ==# '' && b:NERDCommenterDelims['rightAlt'] ==# '' + if a:printMsgs + call s:NerdEcho('Cannot use alternative delimiters, none are specified', 0) + endif + return 0 + endif + + "save the current delimiters + let tempLeft = s:Left() + let tempRight = s:Right() + let tempNested = s:Nested() + + "swap current delimiters for alternative + let b:NERDCommenterDelims['left'] = b:NERDCommenterDelims['leftAlt'] + let b:NERDCommenterDelims['right'] = b:NERDCommenterDelims['rightAlt'] + "set information on whether these are nested + let b:NERDCommenterDelims['nested'] = b:NERDCommenterDelims['nestedAlt'] + + "set the previously current delimiters to be the new alternative ones + let b:NERDCommenterDelims['leftAlt'] = tempLeft + let b:NERDCommenterDelims['rightAlt'] = tempRight + let b:NERDCommenterDelims['nestedAlt'] = tempNested + + "tell the user what comment delimiters they are now using + if a:printMsgs + call s:NerdEcho('Now using ' . s:Left() . ' ' . s:Right() . ' to delimit comments', 1) + endif + + if exists('*NERDCommenter_after') + exe 'call NERDCommenter_after()' + endif + + return 1 +endfunction + +" Section: Comment delimiter add/removal functions {{{1 +" ============================================================================ +" Function: s:AppendCommentToLine(){{{2 +" This function appends comment delimiters at the EOL and places the cursor in +" position to start typing the comment +function s:AppendCommentToLine() + let left = s:Left({'space': 1}) + let right = s:Right({'space': 1}) + + " get the length of the right delimiter + let lenRight = strlen(right) + + let isLineEmpty = strlen(getline('.')) ==# 0 + let insOrApp = (isLineEmpty==#1 ? 'i' : 'A') + + "stick the delimiters down at the end of the line. We have to format the + "comment with spaces as appropriate + execute ':normal! ' . insOrApp . (isLineEmpty ? '' : ' ') . left . right + + " if there is a right delimiter then we gotta move the cursor left + " by the length of the right delimiter so we insert between the delimiters + if lenRight > 0 + let leftMoveAmount = lenRight - 1 + execute ':normal! ' . leftMoveAmount . 'h' + startinsert + else + startinsert! + endif +endfunction + +" Function: s:CommentBlock(top, bottom, lSide, rSide, forceNested ) {{{2 +" This function is used to comment out a region of code. This region is +" specified as a bounding box by arguments to the function. +" +" Args: +" -top: the line number for the top line of code in the region +" -bottom: the line number for the bottom line of code in the region +" -lSide: the column number for the left most column in the region +" -rSide: the column number for the right most column in the region +" -forceNested: a flag indicating whether comments should be nested +function s:CommentBlock(top, bottom, lSide, rSide, forceNested ) + " we need to create local copies of these arguments so we can modify them + let top = a:top + let bottom = a:bottom + let lSide = a:lSide + let rSide = a:rSide + + "if the top or bottom line starts with tabs we have to adjust the left and + "right boundaries so that they are set as though the tabs were spaces + let topline = getline(top) + let bottomline = getline(bottom) + if s:HasLeadingTabs(topline, bottomline) + + "find out how many tabs are in the top line and adjust the left + "boundary accordingly + let numTabs = s:NumberOfLeadingTabs(topline) + if lSide < numTabs + let lSide = &tabstop * lSide + else + let lSide = (lSide - numTabs) + (&tabstop * numTabs) + endif + + "find out how many tabs are in the bottom line and adjust the right + "boundary accordingly + let numTabs = s:NumberOfLeadingTabs(bottomline) + let rSide = (rSide - numTabs) + (&tabstop * numTabs) + endif + + "we must check that bottom IS actually below top, if it is not then we + "swap top and bottom. Similarly for left and right. + if bottom < top + let temp = top + let top = bottom + let bottom = top + endif + if rSide < lSide + let temp = lSide + let lSide = rSide + let rSide = temp + endif + + "if the current delimiters aren't multipart then we will switch to the + "alternative delimiters (if THEY are) as the comment will be better and more + "accurate with multipart delimiters + let switchedDelims = 0 + if !s:Multipart() && g:NERDAllowAnyVisualDelims && s:AltMultipart() + let switchedDelims = 1 + call s:SwitchToAlternativeDelimiters(0) + endif + + "start the commenting from the top and keep commenting till we reach the + "bottom + let currentLine=top + while currentLine <= bottom + + "check if we are allowed to comment this line + if s:CanCommentLine(a:forceNested, currentLine) + + "convert the leading tabs into spaces + let theLine = getline(currentLine) + let lineHasLeadTabs = s:HasLeadingTabs(theLine) + if lineHasLeadTabs + let theLine = s:ConvertLeadingTabsToSpaces(theLine) + endif + + "don't comment lines that begin after the right boundary of the + "block unless the user has specified to do so + if theLine !~# '^ \{' . rSide . '\}' || !g:NERDBlockComIgnoreEmpty + + "attempt to place the cursor in on the left of the boundary box, + "then check if we were successful, if not then we cant comment this + "line + call setline(currentLine, theLine) + if s:CanPlaceCursor(currentLine, lSide) + + let leftSpaced = s:Left({'space': 1}) + let rightSpaced = s:Right({'space': 1}) + + "stick the left delimiter down + let theLine = strpart(theLine, 0, lSide-1) . leftSpaced . strpart(theLine, lSide-1) + + if s:Multipart() + "stick the right delimiter down + let theLine = strpart(theLine, 0, rSide+strlen(leftSpaced)) . rightSpaced . strpart(theLine, rSide+strlen(leftSpaced)) + + let firstLeftDelim = s:FindDelimiterIndex(s:Left(), theLine) + let lastRightDelim = s:LastIndexOfDelim(s:Right(), theLine) + + if firstLeftDelim !=# -1 && lastRightDelim !=# -1 + let searchStr = strpart(theLine, 0, lastRightDelim) + let searchStr = strpart(searchStr, firstLeftDelim+strlen(s:Left())) + + "replace the outer most delimiters in searchStr with + "place-holders + let theLineWithPlaceHolders = s:ReplaceDelims(s:Left(), s:Right(), g:NERDLPlace, g:NERDRPlace, searchStr) + + "add the right delimiter onto the line + let theLine = strpart(theLine, 0, firstLeftDelim+strlen(s:Left())) . theLineWithPlaceHolders . strpart(theLine, lastRightDelim) + endif + endif + endif + endif + + "restore tabs if needed + if lineHasLeadTabs + let theLine = s:ConvertLeadingSpacesToTabs(theLine) + endif + + if g:NERDTrimTrailingWhitespace ==# 1 + let theLine = s:TrimTrailingWhitespace(theLine) + endif + + call setline(currentLine, theLine) + endif + + let currentLine = currentLine + 1 + endwhile + + "if we switched delimiterss then we gotta go back to what they were before + if switchedDelims ==# 1 + call s:SwitchToAlternativeDelimiters(0) + endif +endfunction + +" Function: s:CommentLines(forceNested, alignLeft, alignRight, firstLine, lastLine) {{{2 +" This function comments a range of lines. +" +" Args: +" -forceNested: a flag indicating whether the called is requesting the comment +" to be nested if need be +" -align: should be "left", "start", "both" or "none" +" -firstLine/lastLine: the top and bottom lines to comment +function s:CommentLines(forceNested, align, firstLine, lastLine) + " we need to get the left and right indexes of the leftmost char in the + " block of of lines and the right most char so that we can do alignment of + " the delimiters if the user has specified + let leftAlignIndx = a:align ==# 'start' ? 0 : s:LeftMostIndx(a:forceNested, 0, a:firstLine, a:lastLine) + let rightAlignIndx = s:RightMostIndx(a:forceNested, 0, a:firstLine, a:lastLine) + + " gotta add the length of the left delimiter onto the rightAlignIndx cos + " we'll be adding a left delimiter to the line + let rightAlignIndx = rightAlignIndx + strlen(s:Left({'space': 1})) + + " now we actually comment the lines. Do it line by line + let currentLine = a:firstLine + while currentLine <= a:lastLine + + " get the next line, check commentability and convert spaces to tabs + let theLine = getline(currentLine) + let lineHasLeadingTabs = s:HasLeadingTabs(theLine) + let theLine = s:ConvertLeadingTabsToSpaces(theLine) + if s:CanCommentLine(a:forceNested, currentLine) + "if the user has specified forceNesting then we check to see if we + "need to switch delimiters for place-holders + if a:forceNested && g:NERDUsePlaceHolders && !s:Nested() + let theLine = s:SwapOuterMultiPartDelimsForPlaceHolders(theLine) + endif + + " find out if the line is commented using normal delimiters and/or + " alternate ones + let isCommented = s:IsCommented(s:Left(), s:Right(), theLine) || s:IsCommented(s:Left({'alt': 1}), s:Right({'alt': 1}), theLine) + + " check if we can comment this line + if !isCommented || g:NERDUsePlaceHolders || s:Multipart() + if a:align ==# 'left' || a:align ==# 'start' || a:align ==# 'both' + let theLine = s:AddLeftDelimAligned(s:Left({'space': 1}), theLine, leftAlignIndx) + else + let theLine = s:AddLeftDelim(s:Left({'space': 1}), theLine) + endif + if a:align ==# 'both' + let theLine = s:AddRightDelimAligned(s:Right({'space': 1}), theLine, rightAlignIndx) + else + let theLine = s:AddRightDelim(s:Right({'space': 1}), theLine) + endif + endif + endif + + " restore leading tabs if appropriate + if lineHasLeadingTabs + let theLine = s:ConvertLeadingSpacesToTabs(theLine) + endif + + if g:NERDTrimTrailingWhitespace ==# 1 + let theLine = s:TrimTrailingWhitespace(theLine) + endif + + " we are done with this line + call setline(currentLine, theLine) + let currentLine = currentLine + 1 + endwhile + +endfunction + +" Function: s:CommentLinesMinimal(firstLine, lastLine) {{{2 +" This function comments a range of lines in a minimal style. I +" +" Args: +" -firstLine/lastLine: the top and bottom lines to comment +function s:CommentLinesMinimal(firstLine, lastLine) + "check that minimal comments can be done on this filetype + if !s:HasMultipartDelims() + throw 'NERDCommenter.Delimiters exception: Minimal comments can only be used for filetypes that have multipart delimiters' + endif + + let sexyNested = s:SexyNested() + + "if we need to use place holders for the comment, make sure they are + "enabled for this filetype, or the delimiterss allow nesting + if !g:NERDUsePlaceHolders && !sexyNested && s:DoesBlockHaveMultipartDelim(a:firstLine, a:lastLine) + throw 'NERDCommenter.Settings exception: Place holders are required but disabled.' + endif + + "get the left and right delimiters to smack on + let left = s:GetSexyComLeft(g:NERDSpaceDelims,0) + let right = s:GetSexyComRight(g:NERDSpaceDelims,0) + + "make sure all multipart delimiters on the lines are replaced with + "placeholders to prevent illegal syntax + if !sexyNested + let currentLine = a:firstLine + while(currentLine <= a:lastLine) + let theLine = getline(currentLine) + let theLine = s:ReplaceDelims(left, right, g:NERDLPlace, g:NERDRPlace, theLine) + call setline(currentLine, theLine) + let currentLine = currentLine + 1 + endwhile + endif + + "add the delimiter to the top line + let theLine = getline(a:firstLine) + let lineHasLeadingTabs = s:HasLeadingTabs(theLine) + let theLine = s:ConvertLeadingTabsToSpaces(theLine) + let theLine = s:AddLeftDelim(left, theLine) + if lineHasLeadingTabs + let theLine = s:ConvertLeadingSpacesToTabs(theLine) + endif + call setline(a:firstLine, theLine) + + "add the delimiter to the bottom line + let theLine = getline(a:lastLine) + let lineHasLeadingTabs = s:HasLeadingTabs(theLine) + let theLine = s:ConvertLeadingTabsToSpaces(theLine) + let theLine = s:AddRightDelim(right, theLine) + if lineHasLeadingTabs + let theLine = s:ConvertLeadingSpacesToTabs(theLine) + endif + + if g:NERDTrimTrailingWhitespace ==# 1 + let theLine = s:TrimTrailingWhitespace(theLine) + endif + + call setline(a:lastLine, theLine) +endfunction + +" Function: s:CommentLinesSexy(topline, bottomline) function {{{2 +" This function is used to comment lines in the 'Sexy' style. E.g., in c: +" /* +" * This is a sexy comment +" */ +" Args: +" -topline: the line number of the top line in the sexy comment +" -bottomline: the line number of the bottom line in the sexy comment +function s:CommentLinesSexy(topline, bottomline) + let left = s:GetSexyComLeft(0, 0) + let right = s:GetSexyComRight(0, 0) + + "check if we can do a sexy comment with the available delimiters + if left ==# -1 || right ==# -1 + throw 'NERDCommenter.Delimiters exception: cannot perform sexy comments with available delimiters.' + endif + + "make sure the lines aren't already commented sexually or we can nest + if !s:CanSexyCommentLines(a:topline, a:bottomline) + throw 'NERDCommenter.Nesting exception: cannot nest sexy comments' + endif + + + let sexyComMarker = s:GetSexyComMarker(0,0) + let sexyComMarkerSpaced = s:GetSexyComMarker(1,0) + + + " we jam the comment as far to the right as possible + let leftAlignIndx = s:LeftMostIndx(1, 1, a:topline, a:bottomline) + + "check if we should use the compact style i.e that the left/right + "delimiters should appear on the first and last lines of the code and not + "on separate lines above/below the first/last lines of code + if g:NERDCompactSexyComs + let spaceString = (g:NERDSpaceDelims ? s:spaceStr : '') + + "comment the top line + let theLine = getline(a:topline) + let lineHasTabs = s:HasLeadingTabs(theLine) + if lineHasTabs + let theLine = s:ConvertLeadingTabsToSpaces(theLine) + endif + if !s:SexyNested() + let theLine = s:SwapOuterMultiPartDelimsForPlaceHolders(theLine) + endif + let theLine = s:AddLeftDelimAligned(left . spaceString, theLine, leftAlignIndx) + if lineHasTabs + let theLine = s:ConvertLeadingSpacesToTabs(theLine) + endif + call setline(a:topline, theLine) + + "comment the bottom line + if a:bottomline !=# a:topline + let theLine = getline(a:bottomline) + let lineHasTabs = s:HasLeadingTabs(theLine) + if lineHasTabs + let theLine = s:ConvertLeadingTabsToSpaces(theLine) + endif + if !s:SexyNested() + let theLine = s:SwapOuterMultiPartDelimsForPlaceHolders(theLine) + endif + endif + let theLine = s:AddRightDelim(spaceString . right, theLine) + if lineHasTabs + let theLine = s:ConvertLeadingSpacesToTabs(theLine) + endif + call setline(a:bottomline, theLine) + else + + " add the left delimiter one line above the lines that are to be commented + call cursor(a:topline, 1) + execute 'normal! O' + let theLine = repeat(' ', leftAlignIndx) . left + + " Make sure tabs are respected + if !&expandtab + let theLine = s:ConvertLeadingSpacesToTabs(theLine) + endif + call setline(a:topline, theLine) + + " add the right delimiter after bottom line (we have to add 1 cos we moved + " the lines down when we added the left delimiter + call cursor(a:bottomline+1, 1) + execute 'normal! o' + if g:NERDDisableTabsInBlockComm + let theLine = repeat(' ', leftAlignIndx) . right + else + let theLine = repeat(' ', leftAlignIndx) . repeat(' ', strlen(left)-strlen(sexyComMarker)) . right + endif + + " Make sure tabs are respected + if !&expandtab + let theLine = s:ConvertLeadingSpacesToTabs(theLine) + endif + call setline(a:bottomline+2, theLine) + + endif + + " go thru each line adding the sexyComMarker marker to the start of each + " line in the appropriate place to align them with the comment delimiters + let currentLine = a:topline+1 + while currentLine <= a:bottomline + !g:NERDCompactSexyComs + " get the line and convert the tabs to spaces + let theLine = getline(currentLine) + let lineHasTabs = s:HasLeadingTabs(theLine) + if lineHasTabs + let theLine = s:ConvertLeadingTabsToSpaces(theLine) + endif + + if !s:SexyNested() + let theLine = s:SwapOuterMultiPartDelimsForPlaceHolders(theLine) + endif + + " add the sexyComMarker + if g:NERDDisableTabsInBlockComm + let theLine = repeat(' ', leftAlignIndx) . sexyComMarkerSpaced . strpart(theLine, leftAlignIndx) + else + let theLine = repeat(' ', leftAlignIndx) . repeat(' ', strlen(left)-strlen(sexyComMarker)) . sexyComMarkerSpaced . strpart(theLine, leftAlignIndx) + endif + + if lineHasTabs + let theLine = s:ConvertLeadingSpacesToTabs(theLine) + endif + + if g:NERDTrimTrailingWhitespace ==# 1 + let theLine = s:TrimTrailingWhitespace(theLine) + endif + + " set the line and move onto the next one + call setline(currentLine, theLine) + let currentLine = currentLine + 1 + endwhile + +endfunction + +" Function: s:CommentLinesToggle(forceNested, firstLine, lastLine) {{{2 +" Applies "toggle" commenting to the given range of lines +" +" Args: +" -forceNested: a flag indicating whether the called is requesting the comment +" to be nested if need be +" -firstLine/lastLine: the top and bottom lines to comment +function s:CommentLinesToggle(forceNested, firstLine, lastLine) + let currentLine = a:firstLine + + let align = g:NERDDefaultAlign + let leftAlignIndx = align ==# 'start' ? 0 : s:LeftMostIndx(a:forceNested, 0, a:firstLine, a:lastLine) + let rightAlignIndx = s:RightMostIndx(a:forceNested, 0, a:firstLine, a:lastLine) + let rightAlignIndx = rightAlignIndx + strlen(s:Left({'space': 1})) + + while currentLine <= a:lastLine + + " get the next line, check commentability and convert spaces to tabs + let theLine = getline(currentLine) + let lineHasLeadingTabs = s:HasLeadingTabs(theLine) + let theLine = s:ConvertLeadingTabsToSpaces(theLine) + if s:CanToggleCommentLine(a:forceNested, currentLine) + + "if the user has specified forceNesting then we check to see if we + "need to switch delimiters for place-holders + if g:NERDUsePlaceHolders && !s:Nested() + let theLine = s:SwapOuterMultiPartDelimsForPlaceHolders(theLine) + endif + + if align ==# 'left' || align ==# 'start' || align ==# 'both' + let theLine = s:AddLeftDelimAligned(s:Left({'space': 1}), theLine, leftAlignIndx) + else + let theLine = s:AddLeftDelim(s:Left({'space': 1}), theLine) + endif + if align ==# 'both' + let theLine = s:AddRightDelimAligned(s:Right({'space': 1}), theLine, rightAlignIndx) + else + let theLine = s:AddRightDelim(s:Right({'space': 1}), theLine) + endif + endif + + " restore leading tabs if appropriate + if lineHasLeadingTabs + let theLine = s:ConvertLeadingSpacesToTabs(theLine) + endif + + if g:NERDTrimTrailingWhitespace ==# 1 + let theLine = s:TrimTrailingWhitespace(theLine) + endif + + " we are done with this line + call setline(currentLine, theLine) + let currentLine = currentLine + 1 + endwhile + +endfunction + +" Function: s:CommentRegion(topline, topCol, bottomLine, bottomCol) function {{{2 +" This function comments chunks of text selected in visual mode. +" It will comment exactly the text that they have selected. +" Args: +" -topLine: the line number of the top line in the sexy comment +" -topCol: top left column for this comment +" -bottomline: the line number of the bottom line in the sexy comment +" -bottomCol: the bottom right column for this comment +" -forceNested: whether the caller wants comments to be nested if the +" line(s) are already commented +function s:CommentRegion(topLine, topCol, bottomLine, bottomCol, forceNested) + + "switch delimiters (if we can) if the current set isn't multipart + let switchedDelims = 0 + if !s:Multipart() && s:AltMultipart() && !g:NERDAllowAnyVisualDelims + let switchedDelims = 1 + call s:SwitchToAlternativeDelimiters(0) + endif + + "if there is only one line in the comment then just do it + if a:topLine ==# a:bottomLine + call s:CommentBlock(a:topLine, a:bottomLine, a:topCol, a:bottomCol, a:forceNested) + + "there are multiple lines in the comment + else + "comment the top line + call s:CommentBlock(a:topLine, a:topLine, a:topCol, strlen(getline(a:topLine)), a:forceNested) + + "comment out all the lines in the middle of the comment + let topOfRange = a:topLine+1 + let bottomOfRange = a:bottomLine-1 + if topOfRange <= bottomOfRange + call s:CommentLines(a:forceNested, g:NERDDefaultAlign, topOfRange, bottomOfRange) + endif + + "comment the bottom line + let bottom = getline(a:bottomLine) + let numLeadingSpacesTabs = strlen(substitute(bottom, '^\([ \t]*\).*$', '\1', '')) + call s:CommentBlock(a:bottomLine, a:bottomLine, numLeadingSpacesTabs+1, a:bottomCol, a:forceNested) + + endif + + "stick the cursor back on the char it was on before the comment + call cursor(a:topLine, a:topCol + strlen(s:Left()) + g:NERDSpaceDelims) + + "if we switched delimiters then we gotta go back to what they were before + if switchedDelims ==# 1 + call s:SwitchToAlternativeDelimiters(0) + endif + +endfunction + +" Function: s:InvertComment(firstLine, lastLine) function {{{2 +" Inverts the comments on the lines between and including the given line +" numbers i.e all commented lines are uncommented and vice versa +" Args: +" -firstLine: the top of the range of lines to be inverted +" -lastLine: the bottom of the range of lines to be inverted +function s:InvertComment(firstLine, lastLine) + + " go thru all lines in the given range + let currentLine = a:firstLine + while currentLine <= a:lastLine + let theLine = getline(currentLine) + + let sexyComBounds = s:FindBoundingLinesOfSexyCom(currentLine) + + " if the line is commented normally, uncomment it + if s:IsCommentedFromStartOfLine(s:Left(), theLine) || s:IsCommentedFromStartOfLine(s:Left({'alt': 1}), theLine) + call s:UncommentLines(currentLine, currentLine) + let currentLine = currentLine + 1 + + " check if the line is commented sexually + elseif !empty(sexyComBounds) + let numLinesBeforeSexyComRemoved = s:NumLinesInBuf() + call s:UncommentLinesSexy(sexyComBounds[0], sexyComBounds[1]) + + "move to the line after last line of the sexy comment + let numLinesAfterSexyComRemoved = s:NumLinesInBuf() + let currentLine = sexyComBounds[1] - (numLinesBeforeSexyComRemoved - numLinesAfterSexyComRemoved) + 1 + + " the line isn't commented + else + call s:CommentLinesToggle(1, currentLine, currentLine) + let currentLine = currentLine + 1 + endif + + endwhile +endfunction + +" Function: NERDCommentIsLineCommented(lineNo) +" Check if the line is a comment +" Note this function checks if the line is **completely** a comment +" Args: +" -lineNo: the line number of the line to check +" Return: Number, 1 if the line is a comment, 0 else +function! NERDCommentIsLineCommented(lineNo) + let theLine = getline(a:lineNo) + return s:IsInSexyComment(a:lineNo) || s:IsCommentedFromStartOfLine(s:Left(), theLine) || s:IsCommentedFromStartOfLine(s:Left({'alt': 1}), theLine) +endfunction + +" Function: NERDComment(mode, type) function {{{2 +" This function is a Wrapper for the main commenting functions +" +" Args: +" -mode: a character indicating the mode in which the comment is requested: +" 'n' for Normal mode, 'x' for Visual mode +" -type: the type of commenting requested. Can be 'Sexy', 'Invert', +" 'Minimal', 'Toggle', 'AlignLeft', 'AlignBoth', 'Comment', +" 'Nested', 'ToEOL', 'Append', 'Insert', 'Uncomment', 'Yank' +function! NERDComment(mode, type) range + if exists('*NERDCommenter_before') + exe 'call NERDCommenter_before()' + endif + + let isVisual = a:mode =~# '[vsx]' + + if !exists('g:did_load_ftplugin') || g:did_load_ftplugin !=# 1 + call s:NerdEcho('filetype plugins should be enabled. See :help NERDComInstallation and :help :filetype-plugin-on', 0) + endif + + if isVisual + let firstLine = line("'<") + let lastLine = line("'>") + let firstCol = col("'<") + let lastCol = col("'>") - (&selection ==# 'exclusive' ? 1 : 0) + else + let firstLine = a:firstline + let lastLine = a:lastline + endif + " + " Save options we need to change so we can recover them later + let state = s:SetupStateBeforeLineComment(firstLine, lastLine) + + let countWasGiven = (!isVisual && firstLine !=# lastLine) + + let forceNested = (a:type ==? 'Nested' || g:NERDDefaultNesting) + + if a:type ==? 'Comment' || a:type ==? 'Nested' + if isVisual && visualmode() ==# "\" + call s:CommentBlock(firstLine, lastLine, firstCol, lastCol, forceNested) + elseif isVisual && visualmode() ==# 'v' && (g:NERDCommentWholeLinesInVMode==#0 || (g:NERDCommentWholeLinesInVMode==#2 && s:HasMultipartDelims())) + call s:CommentRegion(firstLine, firstCol, lastLine, lastCol, forceNested) + else + call s:CommentLines(forceNested, g:NERDDefaultAlign, firstLine, lastLine) + endif + + elseif a:type ==? 'AlignLeft' || a:type ==? 'AlignBoth' + let align = 'none' + if a:type ==? 'AlignLeft' + let align = 'left' + elseif a:type ==? 'AlignBoth' + let align = 'both' + endif + call s:CommentLines(forceNested, align, firstLine, lastLine) + + elseif a:type ==? 'Invert' + call s:InvertComment(firstLine, lastLine) + + elseif a:type ==? 'Sexy' + try + call s:CommentLinesSexy(firstLine, lastLine) + catch /NERDCommenter.Delimiters/ + call s:CommentLines(forceNested, g:NERDDefaultAlign, firstLine, lastLine) + catch /NERDCommenter.Nesting/ + call s:NerdEcho('Sexy comment aborted. Nested sexy cannot be nested', 0) + endtry + + elseif a:type ==? 'Toggle' + if g:NERDToggleCheckAllLines ==# 0 + let theLine = getline(firstLine) + if s:IsInSexyComment(firstLine) || s:IsCommentedFromStartOfLine(s:Left(), theLine) || s:IsCommentedFromStartOfLine(s:Left({'alt': 1}), theLine) + call s:UncommentLines(firstLine, lastLine) + else + call s:CommentLinesToggle(forceNested, firstLine, lastLine) + endif + else + let l:commentAllLines = 0 + for i in range(firstLine, lastLine) + let theLine = getline(i) + " if have one line no comment(not include blank/whitespace-only lines), then comment all lines + if theLine =~# '[^ \t]\+' && !s:IsInSexyComment(firstLine) && !s:IsCommentedFromStartOfLine(s:Left(), theLine) && !s:IsCommentedFromStartOfLine(s:Left({'alt': 1}), theLine) + let l:commentAllLines = 1 + break + else + endif + endfor + if l:commentAllLines ==# 1 + call s:CommentLinesToggle(forceNested, firstLine, lastLine) + else + call s:UncommentLines(firstLine, lastLine) + endif + endif + + elseif a:type ==? 'Minimal' + try + call s:CommentLinesMinimal(firstLine, lastLine) + catch /NERDCommenter.Delimiters/ + call s:NerdEcho('Minimal comments can only be used for filetypes that have multipart delimiters.', 0) + catch /NERDCommenter.Settings/ + call s:NerdEcho('Place holders are required but disabled.', 0) + endtry + + elseif a:type ==? 'ToEOL' + call s:SaveScreenState() + call s:CommentBlock(firstLine, firstLine, col('.'), col('$')-1, 1) + call s:RestoreScreenState() + + elseif a:type ==? 'Append' + call s:AppendCommentToLine() + + elseif a:type ==? 'Insert' + call s:PlaceDelimitersAndInsBetween() + + elseif a:type ==? 'Uncomment' + call s:UncommentLines(firstLine, lastLine) + + elseif a:type ==? 'Yank' + if isVisual + normal! gvy + elseif countWasGiven + execute firstLine .','. lastLine .'yank' + else + normal! yy + endif + execute firstLine .','. lastLine .'call NERDComment("'. a:mode .'", "Comment")' + endif + + call s:RecoverStateAfterLineComment(state) + + if isVisual + let nlines = lastLine - firstLine + silent! call repeat#set('V' . nlines . 'jo' . "\NERDCommenter". a:type) + else + silent! call repeat#set("\NERDCommenter". a:type) + endif + + if exists('*NERDCommenter_after') + exe 'call NERDCommenter_after()' + endif + +endfunction + +" Function: NERDCommentIsCharCommented(line, col) abort +" Check if the character at [line, col] is inside a comment +" Note the Comment delimeter it self is considered as part of the comment +" +" Args: +" -line the line number of the character +" -col the column number of the character +" Return: Number, 1 if the character is inside a comment, 0 if is not +function! NERDCommentIsCharCommented(line, col) abort + " Function: s:searchfor(str, line, col, direction, [maxline]) + " search str in the buffer, including the character at [line, col] + " Args: + " -str: the string for search + " -line: the line number where search begins + " -col: the column number where search begins + " -direction: 0 if forward, and 1 if backward + " -maxline: the max lines the search would look up + " 1 if search only one line + " if not given, search until reaches the begining or end of file + " Return: List, in the format of [line, col], where line and col is the + " position of first found result; If str cannot be found, returns + " [0, 0] + function! s:searchfor(str, line, col, direction, ...) abort + let l:curlinenr = a:line + let l:maxline = (a:0 > 0) ? a:1 : (a:direction ? a:line : line('$') - a:line + 1) + while abs(curlinenr - a:line) < maxline + let linestr = getline(curlinenr) + if curlinenr == a:line + if !a:direction + let l:partstr = strpart(linestr, a:col - strlen(a:str)) + else + let l:partstr = strpart(linestr, 0, a:col + strlen(a:str) - 1) + endif + else + let l:partstr = linestr + endif + if !a:direction + " forward + let idx = stridx(partstr, a:str) + if idx != -1 + if curlinenr == a:line + let idx += a:col - strlen(a:str) + else + endif + return [curlinenr, idx + 1] + endif + else + " backward + let idx = strridx(partstr, a:str) + if idx != -1 + return [curlinenr, idx + 1] + endif + endif + let curlinenr += a:direction ? -1 : 1 + endwhile + return [0, 0] + endfunction + " Function: s:checkwith(left, right, line, col) abort + " check if the char at [line, col] is commented using [left, right] pair + " Args: + " -left: the string begins a comment + " -right: the string ends a comment + " -line: the line position of the character + " -col: the column position of the character + " Return: Number, 1 if is in a comment, 0 else + function! s:checkwith(left, right, line, col) abort + let linecommented = 0 + let blockcommented = 0 + if a:right ==# '' + let leftpos = s:searchfor(a:left, a:line, a:col, 1, 1) + if leftpos == [0, 0] + if !linecommented | let linecommented = 0 | endif + else + if !linecommented | let linecommented = 1 | endif + endif + else + let leftpos = s:searchfor(a:left, a:line, a:col, 1) + if leftpos == [0, 0] + if !blockcommented | let blockcommented = 0 | endif + else + " call s:searchfor(a:right, a:line, a:col, 0) + let rightpos = s:searchfor(a:right, leftpos[0], leftpos[1] + strlen(a:right) + 1, 0) + if rightpos != [0, 0] + if rightpos[0] < a:line + if !blockcommented | let blockcommented = 0 | endif + elseif rightpos[0] == a:line + if !blockcommented + let blockcommented = (rightpos[1] + strlen(a:right) > a:col) ? 1 : 0 + endif + else " rightpos > a:line + if !blockcommented | let blockcommented = 1 | endif + endif + else + if !blockcommented | let blockcommented = 1 | endif + endif + endif + endif + return linecommented || blockcommented + endfunction + return s:checkwith( + \ b:NERDCommenterDelims['left'], + \ b:NERDCommenterDelims['right'], + \ a:line, + \ a:col) || + \ s:checkwith( + \ b:NERDCommenterDelims['leftAlt'], + \ b:NERDCommenterDelims['rightAlt'], + \ a:line, + \ a:col) +endfunction + +" Function: s:PlaceDelimitersAndInsBetween() function {{{2 +" This is function is called to place comment delimiters down and place the +" cursor between them +function s:PlaceDelimitersAndInsBetween() + " get the left and right delimiters without any escape chars in them + let left = s:Left({'space': 1}) + let right = s:Right({'space': 1}) + + let theLine = getline('.') + let lineHasLeadTabs = s:HasLeadingTabs(theLine) || (theLine =~# '^ *$' && !&expandtab) + + "convert tabs to spaces and adjust the cursors column to take this into + "account + let untabbedCol = s:UntabbedCol(theLine, col('.')) + call setline(line('.'), s:ConvertLeadingTabsToSpaces(theLine)) + call cursor(line('.'), untabbedCol) + + " get the length of the right delimiter + let lenRight = strlen(right) + + let isDelimOnEOL = col('.') >= strlen(getline('.')) + + " if the cursor is in the first col then we gotta insert rather than + " append the comment delimiters here + let insOrApp = (col('.')==1 ? 'i' : 'a') + + " place the delimiters down. We do it differently depending on whether + " there is a left AND right delimiter + if lenRight > 0 + execute ':normal! ' . insOrApp . left . right + execute ':normal! ' . lenRight . 'h' + else + execute ':normal! ' . insOrApp . left + endif + + "if needed convert spaces back to tabs and adjust the cursors col + "accordingly + if lineHasLeadTabs + let tabbedCol = s:TabbedCol(getline('.'), col('.')) + call setline(line('.'), s:ConvertLeadingSpacesToTabs(getline('.'))) + call cursor(line('.'), tabbedCol) + endif + + if isDelimOnEOL && lenRight ==# 0 + startinsert! + else + call feedkeys('a', 'ni') + endif +endfunction + +" Function: s:RemoveDelimiters(left, right, line) {{{2 +" this function is called to remove the first left comment delimiter and the +" last right delimiter of the given line. +" +" The arguments left and right must be strings. If there is no right delimiter (as +" is the case for e.g vim file comments) them the argument right should be '' +" +" Args: +" -left: the left comment delimiter +" -right: the right comment delimiter +" -line: the line to remove the delimiters from +function s:RemoveDelimiters(left, right, line) + + let l:left = a:left + let l:right = a:right + let lenLeft = strlen(left) + let lenRight = strlen(right) + + let delimsSpaced = (g:NERDSpaceDelims || g:NERDRemoveExtraSpaces) + + let line = a:line + + "look for the left delimiter, if we find it, remove it. + let leftIndx = s:FindDelimiterIndex(a:left, line) + if leftIndx !=# -1 + let line = strpart(line, 0, leftIndx) . strpart(line, leftIndx+lenLeft) + + "if the user has specified that there is a space after the left delimiter + "then check for the space and remove it if it is there + if delimsSpaced && strpart(line, leftIndx, s:lenSpaceStr) ==# s:spaceStr + let line = strpart(line, 0, leftIndx) . strpart(line, leftIndx+s:lenSpaceStr) + endif + endif + + "look for the right delimiter, if we find it, remove it + let rightIndx = s:LastIndexOfDelim(a:right, line) + if rightIndx !=# -1 + let line = strpart(line, 0, rightIndx) . strpart(line, rightIndx+lenRight) + + "if the user has specified that there is a space before the right delimiter + "then check for the space and remove it if it is there + if delimsSpaced && strpart(line, rightIndx-s:lenSpaceStr, s:lenSpaceStr) ==# s:spaceStr && (s:Multipart() || s:AltMultipart()) + let line = strpart(line, 0, rightIndx-s:lenSpaceStr) . strpart(line, rightIndx) + endif + endif + + return line +endfunction + +" Function: s:SetupStateBeforeLineComment(topLine, bottomLine) {{{2 +" Changes ignorecase and foldmethod options before commenting lines and saves +" their original values in a dict, which is returned as a result +" +" Args: +" topLine: the top line of the visual selection to uncomment +" bottomLine: the bottom line of the visual selection to uncomment +" +" Return: a dict with the state prior to configuration changes +" +function s:SetupStateBeforeLineComment(topLine, bottomLine) + let state = {'foldmethod' : &foldmethod, + \'ignorecase' : &ignorecase} + + " Vim's foldmethods are evaluated every time we use 'setline', which can + " make commenting wide ranges of lines VERY slow. We'll change it to + " manual, do the commenting stuff and recover it later. To avoid slowing + " down commenting few lines, we avoid doing this for ranges smaller than + " 10 lines + if a:bottomLine - a:topLine >= 10 && &foldmethod !=# 'manual' + set foldmethod=manual + endif + + " we want case sensitivity when commenting + set noignorecase + + return state +endfunction + +" Function: s:RecoverStateAfterLineComment(state) {{{2 +" Receives the state returned by s:SetupStateBeforeLineComment and restores +" the state accordingly +" +" Args: +" state: the top line of the visual selection to uncomment +" bottomLine: the bottom line of the visual selection to uncomment +function s:RecoverStateAfterLineComment(state) + if a:state['foldmethod'] !=# &foldmethod + let &foldmethod = a:state['foldmethod'] + endif + if a:state['ignorecase'] !=# &ignorecase + let &ignorecase = a:state['ignorecase'] + endif +endfunction + +" Function: s:TrimTrailingWhitespace(line) {{{2 +" This function removes all the trailing whitespace +" Args: +" -line: the target line +function s:TrimTrailingWhitespace(line) + let toReturn = substitute(a:line, '\s\+$', '', 'g') + return toReturn +endfunction + +" Function: s:UncommentLines(topLine, bottomLine) {{{2 +" This function uncomments the given lines +" +" Args: +" topLine: the top line of the visual selection to uncomment +" bottomLine: the bottom line of the visual selection to uncomment +function s:UncommentLines(topLine, bottomLine) + "make local copies of a:firstline and a:lastline and, if need be, swap + "them around if the top line is below the bottom + let l:firstline = a:topLine + let l:lastline = a:bottomLine + if firstline > lastline + let firstline = lastline + let lastline = a:topLine + endif + + "go thru each line uncommenting each line removing sexy comments + let currentLine = firstline + while currentLine <= lastline + + "check the current line to see if it is part of a sexy comment + let sexyComBounds = s:FindBoundingLinesOfSexyCom(currentLine) + if !empty(sexyComBounds) + + "we need to store the number of lines in the buffer before the comment is + "removed so we know how many lines were removed when the sexy comment + "was removed + let numLinesBeforeSexyComRemoved = s:NumLinesInBuf() + + call s:UncommentLinesSexy(sexyComBounds[0], sexyComBounds[1]) + + "move to the line after last line of the sexy comment + let numLinesAfterSexyComRemoved = s:NumLinesInBuf() + let numLinesRemoved = numLinesBeforeSexyComRemoved - numLinesAfterSexyComRemoved + let currentLine = sexyComBounds[1] - numLinesRemoved + 1 + let lastline = lastline - numLinesRemoved + + "no sexy com was detected so uncomment the line as normal + else + call s:UncommentLinesNormal(currentLine, currentLine) + let currentLine = currentLine + 1 + endif + endwhile + +endfunction + +" Function: s:UncommentLinesSexy(topline, bottomline) {{{2 +" This function removes all the comment characters associated with the sexy +" comment spanning the given lines +" Args: +" -topline/bottomline: the top/bottom lines of the sexy comment +function s:UncommentLinesSexy(topline, bottomline) + let left = s:GetSexyComLeft(0,1) + let right = s:GetSexyComRight(0,1) + + + "check if it is even possible for sexy comments to exist with the + "available delimiters + if left ==# -1 || right ==# -1 + throw 'NERDCommenter.Delimiters exception: cannot uncomment sexy comments with available delimiters.' + endif + + let leftUnEsc = s:GetSexyComLeft(0,0) + let rightUnEsc = s:GetSexyComRight(0,0) + + let sexyComMarker = s:GetSexyComMarker(0, 1) + let sexyComMarkerUnEsc = s:GetSexyComMarker(0, 0) + + "the markerOffset is how far right we need to move the sexyComMarker to + "line it up with the end of the left delimiter + let markerOffset = strlen(leftUnEsc)-strlen(sexyComMarkerUnEsc) + + " go thru the intermediate lines of the sexy comment and remove the + " sexy comment markers (e.g., the '*'s on the start of line in a c sexy + " comment) + let currentLine = a:topline+1 + while currentLine < a:bottomline + let theLine = getline(currentLine) + + " remove the sexy comment marker from the line. We also remove the + " space after it if there is one and if appropriate options are set + let sexyComMarkerIndx = stridx(theLine, sexyComMarkerUnEsc) + if strpart(theLine, sexyComMarkerIndx+strlen(sexyComMarkerUnEsc), s:lenSpaceStr) ==# s:spaceStr && g:NERDSpaceDelims + let theLine = strpart(theLine, 0, sexyComMarkerIndx - markerOffset) . strpart(theLine, sexyComMarkerIndx+strlen(sexyComMarkerUnEsc)+s:lenSpaceStr) + else + let theLine = strpart(theLine, 0, sexyComMarkerIndx - markerOffset) . strpart(theLine, sexyComMarkerIndx+strlen(sexyComMarkerUnEsc)) + endif + + let theLine = s:SwapOuterPlaceHoldersForMultiPartDelims(theLine) + + let theLine = s:ConvertLeadingWhiteSpace(theLine) + + if g:NERDTrimTrailingWhitespace ==# 1 + let theLine = s:TrimTrailingWhitespace(theLine) + endif + + " move onto the next line + call setline(currentLine, theLine) + let currentLine = currentLine + 1 + endwhile + + " gotta make a copy of a:bottomline cos we modify the position of the + " last line it if we remove the topline + let bottomline = a:bottomline + + " get the first line so we can remove the left delimiter from it + let theLine = getline(a:topline) + + " if the first line contains only the left delimiter then just delete it + if theLine =~# '^[ \t]*' . left . '[ \t]*$' && !g:NERDCompactSexyComs + call cursor(a:topline, 1) + normal! dd + let bottomline = bottomline - 1 + + " topline contains more than just the left delimiter + else + + " remove the delimiter. If there is a space after it + " then remove this too if appropriate + let delimIndx = stridx(theLine, leftUnEsc) + if strpart(theLine, delimIndx+strlen(leftUnEsc), s:lenSpaceStr) ==# s:spaceStr && g:NERDSpaceDelims + let theLine = strpart(theLine, 0, delimIndx) . strpart(theLine, delimIndx+strlen(leftUnEsc)+s:lenSpaceStr) + else + let theLine = strpart(theLine, 0, delimIndx) . strpart(theLine, delimIndx+strlen(leftUnEsc)) + endif + let theLine = s:SwapOuterPlaceHoldersForMultiPartDelims(theLine) + call setline(a:topline, theLine) + endif + + " get the last line so we can remove the right delimiter + let theLine = getline(bottomline) + + " if the bottomline contains only the right delimiter then just delete it + if theLine =~# '^[ \t]*' . right . '[ \t]*$' + call cursor(bottomline, 1) + normal! dd + + " the last line contains more than the right delimiter + else + " remove the right delimiter. If there is a space after it and + " if the appropriate options are set then remove this too. + let delimIndx = s:LastIndexOfDelim(rightUnEsc, theLine) + if strpart(theLine, delimIndx+strlen(leftUnEsc), s:lenSpaceStr) ==# s:spaceStr && g:NERDSpaceDelims + let theLine = strpart(theLine, 0, delimIndx) . strpart(theLine, delimIndx+strlen(rightUnEsc)+s:lenSpaceStr) + else + let theLine = strpart(theLine, 0, delimIndx) . strpart(theLine, delimIndx+strlen(rightUnEsc)) + endif + + " if the last line also starts with a sexy comment marker then we + " remove this as well + if theLine =~# '^[ \t]*' . sexyComMarker + + " remove the sexyComMarker. If there is a space after it then + " remove that too + let sexyComMarkerIndx = stridx(theLine, sexyComMarkerUnEsc) + if strpart(theLine, sexyComMarkerIndx+strlen(sexyComMarkerUnEsc), s:lenSpaceStr) ==# s:spaceStr && g:NERDSpaceDelims + let theLine = strpart(theLine, 0, sexyComMarkerIndx - markerOffset ) . strpart(theLine, sexyComMarkerIndx+strlen(sexyComMarkerUnEsc)+s:lenSpaceStr) + else + let theLine = strpart(theLine, 0, sexyComMarkerIndx - markerOffset ) . strpart(theLine, sexyComMarkerIndx+strlen(sexyComMarkerUnEsc)) + endif + endif + + let theLine = s:SwapOuterPlaceHoldersForMultiPartDelims(theLine) + call setline(bottomline, theLine) + endif + + " remove trailing whitespaces for first and last line + if g:NERDTrimTrailingWhitespace ==# 1 + let theLine = getline(a:bottomline) + let theLine = s:TrimTrailingWhitespace(theLine) + call setline(a:bottomline, theLine) + let theLine = getline(a:topline) + let theLine = s:TrimTrailingWhitespace(theLine) + call setline(a:topline, theLine) + endif +endfunction + +" Function: s:UncommentLineNormal(line) {{{2 +" uncomments the given line and returns the result +" Args: +" -line: the line to uncomment +function s:UncommentLineNormal(line) + let line = a:line + + "get the positions of all delimiter types on the line + let indxLeft = s:FindDelimiterIndex(s:Left(), line) + let indxLeftAlt = s:FindDelimiterIndex(s:Left({'alt': 1}), line) + let indxRight = s:LastIndexOfDelim(s:Right(), line) + let indxRightAlt = s:LastIndexOfDelim(s:Right({'alt': 1}), line) + + "get the comment status on the line so we know how it is commented + let lineCommentStatus = s:IsCommentedOutermost(s:Left(), s:Right(), s:Left({'alt': 1}), s:Right({'alt': 1}), line) + + "it is commented with s:Left() and s:Right() so remove these delimiters + if lineCommentStatus ==# 1 + let line = s:RemoveDelimiters(s:Left(), s:Right(), line) + + "it is commented with s:Left({'alt': 1}) and s:Right({'alt': 1}) so remove these delimiters + elseif lineCommentStatus ==# 2 && g:NERDRemoveAltComs + let line = s:RemoveDelimiters(s:Left({'alt': 1}), s:Right({'alt': 1}), line) + + "it is not properly commented with any delimiters so we check if it has + "any random left or right delimiters on it and remove the outermost ones + else + "remove the outer most left comment delimiter + if indxLeft !=# -1 && (indxLeft < indxLeftAlt || indxLeftAlt ==# -1) + let line = s:RemoveDelimiters(s:Left(), '', line) + elseif indxLeftAlt !=# -1 && g:NERDRemoveAltComs + let line = s:RemoveDelimiters(s:Left({'alt': 1}), '', line) + endif + + "remove the outer most right comment delimiter + if indxRight !=# -1 && (indxRight < indxRightAlt || indxRightAlt ==# -1) + let line = s:RemoveDelimiters('', s:Right(), line) + elseif indxRightAlt !=# -1 && g:NERDRemoveAltComs + let line = s:RemoveDelimiters('', s:Right({'alt': 1}), line) + endif + endif + + + let indxLeftPlace = s:FindDelimiterIndex(g:NERDLPlace, line) + let indxRightPlace = s:FindDelimiterIndex(g:NERDRPlace, line) + + let right = s:Right() + let left = s:Left() + if !s:Multipart() + let right = s:Right({'alt': 1}) + let left = s:Left({'alt': 1}) + endif + + + "if there are place-holders on the line then we check to see if they are + "the outermost delimiters on the line. If so then we replace them with + "real delimiters + if indxLeftPlace !=# -1 + if (indxLeftPlace < indxLeft || indxLeft==-1) && (indxLeftPlace < indxLeftAlt || indxLeftAlt==-1) + let line = s:ReplaceDelims(g:NERDLPlace, g:NERDRPlace, left, right, line) + endif + elseif indxRightPlace !=# -1 + if (indxRightPlace < indxLeft || indxLeft==-1) && (indxLeftPlace < indxLeftAlt || indxLeftAlt==-1) + let line = s:ReplaceDelims(g:NERDLPlace, g:NERDRPlace, left, right, line) + endif + + endif + + let line = s:ConvertLeadingWhiteSpace(line) + + if g:NERDTrimTrailingWhitespace ==# 1 + let line = s:TrimTrailingWhitespace(line) + endif + + return line +endfunction + +" Function: s:UncommentLinesNormal(topline, bottomline) {{{2 +" This function is called to uncomment lines that aren't a sexy comment +" Args: +" -topline/bottomline: the top/bottom line numbers of the comment +function s:UncommentLinesNormal(topline, bottomline) + let currentLine = a:topline + while currentLine <= a:bottomline + let line = getline(currentLine) + call setline(currentLine, s:UncommentLineNormal(line)) + let currentLine = currentLine + 1 + endwhile +endfunction + + +" Section: Other helper functions {{{1 +" ============================================================================ + +" Function: s:AddLeftDelim(delim, theLine) {{{2 +" Args: +function s:AddLeftDelim(delim, theLine) + return substitute(a:theLine, '^\([ \t]*\)', '\1' . a:delim, '') +endfunction + +" Function: s:AddLeftDelimAligned(delim, theLine) {{{2 +" Args: +function s:AddLeftDelimAligned(delim, theLine, alignIndx) + + "if the line is not long enough then bung some extra spaces on the front + "so we can align the delimiter properly + let theLine = a:theLine + if strlen(theLine) < a:alignIndx + let theLine = repeat(' ', a:alignIndx - strlen(theLine)) + endif + + return strpart(theLine, 0, a:alignIndx) . a:delim . strpart(theLine, a:alignIndx) +endfunction + +" Function: s:AddRightDelim(delim, theLine) {{{2 +" Args: +function s:AddRightDelim(delim, theLine) + if a:delim ==# '' + return a:theLine + else + return substitute(a:theLine, '$', a:delim, '') + endif +endfunction + +" Function: s:AddRightDelimAligned(delim, theLine, alignIndx) {{{2 +" Args: +function s:AddRightDelimAligned(delim, theLine, alignIndx) + if a:delim ==# '' + return a:theLine + else + + " when we align the right delimiter we are just adding spaces + " so we get a string containing the needed spaces (it + " could be empty) + let extraSpaces = '' + let extraSpaces = repeat(' ', a:alignIndx-strlen(a:theLine)) + + " add the right delimiter + return substitute(a:theLine, '$', extraSpaces . a:delim, '') + endif +endfunction + +" Function: s:AltMultipart() {{{2 +" returns 1 if the alternative delimiters are multipart +function s:AltMultipart() + return b:NERDCommenterDelims['rightAlt'] !=# '' +endfunction + +" Function: s:AltNested() {{{2 +" returns 1 if the alternate multipart (if any) delimiters allow nesting +function s:AltNested() + return b:NERDCommenterDelims['nestedAlt'] +endfunction + +" Function: s:CanCommentLine(forceNested, line) {{{2 +"This function is used to determine whether the given line can be commented. +"It returns 1 if it can be and 0 otherwise +" +" Args: +" -forceNested: a flag indicating whether the caller wants comments to be nested +" if the current line is already commented +" -lineNum: the line number of the line to check for commentability +function s:CanCommentLine(forceNested, lineNum) + let theLine = getline(a:lineNum) + + " make sure we don't comment lines that are just spaces or tabs or empty, + " unless configured otherwise + if g:NERDCommentEmptyLines ==# 0 && theLine =~# "^[ \t]*$" + return 0 + endif + + "if the line is part of a sexy comment then just flag it... + if s:IsInSexyComment(a:lineNum) + return 0 + endif + + let isCommented = s:IsCommentedNormOrSexy(a:lineNum) + + "if the line isn't commented return true + if !isCommented + return 1 + endif + + "if the line is commented but nesting is allowed then return true + if s:Nested() || (a:forceNested && (!s:Multipart() || g:NERDUsePlaceHolders)) + return 1 + endif + + return 0 +endfunction + +" Function: s:CanPlaceCursor(line, col) {{{2 +" returns 1 if the cursor can be placed exactly in the given position +function s:CanPlaceCursor(line, col) + let c = col('.') + let l = line('.') + call cursor(a:line, a:col) + let success = (line('.') ==# a:line && col('.') ==# a:col) + call cursor(l,c) + return success +endfunction + +" Function: s:CanSexyCommentLines(topline, bottomline) {{{2 +" Return: 1 if the given lines can be commented sexually, 0 otherwise +function s:CanSexyCommentLines(topline, bottomline) + " see if the selected regions have any sexy comments + " however, if the language allows nested comments, + " we allow nested sexy comments + if s:SexyNested() + return 1 + endif + let currentLine = a:topline + while(currentLine <= a:bottomline) + if s:IsInSexyComment(currentLine) + return 0 + endif + let currentLine = currentLine + 1 + endwhile + return 1 +endfunction +" Function: s:CanToggleCommentLine(forceNested, line) {{{2 +"This function is used to determine whether the given line can be toggle commented. +"It returns 1 if it can be and 0 otherwise +" +" Args: +" -lineNum: the line number of the line to check for commentability +function s:CanToggleCommentLine(forceNested, lineNum) + let theLine = getline(a:lineNum) + if (s:IsCommentedFromStartOfLine(s:Left(), theLine) || s:IsCommentedFromStartOfLine(s:Left({'alt': 1}), theLine)) && !a:forceNested + return 0 + endif + + " make sure we don't comment lines that are just spaces or tabs or empty, + " unless configured otherwise + if g:NERDCommentEmptyLines ==# 0 && theLine =~# "^[ \t]*$" + return 0 + endif + + "if the line is part of a sexy comment then just flag it... + if s:IsInSexyComment(a:lineNum) + return 0 + endif + + return 1 +endfunction + +" Function: s:ConvertLeadingSpacesToTabs(line) {{{2 +" This function takes a line and converts all leading tabs on that line into +" spaces +" +" Args: +" -line: the line whose leading tabs will be converted +function s:ConvertLeadingSpacesToTabs(line) + let toReturn = a:line + while toReturn =~# '^\t*' . s:TabSpace() . '\(.*\)$' + let toReturn = substitute(toReturn, '^\(\t*\)' . s:TabSpace() . '\(.*\)$' , '\1\t\2' , '') + endwhile + + return toReturn +endfunction + + +" Function: s:ConvertLeadingTabsToSpaces(line) {{{2 +" This function takes a line and converts all leading spaces on that line into +" tabs +" +" Args: +" -line: the line whose leading spaces will be converted +function s:ConvertLeadingTabsToSpaces(line) + let toReturn = a:line + while toReturn =~# '^\( *\)\t' + let toReturn = substitute(toReturn, '^\( *\)\t', '\1' . s:TabSpace() , '') + endwhile + + return toReturn +endfunction + +" Function: s:ConvertLeadingWhiteSpace(line) {{{2 +" Converts the leading white space to tabs/spaces depending on &tabstop +" +" Args: +" -line: the line to convert +function s:ConvertLeadingWhiteSpace(line) + let toReturn = a:line + while toReturn =~# '^ *\t' + let toReturn = substitute(toReturn, '^ *\zs\t\ze', s:TabSpace(), 'g') + endwhile + + if !&expandtab + let toReturn = s:ConvertLeadingSpacesToTabs(toReturn) + endif + + return toReturn +endfunction + + +" Function: s:CountNonESCedOccurances(str, searchstr, escChar) {{{2 +" This function counts the number of substrings contained in another string. +" These substrings are only counted if they are not escaped with escChar +" Args: +" -str: the string to look for searchstr in +" -searchstr: the substring to search for in str +" -escChar: the escape character which, when preceding an instance of +" searchstr, will cause it not to be counted +function s:CountNonESCedOccurances(str, searchstr, escChar) + "get the index of the first occurrence of searchstr + let indx = stridx(a:str, a:searchstr) + + "if there is an instance of searchstr in str process it + if indx !=# -1 + "get the remainder of str after this instance of searchstr is removed + let lensearchstr = strlen(a:searchstr) + let strLeft = strpart(a:str, indx+lensearchstr) + + "if this instance of searchstr is not escaped, add one to the count + "and recurse. If it is escaped, just recurse + if !s:IsEscaped(a:str, indx, a:escChar) + return 1 + s:CountNonESCedOccurances(strLeft, a:searchstr, a:escChar) + else + return s:CountNonESCedOccurances(strLeft, a:searchstr, a:escChar) + endif + endif +endfunction +" Function: s:DoesBlockHaveDelim(delim, top, bottom) {{{2 +" Returns 1 if the given block of lines has a delimiter (a:delim) in it +" Args: +" -delim: the comment delimiter to check the block for +" -top: the top line number of the block +" -bottom: the bottom line number of the block +function s:DoesBlockHaveDelim(delim, top, bottom) + let currentLine = a:top + while currentLine < a:bottom + let theline = getline(currentLine) + if s:FindDelimiterIndex(a:delim, theline) !=# -1 + return 1 + endif + let currentLine = currentLine + 1 + endwhile + return 0 +endfunction + +" Function: s:DoesBlockHaveMultipartDelim(top, bottom) {{{2 +" Returns 1 if the given block has a >= 1 multipart delimiter in it +" Args: +" -top: the top line number of the block +" -bottom: the bottom line number of the block +function s:DoesBlockHaveMultipartDelim(top, bottom) + if s:HasMultipartDelims() + if s:Multipart() + return s:DoesBlockHaveDelim(s:Left(), a:top, a:bottom) || s:DoesBlockHaveDelim(s:Right(), a:top, a:bottom) + else + return s:DoesBlockHaveDelim(s:Left({'alt': 1}), a:top, a:bottom) || s:DoesBlockHaveDelim(s:Right({'alt': 1}), a:top, a:bottom) + endif + endif + return 0 +endfunction + + +" Function: s:Esc(str) {{{2 +" Escapes all the tricky chars in the given string +function s:Esc(str) + let charsToEsc = '*/\."&$+' + return escape(a:str, charsToEsc) +endfunction + +" Function: s:FindDelimiterIndex(delimiter, line) {{{2 +" This function is used to get the string index of the input comment delimiter +" on the input line. If no valid comment delimiter is found in the line then +" -1 is returned +" Args: +" -delimiter: the delimiter we are looking to find the index of +" -line: the line we are looking for delimiter on +function s:FindDelimiterIndex(delimiter, line) + + "make sure the delimiter isn't empty otherwise we go into an infinite loop. + if a:delimiter ==# '' + return -1 + endif + + + let l:delimiter = a:delimiter + let lenDel = strlen(l:delimiter) + + "get the index of the first occurrence of the delimiter + let delIndx = stridx(a:line, l:delimiter) + + "keep looping thru the line till we either find a real comment delimiter + "or run off the EOL + while delIndx !=# -1 + + "if we are not off the EOL get the str before the possible delimiter + "in question and check if it really is a delimiter. If it is, return + "its position + if delIndx !=# -1 + if s:IsDelimValid(l:delimiter, delIndx, a:line) + return delIndx + endif + endif + + "we have not yet found a real comment delimiter so move past the + "current one we are looking at + let restOfLine = strpart(a:line, delIndx + lenDel) + let distToNextDelim = stridx(restOfLine , l:delimiter) + + "if distToNextDelim is -1 then there is no more potential delimiters + "on the line so set delIndx to -1. Otherwise, move along the line by + "distToNextDelim + if distToNextDelim ==# -1 + let delIndx = -1 + else + let delIndx = delIndx + lenDel + distToNextDelim + endif + endwhile + + "there is no comment delimiter on this line + return -1 +endfunction + +" Function: s:FindBoundingLinesOfSexyCom(lineNum) {{{2 +" This function takes in a line number and tests whether this line number is +" the top/bottom/middle line of a sexy comment. If it is then the top/bottom +" lines of the sexy comment are returned +" Args: +" -lineNum: the line number that is to be tested whether it is the +" top/bottom/middle line of a sexy com +" Returns: +" A string that has the top/bottom lines of the sexy comment encoded in it. +" The format is 'topline,bottomline'. If a:lineNum turns out not to be the +" top/bottom/middle of a sexy comment then -1 is returned +function s:FindBoundingLinesOfSexyCom(lineNum) + + "find which delimiters to look for as the start/end delimiters of the comment + let left = '' + let right = '' + if s:Multipart() + let left = s:Left({'esc': 1}) + let right = s:Right({'esc': 1}) + elseif s:AltMultipart() + let left = s:Left({'alt': 1, 'esc': 1}) + let right = s:Right({'alt': 1, 'esc': 1}) + else + return [] + endif + + let sexyComMarker = s:GetSexyComMarker(0, 1) + + "initialise the top/bottom line numbers of the sexy comment to -1 + let top = -1 + let bottom = -1 + + let currentLine = a:lineNum + while top ==# -1 || bottom ==# -1 + let theLine = getline(currentLine) + + "check if the current line is the top of the sexy comment + if currentLine <= a:lineNum && theLine =~# '^[ \t]*' . left && theLine !~# '.*' . right && currentLine < s:NumLinesInBuf() + let top = currentLine + let currentLine = a:lineNum + + "check if the current line is the bottom of the sexy comment + elseif theLine =~# '^[ \t]*' . right && theLine !~# '.*' . left && currentLine > 1 + let bottom = currentLine + + "the right delimiter is on the same line as the last sexyComMarker + elseif theLine =~# '^[ \t]*' . sexyComMarker . '.*' . right + let bottom = currentLine + + "we have not found the top or bottom line so we assume currentLine is an + "intermediate line and look to prove otherwise + else + + "if the line doesn't start with a sexyComMarker then it is not a sexy + "comment + if theLine !~# '^[ \t]*' . sexyComMarker + return [] + endif + + endif + + "if top is -1 then we haven't found the top yet so keep looking up + if top ==# -1 + let currentLine = currentLine - 1 + "if we have found the top line then go down looking for the bottom + else + let currentLine = currentLine + 1 + endif + + endwhile + + return [top, bottom] +endfunction + + +" Function: s:GetSexyComMarker() {{{2 +" Returns the sexy comment marker for the current filetype. +" +" C style sexy comments are assumed if possible. If not then the sexy comment +" marker is the last char of the delimiter pair that has both left and right +" delimiters and has the longest left delimiter +" +" Args: +" -space: specifies whether the marker is to have a space string after it +" (the space string will only be added if NERDSpaceDelims is set) +" -esc: specifies whether the tricky chars in the marker are to be ESCed +function s:GetSexyComMarker(space, esc) + let sexyComMarker = b:NERDSexyComMarker + + "if there is no hardcoded marker then we find one + if sexyComMarker ==# '' + + "if the filetype has c style comments then use standard c sexy + "comments + if s:HasCStyleComments() + let sexyComMarker = '*' + else + "find a comment marker by getting the longest available left delimiter + "(that has a corresponding right delimiter) and taking the last char + let lenLeft = strlen(s:Left()) + let lenLeftAlt = strlen(s:Left({'alt': 1})) + let left = '' + let right = '' + if s:Multipart() && lenLeft >= lenLeftAlt + let left = s:Left() + elseif s:AltMultipart() + let left = s:Left({'alt': 1}) + else + return -1 + endif + + "get the last char of left + let sexyComMarker = strpart(left, strlen(left)-1) + endif + endif + + if a:space && g:NERDSpaceDelims + let sexyComMarker = sexyComMarker . s:spaceStr + endif + + if a:esc + let sexyComMarker = s:Esc(sexyComMarker) + endif + + return sexyComMarker +endfunction + +" Function: s:SexyNested() {{{2 +" Returns 1 if the sexy delimeters allow nesting +" TODO this is ugly copy&paste from the GetSexyComLeft/Right functions, +" these could all be cleaned up +function s:SexyNested() + let lenLeft = strlen(s:Left()) + let lenLeftAlt = strlen(s:Left({'alt': 1})) + + "assume c style sexy comments if possible + if s:HasCStyleComments() + return (s:Left() ==# '/*' && s:Nested()) || (s:Left({'alt': 1}) ==# '/*' && s:AltNested()) + else + "grab the longest left delim that has a right + if s:Multipart() && lenLeft >= lenLeftAlt + return s:Nested() + elseif s:AltMultipart() + return s:AltNested() + else + return 0 + endif + endif +endfunction + +" Function: s:GetSexyComLeft(space, esc) {{{2 +" Returns the left delimiter for sexy comments for this filetype or -1 if +" there is none. C style sexy comments are used if possible +" Args: +" -space: specifies if the delimiter has a space string on the end +" (the space string will only be added if NERDSpaceDelims is set) +" -esc: specifies whether the tricky chars in the string are ESCed +function s:GetSexyComLeft(space, esc) + let lenLeft = strlen(s:Left()) + let lenLeftAlt = strlen(s:Left({'alt': 1})) + let left = '' + + "assume c style sexy comments if possible + if s:HasCStyleComments() + let left = '/*' + else + "grab the longest left delimiter that has a right + if s:Multipart() && lenLeft >= lenLeftAlt + let left = s:Left() + elseif s:AltMultipart() + let left = s:Left({'alt': 1}) + else + return -1 + endif + endif + + if a:space && g:NERDSpaceDelims + let left = left . s:spaceStr + endif + + if a:esc + let left = s:Esc(left) + endif + + return left +endfunction + +" Function: s:GetSexyComRight(space, esc) {{{2 +" Returns the right delimiter for sexy comments for this filetype or -1 if +" there is none. C style sexy comments are used if possible. +" Args: +" -space: specifies if the delimiter has a space string on the start +" (the space string will only be added if NERDSpaceDelims +" is specified for the current filetype) +" -esc: specifies whether the tricky chars in the string are ESCed +function s:GetSexyComRight(space, esc) + let lenLeft = strlen(s:Left()) + let lenLeftAlt = strlen(s:Left({'alt': 1})) + let right = '' + + "assume c style sexy comments if possible + if s:HasCStyleComments() + let right = '*/' + else + "grab the right delimiter that pairs with the longest left delimiter + if s:Multipart() && lenLeft >= lenLeftAlt + let right = s:Right() + elseif s:AltMultipart() + let right = s:Right({'alt': 1}) + else + return -1 + endif + endif + + if a:space && g:NERDSpaceDelims + let right = s:spaceStr . right + endif + + if a:esc + let right = s:Esc(right) + endif + + return right +endfunction + +" Function: s:HasMultipartDelims() {{{2 +" Returns 1 if the current filetype has at least one set of multipart delimiters +function s:HasMultipartDelims() + return s:Multipart() || s:AltMultipart() +endfunction + +" Function: s:HasLeadingTabs(...) {{{2 +" Returns 1 if any of the given strings have leading tabs +function s:HasLeadingTabs(...) + for s in a:000 + if s =~# '^\t.*' + return 1 + end + endfor + return 0 +endfunction +" Function: s:HasCStyleComments() {{{2 +" Returns 1 if the current filetype has c style comment delimiters +function s:HasCStyleComments() + return (s:Left() ==# '/*' && s:Right() ==# '*/') || (s:Left({'alt': 1}) ==# '/*' && s:Right({'alt': 1}) ==# '*/') +endfunction + +" Function: s:IsCommentedNormOrSexy(lineNum) {{{2 +"This function is used to determine whether the given line is commented with +"either set of delimiters or if it is part of a sexy comment +" +" Args: +" -lineNum: the line number of the line to check +function s:IsCommentedNormOrSexy(lineNum) + let theLine = getline(a:lineNum) + + "if the line is commented normally return 1 + if s:IsCommented(s:Left(), s:Right(), theLine) || s:IsCommented(s:Left({'alt': 1}), s:Right({'alt': 1}), theLine) + return 1 + endif + + "if the line is part of a sexy comment return 1 + if s:IsInSexyComment(a:lineNum) + return 1 + endif + return 0 +endfunction + +" Function: s:IsCommented(left, right, line) {{{2 +"This function is used to determine whether the given line is commented with +"the given delimiters +" +" Args: +" -line: the line that to check if commented +" -left/right: the left and right delimiters to check for +function s:IsCommented(left, right, line) + "if the line isn't commented return true + if s:FindDelimiterIndex(a:left, a:line) !=# -1 && (s:LastIndexOfDelim(a:right, a:line) !=# -1 || !s:Multipart()) + return 1 + endif + return 0 +endfunction + +" Function: s:IsCommentedFromStartOfLine(left, line) {{{2 +"This function is used to determine whether the given line is commented with +"the given delimiters at the start of the line i.e the left delimiter is the +"first thing on the line (apart from spaces\tabs) +" +" Args: +" -line: the line that to check if commented +" -left: the left delimiter to check for +function s:IsCommentedFromStartOfLine(left, line) + let theLine = s:ConvertLeadingTabsToSpaces(a:line) + let numSpaces = strlen(substitute(theLine, '^\( *\).*$', '\1', '')) + let delimIndx = s:FindDelimiterIndex(a:left, theLine) + return delimIndx ==# numSpaces +endfunction + +" Function: s:IsCommentedOutermost(left, right, leftAlt, rightAlt, line) {{{2 +" Finds the type of the outermost delimiters on the line +" +" Args: +" -line: the line that to check if the outermost comments on it are +" left/right +" -left/right: the left and right delimiters to check for +" -leftAlt/rightAlt: the left and right alternative delimiters to check for +" +" Returns: +" 0 if the line is not commented with either set of delimiters +" 1 if the line is commented with the left/right delimiter set +" 2 if the line is commented with the leftAlt/rightAlt delim set +function s:IsCommentedOutermost(left, right, leftAlt, rightAlt, line) + "get the first positions of the left delimiters and the last positions of the + "right delimiters + let indxLeft = s:FindDelimiterIndex(a:left, a:line) + let indxLeftAlt = s:FindDelimiterIndex(a:leftAlt, a:line) + let indxRight = s:LastIndexOfDelim(a:right, a:line) + let indxRightAlt = s:LastIndexOfDelim(a:rightAlt, a:line) + + "check if the line has a left delimiter before a leftAlt delimiter + if (indxLeft <= indxLeftAlt || indxLeftAlt ==# -1) && indxLeft !=# -1 + "check if the line has a right delimiter after any rightAlt delimiter + if (indxRight > indxRightAlt && indxRight > indxLeft) || !s:Multipart() + return 1 + endif + + "check if the line has a leftAlt delimiter before a left delimiter + elseif (indxLeftAlt <= indxLeft || indxLeft ==# -1) && indxLeftAlt !=# -1 + "check if the line has a rightAlt delimiter after any right delimiter + if (indxRightAlt > indxRight && indxRightAlt > indxLeftAlt) || !s:AltMultipart() + return 2 + endif + else + return 0 + endif + + return 0 + +endfunction + + +" Function: s:IsDelimValid(delimiter, delIndx, line) {{{2 +" This function is responsible for determining whether a given instance of a +" comment delimiter is a real delimiter or not. For example, in java the +" // string is a comment delimiter but in the line: +" System.out.println("//"); +" it does not count as a comment delimiter. This function is responsible for +" distinguishing between such cases. It does so by applying a set of +" heuristics that are not fool proof but should work most of the time. +" +" Args: +" -delimiter: the delimiter we are validating +" -delIndx: the position of delimiter in line +" -line: the line that delimiter occurs in +" +" Returns: +" 0 if the given delimiter is not a real delimiter (as far as we can tell) , +" 1 otherwise +function s:IsDelimValid(delimiter, delIndx, line) + "get the delimiter without the escchars + let l:delimiter = a:delimiter + + "get the strings before and after the delimiter + let preComStr = strpart(a:line, 0, a:delIndx) + let postComStr = strpart(a:line, a:delIndx+strlen(delimiter)) + + "to check if the delimiter is real, make sure it isn't preceded by + "an odd number of quotes and followed by the same (which would indicate + "that it is part of a string and therefore is not a comment) + if !s:IsNumEven(s:CountNonESCedOccurances(preComStr, '"', "\\")) && !s:IsNumEven(s:CountNonESCedOccurances(postComStr, '"', '\\')) + return 0 + endif + if !s:IsNumEven(s:CountNonESCedOccurances(preComStr, "'", '\\')) && !s:IsNumEven(s:CountNonESCedOccurances(postComStr, "'", '\\')) + return 0 + endif + if !s:IsNumEven(s:CountNonESCedOccurances(preComStr, '`', '\\')) && !s:IsNumEven(s:CountNonESCedOccurances(postComStr, '`', '\\')) + return 0 + endif + + + "if the comment delimiter is escaped, assume it isn't a real delimiter + if s:IsEscaped(a:line, a:delIndx, "\\") + return 0 + endif + + "vim comments are so fucking stupid!! Why the hell do they have comment + "delimiters that are used elsewhere in the syntax?!?! We need to check + "some conditions especially for vim + if &filetype ==# 'vim' + if !s:IsNumEven(s:CountNonESCedOccurances(preComStr, '"', "\\")) + return 0 + endif + + "if the delimiter is on the very first char of the line or is the + "first non-tab/space char on the line then it is a valid comment delimiter + if a:delIndx ==# 0 || a:line =~# "^[ \t]\\{" . a:delIndx . "\\}\".*$" + return 1 + endif + + let numLeftParen =s:CountNonESCedOccurances(preComStr, '(', '\\') + let numRightParen =s:CountNonESCedOccurances(preComStr, ')', '\\') + + "if the quote is inside brackets then assume it isn't a comment + if numLeftParen > numRightParen + return 0 + endif + + "if the line has an even num of unescaped "'s then we can assume that + "any given " is not a comment delimiter + if s:IsNumEven(s:CountNonESCedOccurances(a:line, '"', '\\')) + return 0 + endif + endif + + return 1 + +endfunction + +" Function: s:IsNumEven(num) {{{2 +" A small function the returns 1 if the input number is even and 0 otherwise +" Args: +" -num: the number to check +function s:IsNumEven(num) + return (a:num % 2) ==# 0 +endfunction + +" Function: s:IsEscaped(str, indx, escChar) {{{2 +" This function takes a string, an index into that string and an esc char and +" returns 1 if the char at the index is escaped (i.e if it is preceded by an +" odd number of esc chars) +" Args: +" -str: the string to check +" -indx: the index into str that we want to check +" -escChar: the escape char the char at indx may be ESCed with +function s:IsEscaped(str, indx, escChar) + "initialise numEscChars to 0 and look at the char before indx + let numEscChars = 0 + let curIndx = a:indx-1 + + "keep going back thru str until we either reach the start of the str or + "run out of esc chars + while curIndx >= 0 && strpart(a:str, curIndx, 1) ==# a:escChar + + "we have found another esc char so add one to the count and move left + "one char + let numEscChars = numEscChars + 1 + let curIndx = curIndx - 1 + + endwhile + + "if there is an odd num of esc chars directly before the char at indx then + "the char at indx is escaped + return !s:IsNumEven(numEscChars) +endfunction + +" Function: s:IsInSexyComment(line) {{{2 +" returns 1 if the given line number is part of a sexy comment +function s:IsInSexyComment(line) + return !empty(s:FindBoundingLinesOfSexyCom(a:line)) +endfunction + +" Function: s:IsSexyComment(topline, bottomline) {{{2 +" This function takes in 2 line numbers and returns 1 if the lines between and +" including the given line numbers are a sexy comment. It returns 0 otherwise. +" Args: +" -topline: the line that the possible sexy comment starts on +" -bottomline: the line that the possible sexy comment stops on +function s:IsSexyComment(topline, bottomline) + + "get the delimiter set that would be used for a sexy comment + let left = '' + let right = '' + if s:Multipart() + let left = s:Left() + let right = s:Right() + elseif s:AltMultipart() + let left = s:Left({'alt': 1}) + let right = s:Right({'alt': 1}) + else + return 0 + endif + + "swap the top and bottom line numbers around if need be + let topline = a:topline + let bottomline = a:bottomline + if bottomline < topline + let topline = bottomline + let bottomline = a:topline + endif + + "if there is < 2 lines in the comment it cannot be sexy + if (bottomline - topline) <= 0 + return 0 + endif + + "if the top line doesn't begin with a left delimiter then the comment isn't sexy + if getline(a:topline) !~# '^[ \t]*' . left + return 0 + endif + + "if there is a right delimiter on the top line then this isn't a sexy comment + if s:LastIndexOfDelim(right, getline(a:topline)) !=# -1 + return 0 + endif + + "if there is a left delimiter on the bottom line then this isn't a sexy comment + if s:FindDelimiterIndex(left, getline(a:bottomline)) !=# -1 + return 0 + endif + + "if the bottom line doesn't begin with a right delimiter then the comment isn't + "sexy + if getline(a:bottomline) !~# '^.*' . right . '$' + return 0 + endif + + let sexyComMarker = s:GetSexyComMarker(0, 1) + + "check each of the intermediate lines to make sure they start with a + "sexyComMarker + let currentLine = a:topline+1 + while currentLine < a:bottomline + let theLine = getline(currentLine) + + if theLine !~# '^[ \t]*' . sexyComMarker + return 0 + endif + + "if there is a right delimiter in an intermediate line then the block isn't + "a sexy comment + if s:LastIndexOfDelim(right, theLine) !=# -1 + return 0 + endif + + let currentLine = currentLine + 1 + endwhile + + "we have not found anything to suggest that this isn't a sexy comment so + return 1 + +endfunction + +" Function: s:LastIndexOfDelim(delim, str) {{{2 +" This function takes a string and a delimiter and returns the last index of +" that delimiter in string +" Args: +" -delim: the delimiter to look for +" -str: the string to look for delimiter in +function s:LastIndexOfDelim(delim, str) + let delim = a:delim + let lenDelim = strlen(delim) + + "set index to the first occurrence of delimiter. If there is no occurrence then + "bail + let indx = s:FindDelimiterIndex(delim, a:str) + if indx ==# -1 + return -1 + endif + + "keep moving to the next instance of delimiter in str till there is none left + while 1 + + "search for the next delimiter after the previous one + let searchStr = strpart(a:str, indx+lenDelim) + let indx2 = s:FindDelimiterIndex(delim, searchStr) + + "if we find a delimiter update indx to record the position of it, if we + "don't find another delimiter then indx is the last one so break out of + "this loop + if indx2 !=# -1 + let indx = indx + indx2 + lenDelim + else + break + endif + endwhile + + return indx + +endfunction + +" Function: s:Left(...) {{{2 +" returns left delimiter data +function s:Left(...) + let params = a:0 ? a:1 : {} + + let delim = has_key(params, 'alt') ? b:NERDCommenterDelims['leftAlt'] : b:NERDCommenterDelims['left'] + + if delim ==# '' + return '' + endif + + if has_key(params, 'space') && g:NERDSpaceDelims + let delim = delim . s:spaceStr + endif + + if has_key(params, 'esc') + let delim = s:Esc(delim) + endif + + return delim +endfunction + +" Function: s:LeftMostIndx(countCommentedLines, countEmptyLines, topline, bottomline) {{{2 +" This function takes in 2 line numbers and returns the index of the left most +" char (that is not a space or a tab) on all of these lines. +" Args: +" -countCommentedLines: 1 if lines that are commented are to be checked as +" well. 0 otherwise +" -countEmptyLines: 1 if empty lines are to be counted in the search +" -topline: the top line to be checked +" -bottomline: the bottom line to be checked +function s:LeftMostIndx(countCommentedLines, countEmptyLines, topline, bottomline) + + " declare the left most index as an extreme value + let leftMostIndx = 1000 + + " go thru the block line by line updating leftMostIndx + let currentLine = a:topline + while currentLine <= a:bottomline + + " get the next line and if it is allowed to be commented, or is not + " commented, check it + let theLine = getline(currentLine) + if a:countEmptyLines || theLine !~# '^[ \t]*$' + if a:countCommentedLines || (!s:IsCommented(s:Left(), s:Right(), theLine) && !s:IsCommented(s:Left({'alt': 1}), s:Right({'alt': 1}), theLine)) + " convert spaces to tabs and get the number of leading spaces for + " this line and update leftMostIndx if need be + let theLine = s:ConvertLeadingTabsToSpaces(theLine) + let leadSpaceOfLine = strlen( substitute(theLine, '\(^[ \t]*\).*$','\1','') ) + if leadSpaceOfLine < leftMostIndx + let leftMostIndx = leadSpaceOfLine + endif + endif + endif + + " move on to the next line + let currentLine = currentLine + 1 + endwhile + + if leftMostIndx ==# 1000 + return 0 + else + return leftMostIndx + endif +endfunction + +" Function: s:Multipart() {{{2 +" returns 1 if the current delimiters are multipart +function s:Multipart() + return s:Right() !=# '' +endfunction + +" Function: s:NerdEcho(msg, typeOfMsg) {{{2 +" Args: +" -msg: the message to echo +" -typeOfMsg: 0 = warning message +" 1 = normal message +function s:NerdEcho(msg, typeOfMsg) + if a:typeOfMsg ==# 0 + echohl WarningMsg + echom 'NERDCommenter:' . a:msg + echohl None + elseif a:typeOfMsg ==# 1 + echom 'NERDCommenter:' . a:msg + endif +endfunction + +" Function: s:Nested() {{{2 +" returns 1 if the current multipart (if any) delimiters allow nesting +function s:Nested() + return b:NERDCommenterDelims['nested'] +endfunction + +" Function: s:NumberOfLeadingTabs(s) {{{2 +" returns the number of leading tabs in the given string +function s:NumberOfLeadingTabs(s) + return strlen(substitute(a:s, '^\(\t*\).*$', '\1', '')) +endfunction + +" Function: s:NumLinesInBuf() {{{2 +" Returns the number of lines in the current buffer +function s:NumLinesInBuf() + return line('$') +endfunction + +" Function: s:ReplaceDelims(toReplace1, toReplace2, replacor1, replacor2, str) {{{2 +" This function takes in a string, 2 delimiters in that string and 2 strings +" to replace these delimiters with. +" +" Args: +" -toReplace1: the first delimiter to replace +" -toReplace2: the second delimiter to replace +" -replacor1: the string to replace toReplace1 with +" -replacor2: the string to replace toReplace2 with +" -str: the string that the delimiters to be replaced are in +function s:ReplaceDelims(toReplace1, toReplace2, replacor1, replacor2, str) + let line = s:ReplaceLeftMostDelim(a:toReplace1, a:replacor1, a:str) + let line = s:ReplaceRightMostDelim(a:toReplace2, a:replacor2, line) + return line +endfunction + +" Function: s:ReplaceLeftMostDelim(toReplace, replacor, str) {{{2 +" This function takes a string and a delimiter and replaces the left most +" occurrence of this delimiter in the string with a given string +" +" Args: +" -toReplace: the delimiter in str that is to be replaced +" -replacor: the string to replace toReplace with +" -str: the string that contains toReplace +function s:ReplaceLeftMostDelim(toReplace, replacor, str) + let toReplace = a:toReplace + let replacor = a:replacor + "get the left most occurrence of toReplace + let indxToReplace = s:FindDelimiterIndex(toReplace, a:str) + + "if there IS an occurrence of toReplace in str then replace it and return + "the resulting string + if indxToReplace !=# -1 + let line = strpart(a:str, 0, indxToReplace) . replacor . strpart(a:str, indxToReplace+strlen(toReplace)) + return line + endif + + return a:str +endfunction + +" Function: s:ReplaceRightMostDelim(toReplace, replacor, str) {{{2 +" This function takes a string and a delimiter and replaces the right most +" occurrence of this delimiter in the string with a given string +" +" Args: +" -toReplace: the delimiter in str that is to be replaced +" -replacor: the string to replace toReplace with +" -str: the string that contains toReplace +" +function s:ReplaceRightMostDelim(toReplace, replacor, str) + let toReplace = a:toReplace + let replacor = a:replacor + let lenToReplace = strlen(toReplace) + + "get the index of the last delimiter in str + let indxToReplace = s:LastIndexOfDelim(toReplace, a:str) + + "if there IS a delimiter in str, replace it and return the result + let line = a:str + if indxToReplace !=# -1 + let line = strpart(a:str, 0, indxToReplace) . replacor . strpart(a:str, indxToReplace+strlen(toReplace)) + endif + return line +endfunction + +"FUNCTION: s:RestoreScreenState() {{{2 +" +"Sets the screen state back to what it was when s:SaveScreenState was last +"called. +" +function s:RestoreScreenState() + if !exists('t:NERDComOldTopLine') || !exists('t:NERDComOldPos') + throw 'NERDCommenter exception: cannot restore screen' + endif + + call cursor(t:NERDComOldTopLine, 0) + normal! zt + call setpos('.', t:NERDComOldPos) +endfunction + +" Function: s:Right(...) {{{2 +" returns right delimiter data +function s:Right(...) + let params = a:0 ? a:1 : {} + + let delim = has_key(params, 'alt') ? b:NERDCommenterDelims['rightAlt'] : b:NERDCommenterDelims['right'] + + if delim ==# '' + return '' + endif + + if has_key(params, 'space') && g:NERDSpaceDelims + let delim = s:spaceStr . delim + endif + + if has_key(params, 'esc') + let delim = s:Esc(delim) + endif + + return delim +endfunction + +" Function: s:RightMostIndx(countCommentedLines, countEmptyLines, topline, bottomline) {{{2 +" This function takes in 2 line numbers and returns the index of the right most +" char on all of these lines. +" Args: +" -countCommentedLines: 1 if lines that are commented are to be checked as +" well. 0 otherwise +" -countEmptyLines: 1 if empty lines are to be counted in the search +" -topline: the top line to be checked +" -bottomline: the bottom line to be checked +function s:RightMostIndx(countCommentedLines, countEmptyLines, topline, bottomline) + let rightMostIndx = -1 + + " go thru the block line by line updating rightMostIndx + let currentLine = a:topline + while currentLine <= a:bottomline + + " get the next line and see if it is commentable, otherwise it doesn't + " count + let theLine = getline(currentLine) + if a:countEmptyLines || theLine !~# '^[ \t]*$' + + if a:countCommentedLines || (!s:IsCommented(s:Left(), s:Right(), theLine) && !s:IsCommented(s:Left({'alt': 1}), s:Right({'alt': 1}), theLine)) + + " update rightMostIndx if need be + let theLine = s:ConvertLeadingTabsToSpaces(theLine) + let lineLen = strlen(theLine) + if lineLen > rightMostIndx + let rightMostIndx = lineLen + endif + endif + endif + + " move on to the next line + let currentLine = currentLine + 1 + endwhile + + return rightMostIndx +endfunction + +"FUNCTION: s:SaveScreenState() {{{2 +"Saves the current cursor position in the current buffer and the window +"scroll position +function s:SaveScreenState() + let t:NERDComOldPos = getpos('.') + let t:NERDComOldTopLine = line('w0') +endfunction + +" Function: s:SwapOuterMultiPartDelimsForPlaceHolders(line) {{{2 +" This function takes a line and swaps the outer most multi-part delimiters for +" place holders +" Args: +" -line: the line to swap the delimiters in +" +function s:SwapOuterMultiPartDelimsForPlaceHolders(line) + " find out if the line is commented using normal delimiters and/or + " alternate ones + let isCommented = s:IsCommented(s:Left(), s:Right(), a:line) + let isCommentedAlt = s:IsCommented(s:Left({'alt': 1}), s:Right({'alt': 1}), a:line) + + let line2 = a:line + + "if the line is commented and there is a right delimiter, replace + "the delimiters with place-holders + if isCommented && s:Multipart() + let line2 = s:ReplaceDelims(s:Left(), s:Right(), g:NERDLPlace, g:NERDRPlace, a:line) + + "similarly if the line is commented with the alternative + "delimiters + elseif isCommentedAlt && s:AltMultipart() + let line2 = s:ReplaceDelims(s:Left({'alt': 1}), s:Right({'alt': 1}), g:NERDLPlace, g:NERDRPlace, a:line) + endif + + return line2 +endfunction + +" Function: s:SwapOuterPlaceHoldersForMultiPartDelims(line) {{{2 +" This function takes a line and swaps the outermost place holders for +" multi-part delimiters +" Args: +" -line: the line to swap the delimiters in +" +function s:SwapOuterPlaceHoldersForMultiPartDelims(line) + let left = '' + let right = '' + if s:Multipart() + let left = s:Left() + let right = s:Right() + elseif s:AltMultipart() + let left = s:Left({'alt': 1}) + let right = s:Right({'alt': 1}) + endif + + let line = s:ReplaceDelims(g:NERDLPlace, g:NERDRPlace, left, right, a:line) + return line +endfunction +" Function: s:TabbedCol(line, col) {{{2 +" Gets the col number for given line and existing col number. The new col +" number is the col number when all leading spaces are converted to tabs +" Args: +" -line:the line to get the rel col for +" -col: the abs col +function s:TabbedCol(line, col) + let lineTruncated = strpart(a:line, 0, a:col) + let lineSpacesToTabs = substitute(lineTruncated, s:TabSpace(), '\t', 'g') + return strlen(lineSpacesToTabs) +endfunction +"FUNCTION: s:TabSpace() {{{2 +"returns a string of spaces equal in length to &tabstop +function s:TabSpace() + let tabSpace = '' + let spacesPerTab = &tabstop + while spacesPerTab > 0 + let tabSpace = tabSpace . ' ' + let spacesPerTab = spacesPerTab - 1 + endwhile + return tabSpace +endfunction + +" Function: s:UnEsc(str, escChar) {{{2 +" This function removes all the escape chars from a string +" Args: +" -str: the string to remove esc chars from +" -escChar: the escape char to be removed +function s:UnEsc(str, escChar) + return substitute(a:str, a:escChar, '', 'g') +endfunction + +" Function: s:UntabbedCol(line, col) {{{2 +" Takes a line and a col and returns the absolute column of col taking into +" account that a tab is worth 3 or 4 (or whatever) spaces. +" Args: +" -line:the line to get the abs col for +" -col: the col that doesn't take into account tabs +function s:UntabbedCol(line, col) + let lineTruncated = strpart(a:line, 0, a:col) + let lineTabsToSpaces = substitute(lineTruncated, '\t', s:TabSpace(), 'g') + return strlen(lineTabsToSpaces) +endfunction +" Section: Comment mapping and menu item setup {{{1 +" =========================================================================== + +" Create menu items for the specified modes. If a:combo is not empty, then +" also define mappings and show a:combo in the menu items. +function! s:CreateMaps(modes, target, desc, combo) + " Build up a map command like + " 'noremap NERDCommenterComment :call NERDComment("n", "Comment")' + let plug = 'NERDCommenter' . a:target + let plug_start = 'noremap ' . plug . ' :call NERDComment("' + let plug_end = '", "' . a:target . '")' + " Build up a menu command like + " 'menu comment.Comment\\cc NERDCommenterComment' + let menuRoot = get(['', 'comment', '&comment', '&Plugin.&comment'], + \ g:NERDMenuMode, '') + let menu_command = 'menu ' . menuRoot . '.' . escape(a:desc, ' ') + if strlen(a:combo) + let leader = exists('g:mapleader') ? g:mapleader : '\' + let menu_command .= '' . escape(leader, '\') . a:combo + endif + let menu_command .= ' ' . (strlen(a:combo) ? plug : a:target) + " Execute the commands built above for each requested mode. + for mode in (a:modes ==# '') ? [''] : split(a:modes, '\zs') + if strlen(a:combo) + execute mode . plug_start . mode . plug_end + if g:NERDCreateDefaultMappings && !hasmapto(plug, mode) + execute mode . 'map ' . a:combo . ' ' . plug + endif + endif + " Check if the user wants the menu to be displayed. + if g:NERDMenuMode !=# 0 + execute mode . menu_command + endif + endfor +endfunction +call s:CreateMaps('nx', 'Comment', 'Comment', 'cc') +call s:CreateMaps('nx', 'Toggle', 'Toggle', 'c') +call s:CreateMaps('nx', 'Minimal', 'Minimal', 'cm') +call s:CreateMaps('nx', 'Nested', 'Nested', 'cn') +call s:CreateMaps('n', 'ToEOL', 'To EOL', 'c$') +call s:CreateMaps('nx', 'Invert', 'Invert', 'ci') +call s:CreateMaps('nx', 'Sexy', 'Sexy', 'cs') +call s:CreateMaps('nx', 'Yank', 'Yank then comment', 'cy') +call s:CreateMaps('n', 'Append', 'Append', 'cA') +call s:CreateMaps('', ':', '-Sep-', '') +call s:CreateMaps('nx', 'AlignLeft', 'Left aligned', 'cl') +call s:CreateMaps('nx', 'AlignBoth', 'Left and right aligned', 'cb') +call s:CreateMaps('', ':', '-Sep2-', '') +call s:CreateMaps('nx', 'Uncomment', 'Uncomment', 'cu') +call s:CreateMaps('n', 'AltDelims', 'Switch Delimiters', 'ca') +call s:CreateMaps('i', 'Insert', 'Insert Comment Here', '') +call s:CreateMaps('', ':', '-Sep3-', '') +call s:CreateMaps('', ':help NERDCommenterContents', 'Help', '') + +inoremap NERDCommenterInsert :call NERDComment('i', 'insert') + +" switch to/from alternative delimiters (does not use wrapper function) +nnoremap NERDCommenterAltDelims :call SwitchToAlternativeDelimiters(1) + +" This is a workaround to enable lazy-loading from supported plugin managers: +" See https://github.com/preservim/nerdcommenter/issues/176 +call s:SetUpForNewFiletype(&filetype, 1) + +" vim: set foldmethod=marker : diff --git a/skel/.config/nvim/plugged/sparkup/.gitignore b/skel/.config/nvim/plugged/sparkup/.gitignore new file mode 100644 index 0000000..0d0c8f5 --- /dev/null +++ b/skel/.config/nvim/plugged/sparkup/.gitignore @@ -0,0 +1,18 @@ +.DS_Store +.project +doc +distribution/ +.sourcescribe_index +*.swp +*.swo +*.pyc +cscope.out +*~ + +# symlinks created for pathogen +/ftplugin +/doc + +# Distribution files +# */sparkup +# */sparkup.py diff --git a/skel/.config/nvim/plugged/sparkup/Makefile b/skel/.config/nvim/plugged/sparkup/Makefile new file mode 100644 index 0000000..6605644 --- /dev/null +++ b/skel/.config/nvim/plugged/sparkup/Makefile @@ -0,0 +1,48 @@ +# Makefile for sparkup distribution +# TODO: this should use a separate build dir to copy SPARKUP_PY into. +# SPARKUP_PY should not reside in the Vim runtime dir (getting not updated via Git!) +SPARKUP_PY=sparkup.py +VERSION=`date '+%Y%m%d'` +README=README.md + +.PHONY: all textmate vim textmate-dist vim-dist plugins plugins-pre generic all-dist +all: plugins + +plugins-pre: + mkdir -p distribution + +plugins: plugins-pre all-dist + +textmate-dist: textmate + cd TextMate && zip -9r ../distribution/sparkup-textmate-${VERSION}.zip . && cd .. + +vim-dist: vim + cd vim && zip -9r ../distribution/sparkup-vim-${VERSION}.zip . && cd .. + +generic-dist: generic + cd generic && zip -9r ../distribution/sparkup-generic-${VERSION}.zip . && cd .. + +all-dist: + zip -9r distribution/sparkup-${VERSION}.zip generic vim textmate README.md -x */sparkup-readme.txt + cp distribution/sparkup-${VERSION}.zip distribution/sparkup-latest.zip + +generic: + cat ${SPARKUP_PY} > generic/sparkup + chmod +x generic/sparkup + #cp ${README} generic/sparkup-readme.txt + +textmate: + #cp ${README} TextMate/sparkup-readme.txt + +vim: vim/doc/sparkup.txt + +# create pathogen friendly structure +vim-pathogen: vim ftplugin doc + +ftplugin doc: + ln -s vim/$@ + +# Add asterisks to title, so it gets matched by `:helptags` +vim/doc/sparkup.txt: ${README} + mkdir -p $(@D) + sed '1s/.*/*\0*/' $< > $@ diff --git a/skel/.config/nvim/plugged/sparkup/README.md b/skel/.config/nvim/plugged/sparkup/README.md new file mode 100644 index 0000000..ce7ef61 --- /dev/null +++ b/skel/.config/nvim/plugged/sparkup/README.md @@ -0,0 +1,175 @@ +Sparkup +======= + +**Sparkup lets you write HTML code faster.** Don't believe us? +[See it in action!](http://www.youtube.com/watch?v=Jw3jipcenKc) + +Fixed by Zhao: +This is a fork of original version. This version support both python 2 and 3. + +You can write HTML in a CSS-like syntax, and have Sparkup handle the expansion to full HTML +code. It is meant to help you write long HTML blocks in your text editor by letting you +type less characters than needed. + +Sparkup is written in Python, and requires Python 2.5 or newer (2.5 is preinstalled in +Mac OS X Leopard). Sparkup also offers integration into common text editors. Support for VIM +and TextMate are currently included. + +A short screencast is available here: +[http://www.youtube.com/watch?v=Jw3jipcenKc](http://www.youtube.com/watch?v=Jw3jipcenKc) + +Usage and installation +---------------------- +You may download Sparkup from GitHub. [Download the latest version here](http://github.com/rstacruz/sparkup/downloads). + + - **TextMate**: Simply double-click on the `Sparkup.tmbundle` package in Finder. This + will install it automatically. In TextMate, open an HTML file (or set the document type to + HTML) type in something (e.g., `#header > h1`), then press `Ctrl` + `E`. Pressing `Tab` + will cycle through empty elements. + + - **VIM**: See the `vim/README.txt` file for installation. In VIM, + create or open an HTML file (or set the filetype to ``html``), type in something (e.g. + `#header > h1`), then press `` whilst in **insert mode** to expand to HTML. + Pressing `` will cycle through empty elements. Variables specified in + `vim/README.txt` can be used to customise key mappings, and to add **normal mode** mappings + as well. + + - **Others/command line use**: You may put `sparkup` in your `$PATH` somewhere. You may then + invoke it by typing `echo "(input here)" | sparkup`, or `sparkup --help` for a list of commands. + +Credits +------- + +Sparkup is written by Rico Sta. Cruz and is released under the MIT license. + +This project is inspired by [Zen Coding](http://code.google.com/p/zen-coding/) of +[Vadim Makeev](http://pepelsbey.net). The Zen HTML syntax is forward-compatible with Sparkup +(anything that Zen HTML can parse, Sparkup can too). + +The following people have contributed code to the project: + + - Guillermo O. Freschi (Tordek @ GitHub) + Bugfixes to the parsing system + + - Eric Van Dewoestine (ervandew @ GitHub) + Improvements to the VIM plugin + +Examples +-------- + +**`div`** expands to: + +```html +
+``` + +**`div#header`** expands to: + +```html + +``` + +**`div.align-left#header`** expands to: + +```html + +``` + +**`div#header + div#footer`** expands to: + +```html + + +``` + +**`#menu > ul`** expands to: + +```html + +``` + +**`#menu > h3 + ul`** expands to: + +```html + +``` + +**`#header > h1{Welcome to our site}`** expands to: + +```html + +``` + +**`a[href=index.html]{Home}`** expands to: + +```html + Home +``` + +**`ul > li*3`** expands to: + +```html +
    +
  • +
  • +
  • +
+``` + +**`ul > li.item-$*3`** expands to: + +```html +
    +
  • +
  • +
  • +
+``` + +**`ul > li.item-$*3 > strong`** expands to: + +```html +
    +
  • +
  • +
  • +
+``` + +**`table > tr*2 > td.name + td*3`** expands to: + +```html + + + + + + + + + + + + + +
+``` + +**`#header > ul > li < p{Footer}`** expands to: + +```html + + +``` diff --git a/skel/.config/nvim/plugged/sparkup/TextMate/Sparkup.tmbundle/Commands/Sparkup expand.tmCommand b/skel/.config/nvim/plugged/sparkup/TextMate/Sparkup.tmbundle/Commands/Sparkup expand.tmCommand new file mode 100644 index 0000000..795dfba --- /dev/null +++ b/skel/.config/nvim/plugged/sparkup/TextMate/Sparkup.tmbundle/Commands/Sparkup expand.tmCommand @@ -0,0 +1,35 @@ + + + + + beforeRunningCommand + nop + command + #!/usr/bin/env python2 +import sys; import os; sys.path.append(os.getenv('TM_BUNDLE_SUPPORT')); import sparkup + +# You may change these options to your liking. +# Those starting with # are comments (disabled). +options = { + 'textmate': True, + 'no-last-newline': True, + 'indent-tabs': False, + #'start-guide-format': 'Begin %s', + #'end-guide-format': 'End %s', +} + +sparkup.Router().start(options=options) + fallbackInput + line + input + selection + keyEquivalent + ^e + name + Sparkup expand + output + insertAsSnippet + uuid + 73A48D2B-D843-42A1-A288-0D1A6380043B + + diff --git a/skel/.config/nvim/plugged/sparkup/TextMate/Sparkup.tmbundle/Support/sparkup.py b/skel/.config/nvim/plugged/sparkup/TextMate/Sparkup.tmbundle/Support/sparkup.py new file mode 120000 index 0000000..0504c75 --- /dev/null +++ b/skel/.config/nvim/plugged/sparkup/TextMate/Sparkup.tmbundle/Support/sparkup.py @@ -0,0 +1 @@ +../../../sparkup.py \ No newline at end of file diff --git a/skel/.config/nvim/plugged/sparkup/TextMate/Sparkup.tmbundle/info.plist b/skel/.config/nvim/plugged/sparkup/TextMate/Sparkup.tmbundle/info.plist new file mode 100644 index 0000000..2e22c0d --- /dev/null +++ b/skel/.config/nvim/plugged/sparkup/TextMate/Sparkup.tmbundle/info.plist @@ -0,0 +1,14 @@ + + + + + name + Sparkup + ordering + + AA687F82-BF47-477C-A832-D3671736EA81 + + uuid + 0CDE6908-2EF0-4E86-A9C1-5AC12E320414 + + diff --git a/skel/.config/nvim/plugged/sparkup/ftdetect/hsb.vim b/skel/.config/nvim/plugged/sparkup/ftdetect/hsb.vim new file mode 100644 index 0000000..8a2c8cb --- /dev/null +++ b/skel/.config/nvim/plugged/sparkup/ftdetect/hsb.vim @@ -0,0 +1 @@ +au BufNewFile,BufRead *.hbs set filetype=html diff --git a/skel/.config/nvim/plugged/sparkup/mit-license.txt b/skel/.config/nvim/plugged/sparkup/mit-license.txt new file mode 100644 index 0000000..292d6b2 --- /dev/null +++ b/skel/.config/nvim/plugged/sparkup/mit-license.txt @@ -0,0 +1,22 @@ +Copyright (c) 2009, Rico Sta. Cruz. + +Permission is hereby granted, free of charge, to any person +obtaining a copy of this software and associated documentation +files (the "Software"), to deal in the Software without +restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. diff --git a/skel/.config/nvim/plugged/sparkup/sparkup-unittest.py b/skel/.config/nvim/plugged/sparkup/sparkup-unittest.py new file mode 100755 index 0000000..14d55cb --- /dev/null +++ b/skel/.config/nvim/plugged/sparkup/sparkup-unittest.py @@ -0,0 +1,184 @@ +#!/usr/bin/env python2 +# -*- coding: utf-8 -*- +import sys +import sparkup + + +class SparkupTest: + options = { + 'textmate': True, + 'no-last-newline': True, + 'post-tag-guides': True, + } + options = { + 'default': {'textmate': True, 'no-last-newline': True, 'post-tag-guides': True}, + 'guides': {'textmate': True, 'no-last-newline': True, 'post-tag-guides': True, 'start-guide-format': 'Begin %s'}, + 'namespaced-elements': {'textmate': True, 'no-last-newline': True, 'post-tag-guides': True, 'namespaced-elements': True } + } + cases = { + 'Simple test': { + 'options': 'default', + 'input': 'div', + 'output': '
$1
$0' + }, + 'Class test': { + 'input': 'div.lol', + 'output': '
$1
$0' + }, + 'ID and class test': { + 'input': 'div.class#id', + 'output': '
$1
$0' + }, + 'ID and class test 2': { + 'input': 'div#id.class', + 'output': '
$1
$0' + }, + 'Attributes test': { + 'input': 'div#id.class[style=color:blue]', + 'output': '
$1
$0' + }, + 'Multiple attributes test': { + 'input': 'div[align=center][style=color:blue][rel=none]', + 'output': '
$1
$0' + }, + 'Multiple class test': { + 'input': 'div.c1.c2.c3', + 'output': '
$1
$0' + }, + 'Shortcut test': { + 'input': 'input:button', + 'output': '$0' + }, + 'Shortcut synonym test': { + 'input': 'button', + 'output': '$0', + }, + 'Child test': { + 'input': 'div>ul>li', + 'output': "
\n
    \n
  • $1
  • \n
\n
$0" + }, + 'Sibling test': { + 'input': 'div#x + ul+ h3.class', + 'output': '
$1
\n
    $2
\n

$3

$0' + }, + 'Child + sibling test': { + 'input': 'div > ul > li + span', + 'output': '
\n
    \n
  • $1
  • \n $2\n
\n
$0' + }, + 'Multiplier test 1': { + 'input': 'ul > li*3', + 'output': '
    \n
  • $1
  • \n
  • $2
  • \n
  • $3
  • \n
$0' + }, + 'Multiplier test 2': { + 'input': 'ul > li.item-$*3', + 'output': '
    \n
  • $1
  • \n
  • $2
  • \n
  • $3
  • \n
$0' + }, + 'Multiplier test 3': { + 'input': 'ul > li.item-$*3 > a', + 'output': '
    \n
  • \n $2\n
  • \n
  • \n $4\n
  • \n
  • \n $6\n
  • \n
$0' + }, + 'Ampersand test': { + 'input': 'td > tr.row-$*3 > td.cell-&*2', + 'output': '\n \n $1\n $2\n \n \n $3\n $4\n \n \n $5\n $6\n \n$0' + }, + 'Menu test': { + 'input': 'ul#menu > li*3 > a > span', + 'output': '$0' + }, + 'Back test': { + 'input': 'ul#menu > li*3 > a < < div', + 'output': '\n
$7
$0' + }, + 'Expand test': { + 'input': 'p#menu > table+ + ul', + 'output': '
    $2
\n

$0' + }, + 'Text with dot test': { + 'input': 'p { text.com }', + 'output': '

text.com

$0' + }, + 'Attribute with dot test': { + 'input': 'p [attrib=text.com]', + 'output': '

$1

$0' + }, + 'PHP tag test': { + 'input': 'php', + 'output': '$0', + }, + 'Eruby tag test': { + 'input': 'erb:p', + 'output': '<%= %>$0', + }, + 'ERB block test': { + 'input': 'erb:b', + 'output': '<% $2 %>\n $1\n<% end %>$0' + }, + 'Tag name case (#49)': { + 'input': 'groupId{foobar}', + 'output': 'foobar$0' + }, + 'Nested curly braces test': { + 'input': 'p{{{ title }}}', + 'output': '

{{ title }}

$0' + }, + 'Nested curly braces test (#54)': { + 'input': 'html>head>title{${title}}', + 'output': '\n \n ${title}\n \n$0' + }, + 'HTML component element with dash test': { + 'input': 'my-html-component', + 'output': '$1$0' + }, + 'XML namespaced element': { + 'options': 'namespaced-elements', + 'input': 'namespaced-ul', + 'output': '$1$0' + }, + # Add: text test, broken test, multi-attribute tests, indentation test, start and end comments test + } + + def run(self): + """Run Forrest run!""" + failures = 0 + + print("Test results:") + for name, case in self.cases.iteritems(): + try: + options_key = case['options'] + except: + options_key = 'default' + + try: + options = self.options[options_key] + except: + options = self.options['default'] + + # Output buffer + r = sparkup.Router() + input = case['input'] + output = r.start(options=options, str=input, ret=True) + del r + + # Did it work? + result = output == case['output'] + if result: + result_str = " OK " + else: + result_str = "FAIL" + + print(" - %-30s [%s]" % (name, result_str)) + if not result: + failures += 1 + print("= %s" % input.replace("\n", "\n= ")) + print("Actual output (condensed):") + print(" | '%s'" % output.replace("\n", r"\n").replace('"', '\"')) + print("Actual output:") + print(" | %s" % output.replace("\n", "\n | ")) + print("Expected:") + print(" | %s" % case['output'].replace("\n", "\ n| ")) + + return failures + +if __name__ == '__main__': + s = SparkupTest() + sys.exit(s.run()) diff --git a/skel/.config/nvim/plugged/sparkup/sparkup.py b/skel/.config/nvim/plugged/sparkup/sparkup.py new file mode 100755 index 0000000..b545df2 --- /dev/null +++ b/skel/.config/nvim/plugged/sparkup/sparkup.py @@ -0,0 +1,1171 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +version = "0.1.4" + +import getopt +import sys +import re + +# ============================================================================= + +def iteritems(obj): + """iteritems() in python2 and items() in python3""" + if sys.version[0] == '2': + return obj.iteritems() + else: + return obj.items() + +class Dialect: + shortcuts = {} + synonyms = {} + required = {} + short_tags = () + +class XmlDialect(Dialect): + shortcuts = {} + synonyms = {} + short_tags = () + required = {} + +class HtmlDialect(Dialect): + # Constructor, accepts an indent which should come from an Options object + # so it integrates well with their editing environment. + def __init__(self, indent=4): + self.indent = indent + + self.shortcuts = { + 'cc:ie': { + 'opening_tag': ''}, + 'cc:ie8': { + 'opening_tag': ''}, + 'cc:ie9': { + 'opening_tag': ''}, + 'cc:noie': { + 'opening_tag': '', + 'closing_tag': ''}, + 'php:t': { + 'expand': True, + 'opening_tag': '', + }, + 'erb:p': { + 'opening_tag': '<%= ', + 'closing_tag': ' %>', + }, + 'erb:c': { + 'opening_tag': '%<# ', + 'closing_tag': ' %>', + }, + 'erb:d': { + 'opening_tag': '<% ', + 'closing_tag': ' %>', + }, + 'erb:b': { + 'expand': True, + 'opening_tag' : '<% $2 %>', + 'closing_tag' : '<% end %>', + }, + 'erb:bp': { + 'expand': True, + 'opening_tag' : '<%= $2 %>', + 'closing_tag' : '<% end %>', + }, + 'html:4t': { + 'expand': True, + 'opening_tag': + '\n' + + '\n' + + '\n' + + (' ' * self.indent) + '\n' + + (' ' * self.indent) + '\n' + + '\n' + + '', + 'closing_tag': + '\n' + + ''}, + 'html:4s': { + 'expand': True, + 'opening_tag': + '\n' + + '\n' + + '\n' + + (' ' * self.indent) + '\n' + + (' ' * self.indent) + '\n' + + '\n' + + '', + 'closing_tag': + '\n' + + ''}, + 'html:xt': { + 'expand': True, + 'opening_tag': + '\n' + + '\n' + + '\n' + + (' ' * self.indent) + '\n' + + (' ' * self.indent) + '\n' + + '\n' + + '', + 'closing_tag': + '\n' + + ''}, + 'html:xs': { + 'expand': True, + 'opening_tag': + '\n' + + '\n' + + '\n' + + (' ' * self.indent) + '\n' + + (' ' * self.indent) + '\n' + + '\n' + + '', + 'closing_tag': + '\n' + + ''}, + 'html:xxs': { + 'expand': True, + 'opening_tag': + '\n' + + '\n' + + '\n' + + (' ' * self.indent) + '\n' + + (' ' * self.indent) + '\n' + + '\n' + + '', + 'closing_tag': + '\n' + + ''}, + 'html:5': { + 'expand': True, + 'opening_tag': + '\n' + + '\n' + + '\n' + + (' ' * self.indent) + '\n' + + (' ' * self.indent) + '\n' + + '\n' + + '', + 'closing_tag': + '\n' + + ''}, + 'input:button': { + 'name': 'input', + 'attributes': { 'class': 'button', 'type': 'button', 'name': '', 'value': '' } + }, + 'input:password': { + 'name': 'input', + 'attributes': { 'class': 'text password', 'type': 'password', 'name': '', 'value': '' } + }, + 'input:radio': { + 'name': 'input', + 'attributes': { 'class': 'radio', 'type': 'radio', 'name': '', 'value': '' } + }, + 'input:checkbox': { + 'name': 'input', + 'attributes': { 'class': 'checkbox', 'type': 'checkbox', 'name': '', 'value': '' } + }, + 'input:file': { + 'name': 'input', + 'attributes': { 'class': 'file', 'type': 'file', 'name': '', 'value': '' } + }, + 'input:text': { + 'name': 'input', + 'attributes': { 'class': 'text', 'type': 'text', 'name': '', 'value': '' } + }, + 'input:submit': { + 'name': 'input', + 'attributes': { 'class': 'submit', 'type': 'submit', 'value': '' } + }, + 'input:hidden': { + 'name': 'input', + 'attributes': { 'type': 'hidden', 'name': '', 'value': '' } + }, + 'script:src': { + 'name': 'script', + 'attributes': { 'src': '' } + }, + 'script:jquery': { + 'name': 'script', + 'attributes': { 'src': 'http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js' } + }, + 'script:jquery2': { + 'name': 'script', + 'attributes': { 'src': 'http://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js' } + }, + 'script:jsapi': { + 'name': 'script', + 'attributes': { 'src': 'http://www.google.com/jsapi' } + }, + 'script:jsapix': { + 'name': 'script', + 'text': '\n google.load("jquery", "1.3.2");\n google.setOnLoadCallback(function() {\n \n });\n' + }, + 'link:css': { + 'name': 'link', + 'attributes': { 'rel': 'stylesheet', 'type': 'text/css', 'href': '', 'media': 'all' }, + }, + 'link:print': { + 'name': 'link', + 'attributes': { 'rel': 'stylesheet', 'type': 'text/css', 'href': '', 'media': 'print' }, + }, + 'link:favicon': { + 'name': 'link', + 'attributes': { 'rel': 'shortcut icon', 'type': 'image/x-icon', 'href': '' }, + }, + 'link:touch': { + 'name': 'link', + 'attributes': { 'rel': 'apple-touch-icon', 'href': '' }, + }, + 'link:rss': { + 'name': 'link', + 'attributes': { 'rel': 'alternate', 'type': 'application/rss+xml', 'title': 'RSS', 'href': '' }, + }, + 'link:atom': { + 'name': 'link', + 'attributes': { 'rel': 'alternate', 'type': 'application/atom+xml', 'title': 'Atom', 'href': '' }, + }, + 'meta:ieedge': { + 'name': 'meta', + 'attributes': { 'http-equiv': 'X-UA-Compatible', 'content': 'IE=edge' }, + }, + 'form:get': { + 'name': 'form', + 'attributes': { 'method': 'get' }, + }, + 'form:g': { + 'name': 'form', + 'attributes': { 'method': 'get' }, + }, + 'form:post': { + 'name': 'form', + 'attributes': { 'method': 'post' }, + }, + 'form:p': { + 'name': 'form', + 'attributes': { 'method': 'post' }, + }, + } + self.synonyms = { + 'php': 'php:t', + 'checkbox': 'input:checkbox', + 'check': 'input:checkbox', + 'input:c': 'input:checkbox', + 'input:b': 'input:button', + 'input:h': 'input:hidden', + 'hidden': 'input:hidden', + 'submit': 'input:submit', + 'input:s': 'input:submit', + 'radio': 'input:radio', + 'input:r': 'input:radio', + 'text': 'input:text', + 'pass': 'input:password', + 'passwd': 'input:password', + 'password': 'input:password', + 'pw': 'input:password', + 'input': 'input:text', + 'input:t': 'input:text', + 'linkcss': 'link:css', + 'scriptsrc': 'script:src', + 'jquery': 'script:jquery', + 'jsapi': 'script:jsapi', + 'html5': 'html:5', + 'html4': 'html:4s', + 'html4s': 'html:4s', + 'html4t': 'html:4t', + 'xhtml': 'html:xxs', + 'xhtmlt': 'html:xt', + 'xhtmls': 'html:xs', + 'xhtml11': 'html:xxs', + 'opt': 'option', + 'st': 'strong', + 'css': 'style', + 'csss': 'link:css', + 'css:src': 'link:css', + 'csssrc': 'link:css', + 'js': 'script', + 'jss': 'script:src', + 'js:src': 'script:src', + 'jssrc': 'script:src', + } + self.short_tags = ( + 'area', 'base', 'basefont', 'br', 'embed', 'hr', + 'input', 'img', 'link', 'param', 'meta') + self.required = { + 'a': {'href':''}, + 'base': {'href':''}, + 'abbr': {'title': ''}, + 'acronym':{'title': ''}, + 'bdo': {'dir': ''}, + 'link': {'rel': 'stylesheet', 'href': ''}, + 'style': {'type': 'text/css'}, + 'script': {'type': 'text/javascript'}, + 'img': {'src':'', 'alt':''}, + 'iframe': {'src': '', 'frameborder': '0'}, + 'embed': {'src': '', 'type': ''}, + 'object': {'data': '', 'type': ''}, + 'param': {'name': '', 'value': ''}, + 'form': {'action': '', 'method': 'post'}, + 'input': {'type': '', 'name': '', 'value': ''}, + 'area': {'shape': '', 'coords': '', 'href': '', 'alt': ''}, + 'select': {'name': ''}, + 'option': {'value': ''}, + 'textarea':{'name': ''}, + 'meta': {'content': ''}, + } + short_tags = ( + 'area', 'base', 'basefont', 'br', 'embed', 'hr', + 'input', 'img', 'link', 'param', 'meta') + required = { + 'a': {'href':''}, + 'base': {'href':''}, + 'abbr': {'title': ''}, + 'acronym':{'title': ''}, + 'bdo': {'dir': ''}, + 'link': {'rel': 'stylesheet', 'href': ''}, + 'style': {'type': 'text/css'}, + 'script': {'type': 'text/javascript'}, + 'img': {'src':'', 'alt':''}, + 'iframe': {'src': '', 'frameborder': '0'}, + 'embed': {'src': '', 'type': ''}, + 'object': {'data': '', 'type': ''}, + 'param': {'name': '', 'value': ''}, + 'form': {'action': '', 'method': 'post'}, + 'input': {'type': '', 'name': '', 'value': ''}, + 'area': {'shape': '', 'coords': '', 'href': '', 'alt': ''}, + 'select': {'name': ''}, + 'option': {'value': ''}, + 'textarea':{'name': ''}, + 'meta': {'content': ''}, + } + +class Parser: + """The parser. + """ + + # Constructor + # ------------------------------------------------------------------------- + + def __init__(self, options=None, str=''): + """Constructor. + """ + + self.tokens = [] + self.str = str + self.options = options + if self.options.has("xml"): + self.dialect = XmlDialect() + else: + self.dialect = HtmlDialect(int(self.options.options['indent-spaces'])) + self.root = Element(parser=self) + self.caret = [] + self.caret.append(self.root) + self._last = [] + + # Methods + # ------------------------------------------------------------------------- + + def load_string(self, str): + """Loads a string to parse. + """ + + self.str = str + self._tokenize() + self._parse() + + def render(self): + """Renders. + Called by [[Router]]. + """ + + # Get the initial render of the root node + output = self.root.render() + + # Indent by whatever the input is indented with + indent = re.findall("^[\r\n]*(\s*)", self.str)[0] + output = indent + output.replace("\n", "\n" + indent) + + # Strip newline if not needed + if self.options.has("no-last-newline") \ + or self.prefix or self.suffix: + output = re.sub(r'\n\s*$', '', output) + + # TextMate mode + if self.options.has("textmate"): + output = self._textmatify(output) + + return output + + # Protected methods + # ------------------------------------------------------------------------- + + def _textmatify(self, output): + """Returns a version of the output with TextMate placeholders in it. + """ + + matches = re.findall(r'(>$%i]+>\s*)", str) + if match is None: break + if self.prefix is None: self.prefix = '' + self.prefix += match.group(0) + str = str[len(match.group(0)):] + + while True: + match = re.findall(r"(\s*<[^>]+>[\s\n\r]*)$", str) + if not match: break + if self.suffix is None: self.suffix = '' + self.suffix = match[0] + self.suffix + str = str[:-len(match[0])] + + # Split by the element separators + for token in re.split('(<|>|\+(?!\\s*\+|$))', str): + if token.strip() != '': + self.tokens.append(Token(token, parser=self)) + + def _parse(self): + """Takes the tokens and does its thing. + Populates [[self.root]]. + """ + + # Carry it over to the root node. + if self.prefix or self.suffix: + self.root.prefix = self.prefix + self.root.suffix = self.suffix + self.root.depth += 1 + + for token in self.tokens: + if token.type == Token.ELEMENT: + # Reset the "last elements added" list. We will + # repopulate this with the new elements added now. + self._last[:] = [] + + # Create [[Element]]s from a [[Token]]. + # They will be created as many as the multiplier specifies, + # multiplied by how many carets we have + count = 0 + for caret in self.caret: + local_count = 0 + for i in range(token.multiplier): + count += 1 + local_count += 1 + new = Element(token, caret, + count = count, + local_count = local_count, + parser = self) + self._last.append(new) + caret.append(new) + + # For > + elif token.type == Token.CHILD: + # The last children added. + self.caret[:] = self._last + + # For < + elif token.type == Token.PARENT: + # If we're the root node, don't do anything + parent = self.caret[0].parent + if parent is not None: + self.caret[:] = [parent] + return + + # Properties + # ------------------------------------------------------------------------- + + # Property: dialect + # The dialect of XML + dialect = None + + # Property: str + # The string + str = '' + + # Property: tokens + # The list of tokens + tokens = [] + + # Property: options + # Reference to the [[Options]] instance + options = None + + # Property: root + # The root [[Element]] node. + root = None + + # Property: caret + # The current insertion point. + caret = None + + # Property: _last + # List of the last appended stuff + _last = None + + # Property: indent + # Yeah + indent = '' + + # Property: prefix + # (String) The trailing tag in the beginning. + # + # Description: + # For instance, in `
ul>li
`, the `prefix` is `
`. + prefix = '' + + # Property: suffix + # (string) The trailing tag at the end. + suffix = '' + pass + +# ============================================================================= + +class Element: + """An element. + """ + + def __init__(self, token=None, parent=None, count=None, local_count=None, + parser=None, opening_tag=None, closing_tag=None, + attributes=None, name=None, text=None): + """Constructor. + + This is called by ???. + + Description: + All parameters are optional. + + token - (Token) The token (required) + parent - (Element) Parent element; `None` if root + count - (Int) The number to substitute for `&` (e.g., in `li.item-$`) + local_count - (Int) The number to substitute for `$` (e.g., in `li.item-&`) + parser - (Parser) The parser + + attributes - ... + name - ... + text - ... + """ + + self.children = [] + self.attributes = {} + self.parser = parser + + if token is not None: + # Assumption is that token is of type [[Token]] and is + # a [[Token.ELEMENT]]. + self.name = token.name + self.attributes = token.attributes.copy() + self.text = token.text + self.populate = token.populate + self.expand = token.expand + self.opening_tag = token.opening_tag + self.closing_tag = token.closing_tag + + # `count` can be given. This will substitude & in classname and ID + if count is not None: + for key in self.attributes: + attrib = self.attributes[key] + attrib = attrib.replace('&', ("%i" % count)) + if local_count is not None: + attrib = attrib.replace('$', ("%i" % local_count)) + self.attributes[key] = attrib + + # Copy over from parameters + if attributes: self.attributes = attributes + if name: self.name = name + if text: self.text = text + + self._fill_attributes() + + self.parent = parent + if parent is not None: + self.depth = parent.depth + 1 + + if self.populate: self._populate() + + def render(self): + """Renders the element, along with it's subelements, into HTML code. + + [Grouped under "Rendering methods"] + """ + + output = "" + + try: tabs = bool(self.parser.options.options['indent-tabs']) + except: tabs = False + + if tabs: + spaces = '\t' + else: + try: spaces_count = int(self.parser.options.options['indent-spaces']) + except: spaces_count = 4 + spaces = ' ' * spaces_count + + indent = self.depth * spaces + + prefix, suffix = ('', '') + if self.prefix: prefix = self.prefix + "\n" + if self.suffix: suffix = self.suffix + + # Make the guide from the ID (/#header), or the class if there's no ID (/.item) + # This is for the start-guide, end-guide and post-tag-guides + guide_str = '' + if 'id' in self.attributes: + guide_str += "#%s" % self.attributes['id'] + elif 'class' in self.attributes: + guide_str += ".%s" % self.attributes['class'].replace(' ', '.') + + # Build the post-tag guide (e.g.,
), + # the start guide, and the end guide. + guide = '' + start_guide = '' + end_guide = '' + if ((self.name == 'div') and + (('id' in self.attributes) or ('class' in self.attributes))): + + if (self.parser.options.has('post-tag-guides')): + guide = "" % guide_str + + if (self.parser.options.has('start-guide-format')): + format = self.parser.options.get('start-guide-format') + try: start_guide = format % guide_str + except: start_guide = (format + " " + guide_str).strip() + start_guide = "%s\n" % (indent, start_guide) + + if (self.parser.options.has('end-guide-format')): + format = self.parser.options.get('end-guide-format') + try: end_guide = format % guide_str + except: end_guide = (format + " " + guide_str).strip() + end_guide = "\n%s" % (indent, end_guide) + + # Short, self-closing tags (
) + short_tags = self.parser.dialect.short_tags + + # When it should be expanded.. + # (That is,
\n...\n
or similar -- wherein something must go + # inside the opening/closing tags) + if len(self.children) > 0 \ + or self.expand \ + or prefix or suffix \ + or (self.parser.options.has('expand-divs') and self.name == 'div'): + + for child in self.children: + output += child.render() + + # For expand divs: if there are no children (that is, `output` + # is still blank despite above), fill it with a blank line. + if (output == ''): output = indent + spaces + "\n" + + # If we're a root node and we have a prefix or suffix... + # (Only the root node can have a prefix or suffix.) + if prefix or suffix: + output = "%s%s%s%s%s\n" % \ + (indent, prefix, output, suffix, guide) + + # Uh.. + elif self.name != '' or \ + self.opening_tag is not None or \ + self.closing_tag is not None: + output = start_guide + \ + indent + self.get_opening_tag() + "\n" + \ + output + \ + indent + self.get_closing_tag() + \ + guide + end_guide + "\n" + + + # Short, self-closing tags (
or
depending on configuration) + elif self.name in short_tags: + if self.parser.options.has('no-html5-self-closing'): + output = "%s<%s />\n" % (indent, self.get_default_tag()) + else: + output = "%s<%s>\n" % (indent, self.get_default_tag()) + + # Tags with text, possibly + elif self.name != '' or \ + self.opening_tag is not None or \ + self.closing_tag is not None: + between_tags = self.text + if self.parser.options.has('open-empty-tags'): + between_tags += "\n\n" + indent + output = "%s%s%s%s%s%s%s%s" % \ + (start_guide, indent, self.get_opening_tag(), + between_tags, + self.get_closing_tag(), + guide, end_guide, "\n") + + # Else, it's an empty-named element (like the root). Pass. + else: + pass + + return output + + def get_default_tag(self): + """Returns the opening tag (without brackets). + + Usage: + element.get_default_tag() + + [Grouped under "Rendering methods"] + """ + + output = '%s' % (self.name) + for key, value in iteritems(self.attributes): + output += ' %s="%s"' % (key, value) + return output + + def get_opening_tag(self): + if self.opening_tag is None: + return "<%s>" % self.get_default_tag() + else: + return self.opening_tag + + def get_closing_tag(self): + if self.closing_tag is None: + return "" % self.name + else: + return self.closing_tag + + def append(self, object): + """Registers an element as a child of this element. + + Usage: + element.append(child) + + Description: + Adds a given element `child` to the children list of this element. It + will be rendered when [[render()]] is called on the element. + + See also: + - [[get_last_child()]] + + [Grouped under "Traversion methods"] + """ + + self.children.append(object) + + def get_last_child(self): + """Returns the last child element which was [[append()]]ed to this element. + + Usage: + element.get_last_child() + + Description: + This is the same as using `element.children[-1]`. + + [Grouped under "Traversion methods"] + """ + + return self.children[-1] + + def _populate(self): + """Expands with default items. + + This is called when the [[populate]] flag is turned on. + """ + + if self.name == 'ul': + elements = [Element(name='li', parent=self, parser=self.parser)] + + elif self.name == 'dl': + elements = [ + Element(name='dt', parent=self, parser=self.parser), + Element(name='dd', parent=self, parser=self.parser)] + + elif self.name == 'table': + tr = Element(name='tr', parent=self, parser=self.parser) + td = Element(name='td', parent=tr, parser=self.parser) + tr.children.append(td) + elements = [tr] + + else: + elements = [] + + for el in elements: + self.children.append(el) + + def _fill_attributes(self): + """Fills default attributes for certain elements. + + Description: + This is called by the constructor. + + [Protected, grouped under "Protected methods"] + """ + + # Make sure 's have a href, 's have an src, etc. + required = self.parser.dialect.required + + for element, attribs in iteritems(required): + if self.name == element: + for attrib in attribs: + if attrib not in self.attributes: + self.attributes[attrib] = attribs[attrib] + + # ------------------------------------------------------------------------- + + # Property: last_child + # [Read-only] + last_child = property(get_last_child) + + # ------------------------------------------------------------------------- + + # Property: parent + # (Element) The parent element. + parent = None + + # Property: name + # (String) The name of the element (e.g., `div`) + name = '' + + # Property: attributes + # (Dict) The dictionary of attributes (e.g., `{'src': 'image.jpg'}`) + attributes = None + + # Property: children + # (List of Elements) The children + children = None + + # Property: opening_tag + # (String or None) The opening tag. Optional; will use `name` and + # `attributes` if this is not given. + opening_tag = None + + # Property: closing_tag + # (String or None) The closing tag + closing_tag = None + + text = '' + depth = -1 + expand = False + populate = False + parser = None + + # Property: prefix + # Only the root note can have this. + prefix = None + suffix = None + +# ============================================================================= + +class Token: + def __init__(self, str, parser=None): + """Token. + + Description: + str - The string to parse + + In the string `div > ul`, there are 3 tokens. (`div`, `>`, and `ul`) + + For `>`, it will be a `Token` with `type` set to `Token.CHILD` + """ + + self.str = str.strip() + self.attributes = {} + self.parser = parser + + # Set the type. + if self.str == '<': + self.type = Token.PARENT + elif self.str == '>': + self.type = Token.CHILD + elif self.str == '+': + self.type = Token.SIBLING + else: + self.type = Token.ELEMENT + self._init_element() + + def _init_element(self): + """Initializes. Only called if the token is an element token. + [Private] + """ + + # Get the tag name. Default to DIV if none given. + name = re.findall('^([\w\-:]*)', self.str)[0] + if self.parser.options.options['namespaced-elements'] == True: + name = name.replace('-', ':') + + # Find synonyms through this thesaurus + synonyms = self.parser.dialect.synonyms + if name in synonyms.keys(): + name = synonyms[name] + + if ':' in name: + shortcuts = self.parser.dialect.shortcuts + if name in shortcuts.keys(): + for key, value in iteritems(shortcuts[name]): + setattr(self, key, value) + if 'html' in name: + return + else: + self.name = name + + elif (name == ''): self.name = 'div' + else: self.name = name + + # Look for attributes + attribs = [] + for attrib in re.findall('\[([^\]]*)\]', self.str): + attribs.append(attrib) + self.str = self.str.replace("[" + attrib + "]", "") + if len(attribs) > 0: + for attrib in attribs: + try: key, value = attrib.split('=', 1) + except: key, value = attrib, '' + self.attributes[key] = value + + # Try looking for text + text = None + for text in re.findall('\{(.*?)\}(?!\})', self.str): + self.str = self.str.replace("{" + text + "}", "") + if text is not None: + self.text = text + + # Get the class names + classes = [] + for classname in re.findall('\.([\$a-zA-Z0-9_\-\&]+)', self.str): + classes.append(classname) + if len(classes) > 0: + try: self.attributes['class'] + except: self.attributes['class'] = '' + self.attributes['class'] += ' ' + ' '.join(classes) + self.attributes['class'] = self.attributes['class'].strip() + + # Get the ID + id = None + for id in re.findall('#([\$a-zA-Z0-9_\-\&]+)', self.str): pass + if id is not None: + self.attributes['id'] = id + + # See if there's a multiplier (e.g., "li*3") + multiplier = None + for multiplier in re.findall('\*\s*([0-9]+)', self.str): pass + if multiplier is not None: + self.multiplier = int(multiplier) + + # Populate flag (e.g., ul+) + flags = None + for flags in re.findall('[\+\!]+$', self.str): pass + if flags is not None: + if '+' in flags: self.populate = True + if '!' in flags: self.expand = True + + def __str__(self): + return self.str + + str = '' + parser = None + + # For elements + # See the properties of `Element` for description on these. + name = '' + attributes = None + multiplier = 1 + expand = False + populate = False + text = '' + opening_tag = None + closing_tag = None + + # Type + type = 0 + ELEMENT = 2 + CHILD = 4 + PARENT = 8 + SIBLING = 16 + +# ============================================================================= + +class Router: + """The router. + """ + + # Constructor + # ------------------------------------------------------------------------- + + def __init__(self): + pass + + # Methods + # ------------------------------------------------------------------------- + + def start(self, options=None, str=None, ret=None): + if (options): + self.options = Options(router=self, options=options, argv=None) + else: + self.options = Options(router=self, argv=sys.argv[1:], options=None) + + if (self.options.has('help')): + return self.help() + + elif (self.options.has('version')): + return self.version() + + else: + return self.parse(str=str, ret=ret) + + def help(self): + print("Usage: %s [OPTIONS]" % sys.argv[0]) + print("Expands input into HTML.") + print("") + for short, long, info in self.options.cmdline_keys: + if "Deprecated" in info: continue + if not short == '': short = '-%s,' % short + if not long == '': long = '--%s' % long.replace("=", "=XXX") + + print("%6s %-25s %s" % (short, long, info)) + print("") + print("\n".join(self.help_content)) + + def version(self): + print("Uhm, yeah.") + + def parse(self, str=None, ret=None): + self.parser = Parser(self.options) + + try: + # Read the files + if str is not None: + lines = str + else: + lines = sys.stdin.read() + + except KeyboardInterrupt: + pass + + except: + sys.stderr.write("Reading failed.\n") + return + + try: + self.parser.load_string(lines) + output = self.parser.render() + if ret: return output + sys.stdout.write(output) + + except: + sys.stderr.write("Parse error. Check your input.\n") + print(sys.exc_info()[0]) + print(sys.exc_info()[1]) + + def exit(self): + sys.exit() + + help_content = [ + "Please refer to the manual for more information.", + ] + +# ============================================================================= + +class Options: + def __init__(self, router, argv, options=None): + # Init self + self.router = router + + # `options` can be given as a dict of stuff to preload + if options: + for k, v in iteritems(options): + self.options[k] = v + return + + # Prepare for getopt() + short_keys, long_keys = "", [] + for short, long, info in self.cmdline_keys: # 'v', 'version' + short_keys += short + long_keys.append(long) + + try: + getoptions, arguments = getopt.getopt(argv, short_keys, long_keys) + + except getopt.GetoptError: + err = sys.exc_info()[1] + sys.stderr.write("Options error: %s\n" % err) + sys.stderr.write("Try --help for a list of arguments.\n") + return router.exit() + + # Sort them out into options + options = {} + for option in getoptions: + key, value = option # '--version', '' + if (value == ''): value = True + + # If the key is long, write it + if key[0:2] == '--': + clean_key = key[2:] + options[clean_key] = value + + # If the key is short, look for the long version of it + elif key[0:1] == '-': + for short, long, info in self.cmdline_keys: + if short == key[1:]: + print(long) + options[long] = True + + # Done + for k, v in iteritems(options): + self.options[k] = v + + def __getattr__(self, attr): + return self.get(attr) + + def get(self, attr): + try: return self.options[attr] + except: return None + + def has(self, attr): + try: return self.options.has_key(attr) + except: return False + + options = { + 'indent-spaces': 4, + 'namespaced-elements': False, + } + cmdline_keys = [ + ('h', 'help', 'Shows help'), + ('v', 'version', 'Shows the version'), + ('', 'no-guides', 'Deprecated'), + ('', 'post-tag-guides', 'Adds comments at the end of DIV tags'), + ('', 'textmate', 'Adds snippet info (textmate mode)'), + ('', 'indent-spaces=', 'Indent spaces'), + ('', 'indent-tabs', 'Indent with tabs'), + ('', 'expand-divs', 'Automatically expand divs'), + ('', 'no-last-newline', 'Skip the trailing newline'), + ('', 'start-guide-format=', 'To be documented'), # << TODO + ('', 'end-guide-format=', 'To be documented'), # << TODO + ('', 'xml', 'Skip html attribute fillings'), + ('', 'no-html5-self-closing', 'Use HTML4
instead of HTML5
'), + ('', 'open-empty-tags', 'leaves an empty space between empty tags instead of leaving them on one line'), + ] + + # Property: router + # Router + router = 1 + +# ============================================================================= + +if __name__ == "__main__": + z = Router() + z.start() diff --git a/skel/.config/nvim/plugged/sparkup/vim/README.txt b/skel/.config/nvim/plugged/sparkup/vim/README.txt new file mode 100644 index 0000000..c167775 --- /dev/null +++ b/skel/.config/nvim/plugged/sparkup/vim/README.txt @@ -0,0 +1,69 @@ +Installation +------------ + +With Pathogen +^^^^^^^^^^^^^ + +If you are using tpope's vim-pathogen, install as follows: + + cd ~/.vim/bundle ; git clone https://github.com/rstacruz/sparkup.git + cd sparkup + make vim-pathogen + + +With Vundle +^^^^^^^^^^^ + +If using Vundle, you can specify Sparkup as a bundle and installation will happen +automatically. Add this to your Vim configuration: + + Plugin 'rstacruz/sparkup', {'rtp': 'vim/'} + +and run the standard installation command for Vundle: + + :PluginInstall + + +Manual installation +^^^^^^^^^^^^^^^^^^^ + + 1. Copy the contents of vim/ftplugin/ to your ~/.vim/ftplugin directory. + + (Assuming your current dir is sparkup/vim/) + $ cp -R ftplugin ~/.vim/ + + 2. Copy the sparkup.py file to your ~/.vim directory + + (Assuming your current dir is sparkup/vim/) + $ cp ../sparkup.py ~/.vim/ + + +Configuration +------------- + +Customise the Sparkup's configuration within Vim by specifying some or all of the following +as variables within your Vim configuration using the ``let`` directive. + + g:sparkup (Default: 'sparkup') - + Location of the sparkup executable. You shouldn't need to change this + setting if you used the install option above. + + g:sparkupArgs (Default: '--no-last-newline') - + Additional args passed to sparkup. + + g:sparkupExecuteMapping (Default: '') - + Mapping used to execute sparkup within insert mode. + + g:sparkupNextMapping (Default: '') - + Mapping used to jump to the next empty tag/attribute within insert mode. + + g:sparkupMaps (Default: 1) - + Set up automatic mappings for Sparkup. If set to 0, this can be + used to disable creation of any mappings, which is useful if + full customisation is required. + + g:sparkupMapsNormal (Default: 0) - + Set up mappings for normal mode within Vim. The same execute and next + mappings configured above will apply to normal mode if this option is + set. + diff --git a/skel/.config/nvim/plugged/sparkup/vim/ftplugin/html/sparkup.py b/skel/.config/nvim/plugged/sparkup/vim/ftplugin/html/sparkup.py new file mode 120000 index 0000000..0504c75 --- /dev/null +++ b/skel/.config/nvim/plugged/sparkup/vim/ftplugin/html/sparkup.py @@ -0,0 +1 @@ +../../../sparkup.py \ No newline at end of file diff --git a/skel/.config/nvim/plugged/sparkup/vim/ftplugin/html/sparkup.vim b/skel/.config/nvim/plugged/sparkup/vim/ftplugin/html/sparkup.vim new file mode 100644 index 0000000..9ee90d3 --- /dev/null +++ b/skel/.config/nvim/plugged/sparkup/vim/ftplugin/html/sparkup.vim @@ -0,0 +1,129 @@ +" Sparkup +" Installation: +" Copy the contents of vim/ftplugin/ to your ~/.vim/ftplugin directory: +" +" $ cp -R vim/ftplugin ~/.vim/ftplugin/ +" +" or use one of the automated methods specified in the README.txt file. +" +" Configuration: +" g:sparkup (Default: 'sparkup') - +" Location of the sparkup executable. You shouldn't need to change this +" setting if you used the install option above. +" +" g:sparkupArgs (Default: '--no-last-newline') - +" Additional args passed to sparkup. +" +" g:sparkupExecuteMapping (Default: '') - +" Mapping used to execute sparkup within insert mode. +" +" g:sparkupNextMapping (Default: '') - +" Mapping used to jump to the next empty tag/attribute within insert mode. +" +" g:sparkupMaps (Default: 1) - +" Set up automatic mappings for Sparkup. If set to 0, this can be +" used to disable creation of any mappings, which is useful if +" full customisation is required. +" +" g:sparkupMapsNormal (Default: 0) - +" Set up mappings for normal mode within Vim. The same execute and next +" mappings configured above will apply to normal mode if this option is +" set. + +if !exists('g:sparkupExecuteMapping') + let g:sparkupExecuteMapping = '' +endif + +if !exists('g:sparkupNextMapping') + let g:sparkupNextMapping = '' +endif + +if !exists('g:sparkupMaps') + let g:sparkupMaps = 1 +endif + +if !exists('g:sparkupMapsNormal') + let g:sparkupMapsNormal = 0 +endif + +inoremap SparkupExecute u:call Sparkup() +inoremap SparkupNext u:call SparkupNext() + +if g:sparkupMaps + if ! hasmapto('SparkupExecute', 'i') + exec 'imap ' . g:sparkupExecuteMapping . ' SparkupExecute' + endif + if ! hasmapto('SparkupNext', 'i') + exec 'imap ' . g:sparkupNextMapping . ' SparkupNext' + endif + if g:sparkupMapsNormal + if ! hasmapto('SparkupExecute', 'n') + exec 'nnoremap ' . g:sparkupExecuteMapping . ' :call Sparkup()' + endif + if ! hasmapto('SparkupNext', 'n') + exec 'nnoremap ' . g:sparkupNextMapping . ' :call SparkupNext()' + endif + endif +endif + +if exists('*s:Sparkup') + finish +endif + +function! s:Sparkup() + if !exists('s:sparkup') + let s:sparkup = exists('g:sparkup') ? g:sparkup : 'sparkup' + + if !executable(s:sparkup) + " If g:sparkup is not configured (and/or not found in $PATH), + " look for sparkup.vim in Vim's runtimepath. + " XXX: quite expensive for a Pathogen-like environment (where &rtp is huge) + let paths = substitute(escape(&runtimepath, ' '), '\(,\|$\)', '/**\1', 'g') + let s:sparkup = fnamemodify(findfile('sparkup.py', paths), ':p') + + if !filereadable(s:sparkup) + echohl WarningMsg + echom 'Warning: could not find sparkup/sparkup.py on your path or in your vim runtime path.' + echohl None + unlet s:sparkup + return + endif + endif + let s:sparkup = '"' . s:sparkup . '"' + " Workaround for windows, where the Python file cannot be executed via shebang + if has('win32') || has('win64') + let s:sparkup = 'python ' . s:sparkup + endif + endif + + " Build arguments list (not cached, g:sparkupArgs might change, also + " &filetype, &expandtab etc) + let sparkupArgs = exists('g:sparkupArgs') ? g:sparkupArgs : '--no-last-newline' + " Pass '--xml' option, if 'xml' is used as filetype (default: none/'html') + " NOTE: &filetype can contain multiple values, e.g. 'smarty.html' + if index(split(&filetype, '\.'), 'xml') >= 0 + let sparkupArgs .= ' --xml' + endif + " If the user's settings are to indent with tabs, do so! + " TODO textmate version of this functionality + if !&expandtab + let sparkupArgs .= ' --indent-tabs' + endif + + let sparkupCmd = s:sparkup . printf(' %s --indent-spaces=%s', sparkupArgs, &shiftwidth) + exec '.!' . sparkupCmd + call s:SparkupNext() +endfunction + +function! s:SparkupNext() + " 1: empty tag, 2: empty attribute, 3: empty line + let n = search('><\/\|\(""\)\|\(^\s*$\)', 'Wp') + if n == 3 + startinsert! + else + let p = getpos(".") + let p[2] = p[2] + 1 + call setpos(".", p) + startinsert + endif +endfunction diff --git a/skel/.config/nvim/plugged/sparkup/vim/ftplugin/htmldjango b/skel/.config/nvim/plugged/sparkup/vim/ftplugin/htmldjango new file mode 120000 index 0000000..724f4d4 --- /dev/null +++ b/skel/.config/nvim/plugged/sparkup/vim/ftplugin/htmldjango @@ -0,0 +1 @@ +html \ No newline at end of file diff --git a/skel/.config/nvim/plugged/sparkup/vim/ftplugin/smarty b/skel/.config/nvim/plugged/sparkup/vim/ftplugin/smarty new file mode 120000 index 0000000..724f4d4 --- /dev/null +++ b/skel/.config/nvim/plugged/sparkup/vim/ftplugin/smarty @@ -0,0 +1 @@ +html \ No newline at end of file diff --git a/skel/.config/nvim/plugged/sparkup/vim/ftplugin/xml b/skel/.config/nvim/plugged/sparkup/vim/ftplugin/xml new file mode 120000 index 0000000..724f4d4 --- /dev/null +++ b/skel/.config/nvim/plugged/sparkup/vim/ftplugin/xml @@ -0,0 +1 @@ +html \ No newline at end of file diff --git a/skel/.config/nvim/plugged/tlib_vim/.gitignore b/skel/.config/nvim/plugged/tlib_vim/.gitignore new file mode 100644 index 0000000..e626a86 --- /dev/null +++ b/skel/.config/nvim/plugged/tlib_vim/.gitignore @@ -0,0 +1,13 @@ +tags +!doc/tags +Makefile +TODO.TXT +TODO_archived.viki +*.vba +*.vmb +*.zip +.last_* +test +test_* +tmp +var diff --git a/skel/.config/nvim/plugged/tlib_vim/CHANGES.TXT b/skel/.config/nvim/plugged/tlib_vim/CHANGES.TXT new file mode 100644 index 0000000..767ae5e --- /dev/null +++ b/skel/.config/nvim/plugged/tlib_vim/CHANGES.TXT @@ -0,0 +1,909 @@ +0.1 +Initial release + +0.2 +- More list convenience functions +- tlib#EditList() +- tlib#InputList(): properly handle duplicate items; it type contains +'i', the list index + 1 is returned, not the element + +0.3 +- tlib#InputList(): Show feedback in statusline instead of the echo area +- tlib#GetVar(), tlib#GetValue() + +0.4 +- tlib#InputList(): Up/Down keys wrap around list +- tlib#InputList(): FIX: Problem when reducing the filter & using AND +- tlib#InputList(): Made work (can be configured via +- tlib#InputList(): special display_format: "filename" +- tlib#Object: experimental support for some kind of OOP +- tlib#World: Extracted some functions from tlib.vim to tlib/World.vim +- tlib#FileJoin(), tlib#FileSplit(), tlib#RelativeFilename() +- tlib#Let() +- tlib#EnsureDirectoryExists(dir) +- tlib#DirName(dir) +- tlib#DecodeURL(url), tlib#EncodeChar(char), tlib#EncodeURL(url) +- FIX: Problem when using shift-up/down with filtered lists + +0.5 +- tlib#InputList(): FIX: Selecting items in filtered view +- tlib#InputList(): : Remove last AND pattern from filter + +0.6 +- tlib#InputList(): Disabled map +- tlib#InputList(): try to be smart about user itentions only if a +list's length is < g:tlib_sortprefs_threshold (default: 200) +- tlib#Object: Super() method +- tlib#MyRuntimeDir() +- tlib#GetCacheName(), tlib#CacheSave(), tlib#CacheGet() +- tlib#Args(), tlib#GetArg() +- FIX: tlib#InputList(): Display problem with first item + +0.7 +- tlib#InputList(): ... Suspend/Resume input +- tlib#InputList(): ... Input text on the command line (useful on +slow systems when working with very large lists) +- tlib#InputList(): AND-pattern starting with '!' will work as 'exclude +matches' +- tlib#InputList(): FIX pop OR-patterns properly +- tlib#InputList(): display_format == filename: don't add '/' to +directory names (avoid filesystem access) + +0.8 +- FIX: Return empty cache name for buffers that have no files attached to it +- Some re-arranging + +0.9 +- Re-arrangements & modularization (this means many function names have +changed, on the other hand only those functions are loaded that are +actually needed) +- tlib#input#List(): Added maps with m-modifiers for , , +- tlib#input#List(): Make sure &fdm is manual +- tlib#input#List(): When exiting the list view, consume the next 5 +characters in the queue (if any) +- tlib#input#EditList(): Now has cut, copy, paste functionality. +- Added documentation and examples + +0.10 +- tlib#input#List(): (v)split type of commands leave the original window +untouched (you may use to replace its contents) +- tlib#file#With(): Check whether an existing buffer is loaded. +- Scratch related functions went to tlib/scratch.vim so that they are +accessible from other scripts. +- Configure the list window height via g:tlib_inputlist_pct (1..100%) + +0.11 +NEW: + - The :TLet command replaces :TLLet (which was removed) + - :TScratch[!] command (with ! don't split but use the whole window) + - tlib#rx#Escape(text, ?magic='m') + - tlib#buffer#GetList(?show_hidden=0) + - tlib#dir#CD(), tlib#dir#Push(), tlib#dir#Pop() + - tlib#input#ListW: A slightly remodeled version of tlib#input#List + that takes a World as second argument. + - Added some documentation doc/tlib.txt (most of it is automatically + compiled from the source files) +CHANGES: + - tlib#input#List(): The default keys for AND, NOT have changed to + be more Google-like (space, minus); the keys can be configured via + global variables. +IMPROVEMENTS: + - In file listings, indicate if a file is loaded, listed, modified + etc. + - tlib#input#List(): Highlight the filter pattern + - tlib#input#List(): scrolls g:tlib_scroll_lines + (default=10) lines +FIXES: + - tlib#input#List(): Centering line, clear match, clear & restore + the search register + - tlib#input#List(): Ensure the window layout doesn't change (if the + number of windows hasn't changed) + - tlib#arg#Ex(): Don't escape backslashes by default + +0.12 +NEW: + - tlib/tab.vim +CHANGES: + - Renamed tlib#win#SetWin() to tlib#win#Set() +IMPROVEMENTS: + - tlib#input#List(): , keys work in some lists + - tlib#input#List(): If an index_table is provided this will be used + instead of the item's list index. +FIXES: + - tlib#input#List(): Problem with scrolling, when the list was + shorter than the window (eg when using a vertical window). + - tlib#cache#Filename(): Don't rewrite name as relative filename if + explicitly given as argument. Avoid double (back)slashes. + - TLet: simplified + +0.13 +CHANGES: + - Scratch: Set &fdc=0. + - The cache directory can be configured via g:tlib_cache + - Renamed tlib#buffer#SetBuffer() to tlib#buffer#Set(). +FIXES: + - tlib#input#List(): Select the active item per mouse. + - TLet: simplified + +0.14 +NEW: + - tlib#buffer#InsertText() +CHANGES: + - tlib#win#[SG]etLayout(): Use a dictionnary, set &cmdheight. +FIXES: + - Wrong order with pre-defined filters. + +0.15 +NEW: + - tlib#string#TrimLeft(), tlib#string#TrimRight(), tlib#string#Strip() + - Progress bar + +0.16 +NEW: + - tlib#string#Printf1() + +0.17 +NEW: + - TBrowseOutput +- Some minor changes + +0.18 +NEW: + - tlib/time.vim + - g:tlib_inputlist_livesearch_threshold +CHANGES: + - tlib#input#ListD(), World: Don't redisplay the list while typing + new letters; calculate filter regexps only once before filtering the + list. + - World.vim: Minor changes to how filenames are handled. + +0.19 +NEW: + - tag.vim +FIX: + - dir.vim: Use plain dir name in tlib#dir#Ensure() + - tlib#input#List(): An initial filter argument creates [[filter]] + and not as before [[''], [filter]]. + - tlib#input#List(): When type was "si" and the item was picked by + filter, the wrong index was returned. + - tlib#input#List(): Don't check if chars are typed when displaying + the list for the first time. + +0.20 +- The arguments of tlib#tag#Collect() have changed. +- tlib#input#List(): The view can be "suspended" on initial display. +- tlib#input#List(): Follow/trace cursor functionality + +0.21 +- tlib#buffer#InsertText(): Respect tabs and (experimental) formatoptions+=or +- tlib/syntax.vim: Syntax-related functions + +0.22 +- FIX: very magic mode for tlib#rx#Escape() (thanks A Politz) +- FIX: tlib#arg#Ex: escape "!" + +0.23 +- Respect the setting of g:tlib_inputlist_filename_indicators +- tlib#input#List(): Reset syntax on resume; option to make list window "sticky" +- tlib#agent#ToggleStickyList() +- Simplified tlib#url#Decode() +- tlib#arg#Ex(): use fnameescape() if available + +0.24 +- s:prototype.SetInitialFilter: accept list as argument +- Maintain buffer MRU if required + +0.25 +- NEW: tlib#notify#TrimMessage(): trim message to prevent "Press ENTER" +messages (contributed by Erik Falor) +- NEW: tlib#notify#Echo() +- FIX: World.CloseScratch(): Set window +- FIX: tlib#input#ListW(): Set initial_display = 1 on reset + +0.26 +- NEW: tlib#normal#WithRegister() +- FIX: Try not to change numbered registers + +0.27 +- FIX: Cosmetic bug, wrong packaging (thanks Nathan Neff) +- Meaning of World#filter_format changed; new World#filter_options +- Filtering didn't work as advertised +- tlib#string#Count() + +0.28 +- tlib#input#List(): +-- Improved handling of sticky lists; and resume a +suspended list and immediately selects the item under the cursor +-- Experimental "seq" matching style: the conjunctions are sequentially +ordered, they are combined with "OR" (disjunctions), the regexp is +'magic', and "." is expanded to '.\{-}' +-- Experimental "cnfd" matching style: Same as cnf but with an "elastic" +dot "." that matches '\.\{-}' +-- Filtering acts as if &ic=1 && $sc=1 +-- Weighting is done by the filter +- tlib#agent#Input(): Consume when aborting input() +- INCOMPATIBLE CHANGE: Changed eligible values of g:tlib_inputlist_match +to "cnf", "cnfd", "seq" and "fuzzy" +- NEW: tlib#buffer#KeepCursorPosition() +- tlib#buffer#InsertText(): Take care of the extra line when appending +text to an empty buffer. + +0.29 +- tlib#string#Strip(): Strip also control characters (newlines etc.) +- tlib#rx#Suffixes(): 'suffixes' as Regexp +- World#RestoreOrigin(): Don't assume &splitbelow + +0.30 +- World#RestoreOrigin(): Don't assume &splitright + +0.31 +- :TRequire command +-tlib#input#List: For i-type list views, make sure agents are called +with the base indices. + +0.32 +- tlib#agent#Exit: explicitly return empty value (as a consequence, +pressing when browsing an index-list, returns 0 and not "") +- tlib#signs +- tlib#input#List: set local statusline + +0.33 +- Don't reset statusline +- Don't use fnamemodify() to split filenames (for performance reasons) +- scratch: Set ft after setting up scratch options +- tlib#map#PumAccept(key) + +0.34 +- tlib#buffer#HighlightLine(line): call tlib#autocmdgroup#Init() +(reported by Sergey Khorev) + +0.35 +- tlib#input#EditList(): return the list if the user presses esc + +0.36 +- Display a message when the filter is for whatever reason invalid +- Removed tlib#paragraph#Delete() +- New: tlib#paragraph#Define(), tlib#textobjects#StandardParagraph() +- Try to speed up list display (a rewrite of World.DisplayList() etc. is +required) + +0.37 +- g:tlib_inputlist_livesearch_threshold defaults to 1000 +- tlib#World: optional scratch_pos field +- tlib#input#List: By default selects by number but NUMBER is +interpreted as string +- tlib#date +- TTimeCommand + +0.38 +- tlib#World#Resize: set winfix{height|width} + +0.39 +- g:tlib#cache#dont_purge +- tlib#vim#RestoreWindow() +- tlib#ballon#...() + +0.40 +- tlib#agent#ViewFile: Use split/sbuffer if nohidden && modified +- tlib#buffer#GetList(): order by "basename" + +version: "0.41" + - World.UseScratch(): keepalt + - Really include balloon.vim + MD5 checksum: 3fcbc4f7556f5378d39622e62ab8f379 + +version: "0.42" + - tlib#input#List: inserts a *-like wildcard (represented as "__") + - Check if a cache file cannot be created because a directory of the same name exists (display a message if so) + - tlib#cache#Filename: Removed check if a directory of the same name exists (due to inconsistent use) + - Minor improvements related to buffer handling (scratch_split) + - .gitignore + - docs (thanks to blueyed) + - There is no "edit" answer possibility. + - Fix first purge: do nothing if no timestamp file. + - g:tlib_pick_single_item + - Removed pick_single_item. Changed the default behavour when a list has only 1 item. See doc for g:tlib_pick_last_item. + - Updated help for tlib#input#List(); help_extra attribute + - EXPERIMENTAL: cache_var, restore_from_cache, on_leave properties; #Initialize(), #Leave() + - added tlib#cmd#BrowseOutputWithCallback function and :TBrowseScriptnames command + - tlib#cmd#BrowseOutputWithCallback function and :TBrowseScriptnames command documentation + - s:prototype.Initialize(): unlet self.cache_var after restoring values + - tlib#input#List: filter-specific help + - Removed the seq filter (use cnfd or fuzzy instead) + - tlib#input#List: temp_prompt (for help message) + MD5 checksum: aa8b5a4602235cc1a5bc9ee45d801b81 + +version: "0.42" + - g:tlib#cache#silent: don't display messages when purging the cache (fixes #9) + - Changed message when deleting directories in the cache. + - g:tlib#input#use_popup: Don't rely on has('menu') but also check for gtk & win gui (fixes #10) + - debug + - tlib#input#ListW(): Didn't return a list when type == "m" + - docs (solves #11) + MD5 checksum: aa8b5a4602235cc1a5bc9ee45d801b81 + +version: "0.45" + - fuzzy mode: prototype.highlight defaults to g:tlib_inputlist_higroup + - tlib#scratch: Use noautocmd + - tlib#input#ListW(): Use world.RestoreOrigin() instead of tlib#win#SetLayout(world.winview) + - tlib#input#ListW(): Revert to tlib#win#SetLayout(world.winview) + - tlib#cmd#OutputAsList(): Also save output in g:tlib#cmd#last_output + - tlib#agent#Suspend(): Resume on BufEnter + - tlib#input#Resume(): Make sure we are in the right buffer + - tlib#agent#Suspend(): Use only BufEnter event to trigger a Resume + - tlib#input#ListW(): When redisplaying a list, make sure prefix > 0 + - tlib#vcs: Access vcs (initially only git is supported) + - tlib#vcs: improved + - tlib#persistent: Persistent data file names + - tlib#file#With(): Trigger BufRead autocommands + - Duplicate help tags (fixes #13) + - Make sure scrolloff is 0 while viewing the list (fixes https://github.com/tomtom/vikitasks_vim/issues/2) + MD5 checksum: 0af19ebc0e424727a598a988fdc90f4e + + - Support for tinykeymap (move paragraph) + - Moved para_move to autoload/tinykeymap/map + - tlib#vcs: some "diff" commands were defined as "ls"; updated hg def; %s is optional + MD5 checksum: f2f2fe0893e75bb9423c1ddcd01f38f6 +version: "0.46" + + - tlib#input#List: optimizations + - Prepare for multi-mode maps + - tlib#input#List: cnfx is new default filter + - Filters: minor changes to how the pattern is displayed + - g:tlib#input#format_filename: alternative method for formatting filenames + - tlib#input#List: allow multiple keymaps / modes + - Handle rezise events + - Don't initialize the same window twice + - Minor optimizations to how help is displayed + - Handle VimResize event per buffer + - Improve display of filenames & highlighting + - Filename highlighter: set Highlight_filename() + - RunStateHandlers(): set world variable + - Optimize help display + MD5 checksum: e3652927722bdc51935eb1a04238546b +version: "1.00" + + - Set g:tlib_inputlist_and to ' ' again + - g:tlib#input#filename_max_width: maximum display width of filenames + - tlib#input#List: , : run command by name + MD5 checksum: a42f90275cdbe9f7d92cac61b884a2d1 +version: "1.01" + + - #UseInputListScratch(): Make sure the TLib autogroup was created (fixes #14) + MD5 checksum: 5a6da7fc99c7fc7584e8fc2f7bf86fe4 +version: "1.02" + + - tlib#cache#Value(cfile, generator, ftime, ...): cache value & check timestamp + - Replaced g:tlib#cache#silent with g:tlib#cache#verbosity + - FormatFilenames: improved handling of utf8 characters + - tlib#persistent#Value() + - tlib#input#List: Allow filename indiactors defined by the caller + - Custom filename_indicators are displayed after (and clearly separted from) the standard indicators + - Check the return value of an unknown_key agent + - Format filename = "l": Allow ".." as start of a directory name + - Format filename = "l": If the filename is just a filename's tail, display it on both sides + - Set g:tlib_filename_sep to "\" on Windows (again) + - g:tlib#cache#max_filename: If the cache filename is longer than N characters, use |pathshorten()|. + MD5 checksum: b64ce6764f39f40bfc95f3916bbb0057 +version: "1.04" + +version: "1.05" + - tlib#hash: Adler32 & CRC32 (using zlib via ruby) algorithms + - tlib#cache#Filename(): If the cache filename is too long, add the Adler32 checksum to the shortened path + - tlib#cache#Filename(): Use tlib#hash#Adler32() only if the or() function exists + - tlib#hash#Adler32(): Raise error, if or() doesn't exist + - tlib#hash#CRC32(): Alternative implementation of crc32 (doesn't work yet, thus currently disabled) + - tlib#bitwise: Bitwise operations for older versions of vim + - tlib#number: Base conversion + - tlib#input#ListW(): Handle mouse clicks more correctly + - tlib#bitwise#Num2Bits(): Supports returning floats + - tlib#hash#CRC32(): Alternative implementation of crc32 (doesn't work yet) + - tlib#hash#CRC32(): Re-enable ruby version + - tlib#hash#CRC32B(): Implementation of CRC32B checksum in vimscript (used only if +ruby isn't available) + - tlib#hash#CRC32B(): vim version: cache the crc table + - tlib#cache#Filename(): Use tlib#hash#CRC32B(file) instead of not Adler32 for filenames too long + - tlib#hash#CRC32B(): ruby version: return upper case hex value + - g:tlib#hash#use_crc32: define which crc32b version should be used + - Moved spec files from vimtlib to tlib_vim + - tlib#bitwise#Add() and tlib#bitwise#Sub() + - tlib#file#Relative(): Wrong results for filenames that don't exist + - Implementation of hash#Adler32 for earlier vim versions; g:tlib#hash#use_adler32 + - tlib#cache#Filename(): Use adler32 again + - addon-info + - tlib#file#Absolute(): remove redundant "." parts in full filename + - win32: Fix moving window when using :vertical for tlib#inpu#List() + - tlib#cache#Filename(): Don't create wrong directory if the cache filename is too long + - tlib#file#Join(): if strip_slashes, also strip redundant (back)slashes + - tlib#input#ListW(): Always set post_keys variable + - tlib#file#With(): escape backslashes + - tlib#cmd#OutputAsList(): Support for nesting + - tlib#dir#NativeName(dirname) + MD5 checksum: 493f9beca44374de386f20d1613155e3 + + - Rename g:tlib_debug to g:tlib#debug + - Renamed g:tlib_sortprefs_threshold to g:tlib#input#sortprefs_threshold + - Renamed g:tlib#input#livesearch_threshold + - Renamed g:tlib_inputlist_match to g:tlib#input#filter_mode + - Renamed g:tlib_inputlist_higroup to g:tlib#input#higroup + - Renamed g:tlib#debug + - Moved g:tlib_pick_last_item + - Renamed g:tlib#input#and, g:tlib#input#or, g:tlib#input#not + - Moved g:tlib_numeric_chars to autoload/tlib/input.vim + - Renamed g:tlib#input#keyagents_InputList_s, g:tlib#input#keyagents_InputList_m, g:tlib#input#handlers_EditList + - Moved g:tlib_inputlist_pct, g:tlib_inputlist_width_filename, g:tlib_inputlist_filename_indicators, g:tlib_inputlist_shortmessage to autoload/tlib/World.vim + - Renamed tlib#input#pick_last_item (2) + - prototype.SelectItemsByNames() + - filtered_items: Restricted view + - prototype.PrintLines() + - Restricted view (2) + - Moved g:tlib_scroll_lines to autoload/tlib/agent.vim + - prototype.PrintLines() (2) + - tlib#input: Improved handling of popup menu (allows submenu) + - tlib#input: Allow mods in keys + - Moved g:tlib_scratch_pos to autoload/tlib/scratch.vim + - Moved g:tlib_tags_extra, g:tlib_tag_substitute to autoload/tlib/tag.vim + - tlib#agent#CompleteAgentNames(): Respect Arglead + - Move g:tlib_viewline_position to autoload/tlib/buffer.vim + - Move g:tlib_cache to autoload/tlib/cache.vim + - Renamed g:tlib_filename_sep to g:tlib#dir#sep + - prototype.UseScratch(): Set b:tlib_world + - tlib#input: f9 toggles resticted view + - tlib#input: next_agent, next_eval + - tlib#input: Revised use of the popup menu + - tlib#input: Disable popup menu for gui_gtk + - tlib#input: Re-enabled the popup menu for gtk gui + - tlib#input: FIX popup menu on Windows + - Renamed g:tlib_numeric_chars to g:tlib#input#numeric_chars (disabled per-buffer values) (fixes #35) + - Improve scratch list + - New: tlib#grep + - Merge branch 'master' of https://github.com/bruno-/tlib_vim into pull16 + - g:tlib_scratch_hidden: Configure how to "hide" the scratch buffer + - tlib#grep#Do: don't escape "*" in patterns + - Optimize use of visible scratch buffers + - World.scratch_hidden parameter + - scratch: Always use keepalt & keepjumps + MD5 checksum: 2e40449c47dc606ccef57aa0b1e22e8e +version: "1.06" + +version: "1.07" + - Help template + - prototype.Highlight_filename(): Use matchstr() instead of fnamemodify() + - Display buffer-related filename indicators only if g:tlib_inputlist_filename_indicators is true + - tlib#file#Join(): strip_slashes defaults to 1 + MD5 checksum: 6c8fa96fd3747be05df848ee93dd789b + +version: "1.08" + - list#input: Improved support for file indicators (closes #17) + - tlib#char#Get(): Optionally, also return mod + - tlib#input#ListW: Use #DisplayFormat(world.list) + - Renamed cnfx filter to glob & minor filter-related enhancements + - list#input: Make help available as command; help cannot be called via ? + - list#input: Improved help message + - list#input: Support Home & End keys + - list#input: Added glob filter + - tlib#agent#ShowInfo: Show full filename + - tlib#cmd#BrowseOutputWithCallback: Support calling callback with multiple results + - tlib#cmd#ParseScriptname: Properly parse results from :scriptnames + - tlib#tab#Set() + - Prepare for proper handling of scratch_split == -1 + - tlib#vim#CopyFunction() + - tlib#cache#Value(): If generator is empty, use the optional argument as start value + - tlib#persistent#Get() refers to tlib#cache#Get() + MD5 checksum: 459ec620168d1ae9b18c69eb3f991832 + + - tlib#cache#Filename(): Use sha256() for VIM >= 7.4 + - tlib#cache#Value(): Undo previous hack + - tlib#list#Uniq(): option to remove empty values + - tlib#cache#MTime(); tlib#persistent#Save() calls tlib#cache#Save() + - tlib#input#ListW: Temporarily set noshowmode + - tlib#list#Uniq(): Fix handling of empty items + - lis picker: Remove from help + - tlib#list#Uniq(): Implementation based on syntastic#util#unique(list) by scrooloose + MD5 checksum: b5fb4107d63930c2c8b1f0f6b3a7ff07 +version: "1.09" + + - tlib#cache#Filename(): Use sha256() for VIM >= 7.4 + - tlib#cache#Value(): Undo previous hack + - tlib#list#Uniq(): option to remove empty values + - tlib#cache#MTime(); tlib#persistent#Save() calls tlib#cache#Save() + - tlib#input#ListW: Temporarily set noshowmode + - tlib#list#Uniq(): Fix handling of empty items + - lis picker: Remove from help + - tlib#list#Uniq(): Implementation based on syntastic#util#unique(list) by scrooloose + MD5 checksum: b5fb4107d63930c2c8b1f0f6b3a7ff07 +version: "1.09" + + - tlib#string#Chomp: Optional argument: max number of chars that should be removed + MD5 checksum: 8c1b94e25045580874e2f892d509291b +version: "1.10" + + - tlib#vcs#FindVCS(filename): Wrong parameters to fnamemodifiy if filename is a directory + - Some system-related functions (e.g. facilitate use of cygwin tools) + - tlib#arg#StringAsKeyArgsEqual(), tlib#arg#StringAsKeyArgs(): Support "key=val" type argument lists + - tlib#vcs#Executable() + - scripts/create_crc_table.rb + - tlib#var#Get(): For namespaces other than global, replace "#" with "_" + MD5 checksum: 4a33f2f23e1fc6600b32e7f8323e001e +version: "1.11" + + - tlib#list#ToDictionary() + - tlib#dir#CanonicName(): Use tlib#file#Canonic() + - tlib#file#Canonic() + MD5 checksum: 7995ab58f31eb6673d20deab8761838e +version: "1.12" + + - SetInitialFilter(): Use deepcopy() + - tlib#var#List(): use keys(namespace) for newer versions of vim + - g:tlib#input#user_shortcuts (not functional yet) + - tlib#input#List: state "picked" + - UseInputListScratch(): Allow customization via self.index_next_syntax + - tlib#cmd#Capture() + - Facilitate customization of key agents via g:tlib_extend_keyagents_InputList_s, g:tlib_extend_keyagents_InputList_m + MD5 checksum: 7dd8b17a1a5b555df979381dcbd4c9aa +version: "1.13" + + - SetInitialFilter(): Use deepcopy() + - tlib#var#List(): use keys(namespace) for newer versions of vim + - g:tlib#input#user_shortcuts (not functional yet) + - tlib#input#List: state "picked" + - UseInputListScratch(): Allow customization via self.index_next_syntax + - tlib#cmd#Capture() + - Facilitate customization of key agents via g:tlib_extend_keyagents_InputList_s, g:tlib_extend_keyagents_InputList_m + MD5 checksum: 7dd8b17a1a5b555df979381dcbd4c9aa +version: "1.13" + +version: "1.14" + - FIX #18: Make sure the scratch isn't readonly + - FIX: display filter (properly handle backslashes) + - Remove loaded_* guard from autoload files + - tlib#notify#Echo(): minor changes + - tlib#file#Edit() (used by tlib#agent#ViewFile) + - tlib#buffer#GetList(): Buffer numbers are converted to numbers + - tlib#sys: Change order of functions (move tlib#sys#IsCygwinBin to the (possibly FIX #19) + - g:tlib#sys#check_cygpath: Call tlib#sys#IsExecutable('cygpath', 1) (possibly FIX #19) + MD5 checksum: 2cf6386218736a2d09db43c8e751e5a4 + +version: "1.15" + - tlib#file#Join(): New optional argument: maybe_absolute Drop preceding parts if a part looks like an absolute filename + - tlib#sys#Open(), tlib#sys#IsSpecial() (moved from viki) + - tlib#list#Uniq(): Handle hetergenous lists + - FIX #21: duplicate help tag + - NEW tlib#dictionary#Rev() + - tlib#input#List(): Use to complete current word + - NEW tlib#arg#GetOpts(); ENH tlib#arg#StringAsKeyArgsEqual() + - cache: Allow for in memory cache + - NEW tlib#eval#Extend() + - Move qfl/loclist browser from trag to tlib + - FIX tlib#eval#Extend() + - Simplify tlib#eval#Extend() + - World.index_next_syntax may be a dict + - tlib#qfl#QflList: Use copy() + - tlib#arg#GetOpts: Handle exit code + MD5 checksum: 13fd8b0e4ba9cd932c57fc40ac3f641f + +version: "1.15" + - tlib#file#Join(): New optional argument: maybe_absolute Drop preceding parts if a part looks like an absolute filename + - tlib#sys#Open(), tlib#sys#IsSpecial() (moved from viki) + - tlib#list#Uniq(): Handle hetergenous lists + - FIX #21: duplicate help tag + - NEW tlib#dictionary#Rev() + - tlib#input#List(): Use to complete current word + - NEW tlib#arg#GetOpts(); ENH tlib#arg#StringAsKeyArgsEqual() + - cache: Allow for in memory cache + - NEW tlib#eval#Extend() + - Move qfl/loclist browser from trag to tlib + - FIX tlib#eval#Extend() + - Simplify tlib#eval#Extend() + - World.index_next_syntax may be a dict + - tlib#qfl#QflList: Use copy() + - tlib#arg#GetOpts: Handle exit code + MD5 checksum: 13fd8b0e4ba9cd932c57fc40ac3f641f + + - tlib#arg#GetOpts: Handle short options + - tlib#arg: support short flags & facilitate completion + - NEW :TLibTrace + - tlib#sys#system_browser: FIX XDG string + - NEW tlib#sys#SystemInDir() (used by tlib#vcs#Ls) + - tlib#agent#Complete: improve fltrx + - Remove tlib#arg#Key(), :TKeyArg + - Move :TRequire, :TTimeCommand to macros/tlib.vim + - NEW tlib#cmd#TBrowseScriptnames() + - TScratch: use empty('') + - NEW :TLibTrace + - tlib#qfl: FIX TTagedFilesFilename regexp + - Remove tlib#arg#Key() + - tlib#buffer#InsertText(): Don't use TKeyArg + - tlib#eval#Extend: don't assign value + - NEW :TLibTrace, tlib#trace (was tlib#debug) + - NEW tlib#string#SplitCommaList() + - NEW tlib#time#FormatNow() + - tlib#arg#GetOpts: selectively disable "long", "short" flags + - tlib#arg#CComplete(): Support values completion (complete_customlist field) + - NEW tlib#date#Shift() + - tlib#qfl#Balloon(): Handle items with no bufnr + - NEW tlib#file#Glob, tlib#file#Globpath + - tlib#progressbar#Display(): optional "always" argument + - tlib#vcs#GitLsPostprocess(): Try to handle encoded filenames from git ls-files + - tlib#vcs#GitLsPostprocess: Eval only \ddd substrings + - FIX #22: duplicate tag + - tlib#buffer: Use 2match instead of 3match (incompatibility with matchparen) + - FIX #23: duplicate help tag + - tlib#string#SplitCommaList: optional "sep" argument + - Rename TLibTrace -> Tlibtrace; NEW Tlibtraceset command + - Rename s:SetSyntax -> tlib#qfl#SetSyntax + - mv tlib#rx#Convert to incubator + MD5 checksum: f3656fb35b7b3033084d6c5e504aca61 +version: "1.16" + + - tlib#input#List: #ReduceFilter: make sure the regexp is valid + - TTimeCommand -> Ttimecommand + - tlib#eval#Extend: mode argument for expand() compatibility + - tlib#input#List: Key handlers can have additional arguments + - tlib#qfl#AgentWithSelected: Set world + - prototype.UseInputListScratch: Run tlib_UseInputListScratch hook earlier + - tlib#qfl#AgentWithSelected: typo + - tlib#arg#GetOpts: type conversion (comma-separated lists etc.) + - tlib#arg: validators + - NEW tlib#date#IsDate() + - tlib#balloon#Remove: Unset &ballooneval, &balloonexpr + - NEW tlib#balloon#Expand() + - NEW tlib#date#Format() + - FIX tlib#date#Shift(..., "+Xm") for months + - NEW tlib#trace#Backtrace() + - NEW tlib#type#Is(), tlib#type#Are(), tlib#type#Has(), tlib#type#Have() + - NEW :Tlibassert + MD5 checksum: 3c4125a28ff1860accd254846651c251 +version: "1.17" + + - tlib#input#List: #ReduceFilter: make sure the regexp is valid + - TTimeCommand -> Ttimecommand + - tlib#eval#Extend: mode argument for expand() compatibility + - tlib#input#List: Key handlers can have additional arguments + - tlib#qfl#AgentWithSelected: Set world + - prototype.UseInputListScratch: Run tlib_UseInputListScratch hook earlier + - tlib#qfl#AgentWithSelected: typo + - tlib#arg#GetOpts: type conversion (comma-separated lists etc.) + - tlib#arg: validators + - NEW tlib#date#IsDate() + - tlib#balloon#Remove: Unset &ballooneval, &balloonexpr + - NEW tlib#balloon#Expand() + - NEW tlib#date#Format() + - FIX tlib#date#Shift(..., "+Xm") for months + - NEW tlib#trace#Backtrace() + - NEW tlib#type#Is(), tlib#type#Are(), tlib#type#Has(), tlib#type#Have() + - NEW :Tlibassert + MD5 checksum: 3c4125a28ff1860accd254846651c251 +version: "1.17" + + - tlib#input#List: #ReduceFilter: make sure the regexp is valid + - TTimeCommand -> Ttimecommand + - tlib#eval#Extend: mode argument for expand() compatibility + - tlib#input#List: Key handlers can have additional arguments + - tlib#qfl#AgentWithSelected: Set world + - prototype.UseInputListScratch: Run tlib_UseInputListScratch hook earlier + - tlib#qfl#AgentWithSelected: typo + - tlib#arg#GetOpts: type conversion (comma-separated lists etc.) + - tlib#arg: validators + - NEW tlib#date#IsDate() + - tlib#balloon#Remove: Unset &ballooneval, &balloonexpr + - NEW tlib#balloon#Expand() + - NEW tlib#date#Format() + - FIX tlib#date#Shift(..., "+Xm") for months + - NEW tlib#trace#Backtrace() + - NEW tlib#type#Is(), tlib#type#Are(), tlib#type#Has(), tlib#type#Have() + - NEW :Tlibassert + MD5 checksum: 3c4125a28ff1860accd254846651c251 +version: "1.17" + + - tlib#input#List: #ReduceFilter: make sure the regexp is valid + - TTimeCommand -> Ttimecommand + - tlib#eval#Extend: mode argument for expand() compatibility + - tlib#input#List: Key handlers can have additional arguments + - tlib#qfl#AgentWithSelected: Set world + - prototype.UseInputListScratch: Run tlib_UseInputListScratch hook earlier + - tlib#qfl#AgentWithSelected: typo + - tlib#arg#GetOpts: type conversion (comma-separated lists etc.) + - tlib#arg: validators + - NEW tlib#date#IsDate() + - tlib#balloon#Remove: Unset &ballooneval, &balloonexpr + - NEW tlib#balloon#Expand() + - NEW tlib#date#Format() + - FIX tlib#date#Shift(..., "+Xm") for months + - NEW tlib#trace#Backtrace() + - NEW tlib#type#Is(), tlib#type#Are(), tlib#type#Has(), tlib#type#Have() + - NEW :Tlibassert + MD5 checksum: 3c4125a28ff1860accd254846651c251 +version: "1.17" + + - tlib#arg: Completion for comma-separated lists + - Use "silent cd" + - NEW tlib#type#DefSchema(); FIX tlib#type#Has() + - tlib#cache#Value(): minor change + - tlib#date#IsDate() also checks whether the date is valid + - ! tlib#sys#Open(): escape special chars only once + - tlib#trace#Print: Allow for strings + - :Tlibtrace, :Tlibtraceset, :Tlibassert remove `-bar` + - NEW :Tlibtype (type/schema assertions); tlib#type#Is() also accepts schemas as "types" + - tlib#dir#CD(): Use haslocaldir() + - tlib#qfl#AgentGotoQFE: Don't use wincmd w + - NEW tlib#string#Input() + - FIX g:tlib#sys#system_rx; add OpenOffice exensions to g:tlib#sys#special_suffixes + - NEW tlib#selection#GetSelection() + - tlib#date#Shift(): Fix "Xm", ++specs + - tlib#trace#Set: FIX Properly handly "-label" + MD5 checksum: c3a1fe7d3cd86becbd3f7b0ba7ae9cd8 +version: "1.19" + +version: "1.20" + - tlib#arg: Completion for comma-separated lists + - Use "silent cd" + - NEW tlib#type#DefSchema(); FIX tlib#type#Has() + - tlib#cache#Value(): minor change + - tlib#date#IsDate() also checks whether the date is valid + - ! tlib#sys#Open(): escape special chars only once + - tlib#trace#Print: Allow for strings + - :Tlibtrace, :Tlibtraceset, :Tlibassert remove `-bar` + - NEW :Tlibtype (type/schema assertions); tlib#type#Is() also accepts schemas as "types" + - tlib#dir#CD(): Use haslocaldir() + - tlib#qfl#AgentGotoQFE: Don't use wincmd w + - NEW tlib#string#Input() + - FIX g:tlib#sys#system_rx; add OpenOffice exensions to g:tlib#sys#special_suffixes + - NEW tlib#selection#GetSelection() + - tlib#date#Shift(): Fix "Xm", ++specs + - tlib#trace#Set: FIX Properly handly "-label" + MD5 checksum: c919e0782931a8c628c6996903f989d3 + + - tlib#date#Shift(): Support for business days 'Nb' + - tlib#list#Uniq: Properly handle empty strings + - tlib#trace: Use g:tlib#trace#printer and tlib#trace#Printer_{printer} + - tlib#dictionary#Rev: Optional argument `opts = {}`; properly handle empty values etc. + - NEW g:tlib#trace#hl + - NEW spec/dictionary.vim + - tlib#agent#CompleteAgentNames: case insensitive + - tlib#arg#CComplete: --[no-]debug option + - tlib#date#Format: use localtime() if no arg is provided + - NEW tlib#file#IsAbsolute + - NEW tlib#notify#PrintError() + - tlib#trace#Print: FIX s/exec/call/ + - tlib#type#Is() match full type name + - NEW tlib#string#MatchAll() + - Tlibtraceset, tlib#trace#Set(): If no `+` or `-` is prepended, assume `+`. + - tlib#list#Input: fix highlighting for filenames + - tlib#input#ListW: use world.CloseScratch(1) + - tlib#agent#ViewFile: Ignore errors in :exec back + - NEW tlib#agent#EditFileInWindow() + - :Tlibtraceset uses tlib#arg#GetOpts(), i.e. you can set the log file more easily + MD5 checksum: 20a48e225f32b9f58808096a5377af04 +version: "1.22" + + - tlib#date#Shift(): Support for business days 'Nb' + - tlib#list#Uniq: Properly handle empty strings + - tlib#trace: Use g:tlib#trace#printer and tlib#trace#Printer_{printer} + - tlib#dictionary#Rev: Optional argument `opts = {}`; properly handle empty values etc. + - NEW g:tlib#trace#hl + - NEW spec/dictionary.vim + - tlib#agent#CompleteAgentNames: case insensitive + - tlib#arg#CComplete: --[no-]debug option + - tlib#date#Format: use localtime() if no arg is provided + - NEW tlib#file#IsAbsolute + - NEW tlib#notify#PrintError() + - tlib#trace#Print: FIX s/exec/call/ + - tlib#type#Is() match full type name + - NEW tlib#string#MatchAll() + - Tlibtraceset, tlib#trace#Set(): If no `+` or `-` is prepended, assume `+`. + - tlib#list#Input: fix highlighting for filenames + - tlib#input#ListW: use world.CloseScratch(1) + - tlib#agent#ViewFile: Ignore errors in :exec back + - NEW tlib#agent#EditFileInWindow() + - :Tlibtraceset uses tlib#arg#GetOpts(), i.e. you can set the log file more easily + MD5 checksum: 20a48e225f32b9f58808096a5377af04 +version: "1.22" + + - bump version 1.23 + misc changes + - FIX #24: avoid vim8 features + - tlib#win#GetID(): Alternative implementation sets a window variable to identify the window + - tlib#arg#GetOpts(): If args is a dict, return it + - tlib#file#FilterFiles(): FIX typo + - tlib#trace#Set: Experimental support for log levels + - tlib#input#ListW: make sure to close scratch when <= 1 items are in the list + - FIX #25: set win_nr again; fix some lint warnings + - tlib#progressbar#Init(): returns a statusline definition that can be used for restor + MD5 checksum: c4d6e018cbbd3b286a9b1648b748c1f3 +version: "1.23" + + - bump version 1.23 + misc changes + - FIX #24: avoid vim8 features + - tlib#win#GetID(): Alternative implementation sets a window variable to identify the window + - tlib#arg#GetOpts(): If args is a dict, return it + - tlib#file#FilterFiles(): FIX typo + - tlib#trace#Set: Experimental support for log levels + - tlib#input#ListW: make sure to close scratch when <= 1 items are in the list + - FIX #25: set win_nr again; fix some lint warnings + - tlib#progressbar#Init(): returns a statusline definition that can be used for restor + MD5 checksum: c4d6e018cbbd3b286a9b1648b748c1f3 +version: "1.23" + + - bump version 1.23 + misc changes + - FIX #24: avoid vim8 features + - tlib#win#GetID(): Alternative implementation sets a window variable to identify the window + - tlib#arg#GetOpts(): If args is a dict, return it + - tlib#file#FilterFiles(): FIX typo + - tlib#trace#Set: Experimental support for log levels + - tlib#input#ListW: make sure to close scratch when <= 1 items are in the list + - FIX #25: set win_nr again; fix some lint warnings + - tlib#progressbar#Init(): returns a statusline definition that can be used for restor + MD5 checksum: c4d6e018cbbd3b286a9b1648b748c1f3 +version: "1.23" + + - bump version 1.23 + misc changes + - FIX #24: avoid vim8 features + - tlib#win#GetID(): Alternative implementation sets a window variable to identify the window + - tlib#arg#GetOpts(): If args is a dict, return it + - tlib#file#FilterFiles(): FIX typo + - tlib#trace#Set: Experimental support for log levels + - tlib#input#ListW: make sure to close scratch when <= 1 items are in the list + - FIX #25: set win_nr again; fix some lint warnings + - tlib#progressbar#Init(): returns a statusline definition that can be used for restor + MD5 checksum: c4d6e018cbbd3b286a9b1648b748c1f3 +version: "1.23" + + - bump version 1.23 + misc changes + - FIX #24: avoid vim8 features + - tlib#win#GetID(): Alternative implementation sets a window variable to identify the window + - tlib#arg#GetOpts(): If args is a dict, return it + - tlib#file#FilterFiles(): FIX typo + - tlib#trace#Set: Experimental support for log levels + - tlib#input#ListW: make sure to close scratch when <= 1 items are in the list + - FIX #25: set win_nr again; fix some lint warnings + - tlib#progressbar#Init(): returns a statusline definition that can be used for restor + MD5 checksum: c4d6e018cbbd3b286a9b1648b748c1f3 +version: "1.23" + + - bump version 1.23 + misc changes + - FIX #24: avoid vim8 features + - tlib#win#GetID(): Alternative implementation sets a window variable to identify the window + - tlib#arg#GetOpts(): If args is a dict, return it + - tlib#file#FilterFiles(): FIX typo + - tlib#trace#Set: Experimental support for log levels + - tlib#input#ListW: make sure to close scratch when <= 1 items are in the list + - FIX #25: set win_nr again; fix some lint warnings + - tlib#progressbar#Init(): returns a statusline definition that can be used for restor + MD5 checksum: c4d6e018cbbd3b286a9b1648b748c1f3 +version: "1.23" + + - bump version 1.23 + misc changes + - FIX #24: avoid vim8 features + - tlib#win#GetID(): Alternative implementation sets a window variable to identify the window + - tlib#arg#GetOpts(): If args is a dict, return it + - tlib#file#FilterFiles(): FIX typo + - tlib#trace#Set: Experimental support for log levels + - tlib#input#ListW: make sure to close scratch when <= 1 items are in the list + - FIX #25: set win_nr again; fix some lint warnings + - tlib#progressbar#Init(): returns a statusline definition that can be used for restor + MD5 checksum: c4d6e018cbbd3b286a9b1648b748c1f3 +version: "1.23" + + - bump version 1.23 + misc changes + - FIX #24: avoid vim8 features + - tlib#win#GetID(): Alternative implementation sets a window variable to identify the window + - tlib#arg#GetOpts(): If args is a dict, return it + - tlib#file#FilterFiles(): FIX typo + - tlib#trace#Set: Experimental support for log levels + - tlib#input#ListW: make sure to close scratch when <= 1 items are in the list + - FIX #25: set win_nr again; fix some lint warnings + - tlib#progressbar#Init(): returns a statusline definition that can be used for restor + MD5 checksum: c4d6e018cbbd3b286a9b1648b748c1f3 +version: "1.23" + + - bump version 1.23 + misc changes + - FIX #24: avoid vim8 features + - tlib#win#GetID(): Alternative implementation sets a window variable to identify the window + - tlib#arg#GetOpts(): If args is a dict, return it + - tlib#file#FilterFiles(): FIX typo + - tlib#trace#Set: Experimental support for log levels + - tlib#input#ListW: make sure to close scratch when <= 1 items are in the list + - FIX #25: set win_nr again; fix some lint warnings + - tlib#progressbar#Init(): returns a statusline definition that can be used for restor + MD5 checksum: c4d6e018cbbd3b286a9b1648b748c1f3 +version: "1.23" + diff --git a/skel/.config/nvim/plugged/tlib_vim/LICENSE.TXT b/skel/.config/nvim/plugged/tlib_vim/LICENSE.TXT new file mode 100644 index 0000000..94a9ed0 --- /dev/null +++ b/skel/.config/nvim/plugged/tlib_vim/LICENSE.TXT @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/skel/.config/nvim/plugged/tlib_vim/README b/skel/.config/nvim/plugged/tlib_vim/README new file mode 100644 index 0000000..98a20bb --- /dev/null +++ b/skel/.config/nvim/plugged/tlib_vim/README @@ -0,0 +1,32 @@ +This library provides some utility functions. There isn't much need to +install it unless another plugin requires you to do so. + +Most of the library is included in autoload files. No autocommands are +created. With the exception of loading ../plugin/02tlib.vim at startup +the library has no impact on startup time or anything else. + +The change-log is included at the bottom of ../plugin/02tlib.vim +(move the cursor over the file name and type gfG) + +Demo of |tlib#input#List()|: +http://vimsomnia.blogspot.com/2010/11/selecting-items-from-list-with-tlibs.html + + +----------------------------------------------------------------------- +Install~ + +Edit the vba file and type: > + + :so % + +See :help vimball for details. If you have difficulties, please make +sure, you have the current version of vimball (vimscript #1502) +installed. + + + + + +License: GPLv3 or later + + diff --git a/skel/.config/nvim/plugged/tlib_vim/addon-info.json b/skel/.config/nvim/plugged/tlib_vim/addon-info.json new file mode 100644 index 0000000..3585531 --- /dev/null +++ b/skel/.config/nvim/plugged/tlib_vim/addon-info.json @@ -0,0 +1,9 @@ +{ + "name" : "tlib", + "version" : "dev", + "author" : "Tom Link ", + "maintainer" : "Tom Link ", + "repository" : {"type": "git", "url": "git://github.com/tomtom/tlib_vim.git"}, + "dependencies" : {}, + "description" : "tlib -- A library of vim functions" +} diff --git a/skel/.config/nvim/plugged/tlib_vim/autoload/tinykeymap/map/para_move.vim b/skel/.config/nvim/plugged/tlib_vim/autoload/tinykeymap/map/para_move.vim new file mode 100644 index 0000000..908f5f7 --- /dev/null +++ b/skel/.config/nvim/plugged/tlib_vim/autoload/tinykeymap/map/para_move.vim @@ -0,0 +1,12 @@ +" para_move.vim +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2012-08-28. +" @Last Change: 2012-08-29. +" @Revision: 3 + +" Move paragraphs +call tinykeymap#EnterMap("para_move", "gp", {'name': 'move paragraph'}) +call tinykeymap#Map("para_move", "j", "silent call tlib#paragraph#Move('Down', '')") +call tinykeymap#Map("para_move", "k", "silent call tlib#paragraph#Move('Up', '')") + diff --git a/skel/.config/nvim/plugged/tlib_vim/autoload/tlib.vim b/skel/.config/nvim/plugged/tlib_vim/autoload/tlib.vim new file mode 100644 index 0000000..5d805ac --- /dev/null +++ b/skel/.config/nvim/plugged/tlib_vim/autoload/tlib.vim @@ -0,0 +1,8 @@ +" @Author: Tom Link (micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Revision: 13 + +" :nodefault: +TLet g:tlib#debug = 0 + diff --git a/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/Filter_cnf.vim b/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/Filter_cnf.vim new file mode 100644 index 0000000..bfdbda3 --- /dev/null +++ b/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/Filter_cnf.vim @@ -0,0 +1,152 @@ +" Filter_cnf.vim +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2008-11-25. +" @Last Change: 2017-09-28. +" @Revision: 11.0.114 + +let s:prototype = tlib#Object#New({'_class': ['Filter_cnf'], 'name': 'cnf'}) "{{{2 +let s:prototype.highlight = g:tlib#input#higroup + +" The search pattern for |tlib#input#List()| is in conjunctive normal +" form: (P1 OR P2 ...) AND (P3 OR P4 ...) ... +" The pattern is a '/\V' very no-'/magic' regexp pattern. +" +" Pressing joins two patterns with AND. +" Pressing | joins two patterns with OR. +" I.e. In order to get "lala AND (foo OR bar)", you type +" "lala foo|bar". +" +" This is also the base class for other filters. +function! tlib#Filter_cnf#New(...) "{{{3 + let object = s:prototype.New(a:0 >= 1 ? a:1 : {}) + return object +endf + + +" :nodoc: +function! s:prototype.Init(world) dict "{{{3 +endf + + +" :nodoc: +function! s:prototype.Help(world) dict "{{{3 + call a:world.PushHelp( + \ printf('"%s", "%s", "%sWORD"', g:tlib#input#and, g:tlib#input#or, g:tlib#input#not), + \ 'AND, OR, NOT') +endf + + +" :nodoc: +function! s:prototype.AssessName(world, name) dict "{{{3 + let xa = 0 + let prefix = self.FilterRxPrefix() + for flt in a:world.filter_pos + " let flt = prefix . a:world.GetRx(fltl) + " if flt =~# '\u' && a:name =~# flt + " let xa += 5 + " endif + let rel = 1.0 + 5.0 * len(flt) / len(a:name) + let xa += float2nr(rel) + if a:name =~ '\^'. flt + let xa += 4 + elseif a:name =~ '\<'. flt + let xa += 3 + " elseif a:name =~ '[[:punct:][:space:][:digit:]]'. flt + " let xa += 2 + elseif a:name =~ '\A'. flt .'\|'. flt .'\A' + let xa += 1 + endif + endfor + " TLogVAR a:name, xa + return xa +endf + + +" :nodoc: +function! s:prototype.Match(world, text) dict "{{{3 + " TLogVAR a:text + " let sc = &smartcase + " let ic = &ignorecase + " if &ignorecase + " set smartcase + " endif + " try + if !empty(a:world.filter_neg) + for rx in a:world.filter_neg + " TLogVAR rx + if a:text =~ rx + return 0 + endif + endfor + endif + if !empty(a:world.filter_pos) + for rx in a:world.filter_pos + " TLogVAR rx + if a:text !~ rx + return 0 + endif + endfor + endif + " finally + " let &smartcase = sc + " let &ignorecase = ic + " endtry + return 1 +endf + + +" :nodoc: +function! s:prototype.DisplayFilter(filter) dict "{{{3 + let filter1 = deepcopy(a:filter) + call map(filter1, '"(". join(reverse(self.Pretty(v:val)), " OR ") .")"') + return join(reverse(filter1), ' AND ') +endf + + +function! s:prototype.Pretty(filter) dict "{{{3 + " call map(a:filter, 'substitute(v:val, ''\\\.\\{-}'', ''=>'', ''g'')') + call map(a:filter, 'self.CleanFilter(v:val)') + return a:filter +endf + + +" :nodoc: +function! s:prototype.SetFrontFilter(world, pattern) dict "{{{3 + let a:world.filter[0] = reverse(split(a:pattern, '\s*|\s*')) + a:world.filter[0][1 : -1] +endf + + +" :nodoc: +function! s:prototype.PushFrontFilter(world, char) dict "{{{3 + let a:world.filter[0][0] .= nr2char(a:char) +endf + + +" :nodoc: +function! s:prototype.ReduceFrontFilter(world) dict "{{{3 + let filter = a:world.filter[0][0] + " TLogVAR filter + let str = matchstr(filter, '\(\\\(\.\\{-}\|[.?*+$^]\)\|\)$') + if empty(str) + let filter = filter[0 : -2] + else + let filter = tlib#string#Strcharpart(filter, 0, len(filter) - len(str)) + endif + " TLogVAR str, filter + let a:world.filter[0][0] = filter +endf + + +" :nodoc: +function! s:prototype.FilterRxPrefix() dict "{{{3 + return '\V' +endf + + +" :nodoc: +function! s:prototype.CleanFilter(filter) dict "{{{3 + return a:filter +endf + diff --git a/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/Filter_cnfd.vim b/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/Filter_cnfd.vim new file mode 100644 index 0000000..27f00fe --- /dev/null +++ b/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/Filter_cnfd.vim @@ -0,0 +1,53 @@ +" Filter_cnfd.vim +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2008-11-25. +" @Last Change: 2014-01-23. +" @Revision: 0.0.57 + +let s:prototype = tlib#Filter_cnf#New({'_class': ['Filter_cnfd'], 'name': 'cnfd'}) "{{{2 +let s:prototype.highlight = g:tlib#input#higroup + + +" The same as |tlib#Filter_cnf#New()| but a dot is expanded to '\.\{-}'. +" As a consequence, patterns cannot match dots. +" The pattern is a '/\V' very no-'/magic' regexp pattern. +function! tlib#Filter_cnfd#New(...) "{{{3 + let object = s:prototype.New(a:0 >= 1 ? a:1 : {}) + return object +endf + + +" :nodoc: +function! s:prototype.Init(world) dict "{{{3 +endf + + +let s:Help = s:prototype.Help + +" :nodoc: +function! s:prototype.Help(world) dict "{{{3 + call call(s:Help, [a:world], self) + call a:world.PushHelp('.', 'Any characters') +endf + + +" :nodoc: +function! s:prototype.SetFrontFilter(world, pattern) dict "{{{3 + let pattern = substitute(a:pattern, '\.', '\\.\\{-}', 'g') + let a:world.filter[0] = reverse(split(pattern, '\s*|\s*')) + a:world.filter[0][1 : -1] +endf + + +" :nodoc: +function! s:prototype.PushFrontFilter(world, char) dict "{{{3 + let a:world.filter[0][0] .= a:char == 46 ? '\.\{-}' : nr2char(a:char) +endf + + +" :nodoc: +function! s:prototype.CleanFilter(filter) dict "{{{3 + return substitute(a:filter, '\\.\\{-}', '.', 'g') +endf + diff --git a/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/Filter_fuzzy.vim b/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/Filter_fuzzy.vim new file mode 100644 index 0000000..349bfd5 --- /dev/null +++ b/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/Filter_fuzzy.vim @@ -0,0 +1,83 @@ +" Filter_fuzzy.vim +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2008-11-25. +" @Last Change: 2013-09-25. +" @Revision: 0.0.47 + +let s:prototype = tlib#Filter_cnf#New({'_class': ['Filter_fuzzy'], 'name': 'fuzzy'}) "{{{2 +let s:prototype.highlight = g:tlib#input#higroup + + +" Support for "fuzzy" pattern matching in |tlib#input#List()|. +" Patterns are interpreted as if characters were connected with '.\{-}'. +" +" In "fuzzy" mode, the pretty printing of filenames is disabled. +function! tlib#Filter_fuzzy#New(...) "{{{3 + let object = s:prototype.New(a:0 >= 1 ? a:1 : {}) + return object +endf + + +" :nodoc: +function! s:prototype.Init(world) dict "{{{3 + " TLogVAR a:world.display_format + " :nodoc: + function! a:world.Set_display_format(value) dict + if a:value == 'filename' + let self.display_format = '' + else + let self.display_format = a:value + endif + endf +endf + + +let s:Help = s:prototype.Help + +" :nodoc: +function! s:prototype.Help(world) dict "{{{3 + call call(s:Help, [a:world], self) + call a:world.PushHelp('Patterns are interpreted as if characters were connected with .\{-}') +endf + + +" :nodoc: +function! s:prototype.DisplayFilter(filter) dict "{{{3 + " TLogVAR a:filter + let filter1 = deepcopy(a:filter) + call map(filter1, '"{". join(reverse(v:val), " OR ") ."}"') + return join(reverse(filter1), ' AND ') +endf + + +" :nodoc: +function! s:prototype.SetFrontFilter(world, pattern) dict "{{{3 + let a:world.filter[0] = map(reverse(split(a:pattern, '\s*|\s*')), 'join(map(split(v:val, ''\zs''), ''tlib#rx#Escape(v:val, "V")''), ''\.\{-}'')') + a:world.filter[0][1 : -1] + endif +endf + + +" :nodoc: +function! s:prototype.PushFrontFilter(world, char) dict "{{{3 + let ch = tlib#rx#Escape(nr2char(a:char), 'V') + if empty(a:world.filter[0][0]) + let a:world.filter[0][0] .= ch + else + let a:world.filter[0][0] .= '\.\{-}'. ch + endif +endf + + +" :nodoc: +function! s:prototype.ReduceFrontFilter(world) dict "{{{3 + let a:world.filter[0][0] = substitute(a:world.filter[0][0], '\(\\\.\\{-}\)\?.$', '', '') +endf + + +" :nodoc: +function! s:prototype.CleanFilter(filter) dict "{{{3 + return substitute(a:filter, '\\\.\\{-}', '', 'g') +endf + diff --git a/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/Filter_glob.vim b/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/Filter_glob.vim new file mode 100644 index 0000000..904b226 --- /dev/null +++ b/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/Filter_glob.vim @@ -0,0 +1,68 @@ +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2008-11-25. +" @Last Change: 2014-11-18. +" @Revision: 0.0.82 + +let s:prototype = tlib#Filter_cnf#New({'_class': ['Filter_glob'], 'name': 'glob'}) "{{{2 +let s:prototype.highlight = g:tlib#input#higroup + + +" A character that should be expanded to '\.\{-}'. +TLet g:tlib#Filter_glob#seq = '*' + + +" A character that should be expanded to '\.\?'. +TLet g:tlib#Filter_glob#char = '?' + + +" The same as |tlib#Filter_cnf#New()| but a a customizable character +" |see tlib#Filter_glob#seq| is expanded to '\.\{-}' and +" |g:tlib#Filter_glob#char| is expanded to '\.'. +" The pattern is a '/\V' very no-'/magic' regexp pattern. +function! tlib#Filter_glob#New(...) "{{{3 + let object = s:prototype.New(a:0 >= 1 ? a:1 : {}) + return object +endf + + +let s:Help = s:prototype.Help + +" :nodoc: +function! s:prototype.Help(world) dict "{{{3 + call call(s:Help, [a:world], self) + call a:world.PushHelp(g:tlib#Filter_glob#seq, 'Any characters') + call a:world.PushHelp(g:tlib#Filter_glob#char, 'Single characters') +endf + + +" :nodoc: +function! s:prototype.SetFrontFilter(world, pattern) dict "{{{3 + let pattern = substitute(a:pattern, tlib#rx#Escape(g:tlib#Filter_glob#seq, 'V'), '\\.\\{-}', 'g') + let pattern = substitute(a:pattern, tlib#rx#Escape(g:tlib#Filter_glob#char, 'V'), '\\.', 'g') + let a:world.filter[0] = reverse(split(pattern, '\s*|\s*')) + a:world.filter[0][1 : -1] +endf + + +" :nodoc: +function! s:prototype.PushFrontFilter(world, char) dict "{{{3 + " TLogVAR a:char, nr2char(a:char) + if a:char == char2nr(g:tlib#Filter_glob#seq) + let char = '\.\{-}' + elseif a:char == char2nr(g:tlib#Filter_glob#char) + let char = '\.' + else + let char = nr2char(a:char) + endif + let a:world.filter[0][0] .= char +endf + + +" :nodoc: +function! s:prototype.CleanFilter(filter) dict "{{{3 + let filter = substitute(a:filter, '\\\.\\{-}', g:tlib#Filter_glob#seq, 'g') + let filter = substitute(filter, '\\\.', g:tlib#Filter_glob#char, 'g') + return filter +endf + diff --git a/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/Object.vim b/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/Object.vim new file mode 100644 index 0000000..21f38b2 --- /dev/null +++ b/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/Object.vim @@ -0,0 +1,154 @@ +" @Author: Tom Link (micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Revision: 127 + +" :filedoc: +" Provides a prototype plus some OO-like methods. + +let s:id_counter = 0 +let s:prototype = {'_class': ['object'], '_super': [], '_id': 0} "{{{2 + +" :def: function! tlib#Object#New(?fields={}) +" This function creates a prototype that provides some kind of +" inheritance mechanism and a way to call parent/super methods. +" +" The usage demonstrated in the following example works best when every +" class/prototype is defined in a file of its own. +" +" The reason for why there is a dedicated constructor function is that +" this layout facilitates the use of templates and that methods are +" hidden from the user. Other solutions are possible. +" +" EXAMPLES: > +" let s:prototype = tlib#Object#New({ +" \ '_class': ['FooBar'], +" \ 'foo': 1, +" \ 'bar': 2, +" \ }) +" " Constructor +" function! FooBar(...) +" let object = s:prototype.New(a:0 >= 1 ? a:1 : {}) +" return object +" endf +" function! s:prototype.babble() { +" echo "I think, therefore I am ". (self.foo * self.bar) ." months old." +" } +" +" < This could now be used like this: > +" let myfoo = FooBar({'foo': 3}) +" call myfoo.babble() +" => I think, therefore I am 6 months old. +" echo myfoo.IsA('FooBar') +" => 1 +" echo myfoo.IsA('object') +" => 1 +" echo myfoo.IsA('Foo') +" => 0 +" echo myfoo.RespondTo('babble') +" => 1 +" echo myfoo.RespondTo('speak') +" => 0 +function! tlib#Object#New(...) "{{{3 + return s:prototype.New(a:0 >= 1 ? a:1 : {}) +endf + + +function! s:prototype.New(...) dict "{{{3 + let object = deepcopy(self) + let s:id_counter += 1 + let object._id = s:id_counter + if a:0 >= 1 && !empty(a:1) + " call object.Extend(deepcopy(a:1)) + call object.Extend(a:1) + endif + return object +endf + + +function! s:prototype.Inherit(object) dict "{{{3 + let class = copy(self._class) + " TLogVAR class + let objid = self._id + for c in get(a:object, '_class', []) + " TLogVAR c + if index(class, c) == -1 + call add(class, c) + endif + endfor + call extend(self, a:object, 'keep') + let self._class = class + " TLogVAR self._class + let self._id = objid + " let self._super = [super] + self._super + call insert(self._super, a:object) + return self +endf + + +function! s:prototype.Extend(dictionary) dict "{{{3 + let super = copy(self) + let class = copy(self._class) + " TLogVAR class + let objid = self._id + let thisclass = get(a:dictionary, '_class', []) + for c in type(thisclass) == 3 ? thisclass : [thisclass] + " TLogVAR c + if index(class, c) == -1 + call add(class, c) + endif + endfor + call extend(self, a:dictionary) + let self._class = class + " TLogVAR self._class + let self._id = objid + " let self._super = [super] + self._super + call insert(self._super, super) + return self +endf + + +function! s:prototype.IsA(class) dict "{{{3 + return index(self._class, a:class) != -1 +endf + + +function! s:prototype.IsRelated(object) dict "{{{3 + return len(filter(a:object._class, 'self.IsA(v:val)')) > 1 +endf + + +function! s:prototype.RespondTo(name) dict "{{{3 + " return has_key(self, a:name) && type(self[a:name]) == 2 + return has_key(self, a:name) +endf + + +function! s:prototype.Super(method, arglist) dict "{{{3 + for o in self._super + " TLogVAR o + if o.RespondTo(a:method) + " let self._tmp_method = o[a:method] + " TLogVAR self._tmp_method + " return call(self._tmp_method, a:arglist, self) + return call(o[a:method], a:arglist, self) + endif + endfor + echoerr 'tlib#Object: Does not respond to '. a:method .': '. string(self) +endf + + +function! tlib#Object#Methods(object, ...) "{{{3 + TVarArg ['pattern', '\d\+'] + let o = items(a:object) + call filter(o, 'type(v:val[1]) == 2 && string(v:val[1]) =~ "^function(''\\d\\+'')"') + let acc = {} + for e in o + let id = matchstr(string(e[1]), pattern) + if !empty(id) + let acc[id] = e[0] + endif + endfor + return acc +endf + diff --git a/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/Test.vim b/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/Test.vim new file mode 100644 index 0000000..4a4281e --- /dev/null +++ b/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/Test.vim @@ -0,0 +1,19 @@ +" @Author: Tom Link (micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Revision: 11 + +" :enddoc: + + +let s:prototype = tlib#Object#New({'_class': ['Test']}) "{{{2 +function! tlib#Test#New(...) "{{{3 + let object = s:prototype.New(a:0 >= 1 ? a:1 : {}) + return object +endf + + +function! s:prototype.Dummy() dict "{{{3 + return 'Test.vim' +endf + diff --git a/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/TestChild.vim b/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/TestChild.vim new file mode 100644 index 0000000..16979a7 --- /dev/null +++ b/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/TestChild.vim @@ -0,0 +1,19 @@ +" @Author: Tom Link (micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Revision: 15 + +" :enddoc: + + +let s:prototype = tlib#Test#New({'_class': ['TestChild']}) "{{{2 +function! tlib#TestChild#New(...) "{{{3 + let object = s:prototype.New(a:0 >= 1 ? a:1 : {}) + return object +endf + + +function! s:prototype.Dummy() dict "{{{3 + return 'TestChild.vim' +endf + diff --git a/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/World.vim b/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/World.vim new file mode 100644 index 0000000..0d0094a --- /dev/null +++ b/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/World.vim @@ -0,0 +1,1396 @@ +" @Author: Tom Link (micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Revision: 1482 + + +" :filedoc: +" A prototype used by |tlib#input#List|. +" Inherits from |tlib#Object#New|. + + +" Size of the input list window (in percent) from the main size (of &lines). +" See |tlib#input#List()|. +TLet g:tlib_inputlist_pct = 50 + +" Max height for a horizontal list. +TLet g:tlib_inputlist_max_lines = -1 + +" Max width for a vertical list. +TLet g:tlib_inputlist_max_cols = -1 + +" Size of filename columns when listing filenames. +" See |tlib#input#List()|. +TLet g:tlib_inputlist_width_filename = '&columns / 3' +" TLet g:tlib_inputlist_width_filename = 25 + +" If true, |tlib#input#List()| will show some indicators about the +" status of a filename (e.g. buflisted(), bufloaded() etc.). +" This is disabled by default because vim checks also for the file on +" disk when doing this. +TLet g:tlib_inputlist_filename_indicators = 0 + +" If not null, display only a short info about the filter. +TLet g:tlib_inputlist_shortmessage = 0 + + + +" Known keys & values: +" scratch_split ... See |tlib#scratch#UseScratch()| +let s:prototype = tlib#Object#New({ + \ '_class': 'World', + \ 'name': 'world', + \ 'allow_suspend': 1, + \ 'base': [], + \ 'bufnr': -1, + \ 'buffer_local': 1, + \ 'cache_var': '', + \ 'display_format': '', + \ 'fileencoding': &fileencoding, + \ 'fmt_display': {}, + \ 'fmt_filter': {}, + \ 'fmt_options': {}, + \ 'filetype': '', + \ 'filter': [['']], + \ 'filter_format': '', + \ 'filter_options': '', + \ 'follow_cursor': '', + \ 'has_menu': 0, + \ 'help_extra': [], + \ 'index_table': [], + \ 'initial_filter': [['']], + \ 'initial_index': 1, + \ 'initial_display': 1, + \ 'initialized': 0, + \ 'key_handlers': [], + \ 'list': [], + \ 'matcher': {}, + \ 'next_agent': '', + \ 'next_eval': '', + \ 'next_state': '', + \ 'numeric_chars': g:tlib#input#numeric_chars, + \ 'offset': 1, + \ 'offset_horizontal': 0, + \ 'on_leave': [], + \ 'pick_last_item': tlib#var#Get('tlib#input#pick_last_item', 'bg'), + \ 'post_handlers': [], + \ 'query': '', + \ 'resize': 0, + \ 'resize_vertical': 0, + \ 'restore_from_cache': [], + \ 'filtered_items': [], + \ 'resume_state': '', + \ 'retrieve_eval': '', + \ 'return_agent': '', + \ 'rv': '', + \ 'scratch': '__InputList__', + \ 'scratch_filetype': 'tlibInputList', + \ 'scratch_hidden': g:tlib#scratch#hidden, + \ 'scratch_vertical': 0, + \ 'scratch_split': 1, + \ 'sel_idx': [], + \ 'show_empty': 0, + \ 'state': 'display', + \ 'state_handlers': [], + \ 'sticky': 0, + \ 'temp_lines': [], + \ 'temp_prompt': [], + \ 'timeout': 0, + \ 'timeout_resolution': 2, + \ 'tabpagenr': -1, + \ 'type': '', + \ 'win_id': g:tlib#win#null_id, + \ 'win_height': -1, + \ 'win_width': -1, + \ 'win_pct': 25, + \ }) + " \ 'handlers': [], + " \ 'filter_options': '\c', + +function! tlib#World#New(...) abort + let object = s:prototype.New(a:0 >= 1 ? a:1 : {}) + call object.SetMatchMode(tlib#var#Get('tlib#input#filter_mode', 'g', 'cnf')) + return object +endf + + +" :nodoc: +function! s:prototype.Set_display_format(value) dict abort "{{{3 + if a:value ==# 'filename' + call self.Set_highlight_filename() + let self.display_format = 'world.FormatFilename(%s)' + else + let self.display_format = a:value + endif +endf + + +" :nodoc: +function! s:prototype.DisplayFormat(list) dict abort "{{{3 + let display_format = self.display_format + if !empty(display_format) + if has_key(self, 'InitFormatName') + call self.InitFormatName() + endif + let cache = self.fmt_display + Tlibtrace 'tlib', display_format + return map(copy(a:list), 'self.FormatName(cache, display_format, v:val)') + else + return a:list + endif +endf + + +" :nodoc: +function! s:prototype.Set_highlight_filename() dict abort "{{{3 + let self.tlib_UseInputListScratch = 'call world.Highlight_filename()' +endf + + +if g:tlib#input#format_filename ==# 'r' + + " :nodoc: + function! s:prototype.Highlight_filename() dict abort "{{{3 + syntax match TLibDir /\s\+\zs.\{-}[\/]\ze[^\/]\+$/ + hi def link TLibDir Directory + syntax match TLibFilename /[^\/]\+$/ + hi def link TLibFilename Normal + endf + + " :nodoc: + function! s:prototype.FormatFilename(file) dict abort "{{{3 + if !has_key(self.fmt_options, 'maxlen') + let maxco = &columns - len(len(self.base)) - eval(g:tlib#input#filename_padding_r) + let maxfi = max(map(copy(self.base), 'strwidth(v:val)')) + let self.fmt_options.maxlen = min([maxco, maxfi]) + Tlibtrace 'tlib', maxco, maxfi, self.fmt_options.maxlen + endif + let max = self.fmt_options.maxlen + if len(a:file) > max + let filename = '...' . tlib#string#Strcharpart(a:file, len(a:file) - max + 3) + else + let filename = printf('% '. max .'s', a:file) + endif + return filename + endf + +else + + " :nodoc: + function! s:prototype.Highlight_filename() dict abort "{{{3 + " let self.width_filename = 1 + eval(g:tlib_inputlist_width_filename) + Tlibtrace 'tlib', self.base + let self.width_filename = min([ + \ get(self, 'width_filename', &columns), + \ empty(g:tlib#input#filename_max_width) ? &columns : eval(g:tlib#input#filename_max_width), + \ max(map(copy(self.base), 'strwidth(matchstr(v:val, "[^\\/]*$"))')) + \ ]) + " TLogVAR self.width_filename + " exec 'syntax match TLibDir /\%>'. (1 + self.width_filename) .'c \(|\|\[[^]]*\]\) \zs\(\(\a:\|\.\.\|\.\.\..\{-}\)\?[\/][^&<>*|]\{-}\)\?[^\/]\+$/ contained containedin=TLibMarker contains=TLibFilename' + exec 'syntax match TLibDir /\%>'. (1 + self.width_filename) .'c \(|\|\[[^]]*\]\) \zs[^&<>*|]*$/ contained containedin=TLibMarker contains=TLibFilename' + exec 'syntax match TLibMarker /\%>'. (1 + self.width_filename) .'c \(|\|\[[^]]*\]\) \S.*$/ contains=TLibDir' + " exec 'syntax match TLibDir /\(|\|\[.\{-}\]\) \zs\(\(\a:\|\.\.\|\.\.\..\{-}\)\?[\/][^&<>*|]\{-}\)\?[^\/]\+$/ contained containedin=TLibMarker contains=TLibFilename' + " exec 'syntax match TLibMarker /\(|\|\[.\{-}\]\) \S.*$/ contains=TLibDir' + exec 'syntax match TLibFilename /[^\/]\+$/ contained containedin=TLibDir' + hi def link TLibMarker Special + hi def link TLibDir Directory + hi def link TLibFilename NonText + " :nodoc: + function! self.Highlighter(rx) dict abort + let rx = '/\c\%>'. (1 + self.width_filename) .'c \(|\|\[[^]]*\]\) .\{-}\zs'. escape(a:rx, '/') .'/' + exec 'match' self.matcher.highlight rx + endf + endf + + + " :nodoc: + function! s:prototype.UseFilenameIndicators() dict abort "{{{3 + return g:tlib_inputlist_filename_indicators || has_key(self, 'filename_indicators') + endf + + + " :nodoc: + function! s:prototype.InitFormatName() dict abort "{{{3 + if self.UseFilenameIndicators() + let self._buffers = {} + for bufnr in range(1, bufnr('$')) + let filename = fnamemodify(bufname(bufnr), ':p') + Tlibtrace 'tlib', filename + let bufdef = { + \ 'bufnr': bufnr, + \ } + " '&buflisted' + for opt in ['&modified', '&bufhidden'] + let bufdef[opt] = getbufvar(bufnr, opt) + endfor + let self._buffers[filename] = bufdef + endfor + endif + endf + + + " :nodoc: + function! s:prototype.FormatFilename(file) dict abort "{{{3 + Tlibtrace 'tlib', a:file + let width = self.width_filename + let split = match(a:file, '[/\\]\zs[^/\\]\+$') + if split == -1 + let fname = a:file + let dname = a:file + else + let fname = strpart(a:file, split) + " let dname = tlib#string#Strcharpart(a:file, 0, split - 1) + let dname = a:file + endif + if strwidth(fname) > width + let fname = tlib#string#Strcharpart(fname, 0, width - 3) .'...' + endif + let dnmax = &columns - max([width, strwidth(fname)]) - 8 - self.index_width - &foldcolumn + let use_indicators = self.UseFilenameIndicators() + Tlibtrace 'tlib', use_indicators + let marker = [] + if use_indicators + call insert(marker, '[') + if g:tlib_inputlist_filename_indicators + let bufdef = get(self._buffers, a:file, {}) + " let bnr = bufnr(a:file) + let bnr = get(bufdef, 'bufnr', -1) + Tlibtrace 'tlib', a:file, bnr, self.bufnr + if bnr != -1 + if bnr == self.bufnr + call add(marker, '%') + else + call add(marker, bnr) + endif + if get(bufdef, '&modified', 0) + call add(marker, '+') + endif + if get(bufdef, '&bufhidden', '') ==# 'hide' + call add(marker, 'h') + endif + " if !get(bufdef, '&buflisted', 1) + " call add(marker, 'u') + " endif + " echom "DBG" a:file string(get(self,'filename_indicators')) + endif + endif + if has_key(self, 'filename_indicators') && has_key(self.filename_indicators, a:file) + if len(marker) > 1 + call add(marker, '|') + endif + call add(marker, self.filename_indicators[a:file]) + endif + if len(marker) <= 1 + call add(marker, ' ') + endif + call add(marker, ']') + else + call add(marker, '|') + endif + let markers = join(marker, '') + if !empty(markers) + let dnmax -= len(markers) + endif + if strwidth(dname) > dnmax + let dname = '...'. tlib#string#Strcharpart(dname, len(dname) - dnmax) + endif + return printf('%-*s %s %s', + \ self.width_filename + len(fname) - strwidth(fname), + \ fname, markers, dname) + endf + +endif + + +" :nodoc: +function! s:prototype.GetSelectedItems(current) dict abort "{{{3 + Tlibtrace 'tlib', a:current + if stridx(self.type, 'i') != -1 + let rv = copy(self.sel_idx) + else + let rv = map(copy(self.sel_idx), 'self.GetBaseItem(v:val)') + endif + if !empty(a:current) + Tlibtrace 'tlib', a:current, rv, type(a:current) + if tlib#type#IsNumber(a:current) || tlib#type#IsString(a:current) + call s:InsertSelectedItems(rv, a:current) + elseif tlib#type#IsList(a:current) + for item in a:current + call s:InsertSelectedItems(rv, item) + endfor + elseif tlib#type#IsDictionary(a:current) + for [inum, item] in items(a:current) + call s:InsertSelectedItems(rv, item) + endfor + endif + endif + " TAssert empty(rv) || rv[0] == a:current + if stridx(self.type, 'i') != -1 + if !empty(self.index_table) + Tlibtrace 'tlib', rv, self.index_table + call map(rv, 'self.index_table[v:val - 1]') + Tlibtrace 'tlib', rv + endif + endif + return rv +endf + + +function! s:InsertSelectedItems(rv, current) abort "{{{3 + let ci = index(a:rv, a:current) + if ci != -1 + call remove(a:rv, ci) + endif + call insert(a:rv, a:current) +endf + + +" :nodoc: +function! s:prototype.SelectItemsByNames(mode, items) dict abort "{{{3 + for item in a:items + let bi = index(self.base, item) + 1 + Tlibtrace 'tlib', item, bi + if bi > 0 + let si = index(self.sel_idx, bi) + Tlibtrace 'tlib', self.sel_idx + Tlibtrace 'tlib', si + if si == -1 + call add(self.sel_idx, bi) + elseif a:mode ==# 'toggle' + call remove(self.sel_idx, si) + endif + endif + endfor + return 1 +endf + + +" :nodoc: +function! s:prototype.SelectItem(mode, index) dict abort "{{{3 + Tlibtrace 'tlib', a:mode, a:index + let bi = self.GetBaseIdx(a:index) + " if self.RespondTo('MaySelectItem') + " if !self.MaySelectItem(bi) + " return 0 + " endif + " endif + Tlibtrace 'tlib', bi + let si = index(self.sel_idx, bi) + Tlibtrace 'tlib', self.sel_idx + Tlibtrace 'tlib', si + if si == -1 + call add(self.sel_idx, bi) + elseif a:mode ==# 'toggle' + call remove(self.sel_idx, si) + endif + return 1 +endf + + +" :nodoc: +function! s:prototype.FormatBaseFromData() abort dict "{{{3 + if has_key(self, 'format_data') && has_key(self, 'data') + let self.base = map(copy(self.data), 'call(self.format_data, [v:val], self)') + endif +endf + + +" :nodoc: +function! s:prototype.FormatArgs(format_string, arg) dict abort "{{{3 + let nargs = len(substitute(a:format_string, '%%\|[^%]', '', 'g')) + return [a:format_string] + repeat([string(a:arg)], nargs) +endf + + +" :nodoc: +function! s:prototype.GetRx(filter) dict abort "{{{3 + return '\('. join(filter(copy(a:filter), 'v:val[0] !=# "!"'), '\|') .'\)' +endf + + +" :nodoc: +function! s:prototype.GetRx0(...) dict abort "{{{3 + exec tlib#arg#Let(['negative']) + let rx0 = [] + for filter in self.filter + Tlibtrace 'tlib', filter + let rx = join(reverse(filter(copy(filter), '!empty(v:val)')), '\|') + Tlibtrace 'tlib', rx + if !empty(rx) && (negative ? rx[0] == g:tlib#input#not : rx[0] != g:tlib#input#not) + call add(rx0, rx) + endif + endfor + let rx0s = join(rx0, '\|') + if empty(rx0s) + return '' + else + return self.FilterRxPrefix() .'\('. rx0s .'\)' + endif +endf + + +" :nodoc: +function! s:prototype.FormatName(cache, format, value) dict abort "{{{3 + Tlibtrace 'tlib', a:format, a:value + if has_key(a:cache, a:value) + return a:cache[a:value] + else + let world = self + let ftpl = self.FormatArgs(a:format, a:value) + let fn = call(function('printf'), ftpl) + let fmt = eval(fn) + Tlibtrace 'tlib', ftpl, fn, fmt + let a:cache[a:value] = fmt + return fmt + endif +endf + + +" :nodoc: +function! s:prototype.GetItem(idx) dict abort "{{{3 + return self.list[a:idx - 1] +endf + + +" :nodoc: +function! s:prototype.GetListIdx(baseidx) dict abort "{{{3 + " if empty(self.index_table) + let baseidx = a:baseidx + " else + " let baseidx = 0 + self.index_table[a:baseidx - 1] + " Tlibtrace 'tlib', a:baseidx, baseidx, self.index_table + " endif + let rv = index(self.table, baseidx) + Tlibtrace 'tlib', rv, self.table + return rv +endf + + +" :nodoc: +" The first index is 1. +function! s:prototype.GetBaseIdx(idx) dict abort "{{{3 + Tlibtrace 'tlib', a:idx, self.table, self.index_table + if !empty(self.table) && a:idx > 0 && a:idx <= len(self.table) + return self.table[a:idx - 1] + else + return 0 + endif +endf + + +" :nodoc: +function! s:prototype.GetBaseIdx0(idx) dict abort "{{{3 + let idx0 = self.GetBaseIdx(a:idx) - 1 + if idx0 < 0 + call tlib#notify#Echo('TLIB: Internal Error: GetBaseIdx0: idx0 < 0', 'WarningMsg') + endif + return idx0 +endf + + +" :nodoc: +function! s:prototype.GetBaseItem(idx) dict abort "{{{3 + return self.base[a:idx - 1] +endf + + +" :nodoc: +function! s:prototype.SetBaseItem(idx, item) dict abort "{{{3 + let self.base[a:idx - 1] = a:item +endf + + +" :nodoc: +function! s:prototype.GetLineIdx(lnum) dict abort "{{{3 + let line = getline(a:lnum) + let prefidx = substitute(matchstr(line, '^\d\+\ze[*:]'), '^0\+', '', '') + return prefidx +endf + + +" :nodoc: +function! s:prototype.SetPrefIdx() dict abort "{{{3 + " let pref = sort(range(1, self.llen), 'self.SortPrefs') + " let self.prefidx = get(pref, 0, self.initial_index) + let pref_idx = -1 + let pref_weight = -1 + Tlibtrace 'tlib', self.filter_pos, self.filter_neg + let t0 = localtime() + for idx in range(1, self.llen) + let item = self.GetItem(idx) + let weight = self.matcher.AssessName(self, item) + Tlibtrace 'tlib', item, weight + if weight > pref_weight + let pref_idx = idx + let pref_weight = weight + endif + endfor + Tlibtrace 'tlib', localtime() - t0 + Tlibtrace 'tlib', pref_idx + if pref_idx == -1 + let self.prefidx = self.initial_index + else + let self.prefidx = pref_idx + endif +endf + + +" " :nodoc: +" function! s:prototype.GetCurrentItem() dict abort "{{{3 +" let idx = self.prefidx +" Tlibtrace 'tlib', idx +" if stridx(self.type, 'i') != -1 +" return idx +" elseif !empty(self.list) +" if len(self.list) >= idx +" let idx1 = idx - 1 +" let rv = self.list[idx - 1] +" Tlibtrace 'tlib', idx, idx1, rv, self.list +" return rv +" endif +" else +" return '' +" endif +" endf + + +" :nodoc: +function! s:prototype.CurrentItem() dict abort "{{{3 + if stridx(self.type, 'i') != -1 + return self.GetBaseIdx(self.llen == 1 ? 1 : self.prefidx) + else + if self.llen == 1 + Tlibtrace 'tlib', self.llen + return self.list[0] + elseif self.prefidx > 0 + Tlibtrace 'tlib', self.prefidx + " return self.GetCurrentItem() + if len(self.list) >= self.prefidx + let rv = self.list[self.prefidx - 1] + Tlibtrace 'tlib', self.prefidx, len(self.list), rv + return rv + endif + else + return '' + endif + endif +endf + + +" :nodoc: +function! s:prototype.FilterRxPrefix() dict abort "{{{3 + return self.matcher.FilterRxPrefix() +endf + + +" :nodoc: +function! s:prototype.SetFilter() dict abort "{{{3 + " let mrx = '\V'. (a:0 >= 1 && a:1 ? '\C' : '') + let mrx = self.FilterRxPrefix() . self.filter_options + let self.filter_pos = [] + let self.filter_neg = [] + Tlibtrace 'tlib', mrx, self.filter + for filter in self.filter + Tlibtrace 'tlib', filter + let rx = join(reverse(filter(copy(filter), '!empty(v:val)')), '\|') + Tlibtrace 'tlib', rx + if !empty(rx) + if rx =~# '\u' + let mrx1 = mrx .'\C' + else + let mrx1 = mrx + endif + Tlibtrace 'tlib', rx + if rx[0] == g:tlib#input#not + if len(rx) > 1 + call add(self.filter_neg, mrx1 .'\('. rx[1:-1] .'\)') + endif + else + call add(self.filter_pos, mrx1 .'\('. rx .'\)') + endif + endif + endfor + Tlibtrace 'tlib', self.filter_pos, self.filter_neg +endf + + +" :nodoc: +function! s:prototype.IsValidFilter() dict abort "{{{3 + let last = self.FilterRxPrefix() .'\('. self.filter[0][0] .'\)' + Tlibtrace 'tlib', last + Tlibtrace 'tlib', last + try + let a = match('', last) + return 1 + catch + Tlibtrace 'tlib', v:exception + return 0 + endtry +endf + + +" :nodoc: +function! s:prototype.SetMatchMode(match_mode) dict abort "{{{3 + Tlibtrace 'tlib', a:match_mode + if !empty(a:match_mode) + unlet self.matcher + try + let self.matcher = tlib#Filter_{a:match_mode}#New() + call self.matcher.Init(self) + catch /^Vim\%((\a\+)\)\=:E117/ + throw 'tlib: Unknown mode for tlib#input#filter_mode: '. a:match_mode + endtry + endif +endf + + +" function! s:prototype.Match(text) dict abort "{{{3 +" return self.matcher.Match(self, text) +" endf + + +" :nodoc: +function! s:prototype.MatchBaseIdx(idx) dict abort "{{{3 + let text = self.GetBaseItem(a:idx) + if !empty(self.filter_format) + let text = self.FormatName(self.fmt_filter, self.filter_format, text) + endif + Tlibtrace 'tlib', text + " return self.Match(text) + return self.matcher.Match(self, text) +endf + + +" :nodoc: +function! s:prototype.BuildTableList() dict abort "{{{3 + let time0 = str2float(reltimestr(reltime())) + Tlibtrace 'tlib', time0 + call self.SetFilter() + Tlibtrace 'tlib', self.filter_neg, self.filter_pos + let self.table = range(1, len(self.base)) + Tlibtrace 'tlib', self.filtered_items + let copy_base = 1 + if !empty(self.filtered_items) + let self.table = filter(self.table, 'index(self.filtered_items, v:val) != -1') + let copy_base = 0 + endif + if !empty(self.filter_pos) || !empty(self.filter_neg) + let self.table = filter(self.table, 'self.MatchBaseIdx(v:val)') + let copy_base = 0 + endif + if copy_base + let self.list = copy(self.base) + else + let self.list = map(copy(self.table), 'self.GetBaseItem(v:val)') + endif +endf + + +" :nodoc: +function! s:prototype.ReduceFilter() dict abort "{{{3 + Tlibtrace 'tlib', self.filter + let reduced = 0 + while !reduced + if self.filter[0] == [''] && len(self.filter) > 1 + call remove(self.filter, 0) + elseif empty(self.filter[0][0]) && len(self.filter[0]) > 1 + call remove(self.filter[0], 0) + else + call self.matcher.ReduceFrontFilter(self) + endif + if self.IsValidFilter() + let reduced = 1 + endif + endwh +endf + + +" :nodoc: +" filter is either a string or a list of list of strings. +function! s:prototype.SetInitialFilter(filter) dict abort "{{{3 + " let self.initial_filter = [[''], [a:filter]] + Tlibtrace 'tlib', a:filter + if type(a:filter) == 3 + let self.initial_filter = deepcopy(a:filter) + else + let self.initial_filter = [[a:filter]] + endif +endf + + +" :nodoc: +function! s:prototype.PopFilter() dict abort "{{{3 + Tlibtrace 'tlib', self.filter + if len(self.filter[0]) > 1 + call remove(self.filter[0], 0) + elseif len(self.filter) > 1 + call remove(self.filter, 0) + else + let self.filter[0] = [''] + endif +endf + + +" :nodoc: +function! s:prototype.FilterIsEmpty() dict abort "{{{3 + Tlibtrace 'tlib', self.filter + return self.filter == copy(self.initial_filter) +endf + + +" :nodoc: +function! s:prototype.DisplayFilter() dict abort "{{{3 + let filter1 = copy(self.filter) + call filter(filter1, 'v:val != [""]') + Tlibtrace 'tlib', self.matcher['_class'] + let rv = self.matcher.DisplayFilter(filter1) + let rv = self.CleanFilter(rv) + return rv +endf + + +" :nodoc: +function! s:prototype.SetFrontFilter(pattern) dict abort "{{{3 + call self.matcher.SetFrontFilter(self, a:pattern) +endf + + +" :nodoc: +function! s:prototype.PushFrontFilter(char) dict abort "{{{3 + call self.matcher.PushFrontFilter(self, a:char) +endf + + +" :nodoc: +function! s:prototype.CleanFilter(filter) dict abort "{{{3 + return self.matcher.CleanFilter(a:filter) +endf + + +" :nodoc: +function! s:prototype.UseScratch() dict abort "{{{3 + " if type(self.scratch) != 0 && get(self, 'buffer_local', 1) + " if self.scratch != fnamemodify(self.scratch, ':p') + " let self.scratch = tlib#file#Join([expand('%:p:h'), self.scratch]) + " Tlibtrace 'tlib', self.scratch + " endif + " " let self.scratch_hidden = 'wipe' + " endif + keepjumps keepalt let rv = tlib#scratch#UseScratch(self) + " if expand('%:t') == self.scratch + let b:tlib_world = self + " endif + return rv +endf + + +" :nodoc: +function! s:prototype.CloseScratch(...) dict abort "{{{3 + TVarArg ['reset_scratch', 0] + " TVarArg ['reset_scratch', 1] + Tlibtrace 'tlib', reset_scratch + if self.sticky + return 0 + else + let rv = tlib#scratch#CloseScratch(self, reset_scratch) + Tlibtrace 'tlib', rv + if rv + call self.SwitchWindow('win') + endif + return rv + endif +endf + + +" :nodoc: +function! s:prototype.Initialize() dict abort "{{{3 + let self.initialized = 1 + call self.SetOrigin(1) + call self.Reset(1) + if !empty(self.cache_var) && exists(self.cache_var) + for prop in self.restore_from_cache + exec 'let self[prop] = get('. self.cache_var .', prop, self[prop])' + endfor + exec 'unlet '. self.cache_var + endif +endf + + +" :nodoc: +function! s:prototype.Leave() dict abort "{{{3 + if !empty(self.cache_var) + exec 'let '. self.cache_var .' = self' + endif + for handler in self.on_leave + call call(handler, [self]) + endfor +endf + + +" :nodoc: +function! s:prototype.UseInputListScratch() dict abort "{{{3 + let scratch = self.UseScratch() + if !exists('b:tlib_list_init') + call tlib#autocmdgroup#Init() + autocmd TLib VimResized call feedkeys("\", 't') + " autocmd TLib WinLeave let b:tlib_world_event = 'WinLeave' | call feedkeys("\", 't') + let b:tlib_list_init = 1 + endif + if !exists('w:tlib_list_init') + Tlibtrace 'tlib', scratch + if has_key(self, 'index_next_syntax') + if type(self.index_next_syntax) == 1 + exec 'syntax match InputlListIndex /^\d\+:\s/ nextgroup='. self.index_next_syntax + elseif type(self.index_next_syntax) == 4 + for [n, nsyn] in items(self.index_next_syntax) + let fn = printf('%0'. world.index_width .'d', n) + exec 'syntax match InputlListIndex /^'. fn .':\s/ nextgroup='. nsyn + endfor + endif + else + syntax match InputlListIndex /^\d\+:\s/ + endif + call tlib#hook#Run('tlib_UseInputListScratch', self) + syntax match InputlListCursor /^\d\+\* .*$/ contains=InputlListIndex + syntax match InputlListSelected /^\d\+# .*$/ contains=InputlListIndex + hi def link InputlListIndex Constant + hi def link InputlListCursor Search + hi def link InputlListSelected IncSearch + setlocal nowrap + " hi def link InputlListIndex Special + " let b:tlibDisplayListMarks = {} + let b:tlibDisplayListMarks = [] + let b:tlibDisplayListWorld = self + let w:tlib_list_init = 1 + endif + return scratch +endf + + +" s:prototype.Reset(?initial=0) +" :nodoc: +function! s:prototype.Reset(...) dict abort "{{{3 + TVarArg ['initial', 0] + Tlibtrace 'tlib', initial + Tlibtrace 'tlib', initial, self.initial_filter + let self.state = 'display' + let self.offset = 1 + let self.filter = deepcopy(self.initial_filter) + let self.idx = '' + let self.prefidx = 0 + let self.initial_display = 1 + let self.fmt_display = {} + let self.fmt_filter = {} + call self.UseInputListScratch() + call self.ResetSelected() + call self.Retrieve(!initial) + call self.FormatBaseFromData() + return self +endf + + +" :nodoc: +function! s:prototype.ResetSelected() dict abort "{{{3 + let self.sel_idx = [] +endf + + +" :nodoc: +function! s:prototype.Retrieve(anyway) dict abort "{{{3 + Tlibtrace 'tlib', a:anyway, self.base + if (a:anyway || empty(self.base)) + let ra = self.retrieve_eval + Tlibtrace 'tlib', ra + if !empty(ra) + let back = self.SwitchWindow('win') + let world = self + let self.base = eval(ra) + Tlibtrace 'tlib', self.base + exec back + return 1 + endif + endif + return 0 +endf + + +function! s:FormatHelp(help) abort "{{{3 + Tlibtrace 'tlib', a:help + let max = [0, 0] + for item in a:help + Tlibtrace 'tlib', item + if type(item) == 3 + let itemlen = map(copy(item), 'strwidth(v:val)') + Tlibtrace 'tlib', itemlen + let max = map(range(2), 'max[v:val] >= itemlen[v:val] ? max[v:val] : itemlen[v:val]') + endif + unlet item + endfor + Tlibtrace 'tlib', max + let cols = float2nr((winwidth(0) - &foldcolumn - 1) / (max[0] + max[1] + 2)) + if cols < 1 + let cols = 1 + endif + let fmt = printf('%%%ds: %%-%ds', max[0], max[1]) + Tlibtrace 'tlib', cols, fmt + let help = [] + let idx = -1 + let maxidx = len(a:help) + while idx < maxidx + let push_item = 0 + let accum = [] + for i in range(cols) + let idx += 1 + if idx >= maxidx + break + endif + let item = a:help[idx] + if type(item) == 3 + call add(accum, item) + else + let push_item = 1 + break + endif + unlet item + endfor + if !empty(accum) + call add(help, s:FormatHelpItem(accum, fmt)) + endif + if push_item + call add(help, a:help[idx]) + endif + endwh + Tlibtrace 'tlib', help + return help +endf + + +function! s:FormatHelpItem(item, fmt) abort "{{{3 + let args = [join(repeat([a:fmt], len(a:item)), ' ')] + for item in a:item + Tlibtrace 'tlib', item + let args += item + endfor + Tlibtrace 'tlib', args + return call('printf', args) +endf + + +" :nodoc: +function! s:prototype.InitHelp() dict abort "{{{3 + return [] +endf + + +" :nodoc: +function! s:prototype.PushHelp(...) dict abort "{{{3 + Tlibtrace 'tlib', a:000 + if a:0 == 1 + if type(a:1) == 3 + let self.temp_lines += a:1 + else + call add(self.temp_lines, a:1) + endif + elseif a:0 == 2 + call add(self.temp_lines, a:000) + else + throw 'TLIB: PushHelp: Wrong number of arguments: '. string(a:000) + endif + Tlibtrace 'tlib', helpstring +endf + + +" :nodoc: +function! s:prototype.DisplayHelp() dict abort "{{{3 + let self.temp_lines = self.InitHelp() + call self.PushHelp('', self.key_mode == 'default' ? 'Abort' : 'Reset keymap') + call self.PushHelp('Enter, ', 'Pick the current item') + call self.PushHelp('Mouse', 'L: Pick item, R: Show menu') + call self.PushHelp('', 'Select an item') + call self.PushHelp(', ', 'Reduce filter') + call self.PushHelp('', 'Complete word') + call self.PushHelp(', ', 'Enter command') + + if self.key_mode == 'default' + call self.PushHelp('', 'Reset the display') + call self.PushHelp('Up/Down', 'Next/previous item') + call self.PushHelp('', 'Edit top filter string') + call self.PushHelp('Page Up/Down', 'Scroll') + call self.PushHelp('', 'Enter * Wildcard') + if self.allow_suspend + call self.PushHelp('', 'Suspend/Resume') + call self.PushHelp('', 'Switch to origin') + endif + if stridx(self.type, 'm') != -1 + call self.PushHelp('', '(Un)Select items') + call self.PushHelp('#', '(Un)Select the current item') + call self.PushHelp('', '(Un)Select all items') + call self.PushHelp('', '(Un)Restrict view to selection') + " \ ' ... Show only selected', + endif + endif + + Tlibtrace 'tlib', len(self.temp_lines) + call self.matcher.Help(self) + + Tlibtrace 'tlib', self.key_mode + for handler in values(self.key_map[self.key_mode]) + Tlibtrace 'tlib', handler + let key = get(handler, 'key_name', '') + Tlibtrace 'tlib', key + if !empty(key) + let desc = get(handler, 'help', '') + if empty(desc) + let desc = get(handler, 'agent', '') + endif + call self.PushHelp(key, desc) + endif + endfor + + if !has_key(self.key_map[self.key_mode], 'unknown_key') + call self.PushHelp('Letter', 'Filter the list') + endif + + if self.key_mode == 'default' && !empty(self.help_extra) + call self.PushHelp(self.help_extra) + endif + + Tlibtrace 'tlib', len(self.temp_lines) + call self.PushHelp([ + \ '', + \ 'Matches at word boundaries are prioritized.', + \ ]) + let self.temp_lines = s:FormatHelp(self.temp_lines) + call self.PrintLines() +endf + + +function! s:prototype.PrintLines() dict abort "{{{3 + let self.temp_prompt = ['Press any key to continue.', 'Question'] + call tlib#buffer#DeleteRange('1', '$') + call append(0, self.temp_lines) + call tlib#buffer#DeleteRange('$', '$') + 1 + call self.Resize(len(self.temp_lines), 0) + let self.temp_lines = [] +endf + + +" :nodoc: +function! s:prototype.Resize(hsize, vsize) dict abort "{{{3 + Tlibtrace 'tlib', self.scratch_vertical, a:hsize, a:vsize + let world_resize = '' + let winpos = '' + let scratch_split = get(self, 'scratch_split', 1) + Tlibtrace 'tlib', scratch_split + if scratch_split > 0 + if self.scratch_vertical + if a:vsize + let world_resize = 'vert resize '. a:vsize + let winpos = tlib#fixes#Winpos() + " let w:winresize = {'v': a:vsize} + " setlocal winfixwidth + endif + else + if a:hsize + let world_resize = 'resize '. a:hsize + " let w:winresize = {'h': a:hsize} + " setlocal winfixheight + endif + endif + endif + if !empty(world_resize) + Tlibtrace 'tlib', world_resize, winpos + setlocal nowinfixheight + setlocal nowinfixwidth + exec world_resize + setlocal winfixheight + setlocal winfixwidth + if !empty(winpos) + exec winpos + endif + " redraw! + endif +endf + + +" :nodoc: +function! s:prototype.GetResize(size) dict abort "{{{3 + let resize0 = get(self, 'resize', 0) + let resize = empty(resize0) ? 0 : eval(resize0) + Tlibtrace 'tlib', resize0, resize + let resize = resize == 0 ? a:size : min([a:size, resize]) + " let min = self.scratch_vertical ? &cols : &lines + let min1 = (self.scratch_vertical ? self.win_width : self.win_height) * g:tlib_inputlist_pct + let min2 = (self.scratch_vertical ? &columns : &lines) * self.win_pct + let min3 = &previewheight + let min = max([min1, min2]) + let ns = [resize, (min / 100)] + let maxn = self.scratch_vertical ? g:tlib_inputlist_max_cols : g:tlib_inputlist_max_lines + if maxn > 0 + call add(ns, maxn) + endif + let resize = min(ns) + Tlibtrace 'tlib', resize, a:size, min, min1, min2 + return resize +endf + + +" function! s:prototype.DisplayList(?query=self.Query(), ?list=[]) +" :nodoc: +function! s:prototype.DisplayList(...) dict abort "{{{3 + Tlibtrace 'tlib', self.state + let query = a:0 >= 1 ? a:1 : self.Query() + let list = a:0 >= 2 ? a:2 : [] + Tlibtrace 'tlib', query, len(list) + call self.UseScratch() + Tlibtrace 'tlib', self.scratch + " TAssert IsNotEmpty(self.scratch) + if self.state == 'scroll' + call self.ScrollToOffset() + elseif self.state == 'help' + call self.DisplayHelp() + call self.SetStatusline(query) + elseif self.state == 'printlines' + call self.PrintLines() + call self.SetStatusline(query) + else + Tlibtrace 'tlib', query + " let ll = len(list) + let ll = self.llen + " let x = len(ll) + 1 + let x = self.index_width + 1 + Tlibtrace 'tlib', ll + if self.state =~ '\' + call self.Resize(self.GetResize(ll), eval(get(self, 'resize_vertical', 0))) + call tlib#normal#WithRegister('gg"tdG', 't') + let lines = copy(list) + let lines = map(lines, 'substitute(v:val, ''[[:cntrl:][:space:]]'', " ", "g")') + let w = winwidth(0) - &fdc + " let w = winwidth(0) - &fdc - 1 + let lines = map(lines, 'printf("%-'. w .'.'. w .'S", v:val)') + Tlibtrace 'tlib', lines + call append(0, lines) + call tlib#normal#WithRegister('G"tddgg', 't') + endif + Tlibtrace 'tlib', self.prefidx + let base_pref = self.GetBaseIdx(self.prefidx) + Tlibtrace 'tlib', base_pref + if self.state =~ '\' + call filter(b:tlibDisplayListMarks, 'index(self.sel_idx, v:val) == -1 && v:val != base_pref') + Tlibtrace 'tlib', b:tlibDisplayListMarks + call map(b:tlibDisplayListMarks, 'self.DisplayListMark(x, v:val, ":")') + " let b:tlibDisplayListMarks = map(copy(self.sel_idx), 'self.DisplayListMark(x, v:val, "#")') + " call add(b:tlibDisplayListMarks, self.prefidx) + " call self.DisplayListMark(x, self.GetBaseIdx(self.prefidx), '*') + endif + let b:tlibDisplayListMarks = map(copy(self.sel_idx), 'self.DisplayListMark(x, v:val, "#")') + call add(b:tlibDisplayListMarks, base_pref) + call self.DisplayListMark(x, base_pref, '*') + call self.SetOffset() + call self.SetStatusline(query) + Tlibtrace 'tlib', self.offset + call self.ScrollToOffset() + let rx0 = self.GetRx0() + Tlibtrace 'tlib', rx0 + if !empty(self.matcher.highlight) + if empty(rx0) + match none + elseif self.IsValidFilter() + if has_key(self, 'Highlighter') + call self.Highlighter(rx0) + else + exec 'match '. self.matcher.highlight .' /\c'. escape(rx0, '/') .'/' + endif + endif + endif + endif + redraw +endf + + +" :nodoc: +function! s:prototype.SetStatusline(query) dict abort "{{{3 + Tlibtrace 'tlib', a:query + if !empty(self.temp_prompt) + let echo = get(self.temp_prompt, 0, '') + let hl = get(self.temp_prompt, 1, 'Normal') + let self.temp_prompt = [] + else + let hl = 'Normal' + let query = a:query + let options = [self.matcher.name] + if self.sticky + call add(options, '#') + endif + if self.key_mode != 'default' + call add(options, 'map:'. self.key_mode) + endif + if !empty(self.filtered_items) + if g:tlib_inputlist_shortmessage + call add(options, 'R') + else + call add(options, 'restricted') + endif + endif + if !empty(options) + let sopts = printf('[%s]', join(options, ', ')) + " let echo = query . repeat(' ', &columns - len(sopts) - len(query) - 20) . sopts + let echo = query . ' ' . sopts + " let query .= '%%='. sopts .' ' + endif + Tlibtrace 'tlib', &l:statusline, query + " let &l:statusline = query + endif + echo + if hl != 'Normal' + exec 'echohl' hl + echo echo + echohl None + else + echo echo + endif +endf + + +" :nodoc: +function! s:prototype.Query() dict abort "{{{3 + let flt = self.DisplayFilter() + if g:tlib_inputlist_shortmessage + let query = 'Filter: '. flt + else + let query = self.query .' (filter: '. flt .'; press for help)' + endif + return query +endf + + +" :nodoc: +function! s:prototype.ScrollToOffset() dict abort "{{{3 + Tlibtrace 'tlib', self.scratch_vertical, self.llen, winheight(0) + exec 'norm! '. self.offset .'zt' +endf + + +" :nodoc: +function! s:prototype.SetOffset() dict abort "{{{3 + Tlibtrace 'tlib', self.prefidx, self.offset + let listtop = len(self.list) - winheight(0) + 1 + if listtop < 1 + let listtop = 1 + endif + if self.prefidx > listtop + let self.offset = listtop + elseif self.prefidx > self.offset + winheight(0) - 1 + let listoff = self.prefidx - winheight(0) + 1 + let self.offset = min([listtop, listoff]) + " TLogVAR self.prefidx + " TLogVAR listtop, listoff, self.offset + elseif self.prefidx < self.offset + let self.offset = self.prefidx + endif + Tlibtrace 'tlib', self.offset +endf + + +" :nodoc: +function! s:prototype.ClearAllMarks() dict abort "{{{3 + let x = self.index_width + 1 + call map(range(1, line('$')), 'self.DisplayListMark(x, v:val, ":")') +endf + + +" :nodoc: +function! s:prototype.MarkCurrent(y) dict abort "{{{3 + let x = self.index_width + 1 + call self.DisplayListMark(x, a:y, '*') +endf + + +" :nodoc: +function! s:prototype.DisplayListMark(x, y, mark) dict abort "{{{3 + Tlibtrace 'tlib', a:y, a:mark + if a:x > 0 && a:y >= 0 + let sy = self.GetListIdx(a:y) + 1 + Tlibtrace 'tlib', sy + if sy >= 1 + call setpos('.', [0, sy, a:x, 0]) + exec 'norm! r'. a:mark + " exec 'norm! '. a:y .'gg'. a:x .'|r'. a:mark + endif + endif + return a:y +endf + + +" :nodoc: +function! s:prototype.SwitchWindow(where) dict abort "{{{3 + " if self.tabpagenr != tabpagenr() + " call tlib#tab#Set(self.tabpagenr) + " endif + " let wnr = get(self, a:where.'_wnr') + " Tlibtrace 'tlib', self, wnr + " return tlib#win#Set(wnr) + return tlib#win#SetById(self[a:where .'_id']) +endf + + +" :nodoc: +function! s:prototype.FollowCursor() dict abort "{{{3 + if !empty(self.follow_cursor) + let back = self.SwitchWindow('win') + Tlibtrace 'tlib', back + try + call call(self.follow_cursor, [self, [self.CurrentItem()]]) + finally + exec back + endtry + endif +endf + + +" :nodoc: +function! s:prototype.SetOrigin(...) dict abort "{{{3 + TVarArg ['winview', 0] + Tlibtrace 'tlib', 'SetOrigin', self.win_id, self.bufnr, bufnr('%'), winnr() + let self.win_wnr = winnr() + let self.win_id = tlib#win#GetID() + let self.win_height = winheight(self.win_wnr) + let self.win_width = winwidth(self.win_wnr) + Tlibtrace 'tlib', 'SetOrigin', self.win_id, self.win_height, self.win_width, bufnr('%'), winnr() + let self.bufnr = bufnr('%') + let self.tabpagenr = tabpagenr() + let self.cursor = getpos('.') + if winview + let self.winview = tlib#win#GetLayout() + endif + Tlibtrace 'tlib', 'SetOrigin', self.win_id, self.bufnr, get(self,'winview','') + return self +endf + + +" :nodoc: +function! s:prototype.RestoreWindow(...) dict abort "{{{3 + TVarArg ['winview', 0] + if winview + Tlibtrace 'tlib', winview + call tlib#win#SetLayout(self.winview) + endif + call tlib#win#GotoID(self.win_id) +endf + + +" :nodoc: +function! s:prototype.RestoreOrigin(...) dict abort "{{{3 + call call(self.RestoreWindow, a:000) + if bufnr('%') != self.bufnr + exec 'buffer! '. self.bufnr + call setpos('.', self.cursor) + endif +endf + + +function! s:prototype.Suspend() dict abort "{{{3 + call tlib#agent#Suspend(self, self.rv) +endf + diff --git a/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/agent.vim b/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/agent.vim new file mode 100644 index 0000000..96f7527 --- /dev/null +++ b/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/agent.vim @@ -0,0 +1,716 @@ +" @Author: Tom Link (micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Revision: 362 + +" :filedoc: +" Various agents for use as key handlers in tlib#input#List() + +" Number of items to move when pressing in the input list window. +TLet g:tlib_scroll_lines = 10 + + +" General {{{1 + +function! tlib#agent#Exit(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected + if a:world.key_mode ==# 'default' + call a:world.CloseScratch() + let a:world.state = 'exit empty escape' + let a:world.list = [] + " let a:world.base = [] + call a:world.ResetSelected() + else + let a:world.key_mode = 'default' + let a:world.state = 'redisplay' + endif + return a:world +endf + + +function! tlib#agent#CopyItems(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected + let @* = join(a:selected, "\n") + let a:world.state = 'redisplay' + return a:world +endf + + + +" InputList related {{{1 + +function! tlib#agent#PageUp(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected + let a:world.offset -= (winheight(0) / 2) + let a:world.state = 'scroll' + return a:world +endf + + +function! tlib#agent#PageDown(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected + let a:world.offset += (winheight(0) / 2) + let a:world.state = 'scroll' + return a:world +endf + + +function! tlib#agent#Home(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected + let a:world.prefidx = 1 + let a:world.state = 'redisplay' + return a:world +endf + + +function! tlib#agent#End(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected + let a:world.prefidx = len(a:world.list) + let a:world.state = 'redisplay' + return a:world +endf + + +function! tlib#agent#Up(world, selected, ...) "{{{3 + TVarArg ['lines', 1] + Tlibtrace 'tlib', a:selected, lines + let a:world.idx = '' + if a:world.prefidx > lines + let a:world.prefidx -= lines + else + let a:world.prefidx = len(a:world.list) + endif + let a:world.state = 'redisplay' + return a:world +endf + + +function! tlib#agent#Down(world, selected, ...) "{{{3 + TVarArg ['lines', 1] + Tlibtrace 'tlib', a:selected, lines + let a:world.idx = '' + if a:world.prefidx <= (len(a:world.list) - lines) + let a:world.prefidx += lines + else + let a:world.prefidx = 1 + endif + let a:world.state = 'redisplay' + return a:world +endf + + +function! tlib#agent#UpN(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected + return tlib#agent#Up(a:world, a:selected, g:tlib_scroll_lines) +endf + + +function! tlib#agent#DownN(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected + return tlib#agent#Down(a:world, a:selected, g:tlib_scroll_lines) +endf + + +function! tlib#agent#ShiftLeft(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected + let a:world.offset_horizontal -= (winwidth(0) / 2) + if a:world.offset_horizontal < 0 + let a:world.offset_horizontal = 0 + endif + let a:world.state = 'display shift' + return a:world +endf + + +function! tlib#agent#ShiftRight(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected + let a:world.offset_horizontal += (winwidth(0) / 2) + let a:world.state = 'display shift' + return a:world +endf + + +function! tlib#agent#Reset(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected + let a:world.state = 'reset' + return a:world +endf + + +function! tlib#agent#ToggleRestrictView(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected + if empty(a:world.filtered_items) + return tlib#agent#RestrictView(a:world, a:selected) + else + return tlib#agent#UnrestrictView(a:world, a:selected) + endif +endf + + +function! tlib#agent#RestrictView(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected + let filtered_items = map(copy(a:selected), 'index(a:world.base, v:val) + 1') + Tlibtrace 'tlib', 1, filtered_items + let filtered_items = filter(filtered_items, 'v:val > 0') + Tlibtrace 'tlib', 2, filtered_items + if !empty(filtered_items) + let a:world.filtered_items = filtered_items + endif + let a:world.state = 'display' + return a:world +endf + + +function! tlib#agent#UnrestrictView(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected + let a:world.filtered_items = [] + let a:world.state = 'display' + return a:world +endf + + +function! tlib#agent#Input(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected + let flt0 = a:world.CleanFilter(a:world.filter[0][0]) + let flt1 = input('Filter: ', flt0) + echo + if flt1 != flt0 + if empty(flt1) + call getchar(0) + else + call a:world.SetFrontFilter(flt1) + endif + endif + let a:world.state = 'display' + return a:world +endf + + +" Suspend (see |tlib#agent#Suspend|) the input loop and jump back to the +" original position in the parent window. +function! tlib#agent#SuspendToParentWindow(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected + let world = a:world + let wid = world.win_id + Tlibtrace 'tlib', wid + if wid != -1 + let world = tlib#agent#Suspend(world, a:selected) + if world.state =~# '\' + call world.SwitchWindow('win') + " let pos = world.cursor + " Tlibtrace 'tlib', pos + " if !empty(pos) + " call setpos('.', pos) + " endif + return world + endif + endif + let world.state = 'redisplay' + return world +endf + + +" Suspend lets you temporarily leave the input loop of +" |tlib#input#List|. You can resume editing the list by pressing , +" . , or in the suspended window. +" and will immediatly select the item under the cursor. +" < will select the item but the window will remain opened. +function! tlib#agent#Suspend(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected + if a:world.allow_suspend + " TAssert IsNotEmpty(a:world.scratch) + " TLogDBG bufnr('%') + let br = tlib#buffer#Set(a:world.scratch) + Tlibtrace 'tlib', br, a:world.bufnr, a:world.scratch + if bufnr('%') != a:world.scratch + echohl WarningMsg + echom "tlib#agent#Suspend: Internal error: Not a scratch buffer:" bufname('%') + echohl NONE + endif + Tlibtrace 'tlib', bufnr('%'), bufname('%'), a:world.scratch + call tlib#autocmdgroup#Init() + exec 'autocmd TLib BufEnter call tlib#input#Resume("world", 0, '. a:world.scratch .')' + let b:tlib_world = a:world + exec br + let a:world.state = 'exit suspend' + else + echom 'Suspend disabled' + let a:world.state = 'redisplay' + endif + return a:world +endf + + +function! tlib#agent#Help(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected + let a:world.state = 'help' + return a:world +endf + + +function! tlib#agent#OR(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected + if !empty(a:world.filter[0]) + call insert(a:world.filter[0], '') + endif + let a:world.state = 'display' + return a:world +endf + + +function! tlib#agent#AND(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected + if !empty(a:world.filter[0]) + call insert(a:world.filter, ['']) + endif + let a:world.state = 'display' + return a:world +endf + + +function! tlib#agent#ReduceFilter(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected + call a:world.ReduceFilter() + let a:world.offset = 1 + let a:world.state = 'display' + return a:world +endf + + +function! tlib#agent#PopFilter(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected + call a:world.PopFilter() + let a:world.offset = 1 + let a:world.state = 'display' + return a:world +endf + + +function! tlib#agent#Debug(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected + " echo string(world.state) + echo string(a:world.filter) + echo string(a:world.idx) + echo string(a:world.prefidx) + echo string(a:world.sel_idx) + call getchar() + let a:world.state = 'display' + return a:world +endf + + +function! tlib#agent#Select(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected + call a:world.SelectItem('toggle', a:world.prefidx) + " let a:world.state = 'display keepcursor' + let a:world.state = 'redisplay' + return a:world +endf + + +function! tlib#agent#SelectUp(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected + call a:world.SelectItem('toggle', a:world.prefidx) + if a:world.prefidx > 1 + let a:world.prefidx -= 1 + endif + let a:world.state = 'redisplay' + return a:world +endf + + +function! tlib#agent#SelectDown(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected + call a:world.SelectItem('toggle', a:world.prefidx) + if a:world.prefidx < len(a:world.list) + let a:world.prefidx += 1 + endif + let a:world.state = 'redisplay' + return a:world +endf + + +function! tlib#agent#SelectAll(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected + let listrange = range(1, len(a:world.list)) + let mode = empty(filter(copy(listrange), 'index(a:world.sel_idx, a:world.GetBaseIdx(v:val)) == -1')) + \ ? 'toggle' : 'set' + for i in listrange + call a:world.SelectItem(mode, i) + endfor + let a:world.state = 'display keepcursor' + return a:world +endf + + +function! tlib#agent#ToggleStickyList(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected + let a:world.sticky = !a:world.sticky + let a:world.state = 'display keepcursor' + return a:world +endf + + + +" EditList related {{{1 + +function! tlib#agent#EditItem(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected + let lidx = a:world.prefidx + Tlibtrace 'tlib', lidx + let bidx = a:world.GetBaseIdx(lidx) + Tlibtrace 'tlib', bidx + let item = a:world.GetBaseItem(bidx) + let item = input(lidx .'@'. bidx .': ', item) + if item != '' + call a:world.SetBaseItem(bidx, item) + endif + let a:world.state = 'display' + return a:world +endf + + +" Insert a new item below the current one. +function! tlib#agent#NewItem(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected + let basepi = a:world.GetBaseIdx(a:world.prefidx) + let item = input('New item: ') + call insert(a:world.base, item, basepi) + let a:world.state = 'reset' + return a:world +endf + + +function! tlib#agent#DeleteItems(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected + let remove = copy(a:world.sel_idx) + let basepi = a:world.GetBaseIdx(a:world.prefidx) + if index(remove, basepi) == -1 + call add(remove, basepi) + endif + " call map(remove, 'a:world.GetBaseIdx(v:val)') + for idx in reverse(sort(remove)) + call remove(a:world.base, idx - 1) + endfor + let a:world.state = 'display' + call a:world.ResetSelected() + " let a:world.state = 'reset' + return a:world +endf + + +function! tlib#agent#Cut(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected + let world = tlib#agent#Copy(a:world, a:selected) + return tlib#agent#DeleteItems(world, a:selected) +endf + + +function! tlib#agent#Copy(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected + let a:world.clipboard = [] + let bidxs = copy(a:world.sel_idx) + call add(bidxs, a:world.GetBaseIdx(a:world.prefidx)) + for bidx in sort(bidxs) + call add(a:world.clipboard, a:world.GetBaseItem(bidx)) + endfor + let a:world.state = 'redisplay' + return a:world +endf + + +function! tlib#agent#Paste(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected + if has_key(a:world, 'clipboard') + for e in reverse(copy(a:world.clipboard)) + call insert(a:world.base, e, a:world.prefidx) + endfor + endif + let a:world.state = 'display' + call a:world.ResetSelected() + return a:world +endf + + +function! tlib#agent#EditReturnValue(world, rv) "{{{3 + Tlibtrace 'tlib', a:rv + return [a:world.state !~ '\', a:world.base] +endf + + + +" Files related {{{1 + +function! tlib#agent#ViewFile(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected + if !empty(a:selected) + let back = a:world.SwitchWindow('win') + Tlibtrace 'tlib', back + for filename in a:selected + call tlib#file#Edit(filename) + endfor + call a:world.SetOrigin(1) + silent! exec back + let a:world.state = 'display' + endif + return a:world +endf + + +function! tlib#agent#EditFile(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected + return tlib#agent#Exit(tlib#agent#ViewFile(a:world, a:selected), a:selected) +endf + + +function! tlib#agent#EditFileInSplit(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected + call a:world.CloseScratch() + call tlib#file#With('split', 'sbuffer', a:selected, a:world, 1) + call a:world.SetOrigin(1) + return tlib#agent#Exit(a:world, a:selected) +endf + + +function! tlib#agent#EditFileInVSplit(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected + call a:world.CloseScratch() + let winpos = tlib#fixes#Winpos() + call tlib#file#With('vertical split', 'vertical sbuffer', a:selected, a:world, 1) + if !empty(winpos) + exec winpos + endif + call a:world.SetOrigin(1) + return tlib#agent#Exit(a:world, a:selected) +endf + + +function! tlib#agent#EditFileInTab(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected + call a:world.CloseScratch() + call tlib#file#With('tabedit', 'tab sbuffer', a:selected, a:world, 1) + call a:world.SetOrigin(1) + return tlib#agent#Exit(a:world, a:selected) +endf + + +function! tlib#agent#EditFileInWindow(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected + call a:world.CloseScratch() + call tlib#file#With('hide edit', 'hide buffer', a:selected, a:world, 1) + call a:world.SetOrigin(1) + return tlib#agent#Exit(a:world, a:selected) +endf + + +function! tlib#agent#ToggleScrollbind(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected + let a:world.scrollbind = get(a:world, 'scrollbind') ? 0 : 1 + let a:world.state = 'redisplay' + return a:world +endf + + +function! tlib#agent#ShowInfo(world, selected) + Tlibtrace 'tlib', a:selected + let lines = [] + for f in a:selected + if filereadable(f) + let desc = [getfperm(f), strftime('%c', getftime(f)), getfsize(f) .' bytes', getftype(f)] + call add(lines, fnamemodify(f, ':p')) + call add(lines, ' '. join(desc, '; ')) + endif + endfor + let a:world.temp_lines = lines + let a:world.state = 'printlines' + return a:world +endf + + + +" Buffer related {{{1 + +function! tlib#agent#ViewBufferInWindow(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected + if !empty(a:selected) + let back = a:world.SwitchWindow('win') + Tlibtrace 'tlib', back + for bufname in a:selected + let cmd = &modified && !&hidden ? 'sbuffer' : 'buffer' + exec cmd fnameescape(bufname) + endfor + " exec back + endif + return tlib#agent#Exit(a:world, a:selected) +endf + + +function! tlib#agent#PreviewLine(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected + let l = a:selected[0] + " let ww = winnr() + let wid = tlib#win#GetID() + call tlib#agent#SuspendToParentWindow(a:world, a:selected) + call tlib#buffer#ViewLine(l, 1) + call tlib#win#GotoID(wid) + " exec ww .'wincmd w' + let a:world.state = 'redisplay' + return a:world +endf + + +" If not called from the scratch, we assume/guess that we don't have to +" suspend the input-evaluation loop. +function! tlib#agent#GotoLine(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected + if !empty(a:selected) + let l = a:selected[0] + if a:world.win_id != tlib#win#GetID() + let world = tlib#agent#Suspend(a:world, a:selected) + call tlib#win#GotoID(a:world.win_id) + endif + call tlib#buffer#ViewLine(l, 1) + + endif + return a:world +endf + + +function! tlib#agent#DoAtLine(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected + if !empty(a:selected) + let cmd = input('Command: ', '', 'command') + if !empty(cmd) + call a:world.SwitchWindow('win') + " let pos = getpos('.') + let view = winsaveview() + for l in a:selected + call tlib#buffer#ViewLine(l, '') + exec cmd + endfor + " call setpos('.', pos) + call winrestview(view) + endif + endif + call a:world.ResetSelected() + let a:world.state = 'exit' + return a:world +endf + + +function! tlib#agent#Wildcard(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected + if !empty(a:world.filter[0]) + let rx_type = a:world.matcher.FilterRxPrefix() + let flt0 = a:world.CleanFilter(a:world.filter[0][0]) + if rx_type == '\V' + let flt0 .= '\.\{-}' + else + let flt0 .= '.\{-}' + endif + call a:world.SetFrontFilter(flt0) + endif + let a:world.state = 'redisplay' + return a:world +endf + + +function! tlib#agent#Null(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected + let a:world.state = 'redisplay' + return a:world +endf + + +function! tlib#agent#ExecAgentByName(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected + let s:agent_names_world = a:world + let agent_names = {'Help': 'tlib#agent#Help'} + for def in values(a:world.key_map[a:world.key_mode]) + if has_key(def, 'help') && !empty(def.help) && has_key(def, 'agent') && !empty(def.agent) + let agent_names[def.help] = def.agent + endif + endfor + let s:agent_names = sort(keys(agent_names)) + let command = input('Command: ', '', 'customlist,tlib#agent#CompleteAgentNames') + Tlibtrace 'tlib', command + if !has_key(agent_names, command) + Tlibtrace 'tlib', command + silent! let matches = filter(keys(agent_names), 'v:val =~ command') + Tlibtrace 'tlib', matches + if len(matches) == 1 + let command = matches[0] + endif + endif + if has_key(agent_names, command) + let agent = agent_names[command] + return call(agent, [a:world, a:selected]) + else + if !empty(command) + echohl WarningMsg + echom "Unknown command:" command + echohl NONE + sleep 1 + endif + let a:world.state = 'display' + return a:world + endif +endf + + +function! tlib#agent#CompleteAgentNames(ArgLead, CmdLine, CursorPos) + let arglead = tolower(a:Arglead) + return filter(copy(s:agent_names), 'stridx(tolower(v:val), arglead) != -1') +endf + + +function! tlib#agent#Complete(world, selected) abort "{{{3 + Tlibtrace 'tlib', a:selected + let rxprefix = a:world.matcher.FilterRxPrefix() + let flt = a:world.filter[0][0] + Tlibtrace 'tlib', flt + let fltrx = rxprefix . flt . '\m[^[:space:][:cntrl:][:punct:]<>*+?&~{}()\[\]\\/]\+' + let fltrx0 = '\m^' . fltrx + Tlibtrace 'tlib', fltrx, fltrx0 + let words = {} + for item in a:world.list + let parts = split(item, '\ze'. fltrx) + Tlibtrace 'tlib', item, parts + for part in parts + let word = matchstr(part, fltrx0) + Tlibtrace 'tlib', part, word + if !empty(word) + let words[word] = 1 + endif + endfor + endfor + Tlibtrace 'tlib', keys(words) + let completions = keys(words) + " let completions = filter(keys(words), 'matchstr(v:val, fltrx0)') + let completions = sort(completions, 's:SortCompletions') + let completions = tlib#list#Uniq(completions) + Tlibtrace 'tlib', 0, completions + while len(completions) > 1 + let nchar = strwidth(completions[0]) - 1 + let completions = map(completions, 'tlib#string#Strcharpart(v:val, 0, nchar)') + Tlibtrace 'tlib', 'reduce', completions + let completions = tlib#list#Uniq(completions) + Tlibtrace 'tlib', 'unique', len(completions), completions + endwh + Tlibtrace 'tlib', 9, completions + if empty(completions) + let a:world.state = 'redisplay update' + else + let a:world.filter[0][0] = completions[0] + let a:world.state = 'display update' + endif + return a:world +endf + + +function! s:SortCompletions(a, b) abort "{{{3 + let i1 = strwidth(a:a) + let i2 = strwidth(a:b) + return i2 - i1 +endf + diff --git a/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/arg.vim b/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/arg.vim new file mode 100644 index 0000000..498e6c7 --- /dev/null +++ b/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/arg.vim @@ -0,0 +1,342 @@ +" @Author: Tom Link (micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Last Change: 2017-09-28. +" @Revision: 273 + + +" :def: function! tlib#arg#Get(n, var, ?default="", ?test='') +" Set a positional argument from a variable argument list. +" See tlib#string#RemoveBackslashes() for an example. +function! tlib#arg#Get(n, var, ...) "{{{3 + let default = a:0 >= 1 ? a:1 : '' + let atest = a:0 >= 2 ? a:2 : '' + " TLogVAR default, atest + if !empty(atest) + let atest = ' && (a:'. a:n .' '. atest .')' + endif + let test = printf('a:0 >= %d', a:n) . atest + return printf('let %s = %s ? a:%d : %s', a:var, test, a:n, string(default)) +endf + + +" :def: function! tlib#arg#Let(list, ?default='') +" Set a positional arguments from a variable argument list. +" See tlib#input#List() for an example. +function! tlib#arg#Let(list, ...) "{{{3 + let default = a:0 >= 1 ? a:1 : '' + let list = map(copy(a:list), 'type(v:val) == 3 ? v:val : [v:val, default]') + let args = map(range(1, len(list)), 'call("tlib#arg#Get", [v:val] + list[v:val - 1])') + return join(args, ' | ') +endf + + +" :def: function! tlib#arg#StringAsKeyArgs(string, ?keys=[], ?evaluate=0, ?sep=':', ?booleans=0) +function! tlib#arg#StringAsKeyArgs(string, ...) "{{{1 + TVarArg ['keys', {}], ['evaluate', 0], ['sep', ':'], ['booleans', 0] + let keyargs = {} + let args = split(a:string, '\\\@= 0 + let keyargs['__posargs__'] = range(0, pos) + endif + return keyargs +endf + + +function! tlib#arg#StringAsKeyArgsEqual(string) "{{{1 + return tlib#arg#StringAsKeyArgs(a:string, [], 0, '=', 1) +endf + + +" :display: tlib#arg#GetOpts(args, ?def={}) +" Convert a list of strings of command-line arguments into a dictonary. +" +" The main use case is to pass [], i.e. the command-line +" arguments of a command as list, from a command definition to this +" function. +" +" Example: +" ['-h'] +" => If def contains a 'help' key, invoke |:help| on its value. +" +" ['-ab', '--foo', '--bar=BAR', 'bla', bla'] +" => {'a': 1, 'b': 1, 'foo': 1, 'bar': 'BAR', '__rest__': ['bla', 'bla']} +" +" ['-ab', '--', '--foo', '--bar=BAR'] +" => {'a': 1, 'b': 1, '__rest__': ['--foo', '--bar=BAR']} +function! tlib#arg#GetOpts(args, ...) abort "{{{3 + if type(a:args) == 4 + reutrn a:args + else + let throw = a:0 == 0 + TVarArg ['def', {}] + " TLogVAR def + let opts = {'__exit__': 0} + for [key, vdef] in items(get(def, 'values', {})) + if has_key(vdef, 'default') + let opts[key] = vdef.default + endif + endfor + let idx = 0 + for o in a:args + let [break, idx] = s:SetOpt(def, opts, idx, o) + if break == 1 + break + elseif break == 2 + if throw + throw 'tlib#arg#GetOpts: Show help' + else + let opts.__exit__ = 5 + endif + endif + endfor + let opts.__rest__ = a:args[idx : -1] + return opts + endif +endf + + +function! s:GetValueType(def) abort "{{{3 + return get(a:def, 'type', type(get(a:def, 'default', ''))) +endf + + +function! s:SetOpt(def, opts, idx, opt) abort "{{{3 + " TLogVAR a:def + let idx = a:idx + 1 + let break = 0 + let long = get(a:def, 'long', 1) + let short = get(a:def, 'short', 1) + if (short && a:opt =~# '^-[?h]$') || (long && a:opt ==# '--help') + if has_key(a:def, 'help') + exec 'help' a:def.help + else + " TLogVAR a:def + let values = get(a:def, 'values', {}) + let flags = get(a:def, 'flags', {}) + if empty(values) && empty(flags) + echom 'No help' + else + if !empty(values) + echom 'Options:' + for [key, vdef] in sort(items(values)) + let opt = key + let default = get(vdef, 'default', '') + let type = s:GetValueType(vdef) + if default =~ '^-\?\d\+\%(\.\d\+\)$' + if type == -1 || type == 6 + let opt .= ' (flag)' + elseif type == 1 + let opt .= '=INT' + else + let opt .= '=INT or maybe BOOL' + endif + elseif type(default) == 1 + let opt .= '=STRING' + elseif type(default) == 3 + let opt .= '=COMMA-LIST' + endif + echom printf(' --%20s (default: %s)', opt, string(default)) + endfor + endif + if !empty(flags) + echom 'Short flags:' + for [sflag, lflag] in sort(items(flags)) + echom printf(' -%s -> %s', sflag, lflag) + endfor + endif + endif + endif + let break = 2 + elseif long && a:opt =~# '^--\%(no-\)\?debug$' + if has_key(a:def, 'trace') + let mod = a:opt =~# '--no-' ? '-' : '+' + exec 'Tlibtraceset' mod . a:def.trace + endif + elseif long && a:opt =~# '^--no-.\+' + let key = matchstr(a:opt, '^--no-\zs.\+$') + let a:opts[key] = s:Validate(a:def, key, 0) + elseif long && a:opt =~# '^--\w\+$' + let key = matchstr(a:opt, '^--\zs.\+$') + let a:opts[key] = s:Validate(a:def, key, 1) + elseif long && a:opt =~# '^--\w\+=' + let ml = matchlist(a:opt, '^--\(\w\+\)=\(.*\)$') + if empty(ml) + throw 'tlib#arg#GetOpts: Cannot parse: '. a:opt + else + let values = get(a:def, 'values', {}) + if has_key(values, ml[1]) + let vdef = values[ml[1]] + let type = s:GetValueType(vdef) + if type == -1 + let opt_value = !!str2nr(ml[2]) + elseif type == 0 + let opt_value = str2nr(ml[2]) + elseif type == 1 + let opt_value = ml[2] + elseif type == 2 + let opt_value = function(ml[2]) + elseif type == 3 + let opt_value = tlib#string#SplitCommaList(ml[2]) + elseif type == 4 + throw 'tlib#arg#GetOpts: Unsupported type conversion for '. ml[1] + elseif type == 5 + let opt_value = str2float(ml[2]) + endif + else + let opt_value = ml[2] + endif + let a:opts[ml[1]] = s:Validate(a:def, ml[1], opt_value) + unlet opt_value + endif + elseif short && a:opt =~# '^-\w=' + let flagdefs = get(a:def, 'flags', {}) + let flag = matchstr(a:opt, '^-\zs\w') + let rest = matchstr(a:opt, '^-\w\zs.*$') + call s:SetFlag(a:def, a:opts, idx, flag, rest, flagdefs) + elseif short && a:opt =~# '^-\w\+$' + let flagdefs = get(a:def, 'flags', {}) + for flag in split(substitute(a:opt, '^-', '', ''), '\zs') + call s:SetFlag(a:def, a:opts, idx, flag, '', flagdefs) + endfor + else + let break = 1 + if a:opt !=# '--' + let idx -= 1 + endif + endif + return [break, idx] +endf + + +function! s:SetFlag(def, opts, idx, flag, rest, flagdefs) abort "{{{3 + " TLogVAR a:def + if has_key(a:flagdefs, a:flag) + call s:SetOpt(a:def, a:opts, a:idx, a:flagdefs[a:flag] . a:rest) + else + let a:opts[a:flag] = s:Validate(a:def, a:flag, 1) + endif +endf + + +function! s:Validate(def, name, value) abort "{{{3 + let values = get(a:def, 'values', {}) + if has_key(values, a:name) + let vdef = values[a:name] + if has_key(vdef, 'validate') + if !call(vdef.validate, [a:value]) + throw printf('tlib#arg: %s has invalid value: %s', string(a:name), string(a:value)) + endif + endif + endif + return a:value +endf + + +":nodoc: +function! tlib#arg#CComplete(def, ArgLead) abort "{{{3 + let values = get(a:def, 'values', {}) + let opt = matchstr(a:ArgLead, '^--\zs\w\+\ze=') + if has_key(values, opt) + let words = [] + let vals = values[opt] + let complete_customlist = get(vals, 'complete_customlist', '') + if !empty(complete_customlist) + let words = eval(complete_customlist) + " else + " let complete = get(vals, 'complete', '') + " if !empty(complete) + " endif + endif + if !empty(words) + let prefix = matchstr(a:ArgLead, '^--\w\+=\%([^,]\+,\s*\)*') + let lead = substitute(a:ArgLead, '^--\w\+=\%([^,]\+,\s*\)*', '', '') + " TLogVAR a:ArgLead, lead + if !empty(lead) + let nchar = len(lead) + call filter(words, 'tlib#string#Strcharpart(v:val, 0, nchar) ==# lead') + endif + let words = map(words, 'prefix . v:val') + return sort(words) + endif + endif + let cs = {'-h': 1, '--help': 1} + for [name, vdef] in items(values) + let type = s:GetValueType(vdef) + if type >= 0 + let name .= '=' + else + let cs['--no-'. name] = 1 + endif + let cs['--'. name] = 1 + endfor + for [name, subst] in items(get(a:def, 'flags', {})) + let ldef = get(values, substitute(subst, '^--', '', ''), {}) + let type = s:GetValueType(ldef) + if type >= 0 + let name .= '=' + endif + let cs['-'. name] = 1 + endfor + if has_key(a:def, 'trace') + let cs['--debug'] = 1 + endif + let nchar = len(a:ArgLead) + if nchar > 0 + call filter(cs, 'tlib#string#Strcharpart(v:key, 0, nchar) ==# a:ArgLead') + endif + return sort(keys(cs)) +endf + + + +""" Command line {{{1 + +" :def: function! tlib#arg#Ex(arg, ?chars='%#! ') +" Escape some characters in a string. +" +" Use |fnamescape()| if available. +" +" EXAMPLES: > +" exec 'edit '. tlib#arg#Ex('foo%#bar.txt') +function! tlib#arg#Ex(arg, ...) "{{{3 + if exists('*fnameescape') && a:0 == 0 + return fnameescape(a:arg) + else + " let chars = '%# \' + let chars = '%#! ' + if a:0 >= 1 + let chars .= a:1 + endif + return escape(a:arg, chars) + endif +endf + + diff --git a/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/assert.vim b/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/assert.vim new file mode 100644 index 0000000..3d58f59 --- /dev/null +++ b/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/assert.vim @@ -0,0 +1,44 @@ +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @Website: https://github.com/tomtom +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Last Change: 2017-02-22 +" @Revision: 42 + + +" Enable tracing via |:Tlibassert|. +function! tlib#assert#Enable() abort "{{{3 + " :nodoc: + command! -nargs=+ -bang Tlibassert call tlib#assert#Assert(expand(''), , []) +endf + + +" Disable tracing via |:Tlibassert|. +function! tlib#assert#Disable() abort "{{{3 + " :nodoc: + command! -nargs=+ -bang Tlibassert : +endf + + +function! tlib#assert#Assert(caller, check, vals) abort "{{{3 + for val in a:vals + " TLogVAR val + if type(val) == 3 + call tlib#assert#Assert(a:caller, a:check, val) + elseif !val + throw 'Tlibassert: '. tlib#trace#Backtrace(a:caller) .': '. a:check + endif + endfor +endf + + +function! tlib#assert#Map(vals, expr) abort "{{{3 + return tlib#assert#All(map(a:vals, a:expr)) +endf + + +function! tlib#assert#All(vals) abort "{{{3 + " TLogVAR a:vals, empty(filter(a:vals, '!v:val')) + return empty(filter(a:vals, '!v:val')) +endf + + diff --git a/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/autocmdgroup.vim b/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/autocmdgroup.vim new file mode 100644 index 0000000..8439524 --- /dev/null +++ b/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/autocmdgroup.vim @@ -0,0 +1,14 @@ +" autocmdgroup.vim +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Revision: 7 + +augroup TLib + autocmd! +augroup END + + +function! tlib#autocmdgroup#Init() "{{{3 +endf + diff --git a/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/balloon.vim b/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/balloon.vim new file mode 100644 index 0000000..6967523 --- /dev/null +++ b/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/balloon.vim @@ -0,0 +1,73 @@ +" @Author: Tom Link (micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @GIT: http://github.com/tomtom/tlib_vim/ +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2010-08-30. +" @Last Change: 2015-11-23. +" @Revision: 48 + + +function! tlib#balloon#Register(expr) "{{{3 + if !has('balloon_eval') + return + endif + if !exists('b:tlib_balloons') + let b:tlib_balloons = [] + endif + if !&ballooneval + setlocal ballooneval + endif + if &balloonexpr != 'tlib#balloon#Expr()' + if !empty(&balloonexpr) + call add(b:tlib_balloons, &balloonexpr) + endif + setlocal ballooneval balloonexpr=tlib#balloon#Expr() + endif + if index(b:tlib_balloons, a:expr) == -1 + call add(b:tlib_balloons, a:expr) + endif +endf + + +function! tlib#balloon#Remove(expr) "{{{3 + if exists('b:tlib_balloons') + call filter(b:tlib_balloons, 'v:val != a:expr') + if empty(b:tlib_balloons) + setlocal ballooneval& + setlocal balloonexpr& + unlet b:tlib_balloons + endif + endif +endf + + +function! tlib#balloon#Expr() "{{{3 + " TLogVAR exists('b:tlib_balloons') + if !exists('b:tlib_balloons') + return '' + endif + let text = map(copy(b:tlib_balloons), 'eval(v:val)') + " TLogVAR b:tlib_balloons, text + call filter(text, '!empty(v:val)') + if has('balloon_multiline') + return join(text, "\n----------------------------------\n") + else + return get(text, 0, '') + endif +endf + + +function! tlib#balloon#Expand(expr) abort "{{{3 + if v:beval_bufnr != bufnr('%') + " TLogVAR v:beval_bufnr, bufnr('%') + return '' + endif + let win = winsaveview() + try + call setpos('.', [v:beval_bufnr, v:beval_lnum, v:beval_col, 0]) + return expand(a:expr) + finally + call winrestview(win) + endtry +endf + diff --git a/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/bitwise.vim b/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/bitwise.vim new file mode 100644 index 0000000..54a4258 --- /dev/null +++ b/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/bitwise.vim @@ -0,0 +1,141 @@ +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Revision: 124 + + +function! tlib#bitwise#Num2Bits(num) "{{{3 + if type(a:num) <= 1 || type(a:num) == 5 + let bits = reverse(tlib#number#ConvertBase(a:num, 2, 'list')) + elseif type(a:num) == 3 + let bits = copy(a:num) + else + throw "tlib#bitwise#Num2Bits: Must be number of list: ". string(a:num) + endif + return bits +endf + + +function! tlib#bitwise#Bits2Num(bits, ...) "{{{3 + let base = a:0 >= 1 ? a:1 : 10 + " TLogVAR a:bits + let num = 0.0 + for i in range(len(a:bits)) + if get(a:bits, i, 0) + let num += pow(2, i) + endif + endfor + " TLogVAR num + if base == 10 + if type(base) == 5 + return num + else + return float2nr(num) + endif + else + return tlib#number#ConvertBase(num, base) + endif +endf + + +function! tlib#bitwise#AND(num1, num2, ...) "{{{3 + let rtype = a:0 >= 1 ? a:1 : 'num' + return s:BitwiseComparison(a:num1, a:num2, rtype, + \ 'get(bits1, v:val) && get(bits2, v:val)') +endf + + +function! tlib#bitwise#OR(num1, num2, ...) "{{{3 + let rtype = a:0 >= 1 ? a:1 : 'num' + return s:BitwiseComparison(a:num1, a:num2, rtype, + \ 'get(bits1, v:val) || get(bits2, v:val)') +endf + + +function! tlib#bitwise#XOR(num1, num2, ...) "{{{3 + let rtype = a:0 >= 1 ? a:1 : 'num' + return s:BitwiseComparison(a:num1, a:num2, rtype, + \ 'get(bits1, v:val) ? !get(bits2, v:val) : get(bits2, v:val)') +endf + + +function! s:BitwiseComparison(num1, num2, rtype, expr) "{{{3 + let bits1 = tlib#bitwise#Num2Bits(a:num1) + let bits2 = tlib#bitwise#Num2Bits(a:num2) + let range = range(max([len(bits1), len(bits2)])) + let bits = map(range, a:expr) + if a:rtype == 'num' || (a:rtype == 'auto' && type(a:num1) <= 1) + return tlib#bitwise#Bits2Num(bits) + else + return bits + endif +endf + + +function! tlib#bitwise#ShiftRight(bits, n) "{{{3 + let bits = a:bits[a:n : -1] + if empty(bits) + let bits = [0] + endif + return bits +endf + + +function! tlib#bitwise#ShiftLeft(bits, n) "{{{3 + let bits = repeat([0], a:n) + a:bits + return bits +endf + + +function! tlib#bitwise#Add(num1, num2, ...) "{{{3 + let rtype = a:0 >= 1 ? a:1 : 'num' + let bits1 = tlib#bitwise#Num2Bits(a:num1) + let bits2 = tlib#bitwise#Num2Bits(a:num2) + let range = range(max([len(bits1), len(bits2)])) + " TLogVAR bits1, bits2, range + let carry = 0 + let bits = [] + for i in range + let sum = get(bits1, i) + get(bits2, i) + carry + if sum == 3 + let bit = 1 + let carry = 1 + elseif sum == 2 + let bit = 0 + let carry = 1 + elseif sum == 1 + let bit = 1 + let carry = 0 + elseif sum == 0 + let bit = 0 + let carry = 0 + endif + call add(bits, bit) + " TLogVAR i, bits, bit + endfor + if carry == 1 + call add(bits, carry) + endif + if rtype == 'num' || (rtype == 'auto' && type(a:num1) <= 1) + return tlib#bitwise#Bits2Num(bits) + else + return bits + endif +endf + + +function! tlib#bitwise#Sub(num1, num2, ...) "{{{3 + let rtype = a:0 >= 1 ? a:1 : 'num' + let bits1 = tlib#bitwise#Num2Bits(a:num1) + let bits2 = tlib#bitwise#Num2Bits(a:num2) + let range = range(max([len(bits1), len(bits2)])) + let bits2 = map(range, '!get(bits2, v:val)') + let bits2 = tlib#bitwise#Add(bits2, [1], 'bits') + let bits3 = tlib#bitwise#Add(bits1, bits2, 'bits') + let bits = bits3[0 : -2] + if rtype == 'num' || (rtype == 'auto' && type(a:num1) <= 1) + return tlib#bitwise#Bits2Num(bits) + else + return bits + endif +endf + diff --git a/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/buffer.vim b/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/buffer.vim new file mode 100644 index 0000000..1cbcdb7 --- /dev/null +++ b/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/buffer.vim @@ -0,0 +1,401 @@ +" buffer.vim +" @Author: Tom Link (micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2007-06-30. +" @Last Change: 2017-09-28. +" @Revision: 12.1.352 + + +" Where to display the line when using |tlib#buffer#ViewLine|. +" For possible values for position see |scroll-cursor|. +TLet g:tlib_viewline_position = 'zz' + + +let s:bmru = [] + + +function! tlib#buffer#EnableMRU() abort "{{{3 + call tlib#autocmdgroup#Init() + autocmd TLib BufEnter * call s:BMRU_Push(bufnr('%')) +endf + + +function! tlib#buffer#DisableMRU() abort "{{{3 + call tlib#autocmdgroup#Init() + autocmd! TLib BufEnter +endf + + +function! s:BMRU_Push(bnr) abort "{{{3 + let i = index(s:bmru, a:bnr) + if i >= 0 + call remove(s:bmru, i) + endif + call insert(s:bmru, a:bnr) +endf + + +function! s:CompareBuffernameByBasename(a, b) abort "{{{3 + let rx = '"\zs.\{-}\ze" \+\S\+ \+\d\+$' + let an = matchstr(a:a, rx) + let an = fnamemodify(an, ':t') + let bn = matchstr(a:b, rx) + let bn = fnamemodify(bn, ':t') + let rv = an == bn ? 0 : an > bn ? 1 : -1 + return rv +endf + + +function! s:CompareBufferNrByMRU(a, b) abort "{{{3 + let an = matchstr(a:a, '\s*\zs\d\+\ze') + let bn = matchstr(a:b, '\s*\zs\d\+\ze') + let ai = index(s:bmru, 0 + an) + if ai == -1 + return 1 + else + let bi = index(s:bmru, 0 + bn) + if bi == -1 + return -1 + else + return ai == bi ? 0 : ai > bi ? 1 : -1 + endif + endif +endf + + +" Set the buffer to buffer and return a command as string that can be +" evaluated by |:execute| in order to restore the original view. +function! tlib#buffer#Set(buffer) abort "{{{3 + let lazyredraw = &lazyredraw + set lazyredraw + try + let cb = bufnr('%') + let sn = bufnr(a:buffer) + if sn != cb + let ws = bufwinnr(sn) + if ws != -1 + let wb = bufwinnr('%') + exec ws.'wincmd w' + return wb.'wincmd w' + else + silent exec 'sbuffer! '. sn + return 'wincmd c' + endif + else + return '' + endif + finally + let &lazyredraw = lazyredraw + endtry +endf + + +" :def: function! tlib#buffer#Eval(buffer, code) abort +" Evaluate CODE in BUFFER. +" +" EXAMPLES: > +" call tlib#buffer#Eval('foo.txt', 'echo b:bar') +function! tlib#buffer#Eval(buffer, code) abort "{{{3 + " let cb = bufnr('%') + " let wb = bufwinnr('%') + " " TLogVAR cb + " let sn = bufnr(a:buffer) + " let sb = sn != cb + let lazyredraw = &lazyredraw + set lazyredraw + let restore = tlib#buffer#Set(a:buffer) + try + exec a:code + " if sb + " let ws = bufwinnr(sn) + " if ws != -1 + " try + " exec ws.'wincmd w' + " exec a:code + " finally + " exec wb.'wincmd w' + " endtry + " else + " try + " silent exec 'sbuffer! '. sn + " exec a:code + " finally + " wincmd c + " endtry + " endif + " else + " exec a:code + " endif + finally + exec restore + let &lazyredraw = lazyredraw + endtry +endf + + +" :def: function! tlib#buffer#GetList(?show_hidden=0, ?show_number=0, " ?order='bufnr') abort +" Possible values for the "order" argument: +" bufnr :: Default behaviour +" mru :: Sort buffers according to most recent use +" basename :: Sort by the file's basename (last component) +" +" NOTE: MRU order works on second invocation only. If you want to always +" use MRU order, call tlib#buffer#EnableMRU() in your ~/.vimrc file. +function! tlib#buffer#GetList(...) abort + TVarArg ['show_hidden', 0], ['show_number', 0], ['order', ''] + " TLogVAR show_hidden, show_number, order + let ls_bang = show_hidden ? '!' : '' + redir => bfs + exec 'silent ls'. ls_bang + redir END + let buffer_list = split(bfs, '\n') + if order ==# 'mru' + if empty(s:bmru) + call tlib#buffer#EnableMRU() + echom 'tlib: Installed Buffer MRU logger; disable with: call tlib#buffer#DisableMRU()' + else + call sort(buffer_list, function('s:CompareBufferNrByMRU')) + endif + elseif order ==# 'basename' + call sort(buffer_list, function('s:CompareBuffernameByBasename')) + endif + let buffer_nr = map(copy(buffer_list), 'str2nr(matchstr(v:val, ''\s*\zs\d\+\ze''))') + " TLogVAR buffer_list, buffer_nr + if show_number + call map(buffer_list, 'matchstr(v:val, ''^\s*\d\+.\{-}\ze\s\+\S\+ \d\+\s*$'')') + else + call map(buffer_list, 'matchstr(v:val, ''^\s*\d\+\zs.\{-}\ze\s\+\S\+ \d\+\s*$'')') + endif + " TLogVAR buffer_list + " call map(buffer_list, 'matchstr(v:val, ''^.\{-}\ze\s\+line \d\+\s*$'')') + " TLogVAR buffer_list + call map(buffer_list, 'matchstr(v:val, ''^[^"]\+''). printf("%-20s %s", fnamemodify(matchstr(v:val, ''"\zs.\{-}\ze"$''), ":t"), fnamemodify(matchstr(v:val, ''"\zs.\{-}\ze"$''), ":h"))') + " TLogVAR buffer_list + return [buffer_nr, buffer_list] +endf + + +" :def: function! tlib#buffer#ViewLine(line, ?position='z') abort +" line is either a number or a string that begins with a number. +" For possible values for position see |scroll-cursor|. +" See also |g:tlib_viewline_position|. +function! tlib#buffer#ViewLine(line, ...) abort "{{{3 + if a:line + TVarArg 'pos' + let ln = matchstr(a:line, '^\d\+') + let lt = matchstr(a:line, '^\d\+: \zs.*') + " TLogVAR pos, ln, lt + exec ln + if empty(pos) + let pos = tlib#var#Get('tlib_viewline_position', 'wbg') + endif + " TLogVAR pos + if !empty(pos) + exec 'norm! '. pos + endif + call tlib#buffer#HighlightLine(ln) + " let @/ = '\%'. ln .'l.*' + endif +endf + + +function! s:UndoHighlightLine() abort "{{{3 + 2match none + autocmd! TLib CursorMoved,CursorMovedI + autocmd! TLib CursorHold,CursorHoldI + autocmd! TLib InsertEnter,InsertChange,InsertLeave + autocmd! TLib BufLeave,BufWinLeave,WinLeave,BufHidden +endf + + +function! tlib#buffer#HighlightLine(...) abort "{{{3 + TVarArg ['line', line('.')] + " exec '2match MatchParen /^\%'. a:line .'l.*/' + exec '2match Search /^\%'. line .'l.*/' + call tlib#autocmdgroup#Init() + exec 'autocmd TLib CursorMoved,CursorMovedI if line(".") != '. line .' | call s:UndoHighlightLine() | endif' + autocmd TLib CursorHold,CursorHoldI call s:UndoHighlightLine() + autocmd TLib InsertEnter call s:UndoHighlightLine() + " autocmd TLib BufLeave,BufWinLeave,WinLeave,BufHidden call s:UndoHighlightLine() +endf + + +" Delete the lines in the current buffer. Wrapper for |:delete|. +function! tlib#buffer#DeleteRange(line1, line2) abort "{{{3 + let r = @t + try + exec a:line1.','.a:line2.'delete t' + finally + let @t = r + endtry +endf + + +" Replace a range of lines. +function! tlib#buffer#ReplaceRange(line1, line2, lines) abort + call tlib#buffer#DeleteRange(a:line1, a:line2) + call append(a:line1 - 1, a:lines) +endf + + +" Initialize some scratch area at the bottom of the current buffer. +function! tlib#buffer#ScratchStart() abort "{{{3 + norm! Go + let b:tlib_inbuffer_scratch = line('$') + return b:tlib_inbuffer_scratch +endf + + +" Remove the in-buffer scratch area. +function! tlib#buffer#ScratchEnd() abort "{{{3 + if !exists('b:tlib_inbuffer_scratch') + echoerr 'tlib: In-buffer scratch not initalized' + endif + call tlib#buffer#DeleteRange(b:tlib_inbuffer_scratch, line('$')) + unlet b:tlib_inbuffer_scratch +endf + + +" Run exec on all buffers via bufdo and return to the original buffer. +function! tlib#buffer#BufDo(exec) abort "{{{3 + let bn = bufnr('%') + exec 'bufdo '. a:exec + exec 'buffer! '. bn +endf + + +" :def: function! tlib#buffer#InsertText(text, keyargs) abort +" Keyargs: +" 'shift': 0|N +" 'col': col('.')|N +" 'lineno': line('.')|N +" 'indent': 0|1 +" 'pos': 'e'|'s' ... Where to locate the cursor (somewhat like s and e in {offset}) +" Insert text (a string) in the buffer. +function! tlib#buffer#InsertText(text, ...) abort "{{{3 + TVarArg ['keyargs', {}] + " TLogVAR a:text, keyargs + let keyargs = extend({ + \ 'shift': 0, 'col': col('.'), 'lineno': line('.'), 'pos': 'e', 'indent': 0 + \ }, keyargs) + " TLogVAR keyargs + let grow = 0 + let post_del_last_line = line('$') == 1 + let line = getline(keyargs.lineno) + if keyargs.col + keyargs.shift > 0 + let pre = line[0 : (keyargs.col - 1 + keyargs.shift)] + let post = line[(keyargs.col + keyargs.shift): -1] + else + let pre = '' + let post = line + endif + " TLogVAR keyargs.lineno, line, pre, post + let text0 = pre . a:text . post + let text = split(text0, '\n', 1) + " TLogVAR text + let icol = len(pre) + " exec 'norm! '. keyargs.lineno .'G' + call cursor(keyargs.lineno, keyargs.col) + if keyargs.indent && keyargs.col > 1 + if &formatoptions =~# '[or]' + " FIXME: Is the simple version sufficient? + " VERSION 1 + " " This doesn't work because it's not guaranteed that the + " " cursor is set. + " let cline = getline('.') + " norm! a + " "norm! o + " " TAssertExec redraw | sleep 3 + " let idt = tlib#string#Strcharpart(getline('.'), 0, keyargs.col('.') + keyargs.shift) + " " TLogVAR idt + " let idtl = len(idt) + " -1,.delete + " " TAssertExec redraw | sleep 3 + " call append(keyargs.lineno - 1, cline) + " call cursor(keyargs.lineno, keyargs.col) + " " TAssertExec redraw | sleep 3 + " if idtl == 0 && icol != 0 + " let idt = matchstr(pre, '^\s\+') + " let idtl = len(idt) + " endif + " VERSION 2 + let idt = matchstr(pre, '^\s\+') + let idtl = len(idt) + else + let [m_0, idt, iline; rest] = matchlist(pre, '^\(\s*\)\(.*\)$') + let idtl = len(idt) + endif + if idtl < icol + let idt .= repeat(' ', icol - idtl) + endif + " TLogVAR idt + let idtl1 = len(idt) + for i in range(1, len(text) - 1) + let text[i] = idt . text[i] + let grow += idtl1 + endfor + endif + " TLogVAR text + " exec 'norm! '. keyargs.lineno .'Gdd' + call tlib#normal#WithRegister('"tdd', 't') + call append(keyargs.lineno - 1, text) + if post_del_last_line + call tlib#buffer#KeepCursorPosition('$delete') + endif + let tlen = len(text) + let posshift = matchstr(keyargs.pos, '\d\+') + " TLogVAR keyargs.pos + if keyargs.pos =~# '^e' + exec keyargs.lineno + tlen - 1 + exec 'norm! 0'. (len(text[-1]) - len(post) + posshift - 1) .'l' + elseif keyargs.pos =~# '^s' + " TLogVAR keyargs.lineno, pre, posshift + exec keyargs.lineno + exec 'norm! '. len(pre) .'|' + if !empty(posshift) + exec 'norm! '. posshift .'h' + endif + endif + " TLogDBG getline(keyargs.lineno) + " TLogDBG string(getline(1, '$')) + return grow +endf + + +function! tlib#buffer#InsertText0(text, ...) abort "{{{3 + TVarArg ['keyargs', {}] + let mode = get(keyargs, 'mode', 'i') + " TLogVAR mode + if !has_key(keyargs, 'shift') + let col = col('.') + " if mode =~ 'i' + " let col += 1 + " endif + let keyargs.shift = col >= col('$') ? 0 : -1 + " let keyargs.shift = col('.') >= col('$') ? 0 : -1 + " TLogVAR col + " TLogDBG col('.') .'-'. col('$') .': '. string(getline('.')) + endif + " TLogVAR keyargs.shift + return tlib#buffer#InsertText(a:text, keyargs) +endf + + +function! tlib#buffer#CurrentByte() abort "{{{3 + return line2byte(line('.')) + col('.') +endf + + +" Evaluate cmd while maintaining the cursor position and jump registers. +function! tlib#buffer#KeepCursorPosition(cmd) abort "{{{3 + " let pos = getpos('.') + let view = winsaveview() + try + keepjumps exec a:cmd + finally + " call setpos('.', pos) + call winrestview(view) + endtry +endf + diff --git a/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/cache.vim b/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/cache.vim new file mode 100644 index 0000000..5363ebd --- /dev/null +++ b/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/cache.vim @@ -0,0 +1,464 @@ +" cache.vim +" @Author: Tom Link (micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2007-06-30. +" @Last Change: 2019-01-02. +" @Revision: 125.1.243 + + +" The cache directory. If empty, use |tlib#dir#MyRuntime|.'/cache'. +" You might want to delete old files from this directory from time to +" time with a command like: > +" find ~/vimfiles/cache/ -atime +31 -type f -print -delete +TLet g:tlib_cache = '' + +" |tlib#cache#Purge()|: Remove cache files older than N days. +TLet g:tlib#cache#purge_days = 31 + +" Purge the cache every N days. Disable automatic purging by setting +" this value to a negative value. +TLet g:tlib#cache#purge_every_days = 31 + +" The encoding used for the purge-cache script. +" Default: 'enc' +TLet g:tlib#cache#script_encoding = &enc + +" Whether to run the directory removal script: +" 0 ... No +" 1 ... Query user +" 2 ... Yes +TLet g:tlib#cache#run_script = 1 + +" Verbosity level: +" 0 ... Be quiet +" 1 ... Display informative message +" 2 ... Display detailed messages +TLet g:tlib#cache#verbosity = 1 + +" A list of regexps that are matched against partial filenames of the +" cached files. If a regexp matches, the file won't be removed by +" |tlib#cache#Purge()|. +TLet g:tlib#cache#dont_purge = ['[\/]\.last_purge$'] + +" If the cache filename is longer than N characters, use +" |pathshorten()|. +TLet g:tlib#cache#max_filename = 200 + +TLet g:tlib#cache#use_json = 0 + +TLet g:tlib#cache#use_encoding = '' + + +let s:cache = {} + + +" :display: tlib#cache#Dir(?mode = 'bg', ?ensure_dir = true) +" The default cache directory. +function! tlib#cache#Dir(...) "{{{3 + TVarArg ['mode', 'bg'], ['ensure_dir', 1] + let dir = tlib#var#Get('tlib_cache', mode) + if empty(dir) + let dir = tlib#file#Join([tlib#dir#MyRuntime(), 'cache']) + endif + if ensure_dir + call tlib#dir#Ensure(dir) + endif + return dir +endf + + +" :display: tlib#cache#EncodedFilename(type, file, ?mkdir=0, ?dir='') +" Encode `file` and call |tlib#cache#Filename()|. +function! tlib#cache#EncodedFilename(type, file, ...) "{{{3 + let file = tlib#url#Encode(a:file) + return call(function('tlib#cache#Filename'), [a:type, file] + a:000) +endf + + +" :def: function! tlib#cache#Filename(type, ?file=%, ?mkdir=0, ?dir='') +function! tlib#cache#Filename(type, ...) "{{{3 + " TLogDBG 'bufname='. bufname('.') + let dir0 = a:0 >= 3 && !empty(a:3) ? a:3 : tlib#cache#Dir() + let dir = dir0 + if a:0 >= 1 && !empty(a:1) + let file = a:1 + else + if empty(expand('%:t')) + return '' + endif + let file = expand('%:p') + let file = tlib#file#Relative(file, tlib#file#Join([dir, '..'])) + endif + " TLogVAR file, dir + let mkdir = a:0 >= 2 ? a:2 : 0 + let file = substitute(file, '\.\.\|[:&<>]\|//\+\|\\\\\+', '_', 'g') + let dirs = [dir, a:type] + let dirf = fnamemodify(file, ':h') + if dirf != '.' + call add(dirs, dirf) + endif + let dir = tlib#file#Join(dirs) + " TLogVAR dir + let dir = tlib#dir#PlainName(dir) + " TLogVAR dir + let file = fnamemodify(file, ':t') + " TLogVAR file, dir, mkdir + let cache_file = tlib#file#Join([dir, file]) + if len(cache_file) > g:tlib#cache#max_filename + " echom "DBG long filename" cache_file + " echom "DBG long filename" dir + if v:version >= 704 + let shortfilename = sha256(file) + else + let shortfilename = tlib#hash#Adler32(file) + endif + " let cache_file = tlib#cache#Filename(a:type, shortfilename, mkdir, dir0) + let cache_file = tlib#file#Join([dir, shortfilename]) + else + if mkdir && !isdirectory(dir) + try + call mkdir(dir, 'p') + catch /^Vim\%((\a\+)\)\=:E739:/ + if filereadable(dir) && !isdirectory(dir) + echoerr 'TLib: Cannot create directory for cache file because a file with the same name exists (please delete it):' dir + " call delete(dir) + " call mkdir(dir, 'p') + endif + endtry + endif + endif + " TLogVAR cache_file + return cache_file +endf + + +let s:timestamps = {} + + +function! s:SetTimestamp(cfile, type) "{{{3 + if !has_key(s:timestamps, a:cfile) + let s:timestamps[a:cfile] = {} + endif + let s:timestamps[a:cfile].atime = getftime(a:cfile) + let s:timestamps[a:cfile][a:type] = s:timestamps[a:cfile].atime +endf + + +function! s:PutValue(cfile, value) abort "{{{3 + let s:cache[a:cfile] = {'mtime': localtime(), 'data': a:value} +endf + + +function! s:GetValue(cfile, default) abort "{{{3 + return get(get(s:cache, a:cfile, {}), 'data', a:default) +endf + + +function! s:GetCacheTime(cfile) abort "{{{3 + let not_found = !has_key(s:cache, a:cfile) + let cftime = not_found ? -1 : s:cache[a:cfile].mtime + return cftime +endf + + +function! tlib#cache#Save(cfile, value, ...) "{{{3 + TVarArg ['options', {}] + let in_memory = get(options, 'in_memory', 0) + if in_memory + " TLogVAR in_memory, a:cfile, localtime() + call s:PutValue(a:cfile, a:value) + elseif !empty(a:cfile) + " TLogVAR a:value + let cfile = a:cfile + if g:tlib#cache#use_json && exists('*json_encode') + try + let value = json_encode(a:value) + let cfile .= '.json' + catch + echoerr v:exception + let value = string(a:value) + endtry + else + let value = string(a:value) + endif + Tlibtrace 'tlib', cfile, value + call writefile([value], cfile, 'b') + call s:SetTimestamp(a:cfile, 'write') + endif +endf + + +function! tlib#cache#MTime(cfile) "{{{3 + let mtime = {'mtime': getftime(a:cfile)} + let mtime = extend(mtime, get(s:timestamps, a:cfile, {})) + return mtime +endf + + +function! tlib#cache#Get(cfile, ...) "{{{3 + TVarArg ['default', {}], ['options', {}] + let in_memory = get(options, 'in_memory', 0) + if in_memory + " TLogVAR in_memory, a:cfile + return s:GetValue(a:cfile, default) + else + call tlib#cache#MaybePurge() + if !empty(a:cfile) + let jsonfile = a:cfile .'.json' + let use_json = g:tlib#cache#use_json && exists('*json_decode') && exists('v:none') && filereadable(jsonfile) + if use_json + let use_json = 1 + let cfile = jsonfile + else + let cfile = a:cfile + endif + let mt = s:GetCacheTime(cfile) + let ft = getftime(cfile) + if mt != -1 && mt >= ft + return s:GetValue(cfile, default) + elseif ft != -1 + call s:SetTimestamp(cfile, 'read') + let val = join(readfile(cfile, 'b'), '\n') + try + if use_json + " NOTE: Copy result of json_decode() in order to + " avoid "E741: value is locked" error in vim8. + let value = json_decode(val) + if value is v:none + let value = default + else + let value = copy(value) + endif + else + let value = eval(val) + endif + call s:PutValue(cfile, value) + return value + catch + echohl ErrorMsg + echom v:exception + echom 'tlib#cache#Get: Invalid value in:' cfile + echom 'Value:' string(val) + echom 'Please review the file and delete it if necessary' + echom 'Will use default value:' string(default) + echohl NONE + if g:tlib#debug + let @* = string(val) + endif + " call s:PutValue(cfile, default) + return default + endtry + endif + endif + return default + endif +endf + + +" :display: tlib#cache#Value(cfile, generator, ftime, ?generator_args=[], ?options={}) +" Get a cached value from cfile. If it is outdated (compared to ftime) +" or does not exist, create it calling a generator function. +function! tlib#cache#Value(cfile, generator, ftime, ...) "{{{3 + TVarArg ['args', []], ['options', {}] + let in_memory = get(options, 'in_memory', 0) + if in_memory + let cftime = s:GetCacheTime(a:cfile) + else + let cftime = getftime(a:cfile) + endif + let ftime = a:ftime + " TLogVAR in_memory, cftime + if cftime == -1 || ftime == -1 || (ftime != 0 && cftime < ftime) + " TLogVAR a:generator, args + let val = call(a:generator, args) + " TLogVAR val + let cval = {'val': val} + " TLogVAR cval + call tlib#cache#Save(a:cfile, cval, options) + return val + else + let val = tlib#cache#Get(a:cfile, {}, options) + if !has_key(val, 'val') + throw 'tlib#cache#Value: Internal error: '. a:cfile + else + return val.val + endif + endif +endf + + +function! tlib#cache#ValueFromName(type, name, ...) abort "{{{3 + let cfile = tlib#cache#Filename(a:type, tlib#url#Encode(a:name), 1) + return call(function('tlib#cache#Value'), [cfile] + a:000) +endf + + +" Call |tlib#cache#Purge()| if the last purge was done before +" |g:tlib#cache#purge_every_days|. +function! tlib#cache#MaybePurge() "{{{3 + if g:tlib#cache#purge_every_days < 0 + return + endif + let dir = tlib#cache#Dir('g') + let last_purge = tlib#file#Join([dir, '.last_purge']) + let last_purge_exists = filereadable(last_purge) + if last_purge_exists + let threshold = localtime() - g:tlib#cache#purge_every_days * g:tlib#date#dayshift + let should_purge = getftime(last_purge) < threshold + else + let should_purge = 0 " should ignore empty dirs, like the tmru one: !empty(glob(tlib#file#Join([dir, '**']))) + endif + if should_purge + if last_purge_exists + let yn = 'y' + else + let txt = "TLib: The cache directory '". dir ."' should be purged of old files.\nDelete files older than ". g:tlib#cache#purge_days ." days now?" + let yn = tlib#input#Dialog(txt, ['yes', 'no'], 'no') + endif + if yn =~ '^y\%[es]$' + call tlib#cache#Purge() + else + let g:tlib#cache#purge_every_days = -1 + if !last_purge_exists + call s:PurgeTimestamp(dir) + endif + echohl WarningMsg + echom "TLib: Please run :call tlib#cache#Purge() to clean up ". dir + echohl NONE + endif + elseif !last_purge_exists + call s:PurgeTimestamp(dir) + endif +endf + + +" Delete old files. +function! tlib#cache#Purge() "{{{3 + let threshold = localtime() - g:tlib#cache#purge_days * g:tlib#date#dayshift + let dir = tlib#cache#Dir('g') + if g:tlib#cache#verbosity >= 1 + echohl WarningMsg + echom "TLib: Delete files older than ". g:tlib#cache#purge_days ." days from ". dir + echohl NONE + endif + let files = tlib#cache#ListFilesInCache() + let deldir = [] + let newer = [] + let msg = [] + let more = &more + set nomore + try + for file in files + if isdirectory(file) + if empty(filter(copy(newer), 'tlib#string#Strcharpart(v:val, 0, len(file)) ==# file')) + call add(deldir, file) + endif + else + if getftime(file) < threshold + call s:Delete(msg, file, '') + else + call add(newer, file) + endif + endif + endfor + finally + let &more = more + endtry + if !empty(msg) && g:tlib#cache#verbosity >= 1 + echo join(msg, "\n") + endif + if !empty(deldir) + let deldir = filter(reverse(sort(deldir)), 's:Delete(msg, v:val, "d")') + if !empty(deldir) + if &shell =~ 'sh\(\.exe\)\?$' + let scriptfile = 'deldir.sh' + let rmdir = 'rm -rf %s' + else + let scriptfile = 'deldir.bat' + let rmdir = 'rmdir /S /Q %s' + endif + let enc = g:tlib#cache#script_encoding + if has('multi_byte') && enc != &enc + call map(deldir, 'iconv(v:val, &enc, enc)') + endif + let scriptfile = tlib#file#Join([dir, scriptfile]) + if filereadable(scriptfile) + let script = readfile(scriptfile) + else + let script = [] + endif + let script += map(copy(deldir), 'printf(rmdir, shellescape(v:val, 1))') + let script = tlib#list#Uniq(script) + call writefile(script, scriptfile) + call inputsave() + if g:tlib#cache#run_script == 0 + if g:tlib#cache#verbosity >= 1 + echohl WarningMsg + if g:tlib#cache#verbosity >= 2 + echom "TLib: Purged cache. Need to run script to delete directories" + endif + echom "TLib: Please review and execute: ". scriptfile + echohl NONE + endif + else + try + let yn = g:tlib#cache#run_script == 2 ? 'y' : tlib#input#Dialog("TLib: About to delete directories by means of a shell script.\nDirectory removal script: ". scriptfile ."\nRun script to delete directories now?", ['yes', 'no', 'edit'], 'no') + if yn =~ '^y\%[es]$' + exec 'silent cd '. fnameescape(dir) + exec '! ' &shell shellescape(scriptfile, 1) + exec 'silent cd -' + call delete(scriptfile) + elseif yn =~ '^e\%[dit]$' + exec 'edit '. fnameescape(scriptfile) + endif + finally + call inputrestore() + endtry + endif + endif + endif + call s:PurgeTimestamp(dir) +endf + + +function! s:Delete(msg, file, flags) abort "{{{3 + let rv = delete(a:file, a:flags) + if !rv && g:tlib#cache#verbosity >= 2 + call add(a:msg, "TLib#cache: Delete ". file) + endif + return rv +endf + + +function! s:PurgeTimestamp(dir) "{{{3 + let last_purge = tlib#file#Join([a:dir, '.last_purge']) + " TLogVAR last_purge + call writefile([" "], last_purge) +endf + +function! tlib#cache#ListFilesInCache(...) "{{{3 + let dir = a:0 >= 1 ? a:1 : tlib#cache#Dir('g') + if v:version > 702 || (v:version == 702 && has('patch51')) + let filess = glob(tlib#file#Join([dir, '**']), 1) + else + let filess = glob(tlib#file#Join([dir, '**'])) + endif + let files = reverse(split(filess, '\n')) + let pos0 = len(tlib#dir#CanonicName(dir)) + call filter(files, 's:ShouldPurge(tlib#string#Strcharpart(v:val, pos0))') + return files +endf + + +function! s:ShouldPurge(partial_filename) "{{{3 + " TLogVAR a:partial_filename + for rx in g:tlib#cache#dont_purge + if a:partial_filename =~ rx + " TLogVAR a:partial_filename, rx + return 0 + endif + endfor + return 1 +endf + diff --git a/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/char.vim b/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/char.vim new file mode 100644 index 0000000..d3d2cb6 --- /dev/null +++ b/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/char.vim @@ -0,0 +1,59 @@ +" @Author: Tom Link (micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Revision: 38 + + +" :def: function! tlib#char#Get(?timeout=0) +" Get a character. +" +" EXAMPLES: > +" echo tlib#char#Get() +" echo tlib#char#Get(5) +function! tlib#char#Get(...) "{{{3 + TVarArg ['timeout', 0], ['resolution', 0], ['getmod', 0] + let char = -1 + let mode = 0 + if timeout == 0 || !has('reltime') + let char = getchar() + else + let char = tlib#char#GetWithTimeout(timeout, resolution) + endif + if getmod + if char != -1 + let mode = getcharmod() + endif + return [char, mode] + else + return char + endif +endf + + +function! tlib#char#IsAvailable() "{{{3 + let ch = getchar(1) + return type(ch) == 0 && ch != 0 +endf + + +function! tlib#char#GetWithTimeout(timeout, ...) "{{{3 + TVarArg ['resolution', 2] + " TLogVAR a:timeout, resolution + let start = tlib#time#MSecs() + while 1 + let c = getchar(0) + if type(c) != 0 || c != 0 + return c + else + let now = tlib#time#MSecs() + let diff = tlib#time#DiffMSecs(now, start, resolution) + " TLogVAR diff + if diff > a:timeout + return -1 + endif + endif + endwh + return -1 +endf + + diff --git a/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/cmd.vim b/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/cmd.vim new file mode 100644 index 0000000..f65a237 --- /dev/null +++ b/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/cmd.vim @@ -0,0 +1,117 @@ +" @Author: Tom Link (micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Revision: 58 + + +let g:tlib#cmd#last_output = [] + + +function! tlib#cmd#OutputAsList(command) "{{{3 + " TLogVAR a:command + if exists('s:redir_lines') + redir END + let cache = s:redir_lines + endif + let s:redir_lines = '' + redir =>> s:redir_lines + silent! exec a:command + redir END + let g:tlib#cmd#last_output = split(s:redir_lines, '\n') + unlet s:redir_lines + if exists('cache') + let s:redir_lines = cache + redir =>> s:redir_lines + endif + return g:tlib#cmd#last_output +endf + + +" See |:TBrowseOutput|. +function! tlib#cmd#BrowseOutput(command) "{{{3 + call tlib#cmd#BrowseOutputWithCallback("tlib#cmd#DefaultBrowseOutput", a:command) +endf + +" :def: function! tlib#cmd#BrowseOutputWithCallback(callback, command) +" Execute COMMAND and present its output in a |tlib#input#List()|; +" when a line is selected, execute the function named as the CALLBACK +" and pass in that line as an argument. +" +" The CALLBACK function gives you an opportunity to massage the COMMAND output +" and possibly act on it in a meaningful way. For example, if COMMAND listed +" all URIs found in the current buffer, CALLBACK could validate and then open +" the selected URI in the system's default browser. +" +" This function is meant to be a tool to help compose the implementations of +" powerful commands that use |tlib#input#List()| as a common interface. See +" |TBrowseScriptnames| as an example. +" +" EXAMPLES: > +" call tlib#cmd#BrowseOutputWithCallback('tlib#cmd#ParseScriptname', 'scriptnames') +function! tlib#cmd#BrowseOutputWithCallback(callback, command) "{{{3 + let list = tlib#cmd#OutputAsList(a:command) + let cmds = tlib#input#List('m', 'Output of: '. a:command, list) + if !empty(cmds) + for cmd in cmds + let Callback = function(a:callback) + call call(Callback, [cmd]) + endfor + endif +endf + +function! tlib#cmd#DefaultBrowseOutput(cmd) "{{{3 + call feedkeys(':'. a:cmd) +endf + +function! tlib#cmd#ParseScriptname(line) "{{{3 + " let parsedValue = substitute(a:line, '^.\{-}\/', '/', '') + let parsedValue = matchstr(a:line, '^\s*\d\+:\s*\zs.*$') + exe 'drop '. fnameescape(parsedValue) +endf + + +function! tlib#cmd#TBrowseScriptnames() abort "{{{3 + call tlib#cmd#BrowseOutputWithCallback("tlib#cmd#ParseScriptname", "scriptnames") +endf + + +" :def: function! tlib#cmd#UseVertical(?rx='') +" Look at the history whether the command was called with vertical. If +" an rx is provided check first if the last entry in the history matches +" this rx. +function! tlib#cmd#UseVertical(...) "{{{3 + TVarArg ['rx'] + let h0 = histget(':') + let rx0 = '\C\\s\+' + if !empty(rx) + let rx0 .= '.\{-}'.rx + endif + " TLogVAR h0, rx0 + return h0 =~ rx0 +endf + + +" Print the time in seconds or milliseconds (if your version of VIM +" has |+reltime|) a command takes. +function! tlib#cmd#Time(cmd) "{{{3 + if has('reltime') + let start = tlib#time#Now() + exec a:cmd + let end = tlib#time#Now() + let diff = string(tlib#time#Diff(end, start)) .'ms' + else + let start = localtime() + exec a:cmd + let diff = (localtime() - start) .'s' + endif + echom 'Time: '. diff .': '. a:cmd +endf + + +function! tlib#cmd#Capture(cmd) "{{{3 + redir => s + silent exec a:cmd + redir END + return s +endf + diff --git a/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/comments.vim b/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/comments.vim new file mode 100644 index 0000000..879cde1 --- /dev/null +++ b/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/comments.vim @@ -0,0 +1,26 @@ +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Revision: 25 + + +" function! tlib#comments#Comments(?rx='') +function! tlib#comments#Comments(...) + TVarArg ['rx', ''] + let comments = {} + let co = &comments + while !empty(co) + " TLogVAR co + let [m_0, m_key, m_val, m_val1, co0, co; rest] = matchlist(co, '^\([^:]*\):\(\(\\.\|[^,]*\)\+\)\(,\(.*\)$\|$\)') + " TLogVAR m_key, m_val, co + if empty(m_key) + let m_key = ':' + endif + if empty(rx) || m_key =~ rx + let comments[m_key] = m_val + endif + endwh + return comments +endf + + diff --git a/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/date.vim b/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/date.vim new file mode 100644 index 0000000..1b7559c --- /dev/null +++ b/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/date.vim @@ -0,0 +1,195 @@ +" date.vim +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2010-03-25. +" @Last Change: 2017-09-06. +" @Revision: 44.0.34 + + +if !exists('g:tlib#date#ShortDatePrefix') | let g:tlib#date#ShortDatePrefix = '20' | endif "{{{2 +if !exists('g:tlib#date#TimeZoneShift') | let g:tlib#date#TimeZoneShift = 0 | endif "{{{2 + +let g:tlib#date#dayshift = 60 * 60 * 24 +" let g:tlib#date#date_rx = '\<\(\d\{4}\)-\(\d\d\)-\(\d\d\)\%(\s\+\(\(\d\d\):\(\d\d\)\)\)\?\>' +let g:tlib#date#date_rx = '\<\(\d\{4}\)-\(\d\d\)-\(\d\d\)\>' +let g:tlib#date#date_format = '%Y-%m-%d' + + +function! tlib#date#IsDate(text) abort "{{{3 + return a:text =~# '^'. g:tlib#date#date_rx .'$' && + \ !empty(tlib#date#Parse(a:text, 0, 1)) +endf + + +function! tlib#date#Format(...) abort "{{{3 + let secs1970 = a:0 >= 1 ? a:1 : localtime() + return strftime(g:tlib#date#date_format, secs1970) +endf + + +" :display: tlib#date#DiffInDays(date1, ?date2=localtime(), ?allow_zero=0) +function! tlib#date#DiffInDays(date, ...) + let allow_zero = a:0 >= 2 ? a:2 : 0 + let s0 = tlib#date#SecondsSince1970(a:date, 0, allow_zero) + let s1 = a:0 >= 1 ? tlib#date#SecondsSince1970(a:1, 0, allow_zero) : localtime() + let dd = (s0 - s1) / g:tlib#date#dayshift + " TLogVAR dd + return dd +endf + + +" :display: tlib#date#Parse(date, ?allow_zero=0, ?silent=0) "{{{3 +function! tlib#date#Parse(date, ...) "{{{3 + let min = a:0 >= 1 && a:1 ? 0 : 1 + let silent = a:0 >= 2 ? a:2 : 0 + Tlibtype 'tlib', a:date, min, silent + let m = matchlist(a:date, '^\(\d\{2}\|\d\{4}\)-\(\d\{1,2}\)-\(\d\{1,2}\)$') + Tlibtype 'tlib', m + let year = '' + let month = '' + let days = '' + if !empty(m) + let year = m[1] + let month = m[2] + let days = m[3] + else + let m = matchlist(a:date, '^\(\d\+\)/\(\d\{1,2}\)/\(\d\{1,2}\)$') + if !empty(m) + let year = m[1] + let month = m[3] + let days = m[2] + else + let m = matchlist(a:date, '^\(\d\{1,2}\)\.\s*\(\d\{1,2}\)\.\s*\(\d\d\{2}\|\d\{4}\)$') + if !empty(m) + let year = m[3] + let month = m[2] + let days = m[1] + endif + endif + endif + Tlibtype 'tlib', year, month, days + if empty(m) || year == '' || month == '' || days == '' || + \ month < min || month > 12 || days < min || days > 31 + if !silent + echoerr 'TLib: Invalid date: '. a:date + endif + return [] + endif + if strlen(year) == 2 + let year = g:tlib#date#ShortDatePrefix . year + Tlibtype 'tlib', year + endif + return [0 + year, 0 + month, 0 + days] +endf + + +" tlib#date#SecondsSince1970(date, ?daysshift=0, ?allow_zero=0) +function! tlib#date#SecondsSince1970(date, ...) "{{{3 + let allow_zero = a:0 >= 2 ? a:2 : 0 + " TLogVAR a:date, allow_zero + let date = tlib#date#Parse(a:date, allow_zero) + if empty(date) + return 0 + endif + let [year, month, days] = date + if a:0 >= 1 && a:1 > 0 + let days = days + a:1 + end + let days_passed = days + let i = 1970 + while i < year + let days_passed = days_passed + 365 + if i % 4 == 0 || i == 2000 + let days_passed = days_passed + 1 + endif + let i = i + 1 + endwh + let i = 1 + while i < month + if i == 1 + let days_passed = days_passed + 31 + elseif i == 2 + let days_passed = days_passed + 28 + if year % 4 == 0 || year == 2000 + let days_passed = days_passed + 1 + endif + elseif i == 3 + let days_passed = days_passed + 31 + elseif i == 4 + let days_passed = days_passed + 30 + elseif i == 5 + let days_passed = days_passed + 31 + elseif i == 6 + let days_passed = days_passed + 30 + elseif i == 7 + let days_passed = days_passed + 31 + elseif i == 8 + let days_passed = days_passed + 31 + elseif i == 9 + let days_passed = days_passed + 30 + elseif i == 10 + let days_passed = days_passed + 31 + elseif i == 11 + let days_passed = days_passed + 30 + endif + let i = i + 1 + endwh + let seconds = (days_passed - 1) * 24 * 60 * 60 + let seconds = seconds + (strftime('%H') + g:tlib#date#TimeZoneShift) * 60 * 60 + let seconds = seconds + strftime('%M') * 60 + let seconds = seconds + strftime('%S') + return seconds +endf + + +function! tlib#date#Shift(date, shift) abort "{{{3 + let n = str2nr(matchstr(a:shift, '\d\+')) + let ml = matchlist(a:date, g:tlib#date#date_rx) + " TLogVAR a:date, a:shift, n, ml + if a:shift =~ 'd$' + let date = tlib#date#AddDays(a:date, n) + elseif a:shift =~ 'b$' + let n1 = n + let secs = tlib#date#SecondsSince1970(a:date) + while n1 > 0 + let n1 -= 1 + let secs += g:tlib#date#dayshift + let uday = strftime('%u', secs) + if uday == 6 + let secs += g:tlib#date#dayshift * 2 + elseif uday == 7 + let secs += g:tlib#date#dayshift + endif + endwh + let date = tlib#date#Format(secs) + elseif a:shift =~ 'w$' + let date = tlib#date#AddDays(a:date, n * 7) + elseif a:shift =~ 'm$' + let d = str2nr(ml[3]) + let ms = str2nr(ml[2]) + n + let m = (ms - 1) % 12 + 1 + let yr = str2nr(ml[1]) + (ms - 1) / 12 + let date = printf('%04d-%02d-%02d', yr, m, d) + " TLogVAR d, ms, m, yr, date + elseif a:shift =~ 'y$' + let yr = str2nr(ml[1]) + n + let date = substitute(a:date, '^\d\{4}', yr, '') + else + throw 'tlib#date#Shift: Unsupported arguments: '. string(a:shift) + endif + " if !empty(ml[4]) && date !~ '\s'. ml[4] .'$' + " let date .= ' '. ml[4] + " endif + " TLogVAR date + return date +endf + + +function! tlib#date#AddDays(date, n) abort "{{{3 + let secs = tlib#date#SecondsSince1970(a:date) + g:tlib#date#dayshift * a:n + " TLogVAR secs + let date = tlib#date#Format(secs) + return date +endf + diff --git a/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/dictionary.vim b/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/dictionary.vim new file mode 100644 index 0000000..a778519 --- /dev/null +++ b/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/dictionary.vim @@ -0,0 +1,45 @@ +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @Website: https://github.com/tomtom +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Last Change: 2016-04-06 +" @Revision: 22 + + +" :display: tlib#dictionary#Rev(dict, ?opts = {}) abort "{{{3 +function! tlib#dictionary#Rev(dict, ...) abort "{{{3 + let opts = a:0 >= 1 ? a:1 : {} + Tlibtype a:dict, 'dict', opts, 'dict' + let rev = {} + let use_string = get(opts, 'use_string', 0) + let use_eval = get(opts, 'use_eval', 0) + let values_as_list = get(opts, 'values_as_list', 0) + for [m, f] in items(a:dict) + if use_string + let k = string(f) + else + let k = type(f) == 1 ? f : string(f) + if k ==# '' + let k = get(opts, 'empty', '') + if empty(k) + continue + endif + endif + endif + if use_eval + let v = eval(m) + else + let v = m + endif + if values_as_list + if has_key(rev, k) + call add(rev[k], v) + else + let rev[k] = [v] + endif + else + let rev[k] = v + endif + endfor + return rev +endf + diff --git a/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/dir.vim b/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/dir.vim new file mode 100644 index 0000000..0208107 --- /dev/null +++ b/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/dir.vim @@ -0,0 +1,93 @@ +" @Author: Tom Link (micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Revision: 43 + +" TLet g:tlib#dir#sep = '/' +TLet g:tlib#dir#sep = exists('+shellslash') && !&shellslash ? '\' : '/' + + +let s:dir_stack = [] + +" EXAMPLES: > +" tlib#dir#CanonicName('foo/bar') +" => 'foo/bar/' +function! tlib#dir#CanonicName(dirname) "{{{3 + let dirname = tlib#file#Canonic(a:dirname) + if dirname !~ '[/\\]$' + return dirname . g:tlib#dir#sep + endif + return dirname +endf + + +" EXAMPLES: > +" tlib#dir#NativeName('foo/bar/') +" On Windows: +" => 'foo\bar\' +" On Linux: +" => 'foo/bar/' +function! tlib#dir#NativeName(dirname) "{{{3 + let sep = tlib#rx#EscapeReplace(g:tlib#dir#sep) + let dirname = substitute(a:dirname, '[\/]', sep, 'g') + return dirname +endf + + +" EXAMPLES: > +" tlib#dir#PlainName('foo/bar/') +" => 'foo/bar' +function! tlib#dir#PlainName(dirname) "{{{3 + let dirname = a:dirname + while index(['/', '\'], dirname[-1 : -1]) != -1 + let dirname = dirname[0 : -2] + endwh + return dirname + " return substitute(a:dirname, tlib#rx#Escape(g:tlib#dir#sep).'\+$', '', '') +endf + + +" Create a directory if it doesn't already exist. +function! tlib#dir#Ensure(dir) "{{{3 + if !isdirectory(a:dir) + let dir = tlib#dir#PlainName(a:dir) + return mkdir(dir, 'p') + endif + return 1 +endf + + +" Return the first directory in &rtp. +function! tlib#dir#MyRuntime() "{{{3 + return get(split(&rtp, ','), 0) +endf + + +" :def: function! tlib#dir#CD(dir, ?locally=0) => CWD +function! tlib#dir#CD(dir, ...) "{{{3 + TVarArg ['locally', haslocaldir()] + let cmd = locally ? 'lcd! ' : 'cd! ' + " let cwd = getcwd() + let cmd .= tlib#arg#Ex(a:dir) + " TLogVAR a:dir, locally, cmd + exec 'silent' cmd + " return cwd + return getcwd() +endf + + +" :def: function! tlib#dir#Push(dir, ?locally=0) => CWD +function! tlib#dir#Push(dir, ...) "{{{3 + TVarArg ['locally', haslocaldir()] + call add(s:dir_stack, [getcwd(), locally]) + return tlib#dir#CD(a:dir, locally) +endf + + +" :def: function! tlib#dir#Pop() => CWD +function! tlib#dir#Pop() "{{{3 + let [dir, locally] = remove(s:dir_stack, -1) + return tlib#dir#CD(dir, locally) +endf + + diff --git a/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/eval.vim b/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/eval.vim new file mode 100644 index 0000000..117209e --- /dev/null +++ b/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/eval.vim @@ -0,0 +1,72 @@ +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Revision: 56 + + +function! tlib#eval#FormatValue(value, ...) "{{{3 + TVarArg ['indent', 0] + " TLogVAR a:value, indent + let indent1 = indent + 1 + let indenti = repeat(' ', &sw) + let type = type(a:value) + let acc = [] + if type == 0 || type == 1 || type == 2 + " TLogDBG 'Use string() for type='. type + call add(acc, string(a:value)) + elseif type == 3 "List + " TLogDBG 'List' + call add(acc, '[') + for e in a:value + call add(acc, printf('%s%s,', indenti, tlib#eval#FormatValue(e, indent1))) + unlet e + endfor + call add(acc, ']') + elseif type == 4 "Dictionary + " TLogDBG 'Dictionary' + call add(acc, '{') + let indent1 = indent + 1 + for [k, v] in items(a:value) + call add(acc, printf("%s%s: %s,", indenti, string(k), tlib#eval#FormatValue(v, indent1))) + unlet k v + endfor + call add(acc, '}') + else + " TLogDBG 'Unknown type: '. string(a:value) + call add(acc, string(a:value)) + endif + if indent > 0 + let is = repeat(' ', indent * &sw) + for i in range(1,len(acc) - 1) + let acc[i] = is . acc[i] + endfor + endif + return join(acc, "\n") +endf + + +function! tlib#eval#Extend(a, b, ...) abort "{{{3 + let mode = a:0 >= 1 ? a:1 : 'force' + if type(a:a) != type(a:b) + throw 'tlib#eval#Extend: Incompatible types: a='. string(a:a) .' b='. string(a:b) + elseif type(a:a) == 3 " list + return extend(a:a, a:b, mode) + elseif type(a:a) == 4 " dict + for k in keys(a:b) + if has_key(a:a, k) + if mode == 'force' + let a:a[k] = tlib#eval#Extend(copy(a:a[k]), a:b[k], mode) + elseif mode == 'error' + throw 'tlib#eval#Extend: Key already exists: '. k + endif + else + let a:a[k] = a:b[k] + endif + unlet! k + endfor + return a:a + else + return a:b + endif +endf + diff --git a/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/file.vim b/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/file.vim new file mode 100644 index 0000000..a52c1be --- /dev/null +++ b/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/file.vim @@ -0,0 +1,356 @@ +" @Author: Tom Link (micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Revision: 225 + + +if !exists('g:tlib#file#drop') + " If true, use |:drop| to edit loaded buffers (only available with GUI). + let g:tlib#file#drop = has('gui') "{{{2 +endif + + +if !exists('g:tlib#file#use_tabs') + let g:tlib#file#use_tabs = 0 "{{{2 +endif + + +if !exists('g:tlib#file#edit_cmds') + let g:tlib#file#edit_cmds = g:tlib#file#use_tabs ? {'buffer': 'tab split | buffer', 'edit': 'tabedit'} : {} "{{{2 +endif + + +if !exists('g:tlib#file#absolute_filename_rx') + let g:tlib#file#absolute_filename_rx = '^\~\?[\/]' "{{{2 +endif + + +if !exists('g:tlib#file#reject_rx') + let g:tlib#file#reject_rx = '\%(^\|[\/]\)\%(tags\|Thumbs\.db\)$' "{{{2 +endif + + +""" File related {{{1 +" For the following functions please see ../../test/tlib.vim for examples. + + +" EXAMPLES: > +" tlib#file#Split('foo/bar/filename.txt') +" => ['foo', 'bar', 'filename.txt'] +function! tlib#file#Split(filename) abort "{{{3 + let prefix = matchstr(a:filename, '^\(\w\+:\)\?/\+') + Tlibtrace 'tlib', prefix + if !empty(prefix) + let filename = a:filename[len(prefix) : -1] + else + let filename = a:filename + endif + let rv = split(filename, '[\/]') + " let rv = split(filename, '[\/]', 1) + if !empty(prefix) + call insert(rv, prefix[0:-2]) + endif + return rv +endf + + +" :display: tlib#file#Join(filename_parts, ?strip_slashes=1, ?maybe_absolute=0) +" EXAMPLES: > +" tlib#file#Join(['foo', 'bar', 'filename.txt']) +" => 'foo/bar/filename.txt' +function! tlib#file#Join(filename_parts, ...) abort "{{{3 + TVarArg ['strip_slashes', 1], 'maybe_absolute' + Tlibtrace 'tlib', a:filename_parts, strip_slashes + if maybe_absolute + let filename_parts = [] + for part in a:filename_parts + if part =~ g:tlib#file#absolute_filename_rx + let filename_parts = [] + endif + call add(filename_parts, part) + endfor + else + let filename_parts = a:filename_parts + endif + if strip_slashes + " let rx = tlib#rx#Escape(g:tlib#dir#sep) .'$' + let rx = '[/\\]\+$' + let parts = map(copy(filename_parts), 'substitute(v:val, rx, "", "")') + Tlibtrace 'tlib', parts + return join(parts, g:tlib#dir#sep) + else + return join(filename_parts, g:tlib#dir#sep) + endif +endf + + +" EXAMPLES: > +" tlib#file#Relative('foo/bar/filename.txt', 'foo') +" => 'bar/filename.txt' +function! tlib#file#Relative(filename, basedir) abort "{{{3 + Tlibtrace 'tlib', a:filename, a:basedir + " TLogDBG getcwd() + " TLogDBG expand('%:p') + let b0 = tlib#file#Absolute(a:basedir) + let b = tlib#file#Split(b0) + Tlibtrace 'tlib', b + let f0 = tlib#file#Absolute(a:filename) + let fn = fnamemodify(f0, ':t') + let fd = fnamemodify(f0, ':h') + let f = tlib#file#Split(fd) + Tlibtrace 'tlib', f0, fn, fd, f + if f[0] != b[0] + let rv = f0 + else + while !empty(f) && !empty(b) + if f[0] != b[0] + break + endif + call remove(f, 0) + call remove(b, 0) + endwh + Tlibtrace 'tlib', f, b + let rv = tlib#file#Join(repeat(['..'], len(b)) + f + [fn]) + endif + Tlibtrace 'tlib', rv + return rv +endf + + +function! tlib#file#IsAbsolute(filename) abort "{{{3 + return a:filename =~? '^\%(/\|\w\+:/\)' +endf + + +function! tlib#file#Absolute(filename, ...) abort "{{{3 + if filereadable(a:filename) + let filename = fnamemodify(a:filename, ':p') + elseif a:filename =~# '^\(/\|[^\/]\+:\)' + let filename = a:filename + else + let cwd = a:0 >= 1 ? a:1 : getcwd() + let filename = tlib#file#Join([cwd, a:filename]) + endif + let filename = substitute(filename, '\(^\|[\/]\)\zs\.[\/]', '', 'g') + let filename = substitute(filename, '[\/]\zs[^\/]\+[\/]\.\.[\/]', '', 'g') + return filename +endf + + +function! tlib#file#Canonic(filename, ...) abort "{{{3 + TVarArg ['mode', ''] + if empty(mode) + if a:filename =~# '^\\\\' + let mode = 'windows' + elseif a:filename =~# '^\(file\|ftp\|http\)s\?:' + let mode = 'url' + elseif (empty(mode) && g:tlib#sys#windows) + let mode = 'windows' + endif + endif + let filename = a:filename + if mode ==# 'windows' + let filename = substitute(filename, '/', '\\', 'g') + else + let filename = substitute(filename, '\\', '/', 'g') + endif + return filename +endf + + +function! s:SetScrollBind(world) abort "{{{3 + let sb = get(a:world, 'scrollbind', &scrollbind) + if sb != &scrollbind + let &scrollbind = sb + endif +endf + + +" :def: function! tlib#file#With(fcmd, bcmd, files, ?world={}) abort +function! tlib#file#With(fcmd, bcmd, files, ...) abort "{{{3 + Tlibtrace 'tlib', a:fcmd, a:bcmd, a:files + let world = a:0 >= 1 ? a:1 : {} + let unset_switchbuf = a:0 >= 2 ? a:2 : 0 + exec tlib#arg#Let([['world', {}]]) + call tlib#autocmdgroup#Init() + augroup TLibFileRead + autocmd! + augroup END + if unset_switchbuf + let switchbuf = &switchbuf + set switchbuf& + endif + try + for f in a:files + try + let bn = bufnr('^'.f.'$') + Tlibtrace 'tlib', f, bn + let bufloaded = bufloaded(bn) + let ok = 0 + let s:bufread = "" + if bn != -1 && buflisted(bn) + if !empty(a:bcmd) + let bcmd = a:bcmd .' '. bn + Tlibtrace 'tlib', bcmd + exec bcmd + let ok = 1 + call s:SetScrollBind(world) + endif + else + if filereadable(f) + if !empty(a:fcmd) + " TLogDBG a:fcmd .' '. tlib#arg#Ex(f) + exec 'autocmd TLibFileRead BufRead' escape(f, '\ ') 'let s:bufread=expand(":p")' + try + let fcmd = a:fcmd .' '. tlib#arg#Ex(f) + Tlibtrace 'tlib', fcmd + exec fcmd + finally + exec 'autocmd! TLibFileRead BufRead' + endtry + let ok = 1 + call s:SetScrollBind(world) + endif + else + echohl error + echom 'File not readable: '. f + echohl NONE + endif + endif + Tlibtrace 'tlib', ok, bufloaded, &filetype + if empty(s:bufread) && ok && !bufloaded && empty(&filetype) + doautocmd BufRead + endif + catch /^Vim\%((\a\+)\)\=:E325/ + echohl ErrorMsg + echom v:exception + echohl NONE + endtry + endfor + finally + augroup! TLibFileRead + if unset_switchbuf + let &switchbuf = switchbuf + endif + unlet! s:bufread + endtry + " TLogDBG "done" +endf + + +" Return 0 if the file isn't readable/doesn't exist. +" Otherwise return 1. +function! tlib#file#Edit(fileid) abort "{{{3 + if type(a:fileid) == 0 + let bn = a:fileid + let filename = fnamemodify(bufname(bn), ':p') + else + let filename = fnamemodify(a:fileid, ':p') + let bn = bufnr(filename) + endif + if filename == expand('%:p') + return 1 + else + Tlibtrace 'tlib', a:fileid, bn, filename, g:tlib#file#drop, filereadable(filename), bufnr('%') + if bn != -1 && buflisted(bn) + if g:tlib#file#drop + " echom "DBG" get(g:tlib#file#edit_cmds, 'drop', 'drop') fnameescape(filename) + exec get(g:tlib#file#edit_cmds, 'drop', 'drop') fnameescape(filename) + " echom "DBG" bufnr('%') + else + " echom "DBG" get(g:tlib#file#edit_cmds, 'buffer', 'buffer') bn + exec get(g:tlib#file#edit_cmds, 'buffer', 'buffer') bn + " echom "DBG" bufnr('%') + endif + return 1 + endif + if !filereadable(filename) && exists('#TLibPrepareFile#User') + exec 'doautocmd TLibPrepareFile User' filename + endif + if filereadable(filename) + try + " let file = tlib#arg#Ex(filename) + " Tlibtrace 'tlib', file + " echom "DBG" get(g:tlib#file#edit_cmds, 'edit', 'edit') fnameescape(filename) + exec get(g:tlib#file#edit_cmds, 'edit', 'edit') fnameescape(filename) + catch /E325/ + " swap file exists, let the user handle it + catch + echohl error + echom v:exception + echohl NONE + endtry + return 1 + else + echom "TLIB: File not readable: " . filename + if filename != a:fileid + echom "TLIB: original filename: " . a:fileid + endif + endif + endif + return 0 +endf + + +function! tlib#file#FilterFiles(files, options) abort "{{{3 + Tlibtrace 'tlib', a:files, a:options, g:tlib#file#reject_rx + if !get(a:options, 'all', 0) + call filter(a:files, 'v:val !~# g:tlib#file#reject_rx') + endif + Tlibtrace 'tlib', a:files + let type = get(a:options, 'type', 'fd') + Tlibtrace 'tlib', type + if type !~# 'd' || type !~# 'f' + call filter(a:files, 'isdirectory(v:val) ? type =~# "d" : type =~# "f"') + endif + Tlibtrace 'tlib', a:files + return a:files +endf + + +if v:version > 704 || (v:version == 704 && has('patch279')) + + function! tlib#file#Glob(pattern, ...) abort "{{{3 + let all = a:0 >= 1 ? a:1 : 0 + let nosuf = a:0 >= 2 ? a:2 : 0 + return tlib#file#FilterFiles(glob(a:pattern, nosuf, 1), {'all': all}) + endf + + function! tlib#file#Globpath(path, pattern, ...) abort "{{{3 + let all = a:0 >= 1 ? a:1 : 0 + let nosuf = a:0 >= 2 ? a:2 : 0 + return tlib#file#FilterFiles(globpath(a:path, a:pattern, nosuf, 1), {'all': all}) + endf + +else + + " :nodoc: + function! tlib#file#Glob(pattern, ...) abort "{{{3 + let all = a:0 >= 1 ? a:1 : 0 + let nosuf = a:0 >= 2 ? a:2 : 0 + return tlib#file#FilterFiles(split(glob(a:pattern, nosuf), '\n'), {'all': all}) + endf + + " :nodoc: + function! tlib#file#Globpath(path, pattern, ...) abort "{{{3 + let all = a:0 >= 1 ? a:1 : 0 + let nosuf = a:0 >= 2 ? a:2 : 0 + return tlib#file#FilterFiles(split(globpath(a:path, a:pattern), '\n'), {'all': all}) + endf + +endif + + +let s:filereadable = {} + +augroup TLib + autocmd BufWritePost,FileWritePost,FocusLost * let s:filereadable = {} +augroup end + +function! tlib#file#Filereadable(filename) abort "{{{3 + if !has_key(s:filereadable, a:filename) + let s:filereadable[a:filename] = filereadable(a:filename) + endif + return s:filereadable[a:filename] +endf + diff --git a/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/fixes.vim b/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/fixes.vim new file mode 100644 index 0000000..e9247dd --- /dev/null +++ b/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/fixes.vim @@ -0,0 +1,14 @@ +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Last Change: 2013-02-22. +" @Revision: 3 + + +function! tlib#fixes#Winpos() "{{{3 + if has('gui_win32') + return 'winpos '. getwinposx() .' '. getwinposy() + else + return '' + endif +endf + diff --git a/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/grep.vim b/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/grep.vim new file mode 100644 index 0000000..894b1ee --- /dev/null +++ b/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/grep.vim @@ -0,0 +1,38 @@ +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Last Change: 2013-10-16. +" @Revision: 31 + + +function! tlib#grep#Do(cmd, rx, files) "{{{3 + " TLogVAR a:cmd, a:rx, a:files + let files = join(map(copy(a:files), 'tlib#arg#Ex(v:val, "")'), ' ') + let rx = '/'. escape(a:rx, '/') .'/j' + " TLogVAR rx, files + silent exec a:cmd rx files +endf + + +function! tlib#grep#LocList(rx, files) "{{{3 + return tlib#grep#Do('noautocmd lvimgrep', a:rx, a:files) +endf + + +function! tlib#grep#QuickFixList(rx, files) "{{{3 + return tlib#grep#Do('noautocmd vimgrep', a:rx, a:files) +endf + + +function! tlib#grep#List(rx, files) "{{{3 + call setqflist([]) + call tlib#grep#Do('noautocmd vimgrepadd', a:rx, a:files) + let qfl = getqflist() + " TLogVAR qfl + " try + silent! colder + " catch + " call setqflist([], 'r') + " endtry + return qfl +endf + diff --git a/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/hash.vim b/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/hash.vim new file mode 100644 index 0000000..29c9ef6 --- /dev/null +++ b/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/hash.vim @@ -0,0 +1,145 @@ +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Revision: 276 + + +if !exists('g:tlib#hash#use_crc32') + let g:tlib#hash#use_crc32 = '' "{{{2 +endif + + +if !exists('g:tlib#hash#use_adler32') + let g:tlib#hash#use_adler32 = '' "{{{2 +endif + + +function! tlib#hash#CRC32B(chars) "{{{3 + if !empty(g:tlib#hash#use_crc32) + let use = g:tlib#hash#use_crc32 + elseif has('ruby') + let use = 'ruby' + else + let use = 'vim' + endif + if exists('*tlib#hash#CRC32B_'. use) + return tlib#hash#CRC32B_{use}(a:chars) + else + throw "Unknown version of tlib#hash#CRC32B: ". use + endif +endf + + +function! tlib#hash#CRC32B_ruby(chars) "{{{3 + if has('ruby') + let rv = '' + if !exists('s:loaded_ruby_zlib') + ruby require 'zlib' + let s:loaded_ruby_zlib = 1 + endif + ruby VIM::command('let rv = "%08X"' % Zlib.crc32(VIM::evaluate("a:chars"))) + return rv + else + throw "tlib#hash#CRC32B_ruby not supported in this version of vim" + endif +endf + + +function! tlib#hash#CRC32B_vim(chars) "{{{3 + if !exists('s:crc_table') + let cfile = tlib#persistent#Filename('tlib', 'crc_table', 1) + let s:crc_table = tlib#persistent#Value(cfile, 'tlib#hash#CreateCrcTable', 0) + endif + let xFFFF_FFFF = repeat([1], 32) + let crc = tlib#bitwise#XOR([0], xFFFF_FFFF, 'bits') + for char in split(a:chars, '\zs') + let octet = char2nr(char) + let r1 = tlib#bitwise#ShiftRight(crc, 8) + let i0 = tlib#bitwise#AND(crc, xFFFF_FFFF, 'bits') + let i1 = tlib#bitwise#XOR(i0, octet, 'bits') + let i2 = tlib#bitwise#Bits2Num(tlib#bitwise#AND(i1, 0xff, 'bits')) + let r2 = s:crc_table[i2] + let crc = tlib#bitwise#XOR(r1, r2, 'bits') + endfor + let crc = tlib#bitwise#XOR(crc, xFFFF_FFFF, 'bits') + let rv = tlib#bitwise#Bits2Num(crc, 16) + if len(rv) < 8 + let rv = repeat('0', 8 - len(rv)) . rv + endif + return rv +endf + + +" :nodoc: +function! tlib#hash#CreateCrcTable() "{{{3 + let sum = 0.0 + for exponent in [0, 1, 2, 4, 5, 7, 8, 10, 11, 12, 16, 22, 23, 26, 32] + let exp = tlib#bitwise#Bits2Num(repeat([0], 32 - exponent) + [1], 10.0) + let sum += exp + endfor + let divisor = tlib#bitwise#Num2Bits(sum) + let crc_table = [] + for octet in range(256) + let remainder = tlib#bitwise#Num2Bits(octet) + for i in range(8) + if get(remainder, i) != 0 + let remainder = tlib#bitwise#XOR(remainder, tlib#bitwise#ShiftLeft(divisor, i), "bits") + endif + endfor + let remainder = tlib#bitwise#ShiftRight(remainder, 8) + call add(crc_table, remainder) + endfor + return crc_table +endf + + +function! tlib#hash#Adler32(chars) "{{{3 + if !empty(g:tlib#hash#use_adler32) + let use = g:tlib#hash#use_adler32 + elseif exists('*or') + let use = 'vim' + else + let use = 'tlib' + endif + if exists('*tlib#hash#Adler32_'. use) + return tlib#hash#Adler32_{use}(a:chars) + else + throw "Unknown version of tlib#hash#Adler32_: ". use + endif +endf + + +function! tlib#hash#Adler32_vim(chars) "{{{3 + if exists('*or') + let mod_adler = 65521 + let a = 1 + let b = 0 + for index in range(len(a:chars)) + let c = char2nr(a:chars[index]) + let a = (a + c) % mod_adler + let b = (b + a) % mod_adler + endfor + let bb = b * float2nr(pow(2, 16)) + let checksum = or(bb, a) + " TLogVAR checksum, a, b, bb + return printf("%08X", checksum) + else + throw "TLIB: Vim version doesn't support bitwise or()" + endif +endf + + +function! tlib#hash#Adler32_tlib(chars) "{{{3 + let mod_adler = 65521 + let a = 1 + let b = 0 + for index in range(len(a:chars)) + let c = char2nr(a:chars[index]) + let a = (a + c) % mod_adler + let b = (b + a) % mod_adler + endfor + let bb = tlib#bitwise#ShiftLeft(tlib#bitwise#Num2Bits(b), 16) + let checksum = tlib#bitwise#OR(bb, a, "bits") + return printf('%08s', tlib#bitwise#Bits2Num(checksum, 16)) +endf + + diff --git a/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/hook.vim b/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/hook.vim new file mode 100644 index 0000000..07d0504 --- /dev/null +++ b/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/hook.vim @@ -0,0 +1,25 @@ +" @Author: Tom Link (micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Revision: 11 + + +" :def: function! tlib#hook#Run(hook, ?dict={}) +" Execute dict[hook], w:{hook}, b:{hook}, or g:{hook} if existent. +function! tlib#hook#Run(hook, ...) "{{{3 + TVarArg ['dict', {}] + if has_key(dict, a:hook) + let hook = dict[a:hook] + else + let hook = tlib#var#Get(a:hook, 'wbg') + endif + if empty(hook) + return 0 + else + let world = dict + exec hook + return 1 + endif +endf + + diff --git a/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/input.vim b/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/input.vim new file mode 100644 index 0000000..e294e2a --- /dev/null +++ b/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/input.vim @@ -0,0 +1,1270 @@ +" @Author: Tom Link (micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Revision: 1430 + +" :filedoc: +" Input-related, select from a list etc. + +" If a list is bigger than this value, don't try to be smart when +" selecting an item. Be slightly faster instead. +" See |tlib#input#List()|. +TLet g:tlib#input#sortprefs_threshold = 200 + + +" If a list contains more items, |tlib#input#List()| does not perform an +" incremental "live search" but uses |input()| to query the user for a +" filter. This is useful on slower machines or with very long lists. +TLet g:tlib#input#livesearch_threshold = 1000 + + +" Determine how |tlib#input#List()| and related functions work. +" Can be "glob", "cnf", "cnfd", "seq", or "fuzzy". See: +" glob ... Like cnf but "*" and "?" (see |g:tlib#Filter_glob#seq|, +" |g:tlib#Filter_glob#char|) are interpreted as glob-like +" |wildcards| (this is the default method) +" - Examples: +" - "f*o" matches "fo", "fxo", and "fxxxoo", but doesn't match +" "far". +" - Otherwise it is a derivate of the cnf method (see below). +" - See also |tlib#Filter_glob#New()|. +" cnfd ... Like cnf but "." is interpreted as a wildcard, i.e. it is +" expanded to "\.\{-}" +" - A period character (".") acts as a wildcard as if ".\{-}" (see +" |/\{-|) were entered. +" - Examples: +" - "f.o" matches "fo", "fxo", and "fxxxoo", but doesn't match +" "far". +" - Otherwise it is a derivate of the cnf method (see below). +" - See also |tlib#Filter_cnfd#New()|. +" cnf .... Match substrings +" - A blank creates an AND conjunction, i.e. the next pattern has to +" match too. +" - A pipe character ("|") creates an OR conjunction, either this or +" the next next pattern has to match. +" - Patterns are very 'nomagic' |regexp| with a |\V| prefix. +" - A pattern starting with "-" makes the filter exclude items +" matching that pattern. +" - Examples: +" - "foo bar" matches items that contain the strings "foo" AND +" "bar". +" - "foo|bar boo|far" matches items that contain either ("foo" OR +" "bar") AND ("boo" OR "far"). +" - See also |tlib#Filter_cnf#New()|. +" seq .... Match sequences of characters +" - |tlib#Filter_seq#New()| +" fuzzy .. Match fuzzy character sequences +" - |tlib#Filter_fuzzy#New()| +TLet g:tlib#input#filter_mode = 'glob' + + +" The highlight group to use for showing matches in the input list +" window. +" See |tlib#input#List()|. +TLet g:tlib#input#higroup = 'IncSearch' + +" When 1, automatically select the last remaining item only if the list +" had only one item to begin with. +" When 2, automatically select a last remaining item after applying +" any filters. +" See |tlib#input#List()|. +TLet g:tlib_pick_last_item = 1 + + +" :doc: +" Keys for |tlib#input#List|~ + +TLet g:tlib#input#and = ' ' +TLet g:tlib#input#or = '|' +TLet g:tlib#input#not = '-' + +" When editing a list with |tlib#input#List|, typing these numeric chars +" (as returned by getchar()) will select an item based on its index, not +" based on its name. I.e. in the default setting, typing a "4" will +" select the fourth item, not the item called "4". +" In order to make keys 0-9 filter the items in the list and make +" select an item by its index, remove the keys 48 to 57 from +" this dictionary. +" Format: [KEY] = BASE ... the number is calculated as KEY - BASE. +" :nodefault: +TLet g:tlib#input#numeric_chars = { + \ 176: 176, + \ 177: 176, + \ 178: 176, + \ 179: 176, + \ 180: 176, + \ 181: 176, + \ 182: 176, + \ 183: 176, + \ 184: 176, + \ 185: 176, + \} + " \ 48: 48, + " \ 49: 48, + " \ 50: 48, + " \ 51: 48, + " \ 52: 48, + " \ 53: 48, + " \ 54: 48, + " \ 55: 48, + " \ 56: 48, + " \ 57: 48, + + +" :nodefault: +" The default key bindings for single-item-select list views. +" +" This variable is best customized via the variable +" g:tlib_extend_keyagents_InputList_s. If you want to use , +" to move the cursor up and down, add these two lines to your |vimrc| +" file: +" +" let g:tlib_extend_keyagents_InputList_s = { +" \ 10: 'tlib#agent#Down', +" \ 11: 'tlib#agent#Up' +" \ } +TLet g:tlib#input#keyagents_InputList_s = { + \ "\": 'tlib#agent#PageUp', + \ "\": 'tlib#agent#PageDown', + \ "\": 'tlib#agent#Home', + \ "\": 'tlib#agent#End', + \ "\": 'tlib#agent#Up', + \ "\": 'tlib#agent#Down', + \ 9: 'tlib#agent#Complete', + \ "\": 'tlib#agent#UpN', + \ "\": 'tlib#agent#DownN', + \ "\": 'tlib#agent#ShiftLeft', + \ "\": 'tlib#agent#ShiftRight', + \ 18: 'tlib#agent#Reset', + \ 242: 'tlib#agent#Reset', + \ 17: 'tlib#agent#Input', + \ 241: 'tlib#agent#Input', + \ 27: 'tlib#agent#Exit', + \ 26: 'tlib#agent#Suspend', + \ 250: 'tlib#agent#Suspend', + \ 15: 'tlib#agent#SuspendToParentWindow', + \ "\": 'tlib#agent#Help', + \ "\": 'tlib#agent#ExecAgentByName', + \ "\": 'tlib#agent#ExecAgentByName', + \ "\": 'tlib#agent#ReduceFilter', + \ "\": 'tlib#agent#ReduceFilter', + \ "\": 'tlib#agent#PopFilter', + \ "\": 'tlib#agent#PopFilter', + \ "\": 'tlib#agent#PopFilter', + \ "\": 'tlib#agent#PopFilter', + \ "\": 'tlib#agent#Wildcard', + \ 191: 'tlib#agent#Debug', + \ char2nr(g:tlib#input#or): 'tlib#agent#OR', + \ char2nr(g:tlib#input#and): 'tlib#agent#AND', + \ } + " \ 63: 'tlib#agent#Help', + +if exists('g:tlib_extend_keyagents_InputList_s') + let g:tlib#input#keyagents_InputList_s = extend(g:tlib#input#keyagents_InputList_s, g:tlib_extend_keyagents_InputList_s) +endif + + +" :nodefault: +TLet g:tlib#input#keyagents_InputList_m = { + \ 35: 'tlib#agent#Select', + \ "\": 'tlib#agent#SelectUp', + \ "\": 'tlib#agent#SelectDown', + \ 1: 'tlib#agent#SelectAll', + \ 225: 'tlib#agent#SelectAll', + \ "\": 'tlib#agent#ToggleRestrictView', + \ } +" "\": 'tlib#agent#Select' + +if exists('g:tlib_extend_keyagents_InputList_m') + let g:tlib#input#keyagents_InputList_m = extend(g:tlib#input#keyagents_InputList_m, g:tlib_extend_keyagents_InputList_m) +endif + + + +" :nodefault: +TLet g:tlib#input#handlers_EditList = [ + \ {'key': 5, 'agent': 'tlib#agent#EditItem', 'key_name': '', 'help': 'Edit item'}, + \ {'key': 4, 'agent': 'tlib#agent#DeleteItems', 'key_name': '', 'help': 'Delete item(s)'}, + \ {'key': 14, 'agent': 'tlib#agent#NewItem', 'key_name': '', 'help': 'New item'}, + \ {'key': 24, 'agent': 'tlib#agent#Cut', 'key_name': '', 'help': 'Cut item(s)'}, + \ {'key': 3, 'agent': 'tlib#agent#Copy', 'key_name': '', 'help': 'Copy item(s)'}, + \ {'key': 22, 'agent': 'tlib#agent#Paste', 'key_name': '', 'help': 'Paste item(s)'}, + \ {'pick_last_item': 0}, + \ {'return_agent': 'tlib#agent#EditReturnValue'}, + \ {'help_extra': [ + \ 'Submit changes by pressing ENTER or or ', + \ 'Cancel editing by pressing c' + \ ]}, + \ ] + + +" A dictionary KEY => {'agent': AGENT, 'key_name': KEY_NAME} to +" customize keyboard shortcuts in the list view. +TLet g:tlib#input#user_shortcuts = {} + + +" If true, define a popup menu for |tlib#input#List()| and related +" functions. +TLet g:tlib#input#use_popup = has('menu') && (has('gui_gtk') || has('gui_gtk2') || has('gui_win32')) + + +" How to format filenames: +" l ... Show basenames on the left side, separated from the +" directory names +" r ... Show basenames on the right side +TLet g:tlib#input#format_filename = 'l' + + +" If g:tlib#input#format_filename == 'r', how much space should be kept +" free on the right side. +TLet g:tlib#input#filename_padding_r = '&co / 10' + + +" If g:tlib#input#format_filename == 'l', an expression that +" |eval()|uates to the maximum display width of filenames. +TLet g:tlib#input#filename_max_width = '&co / 2' + + +" Functions related to tlib#input#List(type, ...) "{{{2 + +" :def: function! tlib#input#List(type. ?query='', ?list=[], ?handlers=[], ?default="", ?timeout=0) +" Select a single or multiple items from a list. Return either the list +" of selected elements or its indexes. +" +" By default, typing numbers will select an item by its index. See +" |g:tlib#input#numeric_chars| to find out how to change this. +" +" The item is automatically selected if the numbers typed equals the +" number of digits of the list length. I.e. if a list contains 20 items, +" typing 1 will first highlight item 1 but it won't select/use it +" because 1 is an ambiguous input in this context. If you press enter, +" the first item will be selected. If you press another digit (e.g. 0), +" item 10 will be selected. Another way to select item 1 would be to +" type 01. If the list contains only 9 items, typing 1 would select the +" first item right away. +" +" type can be: +" s ... Return one selected element +" si ... Return the index of the selected element +" m ... Return a list of selected elements +" mi ... Return a list of indexes +" +" Several pattern matching styles are supported. See +" |g:tlib#input#filter_mode|. +" +" Users can type to complete the current filter with the longest +" match. +" +" EXAMPLES: > +" echo tlib#input#List('s', 'Select one item', [100,200,300]) +" echo tlib#input#List('si', 'Select one item', [100,200,300]) +" echo tlib#input#List('m', 'Select one or more item(s)', [100,200,300]) +" echo tlib#input#List('mi', 'Select one or more item(s)', [100,200,300]) +" +" See ../samples/tlib/input/tlib_input_list.vim (move the cursor over +" the filename and press gf) for a more elaborated example. +function! tlib#input#List(type, ...) "{{{3 + exec tlib#arg#Let([ + \ ['query', ''], + \ ['list', []], + \ ['handlers', []], + \ ['rv', ''], + \ ['timeout', 0], + \ ]) + " let handlers = a:0 >= 1 ? a:1 : [] + " let rv = a:0 >= 2 ? a:2 : '' + " let timeout = a:0 >= 3 ? a:3 : 0 + " let backchar = ["\", "\"] + + if a:type =~ '^resume' + let world = b:tlib_{matchstr(a:type, ' \zs.\+')} + else + let world = tlib#World#New({ + \ 'type': a:type, + \ 'base': list, + \ 'query': query, + \ 'timeout': timeout, + \ 'rv': rv, + \ 'handlers': handlers, + \ }) + let scratch_name = tlib#list#Find(handlers, 'has_key(v:val, "scratch_name")', '', 'v:val.scratch_name') + if !empty(scratch_name) + let world.scratch = scratch_name + endif + let world.scratch_vertical = tlib#list#Find(handlers, 'has_key(v:val, "scratch_vertical")', 0, 'v:val.scratch_vertical') + call world.Set_display_format(tlib#list#Find(handlers, 'has_key(v:val, "display_format")', '', 'v:val.display_format')) + let world.initial_index = tlib#list#Find(handlers, 'has_key(v:val, "initial_index")', 1, 'v:val.initial_index') + let world.index_table = tlib#list#Find(handlers, 'has_key(v:val, "index_table")', [], 'v:val.index_table') + let world.state_handlers = filter(copy(handlers), 'has_key(v:val, "state")') + let world.post_handlers = filter(copy(handlers), 'has_key(v:val, "postprocess")') + let world.filter_format = tlib#list#Find(handlers, 'has_key(v:val, "filter_format")', '', 'v:val.filter_format') + let world.return_agent = tlib#list#Find(handlers, 'has_key(v:val, "return_agent")', '', 'v:val.return_agent') + let world.help_extra = tlib#list#Find(handlers, 'has_key(v:val, "help_extra")', '', 'v:val.help_extra') + let world.resize = tlib#list#Find(handlers, 'has_key(v:val, "resize")', '', 'v:val.resize') + let world.show_empty = tlib#list#Find(handlers, 'has_key(v:val, "show_empty")', 0, 'v:val.show_empty') + let world.pick_last_item = tlib#list#Find(handlers, 'has_key(v:val, "pick_last_item")', + \ tlib#var#Get('tlib_pick_last_item', 'bg'), 'v:val.pick_last_item') + let world.numeric_chars = tlib#list#Find(handlers, 'has_key(v:val, "numeric_chars")', + \ g:tlib#input#numeric_chars, 'v:val.numeric_chars') + let world.key_handlers = filter(copy(handlers), 'has_key(v:val, "key")') + let filter = tlib#list#Find(handlers, 'has_key(v:val, "filter")', '', 'v:val.filter') + if !empty(filter) + " let world.initial_filter = [[''], [filter]] + " let world.initial_filter = [[filter]] + Tlibtrace 'tlib', world.initial_filter, filter + call world.SetInitialFilter(filter) + endif + endif + return tlib#input#ListW(world) +endf + + +" A wrapper for |tlib#input#ListW()| that builds |tlib#World#New| from +" dict. +function! tlib#input#ListD(dict) "{{{3 + return tlib#input#ListW(tlib#World#New(a:dict)) +endf + + +" :def: function! tlib#input#ListW(world, ?command='') +" The second argument (command) is meant for internal use only. +" The same as |tlib#input#List| but the arguments are packed into world +" (an instance of tlib#World as returned by |tlib#World#New|). +function! tlib#input#ListW(world, ...) "{{{3 + TVarArg 'cmd' + let time0 = str2float(reltimestr(reltime())) + Tlibtrace 'tlib', time0 + let world = a:world + if world.pick_last_item >= 1 && stridx(world.type, 'e') == -1 && len(world.base) <= 1 + call world.CloseScratch(1) + let rv = get(world.base, 0, world.rv) + if stridx(world.type, 'm') != -1 + return [rv] + else + return rv + endif + endif + call s:Init(world, cmd) + Tlibtrace 'tlib', world.state, world.sticky, world.initial_index + " let statusline = &l:statusline + " let laststatus = &laststatus + let showmode = &showmode + set noshowmode + let lastsearch = @/ + let scrolloff = &l:scrolloff + let &l:scrolloff = 0 + let @/ = '' + let dlist = [] + let post_keys = '' + " let &laststatus = 2 + + try + while !empty(world.state) && world.state !~ '^exit' && (world.show_empty || !empty(world.base)) + let post_keys = '' + Tlibtrace 'tlib', 'while', world.state + let time01 = str2float(reltimestr(reltime())) + Tlibtrace 'tlib', time01, time01 - time0 + try + let world = s:RunStateHandlers(world) + + let time02 = str2float(reltimestr(reltime())) + Tlibtrace 'tlib', time02, time02 - time0 + if world.state =~ '\' + call world.Reset() + continue + endif + + call s:SetOffset(world) + + let time02 = str2float(reltimestr(reltime())) + Tlibtrace 'tlib', time02, time02 - time0 + Tlibtrace 'tlib', world.state + if world.state == 'scroll' + let world.prefidx = world.offset + let world.state = 'redisplay' + endif + + if world.state =~ '\' + let world.sticky = 1 + endif + + Tlibtrace 'tlib', world.filter + Tlibtrace 'tlib', world.sticky + if world.state =~ '\' + Tlibtrace 'tlib', world.rv + throw 'picked' + elseif world.state =~ '\' + let world.rv = world.CurrentItem() + Tlibtrace 'tlib', world.rv + throw 'picked' + elseif world.state =~ 'display' + if world.state =~ '^display' + let time03 = str2float(reltimestr(reltime())) + Tlibtrace 'tlib', time03, time03 - time0 + if world.IsValidFilter() + let time1 = str2float(reltimestr(reltime())) + Tlibtrace 'tlib', time1, time1 - time0 + call world.BuildTableList() + let time2 = str2float(reltimestr(reltime())) + Tlibtrace 'tlib', time2, time2 - time0 + let world.llen = len(world.list) + if empty(world.index_table) + let dindex = range(1, world.llen) + let world.index_width = len(world.llen) + else + let dindex = world.index_table + let world.index_width = len(max(dindex)) + endif + let time3 = str2float(reltimestr(reltime())) + Tlibtrace 'tlib', time3, time3 - time0 + if world.llen == 0 && !world.show_empty + call world.ReduceFilter() + let world.offset = 1 + continue + else + if world.llen == 1 + let world.last_item = world.list[0] + if world.pick_last_item >= 2 + " echom 'Pick last item: '. world.list[0] + let world.prefidx = '1' + throw 'pick' + endif + else + let world.last_item = '' + endif + endif + let time4 = str2float(reltimestr(reltime())) + Tlibtrace 'tlib', time4, time4 - time0 + Tlibtrace 'tlib', world.idx, world.llen, world.state + if world.state == 'display' + if world.idx == '' && world.llen < g:tlib#input#sortprefs_threshold && !world.FilterIsEmpty() + call world.SetPrefIdx() + else + let world.prefidx = world.idx == '' ? world.initial_index : world.idx + endif + if world.prefidx > world.llen + let world.prefidx = world.llen + elseif world.prefidx < 1 + let world.prefidx = 1 + endif + endif + let time5 = str2float(reltimestr(reltime())) + Tlibtrace 'tlib', time5, time5 - time0 + Tlibtrace 'tlib', world.initial_index, world.prefidx + Tlibtrace 'tlib', len(world.list) + let dlist = world.DisplayFormat(world.list) + Tlibtrace 'tlib', world.prefidx + let time6 = str2float(reltimestr(reltime())) + Tlibtrace 'tlib', time6, time6 - time0 + if world.offset_horizontal > 0 + call map(dlist, 'tlib#string#Strcharpart(v:val, world.offset_horizontal)') + endif + let time7 = str2float(reltimestr(reltime())) + Tlibtrace 'tlib', time7, time7 - time0 + let dlist = map(range(0, world.llen - 1), 'printf("%0'. world.index_width .'d", dindex[v:val]) .": ". dlist[v:val]') + let time8 = str2float(reltimestr(reltime())) + Tlibtrace 'tlib', time8, time8 - time0 + + else + + let dlist = ['Malformed filter'] + + endif + else + if world.prefidx == 0 + let world.prefidx = 1 + endif + endif + Tlibtrace 'tlib', world.idx, world.prefidx + + Tlibtrace 'tlib', world.prefidx, world.offset + Tlibtrace 'tlib', world.initial_display, !tlib#char#IsAvailable() + if world.state =~ '\' || world.initial_display || !tlib#char#IsAvailable() + call world.DisplayList(world.Query(), dlist) + call world.FollowCursor() + let world.initial_display = 0 + endif + if world.state =~ '\' + let world.state = 'suspend' + else + let world.state = '' + endif + else + " if world.state == 'scroll' + " let world.prefidx = world.offset + " endif + call world.DisplayList() + if world.state == 'help' || world.state == 'printlines' + let world.state = 'display' + else + let world.state = '' + call world.FollowCursor() + endif + endif + " TAssert IsNotEmpty(world.scratch) + let world.list_wid = tlib#win#GetID() + let world.list_wnr = winnr() + + Tlibtrace 'tlib', world.state, world.next_state + if !empty(world.next_state) + let world.state = world.next_state + let world.next_state = '' + endif + + if world.state =~ '\' + let world = tlib#agent#SuspendToParentWindow(world, world.rv) + continue + endif + + if world.state =~ '\' + let query = matchstr(world.state, '\" + if v:mouse_win == world.list_wnr + let world.prefidx = world.GetLineIdx(v:mouse_lnum) + " let world.offset = world.prefidx + if empty(world.prefidx) + " call feedkeys(c, 't') + let c = s:GetModdedChar(world) + let world.state = 'help' + continue + endif + throw 'pick' + else + let post_keys = v:mouse_lnum .'gg'. v:mouse_col .'|'. c + if world.allow_suspend + let world = tlib#agent#SuspendToParentWindow(world, world.rv) + else + let world.state = 'exit empty' + endif + endif + elseif c == "\" + if v:mouse_win == world.list_wnr + call s:BuildMenu(world) + let world.state = 'redisplay' + if s:PopupmenuExists() == 1 + " if v:mouse_lnum != line('.') + " endif + let world.prefidx = world.GetLineIdx(v:mouse_lnum) + let world.next_state = 'eval[Waiting for popup menu ... Press ESC to continue]' + call world.DisplayList() + if line('w$') - v:mouse_lnum < 6 + popup ]TLibInputListPopupMenu + else + popup! ]TLibInputListPopupMenu + endif + endif + else + let post_keys = v:mouse_lnum .'gg'. v:mouse_col .'|'. c + if world.allow_suspend + let world = tlib#agent#SuspendToParentWindow(world, world.rv) + else + let world.state = 'exit empty' + endif + endif + Tlibtrace 'tlib', world.prefidx, world.state + elseif has_key(world.key_map[world.key_mode], 'unknown_key') + let agent = world.key_map[world.key_mode].unknown_key.agent + " let world = call(agent, [world, c]) + " call s:CheckAgentReturnValue(agent, world) + let world = s:CallAgent({'agent': agent}, world, c) + elseif c >= 32 + let world.state = 'display' + let numbase = get(world.numeric_chars, c, -99999) + Tlibtrace 'tlib', numbase, world.numeric_chars, c + if numbase != -99999 + let world.idx .= (c - numbase) + if len(world.idx) == world.index_width + let world.prefidx = world.idx + Tlibtrace 'tlib', world.prefidx + throw 'pick' + endif + else + let world.idx = '' + Tlibtrace 'tlib', world.filter + if world.llen > g:tlib#input#livesearch_threshold + let pattern = input('Filter: ', world.CleanFilter(world.filter[0][0]) . nr2char(c)) + if empty(pattern) + let world.state = 'exit empty' + else + call world.SetFrontFilter(pattern) + echo + endif + elseif c == 124 + call insert(world.filter[0], []) + else + call world.PushFrontFilter(c) + endif + " continue + if c == 45 && world.filter[0][0] == '-' + let world.state = 'redisplay' + end + endif + else + let world.state = 'redisplay' + " let world.state = 'continue' + endif + + catch /^picked$/ + call world.ClearAllMarks() + call world.MarkCurrent(world.prefidx) + let world.state = 'exit' + + catch /^pick$/ + call world.ClearAllMarks() + call world.MarkCurrent(world.prefidx) + let world.state = '' + + finally + if world.state =~ '\' + " if !world.allow_suspend + " echom "Cannot be suspended" + " let world.state = 'redisplay' + " endif + elseif !empty(world.list) && !empty(world.base) + if empty(world.state) + let world.rv = world.CurrentItem() + Tlibtrace 'tlib', world.state, world.rv + endif + for handler in world.post_handlers + let state = get(handler, 'postprocess', '') + Tlibtrace 'tlib', handler + Tlibtrace 'tlib', state + Tlibtrace 'tlib', world.state + if state == world.state + let agent = handler.agent + let [world, world.rv] = call(agent, [world, world.rv]) + Tlibtrace 'tlib', world.state, world.rv + call s:CheckAgentReturnValue(agent, world) + endif + endfor + endif + endtry + endwh + + Tlibtrace 'tlib', world.state + Tlibtrace 'tlib', len(world.list) + Tlibtrace 'tlib', world.sel_idx + Tlibtrace 'tlib', world.idx + Tlibtrace 'tlib', world.prefidx + Tlibtrace 'tlib', world.rv + if world.state =~ '\<\(empty\|escape\)\>' + let world.sticky = 0 + endif + if world.state =~ '\' + Tlibtrace 'tlib', world.prefidx + " exec world.prefidx + return + elseif world.state =~ '\' + " TLog "empty" + Tlibtrace 'tlib', world.type + if stridx(world.type, 'm') != -1 + return [] + elseif stridx(world.type, 'i') != -1 + return 0 + else + return '' + endif + elseif !empty(world.return_agent) + Tlibtrace 'tlib', world.return_agent + call world.CloseScratch(1) + " TAssert IsNotEmpty(world.scratch) + return call(world.return_agent, [world, world.GetSelectedItems(world.rv)]) + elseif stridx(world.type, 'w') != -1 + " TLog "return_world" + return world + elseif stridx(world.type, 'm') != -1 + " TLog "return_multi" + return world.GetSelectedItems(world.rv) + elseif stridx(world.type, 'i') != -1 + " TLog "return_index" + if empty(world.index_table) + return world.rv + else + return world.index_table[world.rv - 1] + endif + else + " TLog "return_else" + return world.rv + endif + + finally + call world.Leave() + + " Tlibtrace 'tlib', statusline + " let &l:statusline = statusline + " let &laststatus = laststatus + if &showmode != showmode + let &showmode = showmode + endif + silent! let @/ = lastsearch + let &l:scrolloff = scrolloff + if s:PopupmenuExists() == 1 + silent! aunmenu ]TLibInputListPopupMenu + endif + + Tlibtrace 'tlib', world.state + if world.state !~ '\' + " redraw + Tlibtrace 'tlib', world.sticky, bufnr("%") + if world.sticky + Tlibtrace 'tlib', world.bufnr + if world.scratch_split > 0 + if bufwinnr(world.bufnr) == -1 + call world.UseScratch() + endif + let world = tlib#agent#SuspendToParentWindow(world, world.GetSelectedItems(world.rv)) + endif + else + Tlibtrace 'tlib', world.state, world.win_id, world.bufnr + if world.CloseScratch(1) + Tlibtrace 'tlib', get(world,'winview','') + call tlib#win#SetLayout(world.winview) + endif + endif + endif + if world.state !~ '\' + call world.RestoreWindow() + endif + " for i in range(0,5) + " call getchar(0) + " endfor + echo + redraw! + if !empty(post_keys) + Tlibtrace 'tlib', post_keys + call feedkeys(post_keys) + endif + let world.state = '' + endtry +endf + + +function! s:CallAgent(handler, world, list) abort "{{{3 + let agent = a:handler.agent + let args = [a:world, a:list] + if has_key(a:handler, 'args') + let args += a:handler.args + endif + let world = call(agent, args) + Tlibtrace 'tlib', world.state, world.rv + call s:CheckAgentReturnValue(agent, world) + return world +endf + +function! s:GetModdedChar(world) "{{{3 + let [char, mode] = tlib#char#Get(a:world.timeout, a:world.timeout_resolution, 1) + if char !~ '\D' && char > 0 && mode != 0 + return printf("<%s-%s>", mode, char) + else + return char + endif +endf + + +function! s:Init(world, cmd) "{{{3 + Tlibtrace 'tlib', a:cmd + let a:world.initial_display = 1 + if a:cmd =~ '\' + let a:world.sticky = 1 + endif + if a:cmd =~ '^resume' + call a:world.UseInputListScratch() + let a:world.initial_index = line('.') + if a:cmd =~ '\' + let a:world.state = 'pick' + let a:world.prefidx = a:world.initial_index + else + call a:world.Retrieve(1) + endif + " if !empty(a:world.resume_state) + " let a:world.state = a:world.resume_state + " endif + elseif !a:world.initialized + Tlibtrace 'tlib', a:world.initialized, a:world.win_id, a:world.bufnr + let a:world.filetype = &filetype + let a:world.fileencoding = &fileencoding + call a:world.SetMatchMode(tlib#var#Get('tlib#input#filter_mode', 'wb')) + call a:world.Initialize() + if !has_key(a:world, 'key_mode') + let a:world.key_mode = 'default' + endif + Tlibtrace 'tlib', has_key(a:world,'key_map') + if has_key(a:world, 'key_map') + Tlibtrace 'tlib', has_key(a:world.key_map,a:world.key_mode) + if has_key(a:world.key_map, a:world.key_mode) + let a:world.key_map[a:world.key_mode] = extend( + \ a:world.key_map[a:world.key_mode], + \ copy(g:tlib#input#keyagents_InputList_s), + \ 'keep') + else + let a:world.key_map[a:world.key_mode] = copy(g:tlib#input#keyagents_InputList_s) + endif + else + let a:world.key_map = { + \ a:world.key_mode : copy(g:tlib#input#keyagents_InputList_s) + \ } + endif + Tlibtrace 'tlib', a:world.type + if stridx(a:world.type, 'm') != -1 + call extend(a:world.key_map[a:world.key_mode], g:tlib#input#keyagents_InputList_m, 'force') + endif + for key_mode in keys(a:world.key_map) + let a:world.key_map[key_mode] = map(a:world.key_map[key_mode], 'type(v:val) == 4 ? v:val : {"agent": v:val}') + endfor + Tlibtrace 'tlib', a:world.key_mode + if type(a:world.key_handlers) == 3 + call s:ExtendKeyMap(a:world, a:world.key_mode, a:world.key_handlers) + elseif type(a:world.key_handlers) == 4 + for [world_key_mode, world_key_handlers] in items(a:world.key_handlers) + call s:ExtendKeyMap(a:world, world_key_mode, world_key_handlers) + endfor + else + throw "tlib#input#ListW: key_handlers must be either a list or a dictionary" + endif + Tlibtrace 'tlib', a:world.type, a:world.key_map + if !empty(a:cmd) + let a:world.state .= ' '. a:cmd + endif + endif + Tlibtrace 'tlib', a:world.state, a:world.sticky +endf + + +function! s:ExtendKeyMap(world, key_mode, key_handlers) "{{{3 + for handler in a:key_handlers + let k = get(handler, 'key', '') + if !empty(k) + let a:world.key_map[a:key_mode][k] = handler + endif + endfor +endf + + +function! s:PopupmenuExists() + if !g:tlib#input#use_popup + \ || exists(':popup') != 2 + \ || !(has('gui_win32') || has('gui_gtk') || has('gui_gtk2')) + " \ || !has('gui_win32') + let rv = -1 + else + try + let rv = 1 + silent amenu ]TLibInputListPopupMenu + catch + let rv = 0 + endtry + endif + Tlibtrace 'tlib', rv + return rv +endf + + +function! s:BuildMenu(world) "{{{3 + if g:tlib#input#use_popup && s:PopupmenuExists() == 0 + call s:BuildItem('Pick\ selected\ item', {'key_name': '', 'eval': 'let world.state = "pick"'}) + call s:BuildItem('Cancel', {'key_name': '', 'agent': 'tlib#agent#Exit'}) + call s:BuildItem('Select', {'key_name': '#', 'agent': 'tlib#agent#Select'}) + call s:BuildItem('Select\ all', {'key_name': '', 'agent': 'tlib#agent#SelectAll'}) + call s:BuildItem('Reset\ list', {'key_name': '', 'agent': 'tlib#agent#Reset'}) + call s:BuildItem('-StandardEntries-', {'key': ":", 'eval': 'let world.state = "redisplay"'}) + for [key_mode, key_handlers] in items(a:world.key_map) + let keys = sort(keys(key_handlers)) + let mitems = {} + for key in keys + let handler = key_handlers[key] + let k = get(handler, 'key', '') + if !empty(k) && has_key(handler, 'help') && !empty(handler.help) + if empty(key_mode) || key_mode == 'default' + let mname = '' + else + let mname = escape(key_mode, ' .\') .'.' + endif + if has_key(handler, 'submenu') + let submenu = escape(handler.submenu, ' .\') + else + let submenu = '~' + endif + for mfield in ['menu', 'help', 'key_name', 'agent'] + if has_key(handler, mfield) + let mname .= escape(handler[mfield], ' .\') + break + endif + endfor + if !has_key(mitems, submenu) + let mitems[submenu] = {} + endif + let mitems[submenu][mname] = handler + endif + endfor + for msubname in sort(keys(mitems)) + let msubitems = mitems[msubname] + if msubname == '~' + let msubmname = '' + else + let msubmname = msubname .'.' + endif + for mname in sort(keys(msubitems)) + let msname = msubmname . mname + let handler = msubitems[mname] + call s:BuildItem(msname, handler) + " if has_key(handler, 'agent') + " call s:BuildItem(msname, {'agent': handler.agent}) + " else + " call s:BuildItem(msname, {'key': handler.key_name}) + " endif + endfor + endfor + endfor + endif +endf + + +function! s:BuildItem(menu, def) "{{{3 + if has('gui_win32') + let key_mode = 'c' + elseif has('gui_gtk') || has('gui_gtk2') + let key_mode = 'raw' + endif + for k in ['agent', 'eval', 'key_name', 'key'] + if has('gui_win32') + elseif has('gui_gtk') || has('gui_gtk') + if k == 'agent' || k == 'eval' + continue + endif + endif + try + if has_key(a:def, k) + let v = a:def[k] + if k == 'key' + if key_mode == 'c' + " echom 'DBG amenu' (']TLibInputListPopupMenu.'. a:menu) ':let c = "'. v .'"' + exec 'amenu' (']TLibInputListPopupMenu.'. a:menu) ':let c = "'. v .'"' + else + " echom 'DBG amenu' (']TLibInputListPopupMenu.'. a:menu) v + exec 'amenu' (']TLibInputListPopupMenu.'. a:menu) v + endif + elseif k == 'key_name' + if key_mode == 'c' + " echom 'DBG amenu' (']TLibInputListPopupMenu.'. a:menu) ':let c = "\'. v .'"' + exec 'amenu' (']TLibInputListPopupMenu.'. a:menu) ':let c = "\'. v .'"' + else + let key = v + " echom 'DBG amenu' (']TLibInputListPopupMenu.'. a:menu) key + exec 'amenu' (']TLibInputListPopupMenu.'. a:menu) key + endif + elseif k == 'agent' + " echom 'DBG amenu' (']TLibInputListPopupMenu.'. a:menu) ':let world.next_agent ='. string(v) .'' + exec 'amenu' (']TLibInputListPopupMenu.'. a:menu) ':let world.next_agent ='. string(v) .'' + elseif k == 'eval' + " echom 'DBG amenu' (']TLibInputListPopupMenu.'. a:menu) ':let world.next_eval ='. string(v) .'' + exec 'amenu' (']TLibInputListPopupMenu.'. a:menu) ':let world.next_eval ='. string(v) .'' + endif + return + endif + catch + endtry + endfor +endf + + +function! s:RunStateHandlers(world) "{{{3 + " Provide the variable "world" in the environment of an "exec" + " handler (ea). + let world = a:world + for handler in a:world.state_handlers + let eh = get(handler, 'state', '') + if !empty(eh) && a:world.state =~ eh + let ea = get(handler, 'exec', '') + if !empty(ea) + exec ea + else + let agent = get(handler, 'agent', '') + " let world = call(agent, [a:world, a:world.GetSelectedItems(a:world.CurrentItem())]) + " call s:CheckAgentReturnValue(agent, a:world) + let world = s:CallAgent({'agent': agent}, world, world.GetSelectedItems(world.CurrentItem())) + endif + endif + endfor + return world +endf + + +function! s:CheckAgentReturnValue(name, value) "{{{3 + if type(a:value) != 4 && !has_key(a:value, 'state') + echoerr 'Malformed agent: '. a:name + endif + return a:value +endf + + +function! s:SetOffset(world) "{{{3 + let llenw = len(a:world.base) - winheight(0) + 1 + if a:world.offset > llenw + let a:world.offset = llenw + endif + if a:world.offset < 1 + let a:world.offset = 1 + endif +endf + + +" Functions related to tlib#input#EditList(type, ...) "{{{2 + +" :def: function! tlib#input#EditList(query, list, ?timeout=0) +" Edit a list. +" +" EXAMPLES: > +" echo tlib#input#EditList('Edit:', [100,200,300]) +function! tlib#input#EditList(query, list, ...) "{{{3 + let handlers = a:0 >= 1 && !empty(a:1) ? a:1 : g:tlib#input#handlers_EditList + let default = a:0 >= 2 ? a:2 : [] + let timeout = a:0 >= 3 ? a:3 : 0 + Tlibtrace 'tlib', handlers + let rv = tlib#input#List('me', a:query, copy(a:list), handlers, default, timeout) + Tlibtrace 'tlib', rv + if empty(rv) + return a:list + else + let [success, list] = rv + return success ? list : a:list + endif +endf + + +function! tlib#input#Resume(name, pick, bufnr) "{{{3 + Tlibtrace 'tlib', a:name, a:pick + echo + if bufnr('%') != a:bufnr + if g:tlib#debug + echohl WarningMsg + echom "tlib#input#Resume: Internal error: Not in scratch buffer:" bufname('%') + echohl NONE + endif + let br = tlib#buffer#Set(a:bufnr) + endif + if !exists('b:tlib_'. a:name) + if g:tlib#debug + echohl WarningMsg + echom "tlib#input#Resume: Internal error: b:tlib_". a:name ." does not exist:" bufname('%') + echohl NONE + redir => varss + silent let b: + redir END + let vars = split(varss, '\n') + call filter(vars, 'v:val =~ "^b:tlib_"') + echom "DEBUG tlib#input#Resume" string(vars) + endif + else + call tlib#autocmdgroup#Init() + autocmd! TLib BufEnter + if b:tlib_{a:name}.state !~# 'display\>' + let b:tlib_{a:name}.state = 'redisplay' + endif + " call tlib#input#List('resume '. a:name) + let cmd = 'resume '. a:name + if a:pick >= 1 + let cmd .= ' pick' + if a:pick >= 2 + let cmd .= ' sticky' + end + endif + call tlib#input#ListW(b:tlib_{a:name}, cmd) + endif +endf + + +" :def: function! tlib#input#CommandSelect(command, ?keyargs={}) +" Take a command, view the output, and let the user select an item from +" its output. +" +" EXAMPLE: > +" command! TMarks exec 'norm! `'. matchstr(tlib#input#CommandSelect('marks'), '^ \+\zs.') +" command! TAbbrevs exec 'norm i'. matchstr(tlib#input#CommandSelect('abbrev'), '^\S\+\s\+\zs\S\+') +function! tlib#input#CommandSelect(command, ...) "{{{3 + TVarArg ['args', {}] + if has_key(args, 'retrieve') + let list = call(args.retrieve) + elseif has_key(args, 'list') + let list = args.list + else + let list = tlib#cmd#OutputAsList(a:command) + endif + if has_key(args, 'filter') + call map(list, args.filter) + endif + let type = has_key(args, 'type') ? args.type : 's' + let handlers = has_key(args, 'handlers') ? args.handlers : [] + let rv = tlib#input#List(type, 'Select', list, handlers) + if !empty(rv) + if has_key(args, 'process') + let rv = call(args.process, [rv]) + endif + endif + return rv +endf + + +" :def: function! tlib#input#Edit(name, value, callback, ?cb_args=[]) +" +" Edit a value (asynchronously) in a scratch buffer. Use name for +" identification. Call callback when done (or on cancel). +" In the scratch buffer: +" Press or to enter the new value, c to cancel +" editing. +" EXAMPLES: > +" fun! FooContinue(success, text) +" if a:success +" let b:var = a:text +" endif +" endf +" call tlib#input#Edit('foo', b:var, 'FooContinue') +function! tlib#input#EditW(world, name, value, callback, ...) "{{{3 + Tlibtrace 'tlib', a:value + TVarArg ['args', []] + let sargs = {'scratch': '__EDIT__'. a:name .'__', 'win_id': tlib#win#GetID()} + let scr = tlib#scratch#UseScratch(sargs) + let b:tlib_world = a:world + + " :nodoc: + map c :call tlib#input#EditCallback(0) + " :nodoc: + imap c call tlib#input#EditCallback(0) + " :nodoc: + map :call tlib#input#EditCallback(1) + " :nodoc: + imap call tlib#input#EditCallback(1) + " :nodoc: + map :call tlib#input#EditCallback(1) + " :nodoc: + imap call tlib#input#EditCallback(1) + + call tlib#normal#WithRegister('gg"tdG', 't') + call append(1, split(a:value, "\", 1)) + " let hrm = 'DON''T DELETE THIS HEADER' + " let hr3 = repeat('"', (tlib#win#Width(0) - len(hrm)) / 2) + let s:horizontal_line = repeat('`', tlib#win#Width(0)) + " hr3.hrm.hr3 + let hd = ['Keys: , ... save/accept; c ... cancel', s:horizontal_line] + call append(1, hd) + call tlib#normal#WithRegister('gg"tdd', 't') + syntax match TlibEditComment /^\%1l.*/ + syntax match TlibEditComment /^```.*/ + hi link TlibEditComment Comment + exec len(hd) + 1 + if type(a:callback) == 4 + let b:tlib_scratch_edit_callback = get(a:callback, 'submit', '') + call call(get(a:callback, 'init', ''), []) + else + let b:tlib_scratch_edit_callback = a:callback + endif + let b:tlib_scratch_edit_args = args + let b:tlib_scratch_edit_scratch = sargs + " exec 'autocmd BufDelete,BufHidden,BufUnload call tlib#input#EditCallback('. string(a:name) .')' + " echohl MoreMsg + " echom 'Press to enter, c to cancel editing.' + " echohl NONE + let world = getbufvar(scr, 'tlib_world', a:world) + let world.state .= ' norestore' + return world +endf + + +function! tlib#input#EditCallback(...) "{{{3 + TVarArg ['ok', -1] + " , ['bufnr', -1] + " autocmd! BufDelete,BufHidden,BufUnload + if ok == -1 + let ok = confirm('Use value') + endif + let start = getline(2) == s:horizontal_line ? 3 : 1 + let text = ok ? join(getline(start, '$'), "\n") : '' + let cb = b:tlib_scratch_edit_callback + let args = b:tlib_scratch_edit_args + let sargs = b:tlib_scratch_edit_scratch + let world = b:tlib_world + Tlibtrace 'tlib', cb, args, sargs + call call(cb, args + [ok, text, world]) + call tlib#scratch#CloseScratch(b:tlib_scratch_edit_scratch) + call tlib#win#SetById(sargs.win_id) +endf + + +function! tlib#input#Dialog(text, options, default) "{{{3 + if has('dialog_con') || has('dialog_gui') + let opts = join(map(a:options, '"&". v:val'), "\n") + let val = confirm(a:text, opts) + if val + let yn = a:options[val - 1] + else + let yn = a:default + endif + else + let oi = index(a:options, a:default) + if oi == -1 + let opts = printf("(%s|%s)", join(a:options, '/'), a:default) + else + let options = copy(a:options) + let options[oi] = toupper(options[oi]) + let opts = printf("(%s)", join(a:options, '/')) + endif + let yn = inputdialog(a:text .' '. opts) + endif + return yn +endf + diff --git a/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/list.vim b/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/list.vim new file mode 100644 index 0000000..e3f681e --- /dev/null +++ b/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/list.vim @@ -0,0 +1,194 @@ +" list.vim +" @Author: Tom Link (micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2007-06-30. +" @Last Change: 2017-03-26. +" @Revision: 71 + + +""" List related functions {{{1 +" For the following functions please see ../../test/tlib.vim for examples. + +" :def: function! tlib#list#Inject(list, initial_value, funcref) abort +" EXAMPLES: > +" echo tlib#list#Inject([1,2,3], 0, function('Add') +" => 6 +function! tlib#list#Inject(list, value, Function) abort "{{{3 + if empty(a:list) + return a:value + else + let item = a:list[0] + let rest = a:list[1:-1] + let value = call(a:Function, [a:value, item]) + return tlib#list#Inject(rest, value, a:Function) + endif +endf + + +" EXAMPLES: > +" tlib#list#Compact([0,1,2,3,[], {}, ""]) +" => [1,2,3] +function! tlib#list#Compact(list) abort "{{{3 + return filter(copy(a:list), '!empty(v:val)') +endf + + +" EXAMPLES: > +" tlib#list#Flatten([0,[1,2,[3,""]]]) +" => [0,1,2,3,""] +function! tlib#list#Flatten(list) abort "{{{3 + let acc = [] + for e in a:list + if type(e) == 3 + let acc += tlib#list#Flatten(e) + else + call add(acc, e) + endif + unlet e + endfor + return acc +endf + + +" :def: function! tlib#list#FindAll(list, filter, ?process_expr="") abort +" Basically the same as filter() +" +" EXAMPLES: > +" tlib#list#FindAll([1,2,3], 'v:val >= 2') +" => [2, 3] +function! tlib#list#FindAll(list, filter, ...) abort "{{{3 + let rv = filter(copy(a:list), a:filter) + if a:0 >= 1 && !empty(a:1) + let rv = map(rv, a:1) + endif + return rv +endf + + +" :def: function! tlib#list#Find(list, filter, ?default="", ?process_expr="") abort +" +" EXAMPLES: > +" tlib#list#Find([1,2,3], 'v:val >= 2') +" => 2 +function! tlib#list#Find(list, filter, ...) abort "{{{3 + let default = a:0 >= 1 ? a:1 : '' + let expr = a:0 >= 2 ? a:2 : '' + return get(tlib#list#FindAll(a:list, a:filter, expr), 0, default) +endf + + +" EXAMPLES: > +" tlib#list#Any([1,2,3], 'v:val >= 2') +" => 1 +function! tlib#list#Any(list, expr) abort "{{{3 + return !empty(tlib#list#FindAll(a:list, a:expr)) +endf + + +" EXAMPLES: > +" tlib#list#All([1,2,3], 'v:val >= 2') +" => 0 +function! tlib#list#All(list, expr) abort "{{{3 + return len(tlib#list#FindAll(a:list, a:expr)) == len(a:list) +endf + + +" EXAMPLES: > +" tlib#list#Remove([1,2,1,2], 2) +" => [1,1,2] +function! tlib#list#Remove(list, element) abort "{{{3 + let idx = index(a:list, a:element) + if idx != -1 + call remove(a:list, idx) + endif + return a:list +endf + + +" EXAMPLES: > +" tlib#list#RemoveAll([1,2,1,2], 2) +" => [1,1] +function! tlib#list#RemoveAll(list, element) abort "{{{3 + call filter(a:list, 'v:val != a:element') + return a:list +endf + + +" :def: function! tlib#list#Zip(lists, ?default='') abort +" EXAMPLES: > +" tlib#list#Zip([[1,2,3], [4,5,6]]) +" => [[1,4], [2,5], [3,6]] +function! tlib#list#Zip(lists, ...) abort "{{{3 + TVarArg 'default' + let lists = copy(a:lists) + let max = 0 + for l in lists + let ll = len(l) + if ll > max + let max = ll + endif + endfor + " TLogVAR default, max + return map(range(0, max - 1), 's:GetNthElement(v:val, lists, default)') +endf + +function! s:GetNthElement(n, lists, default) abort "{{{3 + " TLogVAR a:n, a:lists, a:default + return map(copy(a:lists), 'get(v:val, a:n, a:default)') +endf + + +function! tlib#list#Uniq(list, ...) abort "{{{3 + " TLogVAR a:list + TVarArg ['get_value', ''], ['remove_empty', 0] + if remove_empty + call filter(a:list, 'type(v:val) == 0 || !empty(v:val)') + endif + " CREDITS: Based on syntastic#util#unique(list) by scrooloose + let emptystring = 0 + let seen = {} + let uniques = [] + if empty(get_value) + for e in a:list + if empty(e) + if !emptystring + let emptystring = 1 + call add(uniques, e) + endif + elseif !has_key(seen, e) + let seen[e] = 1 + call add(uniques, e) + endif + unlet e + endfor + else + for e in a:list + let v = eval(printf(get_value, string(e))) + if empty(v) + if !emptystring + let emptystring = 1 + call add(uniques, v) + endif + elseif !has_key(seen, v) + let seen[v] = 1 + call add(uniques, v) + endif + unlet e v + endfor + endif + return uniques +endf + + +function! tlib#list#ToDictionary(list, default, ...) abort "{{{3 + TVarArg ['generator', ''] + let dict = {} + for item in a:list + if !empty(item) + let dict[item] = empty(generator) ? a:default : call(generator, [item, a:default]) + endif + endfor + return dict +endf + diff --git a/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/loclist.vim b/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/loclist.vim new file mode 100644 index 0000000..198dd1b --- /dev/null +++ b/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/loclist.vim @@ -0,0 +1,13 @@ +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Last Change: 2015-10-24 +" @Revision: 2 + + +function! tlib#loclist#Browse(...) abort "{{{3 + let list = getloclist(0) + return call(function('tlib#qfl#QflList'), [list] + a:000) +endf + + diff --git a/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/map.vim b/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/map.vim new file mode 100644 index 0000000..c1af13f --- /dev/null +++ b/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/map.vim @@ -0,0 +1,23 @@ +" map.vim +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2009-08-23. +" @Last Change: 2009-08-23. +" @Revision: 0.0.4 + +let s:save_cpo = &cpo +set cpo&vim + + +" If |pumvisible()| is true, return "\". Otherwise return a:key. +" For use in maps like: > +" imap tlib#map#PumAccept("\") +function! tlib#map#PumAccept(key) "{{{3 + return pumvisible() ? "\" : a:key +endf + + + +let &cpo = s:save_cpo +unlet s:save_cpo diff --git a/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/normal.vim b/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/normal.vim new file mode 100644 index 0000000..faaa444 --- /dev/null +++ b/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/normal.vim @@ -0,0 +1,34 @@ +" normal.vim +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2008-10-06. +" @Last Change: 2010-09-22. +" @Revision: 28 + +let s:save_cpo = &cpo +set cpo&vim + + +" :display: tlib#normal#WithRegister(cmd, ?register='t', ?norm_cmd='norm!') +" Execute a normal command while maintaining all registers. +function! tlib#normal#WithRegister(cmd, ...) "{{{3 + TVarArg ['register', 't'], ['norm_cmd', 'norm!'] + let registers = {} + for reg in split('123456789'. register, '\zs') + exec 'let registers[reg] = @'. reg + endfor + exec 'let reg = @'. register + try + exec norm_cmd .' '. a:cmd + exec 'return @'. register + finally + for [reg, value] in items(registers) + exec 'let @'. reg .' = value' + endfor + endtry +endf + + +let &cpo = s:save_cpo +unlet s:save_cpo diff --git a/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/notify.vim b/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/notify.vim new file mode 100644 index 0000000..d12d109 --- /dev/null +++ b/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/notify.vim @@ -0,0 +1,113 @@ +" notify.vim +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2008-09-19. +" @Last Change: 2017-09-28. +" @Revision: 3.3.19 + +let s:save_cpo = &cpo +set cpo&vim + + +" :display: tlib#notify#Echo(text, ?style='') +" Print text in the echo area. Temporarily disable 'ruler' and 'showcmd' +" in order to prevent |press-enter| messages. +function! tlib#notify#Echo(text, ...) + TVarArg 'style' + let ruler = &ruler + let showcmd = &showcmd + let text = substitute(a:text, '\n', '|', 'g') + try + set noruler + set noshowcmd + if !empty(style) + exec 'echohl' style + endif + echo tlib#string#Strcharpart(text, 0, &columns - 1) + finally + if !empty(style) + echohl None + endif + let &ruler = ruler + let &showcmd = showcmd + endtry +endf + + +" Contributed by Erik Falor: +" If the line containing the message is too long, echoing it will cause +" a 'Hit ENTER' prompt to appear. This function cleans up the line so +" that does not happen. +" The echoed line is too long if it is wider than the width of the +" window, minus cmdline space taken up by the ruler and showcmd +" features. +function! tlib#notify#TrimMessage(message) "{{{3 + let filler = '...' + + " If length of message with tabs converted into spaces + length of + " line number + 2 (for the ': ' that follows the line number) is + " greater than the width of the screen, truncate in the middle + let to_fill = &columns + " TLogVAR to_fill + + " Account for space used by elements in the command-line to avoid + " 'Hit ENTER' prompts. + " If showcmd is on, it will take up 12 columns. + " If the ruler is enabled, but not displayed in the statusline, it + " will in its default form take 17 columns. If the user defines a + " custom &rulerformat, they will need to specify how wide it is. + if has('cmdline_info') + if &showcmd + let to_fill -= 12 + else + let to_fill -= 1 + endif + " TLogVAR &showcmd, to_fill + + " TLogVAR &laststatus, &ruler, &rulerformat + if &ruler + if &laststatus == 0 || winnr('$') == 1 + if has('statusline') + if &rulerformat == '' + " default ruler is 17 chars wide + let to_fill -= 17 + elseif exists('g:MP_rulerwidth') + let to_fill -= g:MP_rulerwidth + else + " tml: fallback: guess length + let to_fill -= strlen(&rulerformat) + endif + else + endif + endif + else + endif + else + let to_fill -= 1 + endif + + " TLogVAR to_fill + " TLogDBG strlen(a:message) + if strlen(a:message) > to_fill + let front = to_fill / 2 - 1 + let back = front + if to_fill % 2 == 0 | let back -= 1 | endif + return tlib#string#Strcharpart(a:message, 0, front) . filler . + \ tlib#string#Strcharpart(a:message, strlen(a:message) - back) + else + return a:message + endif +endfunction + + +function! tlib#notify#PrintError() abort "{{{3 + echohl ErrorMsg + echom v:exception + echom v:throwpoint + echohl NONE +endf + + +let &cpo = s:save_cpo +unlet s:save_cpo diff --git a/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/number.vim b/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/number.vim new file mode 100644 index 0000000..54cddc5 --- /dev/null +++ b/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/number.vim @@ -0,0 +1,29 @@ +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Revision: 18 + + +function! tlib#number#ConvertBase(num, base, ...) "{{{3 + let rtype = a:0 >= 1 ? a:1 : 'string' + if a:base > 36 + throw 'tlib#number#ConvertBase: base > 36 is not supported' + endif + " TLogVAR a:num, a:base, rtype + let rv = [] + let num = 0.0 + a:num + let chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" + while floor(num) > 0.0 + let div = floor(num / a:base) + let num1 = float2nr(num - a:base * div) + call insert(rv, chars[num1]) + let num = num / a:base + endwh + " TLogVAR rv + if rtype == 'list' + return rv + else + return join(rv, '') + endif +endf + + diff --git a/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/paragraph.vim b/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/paragraph.vim new file mode 100644 index 0000000..dd0d112 --- /dev/null +++ b/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/paragraph.vim @@ -0,0 +1,97 @@ +" paragraph.vim +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2009-10-26. +" @Last Change: 2011-04-03. +" @Revision: 62 + +let s:save_cpo = &cpo +set cpo&vim + + +" Return an object describing a |paragraph|. +function! tlib#paragraph#GetMetric() "{{{3 + let sp = {'text_start': line("'{") + 1} + if line("'}") == line("$") + let sp.last = 1 + let sp.text_end = line("'}") + if line("'{") == 1 + let sp.ws_start = 0 + let sp.ws_end = 0 + let sp.top = sp.text_start + let sp.bottom = sp.text_end + else + let sp.ws_start = prevnonblank(line("'{")) + 1 + let sp.ws_end = line("'{") + let sp.top = sp.ws_start + let sp.bottom = sp.text_end + endif + else + let sp.last = 0 + let sp.text_end = line("'}") - 1 + let sp.ws_start = line("'}") + for i in range(line("'}"), line('$')) + if getline(i) =~ '\w' + let sp.ws_end = i - 1 + break + elseif i == line("$") + let sp.ws_end = i + endif + endfor + let sp.top = sp.text_start + let sp.bottom = sp.ws_end + endif + return sp +endf + + +" This function can be used with the tinymode plugin to move around +" paragraphs. +" +" Example configuration: > +" +" call tinymode#EnterMap("para_move", "gp") +" call tinymode#ModeMsg("para_move", "Move paragraph: j/k") +" call tinymode#Map("para_move", "j", "silent call tlib#paragraph#Move('Down', '[N]')") +" call tinymode#Map("para_move", "k", "silent call tlib#paragraph#Move('Up', '[N]')") +" call tinymode#ModeArg("para_move", "owncount", 1) +function! tlib#paragraph#Move(direction, count) + " TLogVAR a:direction, a:count + let mycount = empty(a:count) ? 1 : a:count + for i in range(1, mycount) + let para = tlib#paragraph#GetMetric() + " TLogVAR para + let text = getline(para.text_start, para.text_end) + let ws = getline(para.ws_start, para.ws_end) + " TLogVAR text, ws + exec para.top .','. para.bottom .'delete' + if a:direction == "Down" + let other = tlib#paragraph#GetMetric() + let target = other.bottom + 1 + if other.last + let lines = ws + text + let pos = target + len(ws) + else + let lines = text + ws + let pos = target + endif + elseif a:direction == "Up" + if !para.last + norm! { + endif + let other = tlib#paragraph#GetMetric() + let target = other.text_start + let lines = text + ws + let pos = target + endif + " TLogVAR other, target + " TLogVAR lines + call append(target - 1, lines) + exec pos + endfor +endf + + +let &cpo = s:save_cpo +unlet s:save_cpo diff --git a/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/persistent.vim b/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/persistent.vim new file mode 100644 index 0000000..8e633a6 --- /dev/null +++ b/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/persistent.vim @@ -0,0 +1,54 @@ +" persistent.vim -- Persistent data +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2012-05-11. +" @Last Change: 2017-03-29. +" @Revision: 15 + +" The directory for persistent data files. If empty, use +" |tlib#dir#MyRuntime|.'/share'. +TLet g:tlib_persistent = '' + + +" :display: tlib#persistent#Dir(?mode = 'bg') +" Return the full directory name for persistent data files. +function! tlib#persistent#Dir() "{{{3 + TVarArg ['mode', 'bg'] + let dir = tlib#var#Get('tlib_persistent', mode) + if empty(dir) + let dir = tlib#file#Join([tlib#dir#MyRuntime(), 'share']) + endif + return dir +endf + +" :display: tlib#persistent#EncodedFilename(type, file, ?mkdir=0, ?dir='') +" Encode `file` and call |tlib#persistent#Filename()|. +function! tlib#persistent#EncodedFilename(type, file, ...) "{{{3 + let file = tlib#url#Encode(a:file) + return call(function('tlib#persistent#Filename'), [a:type, file] + a:000) +endf + +" :def: function! tlib#persistent#Filename(type, ?file=%, ?mkdir=0) +function! tlib#persistent#Filename(type, ...) "{{{3 + " TLogDBG 'bufname='. bufname('.') + let file = a:0 >= 1 ? a:1 : '' + let mkdir = a:0 >= 2 ? a:2 : 0 + return tlib#cache#Filename(a:type, file, mkdir, tlib#persistent#Dir()) +endf + +function! tlib#persistent#Get(...) "{{{3 + return call('tlib#cache#Get', a:000) +endf + +function! tlib#persistent#MTime(cfile) "{{{3 + return tlib#cache#MTime(a:cfile) +endf + +function! tlib#persistent#Value(...) "{{{3 + return call('tlib#cache#Value', a:000) +endf + +function! tlib#persistent#Save(...) "{{{3 + call call(function('tlib#cache#Save'), a:000) +endf + diff --git a/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/progressbar.vim b/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/progressbar.vim new file mode 100644 index 0000000..c7e1f86 --- /dev/null +++ b/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/progressbar.vim @@ -0,0 +1,95 @@ +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Revision: 86 + +let s:id = 0 +let s:ids = [] +let s:statusline = [] +let s:laststatus = [] +let s:max = [] +let s:format = [] +let s:width = [] +let s:value = [] +let s:timestamp = -1 + +" EXAMPLE: > +" call tlib#progressbar#Init(20) +" try +" for i in range(20) +" call tlib#progressbar#Display(i) +" call DoSomethingThatTakesSomeTime(i) +" endfor +" finally +" call tlib#progressbar#Restore() +" endtry +function! tlib#progressbar#Init(max, ...) "{{{3 + TVarArg ['format', '%s'], ['width', 10] + let s:id += 1 + call insert(s:ids, s:id) + call insert(s:statusline, &statusline) + call insert(s:laststatus, &laststatus) + call insert(s:max, a:max) + call insert(s:format, format) + call insert(s:width, width) + call insert(s:value, -1) + let sl = { + \ 'id': s:id, + \ 'statusline': &statusline, + \ 'laststatus': &laststatus, + \ 'max': a:max, + \ 'format': format, + \ 'width': width, + \ 'value': -1 + \ } + let &laststatus = 2 + let s:timestamp = localtime() + return sl +endf + + +function! tlib#progressbar#Restore(...) "{{{3 + if a:0 >= 1 + let sl = a:1 + let idx = index(s:ids, sl.id) + let &statusline = sl.statusline + let &laststatus = sl.laststatus + else + let idx = 0 + let &statusline = remove(s:statusline, idx) + let &laststatus = remove(s:laststatus, idx) + endif + call remove(s:ids, idx) + call remove(s:max, idx) + call remove(s:format, idx) + call remove(s:width, idx) + call remove(s:value, idx) + redrawstatus + " redraw + " echo +endf + + +function! tlib#progressbar#Display(value, ...) "{{{3 + TVarArg 'extra', ['always', 0] + let ts = localtime() + if !always && ts == s:timestamp + return + else + let s:timestamp = ts + endif + let val = a:value * s:width[0] / s:max[0] + if always || val != s:value[0] + let s:value[0] = val + let pbl = repeat('#', val) + let pbr = repeat('.', s:width[0] - val) + let txt = printf(s:format[0], '['.pbl.pbr.']') . extra + let &statusline = txt + " TLogDBG txt + redrawstatus + " redraw + " call tlib#notify#Echo(txt) + endif +endf + + diff --git a/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/qfl.vim b/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/qfl.vim new file mode 100644 index 0000000..07eb941 --- /dev/null +++ b/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/qfl.vim @@ -0,0 +1,317 @@ +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @Website: https://github.com/tomtom +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Last Change: 2018-02-08 +" @Revision: 69 + +" :nodoc: +TLet g:tlib#qfl#world = { + \ 'type': 'mi', + \ 'query': 'Select entry', + \ 'pick_last_item': 0, + \ 'resize_vertical': 0, + \ 'resize': 20, + \ 'scratch': '__TLibQFL__', + \ 'tlib_UseInputListScratch': 'call tlib#qfl#InitListBuffer(world)', + \ 'key_handlers': [ + \ {'key': 5, 'agent': 'tlib#qfl#AgentWithSelected', 'key_name': '', 'help': 'Run a command on selected lines'}, + \ {'key': 16, 'agent': 'tlib#qfl#AgentPreviewQFE', 'key_name': '', 'help': 'Preview'}, + \ {'key': 60, 'agent': 'tlib#qfl#AgentGotoQFE', 'key_name': '<', 'help': 'Jump (don''t close the list)'}, + \ {'key': 19, 'agent': 'tlib#qfl#AgentSplitBuffer', 'key_name': '', 'help': 'Show in split buffer'}, + \ {'key': 20, 'agent': 'tlib#qfl#AgentTabBuffer', 'key_name': '', 'help': 'Show in tab'}, + \ {'key': 22, 'agent': 'tlib#qfl#AgentVSplitBuffer', 'key_name': '', 'help': 'Show in vsplit buffer'}, + \ {'key': 12, 'agent': 'tlib#qfl#AgentEditLine', 'key_name': '', 'help': 'Edit selected line(s)'}, + \ {'key': "\", 'agent': 'tlib#qfl#SetFollowCursor', 'key_name': '', 'help': 'Toggle trace cursor'}, + \ ], + \ 'return_agent': 'tlib#qfl#AgentEditQFE', + \ } + + +function! tlib#qfl#FormatQFLE(qfe) dict abort "{{{3 + let filename = tlib#qfl#QfeFilename(a:qfe) + let short_filename = get(self, 'qfl_short_filename', '') + if short_filename ==# 'basename' + let filename = matchstr(filename, '[^\\/]\+$') + elseif !empty(short_filename) + let filename = pathshorten(filename) + endif + return printf("%s|%d| %s", filename, a:qfe.lnum, get(a:qfe, "text")) +endf + + +function! tlib#qfl#QfeFilename(qfe) abort "{{{3 + let filename = get(a:qfe, 'filename') + if empty(filename) + let filename = bufname(get(a:qfe, 'bufnr')) + endif + return filename +endf + + +function! tlib#qfl#InitListBuffer(world) "{{{3 + let set_syntax = get(a:world, 'set_syntax', 'tlib#qfl#SetSyntax') + call call(set_syntax, [], a:world) + if has('balloon_eval') + setlocal ballooneval balloonexpr=tlib#qfl#Balloon() + endif +endf + + +function! tlib#qfl#SetSyntax() dict abort "{{{3 + let syntax = get(self, 'qfl_list_syntax', '') + let nextgroup = get(self, 'qfl_list_syntax_nextgroup', '') + " TLogVAR syntax, nextgroup + if !empty(syntax) + exec printf('runtime syntax/%s.vim', syntax) + endif + syn match TTagedFilesFilename /\%(\f\+\| \)\+\ze|\d\+| / nextgroup=TTagedFilesLNum + if !empty(nextgroup) + exec 'syn match TTagedFilesLNum /|\d\+|\s\+/ nextgroup='. nextgroup + else + syn match TTagedFilesLNum /|\d\+|/ + endif + hi def link TTagedFilesFilename Directory + hi def link TTagedFilesLNum LineNr +endf + + +function! tlib#qfl#Balloon() "{{{3 + let world = getbufvar(v:beval_bufnr, 'tlibDisplayListWorld') + let current = max([1, world.offset]) + v:beval_lnum - 1 + if current > len(world.table) + let current = len(world.table) + endif + let baseidx = world.GetBaseIdx0(current) + " TLogVAR world.offset, v:beval_lnum, current, baseidx + let item = world.data[baseidx] + let bufnr = get(item, 'bufnr', 0) + let bufname = get(item, 'filename', '') + if bufnr == 0 && !empty(bufname) + let bufnr = bufnr(bufname) + endif + if empty(bufname) && bufnr > 0 + let bufname = bufname(bufnr) + endif + " TLogVAR item + if bufnr == 0 + return '' + else + let lines = [printf("%d#%d: %s", bufnr, item.lnum, bufname)] + if has('balloon_multiline') + let desc = {'nr': 'Error number', 'type': 'Error type', 'text': ''} + for key in ['nr', 'type', 'text'] + if has_key(item, key) && !empty(item[key]) + let keydesc = get(desc, key, key) + if empty(keydesc) + let text = item[key] + else + let text = printf("%s: %s", key, item[key]) + endif + call add(lines, text) + endif + endfor + endif + return join(lines, "\n") + endif + " v:beval_bufnr number of the buffer in which balloon is going to show + " v:beval_winnr number of the window + " v:beval_lnum line number + " v:beval_col column number (byte index) + " v:beval_text word under or after the mouse pointer +endf + + +function! tlib#qfl#AgentEditQFE(world, selected, ...) "{{{3 + TVarArg ['cmd_edit', ''], ['cmd_buffer', ''], ['set_origin', 1] + " TVarArg ['cmd_edit', 'edit'], ['cmd_buffer', 'buffer'] + " TLogVAR a:selected + if empty(a:selected) + " call a:world.RestoreOrigin() + " call a:world.ResetSelected() + else + call a:world.RestoreOrigin() + for idx in a:selected + let idx -= 1 + " TLogVAR idx + if idx >= 0 + " TLogVAR a:world.data + " call tlog#Debug(string(map(copy(a:world.data), 'v:val.bufnr'))) + " TLogVAR idx, a:world.data[idx] + let qfe = a:world.data[idx] + " let back = a:world.SwitchWindow('win') + " TLogVAR cmd_edit, cmd_buffer, qfe + let fn = tlib#qfl#QfeFilename(qfe) + " TLogVAR cmd_edit, cmd_buffer, fn + if empty(cmd_edit) && empty(cmd_buffer) + if tlib#file#Edit(fn) + call tlib#buffer#ViewLine(qfe.lnum) + endif + else + call tlib#file#With(cmd_edit, cmd_buffer, [fn], a:world) + " TLogDBG bufname('%') + " TLogVAR &filetype + call tlib#buffer#ViewLine(qfe.lnum) + " exec back + endif + endif + endfor + if set_origin + call a:world.SetOrigin() + endif + endif + return a:world +endf + + +function! tlib#qfl#AgentPreviewQFE(world, selected) "{{{3 + " TLogVAR a:selected + let back = a:world.SwitchWindow('win') + call tlib#qfl#AgentEditQFE(a:world, a:selected[0:0], '', '', 0) + exec back + redraw + let a:world.state = 'redisplay' + return a:world +endf + + +function! tlib#qfl#AgentGotoQFE(world, selected) "{{{3 + let world = a:world + if !empty(a:selected) + let world = tlib#agent#Suspend(world, a:selected) + call tlib#qfl#AgentEditQFE(world, a:selected[0:0]) + endif + return world +endf + + +function! tlib#qfl#AgentWithSelected(world, selected, ...) "{{{3 + let cmd = a:0 >= 1 ? a:1 : input('Ex command: ', '', 'command') + let world = a:world + if !empty(cmd) + let world = tlib#qfl#RunCmdOnSelected(world, a:selected, cmd) + else + let world.state = 'redisplay' + endif + return world +endf + + +function! tlib#qfl#RunCmdOnSelected(world, selected, cmd, ...) "{{{3 + let close_scratch = a:0 >= 1 ? a:1 : 1 + if close_scratch + call a:world.CloseScratch() + endif + " TLogVAR a:cmd + for entry in a:selected + " TLogVAR entry, a:world.GetBaseItem(entry) + call tlib#qfl#AgentEditQFE(a:world, [entry], '', '', 0) + " TLogDBG bufname('%') + exec a:cmd + " let item = a:world.data[a:world.GetBaseIdx(entry - 1)] + " <+TODO+> + let item = a:world.data[entry - 1] + " TLogVAR entry, item, getline('.') + if has_key(a:world, 'GetBufferLines') + let lines = a:world.GetBufferLines('.', '.') + else + let lines = getline('.', '.') + endif + let item['text'] = tlib#string#Strip(lines[0]) + endfor + if has_key(a:world, 'AfterRunCmd') + if bufnr('%') == a:world.bufnr + call a:world.AfterRunCmd() + else + " <+TODO+> Run in other buffer + endif + endif + " call s:FormatBase(a:world) + call a:world.RestoreOrigin() + let a:world.state = 'reset' + return a:world +endf + + +function! tlib#qfl#AgentSplitBuffer(world, selected) "{{{3 + call a:world.CloseScratch() + return tlib#qfl#AgentEditQFE(a:world, a:selected, 'split', 'sbuffer') +endf + + +function! tlib#qfl#AgentTabBuffer(world, selected) "{{{3 + call a:world.CloseScratch() + return tlib#qfl#AgentEditQFE(a:world, a:selected, 'tabedit', 'tab sbuffer') +endf + + +function! tlib#qfl#AgentVSplitBuffer(world, selected) "{{{3 + call a:world.CloseScratch() + return tlib#qfl#AgentEditQFE(a:world, a:selected, 'vertical split', 'vertical sbuffer') +endf + + +" function! tlib#qfl#AgentOpenBuffer(world, selected) "{{{3 +" endf + + +function! tlib#qfl#AgentEditLine(world, selected) "{{{3 + call a:world.CloseScratch() + let cmd = 'call tlib#qfl#EditLine(".")' + return tlib#qfl#RunCmdOnSelected(a:world, a:selected, cmd) + let a:world.state = 'reset' + return a:world +endf + + +function! tlib#qfl#EditLine(lnum) "{{{3 + call inputsave() + let line = input('', getline(a:lnum)) + call inputrestore() + if !empty(line) + call setline(line(a:lnum), line) + endif +endf + + +function! tlib#qfl#SetFollowCursor(world, selected) "{{{3 + if empty(a:world.follow_cursor) + let a:world.follow_cursor = 'tlib#qfl#AgentPreviewQFE' + else + let a:world.follow_cursor = '' + endif + let a:world.state = 'redisplay' + return a:world +endf + + +function! tlib#qfl#QflList(list, ...) abort "{{{3 + TVarArg ['world_dict', {}], ['anyway', 0], ['suspended', 0] + Tlibtrace 'tlib', world_dict, anyway, suspended + " TLogVAR a:list, world_dict, anyway, suspended + if !anyway && empty(a:list) + return + endif + let world = copy(g:tlib#qfl#world) + if !empty(world_dict) + let world = tlib#eval#Extend(world, world_dict) + endif + " TLogVAR world + let world = tlib#World#New(world) + " echom "DBG world" string(sort(keys(world))) + let world.data = copy(a:list) + if !has_key(world, 'format_data') + let world.format_data = 'tlib#qfl#FormatQFLE' + endif + " TLogVAR world + " TLogVAR world.data + " call s:FormatBase(world) + " TLogVAR world.base + return tlib#input#ListW(world, suspended ? 'hibernate' : '') +endf + + +function! tlib#qfl#Browse(...) abort "{{{3 + let list = getqflist() + return call(function('tlib#qfl#QflList'), [list] + a:000) +endf + diff --git a/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/rx.vim b/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/rx.vim new file mode 100644 index 0000000..08e6ae4 --- /dev/null +++ b/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/rx.vim @@ -0,0 +1,54 @@ +" @Author: Tom Link (micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Revision: 114 + + +" :def: function! tlib#rx#Escape(text, ?magic='m') +" magic can be one of: m, M, v, V +" See :help 'magic' +function! tlib#rx#Escape(text, ...) "{{{3 + TVarArg 'magic' + if empty(magic) + let magic = 'm' + endif + if magic =~# '^\\\?m$' + return escape(a:text, '^$.*\[]~') + elseif magic =~# '^\\\?M$' + return escape(a:text, '^$\') + elseif magic =~# '^\\\?V$' + return escape(a:text, '\') + elseif magic =~# '^\\\?v$' + return substitute(a:text, '[^0-9a-zA-Z_]', '\\&', 'g') + else + echoerr 'tlib: Unsupported magic type' + return a:text + endif +endf + +" :def: function! tlib#rx#EscapeReplace(text, ?magic='m') +" Escape return |sub-replace-special|. +function! tlib#rx#EscapeReplace(text, ...) "{{{3 + TVarArg ['magic', 'm'] + return escape(a:text, '\&~') +endf + + +function! tlib#rx#Suffixes(...) "{{{3 + TVarArg ['magic', 'm'] + let sfx = split(&suffixes, ',') + call map(sfx, 'tlib#rx#Escape(v:val, magic)') + if magic ==# 'v' + return '('. join(sfx, '|') .')$' + elseif magic ==# 'V' + return '\('. join(sfx, '\|') .'\)\$' + else + return '\('. join(sfx, '\|') .'\)$' + endif +endf + + +function! tlib#rx#LooksLikeRegexp(text) abort "{{{3 + return a:text =~ '[.?*+{}\[\]]' +endf + diff --git a/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/scratch.vim b/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/scratch.vim new file mode 100644 index 0000000..c9df64d --- /dev/null +++ b/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/scratch.vim @@ -0,0 +1,136 @@ +" @Author: Tom Link (micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Revision: 255 + + +" Scratch window position. By default the list window is opened on the +" bottom. Set this variable to 'topleft' or '' to change this behaviour. +" See |tlib#input#List()|. +TLet g:tlib_scratch_pos = 'botright' + +" If you want the scratch buffer to be fully removed, you might want to +" set this variable to 'wipe'. +" See also https://github.com/tomtom/tlib_vim/pull/16 +TLet g:tlib#scratch#hidden = 'hide' + + +" :def: function! tlib#scratch#UseScratch(?keyargs={}) +" Display a scratch buffer (a buffer with no file). See :TScratch for an +" example. +" Return the scratch buffer's number. +" Values for keyargs: +" scratch_split ... 1: split, 0: window, -1: tab +function! tlib#scratch#UseScratch(...) "{{{3 + exec tlib#arg#Let([['keyargs', {}]]) + " TLogDBG string(keys(keyargs)) + let id = get(keyargs, 'scratch', '__Scratch__') + " TLogVAR id, bufwinnr(id) + " TLogVAR bufnr(id), bufname(id) + " TLogVAR 1, winnr(), bufnr('%'), bufname("%") + if bufwinnr(id) != -1 + " echom 'DBG noautocmd keepalt keepj' bufwinnr(id) 'wincmd w' + exec 'noautocmd keepalt keepj' bufwinnr(id) 'wincmd w' + " TLogVAR "reuse", bufnr("%"), bufname("%") + else + let winpos = '' + let bn = bufnr(id) + let wpos = get(keyargs, 'scratch_pos', g:tlib_scratch_pos) + " TLogVAR keyargs.scratch_vertical + if get(keyargs, 'scratch_vertical') + let wpos .= ' vertical' + let winpos = tlib#fixes#Winpos() + endif + " TLogVAR wpos + let scratch_split = get(keyargs, 'scratch_split', 1) + if bn != -1 + " TLogVAR bn + let wn = bufwinnr(bn) + if wn != -1 + " TLogVAR wn + exec 'noautocmd keepalt keepj' (wn .'wincmd w') + else + if scratch_split == 1 + let cmd = wpos.' sbuffer!' + elseif scratch_split == -1 + let cmd = wpos.' tab sbuffer!' + else + let cmd = 'buffer!' + endif + " TLogVAR cmd, bn + silent exec 'noautocmd keepalt keepj' cmd bn + endif + else + " TLogVAR id + if scratch_split == 1 + let cmd = wpos.' split' + elseif scratch_split == -1 + let cmd = wpos.' tab split' + else + let cmd = 'edit' + endif + " TLogVAR cmd, id + silent exec 'noautocmd keepalt keepj' cmd escape(id, '%#\ ') + " silent exec 'split '. id + endif + let ft = get(keyargs, 'scratch_filetype', '') + " TLogVAR ft, winpos + if !empty(winpos) + exec winpos + endif + setlocal buftype=nofile + let &l:bufhidden = get(keyargs, 'scratch_hidden', g:tlib#scratch#hidden) + setlocal noswapfile + setlocal nobuflisted + setlocal foldmethod=manual + setlocal foldcolumn=0 + setlocal nospell + setlocal modifiable + setlocal noreadonly + " TLogVAR &ft, ft + if !empty(ft) + let &l:ft = ft + endif + endif + let keyargs.scratch = bufnr('%') + let keyargs.scratch_tabpagenr = tabpagenr() + let keyargs.scratch_winnr = winnr() + " TLogVAR 2, winnr(), bufnr('%'), bufname("%"), keyargs.scratch + return keyargs.scratch +endf + + +" Close a scratch buffer as defined in keyargs (usually a World). +" Return 1 if the scratch buffer is closed (or if it already was +" closed). +function! tlib#scratch#CloseScratch(keyargs, ...) "{{{3 + TVarArg ['reset_scratch', 1] + let scratch = get(a:keyargs, 'scratch', '') + " TLogVAR scratch, reset_scratch + " TLogDBG string(tlib#win#List()) + if !empty(scratch) && winnr('$') > 1 + let wn = bufwinnr(scratch) + " TLogVAR wn + try + if wn != -1 + " TLogDBG winnr() + let wb = tlib#win#Set(wn) + let winpos = tlib#fixes#Winpos() + wincmd c + if get(a:keyargs, 'scratch_vertical') && !empty(winpos) + exec winpos + endif + " exec wb + " redraw + " TLogVAR winnr() + endif + return 1 + finally + if reset_scratch + let a:keyargs.scratch = '' + endif + endtry + endif + return 0 +endf + diff --git a/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/selection.vim b/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/selection.vim new file mode 100644 index 0000000..e705f27 --- /dev/null +++ b/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/selection.vim @@ -0,0 +1,40 @@ +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Last Change: 2017-09-28 +" @Revision: 4 + + +" :display: tlib#selection#GetSelection(mode, ?mbeg="'<", ?mend="'>", ?opmode='selection') +" mode can be one of: selection, lines, block +function! tlib#selection#GetSelection(mode, ...) range "{{{3 + if a:0 >= 2 + let mbeg = a:1 + let mend = a:2 + else + let mbeg = "'<" + let mend = "'>" + endif + let opmode = a:0 >= 3 ? a:3 : 'selection' + let l0 = line(mbeg) + let l1 = line(mend) + let text = getline(l0, l1) + let c0 = col(mbeg) + let c1 = col(mend) + " TLogVAR mbeg, mend, opmode, l0, l1, c0, c1 + " TLogVAR text[-1] + " TLogVAR len(text[-1]) + if opmode == 'block' + let clen = c1 - c0 + call map(text, 'tlib#string#Strcharpart(v:val, c0, clen)') + elseif opmode == 'selection' + if c1 > 1 + let text[-1] = tlib#string#Strcharpart(text[-1], 0, c1 - (a:mode == 'o' || c1 > len(text[-1]) ? 0 : 1)) + endif + if c0 > 1 + let text[0] = tlib#string#Strcharpart(text[0], c0 - 1) + endif + endif + return text +endf + diff --git a/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/signs.vim b/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/signs.vim new file mode 100644 index 0000000..1664680 --- /dev/null +++ b/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/signs.vim @@ -0,0 +1,103 @@ +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2009-03-12. +" @Last Change: 2011-03-10. +" @Revision: 0.0.45 + +let s:save_cpo = &cpo +set cpo&vim + + +let s:base = 2327 +let s:register = {} + + +" Clear all signs with name SIGN. +function! tlib#signs#ClearAll(sign) "{{{3 + " TLog a:sign + for bn in keys(s:register) + let idxs = keys(s:register) + call filter(idxs, 's:register[v:val].sign == a:sign') + " TLogVAR bns + for idx in idxs + exec 'sign unplace '. idx .' buffer='. s:register[idx].bn + call remove(s:register, idx) + endfor + endfor +endf + + +" Clear all signs with name SIGN in buffer BUFNR. +function! tlib#signs#ClearBuffer(sign, bufnr) "{{{3 + for bn in keys(s:register) + let idxs = keys(s:register) + call filter(idxs, 's:register[v:val].sign == a:sign && s:register[v:val].bn == a:bufnr') + " TLogVAR bns + for idx in idxs + exec 'sign unplace '. idx .' buffer='. s:register[idx].bn + call remove(s:register, idx) + endfor + endfor +endf + + +" function! tlib#signs#Clear(sign, list) "{{{3 +" " TLogVAR a:sign +" let done = [] +" for item in a:list +" let bn = get(item, 'bufnr', -1) +" if index(done, bn) == -1 +" let idxs = keys(s:register) +" call filter(idxs, 's:register[v:val].sign == a:sign && s:register[v:val].bn == bn') +" for idx in idxs +" exec 'sign unplace '. idx .' buffer='. s:register[idx].bn +" call remove(s:register, idx) +" endfor +" call add(done, bn) +" endif +" endfor +" endf + + +" Add signs for all locations in LIST. LIST must adhere with the +" quickfix list format (see |getqflist()|; only the fields lnum and +" bufnr are required). +" +" list:: a quickfix or location list +" sign:: a sign defined with |:sign-define| +function! tlib#signs#Mark(sign, list) "{{{3 + " TLogVAR a:sign + for item in a:list + let idx = s:SignId(item) + if idx >= 0 + let lnum = get(item, 'lnum', 0) + if lnum > 0 + let bn = get(item, 'bufnr') + exec ':sign place '. idx .' line='. lnum .' name='. a:sign .' buffer='. bn + let s:register[idx] = {'sign': a:sign, 'bn': bn} + endif + endif + endfor +endf + + +function! s:SignId(item) "{{{3 + " TLogVAR a:item + " let bn = bufnr('%') + let bn = get(a:item, 'bufnr', -1) + if bn == -1 + return -1 + else + let idx = s:base + bn * 500 + while has_key(s:register, idx) + let idx += 1 + endwh + return idx + endif +endf + + + +let &cpo = s:save_cpo +unlet s:save_cpo diff --git a/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/string.vim b/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/string.vim new file mode 100644 index 0000000..c15420e --- /dev/null +++ b/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/string.vim @@ -0,0 +1,208 @@ +" @Author: Tom Link (micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Revision: 148 + + +" :def: function! tlib#string#RemoveBackslashes(text, ?chars=' ') +" Remove backslashes from text (but only in front of the characters in +" chars). +function! tlib#string#RemoveBackslashes(text, ...) "{{{3 + exec tlib#arg#Get(1, 'chars', ' ') + " TLogVAR chars + let rv = substitute(a:text, '\\\(['. chars .']\)', '\1', 'g') + return rv +endf + + +" :display: tlib#string#Chomp(string, ?max=0) +function! tlib#string#Chomp(string, ...) "{{{3 + let quant = a:0 >= 1 ? '\{,'. a:1 .'}' : '\+' + return substitute(a:string, '[[:cntrl:][:space:]]'. quant .'$', '', '') +endf + + +" Format a template string. Placeholders have the format "%{NAME}". A +" "%" can be inserted as "%%". +" +" Examples: +" echo tlib#string#Format("foo %{bar} foo", {'bar': 123}, ?prefix='%') +" => foo 123 foo +function! tlib#string#Format(template, dict, ...) "{{{3 + let prefix = a:0 >= 1 ? a:1 : '%' + let pesc = prefix . prefix + let prx = tlib#rx#Escape(prefix) + let parts = split(a:template, '\ze'. prx .'\({.\{-}}\|.\)') + let partrx = '^'. prx .'\({\(.\{-}\)}\|\(.\)\)\(.*\)$' + let out = [] + for part in parts + let ml = matchlist(part, partrx) + if empty(ml) + let rest = part + else + let var = empty(ml[2]) ? ml[3] : ml[2] + let rest = ml[4] + if has_key(a:dict, var) + call add(out, a:dict[var]) + elseif var ==# pesc + call add(out, prefix) + else + call add(out, ml[1]) + endif + endif + call add(out, rest) + endfor + return join(out, '') +endf + + +" This function deviates from |printf()| in certain ways. +" Additional items: +" %{rx} ... insert escaped regexp +" %{fuzzyrx} ... insert typo-tolerant regexp +function! tlib#string#Printf1(format, string) "{{{3 + let s = split(a:format, '%.\zs') + " TLogVAR s + return join(map(s, 's:PrintFormat(v:val, a:string)'), '') +endf + +function! s:PrintFormat(format, string) "{{{3 + let cut = match(a:format, '%\({.\{-}}\|.\)$') + if cut == -1 + return a:format + else + let head = cut > 0 ? a:format[0 : cut - 1] : '' + let tail = a:format[cut : -1] + " TLogVAR head, tail + if tail == '%{fuzzyrx}' + let frx = [] + for i in range(len(a:string)) + if i > 0 + let pb = i - 1 + else + let pb = 0 + endif + let slice = tlib#rx#Escape(a:string[pb : i + 1]) + call add(frx, '['. slice .']') + call add(frx, '.\?') + endfor + let tail = join(frx, '') + elseif tail == '%{rx}' + let tail = tlib#rx#Escape(a:string) + elseif tail == '%%' + let tail = '%' + elseif tail == '%s' + let tail = a:string + endif + " TLogVAR tail + return head . tail + endif +endf +" function! tlib#string#Printf1(format, string) "{{{3 +" let n = len(split(a:format, '%\@ 0 +" let pb = i - 1 +" else +" let pb = 0 +" endif +" let slice = tlib#rx#Escape(a:string[pb : i + 1]) +" call add(frx, '['. slice .']') +" call add(frx, '.\?') +" endfor +" let f = s:RewriteFormatString(f, '%{fuzzyrx}', join(frx, '')) +" endif +" if f =~ '%\@= 1 ? a:1 : ',\s*' + let parts = split(a:text, '\\\@= 1 ? a:1 : '' + Tlibtrace 'tlib', a:string, a:regexp, eregexp + let ms = [] + if a:regexp =~ '\\ze' + let regexp1 = substitute(a:regexp, '\\ze.*$', '', '') + else + let regexp1 = a:regexp + endif + for m in split(a:string, '\ze'. regexp1) + let m1 = matchstr(m, !empty(eregexp) ? eregexp : a:regexp) + Tlibtrace 'tlib', m, m1 + if !empty(m1) + call add(ms, m1) + endif + endfor + return ms +endf + +if exists('*strcharpart') + function! tlib#string#Strcharpart(...) abort "{{{3 + return call(function('strcharpart'), a:000) + endf +else + function! tlib#string#Strcharpart(...) abort "{{{3 + return call(function('strpart'), a:000) + endf +endif + diff --git a/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/syntax.vim b/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/syntax.vim new file mode 100644 index 0000000..aa30b66 --- /dev/null +++ b/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/syntax.vim @@ -0,0 +1,38 @@ +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Revision: 13 + + +function! tlib#syntax#Collect() "{{{3 + let acc = {} + let syn = '' + for line in tlib#cmd#OutputAsList('syntax') + if line =~ '^---' + continue + elseif line =~ '^\w' + let ml = matchlist(line, '^\(\w\+\)\s\+\(xxx\s\+\(.*\)\|\(cluster.*\)\)$') + if empty(ml) + " echoerr 'Internal error: '. string(line) + else + let [m_0, syn, m_1, m_def1, m_def2; m_rest] = ml + let acc[syn] = [empty(m_def1) ? m_def2 : m_def1] + endif + else + call add(acc[syn], matchstr(line, '^\s\+\zs.*$')) + endif + endfor + return acc +endf + + +" :def: function! tlib#syntax#Names(?rx='') +function! tlib#syntax#Names(...) "{{{3 + TVarArg 'rx' + let names = keys(tlib#syntax#Collect()) + if !empty(rx) + call filter(names, 'v:val =~ rx') + endif + return names +endf + diff --git a/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/sys.vim b/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/sys.vim new file mode 100644 index 0000000..667ecdc --- /dev/null +++ b/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/sys.vim @@ -0,0 +1,218 @@ +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Last Change: 2017-04-12. +" @Revision: 62 + + +if !exists('g:tlib#sys#special_protocols') + " A list of |regexp|s matching protocol names that should be handled + " by |g:tlib#sys#system_browser|. + " CAVEAT: Must be a |\V| |regexp|. + let g:tlib#sys#special_protocols = ['https\?', 'nntp', 'mailto'] "{{{2 +endif + + +if !exists('g:tlib#sys#special_suffixes') + " A list of |regexp|s matching suffixes that should be handled by + " |g:tlib#sys#system_browser|. + " CAVEAT: Must be a |\V| |regexp|. + let g:tlib#sys#special_suffixes = ['xlsx\?', 'docx\?', 'pptx\?', 'accdb', 'mdb', 'sqlite', 'pdf', 'jpg', 'png', 'gif', 'od\[tspg]'] "{{{2 +endif + + +if !exists('g:tlib#sys#system_rx') + " Open links matching this |regexp| with |g:tlib#sys#system_browser|. + " CAVEAT: Must be a |\V| |regexp|. + let g:tlib#sys#system_rx = printf('\V\%(\^\%(%s\):\|.\%(%s\)\$\)', join(g:tlib#sys#special_protocols, '\|'), join(g:tlib#sys#special_suffixes, '\|')) "{{{2 +endif + + +if !exists("g:tlib#sys#system_browser") + if exists('g:netrw_browsex_viewer') + " Open files in the system browser. + " :read: let g:tlib#sys#system_browser = ... "{{{2 + let g:tlib#sys#system_browser = "exec 'silent !'. g:netrw_browsex_viewer shellescape('%s')" + elseif has("win32") || has("win16") || has("win64") + " let g:tlib#sys#system_browser = "exec 'silent ! start \"\"' shellescape('%s')" + let g:tlib#sys#system_browser = "exec 'silent ! RunDll32.EXE URL.DLL,FileProtocolHandler' shellescape('%s')" + elseif has("mac") + let g:tlib#sys#system_browser = "exec 'silent !open' shellescape('%s')" + elseif exists('$XDG_CURRENT_DESKTOP') && !empty($XDG_CURRENT_DESKTOP) + let g:tlib#sys#system_browser = "exec 'silent !xdg-open' shellescape('%s') '&'" + elseif !empty($GNOME_DESKTOP_SESSION_ID) || $DESKTOP_SESSION ==# 'gnome' + let g:tlib#sys#system_browser = "exec 'silent !gnome-open' shellescape('%s')" + elseif exists("$KDEDIR") && !empty($KDEDIR) + let g:tlib#sys#system_browser = "exec 'silent !kfmclient exec' shellescape('%s')" + else + let g:tlib#sys#system_browser = '' + endif +endif + + +if !exists('g:tlib#sys#windows') + let g:tlib#sys#windows = &shell !~ 'sh' && (has('win16') || has('win32') || has('win64')) "{{{2 +endif + + +if !exists('g:tlib#sys#null') + let g:tlib#sys#null = g:tlib#sys#windows ? 'NUL' : (filereadable('/dev/null') ? '/dev/null' : '') "{{{2 +endif + + +let s:cygwin = {} + +function! tlib#sys#IsCygwinBin(cmd) "{{{3 + " TLogVAR a:cmd + if !g:tlib#sys#windows + return 0 + elseif has_key(s:cygwin, a:cmd) + let rv = s:cygwin[a:cmd] + else + if !tlib#sys#IsExecutable('cygpath', 1) || !tlib#sys#IsExecutable('which', 1) + let rv = 0 + else + let which = substitute(system('which '. shellescape(a:cmd)), '\n$', '', '') + " echom "DBG which:" which + if which =~ '^/' + let filename = system('cygpath -ma '. shellescape(which)) + " echom "DBG filename:" filename + let rv = filename =~ g:tlib#sys#cygwin_path_rx + else + let rv = 0 + endif + endif + let s:cygwin[a:cmd] = rv + endif + " TLogVAR rv + return rv +endf + + +let s:executables = {} + +function! tlib#sys#IsExecutable(cmd, ...) "{{{3 + " TLogVAR a:cmd + " echom "DBG has_key(s:executables, a:cmd)" has_key(s:executables, a:cmd) + if !has_key(s:executables, a:cmd) + let executable = executable(a:cmd) + " TLogVAR 1, executable + let ignore_cyg = a:0 >= 1 ? a:1 : !g:tlib#sys#windows + if !executable && !ignore_cyg + let executable = tlib#sys#IsCygwinBin(a:cmd) + " TLogVAR 2, executable + endif + let s:executables[a:cmd] = executable + endif + " echom "DBG s:executables[a:cmd]" s:executables[a:cmd] + return s:executables[a:cmd] +endf + + +if !exists('g:tlib#sys#check_cygpath') + " If true, check whether we have to convert a path via cyppath -- + " see |tlib#sys#MaybeUseCygpath| + let g:tlib#sys#check_cygpath = g:tlib#sys#windows && tlib#sys#IsExecutable('cygpath', 1) "{{{2 +endif + + +if !exists('g:tlib#sys#cygwin_path_rx') + " If a full windows filename (with slashes instead of backslashes) + " matches this |regexp|, it is assumed to be a cygwin executable. + let g:tlib#sys#cygwin_path_rx = '/cygwin/' "{{{2 +endif + + +if !exists('g:tlib#sys#cygwin_expr') + " For cygwin binaries, convert command calls using this vim + " expression. + let g:tlib#sys#cygwin_expr = '"bash -c ''". escape(%s, "''\\") ."''"' "{{{2 +endif + + +function! tlib#sys#GetCmd(cmd) "{{{3 + if !empty(g:tlib#sys#cygwin_expr) && tlib#sys#IsCygwinBin(matchstr(a:cmd, '^\S\+')) + let cmd = eval(printf(g:tlib#sys#cygwin_expr, string(a:cmd))) + " TLogVAR cmd + return cmd + else + return a:cmd + endif +endf + + +" If cmd seems to be a cygwin executable, use cygpath to convert +" filenames. This assumes that cygwin's which command returns full +" filenames for non-cygwin executables. +function! tlib#sys#MaybeUseCygpath(cmd) "{{{3 + " echom "DBG" a:cmd + if g:tlib#sys#check_cygpath && tlib#sys#IsCygwinBin(a:cmd) + return 'cygpath -u "%s"' + endif + return '' +endf + + +function! tlib#sys#ConvertPath(converter, filename) "{{{3 + return tlib#string#Chomp(system(printf(a:converter, shellescape(a:filename)))) +endf + + +let s:native_filenames = {} + +function! tlib#sys#FileArgs(cmd, files) "{{{3 + let cygpath = tlib#sys#MaybeUseCygpath(a:cmd) + " TLogVAR cygpath + if empty(cygpath) + return a:files + else + let files = map(copy(a:files), 'has_key(s:native_filenames, v:val) ? s:native_filenames[v:val] : tlib#sys#CygPath(v:val)') + return files + endif +endf + + +" Check whether filename matches |g:tlib#sys#system_rx|, i.e. whether it +" is a special file that should not be opened in vim. +function! tlib#sys#IsSpecial(filename) abort "{{{3 + return a:filename =~ g:tlib#sys#system_rx +endf + + +" Open filename with the default OS application (see +" |g:tlib#sys#system_browser|), if |tlib#sys#IsSpecial()| return 1. +" Returns 1 if successful or 0 otherwise. +function! tlib#sys#Open(filename) abort "{{{3 + Tlibtrace 'tlib', a:filename + if !empty(g:tlib#sys#system_browser) && tlib#sys#IsSpecial(a:filename) + try + call tlib#sys#OpenWithSystemViewer(a:filename) + return 1 + catch + echohl ErrorMsg + echom v:exception + echohl NONE + endtry + endif + return 0 +endf + + +" Open filename with the default system viewer. +function! tlib#sys#OpenWithSystemViewer(filename) abort "{{{3 + let cmd = printf(g:tlib#sys#system_browser, a:filename) + " let cmd = printf(g:tlib#sys#system_browser, escape(a:filename, ' %#!')) + Tlibtrace 'tlib', cmd + exec cmd +endf + + +" :def: function! tlib#sys#SystemInDir(dir, expr, ?input='') +function! tlib#sys#SystemInDir(dir, ...) abort "{{{3 + call tlib#dir#CD(a:dir) + try + return call(function('system'), a:000) + finally + silent cd! - + endtry +endf + diff --git a/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/tab.vim b/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/tab.vim new file mode 100644 index 0000000..fa6bb8d --- /dev/null +++ b/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/tab.vim @@ -0,0 +1,49 @@ +" @Author: Tom Link (micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Revision: 31 + + +" Return a dictionary of bufnumbers => [[tabpage, winnr] ...] +function! tlib#tab#BufMap() "{{{3 + let acc = {} + for t in range(tabpagenr('$')) + let bb = tabpagebuflist(t + 1) + for b in range(len(bb)) + let bn = bb[b] + let bd = [t + 1, b + 1] + if has_key(acc, bn) + call add(acc[bn], bd) + else + let acc[bn] = [bd] + endif + endfor + endfor + return acc +endf + + +" Find a buffer's window at some tab page. +function! tlib#tab#TabWinNr(buffer) "{{{3 + let bn = bufnr(a:buffer) + let bt = tlib#tab#BufMap() + let tn = tabpagenr() + let wn = winnr() + let bc = get(bt, bn) + if !empty(bc) + for [t, w] in bc + if t == tn + return [t, w] + endif + endfor + return bc[0] + endif +endf + + +function! tlib#tab#Set(tabnr) "{{{3 + if a:tabnr > 0 + exec a:tabnr .'tabnext' + endif +endf + diff --git a/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/tag.vim b/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/tag.vim new file mode 100644 index 0000000..b82643d --- /dev/null +++ b/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/tag.vim @@ -0,0 +1,133 @@ +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Revision: 64 + + +" Extra tags for |tlib#tag#Retrieve()| (see there). Can also be buffer-local. +TLet g:tlib_tags_extra = '' + +" Filter the tag description through |substitute()| for these filetypes. +" This applies only if the tag cmd field (see |taglist()|) is used. +" :nodefault: +TLet g:tlib_tag_substitute = { + \ 'java': [['\s*{\s*$', '', '']], + \ 'ruby': [['\<\(def\|class\|module\)\>\s\+', '', '']], + \ 'vim': [ + \ ['^\s*com\%[mand]!\?\(\s\+-\S\+\)*\s*\u\w*\zs.*$', '', ''], + \ ['^\s*\(let\|aug\%[roup]\|fu\%[nction]!\?\|com\%[mand]!\?\(\s\+-\S\+\)*\)\s*', '', ''], + \ ['"\?\s*{{{\d.*$', '', ''], + \ ], + \ } + + +" :def: function! tlib#tag#Retrieve(rx, ?extra_tags=0) +" Get all tags matching rx. Basically, this function simply calls +" |taglist()|, but when extra_tags is true, the list of the tag files +" (see 'tags') is temporarily expanded with |g:tlib_tags_extra|. +" +" Example use: +" If you want to include tags for, eg, JDK, normal tags use can become +" slow. You could proceed as follows: +" 1. Create a tags file for the JDK sources. When creating the tags +" file, make sure to include inheritance information and the like +" (command-line options like --fields=+iaSm --extra=+q should be ok). +" In this example, we want tags only for public methods (there are +" most likely better ways to do this): > +" ctags -R --fields=+iaSm --extra=+q ${JAVA_HOME}/src +" head -n 6 tags > tags0 +" grep access:public tags >> tags0 +" < 2. Make 'tags' include project specific tags files. In +" ~/vimfiles/after/ftplugin/java.vim insert: > +" let b:tlib_tags_extra = $JAVA_HOME .'/tags0' +" < 3. When this function is invoked as > +" echo tlib#tag#Retrieve('print') +" < it will return only project-local tags. If it is invoked as > +" echo tlib#tag#Retrieve('print', 1) +" < tags from the JDK will be included. +function! tlib#tag#Retrieve(rx, ...) "{{{3 + TVarArg ['extra_tags', 0] + Tlibtrace 'tlib', a:rx, extra_tags + if extra_tags + let tags_orig = &l:tags + if empty(tags_orig) + setlocal tags< + endif + try + let more_tags = tlib#var#Get('tlib_tags_extra', 'bg') + if !empty(more_tags) + let &l:tags .= ','. more_tags + endif + let taglist = taglist(a:rx) + finally + let &l:tags = tags_orig + endtry + else + let taglist = taglist(a:rx) + endif + Tlibtrace 'tlib', len(taglist) + return copy(taglist) +endf + + +" Retrieve tags that meet the constraints (a dictionnary of fields and +" regexp, with the exception of the kind field which is a list of chars). +" For the use of the optional use_extra argument see +" |tlib#tag#Retrieve()|. +" :def: function! tlib#tag#Collect(constraints, ?use_extra=1, ?match_front=1) +function! tlib#tag#Collect(constraints, ...) "{{{3 + TVarArg ['use_extra', 0], ['match_end', 1], ['match_front', 1] + Tlibtrace 'tlib', a:constraints, use_extra, match_end, match_front + let rx = get(a:constraints, 'name', '') + if empty(rx) || rx == '*' + let rx = '.' + else + let rxl = ['\C'] + if match_front + call add(rxl, '^') + endif + " call add(rxl, tlib#rx#Escape(rx)) + call add(rxl, rx) + if match_end + call add(rxl, '$') + endif + let rx = join(rxl, '') + endif + Tlibtrace 'tlib', rx, use_extra + let tags = tlib#tag#Retrieve(rx, use_extra) + Tlibtrace 'tlib', len(tags) + for [field, rx] in items(a:constraints) + if !empty(rx) && rx != '*' + " TLogVAR field, rx + if field == 'kind' + call filter(tags, 'v:val.kind =~ "['. rx .']"') + elseif field != 'name' + call filter(tags, '!empty(get(v:val, field)) && get(v:val, field) =~ rx') + endif + endif + endfor + Tlibtrace 'tlib', len(tags) + return tags +endf + + +function! tlib#tag#Format(tag) "{{{3 + if has_key(a:tag, 'signature') + let name = a:tag.name . a:tag.signature + elseif a:tag.cmd[0] == '/' + let name = a:tag.cmd + let name = substitute(name, '^/\^\?\s*', '', '') + let name = substitute(name, '\s*\$\?/$', '', '') + let name = substitute(name, '\s\{2,}', ' ', 'g') + let tsub = tlib#var#Get('tlib_tag_substitute', 'bg') + if has_key(tsub, &filetype) + for [rx, rplc, sub] in tsub[&filetype] + let name = substitute(name, rx, rplc, sub) + endfor + endif + else + let name = a:tag.name + endif + return name +endf + diff --git a/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/textobjects.vim b/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/textobjects.vim new file mode 100644 index 0000000..fb4170e --- /dev/null +++ b/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/textobjects.vim @@ -0,0 +1,45 @@ +" textobjects.vim +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2010-01-09. +" @Last Change: 2010-01-10. +" @Revision: 0.0.29 + +let s:save_cpo = &cpo +set cpo&vim + + +" :tag: standard-paragraph +" Select a "Standard Paragraph", i.e. a text block followed by blank +" lines. Other than |ap|, the last paragraph in a document is handled +" just the same. +" +" The |text-object| can be accessed as "sp". Example: > +" +" vsp ... select the current standard paragraph +" +" Return 1, if the paragraph is the last one in the document. +function! tlib#textobjects#StandardParagraph() "{{{3 + if line("'}") == line('$') + norm! vip + return 1 + else + norm! vap + return 0 + endif +endf + + +function! tlib#textobjects#Init() "{{{3 + if !exists('s:tlib_done_textobjects') + " sp ... Standard paragraph (for use as |text-objects|). + vnoremap sp :call tlib#textobjects#StandardParagraph() + onoremap sp :normal Vsp + let s:tlib_done_textobjects = 1 + endif +endf + + +let &cpo = s:save_cpo +unlet s:save_cpo diff --git a/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/time.vim b/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/time.vim new file mode 100644 index 0000000..130ef5b --- /dev/null +++ b/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/time.vim @@ -0,0 +1,84 @@ +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Revision: 42 + + +function! tlib#time#MSecs() "{{{3 + let rts = reltimestr(reltime()) + return substitute(rts, '\.', '', '') +endf + + +function! tlib#time#Now() "{{{3 + if has('reltime') + let rts = reltimestr(reltime()) + let rtl = map(split(rts, '\.'), 'str2nr(v:val)') + else + let rtl = [localtime()] + endif + return rtl +endf + + +function! tlib#time#FormatNow() "{{{3 + let rtl = tlib#time#Now() + if len(rtl) == 2 + let rts = strftime(g:tlib#date#date_format .' %H:%M:%S', rtl[0]) .'.'. rtl[1] + else + let rts = strftime(g:tlib#date#date_format .' %H:%M:%S', rtl[0]) + endif + return rts +endf + + +function! tlib#time#Diff(a, b, ...) "{{{3 + TVarArg ['resolution', 2] + let [as, am] = a:a + let [bs, bm] = a:b + let rv = 0 + (as - bs) + if resolution > 0 + let rv .= repeat('0', resolution) + let am = am[0 : resolution - 1] + let bm = bm[0 : resolution - 1] + let rv += (am - bm) + endif + return rv +endf + + +function! tlib#time#DiffMSecs(a, b, ...) "{{{3 + TVarArg ['resolution', 2] + if a:a == a:b + return 0 + endif + let a = printf('%30s', a:a[0 : -(7 - resolution)]) + let b = printf('%30s', a:b[0 : -(7 - resolution)]) + for i in range(0, 29) + if a[i] != b[i] + let a = a[i : -1] + let b = b[i : -1] + return a - b + endif + endfor + return 0 +endf + + +function! tlib#time#Command(cmd, ...) abort "{{{3 + let loops = a:0 >= 1 ? a:1 : 1 + let silent = a:0 >= 1 ? a:1 : 0 + let start = tlib#time#Now() + for loop in range(loops) + if silent + silent! exec a:cmd + else + exec a:cmd + endif + endfor + let end = tlib#time#Now() + let diff = tlib#time#Diff(end, start) + echom 'Time:' diff + return diff +endf + diff --git a/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/trace.vim b/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/trace.vim new file mode 100644 index 0000000..25a00a2 --- /dev/null +++ b/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/trace.vim @@ -0,0 +1,198 @@ +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @Website: https://github.com/tomtom +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Last Change: 2017-03-09 +" @Revision: 205 + + +if !exists('g:tlib#trace#backtrace') + " The length of the backtrace that should be included in + " |tlib#trace#Print()|. + let g:tlib#trace#backtrace = 2 "{{{2 +endif + + +if !exists('g:tlib#trace#printer') + " Possible values: + " - 'echom' + " - ['file', FILENAME] + let g:tlib#trace#printer = 'echom' "{{{2 +endif + + +if !exists('g:tlib#trace#hl') + let g:tlib#trace#hl = {'error': 'ErrorMsg', 'fatal': 'ErrorMsg', 'warn': 'WarningMsg'} "{{{2 +endif + + +" Print traces from |tlib#trace#Print()|. +function! tlib#trace#Printer_echom(type, text, args) abort "{{{3 + let hl = get(g:tlib#trace#hl, a:type, '') + try + if !empty(hl) + exec 'echohl' hl + endif + echom a:text + finally + if !empty(hl) + echohl NONE + endif + endtry +endf + + +function! tlib#trace#Printer_file(type, text, args) abort "{{{3 + let filename = get(a:args, 0, '') + if exists(filename) && !filewritable(filename) + throw 'tlib#trace#Printer_file: Cannot write to file: '. filename + else + call writefile([a:text], filename, 'a') + endif +endf + + +" Set the tracing |regexp|. See |:Tlibtrace|. +" This will also call |tlib#trace#Enable()|. +" +" Examples: +" call tlib#trace#Set(["+foo", "-bar"]) +" call tlib#trace#Set("+foo,-bar") +function! tlib#trace#Set(vars, ...) abort "{{{3 + let reset = a:0 >= 1 ? a:1 : 0 + if reset + call tlib#trace#Reset() + endif + if empty(a:vars) + return + endif + call tlib#trace#Enable() + if type(a:vars) == v:t_string + let vars = tlib#string#SplitCommaList(a:vars, '[,[:space:]]\+') + let opts = {} + elseif type(a:vars) == v:t_dict + let vars = a:vars.__rest__ + if has_key(a:vars, 'file') + let g:tlib#trace#printer = ['file', a:vars.file] + endif + if has_key(a:vars, 'echo') + let g:tlib#trace#printer = 'echom' + endif + else + let vars = a:vars + let opts = {} + endif + " TLogVAR vars + for rx in vars + let rx1 = substitute(rx, '^[+-]', '', 'g') + if rx1 !~# '^\%(error\|warn\|fatal\)$' + let erx1 = tlib#rx#Escape(rx1) + " TLogVAR rx, rx1 + " echom "DBG" s:trace_rx + if rx =~ '^-' + let erx1 .= '\[0-\d\]\\?' + if s:trace_rx =~# '[(|]'. erx1 .'\\' + let s:trace_rx = substitute(s:trace_rx, '\\|'. erx1, '', '') + endif + " elseif rx =~ '^+' + else + if erx1 =~ '\d$' + let erx1 = substitute(erx1, '\d$', '[0-\0]\\?', '') + else + let erx1 .= '[0-9]\?' + endif + if s:trace_rx !~# '[(|]'. erx1 .'\\' + let s:trace_rx = substitute(s:trace_rx, '\ze\\)\$', '\\|'. escape(erx1, '\'), '') + endif + " else + " echohl WarningMsg + " echom 'tlib#trace#Print: Unsupported syntax:' rx + " echohl NONE + endif + " echom "DBG" s:trace_rx + endif + endfor + echom "SetTrace:" s:trace_rx +endf + + +function! tlib#trace#Backtrace(caller) abort "{{{3 + let caller = split(a:caller, '\.\.') + let start = max([0, len(caller) - g:tlib#trace#backtrace - 1]) + let caller = caller[start : -1] + return join(caller, '..') +endf + + +" Print the values of vars. The first value is a "guard" (see +" |:Tlibtrace|). +function! tlib#trace#Print(caller, vars, values) abort "{{{3 + " echom "DBG tlib#trace#Print" string(a:vars) string(a:values) + let msg = ['TRACE'] + let guard = a:values[0] + if type(guard) == 0 + let cond = guard + else + let cond = guard =~# s:trace_rx + endif + " TLogVAR guard, cond, a:vars, a:values + if cond + call add(msg, guard) + call add(msg, tlib#time#FormatNow() .':') + if g:tlib#trace#backtrace > 0 + let bt = tlib#trace#Backtrace(a:caller) + if !empty(bt) + call add(msg, bt .':') + endif + endif + if len(a:vars) == len(a:values) + for i in range(1, len(a:vars) - 1) + let v = substitute(a:vars[i], ',$', '', '') + if type(a:values[i]) == v:t_func + let r = string(a:values[i]) + else + let r = a:values[i] + endif + if v =~# '^\([''"]\).\{-}\1$' + call add(msg, r .';') + else + call add(msg, v .'='. string(r) .';') + endif + unlet r + endfor + else + call add(msg, join(a:values[1:-1])) + endif + if type(g:tlib#trace#printer) == v:t_string + let printer = g:tlib#trace#printer + let args = [] + else + let [printer; args] = g:tlib#trace#printer + endif + call tlib#trace#Printer_{printer}(guard, join(msg), args) + endif +endf + + +function! tlib#trace#Reset() abort "{{{3 + let s:trace_rx = '^\%(error\|fatal\|warn\|info\)$' + let g:tlib#trace#printer = 'echom' +endf + + +" Enable tracing via |:Tlibtrace|. +function! tlib#trace#Enable() abort "{{{3 + if !exists('s:trace_rx') + call tlib#trace#Reset() + " :nodoc: + command! -nargs=+ -bang Tlibtrace call tlib#trace#Print(expand(''), [], []) + endif +endf + + +" Disable tracing via |:Tlibtrace|. +function! tlib#trace#Disable() abort "{{{3 + " :nodoc: + command! -nargs=+ -bang Tlibtrace : + unlet! s:trace_rx +endf + diff --git a/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/type.vim b/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/type.vim new file mode 100644 index 0000000..6bac922 --- /dev/null +++ b/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/type.vim @@ -0,0 +1,142 @@ +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2007-09-30. +" @Last Change: 2017-02-22. +" @Revision: 57 + + +let g:tlib#type#nil = [] + + +" Enable type assertiona via |:Tlibtype|. +function! tlib#type#Enable() abort "{{{3 + " :nodoc: + command! -nargs=+ Tlibtype call tlib#type#Check(expand(''), [], []) +endf + + +" Disable type assertiona via |:Tlibtype|. +function! tlib#type#Disable() abort "{{{3 + " :nodoc: + command! -nargs=+ Tlibtype : +endf + + +function! tlib#type#IsNil(expr) abort "{{{3 + return tlib#type#Is(a:expr, v:t_none) || a:expr is g:tlib#type#nil +endf + + +function! tlib#type#IsNumber(expr) + return tlib#type#Is(a:expr, 0) +endf + + +function! tlib#type#IsString(expr) + return tlib#type#Is(a:expr, 1) +endf + + +function! tlib#type#IsFuncref(expr) + return tlib#type#Is(a:expr, 2) +endf + + +function! tlib#type#IsList(expr) + return tlib#type#Is(a:expr, 3) +endf + + +function! tlib#type#IsDictionary(expr) + return tlib#type#Is(a:expr, 4) +endf + + +function! tlib#type#Is(val, type) abort "{{{3 + if has_key(s:schemas, a:type) + return tlib#type#Has(a:val, a:type) + else + if type(a:type) == 0 + let type = a:type + elseif a:type =~? '^b\%[oolean]$' + let type = v:t_bool + elseif a:type =~? '^c\%[hannel]$' + let type = v:t_channel + elseif a:type =~? '^d\%[ictionary]$' + let type = v:t_dict + elseif a:type =~? '^fl\%[oat]$' + let type = v:t_float + elseif a:type =~? '^fu\%[ncref]$' + let type = v:t_func + elseif a:type =~? '^j\%[ob]$' + let type = v:t_job + elseif a:type =~? '^l\%[ist]$' + let type = v:t_list + elseif a:type =~? '^\%(nil\|null\|none\)$' + let type = v:t_none + elseif a:type =~? '^n\%[umber]$' + let type = v:t_number + elseif a:type =~? '^s\%[tring]$' + let type = v:t_string + else + throw 'tlib#type#Is: Unknown type: ' a:type + endif + Tlibtrace 'tlib', a:val, a:type, type, type(a:val), type(a:val) == a:type + return type(a:val) == type + endif +endf + + +function! tlib#type#Are(vals, type) abort "{{{3 + return tlib#assert#Map(a:vals, 'tlib#type#Is(v:val,'. string(a:type) .')') +endf + + +let s:schemas = {} + + +function! tlib#type#Define(name, schema) abort "{{{3 + let s:schemas[a:name] = deepcopy(a:schema) +endf + + +function! tlib#type#Has(val, schema) abort "{{{3 + Tlibtrace 'tlib', type(a:val), type(a:schema) + if !tlib#type#IsDictionary(a:val) + Tlibtrace 'tlib', 'not a dictionary', a:val + return 0 + endif + if tlib#type#IsString(a:schema) + Tlibtrace 'tlib', a:schema + let schema = copy(s:schemas[a:schema]) + else + let schema = copy(a:schema) + endif + if tlib#type#IsDictionary(schema) + return tlib#assert#All(map(schema, 'has_key(a:val, v:key) && tlib#type#Is(a:val[v:key], v:val)')) + else + Tlibtrace 'tlib', keys(a:val), schema + return tlib#assert#All(map(schema, 'has_key(a:val, v:val)')) + endif +endf + + +function! tlib#type#Have(vals, schema) abort "{{{3 + return tlib#assert#Map(a:vals, 'tlib#type#Has(v:val,'. string(a:schema) .')') +endf + + +function! tlib#type#Check(caller, names, vals) abort "{{{3 + Tlibtrace 'tlib', a:names, a:vals, len(a:names) + for i in range(0, len(a:names) - 1, 2) + let val = a:vals[i] + let type = a:vals[i + 1] + Tlibtrace 'tlib', i, val, type + if !tlib#type#Is(val, type) + let name = matchstr(a:names[i], '^''\zs.\{-}\ze'',\?$') + throw 'tlib#type#Check: Type mismatch: '. name .':'. a:vals[i + 1] + endif + endfor +endf + diff --git a/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/url.vim b/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/url.vim new file mode 100644 index 0000000..b948d48 --- /dev/null +++ b/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/url.vim @@ -0,0 +1,52 @@ +" url.vim +" @Author: Tom Link (micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2007-06-30. +" @Last Change: 2011-03-10. +" @Revision: 0.0.28 + + +" TODO: These functions could use printf() now. + +" Decode an encoded URL. +function! tlib#url#Decode(url) "{{{3 + return substitute(a:url, '\(+\|%\(%\|\x\x\)\)', '\=tlib#url#DecodeChar(submatch(1))', 'g') +endf + + +" Decode a single character. +function! tlib#url#DecodeChar(char) "{{{3 + if a:char == '%%' + return '%' + elseif a:char == '+' + return ' ' + else + return nr2char("0x".a:char[1 : -1]) + endif +endf + + +" Encode a single character. +function! tlib#url#EncodeChar(char) "{{{3 + if a:char == '%' + return '%%' + elseif a:char == ' ' + return '+' + else + return printf("%%%X", char2nr(a:char)) + endif +endf + + +" Encode an URL. +function! tlib#url#Encode(url, ...) "{{{3 + TVarArg ['extrachars', ''] + let rx = '\([^a-zA-Z0-9_.'. extrachars .'-]\)' + " TLogVAR a:url, rx + let rv = substitute(a:url, rx, '\=tlib#url#EncodeChar(submatch(1))', 'g') + " TLogVAR rv + return rv +endf + + diff --git a/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/var.vim b/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/var.vim new file mode 100644 index 0000000..cf0d294 --- /dev/null +++ b/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/var.vim @@ -0,0 +1,90 @@ +" @Author: Tom Link (micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Revision: 34 + + +" Define a variable called NAME if yet undefined. +" You can also use the :TLLet command. +" +" EXAMPLES: > +" exec tlib#var#Let('g:foo', 1) +" TLet g:foo = 1 +function! tlib#var#Let(name, val) "{{{3 + return printf('if !exists(%s) | let %s = %s | endif', string(a:name), a:name, string(a:val)) + " return printf('if !exists(%s) | let %s = %s | endif', string(a:name), a:name, a:val) +endf + + +" :def: function! tlib#var#EGet(var, namespace, ?default='') +" Retrieve a variable by searching several namespaces. +" +" EXAMPLES: > +" let g:foo = 1 +" let b:foo = 2 +" let w:foo = 3 +" echo eval(tlib#var#EGet('foo', 'vg')) => 1 +" echo eval(tlib#var#EGet('foo', 'bg')) => 2 +" echo eval(tlib#var#EGet('foo', 'wbg')) => 3 +function! tlib#var#EGet(var, namespace, ...) "{{{3 + let pre = [] + let post = [] + for namespace in split(a:namespace, '\zs') + let var = namespace .':'. a:var + call add(pre, printf('exists("%s") ? %s : (', var, var)) + call add(post, ')') + endfor + let default = a:0 >= 1 ? a:1 : '' + return join(pre) . string(default) . join(post) +endf + + +" :def: function! tlib#var#Get(var, namespace, ?default='') +" Retrieve a variable by searching several namespaces. +" +" EXAMPLES: > +" let g:foo = 1 +" let b:foo = 2 +" let w:foo = 3 +" echo tlib#var#Get('foo', 'bg') => 1 +" echo tlib#var#Get('foo', 'bg') => 2 +" echo tlib#var#Get('foo', 'wbg') => 3 +function! tlib#var#Get(var, namespace, ...) "{{{3 + let var_ = substitute(a:var, '#', '_', 'g') + for namespace in split(a:namespace, '\zs') + let vname = namespace ==# 'g' ? a:var : var_ + let var = namespace .':'. vname + if exists(var) + return {var} + elseif namespace ==# 'g' + try + let val = {var} + catch /^Vim\%((\a\+)\)\=:E\(121\|15\)/ + continue + endtry + return val + endif + endfor + return a:0 >= 1 ? a:1 : '' +endf + + +" :def: function! tlib#var#List(rx, ?prefix='') +" Get a list of variables matching rx. +" EXAMPLE: +" echo tlib#var#List('tlib_', 'g:') +function! tlib#var#List(rx, ...) "{{{3 + TVarArg ['prefix', 'g:'] + if v:version >= 704 + exec 'let varlist = keys('. prefix .')' + else + redir => vars + silent! exec 'let '. prefix + redir END + let varlist = split(vars, '\n') + call map(varlist, 'matchstr(v:val, ''^\S\+'')') + endif + call filter(varlist, 'v:val =~ a:rx') + return varlist +endf + diff --git a/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/vcs.vim b/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/vcs.vim new file mode 100644 index 0000000..e551be2 --- /dev/null +++ b/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/vcs.vim @@ -0,0 +1,230 @@ +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2012-03-08. +" @Last Change: 2017-04-10. +" @Revision: 224 + +scriptencoding utf-8 + + +" A dictionarie of supported VCS (currently: git, hg, svn, bzr). +" :display: g:tlib#vcs#def {...} +TLet g:tlib#vcs#def = { + \ 'git': { + \ 'dir': '.git', + \ 'ls': 'git ls-files --full-name', + \ 'ls.postprocess': '*tlib#vcs#GitLsPostprocess', + \ 'diff': 'git diff --no-ext-diff -U0 %s', + \ 'status': 'git status -s', + \ 'status.filterrx': '^\C[ MADRCU!?]\{2}\s'}, + \ 'hg': { + \ 'dir': '.hg', + \ 'diff': 'hg diff -U0 %s', + \ 'ls': 'hg manifest'}, + \ 'svn': { + \ 'dir': '.svn', + \ 'diff': 'svn diff --diff-cmd diff --extensions -U0 %s'}, + \ 'bzr': { + \ 'dir': '.bzr', + \ 'diff': 'bzr diff --diff-options=-U0 %s'} + \ } + + +" A dictionary of custom executables for VCS commands. If the value is +" empty, support for that VCS will be removed. If no key is present, it +" is assumed that the VCS "type" is the name of the executable. +" :display: g:tlib#vcs#executables {...} +TLet g:tlib#vcs#executables = {} + + +" If non-empty, use it as a format string to check whether a VCS is +" installed on your computer. +TLet g:tlib#vcs#check = has('win16') || has('win32') || has('win64') ? '%s.exe' : '%s' + + +if !empty(g:tlib#vcs#check) + for [s:cmd, s:def] in items(g:tlib#vcs#def) + if !has_key(g:tlib#vcs#executables, s:cmd) + let s:cmd1 = printf(g:tlib#vcs#check, s:cmd) + let g:tlib#vcs#executables[s:cmd] = executable(s:cmd1) ? s:cmd1 : '' + endif + endfor + unlet! s:cmd s:def s:cmd1 +endif + + +function! tlib#vcs#Executable(type) "{{{3 + return get(g:tlib#vcs#executables, a:type, '') +endf + + +let s:vcs_cache = {} +autocmd TLib FocusGained * let s:vcs_cache = {} + + +function! tlib#vcs#FindVCS(filename) "{{{3 + let type = '' + let dir = '' + let filename = fnamemodify(a:filename, ':p') + let dirname = isdirectory(filename) ? filename : fnamemodify(filename, ':h') + if !has_key(s:vcs_cache, dirname) + let path = escape(dirname, ';') .';' + " TLogVAR filename, dirname, path + Tlibtrace 'tlib', filename, path + let depth = -1 + for vcs in keys(g:tlib#vcs#def) + let subdir = g:tlib#vcs#def[vcs].dir + let vcsdir = finddir(subdir, path) + " TLogVAR vcs, subdir, vcsdir + Tlibtrace 'tlib', vcs, subdir, vcsdir + if !empty(vcsdir) + let vcsdir_depth = len(split(fnamemodify(vcsdir, ':p'), '\/')) + if vcsdir_depth > depth + let depth = vcsdir_depth + let type = vcs + let dir = vcsdir + " TLogVAR type, depth + endif + endif + endfor + Tlibtrace 'tlib', type, dir + " TLogVAR type, dir + if empty(type) + let s:vcs_cache[dirname] = ['', ''] + else + let s:vcs_cache[dirname] = [type, dir] + endif + endif + return s:vcs_cache[dirname] +endf + + +function! s:GetCmd(vcstype, cmd) + let vcsdef = get(g:tlib#vcs#def, a:vcstype, {}) + if has_key(vcsdef, a:cmd) + let cmd = vcsdef[a:cmd] + if cmd =~# '^\*' + let cmd = substitute(cmd, '^\*', '', '') + else + let bin = get(g:tlib#vcs#executables, a:vcstype, '') + if empty(bin) + let cmd = '' + elseif bin != a:vcstype + " let bin = escape(shellescape(bin), '\') + let bin = escape(bin, '\') + let cmd = substitute(cmd, '^.\{-}\zs'. escape(a:vcstype, '\'), bin, '') + endif + endif + return cmd + else + return '' + endif +endf + + +" :display: tlib#vcs#Ls(?filename=bufname('%'), ?vcs=[type, dir]) +" Return the files under VCS. +function! tlib#vcs#Ls(...) "{{{3 + if a:0 >= 2 + let vcs = a:2 + else + let vcs = tlib#vcs#FindVCS(a:0 >= 1 ? a:1 : bufname('%')) + endif + Tlibtrace 'tlib', vcs, a:000 + " TLogVAR vcs + if !empty(vcs) + let [vcstype, vcsdir] = vcs + if has_key(g:tlib#vcs#def, vcstype) + let ls = s:GetCmd(vcstype, 'ls') + " TLogVAR ls + if !empty(ls) + let rootdir = fnamemodify(vcsdir, ':p:h:h') + " TLogVAR vcsdir, rootdir + if ls =~# '%s' + let cmd = printf(ls, shellescape(rootdir)) + else + let cmd = ls + endif + " TLogVAR cmd, getcwd() + Tlibtrace 'tlib', getcwd(), vcstype, vcsdir, rootdir, cmd + let filess = tlib#sys#SystemInDir(rootdir, cmd) + " TLogVAR filess + let files = split(filess, '\n') + let postprocess = s:GetCmd(vcstype, 'ls.postprocess') + if !empty(postprocess) + call map(files, 'call(postprocess, [v:val])') + endif + call map(files, 'join([rootdir, v:val], "/")') + " TLogVAR files + return files + endif + endif + endif + return [] +endf + + +" :display: tlib#vcs#Diff(filename, ?vcs=[type, dir]) +" Return the diff for "filename" +function! tlib#vcs#Diff(filename, ...) "{{{3 + let vcs = a:0 >= 1 ? a:1 : tlib#vcs#FindVCS(a:filename) + if !empty(vcs) + let [vcstype, vcsdir] = vcs + let diff = s:GetCmd(vcstype, 'diff') + if !empty(diff) + let cmd = printf(diff, shellescape(fnamemodify(a:filename, ':p'))) + let patch = system(cmd) + return patch + endif + endif + return [] +endf + + +function! tlib#vcs#GitLsPostprocess(filename) abort "{{{3 + if a:filename =~# '^".\{-}"$' + let filename = matchstr(a:filename, '^"\zs.\{-}\ze"$') + let filename = substitute(filename, '\%(\\\@= 1 ? a:1 : '%' + let vcs = a:0 >= 2 ? a:2 : tlib#vcs#FindVCS(filename) + if !empty(vcs) + let [vcstype, vcsdir] = vcs + let cstatus = s:GetCmd(vcstype, 'status') + if !empty(cstatus) + let status = exists('*systemlist') ? systemlist(cstatus) : split(system(cstatus), '\n') + let sfilter = s:GetCmd(vcstype, 'status.filterrx') + if !empty(sfilter) + let status = filter(status, 'v:val =~# sfilter') + endif + return status + endif + endif +endf + + +function! tlib#vcs#IsDirty(...) abort "{{{3 + let filename = a:0 >= 1 ? a:1 : '%' + let vcs = a:0 >= 2 ? a:2 : tlib#vcs#FindVCS(filename) + let status = tlib#vcs#Status(filename, vcs) + return empty(status) ? '' : vcs[0] .'!' +endf + + +" function! tlib#vcs#EnableTStatus() abort "{{{3 +" if has('vim_starting') +" autocmd VimEnter * TStatusregister1 --event=FocusGained,BufRead,BufWritePost %s tlib#vcs#IsDirty() +" else +" TStatusregister1 --event=FocusGained,BufRead,BufWritePost %s tlib#vcs#IsDirty() +" endif +" endf + diff --git a/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/vim.vim b/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/vim.vim new file mode 100644 index 0000000..7154aeb --- /dev/null +++ b/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/vim.vim @@ -0,0 +1,152 @@ +" @Author: Tom Link (micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @GIT: http://github.com/tomtom/tlib_vim/ +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2010-07-19. +" @Last Change: 2012-06-08. +" @Revision: 37 + + +let s:restoreframecmd = '' +let s:fullscreen = 0 + +if has('win16') || has('win32') || has('win64') + + if !exists('g:tlib#vim#simalt_maximize') + " The alt-key for maximizing the window. + " CAUTION: The value of this paramter depends on your locale and + " maybe the windows version you are running. + let g:tlib#vim#simalt_maximize = 'x' "{{{2 + endif + + if !exists('g:tlib#vim#simalt_restore') + " The alt-key for restoring the window. + " CAUTION: The value of this paramter depends on your locale and + " maybe the windows version you are running. + let g:tlib#vim#simalt_restore = 'r' "{{{2 + endif + + if !exists('g:tlib#vim#use_vimtweak') + " If true, use the vimtweak.dll for windows. This will enable + " tlib to remove the caption for fullscreen windows. + let g:tlib#vim#use_vimtweak = 0 "{{{2 + endif + + " Maximize the window. + " You might need to redefine |g:tlib#vim#simalt_maximize| if it doesn't + " work for you. + fun! tlib#vim#Maximize(fullscreen) "{{{3 + if !has("gui_running") + return + endif + call s:SaveFrameParams() + let s:fullscreen = a:fullscreen + if g:tlib#vim#use_vimtweak && a:fullscreen + call libcallnr("vimtweak.dll", "EnableCaption", 0) + endif + exec 'simalt ~'. g:tlib#vim#simalt_maximize + endf + + " Restore the original vimsize after having called |tlib#vim#Maximize()|. + function! tlib#vim#RestoreWindow() "{{{3 + if !has("gui_running") + return + endif + if g:tlib#vim#use_vimtweak + call libcallnr("vimtweak.dll", "EnableCaption", 1) + endif + exec 'simalt ~'. g:tlib#vim#simalt_restore + call s:RestoreFrameParams() + endf + +else + + if !exists('g:tlib#vim#use_wmctrl') + " If true, use wmctrl for X windows to make a window + " maximized/fullscreen. + " + " This is the preferred method for maximizing windows under X + " windows. Some window managers have problem coping with the + " default method of setting 'lines' and 'columns' to a large + " value. + let g:tlib#vim#use_wmctrl = executable('wmctrl') "{{{2 + endif + + " :nodoc: + fun! tlib#vim#Maximize(fullscreen) "{{{3 + if !has("gui_running") + return + endif + call s:SaveFrameParams() + let s:fullscreen = a:fullscreen + if g:tlib#vim#use_wmctrl + if a:fullscreen + silent !wmctrl -r :ACTIVE: -b add,fullscreen + else + silent !wmctrl -r :ACTIVE: -b add,maximized_vert,maximized_horz + endif + else + set lines=1000 columns=1000 + endif + endf + + " :nodoc: + function! tlib#vim#RestoreWindow() "{{{3 + if !has("gui_running") + return + endif + if g:tlib#vim#use_wmctrl + if s:fullscreen + silent !wmctrl -r :ACTIVE: -b remove,fullscreen + else + silent !wmctrl -r :ACTIVE: -b remove,maximized_vert,maximized_horz + endif + endif + call s:RestoreFrameParams() + endf + +endif + + +function! s:SaveFrameParams() "{{{3 + let s:restoreframecmd = printf("set lines=%d columns=%d | winpos %d %d", &lines, &columns, getwinposx(), getwinposy()) +endf + + +function! s:RestoreFrameParams() "{{{3 + if !empty(s:restoreframecmd) + exec s:restoreframecmd + let s:restoreframecmd = '' + endif +endf + + +" :display: tlib#vim##CopyFunction(old, new, overwrite=0) +function! tlib#vim#CopyFunction(old, new, ...) "{{{3 + let overwrite = a:0 >= 1 ? a:1 : 0 + redir => oldfn + exec 'silent function' a:old + redir END + if exists('*'. a:new) + if overwrite > 0 + exec 'delfunction' a:new + elseif overwrite < 0 + throw 'tlib#vim##CopyFunction: Function already exists: '. a:old .' -> '. a:new + else + return + endif + endif + let fn = split(oldfn, '\n') + let fn = map(fn, 'substitute(v:val, ''^\d\+'', "", "")') + let fn[0] = substitute(fn[0], '\V\^\s\*fu\%[nction]!\?\s\+\zs'. a:old, a:new, '') + let t = @t + try + let @t = join(fn, "\n") + redir => out + @t + redir END + finally + let @t = t + endtry +endf + diff --git a/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/win.vim b/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/win.vim new file mode 100644 index 0000000..ee2ca00 --- /dev/null +++ b/skel/.config/nvim/plugged/tlib_vim/autoload/tlib/win.vim @@ -0,0 +1,197 @@ +" @Author: Tom Link (micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Revision: 84 + + +if !exists('g:tlib#win#use_winid') + let g:tlib#win#use_winid = exists('*win_gotoid') && exists('*win_getid') "{{{2 +endif + + +" Return vim code to jump back to the original window. +function! tlib#win#Set(winnr) "{{{3 + if a:winnr > 0 + " TLogVAR a:winnr + " TLogDBG winnr() + " TLogDBG string(tlib#win#List()) + if winnr() != a:winnr && winbufnr(a:winnr) != -1 + let rv = winnr().'wincmd w' + exec a:winnr .'wincmd w' + " TLogVAR rv + " TLogDBG string(tlib#win#List()) + return rv + endif + endif + return '' +endf + + +if g:tlib#win#use_winid + let g:tlib#win#null_id = -1 + function! tlib#win#GetID() abort "{{{3 + return win_getid() + endf + function! tlib#win#GotoID(win_id) abort "{{{3 + call win_gotoid(a:win_id) + endf +else + let s:win_id = 0 + let g:tlib#win#null_id = {} + function! tlib#win#GetID() abort "{{{3 + if !exists('w:tlib_win_id') + let s:win_id += 1 + let w:tlib_win_id = s:win_id + endif + return {'tabpagenr': tabpagenr(), 'bufnr': bufnr('%'), 'winnr': winnr(), 'win_id': w:tlib_win_id} + endf + function! tlib#win#GotoID(win_id) abort "{{{3 + Tlibtrace 'tlib', a:win_id + if tabpagenr() != a:win_id.tabpagenr + exec 'tabnext' a:win_id.tabpagenr + endif + for wnr in range(1, winnr('$')) + let win_id = getwinvar(wnr, 'tlib_win_id', -1) + Tlibtrace 'tlib', wnr, win_id + if win_id == a:win_id.win_id + Tlibtrace 'tlib', wnr + exec wnr 'wincmd w' + return + endif + endfor + " Was the window closed? What should we do now? + if winnr() != a:win_id.winnr + exec a:win_id.winnr 'wincmd w' + endif + if bufnr('%') != a:win_id.bufnr + exec 'hide buffer' a:win_id.bufnr + endif + endf +endif + + +" Return vim code to jump back to the original window. +function! tlib#win#SetById(win_id) "{{{3 + if a:win_id != g:tlib#win#null_id + let win_id = tlib#win#GetID() + call tlib#win#GotoID(a:win_id) + return printf('call tlib#win#GotoID(%s)', win_id) + " " TLogVAR a:winnr + " " TLogDBG winnr() + " " TLogDBG string(tlib#win#List()) + " if winnr() != a:winnr && winbufnr(a:winnr) != -1 + " let rv = winnr().'wincmd w' + " exec a:winnr .'wincmd w' + " " TLogVAR rv + " " TLogDBG string(tlib#win#List()) + " return rv + " endif + endif + return '' +endf + + +" :def: function! tlib#win#GetLayout(?save_view=0) +function! tlib#win#GetLayout(...) "{{{3 + TVarArg ['save_view', 0] + let views = {} + if save_view + let winnr = winnr() + windo let views[winnr()] = winsaveview() + " for w in range(1, winnr('$')) + " call tlib#win#Set(w) + " let views[w] = winsaveview() + " endfor + call tlib#win#Set(winnr) + endif + return {'winnr': winnr('$'), 'winrestcmd': winrestcmd(), 'views': views, 'cmdheight': &cmdheight, 'guioptions': &guioptions, 'tabpagenr': tabpagenr()} +endf + + +function! tlib#win#SetLayout(layout) "{{{3 + if a:layout.tabpagenr == tabpagenr() && a:layout.winnr == winnr('$') + " TLogVAR a:layout.winrestcmd + " TLogDBG string(tlib#win#List()) + exec a:layout.winrestcmd + if !empty(a:layout.views) + let winnr = winnr() + " TLogVAR winnr + for [w, v] in items(a:layout.views) + " TLogVAR w, v + call tlib#win#Set(w) + call winrestview(v) + endfor + call tlib#win#Set(winnr) + endif + if a:layout.cmdheight != &cmdheight + let &cmdheight = a:layout.cmdheight + endif + " TLogDBG string(tlib#win#List()) + return 1 + endif + return 0 +endf + + +function! tlib#win#List() "{{{3 + let wl = {} + for wn in range(1, winnr('$')) + let wl[wn] = bufname(winbufnr(wn)) + endfor + return wl +endf + + +" " :def: function! tlib#win#GetLayout1(?save_view=0) +" " Contrary to |tlib#win#GetLayout|, this version doesn't use +" " |winrestcmd()|. It can also save windows views. +" function! tlib#win#GetLayout1(...) "{{{3 +" TVarArg ['save_view', 0] +" let winnr = winnr() +" let acc = {} +" for w in range(1, winnr('$')) +" let def = {'h': winheight(w), 'w': winwidth(w)} +" if save_view +" call tlib#win#Set(w) +" let def.view = winsaveview() +" endif +" let acc[w] = def +" endfor +" call tlib#win#Set(winnr) +" return acc +" endf +" +" +" " Reset layout from the value of |tlib#win#GetLayout1|. +" function! tlib#win#SetLayout1(layout) "{{{3 +" if len(a:layout) != winnr('$') +" return 0 +" endif +" let winnr = winnr() +" for [w, def] in items(a:layout) +" if tlib#win#Set(w) +" exec 'resize '. def.h +" exec 'vertical resize '. def.w +" if has_key(def, 'view') +" call winrestview(def.view) +" endif +" else +" break +" endif +" endfor +" call tlib#win#Set(winnr) +" return 1 +" endf + + +function! tlib#win#Width(wnr) "{{{3 + return winwidth(a:wnr) - &fdc +endf + + +function! tlib#win#WinDo(ex) "{{{3 + let w = winnr() + exec 'windo '. a:ex + exec w .'wincmd w' +endf + diff --git a/skel/.config/nvim/plugged/tlib_vim/doc/tags b/skel/.config/nvim/plugged/tlib_vim/doc/tags new file mode 100644 index 0000000..26ad408 --- /dev/null +++ b/skel/.config/nvim/plugged/tlib_vim/doc/tags @@ -0,0 +1,223 @@ +:TBrowseOutput tlib.txt /*:TBrowseOutput* +:TBrowseScriptnames tlib.txt /*:TBrowseScriptnames* +:TLet tlib.txt /*:TLet* +:TScratch tlib.txt /*:TScratch* +:TVarArg tlib.txt /*:TVarArg* +:Tbrowseloc tlib.txt /*:Tbrowseloc* +:Tbrowseqfl tlib.txt /*:Tbrowseqfl* +:Texecloc tlib.txt /*:Texecloc* +:Texecqfl tlib.txt /*:Texecqfl* +:Tlibtrace tlib.txt /*:Tlibtrace* +:Tlibtraceset tlib.txt /*:Tlibtraceset* +autoload/tlib/Filter_cnf.vim tlib.txt /*autoload\/tlib\/Filter_cnf.vim* +autoload/tlib/Filter_cnfd.vim tlib.txt /*autoload\/tlib\/Filter_cnfd.vim* +autoload/tlib/Filter_fuzzy.vim tlib.txt /*autoload\/tlib\/Filter_fuzzy.vim* +autoload/tlib/Filter_glob.vim tlib.txt /*autoload\/tlib\/Filter_glob.vim* +autoload/tlib/Object.vim tlib.txt /*autoload\/tlib\/Object.vim* +autoload/tlib/World.vim tlib.txt /*autoload\/tlib\/World.vim* +autoload/tlib/agent.vim tlib.txt /*autoload\/tlib\/agent.vim* +autoload/tlib/arg.vim tlib.txt /*autoload\/tlib\/arg.vim* +autoload/tlib/assert.vim tlib.txt /*autoload\/tlib\/assert.vim* +autoload/tlib/buffer.vim tlib.txt /*autoload\/tlib\/buffer.vim* +autoload/tlib/cache.vim tlib.txt /*autoload\/tlib\/cache.vim* +autoload/tlib/char.vim tlib.txt /*autoload\/tlib\/char.vim* +autoload/tlib/cmd.vim tlib.txt /*autoload\/tlib\/cmd.vim* +autoload/tlib/comments.vim tlib.txt /*autoload\/tlib\/comments.vim* +autoload/tlib/date.vim tlib.txt /*autoload\/tlib\/date.vim* +autoload/tlib/dir.vim tlib.txt /*autoload\/tlib\/dir.vim* +autoload/tlib/file.vim tlib.txt /*autoload\/tlib\/file.vim* +autoload/tlib/hook.vim tlib.txt /*autoload\/tlib\/hook.vim* +autoload/tlib/input.vim tlib.txt /*autoload\/tlib\/input.vim* +autoload/tlib/list.vim tlib.txt /*autoload\/tlib\/list.vim* +autoload/tlib/map.vim tlib.txt /*autoload\/tlib\/map.vim* +autoload/tlib/normal.vim tlib.txt /*autoload\/tlib\/normal.vim* +autoload/tlib/notify.vim tlib.txt /*autoload\/tlib\/notify.vim* +autoload/tlib/paragraph.vim tlib.txt /*autoload\/tlib\/paragraph.vim* +autoload/tlib/persistent.vim tlib.txt /*autoload\/tlib\/persistent.vim* +autoload/tlib/progressbar.vim tlib.txt /*autoload\/tlib\/progressbar.vim* +autoload/tlib/rx.vim tlib.txt /*autoload\/tlib\/rx.vim* +autoload/tlib/scratch.vim tlib.txt /*autoload\/tlib\/scratch.vim* +autoload/tlib/selection.vim tlib.txt /*autoload\/tlib\/selection.vim* +autoload/tlib/signs.vim tlib.txt /*autoload\/tlib\/signs.vim* +autoload/tlib/string.vim tlib.txt /*autoload\/tlib\/string.vim* +autoload/tlib/sys.vim tlib.txt /*autoload\/tlib\/sys.vim* +autoload/tlib/tab.vim tlib.txt /*autoload\/tlib\/tab.vim* +autoload/tlib/tag.vim tlib.txt /*autoload\/tlib\/tag.vim* +autoload/tlib/textobjects.vim tlib.txt /*autoload\/tlib\/textobjects.vim* +autoload/tlib/trace.vim tlib.txt /*autoload\/tlib\/trace.vim* +autoload/tlib/type.vim tlib.txt /*autoload\/tlib\/type.vim* +autoload/tlib/url.vim tlib.txt /*autoload\/tlib\/url.vim* +autoload/tlib/var.vim tlib.txt /*autoload\/tlib\/var.vim* +autoload/tlib/vcs.vim tlib.txt /*autoload\/tlib\/vcs.vim* +autoload/tlib/vim.vim tlib.txt /*autoload\/tlib\/vim.vim* +autoload/tlib/win.vim tlib.txt /*autoload\/tlib\/win.vim* +g:tlib#Filter_glob#char tlib.txt /*g:tlib#Filter_glob#char* +g:tlib#Filter_glob#seq tlib.txt /*g:tlib#Filter_glob#seq* +g:tlib#cache#dont_purge tlib.txt /*g:tlib#cache#dont_purge* +g:tlib#cache#max_filename tlib.txt /*g:tlib#cache#max_filename* +g:tlib#cache#purge_days tlib.txt /*g:tlib#cache#purge_days* +g:tlib#cache#purge_every_days tlib.txt /*g:tlib#cache#purge_every_days* +g:tlib#cache#run_script tlib.txt /*g:tlib#cache#run_script* +g:tlib#cache#script_encoding tlib.txt /*g:tlib#cache#script_encoding* +g:tlib#cache#verbosity tlib.txt /*g:tlib#cache#verbosity* +g:tlib#dir#sep tlib.txt /*g:tlib#dir#sep* +g:tlib#file#drop tlib.txt /*g:tlib#file#drop* +g:tlib#input#filename_max_width tlib.txt /*g:tlib#input#filename_max_width* +g:tlib#input#filename_padding_r tlib.txt /*g:tlib#input#filename_padding_r* +g:tlib#input#filter_mode tlib.txt /*g:tlib#input#filter_mode* +g:tlib#input#format_filename tlib.txt /*g:tlib#input#format_filename* +g:tlib#input#higroup tlib.txt /*g:tlib#input#higroup* +g:tlib#input#keyagents_InputList_s tlib.txt /*g:tlib#input#keyagents_InputList_s* +g:tlib#input#livesearch_threshold tlib.txt /*g:tlib#input#livesearch_threshold* +g:tlib#input#numeric_chars tlib.txt /*g:tlib#input#numeric_chars* +g:tlib#input#sortprefs_threshold tlib.txt /*g:tlib#input#sortprefs_threshold* +g:tlib#input#use_popup tlib.txt /*g:tlib#input#use_popup* +g:tlib#input#user_shortcuts tlib.txt /*g:tlib#input#user_shortcuts* +g:tlib#scratch#hidden tlib.txt /*g:tlib#scratch#hidden* +g:tlib#sys#check_cygpath tlib.txt /*g:tlib#sys#check_cygpath* +g:tlib#sys#cygwin_expr tlib.txt /*g:tlib#sys#cygwin_expr* +g:tlib#sys#cygwin_path_rx tlib.txt /*g:tlib#sys#cygwin_path_rx* +g:tlib#sys#special_protocols tlib.txt /*g:tlib#sys#special_protocols* +g:tlib#sys#special_suffixes tlib.txt /*g:tlib#sys#special_suffixes* +g:tlib#sys#system_browser tlib.txt /*g:tlib#sys#system_browser* +g:tlib#sys#system_rx tlib.txt /*g:tlib#sys#system_rx* +g:tlib#trace#backtrace tlib.txt /*g:tlib#trace#backtrace* +g:tlib#trace#printer tlib.txt /*g:tlib#trace#printer* +g:tlib#vcs#check tlib.txt /*g:tlib#vcs#check* +g:tlib#vcs#def tlib.txt /*g:tlib#vcs#def* +g:tlib#vcs#executables tlib.txt /*g:tlib#vcs#executables* +g:tlib#vim#simalt_maximize tlib.txt /*g:tlib#vim#simalt_maximize* +g:tlib#vim#simalt_restore tlib.txt /*g:tlib#vim#simalt_restore* +g:tlib#vim#use_vimtweak tlib.txt /*g:tlib#vim#use_vimtweak* +g:tlib#vim#use_wmctrl tlib.txt /*g:tlib#vim#use_wmctrl* +g:tlib_cache tlib.txt /*g:tlib_cache* +g:tlib_inputlist_filename_indicators tlib.txt /*g:tlib_inputlist_filename_indicators* +g:tlib_inputlist_max_cols tlib.txt /*g:tlib_inputlist_max_cols* +g:tlib_inputlist_max_lines tlib.txt /*g:tlib_inputlist_max_lines* +g:tlib_inputlist_pct tlib.txt /*g:tlib_inputlist_pct* +g:tlib_inputlist_shortmessage tlib.txt /*g:tlib_inputlist_shortmessage* +g:tlib_inputlist_width_filename tlib.txt /*g:tlib_inputlist_width_filename* +g:tlib_persistent tlib.txt /*g:tlib_persistent* +g:tlib_pick_last_item tlib.txt /*g:tlib_pick_last_item* +g:tlib_scratch_pos tlib.txt /*g:tlib_scratch_pos* +g:tlib_scroll_lines tlib.txt /*g:tlib_scroll_lines* +g:tlib_tag_substitute tlib.txt /*g:tlib_tag_substitute* +g:tlib_tags_extra tlib.txt /*g:tlib_tags_extra* +g:tlib_viewline_position tlib.txt /*g:tlib_viewline_position* +plugin/02tlib.vim tlib.txt /*plugin\/02tlib.vim* +standard-paragraph tlib.txt /*standard-paragraph* +tlib#Filter_cnf#New() tlib.txt /*tlib#Filter_cnf#New()* +tlib#Filter_cnfd#New() tlib.txt /*tlib#Filter_cnfd#New()* +tlib#Filter_fuzzy#New() tlib.txt /*tlib#Filter_fuzzy#New()* +tlib#Filter_glob#New() tlib.txt /*tlib#Filter_glob#New()* +tlib#Object#New() tlib.txt /*tlib#Object#New()* +tlib#agent#GotoLine() tlib.txt /*tlib#agent#GotoLine()* +tlib#agent#NewItem() tlib.txt /*tlib#agent#NewItem()* +tlib#agent#Suspend() tlib.txt /*tlib#agent#Suspend()* +tlib#agent#SuspendToParentWindow() tlib.txt /*tlib#agent#SuspendToParentWindow()* +tlib#arg#Ex() tlib.txt /*tlib#arg#Ex()* +tlib#arg#Get() tlib.txt /*tlib#arg#Get()* +tlib#arg#GetOpts() tlib.txt /*tlib#arg#GetOpts()* +tlib#arg#Let() tlib.txt /*tlib#arg#Let()* +tlib#assert#Disable() tlib.txt /*tlib#assert#Disable()* +tlib#assert#Enable() tlib.txt /*tlib#assert#Enable()* +tlib#buffer#BufDo() tlib.txt /*tlib#buffer#BufDo()* +tlib#buffer#DeleteRange() tlib.txt /*tlib#buffer#DeleteRange()* +tlib#buffer#Eval() tlib.txt /*tlib#buffer#Eval()* +tlib#buffer#GetList() tlib.txt /*tlib#buffer#GetList()* +tlib#buffer#InsertText() tlib.txt /*tlib#buffer#InsertText()* +tlib#buffer#KeepCursorPosition() tlib.txt /*tlib#buffer#KeepCursorPosition()* +tlib#buffer#ReplaceRange() tlib.txt /*tlib#buffer#ReplaceRange()* +tlib#buffer#ScratchEnd() tlib.txt /*tlib#buffer#ScratchEnd()* +tlib#buffer#ScratchStart() tlib.txt /*tlib#buffer#ScratchStart()* +tlib#buffer#Set() tlib.txt /*tlib#buffer#Set()* +tlib#buffer#ViewLine() tlib.txt /*tlib#buffer#ViewLine()* +tlib#cache#Dir() tlib.txt /*tlib#cache#Dir()* +tlib#cache#EncodedFilename() tlib.txt /*tlib#cache#EncodedFilename()* +tlib#cache#MaybePurge() tlib.txt /*tlib#cache#MaybePurge()* +tlib#cache#Purge() tlib.txt /*tlib#cache#Purge()* +tlib#cache#Value() tlib.txt /*tlib#cache#Value()* +tlib#char#Get() tlib.txt /*tlib#char#Get()* +tlib#cmd#BrowseOutput() tlib.txt /*tlib#cmd#BrowseOutput()* +tlib#cmd#BrowseOutputWithCallback() tlib.txt /*tlib#cmd#BrowseOutputWithCallback()* +tlib#cmd#Time() tlib.txt /*tlib#cmd#Time()* +tlib#cmd#UseVertical() tlib.txt /*tlib#cmd#UseVertical()* +tlib#comments#Comments() tlib.txt /*tlib#comments#Comments()* +tlib#date#SecondsSince1970() tlib.txt /*tlib#date#SecondsSince1970()* +tlib#dir#CanonicName() tlib.txt /*tlib#dir#CanonicName()* +tlib#dir#Ensure() tlib.txt /*tlib#dir#Ensure()* +tlib#dir#MyRuntime() tlib.txt /*tlib#dir#MyRuntime()* +tlib#dir#NativeName() tlib.txt /*tlib#dir#NativeName()* +tlib#dir#PlainName() tlib.txt /*tlib#dir#PlainName()* +tlib#file#Edit() tlib.txt /*tlib#file#Edit()* +tlib#file#Join() tlib.txt /*tlib#file#Join()* +tlib#file#Relative() tlib.txt /*tlib#file#Relative()* +tlib#file#Split() tlib.txt /*tlib#file#Split()* +tlib#hook#Run() tlib.txt /*tlib#hook#Run()* +tlib#input#CommandSelect() tlib.txt /*tlib#input#CommandSelect()* +tlib#input#Edit() tlib.txt /*tlib#input#Edit()* +tlib#input#EditList() tlib.txt /*tlib#input#EditList()* +tlib#input#List() tlib.txt /*tlib#input#List()* +tlib#input#ListD() tlib.txt /*tlib#input#ListD()* +tlib#input#ListW() tlib.txt /*tlib#input#ListW()* +tlib#list#All() tlib.txt /*tlib#list#All()* +tlib#list#Any() tlib.txt /*tlib#list#Any()* +tlib#list#Compact() tlib.txt /*tlib#list#Compact()* +tlib#list#Find() tlib.txt /*tlib#list#Find()* +tlib#list#FindAll() tlib.txt /*tlib#list#FindAll()* +tlib#list#Flatten() tlib.txt /*tlib#list#Flatten()* +tlib#list#Inject() tlib.txt /*tlib#list#Inject()* +tlib#list#Remove() tlib.txt /*tlib#list#Remove()* +tlib#list#RemoveAll() tlib.txt /*tlib#list#RemoveAll()* +tlib#list#Zip() tlib.txt /*tlib#list#Zip()* +tlib#map#PumAccept() tlib.txt /*tlib#map#PumAccept()* +tlib#normal#WithRegister() tlib.txt /*tlib#normal#WithRegister()* +tlib#notify#Echo() tlib.txt /*tlib#notify#Echo()* +tlib#notify#TrimMessage() tlib.txt /*tlib#notify#TrimMessage()* +tlib#paragraph#GetMetric() tlib.txt /*tlib#paragraph#GetMetric()* +tlib#paragraph#Move() tlib.txt /*tlib#paragraph#Move()* +tlib#persistent#Dir() tlib.txt /*tlib#persistent#Dir()* +tlib#persistent#EncodedFilename() tlib.txt /*tlib#persistent#EncodedFilename()* +tlib#progressbar#Init() tlib.txt /*tlib#progressbar#Init()* +tlib#rx#Escape() tlib.txt /*tlib#rx#Escape()* +tlib#rx#EscapeReplace() tlib.txt /*tlib#rx#EscapeReplace()* +tlib#scratch#CloseScratch() tlib.txt /*tlib#scratch#CloseScratch()* +tlib#scratch#UseScratch() tlib.txt /*tlib#scratch#UseScratch()* +tlib#selection#GetSelection() tlib.txt /*tlib#selection#GetSelection()* +tlib#signs#ClearAll() tlib.txt /*tlib#signs#ClearAll()* +tlib#signs#ClearBuffer() tlib.txt /*tlib#signs#ClearBuffer()* +tlib#signs#Mark() tlib.txt /*tlib#signs#Mark()* +tlib#string#Format() tlib.txt /*tlib#string#Format()* +tlib#string#Printf1() tlib.txt /*tlib#string#Printf1()* +tlib#string#RemoveBackslashes() tlib.txt /*tlib#string#RemoveBackslashes()* +tlib#sys#IsSpecial() tlib.txt /*tlib#sys#IsSpecial()* +tlib#sys#MaybeUseCygpath() tlib.txt /*tlib#sys#MaybeUseCygpath()* +tlib#sys#Open() tlib.txt /*tlib#sys#Open()* +tlib#sys#OpenWithSystemViewer() tlib.txt /*tlib#sys#OpenWithSystemViewer()* +tlib#tab#BufMap() tlib.txt /*tlib#tab#BufMap()* +tlib#tab#TabWinNr() tlib.txt /*tlib#tab#TabWinNr()* +tlib#tag#Collect() tlib.txt /*tlib#tag#Collect()* +tlib#tag#Retrieve() tlib.txt /*tlib#tag#Retrieve()* +tlib#trace#Disable() tlib.txt /*tlib#trace#Disable()* +tlib#trace#Enable() tlib.txt /*tlib#trace#Enable()* +tlib#trace#Print() tlib.txt /*tlib#trace#Print()* +tlib#trace#Printer_echom() tlib.txt /*tlib#trace#Printer_echom()* +tlib#trace#Set() tlib.txt /*tlib#trace#Set()* +tlib#type#Disable() tlib.txt /*tlib#type#Disable()* +tlib#type#Enable() tlib.txt /*tlib#type#Enable()* +tlib#url#Decode() tlib.txt /*tlib#url#Decode()* +tlib#url#DecodeChar() tlib.txt /*tlib#url#DecodeChar()* +tlib#url#Encode() tlib.txt /*tlib#url#Encode()* +tlib#url#EncodeChar() tlib.txt /*tlib#url#EncodeChar()* +tlib#var#EGet() tlib.txt /*tlib#var#EGet()* +tlib#var#Get() tlib.txt /*tlib#var#Get()* +tlib#var#Let() tlib.txt /*tlib#var#Let()* +tlib#var#List() tlib.txt /*tlib#var#List()* +tlib#vcs#Diff() tlib.txt /*tlib#vcs#Diff()* +tlib#vcs#Ls() tlib.txt /*tlib#vcs#Ls()* +tlib#vim#Maximize() tlib.txt /*tlib#vim#Maximize()* +tlib#vim#RestoreWindow() tlib.txt /*tlib#vim#RestoreWindow()* +tlib#win#Set() tlib.txt /*tlib#win#Set()* +tlib#win#SetById() tlib.txt /*tlib#win#SetById()* +tlib.txt tlib.txt /*tlib.txt* +v_sp tlib.txt /*v_sp* diff --git a/skel/.config/nvim/plugged/tlib_vim/doc/tlib.txt b/skel/.config/nvim/plugged/tlib_vim/doc/tlib.txt new file mode 100644 index 0000000..648181d --- /dev/null +++ b/skel/.config/nvim/plugged/tlib_vim/doc/tlib.txt @@ -0,0 +1,1610 @@ +*tlib.txt* tlib -- A library of vim functions + Author: Tom Link, micathom at gmail com + +This library provides some utility functions. There isn't much need to +install it unless another plugin requires you to do so. + +Most of the library is included in autoload files. No autocommands are +created. With the exception of loading ../plugin/02tlib.vim at startup +the library has no impact on startup time or anything else. + +The change-log is included at the bottom of ../plugin/02tlib.vim +(move the cursor over the file name and type gfG) + +Demo of |tlib#input#List()|: +http://vimsomnia.blogspot.com/2010/11/selecting-items-from-list-with-tlibs.html + + +----------------------------------------------------------------------- +Install~ + +Edit the vba file and type: > + + :so % + +See :help vimball for details. If you have difficulties, please make +sure, you have the current version of vimball (vimscript #1502) +installed. + + +======================================================================== +Contents~ + + :TLet ................................... |:TLet| + :TScratch ............................... |:TScratch| + :TVarArg ................................ |:TVarArg| + :TBrowseOutput .......................... |:TBrowseOutput| + :TBrowseScriptnames ..................... |:TBrowseScriptnames| + :Texecqfl ............................... |:Texecqfl| + :Texecloc ............................... |:Texecloc| + :Tlibtrace .............................. |:Tlibtrace| + :Tlibtraceset ........................... |:Tlibtraceset| + :Tbrowseqfl ............................. |:Tbrowseqfl| + :Tbrowseloc ............................. |:Tbrowseloc| + tlib#Filter_cnf#New ..................... |tlib#Filter_cnf#New()| + tlib#Filter_cnfd#New .................... |tlib#Filter_cnfd#New()| + tlib#Filter_fuzzy#New ................... |tlib#Filter_fuzzy#New()| + g:tlib#Filter_glob#seq .................. |g:tlib#Filter_glob#seq| + g:tlib#Filter_glob#char ................. |g:tlib#Filter_glob#char| + tlib#Filter_glob#New .................... |tlib#Filter_glob#New()| + tlib#Object#New ......................... |tlib#Object#New()| + g:tlib_inputlist_pct .................... |g:tlib_inputlist_pct| + g:tlib_inputlist_max_lines .............. |g:tlib_inputlist_max_lines| + g:tlib_inputlist_max_cols ............... |g:tlib_inputlist_max_cols| + g:tlib_inputlist_width_filename ......... |g:tlib_inputlist_width_filename| + g:tlib_inputlist_filename_indicators .... |g:tlib_inputlist_filename_indicators| + g:tlib_inputlist_shortmessage ........... |g:tlib_inputlist_shortmessage| + g:tlib_scroll_lines ..................... |g:tlib_scroll_lines| + tlib#agent#SuspendToParentWindow ........ |tlib#agent#SuspendToParentWindow()| + tlib#agent#Suspend ...................... |tlib#agent#Suspend()| + tlib#agent#NewItem ...................... |tlib#agent#NewItem()| + tlib#agent#GotoLine ..................... |tlib#agent#GotoLine()| + tlib#arg#Get ............................ |tlib#arg#Get()| + tlib#arg#Let ............................ |tlib#arg#Let()| + tlib#arg#GetOpts ........................ |tlib#arg#GetOpts()| + tlib#arg#Ex ............................. |tlib#arg#Ex()| + tlib#assert#Enable ...................... |tlib#assert#Enable()| + tlib#assert#Disable ..................... |tlib#assert#Disable()| + g:tlib_viewline_position ................ |g:tlib_viewline_position| + tlib#buffer#Set ......................... |tlib#buffer#Set()| + tlib#buffer#Eval ........................ |tlib#buffer#Eval()| + tlib#buffer#GetList ..................... |tlib#buffer#GetList()| + tlib#buffer#ViewLine .................... |tlib#buffer#ViewLine()| + tlib#buffer#DeleteRange ................. |tlib#buffer#DeleteRange()| + tlib#buffer#ReplaceRange ................ |tlib#buffer#ReplaceRange()| + tlib#buffer#ScratchStart ................ |tlib#buffer#ScratchStart()| + tlib#buffer#ScratchEnd .................. |tlib#buffer#ScratchEnd()| + tlib#buffer#BufDo ....................... |tlib#buffer#BufDo()| + tlib#buffer#InsertText .................. |tlib#buffer#InsertText()| + tlib#buffer#KeepCursorPosition .......... |tlib#buffer#KeepCursorPosition()| + g:tlib_cache ............................ |g:tlib_cache| + g:tlib#cache#purge_days ................. |g:tlib#cache#purge_days| + g:tlib#cache#purge_every_days ........... |g:tlib#cache#purge_every_days| + g:tlib#cache#script_encoding ............ |g:tlib#cache#script_encoding| + g:tlib#cache#run_script ................. |g:tlib#cache#run_script| + g:tlib#cache#verbosity .................. |g:tlib#cache#verbosity| + g:tlib#cache#dont_purge ................. |g:tlib#cache#dont_purge| + g:tlib#cache#max_filename ............... |g:tlib#cache#max_filename| + tlib#cache#Dir .......................... |tlib#cache#Dir()| + tlib#cache#EncodedFilename .............. |tlib#cache#EncodedFilename()| + tlib#cache#Value ........................ |tlib#cache#Value()| + tlib#cache#MaybePurge ................... |tlib#cache#MaybePurge()| + tlib#cache#Purge ........................ |tlib#cache#Purge()| + tlib#char#Get ........................... |tlib#char#Get()| + tlib#cmd#BrowseOutput ................... |tlib#cmd#BrowseOutput()| + tlib#cmd#BrowseOutputWithCallback ....... |tlib#cmd#BrowseOutputWithCallback()| + tlib#cmd#UseVertical .................... |tlib#cmd#UseVertical()| + tlib#cmd#Time ........................... |tlib#cmd#Time()| + tlib#comments#Comments .................. |tlib#comments#Comments()| + tlib#date#SecondsSince1970 .............. |tlib#date#SecondsSince1970()| + g:tlib#dir#sep .......................... |g:tlib#dir#sep| + tlib#dir#CanonicName .................... |tlib#dir#CanonicName()| + tlib#dir#NativeName ..................... |tlib#dir#NativeName()| + tlib#dir#PlainName ...................... |tlib#dir#PlainName()| + tlib#dir#Ensure ......................... |tlib#dir#Ensure()| + tlib#dir#MyRuntime ...................... |tlib#dir#MyRuntime()| + g:tlib#file#drop ........................ |g:tlib#file#drop| + tlib#file#Split ......................... |tlib#file#Split()| + tlib#file#Join .......................... |tlib#file#Join()| + tlib#file#Relative ...................... |tlib#file#Relative()| + tlib#file#Edit .......................... |tlib#file#Edit()| + tlib#hook#Run ........................... |tlib#hook#Run()| + g:tlib#input#sortprefs_threshold ........ |g:tlib#input#sortprefs_threshold| + g:tlib#input#livesearch_threshold ....... |g:tlib#input#livesearch_threshold| + g:tlib#input#filter_mode ................ |g:tlib#input#filter_mode| + g:tlib#input#higroup .................... |g:tlib#input#higroup| + g:tlib_pick_last_item ................... |g:tlib_pick_last_item| + g:tlib#input#numeric_chars .............. |g:tlib#input#numeric_chars| + g:tlib#input#keyagents_InputList_s ...... |g:tlib#input#keyagents_InputList_s| + g:tlib#input#user_shortcuts ............. |g:tlib#input#user_shortcuts| + g:tlib#input#use_popup .................. |g:tlib#input#use_popup| + g:tlib#input#format_filename ............ |g:tlib#input#format_filename| + g:tlib#input#filename_padding_r ......... |g:tlib#input#filename_padding_r| + g:tlib#input#filename_max_width ......... |g:tlib#input#filename_max_width| + tlib#input#List ......................... |tlib#input#List()| + tlib#input#ListD ........................ |tlib#input#ListD()| + tlib#input#ListW ........................ |tlib#input#ListW()| + tlib#input#EditList ..................... |tlib#input#EditList()| + tlib#input#CommandSelect ................ |tlib#input#CommandSelect()| + tlib#input#Edit ......................... |tlib#input#Edit()| + tlib#list#Inject ........................ |tlib#list#Inject()| + tlib#list#Compact ....................... |tlib#list#Compact()| + tlib#list#Flatten ....................... |tlib#list#Flatten()| + tlib#list#FindAll ....................... |tlib#list#FindAll()| + tlib#list#Find .......................... |tlib#list#Find()| + tlib#list#Any ........................... |tlib#list#Any()| + tlib#list#All ........................... |tlib#list#All()| + tlib#list#Remove ........................ |tlib#list#Remove()| + tlib#list#RemoveAll ..................... |tlib#list#RemoveAll()| + tlib#list#Zip ........................... |tlib#list#Zip()| + tlib#map#PumAccept ...................... |tlib#map#PumAccept()| + tlib#normal#WithRegister ................ |tlib#normal#WithRegister()| + tlib#notify#Echo ........................ |tlib#notify#Echo()| + tlib#notify#TrimMessage ................. |tlib#notify#TrimMessage()| + tlib#paragraph#GetMetric ................ |tlib#paragraph#GetMetric()| + tlib#paragraph#Move ..................... |tlib#paragraph#Move()| + g:tlib_persistent ....................... |g:tlib_persistent| + tlib#persistent#Dir ..................... |tlib#persistent#Dir()| + tlib#persistent#EncodedFilename ......... |tlib#persistent#EncodedFilename()| + tlib#progressbar#Init ................... |tlib#progressbar#Init()| + tlib#rx#Escape .......................... |tlib#rx#Escape()| + tlib#rx#EscapeReplace ................... |tlib#rx#EscapeReplace()| + g:tlib_scratch_pos ...................... |g:tlib_scratch_pos| + g:tlib#scratch#hidden ................... |g:tlib#scratch#hidden| + tlib#scratch#UseScratch ................. |tlib#scratch#UseScratch()| + tlib#scratch#CloseScratch ............... |tlib#scratch#CloseScratch()| + tlib#selection#GetSelection ............. |tlib#selection#GetSelection()| + tlib#signs#ClearAll ..................... |tlib#signs#ClearAll()| + tlib#signs#ClearBuffer .................. |tlib#signs#ClearBuffer()| + tlib#signs#Mark ......................... |tlib#signs#Mark()| + tlib#string#RemoveBackslashes ........... |tlib#string#RemoveBackslashes()| + tlib#string#Format ...................... |tlib#string#Format()| + tlib#string#Printf1 ..................... |tlib#string#Printf1()| + g:tlib#sys#special_protocols ............ |g:tlib#sys#special_protocols| + g:tlib#sys#special_suffixes ............. |g:tlib#sys#special_suffixes| + g:tlib#sys#system_rx .................... |g:tlib#sys#system_rx| + g:tlib#sys#system_browser ............... |g:tlib#sys#system_browser| + g:tlib#sys#check_cygpath ................ |g:tlib#sys#check_cygpath| + g:tlib#sys#cygwin_path_rx ............... |g:tlib#sys#cygwin_path_rx| + g:tlib#sys#cygwin_expr .................. |g:tlib#sys#cygwin_expr| + tlib#sys#MaybeUseCygpath ................ |tlib#sys#MaybeUseCygpath()| + tlib#sys#IsSpecial ...................... |tlib#sys#IsSpecial()| + tlib#sys#Open ........................... |tlib#sys#Open()| + tlib#sys#OpenWithSystemViewer ........... |tlib#sys#OpenWithSystemViewer()| + tlib#tab#BufMap ......................... |tlib#tab#BufMap()| + tlib#tab#TabWinNr ....................... |tlib#tab#TabWinNr()| + g:tlib_tags_extra ....................... |g:tlib_tags_extra| + g:tlib_tag_substitute ................... |g:tlib_tag_substitute| + tlib#tag#Retrieve ....................... |tlib#tag#Retrieve()| + tlib#tag#Collect ........................ |tlib#tag#Collect()| + tlib#textobjects#StandardParagraph ...... |standard-paragraph| + v_sp .................................... |v_sp| + g:tlib#trace#backtrace .................. |g:tlib#trace#backtrace| + g:tlib#trace#printer .................... |g:tlib#trace#printer| + tlib#trace#Printer_echom ................ |tlib#trace#Printer_echom()| + tlib#trace#Set .......................... |tlib#trace#Set()| + tlib#trace#Print ........................ |tlib#trace#Print()| + tlib#trace#Enable ....................... |tlib#trace#Enable()| + tlib#trace#Disable ...................... |tlib#trace#Disable()| + tlib#type#Enable ........................ |tlib#type#Enable()| + tlib#type#Disable ....................... |tlib#type#Disable()| + tlib#url#Decode ......................... |tlib#url#Decode()| + tlib#url#DecodeChar ..................... |tlib#url#DecodeChar()| + tlib#url#EncodeChar ..................... |tlib#url#EncodeChar()| + tlib#url#Encode ......................... |tlib#url#Encode()| + tlib#var#Let ............................ |tlib#var#Let()| + tlib#var#EGet ........................... |tlib#var#EGet()| + tlib#var#Get ............................ |tlib#var#Get()| + tlib#var#List ........................... |tlib#var#List()| + g:tlib#vcs#def .......................... |g:tlib#vcs#def| + g:tlib#vcs#executables .................. |g:tlib#vcs#executables| + g:tlib#vcs#check ........................ |g:tlib#vcs#check| + tlib#vcs#Ls ............................. |tlib#vcs#Ls()| + tlib#vcs#Diff ........................... |tlib#vcs#Diff()| + g:tlib#vim#simalt_maximize .............. |g:tlib#vim#simalt_maximize| + g:tlib#vim#simalt_restore ............... |g:tlib#vim#simalt_restore| + g:tlib#vim#use_vimtweak ................. |g:tlib#vim#use_vimtweak| + tlib#vim#Maximize ....................... |tlib#vim#Maximize()| + tlib#vim#RestoreWindow .................. |tlib#vim#RestoreWindow()| + g:tlib#vim#use_wmctrl ................... |g:tlib#vim#use_wmctrl| + tlib#win#Set ............................ |tlib#win#Set()| + tlib#win#SetById ........................ |tlib#win#SetById()| + + +------------------------------------------------------------------------ + *plugin/02tlib.vim* + *:TLet* +:TLet VAR = VALUE + Set a variable only if it doesn't already exist. + EXAMPLES: > + TLet foo = 1 + TLet foo = 2 + echo foo + => 1 +< + + *:TScratch* +:TScratch + Open a scratch buffer (a buffer without a file). + TScratch ... use split window + TScratch! ... use the whole frame + This command takes an (inner) dictionary as optional argument. + EXAMPLES: > + TScratch 'scratch': '__FOO__' + => Open a scratch buffer named __FOO__ +< + + *:TVarArg* +:TVarArg VAR1, [VAR2, DEFAULT2] ... + A convenience wrapper for |tlib#arg#Let|. + EXAMPLES: > + function! Foo(...) + TVarArg ['a', 1], 'b' + echo 'a='. a + echo 'b='. b + endf +< + + *:TBrowseOutput* +:TBrowseOutput COMMAND + Ever wondered how to efficiently browse the output of a command + without redirecting it to a file? This command takes a command as + argument and presents the output via |tlib#input#List()| so that you + can easily search for a keyword (e.g. the name of a variable or + function) and the like. + + If you press enter, the selected line will be copied to the command + line. Press ESC to cancel browsing. + + EXAMPLES: > + TBrowseOutput 20verb TeaseTheCulprit +< + + *:TBrowseScriptnames* +:TBrowseScriptnames + List all sourced script names (the output of ':scriptnames'). + + When you press enter, the selected script will be opened in the current + window. Press ESC to cancel. + + EXAMPLES: > + TBrowseScriptnames +< + + *:Texecqfl* +:Texecqfl CMD + Run CMD and display the quickfix list. + + *:Texecloc* +:Texecloc CMD + Run CMD and display the quickfix list. + + *:Tlibtrace* +:Tlibtrace GUARD, VAR1, VAR2... + Do nothing unless |tlib#trace#Enable()| was called. + + When |:Tlibtraceset| or |tlib#trace#Enable()| were called: + + If GUARD is a number that evaluates to true or if it is a string that + matches a |regexp|, which was added using Tlibtrace! (with '!'), + display the values of VAR1, VAR2 ... + + *:Tlibtraceset* +:Tlibtraceset + :Tlibtraceset[!] [--file=FILE] +RX1 -RX2... + If |tlib#trace#Enable()| was called: With the optional , users + can add and remove GUARDs (actually a |regexp|) that should be traced. + + If no `+` or `-` is prepended, assume `+`. + + With the optional bang '!', reset any options. + + *:Tbrowseqfl* +:Tlibtype val, 'type', ... + Browse the current |quickfix| list. + + *:Tbrowseloc* +:Tbrowseloc + Browse the current |location-list|. + + +------------------------------------------------------------------------ + *autoload/tlib/Filter_cnf.vim* + *tlib#Filter_cnf#New()* +tlib#Filter_cnf#New(...) + The search pattern for |tlib#input#List()| is in conjunctive normal + form: (P1 OR P2 ...) AND (P3 OR P4 ...) ... + The pattern is a '/\V' very no-'/magic' regexp pattern. + + Pressing joins two patterns with AND. + Pressing | joins two patterns with OR. + I.e. In order to get "lala AND (foo OR bar)", you type + "lala foo|bar". + + This is also the base class for other filters. + + +------------------------------------------------------------------------ + *autoload/tlib/Filter_cnfd.vim* + *tlib#Filter_cnfd#New()* +tlib#Filter_cnfd#New(...) + The same as |tlib#Filter_cnf#New()| but a dot is expanded to '\.\{-}'. + As a consequence, patterns cannot match dots. + The pattern is a '/\V' very no-'/magic' regexp pattern. + + +------------------------------------------------------------------------ + *autoload/tlib/Filter_fuzzy.vim* + *tlib#Filter_fuzzy#New()* +tlib#Filter_fuzzy#New(...) + Support for "fuzzy" pattern matching in |tlib#input#List()|. + Patterns are interpreted as if characters were connected with '.\{-}'. + + In "fuzzy" mode, the pretty printing of filenames is disabled. + + +------------------------------------------------------------------------ + *autoload/tlib/Filter_glob.vim* + *g:tlib#Filter_glob#seq* +g:tlib#Filter_glob#seq (default: '*') + A character that should be expanded to '\.\{-}'. + + *g:tlib#Filter_glob#char* +g:tlib#Filter_glob#char (default: '?') + A character that should be expanded to '\.\?'. + + *tlib#Filter_glob#New()* +tlib#Filter_glob#New(...) + The same as |tlib#Filter_cnf#New()| but a a customizable character + |see tlib#Filter_glob#seq| is expanded to '\.\{-}' and + |g:tlib#Filter_glob#char| is expanded to '\.'. + The pattern is a '/\V' very no-'/magic' regexp pattern. + + +------------------------------------------------------------------------ + *autoload/tlib/Object.vim* +Provides a prototype plus some OO-like methods. + + *tlib#Object#New()* +tlib#Object#New(?fields={}) + This function creates a prototype that provides some kind of + inheritance mechanism and a way to call parent/super methods. + + The usage demonstrated in the following example works best when every + class/prototype is defined in a file of its own. + + The reason for why there is a dedicated constructor function is that + this layout facilitates the use of templates and that methods are + hidden from the user. Other solutions are possible. + + EXAMPLES: > + let s:prototype = tlib#Object#New({ + \ '_class': ['FooBar'], + \ 'foo': 1, + \ 'bar': 2, + \ }) + " Constructor + function! FooBar(...) + let object = s:prototype.New(a:0 >= 1 ? a:1 : {}) + return object + endf + function! s:prototype.babble() { + echo "I think, therefore I am ". (self.foo * self.bar) ." months old." + } + +< This could now be used like this: > + let myfoo = FooBar({'foo': 3}) + call myfoo.babble() + => I think, therefore I am 6 months old. + echo myfoo.IsA('FooBar') + => 1 + echo myfoo.IsA('object') + => 1 + echo myfoo.IsA('Foo') + => 0 + echo myfoo.RespondTo('babble') + => 1 + echo myfoo.RespondTo('speak') + => 0 +< + + +------------------------------------------------------------------------ + *autoload/tlib/World.vim* +A prototype used by |tlib#input#List|. +Inherits from |tlib#Object#New|. + + *g:tlib_inputlist_pct* +g:tlib_inputlist_pct (default: 50) + Size of the input list window (in percent) from the main size (of &lines). + See |tlib#input#List()|. + + *g:tlib_inputlist_max_lines* +g:tlib_inputlist_max_lines (default: -1) + Max height for a horizontal list. + + *g:tlib_inputlist_max_cols* +g:tlib_inputlist_max_cols (default: -1) + Max width for a vertical list. + + *g:tlib_inputlist_width_filename* +g:tlib_inputlist_width_filename (default: '&columns / 3') + Size of filename columns when listing filenames. + See |tlib#input#List()|. + + *g:tlib_inputlist_filename_indicators* +g:tlib_inputlist_filename_indicators (default: 0) + If true, |tlib#input#List()| will show some indicators about the + status of a filename (e.g. buflisted(), bufloaded() etc.). + This is disabled by default because vim checks also for the file on + disk when doing this. + + *g:tlib_inputlist_shortmessage* +g:tlib_inputlist_shortmessage (default: 0) + If not null, display only a short info about the filter. + + +------------------------------------------------------------------------ + *autoload/tlib/agent.vim* +Various agents for use as key handlers in tlib#input#List() + + *g:tlib_scroll_lines* +g:tlib_scroll_lines (default: 10) + Number of items to move when pressing in the input list window. + + *tlib#agent#SuspendToParentWindow()* +tlib#agent#SuspendToParentWindow(world, selected) + Suspend (see |tlib#agent#Suspend|) the input loop and jump back to the + original position in the parent window. + + *tlib#agent#Suspend()* +tlib#agent#Suspend(world, selected) + Suspend lets you temporarily leave the input loop of + |tlib#input#List|. You can resume editing the list by pressing , + . , or in the suspended window. + and will immediatly select the item under the cursor. + < will select the item but the window will remain opened. + + *tlib#agent#NewItem()* +tlib#agent#NewItem(world, selected) + Insert a new item below the current one. + + *tlib#agent#GotoLine()* +tlib#agent#GotoLine(world, selected) + If not called from the scratch, we assume/guess that we don't have to + suspend the input-evaluation loop. + + +------------------------------------------------------------------------ + *autoload/tlib/arg.vim* + *tlib#arg#Get()* +tlib#arg#Get(n, var, ?default="", ?test='') + Set a positional argument from a variable argument list. + See tlib#string#RemoveBackslashes() for an example. + + *tlib#arg#Let()* +tlib#arg#Let(list, ?default='') + Set a positional arguments from a variable argument list. + See tlib#input#List() for an example. + + *tlib#arg#GetOpts()* +tlib#arg#GetOpts(args, ?def={}) + Convert a list of strings of command-line arguments into a dictonary. + + The main use case is to pass [], i.e. the command-line + arguments of a command as list, from a command definition to this + function. + + Example: + ['-h'] + => If def contains a 'help' key, invoke |:help| on its value. + + ['-ab', '--foo', '--bar=BAR', 'bla', bla'] + => {'a': 1, 'b': 1, 'foo': 1, 'bar': 'BAR', '__rest__': ['bla', 'bla']} + + ['-ab', '--', '--foo', '--bar=BAR'] + => {'a': 1, 'b': 1, '__rest__': ['--foo', '--bar=BAR']} + + *tlib#arg#Ex()* +tlib#arg#Ex(arg, ?chars='%#! ') + Escape some characters in a string. + + Use |fnamescape()| if available. + + EXAMPLES: > + exec 'edit '. tlib#arg#Ex('foo%#bar.txt') +< + + +------------------------------------------------------------------------ + *autoload/tlib/assert.vim* + *tlib#assert#Enable()* +tlib#assert#Enable() + Enable tracing via |:Tlibassert|. + + *tlib#assert#Disable()* +tlib#assert#Disable() + Disable tracing via |:Tlibassert|. + + +------------------------------------------------------------------------ + *autoload/tlib/buffer.vim* + *g:tlib_viewline_position* +g:tlib_viewline_position (default: 'zz') + Where to display the line when using |tlib#buffer#ViewLine|. + For possible values for position see |scroll-cursor|. + + *tlib#buffer#Set()* +tlib#buffer#Set(buffer) + Set the buffer to buffer and return a command as string that can be + evaluated by |:execute| in order to restore the original view. + + *tlib#buffer#Eval()* +tlib#buffer#Eval(buffer, code) + Evaluate CODE in BUFFER. + + EXAMPLES: > + call tlib#buffer#Eval('foo.txt', 'echo b:bar') +< + + *tlib#buffer#GetList()* +tlib#buffer#GetList(?show_hidden=0, ?show_number=0, " ?order='bufnr') + Possible values for the "order" argument: + bufnr :: Default behaviour + mru :: Sort buffers according to most recent use + basename :: Sort by the file's basename (last component) + + NOTE: MRU order works on second invocation only. If you want to always + use MRU order, call tlib#buffer#EnableMRU() in your ~/.vimrc file. + + *tlib#buffer#ViewLine()* +tlib#buffer#ViewLine(line, ?position='z') + line is either a number or a string that begins with a number. + For possible values for position see |scroll-cursor|. + See also |g:tlib_viewline_position|. + + *tlib#buffer#DeleteRange()* +tlib#buffer#DeleteRange(line1, line2) + Delete the lines in the current buffer. Wrapper for |:delete|. + + *tlib#buffer#ReplaceRange()* +tlib#buffer#ReplaceRange(line1, line2, lines) + Replace a range of lines. + + *tlib#buffer#ScratchStart()* +tlib#buffer#ScratchStart() + Initialize some scratch area at the bottom of the current buffer. + + *tlib#buffer#ScratchEnd()* +tlib#buffer#ScratchEnd() + Remove the in-buffer scratch area. + + *tlib#buffer#BufDo()* +tlib#buffer#BufDo(exec) + Run exec on all buffers via bufdo and return to the original buffer. + + *tlib#buffer#InsertText()* +tlib#buffer#InsertText(text, keyargs) + Keyargs: + 'shift': 0|N + 'col': col('.')|N + 'lineno': line('.')|N + 'indent': 0|1 + 'pos': 'e'|'s' ... Where to locate the cursor (somewhat like s and e in {offset}) + Insert text (a string) in the buffer. + + *tlib#buffer#KeepCursorPosition()* +tlib#buffer#KeepCursorPosition(cmd) + Evaluate cmd while maintaining the cursor position and jump registers. + + +------------------------------------------------------------------------ + *autoload/tlib/cache.vim* + *g:tlib_cache* +g:tlib_cache (default: '') + The cache directory. If empty, use |tlib#dir#MyRuntime|.'/cache'. + You might want to delete old files from this directory from time to + time with a command like: > + find ~/vimfiles/cache/ -atime +31 -type f -print -delete +< + + *g:tlib#cache#purge_days* +g:tlib#cache#purge_days (default: 31) + |tlib#cache#Purge()|: Remove cache files older than N days. + + *g:tlib#cache#purge_every_days* +g:tlib#cache#purge_every_days (default: 31) + Purge the cache every N days. Disable automatic purging by setting + this value to a negative value. + + *g:tlib#cache#script_encoding* +g:tlib#cache#script_encoding (default: &enc) + The encoding used for the purge-cache script. + Default: 'enc' + + *g:tlib#cache#run_script* +g:tlib#cache#run_script (default: 1) + Whether to run the directory removal script: + 0 ... No + 1 ... Query user + 2 ... Yes + + *g:tlib#cache#verbosity* +g:tlib#cache#verbosity (default: 1) + Verbosity level: + 0 ... Be quiet + 1 ... Display informative message + 2 ... Display detailed messages + + *g:tlib#cache#dont_purge* +g:tlib#cache#dont_purge (default: ['[\/]\.last_purge$']) + A list of regexps that are matched against partial filenames of the + cached files. If a regexp matches, the file won't be removed by + |tlib#cache#Purge()|. + + *g:tlib#cache#max_filename* +g:tlib#cache#max_filename (default: 200) + If the cache filename is longer than N characters, use + |pathshorten()|. + + *tlib#cache#Dir()* +tlib#cache#Dir(?mode = 'bg', ?ensure_dir = true) + The default cache directory. + + *tlib#cache#EncodedFilename()* +tlib#cache#EncodedFilename(type, file, ?mkdir=0, ?dir='') + Encode `file` and call |tlib#cache#Filename()|. + + *tlib#cache#Value()* +tlib#cache#Value(cfile, generator, ftime, ?generator_args=[], ?options={}) + Get a cached value from cfile. If it is outdated (compared to ftime) + or does not exist, create it calling a generator function. + + *tlib#cache#MaybePurge()* +tlib#cache#MaybePurge() + Call |tlib#cache#Purge()| if the last purge was done before + |g:tlib#cache#purge_every_days|. + + *tlib#cache#Purge()* +tlib#cache#Purge() + Delete old files. + + +------------------------------------------------------------------------ + *autoload/tlib/char.vim* + *tlib#char#Get()* +tlib#char#Get(?timeout=0) + Get a character. + + EXAMPLES: > + echo tlib#char#Get() + echo tlib#char#Get(5) +< + + +------------------------------------------------------------------------ + *autoload/tlib/cmd.vim* + *tlib#cmd#BrowseOutput()* +tlib#cmd#BrowseOutput(command) + See |:TBrowseOutput|. + + *tlib#cmd#BrowseOutputWithCallback()* +tlib#cmd#BrowseOutputWithCallback(callback, command) + Execute COMMAND and present its output in a |tlib#input#List()|; + when a line is selected, execute the function named as the CALLBACK + and pass in that line as an argument. + + The CALLBACK function gives you an opportunity to massage the COMMAND output + and possibly act on it in a meaningful way. For example, if COMMAND listed + all URIs found in the current buffer, CALLBACK could validate and then open + the selected URI in the system's default browser. + + This function is meant to be a tool to help compose the implementations of + powerful commands that use |tlib#input#List()| as a common interface. See + |TBrowseScriptnames| as an example. + + EXAMPLES: > + call tlib#cmd#BrowseOutputWithCallback('tlib#cmd#ParseScriptname', 'scriptnames') +< + + *tlib#cmd#UseVertical()* +tlib#cmd#UseVertical(?rx='') + Look at the history whether the command was called with vertical. If + an rx is provided check first if the last entry in the history matches + this rx. + + *tlib#cmd#Time()* +tlib#cmd#Time(cmd) + Print the time in seconds or milliseconds (if your version of VIM + has |+reltime|) a command takes. + + +------------------------------------------------------------------------ + *autoload/tlib/comments.vim* + *tlib#comments#Comments()* +tlib#comments#Comments(...) + function! tlib#comments#Comments(?rx='') + + +------------------------------------------------------------------------ + *autoload/tlib/date.vim* + *tlib#date#SecondsSince1970()* +tlib#date#Parse(date, ?allow_zero=0, ?silent=0) "{{{3 + tlib#date#SecondsSince1970(date, ?daysshift=0, ?allow_zero=0) + + +------------------------------------------------------------------------ + *autoload/tlib/dir.vim* + *g:tlib#dir#sep* +g:tlib#dir#sep (default: exists('+shellslash') && !&shellslash ? '\' : '/') + TLet g:tlib#dir#sep = '/' + + *tlib#dir#CanonicName()* +tlib#dir#CanonicName(dirname) + EXAMPLES: > + tlib#dir#CanonicName('foo/bar') + => 'foo/bar/' +< + + *tlib#dir#NativeName()* +tlib#dir#NativeName(dirname) + EXAMPLES: > + tlib#dir#NativeName('foo/bar/') + On Windows: + => 'foo\bar\' + On Linux: + => 'foo/bar/' +< + + *tlib#dir#PlainName()* +tlib#dir#PlainName(dirname) + EXAMPLES: > + tlib#dir#PlainName('foo/bar/') + => 'foo/bar' +< + + *tlib#dir#Ensure()* +tlib#dir#Ensure(dir) + Create a directory if it doesn't already exist. + + *tlib#dir#MyRuntime()* +tlib#dir#MyRuntime() + Return the first directory in &rtp. + + +------------------------------------------------------------------------ + *autoload/tlib/file.vim* + *g:tlib#file#drop* +g:tlib#file#drop (default: has('gui')) + If true, use |:drop| to edit loaded buffers (only available with GUI). + + *tlib#file#Split()* +tlib#file#Split(filename) + EXAMPLES: > + tlib#file#Split('foo/bar/filename.txt') + => ['foo', 'bar', 'filename.txt'] +< + + *tlib#file#Join()* +tlib#file#Join(filename_parts, ?strip_slashes=1, ?maybe_absolute=0) + EXAMPLES: > + tlib#file#Join(['foo', 'bar', 'filename.txt']) + => 'foo/bar/filename.txt' +< + + *tlib#file#Relative()* +tlib#file#Relative(filename, basedir) + EXAMPLES: > + tlib#file#Relative('foo/bar/filename.txt', 'foo') + => 'bar/filename.txt' +< + + *tlib#file#Edit()* +tlib#file#Edit(fileid) + Return 0 if the file isn't readable/doesn't exist. + Otherwise return 1. + + +------------------------------------------------------------------------ + *autoload/tlib/hook.vim* + *tlib#hook#Run()* +tlib#hook#Run(hook, ?dict={}) + Execute dict[hook], w:{hook}, b:{hook}, or g:{hook} if existent. + + +------------------------------------------------------------------------ + *autoload/tlib/input.vim* +Input-related, select from a list etc. + + *g:tlib#input#sortprefs_threshold* +g:tlib#input#sortprefs_threshold (default: 200) + If a list is bigger than this value, don't try to be smart when + selecting an item. Be slightly faster instead. + See |tlib#input#List()|. + + *g:tlib#input#livesearch_threshold* +g:tlib#input#livesearch_threshold (default: 1000) + If a list contains more items, |tlib#input#List()| does not perform an + incremental "live search" but uses |input()| to query the user for a + filter. This is useful on slower machines or with very long lists. + + *g:tlib#input#filter_mode* +g:tlib#input#filter_mode (default: 'glob') + Determine how |tlib#input#List()| and related functions work. + Can be "glob", "cnf", "cnfd", "seq", or "fuzzy". See: + glob ... Like cnf but "*" and "?" (see |g:tlib#Filter_glob#seq|, + |g:tlib#Filter_glob#char|) are interpreted as glob-like + |wildcards| (this is the default method) + - Examples: + - "f*o" matches "fo", "fxo", and "fxxxoo", but doesn't match + "far". + - Otherwise it is a derivate of the cnf method (see below). + - See also |tlib#Filter_glob#New()|. + cnfd ... Like cnf but "." is interpreted as a wildcard, i.e. it is + expanded to "\.\{-}" + - A period character (".") acts as a wildcard as if ".\{-}" (see + |/\{-|) were entered. + - Examples: + - "f.o" matches "fo", "fxo", and "fxxxoo", but doesn't match + "far". + - Otherwise it is a derivate of the cnf method (see below). + - See also |tlib#Filter_cnfd#New()|. + cnf .... Match substrings + - A blank creates an AND conjunction, i.e. the next pattern has to + match too. + - A pipe character ("|") creates an OR conjunction, either this or + the next next pattern has to match. + - Patterns are very 'nomagic' |regexp| with a |\V| prefix. + - A pattern starting with "-" makes the filter exclude items + matching that pattern. + - Examples: + - "foo bar" matches items that contain the strings "foo" AND + "bar". + - "foo|bar boo|far" matches items that contain either ("foo" OR + "bar") AND ("boo" OR "far"). + - See also |tlib#Filter_cnf#New()|. + seq .... Match sequences of characters + - |tlib#Filter_seq#New()| + fuzzy .. Match fuzzy character sequences + - |tlib#Filter_fuzzy#New()| + + *g:tlib#input#higroup* +g:tlib#input#higroup (default: 'IncSearch') + The highlight group to use for showing matches in the input list + window. + See |tlib#input#List()|. + + *g:tlib_pick_last_item* +g:tlib_pick_last_item (default: 1) + When 1, automatically select the last remaining item only if the list + had only one item to begin with. + When 2, automatically select a last remaining item after applying + any filters. + See |tlib#input#List()|. + + +Keys for |tlib#input#List|~ + + *g:tlib#input#numeric_chars* +g:tlib#input#numeric_chars + When editing a list with |tlib#input#List|, typing these numeric chars + (as returned by getchar()) will select an item based on its index, not + based on its name. I.e. in the default setting, typing a "4" will + select the fourth item, not the item called "4". + In order to make keys 0-9 filter the items in the list and make + select an item by its index, remove the keys 48 to 57 from + this dictionary. + Format: [KEY] = BASE ... the number is calculated as KEY - BASE. + + *g:tlib#input#keyagents_InputList_s* +g:tlib#input#keyagents_InputList_s + The default key bindings for single-item-select list views. + + This variable is best customized via the variable + g:tlib_extend_keyagents_InputList_s. If you want to use , + to move the cursor up and down, add these two lines to your |vimrc| + file: + + let g:tlib_extend_keyagents_InputList_s = { + \ 10: 'tlib#agent#Down', + \ 11: 'tlib#agent#Up' + \ } + + *g:tlib#input#user_shortcuts* +g:tlib#input#user_shortcuts (default: {}) + A dictionary KEY => {'agent': AGENT, 'key_name': KEY_NAME} to + customize keyboard shortcuts in the list view. + + *g:tlib#input#use_popup* +g:tlib#input#use_popup (default: has('menu') && (has('gui_gtk') || has('gui_gtk2') || has('gui_win32'))) + If true, define a popup menu for |tlib#input#List()| and related + functions. + + *g:tlib#input#format_filename* +g:tlib#input#format_filename (default: 'l') + How to format filenames: + l ... Show basenames on the left side, separated from the + directory names + r ... Show basenames on the right side + + *g:tlib#input#filename_padding_r* +g:tlib#input#filename_padding_r (default: '&co / 10') + If g:tlib#input#format_filename == 'r', how much space should be kept + free on the right side. + + *g:tlib#input#filename_max_width* +g:tlib#input#filename_max_width (default: '&co / 2') + If g:tlib#input#format_filename == 'l', an expression that + |eval()|uates to the maximum display width of filenames. + + *tlib#input#List()* +tlib#input#List(type. ?query='', ?list=[], ?handlers=[], ?default="", ?timeout=0) + Select a single or multiple items from a list. Return either the list + of selected elements or its indexes. + + By default, typing numbers will select an item by its index. See + |g:tlib#input#numeric_chars| to find out how to change this. + + The item is automatically selected if the numbers typed equals the + number of digits of the list length. I.e. if a list contains 20 items, + typing 1 will first highlight item 1 but it won't select/use it + because 1 is an ambiguous input in this context. If you press enter, + the first item will be selected. If you press another digit (e.g. 0), + item 10 will be selected. Another way to select item 1 would be to + type 01. If the list contains only 9 items, typing 1 would select the + first item right away. + + type can be: + s ... Return one selected element + si ... Return the index of the selected element + m ... Return a list of selected elements + mi ... Return a list of indexes + + Several pattern matching styles are supported. See + |g:tlib#input#filter_mode|. + + Users can type to complete the current filter with the longest + match. + + EXAMPLES: > + echo tlib#input#List('s', 'Select one item', [100,200,300]) + echo tlib#input#List('si', 'Select one item', [100,200,300]) + echo tlib#input#List('m', 'Select one or more item(s)', [100,200,300]) + echo tlib#input#List('mi', 'Select one or more item(s)', [100,200,300]) + +< See ../samples/tlib/input/tlib_input_list.vim (move the cursor over + the filename and press gf) for a more elaborated example. + + *tlib#input#ListD()* +tlib#input#ListD(dict) + A wrapper for |tlib#input#ListW()| that builds |tlib#World#New| from + dict. + + *tlib#input#ListW()* +tlib#input#ListW(world, ?command='') + The second argument (command) is meant for internal use only. + The same as |tlib#input#List| but the arguments are packed into world + (an instance of tlib#World as returned by |tlib#World#New|). + + *tlib#input#EditList()* +tlib#input#EditList(query, list, ?timeout=0) + Edit a list. + + EXAMPLES: > + echo tlib#input#EditList('Edit:', [100,200,300]) +< + + *tlib#input#CommandSelect()* +tlib#input#CommandSelect(command, ?keyargs={}) + Take a command, view the output, and let the user select an item from + its output. + + EXAMPLE: > + command! TMarks exec 'norm! `'. matchstr(tlib#input#CommandSelect('marks'), '^ \+\zs.') + command! TAbbrevs exec 'norm i'. matchstr(tlib#input#CommandSelect('abbrev'), '^\S\+\s\+\zs\S\+') +< + + *tlib#input#Edit()* +tlib#input#Edit(name, value, callback, ?cb_args=[]) + + Edit a value (asynchronously) in a scratch buffer. Use name for + identification. Call callback when done (or on cancel). + In the scratch buffer: + Press or to enter the new value, c to cancel + editing. + EXAMPLES: > + fun! FooContinue(success, text) + if a:success + let b:var = a:text + endif + endf + call tlib#input#Edit('foo', b:var, 'FooContinue') +< + + +------------------------------------------------------------------------ + *autoload/tlib/list.vim* + *tlib#list#Inject()* +tlib#list#Inject(list, initial_value, funcref) + EXAMPLES: > + echo tlib#list#Inject([1,2,3], 0, function('Add') + => 6 +< + + *tlib#list#Compact()* +tlib#list#Compact(list) + EXAMPLES: > + tlib#list#Compact([0,1,2,3,[], {}, ""]) + => [1,2,3] +< + + *tlib#list#Flatten()* +tlib#list#Flatten(list) + EXAMPLES: > + tlib#list#Flatten([0,[1,2,[3,""]]]) + => [0,1,2,3,""] +< + + *tlib#list#FindAll()* +tlib#list#FindAll(list, filter, ?process_expr="") + Basically the same as filter() + + EXAMPLES: > + tlib#list#FindAll([1,2,3], 'v:val >= 2') + => [2, 3] +< + + *tlib#list#Find()* +tlib#list#Find(list, filter, ?default="", ?process_expr="") + + EXAMPLES: > + tlib#list#Find([1,2,3], 'v:val >= 2') + => 2 +< + + *tlib#list#Any()* +tlib#list#Any(list, expr) + EXAMPLES: > + tlib#list#Any([1,2,3], 'v:val >= 2') + => 1 +< + + *tlib#list#All()* +tlib#list#All(list, expr) + EXAMPLES: > + tlib#list#All([1,2,3], 'v:val >= 2') + => 0 +< + + *tlib#list#Remove()* +tlib#list#Remove(list, element) + EXAMPLES: > + tlib#list#Remove([1,2,1,2], 2) + => [1,1,2] +< + + *tlib#list#RemoveAll()* +tlib#list#RemoveAll(list, element) + EXAMPLES: > + tlib#list#RemoveAll([1,2,1,2], 2) + => [1,1] +< + + *tlib#list#Zip()* +tlib#list#Zip(lists, ?default='') + EXAMPLES: > + tlib#list#Zip([[1,2,3], [4,5,6]]) + => [[1,4], [2,5], [3,6]] +< + + +------------------------------------------------------------------------ + *autoload/tlib/map.vim* + *tlib#map#PumAccept()* +tlib#map#PumAccept(key) + If |pumvisible()| is true, return "\". Otherwise return a:key. + For use in maps like: > + imap tlib#map#PumAccept("\") +< + + +------------------------------------------------------------------------ + *autoload/tlib/normal.vim* + *tlib#normal#WithRegister()* +tlib#normal#WithRegister(cmd, ?register='t', ?norm_cmd='norm!') + Execute a normal command while maintaining all registers. + + +------------------------------------------------------------------------ + *autoload/tlib/notify.vim* + *tlib#notify#Echo()* +tlib#notify#Echo(text, ?style='') + Print text in the echo area. Temporarily disable 'ruler' and 'showcmd' + in order to prevent |press-enter| messages. + + *tlib#notify#TrimMessage()* +tlib#notify#TrimMessage(message) + Contributed by Erik Falor: + If the line containing the message is too long, echoing it will cause + a 'Hit ENTER' prompt to appear. This function cleans up the line so + that does not happen. + The echoed line is too long if it is wider than the width of the + window, minus cmdline space taken up by the ruler and showcmd + features. + + +------------------------------------------------------------------------ + *autoload/tlib/paragraph.vim* + *tlib#paragraph#GetMetric()* +tlib#paragraph#GetMetric() + Return an object describing a |paragraph|. + + *tlib#paragraph#Move()* +tlib#paragraph#Move(direction, count) + This function can be used with the tinymode plugin to move around + paragraphs. + + Example configuration: > + + call tinymode#EnterMap("para_move", "gp") + call tinymode#ModeMsg("para_move", "Move paragraph: j/k") + call tinymode#Map("para_move", "j", "silent call tlib#paragraph#Move('Down', '[N]')") + call tinymode#Map("para_move", "k", "silent call tlib#paragraph#Move('Up', '[N]')") + call tinymode#ModeArg("para_move", "owncount", 1) +< + + +------------------------------------------------------------------------ + *autoload/tlib/persistent.vim* + *g:tlib_persistent* +g:tlib_persistent (default: '') + The directory for persistent data files. If empty, use + |tlib#dir#MyRuntime|.'/share'. + + *tlib#persistent#Dir()* +tlib#persistent#Dir(?mode = 'bg') + Return the full directory name for persistent data files. + + *tlib#persistent#EncodedFilename()* +tlib#persistent#EncodedFilename(type, file, ?mkdir=0, ?dir='') + Encode `file` and call |tlib#persistent#Filename()|. + + +------------------------------------------------------------------------ + *autoload/tlib/progressbar.vim* + *tlib#progressbar#Init()* +tlib#progressbar#Init(max, ...) + EXAMPLE: > + call tlib#progressbar#Init(20) + try + for i in range(20) + call tlib#progressbar#Display(i) + call DoSomethingThatTakesSomeTime(i) + endfor + finally + call tlib#progressbar#Restore() + endtry +< + + +------------------------------------------------------------------------ + *autoload/tlib/rx.vim* + *tlib#rx#Escape()* +tlib#rx#Escape(text, ?magic='m') + magic can be one of: m, M, v, V + See :help 'magic' + + *tlib#rx#EscapeReplace()* +tlib#rx#EscapeReplace(text, ?magic='m') + Escape return |sub-replace-special|. + + +------------------------------------------------------------------------ + *autoload/tlib/scratch.vim* + *g:tlib_scratch_pos* +g:tlib_scratch_pos (default: 'botright') + Scratch window position. By default the list window is opened on the + bottom. Set this variable to 'topleft' or '' to change this behaviour. + See |tlib#input#List()|. + + *g:tlib#scratch#hidden* +g:tlib#scratch#hidden (default: 'hide') + If you want the scratch buffer to be fully removed, you might want to + set this variable to 'wipe'. + See also https://github.com/tomtom/tlib_vim/pull/16 + + *tlib#scratch#UseScratch()* +tlib#scratch#UseScratch(?keyargs={}) + Display a scratch buffer (a buffer with no file). See :TScratch for an + example. + Return the scratch buffer's number. + Values for keyargs: + scratch_split ... 1: split, 0: window, -1: tab + + *tlib#scratch#CloseScratch()* +tlib#scratch#CloseScratch(keyargs, ...) + Close a scratch buffer as defined in keyargs (usually a World). + Return 1 if the scratch buffer is closed (or if it already was + closed). + + +------------------------------------------------------------------------ + *autoload/tlib/selection.vim* + *tlib#selection#GetSelection()* +tlib#selection#GetSelection(mode, ?mbeg="'<", ?mend="'>", ?opmode='selection') + mode can be one of: selection, lines, block + + +------------------------------------------------------------------------ + *autoload/tlib/signs.vim* + *tlib#signs#ClearAll()* +tlib#signs#ClearAll(sign) + Clear all signs with name SIGN. + + *tlib#signs#ClearBuffer()* +tlib#signs#ClearBuffer(sign, bufnr) + Clear all signs with name SIGN in buffer BUFNR. + + *tlib#signs#Mark()* +tlib#signs#Mark(sign, list) + Add signs for all locations in LIST. LIST must adhere with the + quickfix list format (see |getqflist()|; only the fields lnum and + bufnr are required). + + list:: a quickfix or location list + sign:: a sign defined with |:sign-define| + + +------------------------------------------------------------------------ + *autoload/tlib/string.vim* + *tlib#string#RemoveBackslashes()* +tlib#string#RemoveBackslashes(text, ?chars=' ') + Remove backslashes from text (but only in front of the characters in + chars). + + *tlib#string#Format()* +tlib#string#Chomp(string, ?max=0) + Format a template string. Placeholders have the format "%{NAME}". A + "%" can be inserted as "%%". + + Examples: + echo tlib#string#Format("foo %{bar} foo", {'bar': 123}, ?prefix='%') + => foo 123 foo + + *tlib#string#Printf1()* +tlib#string#Printf1(format, string) + This function deviates from |printf()| in certain ways. + Additional items: + %{rx} ... insert escaped regexp + %{fuzzyrx} ... insert typo-tolerant regexp + + +------------------------------------------------------------------------ + *autoload/tlib/sys.vim* + *g:tlib#sys#special_protocols* +g:tlib#sys#special_protocols (default: ['https\?', 'nntp', 'mailto']) + A list of |regexp|s matching protocol names that should be handled + by |g:tlib#sys#system_browser|. + CAVEAT: Must be a |\V| |regexp|. + + *g:tlib#sys#special_suffixes* +g:tlib#sys#special_suffixes (default: ['xlsx\?', 'docx\?', 'pptx\?', 'accdb', 'mdb', 'sqlite', 'pdf', 'jpg', 'png', 'gif', 'od\[tspg]']) + A list of |regexp|s matching suffixes that should be handled by + |g:tlib#sys#system_browser|. + CAVEAT: Must be a |\V| |regexp|. + + *g:tlib#sys#system_rx* +g:tlib#sys#system_rx (default: printf('\V\%(\^\%(%s\):\|.\%(%s\)\$\)', join(g:tlib#sys#special_protocols, '\|'), join(g:tlib#sys#special_suffixes, '\|'))) + Open links matching this |regexp| with |g:tlib#sys#system_browser|. + CAVEAT: Must be a |\V| |regexp|. + + *g:tlib#sys#system_browser* +g:tlib#sys#system_browser (default: ...) + Open files in the system browser. + + *g:tlib#sys#check_cygpath* +g:tlib#sys#check_cygpath (default: g:tlib#sys#windows && tlib#sys#IsExecutable('cygpath', 1)) + If true, check whether we have to convert a path via cyppath -- + see |tlib#sys#MaybeUseCygpath| + + *g:tlib#sys#cygwin_path_rx* +g:tlib#sys#cygwin_path_rx (default: '/cygwin/') + If a full windows filename (with slashes instead of backslashes) + matches this |regexp|, it is assumed to be a cygwin executable. + + *g:tlib#sys#cygwin_expr* +g:tlib#sys#cygwin_expr (default: '"bash -c ''". escape(%s, "''\\") ."''"') + For cygwin binaries, convert command calls using this vim + expression. + + *tlib#sys#MaybeUseCygpath()* +tlib#sys#MaybeUseCygpath(cmd) + If cmd seems to be a cygwin executable, use cygpath to convert + filenames. This assumes that cygwin's which command returns full + filenames for non-cygwin executables. + + *tlib#sys#IsSpecial()* +tlib#sys#IsSpecial(filename) + Check whether filename matches |g:tlib#sys#system_rx|, i.e. whether it + is a special file that should not be opened in vim. + + *tlib#sys#Open()* +tlib#sys#Open(filename) + Open filename with the default OS application (see + |g:tlib#sys#system_browser|), if |tlib#sys#IsSpecial()| return 1. + Returns 1 if successful or 0 otherwise. + + *tlib#sys#OpenWithSystemViewer()* +tlib#sys#OpenWithSystemViewer(filename) + Open filename with the default system viewer. + + +------------------------------------------------------------------------ + *autoload/tlib/tab.vim* + *tlib#tab#BufMap()* +tlib#tab#BufMap() + Return a dictionary of bufnumbers => [[tabpage, winnr] ...] + + *tlib#tab#TabWinNr()* +tlib#tab#TabWinNr(buffer) + Find a buffer's window at some tab page. + + +------------------------------------------------------------------------ + *autoload/tlib/tag.vim* + *g:tlib_tags_extra* +g:tlib_tags_extra (default: '') + Extra tags for |tlib#tag#Retrieve()| (see there). Can also be buffer-local. + + *g:tlib_tag_substitute* +g:tlib_tag_substitute + Filter the tag description through |substitute()| for these filetypes. + This applies only if the tag cmd field (see |taglist()|) is used. + + *tlib#tag#Retrieve()* +tlib#tag#Retrieve(rx, ?extra_tags=0) + Get all tags matching rx. Basically, this function simply calls + |taglist()|, but when extra_tags is true, the list of the tag files + (see 'tags') is temporarily expanded with |g:tlib_tags_extra|. + + Example use: + If you want to include tags for, eg, JDK, normal tags use can become + slow. You could proceed as follows: + 1. Create a tags file for the JDK sources. When creating the tags + file, make sure to include inheritance information and the like + (command-line options like --fields=+iaSm --extra=+q should be ok). + In this example, we want tags only for public methods (there are + most likely better ways to do this): > + ctags -R --fields=+iaSm --extra=+q ${JAVA_HOME}/src + head -n 6 tags > tags0 + grep access:public tags >> tags0 +< 2. Make 'tags' include project specific tags files. In + ~/vimfiles/after/ftplugin/java.vim insert: > + let b:tlib_tags_extra = $JAVA_HOME .'/tags0' +< 3. When this function is invoked as > + echo tlib#tag#Retrieve('print') +< it will return only project-local tags. If it is invoked as > + echo tlib#tag#Retrieve('print', 1) +< tags from the JDK will be included. + + *tlib#tag#Collect()* +tlib#tag#Collect(constraints, ?use_extra=1, ?match_front=1) + Retrieve tags that meet the constraints (a dictionnary of fields and + regexp, with the exception of the kind field which is a list of chars). + For the use of the optional use_extra argument see + |tlib#tag#Retrieve()|. + + +------------------------------------------------------------------------ + *autoload/tlib/textobjects.vim* + *standard-paragraph* +tlib#textobjects#StandardParagraph() + Select a "Standard Paragraph", i.e. a text block followed by blank + lines. Other than |ap|, the last paragraph in a document is handled + just the same. + + The |text-object| can be accessed as "sp". Example: > + + vsp ... select the current standard paragraph + +< Return 1, if the paragraph is the last one in the document. + + *v_sp* +v_sp ... :call tlib#textobjects#StandardParagraph() + sp ... Standard paragraph (for use as |text-objects|). + + +------------------------------------------------------------------------ + *autoload/tlib/trace.vim* + *g:tlib#trace#backtrace* +g:tlib#trace#backtrace (default: 2) + The length of the backtrace that should be included in + |tlib#trace#Print()|. + + *g:tlib#trace#printer* +g:tlib#trace#printer (default: 'echom') + Possible values: + - 'echom' + - ['file', FILENAME] + + *tlib#trace#Printer_echom()* +tlib#trace#Printer_echom(type, text, args) + Print traces from |tlib#trace#Print()|. + + *tlib#trace#Set()* +tlib#trace#Set(vars, ...) + Set the tracing |regexp|. See |:Tlibtrace|. + This will also call |tlib#trace#Enable()|. + + Examples: + call tlib#trace#Set(["+foo", "-bar"]) + call tlib#trace#Set("+foo,-bar") + + *tlib#trace#Print()* +tlib#trace#Print(caller, vars, values) + Print the values of vars. The first value is a "guard" (see + |:Tlibtrace|). + + *tlib#trace#Enable()* +tlib#trace#Enable() + Enable tracing via |:Tlibtrace|. + + *tlib#trace#Disable()* +tlib#trace#Disable() + Disable tracing via |:Tlibtrace|. + + +------------------------------------------------------------------------ + *autoload/tlib/type.vim* + *tlib#type#Enable()* +tlib#type#Enable() + Enable type assertiona via |:Tlibtype|. + + *tlib#type#Disable()* +tlib#type#Disable() + Disable type assertiona via |:Tlibtype|. + + +------------------------------------------------------------------------ + *autoload/tlib/url.vim* + *tlib#url#Decode()* +tlib#url#Decode(url) + Decode an encoded URL. + + *tlib#url#DecodeChar()* +tlib#url#DecodeChar(char) + Decode a single character. + + *tlib#url#EncodeChar()* +tlib#url#EncodeChar(char) + Encode a single character. + + *tlib#url#Encode()* +tlib#url#Encode(url, ...) + Encode an URL. + + +------------------------------------------------------------------------ + *autoload/tlib/var.vim* + *tlib#var#Let()* +tlib#var#Let(name, val) + Define a variable called NAME if yet undefined. + You can also use the :TLLet command. + + EXAMPLES: > + exec tlib#var#Let('g:foo', 1) + TLet g:foo = 1 +< + + *tlib#var#EGet()* +tlib#var#EGet(var, namespace, ?default='') + Retrieve a variable by searching several namespaces. + + EXAMPLES: > + let g:foo = 1 + let b:foo = 2 + let w:foo = 3 + echo eval(tlib#var#EGet('foo', 'vg')) => 1 + echo eval(tlib#var#EGet('foo', 'bg')) => 2 + echo eval(tlib#var#EGet('foo', 'wbg')) => 3 +< + + *tlib#var#Get()* +tlib#var#Get(var, namespace, ?default='') + Retrieve a variable by searching several namespaces. + + EXAMPLES: > + let g:foo = 1 + let b:foo = 2 + let w:foo = 3 + echo tlib#var#Get('foo', 'bg') => 1 + echo tlib#var#Get('foo', 'bg') => 2 + echo tlib#var#Get('foo', 'wbg') => 3 +< + + *tlib#var#List()* +tlib#var#List(rx, ?prefix='') + Get a list of variables matching rx. + EXAMPLE: + echo tlib#var#List('tlib_', 'g:') + + +------------------------------------------------------------------------ + *autoload/tlib/vcs.vim* + *g:tlib#vcs#def* +g:tlib#vcs#def {...} + A dictionarie of supported VCS (currently: git, hg, svn, bzr). + + *g:tlib#vcs#executables* +g:tlib#vcs#executables {...} + A dictionary of custom executables for VCS commands. If the value is + empty, support for that VCS will be removed. If no key is present, it + is assumed that the VCS "type" is the name of the executable. + + *g:tlib#vcs#check* +g:tlib#vcs#check (default: has('win16') || has('win32') || has('win64') ? '%s.exe' : '%s') + If non-empty, use it as a format string to check whether a VCS is + installed on your computer. + + *tlib#vcs#Ls()* +tlib#vcs#Ls(?filename=bufname('%'), ?vcs=[type, dir]) + Return the files under VCS. + + *tlib#vcs#Diff()* +tlib#vcs#Diff(filename, ?vcs=[type, dir]) + Return the diff for "filename" + + +------------------------------------------------------------------------ + *autoload/tlib/vim.vim* + *g:tlib#vim#simalt_maximize* +g:tlib#vim#simalt_maximize (default: 'x') + The alt-key for maximizing the window. + CAUTION: The value of this paramter depends on your locale and + maybe the windows version you are running. + + *g:tlib#vim#simalt_restore* +g:tlib#vim#simalt_restore (default: 'r') + The alt-key for restoring the window. + CAUTION: The value of this paramter depends on your locale and + maybe the windows version you are running. + + *g:tlib#vim#use_vimtweak* +g:tlib#vim#use_vimtweak (default: 0) + If true, use the vimtweak.dll for windows. This will enable + tlib to remove the caption for fullscreen windows. + + *tlib#vim#Maximize()* +tlib#vim#Maximize(fullscreen) + Maximize the window. + You might need to redefine |g:tlib#vim#simalt_maximize| if it doesn't + work for you. + + *tlib#vim#RestoreWindow()* +tlib#vim#RestoreWindow() + Restore the original vimsize after having called |tlib#vim#Maximize()|. + + *g:tlib#vim#use_wmctrl* +g:tlib#vim#use_wmctrl (default: executable('wmctrl')) + If true, use wmctrl for X windows to make a window + maximized/fullscreen. + + This is the preferred method for maximizing windows under X + windows. Some window managers have problem coping with the + default method of setting 'lines' and 'columns' to a large + value. + + +------------------------------------------------------------------------ + *autoload/tlib/win.vim* + *tlib#win#Set()* +tlib#win#Set(winnr) + Return vim code to jump back to the original window. + + *tlib#win#SetById()* +tlib#win#SetById(win_id) + Return vim code to jump back to the original window. + + + +vim:tw=78:fo=w2croql:isk=!-~,^*,^|,^":ts=8:ft=help:norl: diff --git a/skel/.config/nvim/plugged/tlib_vim/etc/tpl_tlib.txt b/skel/.config/nvim/plugged/tlib_vim/etc/tpl_tlib.txt new file mode 100644 index 0000000..f805970 --- /dev/null +++ b/skel/.config/nvim/plugged/tlib_vim/etc/tpl_tlib.txt @@ -0,0 +1,30 @@ +*tlib.txt* tlib -- A library of vim functions + Author: Tom Link, micathom at gmail com + +This library provides some utility functions. There isn't much need to +install it unless another plugin requires you to do so. + +Most of the library is included in autoload files. No autocommands are +created. With the exception of loading ../plugin/02tlib.vim at startup +the library has no impact on startup time or anything else. + +The change-log is included at the bottom of ../plugin/02tlib.vim +(move the cursor over the file name and type gfG) + +Demo of |tlib#input#List()|: +http://vimsomnia.blogspot.com/2010/11/selecting-items-from-list-with-tlibs.html + + +----------------------------------------------------------------------- +Install~ + +Edit the vba file and type: > + + :so % + +See :help vimball for details. If you have difficulties, please make +sure, you have the current version of vimball (vimscript #1502) +installed. + + +%s diff --git a/skel/.config/nvim/plugged/tlib_vim/macros/tlib.vim b/skel/.config/nvim/plugged/tlib_vim/macros/tlib.vim new file mode 100644 index 0000000..3e5a791 --- /dev/null +++ b/skel/.config/nvim/plugged/tlib_vim/macros/tlib.vim @@ -0,0 +1,38 @@ +" @Author: Tom Link (micathom AT gmail com?subject=[vim]) +" @GIT: http://github.com/tomtom/tlib_vim/ +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Last Change: 2015-11-09. +" @Revision: 10 + +if &cp || exists("loaded_tlib_macros") + finish +endif +let loaded_tlib_macros = 1 + +let s:save_cpo = &cpo +set cpo&vim + + +" :display: :TRequire NAME [VERSION [FILE]] +" Make a certain vim file is loaded. +" +" Conventions: If FILE isn't defined, plugin/NAME.vim is loaded. The +" file must provide a variable loaded_{NAME} that represents the version +" number. +command! -nargs=+ TRequire let s:require = [] + \ | if !exists('loaded_'. get(s:require, 0)) + \ | exec 'runtime '. get(s:require, 2, 'plugin/'. get(s:require, 0) .'.vim') + \ | if !exists('loaded_'. get(s:require, 0)) || loaded_{get(s:require, 0)} < get(s:require, 1, loaded_{get(s:require, 0)}) + \ | echoerr 'Require '. get(s:require, 0) .' >= '. get(s:require, 1, 'any version will do') + \ | finish + \ | endif + \ | endif | unlet s:require + + +" :display: :Ttimecommand CMD +" Time the execution time of CMD. +command! -nargs=1 -complete=command Ttimecommand call tlib#cmd#Time() + + +let &cpo = s:save_cpo +unlet s:save_cpo diff --git a/skel/.config/nvim/plugged/tlib_vim/plugin/02tlib.vim b/skel/.config/nvim/plugged/tlib_vim/plugin/02tlib.vim new file mode 100644 index 0000000..efa153c --- /dev/null +++ b/skel/.config/nvim/plugged/tlib_vim/plugin/02tlib.vim @@ -0,0 +1,126 @@ +" @Author: Tom Link (micathom AT gmail com?subject=[vim]) +" @Created: 2007-04-10. +" @Last Change: 2019-04-09. +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Revision: 836 +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" GetLatestVimScripts: 1863 1 tlib.vim +" tlib.vim -- Some utility functions + +if &cp || exists("g:loaded_tlib") + finish +endif +if v:version < 700 "{{{2 + echoerr "tlib requires Vim >= 7" + finish +endif +let g:loaded_tlib = 127 + +let s:save_cpo = &cpo +set cpo&vim + + +" :display: :TLet VAR = VALUE +" Set a variable only if it doesn't already exist. +" EXAMPLES: > +" TLet foo = 1 +" TLet foo = 2 +" echo foo +" => 1 +command! -nargs=+ TLet if !exists(matchstr(, '^[^=[:space:]]\+')) | exec 'let '. | endif + + +" Open a scratch buffer (a buffer without a file). +" TScratch ... use split window +" TScratch! ... use the whole frame +" This command takes an (inner) dictionary as optional argument. +" EXAMPLES: > +" TScratch 'scratch': '__FOO__' +" => Open a scratch buffer named __FOO__ +command! -bar -nargs=* -bang TScratch call tlib#scratch#UseScratch({'scratch_split': empty(''), }) + + +" :display: :TVarArg VAR1, [VAR2, DEFAULT2] ... +" A convenience wrapper for |tlib#arg#Let|. +" EXAMPLES: > +" function! Foo(...) +" TVarArg ['a', 1], 'b' +" echo 'a='. a +" echo 'b='. b +" endf +command! -nargs=+ TVarArg exec tlib#arg#Let([]) + + +" :display: :TBrowseOutput COMMAND +" Ever wondered how to efficiently browse the output of a command +" without redirecting it to a file? This command takes a command as +" argument and presents the output via |tlib#input#List()| so that you +" can easily search for a keyword (e.g. the name of a variable or +" function) and the like. +" +" If you press enter, the selected line will be copied to the command +" line. Press ESC to cancel browsing. +" +" EXAMPLES: > +" TBrowseOutput 20verb TeaseTheCulprit +command! -nargs=1 -complete=command TBrowseOutput call tlib#cmd#BrowseOutput() + + +" :display: :TBrowseScriptnames +" List all sourced script names (the output of ':scriptnames'). +" +" When you press enter, the selected script will be opened in the current +" window. Press ESC to cancel. +" +" EXAMPLES: > +" TBrowseScriptnames +command! -nargs=0 -complete=command TBrowseScriptnames call tlib#cmd#TBrowseScriptnames() + + +" :display: :Texecqfl CMD +" Run CMD and display the quickfix list. +command! -nargs=1 Texecqfl | call tlib#qfl#QflList(getqflist()) + + +" :display: :Texecloc CMD +" Run CMD and display the quickfix list. +command! -nargs=1 Texecloc | call tlib#qfl#QflList(getloclist(0)) + + +" :display: :Tlibtrace GUARD, VAR1, VAR2... +" Do nothing unless |tlib#trace#Enable()| was called. +" +" When |:Tlibtraceset| or |tlib#trace#Enable()| were called: +" +" If GUARD is a number that evaluates to true or if it is a string that +" matches a |regexp|, which was added using Tlibtrace! (with '!'), +" display the values of VAR1, VAR2 ... +command! -nargs=+ -bang Tlibtrace : + + +" :Tlibtraceset[!] [--file=FILE] +RX1 -RX2... +" If |tlib#trace#Enable()| was called: With the optional , users +" can add and remove GUARDs (actually a |regexp|) that should be traced. +" +" If no `+` or `-` is prepended, assume `+`. +" +" With the optional bang '!', reset any options. +command! -nargs=+ -bang Tlibtraceset call tlib#trace#Set(tlib#arg#GetOpts([], {'short': 0}), !empty("")) + + +" :display: :Tlibtrace ASSERTION +command! -nargs=+ -bang Tlibassert : + +" :display: :Tlibtype val, 'type', ... +command! -nargs=+ Tlibtype : + + +" Browse the current |quickfix| list. +command! -bar Tbrowseqfl call tlib#qfl#Browse() + +" Browse the current |location-list|. +command! -bar Tbrowseloc call tlib#loclist#Browse() + + +let &cpo = s:save_cpo +unlet s:save_cpo diff --git a/skel/.config/nvim/plugged/tlib_vim/samples/tlib/input/tlib_input_list.vim b/skel/.config/nvim/plugged/tlib_vim/samples/tlib/input/tlib_input_list.vim new file mode 100644 index 0000000..4d668ff --- /dev/null +++ b/skel/.config/nvim/plugged/tlib_vim/samples/tlib/input/tlib_input_list.vim @@ -0,0 +1,50 @@ +" The following variable configures the way |tlib#input#ListD()| works. +" In this example, we allow selection of multiple items (we could also +" allow only a single choice and make |tlib#input#ListD()| work on the +" indices, not the items). +" +" We also set a prompt that will be displayed in the command area. +" +" By default, |tlib#input#ListD()| will automatically select an item if +" there is only one item left matching the filter. In this example, we +" disable this feature. +" +" For demonstration purposes, we also define a key handler that prints +" the selected items. +let s:state = { + \ 'type': 'm', + \ 'query': 'Select lines for command output', + \ 'pick_last_item': 0, + \ 'key_handlers': [ + \ {'key': 16, 'agent': 'PrintMe', 'key_name': '', 'help': 'Print line'}, + \ ], + \ } + +" A key handler takes two arguments: the current state of the list +" display and a list of selected items/indices (depending on the type +" parameter). +function! PrintMe(state, items) "{{{3 + echom "You selected:" + for i in a:items + echom i + endfor + call input("Press ENTER to continue") + let a:state.state = 'redisplay' + return a:state +endf + +" In this example, we evaluate an ex-command with |:execute| and display +" the command's output as list. The user can select certain lines by +" typing some pattern or by pressing to select an item by +" number. The user can then press to print the lines (see above) +" or to pick the selected lines. +function! SelectOutput(ex) "{{{3 + redir => lines + silent exec a:ex + redir END + let state = copy(s:state) + let state.base = split(lines, '\n') + let picked = tlib#input#ListD(state) + echom "You picked: ". join(picked, ', ') +endf + diff --git a/skel/.config/nvim/plugged/tlib_vim/scripts/create_crc_table.rb b/skel/.config/nvim/plugged/tlib_vim/scripts/create_crc_table.rb new file mode 100644 index 0000000..149fe11 --- /dev/null +++ b/skel/.config/nvim/plugged/tlib_vim/scripts/create_crc_table.rb @@ -0,0 +1,67 @@ +# @Author: Tom Link (micathom AT gmail com) +# @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +# @Revision: 14 + + +def crc_vim_table + tbl = [0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, + 0x706af48f, 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, + 0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, + 0x90bf1d91, 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de, + 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, 0x136c9856, + 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9, + 0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, + 0xa2677172, 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, + 0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, + 0x45df5c75, 0xdcd60dcf, 0xabd13d59, 0x26d930ac, 0x51de003a, + 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, 0xcfba9599, + 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, + 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190, + 0x01db7106, 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, + 0x9fbfe4a5, 0xe8b8d433, 0x7807c9a2, 0x0f00f934, 0x9609a88e, + 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01, + 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, 0x6c0695ed, + 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950, + 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, + 0xfbd44c65, 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, + 0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, + 0x346ed9fc, 0xad678846, 0xda60b8d0, 0x44042d73, 0x33031de5, + 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa, 0xbe0b1010, + 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f, + 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, + 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, + 0x03b6e20c, 0x74b1d29a, 0xead54739, 0x9dd277af, 0x04db2615, + 0x73dc1683, 0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8, + 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, 0xf00f9344, + 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb, + 0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a, + 0x67dd4acc, 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, + 0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, + 0xa6bc5767, 0x3fb506dd, 0x48b2364b, 0xd80d2bda, 0xaf0a1b4c, + 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, 0x316e8eef, + 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, + 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe, + 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, + 0x2cd99e8b, 0x5bdeae1d, 0x9b64c2b0, 0xec63f226, 0x756aa39c, + 0x026d930a, 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713, + 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, 0x92d28e9b, + 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242, + 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, + 0x18b74777, 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, + 0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45, 0xa00ae278, + 0xd70dd2ee, 0x4e048354, 0x3903b3c2, 0xa7672661, 0xd06016f7, + 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc, 0x40df0b66, + 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9, + 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, + 0xcdd70693, 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, + 0x5d681b02, 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, + 0x2d02ef8d] + tbl.map! do |num| + b = "%b" % num + bits = b.split(//) + bits.map! {|b| b.to_i} + bits.reverse + end + VIM::command("let @t = '#{tbl.inspect}'") +end + diff --git a/skel/.config/nvim/plugged/tlib_vim/spec/tlib/arg.vim b/skel/.config/nvim/plugged/tlib_vim/spec/tlib/arg.vim new file mode 100644 index 0000000..cf060a2 --- /dev/null +++ b/skel/.config/nvim/plugged/tlib_vim/spec/tlib/arg.vim @@ -0,0 +1,66 @@ +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2010-04-03. +" @Last Change: 2010-04-03. +" @Revision: 1 + +let s:save_cpo = &cpo +set cpo&vim + + + +SpecBegin 'title': 'tlib#arg' + +function! TestGetArg(...) "{{{3 + exec tlib#arg#Get(1, 'foo', 1) + return foo +endf + +function! TestGetArg1(...) "{{{3 + exec tlib#arg#Get(1, 'foo', 1, '!= ""') + return foo +endf + +Should be equal TestGetArg(), 1 +Should be equal TestGetArg(''), '' +Should be equal TestGetArg(2), 2 +Should be equal TestGetArg1(), 1 +Should be equal TestGetArg1(''), 1 +Should be equal TestGetArg1(2), 2 + +function! TestArgs(...) "{{{3 + exec tlib#arg#Let([['foo', "o"], ['bar', 2]]) + return repeat(foo, bar) +endf +Should be equal TestArgs(), 'oo' +Should be equal TestArgs('a'), 'aa' +Should be equal TestArgs('a', 3), 'aaa' + +function! TestArgs1(...) "{{{3 + exec tlib#arg#Let(['foo', ['bar', 2]]) + return repeat(foo, bar) +endf +Should be equal TestArgs1(), '' +Should be equal TestArgs1('a'), 'aa' +Should be equal TestArgs1('a', 3), 'aaa' + +function! TestArgs2(...) "{{{3 + exec tlib#arg#Let(['foo', 'bar'], 1) + return repeat(foo, bar) +endf +Should be equal TestArgs2(), '1' +Should be equal TestArgs2('a'), 'a' +Should be equal TestArgs2('a', 3), 'aaa' + +function! TestArgs3(...) + TVarArg ['a', 1], 'b' + return a . b +endf +Should be equal TestArgs3(), '1' +Should be equal TestArgs3('a'), 'a' +Should be equal TestArgs3('a', 3), 'a3' + + +let &cpo = s:save_cpo +unlet s:save_cpo diff --git a/skel/.config/nvim/plugged/tlib_vim/spec/tlib/date.vim b/skel/.config/nvim/plugged/tlib_vim/spec/tlib/date.vim new file mode 100644 index 0000000..42c336b --- /dev/null +++ b/skel/.config/nvim/plugged/tlib_vim/spec/tlib/date.vim @@ -0,0 +1,61 @@ +" @Author: Tom Link (micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @GIT: http://github.com/tomtom/vimtlib/ +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2010-09-17. +" @Last Change: 2016-03-16. +" @Revision: 21 + +SpecBegin 'title': 'tlib#date' + +Should be equal tlib#date#Parse('2000-1-0', 1), [2000, 1, 0] +Should be equal tlib#date#Parse('2000-1-2'), [2000, 1, 2] +Should be equal tlib#date#Parse('2000-01-02'), [2000, 1, 2] +Should be equal tlib#date#Parse('2000-10-20'), [2000, 10, 20] + +Should be equal tlib#date#Parse('00-1-0', 1), [2000, 1, 0] +Should be equal tlib#date#Parse('00-1-2'), [2000, 1, 2] +Should be equal tlib#date#Parse('00-01-02'), [2000, 1, 2] +Should be equal tlib#date#Parse('00-10-20'), [2000, 10, 20] + +Should be equal tlib#date#Parse('2000/2/1'), [2000, 1, 2] +Should be equal tlib#date#Parse('2000/02/01'), [2000, 1, 2] +Should be equal tlib#date#Parse('2000/20/10'), [2000, 10, 20] + +Should be equal tlib#date#Parse('00/2/1'), [2000, 1, 2] +Should be equal tlib#date#Parse('00/02/01'), [2000, 1, 2] +Should be equal tlib#date#Parse('00/20/10'), [2000, 10, 20] + +Should be equal tlib#date#Parse('2.1.2000'), [2000, 1, 2] +Should be equal tlib#date#Parse('2. 1. 2000'), [2000, 1, 2] +Should be equal tlib#date#Parse('02.01.2000'), [2000, 1, 2] +Should be equal tlib#date#Parse('02. 01. 2000'), [2000, 1, 2] +Should be equal tlib#date#Parse('20.10.2000'), [2000, 10, 20] +Should be equal tlib#date#Parse('20. 10. 2000'), [2000, 10, 20] + +Should throw exception "tlib#date#Parse('2000-14-2')", 'TLib: Invalid date' +Should throw exception "tlib#date#Parse('2000-011-02')", 'TLib: Invalid date' +Should throw exception "tlib#date#Parse('2000-10-40')", 'TLib: Invalid date' +Should throw exception "tlib#date#Parse('2000-10-0')", 'TLib: Invalid date' + +Should be equal tlib#date#Shift('2015-10-29', '1m'), '2015-11-29' +Should be equal tlib#date#Shift('2015-11-29', '1m'), '2015-12-29' +Should be equal tlib#date#Shift('2015-12-29', '1m'), '2016-01-29' +Should be equal tlib#date#Shift('2016-01-29', '1m'), '2016-02-29' +Should be equal tlib#date#Shift('2015-10-29', '2m'), '2015-12-29' +Should be equal tlib#date#Shift('2015-10-29', '3m'), '2016-01-29' +Should be equal tlib#date#Shift('2015-10-29', '4m'), '2016-02-29' +Should be equal tlib#date#Shift('2015-12-30', '1d'), '2015-12-31' +Should be equal tlib#date#Shift('2015-12-31', '1d'), '2016-01-01' +Should be equal tlib#date#Shift('2015-12-30', '2d'), '2016-01-01' +Should be equal tlib#date#Shift('2015-12-30', '3d'), '2016-01-02' + +Should be equal tlib#date#Shift('2016-03-16', '1b'), '2016-03-17' +Should be equal tlib#date#Shift('2016-03-16', '2b'), '2016-03-18' +Should be equal tlib#date#Shift('2016-03-16', '3b'), '2016-03-21' +Should be equal tlib#date#Shift('2016-03-16', '4b'), '2016-03-22' +Should be equal tlib#date#Shift('2016-03-16', '5b'), '2016-03-23' +Should be equal tlib#date#Shift('2016-03-16', '6b'), '2016-03-24' +Should be equal tlib#date#Shift('2016-03-16', '7b'), '2016-03-25' +Should be equal tlib#date#Shift('2016-03-16', '8b'), '2016-03-28' + diff --git a/skel/.config/nvim/plugged/tlib_vim/spec/tlib/dictionary.vim b/skel/.config/nvim/plugged/tlib_vim/spec/tlib/dictionary.vim new file mode 100644 index 0000000..52439e6 --- /dev/null +++ b/skel/.config/nvim/plugged/tlib_vim/spec/tlib/dictionary.vim @@ -0,0 +1,28 @@ +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @Website: https://github.com/tomtom +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2016-04-03. +" @Last Change: 2016-04-03. + +let s:save_cpo = &cpo +set cpo&vim + + + +SpecBegin 'title': 'tlib#dictionary' + + +It should handle basic test cases for tlib#dictionary#Rev properly. + +Should be equal tlib#dictionary#Rev({}), {} +Should be equal tlib#dictionary#Rev({1: 2, 3: 4}), {'2': '1', '4': '3'} +Should be equal tlib#dictionary#Rev({1: '', 3: 4}, {'empty': '*'}), {'*': '1', '4': '3'} +Should be equal tlib#dictionary#Rev({1: '', 3: 4}, {'use_string': 1}), {'''''': '1', '4': '3'} +Should be equal tlib#dictionary#Rev({1: '', 3: 4}, {'use_string': 1, 'use_eval': 1}), {'''''': 1, '4': 3} +Should be equal tlib#dictionary#Rev(tlib#dictionary#Rev({1: '', 3: 4}, {'use_string': 1}), {'use_eval': 1}), {1: '', 3: 4} +Should be equal tlib#dictionary#Rev({1: 4, 2: 4}, {'values_as_list': 1}), {'4': ['1', '2']} +Should be equal tlib#dictionary#Rev({1: 4, 2: 4}, {'values_as_list': 1, 'use_eval': 1}), {'4': [1, 2]} + + +let &cpo = s:save_cpo +unlet s:save_cpo diff --git a/skel/.config/nvim/plugged/tlib_vim/spec/tlib/eval.vim b/skel/.config/nvim/plugged/tlib_vim/spec/tlib/eval.vim new file mode 100644 index 0000000..40c5138 --- /dev/null +++ b/skel/.config/nvim/plugged/tlib_vim/spec/tlib/eval.vim @@ -0,0 +1,27 @@ +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @Website: https://github.com/tomtom +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2015-10-26. +" @Last Change: 2015-10-26. + +let s:save_cpo = &cpo +set cpo&vim + + +SpecBegin 'title': 'tlib#eval' + + +let g:eval_a = {'foo': range(0, 5), 'd': {'a': range(0, 5)}} +let g:eval_b = {'foo': range(6, 10), 'd': {'a': range(6, 10), 'b': 2}, 'bar': range(5)} +let g:eval_a0 = deepcopy(g:eval_a) +let g:eval_b0 = deepcopy(g:eval_b) +let g:eval_c = {'foo': range(0, 10), 'd': {'a': range(0, 10), 'b': 2}, 'bar': range(5)} + + +Should be equal tlib#eval#Extend(copy(g:eval_a), g:eval_b), g:eval_c +Should be equal g:eval_a, g:eval_a0 +Should be equal g:eval_b, g:eval_b0 + + +let &cpo = s:save_cpo +unlet s:save_cpo diff --git a/skel/.config/nvim/plugged/tlib_vim/spec/tlib/file.vim b/skel/.config/nvim/plugged/tlib_vim/spec/tlib/file.vim new file mode 100644 index 0000000..f692abf --- /dev/null +++ b/skel/.config/nvim/plugged/tlib_vim/spec/tlib/file.vim @@ -0,0 +1,59 @@ +" @Author: Thomas Link (micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @GIT: http://github.com/tomtom/vimtlib/ +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2009-02-25. +" @Last Change: 2010-04-03. +" @Revision: 13 + +let s:save_cpo = &cpo +set cpo&vim + + +SpecBegin 'title': 'tlib/file', + \ 'sfile': 'autoload/tlib/file.vim' + + + +It should split filenames. +Should be equal tlib#file#Split('foo/bar/filename.txt'), ['foo', 'bar', 'filename.txt'] +Should be equal tlib#file#Split('/foo/bar/filename.txt'), ['', 'foo', 'bar', 'filename.txt'] +Should be equal tlib#file#Split('ftp://foo/bar/filename.txt'), ['ftp:/', 'foo', 'bar', 'filename.txt'] + + +It should join filenames. +Should be#Equal tlib#file#Join(['foo', 'bar']), 'foo/bar' +Should be#Equal tlib#file#Join(['foo/', 'bar'], 1), 'foo/bar' +Should be#Equal tlib#file#Join(['', 'bar']), '/bar' +Should be#Equal tlib#file#Join(['/', 'bar'], 1), '/bar' +Should be#Equal tlib#file#Join(['foo', 'bar', 'filename.txt']), 'foo/bar/filename.txt' +Should be#Equal tlib#file#Join(['', 'foo', 'bar', 'filename.txt']), '/foo/bar/filename.txt' +Should be#Equal tlib#file#Join(['ftp:/', 'foo', 'bar', 'filename.txt']), 'ftp://foo/bar/filename.txt' +Should be#Equal tlib#file#Join(['ftp://', 'foo', 'bar', 'filename.txt'], 1), 'ftp://foo/bar/filename.txt' + +Should be equal tlib#file#Join(['foo', 'bar', 'filename.txt']), 'foo/bar/filename.txt' +Should be equal tlib#file#Join(['', 'foo', 'bar', 'filename.txt']), '/foo/bar/filename.txt' +Should be equal tlib#file#Join(['ftp:/', 'foo', 'bar', 'filename.txt']), 'ftp://foo/bar/filename.txt' + + +It should construct relative path names. +Should be#Equal tlib#file#Relative('foo/bar/filename.txt', 'foo'), 'bar/filename.txt' +Should be#Equal tlib#file#Relative('foo/bar/filename.txt', 'foo/base'), '../bar/filename.txt' +Should be#Equal tlib#file#Relative('filename.txt', 'foo/base'), '../../filename.txt' +Should be#Equal tlib#file#Relative('/foo/bar/filename.txt', '/boo/base'), '../../foo/bar/filename.txt' +Should be#Equal tlib#file#Relative('/bar/filename.txt', '/boo/base'), '../../bar/filename.txt' +Should be#Equal tlib#file#Relative('/foo/bar/filename.txt', '/base'), '../foo/bar/filename.txt' +Should be#Equal tlib#file#Relative('c:/bar/filename.txt', 'x:/boo/base'), 'c:/bar/filename.txt' + + +Should be equal tlib#file#Relative('foo/bar/filename.txt', 'foo'), 'bar/filename.txt' +Should be equal tlib#file#Relative('foo/bar/filename.txt', 'foo/base'), '../bar/filename.txt' +Should be equal tlib#file#Relative('filename.txt', 'foo/base'), '../../filename.txt' +Should be equal tlib#file#Relative('/foo/bar/filename.txt', '/boo/base'), '../../foo/bar/filename.txt' +Should be equal tlib#file#Relative('/bar/filename.txt', '/boo/base'), '../../bar/filename.txt' +Should be equal tlib#file#Relative('/foo/bar/filename.txt', '/base'), '../foo/bar/filename.txt' +Should be equal tlib#file#Relative('c:/bar/filename.txt', 'x:/boo/base'), 'c:/bar/filename.txt' + + +let &cpo = s:save_cpo +unlet s:save_cpo diff --git a/skel/.config/nvim/plugged/tlib_vim/spec/tlib/hash.vim b/skel/.config/nvim/plugged/tlib_vim/spec/tlib/hash.vim new file mode 100644 index 0000000..a2403a3 --- /dev/null +++ b/skel/.config/nvim/plugged/tlib_vim/spec/tlib/hash.vim @@ -0,0 +1,58 @@ +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Revision: 31 + + +SpecBegin 'title': 'tlib#hash' + + +It should calculate CRC32B checksums. + +let g:tlib_hash_use_crc32 = g:tlib#hash#use_crc32 + +let g:tlib#hash#use_crc32 = 'ruby' +Should be equal tlib#hash#CRC32B('The quick brown fox jumps over the lazy dog'), '414FA339' +Should be equal tlib#hash#CRC32B('foo'), '8C736521' +Should be equal tlib#hash#CRC32B('f'), '76D32BE0' + +let g:tlib#hash#use_crc32 = 'vim' +Should be equal tlib#hash#CRC32B('The quick brown fox jumps over the lazy dog'), '414FA339' +Should be equal tlib#hash#CRC32B('foo'), '8C736521' +Should be equal tlib#hash#CRC32B('f'), '76D32BE0' + + +function! s:CompareHash(text) "{{{3 + if !empty(a:text) + exec 'It should calculate the crc32b checksum for:' a:text + let crc32ruby = tlib#hash#CRC32B_ruby(a:text) + let crc32vim = tlib#hash#CRC32B_vim(a:text) + exec 'Should be equal' string(crc32ruby) ',' string(crc32vim) + exec 'It should calculate the adler32 checksum for:' a:text + let adler32tlib = tlib#hash#Adler32_tlib(a:text) + let adler32vim = tlib#hash#Adler32_vim(a:text) + exec 'Should be equal' string(adler32tlib) ',' string(adler32vim) + endif +endf + +redir => s:scriptnames +silent scriptnames +redir END +for s:script in split(s:scriptnames, '\n') + let s:scriptfile = matchstr(s:script, '^\s*\d\+:\s\+\zs.*$') + call s:CompareHash(s:scriptfile) + try + let s:scriptlines = readfile(s:scriptfile) + call s:CompareHash(join(s:scriptlines, "\n")) + for s:scriptline in s:scriptlines + call s:CompareHash(s:scriptline) + endfor + catch /^Vim\%((\a\+)\)\=:E484/ + endtry +endfor +unlet s:scriptnames, :script, s:scriptfile, s:scriptlines, s:scriptline +delf s:CompareHash + + +let g:tlib#hash#use_crc32 = g:tlib_hash_use_crc32 + diff --git a/skel/.config/nvim/plugged/tlib_vim/spec/tlib/input.vim b/skel/.config/nvim/plugged/tlib_vim/spec/tlib/input.vim new file mode 100644 index 0000000..f82aea6 --- /dev/null +++ b/skel/.config/nvim/plugged/tlib_vim/spec/tlib/input.vim @@ -0,0 +1,127 @@ +" @Author: Tom Link (micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @GIT: http://github.com/tomtom/vimtlib/ +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2009-02-28. +" @Last Change: 2009-03-14. +" @Revision: 73 + +let s:save_cpo = &cpo +set cpo&vim + + +SpecBegin 'title': 'tlib: Input', 'scratch': '%', + \ 'after': ':unlet! g:spec_lib_rv', + \ 'options': [ + \ 'vim', + \ ] + + +let g:spec_tlib_list = [10, 20, 30, 40, 'a50', 'aa60', 'b70', 'ba80', 90] + + + +It should return empty values when the user presses . +Replay :let g:spec_lib_rv = tlib#input#List('s', '', g:spec_tlib_list)\ + \ \\\ +Should be#Equal g:spec_lib_rv, '' + +Replay :let g:spec_lib_rv = tlib#input#List('m', '', g:spec_tlib_list)\ + \ \\\ +Should be#Equal g:spec_lib_rv, [] + +Replay :let g:spec_lib_rv = tlib#input#List('si', '', g:spec_tlib_list)\ + \ \\\ +Should be#Equal g:spec_lib_rv, 0 + + + +It should pick an item from s-type list. +Replay :let g:spec_lib_rv = tlib#input#List('s', '', g:spec_tlib_list)\ + \ \\\ +Should be#Equal g:spec_lib_rv, 30 + + + +It should return an index from si-type list. +Replay :let g:spec_lib_rv = tlib#input#List('si', '', g:spec_tlib_list)\ + \ \\\ +Should be#Equal g:spec_lib_rv, 3 + + + +It should return a list from a m-type list. +Replay :let g:spec_lib_rv = tlib#input#List('m', '', g:spec_tlib_list)\ + \ \#\\\ +Should be#Equal sort(g:spec_lib_rv), [20, 40] + +Replay :let g:spec_lib_rv = tlib#input#List('m', '', g:spec_tlib_list)\ + \ \\\ +Should be#Equal sort(g:spec_lib_rv), [20, 30] + +Replay :let g:spec_lib_rv = tlib#input#List('m', '', g:spec_tlib_list)\ + \ \\\\ +Should be#Equal sort(g:spec_lib_rv), [20, 30] + + + +It should return a list of indices from a mi-type list. +Replay :let g:spec_lib_rv = tlib#input#List('mi', '', g:spec_tlib_list)\ + \ \#\\\ +Should be#Equal sort(g:spec_lib_rv), [2, 4] + +Replay :let g:spec_lib_rv = tlib#input#List('mi', '', g:spec_tlib_list)\ + \ \\\ +Should be#Equal sort(g:spec_lib_rv), [2, 3] + +Replay :let g:spec_lib_rv = tlib#input#List('mi', '', g:spec_tlib_list)\ + \ \\\\ +Should be#Equal sort(g:spec_lib_rv), [2, 3] + + + +It should filter items from a s-type list. +Replay :let g:spec_lib_rv = tlib#input#List('s', '', g:spec_tlib_list)\ + \ \a\\ +Should be#Equal g:spec_lib_rv, 'aa60' + + + +It should filter items from a si-type list. +Replay :let g:spec_lib_rv = tlib#input#List('si', '', g:spec_tlib_list)\ + \ \a\\ +Should be#Equal g:spec_lib_rv, 6 + + + +It should filter items from a m-type list. +Replay :let g:spec_lib_rv = tlib#input#List('m', '', g:spec_tlib_list)\ + \ a\#\\ +Should be#Equal sort(g:spec_lib_rv), ['aa60', 'ba80'] + +Replay :let g:spec_lib_rv = tlib#input#List('m', '', g:spec_tlib_list)\ + \ a\\\ +Should be#Equal sort(g:spec_lib_rv), ['aa60', 'ba80'] + +Replay :let g:spec_lib_rv = tlib#input#List('m', '', g:spec_tlib_list)\ + \ a\\\\ +Should be#Equal sort(g:spec_lib_rv), ['aa60', 'ba80'] + + + +It should filter items from a mi-type list. +Replay :let g:spec_lib_rv = tlib#input#List('mi', '', g:spec_tlib_list)\ + \ a\#\\ +Should be#Equal sort(g:spec_lib_rv), [6, 8] + +Replay :let g:spec_lib_rv = tlib#input#List('mi', '', g:spec_tlib_list)\ + \ a\\\ +Should be#Equal sort(g:spec_lib_rv), [6, 8] + +Replay :let g:spec_lib_rv = tlib#input#List('mi', '', g:spec_tlib_list)\ + \ a\\\\ +Should be#Equal sort(g:spec_lib_rv), [6, 8] + + + +let &cpo = s:save_cpo diff --git a/skel/.config/nvim/plugged/tlib_vim/spec/tlib/list.vim b/skel/.config/nvim/plugged/tlib_vim/spec/tlib/list.vim new file mode 100644 index 0000000..d4aae54 --- /dev/null +++ b/skel/.config/nvim/plugged/tlib_vim/spec/tlib/list.vim @@ -0,0 +1,67 @@ +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2010-04-03. +" @Last Change: 2010-04-03. +" @Revision: 4 + +let s:save_cpo = &cpo +set cpo&vim + + + +SpecBegin 'title': 'tlib: List' + " \, 'options': [vim, <+SET+>] + " \, 'sfile': '<+SCRIPT CONTEXT+>' + " \, 'scratch': '<+SCRATCH FILE+>' + " \, 'before': '<+BEFORE EX COMMANDS+>' + " \, 'after': '<+AFTER EX COMMANDS+>' + " \, 'cleanup': ['<+FUNCTION+>()'] + + +" List {{{2 +fun! Add(a,b) + return a:a + a:b +endf + +Should be equal tlib#list#Inject([], 0, function('Add')), 0 +Should be equal tlib#list#Inject([1,2,3], 0, function('Add')), 6 + +Should be equal tlib#list#Compact([]), [] +Should be equal tlib#list#Compact([0,1,2,3,[], {}, ""]), [1,2,3] + +Should be equal tlib#list#Flatten([]), [] +Should be equal tlib#list#Flatten([1,2,3]), [1,2,3] +Should be equal tlib#list#Flatten([1,2, [1,2,3], 3]), [1,2,1,2,3,3] +Should be equal tlib#list#Flatten([0,[1,2,[3,""]]]), [0,1,2,3,""] + +Should be equal tlib#list#FindAll([1,2,3], 'v:val >= 2'), [2,3] +Should be equal tlib#list#FindAll([1,2,3], 'v:val >= 2', 'v:val * 10'), [20,30] + +Should be equal tlib#list#Find([1,2,3], 'v:val >= 2'), 2 +Should be equal tlib#list#Find([1,2,3], 'v:val >= 2', 0, 'v:val * 10'), 20 +Should be equal tlib#list#Find([1,2,3], 'v:val >= 5', 10), 10 + +Should be equal tlib#list#Any([1,2,3], 'v:val >= 2'), 1 +Should be equal tlib#list#Any([1,2,3], 'v:val >= 5'), 0 + +Should be equal tlib#list#All([1,2,3], 'v:val < 5'), 1 +Should be equal tlib#list#All([1,2,3], 'v:val >= 2'), 0 + +Should be equal tlib#list#Remove([1,2,1,2], 2), [1,1,2] +Should be equal tlib#list#RemoveAll([1,2,1,2], 2), [1,1] + +Should be equal tlib#list#Zip([[1,2,3], [4,5,6]]), [[1,4], [2,5], [3,6]] +Should be equal tlib#list#Zip([[1,2,3], [4,5,6,7]]), [[1,4], [2,5], [3,6], ['', 7]] +Should be equal tlib#list#Zip([[1,2,3], [4,5,6,7]], -1), [[1,4], [2,5], [3,6], [-1,7]] +Should be equal tlib#list#Zip([[1,2,3,7], [4,5,6]], -1), [[1,4], [2,5], [3,6], [7,-1]] + + +Should be equal tlib#list#Uniq([]), [] +Should be equal tlib#list#Uniq([1,1]), [1] +Should be equal tlib#list#Uniq([1,2,2,3,2,3,4,2,1,7,2,3,2,3,7]), [1,2,3,4,7] + + + +let &cpo = s:save_cpo +unlet s:save_cpo diff --git a/skel/.config/nvim/plugged/tlib_vim/spec/tlib/rx.vim b/skel/.config/nvim/plugged/tlib_vim/spec/tlib/rx.vim new file mode 100644 index 0000000..fc28103 --- /dev/null +++ b/skel/.config/nvim/plugged/tlib_vim/spec/tlib/rx.vim @@ -0,0 +1,27 @@ +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2010-04-03. +" @Last Change: 2010-04-03. +" @Revision: 2 + +let s:save_cpo = &cpo +set cpo&vim + + + +SpecBegin 'title': 'tlib#rx' + + +for c in split('^$.*+\()|{}[]~', '\zs') + let s = printf('%sfoo%sbar%s', c, c, c) + Should be like s, '\m^'. tlib#rx#Escape(s, 'm') .'$' + Should be like s, '\M^'. tlib#rx#Escape(s, 'M') .'$' + Should be like s, '\v^'. tlib#rx#Escape(s, 'v') .'$' + Should be like s, '\V\^'. tlib#rx#Escape(s, 'V') .'\$' +endfor + + + +let &cpo = s:save_cpo +unlet s:save_cpo diff --git a/skel/.config/nvim/plugged/tlib_vim/spec/tlib/string.vim b/skel/.config/nvim/plugged/tlib_vim/spec/tlib/string.vim new file mode 100644 index 0000000..4329d94 --- /dev/null +++ b/skel/.config/nvim/plugged/tlib_vim/spec/tlib/string.vim @@ -0,0 +1,29 @@ +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2010-04-03. +" @Last Change: 2010-04-03. +" @Revision: 4 + +let s:save_cpo = &cpo +set cpo&vim + + + +SpecBegin 'title': 'tlib#string' + +Should be equal tlib#string#RemoveBackslashes('foo bar'), 'foo bar' +Should be equal tlib#string#RemoveBackslashes('foo\ bar'), 'foo bar' +Should be equal tlib#string#RemoveBackslashes('foo\ \\bar'), 'foo \\bar' +Should be equal tlib#string#RemoveBackslashes('foo\ \\bar', '\ '), 'foo \bar' + + +Should be equal tlib#string#Count("fooo", "o"), 3 +Should be equal tlib#string#Count("***", "\\*"), 3 +Should be equal tlib#string#Count("***foo", "\\*"), 3 +Should be equal tlib#string#Count("foo***", "\\*"), 3 + + + +let &cpo = s:save_cpo +unlet s:save_cpo diff --git a/skel/.config/nvim/plugged/tlib_vim/spec/tlib/url.vim b/skel/.config/nvim/plugged/tlib_vim/spec/tlib/url.vim new file mode 100644 index 0000000..80783e9 --- /dev/null +++ b/skel/.config/nvim/plugged/tlib_vim/spec/tlib/url.vim @@ -0,0 +1,23 @@ +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2010-04-03. +" @Last Change: 2010-04-03. +" @Revision: 2 + +let s:save_cpo = &cpo +set cpo&vim + + + +SpecBegin 'title': 'tlib#url' + +Should be equal tlib#url#Decode('http://example.com/foo+bar%25bar'), 'http://example.com/foo bar%bar' +Should be equal tlib#url#Decode('Hello%20World.%20%20Good%2c%20bye.'), 'Hello World. Good, bye.' + +Should be equal tlib#url#Encode('foo bar%bar'), 'foo+bar%%bar' +Should be equal tlib#url#Encode('Hello World. Good, bye.'), 'Hello+World.+Good%2c+bye.' + + +let &cpo = s:save_cpo +unlet s:save_cpo diff --git a/skel/.config/nvim/plugged/tlib_vim/spec/tlib/var.vim b/skel/.config/nvim/plugged/tlib_vim/spec/tlib/var.vim new file mode 100644 index 0000000..28e3fac --- /dev/null +++ b/skel/.config/nvim/plugged/tlib_vim/spec/tlib/var.vim @@ -0,0 +1,37 @@ +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2010-04-03. +" @Last Change: 2010-04-03. +" @Revision: 2 + +let s:save_cpo = &cpo +set cpo&vim + + + +SpecBegin 'title': 'tlib#var' + + +let g:foo = 1 +let g:bar = 2 +let b:bar = 3 +let s:bar = 4 + +Should be equal tlib#var#Get('bar', 'bg'), 3 +Should be equal tlib#var#Get('bar', 'g'), 2 +Should be equal tlib#var#Get('foo', 'bg'), 1 +Should be equal tlib#var#Get('foo', 'g'), 1 +Should be equal tlib#var#Get('none', 'l'), '' + +Should be equal eval(tlib#var#EGet('bar', 'bg')), 3 +Should be equal eval(tlib#var#EGet('bar', 'g')), 2 +" Should be equal eval(tlib#var#EGet('bar', 'sg')), 4 +Should be equal eval(tlib#var#EGet('foo', 'bg')), 1 +Should be equal eval(tlib#var#EGet('foo', 'g')), 1 +Should be equal eval(tlib#var#EGet('none', 'l')), '' + + + +let &cpo = s:save_cpo +unlet s:save_cpo diff --git a/skel/.config/nvim/plugged/vim-addon-mw-utils/.gitignore b/skel/.config/nvim/plugged/vim-addon-mw-utils/.gitignore new file mode 100644 index 0000000..926ccaa --- /dev/null +++ b/skel/.config/nvim/plugged/vim-addon-mw-utils/.gitignore @@ -0,0 +1 @@ +doc/tags diff --git a/skel/.config/nvim/plugged/vim-addon-mw-utils/autoload/buf_utils.vim b/skel/.config/nvim/plugged/vim-addon-mw-utils/autoload/buf_utils.vim new file mode 100644 index 0000000..d14d404 --- /dev/null +++ b/skel/.config/nvim/plugged/vim-addon-mw-utils/autoload/buf_utils.vim @@ -0,0 +1,24 @@ +" buf_identifier is either a buf_nr or a filename +" If any window shows the buffer move to the buffer +" If not show it in current window (by c-w s c^ you can always +" reshow the last buffer +" +" Example: buf_utils#GotoBuf("/tmp/tfile.txt", {'create': 1}) +" returns: The command which was used to switch to the buffer +fun! buf_utils#GotoBuf(buf_identifier, opts) + let buf_nr = bufnr(a:buf_identifier) + if buf_nr == -1 && ( get(a:opts, 'create', 0) || has_key(a:opts, 'create_cmd')) + exec get(a:opts,'create_cmd','e').' '.fnameescape(a:buf_identifier) + return "e" + else + let win_nr = bufwinnr(buf_nr) + if win_nr == -1 + exec 'b '.buf_nr + return "b" + else + exec win_nr.'wincmd w' + return "w" + endif + wincmd w" + endif +endf diff --git a/skel/.config/nvim/plugged/vim-addon-mw-utils/autoload/cached_file_contents.vim b/skel/.config/nvim/plugged/vim-addon-mw-utils/autoload/cached_file_contents.vim new file mode 100644 index 0000000..3fc3ce4 --- /dev/null +++ b/skel/.config/nvim/plugged/vim-addon-mw-utils/autoload/cached_file_contents.vim @@ -0,0 +1,104 @@ +" cached_file_contents.vim +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Last Change: 2010-01-03. +" @Revision: 0.3.0 + +"exec vam#DefineAndBind('s:c','g:cache_dir_options','{}') +if !exists('g:cache_dir_options') | let g:cache_dir_options = {} | endif | let s:c = g:cache_dir_options + +let s:c['cache_dir'] = get(s:c, 'cache_dir', expand('$HOME').'/.vim-cache') +let s:c['scanned_files'] = get(s:c, 'scanned_files', {}) +let s:scanned_files = s:c['scanned_files'] + + +let s:define_cache_file = "let this_dir = s:c['cache_dir'].'/cached-file-contents' | let cache_file = expand(this_dir.'/'.substitute(string([func_as_string, a:file]),'[[\\]{}:/\\,''\"# ]\\+','_','g'))" + +" read a file, run function to extract contents and cache the result returned +" by that function in memory. Optionally the result can be cached on disk as +" because VimL can be slow! +" +" file : the file to be read +" func: { 'func': function which will be called by funcref#Call +" , 'version' : if this version changes cache will be invalidate automatically +" , 'ftime_check': optional, default 1. if set to 0 cache isn't updated when file changes and file is in cache +" } +" +" default: what to return if file doesn't exist +" think twice about adding lines. This function is called many times. +function! cached_file_contents#CachedFileContents(file, func, ...) abort + let ignore_ftime = a:0 > 0 ? a:1 : 0 + " using string for default so that is evaluated when needed only + let use_file_cache = get(a:func, 'use_file_cache', 0) + + " simple kind of normalization. necessary when using file caching + " this seems to be slower: + " let file = fnamemodify(a:file, ':p') " simple kind of normalization. necessary when using file caching + " / = assume its an absolute path + " let file = a:file[0] == '/' ? a:file : expand(a:file, ':p') + let file = a:file[0] == '/' ? a:file : fnamemodify(a:file, ':p') " simple kind of normalization. necessary when using file caching + let func_as_string = string(a:func['func']) + + if (!has_key(s:scanned_files, func_as_string)) + let s:scanned_files[func_as_string] = {} + endif + let dict = s:scanned_files[func_as_string] + if use_file_cache && !has_key(dict, a:file) + exec s:define_cache_file + if filereadable(cache_file) + let dict[file] = eval(readfile(cache_file,'b')[0]) + endif + endif + if has_key(dict, a:file) + let d = dict[a:file] + if use_file_cache + \ && (ignore_ftime || getftime(a:file) <= d['ftime']) + \ && d['version'] == a:func['version'] + return dict[a:file]['scan_result'] + endif + endif + let scan_result = funcref#Call(a:func['func'], [a:file] ) + let dict[a:file] = {"ftime": getftime(a:file), 'version': a:func['version'], "scan_result": scan_result } + if use_file_cache + if !exists('cache_file') | exec s:define_cache_file | endif + if !isdirectory(this_dir) | call mkdir(this_dir,'p',0700) | endif + call writefile([string(dict[a:file])], cache_file) + endif + return scan_result +endfunction + +fun! cached_file_contents#ClearScanCache() + let s:c['scanned_files'] = {} + + " Don't run rm -fr. Ask user to run it. It cache_dir may have been set to + " $HOME ! (should nevere be the case but who knows + echoe "run manually in your shell: rm -fr ".shellescape(s:c['cache_dir'])."/*" +endf + +fun! cached_file_contents#Test() + + " usually you use a global option so that the function can be reused + let my_interpreting_func = {'func' : funcref#Function('return len(readfile(ARGS[0]))'), 'version': 2, 'use_file_cache':1} + let my_interpreting_func2 = {'func' : funcref#Function('return ARGS[0]') , 'version': 2, 'use_file_cache':1} + + let tmp = tempname() + call writefile(['some text','2nd line'], tmp) + + let r = [ cached_file_contents#CachedFileContents(tmp, my_interpreting_func) + \ , cached_file_contents#CachedFileContents(tmp, my_interpreting_func2) ] + if r != [2, tmp] + throw "test failed 1, got ".string(r) + endif + unlet r + + sleep 3 + + " now let's change contents + call writefile(['some text','2nd line','3rd line'], tmp) + + let r = cached_file_contents#CachedFileContents(tmp, my_interpreting_func) + if 3 != r + throw "test failed 2, got ".string(r) + endif + + echo "test passed" +endf diff --git a/skel/.config/nvim/plugged/vim-addon-mw-utils/autoload/env_reload.vim b/skel/.config/nvim/plugged/vim-addon-mw-utils/autoload/env_reload.vim new file mode 100644 index 0000000..d8af33a --- /dev/null +++ b/skel/.config/nvim/plugged/vim-addon-mw-utils/autoload/env_reload.vim @@ -0,0 +1,12 @@ +" in sh/bash you can type export to get a list of environment variables +" This function assigns those env vars to Vim. +" Does not delete env vars yet +" Example: env_reload#ReloadEnv(system("sh -c 'export'") +fun! env_reload#ReloadEnv(bash_export_command_output) + for i in split(a:bash_export_command_output,"\n") + let m = matchlist(i, 'export \([^=]\+\)="\(.*\)"') + if empty(m) | continue | endif + " don't care about quoted values right now. + exec 'let $'.m[1].'='.string(m[2]) + endfor +endf diff --git a/skel/.config/nvim/plugged/vim-addon-mw-utils/autoload/funcref.vim b/skel/.config/nvim/plugged/vim-addon-mw-utils/autoload/funcref.vim new file mode 100644 index 0000000..20eec54 --- /dev/null +++ b/skel/.config/nvim/plugged/vim-addon-mw-utils/autoload/funcref.vim @@ -0,0 +1,95 @@ +" funcref.vim +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Last Change: 2010-01-03. +" @Revision: 0.1.0 + +" documentation see doc/funcref.txt + +" usage: +" funcref#Function("filename#Function") +" optionally pass arguments: +" funcref#Function("filename#Function",{'args': [2]}) +" optionally define self: +" funcref#Function("filename#Function",{'self': object}) +function! funcref#Function(name,...) + let d = a:0 > 0 ? a:1 : {} + let d['faked_function_reference'] = a:name + return d +endfunction + +" args : same as used for call(f,[args], self) +" f must be either +" - a string which can be evaled (use "return 'value'" to return a value) +" - a Vim function reference created by function('..') +" - a faked function reference created by funcref#Function(..) +" +" the last "self" argument can be overriden by the function reference +" You can pass arguments in a closure like style +function! funcref#Call(...) + let args = copy(a:000) + + " add parameters: + if (len(args) < 2) + call add(args, []) + endif + + + let isDict = type(args[0]) == type({}) + + " prepend parameters which were passed by faked function reference: + if isDict && has_key(args[0], 'args') + let args[1] = args[0]['args']+args[1] + endif + + " always pass self. this way you can call functions from dictionaries not + " refering to self + if (len(args) < 3) + call add(args, {}) + endif + + " the funcref overrides self: + if isDict && has_key(args[0], 'self') + let args[2] = args[0]['self'] + endif + + if type(a:1) == 2 + " funcref: function must have been laoded + return call(function('call'), args) + elseif isDict && has_key(args[0], 'faked_function_reference') + let Fun = args[0]['faked_function_reference'] + if type(Fun) == type('') + \ && (Fun[:len('return ')-1] == 'return ' + \ || Fun[:len('call ')-1] == 'call ' + \ || Fun[:len('if ')-1] == 'if ' + \ || Fun[:len('let ')-1] == 'let ' + \ || Fun[:len('echo ')-1] == 'echo ' + \ || Fun[:len('exec ')-1] == 'exec ' + \ || Fun[:len('debug ')-1] == 'debug ') + " it doesn't make sense to list all vim commands here + " So if you want to execute another action consider using + " funcref#Function('exec '.string('aw')) or such + + " function is a String, call exec + let ARGS = args[1] + let SELF = args[2] + exec Fun + else + " pseudo function, let's load it.. + if type(Fun) == 1 + if !exists('*'.Fun) + " lazily load function + let file = substitute(substitute(Fun,'#[^#]*$','',''),'#','/','g') + exec 'runtime /autoload/'.file.'.vim' + endif + let Fun2 = function(Fun) + else + let Fun2 = Fun + endif + let args[0] = Fun + return call(function('call'), args) + endif + else + " no function, return the value + return args[0] + endif +endfunction diff --git a/skel/.config/nvim/plugged/vim-addon-mw-utils/autoload/glob.vim b/skel/.config/nvim/plugged/vim-addon-mw-utils/autoload/glob.vim new file mode 100644 index 0000000..9a0f79a --- /dev/null +++ b/skel/.config/nvim/plugged/vim-addon-mw-utils/autoload/glob.vim @@ -0,0 +1,27 @@ +exec vam#DefineAndBind('s:c','g:glob_like', '{}') + +" ignore vcs stuff, Don't think you want those.. +let s:c['regex_ignore_directory'] = '\<\%([_.]darcs\|\.git\|.svn\|.hg\|.cvs\|.bzr\)\>' +let s:c['glob_cache'] = get(s:c, 'glob_cache', {}) +let s:glob_cache = s:c['glob_cache'] + +fun! glob#Glob(pattern, ...) + let pattern = a:pattern + if pattern[0] == '~' + let pattern = $HOME.pattern[1:] + endif + let opts = a:0 > 0 ? a:1 : {} + " never cache current directory. You're very likely to edit files in it. + + let c = getcwd() + let cachable = get(opts, 'cachable', 0) && pattern[:len(c)-1] != c + if cachable && has_key(s:glob_cache, pattern) + return s:glob_cache[pattern] + endif + + " FIXME: don't recurse into \.git directory (thus reimplement glob in vimL!) + let r = filter(split(glob(pattern),"\n"),'v:val !~ '.string(s:c['regex_ignore_directory'])) + if cachable | let s:glob_cache[pattern] = r | endif + return r +endf + diff --git a/skel/.config/nvim/plugged/vim-addon-mw-utils/autoload/glob_linux.vim b/skel/.config/nvim/plugged/vim-addon-mw-utils/autoload/glob_linux.vim new file mode 100644 index 0000000..e93820c --- /dev/null +++ b/skel/.config/nvim/plugged/vim-addon-mw-utils/autoload/glob_linux.vim @@ -0,0 +1,43 @@ + +" TODO refactor: create glob function +" noremap \og :callglob_linux#FileByGlobCurrentDir('**/*'.input('glob open '),"\\.git\\\\.hg\\node_modules\\\\.pyc" ) +" noremap \og :callglob_linux#FileByGlobCurrentDir('**/*'.input('glob open '),"default" ) +function! glob_linux#FileByGlobCurrentDir(glob, exclude_pattern, ...) + let opts = a:0 > 0 ? a:1 : {} + if a:exclude_pattern == "default" + let exclude_pattern = '\.git\|\.hg\|node_modules\|\.pyc' + else + let exclude_pattern = a:exclude_pattern + endif + + " let files = split(glob(a:glob),"\n") + let g = a:glob + let replace = {'**': '.*','*': '[^/\]*','.': '\.'} + let g = substitute(g, '\(\*\*\|\*\|\.\)', '\='.string(replace).'[submatch(1)]','g') + + let exclude = exclude_pattern == '' ? '' : ' | grep -v -e '.shellescape(exclude_pattern) + + let cmd = get(opts, 'cmd_find', 'find'). ' . | grep -e '.shellescape(g).exclude + let files = split(system(cmd),"\n") + " for nom in a:excludes + " call filter(files,nom) + " endfor + if len(files) > 1000 + echoe "more than ".2000." files - would be too slow. Open the file in another way" + else + if empty(files) + echoe "no file found" + elseif len(files) == 1 + exec 'e '.fnameescape(files[0]) + else + let g:abc=7 + call tovl#ui#filter_list#ListView({ + \ 'number' : 1, + \ 'selectByIdOrFilter' : 1, + \ 'Continuation' : funcref#Function('exec "e ".fnameescape(ARGS[0])'), + \ 'items' : files, + \ 'cmds' : ['wincmd J'] + \ }) + endif + endif +endfunction diff --git a/skel/.config/nvim/plugged/vim-addon-mw-utils/autoload/tiny_cmd.vim b/skel/.config/nvim/plugged/vim-addon-mw-utils/autoload/tiny_cmd.vim new file mode 100644 index 0000000..052bbe0 --- /dev/null +++ b/skel/.config/nvim/plugged/vim-addon-mw-utils/autoload/tiny_cmd.vim @@ -0,0 +1,19 @@ +" vim suffers: + +exec vam#DefineAndBind('s:c','g:vim_tiny_cmd', '{}') + +fun! tiny_cmd#Put(a) + let new = get(s:c,'next',0) +1 + let s:c['next'] = new + let s:c[new] = a:a + return new +endf + +fun! tiny_cmd#Get(nr) + return s:c[a:nr] +endf + +" Get and remove item +fun! tiny_cmd#Pop(nr) + let r = s:c[a:nr] | unlet s:c[a:nr] | return r +endf diff --git a/skel/.config/nvim/plugged/vim-addon-mw-utils/autoload/tovl/scratch_buffer.vim b/skel/.config/nvim/plugged/vim-addon-mw-utils/autoload/tovl/scratch_buffer.vim new file mode 100644 index 0000000..217dca1 --- /dev/null +++ b/skel/.config/nvim/plugged/vim-addon-mw-utils/autoload/tovl/scratch_buffer.vim @@ -0,0 +1,103 @@ +" old code + +augroup TOVLWrite +augroup end + +" =========== scratch buffer ========================================= +" a scratch buffer is a temporary buffer where the user can enter some text +" It can be used to get commit messages, edit configuration options and so on + +function! tovl#scratch_buffer#KeepIntactLineNr() + let i = 0 + while getline(i)!= b:keepIntact && i < line('$') + let i = i+1 + endwhile + if i > line('$') + return -1 + else + return i + endif +endfunction + +" opens a buffer and runs an action when the buffer is written +" keys: +" name : the name of the buffer +" onWrite : will be called on write +" onWrite is responsible for setlocal nomodified to indicate that +" saving has been successful +" help : callback returning additional information lines +" getContent : callback returning lines +" cmds : extra commands to be run (optional) +" (maybe you prefer adding them the default way afer the +" ScratchBuffer call. They'll be rerun on GetContents +" sp_cmd : the command to use to create the new buffer. Defaults to :e +" buftype : ... +" modifiable : 1 / 0 defaults to 1 +function! tovl#scratch_buffer#ScratchBuffer(opts) + let a:opts['name'] = get(a:opts,'name', 'strach_buffer_without_name') + exec get(a:opts, 'sp_cmd', 'e').' '.escape(a:opts['name'],' ') + let b:settings = a:opts + let b:settings['modifiable'] = get(a:opts,'modifiable', 1) + setlocal buftype=acwrite + command! -buffer -nargs=0 Help call tovl#scratch_buffer#Help() + + " setup write notification + au TOVLWrite BufWriteCmd call tovl#scratch_buffer#Write() + + if has_key(a:opts,'getContent') + command! -buffer -nargs=0 GetContents call tovl#scratch_buffer#GetContents() + GetContents + if !b:settings['modifiable'] + setlocal nomodifiable + endif + endif + "let u=&undolevels + "setlocal undolevels=-1 + "exec 'setlocal undolevels='.u + + " mark buffer as not modified + setlocal nomodified + + au BufReadCmd GetContents + + " run addittional commands + for cmd in get(a:opts,'cmds',[]) + exec cmd + endfor + silent echo get(a:opts,'echo_help', "type :Help for help") +endfunction + +" =========== utility functions ====================================== + +function! tovl#scratch_buffer#Write() + if has_key(b:settings, 'onWrite') + call funcref#Call(b:settings['onWrite']) + else + echo "don't know how to write. Option hasn't been passed" + endif +endfunction + +function! tovl#scratch_buffer#GetContents() + setlocal modifiable + " empty buffer + %g!//d + call append(0, funcref#Call(b:settings['getContent'])) + if !b:settings['modifiable'] + setlocal nomodifiable + endif + for cmd in get(b:settings,'cmds',[]) + exec cmd + endfor +endfunction + +function! tovl#scratch_buffer#Help() + let help = ["use :e! to reload contents, ZZ or :w(q) to write and quit" + \ ,"" + \ ,"Help for this scratch buffer:" + \ ,"=======================================================","",""] + \ + funcref#Call(get(b:settings, 'help', [])) + call tovl#scratch_buffer#ScratchBuffer({ + \ 'name' : "return Help of ".b:settings['name'], + \ 'getContent' : help + \ }) +endfunction diff --git a/skel/.config/nvim/plugged/vim-addon-mw-utils/autoload/tovl/ui/filter_list.vim b/skel/.config/nvim/plugged/vim-addon-mw-utils/autoload/tovl/ui/filter_list.vim new file mode 100644 index 0000000..74b2ab4 --- /dev/null +++ b/skel/.config/nvim/plugged/vim-addon-mw-utils/autoload/tovl/ui/filter_list.vim @@ -0,0 +1,473 @@ +" OLD CODE ! +" I should contribute the multiple filter feature to tlib + +" filter list displays a list of items +" you can white / black filter them by regular expressions (similar to the +" tlib TToC command +" However you can edit the filters afterwards and select the cols which should +" be shown + +fun! tovl#ui#filter_list#ListTest() + call tovl#ui#filter_list#ListView({ + \ 'aligned' : 1, + \ 'Continuation' : funcref#Function('echo string(ARGS[0])'), + \ 'items' : [ {"aa" : "a\nAAAAAAAAAAA", 'bb' : "bbbbbbbbbbbbb\nB" }, + \ {"aa" : "2a\n2AAAAAAAAAAAA", "bb" : "2 bbbbbbbbbbbbb\n2B"}, + \ {"aa" : "XXX", "bb" : "YY"} ], + \ }) + +endfun + +fun! s:Intersection(a, b) + return filter(copy(a:a), 'index(a:b, v:val) >= 0') +endf + +fun! tovl#ui#filter_list#ListTestGotoLineCurrentBuf() + let nr=1 + let lines = [] + for l in getline(0,line('$')) + call add(lines, {'nr': nr, 'line' :l}) + let nr = nr +1 + endfor + call tovl#ui#filter_list#ListView({ + \ 'aligned' : 0, + \ 'keys' : ['nr','line'], + \ 'number' : 1, + \ 'selectByIdOrFilter' : 1, + \ 'Continuation' : funcref#Function('exec ARGS[0]["nr"]'), + \ 'items' : lines, + \ }) +endfun + +" opens a new filtered list +" keys of opts parameters: +" Continuation: This function will be called with the selected items +" items: { key : (string or dict) } +" items willl be modified. use copy(youritems) as argument to prevent +" this. An item is either a string or a dict +" (eg {'file' : .., 'line': ... , 'msg' : .. ) +" keys: list of keys to be shown (optional) +" filter: list of inital filters which must be applied +" contains [ { filter: .. , keep : .. }, ] see FilterItems() below +" aligned: default 0 +" sp_cmd: the command to be used to create the new buffer (default ':e') +" init : 0 / 1 (default 1): wether to show the view right now +" number: 0 /1 (default 1): number items ? +" selectByIdOrFilter: 1: start in getchar() loop so that the user can select +" the item even faster +" auto: only do this if all items fit on screen +" (recommend) +" cmds: extra cmds to be run +" cursorAt : at which item to put the cursor? +" +" If you don't like the default view you can override UpdateDisplay +" +" Usage examples of this list control: +" - db results +" - replacement of the quickfix window +" - select a buffer etc +fun! tovl#ui#filter_list#ListView(opts) + " ActivateAddons theonevimlib + let d = {} + let d.items = a:opts.items + let d.cursorAt = get(a:opts, 'cursorAt', 0) + let d.aligned = get(a:opts, 'aligned', 0) + let d.sep = ' ' + let d.filter = get(a:opts, 'filter', []) + " using sp because of bd! (FIXME) + let d.sp_cmd = get(a:opts, 'sp_cmd', 'sp') + let d.allKeys = {} + let d.closeOnContinuation = get(a:opts,'closeOnContinuation',1) + " don't recommend OnSingleMatch, use OnSingleMatchCR instead + let d.continueOnSingleMatch = get(a:opts, 'continueOnSingleMatch',0) + let d.continueOnSingleMatchCR = get(a:opts, 'continueOnSingleMatchCR',1) + let d.selectByIdOrFilter = get(a:opts, 'selectByIdOrFilter', 0) + let d.linesToItems = {} + let d.number = get(a:opts, 'number', 1) + let d.cmds = get(a:opts, 'cmds', []) + let d.syn_cmds = get(a:opts, 'syn_cmds', []) + + if has_key(a:opts,'keys') | let d.keys = a:opts.keys | endif + if has_key(a:opts,'Continuation') | let d.Continuation = a:opts.Continuation | endif + + " cache already filtered items in case we want to view really long results + " contains [ { filter : { regex: .. , keep : .. } , items : .. , cursorAt :}, + " { filter : { ... } , items: .. , cursorAt : } + let d.cached = [] + " id of buffer + let d.buffer = -1 + let d.modeText = '' + + fun d.HelpText() + return [ "you've entered the the help of the powerful filtered view buffer", + \ "", + \ "type f to start filtering items by regex", + \ "type F to start dropping items by regex", + \ "k / K will ask you for the key to apply the filter to first", + \ "apply the filter by and press again to select item", + \ "", + \ "use :ShowAppliedFilters to list active filters", + \ "use :ToggleAlignment to toggle alignment", + \ "", + \ "TODO: Implement sorting, implement interface to change keys (displayed columns)" + \ ] + endfun + + " create new scratch buffer + " preprocess items calculating line count and maxwidth for all items + fun d.NewBufferAndInit() + let self.bufferId = bufnr(bufname('%')) + for idx in range(0,len(self.items)-1) + if type(self.items[idx]) != 4 + " no dict yet, make it one + let self.items[idx] = {'string_line' : self.items[idx]} + endif + let new = {} + for [k,v] in items(self.items[idx]) + let lines = split(v,"\n") + let self.items[idx][k] = { 'text' : v, 'rows' : len(lines), 'cols' : max(map(copy(lines),'len(v:val)')), 'lines' : lines } + let self.allKeys[k] = 1 + unlet k v + endfor + endfor + call tovl#scratch_buffer#ScratchBuffer({ + \ 'help' : funcref#Function(self.HelpText,{ 'self' : self }), + \ 'sp_cmd' : self.sp_cmd, + \ 'cmds' : self.cmds + \ }) + " I assume we have some kind of formatting anyway. Thus breaking lines is bad! + set nowrap + setlocal cursorline + let b:filtered_view = self + command! -buffer -nargs=0 ToggleAlignment call b:filtered_view.ToggleAlignment() + command! -buffer -nargs=0 ShowAppliedFilters call b:filtered_view.ShowAppliedFilters() + command! -buffer -nargs=0 RemoveFilters call b:filtered_view.RemoveFilters() + noremap f :call b:filtered_view.FilterFromKeyboard(1,'') + " noremap f :call b:filtered_view.FilterFromKeyboard(1) + noremap F :call b:filtered_view.FilterFromKeyboard(0,'') + if has_key(self,'Continuation') + nnoremap :call b:filtered_view.Continue() + endif + "noremap k + "noremap K + + let [items, cursorAt] = self.FilteredItems() + " len(items) is an approximation because one item can have multiple + " lines.. However adding the lines first to check takes too much time + if self.selectByIdOrFilter == 1 || (self.selectByIdOrFilter == 'auto' && winheight('%') > len(items) ) + call self.SelectByIdOrFilter() + else + " user should choose how to proceed + call self.UpdateDisplay() + endif + endfun + + " user interface + fun d.ToggleAlignment() + let self.aligned = !self.aligned + call self.UpdateDisplay() + endfun + fun d.ShowAppliedFilters() + for i in self.filter | echo string(i) | endfor + endfun + fun d.RemoveFilters() + let self.filter = [] + call self.UpdateDisplay() + endfun + fun d.Continue() + let item = self.CurrentItem() + call self.DoContinue(item) + endfun + fun d.DoContinue(v) + if self.closeOnContinuation | bw! | endif + call funcref#Call(self.Continuation,[a:v]) + endfun + + fun d.MapToOriginal(v) + if has_key(a:v, 'string_line') + return a:v.string_line.text + else + let d = {} + for [k,v] in items(a:v) + let d[k] = v.text + unlet k v + endfor + return d + endif + endfun + + fun d.CurrentItem() + let idx=line('.')-len(self.headerLines) + while idx >= 0 + if has_key(self.linesToItems, idx) + return self.MapToOriginal(self.FilteredItems()[0][self.linesToItems[idx]]) + else + let idx = idx -1 + endif + endwhile + throw "internal error, couldn't determine selected item!" + endfun + + " updates the filter cache and returns the final filtered items + fun d.FilteredItems() + " update cache + let idx = 0 + let [items, cursorAt] = [self.items, self.cursorAt] + for idx in range(0, len(self.filter)-1) + if idx +1 > len(self.cached) || self.cached[idx]['filter'] != self.filter[idx] + let self.cached = self.cached[:idx-1] + let [items, cursorAt] = self.FilterItem(copy(items), self.filter[idx], cursorAt) + call add(self.cached, { 'cursorAt' : cursorAt, 'items' : items, 'filter' : self.filter[idx]}) + else + let ci = self.cached[idx] + let [items, cursorAt] = [ci['items'], ci['cursorAt']] + endif + endfor + return [items, cursorAt] + endfun + + " calling this will return a set of lines which are expected to be the new + " buffer contents. The self.linesToItems dict is updated + fun d.UpdateDisplay() + + if empty(self.filter) + let self.statusline= 'no filter applied, :Help for help' + else + let self.statusline = len(self.filter).' '.string(self.filter[-1]) + endif + + let self.linesToItems = {} + let [items, cursorAt] = self.FilteredItems() + "let num_width = printf('%.0f', trunc(log10(len(items))+1)) + let num_width = 4 + if self.aligned + " get column width.. (probably will not work with unicde characters.. I + " don't have a better solution) + let maxlens={} + for i in items + for [k,v] in items(i) + if get(maxlens,k,0) < v.cols + let maxlens[k] = v.cols + endif + endfor + endfor + endif + + " format lines + let self.headerLines = [self.modeText] + let lines = copy(self.headerLines) + let lines_count = 0 + if self.number + let fmt_startA = '%'.num_width.'s)' + let fmt_startB = '%'.num_width.'s' + else + let fmt_startA = '' | let fmt_startB = '' + endif + let cursorAtLine = 1 " sane default + for idx in range(0,len(items)-1) + let self.linesToItems[lines_count + 1] = idx + let i = items[idx] + let keys = has_key(self,'keys') + \ ? s:Intersection(self.keys, keys(i)) + \ : keys(i) + let fmt = '' + let args = [i] + let cols = [] + for k in keys + let fmt .= self.sep.'%-'.(self.aligned ? maxlens[k] : i[k]['cols']).'s' + call add(cols, i[k]) + endfor + for row in range(0, max([1] + map(copy(cols),'v:val["rows"]'))-1) + let fmt_args = row == 0 ? [fmt_startA.fmt] : [fmt_startB.fmt] + if self.number + call add(fmt_args, row == 0 ? idx : '') + endif + for c in cols + call add(fmt_args, c.rows <= row ? '' : c.lines[row]) + endfor + call add(lines, call('printf', fmt_args)) + let lines_count += 1 + endfor + if idx == cursorAt + let cursorAtLine = lines_count + endif + endfor + " update stauts line to show last applied filter + " disabled cause it causes trouble on :wincmd w + " setlocal statusline=%!b:filtered_view.statusline + + " syntax + syn clear + for s in self.syn_cmds | exec s | endfor + let id = 0 + " highlight filter regex in buffer as well + let syn_ids = [ 'Underlined', 'Todo', 'Error', 'Type', 'Statement' ] + for f in self.filter + if !f.keep || !has_key(f, 'regex') | continue | endif + if f.regex != '' + try + exec 'syn match '.syn_ids[id % len(syn_ids)].' '.string(f.regex) + catch /.*/ + " ignore errors such as \ without following characters. Thus just + " ignore and wait for the next character + endtry + endif + let id = id +1 + endfor + if len(lines) > winheight('%') + call extend(lines, self.headerLines) + endif + normal ggdG + call append(0, lines) + " place cursor + exec (cursorAtLine+1) + " move cursor into the middle of the window + normal zz + endf + + " filter = keys : + " filter = string to be executed containing Val + " keep = 1 keep on match + " = 0 drop on match + " key (optional) + " cursorAt: at which item to put the cursor + " if that item is deleted it will be placed at the item above + " optional: key of dict if dict + fun d.FilterItem(items, filter, cursorAt) + let filter = 'Val =~ '.string(a:filter.regex) + let keep = a:filter.keep + let cursorAt = a:cursorAt + + for idx in reverse(range(0, len(a:items)-1)) + let i = a:items[idx] + if has_key(a:filter,'key') + let key = a:filter.key + if has_key(i, key) + " key given, only filter by this column + let Val = i[key]['text'] + exec 'let any = '.filter + else + let any = 0 + endif + else + let any = 0 + " no key given, try all + for x in values(i) + let Val = x['text'] + exec 'let any = '.filter + if any | break | endif + endfor + endif + if any != keep + call remove(a:items, idx) + if idx <= cursorAt + let cursorAt = cursorAt -1 + endif + endif + endfor + return [a:items, cursorAt] + endfun + + " if the user enters a number select by index else start filtering.. + fun d.SelectByIdOrFilter() + let idx='' + let items = self.FilteredItems()[0] + try + let self.modeText = '[0-9]* : select by index| : escape getchar() loop, any char: start filtering' + call self.UpdateDisplay() | redraw + while 1 + let c=getchar() + if index([13,10],c) >= 0 + return self.DoContinue(self.MapToOriginal(items[idx])) + elseif index([27], c) >=0 + " esc, abort + return + else + if type(c) == 0 + let c = nr2char(c) + endif + if c == "\" || index(map(range(0,10),'v:val.""'),c) >= 0 + if c == "\" + let idx = idx[:-2] + else + let idx .= c + endif + if idx < len(items) && idx.'0' > len(items) || idx == 0 && len(items) < 10 + " only match + return self.DoContinue(self.MapToOriginal(items[idx])) + endif + else + return self.FilterFromKeyboard(1,c) + endif + endif + endwhile + finally + let self.modeText = '' + endtry + endfun + + " gets a regular expresion filter by keybaord and updates the display while + " you're typing. The regex ist shown in the statusline + fun d.FilterFromKeyboard(keep, start, ...) + let self.modeText = 'press ESC to exit getchar() loop' + call self.UpdateDisplay() | redraw + + try + let key_text = a:0 > 0 ? 'key : '.a:1 : '' + let filter_bak = self.filter + let filter = copy(self.filter) + let start = a:start + let filter_new = '' + while 1 + if start != '' + " use c= last char to force updating display etc + let filter_new = start[:-2] + let c = start[-1:] + let start = '' + else + let c=getchar() + endif + if index([13,10],c) >= 0 + " c-j or return, accept new filter + let items = self.FilteredItems() + if len(items) == 1 && has_key(self, 'Continuation') && self.continueOnSingleMatchCR + call self.DoContinue(self.MapToOriginal(items[0])) + endif + return + elseif index([27], c) >=0 + " esc, abort + let self.filter = filter_bak + call self.UpdateDisplay() + return + else + if type(c) == 0 + let c = nr2char(c) + endif + if c == "\" + let filter_new = filter_new[:-2] + else + let filter_new .= c + endif + let d = {'keep' : a:keep, 'regex' : filter_new } + if a:0 > 0 + let d['key'] = a:1 + endif + let self.filter = copy(filter_bak) + call add(self.filter, d) + let items = self.FilteredItems() + if len(items) == 1 && has_key(self, 'Continuation') && self.continueOnSingleMatch + call self.DoContinue(self.MapToOriginal(items[0])) + return + endif + call self.UpdateDisplay() | redraw + endif + endwhile + finally + let self.modeText = '' + endtry + endfun + + if get(a:opts,'init',1) + call d.NewBufferAndInit() + endif +endfun diff --git a/skel/.config/nvim/plugged/vim-addon-mw-utils/doc/cached_file_contents.txt b/skel/.config/nvim/plugged/vim-addon-mw-utils/doc/cached_file_contents.txt new file mode 100644 index 0000000..a47a8cf --- /dev/null +++ b/skel/.config/nvim/plugged/vim-addon-mw-utils/doc/cached_file_contents.txt @@ -0,0 +1,7 @@ +*cached_file_contents* read contents of a file then cache extracted data + Author: Marc Weber, marco-oweber@gmx.de + +----------------------------------------------------------------------- +HOWTO~ + + see cached_file_contents#Test() diff --git a/skel/.config/nvim/plugged/vim-addon-mw-utils/doc/funcref.txt b/skel/.config/nvim/plugged/vim-addon-mw-utils/doc/funcref.txt new file mode 100644 index 0000000..cb366d0 --- /dev/null +++ b/skel/.config/nvim/plugged/vim-addon-mw-utils/doc/funcref.txt @@ -0,0 +1,35 @@ +*funcref* create lazier function references. Pass arguments to create closure + like function calls + Author: Marc Weber, marco-oweber@gmx.de + +----------------------------------------------------------------------- +HOWTO~ + +Use *funcref#Function* to create a special dict called +*faked-function-reference* which can be called by *funcref#Call* +> + { 'faked_function_reference': 'file#FuncName' } +< passing some arguments and / or self: > + { 'faked_function_reference': 'MyFunc', 'args': [1,2], 'self' : { a object ] } +< You can also create lambda like functions which will be evaled: > + { 'faked_function_reference': 'return ARGS[1]' } + +REASONS ~ + Creating a Vim funcref pointing to an autoload function will make Vim source + that file. This is not lazy enough. (Seems to be no longer true? Has this changed?) + + A Vim function reference neither allows attaching arguments nor self. + + Don't care about case of variables. Normally when using Vim function + references you have to use variable names starting with an upper case letter + (E704) + +Example: ~ +> + let f = funcref#Function('return ARGS[0].ARGS[1].SELF["key"]',{'args':[3], 'self':{'key': 'value'} }) + echo funcref#Call(f, [2]) + " prints "32value" + + echo funcref#Call('no value') +< + echo funcref#Call(f, [2]) diff --git a/skel/.config/nvim/plugged/vim-addon-mw-utils/doc/tiny_cmd.txt b/skel/.config/nvim/plugged/vim-addon-mw-utils/doc/tiny_cmd.txt new file mode 100644 index 0000000..bc6e002 --- /dev/null +++ b/skel/.config/nvim/plugged/vim-addon-mw-utils/doc/tiny_cmd.txt @@ -0,0 +1,18 @@ +*tiny-cmd* make long commands short so that they hopefully no longer trigger "press Enter .. [ok]" + Author: Marc Weber, marco-oweber@gmx.de + +----------------------------------------------------------------------- +HOWTO~ + +Problem: > + exec 'map :silent! let g:g="'.repeat('foobar ',200).'"' +Now run the mapping by pressing and you notice what I'm talking about + +Solution (Example): + + +Example usage: > + let nr = tiny_cmd#Put('let g:g="'.repeat('foobar ',200).'"') + exec 'map :exec tiny_cmd#Get('.nr.')' +< +Use Pop instead of Get if you use this command once only diff --git a/skel/.config/nvim/plugged/vim-addon-mw-utils/vim-addon-mw-utils-addon-info.txt b/skel/.config/nvim/plugged/vim-addon-mw-utils/vim-addon-mw-utils-addon-info.txt new file mode 100644 index 0000000..0b20bb3 --- /dev/null +++ b/skel/.config/nvim/plugged/vim-addon-mw-utils/vim-addon-mw-utils-addon-info.txt @@ -0,0 +1,9 @@ +{ + "name" : "vim-addon-mw-utils", + "version" : "0.0", + "author" : "Marc Weber ", + "maintainer" : "Marc Weber ", + "repository" : {"type": "git", "url": "git://github.com/MarcWeber/vim-addon-manager-known-repositories.git"}, + "dependencies" : {}, + "description" : "various utils such as caching interpreted contents of files or advanced glob like things" +} diff --git a/skel/.config/nvim/plugged/vim-snipmate/.gitignore b/skel/.config/nvim/plugged/vim-snipmate/.gitignore new file mode 100644 index 0000000..9140e6a --- /dev/null +++ b/skel/.config/nvim/plugged/vim-snipmate/.gitignore @@ -0,0 +1,3 @@ +doc/tags +*.swp +.DS_Store diff --git a/skel/.config/nvim/plugged/vim-snipmate/Contributors.md b/skel/.config/nvim/plugged/vim-snipmate/Contributors.md new file mode 100644 index 0000000..4206472 --- /dev/null +++ b/skel/.config/nvim/plugged/vim-snipmate/Contributors.md @@ -0,0 +1,52 @@ +# Contributors # + +SnipMate was originally authored by Michael Sanders +([Vim](http://www.vim.org/account/profile.php?user_id=16544), +[GitHub](https://github.com/msanders)). + +It is currently maintained by [Rok Garbas](rok@garbas.si), [Marc +Weber](marco-oweber@gmx.de), and [Adnan Zafar](https://github.com/ajzafar) with +additional contributions from: + +* [907th](https://github.com/907th) +* [adkron](https://github.com/adkron) +* [alderz](https://github.com/alderz) +* [asymmetric](https://github.com/asymmetric) +* [bpugh](https://github.com/bpugh) +* [bruno-](https://github.com/bruno-) +* [CharlesGueunet](https://github.com/CharlesGueunet) +* [darkwise](https://github.com/darkwise) +* [dreviejo](https://github.com/dreviejo) +* [fish-face](https://github.com/fish-face) +* [henrik](https://github.com/henrik) +* [holizz](https://github.com/holizz) +* [honza](https://github.com/honza) +* [hpesoj](https://github.com/hpesoj) +* [ironcamel](https://github.com/ironcamel) +* [jb55](https://github.com/jb55) +* [jbernard](https://github.com/jbernard) +* [jherdman](https://github.com/jherdman) +* [kozo2](https://github.com/kozo2) +* [lilydjwg](https://github.com/lilydjwg) +* [lpil](https://github.com/lpil) +* [marutanm](https://github.com/marutanm) +* [MicahElliott](https://github.com/MicahElliott) +* [mikeastock](https://github.com/mikeastock) +* [muffinresearch](https://github.com/muffinresearch) +* [munyari](https://github.com/munyari) +* [pielgrzym](https://github.com/pielgrzym) +* [pose](https://github.com/pose) +* [r00k](https://github.com/r00k) +* [radicalbit](https://github.com/radicalbit) +* [redpill](https://github.com/redpill) +* [rglassett](http://github.com/rglassett) +* [robhudson](https://github.com/robhudson) +* [shinymayhem](https://github.com/shinymayhem) +* [Shraymonks](https://github.com/shraymonks) +* [sickill](https://github.com/sickill) +* [statik](https://github.com/statik) +* [steveno](https://github.com/steveno) +* [taq](https://github.com/taq) +* [thisgeek](https://github.com/thisgeek) +* [trusktr](https://github.com/trusktr) +* [Xandaros](https://github.com/Xandaros) diff --git a/skel/.config/nvim/plugged/vim-snipmate/README.md b/skel/.config/nvim/plugged/vim-snipmate/README.md new file mode 100644 index 0000000..2072d7c --- /dev/null +++ b/skel/.config/nvim/plugged/vim-snipmate/README.md @@ -0,0 +1,187 @@ +# SnipMate # + +SnipMate aims to provide support for textual snippets, similar to TextMate or +other Vim plugins like [UltiSnips][ultisnips]. For +example, in C, typing `for` could be expanded to + + for (i = 0; i < count; i++) { + /* code */ + } + +with successive presses of tab jumping around the snippet. + +Originally authored by [Michael Sanders][msanders], SnipMate was forked in 2011 +after a stagnation in development. This fork is currently maintained by [Rok +Garbas][garbas], [Marc Weber][marcweber], and [Adnan Zafar][ajzafar]. + + +## Installing SnipMate ## + +We recommend one of the following methods for installing SnipMate and its +dependencies. SnipMate depends on [vim-addon-mw-utils][mw-utils] and +[tlib][tlib]. + +> **NOTE:** SnipMate does not ship with any snippets out of the box. We suggest +looking at the [vim-snippets][vim-snippets] repository. + +* Using [VAM][vam], add `vim-snippets` to the list of packages to be installed. + +* Using [Pathogen][pathogen], run the following commands: + + % cd ~/.vim/bundle + % git clone https://github.com/tomtom/tlib_vim.git + % git clone https://github.com/MarcWeber/vim-addon-mw-utils.git + % git clone https://github.com/garbas/vim-snipmate.git + + # Optional: + % git clone https://github.com/honza/vim-snippets.git + +* Using [Vundle][vundle], add the following to your `vimrc` then run + `:PluginInstall` + + Plugin 'MarcWeber/vim-addon-mw-utils' + Plugin 'tomtom/tlib_vim' + Plugin 'garbas/vim-snipmate' + + " Optional: + Plugin 'honza/vim-snippets' + +## Using SnipMate ## +Press and try :SnipMateOpenSnippetFiles for starting. +Also see doc/SnipMate.txt to learn all SnipMate + +## FAQ ## + +> SnipMate doesn't work / My snippets aren't triggering + +Try all of the following: + +* Check that SnipMate is loaded. This can be done by looking for + `snipMateTrigger` and similar maps in the output of `:imap`. + Additionally make sure either `snipMateTrigger` or + `snipMateNextOrTrigger` is mapped to the key you expect. + +* Check that the snippets file you mean to use exists, and that it contains the + snippet you're trying to expand. + +* Check that your snippets file is located inside a `foo/snippets` directory, + where `foo` is a path listed in your `runtimepath`. + +* Check that your snippets file is in scope by either the filetype matching the + path of the snippet file or the scope explicitly loaded. + +* Check if any snippets from your snippets file are available. This can be done + with the "show available snips" map, by default bound to `` in + insert mode. + +If all of the above check out, please open an issue stating your Vim version, +a sample snippet, and a description of exactly what happens when you try to +trigger a snippet. + +> How does SnipMate determine which snippets to load? How can I separate, for +> example, my Rails snippets from my Ruby snippets? + +Primarily SnipMate looks at the `'filetype'` and `'syntax'` settings. Taking +"scopes" from these options, it looks in each `snippets/` directory in +`'runtimepath'` for files named `scope.snippets`, `scope/*.snippets`, or +`scope_*.snippets`. + +However we understand this may not allow for the flexibility desired by some +languages. For this we provide two options: scope aliases and the +`:SnipMateLoadScope` command. Scope aliases simply say "whenever this scope is +loaded, also load this other scope: + + let g:snipMate = get(g:, 'snipMate', {}) " Allow for vimrc re-sourcing + let g:snipMate.scope_aliases = {} + let g:snipMate.scope_aliases['ruby'] = 'ruby,rails' + +will load the `ruby-rails` scope whenever the `ruby` scope is active. The +`:SnipMateLoadScope foo` command will always load the foo scope in the current +buffer. The [vim-rails](https://github.com/tpope/vim-rails) plugin automatically +does `:SnipMateLoadScope rails` when editing a Rails project for example. + +> What are the snippet parser versions and what's the difference between them? + +Originally SnipMate used regex to parse a snippet. Determining where stops were, +what the placeholders were, where mirrors were, etc. were all done with regex. +Needless to say this was a little fragile. When the time came for a rewritten +parser, some incompatibilities were a little necessary. Rather than break +everyone's snippets everywhere, we provided both the new (version 1) and the old +(version 0) and let the user choose between them. + +Version 0 is considered legacy and not a lot of effort is going to go into +improving or even maintaining it. Version 1 is the future, and one can expect +new features to only exist for version 1 users. A full list of differences can +be found in the docs at `:h SnipMate-parser-versions`. + +## Release Notes ## + +### 0.89 - 2016-05-29 ### + +* Various regex updates to legacy parser +* Addition of double bang syntax to completely remove a snippet from lookup +* Group various SnipMate autocommands +* Support setting 'shiftwidth' to 0 +* Parser now operates linewise, adding some flexibility +* Mirror substitutions are more literal +* Mirror length is calculated correctly when substitutions occur + +### 0.88 - 2015-04-04 ### + +* Implement simple caching +* Remove expansion guards +* Add `:SnipMateLoadScope` command and buffer-local scope aliases +* Load `_*.snippets` files +* Use CursorMoved autocmd events entirely + +* The nested branch has been merged + * A new snippet parser has been added. The g:snipmate.version as well as + version lines in snippet files determines which is used + * The new parser supports tab stops placed within placeholders, + substitutions, non-consecutive stop numbers, and fewer ambiguities + * The stop jumping code has been updated + * Tests have been added for the jumping code and the new parser + +* The override branch has been merged + * The g:snipMate.override option is added. When enabled, if two snippets + share the same name, the later-loaded one is kept and the other discarded + * Override behavior can be enabled on a per-snippet basis with a bang (!) in + the snippet file + * Otherwise, SnipMate tries to preserve all snippets loaded + +* Fix bug with mirrors in the first column +* Fix bug with tabs in indents ([#143][143]) +* Fix bug with mirrors in placeholders +* Fix reading single snippet files +* Fix the use of the visual map at the end of a line +* Fix expansion of stops containing only the zero tab stop +* Remove select mode mappings +* Indent visual placeholder expansions and remove extraneous lines ([#177][177] + and [#178][178]) + +### 0.87 - 2014-01-04 ### + +* Stop indenting empty lines when expanding snippets +* Support extends keyword in .snippets files +* Fix visual placeholder support +* Add zero tabstop support +* Support negative 'softtabstop' +* Add g:snipMate_no_default_aliases option +* Add snipMateTrigger for triggering an expansion inside a snippet +* Add snipMate#CanBeTriggered() function + +[ultisnips]: https://github.com/sirver/ultisnips +[msanders]: https://github.com/msanders +[garbas]: https://github.com/garbas +[marcweber]: https://github.com/marcweber +[ajzafar]: https://github.com/ajzafar +[mw-utils]: https://github.com/marcweber/vim-addon-mw-utils +[tlib]: https://github.com/tomtom/tlib_vim +[vim-snippets]: https://github.com/honza/vim-snippets +[vam]: https://github.com/marcweber/vim-addon-manager +[pathogen]: https://github.com/tpope/vim-pathogen +[vundle]: https://github.com/gmarik/vundle + +[143]: https://github.com/garbas/vim-snipmate/issues/143 +[177]: https://github.com/garbas/vim-snipmate/issues/177 +[178]: https://github.com/garbas/vim-snipmate/issues/178 diff --git a/skel/.config/nvim/plugged/vim-snipmate/addon-info.json b/skel/.config/nvim/plugged/vim-snipmate/addon-info.json new file mode 100644 index 0000000..8d9930f --- /dev/null +++ b/skel/.config/nvim/plugged/vim-snipmate/addon-info.json @@ -0,0 +1,12 @@ +{ + "name" : "snipMate", + "version" : "dev", + "author" : "Michael Sanders -> original project http://github.com/msanders/snipmate.vim", + "maintainer" : "Rok Garbas / Marc Weber", + "repository" : {"type": "git", "url": "git://github.com/garbas/vim-snipmate.git"}, + "dependencies" : { + "vim-addon-mw-utils": {}, + "tlib": {} + }, + "description" : "snipMate.vim aims to be a concise vim script that implements some of TextMate's snippets features in Vim. See README.md to learn about the features this fork adds" +} diff --git a/skel/.config/nvim/plugged/vim-snipmate/after/plugin/snipMate.vim b/skel/.config/nvim/plugged/vim-snipmate/after/plugin/snipMate.vim new file mode 100644 index 0000000..3d6bac7 --- /dev/null +++ b/skel/.config/nvim/plugged/vim-snipmate/after/plugin/snipMate.vim @@ -0,0 +1,46 @@ +" snipMate maps +" These maps are created here in order to make sure we can reliably create maps +" after SuperTab. + +let s:save_cpo = &cpo +set cpo&vim + +function! s:map_if_not_mapped(lhs, rhs, mode) abort + let l:unique = s:overwrite ? '' : ' ' + if !hasmapto(a:rhs, a:mode) + silent! exe a:mode . 'map' . l:unique a:lhs a:rhs + endif +endfunction + +if !exists('g:snips_no_mappings') || !g:snips_no_mappings + if exists('g:snips_trigger_key') + echom 'g:snips_trigger_key is deprecated. See :h snipMate-mappings' + exec 'imap ' g:snips_trigger_key 'snipMateTrigger' + exec 'smap ' g:snips_trigger_key 'snipMateSNext' + exec 'xmap ' g:snips_trigger_key 'snipMateVisual' + else + " Remove SuperTab map if it exists + let s:overwrite = maparg('', 'i') ==? 'SuperTabForward' + call s:map_if_not_mapped('', 'snipMateNextOrTrigger', 'i') + call s:map_if_not_mapped('', 'snipMateNextOrTrigger', 's') + let s:overwrite = 0 + call s:map_if_not_mapped('', 'snipMateVisual', 'x') + endif + + if exists('g:snips_trigger_key_backwards') + echom 'g:snips_trigger_key_backwards is deprecated. See :h snipMate-mappings' + exec 'imap ' g:snips_trigger_key_backwards 'snipMateIBack' + exec 'smap ' g:snips_trigger_key_backwards 'snipMateSBack' + else + let s:overwrite = maparg('', 'i') ==? 'SuperTabBackward' + call s:map_if_not_mapped('', 'snipMateBack', 'i') + call s:map_if_not_mapped('', 'snipMateBack', 's') + let s:overwrite = 0 + endif + + call s:map_if_not_mapped('', 'snipMateShow', 'i') +endif + +let &cpo = s:save_cpo + +" vim:noet: diff --git a/skel/.config/nvim/plugged/vim-snipmate/autoload/snipMate.vim b/skel/.config/nvim/plugged/vim-snipmate/autoload/snipMate.vim new file mode 100644 index 0000000..4952879 --- /dev/null +++ b/skel/.config/nvim/plugged/vim-snipmate/autoload/snipMate.vim @@ -0,0 +1,648 @@ +" config which can be overridden (shared lines) +if !exists('g:snipMate') + let g:snipMate = {} +endif + +try + call tlib#input#List('mi', '', []) +catch /.*/ + echoe "tlib is missing. See install instructions at ".expand(':h:h').'/README.md' +endtry + +fun! Filename(...) abort + let filename = expand('%:t:r') + if filename == '' | return a:0 == 2 ? a:2 : '' | endif + return !a:0 || a:1 == '' ? filename : substitute(a:1, '$1', filename, 'g') +endf + +let s:cache = {} + +function! snipMate#expandSnip(snip, version, col) abort + let lnum = line('.') + let col = a:col + let line = getline(lnum) + let indent = match(line, '\S\|$') + 1 + let b:snip_state = snipmate#jumping#state() + + if a:version == 1 + let [snippet, b:snip_state.stops] = snipmate#parse#snippet(a:snip) + " Build stop/mirror info + let b:snip_state.stop_count = s:build_stops(snippet, b:snip_state.stops, lnum, col, indent) + else + let snippet = snipmate#legacy#process_snippet(a:snip) + let [b:snip_state.stops, b:snip_state.stop_count] = snipmate#legacy#build_stops(snippet, lnum, col - indent, indent) + endif + + " Abort if the snippet is empty + if empty(snippet) + return '' + endif + + let col = s:insert_snippet_text(snippet, lnum, col, indent) + + " Open any folds snippet expands into + if &foldenable + silent! exec lnum . ',' . (lnum + len(snipLines) - 1) . 'foldopen' + endif + + aug snipmate_changes + au CursorMoved,CursorMovedI if exists('b:snip_state') | + \ call b:snip_state.update_changes() | + \ else | + \ silent! au! snipmate_changes * | + \ endif + aug END + + let b:snip_state.stop_no = 0 + return b:snip_state.set_stop(0) +endfunction + +function! s:insert_snippet_text(snippet, lnum, col, indent) + let line = getline(a:lnum) + let col = a:col + let snippet = type(a:snippet) == type([]) ? a:snippet : split(a:snippet, "\n", 1) + let lnum = a:lnum + + " Keep text after the cursor + let afterCursor = strpart(line, col - 1) + if afterCursor != "\t" && afterCursor != ' ' + let line = strpart(line, 0, col - 1) + else + let afterCursor = '' + " For some reason the cursor needs to move one right after this + if line != '' && col == 1 && &ve != 'all' && &ve != 'onemore' + let col += 1 + endif + endif + + call setline(lnum, '') + call append(lnum, repeat([''], len(snippet) - 1)) + + for item in snippet + let add = lnum == a:lnum ? line : strpart(line, 0, a:indent - 1) + + if !(empty(item) || (type(item) == type([]) && empty(item[0]))) + if type(item) == type([]) + call setline(lnum, add . + \ snipMate#sniplist_str(item, b:snip_state.stops)) + else + call setline(lnum, add . + \ substitute(item, printf('%s\d\+\|%s{\d\+.\{-}}', + \ g:snipmate#legacy#sigil, g:snipmate#legacy#sigil), + \ '', 'g')) + endif + endif + + let lnum += 1 + endfor + + call setline(lnum - 1, getline(lnum - 1) . afterCursor) + + return col +endfunction + +function! snipMate#placeholder_str(num, stops) abort + return snipMate#sniplist_str(a:stops[a:num].placeholder, a:stops) +endfunction + +function! snipMate#sniplist_str(snippet, stops) abort + let str = '' + let pos = 0 + let add_to = 1 + let seen_stops = [] + + while pos < len(a:snippet) + let item = a:snippet[pos] + + if type(item) == type('') + let str .= item + elseif type(item) == type([]) + let placeholder = snipMate#placeholder_str(item[0], a:stops) + if len(item) > 1 && type(item[1]) == type({}) + let placeholder = substitute(placeholder, + \ get(item[1], 'pat', ''), + \ get(item[1], 'sub', ''), + \ get(item[1], 'flags', '')) + endif + let str .= placeholder + endif + + let pos += 1 + unlet item " avoid E706 + endwhile + + return str +endfunction + +function! s:build_stops(snippet, stops, lnum, col, indent) abort + let stops = a:stops + let lnum = a:lnum + let col = a:col + + for line in a:snippet + let col = s:build_loc_info(line, stops, lnum, col, []) + if line isnot a:snippet[-1] + let lnum += 1 + let col = a:indent + endif + endfor + + " add zero tabstop if it doesn't exist and then link it to the highest stop + " number + let stops[0] = get(stops, 0, + \ { 'placeholder' : [], 'line' : lnum, 'col' : col }) + let stop_count = max(keys(stops)) + 2 + let stops[stop_count - 1] = stops[0] + + return stop_count +endfunction + +function! s:build_loc_info(snippet, stops, lnum, col, seen_items) abort + let stops = a:stops + let lnum = a:lnum + let col = a:col + let pos = 0 + let in_text = 0 + let seen_items = a:seen_items + + for item in a:snippet + if type(item) == type('') + let col += len(item) + elseif type(item) == type([]) + let id = item[0] + let stub = item[-1] + let stub.line = lnum + let stub.col = col + call s:add_update_objects(stub, seen_items) + + if len(item) > 2 && type(item[1]) != type({}) + let col = s:build_loc_info(item[1:-2], stops, lnum, col, seen_items) + else + let col += len(snipMate#placeholder_str(id, stops)) + endif + + let in_text = 0 + endif + unlet item " avoid E706 + endfor + + return col +endfunction + +function! s:add_update_objects(object, targets) abort + let targets = a:targets + + for item in targets + let item.update_objects = get(item, 'update_objects', []) + call add(item.update_objects, a:object) + endfor + + call add(targets, a:object) +endfunction + +" reads a .snippets file +" returns list of +" ['triggername', 'name', 'contents'] +" if triggername is not set 'default' is assumed +" TODO: better error checking +fun! snipMate#ReadSnippetsFile(file) abort + let result = [] + let new_scopes = [] + if !filereadable(a:file) | return [result, new_scopes] | endif + let inSnip = 0 + let line_no = 0 + let snipversion = get(g:snipMate, 'snippet_version', 0) + for line in readfile(a:file) + ["\n"] + let line_no += 1 + + if inSnip && (line[0] == "\t" || line == '') + let content .= strpart(line, 1)."\n" + continue + elseif inSnip + call add(result, [trigger, name, + \ content[:-2], bang, snipversion]) + let inSnip = 0 + endif + + if line[:6] == 'snippet' + let inSnip = 1 + let bang = (line[7] == '!') + if bang + let bang += line[8] == '!' + endif + let trigger = strpart(line, 8 + bang) + let name = '' + let space = stridx(trigger, ' ') + 1 + if space " Process multi snip + let name = strpart(trigger, space) + let trigger = strpart(trigger, 0, space - 1) + endif + let content = '' + if trigger =~ '^\s*$' " discard snippets with empty triggers + echom 'Invalid snippet in' a:file 'near line' line_no + let inSnip = 0 + endif + elseif line[:6] == 'extends' + call extend(new_scopes, map(split(strpart(line, 8)), + \ "substitute(v:val, ',*$', '', '')")) + elseif line[:6] == 'version' + let snipversion = +strpart(line, 8) + endif + endfor + return [result, new_scopes] +endf + +function! s:GetScopes() abort + let ret = exists('b:snipMate.scope_aliases') ? copy(b:snipMate.scope_aliases) : {} + let global = get(g:snipMate, 'scope_aliases', {}) + for alias in keys(global) + if has_key(ret, alias) + let ret[alias] = join(split(ret[alias], ',') + \ + split(global[alias], ','), ',') + else + let ret[alias] = global[alias] + endif + endfor + return ret +endfunction + +" adds scope aliases to list. +" returns new list +" the aliases of aliases are added recursively +fun! s:AddScopeAliases(list) abort + let did = {} + let scope_aliases = s:GetScopes() + let new = a:list + let new2 = [] + while !empty(new) + for i in new + if !has_key(did, i) + let did[i] = 1 + call extend(new2, split(get(scope_aliases,i,''),',')) + endif + endfor + let new = new2 + let new2 = [] + endwhile + return keys(did) +endf + +augroup SnipMateSource + au SourceCmd *.snippet,*.snippets call s:source_snippet() +augroup END + +function! s:info_from_filename(file) abort + let parts = split(fnamemodify(a:file, ':r'), '/') + let snipidx = len(parts) - index(reverse(copy(parts)), 'snippets') - 1 + let rtp_prefix = join(parts[(snipidx - + \ (parts[snipidx - 1] == 'after' ? 3 : 2)):snipidx - 1], '/') + let trigger = get(parts, snipidx + 2, '') + let desc = get(parts, snipidx + 3, get(g:snipMate, 'override', 0) ? + \ '' : fnamemodify(a:file, ':t')) + return [rtp_prefix, trigger, desc] +endfunction + +function! s:source_snippet() abort + let file = expand(':p') + let [rtp_prefix, trigger, desc] = s:info_from_filename(file) + let new_snips = [] + if fnamemodify(file, ':e') == 'snippet' + call add(new_snips, [trigger, desc, join(readfile(file), "\n"), 0, + \ get(g:snipMate, 'snippet_version', 0)]) + else + let [snippets, extends] = s:CachedSnips(file) + let new_snips = deepcopy(snippets) + call extend(s:lookup_state.extends, extends) + endif + for snip in new_snips + if get(g:snipMate, 'override', 0) + let snip[1] = join([s:lookup_state.scope, snip[1]]) + else + let snip[1] = join([s:lookup_state.scope, rtp_prefix, + \ empty(snip[1]) ? desc : snip[1]]) + endif + endfor + call extend(s:lookup_state.snips, new_snips) +endfunction + +function! s:CachedSnips(file) abort + let mtime = getftime(a:file) + if has_key(s:cache, a:file) && s:cache[a:file].mtime >= mtime + return s:cache[a:file].contents + endif + let s:cache[a:file] = {} + let s:cache[a:file].mtime = mtime + let s:cache[a:file].contents = snipMate#ReadSnippetsFile(a:file) + return s:cache[a:file].contents +endfunction + +function! s:snippet_filenames(scope, trigger) abort + let mid = ['', '_*', '/*'] + let mid += map(copy(mid), "'/' . a:trigger . '*' . v:val") + call map(mid, "'snippets/' . a:scope . v:val . '.snippet'") + return map(mid[:2], 'v:val . "s"') + mid[3:] +endfunction + +function! snipMate#SetByPath(dict, trigger, path, snippet, bang, snipversion) abort + let d = a:dict + if a:bang == 2 + unlet! d[a:trigger] + return + elseif !has_key(d, a:trigger) || a:bang == 1 + let d[a:trigger] = {} + endif + let d[a:trigger][a:path] = [a:snippet, a:snipversion] +endfunction + +if v:version < 704 || has('win32') + function! s:Glob(path, expr) + let res = [] + for p in split(a:path, ',') + let h = split(fnamemodify(a:expr, ':h'), '/')[0] + if isdirectory(p . '/' . h) + call extend(res, split(glob(p . '/' . a:expr), "\n")) + endif + endfor + return filter(res, 'filereadable(v:val)') + endfunction +else + function! s:Glob(path, expr) + return split(globpath(a:path, a:expr), "\n") + endfunction +endif + +" default triggers based on paths +function! snipMate#DefaultPool(scopes, trigger, result) abort + let scopes = s:AddScopeAliases(a:scopes) + let scopes_done = [] + let s:lookup_state = {} + let s:lookup_state.snips = [] + + while !empty(scopes) + let scope = remove(scopes, 0) + let s:lookup_state.scope = scope + let s:lookup_state.extends = [] + + for expr in s:snippet_filenames(scope, escape(a:trigger, "*[]?{}`'$|#%")) + for path in s:snippet_dirs() + for file in s:Glob(path, expr) + source `=file` + endfor + endfor + endfor + + call add(scopes_done, scope) + call extend(scopes, s:lookup_state.extends) + call filter(scopes, 'index(scopes_done, v:val) == -1') + endwhile + + for [trigger, desc, contents, bang, snipversion] in s:lookup_state.snips + if trigger =~ '\V\^' . escape(a:trigger, '\') + call snipMate#SetByPath(a:result, trigger, desc, contents, bang, snipversion) + endif + endfor +endfunction + +" return a dict of snippets found in runtimepath matching trigger +" scopes: list of scopes. usually this is the filetype. eg ['c','cpp'] +" trigger may contain glob patterns. Thus use '*' to get all triggers +" +fun! snipMate#GetSnippets(scopes, trigger) abort + let result = {} + + for F in values(g:snipMateSources) + call funcref#Call(F, [a:scopes, a:trigger, result]) + endfor + return result +endf + +function! s:snippet_dirs() abort + return get(g:snipMate, 'snippet_dirs', split(&rtp, ',')) +endfunction + +function! snipMate#OpenSnippetFiles() abort + let files = [] + let scopes_done = [] + let exists = [] + let notexists = [] + for scope in s:AddScopeAliases(snipMate#ScopesByFile()) + let files += s:snippet_filenames(scope, '') + endfor + call filter(files, "v:val !~# '\\*'") + for path in s:snippet_dirs() + let fullpaths = map(copy(files), 'printf("%s/%s", path, v:val)') + let exists += filter(copy(fullpaths), 'filereadable(v:val)') + let notexists += map(filter(copy(fullpaths), + \ 'v:val =~# "\.snippets" && !filereadable(v:val)'), + \ '"does not exist: " . v:val') + endfor + let all = exists + notexists + let select = tlib#input#List('mi', 'select files to be opened in splits', all) + for idx in select + exec 'sp' all[idx - 1] + endfor +endfunction + +fun! snipMate#ScopesByFile() abort + " duplicates are removed in AddScopeAliases + return filter(funcref#Call(g:snipMate.get_scopes), "v:val != ''") +endf + +" used by both: completion and insert snippet +fun! snipMate#GetSnippetsForWordBelowCursor(word, exact) abort + " Split non-word characters into their own piece + " so 'foo.bar..baz' becomes ['foo', '.', 'bar', '.', '.', 'baz'] + " First split just after a \W and then split each resultant string just + " before a \W + let parts = filter(tlib#list#Flatten( + \ map(split(a:word, '\W\zs'), 'split(v:val, "\\ze\\W")')), + \ '!empty(v:val)') + " Only look at the last few possibilities. Too many can be slow. + if len(parts) > 5 + let parts = parts[-5:] + endif + let lookups = [a:word] + let lookup = '' + for w in reverse(parts) + let lookup = w . lookup + if index(lookups, lookup) == -1 + call add(lookups, lookup) + endif + endfor + + " Remove empty lookup entries, but only if there are other nonempty lookups + if len(lookups) > 1 + call filter(lookups, 'v:val != ""') + endif + + let matching_snippets = [] + let snippet = '' + " prefer longest word + for word in lookups + let g:snipMate.word = word + for [k,snippetD] in items(funcref#Call(g:snipMate['get_snippets'], [snipMate#ScopesByFile(), word])) + " hack: require exact match + if a:exact && k !=# word + continue + endif + call add(matching_snippets, [k, snippetD]) + if a:exact + break + endif + endfor + endfor + return matching_snippets +endf + +" snippets: dict containing snippets by name +" usually this is just {'default' : snippet_contents } +fun! s:ChooseSnippet(snippets) abort + let snippet = [] + let keys = keys(a:snippets) + let i = 1 + for snip in keys + let snippet += [i.'. '.snip] + let i += 1 + endfor + if len(snippet) == 1 || get(g:snipMate, 'always_choose_first', 0) == 1 + " there's only a single snippet, choose it + let idx = 0 + else + let idx = tlib#input#List('si','select snippet by name',snippet) -1 + if idx == -1 + return '' + endif + endif + " if a:snippets[..] is a String Call returns it + " If it's a function or a function string the result is returned + return funcref#Call(a:snippets[keys(a:snippets)[idx]]) +endf + +fun! snipMate#WordBelowCursor() abort + return matchstr(getline('.'), '\S\+\%' . col('.') . 'c') +endf + +fun! snipMate#GetSnippetsForWordBelowCursorForComplete(word) abort + let matches = snipMate#GetSnippetsForWordBelowCursor(a:word, 0) + let snippets = [] + for [trigger, dict] in matches + if get(g:snipMate, 'description_in_completion', 0) + call extend(snippets, map(keys(dict), + \ '{ "word" : trigger, "menu" : v:val, "dup" : 1 }')) + else + call add(snippets, { "word" : trigger }) + endif + endfor + return filter(snippets, + \ 'v:val.word =~# "\\V\\^' . escape(a:word, '"\') . '"') +endf + +fun! snipMate#CanBeTriggered() abort + let word = snipMate#WordBelowCursor() + let matches = snipMate#GetSnippetsForWordBelowCursorForComplete(word) + return len(matches) > 0 +endf + +fun! snipMate#ShowAvailableSnips() abort + let col = col('.') + let word = snipMate#WordBelowCursor() + let matches = snipMate#GetSnippetsForWordBelowCursorForComplete(word) + + " Pretty hacky, but really can't have the tab swallowed! + if len(matches) == 0 + call feedkeys(g:snipMate['no_match_completion_feedkeys_chars'], 'n') + return "" + endif + + call complete(col - len(word), sort(matches)) + return '' +endf + +" Pass an argument to force snippet expansion instead of triggering or jumping +function! snipMate#TriggerSnippet(...) abort + if exists('g:SuperTabMappingForward') + if g:SuperTabMappingForward == "" + let SuperTabPlug = maparg('SuperTabForward', 'i') + if SuperTabPlug == "" + let SuperTabKey = "\" + else + exec "let SuperTabKey = \"" . escape(SuperTabPlug, '<') . "\"" + endif + elseif g:SuperTabMappingBackward == "" + let SuperTabPlug = maparg('SuperTabBackward', 'i') + if SuperTabPlug == "" + let SuperTabKey = "\" + else + exec "let SuperTabKey = \"" . escape(SuperTabPlug, '<') . "\"" + endif + endif + endif + + if pumvisible() " Update snippet if completion is used, or deal with supertab + if exists('SuperTabKey') + call feedkeys(SuperTabKey) | return '' + endif + call feedkeys("\a", 'n') " Close completion menu + call feedkeys("\") | return '' + endif + + if exists('b:snip_state') && a:0 == 0 " Jump only if no arguments + let jump = b:snip_state.jump_stop(0) + if type(jump) == 1 " returned a string + return jump + endif + endif + + let word = matchstr(getline('.'), '\S\+\%'.col('.').'c') + let list = snipMate#GetSnippetsForWordBelowCursor(word, 1) + if empty(list) + let snippet = '' + else + let [trigger, snippetD] = list[0] + let snippet = s:ChooseSnippet(snippetD) + " Before expanding snippet, create new undo point |i_CTRL-G| + let &undolevels = &undolevels + let col = col('.') - len(trigger) + sil exe 's/\V'.escape(trigger, '/\.').'\%#//' + return snipMate#expandSnip(snippet[0], snippet[1], col) + endif + + " should allow other plugins to register hooks instead (duplicate code) + if exists('SuperTabKey') + call feedkeys(SuperTabKey) + return '' + endif + return word == '' + \ ? "\" + \ : "\=snipMate#ShowAvailableSnips()\" +endfunction + +fun! snipMate#BackwardsSnippet() abort + if exists('b:snip_state') | return b:snip_state.jump_stop(1) | endif + + if exists('g:SuperTabMappingForward') + if g:SuperTabMappingForward == "" + let SuperTabPlug = maparg('SuperTabForward', 'i') + if SuperTabPlug == "" + let SuperTabKey = "\" + else + exec "let SuperTabKey = \"" . escape(SuperTabPlug, '<') . "\"" + endif + elseif g:SuperTabMappingBackward == "" + let SuperTabPlug = maparg('SuperTabBackward', 'i') + if SuperTabPlug == "" + let SuperTabKey = "\" + else + exec "let SuperTabKey = \"" . escape(SuperTabPlug, '<') . "\"" + endif + endif + endif + " should allow other plugins to register hooks instead (duplicate code) + if exists('SuperTabKey') + call feedkeys(SuperTabKey) + return '' + endif + return "\" +endf + +" vim:noet:sw=4:ts=4:ft=vim diff --git a/skel/.config/nvim/plugged/vim-snipmate/autoload/snipMate_python_demo.vim b/skel/.config/nvim/plugged/vim-snipmate/autoload/snipMate_python_demo.vim new file mode 100644 index 0000000..de495d2 --- /dev/null +++ b/skel/.config/nvim/plugged/vim-snipmate/autoload/snipMate_python_demo.vim @@ -0,0 +1,47 @@ +" This file demonstrates +" - how to register your own snippet sources (call snipMate_python_demo#Activate() in ftplugin/python.vim) +" - implents a source which creates snippets based on python function +" definitions found in the current file +" +" Example: +" +" def abc(a,b,c=None) +" will create a snippet on the fly which looks like this: +" abc(${1:a}, ${2:b}, ${3:c=None}) + +fun! snipMate_python_demo#Activate() abort + if !exists('g:snipMateSources') + let g:snipMateSources = {} + endif + + let g:snipMateSources['python'] = funcref#Function('snipMate_python_demo#FunctionsFromCurrentFileAndTags') +endf + +fun! s:Add(dict, line, source, trigger) abort + let matched = matchlist(a:line,'def\s\+\([^( \t]\+\)[ \t]*(\([^)]*\)') + if len(matched) > 2 + let name = matched[1] + " TODO: is this a glob? + if name !~ a:trigger | return | endif + let a:dict[name] = get(a:dict, name, {}) + let sd = a:dict[name] + let args = [] + let nr=1 + for arg in split(matched[2], '\s*,\s*') + call add(args, '${'.nr.':'.arg.'}') + let nr+=1 + endfor + let sd[a:source] = name.'('.join(args,', ').')' + endif +endf +fun! snipMate_python_demo#FunctionsFromCurrentFileAndTags(scopes, trigger, result) abort + " getting all might be too much + if a:trigger == '*' | return | endif + if index(a:scopes, 'python') < 0 | return | endif + for t in taglist('^'.a:trigger) + call s:Add(a:result, t.cmd, 'tags-' . t.filename, a:trigger) + endfor + for l in getline(0, line('$')) + call s:Add(a:result, l, 'current-file', a:trigger) + endfor +endf diff --git a/skel/.config/nvim/plugged/vim-snipmate/autoload/snipmate/jumping.vim b/skel/.config/nvim/plugged/vim-snipmate/autoload/snipmate/jumping.vim new file mode 100644 index 0000000..aaf65ab --- /dev/null +++ b/skel/.config/nvim/plugged/vim-snipmate/autoload/snipmate/jumping.vim @@ -0,0 +1,228 @@ +function! s:sfile() abort + return expand('') +endfunction + +let s:state_proto = {} + +function! snipmate#jumping#state() abort + return copy(s:state_proto) +endfunction + +function! s:listize_mirror(mirrors) abort + return map(copy(a:mirrors), '[v:val.line, v:val.col]') +endfunction + +" Removes snippet state info +function! s:state_remove() dict abort + " Remove all autocmds in group snipmate_changes in the current buffer + unlet! b:snip_state + silent! au! snipmate_changes * +endfunction + +function! s:state_find_next_stop(backwards) dict abort + let self.stop_no += a:backwards? -1 : 1 + while !has_key(self.stops, self.stop_no) + if self.stop_no == self.stop_count + let self.stop_no = 0 + endif + if self.stop_no <= 0 && a:backwards + let self.stop_no = self.stop_count - 1 + endif + let self.stop_no += a:backwards? -1 : 1 + endwhile +endfunction + +" Update state information to correspond to the given tab stop +function! s:state_set_stop(backwards) dict abort + call self.find_next_stop(a:backwards) + let self.cur_stop = self.stops[self.stop_no] + let self.stop_len = (type(self.cur_stop.placeholder) == type(0)) + \ ? self.cur_stop.placeholder + \ : len(snipMate#placeholder_str(self.stop_no, self.stops)) + let self.start_col = self.cur_stop.col + let self.end_col = self.start_col + self.stop_len + let self.mirrors = get(self.cur_stop, 'mirrors', []) + let self.old_mirrors = deepcopy(self.mirrors) + call cursor(self.cur_stop.line, self.cur_stop.col) + let self.prev_len = col('$') + let self.changed = 0 + let ret = self.select_word() + if (self.stop_no == 0 || self.stop_no == self.stop_count - 1) && !a:backwards + call self.remove() + endif + return ret +endfunction + +" Jump to the next/previous tab stop +function! s:state_jump_stop(backwards) dict abort + " Update changes just in case + " This seems to be only needed because insert completion does not trigger + " the CursorMovedI event + call self.update_changes() + + " Store placeholder/location changes + let self.cur_stop.col = self.start_col + if self.changed + call self.remove_nested() + unlet! self.cur_stop.placeholder " avoid type error for old parsing version + let self.cur_stop.placeholder = [strpart(getline('.'), + \ self.start_col - 1, self.end_col - self.start_col)] + endif + + return self.set_stop(a:backwards) +endfunction + +function! s:state_remove_nested(...) dict abort + let id = a:0 ? a:1 : self.stop_no + if type(self.stops[id].placeholder) == type([]) + for i in self.stops[id].placeholder + if type(i) == type([]) + if type(i[1]) != type({}) + call self.remove_nested(i[0]) + call remove(self.stops, i[0]) + else + call filter(self.stops[i[0]].mirrors, 'v:val isnot i[1]') + endif + endif + unlet i " Avoid E706 + endfor + endif +endfunction + +" Select the placeholder for the current tab stop +function! s:state_select_word() dict abort + let len = self.stop_len + if !len | return '' | endif + let l = col('.') != 1 ? 'l' : '' + if &sel == 'exclusive' + return "\".l.'v'.len."l\" + endif + return len == 1 ? "\".l.'gh' : "\".l.'v'.(len - 1)."l\" +endfunction + +" Update the snippet as text is typed. The self.update_mirrors() function does +" the actual work. +" If the cursor moves outside of a placeholder, call self.remove() +function! s:state_update_changes() dict abort + let change_len = col('$') - self.prev_len + let self.changed = self.changed || change_len != 0 + let self.end_col += change_len + let col = col('.') + + if line('.') != self.cur_stop.line || col < self.start_col || col > self.end_col + return self.remove() + endif + + call self.update(self.cur_stop, change_len, change_len) + if !empty(self.mirrors) + call self.update_mirrors(change_len) + endif + + let self.prev_len = col('$') +endfunction + +" Actually update the mirrors for any changed text +function! s:state_update_mirrors(change) dict abort + let newWordLen = self.end_col - self.start_col + let newWord = strpart(getline('.'), self.start_col - 1, newWordLen) + let changeLen = a:change + let curLine = line('.') + let curCol = col('.') + let oldStartSnip = self.start_col + let i = 0 + + for mirror in self.mirrors + for stop in values(filter(copy(self.stops), 'v:key != 0')) + if type(stop.placeholder) == type(0) + if mirror.line == stop.line && mirror.col > stop.col + \ && mirror.col < stop.col + stop.placeholder + let stop.placeholder += changeLen + endif + endif + endfor + + if has_key(mirror, 'oldSize') + " recover the old size deduce the endline + let oldSize = mirror.oldSize + else + " first time, we use the intitial size + let oldSize = strlen(newWord) + endif + + " Split the line into three parts: the mirror, what's before it, and + " what's after it. Then combine them using the new mirror string. + " Subtract one to go from column index to byte index + + let theline = getline(mirror.line) + + " part before the current mirror + let beginline = strpart(theline, 0, mirror.col - 1) + + " current mirror transformation, and save size + let wordMirror= substitute(newWord, get(mirror, 'pat', ''), get(mirror, 'sub', ''), get(mirror, 'flags', '')) + let mirror.oldSize = strlen(wordMirror) + + " end of the line, use the oldSize because with the transformation, + " the size of the mirror can be different from those of the snippet + let endline = strpart(theline, mirror.col + oldSize -1) + + " Update other object on the line + call self.update(mirror, changeLen, mirror.oldSize - oldSize) + + " reconstruct the line + let update = beginline.wordMirror.endline + + call setline(mirror.line, update) + endfor + + " Reposition the cursor in case a var updates on the same line but before + " the current tabstop + if oldStartSnip != self.start_col || mode() == 'i' + call cursor(0, curCol + self.start_col - oldStartSnip) + endif +endfunction + +function! s:state_find_update_objects(item) dict abort + let item = a:item + let item.update_objects = [] + + " Filter the zeroth stop because it's duplicated as the last + for stop in values(filter(copy(self.stops), 'v:key != 0')) + if stop.line == item.line && stop.col > item.col + call add(item.update_objects, stop) + endif + + for mirror in get(stop, 'mirrors', []) + if mirror.line == item.line && mirror.col > item.col + call add(item.update_objects, mirror) + endif + endfor + endfor + + return item.update_objects +endfunction + +function! s:state_update(item, change_len, mirror_change) dict abort + let item = a:item + if !exists('item.update_objects') + let item.update_objects = self.find_update_objects(a:item) + endif + let to_update = item.update_objects + + for obj in to_update + " object does not necessarly have the same decalage + " than mirrors if mirrors use regexp + let obj.col += a:mirror_change + if obj is self.cur_stop + let self.start_col += a:change_len + let self.end_col += a:change_len + endif + endfor +endfunction + +call extend(s:state_proto, snipmate#util#add_methods(s:sfile(), 'state', + \ [ 'remove', 'set_stop', 'jump_stop', 'remove_nested', + \ 'select_word', 'update_changes', 'update_mirrors', + \ 'find_next_stop', 'find_update_objects', 'update' ]), 'error') + +" vim:noet:sw=4:ts=4:ft=vim diff --git a/skel/.config/nvim/plugged/vim-snipmate/autoload/snipmate/legacy.vim b/skel/.config/nvim/plugged/vim-snipmate/autoload/snipmate/legacy.vim new file mode 100644 index 0000000..7ff39cb --- /dev/null +++ b/skel/.config/nvim/plugged/vim-snipmate/autoload/snipmate/legacy.vim @@ -0,0 +1,139 @@ +let s:sigil = nr2char(31) +let snipmate#legacy#sigil = s:sigil + +" Prepare snippet to be processed by s:BuildTabStops +function! snipmate#legacy#process_snippet(snip) abort + let snippet = a:snip + let esc_bslash = '\%(\\\@ a:lnum + \ ? len(matchstr(beforeMark, '.*\n\zs.*')) + \ : a:col + len(beforeMark)) + call add(stops[i].mirrors, { 'line' : line, 'col' : col }) + let withoutOthers = substitute(withoutOthers, ''.s:sigil .''.i.'\ze\(\D\|$\)', '', '') + endw + endif + let i += 1 + endw + let stops[i] = stops[0] + return [stops, i + 1] +endfunction + +function! s:substitute_visual(snippet, visual) abort + let lines = [] + for line in split(a:snippet, "\n") + let indent = matchstr(line, '^\t\+') + call add(lines, substitute(line, '{VISUAL}', + \ substitute(escape(a:visual, '%\'), "\n", "\n" . indent, 'g'), 'g')) + endfor + return join(lines, "\n") +endfunction + +" Counts occurences of haystack in needle +function! s:count(haystack, needle) abort + let counter = 0 + let index = stridx(a:haystack, a:needle) + while index != -1 + let index = stridx(a:haystack, a:needle, index+1) + let counter += 1 + endw + return counter +endfunction diff --git a/skel/.config/nvim/plugged/vim-snipmate/autoload/snipmate/parse.vim b/skel/.config/nvim/plugged/vim-snipmate/autoload/snipmate/parse.vim new file mode 100644 index 0000000..4cf60e9 --- /dev/null +++ b/skel/.config/nvim/plugged/vim-snipmate/autoload/snipmate/parse.vim @@ -0,0 +1,323 @@ +" Snippet definition parsing code + +function! s:sfile() abort + return expand('') +endfunction + +let s:parser_proto = {} +let s:special_chars = "$`\n" + +function! s:new_parser(text) abort + let ret = copy(s:parser_proto) + let ret.input = a:text + let ret.len = strlen(ret.input) + let ret.pos = -1 + let ret.indent = 0 + let ret.value = [] + let ret.vars = {} + let ret.stored_lines = [] + call ret.advance() + return ret +endfunction + +function! s:parser_advance(...) dict abort + let self.pos += a:0 ? a:1 : 1 + let self.next = self.input[self.pos] +endfunction + +function! s:parser_same(tok) dict abort + if self.next == a:tok + call self.advance() + return 1 + else + return 0 + endif +endfunction + +function! s:parser_id() dict abort + if self.input[(self.pos):(self.pos+5)] == 'VISUAL' + call self.advance(6) + return 'VISUAL' + elseif self.next =~ '\d' + let end = matchend(self.input, '\d\+', self.pos) + let res = strpart(self.input, self.pos, end - self.pos) + call self.advance(end - self.pos) + return +res " force conversion to Number + endif + return -1 +endfunction + +function! s:parser_add_var(var) dict abort + let id = a:var[0] + if !has_key(self.vars, id) + let self.vars[id] = { 'instances' : [] } + endif + call add(self.vars[id].instances, a:var) +endfunction + +function! s:parser_var() dict abort + let ret = [] + if self.same('{') + let id = self.id() + if id >= 0 + call add(ret, id) + call extend(ret, self.varend()) + endif + else + let id = self.id() + if id >= 0 + call add(ret, id) + endif + endif + return ret +endfunction + +function! s:parser_varend() dict abort + let ret = [] + if self.same(':') + call extend(ret, self.placeholder()) + elseif self.same('/') + call add(ret, self.subst()) + endif + call self.same('}') + return ret +endfunction + +function! s:parser_placeholder() dict abort + let ret = self.text('}') + return empty(ret) ? [''] : ret +endfunction + +function! s:parser_subst() dict abort + let ret = {} + let ret.pat = self.pat() + if self.same('/') + let ret.sub = self.pat(1) + endif + if self.same('/') + let ret.flags = self.pat(1) + endif + return ret +endfunction + +function! s:parser_pat(...) dict abort + let val = '' + + while self.pos < self.len + if self.same('\') + if self.next == '/' + let val .= '/' + call self.advance() + elseif a:0 && self.next == '}' + let val .= '}' + call self.advance() + else + let val .= '\' + endif + elseif self.next == '/' || a:0 && self.next == '}' + break + else + let val .= self.next + call self.advance() + endif + endwhile + + return val +endfunction + +function! s:parser_expr() dict abort + let str = self.string('`') + call self.same('`') + return snipmate#util#eval(str) +endfunction + +function! s:parser_string(till, ...) dict abort + let val = '' + let till = '\V\[' . escape(a:till, '\') . ']' + + while self.pos < self.len + if self.same('\') + if self.next != "\n" + let val .= self.next + endif + call self.advance() + elseif self.next =~# till + break + elseif self.next == "\t" + let self.indent += 1 + let val .= s:indent(1) + call self.advance() + else + let val .= self.next + call self.advance() + endif + endwhile + + return val +endfunction + +function! s:join_consecutive_strings(list) abort + let list = a:list + let pos = 0 + while pos + 1 < len(list) + if type(list[pos]) == type('') && type(list[pos+1]) == type('') + let list[pos] .= list[pos+1] + call remove(list, pos + 1) + else + let pos += 1 + endif + endwhile +endfunction + +function! s:parser_text(till) dict abort + let ret = [] + let target = ret + + while self.pos < self.len + let lines = [] + + if self.same('$') + let var = self.var() + if !empty(var) + if var[0] is# 'VISUAL' + let lines = s:visual_placeholder(var, self.indent) + " Remove trailing newline. See #245 + if lines[-1] =~ '^\s*$' && self.next == "\n" + call remove(lines, -1) + endif + elseif var[0] >= 0 + call add(target, var) + call self.add_var(var) + endif + endif + elseif self.same('`') + let lines = split(self.expr(), "\n", 1) + else + let lines = [self.string(a:till . s:special_chars)] + endif + + if !empty(lines) + call add(target, lines[0]) + call extend(self.stored_lines, lines[1:-2]) + " Don't change targets if there's only one line + if exists("lines[1]") + let target = [lines[-1]] + endif + endif + + " Empty lines are ignored if this is tested at the start of an iteration + if self.next ==# a:till + break + endif + endwhile + + call s:join_consecutive_strings(ret) + if target isnot ret + call s:join_consecutive_strings(target) + call extend(self.stored_lines, target) + endif + + return ret +endfunction + +function! s:parser_line() dict abort + let ret = [] + if !empty(self.stored_lines) + call add(ret, remove(self.stored_lines, 0)) + else + call extend(ret, self.text("\n")) + call self.same("\n") + endif + let self.indent = 0 + return ret +endfunction + +function! s:parser_parse() dict abort + while self.pos < self.len || !empty(self.stored_lines) + let line = self.line() + call add(self.value, line) + endwhile +endfunction + +function! s:indent(count) abort + if &expandtab + let shift = repeat(' ', snipmate#util#tabwidth()) + else + let shift = "\t" + endif + return repeat(shift, a:count) +endfunction + +function! s:visual_placeholder(var, indent) abort + let arg = get(a:var, 1, {}) + if type(arg) == type({}) + let pat = get(arg, 'pat', '') + let sub = get(arg, 'sub', '') + let flags = get(arg, 'flags', '') + let content = split(substitute(get(b:, 'snipmate_visual', ''), pat, sub, flags), "\n", 1) + else + let content = split(get(b:, 'snipmate_visual', arg), "\n", 1) + endif + + let indent = s:indent(a:indent) + call map(content, '(v:key != 0) ? indent . v:val : v:val') + + return content +endfunction + +function! s:parser_create_stubs() dict abort + + for [id, dict] in items(self.vars) + for i in dict.instances + if len(i) > 1 && type(i[1]) != type({}) + if !has_key(dict, 'placeholder') + let dict.placeholder = i[1:] + call add(i, dict) + else + unlet i[1:] + call s:create_mirror_stub(i, dict) + endif + else + call s:create_mirror_stub(i, dict) + endif + endfor + if !has_key(dict, 'placeholder') + let dict.placeholder = [] + let j = 0 + while len(dict.instances[j]) > 2 + let j += 1 + endwhile + let oldstub = remove(dict.instances[j], 1, -1)[-1] + call add(dict.instances[j], '') + call add(dict.instances[j], dict) + call filter(dict.mirrors, 'v:val isnot oldstub') + endif + unlet dict.instances + endfor + +endfunction + +function! s:create_mirror_stub(mirror, dict) + let mirror = a:mirror + let dict = a:dict + let stub = get(mirror, 1, {}) + call add(mirror, stub) + let dict.mirrors = get(dict, 'mirrors', []) + call add(dict.mirrors, stub) +endfunction + +function! snipmate#parse#snippet(text, ...) abort + let parser = s:new_parser(a:text) + call parser.parse() + if !(a:0 && a:1) + call parser.create_stubs() + endif + unlet! b:snipmate_visual + return [parser.value, parser.vars] +endfunction + +call extend(s:parser_proto, snipmate#util#add_methods(s:sfile(), 'parser', + \ [ 'advance', 'same', 'id', 'add_var', 'var', 'varend', + \ 'line', 'string', 'create_stubs', 'pat', + \ 'placeholder', 'subst', 'expr', 'text', 'parse', + \ ]), 'error') diff --git a/skel/.config/nvim/plugged/vim-snipmate/autoload/snipmate/util.vim b/skel/.config/nvim/plugged/vim-snipmate/autoload/snipmate/util.vim new file mode 100644 index 0000000..a80d307 --- /dev/null +++ b/skel/.config/nvim/plugged/vim-snipmate/autoload/snipmate/util.vim @@ -0,0 +1,30 @@ +" The next function was based on s:function and s:add_methods in fugitive +" +function! snipmate#util#add_methods(sfile, namespace, methods) abort + let dict = {} + for name in a:methods + let dict[name] = function(join([matchstr(a:sfile, '\d\+'), + \ a:namespace, name], '_')) + endfor + return dict +endfunction + +function! snipmate#util#eval(arg) + try + let ret = eval(a:arg) + catch + echohl ErrorMsg + echom 'SnipMate:Expression: ' . v:exception + echohl None + let ret = '' + endtry + return type(ret) == type('') ? ret : string(ret) +endfunction + +function! snipmate#util#tabwidth() + if &sts > 0 + return &sts + else + return exists('*shiftwidth') ? shiftwidth() : &sw + endif +endfunction diff --git a/skel/.config/nvim/plugged/vim-snipmate/doc/SnipMate.txt b/skel/.config/nvim/plugged/vim-snipmate/doc/SnipMate.txt new file mode 100644 index 0000000..cb5f9ff --- /dev/null +++ b/skel/.config/nvim/plugged/vim-snipmate/doc/SnipMate.txt @@ -0,0 +1,704 @@ +*SnipMate.txt* Plugin for using TextMate-style snippets in Vim. + +SnipMate *snippet* *snippets* *SnipMate* + +1. Description |SnipMate-description| +2. Usage |SnipMate-usage| +3. Interface and Settings |SnipMate-interface| |SnipMate-settings| +4. Snippets |SnipMate-snippets| + - Snippet files |SnipMate-snippet-files| + - Snippet syntax |SnipMate-syntax| +5. Snippet sources |SnipMate-snippet-sources| +6. Disadvantages to TextMate |SnipMate-disadvantages| +7. Contact |SnipMate-contact| +8. License |SnipMate-license| + +For Vim version 7.0 or later. +This plugin only works if 'compatible' is not set. +{Vi does not have any of these features.} + +SnipMate depends on vim-addon-mw-utils and tlib. + +============================================================================== +DESCRIPTION *SnipMate-description* + +SnipMate implements snippet features in Vim. A snippet is like a template, +reducing repetitive insertion of pieces of text. Snippets can contain +placeholders for modifying the text if necessary or interpolated code for +evaluation. For example, in C, typing "for" then pushing could expand +to: > + + for (i = 0; i < count; i++) { + /* code */ + } + +SnipMate is inspired by TextMate's snippet features. + +============================================================================== +USAGE *SnipMate-usage* + +Every snippet consists of an expansion and a trigger. Typing a trigger into +your buffer and then hitting your trigger key ( by default, see +|SnipMate-mappings|) will replace the trigger with the expansion text. + +The expansion text can optionally include tab stops. When it does, upon +expansion of the snippet, the cursor is placed at the first one, and the user +can jump between each tab stop. Each of these tab stops can be represented by +default placeholder text. If such a placeholder is provided, then the text of +the placeholder can be repeated in the snippet at specified mirrors. Any edits +to the placeholder are instantly updated at every mirror. + +SnipMate allows multiple snippets to use the same trigger. When triggered, +a list of all snippets with that trigger is provided and prompts for which +snippet to use. + + *SnipMate-scopes* +SnipMate searches for snippets inside a directory named "snippets" inside each +entry in 'runtimepath'. Which files are loaded depends on 'filetype' and +'syntax'; see |SnipMate-syntax| for more information. Snippets are loaded and +refreshed automatically on demand. + +Note: SnipMate does not ship with any snippets. In order to use it, the user +must either write their own snippets or obtain some from a repository like +https://github.com/honza/vim-snippets + +============================================================================== +INTERFACE AND SETTINGS *SnipMate-interface* *SnipMate-settings* + + *SnipMate-commands* +Commands~ + + *:SnipMateOpenSnippetFiles* +:SnipMateOpenSnippetFiles Opens a list of all valid snippet locations + based on the current scope |SnipMate-scopes|. + Only existing files and non-existing .snippets + files will be shown, with the existing files + shown first. + +:SnipMateLoadScope[!] scope [scope ...] + Load snippets from additional scopes. Without + [!] the additional scopes are loaded only in + the current buffer. For example > + :SnipMateLoadScopes rails +< will load all rails.snippets in the current + buffer. + + *SnipMate-options* +Options~ + +g:snips_author A variable used in some snippets in place of + the author's (your) name. Similar to + $TM_FULLNAME in TextMate. For example, > + snippet name + `g:snips_author` +< creates a snippet "name" that expands to your + name. + +g:snipMate This |Dictionary| contains other SnipMate + options. In short add > + let g:snipMate = {} +< to your .vimrc before setting other SnipMate + options. + +g:snipMate.scope_aliases A |Dictionary| associating certain filetypes + with other scopes |SnipMate-scopes|. The + entries consist of a filetype as the key and + a comma-separated list of aliases as the + value. For example, > + let g:snipMate.scope_aliases = {} + let g:snipMate.scope_aliases['ruby'] + \ = 'ruby,ruby-rails' +< tells SnipMate that "ruby-rails" snippets in + addition to "ruby" snippets should be loaded + when editing files with 'filetype' set to + "ruby" or contains "ruby" as an entry in the + case of dotted filetypes. A buffer local + variant b:snipMate_scope_aliases is merged + with the global variant. + +g:snipMate_no_default_aliases Note: This has been renamed to the following. + +g:snipMate.no_default_aliases + When set to 1, prevents SnipMate from loading + default scope aliases. The defaults are: + Filetype Alias ~ + cpp c + cu c + eruby eruby-rails,html + html javascript + mxml actionscript + objc c + php php,html,javascript + ur html,javascript + xhtml html + Individual defaults can be disabled by setting + them to an empty value: > + let g:snipMate.scope_aliases.php = '' +< will disable the default PHP alias. + Note: Setting this option does not disable + scope aliases entirely, only those made by + SnipMate itself. Any scope aliases created by + the user or someone else will still be in + effect. + +g:snipMate.snippet_version + The snippet parser version to use. The + possible values are: + 0 Use the older parser + 1 Use the newer parser + If unset, SnipMate defaults to version 0. The + value of this option is also used for all + .snippet files. See |SnipMate-parser-versions| + for more information. + +g:snipMate.override + As detailed below, when two snippets with the + same name and description are loaded, both are + kept and differentiated by the location of the + file they were in. When this option is enabled + (set to 1), the snippet originating in the + last loaded file is kept, similar to how Vim + maps and other settings work. Note: Load order + is determined by 'runtimepath'. + + Duplicates are only dropped after reading one + snippet file. If multiple files contain a + snippet see always_choose_first +g:snipMate.always_choose_first + Always choose first snippet if there are + multiple left + +g:snipMate.description_in_completion + If set to 1 (default is 0), snippet + descriptions will be included in the popup + menu used for snippet completion, like with + snipMateShow. + +g:snipMate['no_match_completion_feedkeys_chars'] + A string inserted when no match for a trigger + is found. By default a tab is inserted + according to 'expandtab', 'tabstop', and + 'softtabstop'. Set it to the empty string to + prevent anything from being inserted. + + *SnipMate-mappings* +Mappings~ + +The mappings SnipMate uses can be customized with the |:map| commands. For +example, to change the key that triggers snippets and moves to the next +tab stop, > + + :imap snipMateNextOrTrigger + :smap snipMateNextOrTrigger + +Note: The noremap variants of the map commands must NOT be used. + +The list of possible mappings is as follows: + +snipMateNextOrTrigger Default: Mode: Insert, Select + Jumps to the next tab stop or, if none exists, + try to expand a snippet. Use in both insert + and select modes. + +snipMateTrigger Default: unmapped Mode: Insert + Try to expand a snippet regardless of any + existing snippet expansion. If done within an + expanded snippet, the outer snippet's tab + stops are lost, unless expansion failed. + +snipMateBack Default: Mode: Insert, Select + Jump to the previous tab stop, if it exists. + Use in both insert and select modes. + +snipMateShow Default: Mode: Insert + Show all available snippets (that start with + the previous text, if it exists). Use in + insert mode. + +snipMateVisual Default: Mode: Visual + See |SnipMate-visual|. + +Additionally, is mapped in visual mode in .snippets files for retabbing +snippets. + +============================================================================== +SNIPPETS *SnipMate-snippets* + + *SnipMate-snippet-files* +Snippet Files ~ + +Note: SnipMate does not ship with any snippets. + +SnipMate looks inside of each entry of 'rtp' (or |SnipMate-snippet-sources|) +for a directory named /snippets/. Based on the 'filetype' and 'syntax' +settings (dotted filetypes are parsed), the following files are read for +snippets: > + + .../snippets/.snippets + .../snippets/_.snippets + .../snippets//.snippets + .../snippets//.snippet + .../snippets///.snippet + +where is a scope or 'filetype' or 'syntax', is an arbitrary +name, is the trigger for a snippet, and is +a description used for |SnipMate-multisnip|. + +A .snippet file defines a single snippet with the trigger (and description) +determined by the filename. The entire contents of the file are used as the +snippet expansion text. + +Multiple snippets can be defined in *.snippets files. Each snippet definition +looks something like: > + + snippet trigger optional description + expanded text + more expanded text + +< *SnipMate-multisnip* +The description is optional. If it is left out, the description "default" is +used. When two snippets in the same scope have the same name and the same +description, SnipMate will try to preserve both. The g:snipMate.override +option disables this, in favor of keeping the last-loaded snippet. This can be +overridden on a per-snippet basis by defining the snippet with a bang (!): > + + snippet! trigger optional description + expanded text + more expanded text + +Two bangs will remove the trigger entirely from SnipMate's lookup. In this +case any snippet text is unused. + +Note: Hard tabs in the expansion text are required. When the snippet is +expanded in the text and 'expandtab' is set, each tab will be replaced with +spaces based on 'softtabstop' if nonzero or 'shiftwidth' otherwise. + + +SnipMate currently provides two versions for the snippet parser. The +differences between them can be found at |SnipMate-parser-versions|. Which +version parser the snippets in a file should be used with can be specified +with a version line, e.g.: > + + version 1 + +Specification of a version applies to the snippets following it. Multiple +version specifications can appear in a single file to intermix version 0 and +version 1 snippets. The default is determined by the +g:snipMate.snippet_version option. |SnipMate-options| + +Comments can be made in .snippets files by starting a line with a # character. +However these can't be used inside of snippet definitions: > + + # this is a correct comment + snippet trigger + expanded text + snippet another_trigger + # this isn't a comment! + expanded text + +This should hopefully be clear with the included syntax highlighting. + + *SnipMate-extends* +Borrowing from UltiSnips, .snippets files can also contain an extends +directive, for example: > + + extends html, javascript, css + +will tell SnipMate to also read html, javascript, and css snippets. + +SNIPPET SYNTAX *snippet-syntax* *SnipMate-syntax* + +As mentioned above, there are two versions of the snippet parser. They are +selected by the g:snipMate.snippet_version option (|SnipMate-options|) or the +version directive in .snippets files. Differences will be mentioned throughout +with a summary at |SnipMate-parser-versions|. + +Anywhere in a snippet, a backslash escapes the character following it, +regardless of whether that character is special or not. That is, '\a' will +always result in an 'a' in the output. A single backslash can be output by +using '\\'. + + *SnipMate-tabstops* +Tab stops~ + +When triggering a snippet, SnipMate will by default jump to the very end of +the snippet text. This can be changed through the use of tab stops: $1, $2, +and so on. After expansion, SnipMate will jump to the first tab stop. From +then on, the snipMateNextOrTrigger map will jump to the next higher +numbered tabs top. + +In the case of an ambiguity, for example if a stop occurs just before +a literal number, braces may be placed around the stop number to resolve it: +${3}79 is the third tab stop followed by the string "79". + +NOTE: In the version 0 snippet parser, the braces are mandatory. + + *SnipMate-zero-tabstop* +SnipMate will always stop at the special zero tab stop $0. Once it jumps to +the zero tab stop, snippet expansion is finished. If the zero tab stop is not +present in a definition, it will be put at the end. + +For example, to place the cursor first on the id of a
tag, then on its +class, and finally end editing its contents: > + + snippet div +
+ $0 +
+ +< *SnipMate-placeholders* +In addition to being simply a location, each tab stop contains a placeholder, +or some default text. The placeholder can be specified for every tab stop +(including the zero tab stop) with a colon after the stop ID, as in +${1:default text}. The braces are required only when specifying a placeholder. +Once a tab stop with a placeholder is reached, the placeholder will be +selected in |Select-mode|. For example, > + + snippet div +
+ $0 +
+ +Finally, placeholders can contain mirrors and evaluations (detailed below) and +even entire other tab stops. If the placeholder is edited, then these nested +tab stops are removed and skipped entirely. For example, > + + snippet div + + $0 +
+ +When expanded, this snippet selects the entirety of the id attribute. If this +stop is edited, then the second tab stop is removed and the third tab stop +becomes the next one. If the first tab stop is left unedited, then SnipMate +jumps to the second tab stop. This allows the user to use a single div snippet +that can be used for instances where the id or class attributes are desired +and those where they are not. + + *SnipMate-mirrors* +Mirrors~ + +A mirror is simply a copy of a tab stop's text, updated as the tab stop is +edited. These look like a tab stop without a placeholder; $1 for example. In +the event that no placeholder is specified for a certain tab stop--say $1--the +first instance becomes the tab stop and the rest become mirrors. + +Additionally, in version 1 of the parser, substitutions similar to +|:substitute| can be performed. For instance ${1/foo/bar/g} will replace all +instances of "foo" in the $1 mirror with "bar". This uses |substitute()| +behind the scenes. + +Note: Just like with tab stops, braces can be used to avoid ambiguities: ${1}2 +is a mirror of the first tab stop followed by a 2. Version 0 of the snippet +parser offers no way to resolve such ambiguities. Version 0 also requires that +a tabstop have a placeholder before its mirrors work. + +As an example, > + + snippet for + for ($1 = ${2:start}; ${1:i} < ${3:end}; $1${4:++}) { + ${0:/* code */} + } + +< *SnipMate-eval* +Expression Evaluation~ + +Snippets can contain Vim script expressions that are evaluated as the snippet +is expanded. Expressions are specified inside backticks: > + + snippet date + `strftime("%Y-%m-%d")` + +If the expression results in any Vim error, the error will be displayed (or +found in :messages) and the result of the expression will be the empty string. + +Filename([{expr}] [, {defaultText}]) *SnipMate-Filename()* + +Since the current filename is used often in snippets, a default function +has been defined for it in SnipMate.vim, appropriately called Filename(). + +With no arguments, the default filename without an extension is returned; +the first argument specifies what to place before or after the filename, +and the second argument supplies the default text to be used if the file +has not been named. "$1" in the first argument is replaced with the filename; +if you only want the filename to be returned, the first argument can be left +blank. Examples: > + + snippet filename + `Filename()` + snippet filename_with_default + `Filename('', 'name')` + snippet filename_foo + `Filename('$1_foo')` + +The first example returns the filename if it the file has been named, and an +empty string if it hasn't. The second returns the filename if it's been named, +and "name" if it hasn't. The third returns the filename followed by "_foo" if +it has been named, and an empty string if it hasn't. + + *SnipMate-visual* +The VISUAL Stop~ + +While tab stops have numeric IDs, a special one exists with the ID 'VISUAL'. +When a snippet is expanded, if any text had been grabbed with the +snipMateVisual mapping (see |SnipMate-mappings|), all instances of the VISUAL +stop will be replaced with it. Both transformations as well as a default +placeholder can be used with the VISUAL stop. + +Note: Both $VISUAL and ${VISUAL} are valid in version 1 of the snippet parser. +In version 0, only {VISUAL} is valid (without the $), and neither +transformations nor a default placeholder can be used. + +Example: > + + snippet div +
+ ${0:${VISUAL:}} +
+< + *SnipMate-parser-versions* +Parser Versions~ + +SnipMate provides two versions for its snippet parser. Version 0 is the legacy +regex based version and is updated sparingly. Version 1 is the revamped +version with new features. Any newly developed features will likely only be +available to version 1 users. + +Which version is used is determined by version directives in snippet files +(|SnipMate-snippet-files|) and by the g:snipMate.snippet_version option +(|SnipMate-options|). + +A complete list of current differences is as follows: +- Backslash escaping is guaranteed to work in version 1. In certain edge cases + this may not work in version 0. +- Certain syntactic errors, such as a missing closing brace for a tabstop, are + more gracefully handled in version 1. In most cases, the parser will either + discard the error or, as in the previous example, end an item at the end of + line. Version 0 may not be predictable in this regard. +- Braces are not mandatory in version 1. SnipMate will determine which + instance of a stop ID to use based on the presence of a placeholder, or + whichever instance occurs first. Braces can therefore be used to + disambiguate between stop 12, $12, and stop 1 followed by a 2, ${1}2. In + other words, version 0 makes a distinction between a mirror and a stop while + version 1 resolves the differences for you. +- Placeholders are not mandatory to enable mirror support in version 1. +- Version 0 uses the confusing syntax {VISUAL} to refer to visual content. + Version 1 treats it as just another stop ID, so both $VISUAL and ${VISUAL} + work. Plus version 1 allows a default value in case no visual selection has + been made. +- Transformations similar to |:substitute| can be preformed on any mirror, + including visual content. + +============================================================================== +SNIPPET SOURCES *SnipMate-snippet-sources* + +SnipMate is configurable. + +plugin/SnipMate.vim assigns a couple important keys: > + + " default implementation collecting snippets by handlers + let g:SnipMate['get_snippets'] = SnipMate#GetSnippets + " default handler: + let g:SnipMateSources['default'] = SnipMate#DefaultPool + +You can override both of those settings. + +You can see that the default set of snippets is determined by Vim's 'rtp'. + +Example 1:~ +autoload/SnipMate_python_demo.vim shows how you can register additional +sources such as creating snippets on the fly representing python function +definitions found in the current file. + +Example 2:~ +Add to your ~/.vimrc: For each know snippet add a second version ending in _ +adding folding markers > + + let g:commentChar = { + \ 'vim': '"', + \ 'c': '//', + \ 'cpp': '//', + \ 'sh': '#', + \ 'python': '#' + \ } + " url https://github.com/garbas/vim-snipmate/issues/49 + fun! AddFolding(text) + return substitute(a:text,'\n'," ".g:commentChar[&ft]." {{{\n",1)."\n".g:commentChar[&ft]." }}}" + endf + + fun! SnippetsWithFolding(scopes, trigger, result) + " hacky: temporarely remove this function to prevent infinite recursion: + call remove(g:SnipMateSources, 'with_folding') + " get list of snippets: + let result = SnipMate#GetSnippets(a:scopes, substitute(a:trigger,'_\(\*\)\?$','\1','')) + let g:SnipMateSources['with_folding'] = funcref#Function('SnippetsWithFolding') + + " add folding: + for k in keys(result) + let a:result[k.'_'] = map(result[k],'AddFolding(v:val)') + endfor + endf + + " force setting default: + runtime plugin/SnipMate.vim + " add our own source + let g:SnipMateSources['with_folding'] = funcref#Function('SnippetsWithFolding') + +See |SnipMate-syntax| for more details about all possible relative locations +to 'rtp' can be found in. + +============================================================================== +KNOWN ISSUES *SnipMate-known-issues* + +SnipMate.vim currently has the following disadvantages to TextMate's snippets: + - Placeholders cannot span multiple lines. + - Activating snippets in different scopes of the same file is + not possible. + - Vim formatting with fo=t or fo=a can mess up SnipMate. + +Perhaps some of these features will be added in a later release. + +============================================================================== +CHANGELOG *SnipMate-changelog* + +0.89 - 2016-05-29 +----------------- + +* Various regex updates to legacy parser Addition of double bang syntax to +* completely remove a snippet from lookup Group various SnipMate autocommands +* Support setting 'shiftwidth' to 0 Parser now operates linewise, adding some +* flexibility Mirror substitutions are more literal Mirror length is +* calculated correctly when substitutions occur + +0.88 - 2015-04-04 +----------------- + +* Implement simple caching +* Remove expansion guards +* Add `:SnipMateLoadScope` command and buffer-local scope aliases +* Load `_*.snippets` files +* Use CursorMoved autocmd events entirely + +* The nested branch has been merged + * A new snippet parser has been added. The g:snipmate.version as well as + version lines in snippet files determines which is used + * The new parser supports tab stops placed within placeholders, + substitutions, non-consecutive stop numbers, and fewer ambiguities + * The stop jumping code has been updated + * Tests have been added for the jumping code and the new parser + +* The override branch has been merged + * The g:snipMate.override option is added. When enabled, if two snippets + share the same name, the later-loaded one is kept and the other discarded + * Override behavior can be enabled on a per-snippet basis with a bang (!) in + the snippet file + * Otherwise, SnipMate tries to preserve all snippets loaded + +* Fix bug with mirrors in the first column +* Fix bug with tabs in indents + +* Fix bug with mirrors in placeholders +* Fix reading single snippet files +* Fix the use of the visual map at the end of a line +* Fix expansion of stops containing only the zero tab stop +* Remove select mode mappings +* Indent visual placeholder expansions and remove extraneous lines + + + +0.87 - 2014-01-04 +----------------- + +* Stop indenting empty lines when expanding snippets +* Support extends keyword in .snippets files +* Fix visual placeholder support +* Add zero tabstop support +* Support negative 'softtabstop' +* Add g:snipMate_no_default_aliases option +* Add snipMateTrigger for triggering an expansion inside a snippet +* Add snipMate#CanBeTriggered() function + +0.86 - 2013-06-15 +----------------- +* Use more idiomatic maps +* Remove most select mode mappings + +* Fix disappearing variables bug (hpesoj) +* Fix cursor position bug when a variable is on the same line as the stop +* Fix undo point creation causing problems with Supertab +* Fix bug where SnipMate would use a typed trigger as a regular expression + +0.85 - 2013-04-03 +----------------- + +* Allow trigger key customization +* Enable undoing of snippet expansion +* Support backslash escaping in snippets +* Add support for {VISUAL} +* Expand filetype extension with scope_aliases +* Add expansion guards +* Enable per-buffer expansion of snippets +* Fix 'cpo' compatibility +* Update supertab compatibility +* Enable customization of various things through g:SnipMate + +* Disable spelling in snippet files +* Highlight trigger names in .snippets files + +* Update many snippets +* Separate sample snippets into separate repository + +0.84 +---- + +* Unreleased version by Michael Sanders, available on his GitHub, + + +0.83 - 2009-07-13 +----------------- + +* Last release done by Michael Sanders, available at + + +============================================================================== +CONTACT *SnipMate-contact* *SnipMate-author* + +SnipMate is currently maintained by: + - Rok Garbas + - Marc Weber (marco-oweber@gmx.de) + - Adnan Zafar + +For bug reports, issues, or questions, check out the Issues page on GitHub: +https://github.com/garbas/vim-snipmate/issues + +The original author, Michael Sanders, can be reached at: +msanders42+snipmate gmail com + + +============================================================================== +LICENSE *SnipMate-license* + +SnipMate is released under the MIT license: + +Copyright 2009-2010 Michael Sanders. All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +The software is provided "as is", without warranty of any kind, express or +implied, including but not limited to the warranties of merchantability, +fitness for a particular purpose and noninfringement. In no event shall the +authors or copyright holders be liable for any claim, damages or other +liability, whether in an action of contract, tort or otherwise, arising from, +out of or in connection with the software or the use or other dealings in the +software. + +============================================================================== + vim:tw=78:ts=8:ft=help:norl: diff --git a/skel/.config/nvim/plugged/vim-snipmate/ftplugin/html_snip_helper.vim b/skel/.config/nvim/plugged/vim-snipmate/ftplugin/html_snip_helper.vim new file mode 100644 index 0000000..4d52392 --- /dev/null +++ b/skel/.config/nvim/plugged/vim-snipmate/ftplugin/html_snip_helper.vim @@ -0,0 +1,10 @@ +" Helper function for (x)html snippets +if exists('s:did_snip_helper') || &cp || !exists('loaded_snips') + finish +endif +let s:did_snip_helper = 1 + +" Automatically closes tag if in xhtml +fun! Close() abort + return stridx(&ft, 'xhtml') == -1 ? '' : ' /' +endf diff --git a/skel/.config/nvim/plugged/vim-snipmate/ftplugin/snippets.vim b/skel/.config/nvim/plugged/vim-snipmate/ftplugin/snippets.vim new file mode 100644 index 0000000..dde00e4 --- /dev/null +++ b/skel/.config/nvim/plugged/vim-snipmate/ftplugin/snippets.vim @@ -0,0 +1,20 @@ +" Vim filetype plugin for SnipMate snippets (.snippets and .snippet files) + +if exists("b:did_ftplugin") + finish +endif +let b:did_ftplugin = 1 + +let b:undo_ftplugin = "setl et< sts< cms< fdm< fde<" + +" Use hard tabs +setlocal noexpandtab softtabstop=0 + +setlocal foldmethod=expr foldexpr=getline(v:lnum)!~'^\\t\\\\|^$'?'>1':1 + +setlocal commentstring=#\ %s +setlocal nospell + +command! -buffer -range=% RetabSnip + \ echom "This command is deprecated. Use :retab and = instead. Doing that now." + \ | ,retab! | ,normal = diff --git a/skel/.config/nvim/plugged/vim-snipmate/indent/snippets.vim b/skel/.config/nvim/plugged/vim-snipmate/indent/snippets.vim new file mode 100644 index 0000000..0d28f32 --- /dev/null +++ b/skel/.config/nvim/plugged/vim-snipmate/indent/snippets.vim @@ -0,0 +1,32 @@ +" Simple indent support for SnipMate snippets files + +if exists('b:did_indent') + finish +endif +let b:did_indent = 1 + +setlocal nosmartindent +setlocal indentkeys=!^F,o,O,=snippet,=version,=extends +setlocal indentexpr=GetSnippetIndent() + +if exists("*GetSnippetIndent") + finish +endif + +function! GetSnippetIndent() + let line = getline(v:lnum) + let prev_lnum = v:lnum - 1 + let prev_line = prev_lnum != 0 ? getline(prev_lnum) : "" + + if line =~# '\v^(snippet|extends|version) ' + return 0 + elseif indent(v:lnum) > 0 + return indent(v:lnum) + elseif prev_line =~# '^snippet ' + return &sw + elseif indent(prev_lnum) > 0 + return indent(prev_lnum) + endif + + return 0 +endfunction diff --git a/skel/.config/nvim/plugged/vim-snipmate/plugin/snipMate.vim b/skel/.config/nvim/plugged/vim-snipmate/plugin/snipMate.vim new file mode 100644 index 0000000..75e74aa --- /dev/null +++ b/skel/.config/nvim/plugged/vim-snipmate/plugin/snipMate.vim @@ -0,0 +1,136 @@ +" File: snipMate.vim +" Description: snipMate.vim implements some of TextMate's snippets features in +" Vim. A snippet is a piece of often-typed text that you can +" insert into your document using a trigger word followed by a "". +" +" For more help see snipMate.txt; you can do this by using: +" :helptags ~/.vim/doc +" :h SnipMate + +if exists('loaded_snips') || &cp || version < 700 + finish +endif +let loaded_snips = 1 + +" Save and reset 'cpo' +let s:save_cpo = &cpo +set cpo&vim + +try + call funcref#Function('') +catch /.*/ + echoe "you're missing vim-addon-mw-utils. See install instructions at ".expand(':h:h').'/README.md' +endtry + +if (!exists('g:snipMateSources')) + let g:snipMateSources = {} + " Default source: get snippets based on runtimepath + let g:snipMateSources['default'] = funcref#Function('snipMate#DefaultPool') +endif + +augroup SnipMateDetect + au BufRead,BufNewFile *.snippet,*.snippets setlocal filetype=snippets + au FileType snippets if expand(':e') =~# 'snippet$' + \ | setlocal syntax=snippet + \ | else + \ | setlocal syntax=snippets + \ | endif +augroup END + +inoremap snipMateNextOrTrigger =snipMate#TriggerSnippet() +snoremap snipMateNextOrTrigger a=snipMate#TriggerSnippet() +inoremap snipMateTrigger =snipMate#TriggerSnippet(1) +inoremap snipMateBack =snipMate#BackwardsSnippet() +snoremap snipMateBack a=snipMate#BackwardsSnippet() +inoremap snipMateShow =snipMate#ShowAvailableSnips() +xnoremap snipMateVisual :call grab_visual()gv"_c + +" config variables +if !exists('g:snips_author') + let g:snips_author = 'Me' +endif +if !exists('g:snipMate') + let g:snipMate = {} +endif + +" SnipMate inserts this string when no snippet expansion can be done +let g:snipMate['no_match_completion_feedkeys_chars'] = + \ get(g:snipMate, 'no_match_completion_feedkeys_chars', "\t") + +" Add default scope aliases, without overriding user settings +let g:snipMate.scope_aliases = get(g:snipMate, 'scope_aliases', {}) +if exists('g:snipMate_no_default_aliases') + echom 'The g:snipMate_no_default_aliases option has been renamed.' + \ 'See :h snipMate-options.' +endif +if (!exists('g:snipMate_no_default_aliases') || !g:snipMate_no_default_aliases) + \ && (!exists('g:snipMate.no_default_aliases') + \ || !g:snipMate.no_default_aliases) + let g:snipMate.scope_aliases.objc = + \ get(g:snipMate.scope_aliases, 'objc', 'c') + let g:snipMate.scope_aliases.cpp = + \ get(g:snipMate.scope_aliases, 'cpp', 'c') + let g:snipMate.scope_aliases.cu = + \ get(g:snipMate.scope_aliases, 'cu', 'c') + let g:snipMate.scope_aliases.xhtml = + \ get(g:snipMate.scope_aliases, 'xhtml', 'html') + let g:snipMate.scope_aliases.html = + \ get(g:snipMate.scope_aliases, 'html', 'javascript') + let g:snipMate.scope_aliases.php = + \ get(g:snipMate.scope_aliases, 'php', 'php,html,javascript') + let g:snipMate.scope_aliases.ur = + \ get(g:snipMate.scope_aliases, 'ur', 'html,javascript') + let g:snipMate.scope_aliases.mxml = + \ get(g:snipMate.scope_aliases, 'mxml', 'actionscript') + let g:snipMate.scope_aliases.eruby = + \ get(g:snipMate.scope_aliases, 'eruby', 'eruby-rails,html') + let g:snipMate.scope_aliases.scss = + \ get(g:snipMate.scope_aliases, 'scss', 'css') + let g:snipMate.scope_aliases.less = + \ get(g:snipMate.scope_aliases, 'less', 'css') +endif + +let g:snipMate['get_snippets'] = get(g:snipMate, 'get_snippets', funcref#Function("snipMate#GetSnippets")) + +" List of paths where snippets/ dirs are located +if exists('g:snipMate.snippet_dirs') && type(g:snipMate['snippet_dirs']) != type([]) + echohl WarningMsg + echom "g:snipMate['snippet_dirs'] must be a List" + echohl None +endif + +" _ is default scope added always +" +" &ft honors multiple filetypes and syntax such as in set ft=html.javascript syntax=FOO +let g:snipMate['get_scopes'] = get(g:snipMate, 'get_scopes', funcref#Function('return split(&ft,"\\.")+[&syntax, "_"]')) + +" Modified from Luc Hermitte's function on StackOverflow +" +function! s:grab_visual() abort + let a_save = @a + try + normal! gv"ay + let b:snipmate_visual = @a + finally + let @a = a_save + endtry +endfunction + +" TODO: Allow specifying an arbitrary snippets file +function! s:load_scopes(bang, ...) abort + let gb = a:bang ? g: : b: + let gb.snipMate = get(gb, 'snipMate', {}) + let gb.snipMate.scope_aliases = get(gb.snipMate, 'scope_aliases', {}) + let gb.snipMate.scope_aliases['_'] = join(split(get(gb.snipMate.scope_aliases, '_', ''), ',') + a:000, ',') +endfunction + +command! -bang -bar -nargs=+ SnipMateLoadScope + \ call s:load_scopes(0, ) + +" Edit snippet files +command! SnipMateOpenSnippetFiles call snipMate#OpenSnippetFiles() + +" restore 'cpo' +let &cpo = s:save_cpo + +" vim:noet:sw=4:ts=4:ft=vim diff --git a/skel/.config/nvim/plugged/vim-snipmate/syntax/snippet.vim b/skel/.config/nvim/plugged/vim-snipmate/syntax/snippet.vim new file mode 100644 index 0000000..a947356 --- /dev/null +++ b/skel/.config/nvim/plugged/vim-snipmate/syntax/snippet.vim @@ -0,0 +1,11 @@ +" Syntax highlighting for .snippet files (used for snipMate.vim) +" Hopefully this should make snippets a bit nicer to write! +syn match placeHolder '\${\d\+\(:.\{-}\)\=}' contains=snipCommand +syn match tabStop '\$\d\+' +syn match snipEscape '\\\\\|\\`' +syn match snipCommand '\%(\\\@ autocmds + 0verbose au snipmate_changes * + redir END + return split(autocmds, "\n") + endfunction + aug snipmate_changes + au CursorMoved,CursorMovedI echo 'event' + aug END + + Expect len(ReadAutocmds()) > 1 + call b:snip_state.remove() + Expect len(ReadAutocmds()) == 1 + end + + end + + describe '.find_next_stop()' + + it 'increments/decrements the stop_no' + let b:snip_state.stops = { 1 : {}, 2 : {} } + let b:snip_state.stop_no = 1 + let b:snip_state.stop_count = 4 + + call b:snip_state.find_next_stop(0) + Expect b:snip_state.stop_no == 2 + call b:snip_state.find_next_stop(1) + Expect b:snip_state.stop_no == 1 + end + + it 'continues iterating if the next/previous stop does not exist' + let b:snip_state.stops = { 3 : {} } + let b:snip_state.stop_count = 6 + let b:snip_state.stop_no = 1 + call b:snip_state.find_next_stop(0) + Expect b:snip_state.stop_no == 3 + let b:snip_state.stop_no = 5 + call b:snip_state.find_next_stop(1) + Expect b:snip_state.stop_no == 3 + end + + it 'does something at the ends' + " + end + + end + + describe '.remove_nested()' + + it 'removes nested mirrors and only nested mirrors' + let mirror = { 'line' : 0 } + let b:snip_state.stops = { 1 : { 'placeholder' : [[2, mirror]] }, + \ 2 : { 'mirrors' : [mirror, {}] } } + + call b:snip_state.remove_nested(1) + Expect len(b:snip_state.stops[2].mirrors) == 1 + Expect b:snip_state.stops[2].mirrors[0] isnot mirror + end + + it 'removes nested stops' + let stop = [2, 'abc'] + let b:snip_state.stops = { 1 : { 'placeholder' : [stop] }, + \ 2 : { 'placeholder' : stop[1:1] } } + + call b:snip_state.remove_nested(1) + Expect len(b:snip_state.stops) == 1 + Expect keys(b:snip_state.stops) == ['1'] + end + + end + + describe '.find_update_objects()' + + it 'finds mirrors/stops on the same line and after cur_stop' + let b:snip_state.stops = { + \ 1 : { 'line' : 1, 'col' : 5, + \ 'placeholder' : ['x'] }, + \ 2 : { 'line' : 1, 'col' : 7, + \ 'mirrors' : [{ 'line' : 1, 'col' : 7 }] } + \ } + let stop = b:snip_state.stops[1] + + call b:snip_state.find_update_objects(stop) + for obj in stop.update_objects + Expect obj to_be_in [ b:snip_state.stops[2], + \ b:snip_state.stops[2].mirrors[0] ] + endfor + end + + it 'finds mirrors/stops on the same line and after cur_stop mirrors' + let b:snip_state.stops = { + \ 1 : { 'line' : 1, 'col' : 5, + \ 'mirrors' : [{ 'line' : 2, 'col' : 5 }], + \ 'placeholder' : ['x'] }, + \ 2 : { 'line' : 2, 'col' : 7, + \ 'mirrors' : [{ 'line' : 2, 'col' : 7 }] } + \ } + let stop = b:snip_state.stops[1] + + call b:snip_state.find_update_objects(stop) + for obj in stop.update_objects + Expect obj to_be_in [ b:snip_state.stops[2], + \ b:snip_state.stops[2].mirrors[0] ] + endfor + end + + it 'ignores mirrors/stops on other lines' + let b:snip_state.stops = { + \ 1 : { 'line' : 2, 'col' : 5, + \ 'placeholder' : ['x'] }, + \ 2 : { 'line' : 1, 'col' : 7, + \ 'mirrors' : [{ 'line' : 1, 'col' : 7 }] }, + \ 3 : { 'line' : 3, 'col' : 7, + \ 'mirrors' : [{ 'line' : 3, 'col' : 7 }] } + \ } + let stop = b:snip_state.stops[1] + + call b:snip_state.find_update_objects(stop) + Expect empty(stop.update_objects) to_be_true + end + + it 'ignores mirrors/stops on the same line but before cur_stop/mirrors' + let b:snip_state.stops = { + \ 1 : { 'line' : 1, 'col' : 5, + \ 'mirrors' : [{ 'line' : 2, 'col' : 5 }], + \ 'placeholder' : ['x'] }, + \ 2 : { 'line' : 1, 'col' : 1, + \ 'mirrors' : [{ 'line' : 2, 'col' : 1 }] }, + \ 3 : { 'line' : 2, 'col' : 3, + \ 'mirrors' : [{ 'line' : 1, 'col' : 3 }] }, + \ } + let stop = b:snip_state.stops[1] + + call b:snip_state.find_update_objects(stop) + Expect empty(stop.update_objects) to_be_true + end + + end + +end diff --git a/skel/.config/nvim/plugged/vim-snipmate/t/parser.vim b/skel/.config/nvim/plugged/vim-snipmate/t/parser.vim new file mode 100644 index 0000000..3c2aa6e --- /dev/null +++ b/skel/.config/nvim/plugged/vim-snipmate/t/parser.vim @@ -0,0 +1,152 @@ +describe 'snippet parser' + + before + function! Parse(snippet, ...) + let [snip, stops] = snipmate#parse#snippet(a:snippet, (a:0 ? a:1 : 1)) + return (a:0 > 1 && a:2) ? [snip, stops] : snip + endfunction + let b:snipmate_visual = 'testvisual' + end + + it 'parses numeric $id and ${id} vars as [id] lists' + let expect = [[[1234567890]]] + Expect Parse('$1234567890') == expect + Expect Parse('${1234567890}') == expect + end + + it 'disregards $ or ${ followed by a non-id' + Expect Parse('$x1') == [['x1']] + Expect Parse('${x}1') == [['x}1']] + Expect Parse('$VISUA1') == [['VISUA1']] + Expect Parse('${VISUA}1') == [['VISUA}1']] + end + + it 'gathers references to each instance of each stop id' + let [snip, b:stops] = Parse('x$1x${2:x$1x}x$1x${1/a/b}x$VISUALx', 1, 1) + function! InstanceFound(list) + return !empty(filter(copy(b:stops[a:list[0]].instances), + \ 'v:val is a:list')) + endfunction + function! CheckList(list) + for item in a:list + if type(item) == type([]) + Expect InstanceFound(item) to_be_true + call CheckList(item) + endif + unlet item " E732 + endfor + endfunction + call CheckList(snip[0]) + end + + it 'parses mirror substitutions ${n/pat/sub} as [n, {...}]' + let expect = [[[1, { 'pat' : 'abc', 'sub' : 'def' }]]] + Expect Parse('${1/abc/def}') == expect + let expect[0][0][1].flags = '' + Expect Parse('${1/abc/def/}') == expect + let expect[0][0][1].flags = 'g' + Expect Parse('${1/abc/def/g}') == expect + end + + it 'reads patterns literally except for "\/"' + Expect Parse('${1/\a\/b/\c\/d\}}') == [[[1, { 'pat' : '\a/b', 'sub' : '\c/d}' }]]] + end + + it 'parses vars with placeholders as [id, placeholder] lists' + Expect Parse('${1:abc}') == [[[1, 'abc']]] + end + + it 'evaluates backtick expressions' + Expect Parse('`fnamemodify("x.y", ":r")`') == [['x']] + end + + it 'parses placeholders for vars and other specials' + let text = 'a `fnamemodify("x.y", ":r")` ${2:(${3/a/b})}' + let expect = ['a x ', [2, '(', [3, { 'pat' : 'a', 'sub' : 'b' }], ')']] + Expect Parse(text) == [expect] + Expect Parse(printf('${1:%s}', text)) == [[[1] + expect]] + end + + it 'converts tabs according to &et, &sts, &sw, &ts' + " &noet -> leave tabs alone + setl noet + Expect Parse("abc\tdef\n\t\tghi") == [["abc\tdef"], ["\t\tghi"]] + + " &et -> &sts or &sw + setl et sts=2 sw=3 + Expect Parse("abc\tdef\n\t\tghi") == [["abc def"], [" ghi"]] + + setl et sts=0 sw=3 + Expect Parse("abc\tdef\n\t\tghi") == [["abc def"], [" ghi"]] + + setl et sts=-1 sw=3 + Expect Parse("abc\tdef\n\t\tghi") == [["abc def"], [" ghi"]] + + " See #227 + if exists('*shiftwidth') + setl et sts=0 sw=0 ts=3 + Expect Parse("abc\tdef\n\t\tghi") == [["abc def"], [" ghi"]] + endif + end + + it 'parses backslashes as escaping the next character or joining lines' + Expect Parse('x\x') == [['xx']] + Expect Parse('x\\x') == [['x\x']] + Expect Parse("x\\\nx") == [['xx']] + Expect Parse('x\$1') == [['x$1']] + Expect Parse('${1:\}}') == [[[1, '}']]] + Expect Parse('`fnamemodify("\`.x", ":r")`') == [['`']] + Expect Parse('\`x\`') == [['`x`']] + end + + it 'splits text at newlines' + Expect Parse("x\nx") == [['x'], ['x']] + end + + it 'joins evaluated expressions to surrounding text on the same line' + let g:foo = 'bar' + Expect Parse("x`g:foo`x") == [['xbarx']] + Expect Parse("x`g:foo`\nx") == [['xbar'], ['x']] + Expect Parse("x\n`g:foo`x") == [['x'], ['barx']] + end + + it 'expands $VISUAL placeholders with any indents' + Expect Parse("x$VISUALx") == [['xtestvisualx']] + let b:snipmate_visual = " foo\nbar\n baz" + setl noet + Expect Parse("\tx\n\t$VISUAL\nx") == [["\tx"], ["\t foo"], ["\tbar"], + \ ["\t baz"], ["x"]] + end + + it 'removes newlines from the end of VISUALs if before an end of line' + let b:snipmate_visual = "1\n2\n" + Expect Parse("x\n$VISUAL\nx") == [['x'], ['1'], ['2'], ['x']] + end + + it 'splits the before and after a $VISUAL if it is multiline' + let b:snipmate_visual = "1\n2\n3" + Expect Parse("foo $VISUAL bar") == [['foo 1'], ['2'], ['3 bar']] + end + + it 'determines which var with an id is the stop' + let [snip, stops] = Parse("$1$1$1", 0, 1) + Expect snip == [[[1, "", stops[1]], [1, {}], [1, {}]]] + + let [snip, stops] = Parse("$1${1}$1", 0, 1) + Expect snip == [[[1, "", stops[1]], [1, {}], [1, {}]]] + + let [snip, stops] = Parse("$1${1:}$1", 0, 1) + Expect snip == [[[1, {}], [1, "", stops[1]], [1, {}]]] + + end + + it 'picks the first of many possible stops' + let [snip, stops] = Parse("$1${1:foo}${1:bar}", 0, 1) + Expect snip == [[[1, {}], [1, "foo", stops[1]], [1, {}]]] + end + + it 'represents empty lines as an empty string' + Expect Parse("foo\n\nbar") == [['foo'], [''], ['bar']] + end + +end diff --git a/skel/.config/nvim/plugged/vim-snipmate/t/tests.sh b/skel/.config/nvim/plugged/vim-snipmate/t/tests.sh new file mode 100755 index 0000000..c1da250 --- /dev/null +++ b/skel/.config/nvim/plugged/vim-snipmate/t/tests.sh @@ -0,0 +1,20 @@ +#!/bin/sh + +tmp="$(mktemp || tmpfile)" +vim -Es $tmp <<- EOF + source ~/.vimrc + %delete _ + call append(0, split(&rtp, ',')) + delete _ + wq +EOF + +rtp="$(grep -iE 'vspec|snipmate|tlib|mw-utils' < $tmp | grep -v after)" +vspec="$(grep -iE 'vspec' < $tmp | grep -v after)" +test_files="${*:-parser jumping}" + +for test in $test_files; do + $vspec/bin/vspec $rtp ${test%%.vim}.vim +done + +rm $tmp diff --git a/skel/.config/nvim/plugged/vim-snippets/AUTHORS b/skel/.config/nvim/plugged/vim-snippets/AUTHORS new file mode 100644 index 0000000..c5c68c6 --- /dev/null +++ b/skel/.config/nvim/plugged/vim-snippets/AUTHORS @@ -0,0 +1,45 @@ +Aaron Broder +Adam Folmert +Alberto Pose +Angel Alonso +Ben Orenstein +Bill Casarin +Christopher Joslyn +Daniel Hahler +Elliot Murphy +Eustaquio Rangel +Henrik Nyh +Honza Pokorny +Iuri Fernandes Queiroz +Jakub Nawalaniec +James F. Herdman +Jon Bernard +Kozo NISHIDA +Leandro Pincini +Marc Weber +Marcin Kulik +Marjan.Hratson +Micah Elliott +Michael Sanders +Naveed Massjouni +Rob Hudson +Rok Garbas +Sebastian Schulze +Srushti Ambekallu +Stephen Tudor +Steven Oliver +Stuart Colville +Tom Adams +Zied ABID +fo60213 +marutanm +msanders +Povilas Balzaravičius Pawka +Dmitry Dementev +Travis Holton +Chrisyue +Erik Westrup +Matt Deacalion Stevens + +TODO: add contributors from github.com/SirVer/Ultisnip having contributed to +github.com/SirVer/Ultisnip/UltiSnips/* files diff --git a/skel/.config/nvim/plugged/vim-snippets/LICENSE b/skel/.config/nvim/plugged/vim-snippets/LICENSE new file mode 100644 index 0000000..495ced2 --- /dev/null +++ b/skel/.config/nvim/plugged/vim-snippets/LICENSE @@ -0,0 +1,20 @@ +Copyright (c) 2011 see AUTHORS + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + diff --git a/skel/.config/nvim/plugged/vim-snippets/README.md b/skel/.config/nvim/plugged/vim-snippets/README.md new file mode 100644 index 0000000..27592c7 --- /dev/null +++ b/skel/.config/nvim/plugged/vim-snippets/README.md @@ -0,0 +1,216 @@ +IMPORTANT: comment on: [What about merging with Ultisnip using its engine](https://github.com/garbas/vim-snipmate/issues/114) + +Snipmate & UltiSnip Snippets +============================ + +This repository contains snippets files for various programming languages. + +It is community-maintained and many people have contributed snippet files and +other improvements already. + +Contents +======== + + snippets/*: snippets using snipmate format + UltiSnips/*: snippets using UltiSnips format + +Snippet engines +=============== + +There are different forks of snippet engines which allow the user to insert +sippets by typing the name of a snippet hitting the expansion mapping. + + garbas/vim-snipmate [4]: + VimL, snipmate-snippets, engine sometimes behaves strange, supports + rewriting snippets on the fly (eg adding a second version with folding + markers) + + MarcWeber/UltiSnips [6]: + python, snipmate-snippets and UltiSnips-snippets + + SirVer/ultisnips [7]: + python, UltiSnips-snippets + + github.com/Shougo/neosnippet [5]: + viml, has a compatible mode allowing to reuse most snipmate snippets ? + + XPTemplate: + totally different syntax, does not read snippets contained in this file, + but it is also very powerful + + ... there are some more, but they have less features which is why I don't + mention them here + +UltiSnips engine has additional features such as "nested snippets". + +Which one to use? If you have python give MarcWeber/UltiSnips a try because its +fast and supports all important features. You can prefer the UltiSnip versions +of the snippets by setting the "always_use_first_snippet" option to 1. + +If you have VimL only (vim without python support) your best option is using +garbas/vim-snipmate and cope with the minor bugs found in the engine. + + +Policies / for contributors +=========================== +Some snippets are useful for almost all languages, so let's try to have the same +triggers for them: + +``` +if : if without else +ife: if $1 else $2 +eif : else if ($1) { .. } +el : else .. +wh : while (cond) ... +``` + +If you're not satisfied with these defaults, open a ticket that we implement +aliasing. Then you can remap "else" to "el" or the like. + + +Don't add stupid placeholder default texts like +``` +if (${1:condition}){ + ${2:some code here} +} +``` +instead use: + +``` +if (${1}){ + ${2} +} +``` + +Exception: Functions which are used less often, such as Vim's matchall(), matchstr() +functions which case hints may be helpful to remember order. In the VimL case +get vim-dev plugin which has function completion + +Thus for conditions (while, if ..) and block bodies just use ${N} - Thanks + +Open questions: +What about one line if ee then .. else .. vs if \n .. then \n ... \n else \n .. ? +Which additional policies to add? +Discuss at: https://github.com/honza/vim-snippets/issues/230 + + +Related repositories +==================== +We also encourage people to maintain sets of snippets for particular use cases +so that all users can benefit from them. People can list their snippet repositories here: + + * https://github.com/rbonvall/snipmate-snippets-bib (snippets for BibTeX files) + * https://github.com/sudar/vim-arduino-snippets (snippets for Arduino files) + * https://github.com/zedr/zope-snipmate-bundle.git (snippets for Python, TAL and ZCML) + * https://github.com/bonsaiben/bootstrap-snippets (snippets for Twitter Bootstrap markup, in HTML and Haml) + +Installation using VAM: "github:rbonvall/snipmate-snippets-bib" + + +Future - ideas - examples +========================= +[overview snippet engines](http://vim-wiki.mawercer.de/wiki/topic/text-snippets-skeletons-templates.html) +If you have ideas you can add them to that list of "snippet engine features by example". + + +Historical notes +================ + +[vim-snipmate][1] was originally started by [Michael Sanders][2] who has now +unfortunately abandoned the project. [Rok Garbas][3] is now maintaining a +[fork][4] of the project in hopes of improving the existing code base. + +Versions / dialects / .. +======================== +There are some issues, such as newer language versions may require other +snippets than older. If this exists we currently recommend doing this: + +add snippets/ruby.snippets (common snippets) +add snippets/ruby-1.8.snippets (1.8 only) +add snippets/ruby-1.9.snippets (1.9 only) + +then configure github.com/garbas/vim-snipmate this way: + + +```vim +let g:snipMate = {} +let g:snipMate.scope_aliases = {} +let g:snipMate.scope_aliases['ruby'] = 'ruby,ruby-rails,ruby-1.9' +``` + +or github.com/MarcWeber/UltiSnips this way: + + +```vim +let g:UltiSnips = {} + +let g:UltiSnips.snipmate_ft_filter = { + \ 'default' : {'filetypes': ["FILETYPE"] }, + \ 'ruby' : {'filetypes': ["ruby", "ruby-rails", "ruby-1.9"] }, +``` + +If it happens that you work on a project requiring ruby-1.8 snippets instead, +consider using vim-addon-local-vimrc and override the filetypes. + +Well - of course it may not make sense to create a new file for each +ruby-library-version triplet. Sometimes postfixing a name such as + + migrate_lib_20_down + migrate_lib_20_up + +will do it then if syntax has changed. + +Language maintainers +-------------------- + +No one can really be proficient in all programming languages. If you would like +to maintain snippets for a language, please get in touch. + +Notes: People are interested in snippets - and their interest may stop again +at will. So its ok if people maintain a language only for a short period of +time - or jump in and get things done - don't let the flow stop :) +vim-snippets is not like the "linux kernel". + +* Python - [honza](http://github.com/honza) +* Javascript - [honza](http://github.com/honza) +* HTML Django - [honza](http://github.com/honza) +* Markdown - [honza](http://github.com/honza) +* Ruby - [taq](http://github.com/taq) +* PHP - [chrisyue](http://github.com/chrisyue) +* Scala - [gorodinskiy](https://github.com/gorodinskiy) +* Falcon - [steveno](https://github.com/steveno) +* Elixir - [iurifq](https://github.com/iurifq) + +Contributing notes +------------------ + +Until further work is done on `vim-snipmate`, please don't add folding markers +into snippets. `vim-snipmate` has some comments about how to patch all snippets +on the fly adding those. + +Because MarcWeber/UltiSnips [6] supports also snipmate-snippets there is no +need to duplicate all snippets - only those snippets who use advanced UltiSnips +features should be duplicated in UltiSnips (?) + +Currently all snippets from UltiSnips have been put into UltiSnips - some work +on merging should be done (dropping duplicates etc) + +Authors +------- + +For a list of authors, please see the `AUTHORS` files. + +License +------- + +Just as the original snipMate plugin, all the snippets are licensed under the +terms of the MIT license. + + +[1]: http://github.com/garbas/vim-snipmate +[2]: http://github.com/msanders +[3]: http://github.com/garbas +[4]: http://github.com/garbas/vim-snipmate +[5]: http://github.com/Shougo/neosnippet +[6]: http://github.com/MarcWeber/UltiSnips +[7]: http://github.com/SirVer/ultisnips diff --git a/skel/.config/nvim/plugged/vim-snippets/UltiSnips/README b/skel/.config/nvim/plugged/vim-snippets/UltiSnips/README new file mode 100644 index 0000000..eafd086 --- /dev/null +++ b/skel/.config/nvim/plugged/vim-snippets/UltiSnips/README @@ -0,0 +1,21 @@ +This directory contains the main scripts that come bundled with UltiSnips. + +Standing On The Shoulders of Giants +=================================== + +The snippets have been collected from various other project which I want to +express my gratitude for. My main source for inspiration where the following +two projects: + + TextMate: http://svn.textmate.org/trunk/Bundles/ + SnipMate: http://code.google.com/p/snipmate/ + +All snippets from those sources were copied and cleaned up, so that they are + - not using shell script, only python (so they are cross platform compatible) + - not using any feature that UltiSnips doesn't offer + +UltiSnips has seen contributions by various individuals. Those contributions +have been merged into this collection seamlessly and without further comments. + +-- vim:ft=rst:nospell: + diff --git a/skel/.config/nvim/plugged/vim-snippets/UltiSnips/all.snippets b/skel/.config/nvim/plugged/vim-snippets/UltiSnips/all.snippets new file mode 100644 index 0000000..8844e28 --- /dev/null +++ b/skel/.config/nvim/plugged/vim-snippets/UltiSnips/all.snippets @@ -0,0 +1,112 @@ +# This file contains snippets that are always defined. I personally +# have snippets for signatures and often needed texts + +############## +# NICE BOXES # +############## +global !p +import string, vim + +""" Maps a filetype to comment format used for boxes. +Automatically filled during usage""" +_commentDict = { } + +def _parse_comments(s): + """ Parses vim's comments option to extract comment format """ + i = iter(s.split(",")) + + rv = [] + try: + while True: + # get the flags and text of a comment part + flags,text = i.next().split(':', 1) + + if len(flags) == 0: + if len(text) == 1: + rv.append((text,text,text, "")) + # parse 3-part comment, but ignore those with O flag + elif flags[0] == 's' and 'O' not in flags: + ctriple = [] + indent = "" + + if flags[-1] in string.digits: + indent = " " * int(flags[-1]) + ctriple.append(text) + + flags,text = i.next().split(':', 1) + assert(flags[0] == 'm') + ctriple.append(text) + + flags,text = i.next().split(':', 1) + assert(flags[0] == 'e') + ctriple.append(text) + ctriple.append(indent) + + rv.append(ctriple) + + elif flags[0] == 'b': + if len(text) == 1: + rv.insert(0, (text,text,text, "")) + + except StopIteration: + return rv + +def _get_comment_format(): + """ Returns a 4-element tuple representing the comment format for + the current file. """ + + ft = vim.eval("&filetype") + # check if the comment dict has the format for the current file + if _commentDict.has_key(ft): + return _commentDict[ft] + + # otherwise parse vim's comments and add it for later use + commentformat = _parse_comments(vim.eval("&comments"))[0] + _commentDict[ft] = commentformat + + return commentformat + + +def make_box(twidth, bwidth = None): + if bwidth is None: + bwidth = twidth + 2 + b,m,e,i = _get_comment_format() + sline = b + m + bwidth*m + 2*m + nspaces = (bwidth - twidth)//2 + mlines = i + m + " " + " "*nspaces + mlinee = " " + " "*(bwidth-twidth-nspaces) + m + eline = i + 2*m + bwidth*m + m + e + return sline, mlines, mlinee, eline +endglobal + +snippet box "A nice box with the current comment symbol" b +`!p +box = make_box(len(t[1])) +snip.rv = box[0] + '\n' + box[1] +`${1:content}`!p +box = make_box(len(t[1])) +snip.rv = box[2] + '\n' + box[3]` +$0 +endsnippet + +snippet bbox "A nice box over the full width" b +`!p +box = make_box(len(t[1]), 71) +snip.rv = box[0] + '\n' + box[1] +`${1:content}`!p +box = make_box(len(t[1]), 71) +snip.rv = box[2] + '\n' + box[3]` +$0 +endsnippet + +########################## +# LOREM IPSUM GENERATORS # +########################## +snippet lorem "Lorem Ipsum - 50 Words" b +Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod +tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At +vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, +no sea takimata sanctus est Lorem ipsum dolor sit amet. +endsnippet + +# vim:ft=snippets: diff --git a/skel/.config/nvim/plugged/vim-snippets/UltiSnips/bindzone.snippets b/skel/.config/nvim/plugged/vim-snippets/UltiSnips/bindzone.snippets new file mode 100644 index 0000000..034ccde --- /dev/null +++ b/skel/.config/nvim/plugged/vim-snippets/UltiSnips/bindzone.snippets @@ -0,0 +1,27 @@ +global !p +def newsoa(): + import datetime + now = datetime.datetime.now() + # return standard SOA formatted serial for today + return now.strftime("%Y%m%d00") +endglobal + +snippet zone "Bootstrap a new Bind zonefile" b +$TTL 86400 +@ IN SOA ${1:example.net}. ${2:hostmaster.$1}.( + `!p snip.rv = newsoa()`; serial + 21600; refresh every 6 hours + 3600; retry after one hour + 604800; expire after a week + 86400 ); minimum TTL of 1 day + + IN NS ns01.$1. + IN MX 10 mail.$1. + +ns01.$1 IN A +mail.$1 IN A +endsnippet + +snippet A "Insert A Record" b +${1:hostname} IN A ${2:ip} +endsnippet diff --git a/skel/.config/nvim/plugged/vim-snippets/UltiSnips/c.snippets b/skel/.config/nvim/plugged/vim-snippets/UltiSnips/c.snippets new file mode 100644 index 0000000..062a36a --- /dev/null +++ b/skel/.config/nvim/plugged/vim-snippets/UltiSnips/c.snippets @@ -0,0 +1,117 @@ +########################################################################### +# TextMate Snippets # +########################################################################### + +snippet def "#define ..." +#define ${1} +endsnippet + +snippet ifndef "#ifndef ... #define ... #endif" +#ifndef ${1/([A-Za-z0-9_]+).*/$1/} +#define ${1:SYMBOL} ${2:value} +#endif +endsnippet + +snippet #if "#if #endif" !b +#if ${1:0} +${VISUAL:code}$0 +#endif +endsnippet + +snippet inc "#include local header (inc)" +#include "${1:`!p snip.rv = snip.basename + '.h'`}" +endsnippet + +snippet Inc "#include <> (Inc)" +#include <${1:.h}> +endsnippet + +snippet mark "#pragma mark (mark)" +#if 0 +${1:#pragma mark - +}#pragma mark $2 +#endif + +$0 +endsnippet + +snippet main "main() (main)" +int main(int argc, char const *argv[]) +{ + ${0:/* code */} + return 0; +} +endsnippet + +snippet for "for int loop (fori)" +for (${4:size_t} ${2:i} = 0; $2 < ${1:count}; ${3:++$2}) +{ + ${0:/* code */} +} +endsnippet + +snippet enum "Enumeration" +enum ${1:name} { $0 }; +endsnippet + +snippet once "Include header once only guard" +#ifndef ${1:`!p +if not snip.c: + import random, string + name = re.sub(r'[^A-Za-z0-9]+','_', snip.fn).upper() + rand = ''.join(random.sample(string.ascii_letters+string.digits, 8)) + snip.rv = ('%s_%s' % (name,rand)).upper() +else: + snip.rv = snip.c`} +#define $1 + +${0} + +#endif /* end of include guard: $1 */ + +endsnippet + +snippet td "Typedef" +typedef ${1:int} ${2:MyCustomType}; +endsnippet + +snippet do "do...while loop (do)" +do { + ${0:/* code */} +} while(${1:/* condition */}); +endsnippet + +snippet fprintf "fprintf ..." +fprintf(${1:stderr}, "${2:%s}\n"${2/([^%]|%%)*(%.)?.*/(?2:, :\);)/}$3${2/([^%]|%%)*(%.)?.*/(?2:\);)/} +endsnippet + +snippet if "if .. (if)" +if (${1:/* condition */}) +{ + ${0:/* code */} +} +endsnippet + +snippet ife "if .. else (ife)" +if (${1:/* condition */}) +{ + ${2:/* code */} +} +else +{ + ${3:/* else */} +} +endsnippet + +snippet printf "printf .. (printf)" +printf("${1:%s}\n"${1/([^%]|%%)*(%.)?.*/(?2:, :\);)/}$2${1/([^%]|%%)*(%.)?.*/(?2:\);)/} +endsnippet + +snippet st "struct" +struct ${1:`!p snip.rv = (snip.basename or "name") + "_t"`} +{ + ${0:/* data */} +}; +endsnippet + +# vim:ft=snippets: diff --git a/skel/.config/nvim/plugged/vim-snippets/UltiSnips/coffee.snippets b/skel/.config/nvim/plugged/vim-snippets/UltiSnips/coffee.snippets new file mode 100644 index 0000000..68d4034 --- /dev/null +++ b/skel/.config/nvim/plugged/vim-snippets/UltiSnips/coffee.snippets @@ -0,0 +1,98 @@ +# From the TextMate bundle +# with some modification + +snippet fun "Function" b +${1:name} = `!p snip.rv = "(" if t[2] else ""`${2:args}`!p snip.rv = ") " if t[2] else ""`-> + ${0:# body...} +endsnippet + +snippet bfun "Function (bound)" i +`!p snip.rv = "(" if t[1] else ""`${1:args}`!p snip.rv = ") " if t[1] else ""`=>`!p snip.rv = " " if t[2] and not t[2].startswith("\n") else ""`${2:expr} +endsnippet + +snippet if "If" +if ${1:condition} + ${0:# body...} +endsnippet + +snippet ife "If .. Else" +if ${1:condition} + ${2:# body...} +else + ${3:# body...} +endsnippet + +snippet eif "Else if" b +else if ${1:condition} + ${0:# body...} +endsnippet + +snippet ifte "Ternary if" +if ${1:condition} then ${2:value} else ${3:other} +endsnippet + +snippet unl "Unless" +${1:action} unless ${2:condition} +endsnippet + +snippet fora "Array Comprehension" +for ${1:name} in ${2:array} + ${0:# body...} +endsnippet + +snippet foro "Object Comprehension" +for ${1:key}, ${2:value} of ${3:Object} + ${0:# body...} +endsnippet + +snippet forr "Range Comprehension (inclusive)" +for ${1:name} in [${2:start}..${3:finish}]`!p snip.rv = " by " if t[4] else ""`${4:step} + ${0:# body...} +endsnippet + +snippet forrex "Range Comprehension (exclusive)" +for ${1:name} in [${2:start}...${3:finish}]`!p snip.rv = " by " if t[4] else ""`${4:step} + ${0:# body...} +endsnippet + +snippet swi "Switch" +switch ${1:object} + when ${2:value} + ${3:# body...} + else + $0 +endsnippet + +snippet swit "Switch when .. then" +switch ${1:object} + when ${2:condition}`!p snip.rv = " then " if t[3] else ""`${3:value} + else`!p snip.rv = " " if t[4] and not t[4].startswith("\n") else ""`${4:value} +endsnippet + +snippet cla "Class" b +class ${1:ClassName}`!p snip.rv = " extends " if t[2] else ""`${2:Ancestor} + + ${3:constructor:`!p snip.rv = " (" if t[4] else ""`${4:args}`!p snip.rv = ")" if t[4] else ""` -> + ${5:# body...}} + $0 +endsnippet + +snippet try "Try .. Catch" +try + $1 +catch ${2:error} + $3 +endsnippet + +snippet req "Require" b +${1/^'?(\w+)'?$/\L$1\E/} = require(${1:'${2:sys}'}) +endsnippet + +snippet # "Interpolated Code" i +#{$1}$0 +endsnippet + +snippet log "Log" b +console.log ${1:"${2:msg}"} +endsnippet + diff --git a/skel/.config/nvim/plugged/vim-snippets/UltiSnips/coffee_jasmine.snippets b/skel/.config/nvim/plugged/vim-snippets/UltiSnips/coffee_jasmine.snippets new file mode 100644 index 0000000..47d1e6b --- /dev/null +++ b/skel/.config/nvim/plugged/vim-snippets/UltiSnips/coffee_jasmine.snippets @@ -0,0 +1,163 @@ +# +# CoffeeScript versions -- adapted from the JS TextMate bundle + additions +# for some jasmine-jquery matchers +# +extends coffee + +snippet des "Describe (coffee)" b +describe '${1:description}', -> + $0 +endsnippet + +snippet it "it (coffee)" b +it '${1:description}', -> + $0 +endsnippet + +snippet bef "before each (coffee)" b +beforeEach -> + $0 +endsnippet + +snippet aft "after each (coffee)" b +afterEach -> + $0 +endsnippet + +snippet any "any (coffee)" b +jasmine.any($1) +endsnippet + +snippet ru "runs (coffee)" b +runs -> + $0 +endsnippet + +snippet wa "waits (coffee)" b +waits($1) +endsnippet + +snippet ex "expect (coffee)" b +expect(${1:target})$0 +endsnippet + +snippet ee "expect to equal (coffee)" b +expect(${1:target}).toEqual(${2:value}) +endsnippet + +snippet em "expect to match (coffee)" b +expect(${1:target}).toMatch(${2:pattern}) +endsnippet + +snippet eha "expect to have attribute (coffee)" b +expect(${1:target}).toHaveAttr('${2:attr}'${3:, '${4:value}'}) +endsnippet + +snippet et "expect to be truthy (coffee)" b +expect(${1:target}).toBeTruthy() +endsnippet + +snippet ef "expect to be falsy (coffee)" b +expect(${1:target}).toBeFalsy() +endsnippet + +snippet ed "expect to be defined (coffee)" b +expect(${1:target}).toBeDefined() +endsnippet + +snippet en "expect to be null (coffee)" b +expect(${1:target}).toBeNull() +endsnippet + +snippet ec "expect to contain (coffee)" b +expect(${1:target}).toContain(${2:value}) +endsnippet + +snippet ev "expect to be visible (coffee)" b +expect(${1:target}).toBeVisible() +endsnippet + +snippet eh "expect to be hidden (coffee)" b +expect(${1:target}).toBeHidden() +endsnippet + +snippet notx "expect not (coffee)" b +expect(${1:target}).not$0 +endsnippet + +snippet note "expect not to equal (coffee)" b +expect(${1:target}).not.toEqual(${2:value}) +endsnippet + +snippet notm "expect not to match (coffee)" b +expect(${1:target}).not.toMatch(${2:pattern}) +endsnippet + +snippet notha "expect to not have attribute (coffee)" b +expect(${1:target}).not.toHaveAttr('${2:attr}'${3:, '${4:value}'}) +endsnippet + +snippet nott "expect not to be truthy (coffee)" b +expect(${1:target}).not.toBeTruthy() +endsnippet + +snippet notf "expect not to be falsy (coffee)" b +expect(${1:target}).not.toBeFalsy() +endsnippet + +snippet notd "expect not to be defined (coffee)" b +expect(${1:target}).not.toBeDefined() +endsnippet + +snippet notn "expect not to be null (coffee)" b +expect(${1:target}).not.toBeNull() +endsnippet + +snippet notc "expect not to contain (coffee)" b +expect(${1:target}).not.toContain(${2:value}) +endsnippet + +snippet notv "expect not to be visible (coffee)" b +expect(${1:target}).not.toBeVisible() +endsnippet + +snippet noth "expect not to be hidden (coffee)" b +expect(${1:target}).not.toBeHidden() +endsnippet + +snippet s "spy on (coffee)" b +spyOn(${1:object}, "${2:method}")$0 +endsnippet + +snippet sr "spy on and return (coffee)" b +spyOn(${1:object}, "${2:method}").andReturn(${3:arguments}) +endsnippet + +snippet st "spy on and throw (coffee)" b +spyOn(${1:object}, "${2:method}").andThrow(${3:exception}) +endsnippet + +snippet sct "spy on and call through (coffee)" b +spyOn(${1:object}, "${2:method}").andCallThrough() +endsnippet + +snippet scf "spy on and call fake (coffee)" b +spyOn(${1:object}, "${2:method}").andCallFake(${3:function}) +endsnippet + +snippet esc "expect was called (coffee)" b +expect(${1:target}).wasCalled() +endsnippet + +snippet escw "expect was called with (coffee)" b +expect(${1:target}).wasCalledWith(${2:arguments}) +endsnippet + +snippet notsc "expect was not called (coffee)" b +expect(${1:target}).wasNotCalled() +endsnippet + +snippet noscw "expect was not called with (coffee)" b +expect(${1:target}).wasNotCalledWith(${2:arguments}) +endsnippet + diff --git a/skel/.config/nvim/plugged/vim-snippets/UltiSnips/cpp.snippets b/skel/.config/nvim/plugged/vim-snippets/UltiSnips/cpp.snippets new file mode 100644 index 0000000..6999c1f --- /dev/null +++ b/skel/.config/nvim/plugged/vim-snippets/UltiSnips/cpp.snippets @@ -0,0 +1,50 @@ +########################################################################### +# TextMate Snippets # +########################################################################### +snippet beginend "$1.begin(), $1.end() (beginend)" +${1:v}${1/^.*?(-)?(>)?$/(?2::(?1:>:.))/}begin(), $1${1/^.*?(-)?(>)?$/(?2::(?1:>:.))/}end() +endsnippet + +snippet cl "class .. (class)" +class ${1:`!p snip.rv = snip.basename or "name"`} +{ +public: + ${1/(\w+).*/$1/} (${2:arguments}); + virtual ~${1/(\w+).*/$1/} (); + +private: + ${0:/* data */} +}; +endsnippet + +snippet ns "namespace .. (namespace)" +namespace${1/.+/ /m}${1:`!p snip.rv = snip.basename or "name"`} +{ + $0 +}${1/.+/ \/* /m}$1${1/.+/ *\/ /m} +endsnippet + +snippet readfile "read file (readF)" +std::vector v; +if (FILE *fp = fopen(${1:"filename"}, "r")) +{ + char buf[1024]; + while(size_t len = fread(buf, 1, sizeof(buf), fp)) + v.insert(v.end(), buf, buf + len); + fclose(fp); +} +endsnippet + +snippet map "std::map (map)" +std::map<${1:key}, ${2:value}> map$0; +endsnippet + +snippet vector "std::vector (v)" +std::vector<${1:char}> v$0; +endsnippet + +snippet tp "template (template)" +template +endsnippet + +# vim:ft=snippets: diff --git a/skel/.config/nvim/plugged/vim-snippets/UltiSnips/css.snippets b/skel/.config/nvim/plugged/vim-snippets/UltiSnips/css.snippets new file mode 100644 index 0000000..d14d51c --- /dev/null +++ b/skel/.config/nvim/plugged/vim-snippets/UltiSnips/css.snippets @@ -0,0 +1,405 @@ +########################################################################### +# Most of these came from TextMate # +########################################################################### + +snippet ! "!important CSS (!)" +${1:!important} +endsnippet + +snippet fixed "Fixed Position Bottom 100% wide IE6" +${2:bottom: auto;}top: expression(eval(document.documentElement.scrollTop+document.documentElement.clientHeight-${1:THE HEIGHT OF THIS THING IN PIXELS})); +${3:left: expression(eval(document.documentElement.scrollLeft)); +}${4:width: expression(eval(document.documentElement.clientWidth));}$0 +endsnippet + +snippet background "background-attachment: scroll:fixed (background)" +background-attachment: ${1:scroll/fixed};$0 +endsnippet + +snippet background "background-color: color-hex (background)" +background-color: #${1:DDD};$0 +endsnippet + +snippet background "background-color: color-name (background)" +background-color: ${1:red};$0 +endsnippet + +snippet background "background-color: color-rgb (background)" +background-color: rgb(${1:255},${2:255},${3:255});$0 +endsnippet + +snippet background "background-color: transparent (background)" +background-color: transparent;$0 +endsnippet + +snippet background "background-image: none (background)" +background-image: none;$0 +endsnippet + +snippet background "background-image: url (background)" +background-image: url($1);$0 +endsnippet + +snippet background "background-position: position (background)" +background-position: ${1:top left/top center/top right/center left/center center/center right/bottom left/bottom center/bottom right/x-% y-%/x-pos y-pos};$0 +endsnippet + +snippet background "background-repeat: r:r-x:r-y:n-r (background)" +background-repeat: ${1:repeat/repeat-x/repeat-y/no-repeat};$0 +endsnippet + +snippet background "background: color image repeat attachment position (background)" +background:${6: #${1:DDD}} url($2) ${3:repeat/repeat-x/repeat-y/no-repeat} ${4:scroll/fixed} ${5:top left/top center/top right/center left/center center/center right/bottom left/bottom center/bottom right/x-% y-%/x-pos y-pos};$0 +endsnippet + +snippet border "border-bottom-color: size style color (border)" +border-bottom-color: #${1:999};$0 +endsnippet + +snippet border "border-bottom-style: size style color (border)" +border-bottom-style: ${1:none/hidden/dotted/dashed/solid/double/groove/ridge/inset/outset};$0 +endsnippet + +snippet border "border-bottom-width: size style color (border)" +border-bottom-width: ${1:1}px ${2:solid} #${3:999};$0 +endsnippet + +snippet border "border-bottom: size style color (border)" +border-bottom: ${1:1}px ${2:solid} #${3:999};$0 +endsnippet + +snippet border "border-color: color (border)" +border-color: ${1:999};$0 +endsnippet + +snippet border "border-left-color: color (border)" +border-right-color: #${1:999};$0 +endsnippet + +snippet border "border-left-style: style (border)" +border-left-style: ${1:none/hidden/dotted/dashed/solid/double/groove/ridge/inset/outset};$0 +endsnippet + +snippet border "border-left-width: size (border)" +border-left-width: ${1:1}px +endsnippet + +snippet border "border-left: size style color (border)" +border-left: ${1:1}px ${2:solid} #${3:999};$0 +endsnippet + +snippet border "border-right-color: color (border)" +border-right-color: #${1:999};$0 +endsnippet + +snippet border "border-right-style: style (border)" +border-right-style: ${1:none/hidden/dotted/dashed/solid/double/groove/ridge/inset/outset};$0 +endsnippet + +snippet border "border-right-width: size (border)" +border-right-width: ${1:1}px +endsnippet + +snippet border "border-right: size style color (border)" +border-right: ${1:1}px ${2:solid} #${3:999};$0 +endsnippet + +snippet border "border-style: style (border)" +border-style: ${1:none/hidden/dotted/dashed/solid/double/groove/ridge/inset/outset};$0 +endsnippet + +snippet border "border-top-color: color (border)" +border-top-color: #${1:999};$0 +endsnippet + +snippet border "border-top-style: style (border)" +border-top-style: ${1:none/hidden/dotted/dashed/solid/double/groove/ridge/inset/outset};$0 +endsnippet + +snippet border "border-top-width: size (border)" +border-top-width: ${1:1}px +endsnippet + +snippet border "border-top: size style color (border)" +border-top: ${1:1}px ${2:solid} #${3:999};$0 +endsnippet + +snippet border "border-width: width (border)" +border-width: ${1:1px};$0 +endsnippet + +snippet border "border: size style color (border)" +border: ${1:1px} ${2:solid} #${3:999};$0 +endsnippet + +snippet clear "clear: value (clear)" +clear: ${1:left/right/both/none};$0 +endsnippet + +snippet color "color: color-hex (color)" +color: #${1:DDD};$0 +endsnippet + +snippet color "color: color-name (color)" +color: ${1:red};$0 +endsnippet + +snippet color "color: color-rgb (color)" +color: rgb(${1:255},${2:255},${3:255});$0 +endsnippet + +snippet cursor "cursor: type (cursor)" +cursor: ${1:default/auto/crosshair/pointer/move/*-resize/text/wait/help};$0 +endsnippet + +snippet cursor "cursor: url (cursor)" +cursor: url($1);$0 +endsnippet + +snippet direction "direction: ltr|rtl (direction)" +direction: ${1:ltr|rtl};$0 +endsnippet + +snippet display "display: block (display)" +display: block;$0 +endsnippet + +snippet display "display: common-types (display)" +display: ${1:none/inline/block/list-item/run-in/compact/marker};$0 +endsnippet + +snippet display "display: inline (display)" +display: inline;$0 +endsnippet + +snippet display "display: table-types (display)" +display: ${1:table/inline-table/table-row-group/table-header-group/table-footer-group/table-row/table-column-group/table-column/table-cell/table-caption};$0 +endsnippet + +snippet float "float: left:right:none (float)" +float: ${1:left/right/none};$0 +endsnippet + +snippet font "font-family: family (font)" +font-family: ${1:Arial, "MS Trebuchet"}, ${2:sans-}serif;$0 +endsnippet + +snippet font "font-size: size (font)" +font-size: ${1:100%};$0 +endsnippet + +snippet font "font-style: normal:italic:oblique (font)" +font-style: ${1:normal/italic/oblique};$0 +endsnippet + +snippet font "font-variant: normal:small-caps (font)" +font-variant: ${1:normal/small-caps};$0 +endsnippet + +snippet font "font-weight: weight (font)" +font-weight: ${1:normal/bold};$0 +endsnippet + +snippet font "font: style variant weight size:line-height font -family (font)" +font: ${1:normal/italic/oblique} ${2:normal/small-caps} ${3:normal/bold} ${4:1em/1.5em} ${5:Arial}, ${6:sans-}serif;$0 +endsnippet + +snippet font "font: size font (font)" +font: ${1:75%} ${2:"Lucida Grande", "Trebuchet MS", Verdana,} ${3:sans-}serif;$0 +endsnippet + +snippet letter "letter-spacing: length-em (letter)" +letter-spacing: $1em;$0 +endsnippet + +snippet letter "letter-spacing: length-px (letter)" +letter-spacing: $1px;$0 +endsnippet + +snippet list "list-style-image: url (list)" +list-style-image: url($1);$0 +endsnippet + +snippet list "list-style-position: pos (list)" +list-style-position: ${1:inside/outside};$0 +endsnippet + +snippet list "list-style-type: asian (list)" +list-style-type: ${1:cjk-ideographic/hiragana/katakana/hiragana-iroha/katakana-iroha};$0 +endsnippet + +snippet list "list-style-type: marker(list)" +list-style-type: ${1:none/disc/circle/square};$0 +endsnippet + +snippet list "list-style-type: numeric (list)" +list-style-type: ${1:decimal/decimal-leading-zero/zero};$0 +endsnippet + +snippet list "list-style-type: other (list)" +list-style-type: ${1:hebrew/armenian/georgian};$0 +endsnippet + +snippet list "list-style-type: roman-alpha-greek (list)" +list-style-type: ${1:lower-roman/upper-roman/lower-alpha/upper-alpha/lower-greek/lower-latin/upper-latin};$0 +endsnippet + +snippet list "list-style: type position image (list)" +list-style: ${1:none/disc/circle/square/decimal/zero} ${2:inside/outside} url($3);$0 +endsnippet + +snippet margin "margin-bottom: length (margin)" +margin-bottom: ${1:20px};$0 +endsnippet + +snippet margin "margin-left: length (margin)" +margin-left: ${1:20px};$0 +endsnippet + +snippet margin "margin-right: length (margin)" +margin-right: ${1:20px};$0 +endsnippet + +snippet margin "margin-top: length (margin)" +margin-top: ${1:20px};$0 +endsnippet + +snippet margin "margin: all (margin)" +margin: ${1:20px};$0 +endsnippet + +snippet margin "margin: T R B L (margin)" +margin: ${1:20px} ${2:0px} ${3:40px} ${4:0px};$0 +endsnippet + +snippet margin "margin: V H (margin)" +margin: ${1:20px} ${2:0px};$0 +endsnippet + +snippet marker "marker-offset: auto (marker)" +marker-offset: auto;$0 +endsnippet + +snippet marker "marker-offset: length (marker)" +marker-offset: ${1:10px};$0 +endsnippet + +snippet overflow "overflow: type (overflow)" +overflow: ${1:visible/hidden/scroll/auto};$0 +endsnippet + +snippet padding "padding-bottom: length (margin)" +padding-bottom: ${1:20px};$0 +endsnippet + +snippet padding "padding-left: length (margin)" +padding-left: ${1:20px};$0 +endsnippet + +snippet padding "padding-right: length (margin)" +padding-right: ${1:20px};$0 +endsnippet + +snippet padding "padding-top: length (margin)" +padding-top: ${1:20px};$0 +endsnippet + +snippet padding "padding: T R B L (padding)" +padding: ${1:20px} ${2:0px} ${3:40px} ${4:0px};$0 +endsnippet + +snippet padding "padding: V H (padding)" +padding: ${1:20px} ${2:0px};$0 +endsnippet + +snippet padding "padding: all (padding)" +padding: ${1:20px};$0 +endsnippet + +snippet position "position: type (position)" +position: ${1:static/relative/absolute/fixed};$0 +endsnippet + +snippet { "properties { } ( } )" +{ + /* $1 */ + $0 + +endsnippet + +snippet scrollbar "scrollbar" +scrollbar-base-color: ${1:#CCCCCC};${2: +scrollbar-arrow-color: ${3:#000000}; +scrollbar-track-color: ${4:#999999}; +scrollbar-3dlight-color: ${5:#EEEEEE}; +scrollbar-highlight-color: ${6:#FFFFFF}; +scrollbar-face-color: ${7:#CCCCCC}; +scrollbar-shadow-color: ${9:#999999}; +scrollbar-darkshadow-color: ${8:#666666};} +endsnippet + +snippet selection "selection" +$1::-moz-selection, +$1::selection { + color: ${2:inherit}; + background: ${3:inherit}; +} +endsnippet + +snippet text "text-align: left:center:right (txt)" +text-align: ${1:left/right/center/justify};$0 +endsnippet + +snippet text "text-decoration: none:underline:overline:line-through:blink (text)" +text-decoration: ${1:none/underline/overline/line-through/blink};$0 +endsnippet + +snippet text "text-indent: length (text)" +text-indent: ${1:10}px;$0 +endsnippet + +snippet text "text-shadow: color-hex x y blur (text)" +text-shadow: #${1:DDD} ${2:10px} ${3:10px} ${4:2px};$0 +endsnippet + +snippet text "text-shadow: color-rgb x y blur (text)" +text-shadow: rgb(${1:255},${2:255},${3:255}) ${4:10px} ${5:10px} ${6:2px};$0 +endsnippet + +snippet text "text-shadow: none (text)" +text-shadow: none;$0 +endsnippet + +snippet text "text-transform: capitalize:upper:lower (text)" +text-transform: ${1:capitalize/uppercase/lowercase};$0 +endsnippet + +snippet text "text-transform: none (text)" +text-transform: none;$0 +endsnippet + +snippet vertical "vertical-align: type (vertical)" +vertical-align: ${1:baseline/sub/super/top/text-top/middle/bottom/text-bottom/length/%};$0 +endsnippet + +snippet visibility "visibility: type (visibility)" +visibility: ${1:visible/hidden/collapse};$0 +endsnippet + +snippet white "white-space: normal:pre:nowrap (white)" +white-space: ${1:normal/pre/nowrap};$0 +endsnippet + +snippet word "word-spacing: length (word)" +word-spacing: ${1:10px};$0 +endsnippet + +snippet word "word-spacing: normal (word)" +word-spacing: normal;$0 +endsnippet + +snippet z "z-index: index (z)" +z-index: $1;$0 +endsnippet + +# vim:ft=snippets: diff --git a/skel/.config/nvim/plugged/vim-snippets/UltiSnips/d.snippets b/skel/.config/nvim/plugged/vim-snippets/UltiSnips/d.snippets new file mode 100644 index 0000000..7f38c6d --- /dev/null +++ b/skel/.config/nvim/plugged/vim-snippets/UltiSnips/d.snippets @@ -0,0 +1,583 @@ +# Simple shortcuts + +snippet imp "import (imp)" b +import ${1:std.stdio}; +endsnippet + +snippet pimp "public import (pimp)" b +public import ${1:/*module*/}; +endsnippet + +snippet over "override (over)" b +override ${1:/*function*/} +endsnippet + +snippet al "alias (al)" +alias ${1:/*orig*/} ${2:/*alias*/}; +endsnippet + +snippet mixin "mixin (mixin)" b +mixin ${1:/*mixed_in*/} ${2:/*name*/}; +endsnippet + +snippet new "new (new)" +new ${1}(${2}); +endsnippet + +snippet scpn "@safe const pure nothrow (scpn)" +@safe const pure nothrow +endsnippet + +snippet spn "@safe pure nothrow (spn)" +@safe pure nothrow +endsnippet + +snippet cont "continue (cont)" +continue; +endsnippet + +snippet dis "@disable (dis)" b +@disable ${1:/*method*/}; +endsnippet + +snippet pub "public (pub)" b +public: + ${1:/*members*/} +endsnippet + +snippet priv "private (priv)" b +private: + ${1:/*members*/} +endsnippet + +snippet prot "protected (prot)" b +protected: + ${1:/*members*/} +endsnippet + +snippet pack "package (pack)" b +package: + ${1:/*members*/} +endsnippet + +snippet ret "return (ret)" +return ${1:/*value to return*/}; +endsnippet + +snippet auto "auto (auto)" b +auto ${1:/*variable*/} = ${2:/*value*/}; +endsnippet + +snippet con "const (con)" b +const ${1:/*variable*/} = ${2:/*value*/}; +endsnippet + +snippet siz "size_t (siz)" b +size_t ${1:/*variable*/} = ${2:/*value*/}; +endsnippet + +snippet sup "super (sup)" b +super(${1:/*args*/}); +endsnippet + +# Phobos + +snippet tup "tuple (tup)" +tuple(${1:/*args*/}) +endsnippet + +snippet wr "writeln (wr)" +writeln(${1:/*args*/}); +endsnippet + +snippet to "to (to)" +to!(${1:/*type*/})(${2:/*arg*/}) +endsnippet + +snippet enf "enforce (enf)" b +enforce(${1:/*condition*/}, + new ${2}Exception(${3:/*args*/})); +endsnippet + +# Branches + +snippet if "if .. (if)" +if(${1:/*condition*/}) +{ + ${VISUAL}${0:/*code*/} +} +endsnippet + +snippet ife "if .. else (ife)" b +if(${1:/*condition*/}) +{ + ${2:/*code*/} +} +else +{ + ${3:/*else*/} +} +endsnippet + +snippet el "else (el)" b +else +{ + ${VISUAL}${1:/*code*/} +} +endsnippet + +snippet eif "else if (elif)" b +else if(${1:/*condition*/}) +{ + ${VISUAL}${0:/*code*/} +} +endsnippet + +snippet sw "switch (sw)" +switch(${1:/*var*/}) +{ + case ${2:/*value*/}: + ${3:/*code*/} + break; + case ${4:/*value*/}: + ${5:/*code*/} + break; + ${7:/*more cases*/} + default: + ${6:assert(false);} +} +endsnippet + +snippet fsw "final switch (fsw)" +switch(${1:/*var*/}) +{ + case ${2:/*value*/}: + ${3:/*code*/} + break; + case ${4:/*value*/}: + ${5:/*code*/} + break; + ${7:/*more cases*/} +} +endsnippet + +snippet case "case (case)" b +case ${1:/*value*/}: + ${2:/*code*/} + break; +endsnippet + +snippet ?: "ternary operator (?:)" +${1:/*condition*/} ? ${2:/*then*/} : ${3:/*else*/}$4 +endsnippet + +# Loops + +snippet do "do while (do)" b +do +{ + ${VISUAL}${2:/*code*/} +} while(${1:/*condition*/}); +endsnippet + +snippet wh "while (wh)" b +while(${1:/*condition*/}) +{ + ${VISUAL}${2:/*code*/} +} +endsnippet + +snippet for "for (for)" b +for (${4:size_t} ${2:i} = 0; $2 < ${1:count}; ${3:++$2}) +{ + ${VISUAL}${0:/*code*/} +} +endsnippet + +snippet forever "forever (forever)" b +for(;;) +{ + ${VISUAL}${0:/*code*/} +} +endsnippet + +snippet fore "foreach (fore)" +foreach(${1:/*elem*/}; ${2:/*range*/}) +{ + ${VISUAL}${3:/*code*/} +} +endsnippet + +snippet forif "foreach if (forif)" b +foreach(${1:/*elem*/}; ${2:/*range*/}) if(${3:/*condition*/}) +{ + ${VISUAL}${4:/*code*/} +} +endsnippet + +# Contracts +snippet in "in contract (in)" b +in +{ + assert(${1:/*condition*/}, "${2:error message}"); + ${3} +} +body +endsnippet + +snippet out "out contract (out)" b +out${1:(result)} +{ + assert(${2:/*condition*/}, "${3:error message}"); + ${4} +} +body +endsnippet + +snippet inv "invariant (inv)" b +invariant() +{ + assert(${1:/*condition*/}, "${2:error message}"); + ${3} +} +endsnippet + +# Functions (generic) + +snippet fun "function definition (fun)" +${1:void} ${2:/*function name*/}(${3:/*args*/}) ${4:@safe pure nothrow} +{ + ${VISUAL}${5:/*code*/} +} +endsnippet + +snippet void "void function definition (void)" +void ${1:/*function name*/}(${2:/*args*/}) ${3:@safe pure nothrow} +{ + ${VISUAL}${4:/*code*/} +} +endsnippet + +snippet this "ctor (this)" w +this(${1:/*args*/}) +{ + ${VISUAL}${2:/*code*/} +} +endsnippet + +snippet get "getter property (get)" ! +@property ${1:/*type*/} ${2:/*member_name*/}() const pure nothrow {return ${3:$2_};} +endsnippet + +snippet set "setter property (set)" ! +@property void ${1:/*member_name*/}(${2:/*type*/} rhs) pure nothrow {${3:$1_} = rhs;} +endsnippet + +# Functions (concrete) + +snippet main "Main" b +void main(string[] args) +{ + ${VISUAL}${0: /*code*/} +} +endsnippet + +# Mixins + +snippet signal "signal (signal)" b +mixin Signal!(${1:/*args*/}) ${2:/*name*/}; +endsnippet + +# Scope + +snippet scope "scope (scope)" b +scope(${1:exit}) +{ + ${VISUAL}${2:/*code*/} +} +endsnippet + +# With + +snippet with "with (with)" +with(${1}) +{ + ${VISUAL}${2:/*code*/} +} +endsnippet + +# Exception handling + +snippet try "try/catch (try)" b +try +{ + ${VISUAL}${1:/*code to try*/} +} +catch(${2}Exception e) +{ + ${3:/*handle exception*/} +} +endsnippet + +snippet tryf "try/catch/finally (tryf)" b +try +{ + ${VISUAL}${1:/*code to try*/} +} +catch(${2}Exception e) +{ + ${3:/*handle exception*/} +} +finally +{ + ${4:/*cleanup*/} +} +endsnippet + +snippet catch "catch (catch)" b +catch(${1}Exception e) +{ + ${2:/*handle exception*/} +} +endsnippet + +snippet thr "throw (thr)" +throw new ${1}Exception("${2}"); +endsnippet + + +# Type declarations + +snippet struct "struct (struct)" +struct ${1:`!p snip.rv = (snip.basename or "name")`} +{ + ${2} +} +endsnippet + +snippet union "union (union)" +union ${1:`!p snip.rv = (snip.basename or "name")`} +{ + ${2} +} +endsnippet + +snippet class "class (class)" +class ${1:`!p snip.rv = (snip.basename or "name")`} +{ + ${2} +} +endsnippet + +snippet inter "interface (inter)" +interface ${1:`!p snip.rv = (snip.basename or "name")`} +{ + ${2} +} +endsnippet + +snippet enum "enum (enum)" +enum ${1:`!p snip.rv = (snip.basename or "name")`} +{ + ${2} +} +endsnippet + + +# Exception declarations + +snippet exc "exception declaration (exc)" b +/// ${3:/*documentation*/} +class ${1}Exception : ${2}Exception +{ + public this(string msg, string file = __FILE__, int line = __LINE__) + { + super(msg, file, line); + } +} +endsnippet + + +# Conditional compilation + +snippet version "version (version)" b +version(${1:/*version name*/}) +{ + ${VISUAL}${2:/*code*/} +} +endsnippet + +snippet debug "debug" b +debug +{ + ${VISUAL}${1:/*code*/} +} +endsnippet + + +# Templates + +snippet temp "template (temp)" b +template ${2:/*name*/}(${1:/*args*/}) +{ + ${3:/*code*/} +} +endsnippet + + +# Asserts + +snippet ass "assert (ass)" b +assert(${1:false}, "${2:TODO}"); + +endsnippet + + +# Unittests + +snippet unittest "unittest (unittest)" b +unittest +{ + ${1:/*code*/} +} +endsnippet + + +# Common member functions + +snippet opDis "opDispatch (opDis)" b +${1:/*return type*/} opDispatch(string s)() +{ + ${2:/*code*/}; +} +endsnippet + +snippet op= "opAssign (op=)" b +void opAssign(${1} rhs) ${2:@safe pure nothrow} +{ + ${2:/*code*/} +} +endsnippet + +snippet opCmp "opCmp (opCmp)" b +int opCmp(${1} rhs) @safe const pure nothrow +{ + ${2:/*code*/} +} +endsnippet + +snippet opApply "opApply (opApply)" b +int opApply(int delegate(ref ${1:/*iterated type/s*/}) dg) +{ + int result = 0; + ${2:/*loop*/} + { + result = dg(${3:/*arg/s*/}); + if(result){break;} + } + return result; +} +endsnippet + +snippet toString "toString (toString)" b +string toString() @safe const pure nothrow +{ + ${1:/*code*/} +} +endsnippet + + +# Comments + + +snippet todo "TODO (todo)" ! +// TODO: ${1} +endsnippet + + + +# DDoc + +snippet doc "generic ddoc block (doc)" b +/// ${1:description} +/// +/// ${2:details} +endsnippet + +snippet fdoc "function ddoc block (fdoc)" b +/// ${1:description} +/// +/// ${2:Params: ${3:param} = ${4:param description} +/// ${5}} +/// +/// ${6:Returns: ${7:return value}} +/// +/// ${8:Throws: ${9}Exception ${10}} +endsnippet + +snippet Par "Params (Par)" +Params: ${1:param} = ${2:param description} +/// ${3} +endsnippet + +snippet Ret "Returns (Ret)" +Returns: ${1:return value/s} +endsnippet + +snippet Thr "Throws (Thr)" +Throws: ${1}Exception ${2} +endsnippet + +snippet Example "Examples (Example)" +Examples: +/// -------------------- +/// ${1:example code} +/// -------------------- +endsnippet + + +# License blocks + +snippet gpl "GPL (gpl)" b +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// +// Copyright (C) ${1:Author}, `!v strftime("%Y")` + +${2} +endsnippet + +snippet boost "Boost (boost)" b +// Copyright ${1:Author} `!v strftime("%Y")`. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +${2} +endsnippet + + +# New module + +snippet module "New module (module)" b +// Copyright ${1:Author} `!v strftime("%Y")`. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +module ${2}.`!v vim_snippets#Filename('$1', 'name')`; + + +${3} +endsnippet diff --git a/skel/.config/nvim/plugged/vim-snippets/UltiSnips/django.snippets b/skel/.config/nvim/plugged/vim-snippets/UltiSnips/django.snippets new file mode 100644 index 0000000..553baba --- /dev/null +++ b/skel/.config/nvim/plugged/vim-snippets/UltiSnips/django.snippets @@ -0,0 +1,236 @@ +# Generic Tags +snippet % +{% ${1} %}${2} +endsnippet + +snippet %% +{% ${1:tag_name} %} + ${2} +{% end$1 %} +endsnippet + +snippet { +{{ ${1} }}${2} +endsnippet + +# Template Tags + +snippet autoescape +{% autoescape ${1:off} %} + ${2} +{% endautoescape %} +endsnippet + +snippet block +{% block ${1} %} + ${2} +{% endblock %} +endsnippet + +snippet # +{# ${1:comment} #} +endsnippet + +snippet comment +{% comment %} + ${1} +{% endcomment %} +endsnippet + +snippet cycle +{% cycle ${1:val1} ${2:val2} ${3:as ${4}} %} +endsnippet + +snippet debug +{% debug %} +endsnippet + +snippet extends +{% extends "${1:base.html}" %} +endsnippet + +snippet filter +{% filter ${1} %} + ${2} +{% endfilter %} +endsnippet + +snippet firstof +{% firstof ${1} %} +endsnippet + +snippet for +{% for ${1} in ${2} %} + ${3} +{% endfor %} +endsnippet + +snippet empty +{% empty %} + ${1} +endsnippet + +snippet if +{% if ${1} %} + ${2} +{% endif %} +endsnippet + +snippet el +{% else %} + ${1} +endsnippet + +snippet ifchanged +{% ifchanged %}${1}{% endifchanged %} +endsnippet + +snippet ifequal +{% ifequal ${1} ${2} %} + ${3} +{% endifequal %} +endsnippet + +snippet ifnotequal +{% ifnotequal ${1} ${2} %} + ${3} +{% endifnotequal %} +endsnippet + +snippet include +{% include "${1}" %} +endsnippet + +snippet load +{% load ${1} %} +endsnippet + +snippet now +{% now "${1:jS F Y H:i}" %} +endsnippet + +snippet regroup +{% regroup ${1} by ${2} as ${3} %} +endsnippet + +snippet spaceless +{% spaceless %}${1}{% endspaceless %} +endsnippet + +snippet ssi +{% ssi ${1} %} +endsnippet + +snippet trans +{% trans "${1:string}" %} +endsnippet + +snippet url +{% url ${1} as ${2} %} +endsnippet + +snippet widthratio +{% widthratio ${1:this_value} ${2:max_value} ${3:100} %} +endsnippet + +snippet with +{% with ${1} as ${2} %} +endsnippet + +# Template Filters + +# Note: Since SnipMate can't determine which template filter you are +# expanding without the "|" character, these do not add the "|" +# character. These save a few keystrokes still. + +# Note: Template tags that take no arguments are not implemented. + +snippet add +add:"${1}" +endsnippet + +snippet center +center:"${1}" +endsnippet + +snippet cut +cut:"${1}" +endsnippet + +snippet date +date:"${1}" +endsnippet + +snippet default +default:"${1}" +endsnippet + +snippet defaultifnone +default_if_none:"${1}" +endsnippet + +snippet dictsort +dictsort:"${1}" +endsnippet + +snippet dictsortrev +dictsortreversed:"${1}" +endsnippet + +snippet divisibleby +divisibleby:"${1}" +endsnippet + +snippet floatformat +floatformat:"${1}" +endsnippet + +snippet getdigit +get_digit:"${1}" +endsnippet + +snippet join +join:"${1}" +endsnippet + +snippet lengthis +length_is:"${1}" +endsnippet + +snippet pluralize +pluralize:"${1}" +endsnippet + +snippet removetags +removetags:"${1}" +endsnippet + +snippet slice +slice:"${1}" +endsnippet + +snippet stringformat +stringformat:"${1}" +endsnippet + +snippet time +time:"${1}" +endsnippet + +snippet truncatewords +truncatewords:${1} +endsnippet + +snippet truncatewordshtml +truncatewords_html:${1} +endsnippet + +snippet urlizetrunc +urlizetrunc:${1} +endsnippet + +snippet wordwrap +wordwrap:${1} +endsnippet + +# vim:ft=snippets: diff --git a/skel/.config/nvim/plugged/vim-snippets/UltiSnips/elixir.snippets b/skel/.config/nvim/plugged/vim-snippets/UltiSnips/elixir.snippets new file mode 100644 index 0000000..ae7ea20 --- /dev/null +++ b/skel/.config/nvim/plugged/vim-snippets/UltiSnips/elixir.snippets @@ -0,0 +1,168 @@ +# Credit: @iurifg + +snippet do +do + ${1} +end +endsnippet + +snippet if "if .. do .. end" +if ${1:condition} do + ${2:expression} +end +endsnippet + +snippet if "if .. do: .." +if ${1:condition}, do: ${2:expression} +endsnippet + +snippet ife "if .. do .. else .. end" +if ${1:condition} do + ${2:expression} +else + ${3:expression} +end +endsnippet + +snippet ife "if .. do: .. else:" +if ${1:condition}, do: ${2}, else: ${3} +endsnippet + +snippet unless "unless .. do .. end" +unless ${1} do + ${2} +end +endsnippet + +snippet unless "unless .. do: .." +unless ${1:condition}, do: ${2} +endsnippet + +snippet unlesse "unless .. do .. else .. end" +unless ${1:condition} do + ${2} +else + ${3} +end +endsnippet + +snippet unlesse "unless .. do: .. else:" +unless ${1:condition}, do: ${2}, else: ${3} +endsnippet + +snippet cond +"cond do" +${1} -> + ${2} +end +endsnippet + +snippet case +case ${1} do +${2} -> + ${3} +end +endsnippet + +snippet def +def ${1:name} do + ${2} +end +endsnippet + +snippet defin "def function(n), do: n" +def ${1:name}, do: ${2} +endsnippet + +snippet defg +def ${1:name} when ${2:guard-condition} do + ${3} +end +endsnippet + +snippet defim +defimpl ${1:protocol_name}, for: ${2:data_type} do + ${3} +end +endsnippet + +snippet defma +defmacro ${1:name} do + ${2} +end +endsnippet + +snippet defmo +defmodule ${1:module_name} do + ${2} +end +endsnippet + +snippet defp +defp ${1:name} do + ${2} +end +endsnippet + +snippet defpr +defprotocol ${1:name}, [${2:function}] +endsnippet + +snippet defr +defrecord ${1:record_name}, ${2:fields} +endsnippet + +snippet doc +@doc """ +${1} +""" +endsnippet + +snippet fn +fn(${1:args}) -> ${2} end +endsnippet + +snippet fun +function do + ${1} +end +endsnippet + +snippet mdoc +@moduledoc """ +${1} +""" +endsnippet + +snippet rec +receive do +${1} -> + ${2} +end +endsnippet + +snippet req +require ${1:module_name} +endsnippet + +snippet imp +import ${1:module_name} +endsnippet + +snippet ali "alias old-module to shorthand" +alias ${1:module_name} +endsnippet + +snippet test +test "${1:test_name}" do + ${2} +end +endsnippet + +snippet try "try .. rescue .. end" +try do + ${1} +rescue + ${2} -> ${3} +end +endsnippet diff --git a/skel/.config/nvim/plugged/vim-snippets/UltiSnips/erlang.snippets b/skel/.config/nvim/plugged/vim-snippets/UltiSnips/erlang.snippets new file mode 100644 index 0000000..7823162 --- /dev/null +++ b/skel/.config/nvim/plugged/vim-snippets/UltiSnips/erlang.snippets @@ -0,0 +1,98 @@ +########################################################################### +# TEXTMATE SNIPPETS # +########################################################################### + +snippet pat "Case:Receive:Try Clause" +${1:pattern}${2: when ${3:guard}} ->; + ${4:body} +endsnippet + +snippet beh "Behaviour Directive" +-behaviour (${1:behaviour}). +endsnippet + +snippet case "Case Expression" +case ${1:expression} of + ${2:pattern}${3: when ${4:guard}} -> + ${5:body} +end +endsnippet + +snippet def "Define Directive" +-define (${1:macro}${2: (${3:param})}, ${4:body}). +endsnippet + +snippet exp "Export Directive" +-export ([${1:function}/${2:arity}]). +endsnippet + +snippet fun "Fun Expression" +fun + (${1:pattern})${2: when ${3:guard}} -> + ${4:body} +end +endsnippet + +snippet fu "Function" +${1:function} (${2:param})${3: when ${4:guard}} -> + ${5:body} +endsnippet + +snippet if "If Expression" +if + ${1:guard} -> + ${2:body} +end +endsnippet + +snippet ifdef "Ifdef Directive" +-ifdef (${1:macro}). +endsnippet + +snippet ifndef "Ifndef Directive" +-ifndef (${1:macro}). +endsnippet + +snippet imp "Import Directive" +-import (${1:module}, [${2:function}/${3:arity}]). +endsnippet + +snippet inc "Include Directive" +-include ("${1:file}"). +endsnippet + +snippet mod "Module Directive" +-module (${1:`!p snip.rv = snip.basename or "module"`}). +endsnippet + +snippet rcv "Receive Expression" +receive +${1: ${2:pattern}${3: when ${4:guard}} -> + ${5:body}} +${6:after + ${7:expression} -> + ${8:body}} +end +endsnippet + +snippet rec "Record Directive" +-record (${1:record}, {${2:field}${3: = ${4:value}}}). +endsnippet + +snippet try "Try Expression" +try${1: ${2:expression}${3: of + ${4:pattern}${5: when ${6:guard}} -> + ${7:body}}} +${8:catch + ${9:pattern}${10: when ${11:guard}} -> + ${12:body}} +${13:after + ${14:body}} +end +endsnippet + +snippet undef "Undef Directive" +-undef (${1:macro}). +endsnippet + +# vim:ft=snippets: diff --git a/skel/.config/nvim/plugged/vim-snippets/UltiSnips/eruby.snippets b/skel/.config/nvim/plugged/vim-snippets/UltiSnips/eruby.snippets new file mode 100644 index 0000000..cd462fb --- /dev/null +++ b/skel/.config/nvim/plugged/vim-snippets/UltiSnips/eruby.snippets @@ -0,0 +1,287 @@ +# TextMate added these variables to cope with changes in ERB handling +# in different versions of Rails -- for instance, Rails 3 automatically +# strips whitespace so that it's no longer necessary to use a form like +# <% end -%>, but if you're still maintaining Rails 2 projects, you +# can't omit the minus sign and get the same behavior. +# +# The following regex replace substitutes the function below for the +# TextMate variable references after the snippets are converted: +# +# /\v\$\{(TM_RAILS_TEMPLATE_([^_]+)_RUBY_([^_\s]+))\}/`!p textmate_var('\1', snip)`/g +# +global !p +def textmate_var(var, snip): + lookup = dict( + TM_RAILS_TEMPLATE_START_RUBY_EXPR = snip.opt('g:tm_rails_template_start_ruby_expr', '<%= '), + TM_RAILS_TEMPLATE_END_RUBY_EXPR = snip.opt('g:tm_rails_template_end_ruby_expr', ' %>'), + TM_RAILS_TEMPLATE_START_RUBY_INLINE = snip.opt('g:tm_rails_template_start_ruby_inline', '<% '), + TM_RAILS_TEMPLATE_END_RUBY_INLINE = snip.opt('g:tm_rails_template_end_ruby_inline', ' %>'), + TM_RAILS_TEMPLATE_END_RUBY_BLOCK = '<% end %>' + ) + + snip.rv = lookup[var] + return +endglobal + + +snippet % "<% ${0} %>" +`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_INLINE', snip)`${0}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_INLINE', snip)` +endsnippet + +snippet = "<%= ${0} %>" +`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`${0}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` +endsnippet + +########################################################################### +# GENERATED FROM get_tm_snippets.py + REGEX REPLACE # +########################################################################### + +snippet fi "<%= Fixtures.identify(:symbol) %>" +`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`Fixtures.identify(:${1:name})`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)`$0 +endsnippet + +snippet ft "form_tag" +`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_INLINE', snip)`form_tag(${1::action => "${5:update}"}${6:, {:${8:class} => "${9:form}"\}}) do`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` + $0 +`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_BLOCK', snip)` +endsnippet + +snippet end "end (ERB)" +<% end -%> +endsnippet + +snippet for "for loop (ERB)" +<% if !${1:list}.blank? %> + <% for ${2:item} in ${1} %> + $3 + <% end %> +<% else %> + $4 +<% end %> + +endsnippet + +snippet ffcb "form_for check_box" +`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`f.check_box :${1:attribute}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` +endsnippet + +snippet ffff "form_for file_field 2" +`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`f.file_field :${1:attribute}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` +endsnippet + +snippet ffhf "form_for hidden_field 2" +`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`f.hidden_field :${1:attribute}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` +endsnippet + +snippet ffl "form_for label 2" +`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR}f.label :${1:attribute', snip)`${2:, "${3:${1/[[:alpha:]]+|(_)/(?1: :\u$0)/g}}"}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` +endsnippet + +snippet ffpf "form_for password_field 2" +`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`f.password_field :${1:attribute}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` +endsnippet + +snippet ffrb "form_for radio_box 2" +`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`f.radio_box :${1:attribute}, :${2:tag_value}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` +endsnippet + +snippet ffs "form_for submit 2" +`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`f.submit "${1:Submit}"${2:, :disable_with => '${3:$1ing...}'}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` +endsnippet + +snippet ffta "form_for text_area 2" +`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`f.text_area :${1:attribute}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` +endsnippet + +snippet fftf "form_for text_field 2" +`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`f.text_field :${1:attribute}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` +endsnippet + +snippet fields "fields_for" +`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_INLINE', snip)`fields_for :${1:model}, @${2:$1} do |$1|`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_INLINE', snip)` + $0 +`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_BLOCK', snip)` +endsnippet + +snippet f. "f_fields_for (nff)" +`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_INLINE', snip)`f.fields_for :${1:attribute} do |${2:f}|`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_INLINE', snip)` + $0 +`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_BLOCK', snip)` +endsnippet + +snippet f. "f.checkbox" +`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`f.check_box :${1:attribute}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` +endsnippet + +snippet f. "f.file_field" +`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`f.file_field :${1:attribute}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` +endsnippet + +snippet f. "f.hidden_field" +`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`f.hidden_field :${1:attribute}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` +endsnippet + +snippet f. "f.label" +`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR}f.label :${1:attribute', snip)`${2:, "${3:${1/[[:alpha:]]+|(_)/(?1: :\u$0)/g}}"}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` +endsnippet + +snippet f. "f.password_field" +`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`f.password_field :${1:attribute}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` +endsnippet + +snippet f. "f.radio_box" +`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`f.radio_box :${1:attribute}, :${2:tag_value}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` +endsnippet + +snippet f. "f.submit" +`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`f.submit "${1:Submit}"${2:, :disable_with => '${3:$1ing...}'}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` +endsnippet + +snippet f. "f.text_area" +`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`f.text_area :${1:attribute}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` +endsnippet + +snippet f. "f.text_field" +`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`f.text_field :${1:attribute}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` +endsnippet + +snippet ffe "form_for with errors" +`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`error_messages_for :${1:model}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` + +`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_INLINE', snip)`form_for @${2:$1} do |f|`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_INLINE', snip)` + $0 +`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_BLOCK', snip)` +endsnippet + +snippet ff "form_for" +`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_INLINE', snip)`form_for @${1:model} do |f|`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_INLINE', snip)` + $0 +`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_BLOCK', snip)` +endsnippet + +snippet ist "image_submit_tag" +`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`image_submit_tag("${1:agree.png}"${2:${3:, :id => "${4:${1/^(\w+)(\.\w*)?$/$1/}}"}${5:, :name => "${6:${1/^(\w+)(\.\w*)?$/$1/}}"}${7:, :class => "${8:${1/^(\w+)(\.\w*)?$/$1/}-button}"}${9:, :disabled => ${10:false}}})`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` +endsnippet + +snippet it "image_tag" +`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`image_tag "$1${2:.png}"${3:${4:, :title => "${5:title}"}${6:, :class => "${7:class}"}}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` +endsnippet + +snippet layout "layout" +layout "${1:template_name}"${2:${3:, :only => ${4:[:${5:action}, :${6:action}]}}${7:, :except => ${8:[:${9:action}, :${10:action}]}}} +endsnippet + +snippet jit "javascript_include_tag" +`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`javascript_include_tag ${1::all}${2:, :cache => ${3:true}}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` +endsnippet + +snippet lia "link_to (action)" +`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`link_to "${1:link text...}", :action => "${2:index}"`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` +endsnippet + +snippet liai "link_to (action, id)" +`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`link_to "${1:link text...}", :action => "${2:edit}", :id => ${3:@item}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` +endsnippet + +snippet lic "link_to (controller)" +`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`link_to "${1:link text...}", :controller => "${2:items}"`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` +endsnippet + +snippet lica "link_to (controller, action)" +`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`link_to "${1:link text...}", :controller => "${2:items}", :action => "${3:index}"`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` +endsnippet + +snippet licai "link_to (controller, action, id)" +`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`link_to "${1:link text...}", :controller => "${2:items}", :action => "${3:edit}", :id => ${4:@item}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` +endsnippet + +snippet linpp "link_to (nested path plural)" +`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`link_to ${1:"${2:link text...}"}, ${3:${10:parent}_${11:child}_path(${12:@}${13:${10}})}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` +endsnippet + +snippet linp "link_to (nested path)" +`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`link_to ${1:"${2:link text...}"}, ${3:${12:parent}_${13:child}_path(${14:@}${15:${12}}, ${16:@}${17:${13}})}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` +endsnippet + +snippet lipp "link_to (path plural)" +`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`link_to ${1:"${2:link text...}"}, ${3:${4:model}s_path}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` +endsnippet + +snippet lip "link_to (path)" +`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`link_to ${1:"${2:link text...}"}, ${3:${12:model}_path(${13:@}${14:${12}})}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` +endsnippet + +snippet lim "link_to model" +`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`link_to ${1:model}.${2:name}, ${3:${4:$1}_path(${14:$1})}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` +endsnippet + +snippet hide "page.hide (*ids)" +page.hide ${1:"${2:id(s)}"} +endsnippet + +snippet ins "page.insert_html (position, id, partial)" +page.insert_html :${1:top}, ${2:"${3:id}"}, :${4:partial => "${5:template}"} +endsnippet + +snippet rep "page.replace (id, partial)" +page.replace ${1:"${2:id}"}, :${3:partial => "${4:template}"} +endsnippet + +snippet reph "page.replace_html (id, partial)" +page.replace_html ${1:"${2:id}"}, :${3:partial => "${4:template}"} +endsnippet + +snippet show "page.show (*ids)" +page.show ${1:"${2:id(s)}"} +endsnippet + +snippet tog "page.toggle (*ids)" +page.toggle ${1:"${2:id(s)}"} +endsnippet + +snippet vis "page.visual_effect (effect, id)" +page.visual_effect :${1:toggle_slide}, ${2:"${3:DOM ID}"} +endsnippet + +snippet rp "render (partial) (rp)" +render :partial => "${1:item}" +endsnippet + +snippet rpc "render (partial,collection) (rpc)" +render :partial => "${1:item}", :collection => ${2:@$1s} +endsnippet + +snippet rpl "render (partial,locals) (rpl)" +render :partial => "${1:item}", :locals => { :${2:$1} => ${3:@$1}$0 } +endsnippet + +snippet rpo "render (partial,object) (rpo)" +render :partial => "${1:item}", :object => ${2:@$1} +endsnippet + +snippet rps "render (partial,status) (rps)" +render :partial => "${1:item}", :status => ${2:500} +endsnippet + +snippet slt "stylesheet_link_tag" +`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`stylesheet_link_tag ${1::all}${2:, :cache => ${3:true}}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` +endsnippet + +snippet st "submit_tag" +`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`submit_tag "${1:Save changes}"${2:, :id => "${3:submit}"}${4:, :name => "${5:$3}"}${6:, :class => "${7:form_$3}"}${8:, :disabled => ${9:false}}${10:, :disable_with => "${11:Please wait...}"}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` +endsnippet + +snippet el "else (ERB)" +<% else %> + +endsnippet + +snippet if "if (ERB)" +<% if ${1:condition} %>$0 +endsnippet + +snippet lf "link_to_function" +`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`link_to_function ${1:"${2:Greeting}"}, "${3:alert('Hello world!')}"$4`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` +endsnippet + +# vim:ft=snippets: diff --git a/skel/.config/nvim/plugged/vim-snippets/UltiSnips/go.snippets b/skel/.config/nvim/plugged/vim-snippets/UltiSnips/go.snippets new file mode 100644 index 0000000..ea46931 --- /dev/null +++ b/skel/.config/nvim/plugged/vim-snippets/UltiSnips/go.snippets @@ -0,0 +1,107 @@ +# Snippets for Go + +# when to abbriviate and when not? +# b doesn't work here, because it ignores whitespace +# optional local name? +snippet /^import/ "Import declaration" r +import ( + "${1:package}" +) +endsnippet + +snippet /^package/ "Package declaration" r +// Package $1 provides ... +package ${1:main} +endsnippet + +# Mostly converted from: https://github.com/AlanQuatermain/go-tmbundle +snippet /^cons/ "Constants declaration" r +const ( + ${1:constant}${2/(.+)/ /}${2:type} = ${0:value} +) +endsnippet + +snippet /^con/ "Constant declaration" r +const ${1:name}${2/(.+)/ /}${2:type} = ${0:value} +endsnippet + +snippet iota "Iota constant generator" b +const ( + ${1:constant}${2/(.+)/ /}${2:type} = iota +) +endsnippet + +# statements +snippet for "For loop" !b +for ${1:condition}${1/(.+)/ /}{ + ${0:${VISUAL}} +} +endsnippet + +snippet forr "For range loop" !b +for ${2:name} := range ${1:collection} { + ${0:${VISUAL}} +} +endsnippet + +snippet if "If statement" !b +if ${1:condition}${1/(.+)/ /}{ + ${0:${VISUAL}} +} +endsnippet + +snippet switch "Switch statement" !b +switch ${1:expression}${1/(.+)/ /}{ +case${0} +} +endsnippet + +snippet case "Case clause" !b +case ${1:condition}: + ${0:${VISUAL}} +endsnippet + +snippet default "Default clause" !b +default: + ${0:${VISUAL}} +endsnippet + +# functions +snippet /^main/ "Main function" r +func main() { + ${0:${VISUAL}} +} +endsnippet + +snippet /^meth/ "Method" r +func (${1:receiver} ${2:type}) ${3:name}(${4:params})${5/(.+)/ /}${5:type} { + ${0:${VISUAL}} +} +endsnippet + +snippet func "Function" b +func ${1:name}(${2:params})${3/(.+)/ /}${3:type} { + ${0:${VISUAL}} +} +endsnippet + +# types and variables +snippet map "Map type" !b +map[${1:keytype}]${2:valtype} +endsnippet + +snippet : "Variable declaration :=" !b +${1:name} := ${0:value} +endsnippet + +snippet var "Variable declaration" !b +var ${1:name}${2/(.+)/ /}${2:type}${3: = ${0:value}} +endsnippet + +snippet vars "Variables declaration" !b +var ( + ${1:name}${2/(.+)/ /}${2:type}${3: = ${0:value} } +) +endsnippet + +# vim:ft=snippets: diff --git a/skel/.config/nvim/plugged/vim-snippets/UltiSnips/haskell.snippets b/skel/.config/nvim/plugged/vim-snippets/UltiSnips/haskell.snippets new file mode 100644 index 0000000..99f947f --- /dev/null +++ b/skel/.config/nvim/plugged/vim-snippets/UltiSnips/haskell.snippets @@ -0,0 +1,61 @@ +snippet ife "if ... then ... else ..." +if ${1:condition} + then ${2:expression} + else ${3:expression} +endsnippet + +snippet case "case ... of ..." +case ${1} of + ${2} -> ${3} + ${4} -> ${5} +endsnippet + +snippet :: "Type signature" +${1:name} :: ${2:Type} -> ${3:Type} +endsnippet + +snippet => "Type constraint" +(${1:Class} ${2:Type var}) => ${3:$2} +endsnippet + +snippet def "Function definition" +${1:name} :: ${2:Type} -> ${3:Type} +endsnippet + +snippet def[] "Function definition for list patterns" +${1:name} :: [${2:Type}] -> ${3:Type} +$1 [] = ${4:undefined} +$1 ${5:(x:xs)} = ${6:undefined} +endsnippet + +snippet = "Function clause" +${1:name} ${2:pattern} = ${3:undefined} +endsnippet + +snippet 2= "Function clause" +${1:name} ${2:pattern} = ${3:undefined} +$1 ${4:pattern} = ${5:undefined} +endsnippet + +snippet 3= "Function clause" +${1:name} ${2:pattern} = ${3:undefined} +$1 ${4:pattern} = ${5:undefined} +$1 ${6:pattern} = ${7:undefined} +endsnippet + +snippet | "Guard" +| ${1:predicate} = ${2:undefined} +endsnippet + +snippet \ "Lambda expression" +\ ${1:pattern} -> ${2:expression} +endsnippet + +snippet [|] "List comprehension" +[${3:foo }$1 | ${1:x} <- ${2:xs} ] +endsnippet + +snippet let "let ... in ..." +let ${1:name} = ${2:expression} +in ${3:expression} +endsnippet diff --git a/skel/.config/nvim/plugged/vim-snippets/UltiSnips/help.snippets b/skel/.config/nvim/plugged/vim-snippets/UltiSnips/help.snippets new file mode 100644 index 0000000..bd0bb12 --- /dev/null +++ b/skel/.config/nvim/plugged/vim-snippets/UltiSnips/help.snippets @@ -0,0 +1,30 @@ +# Snippets for VIM Help Files + +global !p +def sec_title(snip, t): + file_start = snip.fn.split('.')[0] + sec_name = t[1].strip("1234567890. ").lower().replace(' ', '-') + return ("*%s-%s*" % (file_start, sec_name)).rjust(78-len(t[1])) +endglobal + +snippet sec "Section marker" b +============================================================================== +${1:SECTION}`!p snip.rv = sec_title(snip, t)` + +$0 +endsnippet + +snippet ssec "Sub section marker" b +${1:Subsection}`!p snip.rv = sec_title(snip, t) +snip += "-"*len(t[1])` + +$0 +endsnippet + +snippet sssec "Subsub Section marker" b +${1:SubSubsection}:`!p snip.rv = sec_title(snip, t)` + +$0 +endsnippet + +# vim:ft=snippets: diff --git a/skel/.config/nvim/plugged/vim-snippets/UltiSnips/html.snippets b/skel/.config/nvim/plugged/vim-snippets/UltiSnips/html.snippets new file mode 100644 index 0000000..fd11d70 --- /dev/null +++ b/skel/.config/nvim/plugged/vim-snippets/UltiSnips/html.snippets @@ -0,0 +1,297 @@ +########################################################################### +# TextMate Snippets # +########################################################################### + +global !p +def x(snip): + if snip.ft.startswith("x"): + snip.rv = '/' + else: + snip.rv = "" +endglobal + +############ +# Doctypes # +############ +snippet doctype "DocType XHTML 1.0 Strict" b + + +endsnippet + +snippet doctype "DocType XHTML 1.0 Transitional" b + + +endsnippet + +snippet doctype "DocType XHTML 1.1" b + + +endsnippet + +snippet doctype "HTML - 4.0 Transitional (doctype)" b + + +endsnippet + +snippet doctype "HTML - 5.0 (doctype)" b + + +endsnippet + +############# +# Shortcuts # +############# +snippet down "Down (down)" +↓ +endsnippet + +snippet enter "Enter (enter)" +⌅ +endsnippet + +snippet escape "Escape (escape)" +⎋ +endsnippet + +snippet shift "Shift (shift)" +⇧ +endsnippet + +snippet tab "Tab (tab)" +⇥ +endsnippet + +snippet up "Up (up)" +↑ +endsnippet + +snippet return "Return (return)" +↩ +endsnippet + +snippet right "Right (right)" +→ +endsnippet + +snippet left "Left (left)" +← +endsnippet + +snippet option "Option (option)" +⌥ +endsnippet + +####################### +# Conditional inserts # +####################### +snippet ! "IE Conditional Comment: Internet Explorer 5_0 only" +$0 +endsnippet + +snippet ! "IE Conditional Comment: Internet Explorer 5_5 only" +$0 +endsnippet + +snippet ! "IE Conditional Comment: Internet Explorer 5_x" +$0 +endsnippet + +snippet ! "IE Conditional Comment: Internet Explorer 6 and below" +$0 +endsnippet + +snippet ! "IE Conditional Comment: Internet Explorer 6 only" +$0 +endsnippet + +snippet ! "IE Conditional Comment: Internet Explorer 7+" +$0 +endsnippet + +snippet ! "IE Conditional Comment: Internet Explorer" +$0 +endsnippet + +snippet ! "IE Conditional Comment: NOT Internet Explorer" +${1: IE Conditional Comment: NOT Internet Explorer }$0 +endsnippet + +############# +# HTML TAGS # +############# +snippet input "Input with Label" + + +endsnippet + +snippet input "XHTML " + +endsnippet + + +snippet opt "Option" +${3:$2} +endsnippet + +snippet select "Select Box" + +endsnippet + + +snippet textarea "XHTML +endsnippet + +snippet mailto "XHTML
" +${3:email me} +endsnippet + +snippet base "XHTML " + +endsnippet + +snippet body "XHTML " + + $0 + +endsnippet + +snippet div "XHTML
" + + $0 +
+endsnippet + +snippet form "XHTML
" + + $0 + +

+
+endsnippet + +snippet h1 "XHTML

" +

${1}

+endsnippet + +snippet head "XHTML " + + + ${1:`!p snip.rv = snip.basename or "Page Title"`} + $0 + +endsnippet + +snippet link "XHTML " + +endsnippet + +snippet meta "XHTML " + +endsnippet + +snippet scriptsrc "XHTML +endsnippet + +snippet script "XHTML +endsnippet + +snippet style "XHTML +endsnippet + +snippet table "XHTML " +
+ + +
${5:Header}
${0:Data}
+endsnippet + +snippet a "Link" +${4:Anchor Text} +endsnippet + +snippet p "paragraph" +

$0

+endsnippet + +snippet li "list item" +
  • +endsnippet + +snippet ul "unordered list" +
      +$0 +
    +endsnippet + +snippet td "table cell" +$0 +endsnippet + +snippet tr "table row" +$0 +endsnippet + +snippet title "XHTML " +<title>${1:`!p snip.rv = snip.basename or "Page Title"`} +endsnippet + +snippet fieldset "Fieldset" +
    + $1 + + $0 +
    +endsnippet + +snippet movie "Embed QT movie (movie)" b + + + + + + +endsnippet + +snippet html5 "HTML5 Template" + + + + ${1} + + + +
    + ${2} +
    +
    + ${4} +
    + + +endsnippet +# vim:ft=snippets: diff --git a/skel/.config/nvim/plugged/vim-snippets/UltiSnips/html_minimal.snippets b/skel/.config/nvim/plugged/vim-snippets/UltiSnips/html_minimal.snippets new file mode 100644 index 0000000..1f77ad7 --- /dev/null +++ b/skel/.config/nvim/plugged/vim-snippets/UltiSnips/html_minimal.snippets @@ -0,0 +1,31 @@ +# more can be found in snippets/html_minimal.snippets +# these UltiSnips override snippets because nested placeholders are being used + +snippet id +id="${1}"${2} +endsnippet + +snippet idn +id="${1}" name="${2:$1}" +endsnippet + +snippet label_and_input + +${8} +endsnippet + +snippet input +${7} +endsnippet + +snippet textarea + +endsnippet + +snippet img + $3 +endsnippet diff --git a/skel/.config/nvim/plugged/vim-snippets/UltiSnips/htmldjango.snippets b/skel/.config/nvim/plugged/vim-snippets/UltiSnips/htmldjango.snippets new file mode 100644 index 0000000..9df5f78 --- /dev/null +++ b/skel/.config/nvim/plugged/vim-snippets/UltiSnips/htmldjango.snippets @@ -0,0 +1 @@ +extends html, django diff --git a/skel/.config/nvim/plugged/vim-snippets/UltiSnips/java.snippets b/skel/.config/nvim/plugged/vim-snippets/UltiSnips/java.snippets new file mode 100644 index 0000000..617c161 --- /dev/null +++ b/skel/.config/nvim/plugged/vim-snippets/UltiSnips/java.snippets @@ -0,0 +1,212 @@ +########################################################################### +# TEXTMATE SNIPPETS # +########################################################################### + +# Many of the snippets here use a global option called +# "g:ultisnips_java_brace_style" which, if set to "nl" will put a newline +# before '{' braces. + +global !p +def nl(snip): + if snip.opt("g:ultisnips_java_brace_style", "") == "nl": + snip += "" + else: + snip.rv += " " +endglobal + +snippet ab "abstract" b +abstract +endsnippet + +snippet as "assert" b +assert ${1:test}${2/(.+)/(?1: \: ")/}${2:Failure message}${2/(.+)/(?1:")/};$0 +endsnippet + +snippet br "break" +break; + +endsnippet + +snippet cs "case" b +case $1: + $2 +$0 +endsnippet + +snippet ca "catch" b +catch (${1:Exception} ${2:e})`!p nl(snip)`{ + $0 +} +endsnippet + +snippet cl "class" b +class ${1:`!p +snip.rv = snip.basename or "untitled"`} ${2:extends ${3:Parent} }${4:implements ${5:Interface} }{ + $0 +} +endsnippet + +snippet cos "constant string" b +static public final String ${1:var} = "$2";$0 +endsnippet + +snippet co "constant" b +static public final ${1:String} ${2:var} = $3;$0 +endsnippet + +snippet de "default" b +default: + $0 +endsnippet + +snippet eif "else if" b +else if ($1)`!p nl(snip)`{ + $0 +} +endsnippet + +snippet /el(se)?/ "else" br +else`!p nl(snip)`{ + $0 +} +endsnippet + +snippet fi "final" b +final +endsnippet + +snippet fore "for (each)" b +for ($1 : $2)`!p nl(snip)`{ + $0 +} +endsnippet + +snippet for "for" b +for ($1; $2; $3)`!p nl(snip)`{ + $0 +} +endsnippet + +snippet if "if" b +if ($1)`!p nl(snip)`{ + $0 +} +endsnippet + +snippet imt "import junit_framework_TestCase;" b +import junit.framework.TestCase; +$0 +endsnippet + +snippet im "import" b +import +endsnippet + +snippet in "interface" b +interface ${1:`!p snip.rv = snip.basename or "untitled"`} ${2:extends ${3:Parent} }{ + $0 +} +endsnippet + +snippet j.b "java_beans_" i +java.beans. +endsnippet + +snippet j.i "java_io" i +java.io. +endsnippet + +snippet j.m "java_math" i +java.math. +endsnippet + +snippet j.n "java_net_" i +java.net. +endsnippet + +snippet j.u "java_util_" i +java.util. +endsnippet + +snippet main "method (main)" b +public static void main(String[] args)`!p nl(snip)`{ + $0 +} +endsnippet + +snippet m "method" b +${1:void} ${2:method}($3) ${4:throws $5 }{ + $0 +} + +endsnippet + +snippet pa "package" b +package +endsnippet + +snippet p "print" b +System.out.print($1);$0 +endsnippet + +snippet pl "println" b +System.out.println($1);$0 +endsnippet + +snippet pr "private" b +private +endsnippet + +snippet po "protected" b +protected +endsnippet + +snippet pu "public" b +public +endsnippet + +snippet re "return" b +return +endsnippet + +snippet st "static" +static +endsnippet + +snippet sw "switch" b +switch ($1)`!p nl(snip)`{ + $0 +} +endsnippet + +snippet sy "synchronized" +synchronized +endsnippet + +snippet tc "test case" +public class ${1:`!p snip.rv = snip.basename or "untitled"`} extends ${2:TestCase}`!p nl(snip)`{ + $0 +} +endsnippet + +snippet t "test" b +public void test${1:Name}() throws Exception`!p nl(snip)`{ + $0 +} +endsnippet + +snippet th "throw" b +throw $0 +endsnippet + +snippet v "variable" b +${1:String} ${2:var}${3: = ${0:null}}; +endsnippet + +snippet wh "while" b +while ($1)`!p nl(snip)`{ + $0 +} +endsnippet + +# vim:ft=snippets: diff --git a/skel/.config/nvim/plugged/vim-snippets/UltiSnips/javascript.snippets b/skel/.config/nvim/plugged/vim-snippets/UltiSnips/javascript.snippets new file mode 100644 index 0000000..439ec87 --- /dev/null +++ b/skel/.config/nvim/plugged/vim-snippets/UltiSnips/javascript.snippets @@ -0,0 +1,72 @@ +########################################################################### +# TextMate Snippets # +########################################################################### +snippet get "Get Elements" +getElement${1/(T)|.*/(?1:s)/}By${1:T}${1/(T)|(I)|.*/(?1:agName)(?2:d)/}('$2') +endsnippet + +snippet '':f "object method string" +'${1:${2:#thing}:${3:click}}': function(element){ + $0 +}${10:,} +endsnippet + +snippet :f "Object Method" +${1:method_name}: function(${3:attribute}){ + $0 +}${10:,} +endsnippet + +snippet :, "Object Value JS" +${1:value_name}:${0:value}, +endsnippet + +snippet : "Object key key: 'value'" +${1:key}: ${2:"${3:value}"}${4:, } +endsnippet + +snippet proto "Prototype (proto)" +${1:class_name}.prototype.${2:method_name} = function(${3:first_argument}) ,,{ + ${0} +} + +endsnippet + +snippet for "for (...) {...} (faster)" +for (var ${2:i} = ${1:Things}.length - 1; $2 >= 0; $2--){ + ${3:$1[$2]}$0 +} +endsnippet + +snippet for "for (...) {...}" +for (var ${2:i}=0; $2 < ${1:Things}.length; $2++) { + ${3:$1[$2]}$0 +} +endsnippet + +snippet fun "function (fun)" +function ${1:function_name} (${2:argument}) { + ${0} +} +endsnippet + +# for one line if .. else you usually use a ? b : c +snippet ife "if ___ else" +if (${1}) { + ${2} +} else { + ${3} +} +endsnippet + +snippet if "if" +if (${1}) { + ${2} +} +endsnippet + +snippet timeout "setTimeout function" +setTimeout(function() {$0}${2:}, ${1:10}) +endsnippet + +# vim:ft=snippets: diff --git a/skel/.config/nvim/plugged/vim-snippets/UltiSnips/javascript_ember.snippets b/skel/.config/nvim/plugged/vim-snippets/UltiSnips/javascript_ember.snippets new file mode 100644 index 0000000..543a26a --- /dev/null +++ b/skel/.config/nvim/plugged/vim-snippets/UltiSnips/javascript_ember.snippets @@ -0,0 +1,88 @@ +################################################################### +# Ember snippets # +################################################################### + +# Application +snippet eapp "App.Name = Ember.Application.create({});" +${1:App.Name} = Ember.Application.create({}); +endsnippet + +# Models +snippet emod "App.ModelName = Ember.Model.extend({...});" +${1:model_name} = Ember.Model.extend({ + ${0://Properties here...} +}); +endsnippet + +# View +snippet eview "App.ViewName = Ember.Model.extend({...});" +${1:view_name} = Ember.View.extend({ + ${0://Properties here...} +}); +endsnippet + +# Controller +snippet econtroller "App.ControllerName = Ember.Model.extend({...});" +${1:controller_name} = Ember.ObjectController.extend({ + ${0://Properties here...} +}); +endsnippet + +# Route +snippet eroute "App.RouteName = Ember.Route.extend({...});" +${1:route_name} = Ember.Route.extend({ + ${0://Properties here...} +}); +endsnippet + +snippet eview "App.ViewName = Ember.Model.create({...});" +${1:view_name} = Ember.View.create({ + ${0://Properties here...} +}); +endsnippet + +# Object +snippet eobj "App.ObjectName = Ember.Object.extend({...});" +${1:object_name} = Ember.Object.create({ + ${0://Properties here...} +}); +endsnippet + +# Mixin +snippet emix "App.MixinName = Ember.Model.extend({...});" +${1:view_name} = Ember.Mixin.create({ + ${0://Properties here...} +}); +endsnippet + +# Ember getter and setter +snippet eget "this.get('property');" +${1:this}.get('${2:property}'); +endsnippet + +snippet eset "this.set('property', value);" +${1:this}.set('${2:property}', ${3:value}); +endsnippet + +# Computer properties +snippet cpro "property_name: function() {...}.property()," +${1:property_name}: function() { + ${0://body...} +}.property('${3:argumenet}'), +endsnippet + +snippet cpro ": function() {...}.property('property')," +${1:property_name}: function() { + ${0://body...} +}.property(), +endsnippet + + +# Observes +snippet proo "property_name: function() {...}.property()" +${1:property_name}: function() { + ${0://body...} +}.observes('${3:property}'), +endsnippet + +# vim:ft=snippets: diff --git a/skel/.config/nvim/plugged/vim-snippets/UltiSnips/javascript_jasmine.snippets b/skel/.config/nvim/plugged/vim-snippets/UltiSnips/javascript_jasmine.snippets new file mode 100644 index 0000000..49e38a3 --- /dev/null +++ b/skel/.config/nvim/plugged/vim-snippets/UltiSnips/javascript_jasmine.snippets @@ -0,0 +1,168 @@ +# +# JavaScript versions -- from the TextMate bundle + some additions +# for jasmine-jquery matchers +# +extends javascript + +snippet des "Describe (js)" b +describe('${1:description}', function() { + $0 +}); +endsnippet + +snippet it "it (js)" b +it('${1:description}', function() { + $0 +}); +endsnippet + +snippet bef "before each (js)" b +beforeEach(function() { + $0 +}); +endsnippet + +snippet aft "after each (js)" b +afterEach(function() { + $0 +}); +endsnippet + +snippet any "any (js)" b +jasmine.any($1) +endsnippet + +snippet ru "runs (js)" b +runs(function() { + $0 +}); +endsnippet + +snippet wa "waits (js)" b +waits($1); +endsnippet + +snippet ex "expect (js)" b +expect(${1:target})$0; +endsnippet + +snippet ee "expect to equal (js)" b +expect(${1:target}).toEqual(${2:value}); +endsnippet + +snippet em "expect to match (js)" b +expect(${1:target}).toMatch(${2:pattern}); +endsnippet + +snippet eha "expect to have attribute (js)" b +expect(${1:target}).toHaveAttr('${2:attr}'${3:, '${4:value}'}); +endsnippet + +snippet et "expect to be truthy (js)" b +expect(${1:target}).toBeTruthy(); +endsnippet + +snippet ef "expect to be falsy (js)" b +expect(${1:target}).toBeFalsy(); +endsnippet + +snippet ed "expect to be defined (js)" b +expect(${1:target}).toBeDefined(); +endsnippet + +snippet en "expect to be null (js)" b +expect(${1:target}).toBeNull(); +endsnippet + +snippet ec "expect to contain (js)" b +expect(${1:target}).toContain(${2:value}); +endsnippet + +snippet ev "expect to be visible (js)" b +expect(${1:target}).toBeVisible(); +endsnippet + +snippet eh "expect to be hidden (js)" b +expect(${1:target}).toBeHidden(); +endsnippet + +snippet notx "expect not (js)" b +expect(${1:target}).not$0; +endsnippet + +snippet note "expect not to equal (js)" b +expect(${1:target}).not.toEqual(${2:value}); +endsnippet + +snippet notm "expect not to match (js)" b +expect(${1:target}).not.toMatch(${2:pattern}); +endsnippet + +snippet notha "expect to not have attribute (js)" b +expect(${1:target}).not.toHaveAttr('${2:attr}'${3:, '${4:value}'}); +endsnippet + +snippet nott "expect not to be truthy (js)" b +expect(${1:target}).not.toBeTruthy(); +endsnippet + +snippet notf "expect not to be falsy (js)" b +expect(${1:target}).not.toBeFalsy(); +endsnippet + +snippet notd "expect not to be defined (js)" b +expect(${1:target}).not.toBeDefined(); +endsnippet + +snippet notn "expect not to be null (js)" b +expect(${1:target}).not.toBeNull(); +endsnippet + +snippet notc "expect not to contain (js)" b +expect(${1:target}).not.toContain(${2:value}); +endsnippet + +snippet notv "expect not to be visible (js)" b +expect(${1:target}).not.toBeVisible(); +endsnippet + +snippet noth "expect not to be hidden (js)" b +expect(${1:target}).not.toBeHidden(); +endsnippet + +snippet s "spy on (js)" b +spyOn(${1:object}, '${2:method}')$0; +endsnippet + +snippet sr "spy on and return (js)" b +spyOn(${1:object}, '${2:method}').andReturn(${3:arguments}); +endsnippet + +snippet st "spy on and throw (js)" b +spyOn(${1:object}, '${2:method}').andThrow(${3:exception}); +endsnippet + +snippet sct "spy on and call through (js)" b +spyOn(${1:object}, '${2:method}').andCallThrough(); +endsnippet + +snippet scf "spy on and call fake (js)" b +spyOn(${1:object}, '${2:method}').andCallFake(${3:function}); +endsnippet + +snippet esc "expect was called (js)" b +expect(${1:target}).wasCalled(); +endsnippet + +snippet escw "expect was called with (js)" b +expect(${1:target}).wasCalledWith(${2:arguments}); +endsnippet + +snippet notsc "expect was not called (js)" b +expect(${1:target}).wasNotCalled(); +endsnippet + +snippet noscw "expect was not called with (js)" b +expect(${1:target}).wasNotCalledWith(${2:arguments}); +endsnippet + diff --git a/skel/.config/nvim/plugged/vim-snippets/UltiSnips/jinja2.snippets b/skel/.config/nvim/plugged/vim-snippets/UltiSnips/jinja2.snippets new file mode 100644 index 0000000..6fef6ed --- /dev/null +++ b/skel/.config/nvim/plugged/vim-snippets/UltiSnips/jinja2.snippets @@ -0,0 +1,209 @@ + +# http://jinja.pocoo.org/ + +# jinja2 is a full featured template engine for Python. It has full +# unicode support, an optional integrated sandboxed execution +# environment, widely used and BSD licensed. + +# possible extends: +#extends html + + +snippet block "block" b +{% block ${1:name} %} + $2 +{% endblock $1 %} +endsnippet + + +snippet {{ "variable" b +{{ $1 }} +endsnippet + + +snippet {# "comment" b +{# $1 #} +endsnippet + + +snippet # "comment" b +{# $1 #} +endsnippet + + +snippet raw "escaped block" b +{% raw %} + $1 +{% endraw %} +endsnippet + + +snippet extends "extends" b +{% extends "${1:template}" %} +endsnippet + + +snippet include "include" b +{% include "${1:template}" %} +endsnippet + + +snippet import "import" b +{% import "${1:template}" %} +endsnippet + + +snippet from "from/import/as" b +{% from "${1:template}" import ${2:name}${3: as ${4:$2}} %} +endsnippet + + +snippet filter "filter" b +{% filter ${1:filter} %} + $2 +{% endfilter %} +endsnippet + + +# Being able to quickly remove the whole 'else' block seems faster to me than +# choosing between 'for' and 'for/else' snippets from the menu. +# snippet for "for" b +# {% for ${1:item} in ${2:sequence} %} +# $3${4: +# {% else %} +# $5} +# {% endfor %} +# endsnippet + + +snippet for "for" b +{% for ${1:item} in ${2:sequence} %} + $3 +{% endfor %} +endsnippet + + +snippet for "for/else" b +{% for ${1:item} in ${2:sequence} %} + $3 +{% else %} + $4 +{% endfor %} +endsnippet + + +snippet if "if" b +{% if ${1:expr} %} + $2 +{% endif %} +endsnippet + + +snippet if "if/else" b +{% if ${1:expr} %} + $2 +{% else %} + $3 +{% endif %} +endsnippet + + +snippet if "if/elif/else" b +{% if ${1:expr} %} + $2 +{% elif %} + $3 +{% else %} + $4 +{% endif %} +endsnippet + + +snippet macro "macro" b +{% macro ${1:name}(${2:args}) %} + $3 +{% endmacro %} +endsnippet + + +snippet call "call" b +{% call ${1:name}(${2:args}) %} + $3 +{% endcall %} +endsnippet + + +snippet set "set" b +{% set ${1:name} = ${2:'value'} %} +endsnippet + + +snippet trans "translation" b +{% trans %} + $1 +{% endtrans %} +endsnippet + + +snippet with "with" b +{% with %} + $1 +{% endwith %} +endsnippet + + +snippet autoescape "autoescape" b +{% autoescape ${1:true} %} + $2 +{% endautoescape %} +endsnippet + +# Filters +# @todo: expand only when snippet is preceeded by a | + +snippet batch "batch items" w +batch(linecount=$1, fill_with=${2:None}) +endsnippet + + +snippet dictsort "sort and yield (key, value) pairs" w +dictsort(case_sensitive=${1:False}, by=${2:'key'}) +endsnippet + + +snippet round "round number" w +round(precision=${1:0}, method=${2:'common|ceil|floor'}) +endsnippet + + +snippet urlize "convert plain-text url to " w +urlize(trim_url_limit=${1:None}, nofollow=${2:False}) +endsnippet + + +snippet wordwrap "wordwrap" w +wordwrap(width=${1:79}, break_long_words=${2:True}) +endsnippet + + +snippet truncate "truncate" w +truncate(lenght=${1:79}, killwords=${2:False}, end=${3:'...''}) +endsnippet + + +snippet sum "sum of sequence of numbers + start" w +sum(attribute=${1:None}, start=${2:0}) +endsnippet + + +snippet sort "sort an iterable" w +sort(reverse=${1:False}, case_sensitive=${2:False}, attribute=${3:None}) +endsnippet + + +snippet indent "indent" w +indent(width=${1:4}, indentfirst=${2:False}) +endsnippet + + +# vim:ft=snippets: diff --git a/skel/.config/nvim/plugged/vim-snippets/UltiSnips/json.snippets b/skel/.config/nvim/plugged/vim-snippets/UltiSnips/json.snippets new file mode 100644 index 0000000..81e6561 --- /dev/null +++ b/skel/.config/nvim/plugged/vim-snippets/UltiSnips/json.snippets @@ -0,0 +1,19 @@ +snippet s "String" b +"${1:key}": "${0:value}", +endsnippet + +snippet n "number" b +"${1:key}": ${0:value}, +endsnippet + +snippet a "Array" b +[ + ${VISUAL}$0 +], +endsnippet +snippet o "Object" b +{ + ${VISUAL}$0 +}, +endsnippet + diff --git a/skel/.config/nvim/plugged/vim-snippets/UltiSnips/lua.snippets b/skel/.config/nvim/plugged/vim-snippets/UltiSnips/lua.snippets new file mode 100644 index 0000000..1b82a24 --- /dev/null +++ b/skel/.config/nvim/plugged/vim-snippets/UltiSnips/lua.snippets @@ -0,0 +1,37 @@ +################################# +# Snippets for the Lua language # +################################# +snippet #! "Shebang header" b +#!/usr/bin/env lua +$0 +endsnippet + +snippet !fun(ction)?! "New function" br +function ${1:new_function}(${2:args}) + $0 +end +endsnippet + +snippet forp "pair for loop" b +for ${1:name},${2:val} in pairs(${3:table_name}) do + $0 +end +endsnippet + +snippet fori "ipair for foop" b +for ${1:idx},${2:val} in ipairs(${3:table_name}) do + $0 +end +endsnippet + +snippet for "numeric for loop" b +for ${1:i}=${2:first},${3:last}${4/^..*/(?0:,:)/}${4:step} do + $0 +end +endsnippet + +snippet local "local x = 1" +local ${1:x} = ${0:1} +endsnippet + +# vim:ft=snippets: diff --git a/skel/.config/nvim/plugged/vim-snippets/UltiSnips/mako.snippets b/skel/.config/nvim/plugged/vim-snippets/UltiSnips/mako.snippets new file mode 100644 index 0000000..92a7be3 --- /dev/null +++ b/skel/.config/nvim/plugged/vim-snippets/UltiSnips/mako.snippets @@ -0,0 +1,90 @@ +################# +# From snipmate # +################# +snippet def "definition" b +<%def name="${1:name}"> + ${2:} + +endsnippet + +snippet call "call" b +<%call expr="${1:name}"> + ${2:} + +endsnippet + +snippet doc "doc" b +<%doc> + ${1:} + +endsnippet + +snippet text "text" b +<%text> + ${1:} + +endsnippet + +snippet for "for" b +% for ${1:i} in ${2:iter}: + ${3:} +% endfor +endsnippet + +snippet if "if " b +% if ${1:condition}: + ${2:} +% endif +endsnippet + +snippet if "if/else" b +% if ${1:condition}: + ${2:} +% else: + ${3:} +% endif +endsnippet + +snippet try "try" b +% try: + ${1:} +% except${2:}: + ${3:pass} +% endtry +endsnippet + +snippet wh "wh" b +% while ${1:}: + ${2:} +% endwhile +endsnippet + +snippet $ "$" i +${${1:}} +endsnippet + +snippet <% "<%" b +<% ${1:} %> +endsnippet + +snippet +endsnippet + +snippet inherit "inherit" b +<%inherit file="${1:filename}" /> +endsnippet + +snippet include "include" b +<%include file="${1:filename}" /> +endsnippet + +snippet namespace "namespace" b +<%namespace file="${1:name}" /> +endsnippet + +snippet page "page" b +<%page args="${1:}" /> +endsnippet + +# vim:ft=snippets: diff --git a/skel/.config/nvim/plugged/vim-snippets/UltiSnips/markdown.snippets b/skel/.config/nvim/plugged/vim-snippets/UltiSnips/markdown.snippets new file mode 100644 index 0000000..c3189b8 --- /dev/null +++ b/skel/.config/nvim/plugged/vim-snippets/UltiSnips/markdown.snippets @@ -0,0 +1,44 @@ +########################################################################### +# SNIPPETS for MARKDOWN # +########################################################################### + +########################### +# Sections and Paragraphs # +########################### +snippet sec "Section" b +# ${1:Section Name} # +$0 +endsnippet + +snippet ssec "Sub Section" b +## ${1:Section Name} ## +$0 +endsnippet + +snippet sssec "SubSub Section" b +### ${1:Section Name} ### +$0 +endsnippet + +snippet par "Paragraph" b +#### ${1:Paragraph Name} #### +$0 +endsnippet + +snippet spar "Paragraph" b +##### ${1:Paragraph Name} ##### +$0 +endsnippet + +################ +# Common stuff # +################ +snippet link "Link to something" +[${1:${VISUAL:Text}}](${3:http://${2:www.url.com}})$0 +endsnippet + +snippet img "Image" +![${1:pic alt}](${2:path}${3/.+/ "/}${3:opt title}${3/.+/"/})$0 +endsnippet + +# vim:ft=snippets: diff --git a/skel/.config/nvim/plugged/vim-snippets/UltiSnips/objc.snippets b/skel/.config/nvim/plugged/vim-snippets/UltiSnips/objc.snippets new file mode 100644 index 0000000..0c67664 --- /dev/null +++ b/skel/.config/nvim/plugged/vim-snippets/UltiSnips/objc.snippets @@ -0,0 +1,270 @@ +########################################################################### +# TextMate Snippets # +########################################################################### + +snippet imp "#import (imp)" b +#import "${1:`!p snip.rv = re.sub(r'\..*$', '.h', fn)`}" +endsnippet + +snippet Imp "#import <> (Imp)" +#import <${1:Cocoa/Cocoa.h}> +endsnippet + +snippet cl "020 Class (objc)" +@interface ${1:`!p +if len(fn): + snip.rv = re.sub(r'\..*$', '', fn) +else: + snip.rv = "object" +`} : ${2:NSObject} +{ +} +@end + +@implementation $1 +- (id)init +{ + if((self = [super init])) + {$0 + } + return self; +} +@end +endsnippet + +snippet array "NSArray (array)" +NSMutableArray *${1:array} = [NSMutableArray array]; +endsnippet + +snippet dict "NSDictionary (dict)" +NSMutableDictionary *${1:dict} = [NSMutableDictionary dictionary]; +endsnippet + +snippet forarray "for NSArray loop (forarray)" +unsigned int ${1:object}Count = [${2:array} count]; + +for(unsigned int index = 0; index < $1Count; index += 1) +{ + ${3:id} $1 = [$2 objectAtIndex:index]; + $0 +} +endsnippet + +snippet objacc "Object Accessors (objacc)" +- (${1:id})${2:thing} +{ + return $2; +} + +- (void)set${2/./\u$0/}:($1)aValue +{ + $0${1/( \*)?$/(?1:$1: )/}old${2/./\u$0/} = $2; + $2 = [aValue retain]; + [old${2/./\u$0/} release]; +} +endsnippet + +snippet sel "@selector" +@selector(${1:method}:) +endsnippet + +snippet cdacc "CoreData Accessors Implementation" +- (${1:id})${2:attribute} +{ + [self willAccessValueForKey:@"$2"]; + $1 value = [self primitiveValueForKey:@"$2"]; + [self didAccessValueForKey:@"$2"]; + return value; +} + +- (void)set${2/./\u$0/}:($1)aValue +{ + [self willChangeValueForKey:@"$2"]; + [self setPrimitiveValue:aValue forKey:@"$2"]; + [self didChangeValueForKey:@"$2"]; +} +endsnippet + +snippet delegate "Delegate Responds to Selector" +if([${1:[self delegate]} respondsToSelector:@selector(${2:selfDidSomething:})]) + [$1 ${3:${2/((^\s*([A-Za-z0-9_]*:)\s*)|(:\s*$)|(:\s*))/(?2:$2self :\:<>)(?4::)(?5: :)/g}}]; + +endsnippet + +snippet thread "Detach New NSThread" +[NSThread detachNewThreadSelector:@selector(${1:method}:) toTarget:${2:aTarget} withObject:${3:anArgument}] +endsnippet + +snippet ibo "IBOutlet (ibo)" +IBOutlet ${1:NSSomeClass} *${2:${1/^[A-Z](?:[A-Z]+|[a-z]+)([A-Z]\w*)/\l$1/}}; +endsnippet + +snippet I "Initialize Implementation (I)" ++ (void)initialize +{ + [[NSUserDefaults standardUserDefaults] registerDefaults:[NSDictionary dictionaryWithObjectsAndKeys: + $0@"value", @"key", + nil]]; +} +endsnippet + +snippet bind "Key:value binding (bind)" +bind:@"${1:binding}" toObject:${2:observableController} withKeyPath:@"${3:keyPath}" options:${4:nil} +endsnippet + +snippet arracc "LoD array (arracc)" +- (void)addObjectTo${1:Things}:(${2:id})anObject +{ + [${3:${1/./\l$0/}} addObject:anObject]; +} + +- (void)insertObject:($2)anObject in$1AtIndex:(unsigned int)i +{ + [$3 insertObject:anObject atIndex:i]; +} + +- ($2)objectIn$1AtIndex:(unsigned int)i +{ + return [$3 objectAtIndex:i]; +} + +- (unsigned int)indexOfObjectIn$1:($2)anObject +{ + return [$3 indexOfObject:anObject]; +} + +- (void)removeObjectFrom$1AtIndex:(unsigned int)i +{ + [$3 removeObjectAtIndex:i]; +} + +- (unsigned int)countOf$1 +{ + return [$3 count]; +} + +- (NSArray *${1/./\l$0/} +{ + return $3; +} + +- (void)set$1:(NSArray *)new$1 +{ + [$3 setArray:new$1]; +} +endsnippet + +snippet arracc "LoD array interface (arracc)" +- (void)addObjectTo${1:Things}:(${2:id})anObject; +- (void)insertObject:($2)anObject in$1AtIndex:(unsigned int)i; +- ($2)objectIn$1AtIndex:(unsigned int)i; +- (unsigned int)indexOfObjectIn$1:($2)anObject; +- (void)removeObjectFrom$1AtIndex:(unsigned int)i; +- (unsigned int)countOf$1; +- (NSArray *)${1/./\l$0/}; +- (void)set$1:(NSArray *)new$1; +endsnippet + +snippet focus "Lock Focus" +[self lockFocus]; +$0 +[self unlockFocus]; +endsnippet + +snippet pool "NSAutoreleasePool (pool)" +NSAutoreleasePool *pool = [NSAutoreleasePool new]; +$0 +[pool drain]; +endsnippet + +snippet log "NSLog (log) 2" +NSLog(@"$1"${1/[^%]*(%)?.*/(?1:, :\);)/}$2${1/[^%]*(%)?.*/(?1:\);)/} +endsnippet + +snippet alert "NSRunAlertPanel (alert)" +int choice = NSRunAlertPanel(@"${1:Something important!}", @"${2:Something important just happend, and now I need to ask you, do you want to continue?}", @"${3:Continue}", @"${4:Cancel}", nil); +if(choice == NSAlertDefaultReturn) // "$3" +{ + $0; +} +else if(choice == NSAlertAlternateReturn) // "$4" +{ + +} +endsnippet + +snippet format "NSString stringWithFormat (format)" +[NSString stringWithFormat:@"$1", $2]$0 +endsnippet + +snippet objacc "Object Accessors Interface (objacc)" +- (${1:id})${2:thing}; +- (void)set${2/./\u$0/}:($1)aValue; +endsnippet + +snippet prop "Property" +@property (${1/^(e)$|.*/(?1:r)/}${1:r}${1/^(?:(r)|(e)|(c)|(a))$|.*/(?1:etain)(?2:adonly)(?3:opy)(?4:ssign)/}) ${2:NSSomeClass}$ *${3:${2/^[A-Z](?:[A-Z]+|[a-z]+)([A-Z]\w*)/\l$1/}}; +endsnippet + +snippet getprefs "Read from defaults (getprefs)" +[[NSUserDefaults standardUserDefaults] objectForKey:${1:key}]; +endsnippet + +snippet obs "Register for Notification" +[[NSNotificationCenter defaultCenter] addObserver:${1:self} selector:@selector(${3:${2/^([A-Z]{2})?(.+?)(Notification)?$/\l$2/}}:) name:${2:NSWindowDidBecomeMainNotification} object:${4:nil}]; +endsnippet + +snippet responds "Responds to Selector" +if ([${1:self} respondsToSelector:@selector(${2:someSelector:})]) +{ + [$1 ${3:${2/((:\s*$)|(:\s*))/:<>(?3: )/g}}]; +} +endsnippet + +snippet gsave "Save and Restore Graphics Context (gsave)" +[NSGraphicsContext saveGraphicsState]; +$0 +[NSGraphicsContext restoreGraphicsState]; + +endsnippet + +snippet acc "Scalar Accessors (acc)" +- (${1:unsigned int})${2:thing} +{ + return ${3:$2}; +} + +- (void)set${2/./\u$0/}:(${1:unsigned int})new${2/./\u$0/} +{ + $3 = new${2/./\u$0/}; +} +endsnippet + +snippet acc "Scalar Accessors Interface (acc)" +- (${1:unsigned int})${2:thing}; +- (void)set${2/./\u$0/}:($1)new${2/./\u$0/}; +endsnippet + +snippet stracc "String Accessors (stracc)" +- (NSString *)${1:thing} +{ + return ${2:$1}; +} + +- (void)set${1/.*/\u$0/}:(NSString *)/})${3:a${1/.*/\u$0/}} +{ + $3 = [$3 copy]; + [$2 release]; + $2 = $3; +} +endsnippet + +snippet syn "Synthesize" +@synthesize ${1:property}; +endsnippet + +snippet setprefs "Write to defaults (setprefs)" +[[NSUserDefaults standardUserDefaults] setObject:${1:object} forKey:${2:key}]; +endsnippet + +# vim:ft=snippets: diff --git a/skel/.config/nvim/plugged/vim-snippets/UltiSnips/ocaml.snippets b/skel/.config/nvim/plugged/vim-snippets/UltiSnips/ocaml.snippets new file mode 100644 index 0000000..157eb91 --- /dev/null +++ b/skel/.config/nvim/plugged/vim-snippets/UltiSnips/ocaml.snippets @@ -0,0 +1,167 @@ +snippet rs "raise" b +raise (${1:Not_found}) +endsnippet + +snippet open "open" +let open ${1:module} in +${2} +endsnippet + +snippet try "try" +try ${1} +with ${2:Not_found} -> ${3:()} +endsnippet + +snippet ref "ref" +let ${1} = ref ${2} in +${3} +endsnippet + +snippet matchl "pattern match on a list" +match ${1:list} with +| [] -> ${2:()} +| x::xs -> ${3:()} +endsnippet + +snippet matcho "pattern match on an option type" +match ${1} with +| Some(${2}) -> ${3:()} +| None -> ${4:()} +endsnippet + +snippet fun "anonymous function" +(fun ${1} -> ${2}) +endsnippet + +snippet cc "commment" +(* ${1} *) +endsnippet + +snippet let "let .. in binding" +let ${1} = ${2} in +${3} +endsnippet + +snippet lr "let rec" +let rec ${1} = + ${2} +endsnippet + +snippet ife "if" +if ${1} then + ${2} +else + ${3} +endsnippet + +snippet if "If" +if ${1} then + ${2} +endsnippet + +snippet wh "while" +while ${1} do + ${2} +done +endsnippet + +snippet for "for" +for ${1:i} = ${2:1} to ${3:10} do + ${4} +done +endsnippet + +snippet match "match" +match ${1} with +| ${2} -> ${3} +endsnippet + +snippet class "class" +class ${1:name} = object + ${2} +end +endsnippet + +snippet obj "obj" +object + ${2} +end +endsnippet + +snippet Obj "object" +object (self) + ${2} +end +endsnippet + +snippet {{ "object functional update" +{< ${1} = ${2} >} +endsnippet + +snippet beg "beg" +begin + ${1}${VISUAL} +end +endsnippet + +snippet ml "module instantiantion with functor" +module ${1:Mod} = ${2:Functor}(${3:Arg}) +endsnippet + +snippet mod "module - no signature" +module ${1:(* Name *)} = struct + ${2} +end +endsnippet + +snippet Mod "module with signature" +module ${1:(* Name *)} : ${2:(* SIG *)} = struct + ${3} +end +endsnippet + +snippet sig "anonymous signature" +sig + ${2} +end +endsnippet + +snippet sigf "functor signature or anonymous functor" +functor (${1:Arg} : ${2:ARG}) -> ${3:(* BODY *)} +endsnippet + +snippet func "define functor - no signature" +module ${1:M} (${2:Arg} : ${3:ARG}) = struct + ${4} +end +endsnippet + +snippet Func "define functor - with signature" +module ${1:M} (${2:Arg} : ${3:ARG}) : ${4:SIG} = struct + ${5} +end +endsnippet + +snippet mot "Declare module signature" +module type ${1:(* Name *)} = sig + ${2} +end +endsnippet + +snippet module "Module with anonymous signature" +module ${1:(* Name *)} : sig + ${2} +end = struct + ${3} +end +endsnippet + +snippet oo "odoc" +(** ${1} *) +endsnippet + +snippet qt "inline qtest" +(*$T ${1:name} + ${2:test} +*) +endsnippet diff --git a/skel/.config/nvim/plugged/vim-snippets/UltiSnips/perl.snippets b/skel/.config/nvim/plugged/vim-snippets/UltiSnips/perl.snippets new file mode 100644 index 0000000..e183b11 --- /dev/null +++ b/skel/.config/nvim/plugged/vim-snippets/UltiSnips/perl.snippets @@ -0,0 +1,127 @@ +########################################################################### +# TextMate Snippets # +########################################################################### +snippet ife "Conditional if..else (ife)" +if ($1) { + ${2:# body...} +} else { + ${3:# else...} +} + +endsnippet + +snippet ifee "Conditional if..elsif..else (ifee)" +if ($1) { + ${2:# body...} +} elsif ($3) { + ${4:# elsif...} +} else { + ${5:# else...} +} + +endsnippet + +snippet xunless "Conditional one-line (unless)" +${1:expression} unless ${2:condition}; + +endsnippet + +snippet xif "Conditional one-line (xif)" +${1:expression} if ${2:condition}; + +endsnippet + +snippet sub "Function (sub)" +sub ${1:function_name} { + ${2:# body...} +} + +endsnippet + +snippet xfore "Loop one-line (xforeach)" +${1:expression} foreach @${2:array}; + +endsnippet + +snippet xwhile "Loop one-line (xwhile)" +${1:expression} while ${2:condition}; + +endsnippet + +snippet test "Test" +#!/usr/bin/perl -w + +use strict; +use Test::More tests => ${1:1}; +use ${2:ModuleName}; + +ok(${3:assertion}); + +endsnippet + +snippet class "class" +package ${1:ClassName}; + +${2:use base qw(${3:ParentClass});}${2/.+/\n\n/}sub new { + my $class = shift; + $class = ref $class if ref $class; + my $self = bless {}, $class; + $self; +} + +1; + +endsnippet + +snippet eval "eval" +eval { + ${1:# do something risky...} +}; +if ($@) { + ${2:# handle failure...} +} + +endsnippet + +snippet for "for" +for (my $${1:var} = 0; $$1 < ${2:expression}; $$1++) { + ${3:# body...} +} + +endsnippet + +snippet fore "foreach" +foreach ${1:my $${2:x}} (@${3:array}) { + ${4:# body...} +} + +endsnippet + +snippet if "if" +if ($1) { + ${2:# body...} +} + +endsnippet + +snippet slurp "slurp" +my $${1:var}; +{ local $/ = undef; local *FILE; open FILE, "<${2:file}"; $$1 = ; close FILE } + +endsnippet + +snippet unless "unless" +unless ($1) { + ${2:# body...} +} + +endsnippet + +snippet wh "while" +while ($1) { + ${2:# body...} +} + +endsnippet + +# vim:ft=snippets: diff --git a/skel/.config/nvim/plugged/vim-snippets/UltiSnips/php.snippets b/skel/.config/nvim/plugged/vim-snippets/UltiSnips/php.snippets new file mode 100644 index 0000000..b7d0167 --- /dev/null +++ b/skel/.config/nvim/plugged/vim-snippets/UltiSnips/php.snippets @@ -0,0 +1,108 @@ +snippet $2 = $$2; + + return $this; +} + +public function get`!p snip.rv = t[2][0:1].upper() + t[2][1:]`() +{ + return $this->$2; +} +endsnippet + +snippet if "php if" !b +if (${1}) { + ${2} +} +endsnippet + +snippet ife "php ife" !b +if (${1}) { + ${2} +} else { + +} +endsnippet + +snippet /** "php comment block" b +/** + * @${1} + */ +endsnippet diff --git a/skel/.config/nvim/plugged/vim-snippets/UltiSnips/php/phpunit.snippets b/skel/.config/nvim/plugged/vim-snippets/UltiSnips/php/phpunit.snippets new file mode 100644 index 0000000..6609f3f --- /dev/null +++ b/skel/.config/nvim/plugged/vim-snippets/UltiSnips/php/phpunit.snippets @@ -0,0 +1,30 @@ +# sugguestion? report bugs? +# please go to https://github.com/chrisyue/vim-snippets/issues +snippet test "phpunit test class" b +namespace `!p +abspath = os.path.abspath(path) +m = re.search(r'[A-Z].+(?=/)', abspath) +if m: + snip.rv = m.group().replace('/', '\\') +`; + +/** + * @author `whoami` + */ +class `!p +snip.rv = re.match(r'.*(?=\.)', fn).group() +` extends \PHPUnit_Framework_TestCase +{ + public function test${1}() + { + ${2} + } +} +endsnippet + +snippet exp "phpunit expects" i +expects($this->${1:once}()) + ->method('${2}') + ->with($this->equalTo(${3})${4}) + ->will($this->returnValue(${5})); +endsnippet diff --git a/skel/.config/nvim/plugged/vim-snippets/UltiSnips/php/symfony2.snippets b/skel/.config/nvim/plugged/vim-snippets/UltiSnips/php/symfony2.snippets new file mode 100644 index 0000000..b5ff0ee --- /dev/null +++ b/skel/.config/nvim/plugged/vim-snippets/UltiSnips/php/symfony2.snippets @@ -0,0 +1,237 @@ +# sugguestion? report bugs? +# go to https://github.com/chrisyue/vim-snippets/issues + +snippet contr "symfony2 controller" b +namespace `!p +abspath = os.path.abspath(path) +m = re.search(r'[A-Z].+(?=/)', abspath) +if m: + snip.rv = m.group().replace('/', '\\') +`; + +use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method; +use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; +use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template; +use Symfony\Bundle\FrameworkBundle\Controller\Controller; +use Symfony\Component\HttpFoundation\Request; + +/** + * ${1:@author `whoami`} + */ +class `!p +snip.rv = re.match(r'.*(?=\.)', fn).group() +` extends Controller +{ +} +endsnippet + +snippet act "symfony2 action" b +/** + * @Route("${3}", name="${4}") + * @Method({${5:"POST"}}) + */ +public function ${1}Action(${2}) +{ + ${6} + return $this->redirect($this->generateUrl('home', [], false)); +} +endsnippet + +snippet actt "symfony2 action and template" b +/** + * @Route("${3}", name="${4}") + * @Method({${5:"GET"}}) + * @Template() + */ +public function ${1}Action(${2}) +{ + ${6} + return []; +}`!p +abspath = os.path.abspath(path)` +endsnippet + +snippet comm "symfony2 command" b +namespace `!p +abspath = os.path.abspath(path) +m = re.search(r'[A-Z].+(?=/)', abspath) +if m: + snip.rv = m.group().replace('/', '\\') +`; + +use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; +use Symfony\Component\Console\Input\InputArgument; +use Symfony\Component\Console\Input\InputOption; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Output\OutputInterface; + +/** + * ${3:@author `whoami`} + */ +class `!p +snip.rv = re.match(r'.*(?=\.)', fn).group() +` extends ContainerAwareCommand +{ + protected function configure() + { + $this + ->setName('${1}') + ->setDescription('${2}') + ->setDefinition([ + new InputArgument('', InputArgument::REQUIRED, ''), + new InputOption('', null, InputOption::VALUE_NONE, ''), + ]) + ; + } + + protected function execute(InputInterface $input, OutputInterface $output) + { + } +} +endsnippet + +snippet subs "symfony2 subscriber" b +namespace `!p +abspath = os.path.abspath(path) +m = re.search(r'[A-Z].+(?=/)', abspath) +if m: + snip.rv = m.group().replace('/', '\\') +`; + +use Symfony\Component\EventDispatcher\EventSubscriberInterface; + +/** + * ${1:@author `whoami`} + */ +class `!p +snip.rv = re.match(r'.*(?=\.)', fn).group() +` implements EventSubscriberInterface +{ + public function __construct() + { + } + + /** + * {@inheritDoc} + */ + public static function getSubscribedEvents() + { + return []; + } +} +endsnippet + +snippet transf "symfony2 form data transformer" b +namespace `!p +abspath = os.path.abspath(path) +m = re.search(r'[A-Z].+(?=/)', abspath) +if m: + snip.rv = m.group().replace('/', '\\') +`; + +use Symfony\Component\Form\DataTransformerInterface; +use Symfony\Component\Form\Exception\TransformationFailedException; + +/** + * ${3:@author `whoami`} + */ +class `!p +snip.rv = re.match(r'.*(?=\.)', fn).group() +` implements DataTransformerInterface +{ + /** + * {@inheritDoc} + */ + public function transform(${1}) + { + } + + /** + * {@inheritDoc} + */ + public function reverseTransform(${2}) + { + } +} +endsnippet + +snippet ent "symfony2 doctrine entity" b +namespace `!p +abspath = os.path.abspath(path) +m = re.search(r'[A-Z].+(?=/)', abspath) +if m: + snip.rv = m.group().replace('/', '\\') +`; + +use Doctrine\ORM\Mapping as ORM; + +/** + * ${3:@author `whoami`} + * + * @ORM\Entity() + * @ORM\Table(name="`!p +tmp = re.match(r'.*(?=\.)', fn).group() +tmp = re.sub(r'\B([A-Z])', r'_\1', tmp) +snip.rv = tmp.lower() +`") + */ +`!p +m = re.search(r'Abstract', path) +if m: + snip.rv = 'abstract ' +`class `!p +snip.rv = re.match(r'.*(?=\.)', fn).group() +` +{ + /** + * @ORM\Column(type="integer") + * @ORM\GeneratedValue + * @ORM\Id + */ + private $id; +} +endsnippet + +snippet form "symfony2 form type" b +namespace `!p +abspath = os.path.abspath(path) +m = re.search(r'[A-Z].+(?=/)', abspath) +if m: + snip.rv = m.group().replace('/', '\\') +`; + +use Symfony\Component\Form\AbstractType; +use Symfony\Component\Form\FormBuilderInterface; +use Symfony\Component\OptionsResolver\OptionsResolverInterface; + +/** + * ${2:@author `whoami`} + */ +class `!p +snip.rv = re.match(r'.*(?=\.)', fn).group() +` extends AbstractType +{ + /** + * {@inheritDoc} + */ + public function buildForm(FormBuilderInterface $builder, array $options) + { + } + + /** + * {@inheritDoc} + */ + public function setDefaultOptions(OptionsResolverInterface $resolver) + { + $resolver->setDefaults(); + } + + /** + * {@inheritDoc} + */ + public function getName() + { + return '${1}'; + } +} +endsnippet diff --git a/skel/.config/nvim/plugged/vim-snippets/UltiSnips/puppet.snippets b/skel/.config/nvim/plugged/vim-snippets/UltiSnips/puppet.snippets new file mode 100644 index 0000000..68ae0fe --- /dev/null +++ b/skel/.config/nvim/plugged/vim-snippets/UltiSnips/puppet.snippets @@ -0,0 +1,78 @@ +# Snippets for Puppet + +snippet /^class/ "Class declaration" r +class ${1:name} { + ${0:# body} +} +endsnippet + +snippet File "Defaults for file" b +File { + owner => ${1:username}, + group => ${2:groupname}, +} +endsnippet + +# Resource types +snippet package "Package resource type" b +package { "${1:name}": + ensure => ${2:installed}, +} +endsnippet + +snippet file "File resource type" b +file { "${1:name}": + source => "puppet://${2:path}", + mode => ${3:mode}, +endsnippet + +snippet group "Group resource type" b +group { "${1:groupname}": + ensure => ${3:present}, + gid => ${2:gid}, +endsnippet + +snippet user "user resource type" b +group { "${1:username}": + ensure => ${2:present}, + uid => ${3:uid}, + gid => ${4:gid}, + comment => ${5:gecos}, + home => ${6:homedirectory}, + managehome => false, + require => Group["${7:group"], +endsnippet + +snippet exec "Exec resource type" b +exec { "${1:command}": + refreshonly => true, +} +endsnippet + +snippet cron "Cron resource type" b +cron { "${1:name}": + user => ${2:user}, + command => "${3:command}", + minute => ${3:minute}, + hour => ${4:hour}, +} +endsnippet + +snippet mount "Mount resource type" b +mount { "${1:path}": + device => "${2:/dev}", + fstype => "${3:filesystem}", + ensure => mounted, + options => "rw,errors=remount-ro", +} +endsnippet + +snippet service "Service resource type" b +service { "${1:name}": + hasstatus => true, + enable => true, + ensure => running, +} +endsnippet + +# vim:ft=snippets: diff --git a/skel/.config/nvim/plugged/vim-snippets/UltiSnips/python.snippets b/skel/.config/nvim/plugged/vim-snippets/UltiSnips/python.snippets new file mode 100644 index 0000000..a770d2a --- /dev/null +++ b/skel/.config/nvim/plugged/vim-snippets/UltiSnips/python.snippets @@ -0,0 +1,468 @@ +########################################################################### +# TEXTMATE SNIPPETS # +########################################################################### + +#! header +snippet #! "Shebang header for python scripts" b +#!/usr/bin/env python +# encoding: utf-8 +$0 +endsnippet + +snippet ifmain "ifmain" b +if __name__ == '__main__': + ${1:main()}$0 +endsnippet + + +########## +# COMMON # +########## + +# The smart def and smart class snippets use a global option called +# "g:ultisnips_python_style" which, if set to "doxygen" will use doxygen +# style comments in docstrings. + +global !p + +NORMAL = 0x1 +DOXYGEN = 0x2 +SPHINX = 0x3 + +def get_args(arglist): + args = [arg.split('=')[0].strip() for arg in arglist.split(',') if arg] + args = [arg for arg in args if arg and arg != "self"] + + return args + + +def get_style(snip): + style = snip.opt("g:ultisnips_python_style", "normal") + + if style == "doxygen": return DOXYGEN + elif style == "sphinx": return SPHINX + else: return NORMAL + + +def format_arg(arg, style): + if style == DOXYGEN: + return "@param %s @todo" % arg + elif style == SPHINX: + return ":param %s: @todo" % arg + elif style == NORMAL: + return ":%s: @todo" % arg + + +def format_return(style): + if style == DOXYGEN: + return "@return: @todo" + elif style in (NORMAL, SPHINX): + return ":returns: @todo" + + +def write_docstring_args(args, snip): + if not args: + snip.rv += ' """' + return + + snip.rv += '\n' + snip.mkline('', indent='') + + style = get_style(snip) + + for arg in args: + snip += format_arg(arg, style) + + +def write_init_body(args, parents, snip): + parents = [p.strip() for p in parents.split(",")] + parents = [p for p in parents if p != 'object'] + + for p in parents: + snip += p + ".__init__(self)" + + if parents: + snip.rv += '\n' + snip.mkline('', indent='') + + for arg in args: + snip += "self._%s = %s" % (arg, arg) + + +def write_slots_args(args, snip): + args = ['"%s"' % arg for arg in args] + snip += '__slots__ = (%s,)' % ', '.join(args) + +endglobal + +######################################## +# Class & Special Method Name Snippets # +######################################## + +snippet class "class with docstrings" b +class ${1:MyClass}(${2:object}): + """${3:Docstring for $1 }""" + + def __init__(self$4): + """${5:@todo: to be defined}`!p +snip.rv = "" +snip >> 2 + +args = get_args(t[4]) + +write_docstring_args(args, snip) +if args: + snip.rv += '\n' + snip.mkline('', indent='') + snip += '"""' + +write_init_body(args, t[2], snip) +` + $0 +endsnippet + + +snippet slotclass "class with slots and docstrings" b +class ${1:MyClass}(${2:object}): + """${3:Docstring for $1 }""" +`!p +snip >> 1 +args = get_args(t[4]) +write_slots_args(args, snip) +` + + def __init__(self$4): + """${5:@todo: to be defined}`!p +snip.rv = "" +snip >> 2 + +args = get_args(t[4]) + +write_docstring_args(args, snip) +if args: + snip.rv += '\n' + snip.mkline('', indent='') + snip += '"""' + +write_init_body(args, t[2], snip) +` + $0 +endsnippet + + +snippet contain "methods for emulating a container type" b +def __len__(self): + ${1:pass} + +def __getitem__(self, key): + ${2:pass} + +def __setitem__(self, key, value): + ${3:pass} + +def __delitem__(self, key): + ${4:pass} + +def __iter__(self): + ${5:pass} + +def __reversed__(self): + ${6:pass} + +def __contains__(self, item): + ${7:pass} +endsnippet + + +snippet context "context manager methods" b +def __enter__(self): + ${1:pass} + +def __exit__(self, exc_type, exc_value, traceback): + ${2:pass} +endsnippet + + +snippet attr "methods for customizing attribute access" b +def __getattr__(self, name): + ${1:pass} + +def __setattr__(self, name, value): + ${2:pass} + +def __delattr__(self, name): + ${3:pass} +endsnippet + + +snippet desc "methods implementing descriptors" b +def __get__(self, instance, owner): + ${1:pass} + +def __set__(self, instance, value): + ${2:pass} + +def __delete__(self, instance): + ${3:pass} +endsnippet + + +snippet cmp "methods implementing rich comparison" +def __eq__(self, other): + ${1:pass} + +def __ne__(self, other): + ${2:pass} + +def __lt__(self, other): + ${3:pass} + +def __le__(self, other): + ${4:pass} + +def __gt__(self, other): + ${5:pass} + +def __ge__(self, other): + ${6:pass} + +def __cmp__(self, other): + ${7:pass} +endsnippet + + +snippet repr "methods implementing string representation" +def __repr__(self): + ${1:pass} + +def __str__(self): + ${2:pass} + +def __unicode__(self): + ${3:pass} +endsnippet + + +# note: reflected operands and augmented arithmeitc assignements have been +# intentionally ommited to reduce verbosity. +snippet numeric "methods for emulating a numeric type" b +def __add__(self, other): + ${1:pass} + +def __sub__(self, other): + ${2:pass} + +def __mul__(self, other): + ${3:pass} + +def __div__(self, other): + ${4:pass} + +def __truediv__(self, other): + ${5:pass} + +def __floordiv__(self, other): + ${6:pass} + + +def __mod__(self, other): + ${7:pass} + +def __divmod__(self, other): + ${8:pass} + +def __pow__(self, other): + ${9:pass} + + +def __lshift__(self, other): + ${10:pass} + +def __rshift__(self, other): + ${11:pass} + +def __and__(self, other): + ${12:pass} + +def __xor__(self, other): + ${13:pass} + +def __or__(self, other): + ${14:pass} + + +def __neg__(self): + ${15:pass} + +def __pos__(self): + ${16:pass} + +def __abs__(self): + ${17:pass} + +def __invert__(self): + ${18:pass} + + +def __complex__(self): + ${19:pass} + +def __int__(self): + ${20:pass} + +def __long__(self): + ${21:pass} + +def __float__(self): + ${22:pass} + + +def __oct__(self): + ${22:pass} + +def __hex__(self): + ${23:pass} + + +def __index__(self): + ${24:pass} + +def __coerce__(self, other): + ${25:pass} +endsnippet + +snippet def "function with docstrings" b +def ${1:function}(`!p +if snip.indent: + snip.rv = 'self' + (", " if len(t[2]) else "")`${2:arg1}): + """${4:@todo: Docstring for $1}`!p +snip.rv = "" +snip >> 1 + +args = get_args(t[2]) +if args: + write_docstring_args(args, snip) + +style = get_style(snip) +snip += format_return(style) +snip.rv += '\n' + snip.mkline('', indent='') +snip += '"""' ` + ${0:pass} +endsnippet + + +# doesn't expand when there is a word in front +snippet /(^|(?<=\W))\./ "self." r +self. +endsnippet + +snippet from "from module import name" b +from ${1:module} import ${2:Stuff} +endsnippet + + +############## +# PROPERTIES # +############## +snippet roprop "Read Only Property" b +@property +def ${1:property}(self): + ${2:return self._$1}$0 +endsnippet + +snippet rwprop "Read write property" b +def ${1:property}(): + ${2/.+/(?0:""")/}${2:The RW property $1}`!p if t[2]: + snip.rv += '"""' + snip >> 1 + snip += "" +else: + snip.rv = ""`def fget(self): + return self._$1$0 + def fset(self, value): + self._$1 = value + return locals() +$1 = property(**$1()) +endsnippet + + +########################## +# Try / Except / Finally # +########################## +snippet try "Try / Except" b +try: + ${1:pass} +except ${2:Exception}, ${3:e}: + ${4:raise $3} +endsnippet + +snippet try "Try / Except / Else" b +try: + ${1:pass} +except ${2:Exception}, ${3:e}: + ${4:raise $3} +else: + ${5:pass} +endsnippet + +snippet try "Try / Except / Finally" b +try: + ${1:pass} +except ${2:Exception}, ${3:e}: + ${4:raise $3} +finally: + ${5:pass} +endsnippet + +snippet try "Try / Except / Else / Finally" b +try: + ${1:pass} +except${2: ${3:Exception}, ${4:e}}: + ${5:raise} +else: + ${6:pass} +finally: + ${7:pass} +endsnippet + + +##################### +# Assertions & Tests # +##################### + +snippet pdb "Set PDB breakpoint" b +import pdb; pdb.set_trace() +endsnippet + +snippet ae "Assert equal" b +self.assertEqual(${1:first},${2:second}) +endsnippet + +snippet at "Assert True" b +self.assertTrue(${0:exp}) +endsnippet + +snippet af "Assert False" b +self.assertFalse(${1:expression}) +endsnippet + +snippet aae "Assert almost equal" b +self.assertAlmostEqual(${1:first},${2:second}) +endsnippet + +snippet ar "Assert raises" b +self.assertRaises(${1:exception}, ${2:func}${3/.+/, /}${3:arguments}) +endsnippet + + +snippet testcase "pyunit testcase" b +class Test${1:Class}(${2:unittest.TestCase}): + """${3:Test case docstring}""" + + def setUp(self): + ${4:pass} + + def tearDown(self): + ${5:pass} + + def test_${6:name}(self): + ${7:pass} +endsnippet + +# vim:ft=snippets: diff --git a/skel/.config/nvim/plugged/vim-snippets/UltiSnips/rails.snippets b/skel/.config/nvim/plugged/vim-snippets/UltiSnips/rails.snippets new file mode 100644 index 0000000..9e0e29f --- /dev/null +++ b/skel/.config/nvim/plugged/vim-snippets/UltiSnips/rails.snippets @@ -0,0 +1,906 @@ +########################################################################### +# GENERATED FROM get_tm_snippets.py # +########################################################################### + +snippet anaf "accepts_nested_attributes_for" +accepts_nested_attributes_for :${1:association_name}${2:${3:, :allow_destroy => true}${4:, :reject_if => proc \{ |obj| ${5:obj.blank?} \}}} + +endsnippet + +snippet tcbi "Create binary column" +t.binary :${1:title}${2:, :limit => ${3:2}.megabytes} +$0 +endsnippet + +snippet tcb "Create boolean column" +t.boolean :${1:title} +$0 +endsnippet + +snippet cla "Create controller class" +class ${1:Model}Controller < ApplicationController + before_filter :find_${2:model} + + $0 + + private + def find_${2} + @$2 = ${3:$1}.find(params[:id]) if params[:id] + end +end +endsnippet + +snippet tcda "Create date column" +t.date :${1:title} +$0 +endsnippet + +snippet tcdt "Create datetime column" +t.datetime :${1:title} +$0 +endsnippet + +snippet tcd "Create decimal column" +t.decimal :${1:title}${2:${3:, :precision => ${4:10}}${5:, :scale => ${6:2}}} +$0 +endsnippet + +snippet tcf "Create float column" +t.float :${1:title} +$0 +endsnippet + +snippet cla "Create functional test class" +require 'test_helper' + +class ${1:Model}ControllerTest < ActionController::TestCase + test$0 +end + +endsnippet + +snippet tci "Create integer column" +t.integer :${1:title} +$0 +endsnippet + +snippet tcl "Create lock_version column" +t.integer :lock_version, :null => false, :default => 0 +$0 +endsnippet + +# FIXME: handling literal bracket pair inside of nested tab groups? +snippet tcr "Create references column" +t.references :${1:taggable}${2:, :polymorphic => ${3:{ :default => '${4:Photo}' \}}} +$0 +endsnippet + +snippet resources "Create resources controller class" +class ${1:Model}sController < ApplicationController + before_filter :find_${1/./\l$0/}, :only => [:show, :edit, :update, :destroy] + + # GET /${1/./\l$0/}s + # GET /${1/./\l$0/}s.xml + def index + @${1/./\l$0/}s = ${1:Model}.all + + respond_to do |wants| + wants.html # index.html.erb + wants.xml { render :xml => @${1/./\l$0/}s } + end + end + + # GET /${1/./\l$0/}s/1 + # GET /${1/./\l$0/}s/1.xml + def show + respond_to do |wants| + wants.html # show.html.erb + wants.xml { render :xml => @${1/./\l$0/} } + end + end + + # GET /${1/./\l$0/}s/new + # GET /${1/./\l$0/}s/new.xml + def new + @${1/./\l$0/} = ${1:Model}.new + + respond_to do |wants| + wants.html # new.html.erb + wants.xml { render :xml => @${1/./\l$0/} } + end + end + + # GET /${1/./\l$0/}s/1/edit + def edit + end + + # POST /${1/./\l$0/}s + # POST /${1/./\l$0/}s.xml + def create + @${1/./\l$0/} = ${1:Model}.new(params[:${1/./\l$0/}]) + + respond_to do |wants| + if @${1/./\l$0/}.save + flash[:notice] = '${1:Model} was successfully created.' + wants.html { redirect_to(@${1/./\l$0/}) } + wants.xml { render :xml => @${1/./\l$0/}, :status => :created, :location => @${1/./\l$0/} } + else + wants.html { render :action => "new" } + wants.xml { render :xml => @${1/./\l$0/}.errors, :status => :unprocessable_entity } + end + end + end + + # PUT /${1/./\l$0/}s/1 + # PUT /${1/./\l$0/}s/1.xml + def update + respond_to do |wants| + if @${1/./\l$0/}.update_attributes(params[:${1/./\l$0/}]) + flash[:notice] = '${1:Model} was successfully updated.' + wants.html { redirect_to(@${1/./\l$0/}) } + wants.xml { head :ok } + else + wants.html { render :action => "edit" } + wants.xml { render :xml => @${1/./\l$0/}.errors, :status => :unprocessable_entity } + end + end + end + + # DELETE /${1/./\l$0/}s/1 + # DELETE /${1/./\l$0/}s/1.xml + def destroy + @${1/./\l$0/}.destroy + + respond_to do |wants| + wants.html { redirect_to(${1/./\l$0/}s_url) } + wants.xml { head :ok } + end + end + + private + def find_${1/./\l$0/} + @${1/./\l$0/} = ${1:Model}.find(params[:id]) + end + +end + +endsnippet + +snippet tcs "Create string column" +t.string :${1:title} +$0 +endsnippet + +snippet tct "Create text column" +t.text :${1:title} +$0 +endsnippet + +snippet tcti "Create time column" +t.time :${1:title} +$0 +endsnippet + +snippet tcts "Create timestamp column" +t.timestamp :${1:title} +$0 +endsnippet + +snippet tctss "Create timestamps columns" +t.timestamps +$0 +endsnippet + +snippet mcol "Migration Create Column (mcc)" +t.column ${1:title}, :${2:string} +$0 +endsnippet + +snippet mccc "Migration Create Column Continue (mccc)" +t.column ${1:title}, :${2:string} +mccc$0 +endsnippet + +snippet mtab "Migration Drop Create Table (mdct)" +drop_table :${1:table}${2: [press tab twice to generate create_table]} +endsnippet + +snippet mcol "Migration Remove and Add Column (mrac)" +remove_column :${1:table}, :${2:column}${3: [press tab twice to generate add_column]} +endsnippet + +snippet rdb "RAILS_DEFAULT_LOGGER.debug (rdb)" +RAILS_DEFAULT_LOGGER.debug "${1:message}"$0 +endsnippet + +snippet tre "Table column(s) rename" +t.rename(:${1:old_column_name}, :${2:new_column_name}) +$0 +endsnippet + +snippet art "Test Assert Redirected To (art)" +assert_redirected_to ${2::action => "${1:index}"} +endsnippet + +snippet asre "Test Assert Response (are)" +assert_response :${1:success}, @response.body$0 +endsnippet + +snippet aftc "after_create" +after_create +endsnippet + +snippet aftd "after_destroy" +after_destroy +endsnippet + +snippet afts "after_save" +after_save +endsnippet + +snippet aftu "after_update" +after_update +endsnippet + +snippet aftv "after_validation" +after_validation +endsnippet + +snippet aftvoc "after_validation_on_create" +after_validation_on_create +endsnippet + +snippet aftvou "after_validation_on_update" +after_validation_on_update +endsnippet + +snippet asg "assert(var = assigns(:var))" +assert(${1:var} = assigns(:${1}), "Cannot find @${1}") +$0 +endsnippet + +snippet asd "assert_difference" +assert_difference "${1:Model}.${2:count}", ${3:1} do + $0 +end +endsnippet + +snippet asnd "assert_no_difference" +assert_no_difference "${1:Model}.${2:count}" do + $0 +end +endsnippet + +snippet artnpp "assert_redirected_to (nested path plural)" +assert_redirected_to ${10:${2:parent}_${3:child}_path(${4:@}${5:${2}})} +endsnippet + +snippet artnp "assert_redirected_to (nested path)" +assert_redirected_to ${2:${12:parent}_${13:child}_path(${14:@}${15:${12}}, ${16:@}${17:${13}})} +endsnippet + +snippet artpp "assert_redirected_to (path plural)" +assert_redirected_to ${10:${2:model}s_path} +endsnippet + +snippet artp "assert_redirected_to (path)" +assert_redirected_to ${2:${12:model}_path(${13:@}${14:${12}})} +endsnippet + +snippet asrj "assert_rjs" +assert_rjs :${1:replace}, ${2:"${3:dom id}"} +endsnippet + +snippet ass "assert_select" +assert_select '${1:path}'${2:, :${3:text} => ${4:'${5:inner_html}'}}${6: do + $0 +end} +endsnippet + +snippet befc "before_create" +before_create +endsnippet + +snippet befd "before_destroy" +before_destroy +endsnippet + +snippet befs "before_save" +before_save +endsnippet + +snippet befu "before_update" +before_update +endsnippet + +snippet befv "before_validation" +before_validation +endsnippet + +snippet befvoc "before_validation_on_create" +before_validation_on_create +endsnippet + +snippet befvou "before_validation_on_update" +before_validation_on_update +endsnippet + +snippet bt "belongs_to (bt)" +belongs_to :${1:object}${2:, :class_name => "${3:${1/[[:alpha:]]+|(_)/(?1::\u$0)/g}}", :foreign_key => "${4:${1}_id}"} +endsnippet + +snippet crw "cattr_accessor" +cattr_accessor :${0:attr_names} +endsnippet + +snippet defcreate "def create - resource" +def create + @${1:model} = ${2:${1/[[:alpha:]]+|(_)/(?1::\u$0)/g}}.new(params[:$1]) + $0 + respond_to do |wants| + if @$1.save + flash[:notice] = '$2 was successfully created.' + wants.html { redirect_to(@$1) } + wants.xml { render :xml => @$1, :status => :created, :location => @$1 } + else + wants.html { render :action => "new" } + wants.xml { render :xml => @$1.errors, :status => :unprocessable_entity } + end + end +end + +endsnippet + +snippet test "test do..end" +test "${1:something interesting}" do + $0 +end +endsnippet + +snippet deftg "def get request" +def test_should_get_${1:action} + ${2:@${3:model} = ${4:$3s}(:${5:fixture_name}) + }get :${1}${6:, :id => @$3.to_param} + assert_response :success + $0 +end +endsnippet + +snippet deftp "def post request" +def test_should_post_${1:action} + ${3:@$2 = ${4:$2s}(:${5:fixture_name}) + }post :${1}${6:, :id => @$2.to_param}, :${2:model} => { $0 } + assert_response :redirect + +end +endsnippet + +snippet fina "find(:all)" +find(:all${1:, :conditions => ['${2:${3:field} = ?}', ${5:true}]}) +endsnippet + +snippet finf "find(:first)" +find(:first${1:, :conditions => ['${2:${3:field} = ?}', ${5:true}]}) +endsnippet + +snippet fini "find(id)" +find(${1:id}) +endsnippet + +snippet fine "find_each" +find_each(${1::conditions => {:${2:field} => ${3:true}\}}) do |${4:${TM_CURRENT_WORD/(\w+)\./\L$1/g}}| + $0 +end +endsnippet + +snippet finb "find_in_batches" +find_in_batches(${1::conditions => {:${2:field} => ${3:true}\}}) do |${4:${TM_CURRENT_WORD/(\w+)\./\L$1/g}}s| + $4s.each do |$4| + $0 + end +end +endsnippet + +snippet habtm "has_and_belongs_to_many (habtm)" +has_and_belongs_to_many :${1:object}${2:, :join_table => "${3:table_name}", :foreign_key => "${4:${1}_id}"} +endsnippet + +snippet hm "has_many (hm)" +has_many :${1:object}s${2:, :class_name => "${1}", :foreign_key => "${4:reference}_id"} +endsnippet + +snippet hmt "has_many (through)" +has_many :${1:objects}, :through => :${2:join_association}${3:, :source => :${4:${2}_table_foreign_key_to_${1}_table}} +endsnippet + +snippet hmd "has_many :dependent => :destroy" +has_many :${1:object}s${2:, :class_name => "${1}", :foreign_key => "${4:reference}_id"}, :dependent => :destroy$0 +endsnippet + +snippet ho "has_one (ho)" +has_one :${1:object}${2:, :class_name => "${3:${1/[[:alpha:]]+|(_)/(?1::\u$0)/g}}", :foreign_key => "${4:${1}_id}"} +endsnippet + +snippet logd "logger.debug" +${1:Rails.}logger.debug { "${1:message}" }$0 +endsnippet + +snippet loge "logger.error" +logger.error { "${1:message}" }$0 +endsnippet + +snippet logf "logger.fatal" +logger.fatal { "${1:message}" }$0 +endsnippet + +snippet logi "logger.info" +logger.info { "${1:message}" }$0 +endsnippet + +snippet logw "logger.warn" +logger.warn { "${1:message}" }$0 +endsnippet + +snippet mp "map(&:sym_proc)" +map(&:${1:id}) +endsnippet + +snippet mapca "map.catch_all" +${1:map}.catch_all "*${2:anything}", :controller => "${3:default}", :action => "${4:error}" + +endsnippet + +snippet map "map.named_route" +${1:map}.${2:connect} '${3::controller/:action/:id}' +endsnippet + +snippet mapr "map.resource" +${1:map}.resource :${2:resource}${10: do |${11:$2}| + $0 +end} +endsnippet + +snippet maprs "map.resources" +${1:map}.resources :${2:resource}${10: do |${11:$2}| + $0 +end} +endsnippet + +snippet mapwo "map.with_options" +${1:map}.with_options :${2:controller} => '${3:thing}' do |${4:$3}| + $0 +end + +endsnippet + +snippet mrw "mattr_accessor" +mattr_accessor :${0:attr_names} +endsnippet + +snippet ncl "named_scope lambda" +named_scope :name, lambda { |${1:param}| { :conditions => ${3:['${4:${5:field} = ?}', ${6:$1}]} } } + +endsnippet + +snippet nc "named_scope" +named_scope :name${1:, :joins => :${2:table}}, :conditions => ${3:['${4:${5:field} = ?}', ${6:true}]} + +endsnippet + +snippet dscope "default_scope" +default_scope ${1:order(${2:'${3:created_at DESC}'})} +endsnippet + +snippet flash "flash[...]" +flash[:${1:notice}] = "${2:Successfully created...}"$0 +endsnippet + +snippet rea "redirect_to (action)" +redirect_to :action => "${1:index}" +endsnippet + +snippet reai "redirect_to (action, id)" +redirect_to :action => "${1:show}", :id => ${0:@item} +endsnippet + +snippet rec "redirect_to (controller)" +redirect_to :controller => "${1:items}" +endsnippet + +snippet reca "redirect_to (controller, action)" +redirect_to :controller => "${1:items}", :action => "${2:list}" +endsnippet + +snippet recai "redirect_to (controller, action, id)" +redirect_to :controller => "${1:items}", :action => "${2:show}", :id => ${0:@item} +endsnippet + +snippet renpp "redirect_to (nested path plural)" +redirect_to(${2:${10:parent}_${11:child}_path(${12:@}${13:${10}})}) +endsnippet + +snippet renp "redirect_to (nested path)" +redirect_to(${2:${12:parent}_${13:child}_path(${14:@}${15:${12}}, ${16:@}${17:${13}})}) +endsnippet + +snippet repp "redirect_to (path plural)" +redirect_to(${2:${10:model}s_path}) +endsnippet + +snippet rep "redirect_to (path)" +redirect_to(${2:${12:model}_path(${13:@}${14:${12}})}) +endsnippet + +snippet reb "redirect_to :back" +redirect_to :back +endsnippet + +snippet ra "render (action)... (ra)" +render :action => "${1:action}" +endsnippet + +snippet ral "render (action,layout) (ral)" +render :action => "${1:action}", :layout => "${2:layoutname}" +endsnippet + +snippet rf "render (file) (rf)" +render :file => "${1:filepath}" +endsnippet + +snippet rfu "render (file,use_full_path) (rfu)" +render :file => "${1:filepath}", :use_full_path => ${2:false} +endsnippet + +snippet ri "render (inline) (ri)" +render :inline => "${1:<%= 'hello' %>}" +endsnippet + +snippet ril "render (inline,locals) (ril)" +render :inline => "${1:<%= 'hello' %>}", :locals => { ${2::name} => "${3:value}"$4 } +endsnippet + +snippet rit "render (inline,type) (rit)" +render :inline => "${1:<%= 'hello' %>}", :type => ${2::rxml} +endsnippet + +snippet rl "render (layout) (rl)" +render :layout => "${1:layoutname}" +endsnippet + +snippet rn "render (nothing) (rn)" +render :nothing => ${1:true} +endsnippet + +snippet rns "render (nothing,status) (rns)" +render :nothing => ${1:true}, :status => ${2:401} +endsnippet + +snippet rt "render (text) (rt)" +render :text => "${1:text to render...}" +endsnippet + +snippet rtl "render (text,layout) (rtl)" +render :text => "${1:text to render...}", :layout => "${2:layoutname}" +endsnippet + +snippet rtlt "render (text,layout => true) (rtlt)" +render :text => "${1:text to render...}", :layout => ${2:true} +endsnippet + +snippet rts "render (text,status) (rts)" +render :text => "${1:text to render...}", :status => ${2:401} +endsnippet + +snippet ru "render (update)" +render :update do |${2:page}| + $2.$0 +end +endsnippet + +snippet rest "respond_to" +respond_to do |wants| + wants.${1:html}${2: { $0 \}} +end +endsnippet + +snippet resw "respond_with" +respond_with(${1:@${2:model}})${3: do |format| + format.${4:html} { $0 \} +end} +endsnippet + +# FIXME +snippet returning "returning do |variable| ... end" +returning ${1:variable} do${2/(^(?\s*[a-z_][a-zA-Z0-9_]*\s*)(,\g)*,?\s*$)|.*/(?1: |)/}${2:v}${2/(^(?\s*[a-z_][a-zA-Z0-9_]*\s*)(,\g)*,?\s*$)|.*/(?1:|)/} + $0 +end +endsnippet + +snippet t. "t.binary (tcbi)" +t.binary :${1:title}${2:, :limit => ${3:2}.megabytes} +t.$0 +endsnippet + +snippet t. "t.boolean (tcb)" +t.boolean :${1:title} +t.$0 +endsnippet + +snippet t. "t.date (tcda)" +t.date :${1:title} +t.$0 +endsnippet + +snippet t. "t.datetime (tcdt)" +t.datetime :${1:title} +t.$0 +endsnippet + +snippet t. "t.decimal (tcd)" +t.decimal :${1:title}${2:${3:, :precision => ${4:10}}${5:, :scale => ${6:2}}} +t.$0 +endsnippet + +snippet t. "t.float (tcf)" +t.float :${1:title} +t.$0 +endsnippet + +snippet t. "t.integer (tci)" +t.integer :${1:title} +t.$0 +endsnippet + +snippet t. "t.lock_version (tcl)" +t.integer :lock_version, :null => false, :default => 0 +t.$0 +endsnippet + +snippet t. "t.references (tcr)" +t.references :${1:taggable}${2:, :polymorphic => ${3:{ :default => '${4:Photo}' \}}} +t.$0 +endsnippet + +snippet t. "t.rename (tre)" +t.rename(:${1:old_column_name}, :${2:new_column_name}) +t.$0 +endsnippet + +snippet t. "t.string (tcs)" +t.string :${1:title} +t.$0 +endsnippet + +snippet t. "t.text (tct)" +t.text :${1:title} +t.$0 +endsnippet + +snippet t. "t.time (tcti)" +t.time :${1:title} +t.$0 +endsnippet + +snippet t. "t.timestamp (tcts)" +t.timestamp :${1:title} +t.$0 +endsnippet + +snippet t. "t.timestamps (tctss)" +t.timestamps +t.$0 +endsnippet + +snippet vaoif "validates_acceptance_of if" +validates_acceptance_of :${1:terms}${2:${3:, :accept => "${4:1}"}${5:, :message => "${6:You must accept the terms of service}"}}, :if => proc { |obj| ${7:obj.condition?} }} +endsnippet + +snippet vao "validates_acceptance_of" +validates_acceptance_of :${1:terms}${2:${3:, :accept => "${4:1}"}${5:, :message => "${6:You must accept the terms of service}"}} +endsnippet + +snippet va "validates_associated (va)" +validates_associated :${1:attribute}${2:, :on => :${3:create}} +endsnippet + +snippet vaif "validates_associated if (vaif)" +validates_associated :${1:attribute}${2:, :on => :${3:create}, :if => proc { |obj| ${5:obj.condition?} }} +endsnippet + +snippet vc "validates_confirmation_of (vc)" +validates_confirmation_of :${1:attribute}${2:, :on => :${3:create}, :message => "${4:should match confirmation}"} +endsnippet + +snippet vcif "validates_confirmation_of if (vcif)" +validates_confirmation_of :${1:attribute}${2:, :on => :${3:create}, :message => "${4:should match confirmation}", :if => proc { |obj| ${5:obj.condition?} }} +endsnippet + +snippet ve "validates_exclusion_of (ve)" +validates_exclusion_of :${1:attribute}${2:, :in => ${3:%w( ${4:mov avi} )}, :on => :${5:create}, :message => "${6:extension %s is not allowed}"} +endsnippet + +snippet veif "validates_exclusion_of if (veif)" +validates_exclusion_of :${1:attribute}${2:, :in => ${3:%w( ${4:mov avi} )}, :on => :${5:create}, :message => "${6:extension %s is not allowed}"}, :if => proc { |obj| ${7:obj.condition?} }} +endsnippet + +snippet vfif "validates_format_of if" +validates_format_of :${1:attribute}, :with => /${2:^[${3:\w\d}]+\$}/${4:, :on => :${5:create}, :message => "${6:is invalid}"}, :if => proc { |obj| ${7:obj.condition?} }} +endsnippet + +snippet vf "validates_format_of" +validates_format_of :${1:attribute}, :with => /${2:^[${3:\w\d}]+\$}/${4:, :on => :${5:create}, :message => "${6:is invalid}"} +endsnippet + +snippet viif "validates_inclusion_of if" +validates_inclusion_of :${1:attribute}${2:, :in => ${3:%w( ${4:mov avi} )}, :on => :${5:create}, :message => "${6:extension %s is not included in the list}"}, :if => proc { |obj| ${7:obj.condition?} }} +endsnippet + +snippet vi "validates_inclusion_of" +validates_inclusion_of :${1:attribute}${2:, :in => ${3:%w( ${4:mov avi} )}, :on => :${5:create}, :message => "${6:extension %s is not included in the list}"} +endsnippet + +snippet vl "validates_length_of (vl)" +validates_length_of :${1:attribute}, :within => ${2:3..20}${3:, :on => :${4:create}, :message => "${5:must be present}"} +endsnippet + +snippet vlif "validates_length_of if" +validates_length_of :${1:attribute}, :within => ${2:3..20}${3:, :on => :${4:create}, :message => "${5:must be present}"}, :if => proc { |obj| ${6:obj.condition?} }} +endsnippet + +snippet vnif "validates_numericality_of if" +validates_numericality_of :${1:attribute}${2:, :on => :${3:create}, :message => "${4:is not a number}"}, :if => proc { |obj| ${5:obj.condition?} }} +endsnippet + +snippet vn "validates_numericality_of" +validates_numericality_of :${1:attribute}${2:, :on => :${3:create}, :message => "${4:is not a number}"} +endsnippet + +snippet vp "validates_presence_of (vp)" +validates_presence_of :${1:attribute}${2:, :on => :${3:create}, :message => "${4:can't be blank}"} +endsnippet + +snippet vpif "validates_presence_of if (vpif) 2" +validates_presence_of :${1:attribute}${2:, :on => :${3:create}, :message => "${4:can't be blank}"}, :if => proc { |obj| ${5:obj.condition?} }} +endsnippet + +snippet vu "validates_uniqueness_of (vu)" +validates_uniqueness_of :${1:attribute}${2:, :on => :${3:create}, :message => "${4:must be unique}"} +endsnippet + +snippet vuif "validates_uniqueness_of if (vuif)" +validates_uniqueness_of :${1:attribute}${2:, :on => :${3:create}, :message => "${4:must be unique}", :if => proc { |obj| ${6:obj.condition?} }} +endsnippet + +snippet verify "verify -- render" +verify :only => [:$1], :method => :post, :render => {:status => 500, :text => "use HTTP-POST"} + +endsnippet + +snippet verify "verify -- redirect" +verify :only => [:$1], :session => :user, :params => :id, :redirect_to => {:action => '${2:index}'} + +endsnippet + +snippet wants "wants_format" +wants.${1:js|xml|html}${2: { $0 \}} +endsnippet + +snippet xdelete "xhr delete" +xhr :delete, :${1:destroy}, :id => ${2:1}$0 +endsnippet + +snippet xget "xhr get" +xhr :get, :${1:show}${2:, :id => ${3:1}}$0 +endsnippet + +snippet xpost "xhr post" +xhr :post, :${1:create}, :${2:object} => { $3 } +endsnippet + +snippet xput "xhr put" +xhr :put, :${1:update}, :id => ${2:1}, :${3:object} => { $4 }$0 +endsnippet + +snippet finl "find(:last)" +find(:last${1:, :conditions => ['${2:${3:field} = ?}', ${5:true}]}) +endsnippet + +snippet sweeper "Create sweeper class" +class ${1:Model}Sweeper < ActionController::Caching::Sweeper + observe ${1:Model} + + def after_save(${1/./\l$0/}) + expire_cache(${1/./\l$0/}) + end + + def after_destroy(${1/./\l$0/}) + expire_cache(${1/./\l$0/}) + end + + private + + def expire_cache(${1/./\l$0/}) + ${0:expire_page ${1/./\l$0/}s_path + expire_page ${1/./\l$0/}_path(${1/./\l$0/})} + end + +end +endsnippet + +snippet col "collection routes" +collection do + ${1:get :${2:action}} + ${3:put :${4:action}} + ${5:post :${6:action}} + ${7:delete :${8:action}} +end +endsnippet + +snippet format "format (respond_with)" +format.${1:html|xml|json|js|any} { $0 } +endsnippet + +snippet gem "gem" +gem '${1:name}'${2:${3:, "${4:1.0}"}${5:${6:, :require => ${7:"${8:$1}"}}${9:, :group => :${10:test}}}} +endsnippet + +snippet gemg "gem :git" +gem '${1:paperclip}', :git => "${2:git://github.com/thoughtbot/paperclip.git}"${3:, :branch => "${4:rails3}"} +endsnippet + +snippet match "match" +match '${1:${2::controller}${3:/${4::action}${5:/${6::id}${7:(.:format)}}}}'${8: => '${9:$2}#${10:$4}'${11:, :as => :${12:$10}}} +endsnippet + +snippet member "member routes" +member do + ${1:get :${2:action}} + ${3:put :${4:action}} + ${5:post :${6:action}} + ${7:delete :${8:action}} +end +endsnippet + +snippet res "resources" +resources :${1:posts}${2: do + $3 +end} +endsnippet + +snippet scope "scope" +scope :${1:name}, ${2:joins(:${3:table}).}where(${4:'${5:$3.${6:field}} = ?', ${7:'${8:value}'}}) +endsnippet + +snippet scopel "scope lambda" +scope :${1:name}, lambda { |${2:param}| ${3:where(${4::${5:field} => ${6:"${7:value}"}})} } +endsnippet + +snippet scopee "scope with extension" +scope :${1:name}, ${2:where(${3::${4:field} => ${5:'${6:value}'}})} do + def ${7:method_name} + $0 + end +end +endsnippet + +snippet sb "scoped_by" +scoped_by_${1:attribute}(${2:id}) +endsnippet + +snippet setup "setup do..end" +setup do + $0 +end +endsnippet + +snippet trans "Translation snippet" +I18n.t('`!v substitute(substitute(substitute(@%, substitute(getcwd() . "/", "\/", "\\\\/", "g"), "", ""), "\\(\\.\\(html\\|js\\)\\.\\(haml\\|erb\\)\\|\\(_controller\\)\\?\\.rb\\)$", "", ""), "/", ".", "g")`.${2:${1/[^\w]/_/g}}${3}', :default => "${1:some_text}"${4})${5:$0} +endsnippet + +snippet route_spec +it 'routes to #${1:action}' do + ${2:get}('/${3:url}').should route_to('`!v substitute(expand('%:t:r'), '_routing_spec$', '', '')`#$1'${4:, ${5:params}})${6} +end +endsnippet + +# vim:ft=snippets: diff --git a/skel/.config/nvim/plugged/vim-snippets/UltiSnips/rst.snippets b/skel/.config/nvim/plugged/vim-snippets/UltiSnips/rst.snippets new file mode 100644 index 0000000..88e0caa --- /dev/null +++ b/skel/.config/nvim/plugged/vim-snippets/UltiSnips/rst.snippets @@ -0,0 +1,314 @@ +# -*- coding: utf-8 -*- + +########################################################################### +# General Stuff # +########################################################################### +global !p +import vim +from os import path as ospath +from string import Template +import re +from collections import Counter + +#http://docutils.sourceforge.net/docs/ref/rst/roles.html +TEXT_ROLES = ['emphasis','literal','code','math', + 'pep-reference','rfc-reference', + 'strong','subscript','superscript', + 'title-reference','raw'] +TEXT_ROLES_REGEX = r'\.\.\srole::?\s(w+)' + +#http://docutils.sourceforge.net/docs/ref/rst/directives.html#specific-admonitions +SPECIFIC_ADMONITIONS = ["attention", "caution", "danger", + "error", "hint", "important", "note", + "tip", "warning"] +#http://docutils.sourceforge.net/docs/ref/rst/directives.html +DIRECTIVES = ['topic','sidebar','math','epigraph', + 'parsed-literal','code','highlights', + 'pull-quote','compound','container', + 'list-table','class','sectnum', + 'role','default-role','unicode', + 'raw'] + +NONE_CONTENT_DIRECTIVES = ['rubric', 'contents', 'header', + 'footer', 'date', 'include', 'title'] + +INCLUDABLE_DIRECTIVES = ['image', 'figure', 'include'] +# CJK chars +# http://stackoverflow.com/questions/2718196/find-all-chinese-text-in-a-string-using-python-and-regex +CJK_RE = re.compile(u'[⺀-⺙⺛-⻳⼀-⿕々〇〡-〩〸-〺〻㐀-䶵一-鿃豈-鶴侮-頻並-龎]', re.UNICODE) + + +def has_cjk(char): + """ + Detect char contains CJK character + + :param char: characters needs to be detect + """ + try: + CJK_RE.finditer(char).next() + except StopIteration: + return False + else: + return True + +def real_filename(filename): + """peal extension name off if possible + # i.e. "foo.bar.png will return "foo.bar" + """ + return ospath.splitext(filename)[0] + +def check_file_exist(rst_path, relative_path): + """ + For RST file, it can just include files as relative path. + + :param rst_path: absolute path to rst file + :param relative_path: path related to rst file + :return: relative file's absolute path if file exist + """ + abs_path = ospath.join(ospath.dirname(rst_path), relative_path) + if ospath.isfile(abs_path): + return abs_path + + +def rst_char_len(char): + """ + return len of string which fit in rst + For instance:chinese "我" decode as only one character, + However, the rst interpreter needs 2 "=" instead of 1. + + :param: char needs to be count + """ + return len(re.findall(r'[^\u4e00-\u9fff\s]', char))+len(char) + +def make_items(times, leading='+'): + """ + make lines with leading char multitimes + + :param: times, how many times you need + :param: leading, leading character + """ + times = int(times) + if leading == 1: + msg = "" + for x in xrange(1, times+1): + msg += "%s. Item\n" % x + return msg + else: + return ("%s Item\n" % leading) * times + + +def look_up_directives(regex, fpath): + """ + find all directive args in given file + :param: regex, the regex that needs to match + :param: path, to path to rst file + + :return: list, empty list if nothing match + """ + try: + with open(fpath) as source: + match = re.findall(regex, source.read()) + except IOError: + match = [] + return match + + +def get_popular_code_type(): + """ + find most popular code type in the given rst + + :param path: file to detect + + :return: string, most popular code type in file + """ + buf = "".join(vim.current.buffer) + types = re.findall(r'[:|\.\.\s]code::?\s(\w+)', buf) + try: + popular_type = Counter(types).most_common()[0][0] + except IndexError: + popular_type = "lua" # Don't break default + return popular_type + + +def complete(t, opts): + """ + get options that start with t + + :param t: query string + :param opts: list that needs to be completed + + :return: a string that start with t + """ + msg = "({0})" + if t: + opts = [ m[len(t):] for m in opts if m.startswith(t) ] + if len(opts) == 1: + return opts[0] + + if not len(opts): + msg = "{0}" + return msg.format("|".join(opts)) + +endglobal + +snippet part "Part" b +`!p snip.rv = rst_char_len(t[1])*'#'` +${1:Part name} +`!p snip.rv = rst_char_len(t[1])*'#'` + +$0 +endsnippet + +snippet sec "Section" b +${1:Section name} +`!p snip.rv = rst_char_len(t[1])*'='` + +$0 +endsnippet + +snippet ssec "Subsection" b +${1:Section name} +`!p snip.rv = rst_char_len(t[1])*'-'` + +$0 +endsnippet + +snippet sssec "Subsubsection" b +${1:Section name} +`!p snip.rv = rst_char_len(t[1])*'^'` + +$0 +endsnippet + +snippet chap "Chapter" b +`!p snip.rv = rst_char_len(t[1])*'*'` +${1:Chapter name} +`!p snip.rv = rst_char_len(t[1])*'*'` + +$0 +endsnippet + +snippet para "Paragraph" b +${1:Paragraph name} +`!p snip.rv = rst_char_len(t[1])*'"'` + +$0 +endsnippet + +snippet em "Emphasize string" i +`!p +# dirty but works with CJK charactor detection +if has_cjk(vim.current.line): + snip.rv ="\ "`*${1:${VISUAL:Em}}*`!p +if has_cjk(vim.current.line): + snip.rv ="\ " +else: + snip.rv = " " +`$0 +endsnippet + +snippet st "Strong string" i +`!p +if has_cjk(vim.current.line): + snip.rv ="\ "`**${1:${VISUAL:Strong}}**`!p +if has_cjk(vim.current.line): + snip.rv ="\ " +else: + snip.rv = " " +`$0 +endsnippet + +snippet "li(st)? (?P\d+)" "List" br +$0 +`!p +# usage: li 4 +# which will extand into a unordered list contains 4 items +snip.rv = make_items(match.groupdict()['num']) +` +endsnippet + +snippet "ol(st)? (?P\d+)" "Order List" br +$0 +`!p +# usage: ol 4 +# which will extand into a ordered list contains 4 items +snip.rv = make_items(match.groupdict()['num'], 1) +` +endsnippet +########################################################################### +# More Specialized Stuff. # +########################################################################### +snippet cb "Code Block" b +.. code-block:: ${1:`!p snip.rv = get_popular_code_type()`} + + ${2:code} + +$0 +endsnippet + +# match snippets : +# img, inc, fig +snippet id "Includable Directives" b +`!p +real_name=real_filename(ospath.basename(t[2])) +di=t[1][:2] + +link="" +content="" + +if di == 'im': + link = "|{0}|".format(real_name) + +if di == 'fi': + content=""" + :alt: {0} + {0}""".format(real_name) +` +..`!p snip.rv = " %s" % link if link else ""` $1`!p snip.rv=complete(t[1], INCLUDABLE_DIRECTIVES)`:: ${2:file}`!p if content: + snip.rv +=" "+content` +`!p +# Tip of whether file is exist in comment type +if not check_file_exist(path, t[2]): + snip.rv='.. FILE {0} does not exist'.format(t[2]) +else: + snip.rv="" +`$0 +endsnippet + +snippet di "Directives" b +.. $1`!p snip.rv=complete(t[1], DIRECTIVES)`:: $2 + + ${3:Content} +$0 +endsnippet + +snippet nd "None Content Directives" b +.. $1`!p snip.rv=complete(t[1], NONE_CONTENT_DIRECTIVES)`:: $2 +$0 +endsnippet + +snippet sa "Specific Admonitions" b +.. $1`!p snip.rv =complete(t[1], SPECIFIC_ADMONITIONS)`:: + + ${2:Content} + +$0 +endsnippet + +#it will be trigger at start of line or after a word +snippet ro "Text Roles" w +\ :$1`!p snip.rv=complete(t[1], + TEXT_ROLES+look_up_directives(TEXT_ROLES_REGEX, + path))`:\`$2\`\ +endsnippet + +############ +# Sphinx # +############ + +snippet sid "SideBar" b +.. sidebar:: ${1:SideBar Title} + + ${2:SideBar Content} +endsnippet +# vim:ft=snippets: diff --git a/skel/.config/nvim/plugged/vim-snippets/UltiSnips/ruby.snippets b/skel/.config/nvim/plugged/vim-snippets/UltiSnips/ruby.snippets new file mode 100644 index 0000000..90001b1 --- /dev/null +++ b/skel/.config/nvim/plugged/vim-snippets/UltiSnips/ruby.snippets @@ -0,0 +1,566 @@ +snippet "^#!" "#!/usr/bin/env ruby" r +#!/usr/bin/env ruby +$0 +endsnippet + + +snippet "^# ?[uU][tT][fF]-?8" "# encoding: UTF-8" r +# encoding: UTF-8 +$0 +endsnippet + + + +snippet If " if " +${1:command} if ${0:expression} +endsnippet + + + +snippet Unless " unless " +${1:command} unless ${0:expression} +endsnippet + + + +snippet if "if ... end" +if ${1:condition} + ${2} +end +endsnippet + + + +snippet ife "if ... else ... end" +if ${1:condition} + ${2} +else + ${3} +end +endsnippet + + + +snippet ifee "if ... elseif ... else ... end" +if ${1:condition} + ${2} +elsif ${3:condition} + ${4} +else + ${0} +end +endsnippet + + + +snippet unless "unless ... end" +unless ${1:condition} + ${0} +end +endsnippet + + + +snippet unlesse "unless ... else ... end" +unless ${1:condition} + ${2} +else + ${0} +end +endsnippet + + + +snippet unlesee "unless ... elseif ... else ... end" +unless ${1:condition} + ${2} +elsif ${3:condition} + ${4} +else + ${0} +end +endsnippet + + + +snippet "\b(de)?f" "def ..." r +def ${1:function_name}${2: ${3:*args}} + ${0} +end +endsnippet + + + +snippet defi "def initialize ..." +def initialize${1: ${2:*args}} + ${0} +end +endsnippet + + + +snippet defr "def ... rescue ..." +def ${1:function_name}${2: ${3:*args}} + ${4} +rescue + ${0} +end +endsnippet + + + +snippet For "(..).each { || }" +(${1:from}..${2:to}).each { |${3:i}| ${4} } +endsnippet + + + +snippet for "(..).each do || end" +(${1:from}..${2:to}).each do |${3:i}| + ${0} +end +endsnippet + + + +snippet "(\S+)\.Merge!" ".merge!() { |,,| }" r +`!p snip.rv=match.group(1)`.merge!(${1:other_hash}) { |${2:key},${3:oldval},${4:newval}| ${5:block} } +endsnippet + + + +snippet "(\S+)\.merge!" ".merge!() do |,,| end" r +`!p snip.rv=match.group(1)`.merge!(${1:other_hash}) do |${2:key},${3:oldval},${4:newval}| + ${0:block} +end +endsnippet + + + +snippet "(\S+)\.Del(ete)?_?if" ".delete_if { |,| }" r +`!p snip.rv=match.group(1)`.delete_if { |${1:key},${2:value}| ${3} } +endsnippet + + + +snippet "(\S+)\.del(ete)?_?if" ".delete_if do |,| end" r +`!p snip.rv=match.group(1)`.delete_if do |${1:key},${2:value}| + ${0} +end +endsnippet + + + +snippet "(\S+)\.Keep_?if" ".keep_if { |,| }" r +`!p snip.rv=match.group(1)`.keep_if { |${1:key},${2:value}| ${3} } +endsnippet + + + +snippet "(\S+)\.keep_?if" ".keep_if do ,| end" r +`!p snip.rv=match.group(1)`.keep_if do |${1:key},${2:value}| + ${0} +end +endsnippet + + + +snippet "(\S+)\.Reject" ".reject { |,| }" r +`!p snip.rv=match.group(1)`.reject { |${1:key},${2:value}| ${3} } +endsnippet + + + +snippet "(\S+)\.reject" ".reject do ,| end" r +`!p snip.rv=match.group(1)`.reject do |${1:key},${2:value}| + ${0} +end +endsnippet + + + +snippet "(\S+)\.Select" ".select { || }" r +`!p snip.rv=match.group(1)`.select { |${1:item}| ${2:block} } +endsnippet + + + +snippet "(\S+)\.select" ".select do || end" r +`!p snip.rv=match.group(1)`.select do |${1:item}| + ${0:block} +end +endsnippet + + + +snippet "(\S+)\.Sort" ".sort { |,| }" r +`!p snip.rv=match.group(1)`.sort { |${1:a},${2:b}| ${3} } +endsnippet + + + +snippet "(\S+)\.sort" ".sort do |,| end" r +`!p snip.rv=match.group(1)`.sort do |${1:a},${2:b}| + ${0} +end +endsnippet + + + +snippet "(\S+)\.Each_?k(ey)?" ".each_key { || }" r +`!p snip.rv=match.group(1)`.each_key { |${1:key}| ${2} } +endsnippet + + + +snippet "(\S+)\.each_?k(ey)?" ".each_key do |key| end" r +`!p snip.rv=match.group(1)`.each_key do |${1:key}| + ${0} +end +endsnippet + + + +snippet "(\S+)\.Each_?val(ue)?" ".each_value { || }" r +`!p snip.rv=match.group(1)`.each_value { |${1:value}| ${2} } +endsnippet + + + +snippet "(\S+)\.each_?val(ue)?" ".each_value do || end" r +`!p snip.rv=match.group(1)`.each_value do |${1:value}| + ${0} +end +endsnippet + + + +snippet Each ".each { || }" +${1:elements}.each { |${2:${1/s$//}}| ${3} } +endsnippet + + + +snippet each ".each do || end" +${1:elements}.each do |${2:${1/s$//}}| + ${0} +end +endsnippet + + + +snippet each_?s(lice)? ".each_slice(n) do |slice| end" +each_slice(${1:2}) do |${2:slice}| + ${0} +end +endsnippet + + + +snippet Each_?s(lice)? ".each_slice(n) { |slice| }" +each_slice(${1:2}) { |${2:slice}| ${3} } +endsnippet + + + + +snippet "(\S+)\.Map" ".map { || }" r +`!p snip.rv=match.group(1)`.map { |${1:`!p +element_name = match.group(1).lstrip('$@') +ematch = re.search("([A-Za-z][A-Za-z0-9_]+?)s?[^A-Za-z0-9_]*?$", element_name) +try: + wmatch = re.search("([A-Za-z][A-Za-z0-9_]+)$", ematch.group(1)) + snip.rv = wmatch.group(1).lower() +except: + snip.rv = 'element' +`}| ${2} } +endsnippet + + + +snippet "(\S+)\.map" ".map do || end" r +`!p snip.rv=match.group(1)`.map do |${1:`!p +element_name = match.group(1).lstrip('$@') +ematch = re.search("([A-Za-z][A-Za-z0-9_]+?)s?[^A-Za-z0-9_]*?$", element_name) +try: + wmatch = re.search("([A-Za-z][A-Za-z0-9_]+)$", ematch.group(1)) + snip.rv = wmatch.group(1).lower() +except: + snip.rv = 'element' +`}| + ${0} +end +endsnippet + + + +snippet "(\S+)\.Rev(erse)?_?each" ".reverse_each { || }" r +`!p snip.rv=match.group(1)`.reverse_each { |${1:`!p +element_name = match.group(1).lstrip('$@') +ematch = re.search("([A-Za-z][A-Za-z0-9_]+?)s?[^A-Za-z0-9_]*?$", element_name) +try: + wmatch = re.search("([A-Za-z][A-Za-z0-9_]+)$", ematch.group(1)) + snip.rv = wmatch.group(1).lower() +except: + snip.rv = 'element' +`}| ${2} } +endsnippet + + + +snippet "(\S+)\.rev(erse)?_?each" ".reverse_each do || end" r +`!p snip.rv=match.group(1)`.reverse_each do |${1:`!p +element_name = match.group(1).lstrip('$@') +ematch = re.search("([A-Za-z][A-Za-z0-9_]+?)s?[^A-Za-z0-9_]*?$", element_name) +try: + wmatch = re.search("([A-Za-z][A-Za-z0-9_]+)$", ematch.group(1)) + snip.rv = wmatch.group(1).lower() +except: + snip.rv = 'element' +`}| + ${0} +end +endsnippet + + + +snippet "(\S+)\.Each" ".each { || }" r +`!p snip.rv=match.group(1)`.each { |${1:`!p +element_name = match.group(1).lstrip('$@') +ematch = re.search("([A-Za-z][A-Za-z0-9_]+?)s?[^A-Za-z0-9_]*?$", element_name) +try: + wmatch = re.search("([A-Za-z][A-Za-z0-9_]+)$", ematch.group(1)) + snip.rv = wmatch.group(1).lower() +except: + snip.rv = 'element' +`}| ${2} } +endsnippet + + + +snippet "(\S+)\.each" ".each do || end" r +`!p snip.rv=match.group(1)`.each do |${1:`!p +element_name = match.group(1).lstrip('$@') +ematch = re.search("([A-Za-z][A-Za-z0-9_]+?)s?[^A-Za-z0-9_]*?$", element_name) +try: + wmatch = re.search("([A-Za-z][A-Za-z0-9_]+)$", ematch.group(1)) + snip.rv = wmatch.group(1).lower() +except: + snip.rv = 'element' +`}| + ${0} +end +endsnippet + + + + +snippet "(\S+)\.Each_w(ith)?_?i(ndex)?" ".each_with_index { |,| }" r +`!p snip.rv=match.group(1)`.each_with_index { |${1:`!p +element_name = match.group(1).lstrip('$@') +ematch = re.search("([A-Za-z][A-Za-z0-9_]+?)s?[^A-Za-z0-9_]*?$", element_name) +try: + wmatch = re.search("([A-Za-z][A-Za-z0-9_]+)$", ematch.group(1)) + snip.rv = wmatch.group(1).lower() +except: + snip.rv = 'element' +`},${2:i}| ${3} }$0 +endsnippet + + + +snippet "(\S+)\.each_?w(ith)?_?i(ndex)?" ".each_with_index do |,| end" r +`!p snip.rv=match.group(1)`.each_with_index do |${1:`!p +element_name = match.group(1).lstrip('$@') +ematch = re.search("([A-Za-z][A-Za-z0-9_]+?)s?[^A-Za-z0-9_]*?$", element_name) +try: + wmatch = re.search("([A-Za-z][A-Za-z0-9_]+)$", ematch.group(1)) + snip.rv = wmatch.group(1).lower() +except: + snip.rv = 'element' +`},${2:i}| + ${0} +end +endsnippet + + + + +snippet "(\S+)\.Each_?p(air)?" ".each_pair { |,| }" r +`!p snip.rv=match.group(1)`.each_pair { |${1:key},${2:value}| ${3} } +endsnippet + + + +snippet "(\S+)\.each_?p(air)?" ".each_pair do |,| end" r +`!p snip.rv=match.group(1)`.each_pair do |${1:key},${2:value}| + ${0} +end +endsnippet + + + +snippet "(\S+)\.sub" ".sub() { }" r +`!p snip.rv=match.group(1)`.sub(${1:expression}) { ${2:"replace_with"} } +endsnippet + + + +snippet "(\S+)\.gsub" ".gsub() { }" r +`!p snip.rv=match.group(1)`.gsub(${1:expression}) { ${2:"replace_with"} } +endsnippet + + + +snippet "(\S+)\.index" ".index { |item| }" r +`!p snip.rv=match.group(1)`.index { |${1:item}| ${2:block} } +endsnippet + + + +snippet "(\S+)\.Index" ".index do |item| ... end" r +`!p snip.rv=match.group(1)`.index do |${1:item}| + ${0:block} +end +endsnippet + +# comments about do and dov see snippets/ruby.snippets +snippet do "do ... end" i +do + $0 +end +endsnippet + +snippet dov "do || ... end" i +do |${1:v}| + $2 +end +endsnippet + + + +snippet until "until ... end" +until ${1:expression} + ${0} +end +endsnippet + + + +snippet Until "begin ... end until " +begin + ${0} +end until ${1:expression} +endsnippet + + + +snippet wh "while ... end" +while ${1:expression} + ${0} +end +endsnippet + + + +snippet While "begin ... end while " +begin + ${0} +end while ${1:expression} +endsnippet + + + +snippet "\b(r|attr)" "attr_reader :" r +attr_reader :${0:attr_names} +endsnippet + + + +snippet "\b(w|attr)" "attr_writer :" r +attr_writer :${0:attr_names} +endsnippet + + + +snippet "\b(rw|attr)" "attr_accessor :" r +attr_accessor :${0:attr_names} +endsnippet + + + +snippet begin "begin ... rescue ... end" +begin + ${1} +rescue + ${0} +end +endsnippet + + + +snippet begin "begin ... rescue ... else ... ensure ... end" +begin + ${1:# Raise exception} +rescue Exception => e + puts e.message + puts e.backtrace.inspect + ${2:# Rescue} +else + ${3:# other exception} +ensure + ${0:# always excute} +end +endsnippet + + + +snippet rescue +rescue Exception => e + puts e.message + puts e.backtrace.inspect + ${0:# Rescue} +endsnippet + + + +snippet "\b(case|sw(itch)?)" "case when ... end" r +case ${1:variable} +when ${2:expression} +$0 +end +endsnippet + + + +snippet alias "alias : :" +alias :${1:new_name} :${2:old_name} +endsnippet + + + +snippet class "class def initialize ... end end" +class ${1:class_name} + def initialize ${2:*args} + $0 + end +end +endsnippet + + + +snippet module "module" +module ${1:module_name} + $0 +end +endsnippet + + + +snippet ### +=begin + $0 +=end +endsnippet + +# vim: set ts=2 sw=2 expandtab: diff --git a/skel/.config/nvim/plugged/vim-snippets/UltiSnips/sh.snippets b/skel/.config/nvim/plugged/vim-snippets/UltiSnips/sh.snippets new file mode 100644 index 0000000..cce06ef --- /dev/null +++ b/skel/.config/nvim/plugged/vim-snippets/UltiSnips/sh.snippets @@ -0,0 +1,88 @@ +global !p +import vim + +# Tests for the existence of a variable declared by Vim's filetype detection +# suggesting the type of shell script of the current file +def testShell(scope, shell): + return vim.eval("exists('" + scope + ":is_" + shell + "')") + +# Loops over the possible variables, checking for global variables +# first since they indicate an override by the user. +def getShell(): + for scope in ["g", "b"]: + for shell in ["bash", "sh", "kornshell"]: + if testShell(scope, shell) == "1": + if shell == "kornshell": + return "ksh" + return shell + return "sh" +endglobal + +########################################################################### +# TextMate Snippets # +########################################################################### +snippet #! +`!p snip.rv = '#!/bin/' + getShell() + "\n\n" ` +endsnippet + +snippet !env "#!/usr/bin/env (!env)" +`!p snip.rv = '#!/usr/bin/env ' + getShell() + "\n\n" ` +endsnippet + +snippet temp "Tempfile" +${1:TMPFILE}="$(mktemp -t ${2:`!p +snip.rv = re.sub(r'[^a-zA-Z]', '_', snip.fn) or "untitled" +`})" +${3:${4/(.+)/trap "/}${4:rm -f '$${1/.*\s//}'}${4/(.+)/" 0 # EXIT\n/}${5/(.+)/trap "/}${5:rm -f '$${1/.*\s//}'; exit 1}${5/(.+)/" 2 # INT\n/}${6/(.+)/trap "/}${6:rm -f '$${1/.*\s//}'; exit 1}${6/(.+)/" 1 15 # HUP TERM\n/}} + +endsnippet + +snippet case "case .. esac (case)" +case ${1:word} in + ${2:pattern} ) + $0;; +esac +endsnippet + +snippet elif "elif .. (elif)" +elif ${2:[[ ${1:condition} ]]}; then + ${0:#statements} +endsnippet + +snippet for "for ... done (for)" +for (( i = 0; i < ${1:10}; i++ )); do + ${0:#statements} +done +endsnippet + +snippet forin "for ... in ... done (forin)" +for ${1:i}${2/.+/ in /}${2:words}; do + ${0:#statements} +done +endsnippet + +snippet here "here document (here)" +<<-${2:'${1:TOKEN}'} + $0 +${1/['"`](.+)['"`]/$1/} +endsnippet + +snippet if "if ... then (if)" +if ${2:[[ ${1:condition} ]]}; then + ${0:#statements} +fi +endsnippet + +snippet until "until ... (done)" +until ${2:[[ ${1:condition} ]]}; do + ${0:#statements} +done +endsnippet + +snippet wh "while ... (done)" +while ${2:[[ ${1:condition} ]]}; do + ${0:#statements} +done +endsnippet + +# vim:ft=snippets: diff --git a/skel/.config/nvim/plugged/vim-snippets/UltiSnips/snippets.snippets b/skel/.config/nvim/plugged/vim-snippets/UltiSnips/snippets.snippets new file mode 100644 index 0000000..414f350 --- /dev/null +++ b/skel/.config/nvim/plugged/vim-snippets/UltiSnips/snippets.snippets @@ -0,0 +1,23 @@ +######################### +# SNIPPETS for SNIPPETS # +######################### + +# We use a little hack so that the snippet is expanded +# and parsed correctly +snippet snip "Snippet definition" ! +`!p snip.rv = "snippet"` ${1:Tab_trigger} "${2:Description}" ${3:!b} +$0 +`!p snip.rv = "endsnippet"` +endsnippet + +snippet global "Global snippet" ! +`!p snip.rv = "global"` !p +$0 +`!p snip.rv = "endglobal"` +endsnippet + +snippet vis "${VISUAL}" i +\$\{VISUAL${1:${2:default}${3:/transform/}}\} +endsnippet + +# vim:ft=snippets: diff --git a/skel/.config/nvim/plugged/vim-snippets/UltiSnips/tcl.snippets b/skel/.config/nvim/plugged/vim-snippets/UltiSnips/tcl.snippets new file mode 100644 index 0000000..fd53d26 --- /dev/null +++ b/skel/.config/nvim/plugged/vim-snippets/UltiSnips/tcl.snippets @@ -0,0 +1,50 @@ +########################################################################### +# TEXTMATE SNIPPETS # +########################################################################### +snippet for "for... (for)" b +for {${1:set i 0}} {${2:\$i < \$n}} {${3:incr i}} { + ${4} +} + +endsnippet + +snippet foreach "foreach... (foreach)" +foreach ${1:var} ${2:\$list} { + ${3} +} + +endsnippet + +snippet if "if... (if)" b +if {${1}} { + ${2} +} + +endsnippet + +snippet proc "proc... (proc)" b +proc ${1} {${2}} \ +{ + ${3} +} + +endsnippet + +snippet switch "switch... (switch)" b +switch ${1:-exact} -- ${2:\$var} { + ${3:match} { + ${4} + } + default {${5}} +} + +endsnippet + +snippet wh "while... (while)" b +while {${1}} { + ${2} +} + +endsnippet + +# vim:ft=snippets: diff --git a/skel/.config/nvim/plugged/vim-snippets/UltiSnips/tex.snippets b/skel/.config/nvim/plugged/vim-snippets/UltiSnips/tex.snippets new file mode 100644 index 0000000..97ea8a8 --- /dev/null +++ b/skel/.config/nvim/plugged/vim-snippets/UltiSnips/tex.snippets @@ -0,0 +1,124 @@ + +########################################################################### +# LATEX SNIPPETS # +########################################################################### + +snippet r "\ref{}" w +\ref{$1} +endsnippet + +########################################################################### +# TEXTMATE SNIPPETS # +########################################################################### + +################# +# GENERAL STUFF # +################# +snippet "b(egin)?" "begin{} / end{}" br +\begin{${1:something}} + ${0:${VISUAL}} +\end{$1} +endsnippet + +#################### +# TABULARS, ARRAYS # +#################### + +snippet tab +\begin{${1:t}${1/(t)$|(a)$|(.*)/(?1:abular)(?2:rray)/}}{${2:c}} +$0${2/((?<=.)c|l|r)|./(?1: & )/g} +\end{$1${1/(t)$|(a)$|(.*)/(?1:abular)(?2:rray)/}} +endsnippet + +######################## +# ENUM, DESCR, ITEMIZE # +######################## +snippet enum "Enumerate" b +\begin{enumerate} + \item $0 +\end{enumerate} +endsnippet + +snippet item "Itemize" b +\begin{itemize} + \item $0 +\end{itemize} +endsnippet + +snippet desc "Description" b +\begin{description} + \item[$1] $0 +\end{description} +endsnippet + +##################################### +# SECTIONS, CHAPTERS AND THERE LIKE # +##################################### + +snippet part "Part" b +\part{${1:part name}} +\label{prt:${2:${1/(\w+)|\W+/(?1:\L$0\E:_)/g}}} + +${0} + +% part $2 (end) +endsnippet + +snippet cha "Chapter" b +\chapter{${1:chapter name}} +\label{cha:${2:${1/\\\w+\{(.*?)\}|\\(.)|(\w+)|([^\w\\]+)/(?4:_:\L$1$2$3\E)/g}}} + +${0} + +% chapter $2 (end) +endsnippet + +snippet sec "Section" b +\section{${1:section name}} +\label{sec:${2:${1/\\\w+\{(.*?)\}|\\(.)|(\w+)|([^\w\\]+)/(?4:_:\L$1$2$3\E)/g}}} + +${0} + +% section $2 (end) +endsnippet + + +snippet sub "Subsection" b +\subsection{${1:subsection name}} +\label{sub:${2:${1/\\\w+\{(.*?)\}|\\(.)|(\w+)|([^\w\\]+)/(?4:_:\L$1$2$3\E)/g}}} + +${0} + +% subsection $2 (end) +endsnippet + +snippet ssub "Subsubsection" b +\subsubsection{${1:subsubsection name}} +\label{ssub:${2:${1/\\\w+\{(.*?)\}|\\(.)|(\w+)|([^\w\\]+)/(?4:_:\L$1$2$3\E)/g}}} + +${0} + +% subsubsection $2 (end) + +endsnippet + +snippet par "Paragraph" b +\paragraph{${1:paragraph name}} +\label{par:${2:${1/\\\w+\{(.*?)\}|\\(.)|(\w+)|([^\w\\]+)/(?4:_:\L$1$2$3\E)/g}}} + +${0} + +% paragraph $2 (end) +endsnippet + + +snippet subp "Subparagraph" b +\subparagraph{${1:subparagraph name}} +\label{par:${2:${1/\\\w+\{(.*?)\}|\\(.)|(\w+)|([^\w\\]+)/(?4:_:\L$1$2$3\E)/g}}} + +${0} + +% subparagraph $2 (end) +endsnippet + +# vim:ft=snippets: diff --git a/skel/.config/nvim/plugged/vim-snippets/UltiSnips/texmath.snippets b/skel/.config/nvim/plugged/vim-snippets/UltiSnips/texmath.snippets new file mode 100644 index 0000000..03589f0 --- /dev/null +++ b/skel/.config/nvim/plugged/vim-snippets/UltiSnips/texmath.snippets @@ -0,0 +1,54 @@ +############## +# MATH STUFF # +############## +snippet eq "Equation" b +\begin{equation} + $0 +\end{equation} +endsnippet + +snippet eqnn "Equation without number" b +\begin{equation*} + $0 +\end{equation*} +endsnippet + +snippet eqa "Equation array" b +\begin{eqnarray} + $1 & $2 & $0 +\end{eqnarray} +endsnippet + +snippet eqann "Equation array without numbers" b +\begin{eqnarray*} + $1 & $2 & $0 +\end{eqnarray*} + +endsnippet +snippet frac "Fraction" w +\frac{${1:${VISUAL:nom}}}{${2:denom}} +endsnippet + +snippet mat "Smart Matrix" +\begin{${1:p/b/v/V/B/small}matrix} + $0 +\end{$1matrix} +endsnippet + +snippet lr( "left( right)" w +\left( ${1:${VISUAL}} \right) +endsnippet + +snippet lr| "left| right|" w +\left| ${1:${VISUAL}} \right| +endsnippet + +snippet lr{ "left\{ right\}" w +\left\\{ ${1:${VISUAL}} \right\\} +endsnippet + +snippet lr[ "left[ right]" w +\left[ ${1:${VISUAL}} \right] +endsnippet + +# vim:ft=snippets: diff --git a/skel/.config/nvim/plugged/vim-snippets/UltiSnips/vim.snippets b/skel/.config/nvim/plugged/vim-snippets/UltiSnips/vim.snippets new file mode 100644 index 0000000..5655c4b --- /dev/null +++ b/skel/.config/nvim/plugged/vim-snippets/UltiSnips/vim.snippets @@ -0,0 +1,58 @@ +########################################################################### +# SnipMate Snippets # +########################################################################### +snippet header +" File: ${1:`!v expand('%:t')`} +" Author: ${2:`!v g:snips_author`} +" Description: ${3} +${4:" Last Modified: `!v strftime("%B %d, %Y")`} + +$0 +endsnippet + +snippet gvar "Global / configuration variable" +if !exists("g:${1:MyUltraImportantVar}") + let g:$1 = ${2:"${3:}"} +endif +endsnippet + +snippet guard +if exists('${1:did_`!p snip.rv = snip.fn.replace('.','_')`}') || &cp${2: || version < 700} + finish +endif +let $1 = 1${3} +endsnippet + +snippet f +fun ${1:function_name}(${2}) + ${3} +endf +endsnippet + +snippet for +for ${1} in ${2} + ${3} +endfor +endsnippet + +snippet wh +while ${1} + ${2} +endw +endsnippet + +snippet if +if ${1} + ${2} +endif +endsnippet + +snippet ife +if ${1} + ${2} +else + ${3} +endif +endsnippet + +# vim:ft=snippets: diff --git a/skel/.config/nvim/plugged/vim-snippets/UltiSnips/xhtml.snippets b/skel/.config/nvim/plugged/vim-snippets/UltiSnips/xhtml.snippets new file mode 100644 index 0000000..e69de29 diff --git a/skel/.config/nvim/plugged/vim-snippets/UltiSnips/xml.snippets b/skel/.config/nvim/plugged/vim-snippets/UltiSnips/xml.snippets new file mode 100644 index 0000000..80b017c --- /dev/null +++ b/skel/.config/nvim/plugged/vim-snippets/UltiSnips/xml.snippets @@ -0,0 +1,9 @@ +snippet t "Simple tag" b +<${1:tag}> + ${2:content} + +endsnippet + +snippet ti "Inline tag" b +<${1:tag}>${2:content} +endsnippet diff --git a/skel/.config/nvim/plugged/vim-snippets/UltiSnips/zsh.snippets b/skel/.config/nvim/plugged/vim-snippets/UltiSnips/zsh.snippets new file mode 100644 index 0000000..8039459 --- /dev/null +++ b/skel/.config/nvim/plugged/vim-snippets/UltiSnips/zsh.snippets @@ -0,0 +1,11 @@ +snippet #! "shebang" ! +#!/bin/zsh + +endsnippet + +snippet !env "#!/usr/bin/env (!env)" ! +#!/usr/bin/env zsh + +endsnippet + +# vim:ft=snippets: diff --git a/skel/.config/nvim/plugged/vim-snippets/addon-info.json b/skel/.config/nvim/plugged/vim-snippets/addon-info.json new file mode 100644 index 0000000..303bf28 --- /dev/null +++ b/skel/.config/nvim/plugged/vim-snippets/addon-info.json @@ -0,0 +1,9 @@ +{ + "name" : "snipmate-snippets", + "author" : "community", + "maintainer" : "honza @ github & others", + "repository" : {"type": "git", "url": "git://github.com/honza/snipmate-snippets.git"}, + "dependencies" : { + }, + "description" : "community driven set of snippets for snipmate" +} diff --git a/skel/.config/nvim/plugged/vim-snippets/autoload/vim_snippets.vim b/skel/.config/nvim/plugged/vim-snippets/autoload/vim_snippets.vim new file mode 100644 index 0000000..061f171 --- /dev/null +++ b/skel/.config/nvim/plugged/vim-snippets/autoload/vim_snippets.vim @@ -0,0 +1,27 @@ +" this is well known Filename found in snipmate (and the other engines), but +" rewritten and documented :) +" +" optional arg1: string in which to replace '$1' by filename with extension +" and path dropped. Defaults to $1 +" optional arg2: return this value if buffer has no filename +" But why not use the template in this case, too? +" Doesn't make sense to me +fun! vim_snippets#Filename(...) + let template = get(a:000, 0, "$1") + let arg2 = get(a:000, 1, "") + + let basename = expand('%:t:r') + + if basename == '' + return arg2 + else + return substitute(template, '$1', basename, 'g') + endif +endf + +" original code: +" fun! Filename(...) +" let filename = expand('%:t:r') +" if filename == '' | return a:0 == 2 ? a:2 : '' | endif +" return !a:0 || a:1 == '' ? filename : substitute(a:1, '$1', filename, 'g') +" endf diff --git a/skel/.config/nvim/plugged/vim-snippets/snippets/_.snippets b/skel/.config/nvim/plugged/vim-snippets/snippets/_.snippets new file mode 100644 index 0000000..6a3d8b2 --- /dev/null +++ b/skel/.config/nvim/plugged/vim-snippets/snippets/_.snippets @@ -0,0 +1,241 @@ +# Global snippets + +# (c) holds no legal value ;) +snippet c) + Copyright `&enc[:2] == "utf" ? "©" : "(c)"` `strftime("%Y")` ${1:`g:snips_author`}. All Rights Reserved. +snippet date + `strftime("%Y-%m-%d")` +snippet ddate + `strftime("%B %d, %Y")` +snippet time + `strftime("%H:%M")` +snippet datetime + `strftime("%Y-%m-%d %H:%M")` +snippet lorem + Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. +snippet GPL2 + ${1:One line to give the program's name and a brief description.} + Copyright (C) `strftime("%Y")` ${2:copyright holder} + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, see . + + ${0} +snippet LGPL2 + ${1:One line to give the program's name and a brief description.} + Copyright (C) `strftime("%Y")` ${2:copyright holder} + + This library is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published + by the Free Software Foundation; either version 2.1 of the License, or + (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this library; if not, see . + + ${0} +snippet GPL3 + ${1:one line to give the program's name and a brief description.} + Copyright (C) `strftime("%Y")` ${2:copyright holder} + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + + ${0} +snippet LGPL3 + ${1:One line to give the program's name and a brief description.} + Copyright (C) `strftime("%Y")` ${2:copyright holder} + + This library is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published + by the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this library; if not, see . + + ${0} +snippet BSD2 + ${1:one line to give the program's name and a brief description} + Copyright (C) `strftime("%Y")` ${2:copyright holder} + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY $2 ''AS IS'' AND ANY + EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL $2 BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + + The views and conclusions contained in the software and documentation + are those of the authors and should not be interpreted as representing + official policies, either expressedor implied, of $2. + + ${0} +snippet BSD3 + ${1:one line to give the program's name and a brief description} + Copyright (C) `strftime("%Y")` ${2:copyright holder} + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + 3. Neither the name of the ${3:organization} nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY $2 ''AS IS'' AND ANY + EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL $2 BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + ${0} +snippet BSD4 + ${1:one line to give the program's name and a brief description} + Copyright (C) `strftime("%Y")` ${2:copyright holder} + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + 3. All advertising materials mentioning features or use of this software + must display the following acknowledgement: + This product includes software developed by the ${3:organization}. + 4. Neither the name of the $3 nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY $2 ''AS IS'' AND ANY + EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL $2 BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + ${0} +snippet MIT + ${1:one line to give the program's name and a brief description} + Copyright (C) `strftime("%Y")` ${2:copyright holder} + + Permission is hereby granted, free of charge, to any person obtaining + a copy of this software and associated documentation files (the "Software"), + to deal in the Software without restriction, including without limitation + the rights to use, copy, modify, merge, publish, distribute, sublicense, + and/or sell copies of the Software, and to permit persons to whom the + Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included + in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE + OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + ${0} +snippet APACHE + ${1:one line to give the program's name and a brief description} + Copyright `strftime("%Y")` ${2:copyright holder} + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + ${0} +snippet BEERWARE + ${2:one line to give the program's name and a brief description} + Copyright `strftime("%Y")` ${3:copyright holder} + + Licensed under the "THE BEER-WARE LICENSE" (Revision 42): + ${1:`g:snips_author`} wrote this file. As long as you retain this notice you + can do whatever you want with this stuff. If we meet some day, and you think + this stuff is worth it, you can buy me a beer or coffee in return + + ${0} + +snippet WTFPL + DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE + Version 2, December 2004 + + Copyright `strftime("%Y")` ${0:copyright holder} + + Everyone is permitted to copy and distribute verbatim or modified + copies of this license document, and changing it is allowed as long + as the name is changed. + + DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. You just DO WHAT THE FUCK YOU WANT TO. diff --git a/skel/.config/nvim/plugged/vim-snippets/snippets/actionscript.snippets b/skel/.config/nvim/plugged/vim-snippets/snippets/actionscript.snippets new file mode 100644 index 0000000..6b1d8eb --- /dev/null +++ b/skel/.config/nvim/plugged/vim-snippets/snippets/actionscript.snippets @@ -0,0 +1,157 @@ +snippet main + package { + import flash.display.*; + import flash.Events.*; + + public class Main extends Sprite { + public function Main ( ) { + trace("start"); + stage.scaleMode = StageScaleMode.NO_SCALE; + stage.addEventListener(Event.RESIZE, resizeListener); + } + + private function resizeListener (e:Event):void { + trace("The application window changed size!"); + trace("New width: " + stage.stageWidth); + trace("New height: " + stage.stageHeight); + } + + } + + } +snippet class + ${1:public|internal} class ${2:name} ${0:extends } { + public function $2 ( ) { + ("start"); + } + } +snippet all + package name { + + ${1:public|internal|final} class ${2:name} ${0:extends } { + private|public| static const FOO = "abc"; + private|public| static var BAR = "abc"; + + // class initializer - no JIT !! one time setup + if Cababilities.os == "Linux|MacOS" { + FOO = "other"; + } + + // constructor: + public function $2 ( ){ + super2(); + trace("start"); + } + public function name (a, b...){ + super.name(..); + lable:break + } + } + } + + function A(){ + // A can only be accessed within this file + } +snippet switch + switch(${1}){ + case ${2}: + ${0} + break; + default: + } +snippet case + case ${1}: + ${0} + break; +snippet package + package ${1:package}{ + ${0} + } +snippet wh + while ${1:cond}{ + ${0} + } +snippet do + do { + ${0} + } while (${1:cond}) +snippet wh + while ${1:cond}{ + ${0} + } +snippet for enumerate names + for (${1:var} in ${2:object}){ + ${0} + } +snippet for enumerate values + for each (${1:var} in ${2:object}){ + ${0} + } +snippet get_set + function get ${1:name} { + return ${2} + } + function set $1 (newValue) { + ${0} + } +snippet interface + interface name { + function method(${1}):${0:returntype}; + } +snippet try + try { + ${1} + } catch (error:ErrorType) { + ${2} + } finally { + ${0} + } +# For Loop (same as c.snippet) +snippet for for (..) {..} + for (${2:i} = 0; $2 < ${1:count}; $2${3:++}) { + ${0} + } +# Custom For Loop +snippet forr + for (${1:i} = ${2:0}; ${3:$1 < 10}; $1${4:++}) { + ${0} + } +# If Condition +snippet if + if (${1:/* condition */}) { + ${0} + } +snippet el + else { + ${0} + } +# Ternary conditional +snippet t + ${1:/* condition */} ? ${2:a} : ${0:b} +snippet fun + function ${1:function_name}(${2})${3} + { + ${0} + } +# FlxSprite (usefull when using the flixel library) +snippet FlxSprite + package + { + import org.flixel.* + + public class ${1:ClassName} extends ${2:FlxSprite} + { + public function $1(${3: X:Number, Y:Number}):void + { + super(X,Y); + ${4} + } + + override public function update():void + { + super.update(); + ${0} + } + } + } + diff --git a/skel/.config/nvim/plugged/vim-snippets/snippets/apache.snippets b/skel/.config/nvim/plugged/vim-snippets/snippets/apache.snippets new file mode 100644 index 0000000..db3256e --- /dev/null +++ b/skel/.config/nvim/plugged/vim-snippets/snippets/apache.snippets @@ -0,0 +1,35 @@ +# Snippets for code blocks used oftenly in Apache files. +# +snippet dir + + DirectoryIndex ${0:index.html} + Order Deny,Allow + Deny from All + +# +snippet filesmatch + + ${0} + +# +snippet ifmodule + + ${0} + +# +snippet limitexcept + + ${0} + +# +snippet proxy + + ${0} + +# +snippet virtualhost + + ServerAdmin ${3:webmaster@example.com} + DocumentRoot ${4:/www/example.com} + ServerName ${0:www.example.com} + diff --git a/skel/.config/nvim/plugged/vim-snippets/snippets/autoit.snippets b/skel/.config/nvim/plugged/vim-snippets/snippets/autoit.snippets new file mode 100644 index 0000000..f973fbc --- /dev/null +++ b/skel/.config/nvim/plugged/vim-snippets/snippets/autoit.snippets @@ -0,0 +1,66 @@ +snippet if + If ${1:condition} Then + ${0:; True code} + EndIf +snippet el + Else + ${0} +snippet eif + ElseIf ${1:condition} Then + ${0:; True code} +# If/Else block +snippet ife + If ${1:condition} Then + ${2:; True code} + Else + ${0:; Else code} + EndIf +# If/ElseIf/Else block - because there is eif this is not really neccessary +snippet ifelif + If ${1:condition 1} Then + ${2:; True code} + ElseIf ${3:condition 2} Then + ${4:; True code} + Else + ${0:; Else code} + EndIf +# Switch block +snippet switch + Switch (${1:condition}) + Case ${2:case1}: + ${3:; Case 1 code} + Case Else: + ${0:; Else code} + EndSwitch +# Select block +snippet select + Select (${1:condition}) + Case ${2:case1}: + ${3:; Case 1 code} + Case Else: + ${0:; Else code} + EndSelect +# While loop +snippet wh + While (${1:condition}) + ${0:; code...} + WEnd +# For loop +snippet for + For ${1:n} = ${3:1} to ${2:count} + ${0:; code...} + Next +# New Function +snippet func + Func ${1:fname}(${2:`indent('.') ? 'self' : ''`}): + ${0:Return} + EndFunc +# Message box +snippet msg + MsgBox(${0:MsgType}, ${1:"Title"}, ${2:"Message Text"}) +# Debug Message +snippet debug + MsgBox(0, "Debug", ${0:"Debug Message"}) +# Show Variable Debug Message +snippet showvar + MsgBox(0, "${0:VarName}", $1) diff --git a/skel/.config/nvim/plugged/vim-snippets/snippets/bootstrap2.snippets b/skel/.config/nvim/plugged/vim-snippets/snippets/bootstrap2.snippets new file mode 100644 index 0000000..96d5dd8 --- /dev/null +++ b/skel/.config/nvim/plugged/vim-snippets/snippets/bootstrap2.snippets @@ -0,0 +1,840 @@ +snippet abtn + ${2:Text} + +snippet abtnblock + ${2:Text} + +snippet abtndanger + ${2:Text} + +snippet abtninfo + ${2:Text} + +snippet abtninverse + ${2:Text} + +snippet abtnlarge + ${2:Text} + +snippet abtnmini + ${2:Text} + +snippet abtnprimary + ${2:Text} + +snippet abtnsmall + ${2:Text} + +snippet abtnsuccess + ${2:Text} + +snippet abtnwarning + ${2:Text} + +snippet aclose + × + +snippet adisabled + ${1:Primary link} + +snippet alert +
    + + ${1:Warning!} ${2:Best check yo self, you're not looking too good.} +
    + +snippet alertblock +
    + +

    ${1:Warning!}

    + ${2:Best check yo self, you're not...} +
    + +snippet alerterror +
    + ${1:...} +
    + + +snippet alertinfo +
    + ${1:...} +
    + + +snippet alertsuccess +
    + ${1:...} +
    + + +snippet badge + ${1:1} + +snippet badgeimportant + ${1:2} + +snippet badgeinfo + ${1:2} + +snippet badgeinverse + ${1:2} + +snippet badgesuccess + ${1:2} + +snippet badgewarning + ${1:2} + +snippet breadcrumb + + +snippet btn + + +snippet btnblock + + +snippet btndanger + + +snippet btndisabled + + +snippet btndropdown +
    + + ${1:Action} + + + +
    + +snippet btndropdownsplit +
    + + + +
    + +snippet btndropup +
    + + + +
    + + +snippet btngroup +
    + + + +
    + +snippet btngroupvertical +
    + ${1:...} +
    + +snippet btninfo + + +snippet btninverse + + +snippet btnlarge + + +snippet btnlink + + +snippet btnmini + + +snippet btnprimary + + +snippet btnsmall + + +snippet btnsuccess + + +snippet btntoolbar +
    +
    + ${1:...} +
    +
    + +snippet btnwarning + + +snippet checkboxinline + + +snippet close + + +snippet container +
    + ${1:...} +
    + +snippet containerfluid +
    + ${1:...} +
    + +snippet controlsrow +
    + + +
    + +snippet dlhorizontal +
    +
    ${1:...}
    +
    ${2:...}
    +
    + +snippet dropdownmenu + + +snippet form +
    +
    + ${1:Legend} + + + ${4:Example block-level help text here.} + + +
    +
    + +snippet formactions +
    + + +
    + +snippet formhorizontal +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    +
    + + +
    +
    +
    + +snippet forminline +
    + + + + +
    + +snippet formsearch + + +snippet helpblock + ${1:A longer block of help text that breaks onto a new line and may extend beyond one line.} + +snippet helpinline + ${1:Inline help text} + +snippet herounit +
    +

    ${1:Heading}

    +

    ${2:Tagline}

    +

    + + ${3:Learn more} + +

    +
    + + +snippet icon + + +snippet iconwhite + + +snippet imgcircle + + +snippet imgpolaroid + + +snippet imgrounded + + +snippet initialism + ${2:HTML} + +snippet inline +
      +
    • ${1:...}
    • +
    + +snippet inputappend +
    + + ${1:.00} +
    + +snippet inputappendbtn +
    + + +
    + +snippet inputappendbtndropdown +
    + +
    + + +
    +
    + +snippet inputblocklevel + + +snippet inputlarge + + +snippet inputmedium + + +snippet inputmini + + +snippet inputprepend +
    + ${1:@} + +
    + +snippet inputprependappend +
    + ${1:$} + + ${3:.00} +
    + + +snippet inputsmall + + +snippet inputxlarge + + +snippet inputxxlarge + + +snippet label + ${1:Default} + +snippet labelimportant + ${1:Important} + +snippet labelinfo + ${1:Info} + +snippet labelinverse + ${1:Inverse} + +snippet labelsuccess + ${1:Success} + +snippet labelwarning + ${1:Warning} + +snippet lead +

    ${1:...}

    + +snippet media +
    + + + +
    +

    Media heading

    + ${2:...} + + +
    + ${3:...} +
    +
    +
    + +snippet medialist +
      +
    • + + + +
      +

      Media heading

      + ${2:...} + + +
      + ${3:...} +
      +
      +
    • +
    + +snippet muted +

    ${1:Fusce dapibus, tellus ac cursus commodo, tortor mauris nibh.}

    + +snippet navbar + + +snippet navbarcollapse + + +snippet navbarfixedbottom + + +snippet navbarfixedtop + + +snippet navbarform + + +snippet navbarsearch + + +snippet navbarstatictop + + +snippet navlist + + +snippet navpills + + +snippet navpillsdropdown + + +snippet navpillsstacked + + +snippet navtabs + + +snippet navtabsdropdown + + +snippet navtabsstacked + + +snippet pageheader + + +snippet pager + + + +snippet pageraligned + + + +snippet pagination + + +snippet paginationcentered + + +snippet paginationlarge + + + +snippet paginationmini + + + +snippet paginationright + + +snippet paginationsmall + + + +snippet prescrollable +
    +	  ${1:<p>Sample text here...</p>}
    +	
    + +snippet progress +
    +
    +
    + +snippet progressdanger +
    +
    +
    + +snippet progressinfo +
    +
    +
    + +snippet progressstacked +
    +
    +
    +
    +
    + +snippet progressstriped +
    +
    +
    + +snippet progressstripedactive +
    +
    +
    + +snippet progresssuccess +
    +
    +
    + +snippet progresswarning +
    +
    +
    + +snippet row +
    +
    ${2:...}
    +
    ${4:...}
    +
    + +snippet rowfluid +
    +
    ${2:...}
    +
    ${4:...}
    +
    + +snippet tabbable +
    + +
    +
    +

    ${3:I'm in Section 1.}

    +
    +
    +

    ${4:Howdy, I'm in Section 2.}

    +
    +
    +
    + +snippet tabbabletabsbelow +
    +
    + ${1:...} +
    + +
    + +snippet tabbabletabsleft +
    +
    + ${1:...} +
    + +
    + +snippet tabbabletabsright +
    +
    + ${1:...} +
    + +
    + +snippet table + + ${1:...} +
    + +snippet tablebordered + + ${1:...} +
    + +snippet tablecondensed + + ${1:...} +
    + +snippet tablehover + + ${1:...} +
    + +snippet tablestriped + + ${1:...} +
    + +snippet textcenter +

    ${1:Center aligned text.}

    + +snippet texterror +

    ${1:Donec ullamcorper nulla non metus auctor fringilla.}

    + +snippet textinfo +

    ${1:Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis.}

    + +snippet textleft +

    ${1:Left aligned text.}

    + +snippet textright +

    ${1:Right aligned text.}

    + +snippet textsuccess +

    ${1:Duis mollis, est non commodo luctus, nisi erat porttitor ligula.}

    + +snippet textwarning +

    ${1:Etiam porta sem malesuada magna mollis euismod.}

    + +snippet thumbnails + + + +snippet thumbnailsdiv +
      +
    • +
      + +

      ${2:Thumbnail label}

      +

      ${3:Thumbnail caption...}

      +
      +
    • + ${4:...} +
    + +snippet uneditableinput + ${1:Some value here} + +snippet unstyled +
      +
    • ${1:...}
    • +
    + +snippet well +
    + ${1:...} +
    + +snippet welllarge +
    + ${1:...} +
    + +snippet wellsmall +
    + ${1:...} +
    diff --git a/skel/.config/nvim/plugged/vim-snippets/snippets/bootstrap3.snippets b/skel/.config/nvim/plugged/vim-snippets/snippets/bootstrap3.snippets new file mode 100644 index 0000000..d78f9be --- /dev/null +++ b/skel/.config/nvim/plugged/vim-snippets/snippets/bootstrap3.snippets @@ -0,0 +1,63 @@ +snippet fg +
    + +
    + +
    +
    +snippet form-h +
    +
    +
    + +
    +
    +
    +snippet sel + ${2} +snippet abtn + ${2:Text} + +snippet abtnblock + ${2:Text} + +snippet abtndanger + ${2:Text} + +snippet abtninfo + ${2:Text} + +snippet abtninverse + ${2:Text} + +snippet abtnlarge + ${2:Text} + +snippet abtnmini + ${2:Text} + +snippet abtnprimary + ${2:Text} + +snippet abtnsmall + ${2:Text} + +snippet abtnsuccess + ${2:Text} + +snippet abtnwarning + ${2:Text} +snippet btn + + +snippet btnblock + + +snippet btndanger + + +snippet btndisabled + + diff --git a/skel/.config/nvim/plugged/vim-snippets/snippets/c.snippets b/skel/.config/nvim/plugged/vim-snippets/snippets/c.snippets new file mode 100644 index 0000000..96e19a0 --- /dev/null +++ b/skel/.config/nvim/plugged/vim-snippets/snippets/c.snippets @@ -0,0 +1,237 @@ +## Main +# main +snippet main + int main(int argc, const char *argv[]) + { + ${0} + return 0; + } +# main(void) +snippet mainn + int main(void) + { + ${0} + return 0; + } +## +## Preprocessor +# #include <...> +snippet inc + #include <${1:stdio}.h> +# #include "..." +snippet Inc + #include "${1:`vim_snippets#Filename("$1.h")`}" +# ifndef...define...endif +snippet ndef + #ifndef $1 + #define ${1:SYMBOL} ${2:value} + #endif +# define +snippet def + #define +# ifdef...endif +snippet ifdef + #ifdef ${1:FOO} + ${2:#define } + #endif +# if +snippet #if + #if ${1:FOO} + ${0} + #endif +# header include guard +snippet once + #ifndef ${1:`toupper(vim_snippets#Filename('$1_H', 'UNTITLED_H'))`} + + #define $1 + + ${0} + + #endif /* end of include guard: $1 */ +## +## Control Statements +# if +snippet if + if (${1:/* condition */}) { + ${2} + } +# else +snippet el + else { + ${1} + } +# else if +snippet elif + else if (${1:/* condition */}) { + ${2} + } +# ifi +snippet ifi + if (${1:/* condition */}) ${2}; +# ternary +snippet t + ${1:/* condition */} ? ${2:a} : ${3:b} +# switch +snippet switch + switch (${1:/* variable */}) { + case ${2:/* variable case */}: + ${3} + ${4:break;}${5} + default: + ${6} + } +# switch without default +snippet switchndef + switch (${1:/* variable */}) { + case ${2:/* variable case */}: + ${3} + ${4:break;}${5} + } +# case +snippet case + case ${1:/* variable case */}: + ${2} + ${3:break;} +## +## Loops +# for +snippet for + for (${2:i} = 0; $2 < ${1:count}; $2${3:++}) { + ${4} + } +# for (custom) +snippet forr + for (${1:i} = ${2:0}; ${3:$1 < 10}; $1${4:++}) { + ${5} + } +# while +snippet wh + while (${1:/* condition */}) { + ${2} + } +# do... while +snippet do + do { + ${2} + } while (${1:/* condition */}); +## +## Functions +# function definition +snippet fun + ${1:void} ${2:function_name}(${3}) + { + ${4} + } +# function declaration +snippet fund + ${1:void} ${2:function_name}(${3}); +## +## Types +# typedef +snippet td + typedef ${1:int} ${2:MyCustomType}; +# struct +snippet st + struct ${1:`vim_snippets#Filename('$1_t', 'name')`} { + ${2:/* data */} + }${3: /* optional variable list */}; +# typedef struct +snippet tds + typedef struct ${2:_$1 }{ + ${3:/* data */} + } ${1:`vim_snippets#Filename('$1_t', 'name')`}; +# typedef enum +snippet tde + typedef enum { + ${1:/* data */} + } ${2:foo}; +## +## Input/Output +# printf +snippet pr + printf("${1:%s}\n"${2}); +# fprintf (again, this isn't as nice as TextMate's version, but it works) +snippet fpr + fprintf(${1:stderr}, "${2:%s}\n"${3}); +# getopt +snippet getopt + int choice; + while (1) + { + static struct option long_options[] = + { + /* Use flags like so: + {"verbose", no_argument, &verbose_flag, 'V'}*/ + /* Argument styles: no_argument, required_argument, optional_argument */ + {"version", no_argument, 0, 'v'}, + {"help", no_argument, 0, 'h'}, + ${1} + {0,0,0,0} + }; + + int option_index = 0; + + /* Argument parameters: + no_argument: " " + required_argument: ":" + optional_argument: "::" */ + + choice = getopt_long( argc, argv, "vh", + long_options, &option_index); + + if (choice == -1) + break; + + switch( choice ) + { + case 'v': + ${2} + break; + + case 'h': + ${3} + break; + + case '?': + /* getopt_long will have already printed an error */ + break; + + default: + /* Not sure how to get here... */ + return EXIT_FAILURE; + } + } + + /* Deal with non-option arguments here */ + if ( optind < argc ) + { + while ( optind < argc ) + { + ${0} + } + } +## +## Miscellaneous +# This is kind of convenient +snippet . + [${1}] +# GPL +snippet gpl + /* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see . + * + * Copyright (C) ${1:Author}, `strftime("%Y")` + */ + + ${0} diff --git a/skel/.config/nvim/plugged/vim-snippets/snippets/chef.snippets b/skel/.config/nvim/plugged/vim-snippets/snippets/chef.snippets new file mode 100644 index 0000000..429146a --- /dev/null +++ b/skel/.config/nvim/plugged/vim-snippets/snippets/chef.snippets @@ -0,0 +1,204 @@ +# Opscode Chef Cookbook Recipe Resources +# Snippet by: Mike Smullin +# Based on: http://wiki.opscode.com/display/chef/Resources + +# @TODO: Include Meta attributes and actions in all snippets +# @TODO: Finish writing snippets for remaining Resources + +snippet cookbook_file + # Cookbook File resource + cookbook_file ${1:"/path/to/file"} do # The remote path where the file will reside + ${2:#}backup ${3} # How many backups of this file to keep. Set to false if you want no backups + ${4:#}group ${5} # The group owner of the file (string or id) + ${6:#}mode ${7} # The octal mode of the file - e.g. 0755 + ${8:#}owner ${9} # The owner for the file + ${10:#}source ${11} # The basename of the source file + ${12:#}cookbook ${13} # The cookbook this file is stored in + + ${14:#}${15: action :create} # Create this file (Default) + ${16:#}${17: action :create_if_missing} # Create only if it doesn't exist yet + ${18:#}${0: action :delete} # Delete this file + end + +snippet execute + # Execute resource + execute ${1:"command to execute"} do # The command to execute + ${2:#}creates ${3:nil} # A file this command creates - if the file exists, the command will not be run. + ${4:#}cwd ${5:nil} # Current working directory to run the command from. + ${6:#}environment ${7:nil} # A hash of environment variables to set before running this command. + ${8:#}group ${9:nil} # A group name or group ID that we should change to before running this command. + ${10:#}path ${11:nil} # An array of paths to use when searching for the command. Nil uses system path. + ${12:#}returns ${13:0} # The return value of the command - this resource raises an exception if the return value does not match. + ${14:#}timeout ${15:nil} # How many seconds to let the command run before timing it out. + ${16:#}user ${17:nil} # A user name or user ID that we should change to before running this command. + ${18:#}umask ${19:nil} # Umask for files created by the command + + ${20:#}${21:action :run} # Run this command (Default) + ${22:#}${0:action :nothing} # Do not run this command + end + +snippet link + # Link resource + link ${1:"/target/file"} do # The file name of the link + ${2:#}to ${3} # The real file you want to link to + ${4:#}link_type ${5:symbolic} # Either :symbolic or :hard + ${6:#}owner ${7} # The owner of the symlink + ${8:#}group ${9} # The group of the symlink + + ${10:#}${11:action :create} # Create a link (Default) + ${12:#}${0:action :delete} # Delete a link + end + +snippet package + # Package resource + package ${1:"package_name"} do # Name of the package to install + ${2:#}version ${3:nil} # The version of the package to install/upgrade + ${4:#}response_file ${5:nil} # An optional response file - used to pre-seed packages (note: the file is fetched by Remote File) + ${6:#}source ${7} # Used to provide an optional package source for providers that use a local file (rubygems, dpkg and rpm) + ${8:#}options ${9:nil} # Add additional options to the underlying package command + ${10:#}gem_binary ${11:gem} # A gem_package attribut to specify a gem binary. Useful for installing ruby 1.9 gems while running chef in ruby 1.8 + + ${12:#}${13:action :install} # Install a package - if version is provided, install that specific version (Default) + ${14:#}${15:action :upgrade} # Upgrade a package - if version is provided, upgrade to that specific version + ${16:#}${17:action :remove} # Remove a package + ${18:#}${0:action :purge} # Purge a package (this usually entails removing configuration files as well as the package itself) + end + +snippet service + # Service resource + service ${1:"service_name"} do # Name of the service + ${2:#}enabled ${3:nil} # Whether the service is enabled at boot time + ${4:#}running ${5:nil} # Make sure the service is running. Start if stopped + ${6:#}pattern ${7} # Pattern to look for in the process table + ${8:#}start_command ${9:nil} # Command used to start this service + ${10:#}stop_command ${11:nil} # Command used to stop this service + ${12:#}status_command ${13:nil} # Command used to check the service run status + ${14:#}restart_command ${15:nil} # Command used to restart this service + ${16:#}reload_command ${17:nil} # Command used to tell this service to reload its configuration + ${18:#}supports ${19:false} # Features this service supports, ie :restart, :reload, :status + + ${20:#}${21:action :enable} # Enable this service + ${22:#}${23:action :disable} # Disable this service + ${24:#}${25:action :nothing} # Don't do anything with this service (Default) + ${26:#}${27:action :start} # Start this service + ${28:#}${29:action :stop} # Stop this service + ${30:#}${31:action :restart} # Restart this service + ${32:#}${0:action :reload} # Reload the configuration for this service + end + +snippet file + # File resource + file ${1:"/path/to/file"} do # Path to the file + ${2:#}backup ${3:5} # How many backups of this file to keep. Set to false if you want no backups. + ${4:#}owner ${5} # The owner for the file + ${6:#}group ${7} # The group owner of the file (string or id) + ${8:#}mode ${9} # The octal mode of the file (4-digit format) + ${10:#}content ${11:nil} # A string to write to the file. This will replace any previous content if set + + ${12:#}${13:action :create} # Create this file (Default) + ${14:#}${15:action :delete} # Delete this file + ${16:#}${0:action :touch} # Touch this file (update the mtime/atime) + end + +snippet directory + # Directory resource + directory ${1:"/path/to/dir"} do # The path to the directory + ${2:#}group ${3} # The group owner of the directory (string or id) + ${4:#}mode ${5} # The octal mode of the directory, eg 0755 + ${6:#}owner ${7} # The owner for the directory + ${10:#}recursive ${11:false} # When deleting the directory, delete it recursively. When creating the directory, create recursively (ie, mkdir -p) + + ${12:#}${13:action :create} # Create this directory (Default) + ${14:#}${0:action :delete} # Delete this directory + end + +snippet template + # Template resource + template ${1:"/path/to/file"} do # Path to the file + ${2:#}cookbook ${3:nil} # Specify the cookbook where the template is located, default is current cookbook + ${4:#}source ${5:nil} # Template source file. Found in templates/default for the cookbook + ${6:#}variables ${7} # Variables to use in the template + ${8:#}local ${9:false} # Is the template already present on the node? + ${10:#}backup ${11:5} # How many backups of this file to keep. Set to false if you want no backups. + ${12:#}owner ${13} # The owner for the file + ${14:#}group ${15} # The group owner of the file (string or id) + ${16:#}mode ${17} # The octal mode of the file (4-digit format) + ${18:#}content ${19:nil} # A string to write to the file. This will replace any previous content if set + + ${20:#}${21:action :create} # Create the file (Default) + ${22:#}${23:action :delete} # Delete this file + ${24:#}${0:action :touch} # Touch this file (update the mtime/atime) + end + +snippet svn + # SCM Resource, Chef::Provider::Subversion + svn ${1:"/destination/path"} do # Path to clone/checkout/export the source to + ${2:#}repository ${3} # URI of the repository + ${4:#}revision ${5:"HEAD"} # revision to checkout. can be symbolic, like "HEAD" or an SCM specific revision id + ${6:#}reference ${7} # (Git only) alias for revision + ${8:#}user ${9:nil} # System user to own the checked out code + ${10:#}group ${11:nil} # System group to own the checked out code + ${12:#}svn_username ${13} # (Subversion only) Username for Subversion operations + ${14:#}svn_password ${15} # (Subversion only) Password for Subversion operations + ${16:#}svn_arguments ${17} # (Subversion only) Extra arguments passed to the subversion command + + ${18:#}${19:action :sync} # Update the source to the specified revision, or get a new checkout (Default) + ${20:#}${21:action :checkout} # Checkout the source. Does nothing if a checkout is available + ${22:#}${0:action :export} # Export the source, excluding or removing any version control artifacts + end + +snippet git + # SCM Resource, Chef::Provider::Git + git ${1:"/destination/path"} do # Path to clone/checkout/export the source to + ${2:#}repository ${3} # URI of the repository + ${4:#}revision ${5:"HEAD"} # revision to checkout. can be symbolic, like "HEAD" or an SCM specific revision id + ${6:#}reference ${7} # (Git only) alias for revision + ${8:#}user ${9:nil} # System user to own the checked out code + ${10:#}group ${11:nil} # System group to own the checked out code + ${12:#}depth ${13:nil} # (Git only) Number of past revisions to include in Git shallow clone + ${14:#}enable_submodules ${15:"false"} # (Git only) performs a submodule init and submodule update + ${16:#}remote ${17:"origin"} # (Git only) remote repository to use for syncing an existing clone + ${18:#}ssh_wrapper ${19} # (Git only) path to a wrapper script for running SSH with git. GIT_SSH environment variable is set to this. + + ${20:#}${21:action :sync} # Update the source to the specified revision, or get a new clone (Default) + ${22:#}${23:action :checkout} # Clone the source. Does nothing if a checkout is available + ${24:#}${0:action :export} # Export the source, excluding or removing any version control artifacts + end + +snippet deploy + # Deploy resource + deploy ${1:"/deploy/dir/"} do # Path to deploy to + ${2:#}deploy_to ${3} # The "meta root" for your application. + ${4:#}repository ${5} # URI of the repository + ${6:#}repo ${7} # alias for repository + ${8:#}revision ${9:"HEAD"} # revision to checkout. can be symbolic, like "HEAD" or an SCM specific revision id + ${10:#}branch ${11} # alias for revision + ${12:#}user ${13:nil} # System user to run the deploy as + ${14:#}group ${15:nil} # System group to run the deploy as + ${16:#}svn_username ${17} # (Subversion only) Username for Subversion operations} + ${18:#}svn_password ${19} # (Subversion only) Password for Subversion operations} + ${20:#}svn_arguments ${21} # (Subversion only) Extra arguments passed to the subversion command} + ${22:#}shallow_clone ${23:nil} # (Git only) boolean, true sets clone depth to 5 + ${24:#}enable_submodules ${25:false} # (Git only) performs a submodule init and submodule update + ${26:#}remote ${27:"origin"} # (Git only) remote repository to use for syncing an existing clone + ${28:#}ssh_wrapper ${29} # (Git only) path to a wrapper script for running SSH with git. GIT_SSH environment variable is set to this. + ${30:#}git_ssh_wrapper ${31} # alias for ssh_wrapper + ${32:#}scm_provider ${33:Chef::Provider::Git} # SCM Provider to use. + ${34:#}repository_cache ${35: "cached-copy"} # Name of the subdirectory where the pristine copy of your app's source is kept + ${36:#}environment ${37} # A hash of the form {"ENV_VARIABLE"=>"VALUE"}} + ${38:#}purge_before_symlink ${39:%w(log tmp/pids public/system)} # An array of paths, relative to app root, to be removed from a checkout before symlinking + ${40:#}create_dirs_before_symlink ${41:%w(tmp public config)} # Directories to create before symlinking. Runs after purge_before_symlink + ${42:#}symlinks ${43:"system" => "public/system", "pids" => "tmp/pids", "log" => "log"} # A hash that maps files in the shared directory to their paths in the current release + ${44:#}symlink_before_migrate ${45:"config/database.yml" => "config/database.yml"} # A hash that maps files in the shared directory into the current release. Runs before migration + ${46:#}migrate ${47:false} # Should the migration command be executed? (true or false) + ${48:#}migration_command ${49} # A string containing a shell command to execute to run the migration + ${50:#}restart_command ${51:nil} # A code block to evaluate or a string containing a shell command + ${52:#}before_migrate ${53:"deploy/before_migrate.rb"} # A block or path to a file containing chef code to run before migrating + ${54:#}before_symlink ${55:"deploy/before_symlink.rb"} # A block or path to a file containing chef code to run before symlinking + ${56:#}before_restart ${57:"deploy/before_restart.rb"} # A block or path to a file containing chef code to run before restarting + ${58:#}after_restart ${59:"deploy/after_restart.rb"} # A block or path to a file containing chef code to run after restarting + + ${60:#}${61::deploy} # Deploy the application (Default) + ${62:#}${63::force_deploy} # For the revision deploy strategy, this removes any existing release of the same code version and re-deploys in its place + ${64:#}${0::rollback} # Rollback the application to the previous release + end diff --git a/skel/.config/nvim/plugged/vim-snippets/snippets/clojure.snippets b/skel/.config/nvim/plugged/vim-snippets/snippets/clojure.snippets new file mode 100644 index 0000000..6fd653f --- /dev/null +++ b/skel/.config/nvim/plugged/vim-snippets/snippets/clojure.snippets @@ -0,0 +1,90 @@ +snippet comm + (comment + ${0} + ) +snippet condp + (condp ${1:pred} ${2:expr} + ${0}) +snippet def + (def ${0}) +snippet defm + (defmethod ${1:multifn} "${2:doc-string}" ${3:dispatch-val} [${4:args}] + ${0}) +snippet defmm + (defmulti ${1:name} "${2:doc-string}" ${0:dispatch-fn}) +snippet defma + (defmacro ${1:name} "${2:doc-string}" ${0:dispatch-fn}) +snippet defn + (defn ${1:name} "${2:doc-string}" [${3:arg-list}] + ${0}) +snippet defp + (defprotocol ${1:name} + ${0}) +snippet defr + (defrecord ${1:name} [${2:fields}] + ${3:protocol} + ${0}) +snippet deft + (deftest ${1:name} + (is (= ${2:assertion}))) + ${0}) +snippet is + (is (= ${1} ${0})) +snippet defty + (deftype ${1:Name} [${2:fields}] + ${3:Protocol} + ${0}) +snippet doseq + (doseq [${1:elem} ${2:coll}] + ${0}) +snippet fn + (fn [${1:arg-list}] ${0}) +snippet if + (if ${1:test-expr} + ${2:then-expr} + ${0:else-expr}) +snippet if-let + (if-let [${1:result} ${2:test-expr}] + (${3:then-expr} $1) + (${0:else-expr})) +snippet imp + (:import [${1:package}]) + & {:keys [${1:keys}] :or {${0:defaults}}} +snippet let + (let [${1:name} ${2:expr}] + ${0}) +snippet letfn + (letfn [(${1:name) [${2:args}] + ${0})]) +snippet map + (map ${1:func} ${0:coll}) +snippet mapl + (map #(${1:lambda}) ${0:coll}) +snippet met + (${1:name} [${2:this} ${3:args}] + ${0}) +snippet ns + (ns ${1:name} + ${0}) +snippet dotimes + (dotimes [_ 10] + (time + (dotimes [_ ${1:times}] + ${0}))) +snippet pmethod + (${1:name} [${2:this} ${0:args}]) +snippet refer + (:refer-clojure :exclude [${0}]) +snippet require + (:require [${1:namespace} :as [${0}]]) +snippet use + (:use [${1:namespace} :only [${0}]]) +snippet print + (println ${0}) +snippet reduce + (reduce ${1:(fn [p n] ${3})} ${2}) +snippet when + (when ${1:test} ${0:body}) +snippet when-let + (when-let [${1:result} ${2:test}] + ${0:body}) diff --git a/skel/.config/nvim/plugged/vim-snippets/snippets/cmake.snippets b/skel/.config/nvim/plugged/vim-snippets/snippets/cmake.snippets new file mode 100644 index 0000000..ef2256a --- /dev/null +++ b/skel/.config/nvim/plugged/vim-snippets/snippets/cmake.snippets @@ -0,0 +1,58 @@ +snippet cmake + CMAKE_MINIMUM_REQUIRED(VERSION 2.6) + PROJECT(${1:ProjectName}) + + FIND_PACKAGE(${2:LIBRARY}) + + INCLUDE_DIRECTORIES( + ${$2_INCLUDE_DIR} + ) + + ADD_SUBDIRECTORY(${0:src}) + + ADD_EXECUTABLE($1) + + TARGET_LINK_LIBRARIES($1 + ${$2_LIBRARIES} + ) + +snippet include + INCLUDE_DIRECTORIES( + ${${0:INCLUDE_DIR}} + ) + +snippet find + FIND_PACKAGE(${0:LIBRARY}) + +snippet glob + FILE(GLOB ${1:SRCS} *.${0:cpp}) + +snippet subdir + ADD_SUBDIRECTORY(${0:src}) + +snippet lib + ADD_LIBRARY(${1:lib} ${2:STATIC} + ${${0:SRCS}} + ) + +snippet link + TARGET_LINK_LIBRARIES(${1:bin} + ${0:somelib} + ) + +snippet bin + ADD_EXECUTABLE(${1:bin}) + +snippet set + SET(${1:var} ${0:val}) + +snippet dep + ADD_DEPENDENCIES(${1:target} + ${0:dep} + ) + +snippet props + SET_TARGET_PROPERTIES(${1:target} + ${2:PROPERTIES} ${3:COMPILE_FLAGS} + ${0:"-O3 -Wall -pedantic"} + ) diff --git a/skel/.config/nvim/plugged/vim-snippets/snippets/coffee.snippets b/skel/.config/nvim/plugged/vim-snippets/snippets/coffee.snippets new file mode 100644 index 0000000..aca6e81 --- /dev/null +++ b/skel/.config/nvim/plugged/vim-snippets/snippets/coffee.snippets @@ -0,0 +1,95 @@ +# Closure loop +snippet forindo + for ${1:name} in ${2:array} + do ($1) -> + ${0:// body} +# Array comprehension +snippet fora + for ${1:name} in ${2:array} + ${0:# body...} +# Object comprehension +snippet foro + for ${1:key}, ${2:value} of ${3:object} + ${0:# body...} +# Range comprehension (inclusive) +snippet forr + for ${1:name} in [${2:start}..${3:finish}] + ${0:# body...} +snippet forrb + for ${1:name} in [${2:start}..${3:finish}] by ${4:step} + ${0:# body...} +# Range comprehension (exclusive) +snippet forrex + for ${1:name} in [${2:start}...${3:finish}] + ${0:# body...} +snippet forrexb + for ${1:name} in [${2:start}...${3:finish}] by ${4:step} + ${0:# body...} +# Function +snippet fun + (${1:args}) -> + ${0:# body...} +# Function (bound) +snippet bfun + (${1:args}) => + ${0:# body...} +# Class +snippet cla class .. + class ${1:`substitute(vim_snippets#Filename(), '\(_\|^\)\(.\)', '\u\2', 'g')`} + ${0} +snippet cla class .. constructor: .. + class ${1:`substitute(vim_snippets#Filename(), '\(_\|^\)\(.\)', '\u\2', 'g')`} + constructor: (${2:args}) -> + ${3} + + ${0} +snippet cla class .. extends .. + class ${1:`substitute(vim_snippets#Filename(), '\(_\|^\)\(.\)', '\u\2', 'g')`} extends ${2:ParentClass} + ${0} +snippet cla class .. extends .. constructor: .. + class ${1:`substitute(vim_snippets#Filename(), '\(_\|^\)\(.\)', '\u\2', 'g')`} extends ${2:ParentClass} + constructor: (${3:args}) -> + ${4} + + ${0} +# If +snippet if + if ${1:condition} + ${0:# body...} +# If __ Else +snippet ife + if ${1:condition} + ${2:# body...} + else + ${0:# body...} +# Else if +snippet eif + else if ${1:condition} + ${0:# body...} +# Ternary If +snippet ifte + if ${1:condition} then ${2:value} else ${0:other} +# Unless +snippet unl + ${1:action} unless ${0:condition} +# Switch +snippet swi + switch ${1:object} + when ${2:value} + ${0:# body...} + +# Log +snippet log + console.log ${0} +# Try __ Catch +snippet try + try + ${1} + catch ${2:error} + ${0} +# Require +snippet req + ${2:$1} = require '${1:sys}' +# Export +snippet exp + ${0:root} = exports ? this diff --git a/skel/.config/nvim/plugged/vim-snippets/snippets/cpp.snippets b/skel/.config/nvim/plugged/vim-snippets/snippets/cpp.snippets new file mode 100644 index 0000000..cdccf1e --- /dev/null +++ b/skel/.config/nvim/plugged/vim-snippets/snippets/cpp.snippets @@ -0,0 +1,131 @@ +## STL Collections +# std::array +snippet array + std::array<${1:T}, ${2:N}> ${3}; +# std::vector +snippet vector + std::vector<${1:T}> ${2}; +# std::deque +snippet deque + std::deque<${1:T}> ${2}; +# std::forward_list +snippet flist + std::forward_list<${1:T}> ${2}; +# std::list +snippet list + std::list<${1:T}> ${2}; +# std::set +snippet set + std::set<${1:T}> ${2}; +# std::map +snippet map + std::map<${1:Key}, ${2:T}> ${3}; +# std::multiset +snippet mset + std::multiset<${1:T}> ${2}; +# std::multimap +snippet mmap + std::multimap<${1:Key}, ${2:T}> ${3}; +# std::unordered_set +snippet uset + std::unordered_set<${1:T}> ${2}; +# std::unordered_map +snippet umap + std::unordered_map<${1:Key}, ${2:T}> ${3}; +# std::unordered_multiset +snippet umset + std::unordered_multiset<${1:T}> ${2}; +# std::unordered_multimap +snippet ummap + std::unordered_multimap<${1:Key}, ${2:T}> ${3}; +# std::stack +snippet stack + std::stack<${1:T}> ${2}; +# std::queue +snippet queue + std::queue<${1:T}> ${2}; +# std::priority_queue +snippet pqueue + std::priority_queue<${1:T}> ${2}; +## +## Access Modifiers +# private +snippet pri + private +# protected +snippet pro + protected +# public +snippet pub + public +# friend +snippet fr + friend +# mutable +snippet mu + mutable +## +## Class +# class +snippet cl + class ${1:`vim_snippets#Filename('$1', 'name')`} + { + public: + $1(${2}); + ~$1(); + + private: + ${0:/* data */} + }; +# member function implementation +snippet mfun + ${4:void} ${1:`vim_snippets#Filename('$1', 'ClassName')`}::${2:memberFunction}(${3}) { + ${0} + } +# namespace +snippet ns + namespace ${1:`vim_snippets#Filename('', 'my')`} { + ${0} + } /* namespace $1 */ +## +## Input/Output +# std::cout +snippet cout + std::cout << ${1} << std::endl; +# std::cin +snippet cin + std::cin >> ${1}; +## +## Iteration +# for i +snippet fori + for (int ${2:i} = 0; $2 < ${1:count}; $2${3:++}) { + ${4} + } + +# foreach +snippet fore + for (${1:auto} ${2:i} : ${3:container}) { + ${4} + } +# iterator +snippet iter + for (${1:std::vector}<${2:type}>::${3:const_iterator} ${4:i} = ${5:container}.begin(); $4 != $5.end(); ++$4) { + ${6} + } + +# auto iterator +snippet itera + for (auto ${1:i} = ${2:container}.begin(); $1 != $2.end(); ++$1) { + ${3:std::cout << *$1 << std::endl;} + } +## +## Lambdas +# lamda (one line) +snippet ld + [${1}](${2}){${3}} +# lambda (multi-line) +snippet lld + [${1}](${2}){ + ${3} + } diff --git a/skel/.config/nvim/plugged/vim-snippets/snippets/cs.snippets b/skel/.config/nvim/plugged/vim-snippets/snippets/cs.snippets new file mode 100644 index 0000000..e537bce --- /dev/null +++ b/skel/.config/nvim/plugged/vim-snippets/snippets/cs.snippets @@ -0,0 +1,374 @@ +# cs.snippets +# =========== +# +# Standard C-Sharp snippets for snipmate. +# +# Largely ported over from Visual Studio 2010 snippets plus +# a few snippets from Resharper plus a few widely known snippets. +# +# Most snippets on elements (i.e. classes, properties) +# follow suffix conventions. The order of suffixes to a snippet +# is fixed. +# +# Snippet Suffix Order +# -------------------- +# 1. Access Modifiers +# 2. Class Modifiers +# +# Access Modifier Suffix Table +# ---------------------------- +# + = public +# & = internal +# | = protected +# - = private +# +# Example: `cls&` expands to `internal class $1`. +# Access modifiers might be doubled to indicate +# different modifiers for get/set on properties. +# Example: `pb+-` expands to `public bool $1 { get; private set; }` +# +# Class Modifier Table +# -------------------- +# ^ = static +# % = abstract +# +# Example: `cls|%` expands to `protected abstract class $1` +# +# On method and property snippets, you can directly set +# one of the common types int, string and bool, if desired, +# just by appending the type modifier. +# +# Type Modifier Table +# ------------------- +# i = integer +# s = string +# b = bool +# +# Example: `pi+&` expands to `public int $1 { get; internal set; }` +# +# I'll most propably add more stuff in here like +# * List/Array constructio +# * Mostly used generics +# * Linq +# * Funcs, Actions, Predicates +# * Lambda +# * Events +# +# Feedback is welcome! +# +# entry point +snippet sim + public static int Main(string[] args) { + ${0} + return 0; + } +snippet simc + public class Application { + public static int Main(string[] args) { + ${0} + return 0; + } + } +# if condition +snippet if + if (${1}) { + ${0} + } +snippet el + else { + ${0} + } +snippet ifs + if (${1}) + ${0} +# ternary conditional +snippet t + ${1} ? ${2} : ${0} +snippet ? + ${1} ? ${2} : ${0} +# do while loop +snippet do + do { + ${0} + } while (${1}); +# while loop +snippet wh + while (${1}) { + ${0} + } +# for loop +snippet for + for (int ${1:i} = 0; $1 < ${2:count}; $1${3:++}) { + ${0} + } +# foreach +snippet fore + foreach (var ${1:entry} in ${2}) { + ${0} + } +snippet foreach + foreach (var ${1:entry} in ${2}) { + ${0} + } +snippet each + foreach (var ${1:entry} in ${2}) { + ${0} + } +# interfaces +snippet interface + public interface ${1:`vim_snippets#Filename()`} { + ${0} + } +snippet if+ + public interface ${1:`vim_snippets#Filename()`} { + ${0} + } +# class bodies +snippet class + public class ${1:`vim_snippets#Filename()`} { + ${0} + } +snippet cls + ${2:public} class ${1:`vim_snippets#Filename()`} { + ${0} + } +snippet cls+ + public class ${1:`vim_snippets#Filename()`} { + ${0} + } +snippet cls+^ + public static class ${1:`vim_snippets#Filename()`} { + ${0} + } +snippet cls& + internal class ${1:`vim_snippets#Filename()`} { + ${0} + } +snippet cls&^ + internal static class ${1:`vim_snippets#Filename()`} { + ${0} + } +snippet cls| + protected class ${1:`vim_snippets#Filename()`} { + ${0} + } +snippet cls|% + protected abstract class ${1:`vim_snippets#Filename()`} { + ${0} + } +# constructor +snippet ctor + public ${1:`vim_snippets#Filename()`}() { + ${0} + } +# properties - auto properties by default. +# default type is int with layout get / set. +snippet prop + ${1:public} ${2:int} ${3:} { get; set; } +snippet p + ${1:public} ${2:int} ${3:} { get; set; } +snippet p+ + public ${1:int} ${2:} { get; set; } +snippet p+& + public ${1:int} ${2:} { get; internal set; } +snippet p+| + public ${1:int} ${2:} { get; protected set; } +snippet p+- + public ${1:int} ${2:} { get; private set; } +snippet p& + internal ${1:int} ${2:} { get; set; } +snippet p&| + internal ${1:int} ${2:} { get; protected set; } +snippet p&- + internal ${1:int} ${2:} { get; private set; } +snippet p| + protected ${1:int} ${2:} { get; set; } +snippet p|- + protected ${1:int} ${2:} { get; private set; } +snippet p- + private ${1:int} ${2:} { get; set; } +# property - bool +snippet pi + ${1:public} int ${2:} { get; set; } +snippet pi+ + public int ${1} { get; set; } +snippet pi+& + public int ${1} { get; internal set; } +snippet pi+| + public int ${1} { get; protected set; } +snippet pi+- + public int ${1} { get; private set; } +snippet pi& + internal int ${1} { get; set; } +snippet pi&| + internal int ${1} { get; protected set; } +snippet pi&- + internal int ${1} { get; private set; } +snippet pi| + protected int ${1} { get; set; } +snippet pi|- + protected int ${1} { get; private set; } +snippet pi- + private int ${1} { get; set; } +# property - bool +snippet pb + ${1:public} bool ${2:} { get; set; } +snippet pb+ + public bool ${1} { get; set; } +snippet pb+& + public bool ${1} { get; internal set; } +snippet pb+| + public bool ${1} { get; protected set; } +snippet pb+- + public bool ${1} { get; private set; } +snippet pb& + internal bool ${1} { get; set; } +snippet pb&| + internal bool ${1} { get; protected set; } +snippet pb&- + internal bool ${1} { get; private set; } +snippet pb| + protected bool ${1} { get; set; } +snippet pb|- + protected bool ${1} { get; private set; } +snippet pb- + private bool ${1} { get; set; } +# property - string +snippet ps + ${1:public} string ${2:} { get; set; } +snippet ps+ + public string ${1} { get; set; } +snippet ps+& + public string ${1} { get; internal set; } +snippet ps+| + public string ${1} { get; protected set; } +snippet ps+- + public string ${1} { get; private set; } +snippet ps& + internal string ${1} { get; set; } +snippet ps&| + internal string ${1} { get; protected set; } +snippet ps&- + internal string ${1} { get; private set; } +snippet ps| + protected string ${1} { get; set; } +snippet ps|- + protected string ${1} { get; private set; } +snippet ps- + private string ${1} { get; set; } +# members - void +snippet m + ${1:public} ${2:void} ${3:}(${4:}) { + ${5:} + } +snippet m+ + public ${1:void} ${2:}(${3:}) { + ${4:} + } +snippet m& + internal ${1:void} ${2:}(${3:}) { + ${4:} + } +snippet m| + protected ${1:void} ${2:}(${3:}) { + ${4:} + } +snippet m- + private ${1:void} ${2:}(${3:}) { + ${4:} + } +# members - int +snippet mi + ${1:public} int ${2:}(${3:}) { + ${4:return 0;} + } +snippet mi+ + public int ${1:}(${2:}) { + ${3:return 0;} + } +snippet mi& + internal int ${1:}(${2:}) { + ${3:return 0;} + } +snippet mi| + protected int ${1:}(${2:}) { + ${3:return 0;} + } +snippet mi- + private int ${1:}(${2:}) { + ${3:return 0;} + } +# members - bool +snippet mb + ${1:public} bool ${2:}(${3:}) { + ${4:return false;} + } +snippet mb+ + public bool ${1:}(${2:}) { + ${3:return false;} + } +snippet mb& + internal bool ${1:}(${2:}) { + ${3:return false;} + } +snippet mb| + protected bool ${1:}(${2:}) { + ${3:return false;} + } +snippet mb- + private bool ${1:}(${2:}) { + ${3:return false;} + } +# members - string +snippet ms + ${1:public} string ${2:}(${3:}) { + ${4:return "";} + } +snippet ms+ + public string ${1:}(${2:}) { + ${3:return "";} + } +snippet ms& + internal string ${1:}(${2:}) { + ${3:return "";} + } +snippet ms| + protected string ${1:}(${2:}) { + ${3:return "";} + } +snippet ms- + private string ${1:}(${2:}) { + ${3:return "";} + } +# structure +snippet struct + public struct ${1:`vim_snippets#Filename()`} { + ${0} + } +# enumeration +snippet enum + public enum ${1} { + ${0} + } +# preprocessor directives +snippet #if + #if + ${0} + #endif +# inline xml documentation +snippet /// + /// + /// ${0} + /// +snippet

    ${2:$1} +snippet ${2} +snippet ${1}{ +snippet +snippet ${1} +snippet ${1} diff --git a/skel/.config/nvim/plugged/vim-snippets/snippets/css.snippets b/skel/.config/nvim/plugged/vim-snippets/snippets/css.snippets new file mode 100644 index 0000000..8886643 --- /dev/null +++ b/skel/.config/nvim/plugged/vim-snippets/snippets/css.snippets @@ -0,0 +1,967 @@ +snippet . + ${1} { + ${0} + } +snippet ! + !important +snippet bdi:m+ + -moz-border-image: url(${1}) ${2:0} ${3:0} ${4:0} ${5:0} ${6:stretch} ${0:stretch}; +snippet bdi:m + -moz-border-image: ${0}; +snippet bdrz:m + -moz-border-radius: ${0}; +snippet bxsh:m+ + -moz-box-shadow: ${1:0} ${2:0} ${3:0} #${0:000}; +snippet bxsh:m + -moz-box-shadow: ${0}; +snippet bdi:w+ + -webkit-border-image: url(${1}) ${2:0} ${3:0} ${4:0} ${5:0} ${6:stretch} ${0:stretch}; +snippet bdi:w + -webkit-border-image: ${0}; +snippet bdrz:w + -webkit-border-radius: ${0}; +snippet bxsh:w+ + -webkit-box-shadow: ${1:0} ${2:0} ${3:0} #${0:000}; +snippet bxsh:w + -webkit-box-shadow: ${0}; +snippet @f + @font-face { + font-family: ${1}; + src: url(${0}); + } +snippet @i + @import url(${0}); +snippet @m + @media ${1:print} { + ${0} + } +snippet bg+ + background: #${1:FFF} url(${2}) ${3:0} ${4:0} ${0:no-repeat}; +snippet bga + background-attachment: ${0}; +snippet bga:f + background-attachment: fixed; +snippet bga:s + background-attachment: scroll; +snippet bgbk + background-break: ${0}; +snippet bgbk:bb + background-break: bounding-box; +snippet bgbk:c + background-break: continuous; +snippet bgbk:eb + background-break: each-box; +snippet bgcp + background-clip: ${0}; +snippet bgcp:bb + background-clip: border-box; +snippet bgcp:cb + background-clip: content-box; +snippet bgcp:nc + background-clip: no-clip; +snippet bgcp:pb + background-clip: padding-box; +snippet bgc + background-color: #${0:FFF}; +snippet bgc:t + background-color: transparent; +snippet bgi + background-image: url(${0}); +snippet bgi:n + background-image: none; +snippet bgo + background-origin: ${0}; +snippet bgo:bb + background-origin: border-box; +snippet bgo:cb + background-origin: content-box; +snippet bgo:pb + background-origin: padding-box; +snippet bgpx + background-position-x: ${0}; +snippet bgpy + background-position-y: ${0}; +snippet bgp + background-position: ${1:0} ${0:0}; +snippet bgr + background-repeat: ${0}; +snippet bgr:n + background-repeat: no-repeat; +snippet bgr:x + background-repeat: repeat-x; +snippet bgr:y + background-repeat: repeat-y; +snippet bgr:r + background-repeat: repeat; +snippet bgz + background-size: ${0}; +snippet bgz:a + background-size: auto; +snippet bgz:ct + background-size: contain; +snippet bgz:cv + background-size: cover; +snippet bg + background: ${0}; +snippet bg:ie + filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='${1}',sizingMethod='${0:crop}'); +snippet bg:n + background: none; +snippet bd+ + border: ${1:1px} ${2:solid} #${0:000}; +snippet bdb+ + border-bottom: ${1:1px} ${2:solid} #${0:000}; +snippet bdbc + border-bottom-color: #${0:000}; +snippet bdbi + border-bottom-image: url(${0}); +snippet bdbi:n + border-bottom-image: none; +snippet bdbli + border-bottom-left-image: url(${0}); +snippet bdbli:c + border-bottom-left-image: continue; +snippet bdbli:n + border-bottom-left-image: none; +snippet bdblrz + border-bottom-left-radius: ${0}; +snippet bdbri + border-bottom-right-image: url(${0}); +snippet bdbri:c + border-bottom-right-image: continue; +snippet bdbri:n + border-bottom-right-image: none; +snippet bdbrrz + border-bottom-right-radius: ${0}; +snippet bdbs + border-bottom-style: ${0}; +snippet bdbs:n + border-bottom-style: none; +snippet bdbw + border-bottom-width: ${0}; +snippet bdb + border-bottom: ${0}; +snippet bdb:n + border-bottom: none; +snippet bdbk + border-break: ${0}; +snippet bdbk:c + border-break: close; +snippet bdcl + border-collapse: ${0}; +snippet bdcl:c + border-collapse: collapse; +snippet bdcl:s + border-collapse: separate; +snippet bdc + border-color: #${0:000}; +snippet bdci + border-corner-image: url(${0}); +snippet bdci:c + border-corner-image: continue; +snippet bdci:n + border-corner-image: none; +snippet bdf + border-fit: ${0}; +snippet bdf:c + border-fit: clip; +snippet bdf:of + border-fit: overwrite; +snippet bdf:ow + border-fit: overwrite; +snippet bdf:r + border-fit: repeat; +snippet bdf:sc + border-fit: scale; +snippet bdf:sp + border-fit: space; +snippet bdf:st + border-fit: stretch; +snippet bdi + border-image: url(${1}) ${2:0} ${3:0} ${4:0} ${5:0} ${6:stretch} ${0:stretch}; +snippet bdi:n + border-image: none; +snippet bdl+ + border-left: ${1:1px} ${2:solid} #${0:000}; +snippet bdlc + border-left-color: #${0:000}; +snippet bdli + border-left-image: url(${0}); +snippet bdli:n + border-left-image: none; +snippet bdls + border-left-style: ${0}; +snippet bdls:n + border-left-style: none; +snippet bdlw + border-left-width: ${0}; +snippet bdl + border-left: ${0}; +snippet bdl:n + border-left: none; +snippet bdlt + border-length: ${0}; +snippet bdlt:a + border-length: auto; +snippet bdrz + border-radius: ${0}; +snippet bdr+ + border-right: ${1:1px} ${2:solid} #${0:000}; +snippet bdrc + border-right-color: #${0:000}; +snippet bdri + border-right-image: url(${0}); +snippet bdri:n + border-right-image: none; +snippet bdrs + border-right-style: ${0}; +snippet bdrs:n + border-right-style: none; +snippet bdrw + border-right-width: ${0}; +snippet bdr + border-right: ${0}; +snippet bdr:n + border-right: none; +snippet bdsp + border-spacing: ${0}; +snippet bds + border-style: ${0}; +snippet bds:ds + border-style: dashed; +snippet bds:dtds + border-style: dot-dash; +snippet bds:dtdtds + border-style: dot-dot-dash; +snippet bds:dt + border-style: dotted; +snippet bds:db + border-style: double; +snippet bds:g + border-style: groove; +snippet bds:h + border-style: hidden; +snippet bds:i + border-style: inset; +snippet bds:n + border-style: none; +snippet bds:o + border-style: outset; +snippet bds:r + border-style: ridge; +snippet bds:s + border-style: solid; +snippet bds:w + border-style: wave; +snippet bdt+ + border-top: ${1:1px} ${2:solid} #${0:000}; +snippet bdtc + border-top-color: #${0:000}; +snippet bdti + border-top-image: url(${0}); +snippet bdti:n + border-top-image: none; +snippet bdtli + border-top-left-image: url(${0}); +snippet bdtli:c + border-corner-image: continue; +snippet bdtli:n + border-corner-image: none; +snippet bdtlrz + border-top-left-radius: ${0}; +snippet bdtri + border-top-right-image: url(${0}); +snippet bdtri:c + border-top-right-image: continue; +snippet bdtri:n + border-top-right-image: none; +snippet bdtrrz + border-top-right-radius: ${0}; +snippet bdts + border-top-style: ${0}; +snippet bdts:n + border-top-style: none; +snippet bdtw + border-top-width: ${0}; +snippet bdt + border-top: ${0}; +snippet bdt:n + border-top: none; +snippet bdw + border-width: ${0}; +snippet bd + border: ${0}; +snippet bd:n + border: none; +snippet b + bottom: ${0}; +snippet b:a + bottom: auto; +snippet bxsh+ + box-shadow: ${1:0} ${2:0} ${3:0} #${0:000}; +snippet bxsh + box-shadow: ${0}; +snippet bxsh:n + box-shadow: none; +snippet bxz + box-sizing: ${0}; +snippet bxz:bb + box-sizing: border-box; +snippet bxz:cb + box-sizing: content-box; +snippet cps + caption-side: ${0}; +snippet cps:b + caption-side: bottom; +snippet cps:t + caption-side: top; +snippet cl + clear: ${0}; +snippet cl:b + clear: both; +snippet cl:l + clear: left; +snippet cl:n + clear: none; +snippet cl:r + clear: right; +snippet cp + clip: ${0}; +snippet cp:a + clip: auto; +snippet cp:r + clip: rect(${1:0} ${2:0} ${3:0} ${0:0}); +snippet c + color: #${0:000}; +snippet ct + content: ${0}; +snippet ct:a + content: attr(${0}); +snippet ct:cq + content: close-quote; +snippet ct:c + content: counter(${0}); +snippet ct:cs + content: counters(${0}); +snippet ct:ncq + content: no-close-quote; +snippet ct:noq + content: no-open-quote; +snippet ct:n + content: normal; +snippet ct:oq + content: open-quote; +snippet coi + counter-increment: ${0}; +snippet cor + counter-reset: ${0}; +snippet cur + cursor: ${0}; +snippet cur:a + cursor: auto; +snippet cur:c + cursor: crosshair; +snippet cur:d + cursor: default; +snippet cur:ha + cursor: hand; +snippet cur:he + cursor: help; +snippet cur:m + cursor: move; +snippet cur:p + cursor: pointer; +snippet cur:t + cursor: text; +snippet d + display: ${0}; +snippet d:mib + display: -moz-inline-box; +snippet d:mis + display: -moz-inline-stack; +snippet d:b + display: block; +snippet d:cp + display: compact; +snippet d:ib + display: inline-block; +snippet d:itb + display: inline-table; +snippet d:i + display: inline; +snippet d:li + display: list-item; +snippet d:n + display: none; +snippet d:ri + display: run-in; +snippet d:tbcp + display: table-caption; +snippet d:tbc + display: table-cell; +snippet d:tbclg + display: table-column-group; +snippet d:tbcl + display: table-column; +snippet d:tbfg + display: table-footer-group; +snippet d:tbhg + display: table-header-group; +snippet d:tbrg + display: table-row-group; +snippet d:tbr + display: table-row; +snippet d:tb + display: table; +snippet ec + empty-cells: ${0}; +snippet ec:h + empty-cells: hide; +snippet ec:s + empty-cells: show; +snippet exp + expression() +snippet fl + float: ${0}; +snippet fl:l + float: left; +snippet fl:n + float: none; +snippet fl:r + float: right; +snippet f+ + font: ${1:1em} ${2:Arial},${0:sans-serif}; +snippet fef + font-effect: ${0}; +snippet fef:eb + font-effect: emboss; +snippet fef:eg + font-effect: engrave; +snippet fef:n + font-effect: none; +snippet fef:o + font-effect: outline; +snippet femp + font-emphasize-position: ${0}; +snippet femp:a + font-emphasize-position: after; +snippet femp:b + font-emphasize-position: before; +snippet fems + font-emphasize-style: ${0}; +snippet fems:ac + font-emphasize-style: accent; +snippet fems:c + font-emphasize-style: circle; +snippet fems:ds + font-emphasize-style: disc; +snippet fems:dt + font-emphasize-style: dot; +snippet fems:n + font-emphasize-style: none; +snippet fem + font-emphasize: ${0}; +snippet ff + font-family: ${0}; +snippet ff:c + font-family: ${0:'Monotype Corsiva','Comic Sans MS'},cursive; +snippet ff:f + font-family: ${0:Capitals,Impact},fantasy; +snippet ff:m + font-family: ${0:Monaco,'Courier New'},monospace; +snippet ff:ss + font-family: ${0:Helvetica,Arial},sans-serif; +snippet ff:s + font-family: ${0:Georgia,'Times New Roman'},serif; +snippet fza + font-size-adjust: ${0}; +snippet fza:n + font-size-adjust: none; +snippet fz + font-size: ${0}; +snippet fsm + font-smooth: ${0}; +snippet fsm:aw + font-smooth: always; +snippet fsm:a + font-smooth: auto; +snippet fsm:n + font-smooth: never; +snippet fst + font-stretch: ${0}; +snippet fst:c + font-stretch: condensed; +snippet fst:e + font-stretch: expanded; +snippet fst:ec + font-stretch: extra-condensed; +snippet fst:ee + font-stretch: extra-expanded; +snippet fst:n + font-stretch: normal; +snippet fst:sc + font-stretch: semi-condensed; +snippet fst:se + font-stretch: semi-expanded; +snippet fst:uc + font-stretch: ultra-condensed; +snippet fst:ue + font-stretch: ultra-expanded; +snippet fs + font-style: ${0}; +snippet fs:i + font-style: italic; +snippet fs:n + font-style: normal; +snippet fs:o + font-style: oblique; +snippet fv + font-variant: ${0}; +snippet fv:n + font-variant: normal; +snippet fv:sc + font-variant: small-caps; +snippet fw + font-weight: ${0}; +snippet fw:b + font-weight: bold; +snippet fw:br + font-weight: bolder; +snippet fw:lr + font-weight: lighter; +snippet fw:n + font-weight: normal; +snippet f + font: ${0}; +snippet h + height: ${0}; +snippet h:a + height: auto; +snippet l + left: ${0}; +snippet l:a + left: auto; +snippet lts + letter-spacing: ${0}; +snippet lh + line-height: ${0}; +snippet lisi + list-style-image: url(${0}); +snippet lisi:n + list-style-image: none; +snippet lisp + list-style-position: ${0}; +snippet lisp:i + list-style-position: inside; +snippet lisp:o + list-style-position: outside; +snippet list + list-style-type: ${0}; +snippet list:c + list-style-type: circle; +snippet list:dclz + list-style-type: decimal-leading-zero; +snippet list:dc + list-style-type: decimal; +snippet list:d + list-style-type: disc; +snippet list:lr + list-style-type: lower-roman; +snippet list:n + list-style-type: none; +snippet list:s + list-style-type: square; +snippet list:ur + list-style-type: upper-roman; +snippet lis + list-style: ${0}; +snippet lis:n + list-style: none; +snippet mb + margin-bottom: ${0}; +snippet mb:a + margin-bottom: auto; +snippet ml + margin-left: ${0}; +snippet ml:a + margin-left: auto; +snippet mr + margin-right: ${0}; +snippet mr:a + margin-right: auto; +snippet mt + margin-top: ${0}; +snippet mt:a + margin-top: auto; +snippet m + margin: ${0}; +snippet m:4 + margin: ${1:0} ${2:0} ${3:0} ${0:0}; +snippet m:3 + margin: ${1:0} ${2:0} ${0:0}; +snippet m:2 + margin: ${1:0} ${0:0}; +snippet m:0 + margin: 0; +snippet m:a + margin: auto; +snippet mah + max-height: ${0}; +snippet mah:n + max-height: none; +snippet maw + max-width: ${0}; +snippet maw:n + max-width: none; +snippet mih + min-height: ${0}; +snippet miw + min-width: ${0}; +snippet op + opacity: ${0}; +snippet op:ie + filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=${0:100}); +snippet op:ms + -ms-filter: 'progid:DXImageTransform.Microsoft.Alpha(Opacity=${0:100})'; +snippet orp + orphans: ${0}; +snippet o+ + outline: ${1:1px} ${2:solid} #${0:000}; +snippet oc + outline-color: ${0:#000}; +snippet oc:i + outline-color: invert; +snippet oo + outline-offset: ${0}; +snippet os + outline-style: ${0}; +snippet ow + outline-width: ${0}; +snippet o + outline: ${0}; +snippet o:n + outline: none; +snippet ovs + overflow-style: ${0}; +snippet ovs:a + overflow-style: auto; +snippet ovs:mq + overflow-style: marquee; +snippet ovs:mv + overflow-style: move; +snippet ovs:p + overflow-style: panner; +snippet ovs:s + overflow-style: scrollbar; +snippet ovx + overflow-x: ${0}; +snippet ovx:a + overflow-x: auto; +snippet ovx:h + overflow-x: hidden; +snippet ovx:s + overflow-x: scroll; +snippet ovx:v + overflow-x: visible; +snippet ovy + overflow-y: ${0}; +snippet ovy:a + overflow-y: auto; +snippet ovy:h + overflow-y: hidden; +snippet ovy:s + overflow-y: scroll; +snippet ovy:v + overflow-y: visible; +snippet ov + overflow: ${0}; +snippet ov:a + overflow: auto; +snippet ov:h + overflow: hidden; +snippet ov:s + overflow: scroll; +snippet ov:v + overflow: visible; +snippet pb + padding-bottom: ${0}; +snippet pl + padding-left: ${0}; +snippet pr + padding-right: ${0}; +snippet pt + padding-top: ${0}; +snippet p + padding: ${0}; +snippet p:4 + padding: ${1:0} ${2:0} ${3:0} ${0:0}; +snippet p:3 + padding: ${1:0} ${2:0} ${0:0}; +snippet p:2 + padding: ${1:0} ${0:0}; +snippet p:0 + padding: 0; +snippet pgba + page-break-after: ${0}; +snippet pgba:aw + page-break-after: always; +snippet pgba:a + page-break-after: auto; +snippet pgba:l + page-break-after: left; +snippet pgba:r + page-break-after: right; +snippet pgbb + page-break-before: ${0}; +snippet pgbb:aw + page-break-before: always; +snippet pgbb:a + page-break-before: auto; +snippet pgbb:l + page-break-before: left; +snippet pgbb:r + page-break-before: right; +snippet pgbi + page-break-inside: ${0}; +snippet pgbi:a + page-break-inside: auto; +snippet pgbi:av + page-break-inside: avoid; +snippet pos + position: ${0}; +snippet pos:a + position: absolute; +snippet pos:f + position: fixed; +snippet pos:r + position: relative; +snippet pos:s + position: static; +snippet q + quotes: ${0}; +snippet q:en + quotes: '\201C' '\201D' '\2018' '\2019'; +snippet q:n + quotes: none; +snippet q:ru + quotes: '\00AB' '\00BB' '\201E' '\201C'; +snippet rz + resize: ${0}; +snippet rz:b + resize: both; +snippet rz:h + resize: horizontal; +snippet rz:n + resize: none; +snippet rz:v + resize: vertical; +snippet r + right: ${0}; +snippet r:a + right: auto; +snippet tbl + table-layout: ${0}; +snippet tbl:a + table-layout: auto; +snippet tbl:f + table-layout: fixed; +snippet tal + text-align-last: ${0}; +snippet tal:a + text-align-last: auto; +snippet tal:c + text-align-last: center; +snippet tal:l + text-align-last: left; +snippet tal:r + text-align-last: right; +snippet ta + text-align: ${0}; +snippet ta:c + text-align: center; +snippet ta:l + text-align: left; +snippet ta:r + text-align: right; +snippet td + text-decoration: ${0}; +snippet td:l + text-decoration: line-through; +snippet td:n + text-decoration: none; +snippet td:o + text-decoration: overline; +snippet td:u + text-decoration: underline; +snippet te + text-emphasis: ${0}; +snippet te:ac + text-emphasis: accent; +snippet te:a + text-emphasis: after; +snippet te:b + text-emphasis: before; +snippet te:c + text-emphasis: circle; +snippet te:ds + text-emphasis: disc; +snippet te:dt + text-emphasis: dot; +snippet te:n + text-emphasis: none; +snippet th + text-height: ${0}; +snippet th:a + text-height: auto; +snippet th:f + text-height: font-size; +snippet th:m + text-height: max-size; +snippet th:t + text-height: text-size; +snippet ti + text-indent: ${0}; +snippet ti:- + text-indent: -9999px; +snippet tj + text-justify: ${0}; +snippet tj:a + text-justify: auto; +snippet tj:d + text-justify: distribute; +snippet tj:ic + text-justify: inter-cluster; +snippet tj:ii + text-justify: inter-ideograph; +snippet tj:iw + text-justify: inter-word; +snippet tj:k + text-justify: kashida; +snippet tj:t + text-justify: tibetan; +snippet to+ + text-outline: ${1:0} ${2:0} #${0:000}; +snippet to + text-outline: ${0}; +snippet to:n + text-outline: none; +snippet tr + text-replace: ${0}; +snippet tr:n + text-replace: none; +snippet tsh+ + text-shadow: ${1:0} ${2:0} ${3:0} #${0:000}; +snippet tsh + text-shadow: ${0}; +snippet tsh:n + text-shadow: none; +snippet tt + text-transform: ${0}; +snippet tt:c + text-transform: capitalize; +snippet tt:l + text-transform: lowercase; +snippet tt:n + text-transform: none; +snippet tt:u + text-transform: uppercase; +snippet tw + text-wrap: ${0}; +snippet tw:no + text-wrap: none; +snippet tw:n + text-wrap: normal; +snippet tw:s + text-wrap: suppress; +snippet tw:u + text-wrap: unrestricted; +snippet t + top: ${0}; +snippet t:a + top: auto; +snippet va + vertical-align: ${0}; +snippet va:bl + vertical-align: baseline; +snippet va:b + vertical-align: bottom; +snippet va:m + vertical-align: middle; +snippet va:sub + vertical-align: sub; +snippet va:sup + vertical-align: super; +snippet va:tb + vertical-align: text-bottom; +snippet va:tt + vertical-align: text-top; +snippet va:t + vertical-align: top; +snippet v + visibility: ${0}; +snippet v:c + visibility: collapse; +snippet v:h + visibility: hidden; +snippet v:v + visibility: visible; +snippet whsc + white-space-collapse: ${0}; +snippet whsc:ba + white-space-collapse: break-all; +snippet whsc:bs + white-space-collapse: break-strict; +snippet whsc:k + white-space-collapse: keep-all; +snippet whsc:l + white-space-collapse: loose; +snippet whsc:n + white-space-collapse: normal; +snippet whs + white-space: ${0}; +snippet whs:n + white-space: normal; +snippet whs:nw + white-space: nowrap; +snippet whs:pl + white-space: pre-line; +snippet whs:pw + white-space: pre-wrap; +snippet whs:p + white-space: pre; +snippet wid + widows: ${0}; +snippet w + width: ${0}; +snippet w:a + width: auto; +snippet wob + word-break: ${0}; +snippet wob:ba + word-break: break-all; +snippet wob:bs + word-break: break-strict; +snippet wob:k + word-break: keep-all; +snippet wob:l + word-break: loose; +snippet wob:n + word-break: normal; +snippet wos + word-spacing: ${0}; +snippet wow + word-wrap: ${0}; +snippet wow:no + word-wrap: none; +snippet wow:n + word-wrap: normal; +snippet wow:s + word-wrap: suppress; +snippet wow:u + word-wrap: unrestricted; +snippet z + z-index: ${0}; +snippet z:a + z-index: auto; +snippet zoo + zoom: 1; diff --git a/skel/.config/nvim/plugged/vim-snippets/snippets/dart.snippets b/skel/.config/nvim/plugged/vim-snippets/snippets/dart.snippets new file mode 100644 index 0000000..0093f2b --- /dev/null +++ b/skel/.config/nvim/plugged/vim-snippets/snippets/dart.snippets @@ -0,0 +1,82 @@ +snippet lib + #library('${1}'); + ${0} +snippet im + #import('${1}'); + ${0} +snippet so + #source('${1}'); + ${0} +snippet main + static void main() { + ${0} + } +snippet st + static ${0} +snippet fi + final ${0} +snippet re + return ${0} +snippet br + break; +snippet th + throw ${0} +snippet cl + class ${1:`vim_snippets#Filename("", "untitled")`} ${0} +snippet in + interface ${1:`vim_snippets#Filename("", "untitled")`} ${0} +snippet imp + implements ${0} +snippet ext + extends ${0} +snippet if + if (${1:true}) { + ${0} + } +snippet ife + if (${1:true}) { + ${2} + } else { + ${0} + } +snippet el + else +snippet sw + switch (${1}) { + ${0} + } +snippet cs + case ${1}: + ${0} +snippet de + default: + ${0} +snippet for + for (var ${2:i} = 0, len = ${1:things}.length; $2 < len; ${3:++}$2) { + ${0:$1[$2]} + } +snippet fore + for (final ${2:item} in ${1:itemList}) { + ${0} + } +snippet wh + while (${1:/* condition */}) { + ${0} + } +snippet dowh + do { + ${0} + } while (${0:/* condition */}); +snippet as + assert(${0:/* condition */}); +snippet try + try { + ${0} + } catch (${1:Exception e}) { + } +snippet tryf + try { + ${0} + } catch (${1:Exception e}) { + } finally { + } diff --git a/skel/.config/nvim/plugged/vim-snippets/snippets/diff.snippets b/skel/.config/nvim/plugged/vim-snippets/snippets/diff.snippets new file mode 100644 index 0000000..89bc31d --- /dev/null +++ b/skel/.config/nvim/plugged/vim-snippets/snippets/diff.snippets @@ -0,0 +1,11 @@ +# DEP-3 (http://dep.debian.net/deps/dep3/) style patch header +snippet header DEP-3 style header + Description: ${1} + Origin: ${2:vendor|upstream|other}, ${3:url of the original patch} + Bug: ${4:url in upstream bugtracker} + Forwarded: ${5:no|not-needed|url} + Author: ${6:`g:snips_author`} + Reviewed-by: ${7:name and email} + Last-Update: ${8:`strftime("%Y-%m-%d")`} + Applied-Upstream: ${0:upstream version|url|commit} + diff --git a/skel/.config/nvim/plugged/vim-snippets/snippets/django.snippets b/skel/.config/nvim/plugged/vim-snippets/snippets/django.snippets new file mode 100644 index 0000000..cad80eb --- /dev/null +++ b/skel/.config/nvim/plugged/vim-snippets/snippets/django.snippets @@ -0,0 +1,108 @@ +# Model Fields + +# Note: Optional arguments are using defaults that match what Django will use +# as a default, e.g. with max_length fields. Doing this as a form of self +# documentation and to make it easy to know whether you should override the +# default or not. + +# Note: Optional arguments that are booleans will use the opposite since you +# can either not specify them, or override them, e.g. auto_now_add=False. + +snippet auto + ${1:FIELDNAME} = models.AutoField(${0}) +snippet bool + ${1:FIELDNAME} = models.BooleanField(${0:default=True}) +snippet char + ${1:FIELDNAME} = models.CharField(max_length=${2}${0:, blank=True}) +snippet comma + ${1:FIELDNAME} = models.CommaSeparatedIntegerField(max_length=${2}${0:, blank=True}) +snippet date + ${1:FIELDNAME} = models.DateField(${2:auto_now_add=True, auto_now=True}${0:, blank=True, null=True}) +snippet datetime + ${1:FIELDNAME} = models.DateTimeField(${2:auto_now_add=True, auto_now=True}${0:, blank=True, null=True}) +snippet decimal + ${1:FIELDNAME} = models.DecimalField(max_digits=${2}, decimal_places=${0}) +snippet email + ${1:FIELDNAME} = models.EmailField(max_length=${2:75}${0:, blank=True}) +snippet file + ${1:FIELDNAME} = models.FileField(upload_to=${2:path/for/upload}${0:, max_length=100}) +snippet filepath + ${1:FIELDNAME} = models.FilePathField(path=${2:"/abs/path/to/dir"}${3:, max_length=100}${4:, match="*.ext"}${5:, recursive=True}${0:, blank=True, }) +snippet float + ${1:FIELDNAME} = models.FloatField(${0}) +snippet image + ${1:FIELDNAME} = models.ImageField(upload_to=${2:path/for/upload}${3:, height_field=height, width_field=width}${0:, max_length=100}) +snippet int + ${1:FIELDNAME} = models.IntegerField(${0}) +snippet ip + ${1:FIELDNAME} = models.IPAddressField(${0}) +snippet nullbool + ${1:FIELDNAME} = models.NullBooleanField(${0}) +snippet posint + ${1:FIELDNAME} = models.PositiveIntegerField(${0}) +snippet possmallint + ${1:FIELDNAME} = models.PositiveSmallIntegerField(${0}) +snippet slug + ${1:FIELDNAME} = models.SlugField(max_length=${2:50}${0:, blank=True}) +snippet smallint + ${1:FIELDNAME} = models.SmallIntegerField(${0}) +snippet text + ${1:FIELDNAME} = models.TextField(${0:blank=True}) +snippet time + ${1:FIELDNAME} = models.TimeField(${2:auto_now_add=True, auto_now=True}${0:, blank=True, null=True}) +snippet url + ${1:FIELDNAME} = models.URLField(${2:verify_exists=False}${3:, max_length=200}${0:, blank=True}) +snippet xml + ${1:FIELDNAME} = models.XMLField(schema_path=${2:None}${0:, blank=True}) +# Relational Fields +snippet fk + ${1:FIELDNAME} = models.ForeignKey(${2:OtherModel}${3:, related_name=''}${4:, limit_choices_to=}${0:, to_field=''}) +snippet m2m + ${1:FIELDNAME} = models.ManyToManyField(${2:OtherModel}${3:, related_name=''}${4:, limit_choices_to=}${5:, symmetrical=False}${6:, through=''}${0:, db_table=''}) +snippet o2o + ${1:FIELDNAME} = models.OneToOneField(${2:OtherModel}${3:, parent_link=True}${4:, related_name=''}${5:, limit_choices_to=}${0:, to_field=''}) + +# Code Skeletons + +snippet form + class ${1:FormName}(forms.Form): + """${2:docstring}""" + ${0} + +snippet model + class ${1:ModelName}(models.Model): + """${2:docstring}""" + ${3} + + class Meta: + ${4} + + def __unicode__(self): + ${5} + + def save(self, force_insert=False, force_update=False): + ${6} + + @models.permalink + def get_absolute_url(self): + return ('${7:view_or_url_name}' ${0}) + +snippet modeladmin + class ${1:ModelName}Admin(admin.ModelAdmin): + ${0} + + admin.site.register($1, $1Admin) + +snippet tabularinline + class ${0:ModelName}Inline(admin.TabularInline): + model = $1 + +snippet stackedinline + class ${0:ModelName}Inline(admin.StackedInline): + model = $1 + +snippet r2r + return render_to_response('${1:template.html}', { + ${2} + }${0:, context_instance=RequestContext(request)} + ) diff --git a/skel/.config/nvim/plugged/vim-snippets/snippets/dosini.snippets b/skel/.config/nvim/plugged/vim-snippets/snippets/dosini.snippets new file mode 100644 index 0000000..95c759c --- /dev/null +++ b/skel/.config/nvim/plugged/vim-snippets/snippets/dosini.snippets @@ -0,0 +1,12 @@ +snippet ec + ; http://editorconfig.org + + root = true + + [*] + indent_style = ${1:space_or_tab} + indent_size = ${2:indent_size} + end_of_line = lf + charset = utf-8 + trim_trailing_whitespace = true + insert_final_newline = true diff --git a/skel/.config/nvim/plugged/vim-snippets/snippets/ect.snippets b/skel/.config/nvim/plugged/vim-snippets/snippets/ect.snippets new file mode 100644 index 0000000..0798f64 --- /dev/null +++ b/skel/.config/nvim/plugged/vim-snippets/snippets/ect.snippets @@ -0,0 +1,37 @@ +snippet % + <% ${1} %> +snippet = + <%= @${1:escaped} %> +snippet - + <%- @${1:unescaped} %> +snippet content + <%content '${1}'%>${2} +snippet block + <% block '${1}' : %> + ${2} + <% end %>${3} +snippet extend + <% extend '${1:layout}' %> +snippet if + <% if @${1}?${2:.length} : %> + ${3} + <% else : %> + ${4} + <% end %> +snippet switch + <% switch @${1} : %> + <% when '${2}' : %> + ${3} + <% end %> + <% else : %> + ${4} + <% end %> + <% end %>${5} +snippet when + <% when '${1}' : %> + ${2} + <% end %>${3} +snippet for + <% for ${1:item} in @${2:$1s} : %> + ${3} + <% end %> diff --git a/skel/.config/nvim/plugged/vim-snippets/snippets/elixir.snippets b/skel/.config/nvim/plugged/vim-snippets/snippets/elixir.snippets new file mode 100644 index 0000000..54aa180 --- /dev/null +++ b/skel/.config/nvim/plugged/vim-snippets/snippets/elixir.snippets @@ -0,0 +1,127 @@ +snippet do + do + ${0} + end +snippet if if .. do .. end + if ${1} do + ${0} + end + +snippet if if .. do: .. + if ${1:condition}, do: ${0} + +snippet ife if .. do .. else .. end + if ${1:condition} do + ${2} + else + ${0} + end + +snippet ife if .. do: .. else: + if ${1:condition}, do: ${2}, else: ${0} + +snippet unless unless .. do .. end + unless ${1} do + ${0} + end + +snippet unless unless .. do: .. + unless ${1:condition}, do: ${0} + +snippet unlesse unless .. do .. else .. end + unless ${1:condition} do + ${2} + else + ${0} + end + +snippet unlesse unless .. do: .. else: + unless ${1:condition}, do: ${2}, else: ${0} + +snippet cond + cond do + ${1} -> + ${0} + end + +snippet case + case ${1} do + ${2} -> + ${0} + end + +snippet def + def ${1:name} do + ${0} + end + +snippet defim + defimpl ${1:protocol_name}, for: ${2:data_type} do + ${0} + end + +snippet defma + defmacro ${1:name} do + ${0} + end + +snippet defmo + defmodule ${1:module_name} do + ${0} + end + +snippet defp + defp ${1:name} do + ${0} + end + +snippet defpr + defprotocol ${1:name}, [${0:function}] + +snippet defr + defrecord ${1:record_name}, ${0:fields} + +snippet doc + @doc """ + ${0} + """ + +snippet fn + fn(${1:args}) -> ${0} end + +snippet fun + function do + ${0} + end + +snippet mdoc + @moduledoc """ + ${0} + """ + +snippet rec + receive do + ${1} -> + ${0} + end + +snippet req + require ${0:module_name} + +snippet imp + import ${0:module_name} + +snippet ali + alias ${0:module_name} + +snippet test + test "${1:test_name}" do + ${0} + end + +snippet try try .. rescue .. end + try do + ${1} + rescue + ${2} -> ${0} + end diff --git a/skel/.config/nvim/plugged/vim-snippets/snippets/erlang.snippets b/skel/.config/nvim/plugged/vim-snippets/snippets/erlang.snippets new file mode 100644 index 0000000..8845870 --- /dev/null +++ b/skel/.config/nvim/plugged/vim-snippets/snippets/erlang.snippets @@ -0,0 +1,353 @@ +# module and export all +snippet mod + -module(${1:`vim_snippets#Filename('', 'my')`}). + + -compile([export_all]). + + start() -> + ${0} + + stop() -> + ok. +# define directive +snippet def + -define(${1:macro}, ${2:body}). +# export directive +snippet exp + -export([${1:function}/${0:arity}]). +# include directive +snippet inc + -include("${1:file}"). +# include_lib directive +snippet incl + -include_lib("${1:lib}/include/${1}.hrl").${2} +# behavior directive +snippet beh + -behaviour(${1:behaviour}). +# if expression +snippet if + if + ${1:guard} -> + ${0:body} + end +# case expression +snippet case + case ${1:expression} of + ${2:pattern} -> + ${0:body}; + end +# anonymous function +snippet fun + fun (${1:Parameters}) -> ${2:body} end +# try...catch +snippet try + try + ${1} + catch + ${2:_:_} -> ${0:got_some_exception} + end +# record directive +snippet rec + -record(${1:record}, { + ${2:field}=${3:value}}). +# todo comment +snippet todo + %% TODO: ${0} +## Snippets below (starting with '%') are in EDoc format. +## See http://www.erlang.org/doc/apps/edoc/chapter.html#id56887 for more details +# doc comment +snippet %d + %% @doc ${0} +# end of doc comment +snippet %e + %% @end +# specification comment +snippet %s + %% @spec ${0} +# private function marker +snippet %p + %% @private +# OTP application +snippet application + -module(${1:`vim_snippets#Filename('', 'my')`}). + + -behaviour(application). + + -export([start/2, stop/1]). + + start(_Type, _StartArgs) -> + case ${0:root_supervisor}:start_link() of + {ok, Pid} -> + {ok, Pid}; + Other -> + {error, Other} + end. + + stop(_State) -> + ok. +# OTP supervisor +snippet supervisor + -module(${1:`vim_snippets#Filename('', 'my')`}). + + -behaviour(supervisor). + + %% API + -export([start_link/0]). + + %% Supervisor callbacks + -export([init/1]). + + -define(SERVER, ?MODULE). + + start_link() -> + supervisor:start_link({local, ?SERVER}, ?MODULE, []). + + init([]) -> + Server = {${0:my_server}, {$2, start_link, []}, + permanent, 2000, worker, [$2]}, + Children = [Server], + RestartStrategy = {one_for_one, 0, 1}, + {ok, {RestartStrategy, Children}}. +# OTP gen_server +snippet gen_server + -module(${0:`vim_snippets#Filename('', 'my')`}). + + -behaviour(gen_server). + + %% API + -export([ + start_link/0 + ]). + + %% gen_server callbacks + -export([init/1, handle_call/3, handle_cast/2, handle_info/2, + terminate/2, code_change/3]). + + -define(SERVER, ?MODULE). + + -record(state, {}). + + %%%=================================================================== + %%% API + %%%=================================================================== + + start_link() -> + gen_server:start_link({local, ?SERVER}, ?MODULE, [], []). + + %%%=================================================================== + %%% gen_server callbacks + %%%=================================================================== + + init([]) -> + {ok, #state{}}. + + handle_call(_Request, _From, State) -> + Reply = ok, + {reply, Reply, State}. + + handle_cast(_Msg, State) -> + {noreply, State}. + + handle_info(_Info, State) -> + {noreply, State}. + + terminate(_Reason, _State) -> + ok. + + code_change(_OldVsn, State, _Extra) -> + {ok, State}. + + %%%=================================================================== + %%% Internal functions + %%%=================================================================== +# common_test test_SUITE +snippet testsuite + -module(${0:`vim_snippets#Filename('', 'my')`}). + + -include_lib("common_test/include/ct.hrl"). + + %% Test server callbacks + -export([suite/0, all/0, groups/0, + init_per_suite/1, end_per_suite/1, + init_per_group/2, end_per_group/2, + init_per_testcase/2, end_per_testcase/2]). + + %% Test cases + -export([ + ]). + + %%-------------------------------------------------------------------- + %% COMMON TEST CALLBACK FUNCTIONS + %%-------------------------------------------------------------------- + + %%-------------------------------------------------------------------- + %% Function: suite() -> Info + %% + %% Info = [tuple()] + %% List of key/value pairs. + %% + %% Description: Returns list of tuples to set default properties + %% for the suite. + %% + %% Note: The suite/0 function is only meant to be used to return + %% default data values, not perform any other operations. + %%-------------------------------------------------------------------- + suite() -> + [{timetrap,{minutes,10}}]. + + %%-------------------------------------------------------------------- + %% Function: init_per_suite(Config0) -> + %% Config1 | {skip,Reason} | {skip_and_save,Reason,Config1} + %% + %% Config0 = Config1 = [tuple()] + %% A list of key/value pairs, holding the test case configuration. + %% Reason = term() + %% The reason for skipping the suite. + %% + %% Description: Initialization before the suite. + %% + %% Note: This function is free to add any key/value pairs to the Config + %% variable, but should NOT alter/remove any existing entries. + %%-------------------------------------------------------------------- + init_per_suite(Config) -> + Config. + + %%-------------------------------------------------------------------- + %% Function: end_per_suite(Config0) -> void() | {save_config,Config1} + %% + %% Config0 = Config1 = [tuple()] + %% A list of key/value pairs, holding the test case configuration. + %% + %% Description: Cleanup after the suite. + %%-------------------------------------------------------------------- + end_per_suite(_Config) -> + ok. + + %%-------------------------------------------------------------------- + %% Function: init_per_group(GroupName, Config0) -> + %% Config1 | {skip,Reason} | {skip_and_save,Reason,Config1} + %% + %% GroupName = atom() + %% Name of the test case group that is about to run. + %% Config0 = Config1 = [tuple()] + %% A list of key/value pairs, holding configuration data for the group. + %% Reason = term() + %% The reason for skipping all test cases and subgroups in the group. + %% + %% Description: Initialization before each test case group. + %%-------------------------------------------------------------------- + init_per_group(_GroupName, Config) -> + Config. + + %%-------------------------------------------------------------------- + %% Function: end_per_group(GroupName, Config0) -> + %% void() | {save_config,Config1} + %% + %% GroupName = atom() + %% Name of the test case group that is finished. + %% Config0 = Config1 = [tuple()] + %% A list of key/value pairs, holding configuration data for the group. + %% + %% Description: Cleanup after each test case group. + %%-------------------------------------------------------------------- + end_per_group(_GroupName, _Config) -> + ok. + + %%-------------------------------------------------------------------- + %% Function: init_per_testcase(TestCase, Config0) -> + %% Config1 | {skip,Reason} | {skip_and_save,Reason,Config1} + %% + %% TestCase = atom() + %% Name of the test case that is about to run. + %% Config0 = Config1 = [tuple()] + %% A list of key/value pairs, holding the test case configuration. + %% Reason = term() + %% The reason for skipping the test case. + %% + %% Description: Initialization before each test case. + %% + %% Note: This function is free to add any key/value pairs to the Config + %% variable, but should NOT alter/remove any existing entries. + %%-------------------------------------------------------------------- + init_per_testcase(_TestCase, Config) -> + Config. + + %%-------------------------------------------------------------------- + %% Function: end_per_testcase(TestCase, Config0) -> + %% void() | {save_config,Config1} | {fail,Reason} + %% + %% TestCase = atom() + %% Name of the test case that is finished. + %% Config0 = Config1 = [tuple()] + %% A list of key/value pairs, holding the test case configuration. + %% Reason = term() + %% The reason for failing the test case. + %% + %% Description: Cleanup after each test case. + %%-------------------------------------------------------------------- + end_per_testcase(_TestCase, _Config) -> + ok. + + %%-------------------------------------------------------------------- + %% Function: groups() -> [Group] + %% + %% Group = {GroupName,Properties,GroupsAndTestCases} + %% GroupName = atom() + %% The name of the group. + %% Properties = [parallel | sequence | Shuffle | {RepeatType,N}] + %% Group properties that may be combined. + %% GroupsAndTestCases = [Group | {group,GroupName} | TestCase] + %% TestCase = atom() + %% The name of a test case. + %% Shuffle = shuffle | {shuffle,Seed} + %% To get cases executed in random order. + %% Seed = {integer(),integer(),integer()} + %% RepeatType = repeat | repeat_until_all_ok | repeat_until_all_fail | + %% repeat_until_any_ok | repeat_until_any_fail + %% To get execution of cases repeated. + %% N = integer() | forever + %% + %% Description: Returns a list of test case group definitions. + %%-------------------------------------------------------------------- + groups() -> + []. + + %%-------------------------------------------------------------------- + %% Function: all() -> GroupsAndTestCases | {skip,Reason} + %% + %% GroupsAndTestCases = [{group,GroupName} | TestCase] + %% GroupName = atom() + %% Name of a test case group. + %% TestCase = atom() + %% Name of a test case. + %% Reason = term() + %% The reason for skipping all groups and test cases. + %% + %% Description: Returns the list of groups and test cases that + %% are to be executed. + %%-------------------------------------------------------------------- + all() -> + []. + + + %%-------------------------------------------------------------------- + %% TEST CASES + %%-------------------------------------------------------------------- + + %%-------------------------------------------------------------------- + %% Function: TestCase(Config0) -> + %% ok | exit() | {skip,Reason} | {comment,Comment} | + %% {save_config,Config1} | {skip_and_save,Reason,Config1} + %% + %% Config0 = Config1 = [tuple()] + %% A list of key/value pairs, holding the test case configuration. + %% Reason = term() + %% The reason for skipping the test case. + %% Comment = term() + %% A comment about the test case that will be printed in the html log. + %% + %% Description: Test case function. (The name of it must be specified in + %% the all/0 list or in a test case group for the test case + %% to be executed). + %%-------------------------------------------------------------------- + diff --git a/skel/.config/nvim/plugged/vim-snippets/snippets/eruby.snippets b/skel/.config/nvim/plugged/vim-snippets/snippets/eruby.snippets new file mode 100644 index 0000000..9541835 --- /dev/null +++ b/skel/.config/nvim/plugged/vim-snippets/snippets/eruby.snippets @@ -0,0 +1,127 @@ +# .erb and .rhmtl files + +# Includes html.snippets + +# Rails ***************************** +snippet rc + <% ${0} %> +snippet rce + <%= ${1} %> +snippet % + <% ${0} %> +snippet = + <%= ${1} %> +snippet end + <% end %> +snippet ead + <% ${1}.each do |${2}| %> + ${0} + <% end %> +snippet for + <% for ${2:item} in ${1} %> + ${0} + <% end %> +snippet rp + <%= render :partial => '${0:item}' %> +snippet rpl + <%= render :partial => '${1:item}', :locals => { :${2:name} => '${3:value}'${0} } %> +snippet rps + <%= render :partial => '${1:item}', :status => ${0:500} %> +snippet rpc + <%= render :partial => '${1:item}', :collection => ${0:items} %> +snippet lia + <%= link_to '${1:link text...}', :action => '${0:index}' %> +snippet liai + <%= link_to '${1:link text...}', :action => '${2:edit}', :id => ${0:@item} %> +snippet lic + <%= link_to '${1:link text...}', :controller => '${0:items}' %> +snippet lica + <%= link_to '${1:link text...}', :controller => '${2:items}', :action => '${0:index}' %> +snippet licai + <%= link_to '${1:link text...}', :controller => '${2:items}', :action => '${3:edit}', :id => ${0:@item} %> +snippet yield + <%= yield ${1::content_symbol} %> +snippet conf + <% content_for :${1:head} do %> + ${0} + <% end %> +snippet cs + <%= collection_select <+object+>, <+method+>, <+collection+>, <+value_method+>, <+text_method+><+, <+[options]+>, <+[html_options]+>+> %> +snippet ct + <%= content_tag '${1:DIV}', ${2:content}${0:,options} %> +snippet ff + <%= form_for @${1:model} do |f| %> + ${0} + <% end %> +snippet ffi + <%= ${1:f}.input :${0:attribute} %> +snippet ffcb + <%= ${1:f}.check_box :${0:attribute} %> +snippet ffe + <% error_messages_for :${1:model} %> + + <%= form_for @${2:model} do |f| %> + ${0} + <% end %> +snippet ffff + <%= ${1:f}.file_field :${0:attribute} %> +snippet ffhf + <%= ${1:f}.hidden_field :${0:attribute} %> +snippet ffl + <%= ${1:f}.label :${2:attribute}, '${0:$2}' %> +snippet ffpf + <%= ${1:f}.password_field :${0:attribute} %> +snippet ffrb + <%= ${1:f}.radio_button :${2:attribute}, :${0:tag_value} %> +snippet ffs + <%= ${1:f}.submit "${0:submit}" %> +snippet ffta + <%= ${1:f}.text_area :${0:attribute} %> +snippet fftf + <%= ${1:f}.text_field :${0:attribute} %> +snippet fields + <%= fields_for :${1:model}, @$1 do |${2:f}| %> + ${0} + <% end %> +snippet i18 + I18n.t('${1:type.key}') +snippet it + <%= image_tag "${1}"${0} %> +snippet jit + <%= javascript_include_tag ${0::all} %> +snippet jsit + <%= javascript_include_tag "${0}" %> +snippet lim + <%= link_to ${1:model}.${2:name}, ${3:$1}_path(${0:$1}) %> +snippet linp + <%= link_to "${1:Link text...}", ${2:parent}_${3:child}_path(${4:@$2}, ${0:@$3}) %> +snippet linpp + <%= link_to "${1:Link text...}", ${2:parent}_${3:child}_path(${0:@$2}) %> +snippet lip + <%= link_to "${1:Link text...}", ${2:model}_path(${0:@$2}) %> +snippet lipp + <%= link_to "${1:Link text...}", ${0:model}s_path %> +snippet lt + <%= link_to "${1:name}", ${0:dest} %> +snippet ntc + <%= number_to_currency(${1}) %> +snippet ofcfs + <%= options_from_collection_for_select ${1:collection}, ${2:value_method}, ${3:text_method}, ${0:selected_value} %> +snippet rf + <%= render :file => "${1:file}"${0} %> +snippet rt + <%= render :template => "${1:file}"${0} %> +snippet slt + <%= stylesheet_link_tag ${1::all}, :cache => ${0:true} %> +snippet sslt + <%= stylesheet_link_tag "${0}" %> +snippet if + <% if ${1} %> + ${0} + <% end %> +snippet ife + <% if ${1} %> + ${2} + <% else %> + ${0} + <% end %> diff --git a/skel/.config/nvim/plugged/vim-snippets/snippets/falcon.snippets b/skel/.config/nvim/plugged/vim-snippets/snippets/falcon.snippets new file mode 100644 index 0000000..c523980 --- /dev/null +++ b/skel/.config/nvim/plugged/vim-snippets/snippets/falcon.snippets @@ -0,0 +1,71 @@ +snippet #! + #!/usr/bin/env falcon + +# Import +snippet imp + import ${0:module} + +# Function +snippet fun + function ${2:function_name}(${3}) + ${0} + end + +# Class +snippet class + class ${1:class_name}(${2:class_params}) + ${0:/* members/methods */} + end + +# If +snippet if + if ${1:condition} + ${0} + end + +# If else +snippet ife + if ${1:condition} + ${0} + else + ${1} + end + +# If else if +snippet eif + elif ${1:condition} + ${0} + +# Switch case +snippet switch + switch ${1:expression} + case ${2:item} + case ${0:item} + default + end + +# Select +snippet select + select ${1:variable} + case ${2:TypeSpec} + case ${0:TypeSpec} + default + end + +# For/in Loop +snippet forin + for ${1:element} in ${2:container} + ${0} + end + +# For/to Loop +snippet forto + for ${1:lowerbound} to ${2:upperbound} + ${0} + end + +# While Loop +snippet wh + while ${1:conidition} + ${0} + end diff --git a/skel/.config/nvim/plugged/vim-snippets/snippets/go.snippets b/skel/.config/nvim/plugged/vim-snippets/snippets/go.snippets new file mode 100644 index 0000000..0239a3f --- /dev/null +++ b/skel/.config/nvim/plugged/vim-snippets/snippets/go.snippets @@ -0,0 +1,232 @@ +# shorthand variable declaration +snippet v + ${1} := ${2} +# variable initialization +snippet vr + var ${1:t} ${0:string} +# variable declaration +snippet var + var ${1} ${2} = ${3} +# variables declaration +snippet vars + var ( + ${1} ${2} = ${3} + ) +# append +snippet ap + append(${1:slice}, ${0:value}) +# bool +snippet bl + bool +# byte +snippet bt + byte +# break +snippet br + break +# channel +snippet ch + chan ${0:int} +# case +snippet cs + case ${1:value}: + ${0} +# const +snippet c + const ${1:NAME} = ${0:0} +# constants with iota +snippet co + const ( + ${1:NAME1} = iota + ${0:NAME2} + ) +# continue +snippet cn + continue +# defer +snippet df + defer ${0:func}() +# defer recover +snippet dfr + defer func() { + if err := recover(); err != nil { + ${0} + } + }() +# gpl +snippet gpl + /* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see . + * + * Copyright (C) ${1:Author}, `strftime("%Y")` + */ + + ${0} +# int +snippet i + int +# import +snippet im + import ( + "${1:package}" + ) +# interface +snippet in + interface{} +# full interface snippet +snippet inf + interface ${1:name} { + ${2:/* methods */} + } +# if condition +snippet if + if ${1:/* condition */} { + ${2} + } +# else snippet +snippet el + else { + ${1} + } +# error snippet +snippet ir + if err != nil { + return err + } + ${0} +# false +snippet f + false +# fallthrough +snippet ft + fallthrough +# float +snippet fl + float32 +# float32 +snippet f3 + float32 +# float64 +snippet f6 + float64 +# if else +snippet ie + if ${1:/* condition */} { + ${2} + } else { + ${3} + } + ${0} +# for loop +snippet fo + for ${2:i} := 0; $2 < ${1:count}; $2${3:++} { + ${4} + } + ${0} +# for range loop +snippet fr + for ${1:k}, ${2:v} := range ${3} { + ${4} + } + ${0} +# function simple +snippet fun + func ${1:funcName}(${2}) ${3:error} { + ${4} + } + ${0} +# function on receiver +snippet fum + func (self ${1:type}) ${2:funcName}(${3}) ${4:error} { + ${5} + } + ${0} +# log printf +snippet lf + log.Printf("%${1:s}", ${2:var}) +# log printf +snippet lp + log.Println("${1}") +# make +snippet mk + make(${1:[]string}, ${0:0}) +# map +snippet mp + map[${1:string}]${0:int} +# main() +snippet main + func main() { + ${1} + } + ${0} +# new +snippet nw + new(${0:type}) +# panic +snippet pn + panic("${0:msg}") +# print +snippet pr + fmt.Printf("%${1:s}\n", ${2:var}) +# range +snippet rn + range ${0} +# return +snippet rt + return ${0} +# result +snippet rs + result +# select +snippet sl + select { + case ${1:v1} := <-${2:chan1} + ${3} + case ${4:v2} := <-${5:chan2} + ${6} + default: + ${0} + } +# string +snippet sr + string +# struct +snippet st + struct ${1:name} { + ${2:/* data */} + } + ${0} +# switch +snippet sw + switch ${1:var} { + case ${2:value1}: + ${3} + case ${4:value2}: + ${5} + default: + ${0} + } +snippet sp + fmt.Sprintf("%${1:s}", ${2:var}) +# true +snippet t + true +# goroutine named function +snippet g + go ${1:funcName}(${0}) +# goroutine anonymous function +snippet ga + go func(${1} ${2:type}) { + ${3:/* code */} + }(${0}) diff --git a/skel/.config/nvim/plugged/vim-snippets/snippets/haml.snippets b/skel/.config/nvim/plugged/vim-snippets/snippets/haml.snippets new file mode 100644 index 0000000..09217c6 --- /dev/null +++ b/skel/.config/nvim/plugged/vim-snippets/snippets/haml.snippets @@ -0,0 +1,37 @@ +snippet t + %table + %tr + %th + ${1:headers} + %tr + %td + ${0:headers} +snippet ul + %ul + %li + ${0:item} + %li +snippet rp + = render :partial => "${0:item}" +snippet rpc + = render :partial => "${1:item}", :collection => ${0:@$1s} +snippet rpl + = render :partial => "${1:item}", :locals => { :${2:$1} => ${0:@$1} +snippet rpo + = render :partial => "${1:item}", :object => ${0:@$1} +snippet lt + = link_to ${1:name}, ${2:dest} +snippet mt + = mail_to ${1:email_address}, ${2:name} +snippet mts + = mail_to ${1:email_address}, ${2:name}, :subject => ${3}, :body => ${4} +snippet ife + - if ${1:condition} + ${2} + - else + ${0} +snippet ifp + - if ${1:condition}.presence? + ${0} +snippet ntc + = number_to_currency(${1}) diff --git a/skel/.config/nvim/plugged/vim-snippets/snippets/haskell.snippets b/skel/.config/nvim/plugged/vim-snippets/snippets/haskell.snippets new file mode 100644 index 0000000..f5f1598 --- /dev/null +++ b/skel/.config/nvim/plugged/vim-snippets/snippets/haskell.snippets @@ -0,0 +1,82 @@ +snippet lang + {-# LANGUAGE ${0:OverloadedStrings} #-} +snippet info + -- | + -- Module : ${1:Module.Namespace} + -- Copyright : ${2:Author} ${3:2011-2012} + -- License : ${4:BSD3} + -- + -- Maintainer : ${5:email@something.com} + -- Stability : ${6:experimental} + -- Portability : ${7:unknown} + -- + -- ${0:Description} + -- +snippet import + import ${0:Data.Text} +snippet import2 + import ${1:Data.Text} (${0:head}) +snippet importq + import qualified ${1:Data.Text} as ${0:T} +snippet inst + instance ${1:Monoid} ${2:Type} where + ${0} +snippet type + type ${1:Type} = ${0:Type} +snippet data + data ${1:Type} = ${2:$1} ${0:Int} +snippet newtype + newtype ${1:Type} = ${2:$1} ${0:Int} +snippet class + class ${1:Class} a where + ${0} +snippet module + module `substitute(substitute(expand('%:r'), '[/\\]','.','g'),'^\%(\l*\.\)\?','','')` ( + ) where + `expand('%') =~ 'Main' ? "\n\nmain = do\n print \"hello world\"" : ""` + +snippet const + ${1:name} :: ${2:a} + $1 = ${0:undefined} +snippet fn + ${1:fn} :: ${2:a} -> ${3:a} + $1 ${4} = ${0:undefined} +snippet fn2 + ${1:fn} :: ${2:a} -> ${3:a} -> ${4:a} + $1 ${5} = ${0:undefined} +snippet ap + ${1:map} ${2:fn} ${0:list} +snippet do + do + +snippet λ + \${1:x} -> ${0} +snippet \ + \${1:x} -> ${0} +snippet <- + ${1:a} <- ${0:m a} +snippet ← + ${1:a} <- ${0:m a} +snippet -> + ${1:m a} -> ${0:a} +snippet → + ${1:m a} -> ${0:a} +snippet tup + (${1:a}, ${0:b}) +snippet tup2 + (${1:a}, ${2:b}, ${0:c}) +snippet tup3 + (${1:a}, ${2:b}, ${3:c}, ${0:d}) +snippet rec + ${1:Record} { ${2:recFieldA} = ${3:undefined} + , ${4:recFieldB} = ${0:undefined} + } +snippet case + case ${1:something} of + ${2} -> ${0} +snippet let + let ${1} = ${2} + in ${3} +snippet where + where + ${1:fn} = ${0:undefined} diff --git a/skel/.config/nvim/plugged/vim-snippets/snippets/html.snippets b/skel/.config/nvim/plugged/vim-snippets/snippets/html.snippets new file mode 100644 index 0000000..f25e1bc --- /dev/null +++ b/skel/.config/nvim/plugged/vim-snippets/snippets/html.snippets @@ -0,0 +1,832 @@ +# Some useful Unicode entities +# Non-Breaking Space +snippet nbs +   +# ← +snippet left + ← +# → +snippet right + → +# ↑ +snippet up + ↑ +# ↓ +snippet down + ↓ +# ↩ +snippet return + ↩ +# ⇤ +snippet backtab + ⇤ +# ⇥ +snippet tab + ⇥ +# ⇧ +snippet shift + ⇧ +# ⌃ +snippet ctrl + ⌃ +# ⌅ +snippet enter + ⌅ +# ⌘ +snippet cmd + ⌘ +# ⌥ +snippet option + ⌥ +# ⌦ +snippet delete + ⌦ +# ⌫ +snippet backspace + ⌫ +# ⎋ +snippet esc + ⎋ +# Generic Doctype +snippet doctype HTML 4.01 Strict + +snippet doctype HTML 4.01 Transitional + +snippet doctype HTML 5 + +snippet doctype XHTML 1.0 Frameset + +snippet doctype XHTML 1.0 Strict + +snippet doctype XHTML 1.0 Transitional + +snippet doctype XHTML 1.1 + +# HTML Doctype 4.01 Strict +snippet docts + +# HTML Doctype 4.01 Transitional +snippet doct + +# HTML Doctype 5 +snippet doct5 + +# XHTML Doctype 1.0 Frameset +snippet docxf + +# XHTML Doctype 1.0 Strict +snippet docxs + +# XHTML Doctype 1.0 Transitional +snippet docxt + +# XHTML Doctype 1.1 +snippet docx + +# Attributes +snippet attr + ${1:attribute}="${0:property}" +snippet attr+ + ${1:attribute}="${2:property}" attr+ +snippet . + class="${1}" +snippet # + id="${1}" +snippet alt + alt="${1}" +snippet charset + charset="${1:utf-8}" +snippet data + data-${1}="${2:$1}" +snippet for + for="${1}" +snippet height + height="${1}" +snippet href + href="${1:#}" +snippet lang + lang="${1:en}" +snippet media + media="${1}" +snippet name + name="${1}" +snippet rel + rel="${1}" +snippet scope + scope="${1:row}" +snippet src + src="${1}" +snippet title= + title="${1}" +snippet type + type="${1}" +snippet value + value="${1}" +snippet width + width="${1}" +# Elements +snippet a + ${0:$1} +snippet a. + ${0:$1} +snippet a# + ${0:$1} +snippet a:ext + ${0:$1} +snippet a:mail + ${0:email me} +snippet abbr + ${0} +snippet address +

    + ${0} +
    +snippet area + ${0} +snippet area+ + ${4} + area+ +snippet area:c + ${0} +snippet area:d + ${0} +snippet area:p + ${0} +snippet area:r + ${0} +snippet article +
    + ${0} +
    +snippet article. +
    + ${0} +
    +snippet article# +
    + ${0} +
    +snippet aside + +snippet aside. + +snippet aside# + +snippet audio +