From 128ad8bc0eb6ab3c635c41cd88a33fa68e3b5983 Mon Sep 17 00:00:00 2001 From: Ashkan Kiani Date: Thu, 24 Oct 2019 11:37:44 -0700 Subject: Update issue templates --- .github/ISSUE_TEMPLATE/bug.md | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/bug.md diff --git a/.github/ISSUE_TEMPLATE/bug.md b/.github/ISSUE_TEMPLATE/bug.md new file mode 100644 index 0000000..76c8566 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug.md @@ -0,0 +1,31 @@ +--- +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 + +**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. -- cgit v1.2.3-70-g09d2 From 174b7a67ce384318f7500e0d256322e1cbba5e5b Mon Sep 17 00:00:00 2001 From: Ashkan Kiani Date: Sat, 26 Oct 2019 13:16:51 -0700 Subject: Update bug.md --- .github/ISSUE_TEMPLATE/bug.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/ISSUE_TEMPLATE/bug.md b/.github/ISSUE_TEMPLATE/bug.md index 76c8566..4cfa53e 100644 --- a/.github/ISSUE_TEMPLATE/bug.md +++ b/.github/ISSUE_TEMPLATE/bug.md @@ -22,6 +22,9 @@ 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 -- cgit v1.2.3-70-g09d2 From ee1a2f0a746c26e0aea35d40de9ec0335952556f Mon Sep 17 00:00:00 2001 From: James Reed Date: Wed, 6 Nov 2019 11:04:58 -0700 Subject: Add function to check if attached to a buffer --- lua/colorizer.lua | 11 +++++++++++ 1 file changed, 11 insertions(+) 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; -- cgit v1.2.3-70-g09d2 From 6da5d9ba2375c9979ec2f406e0ef8872e31dbc04 Mon Sep 17 00:00:00 2001 From: James Reed Date: Wed, 6 Nov 2019 11:28:25 -0700 Subject: Implement ColorizerToggle command Closes #27. --- README.md | 4 ++++ doc/colorizer-lua.txt | 4 ++++ plugin/colorizer.vim | 3 +++ 3 files changed, 11 insertions(+) diff --git a/README.md b/README.md index 6942df2..d8e5d47 100644 --- a/README.md +++ b/README.md @@ -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/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 -- cgit v1.2.3-70-g09d2