diff --git a/after/indent/python.lua b/after/indent/python.lua deleted file mode 100644 index 001a045..0000000 --- a/after/indent/python.lua +++ /dev/null @@ -1,2 +0,0 @@ --- Use treesitter for Python indenting since regex indenting is broken -vim.opt.indentexpr = 'nvim_treesitter#indent()' diff --git a/lua/plugins/mdx.lua b/lua/plugins/mdx.lua deleted file mode 100644 index 1a868d1..0000000 --- a/lua/plugins/mdx.lua +++ /dev/null @@ -1,6 +0,0 @@ -return { - 'davidmh/mdx.nvim', - dependencies = { - 'nvim-treesitter/nvim-treesitter', - }, -} diff --git a/lua/plugins/treesitter.lua b/lua/plugins/treesitter.lua index 41a1e0d..abdc1f7 100644 --- a/lua/plugins/treesitter.lua +++ b/lua/plugins/treesitter.lua @@ -1,107 +1,108 @@ return { - 'nvim-treesitter/nvim-treesitter', - branch = 'master', - dependencies = { - 'nvim-treesitter/nvim-treesitter-textobjects', - { 'nvim-treesitter/nvim-treesitter-context', opts = {} }, - -- TODO: Fork this and add CMake support - -- TODO: Add shell support (sh/bash/zsh if/for/while/etc) - 'RRethy/nvim-treesitter-endwise', - 'danymat/neogen', - }, - build = ':TSUpdate', - config = function() - require('nvim-treesitter').setup() - require('nvim-treesitter.configs').setup({ - sync_install = false, - highlight = { enable = true }, - indent = { enable = false }, - - -- List of languages that must be available - ensure_installed = { - 'asm', - 'bash', - 'c', - 'cmake', - 'cpp', - 'css', - 'csv', - 'cuda', - 'diff', - 'disassembly', - 'dockerfile', - 'dot', - 'doxygen', - 'git_config', - 'git_rebase', - 'gitattributes', - 'gitignore', - 'glsl', - 'go', - 'gpg', - 'hlsl', - 'html', - 'ini', - 'javascript', - 'jq', - 'json', - 'julia', - 'llvm', - 'lua', - 'make', - 'markdown', - 'markdown_inline', - 'meson', - 'ninja', - 'objc', - 'objdump', - 'printf', - 'proto', - 'python', - 'query', - 'regex', - 'requirements', - 'rst', - 'ssh_config', - 'strace', - 'tablegen', - 'tmux', - 'toml', - 'vim', - 'vimdoc', - 'xml', - 'yaml', - }, - - -- After opening statements insert end statements - endwise = { enable = true }, - - -- Text objects using Tree-sitter groups - textobjects = { - select = { - enable = true, - lookahead = true, - -- include_surrounding_whitespace = true, - keymaps = { - -- Class text objects - ['ac'] = '@class.outer', - ['ic'] = '@class.inner', - -- Function text objects - ['af'] = '@function.outer', - ['if'] = '@function.inner', - -- Parameter/argument text objects - ['a,'] = '@parameter.outer', - ['i,'] = '@parameter.inner', - -- Comment text objects - ['a/'] = '@comment.outer', - ['i/'] = '@comment.inner', - }, + { + 'romus204/tree-sitter-manager.nvim', + lazy = false, + config = function() + require('tree-sitter-manager').setup({ + -- Enable core highlighting for every installed parser. + highlight = true, + ensure_installed = { + 'asm', + 'bash', + 'c', + 'cmake', + 'cpp', + 'css', + 'csv', + 'cuda', + 'diff', + 'disassembly', + 'dockerfile', + 'dot', + 'doxygen', + 'git_config', + 'git_rebase', + 'gitattributes', + 'gitignore', + 'glsl', + 'go', + 'gpg', + 'hlsl', + 'html', + 'ini', + 'javascript', + 'jq', + 'json', + 'julia', + 'llvm', + 'lua', + 'make', + 'markdown', + 'markdown_inline', + 'meson', + 'mlir', + 'ninja', + 'objc', + 'objdump', + 'printf', + 'proto', + 'python', + 'query', + 'regex', + 'requirements', + 'rst', + 'ssh_config', + 'strace', + 'tablegen', + 'tmux', + 'toml', + 'vim', + 'vimdoc', + 'xml', + 'yaml', }, - }, - }) + }) + end, + }, - require('neogen').setup({ snippet_engine = 'luasnip' }) - vim.keymap.set('n', 'd', require('neogen').generate, - { desc = 'Generate documentation' }) - end + { + 'nvim-treesitter/nvim-treesitter-textobjects', + branch = 'main', + config = function() + require('nvim-treesitter-textobjects').setup({ + select = { + lookahead = true, + }, + }) + + local select = require('nvim-treesitter-textobjects.select') + local function map(lhs, query) + vim.keymap.set({ 'x', 'o' }, lhs, function() + select.select_textobject(query, 'textobjects') + end, { desc = 'Select ' .. query }) + end + + map('ac', '@class.outer') -- Class text objects + map('ic', '@class.inner') + map('af', '@function.outer') -- Function text objects + map('if', '@function.inner') + map('a,', '@parameter.outer') -- Parameter/argument text objects + map('i,', '@parameter.inner') + map('a/', '@comment.outer') -- Comment text objects + map('i/', '@comment.inner') + end, + }, + + { 'nvim-treesitter/nvim-treesitter-context', opts = {} }, + + { + 'danymat/neogen', + config = function() + require('neogen').setup({ snippet_engine = 'luasnip' }) + vim.keymap.set('n', 'd', require('neogen').generate, + { desc = 'Generate documentation' }) + end, + }, + + 'davidmh/mdx.nvim', } diff --git a/plugin/mappings.lua b/plugin/mappings.lua index ba654dc..330f543 100644 --- a/plugin/mappings.lua +++ b/plugin/mappings.lua @@ -59,7 +59,7 @@ vim.keymap.set('n', 'gw', function() end, { desc = 'Format whole file with gw' }) vim.keymap.set('n', 'fm', function() - if vim.o.foldexpr == 'nvim_treesitter#foldexpr()' then - vim.opt.foldexpr = 'nvim_treesitter#foldexpr()' + if vim.o.foldexpr == 'v:lua.vim.treesitter.foldexpr()' then + vim.opt.foldexpr = 'v:lua.vim.treesitter.foldexpr()' end end) diff --git a/plugin/settings.lua b/plugin/settings.lua index 8f6e609..4bef366 100644 --- a/plugin/settings.lua +++ b/plugin/settings.lua @@ -89,7 +89,7 @@ vim.opt.joinspaces = false -- Set fold level to something high vim.opt.foldlevel = 20 vim.opt.foldmethod = 'expr' -vim.opt.foldexpr = 'nvim_treesitter#foldexpr()' +vim.opt.foldexpr = 'v:lua.vim.treesitter.foldexpr()' vim.opt.foldtext = '' vim.opt.fillchars = { fold = ' ' } diff --git a/plugin/ui.lua b/plugin/ui.lua index 1020fd2..cebdd79 100644 --- a/plugin/ui.lua +++ b/plugin/ui.lua @@ -1,17 +1,3 @@ --- Customise LSP UI -vim.lsp.handlers['textDocument/hover'] = vim.lsp.with( - vim.lsp.handlers.hover, { - border = 'rounded', - title = 'Hover', - } -) -vim.lsp.handlers['textDocument/signatureHelp'] = vim.lsp.with( - vim.lsp.handlers.signature_help, { - border = 'rounded', - title = 'Signature Help', - } -) - -- Customise diagnostic UI vim.diagnostic.config({ float = {