Merge remote-tracking branch 'andreyorst/fix-racer'
This commit is contained in:
commit
ef1523fbb0
|
@ -19,68 +19,28 @@ define-command racer-complete -docstring "Complete the current selection with ra
|
||||||
cursor="${kak_cursor_line} $((${kak_cursor_column} - 1))"
|
cursor="${kak_cursor_line} $((${kak_cursor_column} - 1))"
|
||||||
racer_data=$(racer --interface tab-text complete-with-snippet ${cursor} ${kak_buffile} ${dir}/buf)
|
racer_data=$(racer --interface tab-text complete-with-snippet ${cursor} ${kak_buffile} ${dir}/buf)
|
||||||
compl=$(printf %s\\n "${racer_data}" | awk '
|
compl=$(printf %s\\n "${racer_data}" | awk '
|
||||||
BEGIN { FS = "\t"; ORS = ":" }
|
BEGIN { FS = "\t"; ORS = " " }
|
||||||
/^PREFIX/ {
|
/^PREFIX/ {
|
||||||
column = ENVIRON["kak_cursor_column"] + $2 - $3
|
column = ENVIRON["kak_cursor_column"] + $2 - $3
|
||||||
print ENVIRON["kak_cursor_line"] "." column "@@" ENVIRON["kak_timestamp"]
|
print ENVIRON["kak_cursor_line"] "." column "@@" ENVIRON["kak_timestamp"]
|
||||||
}
|
}
|
||||||
/^MATCH/ {
|
/^MATCH/ {
|
||||||
word = $2
|
word = $2
|
||||||
type = $7
|
|
||||||
desc = substr($9, 2, length($9) - 2)
|
desc = substr($9, 2, length($9) - 2)
|
||||||
gsub(/\|/, "\\|", desc)
|
gsub(/\|/, "\\|", desc)
|
||||||
gsub(/\\n/, "\n", desc)
|
gsub(/\\n/, "\n", desc)
|
||||||
gsub(/!/, "!!", desc)
|
gsub(/!/, "!!", desc)
|
||||||
menu = $8
|
info = $8
|
||||||
sub(/^pub /, "", menu)
|
gsub(/\|/, "\\|", info)
|
||||||
gsub(/\|/, "\\|", menu)
|
|
||||||
if (type == "Function") {
|
|
||||||
sub(word, "{default+F}" word "{default+d}", menu)
|
|
||||||
gsub(/^fn /, " fn ", menu) # The extra spaces are there to vertically align
|
|
||||||
# the type of element on the menu to make it easy
|
|
||||||
# to read
|
|
||||||
menu = "{default+d}" menu
|
|
||||||
} else if (type == "Enum") {
|
|
||||||
menu = substr(menu, 0, length(menu) - 2)
|
|
||||||
sub(word, "{default+F}" word "{default+d}", menu)
|
|
||||||
gsub(/^enum /, " enum ", menu) # The extra spaces are there to vertically align
|
|
||||||
# the type of element on the menu to make it easy
|
|
||||||
# to read
|
|
||||||
} else if (type == "Module") {
|
|
||||||
if (length(menu) > 30) { # The "menu" bit (as returned by racer),
|
|
||||||
# contains the path to the source file
|
|
||||||
# containing the module...
|
|
||||||
|
|
||||||
menu = substr(menu, length(menu) - 29, 30) # ... trimming it, so the completion menu
|
candidate = word "|info -style menu %!" desc "!|" word " {MenuInfo}" info
|
||||||
# doesn''t get distorted if it''s too long
|
|
||||||
}
|
gsub(/@/, "@@", candidate)
|
||||||
menu = " mod {default+F}" word "{default+d} .." menu # The extra spaces are there to vertically align
|
gsub(/~/, "~~", candidate)
|
||||||
# the type of element on the menu to make it easy
|
print "%~" candidate "~"
|
||||||
# to read
|
|
||||||
} else if (type == "Trait") {
|
|
||||||
sub(word, "{default+F}" word "{default+d}", menu)
|
|
||||||
gsub(/^trait /, " trait ", menu) # The extra spaces are there to vertically align
|
|
||||||
# the type of element on the menu to make it easy
|
|
||||||
# to read
|
|
||||||
} else if (type == "Type") {
|
|
||||||
sub(word, "{default+F}" word "{default+d}", menu)
|
|
||||||
gsub(/^type /, " type ", menu) # The extra spaces are there to vertically align
|
|
||||||
# the type of element on the menu to make it easy
|
|
||||||
# to read
|
|
||||||
} else if (type == "Struct") {
|
|
||||||
sub(word, "{default+F}" word "{default+d}", menu) # Struct doesn''t have extra spaces because it''s
|
|
||||||
# the longest keyword
|
|
||||||
} else {
|
|
||||||
menu = "{default+F}" word "{default+d} " menu
|
|
||||||
}
|
|
||||||
candidate = word "|info -style menu %!" desc "!|" menu
|
|
||||||
gsub(/:/, "\\:", candidate)
|
|
||||||
print candidate
|
|
||||||
}'
|
}'
|
||||||
)
|
)
|
||||||
printf %s\\n "evaluate-commands -client '${kak_client}' %{
|
printf %s\\n "evaluate-commands -client '${kak_client}' %@ set-option 'buffer=${kak_bufname}' racer_completions ${compl%?} @" | kak -p ${kak_session}
|
||||||
set-option buffer=${kak_bufname} racer_completions %@${compl%?}@
|
|
||||||
}" | kak -p ${kak_session}
|
|
||||||
rm -r ${dir}
|
rm -r ${dir}
|
||||||
) > /dev/null 2>&1 < /dev/null &
|
) > /dev/null 2>&1 < /dev/null &
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user