From a8436627c3157bd105258d57266c7f7281e17705 Mon Sep 17 00:00:00 2001 From: Andrey Listopadov Date: Fri, 19 Mar 2021 21:00:49 +0300 Subject: [PATCH] refactor modules to provide submodules --- rc/fzf.kak | 13 ++++--------- rc/modules/VCS/fzf-bzr.kak | 19 ++++++++----------- rc/modules/VCS/fzf-git.kak | 21 +++++++++------------ rc/modules/VCS/fzf-hg.kak | 18 ++++++++---------- rc/modules/VCS/fzf-svn.kak | 19 ++++++++----------- rc/modules/fzf-buffer.kak | 20 ++++++++------------ rc/modules/fzf-cd.kak | 21 ++++++++------------- rc/modules/fzf-ctags.kak | 19 ++++++++----------- rc/modules/fzf-file.kak | 19 ++++++++----------- rc/modules/fzf-grep.kak | 18 ++++++++---------- rc/modules/fzf-project.kak | 21 ++++++++++----------- rc/modules/fzf-search.kak | 18 +++++++----------- rc/modules/fzf-vcs.kak | 30 +++++++++++------------------- rc/modules/sk-grep.kak | 26 +++++++++++--------------- 14 files changed, 116 insertions(+), 166 deletions(-) diff --git a/rc/fzf.kak b/rc/fzf.kak index 7bff9df..7c2811a 100644 --- a/rc/fzf.kak +++ b/rc/fzf.kak @@ -1,12 +1,7 @@ -# ╭─────────────╥───────────────────╮ -# │ Author: ║ Plugin: │ -# │ Andrey Orst ║ fzf.kak │ -# ╞═════════════╩═══════════════════╡ -# │ This plugin implements fzf │ -# │ mode for Kakoune. This mode │ -# │ adds several mappings to invoke │ -# │ different fzf commands. │ -# ╰─────────────────────────────────╯ +# Author: Andrey Listopadov +# This plugin implements fzf mode for Kakoune. +# This mode adds several mappings to invoke different fzf commands. +# https://github.com/andreyorst/fzf.kak define-command -docstring "Enter fzf-mode. fzf-mode contains mnemonic key bindings for every fzf.kak command diff --git a/rc/modules/VCS/fzf-bzr.kak b/rc/modules/VCS/fzf-bzr.kak index e0f27a2..cdd10f8 100644 --- a/rc/modules/VCS/fzf-bzr.kak +++ b/rc/modules/VCS/fzf-bzr.kak @@ -1,13 +1,12 @@ -# ╭─────────────╥─────────────────────────╮ -# │ Author: ║ File: │ -# │ Andrey Orst ║ fzf-svn.kak │ -# ╞═════════════╩═════════════════════════╡ -# │ Submodule for Bzr support for fzf.kak │ -# ╞═══════════════════════════════════════╡ -# │ GitHub.com/andreyorst/fzf.kak │ -# ╰───────────────────────────────────────╯ +# Author: Andrey Listopadov +# Submodule for Bzr support for fzf.kak +# https://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' ': require-module fzf-bzr; fzf-bzr' +} + +provide-module fzf-bzr %§ declare-option -docstring "command to provide list of files in GNU Bazaar repository to fzf. Arguments are supported Supported tools: @@ -19,8 +18,6 @@ Default arguments: " \ str fzf_bzr_command "bzr" -map global fzf-vcs -docstring "edit file from GNU Bazaar tree" 'b' ': fzf-bzr' - define-command -hidden fzf-bzr %{ evaluate-commands %sh{ repo_root=$(bzr root) case $kak_opt_fzf_bzr_command in diff --git a/rc/modules/VCS/fzf-git.kak b/rc/modules/VCS/fzf-git.kak index 117f184..d1e878b 100644 --- a/rc/modules/VCS/fzf-git.kak +++ b/rc/modules/VCS/fzf-git.kak @@ -1,13 +1,12 @@ -# ╭─────────────╥─────────────────────────╮ -# │ Author: ║ File: │ -# │ Andrey Orst ║ fzf-svn.kak │ -# ╞═════════════╩═════════════════════════╡ -# │ Submodule for Git support for fzf.kak │ -# ╞═══════════════════════════════════════╡ -# │ GitHub.com/andreyorst/fzf.kak │ -# ╰───────────────────────────────────────╯ +# Author: Andrey Listopadov +# Submodule for Git support for fzf.kak +# https://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' ': require-module fzf-git; fzf-git' +§ + +provide-module fzf-git %§ declare-option -docstring "command to provide list of files in git tree to fzf. Arguments are supported Supported tools: @@ -19,9 +18,7 @@ Default arguments: " \ str fzf_git_command "git" -map global fzf-vcs -docstring "edit file from Git tree" 'g' ': fzf-git' - -define-command -override -hidden fzf-git %{ evaluate-commands %sh{ +define-command -hidden fzf-git %{ evaluate-commands %sh{ case $kak_opt_fzf_git_command in (git) cmd='git ls-tree --full-tree --name-only -r HEAD' ;; diff --git a/rc/modules/VCS/fzf-hg.kak b/rc/modules/VCS/fzf-hg.kak index 743e0af..9ce5e9c 100644 --- a/rc/modules/VCS/fzf-hg.kak +++ b/rc/modules/VCS/fzf-hg.kak @@ -1,13 +1,12 @@ -# ╭─────────────╥────────────────────────╮ -# │ Author: ║ File: │ -# │ Andrey Orst ║ fzf-svn.kak │ -# ╞═════════════╩════════════════════════╡ -# │ Submodule for Hg support for fzf.kak │ -# ╞══════════════════════════════════════╡ -# │ GitHub.com/andreyorst/fzf.kak │ -# ╰──────────────────────────────────────╯ +# Author: Andrey Listopadov +# Submodule for Hg support for fzf.kak +# https://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' ': require-module fzf-hg; fzf-hg' +} + +provide-module fzf-hg %§ declare-option -docstring "command to provide list of files in mercurial repository to fzf. Arguments are supported Supported tools: @@ -19,7 +18,6 @@ Default arguments: " \ str fzf_hg_command "hg" -map global fzf-vcs -docstring "edit file from mercurial tree" 'h' ': fzf-hg' define-command -hidden fzf-hg %{ evaluate-commands %sh{ case $kak_opt_fzf_hg_command in diff --git a/rc/modules/VCS/fzf-svn.kak b/rc/modules/VCS/fzf-svn.kak index 0792773..01812a1 100644 --- a/rc/modules/VCS/fzf-svn.kak +++ b/rc/modules/VCS/fzf-svn.kak @@ -1,13 +1,12 @@ -# ╭─────────────╥─────────────────────────╮ -# │ Author: ║ File: │ -# │ Andrey Orst ║ fzf-svn.kak │ -# ╞═════════════╩═════════════════════════╡ -# │ Submodule for Svn support for fzf.kak │ -# ╞═══════════════════════════════════════╡ -# │ GitHub.com/andreyorst/fzf.kak │ -# ╰───────────────────────────────────────╯ +# Author: Andrey Listopadov +# Submodule for Svn support for fzf.kak +# https://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' ': require-module fzf-svn; fzf-svn' +§ + +provide-module fzf-svn %§ declare-option -docstring "command to provide list of files in svn repository to fzf. Arguments are supported Supported tools: @@ -19,8 +18,6 @@ Default arguments: " \ str fzf_svn_command "svn" -map global fzf-vcs -docstring "edit file from Subversion tree" 's' ': fzf-svn' - define-command -hidden fzf-svn %{ evaluate-commands %sh{ current_path=$(pwd) repo_root=$(svn info | awk -F': ' '/Working Copy Root Path: .*/ {print $2}') diff --git a/rc/modules/fzf-buffer.kak b/rc/modules/fzf-buffer.kak index 4c34d78..7de2205 100644 --- a/rc/modules/fzf-buffer.kak +++ b/rc/modules/fzf-buffer.kak @@ -1,17 +1,13 @@ -# ╭─────────────╥────────────────────────╮ -# │ Author: ║ File: │ -# │ Andrey Orst ║ fzf-buffer.kak │ -# ╞═════════════╩════════════════════════╡ -# │ Module for changing buffers with fzf │ -# │ for fzf.kak plugin │ -# ╞══════════════════════════════════════╡ -# │ GitHub.com/andreyorst/fzf.kak │ -# ╰──────────────────────────────────────╯ +# Author: Andrey Listopadov +# Module for changing buffers with fzf for fzf.kak plugin +# https://github.com/andreyorst/fzf.kak -hook global ModuleLoaded fzf %§ +hook global ModuleLoaded fzf %{ + map global fzf -docstring "open buffer" 'b' ': require-module fzf-buffer; fzf-buffer' + map global fzf -docstring "delete buffer" '' ': require-module fzf-buffer; fzf-delete-buffer' +} -map global fzf -docstring "open buffer" 'b' ': fzf-buffer' -map global fzf -docstring "delete buffer" '' ': fzf-delete-buffer' +provide-module fzf-buffer %§ define-command -hidden fzf-buffer %{ evaluate-commands %sh{ buffers="" diff --git a/rc/modules/fzf-cd.kak b/rc/modules/fzf-cd.kak index fb19ade..f4917ec 100644 --- a/rc/modules/fzf-cd.kak +++ b/rc/modules/fzf-cd.kak @@ -1,14 +1,12 @@ -# ╭─────────────╥────────────────────────╮ -# │ Author: ║ File: │ -# │ Andrey Orst ║ fzf-cd.kak │ -# ╞═════════════╩════════════════════════╡ -# │ Module for changing directories with │ -# │ fzf for fzf.kak plugin │ -# ╞══════════════════════════════════════╡ -# │ GitHub.com/andreyorst/fzf.kak │ -# ╰──────────────────────────────────────╯ +# Author: Andrey Listopadov +# Module for changing directories with fzf for fzf.kak plugin +# https://github.com/andreyorst/fzf.kak -hook global ModuleLoaded fzf %§ +hook global ModuleLoaded fzf %{ + map global fzf -docstring "change directory" 'c' ': require-module fzf-cd; fzf-cd' +} + +provide-module fzf-cd %§ declare-option -docstring "command to provide list of directories to fzf. Default value: @@ -31,9 +29,6 @@ str cd_preview_command "tree -d {}" declare-option -docstring 'maximum amount of previewed directories' \ int fzf_preview_dirs '300' - -map global fzf -docstring "change directory" 'c' ': fzf-cd' - define-command -hidden fzf-cd %{ evaluate-commands %sh{ tmux_height=$kak_opt_fzf_tmux_height printf '%s\n' "info -title %{fzf change directory} %{Change the server's working directory diff --git a/rc/modules/fzf-ctags.kak b/rc/modules/fzf-ctags.kak index 5ce7614..9f4e872 100644 --- a/rc/modules/fzf-ctags.kak +++ b/rc/modules/fzf-ctags.kak @@ -1,20 +1,17 @@ -# ╭─────────────╥──────────────────────────╮ -# │ Author: ║ File: │ -# │ Andrey Orst ║ fzf-ctags.kak │ -# ╞═════════════╩══════════════════════════╡ -# │ Module for searching tags with fzf │ -# │ and universal-ctags for fzf.kak plugin │ -# ╞════════════════════════════════════════╡ -# │ GitHub.com/andreyorst/fzf.kak │ -# ╰────────────────────────────────────────╯ +# Author: Andrey Listopadov +# Module for searching tags with fzf and universal-ctags for fzf.kak plugin +# https://github.com/andreyorst/fzf.kak -hook global ModuleLoaded fzf %§ +hook global ModuleLoaded fzf %{ + map global fzf -docstring "find tag" 't' ': require-module fzf-ctags; fzf-tag' +} + +provide-module fzf-ctags %§ declare-option -docstring "file that should be used by fzf-tag to provide tags. Default value: tags" \ str fzf_tag_file_name "tags" -map global fzf -docstring "find tag" 't' ': fzf-tag' declare-option -hidden bool fzf_tag_filters_defined false diff --git a/rc/modules/fzf-file.kak b/rc/modules/fzf-file.kak index 479a496..a3ea14d 100644 --- a/rc/modules/fzf-file.kak +++ b/rc/modules/fzf-file.kak @@ -1,14 +1,12 @@ -# ╭─────────────╥────────────────────────╮ -# │ Author: ║ File: │ -# │ Andrey Orst ║ fzf-file.kak │ -# ╞═════════════╩════════════════════════╡ -# │ Module for opening files with fzf │ -# │ for fzf.kak plugin │ -# ╞══════════════════════════════════════╡ -# │ GitHub.com/andreyorst/fzf.kak │ -# ╰──────────────────────────────────────╯ +# Author: Andrey Listopadov +# Module for opening files with fzf for fzf.kak plugin +# https://github.com/andreyorst/fzf.kak -hook global ModuleLoaded fzf %§ +hook global ModuleLoaded fzf %{ + map global fzf -docstring "open file" 'f' ': require-module fzf-file; fzf-file' +} + +provide-module fzf-file %§ declare-option -docstring "command to provide list of files to fzf. Arguments are supported Supported tools: @@ -32,7 +30,6 @@ Default value: ' \ bool fzf_file_preview true -map global fzf -docstring "open file" 'f' ': fzf-file' define-command -hidden fzf-file %{ evaluate-commands %sh{ if [ -z "$(command -v $kak_opt_fzf_file_command)" ]; then diff --git a/rc/modules/fzf-grep.kak b/rc/modules/fzf-grep.kak index 10c4e3c..936edef 100644 --- a/rc/modules/fzf-grep.kak +++ b/rc/modules/fzf-grep.kak @@ -1,13 +1,12 @@ -# ╭─────────────╥────────────────────────╮ -# │ Author: ║ File: │ -# │ Andrey Orst ║ fzf-grep.kak │ -# ╞═════════════╩════════════════════════╡ -# │ Module for grepping file contents │ -# ╞══════════════════════════════════════╡ -# │ GitHub.com/andreyorst/fzf.kak │ -# ╰──────────────────────────────────────╯ +# Author: Andrey Listopadov +# Module for grepping file contents +# https://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' +} + +provide-module fzf-grep %§ 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' @@ -16,7 +15,6 @@ Default value: grep -RHn" \ str fzf_grep_command 'grep' -map -docstring 'grep file contents recursively' global fzf g ': fzf-grep' define-command -hidden fzf-grep %{ evaluate-commands %sh{ if [ -z "$(command -v $kak_opt_fzf_grep_command)" ]; then diff --git a/rc/modules/fzf-project.kak b/rc/modules/fzf-project.kak index d4fc3bf..4255eaa 100644 --- a/rc/modules/fzf-project.kak +++ b/rc/modules/fzf-project.kak @@ -1,19 +1,18 @@ -# ╭─────────────╥────────────────────────╮ -# │ Author: ║ File: │ -# │ Andrey Orst ║ fzf-project.kak │ -# ╞═════════════╩════════════════════════╡ -# │ Module for storing and loading │ -# │ projects with fzf for fzf.kak plugin │ -# ╞══════════════════════════════════════╡ -# │ GitHub.com/andreyorst/fzf.kak │ -# ╰──────────────────────────────────────╯ +# Author: Andrey Listopadov +# Module for storing and loading projects with fzf for fzf.kak plugin +# https://github.com/andreyorst/fzf.kak -hook global ModuleLoaded fzf %§ +hook global ModuleLoaded fzf %{ + map global fzf -docstring "open project" 'p' ': require-module fzf-project; fzf-project' +} + +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 %sh{ printf "%s\n" "use '~/' instead of '${HOME}'" } bool fzf_project_use_tilda false -map global fzf -docstring "open project" 'p' ': fzf-project' try %{ declare-user-mode fzf-project } diff --git a/rc/modules/fzf-search.kak b/rc/modules/fzf-search.kak index 961de83..5ce23b2 100644 --- a/rc/modules/fzf-search.kak +++ b/rc/modules/fzf-search.kak @@ -1,16 +1,12 @@ -# ╭─────────────╥────────────────────────╮ -# │ Author: ║ File: │ -# │ Andrey Orst ║ fzf-search.kak │ -# ╞═════════════╩════════════════════════╡ -# │ Module for searching inside current │ -# │ buffer with fzf for fzf.kak │ -# ╞══════════════════════════════════════╡ -# │ GitHub.com/andreyorst/fzf.kak │ -# ╰──────────────────────────────────────╯ +# Author: Andrey Listopadov +# Module for searching inside current buffer with fzf for fzf.kak +# https://github.com/andreyorst/fzf.kak -hook global ModuleLoaded fzf %§ +hook global ModuleLoaded fzf %{ + map global fzf -docstring "search in buffer" 's' ': require-module fzf-search; fzf-buffer-search' +} -map global fzf -docstring "search in buffer" 's' ': fzf-buffer-search' +provide-module fzf-search %§ define-command -hidden fzf-buffer-search %{ evaluate-commands %sh{ title="fzf buffer search" diff --git a/rc/modules/fzf-vcs.kak b/rc/modules/fzf-vcs.kak index 58d4033..242413f 100644 --- a/rc/modules/fzf-vcs.kak +++ b/rc/modules/fzf-vcs.kak @@ -1,26 +1,18 @@ -# ╭─────────────╥────────────────────────╮ -# │ Author: ║ File: │ -# │ Andrey Orst ║ fzf-vcs.kak │ -# ╞═════════════╩════════════════════════╡ -# │ Module that declares VCS submodule │ -# │ for various version control systems │ -# │ to open files with fzf │ -# ╞══════════════════════════════════════╡ -# │ GitHub.com/andreyorst/fzf.kak │ -# ╰──────────────────────────────────────╯ +# Author: Andrey Listopadov +# Module that declares VCS submodule for various version control systems to open files with fzf +# https://github.com/andreyorst/fzf.kak hook global ModuleLoaded fzf %§ - -map global fzf -docstring "edit file from vcs repo" 'v' ': require-module fzf_vcs; fzf-vcs' -map global fzf -docstring "switch to vcs selection mode" '' ': fzf-vcs-mode' - -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' } - + map global fzf -docstring "edit file from vcs repo" 'v' ': require-module fzf-vcs; fzf-vcs' + map global fzf -docstring "switch to vcs selection mode" '' ': require-module fzf-vcs; 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 diff --git a/rc/modules/sk-grep.kak b/rc/modules/sk-grep.kak index ee21975..72a4dcd 100644 --- a/rc/modules/sk-grep.kak +++ b/rc/modules/sk-grep.kak @@ -1,14 +1,16 @@ -# ╭─────────────╥────────────────────────╮ -# │ Author: ║ File: │ -# │ Andrey Orst ║ sk-grep.kak │ -# ╞═════════════╩════════════════════════╡ -# │ Module running interactive grep with │ -# │ ski for fzf.kak │ -# ╞══════════════════════════════════════╡ -# │ GitHub.com/andreyorst/fzf.kak │ -# ╰──────────────────────────────────────╯ +# Author: Andrey Listopadov +# Module running interactive grep with skim for fzf.kak +# https://github.com/andreyorst/fzf.kak hook global ModuleLoaded fzf %§ + evaluate-commands %sh{ + if [ -n "$(command -v sk)" ]; then + printf "%s\n" "map global fzf -docstring %{Interactive grep with skim} '' ': require-module fzf-sk-grep; fzf-sk-grep'" + fi + } +§ + +provide-module fzf-sk-grep %§ 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' @@ -19,12 +21,6 @@ str fzf_sk_grep_command 'grep -RHn' 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} '' ': fzf-sk-grep'" - fi -} - define-command -hidden fzf-sk-grep %{ evaluate-commands %sh{ if [ -z "$(command -v sk)" ]; then printf "%s\n" "echo -markup %{{Information}skim required to run this command}"