@@ -26,9 +26,7 @@ function utils.element_align(tbl)
2626end
2727
2828function utils .get_max_len (contents )
29- vim .validate ({
30- contents = { contents , ' t' },
31- })
29+ assert (type (contents ) == ' table' , ' contents must be a table' )
3230 local cells = {}
3331 for _ , v in pairs (contents ) do
3432 table.insert (cells , vim .api .nvim_strwidth (v ))
@@ -37,11 +35,8 @@ function utils.get_max_len(contents)
3735 return cells [# cells ]
3836end
3937
40- -- draw the graphics into the screen center
4138function utils .center_align (tbl )
42- vim .validate ({
43- tbl = { tbl , ' table' },
44- })
39+ assert (type (tbl ) == ' table' , ' tbl must be a table' )
4540 local function fill_sizes (lines )
4641 local fills = {}
4742 for _ , line in pairs (lines ) do
@@ -100,7 +95,6 @@ function utils.disable_move_key(bufnr)
10095 end , keys )
10196end
10297
103- --- return the most recently files list
10498function utils .get_mru_list ()
10599 local mru = {}
106100 for _ , file in pairs (vim .v .oldfiles or {}) do
@@ -113,29 +107,26 @@ end
113107
114108function utils .get_package_manager_stats ()
115109 local package_manager_stats = { name = ' ' , count = 0 , loaded = 0 , time = 0 }
116- --- @diagnostic disable-next-line : undefined-global
117110 if packer_plugins then
118111 package_manager_stats .name = ' packer'
119- --- @diagnostic disable-next-line : undefined-global
120112 package_manager_stats .count = # vim .tbl_keys (packer_plugins )
121113 end
122114 local status , lazy = pcall (require , ' lazy' )
123115 if status then
124116 package_manager_stats .name = ' lazy'
125- package_manager_stats .loaded = lazy .stats ().loaded
126- package_manager_stats .count = lazy .stats ().count
127- package_manager_stats .time = lazy .stats ().startuptime
117+ local stats = lazy .stats ()
118+ package_manager_stats .loaded = stats .loaded
119+ package_manager_stats .count = stats .count
120+ package_manager_stats .time = stats .startuptime
128121 end
129122 return package_manager_stats
130123end
131124
132- --- generate an empty table by length
133125function utils .generate_empty_table (length )
134126 local empty_tbl = {}
135127 if length == 0 then
136128 return empty_tbl
137129 end
138-
139130 for _ = 1 , length do
140131 table.insert (empty_tbl , ' ' )
141132 end
168159function utils .buf_is_empty (bufnr )
169160 bufnr = bufnr or 0
170161 return vim .api .nvim_buf_line_count (0 ) == 1
171- and vim .api .nvim_buf_get_lines (0 , 0 , - 1 , false )[1 ] == ' '
162+ and vim .api .nvim_buf_get_lines (0 , 0 , - 1 , false )[1 ] == ' '
172163end
173164
174165local last_footer_size = nil
@@ -190,7 +181,7 @@ function utils.add_update_footer_command(bufnr, footer)
190181 vim .bo [bufnr ].modifiable = false
191182 vim .bo [bufnr ].modified = false
192183
193- last_footer_size = # args .fargs -- For future calculation of size
184+ last_footer_size = # args .fargs
194185 end , { nargs = ' *' })
195186end
196187
0 commit comments