What
Set sensible per-filetype makeprg defaults via a FileType autocmd so that :Compile works out-of-the-box without requiring manual vim.opt.makeprg = "..." per session.
Where
lua/config/options.lua:74 — where vim.opt.makeprg = "" is set
lua/config/options.lua:158–169 — the Compile command definition
Why it matters
init.lua:74 sets makeprg to an empty string globally, which means :Compile (options.lua:158) always calls make — a no-op unless the user has manually set makeprg first. Given 7 LSPs are configured for Go, Rust, C/C++, Python, and TypeScript, there is a clear mapping from filetype to build command that could be automated.
The existing workflow already uses marks + terminals (tabe | te) for running code. Per-filetype makeprg fills the gap for the quickfix-based compile loop (:Compile, <leader>co, <leader>cc).
Recommended implementation
Add after the Compile command definition:
vim.api.nvim_create_autocmd("FileType", {
group = vim.api.nvim_create_augroup("FiletypeMakeprg", { clear = true }),
callback = function()
local defaults = {
go = "go build ./...",
rust = "cargo build",
c = "make",
cpp = "make",
python = "python3 %",
typescript = "npx tsc --noEmit",
javascript = "node %",
lua = "luac -p %",
swift = "swift build",
}
local ft = vim.bo.filetype
if defaults[ft] then
vim.bo.makeprg = defaults[ft]
end
end,
})
Notes
vim.bo.makeprg sets the option buffer-locally, so project-level overrides (:set makeprg=cmake --build build) still take effect and don't leak across buffers.
- The existing
lcd (local working directory) feature in the config pairs well: go build ./... runs from whatever directory the current window is rooted in.
% in the makeprg value is expanded to the current filename by :make, so python3 % and node % work as script runners for single files.
- For projects using custom build systems, a
.nvim.lua per-project file (or similar) can override makeprg per project without touching this default.
- Consider adding
:Compile check alias variants (e.g. go vet ./..., cargo check) as optional secondary patterns.
What
Set sensible per-filetype
makeprgdefaults via aFileTypeautocmd so that:Compileworks out-of-the-box without requiring manualvim.opt.makeprg = "..."per session.Where
lua/config/options.lua:74— wherevim.opt.makeprg = ""is setlua/config/options.lua:158–169— theCompilecommand definitionWhy it matters
init.lua:74setsmakeprgto an empty string globally, which means:Compile(options.lua:158) always callsmake— a no-op unless the user has manually setmakeprgfirst. Given 7 LSPs are configured for Go, Rust, C/C++, Python, and TypeScript, there is a clear mapping from filetype to build command that could be automated.The existing workflow already uses marks + terminals (
tabe | te) for running code. Per-filetypemakeprgfills the gap for the quickfix-based compile loop (:Compile,<leader>co,<leader>cc).Recommended implementation
Add after the
Compilecommand definition:Notes
vim.bo.makeprgsets the option buffer-locally, so project-level overrides (:set makeprg=cmake --build build) still take effect and don't leak across buffers.lcd(local working directory) feature in the config pairs well:go build ./...runs from whatever directory the current window is rooted in.%in themakeprgvalue is expanded to the current filename by:make, sopython3 %andnode %work as script runners for single files..nvim.luaper-project file (or similar) can overridemakeprgper project without touching this default.:Compile checkalias variants (e.g.go vet ./...,cargo check) as optional secondary patterns.