Skip to content

Commit

Permalink
Use filetype instead of file extension to detect file type.
Browse files Browse the repository at this point in the history
  • Loading branch information
Clcanny committed Jun 26, 2020
1 parent ce11df2 commit 330ab7e
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions python/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,18 @@


def main():
# TODO(junbin.rjb) Get filetype.
name = vim.current.buffer.name
if name.endswith(".json"):
filetype = vim.eval("&filetype")
if filetype == "json":
JsonFormatter().run()
elif name.endswith(".xml"):
elif filetype == "xml":
XmlFormatter().run()
elif name.endswith(".sh"):
elif filetype == "sh":
BashFormatter().run()
elif name.endswith(".py"):
elif filetype == "python":
PythonFormatter().run()
elif name.endswith(".h") or name.endswith(".cpp"):
elif filetype == "c" or filetype == "cpp":
CppFormatter().run()
elif name.endswith("CMakeLists.txt"):
elif filetype == "cmake":
CMakeFormatter().run()
else:
raise RuntimeError("Unknown filetype.")

0 comments on commit 330ab7e

Please sign in to comment.