diff options
Diffstat (limited to 'lua/lvim')
| -rw-r--r-- | lua/lvim/core/builtins/init.lua | 1 | ||||
| -rw-r--r-- | lua/lvim/core/log.lua | 57 | ||||
| -rw-r--r-- | lua/lvim/core/notify.lua | 31 | ||||
| -rw-r--r-- | lua/lvim/plugins.lua | 5 | 
4 files changed, 69 insertions, 25 deletions
| diff --git a/lua/lvim/core/builtins/init.lua b/lua/lvim/core/builtins/init.lua index 8f83072e..315deed3 100644 --- a/lua/lvim/core/builtins/init.lua +++ b/lua/lvim/core/builtins/init.lua @@ -15,6 +15,7 @@ local builtins = {    "lvim.core.bufferline",    "lvim.core.autopairs",    "lvim.core.comment", +  "lvim.core.notify",    "lvim.core.lualine",  } diff --git a/lua/lvim/core/log.lua b/lua/lvim/core/log.lua index 502fd19b..557590e1 100644 --- a/lua/lvim/core/log.lua +++ b/lua/lvim/core/log.lua @@ -1,6 +1,7 @@  local Log = {}  local logfile = string.format("%s/%s.log", vim.fn.stdpath "cache", "lvim") +local in_headless = #vim.api.nvim_list_uis() == 0  Log.levels = {    TRACE = 1, @@ -33,7 +34,7 @@ function Log:init()    nvim_notify_params_injecter(nil, {})    local log_level = Log.levels[(lvim.log.level):upper() or "WARN"] -  structlog.configure { +  local lvim_log = {      lvim = {        sinks = {          structlog.sinks.Console(log_level, { @@ -49,25 +50,6 @@ function Log:init()              { level = structlog.formatters.FormatColorizer.color_level() }            ),          }), -        structlog.sinks.NvimNotify(Log.levels.INFO, { -          processors = { -            nvim_notify_default_namer, -            nvim_notify_params_injecter, -          }, -          formatter = structlog.formatters.Format( -- -            "%s", -            { "msg" }, -            { blacklist_all = true } -          ), -          params_map = { -            icon = "icon", -            keep = "keep", -            on_open = "on_open", -            on_close = "on_close", -            timeout = "timeout", -            title = "title", -          }, -        }),          structlog.sinks.File(Log.levels.TRACE, logfile, {            processors = {              structlog.processors.Namer(), @@ -83,12 +65,39 @@ function Log:init()      },    } +  if not in_headless and lvim.builtin.notify.active then +    table.insert( +      lvim_log.lvim.sinks, +      structlog.sinks.NvimNotify(Log.levels.INFO, { +        processors = { +          nvim_notify_default_namer, +          nvim_notify_params_injecter, +        }, +        formatter = structlog.formatters.Format( -- +          "%s", +          { "msg" }, +          { blacklist_all = true } +        ), +        params_map = { +          icon = "icon", +          keep = "keep", +          on_open = "on_open", +          on_close = "on_close", +          timeout = "timeout", +          title = "title", +        }, +      }) +    ) +  end + +  structlog.configure(lvim_log) +    local logger = structlog.get_logger "lvim" -  if lvim.log.override_notify then +  if not in_headless and lvim.builtin.notify.active and lvim.log.override_notify then      -- Overwrite vim.notify to use the logger      vim.notify = function(msg, vim_log_level, opts) -      nvim_notify_params = opts or {} +      nvim_notify_params = vim.tbl_deep_extend("force", lvim.builtin.notify.opts, opts)        -- vim_log_level can be omitted        if vim_log_level == nil then          vim_log_level = Log.levels["INFO"] @@ -109,7 +118,7 @@ end  ---@param level string [same as vim.log.log_levels]  function Log:add_entry(level, msg, event)    if self.__handle then -    self.__handle:log(level, msg, event) +    self.__handle:log(level, vim.inspect(msg), event)      return    end @@ -119,7 +128,7 @@ function Log:add_entry(level, msg, event)    end    self.__handle = logger -  self.__handle:log(level, msg, event) +  self.__handle:log(level, vim.inspect(msg), event)  end  ---Retrieves the path of the logfile diff --git a/lua/lvim/core/notify.lua b/lua/lvim/core/notify.lua new file mode 100644 index 00000000..7d222a89 --- /dev/null +++ b/lua/lvim/core/notify.lua @@ -0,0 +1,31 @@ +local M = {} + +function M.config() +  local pallete = require "onedarker.palette" +  lvim.builtin.notify = { +    active = false, +    on_config_done = nil, +    -- TODO: update after https://github.com/rcarriga/nvim-notify/pull/24 +    opts = { +      ---@usage Animation style (see below for details) +      stages = "fade_in_slide_out", + +      ---@usage Default timeout for notifications +      timeout = 5000, + +      ---@usage For stages that change opacity this is treated as the highlight behind the window +      background_colour = pallete.fg, + +      ---@usage Icons for the different levels +      icons = { +        ERROR = "", +        WARN = "", +        INFO = "", +        DEBUG = "", +        TRACE = "✎", +      }, +    }, +  } +end + +return M diff --git a/lua/lvim/plugins.lua b/lua/lvim/plugins.lua index a178eba5..976e5141 100644 --- a/lua/lvim/plugins.lua +++ b/lua/lvim/plugins.lua @@ -8,7 +8,10 @@ return {    {      "williamboman/nvim-lsp-installer",    }, -  { "rcarriga/nvim-notify" }, +  { +    "rcarriga/nvim-notify", +    disable = not lvim.builtin.notify.active, +  },    { "Tastyep/structlog.nvim" },    { "nvim-lua/popup.nvim" }, | 
