lexical-lsp / lexical

Lexical is a next-generation elixir language server
888 stars 82 forks source link

Respect existing capitalization in `defmodule` completion #786

Open zachallaun opened 4 months ago

zachallaun commented 4 months ago

When completing defmodule, Lexical infers the default module name from the path and file name. For instance:

# lib/my_app/foo/bar.ex
defmodule MyApp.Foo.Bar do
  |
end

How you capitalize acronyms in modules is a point of preference. For instance, lib/my_app/http.ex might contain MyApp.Http or MyApp.HTTP; both are equally valid. Lexical will always generate the camel-case version, which is fine.

However, if you've chosen uppercase and have an existing module MyApp.HTTP and then complete defmodule at lib/my_app/http/request.ex, the default module will be MyApp.Http.Request.

It should be possible for Lexical to infer that you want MyApp.HTTP.Request based on the existence of MyApp.HTTP.