Skip to content

Commit

Permalink
feat: add enable_update_available_warning config
Browse files Browse the repository at this point in the history
This option allows disabling the update_available warning diagnostic.
  • Loading branch information
elkowar committed Oct 6, 2023
1 parent 86b31c9 commit 1dcdee0
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 12 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ require('crates').setup {
max_parallel_requests = 80,
open_programs = { "xdg-open", "open" },
disable_invalid_feature_diagnostic = false,
enable_update_available_warning = true,
text = {
loading = "  Loading",
version = "  %s",
Expand Down
10 changes: 9 additions & 1 deletion doc/crates.txt
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ For more information about individual config options see |crates-config|.
max_parallel_requests = 80,
open_programs = { "xdg-open", "open" },
disable_invalid_feature_diagnostic = false,
enable_update_available_warning = true,
text = {
loading = "  Loading",
version = "  %s",
Expand Down Expand Up @@ -562,6 +563,13 @@ disable_invalid_feature_diagnostic
https://github.com/Saecki/crates.nvim/issues/14


*crates-config-enable_update_available_warning*
enable_update_available_warning
Type: `boolean`, Default: `true`

Enable warnings for outdated crates.


text *crates-config-text*
Type: `section`

Expand Down Expand Up @@ -1480,4 +1488,4 @@ CmpItemKindFeature *crates-hl-CmpItemKindFeature*
Default: links to |Special|


vim:tw=78:ts=8:ft=help:norl:
vim:tw=78:ts=8:ft=help:norl:
9 changes: 9 additions & 0 deletions lua/crates/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ local M = {Config = {TextConfig = {}, HighlightConfig = {}, DiagnosticConfig = {






local Config = M.Config
Expand Down Expand Up @@ -372,6 +373,14 @@ entry(M.schema, "disable_invalid_feature_diagnostic", {
]],
})

entry(M.schema, "enable_update_available_warning", {
type = "boolean",
default = true,
description = [[
Enable warnings for outdated crates.
]],
})


entry(M.schema, "text", {
type = "section",
Expand Down
12 changes: 7 additions & 5 deletions lua/crates/diagnostic.lua
Original file line number Diff line number Diff line change
Expand Up @@ -265,12 +265,14 @@ function M.process_api_crate(crate, api_crate)
end
end

table.insert(diagnostics, crate_diagnostic(
crate,
"vers_upgrade",
vim.diagnostic.severity.WARN,
"vers"))
if state.cfg.enable_update_available_warning then
table.insert(diagnostics, crate_diagnostic(
crate,
"vers_upgrade",
vim.diagnostic.severity.WARN,
"vers"))

end

if match then

Expand Down
9 changes: 9 additions & 0 deletions teal/crates/config.tl
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ local record M
open_programs: {string}
max_parallel_requests: integer
disable_invalid_feature_diagnostic: boolean
enable_update_available_warning: boolean
text: TextConfig
highlight: HighlightConfig
diagnostic: DiagnosticConfig
Expand Down Expand Up @@ -372,6 +373,14 @@ entry(M.schema, "disable_invalid_feature_diagnostic", {
]],
})

entry(M.schema, "enable_update_available_warning", {
type = "boolean",
default = true,
description = [[
Enable warnings for outdated crates.
]],
})


entry(M.schema, "text", {
type = "section",
Expand Down
14 changes: 8 additions & 6 deletions teal/crates/diagnostic.tl
Original file line number Diff line number Diff line change
Expand Up @@ -265,12 +265,14 @@ function M.process_api_crate(crate: toml.Crate, api_crate: Crate): CrateInfo, {D
end
end

table.insert(diagnostics, crate_diagnostic(
crate,
"vers_upgrade",
vim.diagnostic.severity.WARN,
"vers"
))
if state.cfg.enable_update_available_warning then
table.insert(diagnostics, crate_diagnostic(
crate,
"vers_upgrade",
vim.diagnostic.severity.WARN,
"vers"
))
end

if match then
-- found a match
Expand Down

0 comments on commit 1dcdee0

Please sign in to comment.