How to get the current file type in lua
with neovim
? I tried following but all of them returns nil
.
print(vim.g.filetype)
print(vim.b.filetype)
print(vim.w.filetype)
print(vim.t.filetype)
print(vim.v.filetype)
Vi and Vim Stack Exchange is a question and answer site for people using the vi and Vim families of text editors. It only takes a minute to sign up.
Sign up to join this communityHow to get the current file type in lua
with neovim
? I tried following but all of them returns nil
.
print(vim.g.filetype)
print(vim.b.filetype)
print(vim.w.filetype)
print(vim.t.filetype)
print(vim.v.filetype)
filetype
is a buffer-local option, so you can access it with:
vim.bo.filetype
From :h lua-vim-options
:
From Lua you can work with editor |options| by reading and setting items in these Lua tables: vim.w ... vim.bo *vim.bo* Get or set buffer-scoped |local-options|. Invalid key is an error. Example: vim.bo.buflisted = true print(vim.bo.comments) vim.wo ...