2025-02-12 11:49:02 +01:00
|
|
|
-- nvim-treesitter
|
|
|
|
--- Interface to the AST-level parser generator 'tree-sitter', enabling operations on source code that intelligently understand the syntax.
|
|
|
|
--- Out of the box, grammer-aware code highlighting, indentation, etc. .
|
|
|
|
--- Base for a lot of other plugins that rely on these kinds of features.
|
|
|
|
|
|
|
|
--- TODO: Look into extensions for:
|
|
|
|
--- * Text Objects: https://github.com/nvim-treesitter/nvim-treesitter-textobjects
|
|
|
|
--- As always, consult <http://www.lazyvim.org/plugins/treesitter>
|
|
|
|
|
|
|
|
return {
|
|
|
|
'nvim-treesitter/nvim-treesitter',
|
|
|
|
commit = 'cfc6f2c117aaaa82f19bcce44deec2c194d900ab',
|
|
|
|
|
|
|
|
dependencies = {
|
|
|
|
{
|
|
|
|
'nvim-treesitter/nvim-treesitter-textobjects',
|
|
|
|
commit = 'ad8f0a472148c3e0ae9851e26a722ee4e29b1595',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
2025-02-13 08:58:49 +01:00
|
|
|
build = ':TSUpdate all', -- Update lang parsers unconditionally on build
|
2025-02-12 11:49:02 +01:00
|
|
|
|
|
|
|
lazy = vim.fn.argc(-1) == 0, -- Load early only when opening file w/cmdline
|
|
|
|
event = {
|
|
|
|
'VeryLazy',
|
|
|
|
},
|
|
|
|
cmd = {
|
2025-02-13 08:58:49 +01:00
|
|
|
'TSUpdateSync',
|
|
|
|
'TSUpdate',
|
|
|
|
'TSInstall',
|
2025-02-12 11:49:02 +01:00
|
|
|
},
|
|
|
|
init = function(plugin)
|
|
|
|
--- Many plugins apparently no longer require("nvim-treesitter").
|
|
|
|
--- This messes with the lazy-loading logic.
|
|
|
|
--- However, such plugins only otherwise use custom queries (seems to be called "RTP").
|
|
|
|
--- We therefore register treesitter w/RTP, so such queries will load treesitter.
|
2025-02-13 08:58:49 +01:00
|
|
|
require('lazy.core.loader').add_to_rtp(plugin)
|
|
|
|
require('nvim-treesitter.query_predicates')
|
2025-02-12 11:49:02 +01:00
|
|
|
end,
|
|
|
|
|
|
|
|
opts = {
|
|
|
|
-- Grammer-Aware Syntax Highlighting
|
|
|
|
highlight = {
|
2025-02-13 08:58:49 +01:00
|
|
|
enable = true,
|
2025-02-12 11:49:02 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
-- Grammer-Aware Indentation
|
|
|
|
--- TODO: EXPERIMENTAL - CAREFUL!
|
|
|
|
--indent = { enable = true },
|
|
|
|
|
|
|
|
textobjects = {
|
|
|
|
select = {
|
|
|
|
enable = true,
|
|
|
|
lookahead = false,
|
|
|
|
keymaps = {
|
|
|
|
-- You can use the capture groups defined in textobjects.scm
|
2025-02-13 08:58:49 +01:00
|
|
|
['af'] = {
|
|
|
|
query = '@function.outer',
|
|
|
|
desc = 'Select [A]round [F]unction',
|
2025-02-12 11:49:02 +01:00
|
|
|
},
|
2025-02-13 08:58:49 +01:00
|
|
|
['if'] = {
|
|
|
|
query = '@function.inner',
|
|
|
|
desc = 'Select [I]nside [F]unction',
|
2025-02-12 11:49:02 +01:00
|
|
|
},
|
2025-02-13 08:58:49 +01:00
|
|
|
['al'] = {
|
|
|
|
query = '@class.outer',
|
|
|
|
desc = 'Select [A]round C[L]ass',
|
2025-02-12 11:49:02 +01:00
|
|
|
},
|
2025-02-13 08:58:49 +01:00
|
|
|
['il'] = {
|
|
|
|
query = '@class.outer',
|
|
|
|
desc = 'Select [I]nside C[L]ass',
|
2025-02-12 11:49:02 +01:00
|
|
|
},
|
2025-02-13 08:58:49 +01:00
|
|
|
['ac'] = {
|
|
|
|
query = '@cell.outer',
|
|
|
|
desc = 'Select [A]round [C]ell',
|
2025-02-12 11:49:02 +01:00
|
|
|
},
|
2025-02-13 08:58:49 +01:00
|
|
|
['ic'] = {
|
|
|
|
query = '@cell.inner',
|
|
|
|
desc = 'Select [I]nside [C]ell',
|
2025-02-12 11:49:02 +01:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
move = {
|
|
|
|
enable = true,
|
|
|
|
set_jumps = true,
|
2025-02-13 08:58:49 +01:00
|
|
|
},
|
2025-02-12 11:49:02 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
-- Always Install Parsers for Languages
|
|
|
|
ensure_installed = {
|
2025-02-13 08:58:49 +01:00
|
|
|
'ada',
|
|
|
|
'arduino',
|
|
|
|
'asm',
|
|
|
|
'awk',
|
|
|
|
'bash',
|
|
|
|
'bibtex',
|
|
|
|
'c',
|
|
|
|
'c_sharp',
|
|
|
|
'clojure',
|
|
|
|
'cmake',
|
|
|
|
'comment',
|
|
|
|
'commonlisp',
|
|
|
|
'cpp',
|
|
|
|
'css',
|
|
|
|
'csv',
|
|
|
|
'cuda',
|
|
|
|
'd',
|
|
|
|
'dart',
|
|
|
|
'diff',
|
|
|
|
'disassembly',
|
|
|
|
'dockerfile',
|
|
|
|
'dot',
|
|
|
|
'doxygen',
|
|
|
|
'dtd',
|
|
|
|
'editorconfig',
|
|
|
|
'eex',
|
|
|
|
'elixir',
|
|
|
|
'elm',
|
|
|
|
'erlang',
|
|
|
|
'fennel',
|
|
|
|
'fish',
|
|
|
|
'forth',
|
|
|
|
'fortran',
|
|
|
|
'fsh',
|
|
|
|
'fsharp',
|
|
|
|
'gap',
|
|
|
|
'gdscript',
|
|
|
|
'gdshader',
|
|
|
|
'git_config',
|
|
|
|
'git_rebase',
|
|
|
|
'gitattributes',
|
|
|
|
'gitcommit',
|
|
|
|
'gitignore',
|
|
|
|
'gleam',
|
|
|
|
'glsl',
|
|
|
|
'gnuplot',
|
|
|
|
'go',
|
|
|
|
'gpg',
|
|
|
|
'graphql',
|
|
|
|
'haskell',
|
|
|
|
'hcl',
|
|
|
|
'hlsl',
|
|
|
|
'hlsplaylist',
|
|
|
|
'html',
|
|
|
|
'htmldjango',
|
|
|
|
'hyprlang',
|
|
|
|
'ini',
|
|
|
|
'java',
|
|
|
|
'javascript',
|
|
|
|
'jq',
|
|
|
|
'jsdoc',
|
|
|
|
'json',
|
|
|
|
'json5',
|
|
|
|
'jsonc',
|
|
|
|
'jsonnet',
|
|
|
|
'julia',
|
|
|
|
'just',
|
|
|
|
'kconfig',
|
|
|
|
'kdl',
|
|
|
|
'latex',
|
|
|
|
'llvm',
|
|
|
|
'lua',
|
|
|
|
'luadoc',
|
|
|
|
'luap',
|
|
|
|
'luau',
|
|
|
|
'm68k',
|
|
|
|
'make',
|
|
|
|
'markdown',
|
|
|
|
'markdown_inline',
|
|
|
|
'matlab',
|
|
|
|
'meson',
|
|
|
|
'mlir',
|
|
|
|
'nasm',
|
|
|
|
'nginx',
|
|
|
|
'nix',
|
|
|
|
'objc',
|
|
|
|
'objdump',
|
|
|
|
'ocaml',
|
|
|
|
'pascal',
|
|
|
|
'pem',
|
|
|
|
'perl',
|
|
|
|
'php',
|
|
|
|
'phpdoc',
|
|
|
|
'po',
|
|
|
|
'pod',
|
|
|
|
'powershell',
|
|
|
|
'printf',
|
|
|
|
'prisma',
|
|
|
|
'prolog',
|
|
|
|
'promql',
|
|
|
|
'proto',
|
|
|
|
'puppet',
|
|
|
|
'pymanifest',
|
|
|
|
'python',
|
|
|
|
'qmldir',
|
|
|
|
'qmljs',
|
|
|
|
'r',
|
|
|
|
'readline',
|
|
|
|
'regex',
|
|
|
|
'requirements',
|
|
|
|
'robots',
|
|
|
|
'rst',
|
|
|
|
'ruby',
|
|
|
|
'rust',
|
|
|
|
'scala',
|
|
|
|
'scss',
|
|
|
|
'sflog',
|
|
|
|
'smithy',
|
|
|
|
'sql',
|
|
|
|
'ssh_config',
|
|
|
|
'starlark',
|
|
|
|
'strace',
|
|
|
|
'svelte',
|
|
|
|
'swift',
|
|
|
|
't32',
|
|
|
|
'tablegen',
|
|
|
|
'tcl',
|
|
|
|
'teal',
|
|
|
|
'terraform',
|
|
|
|
'tmux',
|
|
|
|
'todotxt',
|
|
|
|
'toml',
|
|
|
|
'tsv',
|
|
|
|
'tsx',
|
|
|
|
'turtle',
|
|
|
|
'typescript',
|
|
|
|
'typespec',
|
|
|
|
'typst',
|
|
|
|
'udev',
|
|
|
|
'unison',
|
|
|
|
'usd',
|
|
|
|
'vala',
|
|
|
|
'verilog',
|
|
|
|
'vim',
|
|
|
|
'vimdoc',
|
|
|
|
'vue',
|
|
|
|
'wgsl',
|
|
|
|
'wgsl_bevy',
|
|
|
|
'xml',
|
|
|
|
'xresources',
|
|
|
|
'yaml',
|
|
|
|
'zathurarc',
|
|
|
|
'zig',
|
2025-02-12 11:49:02 +01:00
|
|
|
},
|
|
|
|
},
|
|
|
|
config = function(_, opts)
|
|
|
|
require('nvim-treesitter.configs').setup(opts)
|
|
|
|
|
|
|
|
-- Use Treesitter as the Folding Method
|
|
|
|
--vim.opt.foldmethod = "expr"
|
|
|
|
--vim.opt.foldexpr = "nvim_treesitter#foldexpr()"
|
2025-02-14 10:10:32 +01:00
|
|
|
|
|
|
|
-- Suppress Concealment of ```
|
|
|
|
--- See https://github.com/nvim-treesitter/nvim-treesitter/issues/5751
|
2025-02-13 08:58:49 +01:00
|
|
|
require('vim.treesitter.query').set(
|
|
|
|
'markdown',
|
|
|
|
'highlights',
|
|
|
|
[[
|
|
|
|
;From MDeiml/tree-sitter-markdown
|
|
|
|
[
|
|
|
|
(fenced_code_block_delimiter)
|
|
|
|
] @punctuation.delimiter
|
|
|
|
]]
|
|
|
|
)
|
2025-02-12 11:49:02 +01:00
|
|
|
end,
|
|
|
|
}
|