Make nvim installation helpers platform-aware and add local install helper for tree-sitter-cli
This commit is contained in:
+18
-13
@@ -30,23 +30,28 @@ if vim.fn.has("nvim-0.12") == 0 then
|
|||||||
os.exit(1)
|
os.exit(1)
|
||||||
end
|
end
|
||||||
|
|
||||||
local asset = "nvim-linux-" .. asset_arch
|
local sysname = ((vim.loop.os_uname() or {}).sysname or ""):lower()
|
||||||
vim.api.nvim_echo({
|
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" },
|
{ "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" },
|
{ " curl -LO https://github.com/neovim/neovim/releases/latest/download/" .. asset .. ".tar.gz\n", "None" },
|
||||||
{ " tar xzf " .. asset .. ".tar.gz\n", "None" },
|
{ " mkdir -p ~/.local && tar xzf " .. asset .. ".tar.gz --strip-components=1 -C ~/.local\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" },
|
|
||||||
{ " rm " .. asset .. ".tar.gz\n", "None" },
|
{ " rm " .. asset .. ".tar.gz\n", "None" },
|
||||||
{ " # then make sure ~/.local/bin is on your PATH\n\n", "Comment" },
|
{ " # 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" },
|
if not is_mac then
|
||||||
{ " tar xzf " .. asset .. ".tar.gz\n", "None" },
|
vim.list_extend(lines, {
|
||||||
{ " sudo rm -rf /opt/nvim && sudo mv " .. asset .. " /opt/nvim\n", "None" },
|
{ "Or system-wide (needs root):\n", "None" },
|
||||||
{ " sudo ln -sf /opt/nvim/bin/nvim /usr/local/bin/nvim\n", "None" },
|
{ " curl -LO https://github.com/neovim/neovim/releases/latest/download/" .. asset .. ".tar.gz\n", "None" },
|
||||||
{ " rm " .. asset .. ".tar.gz\n", "None" },
|
{ " sudo mkdir -p /opt/nvim && sudo tar xzf " .. asset .. ".tar.gz --strip-components=1 -C /opt/nvim\n", "None" },
|
||||||
}, true, {})
|
{ " 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()
|
vim.fn.getchar()
|
||||||
os.exit(1)
|
os.exit(1)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -30,8 +30,19 @@ return {
|
|||||||
if vim.fn.executable("tree-sitter") == 1 then
|
if vim.fn.executable("tree-sitter") == 1 then
|
||||||
require("nvim-treesitter").install(parsers)
|
require("nvim-treesitter").install(parsers)
|
||||||
else
|
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(
|
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
|
vim.log.levels.WARN
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user