refactor: Move should refresh logic to utils
This commit is contained in:
@@ -56,8 +56,7 @@ local function __refresh ()
|
|||||||
end
|
end
|
||||||
|
|
||||||
local current_buf = vim.api.nvim_get_current_buf()
|
local current_buf = vim.api.nvim_get_current_buf()
|
||||||
if (not lsp_utils.is_buf_markdown(current_buf)) and
|
if lsp_utils.should_not_refresh(current_buf) then
|
||||||
(not lsp_utils.is_buf_attached_to_lsp(current_buf)) then
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,16 @@ function M.is_buf_attached_to_lsp(bufnr)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function M.is_buf_markdown(bufnr)
|
function M.is_buf_markdown(bufnr)
|
||||||
return vim.api.nvim_buf_get_option(bufnr, 'ft') == 'markdown'
|
return vim.api.nvim_buf_get_option(bufnr, 'ft') == 'markdown'
|
||||||
|
end
|
||||||
|
|
||||||
|
---@param bufnr number
|
||||||
|
---@return boolean
|
||||||
|
function M.should_not_refresh(bufnr)
|
||||||
|
if (not M.is_buf_markdown(bufnr)) and (not M.is_buf_attached_to_lsp(bufnr)) then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
|||||||
Reference in New Issue
Block a user