Skip to content

Don't create user commands #35

Open
@axkirillov

Description

@axkirillov

Hi! I love this plugin, and I think it is the best of out of several trying to integrate aider into nvim.

I have extended it with my own commands, but I have to use workarounds because some core functionality is not exported. Like, for example, consider this user command:

		local terminal = require("nvim_aider.terminal")

		vim.api.nvim_create_user_command(
			"RunTestInAider",
			function()
				local filename = vim.fn.expand('%:t:r')
				local filepath = vim.fn.expand('%')
				terminal.send(
					"/add " .. filepath,
					config,
					false
				)
				terminal.send(
					"/run ./test.sh " .. filename,
					config,
					false
				)
				terminal.toggle()
			end,
			{}
		)

I would prefer an add_file() funtion to be available that takes a filepath, or just grabs current file, if empty
Same, for the send. Besides, I need to provide terminal config each time, because accessing the terminal directly, I bypass the config I passed to nvim_aider already.
This seems to be an issue with other functionality as well where, instead of lua api, user commands are provided, which is less flexible than a lua api would be.
Furthermore, I am generally in favor of the approach of plugins not creating user commands for the user. It pollutes the user's commands list with commands that they might not need. Instead, I find it nice, when plugins only provide a lua api, such as, or example the snacks terminal plugin which you use. Users can create their own command then, and can be provided with an example config to do so.
Let me know what you think, and I would be happy to provide PRs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions