NMAC427 / guess-indent.nvim

Automatic indentation style detection for Neovim
MIT License
413 stars 8 forks source link

[Feature Request] Lua function for guessing indentation #21

Open smartinellimarco opened 4 months ago

smartinellimarco commented 4 months ago

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)
banjo commented 2 months ago

Any news on something similar to this?

smartinellimarco commented 1 month ago

@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