my configs
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

51 lines
1.2 KiB

  1. -- Try to determine filetype by examining actual file contents; read as little
  2. -- as possible, and try to keep things simple and specific to what I typically
  3. -- work on, and will expect to be syntax-highlighted.
  4. -- Read first line
  5. local line = vim.fn.getline(1)
  6. local filetype = vim.opt.filetype
  7. -- If it's not a shebang, we're done
  8. if not line.starts "^#!" then
  9. return
  10. end
  11. if line.find "<[gm]=awk>" then
  12. -- AWK
  13. filetype = "awk"
  14. elseif line.find "<perl5=>" then
  15. -- Perl 5
  16. filetype = "perl"
  17. elseif line.find "<perl6>" then
  18. -- Perl 6
  19. filetype = "perl6"
  20. elseif line.find "<php>" then
  21. -- PHP
  22. filetype = "php"
  23. elseif line.find "<python[23]=>" then
  24. -- Python
  25. filetype = "python"
  26. elseif line.find "<ruby[23]=>" then
  27. -- Ruby
  28. filetype = "ruby"
  29. elseif line.find "<sed>" then
  30. -- sed
  31. filetype = "sed"
  32. elseif line.find "<bash>" then
  33. -- Bash
  34. vim.b.is_bash = true
  35. filetype = "sh"
  36. elseif line.find "<%(ksh|ksh93|mksh|pdksh)>" then
  37. -- Korn shell
  38. vim.b.is_kornshell = true
  39. filetype = "sh"
  40. elseif line.find "<sh>" then
  41. -- POSIX/Bourne shell
  42. vim.b.is_posix = 1
  43. filetype = "sh"
  44. elseif line.find "<%(tcl|wish)>" then
  45. -- TCL
  46. filetype = "tcl"
  47. end