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

Verify that a syntax exists before trying to set it #24

Closed
fregante opened this issue Jul 10, 2014 · 21 comments
Closed

Verify that a syntax exists before trying to set it #24

fregante opened this issue Jul 10, 2014 · 21 comments
Labels
Milestone

Comments

@fregante
Copy link
Owner

Error loading syntax file "Packages/Markdown/Markdown.tmLanguage": Unable to open Packages/Markdown/Markdown.tmLanguage

I've had this problem for a while but I just clicked on "Ok" and it didn't appear anymore until I restarted ST. It looks like I don't have that file installed, I just use the MarkdownEditing package, which is pretty good.

@fregante fregante added the bug label Jul 10, 2014
@Cacodaimon Cacodaimon added this to the Milestone 1 milestone Jul 11, 2014
@Cacodaimon
Copy link
Contributor

I asked a question in the ST forum about it: http://www.sublimetext.com/forum/viewtopic.php?f=6&t=16470

@fregante
Copy link
Owner Author

👍
Someone answered. In the meanwhile I added some instructions on how to install the GitHub-Flavored Markdown, which is pretty good.

@Cacodaimon
Copy link
Contributor

The git hub markdown is cool, did't know about it.

I will try it tomorrow with the suggested sublime.find_resources.

@Cacodaimon
Copy link
Contributor

screenshot - 07132014 - 03 06 06 pm

@fregante
Copy link
Owner Author

If I don't have MarkdownEditing installed I still get the error:

Error loading syntax file "Markdown.tmLanguage": Unable to open Markdown.tmLanguage

GhostTest is starting now…
Setting on request handler
SublimeLinter: debug mode: off 
HTTP Start
Emmet: No need to update PyV8
found 20 files for base name Main.sublime-menu
Package Control: Skipping automatic upgrade, last run at 2014-07-13 16:14:38, next run at 2014-07-13 17:14:38 or after
focus_sublime_window
WebSocketServer id: 1
Setting on message handler
Setting on close handler
Start
Listening on: 62285
Bind view with id: 34
Setting on message handler
Loading dictionary Packages/Language - English/en_US.dic
error: Error loading syntax file "Markdown.tmLanguage": Unable to open Markdown.tmLanguage
Exception in thread Thread-5:
Traceback (most recent call last):
  File "X/threading.py", line 639, in _bootstrap_inner
  File "/Users/bfred/Library/Application Support/Sublime Text 3/Packages/GhostText/GhostText.py", line 32, in run
    self._server.start()
  File "/Users/bfred/Library/Application Support/Sublime Text 3/Packages/GhostText/WebSocket/WebSocketServer.py", line 84, in start
    self._on_message_handler.on_message(self._received_payload)
  File "/Users/bfred/Library/Application Support/Sublime Text 3/Packages/GhostText/GhostText.py", line 107, in on_message
    self._set_syntax_by_host(request['url'], current_view)
  File "/Users/bfred/Library/Application Support/Sublime Text 3/Packages/GhostText/GhostText.py", line 131, in _set_syntax_by_host
    sublime.error_message('Syntax "{}" is not installed!'.format(syntax_part))
UnboundLocalError: local variable 'syntax_part' referenced before assignment

@Cacodaimon
Copy link
Contributor

Can you try it again?

@fregante
Copy link
Owner Author

Right now no syntax is set at all

  • I restarted

  • I tried with MarkdownEditing installed and not installed

  • I tried with with and without the user setting:

    {
            "default_syntax": "Packages/MarkdownEditing/Markdown.tmLanguage"
    }
    

@fregante
Copy link
Owner Author

I think eventually we'll need some way to match .tmLanguage files to their "human" name. Let's say the user is editing in ACE editor, we can know for sure what the editor's syntax is set to, but it will be something like javascript, not Javascript.tmLanguage.

Right now we might just need a way to guess the best Markdown syntax installed, perhaps by checking for Packages/MarkdownEditing/Markdown.tmLanguage first and then the generic Markdown.tmLanguage

@Cacodaimon
Copy link
Contributor

You have to use Markdown.tmLanguage or MarkdownEditing/Markdown.tmLanguage instead of Packages/MarkdownEditing/Markdown.tmLanguage, sublime.find_resources matches is a asterisk prefix.

