nvim: 判斷當前終端機是否在圖形環境裡
This commit is contained in:
parent
5869fb71b8
commit
d220d0ffa2
@ -63,6 +63,7 @@ return {
|
|||||||
|
|
||||||
{
|
{
|
||||||
"eero-lehtinen/oklch-color-picker.nvim",
|
"eero-lehtinen/oklch-color-picker.nvim",
|
||||||
|
enabled = require("tools.gui").is_graphical(),
|
||||||
event = "VeryLazy",
|
event = "VeryLazy",
|
||||||
version = "*",
|
version = "*",
|
||||||
keys = {
|
keys = {
|
||||||
|
@ -2,11 +2,13 @@ return {
|
|||||||
-- 測試狀況:Linux Fcitx5 Wayland 可用 / macOS 15 不可用
|
-- 測試狀況:Linux Fcitx5 Wayland 可用 / macOS 15 不可用
|
||||||
-- {
|
-- {
|
||||||
-- "Freed-Wu/ime.nvim",
|
-- "Freed-Wu/ime.nvim",
|
||||||
|
-- enabled = require("tools.gui").is_graphical(),
|
||||||
-- },
|
-- },
|
||||||
|
|
||||||
-- 測試狀況:Linux Fcitx5 Wayland 可用 / macOS 15 可用
|
-- 測試狀況:Linux Fcitx5 Wayland 可用 / macOS 15 可用
|
||||||
{
|
{
|
||||||
"keaising/im-select.nvim",
|
"keaising/im-select.nvim",
|
||||||
|
enabled = require("tools.gui").is_graphical(),
|
||||||
config = function()
|
config = function()
|
||||||
require("im_select").setup({})
|
require("im_select").setup({})
|
||||||
end,
|
end,
|
||||||
@ -15,17 +17,18 @@ return {
|
|||||||
-- 測試狀況:Linux Fcitx5 Wayland 可用
|
-- 測試狀況:Linux Fcitx5 Wayland 可用
|
||||||
-- {
|
-- {
|
||||||
-- "pysan3/fcitx5.nvim",
|
-- "pysan3/fcitx5.nvim",
|
||||||
|
-- enabled = require("tools.gui").is_graphical(),
|
||||||
-- cond = function()
|
-- cond = function()
|
||||||
-- return vim.fn.executable("fcitx5-remote") == 1
|
-- return vim.fn.executable("fcitx5-remote") == 1
|
||||||
-- end,
|
-- end,
|
||||||
-- event = { "ModeChanged" }, -- 在模式改變時載入插件
|
-- event = { "ModeChanged" }, -- 在模式改變時載入插件
|
||||||
-- config = function()
|
-- config = function()
|
||||||
-- require("fcitx5").setup() -- 初始化插件
|
-- require("fcitx5").setup() -- 初始化插件
|
||||||
--
|
|
||||||
-- -- 以下是手動指定規則
|
-- -- 以下是手動指定規則
|
||||||
-- -- local en = "keyboard-us"
|
-- -- local en = "keyboard-us"
|
||||||
-- -- local tw = "chewing"
|
-- -- local tw = "chewing"
|
||||||
--
|
|
||||||
-- -- require("fcitx5").setup({
|
-- -- require("fcitx5").setup({
|
||||||
-- -- imname = {
|
-- -- imname = {
|
||||||
-- -- norm = en,
|
-- -- norm = en,
|
||||||
@ -34,7 +37,7 @@ return {
|
|||||||
-- -- },
|
-- -- },
|
||||||
-- -- remember_prior = false,
|
-- -- remember_prior = false,
|
||||||
-- -- })
|
-- -- })
|
||||||
--
|
|
||||||
-- -- -- If you are using `jk` to escape, map 全角のjk.
|
-- -- -- If you are using `jk` to escape, map 全角のjk.
|
||||||
-- -- vim.cmd([[
|
-- -- vim.cmd([[
|
||||||
-- -- inoremap <silent> jk <Esc>
|
-- -- inoremap <silent> jk <Esc>
|
||||||
|
19
dot_config/nvim/exact_lua/exact_tools/gui.lua
Normal file
19
dot_config/nvim/exact_lua/exact_tools/gui.lua
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
local M = {}
|
||||||
|
|
||||||
|
--- 當前終端機環境是否在圖形環境裡面(Linux / macOS)
|
||||||
|
--- @return boolean is_gui
|
||||||
|
function M.is_graphical()
|
||||||
|
local env = vim.env
|
||||||
|
local term_program = env.TERM_PROGRAM -- macOS GUI 終端機常見
|
||||||
|
local display = env.DISPLAY -- Linux X11
|
||||||
|
local wayland = env.WAYLAND_DISPLAY -- Linux Wayland
|
||||||
|
local ssh = env.SSH_CONNECTION or env.SSH_CLIENT
|
||||||
|
|
||||||
|
if ssh then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
return term_program or display or wayland and true or false
|
||||||
|
end
|
||||||
|
|
||||||
|
return M
|
Loading…
x
Reference in New Issue
Block a user