Loading ...
Sorry, an error occurred while loading the content.

how to debug file type recognition

Expand Messages
  • Matteo Cavalleri
    i have two identical smarty files: i load the first one and it gets recognized as heist . i load the second one and it gets correclty recognized as smarty...
    Message 1 of 9 , May 21 3:52 AM
    • 0 Attachment
      i have two identical smarty files: i load the first one and it gets recognized as "heist". i load the second one and it gets correclty recognized as smarty... how can that happen?

      if i start vim with "vim -u NONE -U NONE" and give the commands ":set nocompatible" and ":syntax on", the files are all recognized as smarty, so the problem should either be in my .vimrc or some plugin, but i have no idea where to look for to fix this problem.

      thanks in advance.

      --
      --
      You received this message from the "vim_use" maillist.
      Do not top-post! Type your reply below the text you are replying to.
      For more information, visit http://www.vim.org/maillist.php

      ---
      You received this message because you are subscribed to the Google Groups "vim_use" group.
      To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
      For more options, visit https://groups.google.com/groups/opt_out.
    • tooth pik
      ... the first thing I d try would be ... in the first heist buffer -- -- You received this message from the vim_use maillist. Do not top-post! Type your
      Message 2 of 9 , May 21 7:34 AM
      • 0 Attachment
        On Tue, May 21, 2013 at 03:52:03AM -0700, Matteo Cavalleri wrote:
        > i have two identical smarty files: i load the first one and it gets
        > recognized as "heist". i load the second one and it gets correclty
        > recognized as smarty... how can that happen?

        > if i start vim with "vim -u NONE -U NONE" and give the commands
        > ":set nocompatible" and ":syntax on", the files are all recognized
        > as smarty, so the problem should either be in my .vimrc or some
        > plugin, but i have no idea where to look for to fix this problem.

        the first thing I'd try would be

        :verbose set ft?

        in the first "heist" buffer

        --
        --
        You received this message from the "vim_use" maillist.
        Do not top-post! Type your reply below the text you are replying to.
        For more information, visit http://www.vim.org/maillist.php

        ---
        You received this message because you are subscribed to the Google Groups "vim_use" group.
        To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
        For more options, visit https://groups.google.com/groups/opt_out.
      • Ben Fritz
        ... Content is identical? Or file name/extension? Or both? -- -- You received this message from the vim_use maillist. Do not top-post! Type your reply below
        Message 3 of 9 , May 21 7:40 AM
        • 0 Attachment
          On Tuesday, May 21, 2013 5:52:03 AM UTC-5, Matteo Cavalleri wrote:
          > i have two identical smarty files:

          Content is identical? Or file name/extension? Or both?

          --
          --
          You received this message from the "vim_use" maillist.
          Do not top-post! Type your reply below the text you are replying to.
          For more information, visit http://www.vim.org/maillist.php

          ---
          You received this message because you are subscribed to the Google Groups "vim_use" group.
          To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
          For more options, visit https://groups.google.com/groups/opt_out.
        • Christian Brabandt
          ... My guess is, this is caused by some kind of plugins, cause the standard distributed filetype.vim file doesn t know about the filetype heist . So check
          Message 4 of 9 , May 21 7:48 AM
          • 0 Attachment
            On Tue, May 21, 2013 12:52, Matteo Cavalleri wrote:
            > i have two identical smarty files: i load the first one and it gets
            > recognized as "heist". i load the second one and it gets correclty
            > recognized as smarty... how can that happen?
            >
            > if i start vim with "vim -u NONE -U NONE" and give the commands ":set
            > nocompatible" and ":syntax on", the files are all recognized as smarty, so
            > the problem should either be in my .vimrc or some plugin, but i have no
            > idea where to look for to fix this problem.
            >
            > thanks in advance.

            My guess is, this is caused by some kind of plugins, cause
            the standard distributed filetype.vim file doesn't know about
            the filetype "heist".

            So check your plugins.

            regards,
            Christian

            --
            --
            You received this message from the "vim_use" maillist.
            Do not top-post! Type your reply below the text you are replying to.
            For more information, visit http://www.vim.org/maillist.php

            ---
            You received this message because you are subscribed to the Google Groups "vim_use" group.
            To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
            For more options, visit https://groups.google.com/groups/opt_out.
          • Matteo Cavalleri
            ... they are identical in content and extension. name is obviously different. i just did another test with these steps: touch foo1.tpl vim foo1.tpl - put some
            Message 5 of 9 , May 23 1:33 AM
            • 0 Attachment
              > > i have two identical smarty files:
              >
              > Content is identical? Or file name/extension? Or both?

              they are identical in content and extension. name is obviously different. i just did another test with these steps:

              touch foo1.tpl
              vim foo1.tpl -> put some smarty/html tags and quit
              cp foo1.tpl foo2.tpl
              vim foo1.tpl -> recognized as heist
              :e foo2.tpl -> recognized as smarty

              after loading foo1.tpl, "verbose set ft?" gives:

              filetype=heist
              Last set from ~/.vim/bundle/vim2hs/ftdetect/heist.vim

              after loading foo2.tpl

              filetype=smarty
              Last set from ~/.vim/ftplugin/smarty.vim

              so the culprit is known, but the question is why? why the first file gets recognized one way and the second another way?

              --
              --
              You received this message from the "vim_use" maillist.
              Do not top-post! Type your reply below the text you are replying to.
              For more information, visit http://www.vim.org/maillist.php

              ---
              You received this message because you are subscribed to the Google Groups "vim_use" group.
              To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
              For more options, visit https://groups.google.com/groups/opt_out.
            • Matteo Cavalleri
              ... the content of ~/.vim/bundle/vim2hs/ftdetect/heist.vim is just: autocmd BufNewFile,BufRead *.tpl setlocal filetype=heist the content of
              Message 6 of 9 , May 23 1:36 AM
              • 0 Attachment
                > so the culprit is known, but the question is why? why the first file gets recognized one way and the second another way?

                the content of ~/.vim/bundle/vim2hs/ftdetect/heist.vim is just:

                autocmd BufNewFile,BufRead *.tpl setlocal filetype=heist

                the content of ~/.vim/ftplugin/smarty.vim is:

                au BufRead,BufNewFile *.tpl set filetype=smarty

                (plus some other code fir match it)

                --
                --
                You received this message from the "vim_use" maillist.
                Do not top-post! Type your reply below the text you are replying to.
                For more information, visit http://www.vim.org/maillist.php

                ---
                You received this message because you are subscribed to the Google Groups "vim_use" group.
                To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
                For more options, visit https://groups.google.com/groups/opt_out.
              • Matteo Cavalleri
                ok, i finally found this in the documentation: When the same extension is used for two filetypes, Vim tries to guess what kind of file it is. This doesn t
                Message 7 of 9 , May 23 2:20 AM
                • 0 Attachment
                  ok, i finally found this in the documentation: "When the same extension is used for two filetypes, Vim tries to guess what kind of file it is. This doesn't always work." and "The files in the "ftdetect" directory are used after all the default checks, thus they can overrule a previously detected file type"

                  so i suppose i should have done my homework a little bit harder. sorry for this, i'll try not to spam this group any longer :) thanks for your help

                  --
                  --
                  You received this message from the "vim_use" maillist.
                  Do not top-post! Type your reply below the text you are replying to.
                  For more information, visit http://www.vim.org/maillist.php

                  ---
                  You received this message because you are subscribed to the Google Groups "vim_use" group.
                  To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
                  For more options, visit https://groups.google.com/groups/opt_out.
                • Ben Fritz
                  ... Files in the ftplugin directory should not be setting the filetype. That may be the culprit of your multiple loads as well. ftplugin/smarty.vim should only
                  Message 8 of 9 , May 23 4:39 AM
                  • 0 Attachment
                    On Thursday, May 23, 2013 3:36:57 AM UTC-5, Matteo Cavalleri wrote:
                    > > so the culprit is known, but the question is why? why the first file gets recognized one way and the second another way?
                    >
                    > the content of ~/.vim/bundle/vim2hs/ftdetect/heist.vim is just:
                    >
                    > autocmd BufNewFile,BufRead *.tpl setlocal filetype=heist
                    >
                    > the content of ~/.vim/ftplugin/smarty.vim is:
                    >
                    > au BufRead,BufNewFile *.tpl set filetype=smarty
                    >
                    > (plus some other code fir match it)

                    Files in the ftplugin directory should not be setting the filetype. That may be the culprit of your multiple loads as well. ftplugin/smarty.vim should only be running when you do "set ft=smarty" so setting it again is unnecessary at best.

                    --
                    --
                    You received this message from the "vim_use" maillist.
                    Do not top-post! Type your reply below the text you are replying to.
                    For more information, visit http://www.vim.org/maillist.php

                    ---
                    You received this message because you are subscribed to the Google Groups "vim_use" group.
                    To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
                    For more options, visit https://groups.google.com/groups/opt_out.
                  • Matteo Cavalleri
                    ... looking back at my dotfiles git log i found that to be my first attempt to fix this issue, and that clearly shows that i didn t understand at all vim
                    Message 9 of 9 , May 23 9:36 AM
                    • 0 Attachment
                      > Files in the ftplugin directory should not be setting the filetype. That may be the culprit of your multiple loads as well. ftplugin/smarty.vim should only be running when you do "set ft=smarty" so setting it again is unnecessary at best.

                      looking back at my dotfiles git log i found that to be my first attempt to fix this issue, and that clearly shows that i didn't understand at all vim plugins/filetypes ^__^ at least i should have learned something new.

                      btw, after some tries i was able to fix the problem by removing that line from ftplugin/ and putting it inside ~/.vim/after/ftdetect/smarty.vim, ~/.vim/ftdetect/ wasn't enough to get my settings win over the other plugin ftdetect

                      regarding my multiple loads i won't be at office till next monday, so i'll be unable to test this. i can try to replicate the issue here at home on my mac though. supposing os / system performance don't matter, i should be able to get the same result i have on my linux box

                      thanks again for the help

                      --
                      --
                      You received this message from the "vim_use" maillist.
                      Do not top-post! Type your reply below the text you are replying to.
                      For more information, visit http://www.vim.org/maillist.php

                      ---
                      You received this message because you are subscribed to the Google Groups "vim_use" group.
                      To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
                      For more options, visit https://groups.google.com/groups/opt_out.
                    Your message has been successfully submitted and would be delivered to recipients shortly.