-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathastrocore.txt
1405 lines (884 loc) · 32.9 KB
/
astrocore.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
*astrocore.txt* For Neovim >= 0.9.0 Last change: 2025 April 30
==============================================================================
Table of Contents *astrocore-table-of-contents*
1. AstroCore |astrocore-astrocore|
- Features |astrocore-astrocore-features|
- Requirements |astrocore-astrocore-requirements|
- Installation |astrocore-astrocore-installation|
- Configuration |astrocore-astrocore-configuration|
- API |astrocore-astrocore-api|
- Contributing |astrocore-astrocore-contributing|
2. Lua API |astrocore-lua-api|
- astrocore |astrocore-lua-api-astrocore|
- astrocore.buffer |astrocore-lua-api-astrocore.buffer|
- astrocore.buffer.comparator|astrocore-lua-api-astrocore.buffer.comparator|
- astrocore.rooter |astrocore-lua-api-astrocore.rooter|
- astrocore.toggles |astrocore-lua-api-astrocore.toggles|
==============================================================================
1. AstroCore *astrocore-astrocore*
AstroCore provides the core Lua API that powers AstroNvim
<https://github.com/AstroNvim/AstroNvim>. It provides an interface for
configuration auto commands, user commands, on_key functions, key mappings, and
more as well as a Lua API of common utility functions.
FEATURES *astrocore-astrocore-features*
- Unified interface for configuring auto commands, user commands, key maps, on key functions
- Easy toggles of UI/UX elements and features
- Universal interface for setting up git worktrees
- Tab local buffer management for a clean `tabline`
- Project root detection with automatic `cd` features
- Session management with resession.nvim <https://github.com/stevearc/resession.nvim/>
REQUIREMENTS *astrocore-astrocore-requirements*
- Neovim >= 0.10
- lazy.nvim <https://github.com/folke/lazy.nvim>
- resession.nvim <https://github.com/stevearc/resession.nvim/> (_optional_)
INSTALLATION *astrocore-astrocore-installation*
Install the plugin with the lazy plugin manager:
>lua
return {
"AstroNvim/astrocore",
lazy = false, -- disable lazy loading
priority = 10000, -- load AstroCore first
opts = {
-- set configuration options as described below
},
}
<
If you want to enable session management with resession.nvim
<https://github.com/stevearc/resession.nvim/>, enable it in the setup:
>lua
require("resession").setup {
extensions = {
astrocore = {},
},
}
<
CONFIGURATION *astrocore-astrocore-configuration*
**AstroCore** comes with no defaults, but can be configured fully through the
`opts` table in lazy. Here are descriptions of the options and some example
usages:
>lua
---@type AstroCoreConfig
local opts = {
-- easily configure auto commands
autocmds = {
-- first key is the `augroup` (:h augroup)
highlighturl = {
-- list of auto commands to set
{
-- events to trigger
event = { "VimEnter", "FileType", "BufEnter", "WinEnter" },
-- the rest of the autocmd options (:h nvim_create_autocmd)
desc = "URL Highlighting",
callback = function() require("astrocore").set_url_match() end,
},
},
},
-- easily configure user commands
commands = {
-- key is the command name
AstroReload = {
-- first element with no key is the command (string or function)
function() require("astrocore").reload() end,
-- the rest are options for creating user commands (:h nvim_create_user_command)
desc = "Reload AstroNvim (Experimental)",
},
},
-- Configure diagnostics options (`:h vim.diagnostic.config()`)
diagnostics = {
update_in_insert = false,
},
-- passed to `vim.filetype.add`
filetypes = {
-- see `:h vim.filetype.add` for usage
extension = {
foo = "fooscript",
},
filename = {
[".foorc"] = "fooscript",
},
pattern = {
[".*/etc/foo/.*"] = "fooscript",
},
},
-- Configuration of vim mappings to create
mappings = {
-- map mode (:h map-modes)
n = {
-- use vimscript strings for mappings
["<C-s>"] = { ":w!<cr>", desc = "Save File" },
-- navigate buffer tabs with `H` and `L`
L = {
function() require("astrocore.buffer").nav(vim.v.count1) end,
desc = "Next buffer",
},
H = {
function() require("astrocore.buffer").nav(-vim.v.count1) end,
desc = "Previous buffer",
},
-- tables with just a `desc` key will be registered with which-key if it's installed
-- this is useful for naming menus
["<leader>b"] = { desc = "Buffers" },
},
},
-- easily configure functions on key press
on_keys = {
-- first key is the namespace
auto_hlsearch = {
-- list of functions to execute on key press (:h vim.on_key)
function(char) -- example automatically disables `hlsearch` when not actively searching
if vim.fn.mode() == "n" then
local new_hlsearch = vim.tbl_contains({ "<CR>", "n", "N", "*", "#", "?", "/" }, vim.fn.keytrans(char))
if vim.opt.hlsearch:get() ~= new_hlsearch then vim.opt.hlsearch = new_hlsearch end
end
end,
},
},
-- easily configure vim options
options = {
-- first key is the type of option `vim.<first_key>`
opt = {
relativenumber = true, -- sets `vim.opt.relativenumber`
signcolumn = "auto", -- sets `vim.opt.relativenumber`
},
g = {
-- set global `vim.g` settings here
},
},
-- configure AstroNvim features
features = {
autopairs = true, -- enable or disable autopairs on start
cmp = true, -- enable or disable cmp on start
diagnostics = { virtual_text = true, virtual_lines = false }, -- enable or disable diagnostics features on start
highlighturl = true, -- enable or disable highlighting of urls on start
-- table for defining the size of the max file for all features, above these limits we disable features like treesitter.
large_buf = {
-- whether to enable large file detection for a buffer (must return false to disable)
-- first parameter is the buffer number, the second is the large buffer configuration table
-- return values:
-- - `true` or `nil` to continue and respects all changes made to the large buffer configuration table
-- - `false` to disable large file detection for the buffer
-- - a new table of large buffer options to use instead of the defaults
enabled = function(bufnr, config) end,
notify = true, -- whether or not to display a notification when a large file is detected
size = 1024 * 100, -- max file size (or false to disable check)
lines = 10000, -- max number of lines (or false to disable check)
line_length = 1000, -- average line length (or false to disable check)
},
notifications = true, -- enable or disable notifications on start
},
-- Enable git integration for detached worktrees
git_worktrees = {
{ toplevel = vim.env.HOME, gitdir = vim.env.HOME .. "/.dotfiles" },
},
-- Configure project root detection, check status with `:AstroRootInfo`
rooter = {
-- list of detectors in order of prevalence, elements can be:
-- "lsp" : lsp detection
-- string[] : a list of directory patterns to look for
-- fun(bufnr: integer): string|string[] : a function that takes a buffer number and outputs detected roots
detector = {
"lsp", -- highest priority is getting workspace from running language servers
{ ".git", "_darcs", ".hg", ".bzr", ".svn" }, -- next check for a version controlled parent directory
{ "lua", "MakeFile", "package.json" }, -- lastly check for known project root files
},
-- ignore things from root detection
ignore = {
servers = {}, -- list of language server names to ignore (Ex. { "efm" })
dirs = {}, -- list of directory patterns (Ex. { "~/.cargo/*" })
},
-- automatically update working directory (update manually with `:AstroRoot`)
autochdir = false,
-- scope of working directory to change ("global"|"tab"|"win")
scope = "global",
-- show notification on every working directory change
notify = false,
},
-- Configuration table of session options for AstroNvim's session management powered by Resession
sessions = {
-- Configure auto saving
autosave = {
last = true, -- auto save last session
cwd = true, -- auto save session for each working directory
},
-- Patterns to ignore when saving sessions
ignore = {
dirs = {}, -- working directories to ignore sessions in
filetypes = { "gitcommit", "gitrebase" }, -- filetypes to ignore sessions
buftypes = {}, -- buffer types to ignore sessions
},
},
}
<
API *astrocore-astrocore-api*
**AstroCore** provides a Lua API with utility functions. This can be viewed
with |astrocore| or in the repository at doc/api.md <doc/api.md>
CONTRIBUTING *astrocore-astrocore-contributing*
If you plan to contribute, please check the contribution guidelines
<https://github.com/AstroNvim/.github/blob/main/CONTRIBUTING.md> first.
==============================================================================
2. Lua API *astrocore-lua-api*
astrocore API documentation
ASTROCORE *astrocore-lua-api-astrocore*
CMD ~
>lua
function astrocore.cmd(cmd: string|string[], show_error?: boolean)
-> result: string|nil
<
Run a shell command and capture the output and if the command succeeded or
failed
_param_ `cmd` — The terminal command to execute
_param_ `show_error` — Whether or not to show an unsuccessful command as an
error to the user
_return_ `result` — The result of a successfully executed command or nil
CONDITIONAL_FUNC ~
>lua
function astrocore.conditional_func(func: function, condition: boolean, ...any)
-> result: any
<
Call function if a condition is met
_param_ `func` — The function to run
_param_ `condition` — Whether to run the function or not
_return_ `result` — the result of the function running or nil
CONFIG ~
>lua
AstroCoreOpts
<
The configuration as set by the user through the `setup()` function
DELETE_URL_MATCH ~
>lua
function astrocore.delete_url_match(win?: integer)
<
Delete the syntax matching rules for URLs/URIs if set
_param_ `win` — the window id to remove url highlighting in (default: current
window)
EMPTY_MAP_TABLE ~
>lua
function astrocore.empty_map_table()
-> mappings: table<string, table>
<
Get an empty table of mappings with a key for each map mode
_return_ `mappings` — a table with entries for each map mode
EVENT ~
>lua
function astrocore.event(event: string|vim.api.keyset_exec_autocmds, instant?: boolean)
<
Trigger an AstroNvim user event
_param_ `event` — The event pattern or full autocmd options (pattern always
prepended with "Astro")
_param_ `instant` — Whether or not to execute instantly or schedule
EXEC_BUFFER_AUTOCMDS ~
>lua
function astrocore.exec_buffer_autocmds(event: string|string[], opts: vim.api.keyset.exec_autocmds)
<
Execute autocommand across all valid buffers
_param_ `event` — the event or events to execute
_param_ `opts` — Dictionary of autocommnd options
EXTEND_TBL ~
>lua
function astrocore.extend_tbl(default?: table, opts?: table)
-> extended: table
<
Merge extended options with a default table of options
_param_ `default` — The default table that you want to merge into
_param_ `opts` — The new options that should be merged with the default table
_return_ `extended` — The extended table
FILE_WORKTREE ~
>lua
function astrocore.file_worktree(file?: string, worktrees?: table<string, string>[])
-> worktree: table<string, string>|nil
<
Get the first worktree that a file belongs to
_param_ `file` — the file to check, defaults to the current file
_param_ `worktrees` — an array like table of worktrees with entries
`toplevel` and `gitdir`, default retrieves from `vim.g.git_worktrees`
_return_ `worktree` — a table specifying the `toplevel` and `gitdir` of a
worktree or nil if not found
GET_PLUGIN ~
>lua
function astrocore.get_plugin(plugin: string)
-> spec: LazyPlugin?
<
Get a plugin spec from lazy
_param_ `plugin` — The plugin to search for
_return_ `spec` — The found plugin spec from Lazy
IS_AVAILABLE ~
>lua
function astrocore.is_available(plugin: string)
-> available: boolean
<
Check if a plugin is defined in lazy. Useful with lazy loading when a plugin is
not necessarily loaded yet
_param_ `plugin` — The plugin to search for
_return_ `available` — Whether the plugin is available
LIST_INSERT_UNIQUE ~
>lua
function astrocore.list_insert_unique(dst: any[]|nil, src: any[])
-> result: any[]
<
Insert one or more values into a list like table and maintain that you do not
insert non-unique values (THIS MODIFIES `dst`)
_param_ `dst` — The list like table that you want to insert into
_param_ `src` — Values to be inserted
_return_ `result` — The modified list like table
LOAD_PLUGIN_WITH_FUNC ~
>lua
function astrocore.load_plugin_with_func(plugin: string, module: table, funcs: string|string[])
<
A helper function to wrap a module function to require a plugin before running
_param_ `plugin` — The plugin to call `require("lazy").load` with
_param_ `module` — The system module where the functions live
(e.g. `vim.ui`)
_param_ `funcs` — The functions to wrap in the given module (e.g. `"ui",
"select"`)
NORMALIZE_MAPPINGS ~
>lua
function astrocore.normalize_mappings(mappings?: table<string, table<string, (string|function|AstroCoreMapping|false)?>?>)
<
Normalize a mappings table to use official keycode casing
NOTIFY ~
>lua
function astrocore.notify(msg: string, type: integer|nil, opts?: table)
<
Serve a notification with a title of AstroNvim
_param_ `msg` — The notification body
_param_ `type` — The type of the notification (:help vim.log.levels)
_param_ `opts` — The nvim-notify options to use (:help notify-options)
ON_LOAD ~
>lua
function astrocore.on_load(plugins: string|string[], load_op: string|fun()|string[])
<
Execute a function when a specified plugin is loaded with Lazy.nvim, or
immediately if already loaded
_param_ `plugins` — the name of the plugin or a list of plugins to defer the
function execution on. If a list is provided, only one needs to be loaded to
execute the provided function
_param_ `load_op` — the function to execute when the plugin is loaded, a
plugin name to load, or a list of plugin names to load
PATCH_FUNC ~
>lua
function astrocore.patch_func(orig?: function, override: fun(orig: function, ...any):...unknown)
-> patched: function
<
Monkey patch into an existing function
Example from |vim.paste()| `lua local patch_func =
require("astrocore").patch_func vim.paste = patch_func(vim.paste,
function(orig, lines, phase) for i, line in ipairs(lines) do -- Scrub ANSI
color codes from paste input. lines[i] = line:gsub('\27%[[0-9;mK]+', '') end
return orig(lines, phase) end)`
_param_ `orig` — the original function to override, if `nil` is provided then
an empty function is passed
_param_ `override` — the override function
_return_ `patched` — the new function with the patch applied
PLUGIN_OPTS ~
>lua
function astrocore.plugin_opts(plugin: string)
-> opts: table
<
Resolve the options table for a given plugin with lazy
_param_ `plugin` — The plugin to search for
_return_ `opts` — The plugin options
READ_FILE ~
>lua
function astrocore.read_file(path: string)
-> content: string
<
Helper function to read a file and return it’s content
_param_ `path` — the path to the file to read
_return_ `content` — the contents of the file
RELOAD ~
>lua
function astrocore.reload()
<
Partially reload AstroNvim user settings. Includes core vim options, mappings,
and highlights. This is an experimental feature and may lead to instabilities
until restart.
RENAME_FILE ~
>lua
function astrocore.rename_file(opts?: AstroCoreRenameFileOpts)
<
Prompt the user to rename a file
_param_ `opts` — optional fields for file renaming
SET_MAPPINGS ~
>lua
function astrocore.set_mappings(map_table: table<string, table<string, (string|function|AstroCoreMapping|false)?>?>, base?: vim.keymap.set.Opts)
<
Table based API for setting keybindings
_param_ `map_table` — A nested table where the first key is the vim mode, the
second key is the key to map, and the value is the function to set the mapping
to
_param_ `base` — A base set of options to set on every keybinding
SET_URL_MATCH ~
>lua
function astrocore.set_url_match(win?: integer)
<
Add syntax matching rules for highlighting URLs/URIs
_param_ `win` — the window id to remove url highlighting in (default: current
window)
SETUP ~
>lua
function astrocore.setup(opts: AstroCoreOpts)
<
Setup and configure AstroCore See: astrocore.config
<file:///home/runner/work/astrocore/astrocore/lua/astrocore/init.lua#13#0>
TOGGLE_TERM_CMD ~
>lua
function astrocore.toggle_term_cmd(opts: string|table)
<
Toggle a user terminal if it exists, if not then create a new one and save it
_param_ `opts` — A terminal command string or a table of options for
Terminal:new() (Check toggleterm.nvim documentation for table format)
UNIQUE_LIST ~
>lua
function astrocore.unique_list(list: any[])
-> result: any[]
<
Remove duplicate entries from a given list (does not mutate the original list)
_param_ `list` — The list like table that you want to remove duplicates from
_return_ `result` — The list like table of unique values
UPDATE_PACKAGES ~
>lua
function astrocore.update_packages()
<
Sync Lazy and then update Mason
URL_MATCHER ~
>lua
string
<
regex used for matching a valid URL/URI string
USER_TERMINALS ~
>lua
{ [string]: table<integer, table> }
<
A table to manage ToggleTerm terminals created by the user, indexed by the
command run and then the instance number
WHICH_KEY_QUEUE ~
>lua
nil
<
A placeholder variable used to queue section names to be registered by
which-key
WHICH_KEY_REGISTER ~
>lua
function astrocore.which_key_register()
<
Register queued which-key mappings
WITH_FILE ~
>lua
function astrocore.with_file(filename: string, mode?: "a"|"a+"|"a+b"|"ab"|"r"...(+7), callback?: fun(file: file*), on_error?: fun(err: string))
<
Execute function with open file
_param_ `filename` — path to file to interact with
_param_ `mode` — the mode in which to open the file
_param_ `callback` — the callback to execute with the opened file
_param_ `on_error` — the callback to execute if unable to open the file
>lua
mode:
-> "r" -- Read mode.
| "w" -- Write mode.
| "a" -- Append mode.
| "r+" -- Update mode, all previous data is preserved.
| "w+" -- Update mode, all previous data is erased.
| "a+" -- Append update mode, previous data is preserved, writing is only allowed at the end of file.
| "rb" -- Read mode. (in binary mode.)
| "wb" -- Write mode. (in binary mode.)
| "ab" -- Append mode. (in binary mode.)
| "r+b" -- Update mode, all previous data is preserved. (in binary mode.)
| "w+b" -- Update mode, all previous data is erased. (in binary mode.)
| "a+b" -- Append update mode, previous data is preserved, writing is only allowed at the end of file. (in binary mode.)
<
ASTROCORE.BUFFER *astrocore-lua-api-astrocore.buffer*
CLOSE ~
>lua
function astrocore.buffer.close(bufnr?: integer, force?: boolean)
<
Close a given buffer
_param_ `bufnr` — The buffer to close or the current buffer if not provided
_param_ `force` — Whether or not to foce close the buffers or confirm changes
(default: false)
CLOSE_ALL ~
>lua
function astrocore.buffer.close_all(keep_current?: boolean, force?: boolean)
<
Close all buffers
_param_ `keep_current` — Whether or not to keep the current buffer (default:
false)
_param_ `force` — Whether or not to foce close the buffers or confirm changes
(default: false)
CLOSE_LEFT ~
>lua
function astrocore.buffer.close_left(force?: boolean)
<
Close buffers to the left of the current buffer
_param_ `force` — Whether or not to foce close the buffers or confirm changes
(default: false)
CLOSE_RIGHT ~
>lua
function astrocore.buffer.close_right(force?: boolean)
<
Close buffers to the right of the current buffer
_param_ `force` — Whether or not to foce close the buffers or confirm changes
(default: false)
CLOSE_TAB ~
>lua
function astrocore.buffer.close_tab(tabpage?: integer)
<
Close a given tab
_param_ `tabpage` — The tabpage to close or the current tab if not provided
CURRENT_BUF ~
>lua
nil
<
Placeholders for keeping track of most recent and previous buffer
HAS_FILETYPE ~
>lua
function astrocore.buffer.has_filetype(bufnr?: integer)
-> boolean
<
Check if a buffer has a filetype
_param_ `bufnr` — The buffer to check, default to current buffer
_return_ — Whether the buffer has a filetype or not
IS_LARGE ~
>lua
function astrocore.buffer.is_large(bufnr?: integer, large_buf_opts?: AstroCoreMaxFile)
-> is_large: boolean
<
Check if a buffer is a large buffer (always returns false if large buffer
detection is disabled)
_param_ `bufnr` — the buffer to check the size of, default to current buffer
_param_ `large_buf_opts` — large buffer parameters, default to AstroCore
configuration
_return_ `is_large` — whether the buffer is detected as large or not
IS_RESTORABLE ~
>lua
function astrocore.buffer.is_restorable(bufnr: integer)
-> boolean
<
Check if a buffer can be restored
_param_ `bufnr` — The buffer to check
_return_ — Whether the buffer is restorable or not
IS_VALID ~
>lua
function astrocore.buffer.is_valid(bufnr?: integer)
-> boolean
<
Check if a buffer is valid
_param_ `bufnr` — The buffer to check, default to current buffer
_return_ — Whether the buffer is valid or not
IS_VALID_SESSION ~
>lua
function astrocore.buffer.is_valid_session()
-> boolean
<
Check if the current buffers form a valid session
_return_ — Whether the current session of buffers is a valid session
LAST_BUF ~
>lua
nil
<
MOVE ~
>lua
function astrocore.buffer.move(n: integer)
<
Move the current buffer tab n places in the bufferline
_param_ `n` — The number of tabs to move the current buffer over by (positive
= right, negative = left)
NAV ~
>lua
function astrocore.buffer.nav(n: integer)
<
Navigate left and right by n places in the bufferline
_param_ `n` — The number of tabs to navigate to (positive = right, negative =
left)
NAV_TO ~
>lua
function astrocore.buffer.nav_to(tabnr: integer)
<
Navigate to a specific buffer by its position in the bufferline
_param_ `tabnr` — The position of the buffer to navigate to
PREV ~
>lua
function astrocore.buffer.prev()
<
Navigate to the previously used buffer
SORT ~
>lua
function astrocore.buffer.sort(compare_func: string|function, skip_autocmd: boolean|nil)
-> boolean
<
Sort a the buffers in the current tab based on some comparator
_param_ `compare_func` — a string of a comparator defined in
require("astrocore.buffer.comparator") or a custom comparator function
_param_ `skip_autocmd` — whether or not to skip triggering AstroBufsUpdated
autocmd event
_return_ — Whether or not the buffers were sorted
WIPE ~
>lua
function astrocore.buffer.wipe(bufnr?: integer, force?: boolean)
<
Fully wipeout a given buffer
_param_ `bufnr` — The buffer to wipe or the current buffer if not provided
_param_ `force` — Whether or not to foce close the buffers or confirm changes
(default: false)
ASTROCORE.BUFFER.COMPARATOR *astrocore-lua-api-astrocore.buffer.comparator*
BUFNR ~
>lua
function astrocore.buffer.comparator.bufnr(bufnr_a: integer, bufnr_b: integer)
-> comparison: boolean
<
Comparator of two buffer numbers
_param_ `bufnr_a` — buffer number A
_param_ `bufnr_b` — buffer number B
_return_ `comparison` — true if A is sorted before B, false if B should be
sorted before A
EXTENSION ~
>lua
function astrocore.buffer.comparator.extension(bufnr_a: integer, bufnr_b: integer)
-> comparison: boolean
<
Comparator of two buffer numbers based on the file extensions
_param_ `bufnr_a` — buffer number A
_param_ `bufnr_b` — buffer number B
_return_ `comparison` — true if A is sorted before B, false if B should be
sorted before A
FULL_PATH ~
>lua
function astrocore.buffer.comparator.full_path(bufnr_a: integer, bufnr_b: integer)
-> comparison: boolean
<
Comparator of two buffer numbers based on the full path
_param_ `bufnr_a` — buffer number A
_param_ `bufnr_b` — buffer number B
_return_ `comparison` — true if A is sorted before B, false if B should be
sorted before A
MODIFIED ~
>lua
function astrocore.buffer.comparator.modified(bufnr_a: integer, bufnr_b: integer)
-> comparison: boolean
<
Comparator of two buffers based on modification date
_param_ `bufnr_a` — buffer number A
_param_ `bufnr_b` — buffer number B