0

In my init.lua I have:

require("base") -- general settings
require("highlights") -- colourscheme and other highlights
require("keymaps") -- keymaps
require("plugins") -- plugins
require("hop") -- hop
require("bootstrap") -- packer auto-installer

print("✔ nvim loaded")
print(vim.inspect(package.loaded['hop']))

In base.lua, I have:

local g = vim.g
local o = vim.o
local opt = vim.opt

-- Map <leader> to space
g.mapleader = ' '
g.maplocalleader = ' '

In keymaps.lua, I have:

map("n", "<leader>w", ":HopWord<cr>")
map("n", "<leader>W", ":HopWordMW<cr>")
map("n", "f", ":HopChar1<cr>")
map("n", "F", ":HopChar1CurrentLine<cr>")

In plugins.lua, I have:

-- ...packer setup
  local status, packer = pcall(require, "packer")
  if not status then
    return
  
  end
  
  return packer.startup(function(use)

    use {
        'phaazon/hop.nvim',
        branch = 'v2', -- optional but strongly recommended
        -- config = [[require('hop')]],
        -- config = function()
        -- -- you can configure Hop the way you like here; see :h hop-config
        --   require'hop'.setup {}
        -- end
    }
    
    if packer_bootstrap then
      require("packer").sync()
    end
  end)

And finally, in hop.lua I have:

local setup, hop = pcall(require, "hop")

if not setup then
  return
end

hop.setup { keys = "etovxqpdygfblzhckisuran" }

When I load vscode, I see the following output:

✔ nvim loaded
true
nil

The true is from the init.lua and means that hop was loaded, however, when I then press <space>w, I get the error:

E492: Not an editor command: HopWord

which means the hop commands did not load? Please help. I would like an easymotion style navigation flow for vscode neovim where it annotates places to jump to after pressing the spacebar.

romainl
  • 186,200
  • 21
  • 280
  • 313
55 Cancri
  • 1,075
  • 11
  • 23
  • 1
    For your hop conf, rename the conf file, why are you using the same name as the plugin itself? I think there is shadowing issue. **NEVER EVER NAME YOUR CONF THE SAME AS THE PLUGIN NAME.** Try to rename it to `hop-conf.lua` and in `init.lua`, you should `require('hop-conf')` instead. – jdhao Dec 29 '22 at 09:44
  • @jdhao that prevented it from logging true, but now the log outputs nil twice, and I still get the same error `E492: Not an editor command: HopWord`. Do you see anything wrong with this setup? Is the order of the imports relevant here? – 55 Cancri Dec 29 '22 at 23:04
  • Can not see the reason why it does not work. You may need to debug yourself. Try to remove all non-relevant config and see what is wrong. – jdhao Dec 30 '22 at 02:44

1 Answers1

0

Look at my response this ticket. It seems to work native without much configuration other than binding keybinds as hop does not configure any by default.

  • 1
    As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – YesThatIsMyName Jan 17 '23 at 08:40