publicodes / language-server

Language server for Publicodes
https://marketplace.visualstudio.com/items?itemName=EmileRolley.publicodes-language-server
MIT License
5 stars 0 forks source link

Feat: improve completion items #10

Open EmileRolley opened 3 weeks ago

EmileRolley commented 3 weeks ago

As the rule names are often really long, it's difficult to choose the right item from the completion menu:

image

We need to find a way to make it more readable. Here a few ideas (don't hesitate to suggest others @johangirod @Clemog):

  1. Put in first position children rules of the current rule + remove the namespace of this rule.
  2. Only put the first letters of each name segment (e.g. logement . électricité . photovoltaique . présent becomes log . éle . pho . présent)
  3. Directly put the title of the rule and the full rule name as hint after it.
johangirod commented 3 weeks ago

I think the full name is a good choice. But I would rather prioritize for the shorter namespace, and not proposing the childrens. The idea is to achieve a flow of multiple autocompletion by narrowing the context. I find myself trying to do that with the extension, but it's not supported for now.

Here is an example :

  1. Let say I know I want to reference a rule for « clé de répartition retraie complémentaire pour les cotisation auto-entrepreneur », but I don't remember the exact name.
  2. I start by narrowing the context by typing « autoentrepreneur ». In this case, we would want to have only « dirigeant . auto-entrepreneur » that match, but none of its children rules!
  3. I find the rule « dirigeant . auto-entrepreneur » and type « Enter »
  4. Then, I want to see if there is a « cotisation » rule. I immediately type « space + Enter » for toggling autocompletion, and the autocomplete only provides rules that are children of the current one. I type « cotisation » and then « retraite » and here I go.

Presently, the behavior in bold are not implemented, but I think it would benefit greatly to the DX.

The second improvement would be to prioritize child rules of the current namespace, and then the parents' one. And not autocomplete from the root when a rule is found, instead just having the relative path from the common ancestor.

EmileRolley commented 3 weeks ago

The idea is to achieve a flow of multiple autocompletion by narrowing the context.

It would be great for sure! However, I'm not sure that's possible as spaces are allowed in rule names :thinking:

johangirod commented 3 weeks ago

It would be great for sure! However, I'm not sure that's possible as spaces are allowed in rule names 🤔

Mmmh, good point. It could be done so that when the selected autocompleted rule has children (is a namespace), the inserted string automatically adds a trailing . at the end.

Or maybe I'm missing a technical limitation of some other kind?