micro icon indicating copy to clipboard operation
micro copied to clipboard

Help to toggle lint gutter

Open Gavin-Holt opened this issue 1 year ago • 1 comments

Hi,

I am trying to toggle the display of the lint gutter, using a keyboard shortcut.

Taking a lead from the ever helpful dmaluka (https://github.com/zyedidia/micro/issues/2086#issuecomment-826351299) I have the following Lua code:

function lint_toggle(Current)
    local val = Current.Buf.Settings["linter"]
    if val then
        Current:HandleCommand("setlocal linter off")
    else
        Current:HandleCommand("setlocal linter on")
        Current:HandleCommand("lint")
    end
end

This does not work, and I suspect I am testing the wrong setting.

Reading the source of the linter plugin has not enlightened me.

Does anyone know how to test if the lint gutter is displayed?

Kind Regards Gavin Holt

Version: 2.0.14-dev.253 Commit hash: 37379791 Compiled on August 18, 2024

Microsoft Windows [Version 10.0.19045.4651] Terminal: cmd.exe 10.0.19041.4355 (WinBuild.160101.0800)

Gavin-Holt avatar Aug 20 '24 11:08 Gavin-Holt

ClearAllMessages() can be used to clear all linter messages from the gutter. It is not "toggle" though: it permanently removes the messages, not just hides them.

dmaluka avatar Aug 20 '24 17:08 dmaluka

Hi

Many thanks. I have a function to clear all highlighting and have added bp.Buf:ClearAllMessages() to remove the gutter.

function unmark(bp)
-- Hides all the found string highlighting and the gutter
    bp:UnhighlightSearch()
    bp.Buf:ClearAllMessages()
end

Kind Regards Gavin Holt

Gavin-Holt avatar Sep 03 '24 12:09 Gavin-Holt