Wednesday, November 11, 2015

Re: write a very basic syntax file (follow up questions)

On 2015-11-11, Jose Caballero wrote:
> Hi,
>
> I sent the question "write a very basic syntax file" yesterday to this forum.
> Thanks to the help provided I managed to write it.
> But I have a couple of related questions.
>
> ====================================
>
>
> (1) I was suggested to search for the inline help
>
> :help new-filetype
>
> However, if I do that, I get this
>
> "filetype.txt.gz" [readonly][noeol][converted] 26L, 12168C
> E434: Can't find tag pattern
> Press ENTER or type command to continue
>
> And therefore after hitting ENTER I only get garbage.
> Why did that happen?

The Fedora, and I assume RHEL, Vim package uses gzipped help files.
That they are compressed is normally transparent to the user. It
looks like your Vim doesn't know how to uncompress them, but I don't
know why that would be.

I tried that :help command with no gunzip in my PATH and got a
slightly different error:

"filetype.txt.gz" [readonly][noeol] 22L, 8111C
Error detected while processing function gzip#read:
line 44:
Error: Could not read uncompressed file
E434: Can't find tag pattern
Press ENTER or type command to continue

The output of the ":scriptnames" command should include lines such
as the following. Note that these are from a Vim 7.3 installation
on Fedora. I don't know what relevant differences there might be
between 7.2 and 7.3. Your leading numbers may also be different.

97: /usr/share/vim/vim73/plugin/gzip.vim
105: /usr/share/vim/vim73/plugin/zipPlugin.vim
116: /usr/share/vim/vim73/autoload/gzip.vim

I think some small-footprint versions of Vim are built without
support for compressed help files. I would expect a different error
in that case, but execute ":version" anyway (or from the shell, 'vim
--version') and post the results.

> ====================================
>
>
> (2) Following the recommendations, I created a new filetype file as
>
> $HOME/.vim/filetype.vim
>
> and the syntax file as
>
> $HOME/.vim/syntax/myfile.vim
>
> But what if I want it to be part of the system?
> In particular, if I want to distribute it as an RPM?
> If I am not mistaken, for RHEL 6, the syntax files go under
>
> /usr/share/vim/vim72/syntax/
>
> and the filetype one is
>
> /usr/share/vim/vim72/filetype.vim
>
> Is that correct?

You should not be installing anything into the system directories
used for the standard Vim distribution files, e.g.
/usr/share/vim/vim72/. Anything you put there could be overwritten
by an update and will be ignored if you update to a different major
or minor release number. Anything you add that you want to be
accessible by other users should go into /usr/share/vim/vimfiles/.

> Is it always that PATH for RHEL hosts?

It seems to be. The same path is used by Debian and derivatives.

It's not an issue here, but the various distributions do put the
system vimrc file in different places, e.g., Fedora uses /etc/vimrc
while Ubuntu uses /usr/share/vim/vimrc.

> Is not possible to have separate filetype.vim files, `a la`
> /.../filetype.d/ or similar?

Yes, it is. That's what the ftdetct directory is for. Instead of
creating a filetype.vim file as described in section C of ":help
new-filetype", create a myfile.vim file and put it in
~/.vim/ftdetect/ or /usr/share/vim/vimfiles/ftdetect/ as described
in section A.

> I am asking this because creating new files with RPM is easy, adding
> content to existing ones can be a truly nightmare :)

Indeed.

HTH,
Gary

--
--
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@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments: