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

2023-05-16

视频与目录

项目
教程目录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

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

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

  • Oracle行转列wm_concat()

    原数据 span class token keyword select span id span class token punctuation span name span class token keyword from span T

随机推荐