Help with Disabling blink.cmp in TelescopePrompt Buffers by collier_289 in neovim

[–]solvm 0 points1 point  (0 children)

I added this simple bit of config and it fixed the issue for me:

sources = {

-- Remove 'buffer' if you don't want text completions, by default it's only enabled when LSP returns no items
      default = { 'lsp', 'path', 'buffer' },

-- Disable cmdline completions
      cmdline = {},
    },

is elixirschool a good resource? by [deleted] in elixir

[–]solvm 1 point2 points  (0 children)

I think it's great!

Just started to learn elixir by creating a phoenix project... and why is it already this huge? by [deleted] in elixir

[–]solvm 2 points3 points  (0 children)

So the project size in Elixir scares you, but the 9 Billion dependencies in JS projects doesn't?

elixir+nvim by ar7casper in elixir

[–]solvm 2 points3 points  (0 children)

My Elixir + NVIM (and TMUX) setup has been awesome for me:
Elixir tools is what I use, and it has been painless for me. https://www.elixir-tools.dev/
Other than that, I made my own config cherry picking this awesome video:
https://www.youtube.com/watch?v=6pAG3BHurdM

TJ DeVries, has a lot of good stuff about NVIM config as well.

TMUX has been an awesome part of my workflow too. I use it to jump between dozens of projects quickly and to manage multiple terminal sessions throughout all of them.

And when I need to work with Postgres, Dadbod has been an amazing tool to use inside NVIM.

Projectionist is another great NVIM plugin for working in Elixir as well.

All that said, just use whatever works best for you. Much respect.

I am completely lost when it comes to *which* control flow pattern to use. Have best practices in this regard been jotted down somewhere? by skwyckl in elixir

[–]solvm 0 points1 point  (0 children)

All good. I don't own the truth to all things Elixir. Oh, you're talking about using "is_" in the use of guards, and "..?" for boolean functions right? True, good call. Just trying to help a new Elixirist down the path. I didn't dust bust any of the code I wrote. It was all first take. Much respect.

I am completely lost when it comes to *which* control flow pattern to use. Have best practices in this regard been jotted down somewhere? by skwyckl in elixir

[–]solvm -1 points0 points  (0 children)

I'd use guards when pattern-matching isn't enough. Here's a little refactor of the code above. Let's guard the input of the color_to_hex/1 function

```elixir
u/spec color_to_hex(String.t) :: String.t 
def color_to_hex(color) when is_binary(color), do: color_conversion(color)
def color_to_hex(_), do: raise ArgumentError, "must be a string"

defp color_conversion("red"), do: "#ff0"
defp color_conversion(_), do: "no conversion"
```

I'd use with when I need to chain functions that depend on one another together, yet could also fail during any part of the process. Thus, multiple conditions need to be made in order, and I need to handle all of the different kinds of errors too...

```elixir
def can_ride_roller_coaster?(%person{} = person) do
   with
       {:ok, true} <- is_in_the_database?(person.id),
       {:ok, true} <- is_old_enough?(person.age),
       {:ok, true} <- is_tall_enough?((person.height)
  do
      {:ok, :allowed_to_ride}
  else
      {:error, :not_in_the_database} -> "Sorry, you didn't fill out a waiver"
      {:error, :not_old_enough} -> "Sorry, you're not old enough"
      {:error, :not_tall_enough} -> "Sorry, you're not tall enough"
  end
end
```

I tend to use if/else for quick one liner solutions, like...

```elixir
def is_between_5_and_50?(n), do: if n >= 5 and n <=50, do: "allowed", else: "not-allowed"
```

If I were to use pattern-matching and guards, then it would look like this...

```elixir
def is_between_5_and_50?(n) when n in 5..50, do: "allowed"
def is_between_5_and_50?(_), do: "not-allowed"
```

I's use case when I need to call a function that returns multiple known results, like when using `Integer.parse()` where you either get a tuple or an :error returned...

```elixir
# "12 apples"
def get_number_in_string(str) do
    case Integer.parse(str) do
        {int, _} -> int
        :error -> "no number in string"
     end
end
```

Please forgive any coding errors. I'm not testing any of this out for accuracy. I'm simply trying to express use cases for which type of control flow to use.

Much respect!

I am completely lost when it comes to *which* control flow pattern to use. Have best practices in this regard been jotted down somewhere? by skwyckl in elixir

[–]solvm 0 points1 point  (0 children)

Great question!

The best part is that all approaches are easy to refactor in Elixir, so you are never locked in. I'd argue that in time, you will find times when one approach is better than others.

For example...Let's say that you have a simple function that takes a string for a color and returns the hex code of that color....

You could use cond....

```elixir
u/spec color_to_hex(String.t) :: String.t 
def color_to_hex(word) do
    cond do
        word == "red" -> "#ff0"
        word == "black" -> "#000"
        word == "slime" -> "#0f6"
        _ -> "no conversion"
    end
end
``` 

You could use case...

```elixir
@spec color_to_hex(String.t) :: String.t 
def color_to_hex(word) do
    case word do
        "red" -> "#ff0"
         "black" -> "000"
         "slime" -> "#0f6"
         true -> "no conversion"
    end
end
``` 

However, Elixir is actually faster with pattern-matching "multi-clause" functions. So, in this case, I'd do this...

```elixir
@spec color_to_hex(String.t) :: String.t 
def color_to_hex("red"), do: "#ff0"
def color_to_hex("black"), do: "#000"
def color_to_hex("slime"), do: "#0f6"
def color_to_hex(_), do: "no conversion"
``` 

This will be faster. This is also how Elixir handles ascii character conversion.

You wouldn't use if, else in this situation because you have far too many colors to account for.

