mirror of
https://github.com/itme-brain/nvim.git
synced 2026-05-08 07:00:13 -04:00
fix(mason): enable portable tool installs
This commit is contained in:
parent
6e5c670a31
commit
798a266ed7
2 changed files with 27 additions and 26 deletions
|
|
@ -1,5 +1,3 @@
|
||||||
return {
|
return {
|
||||||
{ "williamboman/mason.nvim", enabled = false },
|
|
||||||
{ "williamboman/mason-lspconfig.nvim", enabled = false },
|
|
||||||
{ "jay-babu/mason-nvim-dap.nvim", enabled = false },
|
{ "jay-babu/mason-nvim-dap.nvim", enabled = false },
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,7 @@
|
||||||
-- Neovim 0.11+ LSP configuration
|
-- Neovim 0.11+ LSP configuration
|
||||||
-- Uses nvim-lspconfig for server definitions + vim.lsp.enable() API
|
-- Uses nvim-lspconfig for server definitions + vim.lsp.enable() API
|
||||||
|
|
||||||
-- Detect NixOS (Mason doesn't work on NixOS due to FHS issues)
|
-- Servers to ensure are installed via Mason.
|
||||||
local is_nixos = vim.fn.filereadable("/etc/NIXOS") == 1
|
|
||||||
|
|
||||||
-- Servers to ensure are installed via Mason (non-NixOS only)
|
|
||||||
-- On NixOS, install these via extraPackages or per-project devShells
|
|
||||||
local mason_ensure_installed = {
|
local mason_ensure_installed = {
|
||||||
"lua_ls", -- Neovim config
|
"lua_ls", -- Neovim config
|
||||||
"nil_ls", -- Nix (nixd not available in Mason)
|
"nil_ls", -- Nix (nixd not available in Mason)
|
||||||
|
|
@ -47,10 +43,7 @@ return {
|
||||||
name = "nvim-treesitter",
|
name = "nvim-treesitter",
|
||||||
dependencies = {
|
dependencies = {
|
||||||
"neovim-treesitter/treesitter-parser-registry",
|
"neovim-treesitter/treesitter-parser-registry",
|
||||||
{
|
"williamboman/mason.nvim",
|
||||||
"williamboman/mason.nvim",
|
|
||||||
enabled = not is_nixos,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
lazy = false,
|
lazy = false,
|
||||||
build = ":TSUpdate",
|
build = ":TSUpdate",
|
||||||
|
|
@ -107,8 +100,25 @@ return {
|
||||||
require("nvim-treesitter").install(missing)
|
require("nvim-treesitter").install(missing)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function tree_sitter_cli_works()
|
||||||
|
if vim.fn.executable("tree-sitter") == 0 then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
local result = vim.system({ "tree-sitter", "--version" }, { text = true }):wait()
|
||||||
|
if result.code == 0 then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
vim.notify_once(
|
||||||
|
"tree-sitter CLI is installed but cannot run. On NixOS, enable nix-ld so Mason-installed binaries can execute.",
|
||||||
|
vim.log.levels.WARN
|
||||||
|
)
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
local function ensure_treesitter_cli(callback)
|
local function ensure_treesitter_cli(callback)
|
||||||
if vim.fn.executable("tree-sitter") == 1 then
|
if tree_sitter_cli_works() then
|
||||||
callback()
|
callback()
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
@ -117,14 +127,6 @@ return {
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
if is_nixos then
|
|
||||||
vim.notify_once(
|
|
||||||
"tree-sitter CLI is required to install or update parsers; provide it through your Nix system or dev environment before running :TSUpdate",
|
|
||||||
vim.log.levels.WARN
|
|
||||||
)
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
local mason_ok, mason = pcall(require, "mason")
|
local mason_ok, mason = pcall(require, "mason")
|
||||||
local registry_ok, registry = pcall(require, "mason-registry")
|
local registry_ok, registry = pcall(require, "mason-registry")
|
||||||
if not mason_ok or not registry_ok then
|
if not mason_ok or not registry_ok then
|
||||||
|
|
@ -147,7 +149,9 @@ return {
|
||||||
end
|
end
|
||||||
|
|
||||||
if package:is_installed() then
|
if package:is_installed() then
|
||||||
callback()
|
if tree_sitter_cli_works() then
|
||||||
|
callback()
|
||||||
|
end
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -158,7 +162,7 @@ return {
|
||||||
|
|
||||||
vim.notify_once("Installing tree-sitter-cli with Mason for Treesitter parser updates", vim.log.levels.INFO)
|
vim.notify_once("Installing tree-sitter-cli with Mason for Treesitter parser updates", vim.log.levels.INFO)
|
||||||
package:install({}, function(success, error)
|
package:install({}, function(success, error)
|
||||||
if success then
|
if success and tree_sitter_cli_works() then
|
||||||
callback()
|
callback()
|
||||||
else
|
else
|
||||||
vim.notify(
|
vim.notify(
|
||||||
|
|
@ -177,7 +181,7 @@ return {
|
||||||
end)
|
end)
|
||||||
:totable()
|
:totable()
|
||||||
|
|
||||||
if #missing == 0 and (is_nixos or #vim.api.nvim_list_uis() == 0) then
|
if #missing == 0 and #vim.api.nvim_list_uis() == 0 then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -248,17 +252,16 @@ return {
|
||||||
end
|
end
|
||||||
},
|
},
|
||||||
|
|
||||||
-- Mason: portable LSP installer (disabled on NixOS where it doesn't work)
|
-- Mason: portable LSP installer. On NixOS this requires nix-ld for
|
||||||
|
-- downloaded Linux binaries to run.
|
||||||
{
|
{
|
||||||
"williamboman/mason.nvim",
|
"williamboman/mason.nvim",
|
||||||
enabled = not is_nixos,
|
|
||||||
config = function()
|
config = function()
|
||||||
require("mason").setup()
|
require("mason").setup()
|
||||||
end
|
end
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"williamboman/mason-lspconfig.nvim",
|
"williamboman/mason-lspconfig.nvim",
|
||||||
enabled = not is_nixos,
|
|
||||||
dependencies = { "williamboman/mason.nvim" },
|
dependencies = { "williamboman/mason.nvim" },
|
||||||
config = function()
|
config = function()
|
||||||
require("mason-lspconfig").setup({
|
require("mason-lspconfig").setup({
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue