1
0
Fork 0

refactor modules to provide submodules

This commit is contained in:
Andrey Listopadov 2021-03-19 21:00:49 +03:00
parent 4e6c9a8575
commit a8436627c3
14 changed files with 116 additions and 166 deletions

View file

@ -1,12 +1,7 @@
# ╭─────────────╥───────────────────╮ # Author: Andrey Listopadov
# │ Author: ║ Plugin: │ # This plugin implements fzf mode for Kakoune.
# │ Andrey Orst ║ fzf.kak │ # This mode adds several mappings to invoke different fzf commands.
# ╞═════════════╩═══════════════════╡ # https://github.com/andreyorst/fzf.kak
# │ This plugin implements fzf │
# │ mode for Kakoune. This mode │
# │ adds several mappings to invoke │
# │ different fzf commands. │
# ╰─────────────────────────────────╯
define-command -docstring "Enter fzf-mode. define-command -docstring "Enter fzf-mode.
fzf-mode contains mnemonic key bindings for every fzf.kak command fzf-mode contains mnemonic key bindings for every fzf.kak command

View file

@ -1,13 +1,12 @@
# ╭─────────────╥─────────────────────────╮ # Author: Andrey Listopadov
# │ Author: ║ File: │ # Submodule for Bzr support for fzf.kak
# │ Andrey Orst ║ fzf-svn.kak │ # https://github.com/andreyorst/fzf.kak
# ╞═════════════╩═════════════════════════╡
# │ Submodule for Bzr support for fzf.kak │
# ╞═══════════════════════════════════════╡
# │ GitHub.com/andreyorst/fzf.kak │
# ╰───────────────────────────────────────╯
hook global ModuleLoaded fzf_vcs %§ hook global ModuleLoaded fzf-vcs %{
map global fzf-vcs -docstring "edit file from GNU Bazaar tree" 'b' '<esc>: require-module fzf-bzr; fzf-bzr<ret>'
}
provide-module fzf-bzr %§
declare-option -docstring "command to provide list of files in GNU Bazaar repository to fzf. Arguments are supported declare-option -docstring "command to provide list of files in GNU Bazaar repository to fzf. Arguments are supported
Supported tools: Supported tools:
@ -19,8 +18,6 @@ Default arguments:
" \ " \
str fzf_bzr_command "bzr" str fzf_bzr_command "bzr"
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{
repo_root=$(bzr root) repo_root=$(bzr root)
case $kak_opt_fzf_bzr_command in case $kak_opt_fzf_bzr_command in

View file

@ -1,13 +1,12 @@
# ╭─────────────╥─────────────────────────╮ # Author: Andrey Listopadov
# │ Author: ║ File: │ # Submodule for Git support for fzf.kak
# │ Andrey Orst ║ fzf-svn.kak │ # https://github.com/andreyorst/fzf.kak
# ╞═════════════╩═════════════════════════╡
# │ Submodule for Git support for fzf.kak │
# ╞═══════════════════════════════════════╡
# │ GitHub.com/andreyorst/fzf.kak │
# ╰───────────────────────────────────────╯
hook global ModuleLoaded fzf_vcs %§ hook global ModuleLoaded fzf-vcs %§
map global fzf-vcs -docstring "edit file from Git tree" 'g' '<esc>: require-module fzf-git; fzf-git<ret>'
§
provide-module fzf-git %§
declare-option -docstring "command to provide list of files in git tree to fzf. Arguments are supported declare-option -docstring "command to provide list of files in git tree to fzf. Arguments are supported
Supported tools: Supported tools:
@ -19,9 +18,7 @@ Default arguments:
" \ " \
str fzf_git_command "git" str fzf_git_command "git"
map global fzf-vcs -docstring "edit file from Git tree" 'g' '<esc>: fzf-git<ret>' define-command -hidden fzf-git %{ evaluate-commands %sh{
define-command -override -hidden fzf-git %{ evaluate-commands %sh{
case $kak_opt_fzf_git_command in case $kak_opt_fzf_git_command in
(git) cmd='git ls-tree --full-tree --name-only -r HEAD' ;; (git) cmd='git ls-tree --full-tree --name-only -r HEAD' ;;

View file

@ -1,13 +1,12 @@
# ╭─────────────╥────────────────────────╮ # Author: Andrey Listopadov
# │ Author: ║ File: │ # Submodule for Hg support for fzf.kak
# │ Andrey Orst ║ fzf-svn.kak │ # https://github.com/andreyorst/fzf.kak
# ╞═════════════╩════════════════════════╡
# │ Submodule for Hg support for fzf.kak │
# ╞══════════════════════════════════════╡
# │ GitHub.com/andreyorst/fzf.kak │
# ╰──────────────────────────────────────╯
hook global ModuleLoaded fzf_vcs %§ hook global ModuleLoaded fzf-vcs %{
map global fzf-vcs -docstring "edit file from mercurial tree" 'h' '<esc>: require-module fzf-hg; fzf-hg<ret>'
}
provide-module fzf-hg %§
declare-option -docstring "command to provide list of files in mercurial repository to fzf. Arguments are supported declare-option -docstring "command to provide list of files in mercurial repository to fzf. Arguments are supported
Supported tools: Supported tools:
@ -19,7 +18,6 @@ Default arguments:
" \ " \
str fzf_hg_command "hg" str fzf_hg_command "hg"
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{
case $kak_opt_fzf_hg_command in case $kak_opt_fzf_hg_command in

View file

@ -1,13 +1,12 @@
# ╭─────────────╥─────────────────────────╮ # Author: Andrey Listopadov
# │ Author: ║ File: │ # Submodule for Svn support for fzf.kak
# │ Andrey Orst ║ fzf-svn.kak │ # https://github.com/andreyorst/fzf.kak
# ╞═════════════╩═════════════════════════╡
# │ Submodule for Svn support for fzf.kak │
# ╞═══════════════════════════════════════╡
# │ GitHub.com/andreyorst/fzf.kak │
# ╰───────────────────────────────────────╯
hook global ModuleLoaded fzf_vcs %§ hook global ModuleLoaded fzf-vcs %§
map global fzf-vcs -docstring "edit file from Subversion tree" 's' '<esc>: require-module fzf-svn; fzf-svn<ret>'
§
provide-module fzf-svn %§
declare-option -docstring "command to provide list of files in svn repository to fzf. Arguments are supported declare-option -docstring "command to provide list of files in svn repository to fzf. Arguments are supported
Supported tools: Supported tools:
@ -19,8 +18,6 @@ Default arguments:
" \ " \
str fzf_svn_command "svn" str fzf_svn_command "svn"
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{
current_path=$(pwd) current_path=$(pwd)
repo_root=$(svn info | awk -F': ' '/Working Copy Root Path: .*/ {print $2}') repo_root=$(svn info | awk -F': ' '/Working Copy Root Path: .*/ {print $2}')

View file

@ -1,17 +1,13 @@
# ╭─────────────╥────────────────────────╮ # Author: Andrey Listopadov
# │ Author: ║ File: │ # Module for changing buffers with fzf for fzf.kak plugin
# │ Andrey Orst ║ fzf-buffer.kak │ # https://github.com/andreyorst/fzf.kak
# ╞═════════════╩════════════════════════╡
# │ Module for changing buffers with fzf │
# │ for fzf.kak plugin │
# ╞══════════════════════════════════════╡
# │ GitHub.com/andreyorst/fzf.kak │
# ╰──────────────────────────────────────╯
hook global ModuleLoaded fzf %§ hook global ModuleLoaded fzf %{
map global fzf -docstring "open buffer" 'b' '<esc>: require-module fzf-buffer; fzf-buffer<ret>'
map global fzf -docstring "delete buffer" '<a-b>' '<esc>: require-module fzf-buffer; fzf-delete-buffer<ret>'
}
map global fzf -docstring "open buffer" 'b' '<esc>: fzf-buffer<ret>' provide-module fzf-buffer %§
map global fzf -docstring "delete buffer" '<a-b>' '<esc>: fzf-delete-buffer<ret>'
define-command -hidden fzf-buffer %{ evaluate-commands %sh{ define-command -hidden fzf-buffer %{ evaluate-commands %sh{
buffers="" buffers=""

View file

@ -1,14 +1,12 @@
# ╭─────────────╥────────────────────────╮ # Author: Andrey Listopadov
# │ Author: ║ File: │ # Module for changing directories with fzf for fzf.kak plugin
# │ Andrey Orst ║ fzf-cd.kak │ # https://github.com/andreyorst/fzf.kak
# ╞═════════════╩════════════════════════╡
# │ Module for changing directories with │
# │ fzf for fzf.kak plugin │
# ╞══════════════════════════════════════╡
# │ GitHub.com/andreyorst/fzf.kak │
# ╰──────────────────────────────────────╯
hook global ModuleLoaded fzf %§ hook global ModuleLoaded fzf %{
map global fzf -docstring "change directory" 'c' '<esc>: require-module fzf-cd; fzf-cd<ret>'
}
provide-module fzf-cd %§
declare-option -docstring "command to provide list of directories to fzf. declare-option -docstring "command to provide list of directories to fzf.
Default value: Default value:
@ -31,9 +29,6 @@ str cd_preview_command "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'
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{
tmux_height=$kak_opt_fzf_tmux_height tmux_height=$kak_opt_fzf_tmux_height
printf '%s\n' "info -title %{fzf change directory} %{Change the server's working directory printf '%s\n' "info -title %{fzf change directory} %{Change the server's working directory

View file

@ -1,20 +1,17 @@
# ╭─────────────╥──────────────────────────╮ # Author: Andrey Listopadov
# │ Author: ║ File: │ # Module for searching tags with fzf and universal-ctags for fzf.kak plugin
# │ Andrey Orst ║ fzf-ctags.kak │ # https://github.com/andreyorst/fzf.kak
# ╞═════════════╩══════════════════════════╡
# │ Module for searching tags with fzf │
# │ and universal-ctags for fzf.kak plugin │
# ╞════════════════════════════════════════╡
# │ GitHub.com/andreyorst/fzf.kak │
# ╰────────────────────────────────────────╯
hook global ModuleLoaded fzf %§ hook global ModuleLoaded fzf %{
map global fzf -docstring "find tag" 't' '<esc>: require-module fzf-ctags; fzf-tag<ret>'
}
provide-module fzf-ctags %§
declare-option -docstring "file that should be used by fzf-tag to provide tags. 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"
map global fzf -docstring "find tag" 't' '<esc>: fzf-tag<ret>'
declare-option -hidden bool fzf_tag_filters_defined false declare-option -hidden bool fzf_tag_filters_defined false

View file

@ -1,14 +1,12 @@
# ╭─────────────╥────────────────────────╮ # Author: Andrey Listopadov
# │ Author: ║ File: │ # Module for opening files with fzf for fzf.kak plugin
# │ Andrey Orst ║ fzf-file.kak │ # https://github.com/andreyorst/fzf.kak
# ╞═════════════╩════════════════════════╡
# │ Module for opening files with fzf │
# │ for fzf.kak plugin │
# ╞══════════════════════════════════════╡
# │ GitHub.com/andreyorst/fzf.kak │
# ╰──────────────────────────────────────╯
hook global ModuleLoaded fzf %§ hook global ModuleLoaded fzf %{
map global fzf -docstring "open file" 'f' '<esc>: require-module fzf-file; fzf-file<ret>'
}
provide-module fzf-file %§
declare-option -docstring "command to provide list of files to fzf. Arguments are supported declare-option -docstring "command to provide list of files to fzf. Arguments are supported
Supported tools: Supported tools:
@ -32,7 +30,6 @@ Default value:
' \ ' \
bool fzf_file_preview true bool fzf_file_preview true
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{
if [ -z "$(command -v $kak_opt_fzf_file_command)" ]; then if [ -z "$(command -v $kak_opt_fzf_file_command)" ]; then

View file

@ -1,13 +1,12 @@
# ╭─────────────╥────────────────────────╮ # Author: Andrey Listopadov
# │ Author: ║ File: │ # Module for grepping file contents
# │ Andrey Orst ║ fzf-grep.kak │ # https://github.com/andreyorst/fzf.kak
# ╞═════════════╩════════════════════════╡
# │ Module for grepping file contents │
# ╞══════════════════════════════════════╡
# │ GitHub.com/andreyorst/fzf.kak │
# ╰──────────────────────────────────────╯
hook global ModuleLoaded fzf %§ hook global ModuleLoaded fzf %{
map -docstring 'grep file contents recursively' global fzf g ': require-module fzf-grep; fzf-grep<ret>'
}
provide-module fzf-grep %§
declare-option -docstring "what command to use to provide list of grep search matches. declare-option -docstring "what command to use to provide list of grep search matches.
Grep output must follow the format of 'filename:line-number:text' Grep output must follow the format of 'filename:line-number:text'
@ -16,7 +15,6 @@ Default value:
grep -RHn" \ grep -RHn" \
str fzf_grep_command 'grep' str fzf_grep_command 'grep'
map -docstring 'grep file contents recursively' global fzf g ': fzf-grep<ret>'
define-command -hidden fzf-grep %{ evaluate-commands %sh{ define-command -hidden fzf-grep %{ evaluate-commands %sh{
if [ -z "$(command -v $kak_opt_fzf_grep_command)" ]; then if [ -z "$(command -v $kak_opt_fzf_grep_command)" ]; then

View file

@ -1,19 +1,18 @@
# ╭─────────────╥────────────────────────╮ # Author: Andrey Listopadov
# │ Author: ║ File: │ # Module for storing and loading projects with fzf for fzf.kak plugin
# │ Andrey Orst ║ fzf-project.kak │ # https://github.com/andreyorst/fzf.kak
# ╞═════════════╩════════════════════════╡
# │ Module for storing and loading │
# │ projects with fzf for fzf.kak plugin │
# ╞══════════════════════════════════════╡
# │ GitHub.com/andreyorst/fzf.kak │
# ╰──────────────────────────────────────╯
hook global ModuleLoaded fzf %§ hook global ModuleLoaded fzf %{
map global fzf -docstring "open project" 'p' '<esc>: require-module fzf-project; fzf-project<ret>'
}
provide-module fzf-project %§
require-module fzf-file
declare-option -docstring "file where saved projects are stored" str fzf_project_file "%val{config}/.fzf-projects" 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 declare-option -docstring %sh{ printf "%s\n" "use '~/' instead of '${HOME}'" } bool fzf_project_use_tilda false
map global fzf -docstring "open project" 'p' '<esc>: fzf-project<ret>'
try %{ declare-user-mode fzf-project } try %{ declare-user-mode fzf-project }

View file

@ -1,16 +1,12 @@
# ╭─────────────╥────────────────────────╮ # Author: Andrey Listopadov
# │ Author: ║ File: │ # Module for searching inside current buffer with fzf for fzf.kak
# │ Andrey Orst ║ fzf-search.kak │ # https://github.com/andreyorst/fzf.kak
# ╞═════════════╩════════════════════════╡
# │ Module for searching inside current │
# │ buffer with fzf for fzf.kak │
# ╞══════════════════════════════════════╡
# │ GitHub.com/andreyorst/fzf.kak │
# ╰──────────────────────────────────────╯
hook global ModuleLoaded fzf %§ hook global ModuleLoaded fzf %{
map global fzf -docstring "search in buffer" 's' '<esc>: require-module fzf-search; fzf-buffer-search<ret>'
}
map global fzf -docstring "search in buffer" 's' '<esc>: fzf-buffer-search<ret>' provide-module fzf-search %§
define-command -hidden fzf-buffer-search %{ evaluate-commands %sh{ define-command -hidden fzf-buffer-search %{ evaluate-commands %sh{
title="fzf buffer search" title="fzf buffer search"

View file

@ -1,26 +1,18 @@
# ╭─────────────╥────────────────────────╮ # Author: Andrey Listopadov
# │ Author: ║ File: │ # Module that declares VCS submodule for various version control systems to open files with fzf
# │ Andrey Orst ║ fzf-vcs.kak │ # https://github.com/andreyorst/fzf.kak
# ╞═════════════╩════════════════════════╡
# │ Module that declares VCS submodule │
# │ for various version control systems │
# │ to open files with fzf │
# ╞══════════════════════════════════════╡
# │ GitHub.com/andreyorst/fzf.kak │
# ╰──────────────────────────────────────╯
hook global ModuleLoaded fzf %§ hook global ModuleLoaded 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>: require-module fzf_vcs; fzf-vcs<ret>' map global fzf -docstring "switch to vcs selection mode" '<a-v>' '<esc>: require-module fzf-vcs; enter-user-mode fzf-vcs<ret>'
map global fzf -docstring "switch to vcs selection mode" '<a-v>' '<esc>: fzf-vcs-mode<ret>'
define-command -docstring "Enter fzf-vcs-mode.
This mode allows selecting specific vcs command." \
fzf-vcs-mode %{ require-module fzf_vcs; evaluate-commands 'enter-user-mode fzf-vcs' }
§ §
provide-module fzf_vcs %§ provide-module fzf-vcs %§
require-module fzf-git
require-module fzf-svn
require-module fzf-hg
require-module fzf-bzr
declare-user-mode fzf-vcs declare-user-mode fzf-vcs

View file

@ -1,14 +1,16 @@
# ╭─────────────╥────────────────────────╮ # Author: Andrey Listopadov
# │ Author: ║ File: │ # Module running interactive grep with skim for fzf.kak
# │ Andrey Orst ║ sk-grep.kak │ # https://github.com/andreyorst/fzf.kak
# ╞═════════════╩════════════════════════╡
# │ Module running interactive grep with │
# │ ski for fzf.kak │
# ╞══════════════════════════════════════╡
# │ GitHub.com/andreyorst/fzf.kak │
# ╰──────────────────────────────────────╯
hook global ModuleLoaded fzf %§ hook global ModuleLoaded fzf %§
evaluate-commands %sh{
if [ -n "$(command -v sk)" ]; then
printf "%s\n" "map global fzf -docstring %{Interactive grep with skim} '<a-g>' '<esc>: require-module fzf-sk-grep; fzf-sk-grep<ret>'"
fi
}
§
provide-module fzf-sk-grep %§
declare-option -docstring "what command to use to provide list of grep search matches. declare-option -docstring "what command to use to provide list of grep search matches.
Grep output must follow the format of 'filename:line-number:text' Grep output must follow the format of 'filename:line-number:text'
@ -19,12 +21,6 @@ str fzf_sk_grep_command 'grep -RHn'
declare-option -hidden str fzf_sk_first_file '' declare-option -hidden str fzf_sk_first_file ''
evaluate-commands %sh{
if [ -n "$(command -v sk)" ]; then
printf "%s\n" "map global fzf -docstring %{Interactive grep with skim} '<a-g>' '<esc>: fzf-sk-grep<ret>'"
fi
}
define-command -hidden fzf-sk-grep %{ evaluate-commands %sh{ define-command -hidden fzf-sk-grep %{ evaluate-commands %sh{
if [ -z "$(command -v sk)" ]; then if [ -z "$(command -v sk)" ]; then
printf "%s\n" "echo -markup %{{Information}skim required to run this command}" printf "%s\n" "echo -markup %{{Information}skim required to run this command}"