Feel-ix-343 / markdown-oxide

Editor Agnostic PKM: you bring the text editor and we bring the PKM - inspired by and compatible with Obsidian
GNU General Public License v3.0
684 stars 10 forks source link

feat: add lsp workspace commands to open daily notes #85

Closed Kxnr closed 1 month ago

Kxnr commented 1 month ago

close #99

Feel-ix-343 commented 1 month ago

Thank you!

Feel-ix-343 commented 1 month ago

this is developing nicely!

Feel-ix-343 commented 1 month ago

running lua vim.lsp.buf.execute_command({command="jump", arguments={"today"}}) will make it work;

there is also

that fuzzydate lib is really special

Feel-ix-343 commented 1 month ago

Right now we can do

      require("lspconfig").markdown_oxide.setup({
        -- ...
        capabilities = capabilities,
        on_attach = on_attach,
        commands = {
          Today = {
             function()
               vim.lsp.buf.execute_command({command="jump", arguments={"today"}})
             end,
             description = "Open today's daily note"
          },
          Tomorrow = {
             function()
               vim.lsp.buf.execute_command({command="jump", arguments={"tomorrow"}})
             end,
             description = "Open tomorrow's daily note"
          },
          Yesterday = {
             function()
               vim.lsp.buf.execute_command({command="jump", arguments={"yesterday"}})
             end,
             description = "Open yesterday's daily note"
          },
        }
      })

but cannot provide a default command for entering the jump arguments.

A dedicated plugin would be so helpful for this; right now, the user will have to modify their on_attach to enable this (which we can provide snippets for). Either we make our own, or continue the developments in #65 (or both?). This would be helpful for the other non-ideal nvim-cmp and capabilities configuration.

I think "both" is the way to go: #95

Feel-ix-343 commented 1 month ago

With this snippet, users can open daily notes with natural language Daily two days ago

  if client.name == "markdown_oxide" then

    vim.api.nvim_create_user_command(
      "Daily",
      function(args)
        local input = args.args

        vim.lsp.buf.execute_command({command="jump", arguments={input}})

      end,
      {desc = 'Open daily note', nargs = "*"}
    )
  end
Feel-ix-343 commented 1 month ago

Let me know what you think and we'll merge right in

Feel-ix-343 commented 1 month ago

I wanted to get it closed :smile:

We can talk more on the main issue