git subrepo clone https://github.com/nanotee/zoxide.vim.git ./dotfiles/.vim/plugged/zoxide.vim
subrepo: subdir: "dotfiles/.vim/plugged/zoxide.vim" merged: "7add42b04" upstream: origin: "https://github.com/nanotee/zoxide.vim.git" branch: "master" commit: "7add42b04" git-subrepo: version: "0.4.3" origin: "???" commit: "???"
This commit is contained in:
parent
e30fca43b3
commit
774e7b2439
7 changed files with 293 additions and 0 deletions
12
dotfiles/.vim/plugged/zoxide.vim/.gitrepo
Normal file
12
dotfiles/.vim/plugged/zoxide.vim/.gitrepo
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
; DO NOT EDIT (unless you know what you are doing)
|
||||||
|
;
|
||||||
|
; This subdirectory is a git "subrepo", and this file is maintained by the
|
||||||
|
; git-subrepo command. See https://github.com/git-commands/git-subrepo#readme
|
||||||
|
;
|
||||||
|
[subrepo]
|
||||||
|
remote = https://github.com/nanotee/zoxide.vim.git
|
||||||
|
branch = master
|
||||||
|
commit = 7add42b0474b07c206c94d1693997e52d25c5fec
|
||||||
|
parent = e30fca43b3587faa4c8e4aa9fa124a351855e75c
|
||||||
|
method = merge
|
||||||
|
cmdver = 0.4.3
|
21
dotfiles/.vim/plugged/zoxide.vim/LICENSE
Normal file
21
dotfiles/.vim/plugged/zoxide.vim/LICENSE
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2020 Timothée Sterle
|
||||||
|
|
||||||
|
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.
|
45
dotfiles/.vim/plugged/zoxide.vim/README.md
Normal file
45
dotfiles/.vim/plugged/zoxide.vim/README.md
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
# zoxide.vim
|
||||||
|
|
||||||
|
A small (Neo)Vim wrapper for [zoxide](https://github.com/ajeetdsouza/zoxide)
|
||||||
|
|
||||||
|
## Requirements
|
||||||
|
|
||||||
|
- A recent version of Vim or Neovim
|
||||||
|
- The [zoxide](https://github.com/ajeetdsouza/zoxide) utility
|
||||||
|
- (optional) The [fzf](https://github.com/junegunn/fzf) utility along with the [fzf.vim](https://github.com/junegunn/fzf/blob/master/plugin/fzf.vim) script
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
Install using your favorite plugin manager:
|
||||||
|
|
||||||
|
- [vim-plug](https://github.com/junegunn/vim-plug)
|
||||||
|
```vim
|
||||||
|
Plug 'nanotee/zoxide.vim'
|
||||||
|
```
|
||||||
|
- [packer.nvim](https://github.com/wbthomason/packer.nvim)
|
||||||
|
```lua
|
||||||
|
use 'nanotee/zoxide.vim'
|
||||||
|
```
|
||||||
|
- [dein.vim](https://github.com/Shougo/dein.vim)
|
||||||
|
```vim
|
||||||
|
call dein#add('nanotee/zoxide.vim')
|
||||||
|
```
|
||||||
|
- [vim-packager](https://github.com/kristijanhusak/vim-packager)
|
||||||
|
```vim
|
||||||
|
call packager#add('nanotee/zoxide.vim')
|
||||||
|
```
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
The plugin defines commands that wrap the functionality of zoxide:
|
||||||
|
|
||||||
|
- `:Z {query}`: cd to the highest ranked directory matching your query. If `{query}` is omitted, cd to the home directory
|
||||||
|
- `:Lz {query}`: same as `:Z`, but local to the current window
|
||||||
|
- `:Tz {query}`: same as `:Z`, but local to the current tab
|
||||||
|
- `:Zi {query}`: cd to one of your highest ranking directories using fzf
|
||||||
|
- `:Lzi {query}`: same as `:Zi`, but local to the current window
|
||||||
|
- `:Tzi {query}`: same as `:Zi`, but local to the current tab
|
||||||
|
|
||||||
|
## Configuration
|
||||||
|
|
||||||
|
See [zoxide-vim-configuration](doc/zoxide-vim.txt#L27)
|
74
dotfiles/.vim/plugged/zoxide.vim/autoload/zoxide.vim
Normal file
74
dotfiles/.vim/plugged/zoxide.vim/autoload/zoxide.vim
Normal file
|
@ -0,0 +1,74 @@
|
||||||
|
function! s:build_cmd(cmd, query) abort
|
||||||
|
return join([get(g:, 'zoxide_executable', 'zoxide')] + map(a:cmd + a:query, 'shellescape(v:val)'), ' ')
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! zoxide#exec(cmd, query) abort
|
||||||
|
let result = systemlist(s:build_cmd(a:cmd, a:query))
|
||||||
|
if v:shell_error
|
||||||
|
echohl ErrorMsg | echo join(result, "\n") | echohl None
|
||||||
|
endif
|
||||||
|
return result
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! s:change_directory(cd_command, directory) abort
|
||||||
|
try
|
||||||
|
exe a:cd_command a:directory
|
||||||
|
catch
|
||||||
|
echohl ErrorMsg | echomsg v:exception | echohl None
|
||||||
|
return
|
||||||
|
endtry
|
||||||
|
|
||||||
|
pwd
|
||||||
|
|
||||||
|
if get(g:, 'zoxide_update_score', 1) && get(g:, 'zoxide_hook', 'none') !=# 'pwd'
|
||||||
|
call zoxide#exec(['add'], [getcwd()])
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! zoxide#z(cd_command, ...) abort
|
||||||
|
let query = empty(a:000) ? [$HOME] : a:000
|
||||||
|
|
||||||
|
if len(query) == 1 && (query[0] ==# '-' || isdirectory(query[0]))
|
||||||
|
call s:change_directory(a:cd_command, query[0])
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
let result = zoxide#exec(['query', '--exclude', getcwd()], query)[0]
|
||||||
|
if !v:shell_error | call s:change_directory(a:cd_command, result) | endif
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! zoxide#handle_select_result(cd_command, result) abort
|
||||||
|
if empty(a:result) | return | endif
|
||||||
|
let directory = substitute(a:result, '^\s*\d*\s*', '', '')
|
||||||
|
call s:change_directory(a:cd_command, directory)
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
if has('nvim') && get(g:, 'zoxide_use_select', 0)
|
||||||
|
function! zoxide#zi(cd_command, bang, ...) abort
|
||||||
|
call luaeval('require("zoxide-vim").select(_A[1], _A[2])', [
|
||||||
|
\ zoxide#exec(['query', '--list', '--score'], a:000),
|
||||||
|
\ a:cd_command,
|
||||||
|
\ ])
|
||||||
|
endfunction
|
||||||
|
else
|
||||||
|
let s:default_fzf_options = [
|
||||||
|
\ '--prompt=Zoxide> ',
|
||||||
|
\ '--no-sort',
|
||||||
|
\ '--keep-right',
|
||||||
|
\ '--info=inline',
|
||||||
|
\ '--layout=reverse',
|
||||||
|
\ '--select-1',
|
||||||
|
\ ]
|
||||||
|
if has('unix')
|
||||||
|
let s:default_fzf_options += ['--preview=\command -p ls -p {2..}', '--preview-window=down']
|
||||||
|
endif
|
||||||
|
|
||||||
|
function! zoxide#zi(cd_command, bang, ...) abort
|
||||||
|
if !exists('g:loaded_fzf') | echoerr 'The fzf.vim plugin must be installed' | return | endif
|
||||||
|
|
||||||
|
call fzf#run(fzf#wrap('zoxide', {
|
||||||
|
\ 'source': s:build_cmd(['query', '--list', '--score'], a:000),
|
||||||
|
\ 'sink': funcref('zoxide#handle_select_result', [a:cd_command]),
|
||||||
|
\ 'options': get(g:, 'zoxide_fzf_options', s:default_fzf_options),
|
||||||
|
\ }, a:bang))
|
||||||
|
endfunction
|
||||||
|
endif
|
91
dotfiles/.vim/plugged/zoxide.vim/doc/zoxide-vim.txt
Normal file
91
dotfiles/.vim/plugged/zoxide.vim/doc/zoxide-vim.txt
Normal file
|
@ -0,0 +1,91 @@
|
||||||
|
*zoxide-vim.txt* A small (Neo)Vim wrapper for zoxide
|
||||||
|
|
||||||
|
===============================================================================
|
||||||
|
USAGE *zoxide-vim* *zoxide-vim-usage*
|
||||||
|
|
||||||
|
*:Z*
|
||||||
|
:Z {query} cd to the highest ranked directory matching your query.
|
||||||
|
If {query} is omitted, cd to the home directory.
|
||||||
|
|
||||||
|
*:Lz*
|
||||||
|
:Lz {query} same as :Z but local to the current window.
|
||||||
|
|
||||||
|
*:Tz*
|
||||||
|
:Tz {query} same as :Z but local to the current tab.
|
||||||
|
|
||||||
|
*:Zi*
|
||||||
|
:Zi {query} cd to one of your highest ranking directories using
|
||||||
|
fzf.
|
||||||
|
|
||||||
|
*:Lzi*
|
||||||
|
:Lzi {query} same as :Zi, but local to the current window.
|
||||||
|
|
||||||
|
*:Tzi*
|
||||||
|
:Tzi {query} same as :Zi, but local to the current tab.
|
||||||
|
|
||||||
|
===============================================================================
|
||||||
|
CONFIGURATION *zoxide-vim-configuration*
|
||||||
|
|
||||||
|
*g:zoxide_executable*
|
||||||
|
g:zoxide_executable
|
||||||
|
The name or path of the zoxide executable.
|
||||||
|
|
||||||
|
Default value: `'zoxide'`
|
||||||
|
|
||||||
|
*g:zoxide_prefix*
|
||||||
|
g:zoxide_prefix
|
||||||
|
The prefix to use for commands. Example: >
|
||||||
|
|
||||||
|
let g:zoxide_prefix = 'jump'
|
||||||
|
<
|
||||||
|
Generates the following commands:
|
||||||
|
|
||||||
|
:Jump
|
||||||
|
:Ljump
|
||||||
|
:Tjump
|
||||||
|
:Jumpi
|
||||||
|
:Ljumpi
|
||||||
|
:Tjumpi
|
||||||
|
|
||||||
|
Default value: `'z'`
|
||||||
|
|
||||||
|
*g:zoxide_update_score*
|
||||||
|
g:zoxide_update_score
|
||||||
|
Decides whether the zoxide database should be updated
|
||||||
|
when you execute a :Z-style command.
|
||||||
|
|
||||||
|
Default value: `1`
|
||||||
|
|
||||||
|
*g:zoxide_hook*
|
||||||
|
g:zoxide_hook
|
||||||
|
Automatically increment a directory's score on certain
|
||||||
|
events. Available hooks:
|
||||||
|
- `'none'`: never automatically add directories to
|
||||||
|
zoxide.
|
||||||
|
- `'pwd'`: sets up an autocommand that listens to the
|
||||||
|
|DirChanged| event. Note: on Neovim < `0.6.0`,
|
||||||
|
'autochdir' can cause the event to be triggered very
|
||||||
|
often.
|
||||||
|
|
||||||
|
Default value: `'none'`
|
||||||
|
|
||||||
|
*g:zoxide_use_select*
|
||||||
|
g:zoxide_use_select
|
||||||
|
Use |vim.ui.select()| for :Zi-style commands (Neovim
|
||||||
|
`0.6.0+` only)
|
||||||
|
|
||||||
|
Default value: `0`
|
||||||
|
|
||||||
|
*g:zoxide_fzf_options*
|
||||||
|
g:zoxide_fzf_options
|
||||||
|
Options to pass to fzf during interactive selection.
|
||||||
|
Use this configration if you want to use the same
|
||||||
|
options as `$_ZO_FZF_OPTS`: >
|
||||||
|
|
||||||
|
if exists('$_ZO_FZF_OPTS')
|
||||||
|
let g:zoxide_fzf_options = $_ZO_FZF_OPTS
|
||||||
|
endif
|
||||||
|
<
|
||||||
|
Accepts a string or an array of strings.
|
||||||
|
|
||||||
|
vim:tw=78:ts=8:noet:ft=help:norl:
|
9
dotfiles/.vim/plugged/zoxide.vim/lua/zoxide-vim.lua
Normal file
9
dotfiles/.vim/plugged/zoxide.vim/lua/zoxide-vim.lua
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
local M = {}
|
||||||
|
|
||||||
|
function M.select(items, cd_command)
|
||||||
|
vim.ui.select(items, {prompt = 'Zoxide> '}, function(item)
|
||||||
|
vim.fn["zoxide#handle_select_result"](cd_command, item)
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
return M
|
41
dotfiles/.vim/plugged/zoxide.vim/plugin/zoxide.vim
Normal file
41
dotfiles/.vim/plugged/zoxide.vim/plugin/zoxide.vim
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
if exists('g:loaded_zoxide')
|
||||||
|
finish
|
||||||
|
endif
|
||||||
|
let g:loaded_zoxide = 1
|
||||||
|
|
||||||
|
let s:save_cpo = &cpo
|
||||||
|
set cpo&vim
|
||||||
|
|
||||||
|
let s:z_cmd = substitute(get(g:, 'zoxide_prefix', 'z'), '\A', '', 'g')
|
||||||
|
let s:z_cmd_cap = toupper(s:z_cmd[0]) .. strcharpart(s:z_cmd, 1)
|
||||||
|
|
||||||
|
" Z
|
||||||
|
" Lz
|
||||||
|
" Tz
|
||||||
|
execute 'command! -nargs=* -complete=dir ' .. s:z_cmd_cap .. ' call zoxide#z("cd", <f-args>)'
|
||||||
|
execute 'command! -nargs=* -complete=dir L' .. s:z_cmd .. ' call zoxide#z("lcd", <f-args>)'
|
||||||
|
execute 'command! -nargs=* -complete=dir T' .. s:z_cmd .. ' call zoxide#z("tcd", <f-args>)'
|
||||||
|
|
||||||
|
" Zi
|
||||||
|
" Lzi
|
||||||
|
" Tzi
|
||||||
|
execute 'command! -nargs=* -bang ' .. s:z_cmd_cap .. 'i call zoxide#zi("cd", <bang>0, <f-args>)'
|
||||||
|
execute 'command! -nargs=* -bang L' .. s:z_cmd .. 'i call zoxide#zi("lcd", <bang>0, <f-args>)'
|
||||||
|
execute 'command! -nargs=* -bang T' .. s:z_cmd .. 'i call zoxide#zi("tcd", <bang>0, <f-args>)'
|
||||||
|
|
||||||
|
if get(g:, 'zoxide_hook', 'none') ==# 'pwd'
|
||||||
|
if has('nvim')
|
||||||
|
augroup zoxide_cd
|
||||||
|
autocmd!
|
||||||
|
autocmd DirChanged window,tab,tabpage,global if !v:event['changed_window'] | call zoxide#exec(['add'], [v:event['cwd']]) | endif
|
||||||
|
augroup END
|
||||||
|
else
|
||||||
|
augroup zoxide_cd
|
||||||
|
autocmd!
|
||||||
|
autocmd DirChanged window,tabpage,global call zoxide#exec(['add'], [expand('<afile>')])
|
||||||
|
augroup END
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
let &cpo = s:save_cpo
|
||||||
|
unlet s:save_cpo
|
Loading…
Reference in a new issue