aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhạm Bình An <111893501+brianhuster@users.noreply.github.com>2025-03-15 23:44:53 +0700
committerGitHub <noreply@github.com>2025-03-15 09:44:53 -0700
commitf5714994bc4fc578b5f07bca403e7067e6d9b5a0 (patch)
tree9dae28d3e05330e782366e6d9cd7944544557f4c
parentafdad5c76ec5a5ad1c3e3d21d168ed3d9349ba8c (diff)
downloadrneovim-f5714994bc4fc578b5f07bca403e7067e6d9b5a0.tar.gz
rneovim-f5714994bc4fc578b5f07bca403e7067e6d9b5a0.tar.bz2
rneovim-f5714994bc4fc578b5f07bca403e7067e6d9b5a0.zip
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
-rw-r--r--runtime/doc/insert.txt5
-rw-r--r--runtime/doc/news.txt4
-rw-r--r--runtime/ftplugin/lua.lua7
3 files changed, 15 insertions, 1 deletions
diff --git a/runtime/doc/insert.txt b/runtime/doc/insert.txt
index 31e6dd1ec4..51954e5449 100644
--- a/runtime/doc/insert.txt
+++ b/runtime/doc/insert.txt
@@ -1506,6 +1506,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
diff --git a/runtime/doc/news.txt b/runtime/doc/news.txt
index 33068cf53a..d79e22e174 100644
--- a/runtime/doc/news.txt
+++ b/runtime/doc/news.txt
@@ -246,6 +246,10 @@ DEFAULTS
• 'number', 'relativenumber', 'signcolumn', and 'foldcolumn' are disabled in
|terminal| buffers. |terminal-config| shows how to change these defaults.
+• Options:
+ • Lua |ftplugin| sets 'omnifunc' to "v:lua.vim.lua_omnifunc".
+ • Lua |ftplugin| sets 'foldexpr' to "v:lua.vim.treesitter.foldexpr()".
+
• Snippet:
• `<Tab>` in Insert and Select mode maps to `vim.snippet.jump({ direction = 1 })`
when a snippet is active and jumpable forwards.
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<'