Skip to content

Commit

Permalink
add config and meta for diagnstic module
Browse files Browse the repository at this point in the history
  • Loading branch information
jinzhongjia committed Aug 9, 2023
1 parent 65bdb50 commit 9915ca2
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 1 deletion.
5 changes: 5 additions & 0 deletions lua/LspUI/_meta.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion lua/LspUI/command.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions lua/LspUI/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
26 changes: 26 additions & 0 deletions lua/LspUI/diagnostic/init.lua
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions lua/LspUI/diagnostic/util.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
local M = {}

return M

0 comments on commit 9915ca2

Please sign in to comment.