diff options
| author | TheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com> | 2026-01-13 15:50:14 +0900 |
|---|---|---|
| committer | TheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com> | 2026-01-13 15:50:14 +0900 |
| commit | 7f2dba3d51b9fb585853e7af792155f8a1f4e006 (patch) | |
| tree | 46e896b53bdd054b9a370f9e5d54e4aaa5dc5aac /ar/.config/TheSiahxyz | |
| parent | da7c1e07ae15902256203cc24ace007ba12df5df (diff) | |
modified snippets/diary.lua, modified plugins/ai.lua, modified snippets/diary.lua
Diffstat (limited to 'ar/.config/TheSiahxyz')
| -rw-r--r-- | ar/.config/TheSiahxyz/lua/TheSiahxyz/snippets/diary.lua | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/ar/.config/TheSiahxyz/lua/TheSiahxyz/snippets/diary.lua b/ar/.config/TheSiahxyz/lua/TheSiahxyz/snippets/diary.lua index 90528a1..f1c636b 100644 --- a/ar/.config/TheSiahxyz/lua/TheSiahxyz/snippets/diary.lua +++ b/ar/.config/TheSiahxyz/lua/TheSiahxyz/snippets/diary.lua @@ -3,15 +3,46 @@ local ls = require("luasnip") local s = ls.snippet local i = ls.insert_node local f = ls.function_node +local c = ls.choice_node +local t = ls.text_node local fmt = require("luasnip.extras.fmt").fmta +local function bgm_list() + local handle = io.popen("ssh root@thesiah.xyz 'ls /var/www/thesiah/bgm/' 2>/dev/null") + if not handle then + return nil + end + + local result = handle:read("*a") + handle:close() + + if not result or result == "" then + return nil + end + + local choices = {} + for filename in result:gmatch("[^\r\n]+") do + table.insert(choices, t(filename)) + end + + if #choices == 0 then + return nil + end + + return choices +end + +local bgm_choices = bgm_list() +local bgm_node = bgm_choices and c(2, bgm_choices) or i(2, "bgm") + local diary_snippet = s( "diary", fmt( [[--- title: <title> date: <date> +bgm: <bgm> --- <story> @@ -21,6 +52,7 @@ date: <date> date = f(function() return os.date("%Y-%m-%d") end, {}), + bgm = bgm_node, story = i(3), } ) |
