New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support syntax highlight for filetypes which cannot have the 2 character indent in .vader files. #15

Closed
cirosantilli opened this Issue Sep 7, 2014 · 8 comments

Comments

Projects
None yet
2 participants
@cirosantilli
Contributor

cirosantilli commented Sep 7, 2014

I'm considering using Vader to implement unit tests for https://github.com/plasticboy/vim-markdown

The filetype is mkd (not markdown to distinguish from the built-in).

Added let g:vader_types = ['mkd']

a.vader:

Given mkd (a):
  **a**

Execute (b):
  echo '**b**'

How it gets highlighted: everything after the first line is treated as markdown, including the Expect.

Works normally if I use any other filetype that I have tried like tex and the built-in markdown, so there must be something about the syntax of mkd that is breaking Vader.

@junegunn

This comment has been minimized.

Owner

junegunn commented Sep 7, 2014

Yes, I can reproduce the problem.
I used this helper command to see the highlight group on the cursor

function! s:hl()
  echo join(map(synstack(line('.'), col('.')), 'synIDattr(v:val, "name")'), '/')
endfunction
command! HL call <SID>hl()

And it looks like mkdNonListItemBlock is not compatible with how Vader includes syntaxes. If I comment out the line, the problem goes away. However, I don't think fixing it will make markdown syntax to display properly inside a Vader test file because of the obligatory 2-space indentation. 😕

@cirosantilli

This comment has been minimized.

Contributor

cirosantilli commented Sep 7, 2014

Sorry, I don't quite understand what you mean: do you think it is possible to make it work without modifying mkd, or the only way is to modify mkd? I haven't looked in detail into the problem. In theory, it should be doable without changing mkd syntax since vader has the unambiguous 2-space indent information.

@junegunn

This comment has been minimized.

Owner

junegunn commented Sep 7, 2014

I'm saying that it's not going to be possible to embed markdown syntax inside Vader file anyway, since markdown syntax inherently takes indentation into consideration and Vader requires 2-space indentation.

For example, in markdown we write first-level header like so:

Header 1
=======

But if we want to put it inside a Vader file, it should be indented by 2-spaces

Given mkd:
  Header 1
  =======

Is it still a valid h1 syntax? If it's not, then we're out of luck.

@cirosantilli

This comment has been minimized.

Contributor

cirosantilli commented Sep 7, 2014

OK, so now the highlight only works for syntaxes which can have arbitrary indentation. This is not the case for markdown. I wonder if there is a way to remove the indentation before passing it to the syntax highlight.

@cirosantilli

This comment has been minimized.

Contributor

cirosantilli commented Sep 7, 2014

Another option is to add a a new Vader syntax that does not require indentation, e.g.:

Given mkd (mkd file):{
top level no spaces

    code block
}

Execute (some test):
  ...
@junegunn

This comment has been minimized.

Owner

junegunn commented Sep 7, 2014

Yeah we could do so. But implementation would not be trivial and I don't think I can find time to do it soon. (The current parser of Vader is extremely simple thanks to its very simple syntax.)

Since it doesn't block us from writing tests, I don't think it's an urgent task. If you want to set the filetype of the buffer, you can use before block like so:

Before:
  setf mkd

Given (markdown content):
  ...

@cirosantilli cirosantilli changed the title from mkd filetype syntax on .vader file does not stop before next test. to Support syntax highlight for filetypes which cannot have the 2 character indent in .vader files. Sep 7, 2014

junegunn added a commit that referenced this issue Sep 9, 2014

@junegunn

This comment has been minimized.

Owner

junegunn commented Sep 9, 2014

Discussion continues on #18.

@junegunn

This comment has been minimized.

Owner

junegunn commented Sep 10, 2014

Well, even with the new semi-colon syntax, plasticboy's mkd syntax is not compatible with Vader. (Change Given markdown to Given mkd in test/feature/no-indentation.vader file)

As I mentioned earlier in the comment the culprit is mkdNonListItemBlock region from the plugin, and I don't think there's anything Vader can do about it.

EDIT: Nevermind. Fixed it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment