nvim: treesitter: Update treesitter configuration
This commit is contained in:
parent
2ff1ba46e1
commit
ff93725694
1 changed files with 68 additions and 25 deletions
|
@ -1,27 +1,75 @@
|
|||
-- Required to enable textobjects. See
|
||||
-- https://github.com/nvim-treesitter/nvim-treesitter-textobjects/issues/100.
|
||||
require'nvim-treesitter-textobjects'
|
||||
|
||||
local ts_langs = { "bash", "c", "clojure", "cpp", "fennel", "fish", "haskell", "java", "javascript", "jsdoc", "json", "lua", "nix", "python", "query", "rust", "teal", "toml", "tsx", "typescript", "verilog", "vim" }
|
||||
|
||||
require'nvim-treesitter.install'.compilers = { "gcc" }
|
||||
require'nvim-treesitter.configs'.setup {
|
||||
ensure_installed = { "bash", "c", "clojure", "cpp", "fennel", "fish", "haskell", "java", "javascript", "jsdoc", "json", "lua", "nix", "python", "query", "rust", "toml" },
|
||||
ensure_installed = ts_langs,
|
||||
highlight = { enable = true, },
|
||||
textobjects = {
|
||||
select = {
|
||||
enable = true,
|
||||
lookahead = true,
|
||||
keymaps = {
|
||||
["<Leader><Leader>ab"] = "@block.outer" ,
|
||||
["<Leader><Leader>ib"] = "@block.inner" ,
|
||||
["<Leader><Leader>aC"] = "@call.outer" ,
|
||||
["<Leader><Leader>iC"] = "@call.inner" ,
|
||||
["<Leader><Leader>ao"] = "@class.outer" ,
|
||||
["<Leader><Leader>io"] = "@class.inner" ,
|
||||
["<Leader><Leader>at"] = "@comment.outer" ,
|
||||
["<Leader><Leader>ac"] = "@conditional.outer",
|
||||
["<Leader><Leader>ic"] = "@conditional.inner",
|
||||
["<Leader><Leader>af"] = "@function.outer" ,
|
||||
["<Leader><Leader>if"] = "@function.inner" ,
|
||||
["<Leader><Leader>al"] = "@loop.outer" ,
|
||||
["<Leader><Leader>il"] = "@loop.inner" ,
|
||||
["<Leader><Leader>ap"] = "@parameter.outer" ,
|
||||
["<Leader><Leader>ip"] = "@parameter.inner" ,
|
||||
["<Leader><Leader>is"] = "@scopename.inner" ,
|
||||
["<Leader><Leader>as"] = "@statement.outer" ,
|
||||
["ab"] = "@block.outer" ,
|
||||
["ib"] = "@block.inner" ,
|
||||
-- We use M,m for call/conditional as C/c would conflict with textobj-word-column
|
||||
["aM"] = "@call.outer" ,
|
||||
["iM"] = "@call.inner" ,
|
||||
["ao"] = "@class.outer" ,
|
||||
["io"] = "@class.inner" ,
|
||||
["at"] = "@comment.outer" ,
|
||||
["am"] = "@conditional.outer",
|
||||
["im"] = "@conditional.inner",
|
||||
["af"] = "@function.outer" ,
|
||||
["if"] = "@function.inner" ,
|
||||
["al"] = "@loop.outer" ,
|
||||
["il"] = "@loop.inner" ,
|
||||
["ap"] = "@parameter.outer" ,
|
||||
["ip"] = "@parameter.inner" ,
|
||||
["is"] = "@scopename.inner" ,
|
||||
["as"] = "@statement.outer" ,
|
||||
},
|
||||
},
|
||||
swap = {
|
||||
enable = true,
|
||||
swap_next = {
|
||||
["<Leader>sb"] = "@block.outer" ,
|
||||
["<Leader>sl"] = "@call.outer" ,
|
||||
["<Leader>sc"] = "@class.outer" ,
|
||||
["<Leader>sf"] = "@function.outer" ,
|
||||
["<Leader>sp"] = "@parameter.inner",
|
||||
["<Leader>ss"] = "@statement.outer",
|
||||
},
|
||||
swap_previous = {
|
||||
["<Leader>sB"] = "@block.outer" ,
|
||||
["<Leader>sL"] = "@call.outer" ,
|
||||
["<Leader>sC"] = "@class.outer" ,
|
||||
["<Leader>sF"] = "@function.outer" ,
|
||||
["<Leader>sP"] = "@parameter.inner",
|
||||
["<Leader>sS"] = "@statement.outer",
|
||||
},
|
||||
},
|
||||
move = {
|
||||
enable = true,
|
||||
set_jumps = true,
|
||||
goto_next_start = {
|
||||
["]m"] = "@function.outer",
|
||||
["]s"] = "@class.outer",
|
||||
},
|
||||
goto_next_end = {
|
||||
["]M"] = "@function.outer",
|
||||
["]S"] = "@class.outer",
|
||||
},
|
||||
goto_previous_start = {
|
||||
["[m"] = "@function.outer",
|
||||
["[s"] = "@class.outer",
|
||||
},
|
||||
goto_previous_end = {
|
||||
["[M"] = "@function.outer",
|
||||
["[S"] = "@class.outer",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -30,11 +78,6 @@ require'nvim-treesitter.configs'.setup {
|
|||
use_virtual_text = true,
|
||||
lint_events = { "BufWrite", "CursorHold" },
|
||||
},
|
||||
}
|
||||
|
||||
require'nvim-treesitter.install'.compilers = { "gcc" }
|
||||
|
||||
require "nvim-treesitter.configs".setup {
|
||||
playground = {
|
||||
enable = true,
|
||||
disable = {},
|
||||
|
|
Loading…
Reference in a new issue