Giter Club home page Giter Club logo

Comments (9)

josteink avatar josteink commented on July 17, 2024 1

In csharp-mode we are experimenting on a complete rewrite based on tree-sitter-mode, which gives us a real AST to work with.

The results there have been very promising.

If we were to fix all those small issues we have here, without creating some insane complexity in the lisp-code, I believe we may have to consider doing the same.

from typescript.el.

lddubeau avatar lddubeau commented on July 17, 2024

Yeah, I noticed that they are broken a while back. I thought I might need to fix them in order to fix an indentation issue but it turned out that I did not need them. I've not spent time fixing them because their brokenness does not have an actual impact on my work.

Using git blame it looks like nobody spent any time on them. They are probably exactly like their counterpart in js-mode and so have no TypeScript-specific knowledge.

I suspect they are going to get fixed when they become a real obstacle to someone's work. When that happens, whoever fixes them may want to think about biting the bullet to get the mode to use an AST. The fact of the matter is that TS allows for really complex code structures that would probably throw off the kind of logic that just looks around (point) to figure what is going on. I mean, stuff like this is legit, except for the return undefined (I did not feel like writing a proper return value):

class Q<X> {
}

function glerb(a: any = new class extends Object {
    private x = 1;

    moo(): void {
    }
}): Q<{
    a: 1,   
    b: () => void,  
}> {
    return undefined;
}

And I'm just scratching the surface of what TS allows.

from typescript.el.

oneeman avatar oneeman commented on July 17, 2024

Makes sense. Thanks for the details.

from typescript.el.

kishiguro avatar kishiguro commented on July 17, 2024

I encountered same issue. Is there anybody who is working on fixing this issue?

from typescript.el.

hermann-p avatar hermann-p commented on July 17, 2024

I have similar problems, using the beginning-of-defun and end-of-defun implicitly with narrow-to-defun.
Another place where beginning/end of defun completely fails is lambda functions () => "I'm a a result" or named lambda functions const getTheAnswer = () => 42.
I don't know enough emacs lisp to be of any help, though...

from typescript.el.

ananthakumaran avatar ananthakumaran commented on July 17, 2024

@josteink from what I understand tree-sitter only supports highlighting? does it support other functions like mark-sexp, end-of-defun etc? which is more related to movement. I actually want to use tree-sitter for movement functionality, but can't find any reference or how to use it.

from typescript.el.

josteink avatar josteink commented on July 17, 2024

@josteink from what I understand tree-sitter only supports highlighting? does it support other functions like mark-sexp, end-of-defun etc? which is more related to movement. I actually want to use tree-sitter for movement functionality, but can't find any reference or how to use it.

Tree-sitter supports navigation based on AST knowledge.

Based on this it is fairly trivial to create move-to-beginning-of-defun functions.

See this issue in csharp-mode for an example: emacs-csharp/csharp-mode#219

The discovery there though was that pretty much all of those functions can be generalised for all tree-sitter based major-modes so we decided we should try to get such functions upstreamed rather than implement it in a major-mode specific way.

from typescript.el.

ananthakumaran avatar ananthakumaran commented on July 17, 2024

sweet, tree-sitter-node-at-point this is what I am looking for.

from typescript.el.

josteink avatar josteink commented on July 17, 2024

So... We're rewriting typescript-mode to be tree-sitter-mode based too now? 😁

If so, I would suggest taking a look at csharp-tree-sitter-mode as a whole, and start from scratch based on something like that (sans grammar-portion), instead of incrementally trying to rewrite what we have.

Edit: it seems like tree-sitter-langs-package already contains typescript-grammar.

So ... What's left for us to do then? 😄

from typescript.el.

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.