This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" Use arrow keys or Ctrl-J/K to scroll in popup window. | |
" Also useful for terminals that maps the mouse wheel scrolls to arrow keys | |
" For example Urxvt with its Vtwheel extension | |
" From https://fortime.ws/blog/2020/03/14/20200312-01/ | |
function! s:IsScrollPopup() | |
let winids = popup_list() | |
if empty(winids) | return {} | endif | |
let winid = winids[0] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" From https://old.reddit.com/r/neovim/comments/1c3gf93/commentreplnvim_run_code_from_your_buffer_and/ | |
" | |
" Add the following lines to `ftplugin/{python,sh,zsh,lua,perl, ...}.vim | |
" and call :EvaluateAsComment to add the evaluation of the selected lines as a comment: | |
" | |
" print(1+2) | |
" | |
" becomes | |
" | |
" # 3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" A mapping that uses FZF to list all files in a Git repo and takes a count to restrict to | |
" those altered in last <count> commits. | |
nnoremap <silent><expr> g. v:count ? ':<c-u>' . v:count . 'GFilesAltered<cr>' : ':<c-u>GFiles<cr>' | |
command! -count=1 GFilesAltered call fzf#vim#files('', fzf#vim#with_preview( { | |
\ 'source': 'git log HEAD --max-count=<count> --diff-filter=MA --name-only --pretty=format: | ' . s:filter, | |
\ 'options': '--multi --prompt "Files altered in last <count> commits: "', | |
\ } )) | |
" If Fugitive is installed, there's a fallback, here's a possible fallback |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; Run or Raise Application using Shortcut | |
; From https://gist.github.com/dewaka/c494543b4cd2a2dcd09cc5a6aa0f7517 adapted to ah2 | |
RunOrRaise(exePath, winID:="") { | |
if (winID == "") { | |
exeName := SubStr(exePath, InStr(exePath, "\", , -1)+1) | |
winID := "ahk_exe " . exeName | |
} | |
If not WinExist(winID) { | |
UserProfile := EnvGet("USERPROFILE") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function! Set(args, isPersistent) abort | |
" remove whitespaces surrounding = | |
let cmd = 'set ' . substitute(a:args, '\s*=\s*', '=', 'g') | |
execute cmd | |
if !a:isPersistent | return | endif | |
" append modeline | |
let commentstring = empty(&l:commentstring) ? | |
\ (empty(&g:commentstring) ? '# %s' : &g:commentstring) : &l:commentstring |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" Use :Silent cmd to open a command cmd inside Vim with terminal output. | |
" For example, :Silent lazygit | |
" To surpress its output add a bang; useful for GUI applications. | |
" For example, open Firefox by :Silent! firefox, or | |
" look up a keyword by :set keywordprg=:Silent!\ zeal | |
" To open a file, use :Open file | |
" Useful, say, to view a compiled HTML of a markdown file, by :Open %:r.html | |
" or open an URL such as :set keywordprg=:Open\ https://devdocs.io/#q= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" From https://github.com/mg979/tasks.vim/pull/15/files | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" Command-line completion for ":Make" | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
command! -bang -nargs=* -complete=customlist,MakeComplete Make silent make<bang> <args> | silent redraw! | |
command! -bang -nargs=* -complete=customlist,MakeComplete LMake silent lmake<bang> <args> | silent redraw! | |
if executable('awk') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# Adaption of https://github.com/tom-doerr/chatgpt_commit_message_hook/main/prepare-commit-msg | |
# | |
# Mark this file as executable and add it into the global hooks folder | |
# whose path is given by the core.hooksPath configuration variable | |
# skip during rebase | |
import sys | |
if len(sys.argv) > 2: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
command! -range -nargs=+ -complete=customlist,s:AIChatRoleCompletion AIRole <line1>,<line2>call s:AIRole(<q-args>) | |
function! s:AIRole(instruction) range | |
let instruction = trim(a:instruction) | |
let i = match(instruction . ' ', '\s') | |
let role = instruction[0:i-1] | |
let instruction = trim(instruction[i:-1]) | |
let prompt = !empty(instruction) ? shellescape('Please consider: ' . instruction . '.') : '' | |
" term ++hidden ++open | |
exe a:firstline.','.a:lastline . 'term aichat --role ' . role . ' -- ' . prompt | |
endfunction |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# | |
# Adaption of https://github.com/majutsushi/etc/commit/e62904088c698e064c17522d54dff91b629ee253#diff-53b7e445a85984949f551c277d4cc4ee9682287cb234e075e6d352be887e7494 | |
# with https://github.com/pivotal-cf/git-hooks-core/blob/master/.base-hook | |
# | |
# This script is meant to be put into a directory pointed to by core.hooksPath | |
# in Git 2.9. | |
# Then for each hook you want to support, create a symlink "hookname -> multihook" | |
# and optionally a directory "hookname.d" where you can put all scripts for | |
# that hook |