1
Fork 0

Jupytext and harpoon setup!

This commit is contained in:
Matei Adriel 2023-03-31 18:54:44 +02:00
parent 9d7fd2277a
commit 26e2bee4e0
No known key found for this signature in database
6 changed files with 88 additions and 34 deletions

View file

@ -17,6 +17,7 @@
"firenvim": { "branch": "master", "commit": "12003d9727bc5074ccb405b3d80e691c72d4859b" },
"gitlinker.nvim": { "branch": "master", "commit": "cc59f732f3d043b626c8702cb725c82e54d35c25" },
"glow.nvim": { "branch": "main", "commit": "5a8ccfb1876b1b2e29ea32c63221be6df45870d1" },
"harpoon": { "branch": "master", "commit": "f7040fd0c44e7a4010369136547de5604b9c22a1" },
"hydra.nvim": { "branch": "master", "commit": "3ced42c0b6a6c85583ff0f221635a7f4c1ab0dd0" },
"idris2-nvim": { "branch": "main", "commit": "dd850c1c67bcacd2395121b0898374fe9cdd228f" },
"inc-rename.nvim": { "branch": "main", "commit": "21c23c379342a731a0c90f226601ec0434627b26" },
@ -57,6 +58,7 @@
"telescope-file-browser.nvim": { "branch": "master", "commit": "94fe37a1ea217dd2f90d91222bc1531521146ac3" },
"telescope-fzf-native.nvim": { "branch": "main", "commit": "580b6c48651cabb63455e97d7e131ed557b8c7e2" },
"telescope.nvim": { "branch": "master", "commit": "e960efa60e97df58e089b00270f09d60f27202c8" },
"undotree": { "branch": "master", "commit": "485f01efde4e22cb1ce547b9e8c9238f36566f21" },
"venn.nvim": { "branch": "main", "commit": "c114563960b8fb1197695d42798d1f3e7190b798" },
"vim-abolish": { "branch": "master", "commit": "880a562ff9176773897930b5a26a496f68e5a985" },
"vim-sleuth": { "branch": "master", "commit": "1cc4557420f215d02c4d2645a748a816c220e99b" },

View file

@ -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 = " "

View 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

View file

@ -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,
},
}

View 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

View file

@ -12,6 +12,9 @@ function M.config()
component_separators = { left = "", right = "" },
section_separators = { left = "", right = "" },
theme = "auto",
disabled_filetypes = {
"undotree"
}
},
sections = {
lualine_a = { "branch" },