From 7f9e24cdbfbe1be777bfcbac0aec24d2407ab670 Mon Sep 17 00:00:00 2001 From: Frank LENORMAND Date: Tue, 22 Nov 2016 10:56:17 +0300 Subject: [PATCH] Remove `flake8.kak`, deprecated by `lint.kak` Builtin support for `flake8` can be obtained using the following: ``` set window lintcmd 'flake8 --filename=* --format="%(path)s:%(row)d:%(col)d: error: %(text)s"' ``` --- rc/extra/flake8.kak | 87 --------------------------------------------- 1 file changed, 87 deletions(-) delete mode 100644 rc/extra/flake8.kak diff --git a/rc/extra/flake8.kak b/rc/extra/flake8.kak deleted file mode 100644 index 76229124..00000000 --- a/rc/extra/flake8.kak +++ /dev/null @@ -1,87 +0,0 @@ -decl str flake8_options -decl -hidden str flake8_tmp_dir -decl -hidden line-flags flake8_flags -decl -hidden str flake8_errors - -def flake8-lint -docstring "Lint the contents of the current buffer" %{ - %sh{ - dir=$(mktemp -d -t kak-flake8.XXXXXXXX) - mkfifo ${dir}/fifo - echo "set buffer flake8_tmp_dir ${dir}" - echo "eval -no-hooks write ${dir}/buf" - } - - # end the previous %sh{} so that its output gets interpreted by kakoune - # before launching the following as a background task. - %sh{ - dir=${kak_opt_flake8_tmp_dir} - echo "eval -draft %{ - edit! -fifo ${dir}/fifo *flake8-output* - set buffer filetype make - set buffer _make_current_error_line 0 - hook -group fifo buffer BufCloseFifo .* %{ - nop %sh{ rm -r ${dir} } - rmhooks buffer fifo - } - }" - # this runs in a detached shell, asynchronously, so that kakoune does - # not hang while flake8 is running. - ( - flake8 --ignore=${kak_opt_flake8_options} - < ${dir}/buf > ${dir}/stderr - flags=$(cat ${dir}/stderr | sed -rne " - /^stdin:[0-9]+:[0-9]+:? (W|F|C|N).*/ { s/^stdin:([0-9]+):.*/\1|{yellow}█/; p } - /^stdin:[0-9]+:[0-9]+:? E.*/ { s/^stdin:([0-9]+):.*/\1|{red}█/; p } - " | paste -s -d ':') - errors=$(cat ${dir}/stderr | sed -rne " - /^stdin:[0-9]+:[0-9]+:?.*/ { s/^stdin:([0-9]+):([0-9]+:)? (.*) /\1,\3/; s/'/\\\\'/g; p } - " | sort -n) - - sed -e "s||${kak_bufname}|g" < ${dir}/stderr > ${dir}/fifo - echo "set 'buffer=${kak_buffile}' flake8_flags %{${kak_timestamp}:${flags}} - set 'buffer=${kak_buffile}' flake8_errors '${errors}'" | kak -p ${kak_session} - ) > /dev/null 2>&1 < /dev/null & - } -} - -def -hidden flake8-show-error-info %{ %sh{ - desc=$(printf %s\\n "${kak_opt_flake8_errors}" | sed -ne "/^${kak_cursor_line},.*/ { s/^[[:digit:]]\+,//g; s/'/\\\\'/g; p }") - if [ -n "$desc" ]; then - echo "info -anchor ${kak_cursor_line}.${kak_cursor_column} '${desc}'" - fi -} } - -def flake8-enable-diagnostics -docstring "Activate automatic diagnostics of the code" %{ - addhl flag_lines default flake8_flags - hook window -group flake8-diagnostics NormalIdle .* %{ flake8-show-error-info } -} - -def flake8-disable-diagnostics -docstring "Disable automatic diagnostics of the code" %{ - rmhl hlflags_flake8_flags - rmhooks window flake8-diagnostics -} - -def flake8-diagnostics-next -docstring "Jump to the next line that contains an error" %{ %sh{ - printf "%s\n" "${kak_opt_flake8_errors}" | ( - line=-1 - first_line=-1 - while read line_content; do - candidate=${line_content%%,*} - if [ -n "$candidate" ]; then - if [ $first_line -eq -1 ]; then - first_line=$candidate - fi - if [ $candidate -gt $kak_cursor_line ]; then - if [ $candidate -lt $line ] || [ $line -eq -1 ]; then - line=$candidate - fi - fi - fi - done - if [ $line -eq -1 ]; then - line=$first_line - echo 'echo -color Error no next flake8 diagnostic' - else - echo "exec ${line} g" - fi - ) -}}