-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
plugin: formatter: Add plugin to format files #3166
Conversation
One thought about the duplication of documentation, not related to this new plugin in the first place, but in general to all default plugins: Lines 471 to 481 in a57d29a
Lines 416 to 426 in a57d29a
So the reduced description is duplicated and needs to be maintained twice. Maybe we can link from that default plugin section in options.md to plugins.md#default-plugins. What do you think about this? |
I really don't know if there is a need to have plugin descriptions in the options help, maybe we can link the plugin help and we can use the Plugin options: all plugins come with a special option to enable or disable
them. The option is a boolean with the same name as the plugin itself.
By default, the following plugins are provided, each with an option to activate
or disable them (all are `true` by default):
* `autoclose`
* `comment`
* `diff`
* `formatter`
* `ftoptions`
* `linter`
* `literate`
* `status`
> For more details about these plugins, see plugins help (`> help plugins`) Would that solve it? |
Not really, since we still have to keep track of the plugin list twice. The available plugins (including their description) are listed in the plugin help itself, so we don't need to list them once again. Maybe: Plugin options: all plugins come with a special option to enable or disable For more details about these plugins, see plugins help (plugins.md#default-plugins. or |
Okay for me |
One thing which may be discussed is the situation "default" plugin or not (added to the plugin-channel). @dmaluka |
If you are talking about the manager plugin, it does more things besides managing formatters, so the
I agree. A way for the user to be able to create formatters should come by default, just like the |
Ok, I've found a moment to look at this. So I've been trying to understand what is this all about, what is a "formatter" and what the heck is this plugin doing. I've looked at the documentation, which is supposed to explain these things in its initial section, but instead the documentation begins with some mumbo-jumbo:
Sorry, I'm not sure what am I supposed to do with this. So, I don't know if this plugin is "fundamental" enough and what should I agree or disagree with, since I don't really understand what is this plugin all about. |
# Formatter
With this plugin you can configure cli's that will be used to format your codes. Does this text meet the need to explain what the plugin does? @dmaluka |
The idea would be to eliminate the need for the user to write their own plugin to format files. But how would someone format an elixir file? Creating a plugin to execute the We would be providing a way for the user to define a file formatter without having to create a new plugin for it. Just open function init()
formatter.setup({
{ cmd = 'mix format %f', bind = 'Alt-m', filetypes = { 'elixir' } },
{ cmd = 'rustfmt +nightly %f', onSave = true, filetypes = { 'rust' } },
{ cmd = 'raco fmt -i %f', domatch = true, filetypes = { '\\.rkt$' } },
})
end |
Ok, got it. Yeah, it seems reasonable to have such a unified formatter plugin as a default plugin, like the But regarding the way how you implemented it, I have a fundamental question: why not implement the formatter plugin "just like the linter plugin", to keep things simple and consistent? I.e. just This question also concerns the documentation. Look at |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- I would let users use micro's built-in keybinding system instead of introducing a plugin-specific "bind" option for each formatter.
- How about using the same
format
command for all formatters? So you would useformat goimp
instead ofgoimp
. That would let you get rid of the entiremakeCommands
option which introduces a lot of complexity and needs a lengthy explanation in the documentation.
The linter plugin API is not cool at all, function init()
linter.makeLinter(
'rubocop', -- name : required
'ruby', -- filetype : required
'rubocop', -- cmd : required
{ '--format', 'emacs', '%f' }, -- args : required
'%f:%l:%c: C: %m', -- errorformat : required
nil, -- os
false, -- whitelist
false, -- domatch
0, -- loffset
0, -- coffset
function(buf) -- callback
return false
end
)
end I need to pass The API was implemented based on the formatters found in lunarvim. But I can implement a
Regarding documentation, I don't know if the linter documentation is good because it doesn't give examples of using the features it has and peculiar behaviors such as the behavior of The idea ofthe formatter plugin documentation was to document the plugin, teach the user with examples so that they can actually make use of the features and even copy the example for use, perhaps it is not written in the best way but put a doc like the linter it would be asking the user to find out how to use the plugin or asking how to use it (#3164).
But what would be the problem with making the user write
The |
@dmaluka How could we improve the formatter plugin documentation without having to remove the examples and explanations for each field? (the What points need to be improved? |
For starters, a clear explanation of what the plugin does. Something like:
|
It's only "simpler" as in "less typing" but it's inconsistent with how rest of the editor and other plugins work. Most users already know how to do keybindings through |
What do you mean inconsistent? The plugin is literally calling the No other standard plugin gives the user a way to create keybindings, so because this function doesn't exist today does this make it inconsistent? For me it's one of centralizing the formatter configuration in the formatter. |
This is also not completely true because the I think we should ignore the linter plugin, the pr is to add a plugin for the user to configure formatters and not to add a twin of the linter plugin. |
I corrected a typo in the documentation and the pipeline failed, I think this pipeline is not very reliable. |
Yes, unfortunately this issue was introduced by accident and is already tracked with #3220. |
Today the computer does not have an official way of creating formatters, that is, if I want to do this I will have to create a plugin for it.
Plugins are created for a single formatter, sometimes by more than one person.
The idea of this pull request is to add a built-in plugin for you to create formatters
of files for all types of languages.
Here is an example: