aboutsummaryrefslogtreecommitdiff
path: root/neovim/.config/nvim/lua/plugins/treesitter.lua
diff options
context:
space:
mode:
authordavidpkj <davidpenkow1@gmail.com>2022-12-03 22:26:26 +0100
committerdavidpkj <davidpenkow1@gmail.com>2022-12-03 22:26:26 +0100
commit5d4a749b7c51649bcd3953cd1686856408d08121 (patch)
treed0ddab7d5ee206e9b4403d4f177d942ec1608aa0 /neovim/.config/nvim/lua/plugins/treesitter.lua
parent4f7ccffecdfa36c5e531654b8eec44199935d497 (diff)
Merge in dotfiles
Diffstat (limited to 'neovim/.config/nvim/lua/plugins/treesitter.lua')
-rw-r--r--neovim/.config/nvim/lua/plugins/treesitter.lua126
1 files changed, 126 insertions, 0 deletions
diff --git a/neovim/.config/nvim/lua/plugins/treesitter.lua b/neovim/.config/nvim/lua/plugins/treesitter.lua
new file mode 100644
index 0000000..e3d8fbb
--- /dev/null
+++ b/neovim/.config/nvim/lua/plugins/treesitter.lua
@@ -0,0 +1,126 @@
+-- Treesitter folds
+-- vim.o.foldmethod = "expr"
+-- vim.o.foldexpr = "nvim_treesitter#foldexpr()"
+-- vim.o.foldlevelstart = 99
+
+require("nvim-treesitter.configs").setup({
+ -- nvim-treesitter/nvim-treesitter (self config)
+ auto_install = true,
+ ensure_installed = {
+ "c",
+ "lua",
+ "rust",
+ "go",
+ "javascript",
+ "typescript",
+ "tsx",
+ "markdown",
+ "markdown_inline",
+ "html",
+ "css",
+ "json",
+ "bash",
+ },
+ highlight = {
+ enable = true,
+ -- Setting this to true will run `:h syntax` and tree-sitter at the same time.
+ -- Set this to `true` if you depend on "syntax" being enabled (like for indentation).
+ -- Using this option may slow down your editor, and you may see some duplicate highlights.
+ -- Instead of true it can also be a list of languages
+ additional_vim_regex_highlighting = false,
+ },
+ indent = {
+ enable = true,
+ },
+ incremental_selection = {
+ enable = true,
+ keymaps = {
+ init_selection = "gs",
+ -- NOTE: These are visual mode mappings
+ node_incremental = "gs",
+ node_decremental = "gS",
+ scope_incremental = "<leader>gc",
+ },
+ },
+ -- nvim-treesitter/nvim-treesitter-textobjects
+ textobjects = {
+ select = {
+ enable = true,
+ -- Automatically jump forward to textobj, similar to targets.vim
+ lookahead = true,
+ keymaps = {
+ -- You can use the capture groups defined in textobjects.scm
+ ["af"] = "@function.outer",
+ ["if"] = "@function.inner",
+ ["ac"] = "@class.outer",
+ ["ic"] = "@class.inner",
+ ["al"] = "@loop.outer",
+ ["il"] = "@loop.inner",
+ ["aa"] = "@parameter.outer",
+ ["ia"] = "@parameter.inner",
+ ["uc"] = "@comment.outer",
+
+ -- Or you can define your own textobjects like this
+ -- ["iF"] = {
+ -- python = "(function_definition) @function",
+ -- cpp = "(function_definition) @function",
+ -- c = "(function_definition) @function",
+ -- java = "(method_declaration) @function",
+ -- },
+ },
+ },
+ swap = {
+ enable = true,
+ swap_next = {
+ ["<leader>a"] = "@parameter.inner",
+ ["<leader>f"] = "@function.outer",
+ ["<leader>e"] = "@element",
+ },
+ swap_previous = {
+ ["<leader>A"] = "@parameter.inner",
+ ["<leader>F"] = "@function.outer",
+ ["<leader>E"] = "@element",
+ },
+ },
+ move = {
+ enable = true,
+ set_jumps = true, -- whether to set jumps in the jumplist
+ goto_next_start = {
+ ["]f"] = "@function.outer",
+ ["]]"] = "@class.outer",
+ },
+ goto_next_end = {
+ ["]F"] = "@function.outer",
+ ["]["] = "@class.outer",
+ },
+ goto_previous_start = {
+ ["[f"] = "@function.outer",
+ ["[["] = "@class.outer",
+ },
+ goto_previous_end = {
+ ["[F"] = "@function.outer",
+ ["[]"] = "@class.outer",
+ },
+ },
+ },
+ -- windwp/nvim-ts-autotag
+ autotag = {
+ enable = true,
+ },
+ -- nvim-treesitter/playground
+ playground = {
+ enable = true,
+ disable = {},
+ updatetime = 25, -- Debounced time for highlighting nodes in the playground from source code
+ persist_queries = false, -- Whether the query persists across vim sessions
+ },
+ -- nvim-treesitter/nvim-treesitter-refactor
+ refactor = {
+ highlight_definitions = { enable = true },
+ -- highlight_current_scope = { enable = false },
+ },
+ context_commentstring = {
+ enable = true,
+ enable_autocmd = false,
+ },
+})