cleaned up code and added descriptive comments

Add configurable 'place_mason_bin' option in custom/chadrc.lua for flexible mason/bin path handling
This commit is contained in:
Tiraj 2023-06-29 02:31:39 +05:30 committed by Tiraj
parent d85fa05a19
commit c0640363b0
3 changed files with 14 additions and 9 deletions

View file

@ -83,12 +83,9 @@ 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)
-- Determines the preferred placement of the mason.nvim bin directory in your PATH.
---@type '"prepend"' | '"append"' | '"skip"'
M.mason_path = "prepend"
M.place_mason_bin = "prepend"
M.plugins = "" -- path i.e "custom.plugins", so make custom/plugins.lua file

View file

@ -57,11 +57,15 @@ for _, provider in ipairs { "node", "perl", "python3", "ruby" } do
end
-- add binaries installed by mason.nvim to path
-- based on the selected 'place_mason_bin' option
local is_windows = vim.loop.os_uname().sysname == "Windows_NT"
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"
local path_separator = is_windows and ";" or ":"
local mason_bin_path = vim.fn.stdpath "data" .. "/mason/bin"
if config.place_mason_bin == "prepend" then
vim.env.PATH = mason_bin_path .. path_separator .. vim.env.PATH
elseif config.place_mason_bin == "append" then
vim.env.PATH = vim.env.PATH .. path_separator .. mason_bin_path
end
-------------------------------------- autocmds ------------------------------------------

View file

@ -1,6 +1,10 @@
local options = {
ensure_installed = { "lua-language-server" }, -- not an option from mason.nvim
-- Note: Avoid setting `PATH="prepend"|"append"` here.
-- To change the location of the mason/bin directory, update the 'place_mason_bin' option
-- in 'custom/chadrc.lua'. If you must set it here, ensure 'place_mason_bin' in 'custom/chadrc.lua'
-- is set to 'skip' to prevent duplicate mason/bin paths.
PATH = "skip",
ui = {