Skip to content

Commit

Permalink
Provide update_events as an alias for updateevents.
Browse files Browse the repository at this point in the history
`updateevents` will continue working, but `update_events` is in line
with other config-keys, so recommend using that.
  • Loading branch information
L3MON4D3 committed Mar 20, 2022
1 parent df76732 commit 1c82128
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Examples/snippets.lua
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ local conds = require("luasnip.extras.expand_conditions")
ls.config.set_config({
history = true,
-- Update more often, :h events for more info.
updateevents = "TextChanged,TextChangedI",
update_events = "TextChanged,TextChangedI",
-- Snippets aren't automatically removed if their text is deleted.
-- `delete_check_events` determines on which events (:h events) a check for
-- deleted snippets is performed.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ The [Wiki](https://github.com/L3MON4D3/LuaSnip/wiki) contains some pretty useful

# Config
- `history`: If true, Snippets that were exited can still be jumped back into. As Snippets are not removed when their text is deleted, they have to be removed manually via `LuasnipUnlinkCurrent` if `delete_check_events` is not enabled (set to eg. `'TextChanged'`).
- `updateevents`: Choose which events trigger an update of the active nodes' dependents. Default is just `'InsertLeave'`, `'TextChanged,TextChangedI'` would update on every change.
- `update_events`: Choose which events trigger an update of the active nodes' dependents. Default is just `'InsertLeave'`, `'TextChanged,TextChangedI'` would update on every change.
- `region_check_events`: Events on which to leave the current snippet if the cursor is outside its' 'region'. Disabled by default, `'CursorMoved'`, `'CursorHold'` or `'InsertEnter'` seem reasonable.
- `delete_check_events`: When to check if the current snippet was deleted, and if so, remove it from the history. Off by default, `'TextChanged'` (perhaps `'InsertLeave'`, to react to changes done in Insert mode) should work just fine (alternatively, this can also be mapped using `<Plug>luasnip-delete-check`).
- `store_selection_keys`: Mapping for populating `TM_SELECTED_TEXT` and related variables (not set by default).
Expand Down
10 changes: 8 additions & 2 deletions lua/luasnip/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ local session = require("luasnip.session")

local defaults = {
history = false,
updateevents = "InsertLeave",
update_events = "InsertLeave",
-- see :h User, event should never be triggered(except if it is `doautocmd`'d)
region_check_events = "User None",
delete_check_events = "User None",
Expand Down Expand Up @@ -120,6 +120,12 @@ c = {
)
ext_util.child_extend(user_config.ext_opts, conf.ext_opts)

-- use value from update_events, then updateevents.
-- also nil updateevents, don't spill it into the main config.
user_config.update_events = user_config.update_events
or user_config.updateevents
user_config.updateevents = nil

for k, v in pairs(user_config) do
conf[k] = v
end
Expand Down Expand Up @@ -149,7 +155,7 @@ c = {
augroup END
]],
session.config.delete_check_events,
session.config.updateevents,
session.config.update_events,
session.config.region_check_events
)
)
Expand Down

0 comments on commit 1c82128

Please sign in to comment.