diff --git a/lua/custom/plugins/quarto.lua b/lua/custom/plugins/quarto.lua index 508488d1..2f8d4e5c 100644 --- a/lua/custom/plugins/quarto.lua +++ b/lua/custom/plugins/quarto.lua @@ -1,162 +1,9 @@ return { - - { -- requires plugins in lua/plugins/treesitter.lua and lua/plugins/lsp.lua - -- for complete functionality (language features) - 'quarto-dev/quarto-nvim', - dev = false, - opts = { - lspFeatures = { - enabled = true, - chunks = 'curly', - }, - codeRunner = { - enabled = true, - default_method = 'slime', - }, - }, - dependencies = { - -- for language features in code cells - -- configured in lua/plugins/lsp.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', 'cm', mark_terminal, { desc = '[m]ark terminal' }) - vim.keymap.set('n', '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', 'ii', ':PasteImage', { desc = 'insert [i]mage from clipboard' }) - end, - }, - - { -- preview equations - 'jbyuki/nabla.nvim', - keys = { - { 'qm', ':lua require"nabla".toggle_virt()', desc = 'toggle [m]ath equations' }, - }, - }, - { - 'benlubas/molten-nvim', - dev = false, - enabled = true, - version = '^1.0.0', -- use version <2.0.0 to avoid breaking changes - 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 = true - vim.g.molten_auto_open_html_in_browser = true - vim.g.molten_tick_rate = 200 - end, - config = function() - local init = function() - local quarto_cfg = require('quarto.config').config - quarto_cfg.codeRunner.default_method = 'molten' - vim.cmd [[MoltenInit]] - end - local deinit = function() - local quarto_cfg = require('quarto.config').config - quarto_cfg.codeRunner.default_method = 'slime' - vim.cmd [[MoltenDeinit]] - end - vim.keymap.set('n', 'mi', init, { silent = true, desc = 'Initialize molten' }) - vim.keymap.set('n', 'md', deinit, { silent = true, desc = 'Stop molten' }) - vim.keymap.set('n', 'mp', ':MoltenImagePopup', { silent = true, desc = 'molten image popup' }) - vim.keymap.set('n', 'mb', ':MoltenOpenInBrowser', { silent = true, desc = 'molten open in browser' }) - vim.keymap.set('n', 'mh', ':MoltenHideOutput', { silent = true, desc = 'hide output' }) - vim.keymap.set('n', 'ms', ':noautocmd MoltenEnterOutput', { silent = true, desc = 'show/enter output' }) - end, + 'quarto-dev/quarto-nvim', + dependencies = { + 'jmbuhr/otter.nvim', + 'nvim-treesitter/nvim-treesitter', + }, }, } diff --git a/lua/keymaps.lua b/lua/keymaps.lua index 8c279233..664de710 100644 --- a/lua/keymaps.lua +++ b/lua/keymaps.lua @@ -51,4 +51,6 @@ vim.api.nvim_create_autocmd('TextYankPost', { end, }) +-- Quarto + -- vim: ts=2 sts=2 sw=2 et diff --git a/lua/kickstart/plugins/cmp.lua b/lua/kickstart/plugins/cmp.lua index d5248488..fb5e4cf2 100644 --- a/lua/kickstart/plugins/cmp.lua +++ b/lua/kickstart/plugins/cmp.lua @@ -67,11 +67,11 @@ return { -- Accept ([y]es) the completion. -- This will auto-import if your LSP supports it. -- This will expand snippets if the LSP sent a snippet. - [''] = cmp.mapping.confirm { select = true }, + -- [''] = cmp.mapping.confirm { select = true }, -- If you prefer more traditional completion keymaps, -- you can uncomment the following lines - --[''] = cmp.mapping.confirm { select = true }, + [''] = cmp.mapping.confirm { select = true }, --[''] = cmp.mapping.select_next_item(), --[''] = cmp.mapping.select_prev_item(), diff --git a/lua/kickstart/plugins/which-key.lua b/lua/kickstart/plugins/which-key.lua index f27fb3b9..82668342 100644 --- a/lua/kickstart/plugins/which-key.lua +++ b/lua/kickstart/plugins/which-key.lua @@ -66,6 +66,14 @@ return { { 'w', group = '[W]orkspace' }, { 't', group = '[T]oggle' }, { 'h', group = 'Git [H]unk', mode = { 'n', 'v' } }, + -- Quarto + { 'q', group = '[q]uarto' }, + { 'qh', ':QuartoHelp ', desc = '[h]elp' }, + { 'qp', ":lua require'quarto'.quartoPreview()", desc = '[p]review' }, + -- Vim + { 'v', group = '[v]im' }, + { 'vc', ':Telescope colorscheme', desc = '[c]olortheme' }, + { 'vt', toggle_light_dark_theme, desc = '[t]oggle light/dark theme' }, }, }, },