zk-org/zk-nvim

ZkNew seems to not be following described behavior.

AndOrangutan opened this issue · 1 comments

When looking at https://github.com/mickael-menu/zk/blob/main/docs/editors-integration.md#zknew it says that dir is relative to parent directory of notebook.

When I enter the notebook from my dashboard I run a ZkCd (after waitng 100 ms because I found it didn't work unless I did). Once in the note, running :pwd prints what I would expect:
image

Then I try this binding:

    ["<leader>znc"] = { function ()

        local code = string.lower(vim.fn.input('Class Code: '))
        local ucode = string.upper(code)

        -- Check if nil
        if code == nil then
            vim.notify("ZK: Please include code", "Float")
            return
        elseif vim.fn.isdirectory("classes/"..code) == 0 then
            vim.notify("A directory for "..ucode.." Doesn't Exist.", "Float")
        end

        local title = vim.fn.input('Title: ')

        if title == nil then
            vim.notify("ZK: Please include title", "Float")
            return
        else
            require("zk.commands").get("ZkNew")({ extra = { classcode = ucode }, dir = 'career/'..code, title = title })
        end
    end, "[z]K [n]ew [c]lass Note"},

And I get this output, which I don't understand why it isn't respecting the notebook dir.

Error executing vim.schedule lua callback: ...cal/share/nvim/site/pack/packer/start/zk-nvim/lua/zk.lua:68: RPC[Error] code_name
 = InvalidRequest, message = "new note: /home/vm/career/pols1: path is outside the notebook at /home/vm/Dropbox/Notebooks/Compe
ndium"
stack traceback:
        [C]: in function 'assert'
        ...cal/share/nvim/site/pack/packer/start/zk-nvim/lua/zk.lua:68: in function 'handler'
        /usr/share/nvim/runtime/lua/vim/lsp.lua:1252: in function ''
        vim/_editor.lua: in function <vim/_editor.lua:0>

I don't have $ZK_NOTEBOOK_DIR set, but from my understanding I shouldn't need it since ZkCd seems to figure out the correct directory. Am I missing something here?

Edit:
Just realized I can't use any new command, I am going to tear into my config file and double check it.

Nevermind. I misunderstood the use of $ZK_NOTEBOOK_DIR I think.