On 2/14/23 04:25, Randy Taylor wrote:

Hi Dmitry and Jostein,

Here is the promised patch in all its glory.
I have also attached a screenshot of how things look now.

Changes:
- Attributes are now highlighted with font-lock-preprocessor-face.
- Added import-specific queries to cover all (hopefully...) import highlights, and simplified the existing scoped identifier types.
  - Note: I decided that anything at the end of a scoped identifier for imports or within a use list that's lowercased should be the default face because we don't know if it's a module, function, type, or whatever else. rust-mode also does this, and now we match their highlighting almost one for one. neovim and the rest do it this way too, and it makes the most sense.

Haven given the latest patch a try on a less macro-ridden codebase I have to say it looks a lot better. In general I would say for this other code-base it looks favourable to rust-mode.

If there's one thing which still seems to be done better in rust-mode (not nitpicking the variable highlighting), it would be fully namespaces function calls within classes.

Consider the following code:

extern crate claxon;
let result = claxon::FlacReader::open(path);

While rust-ts-mode correctly identifies that open() is a function-call, rust-mode correctly identified FlacReader as a class.

Based on the tree-sitter output for this node, it seems plausible that one should be able to implement the same for rust-ts-mode as well.

(source_file (line_comment)
 (extern_crate_declaration extern (crate) name: (identifier) ;)
 (let_declaration let pattern: (identifier) =
  value:
   (call_expression
    function:
     (scoped_identifier
      path: (scoped_identifier path: (identifier) ::
                               name: (identifier))                                <-- this is the class
      :: name: (identifier))
    arguments: (arguments ( (identifier) )))
  ;))

That's nowhere near a "big" problem though. It's just icing on the cake ;)

--
Jostein