From 62f5f79ffdc8e267ea1e19dc28253dd30159f28b Mon Sep 17 00:00:00 2001 From: Jannik Donker Date: Wed, 22 Apr 2026 19:56:09 +0200 Subject: [PATCH] treesitter fix --- init.lua | 54 ++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 36 insertions(+), 18 deletions(-) diff --git a/init.lua b/init.lua index 3e6e3a6..264d00f 100644 --- a/init.lua +++ b/init.lua @@ -58,24 +58,37 @@ end setup_plugin("oil") setup_plugin("mini.pick") setup_plugin("blink.cmp", { keymap = { preset = "super-tab" } }) -setup_plugin("nvim-treesitter.configs", { - auto_install = true, - highlight = { enable = true }, - indent = { enable = true }, - textobjects = { - select = { - enable = true, - lookahead = true, - keymaps = { - ["af"] = "@function.outer", - ["if"] = "@function.inner", - ["ac"] = "@class.outer", - ["ic"] = "@class.inner", - }, - }, - }, +-- nvim-treesitter main branch: no configs.setup, no auto_install, +-- no highlight.enable. You install parsers and start TS yourself. +local ok_ts, ts = pcall(require, "nvim-treesitter") +if ok_ts then + ts.install({ + "lua", "vim", "vimdoc", "bash", "c", "cpp", "rust", "python", + "javascript", "typescript", "tsx", "svelte", "css", "html", + "json", "toml", "yaml", "markdown", "markdown_inline", + "java", "typst", "vala", + }) +end + +vim.api.nvim_create_autocmd("FileType", { + pattern = "*", + callback = function() + pcall(vim.treesitter.start) + pcall(function() + vim.bo.indentexpr = "v:lua.vim.treesitter.indentexpr()" + end) + end, }) +local ok_tot, _ = pcall(require, "nvim-treesitter-textobjects") +if ok_tot then + local select = require("nvim-treesitter-textobjects.select") + vim.keymap.set({ "x", "o" }, "af", function() select.select_textobject("@function.outer", "textobjects") end) + vim.keymap.set({ "x", "o" }, "if", function() select.select_textobject("@function.inner", "textobjects") end) + vim.keymap.set({ "x", "o" }, "ac", function() select.select_textobject("@class.outer", "textobjects") end) + vim.keymap.set({ "x", "o" }, "ic", function() select.select_textobject("@class.inner", "textobjects") end) +end + setup_plugin("mason") -- Automatically install these tools via Mason local registry = require("mason-registry") @@ -93,7 +106,8 @@ local ensure_installed = { "taplo", "typescript-language-server", "pylsp", - "black" + "black", + "vala" } -- Refresh the registry and install missing tools @@ -133,9 +147,13 @@ end vim.lsp.enable({ "lua_ls", "ts_ls", "svelte", "tailwindcss", "cssls", "bashls", "rust_analyzer", "clangd", "clang-format", "taplo", - "sourcekit", "lemminx", "tinymist", "jsonls", "hls", "pylsp", "black" + "sourcekit", "lemminx", "tinymist", "jsonls", "hls", "ormolu", "pylsp", "black", "vala_ls" }) +vim.lsp.config["sourcekit"] = { + filetypes = { "swift", "objective-c", "objective-c++" } +} + vim.lsp.config["tinymist"] = { cmd = { "tinymist" }, filetypes = { "typst" },