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

Powershell files (.ps1) not being detected correctly

Expand Messages
  • Guillermo
    Hi, Whenever I try to open a .ps1 file (Powershell v1), Vim thinks it s a conf filetype. By changing the filetype manually within Vim, the correct syntax is
    Message 1 of 10 , Jan 25, 2009
      Hi,

      Whenever I try to open a .ps1 file (Powershell v1), Vim thinks it's a
      "conf" filetype. By changing the filetype manually within Vim, the
      correct syntax is used.

      I've checked the docs and as far as I understand, the autocmds for
      picking the right syntax should be taken care of by synload.vim, but I
      don't know whether I have to modify this file...

      What's the correct way to tell Vim to load a syntax/indent/ftplugin
      based on a file extension?

      Regards,

      Guillermo
      --~--~---------~--~----~------------~-------~--~----~
      You received this message from the "vim_use" maillist.
      For more information, visit http://www.vim.org/maillist.php
      -~----------~----~----~----~------~----~------~--~---
    • Ted Pavlic
      ... A good place to start is ... Create a file in ~/.vim/ftdetect that contains the necessary autocommands to identify the type of file and set (for example)
      Message 2 of 10 , Jan 25, 2009
        > What's the correct way to tell Vim to load a syntax/indent/ftplugin
        > based on a file extension?

        A good place to start is

        :help ftdetect

        Create a file in

        ~/.vim/ftdetect

        that contains the necessary autocommands to identify the type of file
        and set (for example) filetype appropriately.

        For example, in a file called ~/.vim/ftdetect/ps1.vim, you could put

        au BufRead,BufNewFile *.ps1 set filetype=powershell

        (or whatever the appropriate PoSH filetype name is).

        You might also be interested in

        :help after

        --Ted

        --
        Ted Pavlic <ted@...>

        Please visit my ALS association page:
        http://web.alsa.org/goto/tedpavlic
        My family appreciates your support in the fight to defeat ALS.

        --~--~---------~--~----~------------~-------~--~----~
        You received this message from the "vim_use" maillist.
        For more information, visit http://www.vim.org/maillist.php
        -~----------~----~----~----~------~----~------~--~---
      • John Beckett
        ... Our tip on this is: http://vim.wikia.com/wiki/Filetype.vim The tip gives too much detail before the simple things you want to know, and incorrectly refers
        Message 3 of 10 , Jan 25, 2009
          Guillermo wrote:
          > What's the correct way to tell Vim to load a
          > syntax/indent/ftplugin based on a file extension?

          Our tip on this is:
          http://vim.wikia.com/wiki/Filetype.vim

          The tip gives too much detail before the simple things you want to know,
          and incorrectly refers to %USERPROFILE% on Windows. In brief, create
          directories/file $HOME/.vim/filetype.vim (Unix) or
          $HOME/vimfiles/filetype.vim (Windows). In Vim, enter command ':echo
          $HOME' to see its value.

          ---contents---
          if exists("did_load_filetypes")
          finish
          endif
          augroup filetypedetect
          au! BufNewFile,BufRead *.ps1 setf XXX
          au! BufNewFile,BufRead *.csv setf csv
          augroup END
          ---end---

          Replace XXX with whatever the name of your file type is (I'm assuming
          you have such a file type, but it's not being applied to *.ps1 files). I
          added the *.csv line to show what it looks like with two entries (you
          don't need the csv line).

          John


          --~--~---------~--~----~------------~-------~--~----~
          You received this message from the "vim_use" maillist.
          For more information, visit http://www.vim.org/maillist.php
          -~----------~----~----~----~------~----~------~--~---
        • Guillermo
          @John Beckett: Thanks, that did the trick. However, there s still one more annoyance... I thought VIM VIMFILES was the right place to put vim files for all
          Message 4 of 10 , Feb 1, 2009
            @John Beckett:

            Thanks, that did the trick.

            However, there's still one more annoyance... I thought VIM\VIMFILES
            was the right place to put vim files for all users, but if I download
            the ps1 files from vim.org and move them to that location as Admin,
            only the Admin user has access to them.

            The rest of the users have access to all the files under VIM
            \VIM72\..., but not to the newly moved ps1 files under VIM\VIMFILES. I
            can't figure out how to grant access to these files to all users of my
            computer (Windows XP Home).

            Right now, my ps1 config files are located in my regular user's $HOME
            \VIMFILES.

            Regards,

            Guillermo

            On Jan 25, 11:42 pm, "John Beckett" <johnb.beck...@...> wrote:
            > Guillermo wrote:
            > > What's the correct way to tell Vim to load a
            > > syntax/indent/ftplugin based on a file extension?
            >
            > Our tip on this is:http://vim.wikia.com/wiki/Filetype.vim
            >
            > The tip gives too much detail before the simple things you want to know,
            > and incorrectly refers to %USERPROFILE% on Windows. In brief, create
            > directories/file $HOME/.vim/filetype.vim (Unix) or
            > $HOME/vimfiles/filetype.vim (Windows). In Vim, enter command ':echo
            > $HOME' to see its value.
            >
            > ---contents---
            > if exists("did_load_filetypes")
            >   finish
            > endif
            > augroup filetypedetect
            >   au! BufNewFile,BufRead *.ps1 setf XXX
            >   au! BufNewFile,BufRead *.csv setf csv
            > augroup END
            > ---end---
            >
            > Replace XXX with whatever the name of your file type is (I'm assuming
            > you have such a file type, but it's not being applied to *.ps1 files). I
            > added the *.csv line to show what it looks like with two entries (you
            > don't need the csv line).
            >
            > John
            --~--~---------~--~----~------------~-------~--~----~
            You received this message from the "vim_use" maillist.
            For more information, visit http://www.vim.org/maillist.php
            -~----------~----~----~----~------~----~------~--~---
          • John Beckett
            ... Please bottom post on this list. Quote a small (relevant) part of the message you are replying to, and put your text underneath.
            Message 5 of 10 , Feb 1, 2009
              Guillermo wrote:
              > However, there's still one more annoyance... I thought
              > VIM\VIMFILES was the right place to put vim files for all
              > users, but if I download the ps1 files from vim.org and move
              > them to that location as Admin, only the Admin user has
              > access to them.

              Please bottom post on this list. Quote a small (relevant) part
              of the message you are replying to, and put your text underneath.
              http://groups.google.com/group/vim_use/web/vim-information

              First issue that occurs to me is that your admin user might have
              downloaded the files into a directory that assigned permissions that
              don't allow read to other users. Best way to check that is (as another
              user) to try to view the file (in Vim or at command prompt or Explorer
              or anything).

              If that doesn't solve it, please be more explicit:
              - Exactly what are you downloading? (one of the scripts?)
              - Exactly what is the file and what directory?

              For example, I suspect you might need the vim/vimfiles/syntax directory,
              but I don't think you mentioned 'syntax'.

              John


              --~--~---------~--~----~------------~-------~--~----~
              You received this message from the "vim_use" maillist.
              For more information, visit http://www.vim.org/maillist.php
              -~----------~----~----~----~------~----~------~--~---
            • Tony Mechelynck
              ... Check your runtimepath option. It is a comma-separated list of directories (each of which is the root of a tree); it should normally contain the
              Message 6 of 10 , Feb 1, 2009
                On 02/02/09 00:07, Guillermo wrote:
                >
                > @John Beckett:
                >
                > Thanks, that did the trick.
                >
                > However, there's still one more annoyance... I thought VIM\VIMFILES
                > was the right place to put vim files for all users, but if I download
                > the ps1 files from vim.org and move them to that location as Admin,
                > only the Admin user has access to them.
                >
                > The rest of the users have access to all the files under VIM
                > \VIM72\..., but not to the newly moved ps1 files under VIM\VIMFILES. I
                > can't figure out how to grant access to these files to all users of my
                > computer (Windows XP Home).
                >
                > Right now, my ps1 config files are located in my regular user's $HOME
                > \VIMFILES.
                >
                > Regards,
                >
                > Guillermo

                Check your 'runtimepath' option. It is a comma-separated list of
                directories (each of which is the root of a tree); it should normally
                contain the following values (or their equivalents after substituting
                environment variables):

                $HOME/vimfiles
                full-fledged scripts, private to the current user
                $VIM/vimfiles
                system-wide full-fledged scripts
                $VIMRUNTIME
                scripts distributed together with Vim
                $VIM/vimfiles/after
                small system-wide tweaks to any of the above
                $HOME/vimfiles/after
                small user-specific tweaks to any of the above

                Each of these trees has the same structure; any particular directory or
                subdirectory doesn't need to exist unless you have something to put in it.

                The values of the environment variables are what Vim sets them to at
                startup; they don't need to exist outside Vim. Typical values are
                VIM=C:\Program Files\vim (on Windows) and VIMRUNTIME=$VIM/vim72 (for Vim
                7.2 on any platform). I know my use of / and \ as path separators is not
                very consistent.

                If the above seems OK, then it's probably at the OS level rather than at
                Vim level.
                I don't know how Windows XP can allow or forbid read access to one user
                over files belonging to a different user. (Write access is not necessary
                in this case). Maybe it's in the Windows registry somewhere, but where?
                Your guess is as good as mine.


                Best regards,
                Tony.
                --
                We really don't have any enemies. It's just that some of our best
                friends are trying to kill us.

                --~--~---------~--~----~------------~-------~--~----~
                You received this message from the "vim_use" maillist.
                For more information, visit http://www.vim.org/maillist.php
                -~----------~----~----~----~------~----~------~--~---
              • Guillermo
                ... Exactly, I get an error saying that I don t have access to the files (as a regular user). ... After logging on as Admin, I ve downloaded three Vim
                Message 7 of 10 , Feb 1, 2009
                  > First issue that occurs to me is that your admin user might have
                  > downloaded the files into a directory that assigned permissions that
                  > don't allow read to other users. Best way to check that is (as another
                  > user) to try to view the file (in Vim or at command prompt or Explorer
                  > or anything).

                  Exactly, I get an error saying that I don't have access to the files
                  (as a regular user).

                  > If that doesn't solve it, please be more explicit:
                  > - Exactly what are you downloading? (one of the scripts?)
                  > - Exactly what is the file and what directory?
                  >
                  > For example, I suspect you might need the vim/vimfiles/syntax directory,
                  > but I don't think you mentioned 'syntax'.

                  After logging on as Admin, I've downloaded three Vim customization (?)
                  files for Powershell: syntax, indent and ftplugin.

                  I've then moved these files from the Desktop to VIM\VIMFILES\(SYNTAX,
                  INDENT, FTPLUGIN). VIM\VIMFILES and the mentioned subfolders were
                  created during the installation of Vim, I didn't have to create them
                  as Admin now.

                  As a normal user, I can access (read-only mode) any file under VIM
                  \VIM72, but none of the files for Powershell that I've just moved to
                  VIM\VIMFILES as Admin. As a result of this, syntax highlighting, etc
                  for python works well, for example, but nothing happens for Powershell
                  files, even though the filetype is detected correctly (ps1). So I
                  guess Vim can't access the files in VIM\VIMFILES that I've put there
                  as Admin and fails silently, since the default python files are
                  located under VIM\VIM72 and my ps1 files are in VIM\VIMFILES.

                  Hope this helps to clarify my problem.

                  Guillermo
                  --~--~---------~--~----~------------~-------~--~----~
                  You received this message from the "vim_use" maillist.
                  For more information, visit http://www.vim.org/maillist.php
                  -~----------~----~----~----~------~----~------~--~---
                • John Beckett
                  ... In Windows, your desktop is part of your profile, and all files have permissions that prevent other general users reading the files. Moving those files to
                  Message 8 of 10 , Feb 1, 2009
                    Guillermo wrote:
                    > Exactly, I get an error saying that I don't have access to
                    > the files (as a regular user).

                    In Windows, your desktop is part of your profile, and all files have
                    permissions that prevent other general users reading the files. Moving
                    those files to some other directory will KEEP the permissions. If you
                    had COPIED the files they would have received new permissions (probably
                    the simplest would be to do that now; move the files out of the
                    directory, then copy them back).

                    John


                    --~--~---------~--~----~------------~-------~--~----~
                    You received this message from the "vim_use" maillist.
                    For more information, visit http://www.vim.org/maillist.php
                    -~----------~----~----~----~------~----~------~--~---
                  • Guillermo
                    That s a nasty gotcha... It worked! Thanks! ... --~--~---------~--~----~------------~-------~--~----~ You received this message from the vim_use maillist.
                    Message 9 of 10 , Feb 3, 2009
                      That's a nasty gotcha... It worked! Thanks!

                      On Feb 2, 2:43 am, "John Beckett" <johnb.beck...@...> wrote:
                      > Guillermo wrote:
                      > > Exactly, I get an error saying that I don't have access to
                      > > the files (as a regular user).
                      >
                      > In Windows, your desktop is part of your profile, and all files have
                      > permissions that prevent other general users reading the files. Moving
                      > those files to some other directory will KEEP the permissions. If you
                      > had COPIED the files they would have received new permissions (probably
                      > the simplest would be to do that now; move the files out of the
                      > directory, then copy them back).
                      >
                      > John
                      --~--~---------~--~----~------------~-------~--~----~
                      You received this message from the "vim_use" maillist.
                      For more information, visit http://www.vim.org/maillist.php
                      -~----------~----~----~----~------~----~------~--~---
                    • Guillermo
                      ... That s a nasty gotcha. It worked! Thanks! Guillermo --~--~---------~--~----~------------~-------~--~----~ You received this message from the vim_use
                      Message 10 of 10 , Feb 3, 2009
                        > In Windows, your desktop is part of your profile, and all files have
                        > permissions that prevent other general users reading the files. Moving
                        > those files to some other directory will KEEP the permissions. If you
                        > had COPIED the files they would have received new permissions

                        That's a nasty gotcha.

                        It worked! Thanks!

                        Guillermo
                        --~--~---------~--~----~------------~-------~--~----~
                        You received this message from the "vim_use" maillist.
                        For more information, visit http://www.vim.org/maillist.php
                        -~----------~----~----~----~------~----~------~--~---
                      Your message has been successfully submitted and would be delivered to recipients shortly.