From ced575da824e4f936554d9ebbef3f2b0d6a4f640 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ensar=20Saraj=C4=8Di=C4=87?= Date: Thu, 5 May 2022 23:13:21 +0200 Subject: [PATCH] Fix ordering in vimwiki open_subdirectory_index_file --- symlinks/config/nvim/lua/esensar/vimwiki_extensions.lua | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/symlinks/config/nvim/lua/esensar/vimwiki_extensions.lua b/symlinks/config/nvim/lua/esensar/vimwiki_extensions.lua index f92c98a..396120a 100644 --- a/symlinks/config/nvim/lua/esensar/vimwiki_extensions.lua +++ b/symlinks/config/nvim/lua/esensar/vimwiki_extensions.lua @@ -39,7 +39,6 @@ function M.get_directory_index(vimwiki_index, directory) index[noext] = filename end - table.sort(index) return index end @@ -60,13 +59,19 @@ function M.open_subdirectory_index_file(vimwiki_index, subdirectory) } -- Add items + local items = {} for title, fname in pairs(index) do if title ~= "index" then title = string.gsub(title, "-", " ") title = title:sub(1, 1):upper() .. title:sub(2) - table.insert(lines, builder.list_item(builder.link(fname, title))) + table.insert(items, builder.list_item(builder.link(fname, title))) end end + table.sort(items) + + for _, item in ipairs(items) do + table.insert(lines, item) + end local buf = vim.api.nvim_get_current_buf() vim.api.nvim_buf_set_lines(buf, 0, -1, false, {}) -- Clear out