1
1
mirror of https://github.com/mawww/kakoune.git synced 2024-11-15 09:17:22 +03:00

Merge remote-tracking branch 'marcesquerra/racer-tweaks'

This commit is contained in:
Maxime Coste 2018-03-04 10:59:31 +11:00
commit 8acedacf7c

View File

@ -29,13 +29,40 @@ define-command racer-complete -docstring "Complete the current selection with ra
gsub(/\|/, "\\|", menu) gsub(/\|/, "\\|", menu)
if (type == "Function") { if (type == "Function") {
sub(word, "{default+e}" word "{default+d}", menu) sub(word, "{default+e}" 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 menu = "{default+d}" menu
word = word "("
} else if (type == "Enum") { } else if (type == "Enum") {
menu = substr(menu, 0, length(menu) - 2) menu = substr(menu, 0, length(menu) - 2)
sub(word, "{default+e}" word "{default+d}", menu) sub(word, "{default+e}" word "{default+d}", menu)
menu = "{default+d}" menu gsub(/^enum /, " enum ", menu) # The extra spaces are there to vertically align
word = word "::" # 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
# doesn''t get distorted if it''s too long
}
menu = " mod {default+e}" word "{default+d} .." 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 == "Trait") {
sub(word, "{default+e}" 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+e}" 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+e}" word "{default+d}", menu) # Struct doesn''t have extra spaces because it''s
# the longest keyword
} else { } else {
menu = "{default+e}" word "{default+d} " menu menu = "{default+e}" word "{default+d} " menu
} }
@ -45,7 +72,7 @@ define-command racer-complete -docstring "Complete the current selection with ra
}' }'
) )
printf %s\\n "evaluate-commands -client '${kak_client}' %{ printf %s\\n "evaluate-commands -client '${kak_client}' %{
set-option buffer=${kak_bufname} racer_completions %@${compl}@ set-option buffer=${kak_bufname} racer_completions %@${compl: : -1}@
}" | kak -p ${kak_session} }" | kak -p ${kak_session}
rm -r ${dir} rm -r ${dir}
) > /dev/null 2>&1 < /dev/null & ) > /dev/null 2>&1 < /dev/null &