@@ -378,19 +378,50 @@ function Grapple.statusline(opts)
378
378
return statusline
379
379
end
380
380
381
+ --- @param opts ? { scope ?: string , id ?: string , notify ?: boolean }
382
+ --- @return string ? error
383
+ function Grapple .unload (opts )
384
+ local App = require (" grapple.app" )
385
+ local app = App .get ()
386
+
387
+ opts = opts or {}
388
+
389
+ local err = app :unload (opts )
390
+ if err then
391
+ if opts .notify then
392
+ return vim .notify (err , vim .log .levels .ERROR )
393
+ else
394
+ return err
395
+ end
396
+ end
397
+
398
+ if opts .notify then
399
+ vim .notify (string.format (" Scope unloaded: %s" , opts .scope or opts .id ), vim .log .levels .INFO )
400
+ end
401
+ end
402
+
381
403
--- Reset tags for a given (scope) name or loaded scope (id)
382
404
--- By default, uses the current scope
383
- --- @param opts ? { scope ?: string , id ?: string }
405
+ --- @param opts ? { scope ?: string , id ?: string , notify ?: boolean }
406
+ --- @return string ? error
384
407
function Grapple .reset (opts )
385
408
local App = require (" grapple.app" )
386
409
local app = App .get ()
387
410
411
+ opts = opts or {}
412
+
388
413
local err = app :reset (opts )
389
414
if err then
390
- return vim .notify (err , vim .log .levels .ERROR )
415
+ if opts .notify then
416
+ return vim .notify (err , vim .log .levels .ERROR )
417
+ else
418
+ return err
419
+ end
391
420
end
392
421
393
- vim .notify (string.format (" Scope reset: %s" , opts .scope or opts .id ), vim .log .levels .INFO )
422
+ if opts .notify then
423
+ vim .notify (string.format (" Scope reset: %s" , opts .scope or opts .id ), vim .log .levels .INFO )
424
+ end
394
425
end
395
426
396
427
--- Create a user-defined scope
@@ -412,20 +443,20 @@ function Grapple.delete_scope(scope)
412
443
end
413
444
414
445
--- Change the currently selected scope
415
- --- @param scope string
416
- function Grapple .use_scope (scope )
446
+ --- @param scope_name string
447
+ function Grapple .use_scope (scope_name )
417
448
local App = require (" grapple.app" )
418
449
local app = App .get ()
419
450
420
- local resolved , err = app .scope_manager :get (scope )
421
- if not resolved then
451
+ local scope , err = app .scope_manager :get (scope_name )
452
+ if not scope then
422
453
--- @diagnostic disable-next-line : param-type-mismatch
423
454
return vim .notify (err , vim .log .levels .ERROR )
424
455
end
425
456
426
- if resolved .name ~= app .settings .scope then
427
- app .settings :update ({ scope = resolved .name })
428
- vim .notify (string.format (" Changing scope: %s" , resolved .name ))
457
+ if scope .name ~= app .settings .scope then
458
+ app .settings :update ({ scope = scope .name })
459
+ vim .notify (string.format (" Changing scope: %s" , scope .name ))
429
460
end
430
461
end
431
462
@@ -499,9 +530,9 @@ function Grapple.open_tags(opts)
499
530
-- stylua: ignore
500
531
local content = TagContent :new (
501
532
scope ,
502
- app .settings .styles [opts .style or app .settings .style ],
503
533
app .settings .tag_hook ,
504
- app .settings .tag_title
534
+ app .settings .tag_title ,
535
+ app .settings .styles [opts .style or app .settings .style ]
505
536
)
506
537
507
538
open (content )
@@ -642,6 +673,7 @@ function Grapple.initialize()
642
673
toggle_loaded = { args = {}, kwargs = { " all" } },
643
674
toggle_scopes = { args = {}, kwargs = {} },
644
675
toggle_tags = { args = {}, kwargs = window_kwargs },
676
+ unload = { args = {}, kwargs = scope_kwargs },
645
677
untag = { args = {}, kwargs = use_kwargs },
646
678
use_scope = { args = { " scope" }, kwargs = {} },
647
679
}
0 commit comments