From ca508cd237e3d103f998468c8b42b681ec58be8e Mon Sep 17 00:00:00 2001 From: TheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com> Date: Thu, 30 Apr 2026 15:52:29 +0900 Subject: modified snippets/diary.lua --- .../TheSiahxyz/lua/TheSiahxyz/snippets/diary.lua | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'ar/.config') diff --git a/ar/.config/TheSiahxyz/lua/TheSiahxyz/snippets/diary.lua b/ar/.config/TheSiahxyz/lua/TheSiahxyz/snippets/diary.lua index 4f233d1..065de2a 100644 --- a/ar/.config/TheSiahxyz/lua/TheSiahxyz/snippets/diary.lua +++ b/ar/.config/TheSiahxyz/lua/TheSiahxyz/snippets/diary.lua @@ -10,6 +10,8 @@ local sn = ls.snippet_node local fmt = require("luasnip.extras.fmt").fmta +local default_bgm = "darling.mp3" + local function bgm_node_generator() return function() local handle = io.popen("ssh root@thesiah.xyz 'ls /var/www/thesiah/bgm/' 2>/dev/null") @@ -24,9 +26,24 @@ local function bgm_node_generator() return sn(nil, { i(1, "bgm") }) end - local choices = {} + local filenames = {} for filename in result:gmatch("[^\r\n]+") do - table.insert(choices, t(filename)) + table.insert(filenames, filename) + end + + if default_bgm ~= "" then + for idx, name in ipairs(filenames) do + if name == default_bgm then + table.remove(filenames, idx) + table.insert(filenames, 1, name) + break + end + end + end + + local choices = {} + for _, name in ipairs(filenames) do + table.insert(choices, t(name)) end if #choices == 0 then -- cgit v1.2.3