0

In Neovim I want to jump through Python traceback in the quickfix list.

To do that, I set the following option

:set errorformat+=%.%#File\ \"%f\"\\,\ line\ %l%.%#

and this works well.

What I would like now is to add this command in my init.lua, But when I add the previous line, neovim raises errors when I populate the quickfix List. This is my COMPLETE init.lua file:

vim.opt.errorformat:append { "%.%#File \"%f\"\\, line %l%.%#" }

With this config file, when I populate a quickfix list with a command:

:cex system('ls -al')

Neovim raises the following error:

E377: Invalid %- in format string

It seems neovim doesn't like the '%' character because when I set the following line vim.opt.errorformat:append('foo%f') in my init.lua, neovim raises the same error.

Do you know how to append a new string to errorformat?

edit: rephrased my message

7
  • I can't reproduce your problem with Neovim 0.9.5. Could you tell us what is the version of Neovim you are using (:version)? Apr 5 at 12:57
  • Hello, I am using neovim v0.8.2. I will try with a newer version.
    – Fabz
    Apr 7 at 20:49
  • 1
    I tried with 0.9.5 and I still have this issue.
    – Fabz
    Apr 7 at 21:19
  • Thanks for the feedback. It seems we are stuck. I have tried different approach to reproduce the problem but I fail. Could you share a minimal init.lua file where the problem occurs? Apr 8 at 8:52
  • Thank you for helping me. My config:(neovim 0.9.4) I deleted everything in ~/.local/share/nvim and in ~/.config/nvim. I created a simple init.lua with : vim.opt.errorformat:append { "%.%#File \"%f\"\\, line %l%.%#" } When I open nvim I execute the following command: :cex system('ls -al') When I press Enter, neovim prints: E377: Invalid %- in format string When I open quickfix list it is empty Of course, if I execute the same ex-command with nvim --noplugin --clean, the command works perfectly.
    – Fabz
    Apr 9 at 7:32

1 Answer 1

0

The conversion requires to know how how both call convert the string to the option:

set errorformat+=%.%#File\ \"%f\"\\,\ line\ %l%.%#

Set the errorformat to: %.%#File "%f"\, line %l%.%#

  • The needs to be escaped
  • The " needs to be escaped
  • The \ needs to be escaped

To set the errorformat to the same value in lua you have to do:

vim.opt.errorformat="%.%#File \"%f\"\\, line %l%.%#"
  • The " needs to be escaped
  • The \ needs to be escaped

For parsing Python stack I personally use:

set errorformat=%A\ %#File\ \"%f\"\\,\ line\ %l\\,\ in\ %o,%Z\ %#%m
5
  • 1
    Hello, Thank you. It's working, Unfortunately I don't want to set a new value to errorformat variable, I want to append a new value to errorformat.
    – Fabz
    Apr 15 at 7:20
  • I can't reproduce your problem :-/ Now I'm suspecting it is is because I don't have the same initial value. Maybe could you add it to the question? I'm also interested about why you want to append? What do you expect from the original value in this context? Apr 15 at 8:16
  • Hello, What happens if you create a init.lua with only this line vim.opt.errorformat:append {"%.%#File \"%f\"\\, line %l%.%#"} and then you execute the following ex-command : :cex system('ls -al') ? Does neovim raise an error E377 ?
    – Fabz
    Apr 16 at 20:28
  • I run on Windows 10 so I can't reproduce the exact same setup. But if I use MSYS64 to get access to ls no, indeed, I can't reproduce your behavior :-| Apr 17 at 6:46
  • 1
    Hi ! Thank you for your answers, Ok, I am not going further on this issue, I think I will use :compiler pyunit or just setting errorformat instead of appending errorformat
    – Fabz
    Apr 18 at 19:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.