reedline icon indicating copy to clipboard operation
reedline copied to clipboard

prior art as a reference

Open fdncred opened this issue 4 years ago • 2 comments

In this one image are several features that I'd love to see reedline strive to attain.

image

  • [x] context aware syntax highlighting - note how the string 'Hello world' is colored differently from python keywords
  • [x] configurable line continuation character(s) - note the ... on the second line
  • [ ] it's hard to miss the drop down combo box with scroll bar - no clue how to achieve this one, maybe tui? i guess this population would be language specific, but of course, i'm thinking about nushell. :) a use case is to use this with completions of sub commands in nushell and completions in general.
  • [ ] the status bar - would be nice to show hints, errors, etc in a status bar, opt-in configurable, of course

some of these we're well on our way to achieving.

This is taken from here and the github repo.

For reference, i found this collection of supported ansi escape sequences very informative.

To be clear, i'm not talking about baking in python or this python line editor. I'm just using it as a prior art reference.

fdncred avatar Jul 14 '21 13:07 fdncred

One of the ways I can think of achieving this is by using treesitter. With that, we should have even better highlighting, considering it can do syntax highlighting based on an AST instead of regex-based highlighting (which ig is the popular option at present).

I don't really know how to integrate treesitter with reedline (that is something we will need to figure out). Though I would wager the harder part would have been writing the parser for nu-shell. (Luckily for us it already exists - https://github.com/LhKipp/tree-sitter-nu). And for other popular languages, there are already parsers, so if bash/fish/sh or any other shells decide to use reedline they should get this for little work. Note: in addition to syntax highlighting we can also get stuff like

  • context-aware rename
  • text objects (like block, function, etc), (e.g. someone using vim mode can do stuff like cib which can mean change in block)
  • etc.

Absolutely random thought: as for the drop-down menu, I don't really know how to achieve this with the UI, but if we want to do something overkill we can integrate an LSP client (https://github.com/ebkalderon/tower-lsp) to readline so that it can do anything that an editor can. Now the creation of a language server is going to be hard, but my assumption is that the nu-shell folks might already be thinking about it as it can add editor support for almost all the ones that people use.

nixypanda avatar Aug 12 '21 20:08 nixypanda

treesitter would be an interesting experiment, as you've outlined it.

an LSP would be cool indeed. we definitely want to add a LSP to nushell but we're not there yet. luckily, we have @jntrnr who worked on rust's RLS, i believe. we just need a jt.clone() function to get everything done.

fdncred avatar Aug 17 '21 14:08 fdncred