1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
return {
"milanglacier/yarepl.nvim",
lazy = true,
event = "BufRead",
ft = { "python", "bash", "R" },
config = function()
local yarepl = require 'yarepl'
yarepl.setup {
-- see `:h buflisted`, whether the REPL buffer should be buflisted.
buflisted = true,
-- whether the REPL buffer should be a scratch buffer.
scratch = true,
-- the filetype of the REPL buffer created by `yarepl`
ft = 'REPL',
-- How yarepl open the REPL window, can be a string or a lua function.
-- See below example for how to configure this option
-- wincmd = 'belowright 15 split',
-- wincmd = 'vertical 120 split',
wincmd = 'vertical split', -- equally 50%
-- wincmd = function(bufnr, name)
-- if name == 'ipython' then
-- vim.api.nvim_open_win(bufnr, true, {
-- relative = 'editor',
-- row = math.floor(vim.o.lines * 0.25),
-- col = math.floor(vim.o.columns * 0.25),
-- width = math.floor(vim.o.columns * 0.5),
-- height = math.floor(vim.o.lines * 0.5),
-- style = 'minimal',
-- title = name,
-- border = 'rounded',
-- title_pos = 'center',
-- })
-- else
-- -- vim.cmd [[belowright 15 split]]
-- -- vim.api.nvim_set_current_buf(bufnr)
-- end
-- end,
-- The available REPL palattes that `yarepl` can create REPL based on
metas = {
aichat = { cmd = 'aichat', formatter = yarepl.formatter.bracketed_pasting },
radian = { cmd = 'radian', formatter = yarepl.formatter.bracketed_pasting },
ipython = { cmd = 'ipython', formatter = yarepl.formatter.bracketed_pasting },
-- python = { cmd = 'python', formatter = yarepl.formatter.trim_empty_lines },
python = { cmd = 'bpython -q', formatter = yarepl.formatter.trim_empty_lines },
R = { cmd = 'R', formatter = yarepl.formatter.trim_empty_lines },
bash = { cmd = 'bash', formatter = yarepl.formatter.trim_empty_lines },
zsh = { cmd = 'zsh', formatter = yarepl.formatter.bracketed_pasting },
},
-- when a REPL process exits, should the window associated with those REPLs closed?
close_on_exit = true,
-- whether automatically scroll to the bottom of the REPL window after sending
-- text? This feature would be helpful if you want to ensure that your view
-- stays updated with the latest REPL output.
scroll_to_bottom_after_sending = true,
os = {
-- Some hacks for Windows. macOS and Linux users can simply ignore
-- them. The default options are recommended for Windows user.
windows = {
-- Send a final `\r` to the REPL with delay,
send_delayed_cr_after_sending = true,
},
},
}
-- 在这里的定义:~/.config/nvim/lazy/yarepl.nvim/lua/yarepl/init.lua
-- modifi: api.nvim_create_user_command('REPLStart', function(opts)
-- vim.keymap.set({"n"}, "<CR>", ":REPLSendLine<CR>j", { silent = true })
-- vim.keymap.set({"v"}, "<CR>", "<Esc>:REPLSendVisual<CR>j", { silent = true })
end
}
|