mirror of
https://github.com/cap153/nvim.git
synced 2026-05-01 10:55:49 +08:00
适配我的termux、架构判断提取为全局变量、重写ufo使用lsp折叠相关配置
This commit is contained in:
parent
08a226d9ee
commit
ca576a6090
7 changed files with 33 additions and 37 deletions
|
|
@ -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', '<sC-c>', '"+y', { noremap = true })
|
||||
vim.keymap.set('v', '<sC-c>', '"+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', '<sC-v>', '"+p', { noremap = true })
|
||||
vim.keymap.set('v', '<sC-v>', '"+P', { noremap = true })
|
||||
|
|
@ -22,9 +13,15 @@ if vim.g.neovide then
|
|||
vim.keymap.set('t', '<sC-v>', '<C-\\><C-n>"+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
|
||||
|
|
|
|||
|
|
@ -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 = { -- 后缀名
|
||||
|
|
|
|||
|
|
@ -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>" .. cmd .. "<CR>", { silent = true })
|
||||
end
|
||||
|
||||
local function maplua(modes, key, action, desc)
|
||||
|
|
@ -133,10 +131,10 @@ mapkey({ "n", "x", "o" }, "<LEADER>n", "<C-w>h")
|
|||
mapkey({ "n", "x", "o" }, "<LEADER>i", "<C-w>l")
|
||||
|
||||
-- 使用s + 新方向键 进行分屏
|
||||
mapcmd("su", "set nosplitbelow<CR>:split<CR>:set splitbelow")
|
||||
mapcmd("se", "set splitbelow<CR>:split")
|
||||
mapcmd("sn", "set nosplitright<CR>:vsplit<CR>:set splitright")
|
||||
mapcmd("si", "set splitright<CR>:vsplit")
|
||||
mapcmd("su", "leftabove split") -- 在上方分屏
|
||||
mapcmd("se", "rightbelow split") -- 在下方分屏
|
||||
mapcmd("sn", "leftabove vsplit") -- 在左侧分屏
|
||||
mapcmd("si", "rightbelow vsplit") -- 在右侧分屏
|
||||
|
||||
-- 使用方向键来调整窗口大小
|
||||
mapcmd("<up>", "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>" .. cmd .. "<CR>", { silent = true })
|
||||
end
|
||||
|
||||
function map:lua(key, txt_or_func)
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ local ensure_installed = {
|
|||
"python",
|
||||
"lua",
|
||||
"markdown",
|
||||
"bash",
|
||||
"sh",
|
||||
"java",
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue