Coder Social home page Coder Social logo

Comments (3)

lervag avatar lervag commented on May 20, 2024

I believe the problem is quite simple. You forgot to unlet b:current_syntax. This should work, I think:

if exists('b:current_syntax')
  finish
endif

runtime! syntax/markdown.vim
unlet b:current_syntax

" Include tex math in markdown
syn include @tex syntax/tex.vim
syn region mkdMath start="\\\@<!\$" end="\$" skip="\\\$" contains=@tex keepend
syn region mkdMath start="\\\@<!\$\$" end="\$\$" skip="\\\$" contains=@tex keepend

let b:current_syntax = 'markdown'

from vimtex.

Bekaboo avatar Bekaboo commented on May 20, 2024

@lervag That does not work, also the b:_loaded_markdown_syntax is needed to avoid the endless recursive of sourcing syntax/markdown.vim files, so this is the content in my current ~/.config/nvim/syntax/markdown.vim:

if exists('b:current_syntax') || exists('b:_loaded_markdown_syntax')
  finish
endif

let b:_loaded_markdown_syntax = 1
runtime! syntax/markdown.vim
unlet b:current_syntax

" Include tex math in markdown
syn include @tex syntax/tex.vim
syn region mkdMath start="\\\@<!\$" end="\$" skip="\\\$" contains=@tex keepend
syn region mkdMath start="\\\@<!\$\$" end="\$\$" skip="\\\$" contains=@tex keepend

let b:current_syntax = 'markdown'

and this is what I get -- all highlighting in markdown math zone disappears (e.g. it does not make a difference before/after adding unlet b:current_syntax). Can you repro? Thanks!

image

from vimtex.

Bekaboo avatar Bekaboo commented on May 20, 2024

I've also tried moving the syntax file to the after/syntax directory with only the following content to avoid sourcing nvim's default markdown syntax file manually:

syn include @tex syntax/tex.vim
syn region mkdMath start="\\\@<!\$" end="\$" skip="\\\$" contains=@tex keepend
syn region mkdMath start="\\\@<!\$\$" end="\$\$" skip="\\\$" contains=@tex keepend

but that does not give me math conceal in mathzones. Don't know why but the conceal works only if

  1. the tex syntax is included in syntax/markdown.vim, not after/syntax/markdown.vim, and
  2. the default markdown syntax file must not be sourced in syntax/markdown.vim

So it seems that the math concealing works only if nvim does not source the default markdown syntax file. I'm confused.

from vimtex.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.