]> granicus.if.org Git - vim/commitdiff
patch 8.2.3050: cannot recognize elixir files v8.2.3050
authorAustin Gatlin <austin@gatlin.io>
Sat, 26 Jun 2021 10:02:55 +0000 (12:02 +0200)
committerBram Moolenaar <Bram@vim.org>
Sat, 26 Jun 2021 10:02:55 +0000 (12:02 +0200)
Problem:    Cannot recognize elixir files.
Solution:   Recognize Elixir-specific files.  Check if an .ex file is Euphoria
            or Elixir. (Austin Gatlin, closes #8401, closes #8446)

runtime/autoload/dist/ft.vim
runtime/filetype.vim
src/testdir/test_filetype.vim
src/version.c

index 1ac74b57854ec4dd1af169cd401ad48ad70b0aee..ac8065911370dfe614648736a013c1efc17760af 100644 (file)
@@ -172,6 +172,17 @@ func dist#ft#FTent()
   setf dtd
 endfunc
 
+func dist#ft#ExCheck()
+  let lines = getline(1, min([line("$"), 100]))
+  if exists('g:filetype_euphoria')
+    exe 'setf ' . g:filetype_euphoria
+  elseif match(lines, '^--\|^ifdef\>\|^include\>') > -1
+    setf euphoria3
+  else
+    setf elixir
+  endif
+endfunc
+
 func dist#ft#EuphoriaCheck()
   if exists('g:filetype_euphoria')
     exe 'setf ' . g:filetype_euphoria
index 496b58b31352a16c485bae713178ec3e7b21a929..e38bc23de0c99d15199d05449738022625619458 100644 (file)
@@ -393,7 +393,7 @@ au BufNewFile,BufRead *.cfm,*.cfi,*.cfc             setf cf
 " Configure scripts
 au BufNewFile,BufRead configure.in,configure.ac setf config
 
-" CUDA  Cumpute Unified Device Architecture
+" CUDA Compute Unified Device Architecture
 au BufNewFile,BufRead *.cu,*.cuh               setf cuda
 
 " Dockerfile; Podman uses the same syntax with name Containerfile
@@ -408,8 +408,15 @@ au BufNewFile,BufRead *enlightenment/*.cfg setf c
 " Eterm
 au BufNewFile,BufRead *Eterm/*.cfg             setf eterm
 
+" Elixir or Euphoria
+au BufNewFile,BufRead *.ex call dist#ft#ExCheck()
+
+" Elixir
+au BufRead,BufNewFile mix.lock,*.exs setf elixir
+au BufRead,BufNewFile *.eex,*.leex setf eelixir
+
 " Euphoria 3 or 4
-au BufNewFile,BufRead *.eu,*.ew,*.ex,*.exu,*.exw  call dist#ft#EuphoriaCheck()
+au BufNewFile,BufRead *.eu,*.ew,*.exu,*.exw  call dist#ft#EuphoriaCheck()
 if has("fname_case")
    au BufNewFile,BufRead *.EU,*.EW,*.EX,*.EXU,*.EXW  call dist#ft#EuphoriaCheck()
 endif
index 5c9c9753ccc636f65520c31e3de1aab8dfdddd9a..50293e524db6fd3aef2458450f88bd34163cfe9d 100644 (file)
@@ -161,6 +161,8 @@ let s:filename_checks = {
     \ 'ecd': ['file.ecd'],
     \ 'edif': ['file.edf', 'file.edif', 'file.edo'],
     \ 'elinks': ['elinks.conf'],
+    \ 'elixir': ['file.ex', 'file.exs', 'mix.lock'],
+    \ 'eelixir': ['file.eex', 'file.leex'],
     \ 'elm': ['file.elm'],
     \ 'elmfilt': ['filter-rules'],
     \ 'epuppet': ['file.epp'],
@@ -790,5 +792,41 @@ func Test_pp_file()
   filetype off
 endfunc
 
+func Test_ex_file()
+  filetype on
+
+  call writefile(['arbitrary content'], 'Xfile.ex')
+  split Xfile.ex
+  call assert_equal('elixir', &filetype)
+  bwipe!
+  let g:filetype_euphoria = 'euphoria4'
+  split Xfile.ex
+  call assert_equal('euphoria4', &filetype)
+  bwipe!
+  unlet g:filetype_euphoria
+
+  call writefile(['-- filetype euphoria comment'], 'Xfile.ex')
+  split Xfile.ex
+  call assert_equal('euphoria3', &filetype)
+  bwipe!
+
+  call writefile(['--filetype euphoria comment'], 'Xfile.ex')
+  split Xfile.ex
+  call assert_equal('euphoria3', &filetype)
+  bwipe!
+
+  call writefile(['ifdef '], 'Xfile.ex')
+  split Xfile.ex
+  call assert_equal('euphoria3', &filetype)
+  bwipe!
+
+  call writefile(['include '], 'Xfile.ex')
+  split Xfile.ex
+  call assert_equal('euphoria3', &filetype)
+  bwipe!
+
+  call delete('Xfile.ex')
+  filetype off
+endfunc
 
 " vim: shiftwidth=2 sts=2 expandtab
index 36a3970d057de2712521075a422551358c16f8c1..32aec1b506fee471b7335e2370c39deea0cdcf67 100644 (file)
@@ -755,6 +755,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    3050,
 /**/
     3049,
 /**/