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

[Feature Request] Keybindings depending on the filetype #2518

Open
raidenXR opened this issue Aug 1, 2022 · 2 comments
Open

[Feature Request] Keybindings depending on the filetype #2518

raidenXR opened this issue Aug 1, 2022 · 2 comments

Comments

@raidenXR
Copy link
Contributor

raidenXR commented Aug 1, 2022

Keybindings depending on the filetype to have build actions and quickfix plugin work together nicely

Depending on the file type, it might be better to bind the same key to a different command.
I.e with quickfix, depending on the filetype the user might want to execute a different command.
I know about chaining commands with ,, |, &` but that's not the same thing.
The snippet below raises some error when running micro

"*.cs": {
    "F5": "command:fexec dotnet build",
    "Shift-F5": "command:fexec dotnet test",
    },
"*.zig": {
    "F5": "command:fexec zig build",
    "F7": "command:fexec zig ast-check {f}",
    "Shift-F5": "command:fexec zig test {f}",
},

Error

Micro encountered an error: runtime.errorString runtime error: invalid memory address or nil pointer dereference
/usr/lib/golang/src/runtime/panic.go:212 (0x55f1979d3273)
/usr/lib/golang/src/runtime/panic.go:211 (0x55f1979d30f3)
/builddir/build/BUILD/micro-2.0.8/_build/src/github.com/zyedidia/micro/internal/action/bindings.go:88 (0x55f197ed9cbf)
/builddir/build/BUILD/micro-2.0.8/_build/src/github.com/zyedidia/micro/internal/action/bindings.go:70 (0x55f197ed96d7)
/builddir/build/BUILD/micro-2.0.8/_build/src/github.com/zyedidia/micro/cmd/micro/micro.go:318 (0x55f197f15eea)
/usr/lib/golang/src/runtime/proc.go:204 (0x55f1979bfbe9)
/usr/lib/golang/src/runtime/asm_amd64.s:1374 (0x55f1979f34a1)
@raidenXR raidenXR changed the title Keybindings depending on the filetype [Feature Request] Keybindings depending on the filetype Aug 1, 2022
@raidenXR
Copy link
Contributor Author

raidenXR commented Aug 1, 2022

With chaining i.e

"F5": "command:fexec make|command:fexec dotnet build|command:fexec zig build",
"F7": "command:fexec zig ast-check {f}",
"Shift-F5": "command:fexec zig test {f}|command:fexec dotnet test"

things get really weird in case of the quickfix plugin, when binding build action is desired.
If it is possible to implement the alternative, then build actions would be much more straightforward

"*.cs": {
    "F5": "command:fexec dotnet build",
    "Shift-F5": "command:fexec dotnet test",
    },
"*.zig": {
    "F5": "command:fexec zig build",
    "F7": "command:fexec zig ast-check {f}",
    "Shift-F5": "command:fexec zig test {f}",
},

@raidenXR raidenXR changed the title [Feature Request] Keybindings depending on the filetype [Feature Request] Keybindings depending on the filetype to have build actions and quickfix plugin work together nicely Aug 1, 2022
@raidenXR raidenXR changed the title [Feature Request] Keybindings depending on the filetype to have build actions and quickfix plugin work together nicely [Feature Request] Keybindings depending on the filetype Aug 1, 2022
@serge-v
Copy link
Contributor

serge-v commented Aug 1, 2022

you can bind your script "F5": "command:fexec do-action.sh {f} and do actions depending on the file type inside it. It is more flexible. For example, someday you may need to detect a file type by signature, not by extension.

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

No branches or pull requests

2 participants