add vim-lastplace
authorAJ ONeal <aj@therootcompany.com>
Mon, 15 Mar 2021 19:41:36 +0000 (19:41 +0000)
committerAJ ONeal <aj@therootcompany.com>
Mon, 22 Mar 2021 05:52:50 +0000 (05:52 +0000)
vim-lastplace/README.md [new file with mode: 0644]
vim-lastplace/install.ps1 [new file with mode: 0644]
vim-lastplace/install.sh [new file with mode: 0644]
vim-lastplace/lastplace.vim [new file with mode: 0644]

diff --git a/vim-lastplace/README.md b/vim-lastplace/README.md
new file mode 100644 (file)
index 0000000..192f58c
--- /dev/null
@@ -0,0 +1,28 @@
+---
+title: vim-lastplace
+homepage: https://github.com/farmergreg/vim-lastplace
+tagline: |
+  vim-lastplace - Intelligently reopen files at your last edit position in Vim.
+---
+
+To update (replacing the current version) run `webi vim-lastplace`.
+
+## Cheat Sheet
+
+> `vim-lastplace` will resume your cursor to its last position when you re-open
+> a file, including re-opening folds as needed.
+
+Simply put: installing this plugin will cause your cursor to be put back where
+you expect it when switching between files.
+
+### How to remove lastplace
+
+```vim
+rm -rf ~/.vim/pack/plugins/start/vim-lastplace
+```
+
+### How to configure manually
+
+See
+<https://vim.fandom.com/wiki/Restore_cursor_to_file_position_in_previous_editing_session>
+and <https://github.com/farmergreg/vim-lastplace>
diff --git a/vim-lastplace/install.ps1 b/vim-lastplace/install.ps1
new file mode 100644 (file)
index 0000000..749d400
--- /dev/null
@@ -0,0 +1,6 @@
+#!/usr/bin/env pwsh
+
+New-Item -Path "$Env:USERPROFILE\.vim\pack\plugins\start" -ItemType Directory -Force
+
+Remove-Item -Path "$Env:USERPROFILE\.vim\pack\plugins\start\vim-lastplace" -Recurse -ErrorAction Ignore
+& git clone --depth=1 https://github.com/farmergreg/vim-lastplace.git "$Env:USERPROFILE\.vim\pack\plugins\start\vim-lastplace"
diff --git a/vim-lastplace/install.sh b/vim-lastplace/install.sh
new file mode 100644 (file)
index 0000000..fa9e82c
--- /dev/null
@@ -0,0 +1,36 @@
+#!/bin/bash
+
+function __init_vim_lastplace() {
+    set -e
+    set -u
+
+    mkdir -p "$HOME/.vim/pack/plugins/start"
+    rm -rf "$HOME/.vim/pack/plugins/start/vim-lastplace"
+    git clone --depth=1 https://github.com/farmergreg/vim-lastplace.git "$HOME/.vim/pack/plugins/start/vim-lastplace"
+
+    if [ ! -f "$HOME/.vimrc" ]; then
+        touch "$HOME/.vimrc"
+    fi
+
+    mkdir -p ~/.vim/plugins
+    if ! [ -f "$HOME/.vim/plugins/lastplace.vim" ]; then
+        WEBI_HOST=${WEBI_HOST:-"https://webinstall.dev"}
+        curl -fsSL -o ~/.vim/plugins/lastplace.vim "$WEBI_HOST/packages/vim-lastplace/lastplace.vim"
+    fi
+
+    if ! grep 'source.*plugins.lastplace.vim' -r ~/.vimrc >/dev/null 2>/dev/null; then
+        set +e
+        mkdir -p ~/.vim/plugins
+        printf '\n" lastplace: explicit defaults from webinstall.dev/vim-lastplace\n' >> ~/.vimrc
+        printf 'source ~/.vim/plugins/lastplace.vim\n' >> ~/.vimrc
+        set -e
+        echo ""
+        echo "add ~/.vim/plugins/lastplace.vim"
+        echo "updated ~/.vimrc with 'source ~/.vim/plugins/lastplace.vim'"
+    fi
+
+    echo ""
+    echo "vim-lastplace enabled with explicit defaults"
+}
+
+__init_vim_lastplace
diff --git a/vim-lastplace/lastplace.vim b/vim-lastplace/lastplace.vim
new file mode 100644 (file)
index 0000000..49888bf
--- /dev/null
@@ -0,0 +1,11 @@
+" For more configuration details read the source at
+" https://github.com/farmergreg/vim-lastplace/blob/master/plugin/vim-lastplace.vim
+
+" configure what file types to ignore
+let g:lastplace_ignore = "gitcommit,gitrebase,svn,hgcommit"
+
+" configure buffer types to ignore
+let g:lastplace_ignore_buftype = "quickfix,nofile,help"
+
+" automatically open folds when jumping to the last edit position
+let g:lastplace_open_folds = 0