Integration with Vim #11
Replies: 7 comments 39 replies
-
Brilliant move! Thanks for wanting to chat through this. I've long been following @evantravers' setup for note-taking, in all it's various permutations. I'm still discovering what works best for me for my day to day. I fear that I might be trying to force one tool to handle multiple goals. For instance:
I use Drafts.app on mac and iOS for quick entry of things to then use an action @evantravers wrote to convert the draft (original draft is archived in the drafts app itself) to a zettel/obsidian friendly .md file to then use neovim to edit further. I will also just go to town in prose mode via neovim to just type out blog posts and ideas, etc. |
Beta Was this translation helpful? Give feedback.
-
That's right, at the moment I've been using vimwiki coupled with vim-zettel and notational-fzf-vim. This works great for navigating through my notes and creating links, but a better integration with I'm thinking of building a dedicated Vim plugin eventually, especially since I don't really need the vimwiki part which is large. With a better |
Beta Was this translation helpful? Give feedback.
-
@mickael-menu and @evantravers I've implemented the first couple of commands.. a way to install While not a huge deal; it will just require, maybe some basic configuration for the plugin, basically defining a notebook dir to use as the base path for all commands to be executed. Thoughts? https://github.com/megalithic/zk.nvim/tree/feat/main/impl_first_command |
Beta Was this translation helpful? Give feedback.
-
Just wanted to give a quick update on where we're at. I just merged the ability |
Beta Was this translation helpful? Give feedback.
-
This is what I'm using for navigating notes, tags, links in neovim. It basically shells out https://github.com/mhanberg/.dotfiles/blob/main/config/nvim/plugin/zk.lua local nnoremap = require("motch.utils").nnoremap
local _ = require("underscore")
vim.cmd([[command! ZkDaily :term zk daily]])
local colors = require("ansicolors")
local zk = {}
zk.note_picker = function(source)
local notes = vim.fn.system(source)
if vim.fn.trim(notes) == "" then
notes = "[]"
end
notes = vim.fn.json_decode(notes)
notes = _.map(notes, function(n)
local tags = _.join(
_.map(n.tags, function(t)
return "#" .. t
end),
" "
)
return colors.noReset("%{bright}%{yellow}")
.. n.title
.. colors("%{reset}")
.. " "
.. ":"
.. " "
.. tags
.. " "
.. ":"
.. " "
.. n.absPath
end)
local actions = {
["enter"] = function(selected)
vim.fn.execute("edit " .. selected)
end,
["ctrl-v"] = function(selected)
vim.fn.execute("vsplit " .. selected)
end,
["ctrl-x"] = function(selected)
vim.fn.execute("split " .. selected)
end,
["ctrl-n"] = function(_, query)
require("lspconfig/configs").zk.new({ title = query })
end,
}
FZF({
source = notes,
sinklist = function(selected)
local query = selected[1]
local action = actions[selected[2]]
local parts = vim.fn.split(selected[3], ":")
action(parts[#parts], query)
end,
options = {
"--expect",
"enter,ctrl-v,ctrl-x,ctrl-n",
"--header",
colors("%{blue}CTRL-N: create a note with the query as title"),
"--print-query",
"--ansi",
"--delimiter",
":",
"--preview",
"bat {-1}",
"--nth",
"1..2",
"--prompt",
"Notes> ",
},
window = { width = 0.9, height = 0.6, yoffset = 0, highlight = "Normal" },
})
end
zk.list = function()
zk.note_picker("zk list --quiet -f json --sort=created")
end
zk.tags = function()
local tags = vim.fn.system("zk tag list --quiet -f json")
tags = _.map(vim.fn.json_decode(tags), function(t)
return t.name
end)
FZF({
source = tags,
sink = function(tag)
zk.note_picker(string.format("zk list --quiet -f json --sort=created --tag %s", tag))
end,
options = { "--ansi", "--prompt", "Tags> " },
window = { width = 0.9, height = 0.6, yoffset = 0, highlight = "Normal" },
})
end
zk.backlinks = function()
zk.note_picker(string.format("zk list --quiet -f json --sort=created --link-to %s", vim.fn.expand("%")))
end
zk.links = function()
zk.note_picker(string.format("zk list --quiet -f json --sort=created --linked-by %s", vim.fn.expand("%")))
end
_G.motch.zk = zk
local dir = require("lspconfig").util.root_pattern(".zk")(vim.fn.getcwd())
if type(dir) == "string" then
nnoremap("<C-p>", ":lua motch.zk.list()<cr>")
nnoremap("<space>zt", ":lua motch.zk.tags()<cr>")
nnoremap("<space>zb", ":lua motch.zk.backlinks()<cr>")
nnoremap("<space>zl", ":lua motch.zk.links()<cr>")
nnoremap("<space>zd", ":ZkDaily<cr>")
end Note: The global |
Beta Was this translation helpful? Give feedback.
-
Here is my cleaned up integration of the current zk lsp commands (new, list, tags.list) and fzf. I realized it made more sense to separate a "zk" file from a "notes" file that does the actual fzf integration. https://github.com/mhanberg/.dotfiles/blob/main/config/nvim/lua/motch/zk.lua |
Beta Was this translation helpful? Give feedback.
-
Pushed some updates to my zk.nvim plugin and included some links to examples in my dotfiles how i'm using it for some more bespoke things. |
Beta Was this translation helpful? Give feedback.
-
@megalithic started this discussion in #10 (comment)
Beta Was this translation helpful? Give feedback.
All reactions