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

[Feature Request] Lua function for guessing indentation #21

Open
smartinellimarco opened this issue Jul 3, 2024 · 2 comments
Open

[Feature Request] Lua function for guessing indentation #21

smartinellimarco opened this issue Jul 3, 2024 · 2 comments

Comments

@smartinellimarco
Copy link

smartinellimarco commented Jul 3, 2024

It would be helpful to have a Lua function as a callback for conform.nvim to refresh the indentation after formatting with tools like Prettier.

Example:

  vim.keymap.set({ 'n', 'x' }, 'gq', function()
    conform.format({
      async = true,
      lsp_format = 'fallback',
      quiet = true,
    }, <guess_indent_function>)
  end)
@smartinellimarco smartinellimarco changed the title [Feature Request] Lua API [Feature Request] Lua function for guessing indentation Jul 3, 2024
@banjo
Copy link

banjo commented Sep 13, 2024

Any news on something similar to this?

@smartinellimarco
Copy link
Author

smartinellimarco commented Oct 6, 2024

@banjo you can do

  vim.keymap.set({ 'n', 'x' }, 'gq', function()
    conform.format({
      async = true,
      lsp_format = 'fallback',
      quiet = true,
    }, function()
      vim.cmd('silent GuessIndent')
    end)
  end)

I dont like that for some reason lualine gets hidden until the next refresh. You can refresh it manually in the callback, but that adds to much coupling imo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants