diff options
-rw-r--r-- | .github/ISSUE_TEMPLATE/bug.md | 34 | ||||
-rw-r--r-- | README.md | 4 | ||||
-rw-r--r-- | doc/colorizer-lua.txt | 4 | ||||
-rw-r--r-- | lua/colorizer.lua | 11 | ||||
-rw-r--r-- | plugin/colorizer.vim | 3 |
5 files changed, 56 insertions, 0 deletions
diff --git a/.github/ISSUE_TEMPLATE/bug.md b/.github/ISSUE_TEMPLATE/bug.md new file mode 100644 index 0000000..4cfa53e --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug.md @@ -0,0 +1,34 @@ +--- +name: Bug +about: Create a bug report +title: 'Bug:' +labels: bug +assignees: norcalli + +--- + +**Describe the bug** +A clear and concise description of what the bug is. + +**To Reproduce** +Your configuration and/or a small reproducible test, and/or the steps required to reproduce. + +**Expected behavior** +A clear and concise description of what you expected to happen. + +**Screenshots** +If applicable, add screenshots to help explain your problem. + +**Operating System:** +e.g. Ubuntu 16.04 + +**Neovim Version:** +e.g. 0.4.2 + +**Colorizer Version:** +Paste the output of + +`find ~/.config/nvim/ -type d -name 'nvim-colorizer.lua' -exec git rev-parse HEAD \;` + +**Additional context** +Add any other context about the problem here. @@ -132,6 +132,10 @@ Stop highlighting the current buffer (detach). Reload all buffers that are being highlighted with new settings from the setup settings (or the defaults). Shortcut for ColorizerAttachToBuffer on every buffer. + +|:ColorizerToggle| + +Toggle highlighting of the current buffer. ``` diff --git a/doc/colorizer-lua.txt b/doc/colorizer-lua.txt index 39a97a2..bcad522 100644 --- a/doc/colorizer-lua.txt +++ b/doc/colorizer-lua.txt @@ -41,6 +41,10 @@ Reload all buffers that are being highlighted with new settings from the setup settings (or the defaults). Shortcut for ColorizerAttachToBuffer on every buffer. +:ColorizerToggle :ColorizerToggle + +Toggle highlighting of the current buffer. + ============================================================================== LUA API DEFINITION *colorizer-lua-api* diff --git a/lua/colorizer.lua b/lua/colorizer.lua index 6f4948f..e47e079 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; diff --git a/plugin/colorizer.vim b/plugin/colorizer.vim index 9617dfb..a8feb12 100644 --- a/plugin/colorizer.vim +++ b/plugin/colorizer.vim @@ -5,5 +5,8 @@ endif command! ColorizerAttachToBuffer lua require'colorizer'.attach_to_buffer(0) command! ColorizerDetachFromBuffer lua require'colorizer'.detach_from_buffer(0) command! ColorizerReloadAllBuffers lua require'colorizer'.reload_all_buffers() +command! ColorizerToggle lua local c = require'colorizer' + \ if c.is_buffer_attached(0) then c.detach_from_buffer(0) else + \ c.attach_to_buffer(0) end let g:loaded_colorizer = 1 |