aboutsummaryrefslogtreecommitdiffstats
path: root/lua/conform/util.lua
diff options
context:
space:
mode:
Diffstat (limited to 'lua/conform/util.lua')
-rw-r--r--lua/conform/util.lua17
1 files changed, 17 insertions, 0 deletions
diff --git a/lua/conform/util.lua b/lua/conform/util.lua
index 2f334d0..fe2a306 100644
--- a/lua/conform/util.lua
+++ b/lua/conform/util.lua
@@ -187,4 +187,21 @@ M.buf_get_changedtick = function(bufnr)
end
end
+---Parse the rust edition from the Cargo.toml file
+---@param dir string
+---@return string?
+M.parse_rust_edition = function(dir)
+ local manifest = vim.fs.find("Cargo.toml", { upward = true, path = dir })[1]
+ if manifest then
+ for line in io.lines(manifest) do
+ if line:match("^edition *=") then
+ local edition = line:match("%d+")
+ if edition then
+ return edition
+ end
+ end
+ end
+ end
+end
+
return M