adityam / filter

ConTeXt module to process contents of a start-stop environment through an external program
45 stars 10 forks source link

Insufficient coloring of c++ code #52

Closed champignoom closed 2 years ago

champignoom commented 2 years ago
\usemodule[vim]
\setupvimtyping[vimcommand=nvim]
\definevimtyping [CPP]  [syntax=cpp]
\starttext
\startCPP
#include <iostream>
using std::cout;

int main() {
  cout <<"Hello world\n";
}
\stopCPP
\stoptext

Not sure if this is intended, but all code are in black color, except for using and int which are blue.

The "changing the color scheme" section of vim-README seems to suggest that the default t-vim does not provide by default the color schemes of vim/nvim (:colorscheme).

adityam commented 2 years ago

This is the output that I get:

2021-09-03-165957_523x294_scrot

  1. Can you check that if you get correct syntax highlighting when you open a CPP file in neovim.
  2. Can you check the contents of\jobname-temp-CPP-0.vimout which should have:
\SYNBOL{}\SYN[Statement]{using} std::cout;\SYNEOL{}
\SYNBOL{}\SYNEOL{}
\SYNBOL{}\SYN[Type]{int} main() \{\SYNEOL{}
\SYNBOL{}  cout <<\SYN[Constant]{"Hello world}\SYN[Special]{\\n}\SYN[Constant]{"};\SYNEOL{}
\SYNBOL{}\}\SYNEOL{}

This is what gets parsed to display colors.

champignoom commented 2 years ago

Below are \jobname-temp-CPP-0.vimout:

