added treesitter context
authorGeorgios Atheridis <atheridis@tutamail.com>
Sat, 11 Jun 2022 21:48:13 +0000 (00:48 +0300)
committerGeorgios Atheridis <atheridis@tutamail.com>
Sat, 11 Jun 2022 21:48:13 +0000 (00:48 +0300)
nvim/lua/nvim/plugins.lua
nvim/lua/nvim/treesitter.lua

index b697560a969ce5592ba4202bb3e6747b4f4eb7b1..911c7dcd7ac18bff763618d6a3a8abfd4a44bb30 100644 (file)
@@ -106,6 +106,13 @@ return packer.startup(function(use)
                { "nvim-treesitter/nvim-treesitter" },
        } })
 
+       use({
+               "nvim-treesitter/nvim-treesitter-context",
+               requires = {
+                       { "nvim-treesitter/nvim-treesitter" },
+               },
+       })
+
        -- Autopairs
        use("windwp/nvim-autopairs")
 
index 575ecefb3edbfe09663bc56cb4f0e36f011457f7..ce1274fa99b80267de4e232097a64b2fcac46e1f 100644 (file)
@@ -8,7 +8,7 @@ configs.setup({
                disable = { "" }, -- list of language that will be disabled
                additional_vim_regex_highlighting = true,
        },
-       indent = { enable = true, disable = { "yaml" } },
+       indent = { enable = true, disable = { "yaml", "python" } },
        rainbow = {
                enable = true,
                extended_mode = true,
@@ -26,3 +26,46 @@ vim.cmd("hi rainbowcol4 guifg=#FF0000")
 vim.cmd("hi rainbowcol5 guifg=#FF00FF")
 vim.cmd("hi rainbowcol6 guifg=#00FFFF")
 vim.cmd("hi rainbowcol7 guifg=#FFFF00")
+
+local ts_context_status_ok, ts_context = pcall(require, "treesitter-context")
+if not ts_context_status_ok then
+       vim.notify("Error with require treesitter-context")
+       return
+end
+
+ts_context.setup({
+       enable = true, -- Enable this plugin (Can be enabled/disabled later via commands)
+       max_lines = 0, -- How many lines the window should span. Values <= 0 mean no limit.
+       patterns = { -- Match patterns for TS nodes. These get wrapped to match at word boundaries.
+               -- For all filetypes
+               -- Note that setting an entry here replaces all other patterns for this entry.
+               -- By setting the 'default' entry below, you can control which nodes you want to
+               -- appear in the context window.
+               default = {
+                       "class",
+                       "function",
+                       "method",
+                       -- 'for', -- These won't appear in the context
+                       -- 'while',
+                       -- 'if',
+                       -- 'switch',
+                       -- 'case',
+               },
+               -- Example for a specific filetype.
+               -- If a pattern is missing, *open a PR* so everyone can benefit.
+               --   rust = {
+               --       'impl_item',
+               --   },
+       },
+       exact_patterns = {
+               -- Example for a specific filetype with Lua patterns
+               -- Treat patterns.rust as a Lua pattern (i.e "^impl_item$" will
+               -- exactly match "impl_item" only)
+               -- rust = true,
+       },
+
+       -- [!] The options below are exposed but shouldn't require your attention,
+       --     you can safely ignore them.
+
+       zindex = 20, -- The Z-index of the context window
+})