From ae339dc3c4351f73cb34102b63c4798fe229f4e4 Mon Sep 17 00:00:00 2001 From: Dimitar Dimitrov Date: Tue, 1 Nov 2016 20:31:24 +0000 Subject: [PATCH 1/4] Use %~~ for delimiting to avoid issues with braces in the message --- rc/base/lint.kak | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/rc/base/lint.kak b/rc/base/lint.kak index 86f4543d5..696532bc8 100644 --- a/rc/base/lint.kak +++ b/rc/base/lint.kak @@ -48,7 +48,9 @@ def lint -docstring 'Parse the current buffer with a linter' %{ } END { print "set \"buffer=" file "\" lint_flags %{" stamp ":" substr(flags, 1, length(flags)-1) "}" - print "set \"buffer=" file "\" lint_errors %{" substr(errors, 1, length(errors)-1) "}" + errors = substr(errors, 1, length(errors)-1) + gsub("~", "\\~", errors) + print "set \"buffer=" file "\" lint_errors %~" errors "~" } ' "$dir"/stderr | kak -p "$kak_session" From 05f7ab7568ba11f39d1c68d6294599cc2773e612 Mon Sep 17 00:00:00 2001 From: Dimitar Dimitrov Date: Wed, 2 Nov 2016 12:42:35 +0000 Subject: [PATCH 2/4] lint-prev --- rc/base/lint.kak | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/rc/base/lint.kak b/rc/base/lint.kak index 696532bc8..392d8dc40 100644 --- a/rc/base/lint.kak +++ b/rc/base/lint.kak @@ -23,7 +23,7 @@ def lint -docstring 'Parse the current buffer with a linter' %{ { # do the parsing in the background and when ready send to the session - eval "$kak_opt_lintcmd '$dir'/buf" | sort -t: -k2 -n > "$dir"/stderr + eval "$kak_opt_lintcmd '$dir'/buf" | sort -t: -k2,2 -n > "$dir"/stderr printf '%s\n' "eval -client $kak_client echo 'linting done'" | kak -p "$kak_session" # Flags for the gutter: @@ -100,3 +100,27 @@ def lint-next -docstring "Jump to the next line that contains an error" %{ %sh{ printf '%s\n' "select $candidate.$col,$candidate.$col" } }} + +def lint-prev -docstring "Jump to the previous line that contains an error" %{ %sh{ + printf '%s\n' "$kak_opt_lint_errors" | sort -t, -k1,1 -rn | { + while read -r line + do + # get line,column pair + coords="${line%,*}" + candidate="${coords%,*}" + if [ "$candidate" -lt "$kak_cursor_line" ] + then + break + fi + done + if [ "$candidate" -lt "$kak_cursor_line" ] + then + col="${coords#*,}" + else + last=$(printf '%s\n' "$kak_opt_lint_errors" | tail -n1) + candidate=$(printf '%s\n' "$last" | cut -d, -f1) + col=$(printf '%s\n' "$last" | cut -d, -f2) + fi + printf '%s\n' "select $candidate.$col,$candidate.$col" + } +}} From 9a87e7fdff79ce625601e69a17a5ba02a00880eb Mon Sep 17 00:00:00 2001 From: Dimitar Dimitrov Date: Wed, 2 Nov 2016 14:18:38 +0000 Subject: [PATCH 3/4] Use same idiom as for lint-next --- rc/base/lint.kak | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/rc/base/lint.kak b/rc/base/lint.kak index 392d8dc40..11af5b2d0 100644 --- a/rc/base/lint.kak +++ b/rc/base/lint.kak @@ -105,8 +105,7 @@ def lint-prev -docstring "Jump to the previous line that contains an error" %{ % printf '%s\n' "$kak_opt_lint_errors" | sort -t, -k1,1 -rn | { while read -r line do - # get line,column pair - coords="${line%,*}" + coords=$(printf %s "$line" | cut -d, -f1,2) candidate="${coords%,*}" if [ "$candidate" -lt "$kak_cursor_line" ] then From c5ebd5e30345dfab88e431a06ca88ca0b0cbe128 Mon Sep 17 00:00:00 2001 From: Dimitar Dimitrov Date: Wed, 2 Nov 2016 17:00:04 +0000 Subject: [PATCH 4/4] Remove since it gets overwritten by the NormalIdle hook + $kak_cursor_line will always be 1 as that runs in a temporary context for the window --- rc/base/lint.kak | 1 - 1 file changed, 1 deletion(-) diff --git a/rc/base/lint.kak b/rc/base/lint.kak index 11af5b2d0..ff3a8b479 100644 --- a/rc/base/lint.kak +++ b/rc/base/lint.kak @@ -70,7 +70,6 @@ def -hidden lint-show %{ %sh{ def lint-enable -docstring "Activate automatic diagnostics of the code" %{ addhl flag_lines default lint_flags hook window -group lint-diagnostics NormalIdle .* %{ lint-show } - hook window -group lint-diagnostics WinSetOption ^lint_errors=.* %{ info; lint-show } } def lint-disable -docstring "Disable automatic diagnostics of the code" %{