try to use filetype as syntax style, misc refactoring

This pull request makes the syntax filetype optional, and tries to use the file's filetype if none is provided.