summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxime Coste <frrrwww@gmail.com>2016-11-02 22:47:45 +0000
committerMaxime Coste <frrrwww@gmail.com>2016-11-02 22:47:45 +0000
commit9ca0467c4d568b2c8fd1f35d549957f08ab27a13 (patch)
tree781730111c87ce28ca0d7e824a20497e06274436
parent4d222bbb335bcf04e5af3b37cfb6b870c5a9f423 (diff)
parentc5ebd5e30345dfab88e431a06ca88ca0b0cbe128 (diff)
Merge remote-tracking branch 'kurkale6ka/lint_explicit'
-rw-r--r--rc/base/lint.kak30
1 files changed, 27 insertions, 3 deletions
diff --git a/rc/base/lint.kak b/rc/base/lint.kak
index 86f4543d..ff3a8b47 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:
@@ -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"
@@ -68,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" %{
@@ -98,3 +99,26 @@ 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
+ coords=$(printf %s "$line" | cut -d, -f1,2)
+ 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"
+ }
+}}