diff --git a/lua/core/cursor.lua b/lua/core/cursor.lua index 9be53f5..d3d20aa 100644 --- a/lua/core/cursor.lua +++ b/lua/core/cursor.lua @@ -2,18 +2,9 @@ -- === 光标移动neovide -- === -- 判断 CPU 架构 -local arch = jit and jit.arch or "" -local is_arm = arch:match("arm") or arch:match("aarch64") -if is_arm then - vim.o.guifont = "ComicShannsMono Nerd Font:h24" -end vim.keymap.set('n', '', '"+y', { noremap = true }) vim.keymap.set('v', '', '"+y', { noremap = true }) if vim.g.neovide then - if not is_arm then - vim.env.HTTP_PROXY = "http://127.0.0.1:7897" - vim.env.HTTPS_PROXY = "http://127.0.0.1:7897" - end -- https://github.com/neovide/neovide/issues/1282 vim.keymap.set('n', '', '"+p', { noremap = true }) vim.keymap.set('v', '', '"+P', { noremap = true }) @@ -22,9 +13,15 @@ if vim.g.neovide then vim.keymap.set('t', '', '"+Pi', { noremap = true }) vim.g.neovide_opacity = 0.75 -- vim.o.guifont = "ComicShannsMono Nerd Font:h16" -- text below applies for VimScript - vim.o.guifont = "Ioskeley Mono:h15" -- text below applies for VimScript + vim.o.guifont = "Ioskeley_Mono,Noto_Sans_CJK_SC:h15" -- text below applies for VimScript -- 全屏,可以在i3和sway的配置中设置 -- vim.g.neovide_fullscreen = true + if not IS_ARM then + vim.env.HTTP_PROXY = "http://127.0.0.1:7897" + vim.env.HTTPS_PROXY = "http://127.0.0.1:7897" + else + vim.o.guifont = "Ioskeley_Mono,Noto_Sans_CJK_SC:h24" + end end -- === -- === map function diff --git a/lua/core/init.lua b/lua/core/init.lua index 5e9681b..dbbd2e9 100644 --- a/lua/core/init.lua +++ b/lua/core/init.lua @@ -71,6 +71,10 @@ autocmd BufLeave * :silent !fcitx5-remote -c ]]) -- 意为: 当 进入插入模式、创建Buf、进入Buf、离开Buf 时 触发shell命令 fcitx-remote -c 关闭输入法,改为英文输入 +-- 架构判断 +local arch = jit and jit.arch or "" +_G.IS_ARM = arch:match("arm") or arch:match("aarch64") ~= nil + -- 日志高亮关键字 vim.filetype.add({ extension = { -- 后缀名 diff --git a/lua/core/keymap.lua b/lua/core/keymap.lua index 2f7f49d..f61a48d 100644 --- a/lua/core/keymap.lua +++ b/lua/core/keymap.lua @@ -7,9 +7,7 @@ local function mapkey(mode, lhs, rhs, opts) end local function mapcmd(key, cmd) - vim.keymap.set("n", key, function() - vim.cmd(cmd) - end, { silent = true }) + vim.keymap.set("n", key, "" .. cmd .. "", { silent = true }) end local function maplua(modes, key, action, desc) @@ -133,10 +131,10 @@ mapkey({ "n", "x", "o" }, "n", "h") mapkey({ "n", "x", "o" }, "i", "l") -- 使用s + 新方向键 进行分屏 -mapcmd("su", "set nosplitbelow:split:set splitbelow") -mapcmd("se", "set splitbelow:split") -mapcmd("sn", "set nosplitright:vsplit:set splitright") -mapcmd("si", "set splitright:vsplit") +mapcmd("su", "leftabove split") -- 在上方分屏 +mapcmd("se", "rightbelow split") -- 在下方分屏 +mapcmd("sn", "leftabove vsplit") -- 在左侧分屏 +mapcmd("si", "rightbelow vsplit") -- 在右侧分屏 -- 使用方向键来调整窗口大小 mapcmd("", "res +5") @@ -304,9 +302,7 @@ function map:key(mode, lhs, rhs) end function map:cmd(key, cmd) - vim.keymap.set("n", key, function() - vim.cmd(cmd) - end, { silent = true }) + vim.keymap.set("n", key, "" .. cmd .. "", { silent = true }) end function map:lua(key, txt_or_func) diff --git a/lua/pack/configs/lspconfig.lua b/lua/pack/configs/lspconfig.lua index 963a8d5..20ed12e 100644 --- a/lua/pack/configs/lspconfig.lua +++ b/lua/pack/configs/lspconfig.lua @@ -1,12 +1,8 @@ -- === LSP 核心配置 (Lspconfig + Mason) === if vim.g.vscode then return end --- 环境探测:判断 CPU 架构,决定安装哪些 LSP -local arch = jit and jit.arch or "" -local is_arm = arch:match("arm") or arch:match("aarch64") - local servers = { "lua_ls", "rust_analyzer", "pylsp", "denols", } -if not is_arm then +if not IS_ARM then vim.list_extend(servers, { "marksman", "svelte", "cssls", "html" }) end diff --git a/lua/pack/configs/peek.lua b/lua/pack/configs/peek.lua index 4da38d5..91cebc5 100644 --- a/lua/pack/configs/peek.lua +++ b/lua/pack/configs/peek.lua @@ -13,11 +13,16 @@ vim.api.nvim_create_user_command("PeekToggle", function() local peek = require("peek") if not peek.is_open() and vim.bo[vim.api.nvim_get_current_buf()].filetype == 'markdown' then PackUtils.load(P, function() + local app = { "chromium", "--app=http://localhost:9000/?theme=dark", "--incognito" } + if IS_ARM then + app = { "chromium", "--no-sandbox", "--app=http://localhost:9000/?theme=dark", "--incognito", "--test-type", + "--force-device-scale-factor=1.75" } + end require("peek").setup({ port = 9000, -- app = { "zen", "-private-window" }, -- app = { "firefox-esr", "-private-window" }, - app = { "chromium", "--app=http://localhost:9000/?theme=dark", "--incognito" }, + app = app }) end) peek.open() diff --git a/lua/pack/configs/treesitter.lua b/lua/pack/configs/treesitter.lua index 8ac6456..dd78a79 100644 --- a/lua/pack/configs/treesitter.lua +++ b/lua/pack/configs/treesitter.lua @@ -14,7 +14,7 @@ local ensure_installed = { "python", "lua", "markdown", - "bash", + "sh", "java", } diff --git a/lua/pack/configs/ufo.lua b/lua/pack/configs/ufo.lua index 63142d2..34c8327 100644 --- a/lua/pack/configs/ufo.lua +++ b/lua/pack/configs/ufo.lua @@ -20,16 +20,14 @@ vim.api.nvim_create_autocmd({ vim.schedule(function() PackUtils.load(P, function() -- Option 2: nvim lsp as LSP client - local capabilities = vim.lsp.protocol.make_client_capabilities() - capabilities.textDocument.foldingRange = { - dynamicRegistration = false, - lineFoldingOnly = true, - } - local language_servers = vim.lsp.get_clients() -- or list servers manually like {'gopls', 'clangd'} - for _, ls in ipairs(language_servers) do - require("lspconfig")[ls].setup({ - capabilities = capabilities, - }) + local orig_make_client_capabilities = vim.lsp.protocol.make_client_capabilities + vim.lsp.protocol.make_client_capabilities = function() + local caps = orig_make_client_capabilities() + caps.textDocument.foldingRange = { + dynamicRegistration = false, + lineFoldingOnly = true + } + return caps end require("ufo").setup({}) -- Option 3: treesitter as a main provider instead