From f5714994bc4fc578b5f07bca403e7067e6d9b5a0 Mon Sep 17 00:00:00 2001 From: Phạm Bình An <111893501+brianhuster@users.noreply.github.com> Date: Sat, 15 Mar 2025 23:44:53 +0700 Subject: 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 --- runtime/ftplugin/lua.lua | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'runtime/ftplugin') diff --git a/runtime/ftplugin/lua.lua b/runtime/ftplugin/lua.lua index 75deb6b190..e0f7e95cf6 100644 --- a/runtime/ftplugin/lua.lua +++ b/runtime/ftplugin/lua.lua @@ -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<' -- cgit