diff options
author | Squibid <me@zacharyscheiman.com> | 2024-08-09 02:45:31 -0400 |
---|---|---|
committer | Squibid <me@zacharyscheiman.com> | 2024-08-09 02:45:31 -0400 |
commit | c489d393695e90d424f9ae51e35c4d42358e6a71 (patch) | |
tree | 12ea97ec4684fd82cd6b73dd127d0137b115837b /lua/conf/plugins/treesitter-context.lua | |
parent | ad76983d969c318e6e234bc82384b4b025d70447 (diff) | |
download | nvim-c489d393695e90d424f9ae51e35c4d42358e6a71.tar.gz nvim-c489d393695e90d424f9ae51e35c4d42358e6a71.tar.bz2 nvim-c489d393695e90d424f9ae51e35c4d42358e6a71.zip |
yes there's a bit of java in my nvim config why do you ask?
Diffstat (limited to 'lua/conf/plugins/treesitter-context.lua')
-rw-r--r-- | lua/conf/plugins/treesitter-context.lua | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/lua/conf/plugins/treesitter-context.lua b/lua/conf/plugins/treesitter-context.lua new file mode 100644 index 0000000..3306e6b --- /dev/null +++ b/lua/conf/plugins/treesitter-context.lua @@ -0,0 +1,40 @@ +local misc = require("core.misc") +local map = misc.map + +local branch = nil +if vim.version().minor == 7 then + branch = 'compat/0.7' +end + +return { 'nvim-treesitter/nvim-treesitter-context', + disable = vim.version().minor < 7, + branch = branch, + requires = 'nvim-treesitter/nvim-treesitter', + function() + local treesitter_context = require("treesitter-context") + + treesitter_context.setup { + enable = true, + line_numbers = true, + separator = '─', + } + + -- mapping to jump to the first closest line of context in buffer + map("n", "[j", function() + local lline = vim.api.nvim_win_get_cursor(0)[1]; + local line + + -- go to the first closest line of context and center it + treesitter_context.go_to_context() + vim.api.nvim_input('zz') + + -- make sure we actually moved + line = vim.api.nvim_win_get_cursor(0)[1]; + if line == lline then + return + end + + misc.timeout_highlight() + end) + end +} |