\SYNBOL{}\SYN[Include]{#include }\SYN[String]{<iostream>}\SYNEOL{}
\SYNBOL{}\SYN[Statement]{using} std::cout;\SYNEOL{}
\SYNBOL{}\SYNEOL{}
\SYNBOL{}\SYN[Type]{int} main() \{\SYNEOL{}
\SYNBOL{}  cout <<\SYN[String]{"Hello world}\SYN[SpecialChar]{\\n}\SYN[String]{"};\SYNEOL{}
\SYNBOL{}\}\SYNEOL{}

and my neovim screenshot: neovim-cpp

adityam commented 2 years ago

The vimout file is correct. Not sure what is going wrong.

Can you post the complete log file for the above MWE (but add \traceexternalfilter before \starttext). Please also post a screenshot of the PDF output.

champignoom commented 2 years ago

test1.log:

open source     > level 1, order 1, name '/home/me/apps/texlive/2021/texmf-dist/tex/context/base/mkiv/cont-yes.mkiv'
system          > 
system          > ConTeXt  ver: 2021.03.05 19:11 MKIV  fmt: 2021.4.24  int: english/english
system          > 
system          > 'cont-new.mkiv' loaded
open source     > level 2, order 2, name '/home/me/apps/texlive/2021/texmf-dist/tex/context/base/mkiv/cont-new.mkiv'
system          > beware: some patches loaded from cont-new.mkiv
close source    > level 2, order 2, name '/home/me/apps/texlive/2021/texmf-dist/tex/context/base/mkiv/cont-new.mkiv'
system          > files > jobname 'test1', input './test1', result 'test1'
fonts           > latin modern fonts are not preloaded
languages       > language 'en' is active
open source     > level 2, order 3, name '/home/me/test/mkiv/test1.tex'
modules         > 'vim' is loaded
open source     > level 3, order 4, name '/home/me/apps/texlive/2021/texmf-dist/tex/context/third/vim/t-vim.tex'
loading         > Vim syntax highlighting (ver: 2020.06.29)
modules         > 'filter' is loaded
open source     > level 4, order 5, name '/home/me/apps/texlive/2021/texmf-dist/tex/context/third/filter/t-filter.mkiv'
loading         > Filter (ver: 2020.06.29)
modules         > 'module-catcodes' is loaded
open source     > level 5, order 6, name '/home/me/apps/texlive/2021/texmf-dist/tex/context/third/filter/t-module-catcodes.mkiv'
loading         > Module Catcodes (ver: 2018.04.16)
close source    > level 5, order 6, name '/home/me/apps/texlive/2021/texmf-dist/tex/context/third/filter/t-module-catcodes.mkiv'
close source    > level 4, order 6, name '/home/me/apps/texlive/2021/texmf-dist/tex/context/third/filter/t-filter.mkiv'
modules         > 'syntax-highlight' is loaded
open source     > level 4, order 7, name '/home/me/apps/texlive/2021/texmf-dist/tex/context/third/vim/t-syntax-highlight.mkiv'
loading         > Code syntax highlighting (ver: 2020.06.29)
modules         > 'syntax-groups' is loaded
open source     > level 5, order 8, name '/home/me/apps/texlive/2021/texmf-dist/tex/context/third/vim/t-syntax-groups.mkiv'
loading         > Syntax highlighting groups (ver: 2021.03.01)
modules         > 'module-catcodes' is already loaded
close source    > level 5, order 8, name '/home/me/apps/texlive/2021/texmf-dist/tex/context/third/vim/t-syntax-groups.mkiv'
modules         > 'filter' is already loaded
close source    > level 4, order 8, name '/home/me/apps/texlive/2021/texmf-dist/tex/context/third/vim/t-syntax-highlight.mkiv'
close source    > level 3, order 8, name '/home/me/apps/texlive/2021/texmf-dist/tex/context/third/vim/t-vim.tex'
fonts           > preloading latin modern fonts (second stage)
fonts           > 'fallback modern-designsize rm 12pt' is loaded
t-filter        > current filter : CPP
t-filter        > base file : test1-temp-CPP-0
t-filter        > input file : test1-temp-CPP-0.tmp
t-filter        > output file : test1-temp-CPP-0.vimout
t-filter        > command : nvim -u NONE -X -i NONE --noplugin --clean -es -n -c "syntax manual" -c "set syntax=cpp" -c "set tabstop=4" -c "let contextstartline=1| let contextstopline=0| let strip=1" -c "let escapecomments=0" -c "let highlight=[]"  -c "source /home/me/apps/texlive/2021/texmf-dist/tex/context/third/vim/2context.vim" -c "qa" test1-temp-CPP-0.tmp test1-temp-CPP-0.vimout
t-filter        > state : 
graphics        > run > processing file, changes in 'test1-temp-CPP-0.tmp', no result file
open source     > level 3, order 9, name 'test1-temp-CPP-0.vimout'
close source    > level 3, order 9, name 'test1-temp-CPP-0.vimout'
backend         > xmp > using file '/home/me/apps/texlive/2021/texmf-dist/tex/context/base/mkiv/lpdf-pdx.xml'
pages           > flushing realpage 1, userpage 1, subpage 1
close source    > level 2, order 9, name '/home/me/test/mkiv/test1.tex'
close source    > level 1, order 9, name '/home/me/apps/texlive/2021/texmf-dist/tex/context/base/mkiv/cont-yes.mkiv'

system          > start used files

system          > text: test1

system          > stop used files

system          > start used files

system          >    1: filename=char-prv.lua filetype=tex format=tex foundname=/home/me/apps/texlive/2021/texmf-dist/tex/context/base/mkiv/char-prv.lua fullname=/home/me/apps/texlive/2021/texmf-dist/tex/context/base/mkiv/char-prv.lua usedmethod=database
system          >    2: filename=cont-yes.mkiv filetype=tex foundname=/home/me/apps/texlive/2021/texmf-dist/tex/context/base/mkiv/cont-yes.mkiv fullname=/home/me/apps/texlive/2021/texmf-dist/tex/context/base/mkiv/cont-yes.mkiv usedmethod=database
system          >    3: filename=publ-imp-default.lua filetype=lua foundname=/home/me/apps/texlive/2021/texmf-dist/tex/context/base/mkiv/publ-imp-default.lua fullname=/home/me/apps/texlive/2021/texmf-dist/tex/context/base/mkiv/publ-imp-default.lua usedmethod=database
system          >    4: filename=cont-new.mkiv filetype=tex foundname=/home/me/apps/texlive/2021/texmf-dist/tex/context/base/mkiv/cont-new.mkiv fullname=/home/me/apps/texlive/2021/texmf-dist/tex/context/base/mkiv/cont-new.mkiv usedmethod=database
system          >    5: filename=lang-exc.lua filetype=lua foundname=/home/me/apps/texlive/2021/texmf-dist/tex/context/base/mkiv/lang-exc.lua fullname=/home/me/apps/texlive/2021/texmf-dist/tex/context/base/mkiv/lang-exc.lua usedmethod=database
system          >    6: filename=lang-us.lua filetype=lua foundname=/home/me/apps/texlive/2021/texmf-dist/tex/context/patterns/mkiv/lang-us.lua fullname=/home/me/apps/texlive/2021/texmf-dist/tex/context/patterns/mkiv/lang-us.lua usedmethod=database
system          >    7: filename=/home/me/test/mkiv/test1.tex foundname=/home/me/test/mkiv/test1.tex fullname=/home/me/test/mkiv/test1.tex usedmethod=direct
system          >    8: filename=t-vim.tex filetype=tex foundname=/home/me/apps/texlive/2021/texmf-dist/tex/context/third/vim/t-vim.tex fullname=/home/me/apps/texlive/2021/texmf-dist/tex/context/third/vim/t-vim.tex usedmethod=database
system          >    9: filename=t-filter.mkiv filetype=tex foundname=/home/me/apps/texlive/2021/texmf-dist/tex/context/third/filter/t-filter.mkiv fullname=/home/me/apps/texlive/2021/texmf-dist/tex/context/third/filter/t-filter.mkiv usedmethod=database
system          >   10: filename=t-module-catcodes.mkiv filetype=tex foundname=/home/me/apps/texlive/2021/texmf-dist/tex/context/third/filter/t-module-catcodes.mkiv fullname=/home/me/apps/texlive/2021/texmf-dist/tex/context/third/filter/t-module-catcodes.mkiv usedmethod=database
system          >   11: filename=t-syntax-highlight.mkiv filetype=tex foundname=/home/me/apps/texlive/2021/texmf-dist/tex/context/third/vim/t-syntax-highlight.mkiv fullname=/home/me/apps/texlive/2021/texmf-dist/tex/context/third/vim/t-syntax-highlight.mkiv usedmethod=database
system          >   12: filename=t-syntax-groups.mkiv filetype=tex foundname=/home/me/apps/texlive/2021/texmf-dist/tex/context/third/vim/t-syntax-groups.mkiv fullname=/home/me/apps/texlive/2021/texmf-dist/tex/context/third/vim/t-syntax-groups.mkiv usedmethod=database
system          >   13: filename=lm.lfg filetype=tex foundname=/home/me/apps/texlive/2021/texmf-dist/tex/context/fonts/mkiv/lm.lfg fullname=/home/me/apps/texlive/2021/texmf-dist/tex/context/fonts/mkiv/lm.lfg usedmethod=database
system          >   14: filename=lmroman12-regular filetype=otf format=otf foundname=/home/me/apps/texlive/2021/texmf-dist/fonts/opentype/public/lm/lmroman12-regular.otf fullname=/home/me/apps/texlive/2021/texmf-dist/fonts/opentype/public/lm/lmroman12-regular.otf usedmethod=database
system          >   15: filename=latinmodern-math.otf filetype=opentypefonts foundname=/home/me/apps/texlive/2021/texmf-dist/fonts/opentype/public/lm-math/latinmodern-math.otf fullname=/home/me/apps/texlive/2021/texmf-dist/fonts/opentype/public/lm-math/latinmodern-math.otf usedmethod=database
system          >   16: filename=test1-temp-CPP-0.vimout foundname=test1-temp-CPP-0.vimout fullname=/home/me/test/mkiv/test1-temp-CPP-0.vimout usedmethod=direct
system          >   17: filename=lmmono12-regular filetype=otf format=otf foundname=/home/me/apps/texlive/2021/texmf-dist/fonts/opentype/public/lm/lmmono12-regular.otf fullname=/home/me/apps/texlive/2021/texmf-dist/fonts/opentype/public/lm/lmmono12-regular.otf usedmethod=database
system          >   18: filename=pdftex.map filetype=map format=map foundname=/home/me/apps/texlive/2021/texmf-var/fonts/map/pdftex/updmap/pdftex.map fullname=/home/me/apps/texlive/2021/texmf-var/fonts/map/pdftex/updmap/pdftex.map usedmethod=database
system          >   19: filename=lpdf-pdx.xml filetype=tex foundname=/home/me/apps/texlive/2021/texmf-dist/tex/context/base/mkiv/lpdf-pdx.xml fullname=/home/me/apps/texlive/2021/texmf-dist/tex/context/base/mkiv/lpdf-pdx.xml usedmethod=database

system          > stop used files

system          > start commandline options

system          > currentrun="1"
system          > fulljobname="./test1.tex"
system          > input="./test1.tex"
system          > kindofrun="1"
system          > maxnofruns="9"
system          > texmfbinpath="/home/me/apps/texlive/2021/bin/x86_64-linux"

system          > stop commandline options

system          > start commandline files

system          >    1: ./test1.tex

system          > stop commandline files

modules         > start used modules

modules         > loaded : *-filter
modules         > loaded : *-module-catcodes
modules         > loaded : *-syntax-groups
modules         > loaded : *-syntax-highlight
modules         > loaded : *-vim

modules         > stop used modules

mkiv lua stats  > used config file: selfautoparent:/texmfcnf.lua;selfautoparent:/texmf-dist/web2c/texmfcnf.lua
mkiv lua stats  > used cache path: readable+writable: '/home/me/apps/texlive/2021/texmf-var/luatex-cache/context/a86c089b384a3076dc514ba966a1fac9'
mkiv lua stats  > resource resolver: loadtime 0.026 seconds, 0 scans with scantime 0.000 seconds, 0 shared scans, 19 found files, scanned paths: <none>
mkiv lua stats  > stored bytecode data: 454 modules (0.261 sec), 96 tables (0.016 sec), 550 chunks (0.277 sec)
mkiv lua stats  > traced context: maxstack: 1420, freed: 0, unreachable: 1420
mkiv lua stats  > cleaned up reserved nodes: 63 nodes, 9 lists of 442
mkiv lua stats  > node memory usage: 11 attribute, 4 attribute_list, 1 glue, 51 glue_spec, 3 kern, 2 penalty, 2 temp, 2 user_defined
mkiv lua stats  > node list callback tasks: 8 unique task lists, 7 instances (re)created, 68 calls
mkiv lua stats  > used backend: pdf (backend for directly generating pdf output)
mkiv lua stats  > jobdata time: 0.001 seconds saving, 0.000 seconds loading
mkiv lua stats  > callbacks: internal: 408, file: 1455, direct: 11, late: 0, function 705, total: 2579 (2579 per page)
mkiv lua stats  > randomizer: resumed with value 0.43509479379281
mkiv lua stats  > loaded tex modules: 5 requested, all found (*-filter *-module-catcodes *-syntax-groups *-syntax-highlight *-vim)
mkiv lua stats  > result saved in file: test1.pdf, compresslevel 3, objectcompresslevel 1
mkiv lua stats  > loaded patterns: en::1, load time: 0.000
mkiv lua stats  > loaded fonts: 3 files: latinmodern-math.otf, lmmono12-regular.otf, lmroman12-regular.otf
mkiv lua stats  > font engine: otf 3.113, afm 1.513, tfm 1.000, 8 instances, 3 shared in backend, 3 common vectors, 0 common hashes, load time 0.197 seconds 
mkiv lua stats  > used platform: linux-64, type: unix, binary subtree: bin
mkiv lua stats  > used engine: luatex version: 1.1302, functionality level: 7430, banner: this is luatex, version 1.13.2 (tex live 2021)
mkiv lua stats  > used hash slots: 47184 of 65536 + 200000
mkiv lua stats  > lua properties: engine: lua 5.3, used memory: 113 MB, ctx: 113 MB, max: unknown MB, hash chars: min(64,40), symbol mask: utf (τεχ)
mkiv lua stats  > runtime: 0.584 seconds, 1 processed pages, 1 shipped pages, 1.712 pages/second

screenshot of test1.pdf: t-vim-cpp

adityam commented 2 years ago

Ah, you are using MkIV. I was testing with LMTX. I did not know that texlive still defaults to MKIV. ConTeXt has been using the LMTX engine for over an year now. This is a bug in the MkIV code...I need to dig deeper to check if this is a regression in ConTeXt or the vim module.

In the meanwhile, does

context --luametatex test.tex

gives you the correct result.

adityam commented 2 years ago

Can you download:

and place them in the same directory as your test file. That should fix the coloring bug. I'll make an official new release early next week.

champignoom commented 2 years ago

Yes, it works perfectly now.

Thanks a lot!