kakoune: file and project symbols: support spaces in first token (example css)
uses non-breaking space as a separator and assumes that first numeric token (starting from second one) is the line number (i.e., assumes that the searched token does not contain space delimited number)
This commit is contained in:
@@ -136,17 +136,17 @@ define-command -override git-hide-diff %{
|
|||||||
|
|
||||||
define-command -override ctags-file-symbols %{
|
define-command -override ctags-file-symbols %{
|
||||||
prompt -menu -shell-script-candidates %{
|
prompt -menu -shell-script-candidates %{
|
||||||
ctags -uo - -x "$kak_buffile" | awk '{ print $1, $2, $3 }'
|
ctags -uo - -x "$kak_buffile" | awk -f "$kak_config/scripts/filesymbols.awk"
|
||||||
} 'File symbols: ' %{
|
} 'File symbols: ' %{
|
||||||
evaluate-commands %sh{ printf '%s\n' "$kak_text" | awk '{ print "execute-keys", $3, "g", "/\\b" $1 "\\b<ret>" }' }
|
evaluate-commands %sh{ awk -f "$kak_config/scripts/filesymbolscmd.awk" # "$kak_text" }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
define-command -override ctags-project-symbols %{
|
define-command -override ctags-project-symbols %{
|
||||||
prompt -menu -shell-script-candidates %{
|
prompt -menu -shell-script-candidates %{
|
||||||
git ls-files | xargs wc | awk '$1 > 0 && $3/$1 < 1024 { print $4 }' | xargs ctags -uo - -x | awk '{ print $1, $2, $3, $4 }'
|
git ls-files | xargs wc | awk '$1 > 0 && $3/$1 < 1024 { print $4 }' | xargs ctags -uo - -x | awk -f "$kak_config/scripts/projectsymbols.awk"
|
||||||
} 'Project symbols: ' %{
|
} 'Project symbols: ' %{
|
||||||
evaluate-commands %sh{ printf '%s\n' "$kak_text" | awk '{ print "edit --", $4, $3 "; execute-keys /\\b" $1 "\\b<ret>" }' }
|
evaluate-commands %sh{ awk -f "$kak_config/scripts/projectsymbolscmd.awk" # "$kak_text" }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
for (i = 3; i < NF; ++i) {
|
||||||
|
if ($i ~ /^[0-9]+$/) {
|
||||||
|
j = match($0, "[ ]+" $(i-1) "[ ]+" $i " ")
|
||||||
|
print substr($0, 0, j - 1) "\u00a0" $(i-1) "\u00a0" $i
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
BEGIN {
|
||||||
|
n = split(ENVIRON["kak_text"], a, "\u00a0")
|
||||||
|
line = a[3]
|
||||||
|
if (n == 3 && line ~ /^[0-9]+/) {
|
||||||
|
pat = a[1]
|
||||||
|
gsub(/'/, "''", pat)
|
||||||
|
gsub(/\\/, "\\\\", pat)
|
||||||
|
print "execute-keys " line " g vv x s '/\\b\\Q" pat "\\E\\b|\\Q" pat "<ret>' <a-)>,"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
for (i = 3; i < NF; ++i) {
|
||||||
|
if ($i ~ /^[0-9]+$/) {
|
||||||
|
j = match($0, "[ ]+" $(i-1) "[ ]+" $i " ")
|
||||||
|
print substr($0, 0, j - 1) "\u00a0" $(i-1) "\u00a0" $i "\u00a0" $(i+1)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
BEGIN {
|
||||||
|
n = split(ENVIRON["kak_text"], a, "\u00a0")
|
||||||
|
line = a[3]
|
||||||
|
if (n == 4 && line ~ /^[0-9]+/) {
|
||||||
|
pat = a[1]
|
||||||
|
gsub(/'/, "''", pat)
|
||||||
|
gsub(/\\/, "\\\\", pat)
|
||||||
|
print "edit --", a[4], line
|
||||||
|
print "execute-keys vv x s %{/\\b\\Q" pat "\\E\\b|\\Q" pat "<ret>} <a-)>,"
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user