Skip to content

Commit 02bb730

Browse files
committed
Guard fileencoding option assignment
1 parent 145b908 commit 02bb730

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

nvim/lazy-lock.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"gruvbox": { "branch": "master", "commit": "697c00291db857ca0af00ec154e5bd514a79191f" },
1919
"hop.nvim": { "branch": "v2", "commit": "90db1b2c61b820e230599a04fedcd2679e64bd07" },
2020
"indent-blankline.nvim": { "branch": "master", "commit": "005b56001b2cb30bfa61b7986bc50657816ba4ba" },
21-
"lazy.nvim": { "branch": "main", "commit": "f0f5bbb9e5bfae5e6468f9359ffea3d151418176" },
21+
"lazy.nvim": { "branch": "main", "commit": "db067881fff0fd4be8c00e5bde7492e0e1c77a2f" },
2222
"lightline.vim": { "branch": "master", "commit": "e358557e1a9f9fc860416c8eb2e34c0404078155" },
2323
"mason.nvim": { "branch": "main", "commit": "ad7146aa61dcaeb54fa900144d768f040090bff0" },
2424
"menu": { "branch": "main", "commit": "7a0a4a2896b715c066cfbe320bdc048091874cc6" },

nvim/lua/options.lua

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
require "nvchad.options"
22

33
local opt = vim.opt
4+
local opt_global = vim.opt_global
45
local g = vim.g
56
local fn = vim.fn
67

@@ -10,9 +11,18 @@ opt.backspace = { "indent", "eol", "start" }
1011
opt.colorcolumn = "100"
1112
opt.copyindent = true
1213
opt.cursorline = false
13-
opt.encoding = "utf-8"
14+
opt_global.encoding = "utf-8"
1415
opt.expandtab = true
15-
opt.fileencoding = "utf-8"
16+
local function safe_local_option(name, value)
17+
local ok, err = pcall(vim.api.nvim_set_option_value, name, value, { scope = "local" })
18+
if not ok then
19+
vim.schedule(function()
20+
vim.notify(string.format("Failed to set option %s: %s", name, err), vim.log.levels.DEBUG)
21+
end)
22+
end
23+
end
24+
25+
safe_local_option("fileencoding", "utf-8")
1626
opt.hidden = true
1727
opt.hlsearch = true
1828
opt.incsearch = true

0 commit comments

Comments
 (0)