fix: is_modifiable & is_readonly checks were wrong
This commit is contained in:
parent
0499e77aa5
commit
f05607c87c
10
init.lua
10
init.lua
|
@ -335,12 +335,12 @@ local on_attach = function(_, bufnr)
|
|||
group = vim.api.nvim_create_augroup('AutoSave', { clear = true }),
|
||||
buffer = bufnr,
|
||||
callback = function()
|
||||
local is_modifiable = vim.fn.getbufvar(bufnr, "&modifiable")
|
||||
local is_readonly = vim.fn.getbufvar(bufnr, "&readonly")
|
||||
local buftype = vim.api.nvim_buf_get_option(bufnr, "buftype")
|
||||
local is_modified = vim.api.nvim_buf_get_option(bufnr, "modified")
|
||||
local is_modifiable = vim.fn.getbufvar(bufnr, '&modifiable') == 1
|
||||
local is_readonly = vim.fn.getbufvar(bufnr, '&readonly') == 1
|
||||
local buftype = vim.api.nvim_buf_get_option(bufnr, 'buftype')
|
||||
local is_modified = vim.api.nvim_buf_get_option(bufnr, 'modified')
|
||||
|
||||
if is_modifiable and not is_readonly and buftype == "" and is_modified then
|
||||
if is_modifiable and not is_readonly and buftype == '' and is_modified then
|
||||
vim.cmd 'w'
|
||||
end
|
||||
end,
|
||||
|
|
Loading…
Reference in New Issue