Skip to content

Commit c893964

Browse files
committedJan 14, 2025
Add reload command
1 parent b312995 commit c893964

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed
 

‎README.md

+10
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ This plugin provides the following user commands:
9292
:AocGetTodayPuzzleInput
9393
:AocClearCache
9494
:AocInspectConfig
95+
:AocReloadSession
9596
```
9697

9798
### AocGetPuzzleInput
@@ -143,6 +144,15 @@ This command allows you to quickly inspect the current plugin configuration.
143144
}
144145
```
145146

147+
### AocReloadSession
148+
149+
This command reloads session token should your session token change.
150+
151+
``` vim
152+
:AocReloadSession
153+
Session token loaded
154+
```
155+
146156
## Contribution
147157

148158
All contributions are most welcome! Please open a PR or create an [issue](https://github.com/csessh/aoc.nvim/issues).

‎lua/aoc/api.lua

+8
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ local get_session_id = function()
4646

4747
local f = io.open(cfg.options.session_filepath, "r")
4848
if not f then
49+
vim.api.nvim_err_writeln("Unable to open session file" .. cfg.options.session_filepath)
4950
return nil
5051
end
5152

@@ -99,4 +100,11 @@ M.save_puzzle_input = function(day, year)
99100
end
100101
end
101102

103+
M.reload_session_token = function()
104+
M.session_id = get_session_id()
105+
if M.session_id then
106+
vim.notify "Session token reloaded"
107+
end
108+
end
109+
102110
return M

‎lua/aoc/init.lua

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ M.setup = function(args)
2929

3030
vim.api.nvim_create_user_command("AocClearCache", cache.clear_cache, {})
3131
vim.api.nvim_create_user_command("AocInspectConfig", cfg.debug, {})
32+
vim.api.nvim_create_user_command("AocReloadSession", api.reload_session_token, {})
3233
end
3334

3435
return M

0 commit comments

Comments
 (0)