Last active
August 29, 2015 14:18
-
-
Save IceDragon200/6c3f18d57aaa682c0097 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'fileutils' | |
#def fix_tabs(data) | |
# data.gsub(/^(\s{4})+/, "\t").gsub(/^\s+(\n)?$/, '\1').gsub(/\s+(\n)?$/, '\1') | |
#end | |
def fix_lines(filename, data) | |
result = '' | |
#ignore_newline = false | |
data.each_line.each_with_index do |line, lineno| | |
if line.strip.start_with?('#') | |
puts "preprocessor line: #{filename}:#{lineno+1} (#{line.chomp})" | |
# remove trailing ; on preprocessor lines | |
result << line.gsub(/;(\n)?$/, '\1') | |
elsif line.start_with?('}') | |
puts "left bound closing bracket: #{filename}:#{lineno+1}" | |
result << line << "\n" | |
else | |
#if ignore_newline && line.strip.empty? | |
# puts "Skipping line #{filename}:#{lineno+1}" | |
# next | |
#end | |
result << line | |
#ignore_newline = line.strip.empty? | |
end | |
end | |
result.gsub(/(\n{3,})/, "\n\n") # treat 3+ consecutive newlines as 2 | |
.gsub(/(\n+)\z/, "\n") # replace trailing newlines at the end of the file, with 1 | |
.gsub(/\A(\n+)/, '') # remove heading newlines | |
end | |
FileUtils::Verbose.cp_r 'Base', 'BaseBackup' unless File.exist?('BaseBackup') | |
Dir.glob('Base/**/*.as') do |filename| | |
#puts filename | |
File.write(filename, fix_lines(filename, File.read(filename))) | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"autoformat_on_save": true, | |
"user_defined_syntax_mode_mapping": { | |
// For example: | |
/* | |
"arduino": "c", | |
"pde": "java", | |
"apex": "java" | |
*/ | |
"angelscript": "c", | |
"glsl": "c" | |
}, | |
"options_default": { | |
"style": "linux", | |
"indent": "spaces", | |
"indent-spaces": 2, | |
"break-blocks": "all", | |
"unpad-paren": true, | |
"delete-empty-lines": true, | |
"break-closing-brackets": true, | |
"break-elseifs": true, | |
"remove-comment-prefix": true, | |
"add-brackets": true | |
}, | |
"options_angelscript": { | |
"style": "google", | |
"add-brackets": false, | |
"add-one-line-brackets": false, | |
"break-blocks": "default", | |
"break-closing-brackets": false, | |
"break-elseifs": false, | |
"delete-empty-lines": false, | |
"indent": "tab", | |
"indent-spaces": 4, | |
"indent-namespaces": true, | |
"indent-switches": true, | |
"keep-one-line-statements": true, | |
"unpad-paren": true | |
}, | |
"options_glsl": { | |
"indent": "tab", | |
"indent-spaces": 4 | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment