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:
parent
8d9b67cb04
commit
5d8177b1b5
4 changed files with 92 additions and 67 deletions
|
@ -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
|
-- Start quarto session
|
||||||
local startsession = function(file, args)
|
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()
|
local path = require("util").get_python_venv()
|
||||||
vim.g["python3_host_prog"] = path
|
vim.g["python3_host_prog"] = path
|
||||||
|
|
||||||
|
@ -16,7 +28,6 @@ local startsession = function(file, args)
|
||||||
on_stdout = function(_)
|
on_stdout = function(_)
|
||||||
if not once then
|
if not once then
|
||||||
vim.cmd("MoltenInit " .. file)
|
vim.cmd("MoltenInit " .. file)
|
||||||
-- vim.cmd("JupyterAttach " .. file)
|
|
||||||
end
|
end
|
||||||
once = true
|
once = true
|
||||||
end,
|
end,
|
||||||
|
@ -31,39 +42,63 @@ vim.api.nvim_create_user_command("JupyterStart", function()
|
||||||
end, {})
|
end, {})
|
||||||
|
|
||||||
local map = vim.keymap.set
|
local map = vim.keymap.set
|
||||||
-- filetype mappings
|
|
||||||
-- PLUGIN: magma-nvim
|
local function molten_mappings_set()
|
||||||
-- Operate jupyter notebooks from within vim
|
-- Operate jupyter notebooks from within vim
|
||||||
map("n", "<localleader>cc", ":MoltenEvaluateLine<cr>", { silent = true })
|
map("n", "<localleader>cc", ":MoltenEvaluateLine<cr>", { silent = true })
|
||||||
map(
|
map(
|
||||||
"n",
|
"n",
|
||||||
"<localleader>C",
|
"<localleader>C",
|
||||||
"?^```{<cr>jV/```<cr>k:<C-u>MoltenEvaluateVisual<cr>",
|
require("quarto.runner").run_cell,
|
||||||
{ silent = true, desc = "Evaluate current code cell" }
|
{ silent = true, desc = "Evaluate current code cell" }
|
||||||
)
|
)
|
||||||
map("x", "<localleader>c", ":<C-u>MoltenEvaluateVisual<cr>", { silent = true })
|
map("x", "<localleader>c", ":<C-u>MoltenEvaluateVisual<cr>", { silent = true })
|
||||||
map(
|
map(
|
||||||
"n",
|
"n",
|
||||||
"<localleader>c",
|
"<localleader>c",
|
||||||
"nvim_exec('MoltenEvaluateOperator', v:true)",
|
"nvim_exec('MoltenEvaluateOperator', v:true)",
|
||||||
{ expr = true, silent = true, desc = "+code-evaluation" }
|
{ expr = true, silent = true, desc = "+code-evaluation" }
|
||||||
)
|
)
|
||||||
map("n", "<localleader>cr", ":MoltenReevaluateCell<cr>", { silent = true })
|
map("n", "<localleader>cr", ":MoltenReevaluateCell<cr>", { silent = true })
|
||||||
map("n", "<localleader>cu", ":MoltenShowOutput<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>cU", ":noautocmd :MoltenEnterOutput<cr>", { silent = true, desc = "Molten enter output" })
|
||||||
map("n", "<localleader>cd", ":MoltenDelete<cr>", { silent = true })
|
map("n", "<localleader>cd", ":MoltenDelete<cr>", { silent = true })
|
||||||
map("n", "<localleader>cs", ":MoltenInterrupt<cr>")
|
map("n", "<localleader>ci", ":MoltenInterrupt<cr>")
|
||||||
map("n", "<localleader>ci", ":MoltenInit ")
|
map("n", "<localleader>cI", ":MoltenInfo<cr>")
|
||||||
map("n", "<localleader>cD", ":MoltenDeinit<cr>")
|
map("n", "<localleader>cN", ":MoltenInit ")
|
||||||
map("n", "<localleader>cR", ":MoltenRestart<cr>")
|
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
|
-- jump to beginning of previous/ next cell code
|
||||||
map("n", "]c", "/^```{<cr>}:nohl<cr>", { desc = "Next quarto cell" })
|
map("n", "]c", "/^```{<cr>}:nohl<cr>", { desc = "Next quarto cell" })
|
||||||
map("n", "[c", "?^```<cr>n}:nohl<cr>", { desc = "Previous quarto cell" })
|
map("n", "[c", "?^```<cr>n}:nohl<cr>", { desc = "Previous quarto cell" })
|
||||||
-- insert cell header above/below
|
-- 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 below" })
|
||||||
map("n", "<localleader>cO", "O```{python}<cr><cr>```<esc>k", { desc = "Insert quarto cell above" })
|
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
|
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_prev()<cr>", { buffer = bufnr, desc = "Previous diagnostic" })
|
||||||
map("n", "]d", "<cmd>lua vim.diagnostic.goto_next()<cr>", { buffer = bufnr, desc = "Next 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" })
|
map("n", "gt", "<cmd>lua vim.lsp.buf.type_definition()<cr>", { buffer = bufnr, desc = "Type definition" })
|
||||||
|
|
||||||
if vim.b["sessionfile"] == nil then
|
if vim.b["sessionfile"] == nil then
|
||||||
vim.b["sessionfile"] = vim.fn.tempname() .. ".json"
|
local path = default_buffer_session()
|
||||||
startsession(vim.b["sessionfile"])
|
vim.b["sessionfile"] = path
|
||||||
|
vim.schedule_wrap(startsession(path))
|
||||||
end
|
end
|
||||||
|
|
|
@ -32,7 +32,6 @@
|
||||||
"gitsigns.nvim": { "branch": "main", "commit": "6ef8c54fb526bf3a0bc4efb0b2fe8e6d9a7daed2" },
|
"gitsigns.nvim": { "branch": "main", "commit": "6ef8c54fb526bf3a0bc4efb0b2fe8e6d9a7daed2" },
|
||||||
"headlines.nvim": { "branch": "master", "commit": "e3d7bfdf40e41a020d966d35f8b48d75b90367d2" },
|
"headlines.nvim": { "branch": "master", "commit": "e3d7bfdf40e41a020d966d35f8b48d75b90367d2" },
|
||||||
"image.nvim": { "branch": "master", "commit": "c40215d7d7d1d8c823ee9a77be1a894d5c8df41b" },
|
"image.nvim": { "branch": "master", "commit": "c40215d7d7d1d8c823ee9a77be1a894d5c8df41b" },
|
||||||
"jupyter-kernel.nvim": { "branch": "main", "commit": "5772fa8932f2c73736a777082656f1bfe0287076" },
|
|
||||||
"lazy.nvim": { "branch": "main", "commit": "96584866b9c5e998cbae300594d0ccfd0c464627" },
|
"lazy.nvim": { "branch": "main", "commit": "96584866b9c5e998cbae300594d0ccfd0c464627" },
|
||||||
"lightspeed.nvim": { "branch": "main", "commit": "fcc72d8a4d5f4ebba62d8a3a0660f88f1b5c3b05" },
|
"lightspeed.nvim": { "branch": "main", "commit": "fcc72d8a4d5f4ebba62d8a3a0660f88f1b5c3b05" },
|
||||||
"lsp-setup.nvim": { "branch": "main", "commit": "7276e54faf4af909b6ea171975fd4179ebe65cec" },
|
"lsp-setup.nvim": { "branch": "main", "commit": "7276e54faf4af909b6ea171975fd4179ebe65cec" },
|
||||||
|
|
|
@ -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("i", "<c-z>", "<C-G>u<Esc>[s1z=`]a<C-G>u")
|
||||||
map("n", "<localleader>z", "ms[s1z=`s", { desc = "Fix last spell error" })
|
map("n", "<localleader>z", "ms[s1z=`s", { desc = "Fix last spell error" })
|
||||||
|
|
||||||
|
prefix({ ["<leader>s"] = { name = "+show" } })
|
||||||
-- Set vim to distraction free prose mode
|
-- Set vim to distraction free prose mode
|
||||||
map("n", "<leader>sz", ":ZenMode<cr>", { silent = true })
|
map("n", "<leader>sz", ":ZenMode<cr>", { silent = true })
|
||||||
-- PLUGIN: mini.nvim
|
-- PLUGIN: mini.nvim
|
||||||
prefix({ ["<leader>s"] = { name = "+show" } })
|
map("n", "<leader>sm", ":lua MiniMap.toggle()<cr>", { silent = true, desc = "minimap" })
|
||||||
map("n", "<leader>sm", ":lua MiniMap.toggle()<cr>", { silent = true, desc = "toggle minimap" })
|
map("n", "<leader>ss", ":lua MiniStarter.open()<cr>", { desc = "startpage" })
|
||||||
map("n", "<leader>ss", ":lua MiniStarter.open()<cr>", { desc = "show startpage" })
|
|
||||||
|
|
||||||
-- PLUGIN: symbols-outline.nvim
|
-- PLUGIN: symbols-outline.nvim
|
||||||
map("n", "<leader>so", "<cmd>AerialToggle<cr>", { silent = true, desc = "toggle symbol outline" })
|
map("n", "<leader>so", "<cmd>AerialNavToggle<cr>", { silent = true, desc = "symbol navigator" })
|
||||||
map("n", "<leader>sn", "<cmd>AerialNavToggle<cr>", { silent = true, desc = "toggle 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
|
-- 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 workspace_diagnostics<cr>", { silent = true, desc = "diagnostics workspace" })
|
||||||
map("n", "<leader>sD", "<cmd>Trouble document_diagnostics<cr>", { silent = true, desc = "diagnostics document" })
|
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
|
-- PLUGIN: toggleterm.nvim
|
||||||
-- create a lazygit or python window, set up in toggleterm settings
|
-- 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
|
-- 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>sg", ":Lazygit<cr>")
|
||||||
map("n", "<leader>tg", ":Lazygit<cr>")
|
map("n", "<leader>sG", ":Lazygit!<cr>")
|
||||||
map("n", "<leader>tG", ":Lazygit!<cr>")
|
map("n", "<leader>sp", ":Pythonterm<cr>")
|
||||||
map("n", "<leader>tp", ":Pythonterm<cr>")
|
map("n", "<leader>sP", ":Pythonterm!<cr>")
|
||||||
map("n", "<leader>tP", ":Pythonterm!<cr>")
|
|
||||||
|
|
||||||
prefix({ ["<localleader>s"] = { name = "+set" } })
|
prefix({ ["<localleader>s"] = { name = "+set" } })
|
||||||
-- PLUGIN: wrapping.nvim
|
-- PLUGIN: wrapping.nvim
|
||||||
|
|
|
@ -12,31 +12,20 @@ return {
|
||||||
require("quarto").setup({
|
require("quarto").setup({
|
||||||
lspFeatures = {
|
lspFeatures = {
|
||||||
enabled = true,
|
enabled = true,
|
||||||
languages = { "r", "python", "julia" },
|
languages = { "r", "python", "julia", "bash" },
|
||||||
diagnostics = { enabled = true, triggers = { "BufWrite" } },
|
diagnostics = { enabled = true, triggers = { "BufWritePost" } },
|
||||||
completion = { enabled = true },
|
completion = { enabled = true },
|
||||||
},
|
},
|
||||||
|
codeRunner = {
|
||||||
|
enabled = true,
|
||||||
|
default_method = "molten",
|
||||||
|
},
|
||||||
})
|
})
|
||||||
end,
|
end,
|
||||||
lazy = false,
|
lazy = false,
|
||||||
ft = "quarto",
|
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
|
-- REPL work
|
||||||
{
|
{
|
||||||
"3rd/image.nvim",
|
"3rd/image.nvim",
|
||||||
|
@ -62,7 +51,7 @@ return {
|
||||||
"benlubas/molten-nvim",
|
"benlubas/molten-nvim",
|
||||||
build = ":UpdateRemotePlugins",
|
build = ":UpdateRemotePlugins",
|
||||||
config = function()
|
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
|
vim.g.molten_auto_open_output = false
|
||||||
end,
|
end,
|
||||||
cmd = {
|
cmd = {
|
||||||
|
|
Loading…
Reference in a new issue