aboutsummaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorAdam <adamdharrison@gmail.com>2021-12-05 14:42:18 -0500
committerGitHub <noreply@github.com>2021-12-05 14:42:18 -0500
commit5a75d5d56349fa7d97ceb7c478fdbf96795e89fc (patch)
tree3ce71a84a826612bb21cae12ea2359e0f9ada6cb /plugins
parent505594adf5cef63a1487735ce4a5654532863643 (diff)
parent0652077a2532038483f487e5c925d9ba697bac75 (diff)
downloadlite-xl-plugins-5a75d5d56349fa7d97ceb7c478fdbf96795e89fc.tar.gz
lite-xl-plugins-5a75d5d56349fa7d97ceb7c478fdbf96795e89fc.zip
Merge pull request #100 from jminor/minimap_highlight
Minimap highlights selection & caret position
Diffstat (limited to 'plugins')
-rw-r--r--plugins/minimap.lua18
1 files changed, 18 insertions, 0 deletions
diff --git a/plugins/minimap.lua b/plugins/minimap.lua
index b129f40..2c383b8 100644
--- a/plugins/minimap.lua
+++ b/plugins/minimap.lua
@@ -16,6 +16,13 @@ config.plugins.minimap = {
-- how many spaces one tab is equivalent to
tab_width = 4,
draw_background = true,
+
+ -- you can override these colors
+ selection_color = nil,
+ caret_color = nil,
+
+ -- If other plugins provide per-line highlights,
+ -- this controls the placement. (e.g. gitdiff_highlight)
highlight_align = 'left',
highlight_width = 3,
gutter_width = 5,
@@ -222,6 +229,17 @@ DocView.draw_scrollbar = function(self)
-- draw visual rect
renderer.draw_rect(x, visible_y, w, scroller_height, visual_color)
+ -- highlight the selected lines, and the line with the caret on it
+ local selection_color = config.plugins.minimap.selection_color or style.dim
+ local caret_color = config.plugins.minimap.caret_color or style.caret
+ local selection_line, selection_col, selection_line2, selection_col2 = self.doc:get_selection()
+ local selection_y = y + (selection_line - minimap_start_line) * line_spacing
+ local selection2_y = y + (selection_line2 - minimap_start_line) * line_spacing
+ local selection_min_y = math.min(selection_y, selection2_y)
+ local selection_h = math.abs(selection2_y - selection_y)+1
+ renderer.draw_rect(x, selection_min_y, w, selection_h, selection_color)
+ renderer.draw_rect(x, selection_y, w, line_spacing, caret_color)
+
local highlight_align = config.plugins.minimap.highlight_align
local highlight_width = config.plugins.minimap.highlight_width
local gutter_width = config.plugins.minimap.gutter_width