Skip to content
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

Formatting does not work on clean install if this is the only package installed #53

Closed
benonymus opened this issue Dec 14, 2022 · 9 comments · Fixed by #54
Closed

Formatting does not work on clean install if this is the only package installed #53

benonymus opened this issue Dec 14, 2022 · 9 comments · Fixed by #54
Assignees
Labels

Comments

@benonymus
Copy link

Hey,

For context I am in the process of transitioning from another editor and running into the following case:

When I only install this package and add the config to format on save, I see no formatting.

If I check the console in Sublime when I save an elixir file, I see the following:

 File "/Users/xxx/Library/Application Support/Sublime Text/Installed Packages/ElixirSyntax.sublime-package/commands/hex_packages.py", line 6, in <module>
ImportError: No module named 'pathlib'

I found this thread to be helpful: https://forum.sublimetext.com/t/pathlib-not-found-in-purchased-version/49978/2
I can confirm if I install PackageDev (and restart Sublime) the formatting works.
When I install it I can see this:

Package Control: The dependency 'pathlib' is not currently installed; installing...
Package Control: The dependency 'pathlib' has successfully been installed or updated

I think this should be fixed in this package as per the comment.

@princemaple
Copy link
Collaborator

Actually formatting is best done through LSP.

My recommendation would be to install LSP and LSP-elixir.

What's your sublime version BTW?

@azizk
Copy link
Collaborator

azizk commented Dec 14, 2022

So I guess we need a dependencies.json file like this?: https://github.com/SublimeText/PackageDev/blob/master/dependencies.json

Apparently I never ran into this issue because PackageDev was always installed the whole time I worked on this package.

Thanks for pointing this out!

I guess it doesn't matter which version of ST4 it is? I assume you're using the latest version?

Edit: documentation for dependencies.json

@azizk
Copy link
Collaborator

azizk commented Dec 14, 2022

Actually formatting is best done through LSP.

How do you use it? From the context menu? Or did you set a keyboard shortcut for formatting with LSP? I thought mix format is best for mix projects. Does LSP read the .formatter.exs file and can it format HEEx files?

@princemaple
Copy link
Collaborator

How do you use it? From the context menu? Or did you set a keyboard shortcut for formatting with LSP? I thought mix format is best for mix projects. Does LSP read the .formatter.exs file and can it format HEEx files?

LSP has format on save, too. LSP directly invokes the formatter code, so it bypasses the commandline.

@princemaple
Copy link
Collaborator

It does everything mix format can. So yes - it reads the formatter config, and can format HEEX.

@benonymus
Copy link
Author

So I guess we need a dependencies.json file like this?: https://github.com/SublimeText/PackageDev/blob/master/dependencies.json

Apparently I never ran into this issue because PackageDev was always installed the whole time I worked on this package.

Thanks for pointing this out!

I guess it doesn't matter which version of ST4 it is? I assume you're using the latest version?

Edit: documentation for dependencies.json

Correct, I am using the latest version.

@benonymus
Copy link
Author

While LSP does format nicely, I dislike the additional baggage it brings.

This package is more or less an all in one for my use case, with some custom snippets.
Mix format works here too, just not on a clean install.

@azizk
Copy link
Collaborator

azizk commented Dec 15, 2022

Okay, so I tested this myself with a clean config. I couldn't test by installing the ElixirSyntax package but I put a symlink to the repository (with the dependencies.json) in Packages/.

I installed Package Control, restarted and got these console logs:

