diff --git a/ale_linters/nix/nix.vim b/ale_linters/nix/nix.vim index 5d80f652..8d41cb7b 100644 --- a/ale_linters/nix/nix.vim +++ b/ale_linters/nix/nix.vim @@ -29,7 +29,7 @@ function! ale_linters#nix#nix#Handle(buffer, lines) abort \ 'type': 'E', \ 'lnum': l:result.line, \ 'col': l:result.column, - \ 'text': l:result.raw_msg + \ 'text': substitute(l:result.raw_msg, '\e\[[0-9;]*m', '', 'g'), \}) endif endif diff --git a/test/handler/test_nix_handler.vader b/test/handler/test_nix_handler.vader index ee02fef2..56d88b29 100644 --- a/test/handler/test_nix_handler.vader +++ b/test/handler/test_nix_handler.vader @@ -27,6 +27,22 @@ Execute(The nix handler should parse nix-instantiate error messages correctly): \ "@nix {\"unrelated\":\"message\"}" \ ]) +Execute(The nix handler should parse nix-instantiate error messages with ANSI color codes correctly): + AssertEqual + \ [ + \ { + \ 'lnum': 3, + \ 'col': 5, + \ 'type': 'E', + \ 'text': "undefined variable 'foo'", + \ }, + \ + \ ], + \ ale_linters#nix#nix#Handle(bufnr(''), [ + \ "@nix {\"line\":3,\"column\":5,\"raw_msg\":\"undefined variable '\\u001b[35;1mfoo\\u001b[0m'\"}", + \ "@nix {\"unrelated\":\"message\"}" + \ ]) + Execute(The nix handler should parse message from old nix-instantiate correctly): AssertEqual \ [