Skip to content

Commit

Permalink
set nvim foldmethod based on filetype
Browse files Browse the repository at this point in the history
set nvim background
  • Loading branch information
BarretRen committed Apr 10, 2024
1 parent 62be219 commit 4adb45d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
4 changes: 2 additions & 2 deletions nvim/lua/basic.lua
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ vim.opt.splitbelow = true
vim.opt.splitright = true
-- 自动补全不自动选中
vim.opt.completeopt = "menu,menuone,noselect"
-- 代码缩进
vim.opt.foldmethod = "indent"
-- 代码缩进, cmd中根据文件类型设置
-- vim.opt.foldmethod = "indent"
vim.opt.foldlevel = 10
-- 不可见字符的显示
vim.opt.list = false
Expand Down
14 changes: 14 additions & 0 deletions nvim/lua/cmd.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,20 @@ vim.api.nvim_create_autocmd("BufReadPost", {
-- vim.cmd('normal zz')
vim.cmd("silent! foldopen")
end
local is_supported = false
local support_types = { "c", "cpp", "yang", "java"}
for i = 0, #support_types do
if support_types[i] == vim.bo.filetype then
is_supported = true
break
end
end
if is_supported then
vim.opt.foldmethod = "expr"
vim.opt.foldexpr = "nvim_treesitter#foldexpr()"
else
vim.opt.foldmethod = "indent"
end
end,
})

Expand Down
2 changes: 2 additions & 0 deletions nvim/lua/colorscheme.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ local colorscheme
local ctime = os.date("*t")
if ctime.hour < 17 and ctime.hour >= 8 then -- 8 am ~ 6 pm
colorscheme = "noctis_lilac"
vim.opt.background = "light"
else
colorscheme = "noctis_uva"
vim.opt.background = "dark"
end

local status_ok, _ = pcall(vim.cmd, "colorscheme " .. colorscheme)
Expand Down

0 comments on commit 4adb45d

Please sign in to comment.