@Cacodaimon
Copy link
Contributor

This human name thing would be a big part maintenance, we would have to match "JScript", "JS", "Java Script", "JavaScript"… for only one language.

@fregante
Copy link
Owner Author

I used the wrong word, I just meant that if the browser knows the language we need (either by figuring it out or by asking the CodeMirror), it will provide a string like javascript or text/javascript, it can't and shouldn't know the exact name of the syntax in the editor.

CodeMirror has a list of the MIMEs we'd need to support anyway: https://github.com/marijnh/CodeMirror/blob/master/mode/javascript/javascript.js#L672

@Cacodaimon
Copy link
Contributor

Okey but now we are mixing up the issues, advanced syntax detection can only work if we have Cacodaimon/GhostText-for-Chrome#26 finished and this host name based detection is a way espscially for text areas the only element we are currently supporting.

Back to the topic:
Whats the output of the following command in your sublime console.

sublime.find_resources('*Markdown.tmLanguage')

@fregante
Copy link
Owner Author

Yeah I only mentioned that name->tmLanguage matching feature because you're currently working on this tmLanguage setting feature anyway.

>>> sublime.find_resources('*Markdown.tmLanguage')
['Packages/MarkdownEditing/Markdown.tmLanguage', 'Packages/MarkdownEditing/MultiMarkdown.tmLanguage']

@Feltzer
Copy link
Contributor

Feltzer commented Jul 14, 2014

Just wanted to report that I am getting the same error message, even with

{
        "default_syntax": "MarkdownEditing/Markdown.tmLanguage"
}

set.

Output of sublime.find_resources('*Markdown.tmLanguage'):

>>> sublime.find_resources('*Markdown.tmLanguage')
['Packages/MarkdownEditing/Markdown.tmLanguage', 'Packages/MarkdownEditing/MultiMarkdown.tmLanguage']

@Cacodaimon
Copy link
Contributor

I told crap MarkdownEditing/Markdown.tmLanguage wont work, but Markdown.tmLanguage should work:

No extra Markdown installed:

>>> sublime.find_resources('*Markdown.tmLanguage')
['Packages/Markdown/Markdown.tmLanguage', 'Packages/Markdown/MultiMarkdown.tmLanguage']

With MarkdownEditing installed:

>>> sublime.find_resources('*Markdown.tmLanguage')
['Packages/MarkdownEditing/Markdown.tmLanguage', 'Packages/MarkdownEditing/MultiMarkdown.tmLanguage']

This should work, there must be a little bug somewhere, I gonna fix this this evening.

@Cacodaimon
Copy link
Contributor

Can someone please check if it works now, if I got an OK I gonna create a new tag.

@fregante
Copy link
Owner Author

I get this error, both in the console and as an alert(), and the syntax is not set

error: Default syntax "Packages/MarkdownEditing/Markdown.tmLanguage" is not installed!

But I can still set it manually, and the path is the same

>>> view.settings().get('syntax')
'Packages/MarkdownEditing/Markdown.tmLanguage'

@Cacodaimon
Copy link
Contributor

Can you set your default syntax from

"default_syntax": "Packages/MarkdownEditing/Markdown.tmLanguage",

to

"default_syntax": "Markdown.tmLanguage",

this should match to the right syntax, since the output from find_ressources was ['Packages/MarkdownEditing/Markdown.tmLanguage', 'Packages/MarkdownEditing/MultiMarkdown.tmLanguage'] on your system…

@fregante
Copy link
Owner Author

Cool! It started working after I restarted ST.

The sublime.error_message should probably be disabled though, especially because it happens at every connection even with the default settings.

Can we make it so it defaults to Markdown if what they specify is not found? If Markdown is not found either it should default to Plain Text. Errors can appear in the console

@Cacodaimon
Copy link
Contributor

You are right I gonna change it to your suggested behavior.

@Feltzer
Copy link
Contributor

Feltzer commented Jul 15, 2014

Can someone please check if it works now, if I got an OK I gonna create a new tag.

Working fine for me now as well. Great job!

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

No branches or pull requests

3 participants