neovim

Personal neovim configuration files
git clone git://gtms.dev/neovim
Log | Files | Refs

treesitter.lua (2134B)


      1 if not pcall(require, 'nvim-treesitter') then
      2   return
      3 end
      4 
      5 ---@diagnostic disable-next-line: missing-fields
      6 require 'nvim-treesitter.configs'.setup {
      7   -- ensure_intalled = 'all',
      8   -- ignore_install = { 'lua', 'vim', 'c' },
      9   highlight = {
     10     enable = true,
     11     disable = function(_, buf)
     12       local max_filesize = 100 * 1024 -- 100 KB
     13       local ok, stats = pcall(vim.loop.fs_stat, vim.api.nvim_buf_get_name(buf))
     14       if ok and stats and stats.size > max_filesize then
     15         return true
     16       end
     17     end,
     18   },
     19 
     20   indent = { enable = true },
     21 
     22   refactor = { highlight_definitions = { enable = false, clear_on_cursor_move = false } },
     23 
     24   textobjects = {
     25     enable = true,
     26     select = {
     27       enable = false,
     28       keymaps = {
     29         ['ia'] = '@parameter.inner',
     30         ['aa'] = '@parameter.outer',
     31         ['af'] = '@function.outer',
     32         ['if'] = '@function.inner',
     33         ['ac'] = '@comment.tms',
     34         ['im'] = '@identifier',
     35       },
     36     },
     37     swap = {
     38       enable = false,
     39       swap_next = {
     40         --
     41         -- ['>p'] = '@parameter.inner',
     42         ['>m'] = '@function.outer',
     43       },
     44       swap_previous = {
     45         --
     46         -- ['<p'] = '@parameter.inner',
     47         ['<m'] = '@function.outer',
     48       },
     49     },
     50     move = {
     51       enable = true,
     52       goto_next_start = { --
     53         [']m'] = '@function.outer',
     54       },
     55       goto_next_end = { --
     56         [']M'] = '@function.inner',
     57       },
     58       goto_previous_start = { --
     59         ['[m'] = '@function.outer',
     60       },
     61       goto_previous_end = { --
     62         ['[M'] = '@function.inner',
     63       },
     64     },
     65     lsp_interop = {
     66       enable = true,
     67       border = 'single',
     68       peek_definition_code = {
     69         --
     70         ['<leader>sf'] = '@function.outer',
     71         ['<leader>sc'] = '@class.outer',
     72       },
     73     },
     74   },
     75 
     76   -- playground = { enable = true, disable = {}, updatetime = 25, persist_queries = false },
     77   -- context_commentstring = { enable = true, enable_autocmd = false, config = { scss = '// %s' } },
     78 }
     79 
     80 vim.api.nvim_create_user_command('TSHRefresh', 'write|TSBufEnable highlight', {})
     81 vim.keymap.set('n', '<leader>su', '<cmd>TSHRefresh<cr>')