Skip to content
This repository has been archived by the owner on Aug 16, 2021. It is now read-only.

Implement first couple commands #2

Merged
merged 14 commits into from
Mar 16, 2021
Merged

Conversation

megalithic
Copy link
Owner

@megalithic megalithic commented Mar 16, 2021

This PR adds some additional structure and arch around future command creation and usage.

It first enables a way to install zk into the user's GOPATH. Secondly it enables a way to create a new zk note, this feature is presently broken (see #1) until we create a way to handle zk's requirement to be run within a cwd that contains an initialized notebook using a .zk root marker.

See further discussion here: https://github.com/mickael-menu/zk/discussions/11#discussioncomment-489636

cmd = string.format("zk new --title %s", title)
end

vim.fn.jobstart(
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would be nice to have a utility to handle future jobstart usages.

local cmd = "zk new"

if title ~= nil and title ~= "" then
cmd = string.format("zk new --title %s", title)
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems like we don't care about further arguments passed in, just a title is sufficient as an optional arg, yeah?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The destination directory and/or --group could be useful too, to generate different kind of notes. The group is actually derived from the destination directory. See this note and zk new --help.

You can also feed some initial content to the note, which will be expanded in the template with {{content}}. This needs to be fed through an stdin pipe. Maybe it's overkill for now, but could be nice later to create a new note from the current buffer selection, to split a big note into smaller ones.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The destination directory and/or --group could be useful too, to generate different kind of notes. The group is actually derived from the destination directory. See this note and zk new --help.

You can also feed some initial content to the note, which will be expanded in the template with {{content}}. This needs to be fed through an stdin pipe. Maybe it's overkill for now, but could be nice later to create a new note from the current buffer selection, to split a big note into smaller ones.

I love this idea for the note management aspect. Adding for future enhancement idea (#3).

print(string.format("[zk.nvim] on_exit -> j: %s, d: %s, e: %s", vim.inspect(j), vim.inspect(d), vim.inspect(e)))

if d == 0 then
vim.api.nvim_out_write("[zk.nvim] new zettel note created")
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need to be able to get the path to the newly created note and open a buffer/vsplit/split/tab to that note.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So you can do this with zk new --print-path

@@ -1,29 +1,15 @@
local zk = {}
_G.zk_util = require("zk.util")
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we still need this global utility? not using the more complicated way to create commands previously used.

plugin/zk.vim Outdated
@@ -5,52 +5,14 @@ set cpo&vim

if !has('nvim')
echohl Error
echom "Sorry this plugin only works with versions of neovim that support lua: nightly, >=0.5.0"
echom "[zk.nvim] This plug presently only supports neovim versions: nightly, >=0.5.0"
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

plug -> plugin

lua/zk/adapter.lua Outdated Show resolved Hide resolved
@megalithic
Copy link
Owner Author

Merging to main; was able to create a new note from the :ZkNew My Title command from within my notebook-initialized directory.

@megalithic megalithic merged commit a773dfe into main Mar 16, 2021
@megalithic megalithic deleted the feat/main/impl_first_command branch March 16, 2021 18:25
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants