Code Monkey home page Code Monkey logo

tree-sitter-loongdoc's Introduction

tree-sitter-loongdoc

loongdoc grammar for tree-sitter.

tree-sitter-loongdoc's People

Contributors

cathaysia avatar dependabot[bot] avatar

Stargazers

Johann Martinache avatar lokithus avatar Alexandru Ungur avatar deatharte avatar Jared Henderson avatar  avatar sudo pacman -Syu avatar  avatar Matt Petty avatar  avatar Lukas avatar Getaway avatar Daniel James Baumann avatar Ognyan Kulev avatar zerosign avatar  avatar

Watchers

 avatar  avatar  avatar

tree-sitter-loongdoc's Issues

Failed to build in windows

I got below error when trying to execute :TSIntall asciidoc with nvim-treesitter

OS: Windows 11

nvim version

:version
NVIM v0.10.0-dev-3145+g9ca81b025
Build type: RelWithDebInfo
LuaJIT 2.1.1713484068
Run ":verbose version" for more info

Error Message

nvim-treesitter[asciidoc]: Error during compilation
lld-link: error: undefined symbol: tree_sitter_asciidoc_external_scanner_create^M
>>> referenced by C:\Users\BringsRain\AppData\Local\zig\o\822f1c660dd88fc359e9a40d5edf1b4e\parser.obj:(tree_sitter_asciidoc.language)^M
lld-link: error: undefined symbol: tree_sitter_asciidoc_external_scanner_destroy^M
>>> referenced by C:\Users\BringsRain\AppData\Local\zig\o\822f1c660dd88fc359e9a40d5edf1b4e\parser.obj:(tree_sitter_asciidoc.language)^M
lld-link: error: undefined symbol: tree_sitter_asciidoc_external_scanner_scan^M
>>> referenced by C:\Users\BringsRain\AppData\Local\zig\o\822f1c660dd88fc359e9a40d5edf1b4e\parser.obj:(tree_sitter_asciidoc.language)^M
lld-link: error: undefined symbol: tree_sitter_asciidoc_external_scanner_serialize^M
>>> referenced by C:\Users\BringsRain\AppData\Local\zig\o\822f1c660dd88fc359e9a40d5edf1b4e\parser.obj:(tree_sitter_asciidoc.language)^M
lld-link: error: undefined symbol: tree_sitter_asciidoc_external_scanner_deserialize^M
>>> referenced by C:\Users\BringsRain\AppData\Local\zig\o\822f1c660dd88fc359e9a40d5edf1b4e\parser.obj:(tree_sitter_asciidoc.language)^M

Missing highlights

I had some trouble configuring the highlights as it does not install them (highlights.scm is missing); this is not really a github issue, but here's my solution.

My understanding of it is that nvim-tree should have a copy of highlights.scm in the queries folder, which is not yet the case.

As suggested on this very repository, I installed both but I selected the possibly trademarked name as the filetype, thus keeping the original asciidoctor ftplugin as fallback.

loongdoc = {
	install_info = {
		url = 'https://github.com/cathaysia/tree-sitter-loongdoc.git',
		files 	= { 'tree-sitter-loongdoc/src/parser.c', 'tree-sitter-loongdoc/src/scanner.c' },
		branch	= 'master',
		generate_requires_npm = false,
		requires_generate_from_grammar = false,
	},
	filetype = 'asciidoc',
},

loongdoc_inline = {
	install_info = {
		url = 'https://github.com/cathaysia/tree-sitter-loongdoc.git',
		files = { 'tree-sitter-loongdoc_inline/src/parser.c', 'tree-sitter-loongdoc_inline/src/scanner.c' },
		branch = 'master',
		generate_requires_npm = false,
		requires_generate_from_grammar = false,
	},
	filetype = 'asciidoc_inline',
}

Thus I cloned this repository as a standalone plugin, as a nvim-treesitter dependency (using lazy).

As treesitter only automatically accepts queries/{language}/{highlights.scm} and such as reported here, I symlink'd the respective queries directories to $HOME/.local/share/nvim/rtp/queries/{lang}, thus I added the path to the nvim runtimepath.

