nvim: Update +show mode mappings and descriptions

Mappings preceded by <leader>s 'show' something so removed a lot of the 'toggle'
wording from their descriptions.

Subsumed the toggleterm toggles under this menu since they 'show' a term window
(lazygit or ipython).
Changed Aerial mappings to show navigator by default (`<leader>so`) and the
sidebar outline only on capital version (`<leader>sO`) since this mapping is
used less often.

Removed broken molten-image setup.
This commit is contained in:
Marty Oehme 2023-12-08 13:42:20 +01:00
parent 8d9b67cb04
commit 5d8177b1b5
Signed by: Marty
GPG key ID: EDBF2ED917B2EF6A
4 changed files with 92 additions and 67 deletions

View file

@ -1,6 +1,18 @@
local default_buffer_session = function()
local buffer_path = vim.api.nvim_buf_get_name(0) or vim.fn.tempname()
local temp_path = vim.fn.stdpath("run") .. "/molten-sessions" .. buffer_path .. ".json"
local dir = vim.fn.fnamemodify(temp_path, ":p:h")
if vim.fn.getftype(dir) ~= "dir" then
vim.fn.mkdir(dir, "p")
end
return temp_path
end
-- Start quarto session
local startsession = function(file, args)
file = file or "/tmp/jupyter-magma-session.json"
file = file or default_buffer_session()
local path = require("util").get_python_venv()
vim.g["python3_host_prog"] = path
@ -16,7 +28,6 @@ local startsession = function(file, args)
on_stdout = function(_)
if not once then
vim.cmd("MoltenInit " .. file)
-- vim.cmd("JupyterAttach " .. file)
end
once = true
end,
@ -31,14 +42,14 @@ vim.api.nvim_create_user_command("JupyterStart", function()
end, {})
local map = vim.keymap.set
-- filetype mappings
-- PLUGIN: magma-nvim
local function molten_mappings_set()
-- Operate jupyter notebooks from within vim
map("n", "<localleader>cc", ":MoltenEvaluateLine<cr>", { silent = true })
map(
"n",
"<localleader>C",
"?^```{<cr>jV/```<cr>k:<C-u>MoltenEvaluateVisual<cr>",
require("quarto.runner").run_cell,
{ silent = true, desc = "Evaluate current code cell" }
)
map("x", "<localleader>c", ":<C-u>MoltenEvaluateVisual<cr>", { silent = true })
@ -52,10 +63,29 @@ map("n", "<localleader>cr", ":MoltenReevaluateCell<cr>", { silent = true })
map("n", "<localleader>cu", ":MoltenShowOutput<cr>", { silent = true })
map("n", "<localleader>cU", ":noautocmd :MoltenEnterOutput<cr>", { silent = true, desc = "Molten enter output" })
map("n", "<localleader>cd", ":MoltenDelete<cr>", { silent = true })
map("n", "<localleader>cs", ":MoltenInterrupt<cr>")
map("n", "<localleader>ci", ":MoltenInit ")
map("n", "<localleader>ci", ":MoltenInterrupt<cr>")
map("n", "<localleader>cI", ":MoltenInfo<cr>")
map("n", "<localleader>cN", ":MoltenInit ")
map("n", "<localleader>cD", ":MoltenDeinit<cr>")
map("n", "<localleader>cR", ":MoltenRestart<cr>")
map(
"n",
"<localleader>cA",
require("quarto.runner").run_all,
{ silent = true, desc = "Evaluate all code cells" }
)
map(
"n",
"<localleader>ca",
require("quarto.runner").run_above,
{ silent = true, desc = "Evaluate cells above current" }
)
map(
"n",
"<localleader>cb",
require("quarto.runner").run_below,
{ silent = true, desc = "Evaluate cells below current" }
)
-- jump to beginning of previous/ next cell code
map("n", "]c", "/^```{<cr>}:nohl<cr>", { desc = "Next quarto cell" })
@ -63,7 +93,12 @@ map("n", "[c", "?^```<cr>n}:nohl<cr>", { desc = "Previous quarto cell" })
-- insert cell header above/below
map("n", "<localleader>co", "o```{python}<cr><cr>```<esc>k", { desc = "Insert quarto cell below" })
map("n", "<localleader>cO", "O```{python}<cr><cr>```<esc>k", { desc = "Insert quarto cell above" })
end
vim.api.nvim_create_autocmd("User", {
pattern = "MoltenInitPost",
callback = molten_mappings_set,
})
local bufnr = 0
map("n", "[d", "<cmd>lua vim.diagnostic.goto_prev()<cr>", { buffer = bufnr, desc = "Previous diagnostic" })
map("n", "]d", "<cmd>lua vim.diagnostic.goto_next()<cr>", { buffer = bufnr, desc = "Next diagnostic" })
@ -97,6 +132,7 @@ map("n", "gI", "<cmd>lua vim.lsp.buf.implementation()<cr>", { buffer = bufnr, de
map("n", "gt", "<cmd>lua vim.lsp.buf.type_definition()<cr>", { buffer = bufnr, desc = "Type definition" })
if vim.b["sessionfile"] == nil then
vim.b["sessionfile"] = vim.fn.tempname() .. ".json"
startsession(vim.b["sessionfile"])
local path = default_buffer_session()
vim.b["sessionfile"] = path
vim.schedule_wrap(startsession(path))
end

View file

@ -32,7 +32,6 @@
"gitsigns.nvim": { "branch": "main", "commit": "6ef8c54fb526bf3a0bc4efb0b2fe8e6d9a7daed2" },
"headlines.nvim": { "branch": "master", "commit": "e3d7bfdf40e41a020d966d35f8b48d75b90367d2" },
"image.nvim": { "branch": "master", "commit": "c40215d7d7d1d8c823ee9a77be1a894d5c8df41b" },
"jupyter-kernel.nvim": { "branch": "main", "commit": "5772fa8932f2c73736a777082656f1bfe0287076" },
"lazy.nvim": { "branch": "main", "commit": "96584866b9c5e998cbae300594d0ccfd0c464627" },
"lightspeed.nvim": { "branch": "main", "commit": "fcc72d8a4d5f4ebba62d8a3a0660f88f1b5c3b05" },
"lsp-setup.nvim": { "branch": "main", "commit": "7276e54faf4af909b6ea171975fd4179ebe65cec" },

View file

@ -195,19 +195,21 @@ map("n", "<localleader>ZD", ":setlocal spell! spelllang=de_de<cr>", { desc = "To
map("i", "<c-z>", "<C-G>u<Esc>[s1z=`]a<C-G>u")
map("n", "<localleader>z", "ms[s1z=`s", { desc = "Fix last spell error" })
prefix({ ["<leader>s"] = { name = "+show" } })
-- Set vim to distraction free prose mode
map("n", "<leader>sz", ":ZenMode<cr>", { silent = true })
-- PLUGIN: mini.nvim
prefix({ ["<leader>s"] = { name = "+show" } })
map("n", "<leader>sm", ":lua MiniMap.toggle()<cr>", { silent = true, desc = "toggle minimap" })
map("n", "<leader>ss", ":lua MiniStarter.open()<cr>", { desc = "show startpage" })
map("n", "<leader>sm", ":lua MiniMap.toggle()<cr>", { silent = true, desc = "minimap" })
map("n", "<leader>ss", ":lua MiniStarter.open()<cr>", { desc = "startpage" })
-- PLUGIN: symbols-outline.nvim
map("n", "<leader>so", "<cmd>AerialToggle<cr>", { silent = true, desc = "toggle symbol outline" })
map("n", "<leader>sn", "<cmd>AerialNavToggle<cr>", { silent = true, desc = "toggle symbol navigator" })
map("n", "<leader>so", "<cmd>AerialNavToggle<cr>", { silent = true, desc = "symbol navigator" })
map("n", "<leader>sO", "<cmd>AerialToggle<cr>", { silent = true, desc = "symbol outline" })
-- PLUGIN: nvim-tree
map("n", "<leader>se", "<cmd>NvimTreeToggle<cr>", { silent = true, desc = "filetree" })
-- PLUGIN: nvim-tree
map("n", "<leader>se", "<cmd>NvimTreeToggle<cr>", { silent = true, desc = "toggle filetree" })
map("n", "<leader>sd", "<cmd>Trouble workspace_diagnostics<cr>", { silent = true, desc = "diagnostics workspace" })
map("n", "<leader>sD", "<cmd>Trouble document_diagnostics<cr>", { silent = true, desc = "diagnostics document" })
@ -257,11 +259,10 @@ map("v", "<localleader>nf", ":ZkMatch<cr>", { desc = "find note from selection"
-- PLUGIN: toggleterm.nvim
-- create a lazygit or python window, set up in toggleterm settings
-- TODO create ability to go into python environment when in poetry venv and/or euporie/jupyter notebook
prefix({ ["<localleader>t"] = { name = "+term" } })
map("n", "<leader>tg", ":Lazygit<cr>")
map("n", "<leader>tG", ":Lazygit!<cr>")
map("n", "<leader>tp", ":Pythonterm<cr>")
map("n", "<leader>tP", ":Pythonterm!<cr>")
map("n", "<leader>sg", ":Lazygit<cr>")
map("n", "<leader>sG", ":Lazygit!<cr>")
map("n", "<leader>sp", ":Pythonterm<cr>")
map("n", "<leader>sP", ":Pythonterm!<cr>")
prefix({ ["<localleader>s"] = { name = "+set" } })
-- PLUGIN: wrapping.nvim

View file

@ -12,31 +12,20 @@ return {
require("quarto").setup({
lspFeatures = {
enabled = true,
languages = { "r", "python", "julia" },
diagnostics = { enabled = true, triggers = { "BufWrite" } },
languages = { "r", "python", "julia", "bash" },
diagnostics = { enabled = true, triggers = { "BufWritePost" } },
completion = { enabled = true },
},
codeRunner = {
enabled = true,
default_method = "molten",
},
})
end,
lazy = false,
ft = "quarto",
},
{
"lkhphuc/jupyter-kernel.nvim",
config = true,
cmd = "JupyterAttach",
build = ":UpdateRemotePlugins",
keys = {
{
"<localleader>ck",
"<Cmd>JupyterInspect<CR>",
desc = "Inspect object in kernel",
},
},
lazy = false,
},
-- REPL work
{
"3rd/image.nvim",
@ -62,7 +51,7 @@ return {
"benlubas/molten-nvim",
build = ":UpdateRemotePlugins",
config = function()
vim.g.molten_image_provider = "image_nvim"
vim.g.molten_image_provider = "none" -- image integration does NOT work currently :-(
vim.g.molten_auto_open_output = false
end,
cmd = {