mirror of
				https://github.com/neovim/neovim.git
				synced 2025-10-26 12:27:24 +00:00 
			
		
		
		
	docs: document breaking change for nvim_create_autocmd callback (#27484)
https://github.com/neovim/neovim/pull/27428 changed the semantics of callbacks passed to nvim_create_autocmd such that any truthy value will delete the autocommand (rather than just the literal boolean value `true`). Update the documentation accordingly and add an entry to `news.txt`. The behavior is now consistent between nvim_create_autocmd and nvim_buf_attach.
This commit is contained in:
		| @@ -2099,8 +2099,9 @@ nvim_buf_attach({buffer}, {send_buffer}, {*opts})          *nvim_buf_attach()* | |||||||
|                        will be `nvim_buf_changedtick_event`. Not for Lua |                        will be `nvim_buf_changedtick_event`. Not for Lua | ||||||
|                        callbacks. |                        callbacks. | ||||||
|       • {opts}         Optional parameters. |       • {opts}         Optional parameters. | ||||||
|                        • on_lines: Lua callback invoked on change. Return `true` to |                        • on_lines: Lua callback invoked on change. Return a | ||||||
|                          detach. Args: |                          truthy value (not `false` or `nil`) | ||||||
|  |                          to detach. Args: | ||||||
|                          • the string "lines" |                          • the string "lines" | ||||||
|                          • buffer handle |                          • buffer handle | ||||||
|                          • b:changedtick |                          • b:changedtick | ||||||
| @@ -2113,7 +2114,8 @@ nvim_buf_attach({buffer}, {send_buffer}, {*opts})          *nvim_buf_attach()* | |||||||
|  |  | ||||||
|                        • on_bytes: Lua callback invoked on change. This |                        • on_bytes: Lua callback invoked on change. This | ||||||
|                          callback receives more granular information about the |                          callback receives more granular information about the | ||||||
|                          change compared to on_lines. Return `true` to |                          change compared to on_lines. Return a truthy value | ||||||
|  |                          (not `false` or `nil`) to | ||||||
|                          detach. Args: |                          detach. Args: | ||||||
|                          • the string "bytes" |                          • the string "bytes" | ||||||
|                          • buffer handle |                          • buffer handle | ||||||
| @@ -3457,9 +3459,9 @@ nvim_create_autocmd({event}, {*opts})                  *nvim_create_autocmd()* | |||||||
|                    troubleshooting). |                    troubleshooting). | ||||||
|                  • callback (function|string) optional: Lua function (or |                  • callback (function|string) optional: Lua function (or | ||||||
|                    Vimscript function name, if string) called when the |                    Vimscript function name, if string) called when the | ||||||
|                    event(s) is triggered. Lua callback can return true to |                    event(s) is triggered. Lua callback can return a truthy | ||||||
|                    delete the autocommand, and receives a table argument with |                    value (not `false` or `nil`) to delete the | ||||||
|                    these keys: |                    autocommand. Receives a table argument with these keys: | ||||||
|                    • id: (number) autocommand id |                    • id: (number) autocommand id | ||||||
|                    • event: (string) name of the triggered event |                    • event: (string) name of the triggered event | ||||||
|                      |autocmd-events| |                      |autocmd-events| | ||||||
|   | |||||||
| @@ -122,6 +122,9 @@ The following changes may require adaptations in user config or plugins. | |||||||
|  |  | ||||||
| • |shm-q| now fully hides macro recording message instead of only shortening it. | • |shm-q| now fully hides macro recording message instead of only shortening it. | ||||||
|  |  | ||||||
|  | • Returning any truthy value from a callback passed to |nvim_create_autocmd()| | ||||||
|  |   (rather than just `true`) will delete the autocommand. | ||||||
|  |  | ||||||
| ============================================================================== | ============================================================================== | ||||||
| BREAKING CHANGES IN HEAD                                    *news-breaking-dev* | BREAKING CHANGES IN HEAD                                    *news-breaking-dev* | ||||||
|  |  | ||||||
|   | |||||||
							
								
								
									
										14
									
								
								runtime/lua/vim/_meta/api.lua
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										14
									
								
								runtime/lua/vim/_meta/api.lua
									
									
									
										generated
									
									
									
								
							| @@ -155,8 +155,9 @@ function vim.api.nvim_buf_add_highlight(buffer, ns_id, hl_group, line, col_start | |||||||
| ---                    will be `nvim_buf_changedtick_event`. Not for Lua | ---                    will be `nvim_buf_changedtick_event`. Not for Lua | ||||||
| ---                    callbacks. | ---                    callbacks. | ||||||
| --- @param opts vim.api.keyset.buf_attach Optional parameters. | --- @param opts vim.api.keyset.buf_attach Optional parameters. | ||||||
| ---                    • on_lines: Lua callback invoked on change. Return `true` to | ---                    • on_lines: Lua callback invoked on change. Return a | ||||||
| ---                      detach. Args: | ---                      truthy value (not `false` or `nil`) | ||||||
|  | ---                      to detach. Args: | ||||||
| ---                      • the string "lines" | ---                      • the string "lines" | ||||||
| ---                      • buffer handle | ---                      • buffer handle | ||||||
| ---                      • b:changedtick | ---                      • b:changedtick | ||||||
| @@ -169,7 +170,8 @@ function vim.api.nvim_buf_add_highlight(buffer, ns_id, hl_group, line, col_start | |||||||
| --- | --- | ||||||
| ---                    • on_bytes: Lua callback invoked on change. This | ---                    • on_bytes: Lua callback invoked on change. This | ||||||
| ---                      callback receives more granular information about the | ---                      callback receives more granular information about the | ||||||
| ---                      change compared to on_lines. Return `true` to | ---                      change compared to on_lines. Return a truthy value | ||||||
|  | ---                      (not `false` or `nil`) to | ||||||
| ---                      detach. Args: | ---                      detach. Args: | ||||||
| ---                      • the string "bytes" | ---                      • the string "bytes" | ||||||
| ---                      • buffer handle | ---                      • buffer handle | ||||||
| @@ -863,9 +865,9 @@ function vim.api.nvim_create_augroup(name, opts) end | |||||||
| ---                troubleshooting). | ---                troubleshooting). | ||||||
| ---              • callback (function|string) optional: Lua function (or | ---              • callback (function|string) optional: Lua function (or | ||||||
| ---                Vimscript function name, if string) called when the | ---                Vimscript function name, if string) called when the | ||||||
| ---                event(s) is triggered. Lua callback can return true to | ---                event(s) is triggered. Lua callback can return a truthy | ||||||
| ---                delete the autocommand, and receives a table argument with | ---                value (not `false` or `nil`) to delete the | ||||||
| ---                these keys: | ---                autocommand. Receives a table argument with these keys: | ||||||
| ---                • id: (number) autocommand id | ---                • id: (number) autocommand id | ||||||
| ---                • event: (string) name of the triggered event | ---                • event: (string) name of the triggered event | ||||||
| ---                  `autocmd-events` | ---                  `autocmd-events` | ||||||
|   | |||||||
| @@ -378,8 +378,9 @@ cleanup: | |||||||
| ///             |autocmd-buflocal|. Cannot be used with {pattern}. | ///             |autocmd-buflocal|. Cannot be used with {pattern}. | ||||||
| ///             - desc (string) optional: description (for documentation and troubleshooting). | ///             - desc (string) optional: description (for documentation and troubleshooting). | ||||||
| ///             - callback (function|string) optional: Lua function (or Vimscript function name, if | ///             - callback (function|string) optional: Lua function (or Vimscript function name, if | ||||||
| ///             string) called when the event(s) is triggered. Lua callback can return true to | ///             string) called when the event(s) is triggered. Lua callback can return a truthy | ||||||
| ///             delete the autocommand, and receives a table argument with these keys: | ///             value (not `false` or `nil`) to delete the autocommand. Receives a table argument | ||||||
|  | ///             with these keys: | ||||||
| ///                 - id: (number) autocommand id | ///                 - id: (number) autocommand id | ||||||
| ///                 - event: (string) name of the triggered event |autocmd-events| | ///                 - event: (string) name of the triggered event |autocmd-events| | ||||||
| ///                 - group: (number|nil) autocommand group id, if any | ///                 - group: (number|nil) autocommand group id, if any | ||||||
|   | |||||||
| @@ -112,7 +112,7 @@ Integer nvim_buf_line_count(Buffer buffer, Error *err) | |||||||
| ///        Not for Lua callbacks. | ///        Not for Lua callbacks. | ||||||
| /// @param  opts  Optional parameters. | /// @param  opts  Optional parameters. | ||||||
| ///             - on_lines: Lua callback invoked on change. | ///             - on_lines: Lua callback invoked on change. | ||||||
| ///               Return `true` to detach. Args: | ///               Return a truthy value (not `false` or `nil`) to detach. Args: | ||||||
| ///               - the string "lines" | ///               - the string "lines" | ||||||
| ///               - buffer handle | ///               - buffer handle | ||||||
| ///               - b:changedtick | ///               - b:changedtick | ||||||
| @@ -125,8 +125,7 @@ Integer nvim_buf_line_count(Buffer buffer, Error *err) | |||||||
| ///             - on_bytes: Lua callback invoked on change. | ///             - on_bytes: Lua callback invoked on change. | ||||||
| ///               This callback receives more granular information about the | ///               This callback receives more granular information about the | ||||||
| ///               change compared to on_lines. | ///               change compared to on_lines. | ||||||
| ///               Return `true` to detach. | ///               Return a truthy value (not `false` or `nil`) to detach. Args: | ||||||
| ///               Args: |  | ||||||
| ///               - the string "bytes" | ///               - the string "bytes" | ||||||
| ///               - buffer handle | ///               - buffer handle | ||||||
| ///               - b:changedtick | ///               - b:changedtick | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Gregory Anders
					Gregory Anders