From ad4a0e82dc49d9b019a6fd82dfe953ed01ecbe41 Mon Sep 17 00:00:00 2001 From: jdhao Date: Wed, 2 Apr 2025 21:57:37 +0200 Subject: [PATCH] Simplify condition check (#397) --- lua/plugin_specs.lua | 64 ++++++++++---------------------------------- 1 file changed, 14 insertions(+), 50 deletions(-) diff --git a/lua/plugin_specs.lua b/lua/plugin_specs.lua index 5f201bd..d202524 100644 --- a/lua/plugin_specs.lua +++ b/lua/plugin_specs.lua @@ -77,10 +77,7 @@ local plugin_specs = { { "vlime/vlime", enabled = function() - if utils.executable("sbcl") then - return true - end - return false + return utils.executable("sbcl") end, config = function(plugin) vim.opt.rtp:append(plugin.dir .. "/vim") @@ -236,11 +233,7 @@ local plugin_specs = { vim.g.netrw_nogx = 1 -- disable netrw gx end, enabled = function() - if vim.g.is_win or vim.g.is_mac then - return true - else - return false - end + return vim.g.is_win or vim.g.is_mac end, dependencies = { "nvim-lua/plenary.nvim" }, config = true, -- default settings @@ -252,11 +245,7 @@ local plugin_specs = { { "liuchengxu/vista.vim", enabled = function() - if utils.executable("ctags") then - return true - else - return false - end + return utils.executable("ctags") end, cmd = "Vista", }, @@ -302,10 +291,7 @@ local plugin_specs = { { "lyokha/vim-xkbswitch", enabled = function() - if vim.g.is_mac and utils.executable("xkbswitch") then - return true - end - return false + return vim.g.is_mac and utils.executable("xkbswitch") end, event = { "InsertEnter" }, }, @@ -313,10 +299,7 @@ local plugin_specs = { { "Neur1n/neuims", enabled = function() - if vim.g.is_win then - return true - end - return false + return vim.g.is_win end, event = { "InsertEnter" }, }, @@ -365,22 +348,19 @@ local plugin_specs = { }, -- Another markdown plugin - { "preservim/vim-markdown", ft = { "markdown" } }, + -- { "preservim/vim-markdown", ft = { "markdown" } }, -- Faster footnote generation { "vim-pandoc/vim-markdownfootnotes", ft = { "markdown" } }, -- Vim tabular plugin for manipulate tabular, required by markdown plugins - { "godlygeek/tabular", cmd = { "Tabularize" } }, + { "godlygeek/tabular", ft = { "markdown" } }, -- Markdown previewing (only for Mac and Windows) { "iamcco/markdown-preview.nvim", enabled = function() - if vim.g.is_win or vim.g.is_mac then - return true - end - return false + return vim.g.is_win or vim.g.is_mac end, build = "cd app && npm install && git restore .", ft = { "markdown" }, @@ -389,10 +369,7 @@ local plugin_specs = { { "rhysd/vim-grammarous", enabled = function() - if vim.g.is_mac then - return true - end - return false + return vim.g.is_mac end, ft = { "markdown" }, }, @@ -413,10 +390,7 @@ local plugin_specs = { { "lervag/vimtex", enabled = function() - if utils.executable("latex") then - return true - end - return false + return utils.executable("latex") end, ft = { "tex" }, }, @@ -427,10 +401,7 @@ local plugin_specs = { { "tmux-plugins/vim-tmux", enabled = function() - if utils.executable("tmux") then - return true - end - return false + return utils.executable("tmux") end, ft = { "tmux" }, }, @@ -447,8 +418,7 @@ local plugin_specs = { { "glacambre/firenvim", enabled = function() - local result = vim.g.is_win or vim.g.is_mac - return result + return vim.g.is_win or vim.g.is_mac end, -- it seems that we can only call the firenvim function directly. -- Using vim.fn or vim.cmd to call this function will fail. @@ -471,10 +441,7 @@ local plugin_specs = { { "sakhnik/nvim-gdb", enabled = function() - if vim.g.is_win or vim.g.is_linux then - return true - end - return false + return vim.g.is_win or vim.g.is_linux end, build = { "bash install.sh" }, lazy = true, @@ -486,10 +453,7 @@ local plugin_specs = { { "ojroques/vim-oscyank", enabled = function() - if vim.g.is_linux then - return true - end - return false + return vim.g.is_linux end, cmd = { "OSCYank", "OSCYankReg" }, },