File tree Expand file tree Collapse file tree 1 file changed +13
-12
lines changed
Expand file tree Collapse file tree 1 file changed +13
-12
lines changed Original file line number Diff line number Diff line change 9191
9292local devto_au_group = vim .api .nvim_create_augroup (" devto_autocmds" , {})
9393
94+ --- Check if the API key is set before calling the callback
95+ --- @param callback function The function to call if the API key is set
96+ --- @return function
97+ local function check_api_middleware (callback )
98+ return function ()
99+ check_api_key (callback )
100+ end
101+ end
102+
94103--- Setup the plugin
95104--- It will create the necessary autocommands
96105--- @param opts ? table<string , any> At the moment , it is not used
@@ -131,19 +140,11 @@ function M.setup(opts)
131140 if not api .key () then
132141 notify .error (NO_API_KEY_ERROR )
133142 end
134- end
135143
136- --- Check if the API key is set before calling the callback
137- --- @param callback function The function to call if the API key is set
138- --- @return function
139- local function check_api_middleware (callback )
140- return function ()
141- check_api_key (callback )
142- end
144+ M .my_articles = check_api_middleware (my_articles )
145+ M .new_article = check_api_middleware (new_article )
146+ M .feed = check_api_middleware (feed .open )
147+ M .open_url = check_api_middleware (open_by_url )
143148end
144149
145- M .my_articles = check_api_middleware (my_articles )
146- M .new_article = check_api_middleware (new_article )
147- M .feed = check_api_middleware (feed .open )
148- M .open_url = check_api_middleware (open_by_url )
149150return M
You can’t perform that action at this time.
0 commit comments