mini.nvim icon indicating copy to clipboard operation
mini.nvim copied to clipboard

mini.lint and mini.format plugins for linting and formatting.

Open 231tr0n opened this issue 1 year ago • 3 comments

Contributing guidelines

Module(s)

mini.lint, mini.format

Description

Hi echasnovski! Is it in scope of mini.nvim to include plugins like nvim-lint, conform.nvim but without the configurations provided by those for linters and formatters so that anyone can setup their own linter or formatter using the functions provided.

231tr0n avatar Dec 09 '24 07:12 231tr0n

Thanks for the suggestion!

They are not planned in the new future, for sure. Mostly because having such modules without built-in configs cuts from the final worth, but also for other reasons (linting should mostly be covered by built-in diagnostics, while 'stevearc/conform.nvim' is a really good choice for formatting).

But let's keep this open for now.

echasnovski avatar Dec 09 '24 11:12 echasnovski

I am just dropping this plugin here for reference https://github.com/nvimdev/guard.nvim. So this plugin has really clean api and implements formatting and linting configs in a really clean manner. Please do make it so that the config api is similar to something like what this plugin offers if mini.lint and mini.format is going to happen.

231tr0n avatar Dec 09 '24 15:12 231tr0n

I’m not sure if mini.format should be implemented as a module for formatting. It could instead be a module that fixes the behavior of the gq<motion> command.

The main idea is that this command sends the selected lines to formatprg via stdin. The problem is that if you take a single line somewhere in the middle of a program, the formatter will dedent it incorrectly due to the lack of surrounding context.

An imaginary mini.format could instead send a minimal block of code to the formatter, then (using some algorithm) determine which lines were actually changed and update only those in the file.

For demonstration:

1: local function make_example()
2:   local function example()
3:     vim.print('Example')
4:   end
5:   return example
6: end

After 3jgqq:

1: local function make_example()
2:   local function example()
3: vim.print('Example')
4:   end
5:   return example
6: end

As an example, see https://github.com/neovim/neovim/discussions/35602.

drowning-cat avatar Aug 28 '25 12:08 drowning-cat