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

autocmd User AiderOpen #10

Merged
merged 7 commits into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Minimal helper plugin for aider with neovim.

## Settings

### vimscript
Please add the following settings to your vimrc or init.vim.

```vim
Expand All @@ -32,6 +33,49 @@ nnoremap <silent> <leader>ai :AiderAddIgnoreCurrentFile<CR>
nnoremap <silent> <leader>aI :AiderOpenIgnore<CR>
nnoremap <silent> <leader>ah :AiderHide<CR>
vmap <leader>av :AiderVisualTextWithPrompt<CR>
augroup AiderOpenGroup
autocmd!
autocmd User AiderOpen call s:AiderOpenHandler()
augroup END

function! s:AiderOpenHandler() abort
" Set key mappings for the buffer
execute 'tnoremap <buffer=' . a:args.buf . '> <Esc> <C-\><C-n>'
execute 'nnoremap <buffer=' . a:args.buf . '> <Esc> :AiderHide<CR>'
endfunction
Copy link
Contributor Author

@tsukimizake tsukimizake Sep 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

vimscriptの設定は自分のlua設定をaiderくんに翻訳してもらっただけなのでできればマージ前に試しておいてほしい(他力本願)

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a:args.bufのところが動かないので(あとフォークされたリポジトリに切り替える方法がよくわからなかった)、マージしてから直します。

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

なんかgit remote addとかする必要があるかもしれねえ ( ;´。 `;)

```

### lua (lazy.nvim)
Please add the following settings to your lazy settings.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

追記ありがとうございます ( ;´ワ `;)つ☆


```lua
{ "nekowasabi/aider.vim"
, dependencies = "vim-denops/denops.vim"
, config = function()
vim.g.aider_command = 'aider --no-auto-commits'
vim.g.aider_buffer_open_type = 'floating'
vim.g.aider_floatwin_width = 100
vim.g.aider_floatwin_height = 20

vim.api.nvim_create_autocmd('User',
{
pattern = 'AiderOpen',
callback =
function(args)
vim.keymap.set('t', '<Esc>', '<C-\\><C-n>', { buffer = args.buf })
vim.keymap.set('n', '<Esc>', '<cmd>AiderHide<CR>', { buffer = args.buf })
end
})
vim.api.nvim_set_keymap('n', '<leader>ar', ':AiderRun<CR>', { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', '<leader>aa', ':AiderAddCurrentFile<CR>', { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', '<leader>aw', ':AiderAddWeb<CR>', { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', '<leader>ax', ':AiderExit<CR>', { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', '<leader>ai', ':AiderAddIgnoreCurrentFile<CR>', { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', '<leader>aI', ':AiderOpenIgnore<CR>', { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', '<leader>ah', ':AiderHide<CR>', { noremap = true, silent = true })
vim.api.nvim_set_keymap('v', '<leader>av', ':AiderVisualTextWithPrompt<CR>', { noremap = true, silent = true })
end
}
```

## Usage
Expand Down
4 changes: 2 additions & 2 deletions denops/aider/aiderCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import * as v from "https://deno.land/x/denops_std@v6.4.0/variable/mod.ts";
import { ensure, is } from "https://deno.land/x/unknownutil@v3.17.0/mod.ts";
import * as fn from "https://deno.land/x/denops_std@v6.4.0/function/mod.ts";
import { getAiderBufferNr, getCurrentFilePath } from "./utils.ts";
import { buffer, checkIfTerminalBuffer } from "./buffer.ts";
import { buffer } from "./buffer.ts";

export const aiderCommand = {
async debug(denops: Denops): Promise<void> {
Expand Down Expand Up @@ -51,7 +51,7 @@ export const aiderCommand = {
if (await getAiderBufferNr(denops) === undefined) {
await aiderCommand.silentRun(denops);
}
if (await checkIfTerminalBuffer(denops, bufnr)) {
if (await buffer.checkIfTerminalBuffer(denops, bufnr)) {
return;
}
const currentFile = await getCurrentFilePath(denops);
Expand Down
Loading