0

I often forget the comma between embedded table entries in lua code.

t = {
    a = { "str" },
    b = {
      {
        "str3",
        v = 1, 
      }  <<-- missing comma
      {
        ime_state,
        color = {fg = 'black', bg = '#f46868'}
      },
      ...
    },
    c = { "str1", "str2" },
},

Is there a way in vim / neovim to highlight such errors?

3
  • 2
    There is, but it's complicated and error-prone. I suggest you use an LSP server for Lua. It'll tell you all the errors in the file, not just missing comma. Check this repository: nvim-lspconfig.
    – 3N4N
    Nov 6, 2022 at 10:09
  • After installing the language server: scoop install lua-language-server and followed the instructions in help: server_configurations under sumneko_lua it works well.
    – Mattia72
    Nov 7, 2022 at 20:44
  • @Mattia72 please answer in the Answer section, not in the comments.
    – D. Ben Knoble
    Nov 8, 2022 at 18:51

1 Answer 1

0

I found the solution in help: lspconfig-server-configurations under sumneko_lua

Now I see every syntax error, while I type:

enter image description here

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.