Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: formatting.lua sets formatexpr unconditionally #1759

Closed
3 tasks done
agriffis opened this issue Oct 16, 2023 · 3 comments · Fixed by #1757
Closed
3 tasks done

bug: formatting.lua sets formatexpr unconditionally #1759

agriffis opened this issue Oct 16, 2023 · 3 comments · Fixed by #1757
Labels
bug Something isn't working

Comments

@agriffis
Copy link
Contributor

Did you check docs and existing issues?

  • I have read all the LazyVim docs
  • I have searched the existing issues of LazyVim
  • I have searched the existing issues of plugins related to this issue

Neovim version (nvim -v)

v0.10.0-dev+1344-g712adacdf

Operating system/version

Fedora 38

Describe the bug

Since lazyvim switched to conform, formatexpr is set in a way that is hard to override:

vim.o.formatexpr = "v:lua.require'conform'.formatexpr()"

I've tried setting it in config/options.lua back to the default vim.opt.formatexpr = '' (so that gq wraps text rather than calling conform) but the plugin overrides. I also tried various hacks such as

  {
    'stevearc/conform.nvim',
    opts = function()
      vim.opt.formatexpr = '' -- LazyVim conform plugin sets this, but we don't want it
    end,
  },

but that only works on the second invocation of gq, and it's obviously hacky besides.

Seems like this should be an optional setting, but I'm not sure if you'd rather do it in the opts for that plugin, or a different way. Thoughts?

Steps To Reproduce

  1. Load a text file
  2. gql doesn't wrap lines
  3. :set formatexpr=''
  4. Now gql wraps lines

Expected Behavior

I want gq to work the normal vim way, instead of calling conform

Repro

Actually struggling with the minimal repro. Will update when I have that working
@agriffis agriffis added the bug Something isn't working label Oct 16, 2023
@agriffis
Copy link
Contributor Author

agriffis commented Oct 16, 2023

Here's the workaround I'm using for the moment:

local Formatting = require('lazyvim.plugins.formatting')

return {
  {
    'stevearc/conform.nvim',
    init = function()
      Formatting[1].init()    -- call the original init func
      vim.opt.formatexpr = '' -- reset formatexpr
    end,
  },
}

@folke folke closed this as completed in ff64cc5 Oct 16, 2023
@folke
Copy link
Collaborator

folke commented Oct 16, 2023

You can now override it in options.lua

@agriffis
Copy link
Contributor Author

Thank you!

Gasol added a commit to Gasol/dotfiles that referenced this issue Oct 19, 2023
andros21 added a commit to andros21/dotfiles that referenced this issue Oct 24, 2023
so `gq` can be used to manually wrap text as before

see LazyVim/LazyVim#1759
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants