From b4f2c3fe919669aca20c5cb8ee3c0b19ead42192 Mon Sep 17 00:00:00 2001 From: Frank LENORMAND Date: Fri, 29 May 2020 14:39:39 +0300 Subject: [PATCH] rc lint: Remove the concept of "enabling" linting This commit renames `lint-enable` into `lint-show-diagnostics`, makes it hidden, and calls it automatically after diagnostics have been recovered by `:lint-cleaned-selections`. The `lint-disable` command becomes `lint-hide-diagnostics`. The concept of "enabling" diagnostics was inherited from the Clang support script, but in that case it's not clear why calling `:lint` should do the work but not render it (similarly to `:spell`). The `lint-show` command was also renamed into a more descriptive `lint-show-current-line`. --- rc/tools/lint.kak | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/rc/tools/lint.kak b/rc/tools/lint.kak index 20875a23..6f239556 100644 --- a/rc/tools/lint.kak +++ b/rc/tools/lint.kak @@ -207,7 +207,7 @@ define-command \ "lint failed, see *debug* for details" else # No errors detected, show the results. - printf "eval -client %s lint-show-counters" \ + printf "eval -client %s 'lint-show-diagnostics; lint-show-counters'" \ "$kak_client" fi | kak -p "$kak_session" @@ -291,7 +291,7 @@ define-command \ alias global lint lint-buffer -define-command -hidden lint-show %{ +define-command -hidden lint-show-current-line %{ update-option buffer lint_messages evaluate-commands %sh{ # This is going to come in handy later. @@ -320,13 +320,16 @@ define-command -hidden lint-show-counters %{ echo -markup "linting results: {Error} %opt{lint_error_count} error(s) {Information} %opt{lint_warning_count} warning(s) " } -define-command lint-enable -docstring "Activate automatic diagnostics of the code" %{ - add-highlighter window/lint flag-lines default lint_flags - hook window -group lint-diagnostics NormalIdle .* %{ lint-show } - hook window -group lint-diagnostics WinSetOption lint_flags=.* %{ info; lint-show } +define-command -hidden lint-show-diagnostics %{ + try %{ + # Assume that if the highlighter is set, then hooks also are + add-highlighter window/lint flag-lines default lint_flags + hook window -group lint-diagnostics NormalIdle .* %{ lint-show-current-line } + hook window -group lint-diagnostics WinSetOption lint_flags=.* %{ info; lint-show-current-line } + } } -define-command lint-disable -docstring "Disable automatic diagnostics of the code" %{ +define-command lint-hide-diagnostics -docstring "Hide line markers and disable automatic diagnostic displaying" %{ remove-highlighter window/lint remove-hooks window lint-diagnostics }