black / ruff depending on project

This commit is contained in:
Michael Peters 2024-03-25 10:48:50 -07:00
parent 7619e6e50f
commit f339af2a81

View File

@ -11,12 +11,23 @@ local function config()
-- sudo pacman -S stylua
-- https://github.com/JohnnyMorganz/StyLua/releases
lua = { fmt_lua.stylua },
-- pip install isort black
-- TODO: ruff format, depending on the project
-- pip install isort black ruff
python = {
fmt_python.isort,
fmt_python.ruff,
-- fmt_python.black,
function()
-- use `black` or `ruff` based on the project dir
local cwd = vim.fn.getcwd()
-- substr the cwd starting at the last "/" character
local cwd_name = string.sub(cwd, -cwd:reverse():find('/') + 1)
local style = {
['invsys'] = fmt_python.black,
['invsys-b'] = fmt_python.black,
['invsys-c'] = fmt_python.black,
['cubix'] = fmt_python.ruff,
['slots'] = fmt_python.ruff,
}
return style[cwd_name] or nil
end,
},
-- sudo npm i -g fixjson
json = { fmt_json.fixjson },