diff --git a/lua/configs/formatter.lua b/lua/configs/formatter.lua index 489aceb..5d3da48 100644 --- a/lua/configs/formatter.lua +++ b/lua/configs/formatter.lua @@ -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 },