mirror of
https://github.com/neovim/neovim.git
synced 2025-09-07 11:58:17 +00:00
fix(api): vim.filetype.get_option() (#22753)
- Fix a bug in the cache - Set some buffer options on the dummy buffer
This commit is contained in:
@@ -3,7 +3,7 @@ local api = vim.api
|
|||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
local function get_ftplugin_runtime(filetype)
|
local function get_ftplugin_runtime(filetype)
|
||||||
return api.nvim__get_runtime({
|
local files = api.nvim__get_runtime({
|
||||||
string.format('ftplugin/%s.vim', filetype),
|
string.format('ftplugin/%s.vim', filetype),
|
||||||
string.format('ftplugin/%s_*.vim', filetype),
|
string.format('ftplugin/%s_*.vim', filetype),
|
||||||
string.format('ftplugin/%s/*.vim', filetype),
|
string.format('ftplugin/%s/*.vim', filetype),
|
||||||
@@ -11,6 +11,15 @@ local function get_ftplugin_runtime(filetype)
|
|||||||
string.format('ftplugin/%s_*.lua', filetype),
|
string.format('ftplugin/%s_*.lua', filetype),
|
||||||
string.format('ftplugin/%s/*.lua', filetype),
|
string.format('ftplugin/%s/*.lua', filetype),
|
||||||
}, true, {}) --[[@as string[] ]]
|
}, true, {}) --[[@as string[] ]]
|
||||||
|
|
||||||
|
local r = {} ---@type string[]
|
||||||
|
for _, f in ipairs(files) do
|
||||||
|
-- VIMRUNTIME should be static so shouldn't need to worry about it changing
|
||||||
|
if not vim.startswith(f, vim.env.VIMRUNTIME) then
|
||||||
|
r[#r + 1] = f
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return r
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Keep track of ftplugin files
|
-- Keep track of ftplugin files
|
||||||
@@ -52,8 +61,6 @@ local function update_ft_option_cache(filetype)
|
|||||||
end
|
end
|
||||||
|
|
||||||
for _, f in ipairs(files) do
|
for _, f in ipairs(files) do
|
||||||
-- VIMRUNTIME should be static so shouldn't need to worry about it changing
|
|
||||||
if not vim.startswith(f, vim.env.VIMRUNTIME) then
|
|
||||||
local mtime = hash(f)
|
local mtime = hash(f)
|
||||||
if ftplugin_cache[filetype][f] ~= mtime then
|
if ftplugin_cache[filetype][f] ~= mtime then
|
||||||
-- invalidate
|
-- invalidate
|
||||||
@@ -62,7 +69,6 @@ local function update_ft_option_cache(filetype)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
--- @private
|
--- @private
|
||||||
--- @param filetype string Filetype
|
--- @param filetype string Filetype
|
||||||
|
@@ -111,6 +111,10 @@ static buf_T *do_ft_buf(char *filetype, aco_save_T *aco, Error *err)
|
|||||||
|
|
||||||
// Set curwin/curbuf to buf and save a few things.
|
// Set curwin/curbuf to buf and save a few things.
|
||||||
aucmd_prepbuf(aco, ftbuf);
|
aucmd_prepbuf(aco, ftbuf);
|
||||||
|
set_option_value("bufhidden", 0L, "hide", OPT_LOCAL);
|
||||||
|
set_option_value("buftype", 0L, "nofile", OPT_LOCAL);
|
||||||
|
set_option_value("swapfile", 0L, NULL, OPT_LOCAL);
|
||||||
|
set_option_value("modeline", 0L, NULL, OPT_LOCAL); // 'nomodeline'
|
||||||
|
|
||||||
ftbuf->b_p_ft = xstrdup(filetype);
|
ftbuf->b_p_ft = xstrdup(filetype);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user