feat(runtime): Lua ftplugin sets 'omnifunc', 'foldexpr' #32697

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
- Nvim doesn't port Lua foldexpr from Vim

Solution:
- Set 'omnifunc' to 'v:lua.vim.lua_omnifunc' in ftplugin/lua.lua
- Set 'foldexpr' to use treesitter
This commit is contained in:
Phạm Bình An
2025-03-15 23:44:53 +07:00
committed by GitHub
parent afdad5c76e
commit f5714994bc
3 changed files with 15 additions and 1 deletions

View File

@@ -1,4 +1,9 @@
-- 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.wo[0][0].foldexpr = 'v:lua.vim.treesitter.foldexpr()'
vim.b.undo_ftplugin = (vim.b.undo_ftplugin or '')
.. '\n call v:lua.vim.treesitter.stop()'
.. '\n setl omnifunc< foldexpr<'