Vim无法将Podfile和podspec文件识别为Ruby文件

izj3ouym  于 12个月前  发布在  Ruby
关注(0)|答案(2)|浏览(100)

如何让Vim识别Podfile和podspec文件(一些没有扩展名的文件)为ruby文件,这样vim就可以进行语法高亮。

oogrdqng

oogrdqng1#

将此添加到.vimrc

autocmd BufNewFile,BufRead Podfile,*.podspec set filetype=ruby

这一行指示Vim将Podfiles和扩展名为.podspec的文件视为Ruby文件,以便它们继承Ruby语法突出显示。

gk7wooem

gk7wooem2#

对于NeoVim / Lua:

local auto_command_on = vim.api.nvim_create_autocmd

auto_command_on({ "BufRead", "BufNewFile" }, {
  pattern = { "*.podspec", "Podfile" },
  command = "set filetype=ruby",
})

当你打开/创建一个“.podspec”或“Podfile”时,neovim会将该文件视为ruby文件

  • 基于赛·罗西尼奥的回答 *

相关问题