Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Error when processing modelines when noice is installed #71

Closed
MariaSolOs opened this issue Aug 16, 2023 · 14 comments
Closed

[Bug]: Error when processing modelines when noice is installed #71

MariaSolOs opened this issue Aug 16, 2023 · 14 comments
Labels
bug Something isn't working

Comments

@MariaSolOs
Copy link
Contributor

Description

When opening a file that has a modeline, strange things happen when opening/closing buffers. Moreover, I see the following error in my debug logs:

Error detected while processing nvim_exec2()..modelines[1365]..OptionSet Autocommands for "filetype":
E12: Command not allowed in secure mode in current dir or tag search
Executing OptionSet Autocommands for "*"
autocommand <Lua 310: ~/.local/share/nvim/lazy/dropbar.nvim/lua/dropbar.lua:70>

Disclaimer that this happens when using this plugin with noice, and so it might not be this plugin's fault. However, the error logs point to this plugin, so I'll start with creating the issue here.

nvim version

v0.10.0-dev-836+g6d93bdd45

dropbar.nvim version

c47d764

Operating system and version

macOS Ventura 13.5

Minimal config

local lazypath = vim.fn.stdpath('data') .. '/lazy/lazy.nvim'
if not vim.loop.fs_stat(lazypath) then
  vim.fn.system({
    'git',
    'clone',
    '--filter=blob:none',
    'https://github.com/folke/lazy.nvim.git',
    '--branch=stable', -- latest stable release
    lazypath,
  })
end
vim.opt.rtp:prepend(lazypath)

require('lazy').setup({
  { 'Bekaboo/dropbar.nvim', config = true },
  { 'folke/noice.nvim', dependencies = 'MunifTanjim/nui.nvim', config = true },
})

-- I'm sorry for not using the given template. I've only used lazy.nvim for
-- my nvim config and I truly wanted to provide a tested minimal config
-- that reproduces the error.

Steps to reproduce

  1. Save the configuration file above under minimal.lua.
  2. In the same directory, create a file with the following content:
A text file.

 vim:tw=78:ts=8:sw=2:et:ft=help:norl:
  1. Open Neovim with nvim --clean -u minimal.lua test.txt
  2. Type :h help
  3. Notice how Noice's command line get's stuck.
  4. Exit Neovim with qa. Repeat step 4 but opening Neovim with nvim --clean -u minimal.lua test.txt -V10mynvim.log
  5. Open mynvim.log and search for Error.
  6. Notice the errors about incorrectly processing autocommands from this plugin.

Expected behavior

For Neovim to behave as expected when using dropbar and noice.

Actual behavior

noice's command line gets stuck.

Additional information

No response

@MariaSolOs MariaSolOs added the bug Something isn't working label Aug 16, 2023
@Bekaboo
Copy link
Owner

Bekaboo commented Aug 16, 2023

Please use the minimal config provided, do NOT use a plugin manager, it makes things harder to track.

@MariaSolOs
Copy link
Contributor Author

@Bekaboo okay, I'm sorry. This configuration should work then:

local tmp = vim.env.TMPDIR or vim.env.TEMPDIR or vim.env.TMP or vim.env.TEMP or '/tmp'
local data = tmp .. '/' .. (vim.env.NVIM_APPNAME or 'nvim')
local packages_root = data .. '/site'
local cloned_root = packages_root .. '/pack/packages/start'
local plugins = {
  { url = 'https://github.com/Bekaboo/dropbar.nvim.git', path = 'dropbar.nvim' },
  { url = 'https://github.com/MunifTanjim/nui.nvim.git', path = 'nui.nvim' },
  { url = 'https://github.com/folke/noice.nvim.git', path = 'noice.nvim' },
}

vim.fn.mkdir(cloned_root, 'p')
vim.opt.pp:prepend(packages_root)
vim.opt.rtp:prepend(packages_root)

for _, plugin in ipairs(plugins) do
  local url = plugin.url
  local path = plugin.path
  local cloned_path = cloned_root .. '/' .. path
  if not vim.loop.fs_stat(cloned_path) then
    vim.fn.system({ 'git', 'clone', url, cloned_path })
  end
end

require('dropbar').setup()
require('noice').setup()

@MariaSolOs
Copy link
Contributor Author

I again to emphasize how I'm not trying to point any fingers here and that I'm aware that noice is an experimental plugin that might break stuff. I've had a solid experience with your plugin and I really admire the clean API you've constructed.

I'm just trying to better understand the issue :)

@Bekaboo
Copy link
Owner

Bekaboo commented Aug 16, 2023

I again to emphasize how I'm not trying to point any fingers here and that I'm aware that noice is an experimental plugin that might break stuff. I've had a solid experience with your plugin and I really admire the clean API you've constructed.

Take it easy, I'm here to help people. Using the default minimal repro config just make the procedure easier and more efficient.

However I cannot reproduce the error on my side:

nvim

Could you double check if the minimal config is correct?

@MariaSolOs
Copy link
Contributor Author

MariaSolOs commented Aug 16, 2023

@Bekaboo very interesting. I can reproduce the issue from my side:

Screen.Recording.2023-08-15.at.7.55.45.PM.mov

Not sure if it makes a difference, but could you try pressing <Tab> to trigger autocompletion? That is, try :h he<Tab>

@Bekaboo
Copy link
Owner

Bekaboo commented Aug 16, 2023

@MariaSolOs Sorry, forgot to use proper modeline when I test. 😕

However, after adding the modeline the result is the same:

nvim

@MariaSolOs
Copy link
Contributor Author

@Bekaboo what about if you hit Tab when in command line mode and open the completion menu?

@Bekaboo
Copy link
Owner

Bekaboo commented Aug 16, 2023

what about if you hit Tab when in command line mode and open the completion menu?

Result:

nvim

Interesting... I think it is better to report it to noice.nvim

@MariaSolOs
Copy link
Contributor Author

@Bekaboo that's fair. At least you can reproduce it now and I'm not going insane 😂

What are your thoughts on the autocommand error messages though? I'm not an expert in modelines and when they should be updated/ignored with autocommands, but is the one that's triggering the error expected?

@Bekaboo
Copy link
Owner

Bekaboo commented Aug 16, 2023

What are your thoughts on the autocommand error messages though?

Not sure why, but from my experience noice.nvim uses lots of hacks and is prone to cause issues for other (UI) plugins.

I am considering adding an option to configure the triggering events and patterns that calls the attach() function, see #70, after that has landed you can disable the OptionSet event which can (possibly) solve the issue.

@MariaSolOs
Copy link
Contributor Author

@Bekaboo alright. I'll wait for #70 to land and try it out. If it doesn't fix this issue, I'll open one in noice.

Thank you for your help and I'm sorry for wasting your time <3

@Bekaboo
Copy link
Owner

Bekaboo commented Aug 27, 2023

@MariaSolOs #70 has landed, now you can control attach events through opts.general.attach_events, please let me know if it works for you if it is convenient to you.

@MariaSolOs
Copy link
Contributor Author

@Bekaboo I confirm that removing 'OptionSet' from attach_events fixes the issue. I'm not too sure if this disables some important functionality though.

@willothy
Copy link
Collaborator

willothy commented Oct 6, 2023

Maybe it would be better to use FileType instead of OptionSet? OptionSet is called a lot (and sometimes repeatedly), so it might make more sense to attach only when filetype is set instead of any option. Not sure if this would fix the issue with noice but it is possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants