Repository navigation
feat(init): plugin options, preferred plugins, and adding above existing plugins - #1356
Merged
Merged
Conversation
- write an option that's set to its default and clear it with delete - say when the terminal is too small for a prompt - count rows instead of lines in the options editor's scroll indicators - show the options of the version the minimum dependency age allows - don't offer a plugin that an inherited config file already has - only treat a schema enum as a boolean when it allows both values - test the resize debounce
Also keeps an `associations` that's a single pattern when files are left out.
…s prompt terminal
- add carriage returns to logs written while a key is read in raw mode - read init.json without creating the global config directory - show a config file's plugins the info file doesn't know about - only look up a plugin's entry and options once while prompting - read the config file once and share the warning for unresolved plugins
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Extends the interactive
dprint initso plugins can be ordered and configured while selecting them, and so the plugins someone always wants can be remembered.What changes for users
Plugin picker (
dprint init)shift+↑/↓reorders the selected ones.→opens a plugin to choose which of its file extensions and file names it formats, and to set its options. The options come from the plugin's schema, so the plugin is only downloaded the first time it's opened, and leaving before that finishes cancels the download. An option is written once it's given a value, even when that's its default, anddelclears it again so the default applies. The options shown are those of the version that will be written, so--minimum-dependency-ageholds them back too.Existing config file
dprint initwhere a config file already exists offers the plugins it doesn't have yet. The file's plugins are listed first and can't be unselected, including ones that aren't in the plugin info file (ex. a local./custom.wasm), so a new plugin can be moved above any of them.pluginsarray instead of being appended.Preferred plugins (
dprint init --preferences)init.jsonin the global config directory. Nothing is initialized.dprint initstarts out with those choices for the preferred plugins and puts them ahead of the others that format the same files, in that order. A preferred plugin is pre-selected when one of its files is in the project (even if another plugin would otherwise claim it, or it's markedneverPreselect), but not otherwise. Preferred plugins are marked with ★ in the picker either way.dprint initnever writesinit.json, and remembered choices aren't applied to plugins a config file already has.--yesand--global, and needs an interactive terminal.Implementation notes
PromptTerminalis a new trait the multi-select and the new settings editor draw on and read keys from. A scripted implementation drives them in tests.crates/dprint/tests/specs/init/*.txtare spec tests: each has a key script and the screen after every step, plus the files that were written. Regenerate withUPDATE=1 cargo test -p dprint --bin dprint -- init_specs.read_terminal_key_pressnow returns a debouncedEvent::Resizeas well as key presses, and returns read errors instead of retrying forever. This also makes the existing confirm and select prompts redraw on resize.Known limitations
lineWidth) or a plugin's scaffolded default config. Giving the option a value writes it either way.init.jsonis read as empty with a warning, and is replaced on the next save from--preferences.--preferencessilently ignores--configand--minimum-dependency-age.alt+↑/↓arrives as escape, which cancels;shift+↑/↓works everywhere.