Add keyboard layout indicator (RU/EN) to lualine
Green background for EN, red for RU. Uses im-select on macOS. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,3 +1,29 @@
|
||||
local function keyboard_layout()
|
||||
local handle = io.popen("im-select")
|
||||
if not handle then
|
||||
return ""
|
||||
end
|
||||
local result = handle:read("*a")
|
||||
handle:close()
|
||||
if result:find("Russian") then
|
||||
return "RU"
|
||||
end
|
||||
return "EN"
|
||||
end
|
||||
|
||||
local function keyboard_layout_color()
|
||||
local handle = io.popen("im-select")
|
||||
if not handle then
|
||||
return { bg = "#a6e3a1", fg = "#1e1e2e", gui = "bold" }
|
||||
end
|
||||
local result = handle:read("*a")
|
||||
handle:close()
|
||||
if result:find("Russian") then
|
||||
return { bg = "#f38ba8", fg = "#1e1e2e", gui = "bold" }
|
||||
end
|
||||
return { bg = "#a6e3a1", fg = "#1e1e2e", gui = "bold" }
|
||||
end
|
||||
|
||||
return {
|
||||
"nvim-lualine/lualine.nvim",
|
||||
dependencies = { "nvim-tree/nvim-web-devicons" },
|
||||
@@ -9,7 +35,12 @@ return {
|
||||
},
|
||||
sections = {
|
||||
lualine_a = { "mode" },
|
||||
lualine_b = { "branch", "diff", "diagnostics" },
|
||||
lualine_b = {
|
||||
{ keyboard_layout, color = keyboard_layout_color },
|
||||
"branch",
|
||||
"diff",
|
||||
"diagnostics",
|
||||
},
|
||||
lualine_c = { { "filename", path = 1 } },
|
||||
lualine_x = { "encoding", "filetype" },
|
||||
lualine_y = { "progress" },
|
||||
|
||||
Reference in New Issue
Block a user