1
1
mirror of https://github.com/mawww/kakoune.git synced 2024-11-27 02:23:26 +03:00

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`.
This commit is contained in:
Frank LENORMAND 2020-05-29 14:39:39 +03:00
parent aad20f6576
commit b4f2c3fe91

View File

@ -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
}