spadgos / sublime-DefaultFileType

ST2 Package which automatically sets the syntax for new files
MIT License
68 stars 20 forks source link

ST3 support? #4

Open cviebrock opened 11 years ago

cviebrock commented 11 years ago

Any chance of making your plug-in compatible with ST3?

MattDMo commented 11 years ago

It's completely compatible with ST3, I don't know why it's marked ST2-only. You'll have to manually clone the repo into your Packages directory, but other than that it works fine out of the box.

cviebrock commented 11 years ago

I think you need to follow the instructions here: https://sublime.wbond.net/docs/developers

and change the lines https://github.com/wbond/package_control_channel/blob/master/repository/d.json#L138-L147 to read:

{
    "name": "Default File Type",
    "details": "https://github.com/spadgos/sublime-DefaultFileType",
    "releases": [
        {
            "sublime_text": "*",
            "details": "https://github.com/spadgos/sublime-DefaultFileType/tree/master"
        }
    ]
},

That should make it show up in Package Control as working with ST2 and ST3.

cviebrock commented 10 years ago

I've done this for you: https://github.com/wbond/package_control_channel/pull/2421

FichteFoll commented 10 years ago

Merged.

CNG commented 10 years ago

Not being a Sublime Text or OSX pro yet, I was unsure exactly what was meant by "Sublime base directory". I guessed this was /Users/username/Library/Application Support/Sublime Text 3, but the structure seems to be different than it was in ST2. I don't have language folders under the Packages folder, nor do I seem to have a file called "Java.tmLanguage" like the example anywhere on my system.''

Do the docs need to be updated for ST3 or am I missing something? Thanks!

FichteFoll commented 10 years ago

ST3 stores the standard packages in the application folder (where it is installed). See http://www.sublimetext.com/docs/3/packages.html

CNG commented 10 years ago

Thank you @FichteFoll, that's very helpful!

kaimantsch commented 10 years ago

For ST 3 I can't seem to find the default language definitions there (/Applications/Sublime Text 3.app/Contents/MacOS/Packages) or in the (/Users/kai/Library/Application Support/Sublime Text 3/Packages)

Are they compressed in the Markdown.sublime-package file? Would I need to extract this, leave extracted, and point at it? Or am I missing something here?

Thanks, Kai

FichteFoll commented 10 years ago

Yes, packages are stored in zip archives which have the .sublime-package extension. See also the docs page I linekd above. You can get https://github.com/skuroda/PackageResourceViewer which eases the work with zipped packages.

CNG commented 10 years ago

Hi @kaimantsch, do you mean you looked in /Applications/Sublime Text.app/Contents/MacOS/Packages and saw only a Markdown.sublime-package file? You said Sublime Text 3.app but I'm not sure if that was a typo. Mine doesn't have the "3" in the .app filename but does have the "3" in the data directory, ~/Library/Application Support/Sublime Text 3/.

Anyway, my /Applications/Sublime Text.app/Contents/MacOS/Packages contains 48 .sublime-package files corresponding to the various languages.

That said, I'm actually not sure if I have the DefaultFileType plugin working. My default_file_type.sublime-settings file is currently empty, but I seem to have the "open new file as current filetype" behavior working anyway. I guess I forgot where I left off and now am not sure if it was always like that.

CNG commented 10 years ago

Oh on second reading, you're looking to reference Markdown? For some reason I thought you were saying all you had was a Markdown file.

kaimantsch commented 10 years ago

Yes, I was hoping to have Markdown be the default but I can't find the .tmLanguage file for it anywhere. (I renamed my app in the /Applications dir. No problems there.)

CNG commented 10 years ago

If you were to duplicate the "Markdown.sublime-package" file, rename it "Markdown.zip" and extract it, you should find "Markdown/Markdown.tmLanguage". You don't need to actually extract the ZIP, though, but it's how you can be sure of the file name/path.

So to set Markdown as the default file type, I think you would create ~/Library/Application Support/Sublime Text 3/Packages/User/default_file_type.sublime-settings:

{
  "default_new_file_syntax" : "Packages/Markdown/Markdown.tmLanguage",
  "use_current_file_syntax" : false
}

Also note from the docs of this plugin:

This only affects files which are created with the Ctrl+N shortcut (Cmd+N on OSX).

Does that help?

kaimantsch commented 10 years ago

I have only been using the cmd-N to open/test the feature.

I tried a number of paths:

Packages/Markdown/MultiMarkdown.tmLanguage /Packages/Markdown/MultiMarkdown.tmLanguage

I then extracted the MultiMarkdown.tmLanguage from the zip file and just dumped it in the App Packages directory and used the full path:

Error loading syntax file "/Applications/Sublime Text 3.app/Contents/MacOS/Packages/MultiMarkdown.tmLanguage

I moved it several more places, including ~/MultiMarkdown.tmLanguage

Complaint is the same about not being able to open:

Error loading syntax file "~/MultiMarkdown.tmLanguage": Unable to open ~/MultiMarkdown.tmLanguage

Other ideas? Is this working for you?

kaimantsch commented 10 years ago

Correction: I somehow forced a reload that suddenly caused it to work. I went back and even tried Packages/Markdown/MultiMarkdown.tmLangugage and suddenly that works too. I forgot the cardinal rule: "have you tried unplugging it and plugging it back in?" No idea what they worked but seems to be fine now.

Thanks for all the help debugging!

CNG commented 10 years ago

I haven't tried extracting it or moving it anywhere, but just with the default ST3 install and then with DefaultFileType package installed, I get it to work just fine by having this as my default_file_type.sublime-settings file:

{
  "default_new_file_syntax" : "Packages/Markdown/MultiMarkdown.tmLanguage",
  "use_current_file_syntax" : false
}

Is the use_current_file_syntax setting working for you when you set it to true?

CNG commented 10 years ago

Hah OK, glad it works. For me, the changes to the settings file seem to take immediately. I can change to another language, save, and then do Cmd+N and it opens a new tab as the new file type immediately.

kaimantsch commented 10 years ago

The crazy thing is that clear that was happening, at least in part. I would hit cmd-n and it would complain that it couldn't open the file named just as I had typed in the lastest change. So clearly it had read the new file name each time and updated. But somehow... something changed? Suddenly all the same combinations I tried before worked. I went back and tried them all. Anyway, clearly a Sublime text issue and not with your plugin. Hopefully all of this working back and forth will be useful to someone! When in doubt... reboot.

absolutejam commented 10 years ago

I've got the exact same issue as kaimantsch except that a reboot didn't fix it, neither did a reinstall of the package.

If I look under View > Syntax it has the correct language/syntax selected (From my default_file_type.sublime-settings) but it isn't loading all of the syntax.

I've tried;

{
  "default_new_file_syntax" : "Packages/Markdown/MultiMarkdown.tmLanguage",
   "use_current_file_syntax" : false
}

and when I create a new document, it has the white background (as per the language settings) and the correct option is selected in View > Syntax > MarkdownEditing > MultiMarkDown but none of the highlighting or auto-completion works.

I've also tried tried HTML and XML to test and I get the same symptoms.

mliq commented 10 years ago

Did you actually extract the .tmlanguage file to Packages/User/ and then reference it there? That worked for me with Markdown Extended.