che-astronvim-config/lua/polish.lua
User 018b471b72 feat: consolidate Mason configuration and add new plugins for enhanced development workflow
- Refactor community.lua module structure for better readability

- Remove obsolete Mason configuration file

- Add new plugins: nvim-lsp-file-operations, nvim-vtsls, package-info.nvim, tsc.nvim

- Implement dynamic Mason package installation based on FRAMEWORK environment variable

- Create custom command 'MasonInstallR' for framework-specific tool installation

Signed-off-by: User <user@example.com>
2025-10-11 16:12:51 +00:00

77 lines
2.4 KiB
Lua

-- This will run last in the setup process.
-- This is just pure lua so anything that doesn't
-- fit in the normal config locations above can go here
-- Framework-specific tool configurations
local FRAMEWORK_TOOLS = {
python = {
"black",
"python-lsp-server",
"mypy",
"pylint",
"flake8",
"pylama",
"bandit",
"pydocstyle",
"pyproject-flake8",
"pyproject-fmt",
"reorder-python-imports",
},
vue = {
"eslint-lsp",
"stylelint-lsp",
"tailwindcss-language-server",
"typescript-language-server",
"stylelint",
"prettier",
},
}
--- Retrieves the appropriate tool set based on the current framework environment
--- @return table List of tools to install for the detected framework
local function get_framework_tools()
local current_framework = os.getenv "FRAMEWORK"
print("[DEBUG] Current FRAMEWORK environment variable: " .. tostring(current_framework))
if current_framework then
print("[DEBUG] Available frameworks: " .. vim.inspect(vim.tbl_keys(FRAMEWORK_TOOLS)))
local tools = FRAMEWORK_TOOLS[current_framework]
print("[DEBUG] Tools for framework '" .. current_framework .. "': " .. vim.inspect(tools))
return tools or {}
else
print "[DEBUG] No FRAMEWORK environment variable set, returning empty list"
return {}
end
end
-- Функция для установки списка пакетов Mason
function InstallMyMasonPackages()
print "[DEBUG] Starting InstallMyMasonPackages function"
local packages = get_framework_tools()
print("[DEBUG] Packages to install: " .. vim.inspect(packages))
if #packages > 0 then
-- Install packages one by one to handle individual failures
for _, package in ipairs(packages) do
print("[DEBUG] Installing package: " .. package)
local success, result = pcall(function() vim.cmd("MasonInstall " .. package) end)
if not success then
print("[WARNING] Failed to install " .. package .. ": " .. tostring(result))
else
print("[DEBUG] Successfully installed " .. package)
end
end
print "[DEBUG] MasonInstall process completed"
else
print "[DEBUG] No packages to install, skipping MasonInstall"
end
end
-- Создание пользовательской команды
vim.api.nvim_create_user_command(
"MasonInstallR", -- Имя команды
InstallMyMasonPackages, -- Вызываемая функция
{ nargs = 0 } -- Команда не принимает аргументов
)