{ 'cathaysia/tree-sitter-loongdoc',
		name = 'treesitter.parser.loongdoc',
		init = function(spec)
			local rtp = ('%s/rtp'):format(vim.fn.stdpath('data'))
			vim.fn.mkdir(rtp, 'p')
			vim.opt.runtimepath:prepend(rtp)

			local queries = ('%s/queries'):format(rtp)
			vim.fn.mkdir(queries, 'p')

			-- Symlink queries folder for language
			vim.iter({ { 'tree-sitter-loongdoc', 'loongdoc' }, { 'tree-sitter-loongdoc_inline', 'loongdoc_inline' } })
				:each(function(tuple)
					local src = ('%s/%s/queries'):format(spec.dir, tuple[1])
					local dst = ('%s/%s'):format(queries, tuple[2])

					-- Path exists, either it is the wrong one, or it is fine as it is
					if vim.uv.fs_stat(dst) then
						assert(vim.uv.fs_readlink(dst) == src, ('%s link does not match the right source %q'):format(tuple[1], src))
						return end

					-- Symbolic link
					vim.uv.fs_symlink(src, dst, { dir = true })
				end)
		end },

Also, I tried using this local clone to automatically build the parsers on startup with ensure_installed (install_info also accepts a local url), but as loongdoc and loongdoc_inline shares the same working directory, they conflict with each other during the build phase.

One last thing, thanks a lot for your work and for the parser of course!

Cannot escape braces in "stem" mode

Seems like stem with latexmath cannot escape braces.

= Hello world

Normal text stem:[a + b = c]

Bad formula stem:[A = \{ a + b \}]
title0 [0, 0] - [2, 0]
  title_h0_marker [0, 0] - [0, 1]
  line [0, 2] - [1, 0]
section_block [2, 0] - [5, 0]
  paragraph [2, 0] - [5, 0]
    inline_macro [2, 12] - [2, 28]
      attr [2, 18] - [2, 27]
    ERROR [4, 12] - [5, 0]
      intrinsic_attributes [4, 24] - [5, 0]
    inline_macro [2, 12] - [2, 28]
      attr [2, 18] - [2, 27]
    ERROR [4, 12] - [5, 0]
      intrinsic_attributes [4, 24] - [5, 0]
    line [2, 0] - [3, 0]
      inline_macro [2, 12] - [2, 28]
        attr [2, 18] - [2, 27]
    line [4, 0] - [5, 0]
      ERROR [4, 12] - [5, 0]
        intrinsic_attributes [4, 24] - [5, 0]

Cannot parse empty table cell

loongdoc cannot parse the following codes:

|===
| cell |
|===

<<<

something
(document [0, 0] - [8, 0]
  (ERROR [0, 0] - [8, 0]
    (table_block_marker [0, 0] - [0, 4])
    (table_cell [1, 0] - [1, 7])
    (table_block_marker [2, 0] - [2, 4])))
../1.adoc	  0.99 ms	   36 bytes/ms	(ERROR [0, 0] - [8, 0])

Useful for source map for AI tool?

I'm looking for treesitter for Asciidocs for adding support for Asciidoc in aider (a pair programming AI tool).
The tree sitter is used to create repo maps that are then used as context.
My thought was that headlines might be similar to function names and would be useful to be passed to context when writing.

How do you use this tree sitter here?
Do you think it could be used for this case?

Here are some links with context:

The state of this parser

Caution

the state of this parser still under developing, so I will make some force push in some case.

This parser should be able to handle most simple case:

image

Support for more complex syntax is still under development. This parser cannot parse some corner case, but it shouldn't block your editor. So you can try it.

The repo has three branches for now:

  • master: current develop branch.
  • pure_js: Earliest attempt. Without an external scanner, the editor often freezes and often causes parsing errors.
  • adoc: a fork of tree-sitter-markdown with some asciidoc support.

Missing license

Can you please provide a license for this project?

I just created an extension that uses your work in order to provide syntax highlighting in the Zed editor.

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.