Files
dotfiles/dot_config/nvim/lua/core/options.lua.tmpl
2025-08-20 15:05:01 +09:00

93 lines
2.2 KiB
Cheetah
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

vim.cmd([[
try
if exists('+termguicolors')
set termguicolors
endif
colorscheme catppuccin
catch
colorscheme desert
endtry
]])
vim.g.mapleader = " "
vim.opt.incsearch = true
vim.opt.ignorecase = true
vim.opt.smartcase = true
vim.cmd(":filetype plugin indent on")
vim.cmd(":syntax enable")
vim.opt.backspace = "indent,eol,start"
vim.opt.smarttab = true
vim.opt.cursorline = true
vim.opt.ruler = true
vim.opt.wildmenu = true
vim.opt.gdefault = true vim.opt.autoread = true vim.opt.history = 1000
vim.opt.encoding = "utf-8"
vim.opt.number = true
vim.opt.relativenumber = true
vim.opt.scrolloff = 12
vim.opt.laststatus = 2
vim.opt.showcmd = true
vim.opt.showmatch = true
vim.opt.cmdheight = 3
vim.opt.list = true
vim.opt.listchars = "tab:>>,trail:_,eol:$,multispace:··,extends:>,precedes:<,nbsp:%"
vim.opt.encoding = "utf-8"
vim.opt.fenc = "utf-8"
vim.opt.spell = true
vim.opt.undofile = true
vim.opt.undodir = vim.fn.expand("~/.cache/nvim/undo")
if vim.fn.executable('rg') then
vim.opt.grepprg = 'rg --vimgrep --smart-case --hidden'
end
{{- if eq .chezmoi.username "root" }}
vim.opt.expandtab = false
{{- else }}
vim.opt.expandtab = true
{{- end }}
vim.opt.tabstop = 4
vim.opt.shiftwidth = 4
-- abbreviations
vim.cmd(":ca cd. lcd %:p:h")
vim.cmd(':ca mkdir. call mkdir(expand("%:p:h"), "p")')
{{- if ne .chezmoi.username "root" }}
vim.cmd(':ca W! w !sudo -A tee %')
{{- end }}
{{- if (and (eq .hosttype "desktop" "laptop") (eq .chezmoi.os "linux")) }}
vim.cmd([[ autocmd InsertLeave * call system("fcitx5-remote -c") ]])
{{- end }}
vim.cmd("set clipboard+=unnamedplus")
-- folding
vim.opt.fillchars = { fold = " " }
vim.opt.foldmethod = "indent"
vim.opt.foldenable = false
vim.opt.foldlevel = 99
vim.g.markdown_folding = 1 -- enable markdown folding
-- auto undo break (insert mode)
local function map_undobreak(chars)
local term = vim.api.nvim_replace_termcodes("<C-g>u", true, false, true)
for _, ch in ipairs(chars) do
vim.keymap.set("i", ch, function() return term .. ch end,
{ expr = true, silent = true, desc = "undobreak before '" .. ch .. "'" })
end
end
map_undobreak({
".", ",", "!", "?", ";", ":", ")", "]", "}", ">", -- 英文系
"。", "、", "", "", "", "", "", "", "」", "』", "" -- 和文系
})