diff options
author | Gregory Anders <greg@gpanders.com> | 2022-01-11 16:44:31 -0700 |
---|---|---|
committer | Gregory Anders <greg@gpanders.com> | 2022-01-11 16:46:42 -0700 |
commit | c915571b99d7e1ea99e29b103ca2ad37b5974027 (patch) | |
tree | 382ffe7740c43d8f174436e34008af4abd8adcc9 | |
parent | 8a27205d09405b9b040f0122e2adbd22fc29d498 (diff) | |
download | rneovim-c915571b99d7e1ea99e29b103ca2ad37b5974027.tar.gz rneovim-c915571b99d7e1ea99e29b103ca2ad37b5974027.tar.bz2 rneovim-c915571b99d7e1ea99e29b103ca2ad37b5974027.zip |
feat(diagnostic): allow retrieving current diagnostic config
-rw-r--r-- | runtime/doc/diagnostic.txt | 5 | ||||
-rw-r--r-- | runtime/lua/vim/diagnostic.lua | 10 |
2 files changed, 11 insertions, 4 deletions
diff --git a/runtime/doc/diagnostic.txt b/runtime/doc/diagnostic.txt index bb36fa46f6..19db3158be 100644 --- a/runtime/doc/diagnostic.txt +++ b/runtime/doc/diagnostic.txt @@ -334,8 +334,9 @@ config({opts}, {namespace}) *vim.diagnostic.config()* that returns any of the above. Parameters: ~ - {opts} table Configuration table with the following - keys: + {opts} table|nil When omitted or "nil", retrieve the + current configuration. Otherwise, a + configuration table with the following keys: • underline: (default true) Use underline for diagnostics. Options: • severity: Only underline diagnostics diff --git a/runtime/lua/vim/diagnostic.lua b/runtime/lua/vim/diagnostic.lua index 4bf69a2d39..b4537c2882 100644 --- a/runtime/lua/vim/diagnostic.lua +++ b/runtime/lua/vim/diagnostic.lua @@ -552,7 +552,8 @@ end --- - `table`: Enable this feature with overrides. Use an empty table to use default values. --- - `function`: Function with signature (namespace, bufnr) that returns any of the above. --- ----@param opts table Configuration table with the following keys: +---@param opts table|nil When omitted or "nil", retrieve the current configuration. Otherwise, a +--- configuration table with the following keys: --- - underline: (default true) Use underline for diagnostics. Options: --- * severity: Only underline diagnostics matching the given severity --- |diagnostic-severity| @@ -599,7 +600,7 @@ end --- global diagnostic options. function M.config(opts, namespace) vim.validate { - opts = { opts, 't' }, + opts = { opts, 't', true }, namespace = { namespace, 'n', true }, } @@ -611,6 +612,11 @@ function M.config(opts, namespace) t = global_diagnostic_options end + if not opts then + -- Return current config + return vim.deepcopy(t) + end + for k, v in pairs(opts) do t[k] = v end |