From b2b6e51a7c6a32b48148a88cf2171b9f663a2b9d Mon Sep 17 00:00:00 2001 From: Thomas Vigouroux Date: Sun, 19 Apr 2020 14:20:23 +0200 Subject: feat: add locals to setup procedure --- lua/nvim-treesitter.lua | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'lua/nvim-treesitter.lua') diff --git a/lua/nvim-treesitter.lua b/lua/nvim-treesitter.lua index abb3b6d9..ef6c3150 100644 --- a/lua/nvim-treesitter.lua +++ b/lua/nvim-treesitter.lua @@ -1,6 +1,7 @@ local api = vim.api local parsers = require'nvim-treesitter.parsers' local install = require'nvim-treesitter.install' +local locals = require'nvim-treesitter.locals' local M = {} @@ -8,6 +9,12 @@ local M = {} -- this is the main interface through the plugin function M.setup(lang) if parsers.has_parser(lang) then + if locals.is_supported(lang) then + print("Locals setup for", lang) + api.nvim_command(string.format([[ + autocmd NvimTreesitter FileType %s lua vim.api.nvim_buf_attach(0, true, {on_lines=require'nvim-treesitter.locals'.on_lines}) + ]], lang)) + end end end -- cgit v1.2.3 From d25549917de8047eb91d6f56ee2bdcd5e667d6ae Mon Sep 17 00:00:00 2001 From: Thomas Vigouroux Date: Sun, 19 Apr 2020 19:36:26 +0200 Subject: perf: don't compute locals on buffer updates Instead we lazily evaluate them on request. This allow two things : * better performances * being sure the locas are up to date --- lua/nvim-treesitter.lua | 6 ------ 1 file changed, 6 deletions(-) (limited to 'lua/nvim-treesitter.lua') diff --git a/lua/nvim-treesitter.lua b/lua/nvim-treesitter.lua index ef6c3150..8dae7c33 100644 --- a/lua/nvim-treesitter.lua +++ b/lua/nvim-treesitter.lua @@ -9,12 +9,6 @@ local M = {} -- this is the main interface through the plugin function M.setup(lang) if parsers.has_parser(lang) then - if locals.is_supported(lang) then - print("Locals setup for", lang) - api.nvim_command(string.format([[ - autocmd NvimTreesitter FileType %s lua vim.api.nvim_buf_attach(0, true, {on_lines=require'nvim-treesitter.locals'.on_lines}) - ]], lang)) - end end end -- cgit v1.2.3