diff options
| -rw-r--r-- | autoload/+init.kak | 6 | ||||
| -rw-r--r-- | autoload/surround.kak | 2 | ||||
| -rwxr-xr-x | scripts/git.clj | 16 |
3 files changed, 21 insertions, 3 deletions
diff --git a/autoload/+init.kak b/autoload/+init.kak index 0fc5183..0bf78d9 100644 --- a/autoload/+init.kak +++ b/autoload/+init.kak @@ -40,3 +40,9 @@ hook global RegisterModified '/' %{ # Highlight search add-highlighter -override global/search regex "%reg{/}" 0:search } + +declare-user-mode selection +map global user z ': enter-user-mode selection<ret>' -docstring 'Selection mode' +# Turn all selections as "next" pattern. Press n to go to next +map global selection f ': exec "%val{selection_count}n"<ret>' -docstring 'Focus selection' + diff --git a/autoload/surround.kak b/autoload/surround.kak index 5c691ef..ae06858 100644 --- a/autoload/surround.kak +++ b/autoload/surround.kak @@ -2,7 +2,7 @@ declare-user-mode surround declare-user-mode surround-append declare-user-mode surround-delete declare-user-mode surround-select -map global user k ': enter-user-mode surround<ret>' +map global user k ': enter-user-mode surround<ret>' -docstring 'Surround mode' map global surround a ': enter-user-mode surround-append<ret>' map global surround s ': enter-user-mode surround-select<ret>' diff --git a/scripts/git.clj b/scripts/git.clj index c1e450b..a721b3a 100755 --- a/scripts/git.clj +++ b/scripts/git.clj @@ -41,7 +41,19 @@ (remove nil?) (str/join "/")))) -(defn git-current-rev [dir] (git dir "rev-parse" "--short" "HEAD")) +(defn git-current-rev [dir] + (let [commit (git dir "rev-parse" "--short" "HEAD")] + (when (not-empty (git dir "branch" "-r" "--contains" commit)) + commit))) + +#_ (todo add branch?) +#_ (defn git-current-branch [dir] ) + +(defn git-base-branch [dir] + (some->> (git dir "rev-parse" "--abbrev-ref" "origin/HEAD") :out + not-empty + (sh "basename") :out + not-empty)) (defn git-remote-url [dir file-path revision line-start line-end] (some-> (or (git-remote-origin dir) (git-first-remote dir)) @@ -54,7 +66,7 @@ (defn cmd-link [[file-path line-start line-end rev]] (let [dir (git-root file-path) - revision (or rev (git-current-rev dir) "main") + revision (or rev (git-current-rev dir) (git-base-branch dir) "main") relative-file-path (str/trim (:out (sh "realpath" "--relative-to" dir file-path))) remote-url (git-remote-url dir relative-file-path revision line-start line-end)] (println remote-url))) |
