refactor(telekasten): use better keybindings

nixos
Moritz Böhme 2023-07-23 12:27:18 +02:00
parent b6b76a0e7d
commit 70a8d999bd
Signed by: moritz
GPG Key ID: 970C6E89EB0547A9
2 changed files with 29 additions and 22 deletions

View File

@ -269,33 +269,13 @@ with builtins;
plugin = telekasten-nvim;
dependencies = [
{ plugin = telescope-nvim; }
{ plugin = which-key-nvim; }
];
cmd = [ "Telekasten" ];
keys = [
{ key = "<leader>z"; cmd = "<cmd>Telekasten<cr>"; desc = "zettelkasten"; }
];
conf = ''
require("telekasten").setup({
home = vim.fn.expand("~/Nextcloud/Notes/zettelkasten"),
auto_set_filetype = false,
image_subdir = "assets",
})
vim.api.nvim_create_autocmd({ "BufReadPost", "BufNewFile" }, {
pattern = "*/zettelkasten/*",
callback = function(event)
vim.api.nvim_buf_set_keymap(0, "n", "<CR>", "", {
callback = function()
local current_word = vim.fn.expand("<cWORD>")
if vim.fn.match(current_word, "[[") == 0 then
require("telekasten").follow_link()
else
require("telekasten").toggle_todo()
end
end,
})
end,
})
'';
conf = builtins.readFile ./zettelkasten-nvim.lua;
}
{
plugin = markdown-preview-nvim;

View File

@ -0,0 +1,27 @@
local telekasten = require("telekasten")
telekasten.setup({
home = vim.fn.expand("~/Nextcloud/Notes/zettelkasten"),
auto_set_filetype = false,
image_subdir = "assets",
})
vim.api.nvim_create_autocmd({ "BufReadPost", "BufNewFile" }, {
pattern = "*/zettelkasten/*",
callback = function(_)
require("which-key").register({
g = {
f = { telekasten.follow_link, "Follow link" },
r = { telekasten.show_backlinks, "Show backlinks" },
},
["<leader>"] = {
f = {
f = { telekasten.find_notes, "Find note" },
n = { telekasten.new_note, "New note" },
},
s = {
g = { telekasten.search_note, "Grep notes" },
},
},
}, { buffer = vim.fn.bufnr("%") })
end,
})