Skip to content

Error when a fenced language's syntax file locks a variable #227

@wchargin

Description

@wchargin

In stock NVIM v0.11.4, if g:markdown_fenced_languages includes "java", and a Java file is opened, an error is raised. It seems that the "java" script runs :lockvar on a script-local variable, and so re-running the script causes this failure (prettified):

Error detected while processing command line..
FileType Autocommands for "*"..
Syntax Autocommands for "*"..
function <SNR>5_SynSet[26]..
script /tmp/demo/nvim-linux-x86_64/share/nvim/runtime/syntax/java.vim[420]..
command line..
FileType Autocommands for "*"..
Syntax Autocommands for "*"..
function <SNR>5_SynSet[26]..
script /tmp/demo/nvim-linux-x86_64/share/nvim/runtime/syntax/java.vim[393]..
/tmp/demo/nvim-linux-x86_64/share/nvim/runtime/syntax/markdown.vim[36]..
/tmp/demo/nvim-linux-x86_64/share/nvim/runtime/syntax/java.vim:
line  175:
E741: Value is locked: s:with_html

The relevant portion of java.vim (lines 175–177) is:

let s:with_html = !exists("g:java_ignore_html")
let s:with_markdown = !exists("g:java_ignore_markdown")
lockvar s:with_html s:with_markdown

…so it makes sense that it's not safe to re-run.

I'm reporting this here because of the note in the repo README that says, "Generally you don't need to install these if you are running a recent version of Vim." But I'm not sure if you'd consider this an issue with vim-markdown, with the Java syntax definitions, or something else. What do you think?

(Thanks so much for this plugin and all your other work! I am a decade-long happy user. :-) )


Full clean repro:

$ curl -fsSLO 'https://github.com/neovim/neovim/releases/latest/download/nvim-linux-x86_64.tar.gz'
$ tar xf ./nvim-linux-x86_64.tar.gz
$ ./nvim-linux-x86_64/bin/nvim --version
NVIM v0.11.4
Build type: Release
LuaJIT 2.1.1741730670
Run "nvim -V1 -v" for more info
$ ./nvim-linux-x86_64/bin/nvim -u NORC +':redir >errlog' +':let g:markdown_fenced_languages = ["java"]' +':set ft=java' +:q >/dev/null 2>&1
$ cat errlog; echo

Error detected while processing command line..FileType Autocommands for "*"..Syntax Autocommands for "*"..function <SNR>5_SynSet[26]..script /tmp/demo/nvim-linux-x86_64/share/nvim/runtime/syntax/java.vim[420]..command line..FileType Autocommands for "*"..Syntax Autocommands for "*"..function <SNR>5_SynSet[26]..script /tmp/demo/nvim-linux-x86_64/share/nvim/runtime/syntax/java.vim[393]../tmp/demo/nvim-linux-x86_64/share/nvim/runtime/syntax/markdown.vim[36]../tmp/demo/nvim-linux-x86_64/share/nvim/runtime/syntax/java.vim:
line  175:
E741: Value is locked: s:with_html

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions