2

In past I asked the question about how to create syntax specifications for ChatScript, a new programming language unforeseen in standard programming languages vim set (see: Vim syntax highlighting for ChatScript language?)

I eventually created myself the couple of (draft) files:

  • ~/.vim/syntax/ChatScript.vim
  • ~/.vim/ftdetect/ChatScript.vim

What's the standard way to share a new language highlights files proposal ? There is any vim guideline to how to share? With a github repo?

thanks
giorgio

  • 2
    GitHub would probably be the easiest way, but I don't think there's any defined (or generally accepted) best way to share syntax files. Maybe you could add it to the scripts section of Vim.org. – Tumbler41 Apr 4 '17 at 15:22
  • I'm voting to close this question as off-topic because this question is about sharing code and not about vim. – Tumbler41 Apr 4 '17 at 15:22
  • @tumbler, I please ask to leave open my question: as you just said in previous comment, the lack of that standard way to share/certify syntax files is IN-topic with vim ecosystem. Of course is ALSO a question of sharing code. Debatable... – Giorgio Robino Apr 4 '17 at 15:25
3

I'll take a tangent and answer the question that will arise when you start sharing more than a single set of syntax files (and attempt ot make the question more "on-topic" in the process :) ).

There is any vim guideline to how to share?

You could say that with Vim 8 there is (although it can be debatable whether it is or it isn't a guideline). In :help packages (or :help package-create) the Vim manual describes a method to disengage files in the directories in .vim between different packages. Therefore the first thing you should do before sharing the files is to place them inside such a package. Instead of:

~/.vim/syntax/ChatScript.vim
~/.vim/ftdetect/ChatScript.vim

You should really have something of the lines:

~/.vim/pack/mypackages/start/ChatScript/syntax/ChatScript.vim
~/.vim/pack/mypackages/start/ChatScript/ftdetect/ChatScript.vim

So the directory ChatScript becomes your package and can be distributed in any way you want. Some examples:

  • With git clone from github
  • By zipping it together (zip, tar, whatever) and unzipping at the desirable location
  • Symlinks to other user's public folders
  • Constructing a VimBall (but I'd recommend against it since it requires some extra knowledge to install in the right place in Vim 8).

Really, you can distribute it whichever way you find more convenient, and you do not need to distribute it in only a single way either. On the other hand the first option (git clone) is quite popular among Vim users.

Extra Notes

The directory names mypackages and ChatScript in the above are completely up to you. But the names of the other directories are important, and so is the number of subdirectories. The final objective of Vim packages is to allow for several groups of packages. For example

~/.vim/pack/mypackages/start/ChatScript/syntax/ChatScript.vim
~/.vim/pack/mypackages/start/ChatScript/ftdetect/ChatScript.vim
~/.vim/pack/third-party/start/csv.vim/...
~/.vim/pack/third-party/start/airline/...
~/.vim/pack/third-party/opt/django.vim/syntax/...
~/.vim/pack/third-party/opt/django.vim/plugin/...

Note the opt directory there (it is for optionally loaded packages), read the :h packages or the relevant question here on vi.SE

Before Vim 8

The packages system is not present in Vim 7 and earlier, but it was not born from nothing. Several plugins offered a very similar system of packaging a distibution of Vim files (syntax, autoloads, etc) into a single directory and align several such directories together.

We have a more-or-less complete list of these plugins, with their descriptions, advantages and disadvantages.

From those I always used pathogen. Which I dumped in my ~/.vim/autoload/pathogen.vim using the default ~/.vim/bundle for packages. The difference from the Vim 8 packages above is that it does not have groups of packages, everything goes into ~/.vim/bundle. So, the directory structure above would be (actually was):

~/.vim/bundle/ChatScript/syntax/ChatScript.vim
~/.vim/bundle/ChatScript/ftdetect/ChatScript.vim
~/.vim/bundle/csv.vim/...
~/.vim/bundle/airline/...
~/.vim/bundle/django.vim/syntax/...
~/.vim/bundle/django.vim/plugin/...

Then, to distribute them, it is the same story. Use any method(s) you like and tell the user to dump into a subdirectory of bundle. Vundle does the same, just that by default it loads from gihub automatically. Other plugins can do even more (e.g. check for updates).

  • Thanks @grochmal for complete answer. Appreciated! I have to understand better how to git the package. Nevertheless the "before vim8" could be a issue because I guess "mainstream" users didn't yet use vim8 (e.g. it require specific package download on ubuntu, etc.) – Giorgio Robino Apr 5 '17 at 11:27
  • 1
    @GiorgioRobino - heh, if you are serious about developing in Vim, compiling it from source is often needed :) . Nevertheless, I've added the pathogen dirs above, other stuff from Vim 7, will do similar. In general the idea is that you replicate the Vim directory structure and have a way of loading things from there. (and these things come with lots of documentation) – grochmal Apr 5 '17 at 16:42
  • thanks again @grochmal. I released my first tempt, using the "plugin" way: github.com/solyaris/ChatScript.vim – Giorgio Robino Apr 17 '17 at 13:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.