vim-table-mode icon indicating copy to clipboard operation
vim-table-mode copied to clipboard

Changing prefix doesn't work

Open eduardoarandah opened this issue 1 year ago • 8 comments

Version:

  • Neovim v0.8.0
  • tablemode version: branch master commit 9555a3e
  • installed with Lazy.nvim

Want:

change prefix from <leader>t to <localleader>t because I've already mapped some things to: leader t leader tt

Tried:

{
	"dhruvasagar/vim-table-mode",
	config = function()
                    vim.cmd("let g:table_mode_map_prefix = '<localleader>t'")
                    -- also tried: 
		-- vim.g.table_mode_map_prefix = "<localleader>t"
		-- vim.g.toggle_mode_options_toggle_map = "<localleader>tm"
		-- vim.g.table_mode_commands_tableize = "<localleader>tt"
	end,
},

Also tried:

Executing manually :let g:table_mode_map_prefix = '<localleader>t' in buffer with no success, leader tt still adds pipes to content.

Any ideas?

eduardoarandah avatar Jan 27 '23 17:01 eduardoarandah

@eduardoarandah What's your localleader set to ? Make sure it's set to the right thing during config function.

dhruvasagar avatar Jan 31 '23 11:01 dhruvasagar

@eduardoarandah What's your localleader set to ? Make sure it's set to the right thing during config function.

  • localleader is \
  • leader is <space>

As you can see, it's shown as \ when opening a markdown file.

  • <space> tt should not trigger table mode here
  • <localleader> ttshould trigger it and it doesn't

video:

https://user-images.githubusercontent.com/4065733/215833046-eaa8b4d2-53eb-4e15-9f38-ed53f8256963.mp4

eduardoarandah avatar Jan 31 '23 17:01 eduardoarandah

@eduardoarandah Thanks for reporting this, the screencast is really helpful. I am going to test this and report back.

dhruvasagar avatar Feb 01 '23 05:02 dhruvasagar

I added the line vim.g.table_mode_map_prefix = '<leader>mt' to my init.lua file before the line that installs Lazy.nvim and the prefix gets changed correctly to what I want.

I think this issue might be similar to setting the leader key as described in kickstart.nvim, but I'm not entirely sure.

-- Set <space> as the leader key
-- See `:help mapleader`
--  NOTE: Must happen before plugins are required (otherwise wrong leader will be used)

darricheng avatar May 10 '23 09:05 darricheng

@darricheng Can you share a minimal vimrc for me to test with ? I don't use Lazy.nvim, so it'll help me test this quickly.

dhruvasagar avatar May 10 '23 17:05 dhruvasagar

@eduardoarandah ^

dhruvasagar avatar May 10 '23 17:05 dhruvasagar

@dhruvasagar I'm still a beginner with Neovim, so I'm not sure what the absolute minimum config would be to test this, but I can point you to kickstart.nvim's init.lua file. It's the base config that I started with, and it's one of the more minimal base Neovim configs that I'm aware of.

What I did for my config was the equivalent of adding vim.g.table_mode_map_prefix = '<leader>mt' to line 44 of the init.lua file that I linked.

Note that since this is Neovim, the file is init.lua instead of vimrc.

darricheng avatar May 11 '23 02:05 darricheng

By minimal, I mean a vimrc that sets up just maybe lazy.nvim and vim-table-mode as plugins along with any customizations you're using. That way we can isolate and identify if the issue is with vim-table-mode or your particular setup. I'll take a look at the linked kickstart.nvim file, but i'll be a couple of days until I can get back on this.

dhruvasagar avatar May 11 '23 09:05 dhruvasagar

I've had the same issue, the solution is to use the 'init' property instead of 'config', as that triggers much earlier.

gwash avatar Mar 06 '24 03:03 gwash

@eduardoarandah and other folks facing this issue. In neovim, there's an issue that requires you to configure mapleader or maplocalleader before you load plugins to correctly use Leader or LocalLeader mappings. This was an issue I faced myself.

dhruvasagar avatar Mar 07 '24 04:03 dhruvasagar

{
   "dhruvasagar/vim-table-mode",
   config = function ()
       vim.g.table_mode_map_prefix = "mt"
   end
},

I use neovim (+ lazy.nvim as my package manager). Even without using <leader> or <localleader>, the mappings do not change. As @gwash said, changing config to init gets the mappings to change. Though, tbh, I'd prefer the option of disabling all default mappings since I prefer to make my own.

Thanks for the awesome plugin!

carbon-steel avatar Mar 08 '24 23:03 carbon-steel

@carbon-steel That's a good point. Typically these configurations should be added in vimrc, which is loaded before plugins are loaded. While the config callback of lazy is called after loading the plugin. So that's why it does not work, if the configuration is not set before the plugin loads, it uses the defaults as you are experiencing. Sounds like init is the way to go for lazy. I shall add that note in the README.md

dhruvasagar avatar Mar 09 '24 06:03 dhruvasagar