ansible-vim
ansible-vim copied to clipboard
E995 Error When Opening Ansible YAML Files
Bug Report: E995 Error When Opening Ansible YAML Files
Description
When opening an Ansible YAML file in Neovim, the following error occurs:
Error detected while processing BufReadPost Autocommands for "*/ansible/*.yml"..FileType Autocommands for "*"..Syntax Autocommands for "*"..function
<SNR>32_SynSet
[26]..script syntax/ansible.vim:
line 21:
E995: Cannot modify existing variable
E995: Cannot modify existing variable
This prevents proper syntax highlighting and editing of Ansible files.
Steps to Reproduce
- Install the ansible-vim plugin in Neovim (e.g., via lazy.nvim or similar).
- Open any YAML file located in a directory containing "ansible" in the path (e.g., /ansible/.yml).
- The error appears immediately upon opening the file.
Environment
• Neovim version: (please specify, e.g., NVIM v0.9.4) • OS: Linux • Plugin version: Latest from https://github.com/pearofducks/ansible-vim
Root Cause
The issue is on line 21 of syntax/ansible.vim:
const builtin_modules_file = expand("
The const keyword is vim9script syntax, but the file uses legacy Vim script. This causes redefinition errors when the syntax file is sourced multiple times.
Suggested Fix
Change const to let on line 21:
let builtin_modules_file = expand("
This allows the variable to be reassigned if the file is sourced multiple times, resolving the E995 error.