Remove ANSI color codes from nix linter messages (#4944)
Some checks failed
CI / build_image (push) Has been cancelled
CI / test_ale (--linters-only) (push) Has been cancelled
CI / test_ale (--lua-only) (push) Has been cancelled
CI / test_ale (--neovim-07-only) (push) Has been cancelled
CI / test_ale (--neovim-08-only) (push) Has been cancelled
CI / test_ale (--vim-80-only) (push) Has been cancelled
CI / test_ale (--vim-90-only) (push) Has been cancelled

* Remove ANSI color codes from nix linter messages

* Add test for color-coded nix linter findings

* Fix test: Escape backslashes

---------

Co-authored-by: Sebastian Neuser <sebastian.neuser@fnordkollektiv.de>
Co-authored-by: Sebastian Neuser <haggl@sineband.de>
This commit is contained in:
PizZaKatZe
2025-04-07 13:23:13 +02:00
committed by GitHub
parent 2883260ade
commit 22185c4c5c
2 changed files with 17 additions and 1 deletions

View File

@@ -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

View File

@@ -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
\ [