telekasten.nvim icon indicating copy to clipboard operation
telekasten.nvim copied to clipboard

[BUG] insert link yields weird cursor behaviour

Open qwertzui11 opened this issue 2 years ago • 3 comments

Please confirm

  • [x] I am running the latest version of this plugin

Describe the bug

When I enter insert mode, and then call telekasten.insert_link() it's getting inserted after the cursor. eg. abc<cursor>def --> insert --> becomes abcd[[link]]<cursor>ef. However in my opinion it should become abc[[link]]<cursor>def. That would be the same behaviour eg like when pressing C-r to insert from a register.

when I use telekasten.insert_link({i=true}) the link gets added on the wrong position too AND the cursor jumps to the end of the line.

https://asciinema.org/a/X2wNICpkOyVJiL8ZphSAm1Yqu

Operating system (please complete the following information):

  • nvim 0.7
  • OS: Ubuntu, Opensuse

Additional context

my neovim config

local use = require('packer').use
require('packer').startup(function()
  use 'wbthomason/packer.nvim'
  use {'nvim-telescope/telescope.nvim', requires = {{'nvim-lua/plenary.nvim'}} }
  use 'renerocksai/telekasten.nvim'
end)

local telescope = require('telescope')
telescope.setup()

-- https://github.com/renerocksai/telekasten.nvim#0-install-and-setup
local telekasten = require('telekasten')
local home = vim.fn.expand("~/zettelkasten")
telekasten.setup()

-- https://github.com/renerocksai/telekasten.nvim#3-bind-it
vim.keymap.set('n', '<leader>zf', telekasten.find_notes)
vim.keymap.set('n', '<leader>zz', telekasten.panel)
vim.keymap.set('n', '<leader>zp', telekasten.search_notes)
vim.keymap.set('n', '<leader>zg', telekasten.follow_link)
vim.keymap.set('n', '<leader>zn', telekasten.new_note)
vim.keymap.set('n', '<leader>zr', telekasten.rename_note)
vim.keymap.set('n', '<leader>zt', telekasten.show_tags)

local insert_link = function ()
  -- telekasten.insert_link({i=true})
  telekasten.insert_link()
end
vim.keymap.set('i', '<leader>zl', insert_link)
vim.keymap.set('n', '<leader>zl', insert_link)

qwertzui11 avatar Jun 21 '22 08:06 qwertzui11

I cannot reproduce on my setup. When I insert a link it inserts at the cursor position as expected. abc|def -> abc[[mylink]]def

Can someone test that?


If I have i=true it jumps at the end of the line indeed, this is expected.

Now that you mention it, we should instead always jump after the link rather than directly at the end of the line. I think that the jump to the end of the line was made for when you are pasting the link as you write, so it effectively goes after the link. But this is not really useful when editing a pre-existing sentence.

lambtho12 avatar Jun 21 '22 10:06 lambtho12

I cannot reproduce on my setup. When I insert a link it inserts at the cursor position as expected. abc|def -> abc[[mylink]]def

that's weird. I was afraid, that it's difficult to reproduce. That's why I did a minimal init.lua. hm. You did test the nvim tag version 0.7.0?

qwertzui11 avatar Jun 21 '22 10:06 qwertzui11

Yes. I am using nvim 0.7.0

I will try using a minimal init.lua as well when I have some time.

lambtho12 avatar Jun 21 '22 11:06 lambtho12