fregante / GhostText

👻 Use your text editor to write in your browser. Everything you type in the editor will be instantly updated in the browser (and vice versa).
https://GhostText.fregante.com
MIT License
3.32k stars 115 forks source link

Syntax support seems broken #59

Closed 23maverick23 closed 8 years ago

23maverick23 commented 8 years ago

First off - great plugin! Very helpful for some workflows I use at the office.


Overview:

When running GhostText on ST 3103, default syntaxes and host-specific syntaxes aren't working. It looks like you're using the sublime.find_resources method Utils.py#L131-L162, but doesn't this only search for files within installed packages (and not in standard packages)? Might be best to just have users specify the full syntax path of the .tmLanuage file (e.g. Packages/Markdown/Markdown.tmLanguage).

If I manually type your syntax lookup code into the ST console, I'm returning an empty array:

>>> settings = sublime.load_settings('GhostText.sublime-settings')
>>> default_syntax = settings.get('default_syntax', 'Markdown.tmLanguage')
>>> default_syntax
'Markdown.tmLanguage'
>>> resources = sublime.find_resources('*{}'.format(default_syntax))
>>> resources
[]

If I just look for .tmLanugage resource files, I do get results (so the sublime.find_resources method is working), but these are only from installed packages:

>>> sublime.find_resources('*.tmLanguage')
['Packages/Text/Plain text.tmLanguage', 'Packages/ApacheConf.tmLanguage/ApacheConf.tmLanguage', 'Packages/Emmet/Emmet.tmLanguage', 'Packages/Evernote/Evernote.tmLanguage', 'Packages/FreeMarker/Syntaxes/FreeMarker.tmLanguage', 'Packages/Sass/Syntaxes/Sass.tmLanguage', 'Packages/Swift/Syntaxes/Swift.tmLanguage', 'Packages/Theme - Afterglow/Prefs/Langs/Bower JSON.tmLanguage', 'Packages/Theme - Afterglow/Prefs/Langs/Dockerfile.tmLanguage', 'Packages/Theme - Afterglow/Prefs/Langs/font.tmLanguage', 'Packages/Theme - Afterglow/Prefs/Langs/Git.tmLanguage', 'Packages/Theme - Afterglow/Prefs/Langs/Gruntfile Coffee.tmLanguage', 'Packages/Theme - Afterglow/Prefs/Langs/Gruntfile JS.tmLanguage', 'Packages/Theme - Afterglow/Prefs/Langs/Gulpfile Coffee.tmLanguage', 'Packages/Theme - Afterglow/Prefs/Langs/Gulpfile JS.tmLanguage', 'Packages/Theme - Afterglow/Prefs/Langs/npm JSON.tmLanguage', 'Packages/XML SRP/XML (NSOA).tmlanguage', 'Packages/User/fish.tmLanguage']

Steps to Reproduce:

  1. Set thedefault_syntax settings key to Markdown.tmLanguage
  2. Open a new textarea connection
  3. Syntax file still shows as Plain Text.tmLanguage

Console Output:

Start
Listening on: 54346
Bind view with id: 178
Setting on message handler
Default syntax "Markdown.tmLanguage" is not installed!
View with id: 178 closed
Unbind view with id: 178
Stop

Sys Details:

>>> sublime.version()
'3103'
>>> sublime.platform()
'osx'
>>> sublime.arch()
'x64'
fregante commented 8 years ago

Thank you for your detailed issue! Hopefully this can be solved by just specifying a file extension and let ST do the matching. I'll give it a try today, but I don't want to get your hopes up because we might already have tried this.

23maverick23 commented 8 years ago

I can try submitting a pull request for this. I think the only option is to require users to store the full path and then match against that.

On Friday, March 25, 2016, Federico Brigante notifications@github.com wrote:

Thank you for your detailed issue! Hopefully this can be solved by just specifying a file extension and let ST do the matching. I'll give it a try today, but I don't want to get your hopes up because we might already have tried this.

— You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub https://github.com/Cacodaimon/GhostText-for-SublimeText/issues/59#issuecomment-201658052

Ryan Morrissey e: 23maverick23@gmail.com m: +1 857.225.1098 w: rymo.io

fregante commented 8 years ago

Thank you, but this is too complex, the solution I had suggested seems to work. I'll send a PR soon so @Cacodaimon can take a look since he knows GT-ST better.

Currently we create a tab and then figure out the syntax. My suggested solution is:

fregante commented 8 years ago

Let me know what you think @Cacodaimon

Cacodaimon commented 8 years ago

@bfred-it

Sorry I did not noticed the activity in the last days, I was too busy the last year :) , give me some time reading all the issues.

fregante commented 8 years ago

:tada: :grinning: Welcome back, I realized you were busy so I didn't ping you too much :P

Cacodaimon commented 8 years ago

@bfred-it

It seems to work and it is much lesser code. I like the solution!