Update treesitter branch from master to main; added treesitter-textbjects
This commit is contained in:
parent
13845c038f
commit
523730efdb
|
|
@ -1,27 +1,28 @@
|
||||||
{
|
{
|
||||||
"LuaSnip": { "branch": "master", "commit": "458560534a73f7f8d7a11a146c801db00b081df0" },
|
"LuaSnip": { "branch": "master", "commit": "458560534a73f7f8d7a11a146c801db00b081df0" },
|
||||||
"blink.cmp": { "branch": "main", "commit": "022521a8910a5543b0251b21c9e1a1e989745796" },
|
"blink.cmp": { "branch": "main", "commit": "022521a8910a5543b0251b21c9e1a1e989745796" },
|
||||||
"catppuccin": { "branch": "main", "commit": "a0c769bc7cd04bbbf258b3d5f01e2bdce744108d" },
|
"catppuccin": { "branch": "main", "commit": "fa42eb5e26819ef58884257d5ae95dd0552b9a66" },
|
||||||
"conform.nvim": { "branch": "master", "commit": "0e93e0d12d2f7ebdea9e3e444dfaff0050cefbe6" },
|
"conform.nvim": { "branch": "master", "commit": "8132ec733eed3bf415b97b76797ca41b59f51d7d" },
|
||||||
"fidget.nvim": { "branch": "main", "commit": "d9ba6b7bfe29b3119a610892af67602641da778e" },
|
"fidget.nvim": { "branch": "main", "commit": "d9ba6b7bfe29b3119a610892af67602641da778e" },
|
||||||
"flash.nvim": { "branch": "main", "commit": "3c942666f115e2811e959eabbdd361a025db8b63" },
|
"flash.nvim": { "branch": "main", "commit": "3c942666f115e2811e959eabbdd361a025db8b63" },
|
||||||
"fzf-lua": { "branch": "main", "commit": "6d1d81a5c7936d82a47a41a521958e482e499fde" },
|
"fzf-lua": { "branch": "main", "commit": "1977a7648a264fabf453ee082e2398e38cc3b588" },
|
||||||
"gitsigns.nvim": { "branch": "main", "commit": "d0f90ef51d4be86b824b012ec52ed715b5622e51" },
|
"gitsigns.nvim": { "branch": "main", "commit": "d0f90ef51d4be86b824b012ec52ed715b5622e51" },
|
||||||
"guess-indent.nvim": { "branch": "main", "commit": "84a4987ff36798c2fc1169cbaff67960aed9776f" },
|
"guess-indent.nvim": { "branch": "main", "commit": "84a4987ff36798c2fc1169cbaff67960aed9776f" },
|
||||||
"harpoon": { "branch": "harpoon2", "commit": "ed1f853847ffd04b2b61c314865665e1dadf22c7" },
|
"harpoon": { "branch": "harpoon2", "commit": "ed1f853847ffd04b2b61c314865665e1dadf22c7" },
|
||||||
"lazy.nvim": { "branch": "main", "commit": "6c3bda4aca61a13a9c63f1c1d1b16b9d3be90d7a" },
|
"lazy.nvim": { "branch": "main", "commit": "6c3bda4aca61a13a9c63f1c1d1b16b9d3be90d7a" },
|
||||||
"lazydev.nvim": { "branch": "main", "commit": "2367a6c0a01eb9edb0464731cc0fb61ed9ab9d2c" },
|
"lazydev.nvim": { "branch": "main", "commit": "2367a6c0a01eb9edb0464731cc0fb61ed9ab9d2c" },
|
||||||
"lualine.nvim": { "branch": "master", "commit": "0c6cca9f2c63dadeb9225c45bc92bb95a151d4af" },
|
"lualine.nvim": { "branch": "master", "commit": "a94fc68960665e54408fe37dcf573193c4ce82c9" },
|
||||||
"mason-lspconfig.nvim": { "branch": "main", "commit": "c2682b0d9732bf52cbc34862056f143e71dc4a6d" },
|
"mason-lspconfig.nvim": { "branch": "main", "commit": "bef29b653ba71d442816bf56286c2a686210be04" },
|
||||||
"mason-tool-installer.nvim": { "branch": "main", "commit": "93a9ff9b34c91c0cb0f7de8d5f7e4abce51d8903" },
|
"mason-tool-installer.nvim": { "branch": "main", "commit": "93a9ff9b34c91c0cb0f7de8d5f7e4abce51d8903" },
|
||||||
"mason.nvim": { "branch": "main", "commit": "8024d64e1330b86044fed4c8494ef3dcd483a67c" },
|
"mason.nvim": { "branch": "main", "commit": "8024d64e1330b86044fed4c8494ef3dcd483a67c" },
|
||||||
"mini.icons": { "branch": "main", "commit": "397ed3807e96b59709ef3292f0a3e253d5c1dc0a" },
|
"mini.icons": { "branch": "main", "commit": "397ed3807e96b59709ef3292f0a3e253d5c1dc0a" },
|
||||||
"mini.nvim": { "branch": "main", "commit": "5a10dfb3ab49b3ee2425bc2c215b5067ccce1c79" },
|
"mini.nvim": { "branch": "main", "commit": "35e1767f4cd7dde51256eabae7349a5283a43cba" },
|
||||||
"noice.nvim": { "branch": "main", "commit": "0427460c2d7f673ad60eb02b35f5e9926cf67c59" },
|
"noice.nvim": { "branch": "main", "commit": "0427460c2d7f673ad60eb02b35f5e9926cf67c59" },
|
||||||
"nui.nvim": { "branch": "main", "commit": "7cd18e73cfbd70e1546931b7268b3eebaeff9391" },
|
"nui.nvim": { "branch": "main", "commit": "de740991c12411b663994b2860f1a4fd0937c130" },
|
||||||
"nvim-lspconfig": { "branch": "master", "commit": "036885e8e5456d3907626b634693234f628afef6" },
|
"nvim-lspconfig": { "branch": "master", "commit": "77d3fdfb3554632c7a3b101ded643d422de7626f" },
|
||||||
"nvim-notify": { "branch": "master", "commit": "b5825cf9ee881dd8e43309c93374ed5b87b7a896" },
|
"nvim-notify": { "branch": "master", "commit": "b5825cf9ee881dd8e43309c93374ed5b87b7a896" },
|
||||||
"nvim-treesitter": { "branch": "master", "commit": "42fc28ba918343ebfd5565147a42a26580579482" },
|
"nvim-treesitter": { "branch": "main", "commit": "0fb1c6e92e6a03374d578b362301dbd22abd3840" },
|
||||||
|
"nvim-treesitter-textobjects": { "branch": "main", "commit": "fa32a45fdbab9c9c3bda9ecec9b12dddb221b927" },
|
||||||
"nvim-web-devicons": { "branch": "master", "commit": "1fb58cca9aebbc4fd32b086cb413548ce132c127" },
|
"nvim-web-devicons": { "branch": "master", "commit": "1fb58cca9aebbc4fd32b086cb413548ce132c127" },
|
||||||
"oil.nvim": { "branch": "master", "commit": "08c2bce8b00fd780fb7999dbffdf7cd174e896fb" },
|
"oil.nvim": { "branch": "master", "commit": "08c2bce8b00fd780fb7999dbffdf7cd174e896fb" },
|
||||||
"plenary.nvim": { "branch": "master", "commit": "857c5ac632080dba10aae49dba902ce3abf91b35" },
|
"plenary.nvim": { "branch": "master", "commit": "857c5ac632080dba10aae49dba902ce3abf91b35" },
|
||||||
|
|
|
||||||
|
|
@ -2,34 +2,72 @@ return {
|
||||||
{ -- Highlight, edit, and navigate code
|
{ -- Highlight, edit, and navigate code
|
||||||
'nvim-treesitter/nvim-treesitter',
|
'nvim-treesitter/nvim-treesitter',
|
||||||
lazy = false,
|
lazy = false,
|
||||||
branch = 'master',
|
branch = 'main',
|
||||||
build = ':TSUpdate',
|
build = ':TSUpdate',
|
||||||
|
opts = {},
|
||||||
-- main = 'nvim-treesitter.configs', -- Sets main module to use for opts
|
-- main = 'nvim-treesitter.configs', -- Sets main module to use for opts
|
||||||
-- [[ Configure Treesitter ]] See `:help nvim-treesitter`
|
-- [[ Configure Treesitter ]] See `:help nvim-treesitter`
|
||||||
config = function()
|
config = function()
|
||||||
local configs = require 'nvim-treesitter.configs'
|
local ensureInstalled = { 'bash', 'c', 'diff', 'html', 'lua', 'luadoc', 'markdown', 'markdown_inline', 'query', 'vim', 'vimdoc' }
|
||||||
|
local alreadyInstalled = require('nvim-treesitter').get_installed 'parsers'
|
||||||
|
local parsersToInstall = vim
|
||||||
|
.iter(ensureInstalled)
|
||||||
|
:filter(function(parser)
|
||||||
|
return not vim.tbl_contains(alreadyInstalled, parser)
|
||||||
|
end)
|
||||||
|
:totable()
|
||||||
|
print(parsersToInstall)
|
||||||
|
if #parsersToInstall > 0 then
|
||||||
|
require('nvim-treesitter').install(parsersToInstall)
|
||||||
|
end
|
||||||
|
|
||||||
configs.setup {
|
local parsersInstalled = require('nvim-treesitter').get_installed 'parsers'
|
||||||
ensure_installed = { 'bash', 'c', 'diff', 'html', 'lua', 'luadoc', 'markdown', 'markdown_inline', 'query', 'vim', 'vimdoc' },
|
for _, parser in pairs(parsersInstalled) do
|
||||||
-- Autoinstall languages that are not installed
|
local filetypes = vim.treesitter.language.get_filetypes(parser)
|
||||||
auto_install = true,
|
vim.api.nvim_create_autocmd({ 'FileType' }, {
|
||||||
highlight = {
|
group = vim.api.nvim_create_augroup('EnableTreesitterHighlighting', { clear = true }),
|
||||||
enable = true,
|
pattern = filetypes,
|
||||||
-- Some languages depend on vim's regex highlighting system (such as Ruby) for indent rules.
|
callback = function(event)
|
||||||
-- If you are experiencing weird indenting issues, add the language to
|
print(event.buf)
|
||||||
-- the list of additional_vim_regex_highlighting and disabled languages for indent.
|
local parser_installed = pcall(vim.treesitter.get_parser, event.buf, parser)
|
||||||
additional_vim_regex_highlighting = { 'ruby' },
|
if parser_installed then
|
||||||
},
|
pcall(vim.treesitter.start, event.buf, parser)
|
||||||
indent = { enable = true, disable = { 'ruby' } },
|
end
|
||||||
}
|
end,
|
||||||
|
})
|
||||||
|
end
|
||||||
end,
|
end,
|
||||||
opts = {},
|
|
||||||
-- There are additional nvim-treesitter modules that you can use to interact
|
-- There are additional nvim-treesitter modules that you can use to interact
|
||||||
-- with nvim-treesitter. You should go explore a few and see what interests you:
|
-- with nvim-treesitter. You should go explore a few and see what interests you:
|
||||||
--
|
--
|
||||||
-- - Incremental selection: Included, see `:help nvim-treesitter-incremental-selection-mod`
|
-- - Incremental selection: Included, see `:help nvim-treesitter-incremental-selection-mod`
|
||||||
-- - Show your current context: https://github.com/nvim-treesitter/nvim-treesitter-context
|
-- - Show your current context: https://github.com/nvim-treesitter/nvim-treesitter-context
|
||||||
-- - Treesitter + textobjects: https://github.com/nvim-treesitter/nvim-treesitter-textobjects
|
},
|
||||||
|
{
|
||||||
|
'nvim-treesitter/nvim-treesitter-textobjects',
|
||||||
|
opts = {},
|
||||||
|
branch = 'main',
|
||||||
|
config = function()
|
||||||
|
require('nvim-treesitter-textobjects').setup {
|
||||||
|
select = {
|
||||||
|
-- Automatically jump forward to textobj, similar to targets.vim
|
||||||
|
lookahead = true,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
vim.keymap.set({ 'x', 'o' }, 'af', function()
|
||||||
|
require('nvim-treesitter-textobjects.select').select_textobject('@function.outer', 'textobjects')
|
||||||
|
end, { desc = 'Select outer function' })
|
||||||
|
vim.keymap.set({ 'x', 'o' }, 'if', function()
|
||||||
|
require('nvim-treesitter-textobjects.select').select_textobject('@function.inner', 'textobjects')
|
||||||
|
end, { desc = 'Select inside function' })
|
||||||
|
vim.keymap.set({ 'x', 'o' }, 'ac', function()
|
||||||
|
require('nvim-treesitter-textobjects.select').select_textobject('@class.outer', 'textobjects')
|
||||||
|
end, { desc = 'Select outer class' })
|
||||||
|
vim.keymap.set({ 'x', 'o' }, 'ic', function()
|
||||||
|
require('nvim-treesitter-textobjects.select').select_textobject('@class.inner', 'textobjects')
|
||||||
|
end, { desc = 'Select outer class' })
|
||||||
|
end,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
-- vim: ts=2 sts=2 sw=2 et
|
-- vim: ts=2 sts=2 sw=2 et
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue