jcollard / elm-mode

Elm mode for emacs
GNU General Public License v3.0
373 stars 67 forks source link

Is it intention that "." is a word constituent in the syntax table? #187

Open schoettl opened 1 year ago

schoettl commented 1 year ago

elm-mode seems to treat dots as part of a identifier, e.g. model.state is one word.

This means that in evil mode many commands don't work as expected, e.g. w, b, Ctrl-], *, etc.

I'm aware that .state is also a function to access the state property of model. But in most cases . is not part of an identifier – at least in my code.

How about making . not a punctation instead of a word constituent?

(modify-syntax-entry ?. ".")

purcell commented 1 year ago

See #106 and (subsequently) 3f042ec.

purcell commented 1 year ago

Perhaps that provides a bit of context about what the trade-offs might be.

schoettl commented 1 year ago

So eglot and elm lang server really need that for completion to work? I mean, model.state are actually two symbols, not one?

And can these programs complete JD.decode if JD is an import Json.Decoder as JD?

Do these programs also have a "jump to definition" that works with dot being a symbol constituent?

purcell commented 1 year ago

So eglot and elm lang server really need that for completion to work?

Yes, as far as I remember.

I'm not working with Elm much these days, so maybe try applying your suggested change and see what works or perhaps doesn't with elm-language-server.

schoettl commented 1 year ago

I currently don't have time to investigate elm-language-servers behavior – I don't use it myself. I'll fix this in my own emacs config for now.

I'd suggest we leave this issue open as reference for others.

Generally, I think it's better to define the syntax entries semantically correct, i.e. "." not being a symbol constituent because most of the time it isn't. To be honest, I can hardly imagine that the language server needs multiple identifiers to be understood as one term for completion to work.

purcell commented 1 year ago

semantically correct "." not being a symbol constituent because most of the time it isn't.

In Maybe.map, the . is a symbol constituent. One would reasonably expect symbol-at-point to return Maybe.map there, not map.

I can hardly imagine that the language server needs multiple identifiers to be understood as one term for completion to work

Really? For the backend to know whether to correctly complete "ma" to "map" or something else, it needs to know whether or not that string is a prefixed symbol like Maybe.ma.

But yes, needs some testing before we can know if a change is warranted.

schoettl commented 1 year ago

Hm, I would have seen Maybe.map as two identifiers i.e. two symbols: Maybe the identifier for the module and map the identifier for the function within the module. I thought most IDE integration tools are context-aware to a degree.