startup, version: 4143 linux x64 channel: stable
executable: /opt/sublime_text/sublime_text
application: /opt/sublime_text
working dir: /home/aziz
packages path: /home/aziz/.config/sublime-text/Packages
state path: /home/aziz/.config/sublime-text/Local
zip path: /opt/sublime_text/Packages
zip path: /home/aziz/.config/sublime-text/Installed Packages
ignored_packages: ["Vintage"]
pre session restore time: 0.221375
startup time: 0.309014
first paint time: 0.37134
reloading plugin Default.arithmetic
reloading plugin Default.auto_indent_tag
reloading plugin Default.block
reloading plugin Default.colors
reloading plugin Default.comment
reloading plugin Default.convert_color_scheme
reloading plugin Default.convert_syntax
reloading plugin Default.copy_path
reloading plugin Default.echo
reloading plugin Default.exec
reloading plugin Default.fold
reloading plugin Default.font
reloading plugin Default.goto_line
reloading plugin Default.history_list
reloading plugin Default.html_print
reloading plugin Default.indentation
reloading plugin Default.install_package_control
reloading python 3.3 plugin 0_package_control_loader.00-package_control
reloading python 3.3 plugin Package Control.1_reloader
reloading python 3.3 plugin Package Control.2_bootstrap
reloading plugin Default.keymap
reloading plugin Default.kill_ring
reloading plugin Default.mark
reloading plugin Default.new_templates
reloading plugin Default.open_context_url
reloading plugin Default.open_in_browser
reloading plugin Default.pane
reloading plugin Default.paragraph
reloading plugin Default.paste_from_history
reloading plugin Default.profile
reloading plugin Default.quick_panel
reloading plugin Default.rename
reloading plugin Default.run_syntax_tests
reloading plugin Default.save_on_focus_lost
reloading plugin Default.scroll
reloading plugin Default.set_unsaved_view_name
reloading plugin Default.settings
reloading plugin Default.show_scope_name
reloading plugin Default.side_bar
reloading plugin Default.sort
reloading plugin Default.switch_file
reloading plugin Default.symbol
reloading plugin Default.transform
reloading plugin Default.transpose
reloading plugin Default.ui
reloading plugin CSS.css_completions
reloading plugin Diff.diff
reloading plugin HTML.encode_html_entities
reloading plugin HTML.html_completions
reloading plugin ShellScript.ShellScript
reloading python 3.3 plugin Package Control.Package Control
reloading python 3.3 plugin ElixirSyntax.main
Traceback (most recent call last):
File "/opt/sublime_text/Lib/python33/sublime_plugin.py", line 308, in reload_plugin
m = importlib.import_module(modulename)
File "./python3.3/importlib/init.py", line 90, in import_module
File "", line 1584, in _gcd_import
File "", line 1565, in _find_and_load
File "", line 1532, in _find_and_load_unlocked
File "", line 584, in _check_name_wrapper
File "", line 1022, in load_module
File "", line 1003, in load_module
File "", line 560, in module_for_loader_wrapper
File "", line 868, in _load_module
File "", line 313, in _call_with_frames_removed
File "/home/aziz/.config/sublime-text/Packages/ElixirSyntax/main.py", line 10, in
from .commands import *
File "/home/aziz/.config/sublime-text/Packages/ElixirSyntax/commands/init.py", line 1, in
from .hex_packages import *
File "/home/aziz/.config/sublime-text/Packages/ElixirSyntax/commands/hex_packages.py", line 6, in
from pathlib import Path
ImportError: No module named 'pathlib'
plugins loaded
Package Control: Installing 1 missing dependency
Package Control: Error downloading channel. URL error _ssl.c:532: The handshake operation timed out downloading https://packagecontrol.io/channel_v3.json.
Package Control: The dependency 'pathlib' is not available
Package Control: Skipping automatic upgrade, last run at 2022-12-15 18:55:08, next run at 2022-12-15 19:55:08 or after

So it timed out while trying to download pathlib, but when I restarted it managed to download it successfully (don't know why it said error: Package Control):

error: Package Control

1 missing dependency was just installed. Sublime Text should be restarted, otherwise one or more of the installed packages may not function properly.

I checked almost every palette command and everything worked fine. 👍

@azizk azizk mentioned this issue Dec 15, 2022
@azizk azizk self-assigned this Dec 15, 2022
@azizk azizk added the bug label Dec 15, 2022
@princemaple
Copy link
Collaborator

A restart is acceptable

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants