From 30c66846502d186b92f921556505713a39630dd6 Mon Sep 17 00:00:00 2001 From: Vhyrro Date: Fri, 27 Oct 2023 17:35:52 +0200 Subject: [PATCH] feat(completion): sort versions by latest when completing rock versions --- lua/rocks/search.lua | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lua/rocks/search.lua b/lua/rocks/search.lua index 812c82b9..e9b41ed2 100644 --- a/lua/rocks/search.lua +++ b/lua/rocks/search.lua @@ -70,7 +70,12 @@ search.complete_versions = function(name, query) for _, rock in pairs(matching_rocks) do unique_versions[rock.version] = rock end - return vim.tbl_keys(unique_versions) + + local unique_keys = vim.tbl_keys(unique_versions) + table.sort(unique_keys, function(a, b) + return a > b + end) + return unique_keys end ---@param query string | nil