This commit is contained in:
psychhim
2025-09-28 17:04:12 +05:30
parent fd24fb3574
commit f7cea8252b

View File

@@ -87,7 +87,7 @@ require('lazy').setup({
},
},
},
-- Install formatters automatically
{
'zapling/mason-conform.nvim',
@@ -909,23 +909,23 @@ vim.api.nvim_create_autocmd({ 'TabClosed' }, {
local uv = vim.loop
local home = uv.os_homedir()
local os_name = uv.os_uname().sysname
local appdata = os.getenv("APPDATA") or (home .. "/AppData/Roaming")
local appdata = os.getenv 'APPDATA' or (home .. '/AppData/Roaming')
-- List of formatter configs
local formatters = {
{
name = "clang-format",
path = (os_name:match("Windows") and home .. "\\.clang-format" or home .. "/.clang-format"),
name = 'clang-format',
path = (os_name:match 'Windows' and home .. '\\.clang-format' or home .. '/.clang-format'),
content = [[
BasedOnStyle: LLVM
IndentWidth: 4
TabWidth: 4
UseTab: Always
]]
]],
},
{
name = "prettier",
path = (os_name:match("Windows") and appdata .. "\\Prettier\\.prettierrc" or home .. "/.prettierrc"),
name = 'prettier',
path = (os_name:match 'Windows' and appdata .. '\\Prettier\\.prettierrc' or home .. '/.prettierrc'),
content = [[
{
"tabWidth": 4,
@@ -935,53 +935,53 @@ UseTab: Always
"trailingComma": "es5",
"printWidth": 100
}
]]
]],
},
{
name = "yapf",
path = (os_name:match("Windows") and home .. "\\.style.yapf" or home .. "/.style.yapf"),
name = 'yapf',
path = (os_name:match 'Windows' and home .. '\\.style.yapf' or home .. '/.style.yapf'),
content = [[
[style]
based_on_style = pep8
indent_width = 4
use_tabs = True
]]
]],
},
{
name = "isort",
path = (os_name:match("Windows") and home .. "\\.isort.cfg" or home .. "/.isort.cfg"),
name = 'isort',
path = (os_name:match 'Windows' and home .. '\\.isort.cfg' or home .. '/.isort.cfg'),
content = [[
[settings]
profile = black
force_single_line = true
]]
]],
},
}
-- Helper to create file if it doesn't exist
local function ensure_file(path, content)
if not path then
print("Invalid path, skipping file creation")
print 'Invalid path, skipping file creation'
return
end
local stat = uv.fs_stat(path)
if not stat then
-- Make parent directory if needed
local dir = vim.fn.fnamemodify(path, ":h")
local dir = vim.fn.fnamemodify(path, ':h')
if vim.fn.isdirectory(dir) == 0 then
vim.fn.mkdir(dir, "p") -- recursively create directories
print("Created directory: " .. dir)
vim.fn.mkdir(dir, 'p') -- recursively create directories
print('Created directory: ' .. dir)
end
-- Write the file
local fd = uv.fs_open(path, "w", 420) -- 0644
local fd = uv.fs_open(path, 'w', 420) -- 0644
if fd then
uv.fs_write(fd, content, -1)
uv.fs_close(fd)
print("Created file: " .. path)
print('Created file: ' .. path)
else
print("Failed to create file: " .. path)
print('Failed to create file: ' .. path)
end
end
end