Skip to content
This repository was archived by the owner on Dec 15, 2022. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions index.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require "./lib/language-makefile"
25 changes: 25 additions & 0 deletions lib/language-makefile.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
path = require 'path'

module.exports =
activate: (state) ->
forceHardTabsForMakefiles()

forceHardTabsForMakefiles = () ->
atom.workspaceView.eachEditorView (editorView) ->
editor = editorView.getEditor()
grammarScope = editor.getGrammar()['scopeName']
if grammarScope is 'text.plain.null-grammar'

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is here because when you load a makefile directly without atom already running (ie: atom Makefile), the Makefile language isn't loaded before this code is run so the scope is set to a null-grammar.

In this case, I fall back to parsing the file type directly so that it will still work on that first load.

hardTabsBasedOnFileType(editor)
if grammarScope is 'source.makefile'
editor.setSoftTabs(false)

hardTabsBasedOnFileType = (editor) ->
fileTypes = [
'Makefile'
'makefile'
'GNUmakefile'
'OCamlMakefile'
'mk'
]
if path.basename(editor.getPath()) in fileTypes
editor.setSoftTabs(false)