tree-sitter-grammars / tree-sitter-markdown

Markdown grammar for tree-sitter
MIT License
414 stars 52 forks source link

wikilinks #54

Closed namjul closed 11 months ago

namjul commented 2 years ago

Maybe this should not be part of tree-sitter-markdown since its not part of CommonMark Spec or Github flavored markdown so just opening up the question of supporting wikilinks.

MDeiml commented 2 years ago

It could definitely be implemented in a way that it can be conditionally enabled (as an extension). To me it seems like a there would be a few people who would want this.

boltlessengineer commented 1 year ago

@MDeiml Just curious, what do you mean by conditionally enabled? Does tree-sitter parser can be configured?

MDeiml commented 1 year ago

Once the parser is compiled it can't be configured, but I added some code to configure it at compile time (using environment variables). You can see it in the common/grammar.js

vicrdguez commented 1 year ago

+1 for the feature, ideally given that wikilinks are becoming more and more common, alias text support would make it compatible with multiple tools:

[[wikilink]]
[[wikilink|alias]]

This could allow mainly for concealing where just [[alias]] or [alias] is shown

mscott99 commented 1 year ago

I am trying to enable this feature and am having trouble (new to vim/neovim). How do I set the variable in the readme? Is it in vim.g ?

MDeiml commented 1 year ago

This is not really supported that well yet in neovim. See https://github.com/nvim-treesitter/nvim-treesitter/issues/3076. I think the only solution is to build the parser yourself. For this clone the repo, and run the command EXTENSION_WIKI_LINK=1 npm run build. This assumes you are using either linux or macos.

Then you have to point nvim-treesitter to this local version. See their documentation on how to do that.

MDeiml commented 11 months ago

Closing this as wiki links are now supported (but hidden behind a compilation time flag).