From 56a43e4009ff45d80e17367f3cc78247e86fba8a Mon Sep 17 00:00:00 2001 From: jdhao Date: Sun, 19 Dec 2021 20:52:23 +0800 Subject: [PATCH] show IME on statusline on macOS --- lua/config/statusline.lua | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/lua/config/statusline.lua b/lua/config/statusline.lua index f930cd3..8dace97 100644 --- a/lua/config/statusline.lua +++ b/lua/config/statusline.lua @@ -6,6 +6,17 @@ local function spell() return "" end +local function ime_state() + if vim.g.is_mac then + local layout = vim.fn.libcall(vim.g.XkbSwitchLib, 'Xkb_Switch_getXkbLayout', '') + if layout == '0' then + return '[CN]' + end + end + + return "" +end + local function trailing_space() -- Get the positions of trailing whitespaces from plugin 'jdhao/whitespace.nvim'. local trailing_space_pos = vim.b.trailing_whitespace_pos @@ -63,7 +74,11 @@ require("lualine").setup({ spell, color = {fg = 'black', bg = '#a7c080'} }, - "filename" + "filename", + { + ime_state, + color = {fg = 'black', bg = '#f46868'} + }, }, lualine_x = { "encoding",