feat(ftplugin): set Lua 'omnifunc' to vim.lua_omnifunc #32491

Problem:
- Many other ftplugin have defined 'omnifunc', but the Lua one doesn't
  define one, even though there is `vim.lua_omnifunc()`
- Users may want "stupid" completion to fix Lua config with
  `nvim --clean` in case they breaks it

Solution:
Set 'omnifunc' to 'v:lua.vim.lua_omnifunc' in ftplugin/lua.lua
This commit is contained in:
Phạm Bình An
2025-02-23 22:57:16 +07:00
committed by GitHub
parent b283736388
commit f398e3a61a
3 changed files with 12 additions and 1 deletions

View File

@ -1502,6 +1502,11 @@ both major engines implemented element, even if this is not in standards it
will be suggested. All other elements are not placed in suggestion list.
LUA *ft-lua-omni*
Lua |ftplugin| sets 'omnifunc' to |vim.lua_omnifunc()|.
PHP *ft-php-omni*
Completion of PHP code requires a tags file for completion of data from

View File

@ -239,6 +239,9 @@ DEFAULTS
• |[b|, |]b|, |[B|, |]B| navigate through the |buffer-list|
• |[<Space>|, |]<Space>| add an empty line above and below the cursor
• Options:
• Lua |ftplugin| sets |'omnifunc'| to `"v:lua.vim.lua_omnifunc"`.
• Snippet:
• `<Tab>` in Insert and Select mode maps to `vim.snippet.jump({ direction = 1 })`
when a snippet is active and jumpable forwards.

View File

@ -1,4 +1,7 @@
-- use treesitter over syntax
vim.treesitter.start()
vim.b.undo_ftplugin = (vim.b.undo_ftplugin or '') .. '\n call v:lua.vim.treesitter.stop()'
vim.bo.omnifunc = 'v:lua.vim.lua_omnifunc'
vim.b.undo_ftplugin = (vim.b.undo_ftplugin or '')
.. '\n call v:lua.vim.treesitter.stop() \n setl omnifunc<'