From 1f05e0775d22a82033131d3adfc32156a78da401 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Thu, 5 Jun 2025 10:04:21 +0200 Subject: [PATCH] nvim: Add mason env utility function Should return the mason environment for lsp servers to be able to set it in the 'core/languages.lua' list. However, currently it is initialized too early (I think), before mason.nvim, and thus never gets the initialized env var. --- nvim/.config/nvim/lua/core/languages.lua | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/nvim/.config/nvim/lua/core/languages.lua b/nvim/.config/nvim/lua/core/languages.lua index 755fb8c..72ec4f2 100644 --- a/nvim/.config/nvim/lua/core/languages.lua +++ b/nvim/.config/nvim/lua/core/languages.lua @@ -1,8 +1,8 @@ -- A list of all languages for which I have support for any of: --- an LSP --- Treesitter --- linting --- formatting +-- an LSP (lsp) +-- Treesitter (ts) +-- linting (lint) +-- formatting (format) -- -- with their respective names used by lspconfig, nvim-treesitter, nvim-lint and conform. -- @@ -12,6 +12,16 @@ if vim.fn.executable("nufmt") == 1 then nushell.format = { nu = { "nufmt" } } end +-- FIXME: This does not work for populating LSP config, +-- never gets set MASON env var. Executing too early? +local function mason_dir() + local dir = vim.fn.getenv("MASON") + if dir ~= vim.NIL then + return dir + end + return vim.fn.getenv("HOME") .. "/.local/share/nvim/mason" +end + local languages = { arduino = { lsp = { arduino_language_server = {} }, ts = { "arduino" } }, awk = { ts = { "awk" }, format = { awk = { "gawk" } } },