jujutsu file annotations for neovim (like blame)
4

Configure Feed

Select the types of activity you want to include in your feed.

make line highlighting configurable

Signed-off-by: Ron Shavit <me@ronshavit.com>

Ron Shavit (May 27, 2026, 1:56 AM +0300) 2738d4bd 564b141a

+53 -33
+6 -1
README.md
··· 22 22 ```lua 23 23 -- config is absolutely optional, no `.setup()` needed 24 24 vim.g.jjannotate_opts = { 25 - -- disable any mapping by settings it to `nil` 25 + view = { 26 + -- whether to highlight all lines changed by cursor's change id 27 + highlight_lines = true, 28 + }, 29 + -- disable any mapping by setting it to `false` 26 30 mappings = { 31 + -- close the annotation window 27 32 close = "q", 28 33 }, 29 34 }
+11 -1
lua/jjannotate.lua
··· 1 1 ---@class jjannotate.Opts 2 + ---@field view jjannotate.Opts.View 2 3 ---@field mappings jjannotate.Opts.Mappings 3 4 5 + ---@class jjannotate.Opts.View 6 + ---@field highlight_lines boolean 7 + 4 8 ---@class jjannotate.Opts.Mappings 5 - ---@field close string | nil 9 + ---@field close string | false 6 10 7 11 ---@type jjannotate.Opts 8 12 local defaults = { 13 + view = { 14 + -- whether to highlight all lines changed by cursor's change id 15 + highlight_lines = true, 16 + }, 17 + -- disable any mapping by setting it to `false` 9 18 mappings = { 19 + -- close the annotation window 10 20 close = "q", 11 21 }, 12 22 }
+36 -31
lua/jjannotate/view.lua
··· 17 17 ---@field original_opts table<string, any> 18 18 ---@field parsed jjannotate.ParseResult? 19 19 ---@field ns integer 20 + ---@field ns_hl integer 21 + ---@field augroup integer 20 22 21 23 local View = {} 22 24 View.__index = View ··· 139 141 ) 140 142 end 141 143 142 - self:_autocmds() 144 + self:_autocmds(opts) 143 145 144 146 if self.original then 145 147 vim.api.nvim_win_set_cursor(self.win, { vim.api.nvim_win_get_cursor(self.original.win)[1], 0 }) ··· 148 150 vim.cmd.syncbind() 149 151 end 150 152 151 - function View:_autocmds() 152 - local function cursor_moved() 153 - local row = vim.api.nvim_win_get_cursor(self.win)[1] - 1 154 - local change_id = self.parsed.row_index[row].change_id 155 - local lines = self.parsed.change_id_index[change_id] 156 - local dim_hl = hl_cache[change_id].dim 153 + ---@param opts jjannotate.Opts 154 + function View:_autocmds(opts) 155 + if opts.view.highlight_lines then 156 + local function cursor_moved() 157 + local row = vim.api.nvim_win_get_cursor(self.win)[1] - 1 158 + local change_id = self.parsed.row_index[row].change_id 159 + local lines = self.parsed.change_id_index[change_id] 160 + local dim_hl = hl_cache[change_id].dim 157 161 158 - vim.api.nvim_buf_clear_namespace(self.buf, self.ns_hl, 0, -1) 159 - vim.api.nvim_buf_clear_namespace(self.original.buf, self.ns_hl, 0, -1) 162 + vim.api.nvim_buf_clear_namespace(self.buf, self.ns_hl, 0, -1) 163 + vim.api.nvim_buf_clear_namespace(self.original.buf, self.ns_hl, 0, -1) 160 164 161 - for _, line in ipairs(lines) do 162 - vim.api.nvim_buf_set_extmark(self.buf, self.ns_hl, line.range.start, 0, { 163 - end_row = line.range._end + 1, 164 - hl_group = dim_hl, 165 - hl_eol = true, 166 - strict = false, 167 - }) 168 - vim.api.nvim_buf_set_extmark(self.original.buf, self.ns_hl, line.range.start, 0, { 169 - end_row = line.range._end + 1, 170 - hl_group = dim_hl, 171 - hl_eol = true, 172 - strict = false, 173 - }) 165 + for _, line in ipairs(lines) do 166 + vim.api.nvim_buf_set_extmark(self.buf, self.ns_hl, line.range.start, 0, { 167 + end_row = line.range._end + 1, 168 + hl_group = dim_hl, 169 + hl_eol = true, 170 + strict = false, 171 + }) 172 + vim.api.nvim_buf_set_extmark(self.original.buf, self.ns_hl, line.range.start, 0, { 173 + end_row = line.range._end + 1, 174 + hl_group = dim_hl, 175 + hl_eol = true, 176 + strict = false, 177 + }) 178 + end 174 179 end 175 - end 176 180 177 - vim.api.nvim_create_autocmd("CursorMoved", { 178 - group = self.augroup, 179 - buffer = self.buf, 180 - callback = vim.schedule_wrap(cursor_moved), 181 - }) 182 - 183 - if self.original then 184 181 vim.api.nvim_create_autocmd("CursorMoved", { 185 182 group = self.augroup, 186 - buffer = self.original.buf, 183 + buffer = self.buf, 187 184 callback = vim.schedule_wrap(cursor_moved), 188 185 }) 186 + 187 + if self.original then 188 + vim.api.nvim_create_autocmd("CursorMoved", { 189 + group = self.augroup, 190 + buffer = self.original.buf, 191 + callback = vim.schedule_wrap(cursor_moved), 192 + }) 193 + end 189 194 end 190 195 191 196 vim.api.nvim_create_autocmd({ "BufHidden", "BufUnload" }, {