IceNvim
IceNvim copied to clipboard
basic.lua
原文:vim.cmd "language en_US.UTF-8" 修改为: local handle = io.popen("locale -a | grep -iE '.utf.?8$'", "r") local utf8_locales = {} if handle then for line in handle:lines() do table.insert(utf8_locales, line) end handle:close() end
-- 优先选择 en_US.UTF-8,否则选第一个 UTF-8 环境 local chosen_locale for _, locale in ipairs(utf8_locales) do if locale:lower() == "en_us.utf-8" then chosen_locale = locale break end end chosen_locale = chosen_locale or utf8_locales[1]
-- 设置语言环境 if chosen_locale then vim.cmd("language " .. chosen_locale) else vim.notify("未找到任何 UTF-8 语言环境,剪贴板可能异常!", vim.log.levels.ERROR) end