diff --git a/doc/gitsigns.txt b/doc/gitsigns.txt index 99a85e0..05ce8e0 100644 --- a/doc/gitsigns.txt +++ b/doc/gitsigns.txt @@ -526,13 +526,6 @@ use_internal_diff *gitsigns-config-use_internal_diff* This uses LuaJIT's FFI interface. -use_decoration_api *gitsigns-config-use_decoration_api* - Type: `boolean`, Default: `true` - - Use Neovim's decoration API to apply signs. This should improve - performance on large files since signs will only be applied to drawn - lines as opposed to all lines in the buffer. - current_line_blame *gitsigns-config-current_line_blame* Type: `boolean`, Default: `false` diff --git a/lua/gitsigns.lua b/lua/gitsigns.lua index 73072fb..b24b117 100644 --- a/lua/gitsigns.lua +++ b/lua/gitsigns.lua @@ -418,25 +418,23 @@ M.setup = void(function(cfg) setup_command() - if config.use_decoration_api then - api.nvim_set_decoration_provider(namespace, { - on_win = function(_, _, bufnr, top, bot) - local bcache = cache[bufnr] - if not bcache or not bcache.pending_signs then - return false - end - manager.apply_win_signs(bufnr, bcache.pending_signs, top + 1, bot + 1) + api.nvim_set_decoration_provider(namespace, { + on_win = function(_, _, bufnr, top, bot) + local bcache = cache[bufnr] + if not bcache or not bcache.pending_signs then + return false + end + manager.apply_win_signs(bufnr, bcache.pending_signs, top + 1, bot + 1) - return config.word_diff and config.use_internal_diff - end, - on_line = function(_, _, bufnr, row) - manager.apply_word_diff(bufnr, row) - end, - }) - end + return config.word_diff and config.use_internal_diff + end, + on_line = function(_, _, bufnr, row) + manager.apply_word_diff(bufnr, row) + end, + }) git.enable_yadm = config.yadm.enable git.set_version(config._git_version) diff --git a/lua/gitsigns/config.lua b/lua/gitsigns/config.lua index 50f0ff5..7be4e04 100644 --- a/lua/gitsigns/config.lua +++ b/lua/gitsigns/config.lua @@ -60,7 +60,6 @@ local M = {Config = {SignsConfig = {}, watch_index = {}, current_line_blame_form - M.config = {} @@ -353,16 +352,6 @@ M.schema = { ]], }, - use_decoration_api = { - type = 'boolean', - default = true, - description = [[ - Use Neovim's decoration API to apply signs. This should improve - performance on large files since signs will only be applied to drawn - lines as opposed to all lines in the buffer. - ]], - }, - current_line_blame = { type = 'boolean', default = false, @@ -560,9 +549,18 @@ local function resolve_default(v) end end +local function handle_deprecated(cfg) + if cfg.use_decoration_api then + print('Gitsigns: use_decoration_api is now removed; ignoring') + cfg.use_decoration_api = nil + end +end + function M.build(user_config) user_config = user_config or {} + handle_deprecated(user_config) + validate_config(user_config) local config = M.config diff --git a/lua/gitsigns/manager.lua b/lua/gitsigns/manager.lua index 9ee83d6..6394a38 100644 --- a/lua/gitsigns/manager.lua +++ b/lua/gitsigns/manager.lua @@ -43,14 +43,9 @@ function M.apply_win_signs(bufnr, pending, top, bot) local first_apply = top == nil - if config.use_decoration_api then - top = top or vim.fn.line('w0') - bot = bot or vim.fn.line('w$') - else - top = top or 1 - bot = bot or vim.fn.line('$') - end + top = top or vim.fn.line('w0') + bot = bot or vim.fn.line('w$') local scheduled = {} @@ -72,9 +67,7 @@ function M.apply_win_signs(bufnr, pending, top, bot) - if config.use_decoration_api then - schedule_sign(next(pending)) - end + schedule_sign(next(pending)) end signs.add(config, bufnr, scheduled) diff --git a/teal/gitsigns.tl b/teal/gitsigns.tl index 9d679a3..9b9a21a 100644 --- a/teal/gitsigns.tl +++ b/teal/gitsigns.tl @@ -418,25 +418,23 @@ M.setup = void(function(cfg: Config) setup_command() - if config.use_decoration_api then - -- Calling this before any await calls will stop nvim's intro messages being - -- displayed - api.nvim_set_decoration_provider(namespace, { - on_win = function(_, _, bufnr: integer, top: integer, bot: integer): boolean - local bcache = cache[bufnr] - if not bcache or not bcache.pending_signs then - return false - end - manager.apply_win_signs(bufnr, bcache.pending_signs, top+1, bot+1) - - -- Returning false prevents the on_line callbacks - return config.word_diff and config.use_internal_diff - end, - on_line = function(_, _, bufnr: integer, row: integer) - manager.apply_word_diff(bufnr, row) + -- Calling this before any await calls will stop nvim's intro messages being + -- displayed + api.nvim_set_decoration_provider(namespace, { + on_win = function(_, _, bufnr: integer, top: integer, bot: integer): boolean + local bcache = cache[bufnr] + if not bcache or not bcache.pending_signs then + return false end - }) - end + manager.apply_win_signs(bufnr, bcache.pending_signs, top+1, bot+1) + + -- Returning false prevents the on_line callbacks + return config.word_diff and config.use_internal_diff + end, + on_line = function(_, _, bufnr: integer, row: integer) + manager.apply_word_diff(bufnr, row) + end + }) git.enable_yadm = config.yadm.enable git.set_version(config._git_version) diff --git a/teal/gitsigns/config.tl b/teal/gitsigns/config.tl index 54438a8..342095e 100644 --- a/teal/gitsigns/config.tl +++ b/teal/gitsigns/config.tl @@ -46,7 +46,6 @@ local record M preview_config: {string:any} attach_to_untracked: boolean use_internal_diff: boolean - use_decoration_api: boolean record yadm enable: boolean @@ -353,16 +352,6 @@ M.schema = { ]] }, - use_decoration_api = { - type = 'boolean', - default = true, - description = [[ - Use Neovim's decoration API to apply signs. This should improve - performance on large files since signs will only be applied to drawn - lines as opposed to all lines in the buffer. - ]] - }, - current_line_blame = { type = 'boolean', default = false, @@ -560,9 +549,18 @@ local function resolve_default(v: SchemaElem): any end end +local function handle_deprecated(cfg: {string:any}) + if cfg.use_decoration_api then + print('Gitsigns: use_decoration_api is now removed; ignoring') + cfg.use_decoration_api = nil + end +end + function M.build(user_config: {string:any}) user_config = user_config or {} + handle_deprecated(user_config) + validate_config(user_config) local config = M.config as {string:any} diff --git a/teal/gitsigns/manager.tl b/teal/gitsigns/manager.tl index 6d5ab91..82edbce 100644 --- a/teal/gitsigns/manager.tl +++ b/teal/gitsigns/manager.tl @@ -43,14 +43,9 @@ function M.apply_win_signs(bufnr: integer, pending: {integer:Sign}, top: integer -- clearing all the signs local first_apply = top == nil - if config.use_decoration_api then - -- Just apply to signs visible in window - top = top or vim.fn.line('w0') - bot = bot or vim.fn.line('w$') - else - top = top or 1 - bot = bot or vim.fn.line('$') - end + -- Just apply to signs visible in window + top = top or vim.fn.line('w0') + bot = bot or vim.fn.line('w$') local scheduled: {integer:Sign} = {} @@ -72,9 +67,7 @@ function M.apply_win_signs(bufnr: integer, pending: {integer:Sign}, top: integer -- added but none of them are visible in the window, then make sure to add at -- least one sign. Only do this on the first call after an update when we all -- the signs have been cleared. - if config.use_decoration_api then - schedule_sign(next(pending)) - end + schedule_sign(next(pending)) end signs.add(config, bufnr, scheduled) diff --git a/test/gitsigns_spec.lua b/test/gitsigns_spec.lua index fb8a2c5..7d85082 100644 --- a/test/gitsigns_spec.lua +++ b/test/gitsigns_spec.lua @@ -303,11 +303,10 @@ describe('gitsigns', function() end) end) - local function testsuite(advanced_features) + local function testsuite(internal_diff) return function() before_each(function() - config.use_decoration_api = advanced_features - config.use_internal_diff = advanced_features + config.use_internal_diff = internal_diff setup_test_repo() end) @@ -460,11 +459,11 @@ describe('gitsigns', function() p'run_job: git .* show :0:newfile.txt' } - if not advanced_features then + if not internal_diff then table.insert(messages, p'run_job: git .* diff .* /tmp/lua_.* /tmp/lua_.*') end - local jobs = advanced_features and 8 or 9 + local jobs = internal_diff and 8 or 9 table.insert(messages, "update(1): updates: 1, jobs: "..jobs) match_debug_messages(messages)