From 976045d1ca7340dee20a00ce590aac48ffdbd168 Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Thu, 1 Sep 2022 21:58:44 +0100 Subject: [PATCH] feat(nvim): add nvim-treesitter-context --- roles/neovim/files/after/plugin/treesitter.lua | 17 ++++++++++++----- roles/neovim/files/lua/opdavies/plugins.lua | 1 + 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/roles/neovim/files/after/plugin/treesitter.lua b/roles/neovim/files/after/plugin/treesitter.lua index 0a62e33..91a4fb1 100644 --- a/roles/neovim/files/after/plugin/treesitter.lua +++ b/roles/neovim/files/after/plugin/treesitter.lua @@ -1,5 +1,5 @@ -local status_ok, configs = pcall(require, "nvim-treesitter.configs") -if not status_ok then +local has_configs, configs = pcall(require, "nvim-treesitter.configs") +if not has_configs then return end @@ -53,7 +53,14 @@ configs.setup { }, } -local nmap = require "opdavies.keymap".nmap +local nmap = require("opdavies.keymap").nmap -nmap({ "th", "TSHighlightCapturesUnderCursor" }) -nmap({ "tp", "TSPlaygroundToggle" }) +nmap { "th", "TSHighlightCapturesUnderCursor" } +nmap { "tp", "TSPlaygroundToggle" } + +local has_context, context = pcall(require, "treesitter-context") +if not has_context then + return +end + +context.setup { enable = true } diff --git a/roles/neovim/files/lua/opdavies/plugins.lua b/roles/neovim/files/lua/opdavies/plugins.lua index 9dc0a2b..504e0d4 100644 --- a/roles/neovim/files/lua/opdavies/plugins.lua +++ b/roles/neovim/files/lua/opdavies/plugins.lua @@ -69,6 +69,7 @@ return packer.startup(function() -- Treesitter use "nvim-treesitter/playground" + use 'nvim-treesitter/nvim-treesitter-context' use { "nvim-treesitter/nvim-treesitter", run = ":TSUpdate",