@@ -6,8 +6,9 @@ local M = {}
66--- @param filepath string
77--- @return string icon , string ? color
88local function get_filetype_icon (filepath )
9+ local icons = require (' markit.config' ).config .icons
910 if not filepath or filepath == ' ' then
10- return ' ' , nil
11+ return icons . file , nil
1112 end
1213
1314 local ext = vim .fn .fnamemodify (filepath , ' :e' ):lower ()
@@ -21,35 +22,36 @@ local function get_filetype_icon(filepath)
2122 end
2223 end
2324
24- return ' ' , nil
25+ return icons . file , nil
2526end
2627
2728--- Get mark type icon and description
2829--- @param mark string
2930--- @return string icon , string description
3031local function get_mark_type_info (mark )
32+ local marks = require (' markit.config' ).config .icons .marks
3133 if not mark then
32- return ' ' , ' Unknown'
34+ return marks . default , ' Unknown'
3335 end
3436
3537 if mark :match (' [a-z]' ) then
36- return ' ' , ' Buffer Mark'
38+ return marks . buffer , ' Buffer Mark'
3739 elseif mark :match (' [A-Z]' ) then
38- return ' ' , ' Global Mark'
40+ return marks . global , ' Global Mark'
3941 elseif mark :match (' [0-9]' ) then
40- return ' ' , ' Numbered Mark'
42+ return marks . numbered , ' Numbered Mark'
4143 elseif mark == " '" then
42- return ' ' , ' Last Jump'
44+ return marks . last_jump , ' Last Jump'
4345 elseif mark == ' ^' then
44- return ' ' , ' Last Insert'
46+ return marks . last_insert , ' Last Insert'
4547 elseif mark == ' .' then
46- return ' ' , ' Last Change'
48+ return marks . last_change , ' Last Change'
4749 elseif mark == ' <' then
48- return ' ' , ' Visual Start'
50+ return marks . visual_start , ' Visual Start'
4951 elseif mark == ' >' then
50- return ' ' , ' Visual End'
52+ return marks . visual_end , ' Visual End'
5153 else
52- return ' ' , ' Special Mark'
54+ return marks . default , ' Special Mark'
5355 end
5456end
5557
@@ -62,7 +64,7 @@ local function get_bookmark_info(group_nr)
6264 local color = colors [group_nr + 1 ] or ' Default'
6365
6466 local bookmark_config = config .bookmarks [group_nr + 1 ]
65- local icon = ' '
67+ local icon = config . icons . default_bookmark
6668 if bookmark_config then
6769 icon = bookmark_config .sign
6870 end
102104--- @param mark_entry table
103105--- @return table
104106local function marks_entry_maker (mark_entry )
105- local icons = require (' markit.config' ).config .preview . icons
107+ local icons = require (' markit.config' ).config .icons
106108 local file_icon , file_color = get_filetype_icon (mark_entry .path )
107109 local mark_icon , mark_desc = get_mark_type_info (mark_entry .mark )
108110 local file_path = format_file_path (mark_entry .path , 25 )
135137--- @param bookmark_entry table
136138--- @return table
137139local function bookmarks_entry_maker (bookmark_entry )
138- local icons = require (' markit.config' ).config .preview . icons
140+ local icons = require (' markit.config' ).config .icons
139141 local file_icon , file_color = get_filetype_icon (bookmark_entry .path )
140142 local bookmark_icon , bookmark_desc = get_bookmark_info (bookmark_entry .group )
141143 local file_path = format_file_path (bookmark_entry .path , 25 )
@@ -200,19 +202,20 @@ end
200202--- @param entry table
201203--- @return string
202204local function generate_preview (entry )
205+ local config = require (' markit.config' ).config
206+ local icons = config .icons
203207 if not entry .path or entry .path == ' ' then
204- return ' File Not Found\n This mark/bookmark does not have an associated file.'
208+ return icons . error .. ' File Not Found\n This mark/bookmark does not have an associated file.'
205209 end
206210
207211 local file_exists = vim .fn .filereadable (entry .path ) == 1
208212 if not file_exists then
209- return string.format (' File Not Found\n Path: %s' , entry .path )
213+ return string.format (' %s File Not Found\n Path: %s' , icons . error , entry .path )
210214 end
211215
212- local separator_width = 200
213- local config = require (' markit.config' ).config
214216 local context_after = config .preview .context_after
215217 local context_before = config .preview .context_before
218+ local content_separator = string.rep (icons .content_separator , 240 )
216219
217220 local lines = {}
218221 local metadata = get_file_metadata (entry .path )
@@ -233,7 +236,7 @@ local function generate_preview(entry)
233236 local filetype = vim .filetype .match ({ filename = entry .path }) or ' text'
234237
235238 table.insert (lines , string.format (' # %s %s' , file_icon , rel_path ))
236- table.insert (lines , string.rep ( ' ─ ' , separator_width ) )
239+ table.insert (lines , content_separator )
237240
238241 table.insert (
239242 lines ,
@@ -270,19 +273,19 @@ local function generate_preview(entry)
270273 table.insert (lines , ' ' )
271274
272275 table.insert (lines , string.format (' Content (Lines %d-%d of %d):' , start_line , end_line , total_lines ))
273- table.insert (lines , string.rep ( ' ─ ' , separator_width ) )
276+ table.insert (lines , content_separator )
274277 table.insert (lines , ' ```' .. filetype )
275278 local max_line_width = string.len (tostring (end_line ))
276279 for i = start_line , end_line do
277280 local line_content = file_lines [i ] or ' '
278281 local is_target = (i == target_line )
279282 local line_num_str = string.format (' %' .. max_line_width .. ' d' , i )
280- local prefix = is_target and ' ' or ' │ '
283+ local prefix = is_target and icons . target or icons . line_separator
281284 local line_display = string.format (' %s%s %s' , prefix , line_num_str , line_content )
282285 table.insert (lines , line_display )
283286 end
284287 table.insert (lines , ' ```' )
285- table.insert (lines , string.rep ( ' ─ ' , separator_width ) )
288+ table.insert (lines , content_separator )
286289
287290 return table.concat (lines , ' \n ' )
288291end
0 commit comments