diff --git a/lua/LspUI/_meta.lua b/lua/LspUI/_meta.lua index 82ed4cf..fdbaaac 100644 --- a/lua/LspUI/_meta.lua +++ b/lua/LspUI/_meta.lua @@ -14,7 +14,12 @@ --- @field command_enable boolean whether enable command for `lightbulb` --- @field key_binding { exec: string, prev: string, next: string, quit: string } keybind for `code_action` +--- @class LspUI_diagnostic +--- @field enable boolean whether enable `diagnostic` module +--- @field command_enable boolean whether enable command for `diagnostic` + --- @class LspUI_config config for LspUI --- @field rename LspUI_rename_config `rename` module --- @field lightbulb LspUI_lightbulb_config `lightbulb` module --- @field code_action LspUI_code_action_config `code_action` module +--- @field diagnostic LspUI_diagnostic `diagnostic` module diff --git a/lua/LspUI/command.lua b/lua/LspUI/command.lua index 709afb5..3d6a89e 100644 --- a/lua/LspUI/command.lua +++ b/lua/LspUI/command.lua @@ -60,7 +60,7 @@ end -- this function register command --- @param command_key string --- @param run function ---- @param args table +--- @param args string[] M.register_command = function(command_key, run, args) command_store[command_key] = command_store[command_key] or {} command_store[command_key].run = run diff --git a/lua/LspUI/config.lua b/lua/LspUI/config.lua index a317b80..7026f68 100644 --- a/lua/LspUI/config.lua +++ b/lua/LspUI/config.lua @@ -31,12 +31,19 @@ local default_code_action_config = { }, } +--- @type LspUI_diagnostic +local default_diagnostic = { + enable = true, + command_enable = true, +} + -- default config --- @type LspUI_config local default_config = { rename = default_rename_config, lightbulb = default_lightbulb_config, code_action = default_code_action_config, + diagnostic = default_diagnostic, } -- Prevent plugins from being initialized multiple times diff --git a/lua/LspUI/diagnostic/init.lua b/lua/LspUI/diagnostic/init.lua new file mode 100644 index 0000000..3f94581 --- /dev/null +++ b/lua/LspUI/diagnostic/init.lua @@ -0,0 +1,26 @@ +local config = require("LspUI.config") +local M = {} + +-- whether this module has initialized +local is_initialized = false + +-- init for diagnostic +M.init = function() + if not config.options.diagnostic.enable then + return + end + if is_initialized then + return + end + + is_initialized = true +end + +--- @param arg "next"|"prev" +M.run = function(arg) + if not config.options.diagnostic.enable then + return + end +end + +return M diff --git a/lua/LspUI/diagnostic/util.lua b/lua/LspUI/diagnostic/util.lua new file mode 100644 index 0000000..5044d6f --- /dev/null +++ b/lua/LspUI/diagnostic/util.lua @@ -0,0 +1,3 @@ +local M = {} + +return M