aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/lsp/inline_completion.lua
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2026-05-20 17:33:01 -0400
committerGitHub <noreply@github.com>2026-05-20 17:33:01 -0400
commit9aa4608401384a59ea54e0ba800ce063775e8ae9 (patch)
tree6292c7eb1c09d2f0fbc055410bd8a38e58052982 /runtime/lua/vim/lsp/inline_completion.lua
parent799cbfff855c72282a54646f3e5e1b71b0da223c (diff)
downloadrneovim-9aa4608401384a59ea54e0ba800ce063775e8ae9.tar.gz
rneovim-9aa4608401384a59ea54e0ba800ce063775e8ae9.tar.bz2
rneovim-9aa4608401384a59ea54e0ba800ce063775e8ae9.zip
refactor: introduce nvim_on internally #39883
Problem: `nvim_create_autocmd` is too verbose and its `callback` requires extra "nesting". Solution: Introduce `nvim_on`. Start using it internally. Then we can get a feel for how it should look before making it public.
Diffstat (limited to 'runtime/lua/vim/lsp/inline_completion.lua')
-rw-r--r--runtime/lua/vim/lsp/inline_completion.lua21
1 files changed, 7 insertions, 14 deletions
diff --git a/runtime/lua/vim/lsp/inline_completion.lua b/runtime/lua/vim/lsp/inline_completion.lua
index 7dae0c717b..76e15658a5 100644
--- a/runtime/lua/vim/lsp/inline_completion.lua
+++ b/runtime/lua/vim/lsp/inline_completion.lua
@@ -40,6 +40,7 @@ local log = require('vim.lsp.log')
local protocol = require('vim.lsp.protocol')
local grammar = require('vim.lsp._snippet_grammar')
local api = vim.api
+local nvim_on = require('vim._core.util').nvim_on
local Capability = require('vim.lsp._capability')
@@ -78,20 +79,12 @@ Capability.all[Completor.name] = Completor
function Completor:new(buf)
self = Capability.new(self, buf)
self.client_state = {}
- api.nvim_create_autocmd({ 'InsertEnter', 'CursorMovedI', 'TextChangedP' }, {
- group = self.augroup,
- buf = buf,
- callback = function()
- self:automatic_request()
- end,
- })
- api.nvim_create_autocmd({ 'InsertLeave' }, {
- group = self.augroup,
- buf = buf,
- callback = function()
- self:abort()
- end,
- })
+ nvim_on({ 'InsertEnter', 'CursorMovedI', 'TextChangedP' }, self.augroup, { buf = buf }, function()
+ self:automatic_request()
+ end)
+ nvim_on({ 'InsertLeave' }, self.augroup, { buf = buf }, function()
+ self:abort()
+ end)
return self
end