From 05f7ab7568ba11f39d1c68d6294599cc2773e612 Mon Sep 17 00:00:00 2001 From: Dimitar Dimitrov Date: Wed, 2 Nov 2016 12:42:35 +0000 Subject: [PATCH] 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 696532bc..392d8dc4 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" + } +}}