Skip to content

MahdiGMK/keymap-switch.nvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

keymap-switch.nvim

A plugin for Neovim for switching keyboard layout and displaying it in a status line.

Table of contents

Requirements

  • Neovim 0.7

Installation

With lazy.nvim:

{
  'lostl1ght/keymap-switch.nvim',
  keys = {
    { '<c-\\>', '<plug>(keymap-switch)', mode = { 'i', 'c', 'n' } },
  },
  config = function()
    require('keymap_switch').setup({
      keymap = -- *required*, see :h keymap
      -- other configuration
    })
  end
}

Configuration

Default setup values:

{
  keymap = nil, -- *required*, see :h keymap
  format = function(keymap_name) -- used in provider()
    return keymap_name           -- accepts vim.b.keymap_name
  end,
}

Key mappings

Set key mappings:

vim.keymap.set({'i', 'n', 'c'}, '<c-\\>', '<plug>(keymap-switch)')

Status line

The plugin exposes 2 functions for a status line plugin:

condition() allows hiding the component when layout is not EN:

require('keymap_switch').condition()

provider() allows displaying layout, returns en when :h iminsert is 0:

require('keymap_switch').provider()

These functions can be used in a status line to display whether keymap is active.

For example, with lualine:

require('lualine').setup({
  sections = {
    lualine_z = {
      {
        require('keymap_switch').provider,
        cond = require('keymap_switch').condition,
      }
    }
  }
})

Hacks

In insert/command modes the plugin feeds :h i_CTRL-^/:h c_CTRL-^ because changing :h iminsert directly (like in normal mode) is not reflected in the status line components until exiting insert/command modes.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages