Skip to content

Editor Setup

Turiiya edited this page May 17, 2024 · 1 revision

Neovim

Register vzit in null-ls/none-ls

null_ls.register({
	name = "vzit",
	method = null_ls.methods.FORMATTING,
	filetypes = { "zig" },
	generator = null_ls.formatter({
		command = "vzit",
		args = { "-w", "$FILENAME" },
		to_temp_file = true,
	}),
})

To not conflict with zig fmt, disable it's autosave.

vim.g.zig_fmt_autosave = 0

-- The variable can be also added conditionally.
-- E.g., when setting up zls.
mason_lspconfig.setup_handlers({
	function(server)
		-- ...
		if server == "zls" then vim.g.zig_fmt_autosave = 0 end
	end,
})

Below are some more options that might be interesting to add as autocmd.

vim.api.nvim_create_autocmd("FileType", {
	pattern = {"python", "zig"},
	command = "setlocal noet ts=3 sw=0"
})

VS Code / Codium

Since VZiT is a very young project it is not yet clear whether it will have a user base that can benefit from its own VS Code extension. To save efforts the extension has not yet been completed. Until then, please use the Run on Save extension from emeraldwalk.

// settings.json
{
	// ...
	"emeraldwalk.runonsave": {
		"commands": [
			{
				"match": "\\.zig$",
				"isAsync": true,
				"cmd": "vzit -w ${file}"
			}
		]
	},
	"[zig]": {
		"editor.formatOnSave": false
	}
}

Clone this wiki locally