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

View File

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