-
Notifications
You must be signed in to change notification settings - Fork 61
/
Copy pathquarto.lua
143 lines (133 loc) · 4.02 KB
/
quarto.lua
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
return {
{ -- requires plugins in lua/plugins/treesitter.lua and lua/plugins/lsp.lua
-- for complete functionality (language features)
'quarto-dev/quarto-nvim',
ft = { 'quarto' },
dev = false,
opts = {},
dependencies = {
-- for language features in code cells
-- configured in lua/plugins/lsp.lua and
-- added as a nvim-cmp source in lua/plugins/completion.lua
'jmbuhr/otter.nvim',
},
},
{ -- directly open ipynb files as quarto docuements
-- and convert back behind the scenes
'GCBallesteros/jupytext.nvim',
opts = {
custom_language_formatting = {
python = {
extension = 'qmd',
style = 'quarto',
force_ft = 'quarto',
},
r = {
extension = 'qmd',
style = 'quarto',
force_ft = 'quarto',
},
},
},
},
{ -- send code from python/r/qmd documets to a terminal or REPL
-- like ipython, R, bash
'jpalardy/vim-slime',
dev = false,
init = function()
vim.b['quarto_is_python_chunk'] = false
Quarto_is_in_python_chunk = function()
require('otter.tools.functions').is_otter_language_context 'python'
end
vim.cmd [[
let g:slime_dispatch_ipython_pause = 100
function SlimeOverride_EscapeText_quarto(text)
call v:lua.Quarto_is_in_python_chunk()
if exists('g:slime_python_ipython') && len(split(a:text,"\n")) > 1 && b:quarto_is_python_chunk && !(exists('b:quarto_is_r_mode') && b:quarto_is_r_mode)
return ["%cpaste -q\n", g:slime_dispatch_ipython_pause, a:text, "--", "\n"]
else
if exists('b:quarto_is_r_mode') && b:quarto_is_r_mode && b:quarto_is_python_chunk
return [a:text, "\n"]
else
return [a:text]
end
end
endfunction
]]
vim.g.slime_target = 'neovim'
vim.g.slime_no_mappings = true
vim.g.slime_python_ipython = 1
end,
config = function()
vim.g.slime_input_pid = false
vim.g.slime_suggest_default = true
vim.g.slime_menu_config = false
vim.g.slime_neovim_ignore_unlisted = true
local function mark_terminal()
local job_id = vim.b.terminal_job_id
vim.print('job_id: ' .. job_id)
end
local function set_terminal()
vim.fn.call('slime#config', {})
end
vim.keymap.set('n', '<leader>cm', mark_terminal, { desc = '[m]ark terminal' })
vim.keymap.set('n', '<leader>cs', set_terminal, { desc = '[s]et terminal' })
end,
},
{ -- paste an image from the clipboard or drag-and-drop
'HakonHarnes/img-clip.nvim',
event = 'BufEnter',
ft = { 'markdown', 'quarto', 'latex' },
opts = {
default = {
dir_path = 'img',
},
filetypes = {
markdown = {
url_encode_path = true,
template = '![$CURSOR]($FILE_PATH)',
drag_and_drop = {
download_images = false,
},
},
quarto = {
url_encode_path = true,
template = '![$CURSOR]($FILE_PATH)',
drag_and_drop = {
download_images = false,
},
},
},
},
config = function(_, opts)
require('img-clip').setup(opts)
vim.keymap.set('n', '<leader>ii', ':PasteImage<cr>', { desc = 'insert [i]mage from clipboard' })
end,
},
{ -- preview equations
'jbyuki/nabla.nvim',
keys = {
{ '<leader>qm', ':lua require"nabla".toggle_virt()<cr>', desc = 'toggle [m]ath equations' },
},
},
{
'benlubas/molten-nvim',
enabled = false,
build = ':UpdateRemotePlugins',
init = function()
vim.g.molten_image_provider = 'image.nvim'
vim.g.molten_output_win_max_height = 20
vim.g.molten_auto_open_output = false
end,
keys = {
{ '<leader>mi', ':MoltenInit<cr>', desc = '[m]olten [i]nit' },
{
'<leader>mv',
':<C-u>MoltenEvaluateVisual<cr>',
mode = 'v',
desc = 'molten eval visual',
},
{ '<leader>mr', ':MoltenReevaluateCell<cr>', desc = 'molten re-eval cell' },
},
},
}