From e5641df6d3fc3bb6c3c55593b6152082bfc561b6 Mon Sep 17 00:00:00 2001 From: Lewis Russell Date: Sat, 11 Mar 2023 17:11:02 +0000 Subject: feat: add `vim.filetype.get_option()` --- runtime/lua/vim/filetype.lua | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'runtime/lua/vim/filetype.lua') diff --git a/runtime/lua/vim/filetype.lua b/runtime/lua/vim/filetype.lua index cf813b19b1..69fcb01e8c 100644 --- a/runtime/lua/vim/filetype.lua +++ b/runtime/lua/vim/filetype.lua @@ -2631,4 +2631,24 @@ function M.match(args) end end +--- Get the default option value for a {filetype}. +--- +--- The returned value is what would be set in a new buffer after 'filetype' +--- is set, meaning it should respect all FileType autocmds and ftplugin files. +--- +--- Example: +---
lua
+---   vim.filetype.get_option('vim', 'commentstring')
+--- 
+--- +--- Note: this uses |nvim_get_option_value()| but caches the result. +--- This means |ftplugin| and |FileType| autocommands are only +--- triggered once and may not reflect later changes. +--- @param filetype string Filetype +--- @param option string Option name +--- @return string|boolean|integer: Option value +function M.get_option(filetype, option) + return require('vim.filetype.options').get_option(filetype, option) +end + return M -- cgit