wiki.vim icon indicating copy to clipboard operation
wiki.vim copied to clipboard

[Bug] :WikiJournalCopyToNext is not working

Open Aneeqasif opened this issue 1 year ago • 1 comments

:WikiJournalCopyToNext command just open the next dates note of journal.

idk its behaving wierd

  • currently wikijournalnext command is not creating next note of next day (is it supposed to be like this?)
  • if the note is not yet created the copy to next features works (makes another note and copy the content)
  • if lets say i go to my todays journal note and then i go to my yesterdays one to copy stuff to my todays one the features does not work. in short if the next note in time is already created then the copy feature will not work.
  {"lervag/wiki.vim",
    -- enabled = false,
    lazy=false,
    ft ={"markdown"},
    cmd = {"WikiIndex", "WikiJournal"},
    keys = {
      { "<leader>ww", "<cmd>WikiIndex<cr>",         desc = "Wiki Index" },
    },
    init = function()
      vim.cmd([[
      -- see snippet below
      ]])
    end,
  },
let g:wiki_root = '~/Documents/vimwiki/'
let g:wiki_filetypes = ['md','wiki']
let g:wiki_select_method = "fzf"
let g:wiki_fzf_pages_opts = '--preview "glow {1}"'
let g:wiki_fzf_tags_opts = '--preview "bat --color=always {2..}"'

let g:wiki_link_creation = {
      \ 'md': {
      \   'link_type': 'wiki',
      \   'url_extension': '',
      \   'url_transform': { x ->
      \     substitute(x, '\s\+', '-', 'g') },
      \ },
      \}

let g:wiki#tags#default_parser = {
      \ 're_match': '\v%(^|\s):\zs[^: ]+\ze:',
      \ 're_findstart': '\v%(^|\s):\zs[^: ]+$'
      \}

function! g:wiki#tags#default_parser.match(line) dict abort
  return a:line =~# self.re_match
endfunction

function! g:wiki#tags#default_parser.parse(line) dict abort
  let l:tags = []
  let l:tag = matchstr(a:line, self.re_match, 0)

  while !empty(l:tag)
    call add(l:tags, l:tag)
    let l:tag = matchstr(a:line, self.re_match, 0, len(l:tags) + 1)
  endwhile

  return l:tags
endfunction

function! g:wiki#tags#default_parser.make(taglist, curline='') dict abort
  return empty(a:taglist) ? '' : join(map(a:taglist, '":" . v:val . ":"'))
endfunction

let s:tag_parser = deepcopy(g:wiki#tags#default_parser)
let s:tag_parser.re_match = '\v%(^|\s)#\zs[^# ]+'
let s:tag_parser.re_findstart = '\v%(^|\s)#\zs[^# ]+'
let s:tag_parser.make = {t, l -> empty(t) ? '' : join(map(t, '"#" . v:val'))}

let g:wiki_tag_parsers = [s:tag_parser]

let g:wiki_fzf_pages_force_create_key = "alt-n"

let g:wiki_link_schemes = {
      \ 'wiki': {
      \   'resolver': function('personal#wiki#link_resolver'),
      \ }
      \}

Aneeqasif avatar Jul 31 '23 17:07 Aneeqasif

Before I comment, two things:

  1. Sorry for the late answer. I've been on vacations and have been taking some time of. :)

  2. It would be easier for me (any maintainer, really) if you could take some more time to both 1) properly describe and write your issue description and 2) properly format your post. E.g., here you had left-over content from the issue template between your first sentence and the code snippet, and you added a second comment that is just barely understandable. It might take you some more time to write out things properly, but you may very well save time because it makes it easier for me to help you!

:WikiJournalCopyToNext command just open the next dates note of journal.

This may be expected behaviour. The command will not overwrite content of an existing page. It will only copy things to the next entry if that entry does not already exist.

idk its behaving wierd

idk?

  • currently wikijournalnext command is not creating next note of next day (is it supposed to be like this?)

:WikiJournalNext (notice that I take the time to format this properly and write out the proper command) will not create new notes except for the present day. So, if todays date is 2023-08-05 and you don't have any entries for future dates, then :WikiJournalNext will not do anything. That is expected.

  • if the note is not yet created the copy to next features works (makes another note and copy the content)

Precisely - this is what I mentioned above.

  • if lets say i go to my todays journal note and then i go to my yesterdays one to copy stuff to my todays one the features does not work. in short if the next note in time is already created then the copy feature will not work.

This is not the intended purpose of the command. If you go to yesterdays note, you can copy things easily with e.g. ggyG, then return and p.

I've added :WikiJournalCopyToNext because I use it when I plan my work weeks. I use it typically each Monday, during which I use this command to move my TODOs forward in time and plan my week.

  {"lervag/wiki.vim",
    -- enabled = false,
    lazy=false,
    ft ={"markdown"},
    cmd = {"WikiIndex", "WikiJournal"},
    keys = {
      { "<leader>ww", "<cmd>WikiIndex<cr>",         desc = "Wiki Index" },
    },
    init = function()
      vim.cmd([[
      -- see snippet below
      ]])
    end,
  },

You can use Lua for configuration. It is quite simple to migrate. This is likely very close to what you want:

  {
    "lervag/wiki.vim",
    -- …
    init = function()
      vim.g.wiki_root = "~/Documents/vimwiki/"
      vim.g.wiki_filetypes = { "md", "wiki" }
      vim.g.wiki_select_method = "fzf"
      vim.g.wiki_fzf_pages_opts = '--preview "glow {1}"'
      vim.g.wiki_fzf_pages_force_create_key = "alt-n"
      vim.g.wiki_fzf_tags_opts = '--preview "bat --color=always {2..}"'

      vim.g.wiki_link_schemes = {
        wiki = {
          resolver = vim.fn["personal#wiki#link_resolver"],
        }
      }

      vim.g.wiki_link_creation = {
        md = {
          link_type = "wiki",
          url_extension = "",
          url_transform = function(x)
            return vim.fn.substitute(x, '\s\+', '-', 'g')
          end,
        },
      }

      local tag_parser = vim.fn.deepcopy(vim.g["wiki#tags#default_parser"])
      tag_parser.re_match = [[\v%(^|\s)#\zs[^# ]+]]
      tag_parser.re_find_start = [[\v%(^|\s)#\zs[^# ]+]]
      tag_parser.make = function(taglist, curline)
        if vim.fn.empty(taglist) == 1 then
          return ""
        else
          return vim.fn.join(vim.fn.map(taglist, '"#" . v:val'))
        end
      end
      vim.g.wiki_tag_parsers = { tag_parser }
    end,
  },

I've removed things you've commented out and things you've copied that didn't do anything.

lervag avatar Aug 05 '23 17:08 lervag

Closing due to inactivity.

lervag avatar Apr 04 '24 20:04 lervag