Skip to content

error on execute() when triggered from modeline in neovim #154

Open
@asdfzdfj

Description

@asdfzdfj

sample error text (slightly edited for readability):

Error detected while processing modelines[2075]
..OptionSet Autocommands for "tabstop"
..function indent_guides#process_autocmds[2]
..indent_guides#enable[8]
..indent_guides#init_script_vars[7]
..indent_guides#capture_highlight:
line    1:
E12: Command not allowed from exrc/vimrc in current dir or tag search
E12: Command not allowed from exrc/vimrc in current dir or tag search
E12: Command not allowed from exrc/vimrc in current dir or tag search

steps to reproduce (approx).:

  1. start nvim with this plugin and modeline enabled
  2. open a file containing modeline (by :e command)

looks like when this plugin is triggered from OptionSet event via modeline, it is run inside sandbox where indent_guides#capture_highlight() function errors out because execute() function is not allowed inside sandbox.

function! indent_guides#capture_highlight(group_name) abort
let l:output = execute('hi ' . a:group_name, 'silent')
let l:output = substitute(l:output, '\n', '', '')
return l:output
endfunction

one possible solution is to use some function like synIDattr() and related functions (synIDtrans(), hlID()) to directly query any needed highlight color values instead of execute()ing and parsing :highlight output.
those functions exists in regular vim for quite some time and appears to be sandbox safe, so it should be safe to use.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions