SyedFasiuddin / org-roam.nvim

Rudimentary org-roam replica for neovim
MIT License
2 stars 2 forks source link

E5108: Error executing lua: ...ff/.local/share/nvim/lazy/org-roam.nvim/lua/org-roam.lua:111: Cursor position outside buffer #1

Closed nlif-m closed 1 year ago

nlif-m commented 1 year ago

Hello @SyedFasiuddin, First, thank you for your plugin.

I am using your plugin with this nvim using lazy.nvim instead of packer, since packer is not maintained anymore.

NVIM v0.9.1
Build type: Release
LuaJIT 2.1.0-beta3

My issue is that when I call org_roam.org_roam_node_find I get an error E5108: Error executing lua: ...ff/.local/share/nvim/lazy/org-roam.nvim/lua/org-roam.lua:111: Cursor position outside buffer. it's not fatal, since I hit enter twice and .org file is opened, but is's distracting.

I tried to fix this error and it worked when I commented out line 111 and after this all start working without errors.

diff --git a/lua/org-roam.lua b/lua/org-roam.lua
index 07e0feb..94f8996 100644
--- a/lua/org-roam.lua
+++ b/lua/org-roam.lua
@@ -108,7 +108,7 @@ local function org_roam_node_find()
                         end

                         vim.cmd.edit(selection.value.file)
-                        vim.api.nvim_win_set_cursor(0, { row, 0 })
+                        -- vim.api.nvim_win_set_cursor(0, { row, 0 })
                     end
                 end)
                 return true

I'm not really familiar with the vim api, so the question is, does this break something now or maybe break something further in your vision for the development of this project?

If not, I can submit a pull request with this change.

This is my reproducible nvim lua config

vim.g.mapleader = ' '
vim.g.maplocalleader = ' '

local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim'
if not vim.loop.fs_stat(lazypath) then
  vim.fn.system {
    'git',
    'clone',
    '--filter=blob:none',
    'https://github.com/folke/lazy.nvim.git',
    '--branch=stable', -- latest stable release
    lazypath,
  }
end
vim.opt.rtp:prepend(lazypath)

-- NOTE: Here is where you install your plugins.
--  You can configure plugins using the `config` key.
--
--  You can also configure plugins after the setup call,
--    as they will be available in your neovim runtime.
require('lazy').setup(
{
  {
    "SyedFasiuddin/org-roam.nvim",
    config = function()
      local org_roam = require("org-roam")
      org_roam.setup({
        -- required
        org_roam_directory = "~/org-roam",

        -- required (not checked if preset)
        org_roam_database_file = "~/.config/emacs/org-roam.db"
      })
      vim.keymap.set("n", "<space>nf", org_roam.org_roam_node_find)
    end,
    dependencies = {
      "kkharji/sqlite.lua",
      "nvim-orgmode/orgmode",
    },
  },

  {
    -- Highlight, edit, and navigate code
    'nvim-treesitter/nvim-treesitter',
    dependencies = {
      'nvim-treesitter/nvim-treesitter-textobjects',
    },
    build = ':TSUpdate',
  },
  {
    'nvim-telescope/telescope.nvim',
    branch = '0.1.x',
    dependencies = {
      'nvim-lua/plenary.nvim',
      -- Fuzzy Finder Algorithm which requires local dependencies to be built.
      -- Only load if `make` is available. Make sure you have the system
      -- requirements installed.
      {
        'nvim-telescope/telescope-fzf-native.nvim',
        -- NOTE: If you are having trouble with this installation,
        --       refer to the README for telescope-fzf-native for more instructions.
        build = 'make',
        cond = function()
          return vim.fn.executable 'make' == 1
        end,
      },
    },
  },}
  , {})
SyedFasiuddin commented 1 year ago

The real intent behind setting the cursor position within a node was to mimic the functionality of org-roam but it doesn't work properly yet, so this is removed in my local development branch and changes will be pushed soon.

SyedFasiuddin commented 1 year ago

emacs has a goto-char function which takes a number and positions the cursor at that character, this number which is passed as argument to goto-char function is stored in org-roam database, currently I have not implemented the goto-char equivalent for this project. You can comment that line out for time being.

In future there will be an implementation for it, however that is not a priority at the moment.

nlif-m commented 1 year ago

Thanks for the clarification, I wish you good development