mirror of
https://github.com/neovim/neovim.git
synced 2026-07-22 17:02:59 +00:00
Problem:
Vimscript ftplugins that inherit a base ftplugin often use explicit
`runtime! ftplugin/foo.vim` patterns. This skips corresponding Lua
ftplugins, unlike top-level ftplugin loading.
Solution:
Use the existing `{vim,lua}` patterns for bang runtime imports while
preserving each call's current lookup breadth.
38 lines
1.0 KiB
Lua
38 lines
1.0 KiB
Lua
-- Neovim filetype plugin file
|
|
-- Language: Treesitter query
|
|
|
|
if vim.b.did_ftplugin == 1 then
|
|
return
|
|
end
|
|
|
|
-- Do not set vim.b.did_ftplugin = 1 to allow loading of ftplugin/lisp.vim
|
|
|
|
-- use treesitter over syntax
|
|
vim.treesitter.start()
|
|
|
|
-- set omnifunc
|
|
vim.bo.omnifunc = 'v:lua.vim.treesitter.query.omnifunc'
|
|
|
|
vim.api.nvim_set_option_value('iskeyword', '.', { scope = 'local', operation = 'append' })
|
|
|
|
-- query linter
|
|
local buf = vim.api.nvim_get_current_buf()
|
|
local query_lint_on = vim.g.query_lint_on or {}
|
|
|
|
if not vim.b.disable_query_linter and #query_lint_on > 0 then
|
|
vim.api.nvim_create_autocmd(query_lint_on, {
|
|
group = vim.api.nvim_create_augroup('nvim.querylint', { clear = false }),
|
|
buf = buf,
|
|
callback = function()
|
|
vim.treesitter.query.lint(buf)
|
|
end,
|
|
desc = 'Query linter',
|
|
})
|
|
end
|
|
|
|
-- it's a lisp!
|
|
vim.cmd([[runtime! ftplugin/lisp.vim]])
|
|
|
|
vim.b.undo_ftplugin = (vim.b.undo_ftplugin or '') .. '\n setl omnifunc< iskeyword<'
|
|
vim.b.undo_ftplugin = vim.b.undo_ftplugin .. ' | call v:lua.vim.treesitter.stop()'
|