Code editors with hints/autocompletion (split thread)

code-editors
split-thread
#1

Any example of such editors, I’d like to use them, I don’t have any type hints in vscode with elixir_ls … Or maybe I’m misunderstanding what pk1 and pk2 are in your examples, aren’t they primary keys, that is, basic types like strings or ints? In that case there can’t be any type hint since to the type system pk1 and pk2 would be the same. That coupled with non deterministic order during macro generation the possibility of a typo only increases.

But of course, to each their own :slight_smile:

How to create macro to implement get function of Ecto?
#2

Maybe give a try SublimeText 3. It’s not hard use it. The biggest “problem” is configuration which is not created using UI controls, but simply in another editor window in JavaScript files. If it’s not a “problem” for you then it’s nice to at least try it.

With good editor integration you have auto completion which works for already defined variables, module names and function names. If I remember correctly every compiled module in specific project is added to editor hints in SublimeText 3 with Elixir plugin.

SublimeText 3 should be in your package manager. After you install it you only need to install and configure few plugins. For Elixir I use 2 plugins: Elixir and ElixirSublime + some extra plugins like:

  1. A File Icon
  2. Babel
  3. Boxy Theme
  4. BracketHighlighter
  5. Emmet
  6. GraphQL
  7. SideBarEnhancements
    etc.
#3

Seems like your example provides less info than elixir_ls does, so it still doesn’t warn about pk2 being used instead of pk1. So how does it help in avoiding the typos?

#4

Maybe @AstonJ would be able to split the thread, it seems to have gone off-topic.

I’d call it “Avoiding typos in argument order for generated functions”

#5

Please take a look at gif - especially at start when you got a hint for Enum.map/2 which is later changed in example to raw data (list and func). Before that change what you got from hint is: Enum.map(collection, fun) (those variable names comes from function definition), so you would not change it for example to: Enum.map(&IO.puts(&1), [1, 2, 3]) by accident (at least not so easy - you need to be really drunk :077: ).

Now let’s assume our macro generated: MyApp.Queries.get_post_comment(comment_id, post_id). However you have cid (short for comment_id) and pid (short for post_id). As same as in example gif variable: collection is changed to [1, 2] and variable fun is changed to &IO.puts(&1) as same you are changing comment_id to cid and post_id to pid without any typo, because again variables are also in auto completion list. :slight_smile:

So as long as you use hints you would write MyApp.Queries.get_post_comment(cid, pid) rather than MyApp.Queries.get_post_comment(pid, cid). Hmm … SublimeText 3 is not my dreamed editor, but with such hints I never made similar typo. Well … in my case it’s also not about editor, but also coding habits … I personally really like to write long_descriptive_names rather than ldn (whatever it means). :smiley:

Hope I described it well. Please let me know if I misunderstand your question. Also sorry for this off-topic.