-- treesitter
vim.api.nvim_create_autocmd("FileType", {
	pattern = { "<filetype>" },
	callback = function()
		vim.treesitter.start()
	end,
})

vim.wo[0][0].foldexpr = "v:lua.vim.treesitter.foldexpr()"
vim.wo[0][0].foldmethod = "expr"

vim.bo.indentexpr = "v:lua.require'nvim-treesitter'.indentexpr()"

-- Auto-cd + exécution Python
vim.keymap.set("n", "<leader>rr", "<cmd>ToggleTerm direction=float size=20<cr>", { desc = "Run Python" })
vim.keymap.set("n", "<leader>rp", function()
	local term = require("toggleterm.terminal").Terminal:new({
		cmd = "cd " .. vim.fn.expand("%:p:h") .. " && python " .. vim.fn.expand("%"),
		dir = "git_dir",
		direction = "float",
		close_on_exit = false,
	})
	term:toggle()
end, { desc = "Python Run" })

-- ultisnips
vim.g.UltiSnipsExpandOrJumpTrigger = "<tab>"
vim.g.UltiSNipsListSnippets = "<c-tab>"
vim.g.UltiSnipsJumpBackwardTrigger = "<c-b>"
