diff --git a/config/nvim/init.lua b/config/nvim/init.lua index 3d39d05..4f5c786 100644 --- a/config/nvim/init.lua +++ b/config/nvim/init.lua @@ -30,23 +30,28 @@ if vim.fn.has("nvim-0.12") == 0 then os.exit(1) end - local asset = "nvim-linux-" .. asset_arch - vim.api.nvim_echo({ + local sysname = ((vim.loop.os_uname() or {}).sysname or ""):lower() + local is_mac = sysname == "darwin" + local asset = (is_mac and "nvim-macos-" or "nvim-linux-") .. asset_arch + + local lines = { { "This config requires Neovim 0.12.0 or newer (found " .. current .. ", " .. machine .. ").\n\n", "ErrorMsg" }, - { "Install a current build -- locally, no root needed:\n", "None" }, + { "Install a current build into ~/.local (no root needed):\n", "None" }, { " curl -LO https://github.com/neovim/neovim/releases/latest/download/" .. asset .. ".tar.gz\n", "None" }, - { " tar xzf " .. asset .. ".tar.gz\n", "None" }, - { " rm -rf ~/.local/nvim && mv " .. asset .. " ~/.local/nvim\n", "None" }, - { " mkdir -p ~/.local/bin && ln -sf ~/.local/nvim/bin/nvim ~/.local/bin/nvim\n", "None" }, + { " mkdir -p ~/.local && tar xzf " .. asset .. ".tar.gz --strip-components=1 -C ~/.local\n", "None" }, { " rm " .. asset .. ".tar.gz\n", "None" }, { " # then make sure ~/.local/bin is on your PATH\n\n", "Comment" }, - { "Or system-wide (needs root):\n", "None" }, - { " curl -LO https://github.com/neovim/neovim/releases/latest/download/" .. asset .. ".tar.gz\n", "None" }, - { " tar xzf " .. asset .. ".tar.gz\n", "None" }, - { " sudo rm -rf /opt/nvim && sudo mv " .. asset .. " /opt/nvim\n", "None" }, - { " sudo ln -sf /opt/nvim/bin/nvim /usr/local/bin/nvim\n", "None" }, - { " rm " .. asset .. ".tar.gz\n", "None" }, - }, true, {}) + } + if not is_mac then + vim.list_extend(lines, { + { "Or system-wide (needs root):\n", "None" }, + { " curl -LO https://github.com/neovim/neovim/releases/latest/download/" .. asset .. ".tar.gz\n", "None" }, + { " sudo mkdir -p /opt/nvim && sudo tar xzf " .. asset .. ".tar.gz --strip-components=1 -C /opt/nvim\n", "None" }, + { " sudo ln -sf /opt/nvim/bin/nvim /usr/local/bin/nvim\n", "None" }, + { " rm " .. asset .. ".tar.gz\n", "None" }, + }) + end + vim.api.nvim_echo(lines, true, {}) vim.fn.getchar() os.exit(1) end diff --git a/config/nvim/lua/plugins/treesitter.lua b/config/nvim/lua/plugins/treesitter.lua index 9827ffb..81a9ae8 100644 --- a/config/nvim/lua/plugins/treesitter.lua +++ b/config/nvim/lua/plugins/treesitter.lua @@ -30,8 +30,19 @@ return { if vim.fn.executable("tree-sitter") == 1 then require("nvim-treesitter").install(parsers) else + local uname = vim.uv.os_uname() + local sysname = (uname.sysname or ""):lower() + local machine = uname.machine or "" + local os_part = sysname == "darwin" and "macos" or "linux" + local arch_part = ({ x86_64 = "x64", amd64 = "x64", aarch64 = "arm64", arm64 = "arm64" })[machine] or "x64" + local asset = "tree-sitter-" .. os_part .. "-" .. arch_part + vim.notify( - "tree-sitter CLI not found: skipping install of missing parsers", + "tree-sitter CLI not found: skipping install of missing parsers.\n" + .. "Install into ~/.local/bin:\n" + .. " curl -L https://github.com/tree-sitter/tree-sitter/releases/latest/download/" + .. asset + .. ".gz | gunzip > ~/.local/bin/tree-sitter && chmod +x ~/.local/bin/tree-sitter", vim.log.levels.WARN ) end