Open Kesuaheli opened 4 days ago
Thanks for the write up. Popups are rather un-LSP-ly, but I think a warning on the first line of the file with a quick fix for renaming it would work? We could even add another quick fix for automatically changing the config file to allow the current file name/extension, but that might be too much magic.
It frequently happens that one misspelled a file extension e.g.
.mcfuntion
instead of.mcfunction
. Misode hat the Idea if Spyglass could detect that. Which gave me the following concept:I'm thinking of a popup notification in the bottom right. Which says something like, "The file you just created has an unknown extension for the
function
folder. Expected '.mcfunction
'." And then there are two buttons. One that just closes it. And one to automagically rename it. (Ik, the close button is redundant, as you can close a popup on the :95_x:. But I feel like it's better UX to have it next to the button that does stuff)That same concept can be applied to all folders. For example:
function
(functions
) expects.mcfunction
tags/block
(tags/blocks
) expects.json
blockstates
expects.json
textures
expects.png
A sort of config option would be cool; obviously. Maybe even overrides. Simply turning that on/off. By overrides, I mean a whitelist-ish thing, where you specify file extensions that Spyglass won't complain about. Example:
Would result in a behaviour like:
data/*/function/
namednot_a_function.foo
, Spyglass doesn't show the renaming popup.data/*/tags/function
namedhello_world_barfoo
, Spyglass doesn't show the renaming popup. (because the created file ends in one of the given strings"barfoo"
.)If the created file does not exist in the whitelist and the user decides to let Spyglass rename it, Spyglass cuts everything from (including) the last dot
.
, if any. And then the expected extension is added at the end. Example:data/*/function/tick.mcfun
:tick
.mcfun
tick.mcfunction
data/*/tags/item/potato
potato
(unchanged, as there's no.
)potato.json
Maybe also an option to set the expected extensions? Like this: