NMAC427 / guess-indent.nvim

Automatic indentation style detection for Neovim
MIT License
387 stars 7 forks source link

non-issue: readme.md: add lazy and retab keymaps #18

Open recallmenot opened 5 months ago

recallmenot commented 5 months ago

Hi, thank you so much for making this plugin!!

Below is my lua for lazy, you could add that to the readme.

I've also added the following keybindings:

<Tab>g to guess the indetation
<Tab>t to convert to tabs (normal mode)
<Tab>t to convert to tabs (visual line mode)
<Tab>s to convert to spaces (normal mode)
<Tab>s to convert to spaces (visual line mode)

While the last two (four) bindings don't have anything to do with your plugin, you may still choose to add them to the readme as they provide a great workflow enhancement when converting styles.

return {
    'nmac427/guess-indent.nvim',
    lazy = false,
    config = function()
        require('guess-indent').setup {}
        vim.keymap.set('n', '<Tab>g', vim.cmd.GuessIndent, { desc = "GuessIndent (manual)" })
        -- to tabs
        vim.keymap.set('n', '<Tab>t', '<Cmd>set noexpandtab<CR><Cmd>%retab!<CR><Cmd>set tabstop=8<CR>', { noremap = true, desc = "retab to tabs" })
        vim.keymap.set('v', '<Tab>t', "<Cmd>set noexpandtab<CR><Cmd>'<,'>retab!<CR><Cmd>set tabstop=8<CR>", { noremap = true, desc = "retab to tabs" })
        -- to spaces (for the average emacs enjoyer)
        vim.keymap.set('n', '<Tab>s', '<Cmd>set expandtab<CR><Cmd>set tabstop=8<CR><Cmd>%retab!<CR>', { noremap = true, desc = "retab to spaces" })
        vim.keymap.set('v', '<Tab>s', "<Cmd>set expandtab<CR><Cmd>set tabstop=8<CR><Cmd>'<,'>retab!<CR>", { noremap = true, desc = "retab to spaces" })
    end,
}

For beginners like me, these would be quite helpful.