Add set_cache function
This commit is contained in:
@@ -35,4 +35,11 @@ function M.get_state(class)
|
||||
return M.is_active() and 'active' or 'inactive'
|
||||
end
|
||||
|
||||
function M.set_cache(augroup)
|
||||
cmd(string.format('augroup %s', augroup))
|
||||
cmd('autocmd!')
|
||||
cmd(string.format('autocmd CursorHold,BufWritePost * unlet! b:%s', augroup))
|
||||
cmd('augroup END')
|
||||
end
|
||||
|
||||
return M
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
local cmd, fn, vim = vim.cmd, vim.fn, vim
|
||||
local b, bo = vim.b, vim.bo
|
||||
local common = require('hardline.common')
|
||||
|
||||
local enabled = false
|
||||
local cache = ''
|
||||
@@ -49,10 +50,7 @@ end
|
||||
|
||||
local function get_item()
|
||||
if not enabled then
|
||||
cmd 'augroup hardline_whitespace'
|
||||
cmd 'autocmd!'
|
||||
cmd 'autocmd CursorHold,BufWritePost * unlet! b:hardline_whitespace'
|
||||
cmd 'augroup END'
|
||||
common.set_cache('hardline_whitespace')
|
||||
enabled = true
|
||||
end
|
||||
if bo.readonly or not bo.modifiable then return '' end
|
||||
|
||||
@@ -33,10 +33,7 @@ end
|
||||
|
||||
local function get_item()
|
||||
if not enabled then
|
||||
cmd 'augroup hardline_wordcount'
|
||||
cmd 'autocmd!'
|
||||
cmd 'autocmd CursorHold,BufWritePost * unlet! b:hardline_wordcount'
|
||||
cmd 'augroup END'
|
||||
common.set_cache('hardline_wordcount')
|
||||
enabled = true
|
||||
end
|
||||
if not vim.tbl_contains(options.filetypes, bo.filetype) then return '' end
|
||||
|
||||
Reference in New Issue
Block a user