d2-vim icon indicating copy to clipboard operation
d2-vim copied to clipboard

Error on startup after install (`BufReadPost Autocommands` `d2#syntax_post` `Undefined variable: b:included_syntaxes`)

Open gitaarik opened this issue 1 year ago • 1 comments

I just added the plugin in my Nvchad nvim config, and I'm getting this error when I open a .d2 file:

Error detected while processing BufReadPost Autocommands for "*.d2"..FileType Autocommands for "*"..Syntax Autocommands for "d2"..function d2#syntax_post:
line    1:
E121: Undefined variable: b:included_syntaxes
E116: Invalid arguments for function index
Press ENTER or type command to continue

After pressing enter, the syntax highlighting is actually working.

If I close nvim again, then first open a file with a different file type, for example a .md file, I don't get an error. And when I then open the .d2 file in a second buffer, I still don't get an error, but the syntax is not working. When I enter :e! I do get the error again, and then afterwards the syntax highlighting is also working again.

gitaarik avatar Aug 20 '24 06:08 gitaarik

After reading #11 I fixed the issue by adding ft = { "d2" } to my plugin config:

{
  "terrastruct/d2-vim",
  ft = { "d2" },
}

I think this should be able to configure into the plugin itself?

gitaarik avatar Aug 20 '24 07:08 gitaarik