conditionally prepend or append mason/bin to path with mason_path option

This change allows users to choose whether to prepend or append mason/bin to path, by setting mason_path option in custom/chadrc.lua file
This commit is contained in:
Tiraj 2023-06-27 18:00:46 +05:30
parent 286c951d7b
commit d85fa05a19
2 changed files with 12 additions and 1 deletions

View file

@ -83,6 +83,13 @@ M.ui = {
},
}
-- Where NvChad should put mason.nvim bin location in your PATH. Can be one of:
-- - "prepend" (default, Mason's bin location is put first in PATH)
-- - "append" (Mason's bin location is put at the end of PATH)
-- - "skip" (doesn't modify PATH)
---@type '"prepend"' | '"append"' | '"skip"'
M.mason_path = "prepend"
M.plugins = "" -- path i.e "custom.plugins", so make custom/plugins.lua file
M.lazy_nvim = require "plugins.configs.lazy_nvim" -- config for lazy.nvim startup options

View file

@ -58,7 +58,11 @@ end
-- add binaries installed by mason.nvim to path
local is_windows = vim.loop.os_uname().sysname == "Windows_NT"
vim.env.PATH = vim.fn.stdpath "data" .. "/mason/bin" .. (is_windows and ";" or ":") .. vim.env.PATH
if config.mason_path == "prepend" then
vim.env.PATH = vim.fn.stdpath "data" .. "/mason/bin" .. (is_windows and ";" or ":") .. vim.env.PATH
elseif config.mason_path == "append" then
vim.env.PATH = vim.env.PATH .. (is_windows and ";" or ":") .. vim.fn.stdpath "data" .. "/mason/bin"
end
-------------------------------------- autocmds ------------------------------------------
local autocmd = vim.api.nvim_create_autocmd