Repository: rust-lang/rust-enhanced (language: rust)

Issue:
Open Rust views do not automatically switch syntax after installation
See [this comment](https://github.com/rust-lang/rust-enhanced/issues/278#issuecomment-388813339) from #278:

> When using a project/workspace in sublime, the editor seems to cache the language plugin setting for all open files.

> So when you disable Rust without closing all .rs files already open in the workspace - they get stuck with the old type information. Even though View>Syntax>Open all with this extension is pointing at Rust Enhanced, this setting is not applied until you close and reopen the .rs file again.

---

>  It should be fixable (it can iterate over open views after installation and adjust the syntax based on extension).


Discussion / hints:

Fix patch:
diff --git a/README.md b/README.md
index fdbb72e9..3d317911 100644
--- a/README.md
+++ b/README.md
@@ -25,8 +25,6 @@ and select `Package Control: Install Package` and then select `Rust Enhanced` fr
 the list. That's it.
 If you can't see `Rust Enhanced` its most likely because you're using Sublime Text 2.
 
-It is possible that the built-in `Rust` package will cause conflicts with Rust Enhanced. If the default syntax for Rust documents is `Rust` instead of `Rust Enhanced`, then this is likely the case. A recommended solution is to disable the built-in `Rust` package. You can do so through `Package Control: Disable Package` -> `Rust`.
-
 ## Features
 ### Go To Definition
 ### Cargo Build
diff --git a/cargo_build.py b/cargo_build.py
index 3f072b44..2025ea8f 100644
--- a/cargo_build.py
+++ b/cargo_build.py
@@ -518,3 +518,27 @@ def plugin_unloaded():
             del sys.modules[key]
         if package_name in sys.modules:
             del sys.modules[package_name]
+
+
+def plugin_loaded():
+    try:
+        from package_control import events
+    except ImportError:
+        return
+    package_name = __package__.split('.')[0]
+    if events.install(package_name):
+        # Update the syntax for any open views.
+        for window in sublime.windows():
+            for view in window.views():
+                fname = view.file_name()
+                if fname and fname.endswith('.rs'):
+                    view.settings().set('syntax',
+                        'Packages/%s/RustEnhanced.sublime-syntax' % (package_name,))
+
+        # Disable the built-in Rust package.
+        settings = sublime.load_settings('Preferences.sublime-settings')
+        ignored = settings.get('ignored_packages', [])
+        if 'Rust' not in ignored:
+            ignored.append('Rust')
+            settings.set('ignored_packages', ignored)
+            sublime.save_settings('Preferences.sublime-settings')


Test patch: