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

plugin: Add new onBufferOptionChanged callback #2962

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

JoeKar
Copy link
Collaborator

@JoeKar JoeKar commented Oct 13, 2023

With the introduction of the new callback it's possible for plugins to react upon changed buffer settings.
Especially the linter plugin will benefit by this change, since it can the properly unregister messages created with a different linter type.

Fixes #2961
Fixes #3587

@@ -66,7 +66,7 @@ function preinit()
end

makeLinter("gcc", "c", "gcc", {"-fsyntax-only", "-Wall", "-Wextra", "%f"}, "%f:%l:%c:.+: %m")
makeLinter("g++", "c++", "gcc", {"-fsyntax-only","-std=c++14", "-Wall", "-Wextra", "%f"}, "%f:%l:%c:.+: %m")
makeLinter("g++", "c++", "g++", {"-fsyntax-only","-std=c++14", "-Wall", "-Wextra", "%f"}, "%f:%l:%c:.+: %m")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Just a note: this change might be unnecessary (though will not hurt either), since it's basically the same compiler.

BTW... it might be a good idea to remove the -std=c++14 param, to support newer versions of the standard.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Removing the forced standard is a good idea, to go with the actual GCC defined defaults.

Regarding the invoked checker/compiler I had different experiences, due to the different defaults applied by gcc vs g++. Exactly this was the reason why we receive unexpected linter messages when saving a C++ file. So I really recommend to go with the explicit GNU C++ compiler for C++ files.

internal/buffer/settings.go Outdated Show resolved Hide resolved
internal/buffer/settings.go Outdated Show resolved Hide resolved
internal/buffer/settings.go Outdated Show resolved Hide resolved
internal/buffer/settings.go Outdated Show resolved Hide resolved
runtime/help/plugins.md Outdated Show resolved Hide resolved
runtime/help/plugins.md Outdated Show resolved Hide resolved
@JoeKar JoeKar force-pushed the fix/linter-ft-relation branch from 85bb039 to 33244e4 Compare December 28, 2024 20:05
@JoeKar JoeKar force-pushed the fix/linter-ft-relation branch from 33244e4 to 85e2db0 Compare December 29, 2024 12:37
@JoeKar JoeKar force-pushed the fix/linter-ft-relation branch from 85e2db0 to 11dfbf9 Compare December 29, 2024 20:03
@@ -117,6 +120,13 @@ func (b *Buffer) DoSetOptionNative(option string, nativeValue interface{}) {
if b.OptionCallback != nil {
b.OptionCallback(option, nativeValue)
}

_, err := config.RunPluginFnBool(b.Settings, "onBufferOptionChanged",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why Bool?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Since the boolean result is ignored it doesn't seem to be necessary, except the other small difference that RunPluginFnBool() checks for buffer local settings[p.Name] being unset, which RunPluginFn() doesn't. Therefore with RunPluginFnBool() the callback isn't called in plugins which are disabled after loading, while with RunPluginFn() it is...which is an inconsistency on his own.

@JoeKar JoeKar force-pushed the fix/linter-ft-relation branch from 11dfbf9 to dcf064a Compare December 30, 2024 11:53
@JoeKar JoeKar force-pushed the fix/linter-ft-relation branch from dcf064a to d1f54ea Compare December 31, 2024 12:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update C++ linter to use gcc default version of C++ Editor gets angry with C++ in Header files.
2 participants