emmetio / sublime-tern

TernJS plugin for Sublime Text
222 stars 13 forks source link

Disabling TernJS on a specific file type #27

Closed RaphaelDDL closed 10 years ago

RaphaelDDL commented 11 years ago

Hello there Sergey,

short question I'd like to know how I specifically turn TernJS scan for other *.js in a specific file type (this case, .cshtml).

On the emmet.io blog post ( emmet.io/blog/sublime-tern/ ) says this:

Otherwise, if you’re editing file outside project, code completion and other actions will work for this file only.

Seems it's still trying to load other *.js even outside a project, thus crashing ST2.


long explanation of why

Let me explain the problem i have:

I use projects like it's suggested on emmet.io blog post but sometimes I need to edit files that are inside a Visual Studio Project (no ST project). So I only open the .cshtml file inside ST2 without any project only to edit it (because has Emmet, ternjs, jshint, etc etc and VS is bad) but it has sometimes calls to .js files like so <script type="text/javascript" src="/Content/Resources/something/something.js"></script>.

I don't know exactly why but everytime there are scripts included on the .cshtml files, ST2 crashes when I'm writing javascript. I've tested and crashed twice when I tried write the same thing (just a $(selector).val() crashes after pressing v of val). I've removed ternJS and ST stopped crashing. I redownloaded pyV8 but still crashes.

So I think that in this case, the ternJS script that tries to load and analyse other .js files is somewhat 'dying'.

The "exclude": [ /**/ ], seems to only accept folders, since i tried "exclude": ["**/*.cshtml"] and had no luck.

Thanks alot for another awesome plugin and your time reading.

Best Regards, RaphaelDDL

sergeche commented 11 years ago

You can try to modify completions_allowed() method: https://github.com/emmetio/sublime-tern/blob/master/tern.py#L405

You can check view.file_name() and return False when you want to disable Tern.

RaphaelDDL commented 11 years ago

I have no python knowledge but I'll try mess around a bit. Maybe I'll get it to work =D Thanks for pointing out, Sergey