diff --git a/lib/init.coffee b/lib/init.coffee index 2eaee34..57eb466 100644 --- a/lib/init.coffee +++ b/lib/init.coffee @@ -3,6 +3,7 @@ path = require 'path' module.exports = configDefaults: filters: '' + extensions: 'c++' cpplintExecutablePath: path.join __dirname, '..', 'bin' activate: -> diff --git a/lib/linter-cpplint.coffee b/lib/linter-cpplint.coffee index b44abda..de1064b 100644 --- a/lib/linter-cpplint.coffee +++ b/lib/linter-cpplint.coffee @@ -26,14 +26,25 @@ class LinterCpplint extends Linter @executablePath = atom.config.get 'linter-cpplint.cpplintExecutablePath' atom.config.observe 'linter-cpplint.filters', => - filters = atom.config.get 'linter-cpplint.filters' - if filters.length == 0 - @cmd = 'cpplint.py --extensions=c++' - else - @cmd = 'cpplint.py --extensions=c++ --filter=' + filters + @updateCommand() + + atom.config.observe 'linter-cpplint.extensions', => + @updateCommand() + + updateCommand: -> + filters = atom.config.get 'linter-cpplint.filters' + extensions = atom.config.get 'linter-cpplint.extensions' + cmd = "cpplint.py" + if filters + cmd = "#{cmd} --filter=#{filters}" + if extensions + cmd = "#{cmd} --extensions=#{extensions}" + @cmd = cmd + destroy: -> atom.config.unobserve 'linter-cpplint.filters' + atom.config.unobserve 'linter-cpplint.extensions' atom.config.unobserve 'linter-cpplint.cpplintExecutablePath' # Private: cpplint outputs line 0 for some errors. This needs to be changed to