dhruvasagar / vim-table-mode

VIM Table Mode for instant table creation.
2.11k stars 96 forks source link

Changing prefix doesn't work #222

Closed eduardoarandah closed 8 months ago

eduardoarandah commented 1 year ago

Version:

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?

dhruvasagar commented 1 year ago

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

eduardoarandah commented 1 year ago

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

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

video:

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

dhruvasagar commented 1 year ago

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

darricheng commented 1 year ago

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)
dhruvasagar commented 1 year ago

@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 commented 1 year ago

@eduardoarandah ^

darricheng commented 1 year ago

@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.

dhruvasagar commented 1 year ago

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.

gwash commented 8 months ago

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

dhruvasagar commented 8 months ago

@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.

carbon-steel commented 8 months ago
{
   "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!

dhruvasagar commented 8 months ago

@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