From 716de251adebea2617f932a3e10237e80f5c5337 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20La=C3=ADn?= Date: Thu, 11 Jan 2024 12:29:48 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat(nvim):=20add=20zig=20lang=20ex?= =?UTF-8?q?tra?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .config/nvim/lua/plugins/extras/lang/zig.lua | 79 ++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 .config/nvim/lua/plugins/extras/lang/zig.lua diff --git a/.config/nvim/lua/plugins/extras/lang/zig.lua b/.config/nvim/lua/plugins/extras/lang/zig.lua new file mode 100644 index 00000000..972663f1 --- /dev/null +++ b/.config/nvim/lua/plugins/extras/lang/zig.lua @@ -0,0 +1,79 @@ +return { + { + "nvim-treesitter/nvim-treesitter", + opts = function(_, opts) + if type(opts.ensure_installed) == "table" then + vim.list_extend(opts.ensure_installed, { "zig" }) + end + end, + }, + { + "neovim/nvim-lspconfig", + opts = { + servers = { + zls = {}, + }, + }, + }, + { + "williamboman/mason.nvim", + opts = function(_, opts) + opts.ensure_installed = opts.ensure_installed or {} + vim.list_extend(opts.ensure_installed, { "zls", "codelldb" }) + end, + }, + { + "nvim-neotest/neotest", + optional = true, + dependencies = { + "lawrence-laz/neotest-zig", + }, + opts = { + adapters = { + ["neotest-zig"] = {}, + }, + }, + }, + { + "mfussenegger/nvim-dap", + optional = true, + opts = function() + local dap = require("dap") + dap.configurations.zig = { + { + name = "Zig Run", + type = "codelldb", + request = "launch", + program = function() + os.execute("zig build") + local command = "find ! -type d -path './zig-out/bin/*' | grep -v 'Test' | sed 's#.*/##'" + local bin_location = io.popen(command, "r") + if bin_location ~= nil then + return "zig-out/bin/" .. bin_location:read("*a"):gsub("[\n\r]", "") + else + return "" + end + end, + cwd = "${workspaceFolder}", + stopOnEntry = false, + args = function() + local argv = {} + arg = vim.fn.input(string.format("Arguments: ")) + for a in string.gmatch(arg, "%S+") do + table.insert(argv, a) + end + return argv + end, + }, + } + end, + }, + { + "stevearc/conform.nvim", + opts = function(_, opts) + opts.formatters_by_ft.python = opts.formatters_by_ft.python or {} + table.insert(opts.formatters_by_ft.python, "zigfmt") + return opts + end, + }, +}