Skip to content

Commit 72c6983

Browse files
fix: vim.diagnostic.disable is deprecated (#499)
1 parent 010766c commit 72c6983

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

lua/diffview/vcs/file.lua

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ local pl = lazy.access(utils, "path") ---@type PathLib
1515
local api = vim.api
1616
local M = {}
1717

18+
local HAS_NVIM_0_10 = vim.fn.has("nvim-0.10") == 1
19+
1820
---@alias git.FileDataProducer fun(kind: vcs.FileKind, path: string, pos: "left"|"right"): string[]
1921

2022
---@class CustomFolds
@@ -355,7 +357,11 @@ function File:attach_buffer(force, opt)
355357

356358
-- Diagnostics
357359
if state.disable_diagnostics then
358-
vim.diagnostic.disable(self.bufnr)
360+
if HAS_NVIM_0_10 then
361+
vim.diagnostic.enable(false, { bufnr = self.bufnr })
362+
else
363+
vim.diagnostic.disable(self.bufnr)
364+
end
359365
end
360366

361367
File.attached[self.bufnr] = state
@@ -382,7 +388,11 @@ function File:detach_buffer()
382388

383389
-- Diagnostics
384390
if state.disable_diagnostics then
385-
vim.diagnostic.enable(self.bufnr)
391+
if HAS_NVIM_0_10 then
392+
vim.diagnostic.enable(true, { bufnr = self.bufnr })
393+
else
394+
vim.diagnostic.enable(self.bufnr)
395+
end
386396
end
387397

388398
File.attached[self.bufnr] = nil

0 commit comments

Comments
 (0)