elm-mode icon indicating copy to clipboard operation
elm-mode copied to clipboard

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

Open schoettl opened this issue 3 years ago • 7 comments

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 ?. ".")

schoettl avatar Oct 11 '22 14:10 schoettl

See #106 and (subsequently) 3f042ec.

purcell avatar Oct 11 '22 14:10 purcell

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

purcell avatar Oct 11 '22 14:10 purcell

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?

schoettl avatar Oct 11 '22 16:10 schoettl

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.

purcell avatar Oct 11 '22 20:10 purcell

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.

schoettl avatar Oct 16 '22 16:10 schoettl

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.

purcell avatar Oct 19 '22 07:10 purcell

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.

schoettl avatar Oct 19 '22 08:10 schoettl