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

Re: [question] filetype name with dot (example included)

Expand Messages
  • Tony Mechelynck
    ... :set syntax=à (which, if included, should be setlocal syntax=à instead) should not be necessary if your vimrc includes syntax on or syntax
    Message 1 of 2 , Oct 9, 2013
      On 08/10/13 15:37, Bruno Sutic wrote:
      > Hello vimers!
      > I'm using vim-handlebars filetype plugin, link to source: https://github.com/nono/vim-handlebars
      > I noticed the plugin is setting filetype with a dot in the name.
      > Link to the relevant line in the source code:
      > https://github.com/nono/vim-handlebars/blob/master/ftdetect/handlebars.vim#L2
      >
      > Vim seems to be fine with that (see :h 'ft'), but the line above does not seem "right". It is essentially loading 2 filetypes, but then running additional files with "runtime!", which seems redundant.
      >
      > I downloaded the project locally and experimented with removing the "runtime" from the line above.
      > But it seems I can't 'nail' all the functionality: either handlebars syntax is missing, or 'matchit' plugin support for html or handlebars is not working.
      > Basically, I don't know how to use this and the docs are terse.

      ":set syntax=…" (which, if included, should be "setlocal syntax=…"
      instead) should not be necessary if your vimrc includes "syntax on" or
      "syntax enable"; similarly, "runtime! ftplugin/…" should not be
      necessary if it includes _either_ "filetype plugin on" or "syntax on"
      (or both).

      >
      > My question is: what is the idiomatic, proper way in vim to use filetype with dot (2 filetypes at once)?

      Assuming the filename is enough to detect the filetype:

      :au BufRead,BufNewFile *.foobar setf foo.bar " set it only if not yet set
      or
      :au BufRead,BufNewFile *.foobar set filetype=foo.bar " set it even if
      already set.

      in a file named one of
      - on Unix-like
      ~/.vim/filetype.vim
      ~/.vim/ftdetect/foobar.vim
      - on Windows
      ~/vimfiles/filetype.vim
      ~/vimfiles/ftdetect/foobar.vim
      - on either
      $VIM/vimfiles/filetype.vim
      $VIM/ftdetect/foobar.vim

      Most of these directories and all of these files are absent by default
      in a new Vim installation. Create them if necessary.

      This will source the plugins in the order shown (first foo.vim, then
      bar.vim). In case of conflicting settings, e.g. matchit's b:match_words,
      then the last one wins. If the correct value for both HTML and
      handlebars is set in the handlebars ftplugin, then the dotted filename
      should be html.handlebars and not the opposite.

      see
      :help 'filetype'
      :help new-filetype

      > Is there a (good) plugin that uses this trick in a different way, so I can learn from it? Do you know what might be the problem here?

      dunno

      >
      > Any help with this is appreciated!
      > Bruno
      >

      Best regards,
      Tony.
      --
      In specifications, Murphy's Law supersedes Ohm's.

      --
      --
      You received this message from the "vim_dev" 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_dev" group.
      To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+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.