diff options
| author | Andrey Orst <andreyorst@gmail.com> | 2019-05-16 14:23:38 +0300 |
|---|---|---|
| committer | Andrey Orst <andreyorst@gmail.com> | 2019-05-17 20:00:40 +0300 |
| commit | ea960dcdfdb43d2249c41d1f5310c2800628ed7a (patch) | |
| tree | daf6a38f6e72820cb22c56fe937c2b82a7ef8c0f | |
| parent | 27b6889dafc50202e0e931c5b36787b64f6b241d (diff) | |
simplify rust completion to match generic Kakoune completions
| -rw-r--r-- | rc/tools/rust/racer.kak | 48 |
1 files changed, 4 insertions, 44 deletions
diff --git a/rc/tools/rust/racer.kak b/rc/tools/rust/racer.kak index 3df0b418..4a499c0f 100644 --- a/rc/tools/rust/racer.kak +++ b/rc/tools/rust/racer.kak @@ -26,55 +26,15 @@ define-command racer-complete -docstring "Complete the current selection with ra } /^MATCH/ { word = $2 - type = $7 desc = substr($9, 2, length($9) - 2) gsub(/\|/, "\\|", desc) gsub(/\\n/, "\n", desc) gsub(/!/, "!!", desc) - menu = $8 - sub(/^pub /, "", menu) - 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... + info = $8 + gsub(/\|/, "\\|", info) + + candidate = word "|info -style menu %!" desc "!|" word " {MenuInfo}" info - 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+F}" 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+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) gsub(/@/, "@@", candidate) gsub(/~/, "~~", candidate) print "%~" candidate "~" |
