0
0

treesitter.lua 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. vim.api.nvim_create_autocmd("LspAttach", {
  20. callback = function(args)
  21. local client = vim.lsp.get_client_by_id(args.data.client_id)
  22. if vim.treesitter ~= nil and client ~= nil and
  23. type(vim.treesitter.highlighter.active[args.buf]) ~= "nil" then
  24. client.server_capabilities.semanticTokensProvider = nil
  25. end
  26. end
  27. })
  28. end,
  29. build = function()
  30. require("nvim-treesitter.install").update({ with_sync = true })
  31. end
  32. }, {
  33. "nvim-treesitter/nvim-treesitter-context",
  34. enabled = true,
  35. lazy = false,
  36. dependencies = { "nvim-treesitter/nvim-treesitter" },
  37. config = function(_, _)
  38. require("treesitter-context").setup({
  39. enable = true,
  40. max_lines = 5,
  41. min_window_height = 0,
  42. line_numbers = true,
  43. multiline_threshold = 20,
  44. trim_scope = "outer",
  45. mode = "cursor",
  46. zindex = 20,
  47. on_attach = nil
  48. })
  49. vim.api.nvim_set_hl(0, "TreesitterContextSeparator",
  50. { link = "WinSeparator" })
  51. vim.keymap.set("n", "<Leader>c", function()
  52. require("treesitter-context").go_to_context(vim.v.count1)
  53. end, { silent = true })
  54. end
  55. }
  56. }