treesitter.lua 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. return {
  2. {
  3. "nvim-treesitter/nvim-treesitter",
  4. enabled = true,
  5. lazy = false,
  6. config = function(_, _)
  7. local api = require("nvim-treesitter.configs")
  8. api.setup({
  9. ensure_installed = "all",
  10. sync_install = false,
  11. auto_install = true,
  12. highlight = {
  13. enable = true,
  14. additional_vim_regex_highlighting = false
  15. }
  16. })
  17. vim.opt.foldmethod = "expr"
  18. vim.opt.foldexpr = "nvim_treesitter#foldexpr()"
  19. end,
  20. build = function()
  21. require("nvim-treesitter.install").update({ with_sync = true })
  22. end
  23. }, {
  24. "nvim-treesitter/nvim-treesitter-context",
  25. enabled = true,
  26. lazy = false,
  27. dependencies = { "nvim-treesitter/nvim-treesitter" },
  28. config = function(_, _)
  29. require("treesitter-context").setup({
  30. enable = true,
  31. max_lines = 5,
  32. min_window_height = 0,
  33. line_numbers = true,
  34. multiline_threshold = 20,
  35. trim_scope = "outer",
  36. mode = "cursor",
  37. zindex = 20,
  38. on_attach = nil
  39. })
  40. vim.api.nvim_set_hl(0, "TreesitterContextSeparator",
  41. { link = "WinSeparator" })
  42. vim.keymap.set("n", "sc", function()
  43. require("treesitter-context").go_to_context(vim.v.count1)
  44. end, { silent = true })
  45. end
  46. }
  47. }