Why did syntax file in syntax plugin being executed twice when ft
has been set?
#1411
-
Here is the minimal setup and a simple syntax plugin: init.lua: local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({
"git",
"clone",
"--filter=blob:none",
"https://github.com/folke/lazy.nvim.git",
"--branch=stable", -- latest stable release
lazypath,
})
end
vim.opt.rtp:prepend(lazypath)
require("lazy").setup({
{
dir = "~/test.vim/",
ft = "test"
},
}) Create a
Content of autocmd BufNewFile,BufRead *.test setfiletype test Content of " Only do this when not done yet for this buffer
if exists("b:did_ftplugin")
finish
endif
" Don't load another plugin for this buffer
let b:did_ftplugin = 1
setlocal commentstring=//\ %s
" Undo the plugin effect
let b:undo_ftplugin = "setlocal com<"
echom "hi, ftplugin" Content of " Only load this syntax file when no other was loaded.
if exists("b:current_syntax")
finish
endif
" Don't load another syntax file for this buffer
let b:current_syntax = "test"
if !exists("b:syntax_other_checks")
syn keyword testKeyword test
let b:syntax_other_checks = 1
let b:undo_ftplugin = "unlet! b:syntax_other_checks"
echom "hi, syntax other checks"
endif
hi def link testKeyword Keyword
echom "hi, syntax" Content of " Only load this indent file when no other was loaded.
if exists("b:did_indent")
finish
endif
" Don't load another indent file for this buffer
let b:did_indent = 1
setlocal indentkeys=o,O
" Undo the plugin effect
let b:undo_ftplugin = "setlocal indentkeys<"
echom "hi, indent" Here is my Neovim version:
When I opened a
Normally, Vim doesn't care the same highlight being set twice. However, if the plugin has other defined checks other than If I disabled lazy load, i.e., no
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Related #1406 |
Beta Was this translation helpful? Give feedback.
Related #1406