Phidica / sublime-fish

A robust Sublime Text syntax package for fish
MIT License
35 stars 2 forks source link

use fish_indent to indent files #16

Closed nhooyr closed 5 years ago

nhooyr commented 6 years ago

Would be fantastic if this plugin supported using fish_indent

Phidica commented 6 years ago

Leveraging fish_indent for automatic prettification of code is a pretty good idea. Setting it up as a build system option that comes with this package would be really straightforward, and I'll look into that

Unfortunately, fish_indent does not have an option to choose the indent: it's hardcoded to be 4 spaces. Great for people who indent their personal fish scripts with 4 spaces, no good for everyone else (eg, tabs, 2 spaces, etc). Passing a flag to fish_indent to use tabs would probably be ideal, as that would be the right output for tab users and for space users ST would autoconvert back to the internally-preferred number of spaces when it reloads the file. I'll open an issue asking about this

Phidica commented 6 years ago

Never mind, fish-shell/fish-shell#3055 explicitly chose not to add such a feature as it has the potential to introduce inconsistent formatting within the project

Instead, we might still be able to leverage fish_indent, but pipe the output into something like sed (or write a short Python script; probably better for portability), to convert every 4 spaces from the start of a line into a tab character, then write that back over the original file

nhooyr commented 6 years ago

Nice! Sounds great to me.

nhooyr commented 6 years ago

Is it possible to make it run every time the file is saved instead of a build system? Or can you make the build run on every file save?

Phidica commented 6 years ago

I think that can be done! I'll look into it as well

nhooyr commented 6 years ago

Thank you so much :)

On Jul 16, 2018, at 1:15 AM, Violet notifications@github.com wrote:

I think that can be done! I'll look into it as well

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Phidica/sublime-fish/issues/16#issuecomment-405150816, or mute the thread https://github.com/notifications/unsubscribe-auth/AJtY-bjQrkDdjNQEYeZhHCAjq0BAo04Pks5uHCFfgaJpZM4VQMZ-.

Phidica commented 6 years ago

Hey, if you're interested in testing this feature I've pushed it to a new devel branch. You can follow the manual install instructions from the readme (to prevent a conflict, you may need to uninstall from Package Control if that's how you have the package currently), then git checkout devel to switch to the development version. See the changelog for details on what's in the current version, but it's basically keyboard shortcut, build system, and at-save execution options

I'm working on testing the feature on Windows, but it should work smoothly on both macOS and Linux. Let me know if you find any issues!

nhooyr commented 6 years ago

Awesome, thank you so much. Works great for me.

One thing I did notice is the example config doesn't include an extensions key but sublime text adds this field in into the config when you set it to use the fish syntax for all *.fish files (see #18 for why I did this)

    "extensions":
    [
        "fish"
    ]

Is that a part of this plugin or something sublime specific? If sublime configuration, seems weird for it to be mixed in with with the rest of the config.

Phidica commented 6 years ago

Yes, I believe Sublime does this. It is how it achieves the result of overriding the file extension preferences of other packages

Phidica commented 5 years ago

Closed by the official release of 2.3.0 (dbe0df4)