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

Ignore netrw buffers #213

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions plugin/editorconfig.vim
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,11 @@ function! s:ApplyConfig(config) abort " Set the buffer options {{{1
return
endif

" Do not process netrw buffers
if &b:filetype == 'netrw'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are global and local options [1]. There are no 'buffer' options. This is a syntax error that yields

E113: Unknown option: b

Unfortunately, this error is hidden by the try-catch from the call site.

@pmeinhardt Please have a look. Maybe a change to &l is sufficient? I could not reproduce your original problem and therefore don't know if this is the right fix.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Filed #215 for better visibility.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the catch -- I opened #216 to fix this.

Copy link
Contributor Author

@pmeinhardt pmeinhardt Mar 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @kaihowl ❤️ Unfortunately with the change from #216 the problem re-appeared. 🤔

Copy link
Contributor

@kaihowl kaihowl Mar 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is indeed unfortunate.

I can even reproduce this with nerdtree instead of netrw. There already is a condition that should take care of not messing non-editable buffers. Nerdtree for example hijacks the FileExplorer event group and instead sets the necessary options, including buftype, as part of a new set of autocommands. These are sequenced after the editorconfig autocommands (or more precisely: they happen later in my setup, yet there is no guarantee of ordering AFAIK). Therefore, the buftype appears as editable when editorconfig sees it. The final value is of course nofile.

I am not an expert on autocommands. Therefore, my proposal for a fix is rather hacky: #217

return
endif

if g:EditorConfig_verbose
echo 'Options: ' . string(a:config)
endif
Expand Down