0

I'm writing a neovim plugin.
I want json decoding to fail silently. This is what I have tried:

      partial_chunk = partial_chunk .. chunk
      pcall(function()
        -- vim.defer_fn(function()
          local data = vim.fn.json_decode(partial_chunk .. "]")
          on_next_line(data[#data].candidates[1].content.parts[1].text)
        -- end, 0)
      end)
      do_some_stuff()

This gives me the error that I can't call a vimscript function in a fast event context.
I have tried wrapping the json_decode in vim.defer_fn but that doesn't work - i start seeing the errors.

I'm looking for a way to basically ignore whenever json_decode fails.

0

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.