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

mapping function keys for go code #83

Closed
aphsa opened this issue May 11, 2024 · 1 comment
Closed

mapping function keys for go code #83

aphsa opened this issue May 11, 2024 · 1 comment

Comments

@aphsa
Copy link

aphsa commented May 11, 2024

Is there a way to map fn keys for running commands like make and its arguments specifically when using "go" files?

Something like this:

-- custom keys
function map(mode, shortcut, command)
  vim.api.nvim_set_keymap(mode, shortcut, command, { noremap = true, silent = true })
end

function nmap(shortcut, command)
  map('n', shortcut, command)
end


nmap("<F12>", "<cmd>!/usr/bin/make build")

If then where will this code go?

@Allaman
Copy link
Owner

Allaman commented May 12, 2024

Hello,

after/ftplugin/go.lua is responsible for loading go specific stuff. Adding vim.api.nvim_set_keymap("n", "<F12>", "<cmd>echo 'hello'<cr>", {}) works when opening a Go file.

PS: Your command is missing the ending <cr>.

PS2: I included overseer in the config (lua/core/plugins/overseer.lua) which is a plugin to run various tools including make goals.
image

@aphsa aphsa closed this as completed May 14, 2024
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