mirror of
https://github.com/webinstall/webi-installers.git
synced 2026-08-19 03:56:16 +00:00
feat: add vim-commentary
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
---
|
||||
title: vim-commentary
|
||||
homepage: https://github.com/tpope/vim-commentary
|
||||
tagline: |
|
||||
Toggle blocks of line comments.
|
||||
---
|
||||
|
||||
To update (replacing the current version) run `webi vim-smartcase`.
|
||||
|
||||
### Files
|
||||
|
||||
These are the files / directories that are created and/or modified with this
|
||||
install:
|
||||
|
||||
```text
|
||||
~/.vimrc
|
||||
~/.vim/pack/plugins/start/vim-commentary/
|
||||
~/.vim/plugins/smartcase.vim
|
||||
```
|
||||
|
||||
## Cheat Sheet
|
||||
|
||||
> Makes it super easy to toggle entire blocks of comments.
|
||||
|
||||
```vim
|
||||
gc
|
||||
```
|
||||
|
||||
- `v` to enter visual model
|
||||
- `hjkl` (or arrow keys) to select lines
|
||||
- `gc` to toggle comments on or off
|
||||
|
||||
### How to add file types
|
||||
|
||||
Update `~/.vim/plugins/commentary.vim` with a line like this:
|
||||
|
||||
```vim
|
||||
autocmd FileType apache setlocal commentstring=#\ %s
|
||||
```
|
||||
|
||||
### How to do Advanced Vim-Nerd Stuff
|
||||
|
||||
All the typical navigation applies:
|
||||
|
||||
> Use `gcc` to comment out a line (takes a count), `gc` to comment out the
|
||||
> target of a motion (for example, `gcap` to comment out a paragraph), `gc` in
|
||||
> operator pending mode to target a comment. You can also use it as a command,
|
||||
> either with a range like `:7,17Commentary`, or as part of a `:global`
|
||||
> invocation like with `:g/TODO/Commentary`. - The Official README
|
||||
@@ -0,0 +1,2 @@
|
||||
" Example of a adding additional file type support:
|
||||
"autocmd FileType apache setlocal commentstring=#\ %s
|
||||
@@ -0,0 +1,17 @@
|
||||
#!/usr/bin/env pwsh
|
||||
|
||||
$my_name = "commentary"
|
||||
$my_pkg_name = "vim-commentary"
|
||||
$my_repo = "https://github.com/tpope/vim-commentary"
|
||||
|
||||
IF (!(Test-Path -Path "$Env:USERPROFILE\.vim\pack\plugins\start")) {
|
||||
New-Item -Path "$Env:USERPROFILE\.vim\pack\plugins\start" -ItemType Directory -Force | out-null
|
||||
}
|
||||
|
||||
Remove-Item -Path "$Env:USERPROFILE\.vim\pack\plugins\start\${my_name}" -Recurse -ErrorAction Ignore
|
||||
& git clone --depth=1 "$my_repo" "$Env:USERPROFILE\.vim\pack\plugins\start\$my_name.vim"
|
||||
|
||||
IF (!(Test-Path -Path "$Env:USERPROFILE\.vim\plugin\$my_name.vim")) {
|
||||
IF ($Env:WEBI_HOST -eq $null -or $Env:WEBI_HOST -eq "") { $Env:WEBI_HOST = "https://webinstall.dev" }
|
||||
curl.exe -sS -o "$Env:USERPROFILE\.vim\plugin\$my_name.vim" "$Env:WEBI_HOST/packages/${my_pkg_name}/${my_name}.vim"
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
#!/bin/sh
|
||||
|
||||
__install_vim_plugin() { (
|
||||
set -e
|
||||
set -u
|
||||
|
||||
my_name="commentary"
|
||||
my_pkg_name="vim-commentary"
|
||||
my_repo="https://github.com/tpope/vim-commentary.git"
|
||||
my_note="vim-commentary: installed via webinstall.dev/vim-commentary"
|
||||
my_installed_msg="${my_pkg_name} installed with example config"
|
||||
|
||||
mkdir -p ~/.vim/pack/plugins/start
|
||||
rm -rf ~/.vim/pack/plugins/start/"${my_pkg_name}"
|
||||
git clone --depth=1 "${my_repo}" ~/.vim/pack/plugins/start/"${my_pkg_name}"
|
||||
|
||||
if [ ! -f ~/.vimrc ]; then
|
||||
touch ~/.vimrc
|
||||
fi
|
||||
|
||||
mkdir -p ~/.vim/plugins
|
||||
if ! [ -f ~/.vim/plugins/"${my_name}.vim" ]; then
|
||||
WEBI_HOST=${WEBI_HOST:-"https://webinstall.dev"}
|
||||
curl -fsSL -o ~/.vim/plugins/"${my_name}.vim" "$WEBI_HOST/packages/${my_pkg_name}/${my_name}.vim"
|
||||
fi
|
||||
|
||||
if ! grep "source.*plugins.${my_name}.vim" -r ~/.vimrc > /dev/null 2> /dev/null; then
|
||||
set +e
|
||||
mkdir -p ~/.vim/plugins
|
||||
printf '\n" %s\n' "${my_note}" >> ~/.vimrc
|
||||
printf 'source ~/.vim/plugins/%s.vim\n' "${my_name}" >> ~/.vimrc
|
||||
set -e
|
||||
echo ""
|
||||
echo "add ~/.vim/plugins/${my_name}.vim"
|
||||
echo "updated ~/.vimrc with 'source ~/.vim/plugins/${my_name}.vim'"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "${my_installed_msg}"
|
||||
|
||||
); }
|
||||
|
||||
__install_vim_plugin
|
||||
Reference in New Issue
Block a user