supermaven-inc / supermaven-nvim

The official Neovim plugin for Supermaven
https://supermaven.com/
MIT License
279 stars 16 forks source link

feat(#18): add `silence_info` and created `logger` to write to a log file #27

Closed AlejandroSuero closed 2 weeks ago

AlejandroSuero commented 1 month ago

Changes made

Demo of the changes

https://github.com/supermaven-inc/supermaven-nvim/assets/71392160/0be8797b-d6fa-4cb2-b6bd-beae5c57539b

https://github.com/supermaven-inc/supermaven-nvim/assets/71392160/d3300bde-9a8d-420d-9dd3-3a85187f479a

How to use the logger

  1. Import the logger local log = require("supermaven-nvim.logger").
  2. Decide which level of information you want the user to see.
    • Levels:
    • "error": Always shows.
    • "warn": Always shows.
    • "info": Always shows. (like print)
    • "debug": shows if debug is true.
    • "trace": shows if silence_info is true.
    • "off": logger turned off completely log_level option is set too "off".
  3. If you have them set to debug = true or/and silenced info, :SupermavenShowLog to show the log file with timestamps and the level off error.
  4. If you want to reset or clear the log file, :SupermavenClearLog.

Closes #18 Closes #42

joaomendoncaa commented 2 weeks ago

Hey @sm-victorw, if you could take a look at this PR to potentially move it forward it would be amazing since it solves both #42 and #4 (which are both small but annoying quirks).

Sorry for the bump but it was in hopes you had custom notifications and this wasn't on your backlog.

Appreciate your time.

sm-victorw commented 2 weeks ago

@AlejandroSuero would it be possible to have the verbosity for the logger controlled through a single config option, particularly log_level? Having 3 separate boolean values to control what get printed feels rather unintuitive.

I have in mind that e.g. log_level taking values "off", "silent", "warn", or "debug" or something similar would be more manageable

AlejandroSuero commented 2 weeks ago

@sm-victorw I made the changes so now it just needs to be

-- supermaven opts
{
  keymaps = {
    -- ...
  },
  log_level = "off" -- based on `vim.log.levels[log_level:upper()]`
}

if off silence all expect warnings and errors.