diff --git a/configs/nvim/lazy-lock.json b/configs/nvim/lazy-lock.json index b6b7a5a..35fbf0e 100644 --- a/configs/nvim/lazy-lock.json +++ b/configs/nvim/lazy-lock.json @@ -20,10 +20,10 @@ "nvim-dap-virtual-text": { "branch": "master", "commit": "fbdb48c2ed45f4a8293d0d483f7730d24467ccb6" }, "nvim-lint": { "branch": "master", "commit": "6b46370d02cd001509a765591a3ffc481b538794" }, "nvim-lspconfig": { "branch": "master", "commit": "f47cd681d7cb6048876a2e908b6d8ba1e530d152" }, - "nvim-treesitter": { "branch": "master", "commit": "8d4fdc5e47e2a4e00179e43f56221250ce365973" }, - "nvim-treesitter-context": { "branch": "master", "commit": "6b081ea63a3711243d11540ce28ccdb6f35ecd33" }, - "nvim-treesitter-textobjects": { "branch": "master", "commit": "71385f191ec06ffc60e80e6b0c9a9d5daed4824c" }, - "nvim-ts-context-commentstring": { "branch": "main", "commit": "9c74db656c3d0b1c4392fc89a016b1910539e7c0" }, + "nvim-treesitter": { "branch": "main", "commit": "802195d8f1980db25a7a39a55f9a25df21756c73" }, + "nvim-treesitter-context": { "branch": "master", "commit": "66a9b5fa9e806918b5fe3dba00c6cce7e230abd2" }, + "nvim-treesitter-textobjects": { "branch": "main", "commit": "1b2d85d3de6114c4bcea89ffb2cd1ce9e3a19931" }, + "nvim-ts-context-commentstring": { "branch": "main", "commit": "1b212c2eee76d787bbea6aa5e92a2b534e7b4f8f" }, "nvim-web-devicons": { "branch": "master", "commit": "edbe0a65cfacbbfff6a4a1e98ddd60c28c560509" }, "plenary.nvim": { "branch": "master", "commit": "857c5ac632080dba10aae49dba902ce3abf91b35" }, "render-markdown": { "branch": "main", "commit": "6096cf3608b576a38fd1396227dbc0473091714d" }, diff --git a/configs/nvim/lua/aleidk/options.lua b/configs/nvim/lua/aleidk/options.lua index 816ac44..45a3ca3 100644 --- a/configs/nvim/lua/aleidk/options.lua +++ b/configs/nvim/lua/aleidk/options.lua @@ -163,6 +163,7 @@ vim.lsp.enable({ "bashls", "biome", "fish_lsp", + "gleam", "hyprls", "intelephense", "jsonls", diff --git a/configs/nvim/lua/aleidk/plugins/treesitter.lua b/configs/nvim/lua/aleidk/plugins/treesitter.lua index 65a0450..2a63a3d 100644 --- a/configs/nvim/lua/aleidk/plugins/treesitter.lua +++ b/configs/nvim/lua/aleidk/plugins/treesitter.lua @@ -1,50 +1,60 @@ return { - { - "nvim-treesitter/nvim-treesitter", - lazy = false, - branch = "master", - dependencies = { - { - "JoosepAlviste/nvim-ts-context-commentstring", - opts = { - enable_autocmd = false, - }, - }, - { "nvim-treesitter/nvim-treesitter-context" }, - }, - build = ":TSUpdate", - opts = { - auto_install = true, - highlight = { enable = true }, - indent = { enable = true }, - }, - }, - { - "nvim-treesitter/nvim-treesitter-textobjects", - dependencies = { "nvim-treesitter", }, - config = function() - require 'nvim-treesitter.configs'.setup({ - textobjects = { - move = { - enable = true, - set_jumps = true, -- whether to set jumps in the jumplist - goto_next = { - ["]]"] = { query = { "@block.outer", "@function.outer", "@class.outer", } }, - }, - goto_previous = { - ["[["] = { query = { "@block.outer", "@function.outer", "@class.outer", } }, - } - }, - }, - }) + { + "nvim-treesitter/nvim-treesitter", + lazy = false, + branch = "main", + dependencies = { + { + "JoosepAlviste/nvim-ts-context-commentstring", + opts = { + enable_autocmd = false, + }, + }, + { "nvim-treesitter/nvim-treesitter-context" }, + }, + build = ":TSUpdate", + opts = { + auto_install = true, + highlight = { enable = true }, + indent = { enable = true }, + }, + init = function() + -- HACK: for filetypes that doesn't start treesitter hightlight on it's own + vim.api.nvim_create_autocmd("FileType", { + pattern = { "gleam" }, + callback = function() + vim.treesitter.start() + end, + }) + end, + }, + { + "nvim-treesitter/nvim-treesitter-textobjects", + dependencies = { "nvim-treesitter" }, + branch = "main", + config = function() + local ts_obj = require("nvim-treesitter-textobjects") - local ts_repeat_move = require "nvim-treesitter.textobjects.repeatable_move" + ts_obj.setup({ + move = { + set_jumps = true, + }, + }) - -- Repeat movement with ; and , - -- ensure ; goes forward and , goes backward regardless of the last direction - vim.keymap.set({ "n", "x", "o" }, ";", ts_repeat_move.repeat_last_move_previous) - vim.keymap.set({ "n", "x", "o" }, ",", ts_repeat_move.repeat_last_move_next) - end - } + vim.keymap.set({ "n", "x", "o" }, "]]", function() + ts_obj.move.goto_next({ "@block.outer", "@function.outer", "@class.outer" }, "textobjects") + end) + vim.keymap.set({ "n", "x", "o" }, "[[", function() + ts_obj.move.goto_previous({ "@block.outer", "@function.outer", "@class.outer" }, "textobjects") + end) + + local ts_repeat_move = require("nvim-treesitter-textobjects.repeatable_move") + + -- Repeat movement with ; and , + -- ensure ; goes forward and , goes backward regardless of the last direction + vim.keymap.set({ "n", "x", "o" }, ";", ts_repeat_move.repeat_last_move_opposite) + vim.keymap.set({ "n", "x", "o" }, ",", ts_repeat_move.repeat_last_move) + end, + }, }