gennaro-tedesco / nvim-possession

📌 the no-nonsense session manager
MIT License
215 stars 7 forks source link

Plugin doesn't work #34

Closed pmatulis closed 8 months ago

pmatulis commented 8 months ago

I have in my init.vim:

let mapleader=" " require("nvim-possession-conf")

This file's contents is:

require('nvim-possession').setup({
  config = true,
  init = function()
      local possession = require("nvim-possession")
      vim.keymap.set("n", "<leader>sl", function()
          possession.list()
      end)
      vim.keymap.set("n", "<leader>sn", function()
          possession.new()
      end)
      vim.keymap.set("n", "<leader>su", function()
          possession.update()
      end)
      vim.keymap.set("n", "<leader>sd", function()
          possession.delete()
      end)
  end,
  autoload = true,
  autosave = true,
  autoswitch = {
      enable = true,
      exclude_ft = {},
  },
  fzf_winopts = {
      -- any valid fzf-lua winopts options, for instance
      width = 0.5,
      preview = {
          vertical = "right:30%"
      }
  }
})

The leader is set to .

Starting nvim is error-free.

I'm expecting <space>sn or <space>sl to give me results (new or list) but it appears that the key mappings are not set. Apologies if this is a generic config problem. My other plugins show how to do things with vimscript.

gennaro-tedesco commented 8 months ago

The installation instruction of this plugin are addressed to plugin managers that work in lua, that is, you should have an init.lua rather than an init.vim: what plugin manager are you using? The require instruction should have given you errors if used in a vimscript file.

Please choose a specific plugin manager and follow the appropriate instructions to install the plugin: if you still see problems feel free to get back to the issue, however please ascertain first that your neovim configuration works.

pmatulis commented 8 months ago

I have a hybrid configuration - some Vimscript and some Lua. My plugin manager is vim-plug.

gennaro-tedesco commented 8 months ago

Then you need to wrap lua imports in vimscript code: the instruction require isn't loaded because it isn't vimscript code.

Please refer to general instructions on how to include lua configurations via using vimscript and vim-plug. Afterwards check that the plugin is correctly loaded with :PlugStatus - if the plugin is loaded then it should work, if otherwise check if the mappings are correctly assigned via :verbose map <leader>sn (and likewise for the rest).

pmatulis commented 8 months ago

Yes, I'm doing that:

lua << EOF
require("lualine-conf")
.
.
.
require("nvim-possession-conf")
EOF

Command :verbose map <leader>sn results in No mapping found.

gennaro-tedesco commented 8 months ago

Command :verbose map sn results in No mapping found.

then this means that the configuration didn't take effect. Did you run :PlugStatus, is the plugin installed at all?

pmatulis commented 8 months ago

Yes, it is installed.

image

pmatulis commented 8 months ago

If I deliberately create an error in the first line of the plugin's configuration file I get an error when starting up my neovim:

requir('nvim-possession').setup({

(the missing 'e' in "require")

However, applying the strategy to the rest of the file does not give me an error. There is something with the configuration structure (?) that is not right.

gennaro-tedesco commented 8 months ago

However, applying the strategy to the rest of the file does not give me an error. There is something with the configuration structure (?) that is not right.

This would then depend on how you are configuring your neovim. Notice that the plugins instructions that you copied refer to installation via the plugin manager lazy.nvim (as specified in the README): if you are using vim-plug then you have to install the plugin differenty (and to do so please refer to the specific installation instructions of lua plugins via vim-plug, I don't really know how such plugin deals with lua code).

P. S. Given you are using vim-plug I wonder if the other plugins work? They cannot work either if you just copy installation instructions that refer to other plugins :)

pmatulis commented 8 months ago

All the many other plugins work fine. Yours is the only one that needs mappings created using Lua. I will dig into it. Thanks for your guidance.