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

filetype specific behaviour

Expand Messages
  • Jay Glanville
    I want specific behaviour for specific filetypes. For example, for all java files, I want folding to be specified and implemented as follows: syn region
    Message 1 of 5 , Aug 28, 2002
    • 0 Attachment
      I want specific behaviour for specific filetypes. For example, for all java
      files, I want folding to be specified and implemented as follows:

      syn region myFold start="{" end="}" transparent fold
      syn sync fromstart
      set foldmethod=syntax
      set foldlevel=0

      So, I've made a file in ~/vimfiles/ftplugin called java.vim and put the
      above 4 lines in the file. Unfortunately, now, when I open a java file, I
      don't get the behaviour I expect. When I open a file and issue the
      commands, I get the following values:

      :set foldmethod?
      foldmethod=syntax
      :set foldlevel?
      foldlevel=0
      :syn list myFold
      --- Syntax Items ---
      [ .. an empty list .. ]

      So, I know my filetype is being read and executed, but the syn commands are
      not be executed/remembered. How do I do what I'm expecting?

      ---
      Jay Dickon Glanville
      Today's Fortune:

      Aim for the moon. If you miss, you may hit a star.
      -- W. Clement Stone
    • Piet Delport
      ... I ve only glanced at this briefly, but your commands might be getting clobbered by runtime scripts getting sourced later on. Have you tried putting your
      Message 2 of 5 , Aug 28, 2002
      • 0 Attachment
        On Wed, 28 Aug 2002 at 21:30:10 -0400, Jay Glanville wrote:
        >
        > I want specific behaviour for specific filetypes. For example, for all java
        > files, I want folding to be specified and implemented as follows:
        >
        > syn region myFold start="{" end="}" transparent fold
        > syn sync fromstart
        > set foldmethod=syntax
        > set foldlevel=0
        >
        > So, I've made a file in ~/vimfiles/ftplugin called java.vim and put the
        > above 4 lines in the file. Unfortunately, now, when I open a java file, I
        > don't get the behaviour I expect. When I open a file and issue the
        > commands, I get the following values:
        >
        > :set foldmethod?
        > foldmethod=syntax
        > :set foldlevel?
        > foldlevel=0
        > :syn list myFold
        > --- Syntax Items ---
        > [ .. an empty list .. ]
        >
        > So, I know my filetype is being read and executed, but the syn commands are
        > not be executed/remembered. How do I do what I'm expecting?

        I've only glanced at this briefly, but your commands might be getting
        clobbered by runtime scripts getting sourced later on.

        Have you tried putting your commands in
        ~/vimfiles/after/ftplugin/java.vim instead?

        (In general, /after is a better place for your filetype plugins anyway,
        if you're only overriding a few small things.)

        --
        Piet Delport
        Today's subliminal thought is:
      • Jay Glanville
        I ve just tried the ~/vimfiles/after/ftplugin/java.vim, and that doesn t provide me with what I want either. Thanks for the suggestion though. ... Jay Dickon
        Message 3 of 5 , Aug 29, 2002
        • 0 Attachment
          I've just tried the ~/vimfiles/after/ftplugin/java.vim, and that doesn't
          provide me with what I want either.

          Thanks for the suggestion though.
          ---
          Jay Dickon Glanville
          Today's Fortune:

          For my birthday I got a humidifier and a de-humidifier... I put them in
          the same room and let them fight it out.
          -- Steven Wright


          ----- Original Message -----
          From: "Piet Delport" <pjd@...>
          To: "Vim Mailing List" <vim@...>
          Sent: Thursday, August 29, 2002 2:00 AM
          Subject: Re: filetype specific behaviour

          On Wed, 28 Aug 2002 at 21:30:10 -0400, Jay Glanville wrote:
          >
          > I want specific behaviour for specific filetypes. For example, for all
          java
          > files, I want folding to be specified and implemented as follows:
          >
          > syn region myFold start="{" end="}" transparent fold
          > syn sync fromstart
          > set foldmethod=syntax
          > set foldlevel=0
          >
          > So, I've made a file in ~/vimfiles/ftplugin called java.vim and put the
          > above 4 lines in the file. Unfortunately, now, when I open a java file, I
          > don't get the behaviour I expect. When I open a file and issue the
          > commands, I get the following values:
          >
          > :set foldmethod?
          > foldmethod=syntax
          > :set foldlevel?
          > foldlevel=0
          > :syn list myFold
          > --- Syntax Items ---
          > [ .. an empty list .. ]
          >
          > So, I know my filetype is being read and executed, but the syn commands
          are
          > not be executed/remembered. How do I do what I'm expecting?

          I've only glanced at this briefly, but your commands might be getting
          clobbered by runtime scripts getting sourced later on.

          Have you tried putting your commands in
          ~/vimfiles/after/ftplugin/java.vim instead?

          (In general, /after is a better place for your filetype plugins anyway,
          if you're only overriding a few small things.)

          --
          Piet Delport
          Today's subliminal thought is:
        • Benji Fisher
          ... It looks as though the standard syntax file is :source d after the ftplugin files (even those in the after/ directory). You could confirm this by RTFM or
          Message 4 of 5 , Aug 29, 2002
          • 0 Attachment
            Jay Glanville wrote:
            >
            > ----- Original Message -----
            > From: "Piet Delport" <pjd@...>
            > To: "Vim Mailing List" <vim@...>
            > Sent: Thursday, August 29, 2002 2:00 AM
            > Subject: Re: filetype specific behaviour
            >
            > On Wed, 28 Aug 2002 at 21:30:10 -0400, Jay Glanville wrote:
            > >
            > > I want specific behaviour for specific filetypes. For example, for all
            > java
            > > files, I want folding to be specified and implemented as follows:
            > >
            > > syn region myFold start="{" end="}" transparent fold
            > > syn sync fromstart
            > > set foldmethod=syntax
            > > set foldlevel=0
            > >
            > > So, I've made a file in ~/vimfiles/ftplugin called java.vim and put the
            > > above 4 lines in the file. Unfortunately, now, when I open a java file, I
            > > don't get the behaviour I expect. When I open a file and issue the
            > > commands, I get the following values:
            > >
            > > :set foldmethod?
            > > foldmethod=syntax
            > > :set foldlevel?
            > > foldlevel=0
            > > :syn list myFold
            > > --- Syntax Items ---
            > > [ .. an empty list .. ]
            > >
            > > So, I know my filetype is being read and executed, but the syn commands
            > are
            > > not be executed/remembered. How do I do what I'm expecting?
            >
            > I've only glanced at this briefly, but your commands might be getting
            > clobbered by runtime scripts getting sourced later on.
            >
            > Have you tried putting your commands in
            > ~/vimfiles/after/ftplugin/java.vim instead?
            >
            > (In general, /after is a better place for your filetype plugins anyway,
            > if you're only overriding a few small things.)
            >
            > I've just tried the ~/vimfiles/after/ftplugin/java.vim, and that doesn't
            > provide me with what I want either.
            >
            > Thanks for the suggestion though.

            It looks as though the standard syntax file is :source'd after the ftplugin
            files (even those in the after/ directory). You could confirm this by RTFM or
            by

            :set verbose=20
            :e foo.java

            and then looking at the order in which files are read in. Most syntax files
            start by clobbering any existing syntax items with a :syn clear. So try putting
            the syntax items in a separate file, .../after/syntax/java.vim .

            HTH --Benji Fisher
          • Jay Glanville
            ... From: Benji Fisher To: Jay Glanville Sent: Thursday, August 29, 2002 10:46 PM Subject: Re: filetype
            Message 5 of 5 , Sep 4, 2002
            • 0 Attachment
              ----- Original Message -----
              From: "Benji Fisher" <benji@...>
              To: "Jay Glanville" <jayglanville@...>
              Sent: Thursday, August 29, 2002 10:46 PM
              Subject: Re: filetype specific behaviour

              > It looks as though the standard syntax file is :source'd after the
              ftplugin
              > files (even those in the after/ directory). You could confirm this by
              RTFM or
              > by
              >
              > :set verbose=20
              > :e foo.java
              >
              > and then looking at the order in which files are read in. Most syntax
              files
              > start by clobbering any existing syntax items with a :syn clear. So try
              putting
              > the syntax items in a separate file, .../after/syntax/java.vim .
              >
              > HTH --Benji Fisher
              >

              This solved the problem: butting the syntax specific behaviour in
              .../after/syntax/java.vim and other behaviour in
              .../after/ftplugin/java.vim.

              Thanks.

              ---
              Jay Dickon Glanville
              Today's Fortune:

              He that teaches himself has a fool for a master.
              -- Benjamin Franklin
            Your message has been successfully submitted and would be delivered to recipients shortly.