I'm using the latest beta, and I need syntax coloring for SQL (PostgreSQL variant). According to the wiki, there is no SQL syntax coloring available for MKIV yet, but I'd be happy to be wrong :) If I am not wrong, I'd like to write my own syntax file, but not starting from scratch. I cannot find any pret-* files in the beta, though. Should they be downloaded separately? Nicola
On Tue, 1 Mar 2016, Nicola wrote:
I'm using the latest beta, and I need syntax coloring for SQL (PostgreSQL variant). According to the wiki, there is no SQL syntax coloring available for MKIV yet, but I'd be happy to be wrong :)
You can use the vim module: https://github.com/adityam/filter/blob/master/vim-README.md Aditya
On 2016-03-01 15:35:07 +0000, Aditya Mahajan said:
On Tue, 1 Mar 2016, Nicola wrote:
I'm using the latest beta, and I need syntax coloring for SQL (PostgreSQL variant). According to the wiki, there is no SQL syntax coloring available for MKIV yet, but I'd be happy to be wrong :)
You can use the vim module:
That's a pretty impressive module, thanks! I didn't know about it. I have a couple of questions: 1) Vim's SQL highlighting is a bit peculiar, in that a user is allowed to set a SQL dialect (:h sql-dialects) with SQLSetType or by setting g:sql_type_default or b:sql_type_override. For example, the effect of putting let g:sql_type_default='pgsql' in my vimrc is that, when a sql buffer is created, Vim searches for syntax/pgsql.vim instead of the default syntax file (sqloracle.vim, I think). Note that the filetype remains 'sql'. I have tried to set a SQL dialect inside a \startvimrc/\stopvimrc block, but without success (if that matters, I have this plugin in my ~/.vim folder: https://github.com/lifepillar/pgsql.vim). I have also tried \definevimtyping[SQL][syntax=pgsql], but then I don't get any highlighting, which makes me think that the module does not search my ~/.vim folder. Does the module work only with syntaxes in core Vim? 2) Are pscolor and blackandwhite the only possibilities to customize the colors? This is important, I need the syntax highlighting to match my document's colors. Finally, your Readme tells to use \definevimtyping[...][...], but I have found that I need to use put all the options together: \defienvimtyping[...]. Nicola
On Tue, 1 Mar 2016, Nicola wrote:
On 2016-03-01 15:35:07 +0000, Aditya Mahajan said:
On Tue, 1 Mar 2016, Nicola wrote:
I'm using the latest beta, and I need syntax coloring for SQL (PostgreSQL variant). According to the wiki, there is no SQL syntax coloring available for MKIV yet, but I'd be happy to be wrong :)
You can use the vim module:
That's a pretty impressive module, thanks! I didn't know about it.
I have a couple of questions:
1) Vim's SQL highlighting is a bit peculiar, in that a user is allowed to set a SQL dialect (:h sql-dialects) with SQLSetType or by setting g:sql_type_default or b:sql_type_override. For example, the effect of putting
let g:sql_type_default='pgsql'
in my vimrc is that, when a sql buffer is created, Vim searches for syntax/pgsql.vim instead of the default syntax file (sqloracle.vim, I think). Note that the filetype remains 'sql'. I have tried to set a SQL dialect inside a \startvimrc/\stopvimrc block, but without success (if that matters, I have this plugin in my ~/.vim folder: https://github.com/lifepillar/pgsql.vim). I have also tried \definevimtyping[SQL][syntax=pgsql], but then I don't get any highlighting, which makes me think that the module does not search my ~/.vim folder. Does the module work only with syntaxes in core Vim?
I do not load the default vimrc, because that drastically slows down the module. Instead, there is an option to create a specific vimrc using: \startvimrc[name=pgsql] let g:sql_type_default='pgsql' \stopvimrc and then \definevimtyping[SQL][..., vimrc=pgsql, ...] By default, the script searches everything in `runtimepath`. If your local vim folder is not in runtimepath, you can set the runtimepath in the vimrc above.
2) Are pscolor and blackandwhite the only possibilities to customize the colors? This is important, I need the syntax highlighting to match my document's colors.
It is relatively easy to tune the color scheme. See, for example how pscolor is defined: https://github.com/adityam/filter/blob/cc9d9017bfdd7fe0d67b4723570e960ec6c52... You can create similar mappings for your favorite color scheme (It does require a bit of knowledge of vim syntax groups).
Finally, your Readme tells to use \definevimtyping[...][...], but I have found that I need to use put all the options together: \defienvimtyping[...].
What I mean is \definevimtyping[SQL][numbering=on], etc. Aditya
On 2016-03-02 02:14:33 +0000, Aditya Mahajan said:
I do not load the default vimrc, because that drastically slows down the module.
That makes sense. So, Vim is run with something like `vim -u NONE`, I guess.
Instead, there is an option to create a specific vimrc using:
\startvimrc[name=pgsql] let g:sql_type_default='pgsql' \stopvimrc
and then
\definevimtyping[SQL][..., vimrc=pgsql, ...]
By default, the script searches everything in `runtimepath`. If your local vim folder is not in runtimepath, you can set the runtimepath in the vimrc above.
I had to set both runtimepath and nocompatible. Maybe this should be noted in the docs, or the module could run `vim -u NONE -N` (who needs compatible nowadays?). So, for future reference, this works: \startvimrc[name=pgsql] set nocompatible set runtimepath+=~/.vim/bundle/pgsql let g:sql_type_default='pgsql' % ... \stopvimrc
2) Are pscolor and blackandwhite the only possibilities to customize the colors? This is important, I need the syntax highlighting to match my document's colors.
It is relatively easy to tune the color scheme. See, for example how pscolor is defined: https://github.com/adityam/filter/blob/cc9d9017bfdd7fe0d67b4723570e960ec6c52...
You can create similar mappings for your favorite color scheme (It does require a bit of knowledge of vim syntax groups).
Perfect, thanks!
Finally, your Readme tells to use \definevimtyping[...][...], but I have found that I need to use put all the options together: \defienvimtyping[...].
What I mean is \definevimtyping[SQL][numbering=on], etc.
Ops, dumb oversight on my part. Thanks for your help and your amazing module, Nicola
On Wed, 2 Mar 2016, Nicola wrote:
On 2016-03-02 02:14:33 +0000, Aditya Mahajan said:
I do not load the default vimrc, because that drastically slows down the module.
That makes sense. So, Vim is run with something like `vim -u NONE`, I guess.
Yes. And if the vimrc option is used, then it is saved on file, and vim -u \vimrc_filename is run.
Instead, there is an option to create a specific vimrc using:
\startvimrc[name=pgsql] let g:sql_type_default='pgsql' \stopvimrc
and then
\definevimtyping[SQL][..., vimrc=pgsql, ...]
By default, the script searches everything in `runtimepath`. If your local vim folder is not in runtimepath, you can set the runtimepath in the vimrc above.
I had to set both runtimepath and nocompatible. Maybe this should be noted in the docs, or the module could run `vim -u NONE -N` (who needs compatible nowadays?). So, for future reference, this works:
I explicitly set compatible (but I don't remember why I did that anymore). This is the full command that is run: \def\vimtyping@filter_command {vim -u \vimrc_filename\space % read global config file % --startuptime log % -V3log -X % dont connect to X server -i NONE % dont use viminfo file --noplugin % dont load plugins -e % run in ex mode -s % silent -C % set compatible -n % no swap file -c "syntax manual" % don't load filetype detection -c "set syntax=\externalfilterparameter\c!syntax" % -c "set tabstop=\externalfilterparameter\c!tab" % % vim only accepts 10 -c commands, so we combine a few let statements -c "let contextstartline=\externalfilterparameter\c!start \letterbar\space % let contextstopline=\externalfilterparameter\c!stop \letterbar\space % let strip=\getvalue{\vimtyping@id-\c!strip-\externalfilterparameter\c!strip}" % -c "let escapecomments=\getvalue{\vimtyping@id-\c!escape-\externalfilterparameter\c!escape}" % -c "let highlight=[\externalfilterparameter\c!highlight]" % \vimrc_extras\space -c "source \vimtyping@script_name" % -c "qa" % \externalfilterinputfile\space \externalfilteroutputfile} I'll run my test suite with -N instead of -C. If everything works, I'll change to -N.
\startvimrc[name=pgsql] set nocompatible set runtimepath+=~/.vim/bundle/pgsql let g:sql_type_default='pgsql' % ... \stopvimrc
I will add a note to the docs about runtimepath. When I wrote the module, bundle was not popular, but it is the default now. Aditya
On 2016-03-02 14:45:54 +0000, Aditya Mahajan said:
On Wed, 2 Mar 2016, Nicola wrote:
On 2016-03-02 02:14:33 +0000, Aditya Mahajan said:
I do not load the default vimrc, because that drastically slows down the module.
That makes sense. So, Vim is run with something like `vim -u NONE`, I guess.
Yes. And if the vimrc option is used, then it is saved on file, and vim -u \vimrc_filename is run.
Crystal clear, thanks!
\startvimrc[name=pgsql] set nocompatible set runtimepath+=~/.vim/bundle/pgsql let g:sql_type_default='pgsql' % ... \stopvimrc
I will add a note to the docs about runtimepath. When I wrote the module, bundle was not popular, but it is the default now.
I use Pathogen, and `bundle` is its default path for plugins. But recently Vim has introduced a feature called `packages` in the core (:h packages), so one may expect that in the future the default will be `pack`. Nicola
On 2016-03-02 02:14:33 +0000, Aditya Mahajan said:
On Tue, 1 Mar 2016, Nicola wrote:
On 2016-03-01 15:35:07 +0000, Aditya Mahajan said:
On Tue, 1 Mar 2016, Nicola wrote:
I'm using the latest beta, and I need syntax coloring for SQL (PostgreSQL variant). According to the wiki, there is no SQL syntax coloring available for MKIV yet, but I'd be happy to be wrong :)
You can use the vim module:
I have a relatively minor problem with linked highlight groups. As far as I can see, the module resolves linked groups so that, for example, if String links to Constant, then the generated code for 'a string' will be something like \SYN[Constant]{'a string'}, rather than \SYN[String]{'a string'}. In my specific case, strings use the sqlString group, which links by default to String, which in turn links to Constant. Is there a way to decouple linked highlight groups, so that, for example, I may distinguish Constant from String? I have already tried to put commands like hi! clear sqlString hi! link String NONE etc... in the vimrc block, to no avail. Nicola
On 2016-03-02 11:06:34 +0000, Nicola said:
On 2016-03-02 02:14:33 +0000, Aditya Mahajan said:
On Tue, 1 Mar 2016, Nicola wrote:
On 2016-03-01 15:35:07 +0000, Aditya Mahajan said:
On Tue, 1 Mar 2016, Nicola wrote:
I'm using the latest beta, and I need syntax coloring for SQL (PostgreSQL variant). According to the wiki, there is no SQL syntax coloring available for MKIV yet, but I'd be happy to be wrong :)
You can use the vim module:
I have a relatively minor problem with linked highlight groups. As far as I can see, the module resolves linked groups so that, for example, if String links to Constant, then the generated code for 'a string' will be something like \SYN[Constant]{'a string'}, rather than \SYN[String]{'a string'}. In my specific case, strings use the sqlString group, which links by default to String, which in turn links to Constant.
Is there a way to decouple linked highlight groups, so that, for example, I may distinguish Constant from String? I have already tried to put commands like
hi! clear sqlString hi! link String NONE etc...
in the vimrc block, to no avail.
Ok, I have found it: hi! link sqlString NONE With that, I get \SYN[sqlString]{'a string'}, as expected. Nicola
On 2016-03-01 15:35:07 +0000, Aditya Mahajan said:
On Tue, 1 Mar 2016, Nicola wrote:
I'm using the latest beta, and I need syntax coloring for SQL (PostgreSQL variant). According to the wiki, there is no SQL syntax coloring available for MKIV yet, but I'd be happy to be wrong :)
You can use the vim module:
I've set up your module and it works perfectly. It saved me a lot of time! But I need help for one more thing: \inlineMYLANG{X} adds a new line before and after X, as in \startMYLANG X \stopMYLANG. How do I prevent that? Well, why is that the case to begin with? Nicola
On Wed, 2 Mar 2016, Nicola wrote:
On 2016-03-01 15:35:07 +0000, Aditya Mahajan said:
On Tue, 1 Mar 2016, Nicola wrote:
I'm using the latest beta, and I need syntax coloring for SQL (PostgreSQL variant). According to the wiki, there is no SQL syntax coloring available for MKIV yet, but I'd be happy to be wrong :)
You can use the vim module:
I've set up your module and it works perfectly. It saved me a lot of time! But I need help for one more thing: \inlineMYLANG{X} adds a new line before and after X, as in \startMYLANG X \stopMYLANG. How do I prevent that? Well, why is that the case to begin with?
It shouldn't. Can you send me a minimal example. Aditya
On 2016-03-02 19:34:00 +0000, Aditya Mahajan said:
On Wed, 2 Mar 2016, Nicola wrote:
On 2016-03-01 15:35:07 +0000, Aditya Mahajan said:
On Tue, 1 Mar 2016, Nicola wrote:
I'm using the latest beta, and I need syntax coloring for SQL (PostgreSQL variant). According to the wiki, there is no SQL syntax coloring available for MKIV yet, but I'd be happy to be wrong :)
You can use the vim module:
I've set up your module and it works perfectly. It saved me a lot of time! But I need help for one more thing: \inlineMYLANG{X} adds a new line before and after X, as in \startMYLANG X \stopMYLANG. How do I prevent that? Well, why is that the case to begin with?
It shouldn't. Can you send me a minimal example.
I have figured out myself: I have defined \definevimtyping[pgsql][..., before={\blank},after={\blank}, ...] which, I have realized, applies to inline text, too. How do I set up the environment so that there is some blank space before and after without affecting inline code? Nicola
On Wed, 2 Mar 2016, Nicola wrote:
On 2016-03-02 19:34:00 +0000, Aditya Mahajan said:
On Wed, 2 Mar 2016, Nicola wrote:
On 2016-03-01 15:35:07 +0000, Aditya Mahajan said:
On Tue, 1 Mar 2016, Nicola wrote:
I'm using the latest beta, and I need syntax coloring for SQL (PostgreSQL variant). According to the wiki, there is no SQL syntax coloring available for MKIV yet, but I'd be happy to be wrong :)
You can use the vim module:
I've set up your module and it works perfectly. It saved me a lot of time! But I need help for one more thing: \inlineMYLANG{X} adds a new line before and after X, as in \startMYLANG X \stopMYLANG. How do I prevent that? Well, why is that the case to begin with?
It shouldn't. Can you send me a minimal example.
I have figured out myself: I have defined
\definevimtyping[pgsql][..., before={\blank},after={\blank}, ...]
which, I have realized, applies to inline text, too. How do I set up the environment so that there is some blank space before and after without affecting inline code?
You can change the space before and after display environments using spacebefore and spaceafter keys (see the documentation of filter module[1], which is used by the vim module) There are two modes: location=paragraph and location=text. In location=paragraph you get \blank[<spacebefore>] <before> <filtered content> <after> \blank[<spaceafter>] In location=text (which is used by \inline...) you get <left> <filtered content> <right> The behaviour that you see is because, by default, I have set \c!left=\externalfilterparameter\c!before, \c!right=\externalfilterparameter\c!after, Looking at git-blame, I see that this was always the case, ever since the left and right keys were added (I guess to keep backward compatibility at that time). Looking back, I think that this is not a good default and I will change it. In the meanwhile, simply use \definevimtyping[...][left=, right=,] Aditya [1]: https://github.com/adityam/filter
On 3/1/2016 4:26 PM, Nicola wrote:
I'm using the latest beta, and I need syntax coloring for SQL (PostgreSQL variant). According to the wiki, there is no SQL syntax coloring available for MKIV yet, but I'd be happy to be wrong :)
If I am not wrong, I'd like to write my own syntax file, but not starting from scratch. I cannot find any pret-* files in the beta, though. Should they be downloaded separately?
just fyi (as aditya already provided you a solution) there are three highlighters - the build-in one, for which one can define additional variants (there are few defined, some assume proper syntax, some are line based) - the module by aditya which (i assume) also needs vim installed - a relative new mechanism based on the scite lexers that i use (for not it is loaded by \usemodule[scite] The last option is supports combined tex/mp/lua as well as xml, web, pdf, bibtex, lua so basically all the formats used by context and i now also added the sql one (i needed that one a while ago but never added it to the upcoming beta) \usemodule[scite] \starttext % \scitebuffer[sql][x] % \scitefile[sql][abc.sql] \startscite[sql] .... \stopscite \stoptext no upload yet btw, there's also: mtxrun --extra=listing --scite --compact foo.sql or whatever known suffix Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
On 2016-03-01 21:53:10 +0000, Hans Hagen said:
just fyi (as aditya already provided you a solution) there are three highlighters
- the build-in one, for which one can define additional variants (there are few defined, some assume proper syntax, some are line based)
Just to clarify, this is the Lua-based "pretty printers" mentioned in the wiki, is it?
- the module by aditya which (i assume) also needs vim installed
- a relative new mechanism based on the scite lexers that i use (for not it is loaded by \usemodule[scite]
...which does require Scite? (I've tried your example and it doesn't get highlighted.) Nicola
On 3/2/2016 9:56 AM, Nicola wrote:
On 2016-03-01 21:53:10 +0000, Hans Hagen said:
just fyi (as aditya already provided you a solution) there are three highlighters
- the build-in one, for which one can define additional variants (there are few defined, some assume proper syntax, some are line based)
Just to clarify, this is the Lua-based "pretty printers" mentioned in the wiki, is it?
- the module by aditya which (i assume) also needs vim installed
- a relative new mechanism based on the scite lexers that i use (for not it is loaded by \usemodule[scite]
...which does require Scite? (I've tried your example and it doesn't get highlighted.)
the sql lexer is in the upcoming beta and i just added the start/stop but this should work \usemodule[scite] \starttext \startbuffer[x] for i=1cm step 1cm upto 10cm : draw fullcircle scaled (0cm,i) ; endfor ; \stopbuffer \scitebuffer[mps][x] \stoptext You don't need scite installed so it's quite efficient as it's the method that is used, not the binary (and the context related lexers ship with the context distribution). Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
On 2016-03-02 09:13:07 +0000, Hans Hagen said:
On 3/2/2016 9:56 AM, Nicola wrote:
On 2016-03-01 21:53:10 +0000, Hans Hagen said:
- a relative new mechanism based on the scite lexers that i use (for not it is loaded by \usemodule[scite]
...which does require Scite? (I've tried your example and it doesn't get highlighted.)
the sql lexer is in the upcoming beta and i just added the start/stop but this should work [snip]
Indeed it does.
You don't need scite installed so it's quite efficient as it's the method that is used, not the binary (and the context related lexers ship with the context distribution).
That's clear now, thanks! Nicola
On Wed, 2 Mar 2016 11:45:54 +0100
Nicola
You don't need scite installed so it's quite efficient as it's the method that is used, not the binary (and the context related lexers ship with the context distribution).
That's clear now, thanks!
Hans is referring to syntax highlighting within ConTeXt and a method that uses the lua lexers that he originally wrote for SciTe. I would like to point out that in order to use this highlighting *in the SciTe editor* itself, one needs to have the lpeg library compiled for SciTe. Currently, this only exists as a DLL for Windows and has not been ported to any other system. This was our conclusion at the last ConTeXt meeting where we spent a little time, probably not enough, trying to compile this library without success. Alan
participants (4)
-
Aditya Mahajan
-
Alan BRASLAU
-
Hans Hagen
-
Nicola