Skip to content

Commit

Permalink
fix(nvim): annoying indentation for comments in Elixir
Browse files Browse the repository at this point in the history
When entering a new comment in an indented line, the indentation would
get removed and the comment would get pulled to the beginning of the
line. e.g.:

```elixir
def Foo do
  def hi do
\# hello
    IO.inspect("Hello")
  end
end
```

After the fix
```elixir
def Foo do
  def hi do
    \# hello
    IO.inspect("Hello")
  end
end
```
  • Loading branch information
dkarter committed Sep 15, 2023
1 parent 7f12fad commit 546eeb0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 3 additions & 1 deletion config/nvim/lua/core/options.lua
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ opt.shiftwidth = indent -- Number of spaces to use for each step of (auto)indent
opt.softtabstop = indent
opt.expandtab = true -- Use the spaces to insert a <Tab>
opt.shiftround = true -- Round indent to multiple of 'shiftwidth'
opt.smartindent = true
-- this was messing up comments starting with `#`
-- see https://vim.fandom.com/wiki/Restoring_indent_after_typing_hash
opt.smartindent = false

-- text appearance
opt.textwidth = 80 -- set row width size in characters
Expand Down
3 changes: 3 additions & 0 deletions config/nvim/lua/plugins/treesitter.lua
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ M.setup = function()
},
autotag = { enable = true },
highlight = { enable = true },
indent = {
enable = true
},
context_commentstring = {
enable = true,
enable_autocmd = false,
Expand Down

0 comments on commit 546eeb0

Please sign in to comment.