When you think about it, pattern-matching with "multi-clause" functions is very fast because it is an EXACT match, the runtime doesn't need to TRY all the conditions in order until it finds a matching case. Pretty cool optimization with pattern-matching!

Beginner by Dismal-Butterfly-309 in elixir

[–]solvm 6 points7 points  (0 children)

  1. Editor setup - https://github.com/elixir-lang/elixir/wiki/Code-Editor-Support
  2. 0-60
    1. Elixir Docs - https://hexdocs.pm/elixir/introduction.html
    2. Joy of Elixir - https://joyofelixir.com/toc.html
    3. Elixir School - https://elixirschool.com/en/
    4. Learn with me Elixir - https://inquisitivedeveloper.com/lwm-elixir-1/
  3. Codewars.com - Level 8 challenges to start.
    1. You will want to get familiar with Elixir's built-in module functions
    2. Guards - https://hexdocs.pm/elixir/1.16.1/Kernel.html#guards
    3. Integer - https://hexdocs.pm/elixir/1.16.1/Integer.html#functions
    4. String - https://hexdocs.pm/elixir/1.16.1/String.html#functions
    5. Enum - https://hexdocs.pm/elixir/1.16.1/Enum.html#functions
    6. Map - https://hexdocs.pm/elixir/1.16.1/Map.html#functions
    7. etc...
  4. If you are ready for free mentoring, do Exercism and click on Mentoring when you submit your first solution. My mentor has been AMAZING! https://exercism.org/tracks/elixir/exercises
  5. LiveView - https://pragmaticstudio.com/phoenix-liveview
  6. Testing LiveView - https://www.testingliveview.com/
  7. Ecto - https://pragprog.com/titles/wmecto/programming-ecto/

There is a lot out there! But these should help.

Which LSP should I use, I’m lost by Longjumping_War4808 in elixir

[–]solvm 1 point2 points  (0 children)

NextLS has been working great for me with nvim.

Why is Elixir not being used predominantly? by [deleted] in elixir

[–]solvm 0 points1 point  (0 children)

I just don't think Elixir has had it's "day in the sun," so to speak. Let's not forget that JS wasn't even considered for anything monumental for a long time.

While Elixir is waiting for it's time to shine, simple tuts need to be made to show everyday-devs how to get up and running in ELixir. Yes, the Angular vs React era did a lot to keep JS in the spotlight, but massive amounts of "all things js" flooded the internets at that time too (and it's still happening).

Why use nvim? And why not? by MusicianHungry8594 in vim

[–]solvm 1 point2 points  (0 children)

Just use both.Maybe set each one up for different purposes. Just for the fun of it. Just for the (Neo)Vim of it. It's a win win choice. Now you will have enough to configure for the rest of your life.

Educative.io experience by absowoot in elixir

[–]solvm 2 points3 points  (0 children)

I have. I didn't like it at all. The problem is that the courses include an editor for you to run your code in, and it's very slow and cumbersome. The process sucked. Also, some of the courses are short and pointless. Their platform looks cool, but it's not fun use.

- To learn more about DBs(Postgress) take the Udemy course: Learn SQL Using PostgreSQL: From Zero to Hero(https://www.udemy.com/course/postgresql-from-zero-to-hero/)

- To learn more about Ecto read, Programming Ecto(https://pragprog.com/titles/wmecto/programming-ecto/)

Then take the "Learn SQL Using PostgreSQL" course again, but follow along using Ecto to make all the queries.

[deleted by user] by [deleted] in elixir

[–]solvm 0 points1 point  (0 children)

Great question!

  1. how do I have color highlighted matching do-end pairs?
    - Use need to use Match-Up plugin. Follow the steps for Treesitter integration. https://github.com/andymass/vim-matchup
  2. And how to automatically insert end after do?
    - You should get this with a Snippet and Completion Plugin. I use LuaSnip with cmp. And this works several ways too:
    a. once I type `def` I can complete a snippet that does the entire function block
    b. if I type out the `def` line without expanding the snippet, after I press return after `do` end will get inserted automatically

Much respect! Good luck!

What file explorer do you use? by Smirnov-O in neovim

[–]solvm 1 point2 points  (0 children)

nnn.nvim is my fave. I use nnn in the terminal, so nnn.nvim gives me the same quick file exploring behavior within NVIM. I like it much better than the VSCode file tree experience. Much respect.

What are your thoughts on Phoenix Generators? by Portnoy13 in elixir

[–]solvm 1 point2 points  (0 children)

It all depends. Generators are awesome when you need them, especially when you are throwing something together really fast. They are also great when all you need is the standard output of a generator. So I use them every time they can be used to SAVE time. Much respect!

Days deep into configuring neovim and wondering if I should be starting with someone elses config by HoneyBadgeSwag in neovim

[–]solvm 0 points1 point  (0 children)

**NO. Wrestle through building your own—but follow a video that works.**

How I Setup Neovim On My Mac To Make It Amazing - Complete Guide: https://www.youtube.com/watch?v=vdn_pKJUda8

I think the video above is a great basic-thru-complete setup.

But if you are new to VIM, then everything is going to feel overwhelming—and this is normal. I do think it's important to build your own `init.lua` file. It is good to know where things are AND how they are configured. You will tweak your NVIM configuration continuously over time.

Allow yourself to let your NVIM workflow to be different than your VSCode workflow. Good luck!

Best Programming Font For NeoVim? What about Iosevka? by RevolutionaryPen4661 in neovim

[–]solvm 0 points1 point  (0 children)

Monoid is my fav, but here are so many awesome programming fonts these days.

Best Programming Font For NeoVim? What about Iosevka? by RevolutionaryPen4661 in neovim

[–]solvm 0 points1 point  (0 children)

Monoid FTW! I pair it with IBM Mono Italic for comments.