瀏覽代碼

typst fmt

Thomas 1 年之前
父節點
當前提交
a3c5ee9374
共有 1 個文件被更改,包括 19 次插入6 次删除
  1. 19 6
      lua/config/mappings.lua

+ 19 - 6
lua/config/mappings.lua

@@ -4,15 +4,28 @@ local gitsigns = require("gitsigns")
 
 -- local tree = require "nvim-tree.api"
 
-function FormatBuffer(command)
+function FormatBuffer()
 	-- Save the current cursor position
 	local cursor_position = vim.fn.getpos(".")
-
-	-- Run the formatter command on the current buffer
+	local command = "typstyle"
+	-- -- Run the formatter command on the current buffer
 	vim.cmd(":%! " .. command)
-
 	-- Restore the cursor position
-	vim.fn.setpos(".", cursor_position)
+  vim.fn.setpos(".", cursor_position)
+
+	-- local current_file = vim.fn.expand("%:p")
+	-- local cmd = string.format("typstyle -i %s", current_file)
+	-- vim.fn.jobstart(cmd, {
+	-- 	on_exit = function(_, exit_code)
+	-- 		if exit_code == 0 then
+	-- 			print("TypestStyle completed successfully")
+ --        -- vim.cmd('edit!') -- Reload the buffer
+ --        vim.fn.setpos(".", cursor_position)
+	-- 		else
+	-- 			print("TypestStyle failed with exit code: " .. exit_code)
+	-- 		end
+	-- 	end,
+	-- })
 end
 
 function ToggleTree(source)
@@ -80,7 +93,7 @@ wk.add({
 		{
 			"<leader>ft",
 			function()
-				FormatBuffer("typstfmt")
+				FormatBuffer("typststyle")
 			end,
 			desc = "Typst fmt",
 		},