This is the first commit that actually adds files to the repo. Yes it's a bad commit but now the major features are here
44 lines
878 B
Lua
44 lines
878 B
Lua
local ok, formatter = pcall(require,'formatter')
|
|
|
|
if not ok then
|
|
return
|
|
end
|
|
|
|
local config_ft = {}
|
|
if pcall(require, 'mason') then
|
|
-- Configure based on mason status
|
|
local packages = require('mason-registry').get_installed_packages()
|
|
local formatters = {} -- installed formatters go here
|
|
|
|
for _, package in pairs(packages) do
|
|
local cats = package.spec.categories
|
|
if vim.tbl_contains(cats,package.Cat.Formatter) then
|
|
table.insert(formatters,package)
|
|
end
|
|
end
|
|
|
|
-- Insert one ugly ass control flow here
|
|
for _, formatprog in pairs(formatters) do
|
|
local name = formatprog.name
|
|
|
|
if name == 'stylua' then
|
|
config_ft['lua'] = {
|
|
require('formatter.filetypes.lua').stylua
|
|
}
|
|
print()
|
|
end
|
|
|
|
print()
|
|
end
|
|
else
|
|
-- Configure statically
|
|
end
|
|
|
|
formatter.setup {
|
|
logging = true,
|
|
log_level = vim.log.levels.WARN,
|
|
filetype = config_ft
|
|
}
|
|
|
|
-- Configure keybindings
|