Add treesitter AST semantic highlighting

This commit is contained in:
ItsDrike 2021-12-08 20:10:40 +01:00
parent 1c3fc02877
commit 886b79e9a7
No known key found for this signature in database
GPG key ID: FB8CA11A2CF3A843
3 changed files with 34 additions and 9 deletions

View file

@ -22,11 +22,16 @@ local plugin_list = {
{ "wakatime/vim-wakatime" },
{ "mhinz/vim-startify" },
{ "ryanoasis/vim-devicons" },
{ "sheerun/vim-polyglot", setup = get_plugin_file("polyglot.lua") },
{ "vimwiki/vimwiki", config = get_plugin_file("vimwiki.lua") },
{ "tpope/vim-commentary", config = get_plugin_file("commentary.lua") },
{ "junegunn/fzf", run = function() fn['fzf#install']() end },
{ "tomasiser/vim-code-dark", config = get_plugin_file("vim-code-dark.lua") },
{
"nvim-treesitter/nvim-treesitter",
config = get_plugin_file("treesitter.lua"),
run = ':TSUpdate',
requires = { "nvim-treesitter/playground", opt = true }
},
{
"vim-airline/vim-airline",
config = get_plugin_file("airline.lua"),

View file

@ -1,8 +0,0 @@
local vim = require("vim")
local g = vim.g
-- Disable polyglot's "sensible" settings, while there are some nice things it
-- does, I set these manually in my default config and I don't like depending
-- on single plugin for so many things, doing it manually doing it manually is
-- also more explicit making it obvious what's happening
g.polyglot_disabled = {'sensible'}

View file

@ -0,0 +1,28 @@
local vim = require("vim")
local g = vim.g
-- Enable treesitter highlight for all languages
require'nvim-treesitter.configs'.setup {
-- Always automatically install parsers for these languages
ensure_installed = {
"bash", "python", "lua", "rust", "go", "haskell",
"c", "cpp", "cmake", "c_sharp", "java", "dockerfile",
"json", "toml", "yaml", "regex", "vim", "html", "css",
"typescript", "javascript",
},
highlight = {
enable = true,
-- Setting this to true will run `:h syntax` and tree-sitter at the same time.
-- Set this to `true` if you depend on 'syntax' being enabled (like for indentation).
-- Using this option may slow down your editor, and you may see some duplicate highlights.
-- Instead of true it can also be a list of languages
additional_vim_regex_highlighting = false,
},
}
-- Use git instead of curl for downloading parsers
require("nvim-treesitter.install").prefer_git = true
-- Use treesitter for syntax-aware folding
g.foldmethod = "expr"
g.foldexpr = "nvim_treesitter#foldexpr()"