diff options
author | James Reed <jcrd@tuta.io> | 2019-11-06 11:04:58 -0700 |
---|---|---|
committer | Ashkan Kiani <ashkan.k.kiani@gmail.com> | 2019-11-07 20:16:37 -0800 |
commit | ee1a2f0a746c26e0aea35d40de9ec0335952556f (patch) | |
tree | f949e9aa47be1c171769542eb658ec8e5d2e08fb /lua/colorizer.lua | |
parent | Update bug.md (diff) |
Add function to check if attached to a buffer
Diffstat (limited to 'lua/colorizer.lua')
-rw-r--r-- | lua/colorizer.lua | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/lua/colorizer.lua b/lua/colorizer.lua index 657afe7..7fdd206 100644 --- a/lua/colorizer.lua +++ b/lua/colorizer.lua @@ -489,6 +489,16 @@ local function new_buffer_options(buf) return FILETYPE_OPTIONS[filetype] or SETUP_SETTINGS.default_options end +--- Check if attached to a buffer. +-- @tparam[opt=0|nil] integer buf A value of 0 implies the current buffer. +-- @return true if attached to the buffer, false otherwise. +local function is_buffer_attached(buf) + if buf == 0 or buf == nil then + buf = nvim_get_current_buf() + end + return BUFFER_OPTIONS[buf] ~= nil +end + --- Attach to a buffer and continuously highlight changes. -- @tparam[opt=0|nil] integer buf A value of 0 implies the current buffer. -- @param[opt] options Configuration options as described in `setup` @@ -627,6 +637,7 @@ end return { DEFAULT_NAMESPACE = DEFAULT_NAMESPACE; setup = setup; + is_buffer_attached = is_buffer_attached; attach_to_buffer = attach_to_buffer; detach_from_buffer = detach_from_buffer; highlight_buffer = highlight_buffer; |