Treesitter highlight error when opening init.vim

I get this error when opening my init vim. I know it happens when treesitter highlight is enabled and it runs across some lua code in my init.vim like a :lua block or a call to a lua function inside a vim function. so putting these lines will cause the error:

:lua << EOF 
EOF

It can also occur when a vim function calls a lua function like so:

function! RunLSPFormatter()
    lua vim.lsp.buf.formatting_seq_sync()
endfunction

The error:

Error detected while processing BufReadPost Autocommands for "*":
Error executing lua callback: C:\tools\neovim\nvim-win64\share\nvim\runtime\filetype.lua:24: Error executing lua: C:\too
ls\neovim\nvim-win64\share\nvim\runtime\filetype.lua:25: BufReadPost Autocommands for "*"..FileType Autocommands for "*"
: Vim(append):Error executing lua callback: ...im-win64\share\nvim\runtime/lua/vim/treesitter/query.lua:259: query: inva
lid structure at position 3154 for language lua
stack traceback:
        [C]: in function '_ts_parse_query'
        ...im-win64\share\nvim\runtime/lua/vim/treesitter/query.lua:259: in function 'get'
        ...4\share\nvim\runtime/lua/vim/treesitter/languagetree.lua:114: in function 'new'
        ...4\share\nvim\runtime/lua/vim/treesitter/languagetree.lua:365: in function 'add_child'
        ...4\share\nvim\runtime/lua/vim/treesitter/languagetree.lua:294: in function 'parse'
        ...vim\nvim-win64\share\nvim\runtime/lua/vim/treesitter.lua:89: in function '_create_parser'
        ...vim\nvim-win64\share\nvim\runtime/lua/vim/treesitter.lua:131: in function 'get_parser'
        ...vim\nvim-win64\share\nvim\runtime/lua/vim/treesitter.lua:460: in function 'start'
        ...lugged\nvim-treesitter/lua/nvim-treesitter/highlight.lua:20: in function 'attach'
        ...\plugged\nvim-treesitter/lua/nvim-treesitter/configs.lua:509: in function 'attach_module'
        ...\plugged\nvim-treesitter/lua/nvim-treesitter/configs.lua:532: in function 'reattach_module'
        ...\plugged\nvim-treesitter/lua/nvim-treesitter/configs.lua:133: in function <...\plugged\nvim-treesitter/lua/nv
im-treesitter/configs.lua:132>
        [C]: in function 'nvim_cmd'
        C:\tools\neovim\nvim-win64\share\nvim\runtime\filetype.lua:25: in function <C:\tools\neovim\nvim-win64\share\nvi
m\runtime\filetype.lua:24>
        [C]: in function 'nvim_buf_call'
        C:\tools\neovim\nvim-win64\share\nvim\runtime\filetype.lua:24: in function <C:\tools\neovim\nvim-win64\share\nvi
m\runtime\filetype.lua:10>
stack traceback:
        [C]: in function 'nvim_cmd'
        C:\tools\neovim\nvim-win64\share\nvim\runtime\filetype.lua:25: in function <C:\tools\neovim\nvim-win64\share\nvi
m\runtime\filetype.lua:24>
        [C]: in function 'nvim_buf_call'
        C:\tools\neovim\nvim-win64\share\nvim\runtime\filetype.lua:24: in function <C:\tools\neovim\nvim-win64\share\nvim\runtime\filetype.lua:10>
stack traceback:
        [C]: in function 'nvim_buf_call'
        C:\tools\neovim\nvim-win64\share\nvim\runtime\filetype.lua:24: in function <C:\tools\neovim\nvim-win64\share\nvim\runtime\filetype.lua:10>