1
0
Fork 0

use provides requires

This commit is contained in:
Andrey Orst 2019-05-09 18:12:06 +03:00
parent b924eaaade
commit fcb86e9bed
14 changed files with 55 additions and 21 deletions

View file

@ -8,7 +8,6 @@
# │ different fzf commands. │ # │ different fzf commands. │
# ╰─────────────────────────────────╯ # ╰─────────────────────────────────╯
try %{ declare-user-mode fzf }
# Options # Options
declare-option -docstring 'implementation of fzf that you want to use. declare-option -docstring 'implementation of fzf that you want to use.
@ -73,7 +72,11 @@ fzf-mode contains mnemonic key bindings for every fzf.kak command
Best used with mapping like: Best used with mapping like:
map global normal '<some key>' ': fzf-mode<ret>' map global normal '<some key>' ': fzf-mode<ret>'
" \ " \
fzf-mode %{ try %{ evaluate-commands 'enter-user-mode fzf' } } fzf-mode %{ require-module fzf; evaluate-commands 'enter-user-mode fzf' }
provide-module fzf %§
try %{ declare-user-mode fzf }
define-command -hidden -docstring "wrapper command to create new vertical split" \ define-command -hidden -docstring "wrapper command to create new vertical split" \
fzf-vertical -params .. %{ try %{ fzf-vertical -params .. %{ try %{
@ -230,3 +233,4 @@ fzf -params .. %{ evaluate-commands %sh{
) > /dev/null 2>&1 < /dev/null & ) > /dev/null 2>&1 < /dev/null &
}} }}
§

View file

