summaryrefslogtreecommitdiffstats
path: root/lua
diff options
context:
space:
mode:
authorSteven Arcangeli <stevearc@stevearc.com>2023-12-26 19:25:36 -0500
committerSteven Arcangeli <stevearc@stevearc.com>2023-12-26 19:46:48 -0500
commitb3e0752a6c566b97e2896b486caafd4b25f4683a (patch)
treeb232e34c48c3b2b1a015972bd7071de81b01869a /lua
parent86393c143b8d1b7bdae1449fd25de315fd967fd7 (diff)
docs: autogenerate formatter options docs (#234)
Diffstat (limited to 'lua')
-rw-r--r--lua/conform/formatters/init.lua7
-rw-r--r--lua/conform/formatters/prettier.lua5
2 files changed, 8 insertions, 4 deletions
diff --git a/lua/conform/formatters/init.lua b/lua/conform/formatters/init.lua
index c789e12..237d39c 100644
--- a/lua/conform/formatters/init.lua
+++ b/lua/conform/formatters/init.lua
@@ -1,7 +1,8 @@
local M = {}
local uv = vim.uv or vim.loop
--- This is used for documentation generation
+---@private
+---This is used for documentation generation
M.list_all_formatters = function()
local ret = {}
for path in vim.gsplit(vim.o.runtimepath, ",", { plain = true }) do
@@ -14,7 +15,9 @@ M.list_all_formatters = function()
if entry.name ~= "init.lua" then
local basename = string.match(entry.name, "^(.*)%.lua$")
local module = require("conform.formatters." .. basename)
- ret[basename] = module.meta
+ local module_data = vim.deepcopy(module.meta)
+ module_data.has_options = module.options ~= nil
+ ret[basename] = module_data
end
end
entries = uv.fs_readdir(formatter_dir)
diff --git a/lua/conform/formatters/prettier.lua b/lua/conform/formatters/prettier.lua
index 0977748..9274577 100644
--- a/lua/conform/formatters/prettier.lua
+++ b/lua/conform/formatters/prettier.lua
@@ -26,7 +26,8 @@ return {
description = [[Prettier is an opinionated code formatter. It enforces a consistent style by parsing your code and re-printing it with its own rules that take the maximum line length into account, wrapping code when necessary.]],
},
options = {
- -- add parsers for different filetypes
+ -- Use a specific prettier parser for a filetype
+ -- Otherwise, prettier will try to infer the parser from the file name
ft_parsers = {
-- javascript = "babel",
-- javascriptreact = "babel",
@@ -45,7 +46,7 @@ return {
-- graphql = "graphql",
-- handlebars = "glimmer",
},
- -- add parsers for different extensions
+ -- Use a specific prettier parser for a file extension
ext_parsers = {
-- qmd = "markdown",
},