Skip to content
This repository was archived by the owner on Dec 12, 2021. It is now read-only.

Commit aa4ae93

Browse files
committed
Auto-set language when inserting into new file
1 parent 9fd4295 commit aa4ae93

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
- Quick Start Guide enhanced
1414
- `README.md`
1515
- IMEX module configuration
16+
- Auto-set Editor grammar when inserting into new file
1617
#### Patches
1718
- Debug output
1819
- Available debug commands reduced

lib/snippet-injector.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,17 @@ export default {
214214
autoDecreaseIndent: true,
215215
normalizeLineEndings: true
216216
});
217+
218+
if(atom.workspace.getActiveTextEditor().getGrammar().name === 'Null Grammar') {
219+
atom.workspace.getActiveTextEditor().setGrammar(atom.grammars.grammars.filter(function(e) {
220+
if(e.name === snippet.getLang()) {
221+
return true;
222+
} else {
223+
return false;
224+
}
225+
})[0]);
226+
}
227+
217228
atom.notifications.addSuccess('Snippet \''+snippet.getTitle()+'\' was successfully inserted.', null);
218229
}
219230
});

0 commit comments

Comments
 (0)