Skip to content

Commit 2701d06

Browse files
committed
fix(lint): respect opts.enabled_at_start
1 parent 543dc84 commit 2701d06

1 file changed

Lines changed: 15 additions & 6 deletions

File tree

lua/peter/plugins/core/lint.lua

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,16 @@ return {
5959
config = function(_, opts)
6060
local lint = require("lint")
6161

62-
-- Resolve `opts`.
63-
local config = vim.tbl_deep_extend("force", {}, {
62+
---@type peter.lint.Opts
63+
local defaults = {
6464
events = { "BufReadPost", "BufWritePost", "InsertLeave" },
6565
linters_by_ft = {},
6666
linters = {},
6767
enabled_at_start = true,
68-
}, opts or {})
68+
}
69+
70+
-- Resolve `opts`.
71+
local config = vim.tbl_deep_extend("force", {}, defaults, opts or {})
6972

7073
-- Set linter properties.
7174
for name, properties in pairs(config.linters) do
@@ -159,11 +162,17 @@ return {
159162

160163
local group = require("peter.util.autocmds").augroup("Linting")
161164

162-
if config.enabled then
165+
-- Stores current state of linting.
166+
--
167+
-- As mentioned below, I want to refactor some of this.
168+
local is_enabled = false
169+
170+
if config.enabled_at_start then
163171
vim.api.nvim_create_autocmd(config.events, {
164172
group = group,
165173
callback = callback,
166174
})
175+
is_enabled = true
167176
end
168177

169178
local all_linters = vim
@@ -201,10 +210,10 @@ return {
201210
end
202211
end
203212

204-
config.enabled = state
213+
is_enabled = state
205214
end,
206215
get = function()
207-
return config.enabled
216+
return is_enabled
208217
end,
209218
})
210219
:map("<leader>ul")

0 commit comments

Comments
 (0)