@ -17,7 +17,8 @@ Default arguments:
" \ " \
str fzf_bzr_command "bzr" str fzf_bzr_command "bzr"
try %{ declare-user-mode fzf-vcs } hook global ModuleLoad fzf_vcs %§
map global fzf-vcs -docstring "edit file from GNU Bazaar tree" 'b' '<esc>: fzf-bzr<ret>' map global fzf-vcs -docstring "edit file from GNU Bazaar tree" 'b' '<esc>: fzf-bzr<ret>'
define-command -hidden fzf-bzr %{ evaluate-commands %sh{ define-command -hidden fzf-bzr %{ evaluate-commands %sh{
@ -33,3 +34,4 @@ define-command -hidden fzf-bzr %{ evaluate-commands %sh{
printf "%s\n" "fzf -kak-cmd %{cd $repo_root; edit -existing} -items-cmd %{$cmd} -fzf-args %{-m --expect ctrl-w $additional_flags} -post-action %{cd $current_path}" printf "%s\n" "fzf -kak-cmd %{cd $repo_root; edit -existing} -items-cmd %{$cmd} -fzf-args %{-m --expect ctrl-w $additional_flags} -post-action %{cd $current_path}"
}} }}
§

View file

@ -17,7 +17,8 @@ Default arguments:
" \ " \
str fzf_git_command "git" str fzf_git_command "git"
try %{ declare-user-mode fzf-vcs } hook global ModuleLoad fzf_vcs %§
map global fzf-vcs -docstring "edit file from Git tree" 'g' '<esc>: fzf-git<ret>' map global fzf-vcs -docstring "edit file from Git tree" 'g' '<esc>: fzf-git<ret>'
define-command -override -hidden fzf-git %{ evaluate-commands %sh{ define-command -override -hidden fzf-git %{ evaluate-commands %sh{
@ -33,3 +34,4 @@ define-command -override -hidden fzf-git %{ evaluate-commands %sh{
printf "%s\n" "fzf -kak-cmd %{cd $repo_root; edit -existing} -items-cmd %{$cmd} -fzf-args %{-m --expect ctrl-w $additional_flags} -post-action %{cd $current_path}" printf "%s\n" "fzf -kak-cmd %{cd $repo_root; edit -existing} -items-cmd %{$cmd} -fzf-args %{-m --expect ctrl-w $additional_flags} -post-action %{cd $current_path}"
}} }}
§

View file

@ -17,7 +17,8 @@ Default arguments:
" \ " \
str fzf_hg_command "hg" str fzf_hg_command "hg"
try %{ declare-user-mode fzf-vcs } hook global ModuleLoad fzf_vcs %§
map global fzf-vcs -docstring "edit file from mercurial tree" 'h' '<esc>: fzf-hg<ret>' map global fzf-vcs -docstring "edit file from mercurial tree" 'h' '<esc>: fzf-hg<ret>'
define-command -hidden fzf-hg %{ evaluate-commands %sh{ define-command -hidden fzf-hg %{ evaluate-commands %sh{
@ -33,3 +34,4 @@ define-command -hidden fzf-hg %{ evaluate-commands %sh{
printf "%s\n" "fzf -kak-cmd %{cd $repo_root; edit -existing} -items-cmd %{$cmd} -fzf-args %{-m --expect ctrl-w $additional_flags} -post-action %{cd $current_path}" printf "%s\n" "fzf -kak-cmd %{cd $repo_root; edit -existing} -items-cmd %{$cmd} -fzf-args %{-m --expect ctrl-w $additional_flags} -post-action %{cd $current_path}"
}} }}
§

View file

@ -17,7 +17,7 @@ Default arguments:
" \ " \
str fzf_svn_command "svn" str fzf_svn_command "svn"
try %{ declare-user-mode fzf-vcs } hook global ModuleLoad fzf_vcs %§
map global fzf-vcs -docstring "edit file from Subversion tree" 's' '<esc>: fzf-svn<ret>' map global fzf-vcs -docstring "edit file from Subversion tree" 's' '<esc>: fzf-svn<ret>'
define-command -hidden fzf-svn %{ evaluate-commands %sh{ define-command -hidden fzf-svn %{ evaluate-commands %sh{
@ -33,3 +33,4 @@ define-command -hidden fzf-svn %{ evaluate-commands %sh{
printf "%s\n" "fzf -kak-cmd %{cd $repo_root; edit -existing} -items-cmd %{$cmd} -fzf-args %{-m --expect ctrl-w $additional_flags} -post-action %{cd $current_path}" printf "%s\n" "fzf -kak-cmd %{cd $repo_root; edit -existing} -items-cmd %{$cmd} -fzf-args %{-m --expect ctrl-w $additional_flags} -post-action %{cd $current_path}"
}} }}
§

View file

@ -8,7 +8,8 @@
# │ GitHub.com/andreyorst/fzf.kak │ # │ GitHub.com/andreyorst/fzf.kak │
# ╰──────────────────────────────────────╯ # ╰──────────────────────────────────────╯
try %{ declare-user-mode fzf } hook global ModuleLoad fzf %§
map global fzf -docstring "open buffer" 'b' '<esc>: fzf-buffer<ret>' map global fzf -docstring "open buffer" 'b' '<esc>: fzf-buffer<ret>'
define-command -hidden fzf-buffer %{ evaluate-commands %sh{ define-command -hidden fzf-buffer %{ evaluate-commands %sh{
@ -30,3 +31,5 @@ define-command -hidden fzf-buffer %{ evaluate-commands %sh{
printf "%s\n" "fzf -kak-cmd %{buffer} -items-cmd %{(cat $buffers; rm $buffers)} -fzf-args %{--expect ctrl-w $additional_flags}" printf "%s\n" "fzf -kak-cmd %{buffer} -items-cmd %{(cat $buffers; rm $buffers)} -fzf-args %{--expect ctrl-w $additional_flags}"
}} }}
§

View file

@ -29,7 +29,8 @@ str cd_preview_cmd "tree -d {}"
declare-option -docstring 'maximum amount of previewed directories' \ declare-option -docstring 'maximum amount of previewed directories' \
int fzf_preview_dirs '300' int fzf_preview_dirs '300'
try %{ declare-user-mode fzf } hook global ModuleLoad fzf %§
map global fzf -docstring "change directory" 'c' '<esc>: fzf-cd<ret>' map global fzf -docstring "change directory" 'c' '<esc>: fzf-cd<ret>'
define-command -hidden fzf-cd %{ evaluate-commands %sh{ define-command -hidden fzf-cd %{ evaluate-commands %sh{
@ -50,3 +51,4 @@ current path: $(pwd)}"
printf "%s\n" "fzf $preview_flag -kak-cmd %{change-directory} -items-cmd %{$items_command} -preview-cmd %{$preview} -post-action %{fzf-cd}" printf "%s\n" "fzf $preview_flag -kak-cmd %{change-directory} -items-cmd %{$items_command} -preview-cmd %{$preview} -post-action %{fzf-cd}"
}} }}
§

View file

@ -11,7 +11,8 @@ declare-option -docstring "file that should be used by fzf-tag to provide tags.
Default value: tags" \ Default value: tags" \
str fzf_tag_file_name "tags" str fzf_tag_file_name "tags"
try %{ declare-user-mode fzf } hook global ModuleLoad fzf %§
map global fzf -docstring "find tag" 't' '<esc>: fzf-tag<ret>' map global fzf -docstring "find tag" 't' '<esc>: fzf-tag<ret>'
# this huge try block defines filetype aware filter mappings for separate fzf-ctags mode # this huge try block defines filetype aware filter mappings for separate fzf-ctags mode
@ -826,3 +827,5 @@ define-command -hidden fzf-tag -params ..2 %{ evaluate-commands %sh{
printf "%s\n" "set-option -add window ctagsfiles %{$path/$kak_opt_fzf_tag_file_name}" printf "%s\n" "set-option -add window ctagsfiles %{$path/$kak_opt_fzf_tag_file_name}"
printf "%s\n" "fzf -kak-cmd %{ctags-search} -items-cmd %{$cmd | awk '!a[\$0]++'} -fzf-args %{--expect ctrl-w $additional_flags}" printf "%s\n" "fzf -kak-cmd %{ctags-search} -items-cmd %{$cmd | awk '!a[\$0]++'} -fzf-args %{--expect ctrl-w $additional_flags}"
}} }}
§

View file

@ -24,7 +24,8 @@ Default arguments:
" \ " \
str fzf_file_command "find" str fzf_file_command "find"
try %{ declare-user-mode fzf } hook global ModuleLoad fzf %§
map global fzf -docstring "open file" 'f' '<esc>: fzf-file<ret>' map global fzf -docstring "open file" 'f' '<esc>: fzf-file<ret>'
define-command -hidden fzf-file %{ evaluate-commands %sh{ define-command -hidden fzf-file %{ evaluate-commands %sh{
@ -62,3 +63,4 @@ define-command -hidden fzf-file %{ evaluate-commands %sh{
printf "%s\n" "fzf -preview -kak-cmd %{edit -existing} -items-cmd %{$cmd} -fzf-args %{-m --expect ctrl-w $additional_flags}" printf "%s\n" "fzf -preview -kak-cmd %{edit -existing} -items-cmd %{$cmd} -fzf-args %{-m --expect ctrl-w $additional_flags}"
}} }}
§

View file

@ -8,10 +8,15 @@
# │ GitHub.com/andreyorst/fzf.kak │ # │ GitHub.com/andreyorst/fzf.kak │
# ╰──────────────────────────────────────╯ # ╰──────────────────────────────────────╯
try %{ declare-user-mode fzf } declare-option -docstring "file where saved projects are stored" str fzf_project_file "%val{config}/.fzf-projects"
declare-option -docstring %sh{ printf "%s\n" "use '~/' instead of '${HOME}'" } bool fzf_project_use_tilda false
hook global ModuleLoad fzf %§
map global fzf -docstring "open project" 'p' '<esc>: fzf-project<ret>' map global fzf -docstring "open project" 'p' '<esc>: fzf-project<ret>'
try %{ declare-user-mode fzf-project } try %{ declare-user-mode fzf-project }
map global fzf -docstring "project menu" '<a-p>' '<esc>: enter-user-mode fzf-project<ret>' map global fzf -docstring "project menu" '<a-p>' '<esc>: enter-user-mode fzf-project<ret>'
map global fzf-project -docstring "save current path as project" 's' '<esc>: fzf-save-path-as-project<ret>' map global fzf-project -docstring "save current path as project" 's' '<esc>: fzf-save-path-as-project<ret>'
map global fzf-project -docstring "save current path as project (use basename)" '<a-s>' '<esc>: fzf-save-path-as-project-no-prompt<ret>' map global fzf-project -docstring "save current path as project (use basename)" '<a-s>' '<esc>: fzf-save-path-as-project-no-prompt<ret>'
@ -19,9 +24,6 @@ map global fzf-project -docstring "update project" 'u' '<esc>: fzf-update-projec
map global fzf-project -docstring "delete project from project list" 'd' '<esc>: fzf-delete-project<ret>' map global fzf-project -docstring "delete project from project list" 'd' '<esc>: fzf-delete-project<ret>'
map global fzf-project -docstring "rename project" 'r' '<esc>: fzf-rename-project<ret>' map global fzf-project -docstring "rename project" 'r' '<esc>: fzf-rename-project<ret>'
declare-option -docstring "file where saved projects are stored" str fzf_project_file "%val{config}/.fzf-projects"
declare-option -docstring %sh{ printf "%s\n" "use '~/' instead of '${HOME}'" } bool fzf_project_use_tilda false
define-command -hidden fzf-project %{ evaluate-commands %sh{ define-command -hidden fzf-project %{ evaluate-commands %sh{
if [ -s ${kak_opt_fzf_project_file} ]; then if [ -s ${kak_opt_fzf_project_file} ]; then
printf '%s\n' "info -title %{fzf open project} %{Change the server's working directory to selected project}" printf '%s\n' "info -title %{fzf open project} %{Change the server's working directory to selected project}"
@ -159,3 +161,4 @@ define-command -hidden fzf-rename-project %{
}} }}
} }
§

View file

@ -8,7 +8,8 @@
# │ GitHub.com/andreyorst/fzf.kak │ # │ GitHub.com/andreyorst/fzf.kak │
# ╰──────────────────────────────────────╯ # ╰──────────────────────────────────────╯
try %{ declare-user-mode fzf } hook global ModuleLoad fzf %§
map global fzf -docstring "search in buffer" 's' '<esc>: fzf-buffer-search<ret>' map global fzf -docstring "search in buffer" 's' '<esc>: fzf-buffer-search<ret>'
define-command -hidden fzf-buffer-search %{ evaluate-commands %sh{ define-command -hidden fzf-buffer-search %{ evaluate-commands %sh{
@ -20,3 +21,4 @@ define-command -hidden fzf-buffer-search %{ evaluate-commands %sh{
printf "%s\n" "fzf -kak-cmd %{execute-keys} -items-cmd %{(nl -b a -n ln $buffer_content; rm $buffer_content)} -fzf-args %{--reverse} -filter %{cut -f 1} -post-action %{execute-keys gx}" printf "%s\n" "fzf -kak-cmd %{execute-keys} -items-cmd %{(nl -b a -n ln $buffer_content; rm $buffer_content)} -fzf-args %{--reverse} -filter %{cut -f 1} -post-action %{execute-keys gx}"
}} }}
§

View file

@ -9,15 +9,20 @@
# │ GitHub.com/andreyorst/fzf.kak │ # │ GitHub.com/andreyorst/fzf.kak │
# ╰──────────────────────────────────────╯ # ╰──────────────────────────────────────╯
try %{ declare-user-mode fzf-vcs } catch %{echo -markup "{Error}Can't declare mode 'fzf-vcs' - already exists"} hook global ModuleLoad fzf %§
try %{ declare-user-mode fzf } map global fzf -docstring "edit file from vcs repo" 'v' '<esc>: require-module fzf_vcs; fzf-vcs<ret>'
map global fzf -docstring "edit file from vcs repo" 'v' '<esc>: fzf-vcs<ret>'
map global fzf -docstring "svitch to vcs selection mode" '<a-v>' '<esc>: fzf-vcs-mode<ret>' map global fzf -docstring "svitch to vcs selection mode" '<a-v>' '<esc>: fzf-vcs-mode<ret>'
define-command -docstring "Enter fzf-vcs-mode. define-command -docstring "Enter fzf-vcs-mode.
This mode allows selecting specific vcs command." \ This mode allows selecting specific vcs command." \
fzf-vcs-mode %{ try %{ evaluate-commands 'enter-user-mode fzf-vcs' } } fzf-vcs-mode %{ require-module fzf_vcs; evaluate-commands 'enter-user-mode fzf-vcs' }
§
provide-module fzf_vcs %§
declare-user-mode fzf-vcs
define-command -hidden -docstring 'Wrapper command for fzf vcs to automatically decect define-command -hidden -docstring 'Wrapper command for fzf vcs to automatically decect
used version control system. used version control system.
@ -55,3 +60,4 @@ bzr status"
printf "%s\n" "echo -markup '{Information}No VCS found in current folder'" printf "%s\n" "echo -markup '{Information}No VCS found in current folder'"
}} }}
§

View file

@ -10,7 +10,7 @@
# │ GitHub.com/alexherbo2/yank-ring.kak │ # │ GitHub.com/alexherbo2/yank-ring.kak │
# ╰─────────────────────────────────────╯ # ╰─────────────────────────────────────╯
try %{ declare-user-mode fzf } hook global ModuleLoad fzf %§
# this will fail if yank-ring.kak isn't installed # this will fail if yank-ring.kak isn't installed
hook global -once WinCreate .* %{ try %{ hook global -once WinCreate .* %{ try %{
@ -35,3 +35,4 @@ define-command -hidden fzf-yank-ring-set-dquote -params 1 %{
set-register dquote %sh{ printf "%s\n" "$1" | sed "s/␤/\n/g" } set-register dquote %sh{ printf "%s\n" "$1" | sed "s/␤/\n/g" }
} }
§

View file

@ -17,7 +17,7 @@ str fzf_sk_grep_command 'grep -RHn'
declare-option -hidden str fzf_sk_first_file '' declare-option -hidden str fzf_sk_first_file ''
try %{ declare-user-mode fzf } hook global ModuleLoad fzf %§
evaluate-commands %sh{ evaluate-commands %sh{
if [ -n "$(command -v sk)" ]; then if [ -n "$(command -v sk)" ]; then
@ -68,3 +68,4 @@ define-command -hidden fzf-sk-populate-grep -params 1 %{
} }
} }
§