Jupytext and harpoon setup!
This commit is contained in:
parent
9d7fd2277a
commit
26e2bee4e0
6 changed files with 88 additions and 34 deletions
dotfiles/neovim/lua/my
|
@ -35,6 +35,8 @@ function M.setup()
|
|||
vim.opt.wildmode = { "list", "longest" } -- Command-line completion mode
|
||||
vim.opt.completeopt = { "menu", "menuone", "noselect" }
|
||||
|
||||
vim.opt.undofile = true -- persist undos!!
|
||||
|
||||
-- Set leader
|
||||
vim.g.mapleader = " "
|
||||
|
||||
|
|
30
dotfiles/neovim/lua/my/plugins/harpoon.lua
Normal file
30
dotfiles/neovim/lua/my/plugins/harpoon.lua
Normal file
|
@ -0,0 +1,30 @@
|
|||
local M = {
|
||||
"ThePrimeagen/harpoon",
|
||||
}
|
||||
|
||||
local function bindHarpoon(key, index)
|
||||
vim.keymap.set("n", "<C-s>" .. key, function()
|
||||
require("harpoon.ui").nav_file(index)
|
||||
end, { desc = "Harpoon file " .. index })
|
||||
end
|
||||
|
||||
function M.init()
|
||||
vim.keymap.set("n", "<leader>h", function()
|
||||
require("harpoon.mark").add_file()
|
||||
end, { desc = "Add file to [h]arpoon" })
|
||||
vim.keymap.set("n", "<C-a>", function()
|
||||
require("harpoon.ui").toggle_quick_menu()
|
||||
end, { desc = "Toggle harpoon quickmenu" })
|
||||
|
||||
bindHarpoon("q", 1)
|
||||
bindHarpoon("w", 2)
|
||||
bindHarpoon("e", 3)
|
||||
bindHarpoon("r", 4)
|
||||
bindHarpoon("a", 5)
|
||||
bindHarpoon("s", 6)
|
||||
bindHarpoon("d", 7)
|
||||
bindHarpoon("f", 8)
|
||||
bindHarpoon("z", 9)
|
||||
end
|
||||
|
||||
return M
|
|
@ -215,41 +215,15 @@ return {
|
|||
},
|
||||
|
||||
{
|
||||
"goerz/jupytext.vim",
|
||||
lazy = false, -- Otherwise I can't get this to work with nvim *.ipynb
|
||||
cond = env.vscode.not_active(),
|
||||
config = function()
|
||||
-- Use %% as cell delimiter
|
||||
vim.g.jupytext_fmt = "py:percent"
|
||||
-- vim.opt.foldmarker = "%%,%%"
|
||||
end,
|
||||
"mbbill/undotree",
|
||||
cmd = "UndotreeToggle",
|
||||
init = function()
|
||||
vim.cmd([[
|
||||
function GetJupytextFold(linenum)
|
||||
if getline(a:linenum) =~ "^#\\s%%"
|
||||
" start fold
|
||||
return ">1"
|
||||
elseif getline(a:linenum + 1) =~ "^#\\s%%"
|
||||
return "<1"
|
||||
else
|
||||
return "-1"
|
||||
endif
|
||||
endfunction
|
||||
]])
|
||||
|
||||
-- Set the correct foldexpr
|
||||
vim.api.nvim_create_autocmd("BufEnter", {
|
||||
pattern = { "*.ipynb" },
|
||||
group = vim.api.nvim_create_augroup("JupytextFoldExpr", {}),
|
||||
callback = function()
|
||||
vim.cmd([[
|
||||
setlocal foldexpr=GetJupytextFold(v:lnum)
|
||||
setlocal foldmethod=expr
|
||||
" Deletes and pastes all text. Used to refresh folds.
|
||||
:norm ggVGdpggdd
|
||||
]])
|
||||
end,
|
||||
})
|
||||
vim.keymap.set(
|
||||
"n",
|
||||
"<leader>u",
|
||||
"<cmd>UndotreeToggle<cr>",
|
||||
{ desc = "[U]ndo tree" }
|
||||
)
|
||||
end,
|
||||
},
|
||||
}
|
||||
|
|
43
dotfiles/neovim/lua/my/plugins/jupytext.lua
Normal file
43
dotfiles/neovim/lua/my/plugins/jupytext.lua
Normal file
|
@ -0,0 +1,43 @@
|
|||
local env = require("my.helpers.env")
|
||||
|
||||
local M = {
|
||||
"goerz/jupytext.vim",
|
||||
lazy = false, -- Otherwise I can't get this to work with nvim *.ipynb
|
||||
cond = env.vscode.not_active(),
|
||||
}
|
||||
|
||||
function M.config()
|
||||
-- Use %% as cell delimiter
|
||||
vim.g.jupytext_fmt = "py:percent"
|
||||
end
|
||||
|
||||
function M.init()
|
||||
vim.cmd([[
|
||||
function GetJupytextFold(linenum)
|
||||
if getline(a:linenum) =~ "^#\\s%%"
|
||||
" start fold
|
||||
return ">1"
|
||||
elseif getline(a:linenum + 1) =~ "^#\\s%%"
|
||||
return "<1"
|
||||
else
|
||||
return "-1"
|
||||
endif
|
||||
endfunction
|
||||
]])
|
||||
|
||||
-- Set the correct foldexpr
|
||||
vim.api.nvim_create_autocmd("BufEnter", {
|
||||
pattern = { "*.ipynb" },
|
||||
group = vim.api.nvim_create_augroup("JupytextFoldExpr", {}),
|
||||
callback = function()
|
||||
vim.cmd([[
|
||||
setlocal foldexpr=GetJupytextFold(v:lnum)
|
||||
setlocal foldmethod=expr
|
||||
" Deletes and pastes all text. Used to refresh folds.
|
||||
:norm ggVGdpggdd
|
||||
]])
|
||||
end,
|
||||
})
|
||||
end
|
||||
|
||||
return M
|
|
@ -12,6 +12,9 @@ function M.config()
|
|||
component_separators = { left = "", right = "" },
|
||||
section_separators = { left = "", right = "" },
|
||||
theme = "auto",
|
||||
disabled_filetypes = {
|
||||
"undotree"
|
||||
}
|
||||
},
|
||||
sections = {
|
||||
lualine_a = { "branch" },
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue