15_[nvim0.5+从0单排]_通用高性能语法高亮插件nvim-treesitter

25 篇文章 2 订阅

视频与目录

项目
教程目录https://blog.csdn.net/lxyoucan/article/details/120641546
视频全屏https://www.bilibili.com/video/BV1Gv411u7d7/
视频

15通用高性能语法高亮插件nvim-treesitter

15_[nvim0.5+从0单排]_通用高性能语法高亮插件nvim-treesitter

安装插件

这里以packer为例,packer插件管理器安装方法:
修改~/.config/nvim/lua/plugins.lua文件,并增加如下内容:

--语法高亮
  use {
        'nvim-treesitter/nvim-treesitter',
        run = ':TSUpdate'
    }

:wq退出重新打开nvim后,执行:PackerInstall 安装。

如果初次安装没downloading完就退出了,下次进入nvim 可以执行:TSUpdate进行下载。

配置

新增配置文件如下:

~/.config/nvim/after/plugin/nvim-treesitter.lua

配置文件内容如下:

local status, treesitter = pcall(require, "nvim-treesitter.configs")
if (not status) then
  return
end

treesitter.setup {
  highlight = {
    enable = true,
    disable = {}
  },
  indent = {
    enable = false,
    disable = {}
  },
  ensure_installed = {
    "tsx",
    "toml",
    "fish",
    "php",
    "json",
    "yaml",
    "swift",
    "html",
    "scss"
  }
}

local parser_config = require "nvim-treesitter.parsers".get_parser_configs()
parser_config.tsx.used_by = {"javascript", "typescript.tsx"}

使用

Treesitter使用不同的解析器用于每一种语言。

:TSInstall <language_to_install>

您还可以使用 获取所有可用语言及其安装状态的列表:TSInstallInfo

相关链接

https://github.com/nvim-treesitter/nvim-treesitter

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 4
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值