vim.pack.add({
    {
        src = "https://github.com/MeanderingProgrammer/render-markdown.nvim"
    }
})

-- 1. Register the python parser URL and metadata
local parser_config = vim.treesitter.language.get_lang('python') or {}
vim.treesitter.language.add('python', {
    url = "https://github.com",
    files = { "src/parser.c", "src/scanner.c" }, -- Note: scanner.c is required for Python
})

-- 2. Create a clean user command to compile it manually
vim.api.nvim_create_user_command('NativeInstallPython', function()
    local install_dir = vim.fn.stdpath("data") .. "/site/parser"
    vim.fn.mkdir(install_dir, "p")
    
    -- Clone and compile natively using a temporary directory
    local tmp = vim.fn.tempname()
    vim.fn.system(string.format("git clone https://github.com %s", tmp))
    vim.fn.system(string.format("gcc -o %s/python.so -shared %s/src/parser.c %s/src/scanner.c -Os -fPIC -I%s/src", install_dir, tmp, tmp, tmp))
    
    print("Python parser compiled successfully to " .. install_dir)
end, {})

vim.cmd("syntax on")

vim.api.nvim_create_autocmd("FileType", {
    callback = function()
        local lang = vim.treesitter.language.get_lang(vim.bo.filetype)
        if lang then
            pcall(vim.treesitter.start)
        end
    end,
})

