Skip to content

Commit

Permalink
fix: always restore complete func
Browse files Browse the repository at this point in the history
  • Loading branch information
ms-jpq committed Feb 17, 2025
1 parent 9e77f1f commit c53ca04
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions coq/server/registrants/autocmds.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from pynvim_pp.float_win import list_floatwins
from pynvim_pp.nvim import Nvim
from pynvim_pp.rpc_types import NvimError
from pynvim_pp.settings import Settings
from pynvim_pp.types import NoneType
from std2.asyncio import Cancellation
from std2.locale import si_prefixed_smol
Expand All @@ -20,6 +21,7 @@
from ..context import context
from ..rt_types import Stack
from ..state import state
from .omnifunc import omnifunc

_NS = uuid4()
_die = Cancellation()
Expand Down Expand Up @@ -49,6 +51,20 @@ async def _new_cwd(stack: Stack) -> None:
_ = autocmd("DirChanged") << f"lua {NAMESPACE}.{_new_cwd.method}()"


@rpc()
async def _set_complete_func(stack: Stack) -> None:
with suppress(NvimError):
settings = Settings()
settings["completefunc"] = f"v:lua.{NAMESPACE}.{omnifunc.method}"
await settings.drain().commit(NoneType)


_ = (
autocmd("FileType", "CursorHold", "CursorHoldI", "InsertEnter")
<< f"lua {NAMESPACE}.{_set_complete_func.method}()"
)


@rpc()
async def _ft_changed(stack: Stack) -> None:
for worker in stack.workers:
Expand Down

0 comments on commit c53ca04

Please sign in to comment.