# Code editors with hints/autocompletion (split thread)

**URL:** <https://forum.elixirforum.com/t/code-editors-with-hints-autocompletion-split-thread/21990>\
**Category:** General Prog (Archived)\
**Tags:** code-editors, split-thread\
**Created:** [April 28, 2019, 5:34pm UTC](https://forum.elixirforum.com/t/code-editors-with-hints-autocompletion-split-thread/21990 "2019-04-28T17:34:46Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![idi527](https://forum.elixirforum.com/letter_avatar_proxy/v4/letter/i/85e7bf/32.png) [@idi527](https://forum.elixirforum.com/u/idi527)\
**Post date:** [April 28, 2019, 5:34pm UTC](https://forum.elixirforum.com/t/code-editors-with-hints-autocompletion-split-thread/21990/1 "2019-04-28T17:34:46Z")

</div>

> [@How to create macro to implement get function of Ecto?](https://forum.elixirforum.com/t/how-to-create-macro-to-implement-get-function-of-ecto/21977/5):
>
> Also I’m not sure if `get_by` is better in this case. In modern (of course well supported by `Elixir` extension/plugin) editor and in app with no similar model names (like `MyApp.Worlds` and `MyApp.Words` ) there should not be any problem as editor should give proper hints and auto completion. Same goes to arguments order as they would be corrected by editor app.

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 🙂

---

<div class="post-metadata">

**Author:** ![Eiji](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/eiji/32/36743_2.png) [@Eiji](https://forum.elixirforum.com/u/Eiji)\
**Post date:** [April 28, 2019, 6:18pm UTC](https://forum.elixirforum.com/t/code-editors-with-hints-autocompletion-split-thread/21990/2 "2019-04-28T18:18:30Z")

</div>

> [@How to create macro to implement get function of Ecto?](https://forum.elixirforum.com/t/how-to-create-macro-to-implement-get-function-of-ecto/21977/6):
>
> Any example of such editors, I’d like to use them, I don’t have any type hints in vscode with elixir\_ls …

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.

> [@How to create macro to implement get function of Ecto?](https://forum.elixirforum.com/t/how-to-create-macro-to-implement-get-function-of-ecto/21977/6):
>
> 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.

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.

[https://packagecontrol.io/readmes/img/6c0fb3db2a430dab8e4753d4e834059ab9694a10.gif(image larger than 400 KB)](https://packagecontrol.io/readmes/img/6c0fb3db2a430dab8e4753d4e834059ab9694a10.gif)

`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](https://packagecontrol.io/packages/Elixir) and [ElixirSublime](https://packagecontrol.io/packages/ElixirSublime) + some extra plugins like:

1. [A File Icon](https://packagecontrol.io/packages/A%20File%20Icon)
2. [Babel](https://packagecontrol.io/packages/Babel)
3. [Boxy Theme](https://packagecontrol.io/packages/Boxy%20Theme)
4. [BracketHighlighter](https://packagecontrol.io/packages/BracketHighlighter)
5. [Emmet](https://packagecontrol.io/packages/Emmet)
6. [GraphQL](https://packagecontrol.io/packages/GraphQL)
7. [SideBarEnhancements](https://packagecontrol.io/packages/SideBarEnhancements)  
etc.

---

<div class="post-metadata">

**Author:** ![idi527](https://forum.elixirforum.com/letter_avatar_proxy/v4/letter/i/85e7bf/32.png) [@idi527](https://forum.elixirforum.com/u/idi527)\
**Post date:** [April 28, 2019, 6:20pm UTC](https://forum.elixirforum.com/t/code-editors-with-hints-autocompletion-split-thread/21990/3 "2019-04-28T18:20:21Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![idi527](https://forum.elixirforum.com/letter_avatar_proxy/v4/letter/i/85e7bf/32.png) [@idi527](https://forum.elixirforum.com/u/idi527)\
**Post date:** [April 28, 2019, 6:24pm UTC](https://forum.elixirforum.com/t/code-editors-with-hints-autocompletion-split-thread/21990/4 "2019-04-28T18:24:10Z")

</div>

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”

---

<div class="post-metadata">

**Author:** ![Eiji](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/eiji/32/36743_2.png) [@Eiji](https://forum.elixirforum.com/u/Eiji)\
**Post date:** [April 28, 2019, 6:37pm UTC](https://forum.elixirforum.com/t/code-editors-with-hints-autocompletion-split-thread/21990/5 "2019-04-28T18:37:52Z")

</div>

> [@How to create macro to implement get function of Ecto?](https://forum.elixirforum.com/t/how-to-create-macro-to-implement-get-function-of-ecto/21977/8):
>
> 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?

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. 🙂

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). 😃

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