-
Notifications
You must be signed in to change notification settings - Fork 51
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Using go-org
to build a multi-purpose LSP
#91
Comments
Hey, Option 2 sounds best to me. We could also embed a I don't think I should say anything about what's the true golang way; I've committed quite some atrocities against it in this repo :D, e.g. https://github.com/niklasfasching/go-org/commit/14900e9/ So whatever you pick, happy for a PR. I'll eventually look into implementing this myself otherwise, no idea when though. |
So I went trough and try some, and consider one more option, here my learnings:
LSP Considerations:
|
Hey! Thx for the PR. I'll try to take a look this weekend :). |
Sorry for not getting back on this as planned. Looks good! Are you blocked by this getting merged? I'm still pondering how I feel about wrapping in RangedNode (or the suggested Node struct rather than interface). No strong feelings against it, just wondering whether it could be even nicer to instead cast to RangedNode to keep the interface unchanged, e.g. type RangedNode interface {
Node
GetRange() Range
}
type Range struct{ Start, End Position }
func (r Range) GetRange() Range { return r }
type Comment struct{
Range
Content string
}
func (d *Document) parseComment(i int, stop stopFn) (int, Node) {
return 1, Comment{Range{...}, d.tokens[i].content}
}
_, node := parseComment(...)
node.(RangedNode).GetRange() Maybe I'm just being nitpicky here. Any thoughts? |
Hi I would like to experiment with
go-org
to build a LSP for org.I'm new in go and so my observations might be not correct.
My intention is locate all the
#+begin_src
and use the language tag and grab the content and proxy to an appropriate LSP, which I control for proper integration.I manage to do this with
orgajs
because theAST
contains the position (start, end) of theNode
.To achieve the same thing with
go-org
I identify some approaches, but since I'm not an expert I'm looking for suggestions:Document.tokens
into publicDocument.Tokens
, this is not perfect because for parsing information likelanguage
I need to go to AST format, but seems the easiest.Document.parseOne
orDocument.parseMany
by making sure that allNode
are converted into*Node
so that I can use the Pointer reference in a Linked List as[*Node]NodePosition
.type Node interface
intotype Node struct
to include more information.Although I'm willing to do a PR if this is from common interest, I'm asking for help to learn and to understand what is the best "golang way" for such case.
Thank you in advance.
The text was updated successfully, but these errors were encountered: