From d79e680e716d9552cbb4c11a5d3cc778dc75d0cc Mon Sep 17 00:00:00 2001 From: Marc Date: Mon, 26 Feb 2018 12:24:12 +0000 Subject: [PATCH 2/3] Remove trailing ':' from racer execution When AWK processes the racer response, it adds a trailing ':' that kakoune completion expects to lead to a row having an 'a|b|c' shape, but it's empty instead. Removing the extra ':' allows the racer complation to actually work. --- rc/extra/racer.kak | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rc/extra/racer.kak b/rc/extra/racer.kak index a1bb4866..20f6c367 100644 --- a/rc/extra/racer.kak +++ b/rc/extra/racer.kak @@ -45,7 +45,7 @@ define-command racer-complete -docstring "Complete the current selection with ra }' ) 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} rm -r ${dir} ) > /dev/null 2>&1 < /dev/null & From f6a3fd2e4ed8857ffb1900fbb17370eaab277500 Mon Sep 17 00:00:00 2001 From: Marc Date: Mon, 26 Feb 2018 13:07:41 +0000 Subject: [PATCH 3/3] Unify racer code completion format Makes all the suggestions on the completion menu have the same format: {type}{suggestedWord}{extra description} the type column is aligned to 6 characters wide (and aligned to the right), to allow the suggestion to be easily visually detectable and, as a bonus, the type too. For example, a bit of menu would look like this: fn stdout() -> Stdout trait BufRead: Read struct BufReader Type is one of the following: - fn - enum - mod - trait - struct It also trims the module extra bits to only 30 characters long (it can be a lot longer than that) --- rc/extra/racer.kak | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/rc/extra/racer.kak b/rc/extra/racer.kak index 20f6c367..06bed711 100644 --- a/rc/extra/racer.kak +++ b/rc/extra/racer.kak @@ -29,13 +29,40 @@ define-command racer-complete -docstring "Complete the current selection with ra gsub(/\|/, "\\|", menu) if (type == "Function") { 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 - word = word "(" } else if (type == "Enum") { menu = substr(menu, 0, length(menu) - 2) sub(word, "{default+e}" word "{default+d}", menu) - menu = "{default+d}" menu - word = word "::" + 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 + # 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 { menu = "{default+e}" word "{default+d} " menu }