ca1989

ca1989

Hi all,

my editor (neovim + elixir-ls via coc.nvim) does format on save.

Randomly, it adds parenthesis around macros, so I have a diff looking like:

- get "/", PageController, :home
+ get("/", PageController, :home)

Is anyone experiencing something similar?

Thank you

Showing Posts 1 to 10

linusdm

linusdm

I’d guess this is related to this elixir-ls issue: Formatter doesn't respect formatter.exs while your code is still compiling · Issue #526 · elixir-lsp/elixir-ls · GitHub

If you wait for the underlying compilation to finish, the formatter options are respected again, which makes it seem random.

ca1989

ca1989 OP

Ah!

Thank you

elurker

elurker

Sorry to revive this, I’m experiencing this all the time in NeoVim (LazyVim). I’ve already updated all plugins to their latest versions, and using Eliixir 1.15. It doesn’t add parenthesis in VS Code. Not sure what else to try..

dimitarvp

dimitarvp

Not sure if that helps but you could just specify these exceptions in your own .formatter.exs in the root of your project. Here’s an example from one of mine:

[
  import_deps: [:ecto, :phoenix],
  inputs: ["*.{ex,exs}", "priv/*/seeds.exs", "{config,lib,test}/**/*.{ex,exs}"],
  locals_without_parens: [from: 2],
  line_length: 100,
  subdirectories: ["priv/*/migrations"]
]

In this case, I don’t want Ecto.Query.from be given parentheses.

dimitarvp

dimitarvp

Oh, here’s a more detailed example:

[
  inputs: ["mix.exs", ".formatter.exs", "{config,lib,test,priv}/**/*.{ex,exs}"],
  locals_without_parens: [
    # Plug
    plug: 1,
    plug: 2,

    # Phoenix
    pipe_through: 1,
    render: :*,
    action_fallback: 1,
    get: :*,
    post: :*,
    put: :*,
    delete: :*,

    # Ecto
    add: 2,
    add: 3,
    field: 2,
    belongs_to: 2,
    from: 2,
    embeds_many: 2
  ]
]
dimitarvp

dimitarvp

elurker

elurker

Thanks - I’ve tried that and even [:*], and it doesn’t seem to have any effect..

dimitarvp

dimitarvp

Well admittedly I don’t use coc.nvim so not sure I can help further. I use other NeoVim plugins.

elurker

elurker

I don’t think mine uses coc either - here’s the list of the ones in use, I believe: LazyVim/lua/lazyvim/plugins/extras/lang/elixir.lua at 68ff818a5bb7549f90b05e412b76fe448f605ffb · LazyVim/LazyVim · GitHub (also nvim-lint is enabled by default, while none-ls is not).

So it does seem to use elixir_ls under the hood, but for some reason it only behaves correctly in VS Code wrt formatting (other functionality like linting works well).

dimitarvp

dimitarvp

Even though I use NeoVim for a year or so now, I am very slowly learning it (not enough time or energy to become a pro there at the moment). So not sure I can help – maybe try disabling credo?

Where Next? Top

Trending in Questions Top

RSP87
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
nseaSeb
Hello, I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
brecabral
Documentation While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
RemyXRenard
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
velrest
So my question is quite simple and i have found no conclusive answer on forum, google or AI. Should we use :erlang.float for Integer to ...
New
samoloth
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
asweet-confluent
I recently noticed that Elixir’s Logger defaults its primary log level to :debug when no :logger, :level application configuration is pre...
New

Other Trending Topics Top

JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
mhanberg
Hi everyone! The first release candidate for the Expert language server project is now available! We’ve published a press release detai...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Dmk
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews