elixir-editors / vim-elixir

Vim configuration files for Elixir
http://elixir-lang.org/
Other
1.31k stars 152 forks source link

Please do not re-indent the content of multiline strings/heredocs #505

Closed vais closed 5 years ago

vais commented 5 years ago

It could be argued that the content of multiline strings/heredocs shall not be altered when indenting. At least that's how indentation works in both Ruby and JavaScript Vim plugins. Vim-elixir currently re-indents the contents:

Before indenting:

defp sql do
  """
  SELECT *
    FROM table
   WHERE column = 123
     AND another_column = 456
  """
end

Actual (after indenting)

defp sql do
  """
  SELECT *
  FROM table
  WHERE column = 123
  AND another_column = 456
  """
end

Expected (content inside multiline string shall remain the same before and after indenting)

defp sql do
  """
  SELECT *
    FROM table
   WHERE column = 123
     AND another_column = 456
  """
end
jbodah commented 5 years ago

Related: https://github.com/elixir-editors/vim-elixir/issues/346

jbodah commented 5 years ago

One idea for how we could implement this: check if the beginning of the line is a string; if it is, don't indent the line. We may need to do something about quotes and sigils